From 3f6fd994f01a1e0431c169a4532a1b22916610fd Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 13 Jan 2023 23:55:26 +0900 Subject: [PATCH 1/6] README.md: mruby is not Ruby 3.x compatible (for syntax at least) With pattern matching as an exception. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd8661754..07f77e87e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ ## What is mruby mruby is the lightweight implementation of the Ruby language complying to (part -of) the [ISO standard][ISO-standard]. Its syntax is Ruby 2.x compatible. +of) the [ISO standard][ISO-standard] with more recent features provided by Ruby 3.x. +Also, its syntax is Ruby 3.x compatible except for pattern matching. mruby can be linked and embedded within your application. We provide the interpreter program "mruby", and the interactive mruby shell "mirb" as examples. From 7a6d03f869ae93890b35511ec2db4e154643ea73 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 14 Jan 2023 22:55:26 +0900 Subject: [PATCH 2/6] vm.c: transferred fiber termination should kick root fiber; fix #5907 --- src/vm.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/vm.c b/src/vm.c index 2328497fa..2bb3ff30f 100644 --- a/src/vm.c +++ b/src/vm.c @@ -2179,8 +2179,8 @@ RETRY_TRY_BLOCK: c->status = MRB_FIBER_TERMINATED; mrb->c = c->prev; - c->prev = NULL; if (!mrb->c) mrb->c = mrb->root_c; + else c->prev = NULL; goto L_RAISE; } } @@ -2257,11 +2257,17 @@ RETRY_TRY_BLOCK: struct mrb_context *c; c = mrb->c; - if (!c->prev) { /* toplevel return */ - regs[irep->nlocals] = v; - goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP); + if (!c->prev) { + if (c != mrb->root_c) { + /* fiber termination should transfer to root */ + c->prev = mrb->root_c; + } + else { /* toplevel return */ + regs[irep->nlocals] = v; + goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP); + } } - if (!c->vmexec && c->prev->ci == c->prev->cibase) { + else if (!c->vmexec && c->prev->ci == c->prev->cibase) { RAISE_LIT(mrb, E_FIBER_ERROR, "double resume"); } CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_TOPLEVEL) { From 2c261503b516cc075b4a5a4c66ebf954ae084ef8 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 15 Jan 2023 00:05:26 +0900 Subject: [PATCH 3/6] doc/internal/boxing.md: remove an extra double quote sign. --- doc/internal/boxing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/internal/boxing.md b/doc/internal/boxing.md index a16ce8a15..f3bd086e4 100644 --- a/doc/internal/boxing.md +++ b/doc/internal/boxing.md @@ -45,7 +45,7 @@ The NaN boxing packing bit patterns are like following: | ptr | `01111111 11111100 PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPP01` | | nil | `00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000` | -The object values appear far more frequently than floating-point numbers, so we offset the value so that object pointers are unchanged. This technique is called "favor pointer"". +The object values appear far more frequently than floating-point numbers, so we offset the value so that object pointers are unchanged. This technique is called "favor pointer". ## No Boxing From 10768c1191ef058950cfbfd2e79bc25aaa58d00b Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 16 Jan 2023 21:08:03 +0900 Subject: [PATCH 4/6] LEGAL: add entries for non-MIT licensed files. --- LEGAL | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/LEGAL b/LEGAL index ecddf6b95..24c8dc670 100644 --- a/LEGAL +++ b/LEGAL @@ -3,3 +3,38 @@ LEGAL NOTICE INFORMATION All the files in this distribution are covered under the MIT license (see the file LICENSE) except some files mentioned below: + +- src/readfloat.c: public domain by Yasuhiro Matsumoto (@mattn) +- src/fmt_fp.c: public domain by Dave Hylands (@dhylands) +- mrbgems/mruby-dir/src/Win/dirent.c: MIT-like license by Kevlin Henney + +[src/readfloat.c] + +strtod implementation. +author: Yasuhiro Matsumoto (@mattn) +license: public domain + +The original code can be found in https://github.com/mattn/strtod + +[src/fmt_fp.c] + +The code in this function was inspired from Fred Bayer's pdouble.c. +Since pdouble.c was released as Public Domain, I'm releasing this +code as public domain as well. + +Dave Hylands + +The original code can be found in https://github.com/dhylands/format-float + +[mrbgems/mruby-dir/src/Win/dirent.c] used only for Windows platform + +Copyright Kevlin Henney, 1997, 2003, 2012. All rights reserved. + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose is hereby granted without fee, provided +that this copyright and permissions notice appear in all copies and +derivatives. + +This software is supplied "as is" without express or implied warranty. + +But that said, if there are any problems please get in touch. From 6b87aae757c91fb4343893136a1f181d869b5a63 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 17 Jan 2023 10:29:35 +0900 Subject: [PATCH 5/6] doc/guides/compile.md: update compilation example Show usage of multiple command-line options to `mruby-config`. --- doc/guides/compile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/guides/compile.md b/doc/guides/compile.md index fbcc45319..4302d1362 100644 --- a/doc/guides/compile.md +++ b/doc/guides/compile.md @@ -545,7 +545,7 @@ For example, when you have a C source file (`c.c`) and try to compile and link it with `libmruby.a`, you can run the following command, ``` -gcc `mruby-config --cflags` c.c `mruby-config --ldflags` `mruby-config --libs` +`mruby-config --cc --cflags` c.c `mruby-config --ldflags --libs` ``` When you use `make`, add following lines in `Makefile` From 9deb52c7b2ba6028d996172bfdd6cf8a0405ce1c Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 17 Jan 2023 18:25:23 +0900 Subject: [PATCH 6/6] mruby-io/io.c: allow disabling `popen` When `MRB_NO_IO_POPEN` is defined (or iPhone is target), `IO#popen` will be disabled. --- mrbgems/mruby-io/src/io.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mrbgems/mruby-io/src/io.c b/mrbgems/mruby-io/src/io.c index 05b6aaa7a..5ef60d039 100644 --- a/mrbgems/mruby-io/src/io.c +++ b/mrbgems/mruby-io/src/io.c @@ -90,6 +90,11 @@ io_get_open_fptr(mrb_state *mrb, mrb_value io) return fptr; } +#if !defined(MRB_NO_IO_POPEN) && defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +# define MRB_NO_IO_POPEN 1 +#endif + +#ifndef MRB_NO_IO_POEPN static void io_set_process_status(mrb_state *mrb, pid_t pid, int status) { @@ -110,6 +115,7 @@ io_set_process_status(mrb_state *mrb, pid_t pid, int status) } mrb_gv_set(mrb, mrb_intern_lit(mrb, "$?"), v); } +#endif static int io_modestr_to_flags(mrb_state *mrb, const char *mode) @@ -333,7 +339,7 @@ io_alloc(mrb_state *mrb) #define NOFILE 64 #endif -#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +#ifdef NO_IO_POPEN # define io_s_popen mrb_notimplement_m #else static int @@ -764,6 +770,7 @@ fptr_finalize(mrb_state *mrb, struct mrb_io *fptr, int quiet) fptr->fd2 = -1; } +#ifndef NO_IO_POPEN if (fptr->pid != 0) { #if !defined(_WIN32) && !defined(_WIN64) pid_t pid; @@ -785,6 +792,7 @@ fptr_finalize(mrb_state *mrb, struct mrb_io *fptr, int quiet) fptr->pid = 0; /* Note: we don't raise an exception when waitpid(3) fails */ } +#endif if (fptr->buf) { mrb_free(mrb, fptr->buf);