Skip to content

Commit f0f9059

Browse files
committed
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
1 parent e069871 commit f0f9059

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/term.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,19 @@ static int nexttok(char * buf, char ** tok, char ** next)
126126
q++;
127127

128128
/* isolate first token */
129-
n = q+1;
130-
while (*n && !isspace((int)*n))
129+
n = q;
130+
uint8_t quotes = 0;
131+
while (*n && (!isspace((int)*n) || quotes)) {
132+
if (*n == '\"')
133+
quotes++;
134+
else if (isspace((int)*n) && *(n-1) == '\"')
135+
break;
131136
n++;
137+
}
132138

133139
if (*n) {
134140
*n = 0;
141+
avrdude_message(MSG_INFO, "q: %s\n", q);
135142
n++;
136143
}
137144

0 commit comments

Comments
 (0)