diff: Show nanoseconds in -u/-c header line.
Show nanoseconds in the -u/-c header line. The present portability conditionals cannot handle the POSIX standard st_mtim, so remove them and unconditionally use st_mtim. PR: 218018 Reported by: jbeich Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10145
This commit is contained in:
parent
f434f3515b
commit
385a67dc6a
@ -94,12 +94,6 @@ __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
|
||||
|
||||
/*
|
||||
* diff - compare two files.
|
||||
*/
|
||||
@ -1615,14 +1609,10 @@ print_header(const char *file1, const char *file2)
|
||||
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";
|
||||
|
@ -20,7 +20,8 @@ ${PACKAGE}FILES+= \
|
||||
unified_p.out \
|
||||
unified_c9999.out \
|
||||
unified_9999.out \
|
||||
header.out
|
||||
header.out \
|
||||
header_ns.out
|
||||
|
||||
NETBSD_ATF_TESTS_SH+= netbsd_diff_test
|
||||
|
||||
|
@ -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 @@ header_body()
|
||||
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
|
||||
}
|
||||
|
4
usr.bin/diff/tests/header_ns.out
Normal file
4
usr.bin/diff/tests/header_ns.out
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user