[flang-commits] [PATCH] D83104: [flang] External I/O runtime work, repackaged (part 2)

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Jul 2 17:50:19 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e958c1748a9: [flang] External I/O runtime work, repackaged (part 2) (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83104/new/

https://reviews.llvm.org/D83104

Files:
  flang/runtime/edit-input.cpp


Index: flang/runtime/edit-input.cpp
===================================================================
--- flang/runtime/edit-input.cpp
+++ flang/runtime/edit-input.cpp
@@ -13,14 +13,24 @@
 
 namespace Fortran::runtime::io {
 
+static std::optional<char32_t> PrepareInput(
+    IoStatementState &io, const DataEdit &edit, std::optional<int> &remaining) {
+  remaining.reset();
+  if (edit.descriptor == DataEdit::ListDirected) {
+    io.GetNextNonBlank();
+  } else {
+    if (edit.width.value_or(0) > 0) {
+      remaining = *edit.width;
+    }
+    io.SkipSpaces(remaining);
+  }
+  return io.NextInField(remaining);
+}
+
 static bool EditBOZInput(IoStatementState &io, const DataEdit &edit, void *n,
     int base, int totalBitSize) {
   std::optional<int> remaining;
-  if (edit.width) {
-    remaining = std::max(0, *edit.width);
-  }
-  io.SkipSpaces(remaining);
-  std::optional<char32_t> next{io.NextInField(remaining)};
+  std::optional<char32_t> next{PrepareInput(io, edit, remaining)};
   common::UnsignedInt128 value{0};
   for (; next; next = io.NextInField(remaining)) {
     char32_t ch{*next};
@@ -54,14 +64,7 @@
 // Returns false if there's a '-' sign
 static bool ScanNumericPrefix(IoStatementState &io, const DataEdit &edit,
     std::optional<char32_t> &next, std::optional<int> &remaining) {
-  if (edit.descriptor != DataEdit::ListDirected && edit.width) {
-    remaining = std::max(0, *edit.width);
-  } else {
-    // list-directed, namelist, or (nonstandard) 0-width input editing
-    remaining.reset();
-  }
-  io.SkipSpaces(remaining);
-  next = io.NextInField(remaining);
+  next = PrepareInput(io, edit, remaining);
   bool negative{false};
   if (next) {
     negative = *next == '-';
@@ -310,11 +313,7 @@
     return false;
   }
   std::optional<int> remaining;
-  if (edit.width) {
-    remaining = std::max(0, *edit.width);
-  }
-  io.SkipSpaces(remaining);
-  std::optional<char32_t> next{io.NextInField(remaining)};
+  std::optional<char32_t> next{PrepareInput(io, edit, remaining)};
   if (next && *next == '.') { // skip optional period
     next = io.NextInField(remaining);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83104.275268.patch
Type: text/x-patch
Size: 2120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200703/4205ce49/attachment.bin>


More information about the flang-commits mailing list