Commit Graph

15549 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto b06fdb4bfa mruby-io/file.c: reduce the scope of local variables 2024-01-06 08:30:56 +09:00
Yukihiro "Matz" Matsumoto e1b6501183 mruby-io: fix local variable initialization redundancy 2024-01-05 13:03:33 +09:00
Yukihiro "Matz" Matsumoto f1b8d38eb5 mruby-io: narrow a local variable scope 2024-01-05 13:02:39 +09:00
Yukihiro "Matz" Matsumoto 20dd737a4a mruby-io (io_s_popen): remove fflush(stdin)
Flushing input I/O should be useless.
2024-01-05 13:00:55 +09:00
Yukihiro "Matz" Matsumoto 9ee7d955e3 mruby-metaprog: narrow the scope of a local variable 2024-01-04 11:18:14 +09:00
Yukihiro "Matz" Matsumoto 2ce5c52726 mruby-errno (mrb_sce_sys_fail): remove redundant assignment 2024-01-04 10:08:22 +09:00
Yukihiro "Matz" Matsumoto 7861422cbe mruby-fiber (fiber_switch): reduce the scope of local variables 2024-01-03 16:07:15 +09:00
Yukihiro "Matz" Matsumoto 93bda0d27f mruby-fiber (fiber_init_fiber): rename conflicting local variables 2024-01-03 16:05:46 +09:00
Yukihiro "Matz" Matsumoto f0ab79b195 Merge pull request #6136 from dearblue/fiber-fix
Fixed when combined `mrb_fiber_resume()` and `Fiber#transfer`
2024-01-03 07:33:48 +09:00
Yukihiro "Matz" Matsumoto 5257fe4333 mruby-bigint (mrb_bint_new_float): narrow the scope of variable 'f' 2024-01-03 07:23:55 +09:00
Yukihiro "Matz" Matsumoto d632085b5b mruby-bigint (udiv): narrow the scope of loop variable 'i' 2024-01-03 07:23:55 +09:00
Yukihiro "Matz" Matsumoto d944a079a3 mruby-numeric-ext (int_digits): avoid variable name override 2024-01-03 07:23:55 +09:00
Yukihiro "Matz" Matsumoto e71e1bc50e mruby-hash-ext: reduce the scope of the loop variable i 2024-01-03 07:23:55 +09:00
Yukihiro "Matz" Matsumoto 17b2ec643e Merge pull request #6140 from jbampton/actions-label-more-files
actions: label more files for build
2024-01-03 07:23:39 +09:00
dearblue 519a2cbd59 Fixed when combined mrb_fiber_resume() and Fiber#transfer
For example, the following code was crashing.

```c
#include <mruby.h>
#include <mruby/compile.h>
#include <mruby/proc.h>

int
main(int argc, char *argv[])
{
  mrb_state *mrb = mrb_open();

  mrb_value fiber = mrb_load_string(mrb, "Fiber.new { Fiber.new { 12345.6789 }.transfer }");
  mrb_value res = mrb_fiber_resume(mrb, fiber, 0, NULL);
  mrb_p(mrb, res);

  mrb_close(mrb);

  return 0;
}
```
2024-01-02 21:34:44 +09:00
John Bampton e471399044 actions: label more files for build 2024-01-01 17:19:53 +10:00
Yukihiro "Matz" Matsumoto d7a2174519 Merge pull request #6139 from jbampton/fix-prettier-hook
Fix `pre-commit` failure from `prettier`
2024-01-01 15:46:41 +09:00
Yukihiro "Matz" Matsumoto a406e008d1 Merge branch 'master' into fix-prettier-hook 2024-01-01 15:29:08 +09:00
John Bampton 19d0ea803d Fix pre-commit failure from prettier 2023-12-31 21:57:58 +10:00
Yukihiro "Matz" Matsumoto 8094ac27d7 NEWS: add mruby3.3 changes description 2023-12-31 00:43:02 +09:00
Yukihiro "Matz" Matsumoto 39f48d732a mruby-pack: update README.md
'X' and '@' directives are not listed
2023-12-30 16:02:20 +09:00
Yukihiro "Matz" Matsumoto 56b67f8613 mruby-pack (u64tostr): reimplement the function
- direct conversion of single digit numbers
- remove unnecessary update of `line` variable
- simplify the body according to the assertion
2023-12-30 15:35:55 +09:00
Yukihiro "Matz" Matsumoto 8cbd4638f4 mruby-pack (u64tostr): len should always be positive
Add `mrb_assert()` instead of just skipping the function.
2023-12-30 15:33:57 +09:00
Yukihiro "Matz" Matsumoto 1871ff14db mruby-pack (pack_unpack): skip continuous extraction from unpack1
Ref #6134
2023-12-30 15:31:44 +09:00
Yukihiro "Matz" Matsumoto 7765c23f69 mruby-pack (pack_hex): the scope of variables a and b can be reduced 2023-12-30 15:12:17 +09:00
Yukihiro "Matz" Matsumoto fca2bbdcca mruby-pack (unpack_str): the scope of the variable cp can be reduced 2023-12-30 15:12:10 +09:00
Yukihiro "Matz" Matsumoto 159687bef3 mruby-pack: add tests for unpack1 method; ref #6134 2023-12-29 15:05:16 +09:00
Yukihiro "Matz" Matsumoto 6d8323f3c7 mruby-pack (pack_unpack): unpack1 did not return single data; fix #6134
For following unpack directives:

