fortrangoingonforty/fortty / 3ab4723

Browse files

Fix TOML parser treating hex colors as comments

The parser was removing quotes before handling inline comments,
causing "#FFFFFF" to become "#FFFFFF" which was then truncated
at the "#" as if it were a comment. Now calls remove_inline_comment
first, which correctly preserves "#" inside quoted strings.
Authored by espadonne
SHA
3ab47235dd4666efa1eedf7d5c90854a4ef8ed35
Parents
896305f
Tree
3b64feb

1 changed file

StatusFile+-
M src/config/toml_parser.f90 5 4
src/config/toml_parser.f90modified
@@ -114,8 +114,12 @@ contains
114114
     integer :: len_val
115115
 
116116
     value = adjustl(value)
117
-    len_val = len_trim(value)
118117
 
118
+    ! Remove inline comments FIRST (before removing quotes)
119
+    ! This correctly handles "#FFFFFF" as a quoted string, not a comment
120
+    call remove_inline_comment(value)
121
+
122
+    len_val = len_trim(value)
119123
     if (len_val == 0) return
120124
 
121125
     ! Remove surrounding double quotes for strings
@@ -125,9 +129,6 @@ contains
125129
       end if
126130
     end if
127131
 
128
-    ! Remove inline comments (# after value)
129
-    call remove_inline_comment(value)
130
-
131132
   end subroutine parse_value
132133
 
133134
   ! Remove inline comments from value