summaryrefslogtreecommitdiff
path: root/usr.bin/diff
Commit message (Collapse)AuthorAgeFilesLines
* diff: don't force the format to 'context' with -p immediatelyKyle Evans2020-10-271-11/+2
| | | | | | | | | | | | | | | 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
* diff: always properly kill pr(1)Baptiste Daroussin2020-09-011-3/+3
| | | | | | | | | | | | | When diff is invoked with -l it will spawn the pr(1) program. In some circumpstances the pr(1) was not properly killed when diff program exits. Submitted by: Bret Ketchum MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D26232 Notes: svn path=/head/; revision=365041
* diff: fix side_by_side after r363679Kyle Evans2020-07-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | It's currently unclear to me how this could have worked previously; \n here is not a literal newline but actual '\' 'n', and was getting passed to the underlying regex engine as such. regex(3) does not translate this to a newline, and this became an error because we don't really allow escaping of arbitrary ordinary characters anymore. Run the pattern strings through printf to make sure we're dealing with real newlines before passing them through to atf_check, which ultimately feeds them directly to regcomp(3). This fix is different than that will be needed for sed, in that this is the proper way to inject newlines into search strings as long as regex(3) won't combine \ + n as folks might expect. Reported by: Jenkins via lwhsu MFC after: 1 week Notes: svn path=/head/; revision=363692
* diff(1): Add EXAMPLES sectionFernando ApesteguĂ­a2020-06-191-3/+45
| | | | | | | | | | Add examples for -r, -u, -N, -x, -q and -I Approved by: 0mp@ Differential Revision: https://reviews.freebsd.org/D25345 Notes: svn path=/head/; revision=362367
* Document long version of -b optionBaptiste Daroussin2020-06-011-2/+2
| | | | | | | | | | PR: 234195 Submitted by: Fehmi Noyan Isi <fnoyanisi@yahoo.com> Reported by: Andras Farkas <deepbluemistake@gmail.com> MFC after: 3 days Notes: svn path=/head/; revision=361690
* diff: restore compatibility with GNU diff regarding -N optionBaptiste Daroussin2020-06-012-4/+36
| | | | | | | | | | | | | When -N is used the missing files are treated as empty. PR: 233402 Submitted by: Fehmi Noyan Isi <fnoyanisi@yahoo.com> Reported by: Roman Neuhauser <roman@sigpipe.cz> MFC after: 3 days Differential Revision: D25081 Notes: svn path=/head/; revision=361689
* Restore compatibility with GNU diff regarding --labelBaptiste Daroussin2020-06-012-0/+16
| | | | | | | | | | | | | | | | Various options to "diff(1)" show filenames, and traditionally make use of the "--label" parameter, if set. Restore this behaviour in BSD diff. While here add a regression test PR: 244533 Submitted by: Jamie Landeg-Jones <jamie@catflap.org> MFC after: 3 days Notes: svn path=/head/; revision=361688
* diff(1): don't reject specifying the same format multiple timesKyle Evans2020-04-282-11/+29
| | | | | | | | | | | | | | | | | | | | | This may happen, for instance, if one happens to have an alias of diff to diff -up and attempts to specify the amount of context on top of that. Aliases like this may cause other problems, but if they're really not ever generating non-unified diffs then we should at least not break that use-case. In addition, we'll now pick up a format mismatch if -p is specified with !contextual && !unified && !unset. Fix up a small trailing whitespace nit in the tests while we're here, and add tests to make sure that we can double up all the formatting options. Reported by: jbeich MFC after: 3 days Notes: svn path=/head/; revision=360437
* diff(1): reject conflicting formatting optionsKyle Evans2020-04-203-4/+52
| | | | | | | | | | | | | | | | | | | This matches GNU diff(1) behavior and, more importantly, eliminates any source of confusion if multiple formatting options are specified. Note that the committed diff differs slightly from the submitted: I've modified it so that we initialize diff_format to something that isn't an accepted format option so that we can also reject --normal -c and -c --normal, which would've otherwise been accepted because the default was --normal. After option parsing we default it to D_NORMAL if it's still unset. PR: 243975 Submitted by: fehmi noyan isi MFC after: 1 week Notes: svn path=/head/; revision=360125
* diff: fix segfault with --tabsize and no/malformed argumentKyle Evans2020-02-133-8/+20
| | | | | | | | | | | | | | | | | | | | | | | | --tabsize was previously listed as optional_argument, but didn't account for the optionality of it in the argument handling. This is irrelevant -- the manpage doesn't indicate that the argument is optional, and indeed there's no clear interpretation of omitting the argument because there's no other side effect of --tabsize. The "malformed" argument part of the header on this message is simply referring to usage like this: % diff --tabsize 4 A B With an optional_argument, the argument must be attached to the parameter directly (e.g. --tabsize=4), so the argument is effectively NULL with the above invocation as if no argument had been passed. PR: 243974 Submitted by: fehmi noyan isi <fnoyanisi yahoo com> (diff.c portion) MFC after: 3 days Notes: svn path=/head/; revision=357875
* diff.1: Fix style & document -y as extension to POSIXMateusz Piotrowski2020-02-121-13/+13
| | | | | | | | | | | - Long options must be stylized with the Fl macro as well. Reviewed by: bapt Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D23642 Notes: svn path=/head/; revision=357841
* Fix most of the style warningsBaptiste Daroussin2020-02-071-12/+11
| | | | Notes: svn path=/head/; revision=357652
* Update diff(1) TODO removing what has been implementedBaptiste Daroussin2020-02-071-8/+0
| | | | Notes: svn path=/head/; revision=357649
* diff: implement -y (--side-by-side) along with -W and --suppress-common-linesBaptiste Daroussin2020-02-075-44/+229
| | | | | | | | | PR: 219933 Submitted by: fehmi noyan isi <fnoyanisi@yahoo.com> MFC after: 3 weeks Notes: svn path=/head/; revision=357648
* Do not skip line-by-line comparison if -q and -I are specified.Mark Johnston2020-01-141-1/+1
| | | | | | | | | | | This fixes a regression from r356695. Submitted by: kevans Reported by: Jenkins via lwhsu MFC after: 6 days Notes: svn path=/head/; revision=356731
* When system calls indicate an error they return -1, not some arbitraryBaptiste Daroussin2020-01-142-8/+8
| | | | | | | | | | value < 0. errno is only updated in this case. Obtained from: OpenBSD MFC after: 3 days Notes: svn path=/head/; revision=356725
* asprintf returns -1, not an arbitrary value < 0. Also upon error theBaptiste Daroussin2020-01-141-2/+2
| | | | | | | | | | | (very sloppy specification) leaves an undefined value in *ret, so it is wrong to inspect it, the error condition is enough. Obtained from: OpenBSD MFC after: 3 days Notes: svn path=/head/; revision=356724
* mkstemp returns -1Baptiste Daroussin2020-01-141-2/+2
| | | | | | | | Obtained from: OpenBSD MFC after: 3 days Notes: svn path=/head/; revision=356723
* Optimize diff -q.Mark Johnston2020-01-131-0/+5
| | | | | | | | | | | | | | Once we know whether the files differ, we don't need to do any further work. PR: 242828 Submitted by: fehmi noyan isi <fnoyanisi@yahoo.com> (original version) Reviewed by: bapt, kevans MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D23152 Notes: svn path=/head/; revision=356695
* capsicum: use a new capsicum helpers in toolsMariusz Zaborski2018-11-041-4/+2
| | | | | | | Use caph_{rights,ioctls,fcntls}_limit to simplify the code. Notes: svn path=/head/; revision=340138
* diff(1): Refactor -B a little bitKyle Evans2018-08-191-31/+23
| | | | | | | | | Instead of doing a second pass to skip empty lines if we've specified -I, go ahead and check both at once. Ignore critera has been split out into its own function to try and keep the logic cleaner. Notes: svn path=/head/; revision=338040
* diff(1): Implement -B/--ignore-blank-linesKyle Evans2018-08-1910-12/+72
| | | | | | | | | | | | | | | | As noted by cem in r338035, coccinelle invokes diff(1) with the -B flag. This was not previously implemented here, so one was forced to create a link for GNU diff to /usr/local/bin/diff Implement the -B flag and add some primitive tests for it. It is implemented in the same fashion that -I is implemented; each chunk's lines are scanned, and if a non-blank line is encountered then the chunk will be output. Otherwise, it's skipped. MFC after: 2 weeks Notes: svn path=/head/; revision=338039
* Improve --strip-trailing-cr handling:Xin LI2018-07-272-5/+19
| | | | | | | | | | | | | | | - Advance ctold for f1 and ctnew for f2 - ungetc() if the character is unexpected - Don't break early when we hit the combination on one side PR: 230049 Reported by: maskray <emacsray gmail com> Reviewed by: bapt, maskray MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D16451 Notes: svn path=/head/; revision=336754
* Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.Mariusz Zaborski2018-06-191-1/+1
| | | | | | | No functional change intended. Notes: svn path=/head/; revision=335395
* 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
* diff: Import fixes from OpenBSDBaptiste Daroussin2018-06-091-6/+6
| | | | | | | | | original commit log by miller@OpenBSD r1.46: Fix exit value when diffing directories with missing files and the -N or -P options are not used. From Ibrahim Khalifa Notes: svn path=/head/; revision=334896
* Isolate the pr(1) related code in its own source filesBaptiste Daroussin2018-06-094-81/+169
| | | | | | | | | | 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
* Replace homemade equivalent of tolower(3) by towlower(3)Baptiste Daroussin2017-12-131-60/+15
| | | | | | | This will help in the futur making diff -i works with multibyte Notes: svn path=/head/; revision=326822
* spdx: initial adoption of licensing ID tags.Pedro F. Giffuni2017-11-181-1/+3
| | | | | | | | | | | | | | | | | | | | The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Initially, only tag files that use BSD 4-Clause "Original" license. RelNotes: yes Differential Revision: https://reviews.freebsd.org/D13133 Notes: svn path=/head/; revision=325966
* DIRDEPS_BUILD: Connect new directories.Bryan Drewery2017-10-311-0/+11
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325187
* Add HAS_TESTS to all Makefiles that are currently using theEnji Cooper2017-08-021-0/+1
| | | | | | | | | `SUBDIR.${MK_TESTS}+= tests` idiom. This is a follow up to r321912. Notes: svn path=/projects/make-check-sandbox/; revision=321914
* Convert traditional ${MK_TESTS} conditional idiom for including testEnji Cooper2017-08-021-3/+1
| | | | | | | | | | | | | | directories to SUBDIR.${MK_TESTS} idiom This is being done to pave the way for future work (and homogenity) in ^/projects/make-check-sandbox . No functional change intended. MFC after: 1 weeks Notes: svn path=/head/; revision=321912
* Use more flexible expression for replacing t_diff inEnji Cooper2017-07-191-1/+1
| | | | | | | | | | | contrib/netbsd-tests/usr.bin/diff/t_diff.sh with the name of the script via `basename $0`. This was a change I forgot to port over from ^/head/gnu/usr.bin/diff/tests/Makefile@r272787. Notes: svn path=/head/; revision=321227
* Add tests that exercise -q, like -rq and add tests that test -q like -NrqEnji Cooper2017-07-171-2/+15
| | | | | | | | MFC after: 2 months MFC with: r321076, r321077, r321078 Notes: svn path=/head/; revision=321079
* Fix exit status with -rq when there is a file in one directory but not another,Enji Cooper2017-07-171-2/+6
| | | | | | | | | | | | | | | | | | i.e., when print_only is called. Prior to this change, -rq was always returning 0. After this change it will return 1 if there is a difference between two directories. This fixes compatibility with GNU diff and unbreaks backwards compatibility expectations. Found when trying to extend diff_test:brief_format_test. MFC after: 2 months MFC with: r321076, r321077 Notes: svn path=/head/; revision=321078
* Add some tests for brief (--brief/-q) formatEnji Cooper2017-07-171-0/+19
| | | | | | | | MFC after: 2 months MFC with: r321076 Notes: svn path=/head/; revision=321077
* Don't emit "diff: diff <options> arguments" when diffing files ifEnji Cooper2017-07-171-1/+1
| | | | | | | | | | | | | | -q is specified. This improves compatibility with GNU diff. Found by accident with `diff -Nrq /usr/tests /usr/tests.new | grep Kyuafile`. MFC after: 2 months Relnotes: yes Notes: svn path=/head/; revision=321076
* Add some testcases for `diff --side-by-side` supportEnji Cooper2017-06-121-0/+22
| | | | | | | | | | | | | These are were created proactively, in anticipation of the support being fully implemented sometime in the future. The tests currently fail on ^/head@r319845, however. Expect them to fail. PR: 219933 Tested with: gdiff Notes: svn path=/head/; revision=319847
* Add -H as an alias for --speed-large-file to match GNU diff.John Baldwin2017-06-021-5/+5
| | | | | | | | | | | This is undocumented to match GNU diff where -H is also undocumented. Some existing software (such as kompare) uses this option by default. Reviewed by: emaste, rpokala Differential Revision: https://reviews.freebsd.org/D11022 Notes: svn path=/head/; revision=319489
* Fix the following warning from gcc 4.2 in usr.bin/diff:Dimitry Andric2017-04-241-6/+7
| | | | | | | | | | | | | | | | usr.bin/diff/diffreg.c: In function 'change': usr.bin/diff/diffreg.c:1085: warning: 'i' may be used uninitialized in this function This version of gcc is not smart enough to see that 'i' cannot actually be used unitialized. However, the variable is confusingly re-used, so it is better to give it another name, and clearly initialize it before attempting to use it. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10484 Notes: svn path=/head/; revision=317381
* Cross reference pr(1) which diff might call with -l optionBaptiste Daroussin2017-04-201-0/+1
| | | | Notes: svn path=/head/; revision=317207
* Update the TODO list to reflect what has been changedBaptiste Daroussin2017-04-201-3/+3
| | | | Notes: svn path=/head/; revision=317206
* Document all long optionsBaptiste Daroussin2017-04-201-25/+37
| | | | Notes: svn path=/head/; revision=317205
* Implement a basic --changed-group-formatBaptiste Daroussin2017-04-207-8/+101
| | | | | | | | | | | | | etcupdate(8) requires that option, while GNU diff supports many more variation of that options, their behaviour beside the simple verion implemented here are quite inconsistent as such I do not plan to implement those. The only special keyword supported by this implementation are: %< and %> %= is not implemented as the documentation of GNU diff says: common lines, but it actually when tested print the changes from the first file Notes: svn path=/head/; revision=317194
* Add a regression test for diff -DBaptiste Daroussin2017-04-203-1/+37
| | | | Notes: svn path=/head/; revision=317187
* Clean up headers declarationBaptiste Daroussin2017-04-153-6/+1
| | | | Notes: svn path=/head/; revision=316959
* add a stub --speed-large-files for compatibility with GNU diffBaptiste Daroussin2017-04-082-1/+10
| | | | | | | | There is no intention to implement it, but lots of scripts/tools using diff(1) passes GNU diff option Notes: svn path=/head/; revision=316639
* diff: Show nanoseconds in -u/-c header line.Jilles Tjoelker2017-03-264-15/+23
| | | | | | | | | | | | | | | Show nanoseconds in the -u/-c header line. The present portability conditionals cannot handle the POSIX standard st_mtim, so remove them and unconditionally use st_mtim. PR: 218018 Reported by: jbeich Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10145 Notes: svn path=/head/; revision=316002
* diff: Fix mtime of file1 in -u/-c header line.Jilles Tjoelker2017-03-264-4/+22
| | | | | | | | | PR: 218018 Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10140 Notes: svn path=/head/; revision=315985