Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint lint: clean up hash functions



details:   https://anonhg.NetBSD.org/src/rev/e5d1fc99e460
branches:  trunk
changeset: 1023189:e5d1fc99e460
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 28 21:52:14 2021 +0000

description:
lint: clean up hash functions

No functional change.

diffstat:

 usr.bin/xlint/lint1/lex.c  |  10 +++++-----
 usr.bin/xlint/lint2/hash.c |  12 +++++-------
 2 files changed, 10 insertions(+), 12 deletions(-)

diffs (75 lines):

diff -r 4963940e3393 -r e5d1fc99e460 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sat Aug 28 21:14:32 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sat Aug 28 21:52:14 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.77 2021/08/28 21:14:32 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.78 2021/08/28 21:52:14 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.77 2021/08/28 21:14:32 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.78 2021/08/28 21:52:14 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -397,11 +397,11 @@
 hash(const char *s)
 {
        unsigned int v;
-       const unsigned char *us;
+       const char *p;
 
        v = 0;
-       for (us = (const unsigned char *)s; *us != '\0'; us++) {
-               v = (v << 4) + *us;
+       for (p = s; *p != '\0'; p++) {
+               v = (v << 4) + (unsigned char)*p;
                v ^= v >> 28;
        }
        return v % HSHSIZ1;
diff -r 4963940e3393 -r e5d1fc99e460 usr.bin/xlint/lint2/hash.c
--- a/usr.bin/xlint/lint2/hash.c        Sat Aug 28 21:14:32 2021 +0000
+++ b/usr.bin/xlint/lint2/hash.c        Sat Aug 28 21:52:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hash.c,v 1.21 2021/08/28 19:27:44 rillig Exp $ */
+/*     $NetBSD: hash.c,v 1.22 2021/08/28 21:52:14 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: hash.c,v 1.21 2021/08/28 19:27:44 rillig Exp $");
+__RCSID("$NetBSD: hash.c,v 1.22 2021/08/28 21:52:14 rillig Exp $");
 #endif
 
 /*
@@ -54,8 +54,6 @@
 /* pointer to hash table, initialized in inithash() */
 static hte_t   **htab;
 
-static unsigned int hash(const char *);
-
 /*
  * Initialize hash table.
  */
@@ -76,11 +74,11 @@
 hash(const char *s)
 {
        unsigned int v;
-       const unsigned char *us;
+       const char *p;
 
        v = 0;
-       for (us = (const unsigned char *)s; *us != '\0'; us++) {
-               v = (v << 4) + *us;
+       for (p = s; *p != '\0'; p++) {
+               v = (v << 4) + (unsigned char)*p;
                v ^= v >> 28;
        }
        return v % HSHSIZ2;



Home | Main Index | Thread Index | Old Index