functionmatch_keyprivate
logical function match_key(line, key, value)
True if line is key: value, indented by at most three blanks.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| line | character(len=*) | in | the line | |
| key | character(len=:) | out | allocatable | the key, in lowercase |
| value | character(len=:) | out | allocatable | the value |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| match_key | logical |
Calls
Source
Show the code
logical function match_key(line, key, value)
character(len=*), intent(in) :: line !! the line
character(len=:), allocatable, intent(out) :: key !! the key, in lowercase
character(len=:), allocatable, intent(out) :: value !! the value
character(len=*), parameter :: KEY_CHARS = &
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-'
integer :: a, b
match_key = .false.
a = leading_blanks(line) + 1
if (a > 4 .or. a > len(line)) return
b = verify(line(a:), KEY_CHARS)
if (b <= 1) return
b = a + b - 1
if (line(b:b) /= ':') return
key = lowercase(line(a:b - 1))
value = strip(line(b + 1:))
match_key = .true.
end function match_key