Skip to content

Commit 651f056

Browse files
committed
[nrf fromtree] cmake: do not double escape double quote
Do not escape single escaped quote '\"'. A single escape quote in CMake indicates the use of literal '"'. Escaping those results in '\\"' which is a literal '\' and a quote which encapsulates a string. This is a result we do not want. Therefore, exempt the '\"' sequence from further escaping. Signed-off-by: Torsten Rasmussen <[email protected]> (cherry picked from commit 991396c)
1 parent 76f2153 commit 651f056

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cmake/modules/extensions.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3060,9 +3060,9 @@ endfunction()
30603060
# This function extends the CMake string function by providing additional
30613061
# manipulation arguments to CMake string.
30623062
#
3063-
# ESCAPE: Ensure that any single '\' in the input string is escaped with the
3064-
# escape char '\'. For example the string 'foo\bar' will be escaped
3065-
# so that it becomes 'foo\\bar'.
3063+
# ESCAPE: Ensure that any single '\', except '\"', in the input string is
3064+
# escaped with the escape char '\'. For example the string 'foo\bar'
3065+
# will be escaped so that it becomes 'foo\\bar'.
30663066
# Backslashes which are already escaped will not be escaped further,
30673067
# for example 'foo\\bar' will not be modified.
30683068
# This is useful for handling of windows path separator in strings or
@@ -3107,7 +3107,7 @@ function(zephyr_string)
31073107
# If a single '\' is discovered, such as 'foo\bar', then it must be escaped like: 'foo\\bar'
31083108
# \\1 and \\2 are keeping the match patterns, the \\\\ --> \\ meaning an escaped '\',
31093109
# which then becomes a single '\' in the final string.
3110-
string(REGEX REPLACE "([^\\][\\])([^\\])" "\\1\\\\\\2" work_string "${ZEPHYR_STRING_UNPARSED_ARGUMENTS}")
3110+
string(REGEX REPLACE "([^\\][\\])([^\\\"])" "\\1\\\\\\2" work_string "${ZEPHYR_STRING_UNPARSED_ARGUMENTS}")
31113111
endif()
31123112

31133113
set(${return_arg} ${work_string} PARENT_SCOPE)

0 commit comments

Comments
 (0)