ref: b0b1078f5a44eeb374bba25ece1c9dcb218883e4
parent: 70df1fa850f6a1b3e18ce99cbe981462b8bb097f
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Feb 21 16:11:51 EST 2018
[ar] Add insert() This function is used in -r to add the files that weren't present in the file.
--- a/ar/main.c
+++ b/ar/main.c
@@ -216,6 +216,8 @@
int where;
if (inlist(op->fname, argc, argv)) {
+ if (vflag)
+ printf("m - %s\n", op->fname);
where = INDOT;
} else if (posname && !strcmp(posname, op->fname)) {
where = (bflag) ? AFTER : BEFORE;
@@ -227,6 +229,15 @@
}
static void
+insert(int argc, char *argv[])
+{
+ for (; argc-- > 0; ++argv) {
+ archive(*argv, tmps[INDOT].fp, 'r');
+ *argv = NULL;
+ }
+}
+
+static void
update(struct member *op, int argc, char *argv[])
{
int where;
@@ -233,6 +244,8 @@
FILE *fp = tmps[BEFORE].fp;
if (inlist(op->fname, argc, argv)) {
+ if (vflag)
+ printf("r - %s\n", op->fname);
archive(op->fname, tmps[op->cur].fp, 'r');
return;
} else if (posname && !strcmp(posname, op->fname)) {
@@ -491,6 +504,7 @@
switch (key) {
case 'r':
run(fp, argc, argv, update);
+ insert(argc, argv);
merge();
break;
case 'm':