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
Yukihiro "Matz" Matsumoto
996417cabf
integer range check was moved to mrb_flo_to_fixnum(); ref #3025
2015-11-19 22:49:50 +09:00
Yukihiro "Matz" Matsumoto
09abdcb5e8
negative binary format should not be masked by 10bits; ref #3025
2015-11-19 22:49:50 +09:00
Yukihiro "Matz" Matsumoto
1a9b607a4d
binary sprintf should not be restricted by mrb_int size; fix #3025
2015-11-19 22:49:50 +09:00
Yukihiro "Matz" Matsumoto
e35c3aff83
unsigned long may be smaller than mrb_int; use uint64_t instead; fix #2935
2015-09-03 00:14:37 +09:00
Franck Verrot
2588507285
Remove unnecessary backticks.
...
Dr Markus Kuhn published in 1999 an article [1] explaining in details
why we shouldn't use the ASCII grave accent (0x60) as a left quotation.
Backticks have been used most notably to produce nice-looking LaTeX
documents but it doesn't seem to be an issue on modern platforms and
for the oldest ones, there are workarounds as mentioned by Dr Kuhn.
[1]: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2015-06-24 13:07:07 +02:00
Yukihiro "Matz" Matsumoto
33e44a612c
refactor MACRO to avoid local variable name conflict; ref #2585
2014-09-04 23:59:27 +09:00
cremno
fec2c66ea8
get rid of shadowing variables (mrbgems)
...
Mostly renaming, except that the definition of struct accessor methods
is now done in a new function.
2014-09-04 12:31:52 +02:00
Yukihiro "Matz" Matsumoto
61ce5892cc
remove spaces after open parens
2014-07-12 20:36:45 +09:00
Yukihiro "Matz" Matsumoto
c3ed6e3d25
use is_a? Array for String#% argument check as the original PR did in #2349
2014-06-04 09:08:22 +09:00
Yukihiro "Matz" Matsumoto
4380f86150
Special treatment for Hashes, not Arrays; ref #2349
2014-06-03 16:33:30 +09:00
Tomoyuki Sahara
fe9f3fdd20
add 'String#%'.
2014-06-03 16:31:20 +09:00
cremno
86cfcd20d6
simply use isfinite
2014-05-04 01:50:17 +02:00
take_cheeze
b5028421b9
Use mrb_int in mrbgem rest argument getting.
2014-04-25 22:02:10 +09:00
cubicdaiya
bf3f45fc70
Use mrb_int instead of int
2014-03-25 22:33:53 +09:00
cubicdaiya
51947f132b
Use bool-macro instead of magic-number
2014-03-22 09:55:48 +09:00
take_cheeze
c73f8d4def
move summary of mrbgems in default gembox to its spec
2014-03-17 00:34:24 +09:00
cremno
1b6a4fb5a2
add MRB_INT_BIT
2014-03-11 20:14:18 +01:00
ksss
54132e4364
make embed string when create literals
2014-03-06 13:47:51 +00:00
ksss
4070b5987a
embed small string
...
use flags 4 for *this object is embed*
use flags 8~64 for *embed string length*
2014-03-06 13:12:08 +00:00
Yukihiro "Matz" Matsumoto
1f134d723c
cancel 313f6b; add fallthrough comment
2014-02-28 18:55:30 +09:00
chasonr
5e5ee841a1
Implement sprintf("%c") for UTF-8.
...
* sprintf("%c") is changed to accept a string for which String#size returns
1, even if it is longer than one byte, and to convert a Fixnum via
Fixnum#chr (possibly returning more than one byte). Thus, if the UTF-8
gem is in use, a character will be understood as a single UTF-8 character.
* The change to sprintf depends on the implementation of Fixnum#chr added
to mrbgems/mruby-string-utf8/src/string.c.
This should work with any other gem that implements a multibyte encoding, as
long as it implements String#size and Fixnum#chr as appropriate.
2014-02-26 20:18:26 -05:00
Yukihiro "Matz" Matsumoto
313f6b5997
forget to break in the switch statement
2014-02-27 08:23:32 +09:00
cubicdaiya
94c5a5ee73
use mrb_str_new_lit instead of mrb_str_new for C string literals
2014-02-26 02:23:50 +09:00