X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fsys-file-reader.c;h=268023cf2f3ed71ab529e7f41a1afe9144ddc839;hb=refs%2Fbuilds%2F20100724040501%2Fpspp;hp=48a5188fb65fe39586804774c6e1f96b09ea0a92;hpb=78b2280e4d75fc07ce0f17c3607c0707f7ccb819;p=pspp diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 48a5188fb6..268023cf2f 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -42,7 +42,6 @@ #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" @@ -133,6 +132,10 @@ static void text_warn (struct sfm_reader *r, struct text_record *text, 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, @@ -1675,7 +1678,7 @@ read_long_string_value_labels (struct sfm_reader *r, 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)) @@ -1697,7 +1700,7 @@ read_variable_attributes (struct sfm_reader *r, 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); } @@ -2131,6 +2134,27 @@ read_variable_to_value_pair (struct sfm_reader *r, struct dictionary *dict, } } +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,