From c1b29ff5c6db8dd9a4d3508896eb3856eb9974da Mon Sep 17 00:00:00 2001 From: tenderlove Date: Wed, 19 May 2010 03:24:13 +0000 Subject: * ext/psych/lib/psych.rb: Adding Psych::Exception * ext/psych/parser.c: Do not allow extern_encoding to be set twice * test/psych/test_parser.rb: test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/psych/parser.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ext/psych/parser.c') diff --git a/ext/psych/parser.c b/ext/psych/parser.c index 41260ab6f5..c8b92a0fcd 100644 --- a/ext/psych/parser.c +++ b/ext/psych/parser.c @@ -293,8 +293,15 @@ static VALUE parse(VALUE self, VALUE yaml) static VALUE set_external_encoding(VALUE self, VALUE encoding) { yaml_parser_t * parser; + VALUE exception; Data_Get_Struct(self, yaml_parser_t, parser); + + if(parser->encoding) { + exception = rb_const_get_at(mPsych, rb_intern("Exception")); + rb_raise(exception, "don't set the encoding twice!"); + } + yaml_parser_set_encoding(parser, NUM2INT(encoding)); return encoding; -- cgit v1.2.3