Source: lyx
Version: 2.0.0~rc3-1
Severity: important
Tags: patch
User: [email protected]
Hi,
the new lyx 2.0.0~rc3 carries the fix for #597279, but introduces a new
unconditional PATH_MAX usage in src/support/filetools.cpp, see [1].
Attached there is a patch fixing this new PATH_MAX usage.
[1]
https://buildd.debian.org/status/fetch.php?pkg=lyx&arch=hurd-i386&ver=2.0.0%7Erc3-1&stamp=1302560138
Thanks,
--
Pino
--- a/src/support/filetools.cpp
+++ b/src/support/filetools.cpp
@@ -49,6 +49,7 @@
#include <utility>
#include <fstream>
#include <sstream>
+#include <vector>
#if defined (_WIN32)
#include <io.h>
@@ -759,13 +760,31 @@
#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;
}