[Bf-blender-cvs] [341fd67] master: Add string escaping support for BLI_str_quoted_substrN
Campbell Barton
noreply at git.blender.org
Fri Jun 13 16:48:02 CEST 2014
Commit: 341fd67fbf0f83eaf91dae36508c54e53e097360
Author: Campbell Barton
Date: Thu May 29 20:42:09 2014 +1000
https://developer.blender.org/rB341fd67fbf0f83eaf91dae36508c54e53e097360
Add string escaping support for BLI_str_quoted_substrN
===================================================================
M source/blender/blenlib/intern/string.c
===================================================================
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 892bb16..ab81c8f 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);
}
More information about the Bf-blender-cvs
mailing list