tiehuis / zig-regex

A regex implementation for the zig programming language
MIT License
196 stars 24 forks source link

Incorrect match results #5

Closed joachimschmidt557 closed 4 years ago

joachimschmidt557 commented 4 years ago

Example to reproduce:

const std = @import("std");

const regex = @import("zig-regex/src/regex.zig");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    const allocator = &gpa.allocator;
    var re = try regex.Regex.compile(allocator, ".*emacs.*");

    std.debug.print("{}\n", .{try re.match("emacs-packages.nix")});
}

Output:

false

I'll try to look into what is causing this issue.

kivikakk commented 4 years ago

It appears to be because it invokes VmBacktrack instead of VmPike — I think it's not backtracking correctly. If I force it to use VmPike it matches correctly.

kivikakk commented 4 years ago

Concretely, here's how to get this returning true: https://github.com/kivikakk/zig-regex/commit/c81b4e548d0b24ca39783ba6e4c9f3554518361c

kivikakk commented 4 years ago

This is fixed by #9.