Skip to content

Commit 2e5f27c

Browse files
authored
Merge pull request libgit2#5649 from libgit2/ethomson/pcre
Update PCRE to 8.44
2 parents 94e3458 + 722c01b commit 2e5f27c

File tree

5 files changed

+130
-26
lines changed

5 files changed

+130
-26
lines changed

deps/pcre/LICENCE

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
PCRE LICENCE
2+
------------
3+
4+
PCRE is a library of functions to support regular expressions whose syntax
5+
and semantics are as close as possible to those of the Perl 5 language.
6+
7+
Release 8 of PCRE is distributed under the terms of the "BSD" licence, as
8+
specified below. The documentation for PCRE, supplied in the "doc"
9+
directory, is distributed under the same terms as the software itself. The data
10+
in the testdata directory is not copyrighted and is in the public domain.
11+
12+
The basic library functions are written in C and are freestanding. Also
13+
included in the distribution is a set of C++ wrapper functions, and a
14+
just-in-time compiler that can be used to optimize pattern matching. These
15+
are both optional features that can be omitted when the library is built.
16+
17+
18+
THE BASIC LIBRARY FUNCTIONS
19+
---------------------------
20+
21+
Written by: Philip Hazel
22+
Email local part: ph10
23+
Email domain: cam.ac.uk
24+
25+
University of Cambridge Computing Service,
26+
Cambridge, England.
27+
28+
Copyright (c) 1997-2020 University of Cambridge
29+
All rights reserved.
30+
31+
32+
PCRE JUST-IN-TIME COMPILATION SUPPORT
33+
-------------------------------------
34+
35+
Written by: Zoltan Herczeg
36+
Email local part: hzmester
37+
Email domain: freemail.hu
38+
39+
Copyright(c) 2010-2020 Zoltan Herczeg
40+
All rights reserved.
41+
42+
43+
STACK-LESS JUST-IN-TIME COMPILER
44+
--------------------------------
45+
46+
Written by: Zoltan Herczeg
47+
Email local part: hzmester
48+
Email domain: freemail.hu
49+
50+
Copyright(c) 2009-2020 Zoltan Herczeg
51+
All rights reserved.
52+
53+
54+
THE C++ WRAPPER FUNCTIONS
55+
-------------------------
56+
57+
Contributed by: Google Inc.
58+
59+
Copyright (c) 2007-2012, Google Inc.
60+
All rights reserved.
61+
62+
63+
THE "BSD" LICENCE
64+
-----------------
65+
66+
Redistribution and use in source and binary forms, with or without
67+
modification, are permitted provided that the following conditions are met:
68+
69+
* Redistributions of source code must retain the above copyright notice,
70+
this list of conditions and the following disclaimer.
71+
72+
* Redistributions in binary form must reproduce the above copyright
73+
notice, this list of conditions and the following disclaimer in the
74+
documentation and/or other materials provided with the distribution.
75+
76+
* Neither the name of the University of Cambridge nor the name of Google
77+
Inc. nor the names of their contributors may be used to endorse or
78+
promote products derived from this software without specific prior
79+
written permission.
80+
81+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
82+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
83+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
84+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
85+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
86+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
87+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
88+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
89+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
90+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
91+
POSSIBILITY OF SUCH DAMAGE.
92+
93+
End

deps/pcre/pcre.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ POSSIBILITY OF SUCH DAMAGE.
4242
/* The current PCRE version information. */
4343

4444
#define PCRE_MAJOR 8
45-
#define PCRE_MINOR 42
45+
#define PCRE_MINOR 44
4646
#define PCRE_PRERELEASE
47-
#define PCRE_DATE 2018-03-20
47+
#define PCRE_DATE 2020-02-12
4848

4949
#define PCRE_EXP_DECL extern
5050

deps/pcre/pcre_compile.c

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
and semantics are as close as possible to those of the Perl 5 language.
77
88
Written by Philip Hazel
9-
Copyright (c) 1997-2016 University of Cambridge
9+
Copyright (c) 1997-2020 University of Cambridge
1010
1111
-----------------------------------------------------------------------------
1212
Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,7 @@ COMPILE_PCREx macro will already be appropriately set. */
6868

6969
/* Macro for setting individual bits in class bitmaps. */
7070

71-
#define SETBIT(a,b) a[(b)/8] |= (1 << ((b)&7))
71+
#define SETBIT(a,b) a[(b)/8] |= (1U << ((b)&7))
7272

