@@ -698,9 +698,9 @@ subroutine json_file_load_from_string(me, str)
698698
699699 class(json_file),intent (inout ) :: me
700700 character (kind= CK,len=* ),intent (in ) :: str
701-
701+
702702 call json_parse(str= str, p= me% p)
703-
703+
704704 end subroutine json_file_load_from_string
705705! *****************************************************************************************
706706
@@ -3979,7 +3979,7 @@ subroutine json_parse(file, p, unit, str)
39793979
39803980 ! clear any exceptions and initialize:
39813981 call json_initialize()
3982-
3982+
39833983 if (present (unit) .and. present (file) .and. .not. present (str)) then
39843984
39853985 if (unit== 0 ) then
@@ -4217,8 +4217,8 @@ recursive subroutine parse_value(unit, str, value)
42174217 select case (value% var_type)
42184218 case (json_string)
42194219 call parse_string(unit, str, tmp) ! write to a tmp variable because of
4220- value% str_value = tmp ! a bug in 4.9 gfortran compiler.
4221- deallocate (tmp)
4220+ value% str_value = tmp ! a bug in 4.9 gfortran compiler.
4221+ deallocate (tmp) !
42224222 end select
42234223
42244224 case (true_str(1 :1 ))
@@ -4778,7 +4778,7 @@ recursive subroutine parse_object(unit, str, parent)
47784778 else if (quotation_mark == c) then
47794779 call json_value_create(pair)
47804780 call parse_string(unit, str, tmp) ! write to a tmp variable because of
4781- pair % name = tmp ! a bug in 4.9 gfortran compiler.
4781+ pair % name = tmp ! a bug in 4.9 gfortran compiler.
47824782 deallocate (tmp)
47834783 if (exception_thrown) then
47844784 call json_destroy(pair)
@@ -4810,8 +4810,8 @@ recursive subroutine parse_object(unit, str, parent)
48104810 return
48114811 end if
48124812
4813- ! another possible pair
4814- c = pop_char(unit, str= str, eof = eof, skip_ws = .true. )
4813+ ! another possible pair
4814+ c = pop_char(unit, str= str, eof = eof, skip_ws = .true. )
48154815 if (eof) then
48164816 call throw_exception(' Error in parse_object: ' // &
48174817 ' End of file encountered when parsing an object' )
@@ -4938,7 +4938,7 @@ subroutine parse_string(unit, str, string)
49384938
49394939 ! get the next character from the file:
49404940 c = pop_char(unit, str= str, eof = eof, skip_ws = .false. )
4941-
4941+
49424942 if (eof) then
49434943
49444944 call throw_exception(' Error in parse_string: Expecting end of string' )
@@ -5174,6 +5174,7 @@ recursive function pop_char(unit, str, eof, skip_ws) result(popped)
51745174 character (kind= CK,len= 1 ) :: c
51755175 logical (LK) :: ignore
51765176 integer (IK) :: str_len
5177+ character (kind= CK,len= :),allocatable :: tmp ! workaround for bug in gfortran 4.9.2 compiler
51775178
51785179 if (.not. exception_thrown) then
51795180
@@ -5197,14 +5198,17 @@ recursive function pop_char(unit, str, eof, skip_ws) result(popped)
51975198 if (unit/= 0 ) then ! read from the file
51985199 read (unit = unit, fmt = ' (A1)' , advance = ' NO' , iostat = ios) c
51995200 else ! read from the string
5200- str_len = len (str) ! length of the string
5201+ tmp = str ! !! copy to a temp variable to workaround a bug in gfortran 4.9.2
5202+ str_len = len (tmp) ! length of the string
52015203 if (str_len> 0 ) then
5202- c = str (1 :1 )
5204+ c = tmp (1 :1 )
52035205 if (str_len> 1 ) then
5204- str = str (2 :str_len) ! remove the character that was read
5206+ tmp = tmp (2 :str_len) ! remove the character that was read
52055207 else
5206- str = ' ' ! that was the last one
5208+ tmp = ' ' ! that was the last one
52075209 end if
5210+ str = tmp
5211+ deallocate (tmp) ! !!
52085212 ios = 0
52095213 else
52105214 ios = IOSTAT_END ! end of the string
0 commit comments