Compare commits

...

16 Commits

Author SHA1 Message Date
Hiroshi Mimaki 57a56ddaa2 Release mruby 2.1.0. 2019-11-19 18:58:11 +09:00
mimaki a9e27933a9 Fix file/directory name parameter for git command. 2019-10-30 09:32:24 +09:00
Hiroshi Mimaki 4eb8fca140 Merge branch 'master' into stable 2019-10-23 15:44:21 +09:00
Yukihiro "Matz" Matsumoto fa85f91e0e Add type cast to avoid an error from int and enum mixture; fix #4786 2019-10-23 14:47:55 +09:00
Yukihiro "Matz" Matsumoto 9540a8309c Remove unnecessary mrb_funcall(). 2019-10-23 14:47:55 +09:00
Yukihiro "Matz" Matsumoto 11184e9186 Remove unnecessary mrb_string_p() check. 2019-10-23 14:47:55 +09:00
Yukihiro "Matz" Matsumoto 2f0bf1e110 Merge pull request #4785 from shuujii/fix-incorrect-MRB_STR_ASCII-flag-update-in-mrb_str_dump
Fix incorrect `MRB_STR_ASCII` flag update in `mrb_str_dump`
2019-10-23 09:55:47 +09:00
KOBAYASHI Shuji 41c43234a7 Fix incorrect MRB_STR_ASCII flag update in mrb_str_dump
### Example (with `MRB_UTF8_STRING`)

  ```ruby
  s = "\u3042"
  p s.size
  s.dump
  p s.size
  ```

#### Before this patch:

  ```
  1
  3
  ```

#### After this patch:

  ```
  1
  1
  ```
2019-10-22 21:56:40 +09:00
Yukihiro "Matz" Matsumoto 1aacde20fa Merge pull request #4784 from shuujii/remove-Kernel-getc
Remove `Kernel#getc`
2019-10-21 21:27:02 +09:00
KOBAYASHI Shuji 941b99955a Remove Kernel#getc
`Kernel#getc` has been removed since Ruby 1.9 and is not defined in ISO.
2019-10-21 18:50:52 +09:00
Yukihiro "Matz" Matsumoto 0701cc493c Merge pull request #4783 from shuujii/use-mrb_str_cat_str-instead-of-mrb_str_concat-if-possible
Use `mrb_str_cat_str` instead of `mrb_str_concat` if possible
2019-10-20 20:24:10 +09:00
KOBAYASHI Shuji 7047c52d7b Use mrb_str_cat_str instead of mrb_str_concat if possible 2019-10-20 16:26:10 +09:00
Yukihiro "Matz" Matsumoto fddefeb7ee Merge pull request #4781 from shuujii/fix-that-Module-to_s-may-return-frozen-string
Fix that `Module#to_s` may return frozen string; ref 08eafe2
2019-10-19 17:55:26 +09:00
KOBAYASHI Shuji 347729a7c0 Fix that Module#to_s may return frozen string; ref 08eafe2 2019-10-19 17:27:17 +09:00
Yukihiro "Matz" Matsumoto 7957f75bd8 Merge pull request #4779 from take-cheeze/print_mrbc_cmd
Print mrbc command on verbose mode
2019-10-19 11:12:03 +09:00
take-cheeze 4877dbf2a9 Print mrbc command on verbose mode 2019-10-19 01:42:34 +09:00
13 changed files with 59 additions and 42 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ To confirm mrdb was installed properly, run mrdb with the `--version` option:
```bash
$ mrdb --version
mruby 2.1.0 (2019-10-18)
mruby 2.1.0 (2019-11-19)
```
## 2.2 Basic Operation
+9 -9
View File
@@ -38,7 +38,7 @@ puts [1,2,3]
3
```
#### mruby [2.1.0 (2019-10-18)]
#### mruby [2.1.0 (2019-11-19)]
```
[1, 2, 3]
@@ -61,7 +61,7 @@ end
`ZeroDivisionError` is raised.
#### mruby [2.1.0 (2019-10-18)]
#### mruby [2.1.0 (2019-11-19)]
No exception is raised.
@@ -89,7 +89,7 @@ p Liste.new "foobar"
` [] `
#### mruby [2.1.0 (2019-10-18)]
#### mruby [2.1.0 (2019-11-19)]
`ArgumentError` is raised.
@@ -119,7 +119,7 @@ false
true
```
#### mruby [2.1.0 (2019-10-18)]
#### mruby [2.1.0 (2019-11-19)]
```
true
@@ -156,7 +156,7 @@ p 'ok'
ok
```
#### mruby [2.1.0 (2019-10-18)]
#### mruby [2.1.0 (2019-11-19)]
```
test.rb:8: undefined method 'test_func' (NoMethodError)
@@ -178,7 +178,7 @@ defined?(Foo)
nil
```
#### mruby [2.1.0 (2019-10-18)]
#### mruby [2.1.0 (2019-11-19)]
`NameError` is raised.
@@ -195,7 +195,7 @@ alias $a $__a__
` nil `
#### mruby [2.1.0 (2019-10-18)]
#### mruby [2.1.0 (2019-11-19)]
Syntax error
@@ -217,7 +217,7 @@ end
`ArgumentError` is raised.
The re-defined `+` operator does not accept any arguments.
#### mruby [2.1.0 (2019-10-18)]
#### mruby [2.1.0 (2019-11-19)]
` 'ab' `
Behavior of the operator wasn't changed.
@@ -233,7 +233,7 @@ $ ruby -e 'puts Proc.new {}.binding'
#<Binding:0x00000e9deabb9950>
```
#### mruby [2.1.0 (2019-10-18)]
#### mruby [2.1.0 (2019-11-19)]
```
$ ./bin/mruby -e 'puts Proc.new {}.binding'
+1 -1
View File
@@ -52,7 +52,7 @@ mrb_break_value_get(struct RBreak *brk)
{
mrb_value val;
val.value = brk->value;
val.tt = brk->flags & RBREAK_VALUE_TT_MASK;
val.tt = (enum mrb_vtype)(brk->flags & RBREAK_VALUE_TT_MASK);
return val;
}
static inline void
+2 -2
View File
@@ -67,12 +67,12 @@ MRB_BEGIN_DECL
/*
* Release month.
*/
#define MRUBY_RELEASE_MONTH 10
#define MRUBY_RELEASE_MONTH 11
/*
* Release day.
*/
#define MRUBY_RELEASE_DAY 18
#define MRUBY_RELEASE_DAY 19
/*
* Release date as a string.
+16 -6
View File
@@ -24,6 +24,14 @@ module MRuby
target
end
def shellquote(s)
if ENV['OS'] == 'Windows_NT'
"\"#{s}\""
else
"#{s}"
end
end
NotFoundCommands = {}
private
@@ -278,9 +286,9 @@ module MRuby
@command = 'git'
@flags = %w[]
@clone_options = "clone %{flags} %{url} %{dir}"
@pull_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' pull"
@checkout_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' checkout %{checksum_hash}"
@reset_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' reset %{checksum_hash}"
@pull_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} pull"
@checkout_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} checkout %{checksum_hash}"
@reset_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} reset %{checksum_hash}"
end
def run_clone(dir, url, _flags = [])
@@ -304,11 +312,11 @@ module MRuby
end
def commit_hash(dir)
`#{@command} --git-dir '#{dir}/.git' --work-tree '#{dir}' rev-parse --verify HEAD`.strip
`#{@command} --git-dir #{shellquote(dir +'/.git')} --work-tree #{shellquote(dir)} rev-parse --verify HEAD`.strip
end
def current_branch(dir)
`#{@command} --git-dir '#{dir}/.git' --work-tree '#{dir}' rev-parse --abbrev-ref HEAD`.strip
`#{@command} --git-dir #{shellquote(dir + '/.git')} --work-tree #{shellquote(dir)} rev-parse --abbrev-ref HEAD`.strip
end
end
@@ -327,7 +335,9 @@ module MRuby
infiles.each do |f|
_pp "MRBC", f.relative_path, nil, :indent => 2
end
IO.popen("#{filename @command} #{@compile_options % {:funcname => funcname}} #{filename(infiles).join(' ')}", 'r+') do |io|
cmd = "#{filename @command} #{@compile_options % {:funcname => funcname}} #{filename(infiles).join(' ')}"
print("#{cmd}\n") if $verbose
IO.popen(cmd, 'r+') do |io|
out.puts io.read
end
# if mrbc execution fail, drop the file
+9 -1
View File
@@ -54,6 +54,14 @@ module MRuby
end
end
def shellquote(s)
if ENV['OS'] == 'Windows_NT'
"\"#{s}\""
else
"'#{s}'"
end
end
def mruby
mruby = {
'version' => MRuby::Source::MRUBY_VERSION,
@@ -62,7 +70,7 @@ module MRuby
git_dir = "#{MRUBY_ROOT}/.git"
if File.directory?(git_dir)
mruby['git_commit'] = `git --git-dir '#{git_dir}' --work-tree '#{MRUBY_ROOT}' rev-parse --verify HEAD`.strip
mruby['git_commit'] = `git --git-dir #{shellquote(git_dir)} --work-tree #{shellquote(MRUBY_ROOT)} rev-parse --verify HEAD`.strip
end
mruby
-4
View File
@@ -28,8 +28,4 @@ module Kernel
def gets(*args)
$stdin.gets(*args)
end
def getc(*args)
$stdin.getc(*args)
end
end
+7 -10
View File
@@ -284,12 +284,13 @@ mrb_io_alloc(mrb_state *mrb)
#endif
static int
option_to_fd(mrb_state *mrb, mrb_value obj, const char *key)
option_to_fd(mrb_state *mrb, mrb_value hash, const char *key)
{
mrb_value opt = mrb_funcall(mrb, obj, "[]", 1, mrb_symbol_value(mrb_intern_static(mrb, key, strlen(key))));
if (mrb_nil_p(opt)) {
return -1;
}
mrb_value opt;
if (!mrb_hash_p(hash)) return -1;
opt = mrb_hash_fetch(mrb, hash, mrb_symbol_value(mrb_intern_static(mrb, key, strlen(key))), mrb_nil_value());
if (mrb_nil_p(opt)) return -1;
switch (mrb_type(opt)) {
case MRB_TT_DATA: /* IO */
@@ -907,11 +908,7 @@ mrb_io_syswrite(mrb_state *mrb, mrb_value io)
}
mrb_get_args(mrb, "S", &str);
if (!mrb_string_p(str)) {
buf = mrb_funcall(mrb, str, "to_s", 0);
} else {
buf = str;
}
buf = str;
if (fptr->fd2 == -1) {
fd = fptr->fd;
+2 -2
View File
@@ -174,8 +174,8 @@ mrb_str_concat_m(mrb_state *mrb, mrb_value self)
str = int_chr_binary(mrb, str);
#endif
else
str = mrb_ensure_string_type(mrb, str);
mrb_str_concat(mrb, self, str);
mrb_ensure_string_type(mrb, str);
mrb_str_cat_str(mrb, self, str);
return self;
}
+3 -2
View File
@@ -145,7 +145,7 @@ class_name_str(mrb_state *mrb, struct RClass* c)
if (mrb_nil_p(path)) {
path = c->tt == MRB_TT_MODULE ? mrb_str_new_lit(mrb, "#<Module:") :
mrb_str_new_lit(mrb, "#<Class:");
mrb_str_concat(mrb, path, mrb_ptr_to_str(mrb, c));
mrb_str_cat_str(mrb, path, mrb_ptr_to_str(mrb, c));
mrb_str_cat_lit(mrb, path, ">");
}
return path;
@@ -1885,7 +1885,8 @@ mrb_mod_to_s(mrb_state *mrb, mrb_value klass)
return mrb_str_cat_lit(mrb, str, ">");
}
else {
return class_name_str(mrb, mrb_class_ptr(klass));
mrb_value str = class_name_str(mrb, mrb_class_ptr(klass));
return mrb_frozen_p(mrb_basic_ptr(str)) ? mrb_str_dup(mrb, str) : str;
}
}
+1 -1
View File
@@ -423,7 +423,7 @@ mrb_any_to_s(mrb_state *mrb, mrb_value obj)
mrb_str_cat_cstr(mrb, str, cname);
if (!mrb_immediate_p(obj)) {
mrb_str_cat_lit(mrb, str, ":");
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, mrb_ptr(obj)));
mrb_str_cat_str(mrb, str, mrb_ptr_to_str(mrb, mrb_ptr(obj)));
}
mrb_str_cat_lit(mrb, str, ">");
+7 -2
View File
@@ -1388,8 +1388,13 @@ str_escape(mrb_state *mrb, mrb_value str, mrb_bool inspect)
}
mrb_str_cat_lit(mrb, result, "\"");
#ifdef MRB_UTF8_STRING
mrb_str_ptr(str)->flags |= ascii_flag;
mrb_str_ptr(result)->flags |= ascii_flag;
if (inspect) {
mrb_str_ptr(str)->flags |= ascii_flag;
mrb_str_ptr(result)->flags |= ascii_flag;
}
else {
RSTR_SET_ASCII_FLAG(mrb_str_ptr(result));
}
#endif
return result;
+1 -1
View File
@@ -509,7 +509,7 @@ mrb_obj_iv_inspect(mrb_state *mrb, struct RObject *obj)
mrb_str_cat_lit(mrb, str, "-<");
mrb_str_cat_cstr(mrb, str, cn);
mrb_str_cat_lit(mrb, str, ":");
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, obj));
mrb_str_cat_str(mrb, str, mrb_ptr_to_str(mrb, obj));
iv_foreach(mrb, t, inspect_i, &str);
mrb_str_cat_lit(mrb, str, ">");