From 0c13193f334ea744a251f768179468b5a17915b6 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Sat, 22 Feb 2014 14:42:12 +0800 Subject: [PATCH] Handle parse number error in goto_bookmark_command In GDB mainline, the error message for goto-bookmark isn't perfect. (gdb) goto-bookmark 1.1 goto-bookmark: no bookmark found for ''. This patch tweaks the error message by checking the return value of get_number. With patch applied, it becomes: (gdb) goto-bookmark 1.1 goto-bookmark: invalid bookmark number '1.1'. gdb: 2014-03-06 Yao Qi * reverse.c (goto_bookmark_command): Add local 'p'. Emit error early if get_number returns zero. Use 'p' instead of 'args'. --- gdb/ChangeLog | 5 +++++ gdb/reverse.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8088e648c3..3a1124aa6c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-03-06 Yao Qi + + * reverse.c (goto_bookmark_command): Add local 'p'. Emit error + early if get_number returns zero. Use 'p' instead of 'args'. + 2014-03-06 Yao Qi * cli/cli-utils.c (get_number_trailer): Add '\n' at the end of diff --git a/gdb/reverse.c b/gdb/reverse.c index 582252ce5b..30a0328246 100644 --- a/gdb/reverse.c +++ b/gdb/reverse.c @@ -250,6 +250,7 @@ goto_bookmark_command (char *args, int from_tty) { struct bookmark *b; unsigned long num; + char *p = args; if (args == NULL || args[0] == '\0') error (_("Command requires an argument.")); @@ -274,6 +275,10 @@ goto_bookmark_command (char *args, int from_tty) /* General case. Bookmark identified by bookmark number. */ num = get_number (&args); + + if (num == 0) + error (_("goto-bookmark: invalid bookmark number '%s'."), p); + ALL_BOOKMARKS (b) if (b->number == num) break; @@ -285,7 +290,7 @@ goto_bookmark_command (char *args, int from_tty) return; } /* Not found. */ - error (_("goto-bookmark: no bookmark found for '%s'."), args); + error (_("goto-bookmark: no bookmark found for '%s'."), p); } static int