@@ -2431,6 +2431,20 @@ static bool isAbsolutePath(const std::string &path)
24312431}
24322432#endif
24332433
2434+ namespace {
2435+ // "<Pkg/Hdr.h>" -> "<Pkg.framework/Headers/Hdr.h>"
2436+ static inline std::string
2437+ toAppleFrameworkRelative (const std::string& header)
2438+ {
2439+ const std::size_t slash = header.find (' /' );
2440+ if (slash == std::string::npos)
2441+ return header; // no transformation applicable
2442+ const std::string pkg = header.substr (0 , slash);
2443+ const std::string tail = header.substr (slash); // includes '/'
2444+ return pkg + " .framework/Headers" + tail;
2445+ }
2446+ }
2447+
24342448namespace simplecpp {
24352449 /* *
24362450 * perform path simplifications for . and ..
@@ -3008,20 +3022,10 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const
30083022 return path;
30093023 }
30103024
3011- // a named lambda function to insert the ".framework/Headers" part for apple frameworks
3012- auto get_apple_framework_relative_path= [](const std::string& appleFrameworkHeader) -> std::string {
3013- // try the Framework path on apple OS, if there is a path in front
3014- const size_t slashPos = appleFrameworkHeader.find (' /' );
3015- if (slashPos == std::string::npos) {
3016- return appleFrameworkHeader;
3017- }
3018- constexpr auto frameworkSuffix{ " .framework/Headers" };
3019- return appleFrameworkHeader.substr (0 , slashPos) + frameworkSuffix + appleFrameworkHeader.substr (slashPos);
3020- };
30213025 // on Apple, try to find the header in the framework path
30223026 // Convert <includePath>/PKGNAME/myHeader -> <includePath>/PKGNAME.framework/Headers/myHeader
30233027 // Works on any platform, but only relevant when compiling against Apple SDKs.
3024- const std::string appleFrameworkHeader = get_apple_framework_relative_path (header);
3028+ const std::string appleFrameworkHeader = toAppleFrameworkRelative (header);
30253029 if (appleFrameworkHeader != header) {
30263030 for (const auto & includePath: dui.includePaths ) {
30273031 const std::string frameworkCandidatePath = includePath + ' /' + appleFrameworkHeader;
0 commit comments