From a045b6b8d93f70d7bf57a94ed5c7e0432190d584 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sat, 21 Nov 2020 10:17:27 +0900 Subject: Allow to mixed and specify `*.rb` and `*.mrb` in `bin/mruby` It is not decides by the extension. In order to be recognized as a `.mrb` file, the following three points must be satisfied: - File starts with "RITE" - At least `sizeof(struct rite_binary_header)` bytes can be read - `NUL` is included in the first 64 bytes of the file If these are not met, it is judged as a text file and it is processed as a Ruby script. The `bin/mruby -b` switch is still available which treats the given file as a `.mrb` file. New `MRB_API` function: - `include/mruby/compile.h` and `mrbgems/mruby-compiler/core/parse.y` - `mrb_load_detect_file_cxt()` (remove with `MRB_DISABLE_STDIO`) NOTE: - Even script files now always open in binary mode for `bin/mruby`. The `\r\n` is handled by the `nextc()` function already, so there is no problem even on Windows. - The `nextc0()` function in `mrbgems/mruby-compiler/core/parse.y` can now specify a string buffer and a file pointer at the same time. In this case, get it from the string buffer first. This patch includes modifies by comment of https://github.com/mruby/mruby/pull/5157. --- mrbgems/mruby-bin-strip/bintest/mruby-strip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mrbgems/mruby-bin-strip') diff --git a/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb b/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb index 2db3c10b1..5330510a1 100644 --- a/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb +++ b/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb @@ -32,7 +32,7 @@ assert('success') do o = `#{cmd('mruby-strip')} #{compiled1.path}` assert_equal 0, $?.exitstatus assert_equal "", o - assert_equal `#{cmd('mruby')} #{script_file.path}`, `#{cmd('mruby')} -b #{compiled1.path}` + assert_equal `#{cmd('mruby')} #{script_file.path}`, `#{cmd('mruby')} #{compiled1.path}` o = `#{cmd('mruby-strip')} #{compiled1.path} #{compiled2.path}` assert_equal 0, $?.exitstatus -- cgit v1.2.3