From 0c67cce512d7342f4318a1a99ef3ff33dc8101c0 Mon Sep 17 00:00:00 2001 From: mrg Date: Sun, 19 Oct 1997 05:50:26 +0000 Subject: [PATCH] merge lite-2. --- usr.bin/ranlib/Makefile | 4 +-- usr.bin/ranlib/build.c | 51 ++++++++++++++++++++++---------------- usr.bin/ranlib/misc.c | 32 ++++++++++++------------ usr.bin/ranlib/pathnames.h | 9 +++---- usr.bin/ranlib/ranlib.1 | 11 ++++---- usr.bin/ranlib/ranlib.5 | 11 ++++---- usr.bin/ranlib/ranlib.c | 19 ++++++++------ usr.bin/ranlib/touch.c | 13 ++++++---- 8 files changed, 80 insertions(+), 70 deletions(-) diff --git a/usr.bin/ranlib/Makefile b/usr.bin/ranlib/Makefile index fd8e6dabc6b0..888a440233a5 100644 --- a/usr.bin/ranlib/Makefile +++ b/usr.bin/ranlib/Makefile @@ -1,5 +1,5 @@ -# $NetBSD: Makefile,v 1.8 1997/05/14 15:57:07 gwr Exp $ -# from: @(#)Makefile 5.4 (Berkeley) 3/12/91 +# $NetBSD: Makefile,v 1.9 1997/10/19 05:50:26 mrg Exp $ +# from: @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= ranlib SRCS= archive.c build.c misc.c ranlib.c touch.c diff --git a/usr.bin/ranlib/build.c b/usr.bin/ranlib/build.c index ac4b02ac3fd3..9fa64932b452 100644 --- a/usr.bin/ranlib/build.c +++ b/usr.bin/ranlib/build.c @@ -1,8 +1,8 @@ -/* $NetBSD: build.c,v 1.9 1997/01/09 20:20:55 tls Exp $ */ +/* $NetBSD: build.c,v 1.10 1997/10/19 05:50:28 mrg Exp $ */ /*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Hugh Smith at The University of Guelph. @@ -37,22 +37,27 @@ */ #ifndef lint -/*static char sccsid[] = "from: @(#)build.c 5.3 (Berkeley) 3/12/91";*/ -static char rcsid[] = "$NetBSD: build.c,v 1.9 1997/01/09 20:20:55 tls Exp $"; +#if 0 +static char sccsid[] = "@(#)build.c 8.1 (Berkeley) 6/6/93"; +#else +static char rcsid[] = "$NetBSD: build.c,v 1.10 1997/10/19 05:50:28 mrg Exp $"; +#endif #endif /* not lint */ #include #include + +#include +#include +#include #include #include -#include -#include -#include -#include #include #include #include -#include +#include + +#include "archive.h" extern CHDR chdr; /* converted header */ extern char *archive; /* archive name */ @@ -88,6 +93,7 @@ build() /* Read through the archive, creating list of symbols. */ symcnt = tsymlen = 0; pnext = &rhead; + symcnt = tsymlen = 0; while(get_arobj(afd)) { if (!strcmp(chdr.name, RANLIBMAG)) { skip_arobj(afd); @@ -139,7 +145,7 @@ rexec(rfd, wfd) w_off = lseek(wfd, (off_t)0, SEEK_CUR); /* Read in exec structure. */ - nr = read(rfd, (char *)&ebuf, sizeof(struct exec)); + nr = read(rfd, &ebuf, sizeof(struct exec)); if (nr != sizeof(struct exec)) goto badread; @@ -148,17 +154,17 @@ rexec(rfd, wfd) goto bad1; /* Seek to string table. */ - if (lseek(rfd, N_STROFF(ebuf) + r_off, SEEK_SET) == (off_t)-1) + if (lseek(rfd, r_off + N_STROFF(ebuf), SEEK_SET) == (off_t)-1) error(archive); /* Read in size of the string table. */ - nr = read(rfd, (char *)&strsize, sizeof(strsize)); + nr = read(rfd, &strsize, sizeof(strsize)); if (nr != sizeof(strsize)) goto badread; /* Read in the string table. */ strsize -= sizeof(strsize); - strtab = (char *)emalloc(strsize); + strtab = emalloc(strsize); nr = read(rfd, strtab, strsize); if (nr != strsize) { badread: if (nr < 0) @@ -167,13 +173,13 @@ badread: if (nr < 0) } /* Seek to symbol table. */ - if (fseek(fp, N_SYMOFF(ebuf) + r_off, SEEK_SET) == (off_t)-1) + if (fseek(fp, (long)r_off + N_SYMOFF(ebuf), SEEK_SET)) goto bad2; /* For each symbol read the nlist entry and save it as necessary. */ nsyms = ebuf.a_syms / sizeof(struct nlist); while (nsyms--) { - if (!fread((char *)&nl, sizeof(struct nlist), 1, fp)) { + if (!fread(&nl, sizeof(struct nlist), 1, fp)) { if (feof(fp)) badfmt(); error(archive); @@ -209,7 +215,7 @@ badread: if (nr < 0) } bad2: free(strtab); -bad1: (void)lseek(rfd, (off_t)r_off, SEEK_SET); +bad1: (void)lseek(rfd, r_off, SEEK_SET); } /* @@ -222,11 +228,12 @@ symobj() { register RLIB *rp, *rnext; struct ranlib rn; + off_t ransize; + long size, stroff; char hb[sizeof(struct ar_hdr) + 1], pad; - long ransize, size, stroff; /* Rewind the archive, leaving the magic number. */ - if (fseek(fp, (off_t)SARMAG, SEEK_SET) == (off_t)-1) + if (fseek(fp, (long)SARMAG, SEEK_SET)) error(archive); /* Size of the ranlib archive file, pad if necessary. */ @@ -247,7 +254,7 @@ symobj() /* First long is the size of the ranlib structure section. */ size = symcnt * sizeof(struct ranlib); - if (!fwrite((char *)&size, sizeof(size), 1, fp)) + if (!fwrite(&size, sizeof(size), 1, fp)) error(tname); /* Offset of the first archive file. */ @@ -262,12 +269,12 @@ symobj() rn.ran_un.ran_strx = stroff; stroff += rp->symlen; rn.ran_off = size + rp->pos; - if (!fwrite((char *)&rn, sizeof(struct ranlib), 1, fp)) + if (!fwrite(&rn, sizeof(struct ranlib), 1, fp)) error(archive); } /* Second long is the size of the string table. */ - if (!fwrite((char *)&tsymlen, sizeof(tsymlen), 1, fp)) + if (!fwrite(&tsymlen, sizeof(tsymlen), 1, fp)) error(tname); /* Write out the string table. */ diff --git a/usr.bin/ranlib/misc.c b/usr.bin/ranlib/misc.c index 89487be6dd14..5487d5774217 100644 --- a/usr.bin/ranlib/misc.c +++ b/usr.bin/ranlib/misc.c @@ -1,8 +1,8 @@ -/* $NetBSD: misc.c,v 1.6 1997/01/09 20:20:56 tls Exp $ */ +/* $NetBSD: misc.c,v 1.7 1997/10/19 05:50:29 mrg Exp $ */ /*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Hugh Smith at The University of Guelph. @@ -37,8 +37,11 @@ */ #ifndef lint -/*static char sccsid[] = "from: @(#)misc.c 5.2 (Berkeley) 2/26/91";*/ -static char rcsid[] = "$NetBSD: misc.c,v 1.6 1997/01/09 20:20:56 tls Exp $"; +#if 0 +static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93"; +#else +static char rcsid[] = "$NetBSD: misc.c,v 1.7 1997/10/19 05:50:29 mrg Exp $"; +#endif #endif /* not lint */ #include @@ -67,20 +70,17 @@ tmp() } if (envtmp) - (void)snprintf(path, MAXPATHLEN, "%s/%s", envtmp, _NAME_RANTMP); + (void)snprintf(path, MAXPATHLEN, "%s/%s", envtmp, + strrchr(_NAME_RANTMP, '/')); else bcopy(_PATH_RANTMP, path, sizeof(_PATH_RANTMP)); - sigemptyset(&set); - sigaddset(&set, SIGHUP); - sigaddset(&set, SIGINT); - sigaddset(&set, SIGQUIT); - sigaddset(&set, SIGTERM); + sigfillset(&set); (void)sigprocmask(SIG_BLOCK, &set, &oset); if ((fd = mkstemp(path)) == -1) - error(tname); - (void)unlink(path); - (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); + error(path); + (void)unlink(path); + (void)sigprocmask(SIG_SETMASK, &oset, NULL); return(fd); } @@ -88,9 +88,9 @@ void * emalloc(len) int len; { - char *p; + void *p; - if (!(p = malloc((u_int)len))) + if ((p = malloc((u_int)len)) == NULL) error(archive); return(p); } diff --git a/usr.bin/ranlib/pathnames.h b/usr.bin/ranlib/pathnames.h index d3fe61e4afb4..baca97739cdb 100644 --- a/usr.bin/ranlib/pathnames.h +++ b/usr.bin/ranlib/pathnames.h @@ -1,8 +1,8 @@ -/* $NetBSD: pathnames.h,v 1.4 1997/01/09 20:20:57 tls Exp $ */ +/* $NetBSD: pathnames.h,v 1.5 1997/10/19 05:50:30 mrg Exp $ */ /*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,8 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)pathnames.h 5.2 (Berkeley) 4/16/91 - * $NetBSD: pathnames.h,v 1.4 1997/01/09 20:20:57 tls Exp $ + * from: @(#)pathnames.h 8.1 (Berkeley) 6/6/93 */ #define _NAME_RANTMP "ranlib.XXXXXX" diff --git a/usr.bin/ranlib/ranlib.1 b/usr.bin/ranlib/ranlib.1 index b8121d83d994..5b703124cfc8 100644 --- a/usr.bin/ranlib/ranlib.1 +++ b/usr.bin/ranlib/ranlib.1 @@ -1,7 +1,7 @@ -.\" $NetBSD: ranlib.1,v 1.4 1997/01/09 20:20:58 tls Exp $ +.\" $NetBSD: ranlib.1,v 1.5 1997/10/19 05:50:31 mrg Exp $ .\" -.\" Copyright (c) 1990 Regents of the University of California. -.\" All rights reserved. +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -31,10 +31,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" from: @(#)ranlib.1 6.7 (Berkeley) 5/9/91 -.\" $NetBSD: ranlib.1,v 1.4 1997/01/09 20:20:58 tls Exp $ +.\" from: @(#)ranlib.1 8.1 (Berkeley) 6/6/93 .\" -.Dd May 9, 1991 +.Dd June 6, 1993 .Dt RANLIB 1 .Os .Sh NAME diff --git a/usr.bin/ranlib/ranlib.5 b/usr.bin/ranlib/ranlib.5 index f53d3a687f37..a01b6ea48cc5 100644 --- a/usr.bin/ranlib/ranlib.5 +++ b/usr.bin/ranlib/ranlib.5 @@ -1,7 +1,7 @@ -.\" $NetBSD: ranlib.5,v 1.2 1997/01/09 20:20:59 tls Exp $ +.\" $NetBSD: ranlib.5,v 1.3 1997/10/19 05:50:33 mrg Exp $ .\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -31,10 +31,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" from: @(#)ranlib.5.5 5.2 (Berkeley) 5/10/91 -.\" $NetBSD: ranlib.5,v 1.2 1997/01/09 20:20:59 tls Exp $ +.\" from: @(#)ranlib.5.5 8.1 (Berkeley) 6/6/93 .\" -.Dd May 10, 1991 +.Dd June 6, 1993 .Dt RANLIB 5 .Os .Sh NAME diff --git a/usr.bin/ranlib/ranlib.c b/usr.bin/ranlib/ranlib.c index fcfda0b2491e..d90103b27c64 100644 --- a/usr.bin/ranlib/ranlib.c +++ b/usr.bin/ranlib/ranlib.c @@ -1,8 +1,8 @@ -/* $NetBSD: ranlib.c,v 1.4 1997/01/09 20:21:00 tls Exp $ */ +/* $NetBSD: ranlib.c,v 1.5 1997/10/19 05:50:34 mrg Exp $ */ /*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Hugh Smith at The University of Guelph. @@ -37,14 +37,17 @@ */ #ifndef lint -char copyright[] = -"@(#) Copyright (c) 1990 The Regents of the University of California.\n\ - All rights reserved.\n"; +static char copyright[] = +"@(#) Copyright (c) 1990, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -/*static char sccsid[] = "from: @(#)ranlib.c 5.6 (Berkeley) 2/26/91";*/ -static char rcsid[] = "$NetBSD: ranlib.c,v 1.4 1997/01/09 20:21:00 tls Exp $"; +#if 0 +static char sccsid[] = "@(#)ranlib.c 8.1 (Berkeley) 6/6/93"; +#else +static char rcsid[] = "$NetBSD: ranlib.c,v 1.5 1997/10/19 05:50:34 mrg Exp $"; +#endif #endif /* not lint */ #include diff --git a/usr.bin/ranlib/touch.c b/usr.bin/ranlib/touch.c index c13ce516d13a..d9399dae7c21 100644 --- a/usr.bin/ranlib/touch.c +++ b/usr.bin/ranlib/touch.c @@ -1,8 +1,8 @@ -/* $NetBSD: touch.c,v 1.4 1997/01/09 20:21:01 tls Exp $ */ +/* $NetBSD: touch.c,v 1.5 1997/10/19 05:50:36 mrg Exp $ */ /*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Hugh Smith at The University of Guelph. @@ -37,8 +37,11 @@ */ #ifndef lint -/*static char sccsid[] = "from: @(#)touch.c 5.3 (Berkeley) 3/12/91";*/ -static char rcsid[] = "$NetBSD: touch.c,v 1.4 1997/01/09 20:21:01 tls Exp $"; +#if 0 +static char sccsid[] = "@(#)touch.c 8.1 (Berkeley) 6/6/93"; +#else +static char rcsid[] = "$NetBSD: touch.c,v 1.5 1997/10/19 05:50:36 mrg Exp $"; +#endif #endif /* not lint */ #include