aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHui Zhu <teawater@gmail.com>2012-07-25 12:26:27 +0000
committerHui Zhu <teawater@gmail.com>2012-07-25 12:26:27 +0000
commitd7cbec71c938cb53924b6d30ae28644e3a344a47 (patch)
tree9da52ed4ef4e88486d1b4b5ec699cc9d5410f366
parent9e2934f7999c248f7e8452d0726541ce9ad9edce (diff)
downloadgdb-d7cbec71c938cb53924b6d30ae28644e3a344a47.zip
gdb-d7cbec71c938cb53924b6d30ae28644e3a344a47.tar.gz
gdb-d7cbec71c938cb53924b6d30ae28644e3a344a47.tar.bz2
2012-07-25 Hui Zhu <hui_zhu@mentor.com>
* linespec.c (linespec_lexer_lex_number): Update comments, change the return and add check to make sure the input is the decimal numbers. (linespec_lexer_lex_one): If linespec_lexer_lex_number return false, call linespec_lexer_lex_string.
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/linespec.c30
2 files changed, 26 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a14a25f..97cc3ea 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2012-07-25 Hui Zhu <hui_zhu@mentor.com>
+
+ * linespec.c (linespec_lexer_lex_number): Update comments,
+ change the return and add check to make sure the input is
+ the decimal numbers.
+ (linespec_lexer_lex_one): If linespec_lexer_lex_number return
+ false, call linespec_lexer_lex_string.
+
2012-07-24 Tom Tromey <tromey@redhat.com>
* symfile.c (symbol_file_add): Don't open BFD twice.
diff --git a/gdb/linespec.c b/gdb/linespec.c
index e85be68..c72bb4b 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -366,31 +366,36 @@ static const char *const linespec_quote_characters = "\"\'";
/* Lexer functions. */
/* Lex a number from the input in PARSER. This only supports
- decimal numbers. */
+ decimal numbers.\
+ Return true if input is decimal numbers. Return false if not. */
-static linespec_token
-linespec_lexer_lex_number (linespec_parser *parser)
+static int
+linespec_lexer_lex_number (linespec_parser *parser, linespec_token *tokenp)
{
- linespec_token token;
-
- token.type = LSTOKEN_NUMBER;
- LS_TOKEN_STOKEN (token).length = 0;
- LS_TOKEN_STOKEN (token).ptr = PARSER_STREAM (parser);
+ tokenp->type = LSTOKEN_NUMBER;
+ LS_TOKEN_STOKEN (*tokenp).length = 0;
+ LS_TOKEN_STOKEN (*tokenp).ptr = PARSER_STREAM (parser);
/* Keep any sign at the start of the stream. */
if (*PARSER_STREAM (parser) == '+' || *PARSER_STREAM (parser) == '-')
{
- ++LS_TOKEN_STOKEN (token).length;
+ ++LS_TOKEN_STOKEN (*tokenp).length;
++(PARSER_STREAM (parser));
}
while (isdigit (*PARSER_STREAM (parser)))
{
- ++LS_TOKEN_STOKEN (token).length;
+ ++LS_TOKEN_STOKEN (*tokenp).length;
++(PARSER_STREAM (parser));
}
- return token;
+ if (*PARSER_STREAM (parser) != '\0' && !isspace(*PARSER_STREAM (parser)))
+ {
+ PARSER_STREAM (parser) = LS_TOKEN_STOKEN (*tokenp).ptr;
+ return 0;
+ }
+
+ return 1;
}
/* Does P represent one of the keywords? If so, return
@@ -724,7 +729,8 @@ linespec_lexer_lex_one (linespec_parser *parser)
case '+': case '-':
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- parser->lexer.current = linespec_lexer_lex_number (parser);
+ if (!linespec_lexer_lex_number (parser, &(parser->lexer.current)))
+ parser->lexer.current = linespec_lexer_lex_string (parser);
break;
case ':':