diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-24 20:35:32 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-24 20:35:32 -0400 |
| commit | 9c4627fb7d6dbc748386106e2e51d149b2c38ed8 (patch) | |
| tree | 2988155d64f03534c76f5266025f7cddac8969e0 | |
| parent | 4ec3e11b9f542a0239de7bedad9d732b0a20d68b (diff) | |
Some fixes
| -rw-r--r-- | match.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -2,7 +2,6 @@ // match.c - Code for the BP virtual machine that performs the matching. // -#include <ctype.h> #include <err.h> #include <limits.h> #include <setjmp.h> @@ -308,8 +307,8 @@ __attribute__((nonnull(1, 2, 3))) static bp_match_t *_next_match(match_ctx_t *ct // past areas where we know we won't find a match. if (!skip && first->type == BP_STRING && first->min_matchlen > 0) { char *found = ctx->ignorecase ? strcasestr(str, When(first, BP_STRING)->string) - : strnstr(str, When(first, BP_STRING)->string, - MIN((size_t)(ctx->end - str), first->min_matchlen)); + : memmem(str, (size_t)(ctx->end - str), When(first, BP_STRING)->string, + strlen(When(first, BP_STRING)->string)); str = found ? found : ctx->end; } else if (!skip && str > ctx->start && (first->type == BP_START_OF_LINE || first->type == BP_END_OF_LINE)) { char *found = memchr(str, '\n', (size_t)(ctx->end - str)); |
