dearblue
67606170e3
Add configuration guard for MRB_DISABLE_STDIO
...
ref #4576 and ref #4947
* Need MRBAPI functions without `MRB_DISABLE_STDIO`:
* mrbgems/mruby-bin-debugger
* mrbgems/mruby-bin-mirb
* mrbgems/mruby-bin-mrbc
* mrbgems/mruby-bin-mruby
* mrbgems/mruby-bin-strip
* Need `stdio.h`:
* mrbgems/mruby-io
* mrbgems/mruby-print
* Need `snprintf()` in `stdio.h`:
* mrbgems/mruby-pack
* mrbgems/mruby-sprintf
2020-03-08 21:57:17 +09:00
dearblue
cc1db2d117
Remove unnecessary 'stdio.h'; ref #4947
...
'stdio.h' is included in 'mruby.h' ('mrbconf.h').
However, keep 'stdio.h' used by mruby-test.
2020-03-08 21:42:09 +09:00
KOBAYASHI Shuji
04baaab311
Fix argument specs to Kernel
2019-11-15 19:07:42 +09:00
Yukihiro "Matz" Matsumoto
a1886942eb
Further refactoring over #4738
2019-09-29 14:30:41 +09:00
dearblue
e48207cdb3
Remove unnecessary assignments
2019-09-29 13:45:16 +09:00
Yukihiro "Matz" Matsumoto
60cc46a92c
Use proper type specifier for mrb_raisef(); ref #4731
...
The following two may be different:
* `%d` for `int`
* `%i` for `mrb_int`
2019-09-26 09:48:01 +09:00
Yukihiro "Matz" Matsumoto
0d661bcca6
Merge pull request #4731 from dearblue/consistent-type
...
Keep the type of `posarg` consistent
2019-09-26 06:30:55 +09:00
dearblue
9f6ba4bfa1
Keep the type of posarg consistent
...
Match the type with the caller and related functions.
2019-09-25 23:17:06 +09:00
dearblue
5ce1bec1bc
Add "fall through"
2019-09-25 23:07:05 +09:00
KOBAYASHI Shuji
334afb167c
Use new specifiers/modifiers of mrb_vfromat()
...
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in
my environment than before the introduction of new specifiers/modifiers
(5116789a ) with this change.
------------+-------------------+-------------------+--------
BINARY | BEFORE (5116789a ) | AFTER (This PR) | RATIO
------------+-------------------+-------------------+--------
mruby | 593416 bytes | 593208 bytes | -0.04%
libmruby.a | 769048 bytes | 767264 bytes | -0.23%
------------+-------------------+-------------------+--------
BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613 ,
so I put it back.
2019-08-05 13:18:50 +09:00
Yukihiro "Matz" Matsumoto
9516731329
Use type checking mrb_to_str instead of converting mrb_str_to_str.
2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto
610bcc88c2
Removed to_hash conversion method.
2018-11-19 12:08:28 +09:00
Clayton Smith
2760cea451
Prevent signed integer overflow.
2018-09-14 16:53:26 -04:00
Yukihiro "Matz" Matsumoto
625976d793
Fix integer overflow issue; fix #4108
...
I misunderstood the return value from `snprintf()`, which is NOT number
of characters written in buffer, but the number of character the buffer
has to have to write the complete output.
2018-09-07 03:20:57 +09:00
Yukihiro "Matz" Matsumoto
180f39bf4c
Check size of the integer multiply before actual overflow; fix #4062
2018-07-31 16:14:18 +09:00
YAMAMOTO Masaya
5d781312ca
Support MRB_WIHTOUT_FLOAT to mruby-sprintf
2017-10-13 16:42:35 +09:00
Tomasz Dąbrowski
a94525d4ea
fix: mrbgems\mruby-sprintf\src\sprintf.c(1052): warning C4244: '+=': conversion from 'mrb_int' to 'int', possible loss of data
2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski
1e2c962fa5
fix: mrbgems\mruby-sprintf\src\sprintf.c(623): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data
2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski
897eabb1bb
fix: mrbgems\mruby-sprintf\src\sprintf.c(646): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data
2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski
e10b329fa3
fix: mrbgems\mruby-sprintf\src\sprintf.c(618): warning C4244: 'initializing': conversion from 'mrb_int' to 'int', possible loss of data
2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski
861077f779
fix: mrbgems\mruby-sprintf\src\sprintf.c(516): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data
2017-09-27 22:22:04 +02:00
Yukihiro "Matz" Matsumoto
f1767fd079
Separate mrb_str_buf_new and mrb_str_new_capa.
...
`mrb_str_buf_new` is an old function that ensures capacity size of
`MRB_STR_BUF_MIN_SIZE` minimum. Usually one need to use
`mrb_str_new_capa` instead.
2017-08-18 22:17:48 +09:00
Yukihiro "Matz" Matsumoto
8bf492f127
Reduce integer type mismatch warnings in VC.
2017-08-12 09:35:35 +09:00
Christopher Aue
2fadddcd20
Replaced tabs with spaces
2017-08-09 21:56:27 +02:00
Yukihiro "Matz" Matsumoto
1c02b8558f
Avoid duplicated width filling for sprintf %d specifier; fix #3736
2017-07-14 15:21:11 +09:00
Yukihiro "Matz" Matsumoto
cc04f03393
print("%d", 0) should not print -0; fix #3731
2017-07-05 23:31:50 +09:00
Yukihiro "Matz" Matsumoto
b68e7a605c
Negation was not a good way to handle negative integers; fix #3729
...
There's a number that negation does not work (-2147483648 in 32bit
environment).
2017-07-05 18:13:37 +09:00
Yukihiro "Matz" Matsumoto
b643a1a8bc
In Ruby, sprintf specifier %u should behave as %d; fix #3730
...
Since there's no unsigned integer in Ruby. Binary, octal and
hexadecimal negative numbers can be represented by using 2's
compliment. But decimal (not being power of 2) cannot be use
that kind of format.
2017-07-05 17:48:40 +09:00
Yukihiro "Matz" Matsumoto
e9cdc88008
Refactor sprintf() code.
2017-07-04 08:50:39 +09:00
Yukihiro "Matz" Matsumoto
31bc2b0009
Initialize flags for each loop.
2017-07-04 08:46:33 +09:00
Yukihiro "Matz" Matsumoto
f0abd4241f
Avoid mrb_funcall() unless absolutely necessary; ref #3722
...
As a result, `#chr` is not called for ch < 0x80, so we need to
update the "invalid chr" test.
2017-06-28 12:03:53 +09:00
Yukihiro "Matz" Matsumoto
3ef97e3dd9
Under MRB_INT64, width may be bigger than INT_MAX; fix #3665
2017-05-25 10:40:35 +09:00
ksss
30df7c8762
Fix segmentation fault ref: #3648
2017-05-08 23:18:14 +09:00
Nobuyoshi Nakada
ef6e14ee2b
Better error message
...
Raise argument error with the better message, at the only place
where the size to fill can be negative.
2017-04-29 10:17:24 +09:00
Nobuyoshi Nakada
e05c30738e
Use FILL and PUSH
...
Instead of loop or `memcpy` after `CHECK`, use dedicated macros,
`FILL` and `PUSH`, respectively.
2017-04-29 10:10:31 +09:00
Nobuyoshi Nakada
cd4e9a0518
Refactor "%f" % Inf/NaN
...
As for non-finite float, calculate the exact needed size with the
space flag.
2017-04-23 09:54:44 +09:00
Nobuyoshi Nakada
7314423bd1
Fix space flag when Inf/NaN and width==3
...
While `"% 2f"` and `"% 4f"` result in `" Inf"` and `" Inf"`
respectively, `"% 3f"` results in `"Inf"` (no space).
2017-04-23 09:54:20 +09:00
Yukihiro "Matz" Matsumoto
77331d127b
Unify else clause style
2017-04-03 16:56:27 +09:00
ksss
2005bf997f
Should use mrb_int for any object
...
o=Object.new
def o.to_int
1
end
p "%*d" % [o, 1]
2017-03-18 22:06:01 +09:00
Nobuyoshi Nakada
d8c4fe7bcb
Fix out-of-bound access
...
Get rid of out-of-bound access when single % at the end.
2017-03-13 23:56:33 +09:00
Yukihiro "Matz" Matsumoto
94395e81c1
The width printf specifier may be negative; fix #3498
2017-03-11 15:22:54 +09:00
Yukihiro "Matz" Matsumoto
f30ec2dfb0
fixup! Check return value from snprintf(); ref #3498
2017-03-11 15:22:42 +09:00
Yukihiro "Matz" Matsumoto
e3922318bd
Check return value from snprintf(); ref #3498
2017-03-11 15:18:41 +09:00
Yukihiro "Matz" Matsumoto
ff03a9a61c
Avoid integer overflow in sprintf(); fix #3439
...
This issue was reported by https://hackerone.com/aerodudrizzt
2017-02-11 20:35:52 +09:00
Yukihiro "Matz" Matsumoto
c83069860a
Dots is not needed for base 10 negative numbers; fix #3400
2017-01-16 17:21:55 +09:00
Yukihiro "Matz" Matsumoto
5e3077c00d
One less argument for raisef(); fix #3355
...
This issue was reported by https://hackerone.com/mg36
2016-12-21 16:46:26 +09:00
Yukihiro "Matz" Matsumoto
432570723d
Check if width is zero or negative before fill; fix #3347
...
Reported by https://hackerone.com/haquaman .
2016-12-18 02:02:30 +09:00
Yukihiro "Matz" Matsumoto
2edf15bed8
Prohibit mixture of posarg and nextarg; ref #3347
2016-12-18 02:02:30 +09:00
Tomasz Dąbrowski
1af9e363f2
Fixes for compiling mruby as C++
2016-11-24 09:28:00 +09:00
Bouke van der Bijl
9bf1c0e1dc
Fix segfault when Fixnum#chr doesn't return a string
2016-11-23 15:18:52 -05:00