X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/bf53959eec5e017e665cb8bdaadbb433c3c56ec4..a862a6783bd1d4840dbfba8272d87b9be6a81ad9:/usr/src/usr.bin/ar/replace.c diff --git a/usr/src/usr.bin/ar/replace.c b/usr/src/usr.bin/ar/replace.c index ecb0157300..a3ace0f307 100644 --- a/usr/src/usr.bin/ar/replace.c +++ b/usr/src/usr.bin/ar/replace.c @@ -9,15 +9,15 @@ */ #ifndef lint -static char sccsid[] = "@(#)replace.c 5.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)replace.c 5.5 (Berkeley) %G%"; #endif /* not lint */ #include #include -#include #include -#include #include +#include +#include #include #include #include "archive.h" @@ -36,7 +36,7 @@ extern char *tname; /* temporary file "name" */ replace(argv) char **argv; { - extern char *posname; /* positioning file name */ + extern char *posarg, *posname; /* positioning file name */ register char *file; register int afd, curfd, mods, sfd; struct stat sb; @@ -82,13 +82,13 @@ replace(argv) goto useold; if (options & AR_V) - (void)printf("r - %s\n", chdr.name); + (void)printf("r - %s\n", file); + /* Read from disk, write to an archive; pad on write */ SETCF(sfd, file, curfd, tname, WPAD); - put_header(&cf, &sb); - copyfile(&cf, sb.st_size); + put_object(&cf, &sb); (void)close(sfd); - SKIP(afd, chdr.size, archive); + skipobj(afd); continue; } @@ -96,21 +96,21 @@ replace(argv) mods = 0; if (options & AR_B) curfd = tfd2; + /* Read and write to an archive; pad on both. */ SETCF(afd, archive, curfd, tname, RPAD|WPAD); - put_header(&cf, (struct stat *)NULL); - copyfile(&cf, chdr.size); + put_object(&cf, (struct stat *)NULL); if (options & AR_A) curfd = tfd2; } else { + /* Read and write to an archive; pad on both. */ useold: SETCF(afd, archive, curfd, tname, RPAD|WPAD); - put_header(&cf, (struct stat *)NULL); - copyfile(&cf, chdr.size); + put_object(&cf, (struct stat *)NULL); } } if (mods) { (void)fprintf(stderr, "ar: %s: archive member not found.\n", - posname); + posarg); close_archive(afd); return(1); } @@ -118,7 +118,7 @@ useold: SETCF(afd, archive, curfd, tname, RPAD|WPAD); /* Append any left-over arguments to the end of the after file. */ append: while (file = *argv++) { if (options & AR_V) - (void)printf("a - %s\n", rname(file)); + (void)printf("a - %s\n", file); if ((sfd = open(file, O_RDONLY)) < 0) { err = 1; (void)fprintf(stderr, "ar: %s: %s.\n", @@ -126,16 +126,16 @@ append: while (file = *argv++) { continue; } (void)fstat(sfd, &sb); + /* Read from disk, write to an archive; pad on write. */ SETCF(sfd, file, options & (AR_A|AR_B) ? tfd1 : tfd2, tname, WPAD); - put_header(&cf, &sb); - copyfile(&cf, sb.st_size); + put_object(&cf, &sb); (void)close(sfd); } (void)lseek(afd, (off_t)SARMAG, SEEK_SET); - SETCF(tfd1, tname, afd, archive, RPAD|WPAD); + SETCF(tfd1, tname, afd, archive, NOPAD); if (tfd1 != -1) { tsize = size = lseek(tfd1, (off_t)0, SEEK_CUR); (void)lseek(tfd1, (off_t)0, SEEK_SET);