@@ -500,9 +500,6 @@ module json_module
500
500
MAYBEWRAP(json_file_get_logical_vec), &
501
501
MAYBEWRAP(json_file_get_string_vec)
502
502
503
-
504
-
505
-
506
503
generic,public :: update = > MAYBEWRAP(json_file_update_integer), &
507
504
MAYBEWRAP(json_file_update_logical), &
508
505
MAYBEWRAP(json_file_update_real), &
@@ -1437,7 +1434,7 @@ subroutine json_file_print_2(me,filename)
1437
1434
1438
1435
implicit none
1439
1436
1440
- class(json_file),intent (inout ) :: me
1437
+ class(json_file),intent (inout ) :: me
1441
1438
character (kind= CDK,len=* ),intent (in ) :: filename
1442
1439
1443
1440
integer (IK) :: iunit,istat
@@ -6351,32 +6348,39 @@ subroutine annotate_invalid_json(iunit,str)
6351
6348
6352
6349
! draw the arrow string that points to the current character:
6353
6350
arrow_str = repeat (' -' ,max ( 0 , char_count - 1 ) )// ' ^'
6351
+
6352
+ if (line_count> 0 .and. char_count> 0 ) then
6354
6353
6355
- if (iunit/= 0 ) then
6354
+ if (iunit/= 0 ) then
6355
+
6356
+ if (use_unformatted_stream) then
6357
+ call get_current_line_from_file_stream(iunit,line)
6358
+ else
6359
+ call get_current_line_from_file_sequential(iunit,line)
6360
+ end if
6356
6361
6357
- if (use_unformatted_stream) then
6358
- call get_current_line_from_file_stream(iunit,line)
6359
6362
else
6360
- call get_current_line_from_file_sequential(iunit,line)
6361
- end if
6362
6363
6363
- else
6364
+ ! get the current line from the string:
6365
+ ! [this is done by counting the newline characters]
6366
+ i_nl_prev = 0 ! index of previous newline character
6367
+ i_nl = 2 ! just in case line_count = 0
6368
+ do i= 1 ,line_count
6369
+ i_nl = index (str(i_nl_prev+1 :),newline)
6370
+ if (i_nl== 0 ) then ! last line - no newline character
6371
+ i_nl = len (str)+ 1
6372
+ exit
6373
+ end if
6374
+ i_nl = i_nl + i_nl_prev ! index of current newline character
6375
+ i_nl_prev = i_nl ! update for next iteration
6376
+ end do
6377
+ line = str(i_nl_prev+1 : i_nl-1 ) ! extract current line
6364
6378
6365
- ! get the current line from the string:
6366
- ! [this is done by counting the newline characters]
6367
- i_nl_prev = 0 ! index of previous newline character
6368
- i_nl = 2 ! just in case line_count = 0
6369
- do i= 1 ,line_count
6370
- i_nl = index (str(i_nl_prev+1 :),newline)
6371
- if (i_nl== 0 ) then ! last line - no newline character
6372
- i_nl = len (str)+ 1
6373
- exit
6374
- end if
6375
- i_nl = i_nl + i_nl_prev ! index of current newline character
6376
- i_nl_prev = i_nl ! update for next iteration
6377
- end do
6378
- line = str(i_nl_prev+1 : i_nl-1 ) ! extract current line
6379
+ end if
6379
6380
6381
+ else
6382
+ ! in this case, it was an empty line or file
6383
+ line = ' '
6380
6384
end if
6381
6385
6382
6386
! create the error message:
@@ -6469,9 +6473,7 @@ subroutine get_current_line_from_file_stream(iunit,line)
6469
6473
integer (IK) :: istart,iend,ios
6470
6474
character (kind= CK,len= 1 ) :: c
6471
6475
6472
- ! ....update for the new STREAM version.....
6473
-
6474
- ! !!! !!!! not quite right for EXAMPLE 6 case 2 ..... DOUBLE CHECK THIS...
6476
+ ! updated for the new STREAM version:
6475
6477
6476
6478
istart = ipos
6477
6479
do
0 commit comments