X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Ftab.c;fp=src%2Foutput%2Ftab.c;h=db384bdfc93408b434b08211ac774c03f60251a4;hb=8dd405d0900f29f69e54726a79045c119146de89;hp=8ef077e38fae99f8a8b2d8c54b4c3b22f541e296;hpb=7ee8dbfc15aa4580c2132e53b64f13815fc93c62;p=pspp diff --git a/src/output/tab.c b/src/output/tab.c index 8ef077e38f..db384bdfc9 100644 --- a/src/output/tab.c +++ b/src/output/tab.c @@ -88,6 +88,7 @@ tab_create (int nc, int nr) table_set_nr (&t->table, nr); t->title = NULL; + t->caption = NULL; t->cf = nc; t->cc = pool_calloc (t->container, nr * nc, sizeof *t->cc); t->ct = pool_malloc (t->container, nr * nc); @@ -682,11 +683,24 @@ tab_title (struct tab_table *t, const char *title, ...) va_end (args); } +/* Set the caption of table T to CAPTION, which is formatted as if + passed to printf(). */ +void +tab_caption (struct tab_table *t, const char *caption, ...) +{ + va_list args; + + free (t->caption); + va_start (args, caption); + t->caption = xvasprintf (caption, args); + va_end (args); +} + /* Easy, type-safe way to submit a tab table to som. */ void tab_submit (struct tab_table *t) { - table_item_submit (table_item_create (&t->table, t->title)); + table_item_submit (table_item_create (&t->table, t->title, t->caption)); } /* Editing. */ @@ -770,6 +784,8 @@ tab_destroy (struct table *table) struct tab_table *t = tab_cast (table); free (t->title); t->title = NULL; + free (t->caption); + t->caption = NULL; pool_destroy (t->container); }