X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fsort-criteria.c;h=36466cd410f9bfdb89a2db6588fbbe6ba3c6a21d;hb=4e8bfea364b7a1d2d496e14dfefc9dfeefff8d11;hp=649760235432fc4222ed70fed7353d7e815a0027;hpb=55e6e7ba37a30570f5a31e2d78c22dfa7b61a36f;p=pspp diff --git a/src/language/stats/sort-criteria.c b/src/language/stats/sort-criteria.c index 6497602354..36466cd410 100644 --- a/src/language/stats/sort-criteria.c +++ b/src/language/stats/sort-criteria.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2010, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,16 +16,16 @@ #include -#include +#include "language/stats/sort-criteria.h" #include -#include -#include -#include -#include -#include -#include +#include "data/dictionary.h" +#include "data/subcase.h" +#include "data/variable.h" +#include "language/lexer/lexer.h" +#include "language/lexer/variable-parser.h" +#include "libpspp/message.h" #include "gettext.h" #define _(msgid) gettext (msgid) @@ -42,9 +42,9 @@ parse_sort_criteria (struct lexer *lexer, const struct dictionary *dict, const struct variable ***vars, bool *saw_direction) { const struct variable **local_vars = NULL; - size_t var_cnt = 0; + size_t n_vars = 0; - if (vars == NULL) + if (vars == NULL) vars = &local_vars; *vars = NULL; @@ -53,12 +53,12 @@ parse_sort_criteria (struct lexer *lexer, const struct dictionary *dict, do { - size_t prev_var_cnt = var_cnt; + size_t prev_n_vars = n_vars; enum subcase_direction direction; size_t i; /* Variables. */ - if (!parse_variables_const (lexer, dict, vars, &var_cnt, + if (!parse_variables_const (lexer, dict, vars, &n_vars, PV_APPEND | PV_NO_SCRATCH)) goto error; @@ -71,26 +71,23 @@ parse_sort_criteria (struct lexer *lexer, const struct dictionary *dict, direction = SC_ASCEND; else { - msg (SE, _("`A' or `D' expected inside parentheses.")); - goto error; - } - if (!lex_match (lexer, T_RPAREN)) - { - msg (SE, _("`)' expected.")); + lex_error_expecting (lexer, "A", "D"); goto error; } + if (!lex_force_match (lexer, T_RPAREN)) + goto error; if (saw_direction != NULL) *saw_direction = true; } else direction = SC_ASCEND; - for (i = prev_var_cnt; i < var_cnt; i++) + for (i = prev_n_vars; i < n_vars; i++) { const struct variable *var = (*vars)[i]; if (!subcase_add_var (ordering, var, direction)) msg (SW, _("Variable %s specified twice in sort criteria."), - var_get_name (var)); + var_get_name (var)); } } while (lex_token (lexer) == T_ID