From da4d53795fe404e58a706c387c01b7c5b2bafc2a Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 19 May 2009 16:59:22 +0000 Subject: * encoding.c (rb_enc_codepoint_len): combine rb_enc_codepoint() and rb_enc_codelen() in one function to reduce calls. * encoding.c (rb_enc_codepoint): compatibility function. * sprintf.c (rb_str_format): use rb_enc_codepoint_len(). * string.c (rb_str_inspect, rb_str_upcase_bang, rb_str_downcase_bang, rb_str_capitalize_bang, rb_str_swapcase_bang, trnext, tr_trans, rb_str_delete_bang, rb_str_squeeze_bang, rb_str_count, rb_str_split_m, rb_str_each_line, rb_str_each_codepoint, rb_str_lstrip_bang, sym_printable): ditto. * transcode.c (make_econv_exception): use rb_enc_mbc_to_codepoint() git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/encoding.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include/ruby') diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 48b162174..4f6608cb1 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -123,8 +123,14 @@ int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc); /* -> 0x00..0x7f, -1 */ int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc); -/* -> code or raise exception */ + +/* -> code (and len) or raise exception */ +unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len, rb_encoding *enc); + +/* prototype for obsolete function */ unsigned int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc); +/* overriding macro */ +#define rb_enc_codepoint(p,e,enc) rb_enc_codepoint_len((p),(e),0,(enc)) #define rb_enc_mbc_to_codepoint(p, e, enc) ONIGENC_MBC_TO_CODE(enc,(UChar*)(p),(UChar*)(e)) /* -> codelen>0 or raise exception */ -- cgit