From: Willy Tarreau Date: Mon, 23 Nov 2026 14:42:14 +0000 (+0100) Subject: DEV: phash: improve the output to permit an easier copy-paste X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/%7B@url%7D?a=commitdiff_plain;h=ee4e526789c9a4d3f066f18cfeb8b11ee0f38461;p=haproxy.git DEV: phash: improve the output to permit an easier copy-paste The output had to be recopied manually. Let's print it as an array like it is in the code so that it's now possible to simply copy-paste it there and avoid mistakes. --- diff --git a/dev/phash/phash.c b/dev/phash/phash.c index 1d6765273..06f2989e5 100644 --- a/dev/phash/phash.c +++ b/dev/phash/phash.c @@ -110,4 +110,19 @@ int main(int argc, char **argv) mul = bmul; xor = bxor; for (i = 0; i < CODES && codes[i] >= 0; i++) printf("hash(%4u) = %2u // [%2u] = %4u\n", codes[i], hash(codes[i]), hash(codes[i]), codes[i]); + + printf("// table:\n\t"); + for (h = 0; h < CODES; h++) { + for (i = 0; i < CODES && codes[i] >= 0; i++) { + if (hash(codes[i]) == h) { + printf("HTTP_ERR_%03u, ", codes[i]); + break; + } + } + if (codes[i] < 0) // nothing here + printf("HTTP_ERR_500, ", h); + if ((h & 3) == 3) + printf("\n\t"); + } + putchar('\n'); }