~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
progs/mkphrase.c: Fix trailing spaces in usage message.
[catacomb]
/
progs
/
mkphrase.c
diff --git
a/progs/mkphrase.c
b/progs/mkphrase.c
index
17fcb9c
..
1b36cb2
100644
(file)
--- a/
progs/mkphrase.c
+++ b/
progs/mkphrase.c
@@
-40,6
+40,7
@@
#include <mLib/bits.h>
#include <mLib/darray.h>
#include <mLib/dstr.h>
#include <mLib/bits.h>
#include <mLib/darray.h>
#include <mLib/dstr.h>
+#include <mLib/macros.h>
#include <mLib/mdwopt.h>
#include <mLib/quis.h>
#include <mLib/report.h>
#include <mLib/mdwopt.h>
#include <mLib/quis.h>
#include <mLib/report.h>
@@
-55,7
+56,9
@@
static unsigned min = 0, max = 256; /* Word length bounds */
static unsigned minbits = 128, maxbits = UINT_MAX; /* Acceptable entropy */
static unsigned count = 1; /* How many passphrases to make */
static unsigned minbits = 128, maxbits = UINT_MAX; /* Acceptable entropy */
static unsigned count = 1; /* How many passphrases to make */
-static const char wchars[] = "abcdefghijklmnopqrstuvwxyz'";
+static const char
+ all_wchars[] = "'abcdefghijklmnopqrstuvwxyz",
+ *wchars = all_wchars;
typedef struct ppgen_ops {
const char *name; /* Name of the generator */
typedef struct ppgen_ops {
const char *name; /* Name of the generator */
@@
-97,7
+100,7
@@
static void wordlist_scan(FILE *fp, void *p)
for (;;) {
int ch = getc(fp);
for (;;) {
int ch = getc(fp);
- if (ch == EOF ||
isspace
(ch)) {
+ if (ch == EOF ||
ISSPACE
(ch)) {
DPUTZ(&d);
if (f && d.len >= min && d.len <= max)
sym_find(&w->tab, d.buf, d.len + 1, sizeof(sym_base), 0);
DPUTZ(&d);
if (f && d.len >= min && d.len <= max)
sym_find(&w->tab, d.buf, d.len + 1, sizeof(sym_base), 0);
@@
-107,7
+110,7
@@
static void wordlist_scan(FILE *fp, void *p)
break;
continue;
}
break;
continue;
}
- ch =
tolower
(ch);
+ ch =
TOLOWER
(ch);
if (strchr(wchars, ch)) {
DPUTC(&d, ch);
f = 1;
if (strchr(wchars, ch)) {
DPUTC(&d, ch);
f = 1;
@@
-202,7
+205,7
@@
static void markov_scan(FILE *fp, void *p)
const char *q;
node *n = &(*model)[i][j][k];
const char *q;
node *n = &(*model)[i][j][k];
- if (ch == EOF ||
isspace
(ch)) {
+ if (ch == EOF ||
ISSPACE
(ch)) {
if (l != C_END) {
l = C_END;
n->count++;
if (l != C_END) {
l = C_END;
n->count++;
@@
-214,7
+217,7
@@
static void markov_scan(FILE *fp, void *p)
continue;
}
continue;
}
- if ((q = strchr(wchars,
tolower
(ch))) == 0)
+ if ((q = strchr(wchars,
TOLOWER
(ch))) == 0)
continue;
l = q - wchars;
n->count++;
continue;
l = q - wchars;
n->count++;
@@
-273,7
+276,7
@@
static void usage(FILE *fp)
{
pquis(fp, "\
Usage: $ [-p] [-b MIN[-MAX]] [-g GEN] [-n COUNT]\n\
{
pquis(fp, "\
Usage: $ [-p] [-b MIN[-MAX]] [-g GEN] [-n COUNT]\n\
-\t[-r [MIN-]MAX] WORDLIST...\n
\
+\t[-r [MIN-]MAX] WORDLIST...\n\
");
}
");
}
@@
-320,6
+323,7
@@
int main(int argc, char *argv[])
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'v' },
{ "usage", 0, 0, 'u' },
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'v' },
{ "usage", 0, 0, 'u' },
+ { "no-apostrophe", 0, 0, 'A' },
{ "bits", OPTF_ARGREQ, 0, 'b' },
{ "generator", OPTF_ARGREQ, 0, 'g' },
{ "count", OPTF_ARGREQ, 0, 'n' },
{ "bits", OPTF_ARGREQ, 0, 'b' },
{ "generator", OPTF_ARGREQ, 0, 'g' },
{ "count", OPTF_ARGREQ, 0, 'n' },
@@
-327,7
+331,7
@@
int main(int argc, char *argv[])
{ "range", OPTF_ARGREQ, 0, 'r' },
{ 0, 0, 0, 0 }
};
{ "range", OPTF_ARGREQ, 0, 'r' },
{ 0, 0, 0, 0 }
};
- int i = mdwopt(argc, argv, "hvu b:g:n:pr:", opts, 0, 0, 0);
+ int i = mdwopt(argc, argv, "hvu
A
b:g:n:pr:", opts, 0, 0, 0);
if (i < 0)
break;
if (i < 0)
break;
@@
-341,6
+345,9
@@
int main(int argc, char *argv[])
case 'u':
usage(stdout);
exit(0);
case 'u':
usage(stdout);
exit(0);
+ case 'A':
+ wchars = all_wchars + 1;
+ break;
case 'b': {
char *p;
minbits = strtoul(optarg, &p, 0);
case 'b': {
char *p;
minbits = strtoul(optarg, &p, 0);
@@
-356,7
+363,7
@@
int main(int argc, char *argv[])
size_t n = strlen(optarg);
ops = 0;
for (p = ppgentab; *p; p++) {
size_t n = strlen(optarg);
ops = 0;
for (p = ppgentab; *p; p++) {
- if (
strncmp(optarg, (*p)->name, n) == 0
) {
+ if (
STRNCMP(optarg, ==, (*p)->name, n)
) {
if (!(*p)->name[n]) {
ops = *p;
break;
if (!(*p)->name[n]) {
ops = *p;
break;
@@
-408,7
+415,7
@@
int main(int argc, char *argv[])
ctx = ops->init();
while (*argv) {
ctx = ops->init();
while (*argv) {
- if (
strcmp(*argv, "-") == 0
)
+ if (
STRCMP(*argv, ==, "-")
)
ops->scan(stdin, ctx);
else {
FILE *fp = fopen(*argv, "r");
ops->scan(stdin, ctx);
else {
FILE *fp = fopen(*argv, "r");