Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-05-29 14:42:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-06-13 18:47:12 +0400
commit341fd67fbf0f83eaf91dae36508c54e53e097360 (patch)
tree8550b8c97343f0fdc52dea3d1531162104161543 /source
parent9db947df41204b3b19e649a54669655642402300 (diff)
Add string escaping support for BLI_str_quoted_substrN
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/intern/string.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 892bb16a543..ab81c8fdd40 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -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);
}