[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/9] grep: eliminate {COMPILE,EXECUTE}_{RET,ARGS,FCT}
From: |
Paolo Bonzini |
Subject: |
[PATCH 5/9] grep: eliminate {COMPILE,EXECUTE}_{RET,ARGS,FCT} |
Date: |
Fri, 19 Mar 2010 12:36:48 +0100 |
Modern compilers warn about type mismatches.
* src/grep.c (do_execute): Write full declaration.
* src/grep.h (COMPILE_RET, COMPILE_ARGS, COMPILE_FCT, EXECUTE_RET,
EXECUTE_ARGS, EXECUTE_FCT): Remove.
(compile_fp_t, execute_fp_t): Write full declaration.
* src/search.c (GEAcompile, Gcompile, Acompile, Ecompile, EGexecute,
Fcompile, Fexecute, Pcompile, Pexecute): Write full declaration.
---
src/grep.c | 3 ++-
src/grep.h | 16 ++--------------
src/search.c | 26 +++++++++++++++++---------
3 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/src/grep.c b/src/grep.c
index 6c78479..b3e0fdb 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1023,7 +1023,8 @@ prtext (char const *beg, char const *lim, int *nlinesp)
used = 1;
}
-static EXECUTE_RET do_execute EXECUTE_ARGS
+static size_t
+do_execute (char const *buf, size_t size, size_t *match_size, char const
*start_ptr)
{
size_t result;
const char *line_next;
diff --git a/src/grep.h b/src/grep.h
index 1277b61..9a9fe49 100644
--- a/src/grep.h
+++ b/src/grep.h
@@ -29,21 +29,9 @@
# define GREP_PROGRAM
#endif
-/* The two functions each matcher provides. */
-#define COMPILE_RET void
-#define COMPILE_ARGS \
- (char const *pattern, size_t size)
-#define EXECUTE_RET size_t
-#define EXECUTE_ARGS \
- (char const *buf, size_t size, size_t *match_size, char const *start_ptr)
- /* start_ptr == NULL means the caller is not looking for an exact match. */
-
-# define COMPILE_FCT(f) static COMPILE_RET f COMPILE_ARGS
-# define EXECUTE_FCT(f) static EXECUTE_RET f EXECUTE_ARGS
-
/* Function pointer types. */
-typedef COMPILE_RET (*compile_fp_t) COMPILE_ARGS;
-typedef EXECUTE_RET (*execute_fp_t) EXECUTE_ARGS;
+typedef void (*compile_fp_t) (char const *, size_t);
+typedef size_t (*execute_fp_t) (char const *, size_t, size_t *, char const *);
/* grep.c expects the matchers vector to be terminated by an entry
* with a NULL name, and to contain at least an entry. */
diff --git a/src/search.c b/src/search.c
index daa4bb3..fece394 100644
--- a/src/search.c
+++ b/src/search.c
@@ -258,7 +258,7 @@ is_mb_middle(const char **good, const char *buf, const char
*end)
#if defined(GREP_PROGRAM) || defined(EGREP_PROGRAM)
/* No __VA_ARGS__ in C89. So we have to do it this way. */
-static COMPILE_RET
+static void
GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits)
{
const char *err;
@@ -349,24 +349,28 @@ GEAcompile (char const *pattern, size_t size,
reg_syntax_t syntax_bits)
}
#ifndef EGREP_PROGRAM
-COMPILE_FCT(Gcompile)
+static void
+Gcompile (char const *pattern, size_t size)
{
return GEAcompile (pattern, size,
RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE);
}
-COMPILE_FCT(Acompile)
+static void
+Acompile (char const *pattern, size_t size)
{
return GEAcompile (pattern, size, RE_SYNTAX_AWK);
}
#endif /* !EGREP_PROGRAM */
-COMPILE_FCT(Ecompile)
+static void
+Ecompile (char const *pattern, size_t size)
{
return GEAcompile (pattern, size, RE_SYNTAX_POSIX_EGREP);
}
-EXECUTE_FCT(EGexecute)
+static size_t
+EGexecute (char const *buf, size_t size, size_t *match_size, char const
*start_ptr)
{
char const *buflim, *beg, *end, *match, *best_match, *mb_start;
char eol = eolbyte;
@@ -559,7 +563,8 @@ EXECUTE_FCT(EGexecute)
#endif /* defined(GREP_PROGRAM) || defined(EGREP_PROGRAM) */
#if defined(GREP_PROGRAM) || defined(FGREP_PROGRAM)
-COMPILE_FCT(Fcompile)
+static void
+Fcompile (char const *pattern, size_t size)
{
char const *beg, *end, *lim, *err, *pat;
size_t psize;
@@ -603,7 +608,8 @@ COMPILE_FCT(Fcompile)
error (EXIT_TROUBLE, 0, "%s", err);
}
-EXECUTE_FCT(Fexecute)
+static size_t
+Fexecute (char const *buf, size_t size, size_t *match_size, char const
*start_ptr)
{
char const *beg, *try, *end, *mb_start;
size_t len;
@@ -698,7 +704,8 @@ static pcre *cre;
static pcre_extra *extra;
#endif
-COMPILE_FCT(Pcompile)
+static void
+Pcompile (char const *pattern, size_t size)
{
#if !HAVE_LIBPCRE
error (EXIT_TROUBLE, 0, "%s",
@@ -764,7 +771,8 @@ COMPILE_FCT(Pcompile)
#endif
}
-EXECUTE_FCT(Pexecute)
+static size_t
+Pexecute (char const *buf, size_t size, size_t *match_size, char const
*start_ptr)
{
#if !HAVE_LIBPCRE
abort ();
--
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, 2010/03/19
- [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 <=
- [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
- [PATCH 9/9] grep: libify *search.c, Paolo Bonzini, 2010/03/19
- [PATCH 7/9] grep: split search.c, Paolo Bonzini, 2010/03/19