]> granicus.if.org Git - php/commitdiff
- Moved php_srand() call into php_rand().
authorfoobar <sniper@php.net>
Mon, 19 Jan 2004 03:14:58 +0000 (03:14 +0000)
committerfoobar <sniper@php.net>
Mon, 19 Jan 2004 03:14:58 +0000 (03:14 +0000)
# Makes shuffle() and str_shuffle() to be random without having to
# call srand() in scripts.
# They don't internally call php_srand() at all and it would be silly
# to start adding php_srand() calls all over the place..

ext/standard/crypt.c
ext/standard/rand.c

index 207e1d8b6073a23b7241d5d20655de46ab4d2b55..3d7ac50f4145e7a260fe6aa96198550a57512b90 100644 (file)
@@ -119,10 +119,6 @@ PHP_FUNCTION(crypt)
        char *str, *salt_in = NULL;
        int str_len, salt_in_len;
 
-       if (!BG(rand_is_seeded)) {
-               php_srand(GENERATE_SEED() TSRMLS_CC);
-       } 
-
        salt[0]=salt[PHP_MAX_SALT_LEN]='\0';
        /* This will produce suitable results if people depend on DES-encryption
           available (passing always 2-character salt). At least for glibc6.1 */
index a219926c960f80c5e263f9433160920a2567ea3b..851508c45c542defc1bdb5cf5dca00a3fb93b3ff 100644 (file)
@@ -65,6 +65,10 @@ PHPAPI long php_rand(TSRMLS_D)
 {
        long ret;
 
+       if (!BG(rand_is_seeded)) {
+               php_srand(GENERATE_SEED() TSRMLS_CC);
+       }
+
 #ifdef ZTS
        ret = php_rand_r(&BG(rand_seed));
 #else
@@ -323,10 +327,6 @@ PHP_FUNCTION(rand)
        if (argc != 0 && zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE)
                return;
 
-       if (!BG(rand_is_seeded)) {
-               php_srand(GENERATE_SEED() TSRMLS_CC);
-       }
-
        number = php_rand(TSRMLS_C);
        if (argc == 2) {
                RAND_RANGE(number, min, max, PHP_RAND_MAX);