From: Nuno Lopes Date: Thu, 27 Jul 2006 16:31:07 +0000 (+0000) Subject: upgrade the rest of the functions to Unicode (except ob_gzhandler, that I leave for... X-Git-Tag: RELEASE_1_0_0RC1~2192 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e29c9a8708f0947ba15791dae026ffb56dfdb51;p=php upgrade the rest of the functions to Unicode (except ob_gzhandler, that I leave for Mike). also update tests to force binary data to be passed --- diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index 6548d79e11..45e6734f1e 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -54,9 +54,6 @@ PHP_FUNCTION(gzencode); PHP_FUNCTION(ob_gzhandler); PHP_FUNCTION(zlib_get_coding_type); -int php_enable_output_compression(int buffer_size TSRMLS_DC); -int php_ob_gzhandler_check(zval *handler_name TSRMLS_DC); - php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); extern php_stream_ops php_stream_gzio_ops; extern php_stream_wrapper php_stream_gzip_wrapper; diff --git a/ext/zlib/tests/001.phpt b/ext/zlib/tests/001.phpt index 4850a65a5a..36c7a10eaa 100644 --- a/ext/zlib/tests/001.phpt +++ b/ext/zlib/tests/001.phpt @@ -5,19 +5,19 @@ gzdeflate()/gzinflate() --FILE-- --FILE-- diff --git a/ext/zlib/tests/006.phpt b/ext/zlib/tests/006.phpt index 1ddb563784..62d466030b 100644 --- a/ext/zlib/tests/006.phpt +++ b/ext/zlib/tests/006.phpt @@ -6,13 +6,13 @@ gzdeflate()/gzinflate() and invalid params diff --git a/ext/zlib/tests/007.phpt b/ext/zlib/tests/007.phpt index ec37b99de6..4b0f892d2a 100644 --- a/ext/zlib/tests/007.phpt +++ b/ext/zlib/tests/007.phpt @@ -7,14 +7,14 @@ gzencode() and invalid params var_dump(gzencode()); var_dump(gzencode(1,1,1,1)); -var_dump(gzencode("", -10)); -var_dump(gzencode("", 100)); -var_dump(gzencode("", 1, 100)); +var_dump(gzencode(b"", -10)); +var_dump(gzencode(b"", 100)); +var_dump(gzencode(b"", 1, 100)); -var_dump(gzencode("", -1, 1)); -var_dump(gzencode("", 9, 2)); +var_dump(gzencode(b"", -1, 1)); +var_dump(gzencode(b"", 9, 2)); -$string = "Light of my sun +$string = b"Light of my sun Light in this temple Light in my truth Lies in the darkness"; diff --git a/ext/zlib/tests/bug_34821.phpt b/ext/zlib/tests/bug_34821.phpt index ff845c6df7..8554638095 100644 --- a/ext/zlib/tests/bug_34821.phpt +++ b/ext/zlib/tests/bug_34821.phpt @@ -21,9 +21,9 @@ foreach ($b as $size) { for ($i = 0; $i <= $size; ++$i) { $s .= chr(rand(0,255)); } - var_dump($s == gzinflate(gzdeflate($s))); - var_dump($s == gzuncompress(gzcompress($s))); - var_dump($s == gzinflate(substr(gzencode($s), 10, -8))); + var_dump($s == gzinflate(gzdeflate((binary)$s))); + var_dump($s == gzuncompress(gzcompress((binary)$s))); + var_dump($s == gzinflate(substr(gzencode((binary)$s), 10, -8))); } ?> --EXPECT-- diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 60ff45f4b8..0337834f55 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -83,6 +83,9 @@ /* True globals, no need for thread safety */ static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ +static int php_enable_output_compression(int buffer_size TSRMLS_DC); +static int php_ob_gzhandler_check(zval *handler_name TSRMLS_DC); + /* {{{ php_zlib_functions[] */ zend_function_entry php_zlib_functions[] = { @@ -395,7 +398,7 @@ PHP_FUNCTION(readgzfile) } /* }}} */ -/* {{{ proto string gzcompress(string data [, int level]) +/* {{{ proto string gzcompress(string data [, int level]) U Gzip-compress a string */ PHP_FUNCTION(gzcompress) { @@ -404,7 +407,7 @@ PHP_FUNCTION(gzcompress) unsigned long l2; char *data, *s2; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &level) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|l", &data, &data_len, &level) == FAILURE) { return; } @@ -437,7 +440,7 @@ PHP_FUNCTION(gzcompress) } /* }}} */ -/* {{{ proto string gzuncompress(string data [, int length]) +/* {{{ proto string gzuncompress(string data [, int length]) U Unzip a gzip-compressed string */ PHP_FUNCTION(gzuncompress) { @@ -447,7 +450,7 @@ PHP_FUNCTION(gzuncompress) unsigned long plength=0, length; char *data, *s1=NULL, *s2=NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &limit) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|l", &data, &data_len, &limit) == FAILURE) { return; } @@ -483,7 +486,7 @@ PHP_FUNCTION(gzuncompress) } /* }}} */ -/* {{{ proto string gzdeflate(string data [, int level]) +/* {{{ proto string gzdeflate(string data [, int level]) U Gzip-compress a string */ PHP_FUNCTION(gzdeflate) { @@ -492,7 +495,7 @@ PHP_FUNCTION(gzdeflate) z_stream stream; char *data, *s2; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &level) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|l", &data, &data_len, &level) == FAILURE) { return; } @@ -544,7 +547,7 @@ PHP_FUNCTION(gzdeflate) } /* }}} */ -/* {{{ proto string gzinflate(string data [, int length]) +/* {{{ proto string gzinflate(string data [, int length]) U Unzip a gzip-compressed string */ PHP_FUNCTION(gzinflate) { @@ -555,7 +558,7 @@ PHP_FUNCTION(gzinflate) char *data, *s1=NULL, *s2=NULL; z_stream stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &limit) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|l", &data, &data_len, &limit) == FAILURE) { return; } @@ -758,7 +761,7 @@ static int php_deflate_string(const char *str, uint str_length, char **newstr, u } /* }}} */ -/* {{{ proto string gzencode(string data [, int level [, int encoding_mode]]) +/* {{{ proto string gzencode(string data [, int level [, int encoding_mode]]) U GZ encode a string */ PHP_FUNCTION(gzencode) { @@ -768,7 +771,7 @@ PHP_FUNCTION(gzencode) int status; z_stream stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &data, &data_len, &level, &coding) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|ll", &data, &data_len, &level, &coding) == FAILURE) { return; } @@ -862,7 +865,7 @@ PHP_FUNCTION(gzencode) /* {{{ php_ob_gzhandler_check */ -int php_ob_gzhandler_check(zval *handler_name TSRMLS_DC) +static int php_ob_gzhandler_check(zval *handler_name TSRMLS_DC) { /* check for wrong usages */ if (php_output_get_level(TSRMLS_C) > 0) { @@ -1012,7 +1015,7 @@ static void php_gzip_output_handler(char *output, uint output_len, char **handle /* {{{ php_enable_output_compression */ -int php_enable_output_compression(int buffer_size TSRMLS_DC) +static int php_enable_output_compression(int buffer_size TSRMLS_DC) { zval **a_encoding, *output_handler;