diff --git a/ChangeLog b/ChangeLog index 9139d82967..d77c8852e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Aug 19 11:28:08 2006 Nobuyoshi Nakada + + * file.c (rb_file_s_rename): use errno if set properly. + fixed: [ruby-dev:29293] + Fri Aug 18 01:05:57 2006 Yukihiro Matsumoto * lib/cgi.rb (CGI::out): specify -m0 to disable MIME decode. a diff --git a/file.c b/file.c index f1527a0407..00bc40cd7f 100644 --- a/file.c +++ b/file.c @@ -2180,10 +2180,16 @@ rb_file_s_rename(VALUE klass, VALUE from, VALUE to) FilePathValue(to); src = StringValueCStr(from); dst = StringValueCStr(to); +#if defined __CYGWIN__ + errno = 0; +#endif if (rename(src, dst) < 0) { #if defined __CYGWIN__ extern unsigned long __attribute__((stdcall)) GetLastError(void); - errno = GetLastError(); /* This is a Cygwin bug */ + if (errno == 0) { /* This is a bug of old Cygwin */ + /* incorrect as cygwin errno, but the last resort */ + errno = GetLastError(); + } #elif defined DOSISH && !defined _WIN32 if (errno == EEXIST #if defined (__EMX__)