extract_first_word understands "\'string" but doesn't understand "\"string"
fixed this inconsistency.
break;
case DOUBLE_QUOTE:
- if (c == 0)
+ if (c == 0) {
+ if (flags & EXTRACT_RELAX)
+ goto finish_force_terminate;
return -EINVAL;
- else if (c == '\"')
+ } else if (c == '\"')
state = VALUE;
else if (c == '\\')
state = DOUBLE_QUOTE_ESCAPE;
free(t);
assert_se(isempty(p));
+ p = original = "\"fooo";
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_RELAX) > 0);
+ assert_se(streq(t, "fooo"));
+ free(t);
+ assert_se(isempty(p));
+
p = original = "yay\'foo\'bar";
assert_se(extract_first_word(&p, &t, NULL, 0) > 0);
assert_se(streq(t, "yay\'foo\'bar"));