#!/usr/local/bin/rune -x # import "sys"; import ; # pull-up all stdio identifiers too typedef const char *string_p; int main(int ac, char **av) { volatile int a = 4; show("how are you doing", 1, "oclock", 2UB, 3, 4, 5, NULL, (const char *).NULL, a, 0); show("should be: 1 oclock (unknown-int) 3 4 5 (vnull) (null) 4 0"); show(""); stdout->show("how are you doing ", 1, "oclock ", 2UB, 3, 4, 5, (const void *).NULL, (const char *).NULL, " ", a, 0); show("should be: 1 oclock 2 3 4 5 ? (null) 4 0"); #show2("should be: 1 2 3", 1, 2, 3); } void show(...) { Fs fd; int i; fd.setfd(1); for (i = 0; i < self.__varcount; ++i) { if (i) fd.write(" ", 1); switch(typeof(self.__vardata[i])) { case typeof(int): char buf[32]; int v = self.__vardata[i]; int j = arysize(buf); if (v == 0) { buf[--j] = '0'; } else { uint vv; int negative = 0; if (v < 0) { v = -v; negative = 1; } vv = (uint)v; while (vv != 0U) { buf[--j] = (char)(vv % 10U) + '0'; vv = vv / 10U; } if (negative != 0) buf[--j] = '-'; } fd.write(&buf[j], arysize(buf) - (size_t)j); break; case typeof(char *): const char *str = self.__vardata[i]; if (str == NULL) fd.write("(null)", 6); else fd.write(str, Str.strlen(str)); break; case typeof(void *): const void *data = self.__vardata[i]; if (data == NULL) fd.write("(vnull)", 7); else fd.write("(not-null)", 10); break; case typeof(SInteger): /* * Sweep */ fd.write("(unknown-int)", 13); break; default: char c = '?'; fd.write(&c, 1); break; } } fd.write("\n", 1); } #void #show2(...) #{ # stdout->format("show2: varcount %d\n", self.__varcount); # show3(self); #} # #void #show3(...) #{ # stdout->format("show3: varcount %d\n", self.__varcount); #}