From 5cbd84f9b46384ee08da255db816a0971fd5bf3f Mon Sep 17 00:00:00 2001 From: Richard Kistruck Date: Tue, 7 Aug 2007 19:09:43 +0100 Subject: Mps br/diagtag: diag.c: support tagging of diagnostics, and avoid having to say DIAG_STREAM every time, with new macros: DIAG_SINGLEF, DIAG_FIRSTF, DIAG_MOREF, DIAG_END. mpm.c: new WriteF_firstformat_v required by DIAG_MOREF. Copied from Perforce Change: 163059 ServerID: perforce.ravenbrook.com --- mps/code/mpm.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'mps/code/mpm.c') diff --git a/mps/code/mpm.c b/mps/code/mpm.c index 4282a06b937..04bb8418f61 100644 --- a/mps/code/mpm.c +++ b/mps/code/mpm.c @@ -409,7 +409,16 @@ static Res WriteDouble(mps_lib_FILE *stream, double d) /* WriteF -- write formatted output * - * Calls WriteF_v. + * .writef.des: See , also + * + * .writef.p: There is an assumption that void * fits in Word in + * the case of $P, and unsigned long for $U and $B. This is checked in + * MPMCheck. + * + * .writef.div: Although MPS_WORD_WIDTH/4 appears three times, there + * are effectively three separate decisions to format at this width. + * + * .writef.check: See .check.writef. */ Res WriteF(mps_lib_FILE *stream, ...) @@ -423,21 +432,20 @@ Res WriteF(mps_lib_FILE *stream, ...) return res; } +Res WriteF_v(mps_lib_FILE *stream, va_list args) +{ + const char *firstformat; + int r; + size_t i; + Res res; -/* WriteF_v -- write formatted output - * - * .writef.des: See , also - * - * .writef.p: There is an assumption that void * fits in Word in - * the case of $P, and unsigned long for $U and $B. This is checked in - * MPMCheck. - * - * .writef.div: Although MPS_WORD_WIDTH/4 appears three times, there - * are effectively three separate decisions to format at this width. - * - * .writef.check: See .check.writef. */ + firstformat = va_arg(args, const char *); + res = WriteF_firstformat_v(stream, firstformat, args); + return res; +} -Res WriteF_v(mps_lib_FILE *stream, va_list args) +Res WriteF_firstformat_v(mps_lib_FILE *stream, + const char *firstformat, va_list args) { const char *format; int r; @@ -445,9 +453,10 @@ Res WriteF_v(mps_lib_FILE *stream, va_list args) Res res; AVER(stream != NULL); + + format = firstformat; for(;;) { - format = va_arg(args, const char *); if (format == NULL) break; @@ -534,6 +543,8 @@ Res WriteF_v(mps_lib_FILE *stream, va_list args) ++format; } + + format = va_arg(args, const char *); } return ResOK; -- cgit v1.2.1