diff options
| author | 2025-09-14 04:11:09 -0700 | |
|---|---|---|
| committer | 2025-09-14 04:11:09 -0700 | |
| commit | 749197a3f9d25e211615960c02380a3d659b20f9 (patch) | |
| tree | 9c892349f0a7136edb150f27f549dc182f7699bb /codegen/gbp.zig | |
| parent | Update codebase to Zig 0.15.1. (diff) | |
| download | zg-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/gbp.zig')
| -rw-r--r-- | codegen/gbp.zig | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/codegen/gbp.zig b/codegen/gbp.zig index d654cf1..895aa7a 100644 --- a/codegen/gbp.zig +++ b/codegen/gbp.zig | |||
| @@ -61,14 +61,11 @@ pub fn main() anyerror!void { | |||
| 61 | var emoji_set = std.AutoHashMap(u21, void).init(allocator); | 61 | var emoji_set = std.AutoHashMap(u21, void).init(allocator); |
| 62 | defer emoji_set.deinit(); | 62 | defer emoji_set.deinit(); |
| 63 | 63 | ||
| 64 | var line_buf: [4096]u8 = undefined; | ||
| 65 | |||
| 66 | // Process Indic | 64 | // Process Indic |
| 67 | var indic_file = try std.fs.cwd().openFile("data/unicode/DerivedCoreProperties.txt", .{}); | 65 | const indic_file = @embedFile("DerivedCoreProperties.txt"); |
| 68 | defer indic_file.close(); | 66 | var indic_reader = std.io.Reader.fixed(indic_file); |
| 69 | var indic_reader = indic_file.reader(&line_buf); | ||
| 70 | 67 | ||
| 71 | while (indic_reader.interface.takeDelimiterExclusive('\n')) |line| { | 68 | while (indic_reader.takeDelimiterExclusive('\n')) |line| { |
| 72 | if (line.len == 0 or line[0] == '#') continue; | 69 | if (line.len == 0 or line[0] == '#') continue; |
| 73 | if (std.mem.indexOf(u8, line, "InCB") == null) continue; | 70 | if (std.mem.indexOf(u8, line, "InCB") == null) continue; |
| 74 | const no_comment = if (std.mem.indexOfScalar(u8, line, '#')) |octo| line[0..octo] else line; | 71 | const no_comment = if (std.mem.indexOfScalar(u8, line, '#')) |octo| line[0..octo] else line; |
| @@ -106,11 +103,10 @@ pub fn main() anyerror!void { | |||
| 106 | }, | 103 | }, |
| 107 | } | 104 | } |
| 108 | // Process GBP | 105 | // Process GBP |
| 109 | var gbp_file = try std.fs.cwd().openFile("data/unicode/auxiliary/GraphemeBreakProperty.txt", .{}); | ||
| 110 | defer gbp_file.close(); | ||
| 111 | var gbp_reader = gbp_file.reader(&line_buf); | ||
| 112 | 106 | ||
| 113 | while (gbp_reader.interface.takeDelimiterExclusive('\n')) |line| { | 107 | var gbp_reader = std.io.Reader.fixed(@embedFile("GraphemeBreakProperty.txt")); |
| 108 | |||
| 109 | while (gbp_reader.takeDelimiterExclusive('\n')) |line| { | ||
| 114 | if (line.len == 0 or line[0] == '#') continue; | 110 | if (line.len == 0 or line[0] == '#') continue; |
| 115 | const no_comment = if (std.mem.indexOfScalar(u8, line, '#')) |octo| line[0..octo] else line; | 111 | const no_comment = if (std.mem.indexOfScalar(u8, line, '#')) |octo| line[0..octo] else line; |
| 116 | 112 | ||
| @@ -147,11 +143,10 @@ pub fn main() anyerror!void { | |||
| 147 | }, | 143 | }, |
| 148 | } | 144 | } |
| 149 | // Process Emoji | 145 | // Process Emoji |
| 150 | var emoji_file = try std.fs.cwd().openFile("data/unicode/emoji/emoji-data.txt", .{}); | ||
| 151 | defer emoji_file.close(); | ||
| 152 | var emoji_reader = emoji_file.reader(&line_buf); | ||
| 153 | 146 | ||
| 154 | while (emoji_reader.interface.takeDelimiterExclusive('\n')) |line| { | 147 | var emoji_reader = std.io.Reader.fixed(@embedFile("emoji-data.txt")); |
| 148 | |||
| 149 | while (emoji_reader.takeDelimiterExclusive('\n')) |line| { | ||
| 155 | if (line.len == 0 or line[0] == '#') continue; | 150 | if (line.len == 0 or line[0] == '#') continue; |
| 156 | if (std.mem.indexOf(u8, line, "Extended_Pictographic") == null) continue; | 151 | if (std.mem.indexOf(u8, line, "Extended_Pictographic") == null) continue; |
| 157 | const no_comment = if (std.mem.indexOfScalar(u8, line, '#')) |octo| line[0..octo] else line; | 152 | const no_comment = if (std.mem.indexOfScalar(u8, line, '#')) |octo| line[0..octo] else line; |