back all changes out until I fix it properly.

This commit is contained in:
christos 2008-02-15 21:29:50 +00:00
parent 4b3df4502b
commit a686e4e754
23 changed files with 329 additions and 380 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: arch.c,v 1.54 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: arch.c,v 1.55 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: arch.c,v 1.54 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: arch.c,v 1.55 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: arch.c,v 1.54 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: arch.c,v 1.55 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -257,7 +257,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
* Variable spec, so call the Var module to parse the puppy
* so we can safely advance beyond it...
*/
size_t length;
int length;
void *freeIt;
char *result;
@ -298,7 +298,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
* Variable spec, so call the Var module to parse the puppy
* so we can safely advance beyond it...
*/
size_t length;
int length;
void *freeIt;
char *result;
@ -526,7 +526,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
{
#define AR_MAX_NAME_LEN (sizeof(arh.ar_name)-1)
FILE * arch; /* Stream to archive */
size_t size; /* Size of archive member */
int size; /* Size of archive member */
char *cp; /* Useful character pointer */
char magic[SARMAG];
LstNode ln; /* Lst member containing archive descriptor */
@ -617,7 +617,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
Hash_InitTable(&ar->members, -1);
memName[AR_MAX_NAME_LEN] = '\0';
while (fread(&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
if (strncmp( arh.ar_fmag, ARFMAG, sizeof(arh.ar_fmag)) != 0) {
/*
* The header is bogus, so the archive is bad
@ -632,7 +632,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
* 'size' field of the header and round it up during the seek.
*/
arh.ar_size[sizeof(arh.ar_size)-1] = '\0';
size = (size_t)strtol(arh.ar_size, NULL, 10);
size = (int)strtol(arh.ar_size, NULL, 10);
(void)strncpy(memName, arh.ar_name, sizeof(arh.ar_name));
for (cp = &memName[AR_MAX_NAME_LEN]; *cp == ' '; cp--) {
@ -671,11 +671,11 @@ ArchStatMember(char *archive, char *member, Boolean hash)
if (strncmp(memName, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 &&
isdigit((unsigned char)memName[sizeof(AR_EFMT1) - 1])) {
long elen = atol(&memName[sizeof(AR_EFMT1)-1]);
unsigned int elen = atoi(&memName[sizeof(AR_EFMT1)-1]);
if (elen > MAXPATHLEN)
goto badarch;
if (fread(memName, (size_t)elen, (size_t)1, arch) != 1)
if (fread(memName, elen, 1, arch) != 1)
goto badarch;
memName[elen] = '\0';
fseek(arch, -elen, SEEK_CUR);
@ -689,7 +689,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
Hash_SetValue(he, emalloc(sizeof(struct ar_hdr)));
memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));
}
fseek(arch, (long)((size + 1) & ~1), SEEK_CUR);
fseek(arch, (size + 1) & ~1, SEEK_CUR);
}
fclose(arch);
@ -883,7 +883,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
tlen = sizeof(arhPtr->ar_name);
}
while (fread(arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) {
while (fread((char *)arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) {
if (strncmp(arhPtr->ar_fmag, ARFMAG, sizeof(arhPtr->ar_fmag) ) != 0) {
/*
* The header is bogus, so the archive is bad
@ -909,7 +909,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
* the file at the actual member, rather than its header, but
* not here...
*/
fseek(arch, -(long)sizeof(struct ar_hdr), SEEK_CUR);
fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR);
return (arch);
}
} else
@ -922,29 +922,27 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
sizeof(AR_EFMT1) - 1) == 0 &&
isdigit((unsigned char)arhPtr->ar_name[sizeof(AR_EFMT1) - 1])) {
long elen = atol(&arhPtr->ar_name[sizeof(AR_EFMT1)-1]);
unsigned int elen = atoi(&arhPtr->ar_name[sizeof(AR_EFMT1)-1]);
char ename[MAXPATHLEN + 1];
if (elen > MAXPATHLEN) {
fclose(arch);
return NULL;
}
if (fread(ename, (size_t)elen, (size_t)1, arch) != 1) {
if (fread(ename, elen, 1, arch) != 1) {
fclose(arch);
return NULL;
}
ename[elen] = '\0';
if (DEBUG(ARCH) || DEBUG(MAKE)) {
(void)fprintf(debug_file,
"ArchFind: Extended format entry for %s\n", ename);
fprintf(debug_file, "ArchFind: Extended format entry for %s\n", ename);
}
if (strncmp(ename, member, len) == 0) {
/* Found as extended name */
(void)fseek(arch, (long)(-sizeof(struct ar_hdr) - elen),
SEEK_CUR);
fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);
return (arch);
}
(void)fseek(arch, -elen, SEEK_CUR);
fseek(arch, -elen, SEEK_CUR);
goto skip;
} else
#endif
@ -958,8 +956,8 @@ skip:
* header and round it up during the seek.
*/
arhPtr->ar_size[sizeof(arhPtr->ar_size)-1] = '\0';
size = (size_t)strtol(arhPtr->ar_size, NULL, 10);
(void)fseek(arch, (long)((size + 1) & ~1), SEEK_CUR);
size = (int)strtol(arhPtr->ar_size, NULL, 10);
fseek(arch, (size + 1) & ~1, SEEK_CUR);
}
}
@ -1003,11 +1001,11 @@ Arch_Touch(GNode *gn)
free(p1);
if (p2)
free(p2);
(void)snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
if (arch != NULL) {
(void)fwrite(&arh, sizeof(struct ar_hdr), 1, arch);
(void)fclose(arch);
(void)fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch);
fclose(arch);
}
}
@ -1031,7 +1029,6 @@ Arch_Touch(GNode *gn)
*/
void
#if !defined(RANLIBMAG)
/*ARGSUSED*/
Arch_TouchLib(GNode *gn __unused)
#else
Arch_TouchLib(GNode *gn)
@ -1138,9 +1135,8 @@ Arch_MemMTime(GNode *gn)
nameEnd = strchr(nameStart, ')');
if ((pgn->flags & REMAKE) &&
strncmp(nameStart, gn->name,
(size_t)(nameEnd - nameStart)) == 0) {
gn->mtime = Arch_MTime(pgn);
strncmp(nameStart, gn->name, nameEnd - nameStart) == 0) {
gn->mtime = Arch_MTime(pgn);
}
} else if (pgn->flags & REMAKE) {
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: buf.c,v 1.20 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: buf.c,v 1.21 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: buf.c,v 1.20 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: buf.c,v 1.21 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: buf.c,v 1.20 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: buf.c,v 1.21 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -104,7 +104,7 @@ __RCSID("$NetBSD: buf.c,v 1.20 2008/02/14 22:11:20 christos Exp $");
*/
#define BufExpand(bp,nb) \
while (bp->left < (nb)+1) {\
size_t newSize = (bp)->size * 2; \
int newSize = (bp)->size * 2; \
Byte *newBuf = (Byte *)erealloc((bp)->buffer, newSize); \
\
(bp)->inPtr = newBuf + ((bp)->inPtr - (bp)->buffer); \
@ -132,7 +132,7 @@ __RCSID("$NetBSD: buf.c,v 1.20 2008/02/14 22:11:20 christos Exp $");
void
Buf_OvAddByte(Buffer bp, int byte)
{
size_t nbytes = 1;
int nbytes = 1;
bp->left = 0;
BufExpand(bp, nbytes);
@ -159,12 +159,12 @@ Buf_OvAddByte(Buffer bp, int byte)
*-----------------------------------------------------------------------
*/
void
Buf_AddBytes(Buffer bp, size_t numBytes, const Byte *bytesPtr)
Buf_AddBytes(Buffer bp, int numBytes, const Byte *bytesPtr)
{
BufExpand(bp, numBytes);
(void)memcpy(bp->inPtr, bytesPtr, numBytes);
memcpy(bp->inPtr, bytesPtr, numBytes);
bp->inPtr += numBytes;
bp->left -= numBytes;
@ -188,7 +188,7 @@ Buf_AddBytes(Buffer bp, size_t numBytes, const Byte *bytesPtr)
*-----------------------------------------------------------------------
*/
Byte *
Buf_GetAll(Buffer bp, size_t *numBytesPtr)
Buf_GetAll(Buffer bp, int *numBytesPtr)
{
if (numBytesPtr != NULL) {
@ -212,7 +212,7 @@ Buf_GetAll(Buffer bp, size_t *numBytesPtr)
*-----------------------------------------------------------------------
*/
void
Buf_Discard(Buffer bp, size_t numBytes)
Buf_Discard(Buffer bp, int numBytes)
{
if (bp->inPtr - bp->outPtr <= numBytes) {
@ -238,10 +238,10 @@ Buf_Discard(Buffer bp, size_t numBytes)
*
*-----------------------------------------------------------------------
*/
size_t
int
Buf_Size(Buffer buf)
{
return (size_t)(buf->inPtr - buf->outPtr);
return (buf->inPtr - buf->outPtr);
}
/*-
@ -263,13 +263,13 @@ Buf_Size(Buffer buf)
*-----------------------------------------------------------------------
*/
Buffer
Buf_Init(size_t size)
Buf_Init(int size)
{
Buffer bp; /* New Buffer */
bp = emalloc(sizeof(*bp));
if (size == 0) {
if (size <= 0) {
size = BUF_DEF_SIZE;
}
bp->left = bp->size = size;
@ -307,7 +307,6 @@ Buf_Destroy(Buffer buf, Boolean freeData)
free(buf);
}
#ifdef notdef
/*-
*-----------------------------------------------------------------------
* Buf_ReplaceLastByte --
@ -334,4 +333,3 @@ Buf_ReplaceLastByte(Buffer buf, int byte)
else
*(buf->inPtr - 1) = byte;
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: buf.h,v 1.11 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: buf.h,v 1.12 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -85,8 +85,8 @@
typedef char Byte;
typedef struct Buffer {
size_t size; /* Current size of the buffer */
size_t left; /* Space left (== size - (inPtr - buffer)) */
int size; /* Current size of the buffer */
int left; /* Space left (== size - (inPtr - buffer)) */
Byte *buffer; /* The buffer itself */
Byte *inPtr; /* Place to write to */
Byte *outPtr; /* Place to read from */
@ -94,21 +94,18 @@ typedef struct Buffer {
/* Buf_AddByte adds a single byte to a buffer. */
#define Buf_AddByte(bp, byte) \
/*LINTED*/ \
(void)(--(bp)->left == 0 ? Buf_OvAddByte(bp, byte), 1 : \
(void) (--(bp)->left <= 0 ? Buf_OvAddByte(bp, byte), 1 : \
(*(bp)->inPtr++ = (byte), *(bp)->inPtr = 0), 1)
#define BUF_ERROR 256
void Buf_OvAddByte(Buffer, int);
void Buf_AddBytes(Buffer, size_t, const Byte *);
Byte *Buf_GetAll(Buffer, size_t *);
void Buf_Discard(Buffer, size_t);
size_t Buf_Size(Buffer);
Buffer Buf_Init(size_t);
void Buf_AddBytes(Buffer, int, const Byte *);
Byte *Buf_GetAll(Buffer, int *);
void Buf_Discard(Buffer, int);
int Buf_Size(Buffer);
Buffer Buf_Init(int);
void Buf_Destroy(Buffer, Boolean);
#ifdef notdef
void Buf_ReplaceLastByte(Buffer, int);
#endif
#endif /* _BUF_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.70 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: compat.c,v 1.71 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: compat.c,v 1.70 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: compat.c,v 1.71 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: compat.c,v 1.70 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: compat.c,v 1.71 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -211,12 +211,12 @@ CompatRunCommand(ClientData cmdp, ClientData gnp)
volatile Boolean errCheck; /* Check errors */
int reason; /* Reason for child's death */
int status; /* Description of child's death */
pid_t cpid; /* Child actually found */
pid_t retstat; /* Status of fork */
int cpid; /* Child actually found */
ReturnStatus retstat; /* Status of fork */
LstNode cmdNode; /* Node where current command is located */
const char ** volatile av; /* Argument vector for thing to exec */
char ** volatile mav;/* Copy of the argument vector for freeing */
size_t argc; /* Number of arguments in av or 0 if not
int argc; /* Number of arguments in av or 0 if not
* dynamically allocated */
Boolean local; /* TRUE if command should be executed
* locally */
@ -371,7 +371,7 @@ CompatRunCommand(ClientData cmdp, ClientData gnp)
/*
* The child is off and running. Now all we can do is wait...
*/
for (;;) {
while (1) {
while ((retstat = wait(&reason)) != cpid) {
if (retstat == -1 && errno != EINTR) {
@ -545,7 +545,7 @@ Compat_Make(ClientData gnp, ClientData pgnp)
Lst_ForEach(gn->commands, CompatRunCommand, gn);
curTarg = NILGNODE;
} else {
Job_Touch(gn, (gn->type & OP_SILENT) != 0);
Job_Touch(gn, gn->type & OP_SILENT);
}
} else {
gn->made = ERROR;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cond.c,v 1.40 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: cond.c,v 1.41 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: cond.c,v 1.40 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: cond.c,v 1.41 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: cond.c,v 1.40 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: cond.c,v 1.41 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -154,7 +154,7 @@ static Token CondE(Boolean);
static const struct If {
const char *form; /* Form of if */
size_t formlen; /* Length of form */
int formlen; /* Length of form */
Boolean doNot; /* TRUE if default function should be negated */
Boolean (*defProc)(int, char *); /* Default function to apply */
} ifs[] = {
@ -225,7 +225,7 @@ static int
CondGetArg(char **linePtr, char **argPtr, const char *func, Boolean parens)
{
char *cp;
size_t argLen;
int argLen;
Buffer buf;
cp = *linePtr;
@ -268,7 +268,7 @@ CondGetArg(char **linePtr, char **argPtr, const char *func, Boolean parens)
* though perhaps we should...
*/
char *cp2;
size_t len;
int len;
void *freeIt;
cp2 = Var_Parse(cp, VAR_CMD, TRUE, &len, &freeIt);
@ -554,7 +554,7 @@ CondGetString(Boolean doEval, Boolean *quoted, void **freeIt)
Buffer buf;
char *cp;
char *str;
size_t len;
int len;
int qt;
char *start;
@ -903,8 +903,7 @@ error:
* Use Var_Parse to parse the spec in parens and return
* True if the resulting string is empty.
*/
int did_warn;
size_t length;
int did_warn, length;
void *freeIt;
char *val;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.54 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: dir.c,v 1.55 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: dir.c,v 1.54 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: dir.c,v 1.55 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: dir.c,v 1.54 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: dir.c,v 1.55 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -296,7 +296,7 @@ Dir_InitCur(const char *cdname)
* Our build directory is not the same as our source directory.
* Keep this one around too.
*/
if ((p = Dir_AddDir(NULL, cdname)) != NULL) {
if ((p = Dir_AddDir(NULL, cdname))) {
p->refCount += 1;
if (cur && cur != p) {
/*
@ -592,7 +592,7 @@ DirExpandCurly(const char *word, const char *brace, Lst path, Lst expansions)
* right brace when this is 0, we've hit the
* end of the clause. */
char *file; /* Current expansion */
size_t otherLen; /* The length of the other pieces of the
int otherLen; /* The length of the other pieces of the
* expansion (chars before and after the
* clause in 'word') */
char *cp2; /* Pointer for checking for wildcards in
@ -635,14 +635,14 @@ DirExpandCurly(const char *word, const char *brace, Lst path, Lst expansions)
/*
* Allocate room for the combination and install the three pieces.
*/
file = emalloc((size_t)(otherLen + cp - start + 1));
file = emalloc(otherLen + cp - start + 1);
if (brace != word) {
(void)strncpy(file, word, (size_t)(brace-word));
strncpy(file, word, brace-word);
}
if (cp != start) {
strncpy(&file[brace-word], start, (size_t)(cp-start));
strncpy(&file[brace-word], start, cp-start);
}
(void)strcpy(&file[(brace-word)+(cp-start)], end);
strcpy(&file[(brace-word)+(cp-start)], end);
/*
* See if the result has any wildcards in it. If we find one, call
@ -860,7 +860,6 @@ Dir_Expand(const char *word, Lst path, Lst expansions)
*-----------------------------------------------------------------------
*/
static char *
/*ARGSUSED*/
DirLookup(Path *p, const char *name __unused, const char *cp,
Boolean hasSlash __unused)
{
@ -1003,7 +1002,6 @@ DirLookupAbs(Path *p, const char *name, const char *cp)
*-----------------------------------------------------------------------
*/
static char *
/*ARGSUSED*/
DirFindDot(Boolean hasSlash __unused, const char *name, const char *cp)
{
@ -1340,7 +1338,7 @@ Dir_FindFile(const char *name, Lst path)
*-----------------------------------------------------------------------
*/
int
Dir_FindHereOrAbove(char *here, char *search_path, char *result, size_t rlen) {
Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen) {
struct stat st;
char dirbase[MAXPATHLEN + 1], *db_end;
@ -1351,10 +1349,10 @@ Dir_FindHereOrAbove(char *here, char *search_path, char *result, size_t rlen) {
db_end = dirbase + strlen(dirbase);
/* loop until we determine a result */
for (;;) {
while (1) {
/* try and stat(2) it ... */
(void)snprintf(try, sizeof(try), "%s/%s", dirbase, search_path);
snprintf(try, sizeof(try), "%s/%s", dirbase, search_path);
if (stat(try, &st) != -1) {
/*
* success! if we found a file, chop off

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.h,v 1.12 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: dir.h,v 1.13 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -94,7 +94,7 @@ void Dir_SetPATH(void);
Boolean Dir_HasWildcards(char *);
void Dir_Expand(const char *, Lst, Lst);
char *Dir_FindFile(const char *, Lst);
int Dir_FindHereOrAbove(char *, char *, char *, size_t);
int Dir_FindHereOrAbove(char *, char *, char *, int);
int Dir_MTime(GNode *);
Path *Dir_AddDir(Lst, const char *);
char *Dir_MakeFlags(const char *, Lst);

View File

@ -1,4 +1,4 @@
/* $NetBSD: for.c,v 1.27 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: for.c,v 1.28 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@ -30,14 +30,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: for.c,v 1.27 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: for.c,v 1.28 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: for.c,v 1.27 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: for.c,v 1.28 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -110,7 +110,7 @@ static void
ForAddVar(const char *data, size_t len)
{
Buffer buf;
size_t varlen;
int varlen;
buf = Buf_Init(0);
Buf_AddBytes(buf, len, (Byte *)UNCONST(data));
@ -154,7 +154,7 @@ For_Eval(char *line)
if (forLevel == 0) {
Buffer buf;
size_t varlen;
int varlen;
static const char instr[] = "in";
for (ptr++; *ptr && isspace((unsigned char) *ptr); ptr++)
@ -197,7 +197,7 @@ For_Eval(char *line)
wrd = ptr;
while (*ptr && !isspace((unsigned char) *ptr))
ptr++;
ForAddVar(wrd, (size_t)(ptr - wrd));
ForAddVar(wrd, ptr - wrd);
while (*ptr && isspace((unsigned char) *ptr))
ptr++;
}
@ -226,10 +226,10 @@ For_Eval(char *line)
sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE);
#define ADDWORD() \
(void)(Buf_AddBytes(buf, (size_t)(ptr - wrd), (Byte *)wrd), \
Buf_AddBytes(buf, ptr - wrd, (Byte *)wrd), \
Buf_AddByte(buf, (Byte)'\0'), \
Lst_AtFront(accumFor.lst, Buf_GetAll(buf, &varlen)), \
Buf_Destroy(buf, FALSE))
Buf_Destroy(buf, FALSE)
for (ptr = sub; *ptr && isspace((unsigned char) *ptr); ptr++)
continue;
@ -310,8 +310,7 @@ For_Run(int lineno)
For arg;
LstNode ln;
char **values;
int i, done = 0;
size_t len;
int i, done = 0, len;
char *guy, *orig_guy, *old_guy;
if (accumFor.buf == NULL || accumFor.vars == NULL || accumFor.lst == NULL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.138 2008/02/15 20:08:11 christos Exp $ */
/* $NetBSD: job.c,v 1.139 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: job.c,v 1.138 2008/02/15 20:08:11 christos Exp $";
static char rcsid[] = "$NetBSD: job.c,v 1.139 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: job.c,v 1.138 2008/02/15 20:08:11 christos Exp $");
__RCSID("$NetBSD: job.c,v 1.139 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -171,12 +171,13 @@ static int aborting = 0; /* why is the make aborting? */
* this tracks the number of tokens currently "out" to build jobs.
*/
int jobTokensRunning = 0;
int not_parallel = 0; /* set if .NOT_PARALLEL */
/*
* XXX: Avoid SunOS bug... FILENO() is fp->_file, and file
* is a char! So when we go above 127 we turn negative!
*/
#define FILENO(a) ((int)(unsigned)fileno(a))
#define FILENO(a) ((unsigned) fileno(a))
/*
* post-make command processing. The node postCommands is really just the
@ -313,7 +314,7 @@ static int make_suspended = 0; /* non-zero if we've seen a SIGTSTP (etc) */
*/
static struct pollfd *fds = NULL;
static Job **jobfds = NULL;
static size_t nfds = 0;
static int nfds = 0;
static void watchfd(Job *);
static void clearfd(Job *);
static int readyfd(Job *);
@ -360,20 +361,17 @@ static void JobSigLock(sigset_t *);
static void JobSigUnlock(sigset_t *);
static void JobSigReset(void);
#ifdef notdef
const char *_malloc_options = "A";
#endif
const char *malloc_options="A";
static void
job_table_dump(const char *where)
{
Job *job;
(void)fprintf(debug_file, "job table @ %s\n", where);
fprintf(debug_file, "job table @ %s\n", where);
for (job = job_table; job < job_table_end; job++) {
(void)fprintf(debug_file, "job %d, status %d, flags %d, pid %ld\n",
(int)(job - job_table), job->job_state, job->flags,
(long)job->pid);
fprintf(debug_file, "job %d, status %d, flags %d, pid %d\n",
(int)(job - job_table), job->job_state, job->flags, job->pid);
}
}
@ -454,8 +452,8 @@ JobCondPassSig(int signo)
continue;
if (DEBUG(JOB)) {
(void)fprintf(debug_file,
"JobCondPassSig passing signal %d to child %ld.\n",
signo, (long)job->pid);
"JobCondPassSig passing signal %d to child %d.\n",
signo, job->pid);
}
KILLPG(job->pid, signo);
}
@ -479,7 +477,6 @@ JobCondPassSig(int signo)
*-----------------------------------------------------------------------
*/
static void
/*ARGSUSED*/
JobChildSig(int signo __unused)
{
write(childExitJob.outPipe, CHILD_EXIT, 1);
@ -503,7 +500,6 @@ JobChildSig(int signo __unused)
*-----------------------------------------------------------------------
*/
static void
/*ARGSUSED*/
JobContinueSig(int signo __unused)
{
/*
@ -620,7 +616,7 @@ JobPassSig_suspend(int signo)
*-----------------------------------------------------------------------
*/
static Job *
JobFindPid(pid_t pid, int status)
JobFindPid(int pid, int status)
{
Job *job;
@ -964,8 +960,8 @@ JobFinish(Job *job, int status)
Boolean done, return_job_token;
if (DEBUG(JOB)) {
(void)fprintf(debug_file, "Jobfinish: %ld [%s], status %d\n",
(long)job->pid, job->node->name, status);
fprintf(debug_file, "Jobfinish: %d [%s], status %d\n",
job->pid, job->node->name, status);
}
if ((WIFEXITED(status) &&
@ -1012,8 +1008,8 @@ JobFinish(Job *job, int status)
if (done) {
if (WIFEXITED(status)) {
if (DEBUG(JOB)) {
(void)fprintf(debug_file, "Process %ld [%s] exited.\n",
(long)job->pid, job->node->name);
(void)fprintf(debug_file, "Process %d [%s] exited.\n",
job->pid, job->node->name);
}
if (WEXITSTATUS(status) != 0) {
if (job->node != lastNode) {
@ -1227,7 +1223,7 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
static const char msg[] = ": don't know how to make";
if (gn->flags & FROM_DEPEND) {
(void)fprintf(stdout, "%s: ignoring stale .depend for %s\n",
fprintf(stdout, "%s: ignoring stale .depend for %s\n",
progname, gn->name);
return TRUE;
}
@ -1270,7 +1266,7 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
static void
JobExec(Job *job, char **argv)
{
pid_t cpid; /* ID of new child */
int cpid; /* ID of new child */
sigset_t mask;
job->flags &= ~JOB_TRACED;
@ -1401,8 +1397,8 @@ JobExec(Job *job, char **argv)
* Now the job is actually running, add it to the table.
*/
if (DEBUG(JOB)) {
(void)fprintf(debug_file, "JobExec(%s): pid %ld added to jobs table\n",
job->node->name, (long)job->pid);
fprintf(debug_file, "JobExec(%s): pid %d added to jobs table\n",
job->node->name, job->pid);
job_table_dump("job started");
}
JobSigUnlock(&mask);
@ -1750,10 +1746,10 @@ JobDoOutput(Job *job, Boolean finish)
{
Boolean gotNL = FALSE; /* true if got a newline */
Boolean fbuf; /* true if our buffer filled up */
size_t nr; /* number of bytes read */
size_t i; /* auxiliary index into outBuf */
size_t max; /* limit for i (end of current data) */
ssize_t nRead; /* (Temporary) number of bytes read */
int nr; /* number of bytes read */
int i; /* auxiliary index into outBuf */
int max; /* limit for i (end of current data) */
int nRead; /* (Temporary) number of bytes read */
/*
* Read as many bytes as will fit in the buffer.
@ -1763,7 +1759,7 @@ end_loop:
fbuf = FALSE;
nRead = read(job->inPipe, &job->outBuf[job->curPos],
(size_t)(JOB_BUFSIZE - job->curPos));
JOB_BUFSIZE - job->curPos);
if (nRead < 0) {
if (errno == EAGAIN)
return;
@ -1795,20 +1791,17 @@ end_loop:
* TRUE.
*/
max = job->curPos + nr;
if (nr > 0) {
for (i = job->curPos + nr - 1; i >= job->curPos; i--) {
if (job->outBuf[i] == '\n') {
gotNL = TRUE;
break;
} else if (job->outBuf[i] == '\0') {
/*
* Why?
*/
job->outBuf[i] = ' ';
}
for (i = job->curPos + nr - 1; i >= job->curPos; i--) {
if (job->outBuf[i] == '\n') {
gotNL = TRUE;
break;
} else if (job->outBuf[i] == '\0') {
/*
* Why?
*/
job->outBuf[i] = ' ';
}
} else
i = job->curPos - 1;
}
if (!gotNL) {
job->curPos += nr;
@ -1852,7 +1845,7 @@ end_loop:
(void)fflush(stdout);
}
}
if (i + 1 < max) {
if (i < max - 1) {
/* shift the remaining characters down */
(void)memcpy(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
job->curPos = max - (i + 1);
@ -1929,9 +1922,9 @@ JobRun(GNode *targ)
void
Job_CatchChildren(void)
{
pid_t pid; /* pid of dead child */
int pid; /* pid of dead child */
Job *job; /* job descriptor for dead child */
int status; /* Exit/termination status */
int status; /* Exit/termination status */
/*
* Don't even bother if we know there's no one around.
@ -1941,21 +1934,20 @@ Job_CatchChildren(void)
while ((pid = waitpid((pid_t) -1, &status, WNOHANG | WUNTRACED)) > 0) {
if (DEBUG(JOB)) {
(void)fprintf(debug_file, "Process %ld exited/stopped status %x.\n",
(long)pid, status);
(void)fprintf(debug_file, "Process %d exited/stopped status %x.\n", pid,
status);
}
job = JobFindPid(pid, JOB_ST_RUNNING);
if (job == NULL) {
if (!lurking_children)
Error("Child (%ld) status %x not in table?", (long)pid,
status);
Error("Child (%d) status %x not in table?", pid, status);
continue;
}
if (WIFSTOPPED(status)) {
if (DEBUG(JOB)) {
(void)fprintf(debug_file, "Process %ld (%s) stopped.\n",
(long)job->pid, job->node->name);
(void)fprintf(debug_file, "Process %d (%s) stopped.\n",
job->pid, job->node->name);
}
if (!make_suspended) {
switch (WSTOPSIG(status)) {
@ -2319,7 +2311,7 @@ Job_ParseShell(char *line)
{
char **words;
char **argv;
size_t argc;
int argc;
char *path;
Shell newShell;
Boolean fullSpec = FALSE;
@ -2502,8 +2494,8 @@ JobInterrupt(int runINTERRUPT, int signo)
if (job->pid) {
if (DEBUG(JOB)) {
(void)fprintf(debug_file,
"JobInterrupt passing signal %d to child %ld.\n",
signo, (long)job->pid);
"JobInterrupt passing signal %d to child %d.\n",
signo, job->pid);
}
KILLPG(job->pid, signo);
}
@ -2659,8 +2651,8 @@ JobRestartJobs(void)
if (job->job_state == JOB_ST_RUNNING &&
(make_suspended || job->job_suspended)) {
if (DEBUG(JOB)) {
(void)fprintf(debug_file, "Restarting stopped job pid %ld.\n",
(long)job->pid);
(void)fprintf(debug_file, "Restarting stopped job pid %d.\n",
job->pid);
}
if (job->job_suspended) {
(void)printf("*** [%s] Continued\n", job->node->name);
@ -2668,8 +2660,7 @@ JobRestartJobs(void)
}
job->job_suspended = 0;
if (KILLPG(job->pid, SIGCONT) != 0 && DEBUG(JOB)) {
(void)fprintf(debug_file, "Failed to send SIGCONT to %ld\n",
(long)job->pid);
fprintf(debug_file, "Failed to send SIGCONT to %d\n", job->pid);
}
}
if (job->job_state == JOB_ST_FINISHED)
@ -2741,8 +2732,8 @@ JobTokenAdd(void)
continue;
if (DEBUG(JOB))
(void)fprintf(debug_file, "(%ld) aborting %d, deposit token %c\n",
(long)getpid(), aborting, JOB_TOKENS[aborting]);
fprintf(debug_file, "(%d) aborting %d, deposit token %c\n",
getpid(), aborting, JOB_TOKENS[aborting]);
write(tokenWaitJob.outPipe, &tok, 1);
}
@ -2830,9 +2821,8 @@ Job_TokenWithdraw(void)
wantToken = 0;
if (DEBUG(JOB))
(void)fprintf(debug_file,
"Job_TokenWithdraw(%ld): aborting %d, running %d\n",
(long)getpid(), aborting, jobTokensRunning);
fprintf(debug_file, "Job_TokenWithdraw(%d): aborting %d, running %d\n",
getpid(), aborting, jobTokensRunning);
if (aborting || (jobTokensRunning >= maxJobs))
return FALSE;
@ -2845,8 +2835,7 @@ Job_TokenWithdraw(void)
Fatal("job pipe read: %s", strerror(errno));
}
if (DEBUG(JOB))
(void)fprintf(debug_file, "(%ld) blocked for token\n",
(long)getpid());
fprintf(debug_file, "(%d) blocked for token\n", getpid());
wantToken = 1;
return FALSE;
}
@ -2854,8 +2843,7 @@ Job_TokenWithdraw(void)
if (count == 1 && tok != '+') {
/* make being abvorted - remove any other job tokens */
if (DEBUG(JOB))
(void)fprintf(debug_file, "(%ld) aborted by token %c\n",
(long)getpid(), tok);
fprintf(debug_file, "(%d) aborted by token %c\n", getpid(), tok);
while (read(tokenWaitJob.inPipe, &tok1, 1) == 1)
continue;
/* And put the stopper back */
@ -2869,7 +2857,7 @@ Job_TokenWithdraw(void)
jobTokensRunning++;
if (DEBUG(JOB))
(void)fprintf(debug_file, "(%ld) withdrew token\n", (long)getpid());
fprintf(debug_file, "(%d) withdrew token\n", getpid());
return TRUE;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.h,v 1.36 2008/02/15 09:18:56 dholland Exp $ */
/* $NetBSD: job.h,v 1.37 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -137,7 +137,7 @@ struct pollfd;
#define JOB_BUFSIZE 1024
typedef struct Job {
pid_t pid; /* The child's process ID */
int pid; /* The child's process ID */
GNode *node; /* The target the child is making */
LstNode tailCmds; /* The node of the first command to be
* saved when the job has been run */
@ -159,12 +159,12 @@ typedef struct Job {
* commands */
#define JOB_TRACED 0x400 /* we've sent 'set -x' */
int jobPipe[2]; /* Pipe for reading output from job */
int jobPipe[2]; /* Pipe for readind output from job */
struct pollfd *inPollfd; /* pollfd associated with inPipe */
char outBuf[JOB_BUFSIZE + 1];
/* Buffer for storing the output of the
* job, line by line */
size_t curPos; /* Current position in op_outBuf */
int curPos; /* Current position in op_outBuf */
} Job;
#define inPipe jobPipe[0]

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstForEachFrom.c,v 1.14 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: lstForEachFrom.c,v 1.15 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.14 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.15 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstForEachFrom.c,v 1.14 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: lstForEachFrom.c,v 1.15 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -115,7 +115,7 @@ Lst_ForEachFrom(Lst l, LstNode ln, int (*proc)(ClientData, ClientData),
}
if (tln->flags & LN_DELETED) {
free(tln);
free((char *)tln);
}
tln = next;
} while (!result && !LstIsEmpty(list) && !done);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstIsAtEnd.c,v 1.12 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: lstIsAtEnd.c,v 1.13 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.12 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.13 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstIsAtEnd.c,v 1.12 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: lstIsAtEnd.c,v 1.13 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -76,7 +76,6 @@ __RCSID("$NetBSD: lstIsAtEnd.c,v 1.12 2008/02/14 22:11:20 christos Exp $");
*
*-----------------------------------------------------------------------
*/
#ifdef notdef
Boolean
Lst_IsAtEnd(Lst l)
{
@ -85,4 +84,4 @@ Lst_IsAtEnd(Lst l)
return (!LstValid (l) || !list->isOpen ||
(list->atEnd == Head) || (list->atEnd == Tail));
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.148 2008/02/15 02:38:07 christos Exp $ */
/* $NetBSD: main.c,v 1.149 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: main.c,v 1.148 2008/02/15 02:38:07 christos Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.149 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.148 2008/02/15 02:38:07 christos Exp $");
__RCSID("$NetBSD: main.c,v 1.149 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -175,8 +175,8 @@ Boolean varNoExportEnv; /* -X flag */
Boolean doing_depend; /* Set while reading .depend */
static Boolean jobsRunning; /* TRUE if the jobs might be running */
static const char * tracefile;
static char * Check_Cwd_av(size_t, char **, int);
static void MainParseArgs(size_t, char **);
static char * Check_Cwd_av(int, char **, int);
static void MainParseArgs(int, char **);
static int ReadMakefile(ClientData, ClientData);
static void usage(void);
@ -194,7 +194,7 @@ parse_debug_options(const char *argvalue)
const char *modules;
const char *mode;
char *fname;
size_t len;
int len;
for (modules = argvalue; *modules; ++modules) {
switch (*modules) {
@ -278,8 +278,7 @@ parse_debug_options(const char *argvalue)
memcpy(fname, modules, len + 1);
/* Let the filename be modified by the pid */
if (strcmp(fname + len - 3, ".%d") == 0)
snprintf(fname + len - 2, 20, "%ld",
(long)getpid());
snprintf(fname + len - 2, 20, "%d", getpid());
debug_file = fopen(fname, mode);
if (!debug_file) {
fprintf(stderr, "Cannot open debug file %s\n",
@ -314,7 +313,7 @@ parse_debug_options(const char *argvalue)
* given
*/
static void
MainParseArgs(size_t argc, char **argv)
MainParseArgs(int argc, char **argv)
{
char *p;
int c = '?';
@ -576,7 +575,7 @@ void
Main_ParseArgLine(char *line)
{
char **argv; /* Manufactured argument vector */
size_t argc; /* Number of arguments in argv */
int argc; /* Number of arguments in argv */
char *args; /* Space used by the args */
char *buf, *p1;
char *argv0 = Var_Value(".MAKE", VAR_GLOBAL, &p1);
@ -699,7 +698,7 @@ main(int argc, char **argv)
* on each program execution.
*/
gettimeofday(&rightnow, NULL);
srandom((unsigned long)rightnow.tv_sec + rightnow.tv_usec);
srandom(rightnow.tv_sec + rightnow.tv_usec);
if ((progname = strrchr(argv[0], '/')) != NULL)
progname++;
@ -876,9 +875,9 @@ main(int argc, char **argv)
{
char tmp[64];
snprintf(tmp, sizeof(tmp), "%ld", (long)getpid());
snprintf(tmp, sizeof(tmp), "%u", getpid());
Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
snprintf(tmp, sizeof(tmp), "%ld", (long)getppid());
snprintf(tmp, sizeof(tmp), "%u", getppid());
Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0);
}
Job_SetPrefix();
@ -894,7 +893,7 @@ main(int argc, char **argv)
Main_ParseArgLine(getenv("MAKE"));
#endif
MainParseArgs((size_t)argc, argv);
MainParseArgs(argc, argv);
/*
* Be compatible if user did not specify -j and did not explicitly
@ -1155,7 +1154,6 @@ main(int argc, char **argv)
* lots
*/
static int
/*ARGSUSED*/
ReadMakefile(ClientData p, ClientData q __unused)
{
char *fname = p; /* makefile to read */
@ -1248,7 +1246,7 @@ found:
static int Check_Cwd_Off = 0;
static char *
Check_Cwd_av(size_t ac, char **av, int copy)
Check_Cwd_av(int ac, char **av, int copy)
{
static char *make[4];
static char *cur_dir = NULL;
@ -1359,7 +1357,7 @@ Check_Cwd_Cmd(const char *cmd)
{
char *cp, *bp;
char **av;
size_t ac;
int ac;
if (Check_Cwd_Off)
return NULL;
@ -1387,7 +1385,7 @@ void
Check_Cwd(const char **argv)
{
char *cp;
size_t ac;
int ac;
if (Check_Cwd_Off)
return;
@ -1421,14 +1419,13 @@ Cmd_Exec(const char *cmd, const char **errnum)
{
const char *args[4]; /* Args for invoking the shell */
int fds[2]; /* Pipe streams */
pid_t cpid; /* Child PID */
pid_t pid; /* PID from wait() */
int cpid; /* Child PID */
int pid; /* PID from wait() */
char *res; /* result */
int status; /* command exit status */
Buffer buf; /* buffer to store the result */
char *cp;
ssize_t cc;
size_t len;
int cc;
*errnum = NULL;
@ -1491,7 +1488,7 @@ Cmd_Exec(const char *cmd, const char **errnum)
char result[BUFSIZ];
cc = read(fds[0], result, sizeof(result));
if (cc > 0)
Buf_AddBytes(buf, (size_t)cc, (Byte *)result);
Buf_AddBytes(buf, cc, (Byte *)result);
}
while (cc > 0 || (cc == -1 && errno == EINTR));
@ -1506,10 +1503,10 @@ Cmd_Exec(const char *cmd, const char **errnum)
while(((pid = waitpid(cpid, &status, 0)) != cpid) && (pid >= 0))
continue;
res = (char *)Buf_GetAll(buf, &len);
res = (char *)Buf_GetAll(buf, &cc);
Buf_Destroy(buf, FALSE);
if (len == 0)
if (cc == 0)
*errnum = "Couldn't read shell's output for \"%s\"";
if (status)
@ -1519,10 +1516,10 @@ Cmd_Exec(const char *cmd, const char **errnum)
* Null-terminate the result, convert newlines to spaces and
* install it in the variable.
*/
res[len] = '\0';
cp = &res[len];
res[cc] = '\0';
cp = &res[cc];
if (len > 0 && *--cp == '\n') {
if (cc > 0 && *--cp == '\n') {
/*
* A final newline is just stripped
*/
@ -1802,14 +1799,13 @@ usage(void)
}
#ifdef notdef
int
PrintAddr(ClientData a, ClientData b)
{
printf("%lx ", (unsigned long) a);
return b ? 0 : 0;
}
#endif
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.c,v 1.75 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: make.c,v 1.76 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: make.c,v 1.75 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: make.c,v 1.76 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: make.c,v 1.75 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: make.c,v 1.76 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -860,7 +860,6 @@ Make_Update(GNode *cgn)
*-----------------------------------------------------------------------
*/
static int
/*ARGSUSED*/
MakeUnmark(ClientData cgnp, ClientData pgnp __unused)
{
GNode *cgn = (GNode *)cgnp;
@ -995,7 +994,6 @@ Make_DoAllVar(GNode *gn)
*/
static int
/*ARGSUSED*/
MakeCheckOrder(ClientData v_bn, ClientData ignore __unused)
{
GNode *bn = v_bn;

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.73 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: make.h,v 1.74 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -154,7 +154,7 @@ typedef struct GNode {
char *name; /* The target's name */
char *uname; /* The unexpanded name of a .USE node */
char *path; /* The full pathname of the file */
unsigned int type; /* Its type (see the OP flags, below) */
int type; /* Its type (see the OP flags, below) */
int flags;
#define REMAKE 0x1 /* this target needs to be (re)made */
@ -210,7 +210,7 @@ typedef struct GNode {
* Suff_FindDeps and opaque to everyone
* but the Suff module) */
const char *fname; /* filename where the GNode got defined */
size_t lineno; /* line number where the GNode got defined */
int lineno; /* line number where the GNode got defined */
} GNode;
/*
@ -460,7 +460,7 @@ Boolean Main_SetObjdir(const char *);
} __d; \
__d.__cp = ptr, __d.__p; })
#else
#define UNCONST(ptr) (void *)(intptr_t)(ptr)
#define UNCONST(ptr) (void *)(ptr)
#endif
#ifndef MIN

View File

@ -1,4 +1,4 @@
/* $NetBSD: nonints.h,v 1.47 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: nonints.h,v 1.48 2008/02/15 21:29:50 christos Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -144,11 +144,11 @@ Lst Parse_MainName(void);
/* str.c */
char *str_concat(const char *, const char *, int);
char **brk_string(const char *, size_t *, Boolean, char **);
char **brk_string(const char *, int *, Boolean, char **);
char *Str_FindSubstring(const char *, const char *);
int Str_Match(const char *, const char *);
char *Str_SYSVMatch(const char *, const char *, size_t *);
void Str_SYSVSubst(Buffer, char *, char *, size_t);
char *Str_SYSVMatch(const char *, const char *, int *len);
void Str_SYSVSubst(Buffer, char *, char *, int);
/* suff.c */
void Suff_ClearSuffixes(void);
@ -181,7 +181,7 @@ void Targ_SetMain(GNode *);
int Targ_PrintCmd(ClientData, ClientData);
int Targ_PrintNode(ClientData, ClientData);
char *Targ_FmtTime(time_t);
void Targ_PrintType(unsigned int);
void Targ_PrintType(int);
void Targ_PrintGraph(int);
void Targ_Propagate(void);
void Targ_Propagate_Wait(void);
@ -192,7 +192,7 @@ void Var_Set(const char *, const char *, GNode *, int);
void Var_Append(const char *, const char *, GNode *);
Boolean Var_Exists(const char *, GNode *);
char *Var_Value(const char *, GNode *, char **);
char *Var_Parse(const char *, GNode *, Boolean, size_t *, void **);
char *Var_Parse(const char *, GNode *, Boolean, int *, void **);
char *Var_Subst(const char *, const char *, GNode *, Boolean);
char *Var_GetTail(const char *);
char *Var_GetHead(const char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.144 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: parse.c,v 1.145 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: parse.c,v 1.144 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: parse.c,v 1.145 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: parse.c,v 1.144 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: parse.c,v 1.145 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -156,13 +156,13 @@ static GNode *mainNode; /* The main target to create. This is the
* line in the first makefile */
typedef struct IFile {
const char *fname; /* name of file */
size_t lineno; /* line number in file */
int lineno; /* line number in file */
int fd; /* the open file */
size_t cond_depth; /* 'if' nesting when file opened */
int cond_depth; /* 'if' nesting when file opened */
char *P_str; /* point to base of string buffer */
char *P_ptr; /* point to next char of string buffer */
char *P_end; /* point to the end of string buffer */
size_t P_buflen; /* current size of file buffer */
int P_buflen; /* current size of file buffer */
} IFile;
#define IFILE_BUFLEN 0x8000
@ -867,10 +867,11 @@ ParseDoDependency(char *line)
* no errors in this, as they would have been discovered
* in the initial Var_Subst and we wouldn't be here.
*/
size_t length;
int length;
void *freeIt;
char *result;
Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt);
result = Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt);
if (freeIt)
free(freeIt);
cp += length-1;
@ -1794,7 +1795,7 @@ Parse_include_file(char *file, Boolean isSystem, int silent)
char *suff;
Lst suffPath = NILLST;
if ((suff = strrchr(file, '.')) != NULL) {
if ((suff = strrchr(file, '.'))) {
suffPath = Suff_GetPath(suff);
if (suffPath != NILLST) {
fullname = Dir_FindFile(file, suffPath);
@ -1908,7 +1909,7 @@ ParseSetParseFile(const char *filename)
{
char *slash;
char *dirname;
size_t len;
int len;
slash = strrchr(filename, '/');
if (slash == NULL) {
@ -1917,7 +1918,7 @@ ParseSetParseFile(const char *filename)
} else {
len = slash - filename;
dirname = emalloc(len + 1);
(void)memcpy(dirname, filename, len);
memcpy(dirname, filename, len);
dirname[len] = 0;
Var_Set(".PARSEDIR", dirname, VAR_GLOBAL, 0);
Var_Set(".PARSEFILE", slash+1, VAR_GLOBAL, 0);
@ -2128,7 +2129,7 @@ ParseEOF(void)
}
if (DEBUG(PARSE))
fprintf(debug_file, "ParseEOF: returning to file %s, line %zu, fd %d\n",
fprintf(debug_file, "ParseEOF: returning to file %s, line %d, fd %d\n",
curFile->fname, curFile->lineno, curFile->fd);
/* Restore the PARSEDIR/PARSEFILE variables */
@ -2150,8 +2151,7 @@ ParseGetLine(int flags, int *length)
char *escaped;
char *comment;
char *tp;
ssize_t len;
int dist;
int len, dist;
/* Loop through blank lines and comment lines */
for (;;) {
@ -2175,7 +2175,7 @@ ParseGetLine(int flags, int *length)
/* Move existing data to (near) start of file buffer */
len = cf->P_end - cf->P_ptr;
tp = cf->P_str + 32;
(void)memmove(tp, cf->P_ptr, (size_t)len);
memmove(tp, cf->P_ptr, len);
dist = cf->P_ptr - tp;
/* Update all pointers to reflect moved data */
ptr -= dist;
@ -2206,7 +2206,7 @@ ParseGetLine(int flags, int *length)
len += IFILE_BUFLEN;
cf->P_buflen += IFILE_BUFLEN;
}
len = read(cf->fd, tp, (size_t)len);
len = read(cf->fd, tp, len);
if (len <= 0) {
if (len < 0) {
Parse_Error(PARSE_FATAL, "Makefile read error: %s",
@ -2456,8 +2456,8 @@ Parse_File(const char *name, int fd)
do {
for (; (line = ParseReadLine()) != NULL; ) {
if (DEBUG(PARSE))
(void)fprintf(debug_file, "ParseReadLine (%zu): '%s'\n",
curFile->lineno, line);
fprintf(debug_file, "ParseReadLine (%d): '%s'\n",
curFile->lineno, line);
if (*line == '.') {
/*
* Lines that begin with the special character are either

View File

@ -1,4 +1,4 @@
/* $NetBSD: str.c,v 1.27 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: str.c,v 1.28 2008/02/15 21:29:50 christos Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: str.c,v 1.27 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: str.c,v 1.28 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
__RCSID("$NetBSD: str.c,v 1.27 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: str.c,v 1.28 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -94,7 +94,7 @@ __RCSID("$NetBSD: str.c,v 1.27 2008/02/14 22:11:20 christos Exp $");
char *
str_concat(const char *s1, const char *s2, int flags)
{
size_t len1, len2;
int len1, len2;
char *result;
/* get the length of both strings */
@ -102,10 +102,10 @@ str_concat(const char *s1, const char *s2, int flags)
len2 = strlen(s2);
/* allocate length plus separator plus EOS */
result = emalloc(len1 + len2 + 2);
result = emalloc((u_int)(len1 + len2 + 2));
/* copy first string into place */
(void)memcpy(result, s1, len1);
memcpy(result, s1, len1);
/* add separator character */
if (flags & STR_ADDSPACE) {
@ -117,7 +117,7 @@ str_concat(const char *s1, const char *s2, int flags)
}
/* copy second string plus EOS into place */
(void)memcpy(result + len1, s2, len2 + 1);
memcpy(result + len1, s2, len2 + 1);
return(result);
}
@ -138,13 +138,13 @@ str_concat(const char *s1, const char *s2, int flags)
* Number of words in *store_argc.
*/
char **
brk_string(const char *str, size_t *store_argc, Boolean expand, char **buffer)
brk_string(const char *str, int *store_argc, Boolean expand, char **buffer)
{
int argc, ch;
char inquote, *start, *t;
const char *p;
size_t len, curlen = 0;
size_t argmax = 50;
int len;
int argmax = 50, curlen = 0;
char **argv = emalloc((argmax + 1) * sizeof(char *));
/* skip leading space chars. */
@ -419,7 +419,7 @@ thisCharOK: ++pattern;
*-----------------------------------------------------------------------
*/
char *
Str_SYSVMatch(const char *word, const char *pattern, size_t *len)
Str_SYSVMatch(const char *word, const char *pattern, int *len)
{
const char *p = pattern;
const char *w = word;
@ -476,13 +476,13 @@ Str_SYSVMatch(const char *word, const char *pattern, size_t *len)
*-----------------------------------------------------------------------
*/
void
Str_SYSVSubst(Buffer buf, char *pat, char *src, size_t len)
Str_SYSVSubst(Buffer buf, char *pat, char *src, int len)
{
char *m;
if ((m = strchr(pat, '%')) != NULL) {
/* Copy the prefix */
Buf_AddBytes(buf, (size_t)(m - pat), (Byte *)pat);
Buf_AddBytes(buf, m - pat, (Byte *)pat);
/* skip the % */
pat = m + 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.62 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: suff.c,v 1.63 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: suff.c,v 1.62 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: suff.c,v 1.63 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
__RCSID("$NetBSD: suff.c,v 1.62 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: suff.c,v 1.63 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -1412,7 +1412,7 @@ SuffFindCmds(Src *targ, Lst slst)
LstNode ln; /* General-purpose list node */
GNode *t, /* Target GNode */
*s; /* Source GNode */
size_t prefLen;/* The length of the defined prefix */
int prefLen;/* The length of the defined prefix */
Suff *suff; /* Suffix on matching beastie */
Src *ret; /* Return value */
char *cp;
@ -1594,7 +1594,7 @@ SuffExpandChildren(LstNode cln, GNode *pgn)
* to find the end so we can skip over it.
*/
char *junk;
size_t len;
int len;
void *freeIt;
junk = Var_Parse(cp, pgn, TRUE, &len, &freeIt);
@ -2067,7 +2067,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
ln = Lst_FindFrom(sufflist, ln, &sd, SuffSuffIsSuffixP);
if (ln != NILLNODE) {
size_t prefLen; /* Length of the prefix */
int prefLen; /* Length of the prefix */
/*
* Allocate a Src structure to which things can be transformed
@ -2089,7 +2089,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
*/
prefLen = (eoname - targ->suff->nameLen) - sopref;
targ->pref = emalloc(prefLen + 1);
(void)memcpy(targ->pref, sopref, prefLen);
memcpy(targ->pref, sopref, prefLen);
targ->pref[prefLen] = '\0';
/*
@ -2576,7 +2576,7 @@ Suff_End(void)
static int SuffPrintName(ClientData s, ClientData dummy)
{
(void)fprintf(debug_file, "%s ", ((Suff *)s)->name);
fprintf(debug_file, "%s ", ((Suff *)s)->name);
return (dummy ? 0 : 0);
}
@ -2587,38 +2587,38 @@ SuffPrintSuff(ClientData sp, ClientData dummy)
int flags;
int flag;
(void)fprintf(debug_file, "# `%s' [%d] ", s->name, s->refCount);
fprintf(debug_file, "# `%s' [%d] ", s->name, s->refCount);
flags = s->flags;
if (flags) {
(void)fputs(" (", debug_file);
fputs(" (", debug_file);
while (flags) {
flag = 1 << (ffs(flags) - 1);
flags &= ~flag;
switch (flag) {
case SUFF_NULL:
(void)fprintf(debug_file, "NULL");
fprintf(debug_file, "NULL");
break;
case SUFF_INCLUDE:
(void)fprintf(debug_file, "INCLUDE");
fprintf(debug_file, "INCLUDE");
break;
case SUFF_LIBRARY:
(void)fprintf(debug_file, "LIBRARY");
fprintf(debug_file, "LIBRARY");
break;
}
(void)fputc(flags ? '|' : ')', debug_file);
fputc(flags ? '|' : ')', debug_file);
}
}
(void)fputc('\n', debug_file);
(void)fprintf(debug_file, "#\tTo: ");
fputc('\n', debug_file);
fprintf(debug_file, "#\tTo: ");
Lst_ForEach(s->parents, SuffPrintName, NULL);
(void)fputc('\n', debug_file);
(void)fprintf(debug_file, "#\tFrom: ");
fputc('\n', debug_file);
fprintf(debug_file, "#\tFrom: ");
Lst_ForEach(s->children, SuffPrintName, NULL);
(void)fputc('\n', debug_file);
(void)fprintf(debug_file, "#\tSearch Path: ");
fputc('\n', debug_file);
fprintf(debug_file, "#\tSearch Path: ");
Dir_PrintPath(s->searchPath);
(void)fputc('\n', debug_file);
fputc('\n', debug_file);
return (dummy ? 0 : 0);
}
@ -2627,20 +2627,20 @@ SuffPrintTrans(ClientData tp, ClientData dummy)
{
GNode *t = (GNode *)tp;
(void)fprintf(debug_file, "%-16s: ", t->name);
fprintf(debug_file, "%-16s: ", t->name);
Targ_PrintType(t->type);
(void)fputc('\n', debug_file);
fputc('\n', debug_file);
Lst_ForEach(t->commands, Targ_PrintCmd, NULL);
(void)fputc('\n', debug_file);
fputc('\n', debug_file);
return(dummy ? 0 : 0);
}
void
Suff_PrintAll(void)
{
(void)fprintf(debug_file, "#*** Suffixes:\n");
fprintf(debug_file, "#*** Suffixes:\n");
Lst_ForEach(sufflist, SuffPrintSuff, NULL);
(void)fprintf(debug_file, "#*** Transformations:\n");
fprintf(debug_file, "#*** Transformations:\n");
Lst_ForEach(transforms, SuffPrintTrans, NULL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: targ.c,v 1.51 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: targ.c,v 1.52 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: targ.c,v 1.51 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: targ.c,v 1.52 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: targ.c,v 1.51 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: targ.c,v 1.52 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -511,7 +511,6 @@ Targ_SetMain(GNode *gn)
}
static int
/*ARGSUSED*/
TargPrintName(ClientData gnp, ClientData pflags __unused)
{
GNode *gn = (GNode *)gnp;
@ -567,7 +566,7 @@ Targ_FmtTime(time_t tm)
*-----------------------------------------------------------------------
*/
void
Targ_PrintType(unsigned int type)
Targ_PrintType(int type)
{
int tbit;
@ -577,7 +576,7 @@ Targ_PrintType(unsigned int type)
type &= ~OP_OPMASK;
while (type) {
tbit = 1 << (ffs((int)type) - 1);
tbit = 1 << (ffs(type) - 1);
type &= ~tbit;
switch(tbit) {
@ -717,7 +716,6 @@ Targ_PrintNode(ClientData gnp, ClientData passp)
*-----------------------------------------------------------------------
*/
static int
/*ARGSUSED*/
TargPrintOnlySrc(ClientData gnp, ClientData dummy __unused)
{
GNode *gn = (GNode *)gnp;
@ -791,7 +789,6 @@ Targ_PrintGraph(int pass)
*-----------------------------------------------------------------------
*/
static int
/*ARGSUSED*/
TargPropagateNode(ClientData gnp, ClientData junk __unused)
{
GNode *gn = (GNode *)gnp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trace.c,v 1.8 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: trace.c,v 1.9 2008/02/15 21:29:50 christos Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -38,11 +38,11 @@
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: trace.c,v 1.8 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: trace.c,v 1.9 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: trace.c,v 1.8 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: trace.c,v 1.9 2008/02/15 21:29:50 christos Exp $");
#endif /* not lint */
#endif
@ -101,23 +101,23 @@ Trace_Log(TrEvent event, Job *job)
if (trfile == NULL)
return;
(void)gettimeofday(&rightnow, NULL);
gettimeofday(&rightnow, NULL);
(void)fprintf(trfile, "%ld.%06d %d %s %d %s",
fprintf(trfile, "%ld.%06d %d %s %d %s",
rightnow.tv_sec, (int)rightnow.tv_usec,
jobTokensRunning,
evname[event], trpid, trwd);
if (job != NULL) {
(void)fprintf(trfile, " %s %ld %x %x", job->node->name,
(long)job->pid, job->flags, job->node->type);
fprintf(trfile, " %s %d %x %x", job->node->name,
job->pid, job->flags, job->node->type);
}
(void)fputc('\n', trfile);
(void)fflush(trfile);
fputc('\n', trfile);
fflush(trfile);
}
void
Trace_End(void)
{
if (trfile != NULL)
(void)fclose(trfile);
fclose(trfile);
}

View File

@ -1,15 +1,15 @@
/* $NetBSD: util.c,v 1.43 2008/02/14 22:11:20 christos Exp $ */
/* $NetBSD: util.c,v 1.44 2008/02/15 21:29:50 christos Exp $ */
/*
* Missing stuff from OS's
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: util.c,v 1.43 2008/02/14 22:11:20 christos Exp $";
static char rcsid[] = "$NetBSD: util.c,v 1.44 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: util.c,v 1.43 2008/02/14 22:11:20 christos Exp $");
__RCSID("$NetBSD: util.c,v 1.44 2008/02/15 21:29:50 christos Exp $");
#endif
#endif
@ -181,7 +181,7 @@ char *sys_siglist[] = {
#include <unistd.h>
int
killpg(pid_t pid, int sig)
killpg(int pid, int sig)
{
return kill(-pid, sig);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.126 2008/02/15 02:50:53 christos Exp $ */
/* $NetBSD: var.c,v 1.127 2008/02/15 21:29:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: var.c,v 1.126 2008/02/15 02:50:53 christos Exp $";
static char rcsid[] = "$NetBSD: var.c,v 1.127 2008/02/15 21:29:50 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: var.c,v 1.126 2008/02/15 02:50:53 christos Exp $");
__RCSID("$NetBSD: var.c,v 1.127 2008/02/15 21:29:50 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -235,9 +235,9 @@ typedef struct {
* to VarSYSVMatch() for ":lhs=rhs". */
typedef struct {
const char *lhs; /* String to match */
size_t leftLen; /* Length of string */
int leftLen; /* Length of string */
const char *rhs; /* Replacement string (w/ &'s removed) */
size_t rightLen; /* Length of replacement */
int rightLen; /* Length of replacement */
int flags;
} VarPattern;
@ -245,9 +245,9 @@ typedef struct {
typedef struct {
GNode *ctxt; /* variable context */
char *tvar; /* name of temp var */
size_t tvarLen;
int tvarLen;
char *str; /* string to expand */
size_t strLen;
int strLen;
int errnum; /* errnum for not defined */
} VarLoop_t;
@ -255,7 +255,7 @@ typedef struct {
/* struct passed as ClientData to VarRESubstitute() for ":C///" */
typedef struct {
regex_t re;
size_t nsub;
int nsub;
regmatch_t *matches;
char *replace;
int flags;
@ -296,7 +296,7 @@ static Boolean VarSubstitute(GNode *, Var_Parse_State *,
static Boolean VarLoopExpand(GNode *, Var_Parse_State *,
char *, Boolean, Buffer, ClientData);
static char *VarGetPattern(GNode *, Var_Parse_State *,
int, const char **, int, int *, size_t *,
int, const char **, int, int *, int *,
VarPattern *);
static char *VarQuote(char *);
static char *VarChangeCase(char *, int);
@ -396,7 +396,7 @@ VarFind(const char *name, GNode *ctxt, int flags)
char *env;
if ((env = getenv(name)) != NULL) {
size_t len;
int len;
v = emalloc(sizeof(Var));
v->name = estrdup(name);
@ -477,7 +477,7 @@ static void
VarAdd(const char *name, const char *val, GNode *ctxt)
{
Var *v;
size_t len;
int len;
Hash_Entry *h;
v = emalloc(sizeof(Var));
@ -639,7 +639,7 @@ Var_ExportVars(void)
if (n < sizeof(tmp)) {
char **av;
char *as;
size_t ac;
int ac;
int i;
val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
@ -665,7 +665,7 @@ Var_Export(char *str, int isExport)
char *val;
char **av;
char *as;
size_t ac;
int ac;
int i;
if (isExport && (!str || !str[0])) {
@ -742,7 +742,7 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags)
* here will override anything in a lower context, so there's not much
* point in searching them all just to save a bit of memory...
*/
if ((name = strchr(cp, '$')) != NULL) {
if ((name = strchr(cp, '$'))) {
name = Var_Subst(NULL, cp, ctxt, 0);
} else
name = cp;
@ -817,7 +817,7 @@ Var_Append(const char *name, const char *val, GNode *ctxt)
Hash_Entry *h;
const char *cp = name;
if ((name = strchr(cp, '$')) != NULL) {
if ((name = strchr(cp, '$'))) {
name = Var_Subst(NULL, cp, ctxt, 0);
} else
name = cp;
@ -938,7 +938,6 @@ Var_Value(const char *name, GNode *ctxt, char **frp)
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarHead(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData dummy)
@ -987,7 +986,6 @@ VarHead(GNode *ctx __unused, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarTail(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData dummy)
@ -1030,7 +1028,6 @@ VarTail(GNode *ctx __unused, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarSuffix(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData dummy)
@ -1072,7 +1069,6 @@ VarSuffix(GNode *ctx __unused, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarRoot(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData dummy)
@ -1117,7 +1113,6 @@ VarRoot(GNode *ctx __unused, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData pattern)
@ -1161,7 +1156,7 @@ VarSYSVMatch(GNode *ctx, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData patp)
{
size_t len;
int len;
char *ptr;
VarPattern *pat = (VarPattern *)patp;
char *varexp;
@ -1207,7 +1202,6 @@ VarSYSVMatch(GNode *ctx, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarNoMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData pattern)
@ -1245,7 +1239,6 @@ VarNoMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarSubstitute(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData patternp)
@ -1360,15 +1353,14 @@ VarSubstitute(GNode *ctx __unused, Var_Parse_State *vpstate,
while (!done) {
cp = Str_FindSubstring(word, pattern->lhs);
if (cp != NULL) {
size_t sp = (size_t)(cp - word);
if (addSpace && ((sp + pattern->rightLen) != 0)){
if (addSpace && (((cp - word) + pattern->rightLen) != 0)){
Buf_AddByte(buf, vpstate->varSpace);
addSpace = FALSE;
}
Buf_AddBytes(buf, sp, (const Byte *)word);
Buf_AddBytes(buf, cp-word, (const Byte *)word);
Buf_AddBytes(buf, pattern->rightLen,
(const Byte *)pattern->rhs);
wordLen -= sp + pattern->leftLen;
wordLen -= (cp - word) + pattern->leftLen;
word = cp + pattern->leftLen;
if (wordLen == 0) {
done = TRUE;
@ -1422,7 +1414,7 @@ static void
VarREError(int errnum, regex_t *pat, const char *str)
{
char *errbuf;
size_t errlen;
int errlen;
errlen = regerror(errnum, pat, 0, 0);
errbuf = emalloc(errlen);
@ -1447,7 +1439,6 @@ VarREError(int errnum, regex_t *pat, const char *str)
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
char *word, Boolean addSpace, Buffer buf,
ClientData patternp)
@ -1481,13 +1472,13 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
pat->flags |= VAR_SUB_MATCHED;
if (pat->matches[0].rm_so > 0) {
MAYBE_ADD_SPACE();
Buf_AddBytes(buf, (size_t)pat->matches[0].rm_so, wp);
Buf_AddBytes(buf, pat->matches[0].rm_so, wp);
}
for (rp = pat->replace; *rp; rp++) {
if ((*rp == '\\') && ((rp[1] == '&') || (rp[1] == '\\'))) {
MAYBE_ADD_SPACE();
Buf_AddByte(buf, rp[1]);
Buf_AddByte(buf,rp[1]);
rp++;
}
else if ((*rp == '&') ||
@ -1519,9 +1510,8 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
subbuf = "";
sublen = 0;
} else {
subbuf = wp + (size_t)pat->matches[n].rm_so;
sublen = (size_t)
(pat->matches[n].rm_eo - pat->matches[n].rm_so);
subbuf = wp + pat->matches[n].rm_so;
sublen = pat->matches[n].rm_eo - pat->matches[n].rm_so;
}
if (sublen > 0) {
@ -1533,7 +1523,7 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
Buf_AddByte(buf, *rp);
}
}
wp += (size_t)pat->matches[0].rm_eo;
wp += pat->matches[0].rm_eo;
if (pat->flags & VAR_SUB_GLOBAL) {
flags |= REG_NOTBOL;
if (pat->matches[0].rm_so == 0 && pat->matches[0].rm_eo == 0) {
@ -1552,15 +1542,15 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
break;
default:
VarREError(xrv, &pat->re, "Unexpected regex error");
/* FALLTHROUGH */
/* fall through */
case REG_NOMATCH:
if (*wp) {
MAYBE_ADD_SPACE();
Buf_AddBytes(buf, strlen(wp), wp);
Buf_AddBytes(buf,strlen(wp),wp);
}
break;
}
return addSpace || added;
return(addSpace||added);
}
#endif
@ -1589,7 +1579,6 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarLoopExpand(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
char *word, Boolean addSpace, Buffer buf,
ClientData loopp)
@ -1633,7 +1622,6 @@ VarLoopExpand(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
*-----------------------------------------------------------------------
*/
static char *
/*ARGSUSED*/
VarSelectWords(GNode *ctx __unused, Var_Parse_State *vpstate,
const char *str, VarSelectWords_t *seldata)
{
@ -1643,8 +1631,7 @@ VarSelectWords(GNode *ctx __unused, Var_Parse_State *vpstate,
* word */
char **av; /* word list */
char *as; /* word list memory */
size_t ac;
int i;
int ac, i;
int start, end, step;
buf = Buf_Init(0);
@ -1738,7 +1725,7 @@ VarModify(GNode *ctx, Var_Parse_State *vpstate,
* word */
char **av; /* word list */
char *as; /* word list memory */
size_t ac, i;
int ac, i;
buf = Buf_Init(0);
addSpace = FALSE;
@ -1798,7 +1785,7 @@ VarOrder(const char *str, const char otype)
Buffer buf; /* Buffer for the new string */
char **av; /* word list [first word does not count] */
char *as; /* word list memory */
size_t ac, i;
int ac, i;
buf = Buf_Init(0);
@ -1869,7 +1856,7 @@ VarUniq(const char *str)
Buffer buf; /* Buffer for new string */
char **av; /* List of words to affect */
char *as; /* Word list memory */
size_t ac, i, j;
int ac, i, j;
buf = Buf_Init(0);
av = brk_string(str, &ac, FALSE, &as);
@ -1920,14 +1907,13 @@ VarUniq(const char *str)
*-----------------------------------------------------------------------
*/
static char *
/*ARGSUSED*/
VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
int errnum, const char **tstr, int delim, int *flags,
size_t *length, VarPattern *pattern)
int *length, VarPattern *pattern)
{
const char *cp;
Buffer buf = Buf_Init(0);
size_t junk;
int junk;
if (length == NULL)
length = &junk;
@ -1958,7 +1944,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
} else {
if (flags == NULL || (*flags & VAR_NOSUBST) == 0) {
char *cp2;
size_t len;
int len;
void *freeIt;
/*
@ -1992,7 +1978,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
--depth;
}
}
Buf_AddBytes(buf, (size_t)(cp2 - cp), (const Byte *)cp);
Buf_AddBytes(buf, cp2 - cp, (const Byte *)cp);
cp = --cp2;
} else
Buf_AddByte(buf, (Byte)*cp);
@ -2185,7 +2171,7 @@ static char *
ApplyModifiers(char *nstr, const char *tstr,
int startc, int endc,
Var *v, GNode *ctxt, Boolean errnum,
size_t *lengthPtr, void **freePtr)
int *lengthPtr, void **freePtr)
{
const char *start;
const char *cp; /* Secondary pointer into str (place marker
@ -2212,19 +2198,19 @@ ApplyModifiers(char *nstr, const char *tstr,
*/
void *freeIt;
char *rval;
size_t rlen;
int rlen;
rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
if (DEBUG(VAR)) {
fprintf(debug_file, "Got '%s' from '%.*s'%.*s\n",
rval, (int)rlen, tstr, (int)rlen, tstr + rlen);
rval, rlen, tstr, rlen, tstr + rlen);
}
tstr += rlen;
if (rval != NULL && *rval) {
size_t used;
int used;
nstr = ApplyModifiers(nstr, rval,
0, 0,
@ -2400,7 +2386,7 @@ ApplyModifiers(char *nstr, const char *tstr,
* variable substitution and recurse.
*/
char *cp2;
size_t len;
int len;
void *freeIt;
cp2 = Var_Parse(cp, ctxt, errnum, &len, &freeIt);
@ -2526,21 +2512,21 @@ ApplyModifiers(char *nstr, const char *tstr,
* (which should never be needed) and a '\0'
* string terminator.
*/
size_t newStrSize =
int newStrSize =
(sizeof(int) * CHAR_BIT + 2) / 3 + 2;
newStr = emalloc(newStrSize);
if (parsestate.oneBigWord) {
(void)strncpy(newStr, "1", newStrSize);
strncpy(newStr, "1", newStrSize);
} else {
/* XXX: brk_string() is a rather expensive
* way of counting words. */
char **av;
char *as;
size_t ac;
int ac;
av = brk_string(nstr, &ac, FALSE, &as);
(void)snprintf(newStr, newStrSize, "%zu", ac);
snprintf(newStr, newStrSize, "%d", ac);
free(as);
free(av);
}
@ -2660,7 +2646,7 @@ ApplyModifiers(char *nstr, const char *tstr,
if (isdigit((unsigned char)tstr[3])) {
char *ep;
parsestate.varSpace = (Byte)
parsestate.varSpace =
strtoul(&tstr[3], &ep, 0);
if (*ep != ':' && *ep != endc)
goto bad_modifier;
@ -2775,7 +2761,7 @@ ApplyModifiers(char *nstr, const char *tstr,
* cp - tstr takes the null byte into account) and
* compress the pattern into the space.
*/
pattern = emalloc((size_t)(cp - tstr));
pattern = emalloc(cp - tstr);
for (cp2 = pattern, cp = tstr + 1;
cp < endpat;
cp++, cp2++)
@ -2793,7 +2779,7 @@ ApplyModifiers(char *nstr, const char *tstr,
* Either Var_Subst or VarModify will need a
* nul-terminated string soon, so construct one now.
*/
pattern = estrndup(tstr + 1, (size_t)(endpat - (tstr + 1)));
pattern = estrndup(tstr+1, endpat - (tstr + 1));
copy = TRUE;
}
if (strchr(pattern, '$') != NULL) {
@ -3229,7 +3215,7 @@ ApplyModifiers(char *nstr, const char *tstr,
*/
/* coverity[+alloc : arg-*4] */
char *
Var_Parse(const char *str, GNode *ctxt, Boolean errnum, size_t *lengthPtr,
Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
void **freePtr)
{
const char *tstr; /* Pointer into str */
@ -3239,7 +3225,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, size_t *lengthPtr,
* or braces */
char startc=0; /* Starting character when variable in parens
* or braces */
size_t vlen; /* Length of variable name */
int vlen; /* Length of variable name */
const char *start; /* Points to original start of str */
char *nstr; /* New string, used during expansion */
Boolean dynamic; /* TRUE if the variable is local and we're
@ -3320,7 +3306,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, size_t *lengthPtr,
* A variable inside a variable, expand
*/
if (*tstr == '$') {
size_t rlen;
int rlen;
void *freeIt;
char *rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
if (rval != NULL) {
@ -3445,7 +3431,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, size_t *lengthPtr,
isupper((unsigned char) str[1]) &&
((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)))
{
size_t len;
int len;
len = vlen - 1;
if ((strncmp(str, ".TARGET", len) == 0) ||
@ -3511,7 +3497,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, size_t *lengthPtr,
v->flags &= ~VAR_IN_USE;
if ((nstr != NULL) && haveModifier) {
size_t used;
int used;
/*
* Skip initial colon.
*/
@ -3591,7 +3577,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
{
Buffer buf; /* Buffer for forming things */
char *val; /* Value to substitute for a variable */
size_t length; /* Length of the variable invocation */
int length; /* Length of the variable invocation */
Boolean trailingBslash; /* variable ends in \ */
void *freeIt = NULL; /* Set if it should be freed */
static Boolean errorReported; /* Set true if an error has already
@ -3623,7 +3609,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
for (cp = str++; *str != '$' && *str != '\0'; str++)
continue;
Buf_AddBytes(buf, (size_t)(str - cp), (const Byte *)cp);
Buf_AddBytes(buf, str - cp, (const Byte *)cp);
} else {
if (var != NULL) {
int expand;
@ -3659,13 +3645,12 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
* the nested one
*/
if (*p == '$') {
Buf_AddBytes(buf, (size_t)(p - str),
(const Byte *)str);
Buf_AddBytes(buf, p - str, (const Byte *)str);
str = p;
continue;
}
if (strncmp(var, str + 2, (size_t)(p - str - 2)) != 0 ||
if (strncmp(var, str + 2, p - str - 2) != 0 ||
var[p - str - 2] != '\0') {
/*
* Not the variable we want to expand, scan
@ -3673,8 +3658,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
*/
for (;*p != '$' && *p != '\0'; p++)
continue;
Buf_AddBytes(buf, (size_t)(p - str),
(const Byte *)str);
Buf_AddBytes(buf, p - str, (const Byte *)str);
str = p;
expand = FALSE;
}
@ -3712,7 +3696,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
*/
if (!errorReported) {
Parse_Error(PARSE_FATAL,
"Undefined variable \"%.*s\"", (int)length, str);
"Undefined variable \"%.*s\"",length,str);
}
str += length;
errorReported = TRUE;