X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fpivot-table.c;h=f2967eae81de9d14ac60dd015b9421112b2c2068;hb=08959981d167390d9c9ba0ac5a8a2558de9175af;hp=cc7ca59d0fc06487ce00b8c4dc216c13c4ead496;hpb=96db814fbc3a1ec3bf063e447999444e695c6f93;p=pspp diff --git a/src/output/pivot-table.c b/src/output/pivot-table.c index cc7ca59d0f..f2967eae81 100644 --- a/src/output/pivot-table.c +++ b/src/output/pivot-table.c @@ -81,7 +81,7 @@ pivot_area_get_default_style (enum pivot_area area) }, \ } static const struct area_style default_area_styles[PIVOT_N_AREAS] = { - [PIVOT_AREA_TITLE] = STYLE( true, CENTER, CENTER, 8,11,1,8), + [PIVOT_AREA_TITLE] = STYLE(true, CENTER, CENTER, 8,11,1,8), [PIVOT_AREA_CAPTION] = STYLE(false, LEFT, TOP, 8,11,1,1), [PIVOT_AREA_FOOTER] = STYLE(false, LEFT, TOP, 11, 8,2,3), [PIVOT_AREA_CORNER] = STYLE(false, LEFT, BOTTOM, 8,11,1,1), @@ -704,10 +704,8 @@ pivot_table_create__ (struct pivot_value *title, const char *subtype) table->show_caption = true; table->weight_format = (struct fmt_spec) { FMT_F, 40, 0 }; table->title = title; - table->subtype = pivot_value_new_text (subtype); - - const char *command_id = output_get_command_name (); - table->command_c = command_id ? xstrdup (command_id) : NULL; + table->subtype = subtype ? pivot_value_new_text (subtype) : NULL; + table->command_c = output_get_command_name (); table->sizing[TABLE_HORZ].range[0] = 50; table->sizing[TABLE_HORZ].range[1] = 72; @@ -1059,6 +1057,7 @@ pivot_table_create_footnote__ (struct pivot_table *table, size_t idx, f->marker = pivot_make_default_footnote_marker ( f->idx, table->show_numeric_markers); f->content = NULL; + f->show = true; table->footnotes[table->n_footnotes++] = f; } @@ -1139,7 +1138,7 @@ pivot_table_enumerate_axis (const struct pivot_table *table, axis->n_dimensions), 1), sizeof *enumeration); size_t *p = enumeration; - size_t *dindexes = xcalloc (table->n_dimensions, sizeof *dindexes); + size_t *dindexes = XCALLOC (table->n_dimensions, size_t); size_t *axis_indexes; PIVOT_AXIS_FOR_EACH (axis_indexes, axis) @@ -1488,8 +1487,11 @@ pivot_table_dump (const struct pivot_table *table, int indentation) if (table->date) { indent (indentation); - char buf[26]; - printf ("date: %s", ctime_r (&table->date, buf)); + + struct tm *tm = localtime (&table->date); + printf ("date: %d-%02d-%02d %d:%02d:%02d\n", tm->tm_year + 1900, + tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, + tm->tm_sec); } indent (indentation); @@ -1513,7 +1515,7 @@ pivot_table_dump (const struct pivot_table *table, int indentation) pivot_dimension_dump (table->dimensions[i], indentation); /* Presentation and data indexes. */ - size_t *dindexes = xcalloc (table->n_dimensions, sizeof *dindexes); + size_t *dindexes = XCALLOC (table->n_dimensions, size_t); const struct pivot_axis *layer_axis = &table->axes[PIVOT_AXIS_LAYER]; if (layer_axis->n_dimensions) @@ -1566,7 +1568,7 @@ pivot_table_dump (const struct pivot_table *table, int indentation) names[n_names++] = c->name; } - for (size_t i = n_names; i-- > 0; ) + for (size_t i = n_names; i-- > 0;) { putchar (' '); pivot_value_dump (names[i]); @@ -1890,7 +1892,7 @@ pivot_value_format (const struct pivot_value *value, enum settings_value_show show_variables, struct string *out) { - pivot_value_format_body ( value, show_values, show_variables, out); + pivot_value_format_body (value, show_values, show_variables, out); if (value->n_subscripts) { @@ -1984,15 +1986,16 @@ pivot_value_destroy (struct pivot_value *value) DEFAULT_STYLE for the parts of the style that VALUE doesn't override. */ void pivot_value_get_style (struct pivot_value *value, - const struct area_style *default_style, + const struct font_style *base_font_style, + const struct cell_style *base_cell_style, struct area_style *area) { font_style_copy (NULL, &area->font_style, (value->font_style ? value->font_style - : &default_style->font_style)); - area->cell_style = (value->cell_style - ? *value->cell_style - : default_style->cell_style); + : base_font_style)); + area->cell_style = *(value->cell_style + ? value->cell_style + : base_cell_style); } /* Copies AREA into VALUE's style. */ @@ -2227,6 +2230,12 @@ void pivot_value_add_footnote (struct pivot_value *v, const struct pivot_footnote *footnote) { + /* Some legacy tables include numerous duplicate footnotes. Suppress + them. */ + for (size_t i = 0; i < v->n_footnotes; i++) + if (v->footnotes[i] == footnote) + return; + v->footnotes = xrealloc (v->footnotes, (v->n_footnotes + 1) * sizeof *v->footnotes); v->footnotes[v->n_footnotes++] = footnote;