diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2015-10-17 13:50:56 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2015-10-17 13:50:56 +0000 |
commit | deee8d934595c4b856361955aaf4dd26995d203a (patch) | |
tree | e51b5816563a758d536c5c15961441724944dcb1 /src | |
parent | 91cb973c4537327c18217b50f20e82283affe976 (diff) | |
download | pcre2-deee8d934595c4b856361955aaf4dd26995d203a.tar.gz |
Implement --never-backslash-C
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@386 6239d852-aaf2-0410-a92c-79f79f948069
Diffstat (limited to 'src')
-rw-r--r-- | src/config.h.generic | 3 | ||||
-rw-r--r-- | src/config.h.in | 3 | ||||
-rw-r--r-- | src/pcre2_compile.c | 12 | ||||
-rw-r--r-- | src/pcre2_error.c | 2 | ||||
-rw-r--r-- | src/pcre2posix.c | 2 | ||||
-rw-r--r-- | src/pcre2test.c | 33 |
6 files changed, 42 insertions, 13 deletions
diff --git a/src/config.h.generic b/src/config.h.generic index 26bc817..26a4818 100644 --- a/src/config.h.generic +++ b/src/config.h.generic @@ -182,6 +182,9 @@ sure both macros are undefined; an emulation function will then be used. */ #define MAX_NAME_SIZE 32 #endif +/* Defining NEVER_BACKSLASH_C locks out the use of \C in all patterns. */ +/* #undef NEVER_BACKSLASH_C */ + /* The value of NEWLINE_DEFAULT determines the default newline character sequence. PCRE2 client programs can override this by selecting other values at run time. The valid values are 1 (CR), 2 (LF), 3 (CRLF), 4 (ANY), and 5 diff --git a/src/config.h.in b/src/config.h.in index e3ef2fd..e55d0a0 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -169,6 +169,9 @@ sure both macros are undefined; an emulation function will then be used. */ overflow caused by enormously large patterns. */ #undef MAX_NAME_SIZE +/* Defining NEVER_BACKSLASH_C locks out the use of \C in all patterns. */ +#undef NEVER_BACKSLASH_C + /* The value of NEWLINE_DEFAULT determines the default newline character sequence. PCRE2 client programs can override this by selecting other values at run time. The valid values are 1 (CR), 2 (LF), 3 (CRLF), 4 (ANY), and 5 diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index c2945e8..10ce358 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -583,7 +583,7 @@ enum { ERR0 = COMPILE_ERROR_BASE, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59, ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69, ERR70, ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79, ERR80, - ERR81, ERR82, ERR83, ERR84 }; + ERR81, ERR82, ERR83, ERR84, ERR85 }; /* This is a table of start-of-pattern options such as (*UTF) and settings such as (*LIMIT_MATCH=nnnn) and (*CRLF). For completeness and backward @@ -7052,12 +7052,20 @@ for (;; ptr++) #endif /* The use of \C can be locked out. */ - + +#ifdef NEVER_BACKSLASH_C + else if (escape == ESC_C) + { + *errorcodeptr = ERR85; + goto FAILED; + } +#else else if (escape == ESC_C && (options & PCRE2_NEVER_BACKSLASH_C) != 0) { *errorcodeptr = ERR83; goto FAILED; } +#endif /* For the rest (including \X when Unicode properties are supported), we can obtain the OP value by negating the escape value in the default diff --git a/src/pcre2_error.c b/src/pcre2_error.c index a44e27d..ecc1820 100644 --- a/src/pcre2_error.c +++ b/src/pcre2_error.c @@ -168,6 +168,8 @@ static const char compile_error_texts[] = "unrecognized string delimiter follows (?C\0" "using \\C is disabled by the application\0" "(?| and/or (?J: or (?x: parentheses are too deeply nested\0" + /* 85 */ + "using \\C is disabled in this PCRE2 library\0" ; /* Match-time and UTF error texts are in the same format. */ diff --git a/src/pcre2posix.c b/src/pcre2posix.c index da212fc..778d985 100644 --- a/src/pcre2posix.c +++ b/src/pcre2posix.c @@ -106,7 +106,7 @@ static const int eint1[] = { static const int eint2[] = { 30, REG_ECTYPE, /* unknown POSIX class name */ - 32, REG_INVARG, /* this version of PCRE does not have UTF or UCP support */ + 32, REG_INVARG, /* this version of PCRE2 does not have Unicode support */ 37, REG_EESCAPE, /* PCRE2 does not support \L, \l, \N{name}, \U, or \u */ 56, REG_INVARG, /* internal error: unknown newline setting */ }; diff --git a/src/pcre2test.c b/src/pcre2test.c index f6f13ab..88c61eb 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -667,6 +667,12 @@ table itself easier to read. */ #define EBCDIC_NL 0 #endif +#ifdef NEVER_BACKSLASH_C +#define BACKSLASH_C 0 +#else +#define BACKSLASH_C 1 +#endif + typedef struct coptstruct { const char *name; uint32_t type; @@ -681,16 +687,17 @@ enum { CONF_BSR, }; static coptstruct coptlist[] = { - { "bsr", CONF_BSR, PCRE2_CONFIG_BSR }, - { "ebcdic", CONF_FIX, SUPPORT_EBCDIC }, - { "ebcdic-nl", CONF_FIZ, EBCDIC_NL }, - { "jit", CONF_INT, PCRE2_CONFIG_JIT }, - { "linksize", CONF_INT, PCRE2_CONFIG_LINKSIZE }, - { "newline", CONF_NL, PCRE2_CONFIG_NEWLINE }, - { "pcre2-16", CONF_FIX, SUPPORT_16 }, - { "pcre2-32", CONF_FIX, SUPPORT_32 }, - { "pcre2-8", CONF_FIX, SUPPORT_8 }, - { "unicode", CONF_INT, PCRE2_CONFIG_UNICODE } + { "backslash-C", CONF_FIX, BACKSLASH_C }, + { "bsr", CONF_BSR, PCRE2_CONFIG_BSR }, + { "ebcdic", CONF_FIX, SUPPORT_EBCDIC }, + { "ebcdic-nl", CONF_FIZ, EBCDIC_NL }, + { "jit", CONF_INT, PCRE2_CONFIG_JIT }, + { "linksize", CONF_INT, PCRE2_CONFIG_LINKSIZE }, + { "newline", CONF_NL, PCRE2_CONFIG_NEWLINE }, + { "pcre2-16", CONF_FIX, SUPPORT_16 }, + { "pcre2-32", CONF_FIX, SUPPORT_32 }, + { "pcre2-8", CONF_FIX, SUPPORT_8 }, + { "unicode", CONF_INT, PCRE2_CONFIG_UNICODE } }; #define COPTLISTCOUNT sizeof(coptlist)/sizeof(coptstruct) @@ -6467,6 +6474,7 @@ printf(" -b set default pattern control 'fullbincode'\n"); printf(" -C show PCRE2 compile-time options and exit\n"); printf(" -C arg show a specific compile-time option and exit with its\n"); printf(" value if numeric (else 0). The arg can be:\n"); +printf(" backslash-C use of \\C is enabled [0, 1]\n"); printf(" bsr \\R type [ANYCRLF, ANY]\n"); printf(" ebcdic compiled for EBCDIC character code [0,1]\n"); printf(" ebcdic-nl NL code if compiled for EBCDIC\n"); @@ -6618,6 +6626,11 @@ 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_LINKSIZE, &optval); printf(" Internal link size = %d\n", optval); (void)PCRE2_CONFIG(PCRE2_CONFIG_PARENSLIMIT, &optval); |