[libc++] Rename PS() macro to avoid clashing with Xtensa register name
This patch addresses a clash with the PS register from Xtensa
defined in the <specreg.h> header file, which is commonly included in
OS implementation.
Issue identified while building libc++ port for Apache NuttX, targeting
Xtensa-based chips (e.g. Espressif's ESP32).
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
Differential Revision: https://reviews.llvm.org/D122479
NOKEYCHECK=True
GitOrigin-RevId: 4fe6a5d69a61ac59c6b06af93d7093130533ffe1
diff --git a/src/filesystem/operations.cpp b/src/filesystem/operations.cpp
index 7392b83..562cd8b 100644
--- a/src/filesystem/operations.cpp
+++ b/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);