Skip to content

Commit e79d4d2

Browse files
committed
Sys.print() added
1 parent ec6e2ec commit e79d4d2

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

druntime/src/core/system/package.d

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,31 @@ struct Mem
2121
struct Sys
2222
{
2323
static import core.stdc.stdlib;
24+
import core.stdc.stdio;
2425

2526
alias abort = core.stdc.stdlib.abort;
27+
28+
// Assumes str is null-terminated string
29+
static void print(scope const char[] str) nothrow @nogc
30+
{
31+
auto r = fputs(str.ptr, stdout);
32+
if(r < 0)
33+
Sys.abort();
34+
}
35+
36+
//~ void print(T)(scope const char[] str, T vals) nothrow @nogc
37+
//~ {
38+
//~ // Assume str is null-terminated string
39+
//~ auto r = fputs(str.ptr, stdout);
40+
//~ if(r < 0)
41+
//~ Sys.abort();
42+
//~ }
43+
44+
//~ alias format = snprintf
2645
}
2746

28-
// Special case: we don't have resources to implement formatting functionality
29-
// for now just for the sake of using it at debugging
47+
// Special case: we don't have resources to implement mature formatting
48+
// functionality for now just for the sake of using it at debugging
3049
debug
3150
{
3251
static import core.stdc.stdio;

0 commit comments

Comments
 (0)