@@ -10064,6 +10064,7 @@ subroutine get_current_line_from_file_stream(json,iunit,line)
1006410064 integer (IK) :: iend ! ! end position of current line
1006510065 integer (IK) :: ios ! ! file read `iostat` code
1006610066 character (kind= CK,len= 1 ) :: c ! ! a character read from the file
10067+ logical :: done ! ! flag to exit the loop
1006710068
1006810069 istart = json% ipos
1006910070 do
@@ -10072,7 +10073,9 @@ subroutine get_current_line_from_file_stream(json,iunit,line)
1007210073 exit
1007310074 end if
1007410075 read (iunit,pos= istart,iostat= ios) c
10075- if (c== newline .or. ios/= 0 ) then
10076+ done = ios /= 0_IK
10077+ if (.not. done) done = c== newline
10078+ if (done) then
1007610079 if (istart/= 1 ) istart = istart - 1
1007710080 exit
1007810081 end if
@@ -10895,7 +10898,7 @@ recursive subroutine parse_object(json, unit, str, parent)
1089510898 skip_comments= json% allow_comments, popped= c)
1089610899 if (eof) then
1089710900 call json% throw_exception(' Error in parse_object:' // &
10898- ' Unexpected end of file while parsing start of object.' )
10901+ ' Unexpected end of file while parsing start of object.' )
1089910902 return
1090010903 else if (end_object == c) then
1090110904 ! end of an empty object
@@ -10922,8 +10925,9 @@ recursive subroutine parse_object(json, unit, str, parent)
1092210925 call json% pop_char(unit, str= str, eof= eof, skip_ws= .true. , &
1092310926 skip_comments= json% allow_comments, popped= c)
1092410927 if (eof) then
10928+ call json% destroy(pair)
1092510929 call json% throw_exception(' Error in parse_object:' // &
10926- ' Unexpected end of file while parsing object member.' )
10930+ ' Unexpected end of file while parsing object member.' )
1092710931 return
1092810932 else if (colon_char == c) then
1092910933 ! parse the value
@@ -10935,6 +10939,7 @@ recursive subroutine parse_object(json, unit, str, parent)
1093510939 call json% add(parent, pair)
1093610940 end if
1093710941 else
10942+ call json% destroy(pair)
1093810943 call json% throw_exception(' Error in parse_object:' // &
1093910944 ' Expecting : and then a value: ' // c)
1094010945 return
@@ -10945,7 +10950,7 @@ recursive subroutine parse_object(json, unit, str, parent)
1094510950 skip_comments= json% allow_comments, popped= c)
1094610951 if (eof) then
1094710952 call json% throw_exception(' Error in parse_object: ' // &
10948- ' End of file encountered when parsing an object' )
10953+ ' End of file encountered when parsing an object' )
1094910954 return
1095010955 else if (delimiter == c) then
1095110956 ! read the next member
0 commit comments