Commit Graph

31 Commits

Author SHA1 Message Date
Brad King
040c1138df Merge topic 'linux32-time64'
a760a74abf Tests: Optionally skip tests requiring 64-bit time_t
14e21fa992 bootstrap: Compile with 64-bit time_t on 32-bit Linux if possible

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10951
2025-07-21 10:02:26 -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
Martin Duffy
35f002e293 string(JSON): Include invalid JSON in parse error 2025-07-11 11:16:39 -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
Brad King
f4aa34daa7 Tests/RunCMake: Update cmake_minimum_required versions to 3.10
For policy-specific tests, use the version before the policy was
introduced.  Otherwise, use 3.10 where possible.
2024-10-03 11:52:22 -04:00
Brad King
1edf138506 Tests/RunCMake: Update cmake_minimum_required versions
For policy-specific tests, use the version before the policy was
introduced.  Otherwise, use 3.5 where possible.

Also, remove `cmake_minimum_required()` and `project()` calls from
individual cases where they are handled by `CMakeLists.txt`.
2023-02-11 06:24:22 -05:00
Vasiliy Koyrev
9da542d5c1 string(TIMESTAMP): Add %z and %Z for adding time zone string
Fixes: #24056
2022-10-27 11:13:46 -04:00
Sean Kahler
e0d3e6e147 string(JSON): Fix typo in error message
`s/then/than/` in a comparison.
2022-08-04 15:50:59 -04:00
Carlo Teubner
93dce4b4bf string(JSON): fix error message on invalid mode
The `GET_ARRAY` and `MEMBERS` modes were removed during development and
review of commit 8eab76eb84 (string(JSON): Adds JSON parsing support to
the string command, 2020-08-24, v3.19.0-rc1~159^2), but were
accidentally left in an error message.
2022-03-30 15:54:11 -04:00
Peter Würth
c050d6a01e string(TIMESTAMP): add %f specifier for microseconds
The %f specified extends the string(TIMESTAMP) and file(TIMESTAMP)
commands to output the timestamp with a microsecond resolution.
This convention is offered by python's datetime module.
Before, the precision was limited to seconds.

The implementation is done by extending existing cmTimestamp methods
with a `microseconds` parameter. This parameter is optional in order to
be backwards compatible. The timestamps are now received in a
cross-platform manner using libuv, since the standard C functions like
time() don't allow for sub-second precision.

This requires libuv 1.28 or higher.  We already require higher than
that on Windows, so update the required version for other platforms.

Implements: #19335
2022-01-28 06:23:57 -05:00
Antons Jeļkins
aafa392c12 string(TIMESTAMP): Add %V specifier for ISO 8601 week number
In ISO 8601 weeks begin with Monday. The first week of
the year is the week which contains the first Thursday
of the year.
2021-08-02 16:31:53 +02: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
Brad King
9b99b4bfc8 Tests/RunCMake: Update cmake_minimum_required versions
Use 3.3 or 2.8.12 where possible.
2020-06-18 09:52:05 -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
Kyle Edwards
514f0b572e Testing: Update hard-coded line numbers to [0-9]+ in some tests 2018-10-10 10:06:27 -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
Bernhard M. Wiedemann
014ad2989c Timestamp: support %A and %B
These are defined both by [1] and [2] to give full names of a weekday
and month.

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html
[2] https://msdn.microsoft.com/de-de/library/fe06s4ak.aspx
2017-09-07 13:36:11 -04: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
6c54f7b365 string: Teach TIMESTAMP to treat %% as %
This encoding is documented by `strptime`.
2017-01-27 09:25:37 -05: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