helly           Tue May 23 22:26:23 2006 UTC

  Modified files:              
    /php-src/main/streams       memory.c 
  Log:
  - Fix feof() with temp/memory streams
  
http://cvs.php.net/viewcvs.cgi/php-src/main/streams/memory.c?r1=1.21&r2=1.22&diff_format=u
Index: php-src/main/streams/memory.c
diff -u php-src/main/streams/memory.c:1.21 php-src/main/streams/memory.c:1.22
--- php-src/main/streams/memory.c:1.21  Sun May 21 13:35:06 2006
+++ php-src/main/streams/memory.c       Tue May 23 22:26:23 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: memory.c,v 1.21 2006/05/21 13:35:06 helly Exp $ */
+/* $Id: memory.c,v 1.22 2006/05/23 22:26:23 helly Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -88,16 +88,15 @@
        php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
        assert(ms != NULL);
 
-       if (ms->fpos + count > ms->fsize) {
+       if (ms->fpos + count >= ms->fsize) {
                count = ms->fsize - ms->fpos;
+               stream->eof = 1;
        }
        if (count) {
                assert(ms->data!= NULL);
                assert(buf!= NULL);
                memcpy(buf, ms->data+ms->fpos, count);
                ms->fpos += count;
-       } else {
-               stream->eof = 1;
        }
        return count;
 }
@@ -147,6 +146,7 @@
                                } else {
                                        ms->fpos = ms->fpos + offset;
                                        *newoffs = ms->fpos;
+                                       stream->eof = 0;
                                        return 0;
                                }
                        } else {
@@ -157,6 +157,7 @@
                                } else {
                                        ms->fpos = ms->fpos + offset;
                                        *newoffs = ms->fpos;
+                                       stream->eof = 0;
                                        return 0;
                                }
                        }
@@ -168,6 +169,7 @@
                        } else {
                                ms->fpos = offset;
                                *newoffs = ms->fpos;
+                               stream->eof = 0;
                                return 0;
                        }
                case SEEK_END:
@@ -182,6 +184,7 @@
                        } else {
                                ms->fpos = ms->fsize + offset;
                                *newoffs = ms->fpos;
+                               stream->eof = 0;
                                return 0;
                        }
                default:
@@ -359,9 +362,7 @@
        
        got = php_stream_read(ts->innerstream, buf, count);
        
-       if (!got) {
-               stream->eof |= ts->innerstream->eof;
-       }
+       stream->eof = ts->innerstream->eof;
        
        return got;
 }
@@ -418,6 +419,7 @@
        }
        ret = php_stream_seek(ts->innerstream, offset, whence);
        *newoffs = php_stream_tell(ts->innerstream);
+       stream->eof = ts->innerstream->eof;
        
        return ret;
 }

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

Reply via email to