mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-19 14:54:24 +00:00
Stylification: missing spaces, extra space after function names, casts
and the sizeof operator, missing empty lines, void casts, extra empty lines. Checked by: diff on make *.o lst.lib/*.o Submitted by: Max Okumoto <okumoto@soe.ucsd.edu> (partly)
This commit is contained in:
parent
f14eed08c0
commit
e6417f6fe2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=138232
|
@ -138,7 +138,7 @@ static int ArchSVR4Entry(Arch *, char *, size_t, FILE *);
|
|||
static void
|
||||
ArchFree(void *ap)
|
||||
{
|
||||
Arch *a = (Arch *) ap;
|
||||
Arch *a = (Arch *)ap;
|
||||
Hash_Search search;
|
||||
Hash_Entry *entry;
|
||||
|
||||
|
@ -154,8 +154,6 @@ ArchFree(void *ap)
|
|||
free(a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Arch_ParseArchive --
|
||||
|
@ -176,7 +174,7 @@ ArchFree(void *ap)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
||||
Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
|
||||
{
|
||||
char *cp; /* Pointer into line */
|
||||
GNode *gn; /* New node */
|
||||
|
@ -201,9 +199,9 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
Boolean freeIt;
|
||||
char *result;
|
||||
|
||||
result=Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
|
||||
result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
|
||||
if (result == var_Error) {
|
||||
return(FAILURE);
|
||||
return (FAILURE);
|
||||
} else {
|
||||
subLibName = TRUE;
|
||||
}
|
||||
|
@ -211,7 +209,7 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
if (freeIt) {
|
||||
free(result);
|
||||
}
|
||||
cp += length-1;
|
||||
cp += length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,11 +227,11 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
*/
|
||||
Boolean doSubst = FALSE; /* TRUE if need to substitute in memName */
|
||||
|
||||
while (*cp != '\0' && *cp != ')' && isspace ((unsigned char) *cp)) {
|
||||
while (*cp != '\0' && *cp != ')' && isspace((unsigned char)*cp)) {
|
||||
cp++;
|
||||
}
|
||||
memName = cp;
|
||||
while (*cp != '\0' && *cp != ')' && !isspace ((unsigned char) *cp)) {
|
||||
while (*cp != '\0' && *cp != ')' && !isspace((unsigned char)*cp)) {
|
||||
if (*cp == '$') {
|
||||
/*
|
||||
* Variable spec, so call the Var module to parse the puppy
|
||||
|
@ -245,7 +243,7 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
|
||||
result=Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
|
||||
if (result == var_Error) {
|
||||
return(FAILURE);
|
||||
return (FAILURE);
|
||||
} else {
|
||||
doSubst = TRUE;
|
||||
}
|
||||
|
@ -320,18 +318,18 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
|
||||
if (gn == NULL) {
|
||||
free(buf);
|
||||
return(FAILURE);
|
||||
return (FAILURE);
|
||||
} else {
|
||||
gn->type |= OP_ARCHV;
|
||||
(void)Lst_AtEnd(nodeLst, (void *)gn);
|
||||
Lst_AtEnd(nodeLst, (void *)gn);
|
||||
}
|
||||
} else if (Arch_ParseArchive(&sacrifice, nodeLst, ctxt)!=SUCCESS) {
|
||||
} else if (Arch_ParseArchive(&sacrifice, nodeLst, ctxt) != SUCCESS) {
|
||||
/*
|
||||
* Error in nested call -- free buffer and return FAILURE
|
||||
* ourselves.
|
||||
*/
|
||||
free(buf);
|
||||
return(FAILURE);
|
||||
return (FAILURE);
|
||||
}
|
||||
/*
|
||||
* Free buffer and continue with our work.
|
||||
|
@ -356,7 +354,7 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
|
||||
snprintf(nameBuf, sz, "%s(%s)", libName, member);
|
||||
free(member);
|
||||
gn = Targ_FindNode (nameBuf, TARG_CREATE);
|
||||
gn = Targ_FindNode(nameBuf, TARG_CREATE);
|
||||
if (gn == NULL) {
|
||||
free(nameBuf);
|
||||
return (FAILURE);
|
||||
|
@ -369,7 +367,7 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
* end of the provided list.
|
||||
*/
|
||||
gn->type |= OP_ARCHV;
|
||||
(void) Lst_AtEnd (nodeLst, (void *)gn);
|
||||
Lst_AtEnd(nodeLst, (void *)gn);
|
||||
}
|
||||
}
|
||||
Lst_Destroy(members, NOFREE);
|
||||
|
@ -378,7 +376,7 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
size_t sz = strlen(libName) + strlen(memName) + 3;
|
||||
nameBuf = emalloc(sz);
|
||||
snprintf(nameBuf, sz, "%s(%s)", libName, memName);
|
||||
gn = Targ_FindNode (nameBuf, TARG_CREATE);
|
||||
gn = Targ_FindNode(nameBuf, TARG_CREATE);
|
||||
free(nameBuf);
|
||||
if (gn == NULL) {
|
||||
return (FAILURE);
|
||||
|
@ -391,7 +389,7 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
* provided list.
|
||||
*/
|
||||
gn->type |= OP_ARCHV;
|
||||
(void) Lst_AtEnd (nodeLst, (void *)gn);
|
||||
Lst_AtEnd(nodeLst, (void *)gn);
|
||||
}
|
||||
}
|
||||
if (doSubst) {
|
||||
|
@ -415,7 +413,7 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
*/
|
||||
do {
|
||||
cp++;
|
||||
} while (*cp != '\0' && isspace ((unsigned char) *cp));
|
||||
} while (*cp != '\0' && isspace((unsigned char)*cp));
|
||||
|
||||
*linePtr = cp;
|
||||
return (SUCCESS);
|
||||
|
@ -437,9 +435,9 @@ Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
ArchFindArchive (void *ar, void *archName)
|
||||
ArchFindArchive(void *ar, void *archName)
|
||||
{
|
||||
return (strcmp ((char *) archName, ((Arch *) ar)->name));
|
||||
return (strcmp((char *)archName, ((Arch *)ar)->name));
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -461,9 +459,9 @@ ArchFindArchive (void *ar, void *archName)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static struct ar_hdr *
|
||||
ArchStatMember (char *archive, char *member, Boolean hash)
|
||||
ArchStatMember(char *archive, char *member, Boolean hash)
|
||||
{
|
||||
#define AR_MAX_NAME_LEN (sizeof(arh.ar_name)-1)
|
||||
#define AR_MAX_NAME_LEN (sizeof(arh.ar_name) - 1)
|
||||
FILE * arch; /* Stream to archive */
|
||||
int size; /* Size of archive member */
|
||||
char *cp; /* Useful character pointer */
|
||||
|
@ -472,7 +470,7 @@ ArchStatMember (char *archive, char *member, Boolean hash)
|
|||
Arch *ar; /* Archive descriptor */
|
||||
Hash_Entry *he; /* Entry containing member's description */
|
||||
struct ar_hdr arh; /* archive-member header for reading archive */
|
||||
char memName[MAXPATHLEN+1];
|
||||
char memName[MAXPATHLEN + 1];
|
||||
/* Current member name while hashing. */
|
||||
|
||||
/*
|
||||
|
@ -481,30 +479,30 @@ ArchStatMember (char *archive, char *member, Boolean hash)
|
|||
* to point 'member' to the final component, if there is one, to make
|
||||
* the comparisons easier...
|
||||
*/
|
||||
cp = strrchr (member, '/');
|
||||
cp = strrchr(member, '/');
|
||||
if ((cp != NULL) && (strcmp(member, RANLIBMAG) != 0))
|
||||
member = cp + 1;
|
||||
|
||||
ln = Lst_Find (archives, (void *) archive, ArchFindArchive);
|
||||
ln = Lst_Find(archives, (void *)archive, ArchFindArchive);
|
||||
if (ln != NULL) {
|
||||
ar = (Arch *) Lst_Datum (ln);
|
||||
ar = (Arch *)Lst_Datum(ln);
|
||||
|
||||
he = Hash_FindEntry (&ar->members, member);
|
||||
he = Hash_FindEntry(&ar->members, member);
|
||||
|
||||
if (he != NULL) {
|
||||
return ((struct ar_hdr *) Hash_GetValue (he));
|
||||
return ((struct ar_hdr *)Hash_GetValue (he));
|
||||
} else {
|
||||
/* Try truncated name */
|
||||
char copy[AR_MAX_NAME_LEN+1];
|
||||
size_t len = strlen (member);
|
||||
char copy[AR_MAX_NAME_LEN + 1];
|
||||
size_t len = strlen(member);
|
||||
|
||||
if (len > AR_MAX_NAME_LEN) {
|
||||
len = AR_MAX_NAME_LEN;
|
||||
strncpy(copy, member, AR_MAX_NAME_LEN);
|
||||
copy[AR_MAX_NAME_LEN] = '\0';
|
||||
}
|
||||
if ((he = Hash_FindEntry (&ar->members, copy)) != NULL)
|
||||
return ((struct ar_hdr *) Hash_GetValue (he));
|
||||
if ((he = Hash_FindEntry(&ar->members, copy)) != NULL)
|
||||
return ((struct ar_hdr *)Hash_GetValue(he));
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +531,7 @@ ArchStatMember (char *archive, char *member, Boolean hash)
|
|||
* We don't have this archive on the list yet, so we want to find out
|
||||
* everything that's in it and cache it so we can get at it quickly.
|
||||
*/
|
||||
arch = fopen (archive, "r");
|
||||
arch = fopen(archive, "r");
|
||||
if (arch == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -542,21 +540,21 @@ ArchStatMember (char *archive, char *member, Boolean hash)
|
|||
* We use the ARMAG string to make sure this is an archive we
|
||||
* can handle...
|
||||
*/
|
||||
if ((fread (magic, SARMAG, 1, arch) != 1) ||
|
||||
(strncmp (magic, ARMAG, SARMAG) != 0)) {
|
||||
fclose (arch);
|
||||
if ((fread(magic, SARMAG, 1, arch) != 1) ||
|
||||
(strncmp(magic, ARMAG, SARMAG) != 0)) {
|
||||
fclose(arch);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ar = (Arch *)emalloc (sizeof (Arch));
|
||||
ar->name = estrdup (archive);
|
||||
ar = (Arch *)emalloc(sizeof(Arch));
|
||||
ar->name = estrdup(archive);
|
||||
ar->fnametab = NULL;
|
||||
ar->fnamesize = 0;
|
||||
Hash_InitTable (&ar->members, -1);
|
||||
Hash_InitTable(&ar->members, -1);
|
||||
memName[AR_MAX_NAME_LEN] = '\0';
|
||||
|
||||
while (fread ((char *)&arh, sizeof (struct ar_hdr), 1, arch) == 1) {
|
||||
if (strncmp ( arh.ar_fmag, ARFMAG, sizeof (arh.ar_fmag)) != 0) {
|
||||
while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
|
||||
if (strncmp(arh.ar_fmag, ARFMAG, sizeof(arh.ar_fmag)) != 0) {
|
||||
/*
|
||||
* The header is bogus, so the archive is bad
|
||||
* and there's no way we can recover...
|
||||
|
@ -569,10 +567,10 @@ ArchStatMember (char *archive, char *member, Boolean hash)
|
|||
* boundary, so we need to extract the size of the file from the
|
||||
* 'size' field of the header and round it up during the seek.
|
||||
*/
|
||||
arh.ar_size[sizeof(arh.ar_size)-1] = '\0';
|
||||
size = (int) strtol(arh.ar_size, NULL, 10);
|
||||
arh.ar_size[sizeof(arh.ar_size) - 1] = '\0';
|
||||
size = (int)strtol(arh.ar_size, NULL, 10);
|
||||
|
||||
(void) strncpy (memName, arh.ar_name, sizeof(arh.ar_name));
|
||||
strncpy(memName, arh.ar_name, sizeof(arh.ar_name));
|
||||
for (cp = &memName[AR_MAX_NAME_LEN]; *cp == ' '; cp--) {
|
||||
continue;
|
||||
}
|
||||
|
@ -613,10 +611,10 @@ ArchStatMember (char *archive, char *member, Boolean hash)
|
|||
|
||||
if (elen > MAXPATHLEN)
|
||||
goto badarch;
|
||||
if (fread (memName, elen, 1, arch) != 1)
|
||||
if (fread(memName, elen, 1, arch) != 1)
|
||||
goto badarch;
|
||||
memName[elen] = '\0';
|
||||
fseek (arch, -elen, SEEK_CUR);
|
||||
fseek(arch, -elen, SEEK_CUR);
|
||||
/* XXX Multiple levels may be asked for, make this conditional
|
||||
* on one, and use DEBUGF.
|
||||
*/
|
||||
|
@ -626,35 +624,35 @@ 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));
|
||||
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));
|
||||
}
|
||||
fseek (arch, (size + 1) & ~1, SEEK_CUR);
|
||||
fseek(arch, (size + 1) & ~1, SEEK_CUR);
|
||||
}
|
||||
|
||||
fclose (arch);
|
||||
fclose(arch);
|
||||
|
||||
(void) Lst_AtEnd (archives, (void *) ar);
|
||||
Lst_AtEnd(archives, (void *)ar);
|
||||
|
||||
/*
|
||||
* Now that the archive has been read and cached, we can look into
|
||||
* the hash table to find the desired member's header.
|
||||
*/
|
||||
he = Hash_FindEntry (&ar->members, member);
|
||||
he = Hash_FindEntry(&ar->members, member);
|
||||
|
||||
if (he != NULL) {
|
||||
return ((struct ar_hdr *) Hash_GetValue (he));
|
||||
return ((struct ar_hdr *)Hash_GetValue (he));
|
||||
} else {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
badarch:
|
||||
fclose (arch);
|
||||
Hash_DeleteTable (&ar->members);
|
||||
fclose(arch);
|
||||
Hash_DeleteTable(&ar->members);
|
||||
free(ar->fnametab);
|
||||
free (ar);
|
||||
free(ar);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -692,7 +690,7 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch)
|
|||
|
||||
if (ar->fnametab != NULL) {
|
||||
DEBUGF(ARCH, ("Attempted to redefine an SVR4 name table\n"));
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -704,7 +702,7 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch)
|
|||
|
||||
if (fread(ar->fnametab, size, 1, arch) != 1) {
|
||||
DEBUGF(ARCH, ("Reading an SVR4 name table failed\n"));
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
eptr = ar->fnametab + size;
|
||||
for (entry = 0, ptr = ar->fnametab; ptr < eptr; ptr++)
|
||||
|
@ -721,28 +719,28 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch)
|
|||
break;
|
||||
}
|
||||
DEBUGF(ARCH, ("Found svr4 archive name table with %zu entries\n", entry));
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (name[1] == ' ' || name[1] == '\0')
|
||||
return 2;
|
||||
return (2);
|
||||
|
||||
entry = (size_t) strtol(&name[1], &eptr, 0);
|
||||
entry = (size_t)strtol(&name[1], &eptr, 0);
|
||||
if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) {
|
||||
DEBUGF(ARCH, ("Could not parse SVR4 name %s\n", name));
|
||||
return 2;
|
||||
return (2);
|
||||
}
|
||||
if (entry >= ar->fnamesize) {
|
||||
DEBUGF(ARCH, ("SVR4 entry offset %s is greater than %zu\n",
|
||||
name, ar->fnamesize));
|
||||
return 2;
|
||||
return (2);
|
||||
}
|
||||
|
||||
DEBUGF(ARCH, ("Replaced %s with %s\n", name, &ar->fnametab[entry]));
|
||||
|
||||
(void) strncpy(name, &ar->fnametab[entry], MAXPATHLEN);
|
||||
strncpy(name, &ar->fnametab[entry], MAXPATHLEN);
|
||||
name[MAXPATHLEN] = '\0';
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -766,7 +764,7 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static FILE *
|
||||
ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
||||
ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
||||
{
|
||||
FILE * arch; /* Stream to archive */
|
||||
int size; /* Size of archive member */
|
||||
|
@ -774,7 +772,7 @@ ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
|||
char magic[SARMAG];
|
||||
size_t len, tlen;
|
||||
|
||||
arch = fopen (archive, mode);
|
||||
arch = fopen(archive, mode);
|
||||
if (arch == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -783,9 +781,9 @@ ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
|||
* We use the ARMAG string to make sure this is an archive we
|
||||
* can handle...
|
||||
*/
|
||||
if ((fread (magic, SARMAG, 1, arch) != 1) ||
|
||||
(strncmp (magic, ARMAG, SARMAG) != 0)) {
|
||||
fclose (arch);
|
||||
if ((fread(magic, SARMAG, 1, arch) != 1) ||
|
||||
(strncmp(magic, ARMAG, SARMAG) != 0)) {
|
||||
fclose(arch);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -795,24 +793,24 @@ ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
|||
* to point 'member' to the final component, if there is one, to make
|
||||
* the comparisons easier...
|
||||
*/
|
||||
cp = strrchr (member, '/');
|
||||
cp = strrchr(member, '/');
|
||||
if ((cp != NULL) && (strcmp(member, RANLIBMAG) != 0)) {
|
||||
member = cp + 1;
|
||||
}
|
||||
len = tlen = strlen (member);
|
||||
if (len > sizeof (arhPtr->ar_name)) {
|
||||
tlen = sizeof (arhPtr->ar_name);
|
||||
len = tlen = strlen(member);
|
||||
if (len > sizeof(arhPtr->ar_name)) {
|
||||
tlen = sizeof(arhPtr->ar_name);
|
||||
}
|
||||
|
||||
while (fread ((char *)arhPtr, sizeof (struct ar_hdr), 1, arch) == 1) {
|
||||
if (strncmp(arhPtr->ar_fmag, ARFMAG, sizeof (arhPtr->ar_fmag) ) != 0) {
|
||||
while (fread((char *)arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) {
|
||||
if (strncmp(arhPtr->ar_fmag, ARFMAG, sizeof(arhPtr->ar_fmag) ) != 0) {
|
||||
/*
|
||||
* The header is bogus, so the archive is bad
|
||||
* and there's no way we can recover...
|
||||
*/
|
||||
fclose (arch);
|
||||
fclose(arch);
|
||||
return (NULL);
|
||||
} else if (strncmp (member, arhPtr->ar_name, tlen) == 0) {
|
||||
} else if (strncmp(member, arhPtr->ar_name, tlen) == 0) {
|
||||
/*
|
||||
* If the member's name doesn't take up the entire 'name' field,
|
||||
* we have to be careful of matching prefixes. Names are space-
|
||||
|
@ -830,7 +828,7 @@ ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
|||
* the file at the actual member, rather than its header, but
|
||||
* not here...
|
||||
*/
|
||||
fseek (arch, -sizeof(struct ar_hdr), SEEK_CUR);
|
||||
fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR);
|
||||
return (arch);
|
||||
}
|
||||
} else
|
||||
|
@ -847,11 +845,11 @@ ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
|||
char ename[MAXPATHLEN];
|
||||
|
||||
if (elen > MAXPATHLEN) {
|
||||
fclose (arch);
|
||||
fclose(arch);
|
||||
return NULL;
|
||||
}
|
||||
if (fread (ename, elen, 1, arch) != 1) {
|
||||
fclose (arch);
|
||||
if (fread(ename, elen, 1, arch) != 1) {
|
||||
fclose(arch);
|
||||
return NULL;
|
||||
}
|
||||
ename[elen] = '\0';
|
||||
|
@ -863,10 +861,10 @@ ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
|||
}
|
||||
if (strncmp(ename, member, len) == 0) {
|
||||
/* Found as extended name */
|
||||
fseek (arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);
|
||||
fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);
|
||||
return (arch);
|
||||
}
|
||||
fseek (arch, -elen, SEEK_CUR);
|
||||
fseek(arch, -elen, SEEK_CUR);
|
||||
goto skip;
|
||||
} else
|
||||
#endif
|
||||
|
@ -879,9 +877,9 @@ ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
|||
* extract the size of the file from the 'size' field of the
|
||||
* header and round it up during the seek.
|
||||
*/
|
||||
arhPtr->ar_size[sizeof(arhPtr->ar_size)-1] = '\0';
|
||||
size = (int) strtol(arhPtr->ar_size, NULL, 10);
|
||||
fseek (arch, (size + 1) & ~1, SEEK_CUR);
|
||||
arhPtr->ar_size[sizeof(arhPtr->ar_size) - 1] = '\0';
|
||||
size = (int)strtol(arhPtr->ar_size, NULL, 10);
|
||||
fseek(arch, (size + 1) & ~1, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -889,7 +887,7 @@ ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
|||
* We've looked everywhere, but the member is not to be found. Close the
|
||||
* archive and return NULL -- an error.
|
||||
*/
|
||||
fclose (arch);
|
||||
fclose(arch);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -909,22 +907,22 @@ ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Arch_Touch (GNode *gn)
|
||||
Arch_Touch(GNode *gn)
|
||||
{
|
||||
FILE * arch; /* Stream open to archive, positioned properly */
|
||||
struct ar_hdr arh; /* Current header describing member */
|
||||
char *p1, *p2;
|
||||
|
||||
arch = ArchFindMember(Var_Value (ARCHIVE, gn, &p1),
|
||||
Var_Value (TARGET, gn, &p2),
|
||||
arch = ArchFindMember(Var_Value(ARCHIVE, gn, &p1),
|
||||
Var_Value(TARGET, gn, &p2),
|
||||
&arh, "r+");
|
||||
free(p1);
|
||||
free(p2);
|
||||
snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
|
||||
snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long)now);
|
||||
|
||||
if (arch != NULL) {
|
||||
(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch);
|
||||
fclose (arch);
|
||||
fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch);
|
||||
fclose(arch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -944,19 +942,19 @@ Arch_Touch (GNode *gn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Arch_TouchLib (GNode *gn)
|
||||
Arch_TouchLib(GNode *gn)
|
||||
{
|
||||
#ifdef RANLIBMAG
|
||||
FILE * arch; /* Stream open to archive */
|
||||
struct ar_hdr arh; /* Header describing table of contents */
|
||||
struct utimbuf times; /* Times for utime() call */
|
||||
|
||||
arch = ArchFindMember (gn->path, RANLIBMAG, &arh, "r+");
|
||||
arch = ArchFindMember(gn->path, RANLIBMAG, &arh, "r+");
|
||||
snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
|
||||
|
||||
if (arch != NULL) {
|
||||
(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch);
|
||||
fclose (arch);
|
||||
fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch);
|
||||
fclose(arch);
|
||||
|
||||
times.actime = times.modtime = now;
|
||||
utime(gn->path, ×);
|
||||
|
@ -971,7 +969,7 @@ Arch_TouchLib (GNode *gn)
|
|||
* name.
|
||||
*
|
||||
* Results:
|
||||
* The modification time (seconds).
|
||||
* The modification time(seconds).
|
||||
*
|
||||
* Side Effects:
|
||||
* The mtime field of the given node is filled in with the value
|
||||
|
@ -986,14 +984,14 @@ Arch_MTime(GNode *gn)
|
|||
int modTime; /* Modification time as an integer */
|
||||
char *p1, *p2;
|
||||
|
||||
arhPtr = ArchStatMember (Var_Value (ARCHIVE, gn, &p1),
|
||||
Var_Value (TARGET, gn, &p2),
|
||||
arhPtr = ArchStatMember(Var_Value(ARCHIVE, gn, &p1),
|
||||
Var_Value(TARGET, gn, &p2),
|
||||
TRUE);
|
||||
free(p1);
|
||||
free(p2);
|
||||
|
||||
if (arhPtr != NULL) {
|
||||
modTime = (int) strtol(arhPtr->ar_date, NULL, 10);
|
||||
modTime = (int)strtol(arhPtr->ar_date, NULL, 10);
|
||||
} else {
|
||||
modTime = 0;
|
||||
}
|
||||
|
@ -1017,19 +1015,19 @@ Arch_MTime(GNode *gn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Arch_MemMTime (GNode *gn)
|
||||
Arch_MemMTime(GNode *gn)
|
||||
{
|
||||
LstNode ln;
|
||||
GNode *pgn;
|
||||
char *nameStart,
|
||||
*nameEnd;
|
||||
|
||||
if (Lst_Open (gn->parents) != SUCCESS) {
|
||||
if (Lst_Open(gn->parents) != SUCCESS) {
|
||||
gn->mtime = 0;
|
||||
return (0);
|
||||
}
|
||||
while ((ln = Lst_Next (gn->parents)) != NULL) {
|
||||
pgn = (GNode *) Lst_Datum (ln);
|
||||
while ((ln = Lst_Next(gn->parents)) != NULL) {
|
||||
pgn = (GNode *)Lst_Datum(ln);
|
||||
|
||||
if (pgn->type & OP_ARCHV) {
|
||||
/*
|
||||
|
@ -1039,8 +1037,8 @@ Arch_MemMTime (GNode *gn)
|
|||
* child. We keep searching its parents in case some other
|
||||
* parent requires this child to exist...
|
||||
*/
|
||||
nameStart = strchr (pgn->name, '(') + 1;
|
||||
nameEnd = strchr (nameStart, ')');
|
||||
nameStart = strchr(pgn->name, '(') + 1;
|
||||
nameEnd = strchr(nameStart, ')');
|
||||
|
||||
if (pgn->make &&
|
||||
strncmp(nameStart, gn->name, nameEnd - nameStart) == 0) {
|
||||
|
@ -1056,7 +1054,7 @@ Arch_MemMTime (GNode *gn)
|
|||
}
|
||||
}
|
||||
|
||||
Lst_Close (gn->parents);
|
||||
Lst_Close(gn->parents);
|
||||
|
||||
return (gn->mtime);
|
||||
}
|
||||
|
@ -1082,7 +1080,7 @@ Arch_MemMTime (GNode *gn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Arch_FindLib (GNode *gn, Lst path)
|
||||
Arch_FindLib(GNode *gn, Lst path)
|
||||
{
|
||||
char *libName; /* file name for archive */
|
||||
size_t sz;
|
||||
|
@ -1091,14 +1089,14 @@ Arch_FindLib (GNode *gn, Lst path)
|
|||
libName = (char *)emalloc(sz);
|
||||
snprintf(libName, sz, "lib%s.a", &gn->name[2]);
|
||||
|
||||
gn->path = Dir_FindFile (libName, path);
|
||||
gn->path = Dir_FindFile(libName, path);
|
||||
|
||||
free (libName);
|
||||
free(libName);
|
||||
|
||||
#ifdef LIBRARIES
|
||||
Var_Set (TARGET, gn->name, gn);
|
||||
Var_Set(TARGET, gn->name, gn);
|
||||
#else
|
||||
Var_Set (TARGET, gn->path == NULL ? gn->name : gn->path, gn);
|
||||
Var_Set(TARGET, gn->path == NULL ? gn->name : gn->path, gn);
|
||||
#endif /* LIBRARIES */
|
||||
}
|
||||
|
||||
|
@ -1140,7 +1138,7 @@ Arch_FindLib (GNode *gn, Lst path)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Arch_LibOODate (GNode *gn)
|
||||
Arch_LibOODate(GNode *gn)
|
||||
{
|
||||
Boolean oodate;
|
||||
|
||||
|
@ -1153,10 +1151,10 @@ Arch_LibOODate (GNode *gn)
|
|||
struct ar_hdr *arhPtr; /* Header for __.SYMDEF */
|
||||
int modTimeTOC; /* The table-of-contents's mod time */
|
||||
|
||||
arhPtr = ArchStatMember (gn->path, RANLIBMAG, FALSE);
|
||||
arhPtr = ArchStatMember(gn->path, RANLIBMAG, FALSE);
|
||||
|
||||
if (arhPtr != NULL) {
|
||||
modTimeTOC = (int) strtol(arhPtr->ar_date, NULL, 10);
|
||||
modTimeTOC = (int)strtol(arhPtr->ar_date, NULL, 10);
|
||||
|
||||
/* XXX choose one. */
|
||||
if (DEBUG(ARCH) || DEBUG(MAKE)) {
|
||||
|
@ -1193,13 +1191,11 @@ Arch_LibOODate (GNode *gn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Arch_Init (void)
|
||||
Arch_Init(void)
|
||||
{
|
||||
archives = Lst_Init (FALSE);
|
||||
archives = Lst_Init(FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Arch_End --
|
||||
|
@ -1214,7 +1210,7 @@ Arch_Init (void)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Arch_End (void)
|
||||
Arch_End(void)
|
||||
{
|
||||
Lst_Destroy(archives, ArchFree);
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ __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); \
|
||||
int newSize = (bp)->size + max((nb) + 1, BUF_ADD_INC); \
|
||||
Byte *newBuf = (Byte *)erealloc((bp)->buffer, newSize); \
|
||||
\
|
||||
(bp)->inPtr = newBuf + ((bp)->inPtr - (bp)->buffer); \
|
||||
(bp)->outPtr = newBuf + ((bp)->outPtr - (bp)->buffer);\
|
||||
|
@ -92,10 +92,10 @@ __FBSDID("$FreeBSD$");
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_OvAddByte (Buffer bp, int byte)
|
||||
Buf_OvAddByte(Buffer bp, int byte)
|
||||
{
|
||||
bp->left = 0;
|
||||
BufExpand (bp, 1);
|
||||
BufExpand(bp, 1);
|
||||
|
||||
*bp->inPtr++ = byte;
|
||||
bp->left--;
|
||||
|
@ -105,7 +105,7 @@ Buf_OvAddByte (Buffer bp, int byte)
|
|||
*/
|
||||
*bp->inPtr = 0;
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_AddBytes --
|
||||
|
@ -120,12 +120,12 @@ Buf_OvAddByte (Buffer bp, int byte)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_AddBytes (Buffer bp, int numBytes, const Byte *bytesPtr)
|
||||
Buf_AddBytes(Buffer bp, int numBytes, const Byte *bytesPtr)
|
||||
{
|
||||
|
||||
BufExpand (bp, numBytes);
|
||||
BufExpand(bp, numBytes);
|
||||
|
||||
memcpy (bp->inPtr, bytesPtr, numBytes);
|
||||
memcpy(bp->inPtr, bytesPtr, numBytes);
|
||||
bp->inPtr += numBytes;
|
||||
bp->left -= numBytes;
|
||||
|
||||
|
@ -134,7 +134,7 @@ Buf_AddBytes (Buffer bp, int numBytes, const Byte *bytesPtr)
|
|||
*/
|
||||
*bp->inPtr = 0;
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_UngetByte --
|
||||
|
@ -149,7 +149,7 @@ Buf_AddBytes (Buffer bp, int numBytes, const Byte *bytesPtr)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_UngetByte (Buffer bp, int byte)
|
||||
Buf_UngetByte(Buffer bp, int byte)
|
||||
{
|
||||
|
||||
if (bp->outPtr != bp->buffer) {
|
||||
|
@ -171,10 +171,11 @@ Buf_UngetByte (Buffer bp, int byte)
|
|||
Byte *newBuf;
|
||||
|
||||
newBuf = (Byte *)emalloc(bp->size + BUF_UNGET_INC);
|
||||
memcpy ((char *)(newBuf+BUF_UNGET_INC), (char *)bp->outPtr, numBytes+1);
|
||||
memcpy((char *)(newBuf+BUF_UNGET_INC), (char *)bp->outPtr,
|
||||
numBytes + 1);
|
||||
bp->outPtr = newBuf + BUF_UNGET_INC;
|
||||
bp->inPtr = bp->outPtr + numBytes;
|
||||
free ((char *)bp->buffer);
|
||||
free((char *)bp->buffer);
|
||||
bp->buffer = newBuf;
|
||||
bp->size += BUF_UNGET_INC;
|
||||
bp->left = bp->size - (bp->inPtr - bp->buffer);
|
||||
|
@ -182,7 +183,7 @@ Buf_UngetByte (Buffer bp, int byte)
|
|||
*bp->outPtr = byte;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_UngetBytes --
|
||||
|
@ -197,32 +198,32 @@ Buf_UngetByte (Buffer bp, int byte)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_UngetBytes (Buffer bp, int numBytes, Byte *bytesPtr)
|
||||
Buf_UngetBytes(Buffer bp, int numBytes, Byte *bytesPtr)
|
||||
{
|
||||
|
||||
if (bp->outPtr - bp->buffer >= numBytes) {
|
||||
bp->outPtr -= numBytes;
|
||||
memcpy (bp->outPtr, bytesPtr, numBytes);
|
||||
memcpy(bp->outPtr, bytesPtr, numBytes);
|
||||
} else if (bp->outPtr == bp->inPtr) {
|
||||
Buf_AddBytes (bp, numBytes, bytesPtr);
|
||||
Buf_AddBytes(bp, numBytes, bytesPtr);
|
||||
} else {
|
||||
int curNumBytes = bp->inPtr - bp->outPtr;
|
||||
Byte *newBuf;
|
||||
int newBytes = max(numBytes,BUF_UNGET_INC);
|
||||
|
||||
newBuf = (Byte *)emalloc (bp->size + newBytes);
|
||||
memcpy((char *)(newBuf+newBytes), (char *)bp->outPtr, curNumBytes+1);
|
||||
memcpy((char *)(newBuf+newBytes), (char *)bp->outPtr, curNumBytes + 1);
|
||||
bp->outPtr = newBuf + newBytes;
|
||||
bp->inPtr = bp->outPtr + curNumBytes;
|
||||
free ((char *)bp->buffer);
|
||||
free((char *)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((char *)bp->outPtr, (char *)bytesPtr, numBytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_GetByte --
|
||||
|
@ -239,14 +240,14 @@ Buf_UngetBytes (Buffer bp, int numBytes, Byte *bytesPtr)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Buf_GetByte (Buffer bp)
|
||||
Buf_GetByte(Buffer bp)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (bp->inPtr == bp->outPtr) {
|
||||
return (BUF_ERROR);
|
||||
} else {
|
||||
res = (int) *bp->outPtr;
|
||||
res = (int)*bp->outPtr;
|
||||
bp->outPtr += 1;
|
||||
if (bp->outPtr == bp->inPtr) {
|
||||
bp->outPtr = bp->inPtr = bp->buffer;
|
||||
|
@ -256,7 +257,7 @@ Buf_GetByte (Buffer bp)
|
|||
return (res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_GetBytes --
|
||||
|
@ -271,13 +272,13 @@ Buf_GetByte (Buffer bp)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Buf_GetBytes (Buffer bp, int numBytes, Byte *bytesPtr)
|
||||
Buf_GetBytes(Buffer bp, int numBytes, Byte *bytesPtr)
|
||||
{
|
||||
|
||||
if (bp->inPtr - bp->outPtr < numBytes) {
|
||||
numBytes = bp->inPtr - bp->outPtr;
|
||||
}
|
||||
memcpy (bytesPtr, bp->outPtr, numBytes);
|
||||
memcpy(bytesPtr, bp->outPtr, numBytes);
|
||||
bp->outPtr += numBytes;
|
||||
|
||||
if (bp->outPtr == bp->inPtr) {
|
||||
|
@ -287,7 +288,7 @@ Buf_GetBytes (Buffer bp, int numBytes, Byte *bytesPtr)
|
|||
}
|
||||
return (numBytes);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_GetAll --
|
||||
|
@ -302,7 +303,7 @@ Buf_GetBytes (Buffer bp, int numBytes, Byte *bytesPtr)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Byte *
|
||||
Buf_GetAll (Buffer bp, int *numBytesPtr)
|
||||
Buf_GetAll(Buffer bp, int *numBytesPtr)
|
||||
{
|
||||
|
||||
if (numBytesPtr != (int *)NULL) {
|
||||
|
@ -311,7 +312,7 @@ Buf_GetAll (Buffer bp, int *numBytesPtr)
|
|||
|
||||
return (bp->outPtr);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_Discard --
|
||||
|
@ -326,7 +327,7 @@ Buf_GetAll (Buffer bp, int *numBytesPtr)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_Discard (Buffer bp, int numBytes)
|
||||
Buf_Discard(Buffer bp, int numBytes)
|
||||
{
|
||||
|
||||
if (bp->inPtr - bp->outPtr <= numBytes) {
|
||||
|
@ -337,7 +338,7 @@ Buf_Discard (Buffer bp, int numBytes)
|
|||
bp->outPtr += numBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_Size --
|
||||
|
@ -353,11 +354,11 @@ Buf_Discard (Buffer bp, int numBytes)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Buf_Size (Buffer buf)
|
||||
Buf_Size(Buffer buf)
|
||||
{
|
||||
return (buf->inPtr - buf->outPtr);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_Init --
|
||||
|
@ -374,7 +375,7 @@ Buf_Size (Buffer buf)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Buffer
|
||||
Buf_Init (int size)
|
||||
Buf_Init(int size)
|
||||
{
|
||||
Buffer bp; /* New Buffer */
|
||||
|
||||
|
@ -390,7 +391,7 @@ Buf_Init (int size)
|
|||
|
||||
return (bp);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_Destroy --
|
||||
|
@ -405,15 +406,15 @@ Buf_Init (int size)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_Destroy (Buffer buf, Boolean freeData)
|
||||
Buf_Destroy(Buffer buf, Boolean freeData)
|
||||
{
|
||||
|
||||
if (freeData) {
|
||||
free ((char *)buf->buffer);
|
||||
free((char *)buf->buffer);
|
||||
}
|
||||
free ((char *)buf);
|
||||
free((char *)buf);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_ReplaceLastByte --
|
||||
|
@ -429,7 +430,7 @@ Buf_Destroy (Buffer buf, Boolean freeData)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_ReplaceLastByte (Buffer buf, int byte)
|
||||
Buf_ReplaceLastByte(Buffer buf, int byte)
|
||||
{
|
||||
if (buf->inPtr == buf->outPtr)
|
||||
Buf_AddByte(buf, byte);
|
||||
|
|
|
@ -62,7 +62,7 @@ typedef struct Buffer {
|
|||
|
||||
/* Buf_AddByte adds a single byte to a buffer. */
|
||||
#define Buf_AddByte(bp, byte) \
|
||||
(void) (--(bp)->left <= 0 ? Buf_OvAddByte(bp, byte), 1 : \
|
||||
(void)(--(bp)->left <= 0 ? Buf_OvAddByte(bp, byte), 1 : \
|
||||
(*(bp)->inPtr++ = (byte), *(bp)->inPtr = 0), 1)
|
||||
|
||||
#define BUF_ERROR 256
|
||||
|
|
|
@ -85,8 +85,8 @@ static void CompatInterrupt(int);
|
|||
static int CompatMake(void *, void *);
|
||||
static int shellneed(char *);
|
||||
|
||||
static char *sh_builtin[] = {
|
||||
"alias", "cd", "eval", "exec", "exit", "read", "set", "ulimit",
|
||||
static char *sh_builtin[] = {
|
||||
"alias", "cd", "eval", "exec", "exit", "read", "set", "ulimit",
|
||||
"unalias", "umask", "unset", "wait", ":", 0};
|
||||
|
||||
static void
|
||||
|
@ -95,7 +95,7 @@ CompatInit(void)
|
|||
char *cp; /* Pointer to string of shell meta-characters */
|
||||
|
||||
for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) {
|
||||
meta[(unsigned char) *cp] = 1;
|
||||
meta[(unsigned char)*cp] = 1;
|
||||
}
|
||||
/*
|
||||
* The null character serves as a sentinel in the string.
|
||||
|
@ -144,12 +144,12 @@ CompatInterrupt (int signo)
|
|||
/* prevent recursion in evaluation of .INTERRUPT */
|
||||
interrupted = 0;
|
||||
|
||||
if ((curTarg != NULL) && !Targ_Precious (curTarg)) {
|
||||
if ((curTarg != NULL) && !Targ_Precious(curTarg)) {
|
||||
char *p1;
|
||||
char *file = Var_Value (TARGET, curTarg, &p1);
|
||||
char *file = Var_Value(TARGET, curTarg, &p1);
|
||||
|
||||
if (!noExecute && eunlink(file) != -1) {
|
||||
printf ("*** %s removed\n", file);
|
||||
printf("*** %s removed\n", file);
|
||||
}
|
||||
free(p1);
|
||||
}
|
||||
|
@ -168,21 +168,21 @@ CompatInterrupt (int signo)
|
|||
|
||||
if (signo == SIGQUIT)
|
||||
exit(signo);
|
||||
(void) signal(signo, SIG_DFL);
|
||||
(void) kill(getpid(), signo);
|
||||
signal(signo, SIG_DFL);
|
||||
kill(getpid(), signo);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* shellneed --
|
||||
*
|
||||
*
|
||||
* Results:
|
||||
* Returns 1 if a specified line must be executed by the shell,
|
||||
* 0 if it can be run via execve, and -1 if the command is a no-op.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
|
@ -197,7 +197,7 @@ shellneed (char *cmd)
|
|||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Compat_RunCommand --
|
||||
|
@ -214,7 +214,7 @@ shellneed (char *cmd)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Compat_RunCommand (void *cmdp, void *gnp)
|
||||
Compat_RunCommand(void *cmdp, void *gnp)
|
||||
{
|
||||
char *cmdStart; /* Start of expanded command */
|
||||
char *cp;
|
||||
|
@ -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 = (char *)cmdp;
|
||||
GNode *gn = (GNode *)gnp;
|
||||
|
||||
/*
|
||||
* Avoid clobbered variable warnings by forcing the compiler
|
||||
|
@ -245,8 +245,8 @@ Compat_RunCommand (void *cmdp, void *gnp)
|
|||
errCheck = !(gn->type & OP_IGNORE);
|
||||
doit = FALSE;
|
||||
|
||||
cmdNode = Lst_Member (gn->commands, (void *)cmd);
|
||||
cmdStart = Var_Subst (NULL, cmd, gn, FALSE);
|
||||
cmdNode = Lst_Member(gn->commands, (void *)cmd);
|
||||
cmdStart = Var_Subst(NULL, cmd, gn, FALSE);
|
||||
|
||||
/*
|
||||
* brk_string will return an argv with a NULL in av[0], thus causing
|
||||
|
@ -258,18 +258,18 @@ Compat_RunCommand (void *cmdp, void *gnp)
|
|||
if (*cmdStart == '\0') {
|
||||
free(cmdStart);
|
||||
Error("%s expands to empty string", cmd);
|
||||
return(0);
|
||||
return (0);
|
||||
} else {
|
||||
cmd = cmdStart;
|
||||
}
|
||||
Lst_Replace (cmdNode, (void *)cmdStart);
|
||||
|
||||
if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
|
||||
(void)Lst_AtEnd(ENDNode->commands, (void *)cmdStart);
|
||||
return(0);
|
||||
Lst_AtEnd(ENDNode->commands, (void *)cmdStart);
|
||||
return (0);
|
||||
} else if (strcmp(cmdStart, "...") == 0) {
|
||||
gn->type |= OP_SAVE_CMDS;
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
while ((*cmd == '@') || (*cmd == '-') || (*cmd == '+')) {
|
||||
|
@ -309,7 +309,7 @@ Compat_RunCommand (void *cmdp, void *gnp)
|
|||
* this one. We also print the command if -n given, but not if '+'.
|
||||
*/
|
||||
if (!silent || (noExecute && !doit)) {
|
||||
printf ("%s\n", cmd);
|
||||
printf("%s\n", cmd);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
@ -374,22 +374,22 @@ Compat_RunCommand (void *cmdp, void *gnp)
|
|||
}
|
||||
if (cpid == 0) {
|
||||
execvp(av[0], av);
|
||||
(void) write (STDERR_FILENO, av[0], strlen (av[0]));
|
||||
(void) write (STDERR_FILENO, ":", 1);
|
||||
(void) write (STDERR_FILENO, strerror(errno), strlen(strerror(errno)));
|
||||
(void) write (STDERR_FILENO, "\n", 1);
|
||||
write(STDERR_FILENO, av[0], strlen (av[0]));
|
||||
write(STDERR_FILENO, ":", 1);
|
||||
write(STDERR_FILENO, strerror(errno), strlen(strerror(errno)));
|
||||
write(STDERR_FILENO, "\n", 1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* we need to print out the command associated with this Gnode in
|
||||
* Targ_PrintCmd from Targ_PrintGraph when debugging at level g2,
|
||||
* in main(), Fatal() and DieHorribly(), therefore do not free it
|
||||
* when debugging.
|
||||
* when debugging.
|
||||
*/
|
||||
if (!DEBUG(GRAPH2)) {
|
||||
free(cmdStart);
|
||||
Lst_Replace (cmdNode, cmdp);
|
||||
Lst_Replace(cmdNode, cmdp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -411,11 +411,11 @@ Compat_RunCommand (void *cmdp, void *gnp)
|
|||
} else if (WIFEXITED(reason)) {
|
||||
status = WEXITSTATUS(reason); /* exited */
|
||||
if (status != 0) {
|
||||
printf ("*** Error code %d", status);
|
||||
printf("*** Error code %d", status);
|
||||
}
|
||||
} else {
|
||||
status = WTERMSIG(reason); /* signaled */
|
||||
printf ("*** Signal %d", status);
|
||||
printf("*** Signal %d", status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -427,27 +427,27 @@ Compat_RunCommand (void *cmdp, void *gnp)
|
|||
* Abort the current target, but let others
|
||||
* continue.
|
||||
*/
|
||||
printf (" (continuing)\n");
|
||||
printf(" (continuing)\n");
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Continue executing commands for this target.
|
||||
* If we return 0, this will happen...
|
||||
*/
|
||||
printf (" (ignored)\n");
|
||||
printf(" (ignored)\n");
|
||||
status = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
Fatal ("error in wait: %d", rstat);
|
||||
Fatal("error in wait: %d", rstat);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CompatMake --
|
||||
|
@ -462,10 +462,11 @@ Compat_RunCommand (void *cmdp, void *gnp)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
CompatMake (void *gnp, void *pgnp)
|
||||
CompatMake(void *gnp, void *pgnp)
|
||||
{
|
||||
GNode *gn = (GNode *) gnp;
|
||||
GNode *pgn = (GNode *) pgnp;
|
||||
GNode *gn = (GNode *)gnp;
|
||||
GNode *pgn = (GNode *)pgnp;
|
||||
|
||||
if (gn->type & OP_USE) {
|
||||
Make_HandleUse(gn, pgn);
|
||||
} else if (gn->made == UNMADE) {
|
||||
|
@ -479,17 +480,17 @@ CompatMake (void *gnp, void *pgnp)
|
|||
*/
|
||||
gn->make = TRUE;
|
||||
gn->made = BEINGMADE;
|
||||
Suff_FindDeps (gn);
|
||||
Lst_ForEach (gn->children, CompatMake, (void *)gn);
|
||||
Suff_FindDeps(gn);
|
||||
Lst_ForEach(gn->children, CompatMake, (void *)gn);
|
||||
if (!gn->make) {
|
||||
gn->made = ABORTED;
|
||||
pgn->make = FALSE;
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (Lst_Member (gn->iParents, pgn) != NULL) {
|
||||
if (Lst_Member(gn->iParents, pgn) != NULL) {
|
||||
char *p1;
|
||||
Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
|
||||
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
|
||||
free(p1);
|
||||
}
|
||||
|
||||
|
@ -500,7 +501,7 @@ CompatMake (void *gnp, void *pgnp)
|
|||
* Make_OODate function.
|
||||
*/
|
||||
DEBUGF(MAKE, ("Examining %s...", gn->name));
|
||||
if (! Make_OODate(gn)) {
|
||||
if (!Make_OODate(gn)) {
|
||||
gn->made = UPTODATE;
|
||||
DEBUGF(MAKE, ("up-to-date.\n"));
|
||||
return (0);
|
||||
|
@ -513,7 +514,7 @@ CompatMake (void *gnp, void *pgnp)
|
|||
* to tell him/her "yes".
|
||||
*/
|
||||
if (queryFlag) {
|
||||
exit (1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -527,24 +528,24 @@ CompatMake (void *gnp, void *pgnp)
|
|||
* Alter our type to tell if errors should be ignored or things
|
||||
* should not be printed so Compat_RunCommand knows what to do.
|
||||
*/
|
||||
if (Targ_Ignore (gn)) {
|
||||
if (Targ_Ignore(gn)) {
|
||||
gn->type |= OP_IGNORE;
|
||||
}
|
||||
if (Targ_Silent (gn)) {
|
||||
if (Targ_Silent(gn)) {
|
||||
gn->type |= OP_SILENT;
|
||||
}
|
||||
|
||||
if (Job_CheckCommands (gn, Fatal)) {
|
||||
if (Job_CheckCommands(gn, Fatal)) {
|
||||
/*
|
||||
* Our commands are ok, but we still have to worry about the -t
|
||||
* flag...
|
||||
*/
|
||||
if (!touchFlag) {
|
||||
curTarg = gn;
|
||||
Lst_ForEach (gn->commands, Compat_RunCommand, (void *)gn);
|
||||
Lst_ForEach(gn->commands, Compat_RunCommand, (void *)gn);
|
||||
curTarg = NULL;
|
||||
} else {
|
||||
Job_Touch (gn, gn->type & OP_SILENT);
|
||||
Job_Touch(gn, gn->type & OP_SILENT);
|
||||
}
|
||||
} else {
|
||||
gn->made = ERROR;
|
||||
|
@ -623,9 +624,9 @@ CompatMake (void *gnp, void *pgnp)
|
|||
} else {
|
||||
char *p1;
|
||||
|
||||
printf ("\n\nStop in %s.\n", Var_Value(".CURDIR", gn, &p1));
|
||||
printf("\n\nStop in %s.\n", Var_Value(".CURDIR", gn, &p1));
|
||||
free(p1);
|
||||
exit (1);
|
||||
exit(1);
|
||||
}
|
||||
} else if (gn->made == ERROR) {
|
||||
/*
|
||||
|
@ -634,9 +635,9 @@ CompatMake (void *gnp, void *pgnp)
|
|||
*/
|
||||
pgn->make = FALSE;
|
||||
} else {
|
||||
if (Lst_Member (gn->iParents, pgn) != NULL) {
|
||||
if (Lst_Member(gn->iParents, pgn) != NULL) {
|
||||
char *p1;
|
||||
Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
|
||||
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
|
||||
free(p1);
|
||||
}
|
||||
switch(gn->made) {
|
||||
|
@ -663,7 +664,7 @@ CompatMake (void *gnp, void *pgnp)
|
|||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Compat_Run --
|
||||
|
@ -726,14 +727,14 @@ Compat_Run(Lst targs)
|
|||
* could not be made due to errors.
|
||||
*/
|
||||
errors = 0;
|
||||
while (!Lst_IsEmpty (targs)) {
|
||||
gn = (GNode *) Lst_DeQueue (targs);
|
||||
CompatMake (gn, gn);
|
||||
while (!Lst_IsEmpty(targs)) {
|
||||
gn = (GNode *)Lst_DeQueue(targs);
|
||||
CompatMake(gn, gn);
|
||||
|
||||
if (gn->made == UPTODATE) {
|
||||
printf ("`%s' is up to date.\n", gn->name);
|
||||
printf("`%s' is up to date.\n", gn->name);
|
||||
} else if (gn->made == ABORTED) {
|
||||
printf ("`%s' not remade because of errors.\n", gn->name);
|
||||
printf("`%s' not remade because of errors.\n", gn->name);
|
||||
errors += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,11 +155,11 @@ static Boolean skipLine = FALSE; /* Whether the parse module is skipping
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
CondPushBack (Token t)
|
||||
CondPushBack(Token t)
|
||||
{
|
||||
condPushBack = t;
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondGetArg --
|
||||
|
@ -176,7 +176,7 @@ CondPushBack (Token t)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
CondGetArg (char **linePtr, char **argPtr, char *func, Boolean parens)
|
||||
CondGetArg(char **linePtr, char **argPtr, char *func, Boolean parens)
|
||||
{
|
||||
char *cp;
|
||||
int argLen;
|
||||
|
@ -246,7 +246,7 @@ CondGetArg (char **linePtr, char **argPtr, char *func, Boolean parens)
|
|||
cp++;
|
||||
}
|
||||
if (parens && *cp != ')') {
|
||||
Parse_Error (PARSE_WARNING, "Missing closing parenthesis for %s()",
|
||||
Parse_Error(PARSE_WARNING, "Missing closing parenthesis for %s()",
|
||||
func);
|
||||
return (0);
|
||||
} else if (parens) {
|
||||
|
@ -259,7 +259,7 @@ CondGetArg (char **linePtr, char **argPtr, char *func, Boolean parens)
|
|||
*linePtr = cp;
|
||||
return (argLen);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondDoDefined --
|
||||
|
@ -274,14 +274,14 @@ CondGetArg (char **linePtr, char **argPtr, char *func, Boolean parens)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static Boolean
|
||||
CondDoDefined (int argLen, char *arg)
|
||||
CondDoDefined(int argLen, char *arg)
|
||||
{
|
||||
char savec = arg[argLen];
|
||||
char *p1;
|
||||
Boolean result;
|
||||
|
||||
arg[argLen] = '\0';
|
||||
if (Var_Value (arg, VAR_CMD, &p1) != (char *)NULL) {
|
||||
if (Var_Value(arg, VAR_CMD, &p1) != (char *)NULL) {
|
||||
result = TRUE;
|
||||
} else {
|
||||
result = FALSE;
|
||||
|
@ -290,7 +290,7 @@ CondDoDefined (int argLen, char *arg)
|
|||
arg[argLen] = savec;
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondStrMatch --
|
||||
|
@ -308,9 +308,9 @@ CondDoDefined (int argLen, char *arg)
|
|||
static int
|
||||
CondStrMatch(void *string, void *pattern)
|
||||
{
|
||||
return(!Str_Match((char *) string,(char *) pattern));
|
||||
return (!Str_Match((char *)string, (char *)pattern));
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondDoMake --
|
||||
|
@ -325,13 +325,13 @@ CondStrMatch(void *string, void *pattern)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static Boolean
|
||||
CondDoMake (int argLen, char *arg)
|
||||
CondDoMake(int argLen, char *arg)
|
||||
{
|
||||
char savec = arg[argLen];
|
||||
Boolean result;
|
||||
|
||||
arg[argLen] = '\0';
|
||||
if (Lst_Find (create, (void *)arg, CondStrMatch) == NULL) {
|
||||
if (Lst_Find(create, (void *)arg, CondStrMatch) == NULL) {
|
||||
result = FALSE;
|
||||
} else {
|
||||
result = TRUE;
|
||||
|
@ -339,7 +339,7 @@ CondDoMake (int argLen, char *arg)
|
|||
arg[argLen] = savec;
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondDoExists --
|
||||
|
@ -354,7 +354,7 @@ CondDoMake (int argLen, char *arg)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static Boolean
|
||||
CondDoExists (int argLen, char *arg)
|
||||
CondDoExists(int argLen, char *arg)
|
||||
{
|
||||
char savec = arg[argLen];
|
||||
Boolean result;
|
||||
|
@ -371,7 +371,7 @@ CondDoExists (int argLen, char *arg)
|
|||
arg[argLen] = savec;
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondDoTarget --
|
||||
|
@ -386,7 +386,7 @@ CondDoExists (int argLen, char *arg)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static Boolean
|
||||
CondDoTarget (int argLen, char *arg)
|
||||
CondDoTarget(int argLen, char *arg)
|
||||
{
|
||||
char savec = arg[argLen];
|
||||
Boolean result;
|
||||
|
@ -403,7 +403,6 @@ CondDoTarget (int argLen, char *arg)
|
|||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondCvtArg --
|
||||
|
@ -431,12 +430,12 @@ CondCvtArg(char *str, double *value)
|
|||
|
||||
for (str += 2, i = 0; ; str++) {
|
||||
int x;
|
||||
if (isdigit((unsigned char) *str))
|
||||
if (isdigit((unsigned char)*str))
|
||||
x = *str - '0';
|
||||
else if (isxdigit((unsigned char) *str))
|
||||
x = 10 + *str - isupper((unsigned char) *str) ? 'A' : 'a';
|
||||
else if (isxdigit((unsigned char)*str))
|
||||
x = 10 + *str - isupper((unsigned char)*str) ? 'A' : 'a';
|
||||
else {
|
||||
*value = (double) i;
|
||||
*value = (double)i;
|
||||
return str;
|
||||
}
|
||||
i = (i << 4) + x;
|
||||
|
@ -445,10 +444,10 @@ CondCvtArg(char *str, double *value)
|
|||
else {
|
||||
char *eptr;
|
||||
*value = strtod(str, &eptr);
|
||||
return eptr;
|
||||
return (eptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondToken --
|
||||
|
@ -514,17 +513,18 @@ CondToken(Boolean doEval)
|
|||
* value in lhs.
|
||||
*/
|
||||
t = Err;
|
||||
lhs = Var_Parse(condExpr, VAR_CMD, doEval,&varSpecLen,&doFree);
|
||||
lhs = Var_Parse(condExpr, VAR_CMD, doEval,
|
||||
&varSpecLen, &doFree);
|
||||
if (lhs == var_Error) {
|
||||
/*
|
||||
* Even if !doEval, we still report syntax errors, which
|
||||
* is what getting var_Error back with !doEval means.
|
||||
*/
|
||||
return(Err);
|
||||
return (Err);
|
||||
}
|
||||
condExpr += varSpecLen;
|
||||
|
||||
if (!isspace((unsigned char) *condExpr) &&
|
||||
if (!isspace((unsigned char)*condExpr) &&
|
||||
strchr("!=><", *condExpr) == NULL) {
|
||||
Buffer buf;
|
||||
char *cp;
|
||||
|
@ -551,7 +551,7 @@ CondToken(Boolean doEval)
|
|||
/*
|
||||
* Skip whitespace to get to the operator
|
||||
*/
|
||||
while (isspace((unsigned char) *condExpr))
|
||||
while (isspace((unsigned char)*condExpr))
|
||||
condExpr++;
|
||||
|
||||
/*
|
||||
|
@ -577,7 +577,7 @@ CondToken(Boolean doEval)
|
|||
|
||||
goto do_compare;
|
||||
}
|
||||
while (isspace((unsigned char) *condExpr)) {
|
||||
while (isspace((unsigned char)*condExpr)) {
|
||||
condExpr++;
|
||||
}
|
||||
if (*condExpr == '\0') {
|
||||
|
@ -622,7 +622,7 @@ CondToken(Boolean doEval)
|
|||
int len;
|
||||
Boolean freeIt;
|
||||
|
||||
cp2 = Var_Parse(cp, VAR_CMD, doEval,&len, &freeIt);
|
||||
cp2 = Var_Parse(cp, VAR_CMD, doEval, &len, &freeIt);
|
||||
if (cp2 != var_Error) {
|
||||
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
|
||||
if (freeIt) {
|
||||
|
@ -674,7 +674,7 @@ CondToken(Boolean doEval)
|
|||
int len;
|
||||
Boolean freeIt;
|
||||
|
||||
string = Var_Parse(rhs, VAR_CMD, doEval,&len,&freeIt);
|
||||
string = Var_Parse(rhs, VAR_CMD, doEval, &len, &freeIt);
|
||||
if (string == var_Error) {
|
||||
right = 0.0;
|
||||
} else {
|
||||
|
@ -702,7 +702,7 @@ CondToken(Boolean doEval)
|
|||
|
||||
DEBUGF(COND, ("left = %f, right = %f, op = %.2s\n", left,
|
||||
right, op));
|
||||
switch(op[0]) {
|
||||
switch (op[0]) {
|
||||
case '!':
|
||||
if (op[1] != '=') {
|
||||
Parse_Error(PARSE_WARNING,
|
||||
|
@ -748,7 +748,7 @@ CondToken(Boolean doEval)
|
|||
char *arg;
|
||||
int arglen;
|
||||
|
||||
if (strncmp (condExpr, "defined", 7) == 0) {
|
||||
if (strncmp(condExpr, "defined", 7) == 0) {
|
||||
/*
|
||||
* Use CondDoDefined to evaluate the argument and
|
||||
* CondGetArg to extract the argument from the 'function
|
||||
|
@ -756,12 +756,12 @@ CondToken(Boolean doEval)
|
|||
*/
|
||||
evalProc = CondDoDefined;
|
||||
condExpr += 7;
|
||||
arglen = CondGetArg (&condExpr, &arg, "defined", TRUE);
|
||||
arglen = CondGetArg(&condExpr, &arg, "defined", TRUE);
|
||||
if (arglen == 0) {
|
||||
condExpr -= 7;
|
||||
goto use_default;
|
||||
}
|
||||
} else if (strncmp (condExpr, "make", 4) == 0) {
|
||||
} else if (strncmp(condExpr, "make", 4) == 0) {
|
||||
/*
|
||||
* Use CondDoMake to evaluate the argument and
|
||||
* CondGetArg to extract the argument from the 'function
|
||||
|
@ -769,12 +769,12 @@ CondToken(Boolean doEval)
|
|||
*/
|
||||
evalProc = CondDoMake;
|
||||
condExpr += 4;
|
||||
arglen = CondGetArg (&condExpr, &arg, "make", TRUE);
|
||||
arglen = CondGetArg(&condExpr, &arg, "make", TRUE);
|
||||
if (arglen == 0) {
|
||||
condExpr -= 4;
|
||||
goto use_default;
|
||||
}
|
||||
} else if (strncmp (condExpr, "exists", 6) == 0) {
|
||||
} else if (strncmp(condExpr, "exists", 6) == 0) {
|
||||
/*
|
||||
* Use CondDoExists to evaluate the argument and
|
||||
* CondGetArg to extract the argument from the
|
||||
|
@ -832,7 +832,7 @@ CondToken(Boolean doEval)
|
|||
goto use_default;
|
||||
}
|
||||
break;
|
||||
} else if (strncmp (condExpr, "target", 6) == 0) {
|
||||
} else if (strncmp(condExpr, "target", 6) == 0) {
|
||||
/*
|
||||
* Use CondDoTarget to evaluate the argument and
|
||||
* CondGetArg to extract the argument from the
|
||||
|
@ -876,7 +876,7 @@ CondToken(Boolean doEval)
|
|||
}
|
||||
return (t);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondT --
|
||||
|
@ -927,7 +927,7 @@ CondT(Boolean doEval)
|
|||
}
|
||||
return (t);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondF --
|
||||
|
@ -962,18 +962,18 @@ CondF(Boolean doEval)
|
|||
if (l == True) {
|
||||
l = CondF(doEval);
|
||||
} else {
|
||||
(void) CondF(FALSE);
|
||||
CondF(FALSE);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* F -> T
|
||||
*/
|
||||
CondPushBack (o);
|
||||
CondPushBack(o);
|
||||
}
|
||||
}
|
||||
return (l);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondE --
|
||||
|
@ -1009,18 +1009,18 @@ CondE(Boolean doEval)
|
|||
if (l == False) {
|
||||
l = CondE(doEval);
|
||||
} else {
|
||||
(void) CondE(FALSE);
|
||||
CondE(FALSE);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* E -> F
|
||||
*/
|
||||
CondPushBack (o);
|
||||
CondPushBack(o);
|
||||
}
|
||||
}
|
||||
return (l);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Cond_Eval --
|
||||
|
@ -1043,7 +1043,7 @@ CondE(Boolean doEval)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Cond_Eval (char *line)
|
||||
Cond_Eval(char *line)
|
||||
{
|
||||
struct If *ifp;
|
||||
Boolean isElse;
|
||||
|
@ -1065,7 +1065,7 @@ Cond_Eval (char *line)
|
|||
if (line[0] == 'e' && line[1] == 'l') {
|
||||
line += 2;
|
||||
isElse = TRUE;
|
||||
} else if (strncmp (line, "endif", 5) == 0) {
|
||||
} else if (strncmp(line, "endif", 5) == 0) {
|
||||
/*
|
||||
* End of a conditional section. If skipIfLevel is non-zero, that
|
||||
* conditional was skipped, so lines following it should also be
|
||||
|
@ -1079,7 +1079,7 @@ Cond_Eval (char *line)
|
|||
return (COND_SKIP);
|
||||
} else {
|
||||
if (condTop == MAXIF) {
|
||||
Parse_Error (level, "if-less endif");
|
||||
Parse_Error(level, "if-less endif");
|
||||
return (COND_INVALID);
|
||||
} else {
|
||||
skipLine = FALSE;
|
||||
|
@ -1096,12 +1096,12 @@ Cond_Eval (char *line)
|
|||
* function is, etc. -- by looking in the table of valid "ifs"
|
||||
*/
|
||||
for (ifp = ifs; ifp->form != (char *)0; ifp++) {
|
||||
if (strncmp (ifp->form, line, ifp->formlen) == 0) {
|
||||
if (strncmp(ifp->form, line, ifp->formlen) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ifp->form == (char *) 0) {
|
||||
if (ifp->form == (char *)0) {
|
||||
/*
|
||||
* Nothing fit. If the first word on the line is actually
|
||||
* "else", it's a valid conditional whose value is the inverse
|
||||
|
@ -1109,7 +1109,7 @@ Cond_Eval (char *line)
|
|||
*/
|
||||
if (isElse && (line[0] == 's') && (line[1] == 'e')) {
|
||||
if (condTop == MAXIF) {
|
||||
Parse_Error (level, "if-less else");
|
||||
Parse_Error(level, "if-less else");
|
||||
return (COND_INVALID);
|
||||
} else if (skipIfLevel == 0) {
|
||||
value = !condStack[condTop];
|
||||
|
@ -1126,7 +1126,7 @@ Cond_Eval (char *line)
|
|||
} else {
|
||||
if (isElse) {
|
||||
if (condTop == MAXIF) {
|
||||
Parse_Error (level, "if-less elif");
|
||||
Parse_Error(level, "if-less elif");
|
||||
return (COND_INVALID);
|
||||
} else if (skipIfLevel != 0) {
|
||||
/*
|
||||
|
@ -1136,7 +1136,7 @@ Cond_Eval (char *line)
|
|||
* we're skipping...
|
||||
*/
|
||||
skipIfLineno[skipIfLevel - 1] = lineno;
|
||||
return(COND_SKIP);
|
||||
return (COND_SKIP);
|
||||
}
|
||||
} else if (skipLine) {
|
||||
/*
|
||||
|
@ -1145,7 +1145,7 @@ Cond_Eval (char *line)
|
|||
*/
|
||||
skipIfLineno[skipIfLevel] = lineno;
|
||||
skipIfLevel += 1;
|
||||
return(COND_SKIP);
|
||||
return (COND_SKIP);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1179,7 +1179,7 @@ Cond_Eval (char *line)
|
|||
/*FALLTHRU*/
|
||||
case Err:
|
||||
err:
|
||||
Parse_Error (level, "Malformed conditional (%s)",
|
||||
Parse_Error(level, "Malformed conditional (%s)",
|
||||
line);
|
||||
return (COND_INVALID);
|
||||
default:
|
||||
|
@ -1205,7 +1205,7 @@ Cond_Eval (char *line)
|
|||
* This is the one case where we can definitely proclaim a fatal
|
||||
* error. If we don't, we're hosed.
|
||||
*/
|
||||
Parse_Error (PARSE_FATAL, "Too many nested if's. %d max.", MAXIF);
|
||||
Parse_Error(PARSE_FATAL, "Too many nested if's. %d max.", MAXIF);
|
||||
return (COND_INVALID);
|
||||
} else {
|
||||
condStack[condTop] = value;
|
||||
|
@ -1214,7 +1214,7 @@ Cond_Eval (char *line)
|
|||
return (value ? COND_PARSE : COND_SKIP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Cond_End --
|
||||
|
|
|
@ -209,10 +209,11 @@ static int DirPrintDir(void *, void *);
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Dir_Init (void)
|
||||
Dir_Init(void)
|
||||
{
|
||||
dirSearchPath = Lst_Init (FALSE);
|
||||
openDirectories = Lst_Init (FALSE);
|
||||
|
||||
dirSearchPath = Lst_Init(FALSE);
|
||||
openDirectories = Lst_Init(FALSE);
|
||||
Hash_InitTable(&mtimes, 0);
|
||||
}
|
||||
|
||||
|
@ -229,11 +230,11 @@ Dir_Init (void)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Dir_InitDot (void)
|
||||
Dir_InitDot(void)
|
||||
{
|
||||
LstNode ln;
|
||||
|
||||
Dir_AddDir (openDirectories, ".");
|
||||
Dir_AddDir(openDirectories, ".");
|
||||
if ((ln = Lst_Last(openDirectories)) == NULL)
|
||||
err(1, "cannot open current directory");
|
||||
dot = Lst_Datum(ln);
|
||||
|
@ -260,6 +261,7 @@ Dir_InitDot (void)
|
|||
void
|
||||
Dir_End(void)
|
||||
{
|
||||
|
||||
dot->refCount -= 1;
|
||||
Dir_Destroy((void *) dot);
|
||||
Dir_ClearPath(dirSearchPath);
|
||||
|
@ -284,9 +286,9 @@ Dir_End(void)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
DirFindName (void *p, void *dname)
|
||||
DirFindName(void *p, void *dname)
|
||||
{
|
||||
return (strcmp (((Path *)p)->name, (char *) dname));
|
||||
return (strcmp(((Path *)p)->name, (char *)dname));
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -302,13 +304,13 @@ DirFindName (void *p, void *dname)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Dir_HasWildcards (char *name)
|
||||
Dir_HasWildcards(char *name)
|
||||
{
|
||||
char *cp;
|
||||
int wild = 0, brace = 0, bracket = 0;
|
||||
|
||||
for (cp = name; *cp; cp++) {
|
||||
switch(*cp) {
|
||||
switch (*cp) {
|
||||
case '{':
|
||||
brace++;
|
||||
wild = 1;
|
||||
|
@ -331,7 +333,7 @@ Dir_HasWildcards (char *name)
|
|||
break;
|
||||
}
|
||||
}
|
||||
return wild && bracket == 0 && brace == 0;
|
||||
return (wild && bracket == 0 && brace == 0);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -352,7 +354,7 @@ Dir_HasWildcards (char *name)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
DirMatchFiles (char *pattern, Path *p, Lst expansions)
|
||||
DirMatchFiles(char *pattern, Path *p, Lst expansions)
|
||||
{
|
||||
Hash_Search search; /* Index into the directory's table */
|
||||
Hash_Entry *entry; /* Current entry in the table */
|
||||
|
@ -374,7 +376,7 @@ DirMatchFiles (char *pattern, Path *p, Lst expansions)
|
|||
((entry->name[0] != '.') ||
|
||||
(pattern[0] == '.')))
|
||||
{
|
||||
(void)Lst_AtEnd(expansions,
|
||||
Lst_AtEnd(expansions,
|
||||
(isDot ? estrdup(entry->name) :
|
||||
str_concat(p->name, entry->name,
|
||||
STR_ADDSLASH)));
|
||||
|
@ -418,7 +420,7 @@ DirExpandCurly(char *word, char *brace, Lst path, Lst expansions)
|
|||
char *cp2; /* Pointer for checking for wildcards in
|
||||
* expansion before calling Dir_Expand */
|
||||
|
||||
start = brace+1;
|
||||
start = brace + 1;
|
||||
|
||||
/*
|
||||
* Find the end of the brace clause first, being wary of nested brace
|
||||
|
@ -457,12 +459,12 @@ DirExpandCurly(char *word, char *brace, Lst path, Lst expansions)
|
|||
*/
|
||||
file = emalloc(otherLen + cp - start + 1);
|
||||
if (brace != word) {
|
||||
strncpy(file, word, brace-word);
|
||||
strncpy(file, word, brace - word);
|
||||
}
|
||||
if (cp != start) {
|
||||
strncpy(&file[brace-word], start, cp-start);
|
||||
strncpy(&file[brace - word], start, cp - start);
|
||||
}
|
||||
strcpy(&file[(brace-word)+(cp-start)], end);
|
||||
strcpy(&file[(brace - word) + (cp - start)], end);
|
||||
|
||||
/*
|
||||
* See if the result has any wildcards in it. If we find one, call
|
||||
|
@ -486,7 +488,7 @@ DirExpandCurly(char *word, char *brace, Lst path, Lst expansions)
|
|||
* Hit the end w/o finding any wildcards, so stick the expansion
|
||||
* on the end of the list.
|
||||
*/
|
||||
(void)Lst_AtEnd(expansions, file);
|
||||
Lst_AtEnd(expansions, file);
|
||||
} else {
|
||||
next:
|
||||
free(file);
|
||||
|
@ -544,7 +546,8 @@ DirExpandInt(char *word, Lst path, Lst expansions)
|
|||
static int
|
||||
DirPrintWord(void *word, void *dummy __unused)
|
||||
{
|
||||
DEBUGF(DIR, ("%s ", (char *) word));
|
||||
|
||||
DEBUGF(DIR, ("%s ", (char *)word));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -564,7 +567,7 @@ DirPrintWord(void *word, void *dummy __unused)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Dir_Expand (char *word, Lst path, Lst expansions)
|
||||
Dir_Expand(char *word, Lst path, Lst expansions)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
|
@ -675,7 +678,7 @@ Dir_Expand (char *word, Lst path, Lst expansions)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
char *
|
||||
Dir_FindFile (char *name, Lst path)
|
||||
Dir_FindFile(char *name, Lst path)
|
||||
{
|
||||
char *p1; /* pointer into p->name */
|
||||
char *p2; /* pointer into name */
|
||||
|
@ -691,7 +694,7 @@ Dir_FindFile (char *name, Lst path)
|
|||
* Find the final component of the name and note whether it has a
|
||||
* slash in it (the name, I mean)
|
||||
*/
|
||||
cp = strrchr (name, '/');
|
||||
cp = strrchr(name, '/');
|
||||
if (cp) {
|
||||
hasSlash = TRUE;
|
||||
cp += 1;
|
||||
|
@ -708,17 +711,17 @@ 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) != (Hash_Entry *)NULL)) {
|
||||
DEBUGF(DIR, ("in '.'\n"));
|
||||
hits += 1;
|
||||
dot->hits += 1;
|
||||
return (estrdup (name));
|
||||
return (estrdup(name));
|
||||
}
|
||||
|
||||
if (Lst_Open (path) == FAILURE) {
|
||||
if (Lst_Open(path) == FAILURE) {
|
||||
DEBUGF(DIR, ("couldn't open path, file not found\n"));
|
||||
misses += 1;
|
||||
return ((char *) NULL);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -729,10 +732,10 @@ Dir_FindFile (char *name, Lst path)
|
|||
* and return the resulting string. If we don't find any such thing,
|
||||
* we go on to phase two...
|
||||
*/
|
||||
while ((ln = Lst_Next (path)) != NULL) {
|
||||
p = (Path *) Lst_Datum (ln);
|
||||
while ((ln = Lst_Next(path)) != NULL) {
|
||||
p = (Path *)Lst_Datum (ln);
|
||||
DEBUGF(DIR, ("%s...", p->name));
|
||||
if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) {
|
||||
if (Hash_FindEntry(&p->files, cp) != (Hash_Entry *)NULL) {
|
||||
DEBUGF(DIR, ("here..."));
|
||||
if (hasSlash) {
|
||||
/*
|
||||
|
@ -743,7 +746,7 @@ Dir_FindFile (char *name, Lst path)
|
|||
* we matched only part of one of the components of p
|
||||
* along with all the rest of them (*p1 != '/').
|
||||
*/
|
||||
p1 = p->name + strlen (p->name) - 1;
|
||||
p1 = p->name + strlen(p->name) - 1;
|
||||
p2 = cp - 2;
|
||||
while (p2 >= name && p1 >= p->name && *p1 == *p2) {
|
||||
p1 -= 1; p2 -= 1;
|
||||
|
@ -753,9 +756,9 @@ Dir_FindFile (char *name, Lst path)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
file = str_concat (p->name, cp, STR_ADDSLASH);
|
||||
file = str_concat(p->name, cp, STR_ADDSLASH);
|
||||
DEBUGF(DIR, ("returning %s\n", file));
|
||||
Lst_Close (path);
|
||||
Lst_Close(path);
|
||||
p->hits += 1;
|
||||
hits += 1;
|
||||
return (file);
|
||||
|
@ -769,13 +772,13 @@ Dir_FindFile (char *name, Lst path)
|
|||
continue;
|
||||
}
|
||||
if (*p1 == '\0' && p2 == cp - 1) {
|
||||
Lst_Close (path);
|
||||
Lst_Close(path);
|
||||
if (*cp == '\0' || ISDOT(cp) || ISDOTDOT(cp)) {
|
||||
DEBUGF(DIR, ("returning %s\n", name));
|
||||
return (estrdup(name));
|
||||
} else {
|
||||
DEBUGF(DIR, ("must be here but isn't -- returning NULL\n"));
|
||||
return ((char *) NULL);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -796,18 +799,18 @@ Dir_FindFile (char *name, Lst path)
|
|||
if (!hasSlash) {
|
||||
DEBUGF(DIR, ("failed.\n"));
|
||||
misses += 1;
|
||||
return ((char *) NULL);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
if (*name != '/') {
|
||||
Boolean checkedDot = FALSE;
|
||||
|
||||
DEBUGF(DIR, ("failed. Trying subdirectories..."));
|
||||
(void) Lst_Open (path);
|
||||
while ((ln = Lst_Next (path)) != NULL) {
|
||||
p = (Path *) Lst_Datum (ln);
|
||||
Lst_Open(path);
|
||||
while ((ln = Lst_Next(path)) != NULL) {
|
||||
p = (Path *)Lst_Datum(ln);
|
||||
if (p != dot) {
|
||||
file = str_concat (p->name, name, STR_ADDSLASH);
|
||||
file = str_concat(p->name, name, STR_ADDSLASH);
|
||||
} else {
|
||||
/*
|
||||
* Checking in dot -- DON'T put a leading ./ on the thing.
|
||||
|
@ -817,10 +820,10 @@ Dir_FindFile (char *name, Lst path)
|
|||
}
|
||||
DEBUGF(DIR, ("checking %s...", file));
|
||||
|
||||
if (stat (file, &stb) == 0) {
|
||||
if (stat(file, &stb) == 0) {
|
||||
DEBUGF(DIR, ("got it.\n"));
|
||||
|
||||
Lst_Close (path);
|
||||
Lst_Close(path);
|
||||
|
||||
/*
|
||||
* We've found another directory to search. We know there's
|
||||
|
@ -832,9 +835,9 @@ Dir_FindFile (char *name, Lst path)
|
|||
* again in such a manner, we will find it without having to do
|
||||
* numerous numbers of access calls. Hurrah!
|
||||
*/
|
||||
cp = strrchr (file, '/');
|
||||
cp = strrchr(file, '/');
|
||||
*cp = '\0';
|
||||
Dir_AddDir (path, file);
|
||||
Dir_AddDir(path, file);
|
||||
*cp = '/';
|
||||
|
||||
/*
|
||||
|
@ -842,18 +845,18 @@ 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,
|
||||
entry = Hash_CreateEntry(&mtimes, (char *)file,
|
||||
(Boolean *)NULL);
|
||||
Hash_SetValue(entry, (long)stb.st_mtime);
|
||||
nearmisses += 1;
|
||||
return (file);
|
||||
} else {
|
||||
free (file);
|
||||
free(file);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUGF(DIR, ("failed. "));
|
||||
Lst_Close (path);
|
||||
Lst_Close(path);
|
||||
|
||||
if (checkedDot) {
|
||||
/*
|
||||
|
@ -861,7 +864,7 @@ Dir_FindFile (char *name, Lst path)
|
|||
* so no point in proceeding...
|
||||
*/
|
||||
DEBUGF(DIR, ("Checked . already, returning NULL\n"));
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -884,21 +887,21 @@ Dir_FindFile (char *name, Lst path)
|
|||
*/
|
||||
#ifdef notdef
|
||||
cp[-1] = '\0';
|
||||
Dir_AddDir (path, name);
|
||||
Dir_AddDir(path, name);
|
||||
cp[-1] = '/';
|
||||
|
||||
bigmisses += 1;
|
||||
ln = Lst_Last (path);
|
||||
ln = Lst_Last(path);
|
||||
if (ln == NULL) {
|
||||
return ((char *) NULL);
|
||||
return ((char *)NULL);
|
||||
} else {
|
||||
p = (Path *) Lst_Datum (ln);
|
||||
p = (Path *)Lst_Datum (ln);
|
||||
}
|
||||
|
||||
if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) {
|
||||
return (estrdup (name));
|
||||
if (Hash_FindEntry(&p->files, cp) != (Hash_Entry *)NULL) {
|
||||
return (estrdup(name));
|
||||
} else {
|
||||
return ((char *) NULL);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
#else /* !notdef */
|
||||
DEBUGF(DIR, ("Looking for \"%s\"...", name));
|
||||
|
@ -912,7 +915,7 @@ Dir_FindFile (char *name, Lst path)
|
|||
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);
|
||||
return (estrdup (name));
|
||||
return (estrdup(name));
|
||||
} else {
|
||||
DEBUGF(DIR, ("failed. Returning NULL\n"));
|
||||
return ((char *)NULL);
|
||||
|
@ -936,16 +939,16 @@ Dir_FindFile (char *name, Lst path)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Dir_MTime (GNode *gn)
|
||||
Dir_MTime(GNode *gn)
|
||||
{
|
||||
char *fullName; /* the full pathname of name */
|
||||
struct stat stb; /* buffer for finding the mod time */
|
||||
Hash_Entry *entry;
|
||||
|
||||
if (gn->type & OP_ARCHV) {
|
||||
return Arch_MTime (gn);
|
||||
return (Arch_MTime(gn));
|
||||
} else if (gn->path == (char *)NULL) {
|
||||
fullName = Dir_FindFile (gn->name, dirSearchPath);
|
||||
fullName = Dir_FindFile(gn->name, dirSearchPath);
|
||||
} else {
|
||||
fullName = gn->path;
|
||||
}
|
||||
|
@ -965,11 +968,11 @@ Dir_MTime (GNode *gn)
|
|||
Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName));
|
||||
stb.st_mtime = (time_t)(long)Hash_GetValue(entry);
|
||||
Hash_DeleteEntry(&mtimes, entry);
|
||||
} else if (stat (fullName, &stb) < 0) {
|
||||
} else if (stat(fullName, &stb) < 0) {
|
||||
if (gn->type & OP_MEMBER) {
|
||||
if (fullName != gn->path)
|
||||
free(fullName);
|
||||
return Arch_MemMTime (gn);
|
||||
return (Arch_MemMTime(gn));
|
||||
} else {
|
||||
stb.st_mtime = 0;
|
||||
}
|
||||
|
@ -998,31 +1001,31 @@ Dir_MTime (GNode *gn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Dir_AddDir (Lst path, char *name)
|
||||
Dir_AddDir(Lst path, char *name)
|
||||
{
|
||||
LstNode ln; /* node in case Path structure is found */
|
||||
Path *p; /* pointer to new Path structure */
|
||||
DIR *d; /* for reading directory */
|
||||
struct dirent *dp; /* entry in directory */
|
||||
|
||||
ln = Lst_Find (openDirectories, (void *)name, DirFindName);
|
||||
ln = Lst_Find(openDirectories, (void *)name, DirFindName);
|
||||
if (ln != NULL) {
|
||||
p = (Path *)Lst_Datum (ln);
|
||||
p = (Path *)Lst_Datum(ln);
|
||||
if (Lst_Member(path, (void *)p) == NULL) {
|
||||
p->refCount += 1;
|
||||
(void)Lst_AtEnd (path, (void *)p);
|
||||
Lst_AtEnd(path, (void *)p);
|
||||
}
|
||||
} else {
|
||||
DEBUGF(DIR, ("Caching %s...", name));
|
||||
|
||||
if ((d = opendir (name)) != (DIR *) NULL) {
|
||||
p = (Path *) emalloc (sizeof (Path));
|
||||
p->name = estrdup (name);
|
||||
if ((d = opendir(name)) != (DIR *)NULL) {
|
||||
p = (Path *) emalloc(sizeof(Path));
|
||||
p->name = estrdup(name);
|
||||
p->hits = 0;
|
||||
p->refCount = 1;
|
||||
Hash_InitTable (&p->files, -1);
|
||||
Hash_InitTable(&p->files, -1);
|
||||
|
||||
while ((dp = readdir (d)) != (struct dirent *) NULL) {
|
||||
while ((dp = readdir(d)) != (struct dirent *)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
|
||||
|
@ -1044,12 +1047,12 @@ Dir_AddDir (Lst path, char *name)
|
|||
if (ISDOT(dp->d_name) || ISDOTDOT(dp->d_name))
|
||||
continue;
|
||||
|
||||
(void)Hash_CreateEntry(&p->files, dp->d_name, (Boolean *)NULL);
|
||||
Hash_CreateEntry(&p->files, dp->d_name, (Boolean *)NULL);
|
||||
}
|
||||
(void) closedir (d);
|
||||
(void)Lst_AtEnd (openDirectories, (void *)p);
|
||||
closedir(d);
|
||||
Lst_AtEnd(openDirectories, (void *)p);
|
||||
if (path != openDirectories)
|
||||
(void)Lst_AtEnd (path, (void *)p);
|
||||
Lst_AtEnd(path, (void *)p);
|
||||
}
|
||||
DEBUGF(DIR, ("done\n"));
|
||||
}
|
||||
|
@ -1072,7 +1075,8 @@ Dir_AddDir (Lst path, char *name)
|
|||
void *
|
||||
Dir_CopyDir(void *p)
|
||||
{
|
||||
((Path *) p)->refCount += 1;
|
||||
|
||||
((Path *)p)->refCount += 1;
|
||||
|
||||
return ((void *)p);
|
||||
}
|
||||
|
@ -1095,22 +1099,22 @@ Dir_CopyDir(void *p)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
char *
|
||||
Dir_MakeFlags (char *flag, Lst path)
|
||||
Dir_MakeFlags(char *flag, Lst path)
|
||||
{
|
||||
char *str; /* the string which will be returned */
|
||||
char *tstr; /* the current directory preceded by 'flag' */
|
||||
LstNode ln; /* the node of the current directory */
|
||||
Path *p; /* the structure describing the current directory */
|
||||
|
||||
str = estrdup ("");
|
||||
str = estrdup("");
|
||||
|
||||
if (Lst_Open (path) == SUCCESS) {
|
||||
while ((ln = Lst_Next (path)) != NULL) {
|
||||
p = (Path *) Lst_Datum (ln);
|
||||
tstr = str_concat (flag, p->name, 0);
|
||||
str = str_concat (str, tstr, STR_ADDSPACE | STR_DOFREE);
|
||||
if (Lst_Open(path) == SUCCESS) {
|
||||
while ((ln = Lst_Next(path)) != NULL) {
|
||||
p = (Path *)Lst_Datum(ln);
|
||||
tstr = str_concat(flag, p->name, 0);
|
||||
str = str_concat(str, tstr, STR_ADDSPACE | STR_DOFREE);
|
||||
}
|
||||
Lst_Close (path);
|
||||
Lst_Close(path);
|
||||
}
|
||||
|
||||
return (str);
|
||||
|
@ -1132,18 +1136,18 @@ Dir_MakeFlags (char *flag, Lst path)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Dir_Destroy (void *pp)
|
||||
Dir_Destroy(void *pp)
|
||||
{
|
||||
Path *p = (Path *) pp;
|
||||
Path *p = (Path *)pp;
|
||||
p->refCount -= 1;
|
||||
|
||||
if (p->refCount == 0) {
|
||||
LstNode ln;
|
||||
|
||||
ln = Lst_Member (openDirectories, (void *)p);
|
||||
(void) Lst_Remove (openDirectories, ln);
|
||||
ln = Lst_Member(openDirectories, (void *)p);
|
||||
Lst_Remove(openDirectories, ln);
|
||||
|
||||
Hash_DeleteTable (&p->files);
|
||||
Hash_DeleteTable(&p->files);
|
||||
free(p->name);
|
||||
free(p);
|
||||
}
|
||||
|
@ -1167,6 +1171,7 @@ void
|
|||
Dir_ClearPath(Lst path)
|
||||
{
|
||||
Path *p;
|
||||
|
||||
while (!Lst_IsEmpty(path)) {
|
||||
p = (Path *)Lst_DeQueue(path);
|
||||
Dir_Destroy((void *) p);
|
||||
|
@ -1198,7 +1203,7 @@ Dir_Concat(Lst path1, Lst path2)
|
|||
p = (Path *)Lst_Datum(ln);
|
||||
if (Lst_Member(path1, (void *)p) == NULL) {
|
||||
p->refCount += 1;
|
||||
(void)Lst_AtEnd(path1, (void *)p);
|
||||
Lst_AtEnd(path1, (void *)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1210,31 +1215,33 @@ Dir_PrintDirectories(void)
|
|||
LstNode ln;
|
||||
Path *p;
|
||||
|
||||
printf ("#*** Directory Cache:\n");
|
||||
printf ("# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
|
||||
printf("#*** Directory Cache:\n");
|
||||
printf("# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
|
||||
hits, misses, nearmisses, bigmisses,
|
||||
(hits+bigmisses+nearmisses ?
|
||||
(hits + bigmisses + nearmisses ?
|
||||
hits * 100 / (hits + bigmisses + nearmisses) : 0));
|
||||
printf ("# %-20s referenced\thits\n", "directory");
|
||||
if (Lst_Open (openDirectories) == SUCCESS) {
|
||||
while ((ln = Lst_Next (openDirectories)) != NULL) {
|
||||
p = (Path *) Lst_Datum (ln);
|
||||
printf ("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);
|
||||
printf("# %-20s referenced\thits\n", "directory");
|
||||
if (Lst_Open(openDirectories) == SUCCESS) {
|
||||
while ((ln = Lst_Next(openDirectories)) != NULL) {
|
||||
p = (Path *)Lst_Datum(ln);
|
||||
printf("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);
|
||||
}
|
||||
Lst_Close (openDirectories);
|
||||
Lst_Close(openDirectories);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
DirPrintDir (void *p, void *dummy __unused)
|
||||
DirPrintDir(void *p, void *dummy __unused)
|
||||
{
|
||||
printf ("%s ", ((Path *) p)->name);
|
||||
|
||||
printf("%s ", ((Path *)p)->name);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
Dir_PrintPath (Lst path)
|
||||
Dir_PrintPath(Lst path)
|
||||
{
|
||||
Lst_ForEach (path, DirPrintDir, (void *)0);
|
||||
|
||||
Lst_ForEach(path, DirPrintDir, (void *)0);
|
||||
}
|
||||
|
|
|
@ -68,6 +68,6 @@ void Dir_Concat(Lst, Lst);
|
|||
void Dir_PrintDirectories(void);
|
||||
void Dir_PrintPath(Lst);
|
||||
void Dir_Destroy(void *);
|
||||
void * Dir_CopyDir(void *);
|
||||
void *Dir_CopyDir(void *);
|
||||
|
||||
#endif /* _DIR */
|
||||
|
|
|
@ -86,9 +86,6 @@ typedef struct _For {
|
|||
|
||||
static int ForExec(void *, void *);
|
||||
|
||||
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* For_Eval --
|
||||
|
@ -107,7 +104,7 @@ static int ForExec(void *, void *);
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
For_Eval (char *line)
|
||||
For_Eval(char *line)
|
||||
{
|
||||
char *ptr = line, *sub, *wrd;
|
||||
int level; /* Level at which to report errors. */
|
||||
|
@ -119,53 +116,53 @@ For_Eval (char *line)
|
|||
Buffer buf;
|
||||
int varlen;
|
||||
|
||||
for (ptr++; *ptr && isspace((unsigned char) *ptr); ptr++)
|
||||
for (ptr++; *ptr && isspace((unsigned char)*ptr); ptr++)
|
||||
continue;
|
||||
/*
|
||||
* If we are not in a for loop quickly determine if the statement is
|
||||
* a for.
|
||||
*/
|
||||
if (ptr[0] != 'f' || ptr[1] != 'o' || ptr[2] != 'r' ||
|
||||
!isspace((unsigned char) ptr[3]))
|
||||
return FALSE;
|
||||
!isspace((unsigned char)ptr[3]))
|
||||
return (FALSE);
|
||||
ptr += 3;
|
||||
|
||||
/*
|
||||
* we found a for loop, and now we are going to parse it.
|
||||
*/
|
||||
while (*ptr && isspace((unsigned char) *ptr))
|
||||
while (*ptr && isspace((unsigned char)*ptr))
|
||||
ptr++;
|
||||
|
||||
/*
|
||||
* Grab the variable
|
||||
*/
|
||||
buf = Buf_Init(0);
|
||||
for (wrd = ptr; *ptr && !isspace((unsigned char) *ptr); ptr++)
|
||||
for (wrd = ptr; *ptr && !isspace((unsigned char)*ptr); ptr++)
|
||||
continue;
|
||||
Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd);
|
||||
Buf_AddBytes(buf, ptr - wrd, (Byte *)wrd);
|
||||
|
||||
forVar = (char *) Buf_GetAll(buf, &varlen);
|
||||
forVar = (char *)Buf_GetAll(buf, &varlen);
|
||||
if (varlen == 0) {
|
||||
Parse_Error (level, "missing variable in for");
|
||||
return 0;
|
||||
Parse_Error(level, "missing variable in for");
|
||||
return (0);
|
||||
}
|
||||
Buf_Destroy(buf, FALSE);
|
||||
|
||||
while (*ptr && isspace((unsigned char) *ptr))
|
||||
while (*ptr && isspace((unsigned char)*ptr))
|
||||
ptr++;
|
||||
|
||||
/*
|
||||
* Grab the `in'
|
||||
*/
|
||||
if (ptr[0] != 'i' || ptr[1] != 'n' ||
|
||||
!isspace((unsigned char) ptr[2])) {
|
||||
Parse_Error (level, "missing `in' in for");
|
||||
!isspace((unsigned char)ptr[2])) {
|
||||
Parse_Error(level, "missing `in' in for");
|
||||
printf("%s\n", ptr);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
ptr += 3;
|
||||
|
||||
while (*ptr && isspace((unsigned char) *ptr))
|
||||
while (*ptr && isspace((unsigned char)*ptr))
|
||||
ptr++;
|
||||
|
||||
/*
|
||||
|
@ -176,19 +173,19 @@ For_Eval (char *line)
|
|||
sub = Var_Subst(NULL, ptr, VAR_CMD, FALSE);
|
||||
|
||||
#define ADDWORD() \
|
||||
Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd), \
|
||||
Buf_AddByte(buf, (Byte) '\0'), \
|
||||
Lst_AtFront(forLst, (void *) Buf_GetAll(buf, &varlen)), \
|
||||
Buf_AddBytes(buf, ptr - wrd, (Byte *)wrd), \
|
||||
Buf_AddByte(buf, (Byte)'\0'), \
|
||||
Lst_AtFront(forLst, (void *)Buf_GetAll(buf, &varlen)), \
|
||||
Buf_Destroy(buf, FALSE)
|
||||
|
||||
for (ptr = sub; *ptr && isspace((unsigned char) *ptr); ptr++)
|
||||
for (ptr = sub; *ptr && isspace((unsigned char)*ptr); ptr++)
|
||||
continue;
|
||||
|
||||
for (wrd = ptr; *ptr; ptr++)
|
||||
if (isspace((unsigned char) *ptr)) {
|
||||
if (isspace((unsigned char)*ptr)) {
|
||||
ADDWORD();
|
||||
buf = Buf_Init(0);
|
||||
while (*ptr && isspace((unsigned char) *ptr))
|
||||
while (*ptr && isspace((unsigned char)*ptr))
|
||||
ptr++;
|
||||
wrd = ptr--;
|
||||
}
|
||||
|
@ -201,35 +198,35 @@ For_Eval (char *line)
|
|||
|
||||
forBuf = Buf_Init(0);
|
||||
forLevel++;
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
else if (*ptr == '.') {
|
||||
|
||||
for (ptr++; *ptr && isspace((unsigned char) *ptr); ptr++)
|
||||
for (ptr++; *ptr && isspace((unsigned char)*ptr); ptr++)
|
||||
continue;
|
||||
|
||||
if (strncmp(ptr, "endfor", 6) == 0 &&
|
||||
(isspace((unsigned char) ptr[6]) || !ptr[6])) {
|
||||
(isspace((unsigned char)ptr[6]) || !ptr[6])) {
|
||||
DEBUGF(FOR, ("For: end for %d\n", forLevel));
|
||||
if (--forLevel < 0) {
|
||||
Parse_Error (level, "for-less endfor");
|
||||
return 0;
|
||||
Parse_Error(level, "for-less endfor");
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
else if (strncmp(ptr, "for", 3) == 0 &&
|
||||
isspace((unsigned char) ptr[3])) {
|
||||
isspace((unsigned char)ptr[3])) {
|
||||
forLevel++;
|
||||
DEBUGF(FOR, ("For: new loop %d\n", forLevel));
|
||||
}
|
||||
}
|
||||
|
||||
if (forLevel != 0) {
|
||||
Buf_AddBytes(forBuf, strlen(line), (Byte *) line);
|
||||
Buf_AddByte(forBuf, (Byte) '\n');
|
||||
return 1;
|
||||
Buf_AddBytes(forBuf, strlen(line), (Byte *)line);
|
||||
Buf_AddByte(forBuf, (Byte)'\n');
|
||||
return (1);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,14 +251,13 @@ ForExec(void *namep, void *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),
|
||||
Parse_FromString(Var_Subst(arg->var, (char *)Buf_GetAll(arg->buf, &len),
|
||||
VAR_GLOBAL, FALSE), arg->lineno);
|
||||
Var_Delete(arg->var, VAR_GLOBAL);
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* For_Run --
|
||||
|
@ -290,7 +286,7 @@ For_Run(int lineno)
|
|||
forBuf = NULL;
|
||||
forLst = NULL;
|
||||
|
||||
Lst_ForEach(arg.lst, ForExec, (void *) &arg);
|
||||
Lst_ForEach(arg.lst, ForExec, (void *)&arg);
|
||||
|
||||
free(arg.var);
|
||||
Lst_Destroy(arg.lst, free);
|
||||
|
|
|
@ -72,7 +72,7 @@ static void RebuildTable(Hash_Table *);
|
|||
*---------------------------------------------------------
|
||||
*
|
||||
* Hash_InitTable --
|
||||
*
|
||||
*
|
||||
* Set up the hash table t with a given number of buckets, or a
|
||||
* reasonable default if the number requested is less than or
|
||||
* equal to zero. Hash tables will grow in size as needed.
|
||||
|
@ -234,13 +234,13 @@ 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 = (Hash_Entry *)emalloc(sizeof(*e) + keylen);
|
||||
hp = &t->bucketPtr[h & t->mask];
|
||||
e->next = *hp;
|
||||
*hp = e;
|
||||
e->clientData = NULL;
|
||||
e->namehash = h;
|
||||
(void) strcpy(e->name, p);
|
||||
strcpy(e->name, p);
|
||||
t->numEntries++;
|
||||
|
||||
if (newPtr != NULL)
|
||||
|
@ -281,7 +281,7 @@ Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
|
|||
return;
|
||||
}
|
||||
}
|
||||
(void) write(STDERR_FILENO, "bad call to Hash_DeleteEntry\n", 29);
|
||||
write(STDERR_FILENO, "bad call to Hash_DeleteEntry\n", 29);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -307,10 +307,11 @@ Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
|
|||
Hash_Entry *
|
||||
Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr)
|
||||
{
|
||||
|
||||
searchPtr->tablePtr = t;
|
||||
searchPtr->nextIndex = 0;
|
||||
searchPtr->hashEntryPtr = NULL;
|
||||
return Hash_EnumNext(searchPtr);
|
||||
return (Hash_EnumNext(searchPtr));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -388,7 +389,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 = (struct Hash_Entry **)emalloc(sizeof(*hp) * i);
|
||||
while (--i >= 0)
|
||||
*hp++ = NULL;
|
||||
for (hp = oldhp, i = oldsize; --i >= 0;) {
|
||||
|
|
|
@ -99,13 +99,13 @@ typedef struct Hash_Search {
|
|||
* char *val;
|
||||
*/
|
||||
|
||||
#define Hash_SetValue(h, val) ((h)->clientData = (void *) (val))
|
||||
#define Hash_SetValue(h, val) ((h)->clientData = (void *)(val))
|
||||
|
||||
/*
|
||||
* Hash_Size(n) returns the number of words in an object of n bytes
|
||||
*/
|
||||
|
||||
#define Hash_Size(n) (((n) + sizeof (int) - 1) / sizeof (int))
|
||||
#define Hash_Size(n) (((n) + sizeof(int) - 1) / sizeof(int))
|
||||
|
||||
void Hash_InitTable(Hash_Table *, int);
|
||||
void Hash_DeleteTable(Hash_Table *);
|
||||
|
|
|
@ -139,7 +139,7 @@ static int aborting = 0; /* why is the make aborting? */
|
|||
* XXX: Avoid SunOS bug... FILENO() is fp->_file, and file
|
||||
* is a char! So when we go above 127 we turn negative!
|
||||
*/
|
||||
#define FILENO(a) ((unsigned) fileno(a))
|
||||
#define FILENO(a) ((unsigned)fileno(a))
|
||||
|
||||
/*
|
||||
* post-make command processing. The node postCommands is really just the
|
||||
|
@ -162,7 +162,7 @@ static int numCommands; /* The number of commands actually printed
|
|||
|
||||
/*
|
||||
* tfile is used to build temp file names to store shell commands to
|
||||
* execute.
|
||||
* execute.
|
||||
*/
|
||||
static char tfile[sizeof(TMPPAT)];
|
||||
|
||||
|
@ -233,7 +233,7 @@ STATIC char *targFmt; /* Format string to use to head output from a
|
|||
|
||||
#define TARG_FMT "--- %s ---\n" /* Default format */
|
||||
#define MESSAGE(fp, gn) \
|
||||
(void) fprintf(fp, targFmt, gn->name);
|
||||
fprintf(fp, targFmt, gn->name);
|
||||
|
||||
/*
|
||||
* When JobStart attempts to run a job but isn't allowed to
|
||||
|
@ -270,7 +270,7 @@ static sig_atomic_t interrupted;
|
|||
*/
|
||||
#define W_SETMASKED(st, val, fun) \
|
||||
{ \
|
||||
int sh = (int) ~0; \
|
||||
int sh = (int)~0; \
|
||||
int mask = fun(sh); \
|
||||
\
|
||||
for (sh = 0; ((mask >> sh) & 1) == 0; sh++) \
|
||||
|
@ -328,13 +328,13 @@ JobCatchSig(int signo)
|
|||
static int
|
||||
JobCondPassSig(void *jobp, void *signop)
|
||||
{
|
||||
Job *job = (Job *) jobp;
|
||||
int signo = *(int *) signop;
|
||||
Job *job = (Job *)jobp;
|
||||
int signo = *(int *)signop;
|
||||
|
||||
DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n",
|
||||
signo, job->pid));
|
||||
KILL(job->pid, signo);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -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, (void *)&signo);
|
||||
|
||||
/*
|
||||
* Deal with proper cleanup based on the signal received. We only run
|
||||
|
@ -394,15 +394,16 @@ JobPassSig(int signo)
|
|||
act.sa_flags = 0;
|
||||
sigaction(signo, &act, NULL);
|
||||
|
||||
DEBUGF(JOB, ("JobPassSig passing signal to self, mask = %x.\n", ~0 & ~(1 << (signo-1))));
|
||||
(void) signal(signo, SIG_DFL);
|
||||
DEBUGF(JOB, ("JobPassSig passing signal to self, mask = %x.\n",
|
||||
~0 & ~(1 << (signo - 1))));
|
||||
signal(signo, SIG_DFL);
|
||||
|
||||
(void) KILL(getpid(), signo);
|
||||
KILL(getpid(), signo);
|
||||
|
||||
signo = SIGCONT;
|
||||
Lst_ForEach(jobs, JobCondPassSig, (void *) &signo);
|
||||
Lst_ForEach(jobs, JobCondPassSig, (void *)&signo);
|
||||
|
||||
(void) sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||
act.sa_handler = JobPassSig;
|
||||
sigaction(signo, &act, NULL);
|
||||
|
@ -425,7 +426,7 @@ JobPassSig(int signo)
|
|||
static int
|
||||
JobCmpPid(void *job, void *pid)
|
||||
{
|
||||
return *(int *) pid - ((Job *) job)->pid;
|
||||
return (*(int *)pid - ((Job *)job)->pid);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -470,8 +471,8 @@ 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 = (char *)cmdp;
|
||||
Job *job = (Job *)jobp;
|
||||
|
||||
noSpecials = (noExecute && !(job->node->type & OP_MAKE));
|
||||
|
||||
|
@ -480,15 +481,15 @@ JobPrintCommand(void *cmdp, void *jobp)
|
|||
if ((job->flags & JOB_IGNDOTS) == 0) {
|
||||
job->tailCmds = Lst_Succ(Lst_Member(job->node->commands,
|
||||
(void *)cmd));
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
#define DBPRINTF(fmt, arg) \
|
||||
DEBUGF(JOB, (fmt, arg)); \
|
||||
(void) fprintf(job->cmdFILE, fmt, arg); \
|
||||
(void) fflush(job->cmdFILE);
|
||||
fprintf(job->cmdFILE, fmt, arg); \
|
||||
fflush(job->cmdFILE);
|
||||
|
||||
numCommands += 1;
|
||||
|
||||
|
@ -531,7 +532,7 @@ JobPrintCommand(void *cmdp, void *jobp)
|
|||
cmd++;
|
||||
}
|
||||
|
||||
while (isspace((unsigned char) *cmd))
|
||||
while (isspace((unsigned char)*cmd))
|
||||
cmd++;
|
||||
|
||||
if (shutUp) {
|
||||
|
@ -612,7 +613,7 @@ JobPrintCommand(void *cmdp, void *jobp)
|
|||
if (shutUp) {
|
||||
DBPRINTF("%s\n", commandShell->echoOn);
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -632,9 +633,10 @@ JobPrintCommand(void *cmdp, void *jobp)
|
|||
static int
|
||||
JobSaveCommand(void *cmd, void *gn)
|
||||
{
|
||||
cmd = (void *) Var_Subst(NULL, (char *) cmd, (GNode *) gn, FALSE);
|
||||
(void) Lst_AtEnd(postCommands->commands, cmd);
|
||||
return(0);
|
||||
|
||||
cmd = (void *)Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE);
|
||||
Lst_AtEnd(postCommands->commands, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -654,17 +656,18 @@ JobSaveCommand(void *cmd, void *gn)
|
|||
static void
|
||||
JobClose(Job *job)
|
||||
{
|
||||
|
||||
if (usePipes) {
|
||||
#if !defined(USE_KQUEUE)
|
||||
FD_CLR(job->inPipe, &outputs);
|
||||
#endif
|
||||
if (job->outPipe != job->inPipe) {
|
||||
(void) close(job->outPipe);
|
||||
close(job->outPipe);
|
||||
}
|
||||
JobDoOutput(job, TRUE);
|
||||
(void) close(job->inPipe);
|
||||
close(job->inPipe);
|
||||
} else {
|
||||
(void) close(job->outFd);
|
||||
close(job->outFd);
|
||||
JobDoOutput(job, TRUE);
|
||||
}
|
||||
}
|
||||
|
@ -712,7 +715,7 @@ JobFinish(Job *job, int *status)
|
|||
*/
|
||||
JobClose(job);
|
||||
if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
|
||||
(void) fclose(job->cmdFILE);
|
||||
fclose(job->cmdFILE);
|
||||
}
|
||||
done = TRUE;
|
||||
} else if (WIFEXITED(*status)) {
|
||||
|
@ -765,7 +768,7 @@ JobFinish(Job *job, int *status)
|
|||
MESSAGE(out, job->node);
|
||||
lastNode = job->node;
|
||||
}
|
||||
(void) fprintf(out, "*** Error code %d%s\n",
|
||||
fprintf(out, "*** Error code %d%s\n",
|
||||
WEXITSTATUS(*status),
|
||||
(job->flags & JOB_IGNERR) ? "(ignored)" : "");
|
||||
|
||||
|
@ -777,7 +780,7 @@ JobFinish(Job *job, int *status)
|
|||
MESSAGE(out, job->node);
|
||||
lastNode = job->node;
|
||||
}
|
||||
(void) fprintf(out, "*** Completed successfully\n");
|
||||
fprintf(out, "*** Completed successfully\n");
|
||||
}
|
||||
} else if (WIFSTOPPED(*status)) {
|
||||
DEBUGF(JOB, ("Process %d stopped.\n", job->pid));
|
||||
|
@ -785,11 +788,11 @@ JobFinish(Job *job, int *status)
|
|||
MESSAGE(out, job->node);
|
||||
lastNode = job->node;
|
||||
}
|
||||
(void) fprintf(out, "*** Stopped -- signal %d\n",
|
||||
fprintf(out, "*** Stopped -- signal %d\n",
|
||||
WSTOPSIG(*status));
|
||||
job->flags |= JOB_RESUME;
|
||||
(void)Lst_AtEnd(stoppedJobs, (void *)job);
|
||||
(void) fflush(out);
|
||||
Lst_AtEnd(stoppedJobs, (void *)job);
|
||||
fflush(out);
|
||||
return;
|
||||
} else if (WTERMSIG(*status) == SIGCONT) {
|
||||
/*
|
||||
|
@ -802,7 +805,7 @@ JobFinish(Job *job, int *status)
|
|||
MESSAGE(out, job->node);
|
||||
lastNode = job->node;
|
||||
}
|
||||
(void) fprintf(out, "*** Continued\n");
|
||||
fprintf(out, "*** Continued\n");
|
||||
}
|
||||
if (!(job->flags & JOB_CONTINUING)) {
|
||||
DEBUGF(JOB, ("Warning: process %d was not continuing.\n", job->pid));
|
||||
|
@ -824,17 +827,17 @@ JobFinish(Job *job, int *status)
|
|||
jobFull = TRUE;
|
||||
DEBUGF(JOB, ("Job queue is full.\n"));
|
||||
}
|
||||
(void) fflush(out);
|
||||
fflush(out);
|
||||
return;
|
||||
} else {
|
||||
if (usePipes && job->node != lastNode) {
|
||||
MESSAGE(out, job->node);
|
||||
lastNode = job->node;
|
||||
}
|
||||
(void) fprintf(out, "*** Signal %d\n", WTERMSIG(*status));
|
||||
fprintf(out, "*** Signal %d\n", WTERMSIG(*status));
|
||||
}
|
||||
|
||||
(void) fflush(out);
|
||||
fflush(out);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -944,8 +947,8 @@ Job_Touch(GNode *gn, Boolean silent)
|
|||
}
|
||||
|
||||
if (!silent) {
|
||||
(void) fprintf(stdout, "touch %s\n", gn->name);
|
||||
(void) fflush(stdout);
|
||||
fprintf(stdout, "touch %s\n", gn->name);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
if (noExecute) {
|
||||
|
@ -971,15 +974,15 @@ Job_Touch(GNode *gn, Boolean silent)
|
|||
* modification time, then close the file.
|
||||
*/
|
||||
if (read(streamID, &c, 1) == 1) {
|
||||
(void) lseek(streamID, (off_t)0, SEEK_SET);
|
||||
(void) write(streamID, &c, 1);
|
||||
lseek(streamID, (off_t)0, SEEK_SET);
|
||||
write(streamID, &c, 1);
|
||||
}
|
||||
|
||||
(void) close(streamID);
|
||||
close(streamID);
|
||||
} else {
|
||||
(void) fprintf(stdout, "*** couldn't touch %s: %s",
|
||||
fprintf(stdout, "*** couldn't touch %s: %s",
|
||||
file, strerror(errno));
|
||||
(void) fflush(stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1001,6 +1004,7 @@ Job_Touch(GNode *gn, Boolean silent)
|
|||
Boolean
|
||||
Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
|
||||
{
|
||||
|
||||
if (OP_NOP(gn->type) && Lst_IsEmpty(gn->commands) &&
|
||||
(gn->type & OP_LIB) == 0) {
|
||||
/*
|
||||
|
@ -1032,12 +1036,12 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
|
|||
static const char msg[] = "make: don't know how to make";
|
||||
|
||||
if (gn->type & OP_OPTIONAL) {
|
||||
(void) fprintf(stdout, "%s %s(ignored)\n", msg, gn->name);
|
||||
(void) fflush(stdout);
|
||||
fprintf(stdout, "%s %s(ignored)\n", msg, gn->name);
|
||||
fflush(stdout);
|
||||
} else if (keepgoing) {
|
||||
(void) fprintf(stdout, "%s %s(continuing)\n", msg, gn->name);
|
||||
(void) fflush(stdout);
|
||||
return FALSE;
|
||||
fprintf(stdout, "%s %s(continuing)\n", msg, gn->name);
|
||||
fflush(stdout);
|
||||
return (FALSE);
|
||||
} else {
|
||||
#if OLD_JOKE
|
||||
if (strcmp(gn->name,"love") == 0)
|
||||
|
@ -1045,11 +1049,11 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
|
|||
else
|
||||
#endif
|
||||
(*abortProc)("%s %s. Stop", msg, gn->name);
|
||||
return FALSE;
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -1108,8 +1112,8 @@ JobExec(Job *job, char **argv)
|
|||
*/
|
||||
if (dup2(FILENO(job->cmdFILE), 0) == -1)
|
||||
Punt("Cannot dup2: %s", strerror(errno));
|
||||
(void) fcntl(0, F_SETFD, 0);
|
||||
(void) lseek(0, (off_t)0, SEEK_SET);
|
||||
fcntl(0, F_SETFD, 0);
|
||||
lseek(0, (off_t)0, SEEK_SET);
|
||||
|
||||
if (usePipes) {
|
||||
/*
|
||||
|
@ -1133,7 +1137,7 @@ JobExec(Job *job, char **argv)
|
|||
* it before routing the shell's error output to the same place as
|
||||
* its standard output.
|
||||
*/
|
||||
(void) fcntl(1, F_SETFD, 0);
|
||||
fcntl(1, F_SETFD, 0);
|
||||
if (dup2(1, 2) == -1)
|
||||
Punt("Cannot dup2: %s", strerror(errno));
|
||||
|
||||
|
@ -1144,15 +1148,15 @@ JobExec(Job *job, char **argv)
|
|||
* by killing its process family, but not commit suicide.
|
||||
*/
|
||||
# if defined(SYSV)
|
||||
(void) setsid();
|
||||
setsid();
|
||||
# else
|
||||
(void) setpgid(0, getpid());
|
||||
setpgid(0, getpid());
|
||||
# endif
|
||||
#endif /* USE_PGRP */
|
||||
|
||||
(void) execv(shellPath, argv);
|
||||
execv(shellPath, argv);
|
||||
|
||||
(void) write(STDERR_FILENO, "Could not execute shell\n",
|
||||
write(STDERR_FILENO, "Could not execute shell\n",
|
||||
sizeof("Could not execute shell"));
|
||||
_exit(1);
|
||||
} else {
|
||||
|
@ -1184,7 +1188,7 @@ JobExec(Job *job, char **argv)
|
|||
}
|
||||
|
||||
if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
|
||||
(void) fclose(job->cmdFILE);
|
||||
fclose(job->cmdFILE);
|
||||
job->cmdFILE = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1193,7 +1197,7 @@ JobExec(Job *job, char **argv)
|
|||
* Now the job is actually running, add it to the table.
|
||||
*/
|
||||
nJobs += 1;
|
||||
(void) Lst_AtEnd(jobs, (void *)job);
|
||||
Lst_AtEnd(jobs, (void *)job);
|
||||
if (nJobs == maxJobs) {
|
||||
jobFull = TRUE;
|
||||
}
|
||||
|
@ -1229,7 +1233,7 @@ JobMakeArgv(Job *job, char **argv)
|
|||
* Bourne shell thinks its second argument is a file to source.
|
||||
* Grrrr. Note the ten-character limitation on the combined arguments.
|
||||
*/
|
||||
(void)sprintf(args, "-%s%s",
|
||||
sprintf(args, "-%s%s",
|
||||
((job->flags & JOB_IGNERR) ? "" :
|
||||
(commandShell->exit ? commandShell->exit : "")),
|
||||
((job->flags & JOB_SILENT) ? "" :
|
||||
|
@ -1289,7 +1293,7 @@ JobRestart(Job *job)
|
|||
* back on the hold queue and mark the table full
|
||||
*/
|
||||
DEBUGF(JOB, ("holding\n"));
|
||||
(void)Lst_AtFront(stoppedJobs, (void *)job);
|
||||
Lst_AtFront(stoppedJobs, (void *)job);
|
||||
jobFull = TRUE;
|
||||
DEBUGF(JOB, ("Job queue is full.\n"));
|
||||
return;
|
||||
|
@ -1344,7 +1348,7 @@ JobRestart(Job *job)
|
|||
* place the job back on the list of stopped jobs.
|
||||
*/
|
||||
DEBUGF(JOB, ("table full\n"));
|
||||
(void) Lst_AtFront(stoppedJobs, (void *)job);
|
||||
Lst_AtFront(stoppedJobs, (void *)job);
|
||||
jobFull = TRUE;
|
||||
DEBUGF(JOB, ("Job queue is full.\n"));
|
||||
}
|
||||
|
@ -1384,7 +1388,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 = (Job *)emalloc(sizeof(Job));
|
||||
flags |= JOB_FIRST;
|
||||
}
|
||||
|
||||
|
@ -1430,7 +1434,7 @@ JobStart(GNode *gn, int flags, Job *previous)
|
|||
DieHorribly();
|
||||
}
|
||||
|
||||
(void) strcpy(tfile, TMPPAT);
|
||||
strcpy(tfile, TMPPAT);
|
||||
if ((tfd = mkstemp(tfile)) == -1)
|
||||
Punt("Cannot create temp file: %s", strerror(errno));
|
||||
job->cmdFILE = fdopen(tfd, "w+");
|
||||
|
@ -1439,7 +1443,7 @@ JobStart(GNode *gn, int flags, Job *previous)
|
|||
close(tfd);
|
||||
Punt("Could not open %s", tfile);
|
||||
}
|
||||
(void) fcntl(FILENO(job->cmdFILE), F_SETFD, 1);
|
||||
fcntl(FILENO(job->cmdFILE), F_SETFD, 1);
|
||||
/*
|
||||
* Send the commands to the command file, flush all its buffers then
|
||||
* rewind and remove the thing.
|
||||
|
@ -1465,8 +1469,8 @@ JobStart(GNode *gn, int flags, Job *previous)
|
|||
LstNode ln = Lst_Next(gn->commands);
|
||||
|
||||
if ((ln == NULL) ||
|
||||
JobPrintCommand((void *) Lst_Datum(ln),
|
||||
(void *) job))
|
||||
JobPrintCommand((void *)Lst_Datum(ln),
|
||||
(void *)job))
|
||||
{
|
||||
noExec = TRUE;
|
||||
Lst_Close(gn->commands);
|
||||
|
@ -1544,9 +1548,9 @@ JobStart(GNode *gn, int flags, Job *previous)
|
|||
*/
|
||||
if (job->cmdFILE != stdout) {
|
||||
if (job->cmdFILE != NULL)
|
||||
(void) fclose(job->cmdFILE);
|
||||
fclose(job->cmdFILE);
|
||||
} else {
|
||||
(void) fflush(stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1570,7 +1574,7 @@ JobStart(GNode *gn, int flags, Job *previous)
|
|||
return(JOB_ERROR);
|
||||
}
|
||||
} else {
|
||||
(void) fflush(job->cmdFILE);
|
||||
fflush(job->cmdFILE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1587,19 +1591,20 @@ JobStart(GNode *gn, int flags, Job *previous)
|
|||
if (!compatMake || (job->flags & JOB_FIRST)) {
|
||||
if (usePipes) {
|
||||
int fd[2];
|
||||
|
||||
if (pipe(fd) == -1)
|
||||
Punt("Cannot create pipe: %s", strerror(errno));
|
||||
job->inPipe = fd[0];
|
||||
job->outPipe = fd[1];
|
||||
(void) fcntl(job->inPipe, F_SETFD, 1);
|
||||
(void) fcntl(job->outPipe, F_SETFD, 1);
|
||||
fcntl(job->inPipe, F_SETFD, 1);
|
||||
fcntl(job->outPipe, F_SETFD, 1);
|
||||
} else {
|
||||
(void) fprintf(stdout, "Remaking `%s'\n", gn->name);
|
||||
(void) fflush(stdout);
|
||||
(void) strcpy(job->outFile, TMPPAT);
|
||||
fprintf(stdout, "Remaking `%s'\n", gn->name);
|
||||
fflush(stdout);
|
||||
strcpy(job->outFile, TMPPAT);
|
||||
if ((job->outFd = mkstemp(job->outFile)) == -1)
|
||||
Punt("cannot create temp file: %s", strerror(errno));
|
||||
(void) fcntl(job->outFd, F_SETFD, 1);
|
||||
fcntl(job->outFd, F_SETFD, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1614,7 +1619,7 @@ JobStart(GNode *gn, int flags, Job *previous)
|
|||
|
||||
DEBUGF(JOB, ("Can only run job locally.\n"));
|
||||
job->flags |= JOB_RESTART;
|
||||
(void) Lst_AtEnd(stoppedJobs, (void *)job);
|
||||
Lst_AtEnd(stoppedJobs, (void *)job);
|
||||
} else {
|
||||
if (nJobs >= maxJobs) {
|
||||
/*
|
||||
|
@ -1626,7 +1631,7 @@ JobStart(GNode *gn, int flags, Job *previous)
|
|||
}
|
||||
JobExec(job, argv);
|
||||
}
|
||||
return(JOB_RUNNING);
|
||||
return (JOB_RUNNING);
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -1649,8 +1654,8 @@ JobOutput(Job *job, char *cp, char *endp, int msg)
|
|||
* however, since the non-printable comes after it,
|
||||
* there must be a newline, so we don't print one.
|
||||
*/
|
||||
(void) fprintf(stdout, "%s", cp);
|
||||
(void) fflush(stdout);
|
||||
fprintf(stdout, "%s", cp);
|
||||
fflush(stdout);
|
||||
}
|
||||
cp = ecp + commandShell->noPLen;
|
||||
if (cp != endp) {
|
||||
|
@ -1665,11 +1670,11 @@ JobOutput(Job *job, char *cp, char *endp, int msg)
|
|||
}
|
||||
ecp = strstr(cp, commandShell->noPrint);
|
||||
} else {
|
||||
return cp;
|
||||
return (cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cp;
|
||||
return (cp);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -1808,13 +1813,13 @@ JobDoOutput(Job *job, Boolean finish)
|
|||
MESSAGE(stdout, job->node);
|
||||
lastNode = job->node;
|
||||
}
|
||||
(void) fprintf(stdout, "%s%s", cp, gotNL ? "\n" : "");
|
||||
(void) fflush(stdout);
|
||||
fprintf(stdout, "%s%s", cp, gotNL ? "\n" : "");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
if (i < max - 1) {
|
||||
/* shift the remaining characters down */
|
||||
(void) memcpy(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
|
||||
memcpy(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
|
||||
job->curPos = max - (i + 1);
|
||||
|
||||
} else {
|
||||
|
@ -1849,8 +1854,8 @@ JobDoOutput(Job *job, Boolean finish)
|
|||
*/
|
||||
oFILE = fopen(job->outFile, "r");
|
||||
if (oFILE != NULL) {
|
||||
(void) fprintf(stdout, "Results of making %s:\n", job->node->name);
|
||||
(void) 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;
|
||||
|
||||
|
@ -1866,15 +1871,15 @@ JobDoOutput(Job *job, Boolean finish)
|
|||
* we know there's no newline at the end, so we add one of
|
||||
* our own free will.
|
||||
*/
|
||||
(void) fprintf(stdout, "%s", cp);
|
||||
(void) fflush(stdout);
|
||||
fprintf(stdout, "%s", cp);
|
||||
fflush(stdout);
|
||||
if (endp != oendp) {
|
||||
(void) fprintf(stdout, "\n");
|
||||
(void) fflush(stdout);
|
||||
fprintf(stdout, "\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
(void) fclose(oFILE);
|
||||
(void) eunlink(job->outFile);
|
||||
fclose(oFILE);
|
||||
eunlink(job->outFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1914,7 +1919,7 @@ Job_CatchChildren(Boolean block)
|
|||
}
|
||||
|
||||
for (;;) {
|
||||
pid = waitpid((pid_t) -1, &status, (block?0:WNOHANG)|WUNTRACED);
|
||||
pid = waitpid((pid_t)-1, &status, (block ? 0 : WNOHANG) | WUNTRACED);
|
||||
if (pid <= 0)
|
||||
break;
|
||||
DEBUGF(JOB, ("Process %d exited or stopped.\n", pid));
|
||||
|
@ -1923,20 +1928,20 @@ Job_CatchChildren(Boolean block)
|
|||
|
||||
if (jnode == NULL) {
|
||||
if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) {
|
||||
jnode = Lst_Find(stoppedJobs, (void *) &pid, JobCmpPid);
|
||||
jnode = Lst_Find(stoppedJobs, (void *)&pid, JobCmpPid);
|
||||
if (jnode == NULL) {
|
||||
Error("Resumed child (%d) not in table", pid);
|
||||
continue;
|
||||
}
|
||||
job = (Job *)Lst_Datum(jnode);
|
||||
(void) Lst_Remove(stoppedJobs, jnode);
|
||||
Lst_Remove(stoppedJobs, jnode);
|
||||
} else {
|
||||
Error("Child (%d) not in table?", pid);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
job = (Job *) Lst_Datum(jnode);
|
||||
(void) Lst_Remove(jobs, jnode);
|
||||
job = (Job *)Lst_Datum(jnode);
|
||||
Lst_Remove(jobs, jnode);
|
||||
nJobs -= 1;
|
||||
if (fifoFd >= 0 && maxJobs > 1) {
|
||||
write(fifoFd, "+", 1);
|
||||
|
@ -1962,7 +1967,7 @@ Job_CatchChildren(Boolean block)
|
|||
* Job_CatchOutput --
|
||||
* Catch the output from our children, if we're using
|
||||
* pipes do so. Otherwise just block time until we get a
|
||||
* signal (most likely a SIGCHLD) since there's no point in
|
||||
* signal(most likely a SIGCHLD) since there's no point in
|
||||
* just spinning when there's nothing to do and the reaping
|
||||
* of a child can wait for a while.
|
||||
*
|
||||
|
@ -1988,7 +1993,7 @@ Job_CatchOutput(int flag)
|
|||
Job *job;
|
||||
#endif
|
||||
|
||||
(void) fflush(stdout);
|
||||
fflush(stdout);
|
||||
|
||||
if (usePipes) {
|
||||
#ifdef USE_KQUEUE
|
||||
|
@ -2024,7 +2029,7 @@ Job_CatchOutput(int flag)
|
|||
nfds = select(FD_SETSIZE, &readfds, (fd_set *) 0,
|
||||
(fd_set *) 0, &timeout);
|
||||
if (nfds <= 0) {
|
||||
if (interrupted)
|
||||
if (interrupted)
|
||||
JobPassSig(interrupted);
|
||||
return;
|
||||
}
|
||||
|
@ -2036,7 +2041,7 @@ Job_CatchOutput(int flag)
|
|||
Punt("Cannot open job table");
|
||||
}
|
||||
while (nfds && (ln = Lst_Next(jobs)) != NULL) {
|
||||
job = (Job *) Lst_Datum(ln);
|
||||
job = (Job *)Lst_Datum(ln);
|
||||
if (FD_ISSET(job->inPipe, &readfds)) {
|
||||
JobDoOutput(job, FALSE);
|
||||
nfds -= 1;
|
||||
|
@ -2064,7 +2069,8 @@ Job_CatchOutput(int flag)
|
|||
void
|
||||
Job_Make(GNode *gn)
|
||||
{
|
||||
(void) JobStart(gn, 0, NULL);
|
||||
|
||||
JobStart(gn, 0, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2183,8 +2189,8 @@ Job_Init(int maxproc)
|
|||
const char *env;
|
||||
struct sigaction sa;
|
||||
|
||||
fifoFd = -1;
|
||||
jobs = Lst_Init(FALSE);
|
||||
fifoFd = -1;
|
||||
jobs = Lst_Init(FALSE);
|
||||
stoppedJobs = Lst_Init(FALSE);
|
||||
env = getenv("MAKE_JOBS_FIFO");
|
||||
|
||||
|
@ -2234,12 +2240,12 @@ Job_Init(int maxproc)
|
|||
jobFull = FALSE;
|
||||
} else {
|
||||
}
|
||||
nJobs = 0;
|
||||
nJobs = 0;
|
||||
|
||||
aborting = 0;
|
||||
errors = 0;
|
||||
aborting = 0;
|
||||
errors = 0;
|
||||
|
||||
lastNode = NULL;
|
||||
lastNode = NULL;
|
||||
|
||||
if ((maxJobs == 1 && fifoFd < 0) || beVerbose == 0) {
|
||||
/*
|
||||
|
@ -2263,16 +2269,16 @@ Job_Init(int maxproc)
|
|||
sa.sa_flags = 0;
|
||||
|
||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
|
||||
(void) sigaction(SIGINT, &sa, NULL);
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
}
|
||||
if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
|
||||
(void) sigaction(SIGHUP, &sa, NULL);
|
||||
sigaction(SIGHUP, &sa, NULL);
|
||||
}
|
||||
if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
|
||||
(void) sigaction(SIGQUIT, &sa, NULL);
|
||||
sigaction(SIGQUIT, &sa, NULL);
|
||||
}
|
||||
if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
|
||||
(void) sigaction(SIGTERM, &sa, NULL);
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
}
|
||||
/*
|
||||
* There are additional signals that need to be caught and passed if
|
||||
|
@ -2282,16 +2288,16 @@ Job_Init(int maxproc)
|
|||
*/
|
||||
#if defined(USE_PGRP)
|
||||
if (signal(SIGTSTP, SIG_IGN) != SIG_IGN) {
|
||||
(void) sigaction(SIGTSTP, &sa, NULL);
|
||||
sigaction(SIGTSTP, &sa, NULL);
|
||||
}
|
||||
if (signal(SIGTTOU, SIG_IGN) != SIG_IGN) {
|
||||
(void) sigaction(SIGTTOU, &sa, NULL);
|
||||
sigaction(SIGTTOU, &sa, NULL);
|
||||
}
|
||||
if (signal(SIGTTIN, SIG_IGN) != SIG_IGN) {
|
||||
(void) sigaction(SIGTTIN, &sa, NULL);
|
||||
sigaction(SIGTTIN, &sa, NULL);
|
||||
}
|
||||
if (signal(SIGWINCH, SIG_IGN) != SIG_IGN) {
|
||||
(void) sigaction(SIGWINCH, &sa, NULL);
|
||||
sigaction(SIGWINCH, &sa, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2334,7 +2340,7 @@ Job_Full(void)
|
|||
int i;
|
||||
|
||||
if (aborting)
|
||||
return(aborting);
|
||||
return (aborting);
|
||||
if (fifoFd >= 0 && jobFull) {
|
||||
i = read(fifoFd, &c, 1);
|
||||
if (i > 0) {
|
||||
|
@ -2342,7 +2348,7 @@ Job_Full(void)
|
|||
jobFull = FALSE;
|
||||
}
|
||||
}
|
||||
return(jobFull);
|
||||
return (jobFull);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -2372,12 +2378,12 @@ Job_Empty(void)
|
|||
*/
|
||||
jobFull = FALSE;
|
||||
JobRestartJobs();
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
} else {
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
} else {
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2498,7 +2504,7 @@ Job_ParseShell(char *line)
|
|||
Shell *sh;
|
||||
Boolean fullSpec = FALSE;
|
||||
|
||||
while (isspace((unsigned char) *line)) {
|
||||
while (isspace((unsigned char)*line)) {
|
||||
line++;
|
||||
}
|
||||
words = brk_string(line, &wordCount, TRUE);
|
||||
|
@ -2538,7 +2544,7 @@ Job_ParseShell(char *line)
|
|||
} else {
|
||||
Parse_Error(PARSE_FATAL, "Unknown keyword \"%s\"",
|
||||
*argv);
|
||||
return(FAILURE);
|
||||
return (FAILURE);
|
||||
}
|
||||
fullSpec = TRUE;
|
||||
}
|
||||
|
@ -2635,14 +2641,14 @@ JobInterrupt(int runINTERRUPT, int signo)
|
|||
|
||||
aborting = ABORT_INTERRUPT;
|
||||
|
||||
(void) Lst_Open(jobs);
|
||||
Lst_Open(jobs);
|
||||
while ((ln = Lst_Next(jobs)) != NULL) {
|
||||
job = (Job *) Lst_Datum(ln);
|
||||
job = (Job *)Lst_Datum(ln);
|
||||
|
||||
if (!Targ_Precious(job->node)) {
|
||||
char *file = (job->node->path == NULL ?
|
||||
job->node->name :
|
||||
job->node->path);
|
||||
char *file = (job->node->path == NULL ?
|
||||
job->node->name :
|
||||
job->node->path);
|
||||
if (!noExecute && eunlink(file) != -1) {
|
||||
Error("*** %s removed", file);
|
||||
}
|
||||
|
@ -2685,6 +2691,7 @@ JobInterrupt(int runINTERRUPT, int signo)
|
|||
int
|
||||
Job_Finish(void)
|
||||
{
|
||||
|
||||
if (postCommands != NULL && !Lst_IsEmpty(postCommands->commands)) {
|
||||
if (errors) {
|
||||
Error("Errors reported so .END ignored");
|
||||
|
@ -2703,7 +2710,7 @@ Job_Finish(void)
|
|||
if (fifoMaster)
|
||||
unlink(fifoName);
|
||||
}
|
||||
return(errors);
|
||||
return (errors);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -2723,6 +2730,7 @@ Job_Finish(void)
|
|||
void
|
||||
Job_Wait(void)
|
||||
{
|
||||
|
||||
aborting = ABORT_WAIT;
|
||||
while (nJobs != 0) {
|
||||
Job_CatchOutput(0);
|
||||
|
@ -2756,9 +2764,9 @@ Job_AbortAll(void)
|
|||
|
||||
if (nJobs) {
|
||||
|
||||
(void) Lst_Open(jobs);
|
||||
Lst_Open(jobs);
|
||||
while ((ln = Lst_Next(jobs)) != NULL) {
|
||||
job = (Job *) Lst_Datum(ln);
|
||||
job = (Job *)Lst_Datum(ln);
|
||||
|
||||
/*
|
||||
* kill the child process with increasingly drastic signals to make
|
||||
|
@ -2772,7 +2780,7 @@ Job_AbortAll(void)
|
|||
/*
|
||||
* Catch as many children as want to report in at first, then give up
|
||||
*/
|
||||
while (waitpid((pid_t) -1, &foo, WNOHANG) > 0)
|
||||
while (waitpid((pid_t)-1, &foo, WNOHANG) > 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
#define SEL_USEC 0
|
||||
#endif /* !USE_KQUEUE */
|
||||
|
||||
|
||||
/*-
|
||||
* Job Table definitions.
|
||||
*
|
||||
|
@ -148,7 +147,6 @@ typedef struct Job {
|
|||
#define outFile output.o_file.of_outFile
|
||||
#define outFd output.o_file.of_outFd
|
||||
|
||||
|
||||
/*-
|
||||
* Shell Specifications:
|
||||
* Each shell type has associated with it the following information:
|
||||
|
|
|
@ -75,11 +75,11 @@ Lst_Append(Lst list, LstNode ln, void *d)
|
|||
{
|
||||
LstNode nLNode;
|
||||
|
||||
if (Lst_Valid (list) && (ln == NULL && Lst_IsEmpty (list))) {
|
||||
if (Lst_Valid(list) && (ln == NULL && Lst_IsEmpty(list))) {
|
||||
goto ok;
|
||||
}
|
||||
|
||||
if (!Lst_Valid (list) || Lst_IsEmpty (list) || ! Lst_NodeValid(ln, list)) {
|
||||
if (!Lst_Valid(list) || Lst_IsEmpty(list) || ! Lst_NodeValid(ln, list)) {
|
||||
return (FAILURE);
|
||||
}
|
||||
ok:
|
||||
|
|
|
@ -79,7 +79,8 @@ Lst_Concat(Lst list1, Lst list2, int flags)
|
|||
LstNode nln; /* new LstNode */
|
||||
LstNode last; /* the last element in the list. Keeps
|
||||
* bookkeeping until the end */
|
||||
if (!Lst_Valid (list1) || !Lst_Valid (list2)) {
|
||||
|
||||
if (!Lst_Valid(list1) || !Lst_Valid(list2)) {
|
||||
return (FAILURE);
|
||||
}
|
||||
|
||||
|
@ -119,7 +120,7 @@ Lst_Concat(Lst list1, Lst list2, int flags)
|
|||
list1->firstPtr->prevPtr = list1->lastPtr;
|
||||
list1->lastPtr->nextPtr = list1->firstPtr;
|
||||
}
|
||||
free (list2);
|
||||
free(list2);
|
||||
} else if (list2->firstPtr != NULL) {
|
||||
/*
|
||||
* We set the nextPtr of the last element of list 2 to be NULL to make
|
||||
|
|
|
@ -69,13 +69,13 @@ Lst_DeQueue(Lst l)
|
|||
void * rd;
|
||||
LstNode tln;
|
||||
|
||||
tln = Lst_First (l);
|
||||
tln = Lst_First(l);
|
||||
if (tln == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
rd = tln->datum;
|
||||
if (Lst_Remove (l, tln) == FAILURE) {
|
||||
if (Lst_Remove(l, tln) == FAILURE) {
|
||||
return (NULL);
|
||||
} else {
|
||||
return (rd);
|
||||
|
|
|
@ -82,22 +82,22 @@ Lst_Destroy(Lst list, FreeProc *freeProc)
|
|||
if (list->lastPtr != NULL)
|
||||
list->lastPtr->nextPtr = NULL;
|
||||
else {
|
||||
free (list);
|
||||
free(list);
|
||||
return;
|
||||
}
|
||||
|
||||
if (freeProc) {
|
||||
for (ln = list->firstPtr; ln != NULL; ln = tln) {
|
||||
tln = ln->nextPtr;
|
||||
(*freeProc) (ln->datum);
|
||||
free (ln);
|
||||
(*freeProc)(ln->datum);
|
||||
free(ln);
|
||||
}
|
||||
} else {
|
||||
for (ln = list->firstPtr; ln != NULL; ln = tln) {
|
||||
tln = ln->nextPtr;
|
||||
free (ln);
|
||||
free(ln);
|
||||
}
|
||||
}
|
||||
|
||||
free (list);
|
||||
free(list);
|
||||
}
|
||||
|
|
|
@ -73,11 +73,11 @@ Lst_Duplicate(Lst list, DuplicateProc *copyProc)
|
|||
Lst nl;
|
||||
LstNode ln;
|
||||
|
||||
if (!Lst_Valid (list)) {
|
||||
if (!Lst_Valid(list)) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
nl = Lst_Init (list->isCirc);
|
||||
nl = Lst_Init(list->isCirc);
|
||||
if (nl == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ Lst_Duplicate(Lst list, DuplicateProc *copyProc)
|
|||
ln = list->firstPtr;
|
||||
while (ln != NULL) {
|
||||
if (copyProc != NOCOPY) {
|
||||
if (Lst_AtEnd (nl, (*copyProc) (ln->datum)) == FAILURE) {
|
||||
if (Lst_AtEnd(nl, (*copyProc)(ln->datum)) == FAILURE) {
|
||||
return (NULL);
|
||||
}
|
||||
} else if (Lst_AtEnd (nl, ln->datum) == FAILURE) {
|
||||
|
|
|
@ -70,14 +70,14 @@ Lst_FindFrom(Lst l, LstNode ln, void *d, CompareProc *cProc)
|
|||
LstNode tln;
|
||||
Boolean found = FALSE;
|
||||
|
||||
if (!Lst_Valid (l) || Lst_IsEmpty (l) || !Lst_NodeValid (ln, l)) {
|
||||
if (!Lst_Valid(l) || Lst_IsEmpty(l) || !Lst_NodeValid(ln, l)) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
tln = ln;
|
||||
|
||||
do {
|
||||
if ((*cProc) (tln->datum, d) == 0) {
|
||||
if ((*cProc)(tln->datum, d) == 0) {
|
||||
found = TRUE;
|
||||
break;
|
||||
} else {
|
||||
|
|
|
@ -72,7 +72,7 @@ Lst_ForEachFrom(Lst list, LstNode ln, DoProc *proc, void *d)
|
|||
Boolean done;
|
||||
int result;
|
||||
|
||||
if (!Lst_Valid (list) || Lst_IsEmpty (list)) {
|
||||
if (!Lst_Valid(list) || Lst_IsEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -84,9 +84,9 @@ Lst_ForEachFrom(Lst list, LstNode ln, DoProc *proc, void *d)
|
|||
|
||||
next = ln->nextPtr;
|
||||
|
||||
(void) ln->useCount++;
|
||||
result = (*proc) (ln->datum, d);
|
||||
(void) ln->useCount--;
|
||||
ln->useCount++;
|
||||
result = (*proc)(ln->datum, d);
|
||||
ln->useCount--;
|
||||
|
||||
/*
|
||||
* We're done with the traversal if
|
||||
|
|
|
@ -76,10 +76,10 @@ Lst_Insert(Lst list, LstNode ln, void *d)
|
|||
/*
|
||||
* check validity of arguments
|
||||
*/
|
||||
if (Lst_Valid (list) && (Lst_IsEmpty (list) && ln == NULL))
|
||||
if (Lst_Valid(list) && (Lst_IsEmpty(list) && ln == NULL))
|
||||
goto ok;
|
||||
|
||||
if (!Lst_Valid (list) || Lst_IsEmpty (list) || !Lst_NodeValid (ln, list)) {
|
||||
if (!Lst_Valid(list) || Lst_IsEmpty(list) || !Lst_NodeValid(ln, list)) {
|
||||
return (FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,6 @@ Boolean
|
|||
Lst_IsAtEnd(Lst list)
|
||||
{
|
||||
|
||||
return (!Lst_Valid (list) || !list->isOpen ||
|
||||
return (!Lst_Valid(list) || !list->isOpen ||
|
||||
(list->atEnd == LstHead) || (list->atEnd == LstTail));
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ Lst_Next(Lst list)
|
|||
{
|
||||
LstNode tln;
|
||||
|
||||
if ((Lst_Valid (list) == FALSE) || (list->isOpen == FALSE)) {
|
||||
if ((Lst_Valid(list) == FALSE) || (list->isOpen == FALSE)) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,11 +73,11 @@ ReturnStatus
|
|||
Lst_Open(Lst l)
|
||||
{
|
||||
|
||||
if (Lst_Valid (l) == FALSE) {
|
||||
if (Lst_Valid(l) == FALSE) {
|
||||
return (FAILURE);
|
||||
}
|
||||
l->isOpen = TRUE;
|
||||
l->atEnd = Lst_IsEmpty (l) ? LstHead : LstUnknown;
|
||||
l->atEnd = Lst_IsEmpty(l) ? LstHead : LstUnknown;
|
||||
l->curPtr = NULL;
|
||||
|
||||
return (SUCCESS);
|
||||
|
|
|
@ -68,7 +68,7 @@ ReturnStatus
|
|||
Lst_Remove(Lst list, LstNode ln)
|
||||
{
|
||||
|
||||
if (!Lst_Valid (list) || !Lst_NodeValid (ln, list)) {
|
||||
if (!Lst_Valid(list) || !Lst_NodeValid(ln, list)) {
|
||||
return (FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -133,6 +133,7 @@ static char *objdir; /* where we chdir'ed to */
|
|||
static void
|
||||
MFLAGS_append(char *flag, char *arg)
|
||||
{
|
||||
|
||||
Var_Append(MAKEFLAGS, flag, VAR_GLOBAL);
|
||||
if (arg != NULL)
|
||||
Var_Append(MAKEFLAGS, arg, VAR_GLOBAL);
|
||||
|
@ -255,8 +256,8 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
|
|||
}
|
||||
case 'E':
|
||||
p = emalloc(strlen(optarg) + 1);
|
||||
(void)strcpy(p, optarg);
|
||||
(void)Lst_AtEnd(envFirstVars, (void *)p);
|
||||
strcpy(p, optarg);
|
||||
Lst_AtEnd(envFirstVars, (void *)p);
|
||||
MFLAGS_append("-E", optarg);
|
||||
break;
|
||||
case 'e':
|
||||
|
@ -264,7 +265,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
|
|||
MFLAGS_append("-e", NULL);
|
||||
break;
|
||||
case 'f':
|
||||
(void)Lst_AtEnd(makefiles, (void *)optarg);
|
||||
Lst_AtEnd(makefiles, (void *)optarg);
|
||||
break;
|
||||
case 'i':
|
||||
ignoreErrors = TRUE;
|
||||
|
@ -347,7 +348,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
|
|||
optind = 1; /* - */
|
||||
goto rearg;
|
||||
}
|
||||
(void)Lst_AtEnd(create, (void *)estrdup(*argv));
|
||||
Lst_AtEnd(create, (void *)estrdup(*argv));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,12 +392,12 @@ chdir_verify_path(char *path, char *obpath)
|
|||
if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
|
||||
if (chdir(path) == -1 || getcwd(obpath, MAXPATHLEN) == NULL) {
|
||||
warn("warning: %s", path);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
return obpath;
|
||||
return (obpath);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -498,7 +499,7 @@ main(int argc, char **argv)
|
|||
if (getrlimit(RLIMIT_NOFILE, &rl) != -1 &&
|
||||
rl.rlim_cur != rl.rlim_max) {
|
||||
rl.rlim_cur = rl.rlim_max;
|
||||
(void) setrlimit(RLIMIT_NOFILE, &rl);
|
||||
setrlimit(RLIMIT_NOFILE, &rl);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -658,11 +659,11 @@ main(int argc, char **argv)
|
|||
if (!(path = getenv("MAKEOBJDIR"))) {
|
||||
path = _PATH_OBJDIR;
|
||||
pathp = _PATH_OBJDIRPREFIX;
|
||||
(void) snprintf(mdpath, MAXPATHLEN, "%s.%s",
|
||||
snprintf(mdpath, MAXPATHLEN, "%s.%s",
|
||||
path, machine);
|
||||
if (!(objdir = chdir_verify_path(mdpath, obpath)))
|
||||
if (!(objdir=chdir_verify_path(path, obpath))) {
|
||||
(void) snprintf(mdpath, MAXPATHLEN,
|
||||
snprintf(mdpath, MAXPATHLEN,
|
||||
"%s%s", pathp, curdir);
|
||||
if (!(objdir=chdir_verify_path(mdpath,
|
||||
obpath)))
|
||||
|
@ -673,7 +674,7 @@ main(int argc, char **argv)
|
|||
objdir = curdir;
|
||||
}
|
||||
else {
|
||||
(void) snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir);
|
||||
snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir);
|
||||
if (!(objdir = chdir_verify_path(mdpath, obpath)))
|
||||
objdir = curdir;
|
||||
}
|
||||
|
@ -701,7 +702,7 @@ main(int argc, char **argv)
|
|||
Suff_Init();
|
||||
|
||||
DEFAULT = NULL;
|
||||
(void)time(&now);
|
||||
time(&now);
|
||||
|
||||
/*
|
||||
* Set up the .TARGETS variable to contain the list of targets to be
|
||||
|
@ -747,8 +748,8 @@ main(int argc, char **argv)
|
|||
if (!noBuiltins) {
|
||||
LstNode ln;
|
||||
|
||||
sysMkPath = Lst_Init (FALSE);
|
||||
Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath);
|
||||
sysMkPath = Lst_Init(FALSE);
|
||||
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);
|
||||
|
@ -764,9 +765,9 @@ main(int argc, char **argv)
|
|||
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
|
||||
} else if (!ReadMakefile("BSDmakefile", NULL))
|
||||
if (!ReadMakefile("makefile", NULL))
|
||||
(void)ReadMakefile("Makefile", NULL);
|
||||
ReadMakefile("Makefile", NULL);
|
||||
|
||||
(void)ReadMakefile(".depend", NULL);
|
||||
ReadMakefile(".depend", NULL);
|
||||
|
||||
/* Install all the flags into the MAKE envariable. */
|
||||
if (((p = Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1)) != NULL) && *p)
|
||||
|
@ -802,7 +803,7 @@ main(int argc, char **argv)
|
|||
*cp = savec;
|
||||
path = cp + 1;
|
||||
} while (savec == ':');
|
||||
(void)free(vpath);
|
||||
free(vpath);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -825,7 +826,7 @@ main(int argc, char **argv)
|
|||
if (expandVars) {
|
||||
p1 = emalloc(strlen((char *)Lst_Datum(ln)) + 1 + 3);
|
||||
/* This sprintf is safe, because of the malloc above */
|
||||
(void)sprintf(p1, "${%s}", (char *)Lst_Datum(ln));
|
||||
sprintf(p1, "${%s}", (char *)Lst_Datum(ln));
|
||||
value = Var_Subst(NULL, p1, VAR_GLOBAL, FALSE);
|
||||
} else {
|
||||
value = Var_Value((char *)Lst_Datum(ln),
|
||||
|
@ -889,9 +890,9 @@ main(int argc, char **argv)
|
|||
Dir_End();
|
||||
|
||||
if (queryFlag && outOfDate)
|
||||
return(1);
|
||||
return (1);
|
||||
else
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -923,7 +924,7 @@ ReadMakefile(void *p, void *q __unused)
|
|||
|
||||
/* if we've chdir'd, rebuild the path name */
|
||||
if (curdir != objdir && *fname != '/') {
|
||||
(void)snprintf(path, MAXPATHLEN, "%s/%s", curdir, fname);
|
||||
snprintf(path, MAXPATHLEN, "%s/%s", curdir, fname);
|
||||
/*
|
||||
* XXX The realpath stuff breaks relative includes
|
||||
* XXX in some cases. The problem likely is in
|
||||
|
@ -969,7 +970,7 @@ ReadMakefile(void *p, void *q __unused)
|
|||
if (!name)
|
||||
name = Dir_FindFile(fname, sysIncPath);
|
||||
if (!name || !(stream = fopen(name, "r")))
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
MAKEFILE = fname = name;
|
||||
/*
|
||||
* set the MAKEFILE variable desired by System V fans -- the
|
||||
|
@ -980,9 +981,9 @@ ReadMakefile(void *p, void *q __unused)
|
|||
if (setMAKEFILE)
|
||||
Var_Set("MAKEFILE", MAKEFILE, VAR_GLOBAL);
|
||||
Parse_File(fname, stream);
|
||||
(void)fclose(stream);
|
||||
fclose(stream);
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -1038,17 +1039,17 @@ Cmd_Exec(char *cmd, char **error)
|
|||
/*
|
||||
* Close input side of pipe
|
||||
*/
|
||||
(void) close(fds[0]);
|
||||
close(fds[0]);
|
||||
|
||||
/*
|
||||
* Duplicate the output stream to the shell's output, then
|
||||
* shut the extra thing down. Note we don't fetch the error
|
||||
* stream...why not? Why?
|
||||
*/
|
||||
(void) dup2(fds[1], 1);
|
||||
(void) close(fds[1]);
|
||||
dup2(fds[1], 1);
|
||||
close(fds[1]);
|
||||
|
||||
(void) execv(shellPath, args);
|
||||
execv(shellPath, args);
|
||||
_exit(1);
|
||||
/*NOTREACHED*/
|
||||
|
||||
|
@ -1060,34 +1061,34 @@ Cmd_Exec(char *cmd, char **error)
|
|||
/*
|
||||
* No need for the writing half
|
||||
*/
|
||||
(void) close(fds[1]);
|
||||
close(fds[1]);
|
||||
|
||||
buf = Buf_Init (MAKE_BSIZE);
|
||||
buf = Buf_Init(MAKE_BSIZE);
|
||||
|
||||
do {
|
||||
char result[BUFSIZ];
|
||||
cc = read(fds[0], result, sizeof(result));
|
||||
if (cc > 0)
|
||||
Buf_AddBytes(buf, cc, (Byte *) result);
|
||||
Buf_AddBytes(buf, cc, (Byte *)result);
|
||||
}
|
||||
while (cc > 0 || (cc == -1 && errno == EINTR));
|
||||
|
||||
/*
|
||||
* Close the input side of the pipe.
|
||||
*/
|
||||
(void) close(fds[0]);
|
||||
close(fds[0]);
|
||||
|
||||
/*
|
||||
* Wait for the process to exit.
|
||||
*/
|
||||
while(((pid = wait(&status)) != cpid) && (pid >= 0))
|
||||
while (((pid = wait(&status)) != cpid) && (pid >= 0))
|
||||
continue;
|
||||
|
||||
if (cc == -1)
|
||||
*error = "Error reading shell's output for \"%s\"";
|
||||
|
||||
res = (char *)Buf_GetAll (buf, &cc);
|
||||
Buf_Destroy (buf, FALSE);
|
||||
res = (char *)Buf_GetAll(buf, &cc);
|
||||
Buf_Destroy(buf, FALSE);
|
||||
|
||||
if (status)
|
||||
*error = "\"%s\" returned non-zero status";
|
||||
|
@ -1113,11 +1114,11 @@ Cmd_Exec(char *cmd, char **error)
|
|||
}
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
return (res);
|
||||
bad:
|
||||
res = emalloc(1);
|
||||
*res = '\0';
|
||||
return res;
|
||||
return (res);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1127,7 +1128,7 @@ Cmd_Exec(char *cmd, char **error)
|
|||
static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr, "%s\n%s\n%s\n",
|
||||
fprintf(stderr, "%s\n%s\n%s\n",
|
||||
"usage: make [-BPSXeiknqrstv] [-C directory] [-D variable] [-d flags]",
|
||||
" [-E variable] [-f makefile] [-I directory] [-j max_jobs]",
|
||||
" [-m directory] [-V variable] [variable=value] [target ...]");
|
||||
|
|
|
@ -93,6 +93,7 @@ static int MakeTimeStamp(void *, void *);
|
|||
static int MakeHandleUse(void *, void *);
|
||||
static Boolean MakeStartJobs(void);
|
||||
static int MakePrintStatus(void *, void *);
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Make_TimeStamp --
|
||||
|
@ -108,8 +109,9 @@ static int MakePrintStatus(void *, void *);
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Make_TimeStamp (GNode *pgn, GNode *cgn)
|
||||
Make_TimeStamp(GNode *pgn, GNode *cgn)
|
||||
{
|
||||
|
||||
if (cgn->mtime > pgn->cmtime) {
|
||||
pgn->cmtime = cgn->mtime;
|
||||
}
|
||||
|
@ -117,11 +119,12 @@ Make_TimeStamp (GNode *pgn, GNode *cgn)
|
|||
}
|
||||
|
||||
static int
|
||||
MakeTimeStamp (void *pgn, void *cgn)
|
||||
MakeTimeStamp(void *pgn, void *cgn)
|
||||
{
|
||||
return Make_TimeStamp((GNode *) pgn, (GNode *) cgn);
|
||||
|
||||
return (Make_TimeStamp((GNode *)pgn, (GNode *)cgn));
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Make_OODate --
|
||||
|
@ -141,7 +144,7 @@ MakeTimeStamp (void *pgn, void *cgn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Make_OODate (GNode *gn)
|
||||
Make_OODate(GNode *gn)
|
||||
{
|
||||
Boolean oodate;
|
||||
|
||||
|
@ -149,8 +152,8 @@ Make_OODate (GNode *gn)
|
|||
* Certain types of targets needn't even be sought as their datedness
|
||||
* doesn't depend on their modification time...
|
||||
*/
|
||||
if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) {
|
||||
(void) Dir_MTime (gn);
|
||||
if ((gn->type & (OP_JOIN | OP_USE | OP_EXEC)) == 0) {
|
||||
Dir_MTime(gn);
|
||||
if (gn->mtime != 0) {
|
||||
DEBUGF(MAKE, ("modified %s...", Targ_FmtTime(gn->mtime)));
|
||||
} else {
|
||||
|
@ -186,7 +189,7 @@ Make_OODate (GNode *gn)
|
|||
* always out of date if no children and :: target
|
||||
*/
|
||||
|
||||
oodate = Arch_LibOODate (gn) ||
|
||||
oodate = Arch_LibOODate(gn) ||
|
||||
((gn->cmtime == 0) && (gn->type & OP_DOUBLEDEP));
|
||||
} else if (gn->type & OP_JOIN) {
|
||||
/*
|
||||
|
@ -238,12 +241,12 @@ Make_OODate (GNode *gn)
|
|||
* thinking they're out-of-date.
|
||||
*/
|
||||
if (!oodate) {
|
||||
Lst_ForEach (gn->parents, MakeTimeStamp, (void *)gn);
|
||||
Lst_ForEach(gn->parents, MakeTimeStamp, (void *)gn);
|
||||
}
|
||||
|
||||
return (oodate);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* MakeAddChild --
|
||||
|
@ -258,17 +261,17 @@ Make_OODate (GNode *gn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
MakeAddChild (void *gnp, void *lp)
|
||||
MakeAddChild(void *gnp, void *lp)
|
||||
{
|
||||
GNode *gn = (GNode *) gnp;
|
||||
Lst l = (Lst) lp;
|
||||
GNode *gn = (GNode *)gnp;
|
||||
Lst l = (Lst)lp;
|
||||
|
||||
if (!gn->make && !(gn->type & OP_USE)) {
|
||||
(void)Lst_EnQueue (l, (void *)gn);
|
||||
Lst_EnQueue(l, (void *)gn);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Make_HandleUse --
|
||||
|
@ -293,7 +296,7 @@ MakeAddChild (void *gnp, void *lp)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Make_HandleUse (GNode *cgn, GNode *pgn)
|
||||
Make_HandleUse(GNode *cgn, GNode *pgn)
|
||||
{
|
||||
GNode *gn; /* A child of the .USE node */
|
||||
LstNode ln; /* An element in the children list */
|
||||
|
@ -304,23 +307,23 @@ Make_HandleUse (GNode *cgn, GNode *pgn)
|
|||
* .USE or transformation and target has no commands -- append
|
||||
* the child's commands to the parent.
|
||||
*/
|
||||
(void) Lst_Concat (pgn->commands, cgn->commands, LST_CONCNEW);
|
||||
Lst_Concat(pgn->commands, cgn->commands, LST_CONCNEW);
|
||||
}
|
||||
|
||||
if (Lst_Open (cgn->children) == SUCCESS) {
|
||||
while ((ln = Lst_Next (cgn->children)) != NULL) {
|
||||
gn = (GNode *)Lst_Datum (ln);
|
||||
if (Lst_Open(cgn->children) == SUCCESS) {
|
||||
while ((ln = Lst_Next(cgn->children)) != NULL) {
|
||||
gn = (GNode *)Lst_Datum(ln);
|
||||
|
||||
if (Lst_Member (pgn->children, gn) == NULL) {
|
||||
(void) Lst_AtEnd (pgn->children, gn);
|
||||
(void) Lst_AtEnd (gn->parents, pgn);
|
||||
if (Lst_Member(pgn->children, gn) == NULL) {
|
||||
Lst_AtEnd(pgn->children, gn);
|
||||
Lst_AtEnd(gn->parents, pgn);
|
||||
pgn->unmade += 1;
|
||||
}
|
||||
}
|
||||
Lst_Close (cgn->children);
|
||||
Lst_Close(cgn->children);
|
||||
}
|
||||
|
||||
pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_TRANSFORM);
|
||||
pgn->type |= cgn->type & ~(OP_OPMASK | OP_USE | OP_TRANSFORM);
|
||||
|
||||
/*
|
||||
* This child node is now "made", so we decrement the count of
|
||||
|
@ -335,12 +338,14 @@ Make_HandleUse (GNode *cgn, GNode *pgn)
|
|||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
MakeHandleUse (void *pgn, void *cgn)
|
||||
MakeHandleUse(void *pgn, void *cgn)
|
||||
{
|
||||
return Make_HandleUse((GNode *) pgn, (GNode *) cgn);
|
||||
|
||||
return (Make_HandleUse((GNode *)pgn, (GNode *)cgn));
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Make_Update --
|
||||
|
@ -367,14 +372,14 @@ MakeHandleUse (void *pgn, void *cgn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Make_Update (GNode *cgn)
|
||||
Make_Update(GNode *cgn)
|
||||
{
|
||||
GNode *pgn; /* the parent node */
|
||||
char *cname; /* the child's name */
|
||||
LstNode ln; /* Element in parents and iParents lists */
|
||||
char *p1;
|
||||
|
||||
cname = Var_Value (TARGET, cgn, &p1);
|
||||
cname = Var_Value(TARGET, cgn, &p1);
|
||||
free(p1);
|
||||
|
||||
/*
|
||||
|
@ -442,20 +447,20 @@ Make_Update (GNode *cgn)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (Lst_Open (cgn->parents) == SUCCESS) {
|
||||
while ((ln = Lst_Next (cgn->parents)) != NULL) {
|
||||
pgn = (GNode *)Lst_Datum (ln);
|
||||
if (Lst_Open(cgn->parents) == SUCCESS) {
|
||||
while ((ln = Lst_Next(cgn->parents)) != NULL) {
|
||||
pgn = (GNode *)Lst_Datum(ln);
|
||||
if (pgn->make) {
|
||||
pgn->unmade -= 1;
|
||||
|
||||
if ( ! (cgn->type & (OP_EXEC|OP_USE))) {
|
||||
if (!(cgn->type & (OP_EXEC | OP_USE))) {
|
||||
if (cgn->made == MADE) {
|
||||
pgn->childMade = TRUE;
|
||||
if (pgn->cmtime < cgn->mtime) {
|
||||
pgn->cmtime = cgn->mtime;
|
||||
}
|
||||
} else {
|
||||
(void)Make_TimeStamp (pgn, cgn);
|
||||
Make_TimeStamp(pgn, cgn);
|
||||
}
|
||||
}
|
||||
if (pgn->unmade == 0) {
|
||||
|
@ -463,13 +468,13 @@ Make_Update (GNode *cgn)
|
|||
* Queue the node up -- any unmade predecessors will
|
||||
* be dealt with in MakeStartJobs.
|
||||
*/
|
||||
(void)Lst_EnQueue (toBeMade, (void *)pgn);
|
||||
Lst_EnQueue(toBeMade, (void *)pgn);
|
||||
} else if (pgn->unmade < 0) {
|
||||
Error ("Graph cycles through %s", pgn->name);
|
||||
Error("Graph cycles through %s", pgn->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Lst_Close (cgn->parents);
|
||||
Lst_Close(cgn->parents);
|
||||
}
|
||||
/*
|
||||
* Deal with successor nodes. If any is marked for making and has an unmade
|
||||
|
@ -483,7 +488,7 @@ Make_Update (GNode *cgn)
|
|||
if (succ->make && succ->unmade == 0 && succ->made == UNMADE &&
|
||||
Lst_Member(toBeMade, (void *)succ) == NULL)
|
||||
{
|
||||
(void)Lst_EnQueue(toBeMade, (void *)succ);
|
||||
Lst_EnQueue(toBeMade, (void *)succ);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -491,22 +496,22 @@ Make_Update (GNode *cgn)
|
|||
* Set the .PREFIX and .IMPSRC variables for all the implied parents
|
||||
* of this node.
|
||||
*/
|
||||
if (Lst_Open (cgn->iParents) == SUCCESS) {
|
||||
if (Lst_Open(cgn->iParents) == SUCCESS) {
|
||||
char *ptr;
|
||||
char *cpref = Var_Value(PREFIX, cgn, &ptr);
|
||||
|
||||
while ((ln = Lst_Next (cgn->iParents)) != NULL) {
|
||||
while ((ln = Lst_Next(cgn->iParents)) != NULL) {
|
||||
pgn = (GNode *)Lst_Datum (ln);
|
||||
if (pgn->make) {
|
||||
Var_Set (IMPSRC, cname, pgn);
|
||||
Var_Set (PREFIX, cpref, pgn);
|
||||
Var_Set(IMPSRC, cname, pgn);
|
||||
Var_Set(PREFIX, cpref, pgn);
|
||||
}
|
||||
}
|
||||
free(ptr);
|
||||
Lst_Close (cgn->iParents);
|
||||
Lst_Close(cgn->iParents);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* MakeAddAllSrc --
|
||||
|
@ -528,11 +533,12 @@ Make_Update (GNode *cgn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
MakeAddAllSrc (void *cgnp, void *pgnp)
|
||||
MakeAddAllSrc(void *cgnp, void *pgnp)
|
||||
{
|
||||
GNode *cgn = (GNode *) cgnp;
|
||||
GNode *pgn = (GNode *) pgnp;
|
||||
if ((cgn->type & (OP_EXEC|OP_USE|OP_INVISIBLE)) == 0) {
|
||||
|
||||
if ((cgn->type & (OP_EXEC | OP_USE | OP_INVISIBLE)) == 0) {
|
||||
char *child;
|
||||
char *p1 = NULL;
|
||||
|
||||
|
@ -544,7 +550,7 @@ MakeAddAllSrc (void *cgnp, void *pgnp)
|
|||
}
|
||||
else
|
||||
child = Var_Value(TARGET, cgn, &p1);
|
||||
Var_Append (ALLSRC, child, pgn);
|
||||
Var_Append(ALLSRC, child, pgn);
|
||||
if (pgn->type & OP_JOIN) {
|
||||
if (cgn->made == MADE) {
|
||||
Var_Append(OODATE, child, pgn);
|
||||
|
@ -574,7 +580,7 @@ MakeAddAllSrc (void *cgnp, void *pgnp)
|
|||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Make_DoAllVar --
|
||||
|
@ -598,24 +604,26 @@ MakeAddAllSrc (void *cgnp, void *pgnp)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Make_DoAllVar (GNode *gn)
|
||||
Make_DoAllVar(GNode *gn)
|
||||
{
|
||||
Lst_ForEach (gn->children, MakeAddAllSrc, (void *) gn);
|
||||
|
||||
Lst_ForEach(gn->children, MakeAddAllSrc, (void *)gn);
|
||||
|
||||
if (!Var_Exists (OODATE, gn)) {
|
||||
Var_Set (OODATE, "", gn);
|
||||
Var_Set(OODATE, "", gn);
|
||||
}
|
||||
if (!Var_Exists (ALLSRC, gn)) {
|
||||
Var_Set (ALLSRC, "", gn);
|
||||
Var_Set(ALLSRC, "", gn);
|
||||
}
|
||||
|
||||
if (gn->type & OP_JOIN) {
|
||||
char *p1;
|
||||
Var_Set (TARGET, Var_Value (ALLSRC, gn, &p1), gn);
|
||||
|
||||
Var_Set(TARGET, Var_Value(ALLSRC, gn, &p1), gn);
|
||||
free(p1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* MakeStartJobs --
|
||||
|
@ -633,12 +641,12 @@ Make_DoAllVar (GNode *gn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static Boolean
|
||||
MakeStartJobs (void)
|
||||
MakeStartJobs(void)
|
||||
{
|
||||
GNode *gn;
|
||||
|
||||
while (!Lst_IsEmpty (toBeMade) && !Job_Full()) {
|
||||
gn = (GNode *) Lst_DeQueue (toBeMade);
|
||||
gn = (GNode *)Lst_DeQueue(toBeMade);
|
||||
DEBUGF(MAKE, ("Examining %s...", gn->name));
|
||||
/*
|
||||
* Make sure any and all predecessors that are going to be made,
|
||||
|
@ -667,13 +675,13 @@ MakeStartJobs (void)
|
|||
}
|
||||
|
||||
numNodes--;
|
||||
if (Make_OODate (gn)) {
|
||||
if (Make_OODate(gn)) {
|
||||
DEBUGF(MAKE, ("out-of-date\n"));
|
||||
if (queryFlag) {
|
||||
return (TRUE);
|
||||
}
|
||||
Make_DoAllVar (gn);
|
||||
Job_Make (gn);
|
||||
Make_DoAllVar(gn);
|
||||
Job_Make(gn);
|
||||
} else {
|
||||
DEBUGF(MAKE, ("up-to-date\n"));
|
||||
gn->made = UPTODATE;
|
||||
|
@ -684,15 +692,15 @@ MakeStartJobs (void)
|
|||
* value for .TARGET when building up the context variables
|
||||
* of its parent(s)...
|
||||
*/
|
||||
Make_DoAllVar (gn);
|
||||
Make_DoAllVar(gn);
|
||||
}
|
||||
|
||||
Make_Update (gn);
|
||||
Make_Update(gn);
|
||||
}
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* MakePrintStatus --
|
||||
|
@ -713,10 +721,11 @@ MakeStartJobs (void)
|
|||
static int
|
||||
MakePrintStatus(void *gnp, void *cyclep)
|
||||
{
|
||||
GNode *gn = (GNode *) gnp;
|
||||
Boolean cycle = *(Boolean *) cyclep;
|
||||
GNode *gn = (GNode *)gnp;
|
||||
Boolean cycle = *(Boolean *)cyclep;
|
||||
|
||||
if (gn->made == UPTODATE) {
|
||||
printf ("`%s' is up to date.\n", gn->name);
|
||||
printf("`%s' is up to date.\n", gn->name);
|
||||
} else if (gn->unmade != 0) {
|
||||
if (cycle) {
|
||||
Boolean t = TRUE;
|
||||
|
@ -733,19 +742,19 @@ 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, (void *)&t);
|
||||
gn->made = UNMADE;
|
||||
} else if (gn->made != ENDCYCLE) {
|
||||
gn->made = CYCLE;
|
||||
Lst_ForEach(gn->children, MakePrintStatus, (void *) &t);
|
||||
Lst_ForEach(gn->children, MakePrintStatus, (void *)&t);
|
||||
}
|
||||
} else {
|
||||
printf ("`%s' not remade because of errors.\n", gn->name);
|
||||
printf("`%s' not remade because of errors.\n", gn->name);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Make_Run --
|
||||
|
@ -768,13 +777,13 @@ MakePrintStatus(void *gnp, void *cyclep)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Make_Run (Lst targs)
|
||||
Make_Run(Lst targs)
|
||||
{
|
||||
GNode *gn; /* a temporary pointer */
|
||||
Lst examine; /* List of targets to examine */
|
||||
int errors; /* Number of errors the Job module reports */
|
||||
|
||||
toBeMade = Lst_Init (FALSE);
|
||||
toBeMade = Lst_Init(FALSE);
|
||||
|
||||
examine = Lst_Duplicate(targs, NOCOPY);
|
||||
numNodes = 0;
|
||||
|
@ -787,8 +796,8 @@ Make_Run (Lst targs)
|
|||
* be looked at in a minute, otherwise we add its children to our queue
|
||||
* and go on about our business.
|
||||
*/
|
||||
while (!Lst_IsEmpty (examine)) {
|
||||
gn = (GNode *) Lst_DeQueue (examine);
|
||||
while (!Lst_IsEmpty(examine)) {
|
||||
gn = (GNode *)Lst_DeQueue(examine);
|
||||
|
||||
if (!gn->make) {
|
||||
gn->make = TRUE;
|
||||
|
@ -798,18 +807,18 @@ 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);
|
||||
Suff_FindDeps (gn);
|
||||
Lst_ForEach(gn->children, MakeHandleUse, (void *)gn);
|
||||
Suff_FindDeps(gn);
|
||||
|
||||
if (gn->unmade != 0) {
|
||||
Lst_ForEach (gn->children, MakeAddChild, (void *)examine);
|
||||
Lst_ForEach(gn->children, MakeAddChild, (void *)examine);
|
||||
} else {
|
||||
(void)Lst_EnQueue (toBeMade, (void *)gn);
|
||||
Lst_EnQueue(toBeMade, (void *)gn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Lst_Destroy (examine, NOFREE);
|
||||
Lst_Destroy(examine, NOFREE);
|
||||
|
||||
if (queryFlag) {
|
||||
/*
|
||||
|
@ -826,7 +835,7 @@ Make_Run (Lst targs)
|
|||
* the finishing of a job. So we fill the Job table as much as we can
|
||||
* before going into our loop.
|
||||
*/
|
||||
(void) MakeStartJobs();
|
||||
MakeStartJobs();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -840,9 +849,9 @@ Make_Run (Lst targs)
|
|||
* keepgoing flag was given.
|
||||
*/
|
||||
while (!Job_Empty ()) {
|
||||
Job_CatchOutput (!Lst_IsEmpty (toBeMade));
|
||||
Job_CatchChildren (!usePipes);
|
||||
(void)MakeStartJobs();
|
||||
Job_CatchOutput(!Lst_IsEmpty (toBeMade));
|
||||
Job_CatchChildren(!usePipes);
|
||||
MakeStartJobs();
|
||||
}
|
||||
|
||||
errors = Job_Finish();
|
||||
|
@ -852,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, (void *)&errors);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -55,6 +55,7 @@ void
|
|||
str_init(void)
|
||||
{
|
||||
char *p1;
|
||||
|
||||
argv = (char **)emalloc(((argmax = 50) + 1) * sizeof(char *));
|
||||
argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1);
|
||||
}
|
||||
|
@ -115,10 +116,10 @@ str_concat(char *s1, char *s2, int flags)
|
|||
|
||||
/* free original strings */
|
||||
if (flags & STR_DOFREE) {
|
||||
(void)free(s1);
|
||||
(void)free(s2);
|
||||
free(s1);
|
||||
free(s2);
|
||||
}
|
||||
return(result);
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -238,11 +239,11 @@ brk_string(char *str, int *store_argc, Boolean expand)
|
|||
}
|
||||
if (!start)
|
||||
start = t;
|
||||
*t++ = (char) ch;
|
||||
*t++ = (char)ch;
|
||||
}
|
||||
done: argv[argc] = (char *)NULL;
|
||||
*store_argc = argc;
|
||||
return(argv);
|
||||
return (argv);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -268,9 +269,9 @@ Str_Match(const char *string, const char *pattern)
|
|||
* pattern but not at the end of the string, we failed.
|
||||
*/
|
||||
if (*pattern == 0)
|
||||
return(!*string);
|
||||
return (!*string);
|
||||
if (*string == 0 && *pattern != '*')
|
||||
return(0);
|
||||
return (0);
|
||||
/*
|
||||
* Check for a "*" as the next pattern character. It matches
|
||||
* any substring. We handle this by calling ourselves
|
||||
|
@ -280,13 +281,13 @@ Str_Match(const char *string, const char *pattern)
|
|||
if (*pattern == '*') {
|
||||
pattern += 1;
|
||||
if (*pattern == 0)
|
||||
return(1);
|
||||
return (1);
|
||||
while (*string != 0) {
|
||||
if (Str_Match(string, pattern))
|
||||
return(1);
|
||||
return (1);
|
||||
++string;
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Check for a "?" as the next pattern character. It matches
|
||||
|
@ -303,13 +304,13 @@ Str_Match(const char *string, const char *pattern)
|
|||
++pattern;
|
||||
for (;;) {
|
||||
if ((*pattern == ']') || (*pattern == 0))
|
||||
return(0);
|
||||
return (0);
|
||||
if (*pattern == *string)
|
||||
break;
|
||||
if (pattern[1] == '-') {
|
||||
c2 = pattern[2];
|
||||
if (c2 == 0)
|
||||
return(0);
|
||||
return (0);
|
||||
if ((*pattern <= *string) &&
|
||||
(c2 >= *string))
|
||||
break;
|
||||
|
@ -331,14 +332,14 @@ Str_Match(const char *string, const char *pattern)
|
|||
if (*pattern == '\\') {
|
||||
++pattern;
|
||||
if (*pattern == 0)
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* There's no special character. Just make sure that the
|
||||
* next characters of each string match.
|
||||
*/
|
||||
if (*pattern != *string)
|
||||
return(0);
|
||||
return (0);
|
||||
thisCharOK: ++pattern;
|
||||
++string;
|
||||
}
|
||||
|
@ -370,13 +371,13 @@ Str_SYSVMatch(const char *word, const char *pattern, int *len)
|
|||
if (*w == '\0') {
|
||||
/* Zero-length word cannot be matched against */
|
||||
*len = 0;
|
||||
return NULL;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (*p == '\0') {
|
||||
/* Null pattern is the whole string */
|
||||
*len = strlen(w);
|
||||
return w;
|
||||
return (w);
|
||||
}
|
||||
|
||||
if ((m = strchr(p, '%')) != NULL) {
|
||||
|
@ -385,12 +386,12 @@ Str_SYSVMatch(const char *word, const char *pattern, int *len)
|
|||
continue;
|
||||
|
||||
if (p != m)
|
||||
return NULL; /* No match */
|
||||
return (NULL); /* No match */
|
||||
|
||||
if (*++p == '\0') {
|
||||
/* No more pattern, return the rest of the string */
|
||||
*len = strlen(w);
|
||||
return w;
|
||||
return (w);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,11 +401,11 @@ Str_SYSVMatch(const char *word, const char *pattern, int *len)
|
|||
do
|
||||
if (strcmp(p, w) == 0) {
|
||||
*len = w - m;
|
||||
return m;
|
||||
return (m);
|
||||
}
|
||||
while (*w++ != '\0');
|
||||
|
||||
return NULL;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -430,14 +431,14 @@ Str_SYSVSubst(Buffer buf, const char *pat, const char *src, int len)
|
|||
|
||||
if ((m = strchr(pat, '%')) != NULL) {
|
||||
/* Copy the prefix */
|
||||
Buf_AddBytes(buf, m - pat, (Byte *) pat);
|
||||
Buf_AddBytes(buf, m - pat, (Byte *)pat);
|
||||
/* skip the % */
|
||||
pat = m + 1;
|
||||
}
|
||||
|
||||
/* Copy the pattern */
|
||||
Buf_AddBytes(buf, len, (Byte *) src);
|
||||
Buf_AddBytes(buf, len, (Byte *)src);
|
||||
|
||||
/* append the rest */
|
||||
Buf_AddBytes(buf, strlen(pat), (Byte *) pat);
|
||||
Buf_AddBytes(buf, strlen(pat), (Byte *)pat);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -112,10 +112,11 @@ static void TargFreeGN(void *);
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Targ_Init (void)
|
||||
Targ_Init(void)
|
||||
{
|
||||
allTargets = Lst_Init (FALSE);
|
||||
Hash_InitTable (&targets, HTSIZE);
|
||||
|
||||
allTargets = Lst_Init(FALSE);
|
||||
Hash_InitTable(&targets, HTSIZE);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -131,8 +132,9 @@ Targ_Init (void)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Targ_End (void)
|
||||
Targ_End(void)
|
||||
{
|
||||
|
||||
Lst_Destroy(allTargets, NOFREE);
|
||||
if (allGNs)
|
||||
Lst_Destroy(allGNs, TargFreeGN);
|
||||
|
@ -153,37 +155,37 @@ Targ_End (void)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
GNode *
|
||||
Targ_NewGN (char *name)
|
||||
Targ_NewGN(char *name)
|
||||
{
|
||||
GNode *gn;
|
||||
|
||||
gn = (GNode *) emalloc (sizeof (GNode));
|
||||
gn->name = estrdup (name);
|
||||
gn->path = (char *) 0;
|
||||
gn = (GNode *)emalloc(sizeof(GNode));
|
||||
gn->name = estrdup(name);
|
||||
gn->path = (char *)0;
|
||||
if (name[0] == '-' && name[1] == 'l') {
|
||||
gn->type = OP_LIB;
|
||||
} else {
|
||||
gn->type = 0;
|
||||
}
|
||||
gn->unmade = 0;
|
||||
gn->make = FALSE;
|
||||
gn->made = UNMADE;
|
||||
gn->childMade = FALSE;
|
||||
gn->order = 0;
|
||||
gn->unmade = 0;
|
||||
gn->make = FALSE;
|
||||
gn->made = UNMADE;
|
||||
gn->childMade = FALSE;
|
||||
gn->order = 0;
|
||||
gn->mtime = gn->cmtime = 0;
|
||||
gn->iParents = Lst_Init (FALSE);
|
||||
gn->cohorts = Lst_Init (FALSE);
|
||||
gn->parents = Lst_Init (FALSE);
|
||||
gn->children = Lst_Init (FALSE);
|
||||
gn->successors = Lst_Init (FALSE);
|
||||
gn->preds = Lst_Init (FALSE);
|
||||
gn->context = Lst_Init (FALSE);
|
||||
gn->commands = Lst_Init (FALSE);
|
||||
gn->suffix = NULL;
|
||||
gn->iParents = Lst_Init(FALSE);
|
||||
gn->cohorts = Lst_Init(FALSE);
|
||||
gn->parents = Lst_Init(FALSE);
|
||||
gn->children = Lst_Init(FALSE);
|
||||
gn->successors = Lst_Init(FALSE);
|
||||
gn->preds = Lst_Init(FALSE);
|
||||
gn->context = Lst_Init(FALSE);
|
||||
gn->commands = Lst_Init(FALSE);
|
||||
gn->suffix = NULL;
|
||||
|
||||
if (allGNs == NULL)
|
||||
allGNs = Lst_Init(FALSE);
|
||||
Lst_AtEnd(allGNs, (void *) gn);
|
||||
Lst_AtEnd(allGNs, (void *)gn);
|
||||
|
||||
return (gn);
|
||||
}
|
||||
|
@ -201,11 +203,10 @@ Targ_NewGN (char *name)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
TargFreeGN (void *gnp)
|
||||
TargFreeGN(void *gnp)
|
||||
{
|
||||
GNode *gn = (GNode *) gnp;
|
||||
|
||||
|
||||
free(gn->name);
|
||||
free(gn->path);
|
||||
|
||||
|
@ -236,29 +237,28 @@ TargFreeGN (void *gnp)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
GNode *
|
||||
Targ_FindNode (char *name, int flags)
|
||||
Targ_FindNode(char *name, int flags)
|
||||
{
|
||||
GNode *gn; /* node in that element */
|
||||
Hash_Entry *he; /* New or used hash entry for node */
|
||||
Boolean isNew; /* Set TRUE if Hash_CreateEntry had to create */
|
||||
/* an entry for the node */
|
||||
|
||||
|
||||
if (flags & TARG_CREATE) {
|
||||
he = Hash_CreateEntry (&targets, name, &isNew);
|
||||
he = Hash_CreateEntry(&targets, name, &isNew);
|
||||
if (isNew) {
|
||||
gn = Targ_NewGN (name);
|
||||
gn = Targ_NewGN(name);
|
||||
Hash_SetValue (he, gn);
|
||||
(void) Lst_AtEnd (allTargets, (void *)gn);
|
||||
Lst_AtEnd(allTargets, (void *)gn);
|
||||
}
|
||||
} else {
|
||||
he = Hash_FindEntry (&targets, name);
|
||||
he = Hash_FindEntry(&targets, name);
|
||||
}
|
||||
|
||||
if (he == (Hash_Entry *) NULL) {
|
||||
return (NULL);
|
||||
} else {
|
||||
return ((GNode *) Hash_GetValue (he));
|
||||
return ((GNode *)Hash_GetValue(he));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -278,36 +278,36 @@ Targ_FindNode (char *name, int flags)
|
|||
* -----------------------------------------------------------------------
|
||||
*/
|
||||
Lst
|
||||
Targ_FindList (Lst names, int flags)
|
||||
Targ_FindList(Lst names, int flags)
|
||||
{
|
||||
Lst nodes; /* result list */
|
||||
LstNode ln; /* name list element */
|
||||
GNode *gn; /* node in tLn */
|
||||
char *name;
|
||||
|
||||
nodes = Lst_Init (FALSE);
|
||||
nodes = Lst_Init(FALSE);
|
||||
|
||||
if (Lst_Open (names) == FAILURE) {
|
||||
if (Lst_Open(names) == FAILURE) {
|
||||
return (nodes);
|
||||
}
|
||||
while ((ln = Lst_Next (names)) != NULL) {
|
||||
while ((ln = Lst_Next(names)) != NULL) {
|
||||
name = (char *)Lst_Datum(ln);
|
||||
gn = Targ_FindNode (name, flags);
|
||||
gn = Targ_FindNode(name, flags);
|
||||
if (gn != NULL) {
|
||||
/*
|
||||
* Note: Lst_AtEnd must come before the Lst_Concat so the nodes
|
||||
* are added to the list in the order in which they were
|
||||
* encountered in the makefile.
|
||||
*/
|
||||
(void) Lst_AtEnd (nodes, (void *)gn);
|
||||
Lst_AtEnd(nodes, (void *)gn);
|
||||
if (gn->type & OP_DOUBLEDEP) {
|
||||
(void)Lst_Concat (nodes, gn->cohorts, LST_CONCNEW);
|
||||
Lst_Concat(nodes, gn->cohorts, LST_CONCNEW);
|
||||
}
|
||||
} else if (flags == TARG_NOCREATE) {
|
||||
Error ("\"%s\" -- target unknown.", name);
|
||||
Error("\"%s\" -- target unknown.", name);
|
||||
}
|
||||
}
|
||||
Lst_Close (names);
|
||||
Lst_Close(names);
|
||||
return (nodes);
|
||||
}
|
||||
|
||||
|
@ -324,9 +324,10 @@ Targ_FindList (Lst names, int flags)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Targ_Ignore (GNode *gn)
|
||||
Targ_Ignore(GNode *gn)
|
||||
{
|
||||
if (ignoreErrors || gn->type & OP_IGNORE) {
|
||||
|
||||
if (ignoreErrors || (gn->type & OP_IGNORE)) {
|
||||
return (TRUE);
|
||||
} else {
|
||||
return (FALSE);
|
||||
|
@ -346,9 +347,10 @@ Targ_Ignore (GNode *gn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Targ_Silent (GNode *gn)
|
||||
Targ_Silent(GNode *gn)
|
||||
{
|
||||
if (beSilent || gn->type & OP_SILENT) {
|
||||
|
||||
if (beSilent || (gn->type & OP_SILENT)) {
|
||||
return (TRUE);
|
||||
} else {
|
||||
return (FALSE);
|
||||
|
@ -368,9 +370,10 @@ Targ_Silent (GNode *gn)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Targ_Precious (GNode *gn)
|
||||
Targ_Precious(GNode *gn)
|
||||
{
|
||||
if (allPrecious || (gn->type & (OP_PRECIOUS|OP_DOUBLEDEP))) {
|
||||
|
||||
if (allPrecious || (gn->type & (OP_PRECIOUS | OP_DOUBLEDEP))) {
|
||||
return (TRUE);
|
||||
} else {
|
||||
return (FALSE);
|
||||
|
@ -380,6 +383,7 @@ Targ_Precious (GNode *gn)
|
|||
/******************* DEBUG INFO PRINTING ****************/
|
||||
|
||||
static GNode *mainTarg; /* the main target, as set by Targ_SetMain */
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Targ_SetMain --
|
||||
|
@ -394,23 +398,25 @@ static GNode *mainTarg; /* the main target, as set by Targ_SetMain */
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Targ_SetMain (GNode *gn)
|
||||
Targ_SetMain(GNode *gn)
|
||||
{
|
||||
|
||||
mainTarg = gn;
|
||||
}
|
||||
|
||||
static int
|
||||
TargPrintName (void *gnp, void *ppath)
|
||||
TargPrintName(void *gnp, void *ppath)
|
||||
{
|
||||
GNode *gn = (GNode *) gnp;
|
||||
printf ("%s ", gn->name);
|
||||
|
||||
printf("%s ", gn->name);
|
||||
#ifdef notdef
|
||||
if (ppath) {
|
||||
if (gn->path) {
|
||||
printf ("[%s] ", gn->path);
|
||||
printf("[%s] ", gn->path);
|
||||
}
|
||||
if (gn == mainTarg) {
|
||||
printf ("(MAIN NAME) ");
|
||||
printf("(MAIN NAME) ");
|
||||
}
|
||||
}
|
||||
#endif /* notdef */
|
||||
|
@ -419,9 +425,10 @@ TargPrintName (void *gnp, void *ppath)
|
|||
|
||||
|
||||
int
|
||||
Targ_PrintCmd (void *cmd, void *dummy __unused)
|
||||
Targ_PrintCmd(void *cmd, void *dummy __unused)
|
||||
{
|
||||
printf ("\t%s\n", (char *) cmd);
|
||||
|
||||
printf("\t%s\n", (char *)cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -440,7 +447,7 @@ Targ_PrintCmd (void *cmd, void *dummy __unused)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
char *
|
||||
Targ_FmtTime (time_t modtime)
|
||||
Targ_FmtTime(time_t modtime)
|
||||
{
|
||||
struct tm *parts;
|
||||
static char buf[128];
|
||||
|
@ -449,7 +456,7 @@ Targ_FmtTime (time_t modtime)
|
|||
|
||||
strftime(buf, sizeof buf, "%H:%M:%S %b %d, %Y", parts);
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
return(buf);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -465,7 +472,7 @@ Targ_FmtTime (time_t modtime)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Targ_PrintType (int type)
|
||||
Targ_PrintType(int type)
|
||||
{
|
||||
int tbit;
|
||||
|
||||
|
@ -504,10 +511,11 @@ Targ_PrintType (int type)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
TargPrintNode (void *gnp, void *passp)
|
||||
TargPrintNode(void *gnp, void *passp)
|
||||
{
|
||||
GNode *gn = (GNode *) gnp;
|
||||
int pass = *(int *) passp;
|
||||
GNode *gn = (GNode *)gnp;
|
||||
int pass = *(int *)passp;
|
||||
|
||||
if (!OP_NOP(gn->type)) {
|
||||
printf("#\n");
|
||||
if (gn == mainTarg) {
|
||||
|
@ -539,14 +547,14 @@ TargPrintNode (void *gnp, void *passp)
|
|||
}
|
||||
if (!Lst_IsEmpty (gn->iParents)) {
|
||||
printf("# implicit parents: ");
|
||||
Lst_ForEach (gn->iParents, TargPrintName, (void *)0);
|
||||
fputc ('\n', stdout);
|
||||
Lst_ForEach(gn->iParents, TargPrintName, (void *)0);
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
}
|
||||
if (!Lst_IsEmpty (gn->parents)) {
|
||||
printf("# parents: ");
|
||||
Lst_ForEach (gn->parents, TargPrintName, (void *)0);
|
||||
fputc ('\n', stdout);
|
||||
Lst_ForEach(gn->parents, TargPrintName, (void *)0);
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
|
||||
printf("%-16s", gn->name);
|
||||
|
@ -560,13 +568,13 @@ TargPrintNode (void *gnp, void *passp)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
Targ_PrintType (gn->type);
|
||||
Lst_ForEach (gn->children, TargPrintName, (void *)0);
|
||||
fputc ('\n', stdout);
|
||||
Lst_ForEach (gn->commands, Targ_PrintCmd, (void *)0);
|
||||
Targ_PrintType(gn->type);
|
||||
Lst_ForEach(gn->children, TargPrintName, (void *)0);
|
||||
fputc('\n', stdout);
|
||||
Lst_ForEach(gn->commands, Targ_PrintCmd, (void *)0);
|
||||
printf("\n\n");
|
||||
if (gn->type & OP_DOUBLEDEP) {
|
||||
Lst_ForEach (gn->cohorts, TargPrintNode, (void *)&pass);
|
||||
Lst_ForEach(gn->cohorts, TargPrintNode, (void *)&pass);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
|
@ -588,7 +596,8 @@ TargPrintNode (void *gnp, void *passp)
|
|||
static int
|
||||
TargPrintOnlySrc(void *gnp, void *dummy __unused)
|
||||
{
|
||||
GNode *gn = (GNode *) gnp;
|
||||
GNode *gn = (GNode *)gnp;
|
||||
|
||||
if (OP_NOP(gn->type))
|
||||
printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name);
|
||||
|
||||
|
@ -608,17 +617,17 @@ TargPrintOnlySrc(void *gnp, void *dummy __unused)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Targ_PrintGraph (int pass)
|
||||
Targ_PrintGraph(int pass)
|
||||
{
|
||||
printf("#*** Input graph:\n");
|
||||
Lst_ForEach (allTargets, TargPrintNode, (void *)&pass);
|
||||
Lst_ForEach(allTargets, TargPrintNode, (void *)&pass);
|
||||
printf("\n\n");
|
||||
printf("#\n# Files that are only sources:\n");
|
||||
Lst_ForEach (allTargets, TargPrintOnlySrc, (void *) 0);
|
||||
Lst_ForEach(allTargets, TargPrintOnlySrc, (void *)0);
|
||||
printf("#*** Global Variables:\n");
|
||||
Var_Dump (VAR_GLOBAL);
|
||||
Var_Dump(VAR_GLOBAL);
|
||||
printf("#*** Command-line Variables:\n");
|
||||
Var_Dump (VAR_CMD);
|
||||
Var_Dump(VAR_CMD);
|
||||
printf("\n");
|
||||
Dir_PrintDirectories();
|
||||
printf("\n");
|
||||
|
|
|
@ -81,9 +81,9 @@ Debug(const char *fmt, ...)
|
|||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fflush(stderr);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -103,10 +103,10 @@ Error(const char *fmt, ...)
|
|||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
(void)fflush(stderr);
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -130,10 +130,10 @@ Fatal(const char *fmt, ...)
|
|||
if (jobsRunning)
|
||||
Job_Wait();
|
||||
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
(void)fflush(stderr);
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
|
||||
if (DEBUG(GRAPH2))
|
||||
Targ_PrintGraph(2);
|
||||
|
@ -158,11 +158,11 @@ Punt(const char *fmt, ...)
|
|||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
(void)fprintf(stderr, "make: ");
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, "make: ");
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
(void)fflush(stderr);
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
|
||||
DieHorribly();
|
||||
}
|
||||
|
@ -201,6 +201,7 @@ DieHorribly(void)
|
|||
void
|
||||
Finish(int errors)
|
||||
{
|
||||
|
||||
Fatal("%d error%s", errors, errors == 1 ? "" : "s");
|
||||
}
|
||||
|
||||
|
@ -215,7 +216,7 @@ emalloc(size_t len)
|
|||
|
||||
if ((p = malloc(len)) == NULL)
|
||||
enomem();
|
||||
return(p);
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -229,7 +230,7 @@ estrdup(const char *str)
|
|||
|
||||
if ((p = strdup(str)) == NULL)
|
||||
enomem();
|
||||
return(p);
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -239,9 +240,10 @@ estrdup(const char *str)
|
|||
void *
|
||||
erealloc(void *ptr, size_t size)
|
||||
{
|
||||
|
||||
if ((ptr = realloc(ptr, size)) == NULL)
|
||||
enomem();
|
||||
return(ptr);
|
||||
return (ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -264,13 +266,13 @@ eunlink(const char *file)
|
|||
struct stat st;
|
||||
|
||||
if (lstat(file, &st) == -1)
|
||||
return -1;
|
||||
return (-1);
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
errno = EISDIR;
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
return unlink(file);
|
||||
return (unlink(file));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -280,6 +282,7 @@ eunlink(const char *file)
|
|||
int
|
||||
PrintAddr(void *a, void *b __unused)
|
||||
{
|
||||
|
||||
printf("%p ", a);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ static void VarPossiblyExpand(char **, GNode *);
|
|||
static Var *VarFind(char *, GNode *, int);
|
||||
static void VarAdd(char *, char *, GNode *);
|
||||
static void VarDelete(void *);
|
||||
static char *VarGetPattern(GNode *, int, char **, int, int *, int *,
|
||||
static char *VarGetPattern(GNode *, int, char **, int, int *, int *,
|
||||
VarPattern *);
|
||||
static char *VarModify(char *,
|
||||
Boolean (*)(const char *, Boolean, Buffer, void *),
|
||||
|
@ -156,9 +156,10 @@ static int VarPrintVar(void *, void *);
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
VarCmp (void *v, void *name)
|
||||
VarCmp(void *v, void *name)
|
||||
{
|
||||
return (strcmp ((char *) name, ((Var *) v)->name));
|
||||
|
||||
return (strcmp((char *)name, ((Var *)v)->name));
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -176,6 +177,7 @@ VarCmp (void *v, void *name)
|
|||
static void
|
||||
VarPossiblyExpand(char **name, GNode *ctxt)
|
||||
{
|
||||
|
||||
if (strchr(*name, '$') != NULL)
|
||||
*name = Var_Subst(NULL, *name, ctxt, 0);
|
||||
else
|
||||
|
@ -202,7 +204,7 @@ VarPossiblyExpand(char **name, GNode *ctxt)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static Var *
|
||||
VarFind (char *name, GNode *ctxt, int flags)
|
||||
VarFind(char *name, GNode *ctxt, int flags)
|
||||
{
|
||||
Boolean localCheckEnvFirst;
|
||||
LstNode var;
|
||||
|
@ -214,7 +216,7 @@ VarFind (char *name, GNode *ctxt, int flags)
|
|||
* and substitute the short version in for 'name' if it matches one of
|
||||
* them.
|
||||
*/
|
||||
if (*name == '.' && isupper((unsigned char) name[1]))
|
||||
if (*name == '.' && isupper((unsigned char)name[1]))
|
||||
switch (name[1]) {
|
||||
case 'A':
|
||||
if (!strcmp(name, ".ALLSRC"))
|
||||
|
@ -248,7 +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,
|
||||
if (Lst_Find(envFirstVars, (void *)name,
|
||||
(int (*)(void *, void *)) strcmp) != NULL)
|
||||
{
|
||||
localCheckEnvFirst = TRUE;
|
||||
|
@ -261,23 +263,23 @@ 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, (void *)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, (void *)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, (void *)name, VarCmp);
|
||||
}
|
||||
if ((var == NULL) && (flags & FIND_ENV)) {
|
||||
char *env;
|
||||
|
||||
if ((env = getenv (name)) != NULL) {
|
||||
if ((env = getenv(name)) != NULL) {
|
||||
int len;
|
||||
|
||||
v = (Var *) emalloc(sizeof(Var));
|
||||
v = (Var *)emalloc(sizeof(Var));
|
||||
v->name = estrdup(name);
|
||||
|
||||
len = strlen(env);
|
||||
|
@ -290,19 +292,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, (void *)name, VarCmp);
|
||||
if (var == NULL) {
|
||||
return ((Var *) NULL);
|
||||
return ((Var *)NULL);
|
||||
} else {
|
||||
return ((Var *)Lst_Datum(var));
|
||||
}
|
||||
} else {
|
||||
return((Var *)NULL);
|
||||
return ((Var *)NULL);
|
||||
}
|
||||
} else if (var == NULL) {
|
||||
return ((Var *) NULL);
|
||||
return ((Var *)NULL);
|
||||
} else {
|
||||
return ((Var *) Lst_Datum (var));
|
||||
return ((Var *)Lst_Datum(var));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,14 +323,14 @@ VarFind (char *name, GNode *ctxt, int flags)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
VarAdd (char *name, char *val, GNode *ctxt)
|
||||
VarAdd(char *name, char *val, GNode *ctxt)
|
||||
{
|
||||
Var *v;
|
||||
int len;
|
||||
|
||||
v = (Var *) emalloc (sizeof (Var));
|
||||
v = (Var *)emalloc(sizeof(Var));
|
||||
|
||||
v->name = estrdup (name);
|
||||
v->name = estrdup(name);
|
||||
|
||||
len = val ? strlen(val) : 0;
|
||||
v->val = Buf_Init(len+1);
|
||||
|
@ -336,12 +338,11 @@ VarAdd (char *name, char *val, GNode *ctxt)
|
|||
|
||||
v->flags = 0;
|
||||
|
||||
(void) Lst_AtFront (ctxt->context, (void *)v);
|
||||
(void) Lst_AtEnd (allVars, (void *) v);
|
||||
Lst_AtFront(ctxt->context, (void *)v);
|
||||
Lst_AtEnd(allVars, (void *)v);
|
||||
DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val));
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* VarDelete --
|
||||
|
@ -357,14 +358,13 @@ VarAdd (char *name, char *val, GNode *ctxt)
|
|||
static void
|
||||
VarDelete(void *vp)
|
||||
{
|
||||
Var *v = (Var *) vp;
|
||||
Var *v = (Var *)vp;
|
||||
|
||||
free(v->name);
|
||||
Buf_Destroy(v->val, TRUE);
|
||||
free(v);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Var_Delete --
|
||||
|
@ -392,7 +392,7 @@ Var_Delete(char *name, GNode *ctxt)
|
|||
Lst_Remove(ctxt->context, ln);
|
||||
ln = Lst_Member(allVars, v);
|
||||
Lst_Remove(allVars, ln);
|
||||
VarDelete((void *) v);
|
||||
VarDelete((void *)v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ Var_Delete(char *name, GNode *ctxt)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Var_Set (char *name, char *val, GNode *ctxt)
|
||||
Var_Set(char *name, char *val, GNode *ctxt)
|
||||
{
|
||||
Var *v;
|
||||
|
||||
|
@ -428,9 +428,9 @@ Var_Set (char *name, char *val, GNode *ctxt)
|
|||
* point in searching them all just to save a bit of memory...
|
||||
*/
|
||||
VarPossiblyExpand(&name, ctxt);
|
||||
v = VarFind (name, ctxt, 0);
|
||||
if (v == (Var *) NULL) {
|
||||
VarAdd (name, val, ctxt);
|
||||
v = VarFind(name, ctxt, 0);
|
||||
if (v == (Var *)NULL) {
|
||||
VarAdd(name, val, ctxt);
|
||||
} else {
|
||||
Buf_Discard(v->val, Buf_Size(v->val));
|
||||
Buf_AddBytes(v->val, strlen(val), (Byte *)val);
|
||||
|
@ -470,21 +470,21 @@ Var_Set (char *name, char *val, GNode *ctxt)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Var_Append (char *name, char *val, GNode *ctxt)
|
||||
Var_Append(char *name, char *val, GNode *ctxt)
|
||||
{
|
||||
Var *v;
|
||||
|
||||
VarPossiblyExpand(&name, ctxt);
|
||||
v = VarFind (name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0);
|
||||
v = VarFind(name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0);
|
||||
|
||||
if (v == (Var *) NULL) {
|
||||
VarAdd (name, val, ctxt);
|
||||
if (v == (Var *)NULL) {
|
||||
VarAdd(name, val, ctxt);
|
||||
} else {
|
||||
Buf_AddByte(v->val, (Byte)' ');
|
||||
Buf_AddBytes(v->val, strlen(val), (Byte *)val);
|
||||
|
||||
DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name,
|
||||
(char *) Buf_GetAll(v->val, (int *)NULL)));
|
||||
DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name,
|
||||
(char *)Buf_GetAll(v->val, (int *)NULL)));
|
||||
|
||||
if (v->flags & VAR_FROM_ENV) {
|
||||
/*
|
||||
|
@ -523,13 +523,13 @@ Var_Exists(char *name, GNode *ctxt)
|
|||
free(name);
|
||||
|
||||
if (v == (Var *)NULL) {
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
} else if (v->flags & VAR_FROM_ENV) {
|
||||
free(v->name);
|
||||
Buf_Destroy(v->val, TRUE);
|
||||
free((char *)v);
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -545,12 +545,12 @@ Var_Exists(char *name, GNode *ctxt)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
char *
|
||||
Var_Value (char *name, GNode *ctxt, char **frp)
|
||||
Var_Value(char *name, GNode *ctxt, char **frp)
|
||||
{
|
||||
Var *v;
|
||||
|
||||
VarPossiblyExpand(&name, ctxt);
|
||||
v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
|
||||
v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
|
||||
free(name);
|
||||
*frp = NULL;
|
||||
if (v != (Var *) NULL) {
|
||||
|
@ -560,9 +560,9 @@ Var_Value (char *name, GNode *ctxt, char **frp)
|
|||
free(v);
|
||||
*frp = p;
|
||||
}
|
||||
return p;
|
||||
return (p);
|
||||
} else {
|
||||
return ((char *) NULL);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -581,7 +581,7 @@ Var_Value (char *name, GNode *ctxt, char **frp)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static char *
|
||||
VarModify (char *str, Boolean (*modProc)(const char *, Boolean, Buffer, void *),
|
||||
VarModify(char *str, Boolean (*modProc)(const char *, Boolean, Buffer, void *),
|
||||
void *datum)
|
||||
{
|
||||
Buffer buf; /* Buffer for the new string */
|
||||
|
@ -591,7 +591,7 @@ VarModify (char *str, Boolean (*modProc)(const char *, Boolean, Buffer, void *),
|
|||
char **av; /* word list [first word does not count] */
|
||||
int ac, i;
|
||||
|
||||
buf = Buf_Init (0);
|
||||
buf = Buf_Init(0);
|
||||
addSpace = FALSE;
|
||||
|
||||
av = brk_string(str, &ac, FALSE);
|
||||
|
@ -600,8 +600,8 @@ VarModify (char *str, Boolean (*modProc)(const char *, Boolean, Buffer, void *),
|
|||
addSpace = (*modProc)(av[i], addSpace, buf, datum);
|
||||
|
||||
Buf_AddByte (buf, '\0');
|
||||
str = (char *)Buf_GetAll (buf, (int *)NULL);
|
||||
Buf_Destroy (buf, FALSE);
|
||||
str = (char *)Buf_GetAll(buf, (int *)NULL);
|
||||
Buf_Destroy(buf, FALSE);
|
||||
return (str);
|
||||
}
|
||||
|
||||
|
@ -644,6 +644,7 @@ VarSortWords(char *str, int (*cmp)(const void *, const void *))
|
|||
static int
|
||||
SortIncreasing(const void *l, const void *r)
|
||||
{
|
||||
|
||||
return (strcmp(*(const char* const*)l, *(const char* const*)r));
|
||||
}
|
||||
|
||||
|
@ -676,6 +677,7 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags,
|
|||
char *cp;
|
||||
Buffer buf = Buf_Init(0);
|
||||
int junk;
|
||||
|
||||
if (length == NULL)
|
||||
length = &junk;
|
||||
|
||||
|
@ -691,12 +693,12 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags,
|
|||
*/
|
||||
for (cp = *tstr; *cp && (*cp != delim); cp++) {
|
||||
if (IS_A_MATCH(cp, delim)) {
|
||||
Buf_AddByte(buf, (Byte) cp[1]);
|
||||
Buf_AddByte(buf, (Byte)cp[1]);
|
||||
cp++;
|
||||
} else if (*cp == '$') {
|
||||
if (cp[1] == delim) {
|
||||
if (flags == NULL)
|
||||
Buf_AddByte(buf, (Byte) *cp);
|
||||
Buf_AddByte(buf, (Byte)*cp);
|
||||
else
|
||||
/*
|
||||
* Unescaped $ at end of pattern => anchor
|
||||
|
@ -715,7 +717,7 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags,
|
|||
* substitution and recurse.
|
||||
*/
|
||||
cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt);
|
||||
Buf_AddBytes(buf, strlen(cp2), (Byte *) cp2);
|
||||
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
|
||||
if (freeIt)
|
||||
free(cp2);
|
||||
cp += len - 1;
|
||||
|
@ -743,33 +745,31 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags,
|
|||
Buf_AddBytes(buf, cp2 - cp, (Byte *)cp);
|
||||
cp = --cp2;
|
||||
} else
|
||||
Buf_AddByte(buf, (Byte) *cp);
|
||||
Buf_AddByte(buf, (Byte)*cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pattern && *cp == '&')
|
||||
Buf_AddBytes(buf, pattern->leftLen, (Byte *)pattern->lhs);
|
||||
else
|
||||
Buf_AddByte(buf, (Byte) *cp);
|
||||
Buf_AddByte(buf, (Byte)*cp);
|
||||
}
|
||||
|
||||
Buf_AddByte(buf, (Byte) '\0');
|
||||
Buf_AddByte(buf, (Byte)'\0');
|
||||
|
||||
if (*cp != delim) {
|
||||
*tstr = cp;
|
||||
*length = 0;
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
return (NULL);
|
||||
} else {
|
||||
*tstr = ++cp;
|
||||
cp = (char *) Buf_GetAll(buf, length);
|
||||
cp = (char *)Buf_GetAll(buf, length);
|
||||
*length -= 1; /* Don't count the NULL */
|
||||
Buf_Destroy(buf, FALSE);
|
||||
return cp;
|
||||
return (cp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Var_Quote --
|
||||
|
@ -786,22 +786,21 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags,
|
|||
char *
|
||||
Var_Quote(const char *str)
|
||||
{
|
||||
|
||||
Buffer buf;
|
||||
/* This should cover most shells :-( */
|
||||
static char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~";
|
||||
char *ret;
|
||||
|
||||
buf = Buf_Init (MAKE_BSIZE);
|
||||
buf = Buf_Init(MAKE_BSIZE);
|
||||
for (; *str; str++) {
|
||||
if (strchr(meta, *str) != NULL)
|
||||
Buf_AddByte(buf, (Byte)'\\');
|
||||
Buf_AddByte(buf, (Byte)*str);
|
||||
}
|
||||
Buf_AddByte(buf, (Byte) '\0');
|
||||
ret = Buf_GetAll (buf, NULL);
|
||||
Buf_Destroy (buf, FALSE);
|
||||
return ret;
|
||||
Buf_AddByte(buf, (Byte)'\0');
|
||||
ret = Buf_GetAll(buf, NULL);
|
||||
Buf_Destroy(buf, FALSE);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -889,7 +888,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
name[0] = str[1];
|
||||
name[1] = '\0';
|
||||
|
||||
v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
|
||||
v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
|
||||
if (v == (Var *)NULL) {
|
||||
if (str[1] != '\0')
|
||||
*lengthPtr = 2;
|
||||
|
@ -909,13 +908,13 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
/* XXX: It looks like $% and $! are reversed here */
|
||||
switch (str[1]) {
|
||||
case '@':
|
||||
return("$(.TARGET)");
|
||||
return ("$(.TARGET)");
|
||||
case '%':
|
||||
return("$(.ARCHIVE)");
|
||||
return ("$(.ARCHIVE)");
|
||||
case '*':
|
||||
return("$(.PREFIX)");
|
||||
return ("$(.PREFIX)");
|
||||
case '!':
|
||||
return("$(.MEMBER)");
|
||||
return ("$(.MEMBER)");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -945,18 +944,18 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
int rlen;
|
||||
Boolean rfree;
|
||||
char* rval = Var_Parse(tstr, ctxt, err, &rlen, &rfree);
|
||||
|
||||
|
||||
if (rval == var_Error) {
|
||||
Fatal("Error expanding embedded variable.");
|
||||
} else if (rval != NULL) {
|
||||
Buf_AddBytes(buf, strlen(rval), (Byte *) rval);
|
||||
Buf_AddBytes(buf, strlen(rval), (Byte *)rval);
|
||||
if (rfree)
|
||||
free(rval);
|
||||
}
|
||||
tstr += rlen - 1;
|
||||
} else
|
||||
Buf_AddByte(buf, (Byte) *tstr);
|
||||
|
||||
Buf_AddByte(buf, (Byte)*tstr);
|
||||
|
||||
if (*tstr == '\0') {
|
||||
/*
|
||||
* If we never did find the end character, return NULL
|
||||
|
@ -966,15 +965,15 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
*lengthPtr = tstr - str;
|
||||
return (var_Error);
|
||||
}
|
||||
|
||||
|
||||
haveModifier = (*tstr == ':');
|
||||
*tstr = '\0';
|
||||
|
||||
Buf_AddByte(buf, (Byte) '\0');
|
||||
Buf_AddByte(buf, (Byte)'\0');
|
||||
str = Buf_GetAll(buf, NULL);
|
||||
vlen = strlen(str);
|
||||
|
||||
v = VarFind (str, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
|
||||
v = VarFind(str, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
|
||||
if ((v == (Var *)NULL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) &&
|
||||
(vlen == 2) && (str[1] == 'F' || str[1] == 'D'))
|
||||
{
|
||||
|
@ -982,7 +981,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
* Check for bogus D and F forms of local variables since we're
|
||||
* in a local context and the name is the right length.
|
||||
*/
|
||||
switch(str[0]) {
|
||||
switch (str[0]) {
|
||||
case '@':
|
||||
case '%':
|
||||
case '*':
|
||||
|
@ -1021,7 +1020,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
*lengthPtr = tstr-start+1;
|
||||
*tstr = endc;
|
||||
Buf_Destroy(buf, TRUE);
|
||||
return(val);
|
||||
return (val);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1032,8 +1031,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
|
||||
if (v == (Var *)NULL) {
|
||||
if (((vlen == 1) ||
|
||||
(((vlen == 2) && (str[1] == 'F' ||
|
||||
str[1] == 'D')))) &&
|
||||
(((vlen == 2) && (str[1] == 'F' || str[1] == 'D')))) &&
|
||||
((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)))
|
||||
{
|
||||
/*
|
||||
|
@ -1056,7 +1054,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
break;
|
||||
}
|
||||
} else if ((vlen > 2) && (str[0] == '.') &&
|
||||
isupper((unsigned char) str[1]) &&
|
||||
isupper((unsigned char)str[1]) &&
|
||||
((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)))
|
||||
{
|
||||
int len;
|
||||
|
@ -1084,7 +1082,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
str[*lengthPtr] = '\0';
|
||||
*freePtr = TRUE;
|
||||
Buf_Destroy(buf, TRUE);
|
||||
return(str);
|
||||
return (str);
|
||||
} else {
|
||||
Buf_Destroy(buf, TRUE);
|
||||
return (err ? var_Error : varNoError);
|
||||
|
@ -1094,7 +1092,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 = (Var *)emalloc(sizeof(Var));
|
||||
v->name = estrdup(str);
|
||||
v->val = Buf_Init(1);
|
||||
v->flags = VAR_JUNK;
|
||||
|
@ -1119,7 +1117,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
* return.
|
||||
*/
|
||||
str = (char *)Buf_GetAll(v->val, (int *)NULL);
|
||||
if (strchr (str, '$') != (char *)NULL) {
|
||||
if (strchr(str, '$') != (char *)NULL) {
|
||||
str = Var_Subst(NULL, str, ctxt, err);
|
||||
*freePtr = TRUE;
|
||||
}
|
||||
|
@ -1170,7 +1168,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
*cp != '\0' && *cp != ':' && *cp != endc;
|
||||
cp++)
|
||||
{
|
||||
if (*cp == '\\' && (cp[1] == ':' || cp[1] == endc)){
|
||||
if (*cp == '\\' && (cp[1] == ':' || cp[1] == endc)) {
|
||||
copy = TRUE;
|
||||
cp++;
|
||||
}
|
||||
|
@ -1203,8 +1201,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
if (*tstr == 'M' || *tstr == 'm') {
|
||||
newStr = VarModify(str, VarMatch, (void *)pattern);
|
||||
} else {
|
||||
newStr = VarModify(str, VarNoMatch,
|
||||
(void *)pattern);
|
||||
newStr = VarModify(str, VarNoMatch, (void *)pattern);
|
||||
}
|
||||
if (copy) {
|
||||
free(pattern);
|
||||
|
@ -1374,8 +1371,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, (void *)&pattern);
|
||||
/*
|
||||
* Free the two strings.
|
||||
*/
|
||||
|
@ -1465,10 +1461,10 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
Buffer buf;
|
||||
buf = Buf_Init(MAKE_BSIZE);
|
||||
for (cp = str; *cp ; cp++)
|
||||
Buf_AddByte(buf, (Byte) tolower(*cp));
|
||||
Buf_AddByte(buf, (Byte)tolower(*cp));
|
||||
|
||||
Buf_AddByte(buf, (Byte) '\0');
|
||||
newStr = (char *) Buf_GetAll(buf, (int *) NULL);
|
||||
Buf_AddByte(buf, (Byte)'\0');
|
||||
newStr = (char *)Buf_GetAll(buf, (int *)NULL);
|
||||
Buf_Destroy(buf, FALSE);
|
||||
|
||||
cp = tstr + 1;
|
||||
|
@ -1486,7 +1482,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
/* FALLTHROUGH */
|
||||
case 'Q':
|
||||
if (tstr[1] == endc || tstr[1] == ':') {
|
||||
newStr = Var_Quote (str);
|
||||
newStr = Var_Quote(str);
|
||||
cp = tstr + 1;
|
||||
termc = *cp;
|
||||
break;
|
||||
|
@ -1494,7 +1490,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 *)0);
|
||||
cp = tstr + 1;
|
||||
termc = *cp;
|
||||
break;
|
||||
|
@ -1505,10 +1501,10 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
Buffer buf;
|
||||
buf = Buf_Init(MAKE_BSIZE);
|
||||
for (cp = str; *cp ; cp++)
|
||||
Buf_AddByte(buf, (Byte) toupper(*cp));
|
||||
Buf_AddByte(buf, (Byte)toupper(*cp));
|
||||
|
||||
Buf_AddByte(buf, (Byte) '\0');
|
||||
newStr = (char *) Buf_GetAll(buf, (int *) NULL);
|
||||
Buf_AddByte(buf, (Byte)'\0');
|
||||
newStr = (char *)Buf_GetAll(buf, (int *)NULL);
|
||||
Buf_Destroy(buf, FALSE);
|
||||
|
||||
cp = tstr + 1;
|
||||
|
@ -1518,7 +1514,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 *)0);
|
||||
cp = tstr + 1;
|
||||
termc = *cp;
|
||||
break;
|
||||
|
@ -1526,7 +1522,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 *)0);
|
||||
cp = tstr + 1;
|
||||
termc = *cp;
|
||||
break;
|
||||
|
@ -1534,7 +1530,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 *)0);
|
||||
cp = tstr + 1;
|
||||
termc = *cp;
|
||||
break;
|
||||
|
@ -1544,9 +1540,9 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
case 's':
|
||||
if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) {
|
||||
char *error;
|
||||
newStr = Cmd_Exec (str, &error);
|
||||
newStr = Cmd_Exec(str, &error);
|
||||
if (error)
|
||||
Error (error, str);
|
||||
Error(error, str);
|
||||
cp = tstr + 2;
|
||||
termc = *cp;
|
||||
break;
|
||||
|
@ -1626,8 +1622,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, (void *)&pattern);
|
||||
|
||||
free(pattern.lhs);
|
||||
free(pattern.rhs);
|
||||
|
@ -1636,7 +1631,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
} else
|
||||
#endif
|
||||
{
|
||||
Error ("Unknown modifier '%c'\n", *tstr);
|
||||
Error("Unknown modifier '%c'\n", *tstr);
|
||||
for (cp = tstr+1;
|
||||
*cp != ':' && *cp != endc && *cp != '\0';
|
||||
cp++)
|
||||
|
@ -1649,7 +1644,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
DEBUGF(VAR, ("Result is \"%s\"\n", newStr));
|
||||
|
||||
if (*freePtr) {
|
||||
free (str);
|
||||
free(str);
|
||||
}
|
||||
str = newStr;
|
||||
if (str != var_Error) {
|
||||
|
@ -1726,7 +1721,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
char *
|
||||
Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr)
|
||||
Var_Subst(char *var, char *str, GNode *ctxt, Boolean undefErr)
|
||||
{
|
||||
Buffer buf; /* Buffer for forming things */
|
||||
char *val; /* Value to substitute for a variable */
|
||||
|
@ -1736,7 +1731,7 @@ Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr)
|
|||
* been reported to prevent a plethora
|
||||
* of messages when recursing */
|
||||
|
||||
buf = Buf_Init (MAKE_BSIZE);
|
||||
buf = Buf_Init(MAKE_BSIZE);
|
||||
errorReported = FALSE;
|
||||
|
||||
while (*str) {
|
||||
|
@ -1765,7 +1760,7 @@ Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr)
|
|||
for (;;) {
|
||||
if (str[1] != '(' && str[1] != '{') {
|
||||
if (str[1] != *var || var[1] != '\0') {
|
||||
Buf_AddBytes(buf, 2, (Byte *) str);
|
||||
Buf_AddBytes(buf, 2, (Byte *)str);
|
||||
str += 2;
|
||||
expand = FALSE;
|
||||
}
|
||||
|
@ -1789,7 +1784,7 @@ Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr)
|
|||
* the nested one
|
||||
*/
|
||||
if (*p == '$') {
|
||||
Buf_AddBytes(buf, p - str, (Byte *) str);
|
||||
Buf_AddBytes(buf, p - str, (Byte *)str);
|
||||
str = p;
|
||||
continue;
|
||||
}
|
||||
|
@ -1802,7 +1797,7 @@ Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr)
|
|||
*/
|
||||
for (;*p != '$' && *p != '\0'; p++)
|
||||
continue;
|
||||
Buf_AddBytes(buf, p - str, (Byte *) str);
|
||||
Buf_AddBytes(buf, p - str, (Byte *)str);
|
||||
str = p;
|
||||
expand = FALSE;
|
||||
}
|
||||
|
@ -1815,7 +1810,7 @@ Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr)
|
|||
continue;
|
||||
}
|
||||
|
||||
val = Var_Parse (str, ctxt, undefErr, &length, &doFree);
|
||||
val = Var_Parse(str, ctxt, undefErr, &length, &doFree);
|
||||
|
||||
/*
|
||||
* When we come down here, val should either point to the
|
||||
|
@ -1839,7 +1834,7 @@ Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr)
|
|||
* when the file is parsed.
|
||||
*/
|
||||
if (!errorReported) {
|
||||
Parse_Error (PARSE_FATAL,
|
||||
Parse_Error(PARSE_FATAL,
|
||||
"Undefined variable \"%.*s\"",length,str);
|
||||
}
|
||||
str += length;
|
||||
|
@ -1859,17 +1854,17 @@ Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr)
|
|||
* Copy all the characters from the variable value straight
|
||||
* into the new string.
|
||||
*/
|
||||
Buf_AddBytes (buf, strlen (val), (Byte *)val);
|
||||
Buf_AddBytes(buf, strlen(val), (Byte *)val);
|
||||
if (doFree) {
|
||||
free (val);
|
||||
free(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Buf_AddByte (buf, '\0');
|
||||
str = (char *)Buf_GetAll (buf, (int *)NULL);
|
||||
Buf_Destroy (buf, FALSE);
|
||||
Buf_AddByte(buf, '\0');
|
||||
str = (char *)Buf_GetAll(buf, (int *)NULL);
|
||||
Buf_Destroy(buf, FALSE);
|
||||
return (str);
|
||||
}
|
||||
|
||||
|
@ -1890,7 +1885,8 @@ Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr)
|
|||
char *
|
||||
Var_GetTail(char *file)
|
||||
{
|
||||
return(VarModify(file, VarTail, (void *)0));
|
||||
|
||||
return (VarModify(file, VarTail, (void *)0));
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -1911,7 +1907,8 @@ Var_GetTail(char *file)
|
|||
char *
|
||||
Var_GetHead(char *file)
|
||||
{
|
||||
return(VarModify(file, VarHead, (void *)0));
|
||||
|
||||
return (VarModify(file, VarHead, (void *)0));
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -1927,28 +1924,30 @@ Var_GetHead(char *file)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Var_Init (void)
|
||||
Var_Init(void)
|
||||
{
|
||||
VAR_GLOBAL = Targ_NewGN ("Global");
|
||||
VAR_CMD = Targ_NewGN ("Command");
|
||||
|
||||
VAR_GLOBAL = Targ_NewGN("Global");
|
||||
VAR_CMD = Targ_NewGN("Command");
|
||||
allVars = Lst_Init(FALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Var_End (void)
|
||||
Var_End(void)
|
||||
{
|
||||
|
||||
Lst_Destroy(allVars, VarDelete);
|
||||
}
|
||||
|
||||
|
||||
/****************** PRINT DEBUGGING INFO *****************/
|
||||
static int
|
||||
VarPrintVar (void *vp, void *dummy __unused)
|
||||
VarPrintVar(void *vp, void *dummy __unused)
|
||||
{
|
||||
Var *v = (Var *) vp;
|
||||
printf ("%-16s = %s\n", v->name, (char *) Buf_GetAll(v->val, (int *)NULL));
|
||||
|
||||
printf("%-16s = %s\n", v->name, (char *)Buf_GetAll(v->val, (int *)NULL));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1959,7 +1958,8 @@ VarPrintVar (void *vp, void *dummy __unused)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Var_Dump (GNode *ctxt)
|
||||
Var_Dump(GNode *ctxt)
|
||||
{
|
||||
Lst_ForEach (ctxt->context, VarPrintVar, (void *) 0);
|
||||
|
||||
Lst_ForEach (ctxt->context, VarPrintVar, (void *)0);
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ typedef struct {
|
|||
int flags;
|
||||
} VarPattern;
|
||||
|
||||
typedef struct {
|
||||
regex_t re;
|
||||
typedef struct {
|
||||
regex_t re;
|
||||
int nsub;
|
||||
regmatch_t *matches;
|
||||
char *replace;
|
||||
|
|
|
@ -66,19 +66,19 @@ __FBSDID("$FreeBSD$");
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
VarHead (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
||||
VarHead(const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
||||
{
|
||||
char *slash;
|
||||
char *buffer;
|
||||
|
||||
buffer = estrdup(word);
|
||||
slash = strrchr (buffer, '/');
|
||||
slash = strrchr(buffer, '/');
|
||||
if (slash != NULL) {
|
||||
if (addSpace) {
|
||||
Buf_AddByte (buf, (Byte)' ');
|
||||
Buf_AddByte(buf, (Byte)' ');
|
||||
}
|
||||
*slash = '\0';
|
||||
Buf_AddBytes (buf, strlen (buffer), (Byte *)buffer);
|
||||
Buf_AddBytes(buf, strlen (buffer), (Byte *)buffer);
|
||||
free(buffer);
|
||||
return (TRUE);
|
||||
} else {
|
||||
|
@ -111,7 +111,7 @@ VarHead (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
VarTail (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
||||
VarTail(const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
||||
{
|
||||
const char *slash;
|
||||
|
||||
|
@ -119,11 +119,11 @@ VarTail (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
|||
Buf_AddByte (buf, (Byte)' ');
|
||||
}
|
||||
|
||||
slash = strrchr (word, '/');
|
||||
slash = strrchr(word, '/');
|
||||
if (slash++ != NULL) {
|
||||
Buf_AddBytes (buf, strlen(slash), (Byte *)slash);
|
||||
Buf_AddBytes(buf, strlen(slash), (Byte *)slash);
|
||||
} else {
|
||||
Buf_AddBytes (buf, strlen(word), (Byte *)word);
|
||||
Buf_AddBytes(buf, strlen(word), (Byte *)word);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
@ -143,16 +143,16 @@ VarTail (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
VarSuffix (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
||||
VarSuffix(const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
||||
{
|
||||
const char *dot;
|
||||
|
||||
dot = strrchr (word, '.');
|
||||
dot = strrchr(word, '.');
|
||||
if (dot++ != (char *)NULL) {
|
||||
if (addSpace) {
|
||||
Buf_AddByte (buf, (Byte)' ');
|
||||
Buf_AddByte(buf, (Byte)' ');
|
||||
}
|
||||
Buf_AddBytes (buf, strlen (dot), (Byte *)dot);
|
||||
Buf_AddBytes(buf, strlen (dot), (Byte *)dot);
|
||||
addSpace = TRUE;
|
||||
}
|
||||
return (addSpace);
|
||||
|
@ -174,21 +174,21 @@ VarSuffix (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
VarRoot (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
||||
VarRoot(const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
||||
{
|
||||
char *buffer;
|
||||
char *dot;
|
||||
|
||||
if (addSpace) {
|
||||
Buf_AddByte (buf, (Byte)' ');
|
||||
Buf_AddByte(buf, (Byte)' ');
|
||||
}
|
||||
|
||||
buffer = estrdup(word);
|
||||
dot = strrchr (buffer, '.');
|
||||
dot = strrchr(buffer, '.');
|
||||
if (dot != NULL) {
|
||||
*dot = '\0';
|
||||
}
|
||||
Buf_AddBytes (buf, strlen(buffer), (Byte *)buffer);
|
||||
Buf_AddBytes(buf, strlen(buffer), (Byte *)buffer);
|
||||
free(buffer);
|
||||
return (TRUE);
|
||||
}
|
||||
|
@ -211,8 +211,9 @@ VarRoot (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
VarMatch (const char *word, Boolean addSpace, Buffer buf, void *pattern)
|
||||
VarMatch(const char *word, Boolean addSpace, Buffer buf, void *pattern)
|
||||
{
|
||||
|
||||
if (Str_Match(word, pattern)) {
|
||||
if (addSpace) {
|
||||
Buf_AddByte(buf, (Byte)' ');
|
||||
|
@ -220,7 +221,7 @@ VarMatch (const char *word, Boolean addSpace, Buffer buf, void *pattern)
|
|||
addSpace = TRUE;
|
||||
Buf_AddBytes(buf, strlen(word), word);
|
||||
}
|
||||
return(addSpace);
|
||||
return (addSpace);
|
||||
}
|
||||
|
||||
#ifdef SYSVVARSUB
|
||||
|
@ -241,11 +242,11 @@ VarMatch (const char *word, Boolean addSpace, Buffer buf, void *pattern)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
VarSYSVMatch (const char *word, Boolean addSpace, Buffer buf, void *patp)
|
||||
VarSYSVMatch(const char *word, Boolean addSpace, Buffer buf, void *patp)
|
||||
{
|
||||
int len;
|
||||
const char *ptr;
|
||||
VarPattern *pat = (VarPattern *) patp;
|
||||
VarPattern *pat = (VarPattern *)patp;
|
||||
|
||||
if (addSpace)
|
||||
Buf_AddByte(buf, (Byte)' ');
|
||||
|
@ -257,7 +258,7 @@ VarSYSVMatch (const char *word, Boolean addSpace, Buffer buf, void *patp)
|
|||
else
|
||||
Buf_AddBytes(buf, strlen(word), (Byte *) word);
|
||||
|
||||
return(addSpace);
|
||||
return (addSpace);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -279,8 +280,9 @@ VarSYSVMatch (const char *word, Boolean addSpace, Buffer buf, void *patp)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
VarNoMatch (const char *word, Boolean addSpace, Buffer buf, void *pattern)
|
||||
VarNoMatch(const char *word, Boolean addSpace, Buffer buf, void *pattern)
|
||||
{
|
||||
|
||||
if (!Str_Match(word, pattern)) {
|
||||
if (addSpace) {
|
||||
Buf_AddByte(buf, (Byte)' ');
|
||||
|
@ -288,7 +290,7 @@ VarNoMatch (const char *word, Boolean addSpace, Buffer buf, void *pattern)
|
|||
addSpace = TRUE;
|
||||
Buf_AddBytes(buf, strlen(word), (Byte *)word);
|
||||
}
|
||||
return(addSpace);
|
||||
return (addSpace);
|
||||
}
|
||||
|
||||
|
||||
|
@ -307,11 +309,11 @@ VarNoMatch (const char *word, Boolean addSpace, Buffer buf, void *pattern)
|
|||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
VarSubstitute (const char *word, Boolean addSpace, Buffer buf, void *patternp)
|
||||
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 = (VarPattern *)patternp;
|
||||
|
||||
wordLen = strlen(word);
|
||||
if (1) { /* substitute in each word of the variable */
|
||||
|
@ -452,7 +454,7 @@ VarSubstitute (const char *word, Boolean addSpace, Buffer buf, void *patternp)
|
|||
Buf_AddByte(buf, (Byte)' ');
|
||||
}
|
||||
Buf_AddBytes(buf, wordLen, (Byte *)word);
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -579,5 +581,5 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp)
|
|||
}
|
||||
break;
|
||||
}
|
||||
return(addSpace||added);
|
||||
return (addSpace||added);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue