Revert "fix internal `IndexError` in `lex.nim` due to null term n.a."

This reverts commit e147df31718bb5bcd27c4067314dc40c2ecc9348.
This commit is contained in:
Vindaar 2018-10-11 11:53:19 +02:00 committed by flyx
parent e104dc351d
commit 06ddc9eb13
1 changed files with 6 additions and 18 deletions

View File

@ -218,31 +218,19 @@ proc lineWithMarker(lex: YamlLexer, pos: tuple[line, column: int],
lineStartIndex = lex.sSource.pos
lineEndIndex: int
curLine = lex.sSource.line
let srcHigh = lex.sSource.src.high
if pos.line == curLine:
lineEndIndex = lex.sSource.pos
if lineEndIndex < srcHigh:
while lineEndIndex < srcHigh and
lex.sSource.src[lineEndIndex] notin lineEnd:
inc(lineEndIndex)
while lex.sSource.src[lineEndIndex] notin lineEnd: inc(lineEndIndex)
while true:
while lineStartIndex >= 0 and
lineStartIndex < srcHigh and
lex.sSource.src[lineStartIndex] notin lineEnd:
while lineStartIndex >= 0 and lex.sSource.src[lineStartIndex] notin lineEnd:
dec(lineStartIndex)
if curLine == pos.line and lineStartIndex < srcHigh:
if curLine == pos.line:
inc(lineStartIndex)
break
let wasLF = if lineStartIndex > srcHigh or lineStartIndex < 0: false
else: lex.sSource.src[lineStartIndex] == '\l'
let wasLF = lex.sSource.src[lineStartIndex] == '\l'
lineEndIndex = lineStartIndex
if lineStartIndex > 0:
dec(lineStartIndex)
else:
break
if lineStartIndex > 0 and
lineStartIndex <= srcHigh and
lex.sSource.src[lineStartIndex] == '\c' and wasLF:
dec(lineStartIndex)
if lex.sSource.src[lineStartIndex] == '\c' and wasLF:
dec(lineStartIndex)
dec(lineEndIndex)
dec(curLine)