header-only / inglued

#inglued <> : simplified c++ dependencies. Superseeded by nxxm : https://nxxm.github.io
Boost Software License 1.0
8 stars 3 forks source link

BUGFIX: macOS does not like the extra slash #3

Closed linkineo closed 7 years ago

daminetreg commented 7 years ago

On linux without your changes, printing d.get_name() gives me this : get_name : boostorg/fusion

So I don't get why there is a first slash ?

std::cout << " get_name : " << d.get_name() << std::endl;

daminetreg commented 7 years ago

The problem is in the regex executed in d.get_name() it appears that with the same input std::regex yields different capture in libstdc++, libc++ and macOS regex implementation : MacOS printout :

daminetreg commented 7 years ago

Running the following :

  std::string get_name() const {
      //TODO: Add support for full git URIs.
      std::regex only_name("((([^/]+)/)|([^/]+))+"); //(\\.git)?");
      std::smatch matched;
      std::regex_match(git_uri, matched, only_name);

      for (size_t i=0; i < matched.size(); ++i) {
        std::cout << i << " :: " << matched[i] << std::endl;
      }

      if (matched.size() < 3) {
        throw std::runtime_error(str(fmt("Error \"%1%\" is an invalid github-path !") % git_uri));
      }

      return std::string(matched[matched.size() - 2]) 
        + "/" + std::string(matched[matched.size() - 1]);

    }

Linux

0 :: boostorg/fusion
1 :: fusion
2 :: boostorg/
3 :: boostorg
4 :: fusion

MacOS

0 :: boostorg/fusion
1 :: fusion
2 :: 
3 :: 
4 :: fusion
linkineo commented 7 years ago

Weird indeed. I tried it with a simple splitter. Maybe I missed one of your side requirements, but I believe it would do the job. Doesn't tell us why this happens, but regex in C++11 can be a bag of hurt depending on the compiler... Anyway, this does not explain why, but could maybe do the trick. I tested on both Ubuntu 16.04 (gcc 5.2) and macOS.

daminetreg commented 7 years ago

:sunglasses: Hey thank you, can you reply to my considerations in #1 ?

daminetreg commented 7 years ago

Great tested it on macOS and linux, we will be able to make release alpha-0.0.1 for linux AND mac thanks to you.

By the way I prefer the use of split for this task than the regex.

We will surely change these stuffs to accepts full git uris in version 2, but for now it's quite good.

daminetreg commented 7 years ago

Closes #2.