[flang-commits] [PATCH] D128390: [flang][runtime] Handle READ of non-UTF-8 data into multi-byte CHARACTER
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Jun 22 15:37:39 PDT 2022
klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
When a READ statement reads into a CHARACTER(2 or 4) variable from a
unit whose encoding is not UTF-8, don't copy bytes directly; they must
each be zero-extended.
https://reviews.llvm.org/D128390
Files:
flang/runtime/edit-input.cpp
Index: flang/runtime/edit-input.cpp
===================================================================
--- flang/runtime/edit-input.cpp
+++ flang/runtime/edit-input.cpp
@@ -730,7 +730,17 @@
chunk = 1;
}
--remaining;
- } else {
+ } else if constexpr (sizeof *x > 1) {
+ // Read single byte with expansion into multi-byte CHARACTER
+ chunk = 1;
+ if (skipping) {
+ --skip;
+ } else {
+ *x++ = static_cast<unsigned char>(*input);
+ --length;
+ }
+ --remaining;
+ } else { // single bytes -> default CHARACTER
if (skipping) {
chunk = std::min<std::size_t>(skip, ready);
skip -= chunk;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128390.439187.patch
Type: text/x-patch
Size: 690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220622/856361ff/attachment.bin>
More information about the flang-commits
mailing list