X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvariable.c;h=285d9d88f72d90c283db648f0425f055793e1860;hb=a7005f8bc73cb857489acd07b8a792d6cf2ecff7;hp=72d9ade6759cfd33e1ed855e5deac987fd18d3f5;hpb=f481fd69631024bcdc7dc2369bbc1592d7a43ac7;p=pspp diff --git a/src/data/variable.c b/src/data/variable.c index 72d9ade675..285d9d88f7 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -72,10 +72,6 @@ struct variable char **short_names; size_t short_name_cnt; - /* Each command may use these fields as needed. */ - void *aux; - void (*aux_dtor) (struct variable *); - /* Custom attributes. */ struct attrset attributes; }; @@ -149,7 +145,6 @@ var_destroy (struct variable *v) assert (!var_has_vardict (v)); mv_destroy (&v->miss); var_clear_short_names (v); - var_clear_aux (v); val_labs_destroy (v->val_labs); var_clear_label (v); attrset_destroy (var_get_attributes (v)); @@ -201,7 +196,7 @@ compare_vars_by_name (const void *a_, const void *b_, const void *aux UNUSED) const struct variable *a = a_; const struct variable *b = b_; - return strcasecmp (a->name, b->name); + return utf8_strcasecmp (a->name, b->name); } /* A hsh_hash_func that hashes variable V based on its name. */ @@ -210,7 +205,7 @@ hash_var_by_name (const void *v_, const void *aux UNUSED) { const struct variable *v = v_; - return hash_case_string (v->name, 0); + return utf8_hash_case_string (v->name, 0); } /* A hsh_compare_func that orders pointers to variables A and B @@ -222,7 +217,7 @@ compare_var_ptrs_by_name (const void *a_, const void *b_, struct variable *const *a = a_; struct variable *const *b = b_; - return strcasecmp (var_get_name (*a), var_get_name (*b)); + return utf8_strcasecmp (var_get_name (*a), var_get_name (*b)); } /* A hsh_compare_func that orders pointers to variables A and B @@ -246,7 +241,7 @@ hash_var_ptr_by_name (const void *v_, const void *aux UNUSED) { struct variable *const *v = v_; - return hash_case_string (var_get_name (*v), 0); + return utf8_hash_case_string (var_get_name (*v), 0); } /* Returns the type of variable V. */ @@ -926,8 +921,7 @@ var_set_short_name (struct variable *var, size_t idx, const char *short_name) for (i = old_cnt; i < var->short_name_cnt; i++) var->short_names[i] = NULL; } - var->short_names[idx] = xstrdup (short_name); - str_uppercase (var->short_names[idx]); + var->short_names[idx] = utf8_to_upper (short_name); } dict_var_changed (var); @@ -969,63 +963,6 @@ var_get_case_index (const struct variable *v) return vardict_get_case_index (v->vardict); } -/* Returns V's auxiliary data, or a null pointer if none has been - attached. */ -void * -var_get_aux (const struct variable *v) -{ - return v->aux; -} - -/* Assign auxiliary data AUX to variable V, which must not - already have auxiliary data. Before V's auxiliary data is - cleared, AUX_DTOR(V) will be called. (var_dtor_free, below, - may be appropriate for use as AUX_DTOR.) */ -void * -var_attach_aux (const struct variable *v_, - void *aux, void (*aux_dtor) (struct variable *)) -{ - struct variable *v = CONST_CAST (struct variable *, v_); - assert (v->aux == NULL); - assert (aux != NULL); - v->aux = aux; - v->aux_dtor = aux_dtor; - return aux; -} - -/* Remove auxiliary data, if any, from V, and return it, without - calling any associated destructor. */ -void * -var_detach_aux (struct variable *v) -{ - void *aux = v->aux; - assert (aux != NULL); - v->aux = NULL; - return aux; -} - -/* Clears auxiliary data, if any, from V, and calls any - associated destructor. */ -void -var_clear_aux (struct variable *v) -{ - if (v->aux != NULL) - { - if (v->aux_dtor != NULL) - v->aux_dtor (v); - v->aux = NULL; - } -} - -/* This function is appropriate for use an auxiliary data - destructor (passed as AUX_DTOR to var_attach_aux()) for the - case where the auxiliary data should be passed to free(). */ -void -var_dtor_free (struct variable *v) -{ - free (v->aux); -} - /* Returns variable V's attribute set. The caller may examine or modify the attribute set, but must not destroy it. Destroying V, or calling var_set_attributes() on V, will also destroy its