script_core 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -1
  3. data/ext/enterprise_script_service/libseccomp/.travis.yml +3 -5
  4. data/ext/enterprise_script_service/libseccomp/CHANGELOG +10 -0
  5. data/ext/enterprise_script_service/libseccomp/CREDITS +3 -0
  6. data/ext/enterprise_script_service/libseccomp/README.md +18 -0
  7. data/ext/enterprise_script_service/libseccomp/configure.ac +1 -1
  8. data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +7 -0
  9. data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +16 -0
  10. data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +16 -0
  11. data/ext/enterprise_script_service/libseccomp/tests/.gitignore +1 -0
  12. data/ext/enterprise_script_service/libseccomp/tests/15-basic-resolver.c +3 -3
  13. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.c +48 -0
  14. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.py +38 -0
  15. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.tests +11 -0
  16. data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +6 -3
  17. data/ext/enterprise_script_service/libseccomp/tests/regression +4 -0
  18. data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -3
  19. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +2 -0
  20. data/ext/enterprise_script_service/mruby/.github/workflows/build.yml +106 -0
  21. data/ext/enterprise_script_service/mruby/.github/workflows/main.yml +24 -0
  22. data/ext/enterprise_script_service/mruby/.gitignore +3 -0
  23. data/ext/enterprise_script_service/mruby/.travis.yml +6 -9
  24. data/ext/enterprise_script_service/mruby/AUTHORS +1 -0
  25. data/ext/enterprise_script_service/mruby/Doxyfile +1 -1
  26. data/ext/enterprise_script_service/mruby/LICENSE +1 -1
  27. data/ext/enterprise_script_service/mruby/README.md +6 -2
  28. data/ext/enterprise_script_service/mruby/appveyor.yml +9 -12
  29. data/ext/enterprise_script_service/mruby/appveyor_config.rb +9 -0
  30. data/ext/enterprise_script_service/mruby/build_config.rb +6 -6
  31. data/ext/enterprise_script_service/mruby/doc/guides/compile.md +6 -2
  32. data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +1 -1
  33. data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +4 -8
  34. data/ext/enterprise_script_service/mruby/doc/limitations.md +10 -10
  35. data/ext/enterprise_script_service/mruby/doc/opcode.md +108 -95
  36. data/ext/enterprise_script_service/mruby/examples/targets/build_config_ArduinoDue.rb +2 -2
  37. data/ext/enterprise_script_service/mruby/examples/targets/build_config_IntelEdison.rb +2 -2
  38. data/ext/enterprise_script_service/mruby/examples/targets/build_config_IntelGalileo.rb +2 -2
  39. data/ext/enterprise_script_service/mruby/examples/targets/build_config_RX630.rb +2 -2
  40. data/ext/enterprise_script_service/mruby/examples/targets/build_config_chipKITMax32.rb +2 -2
  41. data/ext/enterprise_script_service/mruby/examples/targets/build_config_dreamcast_shelf.rb +108 -0
  42. data/ext/enterprise_script_service/mruby/include/mrbconf.h +10 -7
  43. data/ext/enterprise_script_service/mruby/include/mruby.h +11 -9
  44. data/ext/enterprise_script_service/mruby/include/mruby/array.h +4 -0
  45. data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +11 -2
  46. data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +0 -9
  47. data/ext/enterprise_script_service/mruby/include/mruby/common.h +10 -0
  48. data/ext/enterprise_script_service/mruby/include/mruby/compile.h +11 -3
  49. data/ext/enterprise_script_service/mruby/include/mruby/dump.h +1 -17
  50. data/ext/enterprise_script_service/mruby/include/mruby/irep.h +10 -0
  51. data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -1
  52. data/ext/enterprise_script_service/mruby/include/mruby/khash.h +23 -5
  53. data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +1 -0
  54. data/ext/enterprise_script_service/mruby/include/mruby/ops.h +3 -2
  55. data/ext/enterprise_script_service/mruby/include/mruby/string.h +2 -1
  56. data/ext/enterprise_script_service/mruby/include/mruby/value.h +7 -12
  57. data/ext/enterprise_script_service/mruby/include/mruby/version.h +4 -4
  58. data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +2 -30
  59. data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +21 -46
  60. data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +9 -0
  61. data/ext/enterprise_script_service/mruby/lib/mruby/source.rb +3 -1
  62. data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +7 -0
  63. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +0 -31
  64. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +0 -13
  65. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mrbgem.rake +5 -2
  66. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +0 -1
  67. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +5 -1
  68. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +5 -1
  69. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +7 -11
  70. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +0 -1
  71. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +6 -2
  72. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +6 -2
  73. data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +6 -1
  74. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +76 -48
  75. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +107 -32
  76. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/y.tab.c +13153 -0
  77. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/mrbgem.rake +13 -15
  78. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +3 -3
  79. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +2 -213
  80. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +21 -0
  81. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +1 -3
  82. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/include/mruby/ext/io.h +39 -7
  83. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +2 -8
  84. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file_constants.rb +0 -16
  85. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +7 -12
  86. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +76 -30
  87. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +9 -10
  88. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +323 -120
  89. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +18 -12
  90. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +32 -0
  91. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +57 -49
  92. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +15 -17
  93. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +9 -0
  94. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +1 -1
  95. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +3 -12
  96. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +113 -10
  97. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +5 -1
  98. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +2 -2
  99. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +9 -9
  100. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/src/mrb_sleep.c +1 -1
  101. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrbgem.rake +1 -1
  102. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/test/sockettest.c +3 -2
  103. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +61 -24
  104. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +5 -23
  105. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +3 -3
  106. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +1 -1
  107. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +1 -0
  108. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +6 -5
  109. data/ext/enterprise_script_service/mruby/mrblib/hash.rb +3 -3
  110. data/ext/enterprise_script_service/mruby/src/array.c +11 -0
  111. data/ext/enterprise_script_service/mruby/src/backtrace.c +2 -2
  112. data/ext/enterprise_script_service/mruby/src/class.c +26 -11
  113. data/ext/enterprise_script_service/mruby/src/codedump.c +4 -0
  114. data/ext/enterprise_script_service/mruby/src/debug.c +8 -5
  115. data/ext/enterprise_script_service/mruby/src/dump.c +3 -65
  116. data/ext/enterprise_script_service/mruby/src/error.c +57 -5
  117. data/ext/enterprise_script_service/mruby/src/etc.c +13 -4
  118. data/ext/enterprise_script_service/mruby/src/fmt_fp.c +98 -21
  119. data/ext/enterprise_script_service/mruby/src/gc.c +10 -275
  120. data/ext/enterprise_script_service/mruby/src/hash.c +5 -6
  121. data/ext/enterprise_script_service/mruby/src/kernel.c +2 -2
  122. data/ext/enterprise_script_service/mruby/src/load.c +56 -30
  123. data/ext/enterprise_script_service/mruby/src/numeric.c +22 -10
  124. data/ext/enterprise_script_service/mruby/src/object.c +12 -4
  125. data/ext/enterprise_script_service/mruby/src/print.c +27 -3
  126. data/ext/enterprise_script_service/mruby/src/proc.c +21 -1
  127. data/ext/enterprise_script_service/mruby/src/state.c +34 -11
  128. data/ext/enterprise_script_service/mruby/src/string.c +69 -35
  129. data/ext/enterprise_script_service/mruby/src/symbol.c +12 -10
  130. data/ext/enterprise_script_service/mruby/src/vm.c +21 -30
  131. data/ext/enterprise_script_service/mruby/tasks/gitlab.rake +19 -22
  132. data/ext/enterprise_script_service/mruby/tasks/mrbgems.rake +1 -1
  133. data/ext/enterprise_script_service/mruby/tasks/toolchains/android.rake +46 -1
  134. data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +3 -3
  135. data/ext/enterprise_script_service/mruby/tasks/toolchains/openwrt.rake +6 -6
  136. data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +8 -8
  137. data/ext/enterprise_script_service/mruby/test/assert.rb +5 -4
  138. data/ext/enterprise_script_service/mruby/test/t/ensure.rb +8 -26
  139. data/ext/enterprise_script_service/mruby/test/t/exception.rb +2 -2
  140. data/ext/enterprise_script_service/mruby/test/t/kernel.rb +8 -24
  141. data/ext/enterprise_script_service/mruby/travis_config.rb +0 -14
  142. data/ext/enterprise_script_service/msgpack/.github/depends/boost.sh +56 -0
  143. data/ext/enterprise_script_service/msgpack/.github/workflows/coverage.yml +62 -0
  144. data/ext/enterprise_script_service/msgpack/.github/workflows/gha.yml +304 -0
  145. data/ext/enterprise_script_service/msgpack/CHANGELOG.md +11 -0
  146. data/ext/enterprise_script_service/msgpack/CMakeLists.txt +82 -39
  147. data/ext/enterprise_script_service/msgpack/Files.cmake +22 -12
  148. data/ext/enterprise_script_service/msgpack/QUICKSTART-C.md +26 -29
  149. data/ext/enterprise_script_service/msgpack/README.md +3 -2
  150. data/ext/enterprise_script_service/msgpack/appveyor.yml +6 -2
  151. data/ext/enterprise_script_service/msgpack/ci/build_cmake.sh +3 -1
  152. data/ext/enterprise_script_service/msgpack/cmake/CodeCoverage.cmake +55 -0
  153. data/ext/enterprise_script_service/msgpack/codecov.yml +36 -0
  154. data/ext/enterprise_script_service/msgpack/example/CMakeLists.txt +9 -5
  155. data/ext/enterprise_script_service/msgpack/example/boost/CMakeLists.txt +1 -1
  156. data/ext/enterprise_script_service/msgpack/example/c/CMakeLists.txt +17 -6
  157. data/ext/enterprise_script_service/msgpack/example/c/boundary.c +296 -0
  158. data/ext/enterprise_script_service/msgpack/example/c/jsonconv.c +419 -0
  159. data/ext/enterprise_script_service/msgpack/example/c/simple_c.c +1 -1
  160. data/ext/enterprise_script_service/msgpack/example/cpp03/CMakeLists.txt +3 -3
  161. data/ext/enterprise_script_service/msgpack/example/cpp11/CMakeLists.txt +2 -2
  162. data/ext/enterprise_script_service/msgpack/example/x3/CMakeLists.txt +2 -2
  163. data/ext/enterprise_script_service/msgpack/include/msgpack/pack.h +24 -1
  164. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +5 -4
  165. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/boost/optional.hpp +4 -4
  166. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp17/vector_byte.hpp +8 -8
  167. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/map.hpp +4 -4
  168. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector.hpp +4 -4
  169. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_char.hpp +8 -8
  170. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_unsigned_char.hpp +8 -8
  171. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +4 -4
  172. data/ext/enterprise_script_service/msgpack/include/msgpack/v3/unpack.hpp +6 -6
  173. data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
  174. data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +4 -4
  175. data/ext/enterprise_script_service/msgpack/make_file_list.sh +38 -11
  176. data/ext/enterprise_script_service/msgpack/src/vrefbuffer.c +6 -0
  177. data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +86 -64
  178. data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +4 -0
  179. data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +4 -0
  180. data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +4 -0
  181. data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +4 -1
  182. data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +4 -0
  183. data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +4 -0
  184. data/ext/enterprise_script_service/msgpack/test/buffer.cpp +4 -47
  185. data/ext/enterprise_script_service/msgpack/test/buffer_c.cpp +148 -0
  186. data/ext/enterprise_script_service/msgpack/test/carray.cpp +4 -0
  187. data/ext/enterprise_script_service/msgpack/test/cases.cpp +8 -4
  188. data/ext/enterprise_script_service/msgpack/test/convert.cpp +8 -4
  189. data/ext/enterprise_script_service/msgpack/test/fixint.cpp +4 -0
  190. data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +4 -0
  191. data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +4 -0
  192. data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +4 -0
  193. data/ext/enterprise_script_service/msgpack/test/json.cpp +4 -0
  194. data/ext/enterprise_script_service/msgpack/test/limit.cpp +8 -4
  195. data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +4 -0
  196. data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +159 -0
  197. data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +4 -0
  198. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +32 -27
  199. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +4 -0
  200. data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +4 -0
  201. data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +4 -1
  202. data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +4 -0
  203. data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +4 -0
  204. data/ext/enterprise_script_service/msgpack/test/object.cpp +4 -1
  205. data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +12 -8
  206. data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +30 -26
  207. data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +4 -0
  208. data/ext/enterprise_script_service/msgpack/test/raw.cpp +4 -0
  209. data/ext/enterprise_script_service/msgpack/test/reference.cpp +4 -0
  210. data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +4 -0
  211. data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +4 -0
  212. data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +4 -0
  213. data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +4 -0
  214. data/ext/enterprise_script_service/msgpack/test/streaming.cpp +8 -4
  215. data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +4 -0
  216. data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +4 -0
  217. data/ext/enterprise_script_service/msgpack/test/user_class.cpp +16 -12
  218. data/ext/enterprise_script_service/msgpack/test/version.cpp +4 -0
  219. data/ext/enterprise_script_service/msgpack/test/visitor.cpp +4 -0
  220. data/ext/enterprise_script_service/msgpack/test/zone.cpp +4 -0
  221. data/lib/script_core/version.rb +1 -1
  222. data/script_core.gemspec +1 -1
  223. metadata +23 -9
  224. data/ext/enterprise_script_service/msgpack/.travis.yml +0 -258
