| author | |
| committer | |
| log | b2fbe35178db709c2d9e240c5315e6e137366397 |
| tree | c06c8f5b4c341406546d58d6761e9be186be3142 |
| parent | c5781c41c29fab2503be89178519d6396d4066e7 |
3 files changed, 9 insertions(+), 14 deletions(-)
scripts/Jamo.zig+2-3| ... | @@ -26,9 +26,8 @@ pub usingnamespace common.Main(struct { | ... | @@ -26,9 +26,8 @@ pub usingnamespace common.Main(struct { |
| 26 | var it = std.mem.tokenizeAny(u8, line, "; "); | 26 | var it = std.mem.tokenizeAny(u8, line, "; "); |
| 27 | 27 | ||
| 28 | const first = it.next().?; | 28 | const first = it.next().?; |
| 29 | const next = it.next().?; | 29 | const short = it.next() orelse ""; |
| 30 | const actual = if (std.mem.eql(u8, next, "#")) "" else next; | ||
| 31 | 30 | ||
| 32 | try writer.print(" .{{ .code = 0x{s}, .short_name = \"{}\" }},\n", .{ first, std.zig.fmtEscapes(actual) }); | 31 | try writer.print(" .{{ .code = 0x{s}, .short_name = \"{}\" }},\n", .{ first, std.zig.fmtEscapes(short) }); |
| 33 | } | 32 | } |
| 34 | }); | 33 | }); |
scripts/ScriptExtensions.zig+2-6| ... | @@ -34,18 +34,14 @@ pub usingnamespace common.Main(struct { | ... | @@ -34,18 +34,14 @@ pub usingnamespace common.Main(struct { |
| 34 | const end = try std.fmt.parseInt(u21, first[index + 2 ..], 16); | 34 | const end = try std.fmt.parseInt(u21, first[index + 2 ..], 16); |
| 35 | var i = start; | 35 | var i = start; |
| 36 | while (i <= end) : (i += 1) { | 36 | while (i <= end) : (i += 1) { |
| 37 | try writer.print(" .{{ .code = 0x{X}, .scripts = {} }},\n", .{ i, fmtScripts(untilComment(it.rest())) }); | 37 | try writer.print(" .{{ .code = 0x{X}, .scripts = {} }},\n", .{ i, fmtScripts(it.rest()) }); |
| 38 | } | 38 | } |
| 39 | } else { | 39 | } else { |
| 40 | try writer.print(" .{{ .code = 0x{s}, .scripts = {} }},\n", .{ first, fmtScripts(untilComment(it.rest())) }); | 40 | try writer.print(" .{{ .code = 0x{s}, .scripts = {} }},\n", .{ first, fmtScripts(it.rest()) }); |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | }); | 43 | }); |
| 44 | 44 | ||
| 45 | fn untilComment(input: []const u8) []const u8 { | ||
| 46 | return input[0..std.mem.indexOfScalar(u8, input, '#').?]; | ||
| 47 | } | ||
| 48 | |||
| 49 | fn fmtScripts(bytes: []const u8) std.fmt.Formatter(formatScripts) { | 45 | fn fmtScripts(bytes: []const u8) std.fmt.Formatter(formatScripts) { |
| 50 | return .{ .data = bytes }; | 46 | return .{ .data = bytes }; |
| 51 | } | 47 | } |
scripts/_common.zig+5-5| ... | @@ -54,18 +54,18 @@ pub fn Main(comptime T: type) type { | ... | @@ -54,18 +54,18 @@ pub fn Main(comptime T: type) type { |
| 54 | var arena = std.heap.ArenaAllocator.init(alloc); | 54 | var arena = std.heap.ArenaAllocator.init(alloc); |
| 55 | defer arena.deinit(); | 55 | defer arena.deinit(); |
| 56 | while (true) { | 56 | while (true) { |
| 57 | const line = r.readUntilDelimiterAlloc(alloc, '\n', max_size) catch |err| switch (err) { | 57 | const line_raw = r.readUntilDelimiterAlloc(alloc, '\n', max_size) catch |err| switch (err) { |
| 58 | error.EndOfStream => break, | 58 | error.EndOfStream => break, |
| 59 | else => |e| return e, | 59 | else => |e| return e, |
| 60 | }; | 60 | }; |
| 61 | defer alloc.free(line); | 61 | defer alloc.free(line_raw); |
| 62 | |||
| 63 | var real = std.mem.splitScalar(u8, line_raw, '#'); | ||
| 64 | const line = real.first(); | ||
| 62 | 65 | ||
| 63 | if (line.len == 0) { | 66 | if (line.len == 0) { |
| 64 | continue; | 67 | continue; |
| 65 | } | 68 | } |
| 66 | if (line[0] == '#') { | ||
| 67 | continue; | ||
| 68 | } | ||
| 69 | 69 | ||
| 70 | try T.exec(arena.allocator(), line, w); | 70 | try T.exec(arena.allocator(), line, w); |
| 71 | 71 |