table: Get rid of TAL_GAP.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 9 Dec 2018 20:46:17 +0000 (12:46 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 25 Dec 2018 06:02:57 +0000 (22:02 -0800)
This is only necessary in pathological cases.  Those cases don't really
come up in normal usage and as PSPP shifts toward pivot tables they won't
come up at all.

16 files changed:
src/language/dictionary/split-file.c
src/language/dictionary/sys-file-info.c
src/language/stats/crosstabs.q
src/language/stats/frequencies.c
src/language/stats/t-test-indep.c
src/language/stats/t-test-one-sample.c
src/language/stats/t-test-paired.c
src/output/ascii.c
src/output/cairo.c
src/output/html.c
src/output/render.c
src/output/render.h
src/output/tab.c
src/output/table-casereader.c
src/output/table.h
tests/output/render.at

index 34949c5d15eaacb41ea8330fcaf0ecd88e998543..fda5cfd00c6a71e591cdaa680cb528c4bff46f9d 100644 (file)
@@ -77,8 +77,6 @@ output_split_file_values (const struct dataset *ds, const struct ccase *c)
     return;
 
   t = tab_create (3, split_cnt + 1);
-  tab_vline (t, TAL_GAP, 1, 0, split_cnt);
-  tab_vline (t, TAL_GAP, 2, 0, split_cnt);
   tab_text (t, 0, 0, TAB_NONE, _("Variable"));
   tab_text (t, 1, 0, TAB_LEFT, _("Value"));
   tab_text (t, 2, 0, TAB_LEFT, _("Label"));
index b0c35ec0ce47f9b9206ce1cc2170c226d878e28e..8f0a4c2b69297f624ab71b39be4e5ed6ea6046e1 100644 (file)
@@ -173,8 +173,7 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED)
 
   t = tab_create (2, 11 + (info.product_ext != NULL));
   r = 0;
-  tab_vline (t, TAL_GAP, 1, 0, 8);
-
+  
   tab_text (t, 0, r, TAB_LEFT, _("File:"));
   tab_text (t, 1, r++, TAB_LEFT, fh_get_file_name (h));
 
index 08a182a456a4836d61d1fa9d2f847921f8ae97d3..c2f34c2df213d6a19866edbf87a8e8cf387fe7e4 100644 (file)
@@ -1446,8 +1446,6 @@ submit (struct pivot_table *pt, struct tab_table *t)
   tab_box (t, TAL_2, TAL_2, -1, -1, 0, 0, tab_nc (t) - 1, tab_nr (t) - 1);
   tab_box (t, -1, -1, -1, TAL_1, tab_l (t), tab_t (t) - 1, tab_nc (t) - 1,
           tab_nr (t) - 1);
-  tab_box (t, -1, -1, -1, TAL_GAP, 0, tab_t (t), tab_l (t) - 1,
-          tab_nr (t) - 1);
   tab_vline (t, TAL_2, tab_l (t), 0, tab_nr (t) - 1);
 
   tab_submit (t);
