diff options
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-cmds.c | 32 | ||||
-rw-r--r-- | gdb/cli/cli-utils.c | 4 | ||||
-rw-r--r-- | gdb/cli/cli-utils.h | 6 |
3 files changed, 24 insertions, 18 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 0d37d57..77da738 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1113,20 +1113,22 @@ disassemble_command (char *arg, int from_tty) const char *name; CORE_ADDR pc; int flags; + const char *p; + p = arg; name = NULL; flags = 0; - if (arg && *arg == '/') + if (p && *p == '/') { - ++arg; + ++p; - if (*arg == '\0') + if (*p == '\0') error (_("Missing modifier.")); - while (*arg && ! isspace (*arg)) + while (*p && ! isspace (*p)) { - switch (*arg++) + switch (*p++) { case 'm': flags |= DISASSEMBLY_SOURCE; @@ -1139,20 +1141,20 @@ disassemble_command (char *arg, int from_tty) } } - arg = skip_spaces (arg); + p = skip_spaces_const (p); } - if (! arg || ! *arg) + if (! p || ! *p) { flags |= DISASSEMBLY_OMIT_FNAME; disassemble_current_function (flags); return; } - pc = value_as_address (parse_to_comma_and_eval (&arg)); - if (arg[0] == ',') - ++arg; - if (arg[0] == '\0') + pc = value_as_address (parse_to_comma_and_eval (&p)); + if (p[0] == ',') + ++p; + if (p[0] == '\0') { /* One argument. */ if (find_pc_partial_function (pc, &name, &low, &high) == 0) @@ -1172,13 +1174,13 @@ disassemble_command (char *arg, int from_tty) /* Two arguments. */ int incl_flag = 0; low = pc; - arg = skip_spaces (arg); - if (arg[0] == '+') + p = skip_spaces_const (p); + if (p[0] == '+') { - ++arg; + ++p; incl_flag = 1; } - high = parse_and_eval_address (arg); + high = parse_and_eval_address (p); if (incl_flag) high += low; } diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index 933fb89..f74e6b1 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -237,8 +237,8 @@ skip_spaces_const (const char *chp) /* See documentation in cli-utils.h. */ -char * -skip_to_space (char *chp) +const char * +skip_to_space_const (const char *chp) { if (chp == NULL) return NULL; diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h index 6f28e13..152fb89 100644 --- a/gdb/cli/cli-utils.h +++ b/gdb/cli/cli-utils.h @@ -101,7 +101,11 @@ extern const char *skip_spaces_const (const char *inp); /* Skip leading non-whitespace characters in INP, returning an updated pointer. If INP is NULL, return NULL. */ -extern char *skip_to_space (char *inp); +#define skip_to_space(INP) ((char *) skip_to_space_const (INP)) + +/* A const-correct version of the above. */ + +extern const char *skip_to_space_const (const char *inp); /* Reverse S to the last non-whitespace character without skipping past START. */ |