From fd08e11c1e80591627900dd13db83cee949aba08 Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Sun, 30 Aug 2015 14:11:15 +0000 Subject: [PATCH] Fix pcre2test splitting modifier lists at white space. --- ChangeLog | 3 +++ doc/pcre2test.1 | 17 +++++++++-------- src/pcre2test.c | 5 +++-- testdata/testinput2 | 2 +- testdata/testoutput2 | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c6c413..12e14c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -164,6 +164,9 @@ test (there are now 20 in total). 46. Add the ${*MARK} facility to pcre2_substitute(). +47. Modifier lists in pcre2test were splitting at spaces without the required +commas. + Version 10.20 30-June-2015 -------------------------- diff --git a/doc/pcre2test.1 b/doc/pcre2test.1 index 857adc3..3e0171a 100644 --- a/doc/pcre2test.1 +++ b/doc/pcre2test.1 @@ -1,4 +1,4 @@ -.TH PCRE2TEST 1 "20 May 2015" "PCRE 10.20" +.TH PCRE2TEST 1 "30 August 2015" "PCRE 10.21" .SH NAME pcre2test - a program for testing Perl-compatible regular expressions. .SH SYNOPSIS @@ -303,12 +303,13 @@ subject lines. Modifiers on a subject line can change these settings. .rs .sp Modifier lists are used with both pattern and subject lines. Items in a list -are separated by commas and optional white space. Some modifiers may be given -for both patterns and subject lines, whereas others are valid for one or the -other only. Each modifier has a long name, for example "anchored", and some of -them must be followed by an equals sign and a value, for example, "offset=12". -Modifiers that do not take values may be preceded by a minus sign to turn off a -previous setting. +are separated by commas followed by optional white space. Trailing whitespace +in a modifier list is ignored. Some modifiers may be given for both patterns +and subject lines, whereas others are valid only for one or the other. Each +modifier has a long name, for example "anchored", and some of them must be +followed by an equals sign and a value, for example, "offset=12". Values cannot +contain comma characters, but may contain spaces. Modifiers that do not take +values may be preceded by a minus sign to turn off a previous setting. .P A few of the more common modifiers can also be specified as single letters, for example "i" for "caseless". In documentation, following the Perl convention, @@ -1451,6 +1452,6 @@ Cambridge, England. .rs .sp .nf -Last updated: 20 May 2015 +Last updated: 30 August 2015 Copyright (c) 1997-2015 University of Cambridge. .fi diff --git a/src/pcre2test.c b/src/pcre2test.c index 540b53e..cde7d2f 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -3071,9 +3071,10 @@ for (;;) while (isspace(*p) || *p == ',') p++; if (*p == 0) break; - /* Find the end of the item. */ + /* Find the end of the item; lose trailing whitespace at end of line. */ - for (ep = p; *ep != 0 && *ep != ',' && !isspace(*ep); ep++); + for (ep = p; *ep != 0 && *ep != ','; ep++); + if (*ep == 0) while (ep > p && isspace(ep[-1])) ep--; /* Remember if the first character is '-'. */ diff --git a/testdata/testinput2 b/testdata/testinput2 index 86b658f..f16e75e 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -4079,7 +4079,7 @@ a random value. /Ix apple strudel fruitless -/(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/replace=${*MARK} +/(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/replace=${*MARK} sauce, apple lemon blackberry /(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/g,replace=<$*MARK> diff --git a/testdata/testoutput2 b/testdata/testoutput2 index 9a1e65b..7aa92be 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -13740,9 +13740,9 @@ Failed: error -34: bad option value fruitless 0: fruitless -/(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/replace=${*MARK} +/(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/replace=${*MARK} sauce, apple lemon blackberry - 1: pear lemon blackberry + 1: pear sauce lemon blackberry /(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/g,replace=<$*MARK> apple lemon blackberry