From 48e572ada95ed125de0b383aeb78422931eb28eb Mon Sep 17 00:00:00 2001 From: millert Date: Thu, 17 Jul 2003 21:54:28 +0000 Subject: 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. --- usr.bin/diff/diffreg.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'usr.bin/diff/diffreg.c') 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 @@ -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) +#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 -- cgit v1.2.3-59-g8ed1b