render: Fix bug measuring spanned cells.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 28 Sep 2013 20:55:14 +0000 (13:55 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 28 Sep 2013 20:55:14 +0000 (13:55 -0700)
src/output/render.c
tests/output/render.at

index 8332b85d98ecb51e1ad3849eb6072eab5ceec130..a91e1f7b799570aa4a29689b984fdf17af33758c 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -384,7 +384,7 @@ distribute_spanned_width (int width,
           w += width * unspanned * d0;
         }
 
-      rows[x].width = w / d;
+      rows[x].width = MAX (rows[x].width, w / d);
       w -= rows[x].width * d;
     }
 }
index 230299223f349bb62738cbf2cac6ae34daa8043a..c12cb91753d737d9da759c60fd7499f1bfd72836 100644 (file)
@@ -1831,3 +1831,32 @@ AT_CHECK([render-test --width=15 --length=15 input], [0], [dnl
 +-+-+-----+
 ])
 AT_CLEANUP
+
+# There was a bug that, when multiple cells spanned a single column
+# (or row), only the dimensions of the cell nearest the bottom of the
+# table were actually considered.  This checks for regression.  (This
+# problem was most easily observed with SYSFILE INFO, which uses lots
+# of spanned cells).
+#
+# Without the fix, the output looks like this:
+# +-------+
+# | A long|
+# |   text|
+# |string.|
+# +-------+
+# |shorter|
+AT_SETUP([multiple spanned cells all contribute to dimensions])
+AT_KEYWORDS([render rendering])
+AT_DATA([input], [dnl
+2 2
+1*2 @A long text string.
+1*2 @shorter
+])
+AT_CHECK([render-test --width=30 --length=15 input], [0], [dnl
++-------------------+
+|A long text string.|
++-------------------+
+|            shorter|
++-------------------+
+])
+AT_CLEANUP