64 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto f1207573bd Uninitialized value returned. 2017-12-08 09:50:02 +09:00
YAMAMOTO Masaya 625f9f6fa3 Merge branch 'master' of github.com:mruby/mruby 2017-11-04 01:23:12 +09:00
Yukihiro "Matz" Matsumoto 3c20c96f84 Use a new function: mrb_get_argc(); ref #3826 2017-10-17 15:23:32 +09:00
Yukihiro "Matz" Matsumoto 332d8d2a1c Add String#delete_{prefix,suffix}; CRuby2.5 2017-10-17 11:19:12 +09:00
YAMAMOTO Masaya 9c1f21aaa1 Support MRB_WIHTOUT_FLOAT to mruby-string-ext 2017-10-16 18:09:56 +09:00
Tomasz Dąbrowski 2640896911 fix: mrbgems\mruby-string-ext\src\string.c(49): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 8d816fa142 fix: mrbgems\mruby-string-ext\src\string.c(30): warning C4244: '=': conversion from 'mrb_int' to 'long', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski d3819620ce fix: mrbgems\mruby-string-ext\src\string.c(38): warning C4244: '=': conversion from 'mrb_int' to 'char', possible loss of data 2017-09-27 22:22:04 +02:00
Yukihiro "Matz" Matsumoto 198c898817 Rename mrb_str_concat2 to mrb_str_concat_m.
According to the naming convention a function that implements
a method should be suffixed by `_m`.
2017-08-18 22:17:47 +09:00
Yukihiro "Matz" Matsumoto 615e7e44e3 Avoid using snprintf(3) in case MRB_DISABLE_STDIO; fix #3714 2017-06-20 09:39:33 +09:00
Asmod4n abca63c73b Save gc_arena after buffer got allocated
Latest fix was freeing the buffer while it was still in use.
Fixes #3712
2017-06-19 20:27:38 +02:00
Yukihiro "Matz" Matsumoto 0411cea2df Use MRB_PRId instead of d for mrb_int decimal specifier; ref #3701 2017-06-16 11:50:38 +09:00
Yukihiro "Matz" Matsumoto e96f254ead Use mrb_str_new() instead of malloc(); ref #3701
Otherwise the function may terminate and cause memory leaks.
2017-06-16 11:46:40 +09:00
Yukihiro "Matz" Matsumoto 473b2bb20d Should not use sizeof(buf) when buf is char*; #3701 2017-06-16 11:42:51 +09:00
ksss 4d9ca27ba6 Use malloc instead of dynamic allocation 2017-06-14 18:28:39 +09:00
ksss 432a813905 Fix arena overflow error 2017-06-14 18:12:56 +09:00
ksss 19785f43d1 Reimplement String#upto 2017-06-14 17:30:31 +09:00
ksss 98f9c33fe0 String#concat: Try to convert when not string 2017-05-21 10:30:27 +09:00
Yukihiro "Matz" Matsumoto 3e07a2d77c Silence warnings caused by implicit type casting. 2017-04-25 21:00:16 +09:00
Yukihiro "Matz" Matsumoto 77331d127b Unify else clause style 2017-04-03 16:56:27 +09:00
Tomasz Dabrowski ac9d04f4af String#ljust and String#rjust reimplemented with optimized Ruby 2017-02-10 15:31:33 +01:00
Tomasz Dabrowski 981105b3e6 String#ljust and String#rjust reimplementation (fix #3445)
- String#ljust and String#rjust are now C functions to improve performance
 - infinite loop because of an empty padding argument is now prevented (ArgumentError is raised)
 - extra tests for ljust/rjust added
2017-02-10 12:59:28 +01:00
Yukihiro "Matz" Matsumoto 5e1d923381 Changed the behavior of mrb_range_beg_len(); close #3411
The new API is:

int mrb_range_beg_len(mrb, range, &beg, &len, len, trunc)

The new argument `trunc` is a boolean value that specifies
whether the function truncates the range. The new return value
is an integer instead of a boolean, that is:

 0: not a range
 1: range with proper edges
 2: out of range

To get the old behavior, you have to rewrite:

  mrb_range_beg_len(mrb, range, &beg, &len, len)

to:

  mrn_range_beg_len(mrb, range, &beg, &len, len, TRUE) == 1

