Commit Graph

19 Commits

Author SHA1 Message Date
Martin Duffy
8227028e49 string(GENEX_STRIP): Fix regression on nested generator expressions
Since commit 13c7bb5b0c (cmGeneratorExpression: Update strip function to
collect parsed expressions, 2025-04-08), the logic to strip generator
expressions from a string made incorrect assumptions about the contents of
generator expressions, leading certain cases to be stripped incorrectly.

Clean up the logic and fix broken behavior, and add test coverage with
`string(GENEX_STRIP)`.

Fixes: #27133
2025-08-13 15:52:16 -04:00
Brad King
a760a74abf Tests: Optionally skip tests requiring 64-bit time_t
On some platforms, `time_t` is always 32-bit.  Add an explicit option
to skip tests that require 64-bit `time_t`.
2025-07-16 14:28:43 -04:00
Brad King
1b9e8f833f Linux: Compile with 64-bit time_t even on 32-bit architectures
Extend commit 5b10f96793 (Linux: Compile with _FILE_OFFSET_BITS=64 on
32-bit Linux, 2020-09-23, v3.19.0-rc1~112^2) to cover `time_t` too,
by compiling with `_TIME_BITS=64`.
2025-06-26 09:23:33 -04:00
Brad King
be2f7097ca Tests: Skip string(TIMESTAMP) 2038 case on parisc 32-bit time_t
This was missed by commit 74519e1c83 (string(TIMESTAMP): Fix %s
placeholder for year 2038 on Windows, 2025-02-23).
2025-03-01 14:24:13 -05:00
Brad King
74519e1c83 string(TIMESTAMP): Fix %s placeholder for year 2038 on Windows
`difftime` returns a `double`, so commit 6727270b75 (CMake: Extend
TIMESTAMP sub-commands with new unix time format specifier, 2016-02-16,
v3.6.0-rc1~338^2) cast it to `long` to get an integer result.  However,
in the MSVC ABI, `long` is a 32-bit integer.  Use an explicit 64-bit
integer type instead.

Fixes: #26716
2025-02-26 08:14:56 -05:00
Nikita Nemkin
8d455809b0 string: Allow zero-length matches in all REGEX subcommands
The semantics mimic other languages like Python, Java, JS, etc.
To advance past a zero-length match, the search algorithm first
tries to find a non-zero alternative branch. If that fails, it
force-advances by 1 character.

Fixes: #13790, #13792, #18690, #26629
2025-02-15 01:01:49 +05:00
Nikita Nemkin
5d039f3be3 regex: Match ^ at most once in repeated searches
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
2025-02-13 20:00:02 +05:00
Peter Steneteg
8eab76eb84 string(JSON): Adds JSON parsing support to the string command
Adds a set of sub commands to the string command for parsing JSON, the
JSON commands are: GET, TYPE, MEMBER, LENGTH, REMOVE, SET, and EQUAL.

Closes: #19501
2020-09-16 13:55:24 -04:00
Kyle Edwards
5395bf05eb string: Add new HEX sub-command 2020-02-19 09:11:05 -05:00
Alex Turbov
536cca60ea string: introduce REPEAT sub-command 2019-04-15 11:06:06 -04:00
Alex Turbov
689eeb67cb string: Add JOIN subcommand
This is just like CONCAT but accepts a glue string to put between
each value.  `JOIN ""` is equivalent to `CONCAT`.
2018-02-16 10:04:47 -05:00
Sylvain Joubert
d8ecc25457 Add PREPEND sub-command to string command 2017-08-11 13:26:33 +02:00
Ben Boeckel
b794164143 cmStringCommand: clear intermediate matches
When `string(REGEX REPLACE)` or `string(REGEX MATCHALL)` loop
internally, they store their matches, but they do not clear the previous
match from an earlier iteration. This can leave the contents of
`CMAKE_MATCH_<N>` with bogus values for later matches in the string if
they have groups which earlier matched a non-empty string, but now match
an empty string.

Fixes #17079.
2017-07-21 09:09:56 -04:00
Bernhard M. Wiedemann
243aed525a cmTimestamp: Support SOURCE_DATE_EPOCH to override current time
See https://reproducible-builds.org/ for why this is good and
https://reproducible-builds.org/specs/source-date-epoch/ for the
definition of this variable.
2017-01-26 10:21:41 -05:00
Daniel Pfeifer
2b18cdcaba string: add APPEND subcommand 2015-07-07 09:23:21 -04:00
Justin Borodinsky
1f77a7001b file: Teach STRINGS to support UTF-16 and UTF-32 encodings 2015-01-27 11:30:26 -05:00
Ben Boeckel
7878d06189 test: add a test for clearing regex results 2014-12-03 11:06:44 -05:00
Nils Gladitz
328e869433 StringUuid: Implement new string(UUID) sub-command. 2014-08-28 15:13:54 +02:00
Brad King
4e184a21be string: Add CONCAT sub-command
Add a string(CONCAT) command to simply concatenate input arguments
together.  This will be useful for combining strings from different
quoting syntaxes.  Add a RunCMake.string test covering these cases.
2013-10-21 12:54:20 -04:00