summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Doxyfile2
-rw-r--r--README.md2
-rw-r--r--doc/guides/debugger.md2
-rw-r--r--doc/limitations.md20
-rw-r--r--include/mrbconf.h3
-rw-r--r--include/mruby/array.h6
-rw-r--r--include/mruby/string.h6
-rw-r--r--include/mruby/value.h8
-rw-r--r--include/mruby/version.h8
-rw-r--r--mrbgems/mruby-compiler/core/parse.y64
-rw-r--r--mrbgems/mruby-exit/src/mruby-exit.c13
-rw-r--r--src/string.c38
12 files changed, 70 insertions, 102 deletions
diff --git a/Doxyfile b/Doxyfile
index 8724fe1ac..8e465afad 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -6,7 +6,7 @@
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "mruby"
-PROJECT_NUMBER = 2.0.1
+PROJECT_NUMBER = 2.1.0
PROJECT_BRIEF = "mruby is the lightweight implementation of the Ruby language"
diff --git a/README.md b/README.md
index ec3492530..18ac2a491 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ of the Ministry of Economy, Trade and Industry of Japan.
## How to get mruby
-The stable version 2.0.1 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/2.0.1.zip](https://github.com/mruby/mruby/archive/2.0.1.zip)
+The stable version 2.1.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/2.1.0.zip](https://github.com/mruby/mruby/archive/2.1.0.zip)
The latest development version of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/zipball/master](https://github.com/mruby/mruby/zipball/master)
diff --git a/doc/guides/debugger.md b/doc/guides/debugger.md
index 81c0e9d63..a94ef1802 100644
--- a/doc/guides/debugger.md
+++ b/doc/guides/debugger.md
@@ -38,7 +38,7 @@ To confirm mrdb was installed properly, run mrdb with the `--version` option:
```bash
$ mrdb --version
-mruby 2.0.1 (2019-4-4)
+mruby 2.1.0 (2019-11-19)
```
## 2.2 Basic Operation
diff --git a/doc/limitations.md b/doc/limitations.md
index 6958d396f..9ad2019f7 100644
--- a/doc/limitations.md
+++ b/doc/limitations.md
@@ -38,7 +38,7 @@ puts [1,2,3]
3
```
-#### mruby [2.0.1 (2019-4-4)]
+#### mruby [2.1.0 (2019-11-19)]
```
[1, 2, 3]
@@ -61,7 +61,7 @@ end
`ZeroDivisionError` is raised.
-#### mruby [2.0.1 (2019-4-4)]
+#### mruby [2.1.0 (2019-11-19)]
No exception is raised.
@@ -89,7 +89,7 @@ p Liste.new "foobar"
` [] `
-#### mruby [2.0.1 (2019-4-4)]
+#### mruby [2.1.0 (2019-11-19)]
`ArgumentError` is raised.
@@ -119,7 +119,7 @@ false
true
```
-#### mruby [2.0.1 (2019-4-4)]
+#### mruby [2.1.0 (2019-11-19)]
```
true
@@ -156,7 +156,7 @@ p 'ok'
ok
```
-#### mruby [2.0.1 (2019-4-4)]
+#### mruby [2.1.0 (2019-11-19)]
```
test.rb:8: undefined method 'test_func' (NoMethodError)
@@ -178,7 +178,7 @@ defined?(Foo)
nil
```
-#### mruby [2.0.1 (2019-4-4)]
+#### mruby [2.1.0 (2019-11-19)]
`NameError` is raised.
@@ -195,7 +195,7 @@ alias $a $__a__
` nil `
-#### mruby [2.0.1 (2019-4-4)]
+#### mruby [2.1.0 (2019-11-19)]
Syntax error
@@ -217,7 +217,7 @@ end
`ArgumentError` is raised.
The re-defined `+` operator does not accept any arguments.
-#### mruby [2.0.1 (2019-4-4)]
+#### mruby [2.1.0 (2019-11-19)]
` 'ab' `
Behavior of the operator wasn't changed.
@@ -233,7 +233,7 @@ $ ruby -e 'puts Proc.new {}.binding'
#<Binding:0x00000e9deabb9950>
```
-#### mruby [2.0.1 (2019-4-4)]
+#### mruby [2.1.0 (2019-11-19)]
```
$ ./bin/mruby -e 'puts Proc.new {}.binding'
@@ -255,7 +255,7 @@ $ ruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
[[{"a"=>1}], {:b=>2}]
```
-#### mruby [mruby 2.0.1]
+#### mruby [mruby 2.1.0]
```
$ ./bin/mruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
diff --git a/include/mrbconf.h b/include/mrbconf.h
index b86ce82e8..0509f4ff9 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -62,9 +62,6 @@
# endif
#endif
-#define MRB_COMPLEX_NUMBERS
-#define MRB_RATIONAL_NUMBERS
-
/* define on big endian machines; used by MRB_NAN_BOXING, etc. */
#ifndef MRB_ENDIAN_BIG
# if (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN) || \
diff --git a/include/mruby/array.h b/include/mruby/array.h
index 9664214d6..e2dd9bb1c 100644
--- a/include/mruby/array.h
+++ b/include/mruby/array.h
@@ -17,7 +17,7 @@ MRB_BEGIN_DECL
typedef struct mrb_shared_array {
int refcnt;
- mrb_int len;
+ mrb_ssize len;
mrb_value *ptr;
} mrb_shared_array;
@@ -26,9 +26,9 @@ struct RArray {
MRB_OBJECT_HEADER;
union {
struct {
- mrb_int len;
+ mrb_ssize len;
union {
- mrb_int capa;
+ mrb_ssize capa;
mrb_shared_array *shared;
} aux;
mrb_value *ptr;
diff --git a/include/mruby/string.h b/include/mruby/string.h
index 9039aaab3..e5a046073 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -23,9 +23,9 @@ struct RString {
MRB_OBJECT_HEADER;
union {
struct {
- mrb_int len;
+ mrb_ssize len;
union {
- mrb_int capa;
+ mrb_ssize capa;
struct mrb_shared_string *shared;
struct RString *fshared;
} aux;
@@ -54,7 +54,7 @@ struct RStringEmbed {
RSTR_SET_EMBED_LEN((s),(n));\
}\
else {\
- (s)->as.heap.len = (mrb_int)(n);\
+ (s)->as.heap.len = (mrb_ssize)(n);\
}\
} while (0)
#define RSTR_EMBED_PTR(s) (((struct RStringEmbed*)(s))->ary)
diff --git a/include/mruby/value.h b/include/mruby/value.h
index 84ea7fb0a..5a909a5cf 100644
--- a/include/mruby/value.h
+++ b/include/mruby/value.h
@@ -174,6 +174,14 @@ typedef void mrb_value;
#define MRB_SYMBOL_MAX UINT32_MAX
#endif
+#if INTPTR_MAX < MRB_INT_MAX
+ typedef intptr_t mrb_ssize;
+# define MRB_SSIZE_MAX (INTPTR_MAX>>MRB_FIXNUM_SHIFT)
+#else
+ typedef mrb_int mrb_ssize;
+# define MRB_SSIZE_MAX MRB_INT_MAX
+#endif
+
#ifndef mrb_immediate_p
#define mrb_immediate_p(o) (mrb_type(o) < MRB_TT_FREE)
#endif
diff --git a/include/mruby/version.h b/include/mruby/version.h
index 1c7655a47..f4ef21021 100644
--- a/include/mruby/version.h
+++ b/include/mruby/version.h
@@ -42,12 +42,12 @@ MRB_BEGIN_DECL
/*
* Minor release version number.
*/
-#define MRUBY_RELEASE_MINOR 0
+#define MRUBY_RELEASE_MINOR 1
/*
* Tiny release version number.
*/
-#define MRUBY_RELEASE_TEENY 1
+#define MRUBY_RELEASE_TEENY 0
/*
* The mruby version.
@@ -67,12 +67,12 @@ MRB_BEGIN_DECL
/*
* Release month.
*/
-#define MRUBY_RELEASE_MONTH 4
+#define MRUBY_RELEASE_MONTH 11
/*
* Release day.
*/
-#define MRUBY_RELEASE_DAY 4
+#define MRUBY_RELEASE_DAY 19
/*
* Release date as a string.
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index 5a405b8cb..911812706 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -71,23 +71,8 @@ typedef unsigned int stack_type;
#define nint(x) ((node*)(intptr_t)(x))
#define intn(x) ((int)(intptr_t)(x))
-#if defined(MRB_COMPLEX_NUMBERS) || defined(MRB_RATIONAL_NUMBERS)
- #define MRB_SUFFIX_SUPPORT
-
- #ifdef MRB_RATIONAL_NUMBERS
- #define NUM_SUFFIX_R (1<<0)
- #else
- #define NUM_SUFFIX_R 0
- #endif
-
- #ifdef MRB_COMPLEX_NUMBERS
- #define NUM_SUFFIX_I (1<<1)
- #else
- #define NUM_SUFFIX_I 0
- #endif
-
- #define NUM_SUFFIX_ALL (NUM_SUFFIX_R | NUM_SUFFIX_I)
-#endif
+#define NUM_SUFFIX_R (1<<0)
+#define NUM_SUFFIX_I (1<<1)
static inline mrb_sym
intern_cstr_gen(parser_state *p, const char *s)
@@ -866,37 +851,29 @@ new_op_asgn(parser_state *p, node *a, mrb_sym op, node *b)
return list4((node*)NODE_OP_ASGN, a, nsym(op), b);
}
-#ifdef MRB_COMPLEX_NUMBERS
static node*
new_imaginary(parser_state *p, node *imaginary)
{
return new_call(p, new_const(p, intern_lit("Kernel")), intern_lit("Complex"), list1(list2(list3((node*)NODE_INT, (node*)strdup("0"), nint(10)), imaginary)), 1);
}
-#endif
-#ifdef MRB_RATIONAL_NUMBERS
static node*
new_rational(parser_state *p, node *rational)
{
return new_call(p, new_const(p, intern_lit("Kernel")), intern_lit("Rational"), list1(list1(rational)), 1);
}
-#endif
/* (:int . i) */
static node*
new_int(parser_state *p, const char *s, int base, int suffix)
{
node* result = list3((node*)NODE_INT, (node*)strdup(s), nint(base));
-#ifdef MRB_RATIONAL_NUMBERS
if (suffix & NUM_SUFFIX_R) {
result = new_rational(p, result);
}
-#endif
-#ifdef MRB_COMPLEX_NUMBERS
if (suffix & NUM_SUFFIX_I) {
result = new_imaginary(p, result);
}
-#endif
return result;
}
@@ -906,16 +883,12 @@ static node*
new_float(parser_state *p, const char *s, int suffix)
{
node* result = cons((node*)NODE_FLOAT, (node*)strdup(s));
-#ifdef MRB_RATIONAL_NUMBERS
if (suffix & NUM_SUFFIX_R) {
result = new_rational(p, result);
}
-#endif
-#ifdef MRB_COMPLEX_NUMBERS
if (suffix & NUM_SUFFIX_I) {
result = new_imaginary(p, result);
}
-#endif
return result;
}
#endif
@@ -4585,13 +4558,13 @@ parse_string(parser_state *p)
return tSTRING;
}
-#ifdef MRB_SUFFIX_SUPPORT
static int
-number_literal_suffix(parser_state *p, int mask)
+number_literal_suffix(parser_state *p)
{
int c, result = 0;
node *list = 0;
int column = p->column;
+ int mask = NUM_SUFFIX_R|NUM_SUFFIX_I;
while ((c = nextc(p)) != -1) {
list = push(list, (node*)(intptr_t)c);
@@ -4623,7 +4596,6 @@ number_literal_suffix(parser_state *p, int mask)
}
return result;
}
-#endif
static int
heredoc_identifier(parser_state *p)
@@ -5246,9 +5218,7 @@ parser_yylex(parser_state *p)
no_digits();
}
else if (nondigit) goto trailing_uc;
- #ifdef MRB_SUFFIX_SUPPORT
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- #endif
+ suffix = number_literal_suffix(p);
pylval.nd = new_int(p, tok(p), 16, suffix);
return tINTEGER;
}
@@ -5273,9 +5243,7 @@ parser_yylex(parser_state *p)
no_digits();
}
else if (nondigit) goto trailing_uc;
- #ifdef MRB_SUFFIX_SUPPORT
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- #endif
+ suffix = number_literal_suffix(p);
pylval.nd = new_int(p, tok(p), 2, suffix);
return tINTEGER;
}
@@ -5300,9 +5268,7 @@ parser_yylex(parser_state *p)
no_digits();
}
else if (nondigit) goto trailing_uc;
- #ifdef MRB_SUFFIX_SUPPORT
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- #endif
+ suffix = number_literal_suffix(p);
pylval.nd = new_int(p, tok(p), 10, suffix);
return tINTEGER;
}
@@ -5336,9 +5302,7 @@ parser_yylex(parser_state *p)
pushback(p, c);
tokfix(p);
if (nondigit) goto trailing_uc;
- #ifdef MRB_SUFFIX_SUPPORT
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- #endif
+ suffix = number_literal_suffix(p);
pylval.nd = new_int(p, tok(p), 8, suffix);
return tINTEGER;
}
@@ -5356,9 +5320,7 @@ parser_yylex(parser_state *p)
}
else {
pushback(p, c);
- #ifdef MRB_SUFFIX_SUPPORT
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- #endif
+ suffix = number_literal_suffix(p);
pylval.nd = new_int(p, "0", 10, suffix);
return tINTEGER;
}
@@ -5448,16 +5410,12 @@ parser_yylex(parser_state *p)
yywarning_s(p, "float out of range", tok(p));
errno = 0;
}
- #ifdef MRB_SUFFIX_SUPPORT
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- #endif
+ suffix = number_literal_suffix(p);
pylval.nd = new_float(p, tok(p), suffix);
return tFLOAT;
#endif
}
- #ifdef MRB_SUFFIX_SUPPORT
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- #endif
+ suffix = number_literal_suffix(p);
pylval.nd = new_int(p, tok(p), 10, suffix);
return tINTEGER;
}
diff --git a/mrbgems/mruby-exit/src/mruby-exit.c b/mrbgems/mruby-exit/src/mruby-exit.c
index 05c929622..4ff2f932c 100644
--- a/mrbgems/mruby-exit/src/mruby-exit.c
+++ b/mrbgems/mruby-exit/src/mruby-exit.c
@@ -4,12 +4,17 @@
static mrb_value
f_exit(mrb_state *mrb, mrb_value self)
{
- mrb_int i = EXIT_SUCCESS;
+ mrb_value status = mrb_true_value();
+ int istatus;
+
+ mrb_get_args(mrb, "|o", &status);
+ istatus = mrb_true_p(status) ? EXIT_SUCCESS :
+ mrb_false_p(status) ? EXIT_FAILURE :
+ (int)mrb_int(mrb, status);
+ exit(istatus);
- mrb_get_args(mrb, "|i", &i);
- exit((int)i);
/* not reached */
- return mrb_nil_value();
+ return status;
}
void
diff --git a/src/string.c b/src/string.c
index 724aad745..3399e46a9 100644
--- a/src/string.c
+++ b/src/string.c
@@ -24,7 +24,7 @@
typedef struct mrb_shared_string {
int refcnt;
- mrb_int capa;
+ mrb_ssize capa;
char *ptr;
} mrb_shared_string;
@@ -40,8 +40,8 @@ str_init_normal_capa(mrb_state *mrb, struct RString *s,
if (p) memcpy(dst, p, len);
dst[len] = '\0';
s->as.heap.ptr = dst;
- s->as.heap.len = (mrb_int)len;
- s->as.heap.aux.capa = (mrb_int)capa;
+ s->as.heap.len = (mrb_ssize)len;
+ s->as.heap.aux.capa = (mrb_ssize)capa;
RSTR_UNSET_TYPE_FLAG(s);
return s;
}
@@ -66,7 +66,7 @@ static struct RString*
str_init_nofree(struct RString *s, const char *p, size_t len)
{
s->as.heap.ptr = (char *)p;
- s->as.heap.len = (mrb_int)len;
+ s->as.heap.len = (mrb_ssize)len;
s->as.heap.aux.capa = 0; /* nofree */
RSTR_SET_TYPE_FLAG(s, NOFREE);
return s;
@@ -118,7 +118,7 @@ str_new_static(mrb_state *mrb, const char *p, size_t len)
if (RSTR_EMBEDDABLE_P(len)) {
return str_init_embed(mrb_obj_alloc_string(mrb), p, len);
}
- if (len >= MRB_INT_MAX) {
+ if (len >= MRB_SSIZE_MAX) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
}
return str_init_nofree(mrb_obj_alloc_string(mrb), p, len);
@@ -130,7 +130,7 @@ str_new(mrb_state *mrb, const char *p, size_t len)
if (RSTR_EMBEDDABLE_P(len)) {
return str_init_embed(mrb_obj_alloc_string(mrb), p, len);
}
- if (len >= MRB_INT_MAX) {
+ if (len >= MRB_SSIZE_MAX) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
}
if (p && mrb_ro_data_p(p)) {
@@ -162,7 +162,7 @@ mrb_str_new_capa(mrb_state *mrb, size_t capa)
if (RSTR_EMBEDDABLE_P(capa)) {
s = str_init_embed(mrb_obj_alloc_string(mrb), NULL, 0);
}
- else if (capa >= MRB_INT_MAX) {
+ else if (capa >= MRB_SSIZE_MAX) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "string capacity size too big");
/* not reached */
s = NULL;
@@ -190,8 +190,8 @@ mrb_str_buf_new(mrb_state *mrb, size_t capa)
static void
resize_capa(mrb_state *mrb, struct RString *s, size_t capacity)
{
-#if SIZE_MAX > MRB_INT_MAX
- mrb_assert(capacity < MRB_INT_MAX);
+#if SIZE_MAX > MRB_SSIZE_MAX
+ mrb_assert(capacity < MRB_SSIZE_MAX);
#endif
if (RSTR_EMBED_P(s)) {
if (!RSTR_EMBEDDABLE_P(capacity)) {
@@ -200,7 +200,7 @@ resize_capa(mrb_state *mrb, struct RString *s, size_t capacity)
}
else {
s->as.heap.ptr = (char*)mrb_realloc(mrb, RSTR_PTR(s), capacity+1);
- s->as.heap.aux.capa = (mrb_int)capacity;
+ s->as.heap.aux.capa = (mrb_ssize)capacity;
}
}
@@ -568,7 +568,7 @@ str_share(mrb_state *mrb, struct RString *orig, struct RString *s)
else {
if (orig->as.heap.aux.capa > orig->as.heap.len) {
orig->as.heap.ptr = (char *)mrb_realloc(mrb, orig->as.heap.ptr, len+1);
- orig->as.heap.aux.capa = len;
+ orig->as.heap.aux.capa = (mrb_ssize)len;
}
str_init_shared(mrb, orig, s, NULL);
str_init_shared(mrb, orig, orig, s->as.heap.aux.shared);
@@ -613,8 +613,8 @@ mrb_str_byte_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len)
}
else {
str_share(mrb, orig, s);
- s->as.heap.ptr += beg;
- s->as.heap.len = len;
+ s->as.heap.ptr += (mrb_ssize)beg;
+ s->as.heap.len = (mrb_ssize)len;
}
RSTR_COPY_ASCII_FLAG(s, orig);
return mrb_obj_value(s);
@@ -961,7 +961,7 @@ mrb_str_times(mrb_state *mrb, mrb_value self)
if (times < 0) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "negative argument");
}
- if (times && MRB_INT_MAX / times < RSTRING_LEN(self)) {
+ if (times && MRB_SSIZE_MAX / times < RSTRING_LEN(self)) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "argument too big");
}
@@ -1302,7 +1302,7 @@ str_replace_partial(mrb_state *mrb, mrb_value src, mrb_int pos, mrb_int end, mrb
replen = (mrb_nil_p(rep) ? 0 : RSTRING_LEN(rep));
newlen = replen + len - (end - pos);
- if (newlen >= MRB_INT_MAX || newlen < replen /* overflowed */) {
+ if (newlen >= MRB_SSIZE_MAX || newlen < replen /* overflowed */) {
mrb_raise(mrb, E_RUNTIME_ERROR, "string size too big");
}
@@ -2675,21 +2675,21 @@ mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len)
capa = RSTR_CAPA(s);
total = RSTR_LEN(s)+len;
- if (total >= MRB_INT_MAX) {
+ if (total >= MRB_SSIZE_MAX) {
size_error:
mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
}
if (capa <= total) {
if (capa == 0) capa = 1;
while (capa <= total) {
- if (capa <= MRB_INT_MAX / 2) {
+ if (capa <= MRB_SSIZE_MAX / 2) {
capa *= 2;
}
else {
capa = total+1;
}
}
- if (capa <= total || capa > MRB_INT_MAX) {
+ if (capa <= total || capa > MRB_SSIZE_MAX) {
goto size_error;
}
resize_capa(mrb, s, capa);
@@ -2698,7 +2698,7 @@ mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len)
ptr = RSTR_PTR(s) + off;
}
memcpy(RSTR_PTR(s) + RSTR_LEN(s), ptr, len);
- mrb_assert_int_fit(size_t, total, mrb_int, MRB_INT_MAX);
+ mrb_assert_int_fit(size_t, total, mrb_ssize, MRB_SSIZE_MAX);
RSTR_SET_LEN(s, total);
RSTR_PTR(s)[total] = '\0'; /* sentinel */
return str;