diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-03 07:17:01 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-03 07:17:01 +0000 |
commit | 34cc6247c67e8f99ef5927c43dbb9435853943f0 (patch) | |
tree | 14eee8b6a45566a8abc2cc5210050958638ab527 /regex.c | |
parent | 2062a9149e8a4232b08520200b18a393782e87dd (diff) |
merge revision(s) 13513:
* parse.y (yyerror): limit error message length. [ruby-dev:31848]
* regex.c (re_mbc_startpos): separated from re_adjust_startpos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@16788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regex.c')
-rw-r--r-- | regex.c | 37 |
1 files changed, 23 insertions, 14 deletions
@@ -3109,6 +3109,28 @@ re_compile_fastmap(bufp) /* adjust startpos value to the position between characters. */ int +re_mbc_startpos(string, size, startpos, range) + const char *string; + int size, startpos, range; +{ + int i = mbc_startpos(string, startpos); + + if (i < startpos) { + if (range > 0) { + startpos = i + mbclen(string[i]); + } + else { + int len = mbclen(string[i]); + if (i + len <= startpos) + startpos = i + len; + else + startpos = i; + } + } + return startpos; +} + +int re_adjust_startpos(bufp, string, size, startpos, range) struct re_pattern_buffer *bufp; const char *string; @@ -3121,20 +3143,7 @@ re_adjust_startpos(bufp, string, size, startpos, range) /* Adjust startpos for mbc string */ if (current_mbctype && startpos>0 && !(bufp->options&RE_OPTIMIZE_BMATCH)) { - int i = mbc_startpos(string, startpos); - - if (i < startpos) { - if (range > 0) { - startpos = i + mbclen(string[i]); - } - else { - int len = mbclen(string[i]); - if (i + len <= startpos) - startpos = i + len; - else - startpos = i; - } - } + startpos = re_mbc_startpos(string, size, startpos, range); } return startpos; } |