Author: cazfi
Date: Fri Jul  1 21:29:42 2016
New Revision: 33142

URL: http://svn.gna.org/viewcvs/freeciv?rev=33142&view=rev
Log:
Added configure check for _mkdir().

See bug #24356

Modified:
    branches/S2_6/configure.ac
    branches/S2_6/utility/shared.c

Modified: branches/S2_6/configure.ac
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/configure.ac?rev=33142&r1=33141&r2=33142&view=diff
==============================================================================
--- branches/S2_6/configure.ac  (original)
+++ branches/S2_6/configure.ac  Fri Jul  1 21:29:42 2016
@@ -1281,6 +1281,13 @@
                strerror strlcat strlcpy strncasecmp strstr uname usleep \
                 getline _strcoll stricoll _stricoll strcasecoll \
                 backtrace])
+
+dnl Possible "-Wmissing-declarations" and "-Werror" will prune out
+dnl cases where we should not use _mkdir() even if it's possible to link 
against it
+fc_save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS -Werror $EXTRA_DEBUG_CFLAGS"
+AC_CHECK_FUNCS([_mkdir])
+CPPFLAGS="$fc_save_CPPFLAGS"
 
 AC_MSG_CHECKING(for working gettimeofday)
   FC_CHECK_GETTIMEOFDAY_RUNTIME(,AC_DEFINE([HAVE_GETTIMEOFDAY], [1],

Modified: branches/S2_6/utility/shared.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/shared.c?rev=33142&r1=33141&r2=33142&view=diff
==============================================================================
--- branches/S2_6/utility/shared.c      (original)
+++ branches/S2_6/utility/shared.c      Fri Jul  1 21:29:42 2016
@@ -1755,12 +1755,23 @@
     }
 
 #ifdef WIN32_NATIVE
-    char *path_in_local_encoding = internal_to_local_string_malloc(path);
-    _mkdir(path_in_local_encoding);
-    free(path_in_local_encoding);
-#else
+#ifdef HAVE__MKDIR
+    /* Prefer _mkdir() in Windows even if mkdir() would seem to be available -
+     * chances are that it's wrong kind of mkdir().
+     * TODO: Make a configure check for mkdir() that also makes sure that it
+     *       takes two parameters, and prefer such proper mkdir() here. */
+    {
+      char *path_in_local_encoding = internal_to_local_string_malloc(path);
+
+      _mkdir(path_in_local_encoding);
+      free(path_in_local_encoding);
+    }
+#else  /* HAVE__MKDIR */
     mkdir(path, 0755);
-#endif
+#endif /* HAVE__MKDIR */
+#else  /* WIN32_NATIVE */
+    mkdir(path, 0755);
+#endif /* WIN32_NATIVE */
 
     if (dir) {
       *dir = DIR_SEPARATOR_CHAR;


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to