]> Cypherpunks repositories - gostls13.git/commit
regexp: fix one-pass compilation
authorCaleb Spare <cespare@gmail.com>
Tue, 24 Nov 2015 00:16:42 +0000 (16:16 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 25 Nov 2015 17:44:17 +0000 (17:44 +0000)
commite36bf614c8b2cda985b8c77f144640f82a3413a1
tree8cc207a7704895682f29453474d9024782ec1f3f
parentd1eedfe1321eec4da1c68f711f8bf0de6b926ef1
regexp: fix one-pass compilation

The one-pass transformation is structured as a search over the input
machine for conditions that violate the one-pass requisites. At each
iteration, we should fully explore all non-input paths that proceed from
the current instruction; this is implemented via recursive check calls.
But when we reach instructions that demand input (InstRune*), these
should be put onto the search queue.

Instead of searching this way, the routine previously (effectively)
proceeded through the machine one instruction at a time until finding an
Inst{Match,Fail,Rune*}, calling check on each instruction. This caused
bug #11905, where the transformation stopped before rewriting all
InstAlts as InstAltMatches.

Further, the check function unnecessarily recurred on InstRune*
instructions. (I believe this helps to mask the above bug.)

This change also deletes some unused functions and duplicate test cases.

Fixes #11905.

Change-Id: I5b0b26efea3d3bd01c7479a518b5ed1b886701cd
Reviewed-on: https://go-review.googlesource.com/17195
Reviewed-by: Russ Cox <rsc@golang.org>
src/regexp/onepass.go
src/regexp/onepass_test.go