Perform some cleaning operations on line breaks.

Co-authored-by: Jintao Zhang <zhangjintao9020@gmail.com>
This commit is contained in:
André Storfjord Kristiansen 2024-08-01 17:14:26 +02:00 committed by k8s-infra-cherrypick-robot
parent 6cd1f92775
commit 2003f8563c

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