From 8745f421b4cf7e1d54c17a360d46fab889ca12cc Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 15:33:17 +0000 Subject: feat(input)!: validate INPUT and read whole lines into STRING Scalar INPUT now reads one whitespace-delimited token through module-local IR helpers instead of scanf, then skips spaces and tabs and consumes one newline. INTEGER, REAL, BOOLEAN (TRUE or FALSE in any case) and CHAR are validated, and bad input or end of input is a runtime error. STRING INPUT reads the rest of the line. The unused scanf and REAL printf format globals are removed. Co-Authored-By: Claude Sonnet 5.5 --- tests/ii/strings/reference.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/ii/strings/reference.cc') diff --git a/tests/ii/strings/reference.cc b/tests/ii/strings/reference.cc index 54d6efc..ec67b8c 100644 --- a/tests/ii/strings/reference.cc +++ b/tests/ii/strings/reference.cc @@ -8,7 +8,10 @@ int main() { for (int i = 0; i < count; ++i) { int empty, start, width; std::string text; - if (!(std::cin >> empty >> text >> start >> width)) return 1; + if (!(std::cin >> empty >> start >> width)) return 1; + // The text is the rest of the line, as for INPUT into a STRING. + if (!std::getline(std::cin >> std::ws, text)) return 1; + if (!text.empty() && text.back() == '\r') text.pop_back(); if (empty) text.clear(); auto lower = text, upper = text; for (auto &c : lower) c = static_cast(std::tolower(static_cast(c))); -- cgit v1.3.1-4-g156e