[PHP-CVS] cvs: php4 / NEWS /ext/standard config.m4 file.c
sasha Sun Mar 11 02:08:28 2001 EDT Modified files: /php4 NEWS /php4/ext/standard config.m4 file.c Log: Fixed a compatibility problem is some file functions (fgets, fputs, fread, fwrite). The ANSI standard says that if a file is opened in read/write mode, fseek() should be called before switching from reading to writing and vice versa. Index: php4/NEWS diff -u php4/NEWS:1.608 php4/NEWS:1.609 --- php4/NEWS:1.608 Fri Mar 9 18:09:25 2001 +++ php4/NEWS Sun Mar 11 02:08:27 2001 @@ -2,6 +2,10 @@ ||| ?? ??? 200?, Version 4.0.5 +- Fixed a compatibility problem in some file functions (fgets, fputs, fread, + fwrite). The ANSI standard says that if a file is opened in read/write + mode, fseek() should be called before switching from reading to writing + and vice versa. ([EMAIL PROTECTED]) - Fixed argument checking for call_user_func* functions and allowed specifying array($obj, 'method') syntax for call_user_func_array. (Andrei) - Fixed parent::method() to also work with runtime bindings (Zeev, Zend Engine) Index: php4/ext/standard/config.m4 diff -u php4/ext/standard/config.m4:1.26 php4/ext/standard/config.m4:1.27 --- php4/ext/standard/config.m4:1.26Tue Jan 9 07:11:23 2001 +++ php4/ext/standard/config.m4 Sun Mar 11 02:08:27 2001 @@ -1,8 +1,59 @@ -dnl $Id: config.m4,v 1.26 2001/01/09 15:11:23 hirokawa Exp $ -*- sh -*- +dnl $Id: config.m4,v 1.27 2001/03/11 10:08:27 sasha Exp $ -*- sh -*- divert(3)dnl dnl +dnl Check if flush should be called explicitly after buffered io +dnl +AC_DEFUN(AC_FLUSH_IO,[ + AC_CACHE_CHECK([whether flush should be called explicitly after a bufferered io], +ac_cv_flush_io,[ + AC_TRY_RUN( [ +#include +#include + +int main(int argc, char **argv) +{ + char *filename = tmpnam(NULL); + char buffer[64]; + int result = 0; + + FILE *fp = fopen(filename, "wb"); + if (NULL == fp) + return 0; + fputs("line 1\n", fp); + fputs("line 2\n", fp); + fclose(fp); + + fp = fopen(filename, "rb+"); + if (NULL == fp) + return 0; + fgets(buffer, sizeof(buffer), fp); + fputs("line 3\n", fp); + rewind(fp); + fgets(buffer, sizeof(buffer), fp); + if (0 != strcmp(buffer, "line 1\n")) + result = 1; + fgets(buffer, sizeof(buffer), fp); + if (0 != strcmp(buffer, "line 3\n")) + result = 1; + fclose(fp); + unlink(filename); + + exit(result); +} +],[ + ac_cv_flush_io="no" +],[ + ac_cv_flush_io="yes" +],[ + ac_cv_flush_io="no" +])]) + if test "$ac_cv_flush_io" = "yes"; then +AC_DEFINE(HAVE_FLUSHIO, 1, [Define if flush should be called explicitly after a +buffered io.]) + fi +]) + +dnl dnl Check for crypt() capabilities dnl AC_DEFUN(AC_CRYPT_CAP,[ @@ -143,6 +194,7 @@ AC_CHECK_FUNCS(getcwd getwd) AC_CRYPT_CAP +AC_FLUSH_IO divert(5)dnl Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.147 php4/ext/standard/file.c:1.148 --- php4/ext/standard/file.c:1.147 Mon Mar 5 20:42:04 2001 +++ php4/ext/standard/file.cSun Mar 11 02:08:27 2001 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: file.c,v 1.147 2001/03/06 04:42:04 elixer Exp $ */ +/* $Id: file.c,v 1.148 2001/03/11 10:08:27 sasha Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -918,6 +918,11 @@ buf = emalloc(sizeof(char) * (len + 1)); /* needed because recv doesnt put a null at the end*/ memset(buf,0,len+1); +#ifdef HAVE_FLUSHIO + if (!issock) { + fseek((FILE*)what, 0, SEEK_CUR); + } +#endif if (FP_FGETS(buf, len, socketd, (FILE*)what, issock) == NULL) { efree(buf); RETVAL_FALSE; @@ -961,6 +966,11 @@ socketd=*(int*)what; } +#ifdef HAVE_FLUSHIO + if (!issock) { + fseek((FILE*)what, 0, SEEK_CUR); + } +#endif buf = emalloc(sizeof(int)); if ((result = FP_FGETC(socketd, (FILE*)what, issock)) == EOF) { efree(buf); @@ -1159,6 +1169,9 @@ if (issock){ ret = SOCK_WRITEL((*arg2)->value.str.val,num_bytes,socketd); } else { +#ifdef HAVE_FLUSHIO + fseek((FILE*)what, 0, SEEK_CUR); +#endif ret = fwrite((*arg2)->value.str.val,1,num_bytes,(FILE*)what); } RETURN_LONG(ret); @@ -1794,6 +1807,9 @@ /* needed because recv doesnt put a null at the end*/ if (!issock) { +#ifdef HAVE_FLUSHIO + fseek((FILE*)what, 0, SEEK_CUR); +#endif return_value->value.str.len = fread(return_value->value.str.val, 1, len, (FILE*)what); return_value->value.str.val[return_value->value.str.len] = 0; } else { -- PHP
[PHP-CVS] cvs: php4 /ext/gd gd.c
sasha Mon Mar 12 05:57:53 2001 EDT Modified files: /php4/ext/gdgd.c Log: A small fix to make the function imageloadfont portable. Index: php4/ext/gd/gd.c diff -u php4/ext/gd/gd.c:1.117 php4/ext/gd/gd.c:1.118 --- php4/ext/gd/gd.c:1.117 Sun Feb 25 22:06:56 2001 +++ php4/ext/gd/gd.cMon Mar 12 05:57:53 2001 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.117 2001/02/26 06:06:56 andi Exp $ */ +/* $Id: gd.c,v 1.118 2001/03/12 13:57:53 sasha Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -371,13 +371,15 @@ #endif +#define FLIPWORD(a) (((a & 0xff00) >> 24) | ((a & 0x00ff) >> 8) | ((a & +0xff00) << 8) | ((a & 0x00ff) << 24)) + /* {{{ proto int imageloadfont(string filename) Load a new font */ PHP_FUNCTION(imageloadfont) { zval **file; int hdr_size = sizeof(gdFont) - sizeof(char *); - int ind, body_size, n=0, b; + int ind, body_size, n=0, b, i, body_size_check; gdFontPtr font; FILE *fp; int issock=0, socketd=0; @@ -425,7 +427,23 @@ } RETURN_FALSE; } + i = ftell(fp); + fseek(fp, 0, SEEK_END); + body_size_check = ftell(fp) - hdr_size; + fseek(fp, i, SEEK_SET); body_size = font->w * font->h * font->nchars; + if (body_size != body_size_check) { + font->w = FLIPWORD(font->w); + font->h = FLIPWORD(font->h); + font->nchars = FLIPWORD(font->nchars); + body_size = font->w * font->h * font->nchars; + } + if (body_size != body_size_check) { + php_error(E_WARNING, "ImageFontLoad: error reading font"); + efree(font); + RETURN_FALSE; + } + font->data = emalloc(body_size); b = 0; while (b < body_size && (n = fread(&font->data[b], 1, body_size - b, fp))) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-CVS] cvs: php4 / NEWS
sasha Mon Mar 12 06:07:36 2001 EDT Modified files: /php4 NEWS Log: Added NEWS. Index: php4/NEWS diff -u php4/NEWS:1.609 php4/NEWS:1.610 --- php4/NEWS:1.609 Sun Mar 11 02:08:27 2001 +++ php4/NEWS Mon Mar 12 06:07:36 2001 @@ -2,6 +2,8 @@ ||| ?? ??? 200?, Version 4.0.5 +- The imageloadfont function of the gd extension should be not platform + dependent after this fix. ([EMAIL PROTECTED]) - Fixed a compatibility problem in some file functions (fgets, fputs, fread, fwrite). The ANSI standard says that if a file is opened in read/write mode, fseek() should be called before switching from reading to writing -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-CVS] cvs: php4 /ext/standard file.c
sasha Sun Apr 15 11:42:51 2001 EDT Modified files: /php4/ext/standard file.c Log: We shoud not fseek in a pipe and this caused a problem with popen and fgets on the platforms where the buffer fix was applied (Solaris, FreeBSD). Now the fseek is done only when the handle is of type fopen. Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.150 php4/ext/standard/file.c:1.151 --- php4/ext/standard/file.c:1.150 Sat Apr 7 14:46:43 2001 +++ php4/ext/standard/file.cSun Apr 15 11:42:50 2001 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: file.c,v 1.150 2001/04/07 21:46:43 sniper Exp $ */ +/* $Id: file.c,v 1.151 2001/04/15 18:42:50 sasha Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -921,7 +921,7 @@ /* needed because recv doesnt put a null at the end*/ memset(buf,0,len+1); #ifdef HAVE_FLUSHIO - if (!issock) { + if (type == le_fopen) { fseek((FILE*)what, 0, SEEK_CUR); } #endif @@ -969,7 +969,7 @@ } #ifdef HAVE_FLUSHIO - if (!issock) { + if (type == le_fopen) { fseek((FILE*)what, 0, SEEK_CUR); } #endif @@ -1172,7 +1172,9 @@ ret = SOCK_WRITEL((*arg2)->value.str.val,num_bytes,socketd); } else { #ifdef HAVE_FLUSHIO - fseek((FILE*)what, 0, SEEK_CUR); + if (type == le_fopen) { + fseek((FILE*)what, 0, SEEK_CUR); + } #endif ret = fwrite((*arg2)->value.str.val,1,num_bytes,(FILE*)what); } @@ -1814,7 +1816,9 @@ if (!issock) { #ifdef HAVE_FLUSHIO - fseek((FILE*)what, 0, SEEK_CUR); + if (type == le_fopen) + fseek((FILE*)what, 0, SEEK_CUR); + } #endif return_value->value.str.len = fread(return_value->value.str.val, 1, len, (FILE*)what); return_value->value.str.val[return_value->value.str.len] = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-CVS] cvs: php4 /ext/standard file.c
sasha Sun Apr 15 12:03:13 2001 EDT Modified files: /php4/ext/standard file.c Log: Fixed typo. Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.151 php4/ext/standard/file.c:1.152 --- php4/ext/standard/file.c:1.151 Sun Apr 15 11:42:50 2001 +++ php4/ext/standard/file.cSun Apr 15 12:03:12 2001 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: file.c,v 1.151 2001/04/15 18:42:50 sasha Exp $ */ +/* $Id: file.c,v 1.152 2001/04/15 19:03:12 sasha Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1816,7 +1816,7 @@ if (!issock) { #ifdef HAVE_FLUSHIO - if (type == le_fopen) + if (type == le_fopen) { fseek((FILE*)what, 0, SEEK_CUR); } #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-CVS] cvs: php4(PHP_4_0_5) /ext/standard file.c
sasha Tue Apr 17 14:54:30 2001 EDT Modified files: (Branch: PHP_4_0_5) /php4/ext/standard file.c Log: Merged the patch of the buffering patch as it fixes a pretty major bug. Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.148.2.1 php4/ext/standard/file.c:1.148.2.2 --- php4/ext/standard/file.c:1.148.2.1 Wed Mar 28 01:01:27 2001 +++ php4/ext/standard/file.cTue Apr 17 14:54:29 2001 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: file.c,v 1.148.2.1 2001/03/28 09:01:27 romolo Exp $ */ +/* $Id: file.c,v 1.148.2.2 2001/04/17 21:54:29 sasha Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -919,7 +919,7 @@ /* needed because recv doesnt put a null at the end*/ memset(buf,0,len+1); #ifdef HAVE_FLUSHIO - if (!issock) { + if (type == le_fopen) { fseek((FILE*)what, 0, SEEK_CUR); } #endif @@ -967,7 +967,7 @@ } #ifdef HAVE_FLUSHIO - if (!issock) { + if (type == le_fopen) { fseek((FILE*)what, 0, SEEK_CUR); } #endif @@ -1170,7 +1170,9 @@ ret = SOCK_WRITEL((*arg2)->value.str.val,num_bytes,socketd); } else { #ifdef HAVE_FLUSHIO - fseek((FILE*)what, 0, SEEK_CUR); + if (type == le_fopen) { + fseek((FILE*)what, 0, SEEK_CUR); + } #endif ret = fwrite((*arg2)->value.str.val,1,num_bytes,(FILE*)what); } @@ -1812,7 +1814,9 @@ if (!issock) { #ifdef HAVE_FLUSHIO - fseek((FILE*)what, 0, SEEK_CUR); + if (type == le_fopen) { + fseek((FILE*)what, 0, SEEK_CUR); + } #endif return_value->value.str.len = fread(return_value->value.str.val, 1, len, (FILE*)what); return_value->value.str.val[return_value->value.str.len] = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]