зеркало из https://github.com/github/ruby.git
* include/ruby/io.h (rb_io_t): rename field: writeconv_stateless to
writeconv_asciicompat. * io.c: follow the renaming. * gc.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
dda64cab99
Коммит
baac56be36
|
@ -1,3 +1,12 @@
|
|||
Wed Sep 10 00:01:36 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* include/ruby/io.h (rb_io_t): rename field: writeconv_stateless to
|
||||
writeconv_asciicompat.
|
||||
|
||||
* io.c: follow the renaming.
|
||||
|
||||
* gc.c: ditto.
|
||||
|
||||
Tue Sep 9 23:55:26 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (io_fwrite): raise an error if ASCII incompatible string
|
||||
|
|
2
gc.c
2
gc.c
|
@ -1510,7 +1510,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev)
|
|||
if (obj->as.file.fptr) {
|
||||
gc_mark(objspace, obj->as.file.fptr->pathv, lev);
|
||||
gc_mark(objspace, obj->as.file.fptr->tied_io_for_writing, lev);
|
||||
gc_mark(objspace, obj->as.file.fptr->writeconv_stateless, lev);
|
||||
gc_mark(objspace, obj->as.file.fptr->writeconv_asciicompat, lev);
|
||||
gc_mark(objspace, obj->as.file.fptr->writeconv_pre_ecopts, lev);
|
||||
gc_mark(objspace, obj->as.file.fptr->encs.ecopts, lev);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ typedef struct rb_io_t {
|
|||
int cbuf_capa;
|
||||
|
||||
rb_econv_t *writeconv;
|
||||
VALUE writeconv_stateless;
|
||||
VALUE writeconv_asciicompat;
|
||||
int writeconv_pre_ecflags;
|
||||
VALUE writeconv_pre_ecopts;
|
||||
int writeconv_initialized;
|
||||
|
@ -124,7 +124,7 @@ typedef struct rb_io_t {
|
|||
fp->cbuf_len = 0;\
|
||||
fp->cbuf_capa = 0;\
|
||||
fp->writeconv = NULL;\
|
||||
fp->writeconv_stateless = Qnil;\
|
||||
fp->writeconv_asciicompat = Qnil;\
|
||||
fp->writeconv_pre_ecflags = 0;\
|
||||
fp->writeconv_pre_ecopts = Qnil;\
|
||||
fp->writeconv_initialized = 0;\
|
||||
|
|
12
io.c
12
io.c
|
@ -709,7 +709,7 @@ make_writeconv(rb_io_t *fptr)
|
|||
fptr->writeconv = rb_econv_open_opts("", "", ecflags, ecopts);
|
||||
if (!fptr->writeconv)
|
||||
rb_exc_raise(rb_econv_open_exc("", "", ecflags));
|
||||
fptr->writeconv_stateless = Qnil;
|
||||
fptr->writeconv_asciicompat = Qnil;
|
||||
}
|
||||
else {
|
||||
enc = fptr->encs.enc2 ? fptr->encs.enc2 : fptr->encs.enc;
|
||||
|
@ -719,7 +719,7 @@ make_writeconv(rb_io_t *fptr)
|
|||
fptr->writeconv_pre_ecflags = ecflags;
|
||||
fptr->writeconv_pre_ecopts = ecopts;
|
||||
fptr->writeconv = NULL;
|
||||
fptr->writeconv_stateless = Qnil;
|
||||
fptr->writeconv_asciicompat = Qnil;
|
||||
}
|
||||
else {
|
||||
/* double conversion */
|
||||
|
@ -727,11 +727,11 @@ make_writeconv(rb_io_t *fptr)
|
|||
fptr->writeconv_pre_ecopts = ecopts;
|
||||
if (senc) {
|
||||
denc = enc->name;
|
||||
fptr->writeconv_stateless = rb_str_new2(senc);
|
||||
fptr->writeconv_asciicompat = rb_str_new2(senc);
|
||||
}
|
||||
else {
|
||||
senc = denc = "";
|
||||
fptr->writeconv_stateless = rb_str_new2(enc->name);
|
||||
fptr->writeconv_asciicompat = rb_str_new2(enc->name);
|
||||
}
|
||||
ecflags = fptr->encs.ecflags & (ECONV_ERROR_HANDLER_MASK|ECONV_STATEFUL_DECORATOR_MASK);
|
||||
ecopts = fptr->encs.ecopts;
|
||||
|
@ -754,8 +754,8 @@ io_fwrite(VALUE str, rb_io_t *fptr)
|
|||
make_writeconv(fptr);
|
||||
|
||||
if (fptr->writeconv) {
|
||||
if (!NIL_P(fptr->writeconv_stateless))
|
||||
common_encoding = fptr->writeconv_stateless;
|
||||
if (!NIL_P(fptr->writeconv_asciicompat))
|
||||
common_encoding = fptr->writeconv_asciicompat;
|
||||
else if (!rb_enc_asciicompat(rb_enc_get(str))) {
|
||||
rb_raise(rb_eArgError, "ASCII incompatible string written for text mode IO without encoding conversion: %s",
|
||||
rb_enc_name(rb_enc_get(str)));
|
||||
|
|
Загрузка…
Ссылка в новой задаче