Skip to content

Commit 7398ee1

Browse files
committed
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.
1 parent 0a762e9 commit 7398ee1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

source/colorize/cwrite.d

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ void cwrite(T...)(T args) if (!is(T[0] : File))
1717
}
1818

1919
/// Coloured writef.
20-
void cwritef(T...)(T args)
20+
void cwritef(Char, T...)(in Char[] fmt, T args) if (!is(T[0] : File))
2121
{
22-
stdout.cwritef(args);
22+
stdout.cwritef(fmt, args);
2323
}
2424

2525
/// Coloured writefln.
26-
void cwritefln(T...)(T args)
26+
void cwritefln(Char, T...)(in Char[] fmt, T args)
2727
{
28-
stdout.cwritef(args, "\n");
28+
stdout.cwritef(fmt ~ "\n", args);
2929
}
3030

3131
/// Coloured writeln.
@@ -38,6 +38,7 @@ void cwriteln(T...)(T args)
3838
/// Coloured writef to a File.
3939
void cwritef(Char, A...)(File f, in Char[] fmt, A args)
4040
{
41+
import std.string : format;
4142
auto s = format(fmt, args);
4243
f.cwrite(s);
4344
}
@@ -71,3 +72,4 @@ void cwrite(S...)(File f, S args)
7172
f.write(s);
7273
}
7374
}
75+

0 commit comments

Comments
 (0)