#include "con-utils.h"
#include "cli.h"
+
+/* FIXME: Quoting problems */
+
#define DEBUG_PARSER 0 /* set to 1 to debug */
#define debug_parser(fmt, args...) \
inp++) {
switch (state) {
- case 0:
+ case 0: /* before arg string, waiting for arg start */
if (isblank(c))
continue;
state = 1;
/* fall thru */
- case 1:
+ case 1: /* in arg string, waiting for end of arg string */
if (c == '\\') {
++state;
continue;
}
break;
- case 3:
+ case 3: /* in quote */
if (c == '\\' && quote == '\"') {
++state;
continue;
}
break;
- case 2:
+ case 2: /* waiting for next char */
case 4:
--state;
break;
*/
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;
}