Permalink
Browse files

simplify; use vfprintf().

  • Loading branch information...
1 parent 394809c commit e101e6467e819068902c2d8d34455e82c106ae49 @kjs kjs committed Jun 24, 2012
Showing with 2 additions and 34 deletions.
  1. +2 −34 src/semcheck.c
View
@@ -40,46 +40,14 @@ init_typechecker(M1_compiler *comp) {
static void
type_error(M1_compiler *comp, unsigned line, char *msg, ...) {
va_list argp;
- char *p;
- char *s;
- int i;
- char fmtbuf[256];
++comp->errors;
fprintf(stderr, "%s:%d: error: ", comp->current_filename, line);
va_start(argp, msg);
-
- for (p = msg; *p != '\0'; p++) {
- if (*p != '%') {
- putc(*p, stderr);
-
- continue;
- }
- switch (*++p) {
- case 'd':
- i = va_arg(argp, int);
- sprintf(fmtbuf, "%d", i);
- fputs(fmtbuf, stderr);
- break;
-
- case 's':
- s = va_arg(argp, char *);
- fputs(s, stderr);
- break;
- case '%':
- putchar('%');
- break;
- default:
- fprintf(stderr, "unrecognized error reporting format\n");
- assert(0);
-
- }
-
- }
- fprintf(stderr, "\n");
-
+ vfprintf(stderr, msg, argp);
va_end(argp);
+ fprintf(stderr, "\n");
}
static void

0 comments on commit e101e64

Please sign in to comment.