mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Updated stream API.
This commit is contained in:
committed by
Christoffer Lerno
parent
a6cff5c2a5
commit
9a6d83f526
@@ -38,7 +38,7 @@ fn void! brainf(String program)
|
||||
io::putchar(memory[mem]);
|
||||
io::stdout().flush();
|
||||
case ',':
|
||||
memory[mem] = io::stdin().getc()!!;
|
||||
memory[mem] = io::stdin().read_byte()!!;
|
||||
case '[':
|
||||
usz indent = 1;
|
||||
if (memory[mem]) continue;
|
||||
|
||||
@@ -19,7 +19,7 @@ struct StringData @private
|
||||
char[*] chars;
|
||||
}
|
||||
|
||||
fn void Summary.print(Summary *s, File out)
|
||||
fn void Summary.print(Summary *s, File* out)
|
||||
{
|
||||
String title = s.title ? s.title.as_str() : "missing";
|
||||
out.printf("Summary({ .title = %s, .ok = %s})", title, s.ok);
|
||||
|
||||
@@ -6,6 +6,6 @@ fn void! main()
|
||||
defer f.close()!!;
|
||||
while (!f.eof())
|
||||
{
|
||||
@pool() { io::printn(f.tgetline()); };
|
||||
@pool() { io::printn(f.treadline()!); };
|
||||
}
|
||||
}
|
||||
@@ -10,15 +10,15 @@ fault TokenResult
|
||||
|
||||
// While we could have written this with libc
|
||||
// the C way, let's showcase some features added to C3.
|
||||
fn void main(String[] args)
|
||||
fn void! main(String[] args)
|
||||
{
|
||||
// Grab a string from stdin
|
||||
DString s = io::stdin().getline();
|
||||
String s = io::stdin().readline()!;
|
||||
// Delete it at scope end [defer]
|
||||
defer s.free();
|
||||
|
||||
// Grab the string as a slice.
|
||||
String numbers = s.as_str();
|
||||
// Copy the slice, which doesn't change the underlying data.
|
||||
String numbers = s;
|
||||
|
||||
// Track our current value
|
||||
int val = 0;
|
||||
|
||||
@@ -7,7 +7,7 @@ fn void! main()
|
||||
String command = env::WIN32 ? "dir" : "ls";
|
||||
SubProcess x = process::create({ command }, { .search_user_path = true })!!;
|
||||
x.join()!;
|
||||
Stream stream = x.stdout().as_stream();
|
||||
Stream* stream = &&x.stdout();
|
||||
while (try char b = stream.read_byte())
|
||||
{
|
||||
io::printf("%c", b);
|
||||
|
||||
Reference in New Issue
Block a user