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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-12-10 05:45:57 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-12-10 06:40:01 +0300
commit82e1b65d91f9ac8f09a9a4698776f21113db46c9 (patch)
tree83e70c9268c2da010aca7a4e014e1c2377089b08 /source/blender/blenlib/intern/string.c
parent15d801625cbb2566815a6fed2fc036a14336fec0 (diff)
BLI_string: support escaping additional control character
Add support for escaping \a, \b & \f for completeness, currently it's not required.
Diffstat (limited to 'source/blender/blenlib/intern/string.c')
-rw-r--r--source/blender/blenlib/intern/string.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index c8b2f3f6e93..98eed838197 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -340,7 +340,10 @@ size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, const si
if (ELEM(c, '\\', '"') || /* Use as-is. */
((c == '\t') && ((void)(c = 't'), true)) || /* Tab. */
((c == '\n') && ((void)(c = 'n'), true)) || /* Newline. */
- ((c == '\r') && ((void)(c = 'r'), true))) /* Carriage return. */
+ ((c == '\r') && ((void)(c = 'r'), true)) || /* Carriage return. */
+ ((c == '\a') && ((void)(c = 'a'), true)) || /* Bell. */
+ ((c == '\b') && ((void)(c = 'b'), true)) || /* Backspace. */
+ ((c == '\f') && ((void)(c = 'f'), true))) /* Form-feed. */
{
if (UNLIKELY(len + 1 >= dst_maxncpy)) {
/* Not enough space to escape. */
@@ -378,7 +381,11 @@ size_t BLI_str_unescape(char *__restrict dst, const char *__restrict src, const
if (((c_next == '"') && ((void)(c = '"'), true)) || /* Quote. */
((c_next == '\\') && ((void)(c = '\\'), true)) || /* Backslash. */
((c_next == 't') && ((void)(c = '\t'), true)) || /* Tab. */
- ((c_next == 'n') && ((void)(c = '\n'), true))) /* Newline. */
+ ((c_next == 'n') && ((void)(c = '\n'), true)) || /* Newline. */
+ ((c_next == 'r') && ((void)(c = '\r'), true)) || /* Carriage return. */
+ ((c_next == 'a') && ((void)(c = '\a'), true)) || /* Bell. */
+ ((c_next == 'b') && ((void)(c = '\b'), true)) || /* Backspace. */
+ ((c_next == 'f') && ((void)(c = '\f'), true))) /* Form-feed. */
{
i++;
src++;