static void emitf(int line, char *fmt, ...) { // Replace "#" with "%%" so that vfprintf prints out "#" as "%". char buf[256]; int i = 0; for (char *p = fmt; *p; p++) { assert(i < sizeof(buf) - 3); if (*p == '#') { buf[i++] = '%'; buf[i++] = '%'; } else { buf[i++] = *p; } } buf[i] = '\0'; va_list args; va_start(args, fmt); int col = vfprintf(outputfp, buf, args); va_end(args); if (dumpstack) { for (char *p = fmt; *p; p++) if (*p == '\t') col += TAB - 1; int space = (28 - col) > 0 ? (30 - col) : 2; fprintf(outputfp, "%*c %s:%d", space, '#', get_caller_list(), line); } fprintf(outputfp, "\n"); }
static void emitf(int line, char *fmt, ...) { va_list args; va_start(args, fmt); int col = vfprintf(outputfp, fmt, args); va_end(args); for (char *p = fmt; *p; p++) if (*p == '\t') col += TAB - 1; int space = (28 - col) > 0 ? (30 - col) : 2; fprintf(outputfp, "%*c %s:%d\n", space, '#', get_caller_list(), line); }