summaryrefslogtreecommitdiff
path: root/include/ruby
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-18 12:06:42 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-18 12:06:42 +0000
commit035d4816c3782eca70464fa553b968dc46adee53 (patch)
tree6d4afdf333976a87b4f0de7ef667c8e4603277f9 /include/ruby
parent89b4f06a596e993a82630913f085a82265cb499c (diff)
* include/ruby/io.h (rb_io_t): new fields: writeconv,
writeconv_stateless and writeconv_initialized. (MakeOpenFile): initialize them. * include/ruby/encoding.h (rb_econv_stateless_encoding): declared. (rb_econv_string): declared. * io.c (make_writeconv): new function. (io_fwrite): use econv. (make_readconv): fix error message. (finish_writeconv): new function. (fptr_finalize): call finish_writeconv. (clear_writeconv): new function. (clear_codeconv): new function to call both clear_readconv and clear_writeconv. (rb_io_fptr_finalize): call clear_codeconv instead of clear_readconv. (mode_enc): ditto. (io_set_encoding): ditto. (argf_next_argv): ditto. (io_encoding_set): ditto. * gc.c (gc_mark_children): mark writeconv_stateless in T_FILE. * transcode.c (stateless_encoding_i): new function. (rb_econv_stateless_encoding): ditto. (rb_econv_string): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby')
-rw-r--r--include/ruby/encoding.h5
-rw-r--r--include/ruby/io.h8
2 files changed, 13 insertions, 0 deletions
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index c859c50559..6c443d6f0d 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -268,6 +268,11 @@ void rb_econv_check_error(rb_econv_t *ec);
int rb_econv_putbackable(rb_econv_t *ec);
void rb_econv_putback(rb_econv_t *ec, unsigned char *p, int n);
+/* returns corresponding stateless encoding, or NULL if not stateful. */
+const char *rb_econv_stateless_encoding(const char *stateful_enc);
+
+VALUE rb_econv_string(rb_econv_t *ec, VALUE src, long off, long len, VALUE dst, int flags);
+
/* flags for rb_econv_open */
#define ECONV_UNIVERSAL_NEWLINE_DECODER 0x100
#define ECONV_CRLF_NEWLINE_ENCODER 0x200
diff --git a/include/ruby/io.h b/include/ruby/io.h
index 2a2b991a6d..32830aaaea 100644
--- a/include/ruby/io.h
+++ b/include/ruby/io.h
@@ -63,6 +63,11 @@ typedef struct rb_io_t {
int crbuf_off;
int crbuf_len;
int crbuf_capa;
+
+ rb_econv_t *writeconv;
+ VALUE writeconv_stateless;
+ int writeconv_initialized;
+
} rb_io_t;
#define HAVE_RB_IO_T 1
@@ -110,6 +115,9 @@ typedef struct rb_io_t {
fp->crbuf_off = 0;\
fp->crbuf_len = 0;\
fp->crbuf_capa = 0;\
+ fp->writeconv = NULL;\
+ fp->writeconv_stateless = Qnil;\
+ fp->writeconv_initialized = 0;\
fp->tied_io_for_writing = 0;\
fp->enc = 0;\
fp->enc2 = 0;\