зеркало из https://github.com/github/ruby.git
* 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:
Родитель
974b30a902
Коммит
8a5ffe48e5
|
@ -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>
|
||||
|
||||
* io.c (argf_rewind): need to rewind $. and ARGF.lineno.
|
||||
|
|
|
@ -1945,10 +1945,15 @@ int_chr(int argc, VALUE *argv, VALUE num)
|
|||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
if (i < 0 || 0xff < i) {
|
||||
if (i < 0) {
|
||||
out_of_range:
|
||||
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;
|
||||
if (i < 0x80) {
|
||||
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]);
|
||||
if (!enc) enc = rb_ascii8bit_encoding();
|
||||
decode:
|
||||
#if SIZEOF_INT < SIZEOF_LONG
|
||||
if (i > INT_MAX) goto out_of_range;
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче