Skip to content

Commit

Permalink
fix(plc4go/spi): fix footer being lost on name change
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Oct 1, 2024
1 parent e1741cd commit 7aea3ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions plc4go/spi/utils/asciiBox.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ func NewAsciiBoxWriter(opts ...func(writer *asciiBoxWriter)) AsciiBoxWriter {
for _, opt := range opts {
opt(a)
}
a.boxHeaderRegex = regexp.MustCompile(`^` + a.defaultBoxSet.UpperLeftCorner + a.defaultBoxSet.HorizontalLine + `(?P<name>[\w /]+)` + a.defaultBoxSet.HorizontalLine + `*` + `(?P<header>[\w /]+)?` + a.defaultBoxSet.HorizontalLine + `*` + a.defaultBoxSet.UpperRightCorner)
a.boxFooterRegex = regexp.MustCompile(`(?m)^` + a.defaultBoxSet.LowerLeftCorner + a.defaultBoxSet.HorizontalLine + `*` + `(?P<footer>[\w /]+)` + a.defaultBoxSet.HorizontalLine + `*` + a.defaultBoxSet.LowerRightCorner)
hl := a.defaultBoxSet.HorizontalLine
a.boxHeaderRegex = regexp.MustCompile(`^` + a.defaultBoxSet.UpperLeftCorner + hl + `(?P<name>[^` + hl + `]+)` + hl + `*` + `(?P<header>[^` + hl + `]+)?` + hl + `*` + a.defaultBoxSet.UpperRightCorner)
a.boxFooterRegex = regexp.MustCompile(`(?m)^` + a.defaultBoxSet.LowerLeftCorner + hl + `*` + `(?P<footer>[^` + hl + `]+)` + hl + `*` + a.defaultBoxSet.LowerRightCorner)
return a
}

Expand Down
4 changes: 2 additions & 2 deletions plc4go/spi/utils/asciiBox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,8 @@ func TestNewAsciiBoxWriter(t *testing.T) {
extraNameCharIndent: 1,
borderWidth: 1,
newLineCharWidth: 1,
boxHeaderRegex: regexp.MustCompile(`^` + upperLeftCorner + horizontalLine + `(?P<name>[\w /]+)` + horizontalLine + `*` + `(?P<header>[\w /]+)?` + horizontalLine + `*` + upperRightCorner),
boxFooterRegex: regexp.MustCompile(`(?m)^` + lowerLeftCorner + horizontalLine + `*` + `(?P<footer>[\w /]+)` + horizontalLine + `*` + lowerRightCorner),
boxHeaderRegex: regexp.MustCompile(`^` + upperLeftCorner + horizontalLine + `(?P<name>[^` + horizontalLine + `]+)` + horizontalLine + `*` + `(?P<header>[^` + horizontalLine + `]+)?` + horizontalLine + `*` + upperRightCorner),
boxFooterRegex: regexp.MustCompile(`(?m)^` + lowerLeftCorner + horizontalLine + `*` + `(?P<footer>[^` + horizontalLine + `]+)` + horizontalLine + `*` + lowerRightCorner),
},
},
}
Expand Down

0 comments on commit 7aea3ab

Please sign in to comment.