X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fsort-criteria.c;h=0556f93b6821ef2457c82445aa984ccfde2af6f9;hb=281b782ae22cffb6c8b1c1ac31e9555cfcd2fae6;hp=d808d1c203a161129a6de377dc834330d7528bff;hpb=691c25e36fd1ee722dd35419d6110e3876b99f9c;p=pspp diff --git a/src/language/stats/sort-criteria.c b/src/language/stats/sort-criteria.c index d808d1c203..0556f93b68 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) @@ -44,7 +44,7 @@ parse_sort_criteria (struct lexer *lexer, const struct dictionary *dict, const struct variable **local_vars = NULL; size_t var_cnt = 0; - if (vars == NULL) + if (vars == NULL) vars = &local_vars; *vars = NULL; @@ -71,30 +71,27 @@ 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", NULL_SENTINEL); 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_var_cnt; i < var_cnt; 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 - && dict_lookup_var (dict, lex_tokid (lexer)) != NULL); + && dict_lookup_var (dict, lex_tokcstr (lexer)) != NULL); free (local_vars); return true;