I've added patch to berlios for realpath()
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=2564&group_id=5358This allows realpath() to correctly handle paths with more than one symlink and paths with symlinks to symlinks when the path is absolute.
Index: globals.cpp
===================================================================
--- globals.cpp (revision 5206)
+++ globals.cpp (working copy)
@@ -1027,6 +1027,7 @@
if (S_ISLNK(buffer.st_mode))
{
int s = readlink(ret.substr(0, slashPos).c_str(), buf, sizeof(buf));
+ buf[s] = 0;
if (s > 0 && buf[0] != '/' && buf[0] != '~')
{
// relative
@@ -1036,6 +1037,11 @@
{
// absolute
ret = buf + ret.substr(slashPos, ret.size() - slashPos);
+
+ // start again at the beginning in case the path returned also
+ // has symlinks. For example if using /etc/alternatives this will
+ // be the case
+ s = 0;
}
slashPos = s;
}
gryphon