diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-03-06 20:36:03 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-03-06 20:36:03 +0000 |
commit | e4ab123c32e6ee2064f01f5bb477bfaca438c20f (patch) | |
tree | 45c6c5ff8fa819ab554de69d49403a43f8de5ecb /libgfortran/intrinsics | |
parent | 692323c3112b3b579a1634758842ede7c416f94c (diff) | |
download | gcc-e4ab123c32e6ee2064f01f5bb477bfaca438c20f.tar.gz |
2011-03-06 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 170715 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@170721 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics')
-rw-r--r-- | libgfortran/intrinsics/ctime.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libgfortran/intrinsics/ctime.c b/libgfortran/intrinsics/ctime.c index 7eb10f5fa2c..92c0431357e 100644 --- a/libgfortran/intrinsics/ctime.c +++ b/libgfortran/intrinsics/ctime.c @@ -39,9 +39,18 @@ static size_t strctime (char *s, size_t max, const time_t *timep) { #ifdef HAVE_STRFTIME - struct tm res; - struct tm *ltm = localtime_r (timep, &res); - return strftime (s, max, "%c", ltm); + struct tm ltm; + int failed; + /* Some targets provide a localtime_r based on a draft of the POSIX + standard where the return type is int rather than the + standardized struct tm*. */ + __builtin_choose_expr (__builtin_classify_type (localtime_r (timep, <m)) + == 5, + failed = localtime_r (timep, <m) == NULL, + failed = localtime_r (timep, <m) != 0); + if (failed) + return 0; + return strftime (s, max, "%c", <m); #else return 0; #endif |