From owner-svn-src-user@freebsd.org Sun Dec 25 07:50:25 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 0D649C902E0 for ; Sun, 25 Dec 2016 07:50:25 +0000 (UTC) (envelope-from pho@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 B7D2E974; Sun, 25 Dec 2016 07:50:24 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBP7oNe6085658; Sun, 25 Dec 2016 07:50:23 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBP7oN28085657; Sun, 25 Dec 2016 07:50:23 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201612250750.uBP7oN28085657@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Sun, 25 Dec 2016 07:50:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310532 - user/pho/stress2/misc 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: Sun, 25 Dec 2016 07:50:25 -0000 Author: pho Date: Sun Dec 25 07:50:23 2016 New Revision: 310532 URL: https://svnweb.freebsd.org/changeset/base/310532 Log: Added a test scenario. Sponsored by: Dell EMC Isilon Added: user/pho/stress2/misc/full.sh (contents, props changed) Added: user/pho/stress2/misc/full.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/full.sh Sun Dec 25 07:50:23 2016 (r310532) @@ -0,0 +1,61 @@ +#!/bin/sh + +# +# Copyright (c) 2016 Dell EMC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +# Run all tests from testcases on a 2g swap backed MD with UFS SU fs. + +# "panic: SACK scoreboard must not be empty" seen: +# https://people.freebsd.org/~pho/stress/log/full.txt + +. ../default.cfg + +mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 2g -u $mdstart +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint +chmod 777 $mntpoint + +export LOAD=80 +export rwLOAD=80 +export runRUNTIME=10m +export RUNDIR=$mntpoint/stressX +export TESTPROGS=`cd ..; find testcases/ -perm -1 -type f | egrep -v "/run/|/syscall/"` + +su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' + +../tools/killall.sh +while mount | grep "on $mntpoint " | grep -q /dev/md; do + umount $mntpoint || sleep 1 +done +checkfs /dev/md${mdstart}$part +mdconfig -d -u $mdstart From owner-svn-src-user@freebsd.org Sun Dec 25 08:02:38 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 909F0C907AE for ; Sun, 25 Dec 2016 08:02:38 +0000 (UTC) (envelope-from pho@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 6049D11C9; Sun, 25 Dec 2016 08:02:38 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBP82bEm093550; Sun, 25 Dec 2016 08:02:37 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBP82bFx093549; Sun, 25 Dec 2016 08:02:37 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201612250802.uBP82bFx093549@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Sun, 25 Dec 2016 08:02:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310533 - user/pho/stress2/testcases 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: Sun, 25 Dec 2016 08:02:38 -0000 Author: pho Date: Sun Dec 25 08:02:37 2016 New Revision: 310533 URL: https://svnweb.freebsd.org/changeset/base/310533 Log: Do not build the debug files. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/testcases/Makefile.inc Modified: user/pho/stress2/testcases/Makefile.inc ============================================================================== --- user/pho/stress2/testcases/Makefile.inc Sun Dec 25 07:50:23 2016 (r310532) +++ user/pho/stress2/testcases/Makefile.inc Sun Dec 25 08:02:37 2016 (r310533) @@ -5,3 +5,4 @@ LDADD+= -L../../lib -lstress -lutil DPADD+= ../../lib/libstress.a CFLAGS =-g -Wall -Wextra -O2 -I../../include -I../include MAN= +MK_DEBUG_FILES=no From owner-svn-src-user@freebsd.org Sun Dec 25 09:54:30 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 37DCEC8FE88 for ; Sun, 25 Dec 2016 09:54:30 +0000 (UTC) (envelope-from pho@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 07D0BA14; Sun, 25 Dec 2016 09:54:29 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBP9sTpu037919; Sun, 25 Dec 2016 09:54:29 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBP9sTbJ037917; Sun, 25 Dec 2016 09:54:29 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201612250954.uBP9sTbJ037917@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Sun, 25 Dec 2016 09:54:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310535 - in user/pho/stress2/testcases: thr1 thr2 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: Sun, 25 Dec 2016 09:54:30 -0000 Author: pho Date: Sun Dec 25 09:54:28 2016 New Revision: 310535 URL: https://svnweb.freebsd.org/changeset/base/310535 Log: Fix bug in error handling. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/testcases/thr1/thr1.c user/pho/stress2/testcases/thr2/thr2.c Modified: user/pho/stress2/testcases/thr1/thr1.c ============================================================================== --- user/pho/stress2/testcases/thr1/thr1.c Sun Dec 25 09:40:44 2016 (r310534) +++ user/pho/stress2/testcases/thr1/thr1.c Sun Dec 25 09:54:28 2016 (r310535) @@ -68,7 +68,7 @@ test(void) for (i = 0; i < NTHREADS; i++) if ((r = pthread_create(&threads[i], NULL, thr_routine, 0)) != 0) - err(1, "pthread_create(): %s\n", strerror(r)); + errc(1, r, "pthread_create()"); for (i = 0; i < NTHREADS; i++) if ((r = pthread_join(threads[i], NULL)) != 0) Modified: user/pho/stress2/testcases/thr2/thr2.c ============================================================================== --- user/pho/stress2/testcases/thr2/thr2.c Sun Dec 25 09:40:44 2016 (r310534) +++ user/pho/stress2/testcases/thr2/thr2.c Sun Dec 25 09:54:28 2016 (r310535) @@ -77,15 +77,15 @@ test(void) for (i = 0; i < NTHREADS; i++) if ((r = pthread_create(&threads[i], NULL, thr1, 0)) != 0) - err(1, "pthread_create(): %s\n", strerror(r)); + errc(1, r, "pthread_create()"); for (i = 0; i < NTHREADS; i++) if (pthread_join(threads[i], NULL) != 0) - err(1, "pthread_join(%d)", i); + errc(1, r, "pthread_join(%d)", i); for (i = 0; i < NTHREADS; i++) if ((r = pthread_create(&threads[i], NULL, thr2, 0)) != 0) - err(1, "pthread_create(): %s\n", strerror(r)); + errc(1, r, "pthread_create()"); done = 1; for (i = 0; i < NTHREADS; i++) From owner-svn-src-user@freebsd.org Sun Dec 25 09:58:50 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 7742EC8FEF5 for ; Sun, 25 Dec 2016 09:58:50 +0000 (UTC) (envelope-from pho@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 470E7B68; Sun, 25 Dec 2016 09:58:50 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBP9wnrw038119; Sun, 25 Dec 2016 09:58:49 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBP9wnUJ038117; Sun, 25 Dec 2016 09:58:49 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201612250958.uBP9wnUJ038117@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Sun, 25 Dec 2016 09:58:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310536 - in user/pho/stress2/testcases: shm socket 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: Sun, 25 Dec 2016 09:58:50 -0000 Author: pho Date: Sun Dec 25 09:58:49 2016 New Revision: 310536 URL: https://svnweb.freebsd.org/changeset/base/310536 Log: Use _exit(2). Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/testcases/shm/shm.c user/pho/stress2/testcases/socket/socket.c Modified: user/pho/stress2/testcases/shm/shm.c ============================================================================== --- user/pho/stress2/testcases/shm/shm.c Sun Dec 25 09:54:28 2016 (r310535) +++ user/pho/stress2/testcases/shm/shm.c Sun Dec 25 09:58:49 2016 (r310536) @@ -138,7 +138,7 @@ test(void) pid = fork(); if (pid == -1) { perror("fork"); - exit(2); + _exit(2); } if (pid == 0) { /* child */ @@ -159,7 +159,7 @@ test(void) i = (i + 1) % (10 * pgsize); Sig(0); } - exit(0); + _exit(0); } else { /* parent */ i = 0; Modified: user/pho/stress2/testcases/socket/socket.c ============================================================================== --- user/pho/stress2/testcases/socket/socket.c Sun Dec 25 09:54:28 2016 (r310535) +++ user/pho/stress2/testcases/socket/socket.c Sun Dec 25 09:58:49 2016 (r310536) @@ -110,7 +110,7 @@ test(void) err(1, "socketpair()"); if ((pid = fork()) == 0) { writer(); - exit(EXIT_SUCCESS); + _exit(EXIT_SUCCESS); } else if (pid > 0) { reader(); From owner-svn-src-user@freebsd.org Sun Dec 25 10:00:37 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 BBF39C90064 for ; Sun, 25 Dec 2016 10:00:37 +0000 (UTC) (envelope-from pho@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 85289D1F; Sun, 25 Dec 2016 10:00:37 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBPA0aWC038269; Sun, 25 Dec 2016 10:00:36 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBPA0aEc038268; Sun, 25 Dec 2016 10:00:36 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201612251000.uBPA0aEc038268@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Sun, 25 Dec 2016 10:00:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310537 - user/pho/stress2/testcases/swap 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: Sun, 25 Dec 2016 10:00:37 -0000 Author: pho Date: Sun Dec 25 10:00:36 2016 New Revision: 310537 URL: https://svnweb.freebsd.org/changeset/base/310537 Log: Cleanup. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/testcases/swap/swap.c Modified: user/pho/stress2/testcases/swap/swap.c ============================================================================== --- user/pho/stress2/testcases/swap/swap.c Sun Dec 25 09:58:49 2016 (r310536) +++ user/pho/stress2/testcases/swap/swap.c Sun Dec 25 10:00:36 2016 (r310537) @@ -29,13 +29,14 @@ __FBSDID("$FreeBSD$"); #include +#include #include -#include -#include -#include #include -#include + #include +#include +#include +#include #include "stress.h" @@ -50,15 +51,16 @@ static unsigned long size; int setup(int nb) { - int pct = 0; - unsigned long mem; - int64_t swapinfo = 0; struct rlimit rlp; + int64_t swapinfo; + unsigned long mem; + int pct; if (nb == 0) { mem = usermem(); swapinfo = swap(); + pct = 0; if (op->hog == 0) pct = random_int(80, 100); @@ -112,11 +114,12 @@ cleanup(void) int test(void) { - char *c; - int page; - unsigned long i, oldsize = size; time_t start; + unsigned long i, oldsize; + int page; + char *c; + oldsize = size; c = malloc(size); while (c == NULL && done_testing == 0) { size -= 1024 * 1024; From owner-svn-src-user@freebsd.org Sun Dec 25 12:00:58 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 26E49C90721 for ; Sun, 25 Dec 2016 12:00:58 +0000 (UTC) (envelope-from pho@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 E95D2307; Sun, 25 Dec 2016 12:00:57 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBPC0vUn086984; Sun, 25 Dec 2016 12:00:57 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBPC0vCL086983; Sun, 25 Dec 2016 12:00:57 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201612251200.uBPC0vCL086983@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Sun, 25 Dec 2016 12:00:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310538 - user/pho/stress2/testcases/shm 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: Sun, 25 Dec 2016 12:00:58 -0000 Author: pho Date: Sun Dec 25 12:00:56 2016 New Revision: 310538 URL: https://svnweb.freebsd.org/changeset/base/310538 Log: exit(3) is really needed after perror(3). Reported by: kib Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/testcases/shm/shm.c Modified: user/pho/stress2/testcases/shm/shm.c ============================================================================== --- user/pho/stress2/testcases/shm/shm.c Sun Dec 25 10:00:36 2016 (r310537) +++ user/pho/stress2/testcases/shm/shm.c Sun Dec 25 12:00:56 2016 (r310538) @@ -138,7 +138,7 @@ test(void) pid = fork(); if (pid == -1) { perror("fork"); - _exit(2); + exit(2); } if (pid == 0) { /* child */ From owner-svn-src-user@freebsd.org Mon Dec 26 09:34:58 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 8E536C8F54F for ; Mon, 26 Dec 2016 09:34:58 +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 44A8C83F; Mon, 26 Dec 2016 09:34:58 +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 uBQ9YvwG018758; Mon, 26 Dec 2016 09:34:57 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQ9Yv16018757; Mon, 26 Dec 2016 09:34:57 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612260934.uBQ9Yv16018757@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 09:34:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310576 - user/bapt 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 09:34:58 -0000 Author: bapt Date: Mon Dec 26 09:34:57 2016 New Revision: 310576 URL: https://svnweb.freebsd.org/changeset/base/310576 Log: Create my user directory so I can put in there some work in progress Added: user/bapt/ From owner-svn-src-user@freebsd.org Mon Dec 26 09:46:57 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 13609C8F803 for ; Mon, 26 Dec 2016 09:46:57 +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 CBC48EA3; Mon, 26 Dec 2016 09:46:56 +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 uBQ9kuWT023219; Mon, 26 Dec 2016 09:46:56 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQ9kt24023212; Mon, 26 Dec 2016 09:46:55 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612260946.uBQ9kt24023212@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 09:46:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310577 - 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 09:46:57 -0000 Author: bapt Date: Mon Dec 26 09:46:55 2016 New Revision: 310577 URL: https://svnweb.freebsd.org/changeset/base/310577 Log: Import vanilla diff(1) from OpenBSD Added: user/bapt/diff/ user/bapt/diff/Makefile (contents, props changed) user/bapt/diff/diff.1 (contents, props changed) user/bapt/diff/diff.c (contents, props changed) user/bapt/diff/diff.h (contents, props changed) user/bapt/diff/diffdir.c (contents, props changed) user/bapt/diff/diffreg.c (contents, props changed) user/bapt/diff/xmalloc.c (contents, props changed) user/bapt/diff/xmalloc.h (contents, props changed) Added: user/bapt/diff/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/bapt/diff/Makefile Mon Dec 26 09:46:55 2016 (r310577) @@ -0,0 +1,7 @@ +# $OpenBSD: Makefile,v 1.3 2007/05/29 18:24:56 ray Exp $ + +PROG= diff +SRCS= diff.c diffdir.c diffreg.c xmalloc.c +COPTS+= -Wall + +.include Added: user/bapt/diff/diff.1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/bapt/diff/diff.1 Mon Dec 26 09:46:55 2016 (r310577) @@ -0,0 +1,477 @@ +.\" $OpenBSD: diff.1,v 1.47 2015/11/24 19:35:41 jmc Exp $ +.\" +.\" Copyright (c) 1980, 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)diff.1 8.1 (Berkeley) 6/30/93 +.\" +.Dd $Mdocdate: November 24 2015 $ +.Dt DIFF 1 +.Os +.Sh NAME +.Nm diff +.Nd differential file and directory comparator +.Sh SYNOPSIS +.Nm diff +.Op Fl abdipTtw +.Oo +.Fl c | e | f | +.Fl n | q | u +.Oc +.Op Fl I Ar pattern +.Op Fl L Ar label +.Ar file1 file2 +.Nm diff +.Op Fl abdilpTtw +.Op Fl I Ar pattern +.Op Fl L Ar label +.Fl C Ar number +.Ar file1 file2 +.Nm diff +.Op Fl abdiltw +.Op Fl I Ar pattern +.Fl D Ar string +.Ar file1 file2 +.Nm diff +.Op Fl abdilpTtw +.Op Fl I Ar pattern +.Op Fl L Ar label +.Fl U Ar number +.Ar file1 file2 +.Nm diff +.Op Fl abdilNPprsTtw +.Oo +.Fl c | e | f | +.Fl n | q | u +.Oc +.Op Fl I Ar pattern +.Bk -words +.Op Fl L Ar label +.Op Fl S Ar name +.Op Fl X Ar file +.Op Fl x Ar pattern +.Ek +.Ar dir1 dir2 +.Sh DESCRIPTION +The +.Nm +utility compares the contents of +.Ar file1 +and +.Ar file2 +and writes to the standard output the list of changes necessary to +convert one file into the other. +No output is produced if the files are identical. +.Pp +Output options (mutually exclusive): +.Bl -tag -width Ds +.It Fl C Ar number +Like +.Fl c +but produces a diff with +.Ar number +lines of context. +.It Fl c +Produces a diff with 3 lines of context. +With +.Fl c +the output format is modified slightly: +the output begins with identification of the files involved and +their creation dates and then each change is separated +by a line with fifteen +.Li * Ns 's . +The lines removed from +.Ar file1 +are marked with +.Sq \&-\ \& ; +those added to +.Ar file2 +are marked +.Sq \+\ \& . +Lines which are changed from one file to the other are marked in +both files with +.Sq !\ \& . +Changes which lie within 3 lines of each other are grouped together on +output. +.It Fl D Ar string +Creates a merged version of +.Ar file1 +and +.Ar file2 +on the standard output, with C preprocessor controls included so that +a compilation of the result without defining +.Ar string +is equivalent to compiling +.Ar file1 , +while defining +.Ar string +will yield +.Ar file2 . +.It Fl e +Produces output in a form suitable as input for the editor utility, +.Xr ed 1 , +which can then be used to convert file1 into file2. +.Pp +Extra commands are added to the output when comparing directories with +.Fl e , +so that the result is a +.Xr sh 1 +script for converting text files which are common to the two directories +from their state in +.Ar dir1 +to their state in +.Ar dir2 . +.It Fl f +Identical output to that of the +.Fl e +flag, but in reverse order. +It cannot be digested by +.Xr ed 1 . +.It Fl n +Produces a script similar to that of +.Fl e , +but in the opposite order and with a count of changed lines on each +insert or delete command. +This is the form used by +.Xr rcsdiff 1 . +.It Fl q +Just print a line when the files differ. +Does not output a list of changes. +.It Fl U Ar number +Like +.Fl u +but produces a diff with +.Ar number +lines of context. +.It Fl u +Produces a +.Em unified +diff with 3 lines of context. +A unified diff is similar to the context diff produced by the +.Fl c +option. +However, unlike with +.Fl c , +all lines to be changed (added and/or removed) are present in +a single section. +.El +.Pp +Comparison options: +.Bl -tag -width Ds +.It Fl a +Treat all files as +.Tn ASCII +text. +Normally +.Nm +will simply print +.Dq Binary files ... differ +if files contain binary characters. +Use of this option forces +.Nm +to produce a diff. +.It Fl b +Causes trailing blanks (spaces and tabs) to be ignored, and other +strings of blanks to compare equal. +.It Fl d +Try very hard to produce a diff as small as possible. +This may consume a lot of processing power and memory when processing +large files with many changes. +.It Fl I Ar pattern +Ignores changes, insertions, and deletions whose lines match the +extended regular expression +.Ar pattern . +Multiple +.Fl I +patterns may be specified. +All lines in the change must match some pattern for the change to be +ignored. +See +.Xr re_format 7 +for more information on regular expression patterns. +.It Fl i +Ignores the case of letters. +E.g., +.Dq A +will compare equal to +.Dq a . +.It Fl L Ar label +Print +.Ar label +instead of the first (and second, if this option is specified twice) +file name and time in the context or unified diff header. +.It Fl p +With unified and context diffs, show with each change +the first 40 characters of the last line before the context beginning +with a letter, an underscore or a dollar sign. +For C source code following standard layout conventions, this will +show the prototype of the function the change applies to. +.It Fl T +Print a tab rather than a space before the rest of the line for the +normal, context or unified output formats. +This makes the alignment of tabs in the line consistent. +.It Fl t +Will expand tabs in output lines. +Normal or +.Fl c +output adds character(s) to the front of each line which may screw up +the indentation of the original source lines and make the output listing +difficult to interpret. +This option will preserve the original source's indentation. +.It Fl w +Is similar to +.Fl b +but causes whitespace (blanks and tabs) to be totally ignored. +E.g., +.Dq if (\ \&a == b \&) +will compare equal to +.Dq if(a==b) . +.El +.Pp +Directory comparison options: +.Bl -tag -width Ds +.It Fl N +If a file is found in only one directory, act as if it was found in the +other directory too but was of zero size. +.It Fl P +If a file is found only in +.Ar dir2 , +act as if it was found in +.Ar dir1 +too but was of zero size. +.It Fl r +Causes application of +.Nm +recursively to common subdirectories encountered. +.It Fl S Ar name +Re-starts a directory +.Nm +in the middle, beginning with file +.Ar name . +.It Fl s +Causes +.Nm +to report files which are the same, which are otherwise not mentioned. +.It Fl X Ar file +Exclude files and subdirectories from comparison whose basenames match +lines in +.Ar file . +Multiple +.Fl X +options may be specified. +.It Fl x Ar pattern +Exclude files and subdirectories from comparison whose basenames match +.Ar pattern . +Patterns are matched using shell-style globbing via +.Xr fnmatch 3 . +Multiple +.Fl x +options may be specified. +.El +.Pp +If both arguments are directories, +.Nm +sorts the contents of the directories by name, and then runs the +regular file +.Nm +algorithm, producing a change list, +on text files which are different. +Binary files which differ, +common subdirectories, and files which appear in only one directory +are described as such. +In directory mode only regular files and directories are compared. +If a non-regular file such as a device special file or +.Tn FIFO +is encountered, a diagnostic message is printed. +.Pp +If only one of +.Ar file1 +and +.Ar file2 +is a directory, +.Nm +is applied to the non-directory file and the file contained in +the directory file with a filename that is the same as the +last component of the non-directory file. +.Pp +If either +.Ar file1 +or +.Ar file2 +is +.Sq - , +the standard input is +used in its place. +.Ss Output Style +The default (without +.Fl e , +.Fl c , +or +.Fl n +.\" -C +options) +output contains lines of these forms, where +.Va XX , YY , ZZ , QQ +are line numbers respective of file order. +.Pp +.Bl -tag -width "XX,YYcZZ,QQ" -compact +.It Li XX Ns Ic a Ns Li YY +At (the end of) line +.Va XX +of +.Ar file1 , +append the contents +of line +.Va YY +of +.Ar file2 +to make them equal. +.It Li XX Ns Ic a Ns Li YY,ZZ +Same as above, but append the range of lines, +.Va YY +through +.Va ZZ +of +.Ar file2 +to line +.Va XX +of file1. +.It Li XX Ns Ic d Ns Li YY +At line +.Va XX +delete +the line. +The value +.Va YY +tells to which line the change would bring +.Ar file1 +in line with +.Ar file2 . +.It Li XX,YY Ns Ic d Ns Li ZZ +Delete the range of lines +.Va XX +through +.Va YY +in +.Ar file1 . +.It Li XX Ns Ic c Ns Li YY +Change the line +.Va XX +in +.Ar file1 +to the line +.Va YY +in +.Ar file2 . +.It Li XX,YY Ns Ic c Ns Li ZZ +Replace the range of specified lines with the line +.Va ZZ . +.It Li XX,YY Ns Ic c Ns Li ZZ,QQ +Replace the range +.Va XX , Ns Va YY +from +.Ar file1 +with the range +.Va ZZ , Ns Va QQ +from +.Ar file2 . +.El +.Pp +These lines resemble +.Xr ed 1 +subcommands to convert +.Ar file1 +into +.Ar file2 . +The line numbers before the action letters pertain to +.Ar file1 ; +those after pertain to +.Ar file2 . +Thus, by exchanging +.Ic a +for +.Ic d +and reading the line in reverse order, one can also +determine how to convert +.Ar file2 +into +.Ar file1 . +As in +.Xr ed 1 , +identical +pairs (where num1 = num2) are abbreviated as a single +number. +.Sh FILES +.Bl -tag -width /tmp/diff.XXXXXXXX -compact +.It Pa /tmp/diff. Ns Ar XXXXXXXX +Temporary file used when comparing a device or the standard input. +Note that the temporary file is unlinked as soon as it is created +so it will not show up in a directory listing. +.El +.Sh EXIT STATUS +The +.Nm +utility exits with one of the following values: +.Pp +.Bl -tag -width Ds -offset indent -compact +.It 0 +No differences were found. +.It 1 +Differences were found. +.It >1 +An error occurred. +.El +.Sh SEE ALSO +.Xr cmp 1 , +.Xr comm 1 , +.Xr diff3 1 , +.Xr ed 1 , +.Xr patch 1 , +.Xr sdiff 1 +.Rs +.%A James W. Hunt +.%A M. Douglas McIlroy +.%T "An Algorithm for Differential File Comparison" +.%J Computing Science Technical Report +.%Q Bell Laboratories 41 +.%D June 1976 +.Re +.Sh STANDARDS +The +.Nm +utility is compliant with the +.St -p1003.1-2008 +specification. +.Pp +The flags +.Op Fl aDdIiLlNnPpqSsTtwXx +are extensions to that specification. +.Sh HISTORY +A +.Nm +command appeared in +.At v6 . Added: user/bapt/diff/diff.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/bapt/diff/diff.c Mon Dec 26 09:46:55 2016 (r310577) @@ -0,0 +1,401 @@ +/* $OpenBSD: diff.c,v 1.65 2015/12/29 19:04:46 gsoares Exp $ */ + +/* + * Copyright (c) 2003 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "diff.h" +#include "xmalloc.h" + +int Nflag, Pflag, rflag, sflag, Tflag; +int diff_format, diff_context, status; +char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; +struct stat stb1, stb2; +struct excludes *excludes_list; +regex_t ignore_re; + +#define OPTIONS "0123456789abC:cdD:efhI:iL:lnNPpqrS:sTtU:uwX:x:" +static struct option longopts[] = { + { "text", no_argument, 0, 'a' }, + { "ignore-space-change", no_argument, 0, 'b' }, + { "context", optional_argument, 0, 'C' }, + { "ifdef", required_argument, 0, 'D' }, + { "minimal", no_argument, 0, 'd' }, + { "ed", no_argument, 0, 'e' }, + { "forward-ed", no_argument, 0, 'f' }, + { "ignore-matching-lines", required_argument, 0, 'I' }, + { "ignore-case", no_argument, 0, 'i' }, + { "label", required_argument, 0, 'L' }, + { "new-file", no_argument, 0, 'N' }, + { "rcs", no_argument, 0, 'n' }, + { "unidirectional-new-file", no_argument, 0, 'P' }, + { "show-c-function", no_argument, 0, 'p' }, + { "brief", no_argument, 0, 'q' }, + { "recursive", no_argument, 0, 'r' }, + { "report-identical-files", no_argument, 0, 's' }, + { "starting-file", required_argument, 0, 'S' }, + { "expand-tabs", no_argument, 0, 't' }, + { "initial-tab", no_argument, 0, 'T' }, + { "unified", optional_argument, 0, 'U' }, + { "ignore-all-space", no_argument, 0, 'w' }, + { "exclude", required_argument, 0, 'x' }, + { "exclude-from", required_argument, 0, 'X' }, + { NULL, 0, 0, '\0'} +}; + +__dead void usage(void); +void push_excludes(char *); +void push_ignore_pats(char *); +void read_excludes_file(char *file); +void set_argstr(char **, char **); + +int +main(int argc, char **argv) +{ + char *ep, **oargv; + long l; + int ch, dflags, lastch, gotstdin, prevoptind, newarg; + + oargv = argv; + gotstdin = 0; + dflags = 0; + lastch = '\0'; + prevoptind = 1; + newarg = 1; + while ((ch = getopt_long(argc, argv, OPTIONS, longopts, NULL)) != -1) { + switch (ch) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if (newarg) + usage(); /* disallow -[0-9]+ */ + else if (lastch == 'c' || lastch == 'u') + diff_context = 0; + else if (!isdigit(lastch) || diff_context > INT_MAX / 10) + usage(); + diff_context = (diff_context * 10) + (ch - '0'); + break; + case 'a': + dflags |= D_FORCEASCII; + break; + case 'b': + dflags |= D_FOLDBLANKS; + break; + case 'C': + case 'c': + diff_format = D_CONTEXT; + if (optarg != NULL) { + l = strtol(optarg, &ep, 10); + if (*ep != '\0' || l < 0 || l >= INT_MAX) + usage(); + diff_context = (int)l; + } else + diff_context = 3; + break; + case 'd': + dflags |= D_MINIMAL; + break; + case 'D': + diff_format = D_IFDEF; + ifdefname = optarg; + break; + case 'e': + diff_format = D_EDIT; + break; + case 'f': + diff_format = D_REVERSE; + break; + case 'h': + /* silently ignore for backwards compatibility */ + break; + case 'I': + push_ignore_pats(optarg); + break; + case 'i': + dflags |= D_IGNORECASE; + break; + case 'L': + if (label[0] == NULL) + label[0] = optarg; + else if (label[1] == NULL) + label[1] = optarg; + else + usage(); + break; + case 'N': + Nflag = 1; + break; + case 'n': + diff_format = D_NREVERSE; + break; + case 'p': + dflags |= D_PROTOTYPE; + break; + case 'P': + Pflag = 1; + break; + case 'r': + rflag = 1; + break; + case 'q': + diff_format = D_BRIEF; + break; + case 'S': + start = optarg; + break; + case 's': + sflag = 1; + break; + case 'T': + Tflag = 1; + break; + case 't': + dflags |= D_EXPANDTABS; + break; + case 'U': + case 'u': + diff_format = D_UNIFIED; + if (optarg != NULL) { + l = strtol(optarg, &ep, 10); + if (*ep != '\0' || l < 0 || l >= INT_MAX) + usage(); + diff_context = (int)l; + } else + diff_context = 3; + break; + case 'w': + dflags |= D_IGNOREBLANKS; + break; + case 'X': + read_excludes_file(optarg); + break; + case 'x': + push_excludes(optarg); + break; + default: + usage(); + break; + } + lastch = ch; + newarg = optind != prevoptind; + prevoptind = optind; + } + argc -= optind; + argv += optind; + + if (pledge("stdio rpath tmppath", NULL) == -1) + err(2, "pledge"); + + /* + * Do sanity checks, fill in stb1 and stb2 and call the appropriate + * driver routine. Both drivers use the contents of stb1 and stb2. + */ + if (argc != 2) + usage(); + if (ignore_pats != NULL) { + char buf[BUFSIZ]; + int error; + + if ((error = regcomp(&ignore_re, ignore_pats, + REG_NEWLINE | REG_EXTENDED)) != 0) { + regerror(error, &ignore_re, buf, sizeof(buf)); + if (*ignore_pats != '\0') + errx(2, "%s: %s", ignore_pats, buf); + else + errx(2, "%s", buf); + } + } + if (strcmp(argv[0], "-") == 0) { + fstat(STDIN_FILENO, &stb1); + gotstdin = 1; + } else if (stat(argv[0], &stb1) != 0) + err(2, "%s", argv[0]); + if (strcmp(argv[1], "-") == 0) { + fstat(STDIN_FILENO, &stb2); + gotstdin = 1; + } else if (stat(argv[1], &stb2) != 0) + err(2, "%s", argv[1]); + if (gotstdin && (S_ISDIR(stb1.st_mode) || S_ISDIR(stb2.st_mode))) + errx(2, "can't compare - to a directory"); + set_argstr(oargv, argv); + if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) { + if (diff_format == D_IFDEF) + errx(2, "-D option not supported with directories"); + diffdir(argv[0], argv[1], dflags); + } else { + if (S_ISDIR(stb1.st_mode)) { + argv[0] = splice(argv[0], argv[1]); + if (stat(argv[0], &stb1) < 0) + err(2, "%s", argv[0]); + } + if (S_ISDIR(stb2.st_mode)) { + argv[1] = splice(argv[1], argv[0]); + if (stat(argv[1], &stb2) < 0) + err(2, "%s", argv[1]); + } + print_status(diffreg(argv[0], argv[1], dflags), argv[0], argv[1], + ""); + } + exit(status); +} + +void +set_argstr(char **av, char **ave) +{ + size_t argsize; + char **ap; + + argsize = 4 + *ave - *av + 1; + diffargs = xmalloc(argsize); + strlcpy(diffargs, "diff", argsize); + for (ap = av + 1; ap < ave; ap++) { + if (strcmp(*ap, "--") != 0) { + strlcat(diffargs, " ", argsize); + strlcat(diffargs, *ap, argsize); + } + } +} + +/* + * Read in an excludes file and push each line. + */ +void +read_excludes_file(char *file) +{ + FILE *fp; + char *buf, *pattern; + size_t len; + + if (strcmp(file, "-") == 0) + fp = stdin; + else if ((fp = fopen(file, "r")) == NULL) + err(2, "%s", file); + while ((buf = fgetln(fp, &len)) != NULL) { + if (buf[len - 1] == '\n') + len--; + pattern = xmalloc(len + 1); + memcpy(pattern, buf, len); + pattern[len] = '\0'; + push_excludes(pattern); + } + if (strcmp(file, "-") != 0) + fclose(fp); +} + +/* + * Push a pattern onto the excludes list. + */ +void +push_excludes(char *pattern) +{ + struct excludes *entry; + + entry = xmalloc(sizeof(*entry)); + entry->pattern = pattern; + entry->next = excludes_list; + excludes_list = entry; +} + +void +push_ignore_pats(char *pattern) +{ + size_t len; + + if (ignore_pats == NULL) + ignore_pats = xstrdup(pattern); + else { + /* old + "|" + new + NUL */ + len = strlen(ignore_pats) + strlen(pattern) + 2; + ignore_pats = xreallocarray(ignore_pats, 1, len); + strlcat(ignore_pats, "|", len); + strlcat(ignore_pats, pattern, len); + } +} + +void +print_only(const char *path, size_t dirlen, const char *entry) +{ + if (dirlen > 1) + dirlen--; + printf("Only in %.*s: %s\n", (int)dirlen, path, entry); +} + +void +print_status(int val, char *path1, char *path2, char *entry) +{ + switch (val) { + case D_BINARY: + printf("Binary files %s%s and %s%s differ\n", + path1, entry, path2, entry); + break; + case D_DIFFER: + if (diff_format == D_BRIEF) + printf("Files %s%s and %s%s differ\n", + path1, entry, path2, entry); + break; + case D_SAME: + if (sflag) + printf("Files %s%s and %s%s are identical\n", + path1, entry, path2, entry); + break; + case D_MISMATCH1: + printf("File %s%s is a directory while file %s%s is a regular file\n", + path1, entry, path2, entry); + break; + case D_MISMATCH2: + printf("File %s%s is a regular file while file %s%s is a directory\n", + path1, entry, path2, entry); + break; + case D_SKIPPED1: + printf("File %s%s is not a regular file or directory and was skipped\n", + path1, entry); + break; + case D_SKIPPED2: + printf("File %s%s is not a regular file or directory and was skipped\n", + path2, entry); + break; + } +} + +__dead void +usage(void) +{ + (void)fprintf(stderr, + "usage: diff [-abdipTtw] [-c | -e | -f | -n | -q | -u] [-I pattern] [-L label]\n" + " file1 file2\n" + " diff [-abdipTtw] [-I pattern] [-L label] -C number file1 file2\n" + " diff [-abditw] [-I pattern] -D string file1 file2\n" + " diff [-abdipTtw] [-I pattern] [-L label] -U number file1 file2\n" + " diff [-abdiNPprsTtw] [-c | -e | -f | -n | -q | -u] [-I pattern]\n" + " [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n"); + + exit(2); +} Added: user/bapt/diff/diff.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/bapt/diff/diff.h Mon Dec 26 09:46:55 2016 (r310577) @@ -0,0 +1,98 @@ + + +/*ROR + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)diff.h 8.1 (Berkeley) 6/6/93 + */ + +#include +#include + +/* + * Output format options + */ +#define D_NORMAL 0 /* Normal output */ +#define D_EDIT -1 /* Editor script out */ +#define D_REVERSE 1 /* Reverse editor script */ +#define D_CONTEXT 2 /* Diff with context */ +#define D_UNIFIED 3 /* Unified context diff */ +#define D_IFDEF 4 /* Diff with merged #ifdef's */ +#define D_NREVERSE 5 /* Reverse ed script with numbered + lines and no trailing . */ +#define D_BRIEF 6 /* Say if the files differ */ + +/* + * Output flags + */ +#define D_HEADER 0x001 /* Print a header/footer between files */ +#define D_EMPTY1 0x002 /* Treat first file as empty (/dev/null) */ +#define D_EMPTY2 0x004 /* Treat second file as empty (/dev/null) */ + +/* + * Command line flags + */ +#define D_FORCEASCII 0x008 /* Treat file as ascii regardless of content */ +#define D_FOLDBLANKS 0x010 /* Treat all white space as equal */ +#define D_MINIMAL 0x020 /* Make diff as small as possible */ +#define D_IGNORECASE 0x040 /* Case-insensitive matching */ +#define D_PROTOTYPE 0x080 /* Display C function prototype */ +#define D_EXPANDTABS 0x100 /* Expand tabs to spaces */ +#define D_IGNOREBLANKS 0x200 /* Ignore white space changes */ + +/* + * Status values for print_status() and diffreg() return values + */ +#define D_SAME 0 /* Files are the same */ +#define D_DIFFER 1 /* Files are different */ +#define D_BINARY 2 /* Binary files are different */ +#define D_MISMATCH1 3 /* path1 was a dir, path2 a file */ +#define D_MISMATCH2 4 /* path1 was a file, path2 a dir */ +#define D_SKIPPED1 5 /* path1 was a special file */ +#define D_SKIPPED2 6 /* path2 was a special file */ + +struct excludes { + char *pattern; + struct excludes *next; +}; + +extern int Nflag, Pflag, rflag, sflag, Tflag; +extern int diff_format, diff_context, status; +extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; +extern struct stat stb1, stb2; +extern struct excludes *excludes_list; +extern regex_t ignore_re; + +char *splice(char *, char *); +int diffreg(char *, char *, int); +int easprintf(char **, const char *, ...); +void *emalloc(size_t); +void *erealloc(void *, size_t); +void diffdir(char *, char *, int); +void print_only(const char *, size_t, const char *); +void print_status(int, char *, char *, char *); Added: user/bapt/diff/diffdir.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/bapt/diff/diffdir.c Mon Dec 26 09:46:55 2016 (r310577) @@ -0,0 +1,233 @@ +/* $OpenBSD: diffdir.c,v 1.45 2015/10/05 20:15:00 millert Exp $ */ + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@freebsd.org Mon Dec 26 09:54:39 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 535D9C8FCDE for ; Mon, 26 Dec 2016 09:54:39 +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 142BA17F6; Mon, 26 Dec 2016 09:54:39 +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 uBQ9scZI027235; Mon, 26 Dec 2016 09:54:38 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQ9sb2I027228; Mon, 26 Dec 2016 09:54:37 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612260954.uBQ9sb2I027228@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 09:54:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310579 - 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 09:54:39 -0000 Author: bapt Date: Mon Dec 26 09:54:37 2016 New Revision: 310579 URL: https://svnweb.freebsd.org/changeset/base/310579 Log: FreeBSDify ($FreeBSD) + fixes to build with base maximum set of warnings Modified: user/bapt/diff/Makefile user/bapt/diff/diff.c user/bapt/diff/diff.h user/bapt/diff/diffdir.c user/bapt/diff/diffreg.c user/bapt/diff/xmalloc.c user/bapt/diff/xmalloc.h Modified: user/bapt/diff/Makefile ============================================================================== --- user/bapt/diff/Makefile Mon Dec 26 09:52:19 2016 (r310578) +++ user/bapt/diff/Makefile Mon Dec 26 09:54:37 2016 (r310579) @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.3 2007/05/29 18:24:56 ray Exp $ +# $FreEBSD$ PROG= diff SRCS= diff.c diffdir.c diffreg.c xmalloc.c -COPTS+= -Wall +WARNS= 7 .include Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Mon Dec 26 09:52:19 2016 (r310578) +++ user/bapt/diff/diff.c Mon Dec 26 09:54:37 2016 (r310579) @@ -20,6 +20,9 @@ * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ +#include +__FBSDID("$FreeBSD$"); + #include #include @@ -72,7 +75,7 @@ static struct option longopts[] = { { NULL, 0, 0, '\0'} }; -__dead void usage(void); +void usage(void) __dead2; void push_excludes(char *); void push_ignore_pats(char *); void read_excludes_file(char *file); @@ -211,8 +214,10 @@ main(int argc, char **argv) argc -= optind; argv += optind; +#ifdef __OpenBSD__ if (pledge("stdio rpath tmppath", NULL) == -1) err(2, "pledge"); +#endif /* * Do sanity checks, fill in stb1 and stb2 and call the appropriate @@ -349,7 +354,7 @@ print_only(const char *path, size_t dirl } void -print_status(int val, char *path1, char *path2, char *entry) +print_status(int val, char *path1, char *path2, const char *entry) { switch (val) { case D_BINARY: @@ -385,7 +390,7 @@ print_status(int val, char *path1, char } } -__dead void +void usage(void) { (void)fprintf(stderr, Modified: user/bapt/diff/diff.h ============================================================================== --- user/bapt/diff/diff.h Mon Dec 26 09:52:19 2016 (r310578) +++ user/bapt/diff/diff.h Mon Dec 26 09:54:37 2016 (r310579) @@ -29,6 +29,7 @@ * SUCH DAMAGE. * * @(#)diff.h 8.1 (Berkeley) 6/6/93 + * $FreeBSD$ */ #include @@ -95,4 +96,4 @@ void *emalloc(size_t); void *erealloc(void *, size_t); void diffdir(char *, char *, int); void print_only(const char *, size_t, const char *); -void print_status(int, char *, char *, char *); +void print_status(int, char *, char *, const char *); Modified: user/bapt/diff/diffdir.c ============================================================================== --- user/bapt/diff/diffdir.c Mon Dec 26 09:52:19 2016 (r310578) +++ user/bapt/diff/diffdir.c Mon Dec 26 09:54:37 2016 (r310579) @@ -20,6 +20,9 @@ * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ +#include +__FBSDID("$FreeBSD$"); + #include #include Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Mon Dec 26 09:52:19 2016 (r310578) +++ user/bapt/diff/diffreg.c Mon Dec 26 09:54:37 2016 (r310579) @@ -64,6 +64,9 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ +#include +__FBSDID("$FreeBSD$"); + #include #include @@ -159,7 +162,7 @@ struct cand { int pred; }; -struct line { +static struct line { int serial; int value; } *file[2]; @@ -180,7 +183,7 @@ struct context_vec { static FILE *opentemp(const char *); static void output(char *, FILE *, char *, FILE *, int); static void check(FILE *, FILE *, int); -static void range(int, int, char *); +static void range(int, int, const char *); static void uni_range(int, int); static void dump_context_vec(FILE *, FILE *, int); static void dump_unified_vec(FILE *, FILE *, int); @@ -235,7 +238,7 @@ static int lastmatchline; * chrtran points to one of 2 translation tables: cup2low if folding upper to * lower case clow2low if not folding case */ -u_char clow2low[256] = { +static u_char clow2low[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, @@ -262,7 +265,7 @@ u_char clow2low[256] = { 0xfd, 0xfe, 0xff }; -u_char cup2low[256] = { +static u_char cup2low[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, @@ -444,15 +447,15 @@ files_differ(FILE *f1, FILE *f2, int fla } static FILE * -opentemp(const char *file) +opentemp(const char *path) { char buf[BUFSIZ], tempfile[PATH_MAX]; ssize_t nread; int ifd, ofd; - if (strcmp(file, "-") == 0) + if (strcmp(path, "-") == 0) ifd = STDIN_FILENO; - else if ((ifd = open(file, O_RDONLY, 0644)) < 0) + else if ((ifd = open(path, O_RDONLY, 0644)) < 0) return (NULL); (void)strlcpy(tempfile, _PATH_TMP "/diff.XXXXXXXX", sizeof(tempfile)); @@ -475,7 +478,7 @@ opentemp(const char *file) } char * -splice(char *dir, char *file) +splice(char *dir, char *path) { char *tail, *buf; size_t dirlen; @@ -483,8 +486,8 @@ splice(char *dir, char *file) dirlen = strlen(dir); while (dirlen != 0 && dir[dirlen - 1] == '/') dirlen--; - if ((tail = strrchr(file, '/')) == NULL) - tail = file; + if ((tail = strrchr(path, '/')) == NULL) + tail = path; else tail++; xasprintf(&buf, "%.*s/%s", (int)dirlen, dir, tail); @@ -495,12 +498,12 @@ static void prepare(int i, FILE *fd, off_t filesize, int flags) { struct line *p; - int j, h; - size_t sz; + int h; + size_t sz, j; rewind(fd); - sz = (filesize <= SIZE_MAX ? filesize : SIZE_MAX) / 25; + sz = ((unsigned long)filesize <= SIZE_MAX ? filesize : SIZE_MAX) / 25; if (sz < 100) sz = 100; @@ -905,7 +908,7 @@ output(char *file1, FILE *f1, char *file } static void -range(int a, int b, char *separator) +range(int a, int b, const char *separator) { diff_output("%d", a > b ? b : a); if (a < b) @@ -1253,7 +1256,7 @@ match_function(const long *f, int pos, F unsigned char buf[FUNCTION_CONTEXT_SIZE]; size_t nc; int last = lastline; - char *state = NULL; + const char *state = NULL; lastline = pos; while (pos > last) { Modified: user/bapt/diff/xmalloc.c ============================================================================== --- user/bapt/diff/xmalloc.c Mon Dec 26 09:52:19 2016 (r310578) +++ user/bapt/diff/xmalloc.c Mon Dec 26 09:54:37 2016 (r310579) @@ -13,6 +13,9 @@ * called by a name other than "ssh" or "Secure Shell". */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include Modified: user/bapt/diff/xmalloc.h ============================================================================== --- user/bapt/diff/xmalloc.h Mon Dec 26 09:52:19 2016 (r310578) +++ user/bapt/diff/xmalloc.h Mon Dec 26 09:54:37 2016 (r310579) @@ -14,6 +14,8 @@ * software must be clearly marked as such, and if the derived work is * incompatible with the protocol description in the RFC file, it must be * called by a name other than "ssh" or "Secure Shell". + * + * $FreeBSD$ */ #ifndef XMALLOC_H 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; From owner-svn-src-user@freebsd.org Mon Dec 26 11:42:34 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 B9ED9C91867 for ; Mon, 26 Dec 2016 11:42:34 +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 94C4A1C89; Mon, 26 Dec 2016 11:42:34 +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 uBQBgXTb072454; Mon, 26 Dec 2016 11:42:33 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQBgXOM072449; Mon, 26 Dec 2016 11:42:33 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612261142.uBQBgXOM072449@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 11:42:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310594 - 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 11:42:34 -0000 Author: bapt Date: Mon Dec 26 11:42:33 2016 New Revision: 310594 URL: https://svnweb.freebsd.org/changeset/base/310594 Log: Implement diff -l for compatibility with GNU diff Obtained from: soc2012 Modified: user/bapt/diff/Makefile user/bapt/diff/diff.c user/bapt/diff/diff.h user/bapt/diff/diffreg.c Modified: user/bapt/diff/Makefile ============================================================================== --- user/bapt/diff/Makefile Mon Dec 26 11:20:40 2016 (r310593) +++ user/bapt/diff/Makefile Mon Dec 26 11:42:33 2016 (r310594) @@ -3,5 +3,6 @@ PROG= diff SRCS= diff.c diffdir.c diffreg.c xmalloc.c WARNS= 7 +CFLAGS+= -Wno-incompatible-pointer-types-discards-qualifiers .include Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Mon Dec 26 11:20:40 2016 (r310593) +++ user/bapt/diff/diff.c Mon Dec 26 11:42:33 2016 (r310594) @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); #include "diff.h" #include "xmalloc.h" -int Nflag, Pflag, rflag, sflag, Tflag; +int lflag, Nflag, Pflag, rflag, sflag, Tflag; int diff_format, diff_context, status; char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; struct stat stb1, stb2; @@ -57,6 +57,7 @@ static struct option longopts[] = { { "forward-ed", no_argument, 0, 'f' }, { "ignore-matching-lines", required_argument, 0, 'I' }, { "ignore-case", no_argument, 0, 'i' }, + { "paginate", no_argument, NULL, 'l' }, { "label", required_argument, 0, 'L' }, { "new-file", no_argument, 0, 'N' }, { "rcs", no_argument, 0, 'n' }, @@ -154,6 +155,9 @@ main(int argc, char **argv) else usage(); break; + case 'l': + lflag = 1; + break; case 'N': Nflag = 1; break; Modified: user/bapt/diff/diff.h ============================================================================== --- user/bapt/diff/diff.h Mon Dec 26 11:20:40 2016 (r310593) +++ user/bapt/diff/diff.h Mon Dec 26 11:42:33 2016 (r310594) @@ -82,7 +82,7 @@ struct excludes { struct excludes *next; }; -extern int Nflag, Pflag, rflag, sflag, Tflag; +extern int lflag, Nflag, Pflag, rflag, sflag, Tflag; extern int diff_format, diff_context, status; extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; extern struct stat stb1, stb2; Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Mon Dec 26 11:20:40 2016 (r310593) +++ user/bapt/diff/diffreg.c Mon Dec 26 11:42:33 2016 (r310594) @@ -86,6 +86,8 @@ __FBSDID("$FreeBSD$"); #include "diff.h" #include "xmalloc.h" +#define _PATH_PR "/usr/bin/pr" + #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) #define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) @@ -297,6 +299,8 @@ diffreg(char *file1, char *file2, int fl { FILE *f1, *f2; int i, rval; + int ostdout = -1; + pid_t pid = -1; f1 = f2 = NULL; rval = D_SAME; @@ -372,6 +376,43 @@ diffreg(char *file1, char *file2, int fl status |= 1; goto closem; } + if (lflag) { + /* redirect stdout to pr */ + int pfd[2]; + char *header; + char * prargv[] = { "pr", "-h", NULL, "-f", NULL }; + + xasprintf(&header, "%s %s %s", diffargs, file1, file2); + prargv[2] = header; + fflush(stdout); + rewind(stdout); + pipe(pfd); + switch ((pid = fork())) { + case -1: + status |= 2; + free(header); + err(2, "No more processes"); + case 0: + /* child */ + if (pfd[0] != STDIN_FILENO) { + dup2(pfd[0], STDIN_FILENO); + close(pfd[0]); + } + close(pfd[1]); + execv(_PATH_PR, (char *const *)prargv); + _exit(127); + default: + /* parent */ + if (pfd[1] != STDOUT_FILENO) { + ostdout = dup(STDOUT_FILENO); + dup2(pfd[1], STDOUT_FILENO); + close(pfd[1]); + } + close(pfd[0]); + rewind(stdout); + free(header); + } + } prepare(0, f1, stb1.st_size, flags); prepare(1, f2, stb2.st_size, flags); @@ -404,6 +445,20 @@ diffreg(char *file1, char *file2, int fl ixnew = xreallocarray(ixnew, len[1] + 2, sizeof(*ixnew)); check(f1, f2, flags); output(file1, f1, file2, f2, flags); + if (ostdout != -1) { + int wstatus; + + /* close the pipe to pr and restore stdout */ + fflush(stdout); + rewind(stdout); + if (ostdout != STDOUT_FILENO) { + close(STDOUT_FILENO); + dup2(ostdout, STDOUT_FILENO); + close(ostdout); + } + waitpid(pid, &wstatus, 0); + } + closem: if (anychange) { status |= 1; From owner-svn-src-user@freebsd.org Mon Dec 26 11:46:06 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 E731BC918DF for ; Mon, 26 Dec 2016 11:46:06 +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 B75231DF4; Mon, 26 Dec 2016 11:46:06 +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 uBQBk5iZ072634; Mon, 26 Dec 2016 11:46:05 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQBk5Cq072633; Mon, 26 Dec 2016 11:46:05 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612261146.uBQBk5Cq072633@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 11:46:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310595 - 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 11:46:07 -0000 Author: bapt Date: Mon Dec 26 11:46:05 2016 New Revision: 310595 URL: https://svnweb.freebsd.org/changeset/base/310595 Log: Forgot to ignore SIGPIPE Modified: user/bapt/diff/diffreg.c Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Mon Dec 26 11:42:33 2016 (r310594) +++ user/bapt/diff/diffreg.c Mon Dec 26 11:46:05 2016 (r310595) @@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "diff.h" #include "xmalloc.h" @@ -384,6 +385,7 @@ diffreg(char *file1, char *file2, int fl xasprintf(&header, "%s %s %s", diffargs, file1, file2); prargv[2] = header; + signal(SIGPIPE, SIG_IGN); fflush(stdout); rewind(stdout); pipe(pfd); From owner-svn-src-user@freebsd.org Mon Dec 26 12:39:26 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 43F0EC64911 for ; Mon, 26 Dec 2016 12:39:26 +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 1417613E2; Mon, 26 Dec 2016 12:39:26 +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 uBQCdPh0094275; Mon, 26 Dec 2016 12:39:25 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQCdPZ3094274; Mon, 26 Dec 2016 12:39:25 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612261239.uBQCdPZ3094274@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 12:39:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310596 - 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 12:39:26 -0000 Author: bapt Date: Mon Dec 26 12:39:25 2016 New Revision: 310596 URL: https://svnweb.freebsd.org/changeset/base/310596 Log: Do not pause in pr(1) to have the same behaviour as GNU diff Use execl instead of execv to avoid warnings Modified: user/bapt/diff/diffreg.c Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Mon Dec 26 11:46:05 2016 (r310595) +++ user/bapt/diff/diffreg.c Mon Dec 26 12:39:25 2016 (r310596) @@ -381,10 +381,8 @@ diffreg(char *file1, char *file2, int fl /* redirect stdout to pr */ int pfd[2]; char *header; - char * prargv[] = { "pr", "-h", NULL, "-f", NULL }; xasprintf(&header, "%s %s %s", diffargs, file1, file2); - prargv[2] = header; signal(SIGPIPE, SIG_IGN); fflush(stdout); rewind(stdout); @@ -401,7 +399,7 @@ diffreg(char *file1, char *file2, int fl close(pfd[0]); } close(pfd[1]); - execv(_PATH_PR, (char *const *)prargv); + execl(_PATH_PR, _PATH_PR, "-h", header, (char *)0); _exit(127); default: /* parent */ From owner-svn-src-user@freebsd.org Mon Dec 26 12:40:11 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 7936BC64948 for ; Mon, 26 Dec 2016 12:40:11 +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 49243156E; Mon, 26 Dec 2016 12:40:11 +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 uBQCeAJL094365; Mon, 26 Dec 2016 12:40:10 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQCeAmP094364; Mon, 26 Dec 2016 12:40:10 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612261240.uBQCeAmP094364@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 12:40:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310597 - 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 12:40:11 -0000 Author: bapt Date: Mon Dec 26 12:40:10 2016 New Revision: 310597 URL: https://svnweb.freebsd.org/changeset/base/310597 Log: Document diff -l Modified: user/bapt/diff/diff.1 Modified: user/bapt/diff/diff.1 ============================================================================== --- user/bapt/diff/diff.1 Mon Dec 26 12:39:25 2016 (r310596) +++ user/bapt/diff/diff.1 Mon Dec 26 12:40:10 2016 (r310597) @@ -219,6 +219,10 @@ E.g., .Dq A will compare equal to .Dq a . +.It Fl l +Pass the output through +.Xr pr 1 +to paginate it. .It Fl L Ar label Print .Ar label From owner-svn-src-user@freebsd.org Mon Dec 26 12:41:39 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 A3CDBC64B64 for ; Mon, 26 Dec 2016 12:41:39 +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 7405A1777; Mon, 26 Dec 2016 12:41:39 +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 uBQCfcf6097399; Mon, 26 Dec 2016 12:41:38 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQCfcqs097398; Mon, 26 Dec 2016 12:41:38 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612261241.uBQCfcqs097398@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 12:41:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310598 - 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 12:41:39 -0000 Author: bapt Date: Mon Dec 26 12:41:38 2016 New Revision: 310598 URL: https://svnweb.freebsd.org/changeset/base/310598 Log: Remove now useless warning skipping Set a default BINDIR Modified: user/bapt/diff/Makefile Modified: user/bapt/diff/Makefile ============================================================================== --- user/bapt/diff/Makefile Mon Dec 26 12:40:10 2016 (r310597) +++ user/bapt/diff/Makefile Mon Dec 26 12:41:38 2016 (r310598) @@ -1,8 +1,8 @@ # $FreEBSD$ +BINDIR?= /usr/bin PROG= diff SRCS= diff.c diffdir.c diffreg.c xmalloc.c WARNS= 7 -CFLAGS+= -Wno-incompatible-pointer-types-discards-qualifiers .include From owner-svn-src-user@freebsd.org Mon Dec 26 15:23:23 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 B5DACC911AF for ; Mon, 26 Dec 2016 15:23:23 +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 9094F12B1; Mon, 26 Dec 2016 15:23:23 +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 uBQFNMlw066501; Mon, 26 Dec 2016 15:23:22 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQFNMH6066497; Mon, 26 Dec 2016 15:23:22 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612261523.uBQFNMH6066497@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 15:23:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310602 - 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 15:23:23 -0000 Author: bapt Date: Mon Dec 26 15:23:22 2016 New Revision: 310602 URL: https://svnweb.freebsd.org/changeset/base/310602 Log: Implement diff --tabsize Obtained from: soc2012 Modified: user/bapt/diff/Makefile user/bapt/diff/diff.c user/bapt/diff/diff.h user/bapt/diff/diffreg.c Modified: user/bapt/diff/Makefile ============================================================================== --- user/bapt/diff/Makefile Mon Dec 26 14:39:05 2016 (r310601) +++ user/bapt/diff/Makefile Mon Dec 26 15:23:22 2016 (r310602) @@ -1,7 +1,7 @@ # $FreEBSD$ BINDIR?= /usr/bin -PROG= diff +PROG= bdiff SRCS= diff.c diffdir.c diffreg.c xmalloc.c WARNS= 7 Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Mon Dec 26 14:39:05 2016 (r310601) +++ user/bapt/diff/diff.c Mon Dec 26 15:23:22 2016 (r310602) @@ -41,15 +41,21 @@ __FBSDID("$FreeBSD$"); int lflag, Nflag, Pflag, rflag, sflag, Tflag; int diff_format, diff_context, status; +int tabsize = 8; char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; struct stat stb1, stb2; struct excludes *excludes_list; regex_t ignore_re; -#define OPTIONS "0123456789abC:cdD:efhI:iL:lnNPpqrS:sTtU:uwX:x:" +#define OPTIONS "0123456789aBbC:cdD:efhI:iL:lnNPpqrS:sTtU:uwX:x:" +enum { + OPT_TSIZE = CHAR_MAX + 1, +}; + static struct option longopts[] = { { "text", no_argument, 0, 'a' }, { "ignore-space-change", no_argument, 0, 'b' }, + { "ignore-blank-lines", no_argument, NULL, 'B' }, { "context", optional_argument, 0, 'C' }, { "ifdef", required_argument, 0, 'D' }, { "minimal", no_argument, 0, 'd' }, @@ -73,6 +79,7 @@ static struct option longopts[] = { { "ignore-all-space", no_argument, 0, 'w' }, { "exclude", required_argument, 0, 'x' }, { "exclude-from", required_argument, 0, 'X' }, + { "tabsize", optional_argument, NULL, OPT_TSIZE }, { NULL, 0, 0, '\0'} }; @@ -85,6 +92,7 @@ void set_argstr(char **, char **); int main(int argc, char **argv) { + const char *errstr = NULL; char *ep, **oargv; long l; int ch, dflags, lastch, gotstdin, prevoptind, newarg; @@ -115,6 +123,9 @@ main(int argc, char **argv) case 'b': dflags |= D_FOLDBLANKS; break; + case 'B': + dflags |= D_IGNOREBLANKLINES; + break; case 'C': case 'c': diff_format = D_CONTEXT; @@ -209,6 +220,13 @@ main(int argc, char **argv) case 'x': push_excludes(optarg); break; + case OPT_TSIZE: + tabsize = (int) strtonum(optarg, 1, INT_MAX, &errstr); + if (errstr) { + warnx("Invalid argument for tabsize"); + usage(); + } + break; default: usage(); break; @@ -400,12 +418,12 @@ void usage(void) { (void)fprintf(stderr, - "usage: diff [-abdipTtw] [-c | -e | -f | -n | -q | -u] [-I pattern] [-L label]\n" + "usage: diff [-aBbdipTtw] [-c | -e | -f | -n | -q | -u] [-I pattern] [-L label]\n" " file1 file2\n" - " diff [-abdipTtw] [-I pattern] [-L label] -C number file1 file2\n" - " diff [-abditw] [-I pattern] -D string file1 file2\n" - " diff [-abdipTtw] [-I pattern] [-L label] -U number file1 file2\n" - " diff [-abdiNPprsTtw] [-c | -e | -f | -n | -q | -u] [-I pattern]\n" + " diff [-aBbdipTtw] [-I pattern] [-L label] -C number file1 file2\n" + " diff [-aBbditw] [-I pattern] -D string file1 file2\n" + " diff [-aBbdipTtw] [-I pattern] [-L label] -U number file1 file2\n" + " diff [-aBbdiNPprsTtw] [-c | -e | -f | -n | -q | -u] [-I pattern]\n" " [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n"); exit(2); Modified: user/bapt/diff/diff.h ============================================================================== --- user/bapt/diff/diff.h Mon Dec 26 14:39:05 2016 (r310601) +++ user/bapt/diff/diff.h Mon Dec 26 15:23:22 2016 (r310602) @@ -58,13 +58,14 @@ /* * Command line flags */ -#define D_FORCEASCII 0x008 /* Treat file as ascii regardless of content */ -#define D_FOLDBLANKS 0x010 /* Treat all white space as equal */ -#define D_MINIMAL 0x020 /* Make diff as small as possible */ -#define D_IGNORECASE 0x040 /* Case-insensitive matching */ -#define D_PROTOTYPE 0x080 /* Display C function prototype */ -#define D_EXPANDTABS 0x100 /* Expand tabs to spaces */ -#define D_IGNOREBLANKS 0x200 /* Ignore white space changes */ +#define D_FORCEASCII 0x008 /* Treat file as ascii regardless of content */ +#define D_FOLDBLANKS 0x010 /* Treat all white space as equal */ +#define D_MINIMAL 0x020 /* Make diff as small as possible */ +#define D_IGNORECASE 0x040 /* Case-insensitive matching */ +#define D_PROTOTYPE 0x080 /* Display C function prototype */ +#define D_EXPANDTABS 0x100 /* Expand tabs to spaces */ +#define D_IGNOREBLANKS 0x200 /* Ignore white space changes */ +#define D_IGNOREBLANKLINES 0x400 /* Ignore blank lines changes */ /* * Status values for print_status() and diffreg() return values @@ -84,6 +85,7 @@ struct excludes { extern int lflag, Nflag, Pflag, rflag, sflag, Tflag; extern int diff_format, diff_context, status; +extern int tabsize; extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; extern struct stat stb1, stb2; extern struct excludes *excludes_list; Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Mon Dec 26 14:39:05 2016 (r310601) +++ user/bapt/diff/diffreg.c Mon Dec 26 15:23:22 2016 (r310602) @@ -770,7 +770,7 @@ check(FILE *f1, FILE *f2, int flags) ixnew[j] = ctnew += skipline(f2); j++; } - if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE)) { + if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE|D_IGNOREBLANKLINES)) { for (;;) { c = getc(f1); d = getc(f2); @@ -778,7 +778,7 @@ check(FILE *f1, FILE *f2, int flags) * GNU diff ignores a missing newline * in one file for -b or -w. */ - if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS)) { + if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNOREBLANKLINES)) { if (c == EOF && d == '\n') { ctnew++; break; @@ -810,6 +810,15 @@ check(FILE *f1, FILE *f2, int flags) d = getc(f2); ctnew++; } + } else if (flags & D_IGNOREBLANKLINES) { + while (isspace(c) && c == '\n') { + c = getc(f1); + ctold++; + } + while (isspace(d) && d == '\n') { + d = getc(f2); + ctnew++; + } } if (chrtran[c] != chrtran[d]) { jackpot++; @@ -1151,6 +1160,7 @@ static int fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags) { int i, j, c, lastc, col, nc; + int newcol; /* * When doing #ifdef's, copy down to current line @@ -1200,9 +1210,10 @@ fetch(long *f, int a, int b, FILE *lb, i return (0); } if (c == '\t' && (flags & D_EXPANDTABS)) { + newcol = ((col/tabsize)+1)*tabsize; do { diff_output(" "); - } while (++col & 7); + } while (++col < newcol); } else { if (diff_format == D_EDIT && j == 1 && c == '\n' && lastc == '.') { From owner-svn-src-user@freebsd.org Mon Dec 26 15:24:13 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 B0D13C9120A for ; Mon, 26 Dec 2016 15:24:13 +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 80E6F143B; Mon, 26 Dec 2016 15:24:13 +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 uBQFOCm6066573; Mon, 26 Dec 2016 15:24:12 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQFOCoU066572; Mon, 26 Dec 2016 15:24:12 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612261524.uBQFOCoU066572@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 15:24:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310603 - 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 15:24:13 -0000 Author: bapt Date: Mon Dec 26 15:24:12 2016 New Revision: 310603 URL: https://svnweb.freebsd.org/changeset/base/310603 Log: Document diff -l in usage() Modified: user/bapt/diff/diff.c Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Mon Dec 26 15:23:22 2016 (r310602) +++ user/bapt/diff/diff.c Mon Dec 26 15:24:12 2016 (r310603) @@ -418,12 +418,12 @@ void usage(void) { (void)fprintf(stderr, - "usage: diff [-aBbdipTtw] [-c | -e | -f | -n | -q | -u] [-I pattern] [-L label]\n" + "usage: diff [-aBbdilpTtw] [-c | -e | -f | -n | -q | -u] [-I pattern] [-L label]\n" " file1 file2\n" - " diff [-aBbdipTtw] [-I pattern] [-L label] -C number file1 file2\n" - " diff [-aBbditw] [-I pattern] -D string file1 file2\n" - " diff [-aBbdipTtw] [-I pattern] [-L label] -U number file1 file2\n" - " diff [-aBbdiNPprsTtw] [-c | -e | -f | -n | -q | -u] [-I pattern]\n" + " diff [-aBbdilpTtw] [-I pattern] [-L label] -C number file1 file2\n" + " diff [-aBbdiltw] [-I pattern] -D string file1 file2\n" + " diff [-aBbdilpTtw] [-I pattern] [-L label] -U number file1 file2\n" + " diff [-aBbdilNPprsTtw] [-c | -e | -f | -n | -q | -u] [-I pattern]\n" " [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n"); exit(2); From owner-svn-src-user@freebsd.org Tue Dec 27 21:16:09 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 D4CE0C9366F for ; Tue, 27 Dec 2016 21:16:09 +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 95C1A177F; Tue, 27 Dec 2016 21:16:09 +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 uBRLG8HC001475; Tue, 27 Dec 2016 21:16:08 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBRLG81i001472; Tue, 27 Dec 2016 21:16:08 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612272116.uBRLG81i001472@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Tue, 27 Dec 2016 21:16:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310641 - 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: Tue, 27 Dec 2016 21:16:09 -0000 Author: bapt Date: Tue Dec 27 21:16:08 2016 New Revision: 310641 URL: https://svnweb.freebsd.org/changeset/base/310641 Log: Backout diff -B implementation for SoC is too broken Modified: user/bapt/diff/diff.c user/bapt/diff/diff.h user/bapt/diff/diffreg.c Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Tue Dec 27 21:11:54 2016 (r310640) +++ user/bapt/diff/diff.c Tue Dec 27 21:16:08 2016 (r310641) @@ -55,7 +55,6 @@ enum { static struct option longopts[] = { { "text", no_argument, 0, 'a' }, { "ignore-space-change", no_argument, 0, 'b' }, - { "ignore-blank-lines", no_argument, NULL, 'B' }, { "context", optional_argument, 0, 'C' }, { "ifdef", required_argument, 0, 'D' }, { "minimal", no_argument, 0, 'd' }, @@ -123,9 +122,6 @@ main(int argc, char **argv) case 'b': dflags |= D_FOLDBLANKS; break; - case 'B': - dflags |= D_IGNOREBLANKLINES; - break; case 'C': case 'c': diff_format = D_CONTEXT; Modified: user/bapt/diff/diff.h ============================================================================== --- user/bapt/diff/diff.h Tue Dec 27 21:11:54 2016 (r310640) +++ user/bapt/diff/diff.h Tue Dec 27 21:16:08 2016 (r310641) @@ -65,7 +65,6 @@ #define D_PROTOTYPE 0x080 /* Display C function prototype */ #define D_EXPANDTABS 0x100 /* Expand tabs to spaces */ #define D_IGNOREBLANKS 0x200 /* Ignore white space changes */ -#define D_IGNOREBLANKLINES 0x400 /* Ignore blank lines changes */ /* * Status values for print_status() and diffreg() return values Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Tue Dec 27 21:11:54 2016 (r310640) +++ user/bapt/diff/diffreg.c Tue Dec 27 21:16:08 2016 (r310641) @@ -770,7 +770,7 @@ check(FILE *f1, FILE *f2, int flags) ixnew[j] = ctnew += skipline(f2); j++; } - if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE|D_IGNOREBLANKLINES)) { + if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE)) { for (;;) { c = getc(f1); d = getc(f2); @@ -778,7 +778,7 @@ check(FILE *f1, FILE *f2, int flags) * GNU diff ignores a missing newline * in one file for -b or -w. */ - if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNOREBLANKLINES)) { + if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS)) { if (c == EOF && d == '\n') { ctnew++; break; @@ -810,15 +810,6 @@ check(FILE *f1, FILE *f2, int flags) d = getc(f2); ctnew++; } - } else if (flags & D_IGNOREBLANKLINES) { - while (isspace(c) && c == '\n') { - c = getc(f1); - ctold++; - } - while (isspace(d) && d == '\n') { - d = getc(f2); - ctnew++; - } } if (chrtran[c] != chrtran[d]) { jackpot++; From owner-svn-src-user@freebsd.org Fri Dec 30 23:14:19 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 9AB63C98A11 for ; Fri, 30 Dec 2016 23:14:19 +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 754F71DBA; Fri, 30 Dec 2016 23:14:19 +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 uBUNEI4Z051613; Fri, 30 Dec 2016 23:14:18 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBUNEId6051609; Fri, 30 Dec 2016 23:14:18 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612302314.uBUNEId6051609@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Fri, 30 Dec 2016 23:14:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310871 - 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: Fri, 30 Dec 2016 23:14:19 -0000 Author: bapt Date: Fri Dec 30 23:14:18 2016 New Revision: 310871 URL: https://svnweb.freebsd.org/changeset/base/310871 Log: Make diff -u header printing similar to GNU diff -u Obtained from: soc2012 Modified: user/bapt/diff/diff.c user/bapt/diff/diff.h user/bapt/diff/diffreg.c Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Fri Dec 30 23:05:06 2016 (r310870) +++ user/bapt/diff/diff.c Fri Dec 30 23:14:18 2016 (r310871) @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); #include "diff.h" #include "xmalloc.h" -int lflag, Nflag, Pflag, rflag, sflag, Tflag; +int lflag, Nflag, Pflag, rflag, sflag, Tflag, cflag; int diff_format, diff_context, status; int tabsize = 8; char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; @@ -124,6 +124,7 @@ main(int argc, char **argv) break; case 'C': case 'c': + cflag = 1; diff_format = D_CONTEXT; if (optarg != NULL) { l = strtol(optarg, &ep, 10); Modified: user/bapt/diff/diff.h ============================================================================== --- user/bapt/diff/diff.h Fri Dec 30 23:05:06 2016 (r310870) +++ user/bapt/diff/diff.h Fri Dec 30 23:14:18 2016 (r310871) @@ -82,7 +82,7 @@ struct excludes { struct excludes *next; }; -extern int lflag, Nflag, Pflag, rflag, sflag, Tflag; +extern int lflag, Nflag, Pflag, rflag, sflag, Tflag, cflag; extern int diff_format, diff_context, status; extern int tabsize; extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Fri Dec 30 23:05:06 2016 (r310870) +++ user/bapt/diff/diffreg.c Fri Dec 30 23:14:18 2016 (r310871) @@ -89,6 +89,12 @@ __FBSDID("$FreeBSD$"); #define _PATH_PR "/usr/bin/pr" +#ifdef ST_MTIM_NSEC +# define TIMESPEC_NS(timespec) ((timespec).ST_MTIM_NSEC) +#else +# define TIMESPEC_NS(timespec) 0 +#endif + #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) #define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) @@ -1529,16 +1535,43 @@ dump_unified_vec(FILE *f1, FILE *f2, int static void print_header(const char *file1, const char *file2) { + const char *time_format; + char buf1[256]; + char buf2[256]; + char end1[10]; + char end2[10]; + struct tm *tm_ptr1, *tm_ptr2; + int nsec1 = TIMESPEC_NS (stb1.st_mtime); + int nsec2 = TIMESPEC_NS (stb2.st_mtime); + +#ifdef ST_MTIM_NSEC + time_format = "%Y-%m-%d %H:%M:%S.%N"; +#else + time_format = "%Y-%m-%d %H:%M:%S"; +#endif + + if (cflag) + time_format = "%c"; + tm_ptr1 = localtime(&stb1.st_mtime); + tm_ptr2 = localtime(&stb2.st_mtime); + strftime(buf1, 256, time_format, tm_ptr1); + strftime(buf2, 256, time_format, tm_ptr2); + if (!cflag) { + strftime(end1, 10, "%z", tm_ptr1); + strftime(end2, 10, "%z", tm_ptr2); + sprintf(buf1, "%s.%.9d %s", buf1, nsec1, end1); + sprintf(buf2, "%s.%.9d %s", buf2, nsec2, end2); + } if (label[0] != NULL) diff_output("%s %s\n", diff_format == D_CONTEXT ? "***" : "---", label[0]); else - diff_output("%s %s\t%s", diff_format == D_CONTEXT ? "***" : "---", - file1, ctime(&stb1.st_mtime)); + diff_output("%s %s\t%s\n", diff_format == D_CONTEXT ? "***" : "---", + file1, buf1); if (label[1] != NULL) diff_output("%s %s\n", diff_format == D_CONTEXT ? "---" : "+++", label[1]); else - diff_output("%s %s\t%s", diff_format == D_CONTEXT ? "---" : "+++", - file2, ctime(&stb2.st_mtime)); + diff_output("%s %s\t%s\n", diff_format == D_CONTEXT ? "---" : "+++", + file2, buf2); } From owner-svn-src-user@freebsd.org Sat Dec 31 00:49:31 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 D3FC3C9690E for ; Sat, 31 Dec 2016 00:49:31 +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 AEAA31375; Sat, 31 Dec 2016 00:49:31 +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 uBV0nU1o088577; Sat, 31 Dec 2016 00:49:30 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBV0nUxW088575; Sat, 31 Dec 2016 00:49:30 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612310049.uBV0nUxW088575@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 31 Dec 2016 00:49:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310879 - 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: Sat, 31 Dec 2016 00:49:31 -0000 Author: bapt Date: Sat Dec 31 00:49:30 2016 New Revision: 310879 URL: https://svnweb.freebsd.org/changeset/base/310879 Log: Implement diff --strip-trailing-cr Modified: user/bapt/diff/diff.c user/bapt/diff/diff.h user/bapt/diff/diffreg.c Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Sat Dec 31 00:01:21 2016 (r310878) +++ user/bapt/diff/diff.c Sat Dec 31 00:49:30 2016 (r310879) @@ -50,6 +50,7 @@ regex_t ignore_re; #define OPTIONS "0123456789aBbC:cdD:efhI:iL:lnNPpqrS:sTtU:uwX:x:" enum { OPT_TSIZE = CHAR_MAX + 1, + OPT_STRIPCR, }; static struct option longopts[] = { @@ -78,6 +79,7 @@ static struct option longopts[] = { { "ignore-all-space", no_argument, 0, 'w' }, { "exclude", required_argument, 0, 'x' }, { "exclude-from", required_argument, 0, 'X' }, + { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, { "tabsize", optional_argument, NULL, OPT_TSIZE }, { NULL, 0, 0, '\0'} }; @@ -224,6 +226,9 @@ main(int argc, char **argv) usage(); } break; + case OPT_STRIPCR: + dflags |= D_STRIPCR; + break; default: usage(); break; Modified: user/bapt/diff/diff.h ============================================================================== --- user/bapt/diff/diff.h Sat Dec 31 00:01:21 2016 (r310878) +++ user/bapt/diff/diff.h Sat Dec 31 00:49:30 2016 (r310879) @@ -65,6 +65,7 @@ #define D_PROTOTYPE 0x080 /* Display C function prototype */ #define D_EXPANDTABS 0x100 /* Expand tabs to spaces */ #define D_IGNOREBLANKS 0x200 /* Ignore white space changes */ +#define D_STRIPCR 0x500 /* Strip trailing cr */ /* * Status values for print_status() and diffreg() return values Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Sat Dec 31 00:01:21 2016 (r310878) +++ user/bapt/diff/diffreg.c Sat Dec 31 00:49:30 2016 (r310879) @@ -776,7 +776,7 @@ check(FILE *f1, FILE *f2, int flags) ixnew[j] = ctnew += skipline(f2); j++; } - if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE)) { + if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE|D_STRIPCR)) { for (;;) { c = getc(f1); d = getc(f2); @@ -795,6 +795,20 @@ check(FILE *f1, FILE *f2, int flags) } ctold++; ctnew++; + if (flags & D_STRIPCR) { + if (c == '\r') { + if ((c = getc(f1)) == '\n') { + ctnew++; + break; + } + } + if (d == '\r') { + if ((d = getc(f2)) == '\n') { + ctold++; + break; + } + } + } if ((flags & D_FOLDBLANKS) && isspace(c) && isspace(d)) { do { @@ -850,8 +864,9 @@ check(FILE *f1, FILE *f2, int flags) ixnew[j] = ctnew; j++; } - for (; j <= len[1]; j++) + for (; j <= len[1]; j++) { ixnew[j] = ctnew += skipline(f2); + } /* * if (jackpot) * fprintf(stderr, "jackpot\n"); @@ -1246,6 +1261,12 @@ readhash(FILE *f, int flags) if ((flags & (D_FOLDBLANKS|D_IGNOREBLANKS)) == 0) { if (flags & D_IGNORECASE) for (i = 0; (t = getc(f)) != '\n'; i++) { + if (flags & D_STRIPCR && t == '\r') { + t = getc(f); + if (t == '\n') + break; + ungetc(t, f); + } if (t == EOF) { if (i == 0) return (0); @@ -1255,6 +1276,12 @@ readhash(FILE *f, int flags) } else for (i = 0; (t = getc(f)) != '\n'; i++) { + if (flags & D_STRIPCR && t == '\r') { + t = getc(f); + if (t == '\n') + break; + ungetc(t, f); + } if (t == EOF) { if (i == 0) return (0); @@ -1265,8 +1292,8 @@ readhash(FILE *f, int flags) } else { for (i = 0;;) { switch (t = getc(f)) { - case '\t': case '\r': + case '\t': case '\v': case '\f': case ' ': From owner-svn-src-user@freebsd.org Sat Dec 31 00:54:13 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 D0B5AC96CD7 for ; Sat, 31 Dec 2016 00:54:13 +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 A0A141A14; Sat, 31 Dec 2016 00:54:13 +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 uBV0sCEY092301; Sat, 31 Dec 2016 00:54:12 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBV0sCiJ092300; Sat, 31 Dec 2016 00:54:12 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612310054.uBV0sCiJ092300@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 31 Dec 2016 00:54:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310880 - 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: Sat, 31 Dec 2016 00:54:13 -0000 Author: bapt Date: Sat Dec 31 00:54:12 2016 New Revision: 310880 URL: https://svnweb.freebsd.org/changeset/base/310880 Log: Fix typo Modified: user/bapt/diff/diff.h Modified: user/bapt/diff/diff.h ============================================================================== --- user/bapt/diff/diff.h Sat Dec 31 00:49:30 2016 (r310879) +++ user/bapt/diff/diff.h Sat Dec 31 00:54:12 2016 (r310880) @@ -65,7 +65,7 @@ #define D_PROTOTYPE 0x080 /* Display C function prototype */ #define D_EXPANDTABS 0x100 /* Expand tabs to spaces */ #define D_IGNOREBLANKS 0x200 /* Ignore white space changes */ -#define D_STRIPCR 0x500 /* Strip trailing cr */ +#define D_STRIPCR 0x400 /* Strip trailing cr */ /* * Status values for print_status() and diffreg() return values From owner-svn-src-user@freebsd.org Sat Dec 31 11:35:52 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 BC4EAC99F99 for ; Sat, 31 Dec 2016 11:35:52 +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 7D4EC1B84; Sat, 31 Dec 2016 11:35:52 +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 uBVBZphe054744; Sat, 31 Dec 2016 11:35:51 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVBZpBX054741; Sat, 31 Dec 2016 11:35:51 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612311135.uBVBZpBX054741@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 31 Dec 2016 11:35:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310948 - 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: Sat, 31 Dec 2016 11:35:52 -0000 Author: bapt Date: Sat Dec 31 11:35:51 2016 New Revision: 310948 URL: https://svnweb.freebsd.org/changeset/base/310948 Log: Implement diff --ignore-file-name-case Note that the --no-ignore-file-name-case is not planned to be implemented as this is the default and there is no configuration switch to change that default Obtained from: soc2012 Modified: user/bapt/diff/diff.c user/bapt/diff/diff.h user/bapt/diff/diffdir.c Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Sat Dec 31 11:30:18 2016 (r310947) +++ user/bapt/diff/diff.c Sat Dec 31 11:35:51 2016 (r310948) @@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$"); #include "xmalloc.h" int lflag, Nflag, Pflag, rflag, sflag, Tflag, cflag; -int diff_format, diff_context, status; +int diff_format, diff_context, status, ignore_file_case; int tabsize = 8; char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; struct stat stb1, stb2; @@ -51,6 +51,7 @@ regex_t ignore_re; enum { OPT_TSIZE = CHAR_MAX + 1, OPT_STRIPCR, + OPT_IGN_FN_CASE, }; static struct option longopts[] = { @@ -79,6 +80,7 @@ static struct option longopts[] = { { "ignore-all-space", no_argument, 0, 'w' }, { "exclude", required_argument, 0, 'x' }, { "exclude-from", required_argument, 0, 'X' }, + { "ignore-file-name-case", no_argument, NULL, OPT_IGN_FN_CASE }, { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, { "tabsize", optional_argument, NULL, OPT_TSIZE }, { NULL, 0, 0, '\0'} @@ -219,6 +221,9 @@ main(int argc, char **argv) case 'x': push_excludes(optarg); break; + case OPT_IGN_FN_CASE: + ignore_file_case = 1; + break; case OPT_TSIZE: tabsize = (int) strtonum(optarg, 1, INT_MAX, &errstr); if (errstr) { Modified: user/bapt/diff/diff.h ============================================================================== --- user/bapt/diff/diff.h Sat Dec 31 11:30:18 2016 (r310947) +++ user/bapt/diff/diff.h Sat Dec 31 11:35:51 2016 (r310948) @@ -84,7 +84,7 @@ struct excludes { }; extern int lflag, Nflag, Pflag, rflag, sflag, Tflag, cflag; -extern int diff_format, diff_context, status; +extern int diff_format, diff_context, status, ignore_file_case; extern int tabsize; extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; extern struct stat stb1, stb2; Modified: user/bapt/diff/diffdir.c ============================================================================== --- user/bapt/diff/diffdir.c Sat Dec 31 11:30:18 2016 (r310947) +++ user/bapt/diff/diffdir.c Sat Dec 31 11:35:51 2016 (r310948) @@ -124,7 +124,8 @@ diffdir(char *p1, char *p2, int flags) dent2 = dp2 != edp2 ? *dp2 : NULL; pos = dent1 == NULL ? 1 : dent2 == NULL ? -1 : - strcmp(dent1->d_name, dent2->d_name); + ignore_file_case ? strcasecmp(dent1->d_name, dent2->d_name) : + strcmp(dent1->d_name, dent2->d_name) ; if (pos == 0) { /* file exists in both dirs, diff it */ diffit(dent1, path1, dirlen1, path2, dirlen2, flags); From owner-svn-src-user@freebsd.org Sat Dec 31 11:42:58 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 69A42C991D4 for ; Sat, 31 Dec 2016 11:42:58 +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 39D311097; Sat, 31 Dec 2016 11:42:58 +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 uBVBgvTL058523; Sat, 31 Dec 2016 11:42:57 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVBgvwC058522; Sat, 31 Dec 2016 11:42:57 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612311142.uBVBgvwC058522@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 31 Dec 2016 11:42:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310949 - 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: Sat, 31 Dec 2016 11:42:58 -0000 Author: bapt Date: Sat Dec 31 11:42:57 2016 New Revision: 310949 URL: https://svnweb.freebsd.org/changeset/base/310949 Log: Beside what has been stated in previous commit, actually implement --no-ignore-file-name-case some people might be using it, it is simple enough to implement Note that if one plays with multiple call to both --[case-]ignore-file-name-case the latest one wins Convinced by: cperciva, rwatson Modified: user/bapt/diff/diff.c Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Sat Dec 31 11:35:51 2016 (r310948) +++ user/bapt/diff/diff.c Sat Dec 31 11:42:57 2016 (r310949) @@ -52,6 +52,7 @@ enum { OPT_TSIZE = CHAR_MAX + 1, OPT_STRIPCR, OPT_IGN_FN_CASE, + OPT_NO_IGN_FN_CASE, }; static struct option longopts[] = { @@ -81,6 +82,7 @@ static struct option longopts[] = { { "exclude", required_argument, 0, 'x' }, { "exclude-from", required_argument, 0, 'X' }, { "ignore-file-name-case", no_argument, NULL, OPT_IGN_FN_CASE }, + { "no-ignore-file-name-case", no_argument, NULL, OPT_NO_IGN_FN_CASE }, { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, { "tabsize", optional_argument, NULL, OPT_TSIZE }, { NULL, 0, 0, '\0'} @@ -224,6 +226,9 @@ main(int argc, char **argv) case OPT_IGN_FN_CASE: ignore_file_case = 1; break; + case OPT_NO_IGN_FN_CASE: + ignore_file_case = 0; + break; case OPT_TSIZE: tabsize = (int) strtonum(optarg, 1, INT_MAX, &errstr); if (errstr) { From owner-svn-src-user@freebsd.org Sat Dec 31 11:57:38 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 E57AAC99683 for ; Sat, 31 Dec 2016 11:57:38 +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 B58C51D8F; Sat, 31 Dec 2016 11:57:38 +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 uBVBvboj063643; Sat, 31 Dec 2016 11:57:37 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVBvbS1063642; Sat, 31 Dec 2016 11:57:37 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612311157.uBVBvbS1063642@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 31 Dec 2016 11:57:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310951 - 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: Sat, 31 Dec 2016 11:57:39 -0000 Author: bapt Date: Sat Dec 31 11:57:37 2016 New Revision: 310951 URL: https://svnweb.freebsd.org/changeset/base/310951 Log: Add a TODO entry so people can join in if they want or see the status Added: user/bapt/diff/TODO Added: user/bapt/diff/TODO ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/bapt/diff/TODO Sat Dec 31 11:57:37 2016 (r310951) @@ -0,0 +1,19 @@ +-y: + * soc implemented it via calling sdiff directly, but some options are + incompatible so it is fragile + * just recommend the user to run sdiff directly and do not implement it + * make a libsdiff and use that directly to avoid duplicating the code + +to be implemented: +--suppress-common-lines: depends on -y +--ignore-blank-lines +--horizon-lines +--ignore-tab-expansion +--line-format +--normal + +Will probably be not implemented: +--GTYPE-group-format +--LTYPE-line-format +--speed-large-file: (Do we need that? only a stub?) +--help (We have a manpage already) From owner-svn-src-user@freebsd.org Sat Dec 31 12:16:01 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 5F297C98504 for ; Sat, 31 Dec 2016 12:16:01 +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 2F4161E00; Sat, 31 Dec 2016 12:16:01 +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 uBVCG043071839; Sat, 31 Dec 2016 12:16:00 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVCG0gx071838; Sat, 31 Dec 2016 12:16:00 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612311216.uBVCG0gx071838@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 31 Dec 2016 12:16:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310955 - 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: Sat, 31 Dec 2016 12:16:01 -0000 Author: bapt Date: Sat Dec 31 12:16:00 2016 New Revision: 310955 URL: https://svnweb.freebsd.org/changeset/base/310955 Log: Implement diff --normal Modified: user/bapt/diff/diff.c Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Sat Dec 31 12:14:25 2016 (r310954) +++ user/bapt/diff/diff.c Sat Dec 31 12:16:00 2016 (r310955) @@ -53,6 +53,7 @@ enum { OPT_STRIPCR, OPT_IGN_FN_CASE, OPT_NO_IGN_FN_CASE, + OPT_NORMAL, }; static struct option longopts[] = { @@ -83,6 +84,7 @@ static struct option longopts[] = { { "exclude-from", required_argument, 0, 'X' }, { "ignore-file-name-case", no_argument, NULL, OPT_IGN_FN_CASE }, { "no-ignore-file-name-case", no_argument, NULL, OPT_NO_IGN_FN_CASE }, + { "normal", no_argument, NULL, OPT_NORMAL }, { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, { "tabsize", optional_argument, NULL, OPT_TSIZE }, { NULL, 0, 0, '\0'} @@ -229,6 +231,9 @@ main(int argc, char **argv) case OPT_NO_IGN_FN_CASE: ignore_file_case = 0; break; + case OPT_NORMAL: + diff_format = D_NORMAL; + break; case OPT_TSIZE: tabsize = (int) strtonum(optarg, 1, INT_MAX, &errstr); if (errstr) { From owner-svn-src-user@freebsd.org Sat Dec 31 12:16:22 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 E3878C98521 for ; Sat, 31 Dec 2016 12:16:22 +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 B3C4D1F0F; Sat, 31 Dec 2016 12:16:22 +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 uBVCGLt1071903; Sat, 31 Dec 2016 12:16:21 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVCGL3Q071902; Sat, 31 Dec 2016 12:16:21 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612311216.uBVCGL3Q071902@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 31 Dec 2016 12:16:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310956 - 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: Sat, 31 Dec 2016 12:16:23 -0000 Author: bapt Date: Sat Dec 31 12:16:21 2016 New Revision: 310956 URL: https://svnweb.freebsd.org/changeset/base/310956 Log: Remove --normal from the TODO list Modified: user/bapt/diff/TODO Modified: user/bapt/diff/TODO ============================================================================== --- user/bapt/diff/TODO Sat Dec 31 12:16:00 2016 (r310955) +++ user/bapt/diff/TODO Sat Dec 31 12:16:21 2016 (r310956) @@ -10,7 +10,6 @@ to be implemented: --horizon-lines --ignore-tab-expansion --line-format ---normal Will probably be not implemented: --GTYPE-group-format From owner-svn-src-user@freebsd.org Sat Dec 31 16:02:28 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 B1960C993AA for ; Sat, 31 Dec 2016 16:02:28 +0000 (UTC) (envelope-from pho@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 7282B1F5A; Sat, 31 Dec 2016 16:02:28 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVG2R93068356; Sat, 31 Dec 2016 16:02:27 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVG2RDD068355; Sat, 31 Dec 2016 16:02:27 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201612311602.uBVG2RDD068355@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Sat, 31 Dec 2016 16:02:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r310978 - user/pho/stress2/misc 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: Sat, 31 Dec 2016 16:02:28 -0000 Author: pho Date: Sat Dec 31 16:02:27 2016 New Revision: 310978 URL: https://svnweb.freebsd.org/changeset/base/310978 Log: Added a regression test. Sponsored by: Dell EMC Isilon In collaboration with: kib Added: user/pho/stress2/misc/shm.sh (contents, props changed) Added: user/pho/stress2/misc/shm.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/shm.sh Sat Dec 31 16:02:27 2016 (r310978) @@ -0,0 +1,203 @@ +#!/bin/sh + +# +# Copyright (c) 2016 Dell EMC Isilon +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# Regression test for r310849. Hang in "vmpfw" was seen. + +# Test scenario suggestion by kib. + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +RUNTIME=60 +old=`sysctl -n kern.ipc.shm_use_phys` +trap "sysctl kern.ipc.shm_use_phys=$old" EXIT INT +sysctl kern.ipc.shm_use_phys=1 + +dir=/tmp +odir=`pwd` +cd $dir +sed '1,/^EOF/d' < $odir/$0 > $dir/shm.c +mycc -o shm -Wall -Wextra -O0 -g shm.c -pthread || exit 1 +rm -f shm.c + +/tmp/shm & + +s=0 +sleep $RUNTIME +if pgrep -q shm; then + if pgrep shm | xargs ps -lHp | grep -q vmpfw; then + s=1 + echo FAIL + pgrep shm | xargs ps -lHp + pkill -9 shm + fi +fi +wait + +rm -rf /tmp/shm +exit $s + +EOF +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void *shmp; +static size_t len; +static int cont, shmid; + +#define PAGES 64 +#define RUNTIME (1 * 60) +#define STOP 1 +#define SYNC 0 + +static void +cleanup(void) +{ + if (shmp != MAP_FAILED) + shmdt(shmp); + if (shmid != 0) + shmctl(shmid, IPC_RMID, NULL); +} + +static void * +t1(void *arg __unused) +{ + time_t start; + char *cp; + + pthread_set_name_np(pthread_self(), __func__); + start = time(NULL); + while (cont == 1 && (time(NULL) - start) < RUNTIME) { + if ((cp = mmap(NULL, len, PROT_READ | PROT_WRITE, + MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) + err(1, "mmap"); + usleep(arc4random() % 400); + if (munmap(cp, len) == -1) + warn("unmap(%p, %zu)", shmp, len); + } + + return (NULL); +} + +static void * +t2(void *arg __unused) +{ + key_t shmkey; + size_t i; + time_t start; + char *cp; + + pthread_set_name_np(pthread_self(), __func__); + shmkey = ftok("/tmp", getpid()); + start = time(NULL); + atexit(cleanup); + while ((time(NULL) - start) < RUNTIME) { + if ((shmid = shmget(shmkey, len, IPC_CREAT | IPC_EXCL | + 0640)) == -1) { + if (errno != ENOSPC && errno != EEXIST) + err(1, "shmget (%s:%d)", __FILE__, __LINE__); + break; + } + if ((shmp = shmat(shmid, NULL, 0)) == (void *) -1) + break; + cp = (char *)(shmp); + for (i = 0; i < len; i = i + PAGE_SIZE) + cp[i] = 1; + if (shmdt(shmp) == -1) { + if (errno != EINVAL) + warn("shmdt(%p)", shmp); + } + if (shmctl(shmid, IPC_RMID, NULL) == -1) + warn("shmctl IPC_RMID"); + usleep(50); + + shmp = MAP_FAILED; + shmid = 0; + } + cont = 0; + + return (NULL); +} + +static int +test(void) +{ + pthread_t tid[2]; + int i, rc; + + shmp = MAP_FAILED; + + cont = 1; + if ((rc = pthread_create(&tid[0], NULL, t1, NULL)) != 0) + errc(1, rc, "pthread_create()"); + if ((rc = pthread_create(&tid[1], NULL, t2, NULL)) != 0) + errc(1, rc, "pthread_create()"); + + for (i = 0; i < 2; i++) + if ((rc = pthread_join(tid[i], NULL)) != 0) + errc(1, rc, "pthread_join(%d)", i); + + return (0); +} + +int +main(void) +{ + pid_t pid; + time_t start; + + len = PAGES * PAGE_SIZE; + start = time(NULL); + while ((time(NULL) - start) < RUNTIME) { + if ((pid = fork()) == 0) { + test(); + exit(0); /* calls cleanup() */ + } + if (waitpid(pid, NULL,0) != pid) + err(1, "waitpid(%d)", pid); + } + + return(0); +}