]> granicus.if.org Git - python/commitdiff
Define MAXPATHLEN to be at least PATH_MAX, if that's defined. Python uses
authorThomas Wouters <thomas@python.org>
Tue, 25 Apr 2006 15:29:46 +0000 (15:29 +0000)
committerThomas Wouters <thomas@python.org>
Tue, 25 Apr 2006 15:29:46 +0000 (15:29 +0000)
MAXPATHLEN-sized buffers for various output-buffers (like to realpath()),
and that's correct on BSD platforms, but not Linux (which uses PATH_MAX, and
does not define MAXPATHLEN.) Cursory googling suggests Linux is following a
newer standard than BSD, but in cases like this, who knows. Using the
greater of PATH_MAX and 1024 as a fallback for MAXPATHLEN seems to be the
most portable solution.

Include/osdefs.h
Modules/posixmodule.c
Python/getcwd.c

index 8190a752eaeb464d354754dd17ddcb72bb9ac9f0..6937659325af793133e17b5a3812f3f7bd4a6c15 100644 (file)
@@ -37,8 +37,12 @@ extern "C" {
 
 /* Max pathname length */
 #ifndef MAXPATHLEN
+#if defined(PATH_MAX) && PATH_MAX > 1024
+#define MAXPATHLEN PATH_MAX
+#else
 #define MAXPATHLEN 1024
 #endif
+#endif
 
 /* Search path entry delimiter */
 #ifndef DELIM
index ac74a6741f030210c199aed319325361af948f4a..7f2356c067084a7ca52e4aee562ec14cac7af87b 100644 (file)
@@ -262,7 +262,11 @@ extern int lstat(const char *, struct stat *);
 #endif /* OS2 */
 
 #ifndef MAXPATHLEN
+#if defined(PATH_MAX) && PATH_MAX > 1024
+#define MAXPATHLEN PATH_MAX
+#else
 #define MAXPATHLEN 1024
+#endif
 #endif /* MAXPATHLEN */
 
 #ifdef UNION_WAIT
index 5c57291459906db2261c46d3673d6f5a9df1e110..967d484b35acbbcb2a7624a23afb5f6c1635e287 100644 (file)
 #endif
 
 #ifndef MAXPATHLEN
+#if defined(PATH_MAX) && PATH_MAX > 1024
+#define MAXPATHLEN PATH_MAX
+#else
 #define MAXPATHLEN 1024
 #endif
+#endif
 
 extern char *getwd(char *);