~leon_plickat/public-inbox

zig-exre: Update to Zig 0.13.0 v2 PROPOSED

Sebastian LaVine: 1
 Update to Zig 0.13.0

 5 files changed, 28 insertions(+), 13 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~leon_plickat/public-inbox/patches/54257/mbox | git am -3
Learn more about email & git

[PATCH zig-exre v2] Update to Zig 0.13.0 Export this patch

---
v1 -> v2: Fixed iteration crash, added std.fs.Dir.OpenOptions param

 .gitignore    |  2 ++
 README.md     |  2 +-
 build.zig     | 13 +++++++------
 build.zig.zon | 11 +++++++++++
 cmd.zig       | 13 +++++++------
 5 files changed, 28 insertions(+), 13 deletions(-)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3389c86
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
.zig-cache/
zig-out/
diff --git a/README.md b/README.md
index a394e38..582416a 100644
--- a/README.md
+++ b/README.md
@@ -113,7 +113,7 @@ clone of the `grep` utility and perform performance measurement respectively.

## Zig Version

zig-exre is developed against zig releases. Currently zig 0.11.0.
zig-exre is developed against zig releases. Currently zig 0.13.0.

## Contributing

diff --git a/build.zig b/build.zig
index 71c12eb..6e9b9db 100644
--- a/build.zig
@@ -1,25 +1,26 @@
const std = @import("std");
const Builder = std.build.Builder;

pub fn build(b: *Builder) void {
pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const exre_mod = b.addModule("exre", .{
        .source_file = .{ .path = "exre.zig" },
        .root_source_file = b.path("exre.zig"),
        .target = target,
        .optimize = optimize,
    });

    const exe = b.addExecutable(.{
        .name = "exre",
        .root_source_file = .{ .path = "cmd.zig" },
        .root_source_file = b.path("cmd.zig"),
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("exre", exre_mod);
    exe.root_module.addImport("exre", exre_mod);
    b.installArtifact(exe);

    const tests = b.addTest(.{
        .root_source_file = .{ .path = "exre.zig" },
        .root_source_file = b.path("exre.zig"),
        .target = target,
        .optimize = optimize,
    });
diff --git a/build.zig.zon b/build.zig.zon
index 6499f2f..8ad0dfa 100644
--- a/build.zig.zon
@@ -1,4 +1,15 @@
.{
    .name = "exre",
    .version = "0.1.0",
    .minimum_zig_version = "0.11.0",
    .paths = .{
        "build.zig",
        "build.zig.zon",
        "cmd.zig",
        "exre.zig",
        "LICENSE",
        "perf.py",
        "README.md",
        ".meta",
    },
}
diff --git a/cmd.zig b/cmd.zig
index f56a0d1..9e1fadd 100644
--- a/cmd.zig
+++ b/cmd.zig
@@ -1,13 +1,14 @@
const exre = @import("exre");
const std = @import("std");
const ascii = std.ascii;
const fmt = std.fmt;
const fs = std.fs;
const heap = std.heap;
const io = std.io;
const fmt = std.fmt;
const log = std.log.scoped(.grep);
const mem = std.mem;
const os = std.os;
const log = std.log.scoped(.grep);
const posix = std.posix;
const time = std.time;

const gpa = heap.page_allocator;
@@ -45,7 +46,7 @@ pub fn main() !u8 {
}

fn grep(writer: anytype, r: exre.Regex(.{}), case_sensitive: bool) !void {
    var dir = try fs.cwd().openIterableDir(".", .{});
    var dir = try fs.cwd().openDir(".", .{ .iterate = true });
    defer dir.close();

    var dir_it = dir.iterate();
@@ -56,9 +57,9 @@ fn grep(writer: anytype, r: exre.Regex(.{}), case_sensitive: bool) !void {

        if (!mem.endsWith(u8, name, ".zig")) continue;

        var stat: os.system.Stat = mem.zeroes(os.system.Stat);
        _ = os.system.lstat(name, &stat);
        if ((stat.mode & os.S.IFMT) != os.S.IFREG) continue;
        var stat: posix.system.Stat = mem.zeroes(posix.system.Stat);
        _ = posix.system.lstat(name, &stat);
        if ((stat.mode & posix.S.IFMT) != posix.S.IFREG) continue;

        const file = try fs.cwd().openFile(name, .{});
        defer file.close();
-- 
2.45.2
Thanks!

--
Friendly greetings,
Leon Henrik Plickat