about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2010-02-10T15·55+0000
committerLudovic Courtès <ludo@gnu.org>2010-02-10T15·55+0000
commit20186a40791f662696857720d414dd7cd2ace8a2 (patch)
tree374bd1340492d77fa86e728c617b29d2e43bf909
parentd0bf4adb1f8c72640c9e80dee30f96e173dfab87 (diff)
Don't rely on `PATH_MAX' on GNU.
-rw-r--r--src/libutil/util.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index bb17fa5f66ca..8c52625a2531 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -53,10 +53,20 @@ Path absPath(Path path, Path dir)
 {
     if (path[0] != '/') {
         if (dir == "") {
+#ifdef __GNU__
+            /* GNU (aka. GNU/Hurd) doesn't have any limitation on path
+               lengths and doesn't define `PATH_MAX'.  */
+            char *buf = getcwd(NULL, 0);
+            if (buf == NULL)
+#else
             char buf[PATH_MAX];
             if (!getcwd(buf, sizeof(buf)))
+#endif
                 throw SysError("cannot get cwd");
             dir = buf;
+#ifdef __GNU__
+            free(buf);
+#endif
         }
         path = dir + "/" + path;
     }