1 /****************************************************************************
5 *************************************************************************
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
13 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
14 * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
17 * A merge of Bjorn Reese's format() function and Daniel's dsprintf()
18 * 1.0. A full blooded printf() clone with full support for <num>$
19 * everywhere (parameters, widths and precisions) including variabled
20 * sized parameters (like doubles, long longs, long doubles and even
21 * void * in 64-bit architectures).
23 * Current restrictions:
24 * - Max 128 parameters
25 * - No 'long double' support.
27 *************************************************************************
32 * - Updated version number.
33 * - Corrected a static non-zero prefixed width problem.
36 * Added daprintf() and dvaprintf() for allocated printf() and vprintf().
37 * They return an allocated buffer with the result inside. The result must
42 * Converted all non-printable (and non-whitespace) characters into
43 * their decimal ASCII value preceeded by a '\' character
44 * (this only applies to snprintf family so far)
46 * Added %S (which is the same as %#s)
50 * Fixed precision and width qualifiers (%.*s)
52 * Added support for snprintf()
54 * Quoting (%#s) is disabled for the (nil) pointer
58 * %#s means that the string will be quoted with "
59 * (I was getting tired of writing \"%s\" all the time)
61 * [ERR] for strings changed to (nil)
65 * - Prepended all internal functions with dprintf_
66 * - Defined the booleans
69 * - Added dvsprintf(), dvfprintf() and dvprintf().
70 * - Made the formatting function available with the name _formatf() to enable
71 * other *printf()-inspired functions. (I considered adding a dmsprintf()
72 * that works like sprintf() but allocates the destination string and
73 * possibly enlarges it itself, but things like that should be done with the
74 * new _formatf() instead.)
77 * - Small modifications to make it compile nicely at both Daniel's and
81 * - Made it work with text to the right of the last %!
82 * - Introduced dprintf(), dsprintf() and dfprintf().
83 * - Float/double support enabled. This system is currently using the ordinary
84 * sprintf() function. NOTE that positional parameters, widths and precisions
85 * will still work like it should since the d-system takes care of that and
86 * passes that information re-formatted to the old sprintf().
89 * - Fixed space padding (i.e %d was extra padded previously)
90 * - long long output is supported
91 * - alternate output is done correct like in %#08x
93 ****************************************************************************/
95 static const char rcsid[] = "@(#)$Id$";
100 * Use WIDTH, PRECISION and NUMBERED ARGUMENT combined.
103 #include <sys/types.h>
110 /* The last #include file should be: */
112 #include "memdebug.h"
115 #define BUFFSIZE 256 /* buffer for long-to-str and float-to-str calcs */
116 #define MAX_PARAMETERS 128 /* lame static limit */
126 # define TRUE ((char)(1 == 1))
127 # define FALSE ((char)(0 == 1))
132 /* Lower-case digits. */
133 static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
135 /* Upper-case digits. */
136 static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
138 #define OUTCHAR(x) done+=(stream(x, (FILE *)data)==-1?0:1)
140 /* Data type to read from the arglist */
151 FORMAT_WIDTH /* For internal use */
154 /* convertion and display flags */
158 FLAGS_SHOWSIGN = 1<<1,
163 FLAGS_LONGLONG = 1<<6,
164 FLAGS_LONGDOUBLE = 1<<7,
165 FLAGS_PAD_NIL = 1<<8,
166 FLAGS_UNSIGNED = 1<<9,
170 FLAGS_WIDTH = 1<<13, /* '*' or '*<num>$' used */
171 FLAGS_WIDTHPARAM = 1<<14, /* width PARAMETER was specified */
172 FLAGS_PREC = 1<<15, /* precision was specified */
173 FLAGS_PRECPARAM = 1<<16, /* precision PARAMETER was specified */
174 FLAGS_CHAR = 1<<17, /* %c story */
175 FLAGS_FLOATE = 1<<18, /* %e or %E */
176 FLAGS_FLOATG = 1<<19 /* %g or %G */
182 int width; /* width OR width parameter number */
183 int precision; /* precision OR precision parameter number */
188 #if SIZEOF_LONG_LONG /* if this is non-zero */
192 #if SIZEOF_LONG_DOUBLE
205 char *buffer; /* allocated buffer */
206 size_t len; /* length of string */
207 size_t alloc; /* length of alloc */
210 int curl_msprintf(char *buffer, const char *format, ...);
212 static int dprintf_DollarString(char *input, char **end)
215 while(isdigit((int)*input)) {
217 number += *input-'0';
220 if(number && ('$'==*input++)) {
227 static BOOL dprintf_IsQualifierNoDollar(char c)
230 case '-': case '+': case ' ': case '#': case '.':
231 case '0': case '1': case '2': case '3': case '4':
232 case '5': case '6': case '7': case '8': case '9':
233 case 'h': case 'l': case 'L': case 'Z': case 'q':
240 #ifdef DPRINTF_DEBUG2
241 int dprintf_Pass1Report(va_stack_t *vto, int max)
248 for(i=0; i<max; i++) {
250 switch(vto[i].type) {
266 case FORMAT_LONGLONG:
272 case FORMAT_LONGDOUBLE:
273 type = "long double";
280 for(bit=0; bit<31; bit++) {
281 flags = vto[i].flags & (1<<bit);
283 if(flags & FLAGS_SPACE)
284 strcat(buffer, "space ");
285 else if(flags & FLAGS_SHOWSIGN)
286 strcat(buffer, "plus ");
287 else if(flags & FLAGS_LEFT)
288 strcat(buffer, "left ");
289 else if(flags & FLAGS_ALT)
290 strcat(buffer, "alt ");
291 else if(flags & FLAGS_SHORT)
292 strcat(buffer, "short ");
293 else if(flags & FLAGS_LONG)
294 strcat(buffer, "long ");
295 else if(flags & FLAGS_LONGLONG)
296 strcat(buffer, "longlong ");
297 else if(flags & FLAGS_LONGDOUBLE)
298 strcat(buffer, "longdouble ");
299 else if(flags & FLAGS_PAD_NIL)
300 strcat(buffer, "padnil ");
301 else if(flags & FLAGS_UNSIGNED)
302 strcat(buffer, "unsigned ");
303 else if(flags & FLAGS_OCTAL)
304 strcat(buffer, "octal ");
305 else if(flags & FLAGS_HEX)
306 strcat(buffer, "hex ");
307 else if(flags & FLAGS_UPPER)
308 strcat(buffer, "upper ");
309 else if(flags & FLAGS_WIDTH)
310 strcat(buffer, "width ");
311 else if(flags & FLAGS_WIDTHPARAM)
312 strcat(buffer, "widthparam ");
313 else if(flags & FLAGS_PREC)
314 strcat(buffer, "precision ");
315 else if(flags & FLAGS_PRECPARAM)
316 strcat(buffer, "precparam ");
317 else if(flags & FLAGS_CHAR)
318 strcat(buffer, "char ");
319 else if(flags & FLAGS_FLOATE)
320 strcat(buffer, "floate ");
321 else if(flags & FLAGS_FLOATG)
322 strcat(buffer, "floatg ");
324 printf("REPORT: %d. %s [%s]\n", i, type, buffer);
332 /******************************************************************
335 * Create an index with the type of each parameter entry and its
336 * value (may vary in size)
338 ******************************************************************/
340 static int dprintf_Pass1(char *format, va_stack_t *vto, char **endpos, va_list arglist)
355 continue; /* while */
360 /* Handle the positional case (N$) */
364 this_param = dprintf_DollarString(fmt, &fmt);
366 /* we got no positional, get the next counter */
367 this_param = param_num;
369 if (this_param > max_param)
370 max_param = this_param;
373 * The parameter with number 'i' should be used. Next, we need
374 * to get SIZE and TYPE of the parameter. Add the information
381 /* Handle the flags */
383 while (dprintf_IsQualifierNoDollar(*fmt)) {
386 flags |= FLAGS_SPACE;
389 flags |= FLAGS_SHOWSIGN;
393 flags &= ~FLAGS_PAD_NIL;
401 /* The precision is picked from a specified parameter */
403 flags |= FLAGS_PRECPARAM;
407 i = dprintf_DollarString(fmt, &fmt);
411 precision = param_num;
413 if (precision > max_param)
414 max_param = precision;
418 precision = strtol(fmt, &fmt, 10);
422 flags |= FLAGS_SHORT;
425 if (flags & FLAGS_LONG)
426 flags |= FLAGS_LONGLONG;
431 flags |= FLAGS_LONGDOUBLE;
434 flags |= FLAGS_LONGLONG;
437 if (sizeof(size_t) > sizeof(unsigned long int))
438 flags |= FLAGS_LONGLONG;
439 if (sizeof(size_t) > sizeof(unsigned int))
443 if (!(flags & FLAGS_LEFT))
444 flags |= FLAGS_PAD_NIL;
446 case '1': case '2': case '3': case '4':
447 case '5': case '6': case '7': case '8': case '9':
448 flags |= FLAGS_WIDTH;
449 width = strtol(--fmt, &fmt, 10);
451 case '*': /* Special case */
452 flags |= FLAGS_WIDTHPARAM;
455 i = dprintf_DollarString(fmt, &fmt);
460 if(width > max_param)
468 /* Handle the specifier */
477 vto[i].type = FORMAT_STRING;
480 vto[i].type = FORMAT_INTPTR;
483 vto[i].type = FORMAT_PTR;
486 vto[i].type = FORMAT_INT;
489 vto[i].type = FORMAT_INT;
490 flags |= FLAGS_UNSIGNED;
493 vto[i].type = FORMAT_INT;
494 flags |= FLAGS_OCTAL;
497 vto[i].type = FORMAT_INT;
501 vto[i].type = FORMAT_INT;
502 flags |= FLAGS_HEX|FLAGS_UPPER;
505 vto[i].type = FORMAT_INT;
509 vto[i].type = FORMAT_DOUBLE;
512 vto[i].type = FORMAT_DOUBLE;
513 flags |= FLAGS_FLOATE| (('E' == *fmt)?FLAGS_UPPER:0);
516 vto[i].type = FORMAT_DOUBLE;
517 flags |= FLAGS_FLOATG| (('G' == *fmt)?FLAGS_UPPER:0);
520 vto[i].type = FORMAT_UNKNOWN;
524 vto[i].flags = flags;
525 vto[i].width = width;
526 vto[i].precision = precision;
528 if (flags & FLAGS_WIDTHPARAM) {
529 /* we have the width specified from a parameter, so we make that
530 parameter's info setup properly */
531 vto[i].width = width - 1;
533 vto[i].type = FORMAT_WIDTH;
534 vto[i].flags = FLAGS_NEW;
535 vto[i].precision = vto[i].width = 0; /* can't use width or precision
538 if (flags & FLAGS_PRECPARAM) {
539 /* we have the precision specified from a parameter, so we make that
540 parameter's info setup properly */
541 vto[i].precision = precision - 1;
543 vto[i].type = FORMAT_WIDTH;
544 vto[i].flags = FLAGS_NEW;
545 vto[i].precision = vto[i].width = 0; /* can't use width or precision
548 *endpos++ = fmt + 1; /* end of this sequence */
552 #ifdef DPRINTF_DEBUG2
553 dprintf_Pass1Report(vto, max_param);
556 /* Read the arg list parameters into our data list */
557 for (i=0; i<max_param; i++) {
558 if ((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH))
560 /* Width/precision arguments must be read before the main argument
561 * they are attached to
563 vto[i + 1].data.num = va_arg(arglist, int);
569 vto[i].data.str = va_arg(arglist, char *);
575 vto[i].data.ptr = va_arg(arglist, void *);
580 if(vto[i].flags & FLAGS_LONGLONG)
581 vto[i].data.lnum = va_arg(arglist, long long);
584 if(vto[i].flags & FLAGS_LONG)
585 vto[i].data.num = va_arg(arglist, long);
587 vto[i].data.num = va_arg(arglist, int);
591 #if SIZEOF_LONG_DOUBLE
592 if(vto[i].flags & FLAGS_LONG)
593 vto[i].data.ldnum = va_arg(arglist, long double);
596 vto[i].data.dnum = va_arg(arglist, double);
600 /* Argument has been read. Silently convert it into an integer
603 vto[i].type = FORMAT_INT;
615 static int dprintf_formatf(
616 void *data, /* untouched by format(), just sent to the
617 stream() function in the first argument */
618 int (*stream)(int, FILE *), /* function pointer called for each
620 const char *format, /* %-formatted string */
621 va_list ap_save) /* list of parameters */
623 /* Base-36 digits for numbers. */
624 const char *digits = lower_digits;
626 /* Pointer into the format string. */
629 /* Number of characters written. */
630 register size_t done = 0;
632 long param; /* current parameter to read */
633 long param_num=0; /* parameter counter */
635 va_stack_t vto[MAX_PARAMETERS];
636 char *endpos[MAX_PARAMETERS];
643 /* Do the actual %-code parsing */
644 dprintf_Pass1((char *)format, vto, endpos, ap_save);
646 end = &endpos[0]; /* the initial end-position from the list dprintf_Pass1()
651 /* Format spec modifiers. */
654 /* Width of a field. */
656 /* Precision of a field. */
659 /* Decimal integer is negative. */
662 /* Base of a number to be written. */
665 /* Integral values to be written. */
667 unsigned long long num;
674 /* This isn't a format spec, so write everything out until the next one
675 OR end of string is reached. */
678 } while(*++f && ('%' != *f));
684 /* Check for "%%". Note that although the ANSI standard lists
685 '%' as a conversion specifier, it says "The complete format
686 specification shall be `%%'," so we can avoid all the width
687 and precision processing. */
694 /* If this is a positional parameter, the position must follow imediately
695 after the %, thus create a %<num>$ sequence */
696 param=dprintf_DollarString(f, &f);
703 param_num++; /* increase this always to allow "%2$s %1$s %s" and then the
704 third %s will pick the 3rd argument */
708 /* pick up the specified width */
709 if(p->flags & FLAGS_WIDTHPARAM)
710 width = vto[p->width].data.num;
714 /* pick up the specified precision */
715 if(p->flags & FLAGS_PRECPARAM)
716 prec = vto[p->precision].data.num;
717 else if(p->flags & FLAGS_PREC)
722 alt = p->flags & FLAGS_ALT;
727 if(p->flags & FLAGS_CHAR) {
729 if (!(p->flags & FLAGS_LEFT))
733 if (p->flags & FLAGS_LEFT)
738 if(p->flags & FLAGS_UNSIGNED) {
739 /* Decimal unsigned integer. */
741 goto unsigned_number;
743 if(p->flags & FLAGS_OCTAL) {
744 /* Octal unsigned integer. */
746 goto unsigned_number;
748 if(p->flags & FLAGS_HEX) {
749 /* Hexadecimal unsigned integer. */
751 digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
753 goto unsigned_number;
756 /* Decimal integer. */
760 if(p->flags & FLAGS_LONGLONG) {
764 num = is_neg ? (- num) : num;
769 signed_num = (long) num;
771 is_neg = signed_num < 0;
772 num = is_neg ? (- signed_num) : signed_num;
777 /* Unsigned number of base BASE. */
781 /* Number of base BASE. */
783 char *workend = &work[sizeof(work) - 1];
786 /* Supply a default precision if none was given. */
790 /* Put the number in WORK. */
793 *w-- = digits[num % base];
796 width -= workend - w;
799 if (alt && base == 8 && prec <= 0) {
810 if (alt && base == 16)
813 if (is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE))
816 if (!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL))
822 else if (p->flags & FLAGS_SHOWSIGN)
824 else if (p->flags & FLAGS_SPACE)
827 if (alt && base == 16) {
829 if(p->flags & FLAGS_UPPER)
835 if (!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL))
839 /* Write the number. */
840 while (++w <= workend) {
844 if (p->flags & FLAGS_LEFT)
853 static char null[] = "(nil)";
857 str = (char *) p->data.str;
859 /* Write null[] if there's space. */
860 if (prec == -1 || prec >= (long) sizeof(null) - 1) {
862 len = sizeof(null) - 1;
863 /* Disable quotes around (nil) */
864 p->flags &= (~FLAGS_ALT);
874 if (prec != -1 && (size_t) prec < len)
878 if (p->flags & FLAGS_ALT)
881 if (!(p->flags&FLAGS_LEFT))
887 if (p->flags&FLAGS_LEFT)
891 if (p->flags & FLAGS_ALT)
897 /* Generic pointer. */
900 ptr = (void *) p->data.ptr;
902 /* If the pointer is not NULL, write it as a %#x spec. */
904 digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
906 num = (unsigned long) ptr;
911 /* Write "(nil)" for a nil pointer. */
912 static char nil[] = "(nil)";
913 register char *point;
915 width -= sizeof(nil) - 1;
916 if (p->flags & FLAGS_LEFT)
919 for (point = nil; *point != '\0'; ++point)
921 if (! (p->flags & FLAGS_LEFT))
930 char formatbuf[32]="%";
934 if (p->flags & FLAGS_WIDTH)
936 else if (p->flags & FLAGS_WIDTHPARAM)
937 width = vto[p->width].data.num;
940 if (p->flags & FLAGS_PREC)
942 else if (p->flags & FLAGS_PRECPARAM)
943 prec = vto[p->precision].data.num;
945 if (p->flags & FLAGS_LEFT)
946 strcat(formatbuf, "-");
947 if (p->flags & FLAGS_SHOWSIGN)
948 strcat(formatbuf, "+");
949 if (p->flags & FLAGS_SPACE)
950 strcat(formatbuf, " ");
951 if (p->flags & FLAGS_ALT)
952 strcat(formatbuf, "#");
954 fptr=&formatbuf[strlen(formatbuf)];
957 /* RECURSIVE USAGE */
958 fptr += curl_msprintf(fptr, "%d", width);
961 /* RECURSIVE USAGE */
962 fptr += curl_msprintf(fptr, ".%d", prec);
964 if (p->flags & FLAGS_LONG)
967 if (p->flags & FLAGS_FLOATE)
968 strcat(fptr, p->flags&FLAGS_UPPER?"E":"e");
969 else if (p->flags & FLAGS_FLOATG)
970 strcat(fptr, (p->flags & FLAGS_UPPER) ? "G" : "g");
974 /* NOTE NOTE NOTE!! Not all sprintf() implementations returns number
975 of output characters */
976 #if SIZEOF_LONG_DOUBLE
977 if (p->flags & FLAGS_LONG)
978 /* This is for support of the 'long double' type */
979 (sprintf)(work, formatbuf, p->data.ldnum);
982 (sprintf)(work, formatbuf, p->data.dnum);
984 for(fptr=work; *fptr; fptr++)
990 /* Answer the count of characters written. */
992 if (p->flags & FLAGS_LONGLONG)
993 *(long long int *) p->data.ptr = done;
996 if (p->flags & FLAGS_LONG)
997 *(long int *) p->data.ptr = done;
998 else if (!(p->flags & FLAGS_SHORT))
999 *(int *) p->data.ptr = done;
1001 *(short int *) p->data.ptr = done;
1007 f = *end++; /* goto end of %-code */
1013 /* fputc() look-alike */
1014 static int addbyter(int output, FILE *data)
1016 struct nsprintf *infop=(struct nsprintf *)data;
1018 if(infop->length < infop->max) {
1019 /* only do this if we haven't reached max length yet */
1020 infop->buffer[0] = (char)output; /* store */
1021 infop->buffer++; /* increase pointer */
1022 infop->length++; /* we are now one byte larger */
1023 return output; /* fputc() returns like this on success */
1028 int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...)
1030 va_list ap_save; /* argument pointer */
1032 struct nsprintf info;
1034 info.buffer = buffer;
1036 info.max = maxlength;
1038 va_start(ap_save, format);
1039 retcode = dprintf_formatf(&info, addbyter, format, ap_save);
1041 info.buffer[0] = 0; /* we terminate this with a zero byte */
1043 /* we could even return things like */
1048 int curl_mvsnprintf(char *buffer, size_t maxlength, const char *format, va_list ap_save)
1051 struct nsprintf info;
1053 info.buffer = buffer;
1055 info.max = maxlength;
1057 retcode = dprintf_formatf(&info, addbyter, format, ap_save);
1058 info.buffer[0] = 0; /* we terminate this with a zero byte */
1063 /* fputc() look-alike */
1064 static int alloc_addbyter(int output, FILE *data)
1066 struct asprintf *infop=(struct asprintf *)data;
1068 if(!infop->buffer) {
1069 infop->buffer=(char *)malloc(32);
1071 return -1; /* fail */
1075 else if(infop->len+1 >= infop->alloc) {
1078 newptr = (char *)realloc(infop->buffer, infop->alloc*2);
1083 infop->buffer = newptr;
1087 infop->buffer[ infop->len ] = output;
1091 return output; /* fputc() returns like this on success */
1095 char *curl_maprintf(const char *format, ...)
1097 va_list ap_save; /* argument pointer */
1099 struct asprintf info;
1105 va_start(ap_save, format);
1106 retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
1109 info.buffer[info.len] = 0; /* we terminate this with a zero byte */
1116 char *curl_mvaprintf(const char *format, va_list ap_save)
1119 struct asprintf info;
1125 retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
1126 info.buffer[info.len] = 0; /* we terminate this with a zero byte */
1128 info.buffer[info.len] = 0; /* we terminate this with a zero byte */
1135 static int storebuffer(int output, FILE *data)
1137 char **buffer = (char **)data;
1138 **buffer = (char)output;
1140 return output; /* act like fputc() ! */
1143 int curl_msprintf(char *buffer, const char *format, ...)
1145 va_list ap_save; /* argument pointer */
1147 va_start(ap_save, format);
1148 retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
1150 *buffer=0; /* we terminate this with a zero byte */
1154 extern int fputc(int, FILE *);
1156 int curl_mprintf(const char *format, ...)
1159 va_list ap_save; /* argument pointer */
1160 va_start(ap_save, format);
1161 retcode = dprintf_formatf(stdout, fputc, format, ap_save);
1166 int curl_mfprintf(FILE *whereto, const char *format, ...)
1169 va_list ap_save; /* argument pointer */
1170 va_start(ap_save, format);
1171 retcode = dprintf_formatf(whereto, fputc, format, ap_save);
1176 int curl_mvsprintf(char *buffer, const char *format, va_list ap_save)
1179 retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
1180 *buffer=0; /* we terminate this with a zero byte */
1184 int curl_mvprintf(const char *format, va_list ap_save)
1186 return dprintf_formatf(stdout, fputc, format, ap_save);
1189 int curl_mvfprintf(FILE *whereto, const char *format, va_list ap_save)
1191 return dprintf_formatf(whereto, fputc, format, ap_save);
1194 #ifdef DPRINTF_DEBUG
1199 #ifdef SIZEOF_LONG_LONG
1201 dprintf("%3$12s %1$s %2$qd %4$d\n", "daniel", hullo, "stenberg", 65);
1204 mprintf("%3d %5d\n", 10, 1998);
1206 ptr=maprintf("test this then baby %s%s%s%s%s%s %d %d %d loser baby get a hit in yer face now!", "", "pretty long string pretty long string pretty long string pretty long string pretty long string", "/", "/", "/", "pretty long string", 1998, 1999, 2001);
1210 memset(ptr, 55, strlen(ptr)+1);
1215 mprintf(buffer, "%s %s %d", "daniel", "stenberg", 19988);
1218 mfprintf(stderr, "%s %#08x\n", "dummy", 65);
1220 printf("%s %#08x\n", "dummy", 65);
1222 double tryout = 3.14156592;
1223 mprintf(buffer, "%.2g %G %f %e %E", tryout, tryout, tryout, tryout, tryout);
1225 printf("%.2g %G %f %e %E\n", tryout, tryout, tryout, tryout, tryout);