diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-09-25 20:12:19 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-09-25 20:12:19 +0000 |
commit | 8ca32b6e6e95f650ccb5c8bfcf15bbc9802ac3d0 (patch) | |
tree | 547da6fa2ad79bfa6d5c52d3a92999bf870365be /regex.c | |
parent | b0001e921299e8f443a9d716d1c4367da3279f4d (diff) |
* 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@13513 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; } |