From 83963510edc09860c8e1b765e4e3c9254507ecde Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Tue, 21 Jun 2011 17:12:22 +0200 Subject: automatic commit for pwgen-2.06 --- pw_rand.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'pw_rand.c') diff --git a/pw_rand.c b/pw_rand.c index 127687d..240f173 100644 --- a/pw_rand.c +++ b/pw_rand.c @@ -18,6 +18,7 @@ const char *pw_uppers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const char *pw_lowers = "abcdefghijklmnopqrstuvwxyz"; const char *pw_symbols = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; const char *pw_ambiguous = "B8G6I1l0OQDS5Z2"; +const char *pw_vowels = "01aeiouyAEIOUY"; void pw_rand(char *buf, int size, int pw_flags) { @@ -57,14 +58,14 @@ void pw_rand(char *buf, int size, int pw_flags) try_again: len = strlen(chars); feature_flags = pw_flags; - for (i = 0; i < size; i++) { + i = 0; + while (i < size) { ch = chars[pw_number(len)]; - if (pw_flags & PW_AMBIGUOUS) { - if (strchr(pw_ambiguous,ch)) { - continue; - } - } - buf[i] = ch; + if ((pw_flags & PW_AMBIGUOUS) && strchr(pw_ambiguous,ch)) + continue; + if ((pw_flags & PW_NO_VOWELS) && strchr(pw_vowels, ch)) + continue; + buf[i++] = ch; if (strchr(pw_digits, ch)) feature_flags &= ~PW_DIGITS; if (strchr(pw_uppers, ch)) -- cgit v1.2.3