- PACK_DIR_HEX (h)
- PACK_DIR_BSTR (b)
- PACK_DIR_STR (a,A,Z)
- PACK_DIR_BASE64 (m)
- PACK_DIR_QENC (M)
2023-12-29 13:09:14 +09:00
Yukihiro "Matz" Matsumoto 95aa92d5c4 Update AUTHORS (date and commit hash) 2023-12-28 23:36:40 +09:00
Yukihiro "Matz" Matsumoto c1511d5f5d AUTHORS: update entries [ci skip] 2023-12-28 19:51:31 +09:00
Yukihiro "Matz" Matsumoto 67cb987510 doc/mruby3.{1,2}.md: update CVE links (nvd.nist.gov is down) 2023-12-27 22:24:12 +09:00
Yukihiro "Matz" Matsumoto 6ea3166005 doc/guides/memory.md: small style changes (markdownlink-cli) 2023-12-27 22:24:12 +09:00
Yukihiro "Matz" Matsumoto ae43ce7593 mruby-time: refactor _POSIX_TIMERS handling issue; ref #6124 2023-12-27 22:24:12 +09:00
Yukihiro "Matz" Matsumoto a8b82bfae5 Merge pull request #6128 from dearblue/fiber-end
Integrates the sequence when a fiber is terminated by `OP_RETURN`
2023-12-27 22:24:01 +09:00
Yukihiro "Matz" Matsumoto e51c20888b Merge pull request #6127 from dearblue/catch_handler_find
Changed parameters for `catch_handler_find()`
2023-12-27 22:22:12 +09:00
Yukihiro "Matz" Matsumoto 1ac4148020 Merge pull request #6126 from dearblue/block-return
Fixed return value of `OP_RETURN_BLK` called directly under C function
2023-12-27 22:19:36 +09:00
Yukihiro "Matz" Matsumoto 074374e28d Merge pull request #6125 from dearblue/cross-c
Allow `OP_RETURN_BLK` to cross C boundaries
2023-12-27 22:18:06 +09:00
Yukihiro "Matz" Matsumoto dc633ecae8 Merge pull request #6123 from dearblue/allocate-undef.2
Inherit `MRB_FL_UNDEF_ALLOCATE` in subclasses
2023-12-27 22:16:51 +09:00
Yukihiro "Matz" Matsumoto 7d83e9cd27 Merge pull request #6130 from sizious/dreamcast-shelf-build-config-overhaul
`dreamcast_shelf build config`: complete overhaul
2023-12-27 21:54:26 +09:00
SiZiOUS f81b7a3a1f dreamcast_shelf build config: complete overhaul
This configuration is used to support the Sega Dreamcast system.
mruby is now officially supported as a KallistiOS Port in kos-ports.
See: https://dreamcast.wiki/Using_Ruby_for_Sega_Dreamcast_development
2023-12-25 21:40:37 +00:00
Yukihiro "Matz" Matsumoto ebf66a2b80 Add prettier pre-commit hook; close #5490 2023-12-25 08:02:58 +09:00
Yukihiro "Matz" Matsumoto 9c66d4a453 Merge pull request #6124 from sizious/mruby-time-update
`mruby-time`: protect against incorrectly defined `_POSIX_TIMERS`
2023-12-24 17:33:23 +09:00
dearblue dba1dcdd25 Integrates the sequence when a fiber is terminated by OP_RETURN
In the `ensure` block while executing `fiber.transfer`, keep `fiber->cxt->prev` to be `NULL`.
2023-12-24 15:45:15 +09:00
dearblue dc09000f01 Fixed return value of OP_RETURN_BLK called directly under C function
```ruby
def cross; Class.new { return 1 }; end; p cross'
# => #<Class:0x8245cf170>               # without this patch
# => 1                                  # with this patch
```
2023-12-24 13:56:25 +09:00
dearblue d41a2612f4 Allow OP_RETURN_BLK to cross C boundaries
The restriction was introduced in commit b563bcb7ff to resolve https://github.com/mruby/mruby/issues/3462.
Subsequently, the `RBreak` object, introduced by mruby 1.3.0, allowed crossing the C boundary.

