Yukihiro "Matz" Matsumoto
f3257c448b
mruby-bigint (mrb_bint_powm): should call mpz_clear() on exceptions
2024-10-19 13:09:03 +09:00
Yukihiro "Matz" Matsumoto
e4d2f343fe
mruby-bigint (mrb_bint_neg): move the function to group bit operations
2024-10-19 12:47:06 +09:00
Yukihiro "Matz" Matsumoto
ee13b9e67b
mruby-bigint: fix mrb_int optimization bugs for and, or, xor
...
If the operand is a small integer, those functions tried to reduce
bigint allocations, but we had some bugs in them. We removed those
imperfect optimization altogether.
2024-10-19 12:45:04 +09:00
dearblue
2ec2437d23
Small improvements for mrb_gc_unregister()
...
`ARY_PTR()` and `ARY_LEN()` avoid using them in a loop if the array is not changed, since they involve branching.
2024-10-19 11:10:10 +09:00
dearblue
1dcc2cac03
Avoid calling mrb_gv_set() from mrb_gc_unregister()
...
Should simply be ignored for the possibility of being called from `RData::dfree`.
2024-10-19 11:08:32 +09:00
dearblue
b28d53bda9
Small improvements for mrb_gc_register()
...
The `mrb_nil_p()` used in conditional expressions is semantically included in `!mrb_array_p()`.
2024-10-19 10:59:21 +09:00
Yukihiro "Matz" Matsumoto
2430eaba13
mruby-bigint (mrb_bint_powm): fixed memory leak
2024-10-19 07:32:06 +09:00
Yukihiro "Matz" Matsumoto
001d5fcc3f
mruby-bigint (mpz_get_str): get b2 by table lookup
...
The `b2` is the power of `base` no bigger than DIG_BASE.
2024-10-19 07:32:05 +09:00
Yukihiro "Matz" Matsumoto
4aa87acfc9
mruby-bigint (mpz_set_uint64): adjust reallocation size for uint64
...
The uint64_t value may fit in `mp_limb*n` where n is 1..4.
2024-10-19 07:32:05 +09:00
John Bampton
86e969a406
Remove macOS 12 from the build
...
The macOS 12 runner image will be removed by December 3rd, 2024.
2024-10-19 00:18:19 +10:00
dearblue
13512aba91
Make array objects invisible in mrb_gc_register()
...
Once the class is set, objects can be referenced and manipulated from the Ruby side by using `ObjectSpace.each_object`.
Also, currently `mrb_gc_unregister()` assumes that the element is a non-immediate object.
However, `mrb_gc_unregister()` does not read or write to the address, so there was no problem.
2024-10-18 22:29:23 +09:00
Yukihiro "Matz" Matsumoto
c3be2568ea
Merge pull request #6005 from jbampton/build-and-test-on-macos-13
2024-10-17 23:28:03 -04:00
Yukihiro "Matz" Matsumoto
5e6d382782
mruby-bigint (mpz_set_uint64): fixed a bug in for loop
...
Found double increments in a loop. Since no one called mpz_set_int64()
in the real code, we could not find this bug for long time.
2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto
fe42f1d047
mruby-bigint (mpz_set_int): simplify using early return
2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto
a5c0b2114a
mruby-bigint (mrb_bint_2comp): need to initialize mpz_t
2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto
c8a73515e9
Merge pull request #6381 from 513ry/iss6380
2024-10-17 22:00:56 -04:00
siery
1a426e245f
part 2: Fix indentation to include break after function return type
2024-10-17 22:26:20 +02:00
siery
7d694df717
Fix indentation to include break after function return type
2024-10-17 21:11:11 +02:00
John Bampton
d387e89ae2
Build and test on macOS 13
...
https://github.com/actions/runner-images#available-images
2024-10-17 22:33:59 +10:00
Yukihiro "Matz" Matsumoto
63f3ff4ac5
Merge pull request #6379 from jbampton/add-pre-commit-hook-gitleaks
2024-10-17 02:40:28 -04:00
Yukihiro "Matz" Matsumoto
b4ab4cd7cf
Merge branch 'master' into add-pre-commit-hook-gitleaks
2024-10-17 02:33:23 -04:00
Yukihiro "Matz" Matsumoto
f1863163a8
mruby-bigint (uzero_p): avoid signed and unsigned comparison in loop
2024-10-16 16:33:43 +09:00
Yukihiro "Matz" Matsumoto
84d17f2c44
array.c (mrb_ary_clear): remove unnecessary function
2024-10-16 16:33:42 +09:00
Yukihiro "Matz" Matsumoto
389740e1d2
Merge pull request #6377 from jbampton/add-pre-commit-hook-oxipng
2024-10-16 03:34:12 -04:00
Yukihiro "Matz" Matsumoto
62c8951787
Merge pull request #6378 from jbampton/add-pre-commit-hook-format-json
2024-10-16 03:25:58 -04:00
John Bampton
42d3eb4b60
Add pre-commit hook gitleaks to detect and prevent hardcoded secrets
...
https://github.com/gitleaks/gitleaks
Adding another check/test to our pre-commit framework.
gitleaks is a popular tool that helps with security.
Removes the gitleaks check from the Super-Linter.
So now we can run gitleaks with pre-commit on `git commit`
2024-10-16 04:20:49 +10:00
John Bampton
e0a9a06c77
Add pre-commit hook pretty-format-json
...
https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#pretty-format-json
From the official pre-commit team a minor feature to add.
We have one JSON file at `.github/linters/mlc_config.json`.
2024-10-16 03:56:19 +10:00
John Bampton
83040c50e7
Add pre-commit hook oxipng for lossless PNG compression
...
Oxipng is a multithreaded lossless PNG/APNG compression optimizer.
Lossless compression is a class of data compression that allows the original data to be perfectly reconstructed from the compressed data with no loss of information.
https://en.wikipedia.org/wiki/Lossless_compression
https://github.com/shssoichiro/oxipng?tab=readme-ov-file#git-integration-via-pre-commit
Oxipng is a multithreaded PNG optimizer written in Rust
https://pre-commit.com/index.html#rust
"pre-commit will bootstrap rust if it is not present."
2024-10-16 03:10:16 +10:00
Yukihiro "Matz" Matsumoto
bbce194609
Merge pull request #6374 from jbampton/add-hooks-upgrade-pre-commit
2024-10-15 08:43:54 -04:00
Yukihiro "Matz" Matsumoto
7b5608e78a
mruby-rational: refactor float to rational conversion
...
- the function `float_decode_internal` was removed
- simplified `rational_new_f()`
- do not need to call `ldexp`
- allocate less bigint objects
2024-10-15 21:10:11 +09:00
Yukihiro "Matz" Matsumoto
51b11a6919
mruby-rational: add comments
...
We used `mrb_bint_mul(mrb, n, ONE)` to normalize `n`. The code confused
ChatGPT that could not read the intention.
2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto
8cfc1a4581
variable.c: fix int and mrb_bool confusion
2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto
540bd54ed3
variable.c (iv_rehash): name magic number 4 as IV_INITIAL_SIZE
2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto
06f45f8635
mruby-compiler (codegen): detect too-deep nesting error; fix #6270
2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto
fa68e634a7
variable.c (mrb_exc_const_get): E_XXX_ERROR should not call const_missing
...
As #6359 pointed out, calling const_missing hook from E_XXX_ERROR (that
calls mrb_exc_get_id()) can be an attack vector. Since E_XXX_ERROR is
supposed to be a defined error class, we think that the situation where
it is undefined and the const_missing hook is called should be detected
as an error; fix #6359
2024-10-15 21:09:48 +09:00
Yukihiro "Matz" Matsumoto
b5801cd730
mruby-bigint (mrb_bint_new_int64): fixed a bug on the 32bit platforms
2024-10-11 14:19:33 +09:00
Yukihiro "Matz" Matsumoto
2d565d30cb
Merge pull request #6376 from 513ry/master
2024-10-11 01:18:02 -04:00
siery
c8203b2d52
Fix typo
2024-10-11 05:08:46 +02:00
Yukihiro "Matz" Matsumoto
e29f3d64b2
mruby-compiler: stop malloc/free warnings from Visual Studio build
2024-10-11 09:10:44 +09:00
Yukihiro "Matz" Matsumoto
32a527ad6d
readfloat.c: fix float to int assignment
2024-10-11 08:45:27 +09:00
Yukihiro "Matz" Matsumoto
763c9cba03
mruby-rational (int_lshift): add cast to stop overflow warning
2024-10-11 08:44:12 +09:00
Yukihiro "Matz" Matsumoto
f4fdf25bb0
mruby-bigint (mrb_bint_new_int64): wrong return value
2024-10-11 08:41:51 +09:00
Yukihiro "Matz" Matsumoto
39a5d2a9d8
Merge pull request #6375 from jbampton/fix-grammar
2024-10-10 19:36:49 -04:00
John Bampton
6f97cf10e9
docs: fix grammar
2024-10-11 04:07:58 +10:00
John Bampton
95f58d8a98
Upgrade pre-commit min version; add hook; pre-commit autoupdate
...
https://github.com/pre-commit/pre-commit-hooks/releases/tag/v5.0.0
pre-commit-hooks now requires pre-commit>=3.2.0
https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#check-illegal-windows-names
https://pre-commit.com/#pre-commit-autoupdate
refs pre-commit/pre-commit#2808
https://pre-commit.com/#top_level-default_stages
2024-10-11 03:32:16 +10:00
Yukihiro "Matz" Matsumoto
6d4de2496c
mruby-bigint: remove unused macros; ref #6371
2024-10-10 23:14:27 +09:00
Yukihiro "Matz" Matsumoto
e21055604c
mruby-bigint: separate mpz and bint functions; ref #6371
...
The pull-request #6371 was tight integration of mpz and bint functions.
The mpz functions take `struct RBigint*` instead of `mpz_t*`. It
decrease maintainability, in my opinion. This commit initializes `mpz_t`
from `struct RBigint*` in bint functions, so that we can keep separation
of function roles.
2024-10-10 23:04:04 +09:00
Yukihiro "Matz" Matsumoto
c6dbaf702e
Merge branch 'bigint-embed'; #6371
2024-10-10 23:02:10 +09:00
Yukihiro "Matz" Matsumoto
12b97ceb78
fixup! Merge branch 'bigint-embed' of https://github.com/dearblue/mruby into bigint-embed
2024-10-10 22:57:32 +09:00
Yukihiro "Matz" Matsumoto
bda2fa39d2
Merge branch 'bigint-embed' of https://github.com/dearblue/mruby into bigint-embed
2024-10-10 22:31:55 +09:00