From 7398ee11f1b268e0812daf9709f1a7c57d331aa4 Mon Sep 17 00:00:00 2001 From: yamadapc Date: Wed, 30 Jul 2014 20:12:01 -0300 Subject: [PATCH] Fix a bunch of bugs in the `cwrite` module. We had problems with format parameters dispatching (`cwritefln` ended up calling `format` with '\n' as a trailing - orphan - format parameter), `format` not being imported from `std.string` and an infinitely recursive template case for the overloaded `cwritef` function. This also bumps the version to 0.2.1. --- source/colorize/cwrite.d | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/colorize/cwrite.d b/source/colorize/cwrite.d index 00be507..eec7944 100644 --- a/source/colorize/cwrite.d +++ b/source/colorize/cwrite.d @@ -17,15 +17,15 @@ void cwrite(T...)(T args) if (!is(T[0] : File)) } /// Coloured writef. -void cwritef(T...)(T args) +void cwritef(Char, T...)(in Char[] fmt, T args) if (!is(T[0] : File)) { - stdout.cwritef(args); + stdout.cwritef(fmt, args); } /// Coloured writefln. -void cwritefln(T...)(T args) +void cwritefln(Char, T...)(in Char[] fmt, T args) { - stdout.cwritef(args, "\n"); + stdout.cwritef(fmt ~ "\n", args); } /// Coloured writeln. @@ -38,6 +38,7 @@ void cwriteln(T...)(T args) /// Coloured writef to a File. void cwritef(Char, A...)(File f, in Char[] fmt, A args) { + import std.string : format; auto s = format(fmt, args); f.cwrite(s); } @@ -71,3 +72,4 @@ void cwrite(S...)(File f, S args) f.write(s); } } +