diff --git a/ChangeLog b/ChangeLog index f09948e..7bb3c11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,9 @@ that is called by both pcre2_match() and pcre2_dfa_match(). 3. Add idempotent guard to pcre2_internal.h. +4. Add new pcre2_config() options: PCRE2_CONFIG_NEVER_BACKSLASH_C and +PCRE2_CONFIG_COMPILED_WIDTHS. + Version 10.30 14-August-2017 ---------------------------- diff --git a/doc/pcre2_config.3 b/doc/pcre2_config.3 index 1f99370..ab9623d 100644 --- a/doc/pcre2_config.3 +++ b/doc/pcre2_config.3 @@ -1,4 +1,4 @@ -.TH PCRE2_CONFIG 3 "26 May 2017" "PCRE2 10.30" +.TH PCRE2_CONFIG 3 "16 September 2017" "PCRE2 10.31" .SH NAME PCRE2 - Perl-compatible regular expressions (revised API) .SH SYNOPSIS @@ -31,8 +31,9 @@ point to a uint32_t integer variable. The available codes are: PCRE2_CONFIG_BSR Indicates what \eR matches by default: PCRE2_BSR_UNICODE PCRE2_BSR_ANYCRLF - PCRE2_CONFIG_HEAPLIMIT Default heap memory limit + PCRE2_CONFIG_COMPILED_WIDTHS Which of 8/16/32 support was compiled PCRE2_CONFIG_DEPTHLIMIT Default backtracking depth limit + PCRE2_CONFIG_HEAPLIMIT Default heap memory limit .\" JOIN PCRE2_CONFIG_JIT Availability of just-in-time compiler support (1=yes 0=no) @@ -41,6 +42,7 @@ point to a uint32_t integer variable. The available codes are: architecture for the JIT compiler PCRE2_CONFIG_LINKSIZE Configured internal link size (2, 3, 4) PCRE2_CONFIG_MATCHLIMIT Default internal resource limit + PCRE2_CONFIG_NEVER_BACKSLASH_C Whether or not \eC is disabled PCRE2_CONFIG_NEWLINE Code for the default newline sequence: PCRE2_NEWLINE_CR PCRE2_NEWLINE_LF diff --git a/doc/pcre2api.3 b/doc/pcre2api.3 index f80ae58..4d06fe3 100644 --- a/doc/pcre2api.3 +++ b/doc/pcre2api.3 @@ -1,4 +1,4 @@ -.TH PCRE2API 3 "10 July 2017" "PCRE2 10.30" +.TH PCRE2API 3 "16 September 2017" "PCRE2 10.31" .SH NAME PCRE2 - Perl-compatible regular expressions (revised API) .sp @@ -1014,6 +1014,12 @@ sequences the \eR escape sequence matches by default. A value of PCRE2_BSR_UNICODE means that \eR matches any Unicode line ending sequence; a value of PCRE2_BSR_ANYCRLF means that \eR matches only CR, LF, or CRLF. The default can be overridden when a pattern is compiled. +.sp + PCRE2_CONFIG_COMPILED_WIDTHS +.sp +The output is a uint32_t integer whose lower bits indicate which code unit +widths were selected when PCRE2 was built. The 1-bit indicates 8-bit support, +and the 2-bit and 4-bit indicate 16-bit and 32-bit support, respectively. .sp PCRE2_CONFIG_DEPTHLIMIT .sp @@ -1079,6 +1085,11 @@ sequence that is recognized as meaning "newline". The values are: .sp The default should normally correspond to the standard sequence for your operating system. +.sp + PCRE2_CONFIG_NEVER_BACKSLASH_C +.sp +The output is a uint32_t integer that is set to one if the use of \eC was +permanently disabled when PCRE2 was built; otherwise it is set to zero. .sp PCRE2_CONFIG_PARENSLIMIT .sp @@ -3574,6 +3585,6 @@ Cambridge, England. .rs .sp .nf -Last updated: 10 July 2017 +Last updated: 16 September 2017 Copyright (c) 1997-2017 University of Cambridge. .fi diff --git a/src/pcre2.h b/src/pcre2.h index 7028df3..52b0ea2 100644 --- a/src/pcre2.h +++ b/src/pcre2.h @@ -338,6 +338,9 @@ numbers must not be changed. */ #define PCRE2_CONFIG_UNICODE_VERSION 10 #define PCRE2_CONFIG_VERSION 11 #define PCRE2_CONFIG_HEAPLIMIT 12 +#define PCRE2_CONFIG_NEVER_BACKSLASH_C 13 +#define PCRE2_CONFIG_COMPILED_WIDTHS 14 + /* Types for code units in patterns and subject strings. */ diff --git a/src/pcre2.h.in b/src/pcre2.h.in index 4a8e126..d873a34 100644 --- a/src/pcre2.h.in +++ b/src/pcre2.h.in @@ -338,6 +338,9 @@ numbers must not be changed. */ #define PCRE2_CONFIG_UNICODE_VERSION 10 #define PCRE2_CONFIG_VERSION 11 #define PCRE2_CONFIG_HEAPLIMIT 12 +#define PCRE2_CONFIG_NEVER_BACKSLASH_C 13 +#define PCRE2_CONFIG_COMPILED_WIDTHS 14 + /* Types for code units in patterns and subject strings. */ diff --git a/src/pcre2_config.c b/src/pcre2_config.c index d009c0a..e487b10 100644 --- a/src/pcre2_config.c +++ b/src/pcre2_config.c @@ -84,11 +84,13 @@ if (where == NULL) /* Requests a length */ return PCRE2_ERROR_BADOPTION; case PCRE2_CONFIG_BSR: + case PCRE2_CONFIG_COMPILED_WIDTHS: + case PCRE2_CONFIG_DEPTHLIMIT: case PCRE2_CONFIG_HEAPLIMIT: case PCRE2_CONFIG_JIT: case PCRE2_CONFIG_LINKSIZE: case PCRE2_CONFIG_MATCHLIMIT: - case PCRE2_CONFIG_DEPTHLIMIT: + case PCRE2_CONFIG_NEVER_BACKSLASH_C: case PCRE2_CONFIG_NEWLINE: case PCRE2_CONFIG_PARENSLIMIT: case PCRE2_CONFIG_STACKRECURSE: /* Obsolete */ @@ -117,6 +119,24 @@ switch (what) #endif break; + case PCRE2_CONFIG_COMPILED_WIDTHS: + *((uint32_t *)where) = 0 +#ifdef SUPPORT_PCRE2_8 + + 1 +#endif +#ifdef SUPPORT_PCRE2_16 + + 2 +#endif +#ifdef SUPPORT_PCRE2_32 + + 4 +#endif + ; + break; + + case PCRE2_CONFIG_DEPTHLIMIT: + *((uint32_t *)where) = MATCH_LIMIT_DEPTH; + break; + case PCRE2_CONFIG_HEAPLIMIT: *((uint32_t *)where) = HEAP_LIMIT; break; @@ -148,14 +168,18 @@ switch (what) *((uint32_t *)where) = MATCH_LIMIT; break; - case PCRE2_CONFIG_DEPTHLIMIT: - *((uint32_t *)where) = MATCH_LIMIT_DEPTH; - break; - case PCRE2_CONFIG_NEWLINE: *((uint32_t *)where) = NEWLINE_DEFAULT; break; + case PCRE2_CONFIG_NEVER_BACKSLASH_C: +#ifdef NEVER_BACKSLASH_C + *((uint32_t *)where) = 1; +#else + *((uint32_t *)where) = 0; +#endif + break; + case PCRE2_CONFIG_PARENSLIMIT: *((uint32_t *)where) = PARENS_NEST_LIMIT; break; diff --git a/src/pcre2test.c b/src/pcre2test.c index 7b7670d..88fe6d6 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -7807,15 +7807,11 @@ printf(" EBCDIC code page %s or similar\n", pcrz_cpversion()); #endif #endif -#ifdef SUPPORT_PCRE2_8 -printf(" 8-bit support\n"); -#endif -#ifdef SUPPORT_PCRE2_16 -printf(" 16-bit support\n"); -#endif -#ifdef SUPPORT_PCRE2_32 -printf(" 32-bit support\n"); -#endif +(void)PCRE2_CONFIG(PCRE2_CONFIG_COMPILED_WIDTHS, &optval); +if (optval & 1) printf(" 8-bit support\n"); +if (optval & 2) printf(" 16-bit support\n"); +if (optval & 4) printf(" 32-bit support\n"); + #ifdef SUPPORT_VALGRIND printf(" Valgrind support\n"); #endif @@ -7846,11 +7842,8 @@ print_newline_config(optval, FALSE); (void)PCRE2_CONFIG(PCRE2_CONFIG_BSR, &optval); printf(" \\R matches %s\n", optval? "CR, LF, or CRLF only" : "all Unicode newlines"); -#ifdef NEVER_BACKSLASH_C -printf(" \\C is not supported\n"); -#else -printf(" \\C is supported\n"); -#endif +(void)PCRE2_CONFIG(PCRE2_CONFIG_NEVER_BACKSLASH_C, &optval); +printf(" \\C is %ssupported\n", optval? "not ":""); (void)PCRE2_CONFIG(PCRE2_CONFIG_LINKSIZE, &optval); printf(" Internal link size = %d\n", optval); (void)PCRE2_CONFIG(PCRE2_CONFIG_PARENSLIMIT, &optval);