index 0a1a060d26c5ff440b9031a79b30927661f8aba4..ff29b6600abf97d3e94ca24f41ad4d58183c4e0e 100644 (file)
@@ -1588,7 +1588,6 @@ dump_statistics (const struct frq_proc *frq, const struct var_freqs *vf,
   tab_box (t, TAL_1, TAL_1, -1, -1 , 0 , 0 , 2, tab_nr(t) - 1) ;
 
   tab_vline (t, TAL_1 , 2, 0, tab_nr(t) - 1);
-  tab_vline (t, TAL_GAP , 1, 0, tab_nr(t) - 1 ) ;
 
   for (i = 0; i < FRQ_ST_count; i++)
     {
index a2e0d4d35557777924a5ddf132af32c9e8564a14..e4e42433080389534e7782154dbb0775e83cc846 100644 (file)
@@ -205,7 +205,6 @@ indep_summary (const struct tt *tt, struct indep_samples *is, const struct pair_
   tab_box (t, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols - 1, rows - 1);
   tab_hline (t, TAL_2, 0, cols - 1, 1);
 
-  tab_vline (t, TAL_GAP, 1, 0, rows - 1);
   tab_title (t, _("Group Statistics"));
   tab_text  (t, 1, 0, TAB_CENTER | TAT_TITLE, var_to_string (is->gvar));
   tab_text  (t, 2, 0, TAB_CENTER | TAT_TITLE, _("N"));
index 73356e4e87395065ee502b2dd5a085abb1883040..fdcef55937f5faf20a67e49e7e5c37fdbe485aaa 100644 (file)
@@ -90,7 +90,6 @@ one_sample_test (const struct tt *tt, const struct one_samp *os)
                          _("%g%% Confidence Interval of the Difference"),
                          tt->confidence * 100.0);
 
-  tab_vline (t, TAL_GAP, 6, 1, 1);
   tab_hline (t, TAL_1, 5, 6, 2);
   tab_text (t, 1, 2, TAB_CENTER | TAT_TITLE, _("t"));
   tab_text (t, 2, 2, TAB_CENTER | TAT_TITLE, _("df"));
index 94e7a8c40920ae12da01da84b5957ae6c741dea1..4935e9a8cb866bd112d5d6118050af97f016ce46 100644 (file)
@@ -300,7 +300,6 @@ paired_test (const struct tt *tt, const struct paired_samp *os)
                          _("%g%% Confidence Interval of the Difference"),
                          tt->confidence * 100.0);
 
-  tab_vline (t, TAL_GAP, 6, 1, 1);
   tab_hline (t, TAL_1, 5, 6, 2);
   tab_text (t, 7, 2, TAB_CENTER | TAT_TITLE, _("t"));
   tab_text (t, 8, 2, TAB_CENTER | TAT_TITLE, _("df"));
index ae5e25bef4d32482026d456caade19dda7ae41cc..f53feeaa915eb7d6b1621d6c6281e4ab5548bdd0 100644 (file)
@@ -449,6 +449,7 @@ ascii_output_table_item (struct ascii_driver *a,
     }
   for (i = 0; i < TABLE_N_AXES; i++)
     params.min_break[i] = a->min_break[i];
+  params.supports_margins = false;
 
   if (a->file == NULL && !ascii_open_page (a))
     return;
index 404d9a8fd257297d456fe9ecd810ec1e4510e3e6..3b87aeb64dbde07710167fe7e0fdb6ad1c9e0a5c 100644 (file)
@@ -400,6 +400,7 @@ xr_set_cairo (struct xr_driver *xr, cairo_t *cairo)
 
       for (i = 0; i < TABLE_N_AXES; i++)
         xr->params->min_break[i] = xr->min_break[i];
+      xr->params->supports_margins = true;
     }
 
   cairo_set_source_rgb (xr->cairo, xr->fg.red, xr->fg.green, xr->fg.blue);
index 6dc2ffe7379b00a5018946ace0365af5fec1f32e..6e5181d7da0340134942749643f05d7cede98c3b 100644 (file)
@@ -497,24 +497,24 @@ html_output_table (struct html_driver *html, const struct table_item *item)
              n_borders = 0;
 
              top = table_get_rule (t, TABLE_VERT, x, y);
-             if (top > TAL_GAP)
+             if (top > TAL_0)
                put_border (html->file, n_borders++, top, "top");
 
              if (y + rowspan == table_nr (t))
                {
                  bottom = table_get_rule (t, TABLE_VERT, x, y + rowspan);
-                 if (bottom > TAL_GAP)
+                 if (bottom > TAL_0)
                    put_border (html->file, n_borders++, bottom, "bottom");
                }
 
              left = table_get_rule (t, TABLE_HORZ, x, y);
-             if (left > TAL_GAP)
+             if (left > TAL_0)
                put_border (html->file, n_borders++, left, "left");
 
              if (x + colspan == table_nc (t))
                {
                  right = table_get_rule (t, TABLE_HORZ, x + colspan, y);
-                 if (right > TAL_GAP)
+                 if (right > TAL_0)
                    put_border (html->file, n_borders++, right, "right");
                }
 
index 1dc8f2e2816565d13b5ddbfd93eae2aa97372864..6c7f3bca51e907239bd544db6a8897037190aac1 100644 (file)
@@ -515,7 +515,6 @@ rule_to_render_type (unsigned char type)
   switch (type)
     {
     case TAL_0:
-    case TAL_GAP:
       return RENDER_LINE_NONE;
     case TAL_1:
       return RENDER_LINE_SINGLE;
@@ -544,10 +543,21 @@ measure_rule (const struct render_params *params, const struct table *table,
   for (d[b] = 0; d[b] < table->n[b]; d[b]++)
     rules |= 1u << table_get_rule (table, a, d[H], d[V]);
 
+  /* Turn off TAL_NONE because it has width 0 and we needn't bother.  However,
+     if the device doesn't support margins, make sure that there is at least a
+     small gap between cells (but we don't need any at the left or right edge
+     of the table). */
+  if (rules & (1u << TAL_0))
+    {
+      rules &= ~(1u << TAL_0);
+      if (z > 0 && z < table->n[a] && !params->supports_margins && a == H)
+        rules |= 1u << TAL_1;
+    }
+
   /* Calculate maximum width of the rules that are present. */
   width = 0;
   if (rules & (1u << TAL_1)
-      || (z > 0 && z < table->n[a] && rules & (1u << TAL_GAP)))
+      || (z > 0 && z < table->n[a] && rules & (1u << TAL_0)))
     width = params->line_widths[a][RENDER_LINE_SINGLE];
   if (rules & (1u << TAL_2))
     width = MAX (width, params->line_widths[a][RENDER_LINE_DOUBLE]);
index ed5bb1eaf41aefd4c7386fdeb81eb9495745876e..d1f085fb2c3b5232d60c780b001973a7549dcfd4 100644 (file)
@@ -128,6 +128,8 @@ struct render_params
        across two pages.  (Joined cells may always be broken at join
        points.) */
     int min_break[TABLE_N_AXES];
+
+    bool supports_margins;
   };
 
 /* An iterator for breaking render_pages into smaller chunks. */
