[Cmake-commits] CMake branch, next, updated. v2.8.11-1971-g6e1779f
Stephen Kelly
steveire at gmail.com
Thu May 16 13:30:56 EDT 2013
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 6e1779facf2a53c64b7b450af785ffd148e5296b (commit)
via b6a4f93376397efb65a42f425292adbc92ef9dde (commit)
from 32f0ae5b92662303b26582f5c42fe2f5a17f252e (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=6e1779facf2a53c64b7b450af785ffd148e5296b
commit 6e1779facf2a53c64b7b450af785ffd148e5296b
Merge: 32f0ae5 b6a4f93
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu May 16 13:30:55 2013 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu May 16 13:30:55 2013 -0400
Merge topic 'string-MAKE_C_IDENTIFIER-subcommand' into next
b6a4f93 Add string(MAKE_C_IDENTIFIER) subcommand.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b6a4f93376397efb65a42f425292adbc92ef9dde
commit b6a4f93376397efb65a42f425292adbc92ef9dde
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Mar 21 19:34:32 2013 +0100
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Thu May 16 19:28:33 2013 +0200
Add string(MAKE_C_IDENTIFIER) subcommand.
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index e49edd8..1fbde01 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -93,6 +93,10 @@ bool cmStringCommand
{
return this->HandleTimestampCommand(args);
}
+ else if(subCommand == "MAKE_C_IDENTIFIER")
+ {
+ return this->HandleMakeCIdentifierCommand(args);
+ }
std::string e = "does not recognize sub-command "+subCommand;
this->SetError(e.c_str());
@@ -755,6 +759,24 @@ bool cmStringCommand
}
//----------------------------------------------------------------------------
+bool cmStringCommand
+::HandleMakeCIdentifierCommand(std::vector<std::string> const& args)
+{
+ if(args.size() != 3)
+ {
+ this->SetError("sub-command MAKE_C_IDENTIFIER requires two arguments.");
+ return false;
+ }
+
+ const std::string& input = args[1];
+ const std::string& variableName = args[2];
+
+ this->Makefile->AddDefinition(variableName.c_str(),
+ cmSystemTools::MakeCidentifier(input.c_str()).c_str());
+ return true;
+}
+
+//----------------------------------------------------------------------------
bool cmStringCommand::HandleStripCommand(
std::vector<std::string> const& args)
{
diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h
index 802e0b8..8968cbc 100644
--- a/Source/cmStringCommand.h
+++ b/Source/cmStringCommand.h
@@ -94,6 +94,7 @@ public:
" [RANDOM_SEED <seed>] <output variable>)\n"
" string(FIND <string> <substring> <output variable> [REVERSE])\n"
" string(TIMESTAMP <output variable> [<format string>] [UTC])\n"
+ " string(MAKE_C_IDENTIFIER <input string> <output variable>)\n"
"REGEX MATCH will match the regular expression once and store the "
"match in the output variable.\n"
"REGEX MATCHALL will match the regular expression as many times as "
@@ -176,7 +177,9 @@ public:
"and copied to the output as-is.\n"
"If no explicit <format string> is given it will default to:\n"
" %Y-%m-%dT%H:%M:%S for local time.\n"
- " %Y-%m-%dT%H:%M:%SZ for UTC.";
+ " %Y-%m-%dT%H:%M:%SZ for UTC.\n"
+ "MAKE_C_IDENTIFIER will write a string which can be used as an\n"
+ "identifier in C";
}
cmTypeMacro(cmStringCommand, cmCommand);
@@ -200,6 +203,7 @@ protected:
bool HandleRandomCommand(std::vector<std::string> const& args);
bool HandleFindCommand(std::vector<std::string> const& args);
bool HandleTimestampCommand(std::vector<std::string> const& args);
+ bool HandleMakeCIdentifierCommand(std::vector<std::string> const& args);
class RegexReplacement
{
diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt
index 6d798b0..00383ab 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -280,3 +280,9 @@ endif()
if(NOT ST_NINE STREQUAL "9")
message(SEND_ERROR "SUBSTRING does not return the tail when selected with -1")
endif()
+
+string(MAKE_C_IDENTIFIER "1one-two$" MCI_1)
+
+if(NOT MCI_1 STREQUAL _1one_two_)
+ message(SEND_ERROR "MAKE_C_IDENTIFIER did not create expected result.")
+endif()
-----------------------------------------------------------------------
Summary of changes:
Source/cmStringCommand.cxx | 22 ++++++++++++++++++++++
Source/cmStringCommand.h | 6 +++++-
Tests/StringFileTest/CMakeLists.txt | 6 ++++++
3 files changed, 33 insertions(+), 1 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list