summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-29 14:38:44 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-29 14:38:44 +0000
commit33d5fdaa6a219b9b8dd9757936397eb3a4ef926c (patch)
treeabd38e3e99366b296bd3eac1fef12638d9ab20f0 /io.c
parent31da2859fa83077e3a6eb732e11bfdf977b89900 (diff)
downloadruby-33d5fdaa6a219b9b8dd9757936397eb3a4ef926c.tar.gz
ruby-33d5fdaa6a219b9b8dd9757936397eb3a4ef926c.tar.xz
ruby-33d5fdaa6a219b9b8dd9757936397eb3a4ef926c.zip
* io.c (io_ungetc): raise NotImplementedError when ungetc is called
against dummy encoding IO. * io.c (rb_io_getline_1): ditto when gets with delimiter is called. * io.c (io_getc): ditto when getc is called. * test/ruby/test_io_m17n.rb (test_terminator_stateful_conversion, test_getc_stateful_conversion, test_ungetc_stateful_conversion): these tests should raise NotImplementedError. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/io.c b/io.c
index 52216cff4..72db53787 100644
--- a/io.c
+++ b/io.c
@@ -323,11 +323,17 @@ io_unread(rb_io_t *fptr)
return;
}
+static rb_encoding *io_input_encoding(rb_io_t *fptr);
+
static void
io_ungetc(VALUE str, rb_io_t *fptr)
{
int len = RSTRING_LEN(str);
+ if (rb_enc_dummy_p(io_input_encoding(fptr))) {
+ rb_raise(rb_eNotImpError, "ungetc against dummy encoding is not currently supported");
+ }
+
if (fptr->rbuf == NULL) {
fptr->rbuf_off = 0;
fptr->rbuf_len = 0;
@@ -1950,6 +1956,9 @@ rb_io_getline_1(VALUE rs, long limit, VALUE io)
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
+ if (rb_enc_dummy_p(io_input_encoding(fptr)) && rs != rb_default_rs) {
+ rb_raise(rb_eNotImpError, "gets with delimiter against dummy encoding is not currently supported");
+ }
if (NIL_P(rs)) {
str = read_all(fptr, 0, Qnil);
if (RSTRING_LEN(str) == 0) return Qnil;
@@ -2265,6 +2274,10 @@ io_getc(rb_io_t *fptr, rb_encoding *enc)
int r, n, cr = 0;
VALUE str;
+ if (rb_enc_dummy_p(enc)) {
+ rb_raise(rb_eNotImpError, "getc against dummy encoding is not currently supported");
+ }
+
if (io_fillbuf(fptr) < 0) {
return Qnil;
}