Commit Graph

6122 Commits

Author SHA1 Message Date
rillig 2e1f799d6b indent: remove accidental space before tab 2023-05-15 17:38:56 +00:00
rillig 3842fd14e5 indent: remove backslash line continuation outside preprocessing
The indenter did not handle these backslashes well, interpreting them as
unary operators, and they are an edge case anyway.  Line continuations
in string literals and character constants are kept.
2023-05-15 17:28:14 +00:00
rillig c3a01c7bfa tests/indent: demonstrate wrong spacing after function prototype 2023-05-15 15:04:48 +00:00
rillig 6c38484f82 indent: fix spacing between function prototype and attributes 2023-05-15 14:55:47 +00:00
rillig c74302075d indent: fix indentation of struct member names 2023-05-15 14:12:03 +00:00
rillig 415b6afa14 tests/indent: demonstrate wrong indentation of struct members 2023-05-15 13:53:32 +00:00
rillig b33d7ae266 indent: fix indentation of statements after controlling expression 2023-05-15 13:33:19 +00:00
rillig 60722870c9 tests/indent: add another test for -eei -nlp 2023-05-15 13:28:05 +00:00
rillig 8bbe0ac207 indent: fix indentation of expressions in -nlp -eei mode 2023-05-15 12:59:43 +00:00
rillig 3801fbef33 tests/indent: test extra indentation with fixed continuation indentation 2023-05-15 12:11:07 +00:00
rillig 09166ed3ac indent: fix indentation of multi-line '?:' expressions in functions 2023-05-15 10:13:40 +00:00
rillig e311e1f8e6 tests/indent: -badp should not add blank lines in initializers 2023-05-15 09:05:08 +00:00
rillig 89e0e636cf indent: fix spacing in for loop with declaration (since 2022-02-13) 2023-05-15 08:56:39 +00:00
rillig f382e6fe26 tests/indent: demonstrate wrong spacing in for loops 2023-05-15 08:22:23 +00:00
rillig 9a2185a149 indent: clean up memory and buffer management
Remove the need to explicitly initialize the buffers.  To avoid
subtracting null pointers or comparing them using '<', migrate the
buffers from the (start, end) form to the (start, len) form.  This form
also avoids inconsistencies in whether 'buf.e == buf.s' or 'buf.s ==
buf.e' is used.

Make buffer.st const, to avoid accidental modification of the buffer's
content.

Replace '*buf.e++ = ch' with buf_add_char, to avoid having to keep track
how much unwritten space is left in the buffer.  Remove all safety
margins, that is, no more unchecked access to buf.st[-1] or appending
using '*buf.e++'.

Fix line number counting in lex_word for words that contain line breaks.

No functional change.
2023-05-15 07:28:45 +00:00
rillig 506e3bec5c indent: only null-terminate the buffers if necessary
The only case where a buffer is used as a C-style string is when looking
up a keyword.

