#define f_bogus 1u
#define f_ctab 2u
#define f_reverse 4u
+#define f_const 8u
#define BSCOL 72
static void usage(FILE *fp)
{
- pquis(fp, "Usage: $ [-cr] [-o FILE] [-g GUARD] [-s SYM] [-i HEADER]\n\
+ pquis(fp, "Usage: $ [-Ccr] [-o FILE] [-g GUARD] [-s SYM] [-i HEADER]\n\
[-t TYPE] [-b BITS] [-B BITS] [-p POLY]\n");
}
-u, --usage Show a terse usage message.\n\
\n\
-c, --c-source Emit a C source file rather than a header.\n\
+-C, --const Declare table to be `const' (only useful with `-c').\n\
-b, --bits=BITS Emit a table for a BITS bits-wide CRC.\n\
-B, --bit-chunk=BITS Emit a table to process BITS bits at a time.\n\
-p, --polynomial=POLY Use the POLY as the dividing polynomial.\n\
if (!(flags & f_reverse))
return (x);
xm = 1;
- ym = 1 << (b - 1);
+ ym = 1u << (b - 1);
for (i = 0; i < b; i++) {
if (x & xm)
y |= ym;
{ "output", OPTF_ARGREQ, 0, 'o' },
{ "c-source", 0, 0, 'c' },
+ { "const", 0, 0, 'C' },
{ "symbol", OPTF_ARGREQ, 0, 's' },
{ "type", OPTF_ARGREQ, 0, 't' },
{ "include", OPTF_ARGREQ, 0, 'i' },
{ 0, 0, 0, 0 }
};
- int i = mdwopt(argc, argv, "hvu o:cs:t:i:g: b:B:p:r", opts, 0, 0, 0);
+ int i = mdwopt(argc, argv, "hvu o:cCs:t:i:g: b:B:p:r", opts, 0, 0, 0);
if (i < 0)
break;
case 'c':
flags |= f_ctab;
break;
+ case 'C':
+ flags |= f_const;
+ break;
case 's':
sym = optarg;
break;
if (flags & f_ctab) {
if (inc)
fprintf(fp, "#include \"%s\"\n\n", inc);
- fprintf(fp, "%s %s[] = {\n", type, sym);
+ fprintf(fp, "%s%s %s[] = {\n",
+ (flags&f_const) ? "const " : "", type, sym);
} else {
int n;
if (guard)