Handle parse number error in goto_bookmark_command
authorYao Qi <yao@codesourcery.com>
Sat, 22 Feb 2014 06:42:12 +0000 (14:42 +0800)
committerYao Qi <yao@codesourcery.com>
Thu, 6 Mar 2014 07:03:30 +0000 (15:03 +0800)
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  <yao@codesourcery.com>

* reverse.c (goto_bookmark_command): Add local 'p'.  Emit error
early if get_number returns zero.  Use 'p' instead of 'args'.

gdb/ChangeLog
gdb/reverse.c

index 8088e64..3a1124a 100644 (file)
@@ -1,5 +1,10 @@
 2014-03-06  Yao Qi  <yao@codesourcery.com>
 
+       * 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  <yao@codesourcery.com>
+
        * cli/cli-utils.c (get_number_trailer): Add '\n' at the end of
        message.
 
index 582252c..30a0328 100644 (file)
@@ -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