From a1c2c81bab7e47cd47b661de3cdf6b2567ecaff6 Mon Sep 17 00:00:00 2001 From: kokorokonekuto <199444877+kokorokonekuto@users.noreply.github.com> Date: Fri, 9 May 2025 13:03:11 +0530 Subject: [PATCH] re.c: fix recursive call arguments and set CC optionally When calling the recursive varient of matchpattern, it doesn't call the function with the matchlength argument. This patch fixes it. Also, set Makefile CC to gcc when GNU/make can't find the default CC path. This fixes compilation on other Unix-like platforms where CC defaults to clang (we previously explicitly set this to GCC). --- Makefile | 2 +- re.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 26b97ff..860e502 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Compiler to use - can be replaced by clang for instance -CC := gcc +CC ?= gcc # Number of random text expressions to generate, for random testing NRAND_TESTS := 1000 diff --git a/re.c b/re.c index 20d1474..1e32544 100644 --- a/re.c +++ b/re.c @@ -478,7 +478,7 @@ static int matchpattern(regex_t* pattern, const char* text, int *matchlength) else if ((text[0] != '\0') && matchone(pattern[0], text[0])) { (*matchlength)++; - return matchpattern(&pattern[1], text+1); + return matchpattern(&pattern[1], text+1, matchlength); } else {