mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* numeric.c (int_chr): use default_internal encoding as default
destination encoding if set. [ruby-dev:38717] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
974b30a902
commit
8a5ffe48e5
2 changed files with 12 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Jun 27 03:16:56 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* numeric.c (int_chr): use default_internal encoding as default
|
||||||
|
destination encoding if set. [ruby-dev:38717]
|
||||||
|
|
||||||
Sat Jun 27 03:09:04 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Sat Jun 27 03:09:04 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* io.c (argf_rewind): need to rewind $. and ARGF.lineno.
|
* io.c (argf_rewind): need to rewind $. and ARGF.lineno.
|
||||||
|
|
|
@ -1945,10 +1945,15 @@ int_chr(int argc, VALUE *argv, VALUE num)
|
||||||
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 0:
|
case 0:
|
||||||
if (i < 0 || 0xff < i) {
|
if (i < 0) {
|
||||||
out_of_range:
|
out_of_range:
|
||||||
rb_raise(rb_eRangeError, "%"PRIdVALUE " out of char range", i);
|
rb_raise(rb_eRangeError, "%"PRIdVALUE " out of char range", i);
|
||||||
}
|
}
|
||||||
|
if (0xff < i) {
|
||||||
|
enc = rb_default_internal_encoding();
|
||||||
|
if (!enc) goto out_of_range;
|
||||||
|
goto decode;
|
||||||
|
}
|
||||||
c = (char)i;
|
c = (char)i;
|
||||||
if (i < 0x80) {
|
if (i < 0x80) {
|
||||||
return rb_usascii_str_new(&c, 1);
|
return rb_usascii_str_new(&c, 1);
|
||||||
|
@ -1964,6 +1969,7 @@ int_chr(int argc, VALUE *argv, VALUE num)
|
||||||
}
|
}
|
||||||
enc = rb_to_encoding(argv[0]);
|
enc = rb_to_encoding(argv[0]);
|
||||||
if (!enc) enc = rb_ascii8bit_encoding();
|
if (!enc) enc = rb_ascii8bit_encoding();
|
||||||
|
decode:
|
||||||
#if SIZEOF_INT < SIZEOF_LONG
|
#if SIZEOF_INT < SIZEOF_LONG
|
||||||
if (i > INT_MAX) goto out_of_range;
|
if (i > INT_MAX) goto out_of_range;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue