From: John Darrington Date: Fri, 1 Apr 2016 09:30:44 +0000 (+0200) Subject: value-parser.c (parse_number): Simplified logic and removed redundant lines. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6a62580b53945471660ac9090dac4481e123983;p=pspp value-parser.c (parse_number): Simplified logic and removed redundant lines. --- diff --git a/src/language/lexer/value-parser.c b/src/language/lexer/value-parser.c index cc73176a38..55707f6ac5 100644 --- a/src/language/lexer/value-parser.c +++ b/src/language/lexer/value-parser.c @@ -96,13 +96,7 @@ parse_num_range (struct lexer *lexer, static bool parse_number (struct lexer *lexer, double *x, const enum fmt_type *format) { - if (lex_is_number (lexer)) - { - *x = lex_number (lexer); - lex_get (lexer); - return true; - } - else if (lex_is_string (lexer) && format != NULL) + if (lex_is_string (lexer) && format != NULL) { union value v; @@ -120,14 +114,15 @@ parse_number (struct lexer *lexer, double *x, const enum fmt_type *format) } return true; } - else + + if (lex_force_num (lexer)) { - if (format != NULL) - lex_error (lexer, _("expecting number or data string")); - else - lex_force_num (lexer); - return false; + *x = lex_number (lexer); + lex_get (lexer); + return true; } + + return false; } /* Parses the current token from LEXER into value V, which must already have