--- \dmd.178\dmd\src\phobos\std\/format.d 2006年12月23日 20:43:24.000000000 +0200 +++ ./format.d 2006年12月28日 22:02:16.328125000 +0200 @@ -205,6 +205,7 @@ * putc = Output is sent do this delegate, character by character. * arguments = Array of TypeInfo's, one for each argument to be formatted. * argptr = Points to variadic argument list. + * parse = Boolean. The default of true will parse strings for ($I format specifications). * * Throws: * Mismatched arguments and formats result in a FormatError being thrown. @@ -442,8 +443,8 @@ ------------------------ */ -void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr) -{ int j; +void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr, bool parse =true) +{ TypeInfo ti; Mangle m; uint flags; @@ -601,7 +602,7 @@ putc('['); size_t tsize = ti.tsize(); while (len--) { - doFormat(putc, (&ti)[0 .. 1], p); + doFormat(putc, (&ti)[0 .. 1], p, false); p += tsize; if (len> 0) putc(','); } @@ -935,6 +936,7 @@ throw new FormatError("formatArg"); } + int j; for (j = 0; j < arguments.length; ) { ti = arguments[j++]; @@ -944,7 +946,7 @@ goto Lerror; m = cast(Mangle)ti.classinfo.name[9]; - if (m == Mangle.Tarray) + if (m == Mangle.Tarray && parse) { Mangle m2 = cast(Mangle)ti.classinfo.name[10]; char[] fmt; // format string --- \dmd.178\dmd\src\phobos\std\/stdio.d 2006-12-23 20:43:24.000000000 +0200 +++ ./stdio.d 2006-12-28 20:42:55.296875000 +0200 @@ -51,7 +51,7 @@ void __fp_unlock(FILE* fp) { } } -void writefx(FILE* fp, TypeInfo[] arguments, void* argptr, int newline=false) +void writefx(FILE* fp, TypeInfo[] arguments, void* argptr, bool newline=false, bool parse=true) { int orientation; orientation = fwide(fp, 0); @@ -80,7 +80,7 @@ } } - std.format.doFormat(&putc, arguments, argptr); + std.format.doFormat(&putc, arguments, argptr, parse); if (newline) FPUTC('\n', fp); } @@ -117,7 +117,7 @@ static assert(0); } - std.format.doFormat(&putcw, arguments, argptr); + std.format.doFormat(&putcw, arguments, argptr, parse); if (newline) FPUTWC('\n', fp); } @@ -130,6 +130,47 @@ /*********************************** + * Arguments are converted to strings + * and written to $(B stdout). + */ + +void write(...) +{ + writefx(stdout, _arguments, _argptr, false, false); +} + +/*********************************** + * Same as $(B write), but a newline is appended + * to the output. + */ + +void writeln(...) +{ + writefx(stdout, _arguments, _argptr, true, false); +} + +/*********************************** + * Same as $(B write), but output is sent to the + * stream fp instead of $(B stdout). + */ + +void fwrite(FILE* fp, ...) +{ + writefx(fp, _arguments, _argptr, false, false); +} + +/*********************************** + * Same as $(B writeln), but output is sent to the + * stream fp instead of $(B stdout). + */ + +void fwriteln(FILE* fp, ...) +{ + writefx(fp, _arguments, _argptr, true, false); +} + + +/*********************************** * Arguments are formatted per the * $(LINK2 std_format.html#format-string, format strings) * and written to $(B stdout). @@ -137,7 +178,7 @@ void writef(...) { - writefx(stdout, _arguments, _argptr, 0); + writefx(stdout, _arguments, _argptr, false); } /*********************************** @@ -147,7 +188,7 @@ void writefln(...) { - writefx(stdout, _arguments, _argptr, 1); + writefx(stdout, _arguments, _argptr, true); } /*********************************** @@ -157,7 +198,7 @@ void fwritef(FILE* fp, ...) { - writefx(fp, _arguments, _argptr, 0); + writefx(fp, _arguments, _argptr, false); } /*********************************** @@ -167,5 +208,5 @@ void fwritefln(FILE* fp, ...) { - writefx(fp, _arguments, _argptr, 1); + writefx(fp, _arguments, _argptr, true); }