No functional change.
2023-05-14 22:26:37 +00:00
rillig 1304bdca7f indent: fix handling of multiple block comments in a line 2023-05-14 17:53:38 +00:00
rillig 217e4d847d indent: in comments, keep a leading tab
This kind of comments is used for the CVS IDs at the top of files.
2023-05-14 17:13:37 +00:00
rillig 0cd0431ee6 indent: fix vertical spacing after declarations
A comment is not supposed to change the state of the 'blank line after
declaration', but it did.  The initialization of saved_just_saw_decl was
wrong though since it tried to capture the previous value after it had
already been overwritten.
2023-05-14 16:47:06 +00:00
rillig e04d6833e7 indent: miscellaneous cleanups 2023-05-14 11:29:23 +00:00
rillig 4f2a635091 lint: add query for chained assignments 2023-05-13 20:55:44 +00:00
riastradh 1e9b358f6a openssl: More tests need -Wno-missing-field-initializers. 2023-05-13 17:46:09 +00:00
rillig c49e59f750 indent: do not add a space before a comment that starts a line 2023-05-13 16:40:18 +00:00
rillig 2261e976c8 indent: implement 'blank after declarations' 2023-05-13 15:34:22 +00:00
riastradh 61b8d55f2a openssl: libcrypto bf test needs -Wno-missing-field-initializers 2023-05-13 15:12:13 +00:00
rillig 4cae730b26 tests/indent: extend test for blank line after declaration 2023-05-13 14:19:14 +00:00
rillig 24dd152d37 indent: fix lexing of numbers that are spread over multiple lines 2023-05-13 13:31:37 +00:00
rillig 9db90c6e6b tests/indent: add test for lexing of numbers 2023-05-13 13:24:01 +00:00
rillig 842f73039b indent: clean up a condition, add comments
No functional change.
2023-05-13 09:40:47 +00:00
rillig 38caea9b89 indent: preserve indentation of preprocessor directives 2023-05-13 08:33:39 +00:00
rillig ff059387ed tests/indent: explain, clean up and add some tests 2023-05-13 06:52:48 +00:00
rillig 8ba922e8f2 tests/indent: test pushing the placeholder symbol to the parser stack 2023-05-12 22:36:15 +00:00
rillig 0cdf93c9f3 indent: remove statistics
The numbers from the statistics were wrong.
2023-05-12 10:53:33 +00:00
rillig 46afda1643 tests/indent: test interaction between preprocessing and comments 2023-05-11 21:36:31 +00:00
rillig d5678748c0 indent: don't touch comments in preprocessing lines
The indentation of multi-line comments was wrong, and the code for
handling them was too complicated.
2023-05-11 19:01:35 +00:00
rillig bacb7fc4b5 tests/indent: add more tests for preprocessing directives 2023-05-11 18:44:14 +00:00
rillig 5300eef1a9 tests/indent: test multi-line comments in preprocessing lines 2023-05-11 18:36:36 +00:00
rillig d54ae284ce indent: remove broken code for handling blank lines
This fixes several bugs where blank lines were erroneously added or
removed, treating these old bugs for new bugs in different places.
These new bugs are expected to be easier to fix, as the old bugs will
not interfere anymore.
2023-05-11 18:13:55 +00:00
rillig 3ae5a30b3c indent: add debug output for tracking comments and braces 2023-05-11 17:22:56 +00:00
christos a09aac5f84 aarch64 needs static 2023-05-11 14:34:30 +00:00
rillig 44c1f7b6a8 indent: remove unnecessary assignments to last_else
No functional change intended.
2023-05-11 10:39:25 +00:00
kre 490e17a0c9 Fix building the debugging tarball of the directory tree created for
the pathname matching tests ... this is not used in any way in a normal
test run, but if there are problems, one needs a mechanism to discover
whether the issue is with the code that creates the directory tree in the
test, or with the matching (either what the test expects to happen, or
what the shell actually does).   The couple of lines being fixed here make
that mechanism work --- I have had this in my private sources for years
now, but never got around to committing it.   It is time.  NFC for any
normal test run.
2023-05-11 10:08:34 +00:00
rillig 373317666b indent: remove buggy code for swapping tokens
It is not the job of an indenter to swap tokens, even if it's only about
placing comments elsewhere.  The code that swapped the tokens was
complicated, buggy and impossible to understand.

In -br (brace right) mode, indent no longer moves a '{' from the
beginning of a line to the end of the previous line, as that was handled
by the token swapping code as well.  This change is unintended, but it
will be easier to re-add that now that the code is simpler.
2023-05-11 09:28:53 +00:00
rillig 0510ee8e2a lint: fix type name in diagnostic for enum as controlling expression
Previously, the type was reported as 'int' instead of 'enum'.

