#include "libpspp/array.h"
#include "libpspp/assertion.h"
#include "libpspp/compiler.h"
-#include "libpspp/hash.h"
#include "libpspp/i18n.h"
#include "libpspp/message.h"
#include "libpspp/misc.h"
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,
dict_add_mrset (dict, mrset);
mrset = NULL;
+ stringi_set_destroy (&var_names);
}
mrset_destroy (mrset);
close_text_record (r, text);
first 255 bytes. The maximum documented length
of a label is 120 bytes so this is more than
generous. */
- skip_bytes (r, sizeof label - (label_length + 1));
+ skip_bytes (r, (label_length + 1) - sizeof label);
}
if (!skip && !var_add_value_label (v, &value, label))
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);
}
}
}
+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,