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 lineStartIndex = lex.sSource.pos
lineEndIndex: int lineEndIndex: int
curLine = lex.sSource.line curLine = lex.sSource.line
let srcHigh = lex.sSource.src.high
if pos.line == curLine: if pos.line == curLine:
lineEndIndex = lex.sSource.pos lineEndIndex = lex.sSource.pos
if lineEndIndex < srcHigh: while lex.sSource.src[lineEndIndex] notin lineEnd: inc(lineEndIndex)
while lineEndIndex < srcHigh and
lex.sSource.src[lineEndIndex] notin lineEnd:
inc(lineEndIndex)
while true: while true:
while lineStartIndex >= 0 and while lineStartIndex >= 0 and lex.sSource.src[lineStartIndex] notin lineEnd:
lineStartIndex < srcHigh and
lex.sSource.src[lineStartIndex] notin lineEnd:
dec(lineStartIndex) dec(lineStartIndex)
if curLine == pos.line and lineStartIndex < srcHigh: if curLine == pos.line:
inc(lineStartIndex) inc(lineStartIndex)
break break
let wasLF = if lineStartIndex > srcHigh or lineStartIndex < 0: false let wasLF = lex.sSource.src[lineStartIndex] == '\l'
else: lex.sSource.src[lineStartIndex] == '\l'
lineEndIndex = lineStartIndex lineEndIndex = lineStartIndex
if lineStartIndex > 0: dec(lineStartIndex)
dec(lineStartIndex) if lex.sSource.src[lineStartIndex] == '\c' and wasLF:
else:
break
if lineStartIndex > 0 and
lineStartIndex <= srcHigh and
lex.sSource.src[lineStartIndex] == '\c' and wasLF:
dec(lineStartIndex) dec(lineStartIndex)
dec(lineEndIndex) dec(lineEndIndex)
dec(curLine) dec(curLine)