[Breaking Change]
2017-01-23 14:35:26 +09:00
ksss eeca6ec8f5 Rewrite String#prepend with Ruby
Fix #3357
2017-01-04 14:00:28 +09:00
Yukihiro "Matz" Matsumoto 803bf010ca save/restore arena index around yield; ref #3359 2016-12-28 13:00:28 +09:00
Craig Lehmann 83005d83d8 Read length after args in String#setbyte
Prevents RCE
Reported by https://hackerone.com/raydot
2016-11-24 10:31:29 -05:00
Yukihiro "Matz" Matsumoto 242b219471 Fixed memory disclosure in String#lines
Reported from from Alex Snaps via Mathieu Leduc-Hamel,
both from shopify.com.  Thank you!
2016-11-16 02:05:19 +09:00
Hiroshi Mimaki 861b0eed7b Fix String#ord failure which return a negative value 2016-08-17 15:29:59 +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 798ec3aff4 UTF-8 string support in core
define MRB_UTF8_STRING (in mrbconf.h) to enable UTF-8 support.
2015-09-24 02:37:33 +09:00
Yukihiro "Matz" Matsumoto 4fdf492219 add String#setbyte and String#byteslice to mruby-string-ext 2015-08-05 11:28:41 +09:00
cremno 2ee84eb3df remove unnecessary including of <ctype.h>
Not needed anymore since 85075bef75
2015-05-28 10:44:20 +02:00
Kouhei Sutou 09419874c8 Suppress warnings generated by -Wwrite-strings
Here are suppressed warnings:

    src/fmt_fp.c: In function 'fmt_fp':
    src/fmt_fp.c:124:16: warning: initialization discards 'const' qualifier from pointer target type
         char *ss = (t&32)?"inf":"INF";
                    ^
    src/fmt_fp.c:125:17: warning: assignment discards 'const' qualifier from pointer target type
         if (y!=y) ss=(t&32)?"nan":"NAN";
                     ^
    mrbgems/mruby-string-ext/src/string.c: In function 'mrb_str_succ_bang':
    mrbgems/mruby-string-ext/src/string.c:302:27: warning: assignment discards 'const' qualifier from pointer target type
           if (e == b) prepend = "1";
                               ^
    mrbgems/mruby-string-ext/src/string.c:305:27: warning: assignment discards 'const' qualifier from pointer target type
           if (e == b) prepend = "a";
                               ^
    mrbgems/mruby-string-ext/src/string.c:308:27: warning: assignment discards 'const' qualifier from pointer target type
           if (e == b) prepend = "A";
                               ^
    mrbgems/mruby-bin-mruby/tools/mruby/mruby.c: In function 'main':
    mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:213:13: warning: assignment discards 'const' qualifier from pointer target type
         cmdline = args.cmdline ? args.cmdline : "-";
                 ^
    mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c: In function 'print_breakpoint':
    mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c:159:3: warning: initialization discards 'const' qualifier from pointer target type
       char* enable_letter[] = {BREAK_INFO_MSG_DISABLE, BREAK_INFO_MSG_ENABLE};
       ^
    mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c:159:3: warning: initialization discards 'const' qualifier from pointer target type
2015-04-18 21:43:58 +09:00
Yukihiro "Matz" Matsumoto a19a6edb7c mrb_str_new(mrb, "", len) creates an unmodifiable string object; ref #2674 2014-12-17 08:06:44 +09:00
Jun Hiroe 7ea38ce473 Add String#prepend 2014-12-17 02:23:36 +09:00
Tatsuhiko Kubo 45103ebc20 use mrb_str_cat_lit() instead of mrb_str_cat_cstr(). 2014-08-21 16:51:08 +09:00
mattn 4ece1e3e29 "-a-a-".succ should be "-a-b-" 2014-08-11 15:00:44 +09:00
mattn 3103d063e2 Fix String#succ. "-a-".succ should be "-b-" 2014-08-11 14:28:05 +09:00
mattn 34f40b0a01 Fix String#succ. "-".succ should be "." 2014-08-11 14:01:10 +09:00
mattn dc0c354658 Add String#succ, String#succ!, String#next, String#next! 2014-08-08 17:58:07 +09:00
ksss f1e15b0236 String#clear: use String#replace to simple 2014-06-11 14:46:52 +00:00
Jun Hiroe 9c259c501a Add NOFREE macros 2014-06-11 01:00:35 +09:00
Yukihiro "Matz" Matsumoto 6459a98448 move String#clear to mruby-string-ext; ref #2370 2014-06-07 22:28:42 +09:00
Yukihiro "Matz" Matsumoto b01bb33b75 fix String#lines comment; ref mattn@2e1855a 2014-06-04 10:51:09 +09:00
mattn c927277486 Add String#lines 2014-06-04 10:41:07 +09:00
Jun Hiroe e67817fcec Implement String#chr 2014-06-03 19:49:38 +09:00
take_cheeze b5028421b9 Use mrb_int in mrbgem rest argument getting. 2014-04-25 22:02:10 +09:00
cremno 649081661a reduce RSTRING_PTR usage 2014-04-14 00:58:34 +02:00
cubicdaiya 9c06f297ee add String#oct 2014-03-27 14:10:08 +09:00
mattn 0df65751c6 Implement String#hex 2014-03-27 11:28:29 +09:00