Add is_regex_special()

Add is_regex_special(), a character class macro for chars that have a
special meaning in regular expressions.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2009-01-17 16:50:37 +01:00
committed by Junio C Hamano
parent 8cc3299262
commit f9b7cce61c
4 changed files with 13 additions and 11 deletions

9
grep.c
View File

@ -28,16 +28,9 @@ void append_grep_pattern(struct grep_opt *opt, const char *pat,
p->next = NULL;
}
static int isregexspecial(int c)
{
return c == '\0' || is_glob_special(c) ||
c == '$' || c == '(' || c == ')' || c == '+' ||
c == '.' || c == '^' || c == '{' || c == '|';
}
static int is_fixed(const char *s)
{
while (!isregexspecial(*s))
while (*s && !is_regex_special(*s))
s++;
return !*s;
}