You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by km...@apache.org on 2017/03/23 15:54:04 UTC

geode-native git commit: GEODE-2470: Fix for Solaris regex short comings.

Repository: geode-native
Updated Branches:
  refs/heads/develop 43a724a4e -> ef878c656


GEODE-2470: Fix for Solaris regex short comings.


Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/ef878c65
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/ef878c65
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/ef878c65

Branch: refs/heads/develop
Commit: ef878c65639bb76171b9805d5a891941a5dff99f
Parents: 43a724a
Author: Mike Martell <mm...@pivotal.io>
Authored: Wed Mar 22 12:38:11 2017 -0700
Committer: Karen Miller <km...@pivotal.io>
Committed: Thu Mar 23 08:54:02 2017 -0700

----------------------------------------------------------------------
 src/cppcache/integration-test/CacheHelper.cpp | 36 ++++++++++++++++++++++
 src/cppcache/integration-test/CacheHelper.hpp |  5 +++
 2 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode-native/blob/ef878c65/src/cppcache/integration-test/CacheHelper.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/CacheHelper.cpp b/src/cppcache/integration-test/CacheHelper.cpp
index b71e34d..b6dd35d 100644
--- a/src/cppcache/integration-test/CacheHelper.cpp
+++ b/src/cppcache/integration-test/CacheHelper.cpp
@@ -1376,6 +1376,41 @@ void CacheHelper::createDuplicateXMLFile(std::string& originalFile,
          CacheHelper::staticConfigFileList.size());
 }
 
+// Need to avoid regex usage in Solaris Studio 12.4.
+#ifdef _SOLARIS
+// @Solaris 12.4 compiler is missing support for C++11 regex
+void CacheHelper::replacePortsInFile(int hostPort1, int hostPort2,
+                                     int hostPort3, int hostPort4, int locPort1,
+                                     int locPort2, const std::string& inFile,
+                                     const std::string& outFile) {
+  std::ifstream in(inFile, std::ios::in | std::ios::binary);
+  if (in) {
+    std::string contents;
+    contents.assign(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
+    in.close();
+
+    replaceInPlace(contents, "HOST_PORT1", std::to_string(hostPort1));
+    replaceInPlace(contents, "HOST_PORT2", std::to_string(hostPort2));
+    replaceInPlace(contents, "HOST_PORT3", std::to_string(hostPort3));
+    replaceInPlace(contents, "HOST_PORT4", std::to_string(hostPort4));
+    replaceInPlace(contents, "LOC_PORT1", std::to_string(locPort1));
+    replaceInPlace(contents, "LOC_PORT2", std::to_string(locPort2));
+
+    std::ofstream out(outFile, std::ios::out);
+    out << contents;
+    out.close();
+  }
+}
+
+void CacheHelper::replaceInPlace(std::string& searchStr, const std::string& matchStr,
+                                 const std::string& replaceStr) {
+    size_t pos = 0;
+    while ((pos = searchStr.find(matchStr, pos)) != std::string::npos) {
+      searchStr.replace(pos, matchStr.length(), replaceStr);
+      pos += replaceStr.length();
+    }
+}
+#else
 void CacheHelper::replacePortsInFile(int hostPort1, int hostPort2,
                                      int hostPort3, int hostPort4, int locPort1,
                                      int locPort2, const std::string& inFile,
@@ -1398,6 +1433,7 @@ void CacheHelper::replacePortsInFile(int hostPort1, int hostPort2,
     out.close();
   }
 }
+#endif
 
 void CacheHelper::createDuplicateXMLFile(std::string& duplicateFile,
                                          std::string& originalFile) {

http://git-wip-us.apache.org/repos/asf/geode-native/blob/ef878c65/src/cppcache/integration-test/CacheHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/CacheHelper.hpp b/src/cppcache/integration-test/CacheHelper.hpp
index a1df058..4e85e7c 100644
--- a/src/cppcache/integration-test/CacheHelper.hpp
+++ b/src/cppcache/integration-test/CacheHelper.hpp
@@ -284,6 +284,11 @@ class CacheHelper {
                                  const std::string& inFile,
                                  const std::string& outFile);
 
+#ifdef _SOLARIS
+  static void replaceInPlace(std::string& searchStr, const std::string& matchStr,
+                                   const std::string& replaceStr);
+#endif
+
   static std::list<int> staticLocatorInstanceList;
   static bool isLocatorCleanupCallbackRegistered;
   static void cleanupLocatorInstances();