Home | History | Annotate | Download | only in lint2
History log of /src/usr.bin/xlint/lint2/read.c
RevisionDateAuthorComments
 1.93  30-Nov-2024  rillig lint: reword lint2 warnings, reduce punctuation

The previous diagnostics used unusual punctuation, for example by placing
spaces inside parentheses, as well as using space-space-tab and
double-colon as separators. Convert these diagnostics into readily
readable prose, and mark them clearly as coming from lint2, so that they
can be related to the tests in /usr/tests/usr.bin/xlint/lint2/msg_???.ln.

This change means that usr.bin/error no longer recognizes these messages
as coming from lint2, but that can be fixed later if necessary.
 1.92  12-May-2024  rillig branches: 1.92.2;
lint: add wrapper for <ctype.h> functions, for strict bool mode

When using the Clang preprocessor (with MKLLVM=yes), the preprocessor
output does not indicate which tokens come from a system header and
which tokens come from the user code. Lint's strict bool mode relies on
this information to treat the character classification functions from
<ctype.h> as if their return type were bool instead of int.

These wrapper functions are only used when their argument is indeed a
'char', but not when the argument might be 'EOF or representable as an
unsigned char', such as when reading a byte from the input.
 1.91  02-Mar-2024  rillig lint: remove custom wrappers around <ctype.h> functions
 1.90  03-Dec-2023  rillig lint: in declarations, replace tab with space

Previously, in some cases, the keywords 'const' or 'struct' were
followed by a tab, which doesn't make sense.

No functional change.
 1.89  03-Dec-2023  rillig lint: re-wrap comments

No functional change.
 1.88  03-Dec-2023  rillig lint: indent statement continuations consistently

No binary change.
 1.87  13-Jul-2023  rillig lint: indent copyright lines consistently
 1.86  10-Jul-2023  rillig lint: push memory management one layer down

Just as with type_name in lint1, it is more convenient if the
application code does not have to deal with memory management.
 1.85  10-Jul-2023  rillig lint: clean up lint2
 1.84  10-Jul-2023  rillig lint: clean up wchar_t and hash tables
 1.83  08-Jul-2023  rillig lint: enable more lint warnings for its own source code
 1.82  03-Jul-2023  rillig lint: rename uppercase QUAD to LLONG

No binary change.
 1.81  09-Jun-2023  rillig lint: indent local variables consistently

No binary change.
 1.80  22-May-2023  rillig lint: rename constant NOTSPEC to NO_TSPEC

It was too easy to misread the old name as NOT_SPEC instead of the
intended NO_TSPEC.
 1.79  21-Feb-2023  rillig lint: use __printflike
 1.78  14-Jan-2023  rillig lint: clean up messages for internal errors
 1.77  13-Jan-2023  rillig lint: move xalloc to the only file where it is used

No functional change.
 1.76  20-May-2022  rillig lint: use __RCSID in lint mode as well

Since 1995-10-02, lint supports __asm statements and __asm modifiers.

No binary change.
 1.75  19-Dec-2021  rillig lint: remove redundant braces

No binary change.
 1.74  19-Dec-2021  rillig lint: reduce pointer usage when reading .ln lines

No binary change.
 1.73  19-Dec-2021  rillig lint: remove unused parameter in read_ln_line
 1.72  16-Dec-2021  rillig lint: improve error message for missing newline in .ln file
 1.71  28-Nov-2021  rillig lint2: in case of parse errors, output the offending line

This provides more of a clue than a simple '(not alnum or _: )',
especially in the output of build.sh.

While here, change the format of the error message to the standard
'%s:%d'. Since these are internal errors, they are not supposed to occur
often, so no need to change error(1).
 1.70  28-Nov-2021  rillig lint: move fgetln peculiarities out of read_ln_line

This allows the function parameter to be a pointer to const.

No functional change.
 1.69  16-Nov-2021  rillig lint: clean up lint2

No functional change.
 1.68  16-Nov-2021  rillig lint: clean up initialization of lint2 symbol table

No functional change.
 1.67  05-Sep-2021  rillig lint: remove source code references from internal error message

The additional strings that are provided with the error message are
distinctive enough.
 1.66  05-Sep-2021  rillig lint: extract function for reading a single line from a .ln file

No functional change.
 1.65  05-Sep-2021  rillig lint: fix some more lint warnings

The only remaining warnings are in scan.c, which is a generated Flex
scanner.

No functional change.
 1.64  04-Sep-2021  rillig lint: reduce complexity of reading a function call

No functional change.
 1.63  30-Aug-2021  rillig lint: extract parse_function_attribute from decldef

