X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvariable.c;h=0b8079ca534762c2a776739c6001b8327be2d335;hb=c41f14854e73ad44824b54933ae96eb52f781fc2;hp=4623b77b13a9f65ddcab64565898dcfc390c4cc5;hpb=f662ba6c542ef66d8ab80cb0a4154ff853cfc0af;p=pspp-builds.git diff --git a/src/data/variable.c b/src/data/variable.c index 4623b77b..0b8079ca 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -567,23 +567,26 @@ var_lookup_value_label (const struct variable *v, const union value *value) return val_labs_find (v->val_labs, *value); } -/* Get a string representing VALUE for variable V. - That is, if VALUE has a label, return that label, - otherwise format VALUE and return the formatted string. */ -const char * -var_get_value_name (const struct variable *v, const union value *value) +/* 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) { const char *name = var_lookup_value_label (v, value); if (name == NULL) { - static char buf[MAX_STRING + 1]; - data_out (value, &v->print, buf); - buf[v->print.w] = '\0'; - name = buf; + char *s = ds_put_uninit (str, v->print.w); + data_out (value, &v->print, s); } - return name; + else + ds_put_cstr (str, name); } + /* Print and write formats. */ /* Returns V's print format specification. */