]> git.kaiwu.me - haproxy.git/commitdiff
DEV: phash: improve the output to permit an easier copy-paste
authorWilly Tarreau <w@1wt.eu>
Mon, 23 Nov 2026 14:42:14 +0000 (15:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 23 Nov 2026 22:24:23 +0000 (23:24 +0100)
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.

dev/phash/phash.c

index 1d6765273a4c9338609b61fd27fa655ec8b7c2c8..06f2989e5c50552495639a4e98beeae1e5927bd2 100644 (file)
@@ -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');
 }