From 36db5a4d5ff71efeef65e802ef4bf790a3bafba4 Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Mon, 14 Sep 2015 15:10:19 +0000 Subject: [PATCH] Implement comment lines in subject strings in pcre2test (and perltest.sh) input files. --- ChangeLog | 3 +++ doc/pcre2test.1 | 16 +++++++++++----- perltest.sh | 2 ++ src/pcre2test.c | 3 ++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62bd12d..339e7a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -184,6 +184,9 @@ is specified, a valgrind suppressions file is set up to ignore "Invalid read of size 16" errors because these are false positives when the hardware supports the SSE2 instruction set. +52. It is now possible to have comment lines amid the subject strings in +pcre2test (and perltest.sh) input. + Version 10.20 30-June-2015 -------------------------- diff --git a/doc/pcre2test.1 b/doc/pcre2test.1 index 2ac68dd..4a7a91c 100644 --- a/doc/pcre2test.1 +++ b/doc/pcre2test.1 @@ -1,4 +1,4 @@ -.TH PCRE2TEST 1 "12 September 2015" "PCRE 10.21" +.TH PCRE2TEST 1 "14 September 2015" "PCRE 10.21" .SH NAME pcre2test - a program for testing Perl-compatible regular expressions. .SH SYNOPSIS @@ -443,6 +443,12 @@ the start of a modifier list. For example: .sp abc\e=notbol,notempty .sp +If the subject string is empty and \e= is followed by whitespace, the line is +treated as a comment line, and is not used for matching. For example: +.sp + \e= This is a comment. + abc\e= This is an invalid modifier list. +.sp A backslash followed by any other non-alphanumeric character just escapes that character. A backslash followed by anything else causes an error. However, if the very last character in the line is a backslash (and there is no modifier @@ -654,9 +660,9 @@ If no number is given, 7 is assumed. The phrase "partial matching" means a call to \fBpcre2_match()\fP with either the PCRE2_PARTIAL_SOFT or the PCRE2_PARTIAL_HARD option set. Note that such a call may return a complete match; the options enable the possibility of a partial match, but do not -require it. Note also that if you request JIT compilation only for partial -matching (for example, /jit=2) but do not set the \fBpartial\fP modifier on a -subject line, that match will not use JIT code because none was compiled for +require it. Note also that if you request JIT compilation only for partial +matching (for example, /jit=2) but do not set the \fBpartial\fP modifier on a +subject line, that match will not use JIT code because none was compiled for non-partial matching. .P If JIT compilation is successful, the compiled JIT code will automatically be @@ -1519,6 +1525,6 @@ Cambridge, England. .rs .sp .nf -Last updated: 12 September 2015 +Last updated: 14 September 2015 Copyright (c) 1997-2015 University of Cambridge. .fi diff --git a/perltest.sh b/perltest.sh index 5dd26c6..c8ac32d 100755 --- a/perltest.sh +++ b/perltest.sh @@ -210,6 +210,8 @@ for (;;) s/^\s+//; # Remove leading space last if ($_ eq ""); + next if $_ =~ /^\\=(?:\s|$)/; # Comment line + $x = eval "\"$_\""; # To get escapes processed # Empty array for holding results, ensure $REGERROR and $REGMARK are diff --git a/src/pcre2test.c b/src/pcre2test.c index de2e1dd..b12f310 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -6975,7 +6975,8 @@ while (notdone) skipping = FALSE; setlocale(LC_CTYPE, "C"); } - else if (!skipping) rc = process_data(); + else if (!skipping && !(p[0] == '\\' && p[1] == '=' && isspace(p[2]))) + rc = process_data(); } /* We do not have a pattern set up for testing. Lines starting with # are