Fixes from <thomas@mathematik.uni-Bremen.de> + some minor cleanup:

> re-initialize for before processing each archive.
> release memory.
> get temp file creation right.
This commit is contained in:
pk 1994-03-03 10:20:06 +00:00
parent db651dca40
commit a5d3e918bd
4 changed files with 22 additions and 19 deletions

View File

@ -36,7 +36,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)build.c 5.3 (Berkeley) 3/12/91";*/
static char rcsid[] = "$Id: build.c,v 1.2 1993/08/01 18:09:57 mycroft Exp $";
static char rcsid[] = "$Id: build.c,v 1.3 1994/03/03 10:20:06 pk Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -63,8 +63,12 @@ typedef struct _rlib {
} RLIB;
RLIB *rhead, **pnext;
FILE *fp;
static void rexec(), symobj();
static FILE *fp;
static long symcnt; /* symbol count */
static long tsymlen; /* total string length */
static void rexec(), symobj();
extern void *emalloc();
build()
{
@ -79,6 +83,7 @@ build()
SETCF(afd, archive, tfd, tname, RPAD|WPAD);
/* Read through the archive, creating list of symbols. */
symcnt = tsymlen = 0;
pnext = &rhead;
while(get_arobj(afd)) {
if (!strcmp(chdr.name, RANLIBMAG)) {
@ -107,9 +112,6 @@ build()
return(0);
}
long symcnt; /* symbol count */
long tsymlen; /* total string length */
/*
* rexec
* Read the exec structure; ignore any files that don't look
@ -128,7 +130,6 @@ rexec(rfd, wfd)
struct nlist nl;
off_t r_off, w_off;
long strsize;
void *emalloc();
/* Get current offsets for original and tmp files. */
r_off = lseek(rfd, (off_t)0, SEEK_CUR);
@ -216,12 +217,10 @@ bad1: (void)lseek(rfd, (off_t)r_off, SEEK_SET);
static void
symobj()
{
register RLIB *rp;
register RLIB *rp, *rnext;
struct ranlib rn;
char hb[sizeof(struct ar_hdr) + 1], pad;
long ransize, size, stroff;
gid_t getgid();
uid_t getuid();
/* Rewind the archive, leaving the magic number. */
if (fseek(fp, (off_t)SARMAG, SEEK_SET) == (off_t)-1)
@ -269,9 +268,13 @@ symobj()
error(tname);
/* Write out the string table. */
for (rp = rhead; rp; rp = rp->next)
for (rp = rhead; rp; rp = rnext) {
if (!fwrite(rp->sym, rp->symlen, 1, fp))
error(tname);
rnext = rp->next;
free(rp);
}
rhead = NULL;
if (pad && !fwrite(&pad, sizeof(pad), 1, fp))
error(tname);

View File

@ -36,7 +36,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)misc.c 5.2 (Berkeley) 2/26/91";*/
static char rcsid[] = "$Id: misc.c,v 1.3 1994/01/03 19:14:18 jtc Exp $";
static char rcsid[] = "$Id: misc.c,v 1.4 1994/03/03 10:20:09 pk Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -48,12 +48,12 @@ static char rcsid[] = "$Id: misc.c,v 1.3 1994/01/03 19:14:18 jtc Exp $";
#include <string.h>
#include "pathnames.h"
extern char *archive; /* archive name */
char *tname = "temporary file"; /* temporary file "name" */
extern char *archive; /* archive name */
char *tname = "temporary file";
tmp()
{
char *envtmp;
static char *envtmp;
sigset_t set, oset;
static int first;
int fd;
@ -65,7 +65,7 @@ tmp()
}
if (envtmp)
(void)sprintf(path, "%s/%s", envtmp, _NAME_RANTMP);
(void)snprintf(path, MAXPATHLEN, "%s/%s", envtmp, _NAME_RANTMP);
else
bcopy(_PATH_RANTMP, path, sizeof(_PATH_RANTMP));

View File

@ -42,7 +42,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)ranlib.c 5.6 (Berkeley) 2/26/91";*/
static char rcsid[] = "$Id: ranlib.c,v 1.2 1993/08/01 18:09:54 mycroft Exp $";
static char rcsid[] = "$Id: ranlib.c,v 1.3 1994/03/03 10:20:10 pk Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -59,7 +59,6 @@ main(argc, argv)
int argc;
char **argv;
{
extern int optind;
int ch, eval, tflag;
tflag = 0;

View File

@ -36,7 +36,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)touch.c 5.3 (Berkeley) 3/12/91";*/
static char rcsid[] = "$Id: touch.c,v 1.2 1993/08/01 18:09:52 mycroft Exp $";
static char rcsid[] = "$Id: touch.c,v 1.3 1994/03/03 10:20:12 pk Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -66,6 +66,7 @@ touch()
return(1);
}
settime(afd);
close_archive(afd);
return(0);
}