[Cmake-commits] CMake branch, next, updated. v3.1.0-rc2-578-g71f4347
Brad King
brad.king at kitware.com
Thu Nov 13 11:17:49 EST 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 71f43471402ae1939d29f27748f42be88ac8d837 (commit)
via 474bbb9dbcd6c257e68874e6966c145b3b82dbdd (commit)
from f7974d44f3d5f1900470293f517ee214d21a2670 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=71f43471402ae1939d29f27748f42be88ac8d837
commit 71f43471402ae1939d29f27748f42be88ac8d837
Merge: f7974d4 474bbb9
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 13 11:17:48 2014 -0500
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Nov 13 11:17:48 2014 -0500
Merge topic 'string-SUBSTRING-truncate' into next
474bbb9d string: Tolerate SUBSTRING length exceeding end index
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=474bbb9dbcd6c257e68874e6966c145b3b82dbdd
commit 474bbb9dbcd6c257e68874e6966c145b3b82dbdd
Author: Domen Vrankar <domen.vrankar at gmail.com>
AuthorDate: Wed Nov 12 23:57:16 2014 +0100
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 13 11:04:52 2014 -0500
string: Tolerate SUBSTRING length exceeding end index
string SUBSTRING command now ignores length if it points
past end of string and uses end of string instead.
String SUBSTRING tests now cover more corner cases.
diff --git a/Help/command/string.rst b/Help/command/string.rst
index 07d0ff3..351385b 100644
--- a/Help/command/string.rst
+++ b/Help/command/string.rst
@@ -73,8 +73,13 @@ TOUPPER/TOLOWER will convert string to upper/lower characters.
LENGTH will return a given string's length.
-SUBSTRING will return a substring of a given string. If length is -1
+SUBSTRING will return a substring of a given string. If length is -1
the remainder of the string starting at begin will be returned.
+If string is shorter than length then end of string is used instead.
+
+.. note::
+ CMake 3.1 and below reported an error if length pointed past
+ the end of string.
STRIP will return a substring of a given string with leading and
trailing spaces removed.
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 90a8f85..ce7c854 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -711,12 +711,10 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const&
this->SetError(ostr.str());
return false;
}
- int leftOverLength = intStringLength - begin;
- if ( end < -1 || end > leftOverLength )
+ if ( end < -1 )
{
cmOStringStream ostr;
- ostr << "end index: " << end << " is out of range -1 - "
- << leftOverLength;
+ ostr << "end index: " << end << " should be -1 or greater";
this->SetError(ostr.str());
return false;
}
diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in
index a9fe428..92e70c3 100644
--- a/Tests/CMakeTests/StringTest.cmake.in
+++ b/Tests/CMakeTests/StringTest.cmake.in
@@ -63,7 +63,7 @@ check_cmake_test(String
# Execute each test listed in StringTestScript.cmake:
#
set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/StringTestScript.cmake")
-set(number_of_tests_expected 69)
+set(number_of_tests_expected 70)
include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake")
execute_all_script_tests(${scriptname} number_of_tests_executed)
@@ -75,6 +75,6 @@ message(STATUS "scriptname='${scriptname}'")
message(STATUS "number_of_tests_executed='${number_of_tests_executed}'")
message(STATUS "number_of_tests_expected='${number_of_tests_expected}'")
-if(number_of_tests_executed LESS number_of_tests_expected)
+if(NOT number_of_tests_executed EQUAL number_of_tests_expected)
message(FATAL_ERROR "error: some test cases were skipped")
endif()
diff --git a/Tests/CMakeTests/StringTestScript.cmake b/Tests/CMakeTests/StringTestScript.cmake
index a562e71..44d5653 100644
--- a/Tests/CMakeTests/StringTestScript.cmake
+++ b/Tests/CMakeTests/StringTestScript.cmake
@@ -122,14 +122,17 @@ elseif(testname STREQUAL substring_not_enough_args) # fail
elseif(testname STREQUAL substring_begin_too_large) # fail
string(SUBSTRING "abcdefg" 25 100 v)
-elseif(testname STREQUAL substring_end_too_large) # fail
+elseif(testname STREQUAL substring_end_larger_than_strlen) # pass
string(SUBSTRING "abcdefg" 1 100 v)
elseif(testname STREQUAL substring_begin_less_than_zero) # fail
- string(SUBSTRING "abcdefg" -2 4 v)
+ string(SUBSTRING "abcdefg" -1 4 v)
-elseif(testname STREQUAL substring_end_less_than_begin) # fail
- string(SUBSTRING "abcdefg" 6 3 v)
+elseif(testname STREQUAL substring_end_less_than_zero) # pass
+ string(SUBSTRING "abcdefg" 0 -1 v)
+
+elseif(testname STREQUAL substring_end_less_than_begin) # pass
+ string(SUBSTRING "abcdefg" 6 0 v)
elseif(testname STREQUAL length_not_enough_args) # fail
string(LENGTH)
-----------------------------------------------------------------------
Summary of changes:
Help/command/string.rst | 7 ++++++-
Source/cmStringCommand.cxx | 6 ++----
Tests/CMakeTests/StringTest.cmake.in | 4 ++--
Tests/CMakeTests/StringTestScript.cmake | 11 +++++++----
4 files changed, 17 insertions(+), 11 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list