summaryrefslogtreecommitdiff
path: root/codegen/scripts.zig
diff options
context:
space:
mode:
authorGravatar Michael Chaten2025-09-14 04:11:09 -0700
committerGravatar Michael Chaten2025-09-14 04:11:09 -0700
commit749197a3f9d25e211615960c02380a3d659b20f9 (patch)
tree9c892349f0a7136edb150f27f549dc182f7699bb /codegen/scripts.zig
parentUpdate codebase to Zig 0.15.1. (diff)
downloadzg-749197a3f9d25e211615960c02380a3d659b20f9.tar.gz
zg-749197a3f9d25e211615960c02380a3d659b20f9.tar.xz
zg-749197a3f9d25e211615960c02380a3d659b20f9.zip
Embed data files in scripts rather than relying on filesystem access for easier packaging
Diffstat (limited to 'codegen/scripts.zig')
-rw-r--r--codegen/scripts.zig11
1 files changed, 3 insertions, 8 deletions
diff --git a/codegen/scripts.zig b/codegen/scripts.zig
index bdd3d9d..81511cc 100644
--- a/codegen/scripts.zig
+++ b/codegen/scripts.zig
@@ -203,14 +203,9 @@ pub fn main() anyerror!void {
203 var flat_map = std.AutoHashMap(u21, u8).init(allocator); 203 var flat_map = std.AutoHashMap(u21, u8).init(allocator);
204 defer flat_map.deinit(); 204 defer flat_map.deinit();
205 205
206 var line_buf: [4096]u8 = undefined; 206 // Process Scripts.txt
207 207 var in_reader = std.io.Reader.fixed(@embedFile("Scripts.txt"));
208 // Process DerivedGeneralCategory.txt 208 while (in_reader.takeDelimiterExclusive('\n')) |line| {
209 var in_file = try std.fs.cwd().openFile("data/unicode/Scripts.txt", .{});
210 defer in_file.close();
211 var in_reader = in_file.reader(&line_buf);
212
213 while (in_reader.interface.takeDelimiterExclusive('\n')) |line| {
214 if (line.len == 0 or line[0] == '#') continue; 209 if (line.len == 0 or line[0] == '#') continue;
215 210
216 const no_comment = if (std.mem.indexOfScalar(u8, line, '#')) |octo| line[0..octo] else line; 211 const no_comment = if (std.mem.indexOfScalar(u8, line, '#')) |octo| line[0..octo] else line;