helly           Sat Mar 18 19:44:52 2006 UTC

  Modified files:              
    /php-src/main/streams       streams.c 
  Log:
  - Fix issue in _php_stream_get_line(): Allow maxchars == 0 as macro
    php_stream_get_line() does
  
  
http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.106&r2=1.107&diff_format=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.106 
php-src/main/streams/streams.c:1.107
--- php-src/main/streams/streams.c:1.106        Fri Mar 17 22:52:55 2006
+++ php-src/main/streams/streams.c      Sat Mar 18 19:44:51 2006
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c,v 1.106 2006/03/17 22:52:55 andrei Exp $ */
+/* $Id: streams.c,v 1.107 2006/03/18 19:44:51 helly Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -1053,20 +1053,22 @@
                        }
 
                        if (is_unicode) {
-                               int ulen = u_countChar32(readptr.u, cpysz);
-
-                               if (ulen > maxchars) {
-                                       int32_t i = 0;
-
-                                       ulen = maxchars;
-                                       U16_FWD_N(readptr.u, i, cpysz, ulen);
-                                       cpysz = i;
+                               if (maxchars) {
+                                       int ulen = u_countChar32(readptr.u, 
cpysz);
+       
+                                       if (ulen > maxchars) {
+                                               int32_t i = 0;
+       
+                                               ulen = maxchars;
+                                               U16_FWD_N(readptr.u, i, cpysz, 
ulen);
+                                               cpysz = i;
+                                       }
+                                       maxchars -= ulen;
                                }
-                               maxchars -= ulen;
                                memcpy(buf.u, readptr.u, UBYTES(cpysz));
                                buf.u += cpysz;
                        } else {
-                               if (cpysz > maxchars) {
+                               if (maxchars && cpysz > maxchars) {
                                        cpysz = maxchars;
                                }
                                memcpy(buf.s, readptr.s, cpysz);
@@ -1105,10 +1107,12 @@
                }
        }
 
+       if (returned_len) {
+               *returned_len = total_copied;
+       }
+
        if (total_copied == 0) {
-               if (grow_mode) {
-                       assert(bufstart.v == NULL);
-               }
+               assert(bufstart.v != NULL || !grow_mode || stream->eof);
                return NULL;
        }
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to