src/ini_parser.f90: handle inline comments and whitespace
While the Fortran read statement will ignore whitespace and ignored remaining tokens, these are problematic when manually parsing the INI values.
This commit is contained in:
parent
73bd010458
commit
fa89439994
@ -112,6 +112,10 @@ contains
|
|||||||
cycle
|
cycle
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
! remove possible inline comments
|
||||||
|
sep = index(line, comment_sign, back=.true.)
|
||||||
|
if (sep /= 0) line = line(1:sep-1)
|
||||||
|
|
||||||
! split line at separator (ex. name<here>=value)
|
! split line at separator (ex. name<here>=value)
|
||||||
sep = index(line, property_sep)
|
sep = index(line, property_sep)
|
||||||
if (sep == 0) then
|
if (sep == 0) then
|
||||||
@ -120,8 +124,12 @@ contains
|
|||||||
error = ERR_SYNTAX
|
error = ERR_SYNTAX
|
||||||
exit
|
exit
|
||||||
end if
|
end if
|
||||||
name = trim(line(1:sep - 1))
|
name = line(1:sep - 1)
|
||||||
value = trim(line(sep + 1:))
|
value = line(sep + 1:)
|
||||||
|
|
||||||
|
! remove leading/trailing whitespace
|
||||||
|
name = trim(adjustl(name))
|
||||||
|
value = trim(adjustl(value))
|
||||||
|
|
||||||
! call the handler
|
! call the handler
|
||||||
select case (handler(section, name, value))
|
select case (handler(section, name, value))
|
||||||
|
Loading…
Reference in New Issue
Block a user