lexer: Fix implementation of lex_force_string_or_id().
[pspp] / src / language / lexer / lexer.c
index 1f455119f00b1779f51787d54dedf4b469c46b1b..a3642f8a6c6f7e7f5fc5b9376ee31db8308e9efa 100644 (file)
@@ -604,9 +604,16 @@ lex_force_match (struct lexer *lexer, enum token_type type)
     }
   else
     {
-      char *s = xasprintf ("`%s'", token_type_to_string (type));
-      lex_error_expecting (lexer, s, NULL_SENTINEL);
-      free (s);
+      const char *type_string = token_type_to_string (type);
+      if (type_string)
+       {
+         char *s = xasprintf ("`%s'", type_string);
+         lex_error_expecting (lexer, s, NULL_SENTINEL);
+         free (s);
+       }
+      else
+       lex_error_expecting (lexer, token_type_to_name (type), NULL_SENTINEL);
+
       return false;
     }
 }
@@ -637,7 +644,7 @@ lex_force_string (struct lexer *lexer)
 bool
 lex_force_string_or_id (struct lexer *lexer)
 {
-  return lex_is_integer (lexer) || lex_force_string (lexer);
+  return lex_token (lexer) == T_ID || lex_force_string (lexer);
 }
 
 /* If the current token is an integer, does nothing and returns true.