Skip to content

Fix crash on Xcode #69

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

Merged
merged 1 commit into from
Sep 2, 2015
Merged

Fix crash on Xcode #69

merged 1 commit into from
Sep 2, 2015

Conversation

diamond-msc
Copy link
Contributor

Fixes cpp-netlib/cpp-netlib#539

Quote from http://boost-spirit.com/home/articles/doc-addendum/best-practices/:
Avoid complex rules. [...] C++ compilers were not designed to handle such big expressions and some just couldn’t cope (crashes).

I don't know qi at all. So, this is an experimental, partially script generated, change. Let's see what the tests say...

The script:

puts IO.read("uri_parse.cpp")[/(?<=ipv6address %= qi::raw).*?;/m].gsub(/\s+/, ' ')[2..-3].split("|").each_with_index.map{|l,i|"        ipv6addresses[%d] %%= #{l.strip.sub(/(?<=#{"."*47} )/, "\n#{" "*12}")};" % $i = i};puts "        ipv6address %= qi::raw\n#{" "*12}[#{[*"ipv6addresses[0]".."ipv6addresses[#$i]"].join(" |\n#{" "*12}")}];\n      qi::rule<iterator, string_type()> ipv6addresses[#{$i+1}];"

Fixes #539

Quote from http://boost-spirit.com/home/articles/doc-addendum/best-practices/:
Avoid complex rules. [...] C++ compilers were not designed to handle such big expressions and some just couldn’t cope (crashes).

I don't know qi at all. So, this is an experimental, partially script generated, change. Let's see what the tests say...

The script:
```ruby
puts IO.read("uri_parse.cpp")[/(?<=ipv6address %= qi::raw).*?;/m].gsub(/\s+/, ' ')[2..-3].split("|").each_with_index.map{|l,i|"        ipv6addresses[%d] %%= #{l.strip.sub(/(?<=#{"."*47} )/, "\n#{" "*12}")};" % $i = i};puts "        ipv6address %= qi::raw\n#{" "*12}[#{[*"ipv6addresses[0]".."ipv6addresses[#$i]"].join(" |\n#{" "*12}")}];\n      qi::rule<iterator, string_type()> ipv6addresses[#{$i+1}];"
```
@deanberris
Copy link
Member

LGTM

Yes! Thanks @diamond-msc -- this looks like it does fix it! The tests seem happy! Great work!

deanberris added a commit that referenced this pull request Sep 2, 2015
@deanberris deanberris merged commit 6196a8e into cpp-netlib:master Sep 2, 2015
@diamond-msc diamond-msc deleted the patch-1 branch September 4, 2015 21:12
@danoli3
Copy link

danoli3 commented Mar 24, 2016

Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants