diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-09-12 07:40:38 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-09-12 07:40:38 +0900 |
| commit | cdbd116c49078ab32d70f6a0f8cf9dcfa694a7a3 (patch) | |
| tree | 1cfd1968cd0407a9bf84989be7cdd6b7ab492747 | |
| parent | 2edee29e685d51ddd5ba2cc4b80f93eaa33ae40f (diff) | |
| parent | bcd77200ac829311c745d260053ee9a3ec5d1f16 (diff) | |
| download | mruby-cdbd116c49078ab32d70f6a0f8cf9dcfa694a7a3.tar.gz mruby-cdbd116c49078ab32d70f6a0f8cf9dcfa694a7a3.zip | |
Merge branch 'master' of github.com:mruby/mruby
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | mrblib/Makefile | 2 | ||||
| -rw-r--r-- | src/Makefile | 2 | ||||
| -rw-r--r-- | src/string.c | 5 | ||||
| -rw-r--r-- | src/time.c | 32 | ||||
| -rw-r--r-- | test/Makefile | 4 | ||||
| -rw-r--r-- | test/t/string.rb | 4 | ||||
| -rw-r--r-- | tools/mirb/Makefile | 2 | ||||
| -rw-r--r-- | tools/mrbc/Makefile | 2 | ||||
| -rw-r--r-- | tools/mruby/Makefile | 2 |
10 files changed, 33 insertions, 24 deletions
@@ -1,4 +1,4 @@ -# makefile discription. +# Makefile description. # basic build file for mruby # compiler, linker (gcc), archiver, parser generator diff --git a/mrblib/Makefile b/mrblib/Makefile index c6a668dbd..6d7ac65f9 100644 --- a/mrblib/Makefile +++ b/mrblib/Makefile @@ -1,4 +1,4 @@ -# makefile discription. +# Makefile description. # basic build file for mruby library (Ruby part) # project-specific macros diff --git a/src/Makefile b/src/Makefile index c746fa90a..de9a4e6e3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,4 +1,4 @@ -# makefile discription. +# Makefile description. # basic build file for mruby library # project-specific macros diff --git a/src/string.c b/src/string.c index a454aab97..d8fe56790 100644 --- a/src/string.c +++ b/src/string.c @@ -2598,7 +2598,10 @@ mrb_cstr_to_dbl(mrb_state *mrb, const char * p, int badcheck) double d; // const char *ellipsis = ""; // int w; -#define DBL_DIG 16 +#if !defined(DBL_DIG) + #define DBL_DIG 16 +#endif + enum {max_width = 20}; #define OutOfRange() (((w = end - p) > max_width) ? \ (w = max_width, ellipsis = "...") : \ diff --git a/src/time.c b/src/time.c index 085c4f30f..ea8205c7b 100644 --- a/src/time.c +++ b/src/time.c @@ -27,12 +27,14 @@ /* #define NO_GMTIME_R */ #ifdef _WIN32 +#if _MSC_VER /* Win32 platform do not provide gmtime_r/localtime_r; emulate them using gmtime_s/localtime_s */ #define gmtime_r(tp, tm) ((gmtime_s((tm), (tp)) == 0) ? (tm) : NULL) #define localtime_r(tp, tm) ((localtime_s((tm), (tp)) == 0) ? (tm) : NULL) #else #define NO_GMTIME_R #endif +#endif /* timegm(3) */ /* mktime() creates tm structure for localtime; timegm() is for UTF time */ @@ -81,8 +83,8 @@ timegm(struct tm *tm) } #endif -/* Since we are limited to using ISO C89, this implementation is based -* on time_t. That means the resolution of time is only precise to the +/* Since we are limited to using ISO C89, this implementation is based +* on time_t. That means the resolution of time is only precise to the * second level. Also, there are only 2 timezones, namely UTC and LOCAL. */ @@ -93,7 +95,7 @@ timegm(struct tm *tm) enum mrb_timezone { MRB_TIMEZONE_NONE = 0, - MRB_TIMEZONE_UTC = 1, + MRB_TIMEZONE_UTC = 1, MRB_TIMEZONE_LOCAL = 2, MRB_TIMEZONE_LAST = 3 }; @@ -135,7 +137,7 @@ mrb_time_update_datetime(struct mrb_time *self) { struct tm *aid; - if (self->timezone == MRB_TIMEZONE_UTC) { + if (self->timezone == MRB_TIMEZONE_UTC) { aid = gmtime_r(&self->sec, &self->datetime); } else { @@ -146,7 +148,7 @@ mrb_time_update_datetime(struct mrb_time *self) self->datetime = *aid; // copy data #endif - return self; + return self; } static mrb_value @@ -188,7 +190,7 @@ mrb_time_make(mrb_state *mrb, struct RClass *c, double sec, double usec, enum mr static struct mrb_time* current_mrb_time(mrb_state *mrb) { - struct mrb_time *tm; + struct mrb_time *tm; tm = (struct mrb_time *)mrb_malloc(mrb, sizeof(*tm)); #ifdef NO_GETTIMEOFDAY @@ -232,7 +234,7 @@ mrb_time_now(mrb_state *mrb, mrb_value self) /* Creates an instance of time at the given time in seconds, etc. */ static mrb_value mrb_time_at(mrb_state *mrb, mrb_value self) -{ +{ mrb_float f, f2 = 0; mrb_get_args(mrb, "f|f", &f, &f2); @@ -271,7 +273,7 @@ time_mktime(mrb_state *mrb, mrb_int ayear, mrb_int amonth, mrb_int aday, /* Creates an instance of time at the given time in UTC. */ static mrb_value mrb_time_gm(mrb_state *mrb, mrb_value self) -{ +{ mrb_int ayear = 0, amonth = 1, aday = 1, ahour = 0, amin = 0, asec = 0, ausec = 0; mrb_get_args(mrb, "i|iiiiii", @@ -285,7 +287,7 @@ mrb_time_gm(mrb_state *mrb, mrb_value self) /* Creates an instance of time at the given time in local time zone. */ static mrb_value mrb_time_local(mrb_state *mrb, mrb_value self) -{ +{ mrb_int ayear = 0, amonth = 1, aday = 1, ahour = 0, amin = 0, asec = 0, ausec = 0; mrb_get_args(mrb, "i|iiiiii", @@ -436,7 +438,7 @@ mrb_time_asctime(mrb_state *mrb, mrb_value self) if (!tm) return mrb_nil_value(); d = &tm->datetime; len = snprintf(buf, sizeof(buf), "%s %s %02d %02d:%02d:%02d %s%d", - wday_names[d->tm_wday], mon_names[d->tm_mon], d->tm_mday, + wday_names[d->tm_wday], mon_names[d->tm_mon], d->tm_mday, d->tm_hour, d->tm_min, d->tm_sec, tm->timezone == MRB_TIMEZONE_UTC ? "UTC " : "", d->tm_year + 1900); @@ -518,7 +520,7 @@ mrb_time_hour(mrb_state *mrb, mrb_value self) static mrb_value mrb_time_initialize(mrb_state *mrb, mrb_value self) { - mrb_int ayear = 0, amonth = 1, aday = 1, ahour = 0, + mrb_int ayear = 0, amonth = 1, aday = 1, ahour = 0, amin = 0, asec = 0, ausec = 0; int n; struct mrb_time *tm; @@ -686,7 +688,7 @@ mrb_time_utcp(mrb_state *mrb, mrb_value self) return mrb_bool_value(tm->timezone == MRB_TIMEZONE_UTC); } - + void mrb_init_time(mrb_state *mrb) @@ -722,10 +724,10 @@ mrb_init_time(mrb_state *mrb) mrb_define_method(mrb, tc, "localtime", mrb_time_localtime, ARGS_NONE()); /* 15.2.19.7.18 */ mrb_define_method(mrb, tc, "mday" , mrb_time_mday, ARGS_NONE()); /* 15.2.19.7.19 */ mrb_define_method(mrb, tc, "min" , mrb_time_min, ARGS_NONE()); /* 15.2.19.7.20 */ - + mrb_define_method(mrb, tc, "mon" , mrb_time_mon, ARGS_NONE()); /* 15.2.19.7.21 */ mrb_define_method(mrb, tc, "month", mrb_time_mon, ARGS_NONE()); /* 15.2.19.7.22 */ - + mrb_define_method(mrb, tc, "sec" , mrb_time_sec, ARGS_NONE()); /* 15.2.19.7.23 */ mrb_define_method(mrb, tc, "to_i", mrb_time_to_i, ARGS_NONE()); /* 15.2.19.7.25 */ mrb_define_method(mrb, tc, "to_f", mrb_time_to_f, ARGS_NONE()); /* 15.2.19.7.24 */ @@ -736,7 +738,7 @@ mrb_init_time(mrb_state *mrb) mrb_define_method(mrb, tc, "yday", mrb_time_yday, ARGS_NONE()); /* 15.2.19.7.31 */ mrb_define_method(mrb, tc, "year", mrb_time_year, ARGS_NONE()); /* 15.2.19.7.32 */ mrb_define_method(mrb, tc, "zone", mrb_time_zone, ARGS_NONE()); /* 15.2.19.7.33 */ - + mrb_define_method(mrb, tc, "initialize", mrb_time_initialize, ARGS_REQ(1)); /* 15.2.19.7.16 */ mrb_define_method(mrb, tc, "initialize_copy", mrb_time_initialize_copy, ARGS_REQ(1)); /* 15.2.19.7.17 */ diff --git a/test/Makefile b/test/Makefile index 921442b28..18bc79b5a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,5 +1,5 @@ -# makefile discription. -# basic build file for mruby library (Ruby part) +# Makefile description. +# basic build file for the mruby testing environment mrbtest # project-specific macros # extension of the executable-file is modifiable(.exe .out ...) diff --git a/test/t/string.rb b/test/t/string.rb index 3338e4318..27af38a4c 100644 --- a/test/t/string.rb +++ b/test/t/string.rb @@ -335,3 +335,7 @@ assert('String interpolation (mrb_str_concat for shared strings)') do "#{a}:" == "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:" end +assert('Check the usage of a NUL character') do + "qqq\0ppp" +end + diff --git a/tools/mirb/Makefile b/tools/mirb/Makefile index 52941f242..8dbbc52b3 100644 --- a/tools/mirb/Makefile +++ b/tools/mirb/Makefile @@ -1,4 +1,4 @@ -# makefile discription. +# Makefile description. # basic build file for mirb executable # project-specific macros diff --git a/tools/mrbc/Makefile b/tools/mrbc/Makefile index eea0c02cb..9da1776bd 100644 --- a/tools/mrbc/Makefile +++ b/tools/mrbc/Makefile @@ -1,4 +1,4 @@ -# makefile discription. +# Makefile description. # basic build file for mruby-compiler # project-specific macros diff --git a/tools/mruby/Makefile b/tools/mruby/Makefile index 9955b4302..e94c1b2b4 100644 --- a/tools/mruby/Makefile +++ b/tools/mruby/Makefile @@ -1,4 +1,4 @@ -# makefile discription. +# Makefile description. # basic build file for mruby executable # project-specific macros |
