Use findcc() from ../mkdep so ${CC} can contain multiple tokens instead

of trying to exec the whole contents of ${CC}.
This commit is contained in:
simonb 2002-06-14 23:20:42 +00:00
parent f76ac8f4dc
commit 4feaf5241d
2 changed files with 28 additions and 21 deletions

View File

@ -1,13 +1,15 @@
# $NetBSD: Makefile,v 1.12 2001/11/12 23:16:37 tv Exp $
# $NetBSD: Makefile,v 1.13 2002/06/14 23:20:42 simonb Exp $
.PATH: ${.CURDIR}/../lint1
.PATH: ${.CURDIR}/../../mkdep
PROG= xlint
SRCS= xlint.c mem.c
SRCS= xlint.c mem.c findcc.c
PROGNAME= lint
MAN= lint.1
CPPFLAGS+= -I${.CURDIR}/../lint1
CPPFLAGS+= -I${.CURDIR}/../../mkdep
.ifndef HOSTPROG
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: xlint.c,v 1.27 2002/01/31 19:09:33 tv Exp $ */
/* $NetBSD: xlint.c,v 1.28 2002/06/14 23:20:42 simonb Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: xlint.c,v 1.27 2002/01/31 19:09:33 tv Exp $");
__RCSID("$NetBSD: xlint.c,v 1.28 2002/06/14 23:20:42 simonb Exp $");
#endif
#include <sys/param.h>
@ -52,6 +52,9 @@ __RCSID("$NetBSD: xlint.c,v 1.27 2002/01/31 19:09:33 tv Exp $");
#include "lint.h"
#include "pathnames.h"
#include "findcc.h"
#define DEFAULT_PATH _PATH_DEFPATH
int main(int, char *[]);
@ -581,7 +584,7 @@ static void
fname(const char *name)
{
const char *bn, *suff;
char **args, *ofn, *path;
char **args, *ofn, *pathname, *CC;
size_t len;
int is_stdin;
int fd;
@ -637,15 +640,17 @@ fname(const char *name)
args = xcalloc(1, sizeof (char *));
/* run cc */
if (getenv("CC") == NULL) {
path = xmalloc(strlen(PATH_USRBIN) + sizeof ("/cc"));
(void)sprintf(path, "%s/cc", PATH_USRBIN);
} else {
path = strdup(getenv("CC"));
if ((CC = getenv("CC")) == NULL)
CC = DEFAULT_CC;
if ((pathname = findcc(CC)) == NULL)
if (!setenv("PATH", DEFAULT_PATH, 1))
pathname = findcc(CC);
if (pathname == NULL) {
(void)fprintf(stderr, "%s: %s: not found\n", getprogname(), CC);
exit(EXIT_FAILURE);
}
appcstrg(&args, path);
appcstrg(&args, pathname);
applst(&args, cflags);
applst(&args, lcflags);
appcstrg(&args, name);
@ -660,33 +665,33 @@ fname(const char *name)
terminate(-1);
}
runchild(path, args, cppout, cppoutfd);
free(path);
runchild(pathname, args, cppout, cppoutfd);
free(pathname);
freelst(&args);
/* run lint1 */
if (!Bflag) {
path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint1") +
pathname = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint1") +
strlen(target_prefix));
(void)sprintf(path, "%s/%slint1", PATH_LIBEXEC,
(void)sprintf(pathname, "%s/%slint1", PATH_LIBEXEC,
target_prefix);
} else {
/*
* XXX Unclear whether we should be using target_prefix
* XXX here. --thorpej@wasabisystems.com
*/
path = xmalloc(strlen(libexec_path) + sizeof ("/lint1"));
(void)sprintf(path, "%s/lint1", libexec_path);
pathname = xmalloc(strlen(libexec_path) + sizeof ("/lint1"));
(void)sprintf(pathname, "%s/lint1", libexec_path);
}
appcstrg(&args, path);
appcstrg(&args, pathname);
applst(&args, l1flags);
appcstrg(&args, cppout);
appcstrg(&args, ofn);
runchild(path, args, ofn, -1);
free(path);
runchild(pathname, args, ofn, -1);
free(pathname);
freelst(&args);
appcstrg(&p2in, ofn);