Remove xlint(1).
xlint is currently a fossil. We have much more useful and alive tools to do now what xlint did twenty years ago. I did not cleared some stuff which makes lint operational, in sys/x86/include and sys/sys, but I might do it as followup. The x86/include/ucontext.h and _types.h hacks made to please lint was the main reason for my initial proposal to classify xlint as obsolete and to remove it. Also I do not intend to clear sccs ids. Reviewed by: bapt, brooks, emaste, jhb, pfg Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D13015
This commit is contained in:
parent
b53cf0d5b7
commit
768f1c3fe3
@ -38,6 +38,15 @@
|
||||
# xargs -n1 | sort | uniq -d;
|
||||
# done
|
||||
|
||||
# 20171116: lint(1) removal
|
||||
OLD_FILES+=usr/bin/lint
|
||||
OLD_FILES+=usr/libexec/lint1
|
||||
OLD_FILES+=usr/libexec/lint2
|
||||
OLD_FILES+=usr/libdata/lint/llib-lposix.ln
|
||||
OLD_FILES+=usr/libdata/lint/llib-lstdc.ln
|
||||
OLD_FILES+=usr/share/man/man1/lint.1.gz
|
||||
OLD_FILES+=usr/share/man/man7/lint.7.gz
|
||||
OLD_DIRS+=usr/libdata/lint
|
||||
# 20171114: Removal of all fortune datfiles other than freebsd-tips
|
||||
OLD_FILES+=usr/share/games/fortune/fortunes
|
||||
OLD_FILES+=usr/share/games/fortune/fortunes.dat
|
||||
|
@ -56,8 +56,6 @@
|
||||
..
|
||||
ldscripts
|
||||
..
|
||||
lint
|
||||
..
|
||||
pkgconfig
|
||||
..
|
||||
..
|
||||
|
@ -364,10 +364,6 @@ configuration data
|
||||
linker scripts;
|
||||
see
|
||||
.Xr ld 1
|
||||
.It Pa lint/
|
||||
various prebuilt lint libraries;
|
||||
see
|
||||
.Xr lint 1
|
||||
.El
|
||||
.Pp
|
||||
.It Pa libexec/
|
||||
|
@ -867,14 +867,11 @@ KNF
|
||||
compliant in the repository must not diverge from compliance.
|
||||
.Pp
|
||||
Whenever possible, code should be run through a code checker
|
||||
(e.g.,
|
||||
.Xr lint 1
|
||||
or
|
||||
(e.g., various static analyzers or
|
||||
.Nm cc Fl Wall )
|
||||
and produce minimal warnings.
|
||||
.Sh SEE ALSO
|
||||
.Xr indent 1 ,
|
||||
.Xr lint 1 ,
|
||||
.Xr err 3 ,
|
||||
.Xr warn 3 ,
|
||||
.Xr style.Makefile 5
|
||||
|
@ -15,7 +15,6 @@ DIRDEPS = \
|
||||
usr.bin/mkcsmapper_static \
|
||||
usr.bin/mkesdb_static \
|
||||
usr.bin/xinstall \
|
||||
usr.bin/xlint/xlint \
|
||||
usr.bin/yacc \
|
||||
usr.sbin/config \
|
||||
usr.sbin/crunch/crunchgen \
|
||||
|
@ -416,10 +416,6 @@ DIRDEPS+= \
|
||||
usr.bin/write \
|
||||
usr.bin/xargs \
|
||||
usr.bin/xinstall \
|
||||
usr.bin/xlint/lint1 \
|
||||
usr.bin/xlint/lint2 \
|
||||
usr.bin/xlint/llib \
|
||||
usr.bin/xlint/xlint \
|
||||
usr.bin/xo \
|
||||
usr.bin/xstr \
|
||||
usr.bin/xz \
|
||||
|
@ -278,9 +278,6 @@ SUBDIR.${MK_TOOLCHAIN}+= rpcgen
|
||||
SUBDIR.${MK_TOOLCHAIN}+= unifdef
|
||||
SUBDIR.${MK_TOOLCHAIN}+= size
|
||||
SUBDIR.${MK_TOOLCHAIN}+= strings
|
||||
.if ${MACHINE_ARCH} != "aarch64" # ARM64TODO xlint does not build
|
||||
SUBDIR.${MK_TOOLCHAIN}+= xlint
|
||||
.endif
|
||||
SUBDIR.${MK_TOOLCHAIN}+= xstr
|
||||
SUBDIR.${MK_TOOLCHAIN}+= yacc
|
||||
SUBDIR.${MK_VI}+= vi
|
||||
|
@ -1,12 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.2 1995/07/03 21:23:45 cgd Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
.if ${LINT} == "lint"
|
||||
_llib= llib
|
||||
.else
|
||||
_llib=
|
||||
.endif
|
||||
|
||||
SUBDIR= lint1 lint2 xlint ${_llib}
|
||||
|
||||
.include <bsd.subdir.mk>
|
@ -1,15 +0,0 @@
|
||||
# $NetBSD: Makefile.inc,v 1.8 2002/02/04 00:18:32 thorpej Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
WARNS?= 0
|
||||
|
||||
.PATH: ${.CURDIR}/../common
|
||||
|
||||
.if exists(${.CURDIR}/../arch/${MACHINE_ARCH})
|
||||
CFLAGS+= -I${.CURDIR}/../arch/${MACHINE_ARCH}
|
||||
.else
|
||||
CFLAGS+= -I${.CURDIR}/../arch/${MACHINE_CPUARCH}
|
||||
.endif
|
||||
CFLAGS+= -I${.CURDIR}/../common
|
||||
|
||||
OBJECT_FMT= ELF
|
@ -1,50 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
#include "lp64.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (16 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.2 2002/01/30 06:55:00 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "lp64.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (16 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,63 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:19 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "ilp32.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#if defined(TARGET_OBJFMT_ELF)
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
#else
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
#endif
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (8 * CHAR_BIT)
|
||||
|
||||
#if defined(TARGET_OBJFMT_ELF)
|
||||
/* XXX ARM ELF ABI says packed enums -- variable size! */
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
||||
#else
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
||||
#endif
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:19 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "ilp32.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (12 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "ilp32.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (8 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:19 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "ilp32.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (12 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:19 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "ilp32.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (8 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:20 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "ilp32.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (12 * CHAR_BIT) /* XXX double-check */
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,55 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:20 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "ilp32.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (8 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,55 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:20 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "lp64.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (8 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.2 2002/01/30 06:55:00 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "lp64.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (16 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:20 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "ilp32.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (8 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:21 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "ilp32.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (8 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,55 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.3 2002/01/31 23:31:34 he Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "lp64.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (16 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:22 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "ilp32.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (8 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,53 +0,0 @@
|
||||
/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:22 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent target parameters for lint1.
|
||||
*/
|
||||
|
||||
#include "lp64.h"
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long. Note this MUST be
|
||||
* kept in sync with the compiler!
|
||||
*/
|
||||
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
|
||||
#define FLOAT_SIZE (4 * CHAR_BIT)
|
||||
#define DOUBLE_SIZE (8 * CHAR_BIT)
|
||||
#define LDOUBLE_SIZE (16 * CHAR_BIT)
|
||||
|
||||
#define ENUM_SIZE (4 * CHAR_BIT)
|
@ -1,234 +0,0 @@
|
||||
/* $NetBSD: emit.c,v 1.2 2002/01/21 19:49:51 tv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: emit.c,v 1.2 2002/01/21 19:49:51 tv Exp $");
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lint.h"
|
||||
|
||||
/* name and handle of output file */
|
||||
static const char *loname;
|
||||
static FILE *lout;
|
||||
|
||||
/* output buffer data */
|
||||
ob_t ob;
|
||||
|
||||
static void outxbuf(void);
|
||||
|
||||
|
||||
/*
|
||||
* initialize output
|
||||
*/
|
||||
void
|
||||
outopen(const char *name)
|
||||
{
|
||||
|
||||
loname = name;
|
||||
|
||||
/* Open output file */
|
||||
if ((lout = fopen(name, "w")) == NULL)
|
||||
err(1, "cannot open '%s'", name);
|
||||
|
||||
/* Create output buffer */
|
||||
ob.o_len = 1024;
|
||||
ob.o_end = (ob.o_buf = ob.o_nxt = xmalloc(ob.o_len)) + ob.o_len;
|
||||
}
|
||||
|
||||
/*
|
||||
* flush output buffer and close file
|
||||
*/
|
||||
void
|
||||
outclose(void)
|
||||
{
|
||||
|
||||
outclr();
|
||||
if (fclose(lout) == EOF)
|
||||
err(1, "cannot close '%s'", loname);
|
||||
}
|
||||
|
||||
/*
|
||||
* resize output buffer
|
||||
*/
|
||||
static void
|
||||
outxbuf(void)
|
||||
{
|
||||
ptrdiff_t coffs;
|
||||
|
||||
coffs = ob.o_nxt - ob.o_buf;
|
||||
ob.o_len *= 2;
|
||||
ob.o_end = (ob.o_buf = xrealloc(ob.o_buf, ob.o_len)) + ob.o_len;
|
||||
ob.o_nxt = ob.o_buf + coffs;
|
||||
}
|
||||
|
||||
/*
|
||||
* reset output buffer
|
||||
* if it is not empty, it is flushed
|
||||
*/
|
||||
void
|
||||
outclr(void)
|
||||
{
|
||||
size_t sz;
|
||||
|
||||
if (ob.o_buf != ob.o_nxt) {
|
||||
outchar('\n');
|
||||
sz = ob.o_nxt - ob.o_buf;
|
||||
if (sz > ob.o_len)
|
||||
errx(1, "internal error: outclr() 1");
|
||||
if (fwrite(ob.o_buf, sz, 1, lout) != 1)
|
||||
err(1, "cannot write to %s", loname);
|
||||
ob.o_nxt = ob.o_buf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write a character to the output buffer
|
||||
*/
|
||||
void
|
||||
outchar(int c)
|
||||
{
|
||||
|
||||
if (ob.o_nxt == ob.o_end)
|
||||
outxbuf();
|
||||
*ob.o_nxt++ = (char)c;
|
||||
}
|
||||
|
||||
/*
|
||||
* write a character to the output buffer, qouted if necessary
|
||||
*/
|
||||
void
|
||||
outqchar(int c)
|
||||
{
|
||||
|
||||
if (isprint(c) && c != '\\' && c != '"' && c != '\'') {
|
||||
outchar(c);
|
||||
} else {
|
||||
outchar('\\');
|
||||
switch (c) {
|
||||
case '\\':
|
||||
outchar('\\');
|
||||
break;
|
||||
case '"':
|
||||
outchar('"');
|
||||
break;
|
||||
case '\'':
|
||||
outchar('\'');
|
||||
break;
|
||||
case '\b':
|
||||
outchar('b');
|
||||
break;
|
||||
case '\t':
|
||||
outchar('t');
|
||||
break;
|
||||
case '\n':
|
||||
outchar('n');
|
||||
break;
|
||||
case '\f':
|
||||
outchar('f');
|
||||
break;
|
||||
case '\r':
|
||||
outchar('r');
|
||||
break;
|
||||
case '\v':
|
||||
outchar('v');
|
||||
break;
|
||||
case '\a':
|
||||
outchar('a');
|
||||
break;
|
||||
default:
|
||||
outchar((((u_int)c >> 6) & 07) + '0');
|
||||
outchar((((u_int)c >> 3) & 07) + '0');
|
||||
outchar((c & 07) + '0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write a strint to the output buffer
|
||||
* the string must not contain any characters which
|
||||
* should be quoted
|
||||
*/
|
||||
void
|
||||
outstrg(const char *s)
|
||||
{
|
||||
|
||||
while (*s != '\0') {
|
||||
if (ob.o_nxt == ob.o_end)
|
||||
outxbuf();
|
||||
*ob.o_nxt++ = *s++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write an integer value to toe output buffer
|
||||
*/
|
||||
void
|
||||
outint(int i)
|
||||
{
|
||||
|
||||
if ((ob.o_end - ob.o_nxt) < 3 * sizeof (int))
|
||||
outxbuf();
|
||||
ob.o_nxt += sprintf(ob.o_nxt, "%d", i);
|
||||
}
|
||||
|
||||
/*
|
||||
* write the name of a symbol to the output buffer
|
||||
* the name is preceded by its length
|
||||
*/
|
||||
void
|
||||
outname(const char *name)
|
||||
{
|
||||
|
||||
if (name == NULL)
|
||||
errx(1, "internal error: outname() 1");
|
||||
outint((int)strlen(name));
|
||||
outstrg(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* write the name of the .c source
|
||||
*/
|
||||
void
|
||||
outsrc(const char *name)
|
||||
{
|
||||
|
||||
outclr();
|
||||
outchar('S');
|
||||
outstrg(name);
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/* $NetBSD: externs.h,v 1.1 2002/01/18 20:39:23 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* main[12].c
|
||||
*/
|
||||
extern int pflag;
|
||||
|
||||
/*
|
||||
* inittyp.c
|
||||
*/
|
||||
extern void inittyp(void);
|
||||
|
||||
/*
|
||||
* mem.c
|
||||
*/
|
||||
extern void *xmalloc(size_t);
|
||||
extern void *xcalloc(size_t, size_t);
|
||||
extern void *xrealloc(void *, size_t);
|
||||
extern char *xstrdup(const char *);
|
||||
extern void nomem(void);
|
||||
|
||||
/*
|
||||
* emit.c
|
||||
*/
|
||||
extern ob_t ob;
|
||||
|
||||
extern void outopen(const char *);
|
||||
extern void outclose(void);
|
||||
extern void outclr(void);
|
||||
extern void outchar(int);
|
||||
extern void outqchar(int);
|
||||
extern void outstrg(const char *);
|
||||
extern void outint(int);
|
||||
extern void outname(const char *);
|
||||
extern void outsrc(const char *);
|
@ -1,59 +0,0 @@
|
||||
/* $NetBSD: ilp32.h,v 1.1 2002/01/18 20:39:23 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the NetBSD Project by
|
||||
* Wasabi Systems, Inc.
|
||||
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Type sizes for IPL32 platforms (int, long, pointer: 32-bit)
|
||||
*/
|
||||
|
||||
#define CHAR_SIZE (CHAR_BIT)
|
||||
#define SHORT_SIZE (2 * CHAR_BIT)
|
||||
#define INT_SIZE (4 * CHAR_BIT)
|
||||
#define LONG_SIZE (4 * CHAR_BIT)
|
||||
#define QUAD_SIZE (8 * CHAR_BIT)
|
||||
#define PTR_SIZE (4 * CHAR_BIT)
|
||||
|
||||
#define TARG_INT_MAX ((int32_t) (((uint32_t) -1) >> 1))
|
||||
#define TARG_INT_MIN ((-TARG_INT_MAX) - 1)
|
||||
#define TARG_UINT_MAX ((uint32_t) -1)
|
||||
|
||||
#define TARG_LONG_MAX TARG_INT_MAX
|
||||
#define TARG_LONG_MIN TARG_INT_MIN
|
||||
#define TARG_ULONG_MAX TARG_UINT_MAX
|
||||
|
||||
#define TARG_QUAD_MAX ((int64_t) (((uint64_t) -1) >> 1))
|
||||
#define TARG_QUAD_MIN ((-TARG_QUAD_MAX) - 1)
|
||||
#define TARG_UQUAD_MAX ((uint64_t) -1)
|
@ -1,133 +0,0 @@
|
||||
/* $NetBSD: inittyp.c,v 1.3 2002/01/30 06:55:02 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: inittyp.c,v 1.3 2002/01/30 06:55:02 thorpej Exp $");
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lint.h"
|
||||
|
||||
/* various type information */
|
||||
ttab_t ttab[NTSPEC];
|
||||
|
||||
void
|
||||
inittyp(void)
|
||||
{
|
||||
int i;
|
||||
static const struct {
|
||||
tspec_t it_tspec;
|
||||
ttab_t it_ttab;
|
||||
} ittab[NTSPEC] = {
|
||||
{ SIGNED, { 0, 0,
|
||||
SIGNED, UNSIGN,
|
||||
0, 0, 0, 0, 0, "signed" } },
|
||||
{ UNSIGN, { 0, 0,
|
||||
SIGNED, UNSIGN,
|
||||
0, 0, 0, 0, 0, "unsigned" } },
|
||||
{ CHAR, { CHAR_SIZE, CHAR_BIT,
|
||||
SCHAR, UCHAR,
|
||||
1, 0, 0, 1, 1, "char" } },
|
||||
{ SCHAR, { CHAR_SIZE, CHAR_BIT,
|
||||
SCHAR, UCHAR,
|
||||
1, 0, 0, 1, 1, "signed char" } },
|
||||
{ UCHAR, { CHAR_SIZE, CHAR_BIT,
|
||||
SCHAR, UCHAR,
|
||||
1, 1, 0, 1, 1, "unsigned char" } },
|
||||
{ SHORT, { SHORT_SIZE, 2 * CHAR_BIT,
|
||||
SHORT, USHORT,
|
||||
1, 0, 0, 1, 1, "short" } },
|
||||
{ USHORT, { SHORT_SIZE, 2 * CHAR_BIT,
|
||||
SHORT, USHORT,
|
||||
1, 1, 0, 1, 1, "unsigned short" } },
|
||||
{ INT, { INT_SIZE, 3 * CHAR_BIT,
|
||||
INT, UINT,
|
||||
1, 0, 0, 1, 1, "int" } },
|
||||
{ UINT, { INT_SIZE, 3 * CHAR_BIT,
|
||||
INT, UINT,
|
||||
1, 1, 0, 1, 1, "unsigned int" } },
|
||||
{ LONG, { LONG_SIZE, 4 * CHAR_BIT,
|
||||
LONG, ULONG,
|
||||
1, 0, 0, 1, 1, "long" } },
|
||||
{ ULONG, { LONG_SIZE, 4 * CHAR_BIT,
|
||||
LONG, ULONG,
|
||||
1, 1, 0, 1, 1, "unsigned long" } },
|
||||
{ QUAD, { QUAD_SIZE, 8 * CHAR_BIT,
|
||||
QUAD, UQUAD,
|
||||
1, 0, 0, 1, 1, "long long" } },
|
||||
{ UQUAD, { QUAD_SIZE, 8 * CHAR_BIT,
|
||||
QUAD, UQUAD,
|
||||
1, 1, 0, 1, 1, "unsigned long long" } },
|
||||
{ FLOAT, { FLOAT_SIZE, 4 * CHAR_BIT,
|
||||
FLOAT, FLOAT,
|
||||
0, 0, 1, 1, 1, "float" } },
|
||||
{ DOUBLE, { DOUBLE_SIZE, 8 * CHAR_BIT,
|
||||
DOUBLE, DOUBLE,
|
||||
0, 0, 1, 1, 1, "double" } },
|
||||
{ LDOUBLE, { LDOUBLE_SIZE, 10 * CHAR_BIT,
|
||||
LDOUBLE, LDOUBLE,
|
||||
0, 0, 1, 1, 1, "long double" } },
|
||||
{ VOID, { -1, -1,
|
||||
VOID, VOID,
|
||||
0, 0, 0, 0, 0, "void" } },
|
||||
{ STRUCT, { -1, -1,
|
||||
STRUCT, STRUCT,
|
||||
0, 0, 0, 0, 0, "struct" } },
|
||||
{ UNION, { -1, -1,
|
||||
UNION, UNION,
|
||||
0, 0, 0, 0, 0, "union" } },
|
||||
{ ENUM, { ENUM_SIZE, 3 * CHAR_BIT,
|
||||
ENUM, ENUM,
|
||||
1, 0, 0, 1, 1, "enum" } },
|
||||
{ PTR, { PTR_SIZE, 4 * CHAR_BIT,
|
||||
PTR, PTR,
|
||||
0, 1, 0, 0, 1, "pointer" } },
|
||||
{ ARRAY, { -1, -1,
|
||||
ARRAY, ARRAY,
|
||||
0, 0, 0, 0, 0, "array" } },
|
||||
{ FUNC, { -1, -1,
|
||||
FUNC, FUNC,
|
||||
0, 0, 0, 0, 0, "function" } },
|
||||
};
|
||||
|
||||
for (i = 0; i < sizeof (ittab) / sizeof (ittab[0]); i++)
|
||||
STRUCT_ASSIGN(ttab[ittab[i].it_tspec], ittab[i].it_ttab);
|
||||
if (!pflag) {
|
||||
for (i = 0; i < NTSPEC; i++)
|
||||
ttab[i].tt_psz = ttab[i].tt_sz;
|
||||
}
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
/* $NetBSD: lint.h,v 1.7 2003/10/27 00:12:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#else
|
||||
#define HAVE_DECL_SYS_SIGNAME 1
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stddef.h>
|
||||
#include <err.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "param.h"
|
||||
|
||||
/*
|
||||
* Type specifiers, used in type structures (type_t) and otherwere.
|
||||
*/
|
||||
typedef enum {
|
||||
NOTSPEC = 0,
|
||||
SIGNED, /* keyword "signed", only used in the parser */
|
||||
UNSIGN, /* keyword "unsigned", only used in the parser */
|
||||
CHAR, /* char */
|
||||
SCHAR, /* signed char */
|
||||
UCHAR, /* unsigned char */
|
||||
SHORT, /* (signed) short */
|
||||
USHORT, /* unsigned short */
|
||||
INT, /* (signed) int */
|
||||
UINT, /* unsigned int */
|
||||
LONG, /* (signed) long */
|
||||
ULONG, /* unsigned long */
|
||||
QUAD, /* (signed) long long */
|
||||
UQUAD, /* unsigned long long */
|
||||
FLOAT, /* float */
|
||||
DOUBLE, /* double or, with tflag, long float */
|
||||
LDOUBLE, /* long double */
|
||||
VOID, /* void */
|
||||
STRUCT, /* structure tag */
|
||||
UNION, /* union tag */
|
||||
ENUM, /* enum tag */
|
||||
PTR, /* pointer */
|
||||
ARRAY, /* array */
|
||||
FUNC, /* function */
|
||||
NTSPEC
|
||||
} tspec_t;
|
||||
|
||||
/*
|
||||
* size of types, name and classification
|
||||
*/
|
||||
typedef struct {
|
||||
int tt_sz; /* size in bits */
|
||||
int tt_psz; /* size, different from tt_sz
|
||||
if pflag is set */
|
||||
tspec_t tt_styp; /* signed counterpart */
|
||||
tspec_t tt_utyp; /* unsigned counterpart */
|
||||
u_int tt_isityp : 1; /* 1 if integer type */
|
||||
u_int tt_isutyp : 1; /* 1 if unsigned integer type */
|
||||
u_int tt_isftyp : 1; /* 1 if floating point type */
|
||||
u_int tt_isatyp : 1; /* 1 if arithmetic type */
|
||||
u_int tt_issclt : 1; /* 1 if scalar type */
|
||||
const char *tt_name; /* Bezeichnung des Typs */
|
||||
} ttab_t;
|
||||
|
||||
#define size(t) (ttab[t].tt_sz)
|
||||
#define psize(t) (ttab[t].tt_psz)
|
||||
#define styp(t) (ttab[t].tt_styp)
|
||||
#define utyp(t) (ttab[t].tt_utyp)
|
||||
#define isityp(t) (ttab[t].tt_isityp)
|
||||
#define isutyp(t) (ttab[t].tt_isutyp)
|
||||
#define isftyp(t) (ttab[t].tt_isftyp)
|
||||
#define isatyp(t) (ttab[t].tt_isatyp)
|
||||
#define issclt(t) (ttab[t].tt_issclt)
|
||||
|
||||
extern ttab_t ttab[];
|
||||
|
||||
|
||||
typedef enum {
|
||||
NODECL, /* until now not declared */
|
||||
DECL, /* declared */
|
||||
TDEF, /* tentative defined */
|
||||
DEF /* defined */
|
||||
} def_t;
|
||||
|
||||
/*
|
||||
* Following structure contains some data used for the output buffer.
|
||||
*/
|
||||
typedef struct ob {
|
||||
char *o_buf; /* buffer */
|
||||
char *o_end; /* first byte after buffer */
|
||||
size_t o_len; /* length of buffer */
|
||||
char *o_nxt; /* next free byte in buffer */
|
||||
} ob_t;
|
||||
|
||||
#include "externs.h"
|
@ -1,59 +0,0 @@
|
||||
/* $NetBSD: lp64.h,v 1.1 2002/01/18 20:39:23 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the NetBSD Project by
|
||||
* Wasabi Systems, Inc.
|
||||
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Type sizes for LP64 platforms (long, pointer: 64-bit)
|
||||
*/
|
||||
|
||||
#define CHAR_SIZE (CHAR_BIT)
|
||||
#define SHORT_SIZE (2 * CHAR_BIT)
|
||||
#define INT_SIZE (4 * CHAR_BIT)
|
||||
#define LONG_SIZE (8 * CHAR_BIT)
|
||||
#define QUAD_SIZE (8 * CHAR_BIT)
|
||||
#define PTR_SIZE (8 * CHAR_BIT)
|
||||
|
||||
#define TARG_INT_MAX ((int32_t) (((uint32_t) -1) >> 1))
|
||||
#define TARG_INT_MIN ((-TARG_INT_MAX) - 1)
|
||||
#define TARG_UINT_MAX ((uint32_t) -1)
|
||||
|
||||
#define TARG_QUAD_MAX ((int64_t) (((uint64_t) -1) >> 1))
|
||||
#define TARG_QUAD_MIN ((-TARG_QUAD_MAX) - 1)
|
||||
#define TARG_UQUAD_MAX ((uint64_t) -1)
|
||||
|
||||
#define TARG_LONG_MAX TARG_QUAD_MAX
|
||||
#define TARG_LONG_MIN TARG_QUAD_MIN
|
||||
#define TARG_ULONG_MAX TARG_UQUAD_MAX
|
@ -1,93 +0,0 @@
|
||||
/* $NetBSD: mem.c,v 1.4 2003/10/16 06:35:26 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: mem.c,v 1.4 2003/10/16 06:35:26 itojun Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lint.h"
|
||||
|
||||
void *
|
||||
xmalloc(size_t s)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if ((p = malloc(s)) == NULL)
|
||||
nomem();
|
||||
return (p);
|
||||
}
|
||||
|
||||
void *
|
||||
xcalloc(size_t n, size_t s)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if ((p = calloc(n, s)) == NULL)
|
||||
nomem();
|
||||
return (p);
|
||||
}
|
||||
|
||||
void *
|
||||
xrealloc(void *p, size_t s)
|
||||
{
|
||||
void *n;
|
||||
|
||||
if ((n = realloc(p, s)) == NULL) {
|
||||
free(p);
|
||||
nomem();
|
||||
}
|
||||
p = n;
|
||||
return (p);
|
||||
}
|
||||
|
||||
char *
|
||||
xstrdup(const char *s)
|
||||
{
|
||||
char *s2;
|
||||
|
||||
if ((s2 = strdup(s)) == NULL)
|
||||
nomem();
|
||||
return (s2);
|
||||
}
|
||||
|
||||
void
|
||||
nomem(void)
|
||||
{
|
||||
|
||||
errx(1, "virtual memory exhausted");
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/* $NetBSD: param.h,v 1.2 2002/02/05 03:04:26 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Minimun size of string buffer. If this is not enough, the buffer
|
||||
* is enlarged in steps of STRBLEN bytes.
|
||||
*/
|
||||
#define STRBLEN 256
|
||||
|
||||
/*
|
||||
* This defines the size of memory blocks which are used to allocate
|
||||
* memory in larger chunks.
|
||||
*/
|
||||
#define MBLKSIZ ((size_t)0x4000)
|
||||
|
||||
/*
|
||||
* Sizes of hash tables
|
||||
* Should be a prime. Possible primes are
|
||||
* 307, 401, 503, 601, 701, 809, 907, 1009, 1103, 1201, 1301, 1409, 1511.
|
||||
*
|
||||
* HSHSIZ1 symbol table 1st pass
|
||||
* HSHSIZ2 symbol table 2nd pass
|
||||
* THSHSIZ2 type table 2nd pass
|
||||
*/
|
||||
#define HSHSIZ1 503
|
||||
#define HSHSIZ2 1009
|
||||
#define THSHSIZ2 1009
|
||||
|
||||
/*
|
||||
* Pull in target-specific parameters.
|
||||
*/
|
||||
#include "targparam.h"
|
||||
|
||||
/*
|
||||
* Make sure this matches wchar_t.
|
||||
*/
|
||||
#define WCHAR INT
|
||||
|
||||
/*
|
||||
* And the sparc64 long double code generation is broken.
|
||||
*/
|
||||
#if !defined(__sparc64__)
|
||||
typedef long double ldbl_t;
|
||||
#else
|
||||
typedef double ldbl_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some traditional compilers are not able to assign structures.
|
||||
*/
|
||||
#define STRUCT_ASSIGN(dest, src) (dest) = (src)
|
@ -1,21 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.3 1995/07/04 01:53:05 cgd Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= lint1
|
||||
SRCS= cgram.y scan.l mem1.c mem.c err.c main1.c decl.c tree.c func.c \
|
||||
init.c emit.c emit1.c inittyp.c
|
||||
MAN= lint.7
|
||||
CLEANFILES= lint.7
|
||||
|
||||
LIBADD= l m
|
||||
CFLAGS+= -I. -I${.CURDIR}
|
||||
LINTFLAGS=-aehpz
|
||||
|
||||
BINDIR= ${LIBEXECDIR}
|
||||
|
||||
.PATH: ${.CURDIR}/../common
|
||||
|
||||
lint.7: makeman
|
||||
sh ${.CURDIR}/makeman ${DESTDIR}${BINDIR}/${PROG} -m >${.TARGET}
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,20 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
lib/msun \
|
||||
usr.bin/lex/lib \
|
||||
usr.bin/yacc.host \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,243 +0,0 @@
|
||||
/* $NetBSD: emit.c,v 1.2 1995/07/03 21:24:00 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: emit.c,v 1.2 1995/07/03 21:24:00 cgd Exp $";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "lint.h"
|
||||
|
||||
/* name and handle of output file */
|
||||
static const char *loname;
|
||||
static FILE *lout;
|
||||
|
||||
/* output buffer data */
|
||||
ob_t ob;
|
||||
|
||||
static void outxbuf(void);
|
||||
|
||||
|
||||
/*
|
||||
* initialize output
|
||||
*/
|
||||
void
|
||||
outopen(name)
|
||||
const char *name;
|
||||
{
|
||||
loname = name;
|
||||
|
||||
/* Ausgabedatei oeffnen */
|
||||
if ((lout = fopen(name, "w")) == NULL)
|
||||
err(1, "cannot open '%s'", name);
|
||||
|
||||
/* Ausgabepuffer anlegen */
|
||||
ob.o_len = 1024;
|
||||
ob.o_end = (ob.o_buf = ob.o_nxt = xmalloc(ob.o_len)) + ob.o_len;
|
||||
}
|
||||
|
||||
/*
|
||||
* flush output buffer and close file
|
||||
*/
|
||||
void
|
||||
outclose()
|
||||
{
|
||||
outclr();
|
||||
if (fclose(lout) == EOF)
|
||||
err(1, "cannot close '%s'", loname);
|
||||
}
|
||||
|
||||
/*
|
||||
* resize output buffer
|
||||
*/
|
||||
static void
|
||||
outxbuf()
|
||||
{
|
||||
ptrdiff_t coffs;
|
||||
|
||||
coffs = ob.o_nxt - ob.o_buf;
|
||||
ob.o_len *= 2;
|
||||
ob.o_end = (ob.o_buf = xrealloc(ob.o_buf, ob.o_len)) + ob.o_len;
|
||||
ob.o_nxt = ob.o_buf + coffs;
|
||||
}
|
||||
|
||||
/*
|
||||
* reset output buffer
|
||||
* if it is not empty, it is flushed
|
||||
*/
|
||||
void
|
||||
outclr()
|
||||
{
|
||||
size_t sz;
|
||||
|
||||
if (ob.o_buf != ob.o_nxt) {
|
||||
outchar('\n');
|
||||
sz = ob.o_nxt - ob.o_buf;
|
||||
if (sz > ob.o_len)
|
||||
errx(1, "internal error: outclr() 1");
|
||||
if (fwrite(ob.o_buf, sz, 1, lout) != 1)
|
||||
err(1, "cannot write to %s", loname);
|
||||
ob.o_nxt = ob.o_buf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write a character to the output buffer
|
||||
*/
|
||||
void
|
||||
outchar(c)
|
||||
int c;
|
||||
{
|
||||
if (ob.o_nxt == ob.o_end)
|
||||
outxbuf();
|
||||
*ob.o_nxt++ = (char)c;
|
||||
}
|
||||
|
||||
/*
|
||||
* write a character to the output buffer, qouted if necessary
|
||||
*/
|
||||
void
|
||||
outqchar(c)
|
||||
int c;
|
||||
{
|
||||
if (isprint(c) && c != '\\' && c != '"' && c != '\'') {
|
||||
outchar(c);
|
||||
} else {
|
||||
outchar('\\');
|
||||
switch (c) {
|
||||
case '\\':
|
||||
outchar('\\');
|
||||
break;
|
||||
case '"':
|
||||
outchar('"');
|
||||
break;
|
||||
case '\'':
|
||||
outchar('\'');
|
||||
break;
|
||||
case '\b':
|
||||
outchar('b');
|
||||
break;
|
||||
case '\t':
|
||||
outchar('t');
|
||||
break;
|
||||
case '\n':
|
||||
outchar('n');
|
||||
break;
|
||||
case '\f':
|
||||
outchar('f');
|
||||
break;
|
||||
case '\r':
|
||||
outchar('r');
|
||||
break;
|
||||
#ifdef __STDC__
|
||||
case '\v':
|
||||
#else
|
||||
case '\013':
|
||||
#endif
|
||||
outchar('v');
|
||||
break;
|
||||
#ifdef __STDC__
|
||||
case '\a':
|
||||
#else
|
||||
case '\007':
|
||||
#endif
|
||||
outchar('a');
|
||||
break;
|
||||
default:
|
||||
outchar((((u_int)c >> 6) & 07) + '0');
|
||||
outchar((((u_int)c >> 3) & 07) + '0');
|
||||
outchar((c & 07) + '0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write a strint to the output buffer
|
||||
* the string must not contain any characters which
|
||||
* should be quoted
|
||||
*/
|
||||
void
|
||||
outstrg(s)
|
||||
const char *s;
|
||||
{
|
||||
while (*s != '\0') {
|
||||
if (ob.o_nxt == ob.o_end)
|
||||
outxbuf();
|
||||
*ob.o_nxt++ = *s++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write an integer value to toe output buffer
|
||||
*/
|
||||
void
|
||||
outint(i)
|
||||
int i;
|
||||
{
|
||||
if ((ob.o_end - ob.o_nxt) < 3 * sizeof (int))
|
||||
outxbuf();
|
||||
ob.o_nxt += sprintf(ob.o_nxt, "%d", i);
|
||||
}
|
||||
|
||||
/*
|
||||
* write the name of a symbol to the output buffer
|
||||
* the name is preceded by its length
|
||||
*/
|
||||
void
|
||||
outname(name)
|
||||
const char *name;
|
||||
{
|
||||
if (name == NULL)
|
||||
errx(1, "internal error: outname() 1");
|
||||
outint((int)strlen(name));
|
||||
outstrg(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* write the name of the .c source
|
||||
*/
|
||||
void
|
||||
outsrc(name)
|
||||
const char *name;
|
||||
{
|
||||
outclr();
|
||||
outchar('S');
|
||||
outstrg(name);
|
||||
}
|
@ -1,601 +0,0 @@
|
||||
/* $NetBSD: emit1.c,v 1.14 2004/06/20 22:20:16 jmc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: emit1.c,v 1.14 2004/06/20 22:20:16 jmc Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "lint1.h"
|
||||
|
||||
static void outtt(sym_t *, sym_t *);
|
||||
static void outfstrg(strg_t *);
|
||||
|
||||
/*
|
||||
* Write type into the output buffer.
|
||||
* The type is written as a sequence of substrings, each of which describes a
|
||||
* node of type type_t
|
||||
* a node is coded as follows:
|
||||
* char C
|
||||
* signed char s C
|
||||
* unsigned char u C
|
||||
* short S
|
||||
* unsigned short u S
|
||||
* int I
|
||||
* unsigned int u I
|
||||
* long L
|
||||
* unsigned long u L
|
||||
* long long Q
|
||||
* unsigned long long u Q
|
||||
* float s D
|
||||
* double D
|
||||
* long double l D
|
||||
* void V
|
||||
* * P
|
||||
* [n] A n
|
||||
* () F
|
||||
* (void) F 0
|
||||
* (n arguments) F n arg1 arg2 ... argn
|
||||
* (n arguments, ...) F n arg1 arg2 ... argn-1 E
|
||||
* (a, b, c, ...) f n arg1 arg2 ...
|
||||
* enum tag e T tag_or_typename
|
||||
* struct tag s T tag_or_typename
|
||||
* union tag u T tag_or_typename
|
||||
*
|
||||
* tag_or_typename 0 no tag or type name
|
||||
* 1 n tag Tag
|
||||
* 2 n typename only type name
|
||||
*
|
||||
* spaces are only for better readability
|
||||
* additionally it is possible to prepend the characters 'c' (for const)
|
||||
* and 'v' (for volatile)
|
||||
*/
|
||||
void
|
||||
outtype(type_t *tp)
|
||||
{
|
||||
int t, s, na;
|
||||
sym_t *arg;
|
||||
tspec_t ts;
|
||||
|
||||
while (tp != NULL) {
|
||||
if ((ts = tp->t_tspec) == INT && tp->t_isenum)
|
||||
ts = ENUM;
|
||||
switch (ts) {
|
||||
case CHAR: t = 'C'; s = '\0'; break;
|
||||
case SCHAR: t = 'C'; s = 's'; break;
|
||||
case UCHAR: t = 'C'; s = 'u'; break;
|
||||
case SHORT: t = 'S'; s = '\0'; break;
|
||||
case USHORT: t = 'S'; s = 'u'; break;
|
||||
case INT: t = 'I'; s = '\0'; break;
|
||||
case UINT: t = 'I'; s = 'u'; break;
|
||||
case LONG: t = 'L'; s = '\0'; break;
|
||||
case ULONG: t = 'L'; s = 'u'; break;
|
||||
case QUAD: t = 'Q'; s = '\0'; break;
|
||||
case UQUAD: t = 'Q'; s = 'u'; break;
|
||||
case FLOAT: t = 'D'; s = 's'; break;
|
||||
case DOUBLE: t = 'D'; s = '\0'; break;
|
||||
case LDOUBLE: t = 'D'; s = 'l'; break;
|
||||
case VOID: t = 'V'; s = '\0'; break;
|
||||
case PTR: t = 'P'; s = '\0'; break;
|
||||
case ARRAY: t = 'A'; s = '\0'; break;
|
||||
case FUNC: t = 'F'; s = '\0'; break;
|
||||
case ENUM: t = 'T'; s = 'e'; break;
|
||||
case STRUCT: t = 'T'; s = 's'; break;
|
||||
case UNION: t = 'T'; s = 'u'; break;
|
||||
default:
|
||||
LERROR("outtyp()");
|
||||
}
|
||||
if (tp->t_const)
|
||||
outchar('c');
|
||||
if (tp->t_volatile)
|
||||
outchar('v');
|
||||
if (s != '\0')
|
||||
outchar(s);
|
||||
outchar(t);
|
||||
if (ts == ARRAY) {
|
||||
outint(tp->t_dim);
|
||||
} else if (ts == ENUM) {
|
||||
outtt(tp->t_enum->etag, tp->t_enum->etdef);
|
||||
} else if (ts == STRUCT || ts == UNION) {
|
||||
outtt(tp->t_str->stag, tp->t_str->stdef);
|
||||
} else if (ts == FUNC && tp->t_proto) {
|
||||
na = 0;
|
||||
for (arg = tp->t_args; arg != NULL; arg = arg->s_nxt)
|
||||
na++;
|
||||
if (tp->t_vararg)
|
||||
na++;
|
||||
outint(na);
|
||||
for (arg = tp->t_args; arg != NULL; arg = arg->s_nxt)
|
||||
outtype(arg->s_type);
|
||||
if (tp->t_vararg)
|
||||
outchar('E');
|
||||
}
|
||||
tp = tp->t_subt;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* type to string
|
||||
* used for debugging output
|
||||
*
|
||||
* it uses its own output buffer for conversion
|
||||
*/
|
||||
const char *
|
||||
ttos(type_t *tp)
|
||||
{
|
||||
static ob_t tob;
|
||||
ob_t tmp;
|
||||
|
||||
if (tob.o_buf == NULL) {
|
||||
tob.o_len = 64;
|
||||
tob.o_buf = tob.o_nxt = xmalloc(tob.o_len);
|
||||
tob.o_end = tob.o_buf + tob.o_len;
|
||||
}
|
||||
|
||||
tmp = ob;
|
||||
ob = tob;
|
||||
ob.o_nxt = ob.o_buf;
|
||||
outtype(tp);
|
||||
outchar('\0');
|
||||
tob = ob;
|
||||
ob = tmp;
|
||||
|
||||
return (tob.o_buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* write the name of a tag or typename
|
||||
*
|
||||
* if the tag is named, the name of the
|
||||
* tag is written, otherwise, if a typename exists which
|
||||
* refers to this tag, this typename is written
|
||||
*/
|
||||
static void
|
||||
outtt(sym_t *tag, sym_t *tdef)
|
||||
{
|
||||
|
||||
/*
|
||||
* 0 is no longer used.
|
||||
*/
|
||||
if (tag->s_name != unnamed) {
|
||||
outint(1);
|
||||
outname(tag->s_name);
|
||||
} else if (tdef != NULL) {
|
||||
outint(2);
|
||||
outname(tdef->s_name);
|
||||
} else {
|
||||
outint(3);
|
||||
outint(tag->s_dpos.p_line);
|
||||
outchar('.');
|
||||
outint(getfnid(tag->s_dpos.p_file));
|
||||
outchar('.');
|
||||
outint(tag->s_dpos.p_uniq);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write information about a global declared/defined symbol
|
||||
* with storage class extern
|
||||
*
|
||||
* informations about function definitions are written in outfdef(),
|
||||
* not here
|
||||
*/
|
||||
void
|
||||
outsym(sym_t *sym, scl_t sc, def_t def)
|
||||
{
|
||||
|
||||
/*
|
||||
* Static function declarations must also be written to the output
|
||||
* file. Compatibility of function declarations (for both static
|
||||
* and extern functions) must be checked in lint2. Lint1 can't do
|
||||
* this, especially not, if functions are declared at block level
|
||||
* before their first declaration at level 0.
|
||||
*/
|
||||
if (sc != EXTERN && !(sc == STATIC && sym->s_type->t_tspec == FUNC))
|
||||
return;
|
||||
|
||||
/* reset buffer */
|
||||
outclr();
|
||||
|
||||
/*
|
||||
* line number of .c source, 'd' for declaration, Id of current
|
||||
* source (.c or .h), and line in current source.
|
||||
*/
|
||||
outint(csrc_pos.p_line);
|
||||
outchar('d');
|
||||
outint(getfnid(sym->s_dpos.p_file));
|
||||
outchar('.');
|
||||
outint(sym->s_dpos.p_line);
|
||||
|
||||
/* flags */
|
||||
|
||||
switch (def) {
|
||||
case DEF:
|
||||
/* defined */
|
||||
outchar('d');
|
||||
break;
|
||||
case TDEF:
|
||||
/* tentative defined */
|
||||
outchar('t');
|
||||
break;
|
||||
case DECL:
|
||||
/* declared */
|
||||
outchar('e');
|
||||
break;
|
||||
default:
|
||||
LERROR("outsym()");
|
||||
}
|
||||
if (llibflg && def != DECL) {
|
||||
/*
|
||||
* mark it as used so we get no warnings from lint2 about
|
||||
* unused symbols in libraries.
|
||||
*/
|
||||
outchar('u');
|
||||
}
|
||||
|
||||
if (sc == STATIC)
|
||||
outchar('s');
|
||||
|
||||
/* name of the symbol */
|
||||
outname(sym->s_name);
|
||||
|
||||
/* renamed name of symbol, if necessary */
|
||||
if (sym->s_rename) {
|
||||
outchar('r');
|
||||
outname(sym->s_rename);
|
||||
}
|
||||
|
||||
/* type of the symbol */
|
||||
outtype(sym->s_type);
|
||||
}
|
||||
|
||||
/*
|
||||
* write information about function definition
|
||||
*
|
||||
* this is also done for static functions so we are able to check if
|
||||
* they are called with proper argument types
|
||||
*/
|
||||
void
|
||||
outfdef(sym_t *fsym, pos_t *posp, int rval, int osdef, sym_t *args)
|
||||
{
|
||||
int narg;
|
||||
sym_t *arg;
|
||||
|
||||
/* reset the buffer */
|
||||
outclr();
|
||||
|
||||
/*
|
||||
* line number of .c source, 'd' for declaration, Id of current
|
||||
* source (.c or .h), and line in current source
|
||||
*
|
||||
* we are already at the end of the function. If we are in the
|
||||
* .c source, posp->p_line is correct, otherwise csrc_pos.p_line
|
||||
* (for functions defined in header files).
|
||||
*/
|
||||
if (posp->p_file == csrc_pos.p_file) {
|
||||
outint(posp->p_line);
|
||||
} else {
|
||||
outint(csrc_pos.p_line);
|
||||
}
|
||||
outchar('d');
|
||||
outint(getfnid(posp->p_file));
|
||||
outchar('.');
|
||||
outint(posp->p_line);
|
||||
|
||||
/* flags */
|
||||
|
||||
/* both SCANFLIKE and PRINTFLIKE imply VARARGS */
|
||||
if (prflstrg != -1) {
|
||||
nvararg = prflstrg;
|
||||
} else if (scflstrg != -1) {
|
||||
nvararg = scflstrg;
|
||||
}
|
||||
|
||||
if (nvararg != -1) {
|
||||
outchar('v');
|
||||
outint(nvararg);
|
||||
}
|
||||
if (scflstrg != -1) {
|
||||
outchar('S');
|
||||
outint(scflstrg);
|
||||
}
|
||||
if (prflstrg != -1) {
|
||||
outchar('P');
|
||||
outint(prflstrg);
|
||||
}
|
||||
nvararg = prflstrg = scflstrg = -1;
|
||||
|
||||
outchar('d');
|
||||
|
||||
if (rval)
|
||||
/* has return value */
|
||||
outchar('r');
|
||||
|
||||
if (llibflg)
|
||||
/*
|
||||
* mark it as used so lint2 does not complain about
|
||||
* unused symbols in libraries
|
||||
*/
|
||||
outchar('u');
|
||||
|
||||
if (osdef)
|
||||
/* old style function definition */
|
||||
outchar('o');
|
||||
|
||||
if (fsym->s_scl == STATIC)
|
||||
outchar('s');
|
||||
|
||||
/* name of function */
|
||||
outname(fsym->s_name);
|
||||
|
||||
/* renamed name of function, if necessary */
|
||||
if (fsym->s_rename) {
|
||||
outchar('r');
|
||||
outname(fsym->s_rename);
|
||||
}
|
||||
|
||||
/* argument types and return value */
|
||||
if (osdef) {
|
||||
narg = 0;
|
||||
for (arg = args; arg != NULL; arg = arg->s_nxt)
|
||||
narg++;
|
||||
outchar('f');
|
||||
outint(narg);
|
||||
for (arg = args; arg != NULL; arg = arg->s_nxt)
|
||||
outtype(arg->s_type);
|
||||
outtype(fsym->s_type->t_subt);
|
||||
} else {
|
||||
outtype(fsym->s_type);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write out all information necessary for lint2 to check function
|
||||
* calls
|
||||
*
|
||||
* rvused is set if the return value is used (asigned to a variable)
|
||||
* rvdisc is set if the return value is not used and not ignored
|
||||
* (casted to void)
|
||||
*/
|
||||
void
|
||||
outcall(tnode_t *tn, int rvused, int rvdisc)
|
||||
{
|
||||
tnode_t *args, *arg;
|
||||
int narg, n, i;
|
||||
int64_t q;
|
||||
tspec_t t;
|
||||
|
||||
/* reset buffer */
|
||||
outclr();
|
||||
|
||||
/*
|
||||
* line number of .c source, 'c' for function call, Id of current
|
||||
* source (.c or .h), and line in current source
|
||||
*/
|
||||
outint(csrc_pos.p_line);
|
||||
outchar('c');
|
||||
outint(getfnid(curr_pos.p_file));
|
||||
outchar('.');
|
||||
outint(curr_pos.p_line);
|
||||
|
||||
/*
|
||||
* flags; 'u' and 'i' must be last to make sure a letter
|
||||
* is between the numeric argument of a flag and the name of
|
||||
* the function
|
||||
*/
|
||||
narg = 0;
|
||||
args = tn->tn_right;
|
||||
for (arg = args; arg != NULL; arg = arg->tn_right)
|
||||
narg++;
|
||||
/* informations about arguments */
|
||||
for (n = 1; n <= narg; n++) {
|
||||
/* the last argument is the top one in the tree */
|
||||
for (i = narg, arg = args; i > n; i--, arg = arg->tn_right)
|
||||
continue;
|
||||
arg = arg->tn_left;
|
||||
if (arg->tn_op == CON) {
|
||||
if (isityp(t = arg->tn_type->t_tspec)) {
|
||||
/*
|
||||
* XXX it would probably be better to
|
||||
* explizitly test the sign
|
||||
*/
|
||||
if ((q = arg->tn_val->v_quad) == 0) {
|
||||
/* zero constant */
|
||||
outchar('z');
|
||||
} else if (msb(q, t, 0) == 0) {
|
||||
/* positive if casted to signed */
|
||||
outchar('p');
|
||||
} else {
|
||||
/* negative if casted to signed */
|
||||
outchar('n');
|
||||
}
|
||||
outint(n);
|
||||
}
|
||||
} else if (arg->tn_op == AMPER &&
|
||||
arg->tn_left->tn_op == STRING &&
|
||||
arg->tn_left->tn_strg->st_tspec == CHAR) {
|
||||
/* constant string, write all format specifiers */
|
||||
outchar('s');
|
||||
outint(n);
|
||||
outfstrg(arg->tn_left->tn_strg);
|
||||
}
|
||||
|
||||
}
|
||||
/* return value discarded/used/ignored */
|
||||
outchar(rvdisc ? 'd' : (rvused ? 'u' : 'i'));
|
||||
|
||||
/* name of the called function */
|
||||
outname(tn->tn_left->tn_left->tn_sym->s_name);
|
||||
|
||||
/* types of arguments */
|
||||
outchar('f');
|
||||
outint(narg);
|
||||
for (n = 1; n <= narg; n++) {
|
||||
/* the last argument is the top one in the tree */
|
||||
for (i = narg, arg = args; i > n; i--, arg = arg->tn_right)
|
||||
continue;
|
||||
outtype(arg->tn_left->tn_type);
|
||||
}
|
||||
/* expected type of return value */
|
||||
outtype(tn->tn_type);
|
||||
}
|
||||
|
||||
/*
|
||||
* extracts potential format specifiers for printf() and scanf() and
|
||||
* writes them, enclosed in "" and qouted if necessary, to the output buffer
|
||||
*/
|
||||
static void
|
||||
outfstrg(strg_t *strg)
|
||||
{
|
||||
int c, oc, first;
|
||||
u_char *cp;
|
||||
|
||||
if (strg->st_tspec != CHAR)
|
||||
LERROR("outfstrg()");
|
||||
|
||||
cp = strg->st_cp;
|
||||
|
||||
outchar('"');
|
||||
|
||||
c = *cp++;
|
||||
|
||||
while (c != '\0') {
|
||||
|
||||
if (c != '%') {
|
||||
c = *cp++;
|
||||
continue;
|
||||
}
|
||||
|
||||
outqchar('%');
|
||||
c = *cp++;
|
||||
|
||||
/* flags for printf and scanf and *-fieldwidth for printf */
|
||||
while (c != '\0' && (c == '-' || c == '+' || c == ' ' ||
|
||||
c == '#' || c == '0' || c == '*')) {
|
||||
outqchar(c);
|
||||
c = *cp++;
|
||||
}
|
||||
|
||||
/* numeric field width */
|
||||
while (c != '\0' && isdigit(c)) {
|
||||
outqchar(c);
|
||||
c = *cp++;
|
||||
}
|
||||
|
||||
/* precision for printf */
|
||||
if (c == '.') {
|
||||
outqchar(c);
|
||||
if ((c = *cp++) == '*') {
|
||||
outqchar(c);
|
||||
c = *cp++;
|
||||
} else {
|
||||
while (c != '\0' && isdigit(c)) {
|
||||
outqchar(c);
|
||||
c = *cp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* h, l, L and q flags fpr printf and scanf */
|
||||
if (c == 'h' || c == 'l' || c == 'L' || c == 'q') {
|
||||
outqchar(c);
|
||||
c = *cp++;
|
||||
}
|
||||
|
||||
/*
|
||||
* The last character. It is always written so we can detect
|
||||
* invalid format specifiers.
|
||||
*/
|
||||
if (c != '\0') {
|
||||
outqchar(c);
|
||||
oc = c;
|
||||
c = *cp++;
|
||||
/*
|
||||
* handle [ for scanf. [-] means that a minus sign
|
||||
* was found at an undefined position.
|
||||
*/
|
||||
if (oc == '[') {
|
||||
if (c == '^')
|
||||
c = *cp++;
|
||||
if (c == ']')
|
||||
c = *cp++;
|
||||
first = 1;
|
||||
while (c != '\0' && c != ']') {
|
||||
if (c == '-') {
|
||||
if (!first && *cp != ']')
|
||||
outqchar(c);
|
||||
}
|
||||
first = 0;
|
||||
c = *cp++;
|
||||
}
|
||||
if (c == ']') {
|
||||
outqchar(c);
|
||||
c = *cp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
outchar('"');
|
||||
}
|
||||
|
||||
/*
|
||||
* writes a record if sym was used
|
||||
*/
|
||||
void
|
||||
outusg(sym_t *sym)
|
||||
{
|
||||
/* reset buffer */
|
||||
outclr();
|
||||
|
||||
/*
|
||||
* line number of .c source, 'u' for used, Id of current
|
||||
* source (.c or .h), and line in current source
|
||||
*/
|
||||
outint(csrc_pos.p_line);
|
||||
outchar('u');
|
||||
outint(getfnid(curr_pos.p_file));
|
||||
outchar('.');
|
||||
outint(curr_pos.p_line);
|
||||
|
||||
/* necessary to delimit both numbers */
|
||||
outchar('x');
|
||||
|
||||
/* Den Namen des Symbols ausgeben */
|
||||
outname(sym->s_name);
|
||||
}
|
@ -1,552 +0,0 @@
|
||||
/* $NetBSD: err.c,v 1.40 2009/04/15 01:20:57 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: err.c,v 1.40 2009/04/15 01:20:57 christos Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "lint1.h"
|
||||
|
||||
/* number of errors found */
|
||||
int nerr;
|
||||
|
||||
/* number of syntax errors */
|
||||
int sytxerr;
|
||||
|
||||
|
||||
static const char *lbasename(const char *);
|
||||
static void verror(int, va_list);
|
||||
static void vwarning(int, va_list);
|
||||
|
||||
|
||||
const char *msgs[] = {
|
||||
"syntax error: empty declaration", /* 0 */
|
||||
"old style declaration; add int", /* 1 */
|
||||
"empty declaration", /* 2 */
|
||||
"%s declared in argument declaration list", /* 3 */
|
||||
"illegal type combination", /* 4 */
|
||||
"modifying typedef with '%s'; only qualifiers allowed", /* 5 */
|
||||
"use 'double' instead of 'long float'", /* 6 */
|
||||
"only one storage class allowed", /* 7 */
|
||||
"illegal storage class", /* 8 */
|
||||
"only register valid as formal parameter storage class", /* 9 */
|
||||
"duplicate '%s'", /* 10 */
|
||||
"bit-field initializer out of range", /* 11 */
|
||||
"compiler takes size of function", /* 12 */
|
||||
"incomplete enum type: %s", /* 13 */
|
||||
"compiler takes alignment of function", /* 14 */
|
||||
"function returns illegal type", /* 15 */
|
||||
"array of function is illegal", /* 16 */
|
||||
"null dimension", /* 17 */
|
||||
"illegal use of 'void'", /* 18 */
|
||||
"void type for %s", /* 19 */
|
||||
"negative array dimension (%d)", /* 20 */
|
||||
"redeclaration of formal parameter %s", /* 21 */
|
||||
"incomplete or misplaced function definition", /* 22 */
|
||||
"undefined label %s", /* 23 */
|
||||
"cannot initialize function: %s", /* 24 */
|
||||
"cannot initialize typedef: %s", /* 25 */
|
||||
"cannot initialize extern declaration: %s", /* 26 */
|
||||
"redeclaration of %s", /* 27 */
|
||||
"redefinition of %s", /* 28 */
|
||||
"previously declared extern, becomes static: %s", /* 29 */
|
||||
"redeclaration of %s; ANSI C requires static", /* 30 */
|
||||
"incomplete structure or union %s: %s", /* 31 */
|
||||
"argument type defaults to 'int': %s", /* 32 */
|
||||
"duplicate member name: %s", /* 33 */
|
||||
"nonportable bit-field type", /* 34 */
|
||||
"illegal bit-field type", /* 35 */
|
||||
"illegal bit-field size", /* 36 */
|
||||
"zero size bit-field", /* 37 */
|
||||
"function illegal in structure or union", /* 38 */
|
||||
"zero sized array in struct is a C99 extension: %s", /* 39 */
|
||||
"unknown size: %s", /* 40 */
|
||||
"illegal use of bit-field", /* 41 */
|
||||
"forward reference to enum type", /* 42 */
|
||||
"redefinition hides earlier one: %s", /* 43 */
|
||||
"declaration introduces new type in ANSI C: %s %s", /* 44 */
|
||||
"base type is really '%s %s'", /* 45 */
|
||||
"(%s) tag redeclared", /* 46 */
|
||||
"zero sized %s is a C9X feature", /* 47 */
|
||||
"overflow in enumeration values: %s", /* 48 */
|
||||
"struct or union member must be named", /* 49 */
|
||||
"a function is declared as an argument: %s", /* 50 */
|
||||
"parameter mismatch: %d declared, %d defined", /* 51 */
|
||||
"cannot initialize parameter: %s", /* 52 */
|
||||
"declared argument %s is missing", /* 53 */
|
||||
"trailing ',' prohibited in enum declaration", /* 54 */
|
||||
"integral constant expression expected", /* 55 */
|
||||
"integral constant too large", /* 56 */
|
||||
"enumeration constant hides parameter: %s", /* 57 */
|
||||
"type does not match prototype: %s", /* 58 */
|
||||
"formal parameter lacks name: param #%d", /* 59 */
|
||||
"void must be sole parameter", /* 60 */
|
||||
"void parameter cannot have name: %s", /* 61 */
|
||||
"function prototype parameters must have types", /* 62 */
|
||||
"prototype does not match old-style definition", /* 63 */
|
||||
"()-less function definition", /* 64 */
|
||||
"%s has no named members", /* 65 */
|
||||
"syntax requires ';' after last struct/union member", /* 66 */
|
||||
"cannot return incomplete type", /* 67 */
|
||||
"typedef already qualified with '%s'", /* 68 */
|
||||
"inappropriate qualifiers with 'void'", /* 69 */
|
||||
"%soperand of '%s' is unsigned in ANSI C", /* 70 */
|
||||
"too many characters in character constant", /* 71 */
|
||||
"typedef declares no type name", /* 72 */
|
||||
"empty character constant", /* 73 */
|
||||
"no hex digits follow \\x", /* 74 */
|
||||
"overflow in hex escape", /* 75 */
|
||||
"character escape does not fit in character", /* 76 */
|
||||
"bad octal digit %c", /* 77 */
|
||||
"nonportable character escape", /* 78 */
|
||||
"dubious escape \\%c", /* 79 */
|
||||
"dubious escape \\%o", /* 80 */
|
||||
"\\a undefined in traditional C", /* 81 */
|
||||
"\\x undefined in traditional C", /* 82 */
|
||||
"storage class after type is obsolescent", /* 83 */
|
||||
"ANSI C requires formal parameter before '...'", /* 84 */
|
||||
"dubious tag declaration: %s %s", /* 85 */
|
||||
"automatic hides external declaration: %s", /* 86 */
|
||||
"static hides external declaration: %s", /* 87 */
|
||||
"typedef hides external declaration: %s", /* 88 */
|
||||
"typedef redeclared: %s", /* 89 */
|
||||
"inconsistent redeclaration of extern: %s", /* 90 */
|
||||
"declaration hides parameter: %s", /* 91 */
|
||||
"inconsistent redeclaration of static: %s", /* 92 */
|
||||
"dubious static function at block level: %s", /* 93 */
|
||||
"function has illegal storage class: %s", /* 94 */
|
||||
"declaration hides earlier one: %s", /* 95 */
|
||||
"cannot dereference non-pointer type", /* 96 */
|
||||
"suffix U is illegal in traditional C", /* 97 */
|
||||
"suffixes F and L are illegal in traditional C", /* 98 */
|
||||
"%s undefined", /* 99 */
|
||||
"unary + is illegal in traditional C", /* 100 */
|
||||
"undefined struct/union member: %s", /* 101 */
|
||||
"illegal member use: %s", /* 102 */
|
||||
"left operand of '.' must be struct/union object", /* 103 */
|
||||
"left operand of '->' must be pointer to struct/union", /* 104 */
|
||||
"non-unique member requires struct/union %s", /* 105 */
|
||||
"left operand of '->' must be pointer", /* 106 */
|
||||
"operands of '%s' have incompatible types", /* 107 */
|
||||
"operand of '%s' has incompatible type", /* 108 */
|
||||
"void type illegal in expression", /* 109 */
|
||||
"pointer to function is not allowed here", /* 110 */
|
||||
"unacceptable operand of '%s'", /* 111 */
|
||||
"cannot take address of bit-field", /* 112 */
|
||||
"cannot take address of register %s", /* 113 */
|
||||
"%soperand of '%s' must be lvalue", /* 114 */
|
||||
"%soperand of '%s' must be modifiable lvalue", /* 115 */
|
||||
"illegal pointer subtraction", /* 116 */
|
||||
"bitwise operation on signed value possibly nonportable", /* 117 */
|
||||
"semantics of '%s' change in ANSI C; use explicit cast", /* 118 */
|
||||
"conversion of '%s' to '%s' is out of range", /* 119 */
|
||||
"bitwise operation on signed value nonportable", /* 120 */
|
||||
"negative shift", /* 121 */
|
||||
"shift greater than size of object", /* 122 */
|
||||
"illegal combination of pointer and integer, op %s", /* 123 */
|
||||
"illegal pointer combination, op %s", /* 124 */
|
||||
"ANSI C forbids ordered comparisons of pointers to functions",/* 125 */
|
||||
"incompatible types in conditional", /* 126 */
|
||||
"'&' before array or function: ignored", /* 127 */
|
||||
"operands have incompatible pointer types, op %s", /* 128 */
|
||||
"expression has null effect", /* 129 */
|
||||
"enum type mismatch, op %s", /* 130 */
|
||||
"conversion to '%s' may sign-extend incorrectly", /* 131 */
|
||||
"conversion from '%s' to '%s' may lose accuracy", /* 132 */
|
||||
"conversion of pointer to '%s' loses bits", /* 133 */
|
||||
"conversion of pointer to '%s' may lose bits", /* 134 */
|
||||
"possible pointer alignment problem", /* 135 */
|
||||
"cannot do pointer arithmetic on operand of unknown size", /* 136 */
|
||||
"use of incomplete enum type, op %s", /* 137 */
|
||||
"unknown operand size, op %s", /* 138 */
|
||||
"division by 0", /* 139 */
|
||||
"modulus by 0", /* 140 */
|
||||
"integer overflow detected, op %s", /* 141 */
|
||||
"floating point overflow detected, op %s", /* 142 */
|
||||
"cannot take size of incomplete type", /* 143 */
|
||||
"cannot take size of function", /* 144 */
|
||||
"cannot take size of bit-field", /* 145 */
|
||||
"cannot take size of void", /* 146 */
|
||||
"invalid cast expression", /* 147 */
|
||||
"improper cast of void expression", /* 148 */
|
||||
"illegal function", /* 149 */
|
||||
"argument mismatch: %d arg%s passed, %d expected", /* 150 */
|
||||
"void expressions may not be arguments, arg #%d", /* 151 */
|
||||
"argument cannot have unknown size, arg #%d", /* 152 */
|
||||
"argument has incompatible pointer type, arg #%d", /* 153 */
|
||||
"illegal combination of pointer and integer, arg #%d", /* 154 */
|
||||
"argument is incompatible with prototype, arg #%d", /* 155 */
|
||||
"enum type mismatch, arg #%d", /* 156 */
|
||||
"ANSI C treats constant as unsigned", /* 157 */
|
||||
"%s may be used before set", /* 158 */
|
||||
"assignment in conditional context", /* 159 */
|
||||
"operator '==' found where '=' was expected", /* 160 */
|
||||
"constant in conditional context", /* 161 */
|
||||
"comparison of %s with %s, op %s", /* 162 */
|
||||
"a cast does not yield an lvalue", /* 163 */
|
||||
"assignment of negative constant to unsigned type", /* 164 */
|
||||
"constant truncated by assignment", /* 165 */
|
||||
"precision lost in bit-field assignment", /* 166 */
|
||||
"array subscript cannot be negative: %ld", /* 167 */
|
||||
"array subscript cannot be > %d: %ld", /* 168 */
|
||||
"precedence confusion possible: parenthesize!", /* 169 */
|
||||
"first operand must have scalar type, op ? :", /* 170 */
|
||||
"assignment type mismatch", /* 171 */
|
||||
"too many struct/union initializers", /* 172 */
|
||||
"too many array initializers", /* 173 */
|
||||
"too many initializers", /* 174 */
|
||||
"initialisation of an incomplete type", /* 175 */
|
||||
"invalid initializer type %s", /* 176 */
|
||||
"non-constant initializer", /* 177 */
|
||||
"initializer does not fit", /* 178 */
|
||||
"cannot initialize struct/union with no named member", /* 179 */
|
||||
"bit-field initializer does not fit", /* 180 */
|
||||
"{}-enclosed initializer required", /* 181 */
|
||||
"incompatible pointer types", /* 182 */
|
||||
"illegal combination of pointer and integer", /* 183 */
|
||||
"illegal pointer combination", /* 184 */
|
||||
"initialisation type mismatch", /* 185 */
|
||||
"bit-field initialisation is illegal in traditional C", /* 186 */
|
||||
"non-null byte ignored in string initializer", /* 187 */
|
||||
"no automatic aggregate initialization in traditional C", /* 188 */
|
||||
"assignment of struct/union illegal in traditional C", /* 189 */
|
||||
"empty array declaration: %s", /* 190 */
|
||||
"%s set but not used in function %s", /* 191 */
|
||||
"%s unused in function %s", /* 192 */
|
||||
"statement not reached", /* 193 */
|
||||
"label %s redefined", /* 194 */
|
||||
"case not in switch", /* 195 */
|
||||
"case label affected by conversion", /* 196 */
|
||||
"non-constant case expression", /* 197 */
|
||||
"non-integral case expression", /* 198 */
|
||||
"duplicate case in switch: %ld", /* 199 */
|
||||
"duplicate case in switch: %lu", /* 200 */
|
||||
"default outside switch", /* 201 */
|
||||
"duplicate default in switch", /* 202 */
|
||||
"case label must be of type `int' in traditional C", /* 203 */
|
||||
"controlling expressions must have scalar type", /* 204 */
|
||||
"switch expression must have integral type", /* 205 */
|
||||
"enumeration value(s) not handled in switch", /* 206 */
|
||||
"loop not entered at top", /* 207 */
|
||||
"break outside loop or switch", /* 208 */
|
||||
"continue outside loop", /* 209 */
|
||||
"enum type mismatch in initialisation", /* 210 */
|
||||
"return value type mismatch", /* 211 */
|
||||
"cannot return incomplete type", /* 212 */
|
||||
"void function %s cannot return value", /* 213 */
|
||||
"function %s expects to return value", /* 214 */
|
||||
"function implicitly declared to return int", /* 215 */
|
||||
"function %s has return (e); and return;", /* 216 */
|
||||
"function %s falls off bottom without returning value", /* 217 */
|
||||
"ANSI C treats constant as unsigned, op %s", /* 218 */
|
||||
"concatenated strings are illegal in traditional C", /* 219 */
|
||||
"fallthrough on case statement", /* 220 */
|
||||
"initialisation of unsigned with negative constant", /* 221 */
|
||||
"conversion of negative constant to unsigned type", /* 222 */
|
||||
"end-of-loop code not reached", /* 223 */
|
||||
"cannot recover from previous errors", /* 224 */
|
||||
"static function called but not defined: %s()", /* 225 */
|
||||
"static variable %s unused", /* 226 */
|
||||
"const object %s should have initializer", /* 227 */
|
||||
"function cannot return const or volatile object", /* 228 */
|
||||
"questionable conversion of function pointer", /* 229 */
|
||||
"nonportable character comparison, op %s", /* 230 */
|
||||
"argument %s unused in function %s", /* 231 */
|
||||
"label %s unused in function %s", /* 232 */
|
||||
"struct %s never defined", /* 233 */
|
||||
"union %s never defined", /* 234 */
|
||||
"enum %s never defined", /* 235 */
|
||||
"static function %s unused", /* 236 */
|
||||
"redeclaration of formal parameter %s", /* 237 */
|
||||
"initialisation of union is illegal in traditional C", /* 238 */
|
||||
"constant argument to NOT", /* 239 */
|
||||
"assignment of different structures", /* 240 */
|
||||
"dubious operation on enum, op %s", /* 241 */
|
||||
"combination of '%s' and '%s', op %s", /* 242 */
|
||||
"dubious comparison of enums, op %s", /* 243 */
|
||||
"illegal structure pointer combination", /* 244 */
|
||||
"illegal structure pointer combination, op %s", /* 245 */
|
||||
"dubious conversion of enum to '%s'", /* 246 */
|
||||
"pointer casts may be troublesome", /* 247 */
|
||||
"floating-point constant out of range", /* 248 */
|
||||
"syntax error", /* 249 */
|
||||
"unknown character \\%o", /* 250 */
|
||||
"malformed integer constant", /* 251 */
|
||||
"integer constant out of range", /* 252 */
|
||||
"unterminated character constant", /* 253 */
|
||||
"newline in string or char constant", /* 254 */
|
||||
"undefined or invalid # directive", /* 255 */
|
||||
"unterminated comment", /* 256 */
|
||||
"extra characters in lint comment", /* 257 */
|
||||
"unterminated string constant", /* 258 */
|
||||
"conversion to '%s' due to prototype, arg #%d", /* 259 */
|
||||
"previous declaration of %s", /* 260 */
|
||||
"previous definition of %s", /* 261 */
|
||||
"\\\" inside character constants undefined in traditional C", /* 262 */
|
||||
"\\? undefined in traditional C", /* 263 */
|
||||
"\\v undefined in traditional C", /* 264 */
|
||||
"%s C does not support 'long long'", /* 265 */
|
||||
"'long double' is illegal in traditional C", /* 266 */
|
||||
"shift equal to size of object", /* 267 */
|
||||
"variable declared inline: %s", /* 268 */
|
||||
"argument declared inline: %s", /* 269 */
|
||||
"function prototypes are illegal in traditional C", /* 270 */
|
||||
"switch expression must be of type `int' in traditional C", /* 271 */
|
||||
"empty translation unit", /* 272 */
|
||||
"bit-field type '%s' invalid in ANSI C", /* 273 */
|
||||
"ANSI C forbids comparison of %s with %s", /* 274 */
|
||||
"cast discards 'const' from pointer target type", /* 275 */
|
||||
"", /* 276 */
|
||||
"initialisation of '%s' with '%s'", /* 277 */
|
||||
"combination of '%s' and '%s', arg #%d", /* 278 */
|
||||
"combination of '%s' and '%s' in return", /* 279 */
|
||||
"must be outside function: /* %s */", /* 280 */
|
||||
"duplicate use of /* %s */", /* 281 */
|
||||
"must precede function definition: /* %s */", /* 282 */
|
||||
"argument number mismatch with directive: /* %s */", /* 283 */
|
||||
"fallthrough on default statement", /* 284 */
|
||||
"prototype declaration", /* 285 */
|
||||
"function definition is not a prototype", /* 286 */
|
||||
"function declaration is not a prototype", /* 287 */
|
||||
"dubious use of /* VARARGS */ with /* %s */", /* 288 */
|
||||
"can't be used together: /* PRINTFLIKE */ /* SCANFLIKE */", /* 289 */
|
||||
"static function %s declared but not defined", /* 290 */
|
||||
"invalid multibyte character", /* 291 */
|
||||
"cannot concatenate wide and regular string literals", /* 292 */
|
||||
"argument %d must be 'char *' for PRINTFLIKE/SCANFLIKE", /* 293 */
|
||||
"multi-character character constant", /* 294 */
|
||||
"conversion of '%s' to '%s' is out of range, arg #%d", /* 295 */
|
||||
"conversion of negative constant to unsigned type, arg #%d", /* 296 */
|
||||
"conversion to '%s' may sign-extend incorrectly, arg #%d", /* 297 */
|
||||
"conversion from '%s' to '%s' may lose accuracy, arg #%d", /* 298 */
|
||||
"prototype does not match old style definition, arg #%d", /* 299 */
|
||||
"old style definition", /* 300 */
|
||||
"array of incomplete type", /* 301 */
|
||||
"%s returns pointer to automatic object", /* 302 */
|
||||
"ANSI C forbids conversion of %s to %s", /* 303 */
|
||||
"ANSI C forbids conversion of %s to %s, arg #%d", /* 304 */
|
||||
"ANSI C forbids conversion of %s to %s, op %s", /* 305 */
|
||||
"constant truncated by conversion, op %s", /* 306 */
|
||||
"static variable %s set but not used", /* 307 */
|
||||
"", /* 308 */
|
||||
"extra bits set to 0 in conversion of '%s' to '%s', op %s", /* 309 */
|
||||
"symbol renaming can't be used on function arguments", /* 310 */
|
||||
"symbol renaming can't be used on automatic variables", /* 311 */
|
||||
"%s C does not support // comments", /* 312 */
|
||||
"struct or union member name in initializer is a C9X feature",/* 313 */
|
||||
"%s is not a structure or a union", /* 314 */
|
||||
"GCC style struct or union member name in initializer", /* 315 */
|
||||
"__FUNCTION__ is a GCC extension", /* 316 */
|
||||
"__func__ is a C9X feature", /* 317 */
|
||||
"variable array dimension is a C99/GCC extension", /* 318 */
|
||||
"compound literals are a C9X/GCC extension", /* 319 */
|
||||
"({ }) is a GCC extension", /* 320 */
|
||||
"array initializer with designators is a C9X feature", /* 321 */
|
||||
"zero sized array is a C99 extension", /* 322 */
|
||||
};
|
||||
|
||||
/*
|
||||
* print a list of the messages with their ids
|
||||
*/
|
||||
void
|
||||
msglist(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++)
|
||||
printf("%zu\t%s\n", i, msgs[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
* If Fflag is not set lbasename() returns a pointer to the last
|
||||
* component of the path, otherwise it returns the argument.
|
||||
*/
|
||||
static const char *
|
||||
lbasename(const char *path)
|
||||
{
|
||||
const char *cp, *cp1, *cp2;
|
||||
|
||||
if (Fflag)
|
||||
return (path);
|
||||
|
||||
cp = cp1 = cp2 = path;
|
||||
while (*cp != '\0') {
|
||||
if (*cp++ == '/') {
|
||||
cp2 = cp1;
|
||||
cp1 = cp;
|
||||
}
|
||||
}
|
||||
return (*cp1 == '\0' ? cp2 : cp1);
|
||||
}
|
||||
|
||||
static void
|
||||
verror( int n, va_list ap)
|
||||
{
|
||||
const char *fn;
|
||||
|
||||
if (ERR_ISSET(n, &msgset))
|
||||
return;
|
||||
|
||||
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);
|
||||
nerr++;
|
||||
}
|
||||
|
||||
static void
|
||||
vwarning( int n, va_list ap)
|
||||
{
|
||||
const char *fn;
|
||||
|
||||
if (ERR_ISSET(n, &msgset))
|
||||
return;
|
||||
|
||||
if (nowarn)
|
||||
/* this warning is suppressed by a LINTED comment */
|
||||
return;
|
||||
|
||||
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);
|
||||
if (wflag)
|
||||
nerr++;
|
||||
}
|
||||
|
||||
void
|
||||
error(int n, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, n);
|
||||
verror(n, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
lerror(const char *file, int line, const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
const char *fn;
|
||||
|
||||
va_start(ap, msg);
|
||||
fn = lbasename(curr_pos.p_file);
|
||||
(void)fprintf(stderr, "%s(%d): lint error: %s, %d", fn, curr_pos.p_line,
|
||||
file, line);
|
||||
(void)vfprintf(stderr, msg, ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
va_end(ap);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
warning(int n, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, n);
|
||||
vwarning(n, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
message(int n, ...)
|
||||
{
|
||||
va_list ap;
|
||||
const char *fn;
|
||||
|
||||
if (ERR_ISSET(n, &msgset))
|
||||
return;
|
||||
|
||||
va_start(ap, n);
|
||||
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);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX I think the logic is possibly somewhat screwed up here. The
|
||||
* question is, how do we want to interpret the -s and -S flags going
|
||||
* forward? We need to answer that and then we can fix this to be
|
||||
* "right"... [perry, 2 Nov 2002]
|
||||
*/
|
||||
int
|
||||
c99ism(int n, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int msg;
|
||||
|
||||
va_start(ap, n);
|
||||
if (sflag && !(Sflag || gflag)) {
|
||||
verror(n, ap);
|
||||
msg = 1;
|
||||
} else if (!sflag && (Sflag || gflag)) {
|
||||
msg = 0;
|
||||
} else {
|
||||
vwarning(n, ap);
|
||||
msg = 1;
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return (msg);
|
||||
}
|
||||
|
||||
int
|
||||
gnuism(int n, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int msg;
|
||||
|
||||
va_start(ap, n);
|
||||
if (sflag && !gflag) {
|
||||
verror(n, ap);
|
||||
msg = 1;
|
||||
} else if (!sflag && gflag) {
|
||||
msg = 0;
|
||||
} else {
|
||||
vwarning(n, ap);
|
||||
msg = 1;
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return (msg);
|
||||
}
|
@ -1,292 +0,0 @@
|
||||
/* $NetBSD: externs1.h,v 1.20 2002/11/02 20:09:27 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* main.c
|
||||
*/
|
||||
extern int aflag;
|
||||
extern int bflag;
|
||||
extern int cflag;
|
||||
extern int dflag;
|
||||
extern int eflag;
|
||||
extern int Fflag;
|
||||
extern int gflag;
|
||||
extern int hflag;
|
||||
extern int rflag;
|
||||
extern int sflag;
|
||||
extern int tflag;
|
||||
extern int uflag;
|
||||
extern int vflag;
|
||||
extern int yflag;
|
||||
extern int wflag;
|
||||
extern int zflag;
|
||||
extern int Sflag;
|
||||
|
||||
extern void norecover(void);
|
||||
|
||||
/*
|
||||
* cgram.y
|
||||
*/
|
||||
extern int blklev;
|
||||
extern int mblklev;
|
||||
extern int yydebug;
|
||||
|
||||
extern int yyerror(char *);
|
||||
extern int yyparse(void);
|
||||
|
||||
/*
|
||||
* scan.l
|
||||
*/
|
||||
extern pos_t curr_pos;
|
||||
extern pos_t csrc_pos;
|
||||
extern symt_t symtyp;
|
||||
extern FILE *yyin;
|
||||
extern uint64_t qbmasks[], qlmasks[], qumasks[];
|
||||
|
||||
extern void initscan(void);
|
||||
extern int sign(int64_t, tspec_t, int);
|
||||
extern int msb(int64_t, tspec_t, int);
|
||||
extern int64_t xsign(int64_t, tspec_t, int);
|
||||
extern void clrwflgs(void);
|
||||
extern sym_t *getsym(sbuf_t *);
|
||||
extern void cleanup(void);
|
||||
extern sym_t *pushdown(sym_t *);
|
||||
extern sym_t *mktempsym(type_t *);
|
||||
extern void rmsym(sym_t *);
|
||||
extern void rmsyms(sym_t *);
|
||||
extern void inssym(int, sym_t *);
|
||||
extern void freeyyv(void *, int);
|
||||
extern int yylex(void);
|
||||
|
||||
/*
|
||||
* mem1.c
|
||||
*/
|
||||
extern const char *fnalloc(const char *);
|
||||
extern const char *fnnalloc(const char *, size_t);
|
||||
extern int getfnid(const char *);
|
||||
|
||||
extern void initmem(void);
|
||||
|
||||
extern void *getblk(size_t);
|
||||
extern void *getlblk(int, size_t);
|
||||
extern void freeblk(void);
|
||||
extern void freelblk(int);
|
||||
|
||||
extern void *tgetblk(size_t);
|
||||
extern tnode_t *getnode(void);
|
||||
extern void tfreeblk(void);
|
||||
extern struct mbl *tsave(void);
|
||||
extern void trestor(struct mbl *);
|
||||
|
||||
/*
|
||||
* err.c
|
||||
*/
|
||||
extern int nerr;
|
||||
extern int sytxerr;
|
||||
extern const char *msgs[];
|
||||
|
||||
extern void msglist(void);
|
||||
extern void error(int, ...);
|
||||
extern void warning(int, ...);
|
||||
extern void message(int, ...);
|
||||
extern int gnuism(int, ...);
|
||||
extern int c99ism(int, ...);
|
||||
extern void lerror(const char *, int, const char *, ...)
|
||||
__attribute__((__noreturn__,__format__(__printf__, 3, 4)));
|
||||
|
||||
/*
|
||||
* decl.c
|
||||
*/
|
||||
extern dinfo_t *dcs;
|
||||
extern const char *unnamed;
|
||||
extern int enumval;
|
||||
|
||||
extern void initdecl(void);
|
||||
extern type_t *gettyp(tspec_t);
|
||||
extern type_t *duptyp(const type_t *);
|
||||
extern type_t *tduptyp(const type_t *);
|
||||
extern int incompl(type_t *);
|
||||
extern void setcompl(type_t *, int);
|
||||
extern void addscl(scl_t);
|
||||
extern void addtype(type_t *);
|
||||
extern void addqual(tqual_t);
|
||||
extern void pushdecl(scl_t);
|
||||
extern void popdecl(void);
|
||||
extern void setasm(void);
|
||||
extern void clrtyp(void);
|
||||
extern void deftyp(void);
|
||||
extern int length(type_t *, const char *);
|
||||
extern int getbound(type_t *);
|
||||
extern sym_t *lnklst(sym_t *, sym_t *);
|
||||
extern void chktyp(sym_t *);
|
||||
extern sym_t *decl1str(sym_t *);
|
||||
extern sym_t *bitfield(sym_t *, int);
|
||||
extern pqinf_t *mergepq(pqinf_t *, pqinf_t *);
|
||||
extern sym_t *addptr(sym_t *, pqinf_t *);
|
||||
extern sym_t *addarray(sym_t *, int, int);
|
||||
extern sym_t *addfunc(sym_t *, sym_t *);
|
||||
extern void chkfdef(sym_t *, int);
|
||||
extern sym_t *dname(sym_t *);
|
||||
extern sym_t *iname(sym_t *);
|
||||
extern type_t *mktag(sym_t *, tspec_t, int, int);
|
||||
extern const char *scltoa(scl_t);
|
||||
extern type_t *compltag(type_t *, sym_t *);
|
||||
extern sym_t *ename(sym_t *, int, int);
|
||||
extern void decl1ext(sym_t *, int);
|
||||
extern void cpuinfo(sym_t *, sym_t *);
|
||||
extern int isredec(sym_t *, int *);
|
||||
extern int eqtype(type_t *, type_t *, int, int, int *);
|
||||
extern void compltyp(sym_t *, sym_t *);
|
||||
extern sym_t *decl1arg(sym_t *, int);
|
||||
extern void cluparg(void);
|
||||
extern void decl1loc(sym_t *, int);
|
||||
extern sym_t *aname(void);
|
||||
extern void globclup(void);
|
||||
extern sym_t *decl1abs(sym_t *);
|
||||
extern void chksz(sym_t *);
|
||||
extern void setsflg(sym_t *);
|
||||
extern void setuflg(sym_t *, int, int);
|
||||
extern void chkusage(dinfo_t *);
|
||||
extern void chkusg1(int, sym_t *);
|
||||
extern void chkglsyms(void);
|
||||
extern void prevdecl(int, sym_t *);
|
||||
|
||||
/*
|
||||
* tree.c
|
||||
*/
|
||||
extern void initmtab(void);
|
||||
extern type_t *incref(type_t *, tspec_t);
|
||||
extern type_t *tincref(type_t *, tspec_t);
|
||||
extern tnode_t *getcnode(type_t *, val_t *);
|
||||
extern tnode_t *getnnode(sym_t *, int);
|
||||
extern tnode_t *getsnode(strg_t *);
|
||||
extern sym_t *strmemb(tnode_t *, op_t, sym_t *);
|
||||
extern tnode_t *build(op_t, tnode_t *, tnode_t *);
|
||||
extern tnode_t *cconv(tnode_t *);
|
||||
extern int typeok(op_t, int, tnode_t *, tnode_t *);
|
||||
extern tnode_t *promote(op_t, int, tnode_t *);
|
||||
extern tnode_t *convert(op_t, int, type_t *, tnode_t *);
|
||||
extern void cvtcon(op_t, int, type_t *, val_t *, val_t *);
|
||||
extern const char *tyname(char *, size_t, type_t *);
|
||||
extern const char *basictyname(tspec_t);
|
||||
extern tnode_t *bldszof(type_t *);
|
||||
extern tnode_t *cast(tnode_t *, type_t *);
|
||||
extern tnode_t *funcarg(tnode_t *, tnode_t *);
|
||||
extern tnode_t *funccall(tnode_t *, tnode_t *);
|
||||
extern val_t *constant(tnode_t *, int);
|
||||
extern void expr(tnode_t *, int, int, int);
|
||||
extern void chkmisc(tnode_t *, int, int, int, int, int, int);
|
||||
extern int conaddr(tnode_t *, sym_t **, ptrdiff_t *);
|
||||
extern strg_t *catstrg(strg_t *, strg_t *);
|
||||
|
||||
/*
|
||||
* func.c
|
||||
*/
|
||||
extern sym_t *funcsym;
|
||||
extern int reached;
|
||||
extern int rchflg;
|
||||
extern int ftflg;
|
||||
extern int nargusg;
|
||||
extern pos_t aupos;
|
||||
extern int nvararg;
|
||||
extern pos_t vapos;
|
||||
extern int prflstrg;
|
||||
extern pos_t prflpos;
|
||||
extern int scflstrg;
|
||||
extern pos_t scflpos;
|
||||
extern int ccflg;
|
||||
extern int llibflg;
|
||||
extern int nowarn;
|
||||
extern int bitfieldtype_ok;
|
||||
extern int plibflg;
|
||||
extern int quadflg;
|
||||
|
||||
extern void pushctrl(int);
|
||||
extern void popctrl(int);
|
||||
extern void chkreach(void);
|
||||
extern void funcdef(sym_t *);
|
||||
extern void funcend(void);
|
||||
extern void label(int, sym_t *, tnode_t *);
|
||||
extern void if1(tnode_t *);
|
||||
extern void if2(void);
|
||||
extern void if3(int);
|
||||
extern void switch1(tnode_t *);
|
||||
extern void switch2(void);
|
||||
extern void while1(tnode_t *);
|
||||
extern void while2(void);
|
||||
extern void do1(void);
|
||||
extern void do2(tnode_t *);
|
||||
extern void for1(tnode_t *, tnode_t *, tnode_t *);
|
||||
extern void for2(void);
|
||||
extern void dogoto(sym_t *);
|
||||
extern void docont(void);
|
||||
extern void dobreak(void);
|
||||
extern void doreturn(tnode_t *);
|
||||
extern void glclup(int);
|
||||
extern void argsused(int);
|
||||
extern void constcond(int);
|
||||
extern void fallthru(int);
|
||||
extern void notreach(int);
|
||||
extern void lintlib(int);
|
||||
extern void linted(int);
|
||||
extern void varargs(int);
|
||||
extern void printflike(int);
|
||||
extern void scanflike(int);
|
||||
extern void protolib(int);
|
||||
extern void longlong(int);
|
||||
extern void bitfieldtype(int);
|
||||
|
||||
/*
|
||||
* init.c
|
||||
*/
|
||||
extern int initerr;
|
||||
extern sym_t *initsym;
|
||||
extern int startinit;
|
||||
|
||||
extern void prepinit(void);
|
||||
extern void initrbr(void);
|
||||
extern void initlbr(void);
|
||||
extern void mkinit(tnode_t *);
|
||||
extern void memberpush(sbuf_t *);
|
||||
|
||||
/*
|
||||
* emit.c
|
||||
*/
|
||||
extern void outtype(type_t *);
|
||||
extern const char *ttos(type_t *);
|
||||
extern void outsym(sym_t *, scl_t, def_t);
|
||||
extern void outfdef(sym_t *, pos_t *, int, int, sym_t *);
|
||||
extern void outcall(tnode_t *, int, int);
|
||||
extern void outusg(sym_t *);
|
File diff suppressed because it is too large
Load Diff
@ -1,656 +0,0 @@
|
||||
/* $NetBSD: init.c,v 1.10 2002/01/31 19:36:54 tv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: init.c,v 1.10 2002/01/31 19:36:54 tv Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lint1.h"
|
||||
|
||||
/*
|
||||
* initerr is set as soon as a fatal error occurred in an initialisation.
|
||||
* The effect is that the rest of the initialisation is ignored (parsed
|
||||
* by yacc, expression trees built, but no initialisation takes place).
|
||||
*/
|
||||
int initerr;
|
||||
|
||||
/* Pointer to the symbol which is to be initialized. */
|
||||
sym_t *initsym;
|
||||
|
||||
/* Points to the top element of the initialisation stack. */
|
||||
istk_t *initstk;
|
||||
|
||||
typedef struct namlist {
|
||||
const char *n_name;
|
||||
struct namlist *n_prev;
|
||||
struct namlist *n_next;
|
||||
} namlist_t;
|
||||
|
||||
/* Points to a c9x named member; */
|
||||
namlist_t *namedmem = NULL;
|
||||
|
||||
|
||||
static void popi2(void);
|
||||
static void popinit(int);
|
||||
static void pushinit(void);
|
||||
static void testinit(void);
|
||||
static void nextinit(int);
|
||||
static int strginit(tnode_t *);
|
||||
static void memberpop(void);
|
||||
|
||||
#ifndef DEBUG
|
||||
#define DPRINTF(a)
|
||||
#else
|
||||
#define DPRINTF(a) printf a
|
||||
#endif
|
||||
|
||||
void
|
||||
memberpush(sb)
|
||||
sbuf_t *sb;
|
||||
{
|
||||
namlist_t *nam = xcalloc(1, sizeof (namlist_t));
|
||||
nam->n_name = sb->sb_name;
|
||||
DPRINTF(("memberpush = %s\n", nam->n_name));
|
||||
if (namedmem == NULL) {
|
||||
nam->n_prev = nam->n_next = nam;
|
||||
namedmem = nam;
|
||||
} else {
|
||||
namedmem->n_prev->n_next = nam;
|
||||
nam->n_prev = namedmem->n_prev;
|
||||
nam->n_next = namedmem;
|
||||
namedmem->n_prev = nam;
|
||||
}
|
||||
#if 0
|
||||
nam->n_next = namedmem;
|
||||
namedmem = nam;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
memberpop()
|
||||
{
|
||||
DPRINTF(("memberpop = %s\n", namedmem->n_name));
|
||||
if (namedmem->n_next == namedmem) {
|
||||
free(namedmem);
|
||||
namedmem = NULL;
|
||||
} else {
|
||||
namlist_t *nam = namedmem;
|
||||
namedmem = namedmem->n_next;
|
||||
free(nam);
|
||||
}
|
||||
#if 0
|
||||
namedmem = namedmem->n_next;
|
||||
free(nam);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the initialisation stack by putting an entry for the variable
|
||||
* which is to be initialized on it.
|
||||
*/
|
||||
void
|
||||
prepinit(void)
|
||||
{
|
||||
istk_t *istk;
|
||||
|
||||
if (initerr)
|
||||
return;
|
||||
|
||||
/* free memory used in last initialisation */
|
||||
while ((istk = initstk) != NULL) {
|
||||
initstk = istk->i_nxt;
|
||||
free(istk);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the type which is to be initialized is an incomplete type,
|
||||
* it must be duplicated.
|
||||
*/
|
||||
if (initsym->s_type->t_tspec == ARRAY && incompl(initsym->s_type))
|
||||
initsym->s_type = duptyp(initsym->s_type);
|
||||
|
||||
istk = initstk = xcalloc(1, sizeof (istk_t));
|
||||
istk->i_subt = initsym->s_type;
|
||||
istk->i_cnt = 1;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
popi2(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
char buf[64];
|
||||
#endif
|
||||
istk_t *istk;
|
||||
sym_t *m;
|
||||
|
||||
initstk = (istk = initstk)->i_nxt;
|
||||
if (initstk == NULL)
|
||||
LERROR("popi2()");
|
||||
free(istk);
|
||||
|
||||
istk = initstk;
|
||||
|
||||
istk->i_cnt--;
|
||||
if (istk->i_cnt < 0)
|
||||
LERROR("popi2()");
|
||||
|
||||
DPRINTF(("popi2(): %d %s\n", istk->i_cnt,
|
||||
namedmem ? namedmem->n_name : "*null*"));
|
||||
if (istk->i_cnt >= 0 && namedmem != NULL) {
|
||||
DPRINTF(("popi2(): %d %s %s\n", istk->i_cnt,
|
||||
tyname(buf, sizeof(buf), istk->i_type), namedmem->n_name));
|
||||
for (m = istk->i_type->t_str->memb; m != NULL; m = m->s_nxt) {
|
||||
if (m->s_field && m->s_name == unnamed)
|
||||
continue;
|
||||
if (strcmp(m->s_name, namedmem->n_name) == 0) {
|
||||
istk->i_subt = m->s_type;
|
||||
istk->i_cnt++;
|
||||
memberpop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
error(101, namedmem->n_name);
|
||||
memberpop();
|
||||
istk->i_namedmem = 1;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* If the removed element was a structure member, we must go
|
||||
* to the next structure member.
|
||||
*/
|
||||
if (istk->i_cnt > 0 && istk->i_type->t_tspec == STRUCT &&
|
||||
!istk->i_namedmem) {
|
||||
do {
|
||||
m = istk->i_mem = istk->i_mem->s_nxt;
|
||||
if (m == NULL)
|
||||
LERROR("popi2()");
|
||||
} while (m->s_field && m->s_name == unnamed);
|
||||
istk->i_subt = m->s_type;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
popinit(int brace)
|
||||
{
|
||||
DPRINTF(("popinit(%d)\n", brace));
|
||||
|
||||
if (brace) {
|
||||
/*
|
||||
* Take all entries, including the first which requires
|
||||
* a closing brace, from the stack.
|
||||
*/
|
||||
do {
|
||||
brace = initstk->i_brace;
|
||||
popi2();
|
||||
} while (!brace);
|
||||
} else {
|
||||
/*
|
||||
* Take all entries which cannot be used for further
|
||||
* initializers from the stack, but do this only if
|
||||
* they do not require a closing brace.
|
||||
*/
|
||||
while (!initstk->i_brace &&
|
||||
initstk->i_cnt == 0 && !initstk->i_nolimit) {
|
||||
popi2();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pushinit(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
char buf[64];
|
||||
#endif
|
||||
istk_t *istk;
|
||||
int cnt;
|
||||
sym_t *m;
|
||||
|
||||
istk = initstk;
|
||||
|
||||
/* Extend an incomplete array type by one element */
|
||||
if (istk->i_cnt == 0) {
|
||||
DPRINTF(("pushinit(extend) %s\n", tyname(buf, sizeof(buf),
|
||||
istk->i_type)));
|
||||
/*
|
||||
* Inside of other aggregate types must not be an incomplete
|
||||
* type.
|
||||
*/
|
||||
if (istk->i_nxt->i_nxt != NULL)
|
||||
LERROR("pushinit()");
|
||||
istk->i_cnt = 1;
|
||||
if (istk->i_type->t_tspec != ARRAY)
|
||||
LERROR("pushinit()");
|
||||
istk->i_type->t_dim++;
|
||||
/* from now its a complete type */
|
||||
setcompl(istk->i_type, 0);
|
||||
}
|
||||
|
||||
if (istk->i_cnt <= 0)
|
||||
LERROR("pushinit()");
|
||||
if (istk->i_type != NULL && issclt(istk->i_type->t_tspec))
|
||||
LERROR("pushinit() 4");
|
||||
|
||||
initstk = xcalloc(1, sizeof (istk_t));
|
||||
initstk->i_nxt = istk;
|
||||
initstk->i_type = istk->i_subt;
|
||||
if (initstk->i_type->t_tspec == FUNC)
|
||||
LERROR("pushinit()");
|
||||
|
||||
again:
|
||||
istk = initstk;
|
||||
|
||||
DPRINTF(("pushinit(%s)\n", tyname(buf, sizeof(buf), istk->i_type)));
|
||||
switch (istk->i_type->t_tspec) {
|
||||
case ARRAY:
|
||||
if (namedmem) {
|
||||
DPRINTF(("pushinit ARRAY %s\n", namedmem->n_name));
|
||||
free(istk);
|
||||
initstk = initstk->i_nxt;
|
||||
goto again;
|
||||
}
|
||||
if (incompl(istk->i_type) && istk->i_nxt->i_nxt != NULL) {
|
||||
/* initialisation of an incomplete type */
|
||||
error(175);
|
||||
initerr = 1;
|
||||
return;
|
||||
}
|
||||
istk->i_subt = istk->i_type->t_subt;
|
||||
istk->i_nolimit = incompl(istk->i_type);
|
||||
istk->i_cnt = istk->i_type->t_dim;
|
||||
DPRINTF(("elements array %s[%d] %s\n",
|
||||
tyname(buf, sizeof(buf), istk->i_subt), istk->i_cnt,
|
||||
namedmem ? namedmem->n_name : "*none*"));
|
||||
break;
|
||||
case UNION:
|
||||
if (tflag)
|
||||
/* initialisation of union is illegal in trad. C */
|
||||
warning(238);
|
||||
/* FALLTHROUGH */
|
||||
case STRUCT:
|
||||
if (incompl(istk->i_type)) {
|
||||
/* initialisation of an incomplete type */
|
||||
error(175);
|
||||
initerr = 1;
|
||||
return;
|
||||
}
|
||||
cnt = 0;
|
||||
DPRINTF(("2. member lookup %s %s\n",
|
||||
tyname(buf, sizeof(buf), istk->i_type),
|
||||
namedmem ? namedmem->n_name : "*none*"));
|
||||
for (m = istk->i_type->t_str->memb; m != NULL; m = m->s_nxt) {
|
||||
if (m->s_field && m->s_name == unnamed)
|
||||
continue;
|
||||
if (namedmem != NULL) {
|
||||
DPRINTF(("pushinit():[member:%s, looking:%s]\n",
|
||||
m->s_name, namedmem->n_name));
|
||||
if (strcmp(m->s_name, namedmem->n_name) == 0) {
|
||||
cnt++;
|
||||
break;
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
if (++cnt == 1) {
|
||||
istk->i_mem = m;
|
||||
istk->i_subt = m->s_type;
|
||||
}
|
||||
}
|
||||
if (namedmem != NULL) {
|
||||
istk->i_namedmem = 1;
|
||||
if (m == NULL) {
|
||||
error(101, namedmem->n_name);
|
||||
initerr = 1;
|
||||
} else {
|
||||
istk->i_mem = m;
|
||||
istk->i_subt = m->s_type;
|
||||
}
|
||||
memberpop();
|
||||
cnt = istk->i_type->t_tspec == STRUCT ? 2 : 1;
|
||||
}
|
||||
if (cnt == 0) {
|
||||
/* cannot init. struct/union with no named member */
|
||||
error(179);
|
||||
initerr = 1;
|
||||
return;
|
||||
}
|
||||
istk->i_cnt = istk->i_type->t_tspec == STRUCT ? cnt : 1;
|
||||
break;
|
||||
default:
|
||||
if (namedmem) {
|
||||
DPRINTF(("pushinit(): pop\n"));
|
||||
free(istk);
|
||||
initstk = initstk->i_nxt;
|
||||
goto again;
|
||||
}
|
||||
istk->i_cnt = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
testinit(void)
|
||||
{
|
||||
istk_t *istk;
|
||||
|
||||
istk = initstk;
|
||||
|
||||
/*
|
||||
* If a closing brace is expected we have at least one initializer
|
||||
* too much.
|
||||
*/
|
||||
if (istk->i_cnt == 0 && !istk->i_nolimit && !istk->i_namedmem) {
|
||||
switch (istk->i_type->t_tspec) {
|
||||
case ARRAY:
|
||||
/* too many array initializers */
|
||||
error(173);
|
||||
break;
|
||||
case STRUCT:
|
||||
case UNION:
|
||||
/* too many struct/union initializers */
|
||||
error(172);
|
||||
break;
|
||||
default:
|
||||
/* too many initializers */
|
||||
error(174);
|
||||
break;
|
||||
}
|
||||
initerr = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nextinit(int brace)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
DPRINTF(("nextinit(%d)\n", brace));
|
||||
if (!brace) {
|
||||
if (initstk->i_type == NULL &&
|
||||
!issclt(initstk->i_subt->t_tspec)) {
|
||||
/* {}-enclosed initializer required */
|
||||
error(181);
|
||||
}
|
||||
/*
|
||||
* Make sure an entry with a scalar type is at the top
|
||||
* of the stack.
|
||||
*/
|
||||
if (!initerr)
|
||||
testinit();
|
||||
while (!initerr && (initstk->i_type == NULL ||
|
||||
!issclt(initstk->i_type->t_tspec))) {
|
||||
if (!initerr)
|
||||
pushinit();
|
||||
}
|
||||
} else {
|
||||
if (initstk->i_type != NULL &&
|
||||
issclt(initstk->i_type->t_tspec)) {
|
||||
/* invalid initializer */
|
||||
error(176);
|
||||
initerr = 1;
|
||||
}
|
||||
if (!initerr)
|
||||
testinit();
|
||||
if (!initerr)
|
||||
pushinit();
|
||||
if (!initerr)
|
||||
initstk->i_brace = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
initlbr(void)
|
||||
{
|
||||
|
||||
if (initerr)
|
||||
return;
|
||||
|
||||
if ((initsym->s_scl == AUTO || initsym->s_scl == REG) &&
|
||||
initstk->i_nxt == NULL) {
|
||||
if (tflag && !issclt(initstk->i_subt->t_tspec))
|
||||
/* no automatic aggregate initialization in trad. C*/
|
||||
warning(188);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove all entries which cannot be used for further initializers
|
||||
* and do not expect a closing brace.
|
||||
*/
|
||||
popinit(0);
|
||||
|
||||
nextinit(1);
|
||||
}
|
||||
|
||||
void
|
||||
initrbr(void)
|
||||
{
|
||||
|
||||
if (initerr)
|
||||
return;
|
||||
|
||||
popinit(1);
|
||||
}
|
||||
|
||||
void
|
||||
mkinit(tnode_t *tn)
|
||||
{
|
||||
ptrdiff_t offs;
|
||||
sym_t *sym;
|
||||
tspec_t lt, rt;
|
||||
tnode_t *ln;
|
||||
struct mbl *tmem;
|
||||
scl_t sc;
|
||||
#ifdef DEBUG
|
||||
char buf[64];
|
||||
#endif
|
||||
|
||||
DPRINTF(("mkinit(%s)\n", tyname(buf, sizeof(buf), tn->tn_type)));
|
||||
if (initerr || tn == NULL)
|
||||
goto end;
|
||||
|
||||
sc = initsym->s_scl;
|
||||
|
||||
/*
|
||||
* Do not test for automatic aggregate initialisation. If the
|
||||
* initializer starts with a brace we have the warning already.
|
||||
* If not, an error will be printed that the initializer must
|
||||
* be enclosed by braces.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Local initialisation of non-array-types with only one expression
|
||||
* without braces is done by ASSIGN
|
||||
*/
|
||||
if ((sc == AUTO || sc == REG) &&
|
||||
initsym->s_type->t_tspec != ARRAY && initstk->i_nxt == NULL) {
|
||||
ln = getnnode(initsym, 0);
|
||||
ln->tn_type = tduptyp(ln->tn_type);
|
||||
ln->tn_type->t_const = 0;
|
||||
tn = build(ASSIGN, ln, tn);
|
||||
expr(tn, 0, 0, 1);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove all entries which cannot be used for further initializers
|
||||
* and do not require a closing brace.
|
||||
*/
|
||||
popinit(0);
|
||||
|
||||
/* Initialisations by strings are done in strginit(). */
|
||||
if (strginit(tn))
|
||||
goto end;
|
||||
|
||||
nextinit(0);
|
||||
if (initerr || tn == NULL)
|
||||
goto end;
|
||||
|
||||
initstk->i_cnt--;
|
||||
DPRINTF(("mkinit() cnt=%d tn=%p\n", initstk->i_cnt, tn));
|
||||
/* Create a temporary node for the left side. */
|
||||
ln = tgetblk(sizeof (tnode_t));
|
||||
ln->tn_op = NAME;
|
||||
ln->tn_type = tduptyp(initstk->i_type);
|
||||
ln->tn_type->t_const = 0;
|
||||
ln->tn_lvalue = 1;
|
||||
ln->tn_sym = initsym; /* better than nothing */
|
||||
|
||||
tn = cconv(tn);
|
||||
|
||||
lt = ln->tn_type->t_tspec;
|
||||
rt = tn->tn_type->t_tspec;
|
||||
|
||||
if (!issclt(lt))
|
||||
LERROR("mkinit()");
|
||||
|
||||
if (!typeok(INIT, 0, ln, tn))
|
||||
goto end;
|
||||
|
||||
/*
|
||||
* Store the tree memory. This is necessary because otherwise
|
||||
* expr() would free it.
|
||||
*/
|
||||
tmem = tsave();
|
||||
expr(tn, 1, 0, 1);
|
||||
trestor(tmem);
|
||||
|
||||
if (isityp(lt) && ln->tn_type->t_isfield && !isityp(rt)) {
|
||||
/*
|
||||
* Bit-fields can be initialized in trad. C only by integer
|
||||
* constants.
|
||||
*/
|
||||
if (tflag)
|
||||
/* bit-field initialisation is illegal in trad. C */
|
||||
warning(186);
|
||||
}
|
||||
|
||||
if (lt != rt || (initstk->i_type->t_isfield && tn->tn_op == CON))
|
||||
tn = convert(INIT, 0, initstk->i_type, tn);
|
||||
|
||||
if (tn != NULL && tn->tn_op != CON) {
|
||||
sym = NULL;
|
||||
offs = 0;
|
||||
if (conaddr(tn, &sym, &offs) == -1) {
|
||||
if (sc == AUTO || sc == REG) {
|
||||
/* non-constant initializer */
|
||||
(void)gnuism(177);
|
||||
} else {
|
||||
/* non-constant initializer */
|
||||
error(177);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
/*
|
||||
* We only free the block, if we are not a compound declaration
|
||||
* We know that the only symbols that start with a digit are the
|
||||
* ones we allocate with mktempsym() for compound declarations
|
||||
*/
|
||||
if (!isdigit((unsigned char)initsym->s_name[0]))
|
||||
tfreeblk();
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
strginit(tnode_t *tn)
|
||||
{
|
||||
tspec_t t;
|
||||
istk_t *istk;
|
||||
int len;
|
||||
strg_t *strg;
|
||||
|
||||
if (tn->tn_op != STRING)
|
||||
return (0);
|
||||
|
||||
istk = initstk;
|
||||
strg = tn->tn_strg;
|
||||
|
||||
/*
|
||||
* Check if we have an array type which can be initialized by
|
||||
* the string.
|
||||
*/
|
||||
if (istk->i_subt != NULL && istk->i_subt->t_tspec == ARRAY) {
|
||||
t = istk->i_subt->t_subt->t_tspec;
|
||||
if (!((strg->st_tspec == CHAR &&
|
||||
(t == CHAR || t == UCHAR || t == SCHAR)) ||
|
||||
(strg->st_tspec == WCHAR && t == WCHAR))) {
|
||||
return (0);
|
||||
}
|
||||
/* Put the array at top of stack */
|
||||
pushinit();
|
||||
istk = initstk;
|
||||
} else if (istk->i_type != NULL && istk->i_type->t_tspec == ARRAY) {
|
||||
t = istk->i_type->t_subt->t_tspec;
|
||||
if (!((strg->st_tspec == CHAR &&
|
||||
(t == CHAR || t == UCHAR || t == SCHAR)) ||
|
||||
(strg->st_tspec == WCHAR && t == WCHAR))) {
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* If the array is already partly initialized, we are
|
||||
* wrong here.
|
||||
*/
|
||||
if (istk->i_cnt != istk->i_type->t_dim)
|
||||
return (0);
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Get length without trailing NUL character. */
|
||||
len = strg->st_len;
|
||||
|
||||
if (istk->i_nolimit) {
|
||||
istk->i_nolimit = 0;
|
||||
istk->i_type->t_dim = len + 1;
|
||||
/* from now complete type */
|
||||
setcompl(istk->i_type, 0);
|
||||
} else {
|
||||
if (istk->i_type->t_dim < len) {
|
||||
/* non-null byte ignored in string initializer */
|
||||
warning(187);
|
||||
}
|
||||
}
|
||||
|
||||
/* In every case the array is initialized completely. */
|
||||
istk->i_cnt = 0;
|
||||
|
||||
return (1);
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
/* $NetBSD: lint.h,v 1.2 1995/07/03 21:24:18 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "param.h"
|
||||
|
||||
/*
|
||||
* Type specifiers, used in type structures (type_t) and otherwere.
|
||||
*/
|
||||
typedef enum {
|
||||
NOTSPEC,
|
||||
SIGNED, /* keyword "signed", only used in the parser */
|
||||
UNSIGN, /* keyword "unsigned", only used in the parser */
|
||||
CHAR, /* char */
|
||||
SCHAR, /* signed char */
|
||||
UCHAR, /* unsigned char */
|
||||
SHORT, /* (signed) short */
|
||||
USHORT, /* unsigned short */
|
||||
INT, /* (signed) int */
|
||||
UINT, /* unsigned int */
|
||||
LONG, /* (signed) long */
|
||||
ULONG, /* unsigned long */
|
||||
QUAD, /* (signed) long long */
|
||||
UQUAD, /* unsigned long long */
|
||||
FLOAT, /* float */
|
||||
DOUBLE, /* double or, with tflag, long float */
|
||||
LDOUBLE, /* long double */
|
||||
VOID, /* void */
|
||||
STRUCT, /* structure tag */
|
||||
UNION, /* union tag */
|
||||
ENUM, /* enum tag */
|
||||
PTR, /* pointer */
|
||||
ARRAY, /* array */
|
||||
FUNC /* function */
|
||||
#define NTSPEC ((int)FUNC + 1)
|
||||
} tspec_t;
|
||||
|
||||
/*
|
||||
* size of types, name and classification
|
||||
*/
|
||||
typedef struct {
|
||||
int tt_sz; /* size in bits */
|
||||
int tt_psz; /* size, different from tt_sz
|
||||
if pflag is set */
|
||||
tspec_t tt_styp; /* signed counterpart */
|
||||
tspec_t tt_utyp; /* unsigned counterpart */
|
||||
u_int tt_isityp : 1; /* 1 if integer type */
|
||||
u_int tt_isutyp : 1; /* 1 if unsigned integer type */
|
||||
u_int tt_isftyp : 1; /* 1 if floating point type */
|
||||
u_int tt_isatyp : 1; /* 1 if arithmetic type */
|
||||
u_int tt_issclt : 1; /* 1 if scalar type */
|
||||
char *tt_name; /* type name */
|
||||
} ttab_t;
|
||||
|
||||
#define size(t) (ttab[t].tt_sz)
|
||||
#define psize(t) (ttab[t].tt_psz)
|
||||
#define styp(t) (ttab[t].tt_styp)
|
||||
#define utyp(t) (ttab[t].tt_utyp)
|
||||
#define isityp(t) (ttab[t].tt_isityp)
|
||||
#define isutyp(t) (ttab[t].tt_isutyp)
|
||||
#define isftyp(t) (ttab[t].tt_isftyp)
|
||||
#define isatyp(t) (ttab[t].tt_isatyp)
|
||||
#define issclt(t) (ttab[t].tt_issclt)
|
||||
|
||||
extern ttab_t ttab[];
|
||||
|
||||
|
||||
typedef enum {
|
||||
NODECL, /* until now not declared */
|
||||
DECL, /* declared */
|
||||
TDEF, /* tentative defined */
|
||||
DEF /* defined */
|
||||
} def_t;
|
||||
|
||||
/*
|
||||
* Following structure contains some data used for the output buffer.
|
||||
*/
|
||||
typedef struct ob {
|
||||
char *o_buf; /* buffer */
|
||||
char *o_end; /* first byte after buffer */
|
||||
size_t o_len; /* length of buffer */
|
||||
char *o_nxt; /* next free byte in buffer */
|
||||
} ob_t;
|
||||
|
||||
#include "externs.h"
|
@ -1,424 +0,0 @@
|
||||
/* $NetBSD: lint1.h,v 1.16 2002/10/21 22:44:08 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "lint.h"
|
||||
#include "op.h"
|
||||
|
||||
/* XXX - works for most systems, but the whole ALIGN thing needs to go away */
|
||||
#ifndef LINT_ALIGN
|
||||
#define LINT_ALIGN(x) (((x) + 15) & ~15)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Describes the position of a declaration or anything else.
|
||||
*/
|
||||
typedef struct {
|
||||
int p_line;
|
||||
const char *p_file;
|
||||
int p_uniq; /* uniquifier */
|
||||
} pos_t;
|
||||
|
||||
/* Copies curr_pos, keeping things unique. */
|
||||
#define UNIQUE_CURR_POS(pos) \
|
||||
do { \
|
||||
STRUCT_ASSIGN((pos), curr_pos); \
|
||||
curr_pos.p_uniq++; \
|
||||
if (curr_pos.p_file == csrc_pos.p_file) \
|
||||
csrc_pos.p_uniq++; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Strings cannot be referenced to simply by a pointer to its first
|
||||
* char. This is because strings can contain NUL characters other than the
|
||||
* trailing NUL.
|
||||
*
|
||||
* Strings are stored with a trailing NUL.
|
||||
*/
|
||||
typedef struct strg {
|
||||
tspec_t st_tspec; /* CHAR or WCHAR */
|
||||
size_t st_len; /* length without trailing NUL */
|
||||
union {
|
||||
u_char *_st_cp;
|
||||
wchar_t *_st_wcp;
|
||||
} st_u;
|
||||
} strg_t;
|
||||
|
||||
#define st_cp st_u._st_cp
|
||||
#define st_wcp st_u._st_wcp
|
||||
|
||||
/*
|
||||
* qualifiers (only for lex/yacc interface)
|
||||
*/
|
||||
typedef enum {
|
||||
CONST, VOLATILE
|
||||
} tqual_t;
|
||||
|
||||
/*
|
||||
* Integer and floating point values are stored in this structure
|
||||
*/
|
||||
typedef struct {
|
||||
tspec_t v_tspec;
|
||||
int v_ansiu; /* set if an integer constant is
|
||||
unsigned in ANSI C */
|
||||
union {
|
||||
int64_t _v_quad; /* integers */
|
||||
ldbl_t _v_ldbl; /* floats */
|
||||
} v_u;
|
||||
} val_t;
|
||||
|
||||
#define v_quad v_u._v_quad
|
||||
#define v_ldbl v_u._v_ldbl
|
||||
|
||||
/*
|
||||
* Structures of type str_t uniqely identify structures. This can't
|
||||
* be done in structures of type type_t, because these are copied
|
||||
* if they must be modified. So it would not be possible to check
|
||||
* if two structures are identical by comparing the pointers to
|
||||
* the type structures.
|
||||
*
|
||||
* The typename is used if the structure is unnamed to identify
|
||||
* the structure type in pass 2.
|
||||
*/
|
||||
typedef struct {
|
||||
u_int size; /* size in bit */
|
||||
u_int align : 15; /* alignment in bit */
|
||||
u_int sincompl : 1; /* set if incomplete type */
|
||||
struct sym *memb; /* list of members */
|
||||
struct sym *stag; /* symbol table entry of tag */
|
||||
struct sym *stdef; /* symbol table entry of first typename */
|
||||
} str_t;
|
||||
|
||||
/*
|
||||
* same as above for enums
|
||||
*/
|
||||
typedef struct {
|
||||
u_int eincompl : 1; /* incomplete enum type */
|
||||
struct sym *elem; /* list of enumerators */
|
||||
struct sym *etag; /* symbol table entry of tag */
|
||||
struct sym *etdef; /* symbol table entry of first typename */
|
||||
} enum_t;
|
||||
|
||||
/*
|
||||
* Types are represented by concatenation of structures of type type_t
|
||||
* via t_subt.
|
||||
*/
|
||||
typedef struct type {
|
||||
tspec_t t_tspec; /* type specifier */
|
||||
u_int t_aincompl : 1; /* incomplete array type */
|
||||
u_int t_const : 1; /* const modifier */
|
||||
u_int t_volatile : 1; /* volatile modifier */
|
||||
u_int t_proto : 1; /* function prototype (t_args valid) */
|
||||
u_int t_vararg : 1; /* prototype with ... */
|
||||
u_int t_typedef : 1; /* type defined with typedef */
|
||||
u_int t_isfield : 1; /* type is bitfield */
|
||||
u_int t_isenum : 1; /* type is (or was) enum (t_enum valid) */
|
||||
union {
|
||||
int _t_dim; /* dimension */
|
||||
str_t *_t_str; /* struct/union tag */
|
||||
enum_t *_t_enum; /* enum tag */
|
||||
struct sym *_t_args; /* arguments (if t_proto) */
|
||||
} t_u;
|
||||
struct {
|
||||
u_int _t_flen : 8; /* length of bit-field */
|
||||
u_int _t_foffs : 24; /* offset of bit-field */
|
||||
} t_b;
|
||||
struct type *t_subt; /* element type (arrays), return value
|
||||
(functions), or type pointer points to */
|
||||
} type_t;
|
||||
|
||||
#define t_dim t_u._t_dim
|
||||
#define t_str t_u._t_str
|
||||
#define t_field t_u._t_field
|
||||
#define t_enum t_u._t_enum
|
||||
#define t_args t_u._t_args
|
||||
#define t_flen t_b._t_flen
|
||||
#define t_foffs t_b._t_foffs
|
||||
|
||||
/*
|
||||
* types of symbols
|
||||
*/
|
||||
typedef enum {
|
||||
FVFT, /* variables, functions, type names, enums */
|
||||
FMOS, /* members of structs or unions */
|
||||
FTAG, /* tags */
|
||||
FLAB /* labels */
|
||||
} symt_t;
|
||||
|
||||
/*
|
||||
* storage classes
|
||||
*/
|
||||
typedef enum {
|
||||
NOSCL,
|
||||
EXTERN, /* external symbols (indep. of decl_t) */
|
||||
STATIC, /* static symbols (local and global) */
|
||||
AUTO, /* automatic symbols (except register) */
|
||||
REG, /* register */
|
||||
TYPEDEF, /* typedef */
|
||||
STRTAG,
|
||||
UNIONTAG,
|
||||
ENUMTAG,
|
||||
MOS, /* member of struct */
|
||||
MOU, /* member of union */
|
||||
ENUMCON, /* enumerator */
|
||||
ABSTRACT, /* abstract symbol (sizeof, casts, unnamed argument) */
|
||||
ARG, /* argument */
|
||||
PARG, /* used in declaration stack during prototype
|
||||
declaration */
|
||||
INLINE /* only used by the parser */
|
||||
} scl_t;
|
||||
|
||||
/*
|
||||
* symbol table entry
|
||||
*/
|
||||
typedef struct sym {
|
||||
const char *s_name; /* name */
|
||||
const char *s_rename; /* renamed symbol's given name */
|
||||
pos_t s_dpos; /* position of last (prototype)definition,
|
||||
prototypedeclaration, no-prototype-def.,
|
||||
tentative definition or declaration,
|
||||
in this order */
|
||||
pos_t s_spos; /* position of first initialisation */
|
||||
pos_t s_upos; /* position of first use */
|
||||
symt_t s_kind; /* type of symbol */
|
||||
u_int s_keyw : 1; /* keyword */
|
||||
u_int s_field : 1; /* bit-field */
|
||||
u_int s_set : 1; /* variable set, label defined */
|
||||
u_int s_used : 1; /* variable/label used */
|
||||
u_int s_arg : 1; /* symbol is function argument */
|
||||
u_int s_reg : 1; /* symbol is register variable */
|
||||
u_int s_defarg : 1; /* undefined symbol in old style function
|
||||
definition */
|
||||
u_int s_rimpl : 1; /* return value of function implicit decl. */
|
||||
u_int s_osdef : 1; /* symbol stems from old style function def. */
|
||||
u_int s_inline : 1; /* true if this is an inline function */
|
||||
struct sym *s_xsym; /* for local declared external symbols pointer
|
||||
to external symbol with same name */
|
||||
def_t s_def; /* declared, tentative defined, defined */
|
||||
scl_t s_scl; /* storage class */
|
||||
int s_blklev; /* level of declaration, -1 if not in symbol
|
||||
table */
|
||||
type_t *s_type; /* type */
|
||||
val_t s_value; /* value (if enumcon) */
|
||||
union {
|
||||
str_t *_s_st; /* tag, if it is a struct/union member */
|
||||
enum_t *_s_et; /* tag, if it is an enumerator */
|
||||
tspec_t _s_tsp; /* type (only for keywords) */
|
||||
tqual_t _s_tqu; /* qualifier (only for keywords) */
|
||||
struct sym *_s_args; /* arguments in old style function
|
||||
definitions */
|
||||
} u;
|
||||
struct sym *s_link; /* next symbol with same hash value */
|
||||
struct sym **s_rlink; /* pointer to s_link of prev. symbol */
|
||||
struct sym *s_nxt; /* next struct/union member, enumerator,
|
||||
argument */
|
||||
struct sym *s_dlnxt; /* next symbol declared on same level */
|
||||
} sym_t;
|
||||
|
||||
#define s_styp u._s_st
|
||||
#define s_etyp u._s_et
|
||||
#define s_tspec u._s_tsp
|
||||
#define s_tqual u._s_tqu
|
||||
#define s_args u._s_args
|
||||
|
||||
/*
|
||||
* Used to keep some informations about symbols before they are entered
|
||||
* into the symbol table.
|
||||
*/
|
||||
typedef struct sbuf {
|
||||
const char *sb_name; /* name of symbol */
|
||||
size_t sb_len; /* length (without '\0') */
|
||||
int sb_hash; /* hash value */
|
||||
sym_t *sb_sym; /* symbol table entry */
|
||||
struct sbuf *sb_nxt; /* for freelist */
|
||||
} sbuf_t;
|
||||
|
||||
|
||||
/*
|
||||
* tree node
|
||||
*/
|
||||
typedef struct tnode {
|
||||
op_t tn_op; /* operator */
|
||||
type_t *tn_type; /* type */
|
||||
u_int tn_lvalue : 1; /* node is lvalue */
|
||||
u_int tn_cast : 1; /* if tn_op == CVT its an explicit cast */
|
||||
u_int tn_parn : 1; /* node parenthesized */
|
||||
union {
|
||||
struct {
|
||||
struct tnode *_tn_left; /* (left) operand */
|
||||
struct tnode *_tn_right; /* right operand */
|
||||
} tn_s;
|
||||
sym_t *_tn_sym; /* symbol if op == NAME */
|
||||
val_t *_tn_val; /* value if op == CON */
|
||||
strg_t *_tn_strg; /* string if op == STRING */
|
||||
} tn_u;
|
||||
} tnode_t;
|
||||
|
||||
#define tn_left tn_u.tn_s._tn_left
|
||||
#define tn_right tn_u.tn_s._tn_right
|
||||
#define tn_sym tn_u._tn_sym
|
||||
#define tn_val tn_u._tn_val
|
||||
#define tn_strg tn_u._tn_strg
|
||||
|
||||
/*
|
||||
* For nested declarations a stack exists, which holds all information
|
||||
* needed for the current level. dcs points to the top element of this
|
||||
* stack.
|
||||
*
|
||||
* ctx describes the context of the current declaration. Its value is
|
||||
* one of
|
||||
* EXTERN global declarations
|
||||
* MOS oder MOU declarations of struct or union members
|
||||
* ENUMCON declarations of enums
|
||||
* ARG declaration of arguments in old style function definitions
|
||||
* PARG declaration of arguments in function prototypes
|
||||
* AUTO declaration of local symbols
|
||||
* ABSTRACT abstract declarations (sizeof, casts)
|
||||
*
|
||||
*/
|
||||
typedef struct dinfo {
|
||||
tspec_t d_atyp; /* VOID, CHAR, INT, FLOAT or DOUBLE */
|
||||
tspec_t d_smod; /* SIGNED or UNSIGN */
|
||||
tspec_t d_lmod; /* SHORT, LONG or QUAD */
|
||||
scl_t d_scl; /* storage class */
|
||||
type_t *d_type; /* after deftyp() pointer to the type used
|
||||
for all declarators */
|
||||
sym_t *d_rdcsym; /* redeclared symbol */
|
||||
int d_offset; /* offset of next structure member */
|
||||
int d_stralign; /* alignment required for current structure */
|
||||
scl_t d_ctx; /* context of declaration */
|
||||
u_int d_const : 1; /* const in declaration specifiers */
|
||||
u_int d_volatile : 1; /* volatile in declaration specifiers */
|
||||
u_int d_inline : 1; /* inline in declaration specifiers */
|
||||
u_int d_mscl : 1; /* multiple storage classes */
|
||||
u_int d_terr : 1; /* invalid type combination */
|
||||
u_int d_nedecl : 1; /* 1 if at least a tag is declared */
|
||||
u_int d_vararg : 1; /* ... in current function decl. */
|
||||
u_int d_proto : 1; /* current funct. decl. is prototype */
|
||||
u_int d_notyp : 1; /* set if no type specifier was present */
|
||||
u_int d_asm : 1; /* set if d_ctx == AUTO and asm() present */
|
||||
type_t *d_tagtyp; /* tag during member declaration */
|
||||
sym_t *d_fargs; /* list of arguments during function def. */
|
||||
pos_t d_fdpos; /* position of function definition */
|
||||
sym_t *d_dlsyms; /* first symbol declared at this level */
|
||||
sym_t **d_ldlsym; /* points to s_dlnxt in last symbol decl.
|
||||
at this level */
|
||||
sym_t *d_fpsyms; /* symbols defined in prototype */
|
||||
struct dinfo *d_nxt; /* next level */
|
||||
} dinfo_t;
|
||||
|
||||
/*
|
||||
* Type of stack which is used for initialisation of aggregate types.
|
||||
*/
|
||||
typedef struct istk {
|
||||
type_t *i_type; /* type of initialisation */
|
||||
type_t *i_subt; /* type of next level */
|
||||
u_int i_brace : 1; /* need } for pop */
|
||||
u_int i_nolimit : 1; /* incomplete array type */
|
||||
u_int i_namedmem : 1; /* has c9x named members */
|
||||
sym_t *i_mem; /* next structure member */
|
||||
int i_cnt; /* # of remaining elements */
|
||||
struct istk *i_nxt; /* previous level */
|
||||
} istk_t;
|
||||
|
||||
/*
|
||||
* Used to collect information about pointers and qualifiers in
|
||||
* declarators.
|
||||
*/
|
||||
typedef struct pqinf {
|
||||
int p_pcnt; /* number of asterisks */
|
||||
u_int p_const : 1;
|
||||
u_int p_volatile : 1;
|
||||
struct pqinf *p_nxt;
|
||||
} pqinf_t;
|
||||
|
||||
/*
|
||||
* Case values are stored in a list of type clst_t.
|
||||
*/
|
||||
typedef struct clst {
|
||||
val_t cl_val;
|
||||
struct clst *cl_nxt;
|
||||
} clst_t;
|
||||
|
||||
/*
|
||||
* Used to keep informations about nested control statements.
|
||||
*/
|
||||
typedef struct cstk {
|
||||
int c_env; /* type of statement (T_IF, ...) */
|
||||
u_int c_loop : 1; /* continue && break are valid */
|
||||
u_int c_switch : 1; /* case && break are valid */
|
||||
u_int c_break : 1; /* loop/switch has break */
|
||||
u_int c_cont : 1; /* loop has continue */
|
||||
u_int c_default : 1; /* switch has default */
|
||||
u_int c_infinite : 1; /* break condition always false
|
||||
(for (;;), while (1)) */
|
||||
u_int c_rchif : 1; /* end of if-branch reached */
|
||||
u_int c_noretval : 1; /* had "return;" */
|
||||
u_int c_retval : 1; /* had "return (e);" */
|
||||
type_t *c_swtype; /* type of switch expression */
|
||||
clst_t *c_clst; /* list of case values */
|
||||
struct mbl *c_fexprm; /* saved memory for end of loop
|
||||
expression in for() */
|
||||
tnode_t *c_f3expr; /* end of loop expr in for() */
|
||||
pos_t c_fpos; /* position of end of loop expr */
|
||||
pos_t c_cfpos; /* same for csrc_pos */
|
||||
struct cstk *c_nxt; /* outer control statement */
|
||||
} cstk_t;
|
||||
|
||||
typedef struct {
|
||||
size_t lo;
|
||||
size_t hi;
|
||||
} range_t;
|
||||
|
||||
#include "externs1.h"
|
||||
|
||||
#define ERR_SETSIZE 1024
|
||||
#define __NERRBITS (sizeof(unsigned int))
|
||||
|
||||
typedef struct err_set {
|
||||
unsigned int errs_bits[(ERR_SETSIZE + __NERRBITS-1) / __NERRBITS];
|
||||
} err_set;
|
||||
|
||||
#define ERR_SET(n, p) \
|
||||
((p)->errs_bits[(n)/__NERRBITS] |= (1 << ((n) % __NERRBITS)))
|
||||
#define ERR_CLR(n, p) \
|
||||
((p)->errs_bits[(n)/__NERRBITS] &= ~(1 << ((n) % __NERRBITS)))
|
||||
#define ERR_ISSET(n, p) \
|
||||
((p)->errs_bits[(n)/__NERRBITS] & (1 << ((n) % __NERRBITS)))
|
||||
#define ERR_ZERO(p) (void)memset((p), 0, sizeof(*(p)))
|
||||
|
||||
#define LERROR(fmt, args...) lerror(__FILE__, __LINE__, fmt, ##args)
|
||||
|
||||
extern err_set msgset;
|
@ -1,230 +0,0 @@
|
||||
/* $NetBSD: main1.c,v 1.17 2006/11/08 18:31:15 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: main1.c,v 1.17 2006/11/08 18:31:15 christos Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "lint1.h"
|
||||
|
||||
/* set yydebug to 1*/
|
||||
int yflag;
|
||||
|
||||
/*
|
||||
* Print warnings if an assignment of an integertype to another integertype
|
||||
* causes an implicit narrowing conversion. If aflag is 1, these warnings
|
||||
* are printed only if the source type is at least as wide as long. If aflag
|
||||
* is greater than 1, they are always printed.
|
||||
*/
|
||||
int aflag;
|
||||
|
||||
/* Print a warning if a break statement cannot be reached. */
|
||||
int bflag;
|
||||
|
||||
/* Print warnings for pointer casts. */
|
||||
int cflag;
|
||||
|
||||
/* Print various debug information. */
|
||||
int dflag;
|
||||
|
||||
/* Perform stricter checking of enum types and operations on enum types. */
|
||||
int eflag;
|
||||
|
||||
/* Print complete pathnames, not only the basename. */
|
||||
int Fflag;
|
||||
|
||||
/* Enable some extensions of gcc */
|
||||
int gflag;
|
||||
|
||||
/* Treat warnings as errors */
|
||||
int wflag;
|
||||
|
||||
/*
|
||||
* Apply a number of heuristic tests to attempt to intuit bugs, improve
|
||||
* style, and reduce waste.
|
||||
*/
|
||||
int hflag;
|
||||
|
||||
/* Attempt to check portability to other dialects of C. */
|
||||
int pflag;
|
||||
|
||||
/*
|
||||
* In case of redeclarations/redefinitions print the location of the
|
||||
* previous declaration/definition.
|
||||
*/
|
||||
int rflag;
|
||||
|
||||
/* Strict ANSI C mode. */
|
||||
int sflag;
|
||||
|
||||
/* Traditional C mode. */
|
||||
int tflag;
|
||||
|
||||
/* Enable C9X extensions */
|
||||
int Sflag;
|
||||
/*
|
||||
* Complain about functions and external variables used and not defined,
|
||||
* or defined and not used.
|
||||
*/
|
||||
int uflag = 1;
|
||||
|
||||
/* Complain about unused function arguments. */
|
||||
int vflag = 1;
|
||||
|
||||
/* Complain about structures which are never defined. */
|
||||
int zflag = 1;
|
||||
|
||||
err_set msgset;
|
||||
|
||||
static void usage(void);
|
||||
|
||||
int main(int, char *[]);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
char *ptr;
|
||||
|
||||
ERR_ZERO(&msgset);
|
||||
while ((c = getopt(argc, argv, "abcdeghmprstuvwyzFSX:")) != -1) {
|
||||
switch (c) {
|
||||
case 'a': aflag++; break;
|
||||
case 'b': bflag = 1; break;
|
||||
case 'c': cflag = 1; break;
|
||||
case 'd': dflag = 1; break;
|
||||
case 'e': eflag = 1; break;
|
||||
case 'F': Fflag = 1; break;
|
||||
case 'g': gflag = 1; break;
|
||||
case 'h': hflag = 1; break;
|
||||
case 'p': pflag = 1; break;
|
||||
case 'r': rflag = 1; break;
|
||||
case 's': sflag = 1; break;
|
||||
case 'S': Sflag = 1; break;
|
||||
case 't': tflag = 1; break;
|
||||
case 'u': uflag = 0; break;
|
||||
case 'w': wflag = 1; break;
|
||||
case 'v': vflag = 0; break;
|
||||
case 'y': yflag = 1; break;
|
||||
case 'z': zflag = 0; break;
|
||||
|
||||
case 'm':
|
||||
msglist();
|
||||
return(0);
|
||||
|
||||
case 'X':
|
||||
for (ptr = strtok(optarg, ","); ptr;
|
||||
ptr = strtok(NULL, ",")) {
|
||||
char *eptr;
|
||||
long msg;
|
||||
|
||||
errno = 0;
|
||||
msg = strtol(ptr, &eptr, 0);
|
||||
if ((msg == LONG_MIN || msg == LONG_MAX) &&
|
||||
errno == ERANGE)
|
||||
err(1, "invalid error message id '%s'",
|
||||
ptr);
|
||||
if (*eptr || ptr == eptr || msg < 0 ||
|
||||
msg >= ERR_SETSIZE)
|
||||
errx(1, "invalid error message id '%s'",
|
||||
ptr);
|
||||
ERR_SET(msg, &msgset);
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
/* open the input file */
|
||||
if ((yyin = fopen(argv[0], "r")) == NULL)
|
||||
err(1, "cannot open '%s'", argv[0]);
|
||||
|
||||
/* initialize output */
|
||||
outopen(argv[1]);
|
||||
|
||||
if (yflag)
|
||||
yydebug = 1;
|
||||
|
||||
initmem();
|
||||
initdecl();
|
||||
initscan();
|
||||
initmtab();
|
||||
|
||||
yyparse();
|
||||
|
||||
/* Following warnings cannot be suppressed by LINTED */
|
||||
nowarn = 0;
|
||||
#ifdef DEBUG
|
||||
printf("%s, %d: nowarn = 0\n", curr_pos.p_file, curr_pos.p_line);
|
||||
#endif
|
||||
chkglsyms();
|
||||
|
||||
outclose();
|
||||
|
||||
return (nerr != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: lint1 [-abcdeghmprstuvwyzFS] [-X <id>[,<id>]... src dest\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
norecover(void)
|
||||
{
|
||||
/* cannot recover from previous errors */
|
||||
error(224);
|
||||
exit(1);
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD$
|
||||
#
|
||||
# Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Christos Zoulas.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
cat << \__EOF
|
||||
.\" $NetBSD$
|
||||
.\"
|
||||
.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Christos Zoulas.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd July 5, 2000
|
||||
.Dt LINT 7
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm lint
|
||||
.Nd Lint error message list
|
||||
.Sh DESCRIPTION
|
||||
The following is a list of message IDs and messages produced by
|
||||
.Xr lint 1 .
|
||||
It is intended to be used with
|
||||
.Fl X
|
||||
flag of
|
||||
.Xr lint 1 .
|
||||
.Bl -column -offset indent "XXXX"
|
||||
__EOF
|
||||
"$@" | sed -e 's/\\/\\e/g' -e "s/'/\\'/"
|
||||
echo ".El"
|
@ -1,365 +0,0 @@
|
||||
/* $NetBSD: mem1.c,v 1.7 2002/01/31 19:36:54 tv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: mem1.c,v 1.7 2002/01/31 19:36:54 tv Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <err.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lint1.h"
|
||||
|
||||
/*
|
||||
* Filenames allocated by fnalloc() and fnnalloc() are shared.
|
||||
*/
|
||||
typedef struct fn {
|
||||
char *fn_name;
|
||||
size_t fn_len;
|
||||
int fn_id;
|
||||
struct fn *fn_nxt;
|
||||
} fn_t;
|
||||
|
||||
static fn_t *fnames;
|
||||
|
||||
static fn_t *srchfn(const char *, size_t);
|
||||
|
||||
/*
|
||||
* Look for a Filename of length l.
|
||||
*/
|
||||
static fn_t *
|
||||
srchfn(const char *s, size_t len)
|
||||
{
|
||||
fn_t *fn;
|
||||
|
||||
for (fn = fnames; fn != NULL; fn = fn->fn_nxt) {
|
||||
if (fn->fn_len == len && memcmp(fn->fn_name, s, len) == 0)
|
||||
break;
|
||||
}
|
||||
return (fn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a shared string for filename s.
|
||||
*/
|
||||
const char *
|
||||
fnalloc(const char *s)
|
||||
{
|
||||
|
||||
return (s != NULL ? fnnalloc(s, strlen(s)) : NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
fnnalloc(const char *s, size_t len)
|
||||
{
|
||||
fn_t *fn;
|
||||
|
||||
static int nxt_id = 0;
|
||||
|
||||
if (s == NULL)
|
||||
return (NULL);
|
||||
|
||||
if ((fn = srchfn(s, len)) == NULL) {
|
||||
if ((fn = malloc(sizeof (fn_t))) == NULL)
|
||||
nomem();
|
||||
/* Do not used strdup() because string is not NUL-terminated.*/
|
||||
if ((fn->fn_name = malloc(len + 1)) == NULL)
|
||||
nomem();
|
||||
(void)memcpy(fn->fn_name, s, len);
|
||||
fn->fn_name[len] = '\0';
|
||||
fn->fn_len = len;
|
||||
fn->fn_id = nxt_id++;
|
||||
fn->fn_nxt = fnames;
|
||||
fnames = fn;
|
||||
/* Write id of this filename to the output file. */
|
||||
outclr();
|
||||
outint(fn->fn_id);
|
||||
outchar('s');
|
||||
outstrg(fn->fn_name);
|
||||
}
|
||||
return (fn->fn_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get id of a filename.
|
||||
*/
|
||||
int
|
||||
getfnid(const char *s)
|
||||
{
|
||||
fn_t *fn;
|
||||
|
||||
if (s == NULL || (fn = srchfn(s, strlen(s))) == NULL)
|
||||
return (-1);
|
||||
return (fn->fn_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Memory for declarations and other things which must be available
|
||||
* until the end of a block (or the end of the translation unit)
|
||||
* are associated with the level (mblklev) of the block (or with 0).
|
||||
* Because these memory is allocated in large blocks associated with
|
||||
* a given level it can be freed easily at the end of a block.
|
||||
*/
|
||||
#define ML_INC ((size_t)32) /* Increment for length of *mblks */
|
||||
|
||||
typedef struct mbl {
|
||||
void *blk; /* beginning of memory block */
|
||||
void *ffree; /* first free byte */
|
||||
size_t nfree; /* # of free bytes */
|
||||
size_t size; /* total size of memory block */
|
||||
struct mbl *nxt; /* next block */
|
||||
} mbl_t;
|
||||
|
||||
/*
|
||||
* Array of pointers to lists of memory blocks. mblklev is used as
|
||||
* index into this array.
|
||||
*/
|
||||
static mbl_t **mblks;
|
||||
|
||||
/* number of elements in *mblks */
|
||||
static size_t nmblks;
|
||||
|
||||
/* free list for memory blocks */
|
||||
static mbl_t *frmblks;
|
||||
|
||||
/* length of new allocated memory blocks */
|
||||
static size_t mblklen;
|
||||
|
||||
static void *xgetblk(mbl_t **, size_t);
|
||||
static void xfreeblk(mbl_t **);
|
||||
static mbl_t *xnewblk(void);
|
||||
|
||||
static mbl_t *
|
||||
xnewblk(void)
|
||||
{
|
||||
mbl_t *mb;
|
||||
int prot, flags;
|
||||
|
||||
if ((mb = malloc(sizeof (mbl_t))) == NULL)
|
||||
nomem();
|
||||
|
||||
/* use mmap instead of malloc to avoid malloc's size overhead */
|
||||
|
||||
prot = PROT_READ | PROT_WRITE;
|
||||
flags = MAP_ANON | MAP_PRIVATE;
|
||||
mb->blk = mmap(NULL, mblklen, prot, flags, -1, (off_t)0);
|
||||
if (mb->blk == (void *)MAP_FAILED)
|
||||
err(1, "can't map memory");
|
||||
|
||||
mb->size = mblklen;
|
||||
|
||||
return (mb);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate new memory. If the first block of the list has not enough
|
||||
* free space, or there is no first block, get a new block. The new
|
||||
* block is taken from the free list or, if there is no block on the
|
||||
* free list, is allocated using xnewblk(). If a new block is allocated
|
||||
* it is initialized with zero. Blocks taken from the free list are
|
||||
* zero'd in xfreeblk().
|
||||
*/
|
||||
static void *
|
||||
xgetblk(mbl_t **mbp, size_t s)
|
||||
{
|
||||
mbl_t *mb;
|
||||
void *p;
|
||||
size_t t = 0;
|
||||
|
||||
s = LINT_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;
|
||||
}
|
||||
mb->ffree = mb->blk;
|
||||
mb->nfree = mb->size;
|
||||
mb->nxt = *mbp;
|
||||
*mbp = mb;
|
||||
}
|
||||
p = mb->ffree;
|
||||
mb->ffree = (char *)mb->ffree + s;
|
||||
mb->nfree -= s;
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Move all blocks from list *fmbp to free list. For each block, set all
|
||||
* used memory to zero.
|
||||
*/
|
||||
static void
|
||||
xfreeblk(mbl_t **fmbp)
|
||||
{
|
||||
mbl_t *mb;
|
||||
|
||||
while ((mb = *fmbp) != NULL) {
|
||||
*fmbp = mb->nxt;
|
||||
mb->nxt = frmblks;
|
||||
frmblks = mb;
|
||||
(void)memset(mb->blk, 0, mb->size - mb->nfree);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
initmem(void)
|
||||
{
|
||||
int pgsz;
|
||||
|
||||
pgsz = getpagesize();
|
||||
mblklen = ((MBLKSIZ + pgsz - 1) / pgsz) * pgsz;
|
||||
|
||||
if ((mblks = calloc(nmblks = ML_INC, sizeof (mbl_t *))) == NULL)
|
||||
nomem();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Allocate memory associated with level l.
|
||||
*/
|
||||
void *
|
||||
getlblk(int l, size_t s)
|
||||
{
|
||||
|
||||
while (l >= nmblks) {
|
||||
if ((mblks = realloc(mblks, (nmblks + ML_INC) *
|
||||
sizeof (mbl_t *))) == NULL)
|
||||
nomem();
|
||||
(void)memset(&mblks[nmblks], 0, ML_INC * sizeof (mbl_t *));
|
||||
nmblks += ML_INC;
|
||||
}
|
||||
return (xgetblk(&mblks[l], s));
|
||||
}
|
||||
|
||||
void *
|
||||
getblk(size_t s)
|
||||
{
|
||||
|
||||
return (getlblk(mblklev, s));
|
||||
}
|
||||
|
||||
/*
|
||||
* Free all memory associated with level l.
|
||||
*/
|
||||
void
|
||||
freelblk(int l)
|
||||
{
|
||||
|
||||
xfreeblk(&mblks[l]);
|
||||
}
|
||||
|
||||
void
|
||||
freeblk(void)
|
||||
{
|
||||
|
||||
freelblk(mblklev);
|
||||
}
|
||||
|
||||
/*
|
||||
* tgetblk() returns memory which is associated with the current
|
||||
* expression.
|
||||
*/
|
||||
static mbl_t *tmblk;
|
||||
|
||||
void *
|
||||
tgetblk(size_t s)
|
||||
{
|
||||
|
||||
return (xgetblk(&tmblk, s));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get memory for a new tree node.
|
||||
*/
|
||||
tnode_t *
|
||||
getnode(void)
|
||||
{
|
||||
|
||||
return (tgetblk(sizeof (tnode_t)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Free all memory which is allocated by the current expression.
|
||||
*/
|
||||
void
|
||||
tfreeblk(void)
|
||||
{
|
||||
|
||||
xfreeblk(&tmblk);
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the memory which is used by the current expression. This memory
|
||||
* is not freed by the next tfreeblk() call. The pointer returned can be
|
||||
* used to restore the memory.
|
||||
*/
|
||||
mbl_t *
|
||||
tsave(void)
|
||||
{
|
||||
mbl_t *tmem;
|
||||
|
||||
tmem = tmblk;
|
||||
tmblk = NULL;
|
||||
return (tmem);
|
||||
}
|
||||
|
||||
/*
|
||||
* Free all memory used for the current expression and the memory used
|
||||
* be a previous expression and saved by tsave(). The next call to
|
||||
* tfreeblk() frees the restored memory.
|
||||
*/
|
||||
void
|
||||
trestor(mbl_t *tmem)
|
||||
{
|
||||
|
||||
tfreeblk();
|
||||
if (tmblk != NULL) {
|
||||
free(tmblk->blk);
|
||||
free(tmblk);
|
||||
}
|
||||
tmblk = tmem;
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
/* $NetBSD: op.h,v 1.2 1995/07/03 21:24:27 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Various information about operators
|
||||
*/
|
||||
typedef struct {
|
||||
u_int m_binary : 1; /* binary op. */
|
||||
u_int m_logop : 1; /* logical op., result is int */
|
||||
u_int m_rqint : 1; /* operands must have integer type */
|
||||
u_int m_rqsclt : 1; /* operands must have scalar type */
|
||||
u_int m_rqatyp : 1; /* operands must have arithmetic type */
|
||||
u_int m_fold : 1; /* operands should be folded */
|
||||
u_int m_vctx : 1; /* value context for left operand */
|
||||
u_int m_tctx : 1; /* test context for left operand */
|
||||
u_int m_balance : 1; /* op. requires balancing */
|
||||
u_int m_sideeff : 1; /* op. has side effect */
|
||||
u_int m_tlansiu : 1; /* warning if left op. is unsign. in ANSI C */
|
||||
u_int m_transiu : 1; /* warning if right op. is unsign. in ANSI C */
|
||||
u_int m_tpconf : 1; /* test possible precedence confusion */
|
||||
u_int m_comp : 1; /* op. performs comparison */
|
||||
u_int m_enumop : 1; /* valid operation on enums */
|
||||
u_int m_badeop : 1; /* dubious operation on enums */
|
||||
u_int m_eqwarn : 1; /* warning if on operand stems from == */
|
||||
const char *m_name; /* name of op. */
|
||||
} mod_t;
|
||||
|
||||
typedef enum {
|
||||
NOOP = 0,
|
||||
ARROW,
|
||||
POINT,
|
||||
NOT,
|
||||
COMPL,
|
||||
INC,
|
||||
DEC,
|
||||
INCBEF,
|
||||
DECBEF,
|
||||
INCAFT,
|
||||
DECAFT,
|
||||
UPLUS,
|
||||
UMINUS,
|
||||
STAR,
|
||||
AMPER,
|
||||
MULT,
|
||||
DIV,
|
||||
MOD,
|
||||
PLUS,
|
||||
MINUS,
|
||||
SHL,
|
||||
SHR,
|
||||
LT,
|
||||
LE,
|
||||
GT,
|
||||
GE,
|
||||
EQ,
|
||||
NE,
|
||||
AND,
|
||||
XOR,
|
||||
OR,
|
||||
LOGAND,
|
||||
LOGOR,
|
||||
QUEST,
|
||||
COLON,
|
||||
ASSIGN,
|
||||
MULASS,
|
||||
DIVASS,
|
||||
MODASS,
|
||||
ADDASS,
|
||||
SUBASS,
|
||||
SHLASS,
|
||||
SHRASS,
|
||||
ANDASS,
|
||||
XORASS,
|
||||
ORASS,
|
||||
NAME,
|
||||
CON,
|
||||
STRING,
|
||||
FSEL,
|
||||
CALL,
|
||||
COMMA,
|
||||
CVT,
|
||||
ICALL,
|
||||
LOAD,
|
||||
PUSH,
|
||||
RETURN,
|
||||
INIT, /* pseudo op, not used in trees */
|
||||
CASE, /* pseudo op, not used in trees */
|
||||
FARG /* pseudo op, not used in trees */
|
||||
#define NOPS ((int)FARG + 1)
|
||||
} op_t;
|
@ -1,143 +0,0 @@
|
||||
/* $NetBSD: param.h,v 1.4 1995/07/23 18:14:41 ragge Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Minimun size of string buffer. If this is not enough, the buffer
|
||||
* is enlarged in steps of STRBLEN bytes.
|
||||
*/
|
||||
#define STRBLEN 256
|
||||
|
||||
/*
|
||||
* This defines the size of memory blocks which are used to allocate
|
||||
* memory in larger chunks.
|
||||
*/
|
||||
#define MBLKSIZ ((size_t)0x4000)
|
||||
|
||||
/*
|
||||
* Sizes of hash tables
|
||||
* Should be a prime. Possible primes are
|
||||
* 307, 401, 503, 601, 701, 809, 907, 1009, 1103, 1201, 1301, 1409, 1511.
|
||||
*
|
||||
* HSHSIZ1 symbol table 1st pass
|
||||
* HSHSIZ2 symbol table 2nd pass
|
||||
* THSHSIZ2 type table 2nd pass
|
||||
*/
|
||||
#define HSHSIZ1 503
|
||||
#define HSHSIZ2 1009
|
||||
#define THSHSIZ2 1009
|
||||
|
||||
/*
|
||||
* Should be set to 1 if the difference of two pointers is of type long
|
||||
* or the value of sizeof is of type unsigned long.
|
||||
*/
|
||||
#if __amd64__
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
#elif __alpha__
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
#elif __i386__
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
#elif __m68k__
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
#elif __ns32k__
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
#elif __powerpc__
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
#elif __riscv
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
#elif __sparc__
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
#elif __sparc64__
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
#elif __vax__
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
#elif __arm__
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
#elif __mips__
|
||||
#define PTRDIFF_IS_LONG 0
|
||||
#define SIZEOF_IS_ULONG 0
|
||||
#elif __aarch64__
|
||||
#define PTRDIFF_IS_LONG 1
|
||||
#define SIZEOF_IS_ULONG 1
|
||||
#else
|
||||
#error unknown machine type
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Make sure this matches wchar_t.
|
||||
*/
|
||||
#define WCHAR SHORT
|
||||
|
||||
#ifndef __GNUC__
|
||||
#ifndef lint
|
||||
#ifndef QUAD_MAX /* necessary for mkdep */
|
||||
#define QUAD_MAX LONG_MAX
|
||||
#define QUAD_MIN LONG_MIN
|
||||
#define UQUAD_MAX ULONG_MAX
|
||||
#endif
|
||||
typedef long quad_t;
|
||||
typedef u_long u_quad_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* long double only in ANSI C.
|
||||
*/
|
||||
#ifdef __STDC__
|
||||
typedef long double ldbl_t;
|
||||
#else
|
||||
typedef double ldbl_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,14 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.2 1995/07/03 21:24:39 cgd Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../lint1
|
||||
|
||||
PROG= lint2
|
||||
SRCS= main2.c hash.c read.c mem.c mem2.c chk.c msg.c emit.c emit2.c inittyp.c
|
||||
MAN=
|
||||
CFLAGS+=-I${.CURDIR}/../lint1
|
||||
LINTFLAGS=-abehrz
|
||||
|
||||
BINDIR= ${LIBEXECDIR}
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,17 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
File diff suppressed because it is too large
Load Diff
@ -1,300 +0,0 @@
|
||||
/* $NetBSD: emit2.c,v 1.8 2002/01/21 19:49:52 tv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: emit2.c,v 1.8 2002/01/21 19:49:52 tv Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <err.h>
|
||||
|
||||
#include "lint2.h"
|
||||
|
||||
static void outtype(type_t *);
|
||||
static void outdef(hte_t *, sym_t *);
|
||||
static void dumpname(hte_t *);
|
||||
static void outfiles(void);
|
||||
|
||||
/*
|
||||
* Write type into the output buffer.
|
||||
*/
|
||||
static void
|
||||
outtype(type_t *tp)
|
||||
{
|
||||
int t, s, na;
|
||||
tspec_t ts;
|
||||
type_t **ap;
|
||||
|
||||
while (tp != NULL) {
|
||||
if ((ts = tp->t_tspec) == INT && tp->t_isenum)
|
||||
ts = ENUM;
|
||||
switch (ts) {
|
||||
case CHAR: t = 'C'; s = '\0'; break;
|
||||
case SCHAR: t = 'C'; s = 's'; break;
|
||||
case UCHAR: t = 'C'; s = 'u'; break;
|
||||
case SHORT: t = 'S'; s = '\0'; break;
|
||||
case USHORT: t = 'S'; s = 'u'; break;
|
||||
case INT: t = 'I'; s = '\0'; break;
|
||||
case UINT: t = 'I'; s = 'u'; break;
|
||||
case LONG: t = 'L'; s = '\0'; break;
|
||||
case ULONG: t = 'L'; s = 'u'; break;
|
||||
case QUAD: t = 'Q'; s = '\0'; break;
|
||||
case UQUAD: t = 'Q'; s = 'u'; break;
|
||||
case FLOAT: t = 'D'; s = 's'; break;
|
||||
case DOUBLE: t = 'D'; s = '\0'; break;
|
||||
case LDOUBLE: t = 'D'; s = 'l'; break;
|
||||
case VOID: t = 'V'; s = '\0'; break;
|
||||
case PTR: t = 'P'; s = '\0'; break;
|
||||
case ARRAY: t = 'A'; s = '\0'; break;
|
||||
case ENUM: t = 'T'; s = 'e'; break;
|
||||
case STRUCT: t = 'T'; s = 's'; break;
|
||||
case UNION: t = 'T'; s = 'u'; break;
|
||||
case FUNC:
|
||||
if (tp->t_args != NULL && !tp->t_proto) {
|
||||
t = 'f';
|
||||
} else {
|
||||
t = 'F';
|
||||
}
|
||||
s = '\0';
|
||||
break;
|
||||
default:
|
||||
errx(1, "internal error: outtype() 1");
|
||||
}
|
||||
if (tp->t_const)
|
||||
outchar('c');
|
||||
if (tp->t_volatile)
|
||||
outchar('v');
|
||||
if (s != '\0')
|
||||
outchar(s);
|
||||
outchar(t);
|
||||
if (ts == ARRAY) {
|
||||
outint(tp->t_dim);
|
||||
} else if (ts == ENUM || ts == STRUCT || ts == UNION) {
|
||||
if (tp->t_istag) {
|
||||
outint(1);
|
||||
outname(tp->t_tag->h_name);
|
||||
} else if (tp->t_istynam) {
|
||||
outint(2);
|
||||
outname(tp->t_tynam->h_name);
|
||||
} else if (tp->t_isuniqpos) {
|
||||
outint(3);
|
||||
outint(tp->t_uniqpos.p_line);
|
||||
outchar('.');
|
||||
outint(tp->t_uniqpos.p_file);
|
||||
outchar('.');
|
||||
outint(tp->t_uniqpos.p_uniq);
|
||||
} else
|
||||
errx(1, "internal error: outtype() 2");
|
||||
} else if (ts == FUNC && tp->t_args != NULL) {
|
||||
na = 0;
|
||||
for (ap = tp->t_args; *ap != NULL; ap++)
|
||||
na++;
|
||||
if (tp->t_vararg)
|
||||
na++;
|
||||
outint(na);
|
||||
for (ap = tp->t_args; *ap != NULL; ap++)
|
||||
outtype(*ap);
|
||||
if (tp->t_vararg)
|
||||
outchar('E');
|
||||
}
|
||||
tp = tp->t_subt;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a definition.
|
||||
*/
|
||||
static void
|
||||
outdef(hte_t *hte, sym_t *sym)
|
||||
{
|
||||
|
||||
/* reset output buffer */
|
||||
outclr();
|
||||
|
||||
/* line number in C source file */
|
||||
outint(0);
|
||||
|
||||
/* this is a definition */
|
||||
outchar('d');
|
||||
|
||||
/* index of file where symbol was defined and line number of def. */
|
||||
outint(0);
|
||||
outchar('.');
|
||||
outint(0);
|
||||
|
||||
/* flags */
|
||||
if (sym->s_va) {
|
||||
outchar('v'); /* varargs */
|
||||
outint(sym->s_nva);
|
||||
}
|
||||
if (sym->s_scfl) {
|
||||
outchar('S'); /* scanflike */
|
||||
outint(sym->s_nscfl);
|
||||
}
|
||||
if (sym->s_prfl) {
|
||||
outchar('P'); /* printflike */
|
||||
outint(sym->s_nprfl);
|
||||
}
|
||||
/* definition or tentative definition */
|
||||
outchar(sym->s_def == DEF ? 'd' : 't');
|
||||
if (TP(sym->s_type)->t_tspec == FUNC) {
|
||||
if (sym->s_rval)
|
||||
outchar('r'); /* fkt. has return value */
|
||||
if (sym->s_osdef)
|
||||
outchar('o'); /* old style definition */
|
||||
}
|
||||
outchar('u'); /* used (no warning if not used) */
|
||||
|
||||
/* name */
|
||||
outname(hte->h_name);
|
||||
|
||||
/* type */
|
||||
outtype(TP(sym->s_type));
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the first definition of a name into the lint library.
|
||||
*/
|
||||
static void
|
||||
dumpname(hte_t *hte)
|
||||
{
|
||||
sym_t *sym, *def;
|
||||
|
||||
/* static and undefined symbols are not written */
|
||||
if (hte->h_static || !hte->h_def)
|
||||
return;
|
||||
|
||||
/*
|
||||
* If there is a definition, write it. Otherwise write a tentative
|
||||
* definition. This is necessary because more than one tentative
|
||||
* definition is allowed (except with sflag).
|
||||
*/
|
||||
def = NULL;
|
||||
for (sym = hte->h_syms; sym != NULL; sym = sym->s_nxt) {
|
||||
if (sym->s_def == DEF) {
|
||||
def = sym;
|
||||
break;
|
||||
}
|
||||
if (sym->s_def == TDEF && def == NULL)
|
||||
def = sym;
|
||||
}
|
||||
if (def == NULL)
|
||||
errx(1, "internal error: dumpname() %s", hte->h_name);
|
||||
|
||||
outdef(hte, def);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a new lint library.
|
||||
*/
|
||||
void
|
||||
outlib(const char *name)
|
||||
{
|
||||
/* Open of output file and initialisation of the output buffer */
|
||||
outopen(name);
|
||||
|
||||
/* write name of lint library */
|
||||
outsrc(name);
|
||||
|
||||
/* name of lint lib has index 0 */
|
||||
outclr();
|
||||
outint(0);
|
||||
outchar('s');
|
||||
outstrg(name);
|
||||
|
||||
/*
|
||||
* print the names of all files references by unnamed
|
||||
* struct/union/enum declarations.
|
||||
*/
|
||||
outfiles();
|
||||
|
||||
/* write all definitions with external linkage */
|
||||
forall(dumpname);
|
||||
|
||||
/* close the output */
|
||||
outclose();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out the name of a file referenced by a type.
|
||||
*/
|
||||
struct outflist {
|
||||
short ofl_num;
|
||||
struct outflist *ofl_next;
|
||||
};
|
||||
static struct outflist *outflist;
|
||||
|
||||
int
|
||||
addoutfile(short num)
|
||||
{
|
||||
struct outflist *ofl, **pofl;
|
||||
int i;
|
||||
|
||||
ofl = outflist;
|
||||
pofl = &outflist;
|
||||
i = 1; /* library is 0 */
|
||||
|
||||
while (ofl != NULL) {
|
||||
if (ofl->ofl_num == num)
|
||||
break;
|
||||
|
||||
pofl = &ofl->ofl_next;
|
||||
ofl = ofl->ofl_next;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (ofl == NULL) {
|
||||
ofl = *pofl = xmalloc(sizeof (struct outflist));
|
||||
ofl->ofl_num = num;
|
||||
ofl->ofl_next = NULL;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
static void
|
||||
outfiles(void)
|
||||
{
|
||||
struct outflist *ofl;
|
||||
int i;
|
||||
|
||||
for (ofl = outflist, i = 1; ofl != NULL; ofl = ofl->ofl_next, i++) {
|
||||
/* reset output buffer */
|
||||
outclr();
|
||||
|
||||
outint(i);
|
||||
outchar('s');
|
||||
outstrg(fnames[ofl->ofl_num]);
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
/* $NetBSD: externs2.h,v 1.7 2001/05/28 12:40:38 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* main.c
|
||||
*/
|
||||
extern int xflag;
|
||||
extern int uflag;
|
||||
extern int Cflag;
|
||||
extern const char *libname;
|
||||
extern int sflag;
|
||||
extern int tflag;
|
||||
extern int Hflag;
|
||||
extern int hflag;
|
||||
extern int Fflag;
|
||||
|
||||
|
||||
/*
|
||||
* hash.c
|
||||
*/
|
||||
extern void _inithash(hte_t ***);
|
||||
extern hte_t *_hsearch(hte_t **, const char *, int);
|
||||
extern void _forall(hte_t **, void (*)(hte_t *));
|
||||
extern void _destroyhash(hte_t **);
|
||||
|
||||
#define inithash() _inithash(NULL);
|
||||
#define hsearch(a, b) _hsearch(NULL, (a), (b))
|
||||
#define forall(a) _forall(NULL, (a))
|
||||
|
||||
/*
|
||||
* read.c
|
||||
*/
|
||||
extern const char **fnames;
|
||||
extern type_t **tlst;
|
||||
|
||||
extern void readfile(const char *);
|
||||
extern void mkstatic(hte_t *);
|
||||
|
||||
/*
|
||||
* mem2.c
|
||||
*/
|
||||
extern void initmem(void);
|
||||
extern void *xalloc(size_t);
|
||||
|
||||
/*
|
||||
* chk.c
|
||||
*/
|
||||
extern void inittyp(void);
|
||||
extern void mainused(void);
|
||||
extern void chkname(hte_t *);
|
||||
|
||||
/*
|
||||
* msg.c
|
||||
*/
|
||||
extern void msg(int, ...);
|
||||
extern const char *mkpos(pos_t *);
|
||||
|
||||
/*
|
||||
* emit2.c
|
||||
*/
|
||||
extern void outlib(const char *);
|
||||
extern int addoutfile(short);
|
@ -1,166 +0,0 @@
|
||||
/* $NetBSD: hash.c,v 1.7 2002/01/21 19:49:52 tv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: hash.c,v 1.7 2002/01/21 19:49:52 tv Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* XXX Really need a generalized hash table package
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lint2.h"
|
||||
|
||||
/* pointer to hash table, initialized in inithash() */
|
||||
static hte_t **htab;
|
||||
|
||||
static int hash(const char *);
|
||||
|
||||
/*
|
||||
* Initialize hash table.
|
||||
*/
|
||||
void
|
||||
_inithash(hte_t ***tablep)
|
||||
{
|
||||
|
||||
if (tablep == NULL)
|
||||
tablep = &htab;
|
||||
|
||||
*tablep = xcalloc(HSHSIZ2, sizeof (hte_t *));
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute hash value from a string.
|
||||
*/
|
||||
static int
|
||||
hash(const char *s)
|
||||
{
|
||||
u_int v;
|
||||
const u_char *us;
|
||||
|
||||
v = 0;
|
||||
for (us = (const u_char *)s; *us != '\0'; us++) {
|
||||
v = (v << sizeof (v)) + *us;
|
||||
v ^= v >> (sizeof (v) * CHAR_BIT - sizeof (v));
|
||||
}
|
||||
return (v % HSHSIZ2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for a hash table entry. If no hash table entry for the
|
||||
* given name exists and mknew is set, create a new one.
|
||||
*/
|
||||
hte_t *
|
||||
_hsearch(hte_t **table, const char *s, int mknew)
|
||||
{
|
||||
int h;
|
||||
hte_t *hte;
|
||||
|
||||
if (table == NULL)
|
||||
table = htab;
|
||||
|
||||
h = hash(s);
|
||||
for (hte = table[h]; hte != NULL; hte = hte->h_link) {
|
||||
if (strcmp(hte->h_name, s) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (hte != NULL || !mknew)
|
||||
return (hte);
|
||||
|
||||
/* create a new hte */
|
||||
hte = xmalloc(sizeof (hte_t));
|
||||
hte->h_name = xstrdup(s);
|
||||
hte->h_used = 0;
|
||||
hte->h_def = 0;
|
||||
hte->h_static = 0;
|
||||
hte->h_syms = NULL;
|
||||
hte->h_lsym = &hte->h_syms;
|
||||
hte->h_calls = NULL;
|
||||
hte->h_lcall = &hte->h_calls;
|
||||
hte->h_usyms = NULL;
|
||||
hte->h_lusym = &hte->h_usyms;
|
||||
hte->h_link = table[h];
|
||||
hte->h_hte = NULL;
|
||||
table[h] = hte;
|
||||
|
||||
return (hte);
|
||||
}
|
||||
|
||||
/*
|
||||
* Call function f for each name in the hash table.
|
||||
*/
|
||||
void
|
||||
_forall(hte_t **table, void (*f)(hte_t *))
|
||||
{
|
||||
int i;
|
||||
hte_t *hte;
|
||||
|
||||
if (table == NULL)
|
||||
table = htab;
|
||||
|
||||
for (i = 0; i < HSHSIZ2; i++) {
|
||||
for (hte = table[i]; hte != NULL; hte = hte->h_link)
|
||||
(*f)(hte);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Free all contents of the hash table that this module allocated.
|
||||
*/
|
||||
void
|
||||
_destroyhash(hte_t **table)
|
||||
{
|
||||
int i;
|
||||
hte_t *hte, *nexthte;
|
||||
|
||||
if (table == NULL)
|
||||
err(1, "_destroyhash called on main hash table");
|
||||
|
||||
for (i = 0; i < HSHSIZ2; i++) {
|
||||
for (hte = table[i]; hte != NULL; hte = nexthte) {
|
||||
free((void *)hte->h_name);
|
||||
nexthte = hte->h_link;
|
||||
free(hte);
|
||||
}
|
||||
}
|
||||
free(table);
|
||||
}
|
@ -1,188 +0,0 @@
|
||||
/* $NetBSD: lint2.h,v 1.5 2000/06/14 06:49:23 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "lint.h"
|
||||
|
||||
/*
|
||||
* Types are described by structures of type type_t.
|
||||
*/
|
||||
typedef struct type {
|
||||
tspec_t t_tspec; /* type specifier */
|
||||
u_int t_const : 1; /* constant */
|
||||
u_int t_volatile : 1; /* volatile */
|
||||
u_int t_vararg : 1; /* function has variable number of arguments */
|
||||
u_int t_isenum : 1; /* enum type */
|
||||
u_int t_proto : 1; /* this is a prototype */
|
||||
u_int t_istag : 1; /* tag with _t_tag valid */
|
||||
u_int t_istynam : 1; /* tag with _t_tynam valid */
|
||||
u_int t_isuniqpos : 1; /* tag with _t_uniqpos valid */
|
||||
union {
|
||||
int _t_dim; /* if the type is an ARRAY than this
|
||||
is the dimension of the array. */
|
||||
struct hte *_t_tag; /* hash table entry of tag if
|
||||
t_isenum, STRUCT or UNION */
|
||||
struct hte *_t_tynam; /* hash table entry of typename if
|
||||
t_isenum, STRUCT or UNION */
|
||||
struct {
|
||||
int p_line;
|
||||
short p_file;
|
||||
int p_uniq;
|
||||
} _t_uniqpos; /* unique position, for untagged
|
||||
untyped STRUCTs, UNIONS, and ENUMs,
|
||||
if t_isuniqpos */
|
||||
struct type **_t_args; /* list of argument types if this
|
||||
is a prototype */
|
||||
} t_u;
|
||||
struct type *t_subt; /* indirected type (array element, pointed to
|
||||
type, type of return value) */
|
||||
} type_t;
|
||||
|
||||
#define t_dim t_u._t_dim
|
||||
#define t_tag t_u._t_tag
|
||||
#define t_tynam t_u._t_tynam
|
||||
#define t_uniqpos t_u._t_uniqpos
|
||||
#define t_args t_u._t_args
|
||||
|
||||
/*
|
||||
* argument information
|
||||
*
|
||||
* Such a structure is created for each argument of a function call
|
||||
* which is an integer constant or a constant string.
|
||||
*/
|
||||
typedef struct arginf {
|
||||
int a_num; /* # of argument (1..) */
|
||||
u_int a_zero : 1; /* argument is 0 */
|
||||
u_int a_pcon : 1; /* msb of argument is not set */
|
||||
u_int a_ncon : 1; /* msb of argument is set */
|
||||
u_int a_fmt : 1; /* a_fstrg points to format string */
|
||||
char *a_fstrg; /* format string */
|
||||
struct arginf *a_nxt; /* information for next const. argument */
|
||||
} arginf_t;
|
||||
|
||||
/*
|
||||
* Keeps information about position in source file.
|
||||
*/
|
||||
typedef struct {
|
||||
u_short p_src; /* index of name of translation unit
|
||||
(the name which was specified at the
|
||||
command line) */
|
||||
u_short p_line; /* line number in p_src */
|
||||
u_short p_isrc; /* index of (included) file */
|
||||
u_short p_iline; /* line number in p_iline */
|
||||
} pos_t;
|
||||
|
||||
/*
|
||||
* Used for definitions and declarations
|
||||
*
|
||||
* To save memory, variable sized structures are used. If
|
||||
* all s_va, s_prfl and s_scfl are not set, the memory allocated
|
||||
* for a symbol is only large enough to keep the first member of
|
||||
* struct sym, s_s.
|
||||
*/
|
||||
typedef struct sym {
|
||||
struct {
|
||||
pos_t s_pos; /* pos of def./decl. */
|
||||
#ifndef lint
|
||||
u_int s_def : 3; /* DECL, TDEF or DEF */
|
||||
#else
|
||||
def_t s_def;
|
||||
#endif
|
||||
u_int s_rval : 1; /* function has return value */
|
||||
u_int s_osdef : 1; /* old style function definition */
|
||||
u_int s_static : 1; /* symbol is static */
|
||||
u_int s_va : 1; /* check only first s_nva arguments */
|
||||
u_int s_prfl : 1; /* printflike */
|
||||
u_int s_scfl : 1; /* scanflike */
|
||||
u_short s_type; /* type */
|
||||
struct sym *s_nxt; /* next symbol with same name */
|
||||
} s_s;
|
||||
short s_nva;
|
||||
short s_nprfl;
|
||||
short s_nscfl;
|
||||
} sym_t;
|
||||
|
||||
#define s_pos s_s.s_pos
|
||||
#define s_rval s_s.s_rval
|
||||
#define s_osdef s_s.s_osdef
|
||||
#define s_static s_s.s_static
|
||||
#define s_def s_s.s_def
|
||||
#define s_va s_s.s_va
|
||||
#define s_prfl s_s.s_prfl
|
||||
#define s_scfl s_s.s_scfl
|
||||
#define s_type s_s.s_type
|
||||
#define s_nxt s_s.s_nxt
|
||||
|
||||
/*
|
||||
* Used to store informations about function calls.
|
||||
*/
|
||||
typedef struct fcall {
|
||||
pos_t f_pos; /* position of call */
|
||||
u_int f_rused : 1; /* return value used */
|
||||
u_int f_rdisc : 1; /* return value discarded (casted to void) */
|
||||
u_short f_type; /* types of expected return value and args */
|
||||
arginf_t *f_args; /* information about constant arguments */
|
||||
struct fcall *f_nxt; /* next call of same function */
|
||||
} fcall_t;
|
||||
|
||||
/*
|
||||
* Used to store information about usage of symbols other
|
||||
* than for function calls.
|
||||
*/
|
||||
typedef struct usym {
|
||||
pos_t u_pos; /* position */
|
||||
struct usym *u_nxt; /* next usage */
|
||||
} usym_t;
|
||||
|
||||
/*
|
||||
* hash table entry
|
||||
*/
|
||||
typedef struct hte {
|
||||
const char *h_name; /* name */
|
||||
u_int h_used : 1; /* symbol is used */
|
||||
u_int h_def : 1; /* symbol is defined */
|
||||
u_int h_static : 1; /* static symbol */
|
||||
sym_t *h_syms; /* declarations and definitions */
|
||||
sym_t **h_lsym; /* points to s_nxt of last decl./def. */
|
||||
fcall_t *h_calls; /* function calls */
|
||||
fcall_t **h_lcall; /* points to f_nxt of last call */
|
||||
usym_t *h_usyms; /* usage info */
|
||||
usym_t **h_lusym; /* points to u_nxt of last usage info */
|
||||
struct hte *h_link; /* next hte with same hash function */
|
||||
struct hte *h_hte; /* pointer to other htes (for renames */
|
||||
} hte_t;
|
||||
|
||||
/* maps type indices into pointers to type structs */
|
||||
#define TP(idx) (tlst[idx])
|
||||
|
||||
#include "externs2.h"
|
@ -1,191 +0,0 @@
|
||||
/* $NetBSD: main2.c,v 1.5 2001/11/21 19:14:26 wiz Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: main2.c,v 1.5 2001/11/21 19:14:26 wiz Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lint2.h"
|
||||
|
||||
/* warnings for symbols which are declared but not defined or used */
|
||||
int xflag;
|
||||
|
||||
/*
|
||||
* warnings for symbols which are used and not defined or defined
|
||||
* and not used
|
||||
*/
|
||||
int uflag = 1;
|
||||
|
||||
/* Create a lint library in the current directory with name libname. */
|
||||
int Cflag;
|
||||
const char *libname;
|
||||
|
||||
int pflag;
|
||||
|
||||
/*
|
||||
* warnings for (tentative) definitions of the same name in more than
|
||||
* one translation unit
|
||||
*/
|
||||
int sflag;
|
||||
|
||||
int tflag;
|
||||
|
||||
/*
|
||||
* If a complaint stems from an included file, print the name of the included
|
||||
* file instead of the name spezified at the command line followed by '?'
|
||||
*/
|
||||
int Hflag;
|
||||
|
||||
int hflag;
|
||||
|
||||
/* Print full path names, not only the last component */
|
||||
int Fflag;
|
||||
|
||||
/*
|
||||
* List of libraries (from -l flag). These libraries are read after all
|
||||
* other input files has been read and, for Cflag, after the new lint library
|
||||
* has been written.
|
||||
*/
|
||||
const char **libs;
|
||||
|
||||
static void usage(void);
|
||||
|
||||
int main(int, char *[]);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int c, i;
|
||||
size_t len;
|
||||
char *lname;
|
||||
|
||||
libs = xcalloc(1, sizeof (char *));
|
||||
|
||||
opterr = 0;
|
||||
while ((c = getopt(argc, argv, "hpstxuC:HFl:")) != -1) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
sflag = 1;
|
||||
break;
|
||||
case 't':
|
||||
tflag = 1;
|
||||
break;
|
||||
case 'u':
|
||||
uflag = 0;
|
||||
break;
|
||||
case 'x':
|
||||
xflag = 1;
|
||||
break;
|
||||
case 'p':
|
||||
pflag = 1;
|
||||
break;
|
||||
case 'C':
|
||||
len = strlen(optarg);
|
||||
lname = xmalloc(len + 10);
|
||||
(void)sprintf(lname, "llib-l%s.ln", optarg);
|
||||
libname = lname;
|
||||
Cflag = 1;
|
||||
uflag = 0;
|
||||
break;
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
break;
|
||||
case 'h':
|
||||
hflag = 1;
|
||||
break;
|
||||
case 'F':
|
||||
Fflag = 1;
|
||||
break;
|
||||
case 'l':
|
||||
for (i = 0; libs[i] != NULL; i++)
|
||||
continue;
|
||||
libs = xrealloc(libs, (i + 2) * sizeof (char *));
|
||||
libs[i] = xstrdup(optarg);
|
||||
libs[i + 1] = NULL;
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc == 0)
|
||||
usage();
|
||||
|
||||
initmem();
|
||||
|
||||
/* initialize hash table */
|
||||
inithash();
|
||||
|
||||
inittyp();
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
readfile(argv[i]);
|
||||
|
||||
/* write the lint library */
|
||||
if (Cflag) {
|
||||
forall(mkstatic);
|
||||
outlib(libname);
|
||||
}
|
||||
|
||||
/* read additional libraries */
|
||||
for (i = 0; libs[i] != NULL; i++)
|
||||
readfile(libs[i]);
|
||||
|
||||
forall(mkstatic);
|
||||
|
||||
mainused();
|
||||
|
||||
/* perform all tests */
|
||||
forall(chkname);
|
||||
|
||||
exit(0);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: lint2 -hpstxuHF -Clib -l lib ... src1 ...\n");
|
||||
exit(1);
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
/* $NetBSD: mem2.c,v 1.6 2002/01/21 19:49:52 tv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: mem2.c,v 1.6 2002/01/21 19:49:52 tv Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <err.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lint2.h"
|
||||
|
||||
/* length of new allocated memory blocks */
|
||||
static size_t mblklen;
|
||||
|
||||
/* offset of next free byte in mbuf */
|
||||
static size_t nxtfree;
|
||||
|
||||
/* current buffer to server memory requests from */
|
||||
static void *mbuf;
|
||||
|
||||
void
|
||||
initmem(void)
|
||||
{
|
||||
int pgsz;
|
||||
|
||||
pgsz = getpagesize();
|
||||
mblklen = ((MBLKSIZ + pgsz - 1) / pgsz) * pgsz;
|
||||
|
||||
nxtfree = mblklen;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate memory in large chunks to avoid space and time overhead of
|
||||
* malloc(). This is possible because memory allocated by xalloc()
|
||||
* need never to be freed.
|
||||
*/
|
||||
void *
|
||||
xalloc(size_t sz)
|
||||
{
|
||||
void *ptr;
|
||||
int prot, flags;
|
||||
|
||||
/* Align to at least 8 bytes. */
|
||||
sz = (sz + 7) & ~7L;
|
||||
if (nxtfree + sz > mblklen) {
|
||||
/* use mmap() instead of malloc() to avoid malloc overhead. */
|
||||
prot = PROT_READ | PROT_WRITE;
|
||||
flags = MAP_ANON | MAP_PRIVATE;
|
||||
mbuf = mmap(NULL, mblklen, prot, flags, -1, (off_t)0);
|
||||
if (mbuf == (void *)MAP_FAILED)
|
||||
err(1, "can't map memory");
|
||||
(void)memset(mbuf, 0, mblklen);
|
||||
nxtfree = 0;
|
||||
}
|
||||
|
||||
ptr = (char *)mbuf + nxtfree;
|
||||
nxtfree += sz;
|
||||
|
||||
return (ptr);
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
/* $NetBSD: msg.c,v 1.6 2002/01/21 19:49:52 tv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: msg.c,v 1.6 2002/01/21 19:49:52 tv Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lint2.h"
|
||||
|
||||
static const char *msgs[] = {
|
||||
"%s used( %s ), but not defined", /* 0 */
|
||||
"%s defined( %s ), but never used", /* 1 */
|
||||
"%s declared( %s ), but never used or defined", /* 2 */
|
||||
"%s multiply defined \t%s :: %s", /* 3 */
|
||||
"%s value used inconsistently \t%s :: %s", /* 4 */
|
||||
"%s value declared inconsistently \t%s :: %s", /* 5 */
|
||||
"%s, arg %d used inconsistently \t%s :: %s", /* 6 */
|
||||
"%s: variable # of args \t%s :: %s", /* 7 */
|
||||
"%s returns value which is always ignored", /* 8 */
|
||||
"%s returns value which is sometimes ignored", /* 9 */
|
||||
"%s value is used( %s ), but none returned", /* 10 */
|
||||
"%s, arg %d declared inconsistently \t%s :: %s", /* 11 */
|
||||
"%s: variable # of args declared \t%s :: %s", /* 12 */
|
||||
"%s: malformed format string \t%s", /* 13 */
|
||||
"%s, arg %d inconsistent with format \t%s", /* 14 */
|
||||
"%s: too few args for format \t%s", /* 15 */
|
||||
"%s: too many args for format \t%s", /* 16 */
|
||||
"%s function value must be declared before use \t%s :: %s",/* 17 */
|
||||
"%s renamed multiple times \t%s :: %s", /* 18 */
|
||||
};
|
||||
|
||||
static const char *lbasename(const char *);
|
||||
|
||||
void
|
||||
msg(int n, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, n);
|
||||
|
||||
(void)vprintf(msgs[n], ap);
|
||||
(void)printf("\n");
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a pointer to the last component of a path.
|
||||
*/
|
||||
static const char *
|
||||
lbasename(const char *path)
|
||||
{
|
||||
const char *cp, *cp1, *cp2;
|
||||
|
||||
if (Fflag)
|
||||
return (path);
|
||||
|
||||
cp = cp1 = cp2 = path;
|
||||
while (*cp != '\0') {
|
||||
if (*cp++ == '/') {
|
||||
cp2 = cp1;
|
||||
cp1 = cp;
|
||||
}
|
||||
}
|
||||
return (*cp1 == '\0' ? cp2 : cp1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a string which describes a position in a source file.
|
||||
*/
|
||||
const char *
|
||||
mkpos(pos_t *posp)
|
||||
{
|
||||
size_t len;
|
||||
const char *fn;
|
||||
static char *buf;
|
||||
static size_t blen = 0;
|
||||
int qm, src, line;
|
||||
|
||||
if (Hflag && posp->p_src != posp->p_isrc) {
|
||||
src = posp->p_isrc;
|
||||
line = posp->p_iline;
|
||||
} else {
|
||||
src = posp->p_src;
|
||||
line = posp->p_line;
|
||||
}
|
||||
qm = !Hflag && posp->p_src != posp->p_isrc;
|
||||
|
||||
len = strlen(fn = lbasename(fnames[src]));
|
||||
len += 3 * sizeof (u_short) + 4;
|
||||
|
||||
if (len > blen)
|
||||
buf = xrealloc(buf, blen = len);
|
||||
if (line != 0) {
|
||||
(void)sprintf(buf, "%s%s(%d)",
|
||||
fn, qm ? "?" : "", line);
|
||||
} else {
|
||||
(void)sprintf(buf, "%s", fn);
|
||||
}
|
||||
|
||||
return (buf);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.7 2000/06/14 20:22:19 matt Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
LIBS= llib-lposix.ln llib-lstdc.ln
|
||||
|
||||
FILES= ${LIBS}
|
||||
FILESDIR= ${LINTLIBDIR}
|
||||
|
||||
CLEANFILES+= ${LIBS}
|
||||
|
||||
llib-lposix.ln: llib-lposix
|
||||
${LINT} ${LINTFLAGS} -Cposix ${.ALLSRC}
|
||||
|
||||
llib-lstdc.ln: llib-lstdc
|
||||
${LINT} ${LINTFLAGS} -Cstdc ${.ALLSRC}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
.if !empty(STAGE_INCLUDEDIR)
|
||||
LINTFLAGS+= -I${STAGE_INCLUDEDIR}
|
||||
.else
|
||||
.if ${CFLAGS:M--sysroot=*} != ""
|
||||
_sysroot?= ${CFLAGS:M--sysroot=*:[1]:C,^--sysroot=,,}
|
||||
.elif ${CC:M--sysroot=*} != ""
|
||||
_sysroot?= ${CC:M--sysroot=*:[1]:C,^--sysroot=,,}
|
||||
.endif
|
||||
.if !empty(_sysroot)
|
||||
LINTFLAGS+= -I${_sysroot}/usr/include
|
||||
.endif
|
||||
.endif
|
@ -1,14 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
include \
|
||||
lib/msun \
|
||||
usr.bin/xlint/xlint.host \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,314 +0,0 @@
|
||||
/* $NetBSD: llib-lposix,v 1.2 1995/07/03 21:25:09 cgd Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* LINTLIBRARY */
|
||||
|
||||
#define _POSIX_SOURCE
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/times.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
#include <termios.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <locale.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include <utime.h>
|
||||
|
||||
|
||||
/* PROTOLIB1 */
|
||||
|
||||
|
||||
void (abort)(void);
|
||||
int (abs)(int j);
|
||||
int (access)(const char *path, int amode);
|
||||
double (acos)(double x);
|
||||
unsigned (alarm)(unsigned seconds);
|
||||
char *(asctime)(const struct tm *timeptr);
|
||||
double (asin)(double x);
|
||||
void (__assert)(const char *expression, const char *func, int line,
|
||||
const char *file);
|
||||
double (atan)(double x);
|
||||
double (atan2)(double y, double x);
|
||||
int (atexit)(void (*func)(void));
|
||||
double (atof)(const char *nptr);
|
||||
int (atoi)(const char *nptr);
|
||||
long (atol)(const char *nptr);
|
||||
void *(bsearch)(const void *key, const void *base, size_t nmemb,
|
||||
size_t size, int (*compar)(const void *, const void *));
|
||||
void *(calloc)(size_t nmemb, size_t size);
|
||||
double (ceil)(double x);
|
||||
speed_t (cfgetispeed)(const struct termios *p);
|
||||
speed_t (cfgetospeed)(const struct termios *p);
|
||||
int (cfsetispeed)(struct termios *p, speed_t speed);
|
||||
int (cfsetospeed)(struct termios *p, speed_t speed);
|
||||
int (chdir)(const char *path);
|
||||
int (chmod)(const char *path, mode_t mode);
|
||||
int (chown)(const char *path, uid_t owner, gid_t group);
|
||||
void (clearerr)(FILE *stream);
|
||||
clock_t (clock)(void);
|
||||
int (close)(int fildes);
|
||||
int (closedir)(DIR *dirp);
|
||||
double (cos)(double x);
|
||||
double (cosh)(double x);
|
||||
int (creat)(const char *path, mode_t mode);
|
||||
char *(ctermid)(char *s);
|
||||
char *(ctime)(const time_t *timer);
|
||||
char *(cuserid)(char *s);
|
||||
double (difftime)(time_t time1, time_t time0);
|
||||
div_t (div)(int numer, int denom);
|
||||
int (dup)(int fildes);
|
||||
int (dup2)(int fildes, int fildes2);
|
||||
int (errno);
|
||||
int (execl)(const char *path, const char *arg, ...);
|
||||
int (execle)(const char *path, const char *arg, ...);
|
||||
int (execlp)(const char *file, const char *arg, ...);
|
||||
int (execv)(const char *path, char *const argv[]);
|
||||
int (execve)(const char *path, char *const argv[], char *const *envp);
|
||||
int (execvp)(const char *file, char *const argv[]);
|
||||
void (exit)(int status);
|
||||
void (_exit)(int status);
|
||||
double (exp)(double x);
|
||||
double (fabs)(double x);
|
||||
int (fclose)(FILE *stream);
|
||||
int (fcntl)(int fildes, int cmd, ...);
|
||||
FILE *(fdopen)(int fildes, const char *type);
|
||||
int (feof)(FILE *stream);
|
||||
int (ferror)(FILE *stream);
|
||||
int (fflush)(FILE *stream);
|
||||
int (fgetc)(FILE *stream);
|
||||
int (fgetpos)(FILE *stream, fpos_t *pos);
|
||||
char *(fgets)(char *s, int n, FILE *stream);
|
||||
int (fileno)(FILE *stream);
|
||||
double (floor)(double x);
|
||||
double (fmod)(double x, double y);
|
||||
FILE *(fopen)(const char *filename, const char *mode);
|
||||
pid_t (fork)(void);
|
||||
long (fpathconf)(int fildes, int name);
|
||||
/* PRINTFLIKE2 */
|
||||
int (fprintf)(FILE *stream, const char *format, ...);
|
||||
int (fputc)(int c, FILE *stream);
|
||||
int (fputs)(const char *s, FILE *stream);
|
||||
size_t (fread)(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
void (free)(void *ptr);
|
||||
FILE *(freopen)(const char *filename, const char *mode, FILE *stream);
|
||||
double (frepx)(double value, int *exp);
|
||||
/* SCANFLIKE2 */
|
||||
int (fscanf)(FILE *stream, const char *format, ...);
|
||||
int (fseek)(FILE *stream, long int offset, int whence);
|
||||
int (fsetpos)(FILE *stream, const fpos_t *pos);
|
||||
int (fstat)(int fildes, struct stat *buf);
|
||||
long (ftell)(FILE *stream);
|
||||
size_t (fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
int (getc)(FILE *stream);
|
||||
int (getchar)(void);
|
||||
char *(getcwd)(char *buf, size_t size);
|
||||
gid_t (getegid)(void);
|
||||
char *(getenv)(const char *name);
|
||||
uid_t (geteuid)(void);
|
||||
gid_t (getgid)(void);
|
||||
struct group *(getgrgid)(gid_t gid);
|
||||
struct group *(getgrnam)(const char *name);
|
||||
int (getgroups)(int gidsetsize, gid_t grouplist[]);
|
||||
char *(getlogin)(void);
|
||||
pid_t (getpgrp)(void);
|
||||
pid_t (getpid)(void);
|
||||
pid_t (getppid)(void);
|
||||
struct passwd *(getpwnam)(const char *name);
|
||||
struct passwd *(getpwuid)(uid_t uid);
|
||||
char *(gets)(char *s);
|
||||
uid_t (getuid)(void);
|
||||
struct tm *(gmtime)(const time_t *timer);
|
||||
int (isalnum)(int c);
|
||||
int (isalpha)(int c);
|
||||
int (isatty)(int fildes);
|
||||
int (iscntrl)(int c);
|
||||
int (isdigit)(int c);
|
||||
int (isgraph)(int c);
|
||||
int (islower)(int c);
|
||||
int (isprint)(int c);
|
||||
int (ispunct)(int c);
|
||||
int (isspace)(int c);
|
||||
int (isupper)(int c);
|
||||
int (isxdigit)(int c);
|
||||
int (kill)(pid_t pid, int sig);
|
||||
long (labs)(long j);
|
||||
double (ldexp)(double x, int exp);
|
||||
ldiv_t (ldiv)(long numer, long denom);
|
||||
int (link)(const char *existing, const char *new);
|
||||
struct lconv *(localeconv)(void);
|
||||
struct tm *(localtime)(const time_t *timer);
|
||||
double (log)(double x);
|
||||
double (log10)(double x);
|
||||
void (longjmp)(jmp_buf env, int val);
|
||||
off_t (lseek)(int fildes, off_t offset, int whence);
|
||||
void *(malloc)(size_t size);
|
||||
int (mblen)(const char *s, size_t n);
|
||||
size_t (mbstowcs)(wchar_t *pwcs, const char *s, size_t n);
|
||||
int (mbtowc)(wchar_t *pwc, const char *s, size_t n);
|
||||
void *(memchr)(const void *s, int c, size_t n);
|
||||
int (memcmp)(const void *s1, const void *s2, size_t n);
|
||||
void *(memcpy)(void *s1, const void *s2, size_t n);
|
||||
void *(memmove)(void *s1, const void *s2, size_t n);
|
||||
void *(memset)(void *s, int c, size_t n);
|
||||
int (mkdir)(const char *path, mode_t mode);
|
||||
int (mkfifo)(const char *path, mode_t mode);
|
||||
time_t (mktime)(struct tm *timeptr);
|
||||
double (modf)(double value, double *iptr);
|
||||
int (open)(const char *path, int oflag, ...);
|
||||
DIR *(opendir)(const char *dirname);
|
||||
long (pathconf)(const char *path, int name);
|
||||
int (pause)(void);
|
||||
void (perror)(const char *s);
|
||||
int (pipe)(int fildes[2]);
|
||||
double (pow)(double x, double y);
|
||||
/* PRINTFLIKE1 */
|
||||
int (printf)(const char *format, ...);
|
||||
int (putc)(int c, FILE *stream);
|
||||
int (putchar)(int c);
|
||||
int (puts)(const char *s);
|
||||
void (qsort)(void *base, size_t nmemb, size_t size,
|
||||
int (*compar)(const void *, const void *));
|
||||
int (raise)(int sig);
|
||||
int (rand)(void);
|
||||
ssize_t (read)(int fildes, void *buf, size_t nbyte);
|
||||
struct dirent *(readdir)(DIR *dirp);
|
||||
void *(realloc)(void *ptr, size_t size);
|
||||
int (remove)(const char *filename);
|
||||
int (rename)(const char *old, const char *new);
|
||||
void (rewind)(FILE *stream);
|
||||
void (rewinddir)(DIR *dirp);
|
||||
int (rmdir)(const char *path);
|
||||
/* SCANFLIKE1 */
|
||||
int (scanf)(const char *format, ...);
|
||||
void (setbuf)(FILE *stream, char *buf);
|
||||
int (setgid)(gid_t gid);
|
||||
int (setjmp)(jmp_buf env);
|
||||
char *(setlocale)(int category, const char *locale);
|
||||
int (setpgid)(pid_t pid, pid_t pgid);
|
||||
pid_t (setsid)(void);
|
||||
int (setuid)(uid_t uid);
|
||||
int (setvbuf)(FILE *stream, char *buf, int mode, size_t size);
|
||||
int (sigaction)(int sig, const struct sigaction *act,
|
||||
struct sigaction *oact);
|
||||
int (sigaddset)(sigset_t *set, int signo);
|
||||
int (sigdelset)(sigset_t *set, int signo);
|
||||
int (sigemptyset)(sigset_t *set);
|
||||
int (sigfillset)(sigset_t *set);
|
||||
int (sigismember)(const sigset_t *set, int signo);
|
||||
void (siglongjmp)(sigjmp_buf env, int val);
|
||||
void (*(signal)(int sig, void (*func)(int)))(int);
|
||||
int (sigpending)(sigset_t *set);
|
||||
int (sigprocmask)(int how, const sigset_t *set, sigset_t *oset);
|
||||
int (sigsetjmp)(sigjmp_buf env, int savemask);
|
||||
int (sigsuspend)(const sigset_t *sigmask);
|
||||
double (sin)(double x);
|
||||
double (sinh)(double x);
|
||||
unsigned (sleep)(unsigned seconds);
|
||||
/* PRINTFLIKE2 */
|
||||
int (sprintf)(char *s, const char *format, ...);
|
||||
double (sqrt)(double x);
|
||||
void (srand)(unsigned seed);
|
||||
/* SCANFLIKE2 */
|
||||
int (sscanf)(const char *s, const char *format, ...);
|
||||
int (stat)(const char *path, struct stat *buf);
|
||||
char *(strcat)(char *s1, const char *s2);
|
||||
char *(strchr)(const char *s, int c);
|
||||
int (strcmp)(const char *s1, const char *s2);
|
||||
int (strcoll)(const char *s1, const char *s2);
|
||||
char *(strcpy)(char *s1, const char *s2);
|
||||
size_t (strcspn)(const char *s1, const char *s2);
|
||||
char *(strerror)(int errnum);
|
||||
size_t (strftime)(char *s, size_t maxsize, const char *format,
|
||||
const struct tm *timeptr);
|
||||
size_t (strlen)(const char *s);
|
||||
char *(strncat)(char *s1, const char *s2, size_t n);
|
||||
int (strncmp)(const char *s1, const char *s2, size_t n);
|
||||
char *(strncpy)(char *s1, const char *s2, size_t n);
|
||||
char *(strpbrk)(const char *s1, const char *s2);
|
||||
char *(strrchr)(const char *s, int c);
|
||||
size_t (strspn)(const char *s1, const char *s2);
|
||||
char *(strstr)(const char *s1, const char *s2);
|
||||
double (strtod)(const char *nptr, char **endptr);
|
||||
char *(strtok)(char *s1, const char *s2);
|
||||
long (strtol)(const char *nptr, char **endptr, int base);
|
||||
unsigned long (strtoul)(const char *nptr, char **endptr, int base);
|
||||
size_t (strxfrm)(char *s1, const char *s2, size_t n);
|
||||
long (sysconf)(int name);
|
||||
int (system)(const char *string);
|
||||
double (tan)(double x);
|
||||
double (tanh)(double x);
|
||||
int (tcdrain)(int fildes);
|
||||
int (tcflow)(int fildes, int action);
|
||||
int (tcflush)(int fildes, int queue_selector);
|
||||
int (tcgetattr)(int fildes, struct termios *tp);
|
||||
pid_t (tcgetpgrp)(int fildes);
|
||||
int (tcsendbreak)(int fildes, int duration);
|
||||
int (tcsetattr)(int fildes, int options, const struct termios *tp);
|
||||
int (tcsetpgrp)(int fildes, pid_t pgrpid);
|
||||
time_t (time)(time_t *timer);
|
||||
clock_t (times)(struct tms *buffer);
|
||||
FILE *(tmpfile)(void);
|
||||
char *(tmpnam)(char *s);
|
||||
int (tolower)(int c);
|
||||
int (toupper)(int c);
|
||||
char *(ttyname)(int filedes);
|
||||
void (tzset)(void);
|
||||
mode_t (umask)(mode_t cmask);
|
||||
int (uname)(struct utsname *name);
|
||||
int (ungetc)(int c, FILE *stream);
|
||||
int (unlink)(const char *path);
|
||||
int (utime)(const char *path, const struct utimbuf *times);
|
||||
int (vfprintf)(FILE *stream, const char *format, va_list arg);
|
||||
int (vprintf)(const char *format, va_list arg);
|
||||
int (vsprintf)(char *s, const char *format, va_list arg);
|
||||
pid_t (wait)(int *statloc);
|
||||
pid_t (waitpid)(pid_t pid, int *stat_loc, int options);
|
||||
size_t (wcstombs)(char *s, const wchar_t *pwcs, size_t n);
|
||||
int (wctomb)(char *s, wchar_t wchar);
|
||||
ssize_t (write)(int fildes, const void *buf, size_t nbyte);
|
@ -1,254 +0,0 @@
|
||||
/* $NetBSD: llib-lstdc,v 1.2 1995/07/03 21:25:11 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/* LINTLIBRARY */
|
||||
|
||||
#define _ANSI_SOURCE
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <math.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
/* PROTOLIB1 */
|
||||
|
||||
/*
|
||||
* assert.h
|
||||
*/
|
||||
#ifdef __NetBSD__
|
||||
void (__assert)(const char *expression, int line, const char *file);
|
||||
#else
|
||||
void (assert)(int expression);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ctype.h
|
||||
*/
|
||||
int (isalnum)(int c);
|
||||
int (isalpha)(int c);
|
||||
int (iscntrl)(int c);
|
||||
int (isdigit)(int c);
|
||||
int (isgraph)(int c);
|
||||
int (islower)(int c);
|
||||
int (isprint)(int c);
|
||||
int (ispunct)(int c);
|
||||
int (isspace)(int c);
|
||||
int (isupper)(int c);
|
||||
int (isxdigit)(int c);
|
||||
int (tolower)(int c);
|
||||
int (toupper)(int c);
|
||||
|
||||
/*
|
||||
* errno.h
|
||||
*/
|
||||
int (errno);
|
||||
|
||||
/*
|
||||
* locale.h
|
||||
*/
|
||||
char *(setlocale)(int category, const char *locale);
|
||||
struct lconv *(localeconv)(void);
|
||||
|
||||
/*
|
||||
* math.h
|
||||
*/
|
||||
double (acos)(double x);
|
||||
double (asin)(double x);
|
||||
double (atan)(double x);
|
||||
double (atan2)(double y, double x);
|
||||
double (cos)(double x);
|
||||
double (sin)(double x);
|
||||
double (tan)(double x);
|
||||
double (cosh)(double x);
|
||||
double (sinh)(double x);
|
||||
double (tanh)(double x);
|
||||
double (exp)(double x);
|
||||
double (frexp)(double value, int *exp);
|
||||
double (ldexp)(double x, int exp);
|
||||
double (log)(double x);
|
||||
double (log10)(double x);
|
||||
double (modf)(double value, double *iptr);
|
||||
double (pow)(double x, double y);
|
||||
double (sqrt)(double x);
|
||||
double (ceil)(double x);
|
||||
double (fabs)(double x);
|
||||
double (floor)(double x);
|
||||
double (fmod)(double x, double y);
|
||||
|
||||
/*
|
||||
* setjmp.h
|
||||
*/
|
||||
int (setjmp)(jmp_buf env);
|
||||
void (longjmp)(jmp_buf env, int val);
|
||||
|
||||
/*
|
||||
* signal.h
|
||||
*/
|
||||
void (*(signal)(int sig, void (*func)(int)))(int);
|
||||
int (raise)(int sig);
|
||||
|
||||
/*
|
||||
* stdio.h
|
||||
*/
|
||||
int (remove)(const char *filename);
|
||||
int (rename)(const char *old, const char *new);
|
||||
FILE *(tmpfile)(void);
|
||||
char *(tmpnam)(char *s);
|
||||
int (fclose)(FILE *stream);
|
||||
int (fflush)(FILE *stream);
|
||||
FILE *(fopen)(const char *filename, const char *mode);
|
||||
FILE *(freopen)(const char *filename, const char *mode, FILE *stream);
|
||||
void (setbuf)(FILE *stream, char *buf);
|
||||
int (setvbuf)(FILE *stream, char *buf, int mode, size_t size);
|
||||
/* PRINTFLIKE2 */
|
||||
int (fprintf)(FILE *stream, const char *format, ...);
|
||||
/* SCANFLIKE2 */
|
||||
int (fscanf)(FILE *stream, const char *format, ...);
|
||||
/* PRINTFLIKE1 */
|
||||
int (printf)(const char *format, ...);
|
||||
/* SCANFLIKE1 */
|
||||
int (scanf)(const char *format, ...);
|
||||
/* PRINTFLIKE2 */
|
||||
int (sprintf)(char *s, const char *format, ...);
|
||||
/* SCANFLIKE2 */
|
||||
int (sscanf)(const char *s, const char *format, ...);
|
||||
int (vfprintf)(FILE *stream, const char *format, va_list arg);
|
||||
int (vprintf)(const char *format, va_list arg);
|
||||
int (vsprintf)(char *s, const char *format, va_list arg);
|
||||
int (fgetc)(FILE *stream);
|
||||
char *(fgets)(char *s, int n, FILE *stream);
|
||||
int (fputc)(int c, FILE *stream);
|
||||
int (fputs)(const char *s, FILE *stream);
|
||||
int (getc)(FILE *stream);
|
||||
int (getchar)(void);
|
||||
char *(gets)(char *s);
|
||||
int (putc)(int c, FILE *stream);
|
||||
int (putchar)(int c);
|
||||
int (puts)(const char *s);
|
||||
int (ungetc)(int c, FILE *stream);
|
||||
size_t (fread)(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
size_t (fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
int (fgetpos)(FILE *stream, fpos_t *pos);
|
||||
int (fseek)(FILE *stream, long offset, int whence);
|
||||
int (fsetpos)(FILE *stream, const fpos_t *pos);
|
||||
long (ftell)(FILE *stream);
|
||||
void (rewind)(FILE *stream);
|
||||
void (clearerr)(FILE *stream);
|
||||
int (feof)(FILE *stream);
|
||||
int (ferror)(FILE *stream);
|
||||
void (perror)(const char *s);
|
||||
|
||||
/*
|
||||
* stdlib.h
|
||||
*/
|
||||
double (atof)(const char *nptr);
|
||||
int (atoi)(const char *nptr);
|
||||
long (atol)(const char *nptr);
|
||||
double (strtod)(const char *nptr, char **endptr);
|
||||
long (strtol)(const char *nptr, char **endptr, int base);
|
||||
unsigned long (strtoul)(const char *nptr, char **endptr, int base);
|
||||
int (rand)(void);
|
||||
void (srand)(unsigned seed);
|
||||
void *(calloc)(size_t nmemb, size_t size);
|
||||
void (free)(void *ptr);
|
||||
void *(malloc)(size_t size);
|
||||
void *(realloc)(void *ptr, size_t size);
|
||||
void (abort)(void);
|
||||
int (atexit)(void (*func)(void));
|
||||
void (exit)(int status);
|
||||
char *(getenv)(const char *name);
|
||||
int (system)(const char *string);
|
||||
void *(bsearch)(const void *key, const void *base, size_t nmemb,
|
||||
size_t size, int (*compar)(const void *, const void *));
|
||||
void (qsort)(void *base, size_t nmemb, size_t size,
|
||||
int (*compar)(const void *, const void *));
|
||||
int (abs)(int j);
|
||||
div_t (div)(int numer, int denom);
|
||||
long (labs)(long j);
|
||||
ldiv_t (ldiv)(long numer, long denom);
|
||||
int (mblen)(const char *s, size_t n);
|
||||
int (mbtowc)(wchar_t *PWC, const char *s, size_t n);
|
||||
int (wctomb)(char *s, wchar_t wchar);
|
||||
size_t (mbstowcs)(wchar_t *pwcs, const char *s, size_t n);
|
||||
size_t (wcstombs)(char *s, const wchar_t *pwcs, size_t n);
|
||||
|
||||
/*
|
||||
* string.h
|
||||
*/
|
||||
void *(memcpy)(void *s1, const void *s2, size_t n);
|
||||
void *(memmove)(void *s1, const void *s2, size_t n);
|
||||
char *(strcpy)(char *s1, const char *s2);
|
||||
char *(strncpy)(char *s1, const char *s2, size_t n);
|
||||
char *(strcat)(char *s1, const char *s2);
|
||||
char *(strncat)(char *s1, const char *s2, size_t n);
|
||||
int (memcmp)(const void *s1, const void *s2, size_t n);
|
||||
int (strcmp)(const char *s1, const char *s2);
|
||||
int (strcoll)(const char *s1, const char *s2);
|
||||
int (strncmp)(const char *s1, const char *s2, size_t n);
|
||||
size_t (strxfrm)(char *s1, const char *s2, size_t n);
|
||||
void *(memchr)(const void *s, int c, size_t n);
|
||||
char *(strchr)(const char *s, int c);
|
||||
size_t (strcspn)(const char *s1, const char *s2);
|
||||
char *(strpbrk)(const char *s1, const char *s2);
|
||||
char *(strrchr)(const char *s1, int c);
|
||||
size_t (strspn)(const char *s1, const char *s2);
|
||||
char *(strstr)(const char *s1, const char *s2);
|
||||
char *(strtok)(char *s1, const char *s2);
|
||||
void *(memset)(void *s, int c, size_t n);
|
||||
char *(strerror)(int errnom);
|
||||
size_t (strlen)(const char *s);
|
||||
|
||||
/*
|
||||
* time.h
|
||||
*/
|
||||
clock_t (clock)(void);
|
||||
double (difftime)(time_t time1, time_t time2);
|
||||
time_t (mktime)(struct tm *timeptr);
|
||||
time_t (time)(time_t *timer);
|
||||
char *(asctime)(const struct tm *timeptr);
|
||||
char *(ctime)(const time_t *timer);
|
||||
struct tm *(gmtime)(const time_t *timer);
|
||||
struct tm *(localtime)(const time_t *timer);
|
||||
size_t (strftime)(char *s, size_t maxsize, const char *format,
|
||||
const struct tm *timeptr);
|
@ -1,15 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.2 1995/07/03 21:25:14 cgd Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../lint1
|
||||
|
||||
PROG= xlint
|
||||
PROGNAME= lint
|
||||
SRCS= xlint.c mem.c
|
||||
MAN= lint.1
|
||||
|
||||
CFLAGS+=-I${.CURDIR}/../lint1
|
||||
CFLAGS+= -DPREFIX=\"${TOOLS_PREFIX}\"
|
||||
|
||||
.include "${.CURDIR}/../../Makefile.inc"
|
||||
.include <bsd.prog.mk>
|
@ -1,17 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,627 +0,0 @@
|
||||
.\" $NetBSD: lint.1,v 1.29 2004/01/26 21:59:42 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
.\" Copyright (c) 1994, 1995 Jochen Pohl
|
||||
.\" All Rights Reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by Jochen Pohl for
|
||||
.\" The NetBSD Project.
|
||||
.\" 4. The name of the author may not be used to endorse or promote products
|
||||
.\" derived from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd Mar 23, 2015
|
||||
.Dt LINT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm lint
|
||||
.Nd a C program verifier
|
||||
.Sh SYNOPSIS
|
||||
.Bk -words
|
||||
.Nm
|
||||
.Op Fl abceghprvwxzHFV
|
||||
.Op Fl s | t
|
||||
.Op Fl i | nu
|
||||
.Op Fl D Ar name Ns Op = Ns Ar def
|
||||
.Op Fl U Ar name
|
||||
.Op Fl I Ar directory
|
||||
.Op Fl d Ar directory
|
||||
.Op Fl L Ar directory
|
||||
.Op Fl MD
|
||||
.Op Fl l Ar library
|
||||
.Op Fl o Ar outputfile
|
||||
.Op Fl B Ar directory
|
||||
.Op Fl X Ar id Ns Op , Ns Ar id ...
|
||||
.Ar
|
||||
.Nm
|
||||
.Op Fl abceghprvwzHFV
|
||||
.Op Fl s | t
|
||||
.Fl C Ar library
|
||||
.Op Fl D Ar name Ns Op = Ns Ar def
|
||||
.Op Fl U Ar name
|
||||
.Op Fl I Ar directory
|
||||
.Op Fl d Ar directory
|
||||
.Op Fl B Ar directory
|
||||
.Op Fl X Ar id Ns Op , Ns Ar id ...
|
||||
.Ar
|
||||
.Ek
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility attempts to detect features of the named C program files
|
||||
that are likely to be bugs, to be non-portable, or to be
|
||||
wasteful.
|
||||
It also performs stricter type checking than does
|
||||
the C compiler.
|
||||
The
|
||||
.Nm
|
||||
utility runs the C preprocessor as its first phase, with the
|
||||
preprocessor symbol
|
||||
.Dq Dv lint
|
||||
defined to allow certain questionable code to be altered
|
||||
or skipped by
|
||||
.Nm .
|
||||
Therefore, this symbol should be thought of as a reserved
|
||||
word for all code that is to be checked by
|
||||
.Nm .
|
||||
.Pp
|
||||
Among the possible problems that are currently noted are
|
||||
unreachable statements, loops not entered at the top,
|
||||
variables declared and not used, and logical expressions
|
||||
with constant values.
|
||||
Function calls are checked for
|
||||
inconsistencies, such as calls to functions that return
|
||||
values in some places and not in others, functions called
|
||||
with varying numbers of arguments, function calls that
|
||||
pass arguments of a type other than the type the function
|
||||
expects to receive, functions whose values are not used,
|
||||
and calls to functions not returning values that use
|
||||
the non-existent return value of the function.
|
||||
.Pp
|
||||
Filename arguments ending with
|
||||
.Pa .c
|
||||
are taken to be C source files.
|
||||
Filename arguments with
|
||||
names ending with
|
||||
.Pa .ln
|
||||
are taken to be the result of an earlier invocation of
|
||||
.Nm ,
|
||||
with either the
|
||||
.Fl i , o ,
|
||||
or
|
||||
.Fl C
|
||||
option in effect.
|
||||
The
|
||||
.Pa .ln
|
||||
files are analogous to the
|
||||
.Pa .o
|
||||
(object) files produced by
|
||||
.Xr cc 1
|
||||
from
|
||||
.Pa .c
|
||||
files.
|
||||
The
|
||||
.Nm
|
||||
utility also accepts special libraries specified with the
|
||||
.Fl l
|
||||
option, which contain definitions of library routines and
|
||||
variables.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
utility takes all the
|
||||
.Pa .c , .ln ,
|
||||
and
|
||||
.Pa llib-l Ns Ar library Ns Pa .ln
|
||||
(lint library) files and processes them in command-line order.
|
||||
By default,
|
||||
.Nm
|
||||
appends the standard C lint library
|
||||
.Pq Pa llib-lc.ln
|
||||
to the end of the list of files.
|
||||
When the
|
||||
.Fl i
|
||||
option is used, the
|
||||
.Pa .ln
|
||||
files are ignored.
|
||||
Also, when the
|
||||
.Fl o
|
||||
or
|
||||
.Fl i
|
||||
options are used, the
|
||||
.Pa llib-l Ns Ar library Ns Pa .ln
|
||||
files are ignored.
|
||||
When the
|
||||
.Fl i
|
||||
option is
|
||||
.Em omitted
|
||||
the second pass of
|
||||
.Nm
|
||||
checks this list of files for mutual compatibility.
|
||||
At this point,
|
||||
if a complaint stems not from a given source file, but from one of
|
||||
its included files, the source filename will be printed followed by
|
||||
a question mark.
|
||||
.Pp
|
||||
The special input file name
|
||||
.Dq Pa -
|
||||
causes
|
||||
.Nm
|
||||
to take input from standard input (until end of file) and process
|
||||
it as if it were a
|
||||
.Pa .c
|
||||
file.
|
||||
If the
|
||||
.Fl i
|
||||
flag is given and
|
||||
.Dq Pa -
|
||||
is named as one of the input files, the
|
||||
.Fl o
|
||||
flag must also be specified to provide an output file name.
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl a
|
||||
Report assignments of
|
||||
.Vt long
|
||||
values to variables that are not
|
||||
.Vt long .
|
||||
.It Fl aa
|
||||
Additional to
|
||||
.Fl a ,
|
||||
report
|
||||
.Em all
|
||||
assignments of integer values to other integer values which
|
||||
cause implicit narrowing conversion.
|
||||
.It Fl b
|
||||
Report
|
||||
.Ic break
|
||||
statements that cannot be reached.
|
||||
This is not the default
|
||||
because, unfortunately, most
|
||||
.Xr lex 1
|
||||
and many
|
||||
.Xr yacc 1
|
||||
outputs produce many such complaints.
|
||||
.It Fl c
|
||||
Complain about casts which have questionable portability.
|
||||
.It Fl e
|
||||
Complain about unusual operations on
|
||||
.Vt enum Ns -Types
|
||||
and combinations of
|
||||
.Vt enum Ns -
|
||||
and
|
||||
.Sy integer Ns -Types .
|
||||
.It Fl g
|
||||
Do not print warnings for some extensions of
|
||||
.Xr gcc 1
|
||||
to the C language.
|
||||
Currently these are nonconstant initializers in
|
||||
automatic aggregate initializations, arithmetic on pointer to void,
|
||||
trailing commas in
|
||||
.Vt enum
|
||||
declarations, C++ -style
|
||||
.Dq Li //
|
||||
comments,
|
||||
zero sized structures, subscripting of non-lvalue arrays, prototypes
|
||||
overriding old style function declarations and long long
|
||||
integer types.
|
||||
The
|
||||
.Fl g
|
||||
flag also turns on the keywords
|
||||
.Ic asm
|
||||
and
|
||||
.Ic inline
|
||||
(alternative keywords with leading underscores for both
|
||||
.Ic asm
|
||||
and
|
||||
.Ic inline
|
||||
are always available).
|
||||
.It Fl h
|
||||
Apply a number of heuristic tests to attempt to intuit
|
||||
bugs, improve style, and reduce waste.
|
||||
.It Fl i
|
||||
Produce a
|
||||
.Pa .ln
|
||||
file for every
|
||||
.Pa .c
|
||||
file on the command line.
|
||||
These
|
||||
.Pa .ln
|
||||
files are the product of
|
||||
.Nm Ns 's
|
||||
first pass only, and are not checked for compatibility
|
||||
between functions.
|
||||
.It Fl n
|
||||
Do not check compatibility against the standard library.
|
||||
.It Fl p
|
||||
Attempt to check portability of code to other dialects of C.
|
||||
.It Fl r
|
||||
In case of redeclarations report the position of the
|
||||
previous declaration.
|
||||
.It Fl s
|
||||
Strict ANSI C mode.
|
||||
Issue warnings and errors required by ANSI C.
|
||||
Also do not produce warnings for constructs which behave
|
||||
differently in traditional C and ANSI C.
|
||||
With the
|
||||
.Fl s
|
||||
flag,
|
||||
.Dv __STRICT_ANSI__
|
||||
is a predefined preprocessor macro.
|
||||
.It Fl S
|
||||
C9X mode. Currently not fully implemented.
|
||||
.It Fl t
|
||||
Traditional C mode.
|
||||
.Dv __STDC__
|
||||
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.,
|
||||
.Dv sun3 )
|
||||
and machine architecture (e.g.,
|
||||
.Dv m68k )
|
||||
are defined without leading and trailing underscores.
|
||||
The keywords
|
||||
.Ic const , volatile
|
||||
and
|
||||
.Ic signed
|
||||
are not available in traditional C mode (although the alternative
|
||||
keywords with leading underscores still are).
|
||||
.It Fl u
|
||||
Do not complain about functions and external variables used
|
||||
and not defined, or defined and not used (this is suitable
|
||||
for running
|
||||
.Nm
|
||||
on a subset of files comprising part of a larger program).
|
||||
.It Fl v
|
||||
Suppress complaints about unused arguments in functions.
|
||||
.It Fl x
|
||||
Report variables referred to by
|
||||
.Ic extern
|
||||
declarations, but never used.
|
||||
.It Fl z
|
||||
Do not complain about structures that are never defined
|
||||
(for example, using a structure pointer without knowing
|
||||
its contents).
|
||||
.It Fl B Ar path
|
||||
Path to use when looking for the
|
||||
.Pa lint1
|
||||
and
|
||||
.Pa lint2
|
||||
binaries.
|
||||
Defaults to
|
||||
.Pa /usr/libexec .
|
||||
.It Fl C Ar library
|
||||
Create a
|
||||
.Nm
|
||||
library with the name
|
||||
.Pa llib-l Ns Ar library Ns Pa .ln .
|
||||
This library is built from all
|
||||
.Pa .c
|
||||
and
|
||||
.Pa .ln
|
||||
input files.
|
||||
After all global definitions of functions and
|
||||
variables in these files are written to the newly created library,
|
||||
.Nm
|
||||
checks all input files, including libraries specified with the
|
||||
.Fl l
|
||||
option, for mutual compatibility.
|
||||
.It Fl D Ar name Ns Op = Ns Ar def
|
||||
Define
|
||||
.Ar name
|
||||
for
|
||||
.Xr cpp 1 ,
|
||||
as if by a
|
||||
.Ic #define
|
||||
directive.
|
||||
If no definition is given,
|
||||
.Ar name
|
||||
is defined as 1.
|
||||
.It Fl I Ar directory
|
||||
Add
|
||||
.Ar directory
|
||||
to the list of directories in which to search for include files.
|
||||
.It Fl d Ar directory
|
||||
Use
|
||||
.Ar directory
|
||||
instead of
|
||||
.Pa /usr/include
|
||||
as the default place to find include files.
|
||||
.It Fl l Ar library
|
||||
Include the lint library
|
||||
.Pa llib-l Ns Ar library Ns Pa .ln .
|
||||
.It Fl L Ar directory
|
||||
Search for lint libraries in
|
||||
.Ar directory
|
||||
and
|
||||
.Ar directory Ns Pa /lint
|
||||
before searching the standard place.
|
||||
.It Fl F
|
||||
Print pathnames of files.
|
||||
The
|
||||
.Nm
|
||||
utility normally prints the filename without the path.
|
||||
.It Fl H
|
||||
If a complaint stems from an included file
|
||||
.Nm
|
||||
prints the name of the included file instead of the source file name
|
||||
followed by a question mark.
|
||||
.It Fl MD
|
||||
Pass
|
||||
.Fl MD
|
||||
to
|
||||
.Xr cpp 1
|
||||
causing cpp to create files containing dependency information for
|
||||
each source file.
|
||||
.It Fl o Ar outputfile
|
||||
Name the output file
|
||||
.Ar outputfile .
|
||||
The output file produced is the input that is given to
|
||||
.Nm Ns 's
|
||||
second pass.
|
||||
The
|
||||
.Fl o
|
||||
option simply saves this file in the named output file.
|
||||
If the
|
||||
.Fl i
|
||||
option is also used the files are not checked for compatibility.
|
||||
To produce a
|
||||
.Pa llib-l Ns Ar library Ns Pa .ln
|
||||
without extraneous messages, use of the
|
||||
.Fl u
|
||||
option is suggested.
|
||||
The
|
||||
.Fl v
|
||||
option is useful if the source file(s) for the lint library
|
||||
are just external interfaces.
|
||||
.It Fl U Ar name
|
||||
Remove any initial definition of
|
||||
.Ar name
|
||||
for the preprocessor.
|
||||
.It Fl V
|
||||
Print the command lines constructed by the controller program to
|
||||
run the C preprocessor and
|
||||
.Nm Ns 's
|
||||
first and second pass.
|
||||
.It Fl w
|
||||
Treat warnings as errors.
|
||||
.It Fl X Ar id Ns Op , Ns Ar id ...
|
||||
Suppress error messages identified by the list of ids.
|
||||
A list of messages
|
||||
and ids can be found in
|
||||
.Xr lint 7 .
|
||||
.El
|
||||
.Ss Input Grammar
|
||||
.Nm Ns 's
|
||||
first pass reads standard C source files.
|
||||
The
|
||||
.Nm
|
||||
utility recognizes the following C comments as commands.
|
||||
.Bl -tag -width indent
|
||||
.It Li /* ARGSUSED Ns Ar n Li */
|
||||
Makes
|
||||
.Nm
|
||||
check only the first
|
||||
.Ar n
|
||||
arguments for usage; a missing
|
||||
.Ar n
|
||||
is taken to be 0 (this option acts like the
|
||||
.Fl v
|
||||
option for the next function).
|
||||
.It Li /* BITFIELDTYPE */
|
||||
Suppress error messages about illegal bitfield types if the type
|
||||
is an integer type, and suppress non-portable bitfield type warnings.
|
||||
.It Xo
|
||||
.Li /* CONSTCOND */
|
||||
or
|
||||
.Li /* CONSTANTCOND */
|
||||
or
|
||||
.Li /* CONSTANTCONDITION */
|
||||
.Xc
|
||||
suppress complaints about constant operands for the next expression.
|
||||
.It Xo
|
||||
.Li /* FALLTHRU */
|
||||
or
|
||||
.Li /* FALLTHROUGH */
|
||||
.Xc
|
||||
suppress complaints about fall through to a
|
||||
.Ic case
|
||||
or
|
||||
.Ic default
|
||||
labelled statement.
|
||||
This directive should be placed immediately
|
||||
preceding the label.
|
||||
.It Li /* LINTLIBRARY */
|
||||
At the beginning of a file, mark all functions and variables defined
|
||||
in this file as
|
||||
.Em used .
|
||||
Also shut off complaints about unused function arguments.
|
||||
.It Xo
|
||||
.Li /* LINTED Oo Ar comment Oc Li */
|
||||
or
|
||||
.Li /* NOSTRICT Oo Ar comment Oc Li */
|
||||
.Xc
|
||||
Suppresses any intra-file warning except those dealing with
|
||||
unused variables or functions.
|
||||
This directive should be placed
|
||||
on the line immediately preceding where the
|
||||
.Nm
|
||||
warning occurred.
|
||||
.It Li /* LONGLONG */
|
||||
Suppress complaints about use of long long integer types.
|
||||
.It Li /* NOTREACHED */
|
||||
At appropriate points, inhibit complaints about unreachable code.
|
||||
(This comment is typically placed just after calls to functions
|
||||
like
|
||||
.Xr exit 3 ) .
|
||||
.It Li /* PRINTFLIKE Ns Ar n Li */
|
||||
makes
|
||||
.Nm
|
||||
check the first
|
||||
.Pq Ar n Ns -1
|
||||
arguments as usual.
|
||||
The
|
||||
.Ar n Ns -th
|
||||
argument is interpreted as a
|
||||
.Xr printf 3
|
||||
format string that is used to check the remaining arguments.
|
||||
.It Li /* PROTOLIB Ns Ar n Li */
|
||||
causes
|
||||
.Nm
|
||||
to treat function declaration prototypes as function definitions
|
||||
if
|
||||
.Ar n
|
||||
is non-zero.
|
||||
This directive can only be used in conjunction with
|
||||
the
|
||||
.Li /* LINTLIBRARY */
|
||||
directive.
|
||||
If
|
||||
.Ar n
|
||||
is zero, function prototypes will be treated normally.
|
||||
.It Li /* SCANFLIKE Ns Ar n Li */
|
||||
makes
|
||||
.Nm
|
||||
check the first
|
||||
.Pq Ar n Ns -1
|
||||
arguments as usual.
|
||||
The
|
||||
.Ar n Ns -th
|
||||
argument is interpreted as a
|
||||
.Xr scanf 3
|
||||
format string that is used to check the remaining arguments.
|
||||
.It Li /* VARARGS Ns Ar n Li */
|
||||
Suppress the usual checking for variable numbers of arguments in
|
||||
the following function declaration.
|
||||
The data types of the first
|
||||
.Ar n
|
||||
arguments are checked; a missing
|
||||
.Ar n
|
||||
is taken to be 0.
|
||||
.El
|
||||
.Pp
|
||||
The behavior of the
|
||||
.Fl i
|
||||
and the
|
||||
.Fl o
|
||||
options allows for incremental use of
|
||||
.Nm
|
||||
on a set of C source files.
|
||||
Generally, one invokes
|
||||
.Nm
|
||||
once for each source file with the
|
||||
.Fl i
|
||||
option.
|
||||
Each of these invocations produces a
|
||||
.Pa .ln
|
||||
file that corresponds to the
|
||||
.Pa .c
|
||||
file, and prints all messages that are about just that
|
||||
source file.
|
||||
After all the source files have been separately
|
||||
run through
|
||||
.Nm ,
|
||||
it is invoked once more (without the
|
||||
.Fl i
|
||||
option), listing all the
|
||||
.Pa .ln
|
||||
files with the needed
|
||||
.Fl l Ar library
|
||||
options.
|
||||
This will print all the inter-file inconsistencies.
|
||||
This
|
||||
scheme works well with
|
||||
.Xr make 1 ;
|
||||
it allows
|
||||
.Xr make 1
|
||||
to be used to
|
||||
.Nm
|
||||
only the source files that have been modified since the last
|
||||
time the set of source files were
|
||||
.Nm Ns ed .
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width LIBDIR
|
||||
.It Ev LIBDIR
|
||||
the directory where the lint libraries specified by the
|
||||
.Bk -words
|
||||
.Fl l Ar library
|
||||
.Ek
|
||||
option must exist.
|
||||
If this environment variable is undefined,
|
||||
then the default path
|
||||
.Pa /usr/libdata/lint
|
||||
will be used to search for the libraries.
|
||||
.It Ev TMPDIR
|
||||
usually the path for temporary files can be redefined by setting
|
||||
this environment variable.
|
||||
.It Ev CC
|
||||
Location of the C compiler program.
|
||||
Defaults to
|
||||
.Pa /usr/bin/cc .
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width /usr/libdata/lint/llib-lc.ln -compact
|
||||
.It Pa /usr/libexec/lint Ns Bq Pa 12
|
||||
programs
|
||||
.It Pa /usr/libdata/lint/llib-l*.ln
|
||||
various prebuilt lint libraries
|
||||
.It Pa /tmp/lint*
|
||||
temporaries
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr cc 1 ,
|
||||
.Xr cpp 1 ,
|
||||
.Xr make 1
|
||||
.Sh AUTHORS
|
||||
.An Jochen Pohl
|
||||
.Sh BUGS
|
||||
.Bl -item
|
||||
.It
|
||||
The routines
|
||||
.Xr exit 3 ,
|
||||
.Xr longjmp 3
|
||||
and other functions that do not return are not understood; this
|
||||
causes various incorrect diagnostics.
|
||||
.It
|
||||
Static functions which are used only before their first
|
||||
extern declaration are reported as unused.
|
||||
.It
|
||||
Libraries created by the
|
||||
.Fl o
|
||||
option will, when used in later
|
||||
.Nm
|
||||
runs, cause certain errors that were reported when the libraries
|
||||
were created to be reported again, and cause line numbers and file
|
||||
names from the original source used to create those libraries
|
||||
to be reported in error messages.
|
||||
For these reasons, it is recommended
|
||||
to use the
|
||||
.Fl C
|
||||
option to create lint libraries.
|
||||
.El
|
@ -1,45 +0,0 @@
|
||||
/* $NetBSD: pathnames.h,v 1.3 1999/04/22 04:40:58 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/* directory where lint1 and lint2 reside */
|
||||
#ifndef PATH_LIBEXEC
|
||||
#define PATH_LIBEXEC PREFIX"/usr/libexec"
|
||||
#endif
|
||||
|
||||
/* directory where cc(1) resides */
|
||||
#define PATH_USRBIN PREFIX"/usr/bin"
|
||||
|
||||
/* default library search path */
|
||||
#define PATH_LINTLIB PREFIX"/usr/libdata/lint"
|
@ -1,883 +0,0 @@
|
||||
/* $NetBSD: xlint.c,v 1.36 2005/02/09 21:24:48 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jochen Pohl for
|
||||
* The NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: xlint.c,v 1.36 2005/02/09 21:24:48 dsl Exp $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lint.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
#define DEFAULT_PATH _PATH_DEFPATH
|
||||
|
||||
int main(int, char *[]);
|
||||
|
||||
/* directory for temporary files */
|
||||
static const char *tmpdir;
|
||||
|
||||
/* path name for cpp output */
|
||||
static char *cppout;
|
||||
|
||||
/* file descriptor for cpp output */
|
||||
static int cppoutfd = -1;
|
||||
|
||||
/* files created by 1st pass */
|
||||
static char **p1out;
|
||||
|
||||
/* input files for 2nd pass (without libraries) */
|
||||
static char **p2in;
|
||||
|
||||
/* library which will be created by 2nd pass */
|
||||
static char *p2out;
|
||||
|
||||
/* flags always passed to cc(1) */
|
||||
static char **cflags;
|
||||
|
||||
/* flags for cc(1), controlled by sflag/tflag */
|
||||
static char **lcflags;
|
||||
|
||||
/* flags for lint1 */
|
||||
static char **l1flags;
|
||||
|
||||
/* flags for lint2 */
|
||||
static char **l2flags;
|
||||
|
||||
/* libraries for lint2 */
|
||||
static char **l2libs;
|
||||
|
||||
/* default libraries */
|
||||
static char **deflibs;
|
||||
|
||||
/* additional libraries */
|
||||
static char **libs;
|
||||
|
||||
/* search path for libraries */
|
||||
static char **libsrchpath;
|
||||
|
||||
static char *libexec_path;
|
||||
|
||||
/* flags */
|
||||
static int iflag, oflag, Cflag, sflag, tflag, Fflag, dflag, Bflag, Sflag;
|
||||
|
||||
/* print the commands executed to run the stages of compilation */
|
||||
static int Vflag;
|
||||
|
||||
/* filename for oflag */
|
||||
static char *outputfn;
|
||||
|
||||
/* reset after first .c source has been processed */
|
||||
static int first = 1;
|
||||
|
||||
/*
|
||||
* name of a file which is currently written by a child and should
|
||||
* be removed after abnormal termination of the child
|
||||
*/
|
||||
static const char *currfn;
|
||||
|
||||
#if !defined(TARGET_PREFIX)
|
||||
#define TARGET_PREFIX ""
|
||||
#endif
|
||||
static const char target_prefix[] = TARGET_PREFIX;
|
||||
|
||||
static void appstrg(char ***, char *);
|
||||
static void appcstrg(char ***, const char *);
|
||||
static void applst(char ***, char *const *);
|
||||
static void freelst(char ***);
|
||||
static char *concat2(const char *, const char *);
|
||||
static char *concat3(const char *, const char *, const char *);
|
||||
static void terminate(int) __attribute__((__noreturn__));
|
||||
static const char *lbasename(const char *, int);
|
||||
static void appdef(char ***, const char *);
|
||||
static void usage(void) __dead2;
|
||||
static void fname(const char *);
|
||||
static void runchild(const char *, char *const *, const char *, int);
|
||||
static void findlibs(char *const *);
|
||||
static int rdok(const char *);
|
||||
static void lint2(void);
|
||||
static void cat(char *const *, const char *);
|
||||
|
||||
/*
|
||||
* Some functions to deal with lists of strings.
|
||||
* Take care that we get no surprises in case of asynchronous signals.
|
||||
*/
|
||||
static void
|
||||
appstrg(char ***lstp, char *s)
|
||||
{
|
||||
char **lst, **olst;
|
||||
int i;
|
||||
|
||||
olst = *lstp;
|
||||
for (i = 0; olst[i] != NULL; i++)
|
||||
continue;
|
||||
lst = xrealloc(olst, (i + 2) * sizeof (char *));
|
||||
lst[i] = s;
|
||||
lst[i + 1] = NULL;
|
||||
*lstp = lst;
|
||||
}
|
||||
|
||||
static void
|
||||
appcstrg(char ***lstp, const char *s)
|
||||
{
|
||||
|
||||
appstrg(lstp, xstrdup(s));
|
||||
}
|
||||
|
||||
static void
|
||||
applst(char ***destp, char *const *src)
|
||||
{
|
||||
int i, k;
|
||||
char **dest, **odest;
|
||||
|
||||
odest = *destp;
|
||||
for (i = 0; odest[i] != NULL; i++)
|
||||
continue;
|
||||
for (k = 0; src[k] != NULL; k++)
|
||||
continue;
|
||||
dest = xrealloc(odest, (i + k + 1) * sizeof (char *));
|
||||
for (k = 0; src[k] != NULL; k++)
|
||||
dest[i + k] = xstrdup(src[k]);
|
||||
dest[i + k] = NULL;
|
||||
*destp = dest;
|
||||
}
|
||||
|
||||
static void
|
||||
freelst(char ***lstp)
|
||||
{
|
||||
char *s;
|
||||
int i;
|
||||
|
||||
for (i = 0; (*lstp)[i] != NULL; i++)
|
||||
continue;
|
||||
while (i-- > 0) {
|
||||
s = (*lstp)[i];
|
||||
(*lstp)[i] = NULL;
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
concat2(const char *s1, const char *s2)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = xmalloc(strlen(s1) + strlen(s2) + 1);
|
||||
(void)strcpy(s, s1);
|
||||
(void)strcat(s, s2);
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
static char *
|
||||
concat3(const char *s1, const char *s2, const char *s3)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = xmalloc(strlen(s1) + strlen(s2) + strlen(s3) + 1);
|
||||
(void)strcpy(s, s1);
|
||||
(void)strcat(s, s2);
|
||||
(void)strcat(s, s3);
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean up after a signal.
|
||||
*/
|
||||
static void
|
||||
terminate(int signo)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (cppoutfd != -1)
|
||||
(void)close(cppoutfd);
|
||||
if (cppout != NULL)
|
||||
(void)remove(cppout);
|
||||
|
||||
if (p1out != NULL) {
|
||||
for (i = 0; p1out[i] != NULL; i++)
|
||||
(void)remove(p1out[i]);
|
||||
}
|
||||
|
||||
if (p2out != NULL)
|
||||
(void)remove(p2out);
|
||||
|
||||
if (currfn != NULL)
|
||||
(void)remove(currfn);
|
||||
|
||||
exit(signo != 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a pointer to the last component of strg after delim.
|
||||
* Returns strg if the string does not contain delim.
|
||||
*/
|
||||
static const char *
|
||||
lbasename(const char *strg, int delim)
|
||||
{
|
||||
const char *cp, *cp1, *cp2;
|
||||
|
||||
cp = cp1 = cp2 = strg;
|
||||
while (*cp != '\0') {
|
||||
if (*cp++ == delim) {
|
||||
cp2 = cp1;
|
||||
cp1 = cp;
|
||||
}
|
||||
}
|
||||
return (*cp1 == '\0' ? cp2 : cp1);
|
||||
}
|
||||
|
||||
static void
|
||||
appdef(char ***lstp, const char *def)
|
||||
{
|
||||
|
||||
appstrg(lstp, concat2("-D__", def));
|
||||
appstrg(lstp, concat3("-D__", def, "__"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"usage: lint [-abceghprvwxzHFS] [-s|-t] [-i|-nu] [-Dname[=def]]"
|
||||
" [-Uname] [-X <id>[,<id>]...\n");
|
||||
(void)fprintf(stderr,
|
||||
"\t[-Idirectory] [-Ldirectory] [-llibrary] [-ooutputfile]"
|
||||
" file...\n");
|
||||
(void)fprintf(stderr,
|
||||
" lint [-abceghprvwzHFS] [-s|-t] -Clibrary [-Dname[=def]]\n"
|
||||
" [-X <id>[,<id>]...\n");
|
||||
(void)fprintf(stderr, "\t[-Idirectory] [-Uname] [-Bpath] file"
|
||||
" ...\n");
|
||||
terminate(-1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
char flgbuf[3], *s;
|
||||
const char *tmp;
|
||||
size_t len;
|
||||
|
||||
if ((tmp = getenv("TMPDIR")) == NULL || (len = strlen(tmp)) == 0) {
|
||||
tmpdir = _PATH_TMP;
|
||||
} else {
|
||||
s = xmalloc(len + 2);
|
||||
(void)sprintf(s, "%s%s", tmp, tmp[len - 1] == '/' ? "" : "/");
|
||||
tmpdir = s;
|
||||
}
|
||||
|
||||
cppout = xmalloc(strlen(tmpdir) + sizeof ("lint0.XXXXXX"));
|
||||
(void)sprintf(cppout, "%slint0.XXXXXX", tmpdir);
|
||||
cppoutfd = mkstemp(cppout);
|
||||
if (cppoutfd == -1) {
|
||||
warn("can't make temp");
|
||||
terminate(-1);
|
||||
}
|
||||
|
||||
p1out = xcalloc(1, sizeof (char *));
|
||||
p2in = xcalloc(1, sizeof (char *));
|
||||
cflags = xcalloc(1, sizeof (char *));
|
||||
lcflags = xcalloc(1, sizeof (char *));
|
||||
l1flags = xcalloc(1, sizeof (char *));
|
||||
l2flags = xcalloc(1, sizeof (char *));
|
||||
l2libs = xcalloc(1, sizeof (char *));
|
||||
deflibs = xcalloc(1, sizeof (char *));
|
||||
libs = xcalloc(1, sizeof (char *));
|
||||
libsrchpath = xcalloc(1, sizeof (char *));
|
||||
|
||||
appcstrg(&cflags, "-E");
|
||||
appcstrg(&cflags, "-x");
|
||||
appcstrg(&cflags, "c");
|
||||
#if 0
|
||||
appcstrg(&cflags, "-D__attribute__(x)=");
|
||||
appcstrg(&cflags, "-D__extension__(x)=/*NOSTRICT*/0");
|
||||
#else
|
||||
appcstrg(&cflags, "-U__GNUC__");
|
||||
appcstrg(&cflags, "-undef");
|
||||
#endif
|
||||
#if 0
|
||||
appcstrg(&cflags, "-Wp,-$");
|
||||
#endif
|
||||
appcstrg(&cflags, "-Wp,-C");
|
||||
appcstrg(&cflags, "-Wcomment");
|
||||
appcstrg(&cflags, "-D__LINT__");
|
||||
appcstrg(&cflags, "-Dlint"); /* XXX don't def. with -s */
|
||||
|
||||
appdef(&cflags, "lint");
|
||||
|
||||
appcstrg(&deflibs, "c");
|
||||
|
||||
if (signal(SIGHUP, terminate) == SIG_IGN)
|
||||
(void)signal(SIGHUP, SIG_IGN);
|
||||
(void)signal(SIGINT, terminate);
|
||||
(void)signal(SIGQUIT, terminate);
|
||||
(void)signal(SIGTERM, terminate);
|
||||
while ((c = getopt(argc, argv, "abcd:eghil:no:prstuvwxzB:C:D:FHI:L:M:SU:VX:")) != -1) {
|
||||
switch (c) {
|
||||
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'e':
|
||||
case 'g':
|
||||
case 'r':
|
||||
case 'v':
|
||||
case 'w':
|
||||
case 'z':
|
||||
(void)sprintf(flgbuf, "-%c", c);
|
||||
appcstrg(&l1flags, flgbuf);
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
Fflag = 1;
|
||||
/* FALLTHROUGH */
|
||||
case 'u':
|
||||
case 'h':
|
||||
(void)sprintf(flgbuf, "-%c", c);
|
||||
appcstrg(&l1flags, flgbuf);
|
||||
appcstrg(&l2flags, flgbuf);
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
(void)sprintf(flgbuf, "-%c", c);
|
||||
appcstrg(&l1flags, flgbuf);
|
||||
appcstrg(&l1flags, optarg);
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
if (Cflag)
|
||||
usage();
|
||||
iflag = 1;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
freelst(&deflibs);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
appcstrg(&lcflags, "-Wtraditional");
|
||||
appcstrg(&lcflags, "-Wno-system-headers");
|
||||
appcstrg(&l1flags, "-p");
|
||||
appcstrg(&l2flags, "-p");
|
||||
if (*deflibs != NULL) {
|
||||
freelst(&deflibs);
|
||||
appcstrg(&deflibs, "c");
|
||||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if (tflag)
|
||||
usage();
|
||||
freelst(&lcflags);
|
||||
appcstrg(&lcflags, "-trigraphs");
|
||||
appcstrg(&lcflags, "-Wtrigraphs");
|
||||
appcstrg(&lcflags, "-pedantic");
|
||||
appcstrg(&lcflags, "-D__STRICT_ANSI__");
|
||||
appcstrg(&l1flags, "-s");
|
||||
appcstrg(&l2flags, "-s");
|
||||
sflag = 1;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
if (tflag)
|
||||
usage();
|
||||
appcstrg(&l1flags, "-S");
|
||||
Sflag = 1;
|
||||
break;
|
||||
|
||||
#if !HAVE_CONFIG_H
|
||||
case 't':
|
||||
if (sflag)
|
||||
usage();
|
||||
freelst(&lcflags);
|
||||
appcstrg(&lcflags, "-traditional");
|
||||
appstrg(&lcflags, concat2("-D", MACHINE));
|
||||
appstrg(&lcflags, concat2("-D", MACHINE_ARCH));
|
||||
appcstrg(&l1flags, "-t");
|
||||
appcstrg(&l2flags, "-t");
|
||||
tflag = 1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'x':
|
||||
appcstrg(&l2flags, "-x");
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
if (Cflag || oflag || iflag)
|
||||
usage();
|
||||
Cflag = 1;
|
||||
appstrg(&l2flags, concat2("-C", optarg));
|
||||
p2out = xmalloc(sizeof ("llib-l.ln") + strlen(optarg));
|
||||
(void)sprintf(p2out, "llib-l%s.ln", optarg);
|
||||
freelst(&deflibs);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (dflag)
|
||||
usage();
|
||||
dflag = 1;
|
||||
appcstrg(&cflags, "-nostdinc");
|
||||
appcstrg(&cflags, "-idirafter");
|
||||
appcstrg(&cflags, optarg);
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
case 'I':
|
||||
case 'M':
|
||||
case 'U':
|
||||
(void)sprintf(flgbuf, "-%c", c);
|
||||
appstrg(&cflags, concat2(flgbuf, optarg));
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
appcstrg(&libs, optarg);
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
if (Cflag || oflag)
|
||||
usage();
|
||||
oflag = 1;
|
||||
outputfn = xstrdup(optarg);
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
appcstrg(&libsrchpath, optarg);
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
appcstrg(&l2flags, "-H");
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
Bflag = 1;
|
||||
libexec_path = xstrdup(optarg);
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
Vflag = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
/*
|
||||
* To avoid modifying getopt(3)'s state engine midstream, we
|
||||
* explicitly accept just a few options after the first source file.
|
||||
*
|
||||
* In particular, only -l<lib> and -L<libdir> (and these with a space
|
||||
* after -l or -L) are allowed.
|
||||
*/
|
||||
while (argc > 0) {
|
||||
const char *arg = argv[0];
|
||||
|
||||
if (arg[0] == '-') {
|
||||
char ***list;
|
||||
|
||||
/* option */
|
||||
switch (arg[1]) {
|
||||
case 'l':
|
||||
list = &libs;
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
list = &libsrchpath;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
if (arg[2])
|
||||
appcstrg(list, arg + 2);
|
||||
else if (argc > 1) {
|
||||
argc--;
|
||||
appcstrg(list, *++argv);
|
||||
} else
|
||||
usage();
|
||||
} else {
|
||||
/* filename */
|
||||
fname(arg);
|
||||
first = 0;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (first)
|
||||
usage();
|
||||
|
||||
if (iflag)
|
||||
terminate(0);
|
||||
|
||||
if (!oflag) {
|
||||
if ((tmp = getenv("LIBDIR")) == NULL || strlen(tmp) == 0)
|
||||
tmp = PATH_LINTLIB;
|
||||
appcstrg(&libsrchpath, tmp);
|
||||
findlibs(libs);
|
||||
findlibs(deflibs);
|
||||
}
|
||||
|
||||
(void)printf("Lint pass2:\n");
|
||||
lint2();
|
||||
|
||||
if (oflag)
|
||||
cat(p2in, outputfn);
|
||||
|
||||
if (Cflag)
|
||||
p2out = NULL;
|
||||
|
||||
terminate(0);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a file name from the command line
|
||||
* and pass it through lint1 if it is a C source.
|
||||
*/
|
||||
static void
|
||||
fname(const char *name)
|
||||
{
|
||||
const char *bn, *suff;
|
||||
char **args, *ofn, *p, *pathname;
|
||||
size_t len;
|
||||
int is_stdin;
|
||||
int fd;
|
||||
|
||||
is_stdin = (strcmp(name, "-") == 0);
|
||||
bn = lbasename(name, '/');
|
||||
suff = lbasename(bn, '.');
|
||||
|
||||
if (strcmp(suff, "ln") == 0) {
|
||||
/* only for lint2 */
|
||||
if (!iflag)
|
||||
appcstrg(&p2in, name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_stdin && strcmp(suff, "c") != 0 &&
|
||||
(strncmp(bn, "llib-l", 6) != 0 || bn != suff)) {
|
||||
warnx("unknown file type: %s\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!iflag || !first)
|
||||
(void)printf("%s:\n",
|
||||
is_stdin ? "{standard input}" : Fflag ? name : bn);
|
||||
|
||||
/* build the name of the output file of lint1 */
|
||||
if (oflag) {
|
||||
ofn = outputfn;
|
||||
outputfn = NULL;
|
||||
oflag = 0;
|
||||
} else if (iflag) {
|
||||
if (is_stdin) {
|
||||
warnx("-i not supported without -o for standard input");
|
||||
return;
|
||||
}
|
||||
ofn = xmalloc(strlen(bn) + (bn == suff ? 4 : 2));
|
||||
len = bn == suff ? strlen(bn) : (size_t)((suff - 1) - bn);
|
||||
(void)sprintf(ofn, "%.*s", (int)len, bn);
|
||||
(void)strcat(ofn, ".ln");
|
||||
} else {
|
||||
ofn = xmalloc(strlen(tmpdir) + sizeof ("lint1.XXXXXX"));
|
||||
(void)sprintf(ofn, "%slint1.XXXXXX", tmpdir);
|
||||
fd = mkstemp(ofn);
|
||||
if (fd == -1) {
|
||||
warn("can't make temp");
|
||||
terminate(-1);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
if (!iflag)
|
||||
appcstrg(&p1out, ofn);
|
||||
|
||||
args = xcalloc(1, sizeof (char *));
|
||||
|
||||
/* run cc */
|
||||
|
||||
if (getenv("CC") == NULL) {
|
||||
pathname = xmalloc(strlen(PATH_USRBIN) + sizeof ("/cc"));
|
||||
(void)sprintf(pathname, "%s/cc", PATH_USRBIN);
|
||||
appcstrg(&args, pathname);
|
||||
} else {
|
||||
pathname = strdup(getenv("CC"));
|
||||
for (p = strtok(pathname, " \t"); p; p = strtok(NULL, " \t"))
|
||||
appcstrg(&args, p);
|
||||
}
|
||||
|
||||
applst(&args, cflags);
|
||||
applst(&args, lcflags);
|
||||
appcstrg(&args, name);
|
||||
|
||||
/* we reuse the same tmp file for cpp output, so rewind and truncate */
|
||||
if (lseek(cppoutfd, (off_t)0, SEEK_SET) != 0) {
|
||||
warn("lseek");
|
||||
terminate(-1);
|
||||
}
|
||||
if (ftruncate(cppoutfd, (off_t)0) != 0) {
|
||||
warn("ftruncate");
|
||||
terminate(-1);
|
||||
}
|
||||
|
||||
runchild(pathname, args, cppout, cppoutfd);
|
||||
free(pathname);
|
||||
freelst(&args);
|
||||
|
||||
/* run lint1 */
|
||||
|
||||
if (!Bflag) {
|
||||
pathname = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint1") +
|
||||
strlen(target_prefix));
|
||||
(void)sprintf(pathname, "%s/%slint1", PATH_LIBEXEC,
|
||||
target_prefix);
|
||||
} else {
|
||||
/*
|
||||
* XXX Unclear whether we should be using target_prefix
|
||||
* XXX here. --thorpej@wasabisystems.com
|
||||
*/
|
||||
pathname = xmalloc(strlen(libexec_path) + sizeof ("/lint1"));
|
||||
(void)sprintf(pathname, "%s/lint1", libexec_path);
|
||||
}
|
||||
|
||||
appcstrg(&args, pathname);
|
||||
applst(&args, l1flags);
|
||||
appcstrg(&args, cppout);
|
||||
appcstrg(&args, ofn);
|
||||
|
||||
runchild(pathname, args, ofn, -1);
|
||||
free(pathname);
|
||||
freelst(&args);
|
||||
|
||||
appcstrg(&p2in, ofn);
|
||||
free(ofn);
|
||||
|
||||
free(args);
|
||||
}
|
||||
|
||||
static void
|
||||
runchild(const char *path, char *const *args, const char *crfn, int fdout)
|
||||
{
|
||||
int status, rv, signo, i;
|
||||
|
||||
if (Vflag) {
|
||||
for (i = 0; args[i] != NULL; i++)
|
||||
(void)printf("%s ", args[i]);
|
||||
(void)printf("\n");
|
||||
}
|
||||
|
||||
currfn = crfn;
|
||||
|
||||
(void)fflush(stdout);
|
||||
|
||||
switch (vfork()) {
|
||||
case -1:
|
||||
warn("cannot fork");
|
||||
terminate(-1);
|
||||
/* NOTREACHED */
|
||||
default:
|
||||
/* parent */
|
||||
break;
|
||||
case 0:
|
||||
/* child */
|
||||
|
||||
/* setup the standard output if necessary */
|
||||
if (fdout != -1) {
|
||||
dup2(fdout, STDOUT_FILENO);
|
||||
close(fdout);
|
||||
}
|
||||
(void)execvp(path, args);
|
||||
warn("cannot exec %s", path);
|
||||
_exit(1);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
while ((rv = wait(&status)) == -1 && errno == EINTR) ;
|
||||
if (rv == -1) {
|
||||
warn("wait");
|
||||
terminate(-1);
|
||||
}
|
||||
if (WIFSIGNALED(status)) {
|
||||
signo = WTERMSIG(status);
|
||||
#if HAVE_DECL_SYS_SIGNAME
|
||||
warnx("%s got SIG%s", path, sys_signame[signo]);
|
||||
#else
|
||||
warnx("%s got signal %d", path, signo);
|
||||
#endif
|
||||
terminate(-1);
|
||||
}
|
||||
if (WEXITSTATUS(status) != 0)
|
||||
terminate(-1);
|
||||
currfn = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
findlibs(char *const *liblst)
|
||||
{
|
||||
int i, k;
|
||||
const char *lib, *path;
|
||||
char *lfn;
|
||||
size_t len;
|
||||
|
||||
lfn = NULL;
|
||||
|
||||
for (i = 0; (lib = liblst[i]) != NULL; i++) {
|
||||
for (k = 0; (path = libsrchpath[k]) != NULL; k++) {
|
||||
len = strlen(path) + strlen(lib);
|
||||
lfn = xrealloc(lfn, len + sizeof ("/llib-l.ln"));
|
||||
(void)sprintf(lfn, "%s/llib-l%s.ln", path, lib);
|
||||
if (rdok(lfn))
|
||||
break;
|
||||
lfn = xrealloc(lfn, len + sizeof ("/lint/llib-l.ln"));
|
||||
(void)sprintf(lfn, "%s/lint/llib-l%s.ln", path, lib);
|
||||
if (rdok(lfn))
|
||||
break;
|
||||
}
|
||||
if (path != NULL) {
|
||||
appstrg(&l2libs, concat2("-l", lfn));
|
||||
} else {
|
||||
warnx("cannot find llib-l%s.ln", lib);
|
||||
}
|
||||
}
|
||||
|
||||
free(lfn);
|
||||
}
|
||||
|
||||
static int
|
||||
rdok(const char *path)
|
||||
{
|
||||
struct stat sbuf;
|
||||
|
||||
if (stat(path, &sbuf) == -1)
|
||||
return (0);
|
||||
if (!S_ISREG(sbuf.st_mode))
|
||||
return (0);
|
||||
if (access(path, R_OK) == -1)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
lint2(void)
|
||||
{
|
||||
char *path, **args;
|
||||
|
||||
args = xcalloc(1, sizeof (char *));
|
||||
|
||||
if (!Bflag) {
|
||||
path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint2") +
|
||||
strlen(target_prefix));
|
||||
(void)sprintf(path, "%s/%slint2", 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 ("/lint2"));
|
||||
(void)sprintf(path, "%s/lint2", libexec_path);
|
||||
}
|
||||
|
||||
appcstrg(&args, path);
|
||||
applst(&args, l2flags);
|
||||
applst(&args, l2libs);
|
||||
applst(&args, p2in);
|
||||
|
||||
runchild(path, args, p2out, -1);
|
||||
free(path);
|
||||
freelst(&args);
|
||||
free(args);
|
||||
}
|
||||
|
||||
static void
|
||||
cat(char *const *srcs, const char *dest)
|
||||
{
|
||||
int ifd, ofd, i;
|
||||
char *src, *buf;
|
||||
ssize_t rlen;
|
||||
|
||||
if ((ofd = open(dest, O_WRONLY | O_CREAT | O_TRUNC, 0666)) == -1) {
|
||||
warn("cannot open %s", dest);
|
||||
terminate(-1);
|
||||
}
|
||||
|
||||
buf = xmalloc(MBLKSIZ);
|
||||
|
||||
for (i = 0; (src = srcs[i]) != NULL; i++) {
|
||||
if ((ifd = open(src, O_RDONLY)) == -1) {
|
||||
free(buf);
|
||||
warn("cannot open %s", src);
|
||||
terminate(-1);
|
||||
}
|
||||
do {
|
||||
if ((rlen = read(ifd, buf, MBLKSIZ)) == -1) {
|
||||
free(buf);
|
||||
warn("read error on %s", src);
|
||||
terminate(-1);
|
||||
}
|
||||
if (write(ofd, buf, (size_t)rlen) == -1) {
|
||||
free(buf);
|
||||
warn("write error on %s", dest);
|
||||
terminate(-1);
|
||||
}
|
||||
} while (rlen == MBLKSIZ);
|
||||
(void)close(ifd);
|
||||
}
|
||||
(void)close(ofd);
|
||||
free(buf);
|
||||
}
|
Loading…
Reference in New Issue
Block a user