ruby-changes:22300
From: nobu <ko1@a...>
Date: Sat, 21 Jan 2012 11:44:00 +0900 (JST)
Subject: [ruby-changes:22300] nobu:r34348 (trunk): * dir.c (dir_chdir, check_dirname): get rid of optimization-out.
nobu 2012-01-21 11:43:48 +0900 (Sat, 21 Jan 2012) New Revision: 34348 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34348 Log: * dir.c (dir_chdir, check_dirname): get rid of optimization-out. Modified files: trunk/ChangeLog trunk/dir.c Index: ChangeLog =================================================================== --- ChangeLog (revision 34347) +++ ChangeLog (revision 34348) @@ -1,3 +1,7 @@ +Sat Jan 21 11:43:45 2012 Nobuyoshi Nakada <nobu@r...> + + * dir.c (dir_chdir, check_dirname): get rid of optimization-out. + Fri Jan 20 20:47:37 2012 Kenta Murata <mrkn@c...> * lib/cgi/util.rb (CGI.escape): support a string with invalid byte Index: dir.c =================================================================== --- dir.c (revision 34347) +++ dir.c (revision 34348) @@ -749,7 +749,6 @@ static void dir_chdir(VALUE path) { - path = rb_str_encode_ospath(path); if (chdir(RSTRING_PTR(path)) < 0) rb_sys_fail(RSTRING_PTR(path)); } @@ -832,6 +831,7 @@ rb_secure(2); if (rb_scan_args(argc, argv, "01", &path) == 1) { FilePathValue(path); + path = rb_str_encode_ospath(path); } else { const char *dist = getenv("HOME"); @@ -849,9 +849,8 @@ if (rb_block_given_p()) { struct chdir_data args; - char *cwd = my_getcwd(); - args.old_path = rb_tainted_str_new2(cwd); xfree(cwd); + args.old_path = rb_str_encode_ospath(rb_dir_getwd()); args.new_path = path; args.done = FALSE; return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args); @@ -896,14 +895,16 @@ static void check_dirname(volatile VALUE *dir) { + VALUE d = *dir; char *path, *pend; rb_secure(2); - FilePathValue(*dir); - path = RSTRING_PTR(*dir); + FilePathValue(d); + path = RSTRING_PTR(d); if (path && *(pend = rb_path_end(rb_path_skip_prefix(path)))) { - *dir = rb_str_new(path, pend - path); + d = rb_str_subseq(d, 0, pend - path); } + *dir = rb_str_encode_ospath(d); } #if defined(HAVE_CHROOT) @@ -920,8 +921,6 @@ dir_s_chroot(VALUE dir, VALUE path) { check_dirname(&path); - - path = rb_str_encode_ospath(path); if (chroot(RSTRING_PTR(path)) == -1) rb_sys_fail(RSTRING_PTR(path)); @@ -960,7 +959,6 @@ } check_dirname(&path); - path = rb_str_encode_ospath(path); if (mkdir(RSTRING_PTR(path), mode) == -1) rb_sys_fail(RSTRING_PTR(path)); @@ -980,7 +978,6 @@ dir_s_rmdir(VALUE obj, VALUE dir) { check_dirname(&dir); - dir = rb_str_encode_ospath(dir); if (rmdir(RSTRING_PTR(dir)) < 0) rb_sys_fail(RSTRING_PTR(dir)); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/