Skip to content

Commit 991396c

Browse files
tejlmandfabiobaltieri
authored andcommitted
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]>
1 parent 0858399 commit 991396c

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
@@ -3037,9 +3037,9 @@ endfunction()
30373037
# This function extends the CMake string function by providing additional
30383038
# manipulation arguments to CMake string.
30393039
#
3040-
# ESCAPE: Ensure that any single '\' in the input string is escaped with the
3041-
# escape char '\'. For example the string 'foo\bar' will be escaped
3042-
# so that it becomes 'foo\\bar'.
3040+
# ESCAPE: Ensure that any single '\', except '\"', in the input string is
3041+
# escaped with the escape char '\'. For example the string 'foo\bar'
3042+
# will be escaped so that it becomes 'foo\\bar'.
30433043
# Backslashes which are already escaped will not be escaped further,
30443044
# for example 'foo\\bar' will not be modified.
30453045
# This is useful for handling of windows path separator in strings or
@@ -3084,7 +3084,7 @@ function(zephyr_string)
30843084
# If a single '\' is discovered, such as 'foo\bar', then it must be escaped like: 'foo\\bar'
30853085
# \\1 and \\2 are keeping the match patterns, the \\\\ --> \\ meaning an escaped '\',
30863086
# which then becomes a single '\' in the final string.
3087-
string(REGEX REPLACE "([^\\][\\])([^\\])" "\\1\\\\\\2" work_string "${ZEPHYR_STRING_UNPARSED_ARGUMENTS}")
3087+
string(REGEX REPLACE "([^\\][\\])([^\\\"])" "\\1\\\\\\2" work_string "${ZEPHYR_STRING_UNPARSED_ARGUMENTS}")
30883088
endif()
30893089

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

0 commit comments

Comments
 (0)