Skip to content

Commit 4d4bab8

Browse files
Tal500Tal Hadad
authored andcommitted
more fixes
1 parent 89377e6 commit 4d4bab8

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

simplecpp.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,15 +3173,17 @@ static std::string openHeader(std::ifstream &f, const std::string &path)
31733173
template <bool expandBaseWithAbsolutePath, bool exactRelative>
31743174
static std::string getRelativeFileName(const std::string &baseFile, const std::string &header)
31753175
{
3176-
const std::string baseFileNormalized = (expandBaseWithAbsolutePath && !isAbsolutePath(baseFile)) ? (currentDirectory() + "/" + baseFile) : baseFile;
3177-
const std::string path = isAbsolutePath(header) ? header : (dirPath<true>(baseFileNormalized) + header);
3178-
const std::string simplifiedPath = simplecpp::simplifyPath(path);
3176+
const std::string baseFileSimplified = simplecpp::simplifyPath(baseFile);
3177+
const std::string baseFileNormalized = (expandBaseWithAbsolutePath && !isAbsolutePath(baseFileSimplified)) ? (currentDirectory() + "/" + baseFileSimplified) : baseFileSimplified;
3178+
3179+
const std::string headerSimplified = simplecpp::simplifyPath(header);
3180+
const std::string path = isAbsolutePath(headerSimplified) ? headerSimplified : (dirPath<true>(baseFileNormalized) + headerSimplified);
31793181
if (exactRelative) {
3180-
const std::string absolutePath = expandBaseWithAbsolutePath ? simplifiedPath : toAbsolutePath(simplifiedPath);
3182+
const std::string absolutePath = expandBaseWithAbsolutePath ? path : toAbsolutePath(path);
31813183
const std::string absoluteBaseFile = expandBaseWithAbsolutePath ? baseFileNormalized : toAbsolutePath(baseFileNormalized);
31823184
return extractRelativePathFromAbsolute(absolutePath, dirPath<true>(absoluteBaseFile));
31833185
}
3184-
return simplifiedPath;
3186+
return path;
31853187
}
31863188

31873189
static std::string openHeaderRelative(std::ifstream &f, const std::string &sourcefile, const std::string &header)

0 commit comments

Comments
 (0)