summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--src/GeneralCategories.zig11
2 files changed, 2 insertions, 11 deletions
diff --git a/README.md b/README.md
index 56592ce..5b471b5 100644
--- a/README.md
+++ b/README.md
@@ -94,7 +94,7 @@ test "Code point iterator" {
94## Grapheme Clusters 94## Grapheme Clusters
95 95
96Many characters are composed from more than one code point. These are known as 96Many characters are composed from more than one code point. These are known as
97Grapheme Clusters and the `grapheme` module has a data structure to represent 97Grapheme Clusters, and the `Graphemes` module has a data structure to represent
98them, `Grapheme`, and an `Iterator` to iterate over them in a string. 98them, `Grapheme`, and an `Iterator` to iterate over them in a string.
99 99
100In your `build.zig`: 100In your `build.zig`:
diff --git a/src/GeneralCategories.zig b/src/GeneralCategories.zig
index 3e76d82..8c1b6a3 100644
--- a/src/GeneralCategories.zig
+++ b/src/GeneralCategories.zig
@@ -47,15 +47,6 @@ pub fn init(allocator: Allocator) Allocator.Error!GeneralCategories {
47} 47}
48 48
49pub fn setup(gencat: *GeneralCategories, allocator: Allocator) Allocator.Error!void { 49pub fn setup(gencat: *GeneralCategories, allocator: Allocator) Allocator.Error!void {
50 gencat.setupInner(allocator) catch |err| {
51 switch (err) {
52 error.OutOfMemory => |e| return e,
53 else => unreachable,
54 }
55 };
56}
57
58inline fn setupInner(gencat: *GeneralCategories, allocator: Allocator) !void {
59 const decompressor = compress.flate.inflate.decompressor; 50 const decompressor = compress.flate.inflate.decompressor;
60 const in_bytes = @embedFile("gencat"); 51 const in_bytes = @embedFile("gencat");
61 var in_fbs = std.io.fixedBufferStream(in_bytes); 52 var in_fbs = std.io.fixedBufferStream(in_bytes);
@@ -67,7 +58,7 @@ inline fn setupInner(gencat: *GeneralCategories, allocator: Allocator) !void {
67 const s1_len: u16 = reader.readInt(u16, endian) catch unreachable; 58 const s1_len: u16 = reader.readInt(u16, endian) catch unreachable;
68 gencat.s1 = try allocator.alloc(u16, s1_len); 59 gencat.s1 = try allocator.alloc(u16, s1_len);
69 errdefer allocator.free(gencat.s1); 60 errdefer allocator.free(gencat.s1);
70 for (0..s1_len) |i| gencat.s1[i] = try reader.readInt(u16, endian); 61 for (0..s1_len) |i| gencat.s1[i] = reader.readInt(u16, endian) catch unreachable;
71 62
72 const s2_len: u16 = reader.readInt(u16, endian) catch unreachable; 63 const s2_len: u16 = reader.readInt(u16, endian) catch unreachable;
73 gencat.s2 = try allocator.alloc(u5, s2_len); 64 gencat.s2 = try allocator.alloc(u5, s2_len);