X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fstat-time.h;fp=lib%2Fstat-time.h;h=30c2acdab63637b73c590bfb91e06502839bcf94;hb=dc84183747ce1703eb99685b5dbde1f65a143c06;hp=16300485f328ef9ce69230fe337d31987f7067cb;hpb=a2016c1de6e4884f6c8ed5cc498f3bf821c25ca4;p=debian%2Fgzip diff --git a/lib/stat-time.h b/lib/stat-time.h index 1630048..30c2acd 100644 --- a/lib/stat-time.h +++ b/lib/stat-time.h @@ -1,6 +1,6 @@ /* stat-related time functions. - Copyright (C) 2005, 2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2009-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -142,7 +142,7 @@ get_stat_mtime (struct stat const *st) } /* Return *ST's birth time, if available; otherwise return a value - with negative tv_nsec. */ + with tv_sec and tv_nsec both equal to -1. */ static inline struct timespec get_stat_birthtime (struct stat const *st) { @@ -155,13 +155,13 @@ get_stat_birthtime (struct stat const *st) t.tv_sec = st->st_birthtime; t.tv_nsec = st->st_birthtimensec; #elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - /* Woe32 native platforms (but not Cygwin) put the "file creation + /* Native Windows platforms (but not Cygwin) put the "file creation time" in st_ctime (!). See . */ t.tv_sec = st->st_ctime; t.tv_nsec = 0; #else - /* Birth time is not supported. Set tv_sec to avoid undefined behavior. */ + /* Birth time is not supported. */ t.tv_sec = -1; t.tv_nsec = -1; /* Avoid a "parameter unused" warning. */ @@ -175,10 +175,12 @@ get_stat_birthtime (struct stat const *st) using zero. Attempt to work around this problem. Alas, this can report failure even for valid time stamps. Also, NetBSD sometimes returns junk in the birth time fields; work around this - bug if it it is detected. There's no need to detect negative - tv_nsec junk as negative tv_nsec already indicates an error. */ - if (t.tv_sec == 0 || 1000000000 <= t.tv_nsec) - t.tv_nsec = -1; + bug if it is detected. */ + if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000)) + { + t.tv_sec = -1; + t.tv_nsec = -1; + } #endif return t;