summaryrefslogtreecommitdiffstats
path: root/otherlibs/unix
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/unix')
-rw-r--r--otherlibs/unix/getcwd.c18
-rw-r--r--otherlibs/unix/readlink.c10
2 files changed, 20 insertions, 8 deletions
diff --git a/otherlibs/unix/getcwd.c b/otherlibs/unix/getcwd.c
index 1c7b19f73..f57d68799 100644
--- a/otherlibs/unix/getcwd.c
+++ b/otherlibs/unix/getcwd.c
@@ -15,17 +15,23 @@
#include <alloc.h>
#include "unixsupport.h"
-#ifdef HAS_GETCWD
-
#ifndef _WIN32
#include <sys/param.h>
+#endif
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAN MAXPATHLEN
#else
-#define MAXPATHLEN 512
+#define PATH_MAX 512
+#endif
#endif
+#ifdef HAS_GETCWD
+
value unix_getcwd(value unit) /* ML */
{
- char buff[MAXPATHLEN];
+ char buff[PATH_MAX];
if (getcwd(buff, sizeof(buff)) == 0) uerror("getcwd", Nothing);
return copy_string(buff);
}
@@ -33,11 +39,9 @@ value unix_getcwd(value unit) /* ML */
#else
#ifdef HAS_GETWD
-#include <sys/param.h>
-
value unix_getcwd(value unit)
{
- char buff[MAXPATHLEN];
+ char buff[PATH_MAX];
if (getwd(buff) == 0) uerror("getcwd", copy_string(buff));
return copy_string(buff);
}
diff --git a/otherlibs/unix/readlink.c b/otherlibs/unix/readlink.c
index 885b6243a..2e41cbce8 100644
--- a/otherlibs/unix/readlink.c
+++ b/otherlibs/unix/readlink.c
@@ -19,9 +19,17 @@
#include <sys/param.h>
#include "unixsupport.h"
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAN MAXPATHLEN
+#else
+#define PATH_MAX 512
+#endif
+#endif
+
value unix_readlink(value path) /* ML */
{
- char buffer[MAXPATHLEN];
+ char buffer[PATH_MAX];
int len;
len = readlink(String_val(path), buffer, sizeof(buffer) - 1);
if (len == -1) uerror("readlink", path);