index 78bde01e5dcb1a36de59556dbd7af5140919b8ae..af43d6c2bcdb59a3e2a7d4b27c391742ec3ac8eb 100644 (file)
@@ -99,13 +99,12 @@ tab_create (int nc, int nr)
   memset (t->ct, 0, nc * nr);
 
   t->rh = pool_nmalloc (t->container, nc, nr + 1);
-  memset (t->rh, 0, nc * (nr + 1));
+  memset (t->rh, TAL_0, nc * (nr + 1));
 
   t->rv = pool_nmalloc (t->container, nr, nc + 1);
-  memset (t->fmtmap, 0, sizeof (*t->fmtmap) * n_RC);
-
-  memset (t->rv, TAL_GAP, nr * (nc + 1));
+  memset (t->rv, TAL_0, nr * (nc + 1));
 
+  memset (t->fmtmap, 0, sizeof (*t->fmtmap) * n_RC);
   t->fmtmap[RC_PVALUE] = ugly[RC_PVALUE];
   t->fmtmap[RC_INTEGER] = ugly[RC_INTEGER];
   t->fmtmap[RC_OTHER] = *settings_get_format ();
@@ -204,7 +203,7 @@ tab_realloc (struct tab_table *t, int nc, int nr)
         {
           memset (&t->rh[nc * (tab_nr (t) + 1)], TAL_0,
                   (nr - tab_nr (t)) * nc);
-          memset (&t->rv[(nc + 1) * tab_nr (t)], TAL_GAP,
+          memset (&t->rv[(nc + 1) * tab_nr (t)], TAL_0,
                   (nr - tab_nr (t)) * (nc + 1));
         }
     }
index 36f74f20c4b55c07309c102572efa3693b1da8e5..5acb1a928d98aa72e3ffb1ea8bfb1f17a1485d85 100644 (file)
@@ -148,7 +148,7 @@ table_casereader_get_rule (const struct table *t, enum table_axis axis,
   if (axis == TABLE_VERT)
     return tc->heading != NULL && y == 1 ? TAL_1 : TAL_0;
   else
-    return TAL_GAP;
+    return TAL_0;
 }
 
 static const struct table_class table_casereader_class =
index 09e5041a3eeed7f62b0897bfea25e46fa36ba5a3..d93c69e38cdb31b339353ab9d80f818ada96fa87 100644 (file)
@@ -68,7 +68,6 @@ enum
 enum
   {
     TAL_0,                     /* No line. */
-    TAL_GAP,                    /* Spacing but no line. */
     TAL_1,                     /* Single line. */
     TAL_2,                     /* Double line. */
     N_LINES
index e1d6fcea365ca74d7647e6f2989f592527fabee7..3a12da4c2cf2bc605b087cdaf0eb4ff4d221fb75 100644 (file)
@@ -401,11 +401,11 @@ AT_DATA([input], [2 2
 1*2 hij\nklm\nnop
 ])
 AT_CHECK([render-test input], [0], [dnl
-abc
-def
-hij
-klm
-nop
+ abc
+ def
+ hij
+ klm
+ nop
 ])
 AT_CLEANUP
 
@@ -2775,10 +2775,10 @@ AT_DATA([input], [dnl
 1*2 @shorter
 ])
 AT_CHECK([render-test --width=30 --length=15 input], [0], [dnl
-+-------------------+
-|A long text string.|
-+-------------------+
-|            shorter|
-+-------------------+
++--------------------+
+| A long text string.|
++--------------------+
+|             shorter|
++--------------------+
 ])
 AT_CLEANUP