return n;
}
-read_line :: (use reader: ^Reader, allocator := context.allocator) -> str {
+read_line :: (use reader: ^Reader, consume_newline := true, allocator := context.allocator) -> str {
_, curr_pos := stream_tell(stream);
count := 0;
if err != Error.None do break;
}
+ if consume_newline do count += 1;
+
stream_seek(stream, curr_pos, SeekFrom.Start);
out := str.{
#load "core/std"
use package core
-use package core.string.reader as reader
Vec2 :: struct {
x: i32 = 0;
main :: (args: [] cstr) {
contents := #file_contents "./tests/aoc-2020/input/day24.txt";
- file := reader.make(contents);
+ file_stream := io.string_stream_make(contents);
+ file := io.reader_make(^file_stream);
grid := map.make(Vec2, Cell, .{}, 1021); // `true` is black
defer map.free(^grid);
- while !reader.empty(^file) {
- line := reader.read_line(^file);
+ while !io.stream_end_of_file(^file_stream) {
+ line := io.read_line(^file);
loc := Vec2.{ 0, 0 };
s := 0;
println(word);
}
- println(io.read_line(^sreader, context.temp_allocator));
+ println(io.read_line(^sreader, consume_newline=false, allocator=context.temp_allocator));
a := io.read_u32(^sreader);
b := io.read_u32(^sreader);