Add string escaping support for BLI_str_quoted_substrN

This commit is contained in:
Campbell Barton 2014-05-29 20:42:09 +10:00
parent 9db947df41
commit 341fd67fbf

@ -295,12 +295,22 @@ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict
startMatch = strstr(str, prefix) + prefixLen + 1; startMatch = strstr(str, prefix) + prefixLen + 1;
if (startMatch) { if (startMatch) {
/* get the end point (i.e. where the next occurance of " is after the starting point) */ /* get the end point (i.e. where the next occurance of " is after the starting point) */
endMatch = strchr(startMatch, '"'); /* " NOTE: this comment here is just so that my text editor still shows the functions ok... */
if (endMatch) endMatch = startMatch;
while ((endMatch = strchr(endMatch, '"'))) {
if (LIKELY(*(endMatch - 1) != '\\')) {
break;
}
else {
endMatch++;
}
}
if (endMatch) {
/* return the slice indicated */ /* return the slice indicated */
return BLI_strdupn(startMatch, (size_t)(endMatch - startMatch)); return BLI_strdupn(startMatch, (size_t)(endMatch - startMatch));
} }
}
return BLI_strdupn("", 0); return BLI_strdupn("", 0);
} }