* string.c (rb_str_new): set US-ASCII and ENC_CODERANGE_7BIT when

empty string (len == 0).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2008-01-26 00:18:50 +00:00
parent 2160c40fb2
commit df17bd4313
2 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Sat Jan 26 09:17:13 2008 NARUSE, Yui <naruse@ruby-lang.org>
* string.c (rb_str_new): set US-ASCII and ENC_CODERANGE_7BIT when
empty string (len == 0).
Sat Jan 26 03:41:53 2008 NAKAMURA Usaku <usa@ruby-lang.org> Sat Jan 26 03:41:53 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* parse.y (parser_initialize): set default script encoding as US-ASCII. * parse.y (parser_initialize): set default script encoding as US-ASCII.

View File

@ -278,7 +278,7 @@ str_new(VALUE klass, const char *ptr, long len)
if (ptr) { if (ptr) {
memcpy(RSTRING_PTR(str), ptr, len); memcpy(RSTRING_PTR(str), ptr, len);
} }
else { if (len == 0) {
ENCODING_CODERANGE_SET(str, rb_usascii_encindex(), ENC_CODERANGE_7BIT); ENCODING_CODERANGE_SET(str, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
} }
STR_SET_LEN(str, len); STR_SET_LEN(str, len);