]> granicus.if.org Git - php/commitdiff
#38105 (4/3) ustrlen != USTRLEN, update variable names used to keep this block's...
authorSara Golemon <pollita@php.net>
Fri, 14 Jul 2006 20:50:45 +0000 (20:50 +0000)
committerSara Golemon <pollita@php.net>
Fri, 14 Jul 2006 20:50:45 +0000 (20:50 +0000)
ext/standard/file.c

index 91c2e1967373b48d180b060cab7ac0eb3d234cd0..8d6e79cf77838b321bd3168193d684c85cd9c9a4 100644 (file)
@@ -697,12 +697,14 @@ PHP_FUNCTION(file_put_contents)
                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;