This commit is contained in:
Bung
2022-12-16 15:01:15 +08:00
committed by GitHub
parent 8a3b76b287
commit a9bd78d579
23 changed files with 140 additions and 140 deletions

View File

@@ -183,7 +183,7 @@ when not defined(nimscript):
let kv = $e
let p = find(kv, '=')
yield (substr(kv, 0, p-1), substr(kv, p+1))
e = cast[typ](cast[ByteAddress](eend)+size)
e = cast[typ](cast[int](eend)+size)
if typeof(zero)(eend[1]) == zero: break
discard free_fun(env)
impl(getEnvironmentStringsW, WideCString, 2, 0, freeEnvironmentStringsW)

View File

@@ -93,7 +93,7 @@ func find*(s: cstring, sub: char, start: Natural = 0, last = 0): int =
if L > 0:
let found = c_memchr(s[start].unsafeAddr, sub, cast[csize_t](L))
if not found.isNil:
return cast[ByteAddress](found) -% cast[ByteAddress](s)
return cast[int](found) -% cast[int](s)
return -1
func find*(s, sub: cstring, start: Natural = 0, last = 0): int =
@@ -108,6 +108,6 @@ func find*(s, sub: cstring, start: Natural = 0, last = 0): int =
if last == 0 and s.len > start:
let found = c_strstr(cast[cstring](s[start].unsafeAddr), sub)
if not found.isNil:
result = cast[ByteAddress](found) -% cast[ByteAddress](s)
result = cast[int](found) -% cast[int](s)
else:
result = -1

View File

@@ -480,7 +480,7 @@ proc readLine*(f: File, line: var string): bool {.tags: [ReadIOEffect],
let m = c_memchr(addr line[pos], '\L'.ord, cast[csize_t](sp))
if m != nil:
# \l found: Could be our own or the one by fgets, in any case, we're done
var last = cast[ByteAddress](m) - cast[ByteAddress](addr line[0])
var last = cast[int](m) - cast[int](addr line[0])
if last > 0 and line[last-1] == '\c':
line.setLen(last-1)
return last > 1 or fgetsSuccess