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
Tomasz Dąbrowski
17c249780f
fix String#% %d test with MRB_INT16 set
2017-08-25 14:36:05 +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
Christopher Aue
2730231e50
added tests for #3736
2017-07-16 22:34:23 +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
Tomasz Dąbrowski
4289e0cd81
Fix for sprintf test exceeding bounds with MRB_INT16
2016-11-21 00:37:03 +01:00
ksss
e3bc81e75e
Fix warning shift-negative-value
2016-07-01 22:00:55 +09:00
Yukihiro "Matz" Matsumoto
8f0c1c7d3c
mruby-sprintf:fix double negative signs in printf; fix #3148
...
MRB_INT_MAX does not have corresponding positive integer
2016-04-23 23:50:01 +09:00
Yukihiro "Matz" Matsumoto
c5229074bb
mruby-sprintf: format specifiers o,u,x,b ignore sign(+); ref #3148
2016-04-23 22:20:11 +09:00
Yukihiro "Matz" Matsumoto
7c82bfa7fe
mruby-sprintf to use mrb_int formatting macros; ref #3076
2016-01-07 12:23:17 +09:00
Yukihiro "Matz" Matsumoto
5c405dea3d
include changed from by quotes ("") to by brackets (<>); close #3032
2015-11-27 17:48:23 +09:00
Yukihiro "Matz" Matsumoto
abc724840e
formatting buffer should be bigger for negative dots; ref #3025
2015-11-19 22:49:50 +09:00
Yukihiro "Matz" Matsumoto
f974880563
binary format no longer need to preserve org_v
2015-11-19 22:49:50 +09:00