From: "h.shirosaki (Hiroshi Shirosaki)" Date: 2013-03-13T22:45:50+09:00 Subject: [ruby-core:53373] [ruby-trunk - Bug #8034] File.expand_path('something', '~') do not include home path Issue #8034 has been updated by h.shirosaki (Hiroshi Shirosaki). Assignee changed from h.shirosaki (Hiroshi Shirosaki) to luislavena (Luis Lavena) luislavena (Luis Lavena) wrote: > I've refactored the code, would you mind take a look? > > https://gist.github.com/luislavena/5148562 > Coding style is inconsistent at if/else. Otherwise, looks good to me. Thank you. diff --git a/win32/file.c b/win32/file.c index 53cf085..350f8da 100644 --- a/win32/file.c +++ b/win32/file.c @@ -333,14 +333,12 @@ get_user_from_path(wchar_t **wpath, int offset, UINT cp, UINT path_cp, rb_encodi convert_wchar_to_mb(wuser, &user, &size, cp); /* convert to VALUE and set the path encoding */ - if (path_cp == INVALID_CODE_PAGE) - { + if (path_cp == INVALID_CODE_PAGE) { tmp = rb_enc_str_new(user, size, rb_utf8_encoding()); result = rb_str_encode(tmp, rb_enc_from_encoding(path_encoding), 0, Qnil); rb_str_resize(tmp, 0); } - else - { + else { result = rb_enc_str_new(user, size, path_encoding); } ---------------------------------------- Bug #8034: File.expand_path('something', '~') do not include home path https://bugs.ruby-lang.org/issues/8034#change-37571 Author: rap-kasta (Pavel Manylov) Status: Assigned Priority: Normal Assignee: luislavena (Luis Lavena) Category: platform/windows Target version: ruby -v: 1.9.3p362 =begin Next code works correctly only on ruby <= 1.9.3p362. Tested on Windows XP, Windows 2008 with ruby 1.9.3p194 (works properly), ruby 1.9.3p362 (bug), ruby 2.0.0p0 (bug). (({File.expand_path('something', '~') #=> "C:/path/to/current/dir/~/something"})) However, next code works as it should in all tested rubies: (({File.expand_path '~' # => "C:/Documents and Settings/Jack" Dir.home # => "C:/Documents and Settings/Jack"})) =end -- http://bugs.ruby-lang.org/