[flang-commits] [flang] cbbc662 - [flang][runtime] Ignore leading spaces even in BZ mode
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Apr 22 12:32:34 PDT 2022
Author: Peter Klausler
Date: 2022-04-22T12:27:19-07:00
New Revision: cbbc66290044be2e2031f86a8c650b6951529d7d
URL: https://github.com/llvm/llvm-project/commit/cbbc66290044be2e2031f86a8c650b6951529d7d
DIFF: https://github.com/llvm/llvm-project/commit/cbbc66290044be2e2031f86a8c650b6951529d7d.diff
LOG: [flang][runtime] Ignore leading spaces even in BZ mode
When editing numeric input, always skip leading spaces, even if
BZ mode (or BLANK='ZERO') is in effect; otherwise, a sign character
preceded by blanks will not be recognized.
Differential Revision: https://reviews.llvm.org/D124278
Added:
Modified:
flang/runtime/edit-input.cpp
flang/runtime/io-stmt.h
Removed:
################################################################################
diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index d7cace7b34c3f..04db2e58e4820 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -58,15 +58,12 @@ static inline char32_t GetDecimalPoint(const DataEdit &edit) {
// Returns true if there's a '-' sign.
static bool ScanNumericPrefix(IoStatementState &io, const DataEdit &edit,
std::optional<char32_t> &next, std::optional<int> &remaining) {
- bool bzMode{(edit.modes.editingFlags & blankZero) != 0};
- next = io.PrepareInput(edit, remaining, !bzMode);
+ next = io.PrepareInput(edit, remaining);
bool negative{false};
if (next) {
negative = *next == '-';
if (negative || *next == '+') {
- if (!bzMode) {
- io.SkipSpaces(remaining);
- }
+ io.SkipSpaces(remaining);
next = io.NextInField(remaining, edit);
}
}
diff --git a/flang/runtime/io-stmt.h b/flang/runtime/io-stmt.h
index b076d06e14ab9..4dcc147a8d210 100644
--- a/flang/runtime/io-stmt.h
+++ b/flang/runtime/io-stmt.h
@@ -133,8 +133,8 @@ class IoStatementState {
// For fixed-width fields, initialize the number of remaining characters.
// Skip over leading blanks, then return the first non-blank character (if
// any).
- std::optional<char32_t> PrepareInput(const DataEdit &edit,
- std::optional<int> &remaining, bool skipSpaces = true) {
+ std::optional<char32_t> PrepareInput(
+ const DataEdit &edit, std::optional<int> &remaining) {
remaining.reset();
if (edit.descriptor == DataEdit::ListDirected) {
std::size_t byteCount{0};
@@ -143,9 +143,7 @@ class IoStatementState {
if (edit.width.value_or(0) > 0) {
remaining = *edit.width;
}
- if (skipSpaces) {
- SkipSpaces(remaining);
- }
+ SkipSpaces(remaining);
}
return NextInField(remaining, edit);
}
More information about the flang-commits
mailing list