diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-27 14:27:07 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-27 14:27:07 +0000 |
commit | a2e8e2022bcab4dd87ee5cf6f1ef1d9df1cf4c98 (patch) | |
tree | f29aa519ea99cfcb7a7f13ec44508510d9291a0b /include/ruby/oniguruma.h | |
parent | c34eb9c4312bd142822fefcf0a04ae61ff79c635 (diff) | |
download | ruby-a2e8e2022bcab4dd87ee5cf6f1ef1d9df1cf4c98.tar.gz ruby-a2e8e2022bcab4dd87ee5cf6f1ef1d9df1cf4c98.tar.xz ruby-a2e8e2022bcab4dd87ee5cf6f1ef1d9df1cf4c98.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@15280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/oniguruma.h')
-rw-r--r-- | include/ruby/oniguruma.h | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/include/ruby/oniguruma.h b/include/ruby/oniguruma.h index 5626230a8..6d08f61f0 100644 --- a/include/ruby/oniguruma.h +++ b/include/ruby/oniguruma.h @@ -229,32 +229,23 @@ ONIG_EXTERN OnigEncodingType OnigEncodingASCII; #define ONIGENC_STEP_BACK(enc,start,s,n) \ onigenc_step_back((enc),(start),(s),(n)) - #define ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(n) (n) +#define ONIGENC_MBCLEN_CHARFOUND_P(r) (0 < (r)) +#define ONIGENC_MBCLEN_CHARFOUND_LEN(r) (r) + #define ONIGENC_CONSTRUCT_MBCLEN_INVALID() (-1) -#define ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(n) (-1-(n)) +#define ONIGENC_MBCLEN_INVALID_P(r) ((r) == -1) -static inline int onigenc_mbclen_charfound(int r) { return 0 < r ? r : 0; } -static inline int onigenc_mbclen_needmore(int r) { return r < -1 ? -1 - r : 0; } -#define ONIGENC_MBCLEN_CHARFOUND(r) onigenc_mbclen_charfound(r) -#define ONIGENC_MBCLEN_INVALID(r) ((r) == -1) -#define ONIGENC_MBCLEN_NEEDMORE(r) onigenc_mbclen_needmore(r) +#define ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(n) (-1-(n)) +#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) -static inline int onigenc_mbclen_recover(const OnigUChar* p,const OnigUChar* e, struct OnigEncodingTypeST* enc) -{ - int ret = ONIGENC_PRECISE_MBC_ENC_LEN(enc,p,e); - int r; - if (ONIGENC_MBCLEN_INVALID(ret)) - return 1; - else if ((r = ONIGENC_MBCLEN_NEEDMORE(ret))) - return e-p+r; - else - return ONIGENC_MBCLEN_CHARFOUND(ret); -} +ONIG_EXTERN +int onigenc_mbclen_approximate P_((const OnigUChar* p,const OnigUChar* e, struct OnigEncodingTypeST* enc)); -#define ONIGENC_MBC_ENC_LEN(enc,p,e) onigenc_mbclen_recover(p,e,enc) +#define ONIGENC_MBC_ENC_LEN(enc,p,e) onigenc_mbclen_approximate(p,e,enc) #define ONIGENC_MBC_MAXLEN(enc) ((enc)->max_enc_len) #define ONIGENC_MBC_MAXLEN_DIST(enc) ONIGENC_MBC_MAXLEN(enc) #define ONIGENC_MBC_MINLEN(enc) ((enc)->min_enc_len) |