mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-07 12:24:19 +00:00
fixes remaining ptr2cstring warnings on version-1-6 (#20861)
This commit is contained in:
@@ -1146,7 +1146,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
|
||||
@@ -2337,7 +2337,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
|
||||
|
||||
@@ -44,7 +44,7 @@ proc writeFloatToBufferSprintf*(buf: var array[65, char]; value: BiggestFloat):
|
||||
##
|
||||
## returns the amount of bytes written to `buf` not counting the
|
||||
## terminating '\0' character.
|
||||
var n: int = c_sprintf(addr buf, "%.16g", value)
|
||||
var n: int = c_sprintf(cast[cstring](addr buf), "%.16g", value)
|
||||
var hasDot = false
|
||||
for i in 0..n-1:
|
||||
if buf[i] == ',':
|
||||
@@ -85,7 +85,7 @@ proc addFloatRoundtrip*(result: var string; x: float | float32) =
|
||||
else:
|
||||
var buffer {.noinit.}: array[65, char]
|
||||
let n = writeFloatToBufferRoundtrip(buffer, x)
|
||||
result.addCstringN(cstring(buffer[0].addr), n)
|
||||
result.addCstringN(cast[cstring](buffer[0].addr), n)
|
||||
|
||||
proc addFloatSprintf*(result: var string; x: float) =
|
||||
when nimvm:
|
||||
@@ -93,7 +93,7 @@ proc addFloatSprintf*(result: var string; x: float) =
|
||||
else:
|
||||
var buffer {.noinit.}: array[65, char]
|
||||
let n = writeFloatToBufferSprintf(buffer, x)
|
||||
result.addCstringN(cstring(buffer[0].addr), n)
|
||||
result.addCstringN(cast[cstring](buffer[0].addr), n)
|
||||
|
||||
proc nimFloatToString(a: float): cstring =
|
||||
## ensures the result doesn't print like an integer, i.e. return 2.0, not 2
|
||||
|
||||
@@ -47,7 +47,7 @@ import strutils
|
||||
|
||||
let arr = ['H','e','l','l','o',' ','W','o','r','l','d','!','\0']
|
||||
doAssert $arr == "['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!', '\\x00']"
|
||||
doAssert $cast[cstring](addr arr) == "Hello World!"
|
||||
doAssert $cast[cstring](unsafeAddr arr) == "Hello World!"
|
||||
|
||||
proc takes(c: cstring) =
|
||||
doAssert c == cstring""
|
||||
|
||||
Reference in New Issue
Block a user