fixes #21273; fixes an io.readLine off by one bug [backport 1.0] (#21276)

fixes #21273; io.readLine off by one

(cherry picked from commit c4d3d650ba)
This commit is contained in:
ringabout
2023-01-26 03:56:19 +08:00
committed by narimiran
parent 2c24ac1849
commit b1a0467ffd
2 changed files with 22 additions and 3 deletions

View File

@@ -35,3 +35,21 @@ block: # readChars
break
doAssert n2s == @[2,2,2,1,0]
doAssert s2 == s
import std/strutils
block: # bug #21273
let FILE = buildDir / "D20220119T134305.txt"
let hex = "313632313920313632343720313632353920313632363020313632393020323035363520323037323120323131353020323239393820323331303520323332313020323332343820323332363820"
writeFile FILE, parseHexStr(hex)
doAssert readFile(FILE).toHex == hex
let f = open(FILE)
var s = newString(80)
while f.readLine(s):
doAssert s.toHex == hex