From 06ddc9eb1350a11cd3ef52449f26a683c8af8895 Mon Sep 17 00:00:00 2001 From: Vindaar Date: Thu, 11 Oct 2018 11:53:19 +0200 Subject: [PATCH] Revert "fix internal `IndexError` in `lex.nim` due to null term n.a." This reverts commit e147df31718bb5bcd27c4067314dc40c2ecc9348. --- yaml/private/lex.nim | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/yaml/private/lex.nim b/yaml/private/lex.nim index 2361a73..3da66c5 100644 --- a/yaml/private/lex.nim +++ b/yaml/private/lex.nim @@ -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)