summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-02-06 17:13:27 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-02-06 17:13:27 -0800
commit8c60e9fa2a5e4932d8762469000b232d57c696b5 (patch)
tree29ba5ec4de61ecb966f68e11146de6cb6ca266f3 /ext
parente008a513f5e33031c5e9341cb4da09a225693840 (diff)
downloadpsych-8c60e9fa2a5e4932d8762469000b232d57c696b5.tar.gz
merging from ruby
Diffstat (limited to 'ext')
-rw-r--r--ext/psych/parser.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/ext/psych/parser.c b/ext/psych/parser.c
index 071b8c0..7bfdf4a 100644
--- a/ext/psych/parser.c
+++ b/ext/psych/parser.c
@@ -4,6 +4,7 @@ VALUE cPsychParser;
VALUE ePsychSyntaxError;
static ID id_read;
+static ID id_path;
static ID id_empty;
static ID id_start_stream;
static ID id_end_stream;
@@ -93,10 +94,20 @@ static VALUE parse(VALUE self, VALUE yaml)
while(!done) {
if(!yaml_parser_parse(parser, &event)) {
+ VALUE path;
size_t line = parser->mark.line;
size_t column = parser->mark.column;
- rb_raise(ePsychSyntaxError, "couldn't parse YAML at line %d column %d",
+ if(rb_respond_to(yaml, id_path))
+ path = rb_funcall(yaml, id_path, 0);
+ else
+ path = rb_str_new2("<unknown>");
+
+ yaml_parser_delete(parser);
+ yaml_parser_initialize(parser);
+
+ rb_raise(ePsychSyntaxError, "(%s): couldn't parse YAML at line %d column %d",
+ StringValuePtr(path),
(int)line, (int)column);
}
@@ -357,6 +368,7 @@ void Init_psych_parser()
rb_define_method(cPsychParser, "external_encoding=", set_external_encoding, 1);
id_read = rb_intern("read");
+ id_path = rb_intern("path");
id_empty = rb_intern("empty");
id_start_stream = rb_intern("start_stream");
id_end_stream = rb_intern("end_stream");