Skip to content

Commit eab01fb

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 f3c0afb commit eab01fb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cmake/modules/extensions.cmake

+4-4
Original file line numberDiff line numberDiff line change
@@ -3073,9 +3073,9 @@ endfunction()
30733073
# This function extends the CMake string function by providing additional
30743074
# manipulation arguments to CMake string.
30753075
#
3076-
# ESCAPE: Ensure that any single '\' in the input string is escaped with the
3077-
# escape char '\'. For example the string 'foo\bar' will be escaped
3078-
# so that it becomes 'foo\\bar'.
3076+
# ESCAPE: Ensure that any single '\', except '\"', in the input string is
3077+
# escaped with the escape char '\'. For example the string 'foo\bar'
3078+
# will be escaped so that it becomes 'foo\\bar'.
30793079
# Backslashes which are already escaped will not be escaped further,
30803080
# for example 'foo\\bar' will not be modified.
30813081
# This is useful for handling of windows path separator in strings or
@@ -3120,7 +3120,7 @@ function(zephyr_string)
31203120
# If a single '\' is discovered, such as 'foo\bar', then it must be escaped like: 'foo\\bar'
31213121
# \\1 and \\2 are keeping the match patterns, the \\\\ --> \\ meaning an escaped '\',
31223122
# which then becomes a single '\' in the final string.
3123-
string(REGEX REPLACE "([^\\][\\])([^\\])" "\\1\\\\\\2" work_string "${ZEPHYR_STRING_UNPARSED_ARGUMENTS}")
3123+
string(REGEX REPLACE "([^\\][\\])([^\\\"])" "\\1\\\\\\2" work_string "${ZEPHYR_STRING_UNPARSED_ARGUMENTS}")
31243124
endif()
31253125

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

0 commit comments

Comments
 (0)