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 8088e648c3b57f2b777ba6d8d7c3c0a949c0fcef..3a1124aa6c24470902b9dc8d403e97094c1ee389 100644 (file)
@@ -1,3 +1,8 @@
+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
index 582252ce5b9e469ef0c4178c5a55b8f8faa30b4d..30a0328246032b9190c16c33d6f79e44a3b0f011 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
This page took 0.02809 seconds and 4 git commands to generate.