Skip to content

Commit

Permalink
Fix embedded document with unterminated terminator
Browse files Browse the repository at this point in the history
`skips()` is `mrb_bool` function, should return `FALSE` at EOF, not
`EOF`.
  • Loading branch information
nobu committed Apr 23, 2017
1 parent 809b7ca commit d54f9f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions mrbgems/mruby-compiler/bintest/mrbc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@
assert_equal "#{cmd('mrbc')}:#{a.path}:Syntax OK", result.chomp
assert_equal 0, $?.exitstatus
end

assert('embedded document with invalid terminator') do
a, out = Tempfile.new('a.rb'), Tempfile.new('out.mrb')
a.write("=begin\n=endx\n")
a.flush
result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} 2>&1`
assert_equal "#{a.path}:3:0: embedded document meets end of file", result.chomp
assert_equal 1, $?.exitstatus
end
2 changes: 1 addition & 1 deletion mrbgems/mruby-compiler/core/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -3580,7 +3580,7 @@ skips(parser_state *p, const char *s)
/* skip until first char */
for (;;) {
c = nextc(p);
if (c < 0) return c;
if (c < 0) return FALSE;
if (c == '\n') {
p->lineno++;
p->column = 0;
Expand Down

0 comments on commit d54f9f8

Please sign in to comment.