X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftab.c;h=47fd0b92419ad47ae724ed556212d460cce22b3e;hb=1f8dd363d6c20d07fcca14cb948018465fa5ed8b;hp=6005ec9cc72f16eee02b9ceaa02ce185effef118;hpb=4fdeb2145d081ff1b84e3f6c99f9d1c048c0d64a;p=pspp-builds.git diff --git a/src/tab.c b/src/tab.c index 6005ec9c..47fd0b92 100644 --- a/src/tab.c +++ b/src/tab.c @@ -34,6 +34,9 @@ #include "som.h" #include "var.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) + #include "debug-print.h" struct som_table_class tab_table_class; @@ -607,9 +610,7 @@ tab_float (struct tab_table *table, int c, int r, unsigned char opt, assert (r >= 0); assert (r < table->nr); - f.type = FMT_F; - f.w = w; - f.d = d; + f = make_output_format (FMT_F, w, d); #if GLOBAL_DEBUGGING if (c + table->col_ofs < 0 || r + table->row_ofs < 0 @@ -1137,6 +1138,45 @@ tabi_flags (unsigned *flags) *flags = t->flags; } +/* Returns true if the table will fit in the given page WIDTH, + false otherwise. */ +static bool +tabi_fits_width (int width) +{ + int i; + + for (i = t->l; i < t->nc - t->r; i++) + if (t->wl + t->wr + t->w[i] > width) + return false; + + return true; +} + +/* Returns true if the table will fit in the given page LENGTH, + false otherwise. */ +static bool +tabi_fits_length (int length) +{ + int i; + + for (i = t->t; i < t->nr - t->b; i++) + if (t->ht + t->hb + t->h[i] > length) + return false; + + return true; +} + +/* Sets the number of header rows/columns on the left, right, top, + and bottom sides to HL, HR, HT, and HB, respectively. */ +static void +tabi_set_headers (int hl, int hr, int ht, int hb) +{ + t->l = hl; + t->r = hr; + t->t = ht; + t->b = hb; +} + /* Render title for current table, with major index X and minor index Y. Y may be zero, or X and Y may be zero, but X should be nonzero if Y is nonzero. */ @@ -1237,9 +1277,12 @@ struct som_table_class tab_table_class = NULL, tabi_cumulate, tabi_flags, + tabi_fits_width, + tabi_fits_length, NULL, NULL, + tabi_set_headers, tabi_title, tabi_render,