Date: Tue, 27 Oct 2020 07:59:40 -0500 From: Kyle Evans <kevans@freebsd.org> To: Baptiste Daroussin <bapt@freebsd.org> Cc: Kyle Evans <kevans@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org> Subject: Re: svn commit: r367076 - head/usr.bin/diff Message-ID: <CACNAnaGQRpBHnz7E8Ufcpa3zbO%2B=86t6Ci-BhxRcF=u4m_ca7A@mail.gmail.com> In-Reply-To: <20201027125724.onnk46ruaqyqyizk@ivaldir.net> References: <202010271227.09RCRQEN018075@repo.freebsd.org> <20201027125724.onnk46ruaqyqyizk@ivaldir.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Oct 27, 2020 at 7:57 AM Baptiste Daroussin <bapt@freebsd.org> wrote: > > On Tue, Oct 27, 2020 at 12:27:26PM +0000, Kyle Evans wrote: > > Author: kevans > > Date: Tue Oct 27 12:27:26 2020 > > New Revision: 367076 > > URL: https://svnweb.freebsd.org/changeset/base/367076 > > > > Log: > > diff: don't force the format to 'context' with -p immediately > > > > 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 > > > > Modified: > > head/usr.bin/diff/diff.c > > > > Modified: head/usr.bin/diff/diff.c > > ============================================================================== > > --- head/usr.bin/diff/diff.c Tue Oct 27 11:29:11 2020 (r367075) > > +++ head/usr.bin/diff/diff.c Tue Oct 27 12:27:26 2020 (r367076) > > @@ -210,17 +210,6 @@ main(int argc, char **argv) > > diff_format = D_NREVERSE; > > break; > > case 'p': > > - /* > > - * If it's not unset and it's not set to context or > > - * unified, we'll error out here as a conflicting > > - * format. If it's unset, we'll go ahead and set it to > > - * context. > > - */ > > - if (FORMAT_MISMATCHED(D_CONTEXT) && > > - FORMAT_MISMATCHED(D_UNIFIED)) > > - conflicting_format(); > > - if (diff_format == D_UNSET) > > - diff_format = D_CONTEXT; > > dflags |= D_PROTOTYPE; > > break; > > case 'P': > > @@ -320,6 +309,8 @@ main(int argc, char **argv) > > newarg = optind != prevoptind; > > prevoptind = optind; > > } > > + if (diff_format == D_UNSET && (dflags & D_PROTOTYPE) != 0) > > + diff_format = D_CONTEXT; > > if (diff_format == D_UNSET) > > diff_format = D_NORMAL; > > argc -= optind; > > I think it would be great to have a test to ensure we don't break it in the > futur. > Yeah, I had the same thought right after :wq :-) I'll whip up a test this afternoon. Thanks, Kyle Evans
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACNAnaGQRpBHnz7E8Ufcpa3zbO%2B=86t6Ci-BhxRcF=u4m_ca7A>