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