ruby-changes:6958
From: akr <ko1@a...>
Date: Sun, 10 Aug 2008 22:38:14 +0900 (JST)
Subject: [ruby-changes:6958] Ruby:r18476 (trunk): * transcode.c (transcode_restartable0): invalid handling simplified.
akr 2008-08-10 22:37:44 +0900 (Sun, 10 Aug 2008) New Revision: 18476 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18476 Log: * transcode.c (transcode_restartable0): invalid handling simplified. (transcode_restartable): use PARTIAL_INPUT for converting buffered input. Modified files: trunk/ChangeLog trunk/transcode.c Index: ChangeLog =================================================================== --- ChangeLog (revision 18475) +++ ChangeLog (revision 18476) @@ -1,3 +1,9 @@ +Sun Aug 10 22:34:55 2008 Tanaka Akira <akr@f...> + + * transcode.c (transcode_restartable0): invalid handling simplified. + (transcode_restartable): use PARTIAL_INPUT for converting buffered + input. + Sun Aug 10 22:24:24 2008 Yusuke Endoh <mame@t...> * encoding.c: include util.h. [ruby-dev:35715] Index: transcode.c =================================================================== --- transcode.c (revision 18475) +++ transcode.c (revision 18476) @@ -533,40 +533,26 @@ break; } case INVALID: - { - if (tc->readlen + (in_p - inchar_start) <= unitlen) { - while ((opt & PARTIAL_INPUT) && tc->readlen + (in_stop - inchar_start) < unitlen) { - in_p = in_stop; - SUSPEND(transcode_ibuf_empty, 8); - } - if (tc->readlen + (in_stop - inchar_start) <= unitlen) { - in_p = in_stop; - } - else { - in_p = inchar_start + (unitlen - tc->readlen); - } + if (tc->readlen + (in_p - inchar_start) <= unitlen) { + while ((opt & PARTIAL_INPUT) && tc->readlen + (in_stop - inchar_start) < unitlen) { + in_p = in_stop; + SUSPEND(transcode_ibuf_empty, 8); } + if (tc->readlen + (in_stop - inchar_start) <= unitlen) { + in_p = in_stop; + } else { - int found_len; /* including the last byte which cuases invalid */ - int invalid_len; - int step; - found_len = tc->readlen + (in_p - inchar_start); - invalid_len = ((found_len - 1) / unitlen) * unitlen; - step = invalid_len - found_len; - if (step < -1) { - if (-step <= in_p - *in_pos) { - in_p += step; - } - else { - feedlen = -step; - } - } - else { - in_p += step; - } + in_p = inchar_start + (unitlen - tc->readlen); } - goto invalid; } + else { + int invalid_len; /* including the last byte which causes invalid */ + int discard_len; + invalid_len = tc->readlen + (in_p - inchar_start); + discard_len = ((invalid_len - 1) / unitlen) * unitlen; + feedlen = invalid_len - discard_len; + } + goto invalid; case UNDEF: goto undef; } @@ -608,7 +594,7 @@ MEMCPY(feed_buf, TRANSCODING_READBUF(tc) + tc->readlen, unsigned char, tc->feedlen); tc->feedlen = 0; - res = transcode_restartable0(&feed_pos, out_pos, feed_stop, out_stop, tc, opt); + res = transcode_restartable0(&feed_pos, out_pos, feed_stop, out_stop, tc, opt|PARTIAL_INPUT); if (res != transcode_ibuf_empty) { MEMCPY(TRANSCODING_READBUF(tc) + tc->readlen + tc->feedlen, feed_pos, unsigned char, feed_stop - feed_pos); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/