зеркало из https://github.com/github/ruby.git
Revert r41786 "broken utf-8"
revert unexpected commit git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
b0bc85f933
Коммит
9ae509504b
|
@ -233,12 +233,12 @@ mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc ARG_UNUSED)
|
|||
if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-2);
|
||||
s = trans[s][*p++];
|
||||
if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(3) :
|
||||
ONIGENC_CONSTRUCT_MBCLEN_INVALID2(2);
|
||||
ONIGENC_CONSTRUCT_MBCLEN_INVALID();
|
||||
|
||||
if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-3);
|
||||
s = trans[s][*p++];
|
||||
return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(4) :
|
||||
ONIGENC_CONSTRUCT_MBCLEN_INVALID2(3);
|
||||
ONIGENC_CONSTRUCT_MBCLEN_INVALID();
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -246,14 +246,11 @@ ONIG_EXTERN OnigEncodingType OnigEncodingASCII;
|
|||
#define ONIGENC_MBCLEN_CHARFOUND_P(r) (0 < (r))
|
||||
#define ONIGENC_MBCLEN_CHARFOUND_LEN(r) (r)
|
||||
|
||||
#define ONIGENC_INVALID_NUM 0x10000
|
||||
#define ONIGENC_CONSTRUCT_MBCLEN_INVALID() (-1-ONIGENC_INVALID_NUM)
|
||||
#define ONIGENC_CONSTRUCT_MBCLEN_INVALID2(n) (-(n)-ONIGENC_INVALID_NUM)
|
||||
#define ONIGENC_MBCLEN_INVALID_P(r) ((r) < -ONIGENC_INVALID_NUM)
|
||||
#define ONIGENC_MBCLEN_INVALID_LEN(r) (-(r)-ONIGENC_INVALID_NUM)
|
||||
#define ONIGENC_CONSTRUCT_MBCLEN_INVALID() (-1)
|
||||
#define ONIGENC_MBCLEN_INVALID_P(r) ((r) == -1)
|
||||
|
||||
#define ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(n) (-1-(n))
|
||||
#define ONIGENC_MBCLEN_NEEDMORE_P(r) (-ONIGENC_INVALID_NUM <= (r) && (r) < -1)
|
||||
#define ONIGENC_MBCLEN_NEEDMORE_P(r) ((r) < -1)
|
||||
#define ONIGENC_MBCLEN_NEEDMORE_LEN(r) (-1-(r))
|
||||
|
||||
#define ONIGENC_PRECISE_MBC_ENC_LEN(enc,p,e) (enc)->precise_mbc_enc_len(p,e,enc)
|
||||
|
|
8
regenc.c
8
regenc.c
|
@ -55,12 +55,10 @@ extern int
|
|||
onigenc_mbclen_approximate(const OnigUChar* p,const OnigUChar* e, struct OnigEncodingTypeST* enc)
|
||||
{
|
||||
int ret = ONIGENC_PRECISE_MBC_ENC_LEN(enc,p,e);
|
||||
if (ONIGENC_MBCLEN_NEEDMORE_P(ret))
|
||||
return (int)(e-p)+ONIGENC_MBCLEN_NEEDMORE_LEN(ret);
|
||||
else if (ONIGENC_MBCLEN_INVALID_P(ret))
|
||||
return (int)(e-p)+ONIGENC_MBCLEN_INVALID_LEN(ret);
|
||||
else if (ONIGENC_MBCLEN_CHARFOUND_P(ret))
|
||||
if (ONIGENC_MBCLEN_CHARFOUND_P(ret))
|
||||
return ONIGENC_MBCLEN_CHARFOUND_LEN(ret);
|
||||
else if (ONIGENC_MBCLEN_NEEDMORE_P(ret))
|
||||
return (int)(e-p)+ONIGENC_MBCLEN_NEEDMORE_LEN(ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче