Skip to content

Commit

Permalink
transcode.c: Simplified rb_econv_binmode, avoided a warning on cygwin.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
duerst committed Nov 30, 2011
1 parent 1d234a1 commit ed73a90
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Wed Nov 30 20:02:02 2011 Martin Duerst <duerst@it.aoyama.ac.jp>

* transcode.c: Simplified rb_econv_binmode, avoided a warning on cygwin.

Wed Nov 30 08:57:07 2011 Eric Hodel <drbrain@segment7.net>

* lib/mkmf.rb: Use MakeMakefile's rm_f to avoid conflict with Rake or
Expand Down
41 changes: 14 additions & 27 deletions transcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1936,13 +1936,8 @@ rb_econv_decorate_at_last(rb_econv_t *ec, const char *decorator_name)
void
rb_econv_binmode(rb_econv_t *ec)
{
const rb_transcoder *trs[3];
int n, i, j;
transcoder_entry_t *entry;
int num_trans;
const char *dname = 0;

n = 0;
switch (ec->flags & ECONV_NEWLINE_DECORATOR_MASK) {
case ECONV_UNIVERSAL_NEWLINE_DECORATOR:
dname = "universal_newline";
Expand All @@ -1954,32 +1949,24 @@ rb_econv_binmode(rb_econv_t *ec)
dname = "cr_newline";
break;
}
if (dname) {
entry = get_transcoder_entry("", dname);
if (entry->transcoder)
trs[n++] = entry->transcoder;
}

num_trans = ec->num_trans;
j = 0;
for (i = 0; i < num_trans; i++) {
int k;
for (k = 0; k < n; k++)
if (trs[k] == ec->elems[i].tc->transcoder)
break;
if (k == n) {
ec->elems[j] = ec->elems[i];
j++;
}
else {
rb_transcoding_close(ec->elems[i].tc);
xfree(ec->elems[i].out_buf_start);
ec->num_trans--;
}
if (dname) {
const rb_transcoder *transcoder = get_transcoder_entry("", dname)->transcoder;
int num_trans = ec->num_trans;
int i, j = 0;

for (i=0; i < num_trans; i++) {
if (transcoder == ec->elems[i].tc->transcoder) {
rb_transcoding_close(ec->elems[i].tc);
xfree(ec->elems[i].out_buf_start);
ec->num_trans--;
}
else
ec->elems[j++] = ec->elems[i];
}
}

ec->flags &= ~ECONV_NEWLINE_DECORATOR_MASK;

}

static VALUE
Expand Down

0 comments on commit ed73a90

Please sign in to comment.