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:
parent
6cd1f92775
commit
2fc7a6ec45
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue