www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9211] New: regex lookahead, (?=(\d\d\d)+\b) failed

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9211

           Summary: regex lookahead, (?=(\d\d\d)+\b) failed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: p.summerland gmail.com



14:13:35 PST ---
The following failed for more than six digits:

auto rx_bf_ddd = regex( r"(?<=\d)(?=(\d\d\d)+\b)", "g");
writefln( "rx_bf_ddd:  %s ", replace(digits, rx_bf_ddd, ",") );

Using (\d{3}) i/o (\d\d\d) worked.

DMD64 D Compiler v2.060

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 26 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9211


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh gmail.com



08:15:19 PST ---
Now that was neasty.
The bug lurked in a branch-test code of *-repetition. It was too optimistic
optimization and it was curbed down back then. Looks like one case slipped
through.

The reduced test case doesn't require lookahead at all: 

version A1 prints [["123", "12", "3"]] (!!)
version A2 prints [["1234", "3", "4"]]

The bug is triggered in a specific scenarios but is quite deadly.

import std.regex, std.stdio;

int main(string[] args)
{
    version(A1)
    {
      auto rx_1 =  regex(r"^(\w)*(\d)");
      auto m = match("1234", rx_1);  
      auto captures = m.front;
      writefln("%s", captures);
    }
    version(A2)
    {
      auto rx_2 = regex(r"^([0-9])*(\d)");
      auto m2 = match("1234", rx_2);
      auto captures2 = m2.front;
      writefln("%s", captures2);
    }
    return 0;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9211


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



10:47:11 PST ---
https://github.com/D-Programming-Language/phobos/pull/1040
https://github.com/D-Programming-Language/phobos/pull/1041

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9211




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/4a08974927ffd467ba05a20f42c72a5fbc500f71
fix issue 9211

A leftover from semantically incorrect optimization in std.regex

https://github.com/D-Programming-Language/phobos/commit/efb7a7b5100ea133ef68f5aa65f9e240f20672d4


Regex bugfix (issue 9211). I assume FreeBSD's failure is unrelated.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 29 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9211




Commit pushed to 2.061 at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/6ed2e15cf4a35e274adb8385b3ee8125326509f9


Regex bugfix (issue 9211). I assume FreeBSD's failure is unrelated.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9211


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9211




Commit pushed to staging at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/6ed2e15cf4a35e274adb8385b3ee8125326509f9


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2013