public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-keiths-linespec-rewrite: * linespec.c (struct ls_parser): Add is_quote_enclosed member. (linespec_quote_characters): New constant. (linespec_lexer_lex_string): Permit quote-enclosed linespecs. (linespec_lexer_lex_one): Likewise. (parse_linespec): Likewise.
@ 2012-03-26 18:30 kseitz
0 siblings, 0 replies; only message in thread
From: kseitz @ 2012-03-26 18:30 UTC (permalink / raw)
To: archer-commits
The branch, archer-keiths-linespec-rewrite has been updated
via e4e9b34c8f64d9a2c9d56174206f2ef1f5fe99fb (commit)
from 044932f583c54d22163fdaa7a477dd3997c3194e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit e4e9b34c8f64d9a2c9d56174206f2ef1f5fe99fb
Author: Keith Seitz <keiths@redhat.com>
Date: Mon Mar 26 11:28:41 2012 -0700
* linespec.c (struct ls_parser): Add is_quote_enclosed member.
(linespec_quote_characters): New constant.
(linespec_lexer_lex_string): Permit quote-enclosed linespecs.
(linespec_lexer_lex_one): Likewise.
(parse_linespec): Likewise.
-----------------------------------------------------------------------
Summary of changes:
gdb/linespec.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 49 insertions(+), 2 deletions(-)
First 500 lines of diff:
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 528e8fb..a94499b 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -251,6 +251,9 @@ struct ls_parser
linespec_token current;
} lexer;
+ /* Is the entire linespec quote-enclosed? */
+ int is_quote_enclosed;
+
/* The state of the parse. */
struct linespec_state state;
#define PARSER_STATE(PPTR) (&(PPTR)->state)
@@ -323,6 +326,11 @@ static int compare_msymbols (const void *a, const void *b);
static const char *find_toplevel_char (const char *s, char c);
+/* Permitted quote characters for the parser. This is different from the
+ completer's quote characters to allow backward compatibility with the
+ previous parser. */
+static const char *const linespec_quote_characters = "\"\'";
+
/* Lexer functions. */
/* A convenience macro for trimming trailing whitespace
@@ -452,13 +460,12 @@ linespec_lexer_lex_string (linespec_parser *parser)
{
linespec_token token;
char *start = PARSER_STREAM (parser);
- static const char *quote_characters = "'\"";
token.type = LSTOKEN_STRING;
/* If the input stream starts with a quote character, skip to the next
quote character, regardless of the content. */
- if (strchr (quote_characters, *PARSER_STREAM (parser)))
+ if (strchr (linespec_quote_characters, *PARSER_STREAM (parser)))
{
char *end;
char quote_char = *PARSER_STREAM (parser);
@@ -556,6 +563,16 @@ linespec_lexer_lex_string (linespec_parser *parser)
return token;
}
}
+ /* Special case: permit quote-enclosed linespecs. */
+ else if (parser->is_quote_enclosed
+ && strchr (linespec_quote_characters,
+ PARSER_STREAM (parser)[0])
+ && PARSER_STREAM (parser)[1] == '\0')
+ {
+ LS_TOKEN_STOKEN (token).ptr = start;
+ LS_TOKEN_STOKEN (token).length = PARSER_STREAM (parser) - start;
+ return token;
+ }
/* Advance the stream. */
++(PARSER_STREAM (parser));
@@ -611,6 +628,17 @@ linespec_lexer_lex_one (linespec_parser *parser)
}
break;
+ case '\'': case '\"':
+ /* Special case: permit quote-enclosed linespecs. */
+ if (parser->is_quote_enclosed && PARSER_STREAM (parser)[1] == '\0')
+ {
+ ++(PARSER_STREAM (parser));
+ parser->lexer.current.type = LSTOKEN_EOI;
+ }
+ else
+ parser->lexer.current = linespec_lexer_lex_string (parser);
+ break;
+
default:
/* If the input is not a number, it must be a string.
[Keywords were already considered above.] */
@@ -1856,6 +1884,25 @@ parse_linespec (linespec_parser *parser, char **argptr)
volatile struct gdb_exception file_exception;
struct cleanup *cleanup;
+ /* A special case to start. It has become quite popular for
+ IDEs to work around bugs in the previous parser by quoting
+ the entire linespec, so we attempt to deal with this nicely. */
+ parser->is_quote_enclosed = 0;
+ if (!is_ada_operator (*argptr)
+ && strchr (linespec_quote_characters, **argptr) != NULL)
+ {
+ char *end;
+
+ end = skip_quote_char (*argptr + 1, **argptr);
+ if (end != NULL && end[1] == '\0')
+ {
+ /* Here's the special case. Skip ARGPTR past the initial
+ quote. */
+ ++(*argptr);
+ parser->is_quote_enclosed = 1;
+ }
+ }
+
parser->lexer.saved_arg = *argptr;
parser->lexer.stream = argptr;
file_exception.reason = 0;
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-03-26 18:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-26 18:30 [SCM] archer-keiths-linespec-rewrite: * linespec.c (struct ls_parser): Add is_quote_enclosed member. (linespec_quote_characters): New constant. (linespec_lexer_lex_string): Permit quote-enclosed linespecs. (linespec_lexer_lex_one): Likewise. (parse_linespec): Likewise kseitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).