From: Giuseppe Scrivano <[email protected]> G:
Thanks for the e-mail copy. I check the lists.gnu.org/archive pretty regularly, but the "address@hidden" stuff there can hide many useful details. > Tomas Hozza <[email protected]> writes: > > > Options undocumented at all: > > --backups > > --no-backups > > I have two patches here for --backups, one related to VMS and untested. > > Could someone please proof-read the documentation bits? > [...] > diff --git a/src/retr.c b/src/retr.c > index 3d51ef9..ab1053e 100644 > --- a/src/retr.c > +++ b/src/retr.c > @@ -1194,8 +1194,15 @@ 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); > + const char *sep; > +# ifdef __VMS > + sep = "_"; > +#else > + sep = "."; > +#endif > + > + sprintf (from, "%s%s%d", fname, sep, i - 1); > + sprintf (to, "%s%s%d", fname, sep, i); > rename (from, to); > } I haven't tried to get "git" working here, so I'm looking at original 1.14 source. Did someone already change the rename() code which follows this loop? I'd use a macro instead of "const char *sep;", et al. Also, for proper operation on VMS, a little more work is needed. Naturally. Normally, I'd expect a VMS user to rely on the file versioning which is built into the file system, rather than use any of this backup stuff, but it can be made to work. My patch (against 1.14) follows. > +@cindex backing up files > +@item --backups=@var{backups} > +Before write a file, back up the original version adding a @samp{.1} > +suffix to the file name. Eventual existing backups will be rotated up > +to @var{backups} files incrementing the suffix by one. 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). --- src/retr.c_orig 2012-06-06 06:45:29 -0500 +++ src/retr.c 2013-07-09 17:30:21 -0500 @@ -37,6 +37,9 @@ #include <errno.h> #include <string.h> #include <assert.h> +#ifdef VMS +# include <unixio.h> /* For delete(). */ +#endif #include "exits.h" #include "utils.h" @@ -1177,7 +1180,16 @@ 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; @@ -1189,12 +1201,24 @@ 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); } ------------------------------------------------------------------------ Steven M. Schweda sms@antinode-info 382 South Warwick Street (+1) 651-699-9818 Saint Paul MN 55105-2547
