Michel Boaventura provided a system file for which PSPP complained about
bad variable attributes records. I found out that this was because the
variables were specified using long names, not short names. This commit
allows PSPP to read these variable attributes properly.
In record type 18, this field contains a sequence of one or more
variable attribute sets. If more than one variable attribute set is
present, each one after the first is delimited from the previous by
In record type 18, this field contains a sequence of one or more
variable attribute sets. If more than one variable attribute set is
present, each one after the first is delimited from the previous by
-@code{/}. Each variable attribute set consists of a variable name,
+@code{/}. Each variable attribute set consists of a (potentially
+long) variable name,
followed by @code{:}, followed by an attribute set with the same
syntax as on record type 17.
followed by @code{:}, followed by an attribute set with the same
syntax as on record type 17.
static char *text_get_token (struct text_record *,
struct substring delimiters, char *delimiter);
static bool text_match (struct text_record *, char c);
static char *text_get_token (struct text_record *,
struct substring delimiters, char *delimiter);
static bool text_match (struct text_record *, char c);
+static bool text_read_variable_name (struct sfm_reader *, struct dictionary *,
+ struct text_record *,
+ struct substring delimiters,
+ struct variable **);
static bool text_read_short_name (struct sfm_reader *, struct dictionary *,
struct text_record *,
struct substring delimiters,
static bool text_read_short_name (struct sfm_reader *, struct dictionary *,
struct text_record *,
struct substring delimiters,
for (;;)
{
struct variable *var;
for (;;)
{
struct variable *var;
- if (!text_read_short_name (r, dict, text, ss_cstr (":"), &var))
+ if (!text_read_variable_name (r, dict, text, ss_cstr (":"), &var))
break;
read_attributes (r, text, var != NULL ? var_get_attributes (var) : NULL);
}
break;
read_attributes (r, text, var != NULL ? var_get_attributes (var) : NULL);
}
+static bool
+text_read_variable_name (struct sfm_reader *r, struct dictionary *dict,
+ struct text_record *text, struct substring delimiters,
+ struct variable **var)
+{
+ char *name;
+
+ name = text_get_token (text, delimiters, NULL);
+ if (name == NULL)
+ return false;
+
+ *var = dict_lookup_var (dict, name);
+ if (*var != NULL)
+ return true;
+
+ text_warn (r, text, _("Dictionary record refers to unknown variable %s."),
+ name);
+ return false;
+}
+
+
static bool
text_read_short_name (struct sfm_reader *r, struct dictionary *dict,
struct text_record *text, struct substring delimiters,
static bool
text_read_short_name (struct sfm_reader *r, struct dictionary *dict,
struct text_record *text, struct substring delimiters,