Snapshot of NetBSD's (x)lint. Little functionality, just some code
tidy-ups.
This commit is contained in:
parent
fdd1668006
commit
e07f5fa8bb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/JPO/; revision=100360
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user