Perform some cleaning operations on line breaks. (#11721)

Co-authored-by: André Storfjord Kristiansen <33384479+dev-bio@users.noreply.github.com>
Co-authored-by: Jintao Zhang <zhangjintao9020@gmail.com>
This commit is contained in:
k8s-infra-cherrypick-robot 2024-08-02 08:09:20 -07:00 committed by GitHub
parent 6cd1f92775
commit 2fc7a6ec45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -136,6 +136,13 @@ func cleanConf(in, out *bytes.Buffer) error {
case ' ', '\t':
needOutput = lineStarted
case '\r':
rest := in.Bytes()
if len(rest) > 0 {
if rest[0] != '\n' {
c = ' '
needOutput = lineStarted
}
}
case '\n':
needOutput = !(!lineStarted && emptyLineWritten)
nextLineStarted = false
@ -150,6 +157,13 @@ func cleanConf(in, out *bytes.Buffer) error {
case stateComment:
switch c {
case '\r':
rest := in.Bytes()
if len(rest) > 0 {
if rest[0] != '\n' {
c = ' '
needOutput = lineStarted
}
}
case '\n':
needOutput = true
nextLineStarted = false