summaryrefslogtreecommitdiffstats
path: root/usr.bin/diff
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2003-07-17 21:54:28 +0000
committermillert <millert@openbsd.org>2003-07-17 21:54:28 +0000
commit48e572ada95ed125de0b383aeb78422931eb28eb (patch)
tree4e71bc87207f8e1e724dd1d432f54a39fb448595 /usr.bin/diff
parentA set of regressions to test diff(1). (diff)
downloadwireguard-openbsd-48e572ada95ed125de0b383aeb78422931eb28eb.tar.xz
wireguard-openbsd-48e572ada95ed125de0b383aeb78422931eb28eb.zip
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.c33
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