cvs: php-src / NEWS /ext/standard file.c
| From: | Ilia Alshanetsky | Date: | Tue, 08 Feb 2005 15:25:45 +0000 |
| Subject: | cvs: php-src / NEWS /ext/standard file.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-30322@lists.php.net to get a copy of this message | ||
iliaa Tue Feb 8 10:25:45 2005 EDT
Modified files:
/php-src NEWS
/php-src/ext/standard file.c
Log:
Added optional maxlen parameter to file_get_contents().
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1839&r2=1.1840&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1839 php-src/NEWS:1.1840
--- php-src/NEWS:1.1839 Tue Feb 8 08:40:36 2005
+++ php-src/NEWS Tue Feb 8 10:25:43 2005
@@ -31,6 +31,7 @@
- Added sqlite_fetch_column_types() 3rd argument for arrays. (Ilia)
- Added optional offset parameter to stream_get_contents() and
file_get_contents(). (Ilia)
+- Added optional maxlen parameter to file_get_contents(). (Ilia)
- Added SAPI hook to get the current request time. (Rasmus)
- Added new functions:
. array_diff_key() (Andrey)
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.396&r2=1.397&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.396 php-src/ext/standard/file.c:1.397
--- php-src/ext/standard/file.c:1.396 Sun Feb 6 18:05:24 2005
+++ php-src/ext/standard/file.c Tue Feb 8 10:25:45 2005
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.396 2005/02/06 23:05:24 wez Exp $ */
+/* $Id: file.c,v 1.397 2005/02/08 15:25:45 iliaa Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -506,7 +506,7 @@
/* }}} */
-/* {{{ proto string file_get_contents(string filename [, bool use_include_path [, resource context
[, long offset]]])
+/* {{{ proto string file_get_contents(string filename [, bool use_include_path [, resource context
[, long offset [, long maxlen]]]])
Read the entire file into a string */
PHP_FUNCTION(file_get_contents)
{
@@ -517,12 +517,13 @@
php_stream *stream;
int len, newlen;
long offset = -1;
+ long maxlen = PHP_STREAM_COPY_ALL;
zval *zcontext = NULL;
php_stream_context *context = NULL;
/* Parse arguments */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|br!l",
- &filename, &filename_len, &use_include_path, &zcontext, &offset) ==
FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|br!ll",
+ &filename, &filename_len, &use_include_path, &zcontext, &offset,
&maxlen) == FAILURE) {
return;
}
@@ -541,7 +542,7 @@
}
/* uses mmap if possible */
- if ((len = php_stream_copy_to_mem(stream, &contents, PHP_STREAM_COPY_ALL, 0)) > 0) {
+ if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {
if (PG(magic_quotes_runtime)) {
contents = php_addslashes(contents, len, &newlen, 1 TSRMLS_CC); /* 1 = free source string */