[regex] Small cleanup in subexpression handling
Paolo Bonzini
paolo.bonzini@lu.unisi.ch
Wed Dec 1 11:24:00 GMT 2004
This cleanup has two parts. The first is the remove re_dfa_t's subexps
field, which is only used to test for backreferences used within their
definition like in (x\1). It can be replaced by a simple bitset.
The second is to make OP_BACK_REF 0-based (i.e. \1 corresponds to
opr.idx==0) like OP_OPEN_SUBEXP and OP_CLOSE_SUBEXP are. This
eliminates a good deal of compensation in regexec.c, with no runtime
effects but simplifying some expression.
Since I was at it, I removed a duplicate conditional in
check_subexp_limits. Outer ifs guarantee that (type == OP_OPEN_SUBEXP
|| type == OP_CLOSE_SUBEXP) && ent->subexp_to != str_idx.
Tested with valgrind to avoid stupid off-by-one mistakes like the one
Jakub found yesterday.
Paolo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: regex-subexp-cleanup.patch
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20041201/038f225d/attachment.ksh>
More information about the Libc-alpha
mailing list