summaryrefslogtreecommitdiff
path: root/ext/pcre/pcre2lib/pcre2_maketables.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-06-30 18:24:48 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-06-30 18:24:48 +0200
commite2a407c2fe788e685055e81d672c8cc6cd7ceaa5 (patch)
treeeff567b3b57d2ec369e6a8f8615d754a2655cac0 /ext/pcre/pcre2lib/pcre2_maketables.c
parentaf4ff75c989374d2f850ae397d62d5a537532c40 (diff)
downloadphp-git-e2a407c2fe788e685055e81d672c8cc6cd7ceaa5.tar.gz
Revert "Update to PCRE2 10.35"
This reverts commit b419f96c626d1f9cbbba42698e947e32a0af9c4f. This breaks the GCC build with -fcf-protection (default on Ubuntu at least).
Diffstat (limited to 'ext/pcre/pcre2lib/pcre2_maketables.c')
-rw-r--r--ext/pcre/pcre2lib/pcre2_maketables.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/ext/pcre/pcre2lib/pcre2_maketables.c b/ext/pcre/pcre2lib/pcre2_maketables.c
index 56d2494023..8c93b4b573 100644
--- a/ext/pcre/pcre2lib/pcre2_maketables.c
+++ b/ext/pcre/pcre2lib/pcre2_maketables.c
@@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
- New API code Copyright (c) 2016-2020 University of Cambridge
+ New API code Copyright (c) 2016-2019 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -41,11 +41,10 @@ POSSIBILITY OF SUCH DAMAGE.
/* This module contains the external function pcre2_maketables(), which builds
character tables for PCRE2 in the current locale. The file is compiled on its
-own as part of the PCRE2 library. It is also included in the compilation of
-pcre2_dftables.c as a freestanding program, in which case the macro
-PCRE2_DFTABLES is defined. */
+own as part of the PCRE2 library. However, it is also included in the
+compilation of dftables.c, in which case the macro DFTABLES is defined. */
-#ifndef PCRE2_DFTABLES /* Compiling the library */
+#ifndef DFTABLES
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
@@ -62,29 +61,28 @@ PCRE2_DFTABLES is defined. */
a pointer to them. They are build using the ctype functions, and consequently
their contents will depend upon the current locale setting. When compiled as
part of the library, the store is obtained via a general context malloc, if
-supplied, but when PCRE2_DFTABLES is defined (when compiling the pcre2_dftables
-freestanding auxiliary program) malloc() is used, and the function has a
-different name so as not to clash with the prototype in pcre2.h.
+supplied, but when DFTABLES is defined (when compiling the dftables auxiliary
+program) malloc() is used, and the function has a different name so as not to
+clash with the prototype in pcre2.h.
-Arguments: none when PCRE2_DFTABLES is defined
- else a PCRE2 general context or NULL
+Arguments: none when DFTABLES is defined
+ else a PCRE2 general context or NULL
Returns: pointer to the contiguous block of data
- else NULL if memory allocation failed
*/
-#ifdef PCRE2_DFTABLES /* Included in freestanding pcre2_dftables program */
+#ifdef DFTABLES /* Included in freestanding dftables.c program */
static const uint8_t *maketables(void)
{
-uint8_t *yield = (uint8_t *)malloc(TABLES_LENGTH);
+uint8_t *yield = (uint8_t *)malloc(tables_length);
-#else /* Not PCRE2_DFTABLES, that is, compiling the library */
+#else /* Not DFTABLES, compiling the library */
PCRE2_EXP_DEFN const uint8_t * PCRE2_CALL_CONVENTION
pcre2_maketables(pcre2_general_context *gcontext)
{
uint8_t *yield = (uint8_t *)((gcontext != NULL)?
- gcontext->memctl.malloc(TABLES_LENGTH, gcontext->memctl.memory_data) :
- malloc(TABLES_LENGTH));
-#endif /* PCRE2_DFTABLES */
+ gcontext->memctl.malloc(tables_length, gcontext->memctl.memory_data) :
+ malloc(tables_length));
+#endif /* DFTABLES */
int i;
uint8_t *p;
@@ -105,8 +103,8 @@ exclusive ones - in some locales things may be different.
Note that the table for "space" includes everything "isspace" gives, including
VT in the default locale. This makes it work for the POSIX class [:space:].
-From PCRE1 release 8.34 and for all PCRE2 releases it is also correct for Perl
-space, because Perl added VT at release 5.18.
+From release 8.34 is is also correct for Perl space, because Perl added VT at
+release 5.18.
Note also that it is possible for a character to be alnum or alpha without
being lower or upper, such as "male and female ordinals" (\xAA and \xBA) in the
@@ -116,24 +114,24 @@ test for alnum specially. */
memset(p, 0, cbit_length);
for (i = 0; i < 256; i++)
{
- if (isdigit(i)) p[cbit_digit + i/8] |= 1u << (i&7);
- if (isupper(i)) p[cbit_upper + i/8] |= 1u << (i&7);
- if (islower(i)) p[cbit_lower + i/8] |= 1u << (i&7);
- if (isalnum(i)) p[cbit_word + i/8] |= 1u << (i&7);
- if (i == '_') p[cbit_word + i/8] |= 1u << (i&7);
- if (isspace(i)) p[cbit_space + i/8] |= 1u << (i&7);
- if (isxdigit(i)) p[cbit_xdigit + i/8] |= 1u << (i&7);
- if (isgraph(i)) p[cbit_graph + i/8] |= 1u << (i&7);
- if (isprint(i)) p[cbit_print + i/8] |= 1u << (i&7);
- if (ispunct(i)) p[cbit_punct + i/8] |= 1u << (i&7);
- if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1u << (i&7);
+ if (isdigit(i)) p[cbit_digit + i/8] |= 1u << (i&7);
+ if (isupper(i)) p[cbit_upper + i/8] |= 1u << (i&7);
+ if (islower(i)) p[cbit_lower + i/8] |= 1u << (i&7);
+ if (isalnum(i)) p[cbit_word + i/8] |= 1u << (i&7);
+ if (i == '_') p[cbit_word + i/8] |= 1u << (i&7);
+ if (isspace(i)) p[cbit_space + i/8] |= 1u << (i&7);
+ if (isxdigit(i))p[cbit_xdigit + i/8] |= 1u << (i&7);
+ if (isgraph(i)) p[cbit_graph + i/8] |= 1u << (i&7);
+ if (isprint(i)) p[cbit_print + i/8] |= 1u << (i&7);
+ if (ispunct(i)) p[cbit_punct + i/8] |= 1u << (i&7);
+ if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1u << (i&7);
}
p += cbit_length;
/* Finally, the character type table. In this, we used to exclude VT from the
white space chars, because Perl didn't recognize it as such for \s and for
-comments within regexes. However, Perl changed at release 5.18, so PCRE1
-changed at release 8.34 and it's always been this way for PCRE2. */
+comments within regexes. However, Perl changed at release 5.18, so PCRE changed
+at release 8.34. */
for (i = 0; i < 256; i++)
{
@@ -149,7 +147,7 @@ for (i = 0; i < 256; i++)
return yield;
}
-#ifndef PCRE2_DFTABLES /* Compiling the library */
+#ifndef DFTABLES
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_maketables_free(pcre2_general_context *gcontext, const uint8_t *tables)
{