Revision: 784
http://www.exim.org/viewvc/pcre2?view=rev&revision=784
Author: ph10
Date: 2017-05-16 13:42:17 +0100 (Tue, 16 May 2017)
Log Message:
-----------
Get rid of literal strings in conversion functions.
Modified Paths:
--------------
code/trunk/src/pcre2_convert.c
Modified: code/trunk/src/pcre2_convert.c
===================================================================
--- code/trunk/src/pcre2_convert.c 2017-05-16 07:14:11 UTC (rev 783)
+++ code/trunk/src/pcre2_convert.c 2017-05-16 12:42:17 UTC (rev 784)
@@ -86,10 +86,25 @@
*p++ = *s; \
} \
}
+
+/* Literals that must be escaped: \ ? * + | . ^ $ { } [ ] ( ) */
-static const char *pcre2_escaped_literals = "\\{}?*+[]()|.^$";
+static const char *pcre2_escaped_literals =
+ STR_BACKSLASH STR_QUESTION_MARK STR_ASTERISK STR_PLUS
+ STR_VERTICAL_LINE STR_DOT STR_CIRCUMFLEX_ACCENT STR_DOLLAR_SIGN
+ STR_LEFT_CURLY_BRACKET STR_RIGHT_CURLY_BRACKET
+ STR_LEFT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET
+ STR_LEFT_PARENTHESIS STR_RIGHT_PARENTHESIS;
+
+/* Recognized escapes in POSIX basic patterns. */
+static const char *posix_basic_escapes =
+ STR_QUESTION_MARK STR_PLUS STR_VERTICAL_LINE
+ STR_LEFT_PARENTHESIS STR_RIGHT_PARENTHESIS
+ STR_0 STR_1 STR_2 STR_3 STR_4 STR_5 STR_6 STR_7 STR_8 STR_9;
+
+
/*************************************************
* Convert a POSIX pattern *
*************************************************/
@@ -263,7 +278,8 @@
case CHAR_BACKSLASH:
if (plength <= 0) return ERROR_END_BACKSLASH;
- if (!extended && *posix < 127 && strchr("?+|()0123456789", *posix) != NULL)
+ if (!extended && *posix < 127 &&
+ strchr(posix_basic_escapes, *posix) != NULL)
{
if (isdigit(*posix)) PUTCHARS(STR_BACKSLASH);
if (p + 1 > endp) return PCRE2_ERROR_NOMEMORY;