From f26953c70726386a7c24746df4ea626a4d6361d5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 14 Nov 2024 19:15:20 +0300 Subject: [PATCH] fixed grep --- src/grep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/grep.c b/src/grep.c index 889b4ec..07329cf 100644 --- a/src/grep.c +++ b/src/grep.c @@ -89,12 +89,16 @@ static int addpattern(const char *str, const size_t size) { else if (w_flag) snprintf(reg_str, rs_size + 4, "%s\\<%s%.*s%s\\>%s", (bol) ? "^" : "", (E_flag) ? "(" : "\\(", (int)size - bol - eol, ptrns[ptrns_size]->str + bol, (E_flag) ? ")" : "\\)", (eol) ? "$" : ""); + char flag = 0; if (regcomp(&ptrns[ptrns_size]->reg, reg_str, reg_flag) < 0) - goto ADDP_ERROR; + flag = 1; ptrns[ptrns_size]->reg_set = 1; if (x_flag || w_flag) free(reg_str); + + if (flag) + goto ADDP_ERROR; } ptrns_size++;