[前][次][番号順一覧][スレッド一覧]

ruby-changes:3380

From: ko1@a...
Date: 4 Jan 2008 00:41:06 +0900
Subject: [ruby-changes:3380] akr - Ruby:r14873 (trunk): * io.c (io_ungetc): move data in buffer if it is required to store the

akr	2008-01-04 00:40:45 +0900 (Fri, 04 Jan 2008)

  New Revision: 14873

  Modified files:
    trunk/ChangeLog
    trunk/io.c

  Log:
    * io.c (io_ungetc): move data in buffer if it is required to store the
      argument.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14873&r2=14872&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=14873&r2=14872&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14872)
+++ ChangeLog	(revision 14873)
@@ -1,3 +1,8 @@
+Fri Jan  4 00:20:47 2008  Tanaka Akira  <akr@f...>
+
+	* io.c (io_ungetc): move data in buffer if it is required to store the
+	  argument.
+
 Thu Jan  3 21:56:07 2008  Tanaka Akira  <akr@f...>
 
 	* include/ruby/ruby.h (st_strcasecmp): declared for STRCASECMP.
Index: io.c
===================================================================
--- io.c	(revision 14872)
+++ io.c	(revision 14873)
@@ -320,9 +320,15 @@
 	    fptr->rbuf_capa = 8192;
         fptr->rbuf = ALLOC_N(char, fptr->rbuf_capa);
     }
-    if (fptr->rbuf_off < len) {
+    if (fptr->rbuf_capa < len + fptr->rbuf_len) {
 	rb_raise(rb_eIOError, "ungetc failed");
     }
+    if (fptr->rbuf_off < len) {
+        MEMMOVE(fptr->rbuf+fptr->rbuf_capa-fptr->rbuf_len,
+                fptr->rbuf+fptr->rbuf_off,
+                char, fptr->rbuf_len);
+        fptr->rbuf_off = fptr->rbuf_capa-fptr->rbuf_len;
+    }
     fptr->rbuf_off-=len;
     fptr->rbuf_len+=len;
     MEMMOVE(fptr->rbuf+fptr->rbuf_off, RSTRING_PTR(str), char, len);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]