From 9b0f8ddc5c46cb59c8ee67ec483db29199d1d46c Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Wed, 24 Nov 1999 07:22:11 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'ruby_1_4_3_pre1'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/ruby_1_4_3_pre1@567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/nkf/nkf.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'ext/nkf/nkf.c') diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c index 80d0d2e4be..b59688cb03 100644 --- a/ext/nkf/nkf.c +++ b/ext/nkf/nkf.c @@ -31,14 +31,12 @@ rb_nkf_putchar(c) { if (output_ctr >= o_len) { o_len += incsize; - rb_str_cat(dst, "", incsize); + rb_str_cat(dst, 0, incsize); + output = RSTRING(dst)->ptr; incsize *= 2; } - output[output_ctr++] = c; -/* -printf("[[%c][%c][%d]]\n", c, output[output_ctr - 1], output_ctr); -*/ + return c; } @@ -51,6 +49,7 @@ rb_nkf_kconv(obj, opt, src) { int i; char *opt_ptr, *opt_end; + volatile VALUE v; reinit(); opt_ptr = str2cstr(opt, &i); @@ -66,7 +65,8 @@ rb_nkf_kconv(obj, opt, src) input_ctr = 0; input = str2cstr(src, &i_len); - dst = rb_str_new(0, i_len*3 + 10); /* large enough? */ + dst = rb_str_new(0, i_len*3 + 10); + v = dst; output_ctr = 0; output = RSTRING(dst)->ptr; @@ -78,18 +78,8 @@ rb_nkf_kconv(obj, opt, src) } kanji_convert(NULL); - if (output_ctr > 0) output_ctr--; - if (output[output_ctr] == '\0') { -/* -printf("([%c][%d])\n", output[output_ctr], output_ctr); -*/ - RSTRING(dst)->len = output_ctr; - } else { -/* -printf("<[%c][%d]>\n", output[output_ctr], output_ctr); -*/ - RSTRING(dst)->len = output_ctr + 1; - } + RSTRING(dst)->ptr[output_ctr] = '\0'; + RSTRING(dst)->len = output_ctr; return dst; } -- cgit v1.2.3