PATH_MAX is not guaranteed by POSIX (fixes bug #6906).

Patch from Samuel Thibault.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35452 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2010-09-19 21:29:09 +00:00
parent 0b17cb1135
commit 1291b07c05

View File

@ -297,9 +297,16 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode)
string real_path(string const & path)
{
#ifdef __GLIBC__
char * result = realpath(path.c_str(), NULL);
string ret = FileName::fromFilesystemEncoding(result ? result : path).absFileName();
free(result);
return ret;
#else
char rpath[PATH_MAX + 1];
char * result = realpath(path.c_str(), rpath);
return FileName::fromFilesystemEncoding(result ? rpath : path).absFileName();
#endif
}
} // namespace os