summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:58:35 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:58:35 +0000
commita61fab0724399a4e2e2299c8194be83411e10c47 (patch)
treef188729ec5b69037d748051a45c018e62f2adbe8
parente3ded735847fbf7dea2bc2e8a2dff32f7b116b3d (diff)
downloadruby-a61fab0724399a4e2e2299c8194be83411e10c47.tar.gz
ruby-a61fab0724399a4e2e2299c8194be83411e10c47.tar.xz
ruby-a61fab0724399a4e2e2299c8194be83411e10c47.zip
* transcode.c (str_transcode0): don't short cut for newline conversion.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--transcode.c30
2 files changed, 25 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index bc27f8b68..e002fa39f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Aug 26 00:55:46 2008 Tanaka Akira <akr@fsij.org>
+
+ * transcode.c (str_transcode0): don't short cut for newline conversion.
+
Tue Aug 26 00:36:01 2008 Tanaka Akira <akr@fsij.org>
* io.c (io_fwrite): add TEXTMODE_NEWLINE_ENCODER to option for
diff --git a/transcode.c b/transcode.c
index 658a8769b..40db7c71a 100644
--- a/transcode.c
+++ b/transcode.c
@@ -1878,16 +1878,28 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, rb_econv_option_t *ecopts)
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 (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 ((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 (encoding_equal(from_e, to_e)) {
- return -1;
+ else {
+ if (encoding_equal(from_e, to_e)) {
+ /* newline conversion only.
+ * xxx: this assumes ascii compatible encoding. */
+ from_e = "";
+ to_e = "";
+ }
}
fromp = sp = (unsigned char *)RSTRING_PTR(str);