ruby-changes:8462
From: usa <ko1@a...>
Date: Tue, 28 Oct 2008 20:18:46 +0900 (JST)
Subject: [ruby-changes:8462] Ruby:r19994 (trunk): * io.c (make_readconv): now can specify the size of cbuf.
usa 2008-10-28 20:18:28 +0900 (Tue, 28 Oct 2008) New Revision: 19994 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19994 Log: * io.c (make_readconv): now can specify the size of cbuf. * io.c (read_all, appendline, io_getc, rb_io_ungetc): follow above change. Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 19993) +++ ChangeLog (revision 19994) @@ -1,3 +1,10 @@ +Tue Oct 28 20:15:49 2008 NAKAMURA Usaku <usa@r...> + + * io.c (make_readconv): now can specify the size of cbuf. + + * io.c (read_all, appendline, io_getc, rb_io_ungetc): follow above + change. + Tue Oct 28 19:00:51 2008 NAKAMURA Usaku <usa@r...> * win32/win32.c (rb_w32_pipe_exec): internal fds should be always Index: io.c =================================================================== --- io.c (revision 19993) +++ io.c (revision 19994) @@ -1430,7 +1430,7 @@ } static void -make_readconv(rb_io_t *fptr) +make_readconv(rb_io_t *fptr, int size) { if (!fptr->readconv) { int ecflags; @@ -1452,7 +1452,7 @@ rb_exc_raise(rb_econv_open_exc(sname, dname, ecflags)); fptr->cbuf_off = 0; fptr->cbuf_len = 0; - fptr->cbuf_capa = 1024; + fptr->cbuf_capa = size < 1024 ? 1024 : size; fptr->cbuf = ALLOC_N(char, fptr->cbuf_capa); } } @@ -1558,7 +1558,7 @@ if (NEED_READCONV(fptr)) { if (NIL_P(str)) str = rb_str_new(NULL, 0); else rb_str_set_len(str, 0); - make_readconv(fptr); + make_readconv(fptr, 0); while (1) { if (fptr->cbuf_len) { io_shift_cbuf(fptr, fptr->cbuf_len, &str); @@ -1940,7 +1940,7 @@ long limit = *lp; if (NEED_READCONV(fptr)) { - make_readconv(fptr); + make_readconv(fptr, 0); while (1) { const char *p, *e; int searchlen; @@ -2473,7 +2473,7 @@ if (NEED_READCONV(fptr)) { VALUE str = Qnil; - make_readconv(fptr); + make_readconv(fptr, 0); while (1) { if (fptr->cbuf_len) { @@ -2825,8 +2825,8 @@ SafeStringValue(c); } if (NEED_READCONV(fptr)) { - make_readconv(fptr); len = RSTRING_LEN(c); + make_readconv(fptr, len); if (fptr->cbuf_capa - fptr->cbuf_len < len) rb_raise(rb_eIOError, "ungetc failed"); if (fptr->cbuf_off < len) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/