lib/tmpfile.c and lib/tmpdir.c give compilation errors on MSVC 9,
because PATH_MAX is not defined.

Also, mingw defines PATH_MAX in <limits.h>, but to a wrong value (259
instead of 260). Same mistake as on HP-UX.

This fixes it:


2011-09-13  Bruno Haible  <br...@clisp.org>

        pathmax: Support for native Windows.
        * lib/pathmax.h (PATH_MAX): Define to 260 on native Windows.

--- lib/pathmax.h.orig  Tue Sep 13 12:59:55 2011
+++ lib/pathmax.h       Tue Sep 13 12:32:15 2011
@@ -66,4 +66,19 @@
 #  define PATH_MAX 1024
 # endif
 
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
+   section "Maximum Path Length Limitation",
+   <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath>
+   explains that the maximum size of a filename, including the terminating
+   NUL byte, is 260 = 3 + 256 + 1.
+   This is the same value as
+     - FILENAME_MAX in <stdio.h>,
+     - _MAX_PATH in <stdlib.h>,
+     - MAX_PATH in <windef.h>.
+   Undefine the original value, because mingw's <limits.h> gets it wrong.  */
+#  undef PATH_MAX
+#  define PATH_MAX 260
+# endif
+
 #endif /* _PATHMAX_H */
-- 
In memoriam Ketevan of Mukhrani 
<http://en.wikipedia.org/wiki/Ketevan_of_Mukhrani>

Reply via email to