Skip to content

Commit 36f8706

Browse files
committed
char kinds of blank strings.
1 parent 309de97 commit 36f8706

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

src/json_string_utilities.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ subroutine escape_string(str_in, str_out)
333333
!trim the string if necessary:
334334
if (ipos<len(str_out)+1) then
335335
if (ipos==1) then
336-
str_out = ''
336+
str_out = CK_''
337337
else
338338
#if defined __GFORTRAN__
339339
tmp = str_out(1:ipos-1) !workaround for bug in gfortran 6.1
@@ -718,7 +718,7 @@ pure elemental function lowercase_string(str) result(s_lower)
718718
integer :: i !! counter
719719
integer :: n !! length of input string
720720

721-
s_lower = ''
721+
s_lower = CK_''
722722
n = len_trim(str)
723723

724724
if (n>0) then
@@ -754,7 +754,7 @@ pure subroutine replace_string(str,s1,s2)
754754

755755
if (len(str)>0) then
756756

757-
tmp = '' ! initialize
757+
tmp = CK_'' ! initialize
758758
ilen1 = len(s1)
759759

760760
! .

src/json_value_module.F90

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ module json_value_module
175175
integer(IK) :: char_count = 0 !! character position in the current line
176176
integer(IK) :: line_count = 1 !! lines read counter
177177
integer(IK) :: pushed_index = 0 !! used when parsing lines in file
178-
character(kind=CK,len=pushed_char_size) :: pushed_char = '' !! used when parsing
179-
!! lines in file
178+
character(kind=CK,len=pushed_char_size) :: pushed_char = CK_'' !! used when parsing
179+
!! lines in file
180180

181181
integer(IK) :: ipos = 1 !! for allocatable strings: next character to read
182182

