fixes ptr to cstring warnings[backport] (#20848)
* fix =#13790 ptr char (+friends) should not implicitly convert to cstring * Apply suggestions from code review * first round; compiles on windows * nimPreviewSlimSystem * conversion is unsafe, cast needed * fixes more tests * fixes asyncnet * another try another error * last one * true * one more * why bugs didn't show at once * add `nimPreviewCstringConversion` switch * typo * fixes ptr to cstring warnings[backport] * add fixes Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
This commit is contained in:
parent
3d692d08f7
commit
06cd15663d
25 changed files with 50 additions and 50 deletions
|
|
@ -63,7 +63,7 @@ when defined(windows) and not weirdTarget:
|
|||
template findNextFile*(a, b: untyped): untyped = findNextFileA(a, b)
|
||||
template getCommandLine*(): untyped = getCommandLineA()
|
||||
|
||||
template getFilename*(f: untyped): untyped = $cstring(addr f.cFileName)
|
||||
template getFilename*(f: untyped): untyped = $cast[cstring](addr f.cFileName)
|
||||
|
||||
proc skipFindData*(f: WIN32_FIND_DATA): bool {.inline.} =
|
||||
# Note - takes advantage of null delimiter in the cstring
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ iterator walkDir*(dir: string; relative = false, checkDir = false,
|
|||
while true:
|
||||
var x = readdir(d)
|
||||
if x == nil: break
|
||||
var y = $cstring(addr x.d_name)
|
||||
var y = $cast[cstring](addr x.d_name)
|
||||
if y != "." and y != "..":
|
||||
var s: Stat
|
||||
let path = dir / y
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ func find*(s, sub: cstring, start: Natural = 0, last = 0): int =
|
|||
if sub.len > s.len - start: return -1
|
||||
if sub.len == 1: return find(s, sub[0], start, last)
|
||||
if last == 0 and s.len > start:
|
||||
let found = c_strstr(s[start].unsafeAddr, sub)
|
||||
let found = c_strstr(cast[cstring](s[start].unsafeAddr), sub)
|
||||
if not found.isNil:
|
||||
result = cast[ByteAddress](found) -% cast[ByteAddress](s)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -94,9 +94,9 @@ else:
|
|||
var buf = newSeq[char](requiredSize + 1)
|
||||
let buf2 = buf[0].addr
|
||||
if wcstombs(buf2, wideName, csize_t(requiredSize + 1)) != high(csize_t):
|
||||
var ptrToEnv = c_getenv(buf2)
|
||||
var ptrToEnv = c_getenv(cast[cstring](buf2))
|
||||
ptrToEnv[0] = '\0'
|
||||
ptrToEnv = c_getenv(buf2)
|
||||
ptrToEnv = c_getenv(cast[cstring](buf2))
|
||||
ptrToEnv[1] = '='
|
||||
|
||||
# And now, we have to update the outer environment to have a proper empty value.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue