From: mdw Date: Sat, 17 Jun 2000 11:46:58 +0000 (+0000) Subject: Convenience macros for producing debugging output containing MP X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/commitdiff_plain/f654f4218ac36981a1174b1f09823997239b0358 Convenience macros for producing debugging output containing MP integers. --- diff --git a/mptext.h b/mptext.h index 93cbf50..c6e8275 100644 --- a/mptext.h +++ b/mptext.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mptext.h,v 1.3 1999/12/22 15:56:30 mdw Exp $ + * $Id: mptext.h,v 1.4 2000/06/17 11:46:58 mdw Exp $ * * Textual representation of multiprecision numbers * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: mptext.h,v $ + * Revision 1.4 2000/06/17 11:46:58 mdw + * Convenience macros for producing debugging output containing MP + * integers. + * * Revision 1.3 1999/12/22 15:56:30 mdw * Make the buffer passed to `put' op constant. * @@ -116,6 +120,23 @@ extern const mptext_ops mptext_fileops; extern mp *mp_readfile(mp */*m*/, FILE */*fp*/, int /*radix*/); extern int mp_writefile(mp */*m*/, FILE */*fp*/, int /*radix*/); +#define MP_DOFPRINTFR(fp, args, m, r) do { \ + fprintf args; \ + mp_writefile(m, fp, r); \ + fputc('\n', fp); \ +} while (0) + +#define MP_DOFPRINTR(fp, name, m, r) \ + MP_DOFPRINTFR(fp, (fp, "%s = ", name), m, r) + +#define MP_PRINT(name, m) MP_DOFPRINTR(stdout, name, m, 10) +#define MP_EPRINT(name, m) MP_DOFPRINTR(stderr, name, m, 10) +#define MP_PRINTX(name, m) MP_DOFPRINTR(stdout, name, m, 16) +#define MP_EPRINTX(name, m) MP_DOFPRINTR(stderr, name, m, 16) + +#define MP_FPRINTF(fp, args, m) MP_DOFPRINTFR(fp, args, m, 10) +#define MP_FPRINTFX(fp, args, m) MP_DOFPRINTFR(fp, args, m, 16) + /*----- String I/O --------------------------------------------------------*/ /* --- Context format --- */