progs/mkphrase.[c1]: Optionally drop apostrophes.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 5 Apr 2014 09:52:07 +0000 (10:52 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 16 Jul 2014 09:13:37 +0000 (10:13 +0100)
They don't do much good, really.

progs/mkphrase.1
progs/mkphrase.c

index a40b18d..e98a178 100644 (file)
@@ -33,7 +33,7 @@
 mkphrase \- generate passphrases with guaranteed minimum entropy
 .SH SYNOPSIS
 .B mkphrase
-.RB [ \-p ]
+.RB [ \-Ap ]
 .RB [ \-b
 .IR bits ]
 .RB [ \-g
@@ -56,7 +56,9 @@ something like
 .BR /usr/share/dict/words ,
 though you can use anything you want.  Wordlist files are expected to
 contain whitespace-separated words.  Letters are smashed to lowercase;
-apostrophes are retained; other funny characters are ignored.
+apostrophes are retained (unless the
+.B \-A
+option is set); other funny characters are dropped.
 .PP
 Options provided are:
 .TP
@@ -75,6 +77,9 @@ Write a really brief usage summary for
 .B mkphrase
 to standard output and exit.
 .TP
+.BI "\-A, \-\-no-apostrophe"
+Don't treat apostrophe as a word character.
+.TP
 .BI "\-b, \-\-bits=" bits
 Set the minimum entropy for acceptable phrases.  The default is 128
 bits.  This might increase in future.
index 17fcb9c..b84d850 100644 (file)
@@ -55,7 +55,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 const char wchars[] = "abcdefghijklmnopqrstuvwxyz'";
+static const char
+  all_wchars[] = "'abcdefghijklmnopqrstuvwxyz",
+  *wchars = all_wchars;
 
 typedef struct ppgen_ops {
   const char *name;                    /* Name of the generator */
@@ -320,6 +322,7 @@ int main(int argc, char *argv[])
       { "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' },
@@ -327,7 +330,7 @@ int main(int argc, char *argv[])
       { "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 Ab:g:n:pr:", opts, 0, 0, 0);
 
     if (i < 0)
       break;
@@ -341,6 +344,9 @@ int main(int argc, char *argv[])
       case 'u':
        usage(stdout);
        exit(0);
+      case 'A':
+       wchars = all_wchars + 1;
+       break;
       case 'b': {
        char *p;
        minbits = strtoul(optarg, &p, 0);