From 92c494cebdce7068e6c9c0fe4363467719c8ed67 Mon Sep 17 00:00:00 2001 From: mdw Date: Wed, 29 Sep 2004 00:50:32 +0000 Subject: [PATCH] Fix branch names for Subversion. Add --encoding option to hashsum's help output, and suppress comments for the just-hash-stdin output, to make parsing easier. --- BRANCHES | 6 +++--- hashsum.c | 32 ++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/BRANCHES b/BRANCHES index 5310815..1cd9f21 100644 --- a/BRANCHES +++ b/BRANCHES @@ -1,8 +1,8 @@ General conventions: For a branch FOO, we have: - FOO-root point at which FOO leaves trunk or parent branch - FOO-merge-N Nth branch merge point + FOO:root point at which FOO leaves trunk or parent branch + FOO:merge-N Nth branch merge point `ec' -- elliptic curve work - ec-merge-1 Closed. + ec:merge-1 Closed. diff --git a/hashsum.c b/hashsum.c index dbb6662..492eb9b 100644 --- a/hashsum.c +++ b/hashsum.c @@ -619,6 +619,7 @@ Generates or checks message digests on files. Options available:\n\ -u, --usage Display a terse usage message.\n\ \n\ -a, --algorithm=ALG Use the message digest algorithm ALG.\n\ +-E, --encoding=ENC Represent hashes using encoding ENC.\n\ \n\ -f, --files Read a list of file names from standard input.\n\ -0, --null File names are null terminated, not plain text.\n\ @@ -628,7 +629,7 @@ Generates or checks message digests on files. Options available:\n\ -b, --binary When reading files, treat them as binary.\n\ -v, --verbose Be verbose when checking digests.\n\ \n\ -For a list of supported message digest algorithms, type `$ --list'.\n\ +For a list of hashing algorithms and encodings, type `$ --list'.\n\ "); if (gch) fprintf(fp, "The default message digest algorithm is %s.\n", gch->name); @@ -705,12 +706,18 @@ int main(int argc, char *argv[]) break; case 'l': { unsigned j; + printf("Algorithms: "); for (j = 0; ghashtab[j]; j++) { - if (j) - fputc(' ', stdout); + if (j) fputc(' ', stdout); printf("%s", ghashtab[j]->name); } fputc('\n', stdout); + printf("Encodings: "); + for (j = 0; enctab[j].name; j++) { + if (j) fputc(' ', stdout); + printf("%s", enctab[j].name); + } + fputc('\n', stdout); exit(0); } break; case 'E': @@ -751,22 +758,23 @@ int main(int argc, char *argv[]) /* --- Generate output --- */ - if (!(f & f_check)) { - if (f & f_oddhash) printf("#hash %s\n", gch->name); - if (f & f_oddenc) printf("#encoding %s\n", e->name); - if (f & f_escape) fputs("#escape\n", stdout); - } - - if (argc) { + if (!argc) + rc = hashsum(0, f, gch, e); + else { int i; int rrc; + rc = 0; + if (!(f & f_check)) { + if (f & f_oddhash) printf("#hash %s\n", gch->name); + if (f & f_oddenc) printf("#encoding %s\n", e->name); + if (f & f_escape) fputs("#escape\n", stdout); + } for (i = 0; i < argc; i++) { if ((rrc = hashsum(argv[i], f, gch, e)) != 0) rc = rrc; } - } else - rc = hashsum(0, f, gch, e); + } return (rc); } -- 2.11.0