cvs: php-src /ext/standard file.c /main/streams streams.c
| From: | Derick Rethans | Date: | Mon, 13 Mar 2006 15:01:44 +0000 |
| Subject: | cvs: php-src /ext/standard file.c /main/streams streams.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-37250@lists.php.net to get a copy of this message | ||
derick Mon Mar 13 15:01:44 2006 UTC
Modified files:
/php-src/main/streams streams.c
/php-src/ext/standard file.c
Log:
This makes file_put_contents() work for:
<?php
declare(encoding="latin1");
$a = "1234å67890";
file_put_contents( "/tmp/testuc.1", $a);
file_put_contents( "/tmp/testuc.2", (string) $a);
$context = stream_context_create();
stream_context_set_params($context, array( "output_encoding" =>
"latin1" ) );
file_put_contents( "/tmp/testuc.3", $a, FILE_TEXT, $context);
file_put_contents( "/tmp/testuc.4", (string) $a, FILE_TEXT, $context);
?>
But it still throws a warning on ".3". It's a small design issue that I
didn't want to touch right now.
http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.99&r2=1.100&diff_format=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.99 php-src/main/streams/streams.c:1.100
--- php-src/main/streams/streams.c:1.99 Mon Mar 13 04:40:11 2006
+++ php-src/main/streams/streams.c Mon Mar 13 15:01:44 2006
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.99 2006/03/13 04:40:11 pollita Exp $ */
+/* $Id: streams.c,v 1.100 2006/03/13 15:01:44 derick Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -1140,7 +1140,7 @@
stream->ops->seek(stream, stream->position, SEEK_SET, &stream->position
TSRMLS_CC);
}
- if (stream->output_encoding) {
+ if (stream->output_encoding && buf_type == IS_UNICODE) {
char *dest;
int destlen;
UErrorCode status = U_ZERO_ERROR;
@@ -1150,7 +1150,9 @@
buflen = destlen;
} else {
/* Sloppy handling, make it a binary buffer */
- buflen = UBYTES(buflen);
+ if (buf_type != IS_STRING) {
+ buflen = UBYTES(buflen);
+ }
}
while (buflen > 0) {
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.424&r2=1.425&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.424 php-src/ext/standard/file.c:1.425
--- php-src/ext/standard/file.c:1.424 Mon Mar 13 04:40:11 2006
+++ php-src/ext/standard/file.c Mon Mar 13 15:01:44 2006
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.424 2006/03/13 04:40:11 pollita Exp $ */
+/* $Id: file.c,v 1.425 2006/03/13 15:01:44 derick Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -662,7 +662,7 @@
if (numchars < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %d characters to %s",
ustrlen, filename);
numchars = -1;
- } else if (numchars != UBYTES(Z_USTRLEN_P(data))) {
+ } else if (numchars != ustrlen) {
int numchars = u_countChar32(Z_USTRVAL_P(data), numchars);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d characters written, possibly
out of free disk space", numchars, ustrlen);