From 13d62fadec8d910536ca6117011213f71fe76bea Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Thu, 6 Nov 2008 11:20:05 +0000 Subject: [PATCH] * fns.c (Frandom): Rename arg N to LIMIT to match the docs; doc fix. --- src/ChangeLog | 4 ++++ src/fns.c | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 2d94ce8a9af..5b8003fe779 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2008-11-06 Juanma Barranquero + + * fns.c (Frandom): Rename arg N to LIMIT to match the docs; doc fix. + 2008-11-06 Glenn Morris * xterm.c (handle_one_xevent): Don't let popup menus cause diff --git a/src/fns.c b/src/fns.c index bf7b715223e..c4f4ab5fc76 100644 --- a/src/fns.c +++ b/src/fns.c @@ -95,18 +95,19 @@ DEFUN ("random", Frandom, Srandom, 0, 1, 0, doc: /* Return a pseudo-random number. All integers representable in Lisp are equally likely. On most systems, this is 29 bits' worth. -With positive integer argument N, return random number in interval [0,N). -With argument t, set the random number seed from the current time and pid. */) - (n) - Lisp_Object n; +With positive integer LIMIT, return random number in interval [0,LIMIT). +With argument t, set the random number seed from the current time and pid. +Other values of LIMIT are ignored. */) + (limit) + Lisp_Object limit; { EMACS_INT val; Lisp_Object lispy_val; unsigned long denominator; - if (EQ (n, Qt)) + if (EQ (limit, Qt)) seed_random (getpid () + time (NULL)); - if (NATNUMP (n) && XFASTINT (n) != 0) + if (NATNUMP (limit) && XFASTINT (limit) != 0) { /* Try to take our random number from the higher bits of VAL, not the lower, since (says Gentzel) the low bits of `random' @@ -115,10 +116,10 @@ With argument t, set the random number seed from the current time and pid. */) it's possible to get a quotient larger than n; discarding these values eliminates the bias that would otherwise appear when using a large n. */ - denominator = ((unsigned long)1 << VALBITS) / XFASTINT (n); + denominator = ((unsigned long)1 << VALBITS) / XFASTINT (limit); do val = get_random () / denominator; - while (val >= XFASTINT (n)); + while (val >= XFASTINT (limit)); } else val = get_random (); -- 2.39.2