return -EINVAL;
}
- if (!GREEDY_REALLOC(s, allocated, sz+2))
+ if (!GREEDY_REALLOC(s, allocated, sz+7))
return -ENOMEM;
if (flags & UNQUOTE_CUNESCAPE) {
if (c != 0)
s[sz++] = c; /* normal explicit char */
else
- sz += utf8_encode_unichar(s, u); /* unicode chars we'll encode as utf8 */
+ sz += utf8_encode_unichar(s + sz, u); /* unicode chars we'll encode as utf8 */
} else
s[sz++] = c;
return -EINVAL;
}
- if (!GREEDY_REALLOC(s, allocated, sz+2))
+ if (!GREEDY_REALLOC(s, allocated, sz+7))
return -ENOMEM;
if (flags & UNQUOTE_CUNESCAPE) {
if (c != 0)
s[sz++] = c;
else
- sz += utf8_encode_unichar(s, u);
+ sz += utf8_encode_unichar(s + sz, u);
} else
s[sz++] = c;
return -EINVAL;
}
- if (!GREEDY_REALLOC(s, allocated, sz+2))
+ if (!GREEDY_REALLOC(s, allocated, sz+7))
return -ENOMEM;
if (flags & UNQUOTE_CUNESCAPE) {
if (c != 0)
s[sz++] = c;
else
- sz += utf8_encode_unichar(s, u);
+ sz += utf8_encode_unichar(s + sz, u);
} else
s[sz++] = c;
assert_se(streq(t, "foobax6ar"));
free(t);
assert_se(p == original + 13);
+
+ p = original = " f\\u00f6o \"pi\\U0001F4A9le\" ";
+ assert_se(unquote_first_word(&p, &t, UNQUOTE_CUNESCAPE) > 0);
+ assert_se(streq(t, "föo"));
+ free(t);
+ assert_se(p == original + 13);
+
+ assert_se(unquote_first_word(&p, &t, UNQUOTE_CUNESCAPE) > 0);
+ assert_se(streq(t, "pi\360\237\222\251le"));
+ free(t);
+ assert_se(p == original + 32);
}
static void test_unquote_many_words(void) {