diff --git a/libcxx/src/filesystem/filesystem_common.h b/libcxx/src/filesystem/filesystem_common.h --- a/libcxx/src/filesystem/filesystem_common.h +++ b/libcxx/src/filesystem/filesystem_common.h @@ -49,11 +49,11 @@ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-function") #if defined(_LIBCPP_WIN32API) -#define PS(x) (L##x) -#define PATH_CSTR_FMT "\"%ls\"" +# define PATHSTR(x) (L##x) +# define PATH_CSTR_FMT "\"%ls\"" #else -#define PS(x) (x) -#define PATH_CSTR_FMT "\"%s\"" +# define PATHSTR(x) (x) +# define PATH_CSTR_FMT "\"%s\"" #endif _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp --- a/libcxx/src/filesystem/operations.cpp +++ b/libcxx/src/filesystem/operations.cpp @@ -214,14 +214,14 @@ switch (State) { case PS_BeforeBegin: case PS_AtEnd: - return PS(""); + return PATHSTR(""); case PS_InRootDir: if (RawEntry[0] == '\\') - return PS("\\"); + return PATHSTR("\\"); else - return PS("/"); + return PATHSTR("/"); case PS_InTrailingSep: - return PS(""); + return PATHSTR(""); case PS_InRootName: case PS_InFilenames: return RawEntry; @@ -387,8 +387,8 @@ }; string_view_pair separate_filename(string_view_t const& s) { - if (s == PS(".") || s == PS("..") || s.empty()) - return string_view_pair{s, PS("")}; + if (s == PATHSTR(".") || s == PATHSTR("..") || s.empty()) + return string_view_pair{s, PATHSTR("")}; auto pos = s.find_last_of('.'); if (pos == string_view_t::npos || pos == 0) return string_view_pair{s, string_view_t{}}; @@ -1616,7 +1616,7 @@ } if (!replacement.empty()) { if (replacement.native()[0] != '.') { - __pn_ += PS("."); + __pn_ += PATHSTR("."); } __pn_.append(replacement.__pn_); } @@ -1738,14 +1738,14 @@ static PathPartKind ClassifyPathPart(string_view_t Part) { if (Part.empty()) return PK_TrailingSep; - if (Part == PS(".")) + if (Part == PATHSTR(".")) return PK_Dot; - if (Part == PS("..")) + if (Part == PATHSTR("..")) return PK_DotDot; - if (Part == PS("/")) + if (Part == PATHSTR("/")) return PK_RootSep; #if defined(_LIBCPP_WIN32API) - if (Part == PS("\\")) + if (Part == PATHSTR("\\")) return PK_RootSep; #endif return PK_Filename; @@ -1795,7 +1795,7 @@ NewPathSize -= Parts.back().first.size(); Parts.pop_back(); } else if (LastKind != PK_RootSep) - AddPart(PK_DotDot, PS("..")); + AddPart(PK_DotDot, PATHSTR("..")); MaybeNeedTrailingSep = LastKind == PK_Filename; break; } @@ -1810,7 +1810,7 @@ } // [fs.path.generic]p6.8: If the path is empty, add a dot. if (Parts.empty()) - return PS("."); + return PATHSTR("."); // [fs.path.generic]p6.7: If the last filename is dot-dot, remove any // trailing directory-separator. @@ -1822,7 +1822,7 @@ Result /= PK.first; if (NeedTrailingSep) - Result /= PS(""); + Result /= PATHSTR(""); Result.make_preferred(); return Result; @@ -1832,9 +1832,9 @@ int Count = 0; for (; PP; ++PP) { auto Elem = *PP; - if (Elem == PS("..")) + if (Elem == PATHSTR("..")) --Count; - else if (Elem != PS(".") && Elem != PS("")) + else if (Elem != PATHSTR(".") && Elem != PATHSTR("")) ++Count; } return Count; @@ -1881,15 +1881,15 @@ return {}; // if n == 0 and (a == end() || a->empty()), returns path("."); otherwise - if (ElemCount == 0 && (PP.atEnd() || *PP == PS(""))) - return PS("."); + if (ElemCount == 0 && (PP.atEnd() || *PP == PATHSTR(""))) + return PATHSTR("."); // return a path constructed with 'n' dot-dot elements, followed by the the // elements of '*this' after the mismatch. path Result; // FIXME: Reserve enough room in Result that it won't have to re-allocate. while (ElemCount--) - Result /= PS(".."); + Result /= PATHSTR(".."); for (; PP; ++PP) Result /= *PP; return Result; @@ -1902,7 +1902,7 @@ return 0; auto GetRootName = [](PathParser *Parser) -> string_view_t { - return Parser->inRootName() ? **Parser : PS(""); + return Parser->inRootName() ? **Parser : PATHSTR(""); }; int res = GetRootName(LHS).compare(GetRootName(RHS)); ConsumeRootName(LHS);