output.c: cmd_output: Check return values of lex_force_match
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 1 Apr 2016 09:44:17 +0000 (11:44 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 1 Apr 2016 10:17:35 +0000 (12:17 +0200)
src/language/utilities/output.c

index fc390992b96b494de1bf81b7367b43e99f4f6dba..45aa638743143193a3e61b4a73752a97d8f17886 100644 (file)
@@ -100,8 +100,11 @@ cmd_output (struct lexer *lexer, struct dataset *ds UNUSED)
            {
              if (lex_match_id (lexer, "SELECT"))
                {
-                 lex_force_match (lexer, T_EQUALS);
-                 lex_force_match (lexer, T_LBRACK);
+                 if (! lex_force_match (lexer, T_EQUALS))
+                   goto error;
+                 
+                 if (! lex_force_match (lexer, T_LBRACK))
+                   goto error;
                  
                  while (lex_token (lexer) != T_RBRACK &&
                         lex_token (lexer) != T_ENDCMD)
@@ -122,7 +125,8 @@ cmd_output (struct lexer *lexer, struct dataset *ds UNUSED)
                          goto error;
                        }
                    }
-                 lex_force_match (lexer, T_RBRACK);
+                 if (! lex_force_match (lexer, T_RBRACK))
+                   goto error;
                }
              else if (lex_match_id (lexer, "FORMAT"))
                {
@@ -131,7 +135,8 @@ cmd_output (struct lexer *lexer, struct dataset *ds UNUSED)
                  int width = -1;
                  int decimals = -1;
 
-                 lex_force_match (lexer, T_EQUALS);
+                 if (! lex_force_match (lexer, T_EQUALS))
+                   goto error;
                  if (! parse_abstract_format_specifier (lexer, type, &width, &decimals))
                    {
                      lex_error (lexer, NULL);