From owner-svn-src-head@freebsd.org Sun Aug 19 05:12:18 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33AD810831D1; Sun, 19 Aug 2018 05:12:18 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-it0-f44.google.com (mail-it0-f44.google.com [209.85.214.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9DAA588403; Sun, 19 Aug 2018 05:12:17 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-it0-f44.google.com with SMTP id d9-v6so16502422itf.2; Sat, 18 Aug 2018 22:12:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=AsQ4mBX90M8RaxvYS3madnaCy9W2s6K3viPxQYQqJkc=; b=Z2o8LmXKFZ+vpfWpURSX2hLF1ysjLpR9i8BG6x3GKX4rYHcyUPAF8eVAietOeipgY7 q9qC6cYlCJ2AIJYRr2he8ME4aKYGhyVo8KqSdXqZxEoRpD5H4tqIB8JeuicstJs9HIA/ +9HL7vypj16bW4XoUu3BNaM9BLurBGZ05S3kc+fm7Uf5PwWhelEh5KT3bOam5nlC7Nax VjJ297SaBIk3r3+9jJsbOPQ4ZyM/wnQgIVQFnfmpswjWh46Xl/35fCIzgCDyD3DGVJFZ FjlIFM/SvTsduaAEmbQUCDGyWX/C/a33GTCvKJp2QoE0b+FF8gIMnJvB5/8kGe1nOnyJ i0og== X-Gm-Message-State: AOUpUlHYFKRcUawc/396kHIYtYyTbYy2nay4D+4jkoVv0hLhRkq2njVB 37TRZbahF7HcMN9+UzPlNngukyjB X-Google-Smtp-Source: AA+uWPwcsrMu9cmFCHNzcMkEe7Cnb+vSPgOfzrT72mJgeC0w2GjhJyjEIK9sg/Bs6ygGSejTLOaNrw== X-Received: by 2002:a24:8ec7:: with SMTP id h190-v6mr29072962ite.29.1534655530524; Sat, 18 Aug 2018 22:12:10 -0700 (PDT) Received: from mail-it0-f44.google.com (mail-it0-f44.google.com. [209.85.214.44]) by smtp.gmail.com with ESMTPSA id d12-v6sm3278202itf.25.2018.08.18.22.12.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Aug 2018 22:12:10 -0700 (PDT) Received: by mail-it0-f44.google.com with SMTP id e14-v6so16503747itf.1; Sat, 18 Aug 2018 22:12:09 -0700 (PDT) X-Received: by 2002:a02:4009:: with SMTP id n9-v6mr37321627jaa.19.1534655529714; Sat, 18 Aug 2018 22:12:09 -0700 (PDT) MIME-Version: 1.0 References: <201808190357.w7J3vKHj030368@repo.freebsd.org> In-Reply-To: <201808190357.w7J3vKHj030368@repo.freebsd.org> Reply-To: cem@freebsd.org From: Conrad Meyer Date: Sat, 18 Aug 2018 22:11:57 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r338039 - in head/usr.bin/diff: . tests To: Kyle Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Aug 2018 05:12:18 -0000 Hey, That=E2=80=99s awesome! Thank you! Best, Conrad On Sat, Aug 18, 2018 at 8:57 PM Kyle Evans wrote: > Author: kevans > Date: Sun Aug 19 03:57:20 2018 > New Revision: 338039 > URL: https://svnweb.freebsd.org/changeset/base/338039 > > Log: > diff(1): Implement -B/--ignore-blank-lines > > 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 > > Added: > head/usr.bin/diff/tests/Bflag_C.out (contents, props changed) > head/usr.bin/diff/tests/Bflag_D.out (contents, props changed) > head/usr.bin/diff/tests/Bflag_F.out (contents, props changed) > Modified: > head/usr.bin/diff/TODO > head/usr.bin/diff/diff.1 > head/usr.bin/diff/diff.c > head/usr.bin/diff/diff.h > head/usr.bin/diff/diffreg.c > head/usr.bin/diff/tests/Makefile > head/usr.bin/diff/tests/diff_test.sh > > Modified: head/usr.bin/diff/TODO > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.bin/diff/TODO Sun Aug 19 01:14:46 2018 (r338038) > +++ head/usr.bin/diff/TODO Sun Aug 19 03:57:20 2018 (r338039) > @@ -5,7 +5,6 @@ > * make a libsdiff and use that directly to avoid duplicating the code > > to be implemented: > ---ignore-blank-lines > --horizon-lines > --ignore-tab-expansion > --line-format > > Modified: head/usr.bin/diff/diff.1 > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.bin/diff/diff.1 Sun Aug 19 01:14:46 2018 (r338038) > +++ head/usr.bin/diff/diff.1 Sun Aug 19 03:57:20 2018 (r338039) > @@ -30,7 +30,7 @@ > .\" @(#)diff.1 8.1 (Berkeley) 6/30/93 > .\" $FreeBSD$ > .\" > -.Dd April 20, 2017 > +.Dd August 18, 2018 > .Dt DIFF 1 > .Os > .Sh NAME > @@ -38,7 +38,7 @@ > .Nd differential file and directory comparator > .Sh SYNOPSIS > .Nm diff > -.Op Fl abdipTtw > +.Op Fl aBbdipTtw > .Oo > .Fl c | e | f | > .Fl n | q | u > @@ -67,7 +67,7 @@ > .Op Fl L Ar label | Fl -label Ar label > .Ar file1 file2 > .Nm diff > -.Op Fl abdilpTtw > +.Op Fl aBbdilpTtw > .Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern > .Op Fl L Ar label | Fl -label Ar label > .Op Fl -brief > @@ -93,7 +93,7 @@ > .Fl C Ar number | -context Ar number > .Ar file1 file2 > .Nm diff > -.Op Fl abdiltw > +.Op Fl aBbdiltw > .Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern > .Op Fl -brief > .Op Fl -changed-group-format Ar GFMT > @@ -118,7 +118,7 @@ > .Fl D Ar string | Fl -ifdef Ar string > .Ar file1 file2 > .Nm diff > -.Op Fl abdilpTtw > +.Op Fl aBbdilpTtw > .Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern > .Op Fl L Ar label | Fl -label Ar label > .Op Fl -brief > @@ -144,7 +144,7 @@ > .Fl U Ar number | Fl -unified Ar number > .Ar file1 file2 > .Nm diff > -.Op Fl abdilNPprsTtw > +.Op Fl aBbdilNPprsTtw > .Oo > .Fl c | e | f | > .Fl n | q | u > @@ -300,6 +300,8 @@ if files contain binary characters. > Use of this option forces > .Nm > to produce a diff. > +.It Fl B Fl -ignore-blank-lines > +Causes chunks that include only blank lines to be ignored. > .It Fl b > Causes trailing blanks (spaces and tabs) to be ignored, and other > strings of blanks to compare equal. > > Modified: head/usr.bin/diff/diff.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.bin/diff/diff.c Sun Aug 19 01:14:46 2018 (r338038) > +++ head/usr.bin/diff/diff.c Sun Aug 19 03:57:20 2018 (r338039) > @@ -66,6 +66,7 @@ static struct option longopts[] =3D { > { "ed", no_argument, 0, > 'e' }, > { "forward-ed", no_argument, 0, > 'f' }, > { "speed-large-files", no_argument, NULL, > 'H' }, > + { "ignore-blank-lines", no_argument, 0, > 'B' }, > { "ignore-matching-lines", required_argument, 0, > 'I' }, > { "ignore-case", no_argument, 0, > 'i' }, > { "paginate", no_argument, NULL, > 'l' }, > @@ -164,6 +165,9 @@ main(int argc, char **argv) > case 'h': > /* silently ignore for backwards compatibility */ > break; > + case 'B': > + dflags |=3D D_SKIPBLANKLINES; > + break; > case 'I': > push_ignore_pats(optarg); > break; > @@ -447,18 +451,18 @@ void > usage(void) > { > (void)fprintf(stderr, > - "usage: diff [-abdilpTtw] [-c | -e | -f | -n | -q | -u] > [--ignore-case]\n" > + "usage: diff [-aBbdilpTtw] [-c | -e | -f | -n | -q | -u] > [--ignore-case]\n" > " [--no-ignore-case] [--normal] > [--strip-trailing-cr] [--tabsize]\n" > " [-I pattern] [-L label] file1 file2\n" > - " diff [-abdilpTtw] [-I pattern] [-L label] > [--ignore-case]\n" > + " diff [-aBbdilpTtw] [-I pattern] [-L label] > [--ignore-case]\n" > " [--no-ignore-case] [--normal] > [--strip-trailing-cr] [--tabsize]\n" > " -C number file1 file2\n" > - " diff [-abdiltw] [-I pattern] [--ignore-case] > [--no-ignore-case]\n" > + " diff [-aBbdiltw] [-I pattern] [--ignore-case] > [--no-ignore-case]\n" > " [--normal] [--strip-trailing-cr] [--tabsize] -D > string file1 file2\n" > - " diff [-abdilpTtw] [-I pattern] [-L label] > [--ignore-case]\n" > + " diff [-aBbdilpTtw] [-I pattern] [-L label] > [--ignore-case]\n" > " [--no-ignore-case] [--normal] [--tabsize] > [--strip-trailing-cr]\n" > " -U number file1 file2\n" > - " diff [-abdilNPprsTtw] [-c | -e | -f | -n | -q | -u] > [--ignore-case]\n" > + " diff [-aBbdilNPprsTtw] [-c | -e | -f | -n | -q | -u] > [--ignore-case]\n" > " [--no-ignore-case] [--normal] [--tabsize] [-I > pattern] [-L label]\n" > " [-S name] [-X file] [-x pattern] dir1 dir2\n"); > > > Modified: head/usr.bin/diff/diff.h > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.bin/diff/diff.h Sun Aug 19 01:14:46 2018 (r338038) > +++ head/usr.bin/diff/diff.h Sun Aug 19 03:57:20 2018 (r338039) > @@ -67,6 +67,7 @@ > #define D_EXPANDTABS 0x100 /* Expand tabs to spaces */ > #define D_IGNOREBLANKS 0x200 /* Ignore white space changes */ > #define D_STRIPCR 0x400 /* Strip trailing cr */ > +#define D_SKIPBLANKLINES 0x800 /* Skip blank lines */ > > /* > * Status values for print_status() and diffreg() return values > > Modified: head/usr.bin/diff/diffreg.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.bin/diff/diffreg.c Sun Aug 19 01:14:46 2018 (r338038) > +++ head/usr.bin/diff/diffreg.c Sun Aug 19 03:57:20 2018 (r338039) > @@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -999,6 +1000,31 @@ restart: > } > } > return; > + } > + if (*pflags & D_SKIPBLANKLINES) { > + char *line; > + /* > + * All lines in the change, insert, or delete must not be > + * empty for the change to be ignored. > + */ > + if (a <=3D b) { /* Changes and deletes. */ > + for (i =3D a; i <=3D b; i++) { > + line =3D preadline(fileno(f1), > + ixold[i] - ixold[i - 1], ixold[i - 1]= ); > + if (*line !=3D '\0') > + goto proceed; > + } > + } > + if (a > b || c <=3D d) { /* Changes and inserts. */ > + for (i =3D c; i <=3D d; i++) { > + line =3D preadline(fileno(f2), > + ixnew[i] - ixnew[i - 1], ixnew[i - 1]= ); > + if (*line !=3D '\0') > + goto proceed; > + } > + } > + return; > + > } > proceed: > if (*pflags & D_HEADER && diff_format !=3D D_BRIEF) { > > Added: head/usr.bin/diff/tests/Bflag_C.out > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.bin/diff/tests/Bflag_C.out Sun Aug 19 03:57:20 2018 > (r338039) > @@ -0,0 +1,2 @@ > +1a2 > +> > > Added: head/usr.bin/diff/tests/Bflag_D.out > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.bin/diff/tests/Bflag_D.out Sun Aug 19 03:57:20 2018 > (r338039) > @@ -0,0 +1,2 @@ > +1a2 > +> C > > Added: head/usr.bin/diff/tests/Bflag_F.out > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.bin/diff/tests/Bflag_F.out Sun Aug 19 03:57:20 2018 > (r338039) > @@ -0,0 +1,4 @@ > +7c8 > +< G > +--- > +> X > > Modified: head/usr.bin/diff/tests/Makefile > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.bin/diff/tests/Makefile Sun Aug 19 01:14:46 2018 > (r338038) > +++ head/usr.bin/diff/tests/Makefile Sun Aug 19 03:57:20 2018 > (r338039) > @@ -5,6 +5,9 @@ PACKAGE=3D tests > ATF_TESTS_SH=3D diff_test > > ${PACKAGE}FILES+=3D \ > + Bflag_C.out \ > + Bflag_D.out \ > + Bflag_F.out \ > input1.in \ > input2.in \ > input_c1.in \ > > Modified: head/usr.bin/diff/tests/diff_test.sh > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.bin/diff/tests/diff_test.sh Sun Aug 19 01:14:46 2018 > (r338038) > +++ head/usr.bin/diff/tests/diff_test.sh Sun Aug 19 03:57:20 2018 > (r338039) > @@ -9,6 +9,7 @@ atf_test_case group_format > atf_test_case side_by_side > atf_test_case brief_format > atf_test_case b230049 > +atf_test_case Bflag > > simple_body() > { > @@ -150,6 +151,21 @@ brief_format_body() > diff -Nrq A D > } > > +Bflag_body() > +{ > + atf_check -x 'printf "A\nB\n" > A' > + atf_check -x 'printf "A\n\nB\n" > B' > + atf_check -x 'printf "A\n \nB\n" > C' > + atf_check -x 'printf "A\nC\nB\n" > D' > + atf_check -x 'printf "A\nB\nC\nD\nE\nF\nG\nH" > E' > + atf_check -x 'printf "A\n\nB\nC\nD\nE\nF\nX\nH" > F' > + > + atf_check -s exit:0 -o inline:"" diff -B A B > + atf_check -s exit:1 -o file:"$(atf_get_srcdir)/Bflag_C.out" diff > -B A C > + atf_check -s exit:1 -o file:"$(atf_get_srcdir)/Bflag_D.out" diff > -B A D > + atf_check -s exit:1 -o file:"$(atf_get_srcdir)/Bflag_F.out" diff > -B E F > +} > + > atf_init_test_cases() > { > atf_add_test_case simple > @@ -161,4 +177,5 @@ atf_init_test_cases() > atf_add_test_case side_by_side > atf_add_test_case brief_format > atf_add_test_case b230049 > + atf_add_test_case Bflag > } > >