forked from bartvdbraak/blender
Add string escaping support for BLI_str_quoted_substrN
This commit is contained in:
parent
9db947df41
commit
341fd67fbf
@ -295,11 +295,21 @@ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict
|
||||
startMatch = strstr(str, prefix) + prefixLen + 1;
|
||||
if (startMatch) {
|
||||
/* 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 BLI_strdupn(startMatch, (size_t)(endMatch - startMatch));
|
||||
}
|
||||
}
|
||||
return BLI_strdupn("", 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user