Module Name: src Committed By: rillig Date: Sat Aug 28 21:52:15 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: lex.c src/usr.bin/xlint/lint2: hash.c Log Message: lint: clean up hash functions No functional change. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xlint/lint2/hash.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.77 src/usr.bin/xlint/lint1/lex.c:1.78 --- src/usr.bin/xlint/lint1/lex.c:1.77 Sat Aug 28 21:14:32 2021 +++ src/usr.bin/xlint/lint1/lex.c Sat Aug 28 21:52:14 2021 @@ -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 @@ static unsigned int 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; Index: src/usr.bin/xlint/lint2/hash.c diff -u src/usr.bin/xlint/lint2/hash.c:1.21 src/usr.bin/xlint/lint2/hash.c:1.22 --- src/usr.bin/xlint/lint2/hash.c:1.21 Sat Aug 28 19:27:44 2021 +++ src/usr.bin/xlint/lint2/hash.c Sat Aug 28 21:52:14 2021 @@ -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 @@ __RCSID("$NetBSD: hash.c,v 1.21 2021/08/ /* pointer to hash table, initialized in inithash() */ static hte_t **htab; -static unsigned int hash(const char *); - /* * Initialize hash table. */ @@ -76,11 +74,11 @@ static unsigned int 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;