@@ -10064,6 +10064,7 @@ subroutine get_current_line_from_file_stream(json,iunit,line)
10064
10064
integer (IK) :: iend ! ! end position of current line
10065
10065
integer (IK) :: ios ! ! file read `iostat` code
10066
10066
character (kind= CK,len= 1 ) :: c ! ! a character read from the file
10067
+ logical :: done ! ! flag to exit the loop
10067
10068
10068
10069
istart = json% ipos
10069
10070
do
@@ -10072,7 +10073,9 @@ subroutine get_current_line_from_file_stream(json,iunit,line)
10072
10073
exit
10073
10074
end if
10074
10075
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
10076
10079
if (istart/= 1 ) istart = istart - 1
10077
10080
exit
10078
10081
end if
@@ -10895,7 +10898,7 @@ recursive subroutine parse_object(json, unit, str, parent)
10895
10898
skip_comments= json% allow_comments, popped= c)
10896
10899
if (eof) then
10897
10900
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.' )
10899
10902
return
10900
10903
else if (end_object == c) then
10901
10904
! end of an empty object
@@ -10922,8 +10925,9 @@ recursive subroutine parse_object(json, unit, str, parent)
10922
10925
call json% pop_char(unit, str= str, eof= eof, skip_ws= .true. , &
10923
10926
skip_comments= json% allow_comments, popped= c)
10924
10927
if (eof) then
10928
+ call json% destroy(pair)
10925
10929
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.' )
10927
10931
return
10928
10932
else if (colon_char == c) then
10929
10933
! parse the value
@@ -10935,6 +10939,7 @@ recursive subroutine parse_object(json, unit, str, parent)
10935
10939
call json% add(parent, pair)
10936
10940
end if
10937
10941
else
10942
+ call json% destroy(pair)
10938
10943
call json% throw_exception(' Error in parse_object:' // &
10939
10944
' Expecting : and then a value: ' // c)
10940
10945
return
@@ -10945,7 +10950,7 @@ recursive subroutine parse_object(json, unit, str, parent)
10945
10950
skip_comments= json% allow_comments, popped= c)
10946
10951
if (eof) then
10947
10952
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' )
10949
10954
return
10950
10955
else if (delimiter == c) then
10951
10956
! read the next member
0 commit comments