X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvariable.c;h=05edc57e2db85a3c02df4fbe3a16a6747d92c4bc;hb=dde5a3c946871b4aab3d6b436438dd8df11db261;hp=c0767d7ce245bcfdbcec0b25080228d7c9a38dbc;hpb=04d2c99833753252b724dd9d4f15cc3a80b6bec8;p=pspp-builds.git diff --git a/src/data/variable.c b/src/data/variable.c index c0767d7c..05edc57e 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -149,13 +149,13 @@ var_clone (const struct variable *old_var) return new_var; } -/* Create a variable to be used for internal calculations only. - The variable is assigned a unique dictionary index and a case - index of CASE_IDX. */ +/* Create a variable of the specified WIDTH to be used for + internal calculations only. The variable is assigned a unique + dictionary index and a case index of CASE_IDX. */ struct variable * -var_create_internal (int case_idx) +var_create_internal (int case_idx, int width) { - struct variable *v = var_create ("$internal", 0); + struct variable *v = var_create ("$internal", width); struct vardict_info vdi; static int counter = INT_MAX / 2; @@ -494,7 +494,7 @@ var_is_num_missing (const struct variable *v, double d, enum mv_class class) S[] must contain exactly as many characters as V's width. V must be a string variable. */ bool -var_is_str_missing (const struct variable *v, const char s[], +var_is_str_missing (const struct variable *v, const uint8_t s[], enum mv_class class) { return mv_is_str_missing (&v->miss, s, class); @@ -590,10 +590,12 @@ var_append_value_name (const struct variable *v, const union value *value, struct string *str) { const char *name = var_lookup_value_label (v, value); + const struct dictionary *dict = var_get_vardict (v)->dict; if (name == NULL) { - char *s = ds_put_uninit (str, v->print.w); - data_out (value, &v->print, s); + char *s = data_out (value, dict_get_encoding (dict), &v->print); + ds_put_cstr (str, s); + free (s); } else ds_put_cstr (str, name); @@ -955,7 +957,7 @@ void * var_attach_aux (const struct variable *v_, void *aux, void (*aux_dtor) (struct variable *)) { - struct variable *v = (struct variable *) v_ ; /* cast away const */ + struct variable *v = CONST_CAST (struct variable *, v_); assert (v->aux == NULL); assert (aux != NULL); v->aux = aux; @@ -1013,7 +1015,7 @@ var_get_obs_vals (const struct variable *v) void var_set_obs_vals (const struct variable *v_, struct cat_vals *cat_vals) { - struct variable *v = (struct variable *) v_ ; /* cast away const */ + struct variable *v = CONST_CAST (struct variable *, v_ ); cat_stored_values_destroy (v->obs_vals); v->obs_vals = cat_vals; } @@ -1033,7 +1035,7 @@ var_has_obs_vals (const struct variable *v) struct attrset * var_get_attributes (const struct variable *v) { - return (struct attrset *) &v->attributes; + return CONST_CAST (struct attrset *, &v->attributes); } /* Replaces variable V's attributes set by a copy of ATTRS. */