aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/diff/pr.c
Commit message (Collapse)AuthorAgeFilesLines
* diff: Correct fd 0 case on pipeJilles Tjoelker2026-06-031-2/+3
| | | | | | | | | | | | | | After git commit c8d40bf8ecc60cc15e3904410db62065ea681fdc, if fd 0 was not open, it is left with CLOEXEC set and therefore fails. This is an unlikely situation, but fixing it reduces the size of the code (by using posix_spawn_file_actions_adddup2's special case if the two file descriptor numbers are the same). At the same time, check the error code from posix_spawn_file_actions_adddup2. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D56910
* diff: use O_CLOEXEC on pipesBaptiste Daroussin2026-03-281-5/+2
| | | | | | This only simplifies the code, no functional changes expected MFC After: 1 week
* diff: prefer posix_spawn over pdfork/execlBaptiste Daroussin2026-03-261-23/+39
| | | | | | MFC After: 1 week Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D56076
* diff: Fix pagination leakDag-Erling Smørgrav2026-02-051-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | * 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
* diff: use pdwait(2) instead of homemade oneBaptiste Daroussin2026-02-021-13/+6
| | | | | | MFC After: 3 days Reviewed by: des Differential Revision: https://reviews.freebsd.org/D55053
* diff: Integrate libdiff from OpenBSD GoT.Dag-Erling Smørgrav2024-03-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | This adds support for two new diff algorithms, Myers diff and Patience diff. These algorithms perform a different form of search compared to the classic Stone algorithm and support escapes when worst case scenarios are encountered. Add the -A flag to allow selection of the algorithm, but default to using the new Myers diff implementation. The libdiff implementation currently only supports a subset of input and output options supported by diff. When these options are used, but the algorithm is not selected, automatically fallback to the classic Stone algorithm until support for these modes can be added. Based on work originally done by thj@ with contributions from kevans@. Sponsored by: Klara, Inc. Reviewed by: thj Differential Revision: https://reviews.freebsd.org/D44302
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Fix indentation in usr.bin/diff/pr.cDimitry Andric2022-03-041-13/+12
| | | | | | | | | | 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
* Fix memory leakBaptiste Daroussin2018-06-121-0/+1
| | | | | | | CID: 1393352 Notes: svn path=/head/; revision=335002
* Correctly test return value of pipe(2)Baptiste Daroussin2018-06-121-1/+2
| | | | | | | CID: 1393351 Notes: svn path=/head/; revision=335001
* Isolate the pr(1) related code in its own source filesBaptiste Daroussin2018-06-091-0/+124
This keeps diffreg.c closer to what it is supposed to do: diffing regular files. It also allows my code to get a proper license Notes: svn path=/head/; revision=334894