@@ -176,10 +176,13 @@ def filter(self, rec):
176176
177177
178178class ParsingException (Exception ):
179- def __init__ (self , file : Optional [str ], lineno : int , line : str ):
179+ def __init__ (self , file : Optional [str ], lineno : int , line : str , start : int = 0 ):
180180 self .file = file
181181 self .lineno = lineno
182182 self .line = line
183+ if start < 0 :
184+ start = 0
185+ self .start = start
183186
184187 def __str__ (self ):
185188 out = ""
@@ -191,7 +194,9 @@ def __str__(self):
191194 out += f"\n \n { lineno } { self .line } "
192195
193196 out += f'\n { " " * len (lineno )} '
194- out += "^" * len (self .line .strip ())
197+ if self .start :
198+ out += " " * self .start
199+ out += "^" * (len (self .line .strip ()) - self .start )
195200
196201 return out
197202
@@ -204,6 +209,10 @@ class InvalidSyntax(ParsingException):
204209 pass
205210
206211
212+ class InvalidComment (ParsingException ):
213+ pass
214+
215+
207216def extract_build_opt (name : str , dst : TextIO , src : TextIO ):
208217 """
209218 Read src line by line and extract matching 'create-file' directives.
@@ -254,12 +263,18 @@ def extract_build_opt(name: str, dst: TextIO, src: TextIO):
254263 state = IN_RAW
255264 continue
256265
257- if line . startswith (( "#" , "//" , "*" )) :
266+ if not line :
258267 continue
259268
260- if not line :
269+ # allow standalone comments on each line
270+ if line .startswith (("#" , "//" , "*" )):
261271 continue
262272
273+ # but not nested ones. this should get caught by -Wcomment, too
274+ for comment in ("/*" , "*/" ):
275+ if comment in line :
276+ raise InvalidComment (None , n , raw_line , raw_line .index (comment ))
277+
263278 block .append (f"{ line } \n " )
264279
265280 if state != IN_RAW :
0 commit comments