From: Ben Pfaff Date: Tue, 16 Jun 2009 04:40:06 +0000 (-0700) Subject: output: Make global variables less global. X-Git-Tag: v0.7.3~39 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=832e0124a3b99996d284afbd1ffe72476a15cde6;p=pspp-builds.git output: Make global variables less global. table_num and subtable_num were previously global variables that were referred to from multiple files. Now that we want to make tables renderable from arbitrary contexts, though, we need to save the table number with the table, so this change implements that. --- diff --git a/src/output/manager.c b/src/output/manager.c index b134e890..4699da03 100644 --- a/src/output/manager.c +++ b/src/output/manager.c @@ -22,8 +22,8 @@ #include "output.h" /* Table. */ -int table_num = 1; -int subtable_num; +static int table_num = 1; +static int subtable_num; /* Increments table_num so different procedures' output can be distinguished. */ @@ -99,12 +99,12 @@ som_submit (struct som_entity *t) int hl, hr, ht, hb; int nc, nr; - /* Set up to render the table. */ t->class->flags (t, &flags); if (!(flags & SOMF_NO_TITLE)) subtable_num++; + t->table_num = table_num; + t->subtable_num = subtable_num; - /* Do some basic error checking. */ t->class->count (t, &nc, &nr); t->class->headers (t, &hl, &hr, &ht, &hb); if (hl + hr > nc || ht + hb > nr) @@ -260,7 +260,7 @@ render_columns (void *r, struct outp_driver *d, struct som_entity *t, if (len > max_len) max_len = len; - t->class->title (r, index++, 0); + t->class->title (r, index++, 0, t->table_num, t->subtable_num); t->class->render (r, 0, y0, nc, y1); d->cp_x += tw + 2 * d->prop_em_width; @@ -293,7 +293,7 @@ render_simple (void *r, struct outp_driver *d, struct som_entity *t, assert (d->cp_x == 0); assert (tw < d->width && th + d->cp_y < d->length); - t->class->title (r, 0, 0); + t->class->title (r, 0, 0, t->table_num, t->subtable_num); t->class->render (r, hl, ht, nc - hr, nr - hb); d->cp_y += th; } @@ -342,7 +342,8 @@ render_segments (void *r, struct outp_driver *d, struct som_entity *t, else { t->class->title (r, x_index ? x_index : y_index, - x_index ? y_index : 0); + x_index ? y_index : 0, + t->table_num, t->subtable_num); t->class->render (r, x0, y0, x1, y1); d->cp_y += len; diff --git a/src/output/manager.h b/src/output/manager.h index 76763ae6..1aa2c36a 100644 --- a/src/output/manager.h +++ b/src/output/manager.h @@ -47,6 +47,8 @@ struct som_entity const struct som_table_class *class; /* Table class. */ enum som_type type; /* Table or Chart */ void *ext; /* Owned by table or chart class. */ + int table_num; /* Table number. */ + int subtable_num; /* Sub-table number. */ }; /* Group styles. */ @@ -90,14 +92,10 @@ struct som_table_class void (*area) (void *, int *horiz, int *vert); void (*cumulate) (void *, int cumtype, int start, int *end, int max, int *actual); - void (*title) (void *, int x, int y); + void (*title) (void *, int x, int y, int table_num, int subtable_num); void (*render) (void *, int x1, int y1, int x2, int y2); }; -/* Table indexes. */ -extern int table_num; -extern int subtable_num; - /* Submission. */ void som_new_series (void); void som_submit (struct som_entity *t); diff --git a/src/output/table.c b/src/output/table.c index 3cf6a3ae..91f99a1f 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -1144,7 +1144,7 @@ tabi_cumulate (void *r_, int cumtype, int start, int *end, Y. Y may be zero, or X and Y may be zero, but X should be nonzero if Y is nonzero. */ static void -tabi_title (void *r_, int x, int y) +tabi_title (void *r_, int x, int y, int table_num, int subtable_num) { const struct tab_rendering *r = r_; const struct tab_table *t = r->table;