ruby-changes:7304
From: akr <ko1@a...>
Date: Sun, 24 Aug 2008 19:49:50 +0900 (JST)
Subject: [ruby-changes:7304] Ruby:r18823 (trunk): * include/ruby/encoding.h (rb_econv_t): use rb_econv_option_t.
akr 2008-08-24 19:49:36 +0900 (Sun, 24 Aug 2008) New Revision: 18823 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18823 Log: * include/ruby/encoding.h (rb_econv_t): use rb_econv_option_t. * transcode.c: follow the rb_econv_t change. Modified files: trunk/ChangeLog trunk/include/ruby/encoding.h trunk/transcode.c Index: include/ruby/encoding.h =================================================================== --- include/ruby/encoding.h (revision 18822) +++ include/ruby/encoding.h (revision 18823) @@ -216,6 +216,11 @@ typedef struct { int flags; + /* replacement character, etc. */ +} rb_econv_option_t; + +typedef struct { + rb_econv_option_t opts; const char *source_encoding_name; const char *destination_encoding_name; @@ -247,11 +252,6 @@ rb_encoding *destination_encoding; } rb_econv_t; -typedef struct { - int flags; - /* replacement character, etc. */ -} rb_econv_option_t; - VALUE rb_str_transcode(VALUE str, VALUE to, rb_econv_option_t *ecopts); void rb_econv_opts(VALUE hash, rb_econv_option_t *opts); Index: ChangeLog =================================================================== --- ChangeLog (revision 18822) +++ ChangeLog (revision 18823) @@ -1,3 +1,9 @@ +Sun Aug 24 19:48:46 2008 Tanaka Akira <akr@f...> + + * include/ruby/encoding.h (rb_econv_t): use rb_econv_option_t. + + * transcode.c: follow the rb_econv_t change. + Sun Aug 24 19:40:13 2008 Tanaka Akira <akr@f...> * io.c (rb_io_init_copy): copy encs. Index: transcode.c =================================================================== --- transcode.c (revision 18822) +++ transcode.c (revision 18823) @@ -677,7 +677,7 @@ } ec = ALLOC(rb_econv_t); - ec->flags = 0; + ec->opts.flags = 0; ec->source_encoding_name = NULL; ec->destination_encoding_name = NULL; ec->in_buf_start = NULL; @@ -783,7 +783,10 @@ if (!ec) return NULL; - ec->flags = flags; + if (!opts) + ec->opts.flags = 0; + else + ec->opts = *opts; ec->source_encoding_name = from; ec->destination_encoding_name = to; @@ -1065,10 +1068,10 @@ if (ret == econv_invalid_byte_sequence) { /* deal with invalid byte sequence */ /* todo: add more alternative behaviors */ - if (ec->flags&ECONV_INVALID_IGNORE) { + if (ec->opts.flags&ECONV_INVALID_IGNORE) { goto resume; } - else if (ec->flags&ECONV_INVALID_REPLACE) { + else if (ec->opts.flags&ECONV_INVALID_REPLACE) { if (output_replacement_character(ec) == 0) goto resume; } @@ -1078,10 +1081,10 @@ /* valid character in source encoding * but no related character(s) in destination encoding */ /* todo: add more alternative behaviors */ - if (ec->flags&ECONV_UNDEF_IGNORE) { + if (ec->opts.flags&ECONV_UNDEF_IGNORE) { goto resume; } - else if (ec->flags&ECONV_UNDEF_REPLACE) { + else if (ec->opts.flags&ECONV_UNDEF_REPLACE) { if (output_replacement_character(ec) == 0) goto resume; } @@ -1391,7 +1394,7 @@ void rb_econv_binmode(rb_econv_t *ec) { - if (ec->flags & ECONV_UNIVERSAL_NEWLINE_DECODER) { + if (ec->opts.flags & ECONV_UNIVERSAL_NEWLINE_DECODER) { int i = ec->num_trans-1; rb_transcoding_close(ec->elems[i].tc); xfree(ec->elems[i].out_buf_start); @@ -1402,7 +1405,7 @@ ec->elems[i].out_buf_end = NULL; ec->num_trans--; } - if (ec->flags & (ECONV_CRLF_NEWLINE_ENCODER|ECONV_CR_NEWLINE_ENCODER)) { + if (ec->opts.flags & (ECONV_CRLF_NEWLINE_ENCODER|ECONV_CR_NEWLINE_ENCODER)) { rb_transcoding_close(ec->elems[0].tc); xfree(ec->elems[0].out_buf_start); MEMMOVE(&ec->elems[0], &ec->elems[1], rb_econv_elem_t, ec->num_trans-1); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/