diff -r -c -N ../Ice-3.5.1/cpp/include/Slice/Util.h ./cpp/include/Slice/Util.h *** ../Ice-3.5.1/cpp/include/Slice/Util.h 2013-10-04 17:48:14.000000000 +0200 --- ./cpp/include/Slice/Util.h 2014-11-11 17:16:27.043681177 +0100 *************** *** 27,33 **** SLICE_API void emitRaw(const char*); SLICE_API std::vector filterMcppWarnings(const std::string&); SLICE_API void printGeneratedHeader(IceUtilInternal::Output& out, const std::string&, const std::string& commentStyle = "//"); ! } #endif --- 27,33 ---- SLICE_API void emitRaw(const char*); SLICE_API std::vector filterMcppWarnings(const std::string&); SLICE_API void printGeneratedHeader(IceUtilInternal::Output& out, const std::string&, const std::string& commentStyle = "//"); ! SLICE_API std::string normalizePath(const std::string&); } #endif diff -r -c -N ../Ice-3.5.1/cpp/src/Slice/Parser.cpp ./cpp/src/Slice/Parser.cpp *** ../Ice-3.5.1/cpp/src/Slice/Parser.cpp 2013-10-04 17:48:14.000000000 +0200 --- ./cpp/src/Slice/Parser.cpp 2014-11-11 17:17:08.967682982 +0100 *************** *** 9,14 **** --- 9,15 ---- #include #include + #include #include #include #include *************** *** 19,24 **** --- 20,28 ---- #ifdef _WIN32 # include + #else + # include // For PATH_MAX + # include // For readlink() #endif using namespace std; *************** *** 5657,5662 **** --- 5661,5716 ---- _currentLine++; } + #ifndef _WIN32 + namespace + { + string + readLink(const string& orig) + { + string result = orig; + string::size_type beg = 0; + string::size_type next = string::npos; + do + { + string subpath; + next = result.find('/', beg + 1); + if(next == string::npos) + { + subpath = result; + } + else + { + subpath = result.substr(0, next); + } + + char buf[PATH_MAX + 1]; + int len = static_cast(readlink(subpath.c_str(), buf, sizeof(buf))); + if(len > 0) + { + buf[len] = '\0'; + string linkpath = buf; + if(!IceUtilInternal::isAbsolutePath(linkpath)) // Path relative to the location of the link + { + string::size_type pos = subpath.rfind('/'); + assert(pos != string::npos); + linkpath = subpath.substr(0, pos + 1) + linkpath; + } + result = normalizePath(linkpath) + (next != string::npos ? result.substr(next) : string()); + beg = 0; + next = 0; + } + else + { + beg = next; + } + } + while(next != string::npos); + return result; + } + + } + #endif + bool Slice::Unit::scanPosition(const char* s) { *************** *** 5702,5707 **** --- 5756,5771 ---- LineType type = File; + // + // We need to compare the file targets as one could be a symbolic link. + // + #ifndef _WIN32 + if(readLink(currentFile) == readLink(_topLevelFile)) + { + currentFile = _topLevelFile; + } + #endif + if(_currentLine == 0) { if(_currentIncludeLevel > 0 || currentFile != _topLevelFile) diff -r -c -N ../Ice-3.5.1/cpp/src/Slice/Util.cpp ./cpp/src/Slice/Util.cpp *** ../Ice-3.5.1/cpp/src/Slice/Util.cpp 2013-10-04 17:48:14.000000000 +0200 --- ./cpp/src/Slice/Util.cpp 2014-11-11 17:15:43.335679294 +0100 *************** *** 18,28 **** using namespace std; using namespace Slice; - namespace - { - string ! normalizePath(const string& path) { string result = path; --- 18,25 ---- using namespace std; using namespace Slice; string ! Slice::normalizePath(const string& path) { string result = path; *************** *** 78,85 **** return result; } - } - string Slice::fullPath(const string& path) { --- 75,80 ---- *************** *** 93,143 **** } } ! result = normalizePath(result); ! ! #ifdef _WIN32 ! return result; ! #else ! ! string::size_type beg = 0; ! string::size_type next; ! do ! { ! string subpath; ! next = result.find('/', beg + 1); ! if(next == string::npos) ! { ! subpath = result; ! } ! else ! { ! subpath = result.substr(0, next); ! } ! ! char buf[PATH_MAX + 1]; ! int len = static_cast(readlink(subpath.c_str(), buf, sizeof(buf))); ! if(len > 0) ! { ! buf[len] = '\0'; ! string linkpath = buf; ! if(!IceUtilInternal::isAbsolutePath(linkpath)) // Path relative to the location of the link ! { ! string::size_type pos = subpath.rfind('/'); ! assert(pos != string::npos); ! linkpath = subpath.substr(0, pos + 1) + linkpath; ! } ! result = normalizePath(linkpath) + (next != string::npos ? result.substr(next) : string()); ! beg = 0; ! next = 0; ! } ! else ! { ! beg = next; ! } ! } ! while(next != string::npos); ! return result; ! #endif } string --- 88,94 ---- } } ! return normalizePath(result); } string