chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
hash/crc-mktab.c, hash/unihash-mkstatic.c: Add `const' option.
[mLib]
/
hash
/
crc-mktab.c
diff --git
a/hash/crc-mktab.c
b/hash/crc-mktab.c
index a64b43c079a4ade15ae84956ebfdd52209e37844..4453cf36d87c42468ccb0256fd9003383daac26a 100644
(file)
--- a/
hash/crc-mktab.c
+++ b/
hash/crc-mktab.c
@@
-57,6
+57,7
@@
static FILE *fp;
#define f_bogus 1u
#define f_ctab 2u
#define f_reverse 4u
#define f_bogus 1u
#define f_ctab 2u
#define f_reverse 4u
+#define f_const 8u
#define BSCOL 72
#define BSCOL 72
@@
-79,7
+80,7
@@
static void version(FILE *fp)
static void usage(FILE *fp)
{
static void usage(FILE *fp)
{
- pquis(fp, "Usage: $ [-cr] [-o FILE] [-g GUARD] [-s SYM] [-i HEADER]\n\
+ pquis(fp, "Usage: $ [-
C
cr] [-o FILE] [-g GUARD] [-s SYM] [-i HEADER]\n\
[-t TYPE] [-b BITS] [-B BITS] [-p POLY]\n");
}
[-t TYPE] [-b BITS] [-B BITS] [-p POLY]\n");
}
@@
-97,6
+98,7
@@
of options are provided:\n\
-u, --usage Show a terse usage message.\n\
\n\
-c, --c-source Emit a C source file rather than a header.\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\
-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\
@@
-143,6
+145,7
@@
int main(int argc, char *argv[])
{ "output", OPTF_ARGREQ, 0, 'o' },
{ "c-source", 0, 0, 'c' },
{ "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' },
{ "symbol", OPTF_ARGREQ, 0, 's' },
{ "type", OPTF_ARGREQ, 0, 't' },
{ "include", OPTF_ARGREQ, 0, 'i' },
@@
-155,7
+158,7
@@
int main(int argc, char *argv[])
{ 0, 0, 0, 0 }
};
{ 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:c
C
s:t:i:g: b:B:p:r", opts, 0, 0, 0);
if (i < 0)
break;
if (i < 0)
break;
@@
-176,6
+179,9
@@
int main(int argc, char *argv[])
case 'c':
flags |= f_ctab;
break;
case 'c':
flags |= f_ctab;
break;
+ case 'C':
+ flags |= f_const;
+ break;
case 's':
sym = optarg;
break;
case 's':
sym = optarg;
break;
@@
-287,7
+293,8
@@
int main(int argc, char *argv[])
if (flags & f_ctab) {
if (inc)
fprintf(fp, "#include \"%s\"\n\n", inc);
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)
} else {
int n;
if (guard)