mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-12-13 09:24:55 +00:00
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
This commit is contained in:
11
src/term.c
11
src/term.c
@@ -126,12 +126,19 @@ static int nexttok(char * buf, char ** tok, char ** next)
|
|||||||
q++;
|
q++;
|
||||||
|
|
||||||
/* isolate first token */
|
/* isolate first token */
|
||||||
n = q+1;
|
n = q;
|
||||||
while (*n && !isspace((int)*n))
|
uint8_t quotes = 0;
|
||||||
|
while (*n && (!isspace((int)*n) || quotes)) {
|
||||||
|
if (*n == '\"')
|
||||||
|
quotes++;
|
||||||
|
else if (isspace((int)*n) && *(n-1) == '\"')
|
||||||
|
break;
|
||||||
n++;
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
if (*n) {
|
if (*n) {
|
||||||
*n = 0;
|
*n = 0;
|
||||||
|
avrdude_message(MSG_INFO, "q: %s\n", q);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user