X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Ftable.c;h=be2c2136f945f0262c0295527856855147c6e613;hb=3c5121dc68726f596565894f831e4fa311c99c64;hp=cb06a3f1f910db84b1d4267652ddffdc62aa6a5c;hpb=b74d09af5e07f954c18e7cdb8aca3af47fa10208;p=pspp-builds.git diff --git a/src/output/table.c b/src/output/table.c index cb06a3f1..be2c2136 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,7 @@ #include "gettext.h" #define _(msgid) gettext (msgid) -struct som_table_class tab_table_class; +const struct som_table_class tab_table_class; static char *command_name; /* Returns the font to use for a cell with the given OPTIONS. */ @@ -71,15 +72,9 @@ tab_create (int nc, int nr, int reallocable UNUSED) t->rh = pool_nmalloc (t->container, nc, nr + 1); memset (t->rh, 0, nc * (nr + 1)); - t->hrh = pool_nmalloc (t->container, nr + 1, sizeof *t->hrh); - memset (t->hrh, 0, sizeof *t->hrh * (nr + 1)); - t->rv = pool_nmalloc (t->container, nr, nc + 1); memset (t->rv, UCHAR_MAX, nr * (nc + 1)); - t->wrv = pool_nmalloc (t->container, nc + 1, sizeof *t->wrv); - memset (t->wrv, 0, sizeof *t->wrv * (nc + 1)); - t->dim = NULL; t->w = t->h = NULL; t->col_ofs = t->row_ofs = 0; @@ -92,6 +87,7 @@ void tab_destroy (struct tab_table *t) { assert (t != NULL); + free (t->title); pool_destroy (t->container); } @@ -311,7 +307,7 @@ tab_box (struct tab_table *t, int f_h, int f_v, int i_h, int i_v, x2, t->col_ofs, x2 + t->col_ofs, y2, t->row_ofs, y2 + t->row_ofs, t->nc, t->nr); - abort (); + NOT_REACHED (); } #endif @@ -440,10 +436,10 @@ tab_natural_width (struct tab_table *t, struct outp_driver *d, int c) if (width == 0) { - width = d->prop_em_width * 8; -#if DEBUGGING - printf ("warning: table column %d contains no data.\n", c); -#endif + /* FIXME: This is an ugly kluge to compensate for the fact + that we don't let joined cells contribute to column + widths. */ + width = d->prop_em_width * 8; } { @@ -807,15 +803,15 @@ tab_offset (struct tab_table *t, int col, int row) assert (t != NULL); #if DEBUGGING - if (row < -1 || row >= t->nr) + if (row < -1 || row > t->nr) { printf ("tab_offset(): row=%d in %d-row table\n", row, t->nr); - abort (); + NOT_REACHED (); } - if (col < -1 || col >= t->nc) + if (col < -1 || col > t->nc) { printf ("tab_offset(): col=%d in %d-column table\n", col, t->nc); - abort (); + NOT_REACHED (); } #endif @@ -842,7 +838,7 @@ tab_next_row (struct tab_table *t) static struct tab_table *t; static struct outp_driver *d; -int tab_hit; +static int tab_hit; /* Set the current table to TABLE. */ static void @@ -857,6 +853,8 @@ tabi_table (struct som_entity *table) assert (t->w == NULL && t->h == NULL); t->w = pool_nalloc (t->container, t->nc, sizeof *t->w); t->h = pool_nalloc (t->container, t->nr, sizeof *t->h); + t->hrh = pool_nmalloc (t->container, t->nr + 1, sizeof *t->hrh); + t->wrv = pool_nmalloc (t->container, t->nc + 1, sizeof *t->wrv); } /* Returns the line style to use for spacing purposes for a rule @@ -874,7 +872,7 @@ rule_to_spacing_type (unsigned char type) case TAL_2: return OUTP_L_DOUBLE; default: - abort (); + NOT_REACHED (); } } @@ -1222,7 +1220,7 @@ tabi_render (int c0, int r0, int c1, int r1) y = render_rows (y, c0, c1, (t->nr - t->b) * 2, t->nr * 2 + 1); } -struct som_table_class tab_table_class = +const struct som_table_class tab_table_class = { tabi_table, tabi_driver, @@ -1260,7 +1258,7 @@ translate_justification (unsigned int opt) case TAB_CENTER: return OUTP_CENTER; default: - abort (); + NOT_REACHED (); } } @@ -1279,7 +1277,7 @@ rule_to_draw_type (unsigned char type) case TAL_2: return OUTP_L_DOUBLE; default: - abort (); + NOT_REACHED (); } }