Commit Graph

53 Commits

Author SHA1 Message Date
Stephen Kelly 7916d7bac6 Include cmAlgorithms where it is used. 2015-03-11 00:17:29 +01:00
Stephen Kelly 4afe6c26c6 cmAlgorithms: Add cmReverseRange adaptor.
Use it to implement list(REVERSE).
2015-02-20 21:36:58 +01:00
Stephen Kelly 75661fdfd9 cmListCommand: Move size variable out of loop.
Re-use it where possible in two instances.
2015-02-17 20:18:58 +01:00
Stephen Kelly 116459d34f cmListCommand: Avoid needlessly erasing from vectors.
The entire vector will be destroyed at once at the end of the scope,
and the remove algorithms already give us the end of the range of
interesting values, so just use those sentinals.
2015-02-15 20:47:51 +01:00
Stephen Kelly 1c7c35c372 cmListCommand: Replace remove duplicates loop with algorithm. 2015-02-15 20:47:51 +01:00
Stephen Kelly 3cfe7a4ca8 cmListCommand: Implement REMOVE_ITEM in terms of cmRemoveMatching. 2015-02-15 19:56:09 +01:00
Stephen Kelly a77af8f130 cmListCommand: Replace joining loop with cmJoin algorithm. 2015-02-15 19:56:07 +01:00
Stephen Kelly 6a22e40147 cmListCommand: Use cmRemoveIndices for REMOVE_AT subcommand.
Avoid repeatedly looping over the indices to process elements (even
without breaking out of the loop when the element is found).
2015-02-15 19:55:28 +01:00
Stephen Kelly 069f2440c4 cmListCommand: Convert loop to find algorithm. 2015-02-15 19:04:30 +01:00
Stephen Kelly 67a26764b5 cmListCommand: Implement REVERSE subcommand with std::reverse. 2015-02-15 18:57:23 +01:00
Stephen Kelly 1cecd3a531 cmListCommand: Use std::find algorithm for FIND subcommand.
Use a ostringstream to account for the input being a variable of type
size_t as a result of using std::distance.  There is no single
format string which portably accepts a size_t.
2015-02-15 14:28:50 +01:00
Stephen Kelly 9380e85f86 Convert loops to cmJoin algorithm with cmRange. 2015-02-11 22:58:04 +01:00
Stephen Kelly 7b8725bf84 Convert loops populating maybe-empty content into the common pattern. 2015-02-11 22:57:53 +01:00
Brad King 9de2ab7fce Merge topic 'consistent-empty-method'
5f69314e Replace foo.length() pattern with !foo.empty().
fd0c036c Replace 'foo.length() >= 1' pattern with !foo.empty()
f09fde2d Replace 'foo.length() > 0' pattern with !foo.empty().
86b5bdfa Replace 'foo.length() == 0' pattern with foo.empty().
fd7b3712 Replace foo.size() pattern with !foo.empty().
aa773035 Replace !foo.size() pattern with foo.empty().
64592633 cmListCommand: Use empty() and expand whitespace.
607e1938 Replace 'foo.size() != 0' pattern with !foo.empty().
930bd478 Replace 'foo.size() == 0' pattern with foo.empty().
d92887ef Replace 'foo.size() > 0' pattern with !foo.empty().
2015-01-19 09:43:28 -05:00
Stephen Kelly b54225732f cmListCommand: Replace loop with member algorithm. 2015-01-18 15:15:17 +01:00
Stephen Kelly fd7b371293 Replace foo.size() pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly 6459263377 cmListCommand: Use empty() and expand whitespace. 2015-01-18 14:25:24 +01:00
Stephen Kelly 607e19384f Replace 'foo.size() != 0' pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly 930bd47816 Replace 'foo.size() == 0' pattern with foo.empty(). 2015-01-18 14:25:24 +01:00
Brad King dd6c596c12 Merge topic 'join-algorithm'
55a73e6b Use the cmJoin algorithm where possible.
8dc8d756 cmStandardIncludes: Add a join algorithm for string containers.
b5813cee cmInstallCommand: Remove unused variable.
2015-01-12 09:41:02 -05:00
Stephen Kelly 931e055d8c Port all cmOStringStream to std::ostringstream.
All compilers hosting CMake support the std class.
2015-01-11 17:06:03 +01:00
Stephen Kelly 55a73e6b1f Use the cmJoin algorithm where possible. 2015-01-08 22:28:18 +01:00
Stephen Kelly 21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Ben Boeckel 3742bb0d32 stringapi: Use strings for variable names
Variable names are always generated by CMake and should never be NULL.
2014-03-08 13:05:28 -05:00
Petr Kmoch 07251a8ea5 Consolidate list() argument count testing
Move test for list() argument count >= 2 to InitialPass().
2012-11-02 17:09:55 +01:00
Rolf Eike Beer 52d9c38e72 list command: error on too many arguments
SORT, REVERSE, and REMOVE_DUPLICATES can only operate on exactly one argument.
Until now all other arguments were silently ignored. Give an error instead.
2012-08-15 22:12:12 +02:00
Kitware Robot 7bbaa4283d Remove trailing whitespace from most CMake and C/C++ code
Our Git commit hooks disallow modification or addition of lines with
trailing whitespace.  Wipe out all remnants of trailing whitespace
everywhere except third-party code.

