Skip to content

Commit

Permalink
fix: duplicated whitespaces when parsing dmm
Browse files Browse the repository at this point in the history
Testing was insufficient, and it caused us to miss an else if.
  • Loading branch information
LemonInTheDark authored and SpaiR committed Jul 13, 2023
1 parent dfdf279 commit fa778c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions internal/dmapi/dmmap/dmmdata/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ func parse(file namedReader) (*DmmData, error) {
} else {
currDatum = append(currDatum, c)
}
}
if inVarDataBlock { // retain any whitespace in the data block
} else if inVarDataBlock { // retain any whitespace in the data block
currDatum = append(currDatum, c)
}
continue
Expand Down
4 changes: 2 additions & 2 deletions internal/dmapi/dmmap/dmmdata/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ no_ws=1;
} , /obj/foo2 ,
/obj/foo1 {no_ws=1} ,
/obj/foo3{
liz = list("a" = 2, "c" = 3)
liz = list("a" = 2, "c" = 3, "long bit of text " = "other long bit of text")
})
// Comment line that shouldn't flag TGM format
Expand Down Expand Up @@ -248,7 +248,7 @@ no_ws=1;

assert.Equal("/obj/foo3", prefabs[3].Path())
assert.ElementsMatch(prefabs[3].Vars().Iterate(), []string{"liz"})
assert.Equal("list(\"a\" = 2, \"c\" = 3)", prefabs[3].Vars().ValueV("liz", ""))
assert.Equal("list(\"a\" = 2, \"c\" = 3, \"long bit of text \" = \"other long bit of text\")", prefabs[3].Vars().ValueV("liz", ""))
}

// Table-based test to check failure edge cases.
Expand Down

0 comments on commit fa778c0

Please sign in to comment.