提交 64f85587 编写于 作者: R Rich Felker

handle errors from localtime_r in ctime_r

POSIX requires ctime_r return a null pointer on failure, which can
occur if the input time_t value is not representable in broken down
form.

based on patch by Alexander Monakov.
上级 2d7d05f0
......@@ -2,7 +2,6 @@
char *ctime_r(const time_t *t, char *buf)
{
struct tm tm;
localtime_r(t, &tm);
return asctime_r(&tm, buf);
struct tm tm, *tm_p = localtime_r(t, &tm);
return tm_p ? asctime_r(tm_p, buf) : 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册