diff --git a/build.zig b/build.zig index 18e8286..db4b25e 100755 --- a/build.zig +++ b/build.zig @@ -1,17 +1,18 @@ const std = @import("std"); -pub fn build(b: *std.build.Builder) void { +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + // Standard release options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. - const mode = b.standardReleaseOptions(); - - const lib = b.addStaticLibrary("ctregex", "ctregex.zig"); - lib.setBuildMode(mode); - lib.install(); + const optimize = b.standardOptimizeOption(.{}); - const main_tests = b.addTest("tests.zig"); - main_tests.setBuildMode(mode); + const lib = b.addStaticLibrary(.{ + .name = "ctregex", + .root_source_file = .{ .path = "ctregex.zig" }, + .target = target, + .optimize = optimize, + }); - const test_step = b.step("test", "Run library tests"); - test_step.dependOn(&main_tests.step); + b.installArtifact(lib); } diff --git a/ctregex.zig b/ctregex.zig index bc14fd1..35c9f05 100644 --- a/ctregex.zig +++ b/ctregex.zig @@ -630,7 +630,7 @@ const RegexParser = struct { fn ctStr(comptime self: Brackets) []const u8 { var str: []const u8 = "["; if (self.is_exclusive) str = str ++ " "; - for (self.rules) |rule, idx| { + for (self.rules, 0..) |rule, idx| { if (idx > 0) str = str ++ " "; str = str ++ switch (rule) { .char => |c| ctUtf8EncodeChar(c), @@ -885,7 +885,7 @@ pub fn MatchResult(comptime regex: []const u8, comptime options: MatchOptions) t if (RegexParser.parse(regex)) |parsed| { const capture_len = parsed.captures.len; var capture_names: [capture_len]?[]const u8 = undefined; - for (parsed.captures) |capt, idx| { + for (parsed.captures, 0..) |capt, idx| { if (capt.capture_info) |info| { capture_names[idx] = info.name; } @@ -906,7 +906,7 @@ pub fn MatchResult(comptime regex: []const u8, comptime options: MatchOptions) t pub usingnamespace if (capture_len != 0) struct { pub fn capture(self: Self, comptime name: []const u8) ?[]const CharT { - inline for (capture_names2) |maybe_name, curr_idx| { + inline for (capture_names2, 0..) |maybe_name, curr_idx| { if (maybe_name) |curr_name| { if (comptime std.mem.eql(u8, name, curr_name)) return self.captures[curr_idx];