summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-13 12:37:00 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-13 15:52:28 (GMT)
commit07f69bd5cc9b6b4bc040327f315620c736ec15ba (patch)
tree4b4346c4d3a0bdff2aada3e465c6155ad3dacbee /Source/cmSystemTools.h
parentf76bcee9a6a95b566e36b533a5fa45b496eb456b (diff)
downloadCMake-07f69bd5cc9b6b4bc040327f315620c736ec15ba.zip
CMake-07f69bd5cc9b6b4bc040327f315620c736ec15ba.tar.gz
CMake-07f69bd5cc9b6b4bc040327f315620c736ec15ba.tar.bz2
cmSystemTools: Add strverscmp
Add support for natural string order by comparing non-numerical character directly and numerical number by firstly collecting contiguous digits. The order is defined by the `strverscmp(3)` manual [1]. [1] http://man7.org/linux/man-pages/man3/strverscmp.3.html Inspired-by: Pierluigi Taddei <pierluigi.taddei@gmail.com>
Diffstat (limited to 'Source/cmSystemTools.h')
-rw-r--r--Source/cmSystemTools.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 3c1a9f4..aecf40e 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -306,6 +306,16 @@ public:
std::string const& rhs);
/**
+ * Compare two ASCII strings using natural versioning order.
+ * Non-numerical characters are compared directly.
+ * Numerical characters are first globbed such that, e.g.
+ * `test000 < test01 < test0 < test1 < test10`.
+ * Return a value less than, equal to, or greater than zero if lhs
+ * precedes, equals, or succeeds rhs in the defined ordering.
+ */
+ static int strverscmp(std::string const& lhs, std::string const& rhs);
+
+ /**
* Determine the file type based on the extension
*/
static FileFormat GetFileFormat(const char* ext);