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:
Michele Guerini Rocco 2024-01-29 01:03:13 +01:00
parent 73bd010458
commit fa89439994
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

View File

@ -112,6 +112,10 @@ contains
cycle
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)
sep = index(line, property_sep)
if (sep == 0) then
@ -120,8 +124,12 @@ contains
error = ERR_SYNTAX
exit
end if
name = trim(line(1:sep - 1))
value = trim(line(sep + 1:))
name = line(1:sep - 1)
value = line(sep + 1:)
! remove leading/trailing whitespace
name = trim(adjustl(name))
value = trim(adjustl(value))
! call the handler
select case (handler(section, name, value))