Skip to content

Commit c480ca1

Browse files
committed
enable check for child node in toml, not only string values
1 parent e9cddad commit c480ca1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/fpm/toml.f90

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ subroutine check_keys(table, valid_keys, error)
123123
type(error_t), allocatable, intent(out) :: error
124124

125125
type(toml_key), allocatable :: keys(:)
126+
type(toml_table), pointer :: child
126127
character(:), allocatable :: name, value, valid_keys_string
127128
integer :: ikey, ivalid
128129

@@ -143,12 +144,18 @@ subroutine check_keys(table, valid_keys, error)
143144
end if
144145

145146
! Check if value can be mapped or else (wrong type) show error message with the error location.
146-
! Right now, it can only be mapped to a string, but this can be extended in the future.
147+
! Right now, it can only be mapped to a string or to a child node, but this can be extended in the future.
147148
call get_value(table, keys(ikey)%key, value)
148149
if (.not. allocated(value)) then
149-
allocate (error)
150-
error%message = "'"//name//"' has an invalid '"//keys(ikey)%key//"' entry."
151-
return
150+
151+
! If value is not a string, check if it is a child node
152+
call get_value(table, keys(ikey)%key, child)
153+
154+
if (.not.associated(child)) then
155+
allocate (error)
156+
error%message = "'"//name//"' has an invalid '"//keys(ikey)%key//"' entry."
157+
return
158+
endif
152159
end if
153160
end do
154161

0 commit comments

Comments
 (0)