From 0c60dc4c665721688d9b09d1f1f145f9cd5a1f9f Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 13 Sep 2008 08:37:08 +0800 Subject: [PATCH] New function: var_create_internal. Added a new function for creating "internal" variables. Ie, those which don't appear in any dictionary, and are for the purposes of internal calculations. --- po/en_GB.po | 12 ++++++------ src/data/variable.c | 23 ++++++++++++++++++++++- src/data/variable.h | 2 ++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/po/en_GB.po b/po/en_GB.po index 4cef93ae..b6911c93 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.4.3\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2008-09-13 07:24+0800\n" +"POT-Creation-Date: 2008-09-13 08:26+0800\n" "PO-Revision-Date: 2007-09-15 08:29+0800\n" "Last-Translator: John Darrington \n" "Language-Team: John Darrington \n" @@ -976,28 +976,28 @@ msgstr "" msgid "An I/O error occurred writing system file \"%s\"." msgstr "" -#: src/data/variable.c:209 +#: src/data/variable.c:225 #, c-format msgid "" "Character `%c' (in %s) may not appear as the first character in a variable " "name." msgstr "" -#: src/data/variable.c:221 +#: src/data/variable.c:237 #, c-format msgid "Character `%c' (in %s) may not appear in a variable name." msgstr "" -#: src/data/variable.c:249 +#: src/data/variable.c:265 msgid "Variable name cannot be empty string." msgstr "" -#: src/data/variable.c:255 +#: src/data/variable.c:271 #, c-format msgid "Variable name %s exceeds %d-character limit." msgstr "" -#: src/data/variable.c:263 +#: src/data/variable.c:279 #, c-format msgid "`%s' may not be used as a variable name because it is a reserved word." msgstr "" diff --git a/src/data/variable.c b/src/data/variable.c index a455e40a..e39692a0 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -142,6 +142,23 @@ var_clone (const struct variable *old_var) return new_var; } +/* Create a variable to be used for internal calculations only */ +struct variable * +var_create_internal (int case_idx) +{ + struct variable *v = var_create ("$internal", 0); + + struct vardict_info vdi; + + vdi.dict = NULL; + vdi.dict_index = 0; + vdi.case_index = case_idx; + + var_set_vardict (v, &vdi); + + return v; +} + /* Destroys variable V. V must not belong to a dictionary. If it does, use dict_delete_var instead. */ @@ -150,7 +167,11 @@ var_destroy (struct variable *v) { if (v != NULL) { - assert (!var_has_vardict (v)); + if (var_has_vardict (v)) + { + const struct vardict_info *vdi = var_get_vardict (v); + assert (vdi->dict == NULL); + } cat_stored_values_destroy (v->obs_vals); var_clear_short_names (v); var_clear_aux (v); diff --git a/src/data/variable.h b/src/data/variable.h index c7f86aaf..d2820d34 100644 --- a/src/data/variable.h +++ b/src/data/variable.h @@ -32,6 +32,8 @@ union value; struct variable *var_create (const char *name, int width); struct variable *var_clone (const struct variable *); void var_destroy (struct variable *); +struct variable *var_create_internal (int case_idx); + /* Variable names. */ #define VAR_NAME_LEN 64 /* Maximum length of variable name, in bytes. */ -- 2.30.2