[cmake-developers] string SUBSTRING TRUNCATE mode
Brad King
brad.king at kitware.com
Wed Nov 12 08:56:07 EST 2014
On 11/11/2014 06:16 PM, Domen Vrankar wrote:
> string(SUBSTRING <string> <begin> <length> <output variable> [TRUNCATE])
[snip]
> string(SUBSTRING ${test_str} 2 6 substr TRUNCATE)
>
> If length is set to a higher value than the length of the original
> string the substring is still created but its end is the end of
> original string.
The functionality makes sense. Python 'abcd'[2:6] does this
automatically. I agree the name TRUNCATE is hard to follow
because I had to read the example to understand the command.
SHORTEN may have the same problem. Other brainstorming ideas:
(CLIP|INTERSECT|TOLERANT)(_RANGE)?
Another option is to just start tolerating out-of-range indexes.
Since it is currently an error there would be no compatibility
problem (except that someone may write code using a newer CMake
that then breaks on an older version).
> If this functionality would be welcome I'll write the tests and
> documentation.
Yes. After the naming bikeshed is painted then tests can go in
Tests/RunCMake/string/*
Thanks,
-Brad
More information about the cmake-developers
mailing list