@@ -720,7 +720,7 @@ subroutine json_initialize(json,verbose,compact_reals,&
720720

721721
!Just in case, clear these global variables also:
722722
json%pushed_index = 0
723-
json%pushed_char = ''
723+
json%pushed_char = CK_''
724724
json%char_count = 0
725725
json%line_count = 1
726726
json%ipos = 1
@@ -852,7 +852,7 @@ function name_equal(json,p,name) result(is_equal)
852852
end if
853853

854854
else
855-
is_equal = name == '' ! check a blank name
855+
is_equal = name == CK_'' ! check a blank name
856856
end if
857857

858858
end function name_equal
@@ -1010,7 +1010,7 @@ subroutine json_info(json,p,var_type,n_children,name)
10101010
if (allocated(p%name)) then
10111011
name = p%name
10121012
else
1013-
name = ''
1013+
name = CK_''
10141014
end if
10151015
end if
10161016

@@ -1058,7 +1058,7 @@ subroutine json_info_by_path(json,p,path,found,var_type,n_children,name)
10581058
if (.not. ok) then
10591059
if (present(var_type)) var_type = json_unknown
10601060
if (present(n_children)) n_children = 0
1061-
if (present(name)) name = ''
1061+
if (present(name)) name = CK_''
10621062
else
10631063
!get info:
10641064

@@ -1069,7 +1069,7 @@ subroutine json_info_by_path(json,p,path,found,var_type,n_children,name)
10691069
p_name = p_var%name
10701070
name = p_name
10711071
else
1072-
name = ''
1072+
name = CK_''
10731073
end if
10741074
end if
10751075
#else
@@ -1166,7 +1166,7 @@ subroutine json_matrix_info(json,p,is_matrix,var_type,n_sets,set_size,name)
11661166
p_name = p%name
11671167
name = p_name
11681168
else
1169-
name = ''
1169+
name = CK_''
11701170
end if
11711171
end if
11721172
#else
@@ -1286,7 +1286,7 @@ subroutine json_matrix_info_by_path(json,p,path,is_matrix,found,&
12861286
if (present(var_type)) var_type = json_unknown
12871287
if (present(n_sets)) n_sets = 0
12881288
if (present(set_size)) set_size = 0
1289-
if (present(name)) name = ''
1289+
if (present(name)) name = CK_''
12901290
else
12911291

12921292
!get info about the variable:
@@ -1297,7 +1297,7 @@ subroutine json_matrix_info_by_path(json,p,path,is_matrix,found,&
12971297
p_name = p_var%name
12981298
name = p_name
12991299
else
1300-
name = ''
1300+
name = CK_''
13011301
end if
13021302
end if
13031303
#else
@@ -1392,7 +1392,7 @@ pure subroutine json_clear_exceptions(json)
13921392

13931393
!clear the flag and message:
13941394
json%exception_thrown = .false.
1395-
json%err_message = ''
1395+
json%err_message = CK_''
13961396

13971397
end subroutine json_clear_exceptions
13981398
!*****************************************************************************************
@@ -1495,7 +1495,7 @@ subroutine json_check_for_errors(json,status_ok,error_msg)
14951495
error_msg = 'Unknown error.'
14961496
end if
14971497
else
1498-
error_msg = ''
1498+
error_msg = CK_''
14991499
end if
15001500

15011501
end subroutine json_check_for_errors
@@ -2733,7 +2733,7 @@ subroutine json_value_add_double_vec(json, p, name, val)
27332733

27342734
!populate the array:
27352735
do i=1,size(val)
2736-
call json%add(var, '', val(i))
2736+
call json%add(var, CK_'', val(i))
27372737
end do
27382738

27392739
!add it:
@@ -2876,7 +2876,7 @@ subroutine json_value_add_integer_vec(json, p, name, val)
28762876

28772877
!populate the array:
28782878
do i=1,size(val)
2879-
call json%add(var, '', val(i))
2879+
call json%add(var, CK_'', val(i))
28802880
end do
28812881

28822882
!add it:
@@ -2976,7 +2976,7 @@ subroutine json_value_add_logical_vec(json, p, name, val)
29762976

29772977
!populate the array:
29782978
do i=1,size(val)
2979-
call json%add(var, '', val(i))
2979+
call json%add(var, CK_'', val(i))
29802980
end do
29812981

29822982
!add it:
@@ -3139,7 +3139,7 @@ subroutine json_value_add_string_vec(json, p, name, val, trim_str, adjustl_str)
31393139
if (trim_string) str = trim(str)
31403140

31413141
!write it:
3142-
call json%add(var, '', str)
3142+
call json%add(var, CK_'', str)
31433143

31443144
!cleanup
31453145
deallocate(str)
@@ -3506,7 +3506,7 @@ subroutine json_value_to_string(json,p,str)
35063506
type(json_value),pointer,intent(in) :: p
35073507
character(kind=CK,len=:),intent(out),allocatable :: str !! prints structure to this string
35083508

3509-
str = ''
3509+
str = CK_''
35103510
call json%json_value_print(p, iunit=unit2str, str=str, indent=1, colon=.true.)
35113511

35123512
end subroutine json_value_to_string
@@ -3634,7 +3634,7 @@ recursive subroutine json_value_print(json,p,iunit,str,indent,&
36343634

36353635
!if the colon was the last thing written
36363636
if (present(colon)) then
3637-
s = ''
3637+
s = CK_''
36383638
else
36393639
s = repeat(space, spaces)
36403640
end if
@@ -4154,7 +4154,7 @@ subroutine json_get_by_path_rfc6901(json, me, path, p, found)
41544154

41554155
if (islash_curr==ilen) then
41564156
!the last token is an empty string
4157-
token = ''
4157+
token = CK_''
41584158
islash_next = 0 ! will signal to stop
41594159
else
41604160

@@ -4173,7 +4173,7 @@ subroutine json_get_by_path_rfc6901(json, me, path, p, found)
41734173
token = path(islash_curr+1:islash_next-1)
41744174
else
41754175
!empty token:
4176-
token = ''
4176+
token = CK_''
41774177
end if
41784178
end if
41794179

@@ -4323,7 +4323,7 @@ subroutine json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)
43234323
logical(LK) :: parent_is_root !! if the parent is the root
43244324

43254325
!initialize:
4326-
path = ''
4326+
path = CK_''
43274327

43284328
!optional input:
43294329
if (present(use_alt_array_tokens)) then
@@ -4425,7 +4425,7 @@ subroutine json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)
44254425

44264426
!for errors, return blank string:
44274427
if (json%exception_thrown) then
4428-
path = ''
4428+
path = CK_''
44294429
else
44304430
if (json%use_rfc6901_paths) then
44314431
! add the root slash:
@@ -4455,14 +4455,14 @@ subroutine add_to_path(str,dot)
44554455

44564456
if (json%use_rfc6901_paths) then
44574457
! in this case, the options are ignored
4458-
if (path=='') then
4458+
if (path==CK_'') then
44594459
path = str
44604460
else
44614461
path = str//slash//path
44624462
end if
44634463
else
44644464
! default path format
4465-
if (path=='') then
4465+
if (path==CK_'') then
44664466
path = str
44674467
else
44684468
if (present(dot)) then
@@ -5271,7 +5271,7 @@ subroutine json_get_string(json, me, value)
52715271

52725272
character(kind=CK,len=:),allocatable :: error_message !! for [[unescape_string]]
52735273

5274-
value = ''
5274+
value = CK_''
52755275
if (.not. json%exception_thrown) then
52765276

52775277
if (me%var_type == json_string) then
@@ -5282,7 +5282,7 @@ subroutine json_get_string(json, me, value)
52825282
if (allocated(error_message)) then
52835283
call json%throw_exception(error_message)
52845284
deallocate(error_message)
5285-
value = ''
5285+
value = CK_''
52865286
end if
52875287
else
52885288
value = me%str_value
@@ -5373,7 +5373,7 @@ subroutine json_get_string_with_path(json, me, path, value, found)
53735373

53745374
type(json_value),pointer :: p
53755375

5376-
value = ''
5376+
value = CK_''
53775377
if ( json%exception_thrown ) then
53785378
if ( present(found) ) found = .false.
53795379
return
@@ -5476,7 +5476,7 @@ subroutine get_chars_from_array(json, element, i, count)
54765476
vec(i) = cval
54775477
deallocate(cval)
54785478
else
5479-
vec(i) = ''
5479+
vec(i) = CK_''
54805480
end if
54815481

54825482
end subroutine get_chars_from_array
@@ -5532,7 +5532,7 @@ subroutine get_chars_from_array(json, element, i, count)
55325532
vec(i) = cval
55335533
deallocate(cval)
55345534
else
5535-
vec(i) = ''
5535+
vec(i) = CK_''
55365536
end if
55375537

55385538
end subroutine get_chars_from_array
@@ -5876,7 +5876,7 @@ subroutine json_parse_string(json, p, str)
58765876

58775877
! Note: the name of the root json_value doesn't really matter,
58785878
! but we'll allocate something here just in case.
5879-
p%name = ''
5879+
p%name = CK_''
58805880

58815881
! parse as a value
58825882
call json%parse_value(unit=iunit, str=str, value=p)
@@ -5962,7 +5962,7 @@ subroutine annotate_invalid_json(json,iunit,str)
59625962

59635963
else
59645964
!in this case, it was an empty line or file
5965-
line = ''
5965+
line = CK_''
59665966
end if
59675967

59685968
!create the error message:
@@ -5998,7 +5998,7 @@ subroutine get_current_line_from_file_sequential(json,iunit,line)
59985998
integer(IK) :: isize !! number of characters read in read statement
59995999

60006000
!initialize:
6001-
line = ''
6001+
line = CK_''
60026002

60036003
!rewind to beginning of the current record:
60046004
backspace(iunit, iostat=istat)
@@ -6623,7 +6623,7 @@ subroutine to_string(p,val,name)
66236623
if (present(val)) then
66246624
p%str_value = val
66256625
else
6626-
p%str_value = '' !default value
6626+
p%str_value = CK_'' !default value
66276627
end if
66286628

66296629
!name:
@@ -6928,7 +6928,7 @@ subroutine parse_string(json, unit, str, string)
69286928
if (i==4) then
69296929
if (valid_json_hex(hex)) then
69306930
i = 0
6931-
hex = ''
6931+
hex = CK_''
69326932
is_hex = .false.
69336933
else
69346934
call json%throw_exception('Error in parse_string:'//&
@@ -6957,7 +6957,7 @@ subroutine parse_string(json, unit, str, string)
69576957
!trim the string if necessary:
69586958
if (ip<len(string)+1) then
69596959
if (ip==1) then
6960-
string = ''
6960+
string = CK_''
69616961
else
69626962
string = string(1:ip-1)
69636963
end if

0 commit comments

Comments
 (0)