summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-26 03:01:41 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-26 03:01:41 +0000
commit0e6dcc7ab24e6e5b8ee3b9a532c0318eb5155e2e (patch)
tree10e9d00b89f6bb5b0d275ee4dbd6e35fe886b2ef /io.c
parentc5b7d11e59cf8953d18ed6aba2c4df2b1eb29fd4 (diff)
merge revision(s) 32826,34732: [Backport #6681]
* file.c (rb_enc_path_next, rb_enc_path_skip_prefix) (rb_enc_path_last_separator, rb_enc_path_end) (ruby_enc_find_basename, ruby_enc_find_extname): encoding-aware path handling functions. * file.c (rb_home_dir, file_expand_path, rb_realpath_internal) (rb_file_s_basename, rb_file_dirname, rb_file_s_extname) (rb_file_join): should respect the encodings of arguments than file system encoding. [ruby-dev:45145] [Bug #5919] * dir.c (check_dirname, ruby_glob0): ditto. * ext/pathname/pathname.c (path_sub_ext): ditto. * util.c, include/ruby/util.h (ruby_add_suffix): remove the function. [Bug #5153] [ruby-core:38736] * io.c (argf_next_argv): remove the call of above function. * ext/-test-/add_suffix, test/-ext-/test_add_suffix.rb: remove the test extension module because this is only for testsing ruby_add_suffix(). * LEGAL: remove the mention about a part of util.c, because now we removed the part. * io.c (argf_next_argv): now the new filename is not guranteed to use, so should check the return value of rename(2). * test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible): now we expect same result with other platforms on no_safe_rename platforms (=Windows). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/io.c b/io.c
index d6dc635149..36eb39d3d6 100644
--- a/io.c
+++ b/io.c
@@ -35,10 +35,6 @@
# define NO_SAFE_RENAME
#endif
-#if defined(__CYGWIN__) || defined(_WIN32)
-# define NO_LONG_FNAME
-#endif
-
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(sun) || defined(_nec_ews)
# define USE_SETVBUF
#endif
@@ -7198,15 +7194,15 @@ argf_next_argv(VALUE argf)
fstat(fr, &st);
if (*ARGF.inplace) {
str = rb_str_new2(fn);
-#ifdef NO_LONG_FNAME
- ruby_add_suffix(str, ARGF.inplace);
-#else
rb_str_cat2(str, ARGF.inplace);
-#endif
#ifdef NO_SAFE_RENAME
(void)close(fr);
(void)unlink(RSTRING_PTR(str));
- (void)rename(fn, RSTRING_PTR(str));
+ if (rename(fn, RSTRING_PTR(str)) < 0) {
+ rb_warn("Can't rename %s to %s: %s, skipping file",
+ fn, RSTRING_PTR(str), strerror(errno));
+ goto retry;
+ }
fr = rb_sysopen(str, O_RDONLY, 0);
#else
if (rename(fn, RSTRING_PTR(str)) < 0) {