Fix parsing bug where separator comparisons were flipped

This commit is contained in:
Sasha Koshka 2024-08-31 21:46:10 -04:00
parent 5821510143
commit bb9e317fa7

8
asv.go
View File

@ -61,7 +61,7 @@ func (this *Decoder) ReadFile () (file File, next rune, err error) {
group, next, err := this.ReadGroup() group, next, err := this.ReadGroup()
file = append(file, group) file = append(file, group)
if err != nil { return file, 0, err } if err != nil { return file, 0, err }
if next >= FileSeparator { if next <= FileSeparator {
return file, next, nil return file, next, nil
} }
} }
@ -76,7 +76,7 @@ func (this *Decoder) ReadGroup () (group Group, next rune, err error) {
record, next, err := this.ReadRecord() record, next, err := this.ReadRecord()
group = append(group, record) group = append(group, record)
if err != nil { return group, 0, err } if err != nil { return group, 0, err }
if next >= GroupSeparator { if next <= GroupSeparator {
return group, next, nil return group, next, nil
} }
} }
@ -91,7 +91,7 @@ func (this *Decoder) ReadRecord () (record Record, next rune, err error) {
unit, next, err := this.ReadUnit() unit, next, err := this.ReadUnit()
record = append(record, unit) record = append(record, unit)
if err != nil { return record, 0, err } if err != nil { return record, 0, err }
if next >= RecordSeparator { if next <= RecordSeparator {
return record, next, nil return record, next, nil
} }
} }
@ -113,7 +113,7 @@ func (this *Decoder) ReadUnit () (unit Unit, next rune, err error) {
if esc { if esc {
esc = false esc = false
} else if char >= FileSeparator && char <= UnitSeparator { } else if IsSeparator(char) {
return Unit(str.String()), char, nil return Unit(str.String()), char, nil
} }
str.WriteRune(char) str.WriteRune(char)