1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (rb_external_str_new_with_enc): set ASCII-8BIT if

encoding is US-ASCII and string contains 8bit characters.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-12-23 15:13:18 +00:00
parent b317b345e8
commit 5e62997245
3 changed files with 12 additions and 7 deletions

View file

@ -167,6 +167,11 @@ Mon Dec 22 18:00:36 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/tcltklib.c: fix wrong flag value.
Mon Dec 22 14:35:59 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_external_str_new_with_enc): set ASCII-8BIT if
encoding is US-ASCII and string contains 8bit characters.
Mon Dec 22 12:26:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* cygwin/GNUmakefile.in (rubydll.def), win32/mkexports.rb

View file

@ -7923,13 +7923,8 @@ gettable_gen(struct parser_params *parser, ID id)
return NEW_FALSE();
}
else if (id == keyword__FILE__) {
VALUE str = rb_external_str_new_with_enc(ruby_sourcefile, strlen(ruby_sourcefile),
rb_filesystem_encoding());
if (rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT &&
ENCODING_GET(str) == rb_usascii_encindex()) {
rb_enc_associate(str, rb_ascii8bit_encoding());
}
return NEW_STR(str);
return NEW_STR(rb_external_str_new_with_enc(ruby_sourcefile, strlen(ruby_sourcefile),
rb_filesystem_encoding()));
}
else if (id == keyword__LINE__) {
return NEW_LIT(INT2FIX(ruby_sourceline));

View file

@ -538,6 +538,11 @@ rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
VALUE str;
str = rb_tainted_str_new(ptr, len);
if (rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT &&
eenc == rb_usascii_encoding()) {
rb_enc_associate(str, rb_ascii8bit_encoding());
return str;
}
rb_enc_associate(str, eenc);
return rb_str_conv_enc(str, eenc, rb_default_internal_encoding());
}