diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-07-15 14:08:40 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-07-15 14:08:40 +0200 |
commit | 66e0fdd5369bd804e9147e32a1a043559f2b5e9d (patch) | |
tree | 2553375acc15cf83e0d773858493d758f62212ef /src/regexec.c | |
parent | 0e4c1c1dd3dd4271e54a7305699c303b629fa915 (diff) | |
parent | 9b2a64e0f1cd115b0091c2b57ad938ec0f7bab4d (diff) |
Merge branch 'release/debian/6.3.0-1'debian/6.3.0-1
Diffstat (limited to 'src/regexec.c')
-rw-r--r-- | src/regexec.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/regexec.c b/src/regexec.c index 35fef11..c0626ef 100644 --- a/src/regexec.c +++ b/src/regexec.c @@ -2,7 +2,7 @@ regexec.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2016 K.Kosako <sndgk393 AT ybb DOT ne DOT jp> + * Copyright (c) 2002-2017 K.Kosako <sndgk393 AT ybb DOT ne DOT jp> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1346,8 +1346,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, fprintf(stderr, "%4d> \"", (int )(s - str)); bp = buf; for (i = 0, q = s; i < 7 && q < end; i++) { - len = enclen(encode, q); - while (len-- > 0) *bp++ = *q++; + len = enclen(encode, q); + while (len-- > 0) *bp++ = *q++; } if (q < end) { xmemcpy(bp, "...\"", 4); bp += 4; } else { xmemcpy(bp, "\"", 1); bp += 1; } @@ -1473,14 +1473,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, break; case OP_EXACT1: MOP_IN(OP_EXACT1); -#if 0 DATA_ENSURE(1); if (*p != *s) goto fail; p++; s++; -#endif - if (*p != *s++) goto fail; - DATA_ENSURE(0); - p++; MOP_OUT; break; @@ -3159,6 +3154,8 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, } else { UChar *q = p + reg->dmin; + + if (q >= end) return 0; /* fail */ while (p < q) p += enclen(reg->enc, p); } } @@ -3238,18 +3235,25 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, } else { if (reg->dmax != ONIG_INFINITE_DISTANCE) { - *low = p - reg->dmax; - if (*low > s) { - *low = onigenc_get_right_adjust_char_head_with_prev(reg->enc, s, - *low, (const UChar** )low_prev); - if (low_prev && IS_NULL(*low_prev)) - *low_prev = onigenc_get_prev_char_head(reg->enc, - (pprev ? pprev : s), *low); + if (p - str < reg->dmax) { + *low = (UChar* )str; + if (low_prev) + *low_prev = onigenc_get_prev_char_head(reg->enc, str, *low); } else { - if (low_prev) - *low_prev = onigenc_get_prev_char_head(reg->enc, - (pprev ? pprev : str), *low); + *low = p - reg->dmax; + if (*low > s) { + *low = onigenc_get_right_adjust_char_head_with_prev(reg->enc, s, + *low, (const UChar** )low_prev); + if (low_prev && IS_NULL(*low_prev)) + *low_prev = onigenc_get_prev_char_head(reg->enc, + (pprev ? pprev : s), *low); + } + else { + if (low_prev) + *low_prev = onigenc_get_prev_char_head(reg->enc, + (pprev ? pprev : str), *low); + } } } } @@ -3790,8 +3794,10 @@ onig_scan(regex_t* reg, const UChar* str, const UChar* end, if (rs != 0) return rs; - if (region->end[0] == start - str) - start++; + if (region->end[0] == start - str) { + if (start >= end) break; + start += enclen(reg->enc, start); + } else start = str + region->end[0]; |