Small bug with warnings if localtime_r doesn't exist.

"Sydius" <[email protected]> Thu, 25 Feb 2010 23:34:48 -0000
Newsgroups gmane.text.clearsilver.general
Message-ID <[email protected]>
If localtime_r doesn't exist, my_tm is left uninitialized, and thus tbuf is useless.

Index: util/neo_misc.c

===================================================================

--- util/neo_misc.c	(revision 769)

+++ util/neo_misc.c	(working copy)

@@ -32,14 +32,20 @@

 
   now = time(NULL);
 
+#ifdef HAVE_LOCALTIME_R
   localtime_r(&now, &my_tm);
-
   strftime(tbuf, sizeof(tbuf), "%m/%d %T", &my_tm);
+#endif
 
   _vsnprintf (buf, sizeof(buf), fmt, ap);
   len = strlen(buf);
   while (len && isspace (buf[len-1])) buf[--len] = '\0';
+
+#ifdef HAVE_LOCALTIME_R
   fprintf (stderr, "[%s] %s\n", tbuf, buf);
+#else
+  fprintf (stderr, "%s\n", buf);
+#endif
 }
 
 void ne_warn (const char *fmt, ...)