Note that, given that ws_rename() is a wrapper around ws_stdio_rename()
authorGuy Harris <guy@alum.mit.edu>
Tue, 22 May 2012 10:05:01 +0000 (10:05 -0000)
committerGuy Harris <guy@alum.mit.edu>
Tue, 22 May 2012 10:05:01 +0000 (10:05 -0000)
on Windows, and that ws_stdio_rename() uses MoveFileEx() with
MOVEFILE_REPLACE_EXISTING and should therefore remove the target if it
exists, the extra "remove the target first" stuff should not be
necessary on Windows - if we remove it, it also keeps the code from
removing the target and then having the rename fail, with the result
that the target no longer exists.

svn path=/trunk/; revision=42776

disabled_protos.c
filters.c

index fc6bfc2bc25c270fd9ed345fd8441ebbf25b84f8..86e9aa4a9952dff42764503a71b517f3f32f9580 100644 (file)
@@ -382,7 +382,14 @@ save_disabled_protos_list(char **pref_path_return, int *errno_return)
   /* ANSI C doesn't say whether "rename()" removes the target if it
      exists; the Win32 call to rename files doesn't do so, which I
      infer is the reason why the MSVC++ "rename()" doesn't do so.
-     We must therefore remove the target file first, on Windows. */
+     We must therefore remove the target file first, on Windows.
+
+     XXX - ws_rename() should be ws_stdio_rename() on Windows,
+     and ws_stdio_rename() uses MoveFileEx() with MOVEFILE_REPLACE_EXISTING,
+     so it should remove the target if it exists, so this stuff
+     shouldn't be necessary.  Perhaps it dates back to when we were
+     calling rename(), with that being a wrapper around Microsoft's
+     _rename(), which didn't remove the target. */
   if (ws_remove(ff_path) < 0 && errno != ENOENT) {
     /* It failed for some reason other than "it's not there"; if
        it's not there, we don't need to remove it, so we just
index d2c63f711186640a27e9dbe340ec5b98faa8f1d2..3862d965f28b52db33d10afa0bb9659782b82e3e 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -544,7 +544,14 @@ save_filter_list(filter_list_type_t list_type, char **pref_path_return,
   /* ANSI C doesn't say whether "rename()" removes the target if it
      exists; the Win32 call to rename files doesn't do so, which I
      infer is the reason why the MSVC++ "rename()" doesn't do so.
-     We must therefore remove the target file first, on Windows. */
+     We must therefore remove the target file first, on Windows.
+
+     XXX - ws_rename() should be ws_stdio_rename() on Windows,
+     and ws_stdio_rename() uses MoveFileEx() with MOVEFILE_REPLACE_EXISTING,
+     so it should remove the target if it exists, so this stuff
+     shouldn't be necessary.  Perhaps it dates back to when we were
+     calling rename(), with that being a wrapper around Microsoft's
+     _rename(), which didn't remove the target. */
   if (ws_remove(ff_path) < 0 && errno != ENOENT) {
     /* It failed for some reason other than "it's not there"; if
        it's not there, we don't need to remove it, so we just