ref: cb32df0efbd91bd9f1c1b3840086133b2e7dd6b2
parent: 59ec69003f284ff73480ce2724e50fe7ee178f98
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Feb 19 10:50:53 EST 2018
[ar] Remove current member from pending list We don't want to have them there for anything.
--- a/ar/main.c
+++ b/ar/main.c
@@ -135,8 +135,11 @@
exit(1);
}
- while ((fname = *list++) != NULL)
+ for ( ; fname = *list; ++list) {
+ *list = NULL;
archive(fname, fp, 'a');
+ }
+
if (fclose(fp) == EOF) {
perror("ar:error writing archive");
exit(1);
@@ -194,30 +197,22 @@
return buf;
}
-static void
-rmlist(char *list[])
-{
- for (; *list; ++list)
- list[0] = list[1];
-}
-
-static char **
+static int
inlist(char *fname, char *list[])
{
while (*list && strcmp(*list, fname))
++list;
if (*list == NULL)
- return NULL;
- return list;
+ return 0;
+ for (; *list; ++list)
+ list[0] = list[1];
+ return 1;
}
static void
split(struct arop *op, char *files[])
{
- char **l;
-
- l = inlist(op->fname, files);
- if (!l) {
+ if (!inlist(op->fname, files)) {
copy(&op->hdr, op->size, op->src, op->dst);
return;
} else {
@@ -224,7 +219,6 @@
if (vflag)
printf("m - %s\n", op->fname);
copy(&op->hdr, op->size, op->src, op->tmp);
- rmlist(l);
}
}
@@ -271,13 +265,10 @@
{
char **l;
- l = inlist(op->fname, files);
- if (!l) {
+ if (!inlist(op->fname, files))
copy(&op->hdr, op->size, op->src, op->dst);
- return;
- }
- archive(op->fname, op->dst, 'r');
- rmlist(l);
+ else
+ archive(op->fname, op->dst, 'r');
}
static void