Debian Codegraph @

testsuite/buildok/printf.stp

raw
1 #! stap -p4
2
3 # test the translatability of the formatted printing operators
4 probe begin
5 {
6 x = sprintf("take %d steps forward, %d steps back\n", 3, 2)
7 printf("%s", x);
8 printf("take %d steps forward, %d steps back\n", 3, 2)
9 printf("take %d steps forward, %d steps back\n", 3+1, 2*2)
10
11 bob = "bob"
12 alice = "alice"
13 print(bob)
14 print(alice)
15 print("hello")
16 print(10)
17 printf("%s phoned %s %4.4x times\n", bob, alice, 3456)
18 printf("%s phoned %s %+4d times\n", bob . alice, alice, 3456)
19 printf("%s phoned %s %.4x times\n", bob, alice . bob, 3456)
20 printf("%s phoned %s %-i times\n", sprintf("%s%s", bob, bob), sprint(alice), 3456)
21 printf("%s except after %s\n",
22 sprintf("%s before %s",
23 sprint(1), sprint(3)),
24 sprint("C"))
25 printf("\"quote\\this\"\n")
26 printf("%s", "\"quote\\this\"\n")
27 printf("%s\n", "\"quote\\this\"")
28 printf("%d is %03o in octal\n", 9, 9)
29 printf("%d is %#X in hex\n", 255, 255)
30 printf("print unsigned %u\n", 17)
31 printf("-% d is % d\n", 9, -9)
32
33 print(1, "two", 3, "four")
34 print(sprint(1, "two", 3, "four"))
35 println(1, "two", 3, "four")
36 print(sprintln(1, "two", 3, "four"))
37
38 printd(", ", 1, "two", 3, "four")
39 print(sprintd(", ", 1, "two", 3, "four"))
40 printdln(", ", 1, "two", 3, "four")
41 print(sprintdln(", ", 1, "two", 3, "four"))
42 }