| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
| |
Remove /^\.\\"\s*\$FreeBSD\$$\n/
|
| |
|
|
| |
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
|
| |
|
|
| |
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
| |
|
|
| |
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
|
| |
|
|
| |
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
|
| |
|
|
| |
This fixes a set but unused warning.
|
| |
|
|
|
|
|
|
| |
This is a bit more readable, and this loop is probably unlikely to gain
any `continue` or `break`s.
Suggested by: pstef
Differential Revision: https://reviews.freebsd.org/D37676
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous logic conflated some things... in this block:
- j: input characters rendered so far
- nc: number of characters in the line
- col: columns rendered so far
- hw: column width ((h)ard (w)idth?)
Comparing j to hw or col to nc are naturally wrong, as col and hw are
limits on their respective counters and nc is already brought down to hw
if the input line should be truncated to start with.
Right now, we end up easily truncating lines with tabs in them as we
count each tab for $tabwidth lines in the input line, but we really
should only be accounting for them in the column count. The problem is
most easily demonstrated by the two input files added for the tests,
the two tabbed lines lose at least a word or two even though there's
plenty of space left in the row for each side.
Reviewed by: bapt, pstef
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37676
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Previously print_header() used sprintf() of a buffer to itself as a
kind of string builder but without checking for overflows. This
raised -Wformat-truncation and -Wrestrict warnings in GCC. Instead,
just conditionally print the new timestamp fields after the initial
strftime()-formatted string. While here, use sizeof(buf) with
strftime() rather than a magic number.
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D36814
|
| |
|
|
|
|
|
|
|
|
|
| |
The implicit fall-through in the !D_FORCEASCII case caused null
characters to be treated as carriage returns honoring the D_STRIPCR,
D_FOLDBLANKS, and D_IGNOREBLANKS flags.
Reported by: GCC -Wimplicit-fallthrough
Reviewed by: bapt
Fixes: 3cbf98e2bee9 diff: read whole files to determine if they are ASCII text
Differential Revision: https://reviews.freebsd.org/D36813
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When -B or -I are used, change() evaluates the lines in a hunk to
determine if it is a hunk that should be ignored. It does this by
reading each candidate line into a mallocated buffer via preadline()
and then calling ignoreline(). Previously the buffer was freed as a
side effect of ignoreline_pattern() called from ignoreline().
However, if only -B was specified, then ignoreline_pattern() was not
called and the lines were leaked. If both options were specified,
then ignoreline_pattern() was called before checking for a blank line
so that the second check was a use after free.
To fix, pull the free() out of ignoreline_pattern() and instead do it
up in change() so that is paired with preadline().
While here, simplify ignoreline() by checking for the -B and -I cases
individually without a separate clause for when both are set. Also,
do the cheaper check (-B) first, and remove a false comment (this
function is only called if at least one of -I or -B are specified).
Reviewed by: emaste
Reported by: GCC 12 -Wuse-after-free
Differential Revision: https://reviews.freebsd.org/D36822
|
| |
|
|
|
|
|
|
|
|
| |
This test cannot run without an unprivileged_user being specified
anyways, so just run as the unprivileged user. Revoking read permisions
works just as well if you're guaranteed non-root.
Reviewed by: pstef
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D34950
|
| |
|
|
|
|
|
| |
Previous commit (8cf449db88b2c7a505bc241a78f9736b43f2ede5)
unintentionally dropped the 'void' argument to usage, reinstate it.
Sponsored by: Klara Inc.
|
| |
|
|
|
|
|
|
|
|
| |
Add support for --help and --version to be compatible with gnu diff.
gnu diff --help writes to stdout, do the same to be compatible
Reviewed by: bapt, pstef, debrup, Pau Amma
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34508
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
In b5541f456d641d23e0c46874daff0b62552bf3cb when flags were converted to
be boolean, the setting of cflag as an integer was removed, but no
boolean set was added.
This effects the output format of dates, but the context type was set to
D_CONTEXT so other functionality worked.
Reviewed by: bapt
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34481
|
| |
|
|
|
|
|
|
|
|
| |
In commit 6fa5bf0832ef the pr(1) related code in diff was moved around,
but some part of the indentation was messed up, and one line was
duplicated. Remove the duplicated line, and fix up the indentation.
Reviewed by: bapt
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D34398
|
| |
|
|
|
|
|
|
| |
This reverts commit 85eeb6ea62d45c5df893a16b87969bd7313a3dbb.
The issue has been fixed by 4be7d087c2b566f4910683836be279d55c1a81c6.
PR: 262086
|
| |
|
|
|
|
|
|
|
|
|
| |
Use the start of change when searching for a function rather than the
start of the context. In short functions if this could result in search
for the function name starting from before the function definition.
PR: 262086
Reviewed by: bapt, mckusick, mhorne
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34328
|
| |
|
|
|
| |
PR: 262086
Sponsored by: The FreeBSD Foundation
|
| |
|
|
|
|
|
|
|
|
|
|
| |
With --ignore-file-name-case we need to compare files regardless of
case. We need to propigate both names down to diffit so we can look up
the correct file when the names differ based on case, otherwise we try
to look up the file using the case from the a tree which might not be
discoverable if its case is different in the b tree.
Reviewed by: bapt
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34201
|
| |
|
|
|
|
|
|
| |
Must have left this when I was testing the test invocation for
8f79bd9b85716c495c2741ac25db37e8d71f22f7
Pointy hat: thj
Sponsored by: Klara Inc.
|
| |
|
|
|
|
|
|
|
| |
When diffing files and directories, don't follow symbolic links, instead
compare where the links point to.
Reviewed by: bapt
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34203
|
| |
|
|
|
|
|
|
|
|
| |
When searching back for function definitions, consider lines starting
with '+' and '-', this allows us to pick up Objective-C methods as well
as C style function definitions.
Reviewed by: bapt
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34202
|
| |
|
|
|
| |
Obtained from: OpenBSD
MFC after: 1 week
|
| |
|
|
|
| |
Reported by: Jenkins
Fixes: bcf2e78dc48378456798191f1c15cb76d6221a65
|
| |
|
|
|
|
|
|
| |
With unified and context diffs, show the last line that matches the
provided pattern before the context.
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D31714
|
| |
|
|
|
|
|
|
|
|
| |
Adds a --color flag to diff(1) that supports the same options as GNU's
diff(1). The colors are customizable with the env var DIFFCOLORS in
a format similar to grep(1)'s GREPCOLORS. An example would be 04;36:41
for additions to be underlined light blue, and deletions have a red
background.
Differential Revision: https://reviews.freebsd.org/D30545
|
| |
|
|
| |
An upcoming change will add more code in the loop.
|
| |
|
|
| |
This was the only instance of undefined behavior I could find so far.
|
| |
|
|
| |
Remove cruft and use a system-provided and maintained function instead.
|
| |
|
|
|
|
| |
Most of them become static. There will be more such functions added in
upcoming commits, so they would be inconsistent with existing code.
Improve the existing code instead of reinforcing the unwanted pattern.
|
| |
|
|
|
|
| |
There will be more boolean flags added in upcoming commits and they
would have to be stored in ints in order to be consistent with existing
code. Change the existing code to use the bool type.
|
| |
|
|
| |
Reflow comments, strip trailing space, improve wrapping of lines.
|
| |
|
|
|
|
|
| |
Before this change, only the first BUFSIZE bytes were checked.
Reviewed by: bapt (previous version)
Differential Revision: https://reviews.freebsd.org/D31639
|
| |
|
|
|
| |
--strip-trailing-cr worked as intended for comparison between files,
but the characters were still present in final output.
|
| |
|
|
|
|
|
|
|
|
| |
UBSan complains about the `sum = sum * 127 + chrtran(t);` line below since
that can overflow an `int`. Use `unsigned int` instead to ensure that
overflow is well-defined.
Reviewed By: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31075
|
| |
|
|
|
|
|
|
| |
This test switches users and either hangs or fails when run as an
unprivileged user.
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
|
| |
|
|
|
|
| |
Approved by: bapt
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D28466
|
| |
|
|
|
|
|
|
| |
This changes breaks when one of the files is stdin
This reverts commit fa977a3b2bb2d0e6c2957b14474c31b58dd3a8e1.
Reported by: olivier
|
| |
|
|
|
| |
The diff_output was not bringing any values but was obfuscating
the code.
|
| |
|
|
|
| |
Instead of 3 different complex case they have all been folded into a
simple on based on switch
|
| | |
|
| | |
|
| |
|
|
| |
No functionnal changes
|
| |
|
|
|
| |
fdopen with the "r" already position the stream at the beginning
of the file.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When diff hits certain access errors, function diffreg() shows the error
message, and then returns to the calling function, which calls
print_status() with the return value.
However, in these cases, the return value isn't changed from the initial
default value of D_SAME.
Normally, print_status() with a value of D_SAME does nothing, so this
works out ok, however, if the "-s" flag is set, a message is displayed
showing identicality:
case D_SAME:
if (sflag)
printf("Files %s%s and %s%s are identical\n", path1, entry, path2, entry);
break;
This then produces such results as:
% diff -s /COPYRIGHT /var/run/rpcbind.sock
diff: /var/run/rpcbind.sock: Operation not supported
Files /COPYRIGHT and /var/run/rpcbind.sock are identical
% diff -s /COPYRIGHT /etc/master.passwd
diff: /etc/master.passwd: Permission denied
Files /COPYRIGHT and /etc/master.passwd are identical
Create a D_ERROR status which is returned in such cases, and
print_status() then deals with that status seperately from D_SAME
PR: 252614
MFC after: 1 week
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Previously -q (just print a line when files differ) ignored flags like
-w (ignore whitespace). Avoid the D_BRIEF short-circuit when flags are
in effect.
PR: 252515
Reported by: Scott Aitken
Reviewed by: kevans
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28064
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instead, leave the fomat as unspecified (if it hasn't been) and use the
-p flag as a hint to 'context' if no other formatting option is specified.
This fixes `diff -purw`, used frequently by emaste, and matches the behavior
of its GNU counterpart.
PR: 250015
Reviewed by: emaste
MFC after: 1 week
Notes:
svn path=/head/; revision=367076
|