+/* Originally this program just generated uudmap.h
+ However, when we later wanted to generate bitcount.h, it was easier to
+ refactor it and keep the same name, than either alternative - rename it,
+ or duplicate all of the Makefile logic for a second program. */
+
#include <stdio.h>
#include <stdlib.h>
/* If it turns out that we need to make this conditional on config.sh derived
/* This will ensure it is all zeros. */
static char PL_uudmap[256];
+static char PL_bitcount[256];
int main(int argc, char **argv) {
size_t i;
+ int bits;
- if (argc < 2 || argv[1][0] == '\0') {
- fprintf(stderr, "Usage: %s uudemap.h\n", argv[0]);
+ if (argc < 3 || argv[1][0] == '\0' || argv[2][0] == '\0') {
+ fprintf(stderr, "Usage: %s uudemap.h bitcount.h\n", argv[0]);
return 1;
}
output_block_to_file(argv[0], argv[1], PL_uudmap, sizeof(PL_uudmap));
+ for (bits = 1; bits < 256; bits++) {
+ if (bits & 1) PL_bitcount[bits]++;
+ if (bits & 2) PL_bitcount[bits]++;
+ if (bits & 4) PL_bitcount[bits]++;
+ if (bits & 8) PL_bitcount[bits]++;
+ if (bits & 16) PL_bitcount[bits]++;
+ if (bits & 32) PL_bitcount[bits]++;
+ if (bits & 64) PL_bitcount[bits]++;
+ if (bits & 128) PL_bitcount[bits]++;
+ }
+
+ output_block_to_file(argv[0], argv[2], PL_bitcount, sizeof(PL_bitcount));
+
return 0;
}