aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/patch/inp.c
Commit message (Collapse)AuthorAgeFilesLines
* patch: use getline() instead of fgetln()Martin Tournoij2024-04-191-12/+7
| | | | | | | | | | | | | | | | | | | | | | This replaces fgetln() with getline(). The main reason for this is portability, making things easier for people who want to compile these tools on non-FreeBSD systems. I appreciate that's probably not the top concern for FreeBSD base tools, but fgetln() is impossible to port to most platforms, as concurrent access is essentially impossible to implement fully correct without the line buffer on the FILE struct. Other than this, many generic FreeBSD tools compile fairly cleanly on Linux with a few small changes. Most uses of fgetln() pre-date getline() support (added in 2009 with 69099ba2ec8b), and there's been some previous patches (ee3ca711a898 8c98e6b1a7f3 1a2a4fc8ce1b) for other tools. Obtained from: https://github.com/dcantrell/bsdutils and https://github.com/chimera-linux/chimerautils Signed-off-by: Martin Tournoij <martin@arp242.net> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/893
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* patch: cleanup variable initialization a bit.Pedro F. Giffuni2021-07-221-1/+3
| | | | | | musl libc fgetln is a bit more pickier. Hinted by: chimera-linux (git 31491e1de2e1241885984cd9e4b978965f14eda4)
* patch(1): Don't check for NUL bytes in Plan AKyle Evans2018-01-111-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Plan A mmap()'s the entire input file and operates on it in memory. The map(2) call succeeded, so we shouldn't need to bother checking for the NUL byte as long as we're within our buffer space. This was clearly intentional to match "the behavior of the original code", but it creates a discrepancy between Plan A and Plan B that doesn't seem sensible and it's not inherently wrong to allow a NUL byte. This change was motivated by the gemspec in net/rubygem-grpc failing to patch, despite the patch being generated with diff, because a NUL byte was used as a delimiter in the header briefly in an otherwise text file. An alternative was considered: to fallback to plan B if plan A won't process the entire file due to a NUL byte, but I deemed this to be the better option since plan A isn't failing due to memory limitations and will fail later on if it's really dealing with a file it shouldn't be. PR: 224842 (exp-run) Reported by: swills Reviewed by: emaste, pfg MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D13738 Notes: svn path=/head/; revision=327826
* bc/dc/patch: make some use of reallocarray(3).Pedro F. Giffuni2017-03-051-2/+2
| | | | | | | | | | | reallocarray(3) is a non portable extension from OpenBSD. Given that it is already in FreeBSD, make easier future merges by adopting in some cases where the code has some shared heritage with OpenBSD. Obtained from: OpenBSD Notes: svn path=/head/; revision=314704
* Remove automatic checkout feature.Xin LI2015-08-151-93/+4
| | | | | | | | | Obtained from: DragonFly via OpenBSD Relnotes: yes MFC: never Notes: svn path=/head/; revision=286795
* Use __DECONST instead of doing strdup/free.Xin LI2015-08-111-10/+5
| | | | | | | | Suggested by: ed MFC after: 2 weeks Notes: svn path=/head/; revision=286617
* use posix_spawn(3) instead of fork() and exec() manually as suggestedXin LI2015-08-101-41/+40
| | | | | | | | | | | by jmg@. Reviewed By: pfg MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D3353 Notes: svn path=/head/; revision=286601
* Fix shell injection vulnerability in patch(1) and drop SCCSXin LI2015-07-281-37/+63
| | | | | | | | | | | | support by replacing system() with execve(). Future revisions may remove the functionality completely. Obtained from: Bitrig Security: CVE-2015-1416 Notes: svn path=/head/; revision=285974
* patch(1): small include changes.Pedro F. Giffuni2015-04-201-1/+1
| | | | | | | | | Mostly to match OpenBSD, no functional change. Obtained from: OpenBSD Notes: svn path=/head/; revision=281800
* patch: Bring small updates from OpenBSDPedro F. Giffuni2015-04-071-19/+37
| | | | | | | | | | | | | | Prevent null pointer dereference on empty input files when diff requires a specific version. Fix division by zero for files with long lines (> 1024) in Plan B mode by supporting arbitrarily long lines. Obtained from: OpenBSD (CVS Rev 1.41, 1.42) MFC after: 1 week Notes: svn path=/head/; revision=281216
* - Refresh code with latest OpenBSD revisions.Xin LI2013-01-291-3/+2
| | | | | | | | | | | | - Remove $DragonFly$ tags as they are using git nowadays and VCS tags will not help merging. - Other changes to Copyright headers to make them consistent with other source code, we intend to fork from this point. Reviewed by: pfg Notes: svn path=/head/; revision=246091
* - Add a BSD-licensed patch, ported by Pedro F. Giffuni (pfg) fromGabor Kovesdan2013-01-291-0/+485
| | | | | | | | | | | DragonflyBSD and install it as bsdpatch. WITH_BSD_PATCH makes it default and installs GNU patch as gnupatch. Submitted by: pfg Obtained from: The DragonflyBSD Project Notes: svn path=/head/; revision=246074
* kill the undeadPeter Wemm1997-07-131-313/+0
| | | | Notes: svn path=/head/; revision=27369
* Finish importing Lite2's src/usr.bin, except for ex, diff, grep, mail,Bruce Evans1997-07-061-0/+313
pascal and vmstat.sparc. All changed files on the vendor branch should already have been imported. Notes: svn path=/vendor/CSRG/dist/; revision=27241