Skip to content

Remove dependency on boost::regex from Whiskers#7533

Merged
chriseth merged 1 commit intoargotorg:developfrom
kcy1019:feature/no-boost-regex
Oct 17, 2019
Merged

Remove dependency on boost::regex from Whiskers#7533
chriseth merged 1 commit intoargotorg:developfrom
kcy1019:feature/no-boost-regex

Conversation

@kcy1019
Copy link
Copy Markdown
Contributor

@kcy1019 kcy1019 commented Oct 12, 2019

Description

TL;DR

Thanks in advance for advices :)

  • Whiskers regex - as-is, with boost::regex:
    /<([a-zA-Z0-9_$-]+)>|<#([a-zA-Z0-9_$-]+)>(.*?)</\2>|<\?([a-zA-Z0-9_$-]+)>(.*?)(<!\4>(.*?))?</\4>/g
  • Whiskers regex - to-be, with std::regex:
    /<([a-zA-Z0-9_$-]+)>|<#([a-zA-Z0-9_$-]+)>((?:.|\r|\n)*?)</\2>|<\?([a-zA-Z0-9_$-]+)>((?:.|\n|\r)*?)(<!\4>((?:.|\n|\r)*?))?</\4>/g

Details

This PR replaces boost::regex with std::regex, as suggested in #6971 and #6997.
The biggest difference between boost::regex and std::regex is the behavior of dots:

  • In boost::regex, .* matches over line breaks
  • In std::regex, .* does not match newline characters(\r, \n).

To address the issue, a change is made to the Whiskers regular expression:

  1. Replace . with non-capturing group (?:.|\r|\n)

And two compilation options are added to the MSVC case:

  1. -DBOOST_REGEX_NO_LIB : It prevents automatic linking to libboost_regex.
  2. -D_REGEX_MAX_STACK_COUNT=200000L: Microsoft implementation of std::regex has too tight recursion depth limit. This option increases it to 200,000 - which, IMHO, is sufficient for every sane use case.

Checklist

  • Code compiles correctly
  • All tests are passing
  • New tests have been created which fail without the change (if possible)
  • README / documentation was extended, if necessary
  • Changelog entry (if change is visible to the user)
  • Used meaningful commit messages

Part of #7259.

@kcy1019 kcy1019 changed the title Remove dependency on boost::regex in Whiskers Remove dependency on boost::regex from Whiskers Oct 12, 2019
@kcy1019 kcy1019 requested a review from chriseth October 16, 2019 22:53
Copy link
Copy Markdown
Contributor

@chriseth chriseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@chriseth chriseth merged commit 5ea1d90 into argotorg:develop Oct 17, 2019
@kcy1019 kcy1019 deleted the feature/no-boost-regex branch October 17, 2019 10:29
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.

2 participants