cvs: php4 /ext/standard file.c
| From: | Sterling Hughes | Date: | Tue, 04 Dec 2001 19:40:48 +0000 |
| Subject: | cvs: php4 /ext/standard file.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-8422@lists.php.net to get a copy of this message | ||
sterling Tue Dec 4 14:40:48 2001 EDT
Modified files:
/php4/ext/standard file.c
Log:
Make the length parameter to fgets optional (defaults to 1024)
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.195 php4/ext/standard/file.c:1.196
--- php4/ext/standard/file.c:1.195 Sat Nov 17 22:34:23 2001
+++ php4/ext/standard/file.c Tue Dec 4 14:40:48 2001
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.195 2001/11/18 03:34:23 sniper Exp $ */
+/* $Id: file.c,v 1.196 2001/12/04 19:40:48 sterling Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -966,26 +966,29 @@
/* }}} */
-/* {{{ proto string fgets(resource fp, int length)
+/* {{{ proto string fgets(resource fp[, int length])
Get a line from file pointer */
PHP_FUNCTION(fgets)
{
zval **arg1, **arg2;
- int len, type;
+ int len = 1024, type;
char *buf;
int issock=0;
int socketd=0;
void *what;
+ int argc = ZEND_NUM_ARGS();
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
+ if (argc<1 || argc>2 || zend_get_parameters_ex(argc, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
what = zend_fetch_resource(arg1 TSRMLS_CC, -1, "File-Handle", &type, 4, le_fopen,
le_popen, le_socket, le_stream);
ZEND_VERIFY_RESOURCE(what);
- convert_to_long_ex(arg2);
- len = Z_LVAL_PP(arg2);
+ if (argc>1) {
+ convert_to_long_ex(arg2);
+ len = Z_LVAL_PP(arg2);
+ }
if (len < 0) {
php_error(E_WARNING, "length parameter to fgets() may not be negative");