From: Hui Zhu <teawater@gmail.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Keith Seitz <keiths@redhat.com>,
gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [PATCH Bug breakpoints/14381] Fix linespec to parse file name that begin with decimal numbers
Date: Tue, 24 Jul 2012 03:48:00 -0000 [thread overview]
Message-ID: <CANFwon2KzfyOzhV625S7xqMAw6+iLjmUz8oHjaC=T=PUshUZZw@mail.gmail.com> (raw)
In-Reply-To: <87k3xusgan.fsf@fleche.redhat.com>
On Mon, Jul 23, 2012 at 10:28 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> ">" == Hui Zhu <teawater@gmail.com> writes:
>
>>> The string begin with a number is not a error, why handle it as a
>>> error? I think that will really make this part obfuscates.
>>> What I thought is change the function name to
>>> linespec_lexer_lex_number_string to make it clear.
>
> How about changing linespec_lexer_lex_number to return a boolean
> indicating whether it succeeded? This is basically the same idea, but
> without introducing a new token.
>
> Tom
Agree with you. Post a new patch according to your comments.
Thanks,
Hui
2012-07-24 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.
---
linespec.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
--- a/linespec.c
+++ b/linespec.c
@@ -366,31 +366,38 @@ static const char *const linespec_quote_
/* 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 +731,8 @@ linespec_lexer_lex_one (linespec_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 ':':
next prev parent reply other threads:[~2012-07-24 3:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-22 6:30 Hui Zhu
2012-07-22 7:11 ` Jan Kratochvil
2012-07-22 8:55 ` Hui Zhu
2012-07-22 10:11 ` Hui Zhu
2012-07-22 10:52 ` Jan Kratochvil
2012-07-23 14:26 ` Tom Tromey
2012-07-23 18:04 ` Keith Seitz
2012-07-22 14:12 ` Keith Seitz
2012-07-22 14:48 ` Hui Zhu
2012-07-23 14:28 ` Tom Tromey
2012-07-23 17:17 ` Keith Seitz
2012-07-24 3:48 ` Hui Zhu [this message]
2012-07-24 19:36 ` Tom Tromey
2012-07-25 12:57 ` Hui Zhu
2012-07-25 21:21 ` Keith Seitz
2012-07-26 13:52 ` Tom Tromey
2012-07-26 18:21 ` Keith Seitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANFwon2KzfyOzhV625S7xqMAw6+iLjmUz8oHjaC=T=PUshUZZw@mail.gmail.com' \
--to=teawater@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=keiths@redhat.com \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox