Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145307926
D10145.id26676.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D10145.id26676.diff
View Options
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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Feb 19, 6:02 AM (13 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28870073
Default Alt Text
D10145.id26676.diff (2 KB)
Attached To
Mode
D10145: diff: Show nanoseconds in -u/-c header line.
Attached
Detach File
Event Timeline
Log In to Comment