[flang-commits] [flang] [flang][runtime] Extension: allow a comma to terminate a fixed input … (PR #76768)

via flang-commits flang-commits at lists.llvm.org
Tue Jan 2 16:18:23 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-runtime

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

…field

When a comma appears in a fixed-width input field for integer editing, many compilers accept it without error and interpret the comma as terminating the field early.

---
Full diff: https://github.com/llvm/llvm-project/pull/76768.diff


2 Files Affected:

- (modified) flang/docs/Extensions.md (+2) 
- (modified) flang/runtime/edit-input.cpp (+4) 


``````````diff
diff --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md
index 16eb67f2e27c81..b56ebe6a92bbcf 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -318,6 +318,8 @@ end
 * A `NAMELIST` input group may omit its trailing `/` character if
   it is followed by another `NAMELIST` input group.
 * A `NAMELIST` input group may begin with either `&` or `$`.
+* A comma in a fixed-width integer input field terminates the
+  field rather than signaling an invalid character error.
 
 ### Extensions supported when enabled by options
 
diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index 6d4fa588cbf60d..5d47b146488158 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -80,6 +80,8 @@ static bool EditBOZInput(
     } else if (LOG2_BASE >= 4 && ch >= '8' && ch <= '9') {
     } else if (LOG2_BASE >= 4 && ch >= 'A' && ch <= 'F') {
     } else if (LOG2_BASE >= 4 && ch >= 'a' && ch <= 'f') {
+    } else if (ch == ',') {
+      break; // end non-list-directed field early
     } else {
       io.GetIoErrorHandler().SignalError(
           "Bad character '%lc' in B/O/Z input field", ch);
@@ -214,6 +216,8 @@ bool EditIntegerInput(
     int digit{0};
     if (ch >= '0' && ch <= '9') {
       digit = ch - '0';
+    } else if (ch == ',') {
+      break; // end non-list-directed field early
     } else {
       io.GetIoErrorHandler().SignalError(
           "Bad character '%lc' in INTEGER input field", ch);

``````````

</details>


https://github.com/llvm/llvm-project/pull/76768


More information about the flang-commits mailing list