Run the following shell code:

git ls-files -z -- \
 bootstrap doxygen.config '*.readme' \
 '*.c' '*.cmake' '*.cpp' '*.cxx' \
 '*.el' '*.f' '*.f90' '*.h' '*.in' '*.in.l' '*.java' \
 '*.mm' '*.pike' '*.py' '*.txt' '*.vim' |
egrep -z -v '^(Utilities/cm|Source/(kwsys|CursesDialog/form)/)' |
egrep -z -v '^(Modules/CPack\..*\.in)' |
xargs -0 sed -i 's/ \+$//'
2012-08-13 14:18:39 -04:00
Brad King 05604eb9cb list: Handle errors on empty lists more gracefully (#13138)
Since commit ed1ea24c (Fix INSERT to allow inserting to empty list,
2006-05-15) the list command allows insertion into an empty list at
index 0.  Fix rejection of insertion at non-zero (negative) indices to
present an error message instead of crashing.

While at it, fix the error message of the GET and REMOVE_AT operations
when the list is empty to not present a bogus allowed range.

Add a "RunCMake.list" test to cover failure cases on empty lists.
2012-04-17 11:07:07 -04:00
Brad King 96afb12087 Convert CMake to OSI-approved BSD License
This converts the CMake license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the CMake copyright to
cover the full development time range.
2009-09-28 11:43:28 -04:00
Bill Hoffman afdc33dbb8 BUG: fix failing test 2008-05-20 12:15:40 -04:00
Bill Hoffman fd0e8b3a56 BUG: fix bugs in new style list command that handles empty stuff 2008-05-20 11:30:30 -04:00
Bill Hoffman 2a53075ed8 ENH: fix sort to work with CMP0007 2008-05-07 14:57:29 -04:00
Bill Hoffman 4801fb841f ENH: handle empty lists correctly 2008-04-23 09:56:54 -04:00
Bill Hoffman 0a0672c01f ENH: fix list command with empty elements 2008-04-21 16:57:11 -04:00
Sebastien Barre 3b1bbcfe15 STYLE: yeah yeah. 2008-03-14 16:39:20 -04:00
Sebastien Barre f64d3d0b77 ENH: add REMOVE_DUPLICATES subcommand to LIST command (and test). Remove duplicates from a list (keep the ordering) 2008-03-12 17:02:10 -04:00
Ken Martin 0e69d38004 ENH: add return and break support to cmake, also change basic command invocation signature to be able to return extra informaiton via the cmExecutionStatus class 2008-01-23 10:28:26 -05:00
Brad King a06dcdba97 ENH: Allow LIST(APPEND) command to append nothing. 2008-01-16 11:24:41 -05:00
Alexander Neundorf 2f23ecdb8a ENH: change LIST(CONTAINS ...) TO LIST(FIND ...), which returns the index
and which is more useful, because then you can also access the item behind
the one you were looking, useful for writing macros with optional keywords
with parameters

Alex
2007-08-15 10:26:50 -04:00
Alexander Neundorf c8010cd7fb ENH: add LIST(CONTAINS ...) patch from "Miguel A. Figueroa-Villanueva, miguelf (AT) ieee.org
added tests for LIST(CONTAINS, SORT, REVERSE)

Alex
2007-07-12 11:56:45 -04:00
Brad King 9b89d84210 STYLE: Fixed line-too-long. 2006-08-26 10:29:11 -04:00
Andy Cedilnik c9eaf72567 BUG: Add missing API 2006-08-22 10:16:46 -04:00
Andy Cedilnik 6f7bb4d826 BUG: Fix error messages and fix remove item to actually remove all instances of the item 2006-08-22 09:52:53 -04:00
Andy Cedilnik 70d8c0f3d8 STYLE: Fix style 2006-05-16 08:42:14 -04:00
Andy Cedilnik ed1ea24cef ENH: Fix INSERT to allow inserting to empty list 2006-05-15 10:14:16 -04:00
Andy Cedilnik cb2a9be622 ENH: Change REMOVE and REMOVE_ITEM to REMOVE_AT and REMOVE_ITEM 2006-05-15 09:57:49 -04:00
Andy Cedilnik 3b92585cf0 ENH: Remove some errors, fix append to work on nonexisting lists 2006-05-15 09:25:06 -04:00
Ken Martin 7dc8a92246 STYLE: fix line length 2006-05-12 11:56:09 -04:00
Andy Cedilnik b1b1973736 ENH: Some documentation and add APPEND 2006-05-11 13:56:58 -04:00
Bill Hoffman 5a2668b326 ENH: add support for win64 for visual studio 2005 ide and nmake, also fix warnings produced by building for win64 2006-03-30 13:49:56 -05:00