aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Murray <markm@FreeBSD.org>2002-07-19 15:19:23 +0000
committerMark Murray <markm@FreeBSD.org>2002-07-19 15:19:23 +0000
commite07f5fa8bb8cb80256b2424481bf0878a9a1b0f0 (patch)
tree7c251fa21fd198cb0c54a7290d1e978d05b3f1af
parentfdd16680061b6380766b7ee04f7db3030a9ccecd (diff)
downloadsrc-vendor/NetBSD/xlint.tar.gz
src-vendor/NetBSD/xlint.zip
Snapshot of NetBSD's (x)lint. Little functionality, just some codevendor/NetBSD/xlint
tidy-ups.
Notes
Notes: svn path=/cvs2svn/branches/JPO/; revision=100360
-rw-r--r--usr.bin/xlint/common/lint.h2
-rw-r--r--usr.bin/xlint/common/param.h11
-rw-r--r--usr.bin/xlint/lint1/err.c18
-rw-r--r--usr.bin/xlint/lint1/mem1.c11
-rw-r--r--usr.bin/xlint/xlint/Makefile6
-rw-r--r--usr.bin/xlint/xlint/lint.18
-rw-r--r--usr.bin/xlint/xlint/xlint.c43
7 files changed, 53 insertions, 46 deletions
diff --git a/usr.bin/xlint/common/lint.h b/usr.bin/xlint/common/lint.h
index c73f73c9d49c..c50d28dd2f84 100644
--- a/usr.bin/xlint/common/lint.h
+++ b/usr.bin/xlint/common/lint.h
@@ -1,4 +1,4 @@
-/* $NetBSD: lint.h,v 1.3 2002/01/31 22:44:00 tv Exp $ */
+/* $NetBSD: lint.h,v 1.5 2002/03/07 18:29:56 tv Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
diff --git a/usr.bin/xlint/common/param.h b/usr.bin/xlint/common/param.h
index 46f7326506e8..5a28ce461b52 100644
--- a/usr.bin/xlint/common/param.h
+++ b/usr.bin/xlint/common/param.h
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.1 2002/01/18 20:39:24 thorpej Exp $ */
+/* $NetBSD: param.h,v 1.2 2002/02/05 03:04:26 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -67,11 +67,9 @@
#define WCHAR INT
/*
- * long double only in ANSI C.
- *
* And the sparc64 long double code generation is broken.
*/
-#if !defined(__sparc64__) && defined(__STDC__)
+#if !defined(__sparc64__)
typedef long double ldbl_t;
#else
typedef double ldbl_t;
@@ -80,9 +78,4 @@ typedef double ldbl_t;
/*
* Some traditional compilers are not able to assign structures.
*/
-#ifdef __STDC__
#define STRUCT_ASSIGN(dest, src) (dest) = (src)
-#else
-#define STRUCT_ASSIGN(dest, src) (void)memcpy(&(dest), &(src), \
- sizeof (dest));
-#endif
diff --git a/usr.bin/xlint/lint1/err.c b/usr.bin/xlint/lint1/err.c
index ffbc1bc79a64..24e895095a18 100644
--- a/usr.bin/xlint/lint1/err.c
+++ b/usr.bin/xlint/lint1/err.c
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.16 2001/12/13 23:56:00 augustss Exp $ */
+/* $NetBSD: err.c,v 1.17 2002/01/31 19:36:54 tv Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.16 2001/12/13 23:56:00 augustss Exp $");
+__RCSID("$NetBSD: err.c,v 1.17 2002/01/31 19:36:54 tv Exp $");
#endif
#include <sys/types.h>
@@ -49,7 +49,7 @@ int nerr;
int sytxerr;
-static const char *basename(const char *);
+static const char *lbasename(const char *);
static void verror(int, va_list);
static void vwarning(int, va_list);
@@ -383,11 +383,11 @@ msglist(void)
}
/*
- * If Fflag is not set basename() returns a pointer to the last
+ * If Fflag is not set lbasename() returns a pointer to the last
* component of the path, otherwise it returns the argument.
*/
static const char *
-basename(const char *path)
+lbasename(const char *path)
{
const char *cp, *cp1, *cp2;
@@ -412,7 +412,7 @@ verror( int n, va_list ap)
if (ERR_ISSET(n, &msgset))
return;
- fn = basename(curr_pos.p_file);
+ fn = lbasename(curr_pos.p_file);
(void)printf("%s(%d): ", fn, curr_pos.p_line);
(void)vprintf(msgs[n], ap);
(void)printf(" [%d]\n", n);
@@ -431,7 +431,7 @@ vwarning( int n, va_list ap)
/* this warning is suppressed by a LINTED comment */
return;
- fn = basename(curr_pos.p_file);
+ fn = lbasename(curr_pos.p_file);
(void)printf("%s(%d): warning: ", fn, curr_pos.p_line);
(void)vprintf(msgs[n], ap);
(void)printf(" [%d]\n", n);
@@ -456,7 +456,7 @@ lerror(const char *msg, ...)
const char *fn;
va_start(ap, msg);
- fn = basename(curr_pos.p_file);
+ fn = lbasename(curr_pos.p_file);
(void)fprintf(stderr, "%s(%d): lint error: ", fn, curr_pos.p_line);
(void)vfprintf(stderr, msg, ap);
(void)fprintf(stderr, "\n");
@@ -484,7 +484,7 @@ message(int n, ...)
return;
va_start(ap, n);
- fn = basename(curr_pos.p_file);
+ fn = lbasename(curr_pos.p_file);
(void)printf("%s(%d): ", fn, curr_pos.p_line);
(void)vprintf(msgs[n], ap);
(void)printf(" [%d]\n", n);
diff --git a/usr.bin/xlint/lint1/mem1.c b/usr.bin/xlint/lint1/mem1.c
index 4e21f0795c40..49a00177abe0 100644
--- a/usr.bin/xlint/lint1/mem1.c
+++ b/usr.bin/xlint/lint1/mem1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mem1.c,v 1.6 2002/01/29 02:43:39 tv Exp $ */
+/* $NetBSD: mem1.c,v 1.7 2002/01/31 19:36:54 tv Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.6 2002/01/29 02:43:39 tv Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.7 2002/01/31 19:36:54 tv Exp $");
#endif
#include <sys/types.h>
@@ -196,11 +196,18 @@ xgetblk(mbl_t **mbp, size_t s)
{
mbl_t *mb;
void *p;
+ size_t t = 0;
s = ALIGN(s);
if ((mb = *mbp) == NULL || mb->nfree < s) {
if ((mb = frmblks) == NULL) {
+ if (s > mblklen) {
+ t = mblklen;
+ mblklen = s;
+ }
mb = xnewblk();
+ if (t)
+ mblklen = t;
(void)memset(mb->blk, 0, mb->size);
} else {
frmblks = mb->nxt;
diff --git a/usr.bin/xlint/xlint/Makefile b/usr.bin/xlint/xlint/Makefile
index c49e6c2ae4a8..cd25aff731ac 100644
--- a/usr.bin/xlint/xlint/Makefile
+++ b/usr.bin/xlint/xlint/Makefile
@@ -1,13 +1,15 @@
-# $NetBSD: Makefile,v 1.11 2001/10/25 02:22:56 thorpej Exp $
+# $NetBSD: Makefile,v 1.12 2001/11/12 23:16:37 tv 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 --git a/usr.bin/xlint/xlint/lint.1 b/usr.bin/xlint/xlint/lint.1
index 6c127e283881..4421724ae914 100644
--- a/usr.bin/xlint/xlint/lint.1
+++ b/usr.bin/xlint/xlint/lint.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: lint.1,v 1.20 2001/12/08 19:27:56 wiz Exp $
+.\" $NetBSD: lint.1,v 1.21 2002/01/03 04:25:18 thorpej Exp $
.\"
.\" Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
.\" Copyright (c) 1994, 1995 Jochen Pohl
@@ -294,11 +294,11 @@ is not predefined in this mode. Warnings are printed for constructs
not allowed in traditional C. Warnings for constructs which behave
differently in traditional C and ANSI C are suppressed. Preprocessor
macros describing the machine type (e.g.
-.Li sun3 Ns )
+.Li sun3 )
and machine architecture (e.g.
-.Li m68k Ns )
+.Li m68k )
are defined without leading and trailing underscores. The keywords
-.Sy const Ns ,
+.Sy const ,
.Sy volatile
and
.Sy signed
diff --git a/usr.bin/xlint/xlint/xlint.c b/usr.bin/xlint/xlint/xlint.c
index bacf9c8557e4..d97d678ed0c2 100644
--- a/usr.bin/xlint/xlint/xlint.c
+++ b/usr.bin/xlint/xlint/xlint.c
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.26 2002/01/22 01:14:03 thorpej Exp $ */
+/* $NetBSD: xlint.c,v 1.27 2002/01/31 19:09:33 tv 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.26 2002/01/22 01:14:03 thorpej Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.27 2002/01/31 19:09:33 tv Exp $");
#endif
#include <sys/param.h>
@@ -52,6 +52,9 @@ __RCSID("$NetBSD: xlint.c,v 1.26 2002/01/22 01:14:03 thorpej 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);