diff options
author | Nicholas Tay <nick@windblume.net> | 2022-01-14 00:24:59 +1100 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-01-14 00:24:59 +1100 |
commit | a2f5bce2bd1e462f9cd26d3278ff7dd355bf9540 (patch) | |
tree | d0768ba278972066765addf990e1387520c92a5f /passgen.c | |
parent | a2d5d3b8101a674031745c1609da2644522249c2 (diff) | |
download | passgen-a2f5bce2bd1e462f9cd26d3278ff7dd355bf9540.tar.gz passgen-a2f5bce2bd1e462f9cd26d3278ff7dd355bf9540.tar.bz2 passgen-a2f5bce2bd1e462f9cd26d3278ff7dd355bf9540.zip |
Fix grammar caps generation on new grammars
Diffstat (limited to '')
-rw-r--r-- | passgen.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -183,12 +183,9 @@ Compile-time options (edit `config.h` to customise!):\n\ for (int i = 0; i < grammar_size; ++i) { char c = grammar[i]; - - bool caps = false; - if (c >= 'A' && c <= 'Z') { - caps = true; + bool caps = c >= 'A' && c <= 'Z'; + if (caps) c += 'a' - 'A'; - } struct grammar_class *class = NULL; for (int j = 0; j < classes_n; ++j) { @@ -204,7 +201,9 @@ Compile-time options (edit `config.h` to customise!):\n\ } do { - password[i] = class->letters[get_rng() % class->size] - (caps ? 'a' - 'A' : 0); + password[i] = class->letters[get_rng() % class->size]; + if (caps && password[i] >= 'a' && password[i] <= 'z') + password[i] -= 'a' - 'A'; } while (i != 0 && password[i] == password[i - 1]); } |