From owner-svn-src-user@freebsd.org Mon Dec 26 10:02:03 2016 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 83D74C9011F for ; Mon, 26 Dec 2016 10:02:03 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 510121EC7; Mon, 26 Dec 2016 10:02:03 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBQA22oh028506; Mon, 26 Dec 2016 10:02:02 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQA22XU028505; Mon, 26 Dec 2016 10:02:02 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612261002.uBQA22XU028505@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Mon, 26 Dec 2016 10:02:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310582 - user/bapt/diff X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Dec 2016 10:02:03 -0000 Author: bapt Date: Mon Dec 26 10:02:02 2016 New Revision: 310582 URL: https://svnweb.freebsd.org/changeset/base/310582 Log: Make diff -p compatible with GNU diff: - default context is now set to 3 lines - modify the diff output type for -p to contextual if no other swicth has been set to match GNU diff behaviour Modified: user/bapt/diff/diff.c Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Mon Dec 26 10:01:52 2016 (r310581) +++ user/bapt/diff/diff.c Mon Dec 26 10:02:02 2016 (r310582) @@ -94,6 +94,8 @@ main(int argc, char **argv) lastch = '\0'; prevoptind = 1; newarg = 1; + diff_context = 3; + diff_format = 0; while ((ch = getopt_long(argc, argv, OPTIONS, longopts, NULL)) != -1) { switch (ch) { case '0': case '1': case '2': case '3': case '4': @@ -120,8 +122,7 @@ main(int argc, char **argv) if (*ep != '\0' || l < 0 || l >= INT_MAX) usage(); diff_context = (int)l; - } else - diff_context = 3; + } break; case 'd': dflags |= D_MINIMAL; @@ -160,6 +161,8 @@ main(int argc, char **argv) diff_format = D_NREVERSE; break; case 'p': + if (diff_format == 0) + diff_format = D_CONTEXT; dflags |= D_PROTOTYPE; break; case 'P': @@ -191,8 +194,7 @@ main(int argc, char **argv) if (*ep != '\0' || l < 0 || l >= INT_MAX) usage(); diff_context = (int)l; - } else - diff_context = 3; + } break; case 'w': dflags |= D_IGNOREBLANKS;