* hash.c (env_str_new, rb_f_getenv, env_fetch): use rb_str_conv_enc()

instead of rb_str_encode() to simplify the code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2012-03-15 04:49:20 +00:00
Родитель fcaee4bd64
Коммит f59caa2950
2 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Thu Mar 15 13:47:17 2012 NAKAMURA Usaku <usa@ruby-lang.org>
* hash.c (env_str_new, rb_f_getenv, env_fetch): use rb_str_conv_enc()
instead of rb_str_encode() to simplify the code.
Thu Mar 15 12:44:50 2012 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c, include/ruby/win32.h (rb_w32_ugetenv): new API to
@ -108,8 +113,8 @@ Wed Mar 14 18:25:18 2012 Shugo Maeda <shugo@ruby-lang.org>
Wed Mar 14 17:55:29 2012 NAKAMURA Usaku <usa@ruby-lang.org>
* numeric.c (flodivmod): must through the same pass if HAVE_FMOD or not.
this is a bugfix of r35013.
* numeric.c (flodivmod): must go through the same pass if HAVE_FMOD or
not. this is a bugfix of r35013.
Wed Mar 14 16:41:55 2012 NAKAMURA Usaku <usa@ruby-lang.org>

6
hash.c
Просмотреть файл

@ -2032,7 +2032,7 @@ static VALUE
env_str_new(const char *ptr, long len)
{
#ifdef _WIN32
VALUE str = rb_str_encode(rb_enc_str_new(ptr, len, rb_utf8_encoding()), rb_enc_from_encoding(rb_locale_encoding()), 0, Qnil);
VALUE str = rb_str_conv_enc(rb_str_new(ptr, len), rb_utf8_encoding(), rb_locale_encoding());
#else
VALUE str = rb_locale_str_new(ptr, len);
#endif
@ -2115,7 +2115,7 @@ rb_f_getenv(VALUE obj, VALUE name)
if (env) {
if (ENVMATCH(nam, PATH_ENV) && !env_path_tainted(env)) {
#ifdef _WIN32
VALUE str = rb_str_encode(rb_enc_str_new(env, strlen(env), rb_utf8_encoding()), rb_enc_from_encoding(rb_filesystem_encoding()), 0, Qnil);
VALUE str = rb_str_conv_enc(rb_str_new(env, strlen(env)), rb_utf8_encoding(), rb_filesystem_encoding());
#else
VALUE str = rb_filesystem_str_new_cstr(env);
#endif
@ -2170,7 +2170,7 @@ env_fetch(int argc, VALUE *argv)
}
if (ENVMATCH(nam, PATH_ENV) && !env_path_tainted(env))
#ifdef _WIN32
return rb_str_encode(rb_enc_str_new(env, strlen(env), rb_utf8_encoding()), rb_enc_from_encoding(rb_filesystem_encoding()), 0, Qnil);
return rb_str_conv_enc(rb_str_new(env, strlen(env)), rb_utf8_encoding(), rb_filesystem_encoding());
#else
return rb_filesystem_str_new_cstr(env);
#endif