[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/9] grep: change struct matcher termination
From: |
Paolo Bonzini |
Subject: |
[PATCH 3/9] grep: change struct matcher termination |
Date: |
Fri, 19 Mar 2010 12:36:46 +0100 |
* src/grep.c (setmatcher): Look for NULL matchers[i].name.
* src/grep.h (struct matcher): Change name to pointer. Adjust comments.
* src/search.c (matchers): Terminate with three NULLs.
---
src/grep.c | 2 +-
src/grep.h | 4 ++--
src/search.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/grep.c b/src/grep.c
index 8193bc5..538d4c8 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1586,7 +1586,7 @@ install_matcher (char const *name)
{
int i;
- for (i = 0; matchers[i].compile; i++)
+ for (i = 0; matchers[i].name; i++)
if (strcmp (name, matchers[i].name) == 0)
{
compile = matchers[i].compile;
diff --git a/src/grep.h b/src/grep.h
index 51b6d0c..8a0ca3b 100644
--- a/src/grep.h
+++ b/src/grep.h
@@ -47,11 +47,11 @@ typedef COMPILE_RET (*compile_fp_t) COMPILE_ARGS;
typedef EXECUTE_RET (*execute_fp_t) EXECUTE_ARGS;
/* grep.c expects the matchers vector to be terminated
- by an entry with a NULL compile, and to contain at least
+ by an entry with a NULL name, and to contain at least
an entry named "default". */
extern struct matcher
{
- char name[8];
+ const char *name;
compile_fp_t compile;
execute_fp_t execute;
} const matchers[];
diff --git a/src/search.c b/src/search.c
index 1d3868a..9cb4abb 100644
--- a/src/search.c
+++ b/src/search.c
@@ -847,6 +847,6 @@ struct matcher const matchers[] = {
{ "awk", Acompile, EGexecute },
{ "fgrep", Fcompile, Fexecute },
{ "perl", Pcompile, Pexecute },
- { "", 0, 0 },
+ { NULL, NULL, NULL },
};
#endif /* GREP_PROGRAM */
--
1.6.6.1
- [PATCH 0/9] remove most {,E,F}GREP_PROGRAM occurrences, Paolo Bonzini, 2010/03/19
- [PATCH 1/9] grep: remove getpagesize.h, Paolo Bonzini, 2010/03/19
- [PATCH 2/9] grep: remove one #ifdef, Paolo Bonzini, 2010/03/19
- [PATCH 3/9] grep: change struct matcher termination,
Paolo Bonzini <=
- [PATCH 4/9] grep: make egrep/fgrep use struct matcher, Paolo Bonzini, 2010/03/19
- [PATCH 5/9] grep: eliminate {COMPILE,EXECUTE}_{RET,ARGS,FCT}, Paolo Bonzini, 2010/03/19
- [PATCH 6/9] grep: remove one #ifdef, Paolo Bonzini, 2010/03/19
- [PATCH 8/9] grep: prepare for libification of *search.c, Paolo Bonzini, 2010/03/19