Correct strftime callers
[openafs.git] / src / util / assert.c
index 56c7893..78e9d0c 100644 (file)
 /* ReallyAbort:  called from assert. May/85 */
 #include <afsconfig.h>
 #include <afs/param.h>
-#include <stdlib.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#include <string.h>
 
+#include <roken.h>
 
-#include <stdio.h>
 #include "afsutil.h"
 
 #ifdef AFS_NT40_ENV
@@ -29,23 +24,19 @@ afs_NTAbort(void)
 #endif
 
 #define TIMESTAMP_BUFFER_SIZE 26  /* including the null */
-#define TIMESTAMP_NEWLINE_POS 24  /* offset to the newline placed by ctime */
 
 void
 AssertionFailed(char *file, int line)
 {
     char tdate[TIMESTAMP_BUFFER_SIZE];
     time_t when;
+    struct tm tm;
 
-    time(&when);
-    (void)afs_ctime(&when, tdate, sizeof(tdate));
-    tdate[TIMESTAMP_NEWLINE_POS] = ' ';
-    fprintf(stderr, "%sAssertion failed! file %s, line %d.\n", tdate, file,
+    when = time(NULL);
+    strftime(tdate, sizeof(tdate), "%a %b %d %T %Y",
+            localtime_r(&when, &tm));
+    fprintf(stderr, "%s Assertion failed! file %s, line %d.\n", tdate, file,
            line);
     fflush(stderr);
-#ifdef AFS_NT40_ENV
-    afs_NTAbort();
-#else
-    abort();
-#endif
+    afs_abort();
 }