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
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers