Commit Graph

18186 Commits

Author SHA1 Message Date
chs 5b182ca27f revert rev 1.45:
"PR/54435: Adjust for new kernel behavior of soreceive(9) clearing MSG_OOB"

That change was trying to make rlogin work again after the SIOCATMARK ioctl
was broken, but that kernel bug has now been fixed, so the original rlogin code
now works again.  Further, the changed rlogin code actually did the wrong thing,
by treating reception of the MSG_OOB byte as meaning that we are now
"at the mark", but that is not true... we are "at the mark" only when
we have reached the point in the stream where the MSG_OOB byte was originally,
as indicated by SIOCATMARK.  So going back to the previous code seems best
all around.  ok'd by christos.
2021-08-03 23:21:07 +00:00
rillig 3c10f94429 lint: in strict enum mode, error out on enum type mismatch in union cast 2021-08-03 21:18:24 +00:00
rillig d1299c8ce2 lint: merge almost duplicate code from 'sametype' into 'eqtype'
In 'sametype', the branch for comparing array types was unreachable
since it requires both tspecs to be the same, but t2 underwent the
array-to-pointer conversion.

Previously, lint warned about enum type mismatches, even without -e for
strict enum mode.  Instead, it got the case for 'char *' wrong, which is
now fixed.  Now lint behaves like GCC 10.3.0 in this regard.  The
warning about enum mismatch is useful though, so it may be re-added in a
future commit.
2021-08-03 21:09:26 +00:00
rillig 0f4668a0cb lint: union casts are only available as a GCC extension, not in C99 2021-08-03 20:57:06 +00:00
rillig 84c976b4ec lint: add quotes around placeholder in message 214
function '%s' expects to return value
2021-08-03 18:44:33 +00:00
rillig 3c6cb8a22e lint: casting to a struct is not allowed in C99, only with GCC 2021-08-03 18:38:02 +00:00
rillig 8fbeda539f lint: clean up and move 'sametype'
This function is only used by lint1.  That's good since the lint2 code
was completely broken, as it would regard any two struct types as being
the same.

Remove the large switch statement since it is unlikely that there will
be new type derivations in C anytime soon.

No functional change.
2021-08-03 17:44:58 +00:00
rillig 68912c0f97 lint: reduce number of negations in preprocessor condition
No functional change.
2021-08-03 17:27:48 +00:00
rillig 6e889c432d lint: make memory management code easier to read
No functional change.
2021-08-03 17:20:02 +00:00
wiz 3fcad1e7d3 Document :On modifiers in more detail. 2021-08-03 07:12:50 +00:00
rillig 4f67effb7c tests/make: fix test for the variable modifier ':On'
The variable modifier ':On' sorts words numerically.  If these words are
not numeric at all, they get assigned the numeric value 0.  Internally,
':On' uses qsort for sorting the words.  Since qsort is not specified to
use a stable sorting algorithm, the test data must only use words that
either are written in the same way or that are numerically different.

The test varmod-order failed this requirement by trying to numerically
sort a list of non-numeric words.  This led to different results on BSD
and Ubuntu, as could be expected.

To fix the tests, distinguish between words and numbers in the tests.
While here, clean up the tests for all variants of the variable modifier
':O'.

Found by sjg on Ubuntu.
2021-08-03 04:46:49 +00:00
rillig 7e10b3b4ac lint: expand abbreviations in definitions of operator properties
No functional change.
2021-08-02 20:58:39 +00:00
andvar 077d1c0f36 fix various typos in comments and log messages. 2021-08-02 12:56:22 +00:00
rillig f4aacdc985 lint: clean up debug logging in the C grammar 2021-08-01 19:18:10 +00:00
rillig a11f7ac3ff lint: merge duplicate debugging code
The functions 'debug_node' and 'display_expression' were similar enough
to be merged.

Migrate debug_node to use the existing debug logging functions.

Remove the now unused option 'd' from the options string.
2021-08-01 19:11:54 +00:00
rillig f8d01ed580 lint: remove option -d, clean up debug logging
The command line option -d was not used by /usr/bin/lint, and it only
triggered a handful of debug messages.  Move this debug logging over to
the compile-time -DDEBUG setting.

Move display_expression further up to avoid the forward declaration.
2021-08-01 18:37:29 +00:00
rillig 86a595a37f lint: make xasprintf simpler
No functional change.
2021-08-01 18:13:53 +00:00
rillig cd66f68dee lint: unexport nomem
No functional change.
2021-08-01 18:07:35 +00:00
rillig fdcb9d74e4 lint: remove xmapalloc
Just trust the standard malloc to be smart enough.

No functional change.
2021-08-01 17:59:47 +00:00
andvar c651c20bd5 fix syntax error and typo in overwritten. 2021-08-01 15:52:11 +00:00
andvar 4b2769fe52 fix typos in word "otherwise". 2021-08-01 15:29:29 +00:00
rillig 05d4ee4022 lint: remove unreachable code from usual arithmetic conversions 2021-08-01 14:45:39 +00:00
rillig f33386540b lint: fix usual arithmetic conversions for 128-bit integer types 2021-08-01 13:49:17 +00:00
rillig 653952f0ab lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value
since that belongs to the symbol table.  This makes the code for the
symbol table simpler.  The number of hash calculations increases by
about 5%, which is negligible.

No functional change.
2021-08-01 08:03:43 +00:00
rillig e2febd0a7c lint: merge duplicate code for removing a symbol from the table
No functional change.
2021-08-01 07:46:51 +00:00
rillig a3ba24d77a lint: extract duplicate code for modifying the symbol table
No functional change.
2021-08-01 06:58:58 +00:00
rillig b25dbe034a lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault,
probably related to the symbol table.  To better understand this part,
log insertions and deletions.

The other debug log messages do not need to mention the current file
position anymore, this is what lex_next_line takes care of since scan.l
1.113 from 2021-01-05.
2021-08-01 06:40:37 +00:00
rillig c790f31b75 tests/make: split tests for the variable modifier ':O'
The tests for parse errors are now in varmod-order, which lets the other
tests focus on the desired behavior of the modifiers.
2021-07-31 20:55:45 +00:00
rillig 89727fbc98 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.
2021-07-31 19:52:44 +00:00
rillig b344f57d7d lint: initialize shared types in the same order as in tspec_t
This makes it easier to see whether there are any types missing, such as
__uint128_t.

No functional change.
2021-07-31 19:20:59 +00:00
rillig 6e400373b9 lint: do not evaluate arguments of debug_step
To analyze the unexpected test failure of op_shl_lp64, I had reverted
debug_step to evaluate its arguments.  I then accidentally committed
that without running the tests again.

Anyway, the previous commit can now be used as a demonstration that
initdecl is indeed missing the initialization for __uint128_t, which
leads to the internal error in op_shl_lp64.
2021-07-31 19:12:35 +00:00
rillig bbb47da2ee lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.

Remove the debug_step0 macro and its relatives since lint already uses
enough other features from C99 that it essentially requires this
standard, which supports varargs macro arguments.  Among these features
are __func__ and printf("%zu").

In non-debug mode, do not evaluate the arguments of debug_step.
Evaluating the arguments had caused an internal error when running the
test op_shl_lp64.  This is indeed a bug since initdecl should have
initialized the type table for __uint128_t.  This had been forgotten
when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.

No functional change.
2021-07-31 19:07:52 +00:00
rillig de0175e8f1 lint: extract debug logging to separate file
Lint currently has several different kinds of debug log:

* The -DDEBUG log is controlled at compile time.
* The -d command line options enables some other debug logging.
* The -DYYDEBUG log for parsing is controlled at compile time.
* The -y command line option only has an effect in -DYYDEBUG mode.

Extracting the logging into a separate file is a first step towards
unifying these logs and making the code for debug logging stand out less
than the current #ifdef DEBUG.

No functional change.
2021-07-31 18:16:42 +00:00
rillig 535a64a8ac lint: add debugging output for the grammar tokens
No functional change outside debug mode.
2021-07-31 17:09:21 +00:00
rillig 413d9dbf37 lint: reduce indentation in 'search'
No functional change.
2021-07-31 13:47:19 +00:00
rillig 80a480a84e lint: in has_constant_member, don't reuse variables
No functional change.
2021-07-31 11:37:53 +00:00
rillig c4f8523995 lint: merge duplicate code for generating unqualified type
This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.
2021-07-31 11:03:04 +00:00
rillig cc821a91f9 make: fix lint warnings
The string functions from str.h are declared as 'static __unused' when
compiled with GCC, but lint explicitly undefines __GCC__ during
preprocessing.  Therefore, make those functions inline, to prevent
warnings that they are unused.

The macro UNCONST is used in a few places, and (again) since lint
undefines __GCC__, that macro expanded to a simple type cast, which lint
warned about.  To prevent this warning, implement UNCONST as a function
that works everywhere and hides the type cast.

In filemon_open, the code for closing F->in was obviously unreachable.

No functional change.
2021-07-31 09:30:17 +00:00
rillig 51085f5d8c make: clean up ApplyModifier_Order
No functional change.
2021-07-31 00:17:04 +00:00
rillig d521eda988 make: reword comment for ApplyModifier_Order 2021-07-30 23:35:38 +00:00
rillig 3a30bed0ab make: handle parse errors in ':O' uniformly
Previously, the error handling for the variable modifier ':O' differed
depending on the exact variant and in some cases led to misleading
or missing diagnostics.
2021-07-30 23:28:04 +00:00
rillig b86e759ed8 make: merge duplicate code for sorting strings and numbers
No functional change.
2021-07-30 22:19:51 +00:00
rillig 5884a722aa make: fix typo in manual page, add more tests for the new ':On' 2021-07-30 22:16:09 +00:00
sjg 4696d0f378 Add :On for numeric sort
Reviewed by: christos rillig
2021-07-30 19:55:22 +00:00
rillig c396046123 make: in TryParseNumber, reset errno as late as possible
No functional change.
2021-07-29 06:35:20 +00:00
rillig 5462b7db97 tests/make: test spaces around numbers in comparisons
Just to see whether it is possible to write a conditional in the form
${ ${A} < ${B} :? ${A} : ${B} }, that is, with leading and trailing
whitespace, to make it easier for humans to read the code.

It's not possible, the result of this computation cannot be used in
further numeric comparisons, at least not in .if directives.  Leading
space would work, but trailing space wouldn't.

On the other hand, they would work in expressions of the form
${ ${A} < ${B} :? ... : ... } since in these, the condition is first
expanded and then parsed.  But that is an implementation detail that is
not documented and it is also difficult to understand.
2021-07-29 06:31:18 +00:00
rillig 3c18a23cd9 lint: inline align_as in the grammar
This saves 500 bytes in the resulting binary.

No functional change.
2021-07-27 05:52:53 +00:00
rillig 6e9ad9dcae lint: provide a direct link to the documentation
No functional change.
2021-07-27 05:42:36 +00:00
rillig 2116d9a5d9 lint: fix parse error in conditional expression (since 2021-07-15) 2021-07-26 18:10:14 +00:00
rillig 51b2be3c67 lint: fix parsing of chained assignments (since 2021-07-15)
The grammar rule for assignment_expression is quite different from those
of the other expressions, for 2 reasons: first, its precedence is
right-to-left.  Second, its left-hand side must be an lvalue, which
rules out all binary operators.  K&R C even had a grammar rule named
'lvalue' for this purpose.  Later C standards made the kinds of
expressions more fine-grained and used 'unary_expression' in this place.
2021-07-26 17:27:22 +00:00