INPUT PROGRAM: Avoid infinite loop for trivially empty input program.
[pspp] / src / language / stats / sort-criteria.c
index d808d1c203a161129a6de377dc834330d7528bff..a8c1ff13d221424119a348320ba7b0549e804165 100644 (file)
@@ -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
 
 #include <config.h>
 
-#include <language/stats/sort-criteria.h>
+#include "language/stats/sort-criteria.h"
 
 #include <stdlib.h>
 
-#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 "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)
@@ -71,14 +71,11 @@ 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;
        }
@@ -94,7 +91,7 @@ parse_sort_criteria (struct lexer *lexer, const struct dictionary *dict,
         }
     }
   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;