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,12 @@ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-function") #if defined(_LIBCPP_WIN32API) -#define PS(x) (L##x) #define PATH_CSTR_FMT "\"%ls\"" #else -#define PS(x) (x) -#define PATH_CSTR_FMT "\"%s\"" +# if !defined(TEXT) +# define TEXT(x) (x) +# endif +# 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 TEXT(""); case PS_InRootDir: if (RawEntry[0] == '\\') - return PS("\\"); + return TEXT("\\"); else - return PS("/"); + return TEXT("/"); case PS_InTrailingSep: - return PS(""); + return TEXT(""); 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 == TEXT(".") || s == TEXT("..") || s.empty()) + return string_view_pair{s, TEXT("")}; 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_ += TEXT("."); } __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 == TEXT(".")) return PK_Dot; - if (Part == PS("..")) + if (Part == TEXT("..")) return PK_DotDot; - if (Part == PS("/")) + if (Part == TEXT("/")) return PK_RootSep; #if defined(_LIBCPP_WIN32API) - if (Part == PS("\\")) + if (Part == TEXT("\\")) 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, TEXT("..")); 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 TEXT("."); // [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 /= TEXT(""); Result.make_preferred(); return Result; @@ -1832,9 +1832,9 @@ int Count = 0; for (; PP; ++PP) { auto Elem = *PP; - if (Elem == PS("..")) + if (Elem == TEXT("..")) --Count; - else if (Elem != PS(".") && Elem != PS("")) + else if (Elem != TEXT(".") && Elem != TEXT("")) ++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 == TEXT(""))) + return TEXT("."); // 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 /= TEXT(".."); for (; PP; ++PP) Result /= *PP; return Result; @@ -1901,9 +1901,7 @@ if (!LHS->inRootName() && !RHS->inRootName()) return 0; - auto GetRootName = [](PathParser *Parser) -> string_view_t { - return Parser->inRootName() ? **Parser : PS(""); - }; + auto GetRootName = [](PathParser* Parser) -> string_view_t { return Parser->inRootName() ? **Parser : TEXT(""); }; int res = GetRootName(LHS).compare(GetRootName(RHS)); ConsumeRootName(LHS); ConsumeRootName(RHS);