| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The -r flag is not required to compare two directories; it is only
required to compare them recursively, i.e. descend into their common
subdirectories. Adjust tests that use -r needlessly, and adjust the
dirloop test to verify that these two cases remain distinct.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55262
(cherry picked from commit b2532432971fbd9339a9a49eca1b532978bb6d48)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
POSIX uses the terms “positive decimal integer” for -C and “non-negative
decimal integer” for -U, which translates into lower bounds of 1 for -C
and 0 for -U.
POSIX does not specify a minimum upper bound for either mode, but as of
5fc739eb5949 both our backends support context sizes up to and including
INT_MAX, so use that.
Having had the opportunity to consult the Unix System Test Suite, the
diff test cases found therein happen to precisely match these bounds.
While here, switch to using strtonum() to parse numerical arguments, and
try to be more consistent in how we report usage errors.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55261
(cherry picked from commit 790f1d1cc5fa892ba59fd7f239b22064c8ab14c7)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we're done processing a directory, remove its entry from the tree
of visited inodes, ensuring that we only report a loop when we encounter
a descendant-to-ancestor link, not when we encounter a cousin-to-cousin
or sibling-to-sibling link.
MFC after: 1 week
Reported by: Bakul Shah <bakul@iitbombay.org>
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55248
(cherry picked from commit 71569594d860a59d8362770a56d806e1d31fb946)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In the legacy Stone algorithm, we do a first pass over the files to
check if they're identical before we start diffing them. That code
would correctly set the exit status if an I/O error was encountered,
but would not emit an error message. Do so.
PR: 292198
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj
Differential Revision: https://reviews.freebsd.org/D55125
(cherry picked from commit f8c12e6e3874cdd353fb16785da6f4e7eb134cd9)
|
| |
|
|
|
|
|
|
|
| |
Sponsored by: Klara, Inc.
Fixes: 5fc739eb5949 ("diff: Fix integer overflows in Stone algorithm")
Fixes: 270492602b9b ("diff: Add test case for pagination resource leak")
Fixes: 590126789c84 ("diff: Don't compare a file or directory to itself")
(cherry picked from commit 157d6664aeb815db3b758bd3038fd1512a0f4e2c)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
While here, stop abusing struct dirent for something we don't even need
to store.
PR: 254455
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj, kevans
Differential Revision: https://reviews.freebsd.org/D55113
(cherry picked from commit 590126789c841d80655869bc075c8980c173dd1c)
diff: Fix build
rc must be defined first.
Fixes: 590126789c84
MFC after: 1 week
X-MFC with: 590126789c84
(cherry picked from commit ee44ab936e84bacaa49847d36aabdf280f9fecce)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Drop an unnecessary variable and rename pidfd to procd.
* Rewinding stdout serves no purpose, so stop doing it.
* Don't bother freeing memory or setting the global status right
before erroring out.
* Error out if dup(2) or dup2(2) fail.
* In the unlikely case that our pipe is equal to stdout, we need to
record that information so we don't close it when cleaning up.
* Don't bother closing a descriptor before dup2(2)ing to it.
* Don't forget to close the the process descriptor after reaping the
child process.
PR: 266592
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, markj
Differential Revision: https://reviews.freebsd.org/D55112
(cherry picked from commit c3904a7de78ca1ca15fcdf4c09f9d4be7f6fe6f5)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The pagination code leaks either processes or descriptors or both,
depending on the exact version of the code you have. Add a test case
which exercises this leak to facilitate fixing it.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj, kevans
Differential Revision: https://reviews.freebsd.org/D55111
(cherry picked from commit 270492602b9bd8b8fce4f021f055804978bf3f23)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Fix integer overflows that may occur when the context window is very
large and add tests to exercise those conditions.
PR: 267032
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj, kevans
Differential Revision: https://reviews.freebsd.org/D55110
(cherry picked from commit 5fc739eb5949620da911db2f87ca8faedc549d3a)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This seems to fit the pattern better (e.g. fdopendir()).
I've added weak references to ease the transition, but since it's only
been a few days, we can remove them (and the ObsoleteFiles entries for
the manual pages) before we branch stable/15.
Fixes: deeebfdecab5
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D50980
(cherry picked from commit 0a5b763d98b921f921243525ff25a70bbe00cfaa)
libc: Finish removing fscandir{,_b}().
These only existed for a few days before being renamed, so there's no
reason to continue to carry compatibility shims for them.
Fixes: deeebfdecab5
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D50981
(cherry picked from commit ccf937320a1a7383a2c33698007b7244f66dc022)
|
| |
|
|
|
|
| |
Sponsored by: Klara, Inc.
(cherry picked from commit 28d9586cde8dc783f7b698b10c2b564fde14ae74)
|
| |
|
|
|
|
|
|
| |
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D50936
(cherry picked from commit 42092e1b6625b8226de5f34d22b9a96c713626cb)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The legacy Stone algorithm uses `int` to represent line numbers, array
indices, and array lengths. If given inputs approaching `INT_MAX` lines,
it would overflow and attempt to allocate ridiculously large amounts of
memory. To avoid this without penalizing non-pathological inputs,
switch a few variables to `size_t` and add checks while and immediately
after reading both inputs.
MFC after: 3 days
PR: 280371
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D46169
(cherry picked from commit 9317242469f1ca682626d9806f8caf65d143c09a)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The `--ignore-all-space` option was incorrectly documented as
`--ignore-all-blanks` in some (but not all) places.
MFC after: 3 days
PR: 280434
Sponsored by: Klara, Inc.
Reviewed by: 0mp, markj
Differential Revision: https://reviews.freebsd.org/D46160
(cherry picked from commit ab830de9f58c1b257e42b4fbdd46b3ca6a837ee6)
|
| |
|
|
|
|
|
|
|
|
|
| |
Also, --no-dereference should not imply --recurse.
MFC after: 3 days
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D45779
(cherry picked from commit 4ce4a0fe14c455c6ec77452bc99cd93ea45737b1)
|
| |
|
|
|
|
|
|
|
| |
PR: 278988
Reviewed by: bapt
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45220
(cherry picked from commit fb623aab3927a6825ff7731198ec2e33426f7607)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Overhaul column width and padding calculation.
* Rewrite print_space() so it is now a) correct and b) understandable.
* Rewrite tab expansion in fetch() for the same reason.
This brings us in line with GNU diff for all cases I could think of.
Sponsored by: Klara, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44014
(cherry picked from commit 53de23f4d140becc3166e87665b0064f215a220e)
diff: Bump manual page date.
Sponsored by: Klara, Inc.
(cherry picked from commit 312b1076c6b0aff9bbcaff058b93385eaf607685)
|
| |
|
|
| |
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.
|