Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/xlint Use findcc() from ../mkdep so ${CC} can ...
details: https://anonhg.NetBSD.org/src/rev/317b10cf1786
branches: trunk
changeset: 532776:317b10cf1786
user: simonb <simonb%NetBSD.org@localhost>
date: Fri Jun 14 23:20:42 2002 +0000
description:
Use findcc() from ../mkdep so ${CC} can contain multiple tokens instead
of trying to exec the whole contents of ${CC}.
diffstat:
usr.bin/xlint/xlint/Makefile | 6 ++++--
usr.bin/xlint/xlint/xlint.c | 43 ++++++++++++++++++++++++-------------------
2 files changed, 28 insertions(+), 21 deletions(-)
diffs (126 lines):
diff -r 9578830483ed -r 317b10cf1786 usr.bin/xlint/xlint/Makefile
--- a/usr.bin/xlint/xlint/Makefile Fri Jun 14 23:14:18 2002 +0000
+++ b/usr.bin/xlint/xlint/Makefile Fri Jun 14 23:20:42 2002 +0000
@@ -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>
diff -r 9578830483ed -r 317b10cf1786 usr.bin/xlint/xlint/xlint.c
--- a/usr.bin/xlint/xlint/xlint.c Fri Jun 14 23:14:18 2002 +0000
+++ b/usr.bin/xlint/xlint/xlint.c Fri Jun 14 23:20:42 2002 +0000
@@ -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 @@
#include "lint.h"
#include "pathnames.h"
+#include "findcc.h"
+
+#define DEFAULT_PATH _PATH_DEFPATH
int main(int, char *[]);
@@ -581,7 +584,7 @@
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 @@
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 @@
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@localhost
*/
- 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);
Home |
Main Index |
Thread Index |
Old Index