summaryrefslogtreecommitdiff
path: root/perltest.sh
diff options
context:
space:
mode:
authorph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2018-07-17 16:00:09 +0000
committerph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2018-07-17 16:00:09 +0000
commit8d3008803ffa16d46260e7e1ad087f62e1ca0a28 (patch)
tree45ad24a41f4e0f09b15fb7745c1c49fdcd10a73e /perltest.sh
parentb7443348fccc4c922e9410d72b78d553a1768c24 (diff)
downloadpcre2-8d3008803ffa16d46260e7e1ad087f62e1ca0a28.tar.gz
Upgrade perltest.sh to support (some) #pattern modifiers.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@967 6239d852-aaf2-0410-a92c-79f79f948069
Diffstat (limited to 'perltest.sh')
-rwxr-xr-xperltest.sh31
1 files changed, 29 insertions, 2 deletions
diff --git a/perltest.sh b/perltest.sh
index ac33a68..dc5002c 100755
--- a/perltest.sh
+++ b/perltest.sh
@@ -50,6 +50,13 @@ fi
# ucp sets Perl's /u modifier
# utf invoke UTF-8 functionality
#
+# Comment lines are ignored. The #pattern command can be used to set modifiers
+# that will be added to each subsequent pattern. NOTE: this is different to
+# pcre2test where #pattern sets defaults, some of which can be overridden on
+# individual patterns. The #perltest, #forbid_utf, and #newline_default
+# commands, which are needed in the relevant pcre2test files, are ignored. Any
+# other #-command is ignored, with a warning message.
+#
# The data lines must not have any pcre2test modifiers. Unless
# "subject_literal" is on the pattern, data lines are processed as
# Perl double-quoted strings, so if they contain " $ or @ characters, these
@@ -127,7 +134,26 @@ for (;;)
printf " re> " if $interact;
last if ! ($_ = <$infile>);
printf $outfile "$_" if ! $interact;
- next if ($_ =~ /^\s*$/ || $_ =~ /^#/);
+ next if ($_ =~ /^\s*$/ || $_ =~ /^#[\s!]/);
+
+ # A few of pcre2test's #-commands are supported, or just ignored. Any others
+ # cause an error.
+
+ if ($_ =~ /^#pattern(.*)/)
+ {
+ $extra_modifiers = $1;
+ chomp($extra_modifiers);
+ $extra_modifiers =~ s/\s+$//;
+ next;
+ }
+ elsif ($_ =~ /^#/)
+ {
+ if ($_ !~ /^#newline_default|^#perltest|^#forbid_utf/)
+ {
+ printf $outfile "** Warning: #-command ignored: %s", $_;
+ }
+ next;
+ }
$pattern = $_;
@@ -146,7 +172,8 @@ for (;;)
$pattern =~ /^\s*((.).*\2)(.*)$/s;
$pat = $1;
- $mod = $3;
+ $mod = "$3,$extra_modifiers";
+ $mod =~ s/^,\s*//;
$del = $2;
# The private "aftertext" modifier means "print $' afterwards".