merge lite-2.

This commit is contained in:
mrg 1997-10-19 05:50:26 +00:00
parent e55eeec2c5
commit 0c67cce512
8 changed files with 80 additions and 70 deletions

View File

@ -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

View File

@ -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 <sys/types.h>
#include <sys/stat.h>
#include <a.out.h>
#include <ar.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <a.out.h>
#include <dirent.h>
#include <unistd.h>
#include <ar.h>
#include <ranlib.h>
#include <stdio.h>
#include <string.h>
#include <archive.h>
#include <unistd.h>
#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. */

View File

@ -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 <sys/param.h>
@ -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);
}

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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 <sys/types.h>

View File

@ -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 <sys/types.h>