void die(const char *format, ...) { va_list args; va_start(args, format); #if WITH_HOGWEED gmp_vfprintf(stderr, format, args); #else vfprintf(stderr, format, args); #endif va_end(args); abort (); }
void check_vfprintf (const char *want, const char *fmt, va_list ap) { char got[MAX_OUTPUT]; int got_len, want_len, fread_len; long ftell_len; want_len = strlen (want); rewind (check_vfprintf_fp); got_len = gmp_vfprintf (check_vfprintf_fp, fmt, ap); ASSERT_ALWAYS (got_len != -1); ASSERT_ALWAYS (fflush (check_vfprintf_fp) == 0); ftell_len = ftell (check_vfprintf_fp); ASSERT_ALWAYS (ftell_len != -1); rewind (check_vfprintf_fp); ASSERT_ALWAYS (ftell_len <= sizeof(got)); fread_len = fread (got, 1, ftell_len, check_vfprintf_fp); if (got_len != want_len || ftell_len != want_len || fread_len != want_len || memcmp (got, want, want_len) != 0) { printf ("gmp_vfprintf wrong\n"); printf (" fmt |%s|\n", fmt); printf (" got |%.*s|\n", fread_len, got); printf (" want |%s|\n", want); printf (" got_len %d\n", got_len); printf (" ftell_len %ld\n", ftell_len); printf (" fread_len %d\n", fread_len); printf (" want_len %d\n", want_len); abort (); } }