diff --git a/ChangeLog b/ChangeLog index afd7a508c8..58b7e4028c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Jan 30 02:25:38 2002 Nobuyoshi Nakada + + * regex.c (re_adjust_startpos): search start of multibyte + backward. + + * regex.c (mbc_startpos): ditto. + Tue Jan 29 17:59:20 2002 Tanaka Akira * file.c: `major' and `minor' macro needs sys/mkdev.h on SunOS 5.x. diff --git a/regex.c b/regex.c index 64d32151ed..eb14a38a41 100644 --- a/regex.c +++ b/regex.c @@ -478,6 +478,8 @@ re_set_syntax(syntax) #define WC2MBC1ST(c) \ ((current_mbctype != MBCTYPE_UTF8) ? ((c<0x100) ? (c) : (((c)>>8)&0xff)) : utf8_firstbyte(c)) +int mbc_startpos _((const char *start, int pos)); + static unsigned int utf8_firstbyte(c) unsigned long c; @@ -3076,28 +3078,13 @@ 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 = 0; + int i = mbc_startpos(string, startpos); - if (range > 0) { - while (i 0) { + startpos = i + mbclen(string[i]); } else { - int w; - - while (i 0 && re_mbctab[(unsigned char)string[i]+256]) { + --i; + } + if (i == pos || i + (w = mbclen(string[i])) > pos) return i; + i += w; + + switch (current_mbctype) { + case MBCTYPE_EUC: + case MBCTYPE_SJIS: + /* double byte char only */ + return i + ((pos - i) & ~1); + case MBCTYPE_UTF8: + default: + return pos; + } +} + +/* + vi: sw=2 ts=8 + Local variables: + mode : C + c-file-style : "gnu" + tab-width : 8 + End : +*/ diff --git a/version.h b/version.h index c52dd9aeec..a5b1a71dd9 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.2" -#define RUBY_RELEASE_DATE "2002-01-28" +#define RUBY_RELEASE_DATE "2002-01-30" #define RUBY_VERSION_CODE 172 -#define RUBY_RELEASE_CODE 20020128 +#define RUBY_RELEASE_CODE 20020130