2014-07-30 Tom Tromey <tromey@redhat.com>
+ * breakpoint.c (map_breakpoint_numbers): Update.
+ * cli/cli-utils.c (get_number_trailer): Make "pp" const. Update.
+ (get_number_const): New function.
+ (get_number): Rewrite using get_number_const.
+ (init_number_or_range): Make "string" const.
+ (number_is_in_list): Make "list" const.
+ * cli/cli-utils.h (get_number_const): Declare.
+ (struct get_number_or_range_state) <string, end_ptr>: Now const.
+ (init_number_or_range, number_is_in_list): Update.
+ * printcmd.c (map_display_numbers): Update.
+ * value.c (value_from_history_ref): Constify.
+ * value.h (value_from_history_ref): Update.
+
+2014-07-30 Tom Tromey <tromey@redhat.com>
+
* corefile.c (hook_type, call_extra_exec_file_hooks)
(specify_exec_file_hook): Constify.
* exec.c (exec_file_attach): Make "filename" const.
while (!state.finished)
{
- char *p = state.string;
+ const char *p = state.string;
match = 0;
commonly this is `-'. If you don't want a trailer, use \0. */
static int
-get_number_trailer (char **pp, int trailer)
+get_number_trailer (const char **pp, int trailer)
{
int retval = 0; /* default */
- char *p = *pp;
+ const char *p = *pp;
if (*p == '$')
{
/* Internal variable. Make a copy of the name, so we can
null-terminate it to pass to lookup_internalvar(). */
char *varname;
- char *start = ++p;
+ const char *start = ++p;
LONGEST val;
while (isalnum (*p) || *p == '_')
++p;
retval = 0;
}
- p = skip_spaces (p);
+ p = skip_spaces_const (p);
*pp = p;
return retval;
}
/* See documentation in cli-utils.h. */
int
-get_number (char **pp)
+get_number_const (const char **pp)
{
return get_number_trailer (pp, '\0');
}
/* See documentation in cli-utils.h. */
+int
+get_number (char **pp)
+{
+ int result;
+ const char *p = *pp;
+
+ result = get_number_trailer (&p, '\0');
+ *pp = (char *) p;
+ return result;
+}
+
+/* See documentation in cli-utils.h. */
+
void
init_number_or_range (struct get_number_or_range_state *state,
- char *string)
+ const char *string)
{
memset (state, 0, sizeof (*state));
state->string = string;
state->last_retval = get_number_trailer (&state->string, '-');
if (*state->string == '-')
{
- char **temp;
+ const char **temp;
/* This is the start of a range (<number1> - <number2>).
Skip the '-', parse and remember the second number,
and also remember the end of the final token. */
temp = &state->end_ptr;
- state->end_ptr = skip_spaces (state->string + 1);
- state->end_value = get_number (temp);
+ state->end_ptr = skip_spaces_const (state->string + 1);
+ state->end_value = get_number_const (temp);
if (state->end_value < state->last_retval)
{
error (_("inverted range"));
no arguments. */
int
-number_is_in_list (char *list, int number)
+number_is_in_list (const char *list, int number)
{
struct get_number_or_range_state state;
Currently the string can either be a number, or "$" followed by the
name of a convenience variable, or ("$" or "$$") followed by digits. */
+extern int get_number_const (const char **);
+
+/* Like get_number_const, but takes a non-const "char **". */
+
extern int get_number (char **);
/* An object of this type is passed to get_number_or_range. It must
/* The string being parsed. When parsing has finished, this points
past the last parsed token. */
- char *string;
+ const char *string;
/* Last value returned. */
int last_retval;
/* When parsing a range, a pointer past the final token in the
range. */
- char *end_ptr;
+ const char *end_ptr;
/* Non-zero when parsing a range. */
int in_range;
get_number_or_range_state. STRING is the string to be parsed. */
extern void init_number_or_range (struct get_number_or_range_state *state,
- char *string);
+ const char *string);
/* Parse a number or a range.
A number will be of the form handled by get_number.
be interpreted as typing a command such as "delete break" with
no arguments. */
-extern int number_is_in_list (char *list, int number);
+extern int number_is_in_list (const char *list, int number);
/* Skip leading whitespace characters in INP, returning an updated
pointer. If INP is NULL, return NULL. */
while (!state.finished)
{
- char *p = state.string;
+ const char *p = state.string;
num = get_number_or_range (&state);
if (num == 0)
for details. */
struct value *
-value_from_history_ref (char *h, char **endp)
+value_from_history_ref (const char *h, const char **endp)
{
int index, len;
*endp += len;
}
else
- index = -strtol (&h[2], endp, 10);
+ {
+ char *local_end;
+
+ index = -strtol (&h[2], &local_end, 10);
+ *endp = local_end;
+ }
}
else
{
*endp += len;
}
else
- index = strtol (&h[1], endp, 10);
+ {
+ char *local_end;
+
+ index = strtol (&h[1], &local_end, 10);
+ *endp = local_end;
+ }
}
return access_value_history (index);
extern struct value *value_from_double (struct type *type, DOUBLEST num);
extern struct value *value_from_decfloat (struct type *type,
const gdb_byte *decbytes);
-extern struct value *value_from_history_ref (char *, char **);
+extern struct value *value_from_history_ref (const char *, const char **);
extern struct value *value_at (struct type *type, CORE_ADDR addr);
extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);