aboutsummaryrefslogtreecommitdiff
path: root/pw_rand.c
diff options
context:
space:
mode:
authorPhilipp Klaus <philipp.klaus@gmail.com>2011-06-21 17:12:22 +0200
committerPhilipp Klaus <philipp.klaus@gmail.com>2011-06-21 17:12:22 +0200
commit83963510edc09860c8e1b765e4e3c9254507ecde (patch)
treeedfc92c14a34371680c19606f254cfa7e38d1de2 /pw_rand.c
parentf6085cae15588228695eba6f7e0c2a490641bff9 (diff)
downloadpwgen-83963510edc09860c8e1b765e4e3c9254507ecde.zip
automatic commit for pwgen-2.06
Diffstat (limited to 'pw_rand.c')
-rw-r--r--pw_rand.c15
1 files changed, 8 insertions, 7 deletions
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))