ruby-changes:4998
From: ko1@a...
Date: Tue, 20 May 2008 13:21:14 +0900 (JST)
Subject: [ruby-changes:4998] nobu - Ruby:r16491 (trunk): * ext/nkf/nkf.c (rb_nkf_convert), ext/nkf/nkf-utf8/nkf.c
nobu 2008-05-20 13:20:53 +0900 (Tue, 20 May 2008) New Revision: 16491 Modified files: trunk/ChangeLog trunk/ext/nkf/nkf-utf8/nkf.c trunk/ext/nkf/nkf.c Log: * ext/nkf/nkf.c (rb_nkf_convert), ext/nkf/nkf-utf8/nkf.c (nkf_enc_without_bom): BOM is not a part of encodings. * ext/nkf/nkf.c (Init_nkf), ext/nkf/nkf-utf8/nkf.c (options): UTF-{16,32} without endian have no sense. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16491&r2=16490&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/nkf/nkf.c?r1=16491&r2=16490&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/nkf/nkf-utf8/nkf.c?r1=16491&r2=16490&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 16490) +++ ChangeLog (revision 16491) @@ -1,33 +1,11 @@ -Tue May 20 12:13:50 2008 Nobuyoshi Nakada <nobu@r...> +Tue May 20 13:20:51 2008 Nobuyoshi Nakada <nobu@r...> - * ruby.c (proc_options, process_options): --dump option. + * ext/nkf/nkf.c (rb_nkf_convert), ext/nkf/nkf-utf8/nkf.c + (nkf_enc_without_bom): BOM is not a part of encodings. -Tue May 20 11:36:06 2008 Nobuyoshi Nakada <nobu@r...> + * ext/nkf/nkf.c (Init_nkf), ext/nkf/nkf-utf8/nkf.c (options): + UTF-{16,32} without endian have no sense. - * include/ruby/ruby.h (PRI[diouxX]VALUE): printf format for VALUE. - - * gc.c (assign_heap_slot): suppress a warning. - -Tue May 20 03:42:43 2008 Koichi Sasada <ko1@a...> - - * eval.c, vm_insnhelper.c: fix cref in instance_eval - and cvar_base search protocol. - - * bootstraptest/test_knownbug.rb, test_eval.rb: move soleved test - and add new tests. - - * test/ruby/test_eval.rb: fix tests for spec. - -Tue May 20 01:43:44 2008 Koichi Sasada <ko1@a...> - - * bootstraptest/test_knownbug.rb: fix a test. - "block_given?" returns true if "yield" can be used. - -Tue May 20 01:07:19 2008 Yusuke Endoh <mame@t...> - - * parse.y (assignable_gen): when "self = 1" was evalueted, unnecessary - error message was output, which might cause null pointer access. - Mon May 19 23:32:12 2008 Koichi Sasada <ko1@a...> * vm.c (invoke_block_from_c): fix call flow. Index: ext/nkf/nkf.c =================================================================== --- ext/nkf/nkf.c (revision 16490) +++ ext/nkf/nkf.c (revision 16491) @@ -160,7 +160,7 @@ rb_str_set_len(result, output_ctr); OBJ_INFECT(result, src); - rb_enc_associate(result, rb_nkf_enc_get(nkf_enc_name(output_encoding))); + rb_enc_associate(result, rb_nkf_enc_get(nkf_enc_name(nkf_enc_without_bom(output_encoding)))); return result; } @@ -480,8 +480,8 @@ rb_define_const(mNKF, "EUC", rb_enc_from_encoding(rb_nkf_enc_get("EUC-JP"))); rb_define_const(mNKF, "SJIS", rb_enc_from_encoding(rb_nkf_enc_get("Shift_JIS"))); rb_define_const(mNKF, "UTF8", rb_enc_from_encoding(rb_utf8_encoding())); - rb_define_const(mNKF, "UTF16", rb_enc_from_encoding(rb_nkf_enc_get("UTF-16"))); - rb_define_const(mNKF, "UTF32", rb_enc_from_encoding(rb_nkf_enc_get("UTF-32"))); + rb_define_const(mNKF, "UTF16", rb_enc_from_encoding(rb_nkf_enc_get("UTF-16BE"))); + rb_define_const(mNKF, "UTF32", rb_enc_from_encoding(rb_nkf_enc_get("UTF-32BE"))); /* Full version string of nkf */ rb_define_const(mNKF, "VERSION", rb_str_new2(RUBY_NKF_VERSION)); Index: ext/nkf/nkf-utf8/nkf.c =================================================================== --- ext/nkf/nkf-utf8/nkf.c (revision 16490) +++ ext/nkf/nkf-utf8/nkf.c (revision 16491) @@ -693,6 +693,20 @@ return index; } +static nkf_encoding *nkf_enc_without_bom(nkf_encoding *enc) +{ + int idx; + switch (enc->id) { + case UTF_8_BOM: idx = UTF_8; break; + case UTF_16BE_BOM: idx = UTF_16BE; break; + case UTF_16LE_BOM: idx = UTF_16LE; break; + case UTF_32BE_BOM: idx = UTF_32BE; break; + case UTF_32LE_BOM: idx = UTF_32LE; break; + default: return enc; + } + return &nkf_encoding_table[idx]; +} + static nkf_encoding *nkf_enc_find(const char *name) { int idx = -1; @@ -5897,8 +5911,7 @@ } else if (cp[0] == 'B') { cp++; } else { - output_encoding = nkf_enc_from_index(enc_idx); - continue; + goto utf_no_endian; } if (cp[0] == '0'){ cp++; @@ -5907,6 +5920,7 @@ : (output_endian == ENDIAN_LITTLE ? UTF_32LE : UTF_32BE); } else { output_bom_f = TRUE; + utf_no_endian: enc_idx = enc_idx == UTF_16 ? (output_endian == ENDIAN_LITTLE ? UTF_16LE_BOM : UTF_16BE_BOM) : (output_endian == ENDIAN_LITTLE ? UTF_32LE_BOM : UTF_32BE_BOM); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/