X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftab.c;h=82df4cd23ab8d54d6e46327faee124eeaaa5597b;hb=9b4b94c6d3b5fd98bf396e23d015380b87d2d296;hp=8672bd76be8378bbef60864b55d3de9a55684f09;hpb=63b39c9b76b2db4c9ac79050f256af8207802b7f;p=pspp diff --git a/src/tab.c b/src/tab.c index 8672bd76be..82df4cd23a 100644 --- a/src/tab.c +++ b/src/tab.c @@ -20,10 +20,10 @@ #include #include "tab.h" #include -#include #include #include #include +#include "error.h" #include "alloc.h" #include "command.h" #include "format.h" @@ -115,6 +115,7 @@ tab_destroy (struct tab_table *t) { assert (t != NULL); pool_destroy (t->container); + t=0; } /* Sets the width and height of a table, in columns and rows, @@ -251,11 +252,6 @@ tab_vline (struct tab_table *t, int style, int x, int y1, int y2) int y; assert (t != NULL); - assert (x > 0); - assert (x < t->nc); - assert (y1 >= 0); - assert (y2 >= y1); - assert (y2 <= t->nr); #if GLOBAL_DEBUGGING if (x + t->col_ofs < 0 || x + t->col_ofs > t->nc @@ -276,6 +272,12 @@ tab_vline (struct tab_table *t, int style, int x, int y1, int y2) y1 += t->row_ofs; y2 += t->row_ofs; + assert (x > 0); + assert (x < t->nc); + assert (y1 >= 0); + assert (y2 >= y1); + assert (y2 <= t->nr); + if (style != -1) { if ((style & TAL_SPACING) == 0) @@ -294,16 +296,16 @@ tab_hline (struct tab_table * t, int style, int x1, int x2, int y) assert (t != NULL); + x1 += t->col_ofs; + x2 += t->col_ofs; + y += t->row_ofs; + assert (y >= 0); assert (y < t->nr); assert (x2 >= x1 ); assert (x1 >= 0 ); assert (x2 < t->nc); - x1 += t->col_ofs; - x2 += t->col_ofs; - y += t->row_ofs; - if (style != -1) { if ((style & TAL_SPACING) == 0) @@ -325,13 +327,6 @@ tab_box (struct tab_table *t, int f_h, int f_v, int i_h, int i_v, { assert (t != NULL); - assert (x2 >= x1); - assert (y2 >= y1); - assert (x1 >= 0); - assert (y1 >= 0); - assert (x2 < t->nc); - assert (y2 < t->nr); - #if GLOBAL_DEBUGGING if (x1 + t->col_ofs < 0 || x1 + t->col_ofs >= t->nc || x2 + t->col_ofs < 0 || x2 + t->col_ofs >= t->nc @@ -354,6 +349,13 @@ tab_box (struct tab_table *t, int f_h, int f_v, int i_h, int i_v, y1 += t->row_ofs; y2 += t->row_ofs; + assert (x2 >= x1); + assert (y2 >= y1); + assert (x1 >= 0); + assert (y1 >= 0); + assert (x2 < t->nc); + assert (y2 < t->nr); + if (f_h != -1) { int x; @@ -569,7 +571,6 @@ tab_value (struct tab_table *table, int c, int r, unsigned char opt, const union value *v, const struct fmt_spec *f) { char *contents; - union value temp_val; assert (table != NULL && v != NULL && f != NULL); #if GLOBAL_DEBUGGING @@ -590,11 +591,6 @@ tab_value (struct tab_table *table, int c, int r, unsigned char opt, ls_init (&table->cc[c + r * table->cf], contents, f->w); table->ct[c + r * table->cf] = opt; - if (formats[f->type].cat & FCAT_STRING) - { - temp_val.c = (char *) v->s; - v = &temp_val; - } data_out (contents, f, v); } @@ -608,9 +604,15 @@ tab_float (struct tab_table *table, int c, int r, unsigned char opt, char buf[40], *cp; struct fmt_spec f; + union value double_value; assert (table != NULL && w <= 40); + assert (c >= 0); + assert (c < table->nc); + assert (r >= 0); + assert (r < table->nr); + f.type = FMT_F; f.w = w; f.d = d; @@ -629,7 +631,9 @@ tab_float (struct tab_table *table, int c, int r, unsigned char opt, } #endif - data_out (buf, &f, (union value *) &val); + double_value.f = val; + data_out (buf, &f, &double_value); + cp = buf; while (isspace ((unsigned char) *cp) && cp < &buf[w]) cp++; @@ -686,12 +690,12 @@ tab_joint_text (struct tab_table *table, int x1, int y1, int x2, int y2, assert (table != NULL && text != NULL); - assert (x1 >= 0); - assert (y1 >= 0); + assert (x1 + table->col_ofs >= 0); + assert (y1 + table->row_ofs >= 0); assert (y2 >= y1); assert (x2 >= x1); - assert (y2 < table->nr); - assert (x2 < table->nc); + assert (y2 + table->row_ofs < table->nr); + assert (x2 + table->col_ofs < table->nc); #if GLOBAL_DEBUGGING if (x1 + table->col_ofs < 0 || x1 + table->col_ofs >= table->nc @@ -1257,7 +1261,7 @@ struct som_table_class tab_table_class = FIXME: Doesn't use r1? Huh? */ static int -render_strip (int x, int y, int r, int c1, int c2, int r1 unused, int r2) +render_strip (int x, int y, int r, int c1, int c2, int r1 UNUSED, int r2) { int x_origin = x; @@ -1339,8 +1343,7 @@ render_strip (int x, int y, int r, int c1, int c2, int r1 unused, int r2) { j->hit = tab_hit; - if (j->x1 == c / 2 && j->y1 == r / 2 - && j->x2 <= c2 && j->y2 <= r2) + if (j->x1 == c / 2 && j->y1 == r / 2) { struct outp_text text; @@ -1354,15 +1357,15 @@ render_strip (int x, int y, int r, int c1, int c2, int r1 unused, int r2) int c; for (c = j->x1, text.h = -t->wrv[j->x2]; - c < j->x2; c++) - text.h += t->w[c] + t->wrv[c + 1]; + c < j->x2 && c < c2 / 2; c++) + text.h += t->w[c] + t->wrv[c + 1]; } { int r; for (r = j->y1, text.v = -t->hrh[j->y2]; - r < j->y2; r++) + r < j->y2 && r < r2 / 2; r++) text.v += t->h[r] + t->hrh[r + 1]; } d->class->text_draw (d, &text);