@@ -1964,86 +1964,86 @@ static BOOL is_word_char(uint32_t c)
1964
1964
(c == '_' ));
1965
1965
}
1966
1966
1967
- #define GET_CHAR (c , cptr , cbuf_end ) \
1967
+ #define GET_CHAR (c , cptr , cbuf_end , cbuf_type ) \
1968
1968
do { \
1969
1969
if (cbuf_type == 0) { \
1970
1970
c = *cptr++; \
1971
1971
} else { \
1972
- const uint16_t *_p = (uint16_t *)cptr; \
1973
- const uint16_t *_end = (uint16_t *)cbuf_end; \
1972
+ const uint16_t *_p = (const uint16_t *)cptr; \
1973
+ const uint16_t *_end = (const uint16_t *)cbuf_end; \
1974
1974
c = *_p++; \
1975
1975
if (is_hi_surrogate(c)) \
1976
1976
if (cbuf_type == 2) \
1977
1977
if (_p < _end) \
1978
1978
if (is_lo_surrogate(*_p)) \
1979
1979
c = from_surrogate(c, *_p++); \
1980
- cptr = (void *) _p; \
1980
+ cptr = (const void *)_p; \
1981
1981
} \
1982
1982
} while (0)
1983
1983
1984
- #define PEEK_CHAR (c , cptr , cbuf_end ) \
1984
+ #define PEEK_CHAR (c , cptr , cbuf_end , cbuf_type ) \
1985
1985
do { \
1986
1986
if (cbuf_type == 0) { \
1987
1987
c = cptr[0]; \
1988
1988
} else { \
1989
- const uint16_t *_p = (uint16_t *)cptr; \
1990
- const uint16_t *_end = (uint16_t *)cbuf_end; \
1989
+ const uint16_t *_p = (const uint16_t *)cptr; \
1990
+ const uint16_t *_end = (const uint16_t *)cbuf_end; \
1991
1991
c = *_p++; \
1992
1992
if (is_hi_surrogate(c)) \
1993
1993
if (cbuf_type == 2) \
1994
1994
if (_p < _end) \
1995
1995
if (is_lo_surrogate(*_p)) \
1996
- c = from_surrogate(c, *_p++); \
1996
+ c = from_surrogate(c, *_p); \
1997
1997
} \
1998
1998
} while (0)
1999
1999
2000
- #define PEEK_PREV_CHAR (c , cptr , cbuf_start ) \
2000
+ #define PEEK_PREV_CHAR (c , cptr , cbuf_start , cbuf_type ) \
2001
2001
do { \
2002
2002
if (cbuf_type == 0) { \
2003
2003
c = cptr[-1]; \
2004
2004
} else { \
2005
- const uint16_t *_p = (uint16_t *)cptr - 1; \
2006
- const uint16_t *_start = (uint16_t *)cbuf_start; \
2005
+ const uint16_t *_p = (const uint16_t *)cptr - 1; \
2006
+ const uint16_t *_start = (const uint16_t *)cbuf_start; \
2007
2007
c = *_p; \
2008
2008
if (is_lo_surrogate(c)) \
2009
2009
if (cbuf_type == 2) \
2010
2010
if (_p > _start) \
2011
- if (is_hi_surrogate(*--_p)) \
2012
- c = from_surrogate(*_p, c); \
2011
+ if (is_hi_surrogate(_p[-1])) \
2012
+ c = from_surrogate(*-- _p, c); \
2013
2013
} \
2014
2014
} while (0)
2015
2015
2016
- #define GET_PREV_CHAR (c , cptr , cbuf_start ) \
2016
+ #define GET_PREV_CHAR (c , cptr , cbuf_start , cbuf_type ) \
2017
2017
do { \
2018
2018
if (cbuf_type == 0) { \
2019
2019
cptr--; \
2020
2020
c = cptr[0]; \
2021
2021
} else { \
2022
- const uint16_t *_p = (uint16_t *)cptr - 1; \
2023
- const uint16_t *_start = (uint16_t *)cbuf_start; \
2022
+ const uint16_t *_p = (const uint16_t *)cptr - 1; \
2023
+ const uint16_t *_start = (const uint16_t *)cbuf_start; \
2024
2024
c = *_p; \
2025
2025
if (is_lo_surrogate(c)) \
2026
2026
if (cbuf_type == 2) \
2027
2027
if (_p > _start) \
2028
- if (is_hi_surrogate(*--_p)) \
2029
- c = from_surrogate(*_p, c); \
2030
- cptr = (void *) _p; \
2028
+ if (is_hi_surrogate(_p[-1])) \
2029
+ c = from_surrogate(*-- _p, c); \
2030
+ cptr = (const void *)_p; \
2031
2031
} \
2032
2032
} while (0)
2033
2033
2034
- #define PREV_CHAR (cptr , cbuf_start ) \
2034
+ #define PREV_CHAR (cptr , cbuf_start , cbuf_type ) \
2035
2035
do { \
2036
2036
if (cbuf_type == 0) { \
2037
2037
cptr--; \
2038
2038
} else { \
2039
- const uint16_t *_p = (uint16_t *)cptr - 1; \
2040
- const uint16_t *_start = (uint16_t *)cbuf_start; \
2039
+ const uint16_t *_p = (const uint16_t *)cptr - 1; \
2040
+ const uint16_t *_start = (const uint16_t *)cbuf_start; \
2041
2041
if (is_lo_surrogate(*_p)) \
2042
2042
if (cbuf_type == 2) \
2043
2043
if (_p > _start) \
2044
2044
if (is_hi_surrogate(_p[-1])) \
2045
2045
_p--; \
2046
- cptr = (void *) _p; \
2046
+ cptr = (const void *)_p; \
2047
2047
} \
2048
2048
} while (0)
2049
2049
@@ -2183,7 +2183,7 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
2183
2183
/* go backward */
2184
2184
char_count = get_u32 (pc + 12 );
2185
2185
for (i = 0 ; i < char_count ; i ++ ) {
2186
- PREV_CHAR (cptr , s -> cbuf );
2186
+ PREV_CHAR (cptr , s -> cbuf , cbuf_type );
2187
2187
}
2188
2188
pc = (pc + 16 ) + (int )get_u32 (pc );
2189
2189
rs -> cptr = cptr ;
@@ -2222,7 +2222,7 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
2222
2222
test_char :
2223
2223
if (cptr >= cbuf_end )
2224
2224
goto no_match ;
2225
- GET_CHAR (c , cptr , cbuf_end );
2225
+ GET_CHAR (c , cptr , cbuf_end , cbuf_type );
2226
2226
if (s -> ignore_case ) {
2227
2227
c = lre_canonicalize (c , s -> is_unicode );
2228
2228
}
@@ -2269,7 +2269,7 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
2269
2269
break ;
2270
2270
if (!s -> multi_line )
2271
2271
goto no_match ;
2272
- PEEK_PREV_CHAR (c , cptr , s -> cbuf );
2272
+ PEEK_PREV_CHAR (c , cptr , s -> cbuf , cbuf_type );
2273
2273
if (!is_line_terminator (c ))
2274
2274
goto no_match ;
2275
2275
break ;
@@ -2278,21 +2278,21 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
2278
2278
break ;
2279
2279
if (!s -> multi_line )
2280
2280
goto no_match ;
2281
- PEEK_CHAR (c , cptr , cbuf_end );
2281
+ PEEK_CHAR (c , cptr , cbuf_end , cbuf_type );
2282
2282
if (!is_line_terminator (c ))
2283
2283
goto no_match ;
2284
2284
break ;
2285
2285
case REOP_dot :
2286
2286
if (cptr == cbuf_end )
2287
2287
goto no_match ;
2288
- GET_CHAR (c , cptr , cbuf_end );
2288
+ GET_CHAR (c , cptr , cbuf_end , cbuf_type );
2289
2289
if (is_line_terminator (c ))
2290
2290
goto no_match ;
2291
2291
break ;
2292
2292
case REOP_any :
2293
2293
if (cptr == cbuf_end )
2294
2294
goto no_match ;
2295
- GET_CHAR (c , cptr , cbuf_end );
2295
+ GET_CHAR (c , cptr , cbuf_end , cbuf_type );
2296
2296
break ;
2297
2297
case REOP_save_start :
2298
2298
case REOP_save_end :
@@ -2346,14 +2346,14 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
2346
2346
if (cptr == s -> cbuf ) {
2347
2347
v1 = FALSE;
2348
2348
} else {
2349
- PEEK_PREV_CHAR (c , cptr , s -> cbuf );
2349
+ PEEK_PREV_CHAR (c , cptr , s -> cbuf , cbuf_type );
2350
2350
v1 = is_word_char (c );
2351
2351
}
2352
2352
/* current char */
2353
2353
if (cptr >= cbuf_end ) {
2354
2354
v2 = FALSE;
2355
2355
} else {
2356
- PEEK_CHAR (c , cptr , cbuf_end );
2356
+ PEEK_CHAR (c , cptr , cbuf_end , cbuf_type );
2357
2357
v2 = is_word_char (c );
2358
2358
}
2359
2359
if (v1 ^ v2 ^ (REOP_not_word_boundary - opcode ))
@@ -2378,8 +2378,8 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
2378
2378
while (cptr1 < cptr1_end ) {
2379
2379
if (cptr >= cbuf_end )
2380
2380
goto no_match ;
2381
- GET_CHAR (c1 , cptr1 , cptr1_end );
2382
- GET_CHAR (c2 , cptr , cbuf_end );
2381
+ GET_CHAR (c1 , cptr1 , cptr1_end , cbuf_type );
2382
+ GET_CHAR (c2 , cptr , cbuf_end , cbuf_type );
2383
2383
if (s -> ignore_case ) {
2384
2384
c1 = lre_canonicalize (c1 , s -> is_unicode );
2385
2385
c2 = lre_canonicalize (c2 , s -> is_unicode );
@@ -2392,8 +2392,8 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
2392
2392
while (cptr1 > cptr1_start ) {
2393
2393
if (cptr == s -> cbuf )
2394
2394
goto no_match ;
2395
- GET_PREV_CHAR (c1 , cptr1 , cptr1_start );
2396
- GET_PREV_CHAR (c2 , cptr , s -> cbuf );
2395
+ GET_PREV_CHAR (c1 , cptr1 , cptr1_start , cbuf_type );
2396
+ GET_PREV_CHAR (c2 , cptr , s -> cbuf , cbuf_type );
2397
2397
if (s -> ignore_case ) {
2398
2398
c1 = lre_canonicalize (c1 , s -> is_unicode );
2399
2399
c2 = lre_canonicalize (c2 , s -> is_unicode );
@@ -2413,7 +2413,7 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
2413
2413
pc += 2 ;
2414
2414
if (cptr >= cbuf_end )
2415
2415
goto no_match ;
2416
- GET_CHAR (c , cptr , cbuf_end );
2416
+ GET_CHAR (c , cptr , cbuf_end , cbuf_type );
2417
2417
if (s -> ignore_case ) {
2418
2418
c = lre_canonicalize (c , s -> is_unicode );
2419
2419
}
@@ -2453,7 +2453,7 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
2453
2453
pc += 2 ;
2454
2454
if (cptr >= cbuf_end )
2455
2455
goto no_match ;
2456
- GET_CHAR (c , cptr , cbuf_end );
2456
+ GET_CHAR (c , cptr , cbuf_end , cbuf_type );
2457
2457
if (s -> ignore_case ) {
2458
2458
c = lre_canonicalize (c , s -> is_unicode );
2459
2459
}
@@ -2485,7 +2485,7 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
2485
2485
/* go to the previous char */
2486
2486
if (cptr == s -> cbuf )
2487
2487
goto no_match ;
2488
- PREV_CHAR (cptr , s -> cbuf );
2488
+ PREV_CHAR (cptr , s -> cbuf , cbuf_type );
2489
2489
break ;
2490
2490
case REOP_simple_greedy_quant :
2491
2491
{
0 commit comments