From dbe041231185e3aca57a8bd77636a73c7dff39fd Mon Sep 17 00:00:00 2001 From: Jean-Michel Picod Date: Wed, 18 Oct 2023 10:38:33 +0200 Subject: [PATCH] Simplify quote handling --- client/deps/cliparser/cliparser.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/client/deps/cliparser/cliparser.c b/client/deps/cliparser/cliparser.c index c11863ab6..0ea0bd33b 100644 --- a/client/deps/cliparser/cliparser.c +++ b/client/deps/cliparser/cliparser.c @@ -222,32 +222,13 @@ int CLIParserParseStringEx(CLIParserContext *ctx, const char *str, void *vargtab break; case PS_QUOTE: if (str[i] == '"') { - // Now let's compact the argument by removing spaces - if (spaceptr != NULL) { - // We've seen at least 1 space - char *cur_ptr = spaceptr; - while (spaceptr < bufptr) { - if (isSpace(*spaceptr) == false) { - *cur_ptr = *spaceptr; - cur_ptr++; - } - spaceptr++; - } - *cur_ptr = 0; - // Rollback bufptr - bufptr = cur_ptr; - spaceptr = NULL; - } - *bufptr = 0x00; + *bufptr++ = 0x00; state = PS_FIRST; } else { - if (isSpace(str[i]) && spaceptr == NULL) { - // Store first encountered space for later - spaceptr = bufptr; + if (isSpace(str[i]) == false) { + *bufptr++ = str[i]; } - *bufptr = str[i]; } - bufptr++; break; } if (bufptr > bufptrend) {