Yukihiro "Matz" Matsumoto
9c5dc42e59
small cosmetic changes.
...
I prefer `i++` style unless absolutely necessary.
This commit is an addition to 41e4148.
2022-11-19 17:11:56 +09:00
Yukihiro "Matz" Matsumoto
9fcfd01f20
mruby-pack/pack.c (read_tmpl): check integer overflow before casting.
2022-11-10 22:21:12 +09:00
Yukihiro "Matz" Matsumoto
4a888a34bb
readfloat.c (mrb_read_float): a new function.
...
We no longer use `mrb_float_read()` that depends on `errno`.
2022-11-07 16:09:31 +09:00
Yukihiro "Matz" Matsumoto
4e9773ae3d
readint.c (mrb_int_read): new function.
...
We no longer use `mrb_read_int` which is kinda compatible with `strtol`.
2022-11-07 16:09:31 +09:00
Yukihiro "Matz" Matsumoto
8a67a26104
mruby-pack/pack.c (unpack): check if the given length is positive.
...
To avoid out-of-bound array access.
2022-10-27 16:32:05 +09:00
Yukihiro "Matz" Matsumoto
4f0679bb86
pack.c (pack_unpack): small refactoring.
2022-08-31 23:29:12 +09:00
Yukihiro "Matz" Matsumoto
15e9b09bef
pack.c (hex2int): should return signed integer.
2022-08-30 18:08:05 +09:00
Yukihiro "Matz" Matsumoto
f587edd849
pack.c: need extra space for the terminal NULL.
2022-08-23 15:05:27 +09:00
Yukihiro "Matz" Matsumoto
35a5678899
mruby-pack/pack.c: make base64_dec_tab a static array of chars.
2022-08-21 19:25:16 +09:00
Yukihiro "Matz" Matsumoto
0f4769536b
src/numeric.c: use mrb_ensure_float_type().
...
Instead of obsolete `mrb_to_float()` or the combination of
`mrb_float_value(mrb_as_float())`.
2022-04-25 07:29:55 +09:00
Yukihiro "Matz" Matsumoto
f45ac65532
fixup! mruby-kernel-ext/kernel.c: use mrb_ensure_integer_type().
2022-04-25 07:29:21 +09:00
Yukihiro "Matz" Matsumoto
3be461077d
mruby-pack/pack.c: fix integer size mixtures.
2022-04-21 14:47:15 +09:00
Yukihiro "Matz" Matsumoto
22a98a0ba7
pack.c: unify duplicated error handling code.
2022-03-09 15:21:14 +09:00
Yukihiro "Matz" Matsumoto
278f46f971
unpack.c: check if srcidx is shorter than srclen for safety.
2022-03-04 14:19:10 +09:00
Yukihiro "Matz" Matsumoto
bc9476e7ca
unpack.c: unpack_BER() did assume the string length is not zero.
2022-03-04 14:18:20 +09:00
Yukihiro "Matz" Matsumoto
3b59c95ead
pack.c: check integer overflow in unpacking BER; fix #5611
2021-12-23 07:57:58 +09:00
Yukihiro "Matz" Matsumoto
cbfaa5e20f
object.c: rename mrb_to_int to mrb_to_integer.
...
Consistent naming: `integer` to represent integer packed in `mrb_value`
instead of `int`.
2021-09-07 14:31:56 +09:00
Yukihiro "Matz" Matsumoto
80cf293bf6
pack.c: rename pack/unpack functions for readability.
2021-08-17 13:04:11 +09:00
Yukihiro "Matz" Matsumoto
57b347088d
fixup! pack.c: reduce dispatch in pack_unpack().
2021-08-17 13:04:06 +09:00
Yukihiro "Matz" Matsumoto
4385590d31
pack.c: reduce dispatch in pack_unpack().
2021-08-17 12:52:56 +09:00
Yukihiro "Matz" Matsumoto
bfe2bd4960
pack.c: fix M packing bug.
2021-08-16 10:56:44 +09:00
Yukihiro "Matz" Matsumoto
8e5e96239c
pack.c: fixed a overwriting bug in pack_w and pack_M.
2021-08-14 14:58:09 +09:00
dearblue
18ef4e35f3
Fixed compilation error of "mruby-pack" with MRB_NO_STDIO
2021-08-07 14:29:55 +09:00
Yukihiro "Matz" Matsumoto
47eca476e8
pack.c: fixed sign comparison warning.
2021-07-25 13:07:11 +09:00
Yukihiro "Matz" Matsumoto
f9303699d1
pack.c: fix integer signedness mixture.
2021-07-08 09:59:14 +09:00
Yukihiro "Matz" Matsumoto
50b6fafddf
pack.c: support `w' directive (BER integer compression).
2021-06-14 11:20:52 +09:00
Yukihiro "Matz" Matsumoto
1ed01a8d47
pack.c: count should not be negative for directives xX@.
2021-06-13 20:13:50 +09:00
Yukihiro "Matz" Matsumoto
bf2b06ced7
pack.c: raise error for unsupported w directive.
2021-06-13 14:21:51 +09:00
Yukihiro "Matz" Matsumoto
96ad60b9aa
pack.c: support `@' directive (absolute position).
2021-06-12 16:18:45 +09:00
Yukihiro "Matz" Matsumoto
952e7efdd7
pack.c: refactor pack/unpack 'X'.
2021-06-12 16:18:45 +09:00
Yukihiro "Matz" Matsumoto
3ddc57ed6e
pack.c: add X directive (back up byte).
2021-06-12 16:18:44 +09:00
Yukihiro "Matz" Matsumoto
fb013595ed
pack.c: count should be always positive. no check needed.
2021-06-12 16:18:44 +09:00
Yukihiro "Matz" Matsumoto
203495ccea
pack.c: fix long/int mixtures.
2021-06-12 16:18:44 +09:00
Yukihiro "Matz" Matsumoto
72ea85c8da
pack.c: remove unused arguments from static functions.
2021-06-12 16:18:44 +09:00
Yukihiro "Matz" Matsumoto
f764467c19
pack.c: wrong position after count read.
2021-06-12 16:18:43 +09:00
Yukihiro "Matz" Matsumoto
49af1fca03
readint.c: add new function mrb_int_read.
...
Difference from `strtoul(3)`:
* reads `mrb_int` based on configuration
* specifies the end of the string
* no sign interpretation
* base 10 only
2021-06-11 15:14:17 +09:00
Yukihiro "Matz" Matsumoto
b10a6fd472
pack.c: fix 'void* to char*` assignment.
2021-06-07 22:42:31 +09:00
Yukihiro "Matz" Matsumoto
32e96a1d4a
pack.c: add default to switch statement to silence warnings.
2021-06-07 09:06:37 +09:00
Yukihiro "Matz" Matsumoto
0afa651363
pack.c: support M specifier (quoted-printable).
2021-06-07 09:03:25 +09:00
Yukihiro "Matz" Matsumoto
cd64ddf372
pack.c: raise exception for unsupported specifiers.
2021-06-07 07:18:17 +09:00
Yukihiro "Matz" Matsumoto
e112c46281
pack.c: check overflow before calling pack_x.
2021-06-06 08:01:58 +09:00
Yukihiro "Matz" Matsumoto
d518294f20
pack.c: check overflow before reading count.
2021-06-06 08:01:01 +09:00
Yukihiro "Matz" Matsumoto
af3e0ddfc0
pack.c: failed to detect overflow when ch is zero in read_tmpl.
2021-06-06 08:00:24 +09:00
Yukihiro "Matz" Matsumoto
f01c29b0ec
pack.c: hold enum values in enum variables not int.
2021-06-05 20:04:59 +09:00
Yukihiro "Matz" Matsumoto
5eebbd7df2
Global renaming regarding integer and float.
...
Consistent number conversion function names:
* `mrb_value` to immediate (C) value
* `mrb_int()` -> `mrb_as_int()`
* `mrb_to_flo()` -> `mrb_as_float()`
* `mrb_value` to `mrb_value` (converted)
* `mrb_to_int()'
* `mrb_Integer()` - removed
* `mrb_Float()` -> `mrb_to_float`
Consistent function name (avoid `_flo` suffix):
* `mrb_div_flo()` -> `mrb_div_float`
2021-05-17 15:07:05 +09:00
dearblue
6fc5dc986a
Extend the tab with 8 whitespace
...
This work was done as follows:
- check: `git grep $'\011' -- :^oss-fuzz`
- convert: `ruby -pi -e 'nil while $_.sub!(/^(.*?)\t/) { $1 + " " * (8 - $1.size % 8) }'`
The `doc/guide/{compile,mrbgems}.md` file adds and removes whitespace to make the directory tree look the same.
In `mrbgems/mruby-socket/src/socket.c`, there is a part where the indent is changed from 4 to 2 at the same time as the tab is changed.
2021-05-05 22:16:03 +09:00
Yukihiro "Matz" Matsumoto
3da372b30f
pack.c: add more checks for pack_pack().
2021-02-27 12:00:24 +09:00
dearblue
b500e82950
Remove unnecessary range confirmation
...
This is a correction based on the review by @matz.
https://github.com/mruby/mruby/pull/5306#pullrequestreview-578378401
2021-01-29 22:33:03 +09:00
dearblue
9c36499e31
Fixed String#unpack to handle the highest range of integer values
...
Previously, problems occurred when the `fixnum` was exceeded.
- 32-bit cpu mode with `MRB_WORD_BOXING` and `MRB_INT32`:
```console
% bin/mruby -e 'p [0x7fffffff].pack("N").unpack("N")'
trace (most recent call last):
-e:1: cannot unpack to Integer: 2147483647 (RangeError)
```
- 64-bit cpu mode with `MRB_WORD_BOXING` and `MRB_INT64`:
```console
% bin/mruby -e 'p [0x7fffffff_ffffffff].pack("q").unpack("q")'
trace (most recent call last):
-e:1: cannot unpack to Integer: 9223372036854775807 (RangeError)
```
2021-01-29 22:27:36 +09:00
KOBAYASHI Shuji
3d056d084a
Rename MRB_{ENABLE,DISABLE}_ to MRB_{USE,NO}_; close #5163
...
| Previous Name | New Name |
|------------------------------|-------------------------|
| MRB_ENABLE_ALL_SYMBOLS | MRB_USE_ALL_SYMBOLS |
| MRB_ENABLE_SYMBOLL_ALL | MRB_USE_ALL_SYMBOLS |
| MRB_ENABLE_CXX_ABI | MRB_USE_CXX_ABI |
| MRB_ENABLE_CXX_EXCEPTION | MRB_USE_CXX_EXCEPTION |
| MRB_ENABLE_DEBUG_HOOK | MRB_USE_DEBUG_HOOK |
| MRB_DISABLE_DIRECT_THREADING | MRB_NO_DIRECT_THREADING |
| MRB_DISABLE_STDIO | MRB_NO_STDIO |
| ENABLE_LINENOISE | MRB_USE_LINENOISE |
| ENABLE_READLINE | MRB_USE_READLINE |
| DISABLE_MIRB_UNDERSCORE | MRB_NO_MIRB_UNDERSCORE |
| DISABLE_GEMS | MRB_NO_GEMS |
* `MRB_ENABLE_SYMBOLL_ALL` seems to be a typo, so it is fixed.
* `MRB_` prefix is added to those without.
* The previous names can also be used for compatibility.
2020-11-21 21:14:40 +09:00