mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* encoding.c (rb_enc_init): use enc_register_at() directly.
* encoding.c (rb_utf8_encoding): returns utf-8 encoding. * include/ruby/encoding.h (rb_utf8_encoding): prototyped. * parse.y (UTF8_ENC): uses rb_utf8_encoding(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
328e6a02bf
commit
12df6cf7ce
4 changed files with 35 additions and 6 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Fri Dec 21 15:59:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* encoding.c (rb_enc_init): use enc_register_at() directly.
|
||||
|
||||
* encoding.c (rb_utf8_encoding): returns utf-8 encoding.
|
||||
|
||||
* include/ruby/encoding.h (rb_utf8_encoding): prototyped.
|
||||
|
||||
* parse.y (UTF8_ENC): uses rb_utf8_encoding().
|
||||
|
||||
Fri Dec 21 15:24:22 2007 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* lib/net/imap.rb (initialize): accept service name. changed
|
||||
|
|
28
encoding.c
28
encoding.c
|
@ -236,14 +236,23 @@ rb_enc_alias(const char *alias, const char *orig)
|
|||
return enc_alias(alias, orig);
|
||||
}
|
||||
|
||||
enum {
|
||||
ENCINDEX_ASCII,
|
||||
ENCINDEX_EUC_JP,
|
||||
ENCINDEX_SJIS,
|
||||
ENCINDEX_UTF8,
|
||||
ENCINDEX_BUILTIN_MAX
|
||||
};
|
||||
|
||||
void
|
||||
rb_enc_init(void)
|
||||
{
|
||||
#define ENC_REGISTER(enc) enc_register(rb_enc_name(enc), enc)
|
||||
ENC_REGISTER(ONIG_ENCODING_ASCII);
|
||||
ENC_REGISTER(ONIG_ENCODING_EUC_JP);
|
||||
ENC_REGISTER(ONIG_ENCODING_SJIS);
|
||||
ENC_REGISTER(ONIG_ENCODING_UTF8);
|
||||
enc_table_count = enc_table_expand(ENCINDEX_BUILTIN_MAX);
|
||||
#define ENC_REGISTER(enc) enc_register_at(ENCINDEX_##enc, rb_enc_name(ONIG_ENCODING_##enc), ONIG_ENCODING_##enc)
|
||||
ENC_REGISTER(ASCII);
|
||||
ENC_REGISTER(EUC_JP);
|
||||
ENC_REGISTER(SJIS);
|
||||
ENC_REGISTER(UTF8);
|
||||
#undef ENC_REGISTER
|
||||
enc_alias("ASCII", rb_enc_name(ONIG_ENCODING_ASCII));
|
||||
enc_alias("BINARY", rb_enc_name(ONIG_ENCODING_ASCII));
|
||||
|
@ -695,6 +704,15 @@ rb_default_encoding(void)
|
|||
return enc_table[0].enc;
|
||||
}
|
||||
|
||||
rb_encoding *
|
||||
rb_utf8_encoding(void)
|
||||
{
|
||||
if (!enc_table) {
|
||||
rb_enc_init();
|
||||
}
|
||||
return enc_table[ENCINDEX_UTF8].enc;
|
||||
}
|
||||
|
||||
static int default_external_index;
|
||||
|
||||
rb_encoding *
|
||||
|
|
|
@ -114,6 +114,7 @@ int rb_enc_str_asciionly_p(VALUE);
|
|||
#define rb_enc_str_asciicompat_p(str) rb_enc_asciicompat(rb_enc_get(str))
|
||||
VALUE rb_enc_from_encoding(rb_encoding *enc);
|
||||
rb_encoding *rb_default_encoding(void);
|
||||
rb_encoding *rb_utf8_encoding(void);
|
||||
rb_encoding *rb_default_external_encoding(void);
|
||||
VALUE rb_enc_default_external(void);
|
||||
void rb_enc_set_default_external(VALUE encoding);
|
||||
|
|
2
parse.y
2
parse.y
|
@ -266,7 +266,7 @@ struct parser_params {
|
|||
};
|
||||
|
||||
#define UTF8_ENC() (parser->utf8 ? parser->utf8 : \
|
||||
(parser->utf8 = rb_enc_find("utf-8")))
|
||||
(parser->utf8 = rb_utf8_encoding()))
|
||||
#define STR_NEW(p,n) rb_enc_str_new((p),(n),parser->enc)
|
||||
#define STR_NEW0() rb_str_new(0,0)
|
||||
#define STR_NEW2(p) rb_enc_str_new((p),strlen(p),parser->enc)
|
||||
|
|
Loading…
Reference in a new issue