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.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/ext/enterprise_script_service/libseccomp/.travis.yml +3 -5
- data/ext/enterprise_script_service/libseccomp/CHANGELOG +10 -0
- data/ext/enterprise_script_service/libseccomp/CREDITS +3 -0
- data/ext/enterprise_script_service/libseccomp/README.md +18 -0
- data/ext/enterprise_script_service/libseccomp/configure.ac +1 -1
- data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +7 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +16 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +16 -0
- data/ext/enterprise_script_service/libseccomp/tests/.gitignore +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/15-basic-resolver.c +3 -3
- data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.c +48 -0
- data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.py +38 -0
- data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +6 -3
- data/ext/enterprise_script_service/libseccomp/tests/regression +4 -0
- data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -3
- data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +2 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/build.yml +106 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/main.yml +24 -0
- data/ext/enterprise_script_service/mruby/.gitignore +3 -0
- data/ext/enterprise_script_service/mruby/.travis.yml +6 -9
- data/ext/enterprise_script_service/mruby/AUTHORS +1 -0
- data/ext/enterprise_script_service/mruby/Doxyfile +1 -1
- data/ext/enterprise_script_service/mruby/LICENSE +1 -1
- data/ext/enterprise_script_service/mruby/README.md +6 -2
- data/ext/enterprise_script_service/mruby/appveyor.yml +9 -12
- data/ext/enterprise_script_service/mruby/appveyor_config.rb +9 -0
- data/ext/enterprise_script_service/mruby/build_config.rb +6 -6
- data/ext/enterprise_script_service/mruby/doc/guides/compile.md +6 -2
- data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +1 -1
- data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +4 -8
- data/ext/enterprise_script_service/mruby/doc/limitations.md +10 -10
- data/ext/enterprise_script_service/mruby/doc/opcode.md +108 -95
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_ArduinoDue.rb +2 -2
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_IntelEdison.rb +2 -2
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_IntelGalileo.rb +2 -2
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_RX630.rb +2 -2
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_chipKITMax32.rb +2 -2
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_dreamcast_shelf.rb +108 -0
- data/ext/enterprise_script_service/mruby/include/mrbconf.h +10 -7
- data/ext/enterprise_script_service/mruby/include/mruby.h +11 -9
- data/ext/enterprise_script_service/mruby/include/mruby/array.h +4 -0
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +11 -2
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +0 -9
- data/ext/enterprise_script_service/mruby/include/mruby/common.h +10 -0
- data/ext/enterprise_script_service/mruby/include/mruby/compile.h +11 -3
- data/ext/enterprise_script_service/mruby/include/mruby/dump.h +1 -17
- data/ext/enterprise_script_service/mruby/include/mruby/irep.h +10 -0
- data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -1
- data/ext/enterprise_script_service/mruby/include/mruby/khash.h +23 -5
- data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +1 -0
- data/ext/enterprise_script_service/mruby/include/mruby/ops.h +3 -2
- data/ext/enterprise_script_service/mruby/include/mruby/string.h +2 -1
- data/ext/enterprise_script_service/mruby/include/mruby/value.h +7 -12
- data/ext/enterprise_script_service/mruby/include/mruby/version.h +4 -4
- data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +2 -30
- data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +21 -46
- data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +9 -0
- data/ext/enterprise_script_service/mruby/lib/mruby/source.rb +3 -1
- data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +7 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +0 -31
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +0 -13
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mrbgem.rake +5 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +5 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +5 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +7 -11
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +6 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +6 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +6 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +76 -48
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +107 -32
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/y.tab.c +13153 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/mrbgem.rake +13 -15
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +3 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +2 -213
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +21 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +1 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/include/mruby/ext/io.h +39 -7
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +2 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file_constants.rb +0 -16
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +7 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +76 -30
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +9 -10
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +323 -120
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +18 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +32 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +57 -49
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +15 -17
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +9 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +3 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +113 -10
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +5 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +9 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/src/mrb_sleep.c +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrbgem.rake +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/test/sockettest.c +3 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +61 -24
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +5 -23
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +3 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +1 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +6 -5
- data/ext/enterprise_script_service/mruby/mrblib/hash.rb +3 -3
- data/ext/enterprise_script_service/mruby/src/array.c +11 -0
- data/ext/enterprise_script_service/mruby/src/backtrace.c +2 -2
- data/ext/enterprise_script_service/mruby/src/class.c +26 -11
- data/ext/enterprise_script_service/mruby/src/codedump.c +4 -0
- data/ext/enterprise_script_service/mruby/src/debug.c +8 -5
- data/ext/enterprise_script_service/mruby/src/dump.c +3 -65
- data/ext/enterprise_script_service/mruby/src/error.c +57 -5
- data/ext/enterprise_script_service/mruby/src/etc.c +13 -4
- data/ext/enterprise_script_service/mruby/src/fmt_fp.c +98 -21
- data/ext/enterprise_script_service/mruby/src/gc.c +10 -275
- data/ext/enterprise_script_service/mruby/src/hash.c +5 -6
- data/ext/enterprise_script_service/mruby/src/kernel.c +2 -2
- data/ext/enterprise_script_service/mruby/src/load.c +56 -30
- data/ext/enterprise_script_service/mruby/src/numeric.c +22 -10
- data/ext/enterprise_script_service/mruby/src/object.c +12 -4
- data/ext/enterprise_script_service/mruby/src/print.c +27 -3
- data/ext/enterprise_script_service/mruby/src/proc.c +21 -1
- data/ext/enterprise_script_service/mruby/src/state.c +34 -11
- data/ext/enterprise_script_service/mruby/src/string.c +69 -35
- data/ext/enterprise_script_service/mruby/src/symbol.c +12 -10
- data/ext/enterprise_script_service/mruby/src/vm.c +21 -30
- data/ext/enterprise_script_service/mruby/tasks/gitlab.rake +19 -22
- data/ext/enterprise_script_service/mruby/tasks/mrbgems.rake +1 -1
- data/ext/enterprise_script_service/mruby/tasks/toolchains/android.rake +46 -1
- data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +3 -3
- data/ext/enterprise_script_service/mruby/tasks/toolchains/openwrt.rake +6 -6
- data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +8 -8
- data/ext/enterprise_script_service/mruby/test/assert.rb +5 -4
- data/ext/enterprise_script_service/mruby/test/t/ensure.rb +8 -26
- data/ext/enterprise_script_service/mruby/test/t/exception.rb +2 -2
- data/ext/enterprise_script_service/mruby/test/t/kernel.rb +8 -24
- data/ext/enterprise_script_service/mruby/travis_config.rb +0 -14
- data/ext/enterprise_script_service/msgpack/.github/depends/boost.sh +56 -0
- data/ext/enterprise_script_service/msgpack/.github/workflows/coverage.yml +62 -0
- data/ext/enterprise_script_service/msgpack/.github/workflows/gha.yml +304 -0
- data/ext/enterprise_script_service/msgpack/CHANGELOG.md +11 -0
- data/ext/enterprise_script_service/msgpack/CMakeLists.txt +82 -39
- data/ext/enterprise_script_service/msgpack/Files.cmake +22 -12
- data/ext/enterprise_script_service/msgpack/QUICKSTART-C.md +26 -29
- data/ext/enterprise_script_service/msgpack/README.md +3 -2
- data/ext/enterprise_script_service/msgpack/appveyor.yml +6 -2
- data/ext/enterprise_script_service/msgpack/ci/build_cmake.sh +3 -1
- data/ext/enterprise_script_service/msgpack/cmake/CodeCoverage.cmake +55 -0
- data/ext/enterprise_script_service/msgpack/codecov.yml +36 -0
- data/ext/enterprise_script_service/msgpack/example/CMakeLists.txt +9 -5
- data/ext/enterprise_script_service/msgpack/example/boost/CMakeLists.txt +1 -1
- data/ext/enterprise_script_service/msgpack/example/c/CMakeLists.txt +17 -6
- data/ext/enterprise_script_service/msgpack/example/c/boundary.c +296 -0
- data/ext/enterprise_script_service/msgpack/example/c/jsonconv.c +419 -0
- data/ext/enterprise_script_service/msgpack/example/c/simple_c.c +1 -1
- data/ext/enterprise_script_service/msgpack/example/cpp03/CMakeLists.txt +3 -3
- data/ext/enterprise_script_service/msgpack/example/cpp11/CMakeLists.txt +2 -2
- data/ext/enterprise_script_service/msgpack/example/x3/CMakeLists.txt +2 -2
- data/ext/enterprise_script_service/msgpack/include/msgpack/pack.h +24 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +5 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/boost/optional.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp17/vector_byte.hpp +8 -8
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/map.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_char.hpp +8 -8
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_unsigned_char.hpp +8 -8
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v3/unpack.hpp +6 -6
- data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
- data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +4 -4
- data/ext/enterprise_script_service/msgpack/make_file_list.sh +38 -11
- data/ext/enterprise_script_service/msgpack/src/vrefbuffer.c +6 -0
- data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +86 -64
- data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +4 -1
- data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/buffer.cpp +4 -47
- data/ext/enterprise_script_service/msgpack/test/buffer_c.cpp +148 -0
- data/ext/enterprise_script_service/msgpack/test/carray.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/cases.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/convert.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/fixint.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/json.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/limit.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +159 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +32 -27
- data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +4 -1
- data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/object.cpp +4 -1
- data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +12 -8
- data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +30 -26
- data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/raw.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/reference.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/streaming.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/user_class.cpp +16 -12
- data/ext/enterprise_script_service/msgpack/test/version.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/visitor.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/zone.cpp +4 -0
- data/lib/script_core/version.rb +1 -1
- data/script_core.gemspec +1 -1
- metadata +23 -9
- data/ext/enterprise_script_service/msgpack/.travis.yml +0 -258
@@ -210,26 +210,30 @@ static mrb_value
|
|
210
210
|
flo_to_s(mrb_state *mrb, mrb_value flt)
|
211
211
|
{
|
212
212
|
mrb_float f = mrb_float(flt);
|
213
|
+
mrb_value str;
|
213
214
|
|
214
215
|
if (isinf(f)) {
|
215
|
-
|
216
|
-
|
216
|
+
str = f < 0 ? mrb_str_new_lit(mrb, "-Infinity")
|
217
|
+
: mrb_str_new_lit(mrb, "Infinity");
|
218
|
+
goto exit;
|
217
219
|
}
|
218
220
|
else if (isnan(f)) {
|
219
|
-
|
221
|
+
str = mrb_str_new_lit(mrb, "NaN");
|
222
|
+
goto exit;
|
220
223
|
}
|
221
224
|
else {
|
222
225
|
char fmt[] = "%." MRB_STRINGIZE(FLO_TO_STR_PREC) "g";
|
223
|
-
mrb_value str = mrb_float_to_str(mrb, flt, fmt);
|
224
226
|
mrb_int len;
|
225
227
|
char *begp, *p, *endp;
|
226
228
|
|
229
|
+
str = mrb_float_to_str(mrb, flt, fmt);
|
230
|
+
|
227
231
|
insert_dot_zero:
|
228
232
|
begp = RSTRING_PTR(str);
|
229
233
|
len = RSTRING_LEN(str);
|
230
234
|
for (p = begp, endp = p + len; p < endp; ++p) {
|
231
235
|
if (*p == '.') {
|
232
|
-
|
236
|
+
goto exit;
|
233
237
|
}
|
234
238
|
else if (*p == 'e') {
|
235
239
|
ptrdiff_t e_pos = p - begp;
|
@@ -237,7 +241,7 @@ flo_to_s(mrb_state *mrb, mrb_value flt)
|
|
237
241
|
p = RSTRING_PTR(str) + e_pos;
|
238
242
|
memmove(p + 2, p, len - e_pos);
|
239
243
|
memcpy(p, ".0", 2);
|
240
|
-
|
244
|
+
goto exit;
|
241
245
|
}
|
242
246
|
}
|
243
247
|
|
@@ -247,8 +251,12 @@ flo_to_s(mrb_state *mrb, mrb_value flt)
|
|
247
251
|
goto insert_dot_zero;
|
248
252
|
}
|
249
253
|
|
250
|
-
|
254
|
+
goto exit;
|
251
255
|
}
|
256
|
+
|
257
|
+
exit:
|
258
|
+
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
|
259
|
+
return str;
|
252
260
|
}
|
253
261
|
|
254
262
|
/* 15.2.9.3.2 */
|
@@ -1383,6 +1391,7 @@ mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, mrb_int base)
|
|
1383
1391
|
char buf[MRB_INT_BIT+1];
|
1384
1392
|
char *b = buf + sizeof buf;
|
1385
1393
|
mrb_int val = mrb_fixnum(x);
|
1394
|
+
mrb_value str;
|
1386
1395
|
|
1387
1396
|
if (base < 2 || 36 < base) {
|
1388
1397
|
mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid radix %i", base);
|
@@ -1403,7 +1412,9 @@ mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, mrb_int base)
|
|
1403
1412
|
} while (val /= base);
|
1404
1413
|
}
|
1405
1414
|
|
1406
|
-
|
1415
|
+
str = mrb_str_new(mrb, b, buf + sizeof(buf) - b);
|
1416
|
+
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
|
1417
|
+
return str;
|
1407
1418
|
}
|
1408
1419
|
|
1409
1420
|
/* 15.2.8.3.25 */
|
@@ -1474,13 +1485,14 @@ cmpnum(mrb_state *mrb, mrb_value v1, mrb_value v2)
|
|
1474
1485
|
/* 15.2.9.3.6 */
|
1475
1486
|
/*
|
1476
1487
|
* call-seq:
|
1477
|
-
* self.f <=> other.f => -1, 0, +1
|
1488
|
+
* self.f <=> other.f => -1, 0, +1, or nil
|
1478
1489
|
* < => -1
|
1479
1490
|
* = => 0
|
1480
1491
|
* > => +1
|
1481
1492
|
* Comparison---Returns -1, 0, or +1 depending on whether <i>fix</i> is
|
1482
1493
|
* less than, equal to, or greater than <i>numeric</i>. This is the
|
1483
|
-
* basis for the tests in <code>Comparable</code>.
|
1494
|
+
* basis for the tests in <code>Comparable</code>. When the operands are
|
1495
|
+
* not comparable, it returns nil instead of raising an exception.
|
1484
1496
|
*/
|
1485
1497
|
static mrb_value
|
1486
1498
|
integral_cmp(mrb_state *mrb, mrb_value self)
|
@@ -83,13 +83,17 @@ mrb_true(mrb_state *mrb, mrb_value obj)
|
|
83
83
|
static mrb_value
|
84
84
|
nil_to_s(mrb_state *mrb, mrb_value obj)
|
85
85
|
{
|
86
|
-
|
86
|
+
mrb_value str = mrb_str_new_frozen(mrb, 0, 0);
|
87
|
+
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
|
88
|
+
return str;
|
87
89
|
}
|
88
90
|
|
89
91
|
static mrb_value
|
90
92
|
nil_inspect(mrb_state *mrb, mrb_value obj)
|
91
93
|
{
|
92
|
-
|
94
|
+
mrb_value str = mrb_str_new_lit_frozen(mrb, "nil");
|
95
|
+
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
|
96
|
+
return str;
|
93
97
|
}
|
94
98
|
|
95
99
|
/***********************************************************************
|
@@ -150,7 +154,9 @@ true_xor(mrb_state *mrb, mrb_value obj)
|
|
150
154
|
static mrb_value
|
151
155
|
true_to_s(mrb_state *mrb, mrb_value obj)
|
152
156
|
{
|
153
|
-
|
157
|
+
mrb_value str = mrb_str_new_lit_frozen(mrb, "true");
|
158
|
+
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
|
159
|
+
return str;
|
154
160
|
}
|
155
161
|
|
156
162
|
/* 15.2.5.3.4 */
|
@@ -257,7 +263,9 @@ false_or(mrb_state *mrb, mrb_value obj)
|
|
257
263
|
static mrb_value
|
258
264
|
false_to_s(mrb_state *mrb, mrb_value obj)
|
259
265
|
{
|
260
|
-
|
266
|
+
mrb_value str = mrb_str_new_lit_frozen(mrb, "false");
|
267
|
+
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
|
268
|
+
return str;
|
261
269
|
}
|
262
270
|
|
263
271
|
void
|
@@ -7,24 +7,48 @@
|
|
7
7
|
#include <mruby.h>
|
8
8
|
#include <mruby/string.h>
|
9
9
|
#include <mruby/variable.h>
|
10
|
+
#include <mruby/error.h>
|
11
|
+
#include <string.h>
|
10
12
|
|
11
13
|
#ifndef MRB_DISABLE_STDIO
|
14
|
+
static void
|
15
|
+
printcstr(const char *str, size_t len, FILE *stream)
|
16
|
+
{
|
17
|
+
if (str) {
|
18
|
+
fwrite(str, len, 1, stream);
|
19
|
+
putc('\n', stream);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
12
23
|
static void
|
13
24
|
printstr(mrb_value obj, FILE *stream)
|
14
25
|
{
|
15
26
|
if (mrb_string_p(obj)) {
|
16
|
-
|
17
|
-
putc('\n', stream);
|
27
|
+
printcstr(RSTRING_PTR(obj), RSTRING_LEN(obj), stream);
|
18
28
|
}
|
19
29
|
}
|
20
30
|
#else
|
31
|
+
# define printcstr(str, len, stream) (void)0
|
21
32
|
# define printstr(obj, stream) (void)0
|
22
33
|
#endif
|
23
34
|
|
35
|
+
void
|
36
|
+
mrb_core_init_printabort(void)
|
37
|
+
{
|
38
|
+
static const char *str = "Failed mruby core initialization";
|
39
|
+
printcstr(str, strlen(str), stdout);
|
40
|
+
}
|
41
|
+
|
24
42
|
MRB_API void
|
25
43
|
mrb_p(mrb_state *mrb, mrb_value obj)
|
26
44
|
{
|
27
|
-
|
45
|
+
if (mrb_type(obj) == MRB_TT_EXCEPTION && mrb_obj_ptr(obj) == mrb->nomem_err) {
|
46
|
+
static const char *str = "Out of memory";
|
47
|
+
printcstr(str, strlen(str), stdout);
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
printstr(mrb_inspect(mrb, obj), stdout);
|
51
|
+
}
|
28
52
|
}
|
29
53
|
|
30
54
|
MRB_API void
|
@@ -8,6 +8,7 @@
|
|
8
8
|
#include <mruby/class.h>
|
9
9
|
#include <mruby/proc.h>
|
10
10
|
#include <mruby/opcode.h>
|
11
|
+
#include <mruby/data.h>
|
11
12
|
|
12
13
|
static const mrb_code call_iseq[] = {
|
13
14
|
OP_CALL,
|
@@ -122,7 +123,14 @@ mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const
|
|
122
123
|
p->flags |= MRB_PROC_ENVSET;
|
123
124
|
mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)e);
|
124
125
|
MRB_ENV_UNSHARE_STACK(e);
|
126
|
+
|
127
|
+
/* NOTE: Prevents keeping invalid addresses when NoMemoryError is raised from `mrb_malloc()`. */
|
128
|
+
e->stack = NULL;
|
129
|
+
MRB_ENV_SET_STACK_LEN(e, 0);
|
130
|
+
|
125
131
|
e->stack = (mrb_value*)mrb_malloc(mrb, sizeof(mrb_value) * argc);
|
132
|
+
MRB_ENV_SET_STACK_LEN(e, argc);
|
133
|
+
|
126
134
|
if (argv) {
|
127
135
|
for (i = 0; i < argc; ++i) {
|
128
136
|
e->stack[i] = argv[i];
|
@@ -286,14 +294,25 @@ mrb_proc_arity(const struct RProc *p)
|
|
286
294
|
return arity;
|
287
295
|
}
|
288
296
|
|
297
|
+
static void
|
298
|
+
tempirep_free(mrb_state *mrb, void *p)
|
299
|
+
{
|
300
|
+
if (p) mrb_irep_free(mrb, (mrb_irep *)p);
|
301
|
+
}
|
302
|
+
|
303
|
+
static const mrb_data_type tempirep_type = { "temporary irep", tempirep_free };
|
304
|
+
|
289
305
|
void
|
290
306
|
mrb_init_proc(mrb_state *mrb)
|
291
307
|
{
|
292
308
|
struct RProc *p;
|
293
309
|
mrb_method_t m;
|
294
|
-
|
310
|
+
struct RData *irep_obj = mrb_data_object_alloc(mrb, mrb->object_class, NULL, &tempirep_type);
|
311
|
+
mrb_irep *call_irep;
|
295
312
|
static const mrb_irep mrb_irep_zero = { 0 };
|
296
313
|
|
314
|
+
call_irep = (mrb_irep *)mrb_malloc(mrb, sizeof(mrb_irep));
|
315
|
+
irep_obj->data = call_irep;
|
297
316
|
*call_irep = mrb_irep_zero;
|
298
317
|
call_irep->flags = MRB_ISEQ_NO_FREE;
|
299
318
|
call_irep->iseq = call_iseq;
|
@@ -305,6 +324,7 @@ mrb_init_proc(mrb_state *mrb)
|
|
305
324
|
mrb_define_method(mrb, mrb->proc_class, "arity", proc_arity, MRB_ARGS_NONE());
|
306
325
|
|
307
326
|
p = mrb_proc_new(mrb, call_irep);
|
327
|
+
irep_obj->data = NULL;
|
308
328
|
MRB_METHOD_FROM_PROC(m, p);
|
309
329
|
mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern_lit(mrb, "call"), m);
|
310
330
|
mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern_lit(mrb, "[]"), m);
|
@@ -19,11 +19,25 @@ void mrb_init_mrbgems(mrb_state*);
|
|
19
19
|
void mrb_gc_init(mrb_state*, mrb_gc *gc);
|
20
20
|
void mrb_gc_destroy(mrb_state*, mrb_gc *gc);
|
21
21
|
|
22
|
+
int mrb_core_init_protect(mrb_state *mrb, void (*body)(mrb_state *, void *), void *opaque);
|
23
|
+
|
24
|
+
static void
|
25
|
+
init_gc_and_core(mrb_state *mrb, void *opaque)
|
26
|
+
{
|
27
|
+
static const struct mrb_context mrb_context_zero = { 0 };
|
28
|
+
|
29
|
+
mrb_gc_init(mrb, &mrb->gc);
|
30
|
+
mrb->c = (struct mrb_context*)mrb_malloc(mrb, sizeof(struct mrb_context));
|
31
|
+
*mrb->c = mrb_context_zero;
|
32
|
+
mrb->root_c = mrb->c;
|
33
|
+
|
34
|
+
mrb_init_core(mrb);
|
35
|
+
}
|
36
|
+
|
22
37
|
MRB_API mrb_state*
|
23
38
|
mrb_open_core(mrb_allocf f, void *ud)
|
24
39
|
{
|
25
40
|
static const mrb_state mrb_state_zero = { 0 };
|
26
|
-
static const struct mrb_context mrb_context_zero = { 0 };
|
27
41
|
mrb_state *mrb;
|
28
42
|
|
29
43
|
if (f == NULL) f = mrb_default_allocf;
|
@@ -35,12 +49,10 @@ mrb_open_core(mrb_allocf f, void *ud)
|
|
35
49
|
mrb->allocf = f;
|
36
50
|
mrb->atexit_stack_len = 0;
|
37
51
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
mrb_init_core(mrb);
|
52
|
+
if (mrb_core_init_protect(mrb, init_gc_and_core, NULL)) {
|
53
|
+
mrb_close(mrb);
|
54
|
+
return NULL;
|
55
|
+
}
|
44
56
|
|
45
57
|
return mrb;
|
46
58
|
}
|
@@ -65,6 +77,12 @@ mrb_open(void)
|
|
65
77
|
return mrb;
|
66
78
|
}
|
67
79
|
|
80
|
+
static void
|
81
|
+
init_mrbgems(mrb_state *mrb, void *opaque)
|
82
|
+
{
|
83
|
+
mrb_init_mrbgems(mrb);
|
84
|
+
}
|
85
|
+
|
68
86
|
MRB_API mrb_state*
|
69
87
|
mrb_open_allocf(mrb_allocf f, void *ud)
|
70
88
|
{
|
@@ -75,7 +93,10 @@ mrb_open_allocf(mrb_allocf f, void *ud)
|
|
75
93
|
}
|
76
94
|
|
77
95
|
#ifndef DISABLE_GEMS
|
78
|
-
|
96
|
+
if (mrb_core_init_protect(mrb, init_mrbgems, NULL)) {
|
97
|
+
mrb_close(mrb);
|
98
|
+
return NULL;
|
99
|
+
}
|
79
100
|
mrb_gc_arena_restore(mrb, 0);
|
80
101
|
#endif
|
81
102
|
return mrb;
|
@@ -131,9 +152,11 @@ mrb_irep_free(mrb_state *mrb, mrb_irep *irep)
|
|
131
152
|
}
|
132
153
|
mrb_free(mrb, irep->pool);
|
133
154
|
mrb_free(mrb, irep->syms);
|
134
|
-
|
135
|
-
|
136
|
-
|
155
|
+
if (irep->reps) {
|
156
|
+
for (i=0; i<irep->rlen; i++) {
|
157
|
+
if (irep->reps[i])
|
158
|
+
mrb_irep_decref(mrb, irep->reps[i]);
|
159
|
+
}
|
137
160
|
}
|
138
161
|
mrb_free(mrb, irep->reps);
|
139
162
|
mrb_free(mrb, irep->lv);
|
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
#ifndef MRB_WITHOUT_FLOAT
|
12
12
|
#include <float.h>
|
13
|
+
#include <math.h>
|
13
14
|
#endif
|
14
15
|
#include <limits.h>
|
15
16
|
#include <stddef.h>
|
@@ -300,8 +301,8 @@ static const char utf8len_codepage[256] =
|
|
300
301
|
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,
|
301
302
|
};
|
302
303
|
|
303
|
-
|
304
|
-
|
304
|
+
mrb_int
|
305
|
+
mrb_utf8len(const char* p, const char* e)
|
305
306
|
{
|
306
307
|
mrb_int len;
|
307
308
|
mrb_int i;
|
@@ -317,14 +318,14 @@ utf8len(const char* p, const char* e)
|
|
317
318
|
}
|
318
319
|
|
319
320
|
mrb_int
|
320
|
-
|
321
|
+
mrb_utf8_strlen(const char *str, mrb_int byte_len)
|
321
322
|
{
|
322
323
|
mrb_int total = 0;
|
323
324
|
const char *p = str;
|
324
325
|
const char *e = p + byte_len;
|
325
326
|
|
326
327
|
while (p < e) {
|
327
|
-
p +=
|
328
|
+
p += mrb_utf8len(p, e);
|
328
329
|
total++;
|
329
330
|
}
|
330
331
|
return total;
|
@@ -340,7 +341,7 @@ utf8_strlen(mrb_value str)
|
|
340
341
|
return byte_len;
|
341
342
|
}
|
342
343
|
else {
|
343
|
-
mrb_int utf8_len =
|
344
|
+
mrb_int utf8_len = mrb_utf8_strlen(RSTR_PTR(s), byte_len);
|
344
345
|
if (byte_len == utf8_len) RSTR_SET_ASCII_FLAG(s);
|
345
346
|
return utf8_len;
|
346
347
|
}
|
@@ -361,7 +362,7 @@ chars2bytes(mrb_value s, mrb_int off, mrb_int idx)
|
|
361
362
|
const char *e = RSTRING_END(s);
|
362
363
|
|
363
364
|
for (b=i=0; p<e && i<idx; i++) {
|
364
|
-
n =
|
365
|
+
n = mrb_utf8len(p, e);
|
365
366
|
b += n;
|
366
367
|
p += n;
|
367
368
|
}
|
@@ -378,7 +379,7 @@ bytes2chars(char *p, mrb_int len, mrb_int bi)
|
|
378
379
|
mrb_int i;
|
379
380
|
|
380
381
|
for (i = 0; p < pivot; i ++) {
|
381
|
-
p +=
|
382
|
+
p += mrb_utf8len(p, e);
|
382
383
|
}
|
383
384
|
if (p != pivot) return -1;
|
384
385
|
return i;
|
@@ -399,7 +400,7 @@ char_adjust(const char *beg, const char *end, const char *ptr)
|
|
399
400
|
while (p > beg) {
|
400
401
|
p --;
|
401
402
|
if ((*p & 0xc0) != 0x80) {
|
402
|
-
int clen =
|
403
|
+
int clen = mrb_utf8len(p, end);
|
403
404
|
if (clen > ptr - p) return p;
|
404
405
|
break;
|
405
406
|
}
|
@@ -462,10 +463,10 @@ str_index_str_by_char_search(mrb_state *mrb, const char *p, const char *pend, co
|
|
462
463
|
}
|
463
464
|
|
464
465
|
pivot = p + qstable[(unsigned char)p[slen - 1]];
|
465
|
-
if (pivot
|
466
|
+
if (pivot >= pend || pivot < p /* overflowed */) { return -1; }
|
466
467
|
|
467
468
|
do {
|
468
|
-
p +=
|
469
|
+
p += mrb_utf8len(p, pend);
|
469
470
|
off ++;
|
470
471
|
} while (p < pivot);
|
471
472
|
}
|
@@ -484,7 +485,7 @@ str_index_str_by_char(mrb_state *mrb, mrb_value str, mrb_value sub, mrb_int pos)
|
|
484
485
|
|
485
486
|
for (; pos > 0; pos --) {
|
486
487
|
if (pend - p < 1) { return -1; }
|
487
|
-
p +=
|
488
|
+
p += mrb_utf8len(p, pend);
|
488
489
|
}
|
489
490
|
|
490
491
|
if (slen < 1) { return off; }
|
@@ -503,25 +504,45 @@ str_index_str_by_char(mrb_state *mrb, mrb_value str, mrb_value sub, mrb_int pos)
|
|
503
504
|
#define str_index_str_by_char(mrb, str, sub, pos) str_index_str(mrb, str, sub, pos)
|
504
505
|
#endif
|
505
506
|
|
507
|
+
#ifndef MRB_QS_SHORT_STRING_LENGTH
|
508
|
+
#define MRB_QS_SHORT_STRING_LENGTH 2048
|
509
|
+
#endif
|
510
|
+
|
506
511
|
static inline mrb_int
|
507
512
|
mrb_memsearch_qs(const unsigned char *xs, mrb_int m, const unsigned char *ys, mrb_int n)
|
508
513
|
{
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
ptrdiff_t qstable[256];
|
514
|
+
if (n + m < MRB_QS_SHORT_STRING_LENGTH) {
|
515
|
+
const unsigned char *y = ys;
|
516
|
+
const unsigned char *ye = ys+n-m+1;
|
513
517
|
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
518
|
+
for (;;) {
|
519
|
+
y = (const unsigned char*)memchr(y, xs[0], (size_t)(ye-y));
|
520
|
+
if (y == NULL) return -1;
|
521
|
+
if (memcmp(xs, y, m) == 0) {
|
522
|
+
return (mrb_int)(y - ys);
|
523
|
+
}
|
524
|
+
y++;
|
525
|
+
}
|
526
|
+
return -1;
|
527
|
+
}
|
528
|
+
else {
|
529
|
+
const unsigned char *x = xs, *xe = xs + m;
|
530
|
+
const unsigned char *y = ys;
|
531
|
+
int i;
|
532
|
+
ptrdiff_t qstable[256];
|
533
|
+
|
534
|
+
/* Preprocessing */
|
535
|
+
for (i = 0; i < 256; ++i)
|
536
|
+
qstable[i] = m + 1;
|
537
|
+
for (; x < xe; ++x)
|
538
|
+
qstable[*x] = xe - x;
|
539
|
+
/* Searching */
|
540
|
+
for (; y + m <= ys + n; y += *(qstable + y[m])) {
|
541
|
+
if (*xs == *y && memcmp(xs, y, m) == 0)
|
542
|
+
return (mrb_int)(y - ys);
|
543
|
+
}
|
544
|
+
return -1;
|
523
545
|
}
|
524
|
-
return -1;
|
525
546
|
}
|
526
547
|
|
527
548
|
static mrb_int
|
@@ -1341,7 +1362,7 @@ str_escape(mrb_state *mrb, mrb_value str, mrb_bool inspect)
|
|
1341
1362
|
unsigned char c, cc;
|
1342
1363
|
#ifdef MRB_UTF8_STRING
|
1343
1364
|
if (inspect) {
|
1344
|
-
mrb_int clen =
|
1365
|
+
mrb_int clen = mrb_utf8len(p, pend);
|
1345
1366
|
if (clen > 1) {
|
1346
1367
|
mrb_int i;
|
1347
1368
|
|
@@ -1644,7 +1665,7 @@ mrb_str_chop_bang(mrb_state *mrb, mrb_value str)
|
|
1644
1665
|
const char* t = RSTR_PTR(s), *p = t;
|
1645
1666
|
const char* e = p + RSTR_LEN(s);
|
1646
1667
|
while (p<e) {
|
1647
|
-
mrb_int clen =
|
1668
|
+
mrb_int clen = mrb_utf8len(p, e);
|
1648
1669
|
if (p + clen>=e) break;
|
1649
1670
|
p += clen;
|
1650
1671
|
}
|
@@ -2016,7 +2037,7 @@ mrb_str_reverse_bang(mrb_state *mrb, mrb_value str)
|
|
2016
2037
|
p = RSTR_PTR(s);
|
2017
2038
|
e = p + RSTR_LEN(s);
|
2018
2039
|
while (p<e) {
|
2019
|
-
mrb_int clen =
|
2040
|
+
mrb_int clen = mrb_utf8len(p, e);
|
2020
2041
|
str_reverse(p, p + clen - 1);
|
2021
2042
|
p += clen;
|
2022
2043
|
}
|
@@ -2491,16 +2512,18 @@ mrb_str_to_i(mrb_state *mrb, mrb_value self)
|
|
2491
2512
|
double
|
2492
2513
|
mrb_str_len_to_dbl(mrb_state *mrb, const char *s, size_t len, mrb_bool badcheck)
|
2493
2514
|
{
|
2494
|
-
char buf[DBL_DIG * 4 +
|
2495
|
-
const char *p = s;
|
2515
|
+
char buf[DBL_DIG * 4 + 20];
|
2516
|
+
const char *p = s, *p2;
|
2496
2517
|
const char *pend = p + len;
|
2497
2518
|
char *end;
|
2498
2519
|
char *n;
|
2499
2520
|
char prev = 0;
|
2500
2521
|
double d;
|
2522
|
+
mrb_bool dot = FALSE;
|
2501
2523
|
|
2502
2524
|
if (!p) return 0.0;
|
2503
|
-
while (ISSPACE(*p)) p++;
|
2525
|
+
while (p<pend && ISSPACE(*p)) p++;
|
2526
|
+
p2 = p;
|
2504
2527
|
|
2505
2528
|
if (pend - p > 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
|
2506
2529
|
mrb_value x;
|
@@ -2515,21 +2538,27 @@ mrb_str_len_to_dbl(mrb_state *mrb, const char *s, size_t len, mrb_bool badcheck)
|
|
2515
2538
|
}
|
2516
2539
|
while (p < pend) {
|
2517
2540
|
if (!*p) {
|
2518
|
-
if (badcheck
|
2541
|
+
if (badcheck) {
|
2519
2542
|
mrb_raise(mrb, E_ARGUMENT_ERROR, "string for Float contains null byte");
|
2520
2543
|
/* not reached */
|
2521
2544
|
}
|
2522
2545
|
pend = p;
|
2523
|
-
p =
|
2546
|
+
p = p2;
|
2547
|
+
goto nocopy;
|
2548
|
+
}
|
2549
|
+
if (!badcheck && *p == ' ') {
|
2550
|
+
pend = p;
|
2551
|
+
p = p2;
|
2524
2552
|
goto nocopy;
|
2525
2553
|
}
|
2526
2554
|
if (*p == '_') break;
|
2527
2555
|
p++;
|
2528
2556
|
}
|
2529
|
-
p =
|
2557
|
+
p = p2;
|
2530
2558
|
n = buf;
|
2531
2559
|
while (p < pend) {
|
2532
2560
|
char c = *p++;
|
2561
|
+
if (c == '.') dot = TRUE;
|
2533
2562
|
if (c == '_') {
|
2534
2563
|
/* remove an underscore between digits */
|
2535
2564
|
if (n == buf || !ISDIGIT(prev) || p == pend) {
|
@@ -2539,6 +2568,11 @@ mrb_str_len_to_dbl(mrb_state *mrb, const char *s, size_t len, mrb_bool badcheck)
|
|
2539
2568
|
}
|
2540
2569
|
else if (badcheck && prev == '_' && !ISDIGIT(c)) goto bad;
|
2541
2570
|
else {
|
2571
|
+
const char *bend = buf+sizeof(buf)-1;
|
2572
|
+
if (n==bend) { /* buffer overflow */
|
2573
|
+
if (dot) break; /* cut off remaining fractions */
|
2574
|
+
return INFINITY;
|
2575
|
+
}
|
2542
2576
|
*n++ = c;
|
2543
2577
|
}
|
2544
2578
|
prev = c;
|
@@ -2725,7 +2759,7 @@ mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len)
|
|
2725
2759
|
MRB_API mrb_value
|
2726
2760
|
mrb_str_cat_cstr(mrb_state *mrb, mrb_value str, const char *ptr)
|
2727
2761
|
{
|
2728
|
-
return mrb_str_cat(mrb, str, ptr, strlen(ptr));
|
2762
|
+
return mrb_str_cat(mrb, str, ptr, ptr ? strlen(ptr) : 0);
|
2729
2763
|
}
|
2730
2764
|
|
2731
2765
|
MRB_API mrb_value
|