From: Ben Pfaff Date: Mon, 2 Sep 2019 06:28:08 +0000 (+0000) Subject: variable: New function var_append_value_name__(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47ebf195325ed081e60725a23efc87011671886f;p=pspp variable: New function var_append_value_name__(). This variation on var_append_value_name() allows the caller to pass in the parameter specifying how to show the value, which will be useful in an upcoming commit. --- diff --git a/src/data/variable.c b/src/data/variable.c index 6f4a7964a4..3ad9eccdb0 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -564,18 +564,13 @@ append_value (const struct variable *v, const union value *value, free (s); } -/* Append STR with a string representing VALUE for variable V. - That is, if VALUE has a label, append that label, - otherwise format VALUE and append the formatted string. - STR must be a pointer to an initialised struct string. -*/ void -var_append_value_name (const struct variable *v, const union value *value, - struct string *str) +var_append_value_name__ (const struct variable *v, const union value *value, + enum settings_value_show show, struct string *str) { const char *label = var_lookup_value_label (v, value); - switch (settings_get_show_values ()) + switch (show) { case SETTINGS_VALUE_SHOW_VALUE: append_value (v, value, str); @@ -596,6 +591,18 @@ var_append_value_name (const struct variable *v, const union value *value, break; } } + +/* Append STR with a string representing VALUE for variable V. + That is, if VALUE has a label, append that label, + otherwise format VALUE and append the formatted string. + STR must be a pointer to an initialised struct string. +*/ +void +var_append_value_name (const struct variable *v, const union value *value, + struct string *str) +{ + var_append_value_name__ (v, value, settings_get_show_values (), str); +} /* Print and write formats. */ diff --git a/src/data/variable.h b/src/data/variable.h index 1fefe1ee8d..6347d8173c 100644 --- a/src/data/variable.h +++ b/src/data/variable.h @@ -22,6 +22,7 @@ #include "data/dict-class.h" #include "data/missing-values.h" #include "data/val-type.h" +#include "data/settings.h" /* Bitfields to identify traits of a variable */ @@ -93,6 +94,8 @@ const char *var_lookup_value_label (const struct variable *, struct string; void var_append_value_name (const struct variable *, const union value *, struct string *); +void var_append_value_name__ (const struct variable *, const union value *, + enum settings_value_show, struct string *); bool var_has_value_labels (const struct variable *); const struct val_labs *var_get_value_labels (const struct variable *);