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:
parent
aa1acf1d42
commit
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
|
* encoding.c (rb_enc_set_index, rb_enc_associate_index): validate
|
||||||
argument encoding index.
|
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),
|
VALUE str = rb_sprintf("#<%s:%s%s>", rb_obj_classname(self),
|
||||||
rb_enc_name((rb_encoding*)DATA_PTR(self)),
|
rb_enc_name((rb_encoding*)DATA_PTR(self)),
|
||||||
(enc_dummy_p(self) ? " (dummy)" : ""));
|
(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;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1220,9 +1220,9 @@ rb_locale_encindex(void)
|
|||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
if (NIL_P(charmap))
|
if (NIL_P(charmap))
|
||||||
idx = rb_usascii_encindex();
|
idx = ENCINDEX_US_ASCII;
|
||||||
else if ((idx = rb_enc_find_index(StringValueCStr(charmap))) < 0)
|
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);
|
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];
|
char cp[sizeof(int) * 8 / 3 + 4];
|
||||||
snprintf(cp, sizeof cp, "CP%d", AreFileApisANSI() ? GetACP() : GetOEMCP());
|
snprintf(cp, sizeof cp, "CP%d", AreFileApisANSI() ? GetACP() : GetOEMCP());
|
||||||
idx = rb_enc_find_index(cp);
|
idx = rb_enc_find_index(cp);
|
||||||
if (idx < 0) idx = rb_ascii8bit_encindex();
|
if (idx < 0) idx = ENCINDEX_ASCII;
|
||||||
#else
|
#else
|
||||||
idx = rb_enc_to_index(rb_default_external_encoding());
|
idx = rb_enc_to_index(rb_default_external_encoding());
|
||||||
#endif
|
#endif
|
||||||
@ -1259,7 +1259,7 @@ rb_filesystem_encindex(void)
|
|||||||
{
|
{
|
||||||
int idx = rb_enc_registered("filesystem");
|
int idx = rb_enc_registered("filesystem");
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
idx = rb_ascii8bit_encindex();
|
idx = ENCINDEX_ASCII;
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user