7373
/* Maximum length value to check against when making sure that the integer that
7474
holds the compiled pattern length does not overflow. We make it a bit less than
@@ -129,8 +129,8 @@ overrun before it actually does run off the end of the data block. */
129129

130130
/* Private flags added to firstchar and reqchar. */
131131

132-
#define REQ_CASELESS (1 << 0) /* Indicates caselessness */
133-
#define REQ_VARY (1 << 1) /* Reqchar followed non-literal item */
132+
#define REQ_CASELESS (1U << 0) /* Indicates caselessness */
133+
#define REQ_VARY (1U << 1) /* Reqchar followed non-literal item */
134134
/* Negative values for the firstchar and reqchar flags */
135135
#define REQ_UNSET (-2)
136136
#define REQ_NONE (-1)
@@ -3299,7 +3299,7 @@ for(;;)
32993299
if ((*xclass_flags & XCL_MAP) == 0)
33003300
{
33013301
/* No bits are set for characters < 256. */
3302-
if (list[1] == 0) return TRUE;
3302+
if (list[1] == 0) return (*xclass_flags & XCL_NOT) == 0;
33033303
/* Might be an empty repeat. */
33043304
continue;
33053305
}
@@ -3611,7 +3611,7 @@ for(;;)
36113611
if (chr > 255) break;
36123612
class_bitset = (pcre_uint8 *)
36133613
((list_ptr == list ? code : base_end) - list_ptr[2]);
3614-
if ((class_bitset[chr >> 3] & (1 << (chr & 7))) != 0) return FALSE;
3614+
if ((class_bitset[chr >> 3] & (1U << (chr & 7))) != 0) return FALSE;
36153615
break;
36163616

