cvs: php4 / NEWS /ext/standard file.c

From: Date: Mon, 26 Jun 2000 20:52:04 +0000
Subject: cvs: php4 / NEWS /ext/standard file.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-497@lists.php.net to get a copy of this message
zeev Mon Jun 26 13:52:04 2000 EDT Modified files: /php4 NEWS /php4/ext/standard file.c Log: Removed 8KB limit on line length of the file() function Index: php4/NEWS diff -u php4/NEWS:1.325 php4/NEWS:1.326 --- php4/NEWS:1.325 Mon Jun 26 11:27:12 2000 +++ php4/NEWS Mon Jun 26 13:52:04 2000 @@ -2,6 +2,7 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 28 Jun 2000, Version 4.0.1 +- Removed 8KB limit on line length of the file() function (Zeev) - Disabled dl() when PHP is being used as a module inside a multithreaded web server - it didn't work before, and caused weird results (Zeev) - Added the ImageColorClosestHWB(), ImageCopyMerge() and ImagePaletteCopy() Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.94 php4/ext/standard/file.c:1.95 --- php4/ext/standard/file.c:1.94 Mon Jun 26 10:57:46 2000 +++ php4/ext/standard/file.c Mon Jun 26 13:52:04 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.94 2000/06/26 17:57:46 eschmid Exp $ */ +/* $Id: file.c,v 1.95 2000/06/26 20:52:04 zeev Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -482,14 +482,18 @@ /* {{{ proto array file(string filename [, int use_include_path]) Read entire file into an array */ +#define PHP_FILE_BUF_SIZE 80 + PHP_FUNCTION(file) { pval **filename, **arg2; FILE *fp; - char *slashed, buf[8192]; + char *slashed, *target_buf; register int i=0; int use_include_path = 0; int issock=0, socketd=0; + int target_len, len; + zend_bool reached_eof=0; PLS_FETCH(); /* check args */ @@ -528,16 +532,42 @@ } /* Now loop through the file and do the magic quotes thing if needed */ - memset(buf,0,8191); - while (FP_FGETS(buf,8191,socketd,fp,issock) != NULL) { + target_len = 0; + target_buf = NULL; + while (1) { + if (!target_buf) { + target_buf = (char *) emalloc(PHP_FILE_BUF_SIZE+1); + target_buf[PHP_FILE_BUF_SIZE] = 0; /* avoid overflows */ + } else { + target_buf = (char *) erealloc(target_buf, target_len+PHP_FILE_BUF_SIZE+1); + target_buf[target_len+PHP_FILE_BUF_SIZE] = 0; /* avoid overflows */ + } + if (FP_FGETS(target_buf+target_len, PHP_FILE_BUF_SIZE, socketd, fp, issock)==NULL) { + if (target_len==0) { + efree(target_buf); + break; + } else { + reached_eof = 1; + } + } + if (!reached_eof) { + target_len += strlen(target_buf+target_len); + if (target_buf[target_len-1]!='\n') { + continue; + } + } if (PG(magic_quotes_runtime)) { - int len; - - slashed = php_addslashes(buf,0,&len,0); /* 0 = don't free source string */ + slashed = php_addslashes(target_buf, target_len, &len, 1); /* 1 = free source string */ add_index_stringl(return_value, i++, slashed, len, 0); } else { - add_index_string(return_value, i++, buf, 1); + target_buf = erealloc(target_buf, target_len+1); /* do we really want to do that? */ + add_index_stringl(return_value, i++, target_buf, target_len, 0); + } + if (reached_eof) { + break; } + target_buf = NULL; + target_len = 0; } if (issock) { SOCK_FCLOSE(socketd);

« previous php.cvs (#497) next »