develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33639 - branches/pdd22io_part2/src/io

From:
allison
Date:
December 7, 2008 16:45
Subject:
[svn:parrot] r33639 - branches/pdd22io_part2/src/io
Message ID:
20081208004536.7EF69CB9AF@x12.develooper.com
Author: allison
Date: Sun Dec  7 16:45:35 2008
New Revision: 33639

Modified:
   branches/pdd22io_part2/src/io/buffer.c

Log:
[pdd22io] Clean up several more instances of values modified but not set
in the FileHandle object.


Modified: branches/pdd22io_part2/src/io/buffer.c
==============================================================================
--- branches/pdd22io_part2/src/io/buffer.c	(original)
+++ branches/pdd22io_part2/src/io/buffer.c	Sun Dec  7 16:45:35 2008
@@ -273,15 +273,18 @@
     size_t len;
     size_t current = 0;
     INTVAL buffer_flags = Parrot_io_get_buffer_flags(interp, filehandle);
-    unsigned char *buffer_start = Parrot_io_get_buffer_start(interp, filehandle);
-    unsigned char *buffer_next  = Parrot_io_get_buffer_next(interp, filehandle);
-    unsigned char *buffer_end   = Parrot_io_get_buffer_end(interp, filehandle);
+    unsigned char *buffer_start, *buffer_next, *buffer_end;
 
     /* write buffer flush */
     if (buffer_flags & PIO_BF_WRITEBUF) {
         Parrot_io_flush(interp, filehandle);
+        buffer_flags = Parrot_io_get_buffer_flags(interp, filehandle);
     }
 
+    buffer_start = Parrot_io_get_buffer_start(interp, filehandle);
+    buffer_next  = Parrot_io_get_buffer_next(interp, filehandle);
+    buffer_end   = Parrot_io_get_buffer_end(interp, filehandle);
+
     /* line buffered read */
     if (Parrot_io_get_flags(interp, filehandle) & PIO_F_LINEBUF) {
         return Parrot_io_readline_buffer(interp, filehandle, buf);
@@ -396,16 +399,19 @@
     size_t  avail = 0;
 
     INTVAL         buffer_flags = Parrot_io_get_buffer_flags(interp, filehandle);
-    unsigned char *buffer_next  = Parrot_io_get_buffer_next(interp, filehandle);
-    unsigned char *buffer_end   = Parrot_io_get_buffer_end(interp, filehandle);
+    unsigned char *buffer_next, *buffer_end;
 
     STRING * const s = Parrot_io_make_string(interp, buf, 1);
 
     /* write buffer flush */
     if (buffer_flags & PIO_BF_WRITEBUF) {
         Parrot_io_flush(interp, filehandle);
+        buffer_flags = Parrot_io_get_buffer_flags(interp, filehandle);
     }
 
+    buffer_next  = Parrot_io_get_buffer_next(interp, filehandle);
+    buffer_end   = Parrot_io_get_buffer_end(interp, filehandle);
+
     /* read Data from buffer */
     if (buffer_flags & PIO_BF_READBUF) {
         avail = buffer_end - buffer_next;
@@ -531,7 +537,7 @@
     /* check if buffer is finished */
     if (buffer_next == buffer_end) {
         Parrot_io_set_buffer_flags(interp, filehandle,
-                (buffer_flags & ~PIO_BF_READBUF));
+                (Parrot_io_get_buffer_flags(interp, filehandle) & ~PIO_BF_READBUF));
         Parrot_io_set_buffer_next(interp, filehandle,
                 Parrot_io_get_buffer_start(interp, filehandle));
         Parrot_io_set_buffer_end(interp, filehandle, NULL);
@@ -571,7 +577,8 @@
     else if (buffer_flags & PIO_BF_READBUF) {
         buffer_flags &= ~PIO_BF_READBUF;
         Parrot_io_set_buffer_flags(interp, filehandle, buffer_flags);
-        Parrot_io_set_buffer_next(interp, filehandle, buffer_start);
+        buffer_next = buffer_start;
+        Parrot_io_set_buffer_next(interp, filehandle, buffer_next);
         avail = buffer_size;
     }
     else {
@@ -629,13 +636,16 @@
         Parrot_io_set_buffer_flags(interp, filehandle, buffer_flags);
         /* Fill remainder, flush, then try to buffer more */
         memcpy(buffer_next, buffer, avail);
-        Parrot_io_set_buffer_next(interp, filehandle, buffer_next);
         buffer_next += avail;
+        Parrot_io_set_buffer_next(interp, filehandle, buffer_next);
         Parrot_io_set_file_position(interp, filehandle, (avail +
                     Parrot_io_get_file_position(interp, filehandle)));
         Parrot_io_flush(interp, filehandle);
+        buffer_next = Parrot_io_get_buffer_next(interp, filehandle);
         memcpy(buffer_start, ((const char *)buffer + avail), diff);
+        Parrot_io_set_buffer_start(interp, filehandle, buffer_start);
         buffer_next += diff;
+        Parrot_io_set_buffer_next(interp, filehandle, buffer_next);
         Parrot_io_set_file_position(interp, filehandle, (diff +
                     Parrot_io_get_file_position(interp, filehandle)));
         return len;



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About