summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/pcre/pcre_internal.h
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2013-03-21 19:23:58 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-01 21:33:29 +0200
commitbb5552a22995ba1dbc4f9944e72a6b0e15194fcb (patch)
tree31a94ce99ebdf1a6e32ae30a78001661c70d89d2 /src/3rdparty/pcre/pcre_internal.h
parent34999402898886a969094a39587909ab6764e568 (diff)
Upgrade the bundled PCRE to 8.32
Changelog: http://pcre.org/changelog.txt Amongst other things, the Unicode tables were upgraded to 6.2.0 and case folding support was added, which also fixes a QString autotest (marked as XFAIL). Qt still requires 8.30, not 8.32. Change-Id: I4056c1dc1d949d33443bb8ca280de4c8c363ac74 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty/pcre/pcre_internal.h')
-rw-r--r--src/3rdparty/pcre/pcre_internal.h762
1 files changed, 587 insertions, 175 deletions
diff --git a/src/3rdparty/pcre/pcre_internal.h b/src/3rdparty/pcre/pcre_internal.h
index e5a4b6a526..f3cb001fea 100644
--- a/src/3rdparty/pcre/pcre_internal.h
+++ b/src/3rdparty/pcre/pcre_internal.h
@@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE.
/* This header contains definitions that are shared between the different
modules, but which are not relevant to the exported API. This includes some
-functions whose names all begin with "_pcre_" or "_pcre16_" depending on
-the PRIV macro. */
+functions whose names all begin with "_pcre_", "_pcre16_" or "_pcre32_"
+depending on the PRIV macro. */
#ifndef PCRE_INTERNAL_H
#define PCRE_INTERNAL_H
@@ -53,7 +53,8 @@ the PRIV macro. */
#endif
/* PCRE is compiled as an 8 bit library if it is not requested otherwise. */
-#ifndef COMPILE_PCRE16
+
+#if !defined COMPILE_PCRE16 && !defined COMPILE_PCRE32
#define COMPILE_PCRE8
#endif
@@ -78,11 +79,11 @@ Until then we define it if SUPPORT_UTF is defined. */
#define SUPPORT_UTF8 1
#endif
-/* We do not support both EBCDIC and UTF-8/16 at the same time. The "configure"
+/* We do not support both EBCDIC and UTF-8/16/32 at the same time. The "configure"
script prevents both being selected, but not everybody uses "configure". */
#if defined EBCDIC && defined SUPPORT_UTF
-#error The use of both EBCDIC and SUPPORT_UTF8/16 is not supported.
+#error The use of both EBCDIC and SUPPORT_UTF is not supported.
#endif
/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
@@ -111,6 +112,12 @@ setjmp and stdarg are used is when NO_RECURSE is set. */
#include <stdlib.h>
#include <string.h>
+/* Valgrind (memcheck) support */
+
+#ifdef SUPPORT_VALGRIND
+#include <valgrind/memcheck.h>
+#endif
+
/* When compiling a DLL for Windows, the exported symbols have to be declared
using some MS magic. I found some useful information on this web page:
http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the
@@ -193,7 +200,7 @@ typedef unsigned char pcre_uint8;
typedef unsigned int pcre_uint16;
typedef int pcre_int16;
#else
- #error Cannot determine a type for 16-bit unsigned integers
+# error Cannot determine a type for 16-bit unsigned integers
#endif
#if UINT_MAX == 4294967295
@@ -203,7 +210,7 @@ typedef unsigned char pcre_uint8;
typedef unsigned long int pcre_uint32;
typedef long int pcre_int32;
#else
- #error Cannot determine a type for 32-bit unsigned integers
+# error Cannot determine a type for 32-bit unsigned integers
#endif
/* When checking for integer overflow in pcre_compile(), we need to handle
@@ -214,9 +221,9 @@ stdint.h is available, include it; it may define INT64_MAX. Systems that do not
have stdint.h (e.g. Solaris) may have inttypes.h. The macro int64_t may be set
by "configure". */
-#if HAVE_STDINT_H
+#if defined HAVE_STDINT_H
#include <stdint.h>
-#elif HAVE_INTTYPES_H
+#elif defined HAVE_INTTYPES_H
#include <inttypes.h>
#endif
@@ -243,16 +250,15 @@ exactly 256 items. When the character is able to contain more than 256
items, some check is needed before accessing these tables.
*/
-#ifdef COMPILE_PCRE8
+#if defined COMPILE_PCRE8
typedef unsigned char pcre_uchar;
#define IN_UCHARS(x) (x)
#define MAX_255(c) 1
#define TABLE_GET(c, table, default) ((table)[c])
-#else
+#elif defined COMPILE_PCRE16
-#ifdef COMPILE_PCRE16
#if USHRT_MAX != 65535
/* This is a warning message. Change PCRE_UCHAR16 to a 16 bit data type in
pcre.h(.in) and disable (comment out) this message. */
@@ -260,15 +266,22 @@ pcre.h(.in) and disable (comment out) this message. */
#endif
typedef pcre_uint16 pcre_uchar;
-#define IN_UCHARS(x) ((x) << 1)
+#define UCHAR_SHIFT (1)
+#define IN_UCHARS(x) ((x) << UCHAR_SHIFT)
+#define MAX_255(c) ((c) <= 255u)
+#define TABLE_GET(c, table, default) (MAX_255(c)? ((table)[c]):(default))
+
+#elif defined COMPILE_PCRE32
+
+typedef pcre_uint32 pcre_uchar;
+#define UCHAR_SHIFT (2)
+#define IN_UCHARS(x) ((x) << UCHAR_SHIFT)
#define MAX_255(c) ((c) <= 255u)
#define TABLE_GET(c, table, default) (MAX_255(c)? ((table)[c]):(default))
#else
#error Unsupported compiling mode
-#endif /* COMPILE_PCRE16 */
-
-#endif /* COMPILE_PCRE8 */
+#endif /* COMPILE_PCRE[8|16|32] */
/* This is an unsigned int value that no character can ever have. UTF-8
characters only go up to 0x7fffffff (though Unicode doesn't go beyond
@@ -295,8 +308,8 @@ start/end of string field names are. */
&(NLBLOCK->nllen), utf)) \
: \
((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \
- (p)[0] == NLBLOCK->nl[0] && \
- (NLBLOCK->nllen == 1 || (p)[1] == NLBLOCK->nl[1]) \
+ RAWUCHARTEST(p) == NLBLOCK->nl[0] && \
+ (NLBLOCK->nllen == 1 || RAWUCHARTEST(p+1) == NLBLOCK->nl[1]) \
) \
)
@@ -309,8 +322,8 @@ start/end of string field names are. */
&(NLBLOCK->nllen), utf)) \
: \
((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \
- (p)[-NLBLOCK->nllen] == NLBLOCK->nl[0] && \
- (NLBLOCK->nllen == 1 || (p)[-NLBLOCK->nllen+1] == NLBLOCK->nl[1]) \
+ RAWUCHARTEST(p - NLBLOCK->nllen) == NLBLOCK->nl[0] && \
+ (NLBLOCK->nllen == 1 || RAWUCHARTEST(p - NLBLOCK->nllen + 1) == NLBLOCK->nl[1]) \
) \
)
@@ -335,6 +348,11 @@ values. */
#include "pcre.h"
#include "ucp.h"
+#ifdef COMPILE_PCRE32
+/* Assert that the public PCRE_UCHAR32 is a 32-bit type */
+typedef int __assert_pcre_uchar32_size[sizeof(PCRE_UCHAR32) == 4 ? 1 : -1];
+#endif
+
/* When compiling for use with the Virtual Pascal compiler, these functions
need to have their names changed. PCRE must be compiled with the -DVPCOMPAT
option on the command line. */
@@ -396,7 +414,7 @@ The macros are controlled by the value of LINK_SIZE. This defaults to 2 in
the config.h file, but can be overridden by using -D on the command line. This
is automated on Unix systems via the "configure" command. */
-#ifdef COMPILE_PCRE8
+#if defined COMPILE_PCRE8
#if LINK_SIZE == 2
@@ -441,12 +459,11 @@ is automated on Unix systems via the "configure" command. */
#error LINK_SIZE must be either 2, 3, or 4
#endif
-#else /* COMPILE_PCRE8 */
-
-#ifdef COMPILE_PCRE16
+#elif defined COMPILE_PCRE16
#if LINK_SIZE == 2
+/* Redefine LINK_SIZE as a multiple of sizeof(pcre_uchar) */
#undef LINK_SIZE
#define LINK_SIZE 1
@@ -460,6 +477,7 @@ is automated on Unix systems via the "configure" command. */
#elif LINK_SIZE == 3 || LINK_SIZE == 4
+/* Redefine LINK_SIZE as a multiple of sizeof(pcre_uchar) */
#undef LINK_SIZE
#define LINK_SIZE 2
@@ -477,11 +495,25 @@ is automated on Unix systems via the "configure" command. */
#error LINK_SIZE must be either 2, 3, or 4
#endif
+#elif defined COMPILE_PCRE32
+
+/* Only supported LINK_SIZE is 4 */
+/* Redefine LINK_SIZE as a multiple of sizeof(pcre_uchar) */
+#undef LINK_SIZE
+#define LINK_SIZE 1
+
+#define PUT(a,n,d) \
+ (a[n] = (d))
+
+#define GET(a,n) \
+ (a[n])
+
+/* Keep it positive */
+#define MAX_PATTERN_SIZE (1 << 30)
+
#else
#error Unsupported compiling mode
-#endif /* COMPILE_PCRE16 */
-
-#endif /* COMPILE_PCRE8 */
+#endif /* COMPILE_PCRE[8|16|32] */
/* Convenience macro defined in terms of the others */
@@ -492,7 +524,7 @@ is automated on Unix systems via the "configure" command. */
offsets changes. There are used for repeat counts and for other things such as
capturing parenthesis numbers in back references. */
-#ifdef COMPILE_PCRE8
+#if defined COMPILE_PCRE8
#define IMM2_SIZE 2
@@ -500,12 +532,24 @@ capturing parenthesis numbers in back references. */
a[n] = (d) >> 8; \
a[(n)+1] = (d) & 255
+/* For reasons that I do not understand, the expression in this GET2 macro is
+treated by gcc as a signed expression, even when a is declared as unsigned. It
+seems that any kind of arithmetic results in a signed value. */
+
#define GET2(a,n) \
- (((a)[n] << 8) | (a)[(n)+1])
+ (unsigned int)(((a)[n] << 8) | (a)[(n)+1])
+
+#elif defined COMPILE_PCRE16
+
+#define IMM2_SIZE 1
-#else /* COMPILE_PCRE8 */
+#define PUT2(a,n,d) \
+ a[n] = d
-#ifdef COMPILE_PCRE16
+#define GET2(a,n) \
+ a[n]
+
+#elif defined COMPILE_PCRE32
#define IMM2_SIZE 1
@@ -517,18 +561,25 @@ capturing parenthesis numbers in back references. */
#else
#error Unsupported compiling mode
-#endif /* COMPILE_PCRE16 */
-
-#endif /* COMPILE_PCRE8 */
+#endif /* COMPILE_PCRE[8|16|32] */
#define PUT2INC(a,n,d) PUT2(a,n,d), a += IMM2_SIZE
+/* The maximum length of a MARK name is currently one data unit; it may be
+changed in future to be a fixed number of bytes or to depend on LINK_SIZE. */
+
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+#define MAX_MARK ((1u << 16) - 1)
+#else
+#define MAX_MARK ((1u << 8) - 1)
+#endif
+
/* When UTF encoding is being used, a character is no longer just a single
-character. The macros for character handling generate simple sequences when
-used in character-mode, and more complicated ones for UTF characters.
-GETCHARLENTEST and other macros are not used when UTF is not supported,
-so they are not defined. To make sure they can never even appear when
-UTF support is omitted, we don't even define them. */
+byte. The macros for character handling generate simple sequences when used in
+character-mode, and more complicated ones for UTF characters. GETCHARLENTEST
+and other macros are not used when UTF is not supported, so they are not
+defined. To make sure they can never even appear when UTF support is omitted,
+we don't even define them. */
#ifndef SUPPORT_UTF
@@ -541,6 +592,10 @@ UTF support is omitted, we don't even define them. */
#define GETCHARINC(c, eptr) c = *eptr++;
#define GETCHARINCTEST(c, eptr) c = *eptr++;
#define GETCHARLEN(c, eptr, len) c = *eptr;
+#define RAWUCHAR(eptr) (*(eptr))
+#define RAWUCHARINC(eptr) (*(eptr)++)
+#define RAWUCHARTEST(eptr) (*(eptr))
+#define RAWUCHARINCTEST(eptr) (*(eptr)++)
/* #define GETCHARLENTEST(c, eptr, len) */
/* #define BACKCHAR(eptr) */
/* #define FORWARDCHAR(eptr) */
@@ -548,30 +603,9 @@ UTF support is omitted, we don't even define them. */
#else /* SUPPORT_UTF */
-#ifdef COMPILE_PCRE8
-
-/* These macros were originally written in the form of loops that used data
-from the tables whose names start with PRIV(utf8_table). They were rewritten by
-a user so as not to use loops, because in some environments this gives a
-significant performance advantage, and it seems never to do any harm. */
-
-/* Tells the biggest code point which can be encoded as a single character. */
-
-#define MAX_VALUE_FOR_SINGLE_CHAR 127
-
/* Tests whether the code point needs extra characters to decode. */
-#define HAS_EXTRALEN(c) ((c) >= 0xc0)
-
-/* Returns with the additional number of characters if IS_MULTICHAR(c) is TRUE.
-Otherwise it has an undefined behaviour. */
-
-#define GET_EXTRALEN(c) (PRIV(utf8_table4)[(c) & 0x3f])
-
-/* Returns TRUE, if the given character is not the first character
-of a UTF sequence. */
-
-#define NOT_FIRSTCHAR(c) (((c) & 0xc0) == 0x80)
+#define HASUTF8EXTRALEN(c) ((c) >= 0xc0)
/* Base macro to pick up the remaining bytes of a UTF-8 character, not
advancing the pointer. */
@@ -595,20 +629,6 @@ advancing the pointer. */
((eptr[4] & 0x3f) << 6) | (eptr[5] & 0x3f); \
}
-/* Get the next UTF-8 character, not advancing the pointer. This is called when
-we know we are in UTF-8 mode. */
-
-#define GETCHAR(c, eptr) \
- c = *eptr; \
- if (c >= 0xc0) GETUTF8(c, eptr);
-
-/* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the
-pointer. */
-
-#define GETCHARTEST(c, eptr) \
- c = *eptr; \
- if (utf && c >= 0xc0) GETUTF8(c, eptr);
-
/* Base macro to pick up the remaining bytes of a UTF-8 character, advancing
the pointer. */
@@ -643,6 +663,45 @@ the pointer. */
} \
}
+#if defined COMPILE_PCRE8
+
+/* These macros were originally written in the form of loops that used data
+from the tables whose names start with PRIV(utf8_table). They were rewritten by
+a user so as not to use loops, because in some environments this gives a
+significant performance advantage, and it seems never to do any harm. */
+
+/* Tells the biggest code point which can be encoded as a single character. */
+
+#define MAX_VALUE_FOR_SINGLE_CHAR 127
+
+/* Tests whether the code point needs extra characters to decode. */
+
+#define HAS_EXTRALEN(c) ((c) >= 0xc0)
+
+/* Returns with the additional number of characters if IS_MULTICHAR(c) is TRUE.
+Otherwise it has an undefined behaviour. */
+
+#define GET_EXTRALEN(c) (PRIV(utf8_table4)[(c) & 0x3f])
+
+/* Returns TRUE, if the given character is not the first character
+of a UTF sequence. */
+
+#define NOT_FIRSTCHAR(c) (((c) & 0xc0) == 0x80)
+
+/* Get the next UTF-8 character, not advancing the pointer. This is called when
+we know we are in UTF-8 mode. */
+
+#define GETCHAR(c, eptr) \
+ c = *eptr; \
+ if (c >= 0xc0) GETUTF8(c, eptr);
+
+/* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the
+pointer. */
+
+#define GETCHARTEST(c, eptr) \
+ c = *eptr; \
+ if (utf && c >= 0xc0) GETUTF8(c, eptr);
+
/* Get the next UTF-8 character, advancing the pointer. This is called when we
know we are in UTF-8 mode. */
@@ -709,6 +768,30 @@ do not know if we are in UTF-8 mode. */
c = *eptr; \
if (utf && c >= 0xc0) GETUTF8LEN(c, eptr, len);
+/* Returns the next uchar, not advancing the pointer. This is called when
+we know we are in UTF mode. */
+
+#define RAWUCHAR(eptr) \
+ (*(eptr))
+
+/* Returns the next uchar, advancing the pointer. This is called when
+we know we are in UTF mode. */
+
+#define RAWUCHARINC(eptr) \
+ (*((eptr)++))
+
+/* Returns the next uchar, testing for UTF mode, and not advancing the
+pointer. */
+
+#define RAWUCHARTEST(eptr) \
+ (*(eptr))
+
+/* Returns the next uchar, testing for UTF mode, advancing the
+pointer. */
+
+#define RAWUCHARINCTEST(eptr) \
+ (*((eptr)++))
+
/* If the pointer is not at the start of a character, move it back until
it is. This is called only in UTF-8 mode - we don't put a test within the macro
because almost all calls are already within a block of UTF-8 only code. */
@@ -722,9 +805,7 @@ because almost all calls are already within a block of UTF-8 only code. */
#define ACROSSCHAR(condition, eptr, action) \
while((condition) && ((eptr) & 0xc0) == 0x80) action
-#else /* COMPILE_PCRE8 */
-
-#ifdef COMPILE_PCRE16
+#elif defined COMPILE_PCRE16
/* Tells the biggest code point which can be encoded as a single character. */
@@ -806,6 +887,30 @@ we do not know if we are in UTF-16 mode. */
c = *eptr; \
if (utf && (c & 0xfc00) == 0xd800) GETUTF16LEN(c, eptr, len);
+/* Returns the next uchar, not advancing the pointer. This is called when
+we know we are in UTF mode. */
+
+#define RAWUCHAR(eptr) \
+ (*(eptr))
+
+/* Returns the next uchar, advancing the pointer. This is called when
+we know we are in UTF mode. */
+
+#define RAWUCHARINC(eptr) \
+ (*((eptr)++))
+
+/* Returns the next uchar, testing for UTF mode, and not advancing the
+pointer. */
+
+#define RAWUCHARTEST(eptr) \
+ (*(eptr))
+
+/* Returns the next uchar, testing for UTF mode, advancing the
+pointer. */
+
+#define RAWUCHARINCTEST(eptr) \
+ (*((eptr)++))
+
/* If the pointer is not at the start of a character, move it back until
it is. This is called only in UTF-16 mode - we don't put a test within the
macro because almost all calls are already within a block of UTF-16 only
@@ -820,20 +925,200 @@ code. */
#define ACROSSCHAR(condition, eptr, action) \
if ((condition) && ((eptr) & 0xfc00) == 0xdc00) action
-#endif
+#elif defined COMPILE_PCRE32
-#endif /* COMPILE_PCRE8 */
+/* These are trivial for the 32-bit library, since all UTF-32 characters fit
+into one pcre_uchar unit. */
+#define MAX_VALUE_FOR_SINGLE_CHAR (0x10ffffu)
+#define HAS_EXTRALEN(c) (0)
+#define GET_EXTRALEN(c) (0)
+#define NOT_FIRSTCHAR(c) (0)
+
+/* Get the next UTF-32 character, not advancing the pointer. This is called when
+we know we are in UTF-32 mode. */
+
+#define GETCHAR(c, eptr) \
+ c = *(eptr);
+
+/* Get the next UTF-32 character, testing for UTF-32 mode, and not advancing the
+pointer. */
+
+#define GETCHARTEST(c, eptr) \
+ c = *(eptr);
+
+/* Get the next UTF-32 character, advancing the pointer. This is called when we
+know we are in UTF-32 mode. */
+
+#define GETCHARINC(c, eptr) \
+ c = *((eptr)++);
+
+/* Get the next character, testing for UTF-32 mode, and advancing the pointer.
+This is called when we don't know if we are in UTF-32 mode. */
+
+#define GETCHARINCTEST(c, eptr) \
+ c = *((eptr)++);
+
+/* Get the next UTF-32 character, not advancing the pointer, not incrementing
+length (since all UTF-32 is of length 1). This is called when we know we are in
+UTF-32 mode. */
+
+#define GETCHARLEN(c, eptr, len) \
+ GETCHAR(c, eptr)
+
+/* Get the next UTF-32character, testing for UTF-32 mode, not advancing the
+pointer, not incrementing the length (since all UTF-32 is of length 1).
+This is called when we do not know if we are in UTF-32 mode. */
+
+#define GETCHARLENTEST(c, eptr, len) \
+ GETCHARTEST(c, eptr)
+
+/* Returns the next uchar, not advancing the pointer. This is called when
+we know we are in UTF mode. */
+
+#define RAWUCHAR(eptr) \
+ (*(eptr))
+
+/* Returns the next uchar, advancing the pointer. This is called when
+we know we are in UTF mode. */
+
+#define RAWUCHARINC(eptr) \
+ (*((eptr)++))
+
+/* Returns the next uchar, testing for UTF mode, and not advancing the
+pointer. */
+
+#define RAWUCHARTEST(eptr) \
+ (*(eptr))
+
+/* Returns the next uchar, testing for UTF mode, advancing the
+pointer. */
+
+#define RAWUCHARINCTEST(eptr) \
+ (*((eptr)++))
+
+/* If the pointer is not at the start of a character, move it back until
+it is. This is called only in UTF-32 mode - we don't put a test within the
+macro because almost all calls are already within a block of UTF-32 only
+code.
+These are all no-ops since all UTF-32 characters fit into one pcre_uchar. */
+
+#define BACKCHAR(eptr) do { } while (0)
+
+/* Same as above, just in the other direction. */
+#define FORWARDCHAR(eptr) do { } while (0)
+
+/* Same as above, but it allows a fully customizable form. */
+#define ACROSSCHAR(condition, eptr, action) do { } while (0)
+
+#else
+#error Unsupported compiling mode
+#endif /* COMPILE_PCRE[8|16|32] */
#endif /* SUPPORT_UTF */
+/* Tests for Unicode horizontal and vertical whitespace characters must check a
+number of different values. Using a switch statement for this generates the
+fastest code (no loop, no memory access), and there are several places in the
+interpreter code where this happens. In order to ensure that all the case lists
+remain in step, we use macros so that there is only one place where the lists
+are defined.
+
+These values are also required as lists in pcre_compile.c when processing \h,
+\H, \v and \V in a character class. The lists are defined in pcre_tables.c, but
+macros that define the values are here so that all the definitions are
+together. The lists must be in ascending character order, terminated by
+NOTACHAR (which is 0xffffffff).
+
+Any changes should ensure that the various macros are kept in step with each
+other. NOTE: The values also appear in pcre_jit_compile.c. */
+
+/* ------ ASCII/Unicode environments ------ */
+
+#ifndef EBCDIC
+
+#define HSPACE_LIST \
+ CHAR_HT, CHAR_SPACE, 0xa0, \
+ 0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, \
+ 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202f, 0x205f, 0x3000, \
+ NOTACHAR
+
+#define HSPACE_MULTIBYTE_CASES \
+ case 0x1680: /* OGHAM SPACE MARK */ \
+ case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ \
+ case 0x2000: /* EN QUAD */ \
+ case 0x2001: /* EM QUAD */ \
+ case 0x2002: /* EN SPACE */ \
+ case 0x2003: /* EM SPACE */ \
+ case 0x2004: /* THREE-PER-EM SPACE */ \
+ case 0x2005: /* FOUR-PER-EM SPACE */ \
+ case 0x2006: /* SIX-PER-EM SPACE */ \
+ case 0x2007: /* FIGURE SPACE */ \
+ case 0x2008: /* PUNCTUATION SPACE */ \
+ case 0x2009: /* THIN SPACE */ \
+ case 0x200A: /* HAIR SPACE */ \
+ case 0x202f: /* NARROW NO-BREAK SPACE */ \
+ case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ \
+ case 0x3000 /* IDEOGRAPHIC SPACE */
+
+#define HSPACE_BYTE_CASES \
+ case CHAR_HT: \
+ case CHAR_SPACE: \
+ case 0xa0 /* NBSP */
+
+#define HSPACE_CASES \
+ HSPACE_BYTE_CASES: \
+ HSPACE_MULTIBYTE_CASES
+
+#define VSPACE_LIST \
+ CHAR_LF, CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, 0x2028, 0x2029, NOTACHAR
+
+#define VSPACE_MULTIBYTE_CASES \
+ case 0x2028: /* LINE SEPARATOR */ \
+ case 0x2029 /* PARAGRAPH SEPARATOR */
+
+#define VSPACE_BYTE_CASES \
+ case CHAR_LF: \
+ case CHAR_VT: \
+ case CHAR_FF: \
+ case CHAR_CR: \
+ case CHAR_NEL
+
+#define VSPACE_CASES \
+ VSPACE_BYTE_CASES: \
+ VSPACE_MULTIBYTE_CASES
+
+/* ------ EBCDIC environments ------ */
-/* In case there is no definition of offsetof() provided - though any proper
-Standard C system should have one. */
+#else
+#define HSPACE_LIST CHAR_HT, CHAR_SPACE
+
+#define HSPACE_BYTE_CASES \
+ case CHAR_HT: \
+ case CHAR_SPACE
-#ifndef offsetof
-#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
+#define HSPACE_CASES HSPACE_BYTE_CASES
+
+#ifdef EBCDIC_NL25
+#define VSPACE_LIST \
+ CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, CHAR_LF, NOTACHAR
+#else
+#define VSPACE_LIST \
+ CHAR_VT, CHAR_FF, CHAR_CR, CHAR_LF, CHAR_NEL, NOTACHAR
#endif
+#define VSPACE_BYTE_CASES \
+ case CHAR_LF: \
+ case CHAR_VT: \
+ case CHAR_FF: \
+ case CHAR_CR: \
+ case CHAR_NEL
+
+#define VSPACE_CASES VSPACE_BYTE_CASES
+#endif /* EBCDIC */
+
+/* ------ End of whitespace macros ------ */
+
+
/* Private flags containing information about the compiled regex. They used to
live at the top end of the options word, but that got almost full, so now they
@@ -841,12 +1126,9 @@ are in a 16-bit flags word. From release 8.00, PCRE_NOPARTIAL is unused, as
the restrictions on partial matching have been lifted. It remains for backwards
compatibility. */
-#ifdef COMPILE_PCRE8
-#define PCRE_MODE 0x0001 /* compiled in 8 bit mode */
-#endif
-#ifdef COMPILE_PCRE16
-#define PCRE_MODE 0x0002 /* compiled in 16 bit mode */
-#endif
+#define PCRE_MODE8 0x0001 /* compiled in 8 bit mode */
+#define PCRE_MODE16 0x0002 /* compiled in 16 bit mode */
+#define PCRE_MODE32 0x0004 /* compiled in 32 bit mode */
#define PCRE_FIRSTSET 0x0010 /* first_char is set */
#define PCRE_FCH_CASELESS 0x0020 /* caseless first char */
#define PCRE_REQCHSET 0x0040 /* req_byte is set */
@@ -857,6 +1139,15 @@ compatibility. */
#define PCRE_HASCRORLF 0x0800 /* explicit \r or \n in pattern */
#define PCRE_HASTHEN 0x1000 /* pattern contains (*THEN) */
+#if defined COMPILE_PCRE8
+#define PCRE_MODE PCRE_MODE8
+#elif defined COMPILE_PCRE16
+#define PCRE_MODE PCRE_MODE16
+#elif defined COMPILE_PCRE32
+#define PCRE_MODE PCRE_MODE32
+#endif
+#define PCRE_MODE_MASK (PCRE_MODE8 | PCRE_MODE16 | PCRE_MODE32)
+
/* Flags for the "extra" block produced by pcre_study(). */
#define PCRE_STUDY_MAPPED 0x0001 /* a map of starting chars exists */
@@ -887,7 +1178,12 @@ time, run time, or study time, respectively. */
PCRE_NO_START_OPTIMIZE)
#define PUBLIC_STUDY_OPTIONS \
- PCRE_STUDY_JIT_COMPILE
+ (PCRE_STUDY_JIT_COMPILE|PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE| \
+ PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE|PCRE_STUDY_EXTRA_NEEDED)
+
+#define PUBLIC_JIT_EXEC_OPTIONS \
+ (PCRE_NO_UTF8_CHECK|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|\
+ PCRE_NOTEMPTY_ATSTART|PCRE_PARTIAL_SOFT|PCRE_PARTIAL_HARD)
/* Magic number to provide a small check against being handed junk. */
@@ -898,11 +1194,6 @@ in different endianness. */
#define REVERSED_MAGIC_NUMBER 0x45524350UL /* 'ERCP' */
-/* Negative values for the firstchar and reqchar variables */
-
-#define REQ_UNSET (-2)
-#define REQ_NONE (-1)
-
/* The maximum remaining length of subject we are prepared to search for a
req_byte match. */
@@ -939,22 +1230,71 @@ macros to give the functions distinct names. */
#ifndef SUPPORT_UTF
/* UTF-8 support is not enabled; use the platform-dependent character literals
-so that PCRE works on both ASCII and EBCDIC platforms, in non-UTF-mode only. */
+so that PCRE works in both ASCII and EBCDIC environments, but only in non-UTF
+mode. Newline characters are problematic in EBCDIC. Though it has CR and LF
+characters, a common practice has been to use its NL (0x15) character as the
+line terminator in C-like processing environments. However, sometimes the LF
+(0x25) character is used instead, according to this Unicode document:
+
+http://unicode.org/standard/reports/tr13/tr13-5.html
+
+PCRE defaults EBCDIC NL to 0x15, but has a build-time option to select 0x25
+instead. Whichever is *not* chosen is defined as NEL.
+
+In both ASCII and EBCDIC environments, CHAR_NL and CHAR_LF are synonyms for the
+same code point. */
+
+#ifdef EBCDIC
+
+#ifndef EBCDIC_NL25
+#define CHAR_NL '\x15'
+#define CHAR_NEL '\x25'
+#define STR_NL "\x15"
+#define STR_NEL "\x25"
+#else
+#define CHAR_NL '\x25'
+#define CHAR_NEL '\x15'
+#define STR_NL "\x25"
+#define STR_NEL "\x15"
+#endif
+
+#define CHAR_LF CHAR_NL
+#define STR_LF STR_NL
+
+#define CHAR_ESC '\047'
+#define CHAR_DEL '\007'
+#define STR_ESC "\047"
+#define STR_DEL "\007"
+#else /* Not EBCDIC */
+
+/* In ASCII/Unicode, linefeed is '\n' and we equate this to NL for
+compatibility. NEL is the Unicode newline character; make sure it is
+a positive value. */
+
+#define CHAR_LF '\n'
+#define CHAR_NL CHAR_LF
+#define CHAR_NEL ((unsigned char)'\x85')
+#define CHAR_ESC '\033'
+#define CHAR_DEL '\177'
+
+#define STR_LF "\n"
+#define STR_NL STR_LF
+#define STR_NEL "\x85"
+#define STR_ESC "\033"
+#define STR_DEL "\177"
+
+#endif /* EBCDIC */
+
+/* The remaining definitions work in both environments. */
+
+#define CHAR_NULL '\0'
#define CHAR_HT '\t'
#define CHAR_VT '\v'
#define CHAR_FF '\f'
#define CHAR_CR '\r'
-#define CHAR_NL '\n'
#define CHAR_BS '\b'
#define CHAR_BEL '\a'
-#ifdef EBCDIC
-#define CHAR_ESC '\047'
-#define CHAR_DEL '\007'
-#else
-#define CHAR_ESC '\033'
-#define CHAR_DEL '\177'
-#endif
#define CHAR_SPACE ' '
#define CHAR_EXCLAMATION_MARK '!'
@@ -1056,16 +1396,8 @@ so that PCRE works on both ASCII and EBCDIC platforms, in non-UTF-mode only. */
#define STR_VT "\v"
#define STR_FF "\f"
#define STR_CR "\r"
-#define STR_NL "\n"
#define STR_BS "\b"
#define STR_BEL "\a"
-#ifdef EBCDIC
-#define STR_ESC "\047"
-#define STR_DEL "\007"
-#else
-#define STR_ESC "\033"
-#define STR_DEL "\177"
-#endif
#define STR_SPACE " "
#define STR_EXCLAMATION_MARK "!"
@@ -1196,12 +1528,10 @@ so that PCRE works on both ASCII and EBCDIC platforms, in non-UTF-mode only. */
#define STRING_ANYCRLF_RIGHTPAR "ANYCRLF)"
#define STRING_BSR_ANYCRLF_RIGHTPAR "BSR_ANYCRLF)"
#define STRING_BSR_UNICODE_RIGHTPAR "BSR_UNICODE)"
-#ifdef COMPILE_PCRE8
-#define STRING_UTF_RIGHTPAR "UTF8)"
-#endif
-#ifdef COMPILE_PCRE16
-#define STRING_UTF_RIGHTPAR "UTF16)"
-#endif
+#define STRING_UTF8_RIGHTPAR "UTF8)"
+#define STRING_UTF16_RIGHTPAR "UTF16)"
+#define STRING_UTF32_RIGHTPAR "UTF32)"
+#define STRING_UTF_RIGHTPAR "UTF)"
#define STRING_UCP_RIGHTPAR "UCP)"
#define STRING_NO_START_OPT_RIGHTPAR "NO_START_OPT)"
@@ -1215,12 +1545,15 @@ only. */
#define CHAR_VT '\013'
#define CHAR_FF '\014'
#define CHAR_CR '\015'
-#define CHAR_NL '\012'
+#define CHAR_LF '\012'
+#define CHAR_NL CHAR_LF
+#define CHAR_NEL ((unsigned char)'\x85')
#define CHAR_BS '\010'
#define CHAR_BEL '\007'
#define CHAR_ESC '\033'
#define CHAR_DEL '\177'
+#define CHAR_NULL '\0'
#define CHAR_SPACE '\040'
#define CHAR_EXCLAMATION_MARK '\041'
#define CHAR_QUOTATION_MARK '\042'
@@ -1456,12 +1789,10 @@ only. */
#define STRING_ANYCRLF_RIGHTPAR STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
#define STRING_BSR_ANYCRLF_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
#define STRING_BSR_UNICODE_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_U STR_N STR_I STR_C STR_O STR_D STR_E STR_RIGHT_PARENTHESIS
-#ifdef COMPILE_PCRE8
-#define STRING_UTF_RIGHTPAR STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS
-#endif
-#ifdef COMPILE_PCRE16
-#define STRING_UTF_RIGHTPAR STR_U STR_T STR_F STR_1 STR_6 STR_RIGHT_PARENTHESIS
-#endif
+#define STRING_UTF8_RIGHTPAR STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS
+#define STRING_UTF16_RIGHTPAR STR_U STR_T STR_F STR_1 STR_6 STR_RIGHT_PARENTHESIS
+#define STRING_UTF32_RIGHTPAR STR_U STR_T STR_F STR_3 STR_2 STR_RIGHT_PARENTHESIS
+#define STRING_UTF_RIGHTPAR STR_U STR_T STR_F STR_RIGHT_PARENTHESIS
#define STRING_UCP_RIGHTPAR STR_U STR_C STR_P STR_RIGHT_PARENTHESIS
#define STRING_NO_START_OPT_RIGHTPAR STR_N STR_O STR_UNDERSCORE STR_S STR_T STR_A STR_R STR_T STR_UNDERSCORE STR_O STR_P STR_T STR_RIGHT_PARENTHESIS
@@ -1478,7 +1809,7 @@ only. */
#endif
#ifndef ESC_n
-#define ESC_n CHAR_NL
+#define ESC_n CHAR_LF
#endif
#ifndef ESC_r
@@ -1503,6 +1834,7 @@ only. */
#define PT_SPACE 6 /* Perl space - Z plus 9,10,12,13 */
#define PT_PXSPACE 7 /* POSIX space - Z plus 9,10,11,12,13 */
#define PT_WORD 8 /* Word - L plus N plus underscore */
+#define PT_CLIST 9 /* Pseudo-property: match character list */
/* Flag bits and data types for the extended class (OP_XCLASS) for classes that
contain characters with values greater than 255. */
@@ -1518,19 +1850,19 @@ contain characters with values greater than 255. */
/* These are escaped items that aren't just an encoding of a particular data
value such as \n. They must have non-zero values, as check_escape() returns
-their negation. Also, they must appear in the same order as in the opcode
+0 for a data character. Also, they must appear in the same order as in the opcode
definitions below, up to ESC_z. There's a dummy for OP_ALLANY because it
corresponds to "." in DOTALL mode rather than an escape sequence. It is also
used for [^] in JavaScript compatibility mode, and for \C in non-utf mode. In
non-DOTALL mode, "." behaves like \N.
The special values ESC_DU, ESC_du, etc. are used instead of ESC_D, ESC_d, etc.
-when PCRE_UCP is set, when replacement of \d etc by \p sequences is required.
+when PCRE_UCP is set and replacement of \d etc by \p sequences is required.
They must be contiguous, and remain in order so that the replacements can be
looked up from a table.
-The final escape must be ESC_REF as subsequent values are used for
-backreferences (\1, \2, \3, etc). There are two tests in the code for an escape
+Negative numbers are used to encode a backreference (\1, \2, \3, etc.) in
+check_escape(). There are two tests in the code for an escape
greater than ESC_b and less than ESC_Z to detect the types that may be
repeated. These are the types that consume characters. If any new escapes are
put in between that don't consume a character, that code will have to change.
@@ -1540,8 +1872,7 @@ enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
ESC_W, ESC_w, ESC_N, ESC_dum, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,
ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z,
ESC_E, ESC_Q, ESC_g, ESC_k,
- ESC_DU, ESC_du, ESC_SU, ESC_su, ESC_WU, ESC_wu,
- ESC_REF };
+ ESC_DU, ESC_du, ESC_SU, ESC_su, ESC_WU, ESC_wu };
/* Opcode table: Starting from 1 (i.e. after OP_END), the values up to
OP_EOD must correspond in order to the list of escapes immediately above.
@@ -1567,7 +1898,7 @@ enum {
OP_NOT_WORDCHAR, /* 10 \W */
OP_WORDCHAR, /* 11 \w */
- OP_ANY, /* 12 Match any character except newline */
+ OP_ANY, /* 12 Match any character except newline (\N) */
OP_ALLANY, /* 13 Match any character */
OP_ANYBYTE, /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */
OP_NOTPROP, /* 15 \P (not Unicode property) */
@@ -1578,8 +1909,8 @@ enum {
OP_NOT_VSPACE, /* 20 \V (not vertical whitespace) */
OP_VSPACE, /* 21 \v (vertical whitespace) */
OP_EXTUNI, /* 22 \X (extended Unicode sequence */
- OP_EODN, /* 23 End of data or \n at end of data: \Z. */
- OP_EOD, /* 24 End of data: \z */
+ OP_EODN, /* 23 End of data or \n at end of data (\Z) */
+ OP_EOD, /* 24 End of data (\z) */
OP_CIRC, /* 25 Start of line - not multiline */
OP_CIRCM, /* 26 Start of line - multiline */
@@ -1939,7 +2270,11 @@ enum { ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9,
ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69,
- ERR70, ERR71, ERR72, ERR73, ERR74, ERRCOUNT };
+ ERR70, ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERRCOUNT };
+
+/* JIT compiling modes. The function list is indexed by them. */
+enum { JIT_COMPILE, JIT_PARTIAL_SOFT_COMPILE, JIT_PARTIAL_HARD_COMPILE,
+ JIT_NUMBER_OF_COMPILE_MODES };
/* The real format of the start of the pcre block; the index of names and the
code vector run on as long as necessary after the end. We store an explicit
@@ -1958,30 +2293,71 @@ fields are present. Currently PCRE always sets the dummy fields to zero.
NOTE NOTE NOTE
*/
-#ifdef COMPILE_PCRE8
+#if defined COMPILE_PCRE8
#define REAL_PCRE real_pcre
-#else
+#elif defined COMPILE_PCRE16
#define REAL_PCRE real_pcre16
+#elif defined COMPILE_PCRE32
+#define REAL_PCRE real_pcre32
#endif
-typedef struct REAL_PCRE {
+/* It is necessary to fork the struct for 32 bit, since it needs to use
+ * pcre_uchar for first_char and req_char. Can't put an ifdef inside the
+ * typedef since pcretest needs access to the struct of the 8-, 16-
+ * and 32-bit variants. */
+
+typedef struct real_pcre8_or_16 {
pcre_uint32 magic_number;
pcre_uint32 size; /* Total that was malloced */
pcre_uint32 options; /* Public options */
pcre_uint16 flags; /* Private flags */
- pcre_uint16 dummy1; /* For future use */
- pcre_uint16 top_bracket;
- pcre_uint16 top_backref;
+ pcre_uint16 max_lookbehind; /* Longest lookbehind (characters) */
+ pcre_uint16 top_bracket; /* Highest numbered group */
+ pcre_uint16 top_backref; /* Highest numbered back reference */
pcre_uint16 first_char; /* Starting character */
pcre_uint16 req_char; /* This character must be seen */
pcre_uint16 name_table_offset; /* Offset to name table that follows */
pcre_uint16 name_entry_size; /* Size of any name items */
pcre_uint16 name_count; /* Number of name items */
pcre_uint16 ref_count; /* Reference count */
-
const pcre_uint8 *tables; /* Pointer to tables or NULL for std */
const pcre_uint8 *nullpad; /* NULL padding */
-} REAL_PCRE;
+} real_pcre8_or_16;
+
+typedef struct real_pcre8_or_16 real_pcre;
+typedef struct real_pcre8_or_16 real_pcre16;
+
+typedef struct real_pcre32 {
+ pcre_uint32 magic_number;
+ pcre_uint32 size; /* Total that was malloced */
+ pcre_uint32 options; /* Public options */
+ pcre_uint16 flags; /* Private flags */
+ pcre_uint16 max_lookbehind; /* Longest lookbehind (characters) */
+ pcre_uint16 top_bracket; /* Highest numbered group */
+ pcre_uint16 top_backref; /* Highest numbered back reference */
+ pcre_uint32 first_char; /* Starting character */
+ pcre_uint32 req_char; /* This character must be seen */
+ pcre_uint16 name_table_offset; /* Offset to name table that follows */
+ pcre_uint16 name_entry_size; /* Size of any name items */
+ pcre_uint16 name_count; /* Number of name items */
+ pcre_uint16 ref_count; /* Reference count */
+ pcre_uint16 dummy1; /* for later expansion */
+ pcre_uint16 dummy2; /* for later expansion */
+ const pcre_uint8 *tables; /* Pointer to tables or NULL for std */
+ void *nullpad; /* for later expansion */
+} real_pcre32;
+
+/* Assert that the size of REAL_PCRE is divisible by 8 */
+typedef int __assert_real_pcre_size_divisible_8[(sizeof(REAL_PCRE) % 8) == 0 ? 1 : -1];
+
+/* Needed in pcretest to access some fields in the real_pcre* structures
+ * directly. They're unified for 8/16/32 bits since the structs only differ
+ * after these fields; if that ever changes, need to fork those defines into
+ * 8/16 and 32 bit versions. */
+#define REAL_PCRE_MAGIC(re) (((REAL_PCRE*)re)->magic_number)
+#define REAL_PCRE_SIZE(re) (((REAL_PCRE*)re)->size)
+#define REAL_PCRE_OPTIONS(re) (((REAL_PCRE*)re)->options)
+#define REAL_PCRE_FLAGS(re) (((REAL_PCRE*)re)->flags)
/* The format of the block used to store data from pcre_study(). The same
remark (see NOTE above) about extending this structure applies. */
@@ -2022,8 +2398,9 @@ typedef struct compile_data {
int names_found; /* Number of entries so far */
int name_entry_size; /* Size of each entry */
int workspace_size; /* Size of workspace */
- int bracount; /* Count of capturing parens as we compile */
+ unsigned int bracount; /* Count of capturing parens as we compile */
int final_bracount; /* Saved value after first pass */
+ int max_lookbehind; /* Maximum lookbehind (characters) */
int top_backref; /* Maximum back reference */
unsigned int backref_map; /* Bitmap of low back refs */
int assert_depth; /* Depth of nested assertions */
@@ -2031,6 +2408,7 @@ typedef struct compile_data {
int external_flags; /* External flag bits to be set */
int req_varyopt; /* "After variable item" flag for reqbyte */
BOOL had_accept; /* (*ACCEPT) encountered */
+ BOOL had_pruneorskip; /* (*PRUNE) or (*SKIP) encountered */
BOOL check_lookbehind; /* Lookbehinds need later checking */
int nltype; /* Newline type */
int nllen; /* Newline string length */
@@ -2050,7 +2428,7 @@ call within the pattern; used by pcre_exec(). */
typedef struct recursion_info {
struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
- int group_num; /* Number of group that was called */
+ unsigned int group_num; /* Number of group that was called */
int *offset_save; /* Pointer to start of saved offsets */
int saved_max; /* Number of saved offsets */
PCRE_PUCHAR subject_position; /* Position at start of recursion */
@@ -2125,6 +2503,9 @@ typedef struct match_data {
const pcre_uchar *mark; /* Mark pointer to pass back on success */
const pcre_uchar *nomatch_mark;/* Mark pointer to pass back on failure */
const pcre_uchar *once_target; /* Where to back up to for atomic groups */
+#ifdef NO_RECURSE
+ void *match_frames_base; /* For remembering malloc'd frames */
+#endif
} match_data;
/* A similar structure is used for the same purpose by the DFA matching
@@ -2179,27 +2560,32 @@ total length. */
#define ctypes_offset (cbits_offset + cbit_length)
#define tables_length (ctypes_offset + 256)
-/* Internal function prefix */
+/* Internal function and data prefixes. */
-#ifdef COMPILE_PCRE8
+#if defined COMPILE_PCRE8
#ifndef PUBL
#define PUBL(name) pcre_##name
#endif
#ifndef PRIV
#define PRIV(name) _pcre_##name
#endif
-#else /* COMPILE_PCRE8 */
-#ifdef COMPILE_PCRE16
+#elif defined COMPILE_PCRE16
#ifndef PUBL
#define PUBL(name) pcre16_##name
#endif
#ifndef PRIV
#define PRIV(name) _pcre16_##name
#endif
+#elif defined COMPILE_PCRE32
+#ifndef PUBL
+#define PUBL(name) pcre32_##name
+#endif
+#ifndef PRIV
+#define PRIV(name) _pcre32_##name
+#endif
#else
#error Unsupported compiling mode
-#endif /* COMPILE_PCRE16 */
-#endif /* COMPILE_PCRE8 */
+#endif /* COMPILE_PCRE[8|16|32] */
/* Layout of the UCP type table that translates property names into types and
codes. Each entry used to point directly to a name, but to reduce the number of
@@ -2219,22 +2605,22 @@ but are not part of the PCRE public API. The data for these tables is in the
pcre_tables.c module. */
#ifdef COMPILE_PCRE8
-
extern const int PRIV(utf8_table1)[];
extern const int PRIV(utf8_table1_size);
extern const int PRIV(utf8_table2)[];
extern const int PRIV(utf8_table3)[];
extern const pcre_uint8 PRIV(utf8_table4)[];
-
#endif /* COMPILE_PCRE8 */
extern const char PRIV(utt_names)[];
extern const ucp_type_table PRIV(utt)[];
extern const int PRIV(utt_size);
+extern const pcre_uint8 PRIV(OP_lengths)[];
extern const pcre_uint8 PRIV(default_tables)[];
-extern const pcre_uint8 PRIV(OP_lengths)[];
+extern const pcre_uint32 PRIV(hspace_list)[];
+extern const pcre_uint32 PRIV(vspace_list)[];
/* Internal shared functions. These are functions that are used by more than
@@ -2242,7 +2628,7 @@ one of the exported public functions. They have to be "external" in the C
sense, but are not part of the PCRE public API. */
/* String comparison functions. */
-#ifdef COMPILE_PCRE8
+#if defined COMPILE_PCRE8
#define STRCMP_UC_UC(str1, str2) \
strcmp((char *)(str1), (char *)(str2))
@@ -2254,7 +2640,7 @@ sense, but are not part of the PCRE public API. */
strncmp((char *)(str1), (str2), (num))
#define STRLEN_UC(str) strlen((const char *)str)
-#else
+#elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
extern int PRIV(strcmp_uc_uc)(const pcre_uchar *,
const pcre_uchar *);
@@ -2276,21 +2662,41 @@ extern unsigned int PRIV(strlen_uc)(const pcre_uchar *str);
PRIV(strncmp_uc_c8)((str1), (str2), (num))
#define STRLEN_UC(str) PRIV(strlen_uc)(str)
-#endif /* COMPILE_PCRE8 */
+#endif /* COMPILE_PCRE[8|16|32] */
+
+#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
+
+#define STRCMP_UC_UC_TEST(str1, str2) STRCMP_UC_UC(str1, str2)
+#define STRCMP_UC_C8_TEST(str1, str2) STRCMP_UC_C8(str1, str2)
+
+#elif defined COMPILE_PCRE32
+
+extern int PRIV(strcmp_uc_uc_utf)(const pcre_uchar *,
+ const pcre_uchar *);
+extern int PRIV(strcmp_uc_c8_utf)(const pcre_uchar *,
+ const char *);
+
+#define STRCMP_UC_UC_TEST(str1, str2) \
+ (utf ? PRIV(strcmp_uc_uc_utf)((str1), (str2)) : PRIV(strcmp_uc_uc)((str1), (str2)))
+#define STRCMP_UC_C8_TEST(str1, str2) \
+ (utf ? PRIV(strcmp_uc_c8_utf)((str1), (str2)) : PRIV(strcmp_uc_c8)((str1), (str2)))
+
+#endif /* COMPILE_PCRE[8|16|32] */
extern const pcre_uchar *PRIV(find_bracket)(const pcre_uchar *, BOOL, int);
extern BOOL PRIV(is_newline)(PCRE_PUCHAR, int, PCRE_PUCHAR,
int *, BOOL);
-extern int PRIV(ord2utf)(pcre_uint32, pcre_uchar *);
+extern unsigned int PRIV(ord2utf)(pcre_uint32, pcre_uchar *);
extern int PRIV(valid_utf)(PCRE_PUCHAR, int, int *);
extern BOOL PRIV(was_newline)(PCRE_PUCHAR, int, PCRE_PUCHAR,
int *, BOOL);
-extern BOOL PRIV(xclass)(int, const pcre_uchar *, BOOL);
+extern BOOL PRIV(xclass)(pcre_uint32, const pcre_uchar *, BOOL);
#ifdef SUPPORT_JIT
-extern void PRIV(jit_compile)(const REAL_PCRE *, PUBL(extra) *);
-extern int PRIV(jit_exec)(const REAL_PCRE *, void *,
- const pcre_uchar *, int, int, int, int, int *, int);
+extern void PRIV(jit_compile)(const REAL_PCRE *,
+ PUBL(extra) *, int);
+extern int PRIV(jit_exec)(const PUBL(extra) *,
+ const pcre_uchar *, int, int, int, int *, int);
extern void PRIV(jit_free)(void *);
extern int PRIV(jit_get_size)(void *);
extern const char* PRIV(jit_get_target)(void);
@@ -2299,15 +2705,19 @@ extern const char* PRIV(jit_get_target)(void);
/* Unicode character database (UCD) */
typedef struct {
- pcre_uint8 script;
- pcre_uint8 chartype;
- pcre_int32 other_case;
+ pcre_uint8 script; /* ucp_Arabic, etc. */
+ pcre_uint8 chartype; /* ucp_Cc, etc. (general categories) */
+ pcre_uint8 gbprop; /* ucp_gbControl, etc. (grapheme break property) */
+ pcre_uint8 caseset; /* offset to multichar other cases or zero */
+ pcre_int32 other_case; /* offset to other case, or zero if none */
} ucd_record;
+extern const pcre_uint32 PRIV(ucd_caseless_sets)[];
extern const ucd_record PRIV(ucd_records)[];
extern const pcre_uint8 PRIV(ucd_stage1)[];
extern const pcre_uint16 PRIV(ucd_stage2)[];
-extern const int PRIV(ucp_gentype)[];
+extern const pcre_uint32 PRIV(ucp_gentype)[];
+extern const pcre_uint32 PRIV(ucp_gbtable)[];
#ifdef SUPPORT_JIT
extern const int PRIV(ucp_typerange)[];
#endif
@@ -2317,13 +2727,15 @@ extern const int PRIV(ucp_typerange)[];
#define UCD_BLOCK_SIZE 128
#define GET_UCD(ch) (PRIV(ucd_records) + \
- PRIV(ucd_stage2)[PRIV(ucd_stage1)[(ch) / UCD_BLOCK_SIZE] * \
- UCD_BLOCK_SIZE + (ch) % UCD_BLOCK_SIZE])
-
-#define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype
-#define UCD_SCRIPT(ch) GET_UCD(ch)->script
-#define UCD_CATEGORY(ch) PRIV(ucp_gentype)[UCD_CHARTYPE(ch)]
-#define UCD_OTHERCASE(ch) (ch + GET_UCD(ch)->other_case)
+ PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \
+ UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE])
+
+#define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype
+#define UCD_SCRIPT(ch) GET_UCD(ch)->script
+#define UCD_CATEGORY(ch) PRIV(ucp_gentype)[UCD_CHARTYPE(ch)]
+#define UCD_GRAPHBREAK(ch) GET_UCD(ch)->gbprop
+#define UCD_CASESET(ch) GET_UCD(ch)->caseset
+#define UCD_OTHERCASE(ch) ((pcre_uint32)((int)ch + (int)(GET_UCD(ch)->other_case)))
#endif /* SUPPORT_UCP */