wip(parser): partly finished Message parser

This commit is contained in:
2021-08-15 21:30:58 +01:00
parent 5174ed35ca
commit bf44c4a648
7 changed files with 759 additions and 40 deletions

View File

@@ -58,9 +58,9 @@ type Lines []*Line
// basis.
func NewLines(content []byte) Lines {
r := Lines{}
cLen := len(content)
length := len(content)
if cLen == 0 {
if length == 0 {
return r
}
@@ -68,13 +68,13 @@ func NewLines(content []byte) Lines {
var breaks [][]int
// Locate each line break within content.
for i := 0; i < cLen; i++ {
for i := 0; i < length; i++ {
switch content[i] {
case lf:
breaks = append(breaks, []int{i, i + 1})
case cr:
b := []int{i, i + 1}
if i+1 < cLen && content[i+1] == lf {
if i+1 < length && content[i+1] == lf {
b[1]++
i++
}