scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 2eeb732a0f641780345a590d50ef8f7f08c72373
parent e1461b2fbe8e330617c99a53cb54132c390f856b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 21 Feb 2018 21:11:51 +0000

[ar] Add insert()

This function is used in -r to add the files that weren't present
in the file.

Diffstat:
Mar/main.c | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/ar/main.c b/ar/main.c @@ -216,6 +216,8 @@ move(struct member *op, int argc, char *argv[]) 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,12 +229,23 @@ move(struct member *op, int argc, char *argv[]) } 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; 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 @@ doit(int key, char *argv[], int argc) switch (key) { case 'r': run(fp, argc, argv, update); + insert(argc, argv); merge(); break; case 'm':