summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-27 14:27:07 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-27 14:27:07 +0000
commitfc208c1bd56a4e3fc03cb2f54616b4479f4b0e41 (patch)
treef29aa519ea99cfcb7a7f13ec44508510d9291a0b /encoding.c
parent526ab1f0d15247da489cb2fc8af8d4c3f1a71cc2 (diff)
* include/ruby/oniguruma.h: precise mbclen API redesigned to avoid
inline functions. (onigenc_mbclen_charfound): removed. (onigenc_mbclen_needmore): removed. (onigenc_mbclen_recover): removed. (ONIGENC_MBCLEN_CHARFOUND): removed. (ONIGENC_MBCLEN_CHARFOUND_P): defined. (ONIGENC_MBCLEN_CHARFOUND_LEN): defined. (ONIGENC_MBCLEN_INVALID): removed. (ONIGENC_MBCLEN_INVALID_P): defined. (ONIGENC_MBCLEN_NEEDMORE): removed. (ONIGENC_MBCLEN_NEEDMORE_P): defined. (ONIGENC_MBCLEN_NEEDMORE_LEN): defined. (ONIGENC_MBC_ENC_LEN): use onigenc_mbclen_approximate. * regenc.c (onigenc_mbclen_approximate): defined. * include/ruby/encoding.h (MBCLEN_CHARFOUND): removed. (MBCLEN_INVALID): removed. (MBCLEN_NEEDMORE): removed. (MBCLEN_CHARFOUND_P): defined. (MBCLEN_INVALID_P): defined. (MBCLEN_NEEDMORE_P): defined. (MBCLEN_CHARFOUND_LEN): defined. (MBCLEN_NEEDMORE_LEN): defined. * encoding.c: use new API. * re.c: ditto. * string.c: ditto. * parse.y: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/encoding.c b/encoding.c
index 961c3c4f3d..a23f52b356 100644
--- a/encoding.c
+++ b/encoding.c
@@ -749,9 +749,8 @@ int
rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
{
int n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e);
- n = MBCLEN_CHARFOUND(n);
- if (0 < n && n <= e-p)
- return n;
+ if (MBCLEN_CHARFOUND_P(n) && MBCLEN_CHARFOUND_LEN(n) <= e-p)
+ return MBCLEN_CHARFOUND_LEN(n);
else
return 1;
}
@@ -782,7 +781,7 @@ rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
return c;
}
l = rb_enc_precise_mbclen(p, e, enc);
- if (!MBCLEN_CHARFOUND(l))
+ if (!MBCLEN_CHARFOUND_P(l))
return -1;
c = rb_enc_codepoint(p, e, enc);
if (!rb_enc_isascii(c, enc))
@@ -798,7 +797,7 @@ rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc)
if (e <= p)
rb_raise(rb_eArgError, "empty string");
r = rb_enc_precise_mbclen(p, e, enc);
- if (MBCLEN_CHARFOUND(r))
+ if (MBCLEN_CHARFOUND_P(r))
return rb_enc_mbc_to_codepoint(p, e, enc);
else
rb_raise(rb_eArgError, "invalid mbstring sequence");