helly           Fri Dec 20 11:37:45 2002 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4/ext/standard  basic_functions.c uniqid.c uniqid.h 
  Log:
  MFH
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.543.2.3 
php4/ext/standard/basic_functions.c:1.543.2.4
--- php4/ext/standard/basic_functions.c:1.543.2.3       Thu Dec 12 13:51:02 2002
+++ php4/ext/standard/basic_functions.c Fri Dec 20 11:37:44 2002
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.543.2.3 2002/12/12 18:51:02 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.543.2.4 2002/12/20 16:37:44 helly Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -523,7 +523,10 @@
        PHP_FE(getrusage,                                                              
                                                 NULL)
 #endif
 
+#ifdef HAVE_GETTIMEOFDAY
        PHP_FE(uniqid,                                                                 
                                                 NULL)
+#endif
+
        PHP_FE(quoted_printable_decode,                                                
                                 NULL)
        PHP_FE(convert_cyr_string,                                                     
                                         NULL)
        PHP_FE(get_current_user,                                                       
                                         NULL)
Index: php4/ext/standard/uniqid.c
diff -u php4/ext/standard/uniqid.c:1.31.8.1 php4/ext/standard/uniqid.c:1.31.8.2
--- php4/ext/standard/uniqid.c:1.31.8.1 Thu Dec  5 16:09:19 2002
+++ php4/ext/standard/uniqid.c  Fri Dec 20 11:37:44 2002
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: uniqid.c,v 1.31.8.1 2002/12/05 21:09:19 helly Exp $ */
+/* $Id: uniqid.c,v 1.31.8.2 2002/12/20 16:37:44 helly Exp $ */
 
 #include "php.h"
 
@@ -40,11 +40,15 @@
 
 /* {{{ proto string uniqid(string prefix [, bool more_entropy])
    Generates a unique ID */
+#ifdef HAVE_GETTIMEOFDAY
 PHP_FUNCTION(uniqid)
 {
-#ifdef HAVE_GETTIMEOFDAY
        char *prefix;
+#if defined(__CYGWIN__)
+       zend_bool more_entropy = 1;
+#else
        zend_bool more_entropy = 0;
+#endif
        char uniqid[138];
        int sec, usec, argc, prefix_len;
        struct timeval tv;
@@ -57,17 +61,21 @@
 
        /* Do some bounds checking since we are using a char array. */
        if (prefix_len > 114) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "The prefix to uniqid 
should not be more than 114 characters.");
+               php_error_docref(NULL TSRMLS_CC, E_ERROR, "The prefix to uniqid should 
+not be more than 114 characters.");
                return;
        }
 #if HAVE_USLEEP && !defined(PHP_WIN32)
        if (!more_entropy) {
+#if defined(__CYGWIN__)
+               php_error_docref(NULL TSRMLS_CC, E_ERROR, "You must use 'more entropy' 
+under CYGWIN.");
+               return;
+#endif
                usleep(1);
        }
 #endif
        gettimeofday((struct timeval *) &tv, (struct timezone *) NULL);
        sec = (int) tv.tv_sec;
-       usec = (int) (tv.tv_usec % 1000000);
+       usec = (int) (tv.tv_usec % 0x100000);
 
        /* The max value usec can have is 0xF423F, so we use only five hex
         * digits for usecs.
@@ -79,15 +87,9 @@
        }
 
        RETURN_STRING(uniqid, 1);
-#endif
 }
+#endif
 /* }}} */
-
-function_entry uniqid_functions[] = {
-       PHP_FE(uniqid, NULL)
-       {NULL, NULL, NULL}
-};
-
 
 /*
  * Local variables:
Index: php4/ext/standard/uniqid.h
diff -u php4/ext/standard/uniqid.h:1.7 php4/ext/standard/uniqid.h:1.7.8.1
--- php4/ext/standard/uniqid.h:1.7      Thu Feb 28 03:26:49 2002
+++ php4/ext/standard/uniqid.h  Fri Dec 20 11:37:44 2002
@@ -16,11 +16,13 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: uniqid.h,v 1.7 2002/02/28 08:26:49 sebastian Exp $ */
+/* $Id: uniqid.h,v 1.7.8.1 2002/12/20 16:37:44 helly Exp $ */
 
 #ifndef UNIQID_H
 #define UNIQID_H
 
+#ifdef HAVE_GETTIMEOFDAY
 PHP_FUNCTION(uniqid);
+#endif
 
 #endif /* UNIQID_H */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to