source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Simplify the code building lists of spans, no output change
@ 2021-10-17 20:48 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2021-10-17 20:48 UTC (permalink / raw)
  To: source

Log Message:
-----------
Simplify the code building lists of spans, no output change intended.

A comment in the code claimed that the list of spans would be sorted,
but the sorting did not actually work.  The layout "LSSS,LLSL" resulted
in the list "0-3, 1-2", whereas the layout "LLSL,LSSS" resulted
in the list "1-2, 0-3".  Since sorting serves no purpose, just leave 
the list unsorted.

Modified Files:
--------------
    mandoc:
        out.c

Revision Data
-------------
Index: out.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/out.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -Lout.c -Lout.c -u -p -r1.83 -r1.84
--- out.c
+++ out.c
@@ -149,7 +149,6 @@ tblcalc(struct rofftbl *tbl, const struc
 		 * to data cells in the data section.
 		 */
 
-		gp = &first_group;
 		for (dp = sp->first; dp != NULL; dp = dp->next) {
 			icol = dp->layout->col;
 			while (maxcol < icol + dp->hspans)
@@ -190,16 +189,16 @@ tblcalc(struct rofftbl *tbl, const struc
 				continue;
 
 			/*
-			 * Build an ordered, singly linked list
+			 * Build a singly linked list
 			 * of all groups of columns joined by spans,
 			 * recording the minimum width for each group.
 			 */
 
-			while (*gp != NULL && ((*gp)->startcol < icol ||
-			    (*gp)->endcol < icol + dp->hspans))
+			gp = &first_group;
+			while (*gp != NULL && ((*gp)->startcol != icol ||
+			    (*gp)->endcol != icol + dp->hspans))
 				gp = &(*gp)->next;
-			if (*gp == NULL || (*gp)->startcol > icol ||
-                            (*gp)->endcol > icol + dp->hspans) {
+			if (*gp == NULL) {
 				g = mandoc_malloc(sizeof(*g));
 				g->next = *gp;
 				g->wanted = width;
@@ -554,5 +553,7 @@ tblcalc_number(struct rofftbl *tbl, stru
 		col->nwidth = totsz;
 	if (col->nwidth > col->width)
 		col->width = col->nwidth;
+	fprintf(stderr, "N=%zu D=%zu I=%zu T=%zu %s\n",
+	    col->nwidth, col->decimal, intsz, totsz, dp->string);
 	return totsz;
 }
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-17 20:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-17 20:48 mandoc: Simplify the code building lists of spans, no output change schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).