+2013-10-01 Keith Seitz <keiths@redhat.com>
+
+ * linespec.c (struct ls_parser): Make 'saved_arg' const.
+ (parse_linespec): Make 'argptr' const.
+ Remove temporary cast of 'argptr' to const char **.
+ (decode_line_full): Pass const pointer to parse_linespec.
+ (decode_line_1): Likewise.
+ (decode_objc): Make local variable 'new_argptr' const.
+ (find_function_symbols): Remove temporary cast to char *
+ to find_imps.
+ * objc-lang.c (find_imps): Make argument 'method' const.
+ Return const.
+ * objc-lang.h (find_imps): Likewise.
+
+2013-10-01 Keith Seitz <keiths@redhat.com>
+
+ * completer.c (skip_quoted_chars): Make all arguments const.
+ Return const.
+ (skip_quoted): Likewise.
+ * completer.h (skip_quoted_chars): Likewise.
+ (skip_quoted): Likewise.
+ * defs.h (skip_quoted): Remove duplicate declaration.
+ * jv-exp.y: Include completer.h.
+ (yylex): Remove unneccessary cast to char * fro skip_quoted.
+ * p-exp.y: Include completer.h.
+
+2013-10-01 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.
+
+2013-10-01 Keith Seitz <keiths@redhat.com>
+
+ * ada-exp.y (write_object_renaming): Update: struct stoken.ptr
+ is now const.
+ (block_lookup): Make 'raw_name' and 'name' const.
+ * ada-lex.l (processString): Update for struct stoken.ptr.
+ * c-exp.y (qualified_name : TYPENAME COLONCOLON '~' name): Likewise.
+ (operator_stoken): Likewise.
+ (lex_one_token): Remove temporary cast to char * for
+ 'yylval.sval.ptr'.
+ * f-exp.y (yylex): Likewise.
+ * gdb-types.c (lookup_struct_elt_type): Make argument 'name' const.
+ * gdbtypes.h (lookup_struct_elt_type): Likewisee.
+ * go-exp.y (lex_one_token): Remove temporary cast to char * for
+ 'yylval.sval.ptr'.
+ * jv-exp.y (QualifiedName): Update for struct stoken.ptr.
+ (yylex): Remove temporary cast to char * for 'yylval.sval.ptr'.
+ * linespec.c (struct ls_parser): Make 'stream' const.
+ (find_parameter_list_end): Make argument 'input' and local
+ variable 'p' const.
+ (linespec_lexer_lex_string): Make local variables 'start' and
+ 'p' const.
+ Use skip_spaces_const instead of skip_spaces.
+ (linespec_lexer_peek_token): Make local variable 'saved_stream'
+ const.
+ (parse_linespec): Temporarily cast 'argptr' to const for
+ 'parser->lexer.stream'.
+ * m2-exp.y (yylex): Remove temporary cast to char * for
+ 'yylval.sval.ptr'.
+ * objc-lang.c (add_msglist): Make local variable 'p' const.
+ * p-exp.y (exp : exp '['): Update for struct stoken.ptr.
+ (exp : STRING): Make 'sp' const.
+ (parse_number): Make argument 'p' const.
+ * parser-defs.h (struct stoken): Make 'ptr' const.
+
2013-10-01 Doug Evans <dje@google.com>
* cli/cli-decode.c: Remove unnecessary inclusion of tui/tui.h.
static void write_exp_op_with_string (enum exp_opcode, struct stoken);
-static struct block *block_lookup (struct block *, char *);
+static struct block *block_lookup (struct block *, const char *);
static LONGEST convert_char_literal (struct type *, LONGEST);
{
struct stoken field_name;
const char *end;
+ char *buf;
+
renaming_expr += 1;
if (slice_state != SIMPLE_INDEX)
if (end == NULL)
end = renaming_expr + strlen (renaming_expr);
field_name.length = end - renaming_expr;
- field_name.ptr = malloc (end - renaming_expr + 1);
- strncpy (field_name.ptr, renaming_expr, end - renaming_expr);
- field_name.ptr[end - renaming_expr] = '\000';
+ buf = malloc (end - renaming_expr + 1);
+ field_name.ptr = buf;
+ strncpy (buf, renaming_expr, end - renaming_expr);
+ buf[end - renaming_expr] = '\000';
renaming_expr = end;
write_exp_op_with_string (STRUCTOP_STRUCT, field_name);
break;
}
static struct block*
-block_lookup (struct block *context, char *raw_name)
+block_lookup (struct block *context, const char *raw_name)
{
- char *name;
+ const char *name;
struct ada_symbol_info *syms;
int nsyms;
struct symtab *symtab;
const char *lim = text + len;
struct stoken result;
- q = result.ptr = obstack_alloc (&temp_parse_space, len);
+ q = obstack_alloc (&temp_parse_space, len);
+ result.ptr = q;
p = text;
while (p < lim)
{
%{
/* 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);
{
struct type *type = $1.type;
struct stoken tmp_token;
+ char *buf;
+
CHECK_TYPEDEF (type);
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
&& TYPE_CODE (type) != TYPE_CODE_UNION
&& TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
error (_("`%s' is not defined as an aggregate type."),
TYPE_SAFE_NAME (type));
-
- tmp_token.ptr = (char*) alloca ($4.length + 2);
+ buf = alloca ($4.length + 2);
+ tmp_token.ptr = buf;
tmp_token.length = $4.length + 1;
- tmp_token.ptr[0] = '~';
- memcpy (tmp_token.ptr+1, $4.ptr, $4.length);
- tmp_token.ptr[tmp_token.length] = 0;
+ buf[0] = '~';
+ memcpy (buf+1, $4.ptr, $4.length);
+ buf[tmp_token.length] = 0;
/* Check for valid destructor name. */
destructor_name_p (tmp_token.ptr, $1.type);
{
static const char *operator_string = "operator";
struct stoken st = { NULL, 0 };
+ char *buf;
+
st.length = strlen (operator_string) + strlen (op);
- st.ptr = malloc (st.length + 1);
- strcpy (st.ptr, operator_string);
- strcat (st.ptr, op);
+ buf = malloc (st.length + 1);
+ strcpy (buf, operator_string);
+ strcat (buf, op);
+ st.ptr = buf;
/* The toplevel (c_parse) will free the memory allocated here. */
- make_cleanup (free, st.ptr);
+ make_cleanup (free, buf);
return st;
};
/*** 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. */
ULONGEST high_bit;
struct type *signed_type;
struct type *unsigned_type;
+ char *p;
+
+ p = alloca (len);
+ memcpy (p, buf, len);
if (parsed_float)
{
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
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;
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
int c;
int namelen;
unsigned int i;
- char *tokstart;
+ const char *tokstart;
int saw_structop = last_was_structop;
char *copy;
{
/* 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'))
case '@':
{
- char *p = &tokstart[1];
+ const char *p = &tokstart[1];
size_t len = strlen ("entry");
if (parse_language->la_language == language_objc)
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;
}
&& (tokstart[namelen] == ' ' || tokstart[namelen] == '\t')
&& ! scanning_macro_expansion ())
{
- char *p = tokstart + namelen + 1;
+ const char *p = tokstart + namelen + 1;
+
while (*p == ' ' || *p == '\t')
p++;
if (*p >= '0' && *p <= '9')
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 *,
static void
echo_command (char *text, int from_tty)
{
- char *p = text;
+ const char *p = text;
int c;
if (text)
case var_string:
{
char *new;
- char *p;
+ const char *p;
char *q;
int ch;
QUOTECHARS or BREAKCHARS is NULL, use the same values used by the
completer. */
-char *
-skip_quoted_chars (char *str, char *quotechars, char *breakchars)
+const char *
+skip_quoted_chars (const char *str, const char *quotechars,
+ const char *breakchars)
{
char quote_char = '\0';
- char *scan;
+ const char *scan;
if (quotechars == NULL)
quotechars = gdb_completer_quote_characters;
characters and word break characters used by the completer).
Returns pointer to the location after the "word". */
-char *
-skip_quoted (char *str)
+const char *
+skip_quoted (const char *str)
{
return skip_quoted_chars (str, NULL, NULL);
}
/* Exported to linespec.c */
-extern char *skip_quoted_chars (char *, char *, char *);
+extern const char *skip_quoted_chars (const char *, const char *,
+ const char *);
-extern char *skip_quoted (char *);
+extern const char *skip_quoted (const char *);
#endif /* defined (COMPLETER_H) */
typedef void initialize_file_ftype (void);
-extern char *skip_quoted (char *);
-
extern char *gdb_readline (char *);
extern char *gdb_readline_wrapper (char *);
%{
/* 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
/*** 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;
static int
match_string_literal (void)
{
- char *tokptr = lexptr;
+ const char *tokptr = lexptr;
for (tempbufindex = 0, tokptr++; *tokptr != '\0'; tokptr++)
{
int c;
int namelen;
unsigned int i,token;
- char *tokstart;
+ const char *tokstart;
retry:
{
/* 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'))
If NAME is the name of a baseclass type, return that type. */
struct type *
-lookup_struct_elt_type (struct type *type, char *name, int noerr)
+lookup_struct_elt_type (struct type *type, const char *name, int noerr)
{
int i;
char *typename;
extern const char *type_name_no_tag_or_error (struct type *type);
-extern struct type *lookup_struct_elt_type (struct type *, char *, int);
+extern struct type *lookup_struct_elt_type (struct type *, const char *, int);
extern struct type *make_pointer_type (struct type *, struct type **);
%{
/* 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);
%}
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. */
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;
int c;
int namelen;
unsigned int i;
- char *tokstart;
+ const char *tokstart;
int saw_structop = last_was_structop;
char *copy;
{
/* 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'))
case '@':
{
- char *p = &tokstart[1];
+ const char *p = &tokstart[1];
size_t len = strlen ("entry");
while (isspace (*p))
&& 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')
#include "symfile.h" /* Required by objfiles.h. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
#include "block.h"
+#include "completer.h"
#define parse_type builtin_type (parse_gdbarch)
#define parse_java_type builtin_java_type (parse_gdbarch)
%{
/* 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
$$.ptr = $1.ptr; /* Optimization. */
else
{
- $$.ptr = (char *) malloc ($$.length + 1);
- make_cleanup (free, $$.ptr);
- sprintf ($$.ptr, "%.*s.%.*s",
+ char *buf;
+
+ buf = malloc ($$.length + 1);
+ make_cleanup (free, buf);
+ sprintf (buf, "%.*s.%.*s",
$1.length, $1.ptr, $3.length, $3.ptr);
+ $$.ptr = buf;
} }
;
/*** 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;
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;
{
/* 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'))
struct
{
/* Save head of input stream. */
- char *saved_arg;
+ const char *saved_arg;
/* Head of the input stream. */
- char **stream;
+ const char **stream;
#define PARSER_STREAM(P) (*(P)->lexer.stream)
/* The current token. */
static struct symtabs_and_lines decode_objc (struct linespec_state *self,
linespec_p ls,
- char **argptr);
+ const char **argptr);
static VEC (symtab_ptr) *symtabs_from_filename (const char *);
This helper function assists with lexing string segments
which might contain valid (non-terminating) commas. */
-static char *
-find_parameter_list_end (char *input)
+static const char *
+find_parameter_list_end (const char *input)
{
char end_char, start_char;
int depth;
- char *p;
+ const char *p;
start_char = *input;
if (start_char == '(')
linespec_lexer_lex_string (linespec_parser *parser)
{
linespec_token token;
- char *start = PARSER_STREAM (parser);
+ const char *start = PARSER_STREAM (parser);
token.type = LSTOKEN_STRING;
}
else
{
- char *p;
+ const char *p;
/* Otherwise, only identifier characters are permitted.
Spaces are the exception. In general, we keep spaces,
{
if (isspace (*PARSER_STREAM (parser)))
{
- p = skip_spaces (PARSER_STREAM (parser));
+ p = skip_spaces_const (PARSER_STREAM (parser));
/* When we get here we know we've found something followed by
a space (we skip over parens and templates below).
So if we find a keyword now, we know it is a keyword and not,
else if (*PARSER_STREAM (parser) == '<'
|| *PARSER_STREAM (parser) == '(')
{
- char *p;
+ const char *p;
p = find_parameter_list_end (PARSER_STREAM (parser));
if (p != NULL)
if (parser->lexer.current.type == LSTOKEN_CONSUMED)
{
/* Skip any whitespace. */
- PARSER_STREAM (parser) = skip_spaces (PARSER_STREAM (parser));
+ PARSER_STREAM (parser) = skip_spaces_const (PARSER_STREAM (parser));
/* Check for a keyword, they end the linespec. */
keyword = NULL;
linespec_lexer_peek_token (linespec_parser *parser)
{
linespec_token next;
- char *saved_stream = PARSER_STREAM (parser);
+ const char *saved_stream = PARSER_STREAM (parser);
linespec_token saved_token = parser->lexer.current;
next = linespec_lexer_consume_token (parser);
/* Parse the linespec in ARGPTR. */
static struct symtabs_and_lines
-parse_linespec (linespec_parser *parser, char **argptr)
+parse_linespec (linespec_parser *parser, const char **argptr)
{
linespec_token token;
struct symtabs_and_lines values;
VEC (const_char_ptr) *filters = NULL;
linespec_parser parser;
struct linespec_state *state;
+ const char *copy, *orig;
gdb_assert (canonical != NULL);
/* The filter only makes sense for 'all'. */
cleanups = make_cleanup (linespec_parser_delete, &parser);
save_current_program_space ();
- result = parse_linespec (&parser, argptr);
+ orig = copy = *argptr;
+ result = parse_linespec (&parser, ©);
+ *argptr += copy - orig;
state = PARSER_STATE (&parser);
gdb_assert (result.nelts == 1 || canonical->pre_expanded);
struct symtabs_and_lines result;
linespec_parser parser;
struct cleanup *cleanups;
+ const char *copy, *orig;
linespec_parser_new (&parser, flags, current_language, default_symtab,
default_line, NULL);
cleanups = make_cleanup (linespec_parser_delete, &parser);
save_current_program_space ();
- result = parse_linespec (&parser, argptr);
+ orig = copy = *argptr;
+ result = parse_linespec (&parser, ©);
+ *argptr += copy - orig;
do_cleanups (cleanups);
return result;
the existing C++ code to let the user choose one. */
static struct symtabs_and_lines
-decode_objc (struct linespec_state *self, linespec_p ls, char **argptr)
+decode_objc (struct linespec_state *self, linespec_p ls, const char **argptr)
{
struct collect_info info;
VEC (const_char_ptr) *symbol_names = NULL;
struct symtabs_and_lines values;
- char *new_argptr;
+ const char *new_argptr;
struct cleanup *cleanup = make_cleanup (VEC_cleanup (const_char_ptr),
&symbol_names);
info.file_symtabs = file_symtabs;
/* Try NAME as an Objective-C selector. */
- find_imps ((char *) name, &symbol_names);
+ find_imps (name, &symbol_names);
if (!VEC_empty (const_char_ptr, symbol_names))
add_all_symbol_names_from_pspace (&info, NULL, symbol_names);
else
static int
parse_number (int olen)
{
- char *p = lexptr;
+ const char *p = lexptr;
LONGEST n = 0;
LONGEST prevn = 0;
int c,i,ischar=0;
int c;
int namelen;
int i;
- char *tokstart;
+ const char *tokstart;
char quote;
retry:
{
/* It's a number. */
int got_dot = 0, got_e = 0;
- char *p = tokstart;
+ const char *p = tokstart;
int toktype;
for (++p ;; ++p)
}
else if (*p == '\\')
{
- p++;
- char_count += c_parse_escape (&p, NULL);
+ const char *s, *o;
+
+ s = o = ++p;
+ char_count += c_parse_escape (&s, NULL);
+ p += s - o;
}
else
{
"constants."));
else if (*p == '\\')
{
- p++;
- c_parse_escape (&p, NULL);
+ const char *s, *o;
+
+ s = o = ++p;
+ c_parse_escape (&s, NULL);
+ p += s - o;
}
else
p++;
char *
-macro_expand_next (char **lexptr,
+macro_expand_next (const char **lexptr,
macro_lookup_ftype *lookup_func,
void *lookup_baton)
{
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);
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);
void
add_msglist(struct stoken *str, int addcolon)
{
- char *s, *p;
+ char *s;
+ const char *p;
int len, plen;
if (str == 0) /* Unnamed arg, or... */
}
/*
- * Function: find_imps (char *selector, struct symbol **sym_arr)
+ * Function: find_imps (const char *selector, struct symbol **sym_arr)
*
* Input: a string representing a selector
* a pointer to an array of symbol pointers
* be the index of the first non-debuggable one).
*/
-char *
-find_imps (char *method, VEC (const_char_ptr) **symbol_names)
+const char *
+find_imps (const char *method, VEC (const_char_ptr) **symbol_names)
{
char type = '\0';
char *class = NULL;
extern int find_objc_msgcall (CORE_ADDR pc, CORE_ADDR *new_pc);
-extern char *find_imps (char *method, VEC (const_char_ptr) **symbol_names);
+extern const char *
+ find_imps (const char *method, VEC (const_char_ptr) **symbol_names);
extern struct value *value_nsstring (struct gdbarch *gdbarch,
char *ptr, int len);
#include "symfile.h" /* Required by objfiles.h. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols. */
#include "block.h"
+#include "completer.h"
#define parse_type builtin_type (parse_gdbarch)
%{
/* YYSTYPE gets defined by %union */
-static int parse_number (char *, int, int, YYSTYPE *);
+static int parse_number (const char *, int, int, YYSTYPE *);
static struct type *current_type;
static struct internalvar *intvar;
if (arrayfieldindex)
{
struct stoken stringsval;
- stringsval.ptr = alloca (strlen (arrayname) + 1);
+ char *buf;
+
+ buf = alloca (strlen (arrayname) + 1);
+ stringsval.ptr = buf;
stringsval.length = strlen (arrayname);
- strcpy (stringsval.ptr, arrayname);
+ strcpy (buf, arrayname);
current_type = TYPE_FIELD_TYPE (current_type,
arrayfieldindex - 1);
write_exp_elt_opcode (STRUCTOP_STRUCT);
the array upper bound is the string length.
There is no such thing in C as a completely empty
string. */
- char *sp = $1.ptr; int count = $1.length;
+ const char *sp = $1.ptr; int count = $1.length;
+
while (count-- > 0)
{
write_exp_elt_opcode (OP_LONG);
/*** 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)
{
/* 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. */
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++)
/* 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++;
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
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;
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 *);
}
-char *
-find_template_name_end (char *p)
+const char *
+find_template_name_end (const char *p)
{
int depth = 1;
int just_seen_right = 0;
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;
}
/* As for parse_exp_1, except that if VOID_CONTEXT_P, then
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)
{
struct stoken
{
/* Pointer to first byte of char-string or first bit of bit-string. */
- char *ptr;
+ const char *ptr;
/* Length of string in bytes for char-string or bits for bit-string. */
int length;
};
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);
/* 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. */
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)++;
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 *);
\f