Skip to content

Commit 4682c7c

Browse files
committed
minor changes to avoid using uninitialized variables in some unusual cases.
1 parent ee21405 commit 4682c7c

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/json_module.F90

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ module json_module
301301
! DESCRIPTION
302302
! If Unicode is not enabled, then
303303
! JSON files are opened using access='STREAM' and
304-
! form='UNFORMATTED'. This allows the file to
304+
! form='UNFORMATTED'. This allows the file to
305305
! be read faster.
306306
!
307307
! SEE ALSO
@@ -325,7 +325,7 @@ module json_module
325325
! DESCRIPTION
326326
! If Unicode is not enabled, then
327327
! JSON files are opened using access='STREAM' and
328-
! form='UNFORMATTED'. This allows the file to
328+
! form='UNFORMATTED'. This allows the file to
329329
! be read faster.
330330
!
331331
! SEE ALSO
@@ -349,7 +349,7 @@ module json_module
349349
! DESCRIPTION
350350
! If Unicode is not enabled, then
351351
! JSON files are opened using access='STREAM' and
352-
! form='UNFORMATTED'. This allows the file to
352+
! form='UNFORMATTED'. This allows the file to
353353
! be read faster.
354354
!
355355
! SEE ALSO
@@ -4810,6 +4810,8 @@ function string_to_integer(str) result(ival)
48104810
' string cannot be converted to an integer: '//trim(str))
48114811
end if
48124812

4813+
else
4814+
ival = 0
48134815
end if
48144816

48154817
end function string_to_integer
@@ -6363,6 +6365,7 @@ subroutine annotate_invalid_json(iunit,str)
63636365
!get the current line from the string:
63646366
! [this is done by counting the newline characters]
63656367
i_nl_prev = 0 !index of previous newline character
6368+
i_nl = 2 !just in case line_count = 0
63666369
do i=1,line_count
63676370
i_nl = index(str(i_nl_prev+1:),newline)
63686371
if (i_nl==0) then !last line - no newline character
@@ -6466,12 +6469,12 @@ subroutine get_current_line_from_file_stream(iunit,line)
64666469
integer(IK) :: istart,iend,ios
64676470
character(kind=CK,len=1) :: c
64686471

6469-
!....update for the new STREAM version.....
6470-
6472+
!....update for the new STREAM version.....
6473+
64716474
! !!! !!!! not quite right for EXAMPLE 6 case 2 ..... DOUBLE CHECK THIS...
64726475

64736476
istart = ipos
6474-
do
6477+
do
64756478
if (istart<=1) then
64766479
istart = 1
64776480
exit
@@ -7576,15 +7579,16 @@ subroutine parse_string(unit, str, string)
75767579

75777580
end do
75787581

7579-
end if
75807582

7581-
!trim the string if necessary:
7582-
if (ip<len(string)+1) then
7583-
if (ip==1) then
7584-
string = ''
7585-
else
7586-
string = string(1:ip-1)
7583+
!trim the string if necessary:
7584+
if (ip<len(string)+1) then
7585+
if (ip==1) then
7586+
string = ''
7587+
else
7588+
string = string(1:ip-1)
7589+
end if
75877590
end if
7591+
75887592
end if
75897593

75907594
end subroutine parse_string
@@ -7840,7 +7844,7 @@ recursive function pop_char(unit, str, eof, skip_ws) result(popped)
78407844
ipos = ipos + 1
78417845

78427846
!....note: maybe try read the file in chunks...
7843-
!.... or use asynchronous read with double buffering
7847+
!.... or use asynchronous read with double buffering
78447848
! (see Modern Fortran: Style and Usage)
78457849

78467850
else !read from the string

0 commit comments

Comments
 (0)