[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] Wget manpage missing options
From: |
Giuseppe Scrivano |
Subject: |
Re: [Bug-wget] Wget manpage missing options |
Date: |
Wed, 10 Jul 2013 12:09:48 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
"Steven M. Schweda" <address@hidden> writes:
> I might say something like:
>
> Before (over)writing a file, back up an existing file by adding a
> @samp{.1} suffix (@samp{_1} on VMS) to the file name. Such backup files
> are rotated to @samp{.2}, @samp{.3}, and so on, up to @var{backups} (and
> lost beyond that).
thanks, I amended your suggestion.
> --- src/retr.c_orig 2012-06-06 06:45:29 -0500
> +++ src/retr.c 2013-07-09 17:30:21 -0500
I will use your patch instead.
These are the new commits, I am still unsure about the semantic of
--backups=N, is the current one the desired way?
>From de5855d9b25eaf5f6cc99caa4f34db93b3654336 Mon Sep 17 00:00:00 2001
From: "Steven M. Schweda" <address@hidden>
Date: Mon, 8 Jul 2013 23:23:51 +0200
Subject: [PATCH 1/2] vms: support --backups
---
src/ChangeLog | 4 ++++
src/retr.c | 32 ++++++++++++++++++++++++++++----
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 0240976..6894975 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2013-07-08 Steven M. Schweda <address@hidden>
+
+ * retr.c (rotate_backups): Support for VMS files.
+
2013-06-26 Darshit Shah <address@hidden>
* http.c (gethttp): Reverse change by commit 90896 that prevented
diff --git a/src/retr.c b/src/retr.c
index 3d51ef9..683c811 100644
--- a/src/retr.c
+++ b/src/retr.c
@@ -37,6 +37,9 @@ as that of the covered work. */
#include <errno.h>
#include <string.h>
#include <assert.h>
+#ifdef VMS
+# include <unixio.h> /* For delete(). */
+#endif
#include "exits.h"
#include "utils.h"
@@ -1182,7 +1185,16 @@ free_urlpos (struct urlpos *l)
void
rotate_backups(const char *fname)
{
- int maxlen = strlen (fname) + 1 + numdigit (opt.backups) + 1;
+#ifdef __VMS
+# define SEP "_"
+# define AVS ";*" /* All-version suffix. */
+# define AVSL (sizeof (AVS) - 1)
+#else
+# define SEP "."
+# define AVSL 0
+#endif
+
+ int maxlen = strlen (fname) + sizeof (SEP) + numdigit (opt.backups) + AVSL;
char *from = (char *)alloca (maxlen);
char *to = (char *)alloca (maxlen);
struct_stat sb;
@@ -1194,12 +1206,24 @@ rotate_backups(const char *fname)
for (i = opt.backups; i > 1; i--)
{
- sprintf (from, "%s.%d", fname, i - 1);
- sprintf (to, "%s.%d", fname, i);
+#ifdef VMS
+ /* Delete (all versions of) any existing max-suffix file, to avoid
+ * creating multiple versions of it. (On VMS, rename() will
+ * create a new version of an existing destination file, not
+ * destroy/overwrite it.)
+ */
+ if (i == opt.backups)
+ {
+ sprintf (to, "%s%s%d%s", fname, SEP, i, AVS);
+ delete (to);
+ }
+#endif
+ sprintf (to, "%s%s%d", fname, SEP, i);
+ sprintf (from, "%s%s%d", fname, SEP, i - 1);
rename (from, to);
}
- sprintf (to, "%s.%d", fname, 1);
+ sprintf (to, "%s%s%d", fname, SEP, 1);
rename(fname, to);
}
--
1.8.3.1
>From af4e6fb14ade2b3a7aa6b900395402b6fd4b84ec Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <address@hidden>
Date: Tue, 9 Jul 2013 00:50:30 +0200
Subject: [PATCH 2/2] doc: document --backups
---
doc/ChangeLog | 6 ++++++
doc/wget.texi | 15 ++++++++++++---
src/main.c | 3 +++
3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 1a70e3c..7972d62 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,9 @@
+2013-07-09 Giuseppe Scrivano <address@hidden>
+
+ * wget.texi (Download Options): Add documentation for --backups.
+ (Wgetrc Commands): Add documentation for backups.
+ Reported by: Tomas Hozza <address@hidden>.
+
2013-06-17 Dave Reisner <address@hidden> (tiny change)
* texi2pod.pl: Fix formatting error that causes build to fail with
diff --git a/doc/wget.texi b/doc/wget.texi
index 710f0ac..b147841 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -630,6 +630,13 @@ Note that when @samp{-nc} is specified, files with the
suffixes
@samp{.html} or @samp{.htm} will be loaded from the local disk and
parsed as if they had been retrieved from the Web.
address@hidden backing up files
address@hidden address@hidden
+Before (over)writing a file, back up an existing file by adding a
address@hidden suffix (@samp{_1} on VMS) to the file name. Such backup
+files are rotated to @samp{.2}, @samp{.3}, and so on, up to
address@hidden (and lost beyond that).
+
@cindex continue retrieval
@cindex incomplete downloads
@cindex resume download
@@ -2873,9 +2880,11 @@ enables it).
Enable/disable saving pre-converted files with the suffix
@samp{.orig}---the same as @samp{-K} (which enables it).
address@hidden @item backups = @var{number}
address@hidden #### Document me!
address@hidden
address@hidden backups = @var{number}
+Use up to @var{number} backups for a file. Backups are rotated by
+adding an incremental counter that starts at @samp{1}. The default is
address@hidden
+
@item base = @var{string}
Consider relative @sc{url}s in input files (specified via the
@samp{input} command or the @samp{--input-file}/@samp{-i} option,
diff --git a/src/main.c b/src/main.c
index c895c4e..8ce0eb3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -714,6 +714,9 @@ Recursive download:\n"),
N_("\
-k, --convert-links make links in downloaded HTML or CSS point to\n\
local files.\n"),
+ N_("\
+ --backups=N before writing file X, rotate up to N backup files.\n"),
+
#ifdef __VMS
N_("\
-K, --backup-converted before converting file X, back up as X_orig.\n"),
--
1.8.3.1
--
Giuseppe
- Re: [Bug-wget] Wget manpage missing options, Giuseppe Scrivano, 2013/07/08
- Re: [Bug-wget] Wget manpage missing options, Steven M. Schweda, 2013/07/09
- Re: [Bug-wget] Wget manpage missing options,
Giuseppe Scrivano <=
- Re: [Bug-wget] Wget manpage missing options, Steven M. Schweda, 2013/07/10
- Re: [Bug-wget] Wget manpage missing options, Steven M. Schweda, 2013/07/11
- Re: [Bug-wget] Wget manpage missing options, Steven M. Schweda, 2013/07/12
- Re: [Bug-wget] Wget manpage missing options, Steven M. Schweda, 2013/07/12
- Re: [Bug-wget] Wget manpage missing options, Steven M. Schweda, 2013/07/12