http://d.puremagic.com/issues/show_bug.cgi?id=5511



--- Comment #1 from karasu <himana.kar...@orange.fr> 2011-01-31 07:07:08 PST ---
initializing startIdx and endIdx isn't enough if optional capture with no match
contains sub-capture with match. save matches state before parse parentheses
and restore state if no-match is needed.

in RegexMatch.trymatch, case engine.REparen (line 2397 in v2.051)
replace lines 2404-2405:
                if (!trymatch(pop, pop + len))
                    goto Lnomatch;

by:
                if (!psave)
                {
                    psave = cast(regmatch_t *)alloca(
                        (engine.re_nsub + 1) * regmatch_t.sizeof);
                }
                memcpy(psave, pmatch.ptr,
                        (engine.re_nsub + 1) * regmatch_t.sizeof);
                if (!trymatch(pop, pop + len)) {
                    memcpy(pmatch.ptr, psave,
                            (engine.re_nsub + 1) * regmatch_t.sizeof);
                    goto Lnomatch;
                }

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

Reply via email to