jani Mon, 31 Aug 2009 21:18:55 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=287926
Log:
- Fixed zlib.deflate compress filter to actually accpet level parameter.
Changed paths:
U php/php-src/branches/PHP_5_2/NEWS
A php/php-src/branches/PHP_5_2/ext/zlib/tests/zlib_filter_deflate2.phpt
U php/php-src/branches/PHP_5_2/ext/zlib/zlib_filter.c
U php/php-src/branches/PHP_5_3/NEWS
A php/php-src/branches/PHP_5_3/ext/zlib/tests/zlib_filter_deflate2.phpt
U php/php-src/branches/PHP_5_3/ext/zlib/zlib_filter.c
A php/php-src/trunk/ext/zlib/tests/zlib_filter_deflate2.phpt
U php/php-src/trunk/ext/zlib/zlib_filter.c
Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS 2009-08-31 19:22:29 UTC (rev 287925)
+++ php/php-src/branches/PHP_5_2/NEWS 2009-08-31 21:18:55 UTC (rev 287926)
@@ -3,6 +3,7 @@
?? ??? 2009, PHP 5.2.11
- Added missing sanity checks around exif processing (Ilia)
+- Fixed zlib.deflate compress filter to actually accpet level parameter. (Jani)
- Fixed leak on error in popen/exec (and related functions on Windows. (Pierre)
- Fixed bug #49361 (wordwrap() wraps incorrectly on end of line boundaries).
Added: php/php-src/branches/PHP_5_2/ext/zlib/tests/zlib_filter_deflate2.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/zlib/tests/zlib_filter_deflate2.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/zlib/tests/zlib_filter_deflate2.phpt 2009-08-31 21:18:55 UTC (rev 287926)
@@ -0,0 +1,16 @@
+--TEST--
+zlib.deflate (with level parameter set)
+--SKIPIF--
+<?php if (!extension_loaded("zlib")) print "skip"; ?>
+--FILE--
+<?php
+$text = 'I am the very model of a modern major general, I\'ve information vegetable, animal, and mineral.';
+
+$fp = fopen('php://stdout', 'w');
+stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, array('level' => 9));
+fwrite($fp, $text);
+fclose($fp);
+
+?>
+--EXPECT--
+�A� Dѫ����1�MB��Uv�_�(�EL���/��aP�=Pi�;�6�f�Ce4��U9;w�5��m/
Modified: php/php-src/branches/PHP_5_2/ext/zlib/zlib_filter.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/zlib/zlib_filter.c 2009-08-31 19:22:29 UTC (rev 287925)
+++ php/php-src/branches/PHP_5_2/ext/zlib/zlib_filter.c 2009-08-31 21:18:55 UTC (rev 287926)
@@ -353,7 +353,7 @@
if (filterparams) {
- zval **tmpzval;
+ zval **tmpzval, tmp;
/* filterparams can either be a scalar value to indicate compression level (shortcut method)
Or can be a hash containing one or more of 'window', 'memory', and/or 'level' members. */
@@ -362,8 +362,6 @@
case IS_ARRAY:
case IS_OBJECT:
if (zend_hash_find(HASH_OF(filterparams), "memory", sizeof("memory"), (void**) &tmpzval) == SUCCESS) {
- zval tmp;
-
tmp = **tmpzval;
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
@@ -377,8 +375,6 @@
}
if (zend_hash_find(HASH_OF(filterparams), "window", sizeof("window"), (void**) &tmpzval) == SUCCESS) {
- zval tmp;
-
tmp = **tmpzval;
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
@@ -392,6 +388,8 @@
}
if (zend_hash_find(HASH_OF(filterparams), "level", sizeof("level"), (void**) &tmpzval) == SUCCESS) {
+ tmp = **tmpzval;
+
/* Psuedo pass through to catch level validating code */
goto factory_setlevel;
}
@@ -399,19 +397,16 @@
case IS_STRING:
case IS_DOUBLE:
case IS_LONG:
- {
- zval tmp;
-
- tmp = *filterparams;
- zval_copy_ctor(&tmp);
- convert_to_long(&tmp);
+ tmp = *filterparams;
factory_setlevel:
- /* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */
- if (Z_LVAL(tmp) < -1 || Z_LVAL(tmp) > 9) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%ld)", Z_LVAL(tmp));
- } else {
- level = Z_LVAL(tmp);
- }
+ zval_copy_ctor(&tmp);
+ convert_to_long(&tmp);
+
+ /* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */
+ if (Z_LVAL(tmp) < -1 || Z_LVAL(tmp) > 9) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%ld)", Z_LVAL(tmp));
+ } else {
+ level = Z_LVAL(tmp);
}
break;
default:
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2009-08-31 19:22:29 UTC (rev 287925)
+++ php/php-src/branches/PHP_5_3/NEWS 2009-08-31 21:18:55 UTC (rev 287926)
@@ -16,6 +16,7 @@
- Improved shared extension loading on OSX to use the standard Unix dlopen()
API. (Scott)
+- Fixed zlib.deflate compress filter to actually accpet level parameter. (Jani)
- Fixed leak on error in popen/exec (and related functions) on Windows.
(Pierre)
- Fixed possible bad caching of symlinked directories in the realpath cache
Added: php/php-src/branches/PHP_5_3/ext/zlib/tests/zlib_filter_deflate2.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/zlib/tests/zlib_filter_deflate2.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/zlib/tests/zlib_filter_deflate2.phpt 2009-08-31 21:18:55 UTC (rev 287926)
@@ -0,0 +1,16 @@
+--TEST--
+zlib.deflate (with level parameter set)
+--SKIPIF--
+<?php if (!extension_loaded("zlib")) print "skip"; ?>
+--FILE--
+<?php
+$text = 'I am the very model of a modern major general, I\'ve information vegetable, animal, and mineral.';
+
+$fp = fopen('php://stdout', 'w');
+stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, array('level' => 9));
+fwrite($fp, $text);
+fclose($fp);
+
+?>
+--EXPECT--
+�A� Dѫ����1�MB��Uv�_�(�EL���/��aP�=Pi�;�6�f�Ce4��U9;w�5��m/
Modified: php/php-src/branches/PHP_5_3/ext/zlib/zlib_filter.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/zlib/zlib_filter.c 2009-08-31 19:22:29 UTC (rev 287925)
+++ php/php-src/branches/PHP_5_3/ext/zlib/zlib_filter.c 2009-08-31 21:18:55 UTC (rev 287926)
@@ -352,7 +352,7 @@
if (filterparams) {
- zval **tmpzval;
+ zval **tmpzval, tmp;
/* filterparams can either be a scalar value to indicate compression level (shortcut method)
Or can be a hash containing one or more of 'window', 'memory', and/or 'level' members. */
@@ -361,8 +361,6 @@
case IS_ARRAY:
case IS_OBJECT:
if (zend_hash_find(HASH_OF(filterparams), "memory", sizeof("memory"), (void**) &tmpzval) == SUCCESS) {
- zval tmp;
-
tmp = **tmpzval;
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
@@ -376,8 +374,6 @@
}
if (zend_hash_find(HASH_OF(filterparams), "window", sizeof("window"), (void**) &tmpzval) == SUCCESS) {
- zval tmp;
-
tmp = **tmpzval;
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
@@ -391,6 +387,8 @@
}
if (zend_hash_find(HASH_OF(filterparams), "level", sizeof("level"), (void**) &tmpzval) == SUCCESS) {
+ tmp = **tmpzval;
+
/* Psuedo pass through to catch level validating code */
goto factory_setlevel;
}
@@ -398,19 +396,16 @@
case IS_STRING:
case IS_DOUBLE:
case IS_LONG:
- {
- zval tmp;
-
- tmp = *filterparams;
- zval_copy_ctor(&tmp);
- convert_to_long(&tmp);
+ tmp = *filterparams;
factory_setlevel:
- /* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */
- if (Z_LVAL(tmp) < -1 || Z_LVAL(tmp) > 9) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%ld)", Z_LVAL(tmp));
- } else {
- level = Z_LVAL(tmp);
- }
+ zval_copy_ctor(&tmp);
+ convert_to_long(&tmp);
+
+ /* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */
+ if (Z_LVAL(tmp) < -1 || Z_LVAL(tmp) > 9) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%ld)", Z_LVAL(tmp));
+ } else {
+ level = Z_LVAL(tmp);
}
break;
default:
Added: php/php-src/trunk/ext/zlib/tests/zlib_filter_deflate2.phpt
===================================================================
--- php/php-src/trunk/ext/zlib/tests/zlib_filter_deflate2.phpt (rev 0)
+++ php/php-src/trunk/ext/zlib/tests/zlib_filter_deflate2.phpt 2009-08-31 21:18:55 UTC (rev 287926)
@@ -0,0 +1,16 @@
+--TEST--
+zlib.deflate (with level parameter set)
+--SKIPIF--
+<?php if (!extension_loaded("zlib")) print "skip"; ?>
+--FILE--
+<?php
+$text = 'I am the very model of a modern major general, I\'ve information vegetable, animal, and mineral.';
+
+$fp = fopen('php://stdout', 'w');
+stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, array('level' => 9));
+fwrite($fp, $text);
+fclose($fp);
+
+?>
+--EXPECT--
+�A� Dѫ����1�MB��Uv�_�(�EL���/��aP�=Pi�;�6�f�Ce4��U9;w�5��m/
Modified: php/php-src/trunk/ext/zlib/zlib_filter.c
===================================================================
--- php/php-src/trunk/ext/zlib/zlib_filter.c 2009-08-31 19:22:29 UTC (rev 287925)
+++ php/php-src/trunk/ext/zlib/zlib_filter.c 2009-08-31 21:18:55 UTC (rev 287926)
@@ -370,7 +370,7 @@
if (filterparams) {
- zval **tmpzval;
+ zval **tmpzval, tmp;
/* filterparams can either be a scalar value to indicate compression level (shortcut method)
Or can be a hash containing one or more of 'window', 'memory', and/or 'level' members. */
@@ -379,8 +379,6 @@
case IS_ARRAY:
case IS_OBJECT:
if (zend_hash_find(HASH_OF(filterparams), "memory", sizeof("memory"), (void**) &tmpzval) == SUCCESS) {
- zval tmp;
-
tmp = **tmpzval;
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
@@ -394,8 +392,6 @@
}
if (zend_hash_find(HASH_OF(filterparams), "window", sizeof("window"), (void**) &tmpzval) == SUCCESS) {
- zval tmp;
-
tmp = **tmpzval;
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
@@ -409,6 +405,8 @@
}
if (zend_hash_find(HASH_OF(filterparams), "level", sizeof("level"), (void**) &tmpzval) == SUCCESS) {
+ tmp = **tmpzval;
+
/* Psuedo pass through to catch level validating code */
goto factory_setlevel;
}
@@ -416,19 +414,16 @@
case IS_STRING:
case IS_DOUBLE:
case IS_LONG:
- {
- zval tmp;
-
- tmp = *filterparams;
- zval_copy_ctor(&tmp);
- convert_to_long(&tmp);
+ tmp = *filterparams;
factory_setlevel:
- /* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */
- if (Z_LVAL(tmp) < -1 || Z_LVAL(tmp) > 9) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%ld)", Z_LVAL(tmp));
- } else {
- level = Z_LVAL(tmp);
- }
+ zval_copy_ctor(&tmp);
+ convert_to_long(&tmp);
+
+ /* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */
+ if (Z_LVAL(tmp) < -1 || Z_LVAL(tmp) > 9) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%ld)", Z_LVAL(tmp));
+ } else {
+ level = Z_LVAL(tmp);
}
break;
default:
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php