Index: head/usr.bin/diff/diffreg.c =================================================================== --- head/usr.bin/diff/diffreg.c +++ head/usr.bin/diff/diffreg.c @@ -94,12 +94,6 @@ #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 - /* * diff - compare two files. */ @@ -1615,14 +1609,10 @@ char end1[10]; char end2[10]; struct tm tm1, tm2, *tm_ptr1, *tm_ptr2; - int nsec1 = TIMESPEC_NS (stb1.st_mtime); - int nsec2 = TIMESPEC_NS (stb2.st_mtime); + int nsec1 = stb1.st_mtim.tv_nsec; + int nsec2 = stb2.st_mtim.tv_nsec; -#ifdef ST_MTIM_NSEC - time_format = "%Y-%m-%d %H:%M:%S.%N"; -#else - time_format = "%Y-%m-%d %H:%M:%S"; -#endif + time_format = "%Y-%m-%d %H:%M:%S"; if (cflag) time_format = "%c"; Index: head/usr.bin/diff/tests/Makefile =================================================================== --- head/usr.bin/diff/tests/Makefile +++ head/usr.bin/diff/tests/Makefile @@ -20,7 +20,8 @@ unified_p.out \ unified_c9999.out \ unified_9999.out \ - header.out + header.out \ + header_ns.out NETBSD_ATF_TESTS_SH+= netbsd_diff_test Index: head/usr.bin/diff/tests/diff_test.sh =================================================================== --- head/usr.bin/diff/tests/diff_test.sh +++ head/usr.bin/diff/tests/diff_test.sh @@ -3,6 +3,7 @@ atf_test_case simple atf_test_case unified atf_test_case header +atf_test_case header_ns simple_body() { @@ -58,9 +59,21 @@ diff -u empty hello } +header_ns_body() +{ + export TZ=UTC + : > empty + echo hello > hello + touch -d 2015-04-03T01:02:03.123456789 empty + touch -d 2016-12-22T11:22:33.987654321 hello + atf_check -o "file:$(atf_get_srcdir)/header_ns.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 + atf_add_test_case header_ns } Index: head/usr.bin/diff/tests/header_ns.out =================================================================== --- head/usr.bin/diff/tests/header_ns.out +++ head/usr.bin/diff/tests/header_ns.out @@ -0,0 +1,4 @@ +--- empty 2015-04-03 01:02:03.123456789 +0000 ++++ hello 2016-12-22 11:22:33.987654321 +0000 +@@ -0,0 +1 @@ ++hello