36173617
#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
@@ -7135,17 +7135,19 @@ for (;; ptr++)
71357135
int n = 0;
71367136
ptr++;
71377137
while(IS_DIGIT(*ptr))
7138+
{
71387139
n = n * 10 + *ptr++ - CHAR_0;
7140+
if (n > 255)
7141+
{
7142+
*errorcodeptr = ERR38;
7143+
goto FAILED;
7144+
}
7145+
}
71397146
if (*ptr != CHAR_RIGHT_PARENTHESIS)
71407147
{
71417148
*errorcodeptr = ERR39;
71427149
goto FAILED;
71437150
}
7144-
if (n > 255)
7145-
{
7146-
*errorcodeptr = ERR38;
7147-
goto FAILED;
7148-
}
71497151
*code++ = n;
71507152
PUT(code, 0, (int)(ptr - cd->start_pattern + 1)); /* Pattern offset */
71517153
PUT(code, LINK_SIZE, 0); /* Default length */
@@ -7461,7 +7463,7 @@ for (;; ptr++)
74617463
{
74627464
open_capitem *oc;
74637465
recno = GET2(slot, 0);
7464-
cd->backref_map |= (recno < 32)? (1 << recno) : 1;
7466+
cd->backref_map |= (recno < 32)? (1U << recno) : 1;
74657467
if (recno > cd->top_backref) cd->top_backref = recno;
74667468

74677469
/* Check to see if this back reference is recursive, that it, it
@@ -7647,6 +7649,8 @@ for (;; ptr++)
76477649
/* Can't determine a first byte now */
76487650

76497651
if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
7652+
zerofirstchar = firstchar;
7653+
zerofirstcharflags = firstcharflags;
76507654
continue;
76517655

76527656

@@ -8070,7 +8074,7 @@ for (;; ptr++)
80708074
item_hwm_offset = cd->hwm - cd->start_workspace;
80718075
*code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF;
80728076
PUT2INC(code, 0, recno);
8073-
cd->backref_map |= (recno < 32)? (1 << recno) : 1;
8077+
cd->backref_map |= (recno < 32)? (1U << recno) : 1;
80748078
if (recno > cd->top_backref) cd->top_backref = recno;
80758079

80768080
/* Check to see if this back reference is recursive, that it, it
@@ -8683,14 +8687,22 @@ do {
86838687
op == OP_SCBRA || op == OP_SCBRAPOS)
86848688
{
86858689
int n = GET2(scode, 1+LINK_SIZE);
8686-
int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
8690+
int new_map = bracket_map | ((n < 32)? (1U << n) : 1);
86878691
if (!is_anchored(scode, new_map, cd, atomcount)) return FALSE;
86888692
}
86898693

8690-
/* Positive forward assertions and conditions */
8694+
/* Positive forward assertion */
8695+
8696+
else if (op == OP_ASSERT)
8697+
{
8698+
if (!is_anchored(scode, bracket_map, cd, atomcount)) return FALSE;
8699+
}
8700+
8701+
/* Condition; not anchored if no second branch */
86918702

8692-
else if (op == OP_ASSERT || op == OP_COND)
8703+
else if (op == OP_COND)
86938704
{
8705+
if (scode[GET(scode,1)] != OP_ALT) return FALSE;
86948706
if (!is_anchored(scode, bracket_map, cd, atomcount)) return FALSE;
86958707
}
86968708

@@ -8803,7 +8815,7 @@ do {
88038815
op == OP_SCBRA || op == OP_SCBRAPOS)
88048816
{
88058817
int n = GET2(scode, 1+LINK_SIZE);
8806-
int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
8818+
int new_map = bracket_map | ((n < 32)? (1U << n) : 1);
88078819
if (!is_startline(scode, new_map, cd, atomcount, inassert)) return FALSE;
88088820
}
88098821

deps/pcre/pcre_jit_compile.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3938,10 +3938,10 @@ static sljit_s32 character_to_int32(pcre_uchar chr)
39383938
sljit_s32 value = (sljit_s32)chr;
39393939
#if defined COMPILE_PCRE8
39403940
#define SSE2_COMPARE_TYPE_INDEX 0
3941-
return (value << 24) | (value << 16) | (value << 8) | value;
3941+
return ((unsigned int)value << 24) | ((unsigned int)value << 16) | ((unsigned int)value << 8) | (unsigned int)value;
39423942
#elif defined COMPILE_PCRE16
39433943
#define SSE2_COMPARE_TYPE_INDEX 1
3944-
return (value << 16) | value;
3944+
return ((unsigned int)value << 16) | value;
39453945
#elif defined COMPILE_PCRE32
39463946
#define SSE2_COMPARE_TYPE_INDEX 2
39473947
return value;
@@ -8507,7 +8507,7 @@ if (opcode == OP_ONCE)
85078507
/* We temporarily encode the needs_control_head in the lowest bit.
85088508
Note: on the target architectures of SLJIT the ((x << 1) >> 1) returns
85098509
the same value for small signed numbers (including negative numbers). */
8510-
BACKTRACK_AS(bracket_backtrack)->u.framesize = (BACKTRACK_AS(bracket_backtrack)->u.framesize << 1) | (needs_control_head ? 1 : 0);
8510+
BACKTRACK_AS(bracket_backtrack)->u.framesize = ((unsigned int)BACKTRACK_AS(bracket_backtrack)->u.framesize << 1) | (needs_control_head ? 1 : 0);
85118511
}
85128512
return cc + repeat_length;
85138513
}
@@ -9002,7 +9002,7 @@ if (exact > 1)
90029002
#ifdef SUPPORT_UTF
90039003
&& !common->utf
90049004
#endif
9005-
)
9005+
&& type != OP_ANYNL && type != OP_EXTUNI)
90069006
{
90079007
OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(exact));
90089008
add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_GREATER, TMP1, 0, STR_END, 0));

deps/pcre/pcreposix.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
and semantics are as close as possible to those of the Perl 5 language.
77
88
Written by Philip Hazel
9-
Copyright (c) 1997-2018 University of Cambridge
9+
Copyright (c) 1997-2020 University of Cambridge
1010
1111
-----------------------------------------------------------------------------
1212
Redistribution and use in source and binary forms, with or without
@@ -287,6 +287,7 @@ if (preg->re_pcre == NULL)
287287
(void)pcre_fullinfo((const pcre *)preg->re_pcre, NULL, PCRE_INFO_CAPTURECOUNT,
288288
&re_nsub);
289289
preg->re_nsub = (size_t)re_nsub;
290+
preg->re_erroffset = (size_t)(-1); /* No meaning after successful compile */
290291
return 0;
291292
}
292293

@@ -324,8 +325,6 @@ if ((eflags & PCRE_REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
324325
if ((eflags & PCRE_REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
325326
if ((eflags & PCRE_REG_NOTEMPTY) != 0) options |= PCRE_NOTEMPTY;
326327

327-
((pcre_regex_t *)preg)->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
328-
329328
/* When no string data is being returned, or no vector has been passed in which
330329
to put it, ensure that nmatch is zero. Otherwise, ensure the vector for holding
331330
the return data is large enough. */

0 commit comments

Comments
 (0)