{
unsigned int pos;
+ bool drop;
+ union value tmp;
+
char name[9];
int width;
struct fmt_spec format;
struct pcp_value_label *val_labs;
size_t n_val_labs;
-
- struct variable *var;
};
struct pcp_value_label
return aux.n;
}
-static void
-find_and_delete_var (struct dictionary *dict, const char *name)
-{
- struct variable *var = dict_lookup_var (dict, name);
- if (var)
- dict_delete_var (dict, var);
-}
-
/* Decodes the dictionary read from R, saving it into *DICT. Character
strings in R are decoded using ENCODING, or an encoding obtained from R if
ENCODING is null, or the locale encoding if R specifies no encoding.
dictionary and may destroy or modify its variables. */
r->proto = caseproto_ref_pool (dict_get_proto (dict), r->pool);
- find_and_delete_var (dict, "CASENUM_");
- find_and_delete_var (dict, "DATE_");
- find_and_delete_var (dict, "WEIGHT_");
-
*dictp = dict;
if (infop)
{
for (rec = var_recs; rec < &var_recs[n_var_recs]; rec++)
{
- struct variable *var;
char *name;
size_t i;
rec->name, -1, r->pool);
name[strcspn (name, " ")] = '\0';
- /* Transform $DATE => DATE_, $WEIGHT => WEIGHT_, $CASENUM => CASENUM_. */
- if (name[0] == '$')
- name = pool_asprintf (r->pool, "%s_", name + 1);
+ /* Drop system variables. */
+ rec->drop = name[0] == '$';
+ if (rec->drop)
+ {
+ value_init_pool (r->pool, &rec->tmp, rec->width);
+ continue;
+ }
if (!dict_id_is_valid (dict, name) || name[0] == '#')
{
return false;
}
- var = rec->var = dict_create_var (dict, name, rec->width);
+ struct variable *var = dict_create_var (dict, name, rec->width);
if (var == NULL)
{
char *new_name = dict_make_unique_var_name (dict, NULL, NULL);
pcp_warn (r, rec->pos, _("Renaming variable with duplicate name "
"`%s' to `%s'."),
name, new_name);
- var = rec->var = dict_create_var_assert (dict, new_name, rec->width);
+ var = dict_create_var_assert (dict, new_name, rec->width);
free (new_name);
}
if (rec->weight)
r->n_cases--;
c = case_create (r->proto);
+ size_t case_idx = 0;
for (i = 0; i < r->n_vars; i++)
{
struct pcp_var_record *var = &r->vars[i];
- union value *v = case_data_rw_idx (c, i);
+ union value *v = var->drop ? &var->tmp : case_data_rw_idx (c, case_idx++);
if (var->width == 0)
retval = read_case_number (r, &v->f);