-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support GCC 4.8, using Boost.Regex #43
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cee3d10
Support GCC 4.8, using Boost.Regex
Luthaf 8e45a51
Allow to use Boost.Regex with cmake
Luthaf bf1d121
Enable gcc-48 testing with travis
Luthaf 43ff91d
Make run_tests.py exit with an error for travis
Luthaf d36e13c
Fix version check on travis
Luthaf 6f24219
Clarify the boost version requirement
Luthaf 9ca0721
Fixes parsing of [default: x] in some cases on Win.
8f926b6
Fix cmake installation on OS X in Travis
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
#include <unordered_map> | ||
#include <map> | ||
#include <string> | ||
#include <regex> | ||
#include <iostream> | ||
#include <cassert> | ||
#include <cstddef> | ||
|
@@ -522,31 +521,23 @@ static PatternList parse_argv(Tokens tokens, std::vector<Option>& options, bool | |
return ret; | ||
} | ||
|
||
static std::vector<Option> parse_defaults(std::string const& doc) { | ||
// This pattern is a bit more complex than the python docopt one due to lack of | ||
// re.split. Effectively, it grabs any line with leading whitespace and then a | ||
// hyphen; it stops grabbing when it hits another line that also looks like that. | ||
static std::regex const pattern { | ||
std::vector<Option> parse_defaults(std::string const& doc) { | ||
// This pattern is a delimiter by which we split the options. | ||
// The delimiter is a new line followed by a whitespace(s) followed by one or two hyphens. | ||
static std::regex const re_delimiter{ | ||
"(?:^|\\n)[ \\t]*" // a new line with leading whitespace | ||
"(-(.|\\n)*?)" // a hyphen, and then grab everything it can... | ||
"(?=\\n[ \\t]*-|$)" // .. until it hits another new line with space and a hyphen | ||
"(?=-{1,2})" // [split happens here] (positive lookahead) ... and followed by one or two hyphes | ||
}; | ||
|
||
std::vector<Option> defaults; | ||
for (auto s : parse_section("options:", doc)) { | ||
s.erase(s.begin(), s.begin() + s.find(':') + 1); // get rid of "options:" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You got rid of a |
||
for(auto s : parse_section("options:", doc)) { | ||
s.erase(s.begin(), s.begin()+static_cast<std::ptrdiff_t>(s.find(':'))+1); // get rid of "options:" | ||
|
||
std::for_each(std::sregex_iterator{ s.begin(), s.end(), pattern }, | ||
std::sregex_iterator{}, | ||
[&](std::smatch const& m) | ||
{ | ||
std::string opt = m[1].str(); | ||
|
||
for (const auto& opt : regex_split(s, re_delimiter)) { | ||
if (starts_with(opt, "-")) { | ||
defaults.emplace_back(Option::parse(opt)); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
return defaults; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this really should be implicit? Or should we just assume that people on 4.8 will pass in the "use boost" option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I mean, if that's the only way this'll work, then try as hard as possible to make it work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to update this part. The condition in the if should be
if(USE_BOOST_REGEX)
, and maybe add an error message with a suggestion to define this variable on GCC 4.8.