From owner-svn-src-head@freebsd.org Sun Mar 26 14:09:27 2017 Return-Path: Delivered-To: svn-src-head@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 11031D1D8F9; Sun, 26 Mar 2017 14:09:27 +0000 (UTC) (envelope-from jilles@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 C787019BD; Sun, 26 Mar 2017 14:09:26 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2QE9PGY005796; Sun, 26 Mar 2017 14:09:25 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2QE9PB6005791; Sun, 26 Mar 2017 14:09:25 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201703261409.v2QE9PB6005791@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 26 Mar 2017 14:09:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315985 - in head/usr.bin/diff: . tests X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Mar 2017 14:09:27 -0000 Author: jilles Date: Sun Mar 26 14:09:25 2017 New Revision: 315985 URL: https://svnweb.freebsd.org/changeset/base/315985 Log: diff: Fix mtime of file1 in -u/-c header line. PR: 218018 Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10140 Added: head/usr.bin/diff/tests/header.out (contents, props changed) Modified: head/usr.bin/diff/diffreg.c head/usr.bin/diff/tests/Makefile head/usr.bin/diff/tests/diff_test.sh Modified: head/usr.bin/diff/diffreg.c ============================================================================== --- head/usr.bin/diff/diffreg.c Sun Mar 26 13:03:16 2017 (r315984) +++ head/usr.bin/diff/diffreg.c Sun Mar 26 14:09:25 2017 (r315985) @@ -1614,7 +1614,7 @@ print_header(const char *file1, const ch char buf2[256]; char end1[10]; char end2[10]; - struct tm *tm_ptr1, *tm_ptr2; + struct tm tm1, tm2, *tm_ptr1, *tm_ptr2; int nsec1 = TIMESPEC_NS (stb1.st_mtime); int nsec2 = TIMESPEC_NS (stb2.st_mtime); @@ -1626,8 +1626,8 @@ print_header(const char *file1, const ch if (cflag) time_format = "%c"; - tm_ptr1 = localtime(&stb1.st_mtime); - tm_ptr2 = localtime(&stb2.st_mtime); + tm_ptr1 = localtime_r(&stb1.st_mtime, &tm1); + tm_ptr2 = localtime_r(&stb2.st_mtime, &tm2); strftime(buf1, 256, time_format, tm_ptr1); strftime(buf2, 256, time_format, tm_ptr2); if (!cflag) { Modified: head/usr.bin/diff/tests/Makefile ============================================================================== --- head/usr.bin/diff/tests/Makefile Sun Mar 26 13:03:16 2017 (r315984) +++ head/usr.bin/diff/tests/Makefile Sun Mar 26 14:09:25 2017 (r315985) @@ -19,7 +19,8 @@ ${PACKAGE}FILES+= \ simple_p.out \ unified_p.out \ unified_c9999.out \ - unified_9999.out + unified_9999.out \ + header.out NETBSD_ATF_TESTS_SH+= netbsd_diff_test Modified: head/usr.bin/diff/tests/diff_test.sh ============================================================================== --- head/usr.bin/diff/tests/diff_test.sh Sun Mar 26 13:03:16 2017 (r315984) +++ head/usr.bin/diff/tests/diff_test.sh Sun Mar 26 14:09:25 2017 (r315985) @@ -2,6 +2,7 @@ atf_test_case simple atf_test_case unified +atf_test_case header simple_body() { @@ -46,8 +47,20 @@ unified_body() diff -u9999 -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" } +header_body() +{ + export TZ=UTC + : > empty + echo hello > hello + touch -d 2015-04-03T01:02:03 empty + touch -d 2016-12-22T11:22:33 hello + atf_check -o "file:$(atf_get_srcdir)/header.out" -s eq:1 \ + diff -u empty hello +} + atf_init_test_cases() { atf_add_test_case simple atf_add_test_case unified + atf_add_test_case header } Added: head/usr.bin/diff/tests/header.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/diff/tests/header.out Sun Mar 26 14:09:25 2017 (r315985) @@ -0,0 +1,4 @@ +--- empty 2015-04-03 01:02:03.000000000 +0000 ++++ hello 2016-12-22 11:22:33.000000000 +0000 +@@ -0,0 +1 @@ ++hello