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
This commit is contained in:
Martin Diehl 2021-02-10 09:07:42 +01:00
parent 5b8e199627
commit ef45e856a1
2 changed files with 7 additions and 3 deletions

@ -1 +1 @@
Subproject commit d90babadfb0a33afa1b793044cc4efd4d7430731
Subproject commit 5d27d879abaeb1542e3f9f3065172be740af2899

View File

@ -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