From ef45e856a15cb1f265b08f5c8934a8fc28ad6489 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 10 Feb 2021 09:07:42 +0100 Subject: [PATCH] don't scan the whole file in case of proper line endings might lead to strange behavior if people randomly distribute CRs in their file. But that actually deserves to get strange behavior + Test --- PRIVATE | 2 +- src/IO.f90 | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/PRIVATE b/PRIVATE index d90babadf..5d27d879a 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit d90babadfb0a33afa1b793044cc4efd4d7430731 +Subproject commit 5d27d879abaeb1542e3f9f3065172be740af2899 diff --git a/src/IO.f90 b/src/IO.f90 index 33ab7ee97..36b774191 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -124,7 +124,9 @@ function IO_read(fileName) result(fileContent) integer :: & fileLength, & fileUnit, & - myStat + myStat, & + firstEOL + character, parameter :: CR = achar(13) inquire(file = fileName, size=fileLength) @@ -141,10 +143,12 @@ function IO_read(fileName) result(fileContent) if(myStat /= 0) call IO_error(102,ext_msg=trim(fileName)) close(fileUnit) - if(scan(fileContent,achar(13)) /= 0) call IO_error(115) if(fileContent(fileLength:fileLength) /= IO_EOL) fileContent = fileContent//IO_EOL ! ensure EOL@EOF + firstEOL = index(fileContent,IO_EOL) + if(scan(fileContent(firstEOL:firstEOL),CR) /= 0) call IO_error(115) + end function IO_read