No functional change.
 1.62  30-Aug-2021  rillig lint: remove redundant call to strchr in decldef

This time, the branches for varargs, printflike and scanflike in the big
switch statement are covered by unit tests. These tests would have
caught the previous "cleanup" that broke parsing of these function
attributes. Furthermore, this second cleanup is closer to the original
code and conceptually simpler since it avoids having many 'continue'
statements in a 'switch' statement, which would have been unusual.

The branches for inline functions and used functions are still not
covered by the tests, but they are structurally equal to several other
branches.

No functional change.
 1.61  30-Aug-2021  rillig lint: revert "remove redundant call to strchr" from yesterday

This "refactoring" broke the parsing code for varargs, printflike and
scanflike functions, and there were no tests for these. Revert for now,
maybe try again later, after adding the corresponding tests.
 1.60  30-Aug-2021  christos Move the character one back so that we don't increment twice
 1.59  30-Aug-2021  christos Skip the current character before parsing the number of arguments.
 1.58  29-Aug-2021  rillig lint: remove redundant call to strchr
 1.57  29-Aug-2021  rillig lint: un-abbreviate members of sym_t

No functional change.
 1.56  28-Aug-2021  rillig lint: un-abbreviate unsigned integer types

No functional change.
 1.55  22-Aug-2021  rillig lint: clean up error handling in lint2

These are edge cases that don't happen in practice, therefore reduce the
size of the binary.
 1.54  22-Aug-2021  rillig lint: use unsigned integers for storing hash values

The computation of the hash values is unchanged, only the resulting
value (which is always less than 1009 anyway, see HSHSIZ2) is stored as
unsigned as well.

No functional change.
 1.53  22-Aug-2021  rillig lint: simplify reading of type qualifiers in lint2

The only producer of .ln files is lint1, which always writes the type
qualifiers in the order 'c', 'v', therefore there is no need to expect
any other order or check for duplicates. There is no ambiguity since
the other type modifiers are neither 'c' nor 'v' and the main types are
all uppercase letters.

No functional change.
 1.52  22-Aug-2021  rillig lint: clean up switch statements in gettlen

Since the switch statements are only about tagged and derived types,
there is no need to list all integer and floating types.

No functional change.
 1.51  22-Aug-2021  rillig lint: convert TP from macro to inline function

No functional change.
 1.50  22-Aug-2021  rillig lint: extract parse_tspec from inptype

Add error handling for unknown type character, which led to read of
uninitialized memory before. No practical change as far as lint2 only
ever reads output from lint1, since that is well-formed.
 1.49  08-Aug-2021  rillig lint: force strict bool mode

No functional change.
 1.48  05-Aug-2021  rillig lint: fix type of local variable in inpqstrg

Noted by Clang-Tidy.
 1.47  05-Aug-2021  rillig lint: fix handling of __int128_t/__uint128_t in lint2

Previously, lint exited with "bad type: J u".
 1.46  31-Jul-2021  rillig lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.
 1.45  18-Apr-2021  rillig lint: remove WARNS=3, falling back to the default WARNS=5

It's strange that GCC does not warn about the nonliteral format strings
in lint1/err.c, lint2/msg.c and lint2/read.c, despite -Wformat=2, but
Clang does.
 1.44  18-Apr-2021  rillig lint: reduce duplicate code for parsing .ln files
 1.43  18-Apr-2021  rillig lint: fix error message in lint2 for missing record type in .ln file
 1.42  02-Apr-2021  rillig lint: add parentheses after sizeof, as required by share/misc/style

No functional change.
 1.41  26-Mar-2021  rillig lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'

No functional change.
 1.40  28-Feb-2021  rillig lint2: align comments in the code with actual messages
 1.39  19-Feb-2021  rillig lint: rename t_isenum and t_aincompl to be more expressive

No functional change.
 1.38  16-Jan-2021  rillig lint: replace integer constant expressions with true and false

LINTFLAGS=-gST make lint, with manual review.

The error messages from lint are all correct, they are not complete
though. The return value of a function returning bool may still be
compared to the integer 0.
 1.37  16-Jan-2021  rillig lint: replace 0 and 1 with false and true, where appropriate

Change in behavior: Passing the option -h exactly 4294967296 times or
any multiple thereof is no longer equivalent to passing it never at all,
it is now equivalent to passing it once. See main2.c, hflag++ for the
actual change.

Other than that, no functional change intended.

A very large portion of the code already conformed to the requirements
of the strict bool mode. The only missing thing was using the constant
literals false and true instead of 0 and 1. For sure there are some
integer literals left that can be converted. For now, all literals that
appeared in the form " = 0" or " = 1" have been replaced.
 1.36  04-Jan-2021  rillig lint: fix typos and other minor stylistic issues
 1.35  01-Jan-2021  rillig lint: remove NTSPEC from enum tspec_t

