1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-17 10:33:49 +01:00

Do not skip over the null terminator

This commit is contained in:
René Kijewski 2014-02-26 13:21:25 +01:00
parent 0eb7597ab1
commit 28c4ef45f7

View File

@ -94,13 +94,12 @@ static void handle_input_line(shell_t *shell, char *line)
/* first we need to calculate the number of arguments */ /* first we need to calculate the number of arguments */
unsigned argc = 0; unsigned argc = 0;
char *pos; char *pos = line;
for (pos = line; *pos; ++pos) { while (1) {
if (*pos <= ' ') { if (*pos > ' ') {
*pos = 0; /* found an argument */
continue; if (*pos == '"') {
} /* it's an quoted argument */
else if (*pos == '"') {
do { do {
++pos; ++pos;
if (!*pos) { if (!*pos) {
@ -114,6 +113,7 @@ static void handle_input_line(shell_t *shell, char *line)
} }
} }
else { else {
/* it's an unquoted argument */
do { do {
++pos; ++pos;
if (*pos == '"') { if (*pos == '"') {
@ -122,10 +122,20 @@ static void handle_input_line(shell_t *shell, char *line)
} }
} while (*pos > ' '); } while (*pos > ' ');
} }
/* count the number of arguments we got */
++argc; ++argc;
*pos = 0;
} }
/* zero out the current position (space or quotation mark) and advance */
if (*pos > 0) {
*pos = 0;
++pos;
}
else {
break;
}
}
if (!argc) { if (!argc) {
return; return;
} }