[macruby-changes] [573] MacRuby/trunk/io.c

source_changes at macosforge.org source_changes at macosforge.org
Sun Sep 7 20:53:47 PDT 2008


Revision: 573
          http://trac.macosforge.org/projects/ruby/changeset/573
Author:   lsansonetti at apple.com
Date:     2008-09-07 20:53:47 -0700 (Sun, 07 Sep 2008)
Log Message:
-----------
sync potential bytestrings

Modified Paths:
--------------
    MacRuby/trunk/io.c

Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c	2008-09-08 03:53:33 UTC (rev 572)
+++ MacRuby/trunk/io.c	2008-09-08 03:53:47 UTC (rev 573)
@@ -712,7 +712,10 @@
     }
 
     len = RSTRING_BYTELEN(str);
-    if ((n = len) <= 0) return n;
+    if ((n = len) <= 0) {
+	RSTRING_SYNC(str);
+	return n;
+    }
     if (fptr->wbuf == NULL && !(fptr->mode & FMODE_SYNC)) {
         fptr->wbuf_off = 0;
         fptr->wbuf_len = 0;
@@ -731,10 +734,14 @@
             fptr->wbuf_len += len;
             n = 0;
         }
-        if (io_fflush(fptr) < 0)
+        if (io_fflush(fptr) < 0) {
+	    RSTRING_SYNC(str);
             return -1L;
-        if (n == 0)
+	}
+        if (n == 0) {
+	    RSTRING_SYNC(str);
             return len;
+	}
         /* avoid context switch between "a" and "\n" in STDERR.puts "a".
            [ruby-dev:25080] */
 	if (fptr->stdio_file != stderr && !rb_thread_fd_writable(fptr->fd)) {
@@ -750,7 +757,10 @@
         }
 	r = rb_write_internal(fptr->fd, RSTRING_BYTEPTR(str)+offset, l);
 	/* xxx: other threads may modify given string. */
-        if (r == n) return len;
+        if (r == n) {
+	    RSTRING_SYNC(str);
+	    return len;
+	}
         if (0 <= r) {
             offset += r;
             n -= r;
@@ -761,6 +771,7 @@
 	    if (offset < RSTRING_BYTELEN(str))
 		goto retry;
         }
+	RSTRING_SYNC(str);
         return -1L;
     }
 
@@ -771,6 +782,7 @@
     }
     MEMMOVE(fptr->wbuf+fptr->wbuf_off+fptr->wbuf_len, RSTRING_BYTEPTR(str)+offset, char, len);
     fptr->wbuf_len += len;
+    RSTRING_SYNC(str);
     return len;
 }
 
@@ -4821,6 +4833,7 @@
             RSTRING_BYTEPTR(line)[RSTRING_BYTELEN(line)-1] != '\n') {
 	    rb_io_write(out, rb_default_rs);
 	}
+	RSTRING_SYNC(line);
     }
 
     return Qnil;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080907/315339f8/attachment.html 


More information about the macruby-changes mailing list