From: Ben Pfaff Date: Mon, 6 Dec 2021 05:21:19 +0000 (-0800) Subject: pivot-table: New function pivot_value_new_variable__(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=861528a56e8fcb470285a2ee0bb87d716f652174 pivot-table: New function pivot_value_new_variable__(). --- diff --git a/src/output/pivot-table.c b/src/output/pivot-table.c index f1e0e73372..6ba4c16f2e 100644 --- a/src/output/pivot-table.c +++ b/src/output/pivot-table.c @@ -2844,13 +2844,22 @@ pivot_value_new_value (const union value *value, int width, /* Returns a new pivot_value for VARIABLE. */ struct pivot_value * pivot_value_new_variable (const struct variable *variable) +{ + return pivot_value_new_variable__ (var_get_name (variable), + var_get_label (variable)); +} + +/* Returns a new pivot_value for a variable with the given NAME and optional + LABEL. */ +struct pivot_value * +pivot_value_new_variable__ (const char *name, const char *label) { struct pivot_value *value = xmalloc (sizeof *value); *value = (struct pivot_value) { .variable = { .type = PIVOT_VALUE_VARIABLE, - .var_name = xstrdup (var_get_name (variable)), - .var_label = xstrdup_if_nonempty (var_get_label (variable)), + .var_name = xstrdup (name), + .var_label = xstrdup_if_nonempty (label), }, }; return value; diff --git a/src/output/pivot-table.h b/src/output/pivot-table.h index eb78325428..e7e5ad403b 100644 --- a/src/output/pivot-table.h +++ b/src/output/pivot-table.h @@ -739,6 +739,8 @@ struct pivot_value *pivot_value_new_value (const union value *, int width, /* Values from variable names. */ struct pivot_value *pivot_value_new_variable (const struct variable *); +struct pivot_value *pivot_value_new_variable__ (const char *name, + const char *label); /* Values from text strings. */ struct pivot_value *pivot_value_new_text (const char *);