diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-06 09:28:26 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-06 09:28:26 +0000 |
| commit | 69406aad505414de34dc8b560ac1eadf147b0dbc (patch) | |
| tree | 161d7248925c7bd2c99d3ed6a341e81ba76b40c4 /include/ruby/encoding.h | |
| parent | de4ec689910c07a48b81083adc3130b6b6023be3 (diff) | |
* encoding.c (rb_enc_precise_mbclen): new function for mbclen with
validation.
* include/ruby/encoding.h (rb_enc_precise_mbclen): declared.
(MBCLEN_CHARFOUND): new macro.
(MBCLEN_INVALID): new macro.
(MBCLEN_NEEDMORE): new macro.
* include/ruby/oniguruma.h (OnigEncodingTypeST): replace mbc_enc_len
by precise_mbc_enc_len.
(ONIGENC_PRECISE_MBC_ENC_LEN): new macro.
(ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND): new macro.
(ONIGENC_CONSTRUCT_MBCLEN_INVALID): new macro.
(ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE): new macro.
(ONIGENC_MBCLEN_CHARFOUND): new macro.
(ONIGENC_MBCLEN_INVALID): new macro.
(ONIGENC_MBCLEN_NEEDMORE): new macro.
(ONIGENC_MBC_ENC_LEN): use ONIGENC_PRECISE_MBC_ENC_LEN.
* enc/euc_jp.c: validation implemented.
* enc/sjis.c: ditto.
* enc/utf8.c: ditto.
* string.c (rb_str_inspect): use rb_enc_precise_mbclen for invalid
encoding.
(rb_str_valid_encoding_p): new method String#valid_encoding?.
* io.c (rb_io_getc): use rb_enc_precise_mbclen.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/encoding.h')
| -rw-r--r-- | include/ruby/encoding.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index bdef191338..a800f54274 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -68,9 +68,15 @@ rb_encoding * rb_enc_find(const char *name); #define rb_enc_mbminlen(enc) (enc)->min_enc_len #define rb_enc_mbmaxlen(enc) (enc)->max_enc_len -/* ptr,encoding -> mbclen */ +/* ptr,endptr,encoding -> mbclen */ int rb_enc_mbclen(const char*, const char *, rb_encoding*); +/* ptr,endptr,encoding -> chlen, invalid or needmore */ +int rb_enc_precise_mbclen(const char*, const char *, rb_encoding*); +#define MBCLEN_CHARFOUND(ret) ONIGENC_MBCLEN_CHARFOUND(ret) +#define MBCLEN_INVALID(ret) ONIGENC_MBCLEN_INVALID(ret) +#define MBCLEN_NEEDMORE(ret) ONIGENC_MBCLEN_NEEDMORE(ret) + /* code,encoding -> codelen */ int rb_enc_codelen(int, rb_encoding*); |
