summaryrefslogtreecommitdiff
path: root/string.c
Commit message (Collapse)AuthorAgeFilesLines
* Make String#crypt ractor-safeNobuyoshi Nakada2021-04-131-1/+39
|
* Get rid of LONG_LONG redefinitionNobuyoshi Nakada2021-04-121-9/+9
|
* rb_enc_interned_str: handle autoloaded encodingsJean Boussier2021-03-221-0/+4
| | | | | | | | If called with an autoloaded encoding that was not yet initialized, `rb_enc_interned_str` would crash with a NULL pointer exception. See: https://github.com/ruby/ruby/pull/4119#issuecomment-800189841
* Make String#{strip,lstrip}{,!} strip leading NUL bytesJeremy Evans2021-02-201-2/+2
| | | | | | | | | | | The documentation already specifies that they strip whitespace and defines whitespace to include null. This wraps the new behavior in the appropriate guards in the specs, but does not specify behavior for previous versions, because this is a bug that could be backported. Fixes [Bug #17467]
* correct the result of casecmp? examples [ci skip]Sarun Rattanasiri2021-02-121-1/+1
|
* Merged too-short salt conditions instead of UNREACHABLE_RETURNNobuyoshi Nakada2021-02-111-9/+4
|
* Fix 404 linkS-H-GAMELINKS2021-02-111-1/+1
|
* Remove unsued str_new_shared function declarationS-H-GAMELINKS2021-02-041-1/+0
|
* Constified pointers in str_casecmpNobuyoshi Nakada2021-01-301-1/+1
|
* Fix broken link in RDoc for String (#4123)Burdette Lamar2021-01-261-1/+1
| | | Link was correct; its target was incorrect; now fixed.
* What's Here for String RDoc (#4093)Burdette Lamar2021-01-221-0/+248
| | | * What's Here for String RDoc
* Minor grammar fix in String#chomp documentationEric Schneider2020-12-301-1/+1
|
* Use `size_t` for `RSTRING_LEN` in String#countNobuyoshi Nakada2020-12-261-6/+5
| | | | https://hackerone.com/reports/1042722
* Add Symbol#name and freezing explanation to #to_szverok2020-12-211-0/+23
|
* Replaced magic numbers tr tableNobuyoshi Nakada2020-12-211-14/+15
|
* Use category: :deprecated in warnings that are related to deprecationJeremy Evans2020-12-181-2/+2
| | | | | | | | | | | | | | | | | Also document that both :deprecated and :experimental are supported :category option values. The locations where warnings were marked as deprecation warnings was previously reviewed by shyouhei. Comment a couple locations where deprecation warnings should probably be used but are not currently used because deprecation warning enablement has not occurred at the time they are called (RUBY_FREE_MIN, RUBY_HEAP_MIN_SLOTS, -K). Add assert_deprecated_warn to test assertions. Use this to simplify some tests, and fix failing tests after marking some warnings with deprecated category.
* tuning trial: newobj with current ecKoichi Sasada2020-12-071-2/+29
| | | | | Passing current ec can improve performance of newobj. This patch tries it for Array and String literals ([] and '').
* should not use rb_str_modify(), tooKoichi Sasada2020-12-011-1/+11
| | | | | | Same as 8247b8edde, should not use rb_str_modify() here. https://bugs.ruby-lang.org/issues/17343#change-88858
* Fix rb_interned_str_* functions to not assume static stringsJean Boussier2020-11-301-28/+43
| | | | | | | | Fixes [Feature #13381] When passed a `fake_str`, `register_fstring` would create new strings with `str_new_static`. That's not what was expected, and answer almost no use cases.
* Get rid of allocation when the capacity is smallNobuyoshi Nakada2020-11-291-0/+1
|
* Remove obsoleted str_new_emptyTakashi Kokubun2020-11-201-8/+0
| | | | | | | | since 58325daae3beefda13ed100782cd19a89cc68771. ../string.c:1339:1: warning: ‘str_new_empty’ defined but not used [-Wunused-function] 1339 | str_new_empty(VALUE str) | ^~~~~~~~~~~~~
* Make String methods return String instances when called on a subclass instanceJeremy Evans2020-11-201-54/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This modifies the following String methods to return String instances instead of subclass instances: * String#* * String#capitalize * String#center * String#chomp * String#chop * String#delete * String#delete_prefix * String#delete_suffix * String#downcase * String#dump * String#each/#each_line * String#gsub * String#ljust * String#lstrip * String#partition * String#reverse * String#rjust * String#rpartition * String#rstrip * String#scrub * String#slice! * String#slice/#[] * String#split * String#squeeze * String#strip * String#sub * String#succ/#next * String#swapcase * String#tr * String#tr_s * String#upcase This also fixes a bug in String#swapcase where it would return the receiver instead of a copy of the receiver if the receiver was the empty string. Some string methods were left to return subclass instances: * String#+@ * String#-@ Both of these methods will return the receiver (subclass instance) in some cases, so it is best to keep the returned class consistent. Fixes [#10845]
* Expose the rb_interned_str_* family of functionsJean Boussier2020-11-171-0/+30
| | | | Fixes [Feature #13381]
* Move variable closer to usageAlan Wu2020-10-301-1/+1
|
* Don't redefine #rb_intern over and over againStefan Stüben2020-10-211-9/+6
|
* Enhanced RDoc for String#insert (#3643)Burdette Lamar2020-10-081-13/+13
| | | | * Enhanced RDoc for String#insert
* Enhanced RDoc for String#[] (#3607)Burdette Lamar2020-09-301-65/+65
| | | | * Enhanced RDoc for String#[]
* Enhanced RDoc for String#upto (#3603)Burdette Lamar2020-09-291-29/+23
| | | | * Enhanced RDoc for String#upto
* Enhanced RDoc for String#succ! (#3596)Burdette Lamar2020-09-281-3/+4
| | | * Enhanced RDoc for String#succ!
* Enhanced RDoc for String#succ (#3590)Burdette Lamar2020-09-251-21/+49
| | | | * Enhanced RDoc for String#succ
* Enhanced RDoc for String#match? (#3576)Burdette Lamar2020-09-241-13/+25
| | | * Enhanced RDoc for String#match?
* Enhanced RDoc for String (#3574)Burdette Lamar2020-09-241-42/+41
| | | | | | | Methods: =~ match
* Enhanced RDoc for String (#3569)Burdette Lamar2020-09-241-81/+119
| | | | | | | | | | | | | | Makes some methods doc compliant with https://github.com/ruby/ruby/blob/master/doc/method_documentation.rdoc. Also, other minor revisions to make more consistent. Methods: == === eql? <=> casecmp casecmp? index rindex
* Fix call-seq [ci skip]Kazuhiro NISHIYAMA2020-09-231-1/+1
| | | | | | | | | `encoding` can be not only an encoding name, but also an Encoding object. ``` s = String.new('foo', encoding: Encoding::US_ASCII) s.encoding # => #<Encoding:US-ASCII> ```
* Enhanced RDoc for String (#3565)Burdette Lamar2020-09-221-44/+42
| | | | | | | | | | | | | Makes some methods doc compliant with https://github.com/ruby/ruby/blob/master/doc/method_documentation.rdoc. Also, other minor revisions to make more consistent. Methods: try_convert +string -string concat << prepend hash
* Comply with guide for method doc: string.c (#3528)Burdette Lamar2020-09-211-70/+42
| | | | | | | | | | | | Methods: ::new #length #bytesize #empty? #+ #* #%
* sync fstring_table for deletionKoichi Sasada2020-09-181-2/+7
| | | | | Ractors can access this table simultaneously so we need to sync accesses.
* sync fstring poolKoichi Sasada2020-09-151-6/+12
| | | | fstring pool should be sync with other Ractors.
* Let String#slice! return nil (#3533)Soutaro Matsumoto2020-09-111-1/+4
| | | Returns `nil` instead of an empty string when non-integer number is given (to make it 2.7 compatible).
* Added Symbol#nameNobuyoshi Nakada2020-09-041-0/+1
| | | https://bugs.ruby-lang.org/issues/16150#change-87446
* Partial compliance with doc/method_documentation.rdoc in string.c (#3436)Burdette Lamar2020-08-201-23/+4
| | | Removes references to *-convertible thingies.
* register_fstring: avoid duping the passed string when possibleJean Boussier2020-08-191-1/+2
| | | | | | | | If the passed string is frozen, bare and not shared, then there is no need to duplicate it. Ref: 4ab69ebbd7cef8539f687e1f948845d076461dc6 Ref: https://bugs.ruby-lang.org/issues/11386
* [DOC] fixed a missing markupNobuyoshi Nakada2020-08-151-1/+1
|
* rb_str_{index,rindex}_m: Handle /\K/ in patternKasumi Hanazuki2020-08-131-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | When the pattern Regexp given to String#index and String#rindex contain a /\K/ (lookbehind) operator, these methods return the position where the beginning of the lookbehind pattern matches, while they are expected to return the position where the \K matches. ``` # without patch "abcdbce".index(/b\Kc/) # => 1 "abcdbce".rindex(/b\Kc/) # => 4 ``` This patch fixes this problem by using BEG(0) instead of the return value of rb_reg_search. ``` # with patch "abcdbce".index(/b\Kc/) # => 2 "abcdbce".rindex(/b\Kc/) # => 5 ``` Fixes [Bug #17118]
* rb_str_{partition,rpartition}_m: Handle /\K/ in patternKasumi Hanazuki2020-08-131-23/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | When the pattern given to String#partition and String#rpartition contain a /\K/ (lookbehind) operator, the methods return strings sliced at incorrect positions. ``` # without patch "abcdbce".partition(/b\Kc/) # => ["a", "c", "cdbce"] "abcdbce".rpartition(/b\Kc/) # => ["abcd", "c", "ce"] ``` This patch fixes the problem by using BEG(0) instead of the return value of rb_reg_search. ``` # with patch "abcdbce".partition(/b\Kc/) # => ["ab", "c", "dbce"] "abcdbce".rpartition(/b\Kc/) # => ["abcdb", "c", "e"] ``` As a side-effect this patch makes String#partition 2x faster when the pattern is a costly Regexp by performing Regexp search only once, which was unexpectedly done twice in the original implementation. Fixes [Bug #17119]
* string.c(rb_str_split_m): Handle /\K/ correctlyKasumi Hanazuki2020-08-121-1/+2
| | | | | | | Use BEG(0) instead of the result of rb_reg_search to handle the cases when the separator Regexp contains /\K/ (lookbehind) operator. Fixes [Bug #17113]
* Removed non-ASCII code to suppress warnings by localized compilersNobuyoshi Nakada2020-08-101-4/+4
|
* Adjust indentNobuyoshi Nakada2020-08-101-1/+1
|
* Use https instead of httpKazuhiro NISHIYAMA2020-07-281-1/+1
|
* add UNREACHABLE_RETURN卜部昌平2020-06-291-0/+2
| | | | | | Not every compilers understand that rb_raise does not return. When a function does not end with a return statement, such compilers can issue warnings. We would better tell them about reachabilities.