[PHP-CVS] cvs: php-src /ext/standard file.c
iliaa Mon May 25 13:02:55 2009 UTC Modified files: /php-src/ext/standard file.c Log: MFB: Fixed bug #48313 (fgetcsv() return empty string rather then NULL for empty rows) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.546r2=1.547diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.546 php-src/ext/standard/file.c:1.547 --- php-src/ext/standard/file.c:1.546 Thu May 21 01:39:48 2009 +++ php-src/ext/standard/file.c Mon May 25 13:02:55 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.546 2009/05/21 01:39:48 jani Exp $ */ +/* $Id: file.c,v 1.547 2009/05/25 13:02:55 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2360,6 +2360,15 @@ array_init(return_value); + while (*p == ' ' || *p == '\t') { + p++; + } + + if (*p == '\r' || *p == '\n') { + add_next_index_null(return_value); + goto end; + } + while(p e) { switch (state) { case PHP_FGETCSV_READY: @@ -2551,7 +2560,7 @@ break; } } - +end: if (stream) { efree(buffer); } @@ -2568,6 +2577,15 @@ array_init(return_value); + while (*p == ' ' || *p == '\t') { + p++; + } + + if (*p == '\r' || *p == '\n') { + add_next_index_null(return_value); + goto end; + } + while(p e) { switch (state) { case PHP_FGETCSV_READY: @@ -2756,7 +2774,7 @@ break; } } - +end: if (stream) { efree(buffer); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
janiThu May 21 01:39:49 2009 UTC Modified files: /php-src/ext/standard file.c Log: ws http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.545r2=1.546diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.545 php-src/ext/standard/file.c:1.546 --- php-src/ext/standard/file.c:1.545 Fri May 8 10:01:40 2009 +++ php-src/ext/standard/file.c Thu May 21 01:39:48 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.545 2009/05/08 10:01:40 lbarnaud Exp $ */ +/* $Id: file.c,v 1.546 2009/05/21 01:39:48 jani Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -43,60 +43,65 @@ #include sys/types.h #include sys/stat.h #include fcntl.h + #ifdef PHP_WIN32 -#include io.h -#define O_RDONLY _O_RDONLY -#include win32/param.h -#include win32/winutil.h -#include win32/fnmatch.h +# include io.h +# define O_RDONLY _O_RDONLY +# include win32/param.h +# include win32/winutil.h +# include win32/fnmatch.h #elif defined(NETWARE) -#include sys/param.h -#include sys/select.h -#ifdef USE_WINSOCK -#include novsock2.h -#else -#include sys/socket.h -#include netinet/in.h -#include netdb.h -#endif -#else -#if HAVE_SYS_PARAM_H -#include sys/param.h -#endif -#if HAVE_SYS_SELECT_H -#include sys/select.h -#endif -#if defined(NETWARE) defined(USE_WINSOCK) -#include novsock2.h +# include sys/param.h +# include sys/select.h +# ifdef USE_WINSOCK +# include novsock2.h +# else +# include sys/socket.h +# include netinet/in.h +# include netdb.h +# endif #else -#include sys/socket.h -#include netinet/in.h -#include netdb.h -#endif -#if HAVE_ARPA_INET_H -#include arpa/inet.h -#endif +# if HAVE_SYS_PARAM_H +# include sys/param.h +# endif +# if HAVE_SYS_SELECT_H +# include sys/select.h +# endif +# if defined(NETWARE) defined(USE_WINSOCK) +# include novsock2.h +# else +# include sys/socket.h +# include netinet/in.h +# include netdb.h +# endif +# if HAVE_ARPA_INET_H +# include arpa/inet.h +# endif #endif + #include ext/standard/head.h #include php_string.h #include file.h + #if HAVE_PWD_H -#ifdef PHP_WIN32 -#include win32/pwd.h -#else -#include pwd.h -#endif +# ifdef PHP_WIN32 +# include win32/pwd.h +# else +# include pwd.h +# endif #endif + #ifdef HAVE_SYS_TIME_H -#include sys/time.h +# include sys/time.h #endif + #include fsock.h #include fopen_wrappers.h #include streamsfuncs.h #include php_globals.h #ifdef HAVE_SYS_FILE_H -#include sys/file.h +# include sys/file.h #endif #if MISSING_FCLOSE_DECL @@ -104,7 +109,7 @@ #endif #ifdef HAVE_SYS_MMAN_H -#include sys/mman.h +# include sys/mman.h #endif #include scanf.h @@ -117,18 +122,18 @@ #endif #if defined(HAVE_FNMATCH) !defined(PHP_WIN32) -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include fnmatch.h +# ifndef _GNU_SOURCE +# define _GNU_SOURCE +# endif +# include fnmatch.h #endif #ifdef HAVE_WCHAR_H -#include wchar.h +# include wchar.h #endif #ifndef S_ISDIR -#define S_ISDIR(mode) (((mode)S_IFMT) == S_IFDIR) +# define S_ISDIR(mode) (((mode)S_IFMT) == S_IFDIR) #endif /* }}} */ @@ -198,7 +203,7 @@ REGISTER_LONG_CONSTANT(LOCK_UN, PHP_LOCK_UN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(LOCK_NB, PHP_LOCK_NB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT(STREAM_NOTIFY_CONNECT, PHP_STREAM_NOTIFY_CONNECT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(STREAM_NOTIFY_CONNECT, PHP_STREAM_NOTIFY_CONNECT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_NOTIFY_AUTH_REQUIRED, PHP_STREAM_NOTIFY_AUTH_REQUIRED,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_NOTIFY_AUTH_RESULT, PHP_STREAM_NOTIFY_AUTH_RESULT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_NOTIFY_MIME_TYPE_IS, PHP_STREAM_NOTIFY_MIME_TYPE_IS, CONST_CS | CONST_PERSISTENT); @@ -209,9 +214,9 @@ REGISTER_LONG_CONSTANT(STREAM_NOTIFY_COMPLETED, PHP_STREAM_NOTIFY_COMPLETED,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_NOTIFY_RESOLVE, PHP_STREAM_NOTIFY_RESOLVE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT(STREAM_NOTIFY_SEVERITY_INFO, PHP_STREAM_NOTIFY_SEVERITY_INFO,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT(STREAM_NOTIFY_SEVERITY_WARN, PHP_STREAM_NOTIFY_SEVERITY_WARN,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT(STREAM_NOTIFY_SEVERITY_ERR, PHP_STREAM_NOTIFY_SEVERITY_ERR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(STREAM_NOTIFY_SEVERITY_INFO, PHP_STREAM_NOTIFY_SEVERITY_INFO,CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(STREAM_NOTIFY_SEVERITY_WARN,
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/file bug44034.phpt
lbarnaudFri May 8 09:50:11 2009 UTC Modified files: /php-src/ext/standard file.c /php-src/ext/standard/tests/filebug44034.phpt Log: MFB5.3 fix for bug #44034 (FILE_IGNORE_NEW_LINES in file() does not work as expected when lines end in \r\n) (fixes #48175) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.542r2=1.543diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.542 php-src/ext/standard/file.c:1.543 --- php-src/ext/standard/file.c:1.542 Sun Apr 19 17:09:46 2009 +++ php-src/ext/standard/file.c Fri May 8 09:50:11 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.542 2009/04/19 17:09:46 lbarnaud Exp $ */ +/* $Id: file.c,v 1.543 2009/05/08 09:50:11 lbarnaud Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -852,11 +852,15 @@ } while ((p = u_memchr(p, eol_marker, (e-p; } else { do { - if (skip_blank_lines !(p-s)) { + int windows_eol = 0; + if (eol_marker == '\n' *(p - 1) == '\r') { + windows_eol++; + } + if (skip_blank_lines !(p-s-windows_eol)) { s = ++p; continue; } - add_index_unicodel(return_value, i++, eustrndup(s, p-s), p-s, 0); + add_index_unicodel(return_value, i++, eustrndup(s, p-s-windows_eol), p-s-windows_eol, 0); s = ++p; } while ((p = u_memchr(p, eol_marker, (e-p; } @@ -889,11 +893,15 @@ } while ((p = memchr(p, eol_marker, (e-p; } else { do { - if (skip_blank_lines !(p-s)) { + int windows_eol = 0; + if (p != target_buf eol_marker == '\n' *(p - 1) == '\r') { + windows_eol++; + } + if (skip_blank_lines !(p-s-windows_eol)) { s = ++p; continue; } - add_index_stringl(return_value, i++, estrndup(s, p-s), p-s, 0); + add_index_stringl(return_value, i++, estrndup(s, p-s-windows_eol), p-s-windows_eol, 0); s = ++p; } while ((p = memchr(p, eol_marker, (e-p; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug44034.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/file/bug44034.phpt diff -u /dev/null php-src/ext/standard/tests/file/bug44034.phpt:1.2 --- /dev/null Fri May 8 09:50:11 2009 +++ php-src/ext/standard/tests/file/bug44034.phpt Fri May 8 09:50:11 2009 @@ -0,0 +1,39 @@ +--TEST-- +Bug #44034 +--FILE-- +?php + +$urls = array(); +$urls[] = data://text/plain,foo\r\nbar\r\n; +$urls[] = data://text/plain,\r\nfoo\r\nbar\r\n; +$urls[] = data://text/plain,foo\r\nbar; + +foreach($urls as $url) { + echo strtr($url, array(\r = \\r, \n = \\n)) . \n; + var_dump(file($url, FILE_IGNORE_NEW_LINES|FILE_TEXT)); +} +? +--EXPECTF-- +data://text/plain,foo\r\nbar\r\n +array(2) { + [0]= + %unicode|string%(3) foo + [1]= + %unicode|string%(3) bar +} +data://text/plain,\r\nfoo\r\nbar\r\n +array(3) { + [0]= + %unicode|string%(0) + [1]= + %unicode|string%(3) foo + [2]= + %unicode|string%(3) bar +} +data://text/plain,foo\r\nbar +array(2) { + [0]= + %unicode|string%(3) foo + [1]= + %unicode|string%(3) bar +} -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
lbarnaudFri May 8 10:00:09 2009 UTC Modified files: /php-src/ext/standard file.c Log: Missing check http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.543r2=1.544diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.543 php-src/ext/standard/file.c:1.544 --- php-src/ext/standard/file.c:1.543 Fri May 8 09:50:11 2009 +++ php-src/ext/standard/file.c Fri May 8 10:00:09 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.543 2009/05/08 09:50:11 lbarnaud Exp $ */ +/* $Id: file.c,v 1.544 2009/05/08 10:00:09 lbarnaud Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -853,7 +853,7 @@ } else { do { int windows_eol = 0; - if (eol_marker == '\n' *(p - 1) == '\r') { + if (p != (UChar*)target_buf eol_marker == '\n' *(p - 1) == '\r') { windows_eol++; } if (skip_blank_lines !(p-s-windows_eol)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/file file_variation10.phpt
lbarnaudFri May 8 10:01:40 2009 UTC Added files: /php-src/ext/standard/tests/filefile_variation10.phpt Modified files: /php-src/ext/standard file.c Log: Fix default behavior of file() (FILE_TEXT flag is the default) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.544r2=1.545diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.544 php-src/ext/standard/file.c:1.545 --- php-src/ext/standard/file.c:1.544 Fri May 8 10:00:09 2009 +++ php-src/ext/standard/file.c Fri May 8 10:01:40 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.544 2009/05/08 10:00:09 lbarnaud Exp $ */ +/* $Id: file.c,v 1.545 2009/05/08 10:01:40 lbarnaud Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -779,7 +779,6 @@ /* {{{ proto array file(string filename [, int flags[, resource context]]) U Read entire file into an array */ -/* UTODO: Accept unicode contents */ PHP_FUNCTION(file) { zval **ppfilename; @@ -801,7 +800,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z|lr!, ppfilename, flags, zcontext) == FAILURE) { return; } - if (flags 0 || flags (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT | PHP_FILE_TEXT)) { + if (flags 0 || flags (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT | PHP_FILE_TEXT | PHP_FILE_BINARY)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, '%ld' flag is not supported, flags); RETURN_FALSE; } @@ -809,7 +808,7 @@ use_include_path = flags PHP_FILE_USE_INCLUDE_PATH; include_new_line = !(flags PHP_FILE_IGNORE_NEW_LINES); skip_blank_lines = flags PHP_FILE_SKIP_EMPTY_LINES; - text_mode = flags PHP_FILE_TEXT; + text_mode = !(flags PHP_FILE_BINARY); context = php_stream_context_from_zval(zcontext, flags PHP_FILE_NO_DEFAULT_CONTEXT); if (php_stream_path_param_encode(ppfilename, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/file_variation10.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/file/file_variation10.phpt +++ php-src/ext/standard/tests/file/file_variation10.phpt --TEST-- file(): FILE_TEXT, FILE_BINARY, and default behavior --FILE-- ?php $urls = array(); $urls[] = data://text/plain,foo\nbar\n; $urls[] = data://text/plain,\nfoo\nbar\n; $urls[] = data://text/plain,foo\nbar; foreach($urls as $url) { echo strtr($url, array(\r = \\r, \n = \\n)) . \n; var_dump(file($url, FILE_IGNORE_NEW_LINES)); var_dump(file($url, FILE_IGNORE_NEW_LINES|FILE_TEXT)); var_dump(file($url, FILE_IGNORE_NEW_LINES|FILE_BINARY)); } ? --EXPECTF-- data://text/plain,foo\nbar\n array(2) { [0]= unicode(3) foo [1]= unicode(3) bar } array(2) { [0]= unicode(3) foo [1]= unicode(3) bar } array(2) { [0]= string(3) foo [1]= string(3) bar } data://text/plain,\nfoo\nbar\n array(3) { [0]= unicode(0) [1]= unicode(3) foo [2]= unicode(3) bar } array(3) { [0]= unicode(0) [1]= unicode(3) foo [2]= unicode(3) bar } array(3) { [0]= string(0) [1]= string(3) foo [2]= string(3) bar } data://text/plain,foo\nbar array(2) { [0]= unicode(3) foo [1]= unicode(3) bar } array(2) { [0]= unicode(3) foo [1]= unicode(3) bar } array(2) { [0]= string(3) foo [1]= string(3) bar } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c streamsfuncs.c /main php_streams.h /main/streams cast.c streams.c
lbarnaudSun Apr 19 13:50:25 2009 UTC Modified files: /php-src/ext/standard file.c streamsfuncs.c /php-src/main php_streams.h /php-src/main/streams cast.c streams.c Log: MFB5.3: Fixed bug #47997 (stream_copy_to_stream returns 1 on empty streams) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.540r2=1.541diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.540 php-src/ext/standard/file.c:1.541 --- php-src/ext/standard/file.c:1.540 Thu Mar 26 20:02:28 2009 +++ php-src/ext/standard/file.c Sun Apr 19 13:50:24 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.540 2009/03/26 20:02:28 felipe Exp $ */ +/* $Id: file.c,v 1.541 2009/04/19 13:50:24 lbarnaud Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -662,7 +662,10 @@ switch (Z_TYPE_P(data)) { case IS_RESOURCE: - numchars = php_stream_copy_to_stream(srcstream, stream, PHP_STREAM_COPY_ALL); + numchars = (int) php_stream_copy_to_stream_ex(srcstream, stream, PHP_STREAM_COPY_ALL); + if ((size_t)numchars == PHP_STREAM_FAILURE) { + numchars = -1; + } break; case IS_ARRAY: if (zend_hash_num_elements(Z_ARRVAL_P(data))) { @@ -1949,7 +1952,7 @@ deststream = php_stream_open_wrapper(dest, wb, REPORT_ERRORS, NULL); if (srcstream deststream) { - ret = php_stream_copy_to_stream(srcstream, deststream, PHP_STREAM_COPY_ALL) == 0 ? FAILURE : SUCCESS; + ret = php_stream_copy_to_stream_ex(srcstream, deststream, PHP_STREAM_COPY_ALL) == PHP_STREAM_FAILURE ? FAILURE : SUCCESS; } if (srcstream) { php_stream_close(srcstream); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.136r2=1.137diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.136 php-src/ext/standard/streamsfuncs.c:1.137 --- php-src/ext/standard/streamsfuncs.c:1.136 Thu Mar 26 20:02:29 2009 +++ php-src/ext/standard/streamsfuncs.c Sun Apr 19 13:50:24 2009 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.136 2009/03/26 20:02:29 felipe Exp $ */ +/* $Id: streamsfuncs.c,v 1.137 2009/04/19 13:50:24 lbarnaud Exp $ */ #include php.h #include php_globals.h @@ -458,6 +458,7 @@ php_stream *src, *dest; zval *zsrc, *zdest; long maxlen = PHP_STREAM_COPY_ALL, pos = 0; + size_t ret; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rr|ll, zsrc, zdest, maxlen, pos) == FAILURE) { RETURN_FALSE; @@ -471,7 +472,12 @@ RETURN_FALSE; } - RETURN_LONG(php_stream_copy_to_stream(src, dest, maxlen)); + ret = php_stream_copy_to_stream_ex(src, dest, maxlen); + + if (ret == PHP_STREAM_FAILURE) { + RETURN_FALSE; + } + RETURN_LONG(ret); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.140r2=1.141diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.140 php-src/main/php_streams.h:1.141 --- php-src/main/php_streams.h:1.140Tue Mar 10 23:39:53 2009 +++ php-src/main/php_streams.h Sun Apr 19 13:50:25 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.140 2009/03/10 23:39:53 helly Exp $ */ +/* $Id: php_streams.h,v 1.141 2009/04/19 13:50:25 lbarnaud Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -525,14 +525,25 @@ * Uses mmap if the src is a plain file and at offset 0 */ #define PHP_STREAM_COPY_ALL((size_t)-1) +#define PHP_STREAM_FAILURE ((size_t)-1) + BEGIN_EXTERN_C() +ZEND_ATTRIBUTE_DEPRECATED PHPAPI size_t _php_stream_ucopy_to_stream(php_stream *src, php_stream *dest, size_t maxlen, size_t maxchars STREAMS_DC TSRMLS_DC); +ZEND_ATTRIBUTE_DEPRECATED PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC TSRMLS_DC); /* Preserve characters semantics by having maxlen refer to maxchars in a unicode context */ #define php_stream_copy_to_stream(src, dest, maxlen) ( ((src)-readbuf_type == IS_STRING) \ ? _php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC TSRMLS_CC) \ : _php_stream_ucopy_to_stream((src), (dest), -1, (maxlen) STREAMS_CC TSRMLS_CC) ) +PHPAPI size_t _php_stream_ucopy_to_stream_ex(php_stream *src, php_stream *dest, size_t maxlen, size_t maxchars STREAMS_DC TSRMLS_DC); +PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC TSRMLS_DC);
[PHP-CVS] cvs: php-src /ext/standard file.c streamsfuncs.c /main php_streams.h /main/streams cast.c streams.c
lbarnaudSun Apr 19 17:09:47 2009 UTC Modified files: /php-src/ext/standard file.c streamsfuncs.c /php-src/main php_streams.h /php-src/main/streams cast.c streams.c Log: Better fix for #47997 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.541r2=1.542diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.541 php-src/ext/standard/file.c:1.542 --- php-src/ext/standard/file.c:1.541 Sun Apr 19 13:50:24 2009 +++ php-src/ext/standard/file.c Sun Apr 19 17:09:46 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.541 2009/04/19 13:50:24 lbarnaud Exp $ */ +/* $Id: file.c,v 1.542 2009/04/19 17:09:46 lbarnaud Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -661,12 +661,15 @@ } switch (Z_TYPE_P(data)) { - case IS_RESOURCE: - numchars = (int) php_stream_copy_to_stream_ex(srcstream, stream, PHP_STREAM_COPY_ALL); - if ((size_t)numchars == PHP_STREAM_FAILURE) { + case IS_RESOURCE: { + size_t len; + if (php_stream_copy_to_stream_ex(srcstream, stream, PHP_STREAM_COPY_ALL, len) != SUCCESS) { numchars = -1; + } else { + numchars = len; } break; + } case IS_ARRAY: if (zend_hash_num_elements(Z_ARRVAL_P(data))) { zval **tmp; @@ -1952,7 +1955,7 @@ deststream = php_stream_open_wrapper(dest, wb, REPORT_ERRORS, NULL); if (srcstream deststream) { - ret = php_stream_copy_to_stream_ex(srcstream, deststream, PHP_STREAM_COPY_ALL) == PHP_STREAM_FAILURE ? FAILURE : SUCCESS; + ret = php_stream_copy_to_stream_ex(srcstream, deststream, PHP_STREAM_COPY_ALL, NULL); } if (srcstream) { php_stream_close(srcstream); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.137r2=1.138diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.137 php-src/ext/standard/streamsfuncs.c:1.138 --- php-src/ext/standard/streamsfuncs.c:1.137 Sun Apr 19 13:50:24 2009 +++ php-src/ext/standard/streamsfuncs.c Sun Apr 19 17:09:46 2009 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.137 2009/04/19 13:50:24 lbarnaud Exp $ */ +/* $Id: streamsfuncs.c,v 1.138 2009/04/19 17:09:46 lbarnaud Exp $ */ #include php.h #include php_globals.h @@ -458,7 +458,8 @@ php_stream *src, *dest; zval *zsrc, *zdest; long maxlen = PHP_STREAM_COPY_ALL, pos = 0; - size_t ret; + size_t len; + int ret; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rr|ll, zsrc, zdest, maxlen, pos) == FAILURE) { RETURN_FALSE; @@ -472,12 +473,12 @@ RETURN_FALSE; } - ret = php_stream_copy_to_stream_ex(src, dest, maxlen); + ret = php_stream_copy_to_stream_ex(src, dest, maxlen, len); - if (ret == PHP_STREAM_FAILURE) { + if (ret != SUCCESS) { RETURN_FALSE; } - RETURN_LONG(ret); + RETURN_LONG(len); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.141r2=1.142diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.141 php-src/main/php_streams.h:1.142 --- php-src/main/php_streams.h:1.141Sun Apr 19 13:50:25 2009 +++ php-src/main/php_streams.h Sun Apr 19 17:09:46 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.141 2009/04/19 13:50:25 lbarnaud Exp $ */ +/* $Id: php_streams.h,v 1.142 2009/04/19 17:09:46 lbarnaud Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -525,8 +525,6 @@ * Uses mmap if the src is a plain file and at offset 0 */ #define PHP_STREAM_COPY_ALL((size_t)-1) -#define PHP_STREAM_FAILURE ((size_t)-1) - BEGIN_EXTERN_C() ZEND_ATTRIBUTE_DEPRECATED PHPAPI size_t _php_stream_ucopy_to_stream(php_stream *src, php_stream *dest, size_t maxlen, size_t maxchars STREAMS_DC TSRMLS_DC); @@ -537,12 +535,12 @@ ? _php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC TSRMLS_CC) \ : _php_stream_ucopy_to_stream((src), (dest), -1, (maxlen) STREAMS_CC TSRMLS_CC) ) -PHPAPI size_t _php_stream_ucopy_to_stream_ex(php_stream *src, php_stream *dest, size_t maxlen, size_t maxchars STREAMS_DC TSRMLS_DC); -PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC TSRMLS_DC); +PHPAPI size_t
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/file fnmatch_basic.phpt fnmatch_error.phpt fnmatch_variation.phpt
pajoye Tue Jan 20 01:41:19 2009 UTC Modified files: /php-src/ext/standard file.c /php-src/ext/standard/tests/filefnmatch_basic.phpt fnmatch_error.phpt fnmatch_variation.phpt Log: - MFB - [DOC] add support for fnmatch() on Windows - enable tests (pass) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.537r2=1.538diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.537 php-src/ext/standard/file.c:1.538 --- php-src/ext/standard/file.c:1.537 Fri Jan 9 22:50:45 2009 +++ php-src/ext/standard/file.c Tue Jan 20 01:41:18 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.537 2009/01/09 22:50:45 tony2001 Exp $ */ +/* $Id: file.c,v 1.538 2009/01/20 01:41:18 pajoye Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -48,6 +48,7 @@ #define O_RDONLY _O_RDONLY #include win32/param.h #include win32/winutil.h +#include win32/fnmatch.h #elif defined(NETWARE) #include sys/param.h #include sys/select.h @@ -115,7 +116,7 @@ php_file_globals file_globals; #endif -#ifdef HAVE_FNMATCH +#if defined(HAVE_FNMATCH) !defined(PHP_WIN32) #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fnmatch_basic.phpt?r1=1.6r2=1.7diff_format=u Index: php-src/ext/standard/tests/file/fnmatch_basic.phpt diff -u php-src/ext/standard/tests/file/fnmatch_basic.phpt:1.6 php-src/ext/standard/tests/file/fnmatch_basic.phpt:1.7 --- php-src/ext/standard/tests/file/fnmatch_basic.phpt:1.6 Tue Oct 21 13:38:57 2008 +++ php-src/ext/standard/tests/file/fnmatch_basic.phpt Tue Jan 20 01:41:19 2009 @@ -2,9 +2,6 @@ Test fnmatch() function: Basic functionality --SKIPIF-- ?php -if (substr(PHP_OS, 0, 3) == 'WIN') -die(skip do not run on Windows); - if (!function_exists('fnmatch')) die(skip fnmatch() function is not available); ? http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fnmatch_error.phpt?r1=1.6r2=1.7diff_format=u Index: php-src/ext/standard/tests/file/fnmatch_error.phpt diff -u php-src/ext/standard/tests/file/fnmatch_error.phpt:1.6 php-src/ext/standard/tests/file/fnmatch_error.phpt:1.7 --- php-src/ext/standard/tests/file/fnmatch_error.phpt:1.6 Tue Oct 21 13:38:57 2008 +++ php-src/ext/standard/tests/file/fnmatch_error.phpt Tue Jan 20 01:41:19 2009 @@ -2,9 +2,6 @@ Test fnmatch() function: Error conditions --SKIPIF-- ?php -if (substr(PHP_OS, 0, 3) == 'WIN') -die(skip do not run on Windows); - if (!function_exists('fnmatch')) die(skip fnmatch() function is not available); ? http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fnmatch_variation.phpt?r1=1.6r2=1.7diff_format=u Index: php-src/ext/standard/tests/file/fnmatch_variation.phpt diff -u php-src/ext/standard/tests/file/fnmatch_variation.phpt:1.6 php-src/ext/standard/tests/file/fnmatch_variation.phpt:1.7 --- php-src/ext/standard/tests/file/fnmatch_variation.phpt:1.6 Tue Oct 21 13:38:57 2008 +++ php-src/ext/standard/tests/file/fnmatch_variation.phpt Tue Jan 20 01:41:19 2009 @@ -2,9 +2,6 @@ Test fnmatch() function: Variations --SKIPIF-- ?php -if (substr(PHP_OS, 0, 3) == 'WIN') -die(skip do not run on Windows); - if (!function_exists('fnmatch')) die(skip fnmatch() function is not available); ? @@ -18,6 +15,11 @@ echo *** Testing fnmatch() with file and various patterns ***\n; $file_name = dirname(__FILE__)./match.tmp; +/* avoid using \, it breaks the pattern */ +if (substr(PHP_OS, 0, 3) == 'WIN') { +$file_name = str_replace('\\','/', $file_name); +} + fopen($file_name, w); $pattern_arr = array( -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c ftp_fopen_wrapper.c mail.c php_string.h string.c
tony2001Fri Jan 9 18:23:45 2009 UTC Modified files: /php-src/ext/standard file.c ftp_fopen_wrapper.c mail.c string.c php_string.h Log: change functions to be consistent between branches http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.535r2=1.536diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.535 php-src/ext/standard/file.c:1.536 --- php-src/ext/standard/file.c:1.535 Wed Dec 31 11:12:36 2008 +++ php-src/ext/standard/file.c Fri Jan 9 18:23:45 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.535 2008/12/31 11:12:36 sebastian Exp $ */ +/* $Id: file.c,v 1.536 2009/01/09 18:23:45 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -911,17 +911,18 @@ { zval **ppdir, **ppprefix; char *dir, *prefix; - int dir_len, prefix_len, p_len; + int dir_len; char *opened_path; char *p; int fd; + size_t p_len, prefix_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ZZ, ppdir, ppprefix) == FAILURE) { return; } if (php_stream_path_param_encode(ppdir, dir, dir_len, REPORT_ERRORS, FG(default_context)) == FAILURE || - php_stream_path_param_encode(ppprefix, prefix, prefix_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { + php_stream_path_param_encode(ppprefix, prefix, (int *)prefix_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { RETURN_FALSE; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.104r2=1.105diff_format=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.104 php-src/ext/standard/ftp_fopen_wrapper.c:1.105 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.104 Wed Dec 31 11:12:36 2008 +++ php-src/ext/standard/ftp_fopen_wrapper.cFri Jan 9 18:23:45 2009 @@ -18,7 +18,7 @@ | Sara Golemon poll...@php.net | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.104 2008/12/31 11:12:36 sebastian Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.105 2009/01/09 18:23:45 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -592,7 +592,7 @@ php_stream *innerstream = (php_stream *)stream-abstract; size_t tmp_len; char *basename; - int basename_len; + size_t basename_len; if (count != sizeof(php_stream_dirent)) { return 0; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/mail.c?r1=1.102r2=1.103diff_format=u Index: php-src/ext/standard/mail.c diff -u php-src/ext/standard/mail.c:1.102 php-src/ext/standard/mail.c:1.103 --- php-src/ext/standard/mail.c:1.102 Fri Jan 9 16:33:57 2009 +++ php-src/ext/standard/mail.c Fri Jan 9 18:23:45 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: mail.c,v 1.102 2009/01/09 16:33:57 tony2001 Exp $ */ +/* $Id: mail.c,v 1.103 2009/01/09 18:23:45 tony2001 Exp $ */ #include stdlib.h #include ctype.h @@ -227,7 +227,7 @@ char *f; size_t f_len; - php_basename(tmp, strlen(tmp), NULL, 0,f, f_len TSRMLS_CC); + php_basename(tmp, strlen(tmp), NULL, 0, f, f_len TSRMLS_CC); if (headers != NULL) { spprintf(hdr, 0, %s\r\nX-PHP-Originating-Script: %ld:%s\n, headers, php_getuid(), f); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.689r2=1.690diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.689 php-src/ext/standard/string.c:1.690 --- php-src/ext/standard/string.c:1.689 Wed Dec 31 11:12:37 2008 +++ php-src/ext/standard/string.c Fri Jan 9 18:23:45 2009 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.689 2008/12/31 11:12:37 sebastian Exp $ */ +/* $Id: string.c,v 1.690 2009/01/09 18:23:45 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1847,7 +1847,7 @@ /* {{{ php_u_basename */ -PHPAPI void php_u_basename(UChar *s, int len, UChar *suffix, int sufflen, UChar **p_ret, int *p_len TSRMLS_DC) +PHPAPI void php_u_basename(UChar *s, size_t len, UChar *suffix, size_t sufflen, UChar **p_ret, size_t *p_len TSRMLS_DC) { UChar *end, *c, *comp, *cend; int state; @@ -1895,7 +1895,7 @@ /* {{{ php_basename */ -PHPAPI void php_basename(char *s, int len, char *suffix, int sufflen, char **p_ret, int *p_len TSRMLS_DC) +PHPAPI void php_basename(char *s, size_t len, char *suffix, size_t sufflen, char **p_ret, size_t *p_len TSRMLS_DC) { char *ret = NULL, *c, *comp, *cend; size_t
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Fri Jan 9 22:50:45 2009 UTC Modified files: /php-src/ext/standard file.c Log: use temp var instead of wrong typecast http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.536r2=1.537diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.536 php-src/ext/standard/file.c:1.537 --- php-src/ext/standard/file.c:1.536 Fri Jan 9 18:23:45 2009 +++ php-src/ext/standard/file.c Fri Jan 9 22:50:45 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.536 2009/01/09 18:23:45 tony2001 Exp $ */ +/* $Id: file.c,v 1.537 2009/01/09 22:50:45 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -911,7 +911,7 @@ { zval **ppdir, **ppprefix; char *dir, *prefix; - int dir_len; + int dir_len, tmp_prefix_len; char *opened_path; char *p; int fd; @@ -922,7 +922,7 @@ } if (php_stream_path_param_encode(ppdir, dir, dir_len, REPORT_ERRORS, FG(default_context)) == FAILURE || - php_stream_path_param_encode(ppprefix, prefix, (int *)prefix_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { + php_stream_path_param_encode(ppprefix, prefix, tmp_prefix_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { RETURN_FALSE; } @@ -930,6 +930,7 @@ RETURN_FALSE; } + prefix_len = tmp_prefix_len; php_basename(prefix, prefix_len, NULL, 0, p, p_len TSRMLS_CC); if (p_len 64) { p[63] = '\0'; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
colder Sat Dec 20 00:51:00 2008 UTC Modified files: /php-src/ext/standard file.c Log: Fix #46636 (segfault in SplFileinfo::fgetcsv()) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.533r2=1.534diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.533 php-src/ext/standard/file.c:1.534 --- php-src/ext/standard/file.c:1.533 Fri Dec 12 12:40:58 2008 +++ php-src/ext/standard/file.c Sat Dec 20 00:51:00 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.533 2008/12/12 12:40:58 bjori Exp $ */ +/* $Id: file.c,v 1.534 2008/12/20 00:51:00 colder Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2265,7 +2265,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char escape, size_t buf_len, char *buf, zval *return_value TSRMLS_DC) /* {{{ */ { - char *delim = delimiter, *enc = enclosure, *buffer = buf, *esc; + char *delim = delimiter, *enc = enclosure, *buffer = buf, *esc = escape; int delim_len = 1, enc_len = 1, esc_len = 1, buffer_len = buf_len; zend_uchar type = IS_STRING; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/file mkdir_rmdir_variation2.phpt mkdir_variation1-win32.phpt mkdir_variation1.phpt mkdir_variation5.phpt
bjori Fri Dec 12 12:40:59 2008 UTC Modified files: /php-src/ext/standard file.c /php-src/ext/standard/tests/filemkdir_variation1.phpt mkdir_variation1-win32.phpt mkdir_variation5.phpt mkdir_rmdir_variation2.phpt Log: Fixed bug#46681 (mkdir() fails silently on PHP 5.3) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.532r2=1.533diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.532 php-src/ext/standard/file.c:1.533 --- php-src/ext/standard/file.c:1.532 Wed Nov 26 04:18:24 2008 +++ php-src/ext/standard/file.c Fri Dec 12 12:40:58 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.532 2008/11/26 04:18:24 lbarnaud Exp $ */ +/* $Id: file.c,v 1.533 2008/12/12 12:40:58 bjori Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1498,7 +1498,7 @@ return -1; } - if ((ret = VCWD_MKDIR(dir, (mode_t)mode)) 0 (options REPORT_ERRORS) == 1) { + if ((ret = VCWD_MKDIR(dir, (mode_t)mode)) 0 (options REPORT_ERRORS)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, %s, strerror(errno)); } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/mkdir_variation1.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/standard/tests/file/mkdir_variation1.phpt diff -u php-src/ext/standard/tests/file/mkdir_variation1.phpt:1.2 php-src/ext/standard/tests/file/mkdir_variation1.phpt:1.3 --- php-src/ext/standard/tests/file/mkdir_variation1.phpt:1.2 Wed Nov 26 17:48:41 2008 +++ php-src/ext/standard/tests/file/mkdir_variation1.phpt Fri Dec 12 12:40:58 2008 @@ -2,7 +2,6 @@ Test mkdir() function : usage variation: try invalid pathname --CREDITS-- Dave Kelsey d_kel...@uk.ibm.com ---XFAIL-- --SKIPIF-- ?php if(substr(PHP_OS, 0, 3) == WIN) @@ -119,4 +118,4 @@ --single space-- directory created -===DONE=== \ No newline at end of file +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/mkdir_variation1-win32.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/standard/tests/file/mkdir_variation1-win32.phpt diff -u php-src/ext/standard/tests/file/mkdir_variation1-win32.phpt:1.2 php-src/ext/standard/tests/file/mkdir_variation1-win32.phpt:1.3 --- php-src/ext/standard/tests/file/mkdir_variation1-win32.phpt:1.2 Wed Nov 26 17:48:41 2008 +++ php-src/ext/standard/tests/file/mkdir_variation1-win32.phpt Fri Dec 12 12:40:58 2008 @@ -2,7 +2,6 @@ Test mkdir() function : usage variation: try invalid pathname --CREDITS-- Dave Kelsey d_kel...@uk.ibm.com ---XFAIL-- --SKIPIF-- ?php if(substr(PHP_OS, 0, 3) != WIN) @@ -120,4 +119,4 @@ --single space-- Error: 2 - mkdir(): %s, %s(%d) -===DONE=== \ No newline at end of file +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/mkdir_variation5.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/standard/tests/file/mkdir_variation5.phpt diff -u php-src/ext/standard/tests/file/mkdir_variation5.phpt:1.2 php-src/ext/standard/tests/file/mkdir_variation5.phpt:1.3 --- php-src/ext/standard/tests/file/mkdir_variation5.phpt:1.2 Wed Nov 26 17:48:40 2008 +++ php-src/ext/standard/tests/file/mkdir_variation5.phpt Fri Dec 12 12:40:58 2008 @@ -2,7 +2,6 @@ Test mkdir() function : variation: various valid and invalid paths --CREDITS-- Dave Kelsey d_kel...@uk.ibm.com ---XFAIL-- --SKIPIF-- ?php if(substr(PHP_OS, 0, 3) == WIN) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/mkdir_rmdir_variation2.phpt?r1=1.4r2=1.5diff_format=u Index: php-src/ext/standard/tests/file/mkdir_rmdir_variation2.phpt diff -u php-src/ext/standard/tests/file/mkdir_rmdir_variation2.phpt:1.4 php-src/ext/standard/tests/file/mkdir_rmdir_variation2.phpt:1.5 --- php-src/ext/standard/tests/file/mkdir_rmdir_variation2.phpt:1.4 Tue May 27 09:34:54 2008 +++ php-src/ext/standard/tests/file/mkdir_rmdir_variation2.phpt Fri Dec 12 12:40:58 2008 @@ -70,6 +70,8 @@ *** Testing mkdir() with miscelleneous input *** bool(true) + +Warning: mkdir(): Permission denied in %sfile/mkdir_rmdir_variation2.php on line %d bool(false) bool(true) Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c flock_compat.h /ext/standard/tests/file userstreams_004.phpt /main/streams userspace.c
lbarnaudWed Nov 26 04:18:24 2008 UTC Added files: /php-src/ext/standard/tests/fileuserstreams_004.phpt Modified files: /php-src/ext/standard file.c flock_compat.h /php-src/main/streams userspace.c Log: Fixed bug #46673 (stream_lock call with wrong paramater) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.531r2=1.532diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.531 php-src/ext/standard/file.c:1.532 --- php-src/ext/standard/file.c:1.531 Tue Nov 11 00:40:04 2008 +++ php-src/ext/standard/file.c Wed Nov 26 04:18:24 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.531 2008/11/11 00:40:04 lbarnaud Exp $ */ +/* $Id: file.c,v 1.532 2008/11/26 04:18:24 lbarnaud Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -192,10 +192,10 @@ REGISTER_LONG_CONSTANT(SEEK_SET, SEEK_SET, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SEEK_CUR, SEEK_CUR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SEEK_END, SEEK_END, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT(LOCK_SH, 1, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT(LOCK_EX, 2, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT(LOCK_UN, 3, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT(LOCK_NB, 4, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(LOCK_SH, PHP_LOCK_SH, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(LOCK_EX, PHP_LOCK_EX, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(LOCK_UN, PHP_LOCK_UN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(LOCK_NB, PHP_LOCK_NB, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_NOTIFY_CONNECT, PHP_STREAM_NOTIFY_CONNECT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_NOTIFY_AUTH_REQUIRED, PHP_STREAM_NOTIFY_AUTH_REQUIRED,CONST_CS | CONST_PERSISTENT); @@ -342,7 +342,7 @@ } /* flock_values contains all possible actions if (operation 4) we won't block on the lock */ - act = flock_values[act - 1] | (operation 4 ? LOCK_NB : 0); + act = flock_values[act - 1] | (operation PHP_LOCK_NB ? LOCK_NB : 0); if (php_stream_lock(stream, act)) { if (operation errno == EWOULDBLOCK arg3 PZVAL_IS_REF(arg3)) { Z_LVAL_P(arg3) = 1; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/flock_compat.h?r1=1.24r2=1.25diff_format=u Index: php-src/ext/standard/flock_compat.h diff -u php-src/ext/standard/flock_compat.h:1.24 php-src/ext/standard/flock_compat.h:1.25 --- php-src/ext/standard/flock_compat.h:1.24Sat Aug 23 20:31:27 2008 +++ php-src/ext/standard/flock_compat.h Wed Nov 26 04:18:24 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: flock_compat.h,v 1.24 2008/08/23 20:31:27 pajoye Exp $ */ +/* $Id: flock_compat.h,v 1.25 2008/11/26 04:18:24 lbarnaud Exp $ */ #ifndef FLOCK_COMPAT_H #define FLOCK_COMPAT_H @@ -35,6 +35,12 @@ PHPAPI int flock(int fd, int operation); #endif +/* Userland LOCK_* constants */ +#define PHP_LOCK_SH 1 +#define PHP_LOCK_EX 2 +#define PHP_LOCK_UN 3 +#define PHP_LOCK_NB 4 + #ifdef PHP_WIN32 #define EWOULDBLOCK WSAEWOULDBLOCK # define fsync _commit http://cvs.php.net/viewvc.cgi/php-src/main/streams/userspace.c?r1=1.49r2=1.50diff_format=u Index: php-src/main/streams/userspace.c diff -u php-src/main/streams/userspace.c:1.49 php-src/main/streams/userspace.c:1.50 --- php-src/main/streams/userspace.c:1.49 Sat Nov 15 12:50:17 2008 +++ php-src/main/streams/userspace.cWed Nov 26 04:18:24 2008 @@ -17,11 +17,15 @@ +--+ */ -/* $Id: userspace.c,v 1.49 2008/11/15 12:50:17 lbarnaud Exp $ */ +/* $Id: userspace.c,v 1.50 2008/11/26 04:18:24 lbarnaud Exp $ */ #include php.h #include php_globals.h #include ext/standard/file.h +#include ext/standard/flock_compat.h +#ifdef HAVE_SYS_FILE_H +#include sys/file.h +#endif static int le_protocols; @@ -942,7 +946,23 @@ case PHP_STREAM_OPTION_LOCKING: MAKE_STD_ZVAL(zvalue); - ZVAL_LONG(zvalue, value); + ZVAL_LONG(zvalue, 0); + + if (value LOCK_NB) { + Z_LVAL_P(zvalue) |= PHP_LOCK_NB; + } + switch(value ~LOCK_NB) { + case LOCK_SH: + Z_LVAL_P(zvalue) |= PHP_LOCK_SH; + break; + case LOCK_EX: + Z_LVAL_P(zvalue) |= PHP_LOCK_EX; + break; + case LOCK_UN: + Z_LVAL_P(zvalue) |= PHP_LOCK_UN; +
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/file bug45585.phpt
lbarnaudTue Nov 11 00:40:05 2008 UTC Added files: /php-src/ext/standard/tests/filebug45585.phpt Modified files: /php-src/ext/standard file.c Log: Fixed bug #45585 (fread() return value for EOF inconsistent between PHP 5 and 6) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.530r2=1.531diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.530 php-src/ext/standard/file.c:1.531 --- php-src/ext/standard/file.c:1.530 Tue Oct 21 22:06:48 2008 +++ php-src/ext/standard/file.c Tue Nov 11 00:40:04 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.530 2008/10/21 22:06:48 lbarnaud Exp $ */ +/* $Id: file.c,v 1.531 2008/11/11 00:40:04 lbarnaud Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1984,19 +1984,11 @@ int buflen = len; UChar *buf = php_stream_read_unicode_chars(stream, buflen); - if (!buf) { - RETURN_FALSE; - } - RETURN_UNICODEL(buf, buflen, 0); } else { /* IS_STRING */ char *buf = emalloc(len + 1); int buflen = php_stream_read(stream, buf, len); - if (!buflen) { - efree(buf); - RETURN_FALSE; - } buf[buflen] = 0; RETURN_STRINGL(buf, buflen, 0); } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug45585.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/file/bug45585.phpt +++ php-src/ext/standard/tests/file/bug45585.phpt --TEST-- Bug #45585 (fread() return value for EOF inconsistent between PHP 5 and 6) --FILE-- ?php $fd = fopen(php://temp,w+); fwrite($fd, bfoo); fseek($fd, 0, SEEK_SET); var_dump($fd, fread($fd, 3), fread($fd, 3)); fclose($fd); ? --EXPECTF-- resource(%d) of type (stream) string(3) foo string(0) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
lbarnaudSun Sep 14 14:55:50 2008 UTC Modified files: /php-src/ext/standard file.c Log: Fix leak in fgetc() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.528r2=1.529diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.528 php-src/ext/standard/file.c:1.529 --- php-src/ext/standard/file.c:1.528 Fri Sep 12 10:30:18 2008 +++ php-src/ext/standard/file.c Sun Sep 14 14:55:50 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.528 2008/09/12 10:30:18 tony2001 Exp $ */ +/* $Id: file.c,v 1.529 2008/09/14 14:55:50 lbarnaud Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1185,6 +1185,9 @@ UChar *buf = php_stream_read_unicode_chars(stream, buflen); if (!buf || !buflen) { + if (buf) { + efree(buf); + } RETURN_FALSE; } RETURN_UNICODEL(buf, buflen, 0); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Fri Sep 12 10:30:18 2008 UTC Modified files: /php-src/ext/standard file.c Log: fix typo test before commit! http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.527r2=1.528diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.527 php-src/ext/standard/file.c:1.528 --- php-src/ext/standard/file.c:1.527 Fri Sep 12 01:10:56 2008 +++ php-src/ext/standard/file.c Fri Sep 12 10:30:18 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.527 2008/09/12 01:10:56 felipe Exp $ */ +/* $Id: file.c,v 1.528 2008/09/12 10:30:18 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2053,7 +2053,7 @@ count = zend_hash_num_elements(Z_ARRVAL_P(fields)); zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(fields), pos); - while (zend_hash_get_current_data_ex(Z_ARRVAL_P(fields), (void **) field, pos) == SUCCESS) { + while (zend_hash_get_current_data_ex(Z_ARRVAL_P(fields), (void **) field_tmp, pos) == SUCCESS) { field = **field_tmp; if (Z_TYPE_PP(field_tmp) != IS_STRING) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/file fputcsv_002.phpt
felipe Fri Sep 12 01:10:57 2008 UTC Added files: /php-src/ext/standard/tests/filefputcsv_002.phpt Modified files: /php-src/ext/standard file.c Log: - Fixed unexpected zval changes http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.526r2=1.527diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.526 php-src/ext/standard/file.c:1.527 --- php-src/ext/standard/file.c:1.526 Mon Sep 8 01:30:55 2008 +++ php-src/ext/standard/file.c Fri Sep 12 01:10:56 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.526 2008/09/08 01:30:55 felipe Exp $ */ +/* $Id: file.c,v 1.527 2008/09/12 01:10:56 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2000,7 +2000,7 @@ } /* }}} */ -#define FPUTCSV_FLD_CHK(c) memchr(Z_STRVAL_PP(field), c, Z_STRLEN_PP(field)) +#define FPUTCSV_FLD_CHK(c) memchr(Z_STRVAL(field), c, Z_STRLEN(field)) /* {{{ proto int fputcsv(resource fp, array fields [, string delimiter [, string enclosure]]) Format line as CSV and write to file pointer */ @@ -2012,7 +2012,7 @@ const char escape_char = '\\'; php_stream *stream; int ret; - zval *fp = NULL, *fields = NULL, **field = NULL; + zval *fp = NULL, *fields = NULL, **field_tmp = NULL, field; char *delimiter_str = NULL, *enclosure_str = NULL; int delimiter_str_len, enclosure_str_len; HashPosition pos; @@ -2054,10 +2054,13 @@ count = zend_hash_num_elements(Z_ARRVAL_P(fields)); zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(fields), pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(fields), (void **) field, pos) == SUCCESS) { - if (Z_TYPE_PP(field) != IS_STRING) { - SEPARATE_ZVAL(field); - convert_to_string(*field); + field = **field_tmp; + + if (Z_TYPE_PP(field_tmp) != IS_STRING) { + zval_copy_ctor(field); + convert_to_string(field); } + /* enclose a field that contains a delimiter, an enclosure character, or a newline */ if (FPUTCSV_FLD_CHK(delimiter) || FPUTCSV_FLD_CHK(enclosure) || @@ -2067,8 +2070,8 @@ FPUTCSV_FLD_CHK('\t') || FPUTCSV_FLD_CHK(' ') ) { - char *ch = Z_STRVAL_PP(field); - char *end = ch + Z_STRLEN_PP(field); + char *ch = Z_STRVAL(field); + char *end = ch + Z_STRLEN(field); int escaped = 0; smart_str_appendc(csvline, enclosure); @@ -2085,13 +2088,17 @@ } smart_str_appendc(csvline, enclosure); } else { - smart_str_appendl(csvline, Z_STRVAL_PP(field), Z_STRLEN_PP(field)); + smart_str_appendl(csvline, Z_STRVAL(field), Z_STRLEN(field)); } if (++i != count) { smart_str_appendl(csvline, delimiter, 1); } zend_hash_move_forward_ex(Z_ARRVAL_P(fields), pos); + + if (Z_TYPE_PP(field_tmp) != IS_STRING) { + zval_dtor(field); + } } smart_str_appendc(csvline, '\n'); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fputcsv_002.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/file/fputcsv_002.phpt +++ php-src/ext/standard/tests/file/fputcsv_002.phpt --TEST-- fputcsv(): Checking data after calling the function --FILE-- ?php $file = dirname(__FILE__) .'/fgetcsv-test.csv'; $data = array(1, 2, 'foo', 'haha', array(4, 5, 6), 1.3, null); $fp = fopen($file, 'w'); fputcsv($fp, $data); var_dump($data); @unlink($file); ? --EXPECTF-- Notice: Array to string conversion in %s on line %d array(7) { [0]= int(1) [1]= int(2) [2]= unicode(3) foo [3]= unicode(4) haha [4]= array(3) { [0]= int(4) [1]= int(5) [2]= int(6) } [5]= float(1.3) [6]= NULL } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/file 007_error.phpt fflush_error.phpt fgetc_error.phpt fgetss_error.phpt fseek_ftell_rewind_error1.phpt fseek_ftell_rewind_error2.phpt
felipe Tue Aug 12 19:38:05 2008 UTC Modified files: /php-src/ext/standard file.c /php-src/ext/standard/tests/file007_error.phpt fflush_error.phpt fgetc_error.phpt fgetss_error.phpt fseek_ftell_rewind_error1.phpt fseek_ftell_rewind_error2.phpt fseek_ftell_rewind_error3.phpt ftruncate_error.phpt popen_pclose_error.phpt umask_error.phpt Log: - New parameter parsing API http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.524r2=1.525diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.524 php-src/ext/standard/file.c:1.525 --- php-src/ext/standard/file.c:1.524 Mon Aug 11 13:14:01 2008 +++ php-src/ext/standard/file.c Tue Aug 12 19:38:04 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.524 2008/08/11 13:14:01 pajoye Exp $ */ +/* $Id: file.c,v 1.525 2008/08/12 19:38:04 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1007,14 +1007,14 @@ Close an open file pointer */ PHPAPI PHP_FUNCTION(fclose) { - zval **arg1; + zval *arg1; php_stream *stream; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, arg1) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, arg1) == FAILURE) { + return; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, arg1); if ((stream-flags PHP_STREAM_FLAG_NO_FCLOSE) != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, %d is not a valid stream resource, stream-rsrc_id); @@ -1081,14 +1081,14 @@ Close a file pointer opened by popen() */ PHP_FUNCTION(pclose) { - zval **arg1; + zval *arg1; php_stream *stream; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, arg1) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, arg1) == FAILURE) { + return; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, arg1); zend_list_delete(stream-rsrc_id); RETURN_LONG(FG(pclose_ret)); @@ -1099,14 +1099,14 @@ Test for end-of-file on a file pointer */ PHPAPI PHP_FUNCTION(feof) { - zval **arg1; + zval *arg1; php_stream *stream; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, arg1) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, arg1) == FAILURE) { + return; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, arg1); if (php_stream_eof(stream)) { RETURN_TRUE; @@ -1171,14 +1171,14 @@ Get a character from file pointer */ PHPAPI PHP_FUNCTION(fgetc) { - zval **arg1; + zval *arg1; php_stream *stream; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, arg1) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, arg1) == FAILURE) { + return; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, arg1); if (stream-readbuf_type == IS_UNICODE) { int buflen = 1; @@ -1285,30 +1285,19 @@ Implements a mostly ANSI compatible fscanf() */ PHP_FUNCTION(fscanf) { - int result; - zval **file_handle, **format_string; - int type; + int type, result, argc = 0; + zval ***args = NULL; + zval **format; + zval *file_handle; char *buf; UChar *u_buf; void *what; - zval ***args; - int argCount; - - argCount = ZEND_NUM_ARGS(); - if (argCount 2) { - WRONG_PARAM_COUNT; - } - args = (zval ***)safe_emalloc(argCount, sizeof(zval **), 0); - if (zend_get_parameters_array_ex(argCount, args) == FAILURE) { - efree( args ); - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rZ*, file_handle, format, args, argc) == FAILURE) { + return; } - file_handle = args[0]; - format_string = args[1]; - - what = zend_fetch_resource(file_handle TSRMLS_CC, -1, File-Handle, type, 2, php_file_le_stream(), php_file_le_pstream()); + what = zend_fetch_resource(file_handle TSRMLS_CC, -1, File-Handle, type, 2, php_file_le_stream(), php_file_le_pstream()); /* * we can't do a ZEND_VERIFY_RESOURCE(what), otherwise we end up @@ -1316,38
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/file copy_variation4-win32.phpt copy_variation4.phpt
pajoye Mon Aug 11 13:09:01 2008 UTC Removed files: /php-src/ext/standard/tests/filecopy_variation4-win32.phpt Modified files: /php-src/ext/standard file.c /php-src/ext/standard/tests/filecopy_variation4.phpt Log: - [DOC] detect if dest is a dir (if the given stream layer supports stat) and fails . remove win32 specific test. The errors are not the same http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.522r2=1.523diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.522 php-src/ext/standard/file.c:1.523 --- php-src/ext/standard/file.c:1.522 Wed Jul 23 11:24:34 2008 +++ php-src/ext/standard/file.c Mon Aug 11 13:09:01 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.522 2008/07/23 11:24:34 tony2001 Exp $ */ +/* $Id: file.c,v 1.523 2008/08/11 13:09:01 pajoye Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1892,9 +1892,26 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, The first argument to copy() function cannot be a directory); return FAILURE; } + + switch (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, dest_s, NULL)) { + case -1: + /* non-statable stream */ + goto safe_to_copy; + break; + case 0: + break; + default: /* failed to stat file, does not exist? */ + return ret; + } + if (S_ISDIR(dest_s.sb.st_mode)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, The second argument to copy() function cannot be a directory); + return FAILURE; + } + /* if (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, dest_s, NULL) != 0) { goto safe_to_copy; } +*/ if (!src_s.sb.st_ino || !dest_s.sb.st_ino) { goto no_stat; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/copy_variation4.phpt?r1=1.5r2=1.6diff_format=u Index: php-src/ext/standard/tests/file/copy_variation4.phpt -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pajoye Mon Aug 11 13:14:02 2008 UTC Modified files: /php-src/ext/standard file.c Log: - removed commented code http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.523r2=1.524diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.523 php-src/ext/standard/file.c:1.524 --- php-src/ext/standard/file.c:1.523 Mon Aug 11 13:09:01 2008 +++ php-src/ext/standard/file.c Mon Aug 11 13:14:01 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.523 2008/08/11 13:09:01 pajoye Exp $ */ +/* $Id: file.c,v 1.524 2008/08/11 13:14:01 pajoye Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1907,11 +1907,6 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, The second argument to copy() function cannot be a directory); return FAILURE; } - /* - if (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, dest_s, NULL) != 0) { - goto safe_to_copy; - } -*/ if (!src_s.sb.st_ino || !dest_s.sb.st_ino) { goto no_stat; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c fsock.c proc_open.c streamsfuncs.c /ext/standard/tests/file fscanf_variation10.phpt fscanf_variation16.phpt fscanf_variation22.phpt fscanf_variation29.phpt
felipe Tue Jul 22 14:06:17 2008 UTC Modified files: /php-src/ext/standard file.c fsock.c proc_open.c streamsfuncs.c /php-src/ext/standard/tests/filefscanf_variation10.phpt fscanf_variation16.phpt fscanf_variation22.phpt fscanf_variation29.phpt fscanf_variation35.phpt fscanf_variation4.phpt fscanf_variation41.phpt fscanf_variation47.phpt /php-src/ext/standard/tests/strings sprintf_variation23.phpt /php-src/main php_streams.h /php-src/sapi/cli php_cli.c Log: - Fixed bug #44246 (closedir() accepts a file resource opened by fopen()) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.520r2=1.521diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.520 php-src/ext/standard/file.c:1.521 --- php-src/ext/standard/file.c:1.520 Fri Jul 11 10:24:29 2008 +++ php-src/ext/standard/file.c Tue Jul 22 14:06:16 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.520 2008/07/11 10:24:29 tony2001 Exp $ */ +/* $Id: file.c,v 1.521 2008/07/22 14:06:16 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -965,6 +965,8 @@ stream = php_stream_fopen_tmpfile(); if (stream) { + stream-flags |= PHP_STREAM_FLAG_FCLOSE; + php_stream_to_zval(stream, return_value); } else { RETURN_FALSE; @@ -998,6 +1000,8 @@ if (stream == NULL) { RETURN_FALSE; } + + stream-flags |= PHP_STREAM_FLAG_FCLOSE; php_stream_to_zval(stream, return_value); } @@ -1015,6 +1019,12 @@ } PHP_STREAM_TO_ZVAL(stream, arg1); + + if (!(stream-flags PHP_STREAM_FLAG_FCLOSE)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, %d is not a valid stream resource, stream-rsrc_id); + RETURN_FALSE; + } + if (!stream-is_persistent) { zend_list_delete(stream-rsrc_id); } else { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/fsock.c?r1=1.127r2=1.128diff_format=u Index: php-src/ext/standard/fsock.c diff -u php-src/ext/standard/fsock.c:1.127 php-src/ext/standard/fsock.c:1.128 --- php-src/ext/standard/fsock.c:1.127 Mon Dec 31 07:12:15 2007 +++ php-src/ext/standard/fsock.cTue Jul 22 14:06:16 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: fsock.c,v 1.127 2007/12/31 07:12:15 sebastian Exp $ */ +/* $Id: fsock.c,v 1.128 2008/07/22 14:06:16 felipe Exp $ */ #include php.h #include php_globals.h @@ -79,6 +79,8 @@ stream = php_stream_xport_create(hostname, hostname_len, REPORT_ERRORS, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, hashkey, tv, NULL, errstr, err); + stream-flags |= PHP_STREAM_FLAG_FCLOSE; + if (port 0) { efree(hostname); } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.61r2=1.62diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.61 php-src/ext/standard/proc_open.c:1.62 --- php-src/ext/standard/proc_open.c:1.61 Tue Apr 8 08:42:05 2008 +++ php-src/ext/standard/proc_open.cTue Jul 22 14:06:16 2008 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.61 2008/04/08 08:42:05 jani Exp $ */ +/* $Id: proc_open.c,v 1.62 2008/07/22 14:06:16 felipe Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -971,7 +971,7 @@ zval *retfp; /* nasty hack; don't copy it */ - stream-flags |= PHP_STREAM_FLAG_NO_SEEK; + stream-flags |= PHP_STREAM_FLAG_NO_SEEK | PHP_STREAM_FLAG_FCLOSE; if (UG(unicode) !binary_pipes) { if (write_stream) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.118r2=1.119diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.118 php-src/ext/standard/streamsfuncs.c:1.119 --- php-src/ext/standard/streamsfuncs.c:1.118 Mon Jul 21 14:29:46 2008 +++ php-src/ext/standard/streamsfuncs.c Tue Jul 22 14:06:16 2008 @@ -17,7 +17,7 @@
[PHP-CVS] cvs: php-src /ext/standard file.c
felipe Wed May 28 17:24:47 2008 UTC Modified files: /php-src/ext/standard file.c Log: - Added zval separation (avoid crash when using fwrite($fp, $fp)). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.518r2=1.519diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.518 php-src/ext/standard/file.c:1.519 --- php-src/ext/standard/file.c:1.518 Sun May 4 21:16:22 2008 +++ php-src/ext/standard/file.c Wed May 28 17:24:47 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.518 2008/05/04 21:16:22 colder Exp $ */ +/* $Id: file.c,v 1.519 2008/05/28 17:24:47 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1358,7 +1358,7 @@ php_stream *stream; zval *zstream, *zstring; - if (zend_parse_parameters(argc TSRMLS_CC, rz|l, zstream, zstring, write_len) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, rz/|l, zstream, zstring, write_len) == FAILURE) { RETURN_NULL(); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
iliaa Mon Mar 31 22:44:38 2008 UTC Modified files: /php-src/ext/standard file.c Log: Revert unintended bits from Added a warning message commit http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.516r2=1.517diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.516 php-src/ext/standard/file.c:1.517 --- php-src/ext/standard/file.c:1.516 Sun Mar 30 15:31:33 2008 +++ php-src/ext/standard/file.c Mon Mar 31 22:44:38 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.516 2008/03/30 15:31:33 felipe Exp $ */ +/* $Id: file.c,v 1.517 2008/03/31 22:44:38 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -622,8 +622,8 @@ long flags = ((argc 3) UG(unicode)) ? PHP_FILE_TEXT : 0; zval *zcontext = NULL; php_stream_context *context = NULL; + char mode[3] = { 'w', 0, 0 }; php_stream *srcstream = NULL; - char mode[3] = wb; if (zend_parse_parameters(argc TSRMLS_CC, Zz/|lr!, ppfilename, data, flags, zcontext) == FAILURE) { return; @@ -659,10 +659,6 @@ RETURN_FALSE; } - if (mode[0] = 'c') { - php_stream_truncate_set_size(stream, 0); - } - switch (Z_TYPE_P(data)) { case IS_RESOURCE: numchars = php_stream_copy_to_stream(srcstream, stream, PHP_STREAM_COPY_ALL); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
iliaa Sun Mar 30 15:06:07 2008 UTC Modified files: /php-src/ext/standard file.c Log: MFB: Added a warning message http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.514r2=1.515diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.514 php-src/ext/standard/file.c:1.515 --- php-src/ext/standard/file.c:1.514 Thu Feb 28 14:16:14 2008 +++ php-src/ext/standard/file.c Sun Mar 30 15:06:07 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.514 2008/02/28 14:16:14 felipe Exp $ */ +/* $Id: file.c,v 1.515 2008/03/30 15:06:07 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -624,6 +624,7 @@ php_stream_context *context = NULL; char mode[3] = { 'w', 0, 0 }; php_stream *srcstream = NULL; + char mode[3] = wb; if (zend_parse_parameters(argc TSRMLS_CC, Zz/|lr!, ppfilename, data, flags, zcontext) == FAILURE) { return; @@ -655,9 +656,14 @@ if (flags LOCK_EX (!php_stream_supports_lock(stream) || php_stream_lock(stream, LOCK_EX))) { php_stream_close(stream); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Exclusive locks are not supported for this stream); RETURN_FALSE; } + if (mode[0] = 'c') { + php_stream_truncate_set_size(stream, 0); + } + switch (Z_TYPE_P(data)) { case IS_RESOURCE: numchars = php_stream_copy_to_stream(srcstream, stream, PHP_STREAM_COPY_ALL); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
felipe Sun Mar 30 15:31:33 2008 UTC Modified files: /php-src/ext/standard file.c Log: - Fix build http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.515r2=1.516diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.515 php-src/ext/standard/file.c:1.516 --- php-src/ext/standard/file.c:1.515 Sun Mar 30 15:06:07 2008 +++ php-src/ext/standard/file.c Sun Mar 30 15:31:33 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.515 2008/03/30 15:06:07 iliaa Exp $ */ +/* $Id: file.c,v 1.516 2008/03/30 15:31:33 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -622,7 +622,6 @@ long flags = ((argc 3) UG(unicode)) ? PHP_FILE_TEXT : 0; zval *zcontext = NULL; php_stream_context *context = NULL; - char mode[3] = { 'w', 0, 0 }; php_stream *srcstream = NULL; char mode[3] = wb; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
felipe Sun Feb 24 11:49:39 2008 UTC Modified files: /php-src/ext/standard file.c Log: Removed internal warning http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.512r2=1.513diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.512 php-src/ext/standard/file.c:1.513 --- php-src/ext/standard/file.c:1.512 Sat Feb 23 17:03:53 2008 +++ php-src/ext/standard/file.c Sun Feb 24 11:49:39 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.512 2008/02/23 17:03:53 helly Exp $ */ +/* $Id: file.c,v 1.513 2008/02/24 11:49:39 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1493,7 +1493,6 @@ { int ret; - php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, This function is deprecated; use php_stream_mkdir() instead.); if (php_check_open_basedir(dir TSRMLS_CC)) { return -1; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
stasTue Feb 12 01:30:58 2008 UTC Modified files: /php-src/ext/standard file.c Log: fix build http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.510r2=1.511diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.510 php-src/ext/standard/file.c:1.511 --- php-src/ext/standard/file.c:1.510 Sun Feb 10 04:09:12 2008 +++ php-src/ext/standard/file.c Tue Feb 12 01:30:58 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.510 2008/02/10 04:09:12 felipe Exp $ */ +/* $Id: file.c,v 1.511 2008/02/12 01:30:58 stas Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1368,11 +1368,12 @@ } if (Z_TYPE_P(zstring) == IS_UNICODE) { + int32_t write_uchars = 0; + if (write_len 0 || write_len Z_USTRLEN_P(zstring)) { write_len = Z_USTRLEN_P(zstring); } /* Convert code units to data points */ - int32_t write_uchars = 0; U16_FWD_N(Z_USTRVAL_P(zstring), write_uchars, Z_USTRLEN_P(zstring), write_len); write_len = write_uchars; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
felipe Sat Feb 9 19:46:49 2008 UTC Modified files: /php-src/ext/standard file.c Log: Fixed bugs: - #42036 fgetc() sets end of the file flag when reading on write only file - #42037 fgetc() retuns one char when fails to read on php6 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.507r2=1.508diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.507 php-src/ext/standard/file.c:1.508 --- php-src/ext/standard/file.c:1.507 Wed Feb 6 02:56:49 2008 +++ php-src/ext/standard/file.c Sat Feb 9 19:46:49 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.507 2008/02/06 02:56:49 felipe Exp $ */ +/* $Id: file.c,v 1.508 2008/02/09 19:46:49 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1181,14 +1181,16 @@ int buflen = 1; UChar *buf = php_stream_read_unicode_chars(stream, buflen); - if (!buf) { + if (!buf || !buflen) { RETURN_FALSE; } RETURN_UNICODEL(buf, buflen, 0); } else { /* IS_STRING */ char buf[2]; - buf[0] = php_stream_getc(stream); + if ((buf[0] = php_stream_getc(stream)) == EOF) { + RETURN_FALSE; + } buf[1] = 0; RETURN_STRINGL(buf, 1, 1); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
felipe Sun Feb 10 02:13:37 2008 UTC Modified files: /php-src/ext/standard file.c Log: Fixed Bug #42163 (fgetcsv() gives different output with and without Unicode) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.508r2=1.509diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.508 php-src/ext/standard/file.c:1.509 --- php-src/ext/standard/file.c:1.508 Sat Feb 9 19:46:49 2008 +++ php-src/ext/standard/file.c Sun Feb 10 02:13:37 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.508 2008/02/09 19:46:49 felipe Exp $ */ +/* $Id: file.c,v 1.509 2008/02/10 02:13:37 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2216,7 +2216,7 @@ if (len 0) { buf.v = php_stream_get_line_ex(stream, stream-readbuf_type, NULL_ZSTR, 0, 0, buf_len); } else { - buf.v = stream-readbuf_type == IS_UNICODE ? emalloc(UBYTES(len + 1)) : emalloc(len + 1); + buf.v = stream-readbuf_type == IS_UNICODE ? eumalloc(len + 1) : emalloc(len + 1); if (php_stream_get_line_ex(stream, stream-readbuf_type, buf, len + 1, len + 1, buf_len) == NULL) { efree(buf.v); RETVAL_FALSE; @@ -2541,7 +2541,7 @@ if (*p == '\r' || *p == '\n') { /* Terminal delimiter, treat as empty field */ p++; - add_next_index_stringl(return_value, , 0, 1); + add_next_index_unicodel(return_value, (UChar*), 0, 1); break; } @@ -2595,7 +2595,7 @@ /* Enclosure encountered, is it paired? */ if (PHP_FGETCSV_UNI_CHECK(p + enclosure_len, e, enclosure, enclosure_len)) { /* Double enclosure gets translated to single enclosure */ - memmove(p, p + enclosure_len, (e - p) - enclosure_len); + memmove(p, p + enclosure_len, UBYTES((e - p) - enclosure_len)); e -= enclosure_len; p += enclosure_len; if (p = e) break; @@ -2672,7 +2672,7 @@ int cruft_len = p - (field_end + enclosure_len); field = eumalloc(field_len + cruft_len + 1); - memcpy(field, field_start, field_len); + memcpy(field, field_start, UBYTES(field_len)); memcpy(field + field_len, field_end + enclosure_len, UBYTES(cruft_len)); field_len += cruft_len; field[field_len] = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
felipe Sun Feb 10 04:09:12 2008 UTC Modified files: /php-src/ext/standard file.c Log: Fixed Bug #42229 (fgetcsv() behaves differently for a file containing '\n' with php5 and php6) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.509r2=1.510diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.509 php-src/ext/standard/file.c:1.510 --- php-src/ext/standard/file.c:1.509 Sun Feb 10 02:13:37 2008 +++ php-src/ext/standard/file.c Sun Feb 10 04:09:12 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.509 2008/02/10 02:13:37 felipe Exp $ */ +/* $Id: file.c,v 1.510 2008/02/10 04:09:12 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2359,6 +2359,11 @@ if (p = e) break; goto ready_state; } + + /* Otherwise, starting a new field without enclosures */ + state = PHP_FGETCSV_FIELD_NO_ENC; + field_start = p++; + field_end = NULL; /* Is it an escape character? */ if ((PHP_FGETCSV_BIN_CHECK(p, e, escape, escape_len) escape != enclosure) || @@ -2368,15 +2373,9 @@ /* Skip escape sequence and let next char be treated as literal * If enclosure is the same character as esacpe, it is considered as esacped * if it appears twice */ - p += escape_len; + p += escape_len - 1; /* FALL THROUGH */ } - - /* Otherwise, starting a new field without enclosures */ - state = PHP_FGETCSV_FIELD_NO_ENC; - field_start = p; - field_end = NULL; - p++; break; case PHP_FGETCSV_FIELD_WITH_ENC: @@ -2568,6 +2567,11 @@ if (p = e) break; goto ready_state; } + + /* Otherwise, starting a new field without enclosures */ + state = PHP_FGETCSV_FIELD_NO_ENC; + field_start = p++; + field_end = NULL; /* Is it an escape character? */ if ((PHP_FGETCSV_UNI_CHECK(p, e, escape, escape_len) escape != enclosure) || @@ -2575,17 +2579,11 @@ PHP_FGETCSV_UNI_CHECK(p+1, e, escape, escape_len) escape == enclosure) ) { /* Skip escape sequence and let next char be treated as literal -* If enclosure is the same character as esacpe, it is considered as esacped +* If enclosure is the same character as escape, it is considered as escaped * if it appears twice */ - p += escape_len; + p += escape_len - 1; /* FALL THROUGH */ } - - /* Otherwise, starting a new field without enclosures */ - state = PHP_FGETCSV_FIELD_NO_ENC; - field_start = p; - field_end = NULL; - p++; break; case PHP_FGETCSV_FIELD_WITH_ENC: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
felipe Wed Feb 6 02:56:49 2008 UTC Modified files: /php-src/ext/standard file.c Log: Fixed bug #42167 (fgetcsv gives different output on php6 compared to php5), #42219 (length argument of fgetcsv() is not effective/working in PHP6) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.506r2=1.507diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.506 php-src/ext/standard/file.c:1.507 --- php-src/ext/standard/file.c:1.506 Mon Feb 4 19:48:14 2008 +++ php-src/ext/standard/file.c Wed Feb 6 02:56:49 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.506 2008/02/04 19:48:14 felipe Exp $ */ +/* $Id: file.c,v 1.507 2008/02/06 02:56:49 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2158,7 +2158,7 @@ } if (stream-readbuf_type == IS_STRING) { - /* Binary mode stream needs binary delmiter/enclosure */ + /* Binary mode stream needs binary delimiter/enclosure */ if (delimiter_type == IS_UNICODE) { if (FAILURE == zend_unicode_to_string(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), delimiter, delimiter_len, (UChar*)delimiter, delimiter_len TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed converting delimiter from unicode); @@ -2211,7 +2211,17 @@ } } - buf.v = php_stream_get_line_ex(stream, stream-readbuf_type, NULL_ZSTR, 0, (len 0) ? 0 : len, buf_len); + if (len 0) { + buf.v = php_stream_get_line_ex(stream, stream-readbuf_type, NULL_ZSTR, 0, 0, buf_len); + } else { + buf.v = stream-readbuf_type == IS_UNICODE ? emalloc(UBYTES(len + 1)) : emalloc(len + 1); + if (php_stream_get_line_ex(stream, stream-readbuf_type, buf, len + 1, len + 1, buf_len) == NULL) { + efree(buf.v); + RETVAL_FALSE; + goto cleanup; + } + } + if (!buf.v) { /* No data */ RETVAL_FALSE; @@ -2473,7 +2483,7 @@ case PHP_FGETCSV_FIELD_NO_ENC: /* Check for escapes */ - if (PHP_FGETCSV_BIN_CHECK(p, e, escape, escape_len)) { + if (!PHP_FGETCSV_BIN_CHECK(p, e, delimiter, delimiter_len) PHP_FGETCSV_BIN_CHECK(p, e, escape, escape_len)) { p += escape_len + 1; } @@ -2682,7 +2692,7 @@ case PHP_FGETCSV_FIELD_NO_ENC: /* Check for escapes */ - if (PHP_FGETCSV_UNI_CHECK(p, e, escape, escape_len)) { + if (!PHP_FGETCSV_UNI_CHECK(p, e, delimiter, delimiter_len) PHP_FGETCSV_UNI_CHECK(p, e, escape, escape_len)) { p += escape_len + 1; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
felipe Mon Feb 4 18:45:40 2008 UTC Modified files: /php-src/ext/standard file.c Log: Fixed Bug #42057 (fwrite() writes data into file when length is given as a negative value) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.504r2=1.505diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.504 php-src/ext/standard/file.c:1.505 --- php-src/ext/standard/file.c:1.504 Mon Dec 31 07:12:15 2007 +++ php-src/ext/standard/file.c Mon Feb 4 18:45:40 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.504 2007/12/31 07:12:15 sebastian Exp $ */ +/* $Id: file.c,v 1.505 2008/02/04 18:45:40 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1359,22 +1359,20 @@ RETURN_NULL(); } - if (!write_len) { + if (write_len = 0) { RETURN_LONG(0); } php_stream_from_zval(stream, zstream); if (Z_TYPE_P(zstring) == IS_UNICODE) { - if (write_len = 0) { - /* Convert code units to data points */ - int32_t write_uchars = 0; + /* Convert code units to data points */ + int32_t write_uchars = 0; - U16_FWD_N(Z_USTRVAL_P(zstring), write_uchars, Z_USTRLEN_P(zstring), write_len); - write_len = write_uchars; - } + U16_FWD_N(Z_USTRVAL_P(zstring), write_uchars, Z_USTRLEN_P(zstring), write_len); + write_len = write_uchars; - if (write_len 0 || write_len Z_USTRLEN_P(zstring)) { + if (write_len Z_USTRLEN_P(zstring)) { write_len = Z_USTRLEN_P(zstring); } ret = php_stream_write_unicode(stream, Z_USTRVAL_P(zstring), write_len); @@ -1385,7 +1383,7 @@ } } else { convert_to_string(zstring); - if (write_len 0 || write_len Z_STRLEN_P(zstring)) { + if (write_len Z_STRLEN_P(zstring)) { write_len = Z_STRLEN_P(zstring); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
felipe Mon Feb 4 19:48:14 2008 UTC Modified files: /php-src/ext/standard file.c Log: Fixed wrong fix http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.505r2=1.506diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.505 php-src/ext/standard/file.c:1.506 --- php-src/ext/standard/file.c:1.505 Mon Feb 4 18:45:40 2008 +++ php-src/ext/standard/file.c Mon Feb 4 19:48:14 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.505 2008/02/04 18:45:40 felipe Exp $ */ +/* $Id: file.c,v 1.506 2008/02/04 19:48:14 felipe Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1359,22 +1359,22 @@ RETURN_NULL(); } - if (write_len = 0) { + php_stream_from_zval(stream, zstream); + + if (argc 2 write_len = 0) { RETURN_LONG(0); } - php_stream_from_zval(stream, zstream); - if (Z_TYPE_P(zstring) == IS_UNICODE) { + if (write_len 0 || write_len Z_USTRLEN_P(zstring)) { + write_len = Z_USTRLEN_P(zstring); + } /* Convert code units to data points */ int32_t write_uchars = 0; U16_FWD_N(Z_USTRVAL_P(zstring), write_uchars, Z_USTRLEN_P(zstring), write_len); write_len = write_uchars; - if (write_len Z_USTRLEN_P(zstring)) { - write_len = Z_USTRLEN_P(zstring); - } ret = php_stream_write_unicode(stream, Z_USTRVAL_P(zstring), write_len); /* Convert data points back to code units */ @@ -1383,7 +1383,7 @@ } } else { convert_to_string(zstring); - if (write_len Z_STRLEN_P(zstring)) { + if (write_len 0 || write_len Z_STRLEN_P(zstring)) { write_len = Z_STRLEN_P(zstring); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
janiMon Nov 5 15:24:25 2007 UTC Modified files: /php-src/ext/standard file.c Log: ws + cs http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.502r2=1.503diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.502 php-src/ext/standard/file.c:1.503 --- php-src/ext/standard/file.c:1.502 Sat Oct 6 21:15:46 2007 +++ php-src/ext/standard/file.c Mon Nov 5 15:24:25 2007 @@ -19,9 +19,9 @@ | PHP 4.0 patches by Thies C. Arntzen ([EMAIL PROTECTED]) | | PHP streams by Wez Furlong ([EMAIL PROTECTED])| +--+ - */ +*/ -/* $Id: file.c,v 1.502 2007/10/06 21:15:46 tony2001 Exp $ */ +/* $Id: file.c,v 1.503 2007/11/05 15:24:25 jani Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -146,11 +146,10 @@ { return le_stream_context; } - /* }}} */ -/* {{{ Module-Stuff */ - +/* {{{ Module-Stuff +*/ static ZEND_RSRC_DTOR_FUNC(file_context_dtor) { php_stream_context *context = (php_stream_context*)rsrc-ptr; @@ -172,7 +171,6 @@ { } - PHP_INI_BEGIN() STD_PHP_INI_ENTRY(user_agent, NULL, PHP_INI_ALL, OnUpdateString, user_agent, php_file_globals, file_globals) STD_PHP_INI_ENTRY(default_socket_timeout, 60, PHP_INI_ALL, OnUpdateLong, default_socket_timeout, php_file_globals, file_globals) @@ -190,7 +188,7 @@ #endif REGISTER_INI_ENTRIES(); - + REGISTER_LONG_CONSTANT(SEEK_SET, SEEK_SET, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SEEK_CUR, SEEK_CUR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SEEK_END, SEEK_END, CONST_CS | CONST_PERSISTENT); @@ -209,7 +207,7 @@ REGISTER_LONG_CONSTANT(STREAM_NOTIFY_FAILURE, PHP_STREAM_NOTIFY_FAILURE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_NOTIFY_COMPLETED, PHP_STREAM_NOTIFY_COMPLETED,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_NOTIFY_RESOLVE, PHP_STREAM_NOTIFY_RESOLVE, CONST_CS | CONST_PERSISTENT); - + REGISTER_LONG_CONSTANT(STREAM_NOTIFY_SEVERITY_INFO, PHP_STREAM_NOTIFY_SEVERITY_INFO,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_NOTIFY_SEVERITY_WARN, PHP_STREAM_NOTIFY_SEVERITY_WARN,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_NOTIFY_SEVERITY_ERR, PHP_STREAM_NOTIFY_SEVERITY_ERR, CONST_CS | CONST_PERSISTENT); @@ -230,7 +228,7 @@ REGISTER_LONG_CONSTANT(STREAM_CRYPTO_METHOD_SSLv3_SERVER, STREAM_CRYPTO_METHOD_SSLv3_SERVER, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_CRYPTO_METHOD_SSLv23_SERVER, STREAM_CRYPTO_METHOD_SSLv23_SERVER, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_CRYPTO_METHOD_TLS_SERVER, STREAM_CRYPTO_METHOD_TLS_SERVER,CONST_CS|CONST_PERSISTENT); - + REGISTER_LONG_CONSTANT(STREAM_SHUT_RD,STREAM_SHUT_RD, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_SHUT_WR,STREAM_SHUT_WR, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_SHUT_RDWR, STREAM_SHUT_RDWR, CONST_CS|CONST_PERSISTENT); @@ -284,7 +282,7 @@ REGISTER_LONG_CONSTANT(STREAM_SERVER_BIND, STREAM_XPORT_BIND, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(STREAM_SERVER_LISTEN, STREAM_XPORT_LISTEN,CONST_CS | CONST_PERSISTENT); - + REGISTER_LONG_CONSTANT(FILE_USE_INCLUDE_PATH, PHP_FILE_USE_INCLUDE_PATH, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(FILE_IGNORE_NEW_LINES, PHP_FILE_IGNORE_NEW_LINES, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(FILE_SKIP_EMPTY_LINES, PHP_FILE_SKIP_EMPTY_LINES, CONST_CS | CONST_PERSISTENT); @@ -304,7 +302,6 @@ return SUCCESS; } - /* }}} */ PHP_MSHUTDOWN_FUNCTION(file) /* {{{ */ @@ -316,11 +313,10 @@ } /* }}} */ -/* {{{ proto bool flock(resource fp, int operation [, int wouldblock]) U - Portable file locking */ - static int flock_values[] = { LOCK_SH, LOCK_EX, LOCK_UN }; +/* {{{ proto bool flock(resource fp, int operation [, int wouldblock]) U + Portable file locking */ PHP_FUNCTION(flock) { zval *arg1, *arg3 = NULL; @@ -355,14 +351,12 @@ } RETURN_TRUE; } - /* }}} */ #define PHP_META_UNSAFE .\\+*?[^]$() /* {{{ proto array get_meta_tags(string filename [, bool use_include_path]) U Extracts all meta tag content attributes from a file and returns an array */ - PHP_FUNCTION(get_meta_tags) { zval
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Sat Oct 6 21:15:46 2007 UTC Modified files: /php-src/ext/standard file.c Log: fix ws and avoid freeing integer vars http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.501r2=1.502diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.501 php-src/ext/standard/file.c:1.502 --- php-src/ext/standard/file.c:1.501 Wed Oct 3 10:31:04 2007 +++ php-src/ext/standard/file.c Sat Oct 6 21:15:46 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.501 2007/10/03 10:31:04 dsp Exp $ */ +/* $Id: file.c,v 1.502 2007/10/06 21:15:46 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2259,10 +2259,7 @@ } /* }}} */ -PHPAPI void php_fgetcsv(php_stream *stream, /* {{{ */ - char delimiter, char enclosure, char escape, - size_t buf_len, char *buf, - zval *return_value TSRMLS_DC) +PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char escape, size_t buf_len, char *buf, zval *return_value TSRMLS_DC) /* {{{ */ { char *delim = delimiter, *enc = enclosure, *buffer = buf, *esc; int delim_len = 1, enc_len = 1, esc_len = 1, buffer_len = buf_len; @@ -2273,7 +2270,6 @@ } if (type == IS_UNICODE) { - UChar esc = '\\'; /* Unicode stream, but binary delimiter/enclosures/prefetch, promote to unicode */ if (FAILURE == zend_string_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), (UChar**)delim, delim_len, delimiter, 1 TSRMLS_CC)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
janiMon Sep 3 11:53:44 2007 UTC Modified files: /php-src/ext/standard file.c Log: MFB: Fixed bug #42468 (Write lock on file_get_contents fails when using a compression stream) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.498r2=1.499diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.498 php-src/ext/standard/file.c:1.499 --- php-src/ext/standard/file.c:1.498 Mon Aug 13 08:14:03 2007 +++ php-src/ext/standard/file.c Mon Sep 3 11:53:43 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.498 2007/08/13 08:14:03 jani Exp $ */ +/* $Id: file.c,v 1.499 2007/09/03 11:53:43 jani Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -661,7 +661,7 @@ RETURN_FALSE; } - if (flags LOCK_EX php_stream_lock(stream, LOCK_EX)) { + if (flags LOCK_EX (!php_stream_supports_lock(stream) || php_stream_lock(stream, LOCK_EX))) { php_stream_close(stream); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/assert assert_basic2.phpt /ext/standard/tests/file copy_variation12.phpt copy_variation13.phpt
janiMon Aug 13 08:14:04 2007 UTC Modified files: /php-src/ext/standard file.c /php-src/ext/standard/tests/assert assert_basic2.phpt /php-src/ext/standard/tests/filecopy_variation12.phpt copy_variation13.phpt Log: MFB: Fix tests + directory check inside copy() function http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.497r2=1.498diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.497 php-src/ext/standard/file.c:1.498 --- php-src/ext/standard/file.c:1.497 Sun Aug 12 02:00:03 2007 +++ php-src/ext/standard/file.c Mon Aug 13 08:14:03 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.497 2007/08/12 02:00:03 hirokawa Exp $ */ +/* $Id: file.c,v 1.498 2007/08/13 08:14:03 jani Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1903,13 +1903,13 @@ default: /* failed to stat file, does not exist? */ return ret; } - if (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, dest_s, NULL) != 0) { - goto safe_to_copy; - } if (S_ISDIR(src_s.sb.st_mode)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, The first argument to copy() function cannot be a directory); return FAILURE; } + if (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, dest_s, NULL) != 0) { + goto safe_to_copy; + } if (!src_s.sb.st_ino || !dest_s.sb.st_ino) { goto no_stat; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/assert/assert_basic2.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/assert/assert_basic2.phpt diff -u php-src/ext/standard/tests/assert/assert_basic2.phpt:1.1 php-src/ext/standard/tests/assert/assert_basic2.phpt:1.2 --- php-src/ext/standard/tests/assert/assert_basic2.phpt:1.1Fri Jul 13 14:57:32 2007 +++ php-src/ext/standard/tests/assert/assert_basic2.phptMon Aug 13 08:14:03 2007 @@ -1,5 +1,5 @@ --TEST-- -assert() basic - correct call back values before and after assert. +assert() - basic - correct call back values before and after assert. --INI-- assert.active = 1 assert.warning = 1 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/copy_variation12.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/standard/tests/file/copy_variation12.phpt diff -u php-src/ext/standard/tests/file/copy_variation12.phpt:1.2 php-src/ext/standard/tests/file/copy_variation12.phpt:1.3 --- php-src/ext/standard/tests/file/copy_variation12.phpt:1.2 Fri Aug 10 02:58:50 2007 +++ php-src/ext/standard/tests/file/copy_variation12.phpt Mon Aug 13 08:14:03 2007 @@ -41,15 +41,23 @@ --EXPECTF-- *** Test copy() function: Trying to create a copy of an existing dir *** + +Warning: copy(): The first argument to copy() function cannot be a directory in %s/copy_variation12.php on line %d bool(false) bool(false) int(4096) -int(0) + +Warning: filesize(): stat failed for %s/copy_copy_variation12 in %s/copy_variation12.php on line %d +bool(false) *** Done *** --UEXPECTF-- *** Test copy() function: Trying to create a copy of an existing dir *** + +Warning: copy(): The first argument to copy() function cannot be a directory in %s/copy_variation12.php on line %d bool(false) bool(false) int(4096) -int(0) + +Warning: filesize(): stat failed for %s/copy_copy_variation12 in %s/copy_variation12.php on line %d +bool(false) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/copy_variation13.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/standard/tests/file/copy_variation13.phpt diff -u php-src/ext/standard/tests/file/copy_variation13.phpt:1.2 php-src/ext/standard/tests/file/copy_variation13.phpt:1.3 --- php-src/ext/standard/tests/file/copy_variation13.phpt:1.2 Fri Aug 10 02:58:50 2007 +++ php-src/ext/standard/tests/file/copy_variation13.phpt Mon Aug 13 08:14:03 2007 @@ -1,5 +1,5 @@ --TEST-- -Test copy() function: usage variations - src as dir and dest as an existing file(Bug #42243) +Test copy() function: usage variations - src as dir and dest as an existing file (Bug #42243) --FILE-- ?php /* Prototype: bool copy ( string $source, string $dest ); @@ -44,7 +44,7 @@ *** Test copy() function: Trying to copy dir to file *** *** Testing copy() in copying dir to file *** -Warning: copy(%s): %s +Warning: copy(): The first argument to copy() function cannot be a directory in %s/copy_variation13.php on line %d bool(false) bool(true) bool(true) @@ -59,7 +59,7 @@ *** Test copy() function: Trying to copy dir to file *** *** Testing copy() in copying dir to file *** -Warning: copy(%s): %s +Warning: copy(): The first argument to copy() function cannot be a directory in %s/copy_variation13.php on line %d bool(false) bool(true)
[PHP-CVS] cvs: php-src /ext/standard file.c
hirokawaSun Aug 12 02:00:03 2007 UTC Modified files: /php-src/ext/standard file.c Log: MF PHP_5_2 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.496r2=1.497diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.496 php-src/ext/standard/file.c:1.497 --- php-src/ext/standard/file.c:1.496 Fri Aug 10 08:58:12 2007 +++ php-src/ext/standard/file.c Sun Aug 12 02:00:03 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.496 2007/08/10 08:58:12 tony2001 Exp $ */ +/* $Id: file.c,v 1.497 2007/08/12 02:00:03 hirokawa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -126,6 +126,9 @@ #include wchar.h #endif +#ifndef S_ISDIR +#define S_ISDIR(mode) (((mode)S_IFMT) == S_IFDIR) +#endif /* }}} */ #define PHP_STREAM_TO_ZVAL(stream, arg) \ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Fri Aug 10 08:58:12 2007 UTC Modified files: /php-src/ext/standard file.c Log: MFB: Fixed bug #42243 (copy() does not ouput an error when the first arg is a dir) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.495r2=1.496diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.495 php-src/ext/standard/file.c:1.496 --- php-src/ext/standard/file.c:1.495 Sat Jul 14 08:38:19 2007 +++ php-src/ext/standard/file.c Fri Aug 10 08:58:12 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.495 2007/07/14 08:38:19 tony2001 Exp $ */ +/* $Id: file.c,v 1.496 2007/08/10 08:58:12 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1903,6 +1903,10 @@ if (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, dest_s, NULL) != 0) { goto safe_to_copy; } + if (S_ISDIR(src_s.sb.st_mode)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, The first argument to copy() function cannot be a directory); + return FAILURE; + } if (!src_s.sb.st_ino || !dest_s.sb.st_ino) { goto no_stat; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
dmitry Tue Jul 10 17:02:43 2007 UTC Modified files: /php-src/ext/standard file.c Log: Fixed fgets() and fgetss() with limits http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.493r2=1.494diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.493 php-src/ext/standard/file.c:1.494 --- php-src/ext/standard/file.c:1.493 Sun Jul 1 21:26:30 2007 +++ php-src/ext/standard/file.c Tue Jul 10 17:02:43 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.493 2007/07/01 21:26:30 sniper Exp $ */ +/* $Id: file.c,v 1.494 2007/07/10 17:02:43 dmitry Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1131,13 +1131,16 @@ zval *zstream; int argc = ZEND_NUM_ARGS(); long length = -1; - zstr buf; + long len; + zstr buf, line; size_t retlen = 0; if (zend_parse_parameters(argc TSRMLS_CC, r|l, zstream, length) == FAILURE) { return; } + php_stream_from_zval(stream, zstream); + if (ZEND_NUM_ARGS() == 2 length = 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Length parameter must be greater than 0); RETURN_FALSE; @@ -1147,20 +1150,26 @@ /* For BC reasons, fgets() should only return length-1 bytes. */ RETURN_FALSE; } else if (length 1) { + len = length; + buf.v = ecalloc(len, (stream-readbuf_type == IS_UNICODE) ? sizeof(UChar) : sizeof(char)); length--; + } else { + buf.v = NULL; + len = -1; } - php_stream_from_zval(stream, zstream); - - buf.v = php_stream_get_line_ex(stream, stream-readbuf_type, NULL_ZSTR, 0, length, retlen); - if (!buf.v) { + line.v = php_stream_get_line_ex(stream, stream-readbuf_type, buf, len, length, retlen); + if (!line.v) { + if (buf.v) { + efree(buf.v); + } RETURN_FALSE; } if (stream-readbuf_type == IS_UNICODE) { - RETURN_UNICODEL(buf.u, retlen, 0); + RETURN_UNICODEL(line.u, retlen, 0); } else { /* IS_STRING */ - RETURN_STRINGL(buf.s, retlen, 0); + RETURN_STRINGL(line.s, retlen, 0); } } /* }}} */ @@ -1203,13 +1212,17 @@ zval *zstream; php_stream *stream; long length = 0; + long len; zval **allow = NULL; size_t retlen = 0; + zstr buf; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|lZ, zstream, length, allow) == FAILURE) { return; } + php_stream_from_zval(stream, zstream); + if (ZEND_NUM_ARGS() = 2 length = 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Length parameter must be greater than 0); RETURN_FALSE; @@ -1219,17 +1232,24 @@ /* For BC reasons, fgetss() should only return length-1 bytes. */ RETURN_FALSE; } else if (length 1) { + len = length; + buf.v = ecalloc(len, (stream-readbuf_type == IS_UNICODE) ? sizeof(UChar) : sizeof(char)); length--; + } else { + buf.v = NULL; + len = -1; } - php_stream_from_zval(stream, zstream); - if (stream-readbuf_type == IS_UNICODE) { - UChar *buf = php_stream_get_line_ex(stream, IS_UNICODE, NULL_ZSTR, 0, length, retlen); + UChar *line; UChar *allowed = NULL; int allowed_len = 0; - if (!buf) { + line = php_stream_get_line_ex(stream, IS_UNICODE, buf, len, length, retlen); + if (!line) { + if (buf.v) { + efree(buf.v); + } RETURN_FALSE; } @@ -1238,15 +1258,19 @@ allowed = Z_USTRVAL_PP(allow); allowed_len = Z_USTRLEN_PP(allow); } - retlen = php_u_strip_tags(buf, retlen, stream-fgetss_state, allowed, allowed_len TSRMLS_CC); + retlen = php_u_strip_tags(line, retlen, stream-fgetss_state, allowed, allowed_len TSRMLS_CC); - RETURN_UNICODEL(buf, retlen, 0); + RETURN_UNICODEL(line, retlen, 0); } else { /* IS_STRING */ - char *buf = php_stream_get_line_ex(stream, IS_STRING, NULL_ZSTR, 0, length, retlen); + char *line; char *allowed = NULL; int allowed_len = 0; - if (!buf) { + line = php_stream_get_line_ex(stream, IS_STRING, buf, len, length, retlen); + if (!line) { + if (buf.v) { +
[PHP-CVS] cvs: php-src /ext/standard file.c
sniper Sun Jul 1 21:26:30 2007 UTC Modified files: /php-src/ext/standard file.c Log: - Fixed bug #41865 (fputcsv(): 2nd parameter is not optional) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.492r2=1.493diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.492 php-src/ext/standard/file.c:1.493 --- php-src/ext/standard/file.c:1.492 Thu Jun 14 19:56:35 2007 +++ php-src/ext/standard/file.c Sun Jul 1 21:26:30 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.492 2007/06/14 19:56:35 pajoye Exp $ */ +/* $Id: file.c,v 1.493 2007/07/01 21:26:30 sniper Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1996,7 +1996,7 @@ int count, i = 0; smart_str csvline = {0}; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|ass, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ra|ss, fp, fields, delimiter_str, delimiter_str_len, enclosure_str, enclosure_str_len) == FAILURE) { return; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pajoye Thu Jun 14 19:56:35 2007 UTC Modified files: /php-src/ext/standard file.c Log: - #41609, file_put_contents is not binary safe when a binary string is given (make it consistent with fwriteco when unicode=1) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.491r2=1.492diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.491 php-src/ext/standard/file.c:1.492 --- php-src/ext/standard/file.c:1.491 Wed May 30 09:16:29 2007 +++ php-src/ext/standard/file.c Thu Jun 14 19:56:35 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.491 2007/05/30 09:16:29 tony2001 Exp $ */ +/* $Id: file.c,v 1.492 2007/06/14 19:56:35 pajoye Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -646,7 +646,7 @@ if (flags PHP_FILE_APPEND) { mode[0] = 'a'; } - if (flags PHP_FILE_BINARY) { + if (flags PHP_FILE_BINARY || (Z_TYPE_P(data) == IS_STRING)) { mode[1] = 'b'; } else if (flags PHP_FILE_TEXT) { mode[1] = 't'; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Wed May 30 09:16:29 2007 UTC Modified files: /php-src/ext/standard file.c Log: check length only when it's specified add the same check to fgetss() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.490r2=1.491diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.490 php-src/ext/standard/file.c:1.491 --- php-src/ext/standard/file.c:1.490 Tue May 29 20:48:38 2007 +++ php-src/ext/standard/file.c Wed May 30 09:16:29 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.490 2007/05/29 20:48:38 tony2001 Exp $ */ +/* $Id: file.c,v 1.491 2007/05/30 09:16:29 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1135,10 +1135,10 @@ size_t retlen = 0; if (zend_parse_parameters(argc TSRMLS_CC, r|l, zstream, length) == FAILURE) { - RETURN_NULL(); + return; } - if (length = 0) { + if (ZEND_NUM_ARGS() == 2 length = 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Length parameter must be greater than 0); RETURN_FALSE; } @@ -1210,6 +1210,11 @@ return; } + if (ZEND_NUM_ARGS() = 2 length = 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Length parameter must be greater than 0); + RETURN_FALSE; + } + if (length == 1) { /* For BC reasons, fgetss() should only return length-1 bytes. */ RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Tue May 29 20:48:38 2007 UTC Modified files: /php-src/ext/standard file.c Log: fix #41516 (fgets() returns a line of text when length parameter is = 0) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.489r2=1.490diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.489 php-src/ext/standard/file.c:1.490 --- php-src/ext/standard/file.c:1.489 Fri May 18 20:34:07 2007 +++ php-src/ext/standard/file.c Tue May 29 20:48:38 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.489 2007/05/18 20:34:07 tony2001 Exp $ */ +/* $Id: file.c,v 1.490 2007/05/29 20:48:38 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1138,6 +1138,11 @@ RETURN_NULL(); } + if (length = 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Length parameter must be greater than 0); + RETURN_FALSE; + } + if (length == 1) { /* For BC reasons, fgets() should only return length-1 bytes. */ RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Fri May 18 12:05:55 2007 UTC Modified files: /php-src/ext/standard file.c Log: fix #41430 (Fatal error with negative values of maxlen parameter of file_get_contents()) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.487r2=1.488diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.487 php-src/ext/standard/file.c:1.488 --- php-src/ext/standard/file.c:1.487 Mon Apr 16 09:43:52 2007 +++ php-src/ext/standard/file.c Fri May 18 12:05:55 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.487 2007/04/16 09:43:52 dmitry Exp $ */ +/* $Id: file.c,v 1.488 2007/05/18 12:05:55 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -566,6 +566,11 @@ RETURN_FALSE; } + if (maxlen 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Length must be greater than or equal to zero); + RETURN_FALSE; + } + if (offset 0 php_stream_seek(stream, offset, SEEK_SET) 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to seek to position %ld in the stream, offset); php_stream_close(stream); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Fri May 18 20:34:07 2007 UTC Modified files: /php-src/ext/standard file.c Log: fix leak and check for 0 only of the 5th arg was passed http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.488r2=1.489diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.488 php-src/ext/standard/file.c:1.489 --- php-src/ext/standard/file.c:1.488 Fri May 18 12:05:55 2007 +++ php-src/ext/standard/file.c Fri May 18 20:34:07 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.488 2007/05/18 12:05:55 tony2001 Exp $ */ +/* $Id: file.c,v 1.489 2007/05/18 20:34:07 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -554,6 +554,11 @@ return; } + if (ZEND_NUM_ARGS() == 5 maxlen 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, length must be greater than or equal to zero); + RETURN_FALSE; + } + context = php_stream_context_from_zval(zcontext, 0); if (php_stream_path_param_encode(ppfilename, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { RETURN_FALSE; @@ -566,11 +571,6 @@ RETURN_FALSE; } - if (maxlen 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Length must be greater than or equal to zero); - RETURN_FALSE; - } - if (offset 0 php_stream_seek(stream, offset, SEEK_SET) 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to seek to position %ld in the stream, offset); php_stream_close(stream); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c ftp_fopen_wrapper.c proc_open.c /main SAPI.c main.c php_ini.c /main/streams plain_wrapper.c /win32 select.c /win32/build config.w32 TSRM TSRM.h tsrm_wi
dmitry Mon Apr 16 09:43:53 2007 UTC Modified files: /TSRM TSRM.h tsrm_win32.c /ZendEngine2zend_API.c zend_API.h zend_alloc.c zend_builtin_functions.c zend_compile.c zend_execute.c zend_execute.h zend_execute_API.c zend_ini.c zend_opcode.c zend_types.h zend_vm_def.h zend_vm_execute.h /php-src/ext/standard file.c ftp_fopen_wrapper.c proc_open.c /php-src/main SAPI.c main.c php_ini.c /php-src/main/streams plain_wrapper.c /php-src/win32 select.c /php-src/win32/buildconfig.w32 Log: WIN64 support http://cvs.php.net/viewvc.cgi/TSRM/TSRM.h?r1=1.54r2=1.55diff_format=u Index: TSRM/TSRM.h diff -u TSRM/TSRM.h:1.54 TSRM/TSRM.h:1.55 --- TSRM/TSRM.h:1.54Thu Feb 15 19:11:29 2007 +++ TSRM/TSRM.h Mon Apr 16 09:43:52 2007 @@ -30,6 +30,14 @@ # define TSRM_API #endif +#ifdef _WIN64 +typedef unsigned __int64 tsrm_intptr_t; +typedef __int64 tsrm_uintptr_t; +#else +typedef long tsrm_intptr_t; +typedef unsigned long tsrm_uintptr_t; +#endif + /* Only compile multi-threading functions if we're in ZTS mode */ #ifdef ZTS http://cvs.php.net/viewvc.cgi/TSRM/tsrm_win32.c?r1=1.32r2=1.33diff_format=u Index: TSRM/tsrm_win32.c diff -u TSRM/tsrm_win32.c:1.32 TSRM/tsrm_win32.c:1.33 --- TSRM/tsrm_win32.c:1.32 Mon Apr 2 20:48:53 2007 +++ TSRM/tsrm_win32.c Mon Apr 16 09:43:52 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: tsrm_win32.c,v 1.32 2007/04/02 20:48:53 stas Exp $ */ +/* $Id: tsrm_win32.c,v 1.33 2007/04/16 09:43:52 dmitry Exp $ */ #include stdio.h #include fcntl.h @@ -228,10 +228,10 @@ proc = process_get(NULL TSRMLS_CC); if (read) { - fno = _open_osfhandle((long)in, _O_RDONLY | mode); + fno = _open_osfhandle((tsrm_intptr_t)in, _O_RDONLY | mode); CloseHandle(out); } else { - fno = _open_osfhandle((long)out, _O_WRONLY | mode); + fno = _open_osfhandle((tsrm_intptr_t)out, _O_WRONLY | mode); CloseHandle(in); } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.426r2=1.427diff_format=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.426 ZendEngine2/zend_API.c:1.427 --- ZendEngine2/zend_API.c:1.426Thu Feb 8 14:33:16 2007 +++ ZendEngine2/zend_API.c Mon Apr 16 09:43:52 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: zend_API.c,v 1.426 2007/02/08 14:33:16 helly Exp $ */ +/* $Id: zend_API.c,v 1.427 2007/04/16 09:43:52 dmitry Exp $ */ #include zend.h #include zend_execute.h @@ -44,7 +44,7 @@ TSRMLS_FETCH(); p = EG(argument_stack).top_element-2; - arg_count = (ulong) *p; + arg_count = (int)(zend_uintptr_t) *p; if (param_countarg_count) { return FAILURE; @@ -82,7 +82,7 @@ zval *param_ptr; p = EG(argument_stack).top_element-2; - arg_count = (ulong) *p; + arg_count = (int)(zend_uintptr_t) *p; if (param_countarg_count) { return FAILURE; @@ -122,7 +122,7 @@ TSRMLS_FETCH(); p = EG(argument_stack).top_element-2; - arg_count = (ulong) *p; + arg_count = (int)(zend_uintptr_t) *p; if (param_countarg_count) { return FAILURE; @@ -145,7 +145,7 @@ int arg_count; p = EG(argument_stack).top_element-2; - arg_count = (ulong) *p; + arg_count = (int)(zend_uintptr_t) *p; if (param_countarg_count) { return FAILURE; @@ -168,7 +168,7 @@ int arg_count; p = EG(argument_stack).top_element-2; - arg_count = (ulong) *p; + arg_count = (int)(zend_uintptr_t) *p; if (param_countarg_count) { return FAILURE; @@ -957,7 +957,7 @@ return FAILURE; } - arg_count = (ulong) *(EG(argument_stack).top_element-2); + arg_count = (int)(zend_uintptr_t) *(EG(argument_stack).top_element-2); if (num_args arg_count) { zend_error(E_WARNING, %v(): could not obtain parameters for parsing, @@ -1238,7 +1238,7 @@ zend_update_class_constants(class_type-parent TSRMLS_CC); } #if ZTS - ALLOC_HASHTABLE(CG(static_members)[(long)(class_type-static_members)]); + ALLOC_HASHTABLE(CG(static_members)[(zend_intptr_t)(class_type-static_members)]); #else ALLOC_HASHTABLE(class_type-static_members); #endif http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.h?r1=1.286r2=1.287diff_format=u Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.286 ZendEngine2/zend_API.h:1.287 --- ZendEngine2/zend_API.h:1.286Thu Feb
[PHP-CVS] cvs: php-src /ext/standard file.c
helly Sat Mar 3 19:07:51 2007 UTC Modified files: /php-src/ext/standard file.c Log: - Fix realpath() logic http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.485r2=1.486diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.485 php-src/ext/standard/file.c:1.486 --- php-src/ext/standard/file.c:1.485 Fri Feb 23 16:21:31 2007 +++ php-src/ext/standard/file.c Sat Mar 3 19:07:51 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.485 2007/02/23 16:21:31 tony2001 Exp $ */ +/* $Id: file.c,v 1.486 2007/03/03 19:07:51 helly Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2697,7 +2697,7 @@ #ifdef ZTS if (VCWD_ACCESS(resolved_path_buff, F_OK)) { RETVAL_FALSE; - } + } else #endif if (UG(unicode)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Fri Feb 23 16:21:31 2007 UTC Modified files: /php-src/ext/standard file.c Log: fix #40606 (umask is not being restored when request is finished) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.484r2=1.485diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.484 php-src/ext/standard/file.c:1.485 --- php-src/ext/standard/file.c:1.484 Tue Feb 13 12:56:10 2007 +++ php-src/ext/standard/file.c Fri Feb 23 16:21:31 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.484 2007/02/13 12:56:10 tony2001 Exp $ */ +/* $Id: file.c,v 1.485 2007/02/23 16:21:31 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1581,7 +1581,7 @@ oldumask = umask(077); - if (BG(umask) != -1) { + if (BG(umask) == -1) { BG(umask) = oldumask; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Tue Feb 13 12:56:10 2007 UTC Modified files: /php-src/ext/standard file.c Log: plug possible leak http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.483r2=1.484diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.483 php-src/ext/standard/file.c:1.484 --- php-src/ext/standard/file.c:1.483 Wed Jan 10 20:12:14 2007 +++ php-src/ext/standard/file.c Tue Feb 13 12:56:10 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.483 2007/01/10 20:12:14 helly Exp $ */ +/* $Id: file.c,v 1.484 2007/02/13 12:56:10 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -568,6 +568,7 @@ if (offset 0 php_stream_seek(stream, offset, SEEK_SET) 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to seek to position %ld in the stream, offset); + php_stream_close(stream); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
helly Wed Jan 10 20:12:14 2007 UTC Modified files: /php-src/ext/standard file.c Log: - Fix mem access http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.482r2=1.483diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.482 php-src/ext/standard/file.c:1.483 --- php-src/ext/standard/file.c:1.482 Mon Jan 1 09:29:31 2007 +++ php-src/ext/standard/file.c Wed Jan 10 20:12:14 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.482 2007/01/01 09:29:31 sebastian Exp $ */ +/* $Id: file.c,v 1.483 2007/01/10 20:12:14 helly Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2425,6 +2425,7 @@ state = PHP_FGETCSV_READY; field_start = field_end = NULL; p += delimiter_len; + if (p = e) break; goto ready_state; } @@ -2446,6 +2447,7 @@ state = PHP_FGETCSV_READY; field_start = field_end = NULL; p += delimiter_len; + if (p = e) break; goto ready_state; } @@ -2546,6 +2548,7 @@ memmove(p, p + enclosure_len, (e - p) - enclosure_len); e -= enclosure_len; p += enclosure_len; + if (p = e) break; goto with_enc; } else { /* Genuine end enclosure, switch state */ @@ -2561,6 +2564,7 @@ p += escape_len + 1; /* Reprocess for ending enclosures */ + if (p = e) break; goto with_enc; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Thu Dec 28 15:03:19 2006 UTC Modified files: /php-src/ext/standard file.c Log: fix ZTS build http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.480r2=1.481diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.480 php-src/ext/standard/file.c:1.481 --- php-src/ext/standard/file.c:1.480 Tue Dec 26 22:34:05 2006 +++ php-src/ext/standard/file.c Thu Dec 28 15:03:19 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.480 2006/12/26 22:34:05 andrei Exp $ */ +/* $Id: file.c,v 1.481 2006/12/28 15:03:19 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1288,7 +1288,7 @@ } if (((php_stream *)what)-readbuf_type == IS_UNICODE) { - u_buf = php_stream_u_get_line((php_stream *) what, NULL_ZSTR, 0, 0, NULL TSRMLS_CC); + u_buf = php_stream_u_get_line((php_stream *) what, NULL_ZSTR, 0, 0, NULL); if (u_buf == NULL) { efree(args); RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c scanf.c scanf.h string.c
andrei Tue Dec 26 22:34:05 2006 UTC Modified files: /php-src/ext/standard file.c scanf.c scanf.h string.c Log: Unicode support in sscanf() and fscanf(). (Tony, Andrei) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.479r2=1.480diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.479 php-src/ext/standard/file.c:1.480 --- php-src/ext/standard/file.c:1.479 Thu Dec 21 00:00:11 2006 +++ php-src/ext/standard/file.c Tue Dec 26 22:34:05 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.479 2006/12/21 00:00:11 tony2001 Exp $ */ +/* $Id: file.c,v 1.480 2006/12/26 22:34:05 andrei Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1246,16 +1246,15 @@ } /* }}} */ -/* {{{ proto mixed fscanf(resource stream, string format [, string ...]) +/* {{{ proto mixed fscanf(resource stream, string format [, string ...]) U Implements a mostly ANSI compatible fscanf() */ -/* UTODO: Accept unicode contents */ PHP_FUNCTION(fscanf) { int result; zval **file_handle, **format_string; - size_t len; int type; char *buf; + UChar *u_buf; void *what; zval ***args; @@ -1271,8 +1270,9 @@ WRONG_PARAM_COUNT; } - file_handle= args[0]; - format_string = args[1]; + file_handle = args[0]; + format_string = args[1]; + what = zend_fetch_resource(file_handle TSRMLS_CC, -1, File-Handle, type, 2, php_file_le_stream(), php_file_le_pstream()); @@ -1287,19 +1287,31 @@ RETURN_FALSE; } + if (((php_stream *)what)-readbuf_type == IS_UNICODE) { + u_buf = php_stream_u_get_line((php_stream *) what, NULL_ZSTR, 0, 0, NULL TSRMLS_CC); + if (u_buf == NULL) { + efree(args); + RETURN_FALSE; + } - buf = php_stream_get_line((php_stream *) what, NULL_ZSTR, 0, len); - if (buf == NULL) { - efree(args); - RETURN_FALSE; - } + convert_to_unicode_ex(format_string); + result = php_u_sscanf_internal(u_buf, Z_USTRVAL_PP(format_string), + argCount, args, 2, return_value TSRMLS_CC); + efree(u_buf); + } else { + buf = php_stream_get_line((php_stream *) what, NULL_ZSTR, 0, NULL); + if (buf == NULL) { + efree(args); + RETURN_FALSE; + } - convert_to_string_ex(format_string); - result = php_sscanf_internal(buf, Z_STRVAL_PP(format_string), - argCount, args, 2, return_value TSRMLS_CC); + convert_to_string_ex(format_string); + result = php_sscanf_internal(buf, Z_STRVAL_PP(format_string), + argCount, args, 2, return_value TSRMLS_CC); + efree(buf); + } efree(args); - efree(buf); if (SCAN_ERROR_WRONG_PARAM_COUNT == result) { WRONG_PARAM_COUNT; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/scanf.c?r1=1.35r2=1.36diff_format=u Index: php-src/ext/standard/scanf.c diff -u php-src/ext/standard/scanf.c:1.35 php-src/ext/standard/scanf.c:1.36 --- php-src/ext/standard/scanf.c:1.35 Tue Sep 19 10:38:31 2006 +++ php-src/ext/standard/scanf.cTue Dec 26 22:34:05 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: scanf.c,v 1.35 2006/09/19 10:38:31 dmitry Exp $ */ +/* $Id: scanf.c,v 1.36 2006/12/26 22:34:05 andrei Exp $ */ /* scanf.c -- @@ -119,6 +119,17 @@ } *ranges; } CharSet; +typedef struct u_CharSet { + int exclude;/* 1 if this is an exclusion set. */ + int nchars; + UChar *chars; + int nranges; + struct u_Range { + UChar start; + UChar end; + } *ranges; +} u_CharSet; + /* * Declarations for functions used only in this file. */ @@ -126,6 +137,9 @@ static char *BuildCharSet(CharSet *cset, char *format); static int CharInSet(CharSet *cset, int ch); static voidReleaseCharSet(CharSet *cset); +static UChar *u_BuildCharSet(u_CharSet *cset, UChar *format); +static int u_CharInSet(u_CharSet *cset, UChar ch); +static voidu_ReleaseCharSet(u_CharSet *cset); static inline void scan_set_error_return(int numVars, zval **return_value); @@ -237,6 +251,114 @@ } /* }}} */ +/* {{{ u_BuildCharSet + *-- + * + * BuildCharSet -- + * + * This function examines a character set format specification + * and builds a CharSet containing the individual characters and + * character ranges specified. + * + * Results: + *
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Wed Dec 20 22:42:59 2006 UTC Modified files: /php-src/ext/standard file.c Log: fix double free on error http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.477r2=1.478diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.477 php-src/ext/standard/file.c:1.478 --- php-src/ext/standard/file.c:1.477 Tue Dec 19 08:59:26 2006 +++ php-src/ext/standard/file.c Wed Dec 20 22:42:59 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.477 2006/12/19 08:59:26 dmitry Exp $ */ +/* $Id: file.c,v 1.478 2006/12/20 22:42:59 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1062,7 +1062,6 @@ fp = VCWD_POPEN(command, posix_mode); if (!fp) { php_error_docref2(NULL TSRMLS_CC, command, mode, E_WARNING, %s, strerror(errno)); - efree(posix_mode); RETVAL_FALSE; } else { php_stream *stream = php_stream_fopen_from_pipe(fp, mode); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Thu Dec 21 00:00:11 2006 UTC Modified files: /php-src/ext/standard file.c Log: fix double free http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.478r2=1.479diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.478 php-src/ext/standard/file.c:1.479 --- php-src/ext/standard/file.c:1.478 Wed Dec 20 22:42:59 2006 +++ php-src/ext/standard/file.c Thu Dec 21 00:00:11 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.478 2006/12/20 22:42:59 tony2001 Exp $ */ +/* $Id: file.c,v 1.479 2006/12/21 00:00:11 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2237,7 +2237,6 @@ /* Types converted, free storage */ efree(delim); efree(enc); - efree(buffer); } else { /* Binary stream with binary delimiter/enclosures/prefetch */ php_fgetcsv_ex(stream, delim, delim_len, enc, enc_len, \\, 1, buffer, buffer_len, return_value TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Tue Dec 12 22:38:31 2006 UTC Modified files: /php-src/ext/standard file.c Log: erm.. somehow this part got here twice http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.475r2=1.476diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.475 php-src/ext/standard/file.c:1.476 --- php-src/ext/standard/file.c:1.475 Fri Dec 8 01:02:49 2006 +++ php-src/ext/standard/file.c Tue Dec 12 22:38:30 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.475 2006/12/08 01:02:49 pollita Exp $ */ +/* $Id: file.c,v 1.476 2006/12/12 22:38:30 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1205,11 +1205,6 @@ php_stream_from_zval(stream, zstream); - if (length 0) { - /* For BC reasons, fgetss() should only return length-1 bytes. */ - length--; - } - if (stream-readbuf_type == IS_UNICODE) { UChar *buf = php_stream_get_line_ex(stream, IS_UNICODE, NULL_ZSTR, 0, length, retlen); UChar *allowed = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Thu Dec 7 09:51:36 2006 UTC Modified files: /php-src/ext/standard file.c Log: Change fgets() behavior back to BC version http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.472r2=1.473diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.472 php-src/ext/standard/file.c:1.473 --- php-src/ext/standard/file.c:1.472 Tue Dec 5 13:45:49 2006 +++ php-src/ext/standard/file.c Thu Dec 7 09:51:36 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.472 2006/12/05 13:45:49 tony2001 Exp $ */ +/* $Id: file.c,v 1.473 2006/12/07 09:51:36 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1114,7 +1114,7 @@ } /* }}} */ -/* {{{ proto string fgets(resource fp[, int length]) U +/* {{{ proto string fgets(resource fp[, int lengthish]) U Get a line from file pointer */ PHPAPI PHP_FUNCTION(fgets) { @@ -1131,6 +1131,11 @@ php_stream_from_zval(stream, zstream); + if (length 0) { + /* For BC reasons, fgets() should only return length-1 bytes. */ + length--; + } + buf.v = php_stream_get_line_ex(stream, stream-readbuf_type, NULL_ZSTR, 0, length, retlen); if (!buf.v) { RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/file fgetss.phpt fgetss1.phpt
tony2001Thu Dec 7 23:00:46 2006 UTC Modified files: /php-src/ext/standard file.c /php-src/ext/standard/tests/filefgetss.phpt fgetss1.phpt Log: MFB tests (they still fail though) fix BC in fgetss() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.473r2=1.474diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.473 php-src/ext/standard/file.c:1.474 --- php-src/ext/standard/file.c:1.473 Thu Dec 7 09:51:36 2006 +++ php-src/ext/standard/file.c Thu Dec 7 23:00:45 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.473 2006/12/07 09:51:36 pollita Exp $ */ +/* $Id: file.c,v 1.474 2006/12/07 23:00:45 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1196,6 +1196,11 @@ php_stream_from_zval(stream, zstream); + if (length 0) { + /* For BC reasons, fgetss() should only return length-1 bytes. */ + length--; + } + if (stream-readbuf_type == IS_UNICODE) { UChar *buf = php_stream_get_line_ex(stream, IS_UNICODE, NULL_ZSTR, 0, length, retlen); UChar *allowed = NULL; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fgetss.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/file/fgetss.phpt diff -u /dev/null php-src/ext/standard/tests/file/fgetss.phpt:1.2 --- /dev/null Thu Dec 7 23:00:46 2006 +++ php-src/ext/standard/tests/file/fgetss.phpt Thu Dec 7 23:00:45 2006 @@ -0,0 +1,83 @@ +--TEST-- +fgetss() tests +--FILE-- +?php + +$filename = dirname(__FILE__)./fgetss.html; + +$array = array( + askasdfasdfbaa\n/bdd, + asdqwi onClick=\hello();\\n, + aaascriptfunction foo() {}/scriptqqq, + asdasda\n asdjeje, + , + some text \nbblah/i, + some another text hoho / + ); + +foreach ($array as $str) { + file_put_contents($filename, $str); + $fp = fopen($filename, r); + var_dump(fgetss($fp)); + var_dump(fgetss($fp)); +} + +foreach ($array as $str) { + file_put_contents($filename, $str); + $fp = fopen($filename, r); + var_dump(fgetss($fp, 10)); + var_dump(fgetss($fp, 10)); +} + +var_dump(fgetss($fp, -10)); +var_dump(fgetss($fp, 0)); +fclose($fp); +var_dump(fgetss($fp, 0)); + [EMAIL PROTECTED]($filename); + +echo Done\n; +? +--EXPECTF-- +string(18) askasdfasdfaa + +string(6) dd +string(6) asdqw + +string(8) +string(23) aaafunction foo() {}qqq +bool(false) +string(6) asdasd +string(0) +bool(false) +bool(false) +string(11) some text + +string(4) blah +string(24) some another text hoho +bool(false) +string(9) askasdfas +string(6) df +string(5) asdqw +string(0) +string(3) aaa +string(7) functio +string(6) asdasd +string(0) +bool(false) +bool(false) +string(9) some text +string(2) + +string(9) some anot +string(9) her text + +Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d +bool(false) + +Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d +bool(false) + +Warning: fgetss(): %d is not a valid stream resource in %s on line %d +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fgetss1.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/file/fgetss1.phpt diff -u /dev/null php-src/ext/standard/tests/file/fgetss1.phpt:1.2 --- /dev/null Thu Dec 7 23:00:46 2006 +++ php-src/ext/standard/tests/file/fgetss1.phptThu Dec 7 23:00:45 2006 @@ -0,0 +1,69 @@ +--TEST-- +more fgetss() tests +--FILE-- +?php + +$filename = dirname(__FILE__)./fgetss1.html; + +$array = array( + askasdfasdfbaa\n/bdd, + asdqwi onClick=\hello();\\n, + aaascriptfunction foo() {}/scriptqqq, + asdasda\n asdjeje, + , + some text \nbblah/i, + some another text hoho / + ); + +foreach ($array as $str) { + file_put_contents($filename, $str); + $fp = fopen($filename, r); + var_dump(fgetss($fp, 1000, i,b,a)); + var_dump(fgetss($fp)); +} + +foreach ($array as $str) { + file_put_contents($filename, $str); + $fp = fopen($filename, r); + var_dump(fgetss($fp, 10)); + var_dump(fgetss($fp, 10, script,a)); +} + [EMAIL PROTECTED]($filename); + +echo Done\n; +? +--EXPECTF-- +string(21) askasdfasdfbaa + +string(6) dd +string(28) asdqwi onClick=hello(); + +string(8) +string(23) aaafunction foo() {}qqq +bool(false) +string(6) asdasd +string(0) +bool(false) +bool(false) +string(11) some text + +string(4) blah +string(24) some another text hoho +bool(false) +string(9) askasdfas +string(6) df +string(5) asdqw +string(0) +string(3) aaa +string(9) tfunctio +string(6) asdasd +string(0) +bool(false) +bool(false) +string(9) some text +string(2) + +string(9) some anot +string(9) her
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Fri Dec 8 01:02:49 2006 UTC Modified files: /php-src/ext/standard file.c Log: More BC bodges for fgets/fgetss http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.474r2=1.475diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.474 php-src/ext/standard/file.c:1.475 --- php-src/ext/standard/file.c:1.474 Thu Dec 7 23:00:45 2006 +++ php-src/ext/standard/file.c Fri Dec 8 01:02:49 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.474 2006/12/07 23:00:45 tony2001 Exp $ */ +/* $Id: file.c,v 1.475 2006/12/08 01:02:49 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1129,13 +1129,15 @@ RETURN_NULL(); } - php_stream_from_zval(stream, zstream); - - if (length 0) { + if (length == 1) { /* For BC reasons, fgets() should only return length-1 bytes. */ + RETURN_FALSE; + } else if (length 1) { length--; } + php_stream_from_zval(stream, zstream); + buf.v = php_stream_get_line_ex(stream, stream-readbuf_type, NULL_ZSTR, 0, length, retlen); if (!buf.v) { RETURN_FALSE; @@ -1180,7 +1182,7 @@ } /* }}} */ -/* {{{ proto string fgetss(resource fp [, int length, string allowable_tags]) U +/* {{{ proto string fgetss(resource fp [, int lengthish, string allowable_tags]) U Get a line from file pointer and strip HTML tags */ PHPAPI PHP_FUNCTION(fgetss) { @@ -1194,6 +1196,13 @@ return; } + if (length == 1) { + /* For BC reasons, fgetss() should only return length-1 bytes. */ + RETURN_FALSE; + } else if (length 1) { + length--; + } + php_stream_from_zval(stream, zstream); if (length 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c file.h /ext/standard/tests/file bug12556.phpt fgetcsv.phpt
pollita Tue Dec 5 04:13:47 2006 UTC Modified files: /php-src/ext/standard file.c file.h /php-src/ext/standard/tests/filebug12556.phpt fgetcsv.phpt Log: Unicode upgrade for fgetcsv() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.469r2=1.470diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.469 php-src/ext/standard/file.c:1.470 --- php-src/ext/standard/file.c:1.469 Wed Nov 22 12:56:26 2006 +++ php-src/ext/standard/file.c Tue Dec 5 04:13:46 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.469 2006/11/22 12:56:26 pajoye Exp $ */ +/* $Id: file.c,v 1.470 2006/12/05 04:13:46 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1932,43 +1932,6 @@ } /* }}} */ -static const char *php_fgetcsv_lookup_trailing_spaces(const char *ptr, size_t len, const char delimiter TSRMLS_DC) -{ - int inc_len; - unsigned char last_chars[2] = { 0, 0 }; - - while (len 0) { - inc_len = (*ptr == '\0' ? 1: php_mblen(ptr, len)); - switch (inc_len) { - case -2: - case -1: - inc_len = 1; - php_mblen(NULL, 0); - break; - case 0: - goto quit_loop; - case 1: - default: - last_chars[0] = last_chars[1]; - last_chars[1] = *ptr; - break; - } - ptr += inc_len; - len -= inc_len; - } -quit_loop: - switch (last_chars[1]) { - case '\n': - if (last_chars[0] == '\r') { - return ptr - 2; - } - /* break is omitted intentionally */ - case '\r': - return ptr - 1; - } - return ptr; -} - #define FPUTCSV_FLD_CHK(c) memchr(Z_STRVAL_PP(field), c, Z_STRLEN_PP(field)) /* {{{ proto int fputcsv(resource fp, array fields [, string delimiter [, string enclosure]]) @@ -2072,87 +2035,149 @@ } /* }}} */ -/* {{{ proto array fgetcsv(resource fp [,int length [, string delimiter [, string enclosure]]]) +/* {{{ proto array fgetcsv(resource fp [,int length [, string delimiter [, string enclosure[, string escape) U Get line from file pointer and parse for CSV fields */ -/* UTODO: Accept unicode contents */ +#define PHP_FGETCSV_TRUNCATE(field) \ +if (argc 4) { \ + /* Caller knows about new semantics since they're using new param, allow multichar */ \ +} else if (field##_type == IS_STRING field##_len 1) { \ + php_error_docref(NULL TSRMLS_CC, E_NOTICE, #field must be a single character); \ + delimiter_len = 1; \ +} else if (field##_type == IS_UNICODE u_countChar32((UChar*)field, field##_len) 1) { \ + int __tmp = 0; \ + php_error_docref(NULL TSRMLS_CC, E_NOTICE, #field must be a single character); \ + U16_FWD_1(((UChar*)field), __tmp, field##_len); \ + field##_len = __tmp; \ +} + PHP_FUNCTION(fgetcsv) { - char delimiter = ','; /* allow this to be set as parameter */ - char enclosure = ''; /* allow this to be set as parameter */ - /* first section exactly as php_fgetss */ - - long len = 0; - size_t buf_len; - char *buf; + zend_uchar delimiter_type = IS_STRING, enclosure_type = IS_STRING, escape_type = IS_STRING; + char *delimiter = ,, *enclosure = \, *escape = \\; + int delimiter_len = 1, enclosure_len = 1, escape_len = 1; + long len = -1; + zstr buf; + int buf_len, argc = ZEND_NUM_ARGS(); php_stream *stream; + zval *zstream; + zend_uchar delimiter_free = 0, enclosure_free = 0, escape_free = 0; - { - zval *fd, **len_zv = NULL; - char *delimiter_str = NULL; - int delimiter_str_len = 0; - char *enclosure_str = NULL; - int enclosure_str_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|Zss, - fd, len_zv, delimiter_str, delimiter_str_len, - enclosure_str, enclosure_str_len) == FAILURE) { - return; - } + if (zend_parse_parameters(argc TSRMLS_CC, r|l!ttt, zstream, len, + delimiter, delimiter_len, delimiter_type, + enclosure, enclosure_len, enclosure_type, + escape,escape_len, escape_type) == FAILURE) { + return; + } - if
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/file bug39538.phpt
pajoye Wed Nov 22 12:56:26 2006 UTC Added files: /php-src/ext/standard/tests/filebug39538.phpt Modified files: /php-src/ext/standard file.c Log: - #39538, fgetcsv can't handle starting newlines and trailing odd number of backslashes (David Soria Parra, Pierre) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.468r2=1.469diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.468 php-src/ext/standard/file.c:1.469 --- php-src/ext/standard/file.c:1.468 Mon Nov 20 11:12:35 2006 +++ php-src/ext/standard/file.c Wed Nov 22 12:56:26 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.468 2006/11/20 11:12:35 tony2001 Exp $ */ +/* $Id: file.c,v 1.469 2006/11/22 12:56:26 pajoye Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2249,6 +2249,11 @@ memcpy(tptr, hunk_begin, bptr - hunk_begin); tptr += (bptr - hunk_begin); hunk_begin = bptr; + if (hunk_begin != line_end) { + memcpy(tptr, hunk_begin, bptr - hunk_begin); + tptr += (bptr - hunk_begin); + hunk_begin = bptr; + } /* add the embedded line end to the field */ memcpy(tptr, line_end, line_end_len); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug39538.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/file/bug39538.phpt +++ php-src/ext/standard/tests/file/bug39538.phpt --TEST-- bug 39538 --FILE-- ?php $content = array(\\nthis is an test\, \next data\, \p\narsed\,\\r\nthis is an test\, \next data\, \p\r\narsed\,\\n\rthis is an test\, \next data\, \p\n\rarsed\); $file = dirname(__FILE__) . /bug39538.csv; @unlink($file); foreach ($content as $v) { file_put_contents($file, $v); print_r (fgetcsv(fopen($file, r), filesize($file))); } @unlink($file); --EXPECT-- Array ( [0] = this is an test [1] = next data [2] = p arsed ) Array ( [0] = this is an test [1] = next data [2] = p arsed ) Array ( [0] = this is an test [1] = next data [2] = p arsed ) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /ext/standard/tests/strings get_meta_tags.phpt
tony2001Mon Nov 13 20:17:06 2006 UTC Added files: /php-src/ext/standard/tests/strings get_meta_tags.phpt Modified files: /php-src/ext/standard file.c Log: fix leaks in get_meta_tags() when used with b0rked HTML add test http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.465r2=1.466diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.465 php-src/ext/standard/file.c:1.466 --- php-src/ext/standard/file.c:1.465 Wed Oct 25 17:28:20 2006 +++ php-src/ext/standard/file.c Mon Nov 13 20:17:05 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.465 2006/10/25 17:28:20 andrei Exp $ */ +/* $Id: file.c,v 1.466 2006/11/13 20:17:05 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -425,6 +425,7 @@ } } else if (tok_last == TOK_EQUAL looking_for_val) { if (saw_name) { + STR_FREE(name); /* Get the NAME attr (Single word attr, non-quoted) */ temp = name = estrndup(md.token_data, md.token_len); @@ -437,6 +438,7 @@ have_name = 1; } else if (saw_content) { + STR_FREE(value); /* Get the CONTENT attr (Single word attr, non-quoted) */ value = estrndup(md.token_data, md.token_len); @@ -459,6 +461,7 @@ } } else if (tok == TOK_STRING tok_last == TOK_EQUAL looking_for_val) { if (saw_name) { + STR_FREE(name); /* Get the NAME attr (Quoted single/double) */ temp = name = estrndup(md.token_data, md.token_len); @@ -471,6 +474,7 @@ have_name = 1; } else if (saw_content) { + STR_FREE(value); /* Get the CONTENT attr (Single word attr, non-quoted) */ value = estrndup(md.token_data, md.token_len); @@ -490,12 +494,13 @@ /* For BC */ php_strtolower(name, strlen(name)); if (have_content) { - add_assoc_utf8_string(return_value, name, value, 0); + add_assoc_utf8_string(return_value, name, value, 1); } else { add_assoc_utf8_string(return_value, name, , 1); } efree(name); + efree(value); } else if (have_content) { efree(value); } @@ -517,6 +522,8 @@ md.token_data = NULL; } + STR_FREE(value); + STR_FREE(name); php_stream_close(md.stream); } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/get_meta_tags.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/strings/get_meta_tags.phpt +++ php-src/ext/standard/tests/strings/get_meta_tags.phpt --TEST-- get_meta_tags() tests --FILE-- ?php $filename = dirname(__FILE__)./get_meta_tags.html; $data = DATA meta name=author content=name meta name=keywords content=php documentation meta name=DESCRIPTION content=a php manual meta name=geo.position content=49.33;-86.59 /head !-- parsing stops here -- DATA; $data1 = DATA html head meta name=author content=name meta name=keywords content=php documentation meta name=DESCRIPTION content=a php manual meta name=geo.position content=49.33;-86.59 /head body meta name=author content=name1 meta name=keywords content=php documentation1 meta name=DESCRIPTION content=a php manual1 meta name=geo.position content=49.33;-86.591 /body /html DATA; $data2 = DATA meta name=author content=name meta name=keywords content=php documentation DATA; $data3 = DATA meta meta name=keywords content=php documentation DATA; $data4 = DATA meta name=author content=name meta name=keywords content=php documentation DATA; $array = array($data, $data1, $data2, $data3, $data4, , , meta); foreach ($array as $html) { file_put_contents($filename, $html); var_dump(get_meta_tags($filename)); } @unlink($filename); echo Done\n; ? --EXPECTF-- array(4) { [author]= string(4) name [keywords]= string(17) php documentation [description]= string(12) a php manual
[PHP-CVS] cvs: php-src /ext/standard file.c
andrei Wed Oct 25 17:28:21 2006 UTC Modified files: /php-src/ext/standard file.c Log: Unicode support for fnmatch(). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.464r2=1.465diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.464 php-src/ext/standard/file.c:1.465 --- php-src/ext/standard/file.c:1.464 Fri Oct 13 01:44:42 2006 +++ php-src/ext/standard/file.c Wed Oct 25 17:28:20 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.464 2006/10/13 01:44:42 iliaa Exp $ */ +/* $Id: file.c,v 1.465 2006/10/25 17:28:20 andrei Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2562,22 +2562,36 @@ /* }}} */ #ifdef HAVE_FNMATCH -/* {{{ proto bool fnmatch(string pattern, string filename [, int flags]) +/* {{{ proto bool fnmatch(string pattern, string filename [, int flags]) U Match filename against pattern */ PHP_FUNCTION(fnmatch) { - char *pattern, *filename; + zstr pattern, filename; int pattern_len, filename_len; + char *pattern_utf8, *filename_utf8; + int pattern_utf8_len, filename_utf8_len; + zend_uchar type; long flags = 0; + UErrorCode status = U_ZERO_ERROR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|l, - pattern, pattern_len, - filename, filename_len, - flags) - == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, TT|l, pattern, + pattern_len, type, filename, filename_len, type, flags) == FAILURE) { return; + } + + if (type == IS_UNICODE) { + zend_unicode_to_string_ex(UG(utf8_conv), pattern_utf8, pattern_utf8_len, pattern.u, pattern_len, status); + zend_unicode_to_string_ex(UG(utf8_conv), filename_utf8, filename_utf8_len, filename.u, filename_len, status); + pattern.s = pattern_utf8; + filename.s = filename_utf8; + } + + RETVAL_BOOL( ! fnmatch( pattern.s, filename.s, flags )); - RETURN_BOOL( ! fnmatch( pattern, filename, flags )); + if (type == IS_UNICODE) { + efree(pattern_utf8); + efree(filename_utf8); + } } /* }}} */ #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Mon Oct 9 02:52:27 2006 UTC Modified files: /php-src/ext/standard file.c Log: Fix realpath() in unicode mode http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.462r2=1.463diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.462 php-src/ext/standard/file.c:1.463 --- php-src/ext/standard/file.c:1.462 Sun Oct 8 13:34:23 2006 +++ php-src/ext/standard/file.c Mon Oct 9 02:52:27 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.462 2006/10/08 13:34:23 bjori Exp $ */ +/* $Id: file.c,v 1.463 2006/10/09 02:52:27 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2432,10 +2432,11 @@ UChar *path; int path_len; - if (php_stream_path_decode(php_plain_files_wrapper, path, path_len, filename, filename_len, REPORT_ERRORS, FG(default_context)) == SUCCESS) { + if (php_stream_path_decode(php_plain_files_wrapper, path, path_len, resolved_path_buff, strlen(resolved_path_buff), REPORT_ERRORS, FG(default_context)) == SUCCESS) { RETVAL_UNICODEL(path, path_len, 0); } else { - RETVAL_FALSE; + /* Fallback */ + RETVAL_STRING(resolved_path_buff, 1); } } else { RETVAL_STRING(resolved_path_buff, 1); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Tue Oct 3 23:09:08 2006 UTC Modified files: /php-src/ext/standard file.c Log: use correct type for p_len http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.460r2=1.461diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.460 php-src/ext/standard/file.c:1.461 --- php-src/ext/standard/file.c:1.460 Mon Oct 2 03:13:47 2006 +++ php-src/ext/standard/file.c Tue Oct 3 23:09:08 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.460 2006/10/02 03:13:47 pollita Exp $ */ +/* $Id: file.c,v 1.461 2006/10/03 23:09:08 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -900,12 +900,11 @@ { zval **ppdir, **ppprefix; char *dir, *prefix; - int dir_len, prefix_len; + int dir_len, prefix_len, p_len; char *opened_path; char *p; int fd; - size_t p_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ZZ, ppdir, ppprefix) == FAILURE) { return; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /main php_streams.h
pollita Mon Oct 2 02:24:29 2006 UTC Modified files: /php-src/main php_streams.h /php-src/ext/standard file.c Log: Try out simplified API for encoding paths/filenames http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.115r2=1.116diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.115 php-src/main/php_streams.h:1.116 --- php-src/main/php_streams.h:1.115Sun Sep 24 20:33:14 2006 +++ php-src/main/php_streams.h Mon Oct 2 02:24:29 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.115 2006/09/24 20:33:14 pollita Exp $ */ +/* $Id: php_streams.h,v 1.116 2006/10/02 02:24:29 pollita Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -388,6 +388,61 @@ END_EXTERN_C() +#define php_stream_path_param_encode(ppzval, ppath, ppath_len, options, context) \ + _php_stream_path_param_encode((ppzval), (ppath), (ppath_len), (options), (context) TSRMLS_CC) +static inline int _php_stream_path_param_encode(zval **ppzval, char **ppath, int *ppath_len, int options, php_stream_context *context TSRMLS_DC) +{ + if (Z_TYPE_PP(ppzval) == IS_UNICODE) { + zval *zpath; + char *path; + int path_len; + + /* Convert the path and put it into a fresh new zval */ + if (FAILURE == php_stream_path_encode(NULL, path, path_len, Z_USTRVAL_PP(ppzval), Z_USTRLEN_PP(ppzval), options, context)) { + return FAILURE; + } + MAKE_STD_ZVAL(zpath); + ZVAL_STRINGL(zpath, path, path_len, 0); + zpath-is_ref = 0; + zpath-refcount = 1; + + /* Replace the param stack with the new zval */ + zval_ptr_dtor(ppzval); + *ppzval = zpath; + } else if (Z_TYPE_PP(ppzval) != IS_STRING) { + if ((*ppzval)-is_ref || + (*ppzval)-refcount 1) { + zval *zpath; + + /* Produce a new zval of type string */ + MAKE_STD_ZVAL(zpath); + *zpath = **ppzval; + zval_copy_ctor(zpath); + convert_to_string(zpath); + zpath-is_ref = 0; + zpath-refcount = 1; + + /* Replace the param stack with it */ + zval_ptr_dtor(ppzval); + *ppzval = zpath; + } else { + /* Convert the value on the param stack directly */ + convert_to_string(*ppzval); + } + } + + /* Populate convenience params if requested */ + if (ppath) { + *ppath = Z_STRVAL_PP(ppzval); + } + if (ppath_len) { + *ppath_len = Z_STRLEN_PP(ppzval); + } + + return SUCCESS; +} + + /* Flags for mkdir method in wrapper ops */ #define PHP_STREAM_MKDIR_RECURSIVE 1 /* define REPORT ERRORS 8 (below) */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.457r2=1.458diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.457 php-src/ext/standard/file.c:1.458 --- php-src/ext/standard/file.c:1.457 Sun Sep 24 21:40:44 2006 +++ php-src/ext/standard/file.c Mon Oct 2 02:24:29 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.457 2006/09/24 21:40:44 pollita Exp $ */ +/* $Id: file.c,v 1.458 2006/10/02 02:24:29 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1016,30 +1016,25 @@ Open a file or a URL and return a file pointer */ PHP_NAMED_FUNCTION(php_if_fopen) { + zval **ppfilename; char *filename, *mode; int filename_len, mode_len; - zend_uchar filename_type; zend_bool use_include_path = 0; zval *zcontext = NULL; php_stream *stream; php_stream_context *context = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ts|br, filename, filename_len, filename_type, - mode, mode_len, use_include_path, zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Zs|br, ppfilename, mode, mode_len, use_include_path, zcontext) == FAILURE) { RETURN_FALSE; } context = php_stream_context_from_zval(zcontext, 0); - if (filename_type == IS_UNICODE) { - if (php_stream_path_encode(NULL, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, context) == FAILURE) { - RETURN_FALSE; - } + if (FAILURE == php_stream_path_param_encode(ppfilename, filename, filename_len, REPORT_ERRORS, context)) { + RETURN_FALSE; } + stream =
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Mon Oct 2 02:47:34 2006 UTC Modified files: /php-src/ext/standard file.c Log: Apply simplified path encoding to copy() and give it a context param. Funnily enough, this makes the copy() implementation almost identical to what it was back in PHP5. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.458r2=1.459diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.458 php-src/ext/standard/file.c:1.459 --- php-src/ext/standard/file.c:1.458 Mon Oct 2 02:24:29 2006 +++ php-src/ext/standard/file.c Mon Oct 2 02:47:34 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.458 2006/10/02 02:24:29 pollita Exp $ */ +/* $Id: file.c,v 1.459 2006/10/02 02:47:34 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1881,49 +1881,28 @@ } /* }}} */ -/* {{{ proto bool copy(string source_file, string destination_file) U +/* {{{ proto bool copy(string source_file, string destination_file[, resource context]) U Copy a file */ PHP_FUNCTION(copy) { - char *source, *dest; - int source_len, dest_len; - zend_uchar source_type, dest_type; - zend_uchar free_source = 0, free_dest = 0; + zval **source, **target, *zcontext = NULL; + php_stream_context *context; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, tt, source, source_len, source_type, dest, dest_len, dest_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ZZ|r, source, target, zcontext) == FAILURE) { return; } - /* Assume failure until success is known */ - RETVAL_FALSE; - - if (source_type == IS_UNICODE) { - if (FAILURE == php_stream_path_encode(NULL, source, source_len, (UChar*)source, source_len, REPORT_ERRORS, FG(default_context))) { - goto copy_cleanup; - } - free_source = 1; - } - if (dest_type == IS_UNICODE) { - if (FAILURE == php_stream_path_encode(NULL, dest, dest_len, (UChar*)dest, dest_len, REPORT_ERRORS, FG(default_context))) { - goto copy_cleanup; - } - free_dest = 1; - } - - if (php_check_open_basedir(source TSRMLS_CC)) { - goto copy_cleanup; - } - - if (php_copy_file(source, dest TSRMLS_CC) == SUCCESS) { - RETVAL_TRUE; + context = php_stream_context_from_zval(zcontext, 0); + if (FAILURE == php_stream_path_param_encode(source, NULL, NULL, REPORT_ERRORS, context) || + FAILURE == php_stream_path_param_encode(target, NULL, NULL, REPORT_ERRORS, context) || + 0 != php_check_open_basedir(Z_STRVAL_PP(source) TSRMLS_CC)) { + RETURN_FALSE; } -copy_cleanup: - if (free_source) { - efree(source); - } - if (free_dest) { - efree(dest); + if (php_copy_file(Z_STRVAL_PP(source), Z_STRVAL_PP(target) TSRMLS_CC)==SUCCESS) { + RETURN_TRUE; + } else { + RETURN_FALSE; } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Mon Oct 2 03:13:47 2006 UTC Modified files: /php-src/ext/standard file.c Log: Apply new path encoding style to the rest of e/s/file.c This layout is definately simpler to maintain and every bit as functional as the other version. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.459r2=1.460diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.459 php-src/ext/standard/file.c:1.460 --- php-src/ext/standard/file.c:1.459 Mon Oct 2 02:47:34 2006 +++ php-src/ext/standard/file.c Mon Oct 2 03:13:47 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.459 2006/10/02 02:47:34 pollita Exp $ */ +/* $Id: file.c,v 1.460 2006/10/02 03:13:47 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -358,9 +358,9 @@ PHP_FUNCTION(get_meta_tags) { + zval **ppfilename; char *filename; int filename_len; - zend_uchar filename_type; zend_bool use_include_path = 0; int in_tag = 0, done = 0; int looking_for_val = 0, have_name = 0, have_content = 0; @@ -373,22 +373,14 @@ memset(md, 0, sizeof(md)); /* Parse arguments */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|b, - filename, filename_len, filename_type, use_include_path) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z|b, ppfilename, use_include_path) == FAILURE || + php_stream_path_param_encode(ppfilename, filename, filename_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { return; } - if (filename_type == IS_UNICODE) { - if (php_stream_path_encode(NULL, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { - RETURN_FALSE; - } - } md.stream = php_stream_open_wrapper(filename, rt, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL); - if (filename_type == IS_UNICODE) { - efree(filename); - } if (!md.stream) { RETURN_FALSE; } @@ -534,9 +526,9 @@ Read the entire file into a string */ PHP_FUNCTION(file_get_contents) { + zval **ppfilename; char *filename; int filename_len; - zend_uchar filename_type; void *contents = NULL; long flags = 0; php_stream *stream; @@ -547,24 +539,18 @@ php_stream_context *context = NULL; /* Parse arguments */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|lr!ll, - filename, filename_len, filename_type, flags, zcontext, offset, maxlen) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z|lr!ll, ppfilename, flags, zcontext, offset, maxlen) == FAILURE) { return; } context = php_stream_context_from_zval(zcontext, 0); - if (filename_type == IS_UNICODE) { - if (php_stream_path_encode(NULL, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, context) == FAILURE) { - RETURN_FALSE; - } + if (php_stream_path_param_encode(ppfilename, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + RETURN_FALSE; } stream = php_stream_open_wrapper_ex(filename, (flags PHP_FILE_TEXT) ? rt : rb, ((flags PHP_FILE_USE_INCLUDE_PATH) ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); - if (filename_type == IS_UNICODE) { - efree(filename); - } if (!stream) { RETURN_FALSE; } @@ -616,9 +602,9 @@ { int argc = ZEND_NUM_ARGS(); php_stream *stream; + zval **ppfilename; char *filename; int filename_len; - zend_uchar filename_type; zval *data; int numchars = 0; long flags = ((argc 3) UG(unicode)) ? PHP_FILE_TEXT : 0; @@ -627,8 +613,7 @@ char mode[3] = { 'w', 0, 0 }; php_stream *srcstream = NULL; - if (zend_parse_parameters(argc TSRMLS_CC, tz/|lr!, filename, filename_len, filename_type, - data, flags, zcontext) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, Zz/|lr!, ppfilename, data, flags, zcontext) == FAILURE) { return; } @@ -637,6 +622,9 @@ } context = php_stream_context_from_zval(zcontext, flags PHP_FILE_NO_DEFAULT_CONTEXT); + if (php_stream_path_param_encode(ppfilename, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + RETURN_FALSE; + } if (flags PHP_FILE_APPEND)
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Sun Sep 24 20:01:29 2006 UTC Modified files: /php-src/ext/standard file.c Log: PHP6 Update for get_meta_tags() -- What a silly function... http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.454r2=1.455diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.454 php-src/ext/standard/file.c:1.455 --- php-src/ext/standard/file.c:1.454 Fri Sep 22 21:48:33 2006 +++ php-src/ext/standard/file.c Sun Sep 24 20:01:29 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.454 2006/09/22 21:48:33 pollita Exp $ */ +/* $Id: file.c,v 1.455 2006/09/24 20:01:29 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -353,7 +353,7 @@ #define PHP_META_UNSAFE .\\+*?[^]$() -/* {{{ proto array get_meta_tags(string filename [, bool use_include_path]) +/* {{{ proto array get_meta_tags(string filename [, bool use_include_path]) U Extracts all meta tag content attributes from a file and returns an array */ PHP_FUNCTION(get_meta_tags) @@ -383,7 +383,7 @@ RETURN_FALSE; } } - md.stream = php_stream_open_wrapper(filename, rb, + md.stream = php_stream_open_wrapper(filename, rt, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL); if (filename_type == IS_UNICODE) { @@ -393,6 +393,31 @@ RETURN_FALSE; } + if (md.stream-readbuf_type == IS_UNICODE) { + /* Either stream auto-applied encoding (which http:// wrapper does do) +* Or the streams layer unicodified it for us */ + zval *filterparams; + php_stream_filter *filter; + + /* Be lazy and convert contents to utf8 again +* This could be made more efficient by detecting if +* it's being upconverted from utf8 and cancelling all conversion +* rather than reconverting, but this is a silly function anyway */ + + MAKE_STD_ZVAL(filterparams); + array_init(filterparams); + add_ascii_assoc_long(filterparams, error_mode, UG(from_error_mode)); + add_ascii_assoc_unicode(filterparams, subst_char, UG(from_subst_char), 1); + filter = php_stream_filter_create(unicode.to.utf8, filterparams, 0 TSRMLS_CC); + zval_ptr_dtor(filterparams); + + if (!filter) { + php_stream_close(md.stream); + RETURN_FALSE; + } + php_stream_filter_append(md.stream-readfilters, filter); + } + array_init(return_value); tok_last = TOK_EOF; @@ -473,9 +498,9 @@ /* For BC */ php_strtolower(name, strlen(name)); if (have_content) { - add_assoc_string(return_value, name, value, 0); + add_assoc_utf8_string(return_value, name, value, 0); } else { - add_assoc_string(return_value, name, , 1); + add_assoc_utf8_string(return_value, name, , 1); } efree(name); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /main php_streams.h /main/streams plain_wrapper.c streams.c
pollita Sun Sep 24 20:33:14 2006 UTC Modified files: /php-src/main php_streams.h /php-src/main/streams streams.c plain_wrapper.c /php-src/ext/standard file.c Log: PHP6 Updates for popen() and related functionality http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.114r2=1.115diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.114 php-src/main/php_streams.h:1.115 --- php-src/main/php_streams.h:1.114Fri Sep 22 19:54:30 2006 +++ php-src/main/php_streams.h Sun Sep 24 20:33:14 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.114 2006/09/22 19:54:30 pollita Exp $ */ +/* $Id: php_streams.h,v 1.115 2006/09/24 20:33:14 pollita Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -561,6 +561,7 @@ PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC); PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC); PHPAPI int php_unregister_url_stream_wrapper_volatile(char *protocol TSRMLS_DC); +PHPAPI void php_stream_fix_encoding(php_stream *stream, const char *mode, php_stream_context *context TSRMLS_DC); PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char **path_for_open, int options TSRMLS_DC); PHPAPI void *php_stream_locate_eol(php_stream *stream, zstr zbuf, int buf_len TSRMLS_DC); http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.136r2=1.137diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.136 php-src/main/streams/streams.c:1.137 --- php-src/main/streams/streams.c:1.136Fri Sep 22 19:54:30 2006 +++ php-src/main/streams/streams.c Sun Sep 24 20:33:14 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.136 2006/09/22 19:54:30 pollita Exp $ */ +/* $Id: streams.c,v 1.137 2006/09/24 20:33:14 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -2285,6 +2285,32 @@ } /* }}} */ +/* {{{ php_stream_fix_encoding + * Sets read/write encoding on a stream based on the fopen mode, context options, and INI setting */ +PHPAPI void php_stream_fix_encoding(php_stream *stream, const char *mode, php_stream_context *context TSRMLS_DC) +{ + /* Output encoding on text mode streams defaults to utf8 unless specified in context parameter */ + if (stream strchr(mode, 't') UG(unicode)) { + /* Only apply implicit unicode.to. filter if the wrapper didn't do it for us */ + if ((php_stream_filter_product(stream-writefilters, IS_UNICODE) == IS_UNICODE) + (strchr(mode, 'w') || strchr(mode, 'a') || strchr(mode, '+'))) { + char *encoding = (context context-output_encoding) ? context-output_encoding : UG(stream_encoding); + + /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via context params */ + php_stream_encoding_apply(stream, 1, encoding, UG(from_error_mode), UG(from_subst_char)); + } + + /* Only apply implicit unicode.from. filter if the wrapper didn't do it for us */ + if ((stream-readbuf_type == IS_STRING) (strchr(mode, 'r') || strchr(mode, '+'))) { + char *encoding = (context context-input_encoding) ? context-input_encoding : UG(stream_encoding); + + /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via context params */ + php_stream_encoding_apply(stream, 0, encoding, UG(to_error_mode), NULL); + } + } +} +/* }}} */ + /* {{{ php_stream_open_wrapper_ex */ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) @@ -2387,25 +2413,8 @@ } } - /* Output encoding on text mode streams defaults to utf8 unless specified in context parameter */ - if (stream strchr(implicit_mode, 't') UG(unicode)) { - /* Only apply implicit unicode.to. filter if the wrapper didn't do it for us */ - if ((php_stream_filter_product(stream-writefilters, IS_UNICODE) == IS_UNICODE) - (strchr(implicit_mode, 'w') || strchr(implicit_mode, 'a') || strchr(implicit_mode, '+'))) { - char *encoding = (context context-output_encoding) ? context-output_encoding : UG(stream_encoding); - /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Sun Sep 24 21:40:45 2006 UTC Modified files: /php-src/ext/standard file.c Log: PHP6 Updates for rmdir/mkdir/rename http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.456r2=1.457diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.456 php-src/ext/standard/file.c:1.457 --- php-src/ext/standard/file.c:1.456 Sun Sep 24 20:33:14 2006 +++ php-src/ext/standard/file.c Sun Sep 24 21:40:44 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.456 2006/09/24 20:33:14 pollita Exp $ */ +/* $Id: file.c,v 1.457 2006/09/24 21:40:44 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1485,6 +1485,7 @@ /* {{{ php_mkdir */ +/* DEPRECATED APIs: Use php_stream_mkdir() instead */ PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC) { int ret; @@ -1506,43 +1507,65 @@ } /* }}} */ -/* {{{ proto bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]]) +/* {{{ proto bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]]) U Create a directory */ PHP_FUNCTION(mkdir) { + char *dir; + int dir_len; + zend_uchar dir_type; zval *zcontext = NULL; long mode = 0777; - int dir_len; zend_bool recursive = 0; - char *dir; php_stream_context *context; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|lbr, dir, dir_len, mode, recursive, zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|lbr, dir, dir_len, dir_type, mode, recursive, zcontext) == FAILURE) { RETURN_FALSE; } context = php_stream_context_from_zval(zcontext, 0); - RETURN_BOOL(php_stream_mkdir(dir, mode, (recursive ? PHP_STREAM_MKDIR_RECURSIVE : 0) | REPORT_ERRORS, context)); + if (dir_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, dir, dir_len, (UChar*)dir, dir_len, REPORT_ERRORS, context)) { + RETURN_FALSE; + } + } + + RETVAL_BOOL(php_stream_mkdir(dir, mode, (recursive ? PHP_STREAM_MKDIR_RECURSIVE : 0) | REPORT_ERRORS, context)); + + if (dir_type == IS_UNICODE) { + efree(dir); + } } /* }}} */ -/* {{{ proto bool rmdir(string dirname[, resource context]) +/* {{{ proto bool rmdir(string dirname[, resource context]) U Remove a directory */ PHP_FUNCTION(rmdir) { char *dir; + int dir_len; + zend_uchar dir_type; zval *zcontext = NULL; php_stream_context *context; - int dir_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|r, dir, dir_len, zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|r, dir, dir_len, dir_type, zcontext) == FAILURE) { RETURN_FALSE; } context = php_stream_context_from_zval(zcontext, 0); - RETURN_BOOL(php_stream_rmdir(dir, REPORT_ERRORS, context)); + if (dir_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, dir, dir_len, (UChar*)dir, dir_len, REPORT_ERRORS, context)) { + RETURN_FALSE; + } + } + + RETVAL_BOOL(php_stream_rmdir(dir, REPORT_ERRORS, context)); + + if (dir_type == IS_UNICODE) { + efree(dir); + } } /* }}} */ @@ -1639,40 +1662,65 @@ } /* }}} */ -/* {{{ proto bool rename(string old_name, string new_name[, resource context]) +/* {{{ proto bool rename(string old_name, string new_name[, resource context]) U Rename a file */ PHP_FUNCTION(rename) { char *old_name, *new_name; int old_name_len, new_name_len; + zend_uchar old_name_type, new_name_type; + zend_uchar free_old_name = 0, free_new_name = 0; zval *zcontext = NULL; php_stream_wrapper *wrapper; php_stream_context *context; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|r, old_name, old_name_len, new_name, new_name_len, zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, tt|r, old_name, old_name_len, old_name_type, new_name, new_name_len, new_name_type, zcontext) == FAILURE) { RETURN_FALSE; } + context = php_stream_context_from_zval(zcontext, 0); + RETVAL_FALSE; + + if (old_name_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, old_name, old_name_len, (UChar*)old_name, old_name_len, REPORT_ERRORS, context)) { + goto rename_cleanup; + } + free_old_name = 1; + } + wrapper = php_stream_locate_url_wrapper(old_name, NULL, 0 TSRMLS_CC); if (!wrapper || !wrapper-wops) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Fri Sep 22 18:23:33 2006 UTC Modified files: /php-src/ext/standard file.c Log: Tweak file_get_contents()'s return value a little http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.451r2=1.452diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.451 php-src/ext/standard/file.c:1.452 --- php-src/ext/standard/file.c:1.451 Tue Sep 19 10:38:31 2006 +++ php-src/ext/standard/file.c Fri Sep 22 18:23:33 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.451 2006/09/19 10:38:31 dmitry Exp $ */ +/* $Id: file.c,v 1.452 2006/09/22 18:23:33 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -512,7 +512,7 @@ char *filename; int filename_len; zend_uchar filename_type; - void *contents; + void *contents = NULL; long flags = 0; php_stream *stream; int len; @@ -552,21 +552,32 @@ if (maxlen = 0 || stream-readbuf_type == IS_STRING) { real_maxlen = maxlen; } else { - /* Allows worst case scenario of each input char being turned into two UChars */ - real_maxlen = (maxlen * 2); + /* Allows worst case scenario of each input char being turned into two UChars +* UTODO: Have this take converter into account, since many never generate surrogate pairs */ + real_maxlen = maxlen * 2; } /* uses mmap if possible */ len = php_stream_copy_to_mem_ex(stream, stream-readbuf_type, contents, real_maxlen, maxlen, 0); - if (stream-readbuf_type == IS_STRING len 0) { - RETVAL_STRINGL(contents, len, 0); - } else if (stream-readbuf_type == IS_UNICODE len 0) { - RETVAL_UNICODEL(contents, len, 0); - } else if (len == 0) { - RETVAL_EMPTY_STRING(); + if (stream-readbuf_type == IS_STRING) { + if (len 0) { + RETVAL_STRINGL(contents, len, 0); + } else { + if (contents) { + efree(contents); + } + RETVAL_EMPTY_STRING(); + } } else { - RETVAL_FALSE; + if (len 0) { + RETVAL_UNICODEL(contents, len, 0); + } else { + if (contents) { + efree(contents); + } + RETVAL_EMPTY_UNICODE(); + } } php_stream_close(stream); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Fri Sep 22 20:02:26 2006 UTC Modified files: /php-src/ext/standard file.c Log: Update copy() for PHP6 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.452r2=1.453diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.452 php-src/ext/standard/file.c:1.453 --- php-src/ext/standard/file.c:1.452 Fri Sep 22 18:23:33 2006 +++ php-src/ext/standard/file.c Fri Sep 22 20:02:26 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.452 2006/09/22 18:23:33 pollita Exp $ */ +/* $Id: file.c,v 1.453 2006/09/22 20:02:26 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1779,23 +1779,45 @@ Copy a file */ PHP_FUNCTION(copy) { - zval **source, **target; + char *source, *dest; + int source_len, dest_len; + zend_uchar source_type, dest_type; + zend_uchar free_source = 0, free_dest = 0; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, source, target) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, tt, source, source_len, source_type, dest, dest_len, dest_type) == FAILURE) { + return; } - convert_to_string_ex(source); - convert_to_string_ex(target); + /* Assume failure until success is known */ + RETVAL_FALSE; - if (php_check_open_basedir(Z_STRVAL_PP(source) TSRMLS_CC)) { - RETURN_FALSE; + if (source_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, source, source_len, (UChar*)source, source_len, REPORT_ERRORS, FG(default_context))) { + goto copy_cleanup; + } + free_source = 1; + } + if (dest_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, dest, dest_len, (UChar*)dest, dest_len, REPORT_ERRORS, FG(default_context))) { + goto copy_cleanup; + } + free_dest = 1; } - if (php_copy_file(Z_STRVAL_PP(source), Z_STRVAL_PP(target) TSRMLS_CC)==SUCCESS) { - RETURN_TRUE; - } else { - RETURN_FALSE; + if (php_check_open_basedir(source TSRMLS_CC)) { + goto copy_cleanup; + } + + if (php_copy_file(source, target TSRMLS_CC) == SUCCESS) { + RETVAL_TRUE; + } + +copy_cleanup: + if (free_source) { + efree(source); + } + if (free_dest) { + efree(dest); } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Fri Sep 22 21:48:33 2006 UTC Modified files: /php-src/ext/standard file.c Log: Fix copy() from last commit and add a few more PHP6 updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.453r2=1.454diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.453 php-src/ext/standard/file.c:1.454 --- php-src/ext/standard/file.c:1.453 Fri Sep 22 20:02:26 2006 +++ php-src/ext/standard/file.c Fri Sep 22 21:48:33 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.453 2006/09/22 20:02:26 pollita Exp $ */ +/* $Id: file.c,v 1.454 2006/09/22 21:48:33 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -896,49 +896,78 @@ } /* }}} */ -/* {{{ proto string tempnam(string dir, string prefix) +/* {{{ proto string tempnam(string dir, string prefix) U Create a unique filename in a directory */ PHP_FUNCTION(tempnam) { - zval **arg1, **arg2; + char *dir, *prefix; + int dir_len, prefix_len; + zend_uchar dir_type, prefix_type; + zend_uchar free_dir = 0, free_prefix = 0; + char *d; char *opened_path; char *p; int fd; size_t p_len; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, arg1, arg2) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, tt, dir, dir_len, dir_type, prefix, prefix_len, prefix_type) == FAILURE) { + return; } - convert_to_string_ex(arg1); - convert_to_string_ex(arg2); - if (php_check_open_basedir(Z_STRVAL_PP(arg1) TSRMLS_CC)) { - RETURN_FALSE; + /* Assume failure until success is assured */ + RETVAL_FALSE; + + if (dir_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, dir, dir_len, (UChar*)dir, dir_len, REPORT_ERRORS, FG(default_context))) { + goto tempnam_cleanup; + } + free_dir = 1; + } + + if (prefix_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, prefix, prefix_len, (UChar*)prefix, prefix_len, REPORT_ERRORS, FG(default_context))) { + goto tempnam_cleanup; + } + free_prefix = 1; } - - d = estrndup(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1)); - php_basename(Z_STRVAL_PP(arg2), Z_STRLEN_PP(arg2), NULL, 0, p, p_len TSRMLS_CC); + if (php_check_open_basedir(dir TSRMLS_CC)) { + goto tempnam_cleanup; + } + + php_basename(prefix, prefix_len, NULL, 0, p, p_len TSRMLS_CC); if (p_len 64) { p[63] = '\0'; } - if ((fd = php_open_temporary_fd(d, p, opened_path TSRMLS_CC)) = 0) { + if ((fd = php_open_temporary_fd(dir, p, opened_path TSRMLS_CC)) = 0) { close(fd); - RETVAL_RT_STRING(opened_path, 0); if (UG(unicode)) { + UChar *utmpnam; + int utmpnam_len; + + if (SUCCESS == php_stream_path_decode(NULL, utmpnam, utmpnam_len, opened_path, strlen(opened_path), REPORT_ERRORS, FG(default_context))) { + RETVAL_UNICODEL(utmpnam, utmpnam_len, 0); + } efree(opened_path); + } else { + RETVAL_STRING(opened_path, 0); } - } else { - RETVAL_FALSE; } efree(p); - efree(d); + +tempnam_cleanup: + if (free_dir) { + efree(dir); + } + if (free_prefix) { + efree(prefix); + } } /* }}} */ -/* {{{ proto resource tmpfile(void) +/* {{{ proto resource tmpfile(void) U Create a temporary file that will be deleted automatically after use */ PHP_NAMED_FUNCTION(php_if_tmpfile) { @@ -1775,7 +1804,7 @@ } /* }}} */ -/* {{{ proto bool copy(string source_file, string destination_file) +/* {{{ proto bool copy(string source_file, string destination_file) U Copy a file */ PHP_FUNCTION(copy) { @@ -1808,7 +1837,7 @@ goto copy_cleanup; } - if (php_copy_file(source, target TSRMLS_CC) == SUCCESS) { + if (php_copy_file(source, dest TSRMLS_CC) == SUCCESS) { RETVAL_TRUE; } @@ -2608,11 +2637,24 @@ /* }}} */ #endif -/* {{{ proto string sys_get_temp_dir() +/* {{{ proto string sys_get_temp_dir() U Returns directory path used for temporary files */ PHP_FUNCTION(sys_get_temp_dir) { - RETURN_STRING((char *)php_get_temporary_directory(), 1); + UChar *utemp_dir; + char *temp_dir = (char *)php_get_temporary_directory(); + int temp_dir_len = strlen(temp_dir), utemp_dir_len; + + if (!UG(unicode)) { +
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Fri Aug 18 12:50:36 2006 UTC Modified files: /php-src/ext/standard file.c Log: add a notice to fgetcsv() when delimiter or enclosure is longer than 1 char (feature request #38496) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.449r2=1.450diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.449 php-src/ext/standard/file.c:1.450 --- php-src/ext/standard/file.c:1.449 Sun Jul 16 15:54:25 2006 +++ php-src/ext/standard/file.c Fri Aug 18 12:50:36 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.449 2006/07/16 15:54:25 tony2001 Exp $ */ +/* $Id: file.c,v 1.450 2006/08/18 12:50:36 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2081,6 +2081,8 @@ if (delimiter_str_len 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, delimiter must be a character); RETURN_FALSE; + } else if (delimiter_str_len 1) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, delimiter must be a single character); } /* use first character from string */ @@ -2091,7 +2093,10 @@ if (enclosure_str_len 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, enclosure must be a character); RETURN_FALSE; + } else if (enclosure_str_len 1) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, enclosure must be a single character); } + /* use first character from string */ enclosure = enclosure_str[0]; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Sun Jul 16 15:54:25 2006 UTC Modified files: /php-src/ext/standard file.c Log: all stream functions are actually macros that already have TSRMLS_CC, no need to pass it manually http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.448r2=1.449diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.448 php-src/ext/standard/file.c:1.449 --- php-src/ext/standard/file.c:1.448 Sat Jul 15 14:31:51 2006 +++ php-src/ext/standard/file.c Sun Jul 16 15:54:25 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.448 2006/07/15 14:31:51 helly Exp $ */ +/* $Id: file.c,v 1.449 2006/07/16 15:54:25 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2422,7 +2422,7 @@ UChar *path; int path_len; - if (php_stream_path_decode(php_plain_files_wrapper, path, path_len, filename, filename_len, REPORT_ERRORS, FG(default_context) TSRMLS_CC) == SUCCESS) { + if (php_stream_path_decode(php_plain_files_wrapper, path, path_len, filename, filename_len, REPORT_ERRORS, FG(default_context)) == SUCCESS) { RETVAL_UNICODEL(path, path_len, 0); } else { RETVAL_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c streamsfuncs.c
tony2001Fri Jul 14 20:45:37 2006 UTC Modified files: /php-src/ext/standard file.c streamsfuncs.c Log: MFB: rephrase the error message (fixes #38106) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.445r2=1.446diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.445 php-src/ext/standard/file.c:1.446 --- php-src/ext/standard/file.c:1.445 Fri Jul 14 19:16:23 2006 +++ php-src/ext/standard/file.c Fri Jul 14 20:45:37 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.445 2006/07/14 19:16:23 pollita Exp $ */ +/* $Id: file.c,v 1.446 2006/07/14 20:45:37 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -545,7 +545,7 @@ } if (offset 0 php_stream_seek(stream, offset, SEEK_SET) 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to seek to %ld position in the stream., offset); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to seek to position %ld in the stream., offset); RETURN_FALSE; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.80r2=1.81diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.80 php-src/ext/standard/streamsfuncs.c:1.81 --- php-src/ext/standard/streamsfuncs.c:1.80Mon Jun 26 11:31:19 2006 +++ php-src/ext/standard/streamsfuncs.c Fri Jul 14 20:45:37 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.80 2006/06/26 11:31:19 bjori Exp $ */ +/* $Id: streamsfuncs.c,v 1.81 2006/07/14 20:45:37 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -397,7 +397,7 @@ php_stream_from_zval(stream, zsrc); if (pos 0 php_stream_seek(stream, pos, SEEK_SET) 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to seek to %ld position in the stream., pos); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to seek to position %ld in the stream., pos); RETURN_FALSE; } @@ -427,7 +427,7 @@ php_stream_from_zval(dest, zdest); if (pos 0 php_stream_seek(src, pos, SEEK_SET) 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to seek to %ld position in the stream., pos); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to seek to position %ld in the stream., pos); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Fri Jul 14 20:50:45 2006 UTC Modified files: /php-src/ext/standard file.c Log: #38105 (4/3) ustrlen != USTRLEN, update variable names used to keep this block's meaning clear http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.446r2=1.447diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.446 php-src/ext/standard/file.c:1.447 --- php-src/ext/standard/file.c:1.446 Fri Jul 14 20:45:37 2006 +++ php-src/ext/standard/file.c Fri Jul 14 20:50:45 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.446 2006/07/14 20:45:37 tony2001 Exp $ */ +/* $Id: file.c,v 1.447 2006/07/14 20:50:45 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -697,12 +697,14 @@ case IS_UNICODE: if (Z_USTRLEN_P(data)) { int ustrlen = u_countChar32(Z_USTRVAL_P(data), Z_USTRLEN_P(data)); - numchars = php_stream_write_unicode(stream, Z_USTRVAL_P(data), Z_USTRLEN_P(data)); - if (numchars 0) { + int wrote_u16 = php_stream_write_unicode(stream, Z_USTRVAL_P(data), Z_USTRLEN_P(data)); + + numchars = ustrlen; + if (wrote_u16 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to write %d characters to %s, ustrlen, filename); numchars = -1; - } else if (numchars != ustrlen) { - int written_numchars = u_countChar32(Z_USTRVAL_P(data), numchars); + } else if (wrote_u16 != Z_USTRLEN_P(data)) { + int written_numchars = u_countChar32(Z_USTRVAL_P(data), wrote_u16); php_error_docref(NULL TSRMLS_CC, E_WARNING, Only %d of %d characters written, possibly out of free disk space, written_numchars, ustrlen); numchars = -1; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Mon May 29 10:42:10 2006 UTC Modified files: /php-src/ext/standard file.c Log: initialize srcstream use different variable in local scope http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.443r2=1.444diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.443 php-src/ext/standard/file.c:1.444 --- php-src/ext/standard/file.c:1.443 Mon May 29 10:23:53 2006 +++ php-src/ext/standard/file.c Mon May 29 10:42:10 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.443 2006/05/29 10:23:53 tony2001 Exp $ */ +/* $Id: file.c,v 1.444 2006/05/29 10:42:10 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -588,7 +588,7 @@ zval *zcontext = NULL; php_stream_context *context = NULL; char mode[3] = { 'w', 0, 0 }; - php_stream *srcstream; + php_stream *srcstream = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, tz/|lr!, filename, filename_len, filename_type, data, flags, zcontext) == FAILURE) { @@ -701,9 +701,9 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to write %d characters to %s, ustrlen, filename); numchars = -1; } else if (numchars != ustrlen) { - int numchars = u_countChar32(Z_USTRVAL_P(data), numchars); + int written_numchars = u_countChar32(Z_USTRVAL_P(data), numchars); - php_error_docref(NULL TSRMLS_CC, E_WARNING, Only %d of %d characters written, possibly out of free disk space, numchars, ustrlen); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Only %d of %d characters written, possibly out of free disk space, written_numchars, ustrlen); numchars = -1; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Tue May 2 18:23:33 2006 UTC Modified files: /php-src/ext/standard file.c Log: Unicode Updates: file() now unicode ready get_meta_tags() updated for FS encoding, but content is still non-unicode http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.439r2=1.440diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.439 php-src/ext/standard/file.c:1.440 --- php-src/ext/standard/file.c:1.439 Fri Apr 28 19:03:57 2006 +++ php-src/ext/standard/file.c Tue May 2 18:23:32 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.439 2006/04/28 19:03:57 fmk Exp $ */ +/* $Id: file.c,v 1.440 2006/05/02 18:23:32 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -360,6 +360,7 @@ { char *filename; int filename_len; + zend_uchar filename_type; zend_bool use_include_path = 0; int in_tag = 0, done = 0; int looking_for_val = 0, have_name = 0, have_content = 0; @@ -372,15 +373,22 @@ memset(md, 0, sizeof(md)); /* Parse arguments */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|b, - filename, filename_len, use_include_path) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|b, + filename, filename_len, filename_type, use_include_path) == FAILURE) { return; } + if (filename_type == IS_UNICODE) { + if (php_stream_path_encode(NULL, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { + RETURN_FALSE; + } + } md.stream = php_stream_open_wrapper(filename, rb, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL); - + if (filename_type == IS_UNICODE) { + efree(filename); + } if (!md.stream) { RETURN_FALSE; } @@ -506,7 +514,6 @@ zend_uchar filename_type; void *contents; long flags = 0; - zend_bool use_include_path = 0; php_stream *stream; int len; long offset = -1; @@ -732,7 +739,7 @@ } /* }}} */ -/* {{{ proto array file(string filename [, int flags[, resource context]]) +/* {{{ proto array file(string filename [, int flags[, resource context]]) U Read entire file into an array */ #define PHP_FILE_BUF_SIZE 80 @@ -742,23 +749,24 @@ { char *filename; int filename_len; - char *target_buf=NULL, *p, *s, *e; + zend_uchar filename_type; + char *target_buf=NULL; register int i = 0; int target_len; - char eol_marker = '\n'; long flags = 0; zend_bool use_include_path; zend_bool include_new_line; zend_bool skip_blank_lines; + zend_bool text_mode; php_stream *stream; zval *zcontext = NULL; php_stream_context *context = NULL; /* Parse arguments */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|lr!, filename, filename_len, flags, zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|lr!, filename, filename_len, filename_type, flags, zcontext) == FAILURE) { return; } - if (flags 0 || flags (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT)) { + if (flags 0 || flags (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT | PHP_FILE_TEXT)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, '%ld' flag is not supported, flags); RETURN_FALSE; } @@ -766,10 +774,19 @@ use_include_path = flags PHP_FILE_USE_INCLUDE_PATH; include_new_line = !(flags PHP_FILE_IGNORE_NEW_LINES); skip_blank_lines = flags PHP_FILE_SKIP_EMPTY_LINES; + text_mode = flags PHP_FILE_TEXT; context = php_stream_context_from_zval(zcontext, flags PHP_FILE_NO_DEFAULT_CONTEXT); - stream = php_stream_open_wrapper_ex(filename, rb, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); + if (filename_type == IS_UNICODE) { + if (php_stream_path_encode(NULL, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + RETURN_FALSE; + } + } + stream = php_stream_open_wrapper_ex(filename, text_mode ? rt : rb, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); + if (filename_type == IS_UNICODE) { + efree(filename); + } if (!stream) { RETURN_FALSE;
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Tue Apr 18 19:10:12 2006 UTC Modified files: /php-src/ext/standard file.c Log: Silence compiler warnings http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.436r2=1.437diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.436 php-src/ext/standard/file.c:1.437 --- php-src/ext/standard/file.c:1.436 Fri Apr 14 17:44:56 2006 +++ php-src/ext/standard/file.c Tue Apr 18 19:10:12 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.436 2006/04/14 17:44:56 pollita Exp $ */ +/* $Id: file.c,v 1.437 2006/04/18 19:10:12 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -504,7 +504,7 @@ char *filename; int filename_len; zend_uchar filename_type; - char *contents; + void *contents; long flags = 0; zend_bool use_include_path = 0; php_stream *stream; @@ -522,7 +522,7 @@ context = php_stream_context_from_zval(zcontext, 0); if (filename_type == IS_UNICODE) { - if (php_stream_path_encode(NULL, filename, filename_len, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + if (php_stream_path_encode(NULL, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, context) == FAILURE) { RETURN_FALSE; } } @@ -599,7 +599,7 @@ } if (filename_type == IS_UNICODE) { - if (php_stream_path_encode(NULL, filename, filename_len, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + if (php_stream_path_encode(NULL, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, context) == FAILURE) { RETURN_FALSE; } } @@ -907,7 +907,7 @@ context = php_stream_context_from_zval(zcontext, 0); if (filename_type == IS_UNICODE) { - if (php_stream_path_encode(NULL, filename, filename_len, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + if (php_stream_path_encode(NULL, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, context) == FAILURE) { RETURN_FALSE; } } @@ -1438,7 +1438,7 @@ } if (filename_type == IS_UNICODE) { - if (php_stream_path_encode(NULL, filename, filename_len, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + if (php_stream_path_encode(NULL, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, context) == FAILURE) { RETURN_FALSE; } } @@ -1561,7 +1561,7 @@ context = php_stream_context_from_zval(zcontext, 0); if (filename_type == IS_UNICODE) { - if (php_stream_path_encode(NULL, filename, filename_len, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + if (php_stream_path_encode(NULL, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, context) == FAILURE) { RETURN_FALSE; } } @@ -2333,7 +2333,7 @@ } if (filename_type == IS_UNICODE) { - if (php_stream_path_encode(php_plain_files_wrapper, filename, filename_len, filename, filename_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { + if (php_stream_path_encode(php_plain_files_wrapper, filename, filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { RETURN_FALSE; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Fri Apr 14 17:44:56 2006 UTC Modified files: /php-src/ext/standard file.c Log: MFB (r-1.409.2.6) copy() should not disrespect open_basedir on source file http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.435r2=1.436diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.435 php-src/ext/standard/file.c:1.436 --- php-src/ext/standard/file.c:1.435 Sat Apr 1 00:05:31 2006 +++ php-src/ext/standard/file.c Fri Apr 14 17:44:56 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.435 2006/04/01 00:05:31 pollita Exp $ */ +/* $Id: file.c,v 1.436 2006/04/14 17:44:56 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1786,7 +1786,7 @@ } safe_to_copy: - srcstream = php_stream_open_wrapper(src, rb, STREAM_DISABLE_OPEN_BASEDIR | REPORT_ERRORS, NULL); + srcstream = php_stream_open_wrapper(src, rb, REPORT_ERRORS, NULL); if (!srcstream) { return ret; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /main php_streams.h /main/streams streams.c ZendEngine2 zend.c zend_globals.h
pollita Fri Mar 31 22:51:37 2006 UTC Modified files: /ZendEngine2zend.c zend_globals.h /php-src/ext/standard file.c /php-src/main php_streams.h /php-src/main/streams streams.c Log: Add API hooks and unicode.filesystem_encoding for handling unicode conversions of filename entries. Normal path conversions will simply use this converter, Certain other protocols (such as http) which specify a required character set (utf8), may override the conversion by defining a path_encode() and/or path_decode() wrapper ops method. http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend.c?r1=1.349r2=1.350diff_format=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.349 ZendEngine2/zend.c:1.350 --- ZendEngine2/zend.c:1.349Thu Mar 30 21:39:15 2006 +++ ZendEngine2/zend.c Fri Mar 31 22:51:37 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: zend.c,v 1.349 2006/03/30 21:39:15 tony2001 Exp $ */ +/* $Id: zend.c,v 1.350 2006/03/31 22:51:37 pollita Exp $ */ #include zend.h #include zend_extensions.h @@ -179,6 +179,7 @@ STD_ZEND_INI_ENTRY(unicode.runtime_encoding, NULL, ZEND_INI_ALL, OnUpdateEncoding, runtime_encoding_conv, zend_unicode_globals, unicode_globals) STD_ZEND_INI_ENTRY(unicode.script_encoding, NULL, ZEND_INI_ALL, OnUpdateEncoding, script_encoding_conv, zend_unicode_globals, unicode_globals) STD_ZEND_INI_ENTRY(unicode.http_input_encoding, NULL, ZEND_INI_ALL, OnUpdateEncoding, http_input_encoding_conv, zend_unicode_globals, unicode_globals) + STD_ZEND_INI_ENTRY(unicode.filesystem_encoding, NULL, ZEND_INI_ALL, OnUpdateEncoding, filesystem_encoding_conv, zend_unicode_globals, unicode_globals) ZEND_INI_END() http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_globals.h?r1=1.154r2=1.155diff_format=u Index: ZendEngine2/zend_globals.h diff -u ZendEngine2/zend_globals.h:1.154 ZendEngine2/zend_globals.h:1.155 --- ZendEngine2/zend_globals.h:1.154Sun Mar 26 06:19:24 2006 +++ ZendEngine2/zend_globals.h Fri Mar 31 22:51:37 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: zend_globals.h,v 1.154 2006/03/26 06:19:24 andrei Exp $ */ +/* $Id: zend_globals.h,v 1.155 2006/03/31 22:51:37 pollita Exp $ */ #ifndef ZEND_GLOBALS_H #define ZEND_GLOBALS_H @@ -299,6 +299,7 @@ UConverter *output_encoding_conv;/* output layer converter */ UConverter *script_encoding_conv;/* default script encoding converter */ UConverter *http_input_encoding_conv;/* http input encoding converter */ + UConverter *filesystem_encoding_conv;/* default filesystem converter (entries, not contents) */ UConverter *utf8_conv; /* all-purpose UTF-8 converter */ uint16_t from_error_mode; http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.433r2=1.434diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.433 php-src/ext/standard/file.c:1.434 --- php-src/ext/standard/file.c:1.433 Thu Mar 30 00:22:51 2006 +++ php-src/ext/standard/file.c Fri Mar 31 22:51:37 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.433 2006/03/30 00:22:51 pollita Exp $ */ +/* $Id: file.c,v 1.434 2006/03/31 22:51:37 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -866,25 +866,34 @@ } /* }}} */ -/* {{{ proto resource fopen(string filename, string mode [, bool use_include_path [, resource context]]) +/* {{{ proto resource fopen(string filename, string mode [, bool use_include_path [, resource context]]) U Open a file or a URL and return a file pointer */ PHP_NAMED_FUNCTION(php_if_fopen) { char *filename, *mode; int filename_len, mode_len; + zend_uchar filename_type; zend_bool use_include_path = 0; zval *zcontext = NULL; php_stream *stream; php_stream_context *context = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|br, filename, filename_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ts|br, filename, filename_len, filename_type, mode, mode_len, use_include_path, zcontext) == FAILURE) { RETURN_FALSE; } context = php_stream_context_from_zval(zcontext, 0); - + + if (filename_type == IS_UNICODE) { + if (php_stream_path_encode(NULL, filename, filename_len, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + RETURN_FALSE; + } + } stream = php_stream_open_wrapper_ex(filename, mode, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); + if (filename_type == IS_UNICODE) { + efree(filename); +
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Sat Apr 1 00:05:31 2006 UTC Modified files: /php-src/ext/standard file.c Log: Update filename handling and mark various functions for unicode safety http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.434r2=1.435diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.434 php-src/ext/standard/file.c:1.435 --- php-src/ext/standard/file.c:1.434 Fri Mar 31 22:51:37 2006 +++ php-src/ext/standard/file.c Sat Apr 1 00:05:31 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.434 2006/03/31 22:51:37 pollita Exp $ */ +/* $Id: file.c,v 1.435 2006/04/01 00:05:31 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -309,7 +309,7 @@ -/* {{{ proto bool flock(resource fp, int operation [, int wouldblock]) +/* {{{ proto bool flock(resource fp, int operation [, int wouldblock]) U Portable file locking */ static int flock_values[] = { LOCK_SH, LOCK_EX, LOCK_UN }; @@ -503,6 +503,7 @@ { char *filename; int filename_len; + zend_uchar filename_type; char *contents; long flags = 0; zend_bool use_include_path = 0; @@ -514,16 +515,24 @@ php_stream_context *context = NULL; /* Parse arguments */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|lr!ll, - filename, filename_len, flags, zcontext, offset, maxlen) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|lr!ll, + filename, filename_len, filename_type, flags, zcontext, offset, maxlen) == FAILURE) { return; } context = php_stream_context_from_zval(zcontext, 0); + if (filename_type == IS_UNICODE) { + if (php_stream_path_encode(NULL, filename, filename_len, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + RETURN_FALSE; + } + } stream = php_stream_open_wrapper_ex(filename, (flags PHP_FILE_TEXT) ? rt : rb, ((flags PHP_FILE_USE_INCLUDE_PATH) ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); + if (filename_type == IS_UNICODE) { + efree(filename); + } if (!stream) { RETURN_FALSE; } @@ -565,6 +574,7 @@ php_stream *stream; char *filename; int filename_len; + zend_uchar filename_type; zval *data; int numchars = 0; long flags = 0; @@ -572,7 +582,7 @@ php_stream_context *context = NULL; char mode[3] = { 'w', 0, 0 }; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sz/|lr!, filename, filename_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, tz/|lr!, filename, filename_len, filename_type, data, flags, zcontext) == FAILURE) { return; } @@ -587,8 +597,19 @@ } else if (flags PHP_FILE_TEXT) { mode[1] = 't'; } + + if (filename_type == IS_UNICODE) { + if (php_stream_path_encode(NULL, filename, filename_len, filename, filename_len, REPORT_ERRORS, context) == FAILURE) { + RETURN_FALSE; + } + } + stream = php_stream_open_wrapper_ex(filename, mode, ((flags PHP_FILE_USE_INCLUDE_PATH) ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); + + if (filename_type == IS_UNICODE) { + efree(filename); + } if (stream == NULL) { RETURN_FALSE; } @@ -906,7 +927,7 @@ } /* }}} */ -/* {{{ proto bool fclose(resource fp) +/* {{{ proto bool fclose(resource fp) U Close an open file pointer */ PHPAPI PHP_FUNCTION(fclose) { @@ -972,7 +993,7 @@ } /* }}} */ -/* {{{ proto int pclose(resource fp) +/* {{{ proto int pclose(resource fp) U Close a file pointer opened by popen() */ PHP_FUNCTION(pclose) { @@ -990,7 +1011,7 @@ } /* }}} */ -/* {{{ proto bool feof(resource fp) +/* {{{ proto bool feof(resource fp) U Test for end-of-file on a file pointer */ PHPAPI PHP_FUNCTION(feof) { @@ -1238,7 +1259,7 @@ } /* }}} */ -/* {{{ proto bool fflush(resource fp) +/* {{{ proto bool fflush(resource fp) U Flushes output */ PHPAPI PHP_FUNCTION(fflush) { @@ -1260,7 +1281,7 @@ } /* }}} */ -/* {{{ proto bool rewind(resource fp) +/* {{{ proto bool rewind(resource fp) U Rewind the position of a file pointer */ PHPAPI PHP_FUNCTION(rewind) { @@ -1280,7 +1301,7 @@ } /* }}} */ -/* {{{ proto int ftell(resource fp) +/* {{{ proto int ftell(resource fp) U Get file pointer's read/write position */ PHPAPI PHP_FUNCTION(ftell) { @@ -1302,7 +1323,7 @@ } /* }}} */ -/* {{{ proto int fseek(resource fp, int offset [, int whence]) +/* {{{
[PHP-CVS] cvs: php-src /ext/standard file.c /main/streams streams.c
pollita Wed Mar 29 22:52:24 2006 UTC Modified files: /php-src/ext/standard file.c /php-src/main/streams streams.c Log: Update php_stream_passthru() to handle unicode data. This updates userspace functions fpassthru() and readfile() UG(output_encoding) is used by php_stream_passthru() to translate unicode stream contents back to an outputable character set. Note: readfile()'s second parameter (use_include_path) has been changed to be a bitmask flags parameter instead. For the most commonly used values (TRUE, 1) this will continue functioning as expected since the value of FILE_USE_INCLUDE_PATH is (coincidentally) 1. The impact to other values should be noted in the migration6 guide. This change makes it possible to allow readfile() to output binary file contents (default) or unicode transcoded contents (using FILE_TEXT flag). http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.431r2=1.432diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.431 php-src/ext/standard/file.c:1.432 --- php-src/ext/standard/file.c:1.431 Wed Mar 29 01:20:42 2006 +++ php-src/ext/standard/file.c Wed Mar 29 22:52:24 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.431 2006/03/29 01:20:42 pollita Exp $ */ +/* $Id: file.c,v 1.432 2006/03/29 22:52:24 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -547,7 +547,7 @@ } /* }}} */ -/* {{{ proto int file_put_contents(string file, mixed data [, int flags [, resource context]]) +/* {{{ proto int file_put_contents(string file, mixed data [, int flags [, resource context]]) U Write/Create a file with contents data and return the number of bytes written */ PHP_FUNCTION(file_put_contents) { @@ -991,7 +991,7 @@ } /* }}} */ -/* {{{ proto string fgets(resource fp[, int length]) +/* {{{ proto string fgets(resource fp[, int length]) U Get a line from file pointer */ PHPAPI PHP_FUNCTION(fgets) { @@ -1021,7 +1021,7 @@ } /* }}} */ -/* {{{ proto string fgetc(resource fp) +/* {{{ proto string fgetc(resource fp) U Get a character from file pointer */ PHPAPI PHP_FUNCTION(fgetc) { @@ -1052,7 +1052,7 @@ } /* }}} */ -/* {{{ proto string fgetss(resource fp [, int length, string allowable_tags]) +/* {{{ proto string fgetss(resource fp [, int length, string allowable_tags]) U Get a line from file pointer and strip HTML tags */ PHPAPI PHP_FUNCTION(fgetss) { @@ -1168,7 +1168,7 @@ } /* }}} */ -/* {{{ proto int fwrite(resource fp, string str [, int length]) +/* {{{ proto int fwrite(resource fp, string str [, int length]) U Binary-safe file write */ PHPAPI PHP_FUNCTION(fwrite) { @@ -1371,26 +1371,30 @@ } /* }}} */ -/* {{{ proto int readfile(string filename [, bool use_include_path[, resource context]]) +/* {{{ proto int readfile(string filename [, int flags[, resource context]]) U Output a file or a URL */ -/* UTODO: Accept unicode contents */ PHP_FUNCTION(readfile) { char *filename; int size = 0; int filename_len; - zend_bool use_include_path = 0; + long flags = 0; zval *zcontext = NULL; php_stream *stream; php_stream_context *context = NULL; + char *mode = rb; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|br!, filename, filename_len, use_include_path, zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|lr!, filename, filename_len, flags, zcontext) == FAILURE) { RETURN_FALSE; } context = php_stream_context_from_zval(zcontext, 0); - stream = php_stream_open_wrapper_ex(filename, rb, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); + if (flags PHP_FILE_TEXT) { + mode = rt; + } + + stream = php_stream_open_wrapper_ex(filename, mode, ((flags PHP_FILE_USE_INCLUDE_PATH) ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); if (stream) { size = php_stream_passthru(stream); php_stream_close(stream); @@ -1429,9 +1433,8 @@ /* }}} */ -/* {{{ proto int fpassthru(resource fp) +/* {{{ proto int fpassthru(resource fp) U Output all remaining data from a file pointer */ -/* UTODO: Accept unicode contents */ PHPAPI PHP_FUNCTION(fpassthru) { zval **arg1; @@ -1733,7 +1736,7 @@ } /* }}} */ -/* {{{ proto string fread(resource fp, int length) +/* {{{ proto string fread(resource fp, int length) U Binary-safe file read */ PHPAPI PHP_FUNCTION(fread) { http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.115r2=1.116diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.115 php-src/main/streams/streams.c:1.116 --- php-src/main/streams/streams.c:1.115Wed Mar 29 01:20:43 2006 +++
[PHP-CVS] cvs: php-src /ext/standard file.c /main php_streams.h /main/streams streams.c
pollita Thu Mar 30 00:22:51 2006 UTC Modified files: /php-src/ext/standard file.c /php-src/main php_streams.h /php-src/main/streams streams.c Log: Make php_stream_copy_to_mem() unicode aware and update userspace function file_get_contents(). Note: fgc()'s second parameter (use_include_path) has been changed to be a bitmask flags parameter instead. For the most commonly used values (TRUE, 1) this will continue functioning as expected since the value of FILE_USE_INCLUDE_PATH is (coincidentally) 1. The impact to other values should be noted in the migration6 guide. This change makes it possible to allow fgc() to return binary file contents (default) or unicode transcoded contents (using FILE_TEXT flag). http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.432r2=1.433diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.432 php-src/ext/standard/file.c:1.433 --- php-src/ext/standard/file.c:1.432 Wed Mar 29 22:52:24 2006 +++ php-src/ext/standard/file.c Thu Mar 30 00:22:51 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.432 2006/03/29 22:52:24 pollita Exp $ */ +/* $Id: file.c,v 1.433 2006/03/30 00:22:51 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -497,32 +497,32 @@ /* }}} */ -/* {{{ proto string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen) +/* {{{ proto string file_get_contents(string filename [, long flags [, resource context [, long offset [, long maxlen) U Read the entire file into a string */ -/* UTODO: Accept unicode contents -- Maybe? Perhaps a binary fetch leaving the script to icu_ucnv_toUnicode() on its own is best? */ PHP_FUNCTION(file_get_contents) { char *filename; int filename_len; char *contents; + long flags = 0; zend_bool use_include_path = 0; php_stream *stream; int len; long offset = -1; - long maxlen = PHP_STREAM_COPY_ALL; + long maxlen = PHP_STREAM_COPY_ALL, real_maxlen; zval *zcontext = NULL; php_stream_context *context = NULL; /* Parse arguments */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|br!ll, - filename, filename_len, use_include_path, zcontext, offset, maxlen) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|lr!ll, + filename, filename_len, flags, zcontext, offset, maxlen) == FAILURE) { return; } context = php_stream_context_from_zval(zcontext, 0); - stream = php_stream_open_wrapper_ex(filename, rb, - (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, + stream = php_stream_open_wrapper_ex(filename, (flags PHP_FILE_TEXT) ? rt : rb, + ((flags PHP_FILE_USE_INCLUDE_PATH) ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); if (!stream) { RETURN_FALSE; @@ -533,9 +533,20 @@ RETURN_FALSE; } + if (maxlen = 0 || stream-readbuf_type == IS_STRING) { + real_maxlen = maxlen; + } else { + /* Allows worst case scenario of each input char being turned into two UChars */ + real_maxlen = (maxlen * 2); + } + /* uses mmap if possible */ - if ((len = php_stream_copy_to_mem(stream, contents, maxlen, 0)) 0) { + len = php_stream_copy_to_mem_ex(stream, stream-readbuf_type, contents, real_maxlen, maxlen, 0); + + if (stream-readbuf_type == IS_STRING len 0) { RETVAL_STRINGL(contents, len, 0); + } else if (stream-readbuf_type == IS_UNICODE len 0) { + RETVAL_UNICODEL(contents, len, 0); } else if (len == 0) { RETVAL_EMPTY_STRING(); } else { http://cvs.php.net/viewcvs.cgi/php-src/main/php_streams.h?r1=1.109r2=1.110diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.109 php-src/main/php_streams.h:1.110 --- php-src/main/php_streams.h:1.109Wed Mar 29 01:20:43 2006 +++ php-src/main/php_streams.h Thu Mar 30 00:22:51 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.109 2006/03/29 01:20:43 pollita Exp $ */ +/* $Id: php_streams.h,v 1.110 2006/03/30 00:22:51 pollita Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -284,6 +284,7 @@ /* Convert using runtime_encoding if necessary -- return unicode */ PHPAPI size_t _php_stream_read_unicode(php_stream *stream, UChar *buf, int maxlen, int maxchars TSRMLS_DC); #define php_stream_read_unicode(stream, buf, maxlen) _php_stream_read_unicode((stream),
[PHP-CVS] cvs: php-src /ext/standard file.c
iliaa Mon Mar 27 23:41:05 2006 UTC Modified files: /php-src/ext/standard file.c Log: MFB51: Check 2nd parameter of tempnam() against path components. http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.429r2=1.430diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.429 php-src/ext/standard/file.c:1.430 --- php-src/ext/standard/file.c:1.429 Fri Mar 24 21:32:39 2006 +++ php-src/ext/standard/file.c Mon Mar 27 23:41:05 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.429 2006/03/24 21:32:39 pollita Exp $ */ +/* $Id: file.c,v 1.430 2006/03/27 23:41:05 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -800,8 +800,9 @@ zval **arg1, **arg2; char *d; char *opened_path; - char p[64]; + char *p; int fd; + size_t p_len; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, arg1, arg2) == FAILURE) { WRONG_PARAM_COUNT; @@ -814,7 +815,11 @@ } d = estrndup(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1)); - strlcpy(p, Z_STRVAL_PP(arg2), sizeof(p)); + + php_basename(Z_STRVAL_PP(arg2), Z_STRLEN_PP(arg2), NULL, 0, p, p_len TSRMLS_CC); + if (p_len 64) { + p[63] = '\0'; + } if ((fd = php_open_temporary_fd(d, p, opened_path TSRMLS_CC)) = 0) { close(fd); @@ -825,6 +830,7 @@ } else { RETVAL_FALSE; } + efree(p); efree(d); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Fri Mar 24 21:32:39 2006 UTC Modified files: /php-src/ext/standard file.c Log: Update fgetss() for unicode http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.428r2=1.429diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.428 php-src/ext/standard/file.c:1.429 --- php-src/ext/standard/file.c:1.428 Fri Mar 17 22:52:55 2006 +++ php-src/ext/standard/file.c Fri Mar 24 21:32:39 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.428 2006/03/17 22:52:55 andrei Exp $ */ +/* $Id: file.c,v 1.429 2006/03/24 21:32:39 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1048,70 +1048,55 @@ /* {{{ proto string fgetss(resource fp [, int length, string allowable_tags]) Get a line from file pointer and strip HTML tags */ -/* UTODO: Accept unicode contents */ PHPAPI PHP_FUNCTION(fgetss) { - zval **fd, **bytes = NULL, **allow=NULL; - size_t len = 0; - size_t actual_len, retval_len; - char *buf = NULL, *retval; - php_stream *stream; - char *allowed_tags=NULL; - int allowed_tags_len=0; - - switch(ZEND_NUM_ARGS()) { - case 1: - if (zend_get_parameters_ex(1, fd) == FAILURE) { - RETURN_FALSE; - } - break; - - case 2: - if (zend_get_parameters_ex(2, fd, bytes) == FAILURE) { - RETURN_FALSE; - } - break; - - case 3: - if (zend_get_parameters_ex(3, fd, bytes, allow) == FAILURE) { - RETURN_FALSE; - } - convert_to_string_ex(allow); - allowed_tags = Z_STRVAL_PP(allow); - allowed_tags_len = Z_STRLEN_PP(allow); - break; + zval *zstream; + php_stream *stream; + long length = 0; + zval **allow = NULL; + size_t retlen = 0; - default: - WRONG_PARAM_COUNT; - /* NOTREACHED */ - break; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|lZ, zstream, length, allow) == FAILURE) { + return; } - PHP_STREAM_TO_ZVAL(stream, fd); + php_stream_from_zval(stream, zstream); + + if (php_stream_reads_unicode(stream)) { + UChar *buf = php_stream_get_line_ex(stream, IS_UNICODE, NULL_ZSTR, 0, length, retlen); + UChar *allowed = NULL; + int allowed_len = 0; - if (bytes != NULL) { - convert_to_long_ex(bytes); - if (Z_LVAL_PP(bytes) = 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Length parameter must be greater than 0); + if (!buf) { RETURN_FALSE; } - len = (size_t) Z_LVAL_PP(bytes); - buf = safe_emalloc(sizeof(char), (len + 1), 0); - /*needed because recv doesnt set null char at end*/ - memset(buf, 0, len + 1); - } + if (allow) { + convert_to_unicode_ex(allow); + allowed = Z_USTRVAL_PP(allow); + allowed_len = Z_USTRLEN_PP(allow); + } + retlen = php_u_strip_tags(buf, retlen, stream-fgetss_state, allowed, allowed_len TSRMLS_CC); - if ((retval = php_stream_get_line(stream, buf, len, actual_len)) == NULL) { - if (buf != NULL) { - efree(buf); + RETURN_UNICODEL(buf, retlen, 0); + } else { + char *buf = php_stream_get_line_ex(stream, IS_STRING, NULL_ZSTR, 0, length, retlen); + char *allowed = NULL; + int allowed_len = 0; + + if (!buf) { + RETURN_FALSE; } - RETURN_FALSE; - } - retval_len = php_strip_tags(retval, actual_len, stream-fgetss_state, allowed_tags, allowed_tags_len); + if (allow) { + convert_to_string_ex(allow); + allowed = Z_STRVAL_PP(allow); + allowed_len = Z_STRLEN_PP(allow); + } + retlen = php_strip_tags(buf, retlen, stream-fgetss_state, allowed, allowed_len); - RETURN_STRINGL(retval, retval_len, 0); + RETURN_STRINGL(buf, retlen, 0); + } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /main php_streams.h /main/streams streams.c
pollita Tue Mar 14 21:15:05 2006 UTC Modified files: /php-src/main php_streams.h /php-src/main/streams streams.c /php-src/ext/standard file.c Log: More stream updates. fgets() will work now as will anything which calls one of the _php_stream_get_line() family of functions. The one exception here is when the legacy defines are used on a unicode stream. At the moment they'll simply return NULL, I'll update these to do sloppy conversion in a bit. 'make (u)test' still doesn't work, but it's a different doesn't work. http://cvs.php.net/viewcvs.cgi/php-src/main/php_streams.h?r1=1.106r2=1.107diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.106 php-src/main/php_streams.h:1.107 --- php-src/main/php_streams.h:1.106Mon Mar 13 04:40:11 2006 +++ php-src/main/php_streams.h Tue Mar 14 21:15:05 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.106 2006/03/13 04:40:11 pollita Exp $ */ +/* $Id: php_streams.h,v 1.107 2006/03/14 21:15:05 pollita Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -320,10 +320,14 @@ PHPAPI int _php_stream_flush(php_stream *stream, int closing TSRMLS_DC); #define php_stream_flush(stream) _php_stream_flush((stream), 0 TSRMLS_CC) -PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen, size_t *returned_len TSRMLS_DC); -#define php_stream_gets(stream, buf, maxlen) _php_stream_get_line((stream), (buf), (maxlen), NULL TSRMLS_CC) +PHPAPI void *_php_stream_get_line(php_stream *stream, int buf_type, zstr buf, size_t maxlen, size_t maxchars, size_t *returned_len TSRMLS_DC); +#define php_stream_get_line(stream, buf, maxlen, retlen) _php_stream_get_line((stream), IS_STRING, ZSTR(buf), (maxlen), 0, (retlen) TSRMLS_CC) +#define php_stream_get_line_ex(stream, buf_type, buf, maxlen, maxchars, retlen) \ + _php_stream_get_line((stream), (buf_type), ZSTR(buf), (maxlen), (maxchars), (retlen) TSRMLS_CC) +#define php_stream_gets(stream, buf, maxlen) _php_stream_get_line((stream), IS_STRING, ZSTR(buf), (maxlen), 0, NULL TSRMLS_CC) +#define php_stream_gets_ex(stream, buf_type, buf, maxlen, maxchars) \ + _php_stream_get_line((stream), (buf_type), ZSTR(buf), (maxlen), (maxchars), NULL TSRMLS_CC) -#define php_stream_get_line(stream, buf, maxlen, retlen) _php_stream_get_line((stream), (buf), (maxlen), (retlen) TSRMLS_CC) PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *returned_len, char *delim, size_t delim_len TSRMLS_DC); PHPAPI UChar *_php_stream_u_get_line(php_stream *stream, UChar *buf, int32_t *pmax_bytes, int32_t *pmax_chars, int *pis_unicode TSRMLS_DC); http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.101r2=1.102diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.101 php-src/main/streams/streams.c:1.102 --- php-src/main/streams/streams.c:1.101Mon Mar 13 20:54:06 2006 +++ php-src/main/streams/streams.c Tue Mar 14 21:15:05 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.101 2006/03/13 20:54:06 pollita Exp $ */ +/* $Id: streams.c,v 1.102 2006/03/14 21:15:05 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -955,18 +955,25 @@ /* If buf == NULL, the buffer will be allocated automatically and will be of an * appropriate length to hold the line, regardless of the line length, memory - * permitting -- returned string will be up to (maxlen-1), last byte holding terminating NULL - * Like php_stream_read(), this will treat unicode streams as ugly binary data (use with caution) */ -PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen, - size_t *returned_len TSRMLS_DC) + * permitting -- returned string will be up to (maxlen-1) units of (maxchars) characters, last byte holding terminating NULL + * Like php_stream_read(), this will (UTODO) treat unicode streams as ugly binary data (use with caution) */ +PHPAPI void *_php_stream_get_line(php_stream *stream, int buf_type, zstr buf, size_t maxlen, size_t maxchars, size_t *returned_len TSRMLS_DC) { size_t avail = 0; size_t current_buf_size = 0; size_t total_copied = 0; int grow_mode = 0; - char *bufstart = buf; + int is_unicode = php_stream_reads_unicode(stream); + int split_surrogate = 0; + zstr bufstart = buf; + + if ((buf_type == IS_STRING is_unicode) || + (buf_type == IS_UNICODE !is_unicode)) { + /* UTODO: Allow
[PHP-CVS] cvs: php-src /ext/standard file.c /main/streams streams.c
pollita Wed Mar 15 00:28:57 2006 UTC Modified files: /php-src/ext/standard file.c /php-src/main/streams streams.c Log: Switch (zstr) casts to use ZSTR() macro. http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.426r2=1.427diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.426 php-src/ext/standard/file.c:1.427 --- php-src/ext/standard/file.c:1.426 Tue Mar 14 21:15:05 2006 +++ php-src/ext/standard/file.c Wed Mar 15 00:28:57 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.426 2006/03/14 21:15:05 pollita Exp $ */ +/* $Id: file.c,v 1.427 2006/03/15 00:28:57 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -749,7 +749,7 @@ s = target_buf; e = target_buf + target_len; - if (!(p = php_stream_locate_eol(stream, (zstr)target_buf, target_len TSRMLS_CC))) { + if (!(p = php_stream_locate_eol(stream, ZSTR(target_buf), target_len TSRMLS_CC))) { p = e; goto parse_eol; } http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.102r2=1.103diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.102 php-src/main/streams/streams.c:1.103 --- php-src/main/streams/streams.c:1.102Tue Mar 14 21:15:05 2006 +++ php-src/main/streams/streams.c Wed Mar 15 00:28:57 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.102 2006/03/14 21:15:05 pollita Exp $ */ +/* $Id: streams.c,v 1.103 2006/03/15 00:28:57 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -1335,7 +1335,7 @@ int ret = 0; if (stream-writefilters.head) { - _php_stream_write_filtered(stream, IS_STRING, (zstr)NULL, 0, closing ? PSFS_FLAG_FLUSH_CLOSE : PSFS_FLAG_FLUSH_INC TSRMLS_CC); + _php_stream_write_filtered(stream, IS_STRING, ZSTR(NULL), 0, closing ? PSFS_FLAG_FLUSH_CLOSE : PSFS_FLAG_FLUSH_INC TSRMLS_CC); } if (stream-ops-flush) { @@ -1352,9 +1352,9 @@ } if (stream-writefilters.head) { - return _php_stream_write_filtered(stream, IS_STRING, (zstr)((char*)buf), count, PSFS_FLAG_NORMAL TSRMLS_CC); + return _php_stream_write_filtered(stream, IS_STRING, ZSTR((void*)buf), count, PSFS_FLAG_NORMAL TSRMLS_CC); } else { - return _php_stream_write_buffer(stream, IS_STRING, (zstr)((char*)buf), count TSRMLS_CC); + return _php_stream_write_buffer(stream, IS_STRING, ZSTR((void*)buf), count TSRMLS_CC); } } @@ -1367,9 +1367,9 @@ } if (stream-writefilters.head) { - ret = _php_stream_write_filtered(stream, IS_UNICODE, (zstr)((UChar*)buf), count, PSFS_FLAG_NORMAL TSRMLS_CC); + ret = _php_stream_write_filtered(stream, IS_UNICODE, ZSTR((void*)buf), count, PSFS_FLAG_NORMAL TSRMLS_CC); } else { - ret = _php_stream_write_buffer(stream, IS_UNICODE, (zstr)((UChar*)buf), count TSRMLS_CC); + ret = _php_stream_write_buffer(stream, IS_UNICODE, ZSTR((void*)buf), count TSRMLS_CC); } return ret; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /main/streams streams.c
derick Mon Mar 13 15:01:44 2006 UTC Modified files: /php-src/main/streams streams.c /php-src/ext/standard file.c Log: This makes file_put_contents() work for: ?php declare(encoding=latin1); $a = 1234å67890; file_put_contents( /tmp/testuc.1, $a); file_put_contents( /tmp/testuc.2, (string) $a); $context = stream_context_create(); stream_context_set_params($context, array( output_encoding = latin1 ) ); file_put_contents( /tmp/testuc.3, $a, FILE_TEXT, $context); file_put_contents( /tmp/testuc.4, (string) $a, FILE_TEXT, $context); ? But it still throws a warning on .3. It's a small design issue that I didn't want to touch right now. http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.99r2=1.100diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.99 php-src/main/streams/streams.c:1.100 --- php-src/main/streams/streams.c:1.99 Mon Mar 13 04:40:11 2006 +++ php-src/main/streams/streams.c Mon Mar 13 15:01:44 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.99 2006/03/13 04:40:11 pollita Exp $ */ +/* $Id: streams.c,v 1.100 2006/03/13 15:01:44 derick Exp $ */ #define _GNU_SOURCE #include php.h @@ -1140,7 +1140,7 @@ stream-ops-seek(stream, stream-position, SEEK_SET, stream-position TSRMLS_CC); } - if (stream-output_encoding) { + if (stream-output_encoding buf_type == IS_UNICODE) { char *dest; int destlen; UErrorCode status = U_ZERO_ERROR; @@ -1150,7 +1150,9 @@ buflen = destlen; } else { /* Sloppy handling, make it a binary buffer */ - buflen = UBYTES(buflen); + if (buf_type != IS_STRING) { + buflen = UBYTES(buflen); + } } while (buflen 0) { http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.424r2=1.425diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.424 php-src/ext/standard/file.c:1.425 --- php-src/ext/standard/file.c:1.424 Mon Mar 13 04:40:11 2006 +++ php-src/ext/standard/file.c Mon Mar 13 15:01:44 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.424 2006/03/13 04:40:11 pollita Exp $ */ +/* $Id: file.c,v 1.425 2006/03/13 15:01:44 derick Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -662,7 +662,7 @@ if (numchars 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to write %d characters to %s, ustrlen, filename); numchars = -1; - } else if (numchars != UBYTES(Z_USTRLEN_P(data))) { + } else if (numchars != ustrlen) { int numchars = u_countChar32(Z_USTRVAL_P(data), numchars); php_error_docref(NULL TSRMLS_CC, E_WARNING, Only %d of %d characters written, possibly out of free disk space, numchars, ustrlen); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c file.h
pajoye Fri Jan 13 04:10:32 2006 UTC Modified files: /php-src/ext/standard file.c file.h Log: - MFB: add php_mkdir_ex http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.414r2=1.415diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.414 php-src/ext/standard/file.c:1.415 --- php-src/ext/standard/file.c:1.414 Sun Jan 1 13:09:55 2006 +++ php-src/ext/standard/file.c Fri Jan 13 04:10:32 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.414 2006/01/01 13:09:55 sniper Exp $ */ +/* $Id: file.c,v 1.415 2006/01/13 04:10:32 pajoye Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1408,10 +1408,10 @@ /* {{{ proto int mkdir(char *dir int mode) */ -PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC) +PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC) { int ret; - + if (PG(safe_mode) (!php_checkuid(dir, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { return -1; } @@ -1420,11 +1420,16 @@ return -1; } - if ((ret = VCWD_MKDIR(dir, (mode_t)mode)) 0) { + if ((ret = VCWD_MKDIR(dir, (mode_t)mode)) 0 (options REPORT_ERRORS) == 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, %s, strerror(errno)); } - return ret; + return ret; +} + +PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC) +{ + return php_mkdir_ex(dir, mode, REPORT_ERRORS TSRMLS_CC); } /* }}} */ http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.h?r1=1.96r2=1.97diff_format=u Index: php-src/ext/standard/file.h diff -u php-src/ext/standard/file.h:1.96 php-src/ext/standard/file.h:1.97 --- php-src/ext/standard/file.h:1.96Sun Jan 1 13:09:55 2006 +++ php-src/ext/standard/file.h Fri Jan 13 04:10:32 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: file.h,v 1.96 2006/01/01 13:09:55 sniper Exp $ */ +/* $Id: file.h,v 1.97 2006/01/13 04:10:32 pajoye Exp $ */ /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */ @@ -72,6 +72,7 @@ PHPAPI int php_le_stream_context(void); PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC); PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC); +PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC); PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC); #define META_DEF_BUFSIZE 8192 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
tony2001Fri Aug 12 15:27:50 2005 EDT Modified files: /php-src/ext/standard file.c Log: fix fgetc() compile warnings http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.410r2=1.411ty=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.410 php-src/ext/standard/file.c:1.411 --- php-src/ext/standard/file.c:1.410 Thu Aug 11 19:35:57 2005 +++ php-src/ext/standard/file.c Fri Aug 12 15:27:45 2005 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.410 2005/08/11 23:35:57 andrei Exp $ */ +/* $Id: file.c,v 1.411 2005/08/12 19:27:45 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1109,13 +1109,13 @@ RETVAL_FALSE; } else { if (is_unicode) { - UChar *ubuf = buf; + UChar *ubuf = (UChar *)buf; int32_t num_u16 = num_bytes 1; ubuf[num_u16] = 0; - RETURN_UNICODEL(ubuf, num_u16, 0); + RETURN_UNICODEL(ubuf, num_u16, 1); } else { buf[1] = 0; - RETURN_STRINGL(buf, 1, 0); + RETURN_STRINGL(buf, 1, 1); } } } @@ -1868,7 +1868,7 @@ buf[num_bytes] = 0; buf[num_bytes + 1] = 0; - RETURN_UNICODEL(buf, num_bytes 1, 0); + RETURN_UNICODEL((UChar *)buf, num_bytes 1, 0); } else { buf[num_bytes] = 0; if (PG(magic_quotes_runtime)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard file.c /main/streams plain_wrapper.c
Was this problem only in PHP5.* ? --Jani On Wed, 6 Apr 2005, Ilia Alshanetsky wrote: iliaa Wed Apr 6 09:57:31 2005 EDT Modified files: /php-src/ext/standardfile.c /php-src/main/streamsplain_wrapper.c Log: Fixed bug #31363 (broken non-blocking flock()). # Patch by ian at snork dot net http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.405r2=1.406ty=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.405 php-src/ext/standard/file.c:1.406 --- php-src/ext/standard/file.c:1.405 Sun Mar 27 10:52:49 2005 +++ php-src/ext/standard/file.c Wed Apr 6 09:57:30 2005 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.405 2005/03/27 15:52:49 iliaa Exp $ */ +/* $Id: file.c,v 1.406 2005/04/06 13:57:30 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -339,13 +339,13 @@ /* flock_values contains all possible actions if (operation 4) we won't block on the lock */ act = flock_values[act - 1] | (operation 4 ? LOCK_NB : 0); - if (!php_stream_lock(stream, act)) { + if (php_stream_lock(stream, act)) { if (operation errno == EWOULDBLOCK arg3 PZVAL_IS_REF(arg3)) { Z_LVAL_P(arg3) = 1; } - RETURN_TRUE; + RETURN_FALSE; } - RETURN_FALSE; + RETURN_TRUE; } /* }}} */ http://cvs.php.net/diff.php/php-src/main/streams/plain_wrapper.c?r1=1.42r2=1.43ty=u Index: php-src/main/streams/plain_wrapper.c diff -u php-src/main/streams/plain_wrapper.c:1.42 php-src/main/streams/plain_wrapper.c:1.43 --- php-src/main/streams/plain_wrapper.c:1.42 Thu Oct 28 01:05:20 2004 +++ php-src/main/streams/plain_wrapper.cWed Apr 6 09:57:30 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: plain_wrapper.c,v 1.42 2004/10/28 05:05:20 tony2001 Exp $ */ +/* $Id: plain_wrapper.c,v 1.43 2005/04/06 13:57:30 iliaa Exp $ */ #include php.h #include php_globals.h @@ -578,7 +578,7 @@ return 0; } - if (!flock(fd, value) || (errno == EWOULDBLOCK value LOCK_NB)) { + if (!flock(fd, value)) { data-lock_flag = value; return 0; } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c /main/streams plain_wrapper.c
iliaa Wed Apr 6 09:57:31 2005 EDT Modified files: /php-src/ext/standard file.c /php-src/main/streams plain_wrapper.c Log: Fixed bug #31363 (broken non-blocking flock()). # Patch by ian at snork dot net http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.405r2=1.406ty=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.405 php-src/ext/standard/file.c:1.406 --- php-src/ext/standard/file.c:1.405 Sun Mar 27 10:52:49 2005 +++ php-src/ext/standard/file.c Wed Apr 6 09:57:30 2005 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.405 2005/03/27 15:52:49 iliaa Exp $ */ +/* $Id: file.c,v 1.406 2005/04/06 13:57:30 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -339,13 +339,13 @@ /* flock_values contains all possible actions if (operation 4) we won't block on the lock */ act = flock_values[act - 1] | (operation 4 ? LOCK_NB : 0); - if (!php_stream_lock(stream, act)) { + if (php_stream_lock(stream, act)) { if (operation errno == EWOULDBLOCK arg3 PZVAL_IS_REF(arg3)) { Z_LVAL_P(arg3) = 1; } - RETURN_TRUE; + RETURN_FALSE; } - RETURN_FALSE; + RETURN_TRUE; } /* }}} */ http://cvs.php.net/diff.php/php-src/main/streams/plain_wrapper.c?r1=1.42r2=1.43ty=u Index: php-src/main/streams/plain_wrapper.c diff -u php-src/main/streams/plain_wrapper.c:1.42 php-src/main/streams/plain_wrapper.c:1.43 --- php-src/main/streams/plain_wrapper.c:1.42 Thu Oct 28 01:05:20 2004 +++ php-src/main/streams/plain_wrapper.cWed Apr 6 09:57:30 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: plain_wrapper.c,v 1.42 2004/10/28 05:05:20 tony2001 Exp $ */ +/* $Id: plain_wrapper.c,v 1.43 2005/04/06 13:57:30 iliaa Exp $ */ #include php.h #include php_globals.h @@ -578,7 +578,7 @@ return 0; } - if (!flock(fd, value) || (errno == EWOULDBLOCK value LOCK_NB)) { + if (!flock(fd, value)) { data-lock_flag = value; return 0; } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
iliaa Sun Mar 27 10:52:49 2005 EDT Modified files: /php-src/ext/standard file.c Log: revert copy patch. http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.404r2=1.405ty=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.404 php-src/ext/standard/file.c:1.405 --- php-src/ext/standard/file.c:1.404 Mon Mar 7 17:10:08 2005 +++ php-src/ext/standard/file.c Sun Mar 27 10:52:49 2005 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.404 2005/03/07 22:10:08 helly Exp $ */ +/* $Id: file.c,v 1.405 2005/03/27 15:52:49 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1700,12 +1700,6 @@ { php_stream *srcstream = NULL, *deststream = NULL; int ret = FAILURE; - struct stat src_s, dest_s; - - /* safety check to ensure that source destination files are not the same file */ - if (stat(src, src_s) || (stat(dest, dest_s) == 0 src_s.st_ino == dest_s.st_ino)) { - return ret; - } srcstream = php_stream_open_wrapper(src, rb, STREAM_DISABLE_OPEN_BASEDIR | REPORT_ERRORS, NULL); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard file.c
Shouldn't you also be comparing device? Inode is not necessarily unique. At 03:29 AM 3/3/2005 +, Ilia Alshanetsky wrote: iliaa Wed Mar 2 22:29:24 2005 EDT Modified files: /php-src/ext/standard file.c Log: Fixed bug #32160 (file truncation in copy() when source destination are the same). http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.398r2=1.399ty=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.398 php-src/ext/standard/file.c:1.399 --- php-src/ext/standard/file.c:1.398 Thu Feb 17 08:56:49 2005 +++ php-src/ext/standard/file.c Wed Mar 2 22:29:23 2005 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.398 2005/02/17 13:56:49 hyanantha Exp $ */ +/* $Id: file.c,v 1.399 2005/03/03 03:29:23 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1699,6 +1699,12 @@ { php_stream *srcstream = NULL, *deststream = NULL; int ret = FAILURE; + struct stat src_s, dest_s; + + /* safety check to ensure that source destination files are not the same file */ + if (stat(src, src_s) || (stat(dest, dest_s) == 0 src_s.st_ino == dest_s.st_ino)) { + return ret; + } srcstream = php_stream_open_wrapper(src, rb, STREAM_DISABLE_OPEN_BASEDIR | REPORT_ERRORS, NULL); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard file.c
Hello Markus, Monday, March 7, 2005, 3:20:57 PM, you wrote: Hi, Marcus Boerger wrote: Modified files: /php-src/ext/standard file.c Log: - Allow length 0 as default (e.g. skip param) [...] if (len 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Length parameter may not be negative); RETURN_FALSE; + } else if (len == 0) { + len = -1; } Does this fix http://bugs.php.net/bug.php?id=31192 ? More or less. You have to set limit to 0. -- Best regards, Marcusmailto:[EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
helly Mon Mar 7 16:28:38 2005 EDT Modified files: /php-src/ext/standard file.c Log: - Delay memory allocation, speeds up faiure case http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.400r2=1.401ty=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.400 php-src/ext/standard/file.c:1.401 --- php-src/ext/standard/file.c:1.400 Sun Mar 6 19:16:18 2005 +++ php-src/ext/standard/file.c Mon Mar 7 16:28:38 2005 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.400 2005/03/07 00:16:18 helly Exp $ */ +/* $Id: file.c,v 1.401 2005/03/07 21:28:38 helly Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1052,7 +1052,7 @@ PHPAPI PHP_FUNCTION(fgetc) { zval **arg1; - char *buf; + char buf[2]; int result; php_stream *stream; @@ -1062,18 +1062,15 @@ PHP_STREAM_TO_ZVAL(stream, arg1); - buf = safe_emalloc(2, sizeof(char), 0); - result = php_stream_getc(stream); if (result == EOF) { - efree(buf); RETVAL_FALSE; } else { buf[0] = result; buf[1] = '\0'; - RETURN_STRINGL(buf, 1, 0); + RETURN_STRINGL(buf, 1, 1); } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
helly Mon Mar 7 16:52:35 2005 EDT Modified files: /php-src/ext/standard file.c Log: - Make maic qutes runtime work if length is specified too http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.401r2=1.402ty=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.401 php-src/ext/standard/file.c:1.402 --- php-src/ext/standard/file.c:1.401 Mon Mar 7 16:28:38 2005 +++ php-src/ext/standard/file.c Mon Mar 7 16:52:34 2005 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.401 2005/03/07 21:28:38 helly Exp $ */ +/* $Id: file.c,v 1.402 2005/03/07 21:52:34 helly Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1240,8 +1240,8 @@ PHP_STREAM_TO_ZVAL(stream, arg1); - if (!arg3 PG(magic_quotes_runtime)) { - buffer = estrndup(Z_STRVAL_PP(arg2), Z_STRLEN_PP(arg2)); + if (PG(magic_quotes_runtime)) { + buffer = estrndup(Z_STRVAL_PP(arg2), num_bytes); php_stripslashes(buffer, num_bytes TSRMLS_CC); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php