diff --git a/flang/include/flang/Parser/characters.h b/flang/include/flang/Parser/characters.h --- a/flang/include/flang/Parser/characters.h +++ b/flang/include/flang/Parser/characters.h @@ -58,6 +58,13 @@ return IsLegalIdentifierStart(ch) || IsDecimalDigit(ch); } +inline constexpr bool IsPrintable(char ch) { return ch >= ' ' && ch <= '~'; } + +inline constexpr bool IsWhiteSpace(char ch) { + return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\v' || ch == '\f' || + ch == '\r'; +} + inline constexpr char ToLowerCaseLetter(char ch) { return IsUpperCaseLetter(ch) ? ch - 'A' + 'a' : ch; } diff --git a/flang/lib/Parser/token-parsers.h b/flang/lib/Parser/token-parsers.h --- a/flang/lib/Parser/token-parsers.h +++ b/flang/lib/Parser/token-parsers.h @@ -19,7 +19,6 @@ #include "flang/Parser/characters.h" #include "flang/Parser/instrumented-parser.h" #include "flang/Parser/provenance.h" -#include #include #include #include @@ -526,7 +525,7 @@ int chBytes{UTF_8CharacterBytes(state.GetLocation())}; for (int bytes{chBytes}; bytes > 0; --bytes) { if (std::optional at{nextCh.Parse(state)}) { - if (chBytes == 1 && !std::isprint(**at)) { + if (chBytes == 1 && !IsPrintable(**at)) { state.Say(start, "Bad character in Hollerith"_err_en_US); return std::nullopt; } diff --git a/flang/lib/Semantics/resolve-labels.cpp b/flang/lib/Semantics/resolve-labels.cpp --- a/flang/lib/Semantics/resolve-labels.cpp +++ b/flang/lib/Semantics/resolve-labels.cpp @@ -11,7 +11,6 @@ #include "flang/Common/template.h" #include "flang/Parser/parse-tree-visitor.h" #include "flang/Semantics/semantics.h" -#include #include #include @@ -926,7 +925,7 @@ std::size_t i{1l}; for (; (i < maxPosition) && parser::IsDecimalDigit(position[i]); ++i) { } - for (; (i < maxPosition) && std::isspace(position[i]); ++i) { + for (; (i < maxPosition) && parser::IsWhiteSpace(position[i]); ++i) { } return parser::CharBlock{position.begin() + i, position.end()}; }