diff options
author | Tomas Hlavacek <tmshlvck@gmail.com> | 2013-03-19 18:02:40 +0100 |
---|---|---|
committer | Tomas Hlavacek <tmshlvck@gmail.com> | 2013-03-19 18:03:49 +0100 |
commit | ce1348537455e5482a283f7a4cae734d13dcf34e (patch) | |
tree | 8b57f58da60063a610c2b975f49920f2fc58b1d0 | |
parent | 8322ecde124188a9408b54afead4666bb954e5a5 (diff) |
Fix birdcl questionmark handling
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.
-rw-r--r-- | client/birdcl/client.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/client/birdcl/client.c b/client/birdcl/client.c index 0a7e3808..21b63270 100644 --- a/client/birdcl/client.c +++ b/client/birdcl/client.c @@ -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)); |