summaryrefslogtreecommitdiff
path: root/regexp.h
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2010-08-18 23:48:16 -0600
committerFlorian Ragwitz <rafl@debian.org>2010-09-20 08:13:30 +0200
commitfb85c0447bf1d343a9b4d4d7075184aeb4c9ae46 (patch)
tree47c8406e939af312e69568c7a9ced9ec7d3529ed /regexp.h
parent5c3fa2e7f75bb4370f758b363cec53992c7fd20a (diff)
downloadperl-fb85c0447bf1d343a9b4d4d7075184aeb4c9ae46.tar.gz
Add (?^...) regex construct
This adds (?^...) to signify to use the default regex modifiers for the cluster or embedded pattern-match modifier change. The major purpose of this is to simplify regex stringification, so that "^" is output in place of "-xism". As a result, the stringification will not change in the future when new regex modifiers are added, so tests, etc. that rely on a particular stringification will have to change now, but never again. Code that needs to work properly with both old- and new-style regexes can use something like the following: # Accept both old and new-style stringification my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? '^' : '-xism'; This construct is Ben Morrow's idea.
Diffstat (limited to 'regexp.h')
-rw-r--r--regexp.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/regexp.h b/regexp.h
index 298a417d26..198b51017c 100644
--- a/regexp.h
+++ b/regexp.h
@@ -236,6 +236,10 @@ and check for NULL.
case SINGLE_PAT_MOD: *(pmfl) |= RXf_PMf_SINGLELINE; break; \
case XTENDED_PAT_MOD: *(pmfl) |= RXf_PMf_EXTENDED; break
+/* Note, includes locale */
+#define STD_PMMOD_FLAGS_CLEAR(pmfl) \
+ *(pmfl) &= ~(RXf_PMf_FOLD|RXf_PMf_MULTILINE|RXf_PMf_SINGLELINE|RXf_PMf_EXTENDED|RXf_PMf_LOCALE)
+
/* chars and strings used as regex pattern modifiers
* Singlular is a 'c'har, plural is a "string"
*