This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 1/4] Constify LEXPTR
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Keith Seitz <keiths at redhat dot com>
- Cc: "gdb-patches\ at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Tue, 01 Oct 2013 01:06:03 -0300
- Subject: Re: [RFA 1/4] Constify LEXPTR
- Authentication-results: sourceware.org; auth=none
- References: <5249C947 dot 60604 at redhat dot com>
On Monday, September 30 2013, Keith Seitz wrote:
> Hi,
>
> I am submitting four patches which aim to constify
> parser-defs.h/parse.c's LEXPTR.
Hey!
Thanks for the patch. I've messed around with this code some time ago,
and I appreciate the effort you've made to make it less ugly :-). Your
patch actually made me remember of another (buried) project of mine
which was to make the expout* variables non-global. Maybe it's time to
ressurrect it once and for all!
> This patch is broken into four relatively simple patches, each
> building on the previous patch, typically eliminating a temporary cast
> to/from const. By the end, all of these temporary casts will be
> eliminated. [I'm using the solely as a way to make this more
> digestible.]
>
> Sadly, this first patch is still relatively large. It makes lexptr
> const, and adds temporary casts when dealing with struct
> stoken.ptr. This will be the subject of the next patch.
I don't know how you're planning to commit that, but I'd vote for push
the final result of applying all patches, because I don't see a strong
reason to commit each patch separately in this specific case. WDYT?
But IANAM.
> I know maintainers have little choice, but even so, I would appreciate
> an additional pair of eyes on this for newb mistakes. This stuff can
> get a little mindless after a while.
FWIW,
> Tested, regression-free, on x86_64-linux (Fedora 18) native and gdbserver.
>
> Keith
>
> ChangeLog
> 2013-09-24 Keith Seitz <keiths@redhat.com>
>
> * c-exp.y (parse_number): Make first argument const.
> Make a copy of the input to manipulate.
> (c_parse_escape): Make first argument const.
> Make local variable 'tokptr' const.
> (parse_string_or_char): Make first two arguments const.
> (macro_original_text): Make const.
> (lex_one_token): Make local variable 'tokstart' const.
> Likewise for local variables named 'p'.
> Cast away const for struct stoken (temporary).
> * c-lang.h (c_parse_escpae): Make first argument const.
> * cli/cli-cmds.c (echo_command): Make local variable 'p'
> const.
> * cli/cli-setshow.c (do_set_command): Likewise for 'p' in
> var_string case.
> * f-exp.y (parse_number): Make first argument const.
> (match_string_literal): Make local variable 'tokstart'
> const.
> (yylex): Make local variable 'p' const.
> Cast away const for struct stoken (temporary).
> * go-exp.y (parse_number): Make first argument const.
> (parse_string_or_char): Likewise.
> Make local variable 'tokstart' const.
> (lex_one_token): Likewise for numerous locals called 'p'.
> Cast away const for struct stoken (temporary).
> * jv-exp.y (parse_number): Make first argument const.
> Make local variables 'tokstart' and 'tokptr' const.
> Cast away const for call to skip_quoted (temporary).
> (yylex): Make local variable 'p' const.
> Cast away const for struct stoken (temporary).
> * m2-exp.y (parse_number): Make local variable 'p' const.
> (yylex): Likewise for 'tokstart'.
> Cast away const for struct stoken (temporary).
> Make local variable 'p' const.
> * macroexp.c (get_character_constant): Pass a const string
> to c_parse_escape.
> (get_string_literal): Likewise.
> (macro_expand_next): Make first argument const.
> Cast away const for init_shared_buffer.
> * macroexp.h (macro_expand_next): Make first argument const.
> * p-exp.y (yylex): Make a local copy of 'lexptr'.
> Pass a const string to c_parse_escape.
> Make local variables 'p' and 'namestart' const.
> * parse.c (lexptr): Make const.
> (prev_lexptr): Likewise.
> (find_template_name_end): Return const.
> Make argument const, too.
> (parse_exp_in_context): Make first argument const.
> Remove the entire const_hack.
> (parse_exp_in_context_1): Make first argument const.
> * parser-defs.h (find_template_name_end): Return const.
> Make argument const, too.
> (lexptr): Make const.
> (prev_lexptr): Likewise.
> * utils.c (parse_escape): Make second argument const.
> * utils.h (parse_escape): Likewise.
> diff --git a/gdb/c-exp.y b/gdb/c-exp.y
> index 3a51878..ea19178 100644
> --- a/gdb/c-exp.y
> +++ b/gdb/c-exp.y
> @@ -164,7 +164,7 @@ void yyerror (char *);
>
> %{
> /* YYSTYPE gets defined by %union */
> -static int parse_number (char *, int, int, YYSTYPE *);
> +static int parse_number (const char *, int, int, YYSTYPE *);
> static struct stoken operator_stoken (const char *);
> static void check_parameter_typelist (VEC (type_ptr) *);
> static void write_destructor_name (struct stoken);
> @@ -1699,7 +1699,7 @@ check_parameter_typelist (VEC (type_ptr) *params)
> /*** Needs some error checking for the float case ***/
>
> static int
> -parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
> +parse_number (const char *buf, int len, int parsed_float, YYSTYPE *putithere)
> {
> /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
> here, and we do kind of silly things like cast to unsigned. */
> @@ -1722,6 +1722,9 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
> struct type *signed_type;
> struct type *unsigned_type;
>
> + char *p = alloca (len);
> + memcpy (p, buf, len);
I think the declaration of "p" should go together with the other
declarations. And there should be a newline between the declaration and
memcpy.
> +
> if (parsed_float)
> {
> /* If it ends at "df", "dd" or "dl", take it as type of decimal floating
> @@ -1941,9 +1944,9 @@ static int tempbuf_init;
> character was emitted, 0 otherwise. */
>
> int
> -c_parse_escape (char **ptr, struct obstack *output)
> +c_parse_escape (const char **ptr, struct obstack *output)
> {
> - char *tokptr = *ptr;
> + const char *tokptr = *ptr;
> int result = 1;
>
> /* Some escape sequences undergo character set conversion. Those we
> @@ -2102,8 +2105,8 @@ c_parse_escape (char **ptr, struct obstack *output)
> CHAR, depending on what was parsed. *HOST_CHARS is set to the
> number of host characters in the literal. */
> static int
> -parse_string_or_char (char *tokptr, char **outptr, struct typed_stoken *value,
> - int *host_chars)
> +parse_string_or_char (const char *tokptr, const char **outptr,
> + struct typed_stoken *value, int *host_chars)
> {
> int quote;
> enum c_string_type type;
> @@ -2321,7 +2324,7 @@ static const struct token ident_tokens[] =
> we evaluate ADDRESS in the scope of the current frame, but we
> evaluate CONDITION in the scope of the breakpoint's location. So
> it's simply wrong to try to macro-expand the whole thing at once. */
> -static char *macro_original_text;
> +static const char *macro_original_text;
>
> /* We save all intermediate macro expansions on this obstack for the
> duration of a single parse. The expansion text may sometimes have
> @@ -2411,7 +2414,7 @@ lex_one_token (void)
> int c;
> int namelen;
> unsigned int i;
> - char *tokstart;
> + const char *tokstart;
> int saw_structop = last_was_structop;
> char *copy;
>
> @@ -2538,7 +2541,7 @@ lex_one_token (void)
> {
> /* It's a number. */
> int got_dot = 0, got_e = 0, toktype;
> - char *p = tokstart;
> + const char *p = tokstart;
> int hex = input_radix > 10;
>
> if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
> @@ -2590,7 +2593,7 @@ lex_one_token (void)
>
> case '@':
> {
> - char *p = &tokstart[1];
> + const char *p = &tokstart[1];
> size_t len = strlen ("entry");
>
> if (parse_language->la_language == language_objc)
> @@ -2692,7 +2695,8 @@ lex_one_token (void)
> characters; for comparison expressions, e.g. "a < b > c",
> there must be spaces before the '<', etc. */
>
> - char * p = find_template_name_end (tokstart + namelen);
> + const char *p = find_template_name_end (tokstart + namelen);
> +
> if (p)
> namelen = p - tokstart;
> }
> @@ -2723,7 +2727,7 @@ lex_one_token (void)
> && (tokstart[namelen] == ' ' || tokstart[namelen] == '\t')
> && ! scanning_macro_expansion ())
> {
> - char *p = tokstart + namelen + 1;
> + const char *p = tokstart + namelen + 1;
> while (*p == ' ' || *p == '\t')
Newline between declaration and the "while" (you add this in the other
hunks :-)).
> p++;
> if (*p >= '0' && *p <= '9')
> @@ -2734,7 +2738,7 @@ lex_one_token (void)
>
> tryname:
>
> - yylval.sval.ptr = tokstart;
> + yylval.sval.ptr = (char *) tokstart;
> yylval.sval.length = namelen;
>
> /* Catch specific keywords. */
> diff --git a/gdb/c-lang.h b/gdb/c-lang.h
> index 6bf6591..9f8f50d 100644
> --- a/gdb/c-lang.h
> +++ b/gdb/c-lang.h
> @@ -61,7 +61,7 @@ extern int c_parse (void);
>
> extern void c_error (char *);
>
> -extern int c_parse_escape (char **, struct obstack *);
> +extern int c_parse_escape (const char **, struct obstack *);
>
> /* Defined in c-typeprint.c */
> extern void c_print_type (struct type *, const char *,
> diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
> index 4317ea3..886ba7a 100644
> --- a/gdb/cli/cli-cmds.c
> +++ b/gdb/cli/cli-cmds.c
> @@ -666,7 +666,7 @@ source_command (char *args, int from_tty)
> static void
> echo_command (char *text, int from_tty)
> {
> - char *p = text;
> + const char *p = text;
> int c;
>
> if (text)
> diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
> index 3e41fd4..45df6f6 100644
> --- a/gdb/cli/cli-setshow.c
> +++ b/gdb/cli/cli-setshow.c
> @@ -160,7 +160,7 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
> case var_string:
> {
> char *new;
> - char *p;
> + const char *p;
> char *q;
> int ch;
>
> diff --git a/gdb/f-exp.y b/gdb/f-exp.y
> index 296a7fe..9a82230 100644
> --- a/gdb/f-exp.y
> +++ b/gdb/f-exp.y
> @@ -157,7 +157,7 @@ static int match_string_literal (void);
>
> %{
> /* YYSTYPE gets defined by %union */
> -static int parse_number (char *, int, int, YYSTYPE *);
> +static int parse_number (const char *, int, int, YYSTYPE *);
> %}
>
> %type <voidval> exp type_exp start variable
> @@ -669,7 +669,7 @@ name_not_typename : NAME
> /*** Needs some error checking for the float case ***/
>
> static int
> -parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
> +parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
> {
> LONGEST n = 0;
> LONGEST prevn = 0;
> @@ -920,7 +920,7 @@ growbuf_by_size (int count)
> static int
> match_string_literal (void)
> {
> - char *tokptr = lexptr;
> + const char *tokptr = lexptr;
>
> for (tempbufindex = 0, tokptr++; *tokptr != '\0'; tokptr++)
> {
> @@ -955,7 +955,7 @@ yylex (void)
> int c;
> int namelen;
> unsigned int i,token;
> - char *tokstart;
> + const char *tokstart;
>
> retry:
>
> @@ -1054,7 +1054,7 @@ yylex (void)
> {
> /* It's a number. */
> int got_dot = 0, got_e = 0, got_d = 0, toktype;
> - char *p = tokstart;
> + const char *p = tokstart;
> int hex = input_radix > 10;
>
> if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
> @@ -1159,7 +1159,7 @@ yylex (void)
> return f77_keywords[i].token;
> }
>
> - yylval.sval.ptr = tokstart;
> + yylval.sval.ptr = (char *) tokstart;
> yylval.sval.length = namelen;
>
> if (*tokstart == '$')
> diff --git a/gdb/go-exp.y b/gdb/go-exp.y
> index 2ccb394..166d380 100644
> --- a/gdb/go-exp.y
> +++ b/gdb/go-exp.y
> @@ -158,7 +158,7 @@ void yyerror (char *);
>
> %{
> /* YYSTYPE gets defined by %union. */
> -static int parse_number (char *, int, int, YYSTYPE *);
> +static int parse_number (const char *, int, int, YYSTYPE *);
> static int parse_go_float (struct gdbarch *gdbarch, const char *p, int len,
> DOUBLEST *d, struct type **t);
> %}
> @@ -704,7 +704,7 @@ parse_go_float (struct gdbarch *gdbarch, const char *p, int len,
> as our YYSTYPE is different than c-exp.y's */
>
> static int
> -parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
> +parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
> {
> /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
> here, and we do kind of silly things like cast to unsigned. */
> @@ -908,8 +908,8 @@ static int tempbuf_init;
> number of host characters in the literal. */
>
> static int
> -parse_string_or_char (char *tokptr, char **outptr, struct typed_stoken *value,
> - int *host_chars)
> +parse_string_or_char (const char *tokptr, const char **outptr,
> + struct typed_stoken *value, int *host_chars)
> {
> int quote;
>
> @@ -1049,7 +1049,7 @@ lex_one_token (void)
> int c;
> int namelen;
> unsigned int i;
> - char *tokstart;
> + const char *tokstart;
> int saw_structop = last_was_structop;
> char *copy;
>
> @@ -1143,7 +1143,7 @@ lex_one_token (void)
> {
> /* It's a number. */
> int got_dot = 0, got_e = 0, toktype;
> - char *p = tokstart;
> + const char *p = tokstart;
> int hex = input_radix > 10;
>
> if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
> @@ -1190,7 +1190,7 @@ lex_one_token (void)
>
> case '@':
> {
> - char *p = &tokstart[1];
> + const char *p = &tokstart[1];
> size_t len = strlen ("entry");
>
> while (isspace (*p))
> @@ -1283,7 +1283,8 @@ lex_one_token (void)
> && strncmp (tokstart, "thread", namelen) == 0
> && (tokstart[namelen] == ' ' || tokstart[namelen] == '\t'))
> {
> - char *p = tokstart + namelen + 1;
> + const char *p = tokstart + namelen + 1;
> +
> while (*p == ' ' || *p == '\t')
> p++;
> if (*p >= '0' && *p <= '9')
> @@ -1294,7 +1295,7 @@ lex_one_token (void)
>
> tryname:
>
> - yylval.sval.ptr = tokstart;
> + yylval.sval.ptr = (char *) tokstart;
> yylval.sval.length = namelen;
>
> /* Catch specific keywords. */
> diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y
> index a4e1253..c69caf5 100644
> --- a/gdb/jv-exp.y
> +++ b/gdb/jv-exp.y
> @@ -154,7 +154,7 @@ static void insert_exp (int, struct expression *);
>
> %{
> /* YYSTYPE gets defined by %union */
> -static int parse_number (char *, int, int, YYSTYPE *);
> +static int parse_number (const char *, int, int, YYSTYPE *);
> %}
>
> %type <lval> rcurly Dims Dims_opt
> @@ -696,7 +696,7 @@ Expression:
> /*** Needs some error checking for the float case ***/
>
> static int
> -parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
> +parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
> {
> ULONGEST n = 0;
> ULONGEST limit, limit_div_base;
> @@ -858,8 +858,8 @@ yylex (void)
> int c;
> int namelen;
> unsigned int i;
> - char *tokstart;
> - char *tokptr;
> + const char *tokstart;
> + const char *tokptr;
> int tempbufindex;
> static char *tempbuf;
> static int tempbufsize;
> @@ -915,7 +915,7 @@ yylex (void)
> c = *lexptr++;
> if (c != '\'')
> {
> - namelen = skip_quoted (tokstart) - tokstart;
> + namelen = skip_quoted ((char *) tokstart) - tokstart;
> if (namelen > 2)
> {
> lexptr = tokstart + namelen;
> @@ -966,7 +966,7 @@ yylex (void)
> {
> /* It's a number. */
> int got_dot = 0, got_e = 0, toktype;
> - char *p = tokstart;
> + const char *p = tokstart;
> int hex = input_radix > 10;
>
> if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
> @@ -1175,7 +1175,7 @@ yylex (void)
> break;
> }
>
> - yylval.sval.ptr = tokstart;
> + yylval.sval.ptr = (char *) tokstart;
> yylval.sval.length = namelen;
>
> if (*tokstart == '$')
> diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
> index eaa5a23..47ea640 100644
> --- a/gdb/m2-exp.y
> +++ b/gdb/m2-exp.y
> @@ -662,7 +662,7 @@ type
> static int
> parse_number (int olen)
> {
> - char *p = lexptr;
> + const char *p = lexptr;
> LONGEST n = 0;
> LONGEST prevn = 0;
> int c,i,ischar=0;
> @@ -814,7 +814,7 @@ yylex (void)
> int c;
> int namelen;
> int i;
> - char *tokstart;
> + const char *tokstart;
> char quote;
>
> retry:
> @@ -907,7 +907,7 @@ yylex (void)
> }
> if(c != quote)
> error (_("Unterminated string or character constant."));
> - yylval.sval.ptr = tokstart + 1;
> + yylval.sval.ptr = (char *) (tokstart + 1);
> yylval.sval.length = namelen - 1;
> lexptr += namelen + 1;
>
> @@ -927,7 +927,7 @@ yylex (void)
> {
> /* It's a number. */
> int got_dot = 0, got_e = 0;
> - char *p = tokstart;
> + const char *p = tokstart;
> int toktype;
>
> for (++p ;; ++p)
> @@ -987,7 +987,7 @@ yylex (void)
> && strncmp (tokstart, keytab[i].keyw, namelen) == 0)
> return keytab[i].token;
>
> - yylval.sval.ptr = tokstart;
> + yylval.sval.ptr = (char *) tokstart;
> yylval.sval.length = namelen;
>
> if (*tokstart == '$')
> diff --git a/gdb/macroexp.c b/gdb/macroexp.c
> index d88dac3..14c4994 100644
> --- a/gdb/macroexp.c
> +++ b/gdb/macroexp.c
> @@ -360,8 +360,11 @@ get_character_constant (struct macro_buffer *tok, char *p, char *end)
> }
> else if (*p == '\\')
> {
> - p++;
> - char_count += c_parse_escape (&p, NULL);
> + const char *s, *o;
> +
> + s = o = ++p;
This line is indented wrongly (only spaces).
> + char_count += c_parse_escape (&s, NULL);
> + p += s - o;
> }
> else
> {
> @@ -414,8 +417,11 @@ get_string_literal (struct macro_buffer *tok, char *p, char *end)
> "constants."));
> else if (*p == '\\')
> {
> - p++;
> - c_parse_escape (&p, NULL);
> + const char *s, *o;
> +
> + s = o = ++p;
> + c_parse_escape (&s, NULL);
Wrong indentation (only spaces).
> + p += s - o;
> }
> else
> p++;
> @@ -1434,7 +1440,7 @@ macro_expand_once (const char *source,
>
>
> char *
> -macro_expand_next (char **lexptr,
> +macro_expand_next (const char **lexptr,
> macro_lookup_ftype *lookup_func,
> void *lookup_baton)
> {
> @@ -1442,7 +1448,7 @@ macro_expand_next (char **lexptr,
> struct cleanup *back_to;
>
> /* Set up SRC to refer to the input text, pointed to by *lexptr. */
> - init_shared_buffer (&src, *lexptr, strlen (*lexptr));
> + init_shared_buffer (&src, (char *) *lexptr, strlen (*lexptr));
>
> /* Set up DEST to receive the expansion, if there is one. */
> init_buffer (&dest, 0);
> diff --git a/gdb/macroexp.h b/gdb/macroexp.h
> index cbe9629..8bf4b7f 100644
> --- a/gdb/macroexp.h
> +++ b/gdb/macroexp.h
> @@ -80,7 +80,7 @@ char *macro_expand_once (const char *source,
> much have to do tokenization to find the end of the string that
> needs to be macro-expanded. Our C/C++ tokenizer isn't really
> designed to be called by anything but the yacc parser engine. */
> -char *macro_expand_next (char **lexptr,
> +char *macro_expand_next (const char **lexptr,
> macro_lookup_ftype *lookup_func,
> void *lookup_baton);
>
> diff --git a/gdb/p-exp.y b/gdb/p-exp.y
> index da8d5f7..e0abd07 100644
> --- a/gdb/p-exp.y
> +++ b/gdb/p-exp.y
> @@ -1141,8 +1141,10 @@ yylex (void)
>
> prev_lexptr = lexptr;
>
> - tokstart = lexptr;
> explen = strlen (lexptr);
> + tokstart = alloca (explen + 1);
> + memcpy (tokstart, lexptr, explen + 1);
> +
> /* See if it is a special token of length 3. */
> if (explen > 2)
> for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
> @@ -1361,13 +1363,18 @@ yylex (void)
> /* Do nothing, loop will terminate. */
> break;
> case '\\':
> - tokptr++;
> - c = parse_escape (parse_gdbarch, &tokptr);
> - if (c == -1)
> - {
> - continue;
> - }
> - tempbuf[tempbufindex++] = c;
> + {
> + const char *s, *o;
> +
> + o = s = ++tokptr;
> + c = parse_escape (parse_gdbarch, &s);
> + *tokptr += s - o;
> + if (c == -1)
> + {
> + continue;
> + }
> + tempbuf[tempbufindex++] = c;
> + }
> break;
> default:
> tempbuf[tempbufindex++] = *tokptr++;
> @@ -1623,8 +1630,8 @@ yylex (void)
> distinction) named x, then this code incorrectly thinks we
> are dealing with nested types rather than a member function. */
>
> - char *p;
> - char *namestart;
> + const char *p;
> + const char *namestart;
> struct symbol *best_sym;
>
> /* Look ahead to detect nested types. This probably should be
> diff --git a/gdb/parse.c b/gdb/parse.c
> index 674342b..07c1765 100644
> --- a/gdb/parse.c
> +++ b/gdb/parse.c
> @@ -75,8 +75,8 @@ CORE_ADDR expression_context_pc;
> const struct block *innermost_block;
> int arglist_len;
> static struct type_stack type_stack;
> -char *lexptr;
> -char *prev_lexptr;
> +const char *lexptr;
> +const char *prev_lexptr;
> int paren_depth;
> int comma_terminates;
>
> @@ -123,7 +123,7 @@ static int prefixify_subexp (struct expression *, struct expression *, int,
> static struct expression *parse_exp_in_context (const char **, CORE_ADDR,
> const struct block *, int,
> int, int *);
> -static struct expression *parse_exp_in_context_1 (char **, CORE_ADDR,
> +static struct expression *parse_exp_in_context_1 (const char **, CORE_ADDR,
> const struct block *, int,
> int, int *);
>
> @@ -733,8 +733,8 @@ handle_register:
> }
>
>
> -char *
> -find_template_name_end (char *p)
> +const char *
> +find_template_name_end (const char *p)
> {
> int depth = 1;
> int just_seen_right = 0;
> @@ -1142,16 +1142,8 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
> const struct block *block,
> int comma, int void_context_p, int *out_subexp)
> {
> - struct expression *expr;
> - char *const_hack = *stringptr ? xstrdup (*stringptr) : NULL;
> - char *orig = const_hack;
> - struct cleanup *back_to = make_cleanup (xfree, const_hack);
> -
> - expr = parse_exp_in_context_1 (&const_hack, pc, block, comma,
> + return parse_exp_in_context_1 (stringptr, pc, block, comma,
> void_context_p, out_subexp);
> - (*stringptr) += const_hack - orig;
> - do_cleanups (back_to);
> - return expr;
Nice! :-)
> }
>
> /* As for parse_exp_1, except that if VOID_CONTEXT_P, then
> @@ -1162,7 +1154,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
> is left untouched. */
>
> static struct expression *
> -parse_exp_in_context_1 (char **stringptr, CORE_ADDR pc,
> +parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc,
> const struct block *block,
> int comma, int void_context_p, int *out_subexp)
> {
> diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
> index 92daca9..aaefe3f 100644
> --- a/gdb/parser-defs.h
> +++ b/gdb/parser-defs.h
> @@ -201,7 +201,7 @@ extern void write_dollar_variable (struct stoken str);
>
> extern void mark_struct_expression (void);
>
> -extern char *find_template_name_end (char *);
> +extern const char *find_template_name_end (const char *);
>
> extern void start_arglist (void);
>
> @@ -264,11 +264,11 @@ extern int parse_c_float (struct gdbarch *gdbarch, const char *p, int len,
> /* During parsing of a C expression, the pointer to the next character
> is in this variable. */
>
> -extern char *lexptr;
> +extern const char *lexptr;
>
> /* After a token has been recognized, this variable points to it.
> Currently used only for error reporting. */
> -extern char *prev_lexptr;
> +extern const char *prev_lexptr;
>
> /* Current depth in parentheses within the expression. */
>
> diff --git a/gdb/utils.c b/gdb/utils.c
> index 0652197..26879ec 100644
> --- a/gdb/utils.c
> +++ b/gdb/utils.c
> @@ -1412,7 +1412,7 @@ host_char_to_target (struct gdbarch *gdbarch, int c, int *target_c)
> after the zeros. A value of 0 does not mean end of string. */
>
> int
> -parse_escape (struct gdbarch *gdbarch, char **string_ptr)
> +parse_escape (struct gdbarch *gdbarch, const char **string_ptr)
> {
> int target_char = -2; /* Initialize to avoid GCC warnings. */
> int c = *(*string_ptr)++;
> diff --git a/gdb/utils.h b/gdb/utils.h
> index 143cd6b..3492f09 100644
> --- a/gdb/utils.h
> +++ b/gdb/utils.h
> @@ -64,7 +64,7 @@ struct timeval get_prompt_for_continue_wait_time (void);
>
> extern int parse_pid_to_attach (char *args);
>
> -extern int parse_escape (struct gdbarch *, char **);
> +extern int parse_escape (struct gdbarch *, const char **);
>
> char **gdb_buildargv (const char *);
>
Otherwise, looks good to me (thanks for doing that!), but I can't
approve it :-).
--
Sergio