/* from libvarnish/argv.c */
void FreeArgv(char **argv);
-char **ParseArgv(const char *s, int comment);
+char **ParseArgv(const char *s, int flag);
+#define ARGV_COMMENT (1 << 0)
+#define ARGV_COMMA (1 << 1)
/* from libvarnish/crc32.c */
uint32_t crc32(uint32_t crc, const void *p1, unsigned l);
return (p);
}
+static char err_invalid_backslash[] = "Invalid backslash sequence";
+static char err_missing_quote[] = "Missing '\"'";
+
char **
-ParseArgv(const char *s, int comment)
+ParseArgv(const char *s, int flag)
{
char **argv;
const char *p;
s++;
continue;
}
- if (comment && *s == '#')
+ if ((flag & ARGV_COMMENT) && *s == '#')
break;
if (*s == '"') {
p = ++s;
if (*s == '\\') {
i = BackSlash(s, NULL);
if (i == 0) {
- argv[0] = (void*)(uintptr_t)"Invalid backslash sequence";
+ argv[0] = err_invalid_backslash;
return (argv);
}
s += i;
if (!quote) {
if (*s == '\0' || isspace(*s))
break;
+ if ((flag & ARGV_COMMA) && *s == ',')
+ break;
s++;
continue;
}
if (*s == '"')
break;
if (*s == '\0') {
- argv[0] = (void*)(uintptr_t)"Missing '\"'";
+ argv[0] = err_missing_quote;
return (argv);
}
s++;