]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fix birdcl questionmark handling
authorTomas Hlavacek <tmshlvck@gmail.com>
Tue, 19 Mar 2013 17:02:40 +0000 (18:02 +0100)
committerTomas Hlavacek <tmshlvck@gmail.com>
Tue, 19 Mar 2013 17:03:49 +0000 (18:03 +0100)
Fix handling of questionmark handling in the bird light client. The
questionmark should display help when it is the last non-blank character on
command line. Otherwise the questionmark does not have any special meaning
and it could be a part of a pattern.

client/birdcl/client.c

index 0a7e3808d6f475441c90cbb5ea6acd73ab9deb02..21b632706319c7c31c4eb4f73b32f1dcf846d055 100644 (file)
@@ -18,6 +18,7 @@
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <signal.h>
+#include <ctype.h>
 
 #include "nest/bird.h"
 #include "lib/resource.h"
@@ -177,6 +178,18 @@ print_prompt(void)
 }
 
 
+static int lastnb(char *str)
+{
+  int i;
+  for (i=strlen(str)-1; i>0; i--)
+    {
+      if(!isblank(str[i]))
+        return i;
+    }
+
+  return 0;
+}
+
 static void
 term_read(void)
 {
@@ -208,7 +221,7 @@ term_read(void)
       printf("%s\n",buf);
     }
 
-  if (strchr(buf, '?'))
+  if (buf[lastnb(buf)] == '?')
     {
       printf("\n");
       cmd_help(buf, strlen(buf));