diff --git a/vlib/strconv/vprintf.c.v b/vlib/strconv/vprintf.c.v index 095fe2d78d..0f7c4d8577 100644 --- a/vlib/strconv/vprintf.c.v +++ b/vlib/strconv/vprintf.c.v @@ -23,7 +23,7 @@ enum Char_parse_state { } pub fn v_printf(str string, pt ...voidptr) { - print(v_sprintf(str, pt)) + print(v_sprintf(str, ...pt)) } pub fn v_sprintf(str string, pt ...voidptr) string { diff --git a/vlib/v/tests/inout/strconv_v_printf.out b/vlib/v/tests/inout/strconv_v_printf.out new file mode 100644 index 0000000000..fbce98c4fb --- /dev/null +++ b/vlib/v/tests/inout/strconv_v_printf.out @@ -0,0 +1,10 @@ + . 2 3 . 5 . 7 . . . 11 . 13 . . . 17 . 19 .iter: 20 + . . 23 . . . . . 29 . 31 . . . . . 37 . . .iter: 40 + 41 . 43 . . . 47 . . . . . 53 . . . . . 59 .iter: 60 + 61 . . . . . 67 . . . 71 . 73 . . . . . 79 .iter: 80 + . . 83 . . . . . 89 . . . . . . . 97 . . .iter: 100 +101 .103 . . .107 .109 . . .113 . . . . . . .iter: 120 + . . . . . .127 . . .131 . . . . .137 .139 .iter: 140 + . . . . . . . .149 .151 . . . . .157 . . .iter: 160 + . .163 . . .167 . . . . .173 . . . . .179 .iter: 180 +181 . . . . . . . . .191 .193 . . .197 .199 .iter: 200 diff --git a/vlib/v/tests/inout/strconv_v_printf.vv b/vlib/v/tests/inout/strconv_v_printf.vv new file mode 100644 index 0000000000..d7e5cc1bb8 --- /dev/null +++ b/vlib/v/tests/inout/strconv_v_printf.vv @@ -0,0 +1,40 @@ +import strconv + +const limit = 201 + +fn main() { + // sieve + mut c := [limit]bool{} + c[1] = true + + mut p := 2 + for { + p2 := p * p + if p2 >= limit { + break + } + + for i := p2; i < limit; i += p { + c[i] = true + } + + for { + p++ + if !c[p] { + break + } + } + } + + // sieve complete. now print a representation. + for n in 1 .. limit { + if c[n] { + print(' .') + } else { + strconv.v_printf('%3d', n) + } + if n % 20 == 0 { + println('iter: $n') + } + } +}