[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.459&r2=1.460&diff_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) { +
[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.458&r2=1.459&diff_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 /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.115&r2=1.116&diff_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.457&r2=1.458&diff_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
[PHP-CVS] cvs: php-src /ext/hash hash.c /ext/hash/tests adler32.phpt crc32.phpt gost.phpt haval.phpt hmac-md5.phpt md2.phpt md4.phpt md5.phpt ripemd128.phpt ripemd160.phpt ripemd256.phpt ripemd320.ph
pollita Mon Oct 2 01:38:06 2006 UTC Modified files: /php-src/ext/hash hash.c /php-src/ext/hash/tests adler32.phpt crc32.phpt gost.phpt haval.phpt hmac-md5.phpt md2.phpt md4.phpt md5.phpt ripemd128.phpt ripemd160.phpt ripemd256.phpt ripemd320.phpt sha1.phpt sha256.phpt sha384.phpt sha512.phpt snefru.phpt tiger.phpt whirlpool.phpt Log: Allow hash()/hash_hmac() to accept ascii-unicode data, Update tests to work in unicode.semantics mode. http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.31&r2=1.32&diff_format=u Index: php-src/ext/hash/hash.c diff -u php-src/ext/hash/hash.c:1.31 php-src/ext/hash/hash.c:1.32 --- php-src/ext/hash/hash.c:1.31Wed Sep 20 01:48:06 2006 +++ php-src/ext/hash/hash.c Mon Oct 2 01:38:05 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: hash.c,v 1.31 2006/09/20 01:48:06 pollita Exp $ */ +/* $Id: hash.c,v 1.32 2006/10/02 01:38:05 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -84,9 +84,12 @@ RETURN_FALSE; } } else { - /* Unicode string passed for raw hashing */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unicode strings can not be hashed. Convert to a binary type."); - RETURN_FALSE; + data = zend_unicode_to_ascii((UChar*)data, data_len TSRMLS_CC); + if (!data) { + /* Non-ASCII Unicode string passed for raw hashing */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received"); + RETURN_FALSE; + } } } #else @@ -94,25 +97,19 @@ return; } #endif + /* Assume failure */ + RETVAL_FALSE; ops = php_hash_fetch_ops(algo, algo_len); if (!ops) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing algorithm: %s", algo); - if (data_type != IS_STRING) { - /* Original filename was UNICODE, this string is a converted copy */ - efree(data); - } - RETURN_FALSE; + goto hash_done; } if (isfilename) { stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT); - if (data_type != IS_STRING) { - /* Original filename was UNICODE, this string is a converted copy */ - efree(data); - } if (!stream) { /* Stream will report errors opening file */ - RETURN_FALSE; + goto hash_done; } } @@ -137,14 +134,27 @@ if (raw_output) { digest[ops->digest_size] = 0; - RETURN_STRINGL(digest, ops->digest_size, 0); + + /* Raw output is binary only */ + RETVAL_STRINGL(digest, ops->digest_size, 0); } else { char *hex_digest = safe_emalloc(ops->digest_size, 2, 1); php_hash_bin2hex(hex_digest, (unsigned char *) digest, ops->digest_size); hex_digest[2 * ops->digest_size] = 0; efree(digest); - RETURN_STRINGL(hex_digest, 2 * ops->digest_size, 0); + + /* hexits can be binary or unicode */ +#if PHP_MAJOR_VERSION >= 6 + RETVAL_RT_STRINGL(hex_digest, 2 * ops->digest_size, ZSTR_AUTOFREE); +#else + RETVAL_STRINGL(hex_digest, 2 * ops->digest_size, 0); +#endif + } + +hash_done: + if (data_type != IS_STRING) { + efree(data); } } @@ -168,14 +178,14 @@ { char *algo, *data, *digest, *key, *K; int algo_len, data_len, key_len, i; - zend_uchar data_type = IS_STRING; + zend_uchar data_type = IS_STRING, key_type = IS_STRING; zend_bool raw_output = 0; php_hash_ops *ops; void *context; php_stream *stream = NULL; #if PHP_MAJOR_VERSION >= 6 - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "stS|b", &algo, &algo_len, &data, &data_len, &data_type, &key, &key_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "stt|b", &algo, &algo_len, &data, &data_len, &data_type, &key, &key_len, &key_type, &raw_output) == FAILURE) { return; } @@ -185,8 +195,22 @@ RETURN_FALSE; } } else { - /* Uni
[PHP-CVS] cvs: php-src /ext/standard php_string.h string.c
pollita Mon Oct 2 01:11:05 2006 UTC Modified files: /php-src/ext/standard php_string.h string.c Log: ZTS fix http://cvs.php.net/viewvc.cgi/php-src/ext/standard/php_string.h?r1=1.101&r2=1.102&diff_format=u Index: php-src/ext/standard/php_string.h diff -u php-src/ext/standard/php_string.h:1.101 php-src/ext/standard/php_string.h:1.102 --- php-src/ext/standard/php_string.h:1.101 Wed Aug 30 18:40:26 2006 +++ php-src/ext/standard/php_string.h Mon Oct 2 01:11:04 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: php_string.h,v 1.101 2006/08/30 18:40:26 iliaa Exp $ */ +/* $Id: php_string.h,v 1.102 2006/10/02 01:11:04 pollita Exp $ */ /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */ @@ -133,7 +133,7 @@ PHPAPI void php_basename(char *s, int len, char *suffix, int sufflen, char **p_ret, int *p_len TSRMLS_DC); PHPAPI int php_u_dirname(UChar *str, int len); PHPAPI int php_dirname(char *str, int len); -PHPAPI UChar *php_u_stristr(UChar *s, UChar *t, int s_len, int t_len); +PHPAPI UChar *php_u_stristr(UChar *s, UChar *t, int s_len, int t_len TSRMLS_DC); PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len); PHPAPI int php_u_strspn(UChar *s1, UChar *s2, UChar *s1_end, UChar *s2_end); PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.594&r2=1.595&diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.594 php-src/ext/standard/string.c:1.595 --- php-src/ext/standard/string.c:1.594 Fri Sep 29 21:00:07 2006 +++ php-src/ext/standard/string.c Mon Oct 2 01:11:04 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.594 2006/09/29 21:00:07 andrei Exp $ */ +/* $Id: string.c,v 1.595 2006/10/02 01:11:04 pollita Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -2156,7 +2156,7 @@ /* {{{ php_u_stristr Unicode version of case insensitve strstr */ -PHPAPI UChar *php_u_stristr(UChar *str, UChar *pat, int str_len, int pat_len) +PHPAPI UChar *php_u_stristr(UChar *str, UChar *pat, int str_len, int pat_len TSRMLS_DC) { UChar *str_fold, *pat_fold; int str_fold_len, pat_fold_len; @@ -2192,7 +2192,7 @@ } #if 0 -PHPAPI UChar *php_u_stristr(UChar *s, UChar *t, int s_len, int t_len) +PHPAPI UChar *php_u_stristr(UChar *s, UChar *t, int s_len, int t_len TSRMLS_DC) { int32_t i,j, last; UChar32 ch1, ch2; @@ -2394,7 +2394,7 @@ if (Z_TYPE_PP(haystack) == IS_UNICODE) { found = php_u_stristr(Z_USTRVAL_PP(haystack), target.u, - Z_USTRLEN_PP(haystack), needle_len); + Z_USTRLEN_PP(haystack), needle_len TSRMLS_CC); } else { haystack_copy = estrndup(Z_STRVAL_PP(haystack), Z_STRLEN_PP(haystack)); found = php_stristr(Z_STRVAL_PP(haystack), target.s, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard md5.c sha1.c
pollita Mon Oct 2 00:32:13 2006 UTC Modified files: /php-src/ext/standard md5.c sha1.c Log: Allow unicode-ascii to binary conversion and do proper path conversion for file variants http://cvs.php.net/viewvc.cgi/php-src/ext/standard/md5.c?r1=1.47&r2=1.48&diff_format=u Index: php-src/ext/standard/md5.c diff -u php-src/ext/standard/md5.c:1.47 php-src/ext/standard/md5.c:1.48 --- php-src/ext/standard/md5.c:1.47 Sun Sep 24 17:09:46 2006 +++ php-src/ext/standard/md5.c Mon Oct 2 00:32:13 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: md5.c,v 1.47 2006/09/24 17:09:46 pollita Exp $ */ +/* $Id: md5.c,v 1.48 2006/10/02 00:32:13 pollita Exp $ */ /* * md5.c - Copyright 1997 Lachlan Roche @@ -25,6 +25,7 @@ #include "php.h" #include "md5.h" +#include "ext/standard/file.h" PHPAPI void make_digest(char *md5str, unsigned char *digest) { @@ -44,26 +45,38 @@ { char *arg; int arg_len; + zend_uchar arg_type; zend_bool raw_output = 0; char md5str[33]; PHP_MD5_CTX context; unsigned char digest[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|b", &arg, &arg_len, &arg_type, &raw_output) == FAILURE) { return; } + + if (arg_type == IS_UNICODE) { + arg = zend_unicode_to_ascii((UChar*)arg, arg_len TSRMLS_CC); + if (!arg) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received"); + RETURN_FALSE; + } + } md5str[0] = '\0'; PHP_MD5Init(&context); PHP_MD5Update(&context, (unsigned char*)arg, arg_len); PHP_MD5Final(digest, &context); if (raw_output) { - RETURN_STRINGL((char*)digest, 16, 1); + RETVAL_STRINGL((char*)digest, 16, 1); } else { make_digest(md5str, digest); RETVAL_ASCII_STRING(md5str, ZSTR_DUPLICATE); } + if (arg_type == IS_UNICODE) { + efree(arg); + } } /* }}} */ @@ -73,6 +86,7 @@ { char *arg; int arg_len; + zend_uchararg_type; zend_bool raw_output = 0; char md5str[33]; unsigned char buf[1024]; @@ -81,11 +95,20 @@ int n; php_stream*stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|b", &arg, &arg_len, &arg_type, &raw_output) == FAILURE) { return; } + + if (arg_type == IS_UNICODE) { + if (php_stream_path_encode(NULL, &arg, &arg_len, (UChar*)arg, arg_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { + RETURN_FALSE; + } + } stream = php_stream_open_wrapper(arg, "rb", REPORT_ERRORS, NULL); + if (arg_type == IS_UNICODE) { + efree(arg); + } if (!stream) { RETURN_FALSE; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/sha1.c?r1=1.18&r2=1.19&diff_format=u Index: php-src/ext/standard/sha1.c diff -u php-src/ext/standard/sha1.c:1.18 php-src/ext/standard/sha1.c:1.19 --- php-src/ext/standard/sha1.c:1.18Sun Sep 24 17:09:46 2006 +++ php-src/ext/standard/sha1.c Mon Oct 2 00:32:13 2006 @@ -16,9 +16,10 @@ +--+ */ -/* $Id: sha1.c,v 1.18 2006/09/24 17:09:46 pollita Exp $ */ +/* $Id: sha1.c,v 1.19 2006/10/02 00:32:13 pollita Exp $ */ #include "php.h" +#include "ext/standard/file.h" /* This code is heavily based on the PHP md5 implementation */ @@ -42,26 +43,38 @@ { char *arg; int arg_len; + zend_uchar arg_type; zend_bool raw_output = 0; char sha1str[41]; PHP_SHA1_CTX context; unsigned char digest[20]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|b", &arg, &arg_len, &arg_type, &raw_output) == FAILURE) { return; } + if (arg_type == IS_UNICODE) { + arg = zend_unicode_to_ascii((UChar*)arg, arg_len TSRMLS_CC); + if (!arg) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received"); + RETURN_FALSE; + } + } + sha1str[0] = '\0'; PHP_SHA1Init(&context); PHP_SHA1Update(&context, (unsigned char*)arg
[PHP-CVS] cvs: php-src /ext/standard dns.c
pollita Mon Sep 25 02:27:24 2006 UTC Modified files: /php-src/ext/standard dns.c Log: PHP6 Updates and some very minor feature add in dns_get_record() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dns.c?r1=1.80&r2=1.81&diff_format=u Index: php-src/ext/standard/dns.c diff -u php-src/ext/standard/dns.c:1.80 php-src/ext/standard/dns.c:1.81 --- php-src/ext/standard/dns.c:1.80 Tue Sep 19 10:38:31 2006 +++ php-src/ext/standard/dns.c Mon Sep 25 02:27:24 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: dns.c,v 1.80 2006/09/19 10:38:31 dmitry Exp $ */ +/* $Id: dns.c,v 1.81 2006/09/25 02:27:24 pollita Exp $ */ /* {{{ includes */ #include "php.h" @@ -119,22 +119,21 @@ static char *php_gethostbyaddr(char *ip); static char *php_gethostbyname(char *name); -/* {{{ proto string gethostbyaddr(string ip_address) +/* {{{ proto string gethostbyaddr(string ip_address) U Get the Internet host name corresponding to a given IP address */ PHP_FUNCTION(gethostbyaddr) { - zval **arg; - char *addr; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - ZEND_WRONG_PARAM_COUNT(); - } + char *addr; + int addr_len; + char *hostname; - convert_to_string_ex(arg); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addr, &addr_len) == FAILURE) { + return; + } - addr = php_gethostbyaddr(Z_STRVAL_PP(arg)); + hostname = php_gethostbyaddr(addr); - if (addr == NULL) { + if (hostname == NULL) { #if HAVE_IPV6 && HAVE_INET_PTON php_error_docref(NULL TSRMLS_CC, E_WARNING, "Address is not a valid IPv4 or IPv6 address"); #else @@ -142,10 +141,7 @@ #endif RETVAL_FALSE; } else { - RETVAL_RT_STRING(addr, 0); - if (UG(unicode)) { - efree(addr); - } + RETVAL_RT_STRING(hostname, ZSTR_AUTOFREE); } } /* }}} */ @@ -185,42 +181,39 @@ } /* }}} */ -/* {{{ proto string gethostbyname(string hostname) +/* {{{ proto string gethostbyname(string hostname) U Get the IP address corresponding to a given Internet host name */ PHP_FUNCTION(gethostbyname) { - zval **arg; - char *tmp; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - ZEND_WRONG_PARAM_COUNT(); + char *hostname; + int hostname_len; + char *addr; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &hostname_len) == FAILURE) { + return; } - convert_to_string_ex(arg); + addr = php_gethostbyname(hostname); - tmp = php_gethostbyname(Z_STRVAL_PP(arg)); - RETVAL_RT_STRING(tmp, 0); - if (UG(unicode)) { - efree(tmp); - } + RETVAL_RT_STRING(addr, ZSTR_AUTOFREE); } /* }}} */ -/* {{{ proto array gethostbynamel(string hostname) +/* {{{ proto array gethostbynamel(string hostname) U Return a list of IP addresses that a given hostname resolves to. */ PHP_FUNCTION(gethostbynamel) { - zval **arg; + char *hostname; + int hostname_len; struct hostent *hp; struct in_addr in; int i; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - ZEND_WRONG_PARAM_COUNT(); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &hostname_len) == FAILURE) { + return; } - convert_to_string_ex(arg); - hp = gethostbyname(Z_STRVAL_PP(arg)); + hp = gethostbyname(hostname); if (hp == NULL || hp->h_addr_list == NULL) { RETURN_FALSE; } @@ -229,7 +222,7 @@ for (i = 0 ; hp->h_addr_list[i] != 0 ; i++) { in = *(struct in_addr *) hp->h_addr_list[i]; - add_next_index_rt_string(return_value, inet_ntoa(in), 1); + add_next_index_rt_string(return_value, inet_ntoa(in), ZSTR_DUPLICATE); } } /* }}} */ @@ -254,55 +247,41 @@ #if HAVE_RES_SEARCH && !(defined(__BEOS__)||defined(PHP_WIN32) || defined(NETWARE)) -/* {{{ proto int dns_check_record(string host [, string type]) +/* {{{ proto int dns_check_record(string host [, string type]) U Check DNS records corresponding to a given Internet host name or IP address */ PHP_FUNCTION(dns_check_record) { - zval **arg1, **arg2; - int type, i; #ifndef MAXPACKET #define MAXPACKET 8192 /* max packet size used internally by BIND */ #endif u_char ans[MAXPACKET]; + char *hostname, *rectype = NULL; + int hostname_len, rectype_len = 0; + int type = T_MX, i; - switch (ZEND_NUM_ARGS()) { - case 1: - if (zend_get_parameters_ex(1, &arg1) == FAILUR
[PHP-CVS] cvs: php-src /ext/standard type.c
pollita Mon Sep 25 01:37:55 2006 UTC Modified files: /php-src/ext/standard type.c Log: Make settype($var, 'string'); behave like $var = (string)$var; e.g. switch between (binary) and (unicode) depending on UG(unicode) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/type.c?r1=1.43&r2=1.44&diff_format=u Index: php-src/ext/standard/type.c diff -u php-src/ext/standard/type.c:1.43 php-src/ext/standard/type.c:1.44 --- php-src/ext/standard/type.c:1.43Sun Sep 24 18:23:47 2006 +++ php-src/ext/standard/type.c Mon Sep 25 01:37:55 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: type.c,v 1.43 2006/09/24 18:23:47 pollita Exp $ */ +/* $Id: type.c,v 1.44 2006/09/25 01:37:55 pollita Exp $ */ #include "php.h" #include "php_incomplete_class.h" @@ -113,9 +113,15 @@ convert_to_double(*var); } else if (!strcasecmp(new_type, "double")) { /* deprecated */ convert_to_double(*var); - } else if (!strcasecmp(new_type, "string")) { + } else if (!strcasecmp(new_type, "binary")) { /* explicit binary cast */ convert_to_string(*var); - } else if (!strcasecmp(new_type, "unicode")) { + } else if (!strcasecmp(new_type, "string")) { /* runtime string type */ + if (UG(unicode)) { + convert_to_unicode(*var); + } else { + convert_to_string(*var); + } + } else if (!strcasecmp(new_type, "unicode")) { /* explicit unicode cast */ convert_to_unicode(*var); } else if (!strcasecmp(new_type, "array")) { convert_to_array(*var); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard crc32.c crypt.c
pollita Mon Sep 25 01:33:57 2006 UTC Modified files: /php-src/ext/standard crc32.c crypt.c Log: Flag a couple more unicode ready functions http://cvs.php.net/viewvc.cgi/php-src/ext/standard/crc32.c?r1=1.19&r2=1.20&diff_format=u Index: php-src/ext/standard/crc32.c diff -u php-src/ext/standard/crc32.c:1.19 php-src/ext/standard/crc32.c:1.20 --- php-src/ext/standard/crc32.c:1.19 Thu Feb 9 15:48:18 2006 +++ php-src/ext/standard/crc32.cMon Sep 25 01:33:57 2006 @@ -16,13 +16,13 @@ +--+ */ -/* $Id: crc32.c,v 1.19 2006/02/09 15:48:18 pajoye Exp $ */ +/* $Id: crc32.c,v 1.20 2006/09/25 01:33:57 pollita Exp $ */ #include "php.h" #include "basic_functions.h" #include "crc32.h" -/* {{{ proto string crc32(string str) +/* {{{ proto string crc32(string str) U Calculate the crc32 polynomial of a string */ PHP_NAMED_FUNCTION(php_if_crc32) { @@ -31,7 +31,7 @@ php_uint32 crcinit = 0; register php_uint32 crc; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &p, &nr) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &p, &nr) == FAILURE) { return; } crc = crcinit^0x; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/crypt.c?r1=1.63&r2=1.64&diff_format=u Index: php-src/ext/standard/crypt.c diff -u php-src/ext/standard/crypt.c:1.63 php-src/ext/standard/crypt.c:1.64 --- php-src/ext/standard/crypt.c:1.63 Sun Jan 1 13:09:55 2006 +++ php-src/ext/standard/crypt.cMon Sep 25 01:33:57 2006 @@ -17,7 +17,7 @@ | Rasmus Lerdorf <[EMAIL PROTECTED]> | +--+ */ -/* $Id: crypt.c,v 1.63 2006/01/01 13:09:55 sniper Exp $ */ +/* $Id: crypt.c,v 1.64 2006/09/25 01:33:57 pollita Exp $ */ #include #include "php.h" @@ -111,8 +111,8 @@ } } -/* {{{ proto string crypt(string str [, string salt]) - Encrypt a string */ +/* {{{ proto string crypt(string str [, string salt]) U + Hash a string */ PHP_FUNCTION(crypt) { char salt[PHP_MAX_SALT_LEN+1]; @@ -124,7 +124,7 @@ available (passing always 2-character salt). At least for glibc6.1 */ memset(&salt[1], '$', PHP_MAX_SALT_LEN-1); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S", &str, &str_len, &salt_in, &salt_in_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 base64.c
pollita Mon Sep 25 01:27:11 2006 UTC Modified files: /php-src/ext/standard base64.c Log: base64 functions are basicly binary-only ops http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.48&r2=1.49&diff_format=u Index: php-src/ext/standard/base64.c diff -u php-src/ext/standard/base64.c:1.48 php-src/ext/standard/base64.c:1.49 --- php-src/ext/standard/base64.c:1.48 Mon Jun 26 22:17:42 2006 +++ php-src/ext/standard/base64.c Mon Sep 25 01:27:11 2006 @@ -15,7 +15,7 @@ | Author: Jim Winstead <[EMAIL PROTECTED]> | +--+ */ -/* $Id: base64.c,v 1.48 2006/06/26 22:17:42 bjori Exp $ */ +/* $Id: base64.c,v 1.49 2006/09/25 01:27:11 pollita Exp $ */ #include @@ -203,7 +203,7 @@ } /* }}} */ -/* {{{ proto string base64_encode(string str) +/* {{{ proto string base64_encode(string str) U Encodes string using MIME base64 algorithm */ PHP_FUNCTION(base64_encode) { @@ -211,7 +211,7 @@ unsigned char *result; int str_len, ret_length; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str, &str_len) == FAILURE) { return; } result = php_base64_encode((unsigned char*)str, str_len, &ret_length); @@ -224,7 +224,7 @@ /* }}} */ -/* {{{ proto string base64_decode(string str[, bool strict]) +/* {{{ proto string base64_decode(string str[, bool strict]) U Decodes string using MIME base64 algorithm */ PHP_FUNCTION(base64_decode) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard fsock.c
pollita Sun Sep 24 21:43:42 2006 UTC Modified files: /php-src/ext/standard fsock.c Log: PHP6 Update: fsockopen/psfockopen http://cvs.php.net/viewvc.cgi/php-src/ext/standard/fsock.c?r1=1.123&r2=1.124&diff_format=u Index: php-src/ext/standard/fsock.c diff -u php-src/ext/standard/fsock.c:1.123 php-src/ext/standard/fsock.c:1.124 --- php-src/ext/standard/fsock.c:1.123 Sun Feb 19 04:29:41 2006 +++ php-src/ext/standard/fsock.cSun Sep 24 21:43:41 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: fsock.c,v 1.123 2006/02/19 04:29:41 andi Exp $ */ +/* $Id: fsock.c,v 1.124 2006/09/24 21:43:41 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -98,7 +98,7 @@ if (zerrstr && errstr) { /* no need to dup; we need to efree buf anyway */ zval_dtor(zerrstr); - ZVAL_STRING(zerrstr, errstr, 0); + ZVAL_RT_STRING(zerrstr, errstr, ZSTR_AUTOFREE); } else if (!zerrstr && errstr) { efree(errstr); @@ -116,14 +116,14 @@ /* }}} */ -/* {{{ proto resource fsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]]) +/* {{{ proto resource fsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]]) U Open Internet or Unix domain socket connection */ PHP_FUNCTION(fsockopen) { php_fsockopen_stream(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } /* }}} */ -/* {{{ proto resource pfsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]]) +/* {{{ proto resource pfsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]]) U Open persistent Internet or Unix domain socket connection */ PHP_FUNCTION(pfsockopen) { -- 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 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.456&r2=1.457&diff_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) { ph
[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.114&r2=1.115&diff_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.136&r2=1.137&diff_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 ha
[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.454&r2=1.455&diff_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 type.c
pollita Sun Sep 24 18:23:47 2006 UTC Modified files: /php-src/ext/standard type.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/type.c?r1=1.42&r2=1.43&diff_format=u Index: php-src/ext/standard/type.c diff -u php-src/ext/standard/type.c:1.42 php-src/ext/standard/type.c:1.43 --- php-src/ext/standard/type.c:1.42Fri Mar 17 23:00:20 2006 +++ php-src/ext/standard/type.c Sun Sep 24 18:23:47 2006 @@ -16,12 +16,12 @@ +--+ */ -/* $Id: type.c,v 1.42 2006/03/17 23:00:20 andrei Exp $ */ +/* $Id: type.c,v 1.43 2006/09/24 18:23:47 pollita Exp $ */ #include "php.h" #include "php_incomplete_class.h" -/* {{{ proto string gettype(mixed var) +/* {{{ proto string gettype(mixed var) U Returns the type of the variable */ PHP_FUNCTION(gettype) { @@ -91,7 +91,7 @@ } /* }}} */ -/* {{{ proto bool settype(mixed var, string type) +/* {{{ proto bool settype(mixed var, string type) U Set the type of the variable */ PHP_FUNCTION(settype) { @@ -115,6 +115,8 @@ convert_to_double(*var); } else if (!strcasecmp(new_type, "string")) { convert_to_string(*var); + } else if (!strcasecmp(new_type, "unicode")) { + convert_to_unicode(*var); } else if (!strcasecmp(new_type, "array")) { convert_to_array(*var); } else if (!strcasecmp(new_type, "object")) { @@ -136,7 +138,7 @@ } /* }}} */ -/* {{{ proto int intval(mixed var [, int base]) +/* {{{ proto int intval(mixed var [, int base]) U Get the integer value of a variable using the optional base for the conversion */ PHP_FUNCTION(intval) { @@ -168,22 +170,21 @@ } /* }}} */ -/* {{{ proto float floatval(mixed var) +/* {{{ proto float floatval(mixed var) U Get the float value of a variable */ PHP_FUNCTION(floatval) { - zval **num; + double retval; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &retval) == FAILURE) { + return; } - RETVAL_ZVAL(*num, 1, 0); - convert_to_double(return_value); + RETURN_DOUBLE(retval); } /* }}} */ -/* {{{ proto string strval(mixed var) +/* {{{ proto string strval(mixed var) U Get the string value of a variable */ PHP_FUNCTION(strval) { @@ -211,29 +212,41 @@ static void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type) { - zval **arg; + zval *arg; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only one argument expected"); - RETURN_FALSE; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { + return; } - if (Z_TYPE_PP(arg) == type) { + if (Z_TYPE_P(arg) == type) { if (type == IS_OBJECT) { zend_class_entry *ce; - if(Z_OBJ_HT_PP(arg)->get_class_entry == NULL) { - /* if there's no get_class_entry it's not a PHP object, so it can't be INCOMPLETE_CLASS */ + + if(Z_OBJ_HT_P(arg)->get_class_entry == NULL) { + /* if there's no get_class_entry it's not a PHP object, so it can't be INCOMPLETE_CLASS */ RETURN_TRUE; } - ce = Z_OBJCE_PP(arg); - /* FIXME: Unicode support??? */ - if (!strcmp(ce->name.s, INCOMPLETE_CLASS)) { - RETURN_FALSE; + ce = Z_OBJCE_P(arg); + + if (ce->name_length != sizeof(INCOMPLETE_CLASS) - 1) { + /* We can get away with this because INCOMPLETE_CLASS is ascii and has a 1:1 relationship with unicode */ + RETURN_TRUE; + } else if (UG(unicode)) { + U_STRING_DECL(uIncompleteClass, INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1); + U_STRING_INIT(uIncompleteClass, INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1); + + if (!memcmp(ce->name.u, uIncompleteClass, UBYTES(sizeof(INCOMPLETE_CLASS { + RETURN_FALSE; + } + } else { + if (!memcmp(ce->name.s, INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS))) { + RETURN_FALSE; + } } } if (type == IS_RESOURCE) { char *type_name; - type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(arg
[PHP-CVS] cvs: php-src /ext/standard math.c
pollita Sun Sep 24 17:59:41 2006 UTC Modified files: /php-src/ext/standard math.c Log: PHP6 Updates w/ minor refactoring http://cvs.php.net/viewvc.cgi/php-src/ext/standard/math.c?r1=1.136&r2=1.137&diff_format=u Index: php-src/ext/standard/math.c diff -u php-src/ext/standard/math.c:1.136 php-src/ext/standard/math.c:1.137 --- php-src/ext/standard/math.c:1.136 Sun Aug 27 18:20:39 2006 +++ php-src/ext/standard/math.c Sun Sep 24 17:59:40 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: math.c,v 1.136 2006/08/27 18:20:39 bjori Exp $ */ +/* $Id: math.c,v 1.137 2006/09/24 17:59:40 pollita Exp $ */ #include "php.h" #include "php_math.h" @@ -49,108 +49,100 @@ val = !zend_isnan(tmp_val) ? tmp_val : val; \ } \ -/* {{{ proto int abs(int number) +/* {{{ proto int abs(int number) U Return the absolute value of the number */ PHP_FUNCTION(abs) { - zval **value; + zval *value; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &value) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &value) == FAILURE) { + return; } - convert_scalar_to_number_ex(value); + convert_scalar_to_number(value); - if (Z_TYPE_PP(value) == IS_DOUBLE) { - RETURN_DOUBLE(fabs(Z_DVAL_PP(value))); - } else if (Z_TYPE_PP(value) == IS_LONG) { - if (Z_LVAL_PP(value) == LONG_MIN) { + if (Z_TYPE_P(value) == IS_DOUBLE) { + RETURN_DOUBLE(fabs(Z_DVAL_P(value))); + } else if (Z_TYPE_P(value) == IS_LONG) { + if (Z_LVAL_P(value) == LONG_MIN) { RETURN_DOUBLE(-(double)LONG_MIN); } else { - RETURN_LONG(Z_LVAL_PP(value) < 0 ? -Z_LVAL_PP(value) : Z_LVAL_PP(value)); + RETURN_LONG(Z_LVAL_P(value) < 0 ? -Z_LVAL_P(value) : Z_LVAL_P(value)); } } RETURN_FALSE; } /* }}} */ -/* {{{ proto float ceil(float number) +/* {{{ proto float ceil(float number) U Returns the next highest integer value of the number */ PHP_FUNCTION(ceil) { - zval **value; + zval *value; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &value) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &value) == FAILURE) { + return; } - convert_scalar_to_number_ex(value); + convert_scalar_to_number(value); - if (Z_TYPE_PP(value) == IS_DOUBLE) { - RETURN_DOUBLE(ceil(Z_DVAL_PP(value))); - } else if (Z_TYPE_PP(value) == IS_LONG) { - convert_to_double_ex(value); - RETURN_DOUBLE(Z_DVAL_PP(value)); + if (Z_TYPE_P(value) == IS_DOUBLE) { + RETURN_DOUBLE(ceil(Z_DVAL_P(value))); + } else if (Z_TYPE_P(value) == IS_LONG) { + RETURN_DOUBLE((double)Z_LVAL_P(value)); } RETURN_FALSE; } /* }}} */ -/* {{{ proto float floor(float number) +/* {{{ proto float floor(float number) U Returns the next lowest integer value from the number */ PHP_FUNCTION(floor) { - zval **value; + zval *value; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &value) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &value) == FAILURE) { + return; } - convert_scalar_to_number_ex(value); + convert_scalar_to_number(value); - if (Z_TYPE_PP(value) == IS_DOUBLE) { - RETURN_DOUBLE(floor(Z_DVAL_PP(value))); - } else if (Z_TYPE_PP(value) == IS_LONG) { - convert_to_double_ex(value); - RETURN_DOUBLE(Z_DVAL_PP(value)); + if (Z_TYPE_P(value) == IS_DOUBLE) { + RETURN_DOUBLE(floor(Z_DVAL_P(value))); + } else if (Z_TYPE_P(value) == IS_LONG) { + RETURN_DOUBLE((double)Z_LVAL_P(value)); } RETURN_FALSE; } /* }}} */ -/* {{{ proto float round(float number [, int precision]) +/* {{{ proto float round(float number [, int precision]) U Returns the number rounded to specified precision */ PHP_FUNCTION(round) { - zval **value, **precision; - int places = 0; + zval *value; + long places = 0; double return_val; - if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2 || - zend_get_parameters_ex(ZEND_NUM_ARGS(), &value, &precision) == FAILURE) { - WRONG_PARAM_COUNT; - } - - if (ZEND_NUM_ARGS() == 2) { - convert_to_long_ex(precision); - places = (int) Z_LVAL_PP(precision); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z
[PHP-CVS] cvs: php-src /ext/standard md5.c sha1.c
pollita Sun Sep 24 17:09:46 2006 UTC Modified files: /php-src/ext/standard md5.c sha1.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/md5.c?r1=1.46&r2=1.47&diff_format=u Index: php-src/ext/standard/md5.c diff -u php-src/ext/standard/md5.c:1.46 php-src/ext/standard/md5.c:1.47 --- php-src/ext/standard/md5.c:1.46 Thu Mar 2 13:12:45 2006 +++ php-src/ext/standard/md5.c Sun Sep 24 17:09:46 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: md5.c,v 1.46 2006/03/02 13:12:45 dmitry Exp $ */ +/* $Id: md5.c,v 1.47 2006/09/24 17:09:46 pollita Exp $ */ /* * md5.c - Copyright 1997 Lachlan Roche @@ -38,7 +38,7 @@ *md5str = '\0'; } -/* {{{ proto string md5(string str, [ bool raw_output]) +/* {{{ proto string md5(string str, [ bool raw_output]) U Calculate the md5 hash of a string */ PHP_NAMED_FUNCTION(php_if_md5) { @@ -49,7 +49,7 @@ PHP_MD5_CTX context; unsigned char digest[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -61,13 +61,13 @@ RETURN_STRINGL((char*)digest, 16, 1); } else { make_digest(md5str, digest); - RETVAL_ASCII_STRING(md5str, 1); + RETVAL_ASCII_STRING(md5str, ZSTR_DUPLICATE); } } /* }}} */ -/* {{{ proto string md5_file(string filename [, bool raw_output]) +/* {{{ proto string md5_file(string filename [, bool raw_output]) U Calculate the md5 hash of given filename */ PHP_NAMED_FUNCTION(php_if_md5_file) { @@ -81,7 +81,7 @@ int n; php_stream*stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -108,7 +108,7 @@ RETURN_STRINGL((char*)digest, 16, 1); } else { make_digest(md5str, digest); - RETVAL_ASCII_STRING(md5str, 1); + RETVAL_ASCII_STRING(md5str, ZSTR_DUPLICATE); } } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/sha1.c?r1=1.17&r2=1.18&diff_format=u Index: php-src/ext/standard/sha1.c diff -u php-src/ext/standard/sha1.c:1.17 php-src/ext/standard/sha1.c:1.18 --- php-src/ext/standard/sha1.c:1.17Thu Mar 2 13:12:45 2006 +++ php-src/ext/standard/sha1.c Sun Sep 24 17:09:46 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sha1.c,v 1.17 2006/03/02 13:12:45 dmitry Exp $ */ +/* $Id: sha1.c,v 1.18 2006/09/24 17:09:46 pollita Exp $ */ #include "php.h" @@ -36,7 +36,7 @@ *sha1str = '\0'; } -/* {{{ proto string sha1(string str [, bool raw_output]) +/* {{{ proto string sha1(string str [, bool raw_output]) U Calculate the sha1 hash of a string */ PHP_FUNCTION(sha1) { @@ -47,7 +47,7 @@ PHP_SHA1_CTX context; unsigned char digest[20]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -59,7 +59,7 @@ RETURN_STRINGL((char*)digest, 20, 1); } else { make_sha1_digest(sha1str, digest); - RETVAL_ASCII_STRING(sha1str, 1); + RETVAL_ASCII_STRING(sha1str, ZSTR_DUPLICATE); } } @@ -67,7 +67,7 @@ /* }}} */ -/* {{{ proto string sha1_file(string filename [, bool raw_output]) +/* {{{ proto string sha1_file(string filename [, bool raw_output]) U Calculate the sha1 hash of given filename */ PHP_FUNCTION(sha1_file) { @@ -81,7 +81,7 @@ int n; php_stream*stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -108,7 +108,7 @@ RETURN_STRINGL((char*)digest, 20, 1); } else { make_sha1_digest(sha1str, digest); - RETVAL_ASCII_STRING(sha1str, 1); + RETVAL_ASCII_STRING(sha1str, ZSTR_DUPLICATE); } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard exec.c
pollita Sun Sep 24 17:03:58 2006 UTC Modified files: /php-src/ext/standard exec.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/exec.c?r1=1.120&r2=1.121&diff_format=u Index: php-src/ext/standard/exec.c diff -u php-src/ext/standard/exec.c:1.120 php-src/ext/standard/exec.c:1.121 --- php-src/ext/standard/exec.c:1.120 Sun Jun 11 20:33:29 2006 +++ php-src/ext/standard/exec.c Sun Sep 24 17:03:58 2006 @@ -16,7 +16,7 @@ | Ilia Alshanetsky <[EMAIL PROTECTED]> | +--+ */ -/* $Id: exec.c,v 1.120 2006/06/11 20:33:29 bjori Exp $ */ +/* $Id: exec.c,v 1.121 2006/09/24 17:03:58 pollita Exp $ */ #include #include "php.h" @@ -55,6 +55,7 @@ * If type==2, all lines will be saved to given array (exec with &$array) * If type==3, output will be printed binary, no lines will be saved or returned (passthru) * + * Unicode command strings are encoding using filesystem_encoding, returned data is not decoded back to unicode */ int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_DC) { @@ -168,15 +169,16 @@ { char *cmd; int cmd_len; + zend_uchar cmd_type; zval *ret_code=NULL, *ret_array=NULL; int ret; if (mode) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/", &cmd, &cmd_len, &ret_code) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|z/", &cmd, &cmd_len, &cmd_type, &ret_code) == FAILURE) { RETURN_FALSE; } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/z/", &cmd, &cmd_len, &ret_array, &ret_code) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|z/z/", &cmd, &cmd_len, &cmd_type, &ret_array, &ret_code) == FAILURE) { RETURN_FALSE; } } @@ -185,6 +187,12 @@ RETURN_FALSE; } + if (cmd_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, &cmd, &cmd_len, (UChar*)cmd, cmd_len, REPORT_ERRORS, FG(default_context))) { + RETURN_FALSE; + } + } + if (!ret_array) { ret = php_exec(mode, cmd, NULL, return_value TSRMLS_CC); } else { @@ -198,9 +206,13 @@ zval_dtor(ret_code); ZVAL_LONG(ret_code, ret); } + + if (cmd_type == IS_UNICODE) { + efree(cmd); + } } -/* {{{ proto string exec(string command [, array &output [, int &return_value]]) +/* {{{ proto string exec(string command [, array &output [, int &return_value]]) U Execute an external program */ PHP_FUNCTION(exec) { @@ -209,7 +221,7 @@ /* }}} */ -/* {{{ proto int system(string command [, int &return_value]) +/* {{{ proto int system(string command [, int &return_value]) U Execute an external program and display output */ PHP_FUNCTION(system) { @@ -217,7 +229,7 @@ } /* }}} */ -/* {{{ proto void passthru(string command [, int &return_value]) +/* {{{ proto void passthru(string command [, int &return_value]) U Execute an external program and display raw output */ PHP_FUNCTION(passthru) { @@ -235,11 +247,11 @@ *NOT* safe for binary strings */ char *php_escape_shell_cmd(char *str) { - register int x, y, l; + register int x, y, l = strlen(str); char *cmd; char *p = NULL; + size_t estimate = (2 * l) + 1; - l = strlen(str); cmd = safe_emalloc(2, l, 1); for (x = 0, y = 0; x < l; x++) { @@ -292,6 +304,13 @@ } } cmd[y] = '\0'; + + if ((estimate - y) > 4096) { + /* realloc if the estimate was way overill +* Arbitrary cutoff point of 4096 */ + cmd = erealloc(cmd, y + 1); + } + return cmd; } /* }}} */ @@ -299,12 +318,10 @@ /* {{{ php_escape_shell_arg */ char *php_escape_shell_arg(char *str) { - int x, y, l; + int x, y = 0, l = strlen(str); char *cmd; + size_t estimate = (4 * l) + 3; - y = 0; - l = strlen(str); - cmd = safe_emalloc(4, l, 3); /* worst case */ #ifdef PHP_WIN32 @@ -337,71 +354,106 @@ cmd[y++] = '\''; #endif cmd[y] = '\0'; + + if ((estimate - y) > 4096) { + /* realloc if the estimate was way overill +* Arbitrary cutoff point of 4096 */ + cmd = erealloc(cmd, y + 1); + } return cmd; } /* }}} */ -/* {{{ proto string escapeshellcmd(string command) +/* {{{ proto string escapeshellcmd(string command) U Escape shell metacharacters */ PHP_FUNCTION(escapeshellcmd) { - zval **arg1; + char *command; + int command_len; + zend_uchar command_type;
[PHP-CVS] cvs: php-src /ext/standard streamsfuncs.c /main php_streams.h /main/streams streams.c
pollita Fri Sep 22 19:54:30 2006 UTC Modified files: /php-src/main php_streams.h /php-src/ext/standard streamsfuncs.c /php-src/main/streams streams.c Log: Update stream_copy_to_stream() for PHP6 http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.113&r2=1.114&diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.113 php-src/main/php_streams.h:1.114 --- php-src/main/php_streams.h:1.113Fri Apr 28 19:03:58 2006 +++ php-src/main/php_streams.h Fri Sep 22 19:54:30 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.113 2006/04/28 19:03:58 fmk Exp $ */ +/* $Id: php_streams.h,v 1.114 2006/09/22 19:54:30 pollita Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -456,9 +456,12 @@ #define PHP_STREAM_COPY_ALL((size_t)-1) BEGIN_EXTERN_C() +PHPAPI size_t _php_stream_ucopy_to_stream(php_stream *src, php_stream *dest, size_t maxlen, int maxchars STREAMS_DC TSRMLS_DC); PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC TSRMLS_DC); -#define php_stream_copy_to_stream(src, dest, maxlen) _php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC TSRMLS_CC) - +/* 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) ) /* read all data from stream and put into a buffer. Caller must free buffer when done. * The copy will use mmap if available. */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.88&r2=1.89&diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.88 php-src/ext/standard/streamsfuncs.c:1.89 --- php-src/ext/standard/streamsfuncs.c:1.88Fri Sep 22 18:42:33 2006 +++ php-src/ext/standard/streamsfuncs.c Fri Sep 22 19:54:30 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.88 2006/09/22 18:42:33 pollita Exp $ */ +/* $Id: streamsfuncs.c,v 1.89 2006/09/22 19:54:30 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -443,7 +443,7 @@ } /* }}} */ -/* {{{ proto long stream_copy_to_stream(resource source, resource dest [, long maxlen [, long pos]]) +/* {{{ proto long stream_copy_to_stream(resource source, resource dest [, long maxlen [, long pos]]) U Reads up to maxlen bytes from source stream and writes them to dest stream. */ PHP_FUNCTION(stream_copy_to_stream) { http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.135&r2=1.136&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.135 php-src/main/streams/streams.c:1.136 --- php-src/main/streams/streams.c:1.135Tue Sep 19 20:36:48 2006 +++ php-src/main/streams/streams.c Fri Sep 22 19:54:30 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.135 2006/09/19 20:36:48 pollita Exp $ */ +/* $Id: streams.c,v 1.136 2006/09/22 19:54:30 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -1568,7 +1568,7 @@ ucnv_resetFromUnicode(conv); - while ((b = php_stream_read_unicode(stream, inbuf_start, sizeof(inbuf_start))) > 0) { + while ((b = php_stream_read_unicode(stream, inbuf_start, 8192)) > 0) { char *outbuf = outbuf_start; const UChar *inbuf = inbuf_start; UErrorCode status = U_ZERO_ERROR; @@ -1733,14 +1733,97 @@ return len; } +/* Designed for copying UChars (taking into account both maxlen and maxchars) */ +PHPAPI size_t _php_stream_ucopy_to_stream(php_stream *src, php_stream *dest, size_t maxlen, int maxchars STREAMS_DC TSRMLS_DC) +{ + size_t haveread = 0; + php_stream_statbuf ssbuf; + + if (src->readbuf_type == IS_STRING) { + /* Called incorrectly, don't do that. */ + return _php_stream_copy_to_stream(src, dest, maxlen STREAMS_CC TSRMLS_CC); + } + + if (maxlen == 0 || maxchars == 0) { + return 0; + } + + if (maxlen == PHP_STREAM_COPY_ALL) { + maxlen = 0; + } + + if (php_stream_stat(src, &ssbuf) == 0) { + /* in the event that the source file is 0 bytes, return 1 to indicate success +* because opening the file to write had already created a copy */ + if (ssbuf.sb.st_size == 0 +#ifdef S_ISFIFO +&& !S_ISFIFO(ssbuf.sb.st_mode) +#endif +#ifdef S_ISCHR +
[PHP-CVS] cvs: php-src /ext/standard dir.c
pollita Fri Sep 22 23:57:38 2006 UTC Modified files: /php-src/ext/standard dir.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.153&r2=1.154&diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.153 php-src/ext/standard/dir.c:1.154 --- php-src/ext/standard/dir.c:1.153Sun Feb 19 04:29:41 2006 +++ php-src/ext/standard/dir.c Fri Sep 22 23:57:38 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.153 2006/02/19 04:29:41 andi Exp $ */ +/* $Id: dir.c,v 1.154 2006/09/22 23:57:38 pollita Exp $ */ /* {{{ includes/startup/misc */ @@ -178,40 +178,63 @@ /* {{{ internal functions */ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject) { - char *dirname; - int dir_len; + UChar *udir; + char *dir; + int dir_len, udir_len; + zend_uchar dir_type; zval *zcontext = NULL; php_stream_context *context = NULL; php_stream *dirp; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &dirname, &dir_len, &zcontext) == FAILURE) { - RETURN_NULL(); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|r", &dir, &dir_len, &zcontext) == FAILURE) { + return; } + RETVAL_FALSE; + + /* Save for later */ + udir = (UChar*)dir; + udir_len = dir_len; + if (zcontext) { context = php_stream_context_from_zval(zcontext, 0); } - - dirp = php_stream_opendir(dirname, REPORT_ERRORS, context); + + if (dir_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, &dir, &dir_len, udir, udir_len, REPORT_ERRORS, context)) { + goto opendir_cleanup; + } + } + + dirp = php_stream_opendir(dir, REPORT_ERRORS, context); if (dirp == NULL) { - RETURN_FALSE; + goto opendir_cleanup; } php_set_default_dir(dirp->rsrc_id TSRMLS_CC); if (createobject) { object_init_ex(return_value, dir_class_entry_ptr); - add_property_rt_stringl(return_value, "path", dirname, dir_len, 1); + if (dir_type == IS_UNICODE) { + add_property_unicodel(return_value, "path", udir, udir_len, 1); + } else { + add_property_stringl(return_value, "path", dir, dir_len, 1); + } add_property_resource(return_value, "handle", dirp->rsrc_id); php_stream_auto_cleanup(dirp); /* so we don't get warnings under debug */ } else { php_stream_to_zval(dirp, return_value); } + +opendir_cleanup: + if (dir_type == IS_UNICODE) { + efree(dir); + } } /* }}} */ -/* {{{ proto mixed opendir(string path[, resource context]) +/* {{{ proto mixed opendir(string path[, resource context]) U Open a directory and return a dir_handle */ PHP_FUNCTION(opendir) { @@ -219,7 +242,7 @@ } /* }}} */ -/* {{{ proto object dir(string directory[, resource context]) +/* {{{ proto object dir(string directory[, resource context]) U Directory class with properties, handle and class and methods read, rewind and close */ PHP_FUNCTION(getdir) { @@ -227,7 +250,7 @@ } /* }}} */ -/* {{{ proto void closedir([resource dir_handle]) +/* {{{ proto void closedir([resource dir_handle]) U Close directory connection identified by the dir_handle */ PHP_FUNCTION(closedir) { @@ -245,18 +268,28 @@ /* }}} */ #if defined(HAVE_CHROOT) && !defined(ZTS) && ENABLE_CHROOT_FUNC -/* {{{ proto bool chroot(string directory) +/* {{{ proto bool chroot(string directory) U Change root directory */ PHP_FUNCTION(chroot) { char *str; int ret, str_len; + zend_uchar str_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { - RETURN_FALSE; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &str, &str_len, &str_type) == FAILURE) { + return; + } + + if (str_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, &str, &str_len, (UChar*)str, str_len, REPORT_ERRORS, FG(default_context))) { + RETURN_FALSE; + } } ret = chroot(str); + if (str_type == IS_UNICODE) { + efree(str); + } if (ret != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s (errno %d)", strerror(errno), errno); @@ -275,18 +308,28 @@ /* }}} */ #endif -/* {{{ proto bool chdir(string directory) +/* {{{ proto bool chdir(string directory) U Change the current directory */ PHP_FUNCTION(chdir) { char *str; int ret, str_len
[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.453&r2=1.454&diff_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
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.452&r2=1.453&diff_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 streamsfuncs.c
pollita Fri Sep 22 18:42:33 2006 UTC Modified files: /php-src/ext/standard streamsfuncs.c Log: Update stream_get_contents() for PHP6 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.87&r2=1.88&diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.87 php-src/ext/standard/streamsfuncs.c:1.88 --- php-src/ext/standard/streamsfuncs.c:1.87Thu Sep 21 19:53:10 2006 +++ php-src/ext/standard/streamsfuncs.c Fri Sep 22 18:42:33 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.87 2006/09/21 19:53:10 pollita Exp $ */ +/* $Id: streamsfuncs.c,v 1.88 2006/09/22 18:42:33 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -390,15 +390,15 @@ } /* }}} */ -/* {{{ proto string stream_get_contents(resource source [, long maxlen [, long offset]]) +/* {{{ proto string stream_get_contents(resource source [, long maxlen [, long offset]]) U Reads all remaining bytes (or up to maxlen bytes) from a stream and returns them as a string. */ PHP_FUNCTION(stream_get_contents) { php_stream *stream; zval *zsrc; - long maxlen = PHP_STREAM_COPY_ALL, pos = 0; + long maxlen = PHP_STREAM_COPY_ALL, pos = 0, real_maxlen; int len; - char *contents = NULL; + void *contents = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|ll", &zsrc, &maxlen, &pos) == FAILURE) { RETURN_FALSE; @@ -411,12 +411,34 @@ RETURN_FALSE; } - if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) { - RETVAL_STRINGL(contents, len, 0); - } else if (len == 0) { - RETVAL_EMPTY_STRING(); + if (maxlen <= 0 || stream->readbuf_type == IS_STRING) { + real_maxlen = maxlen; } else { - RETVAL_FALSE; + /* 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; + } + + len = php_stream_copy_to_mem_ex(stream, stream->readbuf_type, &contents, real_maxlen, maxlen, 0); + + if (stream->readbuf_type == IS_STRING) { + if (len > 0) { + RETVAL_STRINGL(contents, len, 0); + } else { + if (contents) { + efree(contents); + } + RETVAL_EMPTY_STRING(); + } + } else { + if (len > 0) { + RETVAL_UNICODEL(contents, len, 0); + } else { + if (contents) { + efree(contents); + } + RETVAL_EMPTY_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
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.451&r2=1.452&diff_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 assert.c basic_functions.c
pollita Fri Sep 22 01:55:48 2006 UTC Modified files: /php-src/ext/standard assert.c basic_functions.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c?r1=1.68&r2=1.69&diff_format=u Index: php-src/ext/standard/assert.c diff -u php-src/ext/standard/assert.c:1.68 php-src/ext/standard/assert.c:1.69 --- php-src/ext/standard/assert.c:1.68 Tue Aug 8 17:32:19 2006 +++ php-src/ext/standard/assert.c Fri Sep 22 01:55:47 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: assert.c,v 1.68 2006/08/08 17:32:19 tony2001 Exp $ */ +/* $Id: assert.c,v 1.69 2006/09/22 01:55:47 pollita Exp $ */ /* {{{ includes/startup/misc */ @@ -119,7 +119,7 @@ /* }}} */ /* {{{ internal functions */ /* }}} */ -/* {{{ proto int assert(string|bool assertion) +/* {{{ proto int assert(string|bool assertion) U Checks if assertion is false */ PHP_FUNCTION(assert) @@ -238,7 +238,7 @@ } /* }}} */ -/* {{{ proto mixed assert_options(int what [, mixed value]) +/* {{{ proto mixed assert_options(int what [, mixed value]) U Set/get the various assert flags */ PHP_FUNCTION(assert_options) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.804&r2=1.805&diff_format=u Index: php-src/ext/standard/basic_functions.c diff -u php-src/ext/standard/basic_functions.c:1.804 php-src/ext/standard/basic_functions.c:1.805 --- php-src/ext/standard/basic_functions.c:1.804Tue Sep 19 23:45:12 2006 +++ php-src/ext/standard/basic_functions.c Fri Sep 22 01:55:47 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: basic_functions.c,v 1.804 2006/09/19 23:45:12 iliaa Exp $ */ +/* $Id: basic_functions.c,v 1.805 2006/09/22 01:55:47 pollita Exp $ */ #include "php.h" #include "php_streams.h" @@ -4217,7 +4217,7 @@ /* }}} */ #ifdef HAVE_INET_NTOP -/* {{{ proto string inet_ntop(string in_addr) +/* {{{ proto string inet_ntop(string in_addr) U Converts a packed inet address to a human readable IP address string */ PHP_NAMED_FUNCTION(php_inet_ntop) { @@ -4225,7 +4225,7 @@ int address_len, af = AF_INET; char buffer[40]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &address, &address_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &address, &address_len) == FAILURE) { RETURN_FALSE; } @@ -4244,13 +4244,13 @@ RETURN_FALSE; } - RETURN_STRING(buffer, 1); + RETURN_RT_STRING(buffer, ZSTR_DUPLICATE); } /* }}} */ #endif /* HAVE_INET_NTOP */ #ifdef HAVE_INET_PTON -/* {{{ proto string inet_pton(string ip_address) +/* {{{ proto string inet_pton(string ip_address) U Converts a human readable IP address to a packed binary string */ PHP_NAMED_FUNCTION(php_inet_pton) { @@ -4289,24 +4289,24 @@ -/* {{{ proto int ip2long(string ip_address) +/* {{{ proto int ip2long(string ip_address) U Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address */ PHP_FUNCTION(ip2long) { - zval **str; + char *addr; + int addr_len; unsigned long int ip; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addr, &addr_len) == FAILURE) { + return; } - convert_to_string_ex(str); - - if (Z_STRLEN_PP(str) == 0 || (ip = inet_addr(Z_STRVAL_PP(str))) == INADDR_NONE) { + if (addr_len == 0 || (ip = inet_addr(addr)) == INADDR_NONE) { /* the only special case when we should return -1 ourselves, * because inet_addr() considers it wrong. */ - if (!memcmp(Z_STRVAL_PP(str), "255.255.255.255", Z_STRLEN_PP(str))) { + if (addr_len == sizeof("255.255.255.255") - 1 && + !memcmp(addr, "255.255.255.255", sizeof("255.255.255.255") - 1)) { RETURN_LONG(-1); } @@ -4317,23 +4317,24 @@ } /* }}} */ -/* {{{ proto string long2ip(int proper_address) +/* {{{ proto string long2ip(int proper_address) U Converts an (IPv4) Internet network address into a string in Internet standard dotted format */ PHP_FUNCTION(long2ip) { - zval **num; + /* "It's a long but it's not, PHP ints are signed */ + char *ip; + int ip_len; unsigned long n; struct in_addr myaddr; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ip, &ip_len) == FAILURE) { + return; } - convert_to_string_ex(num); - n = strtoul(Z_STRVAL_PP(num), NULL,
[PHP-CVS] cvs: php-src /ext/standard filestat.c
pollita Thu Sep 21 23:36:13 2006 UTC Modified files: /php-src/ext/standard filestat.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/filestat.c?r1=1.149&r2=1.150&diff_format=u Index: php-src/ext/standard/filestat.c diff -u php-src/ext/standard/filestat.c:1.149 php-src/ext/standard/filestat.c:1.150 --- php-src/ext/standard/filestat.c:1.149 Tue Sep 19 10:38:31 2006 +++ php-src/ext/standard/filestat.c Thu Sep 21 23:36:13 2006 @@ -16,11 +16,12 @@ +--+ */ -/* $Id: filestat.c,v 1.149 2006/09/19 10:38:31 dmitry Exp $ */ +/* $Id: filestat.c,v 1.150 2006/09/21 23:36:13 pollita Exp $ */ #include "php.h" #include "fopen_wrappers.h" #include "php_globals.h" +#include "ext/standard/file.h" #include #include @@ -117,11 +118,13 @@ return SUCCESS; } -/* {{{ proto float disk_total_space(string path) +/* {{{ proto float disk_total_space(string path) U Get total disk space for filesystem that path is on */ PHP_FUNCTION(disk_total_space) { - zval **path; + char *path; + int path_len; + zend_uchar path_type; #ifdef WINDOWS double bytestotal; @@ -150,16 +153,21 @@ double bytestotal = 0; #endif /* WINDOWS */ - if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &path)==FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &path, &path_len, &path_type) == FAILURE) { + return; } - convert_to_string_ex(path); + if (path_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, &path, &path_len, (UChar*)path, path_len, REPORT_ERRORS, FG(default_context))) { + RETURN_FALSE; + } + } - if (php_check_open_basedir(Z_STRVAL_PP(path) TSRMLS_CC)) { - RETURN_FALSE; + if (php_check_open_basedir(path TSRMLS_CC)) { + goto totalspace_failure; } +/* OS Selection */ #ifdef WINDOWS /* GetDiskFreeSpaceEx is only available in NT and Win95 post-OSR2, so we have to jump through some hoops to see if the function @@ -170,12 +178,12 @@ /* It's available, so we can call it. */ if (gdfse) { func = (gdfse_func)gdfse; - if (func(Z_STRVAL_PP(path), + if (func(path, &FreeBytesAvailableToCaller, &TotalNumberOfBytes, &TotalNumberOfFreeBytes) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", php_win_err()); - RETURN_FALSE; + goto totalspace_failure; } /* i know - this is ugly, but i works <[EMAIL PROTECTED]> */ @@ -185,33 +193,36 @@ } /* If it's not available, we just use GetDiskFreeSpace */ else { - if (GetDiskFreeSpace(Z_STRVAL_PP(path), + if (GetDiskFreeSpace(path, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", php_win_err()); - RETURN_FALSE; + goto totalspace_failure; } bytestotal = (double)TotalNumberOfClusters * (double)SectorsPerCluster * (double)BytesPerSector; } } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to load kernel32.dll"); - RETURN_FALSE; + goto totalspace_failure; } #elif defined(OS2) { FSALLOCATE fsinfo; - char drive = Z_STRVAL_PP(path)[0] & 95; + char drive = path[0] & 0x5F; /* ascii ucase */ if (DosQueryFSInfo( drive ? drive - 64 : 0, FSIL_ALLOC, &fsinfo, sizeof( fsinfo ) ) == 0) bytestotal = (double)fsinfo.cbSector * fsinfo.cSectorUnit * fsinfo.cUnit; } -#else /* WINDOWS, OS/2 */ -#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS) - if (statvfs(Z_STRVAL_PP(path), &buf)) { +#else /* ! WINDOWS, ! OS/2 */ + + +/* *nix Implmentations */ +# if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS) + if (statvfs(path, &buf)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); - RETURN_FALSE; + goto totalspace_failure; } if (buf.f_frsize) { bytestotal = (((double)buf.f_blocks) * ((double)buf.f_frsize)); @@ -219,24 +230,40 @@ bytesto
[PHP-CVS] cvs: php-src /ext/standard streamsfuncs.c /ext/standard/tests/file 002.phpt stream_rfc2397_002.phpt
pollita Thu Sep 21 19:53:10 2006 UTC Modified files: /php-src/ext/standard/tests/file002.phpt stream_rfc2397_002.phpt /php-src/ext/standard streamsfuncs.c Log: Update (most of) the functions in streamsfuncs.c This commit also includes a change to tests/file/stream_rfc2397_002.phpt which doesn't entirely pass in unicode mode yet, however that's a unicode issue in the data:// wrapper that needs fixing, not a problem with the streams layer itself. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/002.phpt?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/standard/tests/file/002.phpt diff -u php-src/ext/standard/tests/file/002.phpt:1.3 php-src/ext/standard/tests/file/002.phpt:1.4 --- php-src/ext/standard/tests/file/002.phpt:1.3Wed May 19 08:54:51 2004 +++ php-src/ext/standard/tests/file/002.phptThu Sep 21 19:53:10 2006 @@ -23,7 +23,7 @@ EOD; $name = tempnam("./ext/standard/tests/file/", "php"); -$fp = fopen($name, "w"); +$fp = fopen($name, "wt"); fwrite($fp, $data); fclose($fp); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/stream_rfc2397_002.phpt?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/standard/tests/file/stream_rfc2397_002.phpt diff -u php-src/ext/standard/tests/file/stream_rfc2397_002.phpt:1.3 php-src/ext/standard/tests/file/stream_rfc2397_002.phpt:1.4 --- php-src/ext/standard/tests/file/stream_rfc2397_002.phpt:1.3 Thu Jun 29 14:53:31 2006 +++ php-src/ext/standard/tests/file/stream_rfc2397_002.phpt Thu Sep 21 19:53:10 2006 @@ -193,11 +193,11 @@ --UEXPECTF-- array(8) { [u"wrapper_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"stream_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"mode"]=> - string(1) "r" + unicode(1) "r" [u"unread_bytes"]=> int(0) [u"unread_chars"]=> @@ -205,7 +205,7 @@ [u"seekable"]=> bool(true) [u"uri"]=> - string(8) "data://," + unicode(8) "data://," [u"base64"]=> bool(false) } @@ -216,11 +216,11 @@ NULL array(8) { [u"wrapper_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"stream_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"mode"]=> - string(1) "r" + unicode(1) "r" [u"unread_bytes"]=> int(0) [u"unread_chars"]=> @@ -228,7 +228,7 @@ [u"seekable"]=> bool(true) [u"uri"]=> - string(15) "data://;base64," + unicode(15) "data://;base64," [u"base64"]=> bool(true) } @@ -247,11 +247,11 @@ NULL array(9) { [u"wrapper_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"stream_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"mode"]=> - string(1) "r" + unicode(1) "r" [u"unread_bytes"]=> int(0) [u"unread_chars"]=> @@ -259,9 +259,9 @@ [u"seekable"]=> bool(true) [u"uri"]=> - string(18) "data://text/plain," + unicode(18) "data://text/plain," [u"mediatype"]=> - string(10) "text/plain" + unicode(10) "text/plain" [u"base64"]=> bool(false) } @@ -272,11 +272,11 @@ NULL array(10) { [u"wrapper_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"stream_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"mode"]=> - string(1) "r" + unicode(1) "r" [u"unread_bytes"]=> int(0) [u"unread_chars"]=> @@ -284,26 +284,26 @@ [u"seekable"]=> bool(true) [u"uri"]=> - string(26) "data://text/plain;foo=bar," + unicode(26) "data://text/plain;foo=bar," [u"mediatype"]=> - string(10) "text/plain" + unicode(10) "text/plain" [u"foo"]=> - string(3) "bar" + unicode(3) "bar" [u"base64"]=> bool(false) } -string(3) "bar" +unicode(3) "bar" Warning: fopen(data://text/plain;foo=bar;bla,): failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d bool(false) NULL array(10) { [u"wrapper_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"stream_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"mode"]=> - string(1) "r" + unicode(1) "r" [u"unread_bytes"]=> int(0) [u"unread_chars"]=> @@ -311,26 +311,26 @@ [u"seekable"]=> bool(true) [u"uri"]=> - string(33) "data://text/plain;foo=bar;base64," + unicode(33) "data://text/plain;foo=bar;base64," [u"mediatype"]=> - string(10) "text/plain" + unicode(10) "text/plain" [u"foo"]=> - string(3) "bar" + unicode(3) "bar" [u"base64"]=> bool(true) } -string(3) "bar" +unicode(3) "bar" Warning: fopen(data://text/plain;foo=bar;bar=baz): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d bool(false) NULL array(11) { [u"wrapper_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"stream_type"]=> - string(7) "RFC2397" + unicode(7) "RFC2397" [u"mode"]=> - string(1) "r" + unicode(1) "r" [u"unread_bytes"]=> int(0) [u"unread_chars"]=> @@ -338,15 +338,15 @@ [u"seekable"]=> bool(true) [u"uri"]=> - string(34) "data://text/plain;foo=bar;bar=baz," + unicode(34) "data://text/plain;fo
[PHP-CVS] cvs: php-src /ext/hash package2.xml
pollita Thu Sep 21 18:39:30 2006 UTC Modified files: /php-src/ext/hash package2.xml Log: Add double-width ripemd tests to package2.xml as well http://cvs.php.net/viewvc.cgi/php-src/ext/hash/package2.xml?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/hash/package2.xml diff -u php-src/ext/hash/package2.xml:1.2 php-src/ext/hash/package2.xml:1.3 --- php-src/ext/hash/package2.xml:1.2 Tue Apr 25 08:52:46 2006 +++ php-src/ext/hash/package2.xml Thu Sep 21 18:39:30 2006 @@ -53,6 +53,8 @@ + + -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/hash package.xml
pollita Thu Sep 21 18:22:04 2006 UTC Modified files: /php-src/ext/hash package.xml Log: Add double-width ripemd tests to package.xml http://cvs.php.net/viewvc.cgi/php-src/ext/hash/package.xml?r1=1.22&r2=1.23&diff_format=u Index: php-src/ext/hash/package.xml diff -u php-src/ext/hash/package.xml:1.22 php-src/ext/hash/package.xml:1.23 --- php-src/ext/hash/package.xml:1.22 Tue Apr 25 08:52:46 2006 +++ php-src/ext/hash/package.xmlThu Sep 21 18:22:04 2006 @@ -41,6 +41,8 @@ + + -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/unicode collator.c property.c transform.c unicode.c
pollita Wed Sep 20 23:44:23 2006 UTC Modified files: /php-src/ext/unicodecollator.c property.c transform.c unicode.c Log: Backfill protos for ext/unicode functions http://cvs.php.net/viewvc.cgi/php-src/ext/unicode/collator.c?r1=1.7&r2=1.8&diff_format=u Index: php-src/ext/unicode/collator.c diff -u php-src/ext/unicode/collator.c:1.7 php-src/ext/unicode/collator.c:1.8 --- php-src/ext/unicode/collator.c:1.7 Fri Apr 21 21:10:01 2006 +++ php-src/ext/unicode/collator.c Wed Sep 20 23:44:23 2006 @@ -14,7 +14,7 @@ +--+ */ -/* $Id: collator.c,v 1.7 2006/04/21 21:10:01 andrei Exp $ */ +/* $Id: collator.c,v 1.8 2006/09/20 23:44:23 pollita Exp $ */ #include "php.h" #include "ext/standard/php_array.h" @@ -163,11 +163,16 @@ return object; } +/* {{{ proto Collator collator_create(string collator_name) U +Create a new collator object */ PHP_METHOD(collator, __construct) { zif_collator_create(INTERNAL_FUNCTION_PARAM_PASSTHRU); } +/* }}} */ +/* {{{ proto Collator collator_create(string collator_name) U +Create a new collator object */ PHP_FUNCTION(collator_create) { UErrorCodestatus = U_ZERO_ERROR; @@ -191,7 +196,10 @@ } collator_set_wrapper(object, zend_collator_create(ucoll) TSRMLS_CC); } +/* }}} */ +/* {{{ proto int collator_compare(Collator coll, string elementA, string elementB) U +Use a collator object to compare two elements */ PHP_FUNCTION(collator_compare) { zval *object; @@ -205,7 +213,10 @@ collatorobj = (php_collator_obj *) zend_object_store_get_object(object TSRMLS_CC); RETURN_LONG(ucol_strcoll(collatorobj->zcoll->coll, string1, string1_len, string2, string2_len)); } +/* }}} */ +/* {{{ proto array collator_sort(Collator coll, array initialarray) U +Sort an array using a collator */ PHP_FUNCTION(collator_sort) { zval *object; @@ -230,7 +241,10 @@ } UG(default_collator) = orig_collator; } +/* }}} */ +/* {{{ proto void collator_set_strength(Collator coll, int strength) U +Set the strength on a collator object */ PHP_FUNCTION(collator_set_strength) { zval *object; @@ -243,7 +257,10 @@ collatorobj = (php_collator_obj *) zend_object_store_get_object(object TSRMLS_CC); ucol_setStrength(collatorobj->zcoll->coll, strength); } +/* }}} */ +/* {{{ proto int collator_get_strength(Collator coll) U +Returns the current collator strength */ PHP_FUNCTION(collator_get_strength) { zval *object; @@ -255,7 +272,10 @@ collatorobj = (php_collator_obj *) zend_object_store_get_object(object TSRMLS_CC); RETURN_LONG(ucol_getStrength(collatorobj->zcoll->coll)); } +/* }}} */ +/* {{{ proto bool collator_set_attribute(Collator coll, int attribute, int value) U +Set a collator attribute */ PHP_FUNCTION(collator_set_attribute) { zval *object; @@ -271,7 +291,11 @@ ucol_setAttribute(collatorobj->zcoll->coll, attribute, value, &error); RETURN_BOOL(error == U_ZERO_ERROR ? 1 : 0); } +/* }}} */ + +/* {{{ proto int collator_get_attribute(Collator coll, int attribute) U +Read an attribute from a collator */ PHP_FUNCTION(collator_get_attribute) { zval *object; @@ -290,6 +314,7 @@ } RETURN_LONG(value); } +/* }}} */ /* {{{ proto Collator collator_get_default(void) U Returns default collator */ http://cvs.php.net/viewvc.cgi/php-src/ext/unicode/property.c?r1=1.14&r2=1.15&diff_format=u Index: php-src/ext/unicode/property.c diff -u php-src/ext/unicode/property.c:1.14 php-src/ext/unicode/property.c:1.15 --- php-src/ext/unicode/property.c:1.14 Tue May 9 18:21:27 2006 +++ php-src/ext/unicode/property.c Wed Sep 20 23:44:23 2006 @@ -14,7 +14,7 @@ +--+ */ -/* $Id: property.c,v 1.14 2006/05/09 18:21:27 andrei Exp $ */ +/* $Id: property.c,v 1.15 2006/09/20 23:44:23 pollita Exp $ */ #include "php_unicode.h" @@ -53,135 +53,208 @@ /* {{{ C/POSIX migration functions */ +/* {{{ proto bool char_is_lower(string text) U +Determines if text is lowercase */ PHP_FUNCTION(char_is_lower) { check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_islower); } +/* }}} */ +/* {{{ proto bool char_is_upper(string text) U +Determines if text is uppercase */ PHP_FUNCTION(char_is_upper) { check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isupper); } +/* }}} */ +/* {{{ proto bool char_is_digit(string text) U +Determines if text is all digits */ PHP_FUNCTION(char_is_digit) { check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isdigit); } +/* }}} */ +/* {{{ proto bool char_is_alpha(string text) U +Determines if text is alpha */ PHP_FUNCTION(char_is_alpha) { check_property_impl(INTERNAL_FUNCTION_PARAM_PAS
[PHP-CVS] cvs: php-src /ext/hash hash.c hash_ripemd.c php_hash.h php_hash_ripemd.h /ext/hash/tests ripemd256.phpt ripemd320.phpt
pollita Wed Sep 20 01:48:06 2006 UTC Added files: /php-src/ext/hash/tests ripemd256.phpt ripemd320.phpt Modified files: /php-src/ext/hash hash.c hash_ripemd.c php_hash.h php_hash_ripemd.h Log: Add ripemd256 and ripemd320 algos http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.30&r2=1.31&diff_format=u Index: php-src/ext/hash/hash.c diff -u php-src/ext/hash/hash.c:1.30 php-src/ext/hash/hash.c:1.31 --- php-src/ext/hash/hash.c:1.30Wed Sep 20 00:32:54 2006 +++ php-src/ext/hash/hash.c Wed Sep 20 01:48:06 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: hash.c,v 1.30 2006/09/20 00:32:54 pollita Exp $ */ +/* $Id: hash.c,v 1.31 2006/09/20 01:48:06 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -613,6 +613,8 @@ php_hash_register_algo("sha512",&php_hash_sha512_ops); php_hash_register_algo("ripemd128", &php_hash_ripemd128_ops); php_hash_register_algo("ripemd160", &php_hash_ripemd160_ops); + php_hash_register_algo("ripemd256", &php_hash_ripemd256_ops); + php_hash_register_algo("ripemd320", &php_hash_ripemd320_ops); php_hash_register_algo("whirlpool", &php_hash_whirlpool_ops); php_hash_register_algo("tiger128,3",&php_hash_3tiger128_ops); php_hash_register_algo("tiger160,3",&php_hash_3tiger160_ops); http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_ripemd.c?r1=1.6&r2=1.7&diff_format=u Index: php-src/ext/hash/hash_ripemd.c diff -u php-src/ext/hash/hash_ripemd.c:1.6 php-src/ext/hash/hash_ripemd.c:1.7 --- php-src/ext/hash/hash_ripemd.c:1.6 Sun Jan 1 13:09:50 2006 +++ php-src/ext/hash/hash_ripemd.c Wed Sep 20 01:48:06 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: hash_ripemd.c,v 1.6 2006/01/01 13:09:50 sniper Exp $ */ +/* $Id: hash_ripemd.c,v 1.7 2006/09/20 01:48:06 pollita Exp $ */ /* Heavily borrowed from md5.c & sha1.c of PHP archival fame Note that ripemd laughs in the face of logic and uses @@ -43,6 +43,24 @@ sizeof(PHP_RIPEMD160_CTX) }; +php_hash_ops php_hash_ripemd256_ops = { + (php_hash_init_func_t) PHP_RIPEMD256Init, + (php_hash_update_func_t) PHP_RIPEMD256Update, + (php_hash_final_func_t) PHP_RIPEMD256Final, + 32, + 64, + sizeof(PHP_RIPEMD256_CTX) +}; + +php_hash_ops php_hash_ripemd320_ops = { + (php_hash_init_func_t) PHP_RIPEMD320Init, + (php_hash_update_func_t) PHP_RIPEMD320Update, + (php_hash_final_func_t) PHP_RIPEMD320Final, + 40, + 64, + sizeof(PHP_RIPEMD320_CTX) +}; + /* {{{ PHP_RIPEMD128Init * ripemd128 initialization. Begins a ripemd128 operation, writing a new context. */ @@ -58,8 +76,27 @@ } /* }}} */ +/* {{{ PHP_RIPEMD256Init + * ripemd256 initialization. Begins a ripemd256 operation, writing a new context. + */ +PHP_HASH_API void PHP_RIPEMD256Init(PHP_RIPEMD256_CTX * context) +{ + context->count[0] = context->count[1] = 0; + /* Load magic initialization constants. +*/ + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0x76543210; + context->state[5] = 0xFEDCBA98; + context->state[6] = 0x89ABCDEF; + context->state[7] = 0x01234567; +} +/* }}} */ + /* {{{ PHP_RIPEMD160Init - * ripemd128 initialization. Begins a ripemd128 operation, writing a new context. + * ripemd160 initialization. Begins a ripemd160 operation, writing a new context. */ PHP_HASH_API void PHP_RIPEMD160Init(PHP_RIPEMD160_CTX * context) { @@ -74,6 +111,27 @@ } /* }}} */ +/* {{{ PHP_RIPEMD320Init + * ripemd320 initialization. Begins a ripemd320 operation, writing a new context. + */ +PHP_HASH_API void PHP_RIPEMD320Init(PHP_RIPEMD320_CTX * context) +{ + context->count[0] = context->count[1] = 0; + /* Load magic initialization constants. +*/ + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; + context->state[5] = 0x76543210; + context->state[6] = 0xFEDCBA98; + context->state[7] = 0x89ABCDEF; + context->state[8] = 0x01234567; + context->state[9] = 0x3C2D1E0F; +} +/* }}} */ + /* Basic ripemd function */ #define F0(x,y,z) ((x) ^ (y) ^ (z)) #define F1(x,y,z) (((x) & (y)) | ((~(x)) & (z))) @@ -81,9 +139,9 @@ #define F3(x,y,z) (((x) & (z)) | ((y) & (~(z #define F4(x,y,z) ((x) ^ ((y) | (~(z -static php_hash_uint32 K_values[5] = { 0x, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E }; -static php_hash_uin
[PHP-CVS] cvs: php-src /ext/hash hash.c /ext/hash/tests adler32.phpt crc32.phpt gost.phpt haval.phpt hmac-md5.phpt md2.phpt md4.phpt md5.phpt ripemd128.phpt ripemd160.phpt sha1.phpt sha256.phpt sha38
pollita Wed Sep 20 00:32:54 2006 UTC Modified files: /php-src/ext/hash hash.c /php-src/ext/hash/tests adler32.phpt crc32.phpt gost.phpt haval.phpt hmac-md5.phpt md2.phpt md4.phpt md5.phpt ripemd128.phpt ripemd160.phpt sha1.phpt sha256.phpt sha384.phpt sha512.phpt snefru.phpt tiger.phpt whirlpool.phpt Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.29&r2=1.30&diff_format=u Index: php-src/ext/hash/hash.c diff -u php-src/ext/hash/hash.c:1.29 php-src/ext/hash/hash.c:1.30 --- php-src/ext/hash/hash.c:1.29Tue Sep 19 23:42:49 2006 +++ php-src/ext/hash/hash.c Wed Sep 20 00:32:54 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: hash.c,v 1.29 2006/09/19 23:42:49 pollita Exp $ */ +/* $Id: hash.c,v 1.30 2006/09/20 00:32:54 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -67,22 +67,49 @@ { char *algo, *data, *digest; int algo_len, data_len; + zend_uchar data_type = IS_STRING; zend_bool raw_output = 0; php_hash_ops *ops; void *context; php_stream *stream = NULL; +#if PHP_MAJOR_VERSION >= 6 + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "st|b", &algo, &algo_len, &data, &data_len, &data_type, &raw_output) == FAILURE) { + return; + } + + if (data_type == IS_UNICODE) { + if (isfilename) { + if (php_stream_path_encode(NULL, &data, &data_len, (UChar *)data, data_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { + RETURN_FALSE; + } + } else { + /* Unicode string passed for raw hashing */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unicode strings can not be hashed. Convert to a binary type."); + RETURN_FALSE; + } + } +#else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &algo, &algo_len, &data, &data_len, &raw_output) == FAILURE) { return; } +#endif ops = php_hash_fetch_ops(algo, algo_len); if (!ops) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing algorithm: %s", algo); + if (data_type != IS_STRING) { + /* Original filename was UNICODE, this string is a converted copy */ + efree(data); + } RETURN_FALSE; } if (isfilename) { stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT); + if (data_type != IS_STRING) { + /* Original filename was UNICODE, this string is a converted copy */ + efree(data); + } if (!stream) { /* Stream will report errors opening file */ RETURN_FALSE; @@ -121,7 +148,7 @@ } } -/* {{{ proto string hash(string algo, string data[, bool raw_output = false]) +/* {{{ proto string hash(string algo, string data[, bool raw_output = false]) U Generate a hash of a given input string Returns lowercase hexits by default */ PHP_FUNCTION(hash) { @@ -129,7 +156,7 @@ } /* }}} */ -/* {{{ proto string hash_file(string algo, string filename[, bool raw_output = false]) +/* {{{ proto string hash_file(string algo, string filename[, bool raw_output = false]) U Generate a hash of a given file Returns lowercase hexits by default */ PHP_FUNCTION(hash_file) { @@ -141,23 +168,49 @@ { char *algo, *data, *digest, *key, *K; int algo_len, data_len, key_len, i; + zend_uchar data_type = IS_STRING; zend_bool raw_output = 0; php_hash_ops *ops; void *context; php_stream *stream = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|b", &algo, &algo_len, &data, &data_len, - &key, &key_len, &raw_output) == FAILURE) { +#if PHP_MAJOR_VERSION >= 6 + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "stS|b", &algo, &algo_len, &data, &data_len, &data_type, &key, &key_len, &raw_output) == FAILURE) { + return; + } + + if (data_type == IS_UNICODE) { + if (isfilename) { + if (php_stream_path_encode(NULL, &data, &data_len, (UChar *)data, data_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { + RETURN_FALSE; + } + } else { + /* Unicode string passed for raw hashing */ +
[PHP-CVS] cvs: php-src /ext/hash hash.c hash_md.c hash_sha.c php_hash_md.h php_hash_sha.h
pollita Tue Sep 19 23:42:49 2006 UTC Modified files: /php-src/ext/hash hash.c hash_md.c hash_sha.c php_hash_md.h php_hash_sha.h Log: Strip unused implementations of md5(), md5_file(), sha1(), and sha1_file() from this extension. It was decided a few months ago that those implementations would simply stay in ext/standard and never leave. http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.28&r2=1.29&diff_format=u Index: php-src/ext/hash/hash.c diff -u php-src/ext/hash/hash.c:1.28 php-src/ext/hash/hash.c:1.29 --- php-src/ext/hash/hash.c:1.28Fri Jul 28 14:27:17 2006 +++ php-src/ext/hash/hash.c Tue Sep 19 23:42:49 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: hash.c,v 1.28 2006/07/28 14:27:17 iliaa Exp $ */ +/* $Id: hash.c,v 1.29 2006/09/19 23:42:49 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -615,34 +615,6 @@ /* }}} */ /* {{{ arginfo */ -#ifdef PHP_HASH_MD5_NOT_IN_CORE -static -ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_md5, 0, 0, 1) - ZEND_ARG_INFO(0, str) - ZEND_ARG_INFO(0, raw_output) -ZEND_END_ARG_INFO() - -static -ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_md5_file, 0, 0, 1) - ZEND_ARG_INFO(0, filename) - ZEND_ARG_INFO(0, raw_output) -ZEND_END_ARG_INFO() -#endif - -#ifdef PHP_HASH_SHA1_NOT_IN_CORE -static -ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_sha1, 0, 0, 1) - ZEND_ARG_INFO(0, str) - ZEND_ARG_INFO(0, raw_output) -ZEND_END_ARG_INFO() - -static -ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_sha1_file, 0, 0, 1) - ZEND_ARG_INFO(0, filename) - ZEND_ARG_INFO(0, raw_output) -ZEND_END_ARG_INFO() -#endif - static ZEND_BEGIN_ARG_INFO_EX(arginfo_hash, 0, 0, 2) ZEND_ARG_INFO(0, algo) @@ -729,17 +701,6 @@ PHP_FE(hash_algos, arginfo_hash_algos) - /* BC Land */ -#ifdef PHP_HASH_MD5_NOT_IN_CORE - PHP_NAMED_FE(md5, php_if_md5, arginfo_hash_md5) - PHP_NAMED_FE(md5_file, php_if_md5_file, arginfo_hash_md5_file) -#endif /* PHP_HASH_MD5_NOT_IN_CORE */ - -#ifdef PHP_HASH_SHA1_NOT_IN_CORE - PHP_NAMED_FE(sha1, php_if_sha1, arginfo_hash_sha1) - PHP_NAMED_FE(sha1_file, php_if_sha1_file, arginfo_hash_sha1_file) -#endif /* PHP_HASH_SHA1_NOT_IN_CORE */ - {NULL, NULL, NULL} }; /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_md.c?r1=1.10&r2=1.11&diff_format=u Index: php-src/ext/hash/hash_md.c diff -u php-src/ext/hash/hash_md.c:1.10 php-src/ext/hash/hash_md.c:1.11 --- php-src/ext/hash/hash_md.c:1.10 Tue Feb 21 20:37:12 2006 +++ php-src/ext/hash/hash_md.c Tue Sep 19 23:42:49 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: hash_md.c,v 1.10 2006/02/21 20:37:12 pollita Exp $ */ +/* $Id: hash_md.c,v 1.11 2006/09/19 23:42:49 pollita Exp $ */ #include "php_hash.h" #include "php_hash_md.h" @@ -88,358 +88,6 @@ } /* }}} */ -#ifdef PHP_HASH_MD5_NOT_IN_CORE - -/* MD5 */ - -PHP_HASH_API void make_digest(char *md5str, unsigned char *digest) -{ - php_hash_bin2hex(md5str, digest, 16); - md5str[32] = '\0'; -} - -/* {{{ proto string md5(string str, [ bool raw_output]) - Calculate the md5 hash of a string */ -PHP_NAMED_FUNCTION(php_if_md5) -{ - char *arg; - int arg_len; - zend_bool raw_output = 0; - char md5str[33]; - PHP_MD5_CTX context; - unsigned char digest[16]; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { - return; - } - - md5str[0] = '\0'; - PHP_MD5Init(&context); - PHP_MD5Update(&context, arg, arg_len); - PHP_MD5Final(digest, &context); - if (raw_output) { - RETURN_STRINGL(digest, 16, 1); - } else { - make_digest(md5str, digest); - RETVAL_STRING(md5str, 1); - } - -} -/* }}} */ - -/* {{{ proto string md5_file(string filename [, bool raw_output]) - Calculate the md5 hash of given filename */ -PHP_NAMED_FUNCTION(php_if_md5_file) -{ - char *arg; - int arg_len; - zend_bool raw_output = 0; - char md5str[33]; - unsigned char buf[1024]; - unsigned char digest[16]; - PHP_MD5_CTX context; - int n; - php_stream*stream; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { - return; - } - - stream = php_stream_open_wrapper(arg, "rb", REPORT_ERRORS, NULL); - if (!stream) { - RETURN_FALSE; - } - - PHP_MD5Init(&context); - - while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) { -
[PHP-CVS] cvs: php-src /ext/bcmath bcmath.c
pollita Tue Sep 19 23:27:03 2006 UTC Modified files: /php-src/ext/bcmath bcmath.c Log: Refactor parameter parsing into the 21st century and flag Unicode readiness http://cvs.php.net/viewvc.cgi/php-src/ext/bcmath/bcmath.c?r1=1.66&r2=1.67&diff_format=u Index: php-src/ext/bcmath/bcmath.c diff -u php-src/ext/bcmath/bcmath.c:1.66 php-src/ext/bcmath/bcmath.c:1.67 --- php-src/ext/bcmath/bcmath.c:1.66Tue Jun 13 13:12:18 2006 +++ php-src/ext/bcmath/bcmath.c Tue Sep 19 23:27:03 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bcmath.c,v 1.66 2006/06/13 13:12:18 dmitry Exp $ */ +/* $Id: bcmath.c,v 1.67 2006/09/19 23:27:03 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -220,238 +220,190 @@ } /* }}} */ -/* {{{ proto string bcadd(string left_operand, string right_operand [, int scale]) + +/* {{{ proto string bcadd(string left_operand, string right_operand [, int scale]) U Returns the sum of two arbitrary precision numbers */ PHP_FUNCTION(bcadd) { - zval **left, **right, **scale_param; + char *left, *right; + int left_len, right_len; + long scale = BCG(bc_precision); bc_num first, second, result; - int scale = BCG(bc_precision); - switch (ZEND_NUM_ARGS()) { - case 2: - if (zend_get_parameters_ex(2, &left, &right) == FAILURE) { - WRONG_PARAM_COUNT; - } - break; - case 3: - if (zend_get_parameters_ex(3, &left, &right, &scale_param) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(scale_param); - scale = (int) (Z_LVAL_PP(scale_param) < 0) ? 0 : Z_LVAL_PP(scale_param); - break; - default: - WRONG_PARAM_COUNT; - break; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale) == FAILURE) { + return; + } + + if (scale < 0) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid scale given, using zero"); + scale = 0; } - convert_to_string_ex(left); - convert_to_string_ex(right); + bc_init_num(&first TSRMLS_CC); bc_init_num(&second TSRMLS_CC); bc_init_num(&result TSRMLS_CC); - php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC); - php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC); - bc_add (first, second, &result, scale); + php_str2num(&first, left TSRMLS_CC); + php_str2num(&second, right TSRMLS_CC); + + bc_add(first, second, &result, scale); if (result->n_scale > scale) { result->n_scale = scale; } - Z_STRVAL_P(return_value) = bc_num2str(result); - Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value)); - Z_TYPE_P(return_value) = IS_STRING; + + RETVAL_STRING(bc_num2str(result), 0); + bc_free_num(&first); bc_free_num(&second); bc_free_num(&result); - return; } /* }}} */ -/* {{{ proto string bcsub(string left_operand, string right_operand [, int scale]) +/* {{{ proto string bcsub(string left_operand, string right_operand [, int scale]) U Returns the difference between two arbitrary precision numbers */ PHP_FUNCTION(bcsub) { - zval **left, **right, **scale_param; + char *left, *right; + int left_len, right_len; + long scale = BCG(bc_precision); bc_num first, second, result; - int scale = BCG(bc_precision); - switch (ZEND_NUM_ARGS()) { - case 2: - if (zend_get_parameters_ex(2, &left, &right) == FAILURE) { - WRONG_PARAM_COUNT; - } - break; - case 3: - if (zend_get_parameters_ex(3, &left, &right, &scale_param) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(scale_param); - scale = (int) (Z_LVAL_PP(scale_param) < 0) ? 0 : Z_LVAL_PP(scale_param); - break; - default: - WRONG_PARAM_COUNT; - break; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale) == FAILURE) { + return; + } + + if (scale < 0) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid scale given, using ze
[PHP-CVS] cvs: php-src /ext/standard streamsfuncs.c /main/streams streams.c ZendEngine2 zend.c zend_globals.h
pollita Tue Sep 19 20:36:49 2006 UTC Modified files: /ZendEngine2zend.c zend_globals.h /php-src/ext/standard streamsfuncs.c /php-src/main/streams streams.c Log: Add INI controlled default stream encoding (unicode.stream_encoding). Add convenience function stream_defualt_encoding() for setting it. http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.370&r2=1.371&diff_format=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.370 ZendEngine2/zend.c:1.371 --- ZendEngine2/zend.c:1.370Mon Sep 11 14:28:19 2006 +++ ZendEngine2/zend.c Tue Sep 19 20:36:48 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: zend.c,v 1.370 2006/09/11 14:28:19 tony2001 Exp $ */ +/* $Id: zend.c,v 1.371 2006/09/19 20:36:48 pollita Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -181,6 +181,7 @@ 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) + STD_ZEND_INI_ENTRY("unicode.stream_encoding", "utf8", ZEND_INI_ALL, OnUpdateStringUnempty, stream_encoding, zend_unicode_globals, unicode_globals) ZEND_INI_END() http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_globals.h?r1=1.162&r2=1.163&diff_format=u Index: ZendEngine2/zend_globals.h diff -u ZendEngine2/zend_globals.h:1.162 ZendEngine2/zend_globals.h:1.163 --- ZendEngine2/zend_globals.h:1.162Mon Sep 11 14:28:19 2006 +++ ZendEngine2/zend_globals.h Tue Sep 19 20:36:48 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: zend_globals.h,v 1.162 2006/09/11 14:28:19 tony2001 Exp $ */ +/* $Id: zend_globals.h,v 1.163 2006/09/19 20:36:48 pollita Exp $ */ #ifndef ZEND_GLOBALS_H #define ZEND_GLOBALS_H @@ -276,6 +276,10 @@ UConverter *utf8_conv; /* all-purpose UTF-8 converter */ UConverter *ascii_conv; /* all-purpose ASCII converter */ + char *stream_encoding; /* default stream encoding (contents, not FS entries) + Uses name of encoding rather than a real converter + because each stream needs its own instance */ + uint16_t from_error_mode; UChar from_subst_char[3]; uint16_t to_error_mode; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.85&r2=1.86&diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.85 php-src/ext/standard/streamsfuncs.c:1.86 --- php-src/ext/standard/streamsfuncs.c:1.85Tue Sep 19 10:38:31 2006 +++ php-src/ext/standard/streamsfuncs.c Tue Sep 19 20:36:48 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.85 2006/09/19 10:38:31 dmitry Exp $ */ +/* $Id: streamsfuncs.c,v 1.86 2006/09/19 20:36:48 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -1458,6 +1458,24 @@ } /* }}} */ + +/* {{{ proto bool stream_default_encoding(string encoding) U +Convenience wrapper for ini_set('unicode.stream_encoding', $encoding) */ +PHP_FUNCTION(stream_default_encoding) +{ + char *encoding; + int encoding_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &encoding, &encoding_len) == FAILURE) { + return; + } + + RETURN_BOOL(SUCCESS == zend_alter_ini_entry("unicode.stream_encoding", sizeof("unicode.stream_encoding"), + encoding, encoding_len, PHP_INI_ALL, PHP_INI_STAGE_RUNTIME)); +} +/* }}} */ + + /* {{{ proto void stream_encoding(resource stream[, string encoding]) Set character set for stream encoding UTODO: Return current encoding charset http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.134&r2=1.135&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.134 php-src/main/streams/streams.c:1.135 --- php-src/main/streams/streams.c:1.134Tue Sep 19 10:38:31 2006 +++ php-src/main/streams/streams.c Tue Sep 19 20:36:48 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.134 2006/09/19 10:38:31 dmitry Exp $ */ +/* $Id: streams.c,v 1.135 2006/09/19 20:36:48 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -2306,7 +2306,7 @@ /* Only apply implicit unicode.to. filter if the wrapper d
[PHP-CVS] cvs: php-src(PHP_5_1) /main network.c
pollita Mon Sep 11 19:18:10 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/main network.c Log: MFH: Bug #38687 - sockaddr local storage insufficient for all sock families http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.118.2.2&r2=1.118.2.3&diff_format=u Index: php-src/main/network.c diff -u php-src/main/network.c:1.118.2.2 php-src/main/network.c:1.118.2.3 --- php-src/main/network.c:1.118.2.2Sun Mar 19 22:33:10 2006 +++ php-src/main/network.c Mon Sep 11 19:18:10 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: network.c,v 1.118.2.2 2006/03/19 22:33:10 tony2001 Exp $ */ +/* $Id: network.c,v 1.118.2.3 2006/09/11 19:18:10 pollita Exp $ */ /*#define DEBUG_MAIN_NETWORK 1*/ @@ -787,37 +787,46 @@ /* make a connection attempt */ if (bindto) { - struct sockaddr local_address; + struct sockaddr *local_address = NULL; + int local_address_len = 0; if (sa->sa_family == AF_INET) { - struct sockaddr_in *in4 = (struct sockaddr_in*)&local_address; + struct sockaddr_in *in4 = emalloc(sizeof(struct sockaddr_in)); + + local_address = (struct sockaddr*)in4; + local_address_len = sizeof(struct sockaddr_in); in4->sin_family = sa->sa_family; in4->sin_port = htons(bindport); if (!inet_aton(bindto, &in4->sin_addr)) { - goto bad_ip; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto); + goto skip_bind; } memset(&(in4->sin_zero), 0, sizeof(in4->sin_zero)); } #if HAVE_IPV6 && HAVE_INET_PTON else { /* IPV6 */ - struct sockaddr_in6 *in6 = (struct sockaddr_in6*)&local_address; + struct sockaddr_in6 *in6 = emalloc(sizeof(struct sockaddr_in6)); + + local_address = (struct sockaddr*)in6; + local_address_len = sizeof(struct sockaddr_in6); in6->sin6_family = sa->sa_family; in6->sin6_port = htons(bindport); if (inet_pton(AF_INET6, bindto, &in6->sin6_addr) < 1) { - goto bad_ip; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto); + goto skip_bind; } } #endif - if (bind(sock, &local_address, sizeof(struct sockaddr))) { + if (!local_address || bind(sock, local_address, local_address_len)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to bind to '%s:%d', system said: %s", bindto, bindport, strerror(errno)); } - goto bind_done; -bad_ip: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto); +skip_bind: + if (local_address) { + efree(local_address); + } } -bind_done: /* free error string recieved during previous iteration (if any) */ if (error_string && *error_string) { efree(*error_string); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main network.c
pollita Mon Sep 11 19:18:06 2006 UTC Modified files: /php-src/main network.c Log: Bug #38687 - sockaddr local storage insufficient for all sock families http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.122&r2=1.123&diff_format=u Index: php-src/main/network.c diff -u php-src/main/network.c:1.122 php-src/main/network.c:1.123 --- php-src/main/network.c:1.122Sat Jul 1 11:50:52 2006 +++ php-src/main/network.c Mon Sep 11 19:18:06 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: network.c,v 1.122 2006/07/01 11:50:52 nlopess Exp $ */ +/* $Id: network.c,v 1.123 2006/09/11 19:18:06 pollita Exp $ */ /*#define DEBUG_MAIN_NETWORK 1*/ @@ -787,37 +787,46 @@ /* make a connection attempt */ if (bindto) { - struct sockaddr local_address; - + struct sockaddr *local_address = NULL; + int local_address_len = 0; + if (sa->sa_family == AF_INET) { - struct sockaddr_in *in4 = (struct sockaddr_in*)&local_address; - + struct sockaddr_in *in4 = emalloc(sizeof(struct sockaddr_in)); + + local_address = (struct sockaddr*)in4; + local_address_len = sizeof(struct sockaddr_in); + in4->sin_family = sa->sa_family; in4->sin_port = htons(bindport); if (!inet_aton(bindto, &in4->sin_addr)) { - goto bad_ip; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto); + goto skip_bind; } memset(&(in4->sin_zero), 0, sizeof(in4->sin_zero)); } #if HAVE_IPV6 && HAVE_INET_PTON else { /* IPV6 */ - struct sockaddr_in6 *in6 = (struct sockaddr_in6*)&local_address; + struct sockaddr_in6 *in6 = emalloc(sizeof(struct sockaddr_in6)); + + local_address = (struct sockaddr*)in6; + local_address_len = sizeof(struct sockaddr_in6); in6->sin6_family = sa->sa_family; in6->sin6_port = htons(bindport); if (inet_pton(AF_INET6, bindto, &in6->sin6_addr) < 1) { - goto bad_ip; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto); + goto skip_bind; } } #endif - if (bind(sock, &local_address, sizeof(struct sockaddr))) { + if (!local_address || bind(sock, local_address, local_address_len)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to bind to '%s:%d', system said: %s", bindto, bindport, strerror(errno)); } - goto bind_done; -bad_ip: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto); +skip_bind: + if (local_address) { + efree(local_address); + } } -bind_done: /* free error string recieved during previous iteration (if any) */ if (error_string && *error_string) { efree(*error_string); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /main network.c
pollita Mon Sep 11 19:18:07 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/main network.c Log: MFH: Bug #38687 - sockaddr local storage insufficient for all sock families http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.118.2.2.2.1&r2=1.118.2.2.2.2&diff_format=u Index: php-src/main/network.c diff -u php-src/main/network.c:1.118.2.2.2.1 php-src/main/network.c:1.118.2.2.2.2 --- php-src/main/network.c:1.118.2.2.2.1Sat Jul 1 11:35:34 2006 +++ php-src/main/network.c Mon Sep 11 19:18:07 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: network.c,v 1.118.2.2.2.1 2006/07/01 11:35:34 nlopess Exp $ */ +/* $Id: network.c,v 1.118.2.2.2.2 2006/09/11 19:18:07 pollita Exp $ */ /*#define DEBUG_MAIN_NETWORK 1*/ @@ -787,37 +787,46 @@ /* make a connection attempt */ if (bindto) { - struct sockaddr local_address; + struct sockaddr *local_address = NULL; + int local_address_len = 0; if (sa->sa_family == AF_INET) { - struct sockaddr_in *in4 = (struct sockaddr_in*)&local_address; + struct sockaddr_in *in4 = emalloc(sizeof(struct sockaddr_in)); + + local_address = (struct sockaddr*)in4; + local_address_len = sizeof(struct sockaddr_in); in4->sin_family = sa->sa_family; in4->sin_port = htons(bindport); if (!inet_aton(bindto, &in4->sin_addr)) { - goto bad_ip; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto); + goto skip_bind; } memset(&(in4->sin_zero), 0, sizeof(in4->sin_zero)); } #if HAVE_IPV6 && HAVE_INET_PTON else { /* IPV6 */ - struct sockaddr_in6 *in6 = (struct sockaddr_in6*)&local_address; + struct sockaddr_in6 *in6 = emalloc(sizeof(struct sockaddr_in6)); + + local_address = (struct sockaddr*)in6; + local_address_len = sizeof(struct sockaddr_in6); in6->sin6_family = sa->sa_family; in6->sin6_port = htons(bindport); if (inet_pton(AF_INET6, bindto, &in6->sin6_addr) < 1) { - goto bad_ip; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto); + goto skip_bind; } } #endif - if (bind(sock, &local_address, sizeof(struct sockaddr))) { + if (!local_address || bind(sock, local_address, local_address_len)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to bind to '%s:%d', system said: %s", bindto, bindport, strerror(errno)); } - goto bind_done; -bad_ip: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto); +skip_bind: + if (local_address) { + efree(local_address); + } } -bind_done: /* free error string recieved during previous iteration (if any) */ if (error_string && *error_string) { efree(*error_string); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams unicode_filter.c
pollita Fri Jul 14 22:24:08 2006 UTC Modified files: /php-src/main/streams unicode_filter.c Log: Logic fix: (!a == b) != (a != b) http://cvs.php.net/viewvc.cgi/php-src/main/streams/unicode_filter.c?r1=1.2&r2=1.3&diff_format=u Index: php-src/main/streams/unicode_filter.c diff -u php-src/main/streams/unicode_filter.c:1.2 php-src/main/streams/unicode_filter.c:1.3 --- php-src/main/streams/unicode_filter.c:1.2 Fri Jul 14 19:15:31 2006 +++ php-src/main/streams/unicode_filter.c Fri Jul 14 22:24:07 2006 @@ -14,7 +14,7 @@ +--+ */ -/* $Id: unicode_filter.c,v 1.2 2006/07/14 19:15:31 pollita Exp $ */ +/* $Id: unicode_filter.c,v 1.3 2006/07/14 22:24:07 pollita Exp $ */ #include "php.h" @@ -56,7 +56,7 @@ UChar *src = bucket->buf.u; php_stream_bucket_unlink(bucket TSRMLS_CC); - if (!bucket->buf_type == IS_UNICODE) { + if (bucket->buf_type != IS_UNICODE) { /* Already ASCII, can't really do anything with it */ consumed += bucket->buflen; php_stream_bucket_append(buckets_out, bucket 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
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.446&r2=1.447&diff_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
pollita Fri Jul 14 19:16:23 2006 UTC Modified files: /php-src/ext/standard file.c Log: #38105 (3/3) Default file_put_contents() to FILE_TEXT when unicode.semantics=on and flags param not specified http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.444&r2=1.445&diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.444 php-src/ext/standard/file.c:1.445 --- php-src/ext/standard/file.c:1.444 Mon May 29 10:42:10 2006 +++ php-src/ext/standard/file.c Fri Jul 14 19:16:23 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.444 2006/05/29 10:42:10 tony2001 Exp $ */ +/* $Id: file.c,v 1.445 2006/07/14 19:16:23 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -578,19 +578,20 @@ Write/Create a file with contents data and return the number of bytes written */ PHP_FUNCTION(file_put_contents) { + int argc = ZEND_NUM_ARGS(); php_stream *stream; char *filename; int filename_len; zend_uchar filename_type; zval *data; int numchars = 0; - long flags = 0; + 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; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "tz/|lr!", &filename, &filename_len, &filename_type, + if (zend_parse_parameters(argc TSRMLS_CC, "tz/|lr!", &filename, &filename_len, &filename_type, &data, &flags, &zcontext) == FAILURE) { return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams unicode_filter.c
pollita Fri Jul 14 19:15:31 2006 UTC Modified files: /php-src/main/streams unicode_filter.c Log: #38105 (2/3) Filters should report char/UChar count, not bytes http://cvs.php.net/viewvc.cgi/php-src/main/streams/unicode_filter.c?r1=1.1&r2=1.2&diff_format=u Index: php-src/main/streams/unicode_filter.c diff -u php-src/main/streams/unicode_filter.c:1.1 php-src/main/streams/unicode_filter.c:1.2 --- php-src/main/streams/unicode_filter.c:1.1 Wed Mar 29 01:20:43 2006 +++ php-src/main/streams/unicode_filter.c Fri Jul 14 19:15:31 2006 @@ -14,7 +14,7 @@ +--+ */ -/* $Id: unicode_filter.c,v 1.1 2006/03/29 01:20:43 pollita Exp $ */ +/* $Id: unicode_filter.c,v 1.2 2006/07/14 19:15:31 pollita Exp $ */ #include "php.h" @@ -79,7 +79,7 @@ php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC); exit_status = PSFS_PASS_ON; } - consumed += UBYTES(bucket->buflen); + consumed += bucket->buflen; php_stream_bucket_delref(bucket TSRMLS_CC); } @@ -131,7 +131,7 @@ php_stream_bucket_unlink(bucket TSRMLS_CC); if (bucket->buf_type == IS_UNICODE) { /* already in unicode, nothing to do */ - consumed += UBYTES(bucket->buflen); + consumed += bucket->buflen; php_stream_bucket_append(buckets_out, bucket TSRMLS_CC); exit_status = PSFS_PASS_ON; continue; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Fri Jul 14 19:14:40 2006 UTC Modified files: /php-src/main/streams streams.c Log: #38105 (1/3) Backward logic, filter_product == IS_STRING means the wrapper HAS applied pre-filtering http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.128&r2=1.129&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.128 php-src/main/streams/streams.c:1.129 --- php-src/main/streams/streams.c:1.128Thu Jul 13 11:58:42 2006 +++ php-src/main/streams/streams.c Fri Jul 14 19:14:40 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.128 2006/07/13 11:58:42 tony2001 Exp $ */ +/* $Id: streams.c,v 1.129 2006/07/14 19:14:40 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -2303,7 +2303,7 @@ /* 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_STRING) && + 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 : "utf8"; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/spl/tests iterator_041b.phpt /ext/standard/tests/file mkdir-004.phpt mkdir-005.phpt
pollita Tue May 30 19:06:22 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/spl/tests iterator_041b.phpt /php-src/ext/standard/tests/filemkdir-004.phpt mkdir-005.phpt Log: MFH: Minor fixes (bjori) http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/tests/iterator_041b.phpt?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-src/ext/spl/tests/iterator_041b.phpt diff -u php-src/ext/spl/tests/iterator_041b.phpt:1.1.2.3 php-src/ext/spl/tests/iterator_041b.phpt:1.1.2.4 --- php-src/ext/spl/tests/iterator_041b.phpt:1.1.2.3Wed May 24 23:04:58 2006 +++ php-src/ext/spl/tests/iterator_041b.phptTue May 30 19:06:21 2006 @@ -94,7 +94,7 @@ ?> ===DONE=== ---EXPECT-- +--EXPECTF-- ===iterator_to_array=== State 0: __construct() State 1: __construct() http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/mkdir-004.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-src/ext/standard/tests/file/mkdir-004.phpt diff -u php-src/ext/standard/tests/file/mkdir-004.phpt:1.1.2.1 php-src/ext/standard/tests/file/mkdir-004.phpt:1.1.2.2 --- php-src/ext/standard/tests/file/mkdir-004.phpt:1.1.2.1 Tue May 16 13:06:06 2006 +++ php-src/ext/standard/tests/file/mkdir-004.phpt Tue May 30 19:06:22 2006 @@ -1,7 +1,7 @@ --TEST-- recursive mkdir() tests --SKIPIF-- -http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/mkdir-005.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-src/ext/standard/tests/file/mkdir-005.phpt diff -u php-src/ext/standard/tests/file/mkdir-005.phpt:1.1.2.1 php-src/ext/standard/tests/file/mkdir-005.phpt:1.1.2.2 --- php-src/ext/standard/tests/file/mkdir-005.phpt:1.1.2.1 Tue May 16 13:06:06 2006 +++ php-src/ext/standard/tests/file/mkdir-005.phpt Tue May 30 19:06:22 2006 @@ -1,7 +1,7 @@ --TEST-- recursive mkdir() tests --SKIPIF-- -http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/spl/tests iterator_041b.phpt /ext/standard/tests/file mkdir-004.phpt mkdir-005.phpt
pollita Tue May 30 19:05:21 2006 UTC Modified files: /php-src/ext/spl/tests iterator_041b.phpt /php-src/ext/standard/tests/filemkdir-004.phpt mkdir-005.phpt Log: Minor fixes (bjori) http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/tests/iterator_041b.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/spl/tests/iterator_041b.phpt diff -u php-src/ext/spl/tests/iterator_041b.phpt:1.2 php-src/ext/spl/tests/iterator_041b.phpt:1.3 --- php-src/ext/spl/tests/iterator_041b.phpt:1.2Wed May 24 23:05:30 2006 +++ php-src/ext/spl/tests/iterator_041b.phptTue May 30 19:05:21 2006 @@ -94,7 +94,7 @@ ?> ===DONE=== ---EXPECT-- +--EXPECTF-- ===iterator_to_array=== State 0: __construct() State 1: __construct() http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/mkdir-004.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/file/mkdir-004.phpt diff -u php-src/ext/standard/tests/file/mkdir-004.phpt:1.2 php-src/ext/standard/tests/file/mkdir-004.phpt:1.3 --- php-src/ext/standard/tests/file/mkdir-004.phpt:1.2 Tue May 16 13:07:07 2006 +++ php-src/ext/standard/tests/file/mkdir-004.phpt Tue May 30 19:05:21 2006 @@ -1,7 +1,7 @@ --TEST-- recursive mkdir() tests --SKIPIF-- -http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/mkdir-005.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/file/mkdir-005.phpt diff -u php-src/ext/standard/tests/file/mkdir-005.phpt:1.2 php-src/ext/standard/tests/file/mkdir-005.phpt:1.3 --- php-src/ext/standard/tests/file/mkdir-005.phpt:1.2 Tue May 16 13:07:07 2006 +++ php-src/ext/standard/tests/file/mkdir-005.phpt Tue May 30 19:05:21 2006 @@ -1,7 +1,7 @@ --TEST-- recursive mkdir() tests --SKIPIF-- -http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/pdo package2.xml
pollita Thu May 4 00:21:51 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/pdopackage2.xml Log: Note addition of new class constants http://cvs.php.net/viewcvs.cgi/php-src/ext/pdo/package2.xml?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: php-src/ext/pdo/package2.xml diff -u php-src/ext/pdo/package2.xml:1.1.2.2 php-src/ext/pdo/package2.xml:1.1.2.3 --- php-src/ext/pdo/package2.xml:1.1.2.2Tue May 2 02:32:40 2006 +++ php-src/ext/pdo/package2.xmlThu May 4 00:21:51 2006 @@ -61,6 +61,7 @@ http://pecl4win.php.net ** Changes ** +- Added PDO::PARAM_EVT_* family of constants. (Sara) - Fixed bug #37167 (PDO segfaults when throwing exception from the fetch handler). (Tony) - Fixed memory corruption when PDO::FETCH_LAZY mode is being used. (Ilia) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) / NEWS
pollita Wed May 3 22:44:37 2006 UTC Modified files: (Branch: PHP_5_1) /php-srcNEWS Log: News entry for exporting PDO::PARAM_EVT_* constants http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.545&r2=1.2027.2.546&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.545 php-src/NEWS:1.2027.2.546 --- php-src/NEWS:1.2027.2.545 Wed May 3 13:32:46 2006 +++ php-src/NEWSWed May 3 22:44:37 2006 @@ -3,6 +3,7 @@ 04 May 2006, PHP 5.1.4 - Added "capture_peer_cert" and "capture_peer_cert_chain" context options for SSL streams. (Wez). +- Added PDO::PARAM_EVT_* family of constants. (Sara) - Fixed possible crash in highlight_string(). (Dmitry) - Fixed bug #37291 (FastCGI now longer works with isapi_fcgi.dll). (Dmitry) - Fixed bug #37277 (cloning Dom Documents or Nodes does not work). (Rob) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/pdo pdo_dbh.c
pollita Wed May 3 21:58:39 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/pdopdo_dbh.c Log: mfh(r-1.129) Expose PARAM_EVT_* constants http://cvs.php.net/viewcvs.cgi/php-src/ext/pdo/pdo_dbh.c?r1=1.82.2.30&r2=1.82.2.31&diff_format=u Index: php-src/ext/pdo/pdo_dbh.c diff -u php-src/ext/pdo/pdo_dbh.c:1.82.2.30 php-src/ext/pdo/pdo_dbh.c:1.82.2.31 --- php-src/ext/pdo/pdo_dbh.c:1.82.2.30 Sun Apr 9 08:05:01 2006 +++ php-src/ext/pdo/pdo_dbh.c Wed May 3 21:58:38 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: pdo_dbh.c,v 1.82.2.30 2006/04/09 08:05:01 wez Exp $ */ +/* $Id: pdo_dbh.c,v 1.82.2.31 2006/05/03 21:58:38 pollita Exp $ */ /* The PDO Database Handle Class */ @@ -1250,6 +1250,14 @@ REGISTER_PDO_CLASS_CONST_LONG("PARAM_STMT", (long)PDO_PARAM_STMT); REGISTER_PDO_CLASS_CONST_LONG("PARAM_INPUT_OUTPUT", (long)PDO_PARAM_INPUT_OUTPUT); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_ALLOC", (long)PDO_PARAM_EVT_ALLOC); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FREE", (long)PDO_PARAM_EVT_FREE); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_EXEC_PRE", (long)PDO_PARAM_EVT_EXEC_PRE); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_EXEC_POST", (long)PDO_PARAM_EVT_EXEC_POST); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_PRE", (long)PDO_PARAM_EVT_FETCH_PRE); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_POST", (long)PDO_PARAM_EVT_FETCH_POST); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_NORMALIZE", (long)PDO_PARAM_EVT_NORMALIZE); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_LAZY", (long)PDO_FETCH_LAZY); REGISTER_PDO_CLASS_CONST_LONG("FETCH_ASSOC",(long)PDO_FETCH_ASSOC); REGISTER_PDO_CLASS_CONST_LONG("FETCH_NUM", (long)PDO_FETCH_NUM); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/pdo pdo_dbh.c
pollita Wed May 3 21:57:58 2006 UTC Modified files: /php-src/ext/pdopdo_dbh.c Log: Expose PARAM_EVT_* constants http://cvs.php.net/viewcvs.cgi/php-src/ext/pdo/pdo_dbh.c?r1=1.128&r2=1.129&diff_format=u Index: php-src/ext/pdo/pdo_dbh.c diff -u php-src/ext/pdo/pdo_dbh.c:1.128 php-src/ext/pdo/pdo_dbh.c:1.129 --- php-src/ext/pdo/pdo_dbh.c:1.128 Sat Apr 29 14:53:26 2006 +++ php-src/ext/pdo/pdo_dbh.c Wed May 3 21:57:58 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: pdo_dbh.c,v 1.128 2006/04/29 14:53:26 fmk Exp $ */ +/* $Id: pdo_dbh.c,v 1.129 2006/05/03 21:57:58 pollita Exp $ */ /* The PDO Database Handle Class */ @@ -1266,6 +1266,14 @@ REGISTER_PDO_CLASS_CONST_LONG("PARAM_STMT", (long)PDO_PARAM_STMT); REGISTER_PDO_CLASS_CONST_LONG("PARAM_INPUT_OUTPUT", (long)PDO_PARAM_INPUT_OUTPUT); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_ALLOC", (long)PDO_PARAM_EVT_ALLOC); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FREE", (long)PDO_PARAM_EVT_FREE); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_EXEC_PRE", (long)PDO_PARAM_EVT_EXEC_PRE); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_EXEC_POST", (long)PDO_PARAM_EVT_EXEC_POST); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_PRE", (long)PDO_PARAM_EVT_FETCH_PRE); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_POST", (long)PDO_PARAM_EVT_FETCH_POST); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_NORMALIZE", (long)PDO_PARAM_EVT_NORMALIZE); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_LAZY", (long)PDO_FETCH_LAZY); REGISTER_PDO_CLASS_CONST_LONG("FETCH_ASSOC",(long)PDO_FETCH_ASSOC); REGISTER_PDO_CLASS_CONST_LONG("FETCH_NUM", (long)PDO_FETCH_NUM); -- 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.439&r2=1.440&diff_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); + } i
[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.436&r2=1.437&diff_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 /main php_streams.h /main/streams streams.c
pollita Tue Apr 18 19:09:31 2006 UTC Modified files: /php-src/main php_streams.h /php-src/main/streams streams.c Log: Fix copy/paste typo in php_stream_path_decode() proto http://cvs.php.net/viewcvs.cgi/php-src/main/php_streams.h?r1=1.111&r2=1.112&diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.111 php-src/main/php_streams.h:1.112 --- php-src/main/php_streams.h:1.111Fri Mar 31 22:51:37 2006 +++ php-src/main/php_streams.h Tue Apr 18 19:09:31 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.111 2006/03/31 22:51:37 pollita Exp $ */ +/* $Id: php_streams.h,v 1.112 2006/04/18 19:09:31 pollita Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -380,7 +380,7 @@ _php_stream_path_encode((wrapper), (pathenc), (pathenc_len), (path), (path_len), (options), (context) TSRMLS_CC) PHPAPI int _php_stream_path_decode(php_stream_wrapper *wrapper, - char **pathdec, int *pathdec_len, UChar *path, int path_len, + UChar **pathdec, int *pathdec_len, char *path, int path_len, int options, php_stream_context *context TSRMLS_DC); #define php_stream_path_decode(wrapper, pathdec, pathdec_len, path, path_len, options, context) \ _php_stream_path_decode((wrapper), (pathdec), (pathdec_len), (path), (path_len), (options), (context) TSRMLS_CC) http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.120&r2=1.121&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.120 php-src/main/streams/streams.c:1.121 --- php-src/main/streams/streams.c:1.120Wed Apr 12 22:40:56 2006 +++ php-src/main/streams/streams.c Tue Apr 18 19:09:31 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.120 2006/04/12 22:40:56 pollita Exp $ */ +/* $Id: streams.c,v 1.121 2006/04/18 19:09:31 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -2653,7 +2653,7 @@ Otherwise (or if wrapper == NULL) the INI defined filesystem_encoding converter will be used. */ PHPAPI int _php_stream_path_decode(php_stream_wrapper *wrapper, - char **pathdec, int *pathdec_len, UChar *path, int path_len, + UChar **pathdec, int *pathdec_len, char *path, int path_len, int options, php_stream_context *context TSRMLS_DC) { int num_conv; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/standard filters.c
pollita Mon Apr 17 19:26:05 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/standard filters.c Log: MFH(r-1.55) Fix 'soft line break' handling in convert.quoted-printable-decode http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/filters.c?r1=1.44.2.5&r2=1.44.2.6&diff_format=u Index: php-src/ext/standard/filters.c diff -u php-src/ext/standard/filters.c:1.44.2.5 php-src/ext/standard/filters.c:1.44.2.6 --- php-src/ext/standard/filters.c:1.44.2.5 Wed Jan 18 23:55:47 2006 +++ php-src/ext/standard/filters.c Mon Apr 17 19:26:04 2006 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: filters.c,v 1.44.2.5 2006/01/18 23:55:47 tony2001 Exp $ */ +/* $Id: filters.c,v 1.44.2.6 2006/04/17 19:26:04 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -1031,6 +1031,18 @@ scan_stat = 4; ps++, icnt--; break; + } else if (!inst->lbchars && lb_cnt == 0 && *ps == '\r') { + /* auto-detect line endings, looks like network line ending \r\n (could be mac \r) */ + lb_cnt++; + scan_stat = 5; + ps++, icnt--; + break; + } else if (!inst->lbchars && lb_cnt == 0 && *ps == '\n') { + /* auto-detect line endings, looks like unix-lineendings, not to spec, but it is seem in the wild, a lot */ + lb_cnt = lb_ptr = 0; + scan_stat = 0; + ps++, icnt--; + break; } else if (lb_cnt < inst->lbchars_len && *ps == (unsigned char)inst->lbchars[lb_cnt]) { lb_cnt++; @@ -1088,7 +1100,16 @@ } break; case 5: { - if (lb_cnt >= inst->lbchars_len) { + if (!inst->lbchars && lb_cnt == 1 && *ps == '\n') { + /* auto-detect soft line breaks, found network line break */ + lb_cnt = lb_ptr = 0; + scan_stat = 0; + ps++, icnt--; /* consume \n */ + } else if (!inst->lbchars && lb_cnt > 0) { + /* auto-detect soft line breaks, found mac line break */ + lb_cnt = lb_ptr = 0; + scan_stat = 0; + } else if (lb_cnt >= inst->lbchars_len) { /* soft line break */ lb_cnt = lb_ptr = 0; scan_stat = 0; @@ -1408,12 +1429,10 @@ size_t lbchars_len; if (options != NULL) { + /* If line-break-chars are not specified, filter will attempt to detect line endings (\r, \n, or \r\n) */ GET_STR_PROP(options, lbchars, lbchars_len, "line-break-chars", 0); - if (lbchars == NULL) { - lbchars = pestrdup("\r\n", 0); - lbchars_len = 2; - } } + retval = pemalloc(sizeof(php_conv_qprint_decode), persistent); if (lbchars != NULL) { if (php_conv_qprint_decode_ctor((php_conv_qprint_decode *)retval, lbchars, lbchars_len, 1, persistent)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard filters.c
pollita Mon Apr 17 19:25:48 2006 UTC Modified files: /php-src/ext/standard filters.c Log: Fix 'soft line break' handling in convert.quoted-printable-decode http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/filters.c?r1=1.54&r2=1.55&diff_format=u Index: php-src/ext/standard/filters.c diff -u php-src/ext/standard/filters.c:1.54 php-src/ext/standard/filters.c:1.55 --- php-src/ext/standard/filters.c:1.54 Mon Mar 20 20:09:20 2006 +++ php-src/ext/standard/filters.c Mon Apr 17 19:25:48 2006 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: filters.c,v 1.54 2006/03/20 20:09:20 tony2001 Exp $ */ +/* $Id: filters.c,v 1.55 2006/04/17 19:25:48 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -1108,6 +1108,18 @@ scan_stat = 4; ps++, icnt--; break; + } else if (!inst->lbchars && lb_cnt == 0 && *ps == '\r') { + /* auto-detect line endings, looks like network line ending \r\n (could be mac \r) */ + lb_cnt++; + scan_stat = 5; + ps++, icnt--; + break; + } else if (!inst->lbchars && lb_cnt == 0 && *ps == '\n') { + /* auto-detect line endings, looks like unix-lineendings, not to spec, but it is seem in the wild, a lot */ + lb_cnt = lb_ptr = 0; + scan_stat = 0; + ps++, icnt--; + break; } else if (lb_cnt < inst->lbchars_len && *ps == (unsigned char)inst->lbchars[lb_cnt]) { lb_cnt++; @@ -1165,7 +1177,16 @@ } break; case 5: { - if (lb_cnt >= inst->lbchars_len) { + if (!inst->lbchars && lb_cnt == 1 && *ps == '\n') { + /* auto-detect soft line breaks, found network line break */ + lb_cnt = lb_ptr = 0; + scan_stat = 0; + ps++, icnt--; /* consume \n */ + } else if (!inst->lbchars && lb_cnt > 0) { + /* auto-detect soft line breaks, found mac line break */ + lb_cnt = lb_ptr = 0; + scan_stat = 0; + } else if (lb_cnt >= inst->lbchars_len) { /* soft line break */ lb_cnt = lb_ptr = 0; scan_stat = 0; @@ -1486,10 +1507,6 @@ if (options != NULL) { GET_STR_PROP(options, lbchars, lbchars_len, "line-break-chars", 0); - if (lbchars == NULL) { - lbchars = pestrdup("\r\n", 0); - lbchars_len = 2; - } } retval = pemalloc(sizeof(php_conv_qprint_decode), persistent); if (lbchars != NULL) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c
pollita Fri Apr 14 17:47:51 2006 UTC Modified files: (Branch: PHP_4_3) /php-src/ext/standard file.c Log: MFH (r-1.436) copy() should not disrespect open_basedir on source file http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.279.2.70&r2=1.279.2.71&diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.279.2.70 php-src/ext/standard/file.c:1.279.2.71 --- php-src/ext/standard/file.c:1.279.2.70 Sun Mar 27 15:53:59 2005 +++ php-src/ext/standard/file.c Fri Apr 14 17:47:51 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.279.2.70 2005/03/27 15:53:59 iliaa Exp $ */ +/* $Id: file.c,v 1.279.2.71 2006/04/14 17:47:51 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2143,7 +2143,7 @@ int ret = FAILURE; srcstream = php_stream_open_wrapper(src, "rb", - STREAM_DISABLE_OPEN_BASEDIR | REPORT_ERRORS, + ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); if (!srcstream) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_4) /ext/standard file.c
pollita Fri Apr 14 17:46:59 2006 UTC Modified files: (Branch: PHP_4_4) /php-src/ext/standard file.c Log: MFH (r-1.436) copy() should not disrespect open_basedir on source file http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.279.2.70.2.6&r2=1.279.2.70.2.7&diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.279.2.70.2.6 php-src/ext/standard/file.c:1.279.2.70.2.7 --- php-src/ext/standard/file.c:1.279.2.70.2.6 Tue Mar 28 09:46:35 2006 +++ php-src/ext/standard/file.c Fri Apr 14 17:46:59 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.279.2.70.2.6 2006/03/28 09:46:35 tony2001 Exp $ */ +/* $Id: file.c,v 1.279.2.70.2.7 2006/04/14 17:46:59 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2201,7 +2201,7 @@ safe_to_copy: srcstream = php_stream_open_wrapper(src, "rb", - STREAM_DISABLE_OPEN_BASEDIR | REPORT_ERRORS, + ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); if (!srcstream) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_0) /ext/standard file.c
pollita Fri Apr 14 17:45:48 2006 UTC Modified files: (Branch: PHP_5_0) /php-src/ext/standard file.c Log: MFH (r-1.436) copy() should not disrespect open_basedir on source file http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.382.2.10&r2=1.382.2.11&diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.382.2.10 php-src/ext/standard/file.c:1.382.2.11 --- php-src/ext/standard/file.c:1.382.2.10 Wed Sep 21 14:47:31 2005 +++ php-src/ext/standard/file.c Fri Apr 14 17:45:47 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.382.2.10 2005/09/21 14:47:31 dmitry Exp $ */ +/* $Id: file.c,v 1.382.2.11 2006/04/14 17:45:47 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1629,7 +1629,7 @@ php_stream *srcstream = NULL, *deststream = NULL; int ret = FAILURE; - srcstream = php_stream_open_wrapper(src, "rb", STREAM_DISABLE_OPEN_BASEDIR | REPORT_ERRORS, NULL); + srcstream = php_stream_open_wrapper(src, "rb", ENFORCE_SAFE_MODE | 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
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.435&r2=1.436&diff_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 streamsfuncs.c /main/streams filter.c php_stream_filter_api.h
pollita Thu Apr 13 04:41:09 2006 UTC Modified files: /php-src/main/streams php_stream_filter_api.h filter.c /php-src/ext/standard streamsfuncs.c Log: Preserve full name of filter for use in stream_get_meta_data() http://cvs.php.net/viewcvs.cgi/php-src/main/streams/php_stream_filter_api.h?r1=1.18&r2=1.19&diff_format=u Index: php-src/main/streams/php_stream_filter_api.h diff -u php-src/main/streams/php_stream_filter_api.h:1.18 php-src/main/streams/php_stream_filter_api.h:1.19 --- php-src/main/streams/php_stream_filter_api.h:1.18 Wed Apr 12 22:40:56 2006 +++ php-src/main/streams/php_stream_filter_api.hThu Apr 13 04:41:08 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: php_stream_filter_api.h,v 1.18 2006/04/12 22:40:56 pollita Exp $ */ +/* $Id: php_stream_filter_api.h,v 1.19 2006/04/13 04:41:08 pollita Exp $ */ /* The filter API works on the principle of "Bucket-Brigades". This is * partially inspired by the Apache 2 method of doing things, although @@ -145,6 +145,8 @@ /* filters are auto_registered when they're applied */ int rsrc_id; int flags; + + char *name; }; /* stack filter onto a stream */ http://cvs.php.net/viewcvs.cgi/php-src/main/streams/filter.c?r1=1.29&r2=1.30&diff_format=u Index: php-src/main/streams/filter.c diff -u php-src/main/streams/filter.c:1.29 php-src/main/streams/filter.c:1.30 --- php-src/main/streams/filter.c:1.29 Wed Apr 12 22:40:56 2006 +++ php-src/main/streams/filter.c Thu Apr 13 04:41:08 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: filter.c,v 1.29 2006/04/12 22:40:56 pollita Exp $ */ +/* $Id: filter.c,v 1.30 2006/04/13 04:41:08 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -343,6 +343,8 @@ else php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to create or locate filter \"%s\"", filtername); } + + filter->name = pestrdup(filtername, filter->is_persistent); return filter; } @@ -365,6 +367,7 @@ { if (filter->fops->dtor) filter->fops->dtor(filter TSRMLS_CC); + pefree(filter->name, filter->is_persistent); pefree(filter, filter->is_persistent); } http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.74&r2=1.75&diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.74 php-src/ext/standard/streamsfuncs.c:1.75 --- php-src/ext/standard/streamsfuncs.c:1.74Mon Apr 3 09:14:50 2006 +++ php-src/ext/standard/streamsfuncs.c Thu Apr 13 04:41:08 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.74 2006/04/03 09:14:50 tony2001 Exp $ */ +/* $Id: streamsfuncs.c,v 1.75 2006/04/13 04:41:08 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -470,7 +470,7 @@ array_init(newval); for (filter = stream->readfilters.head; filter != NULL; filter = filter->next) { - add_next_index_string(newval, (char *)filter->fops->label, 1); + add_next_index_string(newval, filter->name, 1); } add_assoc_zval(return_value, "read_filters", newval); @@ -483,7 +483,7 @@ array_init(newval); for (filter = stream->writefilters.head; filter != NULL; filter = filter->next) { - add_next_index_string(newval, (char *)filter->fops->label, 1); + add_next_index_string(newval, filter->name, 1); } add_assoc_zval(return_value, "write_filters", newval); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c /main/streams filter.c php_stream_filter_api.h streams.c
pollita Wed Apr 12 22:40:56 2006 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c /php-src/main/streams filter.c php_stream_filter_api.h streams.c Log: Allow http:// wrapper to automatically apply correct unicode.from.* filter based on content-type header http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.112&r2=1.113&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.112 php-src/ext/standard/http_fopen_wrapper.c:1.113 --- php-src/ext/standard/http_fopen_wrapper.c:1.112 Sun Mar 26 17:12:26 2006 +++ php-src/ext/standard/http_fopen_wrapper.c Wed Apr 12 22:40:56 2006 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.112 2006/03/26 17:12:26 iliaa Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.113 2006/04/12 22:40:56 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -81,6 +81,47 @@ #define HTTP_HEADER_CONTENT_LENGTH 16 #define HTTP_HEADER_TYPE 32 +static inline char *php_http_detect_charset(char *http_header_line) +{ + char *s; + + /* Note: This is a fairly remedial parser which could be easily confused by invalid data + The worst case scenario from such confusion should only result in the unicode filter not + being applied. While unfortunate, it's more an issue of the server sending a bad header */ + for (s = strchr(http_header_line, ';'); s; s = strchr(s + 1, ';')) { + char *p = s; + + while (*(++p) == ' '); + if (strncmp(p, "charset", sizeof("charset") - 1) != 0) { + continue; + } + p += sizeof("charset") - 1; + + while (*p == ' ') p++; + if (*p != '=') { + continue; + } + + while (*(++p) == ' '); + if (*p == '"') { + s = p + 1; + if (!(p = strchr(s, '"'))) { + /* Bad things, unmatched quote */ + return NULL; + } + return estrndup(s, p - s); + break; + } + + /* Unquoted value */ + s = p; + while (*p && *p != ' ' && *p != ';') p++; + return estrndup(s, p - s); + } + + return NULL; +} + php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context, int redirect_max, int header_init STREAMS_DC TSRMLS_DC) { php_stream *stream = NULL; @@ -104,6 +145,7 @@ int transport_len, have_header = 0, request_fulluri = 0; char *protocol_version = NULL; int protocol_version_len = 3; /* Default: "1.0" */ + char *charset = NULL; tmp_line[0] = '\0'; @@ -543,6 +585,11 @@ if (!strncasecmp(http_header_line, "Location: ", 10)) { strlcpy(location, http_header_line + 10, sizeof(location)); } else if (!strncasecmp(http_header_line, "Content-Type: ", 14)) { + + if (UG(unicode) && strchr(mode, 't')) { + charset = php_http_detect_charset(http_header_line + sizeof("Content-type: ")); + } + php_stream_notify_info(context, PHP_STREAM_NOTIFY_MIME_TYPE_IS, http_header_line + 14, 0); } else if (!strncasecmp(http_header_line, "Content-Length: ", 16)) { file_size = atoi(http_header_line + 16); @@ -572,6 +619,11 @@ php_stream_close(stream); stream = NULL; + if (charset) { + efree(charset); + charset = NULL; + } + if (location[0] != '\0'){ char new_path[HTTP_HEADER_BLOCK_SIZE]; @@ -684,6 +736,13 @@ } + if (charset) { + if (stream && UG(unicode) && strchr(mode, 't')) { + php_stream_encoding_apply(stream, 0, charset, UG(to_error_mode), NULL); + } + efree(charset); + } + return stream; } http://cvs.php.net/viewcvs.cgi/php-src/ma
[PHP-CVS] cvs: php-src /ext/standard uniqid.c
pollita Thu Apr 6 20:05:43 2006 UTC Modified files: /php-src/ext/standard uniqid.c Log: Plug leak which occurs in unicode mode http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/uniqid.c?r1=1.44&r2=1.45&diff_format=u Index: php-src/ext/standard/uniqid.c diff -u php-src/ext/standard/uniqid.c:1.44 php-src/ext/standard/uniqid.c:1.45 --- php-src/ext/standard/uniqid.c:1.44 Sun Jan 1 13:09:56 2006 +++ php-src/ext/standard/uniqid.c Thu Apr 6 20:05:43 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: uniqid.c,v 1.44 2006/01/01 13:09:56 sniper Exp $ */ +/* $Id: uniqid.c,v 1.45 2006/04/06 20:05:43 pollita Exp $ */ #include "php.h" @@ -81,7 +81,7 @@ spprintf(&uniqid, 0, "%s%08x%05x", prefix, sec, usec); } - RETURN_RT_STRING(uniqid, 0); + RETURN_RT_STRING(uniqid, ZSTR_AUTOFREE); } #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/tests/file stream_get_line.phpt userfilters.phpt userstreams.phpt /ext/standard/tests/filters basic.phpt
pollita Thu Apr 6 20:03:27 2006 UTC Modified files: /php-src/ext/standard/tests/filestream_get_line.phpt userfilters.phpt userstreams.phpt /php-src/ext/standard/tests/filters basic.phpt Log: Silence false positives on test results http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/stream_get_line.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/file/stream_get_line.phpt diff -u php-src/ext/standard/tests/file/stream_get_line.phpt:1.2 php-src/ext/standard/tests/file/stream_get_line.phpt:1.3 --- php-src/ext/standard/tests/file/stream_get_line.phpt:1.2Thu Aug 11 23:36:01 2005 +++ php-src/ext/standard/tests/file/stream_get_line.phptThu Apr 6 20:03:26 2006 @@ -2,10 +2,9 @@ Crash inside stream_get_line(), when length=0 --FILE-- barfoo"); +file_put_contents($path, b"foobarfoo"); $fp = fopen($path, "r"); while ($fp && !feof($fp)) { echo stream_get_line($fp, 0, "")."\n"; http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/userfilters.phpt?r1=1.5&r2=1.6&diff_format=u Index: php-src/ext/standard/tests/file/userfilters.phpt diff -u php-src/ext/standard/tests/file/userfilters.phpt:1.5 php-src/ext/standard/tests/file/userfilters.phpt:1.6 --- php-src/ext/standard/tests/file/userfilters.phpt:1.5Mon May 19 15:35:06 2003 +++ php-src/ext/standard/tests/file/userfilters.phptThu Apr 6 20:03:26 2006 @@ -20,7 +20,7 @@ stream_filter_register('testfilter','testfilter'); -$text = "Hello There!"; +$text = b"Hello There!"; $fp = tmpfile(); fwrite($fp, $text); http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/userstreams.phpt?r1=1.12&r2=1.13&diff_format=u Index: php-src/ext/standard/tests/file/userstreams.phpt diff -u php-src/ext/standard/tests/file/userstreams.phpt:1.12 php-src/ext/standard/tests/file/userstreams.phpt:1.13 --- php-src/ext/standard/tests/file/userstreams.phpt:1.12 Mon Mar 20 22:08:59 2006 +++ php-src/ext/standard/tests/file/userstreams.phptThu Apr 6 20:03:26 2006 @@ -67,7 +67,7 @@ /* store the data in a regular file so that we can compare * the results */ $tf = tmpfile(); -fwrite($tf, $DATA); +fwrite($tf, (binary)$DATA); $n = ftell($tf); rewind($tf) or die("failed to rewind tmp file!"); if (ftell($tf) != 0) http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/filters/basic.phpt?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/standard/tests/filters/basic.phpt diff -u php-src/ext/standard/tests/filters/basic.phpt:1.3 php-src/ext/standard/tests/filters/basic.phpt:1.4 --- php-src/ext/standard/tests/filters/basic.phpt:1.3 Mon Sep 27 17:52:25 2004 +++ php-src/ext/standard/tests/filters/basic.phpt Thu Apr 6 20:03:27 2006 @@ -4,7 +4,7 @@ http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard/tests/file 004.phpt bug27508.phpt bug27619.phpt bug35781.phpt
pollita Thu Apr 6 19:51:36 2006 UTC Modified files: /php-src/ext/standard/tests/file004.phpt bug27508.phpt bug27619.phpt bug35781.phpt Log: Silence false positives in test failures http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/004.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/004.phpt diff -u php-src/ext/standard/tests/file/004.phpt:1.1 php-src/ext/standard/tests/file/004.phpt:1.2 --- php-src/ext/standard/tests/file/004.phpt:1.1Sat Jun 28 20:06:13 2003 +++ php-src/ext/standard/tests/file/004.phptThu Apr 6 19:51:36 2006 @@ -31,7 +31,7 @@ } echo "\n"; - $ret = file_put_contents("TEST4", __FILE__); + $ret = file_put_contents("TEST4", (binary)__FILE__); echo "Bool Test: "; if ($ret !== FALSE && md5(__FILE__) == md5_file("TEST4")) { echo 'OK'; http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/bug27508.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/bug27508.phpt diff -u php-src/ext/standard/tests/file/bug27508.phpt:1.1 php-src/ext/standard/tests/file/bug27508.phpt:1.2 --- php-src/ext/standard/tests/file/bug27508.phpt:1.1 Wed May 11 02:01:44 2005 +++ php-src/ext/standard/tests/file/bug27508.phpt Thu Apr 6 19:51:36 2006 @@ -46,9 +46,9 @@ $fp = fopen("myFile://" . urlencode($tn), "w+"); -fwrite($fp, "line1\n"); -fwrite($fp, "line2\n"); -fwrite($fp, "line3\n"); +fwrite($fp, b"line1\n"); +fwrite($fp, b"line2\n"); +fwrite($fp, b"line3\n"); debug_zval_dump(feof($fp)); rewind($fp); http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/bug27619.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/bug27619.phpt diff -u php-src/ext/standard/tests/file/bug27619.phpt:1.1 php-src/ext/standard/tests/file/bug27619.phpt:1.2 --- php-src/ext/standard/tests/file/bug27619.phpt:1.1 Wed Mar 31 23:48:59 2004 +++ php-src/ext/standard/tests/file/bug27619.phpt Thu Apr 6 19:51:36 2006 @@ -3,7 +3,7 @@ --FILE-- http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/file/bug35781.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/file/bug35781.phpt diff -u php-src/ext/standard/tests/file/bug35781.phpt:1.2 php-src/ext/standard/tests/file/bug35781.phpt:1.3 --- php-src/ext/standard/tests/file/bug35781.phpt:1.2 Fri Dec 23 15:05:42 2005 +++ php-src/ext/standard/tests/file/bug35781.phpt Thu Apr 6 19:51:36 2006 @@ -7,7 +7,7 @@ $fp = fopen($filename, "w"); stream_filter_append($fp, "string.rot13", -49); -fwrite($fp, "This is a test\n"); +fwrite($fp, b"This is a test\n"); rewind($fp); fpassthru($fp); fclose($fp); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Thu Apr 6 19:39:11 2006 UTC Modified files: /php-src/main/streams streams.c Log: Do runtime conversions (with an E_NOTICE) on writing unicode data to a binary stream. Take the WTF out of the equation http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.118&r2=1.119&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.118 php-src/main/streams/streams.c:1.119 --- php-src/main/streams/streams.c:1.118Fri Mar 31 22:51:37 2006 +++ php-src/main/streams/streams.c Thu Apr 6 19:39:11 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.118 2006/03/31 22:51:37 pollita Exp $ */ +/* $Id: streams.c,v 1.119 2006/04/06 19:39:11 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -1201,6 +1201,8 @@ { size_t didwrite = 0, towrite, justwrote, shouldwrite; char *freeme = NULL; + void *buf_orig = buf.v; + int buflen_orig = buflen, conv_err = 0; /* if we have a seekable stream we need to ensure that data is written at the * current stream->position. This means invalidating the read buffer and then @@ -1211,9 +1213,26 @@ stream->ops->seek(stream, stream->position, SEEK_SET, &stream->position TSRMLS_CC); } - /* Sloppy handling, make it a binary buffer */ if (buf_type == IS_UNICODE) { - buflen = UBYTES(buflen); + int len, num_conv, ulen = u_countChar32(buf.u, buflen); + char *str; + UErrorCode status = U_ZERO_ERROR; + + /* Use runtime_encoding to map to binary */ + num_conv = zend_convert_from_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &str, &len, buf.u, buflen, &status); + if (U_FAILURE(status)) { + zend_raise_conversion_error_ex("Unable to convert data to be writen", ZEND_U_CONVERTER(UG(runtime_encoding_conv)), + ZEND_FROM_UNICODE, num_conv, (UG(from_error_mode) & ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC); + } else { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%d character unicode buffer downcoded for binary stream runtime_encoding", ulen); + } + + if (num_conv < buflen) { + conv_err = 1; + } + + freeme = buf.s = str; + buflen = len; } shouldwrite = buflen; @@ -1243,8 +1262,23 @@ } if (buf_type == IS_UNICODE) { - /* Was slopily converted */ - didwrite /= UBYTES(1); + /* Map bytes written back to UChars written */ + + if (shouldwrite == didwrite && !conv_err) { + /* wrote it all */ + didwrite = buflen_orig; + } else { + /* Figure out how didwrite corresponds to the input buffer */ + char *tmp = emalloc(didwrite + 1), *t = tmp; + UChar *s = buf_orig; + UErrorCode status = U_ZERO_ERROR; + + ucnv_resetFromUnicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv))); + ucnv_fromUnicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &t, t + didwrite, &s, s + buflen_orig, NULL, TRUE, &status); + + didwrite = s - ((UChar*)buf_orig); + efree(tmp); + } } if (freeme) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard/tests/network tcp4loop.phpt tcp6loop.phpt udgloop.phpt udp4loop.phpt udp6loop.phpt unixloop.phpt
pollita Mon Apr 3 05:57:41 2006 UTC Modified files: /php-src/ext/standard/tests/network tcp4loop.phpt tcp6loop.phpt udgloop.phpt unixloop.phpt udp4loop.phpt udp6loop.phpt Log: Update tests for working with unicode http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/network/tcp4loop.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/network/tcp4loop.phpt diff -u php-src/ext/standard/tests/network/tcp4loop.phpt:1.2 php-src/ext/standard/tests/network/tcp4loop.phpt:1.3 --- php-src/ext/standard/tests/network/tcp4loop.phpt:1.2Sat Nov 29 21:46:48 2003 +++ php-src/ext/standard/tests/network/tcp4loop.phptMon Apr 3 05:57:40 2006 @@ -20,7 +20,7 @@ die('Unable to accept connection'); } - fwrite($client, "ABCdef123\n"); + fwrite($client, b"ABCdef123\n"); $data = fread($socket, 10); var_dump($data); http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/network/tcp6loop.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/network/tcp6loop.phpt diff -u php-src/ext/standard/tests/network/tcp6loop.phpt:1.2 php-src/ext/standard/tests/network/tcp6loop.phpt:1.3 --- php-src/ext/standard/tests/network/tcp6loop.phpt:1.2Tue Aug 12 00:44:05 2003 +++ php-src/ext/standard/tests/network/tcp6loop.phptMon Apr 3 05:57:40 2006 @@ -28,7 +28,7 @@ die('Unable to accept connection'); } - fwrite($client, "ABCdef123\n"); + fwrite($client, b"ABCdef123\n"); $data = fread($socket, 10); var_dump($data); http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/network/udgloop.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/network/udgloop.phpt diff -u php-src/ext/standard/tests/network/udgloop.phpt:1.2 php-src/ext/standard/tests/network/udgloop.phpt:1.3 --- php-src/ext/standard/tests/network/udgloop.phpt:1.2 Fri Dec 5 13:41:01 2003 +++ php-src/ext/standard/tests/network/udgloop.phpt Mon Apr 3 05:57:40 2006 @@ -23,7 +23,7 @@ die('Unable to create AF_UNIX socket [client]'); } - fwrite($client, "ABCdef123\n"); + fwrite($client, b"ABCdef123\n"); $data = fread($server, 10); var_dump($data); http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/network/unixloop.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/network/unixloop.phpt diff -u php-src/ext/standard/tests/network/unixloop.phpt:1.2 php-src/ext/standard/tests/network/unixloop.phpt:1.3 --- php-src/ext/standard/tests/network/unixloop.phpt:1.2Fri Dec 5 13:41:01 2003 +++ php-src/ext/standard/tests/network/unixloop.phptMon Apr 3 05:57:40 2006 @@ -29,7 +29,7 @@ die('Unable to accept connection'); } - fwrite($client, "ABCdef123\n"); + fwrite($client, b"ABCdef123\n"); $data = fread($socket, 10); var_dump($data); http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/network/udp4loop.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/network/udp4loop.phpt diff -u php-src/ext/standard/tests/network/udp4loop.phpt:1.1 php-src/ext/standard/tests/network/udp4loop.phpt:1.2 --- php-src/ext/standard/tests/network/udp4loop.phpt:1.1Mon Aug 11 01:30:55 2003 +++ php-src/ext/standard/tests/network/udp4loop.phptMon Apr 3 05:57:40 2006 @@ -14,7 +14,7 @@ die('Unable to create AF_INET socket [client]'); } - fwrite($client, "ABCdef123\n"); + fwrite($client, b"ABCdef123\n"); $data = fread($server, 10); var_dump($data); http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/network/udp6loop.phpt?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/standard/tests/network/udp6loop.phpt diff -u php-src/ext/standard/tests/network/udp6loop.phpt:1.3 php-src/ext/standard/tests/network/udp6loop.phpt:1.4 --- php-src/ext/standard/tests/network/udp6loop.phpt:1.3Fri Dec 5 13:41:01 2003 +++ php-src/ext/standard/tests/network/udp6loop.phptMon Apr 3 05:57:40 2006 @@ -28,7 +28,7 @@ die('Unable to create AF_INET6 socket [client]'); } - fwrite($client, "ABCdef123\n"); + fwrite($client, b"ABCdef123\n"); $data = fread($server, 10); var_dump($data); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/zlib/tests gzfilegzreadfile.phpt gzreadgzwrite.phpt gzreadgzwriteplain.phpt zlib_filter_deflate.phpt zlib_filter_inflate.phpt
pollita Sun Apr 2 17:49:10 2006 UTC Modified files: /php-src/ext/zlib/tests gzfilegzreadfile.phpt gzreadgzwrite.phpt gzreadgzwriteplain.phpt zlib_filter_deflate.phpt zlib_filter_inflate.phpt Log: Silence false positive test failures http://cvs.php.net/viewcvs.cgi/php-src/ext/zlib/tests/gzfilegzreadfile.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/zlib/tests/gzfilegzreadfile.phpt diff -u php-src/ext/zlib/tests/gzfilegzreadfile.phpt:1.2 php-src/ext/zlib/tests/gzfilegzreadfile.phpt:1.3 --- php-src/ext/zlib/tests/gzfilegzreadfile.phpt:1.2Wed May 19 08:45:23 2004 +++ php-src/ext/zlib/tests/gzfilegzreadfile.phptSun Apr 2 17:49:10 2006 @@ -1,11 +1,11 @@ --TEST-- gzfile(), gzreadfile() --SKIPIF-- - --FILE-- http://cvs.php.net/viewcvs.cgi/php-src/ext/zlib/tests/gzreadgzwrite.phpt?r1=1.4&r2=1.5&diff_format=u Index: php-src/ext/zlib/tests/gzreadgzwrite.phpt diff -u php-src/ext/zlib/tests/gzreadgzwrite.phpt:1.4 php-src/ext/zlib/tests/gzreadgzwrite.phpt:1.5 --- php-src/ext/zlib/tests/gzreadgzwrite.phpt:1.4 Thu Feb 2 15:04:22 2006 +++ php-src/ext/zlib/tests/gzreadgzwrite.phpt Sun Apr 2 17:49:10 2006 @@ -5,7 +5,7 @@ if (!extension_loaded("zlib")) print "skip"; ?> --FILE-- http://cvs.php.net/viewcvs.cgi/php-src/ext/zlib/tests/gzreadgzwriteplain.phpt?r1=1.4&r2=1.5&diff_format=u Index: php-src/ext/zlib/tests/gzreadgzwriteplain.phpt diff -u php-src/ext/zlib/tests/gzreadgzwriteplain.phpt:1.4 php-src/ext/zlib/tests/gzreadgzwriteplain.phpt:1.5 --- php-src/ext/zlib/tests/gzreadgzwriteplain.phpt:1.4 Thu Feb 2 15:04:22 2006 +++ php-src/ext/zlib/tests/gzreadgzwriteplain.phpt Sun Apr 2 17:49:10 2006 @@ -5,7 +5,7 @@ if (!extension_loaded("zlib")) print "skip"; ?> --FILE-- http://cvs.php.net/viewcvs.cgi/php-src/ext/zlib/tests/zlib_filter_deflate.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/zlib/tests/zlib_filter_deflate.phpt diff -u php-src/ext/zlib/tests/zlib_filter_deflate.phpt:1.2 php-src/ext/zlib/tests/zlib_filter_deflate.phpt:1.3 --- php-src/ext/zlib/tests/zlib_filter_deflate.phpt:1.2 Thu Nov 24 04:37:04 2005 +++ php-src/ext/zlib/tests/zlib_filter_deflate.phpt Sun Apr 2 17:49:10 2006 @@ -3,8 +3,8 @@ --SKIPIF-- --FILE-- -http://cvs.php.net/viewcvs.cgi/php-src/ext/zlib/tests/zlib_filter_inflate.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/zlib/tests/zlib_filter_inflate.phpt diff -u php-src/ext/zlib/tests/zlib_filter_inflate.phpt:1.2 php-src/ext/zlib/tests/zlib_filter_inflate.phpt:1.3 --- php-src/ext/zlib/tests/zlib_filter_inflate.phpt:1.2 Thu Nov 24 04:37:04 2005 +++ php-src/ext/zlib/tests/zlib_filter_inflate.phpt Sun Apr 2 17:49:10 2006 @@ -3,8 +3,8 @@ --SKIPIF-- --FILE-- -http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/bz2/tests bz2_filter_compress.phpt bz2_filter_decompress.phpt with_files.phpt with_strings.phpt
pollita Sun Apr 2 17:41:04 2006 UTC Modified files: /php-src/ext/bz2/tests bz2_filter_compress.phpt bz2_filter_decompress.phpt with_files.phpt with_strings.phpt Log: Make some tests pass. compression is just a binary thing. Write unicode and suffer my wrath! http://cvs.php.net/viewcvs.cgi/php-src/ext/bz2/tests/bz2_filter_compress.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/bz2/tests/bz2_filter_compress.phpt diff -u php-src/ext/bz2/tests/bz2_filter_compress.phpt:1.1 php-src/ext/bz2/tests/bz2_filter_compress.phpt:1.2 --- php-src/ext/bz2/tests/bz2_filter_compress.phpt:1.1 Tue Jul 20 05:26:33 2004 +++ php-src/ext/bz2/tests/bz2_filter_compress.phpt Sun Apr 2 17:41:04 2006 @@ -3,8 +3,8 @@ --SKIPIF-- --FILE-- -http://cvs.php.net/viewcvs.cgi/php-src/ext/bz2/tests/bz2_filter_decompress.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/bz2/tests/bz2_filter_decompress.phpt diff -u php-src/ext/bz2/tests/bz2_filter_decompress.phpt:1.1 php-src/ext/bz2/tests/bz2_filter_decompress.phpt:1.2 --- php-src/ext/bz2/tests/bz2_filter_decompress.phpt:1.1Tue Jul 20 05:26:33 2004 +++ php-src/ext/bz2/tests/bz2_filter_decompress.phptSun Apr 2 17:41:04 2006 @@ -3,8 +3,8 @@ --SKIPIF-- --FILE-- -http://cvs.php.net/viewcvs.cgi/php-src/ext/bz2/tests/with_files.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/bz2/tests/with_files.phpt diff -u php-src/ext/bz2/tests/with_files.phpt:1.2 php-src/ext/bz2/tests/with_files.phpt:1.3 --- php-src/ext/bz2/tests/with_files.phpt:1.2 Wed May 19 08:56:50 2004 +++ php-src/ext/bz2/tests/with_files.phpt Sun Apr 2 17:41:04 2006 @@ -3,12 +3,12 @@ --SKIPIF-- --FILE-- -http://cvs.php.net/viewcvs.cgi/php-src/ext/bz2/tests/with_strings.phpt?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/bz2/tests/with_strings.phpt diff -u php-src/ext/bz2/tests/with_strings.phpt:1.3 php-src/ext/bz2/tests/with_strings.phpt:1.4 --- php-src/ext/bz2/tests/with_strings.phpt:1.3 Wed May 19 08:56:50 2004 +++ php-src/ext/bz2/tests/with_strings.phpt Sun Apr 2 17:41:04 2006 @@ -3,12 +3,12 @@ --SKIPIF-- --FILE-- -http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[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.434&r2=1.435&diff_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
[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.349&r2=1.350&diff_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.154&r2=1.155&diff_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.433&r2=1.434&diff_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) { +
[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.432&r2=1.433&diff_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.109&r2=1.110&diff_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, ma
[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.431&r2=1.432&diff_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.115&r2=1.116&diff_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 / configure.in
pollita Wed Mar 29 01:52:28 2006 UTC Modified files: /php-srcconfigure.in Log: Ooops, missed a file http://cvs.php.net/viewcvs.cgi/php-src/configure.in?r1=1.600&r2=1.601&diff_format=u Index: php-src/configure.in diff -u php-src/configure.in:1.600 php-src/configure.in:1.601 --- php-src/configure.in:1.600 Wed Mar 8 14:41:45 2006 +++ php-src/configure.inWed Mar 29 01:52:28 2006 @@ -1,4 +1,4 @@ - ## $Id: configure.in,v 1.600 2006/03/08 14:41:45 iliaa Exp $ -*- autoconf -*- + ## $Id: configure.in,v 1.601 2006/03/29 01:52:28 pollita Exp $ -*- autoconf -*- dnl ## Process this file with autoconf to produce a configure script. divert(1) @@ -1229,7 +1229,8 @@ output.c ) PHP_ADD_SOURCES(main/streams, streams.c cast.c memory.c filter.c \ - plain_wrapper.c userspace.c transports.c xp_socket.c mmap.c) + plain_wrapper.c userspace.c transports.c xp_socket.c mmap.c \ + unicode_filter.c ) PHP_ADD_SOURCES(/main, internal_functions.c,, sapi) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard basic_functions.c file.c streamsfuncs.c streamsfuncs.h /ext/unicode config.m4 config.w32 php_unicode.h unicode.c unicode_filter.c /main main.c php_streams.h /ma
pollita Wed Mar 29 01:20:43 2006 UTC Added files: /php-src/main/streams unicode_filter.c Removed files: /php-src/ext/unicodeunicode_filter.c Modified files: /php-src/ext/standard basic_functions.c file.c streamsfuncs.c streamsfuncs.h /php-src/ext/unicodeconfig.m4 config.w32 php_unicode.h unicode.c /php-src/main main.c php_streams.h /php-src/main/streams filter.c php_stream_filter_api.h streams.c /php-src/win32/buildconfig.w32 Log: Another (and hopefully last) major streams commit. This moves unicode conversion to the filter layer (rather than at the lower streams layer) unicode_filter.c has been moved from ext/unicode to main/streams as it's an integral part of the streams unicode conversion process. There are now three ways to set encoding on a stream: (1) By context $ctx = stream_context_create(NULL,array('encoding'=>'latin1')); $fp = fopen('somefile', 'r+t', false, $ctx); (2) By stream_encoding() $fp = fopen('somefile', 'r+'); stream_encoding($fp, 'latin1'); (3) By filter $fp = fopen('somefile', 'r+'); stream_filter_append($fp, 'unicode.from.latin1', STREAM_FILTER_READ); stream_filter_append($fp, 'unicode.to.latin1', STREAM_FILTER_WRITE); Note: Methods 1 and 2 are convenience wrappers around method 3. http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/basic_functions.c?r1=1.766&r2=1.767&diff_format=u Index: php-src/ext/standard/basic_functions.c diff -u php-src/ext/standard/basic_functions.c:1.766 php-src/ext/standard/basic_functions.c:1.767 --- php-src/ext/standard/basic_functions.c:1.766Wed Mar 22 10:20:20 2006 +++ php-src/ext/standard/basic_functions.c Wed Mar 29 01:20:42 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: basic_functions.c,v 1.766 2006/03/22 10:20:20 derick Exp $ */ +/* $Id: basic_functions.c,v 1.767 2006/03/29 01:20:42 pollita Exp $ */ #include "php.h" #include "php_streams.h" @@ -589,6 +589,7 @@ PHP_FE(stream_filter_prepend, NULL) PHP_FE(stream_filter_append, NULL) PHP_FE(stream_filter_remove, NULL) + PHP_FE(stream_encoding, NULL) PHP_FE(stream_socket_client, second_and_third_args_force_ref) PHP_FE(stream_socket_server, second_and_third_args_force_ref) PHP_FE(stream_socket_accept, third_arg_force_ref) http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.430&r2=1.431&diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.430 php-src/ext/standard/file.c:1.431 --- php-src/ext/standard/file.c:1.430 Mon Mar 27 23:41:05 2006 +++ php-src/ext/standard/file.c Wed Mar 29 01:20:42 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.430 2006/03/27 23:41:05 iliaa Exp $ */ +/* $Id: file.c,v 1.431 2006/03/29 01:20:42 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1008,14 +1008,14 @@ php_stream_from_zval(stream, &zstream); - buf.v = php_stream_get_line_ex(stream, php_stream_reads_unicode(stream) ? IS_UNICODE : IS_STRING, NULL_ZSTR, 0, length, &retlen); + buf.v = php_stream_get_line_ex(stream, stream->readbuf_type, NULL_ZSTR, 0, length, &retlen); if (!buf.v) { RETURN_FALSE; } - if (php_stream_reads_unicode(stream)) { + if (stream->readbuf_type == IS_UNICODE) { RETURN_UNICODEL(buf.u, retlen, 0); - } else { + } else { /* IS_STRING */ RETURN_STRINGL(buf.s, retlen, 0); } } @@ -1034,7 +1034,7 @@ PHP_STREAM_TO_ZVAL(stream, arg1); - if (php_stream_reads_unicode(stream)) { + if (stream->readbuf_type == IS_UNICODE) { int buflen = 1; UChar *buf = php_stream_read_unicode_chars(stream, &buflen); @@ -1042,7 +1042,7 @@ RETURN_FALSE; } RETURN_UNICODEL(buf, buflen, 0); - } else { + } else { /* IS_STRING */ char buf[2]; buf[0] = php_stream_getc(stream); @@ -1068,7 +1068,7 @@ php_stream_from_zval(stream, &zstream); - if (php_stream_reads_unicode(stream)) { + if (stream->readbuf_type == IS_UNICODE) { UChar *buf = php_stream_get_line_e
Re: [PHP-CVS] cvs: php-src / NEWS /ext/standard streamsfuncs.c
Aren't you going to merge this to the 5.1 branch? This change seems pretty useful to me. I have nothing against merging to 5.1, but that's up to the RM as it's new functionality. -Sara - Original Message - pollita Sun Mar 26 04:40:11 2006 UTC Modified files: /php-src NEWS /php-src/ext/standard streamsfuncs.c Log: Expand stream_context_create() to allow specifying params as well as options. Ignore the internal name change of the first arg. The first arg is still for options, the second arg is for actual params. http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2109&r2=1.2110&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2109 php-src/NEWS:1.2110 --- php-src/NEWS:1.2109 Fri Mar 24 10:11:49 2006 +++ php-src/NEWS Sun Mar 26 04:40:11 2006 @@ -43,6 +43,8 @@ the part of haystack before or after first occurence of needle. (Johannes) - Added possibility to check in which extension an internal function was defined using reflection API. (Johannes) +- Added second optional parameter to stream_context_create() to set params + during context creation. (Sara) - Fixed bug #36840 (Memory leak if cast operator throws an exception that is caught). (Dmitry) - Fixed bug #36630 (umask not reset at the end of the request). (Ilia) http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.71&r2=1.72&diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.71 php-src/ext/standard/streamsfuncs.c:1.72 --- php-src/ext/standard/streamsfuncs.c:1.71 Fri Mar 24 22:27:13 2006 +++ php-src/ext/standard/streamsfuncs.c Sun Mar 26 04:40:11 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.71 2006/03/24 22:27:13 pollita Exp $ */ +/* $Id: streamsfuncs.c,v 1.72 2006/03/26 04:40:11 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -1103,21 +1103,25 @@ } /* }}} */ -/* {{{ proto resource stream_context_create([array options]) +/* {{{ proto resource stream_context_create([array options[, array params]]) Create a file context and optionally set parameters */ PHP_FUNCTION(stream_context_create) { - zval *params = NULL; + zval *options = NULL, *params = NULL; php_stream_context *context; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", ¶ms) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!a!", &options, ¶ms) == FAILURE) { RETURN_FALSE; } context = php_stream_context_alloc(); + if (options) { + parse_context_options(context, options TSRMLS_CC); + } + if (params) { - parse_context_options(context, params TSRMLS_CC); + parse_context_params(context, params TSRMLS_CC); } php_stream_context_to_zval(context, return_value); -- 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
[PHP-CVS] cvs: php-src / NEWS /ext/standard streamsfuncs.c
pollita Sun Mar 26 04:40:11 2006 UTC Modified files: /php-srcNEWS /php-src/ext/standard streamsfuncs.c Log: Expand stream_context_create() to allow specifying params as well as options. Ignore the internal name change of the first arg. The first arg is still for options, the second arg is for actual params. http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2109&r2=1.2110&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2109 php-src/NEWS:1.2110 --- php-src/NEWS:1.2109 Fri Mar 24 10:11:49 2006 +++ php-src/NEWSSun Mar 26 04:40:11 2006 @@ -43,6 +43,8 @@ the part of haystack before or after first occurence of needle. (Johannes) - Added possibility to check in which extension an internal function was defined using reflection API. (Johannes) +- Added second optional parameter to stream_context_create() to set params + during context creation. (Sara) - Fixed bug #36840 (Memory leak if cast operator throws an exception that is caught). (Dmitry) - Fixed bug #36630 (umask not reset at the end of the request). (Ilia) http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.71&r2=1.72&diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.71 php-src/ext/standard/streamsfuncs.c:1.72 --- php-src/ext/standard/streamsfuncs.c:1.71Fri Mar 24 22:27:13 2006 +++ php-src/ext/standard/streamsfuncs.c Sun Mar 26 04:40:11 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.71 2006/03/24 22:27:13 pollita Exp $ */ +/* $Id: streamsfuncs.c,v 1.72 2006/03/26 04:40:11 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -1103,21 +1103,25 @@ } /* }}} */ -/* {{{ proto resource stream_context_create([array options]) +/* {{{ proto resource stream_context_create([array options[, array params]]) Create a file context and optionally set parameters */ PHP_FUNCTION(stream_context_create) { - zval *params = NULL; + zval *options = NULL, *params = NULL; php_stream_context *context; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", ¶ms) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!a!", &options, ¶ms) == FAILURE) { RETURN_FALSE; } context = php_stream_context_alloc(); + if (options) { + parse_context_options(context, options TSRMLS_CC); + } + if (params) { - parse_context_options(context, params TSRMLS_CC); + parse_context_params(context, params TSRMLS_CC); } php_stream_context_to_zval(context, return_value); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Sat Mar 25 04:37:44 2006 UTC Modified files: /php-src/main/streams streams.c Log: Handle converter instantiation errors properly http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.111&r2=1.112&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.111 php-src/main/streams/streams.c:1.112 --- php-src/main/streams/streams.c:1.111Fri Mar 24 20:21:48 2006 +++ php-src/main/streams/streams.c Sat Mar 25 04:37:44 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.111 2006/03/24 20:21:48 pollita Exp $ */ +/* $Id: streams.c,v 1.112 2006/03/25 04:37:44 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -2277,45 +2277,47 @@ UErrorCode status = U_ZERO_ERROR; stream->output_encoding = ucnv_open(encoding, &status); - switch (U_FAILURE(status)) { - case U_ZERO_ERROR: - /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via context params */ - zend_set_converter_error_mode(stream->output_encoding, UG(from_u_error_mode)); - zend_set_converter_subst_char(stream->output_encoding, UG(subst_char), UG(subst_char_len)); - break; - case U_MEMORY_ALLOCATION_ERROR: - php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, - "Unable to allocate memory for unicode output converter: %s", encoding); - break; - case U_FILE_ACCESS_ERROR: - php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, - "Error loading unicode output converter: %s", encoding); - break; - default: - php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, - "Unknown error starting unicode output converter: %s", encoding); + if (U_FAILURE(status)) { + switch (status) { + case U_MEMORY_ALLOCATION_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + "Unable to allocate memory for unicode output converter: %s", encoding); + break; + case U_FILE_ACCESS_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + "Error loading unicode output converter: %s", encoding); + break; + default: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + "Unknown error starting unicode output converter: %s", encoding); + } + } else { + /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via context params */ + zend_set_converter_error_mode(stream->output_encoding, UG(from_u_error_mode)); + zend_set_converter_subst_char(stream->output_encoding, UG(subst_char), UG(subst_char_len)); } } if (strchr(implicit_mode, 'r') || strchr(implicit_mode, '+')) { char *encoding = (context && context->input_encoding) ? context->input_encoding : "utf8"; UErrorCode status = U_ZERO_ERROR; + stream->input_encoding = ucnv_open(encoding, &status); - switch (U_FAILURE(status)) { - case U_ZERO_ERROR: - /* UTODO: If/When Input error handling gets implemented, set the options here */ - break; - case U_MEMORY_ALLOCATION_ERROR: - php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, - "Unable to allocate memory for unicode input converter: %s", encoding); -
[PHP-CVS] cvs: php-src /ext/standard streamsfuncs.c
pollita Fri Mar 24 22:27:13 2006 UTC Modified files: /php-src/ext/standard streamsfuncs.c Log: Allow bidirectional encoding option via single context param http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.70&r2=1.71&diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.70 php-src/ext/standard/streamsfuncs.c:1.71 --- php-src/ext/standard/streamsfuncs.c:1.70Fri Mar 24 21:37:42 2006 +++ php-src/ext/standard/streamsfuncs.c Fri Mar 24 22:27:13 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.70 2006/03/24 21:37:42 pollita Exp $ */ +/* $Id: streamsfuncs.c,v 1.71 2006/03/24 22:27:13 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -926,6 +926,20 @@ if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) { parse_context_options(context, *tmp TSRMLS_CC); } + if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "encoding", sizeof("encoding"), (void**)&tmp)) { + zval strval = **tmp; + + if (context->input_encoding) { + efree(context->input_encoding); + } + if (context->output_encoding) { + efree(context->output_encoding); + } + zval_copy_ctor(&strval); + convert_to_string(&strval); + context->input_encoding = Z_STRVAL(strval); + context->output_encoding = estrdup(Z_STRVAL(strval)); + } if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "input_encoding", sizeof("input_encoding"), (void**)&tmp)) { zval strval = **tmp; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard streamsfuncs.c
pollita Fri Mar 24 21:37:42 2006 UTC Modified files: /php-src/ext/standard streamsfuncs.c Log: Fix stream_get_line(): Checking type isn't nearly as important as checking nullness... http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.69&r2=1.70&diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.69 php-src/ext/standard/streamsfuncs.c:1.70 --- php-src/ext/standard/streamsfuncs.c:1.69Fri Mar 24 19:22:24 2006 +++ php-src/ext/standard/streamsfuncs.c Fri Mar 24 21:37:42 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.69 2006/03/24 19:22:24 pollita Exp $ */ +/* $Id: streamsfuncs.c,v 1.70 2006/03/24 21:37:42 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -1259,14 +1259,18 @@ if (php_stream_reads_unicode(stream)) { UChar *buf; + UChar *d = NULL; + int dlen = 0; - if (Z_TYPE_PP(delim) != IS_UNICODE) { + if (delim) { convert_to_unicode_ex(delim); + d = Z_USTRVAL_PP(delim); + dlen = Z_USTRLEN_PP(delim); } /* maxchars == maxlength will prevent the otherwise generous maxlen == max_length * 2 from allocating beyond what's requested */ - buf = php_stream_get_record_unicode(stream, max_length * 2, max_length, &buf_size, Z_USTRVAL_PP(delim), Z_USTRLEN_PP(delim) TSRMLS_CC); + buf = php_stream_get_record_unicode(stream, max_length * 2, max_length, &buf_size, d, dlen TSRMLS_CC); if (!buf) { RETURN_FALSE; } @@ -1274,12 +1278,16 @@ RETURN_UNICODEL(buf, buf_size, 0); } else { char *buf; + char *d = NULL; + int dlen = 0; - if (Z_TYPE_PP(delim) != IS_STRING) { + if (delim) { convert_to_string_ex(delim); + d = Z_STRVAL_PP(delim); + dlen = Z_STRLEN_PP(delim); } - buf = php_stream_get_record(stream, max_length, &buf_size, Z_STRVAL_PP(delim), Z_STRLEN_PP(delim) TSRMLS_CC); + buf = php_stream_get_record(stream, max_length, &buf_size, d, dlen TSRMLS_CC); if (!buf) { 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 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.428&r2=1.429&diff_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 /main/streams filter.c streams.c
pollita Fri Mar 24 20:21:48 2006 UTC Modified files: /php-src/main/streams streams.c filter.c Log: Hook into new unicode conversion error handling API http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.110&r2=1.111&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.110 php-src/main/streams/streams.c:1.111 --- php-src/main/streams/streams.c:1.110Fri Mar 24 19:22:24 2006 +++ php-src/main/streams/streams.c Fri Mar 24 20:21:48 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.110 2006/03/24 19:22:24 pollita Exp $ */ +/* $Id: streams.c,v 1.111 2006/03/24 20:21:48 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -1256,10 +1256,15 @@ if (stream->output_encoding && buf_type == IS_UNICODE) { char *dest; - int destlen; + int destlen, num_conv; UErrorCode status = U_ZERO_ERROR; - zend_convert_from_unicode(stream->output_encoding, &dest, &destlen, buf.u, buflen, &status); + num_conv = zend_convert_from_unicode(stream->output_encoding, &dest, &destlen, buf.u, buflen, &status); + if (U_FAILURE(status)) { + int32_t offset = u_countChar32(buf.u, num_conv)-1; + + zend_raise_conversion_error_ex("Could not convert Unicode string to binary string", stream->output_encoding, offset, (UG(from_u_error_mode) & ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC); + } freeme = buf.s = dest; buflen = destlen; } else { http://cvs.php.net/viewcvs.cgi/php-src/main/streams/filter.c?r1=1.23&r2=1.24&diff_format=u Index: php-src/main/streams/filter.c diff -u php-src/main/streams/filter.c:1.23 php-src/main/streams/filter.c:1.24 --- php-src/main/streams/filter.c:1.23 Mon Mar 13 04:40:11 2006 +++ php-src/main/streams/filter.c Fri Mar 24 20:21:48 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: filter.c,v 1.23 2006/03/13 04:40:11 pollita Exp $ */ +/* $Id: filter.c,v 1.24 2006/03/24 20:21:48 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -706,9 +706,14 @@ } else { UErrorCode status = U_ZERO_ERROR; char *dest; - int destlen; + int destlen, num_conv; + + num_conv = zend_convert_from_unicode(conv, &dest, &destlen, bucket->buf.u, bucket->buflen, &status); + if (U_FAILURE(status)) { + int32_t offset = u_countChar32(bucket->buf.u, num_conv)-1; - zend_convert_from_unicode(conv, &dest, &destlen, bucket->buf.u, bucket->buflen, &status); + zend_raise_conversion_error_ex("Could not convert Unicode string to binary string", conv, offset, (UG(from_u_error_mode) & ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC); + } if (bucket->own_buf) { pefree(bucket->buf.u, bucket->is_persistent); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard streamsfuncs.c /main php_streams.h /main/streams streams.c
pollita Fri Mar 24 19:22:24 2006 UTC Modified files: /php-src/ext/standard streamsfuncs.c /php-src/main php_streams.h /php-src/main/streams streams.c Log: Add php_stream_get_record_unicde() API call. Update stream_get_line() userspace function to handle unicode streams. http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.68&r2=1.69&diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.68 php-src/ext/standard/streamsfuncs.c:1.69 --- php-src/ext/standard/streamsfuncs.c:1.68Mon Mar 13 04:40:11 2006 +++ php-src/ext/standard/streamsfuncs.c Fri Mar 24 19:22:24 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.68 2006/03/13 04:40:11 pollita Exp $ */ +/* $Id: streamsfuncs.c,v 1.69 2006/03/24 19:22:24 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -1235,18 +1235,15 @@ /* {{{ proto string stream_get_line(resource stream, int maxlen [, string ending]) Read up to maxlen bytes from a stream or until the ending string is found */ -/* UTODO */ PHP_FUNCTION(stream_get_line) { - char *str = NULL; - int str_len; long max_length; zval *zstream; - char *buf; size_t buf_size; php_stream *stream; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|s", &zstream, &max_length, &str, &str_len) == FAILURE) { + zval **delim = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|Z", &zstream, &max_length, &delim) == FAILURE) { RETURN_FALSE; } @@ -1260,10 +1257,34 @@ php_stream_from_zval(stream, &zstream); - if ((buf = php_stream_get_record(stream, max_length, &buf_size, str, str_len TSRMLS_CC))) { - RETURN_STRINGL(buf, buf_size, 0); + if (php_stream_reads_unicode(stream)) { + UChar *buf; + + if (Z_TYPE_PP(delim) != IS_UNICODE) { + convert_to_unicode_ex(delim); + } + + /* maxchars == maxlength will prevent the otherwise generous maxlen == max_length * 2 + from allocating beyond what's requested */ + buf = php_stream_get_record_unicode(stream, max_length * 2, max_length, &buf_size, Z_USTRVAL_PP(delim), Z_USTRLEN_PP(delim) TSRMLS_CC); + if (!buf) { + RETURN_FALSE; + } + + RETURN_UNICODEL(buf, buf_size, 0); } else { - RETURN_FALSE; + char *buf; + + if (Z_TYPE_PP(delim) != IS_STRING) { + convert_to_string_ex(delim); + } + + buf = php_stream_get_record(stream, max_length, &buf_size, Z_STRVAL_PP(delim), Z_STRLEN_PP(delim) TSRMLS_CC); + if (!buf) { + RETURN_FALSE; + } + + RETURN_STRINGL(buf, buf_size, 0); } } http://cvs.php.net/viewcvs.cgi/php-src/main/php_streams.h?r1=1.107&r2=1.108&diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.107 php-src/main/php_streams.h:1.108 --- php-src/main/php_streams.h:1.107Tue Mar 14 21:15:05 2006 +++ php-src/main/php_streams.h Fri Mar 24 19:22:24 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.107 2006/03/14 21:15:05 pollita Exp $ */ +/* $Id: php_streams.h,v 1.108 2006/03/24 19:22:24 pollita Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -329,6 +329,8 @@ _php_stream_get_line((stream), (buf_type), ZSTR(buf), (maxlen), (maxchars), NULL 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_get_record_unicode(php_stream *stream, size_t maxlen, size_t maxchars, size_t *returned_len, UChar *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); #define php_stream_u_get_line(stream, buf, maxlen_buf, maxlen_chars, buf_type) _php_stream_u_get_line((stream), (buf), (maxlen_buf), (maxlen_chars), (buf_type) TSRMLS_CC) http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.109&r2=1.110&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.109 php-src/main/streams/streams.c:1.110 --- php-src/main/streams/streams.c:1.109Fri Mar 24 00:19:39 2006 +++ php-src/main/streams/streams.c Fri Mar 24 19:22:24 2006 @@ -19,7 +19,7 @@ +--+ *
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Fri Mar 24 00:19:39 2006 UTC Modified files: /php-src/main/streams streams.c Log: Add some error checking when stream converters are instantiated. Use the global conversion error handlers for output conversion (for now) We may want to make this customizable on a per-stream basis via context param later on... http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.108&r2=1.109&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.108 php-src/main/streams/streams.c:1.109 --- php-src/main/streams/streams.c:1.108Tue Mar 21 18:28:42 2006 +++ php-src/main/streams/streams.c Fri Mar 24 00:19:39 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.108 2006/03/21 18:28:42 pollita Exp $ */ +/* $Id: streams.c,v 1.109 2006/03/24 00:19:39 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -2205,11 +2205,45 @@ UErrorCode status = U_ZERO_ERROR; stream->output_encoding = ucnv_open(encoding, &status); + switch (U_FAILURE(status)) { + case U_ZERO_ERROR: + /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via context params */ + zend_set_converter_error_mode(stream->output_encoding, UG(from_u_error_mode)); + zend_set_converter_subst_char(stream->output_encoding, UG(subst_char), UG(subst_char_len)); + break; + case U_MEMORY_ALLOCATION_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + "Unable to allocate memory for unicode output converter: %s", encoding); + break; + case U_FILE_ACCESS_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + "Error loading unicode output converter: %s", encoding); + break; + default: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + "Unknown error starting unicode output converter: %s", encoding); + } } if (strchr(implicit_mode, 'r') || strchr(implicit_mode, '+')) { char *encoding = (context && context->input_encoding) ? context->input_encoding : "utf8"; UErrorCode status = U_ZERO_ERROR; stream->input_encoding = ucnv_open(encoding, &status); + switch (U_FAILURE(status)) { + case U_ZERO_ERROR: + /* UTODO: If/When Input error handling gets implemented, set the options here */ + break; + case U_MEMORY_ALLOCATION_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + "Unable to allocate memory for unicode input converter: %s", encoding); + break; + case U_FILE_ACCESS_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + "Error loading unicode input converter: %s", encoding); + break; + default: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + "Unknown error starting unicode input converter: %s", encoding); + } } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Tue Mar 21 18:28:42 2006 UTC Modified files: /php-src/main/streams streams.c Log: Allow grow_mode && !bufstart (original assertion logic) http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.107&r2=1.108&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.107 php-src/main/streams/streams.c:1.108 --- php-src/main/streams/streams.c:1.107Sat Mar 18 19:44:51 2006 +++ php-src/main/streams/streams.c Tue Mar 21 18:28:42 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.107 2006/03/18 19:44:51 helly Exp $ */ +/* $Id: streams.c,v 1.108 2006/03/21 18:28:42 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -1112,7 +1112,8 @@ } if (total_copied == 0) { - assert(bufstart.v != NULL || !grow_mode || stream->eof); + assert(stream->eof || !grow_mode || + (grow_mode && bufstart.v == NULL)); return NULL; } @@ -1122,10 +1123,6 @@ buf.s[0] = 0; } - if (returned_len) { - *returned_len = total_copied; - } - return bufstart.s; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/bz2 bz2_filter.c /ext/standardfile.cfilters.c streamsfuncs.c user_filters.c /ext/unicode unicode_filter.c/ext/zlibzlib_filter.c /main php_streams.h /main/streams ca
Derick- I realized I wasn't doing your exact test case and masking the very thing which needed to be tested. I've gone back to precisely what you sent me and it started misbehaving right on cue. I've applied a fix to cvs. -Sara - Original Message - From: "Derick Rethans" <[EMAIL PROTECTED]> To: "Sara Golemon" <[EMAIL PROTECTED]> Cc: "Dmitry Stogov" <[EMAIL PROTECTED]>; Sent: Wednesday, March 15, 2006 12:36 PM Subject: Re: [PHP-CVS] cvs: php-src /ext/bz2 bz2_filter.c /ext/standardfile.cfilters.c streamsfuncs.c user_filters.c /ext/unicode unicode_filter.c/ext/zlibzlib_filter.c /main php_streams.h /main/streams cast.c filter.cphp_stream_filter_api.hstreams.c > On Wed, 15 Mar 2006, Derick Rethans wrote: > > > On Wed, 15 Mar 2006, Sara Golemon wrote: > > > > > Maybe a silly a question, but have you guys tried 'make clean'? (There are > > > some header file changes that might need to propagate to untouched source > > > files) I'm not getting these kinds of errors over here, but I am getting a > > > PASS from tests/lang/024.phpt > > > > I am pretty sure I did, but I will try again :) > > Just tested, still does this: > > [EMAIL PROTECTED]:/tmp/uc-stream-oops-lala$ > /dat/dev/php/php-6.0dev/sapi/cli/php block_file.php > Segmentation fault > > > regards, > Derick > > -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Wed Mar 15 21:18:36 2006 UTC Modified files: /php-src/main/streams streams.c Log: Fix improper byte count on partial reads http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.103&r2=1.104&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.103 php-src/main/streams/streams.c:1.104 --- php-src/main/streams/streams.c:1.103Wed Mar 15 00:28:57 2006 +++ php-src/main/streams/streams.c Wed Mar 15 21:18:36 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.103 2006/03/15 00:28:57 pollita Exp $ */ +/* $Id: streams.c,v 1.104 2006/03/15 21:18:36 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -424,6 +424,10 @@ TODO: Needs better handling of surrogate pairs */ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC) { + if (stream->readpos == stream->writepos) { + stream->readpos = stream->writepos = 0; + } + /* allocate/fill the buffer */ if (stream->readfilters.head) { @@ -573,7 +577,7 @@ /* reduce buffer memory consumption if possible, to avoid a realloc */ if (stream->readbuf.s && stream->readbuflen - stream->writepos < stream->chunk_size) { - memmove(stream->readbuf.s, stream->readbuf.s + stream->readpos, stream->readbuflen - stream->readpos); + memmove(stream->readbuf.s, stream->readbuf.s + stream->readpos, stream->writepos - stream->readpos); stream->writepos -= stream->readpos; stream->readpos = 0; } @@ -605,7 +609,7 @@ * drain the remainder of the buffer before using the "raw" read mode for * the excess */ if (stream->writepos - stream->readpos > 0) { - toread = UBYTES(stream->writepos - stream->readpos); + toread = PS_ULEN(stream->input_encoding, stream->writepos - stream->readpos); if (toread > size) { toread = size; @@ -1038,8 +1042,8 @@ * than 8K, we waste 1 byte per additional 8K or so. * That seems acceptable to me, to avoid making this code * hard to follow */ - bufstart.s = erealloc(bufstart.s, PS_ULEN(stream, current_buf_size + cpysz + 1)); - buf.s = bufstart.s + PS_ULEN(stream, total_copied); + bufstart.s = erealloc(bufstart.s, PS_ULEN(stream->input_encoding, current_buf_size + cpysz + 1)); + buf.s = bufstart.s + PS_ULEN(stream->input_encoding, total_copied); current_buf_size += cpysz + 1; } else { if (cpysz >= maxlen - 1) { @@ -1121,8 +1125,6 @@ return bufstart.s; } -/* Same deal as php_stream_read() and php_stream_get_line() - * Will give unexpected results if used against a unicode stream */ PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *returned_len, char *delim, size_t delim_len TSRMLS_DC) { char *e, *buf; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/bz2 bz2_filter.c /ext/standardfile.c filters.c streamsfuncs.c user_filters.c /ext/unicode unicode_filter.c/ext/zlib zlib_filter.c /main php_streams.h /main/streams
Maybe a silly a question, but have you guys tried 'make clean'? (There are some header file changes that might need to propagate to untouched source files) I'm not getting these kinds of errors over here, but I am getting a PASS from tests/lang/024.phpt -Sara - Original Message - From: "Derick Rethans" <[EMAIL PROTECTED]> To: "Sara Golemon" <[EMAIL PROTECTED]> Cc: "Dmitry Stogov" <[EMAIL PROTECTED]>; Sent: Wednesday, March 15, 2006 7:05 AM Subject: Re: [PHP-CVS] cvs: php-src /ext/bz2 bz2_filter.c /ext/standardfile.c filters.c streamsfuncs.c user_filters.c /ext/unicode unicode_filter.c/ext/zlib zlib_filter.c /main php_streams.h /main/streams cast.c filter.cphp_stream_filter_api.h streams.c > On Wed, 15 Mar 2006, Derick Rethans wrote: > > > No short script yet... I will try. > > http://files.derickrethans.nl/uc-stream.tar.gz > > regards, > Derick > > -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/bz2 bz2_filter.c /ext/standard file.c filters.c streamsfuncs.c user_filters.c /ext/unicode unicode_filter.c /ext/zlib zlib_filter.c /main php_streams.h /main/strea
> "make test" stops work after this patch, because now fgets() always returns > FALSE. > It is not possible for me to commit ZE patches without testing. > Please fix this ASAP or revert your patches. > Sorry about that. Should look good now (though of course there's still stuff to be done with streams to make it "ready"). -Sara -- 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
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.426&r2=1.427&diff_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.102&r2=1.103&diff_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 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.106&r2=1.107&diff_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.101&r2=1.102&diff_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:
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Mon Mar 13 20:54:06 2006 UTC Modified files: /php-src/main/streams streams.c Log: Make php_stream_write_buffer() return characters written, not bytes http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.100&r2=1.101&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.100 php-src/main/streams/streams.c:1.101 --- php-src/main/streams/streams.c:1.100Mon Mar 13 15:01:44 2006 +++ php-src/main/streams/streams.c Mon Mar 13 20:54:06 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.100 2006/03/13 15:01:44 derick Exp $ */ +/* $Id: streams.c,v 1.101 2006/03/13 20:54:06 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -1128,7 +1128,8 @@ /* Writes a buffer directly to a stream, using multiple of the chunk size */ static size_t _php_stream_write_buffer(php_stream *stream, int buf_type, zstr buf, int buflen TSRMLS_DC) { - size_t didwrite = 0, towrite, justwrote; + size_t didwrite = 0, towrite, justwrote, shouldwrite, buflen_orig = buflen; + zstr buf_orig = buf; char *freeme = NULL; /* if we have a seekable stream we need to ensure that data is written at the @@ -1155,6 +1156,8 @@ } } + shouldwrite = buflen; + while (buflen > 0) { towrite = buflen; if (towrite > stream->chunk_size) { @@ -1179,6 +1182,36 @@ } } + + if (stream->output_encoding) { + /* Map didwrite back to the original character count */ + if (didwrite == shouldwrite) { + /* Everything wrote okay, no need to count */ + didwrite = buflen_orig; + } else { + UErrorCode status = U_ZERO_ERROR; + char *t = freeme; + UChar *p = buf_orig.u; + + switch (ucnv_getType(stream->output_encoding)) { + case UCNV_SBCS: + case UCNV_LATIN_1: + case UCNV_US_ASCII: + /* 1:1 character->byte mapping, didwrite really does mean the number of characters written */ + break; + default: + /* Reconvert into junk buffer to see where conversion stops in source string */ + ucnv_resetFromUnicode(stream->output_encoding); + ucnv_fromUnicode(stream->output_encoding, &t, t + didwrite, &p, p + buflen_orig, NULL, TRUE, &status); + /* p stops at the first unconvertable UChar when t runs out of space */ + didwrite = p - buf_orig.u; + } + } + } else if (buf_type == IS_UNICODE) { + /* Was slopily converted */ + didwrite /= UBYTES(1); + } + if (freeme) { efree(freeme); } @@ -1296,10 +1329,6 @@ ret = _php_stream_write_buffer(stream, IS_UNICODE, (zstr)((UChar*)buf), count TSRMLS_CC); } - /* Return data points, not bytes */ - if (ret > 0) { - ret >>= 1; - } return ret; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /main main.c
pollita Thu Mar 9 20:32:23 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/main main.c Log: MFH: Move temporary local storage of primary file's realpath up one block to ensure it stays on the stack. http://cvs.php.net/viewcvs.cgi/php-src/main/main.c?r1=1.640.2.16&r2=1.640.2.17&diff_format=u Index: php-src/main/main.c diff -u php-src/main/main.c:1.640.2.16 php-src/main/main.c:1.640.2.17 --- php-src/main/main.c:1.640.2.16 Sun Feb 26 10:49:51 2006 +++ php-src/main/main.c Thu Mar 9 20:32:22 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: main.c,v 1.640.2.16 2006/02/26 10:49:51 helly Exp $ */ +/* $Id: main.c,v 1.640.2.17 2006/03/09 20:32:22 pollita Exp $ */ /* {{{ includes */ @@ -1662,6 +1662,8 @@ #endif zend_try { + char realfile[MAXPATHLEN]; + #ifdef PHP_WIN32 UpdateIniFromRegistry(primary_file->filename TSRMLS_CC); #endif @@ -1680,7 +1682,6 @@ } if (primary_file->filename) { - char realfile[MAXPATHLEN]; int realfile_len; int dummy = 1; if (VCWD_REALPATH(primary_file->filename, realfile)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main main.c
pollita Thu Mar 9 20:31:58 2006 UTC Modified files: /php-src/main main.c Log: Move temporary local storage of primary file's realpath up one block to ensure it stays on the stack. http://cvs.php.net/viewcvs.cgi/php-src/main/main.c?r1=1.670&r2=1.671&diff_format=u Index: php-src/main/main.c diff -u php-src/main/main.c:1.670 php-src/main/main.c:1.671 --- php-src/main/main.c:1.670 Wed Mar 8 14:41:45 2006 +++ php-src/main/main.c Thu Mar 9 20:31:58 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: main.c,v 1.670 2006/03/08 14:41:45 iliaa Exp $ */ +/* $Id: main.c,v 1.671 2006/03/09 20:31:58 pollita Exp $ */ /* {{{ includes */ @@ -1767,6 +1767,8 @@ #endif zend_try { + char realfile[MAXPATHLEN]; + #ifdef PHP_WIN32 UpdateIniFromRegistry(primary_file->filename TSRMLS_CC); #endif @@ -1785,7 +1787,6 @@ } if (primary_file->filename) { - char realfile[MAXPATHLEN]; int realfile_len; int dummy = 1; if (VCWD_REALPATH(primary_file->filename, realfile)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/hash hash.c hash_md.c package.xml php_hash.h php_hash_md.h /ext/hash/tests md2.phpt
pollita Tue Feb 21 20:37:12 2006 UTC Added files: /php-src/ext/hash/tests md2.phpt Modified files: /php-src/ext/hash hash.c hash_md.c php_hash.h php_hash_md.h package.xml Log: Add md2 algo support http://cvs.php.net/viewcvs.cgi/php-src/ext/hash/hash.c?r1=1.23&r2=1.24&diff_format=u Index: php-src/ext/hash/hash.c diff -u php-src/ext/hash/hash.c:1.23 php-src/ext/hash/hash.c:1.24 --- php-src/ext/hash/hash.c:1.23Tue Feb 21 20:12:42 2006 +++ php-src/ext/hash/hash.c Tue Feb 21 20:37:12 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: hash.c,v 1.23 2006/02/21 20:12:42 dmitry Exp $ */ +/* $Id: hash.c,v 1.24 2006/02/21 20:37:12 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -516,6 +516,7 @@ zend_hash_init(&php_hash_hashtable, 35, NULL, NULL, 1); + php_hash_register_algo("md2", &php_hash_md2_ops); php_hash_register_algo("md4", &php_hash_md4_ops); php_hash_register_algo("md5", &php_hash_md5_ops); php_hash_register_algo("sha1", &php_hash_sha1_ops); http://cvs.php.net/viewcvs.cgi/php-src/ext/hash/hash_md.c?r1=1.9&r2=1.10&diff_format=u Index: php-src/ext/hash/hash_md.c diff -u php-src/ext/hash/hash_md.c:1.9 php-src/ext/hash/hash_md.c:1.10 --- php-src/ext/hash/hash_md.c:1.9 Sun Feb 19 04:29:40 2006 +++ php-src/ext/hash/hash_md.c Tue Feb 21 20:37:12 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: hash_md.c,v 1.9 2006/02/19 04:29:40 andi Exp $ */ +/* $Id: hash_md.c,v 1.10 2006/02/21 20:37:12 pollita Exp $ */ #include "php_hash.h" #include "php_hash_md.h" @@ -39,6 +39,15 @@ sizeof(PHP_MD4_CTX) }; +php_hash_ops php_hash_md2_ops = { + (php_hash_init_func_t) PHP_MD2Init, + (php_hash_update_func_t) PHP_MD2Update, + (php_hash_final_func_t) PHP_MD2Final, + 16, + 16, + sizeof(PHP_MD2_CTX) +}; + /* MD common stuff */ static unsigned char PADDING[64] = @@ -579,6 +588,95 @@ } /* }}} */ +/* MD2 */ + +static unsigned char MD2_S[256] = { +41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, 19, +98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, 76, 130, 202, +30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, 138, 23, 229, 18, + 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, 245, 142, 187, 47, 238, 122, + 169, 104, 121, 145, 21, 178, 7, 63, 148, 194, 16, 137, 11, 34, 95, 33, + 128, 127, 93, 154, 90, 144, 50, 39, 53, 62, 204, 231, 191, 247, 151, 3, + 255, 25, 48, 179, 72, 165, 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, +79, 184, 56, 210, 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, +69, 157, 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, +27, 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, +85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, 234, 38, +44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, 129, 77, 82, + 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, 8, 12, 189, 177, 74, + 120, 136, 149, 139, 227, 99, 232, 109, 233, 203, 213, 254, 59, 0, 29, 57, + 242, 239, 183, 14, 102, 88, 208, 228, 166, 119, 114, 248, 235, 117, 75, 10, +49, 68, 80, 180, 143, 237, 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 }; + +PHP_HASH_API void PHP_MD2Init(PHP_MD2_CTX *context) +{ + memset(context, 0, sizeof(PHP_MD2_CTX)); +} + +static void MD2_Transform(PHP_MD2_CTX *context, const unsigned char *block) +{ + unsigned char i,j,t = 0; + + for(i = 0; i < 16; i++) { + context->state[16+i] = block[i]; + context->state[32+i] = (context->state[16+i] ^ context->state[i]); + } + + for(i = 0; i < 18; i++) { + for(j = 0; j < 48; j++) { + t = context->state[j] = context->state[j] ^ MD2_S[t]; + } + t += i; + } + + /* Update checksum -- must be after transform to avoid fouling up last message block */ + t = context->checksum[15]; + for(i = 0; i < 16; i++) { + t = context->checksum[i] ^= MD2_S[block[i] ^ t]; + } +} + +PHP_HASH_API void PHP_MD2Update(PHP_MD2_CTX *context, const unsigned char *buf, unsigned int len) +{ + const unsigned char *p = buf, *e = buf + len; + + if (context->in_buffer) { + if (context->in_buffer + len < 16) { + /* Not enough for block, just pass into buffer */ + memcpy(context->buffer + context->in_buffer, p, len); + context->in_buffer +=
[PHP-CVS] cvs: php-src /ext/hash package.xml
pollita Tue Feb 21 20:35:38 2006 UTC Modified files: /php-src/ext/hash package.xml Log: Keep history in package.xml file.. http://cvs.php.net/viewcvs.cgi/php-src/ext/hash/package.xml?r1=1.18&r2=1.19&diff_format=u Index: php-src/ext/hash/package.xml diff -u php-src/ext/hash/package.xml:1.18 php-src/ext/hash/package.xml:1.19 --- php-src/ext/hash/package.xml:1.18 Sun Feb 19 23:53:06 2006 +++ php-src/ext/hash/package.xmlTue Feb 21 20:35:38 2006 @@ -20,12 +20,22 @@ - - 1.2 - stable - 2006-02-00 - + +1.2 +stable +2006-02-00 + Fixed tiger algorithm generating wrong results on big endian platforms. + + + + + +1.1 +stable +2005-12-07 + +Fixed PECL bug #6183 - haval source file entries missing in package.xml Supported Algorithms: * md4, md5 @@ -34,8 +44,9 @@ * tiger128, tiger160, tiger192 (3 and 4 passes) * haval128, haval160, haval192, haval224, haval256 (3, 4 and 5 passes) * crc32, crc32b, adler32, gost, snefru, whirlpool - - + + + -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/pdo_oci config.m4
pollita Thu Feb 16 02:03:14 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/pdo_ociconfig.m4 Log: Fix copy/paste problems for instantclient http://cvs.php.net/viewcvs.cgi/php-src/ext/pdo_oci/config.m4?r1=1.14.2.4&r2=1.14.2.5&diff_format=u Index: php-src/ext/pdo_oci/config.m4 diff -u php-src/ext/pdo_oci/config.m4:1.14.2.4 php-src/ext/pdo_oci/config.m4:1.14.2.5 --- php-src/ext/pdo_oci/config.m4:1.14.2.4 Fri Jan 6 11:48:19 2006 +++ php-src/ext/pdo_oci/config.m4 Thu Feb 16 02:03:13 2006 @@ -1,4 +1,4 @@ -dnl $Id: config.m4,v 1.14.2.4 2006/01/06 11:48:19 tony2001 Exp $ +dnl $Id: config.m4,v 1.14.2.5 2006/02/16 02:03:13 pollita Exp $ if test "$PHP_PDO" != "no"; then @@ -88,11 +88,11 @@ PHP_ADD_INCLUDE($PDO_OCI_IC_PREFIX/lib/oracle/$PDO_OCI_IC_VERS/client/include) AC_MSG_RESULT($PDO_OCI_IC_PREFIX/lib/oracle/$PDO_OCI_IC_VERS/client/include) elif test -f $PDO_OCI_IC_PREFIX/sdk/include/oci.h ; then - PHP_ADD_INCLUDE($PDO_OCI_PREFIX/sdk/include) - AC_MSG_RESULT($PDO_OCI_PREFIX/sdk/include) + PHP_ADD_INCLUDE($PDO_OCI_IC_PREFIX/sdk/include) + AC_MSG_RESULT($PDO_OCI_IC_PREFIX/sdk/include) elif test -f $PDO_OCI_IC_PREFIX/client/include/oci.h ; then - PHP_ADD_INCLUDE($PDO_OCI_PREFIX/client/include) - AC_MSG_RESULT($PDO_OCI_PREFIX/client/include) + PHP_ADD_INCLUDE($PDO_OCI_IC_PREFIX/client/include) + AC_MSG_RESULT($PDO_OCI_IC_PREFIX/client/include) else AC_MSG_ERROR([I'm too dumb to figure out where the include dir is in your instant client install]) fi -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /main/streams xp_socket.c
pollita Thu Feb 2 18:16:43 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/main/streams xp_socket.c Log: MFH: Prevent bindport from being used uninitialized http://cvs.php.net/viewcvs.cgi/php-src/main/streams/xp_socket.c?r1=1.33.2.1&r2=1.33.2.2&diff_format=u Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.33.2.1 php-src/main/streams/xp_socket.c:1.33.2.2 --- php-src/main/streams/xp_socket.c:1.33.2.1 Sun Jan 1 12:50:18 2006 +++ php-src/main/streams/xp_socket.cThu Feb 2 18:16:43 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: xp_socket.c,v 1.33.2.1 2006/01/01 12:50:18 sniper Exp $ */ +/* $Id: xp_socket.c,v 1.33.2.2 2006/02/02 18:16:43 pollita Exp $ */ #include "php.h" #include "ext/standard/file.h" @@ -578,7 +578,7 @@ php_stream_xport_param *xparam TSRMLS_DC) { char *host = NULL, *bindto = NULL; - int portno, bindport; + int portno, bindport = 0; int err; int ret; zval **tmpzval = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams xp_socket.c
pollita Thu Feb 2 18:16:25 2006 UTC Modified files: /php-src/main/streams xp_socket.c Log: Prevent bindport from being used uninitialized http://cvs.php.net/viewcvs.cgi/php-src/main/streams/xp_socket.c?r1=1.34&r2=1.35&diff_format=u Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.34 php-src/main/streams/xp_socket.c:1.35 --- php-src/main/streams/xp_socket.c:1.34 Sun Jan 1 13:09:57 2006 +++ php-src/main/streams/xp_socket.cThu Feb 2 18:16:25 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: xp_socket.c,v 1.34 2006/01/01 13:09:57 sniper Exp $ */ +/* $Id: xp_socket.c,v 1.35 2006/02/02 18:16:25 pollita Exp $ */ #include "php.h" #include "ext/standard/file.h" @@ -578,7 +578,7 @@ php_stream_xport_param *xparam TSRMLS_DC) { char *host = NULL, *bindto = NULL; - int portno, bindport; + int portno, bindport = 0; int err; int ret; zval **tmpzval = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /sapi/embed php_embed.h
pollita Thu Dec 29 06:02:18 2005 EDT Modified files: (Branch: PHP_5_1) /php-src/sapi/embed php_embed.h Log: MFH(r-1.7) Silence compiler warning: unused variable http://cvs.php.net/viewcvs.cgi/php-src/sapi/embed/php_embed.h?r1=1.6&r2=1.6.2.1&diff_format=u Index: php-src/sapi/embed/php_embed.h diff -u php-src/sapi/embed/php_embed.h:1.6 php-src/sapi/embed/php_embed.h:1.6.2.1 --- php-src/sapi/embed/php_embed.h:1.6 Wed Aug 3 14:08:49 2005 +++ php-src/sapi/embed/php_embed.h Thu Dec 29 06:02:17 2005 @@ -15,7 +15,7 @@ | Author: Edin Kadribasic <[EMAIL PROTECTED]> | +--+ */ -/* $Id: php_embed.h,v 1.6 2005/08/03 14:08:49 sniper Exp $ */ +/* $Id: php_embed.h,v 1.6.2.1 2005/12/29 06:02:17 pollita Exp $ */ #ifndef _PHP_EMBED_H_ #define _PHP_EMBED_H_ @@ -32,18 +32,24 @@ #define PTSRMLS_DC , PTSRMLS_D #define PTSRMLS_C&tsrm_ls #define PTSRMLS_CC , PTSRMLS_C + +#define PHP_EMBED_START_BLOCK(x,y) { \ +void ***tsrm_ls; \ +php_embed_init(x, y PTSRMLS_CC); \ +zend_first_try { + #else #define PTSRMLS_D #define PTSRMLS_DC #define PTSRMLS_C #define PTSRMLS_CC -#endif #define PHP_EMBED_START_BLOCK(x,y) { \ -void ***tsrm_ls; \ -php_embed_init(x, y PTSRMLS_CC); \ +php_embed_init(x, y); \ zend_first_try { +#endif + #define PHP_EMBED_END_BLOCK() \ } zend_catch { \ /* int exit_status = EG(exit_status); */ \ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/embed php_embed.h
pollita Thu Dec 29 06:00:36 2005 EDT Modified files: /php-src/sapi/embed php_embed.h Log: Silence compiler warning: unused variable http://cvs.php.net/viewcvs.cgi/php-src/sapi/embed/php_embed.h?r1=1.6&r2=1.7&diff_format=u Index: php-src/sapi/embed/php_embed.h diff -u php-src/sapi/embed/php_embed.h:1.6 php-src/sapi/embed/php_embed.h:1.7 --- php-src/sapi/embed/php_embed.h:1.6 Wed Aug 3 14:08:49 2005 +++ php-src/sapi/embed/php_embed.h Thu Dec 29 06:00:36 2005 @@ -15,7 +15,7 @@ | Author: Edin Kadribasic <[EMAIL PROTECTED]> | +--+ */ -/* $Id: php_embed.h,v 1.6 2005/08/03 14:08:49 sniper Exp $ */ +/* $Id: php_embed.h,v 1.7 2005/12/29 06:00:36 pollita Exp $ */ #ifndef _PHP_EMBED_H_ #define _PHP_EMBED_H_ @@ -32,18 +32,25 @@ #define PTSRMLS_DC , PTSRMLS_D #define PTSRMLS_C&tsrm_ls #define PTSRMLS_CC , PTSRMLS_C + +#define PHP_EMBED_START_BLOCK(x,y) { \ +void ***tsrm_ls; \ +php_embed_init(x, y PTSRMLS_CC); \ +zend_first_try { + #else #define PTSRMLS_D #define PTSRMLS_DC #define PTSRMLS_C #define PTSRMLS_CC -#endif #define PHP_EMBED_START_BLOCK(x,y) { \ -void ***tsrm_ls; \ -php_embed_init(x, y PTSRMLS_CC); \ +php_embed_init(x, y); \ zend_first_try { +#endif + + #define PHP_EMBED_END_BLOCK() \ } zend_catch { \ /* int exit_status = EG(exit_status); */ \ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_4) /ext/standard http_fopen_wrapper.c
pollita Tue Dec 6 14:25:16 2005 EDT Modified files: (Branch: PHP_4_4) /php-src/ext/standard http_fopen_wrapper.c Log: MFH: (r-1.104) http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.53.2.20.2.2&r2=1.53.2.20.2.3&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.53.2.20.2.2 php-src/ext/standard/http_fopen_wrapper.c:1.53.2.20.2.3 --- php-src/ext/standard/http_fopen_wrapper.c:1.53.2.20.2.2 Tue Jul 26 05:32:58 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Tue Dec 6 14:25:12 2005 @@ -18,7 +18,7 @@ | Wez Furlong <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.53.2.20.2.2 2005/07/26 09:32:58 hyanantha Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.53.2.20.2.3 2005/12/06 19:25:12 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -199,7 +199,8 @@ /* send it */ php_stream_write(stream, scratch, strlen(scratch)); - if (context && php_stream_context_get_option(context, "http", "header", &tmpzval) == SUCCESS && Z_STRLEN_PP(tmpzval)) { + if (context && php_stream_context_get_option(context, "http", "header", &tmpzval) == SUCCESS && + Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval)) { /* Remove newlines and spaces from start and end, php_trim will estrndup() */ tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), NULL, 0, NULL, 3 TSRMLS_CC); if (strlen(tmp) > 0) { @@ -268,7 +269,8 @@ } if (context && - php_stream_context_get_option(context, "http", "user_agent", &ua_zval) == SUCCESS) { + php_stream_context_get_option(context, "http", "user_agent", &ua_zval) == SUCCESS && + Z_TYPE_PP(ua_zval) == IS_STRING) { ua_str = Z_STRVAL_PP(ua_zval); } else if (FG(user_agent)) { ua_str = FG(user_agent); @@ -300,7 +302,8 @@ php_stream_write(stream, "\r\n", sizeof("\r\n")-1); /* Request content, such as for POST requests */ - if (context && php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS && Z_STRLEN_PP(tmpzval) > 0) { + if (context && php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS && + Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) { php_stream_write(stream, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval)); php_stream_write(stream, "\r\n\r\n", sizeof("\r\n\r\n")-1); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php