Added u flag

This commit is contained in:
ceriel 1991-08-27 09:44:53 +00:00
parent e7856a2204
commit 2c400f6a44

View file

@ -9,16 +9,17 @@
static char RcsId[] = "$Header$"; static char RcsId[] = "$Header$";
/* /*
* Usage: [arch|aal] [adprtvx] archive [file] ... * Usage: [arch|aal] [qdprtx][vlcu] archive [file] ...
* v: verbose * v: verbose
* x: extract * x: extract
* a: append * q: append
* r: replace (append when not in archive) * r: replace (append when not in archive)
* d: delete * d: delete
* t: print contents of archive * t: print contents of archive
* p: print named files * p: print named files
* l: temporaries in current directory instead of /tmp * l: temporaries in current directory instead of /tmp
* c: don't give "create" message * c: don't give "create" message
* u: replace only if dated later than member in archive
#ifdef DISTRIBUTION #ifdef DISTRIBUTION
* D: make distribution: use distr_time, uid=2, gid=2, mode=0644 * D: make distribution: use distr_time, uid=2, gid=2, mode=0644
#endif #endif
@ -28,8 +29,8 @@ static char RcsId[] = "$Header$";
#include <sys/stat.h> #include <sys/stat.h>
#include <signal.h> #include <signal.h>
#include <arch.h> #include <arch.h>
#ifdef AAL
#include <ranlib.h> #include <ranlib.h>
#ifdef AAL
#include <out.h> #include <out.h>
#define MAGIC_NUMBER AALMAG #define MAGIC_NUMBER AALMAG
long offset; long offset;
@ -74,6 +75,7 @@ BOOL app_fl;
BOOL ex_fl; BOOL ex_fl;
BOOL show_fl; BOOL show_fl;
BOOL pr_fl; BOOL pr_fl;
BOOL u_fl;
BOOL rep_fl; BOOL rep_fl;
BOOL del_fl; BOOL del_fl;
BOOL nocr_fl; BOOL nocr_fl;
@ -96,13 +98,8 @@ extern char *ctime();
usage() usage()
{ {
error(TRUE, "usage: %s %s archive [file] ...\n", error(TRUE, "usage: %s [qdprtxl][vlc] archive [file] ...\n",
progname, progname
#ifdef AAL
"[acdrtxvl]"
#else
"[acdprtxvl]"
#endif
); );
} }
@ -203,19 +200,20 @@ char *argv[];
case 'x' : case 'x' :
ex_fl = TRUE; ex_fl = TRUE;
break; break;
case 'a' : case 'q' :
needs_arg = 1; needs_arg = 1;
app_fl = TRUE; app_fl = TRUE;
break; break;
case 'c' : case 'c' :
nocr_fl = TRUE; nocr_fl = TRUE;
break; break;
#ifndef AAL case 'u':
u_fl = TRUE;
break;
case 'p' : case 'p' :
needs_arg = 1; needs_arg = 1;
pr_fl = TRUE; pr_fl = TRUE;
break; break;
#endif
case 'd' : case 'd' :
needs_arg = 1; needs_arg = 1;
del_fl = TRUE; del_fl = TRUE;
@ -253,6 +251,9 @@ char *argv[];
if (app_fl + ex_fl + del_fl + rep_fl + show_fl + pr_fl != 1) if (app_fl + ex_fl + del_fl + rep_fl + show_fl + pr_fl != 1)
usage(); usage();
if (u_fl && ! rep_fl)
usage();
if (rep_fl || del_fl if (rep_fl || del_fl
#ifdef AAL #ifdef AAL
|| app_fl || app_fl
@ -285,12 +286,10 @@ again:
if (member.ar_size < 0) { if (member.ar_size < 0) {
error(TRUE, "archive has member with negative size\n"); error(TRUE, "archive has member with negative size\n");
} }
#ifdef AAL
if (equal(SYMDEF, member.ar_name)) { if (equal(SYMDEF, member.ar_name)) {
lseek(ar_fd, member.ar_size, 1); lseek(ar_fd, member.ar_size, 1);
goto again; goto again;
} }
#endif
return &member; return &member;
} }
@ -442,6 +441,11 @@ char *mess;
error(FALSE, "%s is a directory (ignored)\n", name); error(FALSE, "%s is a directory (ignored)\n", name);
return; return;
} }
else if (u_fl && status.st_mtime <= member.ar_date) {
wr_arhdr(fd, member);
copy_member(member, ar_fd, fd, 0);
return;
}
else if ((src_fd = open(name, 0)) < 0) { else if ((src_fd = open(name, 0)) < 0) {
error(FALSE, "cannot open %s\n", name); error(FALSE, "cannot open %s\n", name);
return; return;
@ -619,6 +623,7 @@ write_symdef()
register long delta; register long delta;
MEMBER arbuf; MEMBER arbuf;
if (! tnum) return;
if (odd(tssiz)) if (odd(tssiz))
tstrtab[tssiz++] = '\0'; tstrtab[tssiz++] = '\0';
for (i = 0; i < sizeof(arbuf.ar_name); i++) for (i = 0; i < sizeof(arbuf.ar_name); i++)