projects
/
yaz-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
686414b
)
Fix yaz-client command args parsing broken YAZ-855
author
Adam Dickmeiss
<adam@indexdata.dk>
Mon, 17 Aug 2015 12:38:01 +0000
(14:38 +0200)
committer
Adam Dickmeiss
<adam@indexdata.dk>
Mon, 17 Aug 2015 12:38:18 +0000
(14:38 +0200)
Bug introduced in
5be87e7a04c7219b31cefc0a3
client/client.c
patch
|
blob
|
history
diff --git
a/client/client.c
b/client/client.c
index
14ce06a
..
0d686ee
100644
(file)
--- a/
client/client.c
+++ b/
client/client.c
@@
-5184,27
+5184,31
@@
static int cmd_register_tab(const char* arg)
static void process_cmd_line(char* line)
{
int i, res;
static void process_cmd_line(char* line)
{
int i, res;
- char word[32], arg[10240];
+ char word[32], *arg;
+ int no_read = 0;
#if HAVE_GETTIMEOFDAY
gettimeofday(&tv_start, 0);
#endif
#if HAVE_GETTIMEOFDAY
gettimeofday(&tv_start, 0);
#endif
- if ((res = sscanf(line, "%31s %10239s", word, arg)) <= 0)
+ sscanf(line, "%31s%n", word, &no_read);
+ if (no_read == 0)
{
strcpy(word, last_cmd);
{
strcpy(word, last_cmd);
- *arg = '\0';
+ arg = line + strlen(line);
}
}
- else if (res == 1)
- *arg = 0;
+ else
+ arg = line + no_read;
strcpy(last_cmd, word);
strcpy(last_cmd, word);
- /* removed tailing spaces from the arg command */
+ /* whitespace chop */
{
{
- char* p = arg;
- char* lastnonspace=NULL;
+ char *p;
+ char *lastnonspace = 0;
- for (; *p; ++p)
+ while (*arg && yaz_isspace(*arg))
+ arg++;
+ for (p = arg; *p; ++p)
{
if (!yaz_isspace(*p))
lastnonspace = p;
{
if (!yaz_isspace(*p))
lastnonspace = p;
@@
-5288,9
+5292,9
@@
static char **readline_completer(char *text, int start, int end)
}
else
{
}
else
{
- char arg[10240],word[32];
- int i ,res;
- if ((res = sscanf(rl_line_buffer, "%31s %10239s", word, arg)) <= 0)
+ char word[32];
+ int i;
+ if (sscanf(rl_line_buffer, "%31s", word) <= 0)
{
rl_attempted_completion_over = 1;
return NULL;
{
rl_attempted_completion_over = 1;
return NULL;