1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
duerst 2011-11-30 11:03:22 +00:00
parent 1d234a1614
commit ed73a902b8
2 changed files with 18 additions and 27 deletions

View file

@ -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> 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 * lib/mkmf.rb: Use MakeMakefile's rm_f to avoid conflict with Rake or

View file

@ -1936,13 +1936,8 @@ rb_econv_decorate_at_last(rb_econv_t *ec, const char *decorator_name)
void void
rb_econv_binmode(rb_econv_t *ec) 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; const char *dname = 0;
n = 0;
switch (ec->flags & ECONV_NEWLINE_DECORATOR_MASK) { switch (ec->flags & ECONV_NEWLINE_DECORATOR_MASK) {
case ECONV_UNIVERSAL_NEWLINE_DECORATOR: case ECONV_UNIVERSAL_NEWLINE_DECORATOR:
dname = "universal_newline"; dname = "universal_newline";
@ -1954,32 +1949,24 @@ rb_econv_binmode(rb_econv_t *ec)
dname = "cr_newline"; dname = "cr_newline";
break; break;
} }
if (dname) {
entry = get_transcoder_entry("", dname);
if (entry->transcoder)
trs[n++] = entry->transcoder;
}
num_trans = ec->num_trans; if (dname) {
j = 0; const rb_transcoder *transcoder = get_transcoder_entry("", dname)->transcoder;
for (i = 0; i < num_trans; i++) { int num_trans = ec->num_trans;
int k; int i, j = 0;
for (k = 0; k < n; k++)
if (trs[k] == ec->elems[i].tc->transcoder) for (i=0; i < num_trans; i++) {
break; if (transcoder == ec->elems[i].tc->transcoder) {
if (k == n) { rb_transcoding_close(ec->elems[i].tc);
ec->elems[j] = ec->elems[i]; xfree(ec->elems[i].out_buf_start);
j++; ec->num_trans--;
} }
else { else
rb_transcoding_close(ec->elems[i].tc); ec->elems[j++] = ec->elems[i];
xfree(ec->elems[i].out_buf_start); }
ec->num_trans--;
}
} }
ec->flags &= ~ECONV_NEWLINE_DECORATOR_MASK; ec->flags &= ~ECONV_NEWLINE_DECORATOR_MASK;
} }
static VALUE static VALUE