2090 Commits
Author SHA1 Message Date
Erik Berlin 4ba4954dd7 Fix Range#include? of an empty range of single characters
A range of single character Strings told that it includes its end
even when it is empty, since the end was not compared with the begin.

    ("z".."a").to_a          #=> []
    ("z".."a").include?("a") #=> true

(cherry picked from commit 1bf9130943)
2026-10-21 11:56:12 -07:00
Randy Stauner 67cd1d3bde [Bug #22387] Fix termlen in str_shared_replace (#19104)
[Bug #22387] Fix termlen in str_shared_replace

The buffer is copied over based on the new string's termlen
so we can just set the new encoding raw
instead of recalculating based on the old encoding's termlen.
2026-09-28 15:53:16 -07:00
Randy Stauner 4ac2a34ced [Bug #22383] Fix inverted STR_SHARED check in rb_str_tmp_frozen_release
45a2c95d0f mistakenly rewrote

    FL_TEST_RAW(orig, STR_SHARED) && !FL_TEST_RAW(orig, STR_TMPLOCK|RUBY_FL_FREEZE)

as

    FL_TEST_RAW(orig, STR_SHARED | STR_TMPLOCK) == STR_TMPLOCK

requiring orig to not be shared, the opposite of the original
condition.  orig always shares the buffer with tmp here, so the buffer
was never given back and the string stayed shared until its next
modification copied it.  The code then read aux.shared from strings
that are not shared, where the union holds aux.capa.

This should be backported to 4.0
2026-09-25 08:48:32 -07:00
ZHIJIE XIE a9b84adbd2 string.c: guard tmp in rb_str_format_m (GH-16280)
[Bug #21931]

Keep tmp alive while RARRAY_CONST_PTR(tmp) is used by rb_str_format.

[alan: sunk the guard below usage]
Reviewed-by: Alan Wu <XrXr@users.noreply.github.com>
2026-03-03 07:57:17 -08:00
Takashi Kokubun 306930ae1a merge revision(s) 78b7646bdb, b4a62a1ca9: [Backport #21842]
[PATCH] [Bug #21842] Let `rb_interned_str` return US-ASCII if possible

	[PATCH] [DOC] Update docs for rb_interned_str and related functions (#15897)

	Related to [Bug #21842].

	* rb_interned_str: document what decides whether the returned string is
	  in US-ASCII or BINARY encoding.
	* rb_interned_str_cstr: include the same description as rb_interned_str
	  for the encoding. This one was still missing the update for US-ASCII
	  and erroneously said the returned string was alwasy in BINARY encoding
	* rb_str_to_interned_str: document how the encoding of the result is
	  defined.

	Co-authored-by: Herwin <herwinw@users.noreply.github.com>
2026-02-09 13:44:42 -08:00
BurdetteLamar e2243ed232 [DOC] Correct typo 2025-12-20 21:24:37 -05:00
BurdetteLamar addbeb6cf3 [DOC] Note for String#<=> about Comparable 2025-12-20 18:13:08 -05:00
BurdetteLamar b7d4d7c911 [DOC] Harmonize several <=> methods 2025-12-19 21:36:46 -05:00
BurdetteLamar 42c4df9ac6 [DOC] Harmonize String#<=> 2025-12-19 17:09:31 -05:00
Alan Wu d209e6f1c0 search_nonascii(): Replace UB pointer cast with memcpy
Casting a pointer to create an unaligned one is undefined behavior in C
standards. Use memcpy to express the unaligned load instead to play by
the rules.

Practically, this yields the same binary output in many situations
while fixing the crash in [Bug #21715].
2025-12-16 13:06:03 -05:00
Shugo Maeda 71dd272506 Remove useless rb_check_arity() calls 2025-12-13 13:52:13 +09:00
Nobuyoshi Nakada 281a000d66 [Bug #19558] Allow ASCII range to mix with Unicode dump 2025-12-11 19:20:12 +09:00
Shugo MaedaandClaude c76ba839b1 Allow String#strip etc. to take optional character selectors
[Feature #21552]

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-11 17:34:57 +09:00
Hiroshi SHIBATA 79c57d747f Fixed by misspell -w -error -source=text 2025-12-09 17:48:57 +09:00
BurdetteLamar bd64cf00a2 [DOC] Tweaks for String#capitalize 2025-12-05 19:05:55 -08:00
BurdetteLamar 2491a504ff [DOC] Tweaks for String#downcase 2025-12-05 19:05:18 -08:00
BurdetteLamar e5e4175dbd [DOC] Tweaks for String#upcase 2025-12-05 19:04:59 -08:00
BurdetteLamar da2c67388a [DOC] Tweaks for String#swapcase 2025-12-05 19:04:23 -08:00
Nobuyoshi Nakada 29a12297c3 Refine non-nil warnings for the deprecated variables 2025-12-05 01:04:08 +09:00
Nobuyoshi Nakada cf12aff059 [Bug #21764] Propagate the encoding of ID to warning 2025-12-05 00:27:45 +09:00
Jean Boussier b78db63be4 fstring_concurrent_set_create: only assert the string has no ivars
The NEWOBJ tracepoint can generate an object_id, that's alright,
what we don't want is actual instance variables.
2025-12-03 15:57:26 +01:00
Jean Boussier 5770c186d1 Rename rb_obj_exivar_p -> rb_obj_gen_fields_p
The "EXIVAR" terminology has been replaced by "gen fields"
AKA "generic fields".

Exivar implies variable, but generic fields include more than
just variables, e.g. `object_id`.
2025-12-03 15:57:26 +01:00
Max Bernstein 8aed311038 ZJIT: Specialize String#<< with Fixnum
Append a codepoint.
2025-12-01 15:19:26 -08:00
Stan Lo 4cd6661e18 Reorganize page documentations (#15154)
Re-organize page docs
2025-11-27 20:12:24 +00:00
Burdette Lamar d5368fc515 [DOC] Tweaks for String#valid_encoding? 2025-11-20 17:07:44 -05:00
BurdetteLamar d1b11592af [DOC] Tweaks for String#upto 2025-11-20 14:06:16 -08:00
BurdetteLamar a4a99a24e8 [DOC] TWeaks for String#upcase! 2025-11-20 14:04:22 -08:00
Burdette Lamar 59e0489248 [DOC] Tweaks for String#upcase (#15244) 2025-11-20 17:03:58 -05:00
BurdetteLamar 1443f89d69 [DOC] Tweaks for String#unicode_normalize 2025-11-18 18:57:29 -08:00
Burdette Lamar 319001192d [DOC] Tweaks for String#dump and String#undump 2025-11-18 21:56:14 -05:00
Luke Gruber 371a295e19 Fix improper termlen fill in str_duplicate_setup_embed.
When term len != 1 (for example: Encoding::UTF32BE), term fill is wrong size.
2025-11-18 00:53:47 +09:00
BurdetteLamar 3cd30814d4 [DOC] Tweaks for String#unicode_normalize! 2025-11-16 13:27:06 -08:00
BurdetteLamar 17f3588a43 [DOC] Tweaks for String#unicode_normalized? 2025-11-16 13:26:46 -08:00
BurdetteLamar e826f815bf [DOC] Tweaks for String#tr_s! 2025-11-13 18:28:09 -08:00
BurdetteLamar 6c7453c5de [DOC] Tweaks for String#tr_s 2025-11-13 18:27:43 -08:00
BurdetteLamar 7ea0d36966 [DOC] Tweaks for String#tr! 2025-11-13 18:27:01 -08:00
BurdetteLamar a4916a6f38 [DOC] Tweaks for String#tr 2025-11-12 14:02:07 -08:00
BurdetteLamar c13b4d79e1 [DOC] Tweaks for String#to_s 2025-11-12 14:01:43 -08:00
Burdette Lamar 79eed1158d [DOC] Tweaks for String#to_i (#15036) 2025-11-08 17:27:26 -05:00
John Hawthorn 3b588dab91 Don't modify fstrings in rb_str_tmp_frozen_no_embed_acquire
[Bug #21671]
2025-11-07 17:06:56 -08:00
BurdetteLamar 4a3d8346a6 [DOC] Tweaks for String#to_f 2025-11-02 13:44:11 -05:00
Peter Zhu 37c7153668 Make rb_str_embed_size aware of termlen 2025-11-02 09:17:17 -05:00
Peter Zhu dba4c9fbe7 Fix string allocation when slot size < 40 bytes
We need to allocate at least sizeof(struct RString) when the string is
embedded on garbage collectors that support slot sizes less than 40 bytes.
2025-11-02 09:17:17 -05:00
BurdetteLamar 836fc00e19 [DOC] Tweaks for String#swapcase 2025-10-27 21:19:42 -04:00
BurdetteLamar e3c4298d40 [DOC] Tweaks for String#swapcase! 2025-10-27 21:18:53 -04:00
BurdetteLamar 9e49ee7937 [DOC] Tweaks for String#succ! 2025-10-26 15:04:28 -04:00
Burdette Lamar 5c683bd9b3 [DOC] Tweaks for String#succ 2025-10-26 15:04:16 -04:00
BurdetteLamar fcae206232 [DOC] Tweaks for String#sub! 2025-10-24 18:09:54 -04:00
BurdetteLamar 245df86ec3 [DOC] Tweaks for String#sub 2025-10-24 18:09:32 -04:00
BurdetteLamar 230276dd42 [DOC] Tweaks for String#strip 2025-10-23 18:14:09 -04:00