Forward fix for MJCF parsing: A recent libc++ update does not natively accept ".x" float format ('.' being the first character) but rather requires "0.x".

PiperOrigin-RevId: 638946382
Change-Id: I3ccb1b5fedc6749a3459916b41148629933fb8c4
This commit is contained in:
Alessio Quaglino
2024-05-31 01:17:08 -07:00
committed by Copybara-Service
parent 0d1c92b20a
commit f616975e28
+10
View File
@@ -481,6 +481,16 @@ bool mjXUtil::ReadAttrValues(XMLElement* elem, const char* attr,
// read numbers
for (int i = 0; (max < 0 || i < max) && !strm.eof(); ++i) {
strm >> token;
// some C++ libraries do not allow .x instead of 0.x
if (!token.empty()) {
if (token[0] == std::string(".")[0]) {
token = "0" + token;
} else if (token[0] == std::string("-")[0] && token[1] == std::string(".")[0]) {
token.insert(1, "0");
}
}
std::istringstream token_strm(token);
token_strm >> item;
if (token_strm.fail() || !token_strm.eof()) {