|
6 | 6 | and semantics are as close as possible to those of the Perl 5 language. |
7 | 7 |
|
8 | 8 | Written by Philip Hazel |
9 | | - Copyright (c) 1997-2018 University of Cambridge |
| 9 | + Copyright (c) 1997-2020 University of Cambridge |
10 | 10 |
|
11 | 11 | ----------------------------------------------------------------------------- |
12 | 12 | Redistribution and use in source and binary forms, with or without |
@@ -68,7 +68,7 @@ COMPILE_PCREx macro will already be appropriately set. */ |
68 | 68 |
|
69 | 69 | /* Macro for setting individual bits in class bitmaps. */ |
70 | 70 |
|
71 | | -#define SETBIT(a,b) a[(b)/8] |= (1 << ((b)&7)) |
| 71 | +#define SETBIT(a,b) a[(b)/8] |= (1U << ((b)&7)) |
72 | 72 |
|
73 | 73 | /* Maximum length value to check against when making sure that the integer that |
74 | 74 | 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. */ |
129 | 129 |
|
130 | 130 | /* Private flags added to firstchar and reqchar. */ |
131 | 131 |
|
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 */ |
134 | 134 | /* Negative values for the firstchar and reqchar flags */ |
135 | 135 | #define REQ_UNSET (-2) |
136 | 136 | #define REQ_NONE (-1) |
@@ -3611,7 +3611,7 @@ for(;;) |
3611 | 3611 | if (chr > 255) break; |
3612 | 3612 | class_bitset = (pcre_uint8 *) |
3613 | 3613 | ((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; |
3615 | 3615 | break; |
3616 | 3616 |
|
3617 | 3617 | #if defined SUPPORT_UTF || !defined COMPILE_PCRE8 |
@@ -7135,17 +7135,19 @@ for (;; ptr++) |
7135 | 7135 | int n = 0; |
7136 | 7136 | ptr++; |
7137 | 7137 | while(IS_DIGIT(*ptr)) |
| 7138 | + { |
7138 | 7139 | n = n * 10 + *ptr++ - CHAR_0; |
| 7140 | + if (n > 255) |
| 7141 | + { |
| 7142 | + *errorcodeptr = ERR38; |
| 7143 | + goto FAILED; |
| 7144 | + } |
| 7145 | + } |
7139 | 7146 | if (*ptr != CHAR_RIGHT_PARENTHESIS) |
7140 | 7147 | { |
7141 | 7148 | *errorcodeptr = ERR39; |
7142 | 7149 | goto FAILED; |
7143 | 7150 | } |
7144 | | - if (n > 255) |
7145 | | - { |
7146 | | - *errorcodeptr = ERR38; |
7147 | | - goto FAILED; |
7148 | | - } |
7149 | 7151 | *code++ = n; |
7150 | 7152 | PUT(code, 0, (int)(ptr - cd->start_pattern + 1)); /* Pattern offset */ |
7151 | 7153 | PUT(code, LINK_SIZE, 0); /* Default length */ |
@@ -7461,7 +7463,7 @@ for (;; ptr++) |
7461 | 7463 | { |
7462 | 7464 | open_capitem *oc; |
7463 | 7465 | recno = GET2(slot, 0); |
7464 | | - cd->backref_map |= (recno < 32)? (1 << recno) : 1; |
| 7466 | + cd->backref_map |= (recno < 32)? (1U << recno) : 1; |
7465 | 7467 | if (recno > cd->top_backref) cd->top_backref = recno; |
7466 | 7468 |
|
7467 | 7469 | /* Check to see if this back reference is recursive, that it, it |
@@ -8072,7 +8074,7 @@ for (;; ptr++) |
8072 | 8074 | item_hwm_offset = cd->hwm - cd->start_workspace; |
8073 | 8075 | *code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF; |
8074 | 8076 | PUT2INC(code, 0, recno); |
8075 | | - cd->backref_map |= (recno < 32)? (1 << recno) : 1; |
| 8077 | + cd->backref_map |= (recno < 32)? (1U << recno) : 1; |
8076 | 8078 | if (recno > cd->top_backref) cd->top_backref = recno; |
8077 | 8079 |
|
8078 | 8080 | /* Check to see if this back reference is recursive, that it, it |
@@ -8685,7 +8687,7 @@ do { |
8685 | 8687 | op == OP_SCBRA || op == OP_SCBRAPOS) |
8686 | 8688 | { |
8687 | 8689 | int n = GET2(scode, 1+LINK_SIZE); |
8688 | | - int new_map = bracket_map | ((n < 32)? (1 << n) : 1); |
| 8690 | + int new_map = bracket_map | ((n < 32)? (1U << n) : 1); |
8689 | 8691 | if (!is_anchored(scode, new_map, cd, atomcount)) return FALSE; |
8690 | 8692 | } |
8691 | 8693 |
|
@@ -8813,7 +8815,7 @@ do { |
8813 | 8815 | op == OP_SCBRA || op == OP_SCBRAPOS) |
8814 | 8816 | { |
8815 | 8817 | int n = GET2(scode, 1+LINK_SIZE); |
8816 | | - int new_map = bracket_map | ((n < 32)? (1 << n) : 1); |
| 8818 | + int new_map = bracket_map | ((n < 32)? (1U << n) : 1); |
8817 | 8819 | if (!is_startline(scode, new_map, cd, atomcount, inassert)) return FALSE; |
8818 | 8820 | } |
8819 | 8821 |
|
|
0 commit comments