Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make(1): print hash in debug log with fixed width



details:   https://anonhg.NetBSD.org/src/rev/5acdf26e12ad
branches:  trunk
changeset: 977523:5acdf26e12ad
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 25 19:28:44 2020 +0000

description:
make(1): print hash in debug log with fixed width

This way all the keys are nicely aligned in the debug log.

diffstat:

 usr.bin/make/hash.c |  14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diffs (50 lines):

diff -r 38a022d0ab58 -r 5acdf26e12ad usr.bin/make/hash.c
--- a/usr.bin/make/hash.c       Sun Oct 25 19:19:07 2020 +0000
+++ b/usr.bin/make/hash.c       Sun Oct 25 19:28:44 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hash.c,v 1.54 2020/10/25 19:19:07 rillig Exp $ */
+/*     $NetBSD: hash.c,v 1.55 2020/10/25 19:28:44 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -74,7 +74,7 @@
 #include "make.h"
 
 /*     "@(#)hash.c     8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: hash.c,v 1.54 2020/10/25 19:19:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.55 2020/10/25 19:28:44 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -86,7 +86,7 @@
 static unsigned int
 hash(const char *key, size_t *out_keylen)
 {
-       unsigned h = 0;
+       unsigned int h = 0;
        const char *p = key;
        while (*p != '\0')
                h = (h << 5) - h + (unsigned char)*p++;
@@ -108,7 +108,7 @@
        unsigned int chainlen = 0;
 
 #ifdef DEBUG_HASH_LOOKUP
-       DEBUG4(HASH, "%s: %p h=%x key=%s\n", __func__, t, h, key);
+       DEBUG4(HASH, "%s: %p h=%08x key=%s\n", __func__, t, h, key);
 #endif
 
        for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) {
@@ -156,11 +156,9 @@
        }
        free(t->buckets);
 
-       /*
-        * Set up the hash table to cause memory faults on any future access
-        * attempts until re-initialization.
-        */
+#ifdef CLEANUP
        t->buckets = NULL;
+#endif
 }
 
 /* Find the entry corresponding to the key, or return NULL. */



Home | Main Index | Thread Index | Old Index