mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* regex.c (re_adjust_startpos): fix for SJIS.
* regex.c (mbc_startpos): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7ddde51c68
commit
ae2d54d91d
2 changed files with 25 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Jan 30 15:58:04 2002 K.Kosako <kosako@sofnec.co.jp>
|
||||
|
||||
* regex.c (re_adjust_startpos): fix for SJIS.
|
||||
|
||||
* regex.c (mbc_startpos): ditto.
|
||||
|
||||
Wed Jan 30 02:25:38 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* regex.c (re_adjust_startpos): search start of multibyte
|
||||
|
|
26
regex.c
26
regex.c
|
@ -3080,11 +3080,17 @@ re_adjust_startpos(bufp, string, size, startpos, range)
|
|||
if (current_mbctype && startpos>0 && !(bufp->options&RE_OPTIMIZE_BMATCH)) {
|
||||
int i = mbc_startpos(string, startpos);
|
||||
|
||||
if (i < startpos && range > 0) {
|
||||
startpos = i + mbclen(string[i]);
|
||||
}
|
||||
else {
|
||||
startpos = i;
|
||||
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;
|
||||
|
@ -4570,10 +4576,16 @@ mbc_startpos(string, pos)
|
|||
|
||||
switch (current_mbctype) {
|
||||
case MBCTYPE_EUC:
|
||||
case MBCTYPE_SJIS:
|
||||
/* double byte char only */
|
||||
return i + ((pos - i) & ~1);
|
||||
|
||||
case MBCTYPE_SJIS:
|
||||
while (i + (w = mbclen(string[i])) < pos) {
|
||||
i += w;
|
||||
}
|
||||
return i;
|
||||
|
||||
case MBCTYPE_UTF8:
|
||||
return i;
|
||||
default:
|
||||
return pos;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue