diff options
| -rw-r--r-- | examples/targets/ArduinoDue.rb | 4 | ||||
| -rw-r--r-- | include/mruby/value.h | 38 | ||||
| -rw-r--r-- | mrbgems/mruby-math/src/math.c | 22 | ||||
| -rw-r--r-- | mrbgems/mruby-sprintf/src/sprintf.c | 4 | ||||
| -rw-r--r-- | src/class.c | 2 | ||||
| -rw-r--r-- | src/parse.y | 12 |
6 files changed, 40 insertions, 42 deletions
diff --git a/examples/targets/ArduinoDue.rb b/examples/targets/ArduinoDue.rb index 762236f3b..a4af4a926 100644 --- a/examples/targets/ArduinoDue.rb +++ b/examples/targets/ArduinoDue.rb @@ -15,9 +15,9 @@ MRuby::CrossBuild.new("Arduino Due") do |conf| conf.cc do |cc| cc.command = "#{BIN_PATH}/arm-none-eabi-gcc" - cc.include_paths << ["#{SAM_PATH}/system/libsam -I#{SAM_PATH}/system/CMSIS/CMSIS/Include/", + cc.include_paths << ["#{SAM_PATH}/system/libsam", "#{SAM_PATH}/system/CMSIS/CMSIS/Include/", "#{SAM_PATH}/system/CMSIS/Device/ATMEL/", - "#{SAM_PATH}/cores/arduino -I#{TARGET_PATH}"] + "#{SAM_PATH}/cores/arduino", "#{SAM_PATH}/libraries","#{TARGET_PATH}"] cc.flags = %w(-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=152 -D__SAM3X8E__ -mthumb -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON) cc.compile_options = "%{flags} -o %{outfile} -c %{infile}" diff --git a/include/mruby/value.h b/include/mruby/value.h index 06241ec76..e78035b5f 100644 --- a/include/mruby/value.h +++ b/include/mruby/value.h @@ -51,23 +51,29 @@ typedef short mrb_sym; #ifdef _MSC_VER -# define _ALLOW_KEYWORD_MACROS -# include <float.h> -# define inline __inline +# ifndef __cplusplus +# define inline __inline +# endif # define snprintf _snprintf -# define isnan _isnan -# define isinf(n) (!_finite(n) && !_isnan(n)) -# define strtoll _strtoi64 -# define PRId32 "I32d" -# define PRIi32 "I32i" -# define PRIo32 "I32o" -# define PRIx32 "I32x" -# define PRIX32 "I32X" -# define PRId64 "I64d" -# define PRIi64 "I64i" -# define PRIo64 "I64o" -# define PRIx64 "I64x" -# define PRIX64 "I64X" +# if _MSC_VER < 1800 +# include <float.h> +# define isnan _isnan +# define isinf(n) (!_finite(n) && !_isnan(n)) +# define strtoll _strtoi64 +# define strtof (float)strtod +# define PRId32 "I32d" +# define PRIi32 "I32i" +# define PRIo32 "I32o" +# define PRIx32 "I32x" +# define PRIX32 "I32X" +# define PRId64 "I64d" +# define PRIi64 "I64i" +# define PRIo64 "I64o" +# define PRIx64 "I64x" +# define PRIX64 "I64X" +# else +# include <inttypes.h> +# endif #else # include <inttypes.h> #endif diff --git a/mrbgems/mruby-math/src/math.c b/mrbgems/mruby-math/src/math.c index bf3c007b4..bdc7767f7 100644 --- a/mrbgems/mruby-math/src/math.c +++ b/mrbgems/mruby-math/src/math.c @@ -12,8 +12,8 @@ #define domain_error(msg) \ mrb_raise(mrb, E_RANGE_ERROR, "Numerical argument is out of domain - " #msg) -/* math functions not provided under Microsoft Visual C++ */ -#ifdef _MSC_VER +/* math functions not provided by Microsoft Visual C++ 2012 or older */ +#if defined _MSC_VER && _MSC_VER < 1800 #define MATH_TOLERANCE 1E-12 @@ -87,6 +87,12 @@ erfc(double x) return one_sqrtpi*exp(-x*x)*q2; } +double +log2(double x) +{ + return log10(x)/log10(2.0); +} + #endif /* @@ -358,18 +364,6 @@ math_atanh(mrb_state *mrb, mrb_value obj) # define log10(x) ((x) < 0.0 ? nan("") : log10(x)) #endif -#ifndef log2 -#ifndef HAVE_LOG2 -double -log2(double x) -{ - return log10(x)/log10(2.0); -} -#else -extern double log2(double); -#endif -#endif - /* * call-seq: * Math.exp(x) -> float diff --git a/mrbgems/mruby-sprintf/src/sprintf.c b/mrbgems/mruby-sprintf/src/sprintf.c index 55698d09f..6479b19bc 100644 --- a/mrbgems/mruby-sprintf/src/sprintf.c +++ b/mrbgems/mruby-sprintf/src/sprintf.c @@ -15,10 +15,6 @@ #include <math.h> #include <ctype.h> -#ifdef _MSC_VER -#include <float.h> -#endif - #ifdef HAVE_IEEEFP_H #include <ieeefp.h> #endif diff --git a/src/class.c b/src/class.c index f94f9a933..6eb70dce6 100644 --- a/src/class.c +++ b/src/class.c @@ -487,7 +487,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) if (i < argc) { ss = to_str(mrb, *sp++); s = mrb_str_ptr(ss); - if (strlen(s->ptr) != s->len) { + if (strlen(s->ptr) < s->len) { mrb_raise(mrb, E_ARGUMENT_ERROR, "String contains NUL"); } *ps = s->ptr; diff --git a/src/parse.y b/src/parse.y index 1d5366d17..fda66e92c 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3620,12 +3620,14 @@ parse_string(parser_state *p) tokadd(p, '\n'); } else { - pushback(p, c); - - if(type & STR_FUNC_REGEXP) + if (type & STR_FUNC_REGEXP) { tokadd(p, '\\'); - - tokadd(p, read_escape(p)); + if (c != -1) + tokadd(p, c); + } else { + pushback(p, c); + tokadd(p, read_escape(p)); + } if (hinf) hinf->line_head = FALSE; } |
