Style: remove a lot of unnecessary casts, add some and spell the null

pointer constant as NULL.

Checked by: diff -r on the object files before and after
This commit is contained in:
Hartmut Brandt 2004-12-01 10:29:20 +00:00
parent d672e07541
commit d21474cec4
17 changed files with 498 additions and 508 deletions

View File

@ -138,7 +138,7 @@ static int ArchSVR4Entry(Arch *, char *, size_t, FILE *);
static void
ArchFree(void *ap)
{
Arch *a = (Arch *)ap;
Arch *a = ap;
Hash_Search search;
Hash_Entry *entry;
@ -345,7 +345,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
Dir_Expand(memName, dirSearchPath, members);
while (!Lst_IsEmpty(members)) {
member = (char *)Lst_DeQueue(members);
member = Lst_DeQueue(members);
nsz = strlen(libName) + strlen(member) + 3;
if (nsz > sz) {
sz = nsz * 2;
@ -389,7 +389,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
* provided list.
*/
gn->type |= OP_ARCHV;
Lst_AtEnd(nodeLst, (void *)gn);
Lst_AtEnd(nodeLst, gn);
}
}
if (doSubst) {
@ -483,9 +483,9 @@ ArchStatMember(char *archive, char *member, Boolean hash)
if ((cp != NULL) && (strcmp(member, RANLIBMAG) != 0))
member = cp + 1;
ln = Lst_Find(archives, (void *)archive, ArchFindArchive);
ln = Lst_Find(archives, archive, ArchFindArchive);
if (ln != NULL) {
ar = (Arch *)Lst_Datum(ln);
ar = Lst_Datum(ln);
he = Hash_FindEntry(&ar->members, member);
@ -502,7 +502,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
copy[AR_MAX_NAME_LEN] = '\0';
}
if ((he = Hash_FindEntry(&ar->members, copy)) != NULL)
return ((struct ar_hdr *)Hash_GetValue(he));
return (Hash_GetValue(he));
return (NULL);
}
}
@ -546,14 +546,14 @@ ArchStatMember(char *archive, char *member, Boolean hash)
return (NULL);
}
ar = (Arch *)emalloc(sizeof(Arch));
ar = emalloc(sizeof(Arch));
ar->name = estrdup(archive);
ar->fnametab = NULL;
ar->fnamesize = 0;
Hash_InitTable(&ar->members, -1);
memName[AR_MAX_NAME_LEN] = '\0';
while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
while (fread(&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
@ -625,16 +625,15 @@ ArchStatMember(char *archive, char *member, Boolean hash)
#endif
he = Hash_CreateEntry(&ar->members, memName, NULL);
Hash_SetValue(he, (void *)emalloc (sizeof(struct ar_hdr)));
memcpy(Hash_GetValue(he), &arh,
sizeof(struct ar_hdr));
Hash_SetValue(he, emalloc(sizeof(struct ar_hdr)));
memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));
}
fseek(arch, (size + 1) & ~1, SEEK_CUR);
}
fclose(arch);
Lst_AtEnd(archives, (void *)ar);
Lst_AtEnd(archives, ar);
/*
* Now that the archive has been read and cached, we can look into
@ -643,7 +642,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
he = Hash_FindEntry(&ar->members, member);
if (he != NULL) {
return ((struct ar_hdr *)Hash_GetValue (he));
return (Hash_GetValue (he));
} else {
return (NULL);
}
@ -802,7 +801,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
tlen = sizeof(arhPtr->ar_name);
}
while (fread((char *)arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) {
while (fread(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
@ -921,7 +920,7 @@ Arch_Touch(GNode *gn)
snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long)now);
if (arch != NULL) {
fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch);
fwrite(&arh, sizeof(struct ar_hdr), 1, arch);
fclose(arch);
}
}
@ -953,7 +952,7 @@ Arch_TouchLib(GNode *gn)
snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
if (arch != NULL) {
fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch);
fwrite(&arh, sizeof(struct ar_hdr), 1, arch);
fclose(arch);
times.actime = times.modtime = now;
@ -1027,7 +1026,7 @@ Arch_MemMTime(GNode *gn)
return (0);
}
while ((ln = Lst_Next(gn->parents)) != NULL) {
pgn = (GNode *)Lst_Datum(ln);
pgn = Lst_Datum(ln);
if (pgn->type & OP_ARCHV) {
/*
@ -1086,7 +1085,7 @@ Arch_FindLib(GNode *gn, Lst path)
size_t sz;
sz = strlen(gn->name) + 4;
libName = (char *)emalloc(sz);
libName = emalloc(sz);
snprintf(libName, sz, "lib%s.a", &gn->name[2]);
gn->path = Dir_FindFile(libName, path);
@ -1193,6 +1192,7 @@ Arch_LibOODate(GNode *gn)
void
Arch_Init(void)
{
archives = Lst_Init(FALSE);
}
@ -1212,5 +1212,6 @@ Arch_Init(void)
void
Arch_End(void)
{
Lst_Destroy(archives, ArchFree);
}

View File

@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
#define BufExpand(bp,nb) \
if (bp->left < (nb)+1) {\
int newSize = (bp)->size + max((nb) + 1, BUF_ADD_INC); \
Byte *newBuf = (Byte *)erealloc((bp)->buffer, newSize); \
Byte *newBuf = erealloc((bp)->buffer, newSize); \
\
(bp)->inPtr = newBuf + ((bp)->inPtr - (bp)->buffer); \
(bp)->outPtr = newBuf + ((bp)->outPtr - (bp)->buffer);\
@ -94,6 +94,7 @@ __FBSDID("$FreeBSD$");
void
Buf_OvAddByte(Buffer bp, int byte)
{
bp->left = 0;
BufExpand(bp, 1);
@ -170,12 +171,11 @@ Buf_UngetByte(Buffer bp, int byte)
int numBytes = bp->inPtr - bp->outPtr;
Byte *newBuf;
newBuf = (Byte *)emalloc(bp->size + BUF_UNGET_INC);
memcpy((char *)(newBuf+BUF_UNGET_INC), (char *)bp->outPtr,
numBytes + 1);
newBuf = emalloc(bp->size + BUF_UNGET_INC);
memcpy(newBuf + BUF_UNGET_INC, bp->outPtr, numBytes + 1);
bp->outPtr = newBuf + BUF_UNGET_INC;
bp->inPtr = bp->outPtr + numBytes;
free((char *)bp->buffer);
free(bp->buffer);
bp->buffer = newBuf;
bp->size += BUF_UNGET_INC;
bp->left = bp->size - (bp->inPtr - bp->buffer);
@ -211,16 +211,16 @@ Buf_UngetBytes(Buffer bp, int numBytes, Byte *bytesPtr)
Byte *newBuf;
int newBytes = max(numBytes,BUF_UNGET_INC);
newBuf = (Byte *)emalloc (bp->size + newBytes);
memcpy((char *)(newBuf+newBytes), (char *)bp->outPtr, curNumBytes + 1);
newBuf = emalloc(bp->size + newBytes);
memcpy(newBuf + newBytes, bp->outPtr, curNumBytes + 1);
bp->outPtr = newBuf + newBytes;
bp->inPtr = bp->outPtr + curNumBytes;
free((char *)bp->buffer);
free(bp->buffer);
bp->buffer = newBuf;
bp->size += newBytes;
bp->left = bp->size - (bp->inPtr - bp->buffer);
bp->outPtr -= numBytes;
memcpy((char *)bp->outPtr, (char *)bytesPtr, numBytes);
memcpy(bp->outPtr, bytesPtr, numBytes);
}
}
@ -306,7 +306,7 @@ Byte *
Buf_GetAll(Buffer bp, int *numBytesPtr)
{
if (numBytesPtr != (int *)NULL) {
if (numBytesPtr != NULL) {
*numBytesPtr = bp->inPtr - bp->outPtr;
}
@ -356,6 +356,7 @@ Buf_Discard(Buffer bp, int numBytes)
int
Buf_Size(Buffer buf)
{
return (buf->inPtr - buf->outPtr);
}
@ -379,13 +380,13 @@ Buf_Init(int size)
{
Buffer bp; /* New Buffer */
bp = (Buffer)emalloc(sizeof(*bp));
bp = emalloc(sizeof(*bp));
if (size <= 0) {
size = BUF_DEF_SIZE;
}
bp->left = bp->size = size;
bp->buffer = (Byte *)emalloc(size);
bp->buffer = emalloc(size);
bp->inPtr = bp->outPtr = bp->buffer;
*bp->inPtr = 0;
@ -410,9 +411,9 @@ Buf_Destroy(Buffer buf, Boolean freeData)
{
if (freeData) {
free((char *)buf->buffer);
free(buf->buffer);
}
free((char *)buf);
free(buf);
}
/*-

View File

@ -230,8 +230,8 @@ Compat_RunCommand(void *cmdp, void *gnp)
int argc; /* Number of arguments in av or 0 if not
* dynamically allocated */
int internal; /* Various values.. */
char *cmd = (char *)cmdp;
GNode *gn = (GNode *)gnp;
char *cmd = cmdp;
GNode *gn = gnp;
/*
* Avoid clobbered variable warnings by forcing the compiler
@ -245,7 +245,7 @@ Compat_RunCommand(void *cmdp, void *gnp)
errCheck = !(gn->type & OP_IGNORE);
doit = FALSE;
cmdNode = Lst_Member(gn->commands, (void *)cmd);
cmdNode = Lst_Member(gn->commands, cmd);
cmdStart = Var_Subst(NULL, cmd, gn, FALSE);
/*
@ -262,10 +262,10 @@ Compat_RunCommand(void *cmdp, void *gnp)
} else {
cmd = cmdStart;
}
Lst_Replace (cmdNode, (void *)cmdStart);
Lst_Replace (cmdNode, cmdStart);
if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
Lst_AtEnd(ENDNode->commands, (void *)cmdStart);
Lst_AtEnd(ENDNode->commands, cmdStart);
return (0);
} else if (strcmp(cmdStart, "...") == 0) {
gn->type |= OP_SAVE_CMDS;
@ -333,7 +333,7 @@ Compat_RunCommand(void *cmdp, void *gnp)
shargv[0] = shellPath;
shargv[1] = (errCheck ? "-ec" : "-c");
shargv[2] = cmd;
shargv[3] = (char *)NULL;
shargv[3] = NULL;
av = shargv;
argc = 0;
} else if ((internal = shellneed(cmd))) {
@ -351,7 +351,7 @@ Compat_RunCommand(void *cmdp, void *gnp)
shargv[0] = shellPath;
shargv[1] = (errCheck ? "-ec" : "-c");
shargv[2] = cmd;
shargv[3] = (char *)NULL;
shargv[3] = NULL;
av = shargv;
argc = 0;
} else {
@ -464,8 +464,8 @@ Compat_RunCommand(void *cmdp, void *gnp)
static int
CompatMake(void *gnp, void *pgnp)
{
GNode *gn = (GNode *)gnp;
GNode *pgn = (GNode *)pgnp;
GNode *gn = gnp;
GNode *pgn = pgnp;
if (gn->type & OP_USE) {
Make_HandleUse(gn, pgn);
@ -481,7 +481,7 @@ CompatMake(void *gnp, void *pgnp)
gn->make = TRUE;
gn->made = BEINGMADE;
Suff_FindDeps(gn);
Lst_ForEach(gn->children, CompatMake, (void *)gn);
Lst_ForEach(gn->children, CompatMake, gn);
if (!gn->make) {
gn->made = ABORTED;
pgn->make = FALSE;
@ -708,7 +708,7 @@ Compat_Run(Lst targs)
if (!queryFlag) {
gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
if (gn != NULL) {
Lst_ForEach(gn->commands, Compat_RunCommand, (void *)gn);
Lst_ForEach(gn->commands, Compat_RunCommand, gn);
if (gn->made == ERROR) {
printf("\n\nStop.\n");
exit(1);
@ -728,7 +728,7 @@ Compat_Run(Lst targs)
*/
errors = 0;
while (!Lst_IsEmpty(targs)) {
gn = (GNode *)Lst_DeQueue(targs);
gn = Lst_DeQueue(targs);
CompatMake(gn, gn);
if (gn->made == UPTODATE) {
@ -743,6 +743,6 @@ Compat_Run(Lst targs)
* If the user has defined a .END target, run its commands.
*/
if (errors == 0) {
Lst_ForEach(ENDNode->commands, Compat_RunCommand, (void *)gn);
Lst_ForEach(ENDNode->commands, Compat_RunCommand, gn);
}
}

View File

@ -157,6 +157,7 @@ static Boolean skipLine = FALSE; /* Whether the parse module is skipping
static void
CondPushBack(Token t)
{
condPushBack = t;
}
@ -213,7 +214,7 @@ CondGetArg(char **linePtr, char **argPtr, char *func, Boolean parens)
*/
buf = Buf_Init(16);
while ((strchr(" \t)&|", *cp) == (char *)NULL) && (*cp != '\0')) {
while ((strchr(" \t)&|", *cp) == NULL) && (*cp != '\0')) {
if (*cp == '$') {
/*
* Parse the variable spec and install it as part of the argument
@ -281,7 +282,7 @@ CondDoDefined(int argLen, char *arg)
Boolean result;
arg[argLen] = '\0';
if (Var_Value(arg, VAR_CMD, &p1) != (char *)NULL) {
if (Var_Value(arg, VAR_CMD, &p1) != NULL) {
result = TRUE;
} else {
result = FALSE;
@ -308,6 +309,7 @@ CondDoDefined(int argLen, char *arg)
static int
CondStrMatch(void *string, void *pattern)
{
return (!Str_Match((char *)string, (char *)pattern));
}
@ -331,7 +333,7 @@ CondDoMake(int argLen, char *arg)
Boolean result;
arg[argLen] = '\0';
if (Lst_Find(create, (void *)arg, CondStrMatch) == NULL) {
if (Lst_Find(create, arg, CondStrMatch) == NULL) {
result = FALSE;
} else {
result = TRUE;
@ -362,7 +364,7 @@ CondDoExists(int argLen, char *arg)
arg[argLen] = '\0';
path = Dir_FindFile(arg, dirSearchPath);
if (path != (char *)NULL) {
if (path != NULL) {
result = TRUE;
free(path);
} else {
@ -436,7 +438,7 @@ CondCvtArg(char *str, double *value)
x = 10 + *str - isupper((unsigned char)*str) ? 'A' : 'a';
else {
*value = (double)i;
return str;
return (str);
}
i = (i << 4) + x;
}
@ -639,7 +641,7 @@ CondToken(Boolean doEval)
Buf_AddByte(buf, (Byte)0);
string = (char *)Buf_GetAll(buf, (int *)0);
string = (char *)Buf_GetAll(buf, (int *)NULL);
Buf_Destroy(buf, FALSE);
DEBUGF(COND, ("lhs = \"%s\", rhs = \"%s\", op = %.2s\n",
@ -1095,13 +1097,13 @@ Cond_Eval(char *line)
* Figure out what sort of conditional it is -- what its default
* function is, etc. -- by looking in the table of valid "ifs"
*/
for (ifp = ifs; ifp->form != (char *)0; ifp++) {
for (ifp = ifs; ifp->form != NULL; ifp++) {
if (strncmp(ifp->form, line, ifp->formlen) == 0) {
break;
}
}
if (ifp->form == (char *)0) {
if (ifp->form == NULL) {
/*
* Nothing fit. If the first word on the line is actually
* "else", it's a valid conditional whose value is the inverse

View File

@ -263,7 +263,7 @@ Dir_End(void)
{
dot->refCount -= 1;
Dir_Destroy((void *) dot);
Dir_Destroy(dot);
Dir_ClearPath(dirSearchPath);
Lst_Destroy(dirSearchPath, NOFREE);
Dir_ClearPath(openDirectories);
@ -288,6 +288,7 @@ Dir_End(void)
static int
DirFindName(void *p, void *dname)
{
return (strcmp(((Path *)p)->name, (char *)dname));
}
@ -363,7 +364,7 @@ DirMatchFiles(char *pattern, Path *p, Lst expansions)
isDot = (*p->name == '.' && p->name[1] == '\0');
for (entry = Hash_EnumFirst(&p->files, &search);
entry != (Hash_Entry *)NULL;
entry != NULL;
entry = Hash_EnumNext(&search))
{
/*
@ -522,7 +523,7 @@ DirExpandInt(char *word, Lst path, Lst expansions)
if (Lst_Open(path) == SUCCESS) {
while ((ln = Lst_Next(path)) != NULL) {
p = (Path *)Lst_Datum(ln);
p = Lst_Datum(ln);
DirMatchFiles(word, p, expansions);
}
Lst_Close(path);
@ -620,7 +621,7 @@ Dir_Expand(char *word, Lst path, Lst expansions)
* looking for Etc, it won't be found. Ah well.
* Probably not important.
*/
if (dirpath != (char *)NULL) {
if (dirpath != NULL) {
char *dp = &dirpath[strlen(dirpath) - 1];
if (*dp == '/')
*dp = '\0';
@ -654,7 +655,7 @@ Dir_Expand(char *word, Lst path, Lst expansions)
}
}
if (DEBUG(DIR)) {
Lst_ForEach(expansions, DirPrintWord, (void *) 0);
Lst_ForEach(expansions, DirPrintWord, (void *)NULL);
DEBUGF(DIR, ("\n"));
}
}
@ -711,7 +712,7 @@ Dir_FindFile(char *name, Lst path)
* (fish.c) and what pmake finds (./fish.c).
*/
if ((!hasSlash || (cp - name == 2 && *name == '.')) &&
(Hash_FindEntry(&dot->files, cp) != (Hash_Entry *)NULL)) {
(Hash_FindEntry(&dot->files, cp) != NULL)) {
DEBUGF(DIR, ("in '.'\n"));
hits += 1;
dot->hits += 1;
@ -721,7 +722,7 @@ Dir_FindFile(char *name, Lst path)
if (Lst_Open(path) == FAILURE) {
DEBUGF(DIR, ("couldn't open path, file not found\n"));
misses += 1;
return ((char *)NULL);
return (NULL);
}
/*
@ -733,9 +734,9 @@ Dir_FindFile(char *name, Lst path)
* we go on to phase two...
*/
while ((ln = Lst_Next(path)) != NULL) {
p = (Path *)Lst_Datum (ln);
p = Lst_Datum (ln);
DEBUGF(DIR, ("%s...", p->name));
if (Hash_FindEntry(&p->files, cp) != (Hash_Entry *)NULL) {
if (Hash_FindEntry(&p->files, cp) != NULL) {
DEBUGF(DIR, ("here..."));
if (hasSlash) {
/*
@ -778,7 +779,7 @@ Dir_FindFile(char *name, Lst path)
return (estrdup(name));
} else {
DEBUGF(DIR, ("must be here but isn't -- returning NULL\n"));
return ((char *)NULL);
return (NULL);
}
}
}
@ -799,16 +800,16 @@ Dir_FindFile(char *name, Lst path)
if (!hasSlash) {
DEBUGF(DIR, ("failed.\n"));
misses += 1;
return ((char *)NULL);
return (NULL);
}
if (*name != '/') {
Boolean checkedDot = FALSE;
DEBUGF(DIR, ("failed. Trying subdirectories..."));
Lst_Open(path);
Lst_Open(path);
while ((ln = Lst_Next(path)) != NULL) {
p = (Path *)Lst_Datum(ln);
p = Lst_Datum(ln);
if (p != dot) {
file = str_concat(p->name, name, STR_ADDSLASH);
} else {
@ -845,9 +846,8 @@ Dir_FindFile(char *name, Lst path)
* to fetch it again.
*/
DEBUGF(DIR, ("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), file));
entry = Hash_CreateEntry(&mtimes, (char *)file,
(Boolean *)NULL);
Hash_SetValue(entry, (long)stb.st_mtime);
entry = Hash_CreateEntry(&mtimes, file, (Boolean *)NULL);
Hash_SetValue(entry, (void *)(long)stb.st_mtime);
nearmisses += 1;
return (file);
} else {
@ -893,32 +893,32 @@ Dir_FindFile(char *name, Lst path)
bigmisses += 1;
ln = Lst_Last(path);
if (ln == NULL) {
return ((char *)NULL);
return (NULL);
} else {
p = (Path *)Lst_Datum (ln);
p = Lst_Datum(ln);
}
if (Hash_FindEntry(&p->files, cp) != (Hash_Entry *)NULL) {
if (Hash_FindEntry(&p->files, cp) != NULL) {
return (estrdup(name));
} else {
return ((char *)NULL);
return (NULL);
}
#else /* !notdef */
DEBUGF(DIR, ("Looking for \"%s\"...", name));
bigmisses += 1;
entry = Hash_FindEntry(&mtimes, name);
if (entry != (Hash_Entry *)NULL) {
if (entry != NULL) {
DEBUGF(DIR, ("got it (in mtime cache)\n"));
return (estrdup(name));
} else if (stat (name, &stb) == 0) {
entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL);
DEBUGF(DIR, ("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), name));
Hash_SetValue(entry, (long)stb.st_mtime);
Hash_SetValue(entry, (void *)(long)stb.st_mtime);
return (estrdup(name));
} else {
DEBUGF(DIR, ("failed. Returning NULL\n"));
return ((char *)NULL);
return (NULL);
}
#endif /* notdef */
}
@ -947,18 +947,18 @@ Dir_MTime(GNode *gn)
if (gn->type & OP_ARCHV) {
return (Arch_MTime(gn));
} else if (gn->path == (char *)NULL) {
} else if (gn->path == NULL) {
fullName = Dir_FindFile(gn->name, dirSearchPath);
} else {
fullName = gn->path;
}
if (fullName == (char *)NULL) {
if (fullName == NULL) {
fullName = estrdup(gn->name);
}
entry = Hash_FindEntry(&mtimes, fullName);
if (entry != (Hash_Entry *)NULL) {
if (entry != NULL) {
/*
* Only do this once -- the second time folks are checking to
* see if the file was actually updated, so we need to actually go
@ -1008,24 +1008,24 @@ Dir_AddDir(Lst path, char *name)
DIR *d; /* for reading directory */
struct dirent *dp; /* entry in directory */
ln = Lst_Find(openDirectories, (void *)name, DirFindName);
ln = Lst_Find(openDirectories, name, DirFindName);
if (ln != NULL) {
p = (Path *)Lst_Datum(ln);
if (Lst_Member(path, (void *)p) == NULL) {
p = Lst_Datum(ln);
if (Lst_Member(path, p) == NULL) {
p->refCount += 1;
Lst_AtEnd(path, (void *)p);
Lst_AtEnd(path, p);
}
} else {
DEBUGF(DIR, ("Caching %s...", name));
if ((d = opendir(name)) != (DIR *)NULL) {
p = (Path *) emalloc(sizeof(Path));
p = emalloc(sizeof(Path));
p->name = estrdup(name);
p->hits = 0;
p->refCount = 1;
Hash_InitTable(&p->files, -1);
while ((dp = readdir(d)) != (struct dirent *)NULL) {
while ((dp = readdir(d)) != NULL) {
#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */
/*
* The sun directory library doesn't check for a 0 inode
@ -1050,9 +1050,9 @@ Dir_AddDir(Lst path, char *name)
Hash_CreateEntry(&p->files, dp->d_name, (Boolean *)NULL);
}
closedir(d);
Lst_AtEnd(openDirectories, (void *)p);
Lst_AtEnd(openDirectories, p);
if (path != openDirectories)
Lst_AtEnd(path, (void *)p);
Lst_AtEnd(path, p);
}
DEBUGF(DIR, ("done\n"));
}
@ -1078,7 +1078,7 @@ Dir_CopyDir(void *p)
((Path *)p)->refCount += 1;
return ((void *)p);
return (p);
}
/*-
@ -1110,7 +1110,7 @@ Dir_MakeFlags(char *flag, Lst path)
if (Lst_Open(path) == SUCCESS) {
while ((ln = Lst_Next(path)) != NULL) {
p = (Path *)Lst_Datum(ln);
p = Lst_Datum(ln);
tstr = str_concat(flag, p->name, 0);
str = str_concat(str, tstr, STR_ADDSPACE | STR_DOFREE);
}
@ -1138,13 +1138,14 @@ Dir_MakeFlags(char *flag, Lst path)
void
Dir_Destroy(void *pp)
{
Path *p = (Path *)pp;
Path *p = pp;
p->refCount -= 1;
if (p->refCount == 0) {
LstNode ln;
ln = Lst_Member(openDirectories, (void *)p);
ln = Lst_Member(openDirectories, p);
Lst_Remove(openDirectories, ln);
Hash_DeleteTable(&p->files);
@ -1173,8 +1174,8 @@ Dir_ClearPath(Lst path)
Path *p;
while (!Lst_IsEmpty(path)) {
p = (Path *)Lst_DeQueue(path);
Dir_Destroy((void *) p);
p = Lst_DeQueue(path);
Dir_Destroy(p);
}
}
@ -1200,10 +1201,10 @@ Dir_Concat(Lst path1, Lst path2)
Path *p;
for (ln = Lst_First(path2); ln != NULL; ln = Lst_Succ(ln)) {
p = (Path *)Lst_Datum(ln);
if (Lst_Member(path1, (void *)p) == NULL) {
p = Lst_Datum(ln);
if (Lst_Member(path1, p) == NULL) {
p->refCount += 1;
Lst_AtEnd(path1, (void *)p);
Lst_AtEnd(path1, p);
}
}
}
@ -1223,7 +1224,7 @@ Dir_PrintDirectories(void)
printf("# %-20s referenced\thits\n", "directory");
if (Lst_Open(openDirectories) == SUCCESS) {
while ((ln = Lst_Next(openDirectories)) != NULL) {
p = (Path *)Lst_Datum(ln);
p = Lst_Datum(ln);
printf("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);
}
Lst_Close(openDirectories);
@ -1243,5 +1244,5 @@ void
Dir_PrintPath(Lst path)
{
Lst_ForEach(path, DirPrintDir, (void *)0);
Lst_ForEach(path, DirPrintDir, (void *)NULL);
}

View File

@ -175,7 +175,7 @@ For_Eval(char *line)
#define ADDWORD() \
Buf_AddBytes(buf, ptr - wrd, (Byte *)wrd), \
Buf_AddByte(buf, (Byte)'\0'), \
Lst_AtFront(forLst, (void *)Buf_GetAll(buf, &varlen)), \
Lst_AtFront(forLst, Buf_GetAll(buf, &varlen)), \
Buf_Destroy(buf, FALSE)
for (ptr = sub; *ptr && isspace((unsigned char)*ptr); ptr++)
@ -246,9 +246,10 @@ For_Eval(char *line)
static int
ForExec(void *namep, void *argp)
{
char *name = (char *) namep;
For *arg = (For *) argp;
char *name = namep;
For *arg = argp;
int len;
Var_Set(arg->var, name, VAR_GLOBAL);
DEBUGF(FOR, ("--- %s = %s\n", arg->var, name));
Parse_FromString(Var_Subst(arg->var, (char *)Buf_GetAll(arg->buf, &len),
@ -286,7 +287,7 @@ For_Run(int lineno)
forBuf = NULL;
forLst = NULL;
Lst_ForEach(arg.lst, ForExec, (void *)&arg);
Lst_ForEach(arg.lst, ForExec, &arg);
free(arg.var);
Lst_Destroy(arg.lst, free);

View File

@ -105,7 +105,7 @@ Hash_InitTable(Hash_Table *t, int numBuckets)
t->numEntries = 0;
t->size = i;
t->mask = i - 1;
t->bucketPtr = hp = (struct Hash_Entry **)emalloc(sizeof(*hp) * i);
t->bucketPtr = hp = emalloc(sizeof(*hp) * i);
while (--i >= 0)
*hp++ = NULL;
}
@ -127,7 +127,6 @@ Hash_InitTable(Hash_Table *t, int numBuckets)
*
*---------------------------------------------------------
*/
void
Hash_DeleteTable(Hash_Table *t)
{
@ -137,10 +136,10 @@ Hash_DeleteTable(Hash_Table *t)
for (hp = t->bucketPtr, i = t->size; --i >= 0;) {
for (h = *hp++; h != NULL; h = nexth) {
nexth = h->next;
free((char *)h);
free(h);
}
}
free((char *)t->bucketPtr);
free(t->bucketPtr);
/*
* Set up the hash table to cause memory faults on any future access
@ -166,7 +165,6 @@ Hash_DeleteTable(Hash_Table *t)
*
*---------------------------------------------------------
*/
Hash_Entry *
Hash_FindEntry(Hash_Table *t, char *key)
{
@ -201,7 +199,6 @@ Hash_FindEntry(Hash_Table *t, char *key)
* Memory may be allocated, and the hash buckets may be modified.
*---------------------------------------------------------
*/
Hash_Entry *
Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr)
{
@ -234,7 +231,7 @@ Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr)
*/
if (t->numEntries >= rebuildLimit * t->size)
RebuildTable(t);
e = (Hash_Entry *)emalloc(sizeof(*e) + keylen);
e = emalloc(sizeof(*e) + keylen);
hp = &t->bucketPtr[h & t->mask];
e->next = *hp;
*hp = e;
@ -264,7 +261,6 @@ Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr)
*
*---------------------------------------------------------
*/
void
Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
{
@ -276,7 +272,7 @@ Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
(p = *hp) != NULL; hp = &p->next) {
if (p == e) {
*hp = p->next;
free((char *)p);
free(p);
t->numEntries--;
return;
}
@ -303,7 +299,6 @@ Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
*
*---------------------------------------------------------
*/
Hash_Entry *
Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr)
{
@ -331,7 +326,6 @@ Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr)
*
*---------------------------------------------------------
*/
Hash_Entry *
Hash_EnumNext(Hash_Search *searchPtr)
{
@ -375,7 +369,6 @@ Hash_EnumNext(Hash_Search *searchPtr)
*
*---------------------------------------------------------
*/
static void
RebuildTable(Hash_Table *t)
{
@ -389,7 +382,7 @@ RebuildTable(Hash_Table *t)
i <<= 1;
t->size = i;
t->mask = mask = i - 1;
t->bucketPtr = hp = (struct Hash_Entry **)emalloc(sizeof(*hp) * i);
t->bucketPtr = hp = emalloc(sizeof(*hp) * i);
while (--i >= 0)
*hp++ = NULL;
for (hp = oldhp, i = oldsize; --i >= 0;) {
@ -400,5 +393,5 @@ RebuildTable(Hash_Table *t)
*xp = e;
}
}
free((char *)oldhp);
free(oldhp);
}

View File

@ -99,7 +99,7 @@ typedef struct Hash_Search {
* char *val;
*/
#define Hash_SetValue(h, val) ((h)->clientData = (void *)(val))
#define Hash_SetValue(h, val) ((h)->clientData = (val))
/*
* Hash_Size(n) returns the number of words in an object of n bytes

View File

@ -328,7 +328,7 @@ JobCatchSig(int signo)
static int
JobCondPassSig(void *jobp, void *signop)
{
Job *job = (Job *)jobp;
Job *job = jobp;
int signo = *(int *)signop;
DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n",
@ -362,7 +362,7 @@ JobPassSig(int signo)
sigprocmask(SIG_SETMASK, &nmask, &omask);
DEBUGF(JOB, ("JobPassSig(%d) called.\n", signo));
Lst_ForEach(jobs, JobCondPassSig, (void *)&signo);
Lst_ForEach(jobs, JobCondPassSig, &signo);
/*
* Deal with proper cleanup based on the signal received. We only run
@ -401,7 +401,7 @@ JobPassSig(int signo)
KILL(getpid(), signo);
signo = SIGCONT;
Lst_ForEach(jobs, JobCondPassSig, (void *)&signo);
Lst_ForEach(jobs, JobCondPassSig, &signo);
sigprocmask(SIG_SETMASK, &omask, NULL);
sigprocmask(SIG_SETMASK, &omask, NULL);
@ -426,6 +426,7 @@ JobPassSig(int signo)
static int
JobCmpPid(void *job, void *pid)
{
return (*(int *)pid - ((Job *)job)->pid);
}
@ -471,16 +472,15 @@ JobPrintCommand(void *cmdp, void *jobp)
* command */
char *cmdStart; /* Start of expanded command */
LstNode cmdNode; /* Node for replacing the command */
char *cmd = (char *)cmdp;
Job *job = (Job *)jobp;
char *cmd = cmdp;
Job *job = jobp;
noSpecials = (noExecute && !(job->node->type & OP_MAKE));
if (strcmp(cmd, "...") == 0) {
job->node->type |= OP_SAVE_CMDS;
if ((job->flags & JOB_IGNDOTS) == 0) {
job->tailCmds = Lst_Succ(Lst_Member(job->node->commands,
(void *)cmd));
job->tailCmds = Lst_Succ(Lst_Member(job->node->commands, cmd));
return (1);
}
return (0);
@ -497,9 +497,9 @@ JobPrintCommand(void *cmdp, void *jobp)
* For debugging, we replace each command with the result of expanding
* the variables in the command.
*/
cmdNode = Lst_Member(job->node->commands, (void *)cmd);
cmdNode = Lst_Member(job->node->commands, cmd);
cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE);
Lst_Replace(cmdNode, (void *)cmdStart);
Lst_Replace(cmdNode, cmdStart);
cmdTemplate = "%s\n";
@ -604,7 +604,7 @@ JobPrintCommand(void *cmdp, void *jobp)
* echoOff command. Otherwise we issue it and pretend it was on
* for the whole command...
*/
if (!shutUp && !(job->flags & JOB_SILENT) && commandShell->hasEchoCtl){
if (!shutUp && !(job->flags & JOB_SILENT) && commandShell->hasEchoCtl) {
DBPRINTF("%s\n", commandShell->echoOff);
shutUp = TRUE;
}
@ -634,7 +634,7 @@ static int
JobSaveCommand(void *cmd, void *gn)
{
cmd = (void *)Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE);
cmd = Var_Subst(NULL, cmd, gn, FALSE);
Lst_AtEnd(postCommands->commands, cmd);
return (0);
}
@ -791,7 +791,7 @@ JobFinish(Job *job, int *status)
fprintf(out, "*** Stopped -- signal %d\n",
WSTOPSIG(*status));
job->flags |= JOB_RESUME;
Lst_AtEnd(stoppedJobs, (void *)job);
Lst_AtEnd(stoppedJobs, job);
fflush(out);
return;
} else if (WTERMSIG(*status) == SIGCONT) {
@ -820,7 +820,7 @@ JobFinish(Job *job, int *status)
#endif
}
job->flags &= ~JOB_CONTINUING;
Lst_AtEnd(jobs, (void *)job);
Lst_AtEnd(jobs, job);
nJobs += 1;
DEBUGF(JOB, ("Process %d is continuing locally.\n", job->pid));
if (nJobs == maxJobs) {
@ -886,8 +886,7 @@ JobFinish(Job *job, int *status)
*/
if (job->tailCmds != NULL) {
Lst_ForEachFrom(job->node->commands, job->tailCmds,
JobSaveCommand,
(void *)job->node);
JobSaveCommand, job->node);
}
job->node->made = MADE;
Make_Update(job->node);
@ -938,7 +937,7 @@ Job_Touch(GNode *gn, Boolean silent)
int streamID; /* ID of stream opened to do the touch */
struct utimbuf times; /* Times for utime() call */
if (gn->type & (OP_JOIN|OP_USE|OP_EXEC|OP_OPTIONAL)) {
if (gn->type & (OP_JOIN | OP_USE | OP_EXEC | OP_OPTIONAL)) {
/*
* .JOIN, .USE, .ZEROTIME and .OPTIONAL targets are "virtual" targets
* and, as such, shouldn't really be created.
@ -1197,7 +1196,7 @@ JobExec(Job *job, char **argv)
* Now the job is actually running, add it to the table.
*/
nJobs += 1;
Lst_AtEnd(jobs, (void *)job);
Lst_AtEnd(jobs, job);
if (nJobs == maxJobs) {
jobFull = TRUE;
}
@ -1388,7 +1387,7 @@ JobStart(GNode *gn, int flags, Job *previous)
previous->flags &= ~(JOB_FIRST|JOB_IGNERR|JOB_SILENT);
job = previous;
} else {
job = (Job *)emalloc(sizeof(Job));
job = emalloc(sizeof(Job));
flags |= JOB_FIRST;
}
@ -1469,8 +1468,7 @@ JobStart(GNode *gn, int flags, Job *previous)
LstNode ln = Lst_Next(gn->commands);
if ((ln == NULL) ||
JobPrintCommand((void *)Lst_Datum(ln),
(void *)job))
JobPrintCommand(Lst_Datum(ln), job))
{
noExec = TRUE;
Lst_Close(gn->commands);
@ -1495,7 +1493,7 @@ JobStart(GNode *gn, int flags, Job *previous)
* We can do all the commands at once. hooray for sanity
*/
numCommands = 0;
Lst_ForEach(gn->commands, JobPrintCommand, (void *)job);
Lst_ForEach(gn->commands, JobPrintCommand, job);
/*
* If we didn't print out any commands to the shell script,
@ -1521,7 +1519,7 @@ JobStart(GNode *gn, int flags, Job *previous)
* doesn't do any harm in this case and may do some good.
*/
if (cmdsOK) {
Lst_ForEach(gn->commands, JobPrintCommand, (void *)job);
Lst_ForEach(gn->commands, JobPrintCommand, job);
}
/*
* Don't execute the shell, thank you.
@ -1535,7 +1533,7 @@ JobStart(GNode *gn, int flags, Job *previous)
* up the graph.
*/
job->cmdFILE = stdout;
Job_Touch(gn, job->flags&JOB_SILENT);
Job_Touch(gn, job->flags & JOB_SILENT);
noExec = TRUE;
}
@ -1561,8 +1559,7 @@ JobStart(GNode *gn, int flags, Job *previous)
if (aborting == 0) {
if (job->tailCmds != NULL) {
Lst_ForEachFrom(job->node->commands, job->tailCmds,
JobSaveCommand,
(void *)job->node);
JobSaveCommand, job->node);
}
job->node->made = MADE;
Make_Update(job->node);
@ -1619,7 +1616,7 @@ JobStart(GNode *gn, int flags, Job *previous)
DEBUGF(JOB, ("Can only run job locally.\n"));
job->flags |= JOB_RESTART;
Lst_AtEnd(stoppedJobs, (void *)job);
Lst_AtEnd(stoppedJobs, job);
} else {
if (nJobs >= maxJobs) {
/*
@ -1717,7 +1714,6 @@ JobDoOutput(Job *job, Boolean finish)
FILE *oFILE; /* Stream pointer to shell's output file */
char inLine[132];
if (usePipes) {
/*
* Read as many bytes as will fit in the buffer.
@ -1854,8 +1850,8 @@ JobDoOutput(Job *job, Boolean finish)
*/
oFILE = fopen(job->outFile, "r");
if (oFILE != NULL) {
fprintf(stdout, "Results of making %s:\n", job->node->name);
fflush(stdout);
fprintf(stdout, "Results of making %s:\n", job->node->name);
fflush(stdout);
while (fgets(inLine, sizeof(inLine), oFILE) != NULL) {
char *cp, *endp, *oendp;
@ -1878,8 +1874,8 @@ JobDoOutput(Job *job, Boolean finish)
fflush(stdout);
}
}
fclose(oFILE);
eunlink(job->outFile);
fclose(oFILE);
eunlink(job->outFile);
}
}
}
@ -1924,23 +1920,23 @@ Job_CatchChildren(Boolean block)
break;
DEBUGF(JOB, ("Process %d exited or stopped.\n", pid));
jnode = Lst_Find(jobs, (void *)&pid, JobCmpPid);
jnode = Lst_Find(jobs, &pid, JobCmpPid);
if (jnode == NULL) {
if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) {
jnode = Lst_Find(stoppedJobs, (void *)&pid, JobCmpPid);
jnode = Lst_Find(stoppedJobs, &pid, JobCmpPid);
if (jnode == NULL) {
Error("Resumed child (%d) not in table", pid);
continue;
}
job = (Job *)Lst_Datum(jnode);
job = Lst_Datum(jnode);
Lst_Remove(stoppedJobs, jnode);
} else {
Error("Child (%d) not in table?", pid);
continue;
}
} else {
job = (Job *)Lst_Datum(jnode);
job = Lst_Datum(jnode);
Lst_Remove(jobs, jnode);
nJobs -= 1;
if (fifoFd >= 0 && maxJobs > 1) {
@ -2026,8 +2022,8 @@ Job_CatchOutput(int flag)
if (flag && jobFull && fifoFd >= 0)
FD_SET(fifoFd, &readfds);
nfds = select(FD_SETSIZE, &readfds, (fd_set *) 0,
(fd_set *) 0, &timeout);
nfds = select(FD_SETSIZE, &readfds, (fd_set *)NULL,
(fd_set *)NULL, &timeout);
if (nfds <= 0) {
if (interrupted)
JobPassSig(interrupted);
@ -2041,7 +2037,7 @@ Job_CatchOutput(int flag)
Punt("Cannot open job table");
}
while (nfds && (ln = Lst_Next(jobs)) != NULL) {
job = (Job *)Lst_Datum(ln);
job = Lst_Datum(ln);
if (FD_ISSET(job->inPipe, &readfds)) {
JobDoOutput(job, FALSE);
nfds -= 1;
@ -2211,7 +2207,7 @@ Job_Init(int maxproc)
while (maxproc-- > 0) {
write(fifoFd, "+", 1);
}
/*The master make does not get a magic token */
/* The master make does not get a magic token */
jobFull = TRUE;
maxJobs = 0;
} else {
@ -2310,7 +2306,7 @@ Job_Init(int maxproc)
begin = Targ_FindNode(".BEGIN", TARG_NOCREATE);
if (begin != NULL) {
JobStart(begin, JOB_SPECIAL, (Job *)0);
JobStart(begin, JOB_SPECIAL, (Job *)NULL);
while (nJobs) {
Job_CatchOutput(0);
Job_CatchChildren(!usePipes);
@ -2643,7 +2639,7 @@ JobInterrupt(int runINTERRUPT, int signo)
Lst_Open(jobs);
while ((ln = Lst_Next(jobs)) != NULL) {
job = (Job *)Lst_Datum(ln);
job = Lst_Datum(ln);
if (!Targ_Precious(job->node)) {
char *file = (job->node->path == NULL ?
@ -2669,7 +2665,7 @@ JobInterrupt(int runINTERRUPT, int signo)
if (interrupt != NULL) {
ignoreErrors = FALSE;
JobStart(interrupt, JOB_IGNDOTS, (Job *)0);
JobStart(interrupt, JOB_IGNDOTS, (Job *)NULL);
while (nJobs) {
Job_CatchOutput(0);
Job_CatchChildren(!usePipes);
@ -2763,10 +2759,9 @@ Job_AbortAll(void)
aborting = ABORT_ERROR;
if (nJobs) {
Lst_Open(jobs);
while ((ln = Lst_Next(jobs)) != NULL) {
job = (Job *)Lst_Datum(ln);
job = Lst_Datum(ln);
/*
* kill the child process with increasingly drastic signals to make
@ -2804,6 +2799,6 @@ JobRestartJobs(void)
{
while (!jobFull && !Lst_IsEmpty(stoppedJobs)) {
DEBUGF(JOB, ("Job queue is not full. Restarting a stopped job.\n"));
JobRestart((Job *)Lst_DeQueue(stoppedJobs));
JobRestart(Lst_DeQueue(stoppedJobs));
}
}

View File

@ -257,7 +257,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
case 'E':
p = emalloc(strlen(optarg) + 1);
strcpy(p, optarg);
Lst_AtEnd(envFirstVars, (void *)p);
Lst_AtEnd(envFirstVars, p);
MFLAGS_append("-E", optarg);
break;
case 'e':
@ -265,7 +265,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
MFLAGS_append("-e", NULL);
break;
case 'f':
Lst_AtEnd(makefiles, (void *)optarg);
Lst_AtEnd(makefiles, optarg);
break;
case 'i':
ignoreErrors = TRUE;
@ -348,7 +348,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
optind = 1; /* - */
goto rearg;
}
Lst_AtEnd(create, (void *)estrdup(*argv));
Lst_AtEnd(create, estrdup(*argv));
}
}
@ -586,7 +586,6 @@ main(int argc, char **argv)
forceJobs = FALSE; /* No -j flag */
compatMake = FALSE; /* No compat mode */
/*
* Initialize the parsing, directory and variable modules to prepare
* for the reading of inclusion paths and variable settings on the
@ -712,9 +711,8 @@ main(int argc, char **argv)
if (!Lst_IsEmpty(create)) {
LstNode ln;
for (ln = Lst_First(create); ln != NULL;
ln = Lst_Succ(ln)) {
char *name = (char *)Lst_Datum(ln);
for (ln = Lst_First(create); ln != NULL; ln = Lst_Succ(ln)) {
char *name = Lst_Datum(ln);
Var_Append(".TARGETS", name, VAR_GLOBAL);
}
@ -752,7 +750,7 @@ main(int argc, char **argv)
Dir_Expand(_PATH_DEFSYSMK, sysIncPath, sysMkPath);
if (Lst_IsEmpty(sysMkPath))
Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
ln = Lst_Find(sysMkPath, (void *)NULL, ReadMakefile);
ln = Lst_Find(sysMkPath, NULL, ReadMakefile);
if (ln != NULL)
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
}
@ -760,7 +758,7 @@ main(int argc, char **argv)
if (!Lst_IsEmpty(makefiles)) {
LstNode ln;
ln = Lst_Find(makefiles, (void *)NULL, ReadMakefile);
ln = Lst_Find(makefiles, NULL, ReadMakefile);
if (ln != NULL)
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
} else if (!ReadMakefile("BSDmakefile", NULL))
@ -824,12 +822,12 @@ main(int argc, char **argv)
ln = Lst_Succ(ln)) {
char *value;
if (expandVars) {
p1 = emalloc(strlen((char *)Lst_Datum(ln)) + 1 + 3);
p1 = emalloc(strlen(Lst_Datum(ln)) + 1 + 3);
/* This sprintf is safe, because of the malloc above */
sprintf(p1, "${%s}", (char *)Lst_Datum(ln));
value = Var_Subst(NULL, p1, VAR_GLOBAL, FALSE);
} else {
value = Var_Value((char *)Lst_Datum(ln),
value = Var_Value(Lst_Datum(ln),
VAR_GLOBAL, &p1);
}
printf("%s\n", value ? value : "");

View File

@ -122,7 +122,7 @@ static int
MakeTimeStamp(void *pgn, void *cgn)
{
return (Make_TimeStamp((GNode *)pgn, (GNode *)cgn));
return (Make_TimeStamp(pgn, cgn));
}
/*-
@ -153,7 +153,7 @@ Make_OODate(GNode *gn)
* doesn't depend on their modification time...
*/
if ((gn->type & (OP_JOIN | OP_USE | OP_EXEC)) == 0) {
Dir_MTime(gn);
Dir_MTime(gn);
if (gn->mtime != 0) {
DEBUGF(MAKE, ("modified %s...", Targ_FmtTime(gn->mtime)));
} else {
@ -241,7 +241,7 @@ Make_OODate(GNode *gn)
* thinking they're out-of-date.
*/
if (!oodate) {
Lst_ForEach(gn->parents, MakeTimeStamp, (void *)gn);
Lst_ForEach(gn->parents, MakeTimeStamp, gn);
}
return (oodate);
@ -263,11 +263,11 @@ Make_OODate(GNode *gn)
static int
MakeAddChild(void *gnp, void *lp)
{
GNode *gn = (GNode *)gnp;
Lst l = (Lst)lp;
GNode *gn = gnp;
Lst l = lp;
if (!gn->make && !(gn->type & OP_USE)) {
Lst_EnQueue(l, (void *)gn);
Lst_EnQueue(l, gn);
}
return (0);
}
@ -301,7 +301,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
GNode *gn; /* A child of the .USE node */
LstNode ln; /* An element in the children list */
if (cgn->type & (OP_USE|OP_TRANSFORM)) {
if (cgn->type & (OP_USE | OP_TRANSFORM)) {
if ((cgn->type & OP_USE) || Lst_IsEmpty(pgn->commands)) {
/*
* .USE or transformation and target has no commands -- append
@ -312,7 +312,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
if (Lst_Open(cgn->children) == SUCCESS) {
while ((ln = Lst_Next(cgn->children)) != NULL) {
gn = (GNode *)Lst_Datum(ln);
gn = Lst_Datum(ln);
if (Lst_Member(pgn->children, gn) == NULL) {
Lst_AtEnd(pgn->children, gn);
@ -343,7 +343,7 @@ static int
MakeHandleUse(void *pgn, void *cgn)
{
return (Make_HandleUse((GNode *)pgn, (GNode *)cgn));
return (Make_HandleUse(pgn, cgn));
}
/*-
@ -449,7 +449,7 @@ Make_Update(GNode *cgn)
if (Lst_Open(cgn->parents) == SUCCESS) {
while ((ln = Lst_Next(cgn->parents)) != NULL) {
pgn = (GNode *)Lst_Datum(ln);
pgn = Lst_Datum(ln);
if (pgn->make) {
pgn->unmade -= 1;
@ -468,7 +468,7 @@ Make_Update(GNode *cgn)
* Queue the node up -- any unmade predecessors will
* be dealt with in MakeStartJobs.
*/
Lst_EnQueue(toBeMade, (void *)pgn);
Lst_EnQueue(toBeMade, pgn);
} else if (pgn->unmade < 0) {
Error("Graph cycles through %s", pgn->name);
}
@ -483,12 +483,12 @@ Make_Update(GNode *cgn)
* before.
*/
for (ln = Lst_First(cgn->successors); ln != NULL; ln = Lst_Succ(ln)) {
GNode *succ = (GNode *)Lst_Datum(ln);
GNode *succ = Lst_Datum(ln);
if (succ->make && succ->unmade == 0 && succ->made == UNMADE &&
Lst_Member(toBeMade, (void *)succ) == NULL)
Lst_Member(toBeMade, succ) == NULL)
{
Lst_EnQueue(toBeMade, (void *)succ);
Lst_EnQueue(toBeMade, succ);
}
}
@ -501,7 +501,7 @@ Make_Update(GNode *cgn)
char *cpref = Var_Value(PREFIX, cgn, &ptr);
while ((ln = Lst_Next(cgn->iParents)) != NULL) {
pgn = (GNode *)Lst_Datum (ln);
pgn = Lst_Datum (ln);
if (pgn->make) {
Var_Set(IMPSRC, cname, pgn);
Var_Set(PREFIX, cpref, pgn);
@ -607,7 +607,7 @@ void
Make_DoAllVar(GNode *gn)
{
Lst_ForEach(gn->children, MakeAddAllSrc, (void *)gn);
Lst_ForEach(gn->children, MakeAddAllSrc, gn);
if (!Var_Exists (OODATE, gn)) {
Var_Set(OODATE, "", gn);
@ -645,8 +645,8 @@ MakeStartJobs(void)
{
GNode *gn;
while (!Lst_IsEmpty (toBeMade) && !Job_Full()) {
gn = (GNode *)Lst_DeQueue(toBeMade);
while (!Lst_IsEmpty(toBeMade) && !Job_Full()) {
gn = Lst_DeQueue(toBeMade);
DEBUGF(MAKE, ("Examining %s...", gn->name));
/*
* Make sure any and all predecessors that are going to be made,
@ -656,7 +656,7 @@ MakeStartJobs(void)
LstNode ln;
for (ln = Lst_First(gn->preds); ln != NULL; ln = Lst_Succ(ln)){
GNode *pgn = (GNode *)Lst_Datum(ln);
GNode *pgn = Lst_Datum(ln);
if (pgn->make && pgn->made == UNMADE) {
DEBUGF(MAKE, ("predecessor %s not made yet.\n", pgn->name));
@ -721,8 +721,8 @@ MakeStartJobs(void)
static int
MakePrintStatus(void *gnp, void *cyclep)
{
GNode *gn = (GNode *)gnp;
Boolean cycle = *(Boolean *)cyclep;
GNode *gn = gnp;
Boolean cycle = *(Boolean *)cyclep;
if (gn->made == UPTODATE) {
printf("`%s' is up to date.\n", gn->name);
@ -742,11 +742,11 @@ MakePrintStatus(void *gnp, void *cyclep)
if (gn->made == CYCLE) {
Error("Graph cycles through `%s'", gn->name);
gn->made = ENDCYCLE;
Lst_ForEach(gn->children, MakePrintStatus, (void *)&t);
Lst_ForEach(gn->children, MakePrintStatus, &t);
gn->made = UNMADE;
} else if (gn->made != ENDCYCLE) {
gn->made = CYCLE;
Lst_ForEach(gn->children, MakePrintStatus, (void *)&t);
Lst_ForEach(gn->children, MakePrintStatus, &t);
}
} else {
printf("`%s' not remade because of errors.\n", gn->name);
@ -797,7 +797,7 @@ Make_Run(Lst targs)
* and go on about our business.
*/
while (!Lst_IsEmpty(examine)) {
gn = (GNode *)Lst_DeQueue(examine);
gn = Lst_DeQueue(examine);
if (!gn->make) {
gn->make = TRUE;
@ -807,13 +807,13 @@ Make_Run(Lst targs)
* Apply any .USE rules before looking for implicit dependencies
* to make sure everything has commands that should...
*/
Lst_ForEach(gn->children, MakeHandleUse, (void *)gn);
Lst_ForEach(gn->children, MakeHandleUse, gn);
Suff_FindDeps(gn);
if (gn->unmade != 0) {
Lst_ForEach(gn->children, MakeAddChild, (void *)examine);
Lst_ForEach(gn->children, MakeAddChild, examine);
} else {
Lst_EnQueue(toBeMade, (void *)gn);
Lst_EnQueue(toBeMade, gn);
}
}
}
@ -849,7 +849,7 @@ Make_Run(Lst targs)
* keepgoing flag was given.
*/
while (!Job_Empty ()) {
Job_CatchOutput(!Lst_IsEmpty (toBeMade));
Job_CatchOutput(!Lst_IsEmpty(toBeMade));
Job_CatchChildren(!usePipes);
MakeStartJobs();
}
@ -861,7 +861,7 @@ Make_Run(Lst targs)
* because some inferior reported an error.
*/
errors = ((errors == 0) && (numNodes != 0));
Lst_ForEach(targs, MakePrintStatus, (void *)&errors);
Lst_ForEach(targs, MakePrintStatus, &errors);
return (TRUE);
}

View File

@ -320,13 +320,13 @@ Parse_Error(int type, const char *fmt, ...)
static int
ParseLinkSrc(void *pgnp, void *cgnp)
{
GNode *pgn = (GNode *)pgnp;
GNode *cgn = (GNode *)cgnp;
GNode *pgn = pgnp;
GNode *cgn = cgnp;
if (Lst_Member(pgn->children, (void *)cgn) == NULL) {
Lst_AtEnd (pgn->children, (void *)cgn);
if (Lst_Member(pgn->children, cgn) == NULL) {
Lst_AtEnd(pgn->children, cgn);
if (specType == Not) {
Lst_AtEnd (cgn->parents, (void *)pgn);
Lst_AtEnd(cgn->parents, pgn);
}
pgn->unmade += 1;
}
@ -352,8 +352,8 @@ ParseLinkSrc(void *pgnp, void *cgnp)
static int
ParseDoOp(void *gnp, void *opp)
{
GNode *gn = (GNode *)gnp;
int op = *(int *)opp;
GNode *gn = gnp;
int op = *(int *)opp;
/*
* If the dependency mask of the operator and the node don't match and
@ -389,15 +389,15 @@ ParseDoOp(void *gnp, void *opp)
* anything with their local variables, but better safe than
* sorry.
*/
Lst_ForEach(gn->parents, ParseLinkSrc, (void *)cohort);
Lst_ForEach(gn->parents, ParseLinkSrc, cohort);
cohort->type = OP_DOUBLEDEP|OP_INVISIBLE;
Lst_AtEnd(gn->cohorts, (void *)cohort);
Lst_AtEnd(gn->cohorts, cohort);
/*
* Replace the node in the targets list with the new copy
*/
ln = Lst_Member(targets, (void *)gn);
Lst_Replace(ln, (void *)cohort);
ln = Lst_Member(targets, gn);
Lst_Replace(ln, cohort);
gn = cohort;
}
/*
@ -428,8 +428,8 @@ ParseDoOp(void *gnp, void *opp)
static int
ParseAddDep(void *pp, void *sp)
{
GNode *p = (GNode *)pp;
GNode *s = (GNode *)sp;
GNode *p = pp;
GNode *s = sp;
if (p->order < s->order) {
/*
@ -437,8 +437,8 @@ ParseAddDep(void *pp, void *sp)
* but checking is tedious, and the debugging output can show the
* problem
*/
Lst_AtEnd(p->successors, (void *)s);
Lst_AtEnd(s->preds, (void *)p);
Lst_AtEnd(p->successors, s);
Lst_AtEnd(s->preds, p);
return (0);
}
else
@ -473,7 +473,7 @@ ParseDoSrc(int tOp, char *src, Lst allsrc)
if (keywd != -1) {
int op = parseKeywords[keywd].op;
if (op != 0) {
Lst_ForEach (targets, ParseDoOp, (void *)&op);
Lst_ForEach(targets, ParseDoOp, &op);
return;
}
if (parseKeywords[keywd].spec == Wait) {
@ -493,7 +493,7 @@ ParseDoSrc(int tOp, char *src, Lst allsrc)
* invoked if the user didn't specify a target on the command
* line. This is to allow #ifmake's to succeed, or something...
*/
Lst_AtEnd (create, (void *)estrdup(src));
Lst_AtEnd(create, estrdup(src));
/*
* Add the name to the .TARGETS variable as well, so the user cna
* employ that, if desired.
@ -508,8 +508,8 @@ ParseDoSrc(int tOp, char *src, Lst allsrc)
*/
gn = Targ_FindNode(src, TARG_CREATE);
if (predecessor != NULL) {
Lst_AtEnd(predecessor->successors, (void *)gn);
Lst_AtEnd(gn->preds, (void *)predecessor);
Lst_AtEnd(predecessor->successors, gn);
Lst_AtEnd(gn->preds, predecessor);
}
/*
* The current source now becomes the predecessor for the next one.
@ -533,18 +533,18 @@ ParseDoSrc(int tOp, char *src, Lst allsrc)
if (tOp) {
gn->type |= tOp;
} else {
Lst_ForEach (targets, ParseLinkSrc, (void *)gn);
Lst_ForEach(targets, ParseLinkSrc, gn);
}
if ((gn->type & OP_OPMASK) == OP_DOUBLEDEP) {
GNode *cohort;
LstNode ln;
for (ln=Lst_First(gn->cohorts); ln != NULL; ln = Lst_Succ(ln)){
cohort = (GNode *)Lst_Datum(ln);
cohort = Lst_Datum(ln);
if (tOp) {
cohort->type |= tOp;
} else {
Lst_ForEach(targets, ParseLinkSrc, (void *)cohort);
Lst_ForEach(targets, ParseLinkSrc, cohort);
}
}
}
@ -552,9 +552,9 @@ ParseDoSrc(int tOp, char *src, Lst allsrc)
}
gn->order = waiting;
Lst_AtEnd(allsrc, (void *)gn);
Lst_AtEnd(allsrc, gn);
if (waiting) {
Lst_ForEach(allsrc, ParseAddDep, (void *)gn);
Lst_ForEach(allsrc, ParseAddDep, gn);
}
}
@ -576,7 +576,8 @@ ParseDoSrc(int tOp, char *src, Lst allsrc)
static int
ParseFindMain(void *gnp, void *dummy __unused)
{
GNode *gn = (GNode *) gnp;
GNode *gn = gnp;
if ((gn->type & (OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM)) == 0) {
mainNode = gn;
Targ_SetMain(gn);
@ -603,7 +604,7 @@ static int
ParseAddDir(void *path, void *name)
{
Dir_AddDir((Lst)path, (char *)name);
Dir_AddDir(path, name);
return(0);
}
@ -624,7 +625,7 @@ static int
ParseClearPath(void *path, void *dummy __unused)
{
Dir_ClearPath((Lst)path);
Dir_ClearPath(path);
return (0);
}
@ -682,15 +683,15 @@ ParseDoDependency (char *line)
specType = Not;
waiting = 0;
paths = (Lst)NULL;
paths = NULL;
curTargs = Lst_Init(FALSE);
curSrcs = Lst_Init(FALSE);
do {
for (cp = line;
*cp && !isspace ((unsigned char)*cp) && *cp != '(';
cp++)
*cp && !isspace((unsigned char)*cp) && *cp != '(';
cp++)
{
if (*cp == '$') {
/*
@ -781,7 +782,7 @@ ParseDoDependency (char *line)
* Have a word in line. See if it's a special target and set
* specType to match it.
*/
if (*line == '.' && isupper ((unsigned char)line[1])) {
if (*line == '.' && isupper((unsigned char)line[1])) {
/*
* See if the target is a special target that must have it
* or its sources handled specially.
@ -829,7 +830,7 @@ ParseDoDependency (char *line)
if (paths == NULL) {
paths = Lst_Init(FALSE);
}
Lst_AtEnd(paths, (void *)dirSearchPath);
Lst_AtEnd(paths, dirSearchPath);
break;
case Main:
if (!Lst_IsEmpty(create)) {
@ -841,12 +842,12 @@ ParseDoDependency (char *line)
case Interrupt:
gn = Targ_FindNode(line, TARG_CREATE);
gn->type |= OP_NOTMAIN;
Lst_AtEnd(targets, (void *)gn);
Lst_AtEnd(targets, gn);
break;
case Default:
gn = Targ_NewGN(".DEFAULT");
gn->type |= (OP_NOTMAIN|OP_TRANSFORM);
Lst_AtEnd(targets, (void *)gn);
Lst_AtEnd(targets, gn);
DEFAULT = gn;
break;
case NotParallel:
@ -882,7 +883,7 @@ ParseDoDependency (char *line)
if (paths == (Lst)NULL) {
paths = Lst_Init(FALSE);
}
Lst_AtEnd(paths, (void *)path);
Lst_AtEnd(paths, path);
}
}
}
@ -909,11 +910,11 @@ ParseDoDependency (char *line)
* No wildcards, but we want to avoid code duplication,
* so create a list with the word on it.
*/
Lst_AtEnd(curTargs, (void *)line);
Lst_AtEnd(curTargs, line);
}
while(!Lst_IsEmpty(curTargs)) {
char *targName = (char *)Lst_DeQueue(curTargs);
char *targName = Lst_DeQueue(curTargs);
if (!Suff_IsTransform (targName)) {
gn = Targ_FindNode(targName, TARG_CREATE);
@ -921,7 +922,7 @@ ParseDoDependency (char *line)
gn = Suff_AddTransform(targName);
}
Lst_AtEnd(targets, (void *)gn);
Lst_AtEnd(targets, gn);
}
} else if (specType == ExPath && *line != '.' && *line != '\0') {
Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line);
@ -945,7 +946,7 @@ ParseDoDependency (char *line)
Parse_Error(PARSE_WARNING, "Extra target ignored");
}
} else {
while (*cp && isspace ((unsigned char) *cp)) {
while (*cp && isspace((unsigned char)*cp)) {
cp++;
}
}
@ -958,7 +959,7 @@ ParseDoDependency (char *line)
Lst_Destroy(curTargs, NOFREE);
if (!Lst_IsEmpty(targets)) {
switch(specType) {
switch (specType) {
default:
Parse_Error(PARSE_WARNING, "Special and mundane targets don't mix. Mundane ones ignored");
break;
@ -998,12 +999,12 @@ ParseDoDependency (char *line)
cp++; /* Advance beyond operator */
Lst_ForEach(targets, ParseDoOp, (void *)&op);
Lst_ForEach(targets, ParseDoOp, &op);
/*
* Get to the first source
*/
while (*cp && isspace ((unsigned char)*cp)) {
while (*cp && isspace((unsigned char)*cp)) {
cp++;
}
line = cp;
@ -1032,7 +1033,7 @@ ParseDoDependency (char *line)
beSilent = TRUE;
break;
case ExPath:
Lst_ForEach(paths, ParseClearPath, (void *)NULL);
Lst_ForEach(paths, ParseClearPath, NULL);
break;
case Posix:
Var_Set("%POSIX", "1003.2", VAR_GLOBAL);
@ -1091,7 +1092,7 @@ ParseDoDependency (char *line)
* has no valid suffix.
*/
char savech;
while (*cp && !isspace ((unsigned char)*cp)) {
while (*cp && !isspace((unsigned char)*cp)) {
cp++;
}
savech = *cp;
@ -1101,7 +1102,7 @@ ParseDoDependency (char *line)
Suff_AddSuffix(line);
break;
case ExPath:
Lst_ForEach(paths, ParseAddDir, (void *)line);
Lst_ForEach(paths, ParseAddDir, line);
break;
case Includes:
Suff_AddInclude(line);
@ -1119,7 +1120,7 @@ ParseDoDependency (char *line)
if (savech != '\0') {
cp++;
}
while (*cp && isspace ((unsigned char)*cp)) {
while (*cp && isspace((unsigned char)*cp)) {
cp++;
}
line = cp;
@ -1134,7 +1135,7 @@ ParseDoDependency (char *line)
* specifications (i.e. things with left parentheses in them)
* and handle them accordingly.
*/
while (*cp && !isspace ((unsigned char)*cp)) {
while (*cp && !isspace((unsigned char)*cp)) {
if ((*cp == '(') && (cp > line) && (cp[-1] != '$')) {
/*
* Only stop for a left parenthesis if it isn't at the
@ -1159,7 +1160,7 @@ ParseDoDependency (char *line)
}
while (!Lst_IsEmpty (sources)) {
gnp = (GNode *)Lst_DeQueue(sources);
gnp = Lst_DeQueue(sources);
ParseDoSrc(tOp, gnp->name, curSrcs);
}
Lst_Destroy(sources, NOFREE);
@ -1172,7 +1173,7 @@ ParseDoDependency (char *line)
ParseDoSrc(tOp, line, curSrcs);
}
while (*cp && isspace ((unsigned char)*cp)) {
while (*cp && isspace((unsigned char)*cp)) {
cp++;
}
line = cp;
@ -1186,7 +1187,7 @@ ParseDoDependency (char *line)
* the first dependency line that is actually a real target
* (i.e. isn't a .USE or .EXEC rule) to be made.
*/
Lst_ForEach(targets, ParseFindMain, (void *)0);
Lst_ForEach(targets, ParseFindMain, NULL);
}
/*
@ -1342,7 +1343,7 @@ Parse_DoVar(char *line, GNode *ctxt)
* Skip to operator character, nulling out whitespace as we go
*/
for (cp = line + 1; *cp != '='; cp++) {
if (isspace ((unsigned char)*cp)) {
if (isspace((unsigned char)*cp)) {
*cp = '\0';
}
}
@ -1398,7 +1399,7 @@ Parse_DoVar(char *line, GNode *ctxt)
break;
}
while (isspace ((unsigned char)*cp)) {
while (isspace((unsigned char)*cp)) {
cp++;
}
@ -1464,7 +1465,6 @@ Parse_DoVar(char *line, GNode *ctxt)
}
}
/*-
* ParseAddCmd --
* Lst_ForEach function to add a command line to all targets
@ -1478,7 +1478,7 @@ Parse_DoVar(char *line, GNode *ctxt)
static int
ParseAddCmd(void *gnp, void *cmd)
{
GNode *gn = (GNode *) gnp;
GNode *gn = gnp;
/* if target already supplied, ignore commands */
if (!(gn->type & OP_HAS_COMMANDS))
@ -1509,8 +1509,7 @@ ParseAddCmd(void *gnp, void *cmd)
static void
ParseHasCommands(void *gnp)
{
GNode *gn = (GNode *) gnp;
GNode *gn = gnp;
if (!Lst_IsEmpty(gn->commands)) {
gn->type |= OP_HAS_COMMANDS;
@ -1697,20 +1696,20 @@ ParseDoInclude (char *file)
else
newName = str_concat(Fname, file, STR_ADDSLASH);
fullname = Dir_FindFile(newName, parseIncPath);
if (fullname == (char *)NULL) {
if (fullname == NULL) {
fullname = Dir_FindFile(newName, dirSearchPath);
}
free(newName);
*prefEnd = '/';
} else {
fullname = (char *)NULL;
fullname = NULL;
}
free(Fname);
} else {
fullname = (char *)NULL;
fullname = NULL;
}
if (fullname == (char *)NULL) {
if (fullname == NULL) {
/*
* System makefile or makefile wasn't found in same directory as
* included makefile. Search for it first on the -I search path,
@ -1718,12 +1717,12 @@ ParseDoInclude (char *file)
* XXX: Suffix specific?
*/
fullname = Dir_FindFile(file, parseIncPath);
if (fullname == (char *)NULL) {
if (fullname == NULL) {
fullname = Dir_FindFile(file, dirSearchPath);
}
}
if (fullname == (char *)NULL) {
if (fullname == NULL) {
/*
* Still haven't found the makefile. Look for it on the system
* path as a last resort.
@ -1731,7 +1730,7 @@ ParseDoInclude (char *file)
fullname = Dir_FindFile(file, sysIncPath);
}
if (fullname == (char *) NULL) {
if (fullname == NULL) {
*cp = endc;
Parse_Error(PARSE_FATAL, "Could not find %s", file);
return;
@ -1746,10 +1745,10 @@ ParseDoInclude (char *file)
* is placed on a list with other IFile structures. The list makes
* a very nice stack to track how we got here...
*/
oldFile = (IFile *) emalloc(sizeof (IFile));
memcpy(oldFile, &curFile, sizeof (IFile));
oldFile = emalloc(sizeof (IFile));
memcpy(oldFile, &curFile, sizeof(IFile));
Lst_AtFront(includes, (void *)oldFile);
Lst_AtFront(includes, oldFile);
/*
* Once the previous state has been saved, we can get down to reading
@ -1762,7 +1761,7 @@ ParseDoInclude (char *file)
curFile.F = fopen(fullname, "r");
curFile.p = NULL;
if (curFile.F == (FILE * ) NULL) {
if (curFile.F == NULL) {
Parse_Error(PARSE_FATAL, "Cannot open %s", fullname);
/*
* Pop to previous file
@ -1793,13 +1792,13 @@ Parse_FromString(char *str, int lineno)
DEBUGF(FOR, ("%s\n---- at line %d\n", str, lineno));
oldFile = (IFile *)emalloc(sizeof(IFile));
oldFile = emalloc(sizeof(IFile));
memcpy(oldFile, &curFile, sizeof(IFile));
Lst_AtFront (includes, (void *)oldFile);
Lst_AtFront(includes, oldFile);
curFile.F = NULL;
curFile.p = (PTR *)emalloc(sizeof (PTR));
curFile.p = emalloc(sizeof (PTR));
curFile.p->str = curFile.p->ptr = str;
curFile.lineno = lineno;
curFile.fname = estrdup(curFile.fname);
@ -1863,11 +1862,11 @@ ParseTraditionalInclude (char *file)
* search path, if not found in a -I directory.
*/
fullname = Dir_FindFile(file, parseIncPath);
if (fullname == (char *)NULL) {
if (fullname == NULL) {
fullname = Dir_FindFile(file, dirSearchPath);
}
if (fullname == (char *)NULL) {
if (fullname == NULL) {
/*
* Still haven't found the makefile. Look for it on the system
* path as a last resort.
@ -1875,7 +1874,7 @@ ParseTraditionalInclude (char *file)
fullname = Dir_FindFile(file, sysIncPath);
}
if (fullname == (char *) NULL) {
if (fullname == NULL) {
Parse_Error(PARSE_FATAL, "Could not find %s", file);
return;
}
@ -1887,10 +1886,10 @@ ParseTraditionalInclude (char *file)
* is placed on a list with other IFile structures. The list makes
* a very nice stack to track how we got here...
*/
oldFile = (IFile *)emalloc(sizeof(IFile));
oldFile = emalloc(sizeof(IFile));
memcpy(oldFile, &curFile, sizeof(IFile));
Lst_AtFront(includes, (void *)oldFile);
Lst_AtFront(includes, oldFile);
/*
* Once the previous state has been saved, we can get down to reading
@ -1903,7 +1902,7 @@ ParseTraditionalInclude (char *file)
curFile.F = fopen(fullname, "r");
curFile.p = NULL;
if (curFile.F == (FILE * )NULL) {
if (curFile.F == NULL) {
Parse_Error(PARSE_FATAL, "Cannot open %s", fullname);
/*
* Pop to previous file
@ -1941,7 +1940,7 @@ ParseEOF(int opened)
return (DONE);
}
ifile = (IFile *)Lst_DeQueue(includes);
ifile = Lst_DeQueue(includes);
free(curFile.fname);
if (opened && curFile.F) {
fclose(curFile.F);
@ -2053,7 +2052,7 @@ ParseSkipLine(int skip, int keep_newline)
if (c == EOF) {
Parse_Error(PARSE_FATAL, "Unclosed conditional/for loop");
Buf_Destroy(buf, TRUE);
return ((char *)NULL);
return (NULL);
}
curFile.lineno++;
@ -2328,7 +2327,7 @@ ParseReadLine(void)
/*
* Hit end-of-file, so return a NULL line to indicate this.
*/
return ((char *)NULL);
return (NULL);
}
}
@ -2350,7 +2349,7 @@ ParseFinishLine(void)
{
if (inLine) {
Lst_ForEach(targets, Suff_EndTransform, (void *)NULL);
Lst_ForEach(targets, Suff_EndTransform, NULL);
Lst_Destroy(targets, ParseHasCommands);
targets = NULL;
inLine = FALSE;
@ -2445,7 +2444,7 @@ Parse_File(char *name, FILE *stream)
* commands of all targets in the dependency spec
*/
Lst_ForEach(targets, ParseAddCmd, cp);
Lst_AtEnd(targCmds, (void *)line);
Lst_AtEnd(targCmds, line);
continue;
} else {
Parse_Error(PARSE_FATAL,
@ -2584,10 +2583,10 @@ Parse_MainName(void)
Punt("no target to make.");
/*NOTREACHED*/
} else if (mainNode->type & OP_DOUBLEDEP) {
Lst_AtEnd(listmain, (void *)mainNode);
Lst_AtEnd(listmain, mainNode);
Lst_Concat(listmain, mainNode->cohorts, LST_CONCNEW);
}
else
Lst_AtEnd(listmain, (void *)mainNode);
Lst_AtEnd(listmain, mainNode);
return (listmain);
}

View File

@ -56,7 +56,7 @@ str_init(void)
{
char *p1;
argv = (char **)emalloc(((argmax = 50) + 1) * sizeof(char *));
argv = emalloc(((argmax = 50) + 1) * sizeof(char *));
argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1);
}
@ -97,7 +97,7 @@ str_concat(char *s1, char *s2, int flags)
len2 = strlen(s2);
/* allocate length plus separator plus EOS */
result = emalloc((u_int)(len1 + len2 + 2));
result = emalloc(len1 + len2 + 2);
/* copy first string into place */
memcpy(result, s1, len1);
@ -168,7 +168,7 @@ brk_string(char *str, int *store_argc, Boolean expand)
if (!start)
start = t;
} else
inquote = (char) ch;
inquote = (char)ch;
if (expand)
continue;
break;
@ -191,11 +191,11 @@ brk_string(char *str, int *store_argc, Boolean expand)
*t++ = '\0';
if (argc == argmax) {
argmax *= 2; /* ramp up fast */
argv = (char **)erealloc(argv,
argv = erealloc(argv,
(argmax + 1) * sizeof(char *));
}
argv[argc++] = start;
start = (char *)NULL;
start = NULL;
if (ch == '\n' || ch == '\0')
goto done;
continue;
@ -241,7 +241,7 @@ brk_string(char *str, int *store_argc, Boolean expand)
start = t;
*t++ = (char)ch;
}
done: argv[argc] = (char *)NULL;
done: argv[argc] = NULL;
*store_argc = argc;
return (argv);
}

View File

@ -252,7 +252,7 @@ static int
SuffSuffIsSuffixP(void *s, void *str)
{
return (!SuffSuffIsSuffix((Suff *)s, (char *)str));
return (!SuffSuffIsSuffix(s, str));
}
/*-
@ -272,7 +272,7 @@ static int
SuffSuffHasNameP(void *s, void *sname)
{
return (strcmp((char *)sname, ((Suff *)s)->name));
return (strcmp(sname, ((Suff *)s)->name));
}
/*-
@ -294,7 +294,7 @@ static int
SuffSuffIsPrefix(void *s, void *str)
{
return (SuffStrIsPrefix(((Suff *)s)->name, (char *)str) == NULL ? 1 : 0);
return (SuffStrIsPrefix(((Suff *)s)->name, str) == NULL ? 1 : 0);
}
/*-
@ -313,7 +313,7 @@ static int
SuffGNHasNameP(void *gn, void *name)
{
return (strcmp((char *)name, ((GNode *)gn)->name));
return (strcmp(name, ((GNode *)gn)->name));
}
/*********** Maintenance Functions ************/
@ -333,7 +333,7 @@ SuffGNHasNameP(void *gn, void *name)
static void
SuffFree(void *sp)
{
Suff *s = (Suff *) sp;
Suff *s = sp;
if (s == suffNull)
suffNull = NULL;
@ -365,7 +365,8 @@ SuffFree(void *sp)
static void
SuffRemove(Lst l, Suff *s)
{
LstNode ln = Lst_Member(l, (void *)s);
LstNode ln = Lst_Member(l, s);
if (ln != NULL) {
Lst_Remove(l, ln);
s->refCount--;
@ -395,7 +396,7 @@ SuffInsert(Lst l, Suff *s)
return;
}
while ((ln = Lst_Next(l)) != NULL) {
s2 = (Suff *)Lst_Datum(ln);
s2 = Lst_Datum(ln);
if (s2->sNum >= s->sNum) {
break;
}
@ -408,14 +409,14 @@ SuffInsert(Lst l, Suff *s)
DEBUGF(SUFF, ("inserting %s(%d)...", s->name, s->sNum));
if (ln == NULL) {
DEBUGF(SUFF, ("at end of list\n"));
Lst_AtEnd (l, (void *)s);
Lst_AtEnd (l, s);
s->refCount++;
Lst_AtEnd(s->ref, (void *)l);
Lst_AtEnd(s->ref, l);
} else if (s2->sNum != s->sNum) {
DEBUGF(SUFF, ("before %s(%d)\n", s2->name, s2->sNum));
Lst_Insert(l, ln, (void *)s);
Lst_Insert(l, ln, s);
s->refCount++;
Lst_AtEnd(s->ref, (void *)l);
Lst_AtEnd(s->ref, l);
} else {
DEBUGF(SUFF, ("already there\n"));
}
@ -492,9 +493,9 @@ SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
*/
for (;;) {
if (srcLn == NULL) {
srcLn = Lst_Find(sufflist, (void *)str, SuffSuffIsPrefix);
srcLn = Lst_Find(sufflist, str, SuffSuffIsPrefix);
} else {
srcLn = Lst_FindFrom(sufflist, Lst_Succ(srcLn), (void *)str,
srcLn = Lst_FindFrom(sufflist, Lst_Succ(srcLn), str,
SuffSuffIsPrefix);
}
if (srcLn == NULL) {
@ -517,16 +518,16 @@ SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
}
return (FALSE);
}
src = (Suff *) Lst_Datum (srcLn);
src = Lst_Datum (srcLn);
str2 = str + src->nameLen;
if (*str2 == '\0') {
single = src;
singleLn = srcLn;
} else {
targLn = Lst_Find(sufflist, (void *)str2, SuffSuffHasNameP);
targLn = Lst_Find(sufflist, str2, SuffSuffHasNameP);
if (targLn != NULL) {
*srcPtr = src;
*targPtr = (Suff *)Lst_Datum(targLn);
*targPtr = Lst_Datum(targLn);
return (TRUE);
}
}
@ -577,14 +578,14 @@ Suff_AddTransform(char *line)
*t; /* target suffix */
LstNode ln; /* Node for existing transformation */
ln = Lst_Find(transforms, (void *)line, SuffGNHasNameP);
ln = Lst_Find(transforms, line, SuffGNHasNameP);
if (ln == NULL) {
/*
* Make a new graph node for the transformation. It will be filled in
* by the Parse module.
*/
gn = Targ_NewGN(line);
Lst_AtEnd (transforms, (void *)gn);
Lst_AtEnd(transforms, gn);
} else {
/*
* New specification for transformation rule. Just nuke the old list
@ -592,7 +593,7 @@ Suff_AddTransform(char *line)
* free the commands themselves, because a given command can be
* attached to several different transformations.
*/
gn = (GNode *)Lst_Datum(ln);
gn = Lst_Datum(ln);
Lst_Destroy(gn->commands, NOFREE);
Lst_Destroy(gn->children, NOFREE);
gn->commands = Lst_Init(FALSE);
@ -694,8 +695,8 @@ Suff_EndTransform(void *gnp, void *dummy __unused)
static int
SuffRebuildGraph(void *transformp, void *sp)
{
GNode *transform = (GNode *)transformp;
Suff *s = (Suff *)sp;
GNode *transform = transformp;
Suff *s = sp;
char *cp;
LstNode ln;
Suff *s2 = NULL;
@ -708,9 +709,9 @@ SuffRebuildGraph(void *transformp, void *sp)
if (cp[0] == '\0') /* null rule */
s2 = suffNull;
else {
ln = Lst_Find(sufflist, (void *)cp, SuffSuffHasNameP);
ln = Lst_Find(sufflist, cp, SuffSuffHasNameP);
if (ln != NULL)
s2 = (Suff *)Lst_Datum(ln);
s2 = Lst_Datum(ln);
}
if (s2 != NULL) {
/*
@ -727,12 +728,12 @@ SuffRebuildGraph(void *transformp, void *sp)
* Not from, maybe to?
*/
cp = SuffSuffIsSuffix(s, transform->name + strlen(transform->name));
if (cp != (char *)NULL) {
if (cp != NULL) {
/*
* Null-terminate the source suffix in order to find it.
*/
cp[1] = '\0';
ln = Lst_Find(sufflist, (void *)transform->name, SuffSuffHasNameP);
ln = Lst_Find(sufflist, transform->name, SuffSuffHasNameP);
/*
* Replace the start of the target suffix
*/
@ -741,7 +742,7 @@ SuffRebuildGraph(void *transformp, void *sp)
/*
* Found it -- establish the proper relationship
*/
s2 = (Suff *)Lst_Datum(ln);
s2 = Lst_Datum(ln);
SuffInsert(s->children, s2);
SuffInsert(s2->parents, s);
}
@ -769,9 +770,9 @@ Suff_AddSuffix(char *str)
Suff *s; /* new suffix descriptor */
LstNode ln;
ln = Lst_Find(sufflist, (void *)str, SuffSuffHasNameP);
ln = Lst_Find(sufflist, str, SuffSuffHasNameP);
if (ln == NULL) {
s = (Suff *)emalloc(sizeof(Suff));
s = emalloc(sizeof(Suff));
s->name = estrdup(str);
s->nameLen = strlen (s->name);
@ -783,12 +784,13 @@ Suff_AddSuffix(char *str)
s->flags = 0;
s->refCount = 0;
Lst_AtEnd(sufflist, (void *)s);
Lst_AtEnd(sufflist, s);
/*
* Look for any existing transformations from or to this suffix.
* XXX: Only do this after a Suff_ClearSuffixes?
*/
Lst_ForEach(transforms, SuffRebuildGraph, (void *)s);
Lst_ForEach(transforms, SuffRebuildGraph, s);
}
}
@ -811,11 +813,11 @@ Suff_GetPath(char *sname)
LstNode ln;
Suff *s;
ln = Lst_Find(sufflist, (void *)sname, SuffSuffHasNameP);
ln = Lst_Find(sufflist, sname, SuffSuffHasNameP);
if (ln == NULL) {
return (NULL);
} else {
s = (Suff *)Lst_Datum(ln);
s = Lst_Datum(ln);
return (s->searchPath);
}
}
@ -855,7 +857,7 @@ Suff_DoPaths(void)
inLibs = Lst_Init(FALSE);
while ((ln = Lst_Next(sufflist)) != NULL) {
s = (Suff *)Lst_Datum(ln);
s = Lst_Datum(ln);
if (!Lst_IsEmpty(s->searchPath)) {
#ifdef INCLUDES
if (s->flags & SUFF_INCLUDE) {
@ -906,9 +908,9 @@ Suff_AddInclude(char *sname)
LstNode ln;
Suff *s;
ln = Lst_Find(sufflist, (void *)sname, SuffSuffHasNameP);
ln = Lst_Find(sufflist, sname, SuffSuffHasNameP);
if (ln != NULL) {
s = (Suff *)Lst_Datum(ln);
s = Lst_Datum(ln);
s->flags |= SUFF_INCLUDE;
}
}
@ -935,9 +937,9 @@ Suff_AddLib(char *sname)
LstNode ln;
Suff *s;
ln = Lst_Find(sufflist, (void *)sname, SuffSuffHasNameP);
ln = Lst_Find(sufflist, sname, SuffSuffHasNameP);
if (ln != NULL) {
s = (Suff *)Lst_Datum(ln);
s = Lst_Datum(ln);
s->flags |= SUFF_LIBRARY;
}
}
@ -961,8 +963,8 @@ Suff_AddLib(char *sname)
static int
SuffAddSrc(void *sp, void *lsp)
{
Suff *s = (Suff *) sp;
LstSrc *ls = (LstSrc *) lsp;
Suff *s = sp;
LstSrc *ls = lsp;
Src *s2; /* new Src structure */
Src *targ; /* Target structure */
@ -974,7 +976,7 @@ SuffAddSrc(void *sp, void *lsp)
* structure for a file with no suffix attached. Two birds, and all
* that...
*/
s2 = (Src *)emalloc(sizeof(Src));
s2 = emalloc(sizeof(Src));
s2->file = estrdup(targ->pref);
s2->pref = targ->pref;
s2->parent = targ;
@ -983,30 +985,30 @@ SuffAddSrc(void *sp, void *lsp)
s->refCount++;
s2->children = 0;
targ->children += 1;
Lst_AtEnd(ls->l, (void *)s2);
Lst_AtEnd(ls->l, s2);
#ifdef DEBUG_SRC
s2->cp = Lst_Init(FALSE);
Lst_AtEnd(targ->cp, (void *) s2);
Lst_AtEnd(targ->cp, s2);
printf("1 add %x %x to %x:", targ, s2, ls->l);
Lst_ForEach(ls->l, PrintAddr, (void *) 0);
Lst_ForEach(ls->l, PrintAddr, (void *)NULL);
printf("\n");
#endif
}
s2 = (Src *)emalloc(sizeof(Src));
s2 = emalloc(sizeof(Src));
s2->file = str_concat(targ->pref, s->name, 0);
s2->pref = targ->pref;
s2->parent = targ;
s2->node = NULL;
s2->suff = s;
s->refCount++;
s2->children = 0;
s2->children = 0;
targ->children += 1;
Lst_AtEnd(ls->l, (void *)s2);
Lst_AtEnd(ls->l, s2);
#ifdef DEBUG_SRC
s2->cp = Lst_Init(FALSE);
Lst_AtEnd(targ->cp, (void *) s2);
Lst_AtEnd(targ->cp, s2);
printf("2 add %x %x to %x:", targ, s2, ls->l);
Lst_ForEach(ls->l, PrintAddr, (void *) 0);
Lst_ForEach(ls->l, PrintAddr, (void *)NULL);
printf("\n");
#endif
@ -1033,7 +1035,7 @@ SuffAddLevel(Lst l, Src *targ)
ls.s = targ;
ls.l = l;
Lst_ForEach(targ->suff->children, SuffAddSrc, (void *)&ls);
Lst_ForEach(targ->suff->children, SuffAddSrc, &ls);
}
/*-
@ -1060,7 +1062,7 @@ SuffRemoveSrc(Lst l)
}
#ifdef DEBUG_SRC
printf("cleaning %lx: ", (unsigned long) l);
Lst_ForEach(l, PrintAddr, (void *) 0);
Lst_ForEach(l, PrintAddr, (void *)NULL);
printf("\n");
#endif
@ -1073,7 +1075,7 @@ SuffRemoveSrc(Lst l)
free(s->pref);
else {
#ifdef DEBUG_SRC
LstNode ln = Lst_Member(s->parent->cp, (void *)s);
LstNode ln = Lst_Member(s->parent->cp, s);
if (ln != NULL)
Lst_Remove(s->parent->cp, ln);
#endif
@ -1092,7 +1094,7 @@ SuffRemoveSrc(Lst l)
#ifdef DEBUG_SRC
else {
printf("keep: [l=%x] p=%x %d: ", l, s, s->children);
Lst_ForEach(s->cp, PrintAddr, (void *)0);
Lst_ForEach(s->cp, PrintAddr, (void *)NULL);
printf("\n");
}
#endif
@ -1122,10 +1124,10 @@ SuffFindThem (Lst srcs, Lst slst)
Src *rs; /* returned Src */
char *ptr;
rs = (Src *)NULL;
rs = NULL;
while (!Lst_IsEmpty (srcs)) {
s = (Src *)Lst_DeQueue(srcs);
s = Lst_DeQueue(srcs);
DEBUGF(SUFF, ("\ttrying %s...", s->file));
@ -1153,7 +1155,7 @@ SuffFindThem (Lst srcs, Lst slst)
DEBUGF(SUFF, ("not there\n"));
SuffAddLevel(srcs, s);
Lst_AtEnd(slst, (void *)s);
Lst_AtEnd(slst, s);
}
if (rs) {
@ -1193,10 +1195,10 @@ SuffFindCmds (Src *targ, Lst slst)
prefLen = strlen(targ->pref);
while ((ln = Lst_Next(t->children)) != NULL) {
s = (GNode *)Lst_Datum(ln);
s = Lst_Datum(ln);
cp = strrchr(s->name, '/');
if (cp == (char *)NULL) {
if (cp == NULL) {
cp = s->name;
} else {
cp++;
@ -1206,7 +1208,7 @@ SuffFindCmds (Src *targ, Lst slst)
* The node matches the prefix ok, see if it has a known
* suffix.
*/
ln = Lst_Find(sufflist, (void *)&cp[prefLen], SuffSuffHasNameP);
ln = Lst_Find(sufflist, &cp[prefLen], SuffSuffHasNameP);
if (ln != NULL) {
/*
* It even has a known suffix, see if there's a transformation
@ -1214,17 +1216,16 @@ SuffFindCmds (Src *targ, Lst slst)
*
* XXX: Handle multi-stage transformations here, too.
*/
suff = (Suff *)Lst_Datum(ln);
suff = Lst_Datum(ln);
if (Lst_Member(suff->parents, (void *)targ->suff) != NULL)
{
if (Lst_Member(suff->parents, targ->suff) != NULL) {
/*
* Hot Damn! Create a new Src structure to describe
* this transformation (making sure to duplicate the
* source node's name so Suff_FindDeps can free it
* again (ick)), and return the new structure.
*/
ret = (Src *)emalloc (sizeof(Src));
ret = emalloc(sizeof(Src));
ret->file = estrdup(s->name);
ret->pref = targ->pref;
ret->suff = suff;
@ -1236,9 +1237,9 @@ SuffFindCmds (Src *targ, Lst slst)
#ifdef DEBUG_SRC
ret->cp = Lst_Init(FALSE);
printf("3 add %x %x\n", targ, ret);
Lst_AtEnd(targ->cp, (void *)ret);
Lst_AtEnd(targ->cp, ret);
#endif
Lst_AtEnd(slst, (void *)ret);
Lst_AtEnd(slst, ret);
DEBUGF(SUFF, ("\tusing existing source %s\n", s->name));
return (ret);
}
@ -1246,7 +1247,7 @@ SuffFindCmds (Src *targ, Lst slst)
}
}
Lst_Close(t->children);
return ((Src *)NULL);
return (NULL);
}
/*-
@ -1256,7 +1257,7 @@ SuffFindCmds (Src *targ, Lst slst)
* variable invocations or file wildcards into actual targets.
*
* Results:
* === 0 (continue)
* == 0 (continue)
*
* Side Effects:
* The expanded node is removed from the parent's list of children,
@ -1268,8 +1269,8 @@ SuffFindCmds (Src *targ, Lst slst)
static int
SuffExpandChildren(void *cgnp, void *pgnp)
{
GNode *cgn = (GNode *)cgnp;
GNode *pgn = (GNode *)pgnp;
GNode *cgn = cgnp;
GNode *pgn = pgnp;
GNode *gn; /* New source 8) */
LstNode prevLN; /* Node after which new source should be put */
LstNode ln; /* List element for old source */
@ -1279,7 +1280,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* New nodes effectively take the place of the child, so place them
* after the child
*/
prevLN = Lst_Member(pgn->children, (void *)cgn);
prevLN = Lst_Member(pgn->children, cgn);
/*
* First do variable expansion -- this takes precedence over
@ -1287,11 +1288,11 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* to later since the resulting words are tacked on to the end of
* the children list.
*/
if (strchr(cgn->name, '$') != (char *)NULL) {
if (strchr(cgn->name, '$') != NULL) {
DEBUGF(SUFF, ("Expanding \"%s\"...", cgn->name));
cp = Var_Subst(NULL, cgn->name, pgn, TRUE);
if (cp != (char *)NULL) {
if (cp != NULL) {
Lst members = Lst_Init(FALSE);
if (cgn->type & OP_ARCHV) {
@ -1324,7 +1325,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
*/
*cp++ = '\0';
gn = Targ_FindNode(start, TARG_CREATE);
Lst_AtEnd(members, (void *)gn);
Lst_AtEnd(members, gn);
while (*cp == ' ' || *cp == '\t') {
cp++;
}
@ -1363,7 +1364,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* Stuff left over -- add it to the list too
*/
gn = Targ_FindNode(start, TARG_CREATE);
Lst_AtEnd(members, (void *)gn);
Lst_AtEnd(members, gn);
}
/*
* Point cp back at the beginning again so the variable value
@ -1375,13 +1376,13 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* Add all elements of the members list to the parent node.
*/
while(!Lst_IsEmpty(members)) {
gn = (GNode *)Lst_DeQueue(members);
gn = Lst_DeQueue(members);
DEBUGF(SUFF, ("%s...", gn->name));
if (Lst_Member(pgn->children, (void *)gn) == NULL) {
Lst_Append(pgn->children, prevLN, (void *)gn);
if (Lst_Member(pgn->children, gn) == NULL) {
Lst_Append(pgn->children, prevLN, gn);
prevLN = Lst_Succ(prevLN);
Lst_AtEnd(gn->parents, (void *)pgn);
Lst_AtEnd(gn->parents, pgn);
pgn->unmade++;
}
}
@ -1389,13 +1390,13 @@ SuffExpandChildren(void *cgnp, void *pgnp)
/*
* Free the result
*/
free((char *)cp);
free(cp);
}
/*
* Now the source is expanded, remove it from the list of children to
* keep it from being processed.
*/
ln = Lst_Member(pgn->children, (void *)cgn);
ln = Lst_Member(pgn->children, cgn);
pgn->unmade--;
Lst_Remove(pgn->children, ln);
DEBUGF(SUFF, ("\n"));
@ -1412,12 +1413,12 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* Else use the default system search path.
*/
cp = cgn->name + strlen(cgn->name);
ln = Lst_Find(sufflist, (void *)cp, SuffSuffIsSuffixP);
ln = Lst_Find(sufflist, cp, SuffSuffIsSuffixP);
DEBUGF(SUFF, ("Wildcard expanding \"%s\"...", cgn->name));
if (ln != NULL) {
Suff *s = (Suff *)Lst_Datum(ln);
Suff *s = Lst_Datum(ln);
DEBUGF(SUFF, ("suffix is \"%s\"...", s->name));
path = s->searchPath;
@ -1438,7 +1439,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
/*
* Fetch next expansion off the list and find its GNode
*/
cp = (char *)Lst_DeQueue(exp);
cp = Lst_DeQueue(exp);
DEBUGF(SUFF, ("%s...", cp));
gn = Targ_FindNode(cp, TARG_CREATE);
@ -1447,10 +1448,10 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* If gn isn't already a child of the parent, make it so and
* up the parent's count of unmade children.
*/
if (Lst_Member(pgn->children, (void *)gn) == NULL) {
Lst_Append(pgn->children, prevLN, (void *)gn);
if (Lst_Member(pgn->children, gn) == NULL) {
Lst_Append(pgn->children, prevLN, gn);
prevLN = Lst_Succ(prevLN);
Lst_AtEnd(gn->parents, (void *)pgn);
Lst_AtEnd(gn->parents, pgn);
pgn->unmade++;
}
}
@ -1464,7 +1465,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* Now the source is expanded, remove it from the list of children to
* keep it from being processed.
*/
ln = Lst_Member(pgn->children, (void *)cgn);
ln = Lst_Member(pgn->children, cgn);
pgn->unmade--;
Lst_Remove(pgn->children, ln);
DEBUGF(SUFF, ("\n"));
@ -1498,13 +1499,13 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
char *tname; /* Name of transformation rule */
GNode *gn; /* Node for same */
if (Lst_Member(tGn->children, (void *)sGn) == NULL) {
if (Lst_Member(tGn->children, sGn) == NULL) {
/*
* Not already linked, so form the proper links between the
* target and source.
*/
Lst_AtEnd(tGn->children, (void *)sGn);
Lst_AtEnd(sGn->parents, (void *)tGn);
Lst_AtEnd(tGn->children, sGn);
Lst_AtEnd(sGn->parents, tGn);
tGn->unmade += 1;
}
@ -1515,16 +1516,16 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
* sGn gets the target in its iParents list, however, as that
* will be sufficient to get the .IMPSRC variable set for tGn
*/
for (ln=Lst_First(sGn->cohorts); ln != NULL; ln=Lst_Succ(ln)) {
gn = (GNode *)Lst_Datum(ln);
for (ln = Lst_First(sGn->cohorts); ln != NULL; ln = Lst_Succ(ln)) {
gn = Lst_Datum(ln);
if (Lst_Member(tGn->children, (void *)gn) == NULL) {
if (Lst_Member(tGn->children, gn) == NULL) {
/*
* Not already linked, so form the proper links between the
* target and source.
*/
Lst_AtEnd(tGn->children, (void *)gn);
Lst_AtEnd(gn->parents, (void *)tGn);
Lst_AtEnd(tGn->children, gn);
Lst_AtEnd(gn->parents, tGn);
tGn->unmade += 1;
}
}
@ -1533,7 +1534,7 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
* Locate the transformation rule itself
*/
tname = str_concat(s->name, t->name, 0);
ln = Lst_Find(transforms, (void *)tname, SuffGNHasNameP);
ln = Lst_Find(transforms, tname, SuffGNHasNameP);
free(tname);
if (ln == NULL) {
@ -1545,7 +1546,7 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
return (FALSE);
}
gn = (GNode *)Lst_Datum(ln);
gn = Lst_Datum(ln);
DEBUGF(SUFF, ("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name));
@ -1564,14 +1565,14 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
*/
ln = Lst_Succ(ln);
if (ln != NULL) {
Lst_ForEachFrom(tGn->children, ln, SuffExpandChildren, (void *)tGn);
Lst_ForEachFrom(tGn->children, ln, SuffExpandChildren, tGn);
}
/*
* Keep track of another parent to which this beast is transformed so
* the .IMPSRC variable can be set correctly for the parent.
*/
Lst_AtEnd(sGn->iParents, (void *)tGn);
Lst_AtEnd(sGn->iParents, tGn);
return (TRUE);
}
@ -1629,9 +1630,9 @@ SuffFindArchiveDeps(GNode *gn, Lst slst)
/*
* Create the link between the two nodes right off
*/
if (Lst_Member(gn->children, (void *)mem) == NULL) {
Lst_AtEnd(gn->children, (void *)mem);
Lst_AtEnd(mem->parents, (void *)gn);
if (Lst_Member(gn->children, mem) == NULL) {
Lst_AtEnd(gn->children, mem);
Lst_AtEnd(mem->parents, gn);
gn->unmade += 1;
}
@ -1679,7 +1680,7 @@ SuffFindArchiveDeps(GNode *gn, Lst slst)
/*
* Got one -- apply it
*/
if (!SuffApplyTransform(gn, mem, (Suff *)Lst_Datum(ln), ms)) {
if (!SuffApplyTransform(gn, mem, Lst_Datum(ln), ms)) {
DEBUGF(SUFF, ("\tNo transformation from %s -> %s\n",
ms->name, ((Suff *)Lst_Datum(ln))->name));
}
@ -1780,12 +1781,12 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
/*
* Allocate a Src structure to which things can be transformed
*/
target = (Src *)emalloc(sizeof(Src));
target = emalloc(sizeof(Src));
target->file = estrdup(gn->name);
target->suff = (Suff *)Lst_Datum(ln);
target->suff = Lst_Datum(ln);
target->suff->refCount++;
target->node = gn;
target->parent = (Src *)NULL;
target->parent = NULL;
target->children = 0;
#ifdef DEBUG_SRC
target->cp = Lst_Init(FALSE);
@ -1808,7 +1809,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
/*
* Record the target so we can nuke it
*/
Lst_AtEnd(targs, (void *)target);
Lst_AtEnd(targs, target);
/*
* Search from this suffix's successor...
@ -1823,12 +1824,12 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
if (Lst_IsEmpty(targs) && suffNull != NULL) {
DEBUGF(SUFF, ("\tNo known suffix on %s. Using .NULL suffix\n", gn->name));
targ = (Src *)emalloc(sizeof(Src));
targ = emalloc(sizeof(Src));
targ->file = estrdup(gn->name);
targ->suff = suffNull;
targ->suff->refCount++;
targ->node = gn;
targ->parent = (Src *)NULL;
targ->parent = NULL;
targ->children = 0;
targ->pref = estrdup(sopref);
#ifdef DEBUG_SRC
@ -1847,7 +1848,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
DEBUGF(SUFF, ("adding suffix rules\n"));
Lst_AtEnd(targs, (void *)targ);
Lst_AtEnd(targs, targ);
}
/*
@ -1856,15 +1857,15 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
*/
bottom = SuffFindThem(srcs, slst);
if (bottom == (Src *)NULL) {
if (bottom == NULL) {
/*
* No known transformations -- use the first suffix found for setting
* the local variables.
*/
if (!Lst_IsEmpty(targs)) {
targ = (Src *)Lst_Datum(Lst_First(targs));
targ = Lst_Datum(Lst_First(targs));
} else {
targ = (Src *)NULL;
targ = NULL;
}
} else {
/*
@ -1984,14 +1985,14 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
if (!Lst_IsEmpty(gn->children)) {
src = SuffFindCmds(targ, slst);
if (src != (Src *)NULL) {
if (src != NULL) {
/*
* Free up all the Src structures in the transformation path
* up to, but not including, the parent node.
*/
while (bottom && bottom->parent != NULL) {
if (Lst_Member(slst, (void *)bottom) == NULL) {
Lst_AtEnd(slst, (void *)bottom);
if (Lst_Member(slst, bottom) == NULL) {
Lst_AtEnd(slst, bottom);
}
bottom = bottom->parent;
}
@ -2022,7 +2023,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
bottom->node = Targ_FindNode(bottom->file, TARG_CREATE);
}
for (src = bottom; src->parent != (Src *)NULL; src = src->parent) {
for (src = bottom; src->parent != NULL; src = src->parent) {
targ = src->parent;
if (src->node->suffix)
@ -2072,8 +2073,8 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
*/
sfnd_return:
if (bottom)
if (Lst_Member(slst, (void *)bottom) == NULL)
Lst_AtEnd(slst, (void *)bottom);
if (Lst_Member(slst, bottom) == NULL)
Lst_AtEnd(slst, bottom);
while (SuffRemoveSrc(srcs) || SuffRemoveSrc(targs))
continue;
@ -2148,11 +2149,11 @@ SuffFindDeps(GNode *gn, Lst slst)
LstNode ln;
Suff *s;
ln = Lst_Find(sufflist, (void *)LIBSUFF, SuffSuffHasNameP);
ln = Lst_Find(sufflist, LIBSUFF, SuffSuffHasNameP);
if (gn->suffix)
gn->suffix->refCount--;
if (ln != NULL) {
gn->suffix = s = (Suff *)Lst_Datum (ln);
gn->suffix = s = Lst_Datum (ln);
gn->suffix->refCount++;
Arch_FindLib(gn, s->searchPath);
} else {
@ -2193,10 +2194,10 @@ Suff_SetNull(char *name)
Suff *s;
LstNode ln;
ln = Lst_Find(sufflist, (void *)name, SuffSuffHasNameP);
ln = Lst_Find(sufflist, name, SuffSuffHasNameP);
if (ln != NULL) {
s = (Suff *)Lst_Datum(ln);
if (suffNull != (Suff *)NULL) {
s = Lst_Datum(ln);
if (suffNull != NULL) {
suffNull->flags &= ~SUFF_NULL;
}
s->flags |= SUFF_NULL;
@ -2237,7 +2238,7 @@ Suff_Init(void)
* actually go on the suffix list or everyone will think that's its
* suffix.
*/
emptySuff = suffNull = (Suff *)emalloc(sizeof(Suff));
emptySuff = suffNull = emalloc(sizeof(Suff));
suffNull->name = estrdup("");
suffNull->nameLen = 0;
@ -2289,7 +2290,7 @@ SuffPrintName(void *s, void *dummy __unused)
static int
SuffPrintSuff(void *sp, void *dummy __unused)
{
Suff *s = (Suff *)sp;
Suff *s = sp;
int flags;
int flag;
@ -2319,10 +2320,10 @@ SuffPrintSuff(void *sp, void *dummy __unused)
}
fputc('\n', stdout);
printf("#\tTo: ");
Lst_ForEach (s->parents, SuffPrintName, (void *)0);
Lst_ForEach(s->parents, SuffPrintName, (void *)NULL);
fputc('\n', stdout);
printf("#\tFrom: ");
Lst_ForEach (s->children, SuffPrintName, (void *)0);
Lst_ForEach(s->children, SuffPrintName, (void *)NULL);
fputc('\n', stdout);
printf("#\tSearch Path: ");
Dir_PrintPath(s->searchPath);
@ -2333,12 +2334,12 @@ SuffPrintSuff(void *sp, void *dummy __unused)
static int
SuffPrintTrans(void *tp, void *dummy __unused)
{
GNode *t = (GNode *)tp;
GNode *t = tp;
printf("%-16s: ", t->name);
Targ_PrintType(t->type);
fputc('\n', stdout);
Lst_ForEach(t->commands, Targ_PrintCmd, (void *)0);
Lst_ForEach(t->commands, Targ_PrintCmd, (void *)NULL);
fputc('\n', stdout);
return (0);
}
@ -2348,8 +2349,8 @@ Suff_PrintAll(void)
{
printf("#*** Suffixes:\n");
Lst_ForEach(sufflist, SuffPrintSuff, (void *)0);
Lst_ForEach(sufflist, SuffPrintSuff, (void *)NULL);
printf("#*** Transformations:\n");
Lst_ForEach(transforms, SuffPrintTrans, (void *)0);
Lst_ForEach(transforms, SuffPrintTrans, (void *)NULL);
}

View File

@ -159,9 +159,9 @@ Targ_NewGN(char *name)
{
GNode *gn;
gn = (GNode *)emalloc(sizeof(GNode));
gn = emalloc(sizeof(GNode));
gn->name = estrdup(name);
gn->path = (char *)0;
gn->path = NULL;
if (name[0] == '-' && name[1] == 'l') {
gn->type = OP_LIB;
} else {
@ -205,7 +205,7 @@ Targ_NewGN(char *name)
static void
TargFreeGN(void *gnp)
{
GNode *gn = (GNode *) gnp;
GNode *gn = gnp;
free(gn->name);
free(gn->path);
@ -221,7 +221,6 @@ TargFreeGN(void *gnp)
free(gn);
}
/*-
*-----------------------------------------------------------------------
* Targ_FindNode --
@ -249,16 +248,16 @@ Targ_FindNode(char *name, int flags)
if (isNew) {
gn = Targ_NewGN(name);
Hash_SetValue (he, gn);
Lst_AtEnd(allTargets, (void *)gn);
Lst_AtEnd(allTargets, gn);
}
} else {
he = Hash_FindEntry(&targets, name);
}
if (he == (Hash_Entry *) NULL) {
if (he == NULL) {
return (NULL);
} else {
return ((GNode *)Hash_GetValue(he));
return (Hash_GetValue(he));
}
}
@ -291,7 +290,7 @@ Targ_FindList(Lst names, int flags)
return (nodes);
}
while ((ln = Lst_Next(names)) != NULL) {
name = (char *)Lst_Datum(ln);
name = Lst_Datum(ln);
gn = Targ_FindNode(name, flags);
if (gn != NULL) {
/*
@ -299,7 +298,7 @@ Targ_FindList(Lst names, int flags)
* are added to the list in the order in which they were
* encountered in the makefile.
*/
Lst_AtEnd(nodes, (void *)gn);
Lst_AtEnd(nodes, gn);
if (gn->type & OP_DOUBLEDEP) {
Lst_Concat(nodes, gn->cohorts, LST_CONCNEW);
}
@ -513,7 +512,7 @@ Targ_PrintType(int type)
static int
TargPrintNode(void *gnp, void *passp)
{
GNode *gn = (GNode *)gnp;
GNode *gn = gnp;
int pass = *(int *)passp;
if (!OP_NOP(gn->type)) {
@ -527,7 +526,7 @@ TargPrintNode(void *gnp, void *passp)
} else {
printf("# No unmade children\n");
}
if (! (gn->type & (OP_JOIN|OP_USE|OP_EXEC))) {
if (!(gn->type & (OP_JOIN | OP_USE | OP_EXEC))) {
if (gn->mtime != 0) {
printf("# last modified %s: %s\n",
Targ_FmtTime(gn->mtime),
@ -547,13 +546,13 @@ TargPrintNode(void *gnp, void *passp)
}
if (!Lst_IsEmpty (gn->iParents)) {
printf("# implicit parents: ");
Lst_ForEach(gn->iParents, TargPrintName, (void *)0);
Lst_ForEach(gn->iParents, TargPrintName, (void *)NULL);
fputc('\n', stdout);
}
}
if (!Lst_IsEmpty (gn->parents)) {
printf("# parents: ");
Lst_ForEach(gn->parents, TargPrintName, (void *)0);
Lst_ForEach(gn->parents, TargPrintName, (void *)NULL);
fputc('\n', stdout);
}
@ -569,12 +568,12 @@ TargPrintNode(void *gnp, void *passp)
break;
}
Targ_PrintType(gn->type);
Lst_ForEach(gn->children, TargPrintName, (void *)0);
Lst_ForEach(gn->children, TargPrintName, (void *)NULL);
fputc('\n', stdout);
Lst_ForEach(gn->commands, Targ_PrintCmd, (void *)0);
Lst_ForEach(gn->commands, Targ_PrintCmd, (void *)NULL);
printf("\n\n");
if (gn->type & OP_DOUBLEDEP) {
Lst_ForEach(gn->cohorts, TargPrintNode, (void *)&pass);
Lst_ForEach(gn->cohorts, TargPrintNode, &pass);
}
}
return (0);
@ -596,7 +595,7 @@ TargPrintNode(void *gnp, void *passp)
static int
TargPrintOnlySrc(void *gnp, void *dummy __unused)
{
GNode *gn = (GNode *)gnp;
GNode *gn = gnp;
if (OP_NOP(gn->type))
printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name);
@ -619,11 +618,12 @@ TargPrintOnlySrc(void *gnp, void *dummy __unused)
void
Targ_PrintGraph(int pass)
{
printf("#*** Input graph:\n");
Lst_ForEach(allTargets, TargPrintNode, (void *)&pass);
Lst_ForEach(allTargets, TargPrintNode, &pass);
printf("\n\n");
printf("#\n# Files that are only sources:\n");
Lst_ForEach(allTargets, TargPrintOnlySrc, (void *)0);
Lst_ForEach(allTargets, TargPrintOnlySrc, (void *)NULL);
printf("#*** Global Variables:\n");
Var_Dump(VAR_GLOBAL);
printf("#*** Command-line Variables:\n");

View File

@ -159,7 +159,7 @@ static int
VarCmp(void *v, void *name)
{
return (strcmp((char *)name, ((Var *)v)->name));
return (strcmp(name, ((Var *)v)->name));
}
/*-
@ -250,9 +250,7 @@ VarFind(char *name, GNode *ctxt, int flags)
* Note whether this is one of the specific variables we were told through
* the -E flag to use environment-variable-override for.
*/
if (Lst_Find(envFirstVars, (void *)name,
(int (*)(void *, void *)) strcmp) != NULL)
{
if (Lst_Find(envFirstVars, name, (CompareProc *)strcmp) != NULL) {
localCheckEnvFirst = TRUE;
} else {
localCheckEnvFirst = FALSE;
@ -263,15 +261,15 @@ VarFind(char *name, GNode *ctxt, int flags)
* look for it in VAR_CMD, VAR_GLOBAL and the environment, in that order,
* depending on the FIND_* flags in 'flags'
*/
var = Lst_Find(ctxt->context, (void *)name, VarCmp);
var = Lst_Find(ctxt->context, name, VarCmp);
if ((var == NULL) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) {
var = Lst_Find(VAR_CMD->context, (void *)name, VarCmp);
var = Lst_Find(VAR_CMD->context, name, VarCmp);
}
if ((var == NULL) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL) &&
!checkEnvFirst && !localCheckEnvFirst)
{
var = Lst_Find(VAR_GLOBAL->context, (void *)name, VarCmp);
var = Lst_Find(VAR_GLOBAL->context, name, VarCmp);
}
if ((var == NULL) && (flags & FIND_ENV)) {
char *env;
@ -279,7 +277,7 @@ VarFind(char *name, GNode *ctxt, int flags)
if ((env = getenv(name)) != NULL) {
int len;
v = (Var *)emalloc(sizeof(Var));
v = emalloc(sizeof(Var));
v->name = estrdup(name);
len = strlen(env);
@ -292,19 +290,19 @@ VarFind(char *name, GNode *ctxt, int flags)
} else if ((checkEnvFirst || localCheckEnvFirst) &&
(flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL))
{
var = Lst_Find(VAR_GLOBAL->context, (void *)name, VarCmp);
var = Lst_Find(VAR_GLOBAL->context, name, VarCmp);
if (var == NULL) {
return ((Var *)NULL);
return (NULL);
} else {
return ((Var *)Lst_Datum(var));
return (Lst_Datum(var));
}
} else {
return ((Var *)NULL);
return (NULL);
}
} else if (var == NULL) {
return ((Var *)NULL);
return (NULL);
} else {
return ((Var *)Lst_Datum(var));
return (Lst_Datum(var));
}
}
@ -328,7 +326,7 @@ VarAdd(char *name, char *val, GNode *ctxt)
Var *v;
int len;
v = (Var *)emalloc(sizeof(Var));
v = emalloc(sizeof(Var));
v->name = estrdup(name);
@ -338,8 +336,8 @@ VarAdd(char *name, char *val, GNode *ctxt)
v->flags = 0;
Lst_AtFront(ctxt->context, (void *)v);
Lst_AtEnd(allVars, (void *)v);
Lst_AtFront(ctxt->context, v);
Lst_AtEnd(allVars, v);
DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val));
}
@ -358,7 +356,7 @@ VarAdd(char *name, char *val, GNode *ctxt)
static void
VarDelete(void *vp)
{
Var *v = (Var *)vp;
Var *v = vp;
free(v->name);
Buf_Destroy(v->val, TRUE);
@ -384,15 +382,15 @@ Var_Delete(char *name, GNode *ctxt)
LstNode ln;
DEBUGF(VAR, ("%s:delete %s\n", ctxt->name, name));
ln = Lst_Find(ctxt->context, (void *)name, VarCmp);
ln = Lst_Find(ctxt->context, name, VarCmp);
if (ln != NULL) {
Var *v;
v = (Var *)Lst_Datum(ln);
v = Lst_Datum(ln);
Lst_Remove(ctxt->context, ln);
ln = Lst_Member(allVars, v);
Lst_Remove(allVars, ln);
VarDelete((void *)v);
VarDelete(v);
}
}
@ -429,7 +427,7 @@ Var_Set(char *name, char *val, GNode *ctxt)
*/
VarPossiblyExpand(&name, ctxt);
v = VarFind(name, ctxt, 0);
if (v == (Var *)NULL) {
if (v == NULL) {
VarAdd(name, val, ctxt);
} else {
Buf_Discard(v->val, Buf_Size(v->val));
@ -477,7 +475,7 @@ Var_Append(char *name, char *val, GNode *ctxt)
VarPossiblyExpand(&name, ctxt);
v = VarFind(name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0);
if (v == (Var *)NULL) {
if (v == NULL) {
VarAdd(name, val, ctxt);
} else {
Buf_AddByte(v->val, (Byte)' ');
@ -494,7 +492,7 @@ Var_Append(char *name, char *val, GNode *ctxt)
* export other variables...)
*/
v->flags &= ~VAR_FROM_ENV;
Lst_AtFront(ctxt->context, (void *)v);
Lst_AtFront(ctxt->context, v);
}
}
free(name);
@ -522,12 +520,12 @@ Var_Exists(char *name, GNode *ctxt)
v = VarFind(name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV);
free(name);
if (v == (Var *)NULL) {
if (v == NULL) {
return (FALSE);
} else if (v->flags & VAR_FROM_ENV) {
free(v->name);
Buf_Destroy(v->val, TRUE);
free((char *)v);
free(v);
}
return (TRUE);
}
@ -553,8 +551,9 @@ Var_Value(char *name, GNode *ctxt, char **frp)
v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
free(name);
*frp = NULL;
if (v != (Var *) NULL) {
char *p = ((char *)Buf_GetAll(v->val, (int *)NULL));
if (v != NULL) {
char *p = (char *)Buf_GetAll(v->val, (int *)NULL);
if (v->flags & VAR_FROM_ENV) {
Buf_Destroy(v->val, FALSE);
free(v);
@ -562,7 +561,7 @@ Var_Value(char *name, GNode *ctxt, char **frp)
}
return (p);
} else {
return ((char *)NULL);
return (NULL);
}
}
@ -631,7 +630,7 @@ VarSortWords(char *str, int (*cmp)(const void *, const void *))
buf = Buf_Init(0);
av = brk_string(str, &ac, FALSE);
qsort((void*)(av + 1), ac - 1, sizeof(char*), cmp);
qsort(av + 1, ac - 1, sizeof(char *), cmp);
for (i = 1; i < ac; i++) {
Buf_AddBytes(buf, strlen(av[i]), (Byte *)av[i]);
Buf_AddByte(buf, (Byte)((i < ac - 1) ? ' ' : '\0'));
@ -970,7 +969,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
*tstr = '\0';
Buf_AddByte(buf, (Byte)'\0');
str = Buf_GetAll(buf, NULL);
str = Buf_GetAll(buf, (int *)NULL);
vlen = strlen(str);
v = VarFind(str, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
@ -999,7 +998,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
vname[1] = '\0';
v = VarFind(vname, ctxt, 0);
if (v != (Var *)NULL && !haveModifier) {
if (v != NULL && !haveModifier) {
/*
* No need for nested expansion or anything, as we're
* the only one who sets these things and we sure don't
@ -1008,9 +1007,9 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
val = (char *)Buf_GetAll(v->val, (int *)NULL);
if (str[1] == 'D') {
val = VarModify(val, VarHead, (void *)0);
val = VarModify(val, VarHead, (void *)NULL);
} else {
val = VarModify(val, VarTail, (void *)0);
val = VarModify(val, VarTail, (void *)NULL);
}
/*
* Resulting string is dynamically allocated, so
@ -1092,7 +1091,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
* Still need to get to the end of the variable specification,
* so kludge up a Var structure for the modifications
*/
v = (Var *)emalloc(sizeof(Var));
v = emalloc(sizeof(Var));
v->name = estrdup(str);
v->val = Buf_Init(1);
v->flags = VAR_JUNK;
@ -1145,7 +1144,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
* :U Converts variable to upper-case.
* :L Converts variable to lower-case.
*/
if ((str != (char *)NULL) && haveModifier) {
if ((str != NULL) && haveModifier) {
/*
* Skip initial colon while putting it back.
*/
@ -1199,9 +1198,9 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
pattern = &tstr[1];
}
if (*tstr == 'M' || *tstr == 'm') {
newStr = VarModify(str, VarMatch, (void *)pattern);
newStr = VarModify(str, VarMatch, pattern);
} else {
newStr = VarModify(str, VarNoMatch, (void *)pattern);
newStr = VarModify(str, VarNoMatch, pattern);
}
if (copy) {
free(pattern);
@ -1371,7 +1370,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
Fatal("Global substitution of the empty string");
termc = *cp;
newStr = VarModify(str, VarSubstitute, (void *)&pattern);
newStr = VarModify(str, VarSubstitute, &pattern);
/*
* Free the two strings.
*/
@ -1449,8 +1448,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
pattern.nsub = 10;
pattern.matches = emalloc(pattern.nsub *
sizeof(regmatch_t));
newStr = VarModify(str, VarRESubstitute,
(void *) &pattern);
newStr = VarModify(str, VarRESubstitute, &pattern);
regfree(&pattern.re);
free(pattern.replace);
free(pattern.matches);
@ -1490,7 +1488,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
/*FALLTHRU*/
case 'T':
if (tstr[1] == endc || tstr[1] == ':') {
newStr = VarModify(str, VarTail, (void *)0);
newStr = VarModify(str, VarTail, (void *)NULL);
cp = tstr + 1;
termc = *cp;
break;
@ -1514,7 +1512,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
/* FALLTHROUGH */
case 'H':
if (tstr[1] == endc || tstr[1] == ':') {
newStr = VarModify(str, VarHead, (void *)0);
newStr = VarModify(str, VarHead, (void *)NULL);
cp = tstr + 1;
termc = *cp;
break;
@ -1522,7 +1520,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
/*FALLTHRU*/
case 'E':
if (tstr[1] == endc || tstr[1] == ':') {
newStr = VarModify(str, VarSuffix, (void *)0);
newStr = VarModify(str, VarSuffix, (void *)NULL);
cp = tstr + 1;
termc = *cp;
break;
@ -1530,7 +1528,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
/*FALLTHRU*/
case 'R':
if (tstr[1] == endc || tstr[1] == ':') {
newStr = VarModify(str, VarRoot, (void *)0);
newStr = VarModify(str, VarRoot, (void *)NULL);
cp = tstr + 1;
termc = *cp;
break;
@ -1622,7 +1620,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
*/
termc = *--cp;
delim = '\0';
newStr = VarModify(str, VarSYSVMatch, (void *)&pattern);
newStr = VarModify(str, VarSYSVMatch, &pattern);
free(pattern.lhs);
free(pattern.rhs);
@ -1886,7 +1884,7 @@ char *
Var_GetTail(char *file)
{
return (VarModify(file, VarTail, (void *)0));
return (VarModify(file, VarTail, (void *)NULL));
}
/*-
@ -1908,7 +1906,7 @@ char *
Var_GetHead(char *file)
{
return (VarModify(file, VarHead, (void *)0));
return (VarModify(file, VarHead, (void *)NULL));
}
/*-
@ -1961,5 +1959,5 @@ void
Var_Dump(GNode *ctxt)
{
Lst_ForEach (ctxt->context, VarPrintVar, (void *)0);
Lst_ForEach (ctxt->context, VarPrintVar, (void *)NULL);
}

View File

@ -148,11 +148,11 @@ VarSuffix(const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
const char *dot;
dot = strrchr(word, '.');
if (dot++ != (char *)NULL) {
if (dot++ != NULL) {
if (addSpace) {
Buf_AddByte(buf, (Byte)' ');
}
Buf_AddBytes(buf, strlen (dot), (Byte *)dot);
Buf_AddBytes(buf, strlen(dot), (Byte *)dot);
addSpace = TRUE;
}
return (addSpace);
@ -256,7 +256,7 @@ VarSYSVMatch(const char *word, Boolean addSpace, Buffer buf, void *patp)
if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL)
Str_SYSVSubst(buf, pat->rhs, ptr, len);
else
Buf_AddBytes(buf, strlen(word), (Byte *) word);
Buf_AddBytes(buf, strlen(word), (Byte *)word);
return (addSpace);
}
@ -313,7 +313,7 @@ VarSubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp)
{
int wordLen; /* Length of word */
const char *cp; /* General pointer */
VarPattern *pattern = (VarPattern *)patternp;
VarPattern *pattern = patternp;
wordLen = strlen(word);
if (1) { /* substitute in each word of the variable */
@ -414,7 +414,7 @@ VarSubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp)
origSize = Buf_Size(buf);
while (!done) {
cp = strstr(word, pattern->lhs);
if (cp != (char *)NULL) {
if (cp != NULL) {
if (addSpace && (((cp - word) + pattern->rightLen) != 0)){
Buf_AddByte(buf, (Byte)' ');
addSpace = FALSE;
@ -481,17 +481,17 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp)
int added;
int flags = 0;
#define MAYBE_ADD_SPACE() \
if (addSpace && !added) \
Buf_AddByte(buf, ' '); \
#define MAYBE_ADD_SPACE() \
if (addSpace && !added) \
Buf_AddByte(buf, (Byte)' '); \
added = 1
added = 0;
wp = word;
pat = patternp;
if ((pat->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) ==
(VAR_SUB_ONE|VAR_SUB_MATCHED))
if ((pat->flags & (VAR_SUB_ONE | VAR_SUB_MATCHED)) ==
(VAR_SUB_ONE | VAR_SUB_MATCHED))
xrv = REG_NOMATCH;
else {
tryagain:
@ -503,13 +503,13 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp)
pat->flags |= VAR_SUB_MATCHED;
if (pat->matches[0].rm_so > 0) {
MAYBE_ADD_SPACE();
Buf_AddBytes(buf, pat->matches[0].rm_so, wp);
Buf_AddBytes(buf, pat->matches[0].rm_so, (Byte *)wp);
}
for (rp = pat->replace; *rp; rp++) {
if ((*rp == '\\') && ((rp[1] == '&') || (rp[1] == '\\'))) {
MAYBE_ADD_SPACE();
Buf_AddByte(buf,rp[1]);
Buf_AddByte(buf, (Byte)rp[1]);
rp++;
}
else if ((*rp == '&') ||
@ -547,11 +547,11 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp)
if (sublen > 0) {
MAYBE_ADD_SPACE();
Buf_AddBytes(buf, sublen, subbuf);
Buf_AddBytes(buf, sublen, (Byte *)subbuf);
}
} else {
MAYBE_ADD_SPACE();
Buf_AddByte(buf, *rp);
Buf_AddByte(buf, (Byte)*rp);
}
}
wp += pat->matches[0].rm_eo;
@ -559,7 +559,7 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp)
flags |= REG_NOTBOL;
if (pat->matches[0].rm_so == 0 && pat->matches[0].rm_eo == 0) {
MAYBE_ADD_SPACE();
Buf_AddByte(buf, *wp);
Buf_AddByte(buf, (Byte)*wp);
wp++;
}
@ -568,7 +568,7 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp)
}
if (*wp) {
MAYBE_ADD_SPACE();
Buf_AddBytes(buf, strlen(wp), wp);
Buf_AddBytes(buf, strlen(wp), (Byte *)wp);
}
break;
default:
@ -577,9 +577,9 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp)
case REG_NOMATCH:
if (*wp) {
MAYBE_ADD_SPACE();
Buf_AddBytes(buf,strlen(wp),wp);
Buf_AddBytes(buf, strlen(wp), (Byte *)wp);
}
break;
}
return (addSpace||added);
return (addSpace || added);
}