tony2001 Wed Oct 5 17:46:31 2005 EDT Modified files: /php-src/main/streams streams.c Log: fix fwrite() and fgets() in unicode mode http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.88&r2=1.89&ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.88 php-src/main/streams/streams.c:1.89 --- php-src/main/streams/streams.c:1.88 Wed Oct 5 13:18:06 2005 +++ php-src/main/streams/streams.c Wed Oct 5 17:46:28 2005 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.88 2005/10/05 17:18:06 tony2001 Exp $ */ +/* $Id: streams.c,v 1.89 2005/10/05 21:46:28 tony2001 Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -1258,7 +1258,7 @@ count_bytes <<= 1; /* translate U16 to bytes */ } - memcpy(buf + num_bytes, s, count_bytes); + memcpy(buf + (num_bytes >> 1), s, count_bytes); num_bytes += count_bytes; num_chars += count_chars; stream->readbuf_ofs += count_bytes >> 1; @@ -1577,23 +1577,23 @@ PHPAPI size_t _php_stream_u_write(php_stream *stream, const UChar *buf, int32_t count TSRMLS_DC) { + int32_t ret; + if (buf == NULL || count == 0 || stream->ops->write == NULL) { return 0; } if (stream->writefilters.head) { - return _php_stream_write_filtered(stream, (const char*)buf, count, PSFS_FLAG_NORMAL, 1 TSRMLS_CC); + ret = _php_stream_write_filtered(stream, (const char*)buf, count, PSFS_FLAG_NORMAL, 1 TSRMLS_CC); } else { - int32_t ret; - ret = _php_stream_write_buffer(stream, (const char*)buf, UBYTES(count) TSRMLS_CC); + } - /* Return data points, not bytes */ - if (ret > 0) { - ret >>= 1; - } - return ret; + /* Return data points, not bytes */ + if (ret > 0) { + ret >>= 1; } + return ret; } PHPAPI size_t _php_stream_printf(php_stream *stream TSRMLS_DC, const char *fmt, ...)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php