make typesafeprintf test green
This commit is contained in:
parent
6a9b082b53
commit
0cbfd67522
1 changed files with 4 additions and 3 deletions
|
|
@ -9,7 +9,7 @@ proc printfImpl(formatstr: cstring) {.importc: "printf", varargs.}
|
||||||
|
|
||||||
iterator tokenize(format: string): char =
|
iterator tokenize(format: string): char =
|
||||||
var i = 0
|
var i = 0
|
||||||
while true:
|
while i < format.len:
|
||||||
case format[i]
|
case format[i]
|
||||||
of '%':
|
of '%':
|
||||||
case format[i+1]
|
case format[i+1]
|
||||||
|
|
@ -42,7 +42,8 @@ macro printf(formatString: string{lit}, args: varargs[typed]): untyped =
|
||||||
$expectedType & ", actual type: " & $actualType
|
$expectedType & ", actual type: " & $actualType
|
||||||
|
|
||||||
# keep the original callsite, but use cprintf instead
|
# keep the original callsite, but use cprintf instead
|
||||||
result = callsite()
|
result = newCall(bindSym"printfImpl")
|
||||||
result[0] = bindSym"printfImpl"
|
result.add formatString
|
||||||
|
for a in args: result.add a
|
||||||
|
|
||||||
printf("test %d\n", 10)
|
printf("test %d\n", 10)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue