[Cmake-commits] CMake branch, next, updated. v2.8.3-771-g7bc03a4

Ben Boeckel ben.boeckel at kitware.com
Wed Dec 8 16:50:16 EST 2010


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  7bc03a468805df1fbc89d18d4976f521fa8b2960 (commit)
       via  36cb701690b201136ca4892eb561da3df34ae191 (commit)
      from  bb94b4867b1750aa98a0b0a92b7cde96fd1019d2 (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=7bc03a468805df1fbc89d18d4976f521fa8b2960
commit 7bc03a468805df1fbc89d18d4976f521fa8b2960
Merge: bb94b48 36cb701
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Dec 8 16:50:13 2010 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Dec 8 16:50:13 2010 -0500

    Merge topic 'dev/support-substring-negative-indices' into next
    
    36cb701 allow STRING(SUBSTRING) work with length -1 as "rest of the string"


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=36cb701690b201136ca4892eb561da3df34ae191
commit 36cb701690b201136ca4892eb561da3df34ae191
Author:     Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Sun Jul 4 18:56:05 2010 +0200
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Dec 8 16:38:30 2010 -0500

    allow STRING(SUBSTRING) work with length -1 as "rest of the string"
    
    This fixes the first half of bug 10740.

diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 19f5c0f..2b4414d 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -606,7 +606,7 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const&
     return false;
     }
   int leftOverLength = intStringLength - begin;
-  if ( end < 0 || end > leftOverLength )
+  if ( end < -1 || end > leftOverLength )
     {
     cmOStringStream ostr;
     ostr << "end index: " << end << " is out of range " << 0 << " - "
diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt
index 2e052bf..7792a35 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -256,3 +256,27 @@ endif()
 if(NOT "${var_b}" STREQUAL "x")
   message(FATAL_ERROR "count incorrect \"b\": [${var_b}]")
 endif()
+
+# Test SUBSTRING command
+SET(ST_INPUTSTRING "0123456789")
+STRING(SUBSTRING ${ST_INPUTSTRING} 3 0 ST_EMPTY)
+STRING(SUBSTRING ${ST_INPUTSTRING} 1 1 ST_ONE)
+STRING(SUBSTRING ${ST_INPUTSTRING} 0 10 ST_ALL)
+STRING(SUBSTRING ${ST_INPUTSTRING} 0 -1 ST_ALL_MINUS)
+STRING(SUBSTRING ${ST_INPUTSTRING} 9 -1 ST_NINE)
+
+IF(ST_EMPTY)
+  MESSAGE(SEND_ERROR "SUBSTRING with length 0 does not return an empty string")
+ENDIF(ST_EMPTY)
+IF(NOT ST_ONE STREQUAL "1")
+  MESSAGE(SEND_ERROR "SUBSTING command does not cut the correct selected character, was \"" ${ST_ONE} "\", should be \"1\"")
+ENDIF(NOT ST_ONE STREQUAL "1")
+IF(NOT ST_INPUTSTRING STREQUAL ST_ALL)
+  MESSAGE(SEND_ERROR "SUBSTRING does not return the whole string when selected with length")
+ENDIF(NOT ST_INPUTSTRING STREQUAL ST_ALL)
+IF(NOT ST_INPUTSTRING STREQUAL ST_ALL_MINUS)
+  MESSAGE(SEND_ERROR "SUBSTRING does not return the whole string when selected with -1")
+ENDIF(NOT ST_INPUTSTRING STREQUAL ST_ALL_MINUS)
+IF(NOT ST_NINE STREQUAL "9")
+  MESSAGE(SEND_ERROR "SUBSTRING does not return the tail when selected with -1")
+ENDIF(NOT ST_NINE STREQUAL "9")

-----------------------------------------------------------------------

Summary of changes:
 Source/cmStringCommand.cxx          |    2 +-
 Tests/StringFileTest/CMakeLists.txt |   24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list