Continue to only report the type simple for pointer types, as the exact
pointer type is irrelevant to this message.
2023-05-11 08:01:36 +00:00
gutteridge 1b3c330bb0 t_fss.sh: add missing test case head 2023-05-11 01:56:31 +00:00
gutteridge 7cb4398ae9 t_patterns.sh: fix naming of head() of filename_expansion 2023-05-11 01:50:40 +00:00
gutteridge 3d108ca492 t_cmdsub.sh: fix naming of head() of cmdsub_paren_tests 2023-05-11 00:32:48 +00:00
gutteridge 360a298dc1 t_getopt.sh: fix naming of head() of getopt_optval test case 2023-05-10 23:44:15 +00:00
rillig a48523a624 lint: track integer constraints through conditional expressions 2023-05-09 15:51:33 +00:00
rillig 872d56a969 lint: preserve integer constraints on cast 2023-05-09 15:45:06 +00:00
rillig b889b215f6 tests/lint: demonstrate wrong warning about loss of accuracy 2023-05-09 15:37:29 +00:00
rillig 815f75fc84 tests/lint: demonstrate wrong warning about losing accuracy 2023-05-09 14:46:36 +00:00
andvar e171cef674 fix the grammar in comments reported by Jim Spath in misc/57397. 2023-05-08 19:23:45 +00:00
christos 59a49c3ac2 make tests support both 1.x and 3.x.
Lot of work needed to add all the 3.x tests, but that can wait until all
is switched
2023-05-08 17:46:06 +00:00
skrll 75b842b847 RISC-V support that works on QEMU with a single hart.
Thanks for Simon Burge for plic(4).
2023-05-07 12:41:45 +00:00
gutteridge 09bc0ce2d8 t_sed.sh: add a test case for relative addressing
At one time, this didn't always work correctly, per PR bin/49109. Test
case from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192108
2023-05-06 02:12:11 +00:00
gutteridge f12d9a9c2d t_sed.sh: fix grammar, spelling, and formatting issues (NFC) 2023-05-06 02:07:42 +00:00
gutteridge 9e739a8449 t_trapsignal.sh: fix head() function definitions of test cases 2023-05-05 01:27:18 +00:00
gutteridge 3a6eaa3511 t_fexecve.sh: fix head() function definitions of test cases 2023-05-04 00:02:10 +00:00
gutteridge 55843ced06 t_expr.sh: fix naming of head() of lang test case 2023-05-02 00:11:27 +00:00
rillig 0878a3d7ee lint: reword message for missing declaration in header
Suggested by Christos.
2023-04-25 19:00:57 +00:00
uwe c9764f2dff tests/rump/modautoload: reorder -lrumpvfs_nofifofs
Make the way we spell "-lrumpvfs -lrumpvfs_nofifofs" hack consistent.
The order doesn't matter here because of --whole-archive.
2023-04-24 20:55:53 +00:00
uwe 1694588bdd tests: trim down the list of LIBRUMPBASE libraries
Now that cyclic dependencies are (mostly) broken, we can drop repeated
-l instances that worked around those cycles.  Links on sun2.
2023-04-24 20:35:49 +00:00
mlelstv 7d5fef3b2c Allow 24bit support. 2023-04-23 16:49:38 +00:00
rillig 951d064816 tests/lint: add rationale for not warning about alignment problems 2023-04-23 11:52:43 +00:00
rillig f0ae73e148 lint: be strict when parsing command line for excluded message IDs
Previously, lint accepted -X '1, 2, 3', while the manual page lists the
IDs without spaces.

On 32-bit platforms, lint accepted -X -4294967295, and on 64-bit
platforms, it accepted the corresponding larger numbers.

The code for parsing message IDs and query IDs conceptually does the
same, but the implementations differed for no reason.
2023-04-23 09:04:44 +00:00
rillig 1d3cf26e0d tests/lint: test command line parsing for message and query IDs
The parsing methods differ but shouldn't.
2023-04-23 08:47:27 +00:00
gutteridge 212fac277d t_open_pr_57260.c: KNF a block (spaces to tabs) 2023-04-23 00:46:46 +00:00
rillig 6b952c1471 lint: allow cast from a type to a union containing that type 2023-04-22 20:54:28 +00:00
rillig 368afe279d lint: fix wrong warning about 'extern' temporary identifier 2023-04-22 20:27:09 +00:00
rillig da9016a31f tests/lint: demonstrate wrong warning about extern temporary identifier 2023-04-22 20:21:13 +00:00
rillig a143ec617b tests/lint: test cast to union with stricter alignment 2023-04-22 19:45:04 +00:00
rillig b847195210 lint: don't warn about cast between union and one of its member types
Seen in src/sbin/newfs_udf/udf_core.c for context.anchors.
2023-04-22 17:42:29 +00:00
rillig 0e61302acd tests/lint: add test for conversions to and from a union type
Additionally, fix the line numbers in another test.
2023-04-22 17:30:35 +00:00
rillig 83d27b7d33 lint: do not warn about parenthesized assignment in controlling expr
Same as for GCC and Clang.
2023-04-22 15:14:37 +00:00
gutteridge 04d453bc9d Add new test t_open_pr_57260
New test case that reflects the fix in PR kern/57260. The majority of
work for this case itself was by riastradh@, who'd supplied the basis
for it in the ticket, and provided further guidance.
2023-04-21 21:50:04 +00:00
rillig 5fe653032c tests/lint: remove wrong comment
GCC 10 does warn about returning a temporary object, but only when
optimizations are enabled.
2023-04-15 12:59:02 +00:00
rillig db7f32c2b2 tests/lint: add more tests for returning local objects 2023-04-15 12:47:32 +00:00
rillig 408e7ca205 lint: add query for parenthesized return value 2023-04-15 11:34:45 +00:00
rillig e7d3b23c6b tests/lint: extend test for returning local address 2023-04-15 10:53:59 +00:00
kre 960493d8f0 PR misc/57343 (Jim Spath) - fixed a typo in atf_tc_skip message. 2023-04-11 18:23:42 +00:00
rillig 484ed28712 lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
2023-04-11 00:03:42 +00:00
rillig f8bad61ed5 tests/lint: demonstrate wrong warning with complex numbers 2023-04-10 23:52:49 +00:00
rillig f92802e558 lint: fix duplicate warning when parsing big float constants 2023-04-05 20:17:30 +00:00
rillig cc35e66604 tests/lint: demonstrate duplicate warning when parsing big floats 2023-04-05 20:13:01 +00:00
he ac0941c572 Fix the test for "inf" output, also include newline in printf format... 2023-04-04 19:39:38 +00:00
christos 30cc241785 Add a test for PR/57250 from Havard Eidnes 2023-04-04 19:30:11 +00:00
gutteridge 57f997550b t_magic_symlinks.sh: fix line continuation in realpath head()
This wasn't noticed before because the name of the head() itself was
wrong, and was being ignored.
2023-04-03 21:35:59 +00:00
gutteridge f56d3fb7f1 t_magic_symlinks.sh: fix naming of head() of realpath test case
Addresses part of PR kern/57319 from Jim Spath.
2023-04-03 20:08:38 +00:00
rillig ce2e717784 lint: allow querying for octal integer constants 2023-03-31 13:03:05 +00:00
rillig d0a5c1bc3c lint: warn about 'extern' declarations inside function bodies
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html

The previous attempt (message 351 about 'extern' declarations outside
headers) did not cover the proposal from the tech-userlevel mailing list
but instead warns about a different usage pattern of the 'extern'
keyword.
2023-03-28 20:04:51 +00:00
rillig b2baa50111 lint: warn about extern declarations outside headers
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html
2023-03-28 14:44:34 +00:00
andvar 95f94af301 fix various typos in documentation, comments and sysctl device description.
mainly aion -> ation and inlude -> include.
2023-03-26 19:10:32 +00:00
martin 9da6df7d4c PR 57284: rewrite test to extract all temperaturs from all local sensors
and test them (instead of only one temperature from a tiny list of hard
coded possible devices).
2023-03-23 11:32:49 +00:00
hannken 86c75e95c0 Adjust pc/npc before syscall allowing EJUSTRETURN to return
to the next instruction.  Only ERESTART should return to
the same instruction.  Differences to sparc64 reduced.

Test t_ptrace_wait:syscallemu1 now passes on sparc.

Fixes PR kern/52166 "syscallemu does not work on sparc (32-bit)"

Ok: Martin Husemann
2023-03-20 11:19:29 +00:00
kre 23edd9e279 Adjust the tilde expansion test to deal with (very) recent changes
to what the shell produces for tilde expansions, when the expansion
of the tilde prefix ends with '/' and the character immediately following
is another '/' - previously /bin/sh (and most other shells, but not all)
retained both slashes, and this test expected that behaviour.

No longer, now only one of the two will appear.  Adjust the expected
test results accordingly, and add an extra loop iteration to make sure
this is thoroughly tested (one more tilde expansion value).

Also, add two new test cases that test for the new (explicit - though
it was always stated this way, but not as explicitly) that if HOME is
an empty string (not unset - that remains an unspecified case, as it
was) then the expansion of ~ must generate "", and not nothing.
The current test was unable to distinguish those two, since it
simply looked for characters in the output, so add a new test cases
explicitly to test for this particular case.   This also means (also
previously in the standard, but not as explicitly) that shells are
not permitted to decide "The ~ expansion produces an empty string, that
is weird, let's generate something else instead" which some shells were
doing.
2023-03-06 05:54:54 +00:00
nia 188cf0e1a1 delete attribution per request of contributor 2023-03-01 21:06:41 +00:00
rillig eaf30a03e7 lint: split platform-specific test for loss of accuracy
Lint distinguishes between platforms where size_t is unsigned int and
platforms where size_t is unsigned long.
2023-02-27 23:07:53 +00:00
rillig 17f65f1e9a tests/lint: sync test for nonportable character comparisons
Message 230 was changed on 2023-02-22 but only tested on signed char
platforms.
2023-02-27 21:59:14 +00:00
sjg 68f52b2486 t_make skip varname-dot-make-meta-ignore_*
The meta-ignore tests will likely not work in this environment
so skip them.
2023-02-25 19:37:33 +00:00