From f0f9059ade2fe39267b19738846034651aac16ae Mon Sep 17 00:00:00 2001 From: MCUdude Date: Fri, 1 Apr 2022 16:52:59 +0200 Subject: [PATCH] Tweak nexttok for better string handling Now a string that starts and ends with a quote (") is combined into a single (argc) argument rather than being split where spaces used to be --- src/term.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/term.c b/src/term.c index 5961f8df..a09880fc 100644 --- a/src/term.c +++ b/src/term.c @@ -126,12 +126,19 @@ static int nexttok(char * buf, char ** tok, char ** next) q++; /* isolate first token */ - n = q+1; - while (*n && !isspace((int)*n)) + n = q; + uint8_t quotes = 0; + while (*n && (!isspace((int)*n) || quotes)) { + if (*n == '\"') + quotes++; + else if (isspace((int)*n) && *(n-1) == '\"') + break; n++; + } if (*n) { *n = 0; + avrdude_message(MSG_INFO, "q: %s\n", q); n++; }