Skip to content

Commit

Permalink
Fix bug in block comment parsing.
Browse files Browse the repository at this point in the history
`--]]` is just a convention, apparently. `]]` is what actually ends the
block.
  • Loading branch information
DanAlbert committed May 11, 2023
1 parent 3ef96ec commit cc38bab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dcs/lua/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@ def eat_line(self) -> None:
self.pos += 1

def eat_block_comment(self) -> None:
while not self.eob() and self.next_n_chars(4) != "--]]":
while not self.eob() and self.next_n_chars(2) != "]]":
self.pos += 1
if not self.eob():
self.pos += 4
self.pos += 2

def eat_ws(self):
"""
Expand Down
10 changes: 10 additions & 0 deletions dcs/lua/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,16 @@ def test_block_comment(self) -> None:

loads("--[[ Old Bort Calls For 1.5.3 and Older ]]--")

r = loads(
textwrap.dedent(
"""\
--[[ Comment ]]
foo = "bar"
"""
)
)
self.assertEqual(r["foo"], "bar")


if __name__ == '__main__':
unittest.main()

0 comments on commit cc38bab

Please sign in to comment.