ruby-changes:7333
From: akr <ko1@a...>
Date: Tue, 26 Aug 2008 00:58:51 +0900 (JST)
Subject: [ruby-changes:7333] Ruby:r18852 (trunk): * transcode.c (str_transcode0): don't short cut for newline conversion.
akr 2008-08-26 00:58:35 +0900 (Tue, 26 Aug 2008) New Revision: 18852 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18852 Log: * transcode.c (str_transcode0): don't short cut for newline conversion. Modified files: trunk/ChangeLog trunk/transcode.c Index: ChangeLog =================================================================== --- ChangeLog (revision 18851) +++ ChangeLog (revision 18852) @@ -1,3 +1,7 @@ +Tue Aug 26 00:55:46 2008 Tanaka Akira <akr@f...> + + * transcode.c (str_transcode0): don't short cut for newline conversion. + Tue Aug 26 00:36:01 2008 Tanaka Akira <akr@f...> * io.c (io_fwrite): add TEXTMODE_NEWLINE_ENCODER to option for Index: transcode.c =================================================================== --- transcode.c (revision 18851) +++ transcode.c (revision 18852) @@ -1878,17 +1878,29 @@ to_encidx = str_transcode_enc_args(str, argv[0], argc==1 ? Qnil : argv[1], &from_e, &from_enc, &to_e, &to_enc); - if (from_enc && from_enc == to_enc) { - return -1; + if ((ecopts->flags & (ECONV_UNIVERSAL_NEWLINE_DECODER| + ECONV_CRLF_NEWLINE_ENCODER| + ECONV_CR_NEWLINE_ENCODER)) == 0) { + if (from_enc && from_enc == to_enc) { + return -1; + } + if (from_enc && to_enc && rb_enc_asciicompat(from_enc) && rb_enc_asciicompat(to_enc)) { + if (ENC_CODERANGE(str) == ENC_CODERANGE_7BIT) { + return to_encidx; + } + } + if (encoding_equal(from_e, to_e)) { + return -1; + } } - if (from_enc && to_enc && rb_enc_asciicompat(from_enc) && rb_enc_asciicompat(to_enc)) { - if (ENC_CODERANGE(str) == ENC_CODERANGE_7BIT) { - return to_encidx; - } + else { + if (encoding_equal(from_e, to_e)) { + /* newline conversion only. + * xxx: this assumes ascii compatible encoding. */ + from_e = ""; + to_e = ""; + } } - if (encoding_equal(from_e, to_e)) { - return -1; - } fromp = sp = (unsigned char *)RSTRING_PTR(str); slen = RSTRING_LEN(str); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/