diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-17 21:54:29 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-17 21:54:29 +0000 |
commit | c45abbab1ec69d239eebd602c5c249736c31ea4c (patch) | |
tree | 46342c43c0d19099b0d803cfd05eab08f7e366f2 /usr.bin/diff | |
parent | 9d6d3eb6b3892b849bcbf39950ec2281c02349c5 (diff) |
cc -O2 -pipe -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DDIRENT=1 -DDYN_ALLOC -c unpGet rid of ugly hack in readhash() that appears to be there for
machines with a 16 bit word size. Also replace (HALFLONG - 1) with
a new define, HASHMASK since it really is a mask.
None of this results in any actual change in behavior.
Diffstat (limited to 'usr.bin/diff')
-rw-r--r-- | usr.bin/diff/diffreg.c | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index f2bad0095e8..74e8a5451e8 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.34 2003/07/16 21:39:06 millert Exp $ */ +/* $OpenBSD: diffreg.c,v 1.35 2003/07/17 21:54:28 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -65,7 +65,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.34 2003/07/16 21:39:06 millert Exp $"; +static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.35 2003/07/17 21:54:28 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -1066,10 +1066,7 @@ fetch(long *f, int a, int b, FILE *lb, char *s, int oldfile) } } -#define POW2 /* define only if HALFLONG is 2**n */ -#define HALFLONG 16 -#define low(x) (x&((1L<<HALFLONG)-1)) -#define high(x) (x>>HALFLONG) +#define HASHMASK (16 - 1) /* for masking out 16 bytes */ /* * hashing has the effect of @@ -1093,12 +1090,7 @@ readhash(FILE *f) return (0); break; } - sum += (long)chrtran[t] << (shift -#ifdef POW2 - &= HALFLONG - 1); -#else - %= HALFLONG); -#endif + sum += (long)chrtran[t] << (shift &= HASHMASK); } else for (shift = 0; (t = getc(f)) != '\n'; shift += 7) { @@ -1107,12 +1099,7 @@ readhash(FILE *f) return (0); break; } - sum += (long)t << (shift -#ifdef POW2 - &= HALFLONG - 1); -#else - %= HALFLONG); -#endif + sum += (long)t << (shift &= HASHMASK); } } else { for (shift = 0;;) { @@ -1126,12 +1113,7 @@ readhash(FILE *f) shift += 7; space = 0; } - sum += (long)chrtran[t] << (shift -#ifdef POW2 - &= HALFLONG - 1); -#else - %= HALFLONG); -#endif + sum += (long)chrtran[t] << (shift &= HASHMASK); shift += 7; continue; case EOF: @@ -1144,8 +1126,7 @@ readhash(FILE *f) break; } } - sum = low(sum) + high(sum); - return ((short) low(sum) + (short) high(sum)); + return (sum); } int |