upgrade SDL to version 2.0.8
[platform/upstream/SDL.git] / src / test / SDL_test_log.c
index 1db5bec..6f6e4e9 100755 (executable)
@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -26,7 +26,9 @@
 */
 
 /* quiet windows compiler warnings */
-#define _CRT_SECURE_NO_WARNINGS
+#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
+# define _CRT_SECURE_NO_WARNINGS
+#endif
 
 #include "SDL_config.h"
 
 
 #include "SDL_test.h"
 
+/* work around compiler warning on older GCCs. */
+#if (defined(__GNUC__) && (__GNUC__ <= 2))
+static size_t
+strftime_gcc2_workaround(char *s, size_t max, const char *fmt, const struct tm *tm)
+{
+    return strftime(s, max, fmt, tm);
+}
+#ifdef strftime
+#undef strftime
+#endif
+#define strftime strftime_gcc2_workaround
+#endif
+
 /* !
  * Converts unix timestamp to its ascii representation in localtime
  *
  *
  * \return Ascii representation of the timestamp in localtime in the format '08/23/01 14:55:02'
  */
-char *SDLTest_TimestampToString(const time_t timestamp)
+static char *SDLTest_TimestampToString(const time_t timestamp)
 {
     time_t copy;
     static char buffer[64];
     struct tm *local;
-    const char *fmt = "%x %X";
 
     SDL_memset(buffer, 0, sizeof(buffer));
     copy = timestamp;
     local = localtime(&copy);
-    strftime(buffer, sizeof(buffer), fmt, local);
+    strftime(buffer, sizeof(buffer), "%x %X", local);
 
     return buffer;
 }
@@ -146,3 +160,5 @@ void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
     /* Log with timestamp and newline */
     SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(0)), logMessage);
 }
+
+/* vi: set ts=4 sw=4 expandtab: */