Skip to content

Commit 8c12e7a

Browse files
Merge pull request #479 from jacobwilliams/477-remove-bug-fix
bug fix in json_value_remove
2 parents 690a8bd + 7df56d4 commit 8c12e7a

12 files changed

+188
-11
lines changed

.VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.2.0
1+
8.2.1

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ builds/
44
build/
55
install/
66
doc/
7+
.vscode/
78

89
*.gcov
910
*.gcov.md*

CHANGELOG.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
- [Change Log](#change-log)
66
- [Unreleased](#unreleased)
7-
- [8.2.0 (2020-08-16)](#800-2020-08-16)
8-
- [8.1.0 (2020-06-21)](#800-2020-06-21)
7+
- [8.2.1 (2021-01-02)](#821-2021-01-02)
8+
- [8.2.0 (2020-08-16)](#820-2020-08-16)
9+
- [8.1.0 (2020-06-21)](#810-2020-06-21)
910
- [8.0.0 (2020-04-04)](#800-2020-04-04)
1011
- [7.1.0 (2019-06-23)](#710-2019-06-23)
1112
- [7.0.0 (2019-01-26)](#700-2019-01-26)
@@ -39,7 +40,22 @@
3940

4041
### [Unreleased](https://github.com/jacobwilliams/json-fortran/tree/HEAD)
4142

42-
[Complete Changeset](https://github.com/jacobwilliams/json-fortran/compare/8.2.0...HEAD)
43+
[Complete Changeset](https://github.com/jacobwilliams/json-fortran/compare/8.2.1...HEAD)
44+
45+
### [8.2.1](https://github.com/jacobwilliams/json-fortran/tree/8.2.1) (2020-01-02)
46+
47+
[Complete Changeset](https://github.com/jacobwilliams/json-fortran/compare/8.2.0...8.2.1)
48+
or [Download v8.2.1](https://github.com/jacobwilliams/json-fortran/releases/tag/8.2.1)
49+
50+
**Enhancements:**
51+
52+
- Fixed a couple compiler warnings when using the latest Intel Fortran compiler. [\#477](https://github.com/jacobwilliams/json-fortran/issues/480) ([jacobwilliams](https://github.com/jacobwilliams))
53+
- replaced `-std15` with `-std18` for the Intel compiler in the FoBiS build file.
54+
- Updated the Visual Studio test project with some missing test cases. ([jacobwilliams](https://github.com/jacobwilliams))
55+
56+
**Bug fixes:**
57+
58+
- Bug fix in `json_value_remove`: the parent and previous pointers should also be nullified when removing from an array. [\#477](https://github.com/jacobwilliams/json-fortran/issues/477) [\#479](https://github.com/jacobwilliams/json-fortran/pull/479) ([jacobwilliams](https://github.com/jacobwilliams))
4359

4460
### [8.2.0](https://github.com/jacobwilliams/json-fortran/tree/8.2.0) (2020-08-16)
4561

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ cmake_minimum_required ( VERSION 2.8.8 FATAL_ERROR )
122122
enable_language ( Fortran )
123123
project ( jf_test NONE )
124124
125-
find_package ( jsonfortran-${CMAKE_Fortran_COMPILER_ID} 8.2.0 REQUIRED )
125+
find_package ( jsonfortran-${CMAKE_Fortran_COMPILER_ID} 8.2.1 REQUIRED )
126126
include_directories ( "${jsonfortran_INCLUDE_DIRS}" )
127127
128128
file ( GLOB JF_TEST_SRCS "src/tests/jf_test_*.F90" )

json-fortran.fobis

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ $SHARED_LIB = libjsonfortran.so
1414
$OPTIMIZE = -O2
1515
$CSTATIC_GNU = -c -fbacktrace -Wall -Wextra -Wno-maybe-uninitialized -Wno-unused-function -pedantic -std=f2008ts
1616
$DEBUG_GNU = -O0 -g3 -Warray-bounds -Wcharacter-truncation -Wline-truncation -Wimplicit-interface -Wimplicit-procedure -Wunderflow -fcheck=all -fmodule-private -ffree-line-length-132 -fimplicit-none -fbacktrace -fdump-core -finit-real=nan -std=f2008ts -fall-intrinsics
17-
$CSTATIC_INT = -c -std15
18-
$DEBUG_INT = -O0 -debug all -check all -warn all -extend-source 132 -traceback -gen-interfaces -fpe-all=0 -fp-stack-check -fstack-protector-all -ftrapuv -no-ftz -std15
17+
$CSTATIC_INT = -c -std18
18+
$DEBUG_INT = -O0 -debug all -check all -warn all -extend-source 132 -traceback -gen-interfaces -fpe-all=0 -fp-stack-check -fstack-protector-all -ftrapuv -no-ftz -std18
1919
$EXCLUDE_DIRS = ./src/tests/introspection
2020
./visual_studio/jsonfortrantest
2121

pages/releases/index.md

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ documentation from the documentation for official releases other than
2525
using the browser's back button. Feel free to bookmark this page, or
2626
the [main project page](|url|/index.html) for convenient navigation.
2727

28+
* [8.2.1](http://jacobwilliams.github.io/json-fortran/8.2.1/index.html)
29+
([FORD](https://github.com/Fortran-FOSS-Programmers/ford) generated documentation)
30+
- [Download](https://github.com/jacobwilliams/json-fortran/releases/tag/8.2.1)
2831
* [8.2.0](http://jacobwilliams.github.io/json-fortran/8.2.0/index.html)
2932
([FORD](https://github.com/Fortran-FOSS-Programmers/ford) generated documentation)
3033
- [Download](https://github.com/jacobwilliams/json-fortran/releases/tag/8.2.0)

src/json_parameters.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module json_parameters
5252
!! [[json_get_by_path_default]]
5353
character(kind=CK,len=*),parameter :: end_array_alt = CK_')' !! alternate end of JSON array for
5454
!! [[json_get_by_path_default]]
55-
character(kind=CK,len=*),parameter :: root = CK_'$' !! root for [[json_get_by_path_default]]
55+
character(kind=CK,len=*),parameter :: root = achar(36, kind=CK) !! (`$`) root for [[json_get_by_path_default]]
5656
character(kind=CK,len=*),parameter :: this = CK_'@' !! 'this' for [[json_get_by_path_default]]
5757
character(kind=CK,len=*),parameter :: dot = CK_'.' !! path separator for [[json_get_by_path_default]]
5858
character(kind=CK,len=*),parameter :: tilde = CK_'~' !! RFC 6901 escape character

src/json_string_utilities.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ end function default_neq_ucs4
809809
!
810810
! Returns lowercase version of the `CK` string.
811811

812-
pure elemental function lowercase_string(str) result(s_lower)
812+
pure function lowercase_string(str) result(s_lower)
813813

814814
implicit none
815815

src/json_value_module.F90

+6-2
Original file line numberDiff line numberDiff line change
@@ -2340,6 +2340,7 @@ end subroutine json_value_destroy
23402340
!
23412341
!### History
23422342
! * Jacob Williams : 12/28/2014 : added destroy optional argument.
2343+
! * Jacob Williams : 12/04/2020 : bug fix.
23432344

23442345
subroutine json_value_remove(json,p,destroy)
23452346

@@ -2374,9 +2375,7 @@ subroutine json_value_remove(json,p,destroy)
23742375
if (associated(p%next)) then
23752376

23762377
!there are later items in the list:
2377-
23782378
next => p%next
2379-
nullify(p%next)
23802379

23812380
if (associated(p%previous)) then
23822381
!there are earlier items in the list
@@ -2404,6 +2403,11 @@ subroutine json_value_remove(json,p,destroy)
24042403

24052404
end if
24062405

2406+
! nullify all pointers to original structure:
2407+
nullify(p%next)
2408+
nullify(p%previous)
2409+
nullify(p%parent)
2410+
24072411
parent%n_children = parent%n_children - 1
24082412

24092413
end if

src/tests/jf_test_47.F90

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
!*****************************************************************************************
2+
!>
3+
! Module for the 47th unit test
4+
5+
module jf_test_47_mod
6+
7+
use json_module, CK => json_CK, IK => json_IK, RK => json_RK, LK => json_LK
8+
use, intrinsic :: iso_fortran_env , only: error_unit, output_unit
9+
10+
implicit none
11+
12+
private
13+
public :: test_47
14+
15+
contains
16+
17+
subroutine test_47(error_cnt)
18+
19+
!! testing of `remove`.
20+
21+
implicit none
22+
23+
integer,intent(out) :: error_cnt !! error counter
24+
25+
character(kind=CK,len=*), parameter :: STR = CK_'&
26+
&{&
27+
& "object1": {&
28+
& "a": 1,&
29+
& "b": 2,&
30+
& "move1": 3,&
31+
& "move2": 4,&
32+
& "e": 5 &
33+
& },&
34+
& "object2": {&
35+
& "f": 10,&
36+
& "g": 11,&
37+
& "h": 12,&
38+
& "i": 13,&
39+
& "j": 14 &
40+
& }&
41+
&}'
42+
43+
character(kind=CK,len=:), allocatable :: errtxt
44+
type(json_core) :: json
45+
type(json_value), pointer :: inp, p, p2
46+
logical(LK) :: found, status_ok
47+
integer(IK) :: ival
48+
49+
write(error_unit,'(A)') ''
50+
write(error_unit,'(A)') '================================='
51+
write(error_unit,'(A)') ' TEST 47'
52+
write(error_unit,'(A)') '================================='
53+
write(error_unit,'(A)') ''
54+
55+
call json%deserialize(inp, STR)
56+
call json%check_for_errors(status_ok, errtxt)
57+
if (.not. status_ok) then
58+
write(error_unit,'(A)') errtxt
59+
error_cnt = error_cnt + 1
60+
else
61+
call json%print(inp)
62+
write(error_unit,'(A)') ''
63+
write(error_unit,'(A)') 'Move object1.move1 to object2 [clone]...'
64+
call json%get(inp, 'object1.move1', p, found)
65+
if (found) then
66+
call json%clone(p, p2)
67+
call json%remove(p, .true.)
68+
call json%add_by_path(inp, 'object2.move1', p2)
69+
end if
70+
write(error_unit,'(A)') ''
71+
call json%print(inp)
72+
write(error_unit,'(A)') ''
73+
call json%get(inp, 'object2.move1', ival, found)
74+
if (.not. found) then
75+
write(error_unit,'(A)') 'Error moving move1'
76+
error_cnt = error_cnt + 1
77+
else
78+
if (ival==3_IK) then
79+
write(error_unit,'(A)') '...Success'
80+
else
81+
write(error_unit,'(A,1X,I5)') 'Invalid move1 value: ', ival
82+
error_cnt = error_cnt + 1
83+
end if
84+
end if
85+
86+
write(error_unit,'(A)') ''
87+
write(error_unit,'(A)') 'Move object1.move2 to object2...'
88+
89+
call json%get(inp, 'object1.move2', p, found)
90+
if (found) then
91+
call json%remove(p, .false.)
92+
call json%add_by_path(inp, 'object2.move2', p)
93+
end if
94+
write(error_unit,'(A)') ''
95+
call json%print(inp)
96+
write(error_unit,'(A)') ''
97+
call json%get(inp, 'object2.move2', ival, found)
98+
if (.not. found) then
99+
write(error_unit,'(A)') 'Error moving move2'
100+
error_cnt = error_cnt + 1
101+
else
102+
if (ival==4_IK) then
103+
write(error_unit,'(A)') '...Success'
104+
else
105+
write(error_unit,'(A,1X,I5)') 'Invalid move2 value: ', ival
106+
error_cnt = error_cnt + 1
107+
end if
108+
end if
109+
110+
call json%check_for_errors(status_ok, errtxt)
111+
if (.not. status_ok) then
112+
write(error_unit,'(A)') errtxt
113+
error_cnt = error_cnt + 1
114+
end if
115+
116+
end if
117+
118+
write(error_unit,'(A)') ''
119+
if (error_cnt==0) then
120+
write(error_unit,'(A)') 'Success!'
121+
else
122+
write(error_unit,'(A)') 'Failed!'
123+
end if
124+
write(error_unit,'(A)') ''
125+
126+
end subroutine test_47
127+
128+
end module jf_test_47_mod
129+
!*****************************************************************************************
130+
131+
#ifndef INTEGRATED_TESTS
132+
!*****************************************************************************************
133+
program jf_test_47
134+
135+
!! 47th unit test.
136+
137+
use jf_test_47_mod , only: test_47
138+
implicit none
139+
integer :: n_errors
140+
n_errors = 0
141+
call test_47(n_errors)
142+
if (n_errors /= 0) stop 1
143+
144+
end program jf_test_47
145+
!*****************************************************************************************
146+
#endif

visual_studio/jsonfortrantest/jsonfortrantest.f90

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ program jsonfortrantest
4949
use jf_test_40_mod , only: test_40
5050
use jf_test_41_mod , only: test_41
5151
use jf_test_42_mod , only: test_42
52+
use jf_test_43_mod , only: test_43
53+
use jf_test_44_mod , only: test_44
54+
use jf_test_45_mod , only: test_45
55+
use jf_test_46_mod , only: test_46
56+
use jf_test_47_mod , only: test_47
5257

5358
implicit none
5459

@@ -102,6 +107,7 @@ program jsonfortrantest
102107
call test_44(n_errors); if (n_errors /= 0) stop 1
103108
call test_45(n_errors); if (n_errors /= 0) stop 1
104109
call test_46(n_errors); if (n_errors /= 0) stop 1
110+
call test_47(n_errors); if (n_errors /= 0) stop 1
105111

106112
end program jsonfortrantest
107113
!*****************************************************************************************

visual_studio/jsonfortrantest/jsonfortrantest.vfproj

+1
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,6 @@
9292
<File RelativePath="..\..\src\tests\jf_test_44.F90"/>
9393
<File RelativePath="..\..\src\tests\jf_test_45.F90"/>
9494
<File RelativePath="..\..\src\tests\jf_test_46.F90"/>
95+
<File RelativePath="..\..\src\tests\jf_test_47.F90"/>
9596
<File RelativePath=".\jsonfortrantest.f90"/></Filter></Files>
9697
<Globals/></VisualStudioProject>

0 commit comments

Comments
 (0)