From: Ben Pfaff Date: Thu, 26 Dec 2019 00:43:45 +0000 (+0000) Subject: pivot-table: Make pivot_area_get_default_style() return a static copy. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1fc57ddc57637e5c8bb87b478cbe585b6b4cf84;p=pspp pivot-table: Make pivot_area_get_default_style() return a static copy. The existing callers all want to make their own copy, but an upcoming new caller wants an existing one, so refactor the interface a bit. --- diff --git a/src/output/pivot-table.c b/src/output/pivot-table.c index cce72ef1de..d4649292ac 100644 --- a/src/output/pivot-table.c +++ b/src/output/pivot-table.c @@ -62,8 +62,8 @@ pivot_area_to_string (enum pivot_area area) } } -void -pivot_area_get_default_style (enum pivot_area area, struct area_style *style) +const struct area_style * +pivot_area_get_default_style (enum pivot_area area) { #define STYLE(BOLD, H, V, L, R, T, B) { \ .cell_style = { \ @@ -77,6 +77,7 @@ pivot_area_get_default_style (enum pivot_area area, struct area_style *style) .fg = { [0] = CELL_COLOR_BLACK, [1] = CELL_COLOR_BLACK}, \ .bg = { [0] = CELL_COLOR_WHITE, [1] = CELL_COLOR_WHITE}, \ .size = 9, \ + .typeface = (char *) "Sans Serif", \ }, \ } static const struct area_style default_area_styles[PIVOT_N_AREAS] = { @@ -91,8 +92,7 @@ pivot_area_get_default_style (enum pivot_area area, struct area_style *style) }; #undef STYLE - *style = default_area_styles[area]; - style->font_style.typeface = xstrdup ("SansSerif"); + return &default_area_styles[area]; } void @@ -714,7 +714,7 @@ pivot_table_create__ (struct pivot_value *title, const char *subtype) table->sizing[TABLE_VERT].range[1] = 120; for (size_t i = 0; i < PIVOT_N_AREAS; i++) - pivot_area_get_default_style (i, &table->areas[i]); + area_style_copy (NULL, &table->areas[i], pivot_area_get_default_style (i)); /* Set default border styles. */ static const enum table_stroke default_strokes[PIVOT_N_BORDERS] = { diff --git a/src/output/pivot-table.h b/src/output/pivot-table.h index c11874da2e..096e50a1eb 100644 --- a/src/output/pivot-table.h +++ b/src/output/pivot-table.h @@ -107,7 +107,7 @@ enum pivot_area }; const char *pivot_area_to_string (enum pivot_area); -void pivot_area_get_default_style (enum pivot_area, struct area_style *); +const struct area_style *pivot_area_get_default_style (enum pivot_area); /* Table borders for styling purposes. */ enum pivot_border