X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fpivot-table.c;h=96dd9d2413abaac75fd58a251a2aa41ef46c8a96;hb=c7660b4a54e32aebfbda642c52afff57284a306c;hp=50bed0a7115f626918d27c7be8057c8e712d3c9c;hpb=9e63184628ce4e0a1f36ef72d2acda48846bdb59;p=pspp diff --git a/src/output/pivot-table.c b/src/output/pivot-table.c index 50bed0a711..96dd9d2413 100644 --- a/src/output/pivot-table.c +++ b/src/output/pivot-table.c @@ -370,7 +370,8 @@ pivot_axis_iterator_next (size_t *indexes, const struct pivot_axis *axis) if (axis->dimensions[i]->n_leaves == 0) return NULL; - return xcalloc (axis->n_dimensions, sizeof *indexes); + size_t size = axis->n_dimensions * sizeof *indexes; + return xzalloc (MAX (size, 1)); } for (size_t i = 0; i < axis->n_dimensions; i++) @@ -817,11 +818,11 @@ pivot_table_create (const char *title) return pivot_table_create__ (pivot_value_new_text (title), title); } -/* Creates and returns a new pivot table with the given TITLE, and takes - ownership of TITLE. The new pivot table's subtype is SUBTYPE, which - should be an untranslated English string that describes the contents of - the table at a high level without being specific about the variables or - other context involved. +/* Creates and returns a new pivot table with the given TITLE (which may be + null), and takes ownership of TITLE. The new pivot table's subtype is + SUBTYPE, which should be an untranslated English string that describes the + contents of the table at a high level without being specific about the + variables or other context involved. Operations commonly performed on the new pivot_table: @@ -993,6 +994,25 @@ pivot_table_is_empty (const struct pivot_table *table) return hmap_is_empty (&table->cells); } +size_t * +pivot_table_next_display_layer (const struct pivot_table *pt, size_t *indexes, + bool print) +{ + const struct pivot_axis *layer_axis = &pt->axes[PIVOT_AXIS_LAYER]; + if (print && pt->look->print_all_layers) + return pivot_axis_iterator_next (indexes, layer_axis); + else if (!indexes) + { + size_t size = layer_axis->n_dimensions * sizeof *pt->current_layer; + return xmemdup (pt->current_layer, MAX (size, 1)); + } + else + { + free (indexes); + return NULL; + } +} + static unsigned int pivot_cell_hash_indexes (const size_t *indexes, size_t n_idx) { @@ -2122,16 +2142,29 @@ pivot_value_get_style (struct pivot_value *value, void pivot_value_set_style (struct pivot_value *value, const struct table_area_style *area) +{ + pivot_value_set_font_style (value, &area->font_style); + pivot_value_set_cell_style (value, &area->cell_style); +} + +void +pivot_value_set_font_style (struct pivot_value *value, + const struct font_style *font_style) { if (value->font_style) font_style_uninit (value->font_style); else value->font_style = xmalloc (sizeof *value->font_style); - font_style_copy (NULL, value->font_style, &area->font_style); + font_style_copy (NULL, value->font_style, font_style); +} +void +pivot_value_set_cell_style (struct pivot_value *value, + const struct cell_style *cell_style) +{ if (!value->cell_style) value->cell_style = xmalloc (sizeof *value->cell_style); - *value->cell_style = area->cell_style; + *value->cell_style = *cell_style; } /* Frees the data owned by ARG (but not ARG itself). */