Revision: 436
http://www.exim.org/viewvc/pcre2?view=rev&revision=436
Author: ph10
Date: 2015-11-14 17:28:19 +0000 (Sat, 14 Nov 2015)
Log Message:
-----------
Implement PCRE2_INFO_HASBACKSLASHC.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/doc/pcre2api.3
code/trunk/src/pcre2.h
code/trunk/src/pcre2.h.in
code/trunk/src/pcre2_compile.c
code/trunk/src/pcre2_internal.h
code/trunk/src/pcre2_pattern_info.c
code/trunk/src/pcre2test.c
code/trunk/testdata/testinput2
code/trunk/testdata/testinput5
code/trunk/testdata/testoutput2
code/trunk/testdata/testoutput5
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/ChangeLog 2015-11-14 17:28:19 UTC (rev 436)
@@ -307,7 +307,9 @@
91. Document that JIT has a limit on pattern size, and give more information
about JIT compile failures in pcre2test.
+92. Implement PCRE2_INFO_HASBACKSLASHC.
+
Version 10.20 30-June-2015
--------------------------
Modified: code/trunk/doc/pcre2api.3
===================================================================
--- code/trunk/doc/pcre2api.3 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/doc/pcre2api.3 2015-11-14 17:28:19 UTC (rev 436)
@@ -1,4 +1,4 @@
-.TH PCRE2API 3 "13 November 2015" "PCRE2 10.21"
+.TH PCRE2API 3 "14 November 2015" "PCRE2 10.21"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.sp
@@ -1644,6 +1644,11 @@
returned. Otherwise NULL is returned. The third argument should point to an
\fBconst uint8_t *\fP variable.
.sp
+ PCRE2_INFO_HASBACKSLASHC
+.sp
+Return 1 if the pattern contains any instances of \eC, otherwise 0. The third
+argument should point to an \fBuint32_t\fP variable.
+.sp
PCRE2_INFO_HASCRORLF
.sp
Return 1 if the pattern contains any explicit matches for CR or LF characters,
@@ -3092,6 +3097,6 @@
.rs
.sp
.nf
-Last updated: 13 November 2015
+Last updated: 14 November 2015
Copyright (c) 1997-2015 University of Cambridge.
.fi
Modified: code/trunk/src/pcre2.h
===================================================================
--- code/trunk/src/pcre2.h 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/src/pcre2.h 2015-11-14 17:28:19 UTC (rev 436)
@@ -268,6 +268,7 @@
#define PCRE2_INFO_NEWLINE 20
#define PCRE2_INFO_RECURSIONLIMIT 21
#define PCRE2_INFO_SIZE 22
+#define PCRE2_INFO_HASBACKSLASHC 23
/* Request types for pcre2_config(). */
Modified: code/trunk/src/pcre2.h.in
===================================================================
--- code/trunk/src/pcre2.h.in 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/src/pcre2.h.in 2015-11-14 17:28:19 UTC (rev 436)
@@ -268,6 +268,7 @@
#define PCRE2_INFO_NEWLINE 20
#define PCRE2_INFO_RECURSIONLIMIT 21
#define PCRE2_INFO_SIZE 22
+#define PCRE2_INFO_HASBACKSLASHC 23
/* Request types for pcre2_config(). */
Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/src/pcre2_compile.c 2015-11-14 17:28:19 UTC (rev 436)
@@ -7287,6 +7287,7 @@
else
{
+ if (escape == ESC_C) cb->external_flags |= PCRE2_HASBKC; /* Record */
if ((escape == ESC_b || escape == ESC_B || escape == ESC_A) &&
cb->max_lookbehind == 0)
cb->max_lookbehind = 1;
Modified: code/trunk/src/pcre2_internal.h
===================================================================
--- code/trunk/src/pcre2_internal.h 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/src/pcre2_internal.h 2015-11-14 17:28:19 UTC (rev 436)
@@ -531,6 +531,7 @@
#define PCRE2_NOJIT 0x00080000 /* (*NOJIT) used */
#define PCRE2_HASBKPORX 0x00100000 /* contains \P, \p, or \X */
#define PCRE2_DUPCAPUSED 0x00200000 /* contains (?| */
+#define PCRE2_HASBKC 0x00400000 /* contains \C */
#define PCRE2_MODE_MASK (PCRE2_MODE8 | PCRE2_MODE16 | PCRE2_MODE32)
Modified: code/trunk/src/pcre2_pattern_info.c
===================================================================
--- code/trunk/src/pcre2_pattern_info.c 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/src/pcre2_pattern_info.c 2015-11-14 17:28:19 UTC (rev 436)
@@ -7,7 +7,7 @@
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
- New API code Copyright (c) 2014 University of Cambridge
+ New API code Copyright (c) 2015 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -77,6 +77,7 @@
case PCRE2_INFO_CAPTURECOUNT:
case PCRE2_INFO_FIRSTCODETYPE:
case PCRE2_INFO_FIRSTCODEUNIT:
+ case PCRE2_INFO_HASBACKSLASHC:
case PCRE2_INFO_HASCRORLF:
case PCRE2_INFO_JCHANGED:
case PCRE2_INFO_LASTCODETYPE:
@@ -151,6 +152,10 @@
&(re->start_bitmap[0]) : NULL;
break;
+ case PCRE2_INFO_HASBACKSLASHC:
+ *((uint32_t *)where) = (re->flags & PCRE2_HASBKC) != 0;
+ break;
+
case PCRE2_INFO_HASCRORLF:
*((uint32_t *)where) = (re->flags & PCRE2_HASCRORLF) != 0;
break;
Modified: code/trunk/src/pcre2test.c
===================================================================
--- code/trunk/src/pcre2test.c 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/src/pcre2test.c 2015-11-14 17:28:19 UTC (rev 436)
@@ -3745,8 +3745,9 @@
const uint8_t *start_bits;
BOOL match_limit_set, recursion_limit_set;
uint32_t backrefmax, bsr_convention, capture_count, first_ctype, first_cunit,
- hascrorlf, jchanged, last_ctype, last_cunit, match_empty, match_limit,
- minlength, nameentrysize, namecount, newline_convention, recursion_limit;
+ hasbackslashc, hascrorlf, jchanged, last_ctype, last_cunit, match_empty,
+ match_limit, minlength, nameentrysize, namecount, newline_convention,
+ recursion_limit;
/* These info requests may return PCRE2_ERROR_UNSET. */
@@ -3786,6 +3787,7 @@
pattern_info(PCRE2_INFO_FIRSTBITMAP, &start_bits, FALSE) +
pattern_info(PCRE2_INFO_FIRSTCODEUNIT, &first_cunit, FALSE) +
pattern_info(PCRE2_INFO_FIRSTCODETYPE, &first_ctype, FALSE) +
+ pattern_info(PCRE2_INFO_HASBACKSLASHC, &hasbackslashc, FALSE) +
pattern_info(PCRE2_INFO_HASCRORLF, &hascrorlf, FALSE) +
pattern_info(PCRE2_INFO_JCHANGED, &jchanged, FALSE) +
pattern_info(PCRE2_INFO_LASTCODEUNIT, &last_cunit, FALSE) +
@@ -3840,8 +3842,9 @@
}
}
- if (hascrorlf) fprintf(outfile, "Contains explicit CR or LF match\n");
- if (match_empty) fprintf(outfile, "May match empty string\n");
+ if (hascrorlf) fprintf(outfile, "Contains explicit CR or LF match\n");
+ if (hasbackslashc) fprintf(outfile, "Contains \\C\n");
+ if (match_empty) fprintf(outfile, "May match empty string\n");
pattern_info(PCRE2_INFO_ARGOPTIONS, &compile_options, FALSE);
pattern_info(PCRE2_INFO_ALLOPTIONS, &overall_options, FALSE);
Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/testdata/testinput2 2015-11-14 17:28:19 UTC (rev 436)
@@ -11,6 +11,8 @@
#forbid_utf
#newline_default lf any anycrlf
+/abc\Cdef/info
+
# Test binary zeroes in the pattern
# /a\0B/ where 0 is a binary zero
Modified: code/trunk/testdata/testinput5
===================================================================
--- code/trunk/testdata/testinput5 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/testdata/testinput5 2015-11-14 17:28:19 UTC (rev 436)
@@ -1691,4 +1691,6 @@
/abc/utf,replace=xyz
abc\=zero_terminate
+/abc\Cdef/info,utf
+
# End of testinput5
Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/testdata/testoutput2 2015-11-14 17:28:19 UTC (rev 436)
@@ -11,6 +11,13 @@
#forbid_utf
#newline_default lf any anycrlf
+/abc\Cdef/info
+Capturing subpattern count = 0
+Contains \C
+First code unit = 'a'
+Last code unit = 'f'
+Subject length lower bound = 7
+
# Test binary zeroes in the pattern
# /a\0B/ where 0 is a binary zero
Modified: code/trunk/testdata/testoutput5
===================================================================
--- code/trunk/testdata/testoutput5 2015-11-14 17:08:03 UTC (rev 435)
+++ code/trunk/testdata/testoutput5 2015-11-14 17:28:19 UTC (rev 436)
@@ -4064,4 +4064,12 @@
abc\=zero_terminate
1: xyz
+/abc\Cdef/info,utf
+Capturing subpattern count = 0
+Contains \C
+Options: utf
+First code unit = 'a'
+Last code unit = 'f'
+Subject length lower bound = 0
+
# End of testinput5