summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--INSTALL10
-rw-r--r--mrbgems/mruby-bin-mirb/tools/mirb/mirb.c2
-rw-r--r--mrbgems/mruby-hash-ext/src/hash-ext.c4
-rw-r--r--mrbgems/mruby-hash-ext/test/hash.rb5
-rw-r--r--src/error.h3
-rw-r--r--src/numeric.c27
-rw-r--r--tasks/mruby_build.rake10
-rw-r--r--tasks/toolchains/gcc.rake2
-rw-r--r--test/t/string.rb3
-rw-r--r--travis_config.rb2
10 files changed, 56 insertions, 12 deletions
diff --git a/INSTALL b/INSTALL
index d8b40243d..7a0e6cd47 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,6 +1,6 @@
* Prerequisites
-
- 1. Make sure you have bison (http://www.gnu.org/software/bison/) installed in your system.
+
+ 1. Make sure you have bison (http://www.gnu.org/software/bison/) installed in your system.
2. Make sure you have ruby installed in your system (required to build).
* Compilation and Installation
@@ -8,10 +8,10 @@
1. Run make in the top directory.
This command will create a build directory with a directory for the host environment
- and one for each crossbuild environment based on the settings in the build_config.rb
+ and one for each crossbuild environment based on the settings in the build_config.rb
file.
- Assuming a default build, each of the environment directories will have the following
+ Assuming a default build, each of the environment directories will have the following
important directories:
* bin - The binary executables for this environment
@@ -19,7 +19,7 @@
You can find the header files in the include directory at the root of the project.
- You can directory invoke 'minirake' as the following.
+ You can directly invoke 'minirake' with the following command:
$ ruby ./minirake
diff --git a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
index a9d6850a5..b204c8e2d 100644
--- a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
+++ b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
@@ -218,6 +218,7 @@ print_hint(void)
printf("mirb - Embeddable Interactive Ruby Shell\n\n");
}
+#ifndef ENABLE_READLINE
/* Print the command line prompt of the REPL */
static void
print_cmdline(int code_block_open)
@@ -229,6 +230,7 @@ print_cmdline(int code_block_open)
printf("> ");
}
}
+#endif
void mrb_codedump_all(mrb_state*, struct RProc*);
diff --git a/mrbgems/mruby-hash-ext/src/hash-ext.c b/mrbgems/mruby-hash-ext/src/hash-ext.c
index 298559686..937a7fddd 100644
--- a/mrbgems/mruby-hash-ext/src/hash-ext.c
+++ b/mrbgems/mruby-hash-ext/src/hash-ext.c
@@ -23,12 +23,14 @@ static mrb_value
hash_values_at(mrb_state *mrb, mrb_value hash)
{
mrb_value *argv, result;
- int argc, i;
+ int argc, i, ai;
mrb_get_args(mrb, "*", &argv, &argc);
result = mrb_ary_new_capa(mrb, argc);
+ ai = mrb_gc_arena_save(mrb);
for (i = 0; i < argc; i++) {
mrb_ary_push(mrb, result, mrb_hash_get(mrb, hash, argv[i]));
+ mrb_gc_arena_restore(mrb, ai);
}
return result;
}
diff --git a/mrbgems/mruby-hash-ext/test/hash.rb b/mrbgems/mruby-hash-ext/test/hash.rb
index 40f6ac8bf..cdf00173a 100644
--- a/mrbgems/mruby-hash-ext/test/hash.rb
+++ b/mrbgems/mruby-hash-ext/test/hash.rb
@@ -21,4 +21,9 @@ end
assert('Hash#values_at') do
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
assert_equal ["bovine", "feline"], h.values_at("cow", "cat")
+
+ keys = []
+ (0...1000).each { |v| keys.push "#{v}" }
+ h = Hash.new { |hash,k| hash[k] = k }
+ assert_equal keys, h.values_at(*keys)
end
diff --git a/src/error.h b/src/error.h
new file mode 100644
index 000000000..0e0dacf63
--- /dev/null
+++ b/src/error.h
@@ -0,0 +1,3 @@
+/* this header file is to be removed soon.
+ added for compatibility purpose (1.0.0) */
+#include "mruby/error.h"
diff --git a/src/numeric.c b/src/numeric.c
index 0789a7654..ec7f05b97 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -136,6 +136,7 @@ mrb_flo_to_str(mrb_state *mrb, mrb_value flo)
mrb_bool e = FALSE;
char s[48];
char *c = &s[0];
+ int length = 0;
if (n < 0) {
n = -n;
@@ -143,11 +144,35 @@ mrb_flo_to_str(mrb_state *mrb, mrb_value flo)
}
exp = (n > 1) ? floor(log10(n)) : -ceil(-log10(n));
+
+ /* preserve significands */
+ if (exp < 0) {
+ int i, beg = -1, end = 0;
+ double f = n;
+ double fd = 0;
+ for (i = 0; i < FLO_MAX_DIGITS; ++i) {
+ f = (f - fd) * 10.0;
+ fd = floor(f + FLO_EPSILON);
+ if (fd != 0) {
+ if (beg < 0) beg = i;
+ end = i + 1;
+ }
+ }
+ if (beg >= 0) length = end - beg;
+ }
- if ((exp < 0 ? -exp : exp) >= FLO_MAX_DIGITS) {
+ if (abs(exp) + length >= FLO_MAX_DIGITS) {
/* exponent representation */
e = TRUE;
n = n / pow(10.0, exp);
+ if (isinf(n)) {
+ if (s[0] == '-') {
+ return mrb_str_new_lit(mrb, "-0.0");
+ }
+ else {
+ return mrb_str_new_lit(mrb, "0.0");
+ }
+ }
}
else {
/* un-exponent (normal) representation */
diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake
index c92400cf9..b7efa96b9 100644
--- a/tasks/mruby_build.rake
+++ b/tasks/mruby_build.rake
@@ -52,7 +52,7 @@ module MRuby
Exts = Struct.new(:object, :executable, :library)
- def initialize(name='host', &block)
+ def initialize(name='host', build_dir=nil, &block)
@name = name.to_s
unless MRuby.targets[@name]
@@ -62,9 +62,11 @@ module MRuby
@exts = Exts.new('.o', '', '.a')
end
+ build_dir = build_dir || ENV['MRUBY_BUILD_DIR'] || "#{MRUBY_ROOT}/build"
+
@file_separator = '/'
- @build_dir = "#{MRUBY_ROOT}/build/#{@name}"
- @gem_clone_dir = "#{MRUBY_ROOT}/build/mrbgems"
+ @build_dir = "#{build_dir}/#{@name}"
+ @gem_clone_dir = "#{build_dir}/mrbgems"
@cc = Command::Compiler.new(self, %w(.c))
@cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp))
@objc = Command::Compiler.new(self, %w(.m))
@@ -204,7 +206,7 @@ module MRuby
class CrossBuild < Build
attr_block %w(test_runner)
- def initialize(name, &block)
+ def initialize(name, build_dir=nil, &block)
@test_runner = Command::CrossTestRunner.new(self)
super
end
diff --git a/tasks/toolchains/gcc.rake b/tasks/toolchains/gcc.rake
index dec502732..a25f840c5 100644
--- a/tasks/toolchains/gcc.rake
+++ b/tasks/toolchains/gcc.rake
@@ -1,7 +1,7 @@
MRuby::Toolchain.new(:gcc) do |conf|
[conf.cc, conf.objc, conf.asm].each do |cc|
cc.command = ENV['CC'] || 'gcc'
- cc.flags = [ENV['CFLAGS'] || %w(-g -std=gnu99 -O3 -Wall -Werror-implicit-function-declaration)]
+ cc.flags = [ENV['CFLAGS'] || %w(-g -std=gnu99 -O3 -Wall -Werror-implicit-function-declaration -Wdeclaration-after-statement)]
cc.include_paths = ["#{MRUBY_ROOT}/include"]
cc.defines = %w(DISABLE_GEMS)
cc.option_include_path = '-I%s'
diff --git a/test/t/string.rb b/test/t/string.rb
index c42fa006f..3219f98c3 100644
--- a/test/t/string.rb
+++ b/test/t/string.rb
@@ -125,6 +125,7 @@ assert('String#capitalize!', '15.2.10.5.8') do
a.capitalize!
assert_equal 'Abc', a
+ assert_equal nil, 'Abc'.capitalize!
end
assert('String#chomp', '15.2.10.5.9') do
@@ -204,6 +205,7 @@ assert('String#downcase!', '15.2.10.5.14') do
a.downcase!
assert_equal 'abc', a
+ assert_equal nil, 'abc'.downcase!
end
assert('String#each_line', '15.2.10.5.15') do
@@ -442,6 +444,7 @@ assert('String#upcase!', '15.2.10.5.43') do
a.upcase!
assert_equal 'ABC', a
+ assert_equal nil, 'ABC'.upcase!
end
# Not ISO specified
diff --git a/travis_config.rb b/travis_config.rb
index 6f406ae37..ffa0a75d4 100644
--- a/travis_config.rb
+++ b/travis_config.rb
@@ -4,6 +4,7 @@ MRuby::Build.new('debug') do |conf|
# include all core GEMs
conf.gembox 'full-core'
+ conf.cc.flags += %w(-Werror=declaration-after-statement)
conf.cc.defines += %w(MRB_GC_FIXED_ARENA)
end
@@ -12,6 +13,7 @@ MRuby::Build.new do |conf|
# include all core GEMs
conf.gembox 'full-core'
+ conf.cc.flags += %w(-Werror=declaration-after-statement)
conf.cc.defines = %w(MRB_DEBUG MRB_GC_FIXED_ARENA)
conf.enable_bintest = true
end