From ff6eb7fc9763ef77df2336250d49c78780ab4676 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Thu, 26 Jan 2006 13:04:26 +0100 Subject: [PATCH] Fix stupid bug in gen-character --- src/random.lisp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/random.lisp b/src/random.lisp index d9c4d2b..a1f16bb 100644 --- a/src/random.lisp +++ b/src/random.lisp @@ -151,12 +151,16 @@ CODE must be a generator of random integers. ALPHANUMERICP, if non-NIL, limits the returned chars to those which pass alphanumericp." (lambda () - (if alphanumericp - (code-char (funcall code)) + (if alphanumericp (loop + for count upfrom 0 for char = (code-char (funcall code)) until (alphanumericp char) - finally (return char))))) + when (= 1000 count) + do (error "After 1000 iterations ~S has still not generated an alphanumeric character :(." + code) + finally (return char)) + (code-char (funcall code))))) (defun gen-string (&key (length (gen-integer :min 0 :max 80)) (elements (gen-character)) -- 1.7.10.4