Add -LM to pcre2test.
This commit is contained in:
parent
89a834b75e
commit
cc2182261a
|
@ -30,6 +30,10 @@ the public names in pcre2_convert.c.
|
||||||
PCRE2GREP_RC to the exit status, because VMS does not distinguish between
|
PCRE2GREP_RC to the exit status, because VMS does not distinguish between
|
||||||
exit(0) and exit(1).
|
exit(0) and exit(1).
|
||||||
|
|
||||||
|
10. Added the -LM (list modifiers) option to pcre2test. Also made -C complain
|
||||||
|
about a bad option only if the following argument item does not start with a
|
||||||
|
hyphen.
|
||||||
|
|
||||||
|
|
||||||
Version 10.30 14-August-2017
|
Version 10.30 14-August-2017
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH PCRE2TEST 1 "12 July 2017" "PCRE 10.30"
|
.TH PCRE2TEST 1 "17 October 2017" "PCRE 10.31"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
pcre2test - a program for testing Perl-compatible regular expressions.
|
pcre2test - a program for testing Perl-compatible regular expressions.
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -136,7 +136,8 @@ internal binary form of the pattern is output after compilation.
|
||||||
\fB-C\fP
|
\fB-C\fP
|
||||||
Output the version number of the PCRE2 library, and all available information
|
Output the version number of the PCRE2 library, and all available information
|
||||||
about the optional features that are included, and then exit with zero exit
|
about the optional features that are included, and then exit with zero exit
|
||||||
code. All other options are ignored.
|
code. All other options are ignored. If both -C and -LM are present, whichever
|
||||||
|
is first is recognized.
|
||||||
.TP 10
|
.TP 10
|
||||||
\fB-C\fP \fIoption\fP
|
\fB-C\fP \fIoption\fP
|
||||||
Output information about a specific build-time option, then exit. This
|
Output information about a specific build-time option, then exit. This
|
||||||
|
@ -201,6 +202,11 @@ Behave as if each pattern line has the \fBjitverify\fP modifier; after
|
||||||
successful compilation, each pattern is passed to the just-in-time compiler, if
|
successful compilation, each pattern is passed to the just-in-time compiler, if
|
||||||
available, and the use of JIT is verified.
|
available, and the use of JIT is verified.
|
||||||
.TP 10
|
.TP 10
|
||||||
|
\fB-LM\fP
|
||||||
|
List modifiers: write a list of available pattern and subject modifiers to the
|
||||||
|
standard output, then exit with zero exit code. All other options are ignored.
|
||||||
|
If both -C and -LM are present, whichever is first is recognized.
|
||||||
|
.TP 10
|
||||||
\fB-pattern\fB \fImodifier-list\fP
|
\fB-pattern\fB \fImodifier-list\fP
|
||||||
Behave as if each pattern line contains the given modifiers.
|
Behave as if each pattern line contains the given modifiers.
|
||||||
.TP 10
|
.TP 10
|
||||||
|
@ -984,13 +990,14 @@ are mutually exclusive.
|
||||||
The following modifiers are really subject modifiers, and are described under
|
The following modifiers are really subject modifiers, and are described under
|
||||||
"Subject Modifiers" below. However, they may be included in a pattern's
|
"Subject Modifiers" below. However, they may be included in a pattern's
|
||||||
modifier list, in which case they are applied to every subject line that is
|
modifier list, in which case they are applied to every subject line that is
|
||||||
processed with that pattern. They may not appear in \fB#pattern\fP commands.
|
processed with that pattern. These modifiers do not affect the compilation
|
||||||
These modifiers do not affect the compilation process.
|
process.
|
||||||
.sp
|
.sp
|
||||||
aftertext show text after match
|
aftertext show text after match
|
||||||
allaftertext show text after captures
|
allaftertext show text after captures
|
||||||
allcaptures show all captures
|
allcaptures show all captures
|
||||||
allusedtext show all consulted text
|
allusedtext show all consulted text
|
||||||
|
altglobal alternative global matching
|
||||||
/g global global matching
|
/g global global matching
|
||||||
jitstack=<n> set size of JIT stack
|
jitstack=<n> set size of JIT stack
|
||||||
mark show mark values
|
mark show mark values
|
||||||
|
@ -1887,6 +1894,6 @@ Cambridge, England.
|
||||||
.rs
|
.rs
|
||||||
.sp
|
.sp
|
||||||
.nf
|
.nf
|
||||||
Last updated: 12 July 2017
|
Last updated: 17 October 2017
|
||||||
Copyright (c) 1997-2017 University of Cambridge.
|
Copyright (c) 1997-2017 University of Cambridge.
|
||||||
.fi
|
.fi
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
124
src/pcre2test.c
124
src/pcre2test.c
|
@ -7707,6 +7707,7 @@ printf(" -help show usage information\n");
|
||||||
printf(" -i set default pattern modifier 'info'\n");
|
printf(" -i set default pattern modifier 'info'\n");
|
||||||
printf(" -jit set default pattern modifier 'jit'\n");
|
printf(" -jit set default pattern modifier 'jit'\n");
|
||||||
printf(" -jitverify set default pattern modifier 'jitverify'\n");
|
printf(" -jitverify set default pattern modifier 'jitverify'\n");
|
||||||
|
printf(" -LM list pattern and subject modifiers, then exit\n");
|
||||||
printf(" -q quiet: do not output PCRE2 version number at start\n");
|
printf(" -q quiet: do not output PCRE2 version number at start\n");
|
||||||
printf(" -pattern <s> set default pattern modifier fields\n");
|
printf(" -pattern <s> set default pattern modifier fields\n");
|
||||||
printf(" -subject <s> set default subject modifier fields\n");
|
printf(" -subject <s> set default subject modifier fields\n");
|
||||||
|
@ -7737,19 +7738,18 @@ static int
|
||||||
c_option(const char *arg)
|
c_option(const char *arg)
|
||||||
{
|
{
|
||||||
uint32_t optval;
|
uint32_t optval;
|
||||||
|
unsigned int i = COPTLISTCOUNT;
|
||||||
int yield = 0;
|
int yield = 0;
|
||||||
|
|
||||||
if (arg != NULL)
|
if (arg != NULL && arg[0] != CHAR_MINUS)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < COPTLISTCOUNT; i++)
|
for (i = 0; i < COPTLISTCOUNT; i++)
|
||||||
if (strcmp(arg, coptlist[i].name) == 0) break;
|
if (strcmp(arg, coptlist[i].name) == 0) break;
|
||||||
|
|
||||||
if (i >= COPTLISTCOUNT)
|
if (i >= COPTLISTCOUNT)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "** Unknown -C option '%s'\n", arg);
|
fprintf(stderr, "** Unknown -C option '%s'\n", arg);
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (coptlist[i].type)
|
switch (coptlist[i].type)
|
||||||
|
@ -7859,6 +7859,114 @@ return 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
* Display one modifier *
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
display_one_modifier(modstruct *m, BOOL for_pattern)
|
||||||
|
{
|
||||||
|
uint32_t c = (!for_pattern && (m->which == MOD_PND || m->which == MOD_PNDP))?
|
||||||
|
'*' : ' ';
|
||||||
|
printf("%c%s", c, m->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
* Display pattern or subject modifiers *
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/* In order to print in two columns, first scan without printing to get a list
|
||||||
|
of the modifiers that are required.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
for_pattern TRUE for pattern modifiers, FALSE for subject modifiers
|
||||||
|
title string to be used in title
|
||||||
|
|
||||||
|
Returns: nothing
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
display_selected_modifiers(BOOL for_pattern, const char *title)
|
||||||
|
{
|
||||||
|
uint32_t i, j;
|
||||||
|
uint32_t n = 0;
|
||||||
|
uint32_t list[MODLISTCOUNT];
|
||||||
|
|
||||||
|
for (i = 0; i < MODLISTCOUNT; i++)
|
||||||
|
{
|
||||||
|
BOOL is_pattern = TRUE;
|
||||||
|
modstruct *m = modlist + i;
|
||||||
|
|
||||||
|
switch (m->which)
|
||||||
|
{
|
||||||
|
case MOD_CTC: /* Compile context */
|
||||||
|
case MOD_PAT: /* Pattern */
|
||||||
|
case MOD_PATP: /* Pattern, OK for Perl-compatible test */
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* The MOD_PND and MOD_PNDP modifiers are precisely those that affect
|
||||||
|
subjects, but can be given with a pattern. We list them as subject
|
||||||
|
modifiers, but marked with an asterisk.*/
|
||||||
|
|
||||||
|
case MOD_CTM: /* Match context */
|
||||||
|
case MOD_DAT: /* Subject line */
|
||||||
|
case MOD_PND: /* As PD, but not default pattern */
|
||||||
|
case MOD_PNDP: /* As PND, OK for Perl-compatible test */
|
||||||
|
is_pattern = FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: printf("** Unknown type for modifier '%s'\n", m->name);
|
||||||
|
/* Fall through */
|
||||||
|
case MOD_PD: /* Pattern or subject */
|
||||||
|
case MOD_PDP: /* As PD, OK for Perl-compatible test */
|
||||||
|
is_pattern = for_pattern;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (for_pattern == is_pattern) list[n++] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now print from the list in two columns. */
|
||||||
|
|
||||||
|
printf("-------------- %s MODIFIERS --------------\n", title);
|
||||||
|
|
||||||
|
for (i = 0, j = (n+1)/2; i < (n+1)/2; i++, j++)
|
||||||
|
{
|
||||||
|
modstruct *m = modlist + list[i];
|
||||||
|
display_one_modifier(m, for_pattern);
|
||||||
|
if (j < n)
|
||||||
|
{
|
||||||
|
uint32_t k = 27 - strlen(m->name);
|
||||||
|
while (k-- > 0) printf(" ");
|
||||||
|
display_one_modifier(modlist + list[j], for_pattern);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
* Display the list of modifiers *
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
display_modifiers(void)
|
||||||
|
{
|
||||||
|
printf(
|
||||||
|
"An asterisk on a subject modifier means that it may be given on a pattern\n"
|
||||||
|
"line, in order to apply to all subjects matched by that pattern. Modifiers\n"
|
||||||
|
"that are listed for both patterns and subjects have different effects in\n"
|
||||||
|
"each case.\n\n");
|
||||||
|
display_selected_modifiers(TRUE, "PATTERN");
|
||||||
|
printf("\n");
|
||||||
|
display_selected_modifiers(FALSE, "SUBJECT");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************
|
/*************************************************
|
||||||
* Main Program *
|
* Main Program *
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
@ -7964,6 +8072,14 @@ while (argc > 1 && argv[op][0] == '-' && argv[op][1] != 0)
|
||||||
char *arg = argv[op];
|
char *arg = argv[op];
|
||||||
unsigned long uli;
|
unsigned long uli;
|
||||||
|
|
||||||
|
/* List modifiers and exit. */
|
||||||
|
|
||||||
|
if (strcmp(arg, "-LM") == 0)
|
||||||
|
{
|
||||||
|
display_modifiers();
|
||||||
|
goto EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Display and/or set return code for configuration options. */
|
/* Display and/or set return code for configuration options. */
|
||||||
|
|
||||||
if (strcmp(arg, "-C") == 0)
|
if (strcmp(arg, "-C") == 0)
|
||||||
|
|
Loading…
Reference in New Issue