1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "data/variable.h"
23 #include "data/attributes.h"
24 #include "data/data-out.h"
25 #include "data/dictionary.h"
26 #include "data/format.h"
27 #include "data/identifier.h"
28 #include "data/missing-values.h"
29 #include "data/settings.h"
30 #include "data/value-labels.h"
31 #include "data/vardict.h"
32 #include "libpspp/assertion.h"
33 #include "libpspp/compiler.h"
34 #include "libpspp/hash-functions.h"
35 #include "libpspp/i18n.h"
36 #include "libpspp/message.h"
37 #include "libpspp/misc.h"
38 #include "libpspp/str.h"
40 #include "gl/minmax.h"
41 #include "gl/xalloc.h"
44 #define _(msgid) gettext (msgid)
49 /* Dictionary information. */
50 char *name; /* Variable name. Mixed case. */
51 int width; /* 0 for numeric, otherwise string width. */
52 struct missing_values miss; /* Missing values. */
53 struct fmt_spec print; /* Default format for PRINT. */
54 struct fmt_spec write; /* Default format for WRITE. */
55 struct val_labs *val_labs; /* Value labels. */
56 char *label; /* Variable label. */
58 /* GUI information. */
59 enum measure measure; /* Nominal, ordinal, or continuous. */
60 int display_width; /* Width of data editor column. */
61 enum alignment alignment; /* Alignment of data in GUI. */
63 /* Case information. */
64 bool leave; /* Leave value from case to case? */
66 /* Data for use by containing dictionary. */
67 struct vardict_info *vardict;
69 /* Used only for system and portable file input and output.
72 size_t short_name_cnt;
74 /* Each command may use these fields as needed. */
76 void (*aux_dtor) (struct variable *);
78 /* Custom attributes. */
79 struct attrset attributes;
82 /* Creates and returns a new variable with the given NAME and
83 WIDTH and other fields initialized to default values. The
84 variable is not added to a dictionary; for that, use
85 dict_create_var instead. */
87 var_create (const char *name, int width)
92 assert (width >= 0 && width <= MAX_STRING);
94 v = xmalloc (sizeof *v);
97 var_set_name (v, name);
99 mv_init (&v->miss, width);
100 v->leave = var_must_leave (v);
101 type = val_type_from_width (width);
102 v->alignment = var_default_alignment (type);
103 v->measure = var_default_measure (type);
104 v->display_width = var_default_display_width (width);
105 v->print = v->write = var_default_formats (width);
108 v->short_names = NULL;
109 v->short_name_cnt = 0;
112 attrset_init (&v->attributes);
117 /* Creates and returns a clone of OLD_VAR. Most properties of
118 the new variable are copied from OLD_VAR, except:
120 - The variable's short name is not copied, because there is
121 no reason to give a new variable with potentially a new
122 name the same short name.
124 - The new variable is not added to OLD_VAR's dictionary by
125 default. Use dict_clone_var, instead, to do that.
128 var_clone (const struct variable *old_var)
130 struct variable *new_var = var_create (var_get_name (old_var),
131 var_get_width (old_var));
133 var_set_missing_values (new_var, var_get_missing_values (old_var));
134 var_set_print_format (new_var, var_get_print_format (old_var));
135 var_set_write_format (new_var, var_get_write_format (old_var));
136 var_set_value_labels (new_var, var_get_value_labels (old_var));
137 var_set_label (new_var, var_get_label (old_var), false);
138 var_set_measure (new_var, var_get_measure (old_var));
139 var_set_display_width (new_var, var_get_display_width (old_var));
140 var_set_alignment (new_var, var_get_alignment (old_var));
141 var_set_leave (new_var, var_get_leave (old_var));
142 var_set_attributes (new_var, var_get_attributes (old_var));
147 /* Destroys variable V.
148 V must not belong to a dictionary. If it does, use
149 dict_delete_var instead. */
151 var_destroy (struct variable *v)
155 assert (!var_has_vardict (v));
156 mv_destroy (&v->miss);
157 var_clear_short_names (v);
159 val_labs_destroy (v->val_labs);
161 attrset_destroy (var_get_attributes (v));
167 /* Variable names. */
169 /* Return variable V's name, as a UTF-8 encoded string. */
171 var_get_name (const struct variable *v)
176 /* Sets V's name to NAME, a UTF-8 encoded string.
177 Do not use this function for a variable in a dictionary. Use
178 dict_rename_var instead. */
180 var_set_name (struct variable *v, const char *name)
182 assert (!var_has_vardict (v));
183 assert (id_is_plausible (name, false));
186 v->name = xstrdup (name);
187 dict_var_changed (v);
190 /* Returns VAR's dictionary class. */
192 var_get_dict_class (const struct variable *var)
194 return dict_class_from_id (var->name);
197 /* A hsh_compare_func that orders variables A and B by their
200 compare_vars_by_name (const void *a_, const void *b_, const void *aux UNUSED)
202 const struct variable *a = a_;
203 const struct variable *b = b_;
205 return strcasecmp (a->name, b->name);
208 /* A hsh_hash_func that hashes variable V based on its name. */
210 hash_var_by_name (const void *v_, const void *aux UNUSED)
212 const struct variable *v = v_;
214 return hash_case_string (v->name, 0);
217 /* A hsh_compare_func that orders pointers to variables A and B
220 compare_var_ptrs_by_name (const void *a_, const void *b_,
221 const void *aux UNUSED)
223 struct variable *const *a = a_;
224 struct variable *const *b = b_;
226 return strcasecmp (var_get_name (*a), var_get_name (*b));
229 /* A hsh_compare_func that orders pointers to variables A and B
230 by their dictionary indexes. */
232 compare_var_ptrs_by_dict_index (const void *a_, const void *b_,
233 const void *aux UNUSED)
235 struct variable *const *a = a_;
236 struct variable *const *b = b_;
237 size_t a_index = var_get_dict_index (*a);
238 size_t b_index = var_get_dict_index (*b);
240 return a_index < b_index ? -1 : a_index > b_index;
243 /* A hsh_hash_func that hashes pointer to variable V based on its
246 hash_var_ptr_by_name (const void *v_, const void *aux UNUSED)
248 struct variable *const *v = v_;
250 return hash_case_string (var_get_name (*v), 0);
253 /* Returns the type of variable V. */
255 var_get_type (const struct variable *v)
257 return val_type_from_width (v->width);
260 /* Returns the width of variable V. */
262 var_get_width (const struct variable *v)
267 /* Changes the width of V to NEW_WIDTH.
268 This function should be used cautiously. */
270 var_set_width (struct variable *v, int new_width)
272 const int old_width = v->width;
274 if (old_width == new_width)
277 if (mv_is_resizable (&v->miss, new_width))
278 mv_resize (&v->miss, new_width);
281 mv_destroy (&v->miss);
282 mv_init (&v->miss, new_width);
285 if (v->val_labs != NULL)
287 if (val_labs_can_set_width (v->val_labs, new_width))
288 val_labs_set_width (v->val_labs, new_width);
291 val_labs_destroy (v->val_labs);
296 fmt_resize (&v->print, new_width);
297 fmt_resize (&v->write, new_width);
299 v->width = new_width;
300 dict_var_resized (v, old_width);
301 dict_var_changed (v);
304 /* Returns true if variable V is numeric, false otherwise. */
306 var_is_numeric (const struct variable *v)
308 return var_get_type (v) == VAL_NUMERIC;
311 /* Returns true if variable V is a string variable, false
314 var_is_alpha (const struct variable *v)
316 return var_get_type (v) == VAL_STRING;
319 /* Returns variable V's missing values. */
320 const struct missing_values *
321 var_get_missing_values (const struct variable *v)
326 /* Sets variable V's missing values to MISS, which must be of V's
327 width or at least resizable to V's width.
328 If MISS is null, then V's missing values, if any, are
331 var_set_missing_values (struct variable *v, const struct missing_values *miss)
335 assert (mv_is_resizable (miss, v->width));
336 mv_destroy (&v->miss);
337 mv_copy (&v->miss, miss);
338 mv_resize (&v->miss, v->width);
343 dict_var_changed (v);
346 /* Sets variable V to have no user-missing values. */
348 var_clear_missing_values (struct variable *v)
350 var_set_missing_values (v, NULL);
353 /* Returns true if V has any user-missing values,
356 var_has_missing_values (const struct variable *v)
358 return !mv_is_empty (&v->miss);
361 /* Returns true if VALUE is in the given CLASS of missing values
362 in V, false otherwise. */
364 var_is_value_missing (const struct variable *v, const union value *value,
367 return mv_is_value_missing (&v->miss, value, class);
370 /* Returns true if D is in the given CLASS of missing values in
372 V must be a numeric variable. */
374 var_is_num_missing (const struct variable *v, double d, enum mv_class class)
376 return mv_is_num_missing (&v->miss, d, class);
379 /* Returns true if S[] is a missing value for V, false otherwise.
380 S[] must contain exactly as many characters as V's width.
381 V must be a string variable. */
383 var_is_str_missing (const struct variable *v, const uint8_t s[],
386 return mv_is_str_missing (&v->miss, s, class);
389 /* Returns variable V's value labels,
390 possibly a null pointer if it has none. */
391 const struct val_labs *
392 var_get_value_labels (const struct variable *v)
397 /* Returns true if variable V has at least one value label. */
399 var_has_value_labels (const struct variable *v)
401 return val_labs_count (v->val_labs) > 0;
404 /* Sets variable V's value labels to a copy of VLS,
405 which must have a width equal to V's width or one that can be
406 changed to V's width.
407 If VLS is null, then V's value labels, if any, are removed. */
409 var_set_value_labels (struct variable *v, const struct val_labs *vls)
411 val_labs_destroy (v->val_labs);
416 assert (val_labs_can_set_width (vls, v->width));
417 v->val_labs = val_labs_clone (vls);
418 val_labs_set_width (v->val_labs, v->width);
419 dict_var_changed (v);
423 /* Makes sure that V has a set of value labels,
424 by assigning one to it if necessary. */
426 alloc_value_labels (struct variable *v)
428 if (v->val_labs == NULL)
429 v->val_labs = val_labs_create (v->width);
432 /* Attempts to add a value label with the given VALUE and UTF-8 encoded LABEL
433 to V. Returns true if successful, false otherwise (probably due to an
436 In LABEL, the two-byte sequence "\\n" is interpreted as a new-line. */
438 var_add_value_label (struct variable *v,
439 const union value *value, const char *label)
441 alloc_value_labels (v);
442 return val_labs_add (v->val_labs, value, label);
445 /* Adds or replaces a value label with the given VALUE and UTF-8 encoded LABEL
448 In LABEL, the two-byte sequence "\\n" is interpreted as a new-line. */
450 var_replace_value_label (struct variable *v,
451 const union value *value, const char *label)
453 alloc_value_labels (v);
454 val_labs_replace (v->val_labs, value, label);
457 /* Removes V's value labels, if any. */
459 var_clear_value_labels (struct variable *v)
461 var_set_value_labels (v, NULL);
464 /* Returns the label associated with VALUE for variable V, as a UTF-8 string in
465 a format suitable for output, or a null pointer if none. */
467 var_lookup_value_label (const struct variable *v, const union value *value)
469 return val_labs_find (v->val_labs, value);
473 Append to STR the string representation of VALUE for variable V.
474 STR must be a pointer to an initialised struct string.
477 append_value (const struct variable *v, const union value *value,
480 char *s = data_out (value, var_get_encoding (v), &v->print);
481 ds_put_cstr (str, s);
485 /* Append STR with a string representing VALUE for variable V.
486 That is, if VALUE has a label, append that label,
487 otherwise format VALUE and append the formatted string.
488 STR must be a pointer to an initialised struct string.
491 var_append_value_name (const struct variable *v, const union value *value,
494 enum settings_value_style style = settings_get_value_style ();
495 const char *name = var_lookup_value_label (v, value);
499 case SETTINGS_VAL_STYLE_VALUES:
500 append_value (v, value, str);
503 case SETTINGS_VAL_STYLE_LABELS:
505 append_value (v, value, str);
507 ds_put_cstr (str, name);
510 case SETTINGS_VAL_STYLE_BOTH:
512 append_value (v, value, str);
515 ds_put_cstr (str, " (");
516 ds_put_cstr (str, name);
517 ds_put_cstr (str, ")");
523 /* Print and write formats. */
525 /* Returns V's print format specification. */
526 const struct fmt_spec *
527 var_get_print_format (const struct variable *v)
532 /* Sets V's print format specification to PRINT, which must be a
533 valid format specification for a variable of V's width
534 (ordinarily an output format, but input formats are not
537 var_set_print_format (struct variable *v, const struct fmt_spec *print)
539 assert (fmt_check_width_compat (print, v->width));
541 dict_var_changed (v);
544 /* Returns V's write format specification. */
545 const struct fmt_spec *
546 var_get_write_format (const struct variable *v)
551 /* Sets V's write format specification to WRITE, which must be a
552 valid format specification for a variable of V's width
553 (ordinarily an output format, but input formats are not
556 var_set_write_format (struct variable *v, const struct fmt_spec *write)
558 assert (fmt_check_width_compat (write, v->width));
560 dict_var_changed (v);
563 /* Sets V's print and write format specifications to FORMAT,
564 which must be a valid format specification for a variable of
565 V's width (ordinarily an output format, but input formats are
568 var_set_both_formats (struct variable *v, const struct fmt_spec *format)
570 var_set_print_format (v, format);
571 var_set_write_format (v, format);
574 /* Returns the default print and write format for a variable of
575 the given TYPE, as set by var_create. The return value can be
576 used to reset a variable's print and write formats to the
579 var_default_formats (int width)
582 ? fmt_for_output (FMT_F, 8, 2)
583 : fmt_for_output (FMT_A, width, 0));
586 /* Return a string representing this variable, in the form most
587 appropriate from a human factors perspective, that is, its
588 variable label if it has one, otherwise its name. */
590 var_to_string (const struct variable *v)
592 return v->label != NULL ? v->label : v->name;
595 /* Returns V's variable label, or a null pointer if it has none. */
597 var_get_label (const struct variable *v)
602 /* Sets V's variable label to UTF-8 encoded string LABEL, stripping off leading
603 and trailing white space. If LABEL is a null pointer or if LABEL is an
604 empty string (after stripping white space), then V's variable label (if any)
607 Variable labels are limited to 255 bytes in V's encoding (as returned by
608 var_get_encoding()). If LABEL fits within this limit, this function returns
609 true. Otherwise, the variable label is set to a truncated value, this
610 function returns false and, if ISSUE_WARNING is true, issues a warning. */
612 var_set_label (struct variable *v, const char *label, bool issue_warning)
614 bool truncated = false;
619 if (label != NULL && label[strspn (label, CC_SPACES)])
621 const char *dict_encoding = var_get_encoding (v);
622 struct substring s = ss_cstr (label);
625 if (dict_encoding != NULL)
627 enum { MAX_LABEL_LEN = 255 };
629 trunc_len = utf8_encoding_trunc_len (label, dict_encoding,
631 if (ss_length (s) > trunc_len)
634 msg (SW, _("Truncating variable label for variable `%s' to %d "
635 "bytes."), var_get_name (v), MAX_LABEL_LEN);
636 ss_truncate (&s, trunc_len);
641 v->label = ss_xstrdup (s);
644 dict_var_changed (v);
649 /* Removes any variable label from V. */
651 var_clear_label (struct variable *v)
653 var_set_label (v, NULL, false);
656 /* Returns true if V has a variable V,
659 var_has_label (const struct variable *v)
661 return v->label != NULL;
664 /* Returns true if M is a valid variable measurement level,
667 measure_is_valid (enum measure m)
669 return m == MEASURE_NOMINAL || m == MEASURE_ORDINAL || m == MEASURE_SCALE;
672 /* Returns a string version of measurement level M, for display to a user. */
674 measure_to_string (enum measure m)
678 case MEASURE_NOMINAL:
681 case MEASURE_ORDINAL:
692 /* Returns V's measurement level. */
694 var_get_measure (const struct variable *v)
699 /* Sets V's measurement level to MEASURE. */
701 var_set_measure (struct variable *v, enum measure measure)
703 assert (measure_is_valid (measure));
704 v->measure = measure;
705 dict_var_changed (v);
708 /* Returns the default measurement level for a variable of the
709 given TYPE, as set by var_create. The return value can be
710 used to reset a variable's measurement level to the
713 var_default_measure (enum val_type type)
715 return type == VAL_NUMERIC ? MEASURE_SCALE : MEASURE_NOMINAL;
718 /* Returns V's display width, which applies only to GUIs. */
720 var_get_display_width (const struct variable *v)
722 return v->display_width;
725 /* Sets V's display width to DISPLAY_WIDTH. */
727 var_set_display_width (struct variable *v, int new_width)
729 if (v->display_width != new_width)
731 v->display_width = new_width;
732 dict_var_display_width_changed (v);
733 dict_var_changed (v);
737 /* Returns the default display width for a variable of the given
738 WIDTH, as set by var_create. The return value can be used to
739 reset a variable's display width to the default. */
741 var_default_display_width (int width)
743 return width == 0 ? 8 : MIN (width, 32);
746 /* Returns true if A is a valid alignment,
749 alignment_is_valid (enum alignment a)
751 return a == ALIGN_LEFT || a == ALIGN_RIGHT || a == ALIGN_CENTRE;
754 /* Returns a string version of alignment A, for display to a user. */
756 alignment_to_string (enum alignment a)
774 /* Returns V's display alignment, which applies only to GUIs. */
776 var_get_alignment (const struct variable *v)
781 /* Sets V's display alignment to ALIGNMENT. */
783 var_set_alignment (struct variable *v, enum alignment alignment)
785 assert (alignment_is_valid (alignment));
786 v->alignment = alignment;
787 dict_var_changed (v);
790 /* Returns the default display alignment for a variable of the
791 given TYPE, as set by var_create. The return value can be
792 used to reset a variable's display alignment to the default. */
794 var_default_alignment (enum val_type type)
796 return type == VAL_NUMERIC ? ALIGN_RIGHT : ALIGN_LEFT;
799 /* Whether variables' values should be preserved from case to
802 /* Returns true if variable V's value should be left from case to
803 case, instead of being reset to system-missing or blanks. */
805 var_get_leave (const struct variable *v)
810 /* Sets V's leave setting to LEAVE. */
812 var_set_leave (struct variable *v, bool leave)
814 assert (leave || !var_must_leave (v));
816 dict_var_changed (v);
819 /* Returns true if V must be left from case to case,
820 false if it can be set either way. */
822 var_must_leave (const struct variable *v)
824 return var_get_dict_class (v) == DC_SCRATCH;
827 /* Returns the number of short names stored in VAR.
829 Short names are used only for system and portable file input
830 and output. They are upper-case only, not necessarily unique,
831 and limited to SHORT_NAME_LEN characters (plus a null
832 terminator). Ordinarily a variable has at most one short
833 name, but very long string variables (longer than 255 bytes)
834 may have more. A variable might not have any short name at
835 all if it hasn't been saved to or read from a system or
838 var_get_short_name_cnt (const struct variable *var)
840 return var->short_name_cnt;
843 /* Returns VAR's short name with the given IDX, if it has one
844 with that index, or a null pointer otherwise. Short names may
845 be sparse: even if IDX is less than the number of short names
846 in VAR, this function may return a null pointer. */
848 var_get_short_name (const struct variable *var, size_t idx)
850 return idx < var->short_name_cnt ? var->short_names[idx] : NULL;
853 /* Sets VAR's short name with the given IDX to the UTF-8 string SHORT_NAME.
854 The caller must already have checked that, in the dictionary encoding,
855 SHORT_NAME is no more than SHORT_NAME_LEN bytes long. The new short name
856 will be converted to uppercase.
858 Specifying a null pointer for SHORT_NAME clears the specified short name. */
860 var_set_short_name (struct variable *var, size_t idx, const char *short_name)
862 assert (short_name == NULL || id_is_plausible (short_name, false));
864 /* Clear old short name numbered IDX, if any. */
865 if (idx < var->short_name_cnt)
867 free (var->short_names[idx]);
868 var->short_names[idx] = NULL;
871 /* Install new short name for IDX. */
872 if (short_name != NULL)
874 if (idx >= var->short_name_cnt)
876 size_t old_cnt = var->short_name_cnt;
878 var->short_name_cnt = MAX (idx * 2, 1);
879 var->short_names = xnrealloc (var->short_names, var->short_name_cnt,
880 sizeof *var->short_names);
881 for (i = old_cnt; i < var->short_name_cnt; i++)
882 var->short_names[i] = NULL;
884 var->short_names[idx] = xstrdup (short_name);
885 str_uppercase (var->short_names[idx]);
888 dict_var_changed (var);
891 /* Clears V's short names. */
893 var_clear_short_names (struct variable *v)
897 for (i = 0; i < v->short_name_cnt; i++)
898 free (v->short_names[i]);
899 free (v->short_names);
900 v->short_names = NULL;
901 v->short_name_cnt = 0;
904 /* Relationship with dictionary. */
906 /* Returns V's index within its dictionary, the value
907 for which "dict_get_var (dict, index)" will return V.
908 V must be in a dictionary. */
910 var_get_dict_index (const struct variable *v)
912 assert (var_has_vardict (v));
913 return vardict_get_dict_index (v->vardict);
916 /* Returns V's index within the case represented by its
917 dictionary, that is, the value for which "case_data_idx (case,
918 index)" will return the data for V in that case.
919 V must be in a dictionary. */
921 var_get_case_index (const struct variable *v)
923 assert (var_has_vardict (v));
924 return vardict_get_case_index (v->vardict);
927 /* Returns V's auxiliary data, or a null pointer if none has been
930 var_get_aux (const struct variable *v)
935 /* Assign auxiliary data AUX to variable V, which must not
936 already have auxiliary data. Before V's auxiliary data is
937 cleared, AUX_DTOR(V) will be called. (var_dtor_free, below,
938 may be appropriate for use as AUX_DTOR.) */
940 var_attach_aux (const struct variable *v_,
941 void *aux, void (*aux_dtor) (struct variable *))
943 struct variable *v = CONST_CAST (struct variable *, v_);
944 assert (v->aux == NULL);
945 assert (aux != NULL);
947 v->aux_dtor = aux_dtor;
951 /* Remove auxiliary data, if any, from V, and return it, without
952 calling any associated destructor. */
954 var_detach_aux (struct variable *v)
957 assert (aux != NULL);
962 /* Clears auxiliary data, if any, from V, and calls any
963 associated destructor. */
965 var_clear_aux (struct variable *v)
969 if (v->aux_dtor != NULL)
975 /* This function is appropriate for use an auxiliary data
976 destructor (passed as AUX_DTOR to var_attach_aux()) for the
977 case where the auxiliary data should be passed to free(). */
979 var_dtor_free (struct variable *v)
984 /* Returns variable V's attribute set. The caller may examine or
985 modify the attribute set, but must not destroy it. Destroying
986 V, or calling var_set_attributes() on V, will also destroy its
989 var_get_attributes (const struct variable *v)
991 return CONST_CAST (struct attrset *, &v->attributes);
994 /* Replaces variable V's attributes set by a copy of ATTRS. */
996 var_set_attributes (struct variable *v, const struct attrset *attrs)
998 attrset_destroy (&v->attributes);
999 attrset_clone (&v->attributes, attrs);
1002 /* Returns true if V has any custom attributes, false if it has none. */
1004 var_has_attributes (const struct variable *v)
1006 return attrset_count (&v->attributes) > 0;
1009 /* Returns the encoding of values of variable VAR. (This is actually a
1010 property of the dictionary.) Returns null if no specific encoding has been
1013 var_get_encoding (const struct variable *var)
1015 return (var_has_vardict (var)
1016 ? dict_get_encoding (vardict_get_dictionary (var->vardict))
1020 /* Returns V's vardict structure. */
1021 struct vardict_info *
1022 var_get_vardict (const struct variable *v)
1024 return CONST_CAST (struct vardict_info *, v->vardict);
1027 /* Sets V's vardict data to VARDICT. */
1029 var_set_vardict (struct variable *v, struct vardict_info *vardict)
1031 v->vardict = vardict;
1034 /* Returns true if V has vardict data. */
1036 var_has_vardict (const struct variable *v)
1038 return v->vardict != NULL;
1041 /* Clears V's vardict data. */
1043 var_clear_vardict (struct variable *v)