[llvm-commits] CVS: llvm/lib/System/Win32/TimeValue.cpp

Jeff Cohen jeffc at jolt-lang.org
Tue Dec 14 20:28:55 PST 2004



Changes in directory llvm/lib/System/Win32:

TimeValue.cpp updated: 1.5 -> 1.6
---
Log message:

Make Win32 TimeValue::toString() re-entrant and work with mingw

---
Diffs of the changes:  (+9 -5)

Index: llvm/lib/System/Win32/TimeValue.cpp
diff -u llvm/lib/System/Win32/TimeValue.cpp:1.5 llvm/lib/System/Win32/TimeValue.cpp:1.6
--- llvm/lib/System/Win32/TimeValue.cpp:1.5	Mon Dec 13 23:26:43 2004
+++ llvm/lib/System/Win32/TimeValue.cpp	Tue Dec 14 22:28:44 2004
@@ -31,13 +31,17 @@
 }
 
 std::string TimeValue::toString() const {
-  // Alas, asctime is not re-entrant on Windows...
-
+#ifdef __MINGW
+  time_t ourTime = time_t(this->toEpochTime());
+  struct tm *lt = ::localtime(&ourTime);
+#else
   __time64_t ourTime = this->toEpochTime();
-  char* buffer = ::asctime(::_localtime64(&ourTime));
+  struct tm *lt = ::_localtime64(&ourTime);
+#endif
 
-  std::string result(buffer);
-  return result.substr(0,24);
+  char buffer[25];
+  strftime(buffer, 25, "%a %b %d %H:%M:%S %Y", lt);
+  return std::string(buffer);
 }
 
 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab






More information about the llvm-commits mailing list