lexer: Fix negative 'n0' and 'n1' in lex_source_contains_macro_call().
[pspp] / src / language / lexer / lexer.c
index 1fadf53b3079e9758bc4e13a5fc8bc36f1d0a046..d7d7eae588e156a6ba7a19f373c236dbc155b424 100644 (file)
@@ -531,7 +531,19 @@ lex_error_expecting_array (struct lexer *lexer, const char **options, size_t n)
       break;
 
     default:
-      lex_error (lexer, NULL);
+      {
+        struct string s = DS_EMPTY_INITIALIZER;
+        for (size_t i = 0; i < n; i++)
+          {
+            if (i > 0)
+              ds_put_cstr (&s, ", ");
+            ds_put_cstr (&s, options[i]);
+          }
+        lex_error (lexer, _("expecting one of the following: %s"),
+                   ds_cstr (&s));
+        ds_destroy (&s);
+      }
+      break;
     }
 }
 
@@ -1862,7 +1874,7 @@ lex_source_syntax__ (const struct lex_source *src, int ofs0, int ofs1)
 static bool
 lex_source_contains_macro_call (struct lex_source *src, int n0, int n1)
 {
-  for (size_t i = n0; i <= n1; i++)
+  for (int i = n0; i <= n1; i++)
     if (lex_source_next__ (src, i)->macro_rep)
       return true;
   return false;