summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2009-03-17 21:16:01 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2009-03-17 21:16:01 +0000
commitf6cacbfecd16ac9d19ee6fe6c26c107ee4846b1c (patch)
treefb3166c26b8f211814f8302719f5bd93842aa575
parent8d719b57aa95b8a2baebd8fd13c6b80c2da84680 (diff)
downloadpcre-f6cacbfecd16ac9d19ee6fe6c26c107ee4846b1c.tar.gz
Add support for UTF-8 in EBCDIC environments.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@391 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog4
-rw-r--r--README19
-rw-r--r--configure.ac22
-rw-r--r--doc/pcreapi.38
-rw-r--r--doc/pcrebuild.319
-rwxr-xr-xmaint/GenerateUtt.py24
-rw-r--r--pcre_compile.c570
-rw-r--r--pcre_dfa_exec.c14
-rw-r--r--pcre_exec.c14
-rw-r--r--pcre_internal.h547
-rw-r--r--pcre_printint.src6
-rw-r--r--pcre_tables.c364
-rw-r--r--pcregrep.c14
-rw-r--r--pcretest.c14
14 files changed, 1216 insertions, 423 deletions
diff --git a/ChangeLog b/ChangeLog
index b02b213..74df514 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -59,6 +59,10 @@ Version 7.9 xx-xxx-09
16. Added comments and documentation about mis-use of no_arg in the C++
wrapper.
+
+17. Implemented support for UTF-8 encoding in EBCDIC environments, a patch
+ from Martin Jerabek that uses macro names for all relevant character and
+ string constants.
Version 7.8 05-Sep-08
diff --git a/README b/README
index e149bf4..10f73d7 100644
--- a/README
+++ b/README
@@ -161,10 +161,13 @@ library. You can read more about them in the pcrebuild man page.
it will try to find a C++ compiler and C++ header files, and if it succeeds,
it will try to build the C++ wrapper.
-. If you want to make use of the support for UTF-8 character strings in PCRE,
- you must add --enable-utf8 to the "configure" command. Without it, the code
- for handling UTF-8 is not included in the library. (Even when included, it
- still has to be enabled by an option at run time.)
+. If you want to make use of the support for UTF-8 Unicode character strings in
+ PCRE, you must add --enable-utf8 to the "configure" command. Without it, the
+ code for handling UTF-8 is not included in the library. Even when included,
+ it still has to be enabled by an option at run time. When PCRE is compiled
+ with this option, its input can only either be ASCII or UTF-8, even when
+ running on EBCDIC platforms. It is not possible to use both --enable-utf8 and
+ --enable-ebcdic at the same time.
. If, in addition to support for UTF-8 character strings, you want to include
support for the \P, \p, and \X sequences that recognize Unicode character
@@ -255,11 +258,13 @@ library. You can read more about them in the pcrebuild man page.
pcre_chartables.c.dist. See "Character tables" below for further information.
. It is possible to compile PCRE for use on systems that use EBCDIC as their
- default character code (as opposed to ASCII) by specifying
+ character code (as opposed to ASCII) by specifying
--enable-ebcdic
- This automatically implies --enable-rebuild-chartables (see above).
+ This automatically implies --enable-rebuild-chartables (see above). However,
+ when PCRE is built this way, it always operates in EBCDIC. It cannot support
+ both EBCDIC and UTF-8.
. It is possible to compile pcregrep to use libz and/or libbz2, in order to
read .gz and .bz2 files (respectively), by specifying one or both of
@@ -755,4 +760,4 @@ The distribution should contain the following files:
Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
-Last updated: 27 February 2009
+Last updated: 17 March 2009
diff --git a/configure.ac b/configure.ac
index f5dabf0..7b7c46f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,7 +102,7 @@ AC_ARG_ENABLE(rebuild-chartables,
# Handle --enable-utf8 (disabled by default)
AC_ARG_ENABLE(utf8,
AS_HELP_STRING([--enable-utf8],
- [enable UTF-8 support]),
+ [enable UTF-8 support (incompatible with --enable-ebcdic)]),
, enable_utf8=unset)
# Handle --enable-unicode-properties
@@ -150,7 +150,7 @@ AC_ARG_ENABLE(bsr-anycrlf,
# Handle --enable-ebcdic
AC_ARG_ENABLE(ebcdic,
AS_HELP_STRING([--enable-ebcdic],
- [assume EBCDIC coding rather than ASCII; use this only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
+ [assume EBCDIC coding rather than ASCII; incompatible with --enable-utf8; use only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
, enable_ebcdic=no)
# Handle --disable-stack-for-recursion
@@ -226,10 +226,17 @@ then
fi
# Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled.
+# Also check that UTF-8 support is not requested, because PCRE cannot handle
+# EBCDIC and UTF-8 in the same build. To do so it would need to use different
+# character constants depending on the mode.
#
if test "x$enable_ebcdic" = "xyes"
then
enable_rebuild_chartables=yes
+ if test "x$enable_utf8" = "xyes"
+ then
+ AC_MSG_ERROR([support for EBCDIC and UTF-8 cannot be enabled at the same time])
+ fi
fi
# Convert the newline identifier into the appropriate integer value.
@@ -381,7 +388,10 @@ fi
if test "$enable_utf8" = "yes"; then
AC_DEFINE([SUPPORT_UTF8], [], [
- Define to enable support for the UTF-8 Unicode encoding.])
+ Define to enable support for the UTF-8 Unicode encoding. This will
+ work even in an EBCDIC environment, but it is incompatible with
+ the EBCDIC macro. That is, PCRE can support *either* EBCDIC code
+ *or* ASCII/UTF-8, but not both at once.])
fi
if test "$enable_unicode_properties" = "yes"; then
@@ -502,7 +512,11 @@ if test "$enable_ebcdic" = "yes"; then
AC_DEFINE_UNQUOTED([EBCDIC], [], [
If you are compiling for a system that uses EBCDIC instead of ASCII
character codes, define this macro as 1. On systems that can use
- "configure", this can be done via --enable-ebcdic.])
+ "configure", this can be done via --enable-ebcdic. PCRE will then
+ assume that all input strings are in EBCDIC. If you do not define
+ this macro, PCRE will assume input strings are ASCII or UTF-8 Unicode.
+ It is not possible to build a version of PCRE that supports both
+ EBCDIC and UTF-8.])
fi
# Platform specific issues
diff --git a/doc/pcreapi.3 b/doc/pcreapi.3
index 5e71486..12b177b 100644
--- a/doc/pcreapi.3
+++ b/doc/pcreapi.3
@@ -317,8 +317,10 @@ properties is available; otherwise it is set to zero.
.sp
The output is an integer whose value specifies the default character sequence
that is recognized as meaning "newline". The four values that are supported
-are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF, and -1 for ANY. The
-default should normally be the standard sequence for your operating system.
+are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF, and -1 for ANY.
+Though they are derived from ASCII, the same values are returned in EBCDIC
+environments. The default should normally correspond to the standard sequence
+for your operating system.
.sp
PCRE_CONFIG_BSR
.sp
@@ -1993,6 +1995,6 @@ Cambridge CB2 3QH, England.
.rs
.sp
.nf
-Last updated: 15 March 2009
+Last updated: 17 March 2009
Copyright (c) 1997-2009 University of Cambridge.
.fi
diff --git a/doc/pcrebuild.3 b/doc/pcrebuild.3
index db635e8..f1bfe88 100644
--- a/doc/pcrebuild.3
+++ b/doc/pcrebuild.3
@@ -38,7 +38,7 @@ to the \fBconfigure\fP command.
.SH "UTF-8 SUPPORT"
.rs
.sp
-To build PCRE with support for UTF-8 character strings, add
+To build PCRE with support for UTF-8 Unicode character strings, add
.sp
--enable-utf8
.sp
@@ -46,6 +46,12 @@ to the \fBconfigure\fP command. Of itself, this does not make PCRE treat
strings as UTF-8. As well as compiling PCRE with this option, you also have
have to set the PCRE_UTF8 option when you call the \fBpcre_compile()\fP
function.
+.P
+If you set --enable-utf8 when compiling in an EBCDIC environment, PCRE expects
+its input to be either ASCII or UTF-8 (depending on the runtime option). It is
+not possible to support both EBCDIC and UTF-8 codes in the same version of the
+library. Consequently, --enable-utf8 and --enable-ebcdic are mutually
+exclusive.
.
.SH "UNICODE CHARACTER PROPERTY SUPPORT"
.rs
@@ -72,9 +78,9 @@ documentation.
.SH "CODE VALUE OF NEWLINE"
.rs
.sp
-By default, PCRE interprets character 10 (linefeed, LF) as indicating the end
+By default, PCRE interprets the linefeed (LF) character as indicating the end
of a line. This is the normal newline character on Unix-like systems. You can
-compile PCRE to use character 13 (carriage return, CR) instead, by adding
+compile PCRE to use carriage return (CR) instead, by adding
.sp
--enable-newline-is-cr
.sp
@@ -254,7 +260,8 @@ EBCDIC environment by adding
.sp
to the \fBconfigure\fP command. This setting implies
--enable-rebuild-chartables. You should only use it if you know that you are in
-an EBCDIC environment (for example, an IBM mainframe operating system).
+an EBCDIC environment (for example, an IBM mainframe operating system). The
+--enable-ebcdic option is incompatible with --enable-utf8.
.
.SH "PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT"
.rs
@@ -322,6 +329,6 @@ Cambridge CB2 3QH, England.
.rs
.sp
.nf
-Last updated: 13 April 2008
-Copyright (c) 1997-2008 University of Cambridge.
+Last updated: 17 March 2009
+Copyright (c) 1997-2009 University of Cambridge.
.fi
diff --git a/maint/GenerateUtt.py b/maint/GenerateUtt.py
index 460c4b5..f016383 100755
--- a/maint/GenerateUtt.py
+++ b/maint/GenerateUtt.py
@@ -8,6 +8,9 @@
# offsets in the table. This is tedious to maintain by hand. Therefore, this
# script is used to generate the table. The output is sent to stdout.
+# Modified by PH 17-March-2009 to generate the more verbose form that works
+# for UTF-support in EBCDIC as well as ASCII environments.
+
script_names = ['Arabic', 'Armenian', 'Bengali', 'Bopomofo', 'Braille', 'Buginese', 'Buhid', 'Canadian_Aboriginal', \
'Cherokee', 'Common', 'Coptic', 'Cypriot', 'Cyrillic', 'Deseret', 'Devanagari', 'Ethiopic', 'Georgian', \
'Glagolitic', 'Gothic', 'Greek', 'Gujarati', 'Gurmukhi', 'Han', 'Hangul', 'Hanunoo', 'Hebrew', 'Hiragana', \
@@ -35,12 +38,31 @@ utt_table.append(('Any', 'PT_ANY'))
utt_table.sort()
+# We have to use STR_ macros to define the strings so that it all works in
+# UTF-8 mode on EBCDIC platforms.
+
+for utt in utt_table:
+ print '#define STRING_%s0' % (utt[0].replace('&', '_AMPERSAND')),
+ for c in utt[0]:
+ if c == '_':
+ print 'STR_UNDERSCORE',
+ elif c == '&':
+ print 'STR_AMPERSAND',
+ else:
+ print 'STR_%s' % c,;
+ print '"\\0"'
+
+# Print the actual table, using the string names
+
+print ''
print 'const char _pcre_utt_names[] = ';
last = ''
for utt in utt_table:
if utt == utt_table[-1]:
last = ';'
- print ' "%s\\0"%s' % (utt[0], last)
+ print ' STRING_%s0%s' % (utt[0].replace('&', '_AMPERSAND'), last)
+# This was how it was done before the EBCDIC-compatible modification.
+# print ' "%s\\0"%s' % (utt[0], last)
print '\nconst ucp_type_table _pcre_utt[] = { '
offset = 0
diff --git a/pcre_compile.c b/pcre_compile.c
index 25f7dd5..c498fb8 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -97,21 +97,56 @@ are simple data values; negative values are for special things like \d and so
on. Zero means further processing is needed (for things like \x), or the escape
is invalid. */
-#ifndef EBCDIC /* This is the "normal" table for ASCII systems */
-static const short int escapes[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 7 */
- 0, 0, ':', ';', '<', '=', '>', '?', /* 8 - ? */
- '@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E, 0, -ESC_G, /* @ - G */
--ESC_H, 0, 0, -ESC_K, 0, 0, 0, 0, /* H - O */
--ESC_P, -ESC_Q, -ESC_R, -ESC_S, 0, 0, -ESC_V, -ESC_W, /* P - W */
--ESC_X, 0, -ESC_Z, '[', '\\', ']', '^', '_', /* X - _ */
- '`', 7, -ESC_b, 0, -ESC_d, ESC_e, ESC_f, 0, /* ` - g */
--ESC_h, 0, 0, -ESC_k, 0, 0, ESC_n, 0, /* h - o */
--ESC_p, 0, ESC_r, -ESC_s, ESC_tee, 0, -ESC_v, -ESC_w, /* p - w */
- 0, 0, -ESC_z /* x - z */
+#ifndef EBCDIC
+
+/* This is the "normal" table for ASCII systems or for EBCDIC systems running
+in UTF-8 mode. */
+
+static const short int escapes[] = {
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ CHAR_COLON, CHAR_SEMICOLON,
+ CHAR_LESS_THAN_SIGN, CHAR_EQUALS_SIGN,
+ CHAR_GREATER_THAN_SIGN, CHAR_QUESTION_MARK,
+ CHAR_COMMERCIAL_AT, -ESC_A,
+ -ESC_B, -ESC_C,
+ -ESC_D, -ESC_E,
+ 0, -ESC_G,
+ -ESC_H, 0,
+ 0, -ESC_K,
+ 0, 0,
+ 0, 0,
+ -ESC_P, -ESC_Q,
+ -ESC_R, -ESC_S,
+ 0, 0,
+ -ESC_V, -ESC_W,
+ -ESC_X, 0,
+ -ESC_Z, CHAR_LEFT_SQUARE_BRACKET,
+ CHAR_BACKSLASH, CHAR_RIGHT_SQUARE_BRACKET,
+ CHAR_CIRCUMFLEX_ACCENT, CHAR_UNDERSCORE,
+ CHAR_GRAVE_ACCENT, 7,
+ -ESC_b, 0,
+ -ESC_d, ESC_e,
+ ESC_f, 0,
+ -ESC_h, 0,
+ 0, -ESC_k,
+ 0, 0,
+ ESC_n, 0,
+ -ESC_p, 0,
+ ESC_r, -ESC_s,
+ ESC_tee, 0,
+ -ESC_v, -ESC_w,
+ 0, 0,
+ -ESC_z
};
-#else /* This is the "abnormal" table for EBCDIC systems */
+#else
+
+/* This is the "abnormal" table for EBCDIC systems without UTF-8 support. */
+
static const short int escapes[] = {
/* 48 */ 0, 0, 0, '.', '<', '(', '+', '|',
/* 50 */ '&', 0, 0, 0, 0, 0, 0, 0,
@@ -142,7 +177,9 @@ static const short int escapes[] = {
/* Table of special "verbs" like (*PRUNE). This is a short table, so it is
searched linearly. Put all the names into a single string, in order to reduce
-the number of relocations when a shared library is dynamically linked. */
+the number of relocations when a shared library is dynamically linked. The
+string is built from string macros so that it works in UTF-8 mode on EBCDIC
+platforms. */
typedef struct verbitem {
int len;
@@ -150,13 +187,13 @@ typedef struct verbitem {
} verbitem;
static const char verbnames[] =
- "ACCEPT\0"
- "COMMIT\0"
- "F\0"
- "FAIL\0"
- "PRUNE\0"
- "SKIP\0"
- "THEN";
+ STRING_ACCEPT0
+ STRING_COMMIT0
+ STRING_F0
+ STRING_FAIL0
+ STRING_PRUNE0
+ STRING_SKIP0
+ STRING_THEN;
static const verbitem verbs[] = {
{ 6, OP_ACCEPT },
@@ -178,9 +215,10 @@ length entry. The first three must be alpha, lower, upper, as this is assumed
for handling case independence. */
static const char posix_names[] =
- "alpha\0" "lower\0" "upper\0" "alnum\0" "ascii\0" "blank\0"
- "cntrl\0" "digit\0" "graph\0" "print\0" "punct\0" "space\0"
- "word\0" "xdigit";
+ STRING_alpha0 STRING_lower0 STRING_upper0 STRING_alnum0
+ STRING_ascii0 STRING_blank0 STRING_cntrl0 STRING_digit0
+ STRING_graph0 STRING_print0 STRING_punct0 STRING_space0
+ STRING_word0 STRING_xdigit;
static const uschar posix_name_lengths[] = {
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 };
@@ -322,7 +360,11 @@ For convenience, we use the same bit definitions as in chartables:
Then we can use ctype_digit and ctype_xdigit in the code. */
-#ifndef EBCDIC /* This is the "normal" case, for ASCII systems */
+#ifndef EBCDIC
+
+/* This is the "normal" case, for ASCII systems, and EBCDIC systems running in
+UTF-8 mode. */
+
static const unsigned char digitab[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */
@@ -358,7 +400,10 @@ static const unsigned char digitab[] =
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
-#else /* This is the "abnormal" case, for EBCDIC systems */
+#else
+
+/* This is the "abnormal" case, for EBCDIC systems not running in UTF-8 mode. */
+
static const unsigned char digitab[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 0 */
@@ -503,9 +548,9 @@ if (c == 0) *errorcodeptr = ERR1;
in a table. A non-zero result is something that can be returned immediately.
Otherwise further processing may be required. */
-#ifndef EBCDIC /* ASCII coding */
-else if (c < '0' || c > 'z') {} /* Not alphanumeric */
-else if ((i = escapes[c - '0']) != 0) c = i;
+#ifndef EBCDIC /* ASCII/UTF-8 coding */
+else if (c < CHAR_0 || c > CHAR_z) {} /* Not alphanumeric */
+else if ((i = escapes[c - CHAR_0]) != 0) c = i;
#else /* EBCDIC coding */
else if (c < 'a' || (ebcdic_chartab[c] & 0x0E) == 0) {} /* Not alphanumeric */
@@ -524,11 +569,11 @@ else
/* A number of Perl escapes are not handled by PCRE. We give an explicit
error. */
- case 'l':
- case 'L':
- case 'N':
- case 'u':
- case 'U':
+ case CHAR_l:
+ case CHAR_L:
+ case CHAR_N:
+ case CHAR_u:
+ case CHAR_U:
*errorcodeptr = ERR37;
break;
@@ -548,8 +593,8 @@ else
(possibly recursive) subroutine calls, _not_ backreferences. Just return
the -ESC_g code (cf \k). */
- case 'g':
- if (ptr[1] == '<' || ptr[1] == '\'')
+ case CHAR_g:
+ if (ptr[1] == CHAR_LESS_THAN_SIGN || ptr[1] == CHAR_APOSTROPHE)
{
c = -ESC_g;
break;
@@ -557,12 +602,12 @@ else
/* Handle the Perl-compatible cases */
- if (ptr[1] == '{')
+ if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)
{
const uschar *p;
- for (p = ptr+2; *p != 0 && *p != '}'; p++)
- if (*p != '-' && (digitab[*p] & ctype_digit) == 0) break;
- if (*p != 0 && *p != '}')
+ for (p = ptr+2; *p != 0 && *p != CHAR_RIGHT_CURLY_BRACKET; p++)
+ if (*p != CHAR_MINUS && (digitab[*p] & ctype_digit) == 0) break;
+ if (*p != 0 && *p != CHAR_RIGHT_CURLY_BRACKET)
{
c = -ESC_k;
break;
@@ -572,7 +617,7 @@ else
}
else braced = FALSE;
- if (ptr[1] == '-')
+ if (ptr[1] == CHAR_MINUS)
{
negated = TRUE;
ptr++;
@@ -581,7 +626,7 @@ else
c = 0;
while ((digitab[ptr[1]] & ctype_digit) != 0)
- c = c * 10 + *(++ptr) - '0';
+ c = c * 10 + *(++ptr) - CHAR_0;
if (c < 0) /* Integer overflow */
{
@@ -589,7 +634,7 @@ else
break;
}
- if (braced && *(++ptr) != '}')
+ if (braced && *(++ptr) != CHAR_RIGHT_CURLY_BRACKET)
{
*errorcodeptr = ERR57;
break;
@@ -626,15 +671,15 @@ else
value is greater than 377, the least significant 8 bits are taken. Inside a
character class, \ followed by a digit is always an octal number. */
- case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
+ case CHAR_1: case CHAR_2: case CHAR_3: case CHAR_4: case CHAR_5:
+ case CHAR_6: case CHAR_7: case CHAR_8: case CHAR_9:
if (!isclass)
{
oldptr = ptr;
- c -= '0';
+ c -= CHAR_0;
while ((digitab[ptr[1]] & ctype_digit) != 0)
- c = c * 10 + *(++ptr) - '0';
+ c = c * 10 + *(++ptr) - CHAR_0;
if (c < 0) /* Integer overflow */
{
*errorcodeptr = ERR61;
@@ -652,7 +697,7 @@ else
generates a binary zero byte and treats the digit as a following literal.
Thus we have to pull back the pointer by one. */
- if ((c = *ptr) >= '8')
+ if ((c = *ptr) >= CHAR_8)
{
ptr--;
c = 0;
@@ -665,10 +710,10 @@ else
to do). Nowadays we allow for larger numbers in UTF-8 mode, but no more
than 3 octal digits. */
- case '0':
- c -= '0';
- while(i++ < 2 && ptr[1] >= '0' && ptr[1] <= '7')
- c = c * 8 + *(++ptr) - '0';
+ case CHAR_0:
+ c -= CHAR_0;
+ while(i++ < 2 && ptr[1] >= CHAR_0 && ptr[1] <= CHAR_7)
+ c = c * 8 + *(++ptr) - CHAR_0;
if (!utf8 && c > 255) *errorcodeptr = ERR51;
break;
@@ -676,8 +721,8 @@ else
than 0xff in utf8 mode, but only if the ddd are hex digits. If not, { is
treated as a data character. */
- case 'x':
- if (ptr[1] == '{')
+ case CHAR_x:
+ if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)
{
const uschar *pt = ptr + 2;
int count = 0;
@@ -686,19 +731,19 @@ else
while ((digitab[*pt] & ctype_xdigit) != 0)
{
register int cc = *pt++;
- if (c == 0 && cc == '0') continue; /* Leading zeroes */
+ if (c == 0 && cc == CHAR_0) continue; /* Leading zeroes */
count++;
-#ifndef EBCDIC /* ASCII coding */
- if (cc >= 'a') cc -= 32; /* Convert to upper case */
- c = (c << 4) + cc - ((cc < 'A')? '0' : ('A' - 10));
+#ifndef EBCDIC /* ASCII/UTF-8 coding */
+ if (cc >= CHAR_a) cc -= 32; /* Convert to upper case */
+ c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
#else /* EBCDIC coding */
- if (cc >= 'a' && cc <= 'z') cc += 64; /* Convert to upper case */
- c = (c << 4) + cc - ((cc >= '0')? '0' : ('A' - 10));
+ if (cc >= CHAR_a && cc <= CHAR_z) cc += 64; /* Convert to upper case */
+ c = (c << 4) + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));
#endif
}
- if (*pt == '}')
+ if (*pt == CHAR_RIGHT_CURLY_BRACKET)
{
if (c < 0 || count > (utf8? 8 : 2)) *errorcodeptr = ERR34;
ptr = pt;
@@ -714,14 +759,14 @@ else
c = 0;
while (i++ < 2 && (digitab[ptr[1]] & ctype_xdigit) != 0)
{
- int cc; /* Some compilers don't like ++ */
- cc = *(++ptr); /* in initializers */
-#ifndef EBCDIC /* ASCII coding */
- if (cc >= 'a') cc -= 32; /* Convert to upper case */
- c = c * 16 + cc - ((cc < 'A')? '0' : ('A' - 10));
+ int cc; /* Some compilers don't like */
+ cc = *(++ptr); /* ++ in initializers */
+#ifndef EBCDIC /* ASCII/UTF-8 coding */
+ if (cc >= CHAR_a) cc -= 32; /* Convert to upper case */
+ c = c * 16 + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
#else /* EBCDIC coding */
- if (cc <= 'z') cc += 64; /* Convert to upper case */
- c = c * 16 + cc - ((cc >= '0')? '0' : ('A' - 10));
+ if (cc <= CHAR_z) cc += 64; /* Convert to upper case */
+ c = c * 16 + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));
#endif
}
break;
@@ -730,7 +775,7 @@ else
This coding is ASCII-specific, but then the whole concept of \cx is
ASCII-specific. (However, an EBCDIC equivalent has now been added.) */
- case 'c':
+ case CHAR_c:
c = *(++ptr);
if (c == 0)
{
@@ -738,11 +783,11 @@ else
break;
}
-#ifndef EBCDIC /* ASCII coding */
- if (c >= 'a' && c <= 'z') c -= 32;
+#ifndef EBCDIC /* ASCII/UTF-8 coding */
+ if (c >= CHAR_a && c <= CHAR_z) c -= 32;
c ^= 0x40;
#else /* EBCDIC coding */
- if (c >= 'a' && c <= 'z') c += 64;
+ if (c >= CHAR_a && c <= CHAR_z) c += 64;
c ^= 0xC0;
#endif
break;
@@ -804,9 +849,9 @@ if (c == 0) goto ERROR_RETURN;
/* \P or \p can be followed by a name in {}, optionally preceded by ^ for
negation. */
-if (c == '{')
+if (c == CHAR_LEFT_CURLY_BRACKET)
{
- if (ptr[1] == '^')
+ if (ptr[1] == CHAR_CIRCUMFLEX_ACCENT)
{
*negptr = TRUE;
ptr++;
@@ -815,10 +860,10 @@ if (c == '{')
{
c = *(++ptr);
if (c == 0) goto ERROR_RETURN;
- if (c == '}') break;
+ if (c == CHAR_RIGHT_CURLY_BRACKET) break;
name[i] = c;
}
- if (c !='}') goto ERROR_RETURN;
+ if (c != CHAR_RIGHT_CURLY_BRACKET) goto ERROR_RETURN;
name[i] = 0;
}
@@ -883,15 +928,15 @@ is_counted_repeat(const uschar *p)
{
if ((digitab[*p++] & ctype_digit) == 0) return FALSE;
while ((digitab[*p] & ctype_digit) != 0) p++;
-if (*p == '}') return TRUE;
+if (*p == CHAR_RIGHT_CURLY_BRACKET) return TRUE;
-if (*p++ != ',') return FALSE;
-if (*p == '}') return TRUE;
+if (*p++ != CHAR_COMMA) return FALSE;
+if (*p == CHAR_RIGHT_CURLY_BRACKET) return TRUE;
if ((digitab[*p++] & ctype_digit) == 0) return FALSE;
while ((digitab[*p] & ctype_digit) != 0) p++;
-return (*p == '}');
+return (*p == CHAR_RIGHT_CURLY_BRACKET);
}
@@ -924,7 +969,7 @@ int max = -1;
/* Read the minimum value and do a paranoid check: a negative value indicates
an integer overflow. */
-while ((digitab[*p] & ctype_digit) != 0) min = min * 10 + *p++ - '0';
+while ((digitab[*p] & ctype_digit) != 0) min = min * 10 + *p++ - CHAR_0;
if (min < 0 || min > 65535)
{
*errorcodeptr = ERR5;
@@ -934,12 +979,12 @@ if (min < 0 || min > 65535)
/* Read the maximum value if there is one, and again do a paranoid on its size.
Also, max must not be less than min. */
-if (*p == '}') max = min; else
+if (*p == CHAR_RIGHT_CURLY_BRACKET) max = min; else
{
- if (*(++p) != '}')
+ if (*(++p) != CHAR_RIGHT_CURLY_BRACKET)
{
max = 0;
- while((digitab[*p] & ctype_digit) != 0) max = max * 10 + *p++ - '0';
+ while((digitab[*p] & ctype_digit) != 0) max = max * 10 + *p++ - CHAR_0;
if (max < 0 || max > 65535)
{
*errorcodeptr = ERR5;
@@ -997,14 +1042,14 @@ for (; *ptr != 0; ptr++)
/* Skip over backslashed characters and also entire \Q...\E */
- if (*ptr == '\\')
+ if (*ptr == CHAR_BACKSLASH)
{
if (*(++ptr) == 0) return -1;
- if (*ptr == 'Q') for (;;)
+ if (*ptr == CHAR_Q) for (;;)
{
- while (*(++ptr) != 0 && *ptr != '\\') {};
+ while (*(++ptr) != 0 && *ptr != CHAR_BACKSLASH) {};
if (*ptr == 0) return -1;
- if (*(++ptr) == 'E') break;
+ if (*(++ptr) == CHAR_E) break;
}
continue;
}
@@ -1012,21 +1057,26 @@ for (; *ptr != 0; ptr++)
/* Skip over character classes; this logic must be similar to the way they
are handled for real. If the first character is '^', skip it. Also, if the
first few characters (either before or after ^) are \Q\E or \E we skip them
- too. This makes for compatibility with Perl. */
+ too. This makes for compatibility with Perl. Note the use of STR macros to
+ encode "Q\\E" so that it works in UTF-8 on EBCDIC platforms. */
- if (*ptr == '[')
+ if (*ptr == CHAR_LEFT_SQUARE_BRACKET)
{
BOOL negate_class = FALSE;
for (;;)
{
int c = *(++ptr);
- if (c == '\\')
+ if (c == CHAR_BACKSLASH)
{
- if (ptr[1] == 'E') ptr++;
- else if (strncmp((const char *)ptr+1, "Q\\E", 3) == 0) ptr += 3;
- else break;
+ if (ptr[1] == CHAR_E)
+ ptr++;
+ else if (strncmp((const char *)ptr+1,
+ STR_Q STR_BACKSLASH STR_E, 3) == 0)
+ ptr += 3;
+ else
+ break;
}
- else if (!negate_class && c == '^')
+ else if (!negate_class && c == CHAR_CIRCUMFLEX_ACCENT)
negate_class = TRUE;
else break;
}
@@ -1034,20 +1084,21 @@ for (; *ptr != 0; ptr++)
/* If the next character is ']', it is a data character that must be
skipped, except in JavaScript compatibility mode. */
- if (ptr[1] == ']' && (cd->external_options & PCRE_JAVASCRIPT_COMPAT) == 0)
+ if (ptr[1] == CHAR_RIGHT_SQUARE_BRACKET &&
+ (cd->external_options & PCRE_JAVASCRIPT_COMPAT) == 0)
ptr++;
- while (*(++ptr) != ']')
+ while (*(++ptr) != CHAR_RIGHT_SQUARE_BRACKET)
{
if (*ptr == 0) return -1;
- if (*ptr == '\\')
+ if (*ptr == CHAR_BACKSLASH)
{
if (*(++ptr) == 0) return -1;
- if (*ptr == 'Q') for (;;)
+ if (*ptr == CHAR_Q) for (;;)
{
- while (*(++ptr) != 0 && *ptr != '\\') {};
+ while (*(++ptr) != 0 && *ptr != CHAR_BACKSLASH) {};
if (*ptr == 0) return -1;
- if (*(++ptr) == 'E') break;
+ if (*(++ptr) == CHAR_E) break;
}
continue;
}
@@ -1057,17 +1108,17 @@ for (; *ptr != 0; ptr++)
/* Skip comments in /x mode */
- if (xmode && *ptr == '#')
+ if (xmode && *ptr == CHAR_NUMBER_SIGN)
{
- while (*(++ptr) != 0 && *ptr != '\n') {};
+ while (*(++ptr) != 0 && *ptr != CHAR_NL) {};
if (*ptr == 0) return -1;
continue;
}
/* An opening parens must now be a real metacharacter */
- if (*ptr != '(') continue;
- if (ptr[1] != '?' && ptr[1] != '*')
+ if (*ptr != CHAR_LEFT_PARENTHESIS) continue;
+ if (ptr[1] != CHAR_QUESTION_MARK && ptr[1] != CHAR_ASTERISK)
{
count++;
if (name == NULL && count == lorn) return count;
@@ -1075,19 +1126,19 @@ for (; *ptr != 0; ptr++)
}
ptr += 2;
- if (*ptr == 'P') ptr++; /* Allow optional P */
+ if (*ptr == CHAR_P) ptr++; /* Allow optional P */
/* We have to disambiguate (?<! and (?<= from (?<name> */
- if ((*ptr != '<' || ptr[1] == '!' || ptr[1] == '=') &&
- *ptr != '\'')
+ if ((*ptr != CHAR_LESS_THAN_SIGN || ptr[1] == CHAR_EXCLAMATION_MARK ||
+ ptr[1] == CHAR_EQUALS_SIGN) && *ptr != CHAR_APOSTROPHE)
continue;
count++;
if (name == NULL && count == lorn) return count;
term = *ptr++;
- if (term == '<') term = '>';
+ if (term == CHAR_LESS_THAN_SIGN) term = CHAR_GREATER_THAN_SIGN;
thisname = ptr;
while (*ptr != term) ptr++;
if (name != NULL && lorn == ptr - thisname &&
@@ -1825,10 +1876,10 @@ int terminator; /* Don't combine these lines; the Solaris cc */
terminator = *(++ptr); /* compiler warns about "non-constant" initializer. */
for (++ptr; *ptr != 0; ptr++)
{
- if (*ptr == '\\' && ptr[1] == ']') ptr++; else
+ if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET) ptr++; else
{
- if (*ptr == ']') return FALSE;
- if (*ptr == terminator && ptr[1] == ']')
+ if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
+ if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
{
*endptr = ptr;
return TRUE;
@@ -2074,7 +2125,7 @@ if ((options & PCRE_EXTENDED) != 0)
for (;;)
{
while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;
- if (*ptr == '#')
+ if (*ptr == CHAR_NUMBER_SIGN)
{
while (*(++ptr) != 0)
if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }
@@ -2086,7 +2137,7 @@ if ((options & PCRE_EXTENDED) != 0)
/* If the next item is one that we can handle, get its value. A non-negative
value is a character, a negative value is an escape value. */
-if (*ptr == '\\')
+if (*ptr == CHAR_BACKSLASH)
{
int temperrorcode = 0;
next = check_escape(&ptr, &temperrorcode, cd->bracount, options, FALSE);
@@ -2111,7 +2162,7 @@ if ((options & PCRE_EXTENDED) != 0)
for (;;)
{
while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;
- if (*ptr == '#')
+ if (*ptr == CHAR_NUMBER_SIGN)
{
while (*(++ptr) != 0)
if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }
@@ -2122,8 +2173,9 @@ if ((options & PCRE_EXTENDED) != 0)
/* If the next thing is itself optional, we have to give up. */
-if (*ptr == '*' || *ptr == '?' || strncmp((char *)ptr, "{0,", 3) == 0)
- return FALSE;
+if (*ptr == CHAR_ASTERISK || *ptr == CHAR_QUESTION_MARK ||
+ strncmp((char *)ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0)
+ return FALSE;
/* Now compare the next item with the previous opcode. If the previous is a
positive single character match, "item" either contains the character or, if
@@ -2561,7 +2613,7 @@ for (;; ptr++)
if (inescq && c != 0)
{
- if (c == '\\' && ptr[1] == 'E')
+ if (c == CHAR_BACKSLASH && ptr[1] == CHAR_E)
{
inescq = FALSE;
ptr++;
@@ -2587,8 +2639,9 @@ for (;; ptr++)
/* Fill in length of a previous callout, except when the next thing is
a quantifier. */
- is_quantifier = c == '*' || c == '+' || c == '?' ||
- (c == '{' && is_counted_repeat(ptr+1));
+ is_quantifier =
+ c == CHAR_ASTERISK || c == CHAR_PLUS || c == CHAR_QUESTION_MARK ||
+ (c == CHAR_LEFT_CURLY_BRACKET && is_counted_repeat(ptr+1));
if (!is_quantifier && previous_callout != NULL &&
after_manual_callout-- <= 0)
@@ -2603,7 +2656,7 @@ for (;; ptr++)
if ((options & PCRE_EXTENDED) != 0)
{
if ((cd->ctypes[c] & ctype_space) != 0) continue;
- if (c == '#')
+ if (c == CHAR_NUMBER_SIGN)
{
while (*(++ptr) != 0)
{
@@ -2628,8 +2681,8 @@ for (;; ptr++)
{
/* ===================================================================*/
case 0: /* The branch terminates at string end */
- case '|': /* or | or ) */
- case ')':
+ case CHAR_VERTICAL_LINE: /* or | or ) */
+ case CHAR_RIGHT_PARENTHESIS:
*firstbyteptr = firstbyte;
*reqbyteptr = reqbyte;
*codeptr = code;
@@ -2651,7 +2704,7 @@ for (;; ptr++)
/* Handle single-character metacharacters. In multiline mode, ^ disables
the setting of any following char as a first character. */
- case '^':
+ case CHAR_CIRCUMFLEX_ACCENT:
if ((options & PCRE_MULTILINE) != 0)
{
if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
@@ -2660,7 +2713,7 @@ for (;; ptr++)
*code++ = OP_CIRC;
break;
- case '$':
+ case CHAR_DOLLAR_SIGN:
previous = NULL;
*code++ = OP_DOLL;
break;
@@ -2668,7 +2721,7 @@ for (;; ptr++)
/* There can never be a first char if '.' is first, whatever happens about
repeats. The value of reqbyte doesn't change either. */
- case '.':
+ case CHAR_DOT:
if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
zerofirstbyte = firstbyte;
zeroreqbyte = reqbyte;
@@ -2692,7 +2745,7 @@ for (;; ptr++)
In JavaScript compatibility mode, an isolated ']' causes an error. In
default (Perl) mode, it is treated as a data character. */
- case ']':
+ case CHAR_RIGHT_SQUARE_BRACKET:
if ((cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)
{
*errorcodeptr = ERR64;
@@ -2700,16 +2753,17 @@ for (;; ptr++)
}
goto NORMAL_CHAR;
- case '[':
+ case CHAR_LEFT_SQUARE_BRACKET:
previous = code;
/* PCRE supports POSIX class stuff inside a class. Perl gives an error if
they are encountered at the top level, so we'll do that too. */
- if ((ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
+ if ((ptr[1] == CHAR_COLON || ptr[1] == CHAR_DOT ||
+ ptr[1] == CHAR_EQUALS_SIGN) &&
check_posix_syntax(ptr, &tempptr))
{
- *errorcodeptr = (ptr[1] == ':')? ERR13 : ERR31;
+ *errorcodeptr = (ptr[1] == CHAR_COLON)? ERR13 : ERR31;
goto FAILED;
}
@@ -2721,13 +2775,17 @@ for (;; ptr++)
for (;;)
{
c = *(++ptr);
- if (c == '\\')
+ if (c == CHAR_BACKSLASH)
{
- if (ptr[1] == 'E') ptr++;
- else if (strncmp((const char *)ptr+1, "Q\\E", 3) == 0) ptr += 3;
- else break;
+ if (ptr[1] == CHAR_E)
+ ptr++;
+ else if (strncmp((const char *)ptr+1,
+ STR_Q STR_BACKSLASH STR_E, 3) == 0)
+ ptr += 3;
+ else
+ break;
}
- else if (!negate_class && c == '^')
+ else if (!negate_class && c == CHAR_CIRCUMFLEX_ACCENT)
negate_class = TRUE;
else break;
}
@@ -2737,7 +2795,8 @@ for (;; ptr++)
that. In JS mode, [] must always fail, so generate OP_FAIL, whereas
[^] must match any character, so generate OP_ALLANY. */
- if (c ==']' && (cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)
+ if (c == CHAR_RIGHT_SQUARE_BRACKET &&
+ (cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)
{
*code++ = negate_class? OP_ALLANY : OP_FAIL;
if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
@@ -2802,7 +2861,7 @@ for (;; ptr++)
if (inescq)
{
- if (c == '\\' && ptr[1] == 'E') /* If we are at \E */
+ if (c == CHAR_BACKSLASH && ptr[1] == CHAR_E) /* If we are at \E */
{
inescq = FALSE; /* Reset literal state */
ptr++; /* Skip the 'E' */
@@ -2817,23 +2876,23 @@ for (;; ptr++)
[.ch.] and [=ch=] ("collating elements") and fault them, as Perl
5.6 and 5.8 do. */
- if (c == '[' &&
- (ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
- check_posix_syntax(ptr, &tempptr))
+ if (c == CHAR_LEFT_SQUARE_BRACKET &&
+ (ptr[1] == CHAR_COLON || ptr[1] == CHAR_DOT ||
+ ptr[1] == CHAR_EQUALS_SIGN) && check_posix_syntax(ptr, &tempptr))
{
BOOL local_negate = FALSE;
int posix_class, taboffset, tabopt;
register const uschar *cbits = cd->cbits;
uschar pbits[32];
- if (ptr[1] != ':')
+ if (ptr[1] != CHAR_COLON)
{
*errorcodeptr = ERR31;
goto FAILED;
}
ptr += 2;
- if (*ptr == '^')
+ if (*ptr == CHAR_CIRCUMFLEX_ACCENT)
{
local_negate = TRUE;
should_flip_negation = TRUE; /* Note negative special */
@@ -2906,17 +2965,17 @@ for (;; ptr++)
to 'or' into the one we are building. We assume they have more than one
character in them, so set class_charcount bigger than one. */
- if (c == '\\')
+ if (c == CHAR_BACKSLASH)
{
c = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE);
if (*errorcodeptr != 0) goto FAILED;
- if (-c == ESC_b) c = '\b'; /* \b is backspace in a class */
- else if (-c == ESC_X) c = 'X'; /* \X is literal X in a class */
- else if (-c == ESC_R) c = 'R'; /* \R is literal R in a class */
+ if (-c == ESC_b) c = CHAR_BS; /* \b is backspace in a class */
+ else if (-c == ESC_X) c = CHAR_X; /* \X is literal X in a class */
+ else if (-c == ESC_R) c = CHAR_R; /* \R is literal R in a class */
else if (-c == ESC_Q) /* Handle start of quoted string */
{
- if (ptr[1] == '\\' && ptr[2] == 'E')
+ if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
{
ptr += 2; /* avoid empty string */
}
@@ -3142,7 +3201,7 @@ for (;; ptr++)
entirely. The code for handling \Q and \E is messy. */
CHECK_RANGE:
- while (ptr[1] == '\\' && ptr[2] == 'E')
+ while (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
{
inescq = FALSE;
ptr += 2;
@@ -3152,28 +3211,29 @@ for (;; ptr++)
/* Remember \r or \n */
- if (c == '\r' || c == '\n') cd->external_flags |= PCRE_HASCRORLF;
+ if (c == CHAR_CR || c == CHAR_NL) cd->external_flags |= PCRE_HASCRORLF;
/* Check for range */
- if (!inescq && ptr[1] == '-')
+ if (!inescq && ptr[1] == CHAR_MINUS)
{
int d;
ptr += 2;
- while (*ptr == '\\' && ptr[1] == 'E') ptr += 2;
+ while (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_E) ptr += 2;
/* If we hit \Q (not followed by \E) at this point, go into escaped
mode. */
- while (*ptr == '\\' && ptr[1] == 'Q')
+ while (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_Q)
{
ptr += 2;
- if (*ptr == '\\' && ptr[1] == 'E') { ptr += 2; continue; }
+ if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_E)
+ { ptr += 2; continue; }
inescq = TRUE;
break;
}
- if (*ptr == 0 || (!inescq && *ptr == ']'))
+ if (*ptr == 0 || (!inescq && *ptr == CHAR_RIGHT_SQUARE_BRACKET))
{
ptr = oldptr;
goto LONE_SINGLE_CHARACTER;
@@ -3192,7 +3252,7 @@ for (;; ptr++)
not any of the other escapes. Perl 5.6 treats a hyphen as a literal
in such circumstances. */
- if (!inescq && d == '\\')
+ if (!inescq && d == CHAR_BACKSLASH)
{
d = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE);
if (*errorcodeptr != 0) goto FAILED;
@@ -3202,9 +3262,9 @@ for (;; ptr++)
if (d < 0)
{
- if (d == -ESC_b) d = '\b';
- else if (d == -ESC_X) d = 'X';
- else if (d == -ESC_R) d = 'R'; else
+ if (d == -ESC_b) d = CHAR_BS;
+ else if (d == -ESC_X) d = CHAR_X;
+ else if (d == -ESC_R) d = CHAR_R; else
{
ptr = oldptr;
goto LONE_SINGLE_CHARACTER; /* A few lines below */
@@ -3225,7 +3285,7 @@ for (;; ptr++)
/* Remember \r or \n */
- if (d == '\r' || d == '\n') cd->external_flags |= PCRE_HASCRORLF;
+ if (d == CHAR_CR || d == CHAR_NL) cd->external_flags |= PCRE_HASCRORLF;
/* In UTF-8 mode, if the upper limit is > 255, or > 127 for caseless
matching, we have to use an XCLASS with extra data items. Caseless
@@ -3372,7 +3432,7 @@ for (;; ptr++)
/* Loop until ']' reached. This "while" is the end of the "do" above. */
- while ((c = *(++ptr)) != 0 && (c != ']' || inescq));
+ while ((c = *(++ptr)) != 0 && (c != CHAR_RIGHT_SQUARE_BRACKET || inescq));
if (c == 0) /* Missing terminating ']' */
{
@@ -3517,23 +3577,23 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* Various kinds of repeat; '{' is not necessarily a quantifier, but this
has been tested above. */
- case '{':
+ case CHAR_LEFT_CURLY_BRACKET:
if (!is_quantifier) goto NORMAL_CHAR;
ptr = read_repeat_counts(ptr+1, &repeat_min, &repeat_max, errorcodeptr);
if (*errorcodeptr != 0) goto FAILED;
goto REPEAT;
- case '*':
+ case CHAR_ASTERISK:
repeat_min = 0;
repeat_max = -1;
goto REPEAT;
- case '+':
+ case CHAR_PLUS:
repeat_min = 1;
repeat_max = -1;
goto REPEAT;
- case '?':
+ case CHAR_QUESTION_MARK:
repeat_min = 0;
repeat_max = 1;
@@ -3568,13 +3628,13 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
but if PCRE_UNGREEDY is set, it works the other way round. We change the
repeat type to the non-default. */
- if (ptr[1] == '+')
+ if (ptr[1] == CHAR_PLUS)
{
repeat_type = 0; /* Force greedy */
possessive_quantifier = TRUE;
ptr++;
}
- else if (ptr[1] == '?')
+ else if (ptr[1] == CHAR_QUESTION_MARK)
{
repeat_type = greedy_non_default;
ptr++;
@@ -4207,7 +4267,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
lookbehind or option setting or condition or all the other extended
parenthesis forms. */
- case '(':
+ case CHAR_LEFT_PARENTHESIS:
newoptions = options;
skipbytes = 0;
bravalue = OP_CBRA;
@@ -4216,19 +4276,19 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* First deal with various "verbs" that can be introduced by '*'. */
- if (*(++ptr) == '*' && (cd->ctypes[ptr[1]] & ctype_letter) != 0)
+ if (*(++ptr) == CHAR_ASTERISK && (cd->ctypes[ptr[1]] & ctype_letter) != 0)
{
int i, namelen;
const char *vn = verbnames;
const uschar *name = ++ptr;
previous = NULL;
while ((cd->ctypes[*++ptr] & ctype_letter) != 0) {};
- if (*ptr == ':')
+ if (*ptr == CHAR_COLON)
{
*errorcodeptr = ERR59; /* Not supported */
goto FAILED;
}
- if (*ptr != ')')
+ if (*ptr != CHAR_RIGHT_PARENTHESIS)
{
*errorcodeptr = ERR60;
goto FAILED;
@@ -4253,7 +4313,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* Deal with the extended parentheses; all are introduced by '?', and the
appearance of any of them means that this is not a capturing group. */
- else if (*ptr == '?')
+ else if (*ptr == CHAR_QUESTION_MARK)
{
int i, set, unset, namelen;
int *optset;
@@ -4262,9 +4322,9 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
switch (*(++ptr))
{
- case '#': /* Comment; skip to ket */
+ case CHAR_NUMBER_SIGN: /* Comment; skip to ket */
ptr++;
- while (*ptr != 0 && *ptr != ')') ptr++;
+ while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
if (*ptr == 0)
{
*errorcodeptr = ERR18;
@@ -4274,19 +4334,19 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* ------------------------------------------------------------ */
- case '|': /* Reset capture count for each branch */
+ case CHAR_VERTICAL_LINE: /* Reset capture count for each branch */
reset_bracount = TRUE;
/* Fall through */
/* ------------------------------------------------------------ */
- case ':': /* Non-capturing bracket */
+ case CHAR_COLON: /* Non-capturing bracket */
bravalue = OP_BRA;
ptr++;
break;
/* ------------------------------------------------------------ */
- case '(':
+ case CHAR_LEFT_PARENTHESIS:
bravalue = OP_COND; /* Conditional group */
/* A condition can be an assertion, a number (referring to a numbered
@@ -4306,7 +4366,8 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
the switch. This will take control down to where bracketed groups,
including assertions, are processed. */
- if (ptr[1] == '?' && (ptr[2] == '=' || ptr[2] == '!' || ptr[2] == '<'))
+ if (ptr[1] == CHAR_QUESTION_MARK && (ptr[2] == CHAR_EQUALS_SIGN ||
+ ptr[2] == CHAR_EXCLAMATION_MARK || ptr[2] == CHAR_LESS_THAN_SIGN))
break;
/* Most other conditions use OP_CREF (a couple change to OP_RREF
@@ -4318,7 +4379,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* Check for a test for recursion in a named group. */
- if (ptr[1] == 'R' && ptr[2] == '&')
+ if (ptr[1] == CHAR_R && ptr[2] == CHAR_AMPERSAND)
{
terminator = -1;
ptr += 2;
@@ -4328,20 +4389,20 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* Check for a test for a named group's having been set, using the Perl
syntax (?(<name>) or (?('name') */
- else if (ptr[1] == '<')
+ else if (ptr[1] == CHAR_LESS_THAN_SIGN)
{
- terminator = '>';
+ terminator = CHAR_GREATER_THAN_SIGN;
ptr++;
}
- else if (ptr[1] == '\'')
+ else if (ptr[1] == CHAR_APOSTROPHE)
{
- terminator = '\'';
+ terminator = CHAR_APOSTROPHE;
ptr++;
}
else
{
terminator = 0;
- if (ptr[1] == '-' || ptr[1] == '+') refsign = *(++ptr);
+ if (ptr[1] == CHAR_MINUS || ptr[1] == CHAR_PLUS) refsign = *(++ptr);
}
/* We now expect to read a name; any thing else is an error */
@@ -4361,12 +4422,13 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
{
if (recno >= 0)
recno = ((digitab[*ptr] & ctype_digit) != 0)?
- recno * 10 + *ptr - '0' : -1;
+ recno * 10 + *ptr - CHAR_0 : -1;
ptr++;
}
namelen = ptr - name;
- if ((terminator > 0 && *ptr++ != terminator) || *ptr++ != ')')
+ if ((terminator > 0 && *ptr++ != terminator) ||
+ *ptr++ != CHAR_RIGHT_PARENTHESIS)
{
ptr--; /* Error offset */
*errorcodeptr = ERR26;
@@ -4388,7 +4450,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
*errorcodeptr = ERR58;
goto FAILED;
}
- recno = (refsign == '-')?
+ recno = (refsign == CHAR_MINUS)?
cd->bracount - recno + 1 : recno +cd->bracount;
if (recno <= 0 || recno > cd->final_bracount)
{
@@ -4440,7 +4502,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* Check for (?(R) for recursion. Allow digits after R to specify a
specific group number. */
- else if (*name == 'R')
+ else if (*name == CHAR_R)
{
recno = 0;
for (i = 1; i < namelen; i++)
@@ -4450,7 +4512,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
*errorcodeptr = ERR15;
goto FAILED;
}
- recno = recno * 10 + name[i] - '0';
+ recno = recno * 10 + name[i] - CHAR_0;
}
if (recno == 0) recno = RREF_ANY;
code[1+LINK_SIZE] = OP_RREF; /* Change test type */
@@ -4460,7 +4522,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* Similarly, check for the (?(DEFINE) "condition", which is always
false. */
- else if (namelen == 6 && strncmp((char *)name, "DEFINE", 6) == 0)
+ else if (namelen == 6 && strncmp((char *)name, STRING_DEFINE, 6) == 0)
{
code[1+LINK_SIZE] = OP_DEF;
skipbytes = 1;
@@ -4485,16 +4547,16 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* ------------------------------------------------------------ */
- case '=': /* Positive lookahead */
+ case CHAR_EQUALS_SIGN: /* Positive lookahead */
bravalue = OP_ASSERT;
ptr++;
break;
/* ------------------------------------------------------------ */
- case '!': /* Negative lookahead */
+ case CHAR_EXCLAMATION_MARK: /* Negative lookahead */
ptr++;
- if (*ptr == ')') /* Optimize (?!) */
+ if (*ptr == CHAR_RIGHT_PARENTHESIS) /* Optimize (?!) */
{
*code++ = OP_FAIL;
previous = NULL;
@@ -4505,15 +4567,15 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* ------------------------------------------------------------ */
- case '<': /* Lookbehind or named define */
+ case CHAR_LESS_THAN_SIGN: /* Lookbehind or named define */
switch (ptr[1])
{
- case '=': /* Positive lookbehind */
+ case CHAR_EQUALS_SIGN: /* Positive lookbehind */
bravalue = OP_ASSERTBACK;
ptr += 2;
break;
- case '!': /* Negative lookbehind */
+ case CHAR_EXCLAMATION_MARK: /* Negative lookbehind */
bravalue = OP_ASSERTBACK_NOT;
ptr += 2;
break;
@@ -4528,22 +4590,22 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* ------------------------------------------------------------ */
- case '>': /* One-time brackets */
+ case CHAR_GREATER_THAN_SIGN: /* One-time brackets */
bravalue = OP_ONCE;
ptr++;
break;
/* ------------------------------------------------------------ */
- case 'C': /* Callout - may be followed by digits; */
+ case CHAR_C: /* Callout - may be followed by digits; */
previous_callout = code; /* Save for later completion */
after_manual_callout = 1; /* Skip one item before completing */
*code++ = OP_CALLOUT;
{
int n = 0;
while ((digitab[*(++ptr)] & ctype_digit) != 0)
- n = n * 10 + *ptr - '0';
- if (*ptr != ')')
+ n = n * 10 + *ptr - CHAR_0;
+ if (*ptr != CHAR_RIGHT_PARENTHESIS)
{
*errorcodeptr = ERR39;
goto FAILED;
@@ -4563,14 +4625,15 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* ------------------------------------------------------------ */
- case 'P': /* Python-style named subpattern handling */
- if (*(++ptr) == '=' || *ptr == '>') /* Reference or recursion */
+ case CHAR_P: /* Python-style named subpattern handling */
+ if (*(++ptr) == CHAR_EQUALS_SIGN ||
+ *ptr == CHAR_GREATER_THAN_SIGN) /* Reference or recursion */
{
- is_recurse = *ptr == '>';
- terminator = ')';
+ is_recurse = *ptr == CHAR_GREATER_THAN_SIGN;
+ terminator = CHAR_RIGHT_PARENTHESIS;
goto NAMED_REF_OR_RECURSE;
}
- else if (*ptr != '<') /* Test for Python-style definition */
+ else if (*ptr != CHAR_LESS_THAN_SIGN) /* Test for Python-style defn */
{
*errorcodeptr = ERR41;
goto FAILED;
@@ -4580,9 +4643,10 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* ------------------------------------------------------------ */
DEFINE_NAME: /* Come here from (?< handling */
- case '\'':
+ case CHAR_APOSTROPHE:
{
- terminator = (*ptr == '<')? '>' : '\'';
+ terminator = (*ptr == CHAR_LESS_THAN_SIGN)?
+ CHAR_GREATER_THAN_SIGN : CHAR_APOSTROPHE;
name = ++ptr;
while ((cd->ctypes[*ptr] & ctype_word) != 0) ptr++;
@@ -4656,8 +4720,8 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* ------------------------------------------------------------ */
- case '&': /* Perl recursion/subroutine syntax */
- terminator = ')';
+ case CHAR_AMPERSAND: /* Perl recursion/subroutine syntax */
+ terminator = CHAR_RIGHT_PARENTHESIS;
is_recurse = TRUE;
/* Fall through */
@@ -4732,18 +4796,18 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* ------------------------------------------------------------ */
- case 'R': /* Recursion */
+ case CHAR_R: /* Recursion */
ptr++; /* Same as (?0) */
/* Fall through */
/* ------------------------------------------------------------ */
- case '-': case '+':
- case '0': case '1': case '2': case '3': case '4': /* Recursion or */
- case '5': case '6': case '7': case '8': case '9': /* subroutine */
+ case CHAR_MINUS: case CHAR_PLUS: /* Recursion or subroutine */
+ case CHAR_0: case CHAR_1: case CHAR_2: case CHAR_3: case CHAR_4:
+ case CHAR_5: case CHAR_6: case CHAR_7: case CHAR_8: case CHAR_9:
{
const uschar *called;
- terminator = ')';
+ terminator = CHAR_RIGHT_PARENTHESIS;
/* Come here from the \g<...> and \g'...' code (Oniguruma
compatibility). However, the syntax has been checked to ensure that
@@ -4753,7 +4817,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
HANDLE_NUMERICAL_RECURSION:
- if ((refsign = *ptr) == '+')
+ if ((refsign = *ptr) == CHAR_PLUS)
{
ptr++;
if ((digitab[*ptr] & ctype_digit) == 0)
@@ -4762,7 +4826,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
goto FAILED;
}
}
- else if (refsign == '-')
+ else if (refsign == CHAR_MINUS)
{
if ((digitab[ptr[1]] & ctype_digit) == 0)
goto OTHER_CHAR_AFTER_QUERY;
@@ -4771,7 +4835,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
recno = 0;
while((digitab[*ptr] & ctype_digit) != 0)
- recno = recno * 10 + *ptr++ - '0';
+ recno = recno * 10 + *ptr++ - CHAR_0;
if (*ptr != terminator)
{
@@ -4779,7 +4843,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
goto FAILED;
}
- if (refsign == '-')
+ if (refsign == CHAR_MINUS)
{
if (recno == 0)
{
@@ -4793,7 +4857,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
goto FAILED;
}
}
- else if (refsign == '+')
+ else if (refsign == CHAR_PLUS)
{
if (recno == 0)
{
@@ -4879,23 +4943,23 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
set = unset = 0;
optset = &set;
- while (*ptr != ')' && *ptr != ':')
+ while (*ptr != CHAR_RIGHT_PARENTHESIS && *ptr != CHAR_COLON)
{
switch (*ptr++)
{
- case '-': optset = &unset; break;
+ case CHAR_MINUS: optset = &unset; break;
- case 'J': /* Record that it changed in the external options */
+ case CHAR_J: /* Record that it changed in the external options */
*optset |= PCRE_DUPNAMES;
cd->external_flags |= PCRE_JCHANGED;
break;
- case 'i': *optset |= PCRE_CASELESS; break;
- case 'm': *optset |= PCRE_MULTILINE; break;
- case 's': *optset |= PCRE_DOTALL; break;
- case 'x': *optset |= PCRE_EXTENDED; break;
- case 'U': *optset |= PCRE_UNGREEDY; break;
- case 'X': *optset |= PCRE_EXTRA; break;
+ case CHAR_i: *optset |= PCRE_CASELESS; break;
+ case CHAR_m: *optset |= PCRE_MULTILINE; break;
+ case CHAR_s: *optset |= PCRE_DOTALL; break;
+ case CHAR_x: *optset |= PCRE_EXTENDED; break;
+ case CHAR_U: *optset |= PCRE_UNGREEDY; break;
+ case CHAR_X: *optset |= PCRE_EXTRA; break;
default: *errorcodeptr = ERR12;
ptr--; /* Correct the offset */
@@ -4929,7 +4993,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
options if this setting actually changes any of them, and reset the
greedy defaults and the case value for firstbyte and reqbyte. */
- if (*ptr == ')')
+ if (*ptr == CHAR_RIGHT_PARENTHESIS)
{
if (code == cd->start_code + 1 + LINK_SIZE &&
(lengthptr == NULL || *lengthptr == 2 + 2*LINK_SIZE))
@@ -5069,7 +5133,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* Error if hit end of pattern */
- if (*ptr != ')')
+ if (*ptr != CHAR_RIGHT_PARENTHESIS)
{
*errorcodeptr = ERR14;
goto FAILED;
@@ -5167,7 +5231,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
We can test for values between ESC_b and ESC_Z for the latter; this may
have to change if any new ones are ever created. */
- case '\\':
+ case CHAR_BACKSLASH:
tempptr = ptr;
c = check_escape(&ptr, errorcodeptr, cd->bracount, options, FALSE);
if (*errorcodeptr != 0) goto FAILED;
@@ -5176,8 +5240,9 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
{
if (-c == ESC_Q) /* Handle start of quoted string */
{
- if (ptr[1] == '\\' && ptr[2] == 'E') ptr += 2; /* avoid empty string */
- else inescq = TRUE;
+ if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
+ ptr += 2; /* avoid empty string */
+ else inescq = TRUE;
continue;
}
@@ -5205,7 +5270,8 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
{
const uschar *p;
save_hwm = cd->hwm; /* Normally this is set when '(' is read */
- terminator = (*(++ptr) == '<')? '>' : '\'';
+ terminator = (*(++ptr) == CHAR_LESS_THAN_SIGN)?
+ CHAR_GREATER_THAN_SIGN : CHAR_APOSTROPHE;
/* These two statements stop the compiler for warning about possibly
unset variables caused by the jump to HANDLE_NUMERICAL_RECURSION. In
@@ -5217,7 +5283,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* Test for a name */
- if (ptr[1] != '+' && ptr[1] != '-')
+ if (ptr[1] != CHAR_PLUS && ptr[1] != CHAR_MINUS)
{
BOOL isnumber = TRUE;
for (p = ptr + 1; *p != 0 && *p != terminator; p++)
@@ -5255,10 +5321,13 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* \k<name> or \k'name' is a back reference by name (Perl syntax).
We also support \k{name} (.NET syntax) */
- if (-c == ESC_k && (ptr[1] == '<' || ptr[1] == '\'' || ptr[1] == '{'))
+ if (-c == ESC_k && (ptr[1] == CHAR_LESS_THAN_SIGN ||
+ ptr[1] == CHAR_APOSTROPHE || ptr[1] == CHAR_LEFT_CURLY_BRACKET))
{
is_recurse = FALSE;
- terminator = (*(++ptr) == '<')? '>' : (*ptr == '\'')? '\'' : '}';
+ terminator = (*(++ptr) == CHAR_LESS_THAN_SIGN)?
+ CHAR_GREATER_THAN_SIGN : (*ptr == CHAR_APOSTROPHE)?
+ CHAR_APOSTROPHE : CHAR_RIGHT_CURLY_BRACKET;
goto NAMED_REF_OR_RECURSE;
}
@@ -5361,7 +5430,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* Remember if \r or \n were seen */
- if (mcbuffer[0] == '\r' || mcbuffer[0] == '\n')
+ if (mcbuffer[0] == CHAR_CR || mcbuffer[0] == CHAR_NL)
cd->external_flags |= PCRE_HASCRORLF;
/* Set the first and required bytes appropriately. If no previous first
@@ -5606,7 +5675,7 @@ for (;;)
compile a resetting op-code following, except at the very end of the pattern.
Return leaving the pointer at the terminating char. */
- if (*ptr != '|')
+ if (*ptr != CHAR_VERTICAL_LINE)
{
if (lengthptr == NULL)
{
@@ -5629,7 +5698,7 @@ for (;;)
/* Resetting option if needed */
- if ((options & PCRE_IMS) != oldims && *ptr == ')')
+ if ((options & PCRE_IMS) != oldims && *ptr == CHAR_RIGHT_PARENTHESIS)
{
*code++ = OP_OPT;
*code++ = oldims;
@@ -6072,25 +6141,26 @@ cd->ctypes = tables + ctypes_offset;
/* Check for global one-time settings at the start of the pattern, and remember
the offset for later. */
-while (ptr[skipatstart] == '(' && ptr[skipatstart+1] == '*')
+while (ptr[skipatstart] == CHAR_LEFT_PARENTHESIS &&
+ ptr[skipatstart+1] == CHAR_ASTERISK)
{
int newnl = 0;
int newbsr = 0;
- if (strncmp((char *)(ptr+skipatstart+2), "CR)", 3) == 0)
+ if (strncmp((char *)(ptr+skipatstart+2), STRING_CR_RIGHTPAR, 3) == 0)
{ skipatstart += 5; newnl = PCRE_NEWLINE_CR; }
- else if (strncmp((char *)(ptr+skipatstart+2), "LF)", 3) == 0)
+ else if (strncmp((char *)(ptr+skipatstart+2), STRING_LF_RIGHTPAR, 3) == 0)
{ skipatstart += 5; newnl = PCRE_NEWLINE_LF; }
- else if (strncmp((char *)(ptr+skipatstart+2), "CRLF)", 5) == 0)
+ else if (strncmp((char *)(ptr+skipatstart+2), STRING_CRLF_RIGHTPAR, 5) == 0)
{ skipatstart += 7; newnl = PCRE_NEWLINE_CR + PCRE_NEWLINE_LF; }
- else if (strncmp((char *)(ptr+skipatstart+2), "ANY)", 4) == 0)
+ else if (strncmp((char *)(ptr+skipatstart+2), STRING_ANY_RIGHTPAR, 4) == 0)
{ skipatstart += 6; newnl = PCRE_NEWLINE_ANY; }
- else if (strncmp((char *)(ptr+skipatstart+2), "ANYCRLF)", 8) == 0)
+ else if (strncmp((char *)(ptr+skipatstart+2), STRING_ANYCRLF_RIGHTPAR, 8) == 0)
{ skipatstart += 10; newnl = PCRE_NEWLINE_ANYCRLF; }
- else if (strncmp((char *)(ptr+skipatstart+2), "BSR_ANYCRLF)", 12) == 0)
+ else if (strncmp((char *)(ptr+skipatstart+2), STRING_BSR_ANYCRLF_RIGHTPAR, 12) == 0)
{ skipatstart += 14; newbsr = PCRE_BSR_ANYCRLF; }
- else if (strncmp((char *)(ptr+skipatstart+2), "BSR_UNICODE)", 12) == 0)
+ else if (strncmp((char *)(ptr+skipatstart+2), STRING_BSR_UNICODE_RIGHTPAR, 12) == 0)
{ skipatstart += 14; newbsr = PCRE_BSR_UNICODE; }
if (newnl != 0)
@@ -6118,10 +6188,10 @@ current code allows for fixed one- or two-byte sequences, plus "any" and
switch (options & PCRE_NEWLINE_BITS)
{
case 0: newline = NEWLINE; break; /* Build-time default */
- case PCRE_NEWLINE_CR: newline = '\r'; break;
- case PCRE_NEWLINE_LF: newline = '\n'; break;
+ case PCRE_NEWLINE_CR: newline = CHAR_CR; break;
+ case PCRE_NEWLINE_LF: newline = CHAR_NL; break;
case PCRE_NEWLINE_CR+
- PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
+ PCRE_NEWLINE_LF: newline = (CHAR_CR << 8) | CHAR_NL; break;
case PCRE_NEWLINE_ANY: newline = -1; break;
case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN;
diff --git a/pcre_dfa_exec.c b/pcre_dfa_exec.c
index 248a6b1..c728501 100644
--- a/pcre_dfa_exec.c
+++ b/pcre_dfa_exec.c
@@ -2615,10 +2615,10 @@ switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)option
PCRE_NEWLINE_BITS)
{
case 0: newline = NEWLINE; break; /* Compile-time default */
- case PCRE_NEWLINE_CR: newline = '\r'; break;
- case PCRE_NEWLINE_LF: newline = '\n'; break;
+ case PCRE_NEWLINE_CR: newline = CHAR_CR; break;
+ case PCRE_NEWLINE_LF: newline = CHAR_NL; break;
case PCRE_NEWLINE_CR+
- PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
+ PCRE_NEWLINE_LF: newline = (CHAR_CR << 8) | CHAR_NL; break;
case PCRE_NEWLINE_ANY: newline = -1; break;
case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
default: return PCRE_ERROR_BADNEWLINE;
@@ -2797,10 +2797,10 @@ for (;;)
ANYCRLF, and we are now at a LF, advance the match position by one
more character. */
- if (current_subject[-1] == '\r' &&
+ if (current_subject[-1] == CHAR_CR &&
(md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
current_subject < end_subject &&
- *current_subject == '\n')
+ *current_subject == CHAR_NL)
current_subject++;
}
}
@@ -2916,9 +2916,9 @@ for (;;)
not contain any explicit matches for \r or \n, and the newline option is CRLF
or ANY or ANYCRLF, advance the match position by one more character. */
- if (current_subject[-1] == '\r' &&
+ if (current_subject[-1] == CHAR_CR &&
current_subject < end_subject &&
- *current_subject == '\n' &&
+ *current_subject == CHAR_NL &&
(re->flags & PCRE_HASCRORLF) == 0 &&
(md->nltype == NLTYPE_ANY ||
md->nltype == NLTYPE_ANYCRLF ||
diff --git a/pcre_exec.c b/pcre_exec.c
index 28b9b93..39726bc 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -4562,10 +4562,10 @@ switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options :
(pcre_uint32)options) & PCRE_NEWLINE_BITS)
{
case 0: newline = NEWLINE; break; /* Compile-time default */
- case PCRE_NEWLINE_CR: newline = '\r'; break;
- case PCRE_NEWLINE_LF: newline = '\n'; break;
+ case PCRE_NEWLINE_CR: newline = CHAR_CR; break;
+ case PCRE_NEWLINE_LF: newline = CHAR_NL; break;
case PCRE_NEWLINE_CR+
- PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
+ PCRE_NEWLINE_LF: newline = (CHAR_CR << 8) | CHAR_NL; break;
case PCRE_NEWLINE_ANY: newline = -1; break;
case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
default: return PCRE_ERROR_BADNEWLINE;
@@ -4785,10 +4785,10 @@ for(;;)
and we are now at a LF, advance the match position by one more character.
*/
- if (start_match[-1] == '\r' &&
+ if (start_match[-1] == CHAR_CR &&
(md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
start_match < end_subject &&
- *start_match == '\n')
+ *start_match == CHAR_NL)
start_match++;
}
}
@@ -4942,9 +4942,9 @@ for(;;)
not contain any explicit matches for \r or \n, and the newline option is CRLF
or ANY or ANYCRLF, advance the match position by one more character. */
- if (start_match[-1] == '\r' &&
+ if (start_match[-1] == CHAR_CR &&
start_match < end_subject &&
- *start_match == '\n' &&
+ *start_match == CHAR_NL &&
(re->flags & PCRE_HASCRORLF) == 0 &&
(md->nltype == NLTYPE_ANY ||
md->nltype == NLTYPE_ANYCRLF ||
diff --git a/pcre_internal.h b/pcre_internal.h
index de46426..4bfdf4a 100644
--- a/pcre_internal.h
+++ b/pcre_internal.h
@@ -51,6 +51,13 @@ functions whose names all begin with "_pcre_". */
#define DEBUG
#endif
+/* We do not support both EBCDIC and UTF-8 at the same time. The "configure"
+script prevents both being selected, but not everybody uses "configure". */
+
+#if defined EBCDIC && defined SUPPORT_UTF8
+#error The use of both EBCDIC and SUPPORT_UTF8 is not supported.
+#endif
+
/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
inline, and there are *still* stupid compilers about that don't like indented
pre-processor statements, or at least there were when I first wrote this. After
@@ -591,29 +598,559 @@ typedef int BOOL;
#define TRUE 1
#endif
+/* If PCRE is to support UTF-8 on EBCDIC platforms, we cannot use normal
+character constants like '*' because the compiler would emit their EBCDIC code,
+which is different from their ASCII/UTF-8 code. Instead we define macros for
+the characters so that they always use the ASCII/UTF-8 code when UTF-8 support
+is enabled. When UTF-8 support is not enabled, the definitions use character
+literals. Both character and string versions of each character are needed, and
+there are some longer strings as well.
+
+This means that, on EBCDIC platforms, the PCRE library can handle either
+EBCDIC, or UTF-8, but not both. To support both in the same compiled library
+would need different lookups depending on whether PCRE_UTF8 was set or not.
+This would make it impossible to use characters in switch/case statements,
+which would reduce performance. For a theoretical use (which nobody has asked
+for) in a minority area (EBCDIC platforms), this is not sensible. Any
+application that did need both could compile two versions of the library, using
+macros to give the functions distinct names. */
+
+#ifndef SUPPORT_UTF8
+
+/* 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. */
+
+#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 '!'
+#define CHAR_QUOTATION_MARK '"'
+#define CHAR_NUMBER_SIGN '#'
+#define CHAR_DOLLAR_SIGN '$'
+#define CHAR_PERCENT_SIGN '%'
+#define CHAR_AMPERSAND '&'
+#define CHAR_APOSTROPHE '\''
+#define CHAR_LEFT_PARENTHESIS '('
+#define CHAR_RIGHT_PARENTHESIS ')'
+#define CHAR_ASTERISK '*'
+#define CHAR_PLUS '+'
+#define CHAR_COMMA ','
+#define CHAR_MINUS '-'
+#define CHAR_DOT '.'
+#define CHAR_SLASH '/'
+#define CHAR_0 '0'
+#define CHAR_1 '1'
+#define CHAR_2 '2'
+#define CHAR_3 '3'
+#define CHAR_4 '4'
+#define CHAR_5 '5'
+#define CHAR_6 '6'
+#define CHAR_7 '7'
+#define CHAR_8 '8'
+#define CHAR_9 '9'
+#define CHAR_COLON ':'
+#define CHAR_SEMICOLON ';'
+#define CHAR_LESS_THAN_SIGN '<'
+#define CHAR_EQUALS_SIGN '='
+#define CHAR_GREATER_THAN_SIGN '>'
+#define CHAR_QUESTION_MARK '?'
+#define CHAR_COMMERCIAL_AT '@'
+#define CHAR_A 'A'
+#define CHAR_B 'B'
+#define CHAR_C 'C'
+#define CHAR_D 'D'
+#define CHAR_E 'E'
+#define CHAR_F 'F'
+#define CHAR_G 'G'
+#define CHAR_H 'H'
+#define CHAR_I 'I'
+#define CHAR_J 'J'
+#define CHAR_K 'K'
+#define CHAR_L 'L'
+#define CHAR_M 'M'
+#define CHAR_N 'N'
+#define CHAR_O 'O'
+#define CHAR_P 'P'
+#define CHAR_Q 'Q'
+#define CHAR_R 'R'
+#define CHAR_S 'S'
+#define CHAR_T 'T'
+#define CHAR_U 'U'
+#define CHAR_V 'V'
+#define CHAR_W 'W'
+#define CHAR_X 'X'
+#define CHAR_Y 'Y'
+#define CHAR_Z 'Z'
+#define CHAR_LEFT_SQUARE_BRACKET '['
+#define CHAR_BACKSLASH '\\'
+#define CHAR_RIGHT_SQUARE_BRACKET ']'
+#define CHAR_CIRCUMFLEX_ACCENT '^'
+#define CHAR_UNDERSCORE '_'
+#define CHAR_GRAVE_ACCENT '`'
+#define CHAR_a 'a'
+#define CHAR_b 'b'
+#define CHAR_c 'c'
+#define CHAR_d 'd'
+#define CHAR_e 'e'
+#define CHAR_f 'f'
+#define CHAR_g 'g'
+#define CHAR_h 'h'
+#define CHAR_i 'i'
+#define CHAR_j 'j'
+#define CHAR_k 'k'
+#define CHAR_l 'l'
+#define CHAR_m 'm'
+#define CHAR_n 'n'
+#define CHAR_o 'o'
+#define CHAR_p 'p'
+#define CHAR_q 'q'
+#define CHAR_r 'r'
+#define CHAR_s 's'
+#define CHAR_t 't'
+#define CHAR_u 'u'
+#define CHAR_v 'v'
+#define CHAR_w 'w'
+#define CHAR_x 'x'
+#define CHAR_y 'y'
+#define CHAR_z 'z'
+#define CHAR_LEFT_CURLY_BRACKET '{'
+#define CHAR_VERTICAL_LINE '|'
+#define CHAR_RIGHT_CURLY_BRACKET '}'
+#define CHAR_TILDE '~'
+
+#define STR_HT "\t"
+#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 "!"
+#define STR_QUOTATION_MARK "\""
+#define STR_NUMBER_SIGN "#"
+#define STR_DOLLAR_SIGN "$"
+#define STR_PERCENT_SIGN "%"
+#define STR_AMPERSAND "&"
+#define STR_APOSTROPHE "'"
+#define STR_LEFT_PARENTHESIS "("
+#define STR_RIGHT_PARENTHESIS ")"
+#define STR_ASTERISK "*"
+#define STR_PLUS "+"
+#define STR_COMMA ","
+#define STR_MINUS "-"
+#define STR_DOT "."
+#define STR_SLASH "/"
+#define STR_0 "0"
+#define STR_1 "1"
+#define STR_2 "2"
+#define STR_3 "3"
+#define STR_4 "4"
+#define STR_5 "5"
+#define STR_6 "6"
+#define STR_7 "7"
+#define STR_8 "8"
+#define STR_9 "9"
+#define STR_COLON ":"
+#define STR_SEMICOLON ";"
+#define STR_LESS_THAN_SIGN "<"
+#define STR_EQUALS_SIGN "="
+#define STR_GREATER_THAN_SIGN ">"
+#define STR_QUESTION_MARK "?"
+#define STR_COMMERCIAL_AT "@"
+#define STR_A "A"
+#define STR_B "B"
+#define STR_C "C"
+#define STR_D "D"
+#define STR_E "E"
+#define STR_F "F"
+#define STR_G "G"
+#define STR_H "H"
+#define STR_I "I"
+#define STR_J "J"
+#define STR_K "K"
+#define STR_L "L"
+#define STR_M "M"
+#define STR_N "N"
+#define STR_O "O"
+#define STR_P "P"
+#define STR_Q "Q"
+#define STR_R "R"
+#define STR_S "S"
+#define STR_T "T"
+#define STR_U "U"
+#define STR_V "V"
+#define STR_W "W"
+#define STR_X "X"
+#define STR_Y "Y"
+#define STR_Z "Z"
+#define STR_LEFT_SQUARE_BRACKET "["
+#define STR_BACKSLASH "\\"
+#define STR_RIGHT_SQUARE_BRACKET "]"
+#define STR_CIRCUMFLEX_ACCENT "^"
+#define STR_UNDERSCORE "_"
+#define STR_GRAVE_ACCENT "`"
+#define STR_a "a"
+#define STR_b "b"
+#define STR_c "c"
+#define STR_d "d"
+#define STR_e "e"
+#define STR_f "f"
+#define STR_g "g"
+#define STR_h "h"
+#define STR_i "i"
+#define STR_j "j"
+#define STR_k "k"
+#define STR_l "l"
+#define STR_m "m"
+#define STR_n "n"
+#define STR_o "o"
+#define STR_p "p"
+#define STR_q "q"
+#define STR_r "r"
+#define STR_s "s"
+#define STR_t "t"
+#define STR_u "u"
+#define STR_v "v"
+#define STR_w "w"
+#define STR_x "x"
+#define STR_y "y"
+#define STR_z "z"
+#define STR_LEFT_CURLY_BRACKET "{"
+#define STR_VERTICAL_LINE "|"
+#define STR_RIGHT_CURLY_BRACKET "}"
+#define STR_TILDE "~"
+
+#define STRING_ACCEPT0 "ACCEPT\0"
+#define STRING_COMMIT0 "COMMIT\0"
+#define STRING_F0 "F\0"
+#define STRING_FAIL0 "FAIL\0"
+#define STRING_PRUNE0 "PRUNE\0"
+#define STRING_SKIP0 "SKIP\0"
+#define STRING_THEN "THEN"
+
+#define STRING_alpha0 "alpha\0"
+#define STRING_lower0 "lower\0"
+#define STRING_upper0 "upper\0"
+#define STRING_alnum0 "alnum\0"
+#define STRING_ascii0 "ascii\0"
+#define STRING_blank0 "blank\0"
+#define STRING_cntrl0 "cntrl\0"
+#define STRING_digit0 "digit\0"
+#define STRING_graph0 "graph\0"
+#define STRING_print0 "print\0"
+#define STRING_punct0 "punct\0"
+#define STRING_space0 "space\0"
+#define STRING_word0 "word\0"
+#define STRING_xdigit "xdigit"
+
+#define STRING_DEFINE "DEFINE"
+
+#define STRING_CR_RIGHTPAR "CR)"
+#define STRING_LF_RIGHTPAR "LF)"
+#define STRING_CRLF_RIGHTPAR "CRLF)"
+#define STRING_ANY_RIGHTPAR "ANY)"
+#define STRING_ANYCRLF_RIGHTPAR "ANYCRLF)"
+#define STRING_BSR_ANYCRLF_RIGHTPAR "BSR_ANYCRLF)"
+#define STRING_BSR_UNICODE_RIGHTPAR "BSR_UNICODE)"
+
+#else /* SUPPORT_UTF8 */
+
+/* UTF-8 support is enabled; always use UTF-8 (=ASCII) character codes. This
+works in both modes non-EBCDIC platforms, and on EBCDIC platforms in UTF-8 mode
+only. */
+
+#define CHAR_HT '\011'
+#define CHAR_VT '\013'
+#define CHAR_FF '\014'
+#define CHAR_CR '\015'
+#define CHAR_NL '\012'
+#define CHAR_BS '\010'
+#define CHAR_BEL '\007'
+#define CHAR_ESC '\033'
+#define CHAR_DEL '\177'
+
+#define CHAR_SPACE '\040'
+#define CHAR_EXCLAMATION_MARK '\041'
+#define CHAR_QUOTATION_MARK '\042'
+#define CHAR_NUMBER_SIGN '\043'
+#define CHAR_DOLLAR_SIGN '\044'
+#define CHAR_PERCENT_SIGN '\045'
+#define CHAR_AMPERSAND '\046'
+#define CHAR_APOSTROPHE '\047'
+#define CHAR_LEFT_PARENTHESIS '\050'
+#define CHAR_RIGHT_PARENTHESIS '\051'
+#define CHAR_ASTERISK '\052'
+#define CHAR_PLUS '\053'
+#define CHAR_COMMA '\054'
+#define CHAR_MINUS '\055'
+#define CHAR_DOT '\056'
+#define CHAR_SLASH '\057'
+#define CHAR_0 '\060'
+#define CHAR_1 '\061'
+#define CHAR_2 '\062'
+#define CHAR_3 '\063'
+#define CHAR_4 '\064'
+#define CHAR_5 '\065'
+#define CHAR_6 '\066'
+#define CHAR_7 '\067'
+#define CHAR_8 '\070'
+#define CHAR_9 '\071'
+#define CHAR_COLON '\072'
+#define CHAR_SEMICOLON '\073'
+#define CHAR_LESS_THAN_SIGN '\074'
+#define CHAR_EQUALS_SIGN '\075'
+#define CHAR_GREATER_THAN_SIGN '\076'
+#define CHAR_QUESTION_MARK '\077'
+#define CHAR_COMMERCIAL_AT '\100'
+#define CHAR_A '\101'
+#define CHAR_B '\102'
+#define CHAR_C '\103'
+#define CHAR_D '\104'
+#define CHAR_E '\105'
+#define CHAR_F '\106'
+#define CHAR_G '\107'
+#define CHAR_H '\110'
+#define CHAR_I '\111'
+#define CHAR_J '\112'
+#define CHAR_K '\113'
+#define CHAR_L '\114'
+#define CHAR_M '\115'
+#define CHAR_N '\116'
+#define CHAR_O '\117'
+#define CHAR_P '\120'
+#define CHAR_Q '\121'
+#define CHAR_R '\122'
+#define CHAR_S '\123'
+#define CHAR_T '\124'
+#define CHAR_U '\125'
+#define CHAR_V '\126'
+#define CHAR_W '\127'
+#define CHAR_X '\130'
+#define CHAR_Y '\131'
+#define CHAR_Z '\132'
+#define CHAR_LEFT_SQUARE_BRACKET '\133'
+#define CHAR_BACKSLASH '\134'
+#define CHAR_RIGHT_SQUARE_BRACKET '\135'
+#define CHAR_CIRCUMFLEX_ACCENT '\136'
+#define CHAR_UNDERSCORE '\137'
+#define CHAR_GRAVE_ACCENT '\140'
+#define CHAR_a '\141'
+#define CHAR_b '\142'
+#define CHAR_c '\143'
+#define CHAR_d '\144'
+#define CHAR_e '\145'
+#define CHAR_f '\146'
+#define CHAR_g '\147'
+#define CHAR_h '\150'
+#define CHAR_i '\151'
+#define CHAR_j '\152'
+#define CHAR_k '\153'
+#define CHAR_l '\154'
+#define CHAR_m '\155'
+#define CHAR_n '\156'
+#define CHAR_o '\157'
+#define CHAR_p '\160'
+#define CHAR_q '\161'
+#define CHAR_r '\162'
+#define CHAR_s '\163'
+#define CHAR_t '\164'
+#define CHAR_u '\165'
+#define CHAR_v '\166'
+#define CHAR_w '\167'
+#define CHAR_x '\170'
+#define CHAR_y '\171'
+#define CHAR_z '\172'
+#define CHAR_LEFT_CURLY_BRACKET '\173'
+#define CHAR_VERTICAL_LINE '\174'
+#define CHAR_RIGHT_CURLY_BRACKET '\175'
+#define CHAR_TILDE '\176'
+
+#define STR_HT "\011"
+#define STR_VT "\013"
+#define STR_FF "\014"
+#define STR_CR "\015"
+#define STR_NL "\012"
+#define STR_BS "\010"
+#define STR_BEL "\007"
+#define STR_ESC "\033"
+#define STR_DEL "\177"
+
+#define STR_SPACE "\040"
+#define STR_EXCLAMATION_MARK "\041"
+#define STR_QUOTATION_MARK "\042"
+#define STR_NUMBER_SIGN "\043"
+#define STR_DOLLAR_SIGN "\044"
+#define STR_PERCENT_SIGN "\045"
+#define STR_AMPERSAND "\046"
+#define STR_APOSTROPHE "\047"
+#define STR_LEFT_PARENTHESIS "\050"
+#define STR_RIGHT_PARENTHESIS "\051"
+#define STR_ASTERISK "\052"
+#define STR_PLUS "\053"
+#define STR_COMMA "\054"
+#define STR_MINUS "\055"
+#define STR_DOT "\056"
+#define STR_SLASH "\057"
+#define STR_0 "\060"
+#define STR_1 "\061"
+#define STR_2 "\062"
+#define STR_3 "\063"
+#define STR_4 "\064"
+#define STR_5 "\065"
+#define STR_6 "\066"
+#define STR_7 "\067"
+#define STR_8 "\070"
+#define STR_9 "\071"
+#define STR_COLON "\072"
+#define STR_SEMICOLON "\073"
+#define STR_LESS_THAN_SIGN "\074"
+#define STR_EQUALS_SIGN "\075"
+#define STR_GREATER_THAN_SIGN "\076"
+#define STR_QUESTION_MARK "\077"
+#define STR_COMMERCIAL_AT "\100"
+#define STR_A "\101"
+#define STR_B "\102"
+#define STR_C "\103"
+#define STR_D "\104"
+#define STR_E "\105"
+#define STR_F "\106"
+#define STR_G "\107"
+#define STR_H "\110"
+#define STR_I "\111"
+#define STR_J "\112"
+#define STR_K "\113"
+#define STR_L "\114"
+#define STR_M "\115"
+#define STR_N "\116"
+#define STR_O "\117"
+#define STR_P "\120"
+#define STR_Q "\121"
+#define STR_R "\122"
+#define STR_S "\123"
+#define STR_T "\124"
+#define STR_U "\125"
+#define STR_V "\126"
+#define STR_W "\127"
+#define STR_X "\130"
+#define STR_Y "\131"
+#define STR_Z "\132"
+#define STR_LEFT_SQUARE_BRACKET "\133"
+#define STR_BACKSLASH "\134"
+#define STR_RIGHT_SQUARE_BRACKET "\135"
+#define STR_CIRCUMFLEX_ACCENT "\136"
+#define STR_UNDERSCORE "\137"
+#define STR_GRAVE_ACCENT "\140"
+#define STR_a "\141"
+#define STR_b "\142"
+#define STR_c "\143"
+#define STR_d "\144"
+#define STR_e "\145"
+#define STR_f "\146"
+#define STR_g "\147"
+#define STR_h "\150"
+#define STR_i "\151"
+#define STR_j "\152"
+#define STR_k "\153"
+#define STR_l "\154"
+#define STR_m "\155"
+#define STR_n "\156"
+#define STR_o "\157"
+#define STR_p "\160"
+#define STR_q "\161"
+#define STR_r "\162"
+#define STR_s "\163"
+#define STR_t "\164"
+#define STR_u "\165"
+#define STR_v "\166"
+#define STR_w "\167"
+#define STR_x "\170"
+#define STR_y "\171"
+#define STR_z "\172"
+#define STR_LEFT_CURLY_BRACKET "\173"
+#define STR_VERTICAL_LINE "\174"
+#define STR_RIGHT_CURLY_BRACKET "\175"
+#define STR_TILDE "\176"
+
+#define STRING_ACCEPT0 STR_A STR_C STR_C STR_E STR_P STR_T "\0"
+#define STRING_COMMIT0 STR_C STR_O STR_M STR_M STR_I STR_T "\0"
+#define STRING_F0 STR_F "\0"
+#define STRING_FAIL0 STR_F STR_A STR_I STR_L "\0"
+#define STRING_PRUNE0 STR_P STR_R STR_U STR_N STR_E "\0"
+#define STRING_SKIP0 STR_S STR_K STR_I STR_P "\0"
+#define STRING_THEN STR_T STR_H STR_E STR_N
+
+#define STRING_alpha0 STR_a STR_l STR_p STR_h STR_a "\0"
+#define STRING_lower0 STR_l STR_o STR_w STR_e STR_r "\0"
+#define STRING_upper0 STR_u STR_p STR_p STR_e STR_r "\0"
+#define STRING_alnum0 STR_a STR_l STR_n STR_u STR_m "\0"
+#define STRING_ascii0 STR_a STR_s STR_c STR_i STR_i "\0"
+#define STRING_blank0 STR_b STR_l STR_a STR_n STR_k "\0"
+#define STRING_cntrl0 STR_c STR_n STR_t STR_r STR_l "\0"
+#define STRING_digit0 STR_d STR_i STR_g STR_i STR_t "\0"
+#define STRING_graph0 STR_g STR_r STR_a STR_p STR_h "\0"
+#define STRING_print0 STR_p STR_r STR_i STR_n STR_t "\0"
+#define STRING_punct0 STR_p STR_u STR_n STR_c STR_t "\0"
+#define STRING_space0 STR_s STR_p STR_a STR_c STR_e "\0"
+#define STRING_word0 STR_w STR_o STR_r STR_d "\0"
+#define STRING_xdigit STR_x STR_d STR_i STR_g STR_i STR_t
+
+#define STRING_DEFINE STR_D STR_E STR_F STR_I STR_N STR_E
+
+#define STRING_CR_RIGHTPAR STR_C STR_R STR_RIGHT_PARENTHESIS
+#define STRING_LF_RIGHTPAR STR_L STR_F STR_RIGHT_PARENTHESIS
+#define STRING_CRLF_RIGHTPAR STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
+#define STRING_ANY_RIGHTPAR STR_A STR_N STR_Y STR_RIGHT_PARENTHESIS
+#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
+
+#endif /* SUPPORT_UTF8 */
+
/* Escape items that are just an encoding of a particular data value. */
#ifndef ESC_e
-#define ESC_e 27
+#define ESC_e CHAR_ESC
#endif
#ifndef ESC_f
-#define ESC_f '\f'
+#define ESC_f CHAR_FF
#endif
#ifndef ESC_n
-#define ESC_n '\n'
+#define ESC_n CHAR_NL
#endif
#ifndef ESC_r
-#define ESC_r '\r'
+#define ESC_r CHAR_CR
#endif
/* We can't officially use ESC_t because it is a POSIX reserved identifier
(presumably because of all the others like size_t). */
#ifndef ESC_tee
-#define ESC_tee '\t'
+#define ESC_tee CHAR_HT
#endif
/* Codes for different types of Unicode property */
diff --git a/pcre_printint.src b/pcre_printint.src
index 98b42aa..5f45fc1 100644
--- a/pcre_printint.src
+++ b/pcre_printint.src
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2008 University of Cambridge
+ Copyright (c) 1997-2009 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -54,7 +54,11 @@ hexadecimal. We don't use isprint() because that can vary from system to system
(even without the use of locales) and we want the output always to be the same,
for testing purposes. This macro is used in pcretest as well as in this file. */
+#ifdef EBCDIC
+#define PRINTABLE(c) ((c) >= 64 && (c) < 255)
+#else
#define PRINTABLE(c) ((c) >= 32 && (c) < 127)
+#endif
/* The table of operator names. */
diff --git a/pcre_tables.c b/pcre_tables.c
index 160bc5d..f1a8de4 100644
--- a/pcre_tables.c
+++ b/pcre_tables.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2008 University of Cambridge
+ Copyright (c) 1997-2009 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -109,126 +109,248 @@ putting all the names into a single, large string and then using offsets in the
table itself. Maintenance is more error-prone, but frequent changes to this
data are unlikely.
-July 2008: There is now a script called maint/GenerateUtt.py which can be used
-to generate this data instead of maintaining it entirely by hand. */
-
-const char _pcre_utt_names[] =
- "Any\0"
- "Arabic\0"
- "Armenian\0"
- "Balinese\0"
- "Bengali\0"
- "Bopomofo\0"
- "Braille\0"
- "Buginese\0"
- "Buhid\0"
- "C\0"
- "Canadian_Aboriginal\0"
- "Carian\0"
- "Cc\0"
- "Cf\0"
- "Cham\0"
- "Cherokee\0"
- "Cn\0"
- "Co\0"
- "Common\0"
- "Coptic\0"
- "Cs\0"
- "Cuneiform\0"
- "Cypriot\0"
- "Cyrillic\0"
- "Deseret\0"
- "Devanagari\0"
- "Ethiopic\0"
- "Georgian\0"
- "Glagolitic\0"
- "Gothic\0"
- "Greek\0"
- "Gujarati\0"
- "Gurmukhi\0"
- "Han\0"
- "Hangul\0"
- "Hanunoo\0"
- "Hebrew\0"
- "Hiragana\0"
- "Inherited\0"
- "Kannada\0"
- "Katakana\0"
- "Kayah_Li\0"
- "Kharoshthi\0"
- "Khmer\0"
- "L\0"
- "L&\0"
- "Lao\0"
- "Latin\0"
- "Lepcha\0"
- "Limbu\0"
- "Linear_B\0"
- "Ll\0"
- "Lm\0"
- "Lo\0"
- "Lt\0"
- "Lu\0"
- "Lycian\0"
- "Lydian\0"
- "M\0"
- "Malayalam\0"
- "Mc\0"
- "Me\0"
- "Mn\0"
- "Mongolian\0"
- "Myanmar\0"
- "N\0"
- "Nd\0"
- "New_Tai_Lue\0"
- "Nko\0"
- "Nl\0"
- "No\0"
- "Ogham\0"
- "Ol_Chiki\0"
- "Old_Italic\0"
- "Old_Persian\0"
- "Oriya\0"
- "Osmanya\0"
- "P\0"
- "Pc\0"
- "Pd\0"
- "Pe\0"
- "Pf\0"
- "Phags_Pa\0"
- "Phoenician\0"
- "Pi\0"
- "Po\0"
- "Ps\0"
- "Rejang\0"
- "Runic\0"
- "S\0"
- "Saurashtra\0"
- "Sc\0"
- "Shavian\0"
- "Sinhala\0"
- "Sk\0"
- "Sm\0"
- "So\0"
- "Sundanese\0"
- "Syloti_Nagri\0"
- "Syriac\0"
- "Tagalog\0"
- "Tagbanwa\0"
- "Tai_Le\0"
- "Tamil\0"
- "Telugu\0"
- "Thaana\0"
- "Thai\0"
- "Tibetan\0"
- "Tifinagh\0"
- "Ugaritic\0"
- "Vai\0"
- "Yi\0"
- "Z\0"
- "Zl\0"
- "Zp\0"
- "Zs\0";
+July 2008: There is now a script called maint/GenerateUtt.py that can be used
+to generate this data instead of maintaining it entirely by hand.
+
+The script was updated in March 2009 to generate a new EBCDIC-compliant
+version. Like all other character and string literals that are compared against
+the regular expression pattern, we must use STR_ macros instead of literal
+strings to make sure that UTF-8 support works on EBCDIC platforms. */
+
+#define STRING_Any0 STR_A STR_n STR_y "\0"
+#define STRING_Arabic0 STR_A STR_r STR_a STR_b STR_i STR_c "\0"
+#define STRING_Armenian0 STR_A STR_r STR_m STR_e STR_n STR_i STR_a STR_n "\0"
+#define STRING_Balinese0 STR_B STR_a STR_l STR_i STR_n STR_e STR_s STR_e "\0"
+#define STRING_Bengali0 STR_B STR_e STR_n STR_g STR_a STR_l STR_i "\0"
+#define STRING_Bopomofo0 STR_B STR_o STR_p STR_o STR_m STR_o STR_f STR_o "\0"
+#define STRING_Braille0 STR_B STR_r STR_a STR_i STR_l STR_l STR_e "\0"
+#define STRING_Buginese0 STR_B STR_u STR_g STR_i STR_n STR_e STR_s STR_e "\0"
+#define STRING_Buhid0 STR_B STR_u STR_h STR_i STR_d "\0"
+#define STRING_C0 STR_C "\0"
+#define STRING_Canadian_Aboriginal0 STR_C STR_a STR_n STR_a STR_d STR_i STR_a STR_n STR_UNDERSCORE STR_A STR_b STR_o STR_r STR_i STR_g STR_i STR_n STR_a STR_l "\0"
+#define STRING_Carian0 STR_C STR_a STR_r STR_i STR_a STR_n "\0"
+#define STRING_Cc0 STR_C STR_c "\0"
+#define STRING_Cf0 STR_C STR_f "\0"
+#define STRING_Cham0 STR_C STR_h STR_a STR_m "\0"
+#define STRING_Cherokee0 STR_C STR_h STR_e STR_r STR_o STR_k STR_e STR_e "\0"
+#define STRING_Cn0 STR_C STR_n "\0"
+#define STRING_Co0 STR_C STR_o "\0"
+#define STRING_Common0 STR_C STR_o STR_m STR_m STR_o STR_n "\0"
+#define STRING_Coptic0 STR_C STR_o STR_p STR_t STR_i STR_c "\0"
+#define STRING_Cs0 STR_C STR_s "\0"
+#define STRING_Cuneiform0 STR_C STR_u STR_n STR_e STR_i STR_f STR_o STR_r STR_m "\0"
+#define STRING_Cypriot0 STR_C STR_y STR_p STR_r STR_i STR_o STR_t "\0"
+#define STRING_Cyrillic0 STR_C STR_y STR_r STR_i STR_l STR_l STR_i STR_c "\0"
+#define STRING_Deseret0 STR_D STR_e STR_s STR_e STR_r STR_e STR_t "\0"
+#define STRING_Devanagari0 STR_D STR_e STR_v STR_a STR_n STR_a STR_g STR_a STR_r STR_i "\0"
+#define STRING_Ethiopic0 STR_E STR_t STR_h STR_i STR_o STR_p STR_i STR_c "\0"
+#define STRING_Georgian0 STR_G STR_e STR_o STR_r STR_g STR_i STR_a STR_n "\0"
+#define STRING_Glagolitic0 STR_G STR_l STR_a STR_g STR_o STR_l STR_i STR_t STR_i STR_c "\0"
+#define STRING_Gothic0 STR_G STR_o STR_t STR_h STR_i STR_c "\0"
+#define STRING_Greek0 STR_G STR_r STR_e STR_e STR_k "\0"
+#define STRING_Gujarati0 STR_G STR_u STR_j STR_a STR_r STR_a STR_t STR_i "\0"
+#define STRING_Gurmukhi0 STR_G STR_u STR_r STR_m STR_u STR_k STR_h STR_i "\0"
+#define STRING_Han0 STR_H STR_a STR_n "\0"
+#define STRING_Hangul0 STR_H STR_a STR_n STR_g STR_u STR_l "\0"
+#define STRING_Hanunoo0 STR_H STR_a STR_n STR_u STR_n STR_o STR_o "\0"
+#define STRING_Hebrew0 STR_H STR_e STR_b STR_r STR_e STR_w "\0"
+#define STRING_Hiragana0 STR_H STR_i STR_r STR_a STR_g STR_a STR_n STR_a "\0"
+#define STRING_Inherited0 STR_I STR_n STR_h STR_e STR_r STR_i STR_t STR_e STR_d "\0"
+#define STRING_Kannada0 STR_K STR_a STR_n STR_n STR_a STR_d STR_a "\0"
+#define STRING_Katakana0 STR_K STR_a STR_t STR_a STR_k STR_a STR_n STR_a "\0"
+#define STRING_Kayah_Li0 STR_K STR_a STR_y STR_a STR_h STR_UNDERSCORE STR_L STR_i "\0"
+#define STRING_Kharoshthi0 STR_K STR_h STR_a STR_r STR_o STR_s STR_h STR_t STR_h STR_i "\0"
+#define STRING_Khmer0 STR_K STR_h STR_m STR_e STR_r "\0"
+#define STRING_L0 STR_L "\0"
+#define STRING_L_AMPERSAND0 STR_L STR_AMPERSAND "\0"
+#define STRING_Lao0 STR_L STR_a STR_o "\0"
+#define STRING_Latin0 STR_L STR_a STR_t STR_i STR_n "\0"
+#define STRING_Lepcha0 STR_L STR_e STR_p STR_c STR_h STR_a "\0"
+#define STRING_Limbu0 STR_L STR_i STR_m STR_b STR_u "\0"
+#define STRING_Linear_B0 STR_L STR_i STR_n STR_e STR_a STR_r STR_UNDERSCORE STR_B "\0"
+#define STRING_Ll0 STR_L STR_l "\0"
+#define STRING_Lm0 STR_L STR_m "\0"
+#define STRING_Lo0 STR_L STR_o "\0"
+#define STRING_Lt0 STR_L STR_t "\0"
+#define STRING_Lu0 STR_L STR_u "\0"
+#define STRING_Lycian0 STR_L STR_y STR_c STR_i STR_a STR_n "\0"
+#define STRING_Lydian0 STR_L STR_y STR_d STR_i STR_a STR_n "\0"
+#define STRING_M0 STR_M "\0"
+#define STRING_Malayalam0 STR_M STR_a STR_l STR_a STR_y STR_a STR_l STR_a STR_m "\0"
+#define STRING_Mc0 STR_M STR_c "\0"
+#define STRING_Me0 STR_M STR_e "\0"
+#define STRING_Mn0 STR_M STR_n "\0"
+#define STRING_Mongolian0 STR_M STR_o STR_n STR_g STR_o STR_l STR_i STR_a STR_n "\0"
+#define STRING_Myanmar0 STR_M STR_y STR_a STR_n STR_m STR_a STR_r "\0"
+#define STRING_N0 STR_N "\0"
+#define STRING_Nd0 STR_N STR_d "\0"
+#define STRING_New_Tai_Lue0 STR_N STR_e STR_w STR_UNDERSCORE STR_T STR_a STR_i STR_UNDERSCORE STR_L STR_u STR_e "\0"
+#define STRING_Nko0 STR_N STR_k STR_o "\0"
+#define STRING_Nl0 STR_N STR_l "\0"
+#define STRING_No0 STR_N STR_o "\0"
+#define STRING_Ogham0 STR_O STR_g STR_h STR_a STR_m "\0"
+#define STRING_Ol_Chiki0 STR_O STR_l STR_UNDERSCORE STR_C STR_h STR_i STR_k STR_i "\0"
+#define STRING_Old_Italic0 STR_O STR_l STR_d STR_UNDERSCORE STR_I STR_t STR_a STR_l STR_i STR_c "\0"
+#define STRING_Old_Persian0 STR_O STR_l STR_d STR_UNDERSCORE STR_P STR_e STR_r STR_s STR_i STR_a STR_n "\0"
+#define STRING_Oriya0 STR_O STR_r STR_i STR_y STR_a "\0"
+#define STRING_Osmanya0 STR_O STR_s STR_m STR_a STR_n STR_y STR_a "\0"
+#define STRING_P0 STR_P "\0"
+#define STRING_Pc0 STR_P STR_c "\0"
+#define STRING_Pd0 STR_P STR_d "\0"
+#define STRING_Pe0 STR_P STR_e "\0"
+#define STRING_Pf0 STR_P STR_f "\0"
+#define STRING_Phags_Pa0 STR_P STR_h STR_a STR_g STR_s STR_UNDERSCORE STR_P STR_a "\0"
+#define STRING_Phoenician0 STR_P STR_h STR_o STR_e STR_n STR_i STR_c STR_i STR_a STR_n "\0"
+#define STRING_Pi0 STR_P STR_i "\0"
+#define STRING_Po0 STR_P STR_o "\0"
+#define STRING_Ps0 STR_P STR_s "\0"
+#define STRING_Rejang0 STR_R STR_e STR_j STR_a STR_n STR_g "\0"
+#define STRING_Runic0 STR_R STR_u STR_n STR_i STR_c "\0"
+#define STRING_S0 STR_S "\0"
+#define STRING_Saurashtra0 STR_S STR_a STR_u STR_r STR_a STR_s STR_h STR_t STR_r STR_a "\0"
+#define STRING_Sc0 STR_S STR_c "\0"
+#define STRING_Shavian0 STR_S STR_h STR_a STR_v STR_i STR_a STR_n "\0"
+#define STRING_Sinhala0 STR_S STR_i STR_n STR_h STR_a STR_l STR_a "\0"
+#define STRING_Sk0 STR_S STR_k "\0"
+#define STRING_Sm0 STR_S STR_m "\0"
+#define STRING_So0 STR_S STR_o "\0"
+#define STRING_Sundanese0 STR_S STR_u STR_n STR_d STR_a STR_n STR_e STR_s STR_e "\0"
+#define STRING_Syloti_Nagri0 STR_S STR_y STR_l STR_o STR_t STR_i STR_UNDERSCORE STR_N STR_a STR_g STR_r STR_i "\0"
+#define STRING_Syriac0 STR_S STR_y STR_r STR_i STR_a STR_c "\0"
+#define STRING_Tagalog0 STR_T STR_a STR_g STR_a STR_l STR_o STR_g "\0"
+#define STRING_Tagbanwa0 STR_T STR_a STR_g STR_b STR_a STR_n STR_w STR_a "\0"
+#define STRING_Tai_Le0 STR_T STR_a STR_i STR_UNDERSCORE STR_L STR_e "\0"
+#define STRING_Tamil0 STR_T STR_a STR_m STR_i STR_l "\0"
+#define STRING_Telugu0 STR_T STR_e STR_l STR_u STR_g STR_u "\0"
+#define STRING_Thaana0 STR_T STR_h STR_a STR_a STR_n STR_a "\0"
+#define STRING_Thai0 STR_T STR_h STR_a STR_i "\0"
+#define STRING_Tibetan0 STR_T STR_i STR_b STR_e STR_t STR_a STR_n "\0"
+#define STRING_Tifinagh0 STR_T STR_i STR_f STR_i STR_n STR_a STR_g STR_h "\0"
+#define STRING_Ugaritic0 STR_U STR_g STR_a STR_r STR_i STR_t STR_i STR_c "\0"
+#define STRING_Vai0 STR_V STR_a STR_i "\0"
+#define STRING_Yi0 STR_Y STR_i "\0"
+#define STRING_Z0 STR_Z "\0"
+#define STRING_Zl0 STR_Z STR_l "\0"
+#define STRING_Zp0 STR_Z STR_p "\0"
+#define STRING_Zs0 STR_Z STR_s "\0"
+
+const char _pcre_utt_names[] =
+ STRING_Any0
+ STRING_Arabic0
+ STRING_Armenian0
+ STRING_Balinese0
+ STRING_Bengali0
+ STRING_Bopomofo0
+ STRING_Braille0
+ STRING_Buginese0
+ STRING_Buhid0
+ STRING_C0
+ STRING_Canadian_Aboriginal0
+ STRING_Carian0
+ STRING_Cc0
+ STRING_Cf0
+ STRING_Cham0
+ STRING_Cherokee0
+ STRING_Cn0
+ STRING_Co0
+ STRING_Common0
+ STRING_Coptic0
+ STRING_Cs0
+ STRING_Cuneiform0
+ STRING_Cypriot0
+ STRING_Cyrillic0
+ STRING_Deseret0
+ STRING_Devanagari0
+ STRING_Ethiopic0
+ STRING_Georgian0
+ STRING_Glagolitic0
+ STRING_Gothic0
+ STRING_Greek0
+ STRING_Gujarati0
+ STRING_Gurmukhi0
+ STRING_Han0
+ STRING_Hangul0
+ STRING_Hanunoo0
+ STRING_Hebrew0
+ STRING_Hiragana0
+ STRING_Inherited0
+ STRING_Kannada0
+ STRING_Katakana0
+ STRING_Kayah_Li0
+ STRING_Kharoshthi0
+ STRING_Khmer0
+ STRING_L0
+ STRING_L_AMPERSAND0
+ STRING_Lao0
+ STRING_Latin0
+ STRING_Lepcha0
+ STRING_Limbu0
+ STRING_Linear_B0
+ STRING_Ll0
+ STRING_Lm0
+ STRING_Lo0
+ STRING_Lt0
+ STRING_Lu0
+ STRING_Lycian0
+ STRING_Lydian0
+ STRING_M0
+ STRING_Malayalam0
+ STRING_Mc0
+ STRING_Me0
+ STRING_Mn0
+ STRING_Mongolian0
+ STRING_Myanmar0
+ STRING_N0
+ STRING_Nd0
+ STRING_New_Tai_Lue0
+ STRING_Nko0
+ STRING_Nl0
+ STRING_No0
+ STRING_Ogham0
+ STRING_Ol_Chiki0
+ STRING_Old_Italic0
+ STRING_Old_Persian0
+ STRING_Oriya0
+ STRING_Osmanya0
+ STRING_P0
+ STRING_Pc0
+ STRING_Pd0
+ STRING_Pe0
+ STRING_Pf0
+ STRING_Phags_Pa0
+ STRING_Phoenician0
+ STRING_Pi0
+ STRING_Po0
+ STRING_Ps0
+ STRING_Rejang0
+ STRING_Runic0
+ STRING_S0
+ STRING_Saurashtra0
+ STRING_Sc0
+ STRING_Shavian0
+ STRING_Sinhala0
+ STRING_Sk0
+ STRING_Sm0
+ STRING_So0
+ STRING_Sundanese0
+ STRING_Syloti_Nagri0
+ STRING_Syriac0
+ STRING_Tagalog0
+ STRING_Tagbanwa0
+ STRING_Tai_Le0
+ STRING_Tamil0
+ STRING_Telugu0
+ STRING_Thaana0
+ STRING_Thai0
+ STRING_Tibetan0
+ STRING_Tifinagh0
+ STRING_Ugaritic0
+ STRING_Vai0
+ STRING_Yi0
+ STRING_Z0
+ STRING_Zl0
+ STRING_Zp0
+ STRING_Zs0;
const ucp_type_table _pcre_utt[] = {
{ 0, PT_ANY, 0 },
diff --git a/pcregrep.c b/pcregrep.c
index af54842..fc1eb60 100644
--- a/pcregrep.c
+++ b/pcregrep.c
@@ -1871,16 +1871,18 @@ const char *error;
/* Set the default line ending value from the default in the PCRE library;
"lf", "cr", "crlf", and "any" are supported. Anything else is treated as "lf".
-*/
+Note that the return values from pcre_config(), though derived from the ASCII
+codes, are the same in EBCDIC environments, so we must use the actual values
+rather than escapes such as as '\r'. */
(void)pcre_config(PCRE_CONFIG_NEWLINE, &i);
switch(i)
{
- default: newline = (char *)"lf"; break;
- case '\r': newline = (char *)"cr"; break;
- case ('\r' << 8) | '\n': newline = (char *)"crlf"; break;
- case -1: newline = (char *)"any"; break;
- case -2: newline = (char *)"anycrlf"; break;
+ default: newline = (char *)"lf"; break;
+ case 13: newline = (char *)"cr"; break;
+ case (13 << 8) | 10: newline = (char *)"crlf"; break;
+ case -1: newline = (char *)"any"; break;
+ case -2: newline = (char *)"anycrlf"; break;
}
/* Process the options */
diff --git a/pcretest.c b/pcretest.c
index dd40e3f..3c0430b 100644
--- a/pcretest.c
+++ b/pcretest.c
@@ -936,8 +936,10 @@ while (argc > 1 && argv[op][0] == '-')
(void)pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &rc);
printf(" %sUnicode properties support\n", rc? "" : "No ");
(void)pcre_config(PCRE_CONFIG_NEWLINE, &rc);
- printf(" Newline sequence is %s\n", (rc == '\r')? "CR" :
- (rc == '\n')? "LF" : (rc == ('\r'<<8 | '\n'))? "CRLF" :
+ /* Note that these values are always the ASCII values, even
+ in EBCDIC environments. CR is 13 and NL is 10. */
+ printf(" Newline sequence is %s\n", (rc == 13)? "CR" :
+ (rc == 10)? "LF" : (rc == (13<<8 | 10))? "CRLF" :
(rc == -2)? "ANYCRLF" :
(rc == -1)? "ANY" : "???");
(void)pcre_config(PCRE_CONFIG_BSR, &rc);
@@ -2380,9 +2382,11 @@ while (!done)
{
int d;
(void)pcre_config(PCRE_CONFIG_NEWLINE, &d);
- obits = (d == '\r')? PCRE_NEWLINE_CR :
- (d == '\n')? PCRE_NEWLINE_LF :
- (d == ('\r'<<8 | '\n'))? PCRE_NEWLINE_CRLF :
+ /* Note that these values are always the ASCII ones, even in
+ EBCDIC environments. CR = 13, NL = 10. */
+ obits = (d == 13)? PCRE_NEWLINE_CR :
+ (d == 10)? PCRE_NEWLINE_LF :
+ (d == (13<<8 | 10))? PCRE_NEWLINE_CRLF :
(d == -2)? PCRE_NEWLINE_ANYCRLF :
(d == -1)? PCRE_NEWLINE_ANY : 0;
}