render: Fix cells spanning otherwise completely empty rows/columns.
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 26 Oct 2010 04:45:42 +0000 (21:45 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 26 Oct 2010 04:46:00 +0000 (21:46 -0700)
When adjacent rows or columns contain only spanned cells and no rules give
the rows or columns a natural minimum height or width, this triggers a
special case in distribute_spanned_width().  This special case had not been
tested and (therefore) was broken.  This commit fixes the problem and adds
test cases to prevent it from recurring.

Bug #31346.

src/output/render.c
tests/output/render.at

index 094e68799cf93b7e72be846075f8e04da80ec499..6722a13dc2e1100a99fc0f3d8b971a14150e665e 100644 (file)
@@ -359,9 +359,14 @@ distribute_spanned_width (int width,
      w1 by the common denominator of all three calculations (d), dividing that
      out in the column width calculation, and then keeping the remainder for
      the next iteration.
      w1 by the common denominator of all three calculations (d), dividing that
      out in the column width calculation, and then keeping the remainder for
      the next iteration.
+
+     (We actually compute the unspanned width of a column as twice the
+     unspanned width, plus the width of the rule on the left, plus the width of
+     the rule on the right.  That way each rule contributes to both the cell on
+     its left and on its right.)
   */
   d0 = n;
   */
   d0 = n;
-  d1 = total_unspanned * 2.0;
+  d1 = 2.0 * (total_unspanned > 0 ? total_unspanned : 1.0);
   d = d0 * d1;
   if (total_unspanned > 0)
     d *= 2.0;
   d = d0 * d1;
   if (total_unspanned > 0)
     d *= 2.0;
index 902a5b6be6072bf1b0cd9f3de6d4c3162465acb9..a39f688d68af2103ac124563564d9e2f1df4c395 100644 (file)
@@ -292,6 +292,36 @@ AT_CHECK([render-test input], [0], [dnl
 ])
 AT_CLEANUP
 
 ])
 AT_CLEANUP
 
+dnl This checks for bug #31346, a segmentation fault that surfaced
+dnl when two or more rows  had no unspanned cells and no rules.
+AT_SETUP([joined rows only, no rules])
+AT_KEYWORDS([render rendering])
+AT_DATA([input], [2 2
+2*1 ab\ncd\nef
+2*1 hij\nklm\nnop
+])
+AT_CHECK([render-test input], [0], [dnl
+abhij
+cdklm
+efnop
+])
+AT_CLEANUP
+
+AT_SETUP([joined columns only, no rules])
+AT_KEYWORDS([render rendering])
+AT_DATA([input], [2 2
+1*2 abc\ndef
+1*2 hij\nklm\nnop
+])
+AT_CHECK([render-test input], [0], [dnl
+abc
+def
+hij
+klm
+nop
+])
+AT_CLEANUP
+
 AT_SETUP([5 big narrow cells])
 AT_KEYWORDS([render rendering])
 AT_DATA([input], [1 5
 AT_SETUP([5 big narrow cells])
 AT_KEYWORDS([render rendering])
 AT_DATA([input], [1 5