aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
Commit message (Collapse)AuthorAgeFilesLines
* * include/ruby/oniguruma.h (onigenc_get_prev_char_head): add endakr2008-09-131-6/+6
| | | | | | | | | | | | | | | | | | | | argument. * include/ruby/encoding.h (rb_enc_prev_char): ditto. * regenc.c (onigenc_get_prev_char_head): add end argument. * regparse.c: follow the interface change. * regexec.c: ditto. * string.c: ditto. * parse.y: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/oniguruma.h (onigenc_get_right_adjust_char_head): addakr2008-09-131-2/+3
| | | | | | | | | | | | | | | | | | | end argument. * include/ruby/encoding.h (rb_enc_right_char_head): add end argument. * regenc.c (onigenc_get_right_adjust_char_head): use end argument. * re.c (rb_reg_adjust_startpos): follow the interface change. * string.c (rb_str_index): ditto. * regexec.c (backward_search_range): ditto. (onig_search): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/oniguruma.h (OnigCodePoint): unsigned long to unsigned int.naruse2008-09-111-51/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/ruby/encoding.h (rb_enc_codepoint): ditto. * encoding.c (rb_enc_codepoint): signed int to unsigned int. * encoding.c (rb_enc_ascget): ditto. * string.c (rb_str_casecmp): ditto. * string.c (enc_succ_alnum_char): ditto. * string.c (rb_str_inspect): ditto. * string.c (rb_str_upcase_bang): ditto. * string.c (rb_str_downcase_bang): ditto. * string.c (rb_str_capitalize_bang): ditto. * string.c (rb_str_swapcase_bang): ditto. * string.c (struct tr): ditto. * string.c (trnext): ditto. * string.c (tr_trans): ditto. * string.c (tr_setup_table): ditto. * string.c (tr_find): ditto. * string.c (rb_str_delete_bang): ditto. * string.c (rb_str_squeeze_bang): ditto. * string.c (rb_str_count): ditto. * string.c (rb_str_split_m): ditto. * string.c (rb_str_each_line): ditto. * string.c (rb_str_lstrip_bang): ditto. * string.c (rb_str_rstrip_bang): ditto. * string.c (rb_str_intern): ditto. * dir.c (char_casecmp): ditto. * sprintf.c (rb_str_format): ditto. * enc/emacs_mule.c (mbc_to_code): to be 32bit clean. * enc/emacs_mule.c (code_to_mbc): ditto. * enc/gb18030.c (mbc_to_code): ditto. * enc/gb18030.c (code_to_mbc): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: Mac OS X's crypt(2) is broken with invalid salt.kazu2008-09-071-0/+15
| | | | | | | | [ruby-dev:35899] * string.c (rb_str_crypt): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (DBL2NUM): renamed from DOUBLE2NUM.matz2008-09-051-1/+1
| | | | | | | a patch from Tadashi Saito <shiba at mail2.accsnet.ne.jp> in [ruby-dev:36102]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_index_m): only regexp uses byte offset.naruse2008-08-291-6/+6
| | | | | | * string.c (rb_str_rindex_m): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * encoding.c (rb_enc_compatible): ASCII compatible string and US-ASCIInaruse2008-08-291-0/+6
| | | | | | | | | | | regexp is compatible. [ruby-dev:36033] * string.c (rb_str_index_m): second argument is position of character. by usa. [ruby-dev:36033] * string.c (rb_str_rindex_m): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_shared_replace): remove corrupt noembed stringmame2008-08-281-4/+3
| | | | | | | which causes SEGV. [ruby-dev:35989] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (rb_intern_const): tiny optimization.nobu2008-08-161-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_drop_bytes): use memmove.nobu2008-08-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in (rb_cv_gcc_function_alias): checks alias attribute.nobu2008-08-131-16/+8
| | | | | | | * string.c (alias_func): replaced with RUBY_ALIAS_FUNCTION. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (alias_func): changed to 'weak, alias' from 'alias' forkouji2008-08-131-2/+2
| | | | | | | Mac OSX. (closes #429) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * object.c (rb_obj_untrusted): new method Object#untrusted?.shugo2008-08-131-1/+5
| | | | | | | | | | | | | | | (rb_obj_untrust): new method Object#untrust. (rb_obj_trust): new method Object#trust. * array.c, debug.c, time.c, include/ruby/ruby.h, re.c, variable.c, string.c, io.c, dir.c, vm_method.c, struct.c, class.c, hash.c, ruby.c, marshal.c: fixes for Object#untrusted?. * test/ruby/test_module.rb, test/ruby/test_array.rb, test/ruby/test_object.rb, test/ruby/test_string.rb, test/ruby/test_marshal.rb, test/ruby/test_hash.rb: added tests for Object#untrusted?. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: Apply a temporary fix to fix build on OS X. A realknu2008-08-131-1/+1
| | | | | | | fix will follow later. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * error.c (rb_eEncCompatError): add Exception.naruse2008-08-121-4/+4
| | | | | | | | | | | | | | | | * include/ruby/ruby.h: ditto. * encoding.c (rb_enc_check): use rb_eEncCompatError. * string.c (rb_enc_cr_str_buf_cat): ditto. * string.c (rb_str_sub_bang): ditto. * string.c (rb_str_hex): ditto. * string.c (rb_str_oct): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_splice_0): call rb_str_drop_bytes, not rb_str_drop.akr2008-08-121-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_drop_bytes): new function to drop first bytes.nobu2008-08-121-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_drop): new function to drop first bytes.nobu2008-08-121-0/+34
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_str_new2, rb_tainted_str_new2,nobu2008-08-121-22/+47
| | | | | | | | rb_usascii_str_new2): use with-length versions with strlen to optimize strlen, if optimized. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_intern): constified.nobu2008-08-121-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_intern): should check symbol table overflow.matz2008-08-121-2/+17
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * marshal.c (dump_ensure), process.c (run_exec_dup2),nobu2008-08-041-4/+3
| | | | | | | | | string.c (rb_str_replace), transcode.c (transcode_dispatch): fixed memory leaks. based on patches from shinichiro.h <shinichiro.hamaji AT gmail.com> at [ruby-dev:35751]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_shared_replace): fixed memory leak. a patch fromnobu2008-08-031-4/+4
| | | | | | | shinichiro.h <shinichiro.hamaji AT gmail.com> at [ruby-dev:35742] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (sym_inspect): remove dead code.mame2008-07-301-5/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h, sprintf.c (rb_str_catf, rb_str_vcatf): newnobu2008-07-221-0/+14
| | | | | | | | | functions. [ruby-dev:35597] * string.c (rb_str_capacity): new function to return the capacity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_str_buf_new2): optimization for literals.nobu2008-07-211-2/+3
| | | | | | | * string.c (str_buf_cat): returns VALUE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_str_buf_cat2, rb_str_cat2): optimizationnobu2008-07-211-0/+2
| | | | | | | for literals. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_succ): alphabets or numerics mutually enclosingnobu2008-07-081-8/+17
| | | | | | | | non-alphanumeric characters can carry up. e.g., "1.999".succ should be "2.000". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_succ): limit carrying in an alphanumeric region ifnobu2008-07-071-3/+6
| | | | | | | exists. [ruby-dev:35094] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_format_m): make tmp volatile to avoid possible GCakr2008-06-291-1/+1
| | | | | | | problem. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (struct RRegexp): new field usecnt. replaceakr2008-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | | str and len by src. * gc.c (gc_mark_children): mark src field of regexp. (obj_free): don't free str field. * re.c (REG_BUSY): removed. (rb_reg_initialize): prohibit re-initialize regexp. (rb_reg_search): use usecnt to prevent freeing regexp currently using. this prevents SEGV by: r = /\A((a.)*(a.)*)*b/ r =~ "ab" + "\xc2\xa1".force_encoding("euc-jp") t = Thread.new { r =~ "ab"*8 + "\xc2\xa1".force_encoding("utf-8")} sleep 0.2 r =~ "ab"*8 + "\xc2\xa1".force_encoding("euc-jp") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_str_new2, rb_tainted_str_new2,nobu2008-06-271-0/+4
| | | | | | | | rb_usascii_str_new2): use with-length versions with strlen to optimize strlen. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_index_m, rb_str_rindex_m, rb_str_include): fixmame2008-06-261-14/+9
| | | | | | | rdoc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_store, rb_ary_splice): not depend on unspecifiednobu2008-06-201-43/+27
| | | | | | | | | behavior at integer overflow. * string.c (str_buf_cat): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_sub_bang): should preserve replacement pointsmatz2008-06-201-9/+11
| | | | | | since they may be altered in the yielded block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_memhash): randomize hash to avoid algorithmicakr2008-06-201-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | complexity attacks. (rb_str_hash): use rb_memhash. * include/ruby/intern.h (rb_reset_random_seed): declared. * thread.c (rb_thread_atfork): call rb_reset_random_seed. * inits.c (rb_call_inits): call Init_RandomSeed at first. * random.c (seed_initialized): defined. (fill_random_seed): extracted from random_seed. (make_seed_value): extracted from random_seed. (rb_f_rand): initialize random seed at first. (initial_seed): defined. (Init_RandomSeed): defined. (Init_RandomSeed2): defined. (rb_reset_random_seed): defined. (Init_Random): call Init_RandomSeed2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (ary_new, rb_ary_initialize, rb_ary_store,shyouhei2008-06-191-0/+3
| | | | | | | | | | | | | | | | | rb_ary_aplice, rb_ary_times): integer overflows should be checked. based on patches from Drew Yao <ayao at apple.com> fixed CVE-2008-2726 * string.c (rb_str_buf_append): fixed unsafe use of alloca, which led memory corruption. based on a patch from Drew Yao <ayao at apple.com> fixed CVE-2008-2726 * sprintf.c (rb_str_format): backported from trunk. * intern.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (str_gsub): should preserve last successful matchmatz2008-06-191-18/+17
| | | | | | data. [ruby-dev:35182] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (str_alloc): specify 'inline' modifier.matz2008-06-191-7/+2
| | | | | | | | | | * string.c (str_alloc): remove cSymbol hack that no longer necessary. * string.c (scan_once): avoid retrieving encoding info unless necessary. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_scan): String#scan should preserve lastmatz2008-06-191-4/+7
| | | | | | successful match data. [ruby-dev:35106] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (read_all): should use io_read_encoding(), notmatz2008-06-111-3/+0
| | | | | | | | | | | io_input_encoding(). * io.c (rb_io_getline_1): reduce calling of io_read_encoding(). * string.c (rb_str_scan): need not to restore $~ value, so avoid pinning match object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.nobu2008-06-091-1/+3
| | | | | | | * *.c: no cache in init functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,ko12008-06-081-4/+4
| | | | | | | | | | | | | | | | | | | enumerator.c (enumerator_allocate), eval_jump.c, file.c, hash.c, io.c, load.c, pack.c, proc.c, random.c, re.c, ruby.c, st.c, string.c, thread.c, thread_pthread.c, time.c, util.c, variable.c, vm.c, gc.c: allocated memory objects by xmalloc (ruby_xmalloc) should be freed by xfree (ruby_xfree). * ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c, ext/gdbm/gdbm.c, ext/json/ext/parser/parser.c, ext/json/ext/parser/unicode.c, ext/openssl/ossl_cipher.c, ext/openssl/ossl_hmac.c, ext/openssl/ossl_pkey_ec.c, ext/sdbm/init.c, ext/strscan/strscan.c, ext/zlib/zlib.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (hash): should be "static".ko12008-06-041-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * suppress warnings with -Wwrite-string.nobu2008-05-311-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_usascii_str_new): use rb_str_new.naruse2008-05-201-8/+5
| | | | | | | | * string.c (rb_enc_str_new): ditto. * string.c (rb_usascii_str_new2): use rb_str_new2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_enc_strlen_cr): need to set ENC_CODERANGE_7BIT ifmatz2008-05-201-15/+35
| | | | | | | | | | | | | | | | | search_nonascii() fails. [ruby-dev:34751] * string.c (rb_str_reverse): preserve coderange info if the receiver is 7bit string. * string.c (rb_str_reverse_bang): ditto. * string.c (rb_str_reverse_bang): should have called single_byte_optimizable before rb_str_modify() that clears coderange info. * string.c (tr_trans): handle single bytes more eagerly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * regparse.c (PINC): use optimized enclen() instead ofmatz2008-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ONIGENC_MBC_ENC_LEN(). * regparse.c (PFETCH): ditto. * regparse.c (PFETCH): small optimization. * regexec.c (slow_search): single byte encoding optimization. * regenc.h (enclen): avoid calling function when encoding's min_len == max_len. * re.c (rb_reg_regsub): rb_enc_ascget() optimization for single byte encoding. * re.c (rb_reg_search): avoid allocating new re_registers if we already have MatchData. * re.c (match_init_copy): avoid unnecessary onig_region_free() before onig_region_copy. * encoding.c (rb_enc_get_index): remove implicit enc_capable check each time. * encoding.c (rb_enc_set_index): ditto. * encoding.c (enc_compatible_p): small refactoring. * include/ruby/encoding.h (rb_enc_dummy_p): inline rb_enc_dummy_p() and export related code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (tr_find): String#delete returned wrong result when multiplemame2008-05-151-5/+5
| | | | | | | | | utf-8 arguments are passed. * test/ruby/test_m17n.rb (test_delete): add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_cat): fixed buffer overrun reported bymatz2008-05-131-1/+1
| | | | | | Christopher Thompson <cthompson at nexopia.com> in [ruby-core:16746] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e