From: John C. McCabe-Dansted Date: Tue, 19 Jul 2011 04:14:09 +0000 (+0000) Subject: Backport r39333 to fix bug #7467: PATH_MAX related build failure on GNU/Hurd. X-Git-Tag: 2.0.1~90 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6a60ef8ab4eafc5e4c6a925c863bdfd81f6a77cb;p=features.git Backport r39333 to fix bug #7467: PATH_MAX related build failure on GNU/Hurd. (Patch from Pino, adapted for trunk by Sven) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@39342 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index dbf91ee59e..dc4e3cd5bd 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #if defined (_WIN32) #include @@ -795,13 +796,31 @@ docstring const makeDisplayPath(string const & path, unsigned int threshold) #ifdef HAVE_READLINK bool readLink(FileName const & file, FileName & link) { - char linkbuffer[PATH_MAX + 1]; string const encoded = file.toFilesystemEncoding(); +#ifdef HAVE_DEF_PATH_MAX + char linkbuffer[PATH_MAX + 1]; int const nRead = ::readlink(encoded.c_str(), linkbuffer, sizeof(linkbuffer) - 1); if (nRead <= 0) return false; linkbuffer[nRead] = '\0'; // terminator +#else + vector buf(1024); + int nRead = -1; + + while (true) { + nRead = ::readlink(encoded.c_str(), &buf[0], buf.size() - 1); + if (nRead < 0) { + return false; + } + if (nRead < buf.size() - 1) { + break; + } + buf.resize(buf.size() * 2); + } + buf[nRead] = '\0'; // terminator + const char * linkbuffer = &buf[0]; +#endif link = makeAbsPath(linkbuffer, onlyPath(file.absFileName())); return true; } diff --git a/status.20x b/status.20x index 5fe307bfa1..42929c988e 100644 --- a/status.20x +++ b/status.20x @@ -273,3 +273,5 @@ What's new - Using pkgconfig to configure hunspell (hunspell 1.3 was not correctly recognized). + +- Fixed build failure on GNU/Hurd, which doesn't define PATH_MAX (bug #7467).