From: IWAMURO Motonori Date: 1999-11-19T20:17:01+09:00 Subject: [ruby-dev:8381] Re: [PATCH] use kconv with stream --Multipart_Fri_Nov_19_20:17:04_1999-1 Content-Type: text/plain; charset=ISO-2022-JP 岩室@富士通です。 In message "[ruby-dev:8380] Re: [PATCH] use kconv with stream" on 99/11/19, IWAMURO Motonori writes: > > ・インターフェースは妥当か? (一応これでいいと思ってるんですけれども) > > あ、だめだ、やっぱ使いにくい……(^^; <略> > Kconv::kconv(STRING, OUT_CODE [, IN_CODE [, INCOMP_STRING]]) > > にして、INCOMP_STRINGを不完全文字列で書き換える方がいいでしょうか? ということでこれ(↑)に修正したバージョン。 --Multipart_Fri_Nov_19_20:17:04_1999-1 Content-Type: text/plain; charset=US-ASCII --- nkf.c.ORIG Fri Nov 19 20:12:50 1999 +++ nkf.c Fri Nov 19 20:10:34 1999 @@ -107,4 +107,6 @@ - if (incomp != Qnil && incomp != Qfalse) { + if (TYPE(incomp) == T_STRING) { int offset = INCOMP_OFFSET; + VALUE new_incomp; + if (input_mode == X0201) { @@ -129,4 +131,9 @@ } - return rb_ary_new3(2, dst, rb_str_new(incomp_buf + offset, - incomp_buf_ctr)); + + rb_str_modify(incomp); + if (incomp_buf_ctr != RSTRING(incomp)->len) { + REALLOC_N(RSTRING(incomp)->ptr, char, incomp_buf_ctr + 1); + RSTRING(incomp)->len = incomp_buf_ctr; + } + memcpy(RSTRING(incomp)->ptr, incomp_buf + offset, incomp_buf_ctr); } --Multipart_Fri_Nov_19_20:17:04_1999-1 Content-Type: text/plain; charset=ISO-2022-JP -- 岩室元典 [E-Mail: vmi@kw.netlaputa.ne.jp / iwa@mmp.fujitsu.co.jp] 「おばは〜〜〜ん♪」「おばは〜〜〜ん♪」「おばは〜〜〜ん♪」 「さあみなさんごいっしょに」「「「おばは〜〜〜ん♪」」」 (「マール王国の人形姫」日本一ソフトウェア/PlayStation) --Multipart_Fri_Nov_19_20:17:04_1999-1--