зеркало из https://github.com/github/ruby.git
encoding.c: use built-in encoding indexes
* encoding.c (enc_inspect, rb_locale_encindex), (enc_set_filesystem_encoding, rb_filesystem_encindex): use built-in encoding indexes directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
aa1acf1d42
Коммит
869a1b5876
|
@ -1,4 +1,8 @@
|
|||
Tue Jul 2 17:22:16 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Tue Jul 2 17:22:21 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* encoding.c (enc_inspect, rb_locale_encindex),
|
||||
(enc_set_filesystem_encoding, rb_filesystem_encindex): use built-in
|
||||
encoding indexes directly.
|
||||
|
||||
* encoding.c (rb_enc_set_index, rb_enc_associate_index): validate
|
||||
argument encoding index.
|
||||
|
|
10
encoding.c
10
encoding.c
|
@ -1005,7 +1005,7 @@ enc_inspect(VALUE self)
|
|||
VALUE str = rb_sprintf("#<%s:%s%s>", rb_obj_classname(self),
|
||||
rb_enc_name((rb_encoding*)DATA_PTR(self)),
|
||||
(enc_dummy_p(self) ? " (dummy)" : ""));
|
||||
ENCODING_CODERANGE_SET(str, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
|
||||
ENCODING_CODERANGE_SET(str, ENCINDEX_US_ASCII, ENC_CODERANGE_7BIT);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -1220,9 +1220,9 @@ rb_locale_encindex(void)
|
|||
int idx;
|
||||
|
||||
if (NIL_P(charmap))
|
||||
idx = rb_usascii_encindex();
|
||||
idx = ENCINDEX_US_ASCII;
|
||||
else if ((idx = rb_enc_find_index(StringValueCStr(charmap))) < 0)
|
||||
idx = rb_ascii8bit_encindex();
|
||||
idx = ENCINDEX_ASCII;
|
||||
|
||||
if (rb_enc_registered("locale") < 0) enc_alias_internal("locale", idx);
|
||||
|
||||
|
@ -1245,7 +1245,7 @@ enc_set_filesystem_encoding(void)
|
|||
char cp[sizeof(int) * 8 / 3 + 4];
|
||||
snprintf(cp, sizeof cp, "CP%d", AreFileApisANSI() ? GetACP() : GetOEMCP());
|
||||
idx = rb_enc_find_index(cp);
|
||||
if (idx < 0) idx = rb_ascii8bit_encindex();
|
||||
if (idx < 0) idx = ENCINDEX_ASCII;
|
||||
#else
|
||||
idx = rb_enc_to_index(rb_default_external_encoding());
|
||||
#endif
|
||||
|
@ -1259,7 +1259,7 @@ rb_filesystem_encindex(void)
|
|||
{
|
||||
int idx = rb_enc_registered("filesystem");
|
||||
if (idx < 0)
|
||||
idx = rb_ascii8bit_encindex();
|
||||
idx = ENCINDEX_ASCII;
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче