scc

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

commit 7b38f863668cb3b479957580516dac0b413851a7
parent d0b7686f0c9434bf235ae2b2bb65ef1a41db07b7
Author: Quentin Rameau <quinq@fifth.space>
Date:   Thu, 10 Jan 2019 00:11:13 +0100

[ar] Implement u flag

Update only older files in the archive.

Diffstat:
Msrc/cmd/ar.c | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/cmd/ar.c b/src/cmd/ar.c @@ -208,6 +208,16 @@ inlist(char *fname, int argc, char *argv[]) return 0; } +static int +older(struct member *m) +{ + struct fprop prop; + + if (getstat(m->fname, &prop) < 0) + error("error getting '%s' attributes", m->fname); + return prop.time > m->date; +} + static void move(struct member *m, int argc, char *argv[]) { @@ -244,7 +254,8 @@ update(struct member *m, int argc, char *argv[]) FILE *fp = tmps[BEFORE].fp; if (inlist(m->fname, argc, argv)) { - archive(m->fname, tmps[m->cur].fp, 'r'); + if (uflag && older(m)) + archive(m->fname, tmps[m->cur].fp, 'r'); return; } else if (posname && !strcmp(posname, m->fname)) { where = (bflag) ? AFTER : BEFORE; @@ -595,8 +606,6 @@ main(int argc, char *argv[]) lflag = 1; break; case 'u': - /* TODO */ - abort(); uflag = 1; break; default: