summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md54
-rw-r--r--mrbgems/mruby-bin-mruby/bintest/mruby.rb20
-rw-r--r--mrbgems/mruby-bin-strip/bintest/mruby-strip.rb32
-rw-r--r--mrbgems/mruby-compiler/bintest/mrbc.rb4
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c20
-rw-r--r--mrbgems/mruby-compiler/core/parse.y22
-rw-r--r--test/bintest.rb8
7 files changed, 79 insertions, 81 deletions
diff --git a/README.md b/README.md
index 9c3ccd466..e5ddfab2c 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
[![Build Status][build-status-img]][travis-ci]
-## What's mruby
+## What is mruby
mruby is the lightweight implementation of the Ruby language complying to (part
-of) the [ISO standard][ISO-standard]. Its syntax is Ruby 1.9 compatible.
+of) the [ISO standard][ISO-standard]. Its syntax is Ruby 1.9 compatible.
mruby can be linked and embedded within your application. We provide the
interpreter program "mruby" and the interactive mruby shell "mirb" as examples.
@@ -15,40 +15,29 @@ program under the "test" directory for an example.
This achievement was sponsored by the Regional Innovation Creation R&D Programs
of the Ministry of Economy, Trade and Industry of Japan.
-
## How to get mruby
-The stable version 1.1.0 of mruby can be downloaded via the following URL:
-
- https://github.com/mruby/mruby/archive/1.1.0.zip
+The stable version 1.1.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/1.1.0.zip](https://github.com/mruby/mruby/archive/1.1.0.zip)
-The latest development version of mruby can be downloaded via the following URL:
-
- https://github.com/mruby/mruby/zipball/master
+The latest development version of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/zipball/master](https://github.com/mruby/mruby/zipball/master)
The trunk of the mruby source tree can be checked out with the
following command:
$ git clone https://github.com/mruby/mruby.git
-
## mruby home-page
-The URL of the mruby home-page is:
-
- http://www.mruby.org/
-
+The URL of the mruby home-page is: [http://www.mruby.org](http://www.mruby.org).
## Mailing list
-We don't have mailing list, use GitHub forum <http://github.com/mruby/mruby>.
-
+We don't have mailing list, but you can use [GitHub issues](https://github.com/mruby/mruby).
## How to compile and install (mruby and gems)
See the [doc/compile/README.md](doc/compile/README.md) file.
-
## Running Tests
To run the tests, execute the following from the project's root directory.
@@ -59,7 +48,6 @@ Or
$ ruby ./minirake test
-
## How to customize mruby (mrbgems)
mruby contains a package manager called *mrbgems*. To create extensions
@@ -67,29 +55,9 @@ in C and/or Ruby you should create a *GEM*. For a documentation of how to
use mrbgems consult the file [doc/mrbgems/README.md](doc/mrbgems/README.md). For example code of
how to use mrbgems look into the folder *examples/mrbgems/*.
-
## License
-Copyright (c) 2015 mruby developers
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-
+mruby is released under the [MIT License](MITL).
## Note for License
@@ -108,17 +76,15 @@ file.)
Please ask us if you want to distribute your code under another license.
-
## How to Contribute
-See the [contribution guidelines][contribution-guidelines] then send a pull
+See the [contribution guidelines][contribution-guidelines], and then send a pull
request to <http://github.com/mruby/mruby>. We consider you have granted
non-exclusive right to your contributed code under MIT license. If you want to
be named as one of mruby developers, please include an update to the AUTHORS
file in your pull request.
[ISO-standard]: http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
-[build-status-img]: https://travis-ci.org/mruby/mruby.png?branch=master
-[contribution-guidelines]: https://github.com/mruby/mruby/blob/master/CONTRIBUTING.md
+[build-status-img]: https://travis-ci.org/mruby/mruby.svg?branch=master
+[contribution-guidelines]: CONTRIBUTING.md
[travis-ci]: https://travis-ci.org/mruby/mruby
-
diff --git a/mrbgems/mruby-bin-mruby/bintest/mruby.rb b/mrbgems/mruby-bin-mruby/bintest/mruby.rb
index de211c1ba..01fc94632 100644
--- a/mrbgems/mruby-bin-mruby/bintest/mruby.rb
+++ b/mrbgems/mruby-bin-mruby/bintest/mruby.rb
@@ -1,17 +1,17 @@
require 'tempfile'
assert('regression for #1564') do
- o = `bin/mruby -e '<<' 2>&1`
+ o = `#{cmd('mruby')} -e #{shellquote('<<')} 2>&1`
assert_equal o, "-e:1:2: syntax error, unexpected tLSHFT\n"
- o = `bin/mruby -e '<<-' 2>&1`
+ o = `#{cmd('mruby')} -e #{shellquote('<<-')} 2>&1`
assert_equal o, "-e:1:3: syntax error, unexpected tLSHFT\n"
end
assert('regression for #1572') do
script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb')
- system "echo 'p \"ok\"' > #{script.path}"
- system "bin/mrbc -g -o #{bin.path} #{script.path}"
- o = `bin/mruby -b #{bin.path}`.strip
+ File.write script.path, 'p "ok"'
+ system "#{cmd('mrbc')} -g -o #{bin.path} #{script.path}"
+ o = `#{cmd('mruby')} -b #{bin.path}`.strip
assert_equal o, '"ok"'
end
@@ -21,14 +21,14 @@ assert '$0 value' do
# .rb script
script.write "p $0\n"
script.flush
- assert_equal "\"#{script.path}\"", `./bin/mruby "#{script.path}"`.chomp
+ assert_equal "\"#{script.path}\"", `#{cmd('mruby')} "#{script.path}"`.chomp
# .mrb file
- `./bin/mrbc -o "#{bin.path}" "#{script.path}"`
- assert_equal "\"#{bin.path}\"", `./bin/mruby -b "#{bin.path}"`.chomp
+ `#{cmd('mrbc')} -o "#{bin.path}" "#{script.path}"`
+ assert_equal "\"#{bin.path}\"", `#{cmd('mruby')} -b "#{bin.path}"`.chomp
# one liner
- assert_equal '"-e"', `./bin/mruby -e 'p $0'`.chomp
+ assert_equal '"-e"', `#{cmd('mruby')} -e #{shellquote('p $0')}`.chomp
end
assert '__END__', '8.6' do
@@ -42,5 +42,5 @@ __END__
p 'legend'
EOS
script.flush
- assert_equal "\"test\"\n\"fin\"\n", `./bin/mruby #{script.path}`
+ assert_equal "\"test\"\n\"fin\"\n", `#{cmd('mruby')} #{script.path}`
end
diff --git a/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb b/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
index e74a74f10..bb664a2b1 100644
--- a/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
+++ b/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
@@ -1,13 +1,13 @@
require 'tempfile'
assert('no files') do
- o = `bin/mruby-strip 2>&1`
+ o = `#{cmd('mruby-strip')} 2>&1`
assert_equal 1, $?.exitstatus
assert_equal "no files to strip", o.split("\n")[0]
end
assert('file not found') do
- o = `bin/mruby-strip not_found.mrb 2>&1`
+ o = `#{cmd('mruby-strip')} not_found.mrb 2>&1`
assert_equal 1, $?.exitstatus
assert_equal "can't open file for reading not_found.mrb\n", o
end
@@ -16,7 +16,7 @@ assert('not irep file') do
t = Tempfile.new('script.rb')
t.write 'p test\n'
t.flush
- o = `bin/mruby-strip #{t.path} 2>&1`
+ o = `#{cmd('mruby-strip')} #{t.path} 2>&1`
assert_equal 1, $?.exitstatus
assert_equal "can't read irep file #{t.path}\n", o
end
@@ -26,15 +26,15 @@ assert('success') do
Tempfile.new('script.rb'), Tempfile.new('c1.mrb'), Tempfile.new('c2.mrb')
script_file.write "p 'test'\n"
script_file.flush
- `bin/mrbc -g -o #{compiled1.path} #{script_file.path}`
- `bin/mrbc -g -o #{compiled2.path} #{script_file.path}`
+ `#{cmd('mrbc')} -g -o #{compiled1.path} #{script_file.path}`
+ `#{cmd('mrbc')} -g -o #{compiled2.path} #{script_file.path}`
- o = `bin/mruby-strip #{compiled1.path}`
+ o = `#{cmd('mruby-strip')} #{compiled1.path}`
assert_equal 0, $?.exitstatus
assert_equal "", o
- assert_equal `bin/mruby #{script_file.path}`, `bin/mruby -b #{compiled1.path}`
+ assert_equal `#{cmd('mruby')} #{script_file.path}`, `#{cmd('mruby')} -b #{compiled1.path}`
- o = `bin/mruby-strip #{compiled1.path} #{compiled2.path}`
+ o = `#{cmd('mruby-strip')} #{compiled1.path} #{compiled2.path}`
assert_equal 0, $?.exitstatus
assert_equal "", o
end
@@ -44,12 +44,12 @@ assert('check debug section') do
Tempfile.new('script.rb'), Tempfile.new('c1.mrb'), Tempfile.new('c2.mrb')
script_file.write "p 'test'\n"
script_file.flush
- `bin/mrbc -o #{without_debug.path} #{script_file.path}`
- `bin/mrbc -g -o #{with_debug.path} #{script_file.path}`
+ `#{cmd('mrbc')} -o #{without_debug.path} #{script_file.path}`
+ `#{cmd('mrbc')} -g -o #{with_debug.path} #{script_file.path}`
assert_true with_debug.size >= without_debug.size
- `bin/mruby-strip #{with_debug.path}`
+ `#{cmd('mruby-strip')} #{with_debug.path}`
assert_equal without_debug.size, with_debug.size
end
@@ -62,12 +62,12 @@ a += b
p Kernel.local_variables
EOS
script_file.flush
- `bin/mrbc -o #{with_lv.path} #{script_file.path}`
- `bin/mrbc -o #{without_lv.path} #{script_file.path}`
+ `#{cmd('mrbc')} -o #{with_lv.path} #{script_file.path}`
+ `#{cmd('mrbc')} -o #{without_lv.path} #{script_file.path}`
- `bin/mruby-strip -l #{without_lv.path}`
+ `#{cmd('mruby-strip')} -l #{without_lv.path}`
assert_true without_lv.size < with_lv.size
- assert_equal '[:a, :b]', `bin/mruby -b #{with_lv.path}`.chomp
- assert_equal '[]', `bin/mruby -b #{without_lv.path}`.chomp
+ assert_equal '[:a, :b]', `#{cmd('mruby')} -b #{with_lv.path}`.chomp
+ assert_equal '[]', `#{cmd('mruby')} -b #{without_lv.path}`.chomp
end
diff --git a/mrbgems/mruby-compiler/bintest/mrbc.rb b/mrbgems/mruby-compiler/bintest/mrbc.rb
index b016378a1..e4dc6a9a8 100644
--- a/mrbgems/mruby-compiler/bintest/mrbc.rb
+++ b/mrbgems/mruby-compiler/bintest/mrbc.rb
@@ -6,7 +6,7 @@ assert('Compiling multiple files without new line in last line. #2361') do
a.flush
b.write('module B; end')
b.flush
- result = `bin/mrbc -c -o #{out.path} #{a.path} #{b.path} 2>&1`
- assert_equal "bin/mrbc:#{a.path}:Syntax OK", result.chomp
+ result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} #{b.path} 2>&1`
+ assert_equal "#{cmd('mrbc')}:#{a.path}:Syntax OK", result.chomp
assert_equal 0, $?.exitstatus
end
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index 3853814ec..f2bbf3497 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -2216,7 +2216,8 @@ codegen(codegen_scope *s, node *tree, int val)
case NODE_REGX:
if (val) {
char *p1 = (char*)tree->car;
- char *p2 = (char*)tree->cdr;
+ char *p2 = (char*)tree->cdr->car;
+ char *p3 = (char*)tree->cdr->cdr;
int ai = mrb_gc_arena_save(s->mrb);
int sym = new_sym(s, mrb_intern_lit(s->mrb, REGEXP_CLASS));
int off = new_lit(s, mrb_str_new_cstr(s->mrb, p1));
@@ -2226,11 +2227,22 @@ codegen(codegen_scope *s, node *tree, int val)
genop(s, MKOP_ABx(OP_GETMCNST, cursp(), sym));
push();
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
- if (p2) {
+ if (p2 || p3) {
push();
- off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));
- genop(s, MKOP_ABx(OP_STRING, cursp(), off));
+ if (p2) {
+ off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));
+ genop(s, MKOP_ABx(OP_STRING, cursp(), off));
+ } else {
+ genop(s, MKOP_A(OP_LOADNIL, cursp()));
+ }
argc++;
+ if (p3) {
+ push();
+ off = new_lit(s, mrb_str_new(s->mrb, p3, 1));
+ genop(s, MKOP_ABx(OP_STRING, cursp(), off));
+ argc++;
+ pop();
+ }
pop();
}
pop();
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index 097d63ac4..2b0591769 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -761,9 +761,9 @@ new_dsym(parser_state *p, node *a)
/* (:str . (a . a)) */
static node*
-new_regx(parser_state *p, const char *p1, const char* p2)
+new_regx(parser_state *p, const char *p1, const char* p2, const char* p3)
{
- return cons((node*)NODE_REGX, cons((node*)p1, (node*)p2));
+ return cons((node*)NODE_REGX, cons((node*)p1, cons((node*)p2, (node*)p3)));
}
/* (:dregx . a) */
@@ -3986,6 +3986,8 @@ parse_string(parser_state *p)
char *s = strndup(tok(p), toklen(p));
char flags[3];
char *flag = flags;
+ char enc = '\0';
+ char *encp;
char *dup;
newtok(p);
@@ -3994,6 +3996,8 @@ parse_string(parser_state *p)
case 'i': f |= 1; break;
case 'x': f |= 2; break;
case 'm': f |= 4; break;
+ case 'u': f |= 16; break;
+ case 'n': f |= 32; break;
default: tokadd(p, re_opt); break;
}
}
@@ -4009,12 +4013,20 @@ parse_string(parser_state *p)
if (f & 1) *flag++ = 'i';
if (f & 2) *flag++ = 'x';
if (f & 4) *flag++ = 'm';
- dup = strndup(flags, (size_t)(flag - flags));
+ if (f & 16) enc = 'u';
+ if (f & 32) enc = 'n';
}
- else {
+ if (flag > flags) {
+ dup = strndup(flags, (size_t)(flag - flags));
+ } else {
dup = NULL;
}
- yylval.nd = new_regx(p, s, dup);
+ if (enc) {
+ encp = strndup(&enc, 1);
+ } else {
+ encp = NULL;
+ }
+ yylval.nd = new_regx(p, s, dup, encp);
return tREGEXP;
}
diff --git a/test/bintest.rb b/test/bintest.rb
index 49990abb9..e6d122047 100644
--- a/test/bintest.rb
+++ b/test/bintest.rb
@@ -1,6 +1,14 @@
$:.unshift File.dirname(File.dirname(File.expand_path(__FILE__)))
require 'test/assert.rb'
+def cmd(s)
+ ENV['SHELL'] ? "bin/#{s}" : "bin\\#{s}.exe"
+end
+
+def shellquote(s)
+ ENV['SHELL'] ? "'#{s}'" : "\"#{s}\""
+end
+
ARGV.each do |gem|
Dir["#{gem}/bintest/**/*.rb"].each do |file|
load file