X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdictionary%2Fvalue-labels.c;h=c39bebd4caed1c65283887896b21df00ab9ea96c;hb=799e56c0e3a9911a860607e1c07caf2acf8cc9ef;hp=96b80ba735294adad2dd73852c464eed45c3f933;hpb=dcf9b154cbcaa35c3d8459a201b77eec8bcb30bd;p=pspp diff --git a/src/language/dictionary/value-labels.c b/src/language/dictionary/value-labels.c index 96b80ba735..c39bebd4ca 100644 --- a/src/language/dictionary/value-labels.c +++ b/src/language/dictionary/value-labels.c @@ -18,23 +18,27 @@ 02110-1301, USA. */ #include + #include #include -#include "alloc.h" -#include "command.h" -#include "message.h" -#include "hash.h" -#include "lexer.h" -#include "str.h" -#include "value-labels.h" -#include "variable.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "gettext.h" #define _(msgid) gettext (msgid) /* Declarations. */ -static int do_value_labels (int); +static int do_value_labels (const struct dictionary *dict, int); static int verify_val_labs (struct variable **vars, size_t var_cnt); static void erase_labels (struct variable **vars, size_t var_cnt); static int get_label (struct variable **vars, size_t var_cnt); @@ -42,21 +46,21 @@ static int get_label (struct variable **vars, size_t var_cnt); /* Stubs. */ int -cmd_value_labels (void) +cmd_value_labels (struct dataset *ds) { - return do_value_labels (1); + return do_value_labels (dataset_dict (ds), 1); } int -cmd_add_value_labels (void) +cmd_add_value_labels (struct dataset *ds) { - return do_value_labels (0); + return do_value_labels (dataset_dict (ds), 0); } /* Do it. */ static int -do_value_labels (int erase) +do_value_labels (const struct dictionary *dict, int erase) { struct variable **vars; /* Variable list. */ size_t var_cnt; /* Number of variables. */ @@ -66,7 +70,7 @@ do_value_labels (int erase) while (token != '.') { - parse_err = !parse_variables (default_dict, &vars, &var_cnt, + parse_err = !parse_variables (dict, &vars, &var_cnt, PV_SAME_TYPE) ; if (var_cnt < 1) { @@ -92,17 +96,14 @@ do_value_labels (int erase) free (vars); } - if (token != '.') - { - lex_error (NULL); - return CMD_TRAILING_GARBAGE; - } + if (parse_err) + return CMD_FAILURE; - return parse_err ? CMD_PART_SUCCESS_MAYBE : CMD_SUCCESS; + return lex_end_of_command (); lossage: free (vars); - return CMD_PART_SUCCESS_MAYBE; + return CMD_FAILURE; } /* Verifies that none of the VAR_CNT variables in VARS are long @@ -157,7 +158,7 @@ get_label (struct variable **vars, size_t var_cnt) lex_error (_("expecting string")); return 0; } - buf_copy_str_rpad (value.s, MAX_SHORT_STRING, ds_c_str (&tokstr)); + buf_copy_str_rpad (value.s, MAX_SHORT_STRING, ds_cstr (&tokstr)); } else { @@ -180,7 +181,7 @@ get_label (struct variable **vars, size_t var_cnt) msg (SW, _("Truncating value label to 60 characters.")); ds_truncate (&tokstr, 60); } - label = ds_c_str (&tokstr); + label = ds_cstr (&tokstr); for (i = 0; i < var_cnt; i++) val_labs_replace (vars[i]->val_labs, value, label);