FYI, some clean-up, in preparation for the dfa.c merge from gawk: >From bedc0229b071ff536a631462e74113913f4c645f Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Thu, 11 Mar 2010 15:12:47 +0100 Subject: [PATCH 1/3] maint: remove now-useless prototypes
* src/dfa.c: Remove the prototype of each static, non-recursive function whose definition precedes first use. --- src/dfa.c | 40 ---------------------------------------- 1 files changed, 0 insertions(+), 40 deletions(-) diff --git a/src/dfa.c b/src/dfa.c index 2567bc2..2bd01e5 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -99,47 +99,7 @@ #endif static void dfamust PARAMS ((struct dfa *dfa)); - -static ptr_t xcalloc PARAMS ((size_t n, size_t s)); -static ptr_t xmalloc PARAMS ((size_t n)); -static ptr_t xrealloc PARAMS ((ptr_t p, size_t n)); -#ifdef DEBUG -static void prtok PARAMS ((token t)); -#endif -static int tstbit PARAMS ((unsigned b, charclass c)); -static void setbit PARAMS ((unsigned b, charclass c)); -static void clrbit PARAMS ((unsigned b, charclass c)); -static void copyset PARAMS ((charclass src, charclass dst)); -static void zeroset PARAMS ((charclass s)); -static void notset PARAMS ((charclass s)); -static int equal PARAMS ((charclass s1, charclass s2)); -static int charclass_index PARAMS ((charclass s)); -static int looking_at PARAMS ((const char *s)); -static token lex PARAMS ((void)); -static void addtok PARAMS ((token t)); -static void atom PARAMS ((void)); -static int nsubtoks PARAMS ((int tindex)); -static void copytoks PARAMS ((int tindex, int ntokens)); -static void closure PARAMS ((void)); -static void branch PARAMS ((void)); static void regexp PARAMS ((int toplevel)); -static void copy PARAMS ((position_set const *src, position_set *dst)); -static void insert PARAMS ((position p, position_set *s)); -static void merge PARAMS ((position_set const *s1, position_set const *s2, position_set *m)); -static void delete PARAMS ((position p, position_set *s)); -static int state_index PARAMS ((struct dfa *d, position_set const *s, - int newline, int letter)); -static void build_state PARAMS ((int s, struct dfa *d)); -static void build_state_zero PARAMS ((struct dfa *d)); -static char *icatalloc PARAMS ((char *old, char *new)); -static char *icpyalloc PARAMS ((char *string)); -static char *istrstr PARAMS ((char *lookin, char *lookfor)); -static void ifree PARAMS ((char *cp)); -static void freelist PARAMS ((char **cpp)); -static char **enlist PARAMS ((char **cpp, char *new, size_t len)); -static char **comsubs PARAMS ((char *left, char *right)); -static char **addlists PARAMS ((char **old, char **new)); -static char **inboth PARAMS ((char **left, char **right)); static ptr_t xcalloc (size_t n, size_t s) -- 1.7.0.2.393.gfb6b >From bed24c8e8adf8635f407e3bdb516174d85f78016 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Thu, 11 Mar 2010 15:06:37 +0100 Subject: [PATCH 2/3] maint: remove all uses of PARAMS * lib/savedir.h (PARAMS): Remove definitions manually. Remove the remaining ones via this command: git grep -l define.PARAMS |xargs perl -ni -e '/define PARAMS/ or print' * src/dfa.h (PARAMS): Remove definitions. * src/system.h (PARAMS): Likewise. Remove most uses with this: git grep -lw PARAMS |xargs perl -pi -e 's/\bPARAMS *\((.*)\);/$1;/' Remove the remainder manually. --- lib/savedir.h | 14 +++----------- src/dfa.c | 8 ++++---- src/dfa.h | 23 +++++++++-------------- src/grep.c | 4 ++-- src/grep.h | 8 ++++---- src/kwset.h | 10 +++++----- src/system.h | 3 --- 7 files changed, 27 insertions(+), 43 deletions(-) diff --git a/lib/savedir.h b/lib/savedir.h index a5f6e44..003f7fe 100644 --- a/lib/savedir.h +++ b/lib/savedir.h @@ -3,17 +3,9 @@ #include "exclude.h" -# ifndef PARAMS -# if defined PROTOTYPES || (defined __STDC__ && __STDC__) -# define PARAMS(Args) Args -# else -# define PARAMS(Args) () -# endif -# endif - extern char * -savedir PARAMS ((const char *dir, off_t name_size, - struct exclude *, struct exclude *, - struct exclude *)); +savedir (const char *dir, off_t name_size, + struct exclude *, struct exclude *, + struct exclude *); #endif diff --git a/src/dfa.c b/src/dfa.c index 2bd01e5..a81dc83 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -98,8 +98,8 @@ # undef clrbit #endif -static void dfamust PARAMS ((struct dfa *dfa)); -static void regexp PARAMS ((int toplevel)); +static void dfamust (struct dfa *dfa); +static void regexp (int toplevel); static ptr_t xcalloc (size_t n, size_t s) @@ -670,7 +670,7 @@ is_blank (int c) the class. The leading [ has already been eaten by the lexical analyzer. */ static struct { const char *name; - int (*pred) PARAMS ((int)); + int (*pred) (int); } const prednames[] = { { ":alpha:]", is_alpha }, { ":upper:]", is_upper }, @@ -1029,7 +1029,7 @@ lex (void) for (c1 = 0; prednames[c1].name; ++c1) if (looking_at(prednames[c1].name)) { - int (*pred) PARAMS ((int)) = prednames[c1].pred; + int (*pred) (int) = prednames[c1].pred; for (c2 = 0; c2 < NOTCHAR; ++c2) if ((*pred)(c2)) diff --git a/src/dfa.h b/src/dfa.h index dbac197..ce8b951 100644 --- a/src/dfa.h +++ b/src/dfa.h @@ -23,21 +23,16 @@ In addition to clobbering modularity, we eat up valuable name space. */ -#ifdef PARAMS -# undef PARAMS -#endif #ifdef __STDC__ # ifndef _PTR_T # define _PTR_T typedef void * ptr_t; # endif -# define PARAMS(x) x #else # ifndef _PTR_T # define _PTR_T typedef char * ptr_t; # endif -# define PARAMS(x) () #endif /* Number of bits in an unsigned char. */ @@ -386,12 +381,12 @@ struct dfa /* dfasyntax() takes three arguments; the first sets the syntax bits described earlier in this file, the second sets the case-folding flag, and the third specifies the line terminator. */ -extern void dfasyntax PARAMS ((reg_syntax_t, int, unsigned char)); +extern void dfasyntax (reg_syntax_t, int, unsigned char); /* Compile the given string of the given length into the given struct dfa. Final argument is a flag specifying whether to build a searching or an exact matcher. */ -extern void dfacomp PARAMS ((char const *, size_t, struct dfa *, int)); +extern void dfacomp (char const *, size_t, struct dfa *, int); /* Execute the given struct dfa on the buffer of characters. The last byte of the buffer must equal the end-of-line byte. @@ -400,30 +395,30 @@ extern void dfacomp PARAMS ((char const *, size_t, struct dfa *, int)); order to verify backreferencing; otherwise the flag will be cleared. Returns (size_t) -1 if no match is found, or the offset of the first character after the first & shortest matching string in the buffer. */ -extern size_t dfaexec PARAMS ((struct dfa *, char const *, size_t, int *)); +extern size_t dfaexec (struct dfa *, char const *, size_t, int *); /* Free the storage held by the components of a struct dfa. */ -extern void dfafree PARAMS ((struct dfa *)); +extern void dfafree (struct dfa *); /* Entry points for people who know what they're doing. */ /* Initialize the components of a struct dfa. */ -extern void dfainit PARAMS ((struct dfa *)); +extern void dfainit (struct dfa *); /* Incrementally parse a string of given length into a struct dfa. */ -extern void dfaparse PARAMS ((char const *, size_t, struct dfa *)); +extern void dfaparse (char const *, size_t, struct dfa *); /* Analyze a parsed regexp; second argument tells whether to build a searching or an exact matcher. */ -extern void dfaanalyze PARAMS ((struct dfa *, int)); +extern void dfaanalyze (struct dfa *, int); /* Compute, for each possible character, the transitions out of a given state, storing them in an array of integers. */ -extern void dfastate PARAMS ((int, struct dfa *, int [])); +extern void dfastate (int, struct dfa *, int []); /* Error handling. */ /* dfaerror() is called by the regexp routines whenever an error occurs. It takes a single argument, a NUL-terminated string describing the error. The user must supply a dfaerror. */ -extern void dfaerror PARAMS ((const char *)); +extern void dfaerror (const char *); diff --git a/src/grep.c b/src/grep.c index 680d8de..c1c6152 100644 --- a/src/grep.c +++ b/src/grep.c @@ -371,9 +371,9 @@ static enum SKIP_DEVICES } devices = READ_DEVICES; -static int grepdir PARAMS ((char const *, struct stats const *)); +static int grepdir (char const *, struct stats const *); #if defined(HAVE_DOS_FILE_CONTENTS) -static inline int undossify_input PARAMS ((register char *, size_t)); +static inline int undossify_input (register char *, size_t); #endif /* Functions we'll use to search. */ diff --git a/src/grep.h b/src/grep.h index 1018a72..51b6d0c 100644 --- a/src/grep.h +++ b/src/grep.h @@ -43,8 +43,8 @@ # 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) PARAMS (COMPILE_ARGS); -typedef EXECUTE_RET (*execute_fp_t) PARAMS (EXECUTE_ARGS); +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 @@ -61,8 +61,8 @@ extern struct matcher # define COMPILE_FCT(f) COMPILE_RET compile COMPILE_ARGS # define EXECUTE_FCT(f) EXECUTE_RET execute EXECUTE_ARGS /* Function prototypes. */ -extern COMPILE_RET compile PARAMS (COMPILE_ARGS); -extern EXECUTE_RET execute PARAMS (EXECUTE_ARGS); +extern COMPILE_RET compile COMPILE_ARGS; +extern EXECUTE_RET execute EXECUTE_ARGS; #endif /* GREP_PROGRAM */ /* The following flags are exported from grep for the matchers diff --git a/src/kwset.h b/src/kwset.h index b5e3f5a..c1ea6f0 100644 --- a/src/kwset.h +++ b/src/kwset.h @@ -34,16 +34,16 @@ typedef ptr_t kwset_t; if enough memory cannot be obtained. The argument if non-NULL specifies a table of character translations to be applied to all pattern and search text. */ -extern kwset_t kwsalloc PARAMS((char const *)); +extern kwset_t kwsalloc (char const *); /* Incrementally extend the keyword set to include the given string. Return NULL for success, or an error message. Remember an index number for each keyword included in the set. */ -extern const char *kwsincr PARAMS((kwset_t, char const *, size_t)); +extern const char *kwsincr (kwset_t, char const *, size_t); /* When the keyword set has been completely built, prepare it for use. Return NULL for success, or an error message. */ -extern const char *kwsprep PARAMS((kwset_t)); +extern const char *kwsprep (kwset_t); /* Search through the given buffer for a member of the keyword set. Return a pointer to the leftmost longest match found, or NULL if @@ -51,8 +51,8 @@ extern const char *kwsprep PARAMS((kwset_t)); the matching substring in the integer it points to. Similarly, if foundindex is non-NULL, store the index of the particular keyword found therein. */ -extern size_t kwsexec PARAMS((kwset_t, char const *, size_t, struct kwsmatch *)); +extern size_t kwsexec (kwset_t, char const *, size_t, struct kwsmatch *); /* Deallocate the given keyword set and all its associated storage. */ -extern void kwsfree PARAMS((kwset_t)); +extern void kwsfree (kwset_t); diff --git a/src/system.h b/src/system.h index 93fdbf1..4f5e854 100644 --- a/src/system.h +++ b/src/system.h @@ -16,19 +16,16 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#undef PARAMS #if defined (__STDC__) && __STDC__ # ifndef _PTR_T # define _PTR_T typedef void * ptr_t; # endif -# define PARAMS(x) x #else # ifndef _PTR_T # define _PTR_T typedef char * ptr_t; # endif -# define PARAMS(x) () #endif #include <fcntl.h> -- 1.7.0.2.393.gfb6b >From 73595e9fd2df9af60be10004720e59acd1340a29 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Thu, 11 Mar 2010 15:48:52 +0100 Subject: [PATCH 3/3] maint: remove a trailing space * src/search.c (EXECUTE_FCT): Remove trailing space. maint: remove all uses of PARAMS Remove most with this: git grep -lw PARAMS |xargs perl -pi -e 's/\bPARAMS *\((.*)\);/$1;/' Remove the remainder manually. --- src/search.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/search.c b/src/search.c index c4e5149..bd44696 100644 --- a/src/search.c +++ b/src/search.c @@ -743,7 +743,7 @@ EXECUTE_FCT(Pexecute) /* PCRE can't limit the matching to single lines, therefore we have to match each line in the buffer separately. */ for (line_next = buf; - e == PCRE_ERROR_NOMATCH && line_next < buf + size; + e == PCRE_ERROR_NOMATCH && line_next < buf + size; start_ofs -= line_next - line_buf) { line_buf = line_next; -- 1.7.0.2.393.gfb6b
