diff options
author | Charles Levert <charles_levert@gna.org> | 2005-07-05 01:17:41 +0000 |
---|---|---|
committer | Charles Levert <charles_levert@gna.org> | 2005-07-05 01:17:41 +0000 |
commit | e0a07a796e573cbabd7cd1416c4e36179b712273 (patch) | |
tree | 61b6578ddd3342443f3fb2cba16e0ebe9a23ab68 /src | |
parent | 14b00d96eb34379bfd26a2893cef7f2e5c6b6406 (diff) | |
download | grep-e0a07a796e573cbabd7cd1416c4e36179b712273.tar.gz |
* src/kwset.c (DEPTH_SIZE): New macro to anticipate
architectures/compilers where CHAR_BIT is not 8 (we assume it
won't be less than 4, which would be non-standard and unlikely).
Checked to hold for CHAR_BIT up to 1023 (and maybe more)!
* src/kwset.c (kwsincr): Use DEPTH_SIZE in two array declarations.
Diffstat (limited to 'src')
-rw-r--r-- | src/kwset.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/kwset.c b/src/kwset.c index 8c08ac51..b9197b88 100644 --- a/src/kwset.c +++ b/src/kwset.c @@ -121,6 +121,10 @@ kwsalloc (char const *trans) return (kwset_t) kwset; } +/* This upper bound is valid for CHAR_BIT >= 4 and + exact for CHAR_BIT in { 4..11, 13, 15, 17, 19 }. */ +#define DEPTH_SIZE (CHAR_BIT + CHAR_BIT/2) + /* Add the given string to the contents of the keyword set. Return NULL for success, an error message otherwise. */ const char * @@ -131,8 +135,8 @@ kwsincr (kwset_t kws, char const *text, size_t len) register unsigned char label; register struct tree *link; register int depth; - struct tree *links[12]; - enum { L, R } dirs[12]; + struct tree *links[DEPTH_SIZE]; + enum { L, R } dirs[DEPTH_SIZE]; struct tree *t, *r, *l, *rl, *lr; kwset = (struct kwset *) kws; |