@@ -1,6 +1,10 @@
1
1
  #include <mruby.h>
2
+
3
+ #ifdef MRB_DISABLE_STDIO
4
+ # error print conflicts 'MRB_DISABLE_STDIO' configuration in your 'build_config.rb'
5
+ #endif
6
+
2
7
  #include <mruby/string.h>
3
- #include <stdio.h>
4
8
  #include <string.h>
5
9
  #include <stdlib.h>
6
10
  #if defined(_WIN32)
@@ -6,7 +6,7 @@
6
6
  #include <mruby/debug.h>
7
7
 
8
8
  static mrb_value
9
- mrb_proc_lambda(mrb_state *mrb, mrb_value self)
9
+ mrb_proc_lambda_p(mrb_state *mrb, mrb_value self)
10
10
  {
11
11
  struct RProc *p = mrb_proc_ptr(self);
12
12
  return mrb_bool_value(MRB_PROC_STRICT_P(p));
@@ -169,7 +169,7 @@ void
169
169
  mrb_mruby_proc_ext_gem_init(mrb_state* mrb)
170
170
  {
171
171
  struct RClass *p = mrb->proc_class;
172
- mrb_define_method(mrb, p, "lambda?", mrb_proc_lambda, MRB_ARGS_NONE());
172
+ mrb_define_method(mrb, p, "lambda?", mrb_proc_lambda_p, MRB_ARGS_NONE());
173
173
  mrb_define_method(mrb, p, "source_location", mrb_proc_source_location, MRB_ARGS_NONE());
174
174
  mrb_define_method(mrb, p, "to_s", mrb_proc_inspect, MRB_ARGS_NONE());
175
175
  mrb_define_method(mrb, p, "inspect", mrb_proc_inspect, MRB_ARGS_NONE());
@@ -91,9 +91,9 @@ rational_s_new(mrb_state *mrb, mrb_value self)
91
91
  mrb_get_args(mrb, "ii", &numerator, &denominator);
92
92
  #else
93
93
 
94
- #define DROP_PRECISION(cond, num, denom) \
94
+ #define DROP_PRECISION(f, num, denom) \
95
95
  do { \
96
- while (cond) { \
96
+ while (f < (mrb_float)MRB_INT_MIN || f > (mrb_float)MRB_INT_MAX) { \
97
97
  num /= 2; \
98
98
  denom /= 2; \
99
99
  } \
@@ -111,8 +111,8 @@ rational_s_new(mrb_state *mrb, mrb_value self)
111
111
  else {
112
112
  mrb_float denomf = mrb_to_flo(mrb, denomv);
113
113
 
114
- DROP_PRECISION(denomf < MRB_INT_MIN || denomf > MRB_INT_MAX, numerator, denomf);
115
- denominator = denomf;
114
+ DROP_PRECISION(denomf, numerator, denomf);
115
+ denominator = (mrb_int)denomf;
116
116
  }
117
117
  }
118
118
  else {
@@ -124,12 +124,12 @@ rational_s_new(mrb_state *mrb, mrb_value self)
124
124
  else {
125
125
  mrb_float denomf = mrb_to_flo(mrb, denomv);
126
126
 
127
- DROP_PRECISION(denomf < MRB_INT_MIN || denomf > MRB_INT_MAX, numf, denomf);
128
- denominator = denomf;
127
+ DROP_PRECISION(denomf, numf, denomf);
128
+ denominator = (mrb_int)denomf;
129
129
  }
130
130
 
131
- DROP_PRECISION(numf < MRB_INT_MIN || numf > MRB_INT_MAX, numf, denominator);
132
- numerator = numf;
131
+ DROP_PRECISION(numf, numf, denominator);
132
+ numerator = (mrb_int)numf;
133
133
  }
134
134
  #endif
135
135
 
@@ -152,7 +152,7 @@ rational_to_i(mrb_state *mrb, mrb_value self)
152
152
  {
153
153
  struct mrb_rational *p = rational_ptr(mrb, self);
154
154
  if (p->denominator == 0) {
155
- mrb_raise(mrb, mrb_exc_get(mrb, "StandardError"), "divided by 0");
155
+ mrb_raise(mrb, mrb->eStandardError_class, "divided by 0");
156
156
  }
157
157
  return mrb_fixnum_value(p->numerator / p->denominator);
158
158
  }
@@ -30,7 +30,7 @@
30
30
  #ifdef _WIN32
31
31
  #include <windows.h>
32
32
  #define sleep(x) Sleep(x * 1000)
33
- #define usleep(x) Sleep((DWORD)((x)<1000) ? 1 : ((x)/1000))
33
+ #define usleep(x) Sleep((DWORD)(((x)<1000) ? 1 : ((x)/1000)))
34
34
  #else
35
35
  #include <unistd.h>
36
36
  #include <sys/time.h>
@@ -7,7 +7,7 @@
7
7
  #spec.cc.defines << "HAVE_SA_LEN=0"
8
8
 
9
9
  # If Windows, use winsock
10
- if ( /mswin|mingw|win32/ =~ RUBY_PLATFORM ) then
10
+ if for_windows?
11
11
  spec.linker.libraries << "wsock32"
12
12
  spec.linker.libraries << "ws2_32"
13
13
  end
@@ -1,4 +1,3 @@
1
- #include <stdio.h>
2
1
  #include <stdlib.h>
3
2
 
4
3
  #include "mruby.h"
@@ -8,7 +7,9 @@
8
7
 
9
8
  #include <io.h>
10
9
 
11
- #ifdef _MSC_VER
10
+ #if defined(_MSC_VER) || \
11
+ (defined(MRB_MINGW32_VERSION) && MRB_MINGW32_VERSION < 3021) || \
12
+ (defined(MRB_MINGW64_VERSION) && MRB_MINGW64_VERSION < 4000)
12
13
 
13
14
  #include <fcntl.h>
14
15
  #include <sys/stat.h>
@@ -5,9 +5,7 @@
5
5
  */
6
6
 
7
7
  #include <mruby.h>
8
-
9
8
  #include <limits.h>
10
- #include <stdio.h>
11
9
  #include <string.h>
12
10
  #include <mruby/string.h>
13
11
  #include <mruby/hash.h>
@@ -518,6 +516,50 @@ mrb_f_sprintf(mrb_state *mrb, mrb_value obj)
518
516
  }
519
517
  }
520
518
 
519
+ static int
520
+ mrb_int2str(char *buf, size_t len, mrb_int n)
521
+ {
522
+ #ifdef MRB_DISABLE_STDIO
523
+ char *bufend = buf + len;
524
+ char *p = bufend - 1;
525
+
526
+ if (len < 1) return -1;
527
+
528
+ *p -- = '\0';
529
+ len --;
530
+
531
+ if (n < 0) {
532
+ if (len < 1) return -1;
533
+
534
+ *p -- = '-';
535
+ len --;
536
+ n = -n;
537
+ }
538
+
539
+ if (n > 0) {
540
+ for (; n > 0; len --, n /= 10) {
541
+ if (len < 1) return -1;
542
+
543
+ *p -- = '0' + (n % 10);
544
+ }
545
+ p ++;
546
+ }
547
+ else if (len > 0) {
548
+ *p = '0';
549
+ len --;
550
+ }
551
+ else {
552
+ return -1;
553
+ }
554
+
555
+ memmove(buf, p, bufend - p);
556
+
557
+ return bufend - p - 1;
558
+ #else
559
+ return snprintf(buf, len, "%" MRB_PRId, n);
560
+ #endif /* MRB_DISABLE_STDIO */
561
+ }
562
+
521
563
  mrb_value
522
564
  mrb_str_format(mrb_state *mrb, mrb_int argc, const mrb_value *argv, mrb_value fmt)
523
565
  {
@@ -708,7 +750,12 @@ retry:
708
750
  }
709
751
  else if (mrb_fixnum_p(val)) {
710
752
  mrb_int n = mrb_fixnum(val);
753
+ #ifndef MRB_UTF8_STRING
754
+ char buf[1];
711
755
 
756
+ buf[0] = (char)n&0xff;
757
+ tmp = mrb_str_new(mrb, buf, 1);
758
+ #else
712
759
  if (n < 0x80) {
713
760
  char buf[1];
714
761
 
@@ -719,6 +766,7 @@ retry:
719
766
  tmp = mrb_funcall(mrb, val, "chr", 0);
720
767
  mrb_check_type(mrb, tmp, MRB_TT_STRING);
721
768
  }
769
+ #endif
722
770
  }
723
771
  else {
724
772
  mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid character");
@@ -866,7 +914,7 @@ retry:
866
914
  width--;
867
915
  }
868
916
  mrb_assert(base == 10);
869
- snprintf(nbuf, sizeof(nbuf), "%" MRB_PRId, v);
917
+ mrb_int2str(nbuf, sizeof(nbuf), v);
870
918
  s = nbuf;
871
919
  if (v < 0) s++; /* skip minus sign */
872
920
  }
