diff -urN diffutils-2.9-orig/configure diffutils-2.9/configure --- diffutils-2.9-orig/configure 2010-02-11 18:46:35 +0900 +++ diffutils-2.9/configure 2010-02-16 00:11:11 +0900 @@ -1892,6 +1892,8 @@ --disable-rpath do not hardcode runtime library paths --enable-gcc-warnings turn on lots of GCC warnings (for developers) --disable-nls do not use Native Language Support + --disable-nanosecond-timestamps + disable nanosecond resolution in timestamps Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -3636,6 +3638,12 @@ ac_config_headers="$ac_config_headers lib/config.h:lib/config.hin" +# Check whether --enable-nanosecond-timestamps was given. +if test "${enable_nanosecond_timestamps+set}" = set; then + enableval=$enable_nanosecond_timestamps; if test "no" = "$enableval"; then ac_cv_search_clock_gettime=no; fi +fi + + for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. diff -urN diffutils-2.9-orig/configure.ac diffutils-2.9/configure.ac --- diffutils-2.9-orig/configure.ac 2010-02-05 17:10:15 +0900 +++ diffutils-2.9/configure.ac 2010-02-16 00:06:07 +0900 @@ -31,6 +31,11 @@ AC_CONFIG_HEADER([lib/config.h:lib/config.hin]) +AC_ARG_ENABLE(nanosecond-timestamps, + [AS_HELP_STRING([--disable-nanosecond-timestamps], + [disable nanosecond resolution in timestamps])], + [if test "no" = "$enableval"; then ac_cv_search_clock_gettime=no; fi]) + AC_PROG_AWK AC_PROG_CC AM_PROG_CC_STDC diff -urN diffutils-2.9-orig/src/context.c diffutils-2.9/src/context.c --- diffutils-2.9-orig/src/context.c 2010-02-05 17:10:15 +0900 +++ diffutils-2.9/src/context.c 2010-02-16 00:08:14 +0900 @@ -57,17 +57,29 @@ && TYPE_MAXIMUM (time_t) <= LONG_MAX) { long int sec = inf->stat.st_mtime; +#if HAVE_CLOCK_GETTIME sprintf (buf, "%ld.%.9d", sec, nsec); +#else + sprintf (buf, "%ld", sec); +#endif } else if (TYPE_MAXIMUM (time_t) <= INTMAX_MAX) { intmax_t sec = inf->stat.st_mtime; +#if HAVE_CLOCK_GETTIME sprintf (buf, "%"PRIdMAX".%.9d", sec, nsec); +#else + sprintf (buf, "%"PRIdMAX, sec); +#endif } else { uintmax_t sec = inf->stat.st_mtime; +#if HAVE_CLOCK_GETTIME sprintf (buf, "%"PRIuMAX".%.9d", sec, nsec); +#else + sprintf (buf, "%"PRIuMAX, sec); +#endif } } fprintf (outfile, "%s %s\t%s\n", mark, inf->name, buf); diff -urN diffutils-2.9-orig/src/diff.c diffutils-2.9/src/diff.c --- diffutils-2.9-orig/src/diff.c 2010-02-11 18:39:17 +0900 +++ diffutils-2.9/src/diff.c 2010-02-16 00:09:48 +0900 @@ -636,7 +636,7 @@ if (output_style != OUTPUT_CONTEXT || hard_locale (LC_TIME)) { #if (defined STAT_TIMESPEC || defined STAT_TIMESPEC_NS \ - || defined HAVE_STRUCT_STAT_ST_SPARE1) + || defined HAVE_STRUCT_STAT_ST_SPARE1) && HAVE_CLOCK_GETTIME time_format = "%Y-%m-%d %H:%M:%S.%N %z"; #else time_format = "%Y-%m-%d %H:%M:%S %z";