Skip to content

Commit 05dc7f6

Browse files
Merge pull request #465 from jacobwilliams/unicode-assignment
added unicode support for assignment
2 parents 42f9052 + e1b1814 commit 05dc7f6

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/json_file_module.F90

+21-4
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ module json_file_module
246246

247247
generic,public :: assignment(=) => assign_json_file,&
248248
assign_json_file_to_string,&
249-
assign_string_to_json_file
249+
MAYBEWRAP(assign_string_to_json_file)
250250
procedure :: assign_json_file
251251
procedure,pass(me) :: assign_json_file_to_string
252-
procedure :: assign_string_to_json_file
252+
procedure :: MAYBEWRAP(assign_string_to_json_file)
253253

254254
! ***************************************************
255255
! private routines
@@ -1167,7 +1167,7 @@ subroutine assign_json_file_to_string(str,me)
11671167
type(json_core) :: core_copy !! a copy of `core` from `me`
11681168

11691169
if (me%core%failed() .or. .not. associated(me%p)) then
1170-
str = ''
1170+
str = CK_''
11711171
else
11721172

11731173
! This is sort of a hack. Since `me` has to have `intent(in)`
@@ -1179,7 +1179,7 @@ subroutine assign_json_file_to_string(str,me)
11791179
core_copy = me%core ! copy the parser settings
11801180

11811181
call core_copy%serialize(me%p,str)
1182-
if (me%core%failed()) str = ''
1182+
if (me%core%failed()) str = CK_''
11831183

11841184
end if
11851185

@@ -1206,6 +1206,23 @@ subroutine assign_string_to_json_file(me,str)
12061206
end subroutine assign_string_to_json_file
12071207
!*****************************************************************************************
12081208

1209+
!*****************************************************************************************
1210+
!> author: Jacob Williams
1211+
!
1212+
! Alternate version of [[assign_string_to_json_file]], where "str" is kind=CDK.
1213+
1214+
subroutine wrap_assign_string_to_json_file(me,str)
1215+
1216+
implicit none
1217+
1218+
class(json_file),intent(inout) :: me
1219+
character(kind=CDK,len=*),intent(in) :: str
1220+
1221+
call me%assign_string_to_json_file(to_unicode(str))
1222+
1223+
end subroutine wrap_assign_string_to_json_file
1224+
!*****************************************************************************************
1225+
12091226
!*****************************************************************************************
12101227
!> author: Jacob Williams
12111228
!

src/tests/jf_test_46.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ subroutine test_46(error_cnt)
259259
end if
260260

261261
! now, we try them when an exception is active:
262-
json_f = CK_'{"x": 1.0e.2.1}' ! this will raise an exception
262+
json_f = '{"x": 1.0e.2.1}' ! this will raise an exception
263263
if (.not. json_f%failed()) then
264264
write(error_unit,'(A)') 'Error in json_file = string assignment operator : '//&
265265
'should have raised an exception'

0 commit comments

Comments
 (0)