From: ceriel Date: Tue, 27 Jun 1989 15:41:47 +0000 (+0000) Subject: fixed reading of archives X-Git-Tag: release-5-5~2361 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=58f837cd33a062af7fb8108caff7f5890e78fe6c;p=ack.git fixed reading of archives --- diff --git a/util/ego/ic/ic_lib.c b/util/ego/ic/ic_lib.c index f9255d4ba..3505a9db2 100644 --- a/util/ego/ic/ic_lib.c +++ b/util/ego/ic/ic_lib.c @@ -175,14 +175,14 @@ STATIC bool is_archive(name) char *name; { /* See if 'name' is the name of an archive file, i.e. it - * should end on ".a" and should at least be three characters - * long (i.e. the name ".a" is not accepted as an archive name!). + * should end on ".ma" and should at least be four characters + * long (i.e. the name ".ma" is not accepted as an archive name!). */ register char *p; for (p = name; *p; p++); - return (p > name+2) && (*--p == 'a') && (*--p == '.'); + return (p > name+3) && (*--p == 'a') && (*--p == 'm') && (*--p == '.'); } @@ -193,9 +193,29 @@ STATIC bool read_hdr() { /* Read the header of an archive module */ + char buf[AR_TOTAL]; + register char *c = buf; + register char *p = hdr.ar_name; + register int i; - fread(&hdr, sizeof(hdr), 1, curfile); - return !feof(curfile); + fread(c, AR_TOTAL, 1, curfile); + if (feof(curfile)) return 0; + i = 14; + while (i--) { + *p++ = *c++; + } + +#define get2(c) (((c)[0]&0377) | ((unsigned) ((c)[1]&0377) << 8)) + + hdr.ar_date = ((long) get2(c)) << 16; c += 2; + hdr.ar_date |= ((long) get2(c)) & 0xffff; c += 2; + hdr.ar_uid = *c++; + hdr.ar_gid = *c++; + hdr.ar_mode = get2(c); c += 2; + hdr.ar_size = (long) get2(c) << 16; c += 2; + hdr.ar_size |= (long) get2(c) & 0xffff; + + return 1; } @@ -267,7 +287,7 @@ FILE *next_file(argc,argv) error("cannot open %s",filename); } if (is_archive(filename)) { - /* ends on '.a' */ + /* ends on '.ma' */ arstate = ARCHIVE; arch_init(curfile); /* read magic ar number */ } else {