mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
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
This commit is contained in:
parent
6467f4657a
commit
6a60ef8ab4
@ -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;
|
||||
}
|
||||
|
@ -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).
|
||||
|
Loading…
Reference in New Issue
Block a user