]> granicus.if.org Git - php/commitdiff
change range macro semantics
authorSterling Hughes <sterling@php.net>
Wed, 5 Sep 2001 20:59:24 +0000 (20:59 +0000)
committerSterling Hughes <sterling@php.net>
Wed, 5 Sep 2001 20:59:24 +0000 (20:59 +0000)
# Kinda torn between the two, thoughts?

ext/standard/rand.c

index 243376c4b7b06da5ba28aa1eecec467c40b3d556..e71692d169d05c3b8875af36a3c3ef4dbacb032a 100644 (file)
@@ -249,7 +249,7 @@ PHP_FUNCTION(mt_srand)
  * -RL
  */    
 #define RAND_RANGE(__n, __min, __max) \
-       (__min) + (int)((double)(__max) - (__min) + 1.0) * ((__n) / (PHP_RAND_MAX + 1.0))
+       (__n) = (__min) + (int)((double)(__max) - (__min) + 1.0) * ((__n) / (PHP_RAND_MAX + 1.0))
 
 /* {{{ proto int rand([int min, int max])
    Returns a random number */
@@ -267,7 +267,7 @@ PHP_FUNCTION(rand)
 
        number = php_rand();
        if (argc == 2) {
-               number = RAND_RANGE(number, Z_LVAL_PP(min), Z_LVAL_PP(max));
+               RAND_RANGE(number, Z_LVAL_PP(min), Z_LVAL_PP(max));
        }
 
        RETURN_LONG(number);
@@ -298,7 +298,7 @@ PHP_FUNCTION(mt_rand)
         */
        number = (long) (randomMT(TSRMLS_C) >> 1);
        if (argc == 2) {
-               number = RAND_RANGE(number, Z_LVAL_PP(min), Z_LVAL_PP(max));
+               RAND_RANGE(number, Z_LVAL_PP(min), Z_LVAL_PP(max));
        }
 
        RETURN_LONG(number);