From 8eca5916a7534b3cb25a84501cadc1f056ceb8d8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 5 Sep 2017 15:42:16 +0200 Subject: Do not consider gl.h a system include file (all platforms) Amends db904f8e9ed06eac37151c9a8b955c63c1eb8a46 to apply to all platforms since the issue is also present on Linux. Task-number: PYSIDE-516 Change-Id: I564506f6aefc26e95beae90d95643553eba5dbff Reviewed-by: Alexandru Croitor --- .../ApiExtractor/clangparser/clangbuilder.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index 9fff9af8b..ea6559689 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -514,11 +514,28 @@ Builder::~Builder() delete d; } +static inline bool compareHeaderName(const char *haystack, const char *needle) +{ + const char *lastSlash = strrchr(haystack, '/'); +#ifdef Q_OS_WIN + if (lastSlash == nullptr) + lastSlash = strrchr(haystack, '\\'); +#endif + if (lastSlash == nullptr) + lastSlash = haystack; + else + ++lastSlash; +#ifdef Q_OS_WIN + return _stricmp(lastSlash, needle) == 0; +#else + return strcmp(lastSlash, needle) == 0; +#endif +} + bool Builder::visitLocation(const CXSourceLocation &location) const { if (clang_Location_isInSystemHeader(location) == 0) return true; -#ifdef Q_OS_WIN CXFile file; // void * unsigned line; unsigned column; @@ -528,12 +545,11 @@ bool Builder::visitLocation(const CXSourceLocation &location) const // Has been observed to be 0 for invalid locations if (const char *cFileName = clang_getCString(cxFileName)) { // Resolve OpenGL typedefs although the header is considered a system header. - const bool visitHeader = _stricmp(cFileName, "GL/gl.h") || _stricmp(cFileName, "gl.h") == 0; + const bool visitHeader = compareHeaderName(cFileName, "gl.h"); clang_disposeString(cxFileName); if (visitHeader) return true; } -#endif // Q_OS_WIN return false; } -- cgit v1.2.3