// Copyright 2022 DistressNetwork° // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. const std = @import("std"); const data = @import("data.zig"); const log = @import("log.zig").log; const Allocator = std.mem.Allocator; pub fn main() !u8 { const stdin = std.io.getStdIn(); const stdout = std.io.getStdOut(); var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); var alloc = arena.allocator(); defer arena.deinit(); const input = stdin.reader().readAllAlloc(alloc, data.input_max) catch |err| switch (err) { error.StreamTooLong => { log(.err, "input too large (maximum {})", .{std.fmt.fmtIntSizeBin(data.input_max)}); return 1; }, else => |e| return e, }; const lines = try data.split_lines(input, alloc); const text = data.textgen(lines, alloc) catch |err| switch (err) { error.NotFound => { return 1; }, else => |e| return e, }; for (text) |line| { try stdout.writer().print("{s}\n", .{line}); } return 0; }