Correct strftime callers
[openafs.git] / src / util / assert.c
index 097106b..78e9d0c 100644 (file)
@@ -1,34 +1,42 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
-#ifndef lint
-#endif
 /* ReallyAbort:  called from assert. May/85 */
+#include <afsconfig.h>
 #include <afs/param.h>
-#include <stdio.h>
+
+#include <roken.h>
+
+#include "afsutil.h"
 
 #ifdef AFS_NT40_ENV
-void afs_NTAbort(void)
+void
+afs_NTAbort(void)
 {
-    _asm int 3h; /* always trap. */
+    DebugBreak();
 }
 #endif
 
+#define TIMESTAMP_BUFFER_SIZE 26  /* including the null */
 
-void AssertionFailed(char *file, int line)
+void
+AssertionFailed(char *file, int line)
 {
-    fprintf(stderr, "Assertion failed! file %s, line %d.\n", file, line);
+    char tdate[TIMESTAMP_BUFFER_SIZE];
+    time_t when;
+    struct tm tm;
+
+    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();
 }
-