[PHP-CVS] cvs: php-src /tests/classes iterators_006.phpt
helly Tue Nov 18 02:33:31 2003 EDT
Added files:
/php-src/tests/classes iterators_006.phpt
Log:
Add new iterator test inspired by bug #26527
Index: php-src/tests/classes/iterators_006.phpt
+++ php-src/tests/classes/iterators_006.phpt
--TEST--
ZE2 iterators and array wrapping
--SKIPIF--
--FILE--
array = array('foo', 'bar', 'baz');
}
function rewind() {
reset($this->array);
$this->next();
}
function hasMore() {
return $this->key !== NULL;
}
function key() {
return $this->key;
}
function current() {
return $this->current;
}
function next() {
list($this->key, $this->current) = each($this->array);
// list($key, $current) = each($this->array);
// $this->key = $key;
// $this->current = $current;
}
}
class a implements IteratorAggregate {
public function getIterator() {
return new ai();
}
}
$array = new a();
foreach ($array as $property => $value) {
print "$property: $value\n";
}
#$array = $array->getIterator();
#$array->rewind();
#$array->hasMore();
#var_dump($array->key());
#var_dump($array->current());
echo "===2nd===\n";
$array = new ai();
foreach ($array as $property => $value) {
print "$property: $value\n";
}
echo "===3rd===\n";
foreach ($array as $property => $value) {
print "$property: $value\n";
}
?>
===DONE===
--EXPECT--
0: foo
1: bar
2: baz
===2nd===
0: foo
1: bar
2: baz
===3rd===
0: foo
1: bar
2: baz
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /win32 install.txt
thetaphiTue Nov 18 04:04:32 2003 EDT Modified files: /php-src/win32 install.txt Log: change names to to php5_xxx in NSAPI Index: php-src/win32/install.txt diff -u php-src/win32/install.txt:1.26 php-src/win32/install.txt:1.27 --- php-src/win32/install.txt:1.26 Mon Nov 17 19:06:37 2003 +++ php-src/win32/install.txt Tue Nov 18 04:04:31 2003 @@ -578,8 +578,8 @@ for iPlanet/SunONE Web Server 6.0 and above however at the end of the \https-servername\config\magnus.conf file: - Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c:/path/to/PHP4/php4nsapi.dll" - Init fn=php4_init errorString="Failed to initialize PHP!" [php_ini="c:/path/to/php.ini"] + Init fn="load-modules" funcs="php5_init,php5_execute,php5_auth_trans" shlib="c:/path/to/PHP/php5nsapi.dll" + Init fn=php5_init errorString="Failed to initialize PHP!" [php_ini="c:/path/to/php.ini"] In obj.conf (for virtual server classes [SunONE 6.0+] in their vserver.obj.conf): @@ -594,7 +594,7 @@ # For boolean ini-keys please use 0/1 as value, NOT "On","Off",... (this will not work # correctly), e.g. zlib.output_compression=1 instead of zlib.output_compression="On" - Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value ...] + Service fn="php5_execute" type="magnus-internal/x-httpd-php" [inikey=value ...] . . . @@ -605,7 +605,7 @@ ObjectType fn="force-type" type="magnus-internal/x-httpd-php" - Service fn="php4_execute" [inikey=value ...] + Service fn="php5_execute" [inikey=value ...] After that you can configure a directory in the Administration server and assign it -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gmp gmp.c
sniper Tue Nov 18 05:28:14 2003 EDT
Modified files:
/php-src/ext/gmpgmp.c
Log:
- Fix the parameter setting. (this function has 1 optional parameter)
Index: php-src/ext/gmp/gmp.c
diff -u php-src/ext/gmp/gmp.c:1.36 php-src/ext/gmp/gmp.c:1.37
--- php-src/ext/gmp/gmp.c:1.36 Mon Oct 13 07:46:36 2003
+++ php-src/ext/gmp/gmp.c Tue Nov 18 05:28:13 2003
@@ -1032,15 +1032,13 @@
argc = ZEND_NUM_ARGS();
- if (argc < 0 || argc > 1 || zend_get_parameters_ex(1, &limiter_arg) ==
FAILURE){
- WRONG_PARAM_COUNT;
- }
-
- if(argc) {
+ if (argc == 0) {
+ limiter = 20;
+ } else if (argc == 1 && zend_get_parameters_ex(1, &limiter_arg) == SUCCESS) {
convert_to_long_ex(limiter_arg);
limiter = Z_LVAL_PP(limiter_arg);
} else {
- limiter = 20;
+ WRONG_PARAM_COUNT;
}
INIT_GMP_NUM(gmpnum_result);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/gmp gmp.c
sniper Tue Nov 18 05:28:35 2003 EDT
Modified files: (Branch: PHP_4_3)
/php-src/ext/gmpgmp.c
Log:
MFH: fixed parameters for gmp_random()
Index: php-src/ext/gmp/gmp.c
diff -u php-src/ext/gmp/gmp.c:1.29.4.3 php-src/ext/gmp/gmp.c:1.29.4.4
--- php-src/ext/gmp/gmp.c:1.29.4.3 Mon Oct 13 07:47:05 2003
+++ php-src/ext/gmp/gmp.c Tue Nov 18 05:28:34 2003
@@ -1031,15 +1031,13 @@
argc = ZEND_NUM_ARGS();
- if (argc < 0 || argc > 1 || zend_get_parameters_ex(1, &limiter_arg) ==
FAILURE){
- WRONG_PARAM_COUNT;
- }
-
- if(argc) {
+ if (argc == 0) {
+ limiter = 20;
+ } else if (argc == 1 && zend_get_parameters_ex(1, &limiter_arg) == SUCCESS) {
convert_to_long_ex(limiter_arg);
limiter = Z_LVAL_PP(limiter_arg);
} else {
- limiter = 20;
+ WRONG_PARAM_COUNT;
}
INIT_GMP_NUM(gmpnum_result);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard parsedate.y
MFH ? On November 18, 2003 01:46 am, Hartmut Holzgraefe wrote: > hholzgra Tue Nov 18 01:46:07 2003 EDT > > Modified files: > /php-src/ext/standard parsedate.y > Log: > the military time zone offsets where pointing in the wrong direction -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard parsedate.y
Ilia Alshanetsky wrote: MFH ? On November 18, 2003 01:46 am, Hartmut Holzgraefe wrote: hholzgra Tue Nov 18 01:46:07 2003 EDT Modified files: /php-src/ext/standardparsedate.y Log: the military time zone offsets where pointing in the wrong direction yeah, later ... after my talk ;) ... and after adding regression test cases ... -- Hartmut Holzgraefe <[EMAIL PROTECTED]> -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: spl / spl_directory.c spl_functions.h spl_iterators.c
helly Tue Nov 18 17:14:20 2003 EDT
Modified files:
/splspl_directory.c spl_functions.h spl_iterators.c
Log:
- Rename DirectoryTreeIterator to RecursiveDirectoryiterator (what it
effectively is).
- Add DirectoryIterator::__toString ->getFilename
- Add RecursiveDirecetoryIterator::__toString ->getPathname
- Add RecursiveIteratorIterator::getSubIterator.
Index: spl/spl_directory.c
diff -u spl/spl_directory.c:1.12 spl/spl_directory.c:1.13
--- spl/spl_directory.c:1.12Sun Nov 9 18:00:50 2003
+++ spl/spl_directory.c Tue Nov 18 17:14:19 2003
@@ -16,7 +16,7 @@
+--+
*/
-/* $Id: spl_directory.c,v 1.12 2003/11/09 23:00:50 helly Exp $ */
+/* $Id: spl_directory.c,v 1.13 2003/11/18 22:14:19 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -53,11 +53,12 @@
SPL_METHOD(DirectoryIterator, isDot);
SPL_METHOD(DirectoryIterator, isDir);
-SPL_METHOD(DirectoryTreeIterator, rewind);
-SPL_METHOD(DirectoryTreeIterator, next);
-SPL_METHOD(DirectoryTreeIterator, key);
-SPL_METHOD(DirectoryTreeIterator, hasChildren);
-SPL_METHOD(DirectoryTreeIterator, getChildren);
+SPL_METHOD(RecursiveDirectoryIterator, rewind);
+SPL_METHOD(RecursiveDirectoryIterator, next);
+SPL_METHOD(RecursiveDirectoryIterator, key);
+SPL_METHOD(RecursiveDirectoryIterator, hasChildren);
+SPL_METHOD(RecursiveDirectoryIterator, getChildren);
+SPL_METHOD(RecursiveDirectoryIterator, __toString);
/* declare method parameters */
@@ -82,15 +83,17 @@
SPL_ME(DirectoryIterator, getPathname, NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryIterator, isDot, NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryIterator, isDir, NULL, ZEND_ACC_PUBLIC)
+ SPL_MA(DirectoryIterator, __toString, DirectoryIterator, getFilename, NULL,
ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
static zend_function_entry spl_ce_dir_tree_class_functions[] = {
- SPL_ME(DirectoryTreeIterator, rewind,NULL, ZEND_ACC_PUBLIC)
- SPL_ME(DirectoryTreeIterator, next, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(DirectoryTreeIterator, key, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(DirectoryTreeIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(DirectoryTreeIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveDirectoryIterator, rewind,NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveDirectoryIterator, next, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveDirectoryIterator, key, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveDirectoryIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveDirectoryIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
+ SPL_MA(RecursiveDirectoryIterator, __toString, DirectoryIterator, getPathname,
NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
@@ -101,7 +104,7 @@
/* decalre the class entry */
zend_class_entry *spl_ce_DirectoryIterator;
-zend_class_entry *spl_ce_DirectoryTreeIterator;
+zend_class_entry *spl_ce_RecursiveDirectoryIterator;
/* the overloaded class structure */
@@ -358,15 +361,19 @@
zval *object = getThis();
spl_ce_dir_object *intern =
(spl_ce_dir_object*)zend_object_store_get_object(object TSRMLS_CC);
- char *filename;
- int filename_len = spprintf(&filename, 0, "%s/%s", intern->path,
intern->entry.d_name);
- RETURN_STRINGL(filename, filename_len, 0);
+ if (intern->entry.d_name[0]) {
+ char *filename;
+ int filename_len = spprintf(&filename, 0, "%s/%s", intern->path,
intern->entry.d_name);
+ RETURN_STRINGL(filename, filename_len, 0);
+ } else {
+ RETURN_BOOL(0);
+ }
}
/* }}} */
-/* {{{ proto string DirectoryTreeIterator::key()
+/* {{{ proto string RecursiveDirectoryIterator::key()
Return path and filename of current dir entry */
-SPL_METHOD(DirectoryTreeIterator, key)
+SPL_METHOD(RecursiveDirectoryIterator, key)
{
zval *object = getThis();
spl_ce_dir_object *intern =
(spl_ce_dir_object*)zend_object_store_get_object(object TSRMLS_CC);
@@ -404,9 +411,9 @@
}
/* }}} */
-/* {{{ proto void DirectoryTreeIterator::rewind()
+/* {{{ proto void RecursiveDirectoryIterator::rewind()
Rewind dir back to the start */
-SPL_METHOD(DirectoryTreeIterator, rewind)
+SPL_METHOD(RecursiveDirectoryIterator, rewind)
{
zval *object = getThis();
spl_ce_dir_object *intern =
(spl_ce_dir_object*)zend_object_store_get_object(object TSRMLS_CC);
@@ -423,9 +430,9 @@
}
/* }}} */
-/* {{{ proto void DirectoryTreeIterator::next()
+/* {{{ proto void RecursiveDirectoryIterator::next()
Move to next entry */
-SPL_METHOD(DirectoryTreeIterator, next)
+SPL_METHOD(RecursiveDirectoryIterator, next)
{
zval *object = getThis();
spl_ce_dir_object *intern =
(spl_ce_dir_object*)zend_object_store_get_object(object TSRMLS_CC);
@@
[PHP-CVS] cvs: spl /examples cachingiterator.inc cachingrecursiveiterator.inc directorytree.php directorytreeiterator.inc limititerator.inc recursiveiterator.inc searchiterator.inc
helly Tue Nov 18 17:18:39 2003 EDT
Added files:
/spl/examples cachingiterator.inc cachingrecursiveiterator.inc
directorytreeiterator.inc recursiveiterator.inc
Modified files:
/spl/examples directorytree.php limititerator.inc
searchiterator.inc
Log:
update directory examples
Index: spl/examples/directorytree.php
diff -u spl/examples/directorytree.php:1.2 spl/examples/directorytree.php:1.3
--- spl/examples/directorytree.php:1.2 Sun Nov 16 19:56:15 2003
+++ spl/examples/directorytree.php Tue Nov 18 17:18:38 2003
@@ -11,8 +11,8 @@
$length = $argc > 3 ? $argv[3] : NULL;
-foreach(new RecursiveIteratorIterator(new DirectoryTreeIterator($argv[1])) as
$pathname => $file) {
- echo "$pathname\n";
+foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as
$pathname => $file) {
+ echo "$file\n";
}
?>
\ No newline at end of file
Index: spl/examples/limititerator.inc
diff -u spl/examples/limititerator.inc:1.2 spl/examples/limititerator.inc:1.3
--- spl/examples/limititerator.inc:1.2 Tue Nov 11 13:31:50 2003
+++ spl/examples/limititerator.inc Tue Nov 18 17:18:38 2003
@@ -21,7 +21,7 @@
{
$this->it->rewind();
$this->index = 0;
- if (is_a($this->it, 'SeekableIterator')) {
+ if ($this->it instanceof SeekableIterator) {
$this->index = $this->it->seek($this->offset);
} else {
while($this->index < $this->offset && $this->it->hasMore()) {
Index: spl/examples/searchiterator.inc
diff -u spl/examples/searchiterator.inc:1.1 spl/examples/searchiterator.inc:1.2
--- spl/examples/searchiterator.inc:1.1 Sun Nov 9 09:05:36 2003
+++ spl/examples/searchiterator.inc Tue Nov 18 17:18:38 2003
@@ -4,6 +4,11 @@
{
private $done = false;
+ function rewind() {
+ parent::rewind();
+ $this->done = false;
+ }
+
function hasMore() {
return !$this->done && parent::hasMore();
}
Index: spl/examples/cachingiterator.inc
+++ spl/examples/cachingiterator.inc
it = $it;
}
function rewind() {
$this->it->rewind();
$this->next();
}
function next() {
if ($this->more = $this->it->hasMore()) {
$this->current = $this->it->current();
$this->key = $this->it->key();
$this->strvalue = (string)$this->current;
} else {
$this->current = NULL;
$this->key = NULL;
$this->strvalue = '';
}
$this->it->next();
}
function hasMore() {
return $this->more;
}
function hasNext() {
return $this->it->hasMore();
}
function current() {
return $this->current;
}
function key() {
return $this->key;
}
function __call($func, $params) {
return call_user_func_array(array($this->it, $func), $params);
}
function __toString() {
return $this->strvalue;
}
}
?>
Index: spl/examples/cachingrecursiveiterator.inc
+++ spl/examples/cachingrecursiveiterator.inc
hasChildren = $this->it->hasChildren()) {
$this->getChildren = new
CachingRecursiveIterator($this->it->getChildren());
} else {
$this->getChildren = NULL;
}
parent::next();
}
function hasChildren() {
return $this->hasChildren;
}
function getChildren() {
return $this->getChildren;
}
}
?>
Index: spl/examples/directorytreeiterator.inc
+++ spl/examples/directorytreeiterator.inc
getLevel(); $l++) {
$tree .= $this->getSubIterator($l)->hasMore() ? '| ' : ' ';
}
return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
. $this->getSubIterator($l);
}
}
?>
Index: spl/examples/recursiveiterator.inc
+++ spl/examples/recursiveiterator.inc
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: spl /examples directorytreeiterator.inc
helly Tue Nov 18 17:34:52 2003 EDT
Modified files:
/spl/examples directorytreeiterator.inc
Log:
Must use hasNext() here
Index: spl/examples/directorytreeiterator.inc
diff -u spl/examples/directorytreeiterator.inc:1.1
spl/examples/directorytreeiterator.inc:1.2
--- spl/examples/directorytreeiterator.inc:1.1 Tue Nov 18 17:18:38 2003
+++ spl/examples/directorytreeiterator.inc Tue Nov 18 17:34:51 2003
@@ -11,7 +11,7 @@
{
$tree = '';
for ($l=0; $l < $this->getLevel(); $l++) {
- $tree .= $this->getSubIterator($l)->hasMore() ? '| ' : ' ';
+ $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' ';
}
return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
. $this->getSubIterator($l);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/tokenizer Makefile.frag
sniper Tue Nov 18 19:09:46 2003 EDT Modified files: /php-src/ext/tokenizer Makefile.frag Log: Fix build Index: php-src/ext/tokenizer/Makefile.frag diff -u php-src/ext/tokenizer/Makefile.frag:1.2 php-src/ext/tokenizer/Makefile.frag:1.3 --- php-src/ext/tokenizer/Makefile.frag:1.2 Mon Nov 17 14:31:17 2003 +++ php-src/ext/tokenizer/Makefile.frag Tue Nov 18 19:09:45 2003 @@ -1 +1,2 @@ -$(builddir)/tokenizer.lo: $(builddir)/../../Zend/zend_language_parser.h +Zend/zend_language_parser.h: +$(builddir)/tokenizer.lo: Zend/zend_language_parser.h -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/tokenizer Makefile.frag
sniper Tue Nov 18 19:10:04 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/tokenizer Makefile.frag Log: Fix build Index: php-src/ext/tokenizer/Makefile.frag diff -u php-src/ext/tokenizer/Makefile.frag:1.1.4.1 php-src/ext/tokenizer/Makefile.frag:1.1.4.2 --- php-src/ext/tokenizer/Makefile.frag:1.1.4.1 Mon Nov 17 14:32:05 2003 +++ php-src/ext/tokenizer/Makefile.frag Tue Nov 18 19:10:03 2003 @@ -1 +1,2 @@ -$(builddir)/tokenizer.lo: $(builddir)/../../Zend/zend_language_parser.h +Zend/zend_language_parser.h: +$(builddir)/tokenizer.lo: Zend/zend_language_parser.h -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: spl /examples cachingrecursiveiterator.inc directorytreeiterator.inc
helly Tue Nov 18 19:18:30 2003 EDT
Modified files:
/spl/examples cachingrecursiveiterator.inc
directorytreeiterator.inc
Log:
Dont't stop if directory can't be openedbecause of user rights etc
Index: spl/examples/cachingrecursiveiterator.inc
diff -u spl/examples/cachingrecursiveiterator.inc:1.1
spl/examples/cachingrecursiveiterator.inc:1.2
--- spl/examples/cachingrecursiveiterator.inc:1.1 Tue Nov 18 17:18:38 2003
+++ spl/examples/cachingrecursiveiterator.inc Tue Nov 18 19:18:30 2003
@@ -4,14 +4,28 @@
{
protected $hasChildren;
protected $getChildren;
+ protected $catch_get_child_exceptions;
- function __construct(RecursiveIterator $it) {
+ function __construct(RecursiveIterator $it, $catch_get_child_exceptions =
false) {
+ $this->catch_get_child_exceptions = $catch_get_child_exceptions;
parent::__construct($it);
}
function next() {
if ($this->hasChildren = $this->it->hasChildren()) {
- $this->getChildren = new
CachingRecursiveIterator($this->it->getChildren());
+ try {
+ //$this->getChildren = new
CachingRecursiveIterator($this->it->getChildren(), $this->catch_get_child_exceptions);
+ // workaround memleaks...
+ $child = $this->it->getChildren();
+ $this->getChildren = new
CachingRecursiveIterator($child, $this->catch_get_child_exceptions);
+ }
+ catch(Exception $e) {
+ if (!$this->catch_get_child_exceptions) {
+ throw $e;
+ }
+ $this->hasChildren = false;
+ $this->getChildren = NULL;
+ }
} else {
$this->getChildren = NULL;
}
Index: spl/examples/directorytreeiterator.inc
diff -u spl/examples/directorytreeiterator.inc:1.2
spl/examples/directorytreeiterator.inc:1.3
--- spl/examples/directorytreeiterator.inc:1.2 Tue Nov 18 17:34:51 2003
+++ spl/examples/directorytreeiterator.inc Tue Nov 18 19:18:30 2003
@@ -4,7 +4,7 @@
{
function __construct($path)
{
- parent::__construct(new CachingRecursiveIterator(new
RecursiveDirectoryIterator($path)), 1);
+ parent::__construct(new CachingRecursiveIterator(new
RecursiveDirectoryIterator($path), true), 1);
}
function current()
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gmp config.m4 gmp.c php_gmp.h
sniper Tue Nov 18 23:44:07 2003 EDT
Modified files:
/php-src/ext/gmpconfig.m4 gmp.c php_gmp.h
Log:
- Fixed bug #26267 (gmp_random() leaks memory and does not produce random numbers)
# ..and mpz_random() is obsolete according to the GNU MP manual.
Index: php-src/ext/gmp/config.m4
diff -u php-src/ext/gmp/config.m4:1.9 php-src/ext/gmp/config.m4:1.10
--- php-src/ext/gmp/config.m4:1.9 Tue Sep 30 22:53:08 2003
+++ php-src/ext/gmp/config.m4 Tue Nov 18 23:44:06 2003
@@ -1,9 +1,9 @@
dnl
-dnl $Id: config.m4,v 1.9 2003/10/01 02:53:08 sniper Exp $
+dnl $Id: config.m4,v 1.10 2003/11/19 04:44:06 sniper Exp $
dnl
PHP_ARG_WITH(gmp, for GNU MP support,
-[ --with-gmp Include GNU MP support])
+[ --with-gmp[=DIR]Include GNU MP support])
if test "$PHP_GMP" != "no"; then
@@ -14,6 +14,18 @@
if test -z "$GMP_DIR"; then
AC_MSG_ERROR(Unable to locate gmp.h)
fi
+
+ PHP_CHECK_LIBRARY(gmp, __gmp_randinit_lc_2exp_size,
+ [],[
+PHP_CHECK_LIBRARY(gmp, gmp_randinit_lc_2exp_size,
+[],[
+ AC_MSG_ERROR([GNU MP Library version 4.1.2 or greater required.])
+],[
+ -L$GMP_DIR/lib
+])
+ ],[
+-L$GMP_DIR/lib
+ ])
PHP_ADD_LIBRARY_WITH_PATH(gmp, $GMP_DIR/lib, GMP_SHARED_LIBADD)
PHP_ADD_INCLUDE($GMP_DIR/include)
Index: php-src/ext/gmp/gmp.c
diff -u php-src/ext/gmp/gmp.c:1.37 php-src/ext/gmp/gmp.c:1.38
--- php-src/ext/gmp/gmp.c:1.37 Tue Nov 18 05:28:13 2003
+++ php-src/ext/gmp/gmp.c Tue Nov 18 23:44:06 2003
@@ -28,9 +28,12 @@
#if HAVE_GMP
#include
-/* If you declare any globals in php_gmp.h uncomment this:
-ZEND_DECLARE_MODULE_GLOBALS(gmp)
-*/
+
+/* Needed for gmp_random() */
+#include "ext/standard/php_rand.h"
+#include "ext/standard/php_lcg.h"
+#include
+#define GMP_ABS(x) ((x) >= 0 ? (x) : -(x))
/* True global resources - no need for thread safety here */
static int le_gmp;
@@ -90,13 +93,15 @@
ZEND_MODULE_STARTUP_N(gmp),
ZEND_MODULE_SHUTDOWN_N(gmp),
NULL,
- NULL,
+ ZEND_MODULE_DEACTIVATE_N(gmp),
ZEND_MODULE_INFO_N(gmp),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
/* }}} */
+ZEND_DECLARE_MODULE_GLOBALS(gmp)
+
#ifdef COMPILE_DL_GMP
ZEND_GET_MODULE(gmp)
# ifdef PHP_WIN32
@@ -136,10 +141,20 @@
}
/* }}} */
+/* {{{ php_gmp_init_globals
+ */
+static void php_gmp_init_globals(zend_gmp_globals *gmp_globals)
+{
+ gmp_globals->rand_initialized = 0;
+}
+/* }}} */
+
/* {{{ ZEND_MINIT_FUNCTION
*/
ZEND_MODULE_STARTUP_D(gmp)
{
+ZEND_INIT_MODULE_GLOBALS(gmp, php_gmp_init_globals, NULL);
+
le_gmp = zend_register_list_destructors_ex(_php_gmpnum_free, NULL,
GMP_RESOURCE_NAME, module_number);
REGISTER_LONG_CONSTANT("GMP_ROUND_ZERO", GMP_ROUND_ZERO, CONST_CS |
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GMP_ROUND_PLUSINF", GMP_ROUND_PLUSINF, CONST_CS |
CONST_PERSISTENT);
@@ -151,6 +166,19 @@
}
/* }}} */
+/* {{{ ZEND_RSHUTDOWN_FUNCTION
+ */
+ZEND_MODULE_DEACTIVATE_D(gmp)
+{
+ if (GMPG(rand_initialized)) {
+ gmp_randclear(GMPG(rand_state));
+ GMPG(rand_initialized) = 0;
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
/* {{{ ZEND_MSHUTDOWN_FUNCTION
*/
ZEND_MODULE_SHUTDOWN_D(gmp)
@@ -1042,7 +1070,17 @@
}
INIT_GMP_NUM(gmpnum_result);
- mpz_random(*gmpnum_result, limiter);
+
+ if (!GMPG(rand_initialized)) {
+ /* Initialize */
+ gmp_randinit_lc_2exp_size(GMPG(rand_state), 32L);
+
+ /* Seed */
+ gmp_randseed_ui(GMPG(rand_state), GENERATE_SEED());
+
+ GMPG(rand_initialized) = 1;
+ }
+ mpz_urandomb(*gmpnum_result, GMPG(rand_state), GMP_ABS (limiter) *
BITS_PER_MP_LIMB);
ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp);
}
Index: php-src/ext/gmp/php_gmp.h
diff -u php-src/ext/gmp/php_gmp.h:1.9 php-src/ext/gmp/php_gmp.h:1.10
--- php-src/ext/gmp/php_gmp.h:1.9 Tue Jun 10 16:03:29 2003
+++ php-src/ext/gmp/php_gmp.h Tue Nov 18 23:44:06 2003
@@ -19,11 +19,10 @@
#ifndef PHP_GMP_H
#define PHP_GMP_H
-/* You should tweak config.m4 so this symbol (or some else suitable)
- gets defined.
-*/
#if HAVE_GMP
+#include
+
extern zend_module_entry gmp_module_entry;
#define phpext_gmp_ptr &gmp_module_entry
@@ -35,6 +34,7 @@
ZEND_MODULE_STARTUP_D(gmp);
ZEND_MODULE_SHUTDOWN_D(gmp);
+ZEND_MODULE_DEACTIVATE_D(gmp);
ZEND_MODULE_INFO_D(gmp);
ZEND_FUNCTION(gmp_init);
@@ -76,24 +76,13 @@
ZEND_FUNCTION(gmp_popcount);
ZEND_FUNCTION(gmp_hamdist);
-/*
- Declare any global variables you may need between the BEGIN
- and END macros here:
-
ZEND_BEGIN_MODULE_GLOBALS(gmp)
- int global_variable;
+ zend_bool rand_initialized;
+ gmp_randstate_t rand_state;
ZEND_END_MODULE_GLOBALS(gmp)
-*/
-
-/* In every function that needs to use variables in php_gmp_globals,
- do call GMPLS_FETCH(); after declaring other
[PHP-CVS] cvs: php-src(PHP_4_3) / NEWS /ext/gmp config.m4 gmp.c php_gmp.h
sniper Tue Nov 18 23:44:25 2003 EDT
Modified files: (Branch: PHP_4_3)
/php-srcNEWS
/php-src/ext/gmpconfig.m4 gmp.c php_gmp.h
Log:
MFH: - Fixed bug #26267 (gmp_random() leaks memory and does not produce random
numbers)
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.471 php-src/NEWS:1.1247.2.472
--- php-src/NEWS:1.1247.2.471 Mon Nov 17 21:50:50 2003
+++ php-src/NEWSTue Nov 18 23:44:23 2003
@@ -3,6 +3,8 @@
?? ??? 2003, Version 4.3.5
- Fixed header handler in NSAPI SAPI module (header->replace was ignored,
send_default_content_type now sends value from php.ini). (Uwe Schindler)
+- Fixed bug #26267 (gmp_random() leaks memory and does not produce random
+ numbers). (Jani)
- Fixed bug #26253 (ext/tokenizer: build as shared extension fails). (Jani)
- Fixed bug #26235 (yp_first/yp_next do not specify correct key length). (Ilia)
- Fixed bug #26216 ("getimagesize(): stream does not support seeking" when
Index: php-src/ext/gmp/config.m4
diff -u php-src/ext/gmp/config.m4:1.7.4.2 php-src/ext/gmp/config.m4:1.7.4.3
--- php-src/ext/gmp/config.m4:1.7.4.2 Tue Sep 30 22:53:58 2003
+++ php-src/ext/gmp/config.m4 Tue Nov 18 23:44:24 2003
@@ -1,9 +1,9 @@
dnl
-dnl $Id: config.m4,v 1.7.4.2 2003/10/01 02:53:58 sniper Exp $
+dnl $Id: config.m4,v 1.7.4.3 2003/11/19 04:44:24 sniper Exp $
dnl
PHP_ARG_WITH(gmp, for GNU MP support,
-[ --with-gmp Include GNU MP support])
+[ --with-gmp[=DIR]Include GNU MP support])
if test "$PHP_GMP" != "no"; then
@@ -14,6 +14,18 @@
if test -z "$GMP_DIR"; then
AC_MSG_ERROR(Unable to locate gmp.h)
fi
+
+ PHP_CHECK_LIBRARY(gmp, __gmp_randinit_lc_2exp_size,
+ [],[
+PHP_CHECK_LIBRARY(gmp, gmp_randinit_lc_2exp_size,
+[],[
+ AC_MSG_ERROR([GNU MP Library version 4.1.2 or greater required.])
+],[
+ -L$GMP_DIR/lib
+])
+ ],[
+-L$GMP_DIR/lib
+ ])
PHP_ADD_LIBRARY_WITH_PATH(gmp, $GMP_DIR/lib, GMP_SHARED_LIBADD)
PHP_ADD_INCLUDE($GMP_DIR/include)
Index: php-src/ext/gmp/gmp.c
diff -u php-src/ext/gmp/gmp.c:1.29.4.4 php-src/ext/gmp/gmp.c:1.29.4.5
--- php-src/ext/gmp/gmp.c:1.29.4.4 Tue Nov 18 05:28:34 2003
+++ php-src/ext/gmp/gmp.c Tue Nov 18 23:44:24 2003
@@ -28,9 +28,12 @@
#if HAVE_GMP
#include
-/* If you declare any globals in php_gmp.h uncomment this:
-ZEND_DECLARE_MODULE_GLOBALS(gmp)
-*/
+
+/* Needed for gmp_random() */
+#include "ext/standard/php_rand.h"
+#include "ext/standard/php_lcg.h"
+#include
+#define GMP_ABS(x) ((x) >= 0 ? (x) : -(x))
/* True global resources - no need for thread safety here */
static int le_gmp;
@@ -92,13 +95,15 @@
ZEND_MODULE_STARTUP_N(gmp),
ZEND_MODULE_SHUTDOWN_N(gmp),
NULL,
- NULL,
+ ZEND_MODULE_DEACTIVATE_N(gmp),
ZEND_MODULE_INFO_N(gmp),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
/* }}} */
+ZEND_DECLARE_MODULE_GLOBALS(gmp)
+
#ifdef COMPILE_DL_GMP
ZEND_GET_MODULE(gmp)
#endif
@@ -135,10 +140,20 @@
}
/* }}} */
+/* {{{ php_gmp_init_globals
+ */
+static void php_gmp_init_globals(zend_gmp_globals *gmp_globals)
+{
+ gmp_globals->rand_initialized = 0;
+}
+/* }}} */
+
/* {{{ ZEND_MINIT_FUNCTION
*/
ZEND_MODULE_STARTUP_D(gmp)
{
+ZEND_INIT_MODULE_GLOBALS(gmp, php_gmp_init_globals, NULL);
+
le_gmp = zend_register_list_destructors_ex(_php_gmpnum_free, NULL,
GMP_RESOURCE_NAME, module_number);
REGISTER_LONG_CONSTANT("GMP_ROUND_ZERO", GMP_ROUND_ZERO, CONST_CS |
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GMP_ROUND_PLUSINF", GMP_ROUND_PLUSINF, CONST_CS |
CONST_PERSISTENT);
@@ -150,6 +165,19 @@
}
/* }}} */
+/* {{{ ZEND_RSHUTDOWN_FUNCTION
+ */
+ZEND_MODULE_DEACTIVATE_D(gmp)
+{
+ if (GMPG(rand_initialized)) {
+ gmp_randclear(GMPG(rand_state));
+ GMPG(rand_initialized) = 0;
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
/* {{{ ZEND_MSHUTDOWN_FUNCTION
*/
ZEND_MODULE_SHUTDOWN_D(gmp)
@@ -1041,7 +1069,17 @@
}
INIT_GMP_NUM(gmpnum_result);
- mpz_random(*gmpnum_result, limiter);
+
+ if (!GMPG(rand_initialized)) {
+ /* Initialize */
+ gmp_randinit_lc_2exp_size(GMPG(rand_state), 32L);
+
+ /* Seed */
+ gmp_randseed_ui(GMPG(rand_state), GENERATE_SEED());
+
+ GMPG(rand_initialized) = 1;
+ }
+ mpz_urandomb(*gmpnum_result, GMPG(rand_state), GMP_ABS (limiter) *
BITS_PER_MP_LIMB);
ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp);
}
Index: php-src/ext/gmp/php_gmp.h
diff -u php-src/ext/gmp/php_gmp.h:1.7.8.1 php-src/ext/gmp/php_gmp.h:1.7.8.2
--- php-src/ext/gmp/php_gmp.h:1.7.8.1 Tue Dec 31 11:34:39 2002
+++ php-src/ext/gmp/php_gmp.h Tue Nov 18 23:44:24 2003
@@ -19,11 +19,10 @@
#ifndef PHP_GMP_H
#define PHP_GMP_H
-/* You should tweak config.m4 so this symbol (or some else suitable)
- gets defined.
-*/
#if HAVE_GMP
+#include
+
extern zend_module_
[PHP-CVS] cvs: php-src /ext/gmp gmp.c
sniper Wed Nov 19 00:00:58 2003 EDT
Modified files:
/php-src/ext/gmpgmp.c
Log:
ws fix
Index: php-src/ext/gmp/gmp.c
diff -u php-src/ext/gmp/gmp.c:1.38 php-src/ext/gmp/gmp.c:1.39
--- php-src/ext/gmp/gmp.c:1.38 Tue Nov 18 23:44:06 2003
+++ php-src/ext/gmp/gmp.c Wed Nov 19 00:00:56 2003
@@ -153,7 +153,7 @@
*/
ZEND_MODULE_STARTUP_D(gmp)
{
-ZEND_INIT_MODULE_GLOBALS(gmp, php_gmp_init_globals, NULL);
+ ZEND_INIT_MODULE_GLOBALS(gmp, php_gmp_init_globals, NULL);
le_gmp = zend_register_list_destructors_ex(_php_gmpnum_free, NULL,
GMP_RESOURCE_NAME, module_number);
REGISTER_LONG_CONSTANT("GMP_ROUND_ZERO", GMP_ROUND_ZERO, CONST_CS |
CONST_PERSISTENT);
@@ -204,10 +204,10 @@
/* Fetch zval to be GMP number.
Initially, zval can be also number or string */
#define FETCH_GMP_ZVAL(gmpnumber, zval) \
-if(Z_TYPE_PP(zval) == IS_RESOURCE) { \
+if (Z_TYPE_PP(zval) == IS_RESOURCE) { \
ZEND_FETCH_RESOURCE(gmpnumber, mpz_t *, zval, -1, GMP_RESOURCE_NAME, le_gmp);\
} else {\
- if(convert_to_gmp(&gmpnumber, zval, 0 TSRMLS_CC) == FAILURE) {\
+ if (convert_to_gmp(&gmpnumber, zval, 0 TSRMLS_CC) == FAILURE) {\
RETURN_FALSE;\
}\
ZEND_REGISTER_RESOURCE(NULL, gmpnumber, le_gmp);\
@@ -225,7 +225,8 @@
int skip_lead = 0;
*gmpnumber = emalloc(sizeof(mpz_t));
- switch(Z_TYPE_PP(val)) {
+
+ switch (Z_TYPE_PP(val)) {
case IS_LONG:
case IS_BOOL:
case IS_CONSTANT:
@@ -301,19 +302,21 @@
static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zval
**b_arg, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int allow_ui_return
TSRMLS_DC)
{
mpz_t *gmpnum_a, *gmpnum_b, *gmpnum_result;
- unsigned long long_result=0;
- int use_ui=0;
+ unsigned long long_result = 0;
+ int use_ui = 0;
FETCH_GMP_ZVAL(gmpnum_a, a_arg);
- if(gmp_ui_op && Z_TYPE_PP(b_arg) == IS_LONG && Z_LVAL_PP(b_arg) >= 0) {
- use_ui=1;
+
+ if (gmp_ui_op && Z_TYPE_PP(b_arg) == IS_LONG && Z_LVAL_PP(b_arg) >= 0) {
+ use_ui = 1;
} else {
FETCH_GMP_ZVAL(gmpnum_b, b_arg);
}
INIT_GMP_NUM(gmpnum_result);
- if(use_ui && gmp_ui_op) {
- if(allow_ui_return) {
+
+ if (use_ui && gmp_ui_op) {
+ if (allow_ui_return) {
long_result = gmp_ui_op(*gmpnum_result, *gmpnum_a, (unsigned
long)Z_LVAL_PP(b_arg));
} else {
gmp_ui_op(*gmpnum_result, *gmpnum_a, (unsigned
long)Z_LVAL_PP(b_arg));
@@ -322,7 +325,7 @@
gmp_op(*gmpnum_result, *gmpnum_a, *gmpnum_b);
}
- if(use_ui && allow_ui_return) {
+ if (use_ui && allow_ui_return) {
FREE_GMP_NUM(gmpnum_result);
RETURN_LONG((long)long_result);
} else {
@@ -339,13 +342,14 @@
{
mpz_t *gmpnum_a, *gmpnum_b, *gmpnum_result1, *gmpnum_result2;
zval r;
- int use_ui=0;
+ int use_ui = 0;
unsigned long long_result = 0;
FETCH_GMP_ZVAL(gmpnum_a, a_arg);
- if(gmp_ui_op && Z_TYPE_PP(b_arg) == IS_LONG && Z_LVAL_PP(b_arg) >= 0) {
+
+ if (gmp_ui_op && Z_TYPE_PP(b_arg) == IS_LONG && Z_LVAL_PP(b_arg) >= 0) {
/* use _ui function */
- use_ui=1;
+ use_ui = 1;
} else {
FETCH_GMP_ZVAL(gmpnum_b, b_arg);
}
@@ -353,8 +357,8 @@
INIT_GMP_NUM(gmpnum_result1);
INIT_GMP_NUM(gmpnum_result2);
- if(use_ui && gmp_ui_op) {
- if(allow_ui_return) {
+ if (use_ui && gmp_ui_op) {
+ if (allow_ui_return) {
long_result = gmp_ui_op(*gmpnum_result1, *gmpnum_result2,
*gmpnum_a, (unsigned long)Z_LVAL_PP(b_arg));
} else {
gmp_ui_op(*gmpnum_result1, *gmpnum_result2, *gmpnum_a,
(unsigned long)Z_LVAL_PP(b_arg));
@@ -366,7 +370,7 @@
array_init(return_value);
ZEND_REGISTER_RESOURCE(&r, gmpnum_result1, le_gmp);
add_index_resource(return_value, 0, Z_LVAL(r));
- if(use_ui && allow_ui_return) {
+ if (use_ui && allow_ui_return) {
mpz_clear(*gmpnum_result2);
add_index_long(return_value, 1, long_result);
} else {
@@ -378,7 +382,8 @@
/* {{{ _gmp_binary_ui_op
*/
-static inline void _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAMETERS, gmp_binary_op_t
gmp_op, gmp_binary_ui_op_t gmp_ui_op) {
+static inline void _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAMETERS, gmp_binary_op_t
gmp_op, gmp_binary_ui_op_t gmp_ui_op)
+{
zval **a_arg, **b_arg;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &a_arg, &b_arg) ==
FAILURE){
@@ -408,7 +413,8 @@
/* {{{ gmp_zval_unary_ui_op
*/
-static inline void gmp_zval_unary_ui_op(zval *return_value, zval **a_arg,
gmp_unary_ui_op_t gmp
[PHP-CVS] cvs: php-src /main main.c
andiWed Nov 19 01:11:48 2003 EDT
Modified files:
/php-src/main main.c
Log:
- Commit patch by standards
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.579 php-src/main/main.c:1.580
--- php-src/main/main.c:1.579 Wed Oct 8 22:58:34 2003
+++ php-src/main/main.c Wed Nov 19 01:11:47 2003
@@ -18,7 +18,7 @@
+--+
*/
-/* $Id: main.c,v 1.579 2003/10/09 02:58:34 iliaa Exp $ */
+/* $Id: main.c,v 1.580 2003/11/19 06:11:47 andi Exp $ */
/* {{{ includes
*/
@@ -723,6 +723,9 @@
case E_USER_NOTICE:
error_type_str = "Notice";
break;
+ case E_STRICT:
+ error_type_str = "Strict Standards";
+ break;
default:
error_type_str = "Unknown error";
break;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
