Xpressive and line breaks

Hi, I think there's a bug in Xpressive in Boost 1.35 with newline handling. Here is a very simple example: Subject: abc\ndef\nghi Regex: ^.+$ I'm looking for "abc". The following xpressive-based code has odd results: string text(argv[1]); sregex rex = sregex::compile(text, regex_constants::not_dot_newline); smatch match; string subject("abc\ndef\nghi"); if (regex_search(subject.begin(), subject.end(), match, rex, regex_constants::match_default)) { std::cout << "Match at: " << match.position(0) << " length: " << match.length(0); } ^.+$: Match at: 8 length: 3 $: Match at: 4 length: 0 .$: Match at: 10 length: 1 These definitely aren't right, it appears that the only place where end-of-line is matching is at end-of-string. Things get even stranger if I try to use Windows or Mac style end-of-line characters which I need to support too. If I use boost::regex instead then I get these results: ^.+$: Match at: 0 length: 3 $: Match at: 3 length: 0 .$: Match at: 2 length: 1 These are the results I'd expect. It appears in Xpressive that the check in assert_line_base::is_line_break is broken, the following line: if(traits_cast<Traits>(state).isctype(ch, this->newline_)) checks the previous character to see if it's a line break. I believe this should check the current character: if(traits_cast<Traits>(state).isctype(*state.cur_, this->newline_)) This then gets me sane results: ^.+$: Match at: 0 length: 3 $: Match at: 3 length: 0 .$: Match at: 2 length: 1 Is this a known bug? Thanks, Simon.

Simon Steele wrote:
Hi,
I think there's a bug in Xpressive in Boost 1.35 with newline handling. Here is a very simple example: <snip>
Looks like you've found a bug.
These are the results I'd expect. It appears in Xpressive that the check in assert_line_base::is_line_break is broken, the following line:
if(traits_cast<Traits>(state).isctype(ch, this->newline_))
checks the previous character to see if it's a line break. I believe this should check the current character:
if(traits_cast<Traits>(state).isctype(*state.cur_, this->newline_))
I don't think this is the right fix because it causes regression failures. I'll investigate further. Please open a track ticket at svn.boost.org. Thanks for the report. -- Eric Niebler BoostPro Computing http://www.boostpro.com

Eric Niebler wrote:
Simon Steele wrote:
Hi,
I think there's a bug in Xpressive in Boost 1.35 with newline handling. Here is a very simple example: <snip>
Looks like you've found a bug.
This is now fixed on trunk: http://svn.boost.org/trac/boost/changeset/47899 We'll need to let the tests on trunk cycle before I ask the release manager if it's ok to merge this fix to 1.36. Thanks again, -- Eric Niebler BoostPro Computing http://www.boostpro.com

Eric Niebler wrote:
Eric Niebler wrote:
Simon Steele wrote:
Hi,
I think there's a bug in Xpressive in Boost 1.35 with newline handling. Here is a very simple example: <snip>
Looks like you've found a bug.
This is now fixed on trunk: http://svn.boost.org/trac/boost/changeset/47899
I poked some more and found another bug. It's really fixed now. http://svn.boost.org/trac/boost/changeset/47901 -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (2)
-
Eric Niebler
-
Simon Steele