From 8cc32992624ed4140fb136d98675f0f19b20ba09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 17 Jan 2009 16:50:34 +0100 Subject: Change NUL char handling of isspecial() Replace isspecial() by the new macro is_glob_special(), which is more, well, specialized. The former included the NUL char in its character class, while the letter only included characters that are special to file name globbing. The new name contains underscores because they enhance readability considerably now that it's made up of three words. Renaming the function is necessary to document its changed scope. The call sites of isspecial() are updated to check explicitly for NUL. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- grep.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'grep.c') diff --git a/grep.c b/grep.c index 6485760ff3..f9a45258aa 100644 --- a/grep.c +++ b/grep.c @@ -30,8 +30,9 @@ void append_grep_pattern(struct grep_opt *opt, const char *pat, static int isregexspecial(int c) { - return isspecial(c) || c == '$' || c == '(' || c == ')' || c == '+' || - c == '.' || c == '^' || c == '{' || c == '|'; + return c == '\0' || is_glob_special(c) || + c == '$' || c == '(' || c == ')' || c == '+' || + c == '.' || c == '^' || c == '{' || c == '|'; } static int is_fixed(const char *s) -- cgit v1.2.1 From f9b7cce61cbd19c99e89b859b5909f0741111185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 17 Jan 2009 16:50:37 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- grep.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'grep.c') diff --git a/grep.c b/grep.c index f9a45258aa..062b2b6f28 100644 --- a/grep.c +++ b/grep.c @@ -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; } -- cgit v1.2.1