diff options
author | ksaito <ksaito@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-04-27 16:20:02 +0000 |
---|---|---|
committer | ksaito <ksaito@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-04-27 16:20:02 +0000 |
commit | 803279135ce8585f31047a9b39200057622f935d (patch) | |
tree | c659eb28d69a5de228d15e17651ea256eda76bc4 /regexec.c | |
parent | 4e85c0322aa3f9843a42ac1955004854dd501df5 (diff) | |
download | ruby-803279135ce8585f31047a9b39200057622f935d.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r6231,
which included commits to RCS files with non-trunk default branches.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 40 |
1 files changed, 32 insertions, 8 deletions
@@ -362,11 +362,26 @@ typedef struct { };\ } while(0) +static unsigned int MatchStackLimitSize = DEFAULT_MATCH_STACK_LIMIT_SIZE; + +extern unsigned int +onig_get_match_stack_limit_size(void) +{ + return MatchStackLimitSize; +} + +extern int +onig_set_match_stack_limit_size(unsigned int size) +{ + MatchStackLimitSize = size; + return 0; +} + static int stack_double(StackType** arg_stk_base, StackType** arg_stk_end, StackType** arg_stk, StackType* stk_alloc, MatchArg* msa) { - int n; + unsigned int n; StackType *x, *stk_base, *stk_end, *stk; stk_base = *arg_stk_base; @@ -385,7 +400,12 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, } else { n *= 2; - if (n > MATCH_STACK_LIMIT_SIZE) return ONIGERR_MATCH_STACK_LIMIT_OVER; + if (MatchStackLimitSize != 0 && n > MatchStackLimitSize) { + if ((unsigned int )(stk_end - stk_base) == MatchStackLimitSize) + return ONIGERR_MATCH_STACK_LIMIT_OVER; + else + n = MatchStackLimitSize; + } x = (StackType* )xrealloc(stk_base, sizeof(StackType) * n); if (IS_NULL(x)) { STACK_SAVE; @@ -2573,11 +2593,13 @@ bm_search_notrev(regex_t* reg, UChar* target, UChar* target_end, if (t < target) return p + 1; skip = reg->map[*s]; - p++; + p = s + 1; + if (p >= text_end) return (UChar* )NULL; t = p; - while ((p - t) < skip) { + do { p += enc_len(reg->enc, *p); - } + } while ((p - t) < skip && p < text_end); + s += (p - t); } } @@ -2591,11 +2613,13 @@ bm_search_notrev(regex_t* reg, UChar* target, UChar* target_end, if (t < target) return p + 1; skip = reg->int_map[*s]; - p++; + p = s + 1; + if (p >= text_end) return (UChar* )NULL; t = p; - while ((p - t) < skip) { + do { p += enc_len(reg->enc, *p); - } + } while ((p - t) < skip && p < text_end); + s += (p - t); } } |