You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by mmartell <gi...@git.apache.org> on 2017/03/22 20:21:50 UTC

[GitHub] geode-native pull request #70: GEODE-2470: Fix for Solaris regex short comin...

GitHub user mmartell opened a pull request:

    https://github.com/apache/geode-native/pull/70

    GEODE-2470: Fix for Solaris regex short comings.

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mmartell/geode-native feature/GEODE-2470

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/geode-native/pull/70.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #70
    
----
commit fb61f34272f054cd6a6ab47ef1b7edf802ee9c29
Author: Mike Martell <mm...@pivotal.io>
Date:   2017-03-22T19:38:11Z

    GEODE-2470: Fix for Solaris regex short comings.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native pull request #70: GEODE-2470: Fix for Solaris regex short comin...

Posted by echobravopapa <gi...@git.apache.org>.
Github user echobravopapa commented on a diff in the pull request:

    https://github.com/apache/geode-native/pull/70#discussion_r107542483
  
    --- Diff: 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);
    --- End diff --
    
    There we go... second arg to .replace() makes all the difference


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native pull request #70: GEODE-2470: Fix for Solaris regex short comin...

Posted by echobravopapa <gi...@git.apache.org>.
Github user echobravopapa commented on a diff in the pull request:

    https://github.com/apache/geode-native/pull/70#discussion_r107535535
  
    --- Diff: 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) {
    --- End diff --
    
    @mmartell I think there is an issue with this replacement code... 
    I'm not convinced we need the loop and my experiments are showing that a searchStr like so:
    "look do leap be sheep" where the matchStr is "leap" and replaceStr is "lose" you will end up with "look do lose"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native pull request #70: GEODE-2470: Fix for Solaris regex short comin...

Posted by mmartell <gi...@git.apache.org>.
Github user mmartell closed the pull request at:

    https://github.com/apache/geode-native/pull/70


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native issue #70: GEODE-2470: Fix for Solaris regex short comings.

Posted by mmartell <gi...@git.apache.org>.
Github user mmartell commented on the issue:

    https://github.com/apache/geode-native/pull/70
  
    This PR has been merged.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---