mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 04:40:56 -06:00
When doing successive matches, track the input start and current search start positions separately to prevent the `^` anchor from matching in the middle of the string. Add policy CMP0186 to provide compatibility. Issue: #26629 Fixes: #16899
91 lines
2.1 KiB
CMake
91 lines
2.1 KiB
CMake
function(check_output name expected)
|
|
set(output "${${name}}")
|
|
if(NOT output STREQUAL expected)
|
|
message(FATAL_ERROR "\"string(REGEX)\" set ${name} to \"${output}\", expected \"${expected}\"")
|
|
endif()
|
|
endfunction()
|
|
|
|
# OLD
|
|
cmake_policy(SET CMP0186 OLD)
|
|
|
|
string(REGEX MATCHALL "^0" out "0000")
|
|
check_output(out "0;0;0;0")
|
|
|
|
string(REGEX MATCHALL "^0+" out "0000")
|
|
check_output(out "0000")
|
|
|
|
string(REGEX MATCHALL "^(0|a)" out "0000" )
|
|
check_output(out "0;0;0;0")
|
|
|
|
string(REGEX MATCHALL "^(0|a)" out "aaaa")
|
|
check_output(out "a;a;a;a")
|
|
|
|
string(REGEX MATCHALL "^(0|a)" out "a0a0")
|
|
check_output(out "a;0;a;0")
|
|
|
|
string(REGEX MATCHALL "(^|a)0" out "00a0")
|
|
check_output(out "0;0;a0")
|
|
|
|
string(REGEX REPLACE "^0" "" out "0000")
|
|
check_output(out "")
|
|
|
|
string(REGEX REPLACE "^0" "x" out "0000")
|
|
check_output(out "xxxx")
|
|
|
|
string(REGEX REPLACE "^0+" "x" out "0000")
|
|
check_output(out "x")
|
|
|
|
string(REGEX REPLACE "^(0|a)" "x" out "0000")
|
|
check_output(out "xxxx")
|
|
|
|
string(REGEX REPLACE "^(0|a)" "x" out "aaaa")
|
|
check_output(out "xxxx")
|
|
|
|
string(REGEX REPLACE "^(0|a)" "x" out "a0a0")
|
|
check_output(out "xxxx")
|
|
|
|
string(REGEX REPLACE "(^|a)0" "x" out "00a0")
|
|
check_output(out "xxx")
|
|
|
|
# NEW, same cases as above
|
|
cmake_policy(SET CMP0186 NEW)
|
|
|
|
string(REGEX MATCHALL "^0" out "0000")
|
|
check_output(out "0")
|
|
|
|
string(REGEX MATCHALL "^0+" out "0000")
|
|
check_output(out "0000")
|
|
|
|
string(REGEX MATCHALL "^(0|a)" out "0000")
|
|
check_output(out "0")
|
|
|
|
string(REGEX MATCHALL "^(0|a)" out "aaaa")
|
|
check_output(out "a")
|
|
|
|
string(REGEX MATCHALL "^(0|a)" out "a0a0")
|
|
check_output(out "a")
|
|
|
|
string(REGEX MATCHALL "(^|a)0" out "00a0")
|
|
check_output(out "0;a0")
|
|
|
|
string(REGEX REPLACE "^0" "" out "0000")
|
|
check_output(out "000")
|
|
|
|
string(REGEX REPLACE "^0" "x" out "0000")
|
|
check_output(out "x000")
|
|
|
|
string(REGEX REPLACE "^0+" "x" out "0000")
|
|
check_output(out "x")
|
|
|
|
string(REGEX REPLACE "^(0|a)" "x" out "0000")
|
|
check_output(out "x000")
|
|
|
|
string(REGEX REPLACE "^(0|a)" "x" out "aaaa")
|
|
check_output(out "xaaa")
|
|
|
|
string(REGEX REPLACE "^(0|a)" "x" out "a0a0")
|
|
check_output(out "x0a0")
|
|
|
|
string(REGEX REPLACE "(^|a)0" "x" out "00a0")
|
|
check_output(out "x0x")
|