[flang-commits] [PATCH] D84078: [flang] Treat tabs like spaces in formatted input.

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Jul 17 17:20:24 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG8305a92a4752: [flang] Treat tabs like spaces in formatted input. (authored by klausler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84078

Files:
  flang/runtime/edit-input.cpp
  flang/runtime/io-stmt.cpp


Index: flang/runtime/io-stmt.cpp
===================================================================
--- flang/runtime/io-stmt.cpp
+++ flang/runtime/io-stmt.cpp
@@ -353,7 +353,7 @@
     std::optional<int> &remaining) {
   while (!remaining || *remaining > 0) {
     if (auto ch{GetCurrentChar()}) {
-      if (*ch != ' ') {
+      if (*ch != ' ' && *ch != '\t') {
         return ch;
       }
       HandleRelativePosition(1);
@@ -373,6 +373,7 @@
     if (auto next{GetCurrentChar()}) {
       switch (*next) {
       case ' ':
+      case '\t':
       case ',':
       case ';':
       case '/':
@@ -415,7 +416,7 @@
 
 std::optional<char32_t> IoStatementState::GetNextNonBlank() {
   auto ch{GetCurrentChar()};
-  while (ch.value_or(' ') == ' ') {
+  while (!ch || *ch == ' ' || *ch == '\t') {
     if (ch) {
       HandleRelativePosition(1);
     } else if (!AdvanceRecord()) {
@@ -485,7 +486,8 @@
     if (!imaginaryPart_) {
       edit.repeat = std::min<int>(remaining_, maxRepeat);
       auto ch{io.GetNextNonBlank()};
-      if (!ch || *ch == ' ' || *ch == comma) { // "r*" repeated null
+      if (!ch || *ch == ' ' || *ch == '\t' || *ch == comma) {
+        // "r*" repeated null
         edit.descriptor = DataEdit::ListDirectedNullValue;
       }
     }
@@ -554,7 +556,7 @@
         edit.descriptor = DataEdit::ListDirectedNullValue;
         return edit;
       }
-      if (!ch || *ch == ' ' || *ch == comma) { // "r*" null
+      if (!ch || *ch == ' ' || *ch == '\t' || *ch == comma) { // "r*" null
         edit.descriptor = DataEdit::ListDirectedNullValue;
       }
       edit.repeat = std::min<int>(r, maxRepeat);
Index: flang/runtime/edit-input.cpp
===================================================================
--- flang/runtime/edit-input.cpp
+++ flang/runtime/edit-input.cpp
@@ -34,7 +34,7 @@
   common::UnsignedInt128 value{0};
   for (; next; next = io.NextInField(remaining)) {
     char32_t ch{*next};
-    if (ch == ' ') {
+    if (ch == ' ' || ch == '\t') {
       continue;
     }
     int digit{0};
@@ -101,7 +101,7 @@
   common::UnsignedInt128 value;
   for (; next; next = io.NextInField(remaining)) {
     char32_t ch{*next};
-    if (ch == ' ') {
+    if (ch == ' ' || ch == '\t') {
       if (edit.modes.editingFlags & blankZero) {
         ch = '0'; // BZ mode - treat blank as if it were zero
       } else {
@@ -170,7 +170,7 @@
   } else if (*next == decimal || (*next >= '0' && *next <= '9')) {
     for (; next; next = io.NextInField(remaining)) {
       char32_t ch{*next};
-      if (ch == ' ') {
+      if (ch == ' ' || ch == '\t') {
         if (edit.modes.editingFlags & blankZero) {
           ch = '0'; // BZ mode - treat blank as if it were zero
         } else {
@@ -229,7 +229,7 @@
     return 0;
   }
   if (remaining) {
-    while (next && *next == ' ') {
+    while (next && (*next == ' ' || *next == '\t')) {
       next = io.NextInField(remaining);
     }
     if (next) {
@@ -386,6 +386,7 @@
        next = io.NextInField(remaining)) {
     switch (*next) {
     case ' ':
+    case '\t':
     case ',':
     case ';':
     case '/':


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84078.278941.patch
Type: text/x-patch
Size: 3095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200718/16305a8d/attachment.bin>


More information about the flang-commits mailing list