tyInt tyUint fit target int bit width (#20829)

This commit is contained in:
Bung 2022-12-01 20:34:00 +08:00 • committed by GitHub
commit 658b28dc57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 306 additions and 267 deletions

View file

@ -573,7 +573,7 @@ proc readAllFile(file: File, len: int64): string =
result = newString(len)
let bytes = readBuffer(file, addr(result[0]), len)
if endOfFile(file):
if bytes < len:
if bytes.int64 < len:
result.setLen(bytes)
else:
# We read all the bytes but did not reach the EOF
@ -717,7 +717,7 @@ proc open*(f: var File, filename: string,
result = true
f = cast[File](p)
if bufSize > 0 and bufSize <= high(cint).int:
if bufSize > 0 and bufSize.uint <= high(uint):
discard c_setvbuf(f, nil, IOFBF, cast[csize_t](bufSize))
elif bufSize == 0:
discard c_setvbuf(f, nil, IONBF, 0)
@ -821,7 +821,7 @@ when defined(windows) and appType == "console" and
proc getConsoleCP(): cuint {.stdcall, dynlib: "kernel32",
importc: "GetConsoleCP".}
const Utf8codepage = 65001
const Utf8codepage = 65001'u32
let
consoleOutputCP = getConsoleOutputCP()