diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-03-21 06:21:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-03-21 06:22:14 +0300 |
commit | 9c0eb1700e13c5e72268f7b2cc604a270d005dcc (patch) | |
tree | 3e8617e511f651fb2eecaf1f516d85621f526d84 /source/blender/blenlib | |
parent | dfefafa814dd8daf1fe0e49f48e5ddbf6435bbfe (diff) |
Cleanup: correct variable name mixup in BLI_str_quoted_substrN
Also expand doc-string for `BLI_str_escape_find_quote`
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/string.c | 15 |
1 files changed, 10 insertions, 5 deletions
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; } |