summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Levert <charles_levert@gna.org>2005-07-05 01:17:41 +0000
committerCharles Levert <charles_levert@gna.org>2005-07-05 01:17:41 +0000
commite0a07a796e573cbabd7cd1416c4e36179b712273 (patch)
tree61b6578ddd3342443f3fb2cba16e0ebe9a23ab68
parent14b00d96eb34379bfd26a2893cef7f2e5c6b6406 (diff)
downloadgrep-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.
-rw-r--r--ChangeLog6
-rw-r--r--src/kwset.c8
2 files changed, 12 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f201a485..56e2609a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,12 @@
* doc/grep.texi: Add missing green color in GREP_COLORS description.
* doc/grep.1: Fix typo and reorganize GREP_COLORS documentation.
+ * 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.
+
2005-07-04 Charles Levert <charles_levert@gna.org>
* src/kwset.c: Readability changes.
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;