111 Commits

Author SHA1 Message Date
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 5ee42ff1dd Merge pull request #5833 from jbampton/remove-coding-utf-8-ruby
Remove `# coding: utf-8` from Ruby files
2022-10-27 18:11:54 +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
John Bampton 44db4f18d3 Remove # coding: utf-8 from Ruby files
The default script encoding is Encoding::UTF-8 after v2.0.

https://ruby-doc.org/core-2.1.2/Encoding.html#class-Encoding-label-Script+encoding
2022-10-27 04:43:13 +10: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
dearblue 9a84ef926b Avoid adding MRUBY_ROOT/src to cc.include_paths 2022-07-02 09:56:13 +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
John Bampton 188e9b6fb0 Enable markdownlint rules MD003,MD005,MD007
Lint Markdown

https://github.com/DavidAnson/markdownlint#rules--aliases
2021-06-22 06:57:03 +10: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 bba044cfc8 test/pack.c: reorganize test suits. 2021-06-07 08:54:54 +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