(mpuz-random-puzzle): Fix potential lockup when
[bpt/emacs.git] / lisp / play / mpuz.el
index ebeeb31..5cb2ed0 100644 (file)
@@ -1,7 +1,7 @@
 ;;; mpuz.el --- multiplication puzzle for GNU Emacs
 
-;; Copyright (C) 1990, 2002, 2003, 2004, 2005,
-;;   2006 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Philippe Schnoebelen <phs@lsv.ens-cachan.fr>
 ;; Overhauled: Daniel Pfeiffer <occitan@esperanto.org>
@@ -262,8 +262,9 @@ You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]."
   (fillarray mpuz-board nil)           ; erase the board
   ;; A,B,C,D & E, are the five rows of our multiplication.
   ;; Choose random values, discarding cases with leading zeros in C or D.
-  (let* ((A (+ 112 (random 888)))
-        (min (1+ (/ 1000 A)))
+  (let* ((A (if mpuz-allow-double-multiplicator (+ 112 (random 888))
+             (+ 125 (random 875))))
+        (min (1+ (/ 999 A)))
         (B1 (+ min (random (- 10 min))))
         B2 C D E)
     (while (if (= B1 (setq B2 (+ min (random (- 10 min)))))