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':
|
case ' ', '\t':
|
||||||
needOutput = lineStarted
|
needOutput = lineStarted
|
||||||
case '\r':
|
case '\r':
|
||||||
|
rest := in.Bytes()
|
||||||
|
if len(rest) > 0 {
|
||||||
|
if rest[0] != '\n' {
|
||||||
|
c = ' '
|
||||||
|
needOutput = lineStarted
|
||||||
|
}
|
||||||
|
}
|
||||||
case '\n':
|
case '\n':
|
||||||
needOutput = !(!lineStarted && emptyLineWritten)
|
needOutput = !(!lineStarted && emptyLineWritten)
|
||||||
nextLineStarted = false
|
nextLineStarted = false
|
||||||
|
@ -150,6 +157,13 @@ func cleanConf(in, out *bytes.Buffer) error {
|
||||||
case stateComment:
|
case stateComment:
|
||||||
switch c {
|
switch c {
|
||||||
case '\r':
|
case '\r':
|
||||||
|
rest := in.Bytes()
|
||||||
|
if len(rest) > 0 {
|
||||||
|
if rest[0] != '\n' {
|
||||||
|
c = ' '
|
||||||
|
needOutput = lineStarted
|
||||||
|
}
|
||||||
|
}
|
||||||
case '\n':
|
case '\n':
|
||||||
needOutput = true
|
needOutput = true
|
||||||
nextLineStarted = false
|
nextLineStarted = false
|
||||||
|
|
Loading…
Reference in a new issue