trussinfo->curthread must be initialized before calling enter_syscall(),
it is used by t->proc->abi->fetch_args().
Without that truss is segfaulting and the attached program also crash.
Submitted by: Nikita Kozlov (nikita@gandi.net)
Reviewed by: jhb
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D7399
or "+" (these are invalid, because there is no preceding operand).
When bsdgrep attempts to emulate GNU grep in discarding and ignoring the
invalid ? or + operators, some later logic in tre_compile_fast() goes
beyond the end of the buffer, leading to a crash.
Fix this by bailing out, and reporting a bad pattern instead.
Reported by: Steve Kargl
MFC after: 1 week
While big, the change was meant to have no effect on behavior and instead
so far we have found two regressions: one in the etcupdate tests and
another one in the games/openttd port[1].
Revert to a known working state. We will likely have to split the patch in
functional parts before bringing back the changes.
PR: 195929
Reported by: danfe, madpilot [1]
For now maintain the local style in this file.
Reviewed by: jilles
Reference:
9099a9f17b
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Submitted by: Piotr Stefaniak
clang-analyzer complained that eqin() sets file-scoped pointer param_start
to point into char buffer defined in scan_profile(), and once
scan_profile() exits, param_start is a "dangling reference". param_start
was never used afterwards, but it's cleaner to move it to set_option()
which is the only branch where param_start is needed.
Reference:
ab0e44e5da
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Submitted by: Piotr Stefaniak
It's pr_comment.c that should decide whether to put a "star comment
continuation" or not. This duplicates code a bit, but it simplifies
pr_comment() at the same time since pr_comment() no longer has to "signal"
whether a star continuation is needed or not.
This change requires indent(1) to not wrap comment lines that lack a blank
character, but I think it's for the better if you look at cases when that
happens (mostly long URIs and file system paths, which arguably shouldn't
be wrapped).
It also fixes two bugs:
1. Cases where asterisk is a part of the comment's content (like in "*we*
are the champions") and happens to appear at the beginning of the line,
misleading dump_line() into thinking that this is part of the star comment
continuation, leading to misalignment.
2. Cases where blank starred lines had three too many characters on the
line when wrapped.
Reference:
3b41ee78aa
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Submitted by: Piotr Stefaniak
After a blank line was printed (to separate paragraphs in comments), the
next line was sometimes wrapped to the column at which the previous
non-empty line ended. The fix is to reset the last blank pointer (last_bl)
on newline.
References:
345663c07a
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Submitted by: Piotr Stefaniak
Modify count_spaces() to take a third parameter "end" that will make the
function return when the end is reached. This lets the caller pass a
pointer to non nul-terminated sequence of characters. Rename
count_spaces() to count_spaces_until() and reinstate count_spaces(), this
time based on count_spaces_until().
Use count_spaces_until() to recalculate current column when going through
a comment just before the fragment which decides if current line of the
comment should be wrapped. This move simplifies this code by eliminating
the need for keeping the column counter up to date every time e_com is
advanced and also reduces spread of code that has to know how many columns
a tab will produce.
Deduplicate code that decided if a comment needs a blank line at the top.
References:
d9fa3b481527185b4b33
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Submitted by: Piotr Stefaniak
The original indent(1) described unix-style comments as similar to box
comments, except the first non-blank character on each line is lined up
with the '*' of the "/*" which appears on a line by itself.
The code has been turned off for ages and -sc/-nsc make it even
less relevant.
Reference:
89c5fe2c56
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Submitted by: Piotr Stefaniak
'\n' was specifically added to -e arguments prior to r303047. Restore
historical behavior which in turn fixes usr.sbin/etcupdate/preworld_test:main .
The fix is being committed to address the issue in the short term and may be
iterated upon as noted in bug 211399
Discussed with: mi, pfg
Differential Revision: https://reviews.freebsd.org/D7368
PR: 195929, 211399 [*]
MFC after: 18 days
X-MFC with: r303047
Reported by: Jenkins
Sponsored by: EMC / Isilon Storage Division
Also increase the stack size still keeping a conservative value of 256.
This is based on a similar changes done for PostgreSQL which instead
uses a stack size of 1000.
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Submitted by: Piotr Stefaniak (with changes)
This fixes a very visible issue that may be hidden by some indent.pro
settings as in the example from FreeBSD's /usr/share.
From Piotr's log:
____
To prevent losing tabs from indentation in declarations, FreeBSD indent's
r125624 added code for the most common case when it's an identifier that
is indented, but didn't do anything with the original code that did the
same for any other cases. The other cases are: lparens (function pointer
declaration), asterisks (pointer declaration), stray semicolons, and
commas leading identifiers instead of trailing them.
Use the code added in r125624 (and improved in later commits) to write a
new function indent_declaration() and use it in all places that meant to
indent declarations. In order to indent only once per line, reuse existing
ps.dumped_decl_indent variable that was only used when formatting for
troff (-troff) until now.
____
Reference:
ddd263db2a
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Submitted by: Piotr Stefaniak
strchr(3) returns a pointer not a boolean.
Attempt to make the style somewhat more ocnsistent with what indent
had before recent changes.
Pointed out by: bde
Remove the excessive braces from r303485 and align the comments to the
right as done in the rest of the code. This is not nice but there is no
clear way to make it nice (and KNF).
Pointed out by: bde
Actually this just brings back r303487 with the correct commit log.
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Obtained from: Piotr Stefaniak
This piece of code removed tabs and space characters from after colons
that follow labels by decrementing the e_lab (end of label) "pointer"
which is later used to calculate the width of the string that fprintf()
puts into "output". But pad_output() gets the length from the actual
string, so it miscalculated what the current column is.
Fixed by putting a string terminator at the e_lab "pointer".
Differential Revision: https://reviews.freebsd.org/D6966
(Partial)
Obtained from: Piotr Stefaniak
indent(1) simply wasn't taught that "else" may be followed by a comment
without any opening brace anywhere on the line, so it was very confused
in such cases.
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Obtained from: Piotr Stefaniak
last_bl is a char pointer that tracks the last blank character in a
comment, which is used for wrapping long comment lines. Since the
underlying array may be reallocated, make sure last_bl is up to date when
that happens.
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Obtained from: Piotr Stefaniak
dump_line() requires s_code to be a string, because it will call count_spaces().
Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Obtained from: Piotr Stefaniak
Pull a copy of the filename string before calling basename(). Change the
loop to not return on its own, so we can put a free() statement at the
bottom.
POSIX allows these functions to modify their input buffer, so that they
have storage for the return value. Pull copies of the filename before
calling these utility functions.
which is more efficient.
Note that for now we do not create a separate library for libdivsufsort
because it's not used anywhere else.
Obtained from: Chromium
MFC after: 2 months