[Bf-blender-cvs] [9c0eb1700e1] master: Cleanup: correct variable name mixup in BLI_str_quoted_substrN

Campbell Barton noreply at git.blender.org
Sun Mar 21 04:22:51 CET 2021


Commit: 9c0eb1700e13c5e72268f7b2cc604a270d005dcc
Author: Campbell Barton
Date:   Sun Mar 21 14:21:29 2021 +1100
Branches: master
https://developer.blender.org/rB9c0eb1700e13c5e72268f7b2cc604a270d005dcc

Cleanup: correct variable name mixup in BLI_str_quoted_substrN

Also expand doc-string for `BLI_str_escape_find_quote`

===================================================================

M	source/blender/blenlib/intern/string.c

===================================================================

diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index b0d87838d06..3bfedd6f586 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -400,6 +400,11 @@ size_t BLI_str_unescape(char *__restrict dst, const char *__restrict src, const
 
 /**
  * Find the first un-escaped quote in the string (to find the end of the string).
+ *
+ * \param str: Typically this is the first character in a quoted string.
+ * Where the character before `*str` would be `"`.
+
+ * \return The pointer to the first un-escaped quote.
  */
 const char *BLI_str_escape_find_quote(const char *str)
 {
@@ -436,11 +441,11 @@ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict
     /* get the end point (i.e. where the next occurrence of " is after the starting point) */
     end_match = BLI_str_escape_find_quote(start_match);
     if (end_match) {
-      const size_t unescaped_len = (size_t)(end_match - start_match);
-      char *result = MEM_mallocN(sizeof(char) * (unescaped_len + 1), __func__);
-      const size_t escaped_len = BLI_str_unescape(result, start_match, unescaped_len);
-      if (escaped_len != unescaped_len) {
-        result = MEM_reallocN(result, sizeof(char) * (escaped_len + 1));
+      const size_t escaped_len = (size_t)(end_match - start_match);
+      char *result = MEM_mallocN(sizeof(char) * (escaped_len + 1), __func__);
+      const size_t unescaped_len = BLI_str_unescape(result, start_match, escaped_len);
+      if (unescaped_len != escaped_len) {
+        result = MEM_reallocN(result, sizeof(char) * (unescaped_len + 1));
       }
       return result;
     }



More information about the Bf-blender-cvs mailing list