From 1859bb2d0a1aa8e3d04d6964d8920f15dca202e8 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sat, 5 Aug 2000 06:52:14 +0000 Subject: 12548: Tweak 12547. --- Src/compat.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'Src/compat.c') diff --git a/Src/compat.c b/Src/compat.c index f639c8b8a..e9c275df4 100644 --- a/Src/compat.c +++ b/Src/compat.c @@ -133,8 +133,6 @@ zpathmax(char *dir) { long pathmax; - if (!dir || !*dir) - dir = "."; errno = 0; if ((pathmax = pathconf(dir, _PC_PATH_MAX)) >= 0) { /* This code is redundant if pathconf works correctly, but * @@ -152,18 +150,19 @@ zpathmax(char *dir) *tail = 0; pathmax = zpathmax(dir); *tail = '/'; - if (pathmax > 0) { - if (strlen(dir) < pathmax) - return pathmax; - else - errno = ENAMETOOLONG; - } + } else { + errno = 0; + if (tail) + pathmax = pathconf("/", _PC_PATH_MAX); + else + pathmax = pathconf(".", _PC_PATH_MAX); + } + if (pathmax > 0) { + if (strlen(dir) < pathmax) + return pathmax; + else + errno = ENAMETOOLONG; } - /* else * - * Either we're at the root (tail == dir) or we're on the first * - * component of a relative path (tail == NULL). Either way we * - * have nothing to do here, the error from pathconf() is real. * - * Perhaps our current working directory has been removed? */ } if (errno) return -1; -- cgit v1.2.3