summaryrefslogtreecommitdiff
path: root/op.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-01-04 16:10:53 +0000
committerDavid Mitchell <davem@iabyn.com>2013-01-04 16:23:32 +0000
commitd234778b5b6b322797137257f7f372e6c6c60a12 (patch)
treec3318b886cd29d3afbbf2c9902540c7162d8e2b2 /op.h
parent4a30d80398948aef6e63361ec83ff9ec98d0987a (diff)
downloadperl-d234778b5b6b322797137257f7f372e6c6c60a12.tar.gz
make m?$pat? match only once under ithreads
[perl #115080] m?...? is only supposed to match once, until reset. Normally this is done by setting the PMf_USED flag on the PMOP. Under ithreads we can't modify ops, so instead we indicate by setting the regex's SV to readonly. (This is a bit of a hack: the flag should be associated with the PMOP, not the regex). This breaks with run-time regexes when the pattern gets recompiled; for example: for my $c (qw(a b c)) { print "matched $c\n" if $c =~ m?^$c$?; } outputs matched a on unthreaded, but matched a matched b matched c on threaded. The re_eval jumbo fix made this more noticeable by sometimes recompiling even when the pattern text hasn't changed (to make closures work ok). The quick fix is to propagate the readonlyness of the old re to the new re. (The proper fix would be to store the flag state in a pad slot associated with the PMOP). Needless to say, I've gone for the quick fix.
Diffstat (limited to 'op.h')
-rw-r--r--op.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/op.h b/op.h
index 286b880866..88703da5c8 100644
--- a/op.h
+++ b/op.h
@@ -412,7 +412,7 @@ struct pmop {
* OP_MATCH and OP_QR */
#define PMf_ONCE (1<<(PMf_BASE_SHIFT+1))
-/* PMf_ONCE has matched successfully. Not used under threading. */
+/* PMf_ONCE, i.e. ?pat?, has matched successfully. Not used under threading. */
#define PMf_USED (1<<(PMf_BASE_SHIFT+3))
/* subst replacement is constant */