scc

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

commit 60c7eab51eb00b3123f6644fe52d8cfb5a5e38c1
parent a70327662183619906f80e32669eb536aa4e31fc
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 19 Feb 2018 16:51:52 +0000

[ar] Use a haslist variable

This variable marks when the original command line had a list of
members. We cannot use the list itself because it is modified
by the program.

Diffstat:
Mar/main.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/ar/main.c b/ar/main.c @@ -15,7 +15,7 @@ static char sccsid[] = "@(#) ./ar/main.c"; char *argv0; -static int bflag, iflag, vflag, cflag, lflag, uflag, aflag; +static int bflag, iflag, vflag, cflag, lflag, uflag, aflag, haslist; static char *posname, *tmpafile1, *tmpafile2; struct arop { @@ -278,7 +278,7 @@ extract(struct arop *op, char *files[]) long siz; FILE *fp; - if (*files && !inlist(op->fname, files)) + if (haslist && !inlist(op->fname, files)) return; if (vflag) printf("x - %s\n", op->fname); @@ -308,7 +308,7 @@ print(struct arop *op, char *files[]) long siz; int c; - if (*files && !inlist(op->fname, files)) + if (haslist && !inlist(op->fname, files)) return; if (vflag) printf("\n<%s>\n\n", op->fname); @@ -324,7 +324,7 @@ list(struct arop *op, char *files[]) struct ar_hdr *hdr = &op->hdr; char mtime[30]; - if (*files && !inlist(op->fname, files)) + if (haslist && !inlist(op->fname, files)) return; if (!vflag) { printf("%s\n", op->fname); @@ -517,6 +517,7 @@ doit(int key, char *afile, FILE *fp, char *flist[]) } return; } + haslist = *flist != NULL; switch (key) { case 'r':