From 861528a56e8fcb470285a2ee0bb87d716f652174 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 5 Dec 2021 21:21:19 -0800 Subject: [PATCH] pivot-table: New function pivot_value_new_variable__(). --- src/output/pivot-table.c | 13 +++++++++++-- src/output/pivot-table.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) 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 *); -- 2.30.2