From cf016e798eef6b04085298186373e39b8471b692 Mon Sep 17 00:00:00 2001 From: Ethan Evans Date: Tue, 25 Nov 2025 18:53:11 -0800 Subject: [PATCH] Update to zig 0.15.1 --- .gitignore | 2 ++ build.zig | 21 +++++++-------------- build.zig.zon | 8 +++++++- src/lib.zig | 8 ++++---- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 4c14adf..525ac4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ **/zig-out/ **/zig-cache/ + +.zig-cache/* \ No newline at end of file diff --git a/build.zig b/build.zig index 6ae7d3f..4812ae1 100644 --- a/build.zig +++ b/build.zig @@ -15,18 +15,13 @@ pub fn build(b: *std.Build) void { // set a preferred release mode, allowing the user to decide how to optimize. const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("deunicode", .{ - .source_file = .{ .path = "src/lib.zig" }, - .dependencies = &.{}, - }); - - const lib = b.addStaticLibrary(.{ + const lib = b.addLibrary(.{ .name = "deunicode", - // In this case the main source file is merely a path, however, in more - // complicated build scripts, this could be a generated file. - .root_source_file = .{ .path = "src/lib.zig" }, - .target = target, - .optimize = optimize, + .root_module = b.addModule("deunicode", .{ + .root_source_file = b.path("src/lib.zig"), + .target = target, + .optimize = optimize, + }), }); // This declares intent for the library to be installed into the standard @@ -37,9 +32,7 @@ pub fn build(b: *std.Build) void { // Creates a step for unit testing. This only builds the test executable // but does not run it. const main_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/lib.zig" }, - .target = target, - .optimize = optimize, + .root_module = lib.root_module, }); const run_main_tests = b.addRunArtifact(main_tests); diff --git a/build.zig.zon b/build.zig.zon index 60e16d2..8822f66 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,5 +1,11 @@ .{ - .name = "deunicode", + .name = .deunicode, .version = "0.1.0", + .fingerprint = 0x315001c71c0958c8, .dependencies = .{}, + .paths = .{ + "build.zig", + "build.zig.zon", + "src", + }, } diff --git a/src/lib.zig b/src/lib.zig index b3e0ca6..1aa3069 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -102,7 +102,7 @@ pub fn deunicodeCustomAlloc(allocator: Allocator, s: []const u8, custom_placehol // reserve a bit more space to avoid reallocations on longer transliterations // but instead of `+ 16` uses `| 15` to stay in the smallest allocation bucket for short strings - var out = try std.ArrayList(u8).initCapacity(allocator, s.len | 15); + var out = try std.array_list.Managed(u8).initCapacity(allocator, s.len | 15); defer out.deinit(); const ascii = s[0..ascii_len]; @@ -179,7 +179,7 @@ pub fn deunicodeCustom(out: []u8, s: []const u8, custom_placeholder: []const u8) break; } - std.mem.copy(u8, out[cursor .. cursor + ascii_len], s[0..ascii_len]); + std.mem.copyForwards(u8, out[cursor .. cursor + ascii_len], s[0..ascii_len]); cursor += ascii_len; if (ascii_len >= s.len) { @@ -208,14 +208,14 @@ pub fn deunicodeCustom(out: []u8, s: []const u8, custom_placeholder: []const u8) has_next_cache = false; if (res == null) { - std.mem.copy(u8, out[cursor .. cursor + custom_placeholder.len], custom_placeholder); + std.mem.copyForwards(u8, out[cursor .. cursor + custom_placeholder.len], custom_placeholder); cursor += custom_placeholder.len; continue; } const chars = res.?; - std.mem.copy(u8, out[cursor .. cursor + chars.len], chars); + std.mem.copyForwards(u8, out[cursor .. cursor + chars.len], chars); cursor += chars.len; // true if end