summaryrefslogtreecommitdiff
path: root/avr/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'avr/cli.c')
-rw-r--r--avr/cli.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/avr/cli.c b/avr/cli.c
index 52c85db..6b26b6f 100644
--- a/avr/cli.c
+++ b/avr/cli.c
@@ -27,6 +27,9 @@
#include "con-utils.h"
#include "cli.h"
+
+/* FIXME: Quoting problems */
+
#define DEBUG_PARSER 0 /* set to 1 to debug */
#define debug_parser(fmt, args...) \
@@ -46,7 +49,7 @@ static int cli_parse_line(char *line, char *argv[])
inp++) {
switch (state) {
- case 0:
+ case 0: /* before arg string, waiting for arg start */
if (isblank(c))
continue;
@@ -55,7 +58,7 @@ static int cli_parse_line(char *line, char *argv[])
state = 1;
/* fall thru */
- case 1:
+ case 1: /* in arg string, waiting for end of arg string */
if (c == '\\') {
++state;
continue;
@@ -71,7 +74,7 @@ static int cli_parse_line(char *line, char *argv[])
}
break;
- case 3:
+ case 3: /* in quote */
if (c == '\\' && quote == '\"') {
++state;
continue;
@@ -82,7 +85,7 @@ static int cli_parse_line(char *line, char *argv[])
}
break;
- case 2:
+ case 2: /* waiting for next char */
case 4:
--state;
break;
@@ -252,12 +255,13 @@ static int cli_run_command(const char *cmd, int flag)
*/
for (inquotes = 0, sep = str; *sep; sep++) {
if ((*sep == '\'') &&
- (*(sep - 1) != '\\'))
+ (sep != str) && /* past string start */
+ (*(sep - 1) != '\\')) /* and NOT escaped */
inquotes = !inquotes;
if (!inquotes &&
- (*sep == ';' || *sep == '\n') && /* separator */
- (sep != str) && /* past string start */
+ (*sep == ';' || *sep == '\n') && /* separator */
+ (sep != str) && /* past string start */
(*(sep - 1) != '\\')) /* and NOT escaped */
break;
}