From 20186a40791f662696857720d414dd7cd2ace8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 10 Feb 2010 15:55:50 +0000 Subject: [PATCH] Don't rely on `PATH_MAX' on GNU. --- src/libutil/util.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libutil/util.cc b/src/libutil/util.cc index bb17fa5f6..8c52625a2 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; }