Blame SOURCES/wget-1.14-fix-backups-to-work-as-documented.patch

bc22e6
From c52bbad9e4bad1393a9d6ba37e600d388f5ab419 Mon Sep 17 00:00:00 2001
bc22e6
From: Giuseppe Scrivano <gscrivano@gnu.org>
bc22e6
Date: Wed, 10 Jul 2013 20:59:34 +0200
bc22e6
Subject: [PATCH] Make --backups work as documented
bc22e6
bc22e6
---
bc22e6
 src/http.c    | 6 ------
bc22e6
 src/options.h | 2 +-
bc22e6
 src/url.c     | 3 ++-
bc22e6
 src/url.h     | 6 ++++++
bc22e6
 4 files changed, 9 insertions(+), 8 deletions(-)
bc22e6
bc22e6
diff --git a/src/http.c b/src/http.c
bc22e6
index 9f274dc..b0c782b 100644
bc22e6
--- a/src/http.c
bc22e6
+++ b/src/http.c
bc22e6
@@ -1641,12 +1641,6 @@ read_response_body (struct http_stat *hs, int sock, FILE *fp, wgint contlen,
bc22e6
 } while (0)
bc22e6
 #endif /* def __VMS [else] */
bc22e6
 
bc22e6
-/* The flags that allow clobbering the file (opening with "wb").
bc22e6
-   Defined here to avoid repetition later.  #### This will require
bc22e6
-   rework.  */
bc22e6
-#define ALLOW_CLOBBER (opt.noclobber || opt.always_rest || opt.timestamping \
bc22e6
-                       || opt.dirstruct || opt.output_document)
bc22e6
-
bc22e6
 /* Retrieve a document through HTTP protocol.  It recognizes status
bc22e6
    code, and correctly handles redirections.  It closes the network
bc22e6
    socket.  If it receives an error from the functions below it, it
bc22e6
diff --git a/src/options.h b/src/options.h
bc22e6
index ed38617..0a10c9b 100644
bc22e6
--- a/src/options.h
bc22e6
+++ b/src/options.h
bc22e6
@@ -166,7 +166,7 @@ struct options
bc22e6
   bool timestamping;		/* Whether to use time-stamping. */
bc22e6
 
bc22e6
   bool backup_converted;	/* Do we save pre-converted files as *.orig? */
bc22e6
-  bool backups;			/* Are numeric backups made? */
bc22e6
+  int backups;			/* Are numeric backups made? */
bc22e6
 
bc22e6
   char *useragent;		/* User-Agent string, which can be set
bc22e6
 				   to something other than Wget. */
bc22e6
diff --git a/src/url.c b/src/url.c
bc22e6
index 5e2b9a3..bf9d697 100644
bc22e6
--- a/src/url.c
bc22e6
+++ b/src/url.c
bc22e6
@@ -1669,11 +1669,12 @@ url_file_name (const struct url *u, char *replaced_filename)
bc22e6
      2) Retrieval with regetting.
bc22e6
      3) Timestamping is used.
bc22e6
      4) Hierarchy is built.
bc22e6
+     5) Backups are specified.
bc22e6
 
bc22e6
      The exception is the case when file does exist and is a
bc22e6
      directory (see `mkalldirs' for explanation).  */
bc22e6
 
bc22e6
-  if ((opt.noclobber || opt.always_rest || opt.timestamping || opt.dirstruct)
bc22e6
+  if (ALLOW_CLOBBER
bc22e6
       && !(file_exists_p (fname) && !file_non_directory_p (fname)))
bc22e6
     {
bc22e6
       unique = fname;
bc22e6
diff --git a/src/url.h b/src/url.h
bc22e6
index b7f4366..cd3782b 100644
bc22e6
--- a/src/url.h
bc22e6
+++ b/src/url.h
bc22e6
@@ -47,6 +47,12 @@ as that of the covered work.  */
bc22e6
 #define DEFAULT_FTP_PORT 21
bc22e6
 #define DEFAULT_HTTPS_PORT 443
bc22e6
 
bc22e6
+/* The flags that allow clobbering the file (opening with "wb").
bc22e6
+   Defined here to avoid repetition later.  #### This will require
bc22e6
+   rework.  */
bc22e6
+#define ALLOW_CLOBBER (opt.noclobber || opt.always_rest || opt.timestamping \
bc22e6
+                  || opt.dirstruct || opt.output_document || opt.backups > 0)
bc22e6
+
bc22e6
 /* Specifies how, or whether, user auth information should be included
bc22e6
  * in URLs regenerated from URL parse structures. */
bc22e6
 enum url_auth_mode {
bc22e6
-- 
bc22e6
1.8.3.1
bc22e6