]> sjero.net Git - wget/commitdiff
Make --backups work as documented
authorGiuseppe Scrivano <gscrivano@gnu.org>
Wed, 10 Jul 2013 18:59:34 +0000 (20:59 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Sat, 13 Jul 2013 11:36:55 +0000 (13:36 +0200)
src/ChangeLog
src/http.c
src/options.h
src/url.c
src/url.h

index 90d8637701e3261b6cfa954ee4d01f5a40be471f..b80138f2205edce9f3ce717d8e34207112f8a3ea 100644 (file)
@@ -1,3 +1,11 @@
+2013-07-10  Giuseppe Scrivano  <gscrivano@gnu.org>
+
+       * http.c (read_response_body) [ALLOW_CLOBBER]: Move definition to..
+       * options.h (struct options): Make `backups' an int.
+       * url.h [ALLOW_CLOBBER]: .. Here.  Do not clobber when backups are used.
+       * url.c (url_file_name): Use the ALLOW_CLOBBER macro instead of
+       repeating the code.
+
 2013-07-08  Steven M. Schweda <sms@antinode.info>
 
        * retr.c (rotate_backups): Support for VMS files.
index 9f274dc618abc8c65acbfe2e001206acf7ff7c54..b0c782b94cbac70e4334b075e71035d04b09057a 100644 (file)
@@ -1641,12 +1641,6 @@ read_response_body (struct http_stat *hs, int sock, FILE *fp, wgint contlen,
 } while (0)
 #endif /* def __VMS [else] */
 
-/* The flags that allow clobbering the file (opening with "wb").
-   Defined here to avoid repetition later.  #### This will require
-   rework.  */
-#define ALLOW_CLOBBER (opt.noclobber || opt.always_rest || opt.timestamping \
-                       || opt.dirstruct || opt.output_document)
-
 /* Retrieve a document through HTTP protocol.  It recognizes status
    code, and correctly handles redirections.  It closes the network
    socket.  If it receives an error from the functions below it, it
index ed38617a866139dfefe476b7d6d7dd942bf4245e..0a10c9b396b6ae4491c572a2308eca350b1b3603 100644 (file)
@@ -166,7 +166,7 @@ struct options
   bool timestamping;           /* Whether to use time-stamping. */
 
   bool backup_converted;       /* Do we save pre-converted files as *.orig? */
-  bool backups;                        /* Are numeric backups made? */
+  int backups;                 /* Are numeric backups made? */
 
   char *useragent;             /* User-Agent string, which can be set
                                   to something other than Wget. */
index 5e2b9a3bde9f1a0d79a74bfc093317ceb3e21783..bf9d6971de49e52f75762aa7a2c4d174a7eb41c1 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -1669,11 +1669,12 @@ url_file_name (const struct url *u, char *replaced_filename)
      2) Retrieval with regetting.
      3) Timestamping is used.
      4) Hierarchy is built.
+     5) Backups are specified.
 
      The exception is the case when file does exist and is a
      directory (see `mkalldirs' for explanation).  */
 
-  if ((opt.noclobber || opt.always_rest || opt.timestamping || opt.dirstruct)
+  if (ALLOW_CLOBBER
       && !(file_exists_p (fname) && !file_non_directory_p (fname)))
     {
       unique = fname;
index b7f4366d5c48b615a1270c834f35134c1d5b7cce..cd3782b1e0b833cb5a21e8d87b8d6d864aa9827c 100644 (file)
--- a/src/url.h
+++ b/src/url.h
@@ -47,6 +47,12 @@ as that of the covered work.  */
  * file descriptor. */
 #define CHOMP_BUFFER 19
 
+/* The flags that allow clobbering the file (opening with "wb").
+   Defined here to avoid repetition later.  #### This will require
+   rework.  */
+#define ALLOW_CLOBBER (opt.noclobber || opt.always_rest || opt.timestamping \
+                  || opt.dirstruct || opt.output_document || opt.backups > 0)
+
 /* Specifies how, or whether, user auth information should be included
  * in URLs regenerated from URL parse structures. */
 enum url_auth_mode {