From: Sterling Hughes Date: Sun, 16 Sep 2001 03:50:04 +0000 (+0000) Subject: for the daft folks that think 0 is a good seed. X-Git-Tag: PRE_SUBST_Z_MACROS~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47f3851a0068f5f66d836079aaa71e28df2cf426;p=php for the daft folks that think 0 is a good seed. --- diff --git a/ext/standard/rand.c b/ext/standard/rand.c index 8cde64300b..50f09e2e4c 100644 --- a/ext/standard/rand.c +++ b/ext/standard/rand.c @@ -198,12 +198,12 @@ PHPAPI php_uint32 php_mt_rand(TSRMLS_D) Seeds random number generator */ PHP_FUNCTION(srand) { - long seed = 0; + long seed; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &seed) == FAILURE) return; - if (!seed) + if (ZEND_NUM_ARGS() == 0) seed = GENERATE_SEED(); php_srand(seed); @@ -214,12 +214,12 @@ PHP_FUNCTION(srand) Seeds Mersenne Twister random number generator */ PHP_FUNCTION(mt_srand) { - long seed = 0; + long seed; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &seed) == FAILURE) return; - if (!seed) + if (ZEND_NUM_ARGS() == 0) seed = GENERATE_SEED(); php_mt_srand(seed TSRMLS_CC);