The number of elements in an enumeration is not a valid enum constant of
that enumeration itself.
 1.34  30-Dec-2020  rillig lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.
 1.33  30-Dec-2020  rillig lint: rename more _nxt members to _next
 1.32  30-Dec-2020  rillig lint: rename s_nxt to s_next
 1.31  29-Dec-2020  rillig lint: fix indentation and alignment that used space-tab
 1.30  29-Dec-2020  rillig lint: remove redundant parentheses around return value
 1.29  28-Dec-2020  rillig lint: sort includes
 1.28  07-Sep-2018  christos recognize int128
 1.27  26-Dec-2017  christos branches: 1.27.2; 1.27.4;
Don't print duplicate definitions for inline symbols.
 1.26  18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.25  15-Apr-2009  christos Lukemify (WARNS=4)
 1.24  14-Apr-2009  lukem Fix -Wshadow and -Wcast-qual issues
 1.23  26-Sep-2008  matt branches: 1.23.6;
Teach lint about long double _Complex (C99)
 1.22  26-Apr-2008  christos make the complex float/double annotated consistently with regular float/double.
 1.21  26-Apr-2008  christos - simplify logic in getting the filename index.
- fix an allocation botch.
 1.20  25-Apr-2008  christos preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.
 1.19  28-Sep-2007  uwe branches: 1.19.6;
tlst[inptype(...)] is bad C code because inptype() can realloc tlst
and there's no intermediate sequence point! We actually hit this on
sh3 with -O2 where gcc4 caches tlst in a register prior to recursive
call to inptype() and if you are unlucky the recursive call needs to
realloc tlst.

Introduce a temp variable to force a sequence point.
 1.18  22-Mar-2006  christos branches: 1.18.6; 1.18.8; 1.18.12;
gcc says case is missing, coverity says case not reached. Appease both.
 1.17  22-Mar-2006  christos Coverity CID 46: Remove dead code.
 1.16  16-Jul-2005  christos - make input errors print the lint source line number they are called from.
- simplify a conditional.
 1.15  12-Sep-2004  yamt recognize _Bool.
 1.14  20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.13  31-Jan-2002  tv branches: 1.13.4;
Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.12  21-Jan-2002  tv Add hooks for compiling on non-NetBSD hosts.
 1.11  03-Jan-2002  tron Add "case" statements for "NTSPEC" to fix "gcc" warnings.
 1.10  26-Jul-2001  wiz Various typos in comments (neccessary, sceme, choise, ...).
 1.9  28-May-2001  lukem cleanup (prior to more adding more features):
- convert to ANSI KNF
- remove trailing whitespace
- translate some comments from german into english

code compiles and runs clean, and tested by running "make lint" against
xlint source using previous and this lint produces same results.
 1.8  14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.7  20-Dec-1998  christos branches: 1.7.8;
char -> unsigned char
 1.6  27-Jul-1998  mycroft Fix uses of uninitialized memory, and incorrect types for initializers.
From ITOH Yasufumi, PR 5861.
 1.5  22-Feb-1998  christos WARNSify
 1.4  03-Nov-1997  cgd implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.
 1.3  22-Dec-1996  cgd branches: 1.3.2;
* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.
 1.2  03-Jul-1995  cgd RCS id cleanup
 1.1  03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1  03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.3.2.1  04-Nov-1997  thorpej Pull up from trunk: make renaming work and other minor fixes.
 1.7.8.1  23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.13.4.1  22-Jun-2004  tron Pull up revision 1.14 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.18.12.1  06-Nov-2007  matt sync with HEAD
 1.18.8.1  30-Sep-2007  wrstuden Catch up w/ last night's netbsd-4
 1.18.6.1  28-Sep-2007  xtraeme Pull up following revision(s) (requested by uwe in ticket #907):
usr.bin/xlint/lint2/read.c: revision 1.19

tlst[inptype(...)] is bad C code because inptype() can realloc tlst
and there's no intermediate sequence point! We actually hit this on
sh3 with -O2 where gcc4 caches tlst in a register prior to recursive
call to inptype() and if you are unlucky the recursive call needs to
realloc tlst.
Introduce a temp variable to force a sequence point.
 1.19.6.1  18-May-2008  yamt sync with head.
 1.23.6.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.27.4.1  10-Jun-2019  christos Sync with HEAD
 1.27.2.1  30-Sep-2018  pgoyette Ssync with HEAD
 1.92.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed