aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
Commit message (Collapse)AuthorAgeFilesLines
...
* re.c: rb_reg_region_copynobu2014-12-011-6/+17
| | | | | | | * re.c (rb_reg_region_copy): new function to try with GC if copy failed and return the error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c: check if onig_region_copy failednobu2014-12-011-0/+4
| | | | | | | * re.c (CHECK_REGION_COPIED): onig_region_copy() can fail when memory exhausted but returns nothing, so check by if allocated. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-3/+1
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (unescape_nonascii): cast -1 for the case char is unsigned char.naruse2014-11-061-1/+1
| | | | | | | | | If char is signed char, for example gcc for ARM or ppc64, it caused infinite loop. http://kmuto.jp/build-ruby/arm/ruby-trunk/log/20141106T013005Z.fail.html.gz http://rubyci.blob.core.windows.net/f19p8/ruby-trunk/log/20141106T090217Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c: mak eregexps with binary escapes ASCII-8BITnobu2014-10-171-2/+9
| | | | | | | | | * re.c (unescape_nonascii): make dynamically compiled US-ASCII regexps ASCII-8BIT encoding if binary (hexadecimal, control, meta) escapes are contained, as well as literal regexps. [ruby-dev:48626] [Bug #10382] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* get rid of function calls in RSTRING_PTRnobu2014-07-301-2/+2
| | | | | | | | | | | | * process.c (rlimit_resource_type, rlimit_resource_value): get rid of function calls in RSTRING_PTR(), as it evaluates the argument twice. * re.c (match_backref_number): ditto. * signal.c (esignal_init, rb_f_kill, trap_signm): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (rlimit_resource_type, rlimit_resource_value):ktsj2014-07-301-1/+1
| | | | | | | | | | | | | | get rid of inadvertent dynamic symbol pin-down. * re.c (match_backref_number): ditto. * signal.c (esignal_init, rb_f_kill, trap_signm): ditto. * transcode.c (econv_opts): ditto. * vm_trace.c (symbol2event_flag): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce ZALLOC{,_N} to replace ALLOC{,_N}+MEMZERO usenormal2014-07-251-2/+1
| | | | | | | | | | | | | | | | | | | | Using calloc where possible reduces code and binary sizes. * include/ruby/ruby.h (ZALLOC, ZALLOC_N): implement (Data_Make_Struct, TypedData_Make_Struct): ZALLOC replaces ALLOC+memset * compile.c (iseq_seq_sequence): ZALLOC_N replaces ALLOC_N+MEMZERO * cont.c (fiber_t_alloc): ZALLOC replaces ALLOC+MEMZERO * io.c (rb_io_reopen): ditto * iseq.c (prepare_iseq_build): ditto * parse.y (new_args_tail_gen, parser_new, ripper_s_allocate): ditto * re.c (match_alloc): ditto * variable.c (rb_const_set): ditto * ext/socket/raddrinfo.c (get_addrinfo): ditto * ext/strscan/strscan.c (strscan_s_allocate): ditto * gc.c (rb_objspace_alloc): calloc replaces malloc+MEMZERO git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c: consider name encodingnobu2014-06-041-6/+7
| | | | | | | | * re.c (match_aref, rb_reg_regsub): consider encoding of captured names, encoding-incompatible should not match. [ruby-dev:48278] [Bug #9903] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c: reduce new stringsnobu2014-06-041-12/+15
| | | | | | | * re.c (match_aref, rb_reg_regsub): reduce new strings creation for exceptions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c: fix name with NULnobu2014-06-041-7/+3
| | | | | | | * re.c (match_aref): should not ignore name after NUL byte. [ruby-dev:48275] [Bug #9902] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* encoding.h: constify rb_encodingnobu2014-06-021-31/+31
| | | | | | | * include/ruby/encoding.h: constify `rb_encoding` itself, not only arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* constify rb_encoding and OnigEncodingnobu2014-06-011-31/+31
| | | | | | | * include/ruby/encoding.h: constify `rb_encoding` arguments. * include/ruby/oniguruma.h: constify `OnigEncoding` arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: infect match resultnobu2014-03-281-0/+1
| | | | | | | * string.c (rb_pat_search): match result should be infected by the pattern. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: backref substitutionnobu2014-03-281-1/+1
| | | | | | | | | * re.c (rb_reg_regsub): allow nil regexp for string matching. * string.c (rb_str_sub_bang, str_gsub): make substitution if replacement string has backref escapes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: search by rb_str_indexnobu2014-03-271-1/+37
| | | | | | | | | | | | * re.c (match_regexp): set regexp for MatchData from string. * re.c (rb_backref_set_string): create MatchData from string and set backref. * string.c (rb_pat_search, rb_str_sub, rb_str_sub_bang, str_gsub), (scan_once, rb_str_scan, rb_str_partition): use rb_str_index instead of rb_reg_search() when pattern is a String. based on the patch by Sam Rawlins <sam.rawlins@gmail.com> [Fixes GH-579] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c: class name encodingnobu2014-03-271-3/+3
| | | | | | * re.c (match_inspect): preserve class name encoding by PRIsVALUE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c: indentnobu2014-03-271-1/+1
| | | | | | * re.c (rb_reg_search): adjust indent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Stop allocating backref strings within gsub's search loopcharliesome2014-03-251-3/+12
| | | | | | | | | | | | | | * internal.h: add prototype for rb_reg_search0 * re.c: rename rb_reg_search to rb_reg_search0, add set_backref_str argument to allow callers to indicate that they don't require the backref string to be allocated * string.c: don't allocate backref str if replacement string is provided Closes GH-578. [Bug #9676] [ruby-core:61682] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] add links to `Object#hash`nobu2014-03-141-0/+4
| | | | | | | add links to `Object#hash` to each #`hash` methods rdocs. [Fixes GH-567] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c (rb_reg_raise): remove volatilenormal2014-02-131-1/+1
| | | | | | | * re.c (rb_reg_raise): remove volatile Unnecessary since r41597 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c (rb_reg_regcomp): remove volatilenormal2014-02-131-2/+1
| | | | | | | * re.c (rb_reg_regcomp): remove volatile Unnecessary since r13261 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN intoko12013-12-201-2/+2
| | | | | | | | | | | | RB_OBJ_WRITE and RB_OBJ_WRITTEN. * array.c, class.c, compile.c, hash.c, internal.h, iseq.c, proc.c, process.c, re.c, string.c, variable.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c: Use rb_fstring() to de-duplicate string literals in code. ↵tmm12013-11-261-2/+1
| | | | | | | | | | | [ruby-core:58599] [Bug #9159] [ruby-core:54405] * iseq.c (prepare_iseq_build): De-duplicate iseq labels and source locations. * re.c (rb_reg_initialize): Use rb_fstring() for regex string. * string.c (rb_fstring): Handle non-string and already-fstr arguments. * vm_eval.c (eval_string_with_cref): De-duplicate eval source filename. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c: [DOC] arguments of Regexp::union receive #to_regexp [Bug #8205]zzak2013-09-261-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c: suppress warningnobu2013-08-091-2/+2
| | | | | | * re.c (rb_memsearch): suppress parentheses warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_to_s): convert closing parenthes to the target encodingnaruse2013-07-251-2/+24
| | | | | | if it is ASCII incompatible encoding. [ruby-core:56063] [Bug #8650] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c: use built-in encoding indexesnobu2013-07-021-2/+2
| | | | | | | | * internal.h: add EUC-JP and Windows-31J. * re.c (rb_char_to_option_kcode): use built-in encoding indexes in internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (make_name_for_block): use PRIsVALUE in format stringcharliesome2013-06-241-1/+1
| | | | | | | | | | | | | | | | instead of %s and RSTRING_PTR to protect objects from being garbage collected too soon * encoding.c (str_to_encindex): ditto * hash.c (rb_hash_fetch_m): ditto * io.c (rb_io_reopen): ditto * parse.y (reg_fragment_check_gen): ditto * parse.y (reg_compile_gen): ditto * parse.y (ripper_assert_Qundef): ditto * re.c (rb_reg_raise): ditto * ruby.c (set_option_encoding_once): ditto * vm_eval.c (rb_throw_obj): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for secondko12013-06-211-2/+2
| | | | | | | | | | parameter `slot'. You don't need to write a cast (VALUE *) any more. * class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c, vm.c, vm_method.c: remove cast expressions for OBJ_WRITE(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h, re.c: support write barrier for T_REGEXP.ko12013-06-211-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentErrorshugo2013-06-121-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when $SAFE is set to 4. $SAFE=4 is now obsolete. [ruby-core:55222] [Feature #8468] * object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust): Kernel#untrusted?, untrust, and trust are now deprecated. Their behavior is same as tainted?, taint, and untaint, respectively. * include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED() and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(), respectively. * array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c, ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c, ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c, ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c, ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c, ext/socket/socket.c, ext/socket/udpsocket.c, ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c, ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c, load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c, safe.c, string.c, thread.c, transcode.c, variable.c, vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for $SAFE=4. * test/dl/test_dl2.rb, test/erb/test_erb.rb, test/readline/test_readline.rb, test/readline/test_readline_history.rb, test/ruby/test_alias.rb, test/ruby/test_array.rb, test/ruby/test_dir.rb, test/ruby/test_encoding.rb, test/ruby/test_env.rb, test/ruby/test_eval.rb, test/ruby/test_exception.rb, test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb, test/ruby/test_io.rb, test/ruby/test_method.rb, test/ruby/test_module.rb, test/ruby/test_object.rb, test/ruby/test_pack.rb, test/ruby/test_rand.rb, test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb, test/ruby/test_struct.rb, test/ruby/test_thread.rb, test/ruby/test_time.rb: remove tests for $SAFE=4. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * doc/re.rdoc: Rename to doc/regexp.rdoczzak2013-06-111-1/+1
| | | | | | | * re.c: Update rdoc include for rename of file git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macroko12013-05-131-1/+1
| | | | | | | | instead of using RARRAY_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: Document synonymous methods, by windwiny [GH-277]zzak2013-04-121-0/+1
| | | | | | | | | | | | | | | * bignum.c: ditto * complex.c: ditto * dir.c: ditto * encoding.c: ditto * enumerator.c: ditto * numeric.c: ditto * proc.c: ditto * re.c: ditto * string.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_to_s): suppress duplicated charclass warning.naruse2013-04-021-0/+3
| | | | | | | | | | | Regexp#to_s suppress extra its whole regexp options by calling onig_new with its source, but it doesn't call rb_reg_preprocess. Therefore its Unicode escapes (\u{XXXX}) are given as is, and it may cause duplicated charclass warning for example "[\u{33}]" (3 is duplicated) or "[\u{a}\u{b}]" (u is duplicated). [ruby-core:53649] [Bug #8151] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_rpartition): revert r39903, and convert byte offsetnaruse2013-03-241-0/+1
| | | | | | | | to char offset; the return value of rb_reg_search is byte offset, but other than it of rb_str_rpartition expects char offset. [Bug #8138] [ruby-dev:47183] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (reg_operand): Simplify and reuse error handling [Bug #7539]marcandre2013-01-291-6/+1
| | | | | | * test/ruby/test_regexp.rb: Test for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [rdoc] expalin kcode argument of Regexp.newnaruse2013-01-131-3/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* adjust stylenobu2012-12-291-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_eqq): doc: #=== is not a synonym for #=~, added examplezzak2012-12-231-3/+6
| | | | | | | [ruby-dev:46746] [Bug #7571] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Apply performance improvement to short byte array search.knu2012-11-221-0/+3
| | | | | | | | * re.c (rb_memsearch_ss): Apply performance improvement to short byte array search for platforms without memmem(3). [Feature #6311] [ruby-dev:45530] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_memsearch_ss): performance improvement by using memmem(3) ifglass2012-11-131-0/+13
| | | | | | | | possible. [ruby-dev:45530] [Feature #6311] * configure.in: check existence of memmem(3) and that it is not broken. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_memsearch): performance improvement by using memchr().glass2012-11-081-6/+6
| | | | | | [ruby-dev:45397] [Feature #6173] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: add C APIs.nari2012-10-201-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | VALUE rb_newobj_of(VALUE klass, VALUE flags) #define NEWOBJ_OF(obj,type,klass,flags) These allow to change a allocation strategy depending on klass or flags. * gc.c: ditto * array.c: use new C API. * bignum.c: ditto * class.c: ditto * complex.c: ditto * ext/socket/ancdata.c: ditto * ext/socket/option.c: ditto * hash.c: ditto * io.c: ditto * marshal.c: ditto * numeric.c: ditto * object.c: ditto * random.c: ditto * range.c: ditto * rational.c: ditto * re.c: ditto * string.c: ditto * struct.c: ditto [Feature #7177][Feature #7047] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_initialize_m): Forgot to update output for or'd-optionsdrbrain2012-08-201-4/+4
| | | | | | | example. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_initialize_m): Update example to show that regexpdrbrain2012-08-201-11/+12
| | | | | | | options use | an not || to avoid confusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_s_last_match): Update $~ to reference Regexpdrbrain2012-07-241-7/+9
| | | | | | | documentation about "special global variables". [Bug #6723] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* obj_init_copynobu2012-06-051-10/+2
| | | | | | * object.c (rb_obj_init_copy): should check if trusted too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use RB_TYPE_P() instead of comparison of TYPE()nobu2012-05-231-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e