From 34cc6247c67e8f99ef5927c43dbb9435853943f0 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Tue, 3 Jun 2008 07:17:01 +0000 Subject: 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 --- regex.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'regex.c') diff --git a/regex.c b/regex.c index fa04871c1b..a7a831286e 100644 --- a/regex.c +++ b/regex.c @@ -3108,6 +3108,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; @@ -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; } -- cgit v1.2.3