fixed grep

This commit is contained in:
Your Name 2024-11-14 19:15:20 +03:00
parent c601693811
commit f26953c707

View File

@ -89,12 +89,16 @@ static int addpattern(const char *str, const size_t size) {
else if (w_flag) 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) ? "$" : ""); 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) if (regcomp(&ptrns[ptrns_size]->reg, reg_str, reg_flag) < 0)
goto ADDP_ERROR; flag = 1;
ptrns[ptrns_size]->reg_set = 1; ptrns[ptrns_size]->reg_set = 1;
if (x_flag || w_flag) if (x_flag || w_flag)
free(reg_str); free(reg_str);
if (flag)
goto ADDP_ERROR;
} }
ptrns_size++; ptrns_size++;