Manually sort some includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / utility / cstringutil.c
index ca835d4c106dab065b216b5e595ff2d195ffe839..85cbd41c0af55b776340fcaa385f24f2992ce70a 100644 (file)
@@ -35,9 +35,9 @@
  * the research papers on the package. Check out http://www.gromacs.org.
  */
 /* This file is completely threadsafe - keep it that way! */
-#include "cstringutil.h"
+#include "gmxpre.h"
 
-#include "config.h"
+#include "cstringutil.h"
 
 #include <assert.h>
 #include <ctype.h>
@@ -47,6 +47,9 @@
 #include <time.h>
 
 #include <sys/types.h>
+
+#include "config.h"
+
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
@@ -190,20 +193,22 @@ void trim (char *str)
 char *
 gmx_ctime_r(const time_t *clock, char *buf, int n)
 {
-    char tmpbuf[STRLEN];
-
-#ifdef GMX_NATIVE_WINDOWS
+#ifdef _MSC_VER
     /* Windows */
-    ctime_s( tmpbuf, STRLEN, clock );
+    ctime_s( buf, n, clock );
+#elif defined(GMX_NATIVE_WINDOWS)
+    char *tmpbuf = ctime( clock );
+    strncpy(buf, tmpbuf, n-1);
+    buf[n-1] = '\0';
 #elif (defined(__sun))
     /*Solaris*/
-    ctime_r(clock, tmpbuf, n);
+    ctime_r(clock, buf, n);
 #else
+    char tmpbuf[STRLEN];
     ctime_r(clock, tmpbuf);
-#endif
     strncpy(buf, tmpbuf, n-1);
     buf[n-1] = '\0';
-
+#endif
     return buf;
 }