cataphract Sun, 04 Sep 2011 22:36:33 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=316121
Log:
- Fixed borked refactoring in r307437 (using SUCCESS/FAILURE return instead of
out parameter).
- Fixed signature of php_stream_copy_to_stream_ex to return int in 5.4/trunk
instead of size_t, as the function only returns SUCCESS/FAILURE.
Changed paths:
U php/php-src/branches/PHP_5_3/main/streams/cast.c
U php/php-src/branches/PHP_5_4/main/php_streams.h
U php/php-src/branches/PHP_5_4/main/streams/cast.c
U php/php-src/branches/PHP_5_4/main/streams/streams.c
U php/php-src/trunk/main/php_streams.h
U php/php-src/trunk/main/streams/cast.c
U php/php-src/trunk/main/streams/streams.c
Modified: php/php-src/branches/PHP_5_3/main/streams/cast.c
===================================================================
--- php/php-src/branches/PHP_5_3/main/streams/cast.c 2011-09-04 22:21:58 UTC
(rev 316120)
+++ php/php-src/branches/PHP_5_3/main/streams/cast.c 2011-09-04 22:36:33 UTC
(rev 316121)
@@ -271,15 +271,15 @@
newstream = php_stream_fopen_tmpfile();
if (newstream) {
- size_t retval =
php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL);
+ size_t retcopy =
php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL);
- if (ret != SUCCESS) {
+ if (retcopy != SUCCESS) {
php_stream_close(newstream);
} else {
- int retcode =
php_stream_cast(newstream, castas | flags, (void **)ret, show_err);
+ int retcast =
php_stream_cast(newstream, castas | flags, (void **)ret, show_err);
- if (retcode == SUCCESS) {
- rewind(*(FILE**)retval);
+ if (retcast == SUCCESS) {
+ rewind(*(FILE**)ret);
}
/* do some specialized cleanup */
@@ -287,7 +287,9 @@
php_stream_free(stream,
PHP_STREAM_FREE_CLOSE_CASTED);
}
- return retcode;
+ /* TODO: we probably should be setting
.stdiocast and .fclose_stdiocast or
+ * we may be leaking the FILE*. Needs
investigation, though. */
+ return retcast;
}
}
}
Modified: php/php-src/branches/PHP_5_4/main/php_streams.h
===================================================================
--- php/php-src/branches/PHP_5_4/main/php_streams.h 2011-09-04 22:21:58 UTC
(rev 316120)
+++ php/php-src/branches/PHP_5_4/main/php_streams.h 2011-09-04 22:36:33 UTC
(rev 316121)
@@ -438,7 +438,7 @@
ZEND_ATTRIBUTE_DEPRECATED
PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest,
size_t maxlen STREAMS_DC TSRMLS_DC);
#define php_stream_copy_to_stream(src, dest, maxlen)
_php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC TSRMLS_CC)
-PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest,
size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC);
+PHPAPI int _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest,
size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC);
#define php_stream_copy_to_stream_ex(src, dest, maxlen, len)
_php_stream_copy_to_stream_ex((src), (dest), (maxlen), (len) STREAMS_CC
TSRMLS_CC)
Modified: php/php-src/branches/PHP_5_4/main/streams/cast.c
===================================================================
--- php/php-src/branches/PHP_5_4/main/streams/cast.c 2011-09-04 22:21:58 UTC
(rev 316120)
+++ php/php-src/branches/PHP_5_4/main/streams/cast.c 2011-09-04 22:36:33 UTC
(rev 316121)
@@ -271,15 +271,15 @@
newstream = php_stream_fopen_tmpfile();
if (newstream) {
- size_t retval =
php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL);
+ int retcopy =
php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL);
- if (ret != SUCCESS) {
+ if (retcopy != SUCCESS) {
php_stream_close(newstream);
} else {
- int retcode =
php_stream_cast(newstream, castas | flags, (void **)ret, show_err);
+ int retcast =
php_stream_cast(newstream, castas | flags, (void **)ret, show_err);
- if (retcode == SUCCESS) {
- rewind(*(FILE**)retval);
+ if (retcast == SUCCESS) {
+ rewind(*(FILE**)ret);
}
/* do some specialized cleanup */
@@ -287,7 +287,9 @@
php_stream_free(stream,
PHP_STREAM_FREE_CLOSE_CASTED);
}
- return retcode;
+ /* TODO: we probably should be setting
.stdiocast and .fclose_stdiocast or
+ * we may be leaking the FILE*. Needs
investigation, though. */
+ return retcast;
}
}
}
Modified: php/php-src/branches/PHP_5_4/main/streams/streams.c
===================================================================
--- php/php-src/branches/PHP_5_4/main/streams/streams.c 2011-09-04 22:21:58 UTC
(rev 316120)
+++ php/php-src/branches/PHP_5_4/main/streams/streams.c 2011-09-04 22:36:33 UTC
(rev 316121)
@@ -1417,7 +1417,7 @@
}
/* Returns SUCCESS/FAILURE and sets *len to the number of bytes moved */
-PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest,
size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC)
+PHPAPI int _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest,
size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC)
{
char buf[CHUNK_SIZE];
size_t readchunk;
Modified: php/php-src/trunk/main/php_streams.h
===================================================================
--- php/php-src/trunk/main/php_streams.h 2011-09-04 22:21:58 UTC (rev
316120)
+++ php/php-src/trunk/main/php_streams.h 2011-09-04 22:36:33 UTC (rev
316121)
@@ -438,7 +438,7 @@
ZEND_ATTRIBUTE_DEPRECATED
PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest,
size_t maxlen STREAMS_DC TSRMLS_DC);
#define php_stream_copy_to_stream(src, dest, maxlen)
_php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC TSRMLS_CC)
-PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest,
size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC);
+PHPAPI int _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest,
size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC);
#define php_stream_copy_to_stream_ex(src, dest, maxlen, len)
_php_stream_copy_to_stream_ex((src), (dest), (maxlen), (len) STREAMS_CC
TSRMLS_CC)
Modified: php/php-src/trunk/main/streams/cast.c
===================================================================
--- php/php-src/trunk/main/streams/cast.c 2011-09-04 22:21:58 UTC (rev
316120)
+++ php/php-src/trunk/main/streams/cast.c 2011-09-04 22:36:33 UTC (rev
316121)
@@ -271,15 +271,15 @@
newstream = php_stream_fopen_tmpfile();
if (newstream) {
- size_t retval =
php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL);
+ int retcopy =
php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL);
- if (ret != SUCCESS) {
+ if (retcopy != SUCCESS) {
php_stream_close(newstream);
} else {
- int retcode =
php_stream_cast(newstream, castas | flags, (void **)ret, show_err);
+ int retcast =
php_stream_cast(newstream, castas | flags, (void **)ret, show_err);
- if (retcode == SUCCESS) {
- rewind(*(FILE**)retval);
+ if (retcast == SUCCESS) {
+ rewind(*(FILE**)ret);
}
/* do some specialized cleanup */
@@ -287,7 +287,9 @@
php_stream_free(stream,
PHP_STREAM_FREE_CLOSE_CASTED);
}
- return retcode;
+ /* TODO: we probably should be setting
.stdiocast and .fclose_stdiocast or
+ * we may be leaking the FILE*. Needs
investigation, though. */
+ return retcast;
}
}
}
Modified: php/php-src/trunk/main/streams/streams.c
===================================================================
--- php/php-src/trunk/main/streams/streams.c 2011-09-04 22:21:58 UTC (rev
316120)
+++ php/php-src/trunk/main/streams/streams.c 2011-09-04 22:36:33 UTC (rev
316121)
@@ -1417,7 +1417,7 @@
}
/* Returns SUCCESS/FAILURE and sets *len to the number of bytes moved */
-PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest,
size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC)
+PHPAPI int _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest,
size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC)
{
char buf[CHUNK_SIZE];
size_t readchunk;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php