From 2d7959f03575e637d56924c14e2a37b54368953e Mon Sep 17 00:00:00 2001 From: Jose Colon Rodriguez Date: Tue, 26 Mar 2024 21:53:04 -0400 Subject: GraphemeData and Normalize non-pub fns --- src/Normalize.zig | 12 ++++++------ src/grapheme.zig | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Normalize.zig b/src/Normalize.zig index b5a54d1..6ef7c90 100644 --- a/src/Normalize.zig +++ b/src/Normalize.zig @@ -91,8 +91,8 @@ const Decomp = struct { cps: []const u21 = &.{}, }; -/// `mapping` retrieves the decomposition mapping for a code point as per the UCD. -pub fn mapping(self: Self, cp: u21, form: Form) Decomp { +// `mapping` retrieves the decomposition mapping for a code point as per the UCD. +fn mapping(self: Self, cp: u21, form: Form) Decomp { var dc = Decomp{}; switch (form) { @@ -117,8 +117,8 @@ pub fn mapping(self: Self, cp: u21, form: Form) Decomp { return dc; } -/// `decompose` a code point to the specified normalization form, which should be either `.nfd` or `.nfkd`. -pub fn decompose( +// `decompose` a code point to the specified normalization form, which should be either `.nfd` or `.nfkd`. +fn decompose( self: Self, cp: u21, form: Form, @@ -587,8 +587,8 @@ fn getTrailCcc(self: Self, cp: u21) u8 { return self.norm_data.ccc_data.ccc(dcp); } -/// Fast check to detect if a string is already in NFC or NFD form. -pub fn isFcd(self: Self, str: []const u8) bool { +// Fast check to detect if a string is already in NFC or NFD form. +fn isFcd(self: Self, str: []const u8) bool { var prev_ccc: u8 = 0; var cp_iter = CodePointIterator{ .bytes = str }; diff --git a/src/grapheme.zig b/src/grapheme.zig index 7125b5b..e55a6a4 100644 --- a/src/grapheme.zig +++ b/src/grapheme.zig @@ -4,7 +4,7 @@ const unicode = std.unicode; const CodePoint = @import("code_point").CodePoint; const CodePointIterator = @import("code_point").Iterator; -pub const Data = @import("GraphemeData"); +pub const GraphemeData = @import("GraphemeData"); /// `Grapheme` represents a Unicode grapheme cluster by its length and offset in the source bytes. pub const Grapheme = struct { @@ -22,12 +22,12 @@ pub const Grapheme = struct { pub const Iterator = struct { buf: [2]?CodePoint = .{ null, null }, cp_iter: CodePointIterator, - data: *Data, + data: *const GraphemeData, const Self = @This(); /// Assumes `src` is valid UTF-8. - pub fn init(str: []const u8, data: *Data) Self { + pub fn init(str: []const u8, data: *const GraphemeData) Self { var self = Self{ .cp_iter = .{ .bytes = str }, .data = data }; self.advance(); return self; @@ -80,7 +80,7 @@ pub const Iterator = struct { }; // Predicates -fn isBreaker(cp: u21, data: *Data) bool { +fn isBreaker(cp: u21, data: *const GraphemeData) bool { // Extract relevant properties. const cp_gbp_prop = data.gbp(cp); return cp == '\x0d' or cp == '\x0a' or cp_gbp_prop == .Control; @@ -133,7 +133,7 @@ const State = struct { pub fn graphemeBreak( cp1: u21, cp2: u21, - data: *Data, + data: *const GraphemeData, state: *State, ) bool { // Extract relevant properties. @@ -237,7 +237,7 @@ test "Segmentation GraphemeIterator" { var buf_reader = std.io.bufferedReader(file.reader()); var input_stream = buf_reader.reader(); - var data = try Data.init(allocator); + var data = try GraphemeData.init(allocator); defer data.deinit(); var buf: [4096]u8 = undefined; @@ -302,7 +302,7 @@ test "Segmentation ZWJ and ZWSP emoji sequences" { const with_zwsp = seq_1 ++ "\u{200B}" ++ seq_2; const no_joiner = seq_1 ++ seq_2; - var data = try Data.init(std.testing.allocator); + var data = try GraphemeData.init(std.testing.allocator); defer data.deinit(); var iter = Iterator.init(with_zwj, &data); -- cgit v1.2.3