From: Ben Pfaff Date: Thu, 26 Dec 2019 01:02:43 +0000 (+0000) Subject: table: Get rid of TAL_* constants. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb142a3b4d4e2d4296fb3fcddb683c360748b6ca;p=pspp table: Get rid of TAL_* constants. These were the same as TABLE_STROKE_* so get rid of the extras. --- diff --git a/src/output/html.c b/src/output/html.c index f28476eae6..5233fc8fe5 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -341,22 +341,22 @@ border_to_css (int border) { switch (border) { - case TAL_NONE: + case TABLE_STROKE_NONE: return NULL; - case TAL_SOLID: + case TABLE_STROKE_SOLID: return "solid"; - case TAL_DASHED: + case TABLE_STROKE_DASHED: return "dashed"; - case TAL_THICK: + case TABLE_STROKE_THICK: return "thick solid"; - case TAL_THIN: + case TABLE_STROKE_THIN: return "thin solid"; - case TAL_DOUBLE: + case TABLE_STROKE_DOUBLE: return "double"; default: diff --git a/src/output/render.c b/src/output/render.c index 39cde176ee..423940b068 100644 --- a/src/output/render.c +++ b/src/output/render.c @@ -463,17 +463,17 @@ rule_to_render_type (unsigned char type) { switch (type) { - case TAL_NONE: + case TABLE_STROKE_NONE: return RENDER_LINE_NONE; - case TAL_SOLID: + case TABLE_STROKE_SOLID: return RENDER_LINE_SINGLE; - case TAL_DASHED: + case TABLE_STROKE_DASHED: return RENDER_LINE_DASHED; - case TAL_THICK: + case TABLE_STROKE_THICK: return RENDER_LINE_THICK; - case TAL_THIN: + case TABLE_STROKE_THIN: return RENDER_LINE_THIN; - case TAL_DOUBLE: + case TABLE_STROKE_DOUBLE: return RENDER_LINE_DOUBLE; default: NOT_REACHED (); @@ -497,15 +497,15 @@ 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], &color); - /* 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_NONE)) + /* Turn off TABLE_STROKE_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 << TABLE_STROKE_NONE)) { - rules &= ~(1u << TAL_NONE); + rules &= ~(1u << TABLE_STROKE_NONE); if (z > 0 && z < table->n[a] && !params->supports_margins && a == H) - rules |= 1u << TAL_SOLID; + rules |= 1u << TABLE_STROKE_SOLID; } /* Calculate maximum width of the rules that are present. */ @@ -974,7 +974,7 @@ get_rule (const struct render_page *page, enum table_axis axis, { d[a] = d2; int r2 = table_get_rule (page->table, axis, d[H], d[V], color); - r = table_rule_combine (r, r2); + r = table_stroke_combine (r, r2); } return rule_to_render_type (r); } diff --git a/src/output/table.c b/src/output/table.c index b6caf598c6..2fa40c9091 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -366,10 +366,10 @@ table_create (int nc, int nr, int hl, int hr, int ht, int hb) t->ct = pool_calloc (t->container, nr * nc, sizeof *t->ct); t->rh = pool_nmalloc (t->container, nc, nr + 1); - memset (t->rh, TAL_0, nc * (nr + 1)); + memset (t->rh, TABLE_STROKE_NONE, nc * (nr + 1)); t->rv = pool_nmalloc (t->container, nr, nc + 1); - memset (t->rv, TAL_0, nr * (nc + 1)); + memset (t->rv, TABLE_STROKE_NONE, nr * (nc + 1)); memset (t->styles, 0, sizeof t->styles); memset (t->rule_colors, 0, sizeof t->rule_colors); @@ -590,7 +590,8 @@ add_joined_cell (struct table *table, int x1, int y1, int x2, int y2, } } - table_box (table, -1, -1, TAL_0, TAL_0, x1, y1, x2, y2); + table_box (table, -1, -1, TABLE_STROKE_NONE, TABLE_STROKE_NONE, + x1, y1, x2, y2); j = pool_alloc (table->container, sizeof *j); j->d[TABLE_HORZ][0] = x1; diff --git a/src/output/table.h b/src/output/table.h index fb3ca946aa..b3a9c41682 100644 --- a/src/output/table.h +++ b/src/output/table.h @@ -86,6 +86,15 @@ enum table_stroke const char *table_stroke_to_string (enum table_stroke); +/* Given strokes A and B, returns a stroke that "combines" them, that is, that + gives a reasonable stroke choice for a rule for different reasons should + have both styles A and B. */ +static inline int +table_stroke_combine (enum table_stroke a, enum table_stroke b) +{ + return a > b ? a : b; +} + struct table_border_style { enum table_stroke stroke; @@ -181,29 +190,6 @@ enum TAB_JOIN = 1 << 14, }; -/* Styles for the rules around table cells. */ -enum - { - TAL_NONE = TABLE_STROKE_NONE, -#define TAL_0 TAL_NONE - TAL_SOLID = TABLE_STROKE_SOLID, -#define TAL_1 TAL_SOLID - TAL_DASHED = TABLE_STROKE_DASHED, - TAL_THICK = TABLE_STROKE_THICK, - TAL_THIN = TABLE_STROKE_THIN, - TAL_DOUBLE = TABLE_STROKE_DOUBLE, -#define TAL_2 TAL_DOUBLE - }; - -/* Given line styles A and B (each one of the TAL_* enumeration constants - above), returns a line style that "combines" them, that is, that gives a - reasonable line style choice for a rule for different reasons should have - both styles A and B. */ -static inline int table_rule_combine (int a, int b) -{ - return a > b ? a : b; -} - /* A table. */ struct table { diff --git a/tests/output/render-test.c b/tests/output/render-test.c index 3540021654..90b5867f87 100644 --- a/tests/output/render-test.c +++ b/tests/output/render-test.c @@ -422,24 +422,24 @@ read_table (FILE *stream) switch (*text++) { case '<': - table_vline (tab, TAL_1, c, r, r + rs - 1); + table_vline (tab, TABLE_STROKE_SOLID, c, r, r + rs - 1); break; case '>': - table_vline (tab, TAL_1, c + cs, r, r + rs - 1); + table_vline (tab, TABLE_STROKE_SOLID, c + cs, r, r + rs - 1); break; case '^': - table_hline (tab, TAL_1, c, c + cs - 1, r); + table_hline (tab, TABLE_STROKE_SOLID, c, c + cs - 1, r); break; case ',': - table_hline (tab, TAL_1, c, c + cs - 1, r + rs); + table_hline (tab, TABLE_STROKE_SOLID, c, c + cs - 1, r + rs); break; case '@': - table_box (tab, TAL_1, TAL_1, -1, -1, c, r, - c + cs - 1, r + rs - 1); + table_box (tab, TABLE_STROKE_SOLID, TABLE_STROKE_SOLID, + -1, -1, c, r, c + cs - 1, r + rs - 1); break; case '(':