```ruby
def cross; Class.new { proc { return }.call }; end; cross
# => unexpected return (LocalJumpError) # without this patch
# => nothing raised                     # with this patch
```
2023-12-24 13:56:25 +09:00
SiZiOUS c0ffc13801 mruby-time: protect against incorrectly defined _POSIX_TIMERS
This update avoids the following error: operator '&&' has no right operand (related to _POSIX_TIMERS)
See: https://stackoverflow.com/questions/48538243/macro-if-statement-returns-error-operator-has-no-right-operand
2023-12-23 19:16:23 +00:00
dearblue 6a9671eac7 Changed parameters for catch_handler_find()
- Removed `mrb` and `ci` parameters.
  - Added `irep` parameter.
    The caller must guarantee that `irep->clen > 0`.
2023-12-23 23:02:48 +09:00
dearblue 2a1ea7d605 Inherit MRB_FL_UNDEF_ALLOCATE in subclasses
If `Class#allocate` is prohibited, subclasses should also be implicitly prohibited.

```ruby
p Class.new(Struct).allocate.class
# => #<Class:0x82362ac00>                                             by #6122
# => allocator undefined for #<Class:0x000000083a983220> (TypeError)  by Ruby 3.2
```

Added `MRB_DEFINE_ALLOCATOR()` to allow subclasses to use `Class#allocate`.

Supplement to #6122.
2023-12-23 21:01:42 +09:00
Yukihiro "Matz" Matsumoto 63580581f7 Merge pull request #6122 from dearblue/allocate-undef.1
Prohibit `Class#allocate` in a different way
2023-12-23 15:15:11 +09:00
dearblue 8ecfacefca Prohibit Class#allocate in a different way
The method introduced by #5979 causes a fault by swapping classes.

```console
% bin/mruby -e 'Method = Proc; p Object.method(:inspect)'
zsh: segmentation fault (core dumped)  bin/mruby -e 'Method = Proc; p Object.method(:inspect)'
```

After applying this patch, a `TypeError` exception will be raised.

```console
% bin/mruby -e 'Method = Proc; p Object.method(:inspect)'
trace (most recent call last):
        [1] -e:1
-e:1:in method: allocation failure of Proc (TypeError)
```

However, if the `mrb_vtype` is the same object, the same care must still be taken as before.

```console
% bin/mruby -e 'Method = Binding; p method(:puts).eval("12345")'
trace (most recent call last):
        [1] -e:1
-e:1:in eval: wrong argument type nil (expected Proc) (TypeError)
```
2023-12-22 21:59:34 +09:00