]> git.lyx.org Git - features.git/commitdiff
Backport r39333 to fix bug #7467: PATH_MAX related build failure on GNU/Hurd.
authorJohn C. McCabe-Dansted <cmd@lyx.org>
Tue, 19 Jul 2011 04:14:09 +0000 (04:14 +0000)
committerJohn C. McCabe-Dansted <cmd@lyx.org>
Tue, 19 Jul 2011 04:14:09 +0000 (04:14 +0000)
(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

src/support/filetools.cpp
status.20x

index dbf91ee59e10c7fd89e45e1a6f40b13b2727b776..dc4e3cd5bd922fc48142ed4f537265e4536c4136 100644 (file)
@@ -49,6 +49,7 @@
 #include <utility>
 #include <fstream>
 #include <sstream>
+#include <vector>
 
 #if defined (_WIN32)
 #include <io.h>
@@ -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<char> 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;
 }
index 5fe307bfa1d36f5b18c4183225d71ceaa17222c7..42929c988ed225cc4f06e8d1bdc1cddb588eae4d 100644 (file)
@@ -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).