@@ -874,24 +922,12 @@ retry:
874
922
  s = nbuf;
875
923
  if (v < 0) {
876
924
  dots = 1;
925
+ val = mrb_fix2binstr(mrb, mrb_fixnum_value(v), base);
877
926
  }
878
- switch (base) {
879
- case 2:
880
- if (v < 0) {
881
- val = mrb_fix2binstr(mrb, mrb_fixnum_value(v), base);
882
- }
883
- else {
884
- val = mrb_fixnum_to_str(mrb, mrb_fixnum_value(v), base);
885
- }
886
- strncpy(++s, RSTRING_PTR(val), sizeof(nbuf)-1);
887
- break;
888
- case 8:
889
- snprintf(++s, sizeof(nbuf)-1, "%" MRB_PRIo, v);
890
- break;
891
- case 16:
892
- snprintf(++s, sizeof(nbuf)-1, "%" MRB_PRIx, v);
893
- break;
927
+ else {
928
+ val = mrb_fixnum_to_str(mrb, mrb_fixnum_value(v), base);
894
929
  }
930
+ strncpy(++s, RSTRING_PTR(val), sizeof(nbuf)-1);
895
931
  if (v < 0) {
896
932
  char d;
897
933
 
@@ -1005,7 +1041,7 @@ retry:
1005
1041
  mrb_value val = GETARG();
1006
1042
  double fval;
1007
1043
  mrb_int need = 6;
1008
- char fbuf[32];
1044
+ char fbuf[64];
1009
1045
 
1010
1046
  fval = mrb_float(mrb_Float(mrb, val));
1011
1047
  if (!isfinite(fval)) {
@@ -1046,7 +1082,6 @@ retry:
1046
1082
  break;
1047
1083
  }
1048
1084
 
1049
- fmt_setup(fbuf, sizeof(fbuf), *p, flags, width, prec);
1050
1085
  need = 0;
1051
1086
  if (*p != 'e' && *p != 'E') {
1052
1087
  int i;
@@ -1068,7 +1103,8 @@ retry:
1068
1103
  need += 20;
1069
1104
 
1070
1105
  CHECK(need);
1071
- n = snprintf(&buf[blen], need, fbuf, fval);
1106
+ fmt_setup(fbuf, sizeof(fbuf), *p, flags, width, prec);
1107
+ n = mrb_float_to_cstr(mrb, &buf[blen], need, fbuf, fval);
1072
1108
  if (n < 0 || n >= need) {
1073
1109
  mrb_raise(mrb, E_RUNTIME_ERROR, "formatting error");
1074
1110
  }
@@ -1110,12 +1146,13 @@ fmt_setup(char *buf, size_t size, int c, int flags, mrb_int width, mrb_int prec)
1110
1146
  if (flags & FSPACE) *buf++ = ' ';
1111
1147
 
1112
1148
  if (flags & FWIDTH) {
1113
- n = snprintf(buf, end - buf, "%d", (int)width);
1149
+ n = mrb_int2str(buf, end - buf, width);
1114
1150
  buf += n;
1115
1151
  }
1116
1152
 
1117
1153
  if (flags & FPREC) {
1118
- n = snprintf(buf, end - buf, ".%d", (int)prec);
1154
+ *buf ++ = '.';
1155
+ n = mrb_int2str(buf, end - buf, prec);
1119
1156
  buf += n;
1120
1157
  }
1121
1158
 
@@ -8,6 +8,11 @@
8
8
  assert_equal 15, ("%b" % (1<<14)).size
9
9
  skip unless Object.const_defined?(:Float)
10
10
  assert_equal "1.0", "%3.1f" % 1.01
11
+ assert_equal " 123456789.12", "% 4.2f" % 123456789.123456789
12
+ assert_equal "123456789.12", "%-4.2f" % 123456789.123456789
13
+ assert_equal "+123456789.12", "%+4.2f" % 123456789.123456789
14
+ assert_equal "123456789.12", "%04.2f" % 123456789.123456789
15
+ assert_equal "00000000123456789.12", "%020.2f" % 123456789.123456789
11
16
  end
12
17
 
13
18
  assert('String#% with inf') do
@@ -68,29 +73,6 @@
68
73
  assert_equal " NaN", "% 5f" % nan
69
74
  end
70
75
 
71
- assert("String#% with invalid chr") do
72
- begin
73
- class Fixnum
74
- alias_method :chr_, :chr if method_defined?(:chr)
75
-
76
- def chr
77
- nil
78
- end
79
- end
80
-
81
- assert_raise TypeError do
82
- "%c" % 0x80
83
- end
84
- ensure
85
- class Fixnum
86
- if method_defined?(:chr_)
87
- alias_method :chr, :chr_
88
- remove_method :chr_
89
- end
90
- end
91
- end
92
- end
93
-
94
76
  assert("String#% %b") do
95
77
  assert_equal("..10115", "%0b5" % -5)
96
78
  end
@@ -335,7 +335,7 @@ tr_parse_pattern(mrb_state *mrb, struct tr_pattern *ret, const mrb_value v_patte
335
335
 
336
336
  len = i - start_pos;
337
337
  if (len > UINT16_MAX) {
338
- mrb_raise(mrb, E_ARGUMENT_ERROR, "tr pattern too long (max 65536)");
338
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "tr pattern too long (max 65535)");
339
339
  }
340
340
  if (pat1 == NULL && ret) {
341
341
  goto nomem;
@@ -343,9 +343,9 @@ tr_parse_pattern(mrb_state *mrb, struct tr_pattern *ret, const mrb_value v_patte
343
343
  pat1->type = TR_IN_ORDER;
344
344
  pat1->flag_reverse = flag_reverse;
345
345
  pat1->flag_on_heap = !ret_uninit;
346
- pat1->n = len;
346
+ pat1->n = (uint16_t)len;
347
347
  pat1->next = NULL;
348
- pat1->val.start_pos = start_pos;
348
+ pat1->val.start_pos = (uint16_t)start_pos;
349
349
  }
350
350
 
351
351
  if (ret == NULL || ret_uninit) {
@@ -47,7 +47,7 @@ mrb_sym_length(mrb_state *mrb, mrb_value self)
47
47
  #ifdef MRB_UTF8_STRING
48
48
  mrb_int byte_len;
49
49
  const char *name = mrb_sym_name_len(mrb, mrb_symbol(self), &byte_len);
50
- len = mrb_utf8_len(name, byte_len);
50
+ len = mrb_utf8_strlen(name, byte_len);
51
51
  #else
52
52
  mrb_sym_name_len(mrb, mrb_symbol(self), &len);
53
53
  #endif
@@ -26,6 +26,7 @@
26
26
 
27
27
  file assert_lib => assert_c
28
28
  file assert_c => [assert_rb, build.mrbcfile] do |t|
29
+ mkdir_p File.dirname(t.name)
29
30
  open(t.name, 'w') do |f|
30
31
  mrbc.run f, assert_rb, 'mrbtest_assert_irep'
31
32
  end
@@ -13,10 +13,9 @@
13
13
  #include <mruby/data.h>
14
14
  #include <mruby/numeric.h>
15
15
  #include <mruby/time.h>
16
+ #include <mruby/string.h>
16
17
 
17
- #ifndef MRB_DISABLE_STDIO
18
- #include <stdio.h>
19
- #else
18
+ #ifdef MRB_DISABLE_STDIO
20
19
  #include <string.h>
21
20
  #endif
22
21
 
@@ -238,7 +237,7 @@ mrb_to_time_t(mrb_state *mrb, mrb_value obj, time_t *usec)
238
237
  mrb_float f = mrb_float(obj);
239
238
 
240
239
  mrb_check_num_exact(mrb, f);
241
- if (f > (mrb_float)MRB_TIME_MAX || (mrb_float)MRB_TIME_MIN > f) {
240
+ if (f >= ((mrb_float)MRB_TIME_MAX-1.0) || f < ((mrb_float)MRB_TIME_MIN+1.0)) {
242
241
  goto out_of_range;
243
242
  }
244
243
 
@@ -956,7 +955,9 @@ mrb_time_to_s(mrb_state *mrb, mrb_value self)
956
955
  struct mrb_time *tm = time_get_ptr(mrb, self);
957
956
  mrb_bool utc = tm->timezone == MRB_TIMEZONE_UTC;
958
957
  size_t len = (utc ? time_to_s_utc : time_to_s_local)(mrb, tm, buf, sizeof(buf));
959
- return mrb_str_new(mrb, buf, len);
958
+ mrb_value str = mrb_str_new(mrb, buf, len);
959
+ RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
960
+ return str;
960
961
  }
961
962
 
962
963
  void
@@ -140,7 +140,7 @@ def each_key(&block)
140
140
  def each_value(&block)
141
141
  return to_enum :each_value unless block
142
142
 
143
- self.keys.each{|k| block.call(self[k])}
143
+ self.values.each{|v| block.call(v)}
144
144
  self
145
145
  end
146
146
 
@@ -192,11 +192,11 @@ def _inspect(recur_list)
192
192
  recur_list[self.object_id] = true
193
193
  ary=[]
194
194
  keys=self.keys
195
+ vals=self.values
195
196
  size=keys.size
196
197
  i=0
197
198
  while i<size
198
- k=keys[i]
199
- ary<<(k._inspect(recur_list) + "=>" + self[k]._inspect(recur_list))
199
+ ary<<(keys[i]._inspect(recur_list) + "=>" + vals[i]._inspect(recur_list))
200
200
  i+=1
201
201
  end
202
202
  "{"+ary.join(", ")+"}"
@@ -732,6 +732,10 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val
732
732
  argv = ARY_PTR(r);
733
733
  }
734
734
  }
735
+ else if (mrb_undef_p(rpl)) {
736
+ argc = 0;
737
+ argv = NULL;
738
+ }
735
739
  else {
736
740
  argc = 1;
737
741
  argv = &rpl;
@@ -804,6 +808,13 @@ ary_subseq(mrb_state *mrb, struct RArray *a, mrb_int beg, mrb_int len)
804
808
  return mrb_obj_value(b);
805
809
  }
806
810
 
811
+ mrb_value
812
+ mrb_ary_subseq(mrb_state *mrb, mrb_value ary, mrb_int beg, mrb_int len)
813
+ {
814
+ struct RArray *a = mrb_ary_ptr(ary);
815
+ return ary_subseq(mrb, a, beg, len);
816
+ }
817
+
807
818
  static mrb_int
808
819
  aget_index(mrb_state *mrb, mrb_value index)
809
820
  {
@@ -79,7 +79,7 @@ each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, const mrb_code *pc0, each_backtr
79
79
  static void
80
80
  print_backtrace(mrb_state *mrb, struct RObject *exc, mrb_value backtrace)
81
81
  {
82
- int i;
82
+ mrb_int i;
83
83
  mrb_int n = RARRAY_LEN(backtrace);
84
84
  mrb_value *loc, mesg;
85
85
  FILE *stream = stderr;
@@ -89,7 +89,7 @@ print_backtrace(mrb_state *mrb, struct RObject *exc, mrb_value backtrace)
89
89
  for (i=n-1,loc=&RARRAY_PTR(backtrace)[i]; i>0; i--,loc--) {
90
90
  if (mrb_string_p(*loc)) {
91
91
  fprintf(stream, "\t[%d] %.*s\n",
92
- i, (int)RSTRING_LEN(*loc), RSTRING_PTR(*loc));
92
+ (int)i, (int)RSTRING_LEN(*loc), RSTRING_PTR(*loc));
93
93
  }
94
94
  }
95
95
  if (mrb_string_p(*loc)) {