Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ rb_dbl_complex_new(double real, double imag)
* Complex.rect(1, Rational(0, 1)).to_i # => 1
*
* Raises RangeError if <tt>self.imag</tt> is not exactly zero
* (either <tt>Integer(0)</tt> or <tt>Rational(0, _n_)</tt>).
* (either <tt>Integer(0)</tt> or <tt>Rational(0, n)</tt>).
*/
static VALUE
nucomp_to_i(VALUE self)
Expand All @@ -1827,7 +1827,7 @@ nucomp_to_i(VALUE self)
* Complex.rect(1, Rational(0, 1)).to_f # => 1.0
*
* Raises RangeError if <tt>self.imag</tt> is not exactly zero
* (either <tt>Integer(0)</tt> or <tt>Rational(0, _n_)</tt>).
* (either <tt>Integer(0)</tt> or <tt>Rational(0, n)</tt>).
*/
static VALUE
nucomp_to_f(VALUE self)
Expand All @@ -1852,7 +1852,7 @@ nucomp_to_f(VALUE self)
* Complex.rect(1, 0.0).to_r # => (1/1)
*
* Raises RangeError if <tt>self.imag</tt> is not exactly zero
* (either <tt>Integer(0)</tt> or <tt>Rational(0, _n_)</tt>)
* (either <tt>Integer(0)</tt> or <tt>Rational(0, n)</tt>)
* and <tt>self.imag.to_r</tt> is not exactly zero.
*
* Related: Complex#rationalize.
Expand Down
8 changes: 4 additions & 4 deletions dir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,14 @@ def self.[](*args, base: nil, sort: true)
#
# Dir.glob('io.?') # => ["io.c"]
#
# - <tt>'[_set_]'</tt>: Matches any one character in the string _set_;
# - <tt>'[set]'</tt>: Matches any one character in the string _set_;
# behaves like a {Regexp character class}[rdoc-ref:Regexp@Character+Classes],
# including set negation (<tt>'[^a-z]'</tt>):
#
# Dir.glob('*.[a-z][a-z]').take(3)
# # => ["CONTRIBUTING.md", "COPYING.ja", "KNOWNBUGS.rb"]
#
# - <tt>'{_abc_,_xyz_}'</tt>:
# - <tt>'{abc,xyz}'</tt>:
# Matches either string _abc_ or string _xyz_;
# behaves like {Regexp alternation}[rdoc-ref:Regexp@Alternation]:
#
Expand Down Expand Up @@ -388,10 +388,10 @@ def self.[](*args, base: nil, sort: true)
#
# - File::FNM_EXTGLOB:
# enables the pattern extension
# <tt>'{_a_,_b_}'</tt>, which matches pattern _a_ and pattern _b_;
# <tt>'{a,b}'</tt>, which matches pattern _a_ and pattern _b_;
# behaves like a
# {regexp union}[rdoc-ref:Regexp.union]
# (e.g., <tt>'(?:_a_|_b_)'</tt>):
# (e.g., <tt>'(?:a|b)'</tt>):
#
# pattern = '{LEGAL,BSDL}'
# Dir.glob(pattern) # => ["LEGAL", "BSDL"]
Expand Down
52 changes: 26 additions & 26 deletions doc/_regexp.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -414,21 +414,21 @@ Each of these anchors matches a boundary:

Lookahead anchors:

- <tt>(?=_pat_)</tt>: Positive lookahead assertion:
- <tt>(?=pat)</tt>: Positive lookahead assertion:
ensures that the following characters match _pat_,
but doesn't include those characters in the matched substring.

- <tt>(?!_pat_)</tt>: Negative lookahead assertion:
- <tt>(?!pat)</tt>: Negative lookahead assertion:
ensures that the following characters <i>do not</i> match _pat_,
but doesn't include those characters in the matched substring.

Lookbehind anchors:

- <tt>(?<=_pat_)</tt>: Positive lookbehind assertion:
- <tt>(?<=pat)</tt>: Positive lookbehind assertion:
ensures that the preceding characters match _pat_, but
doesn't include those characters in the matched substring.

- <tt>(?<!_pat_)</tt>: Negative lookbehind assertion:
- <tt>(?<!pat)</tt>: Negative lookbehind assertion:
ensures that the preceding characters do not match
_pat_, but doesn't include those characters in the matched substring.

Expand Down Expand Up @@ -574,7 +574,7 @@ A simple regexp has (at most) one match:
re.match('1943-02-04').size # => 1
re.match('foo') # => nil

Adding one or more pairs of parentheses, <tt>(_subexpression_)</tt>,
Adding one or more pairs of parentheses, <tt>(subexpression)</tt>,
defines _groups_, which may result in multiple matched substrings,
called _captures_:

Expand Down Expand Up @@ -647,8 +647,8 @@ A regexp may contain any number of groups:

- For a large number of groups:

- The ordinary <tt>\\_n_</tt> notation applies only for _n_ in range (1..9).
- The <tt>MatchData[_n_]</tt> notation applies for any non-negative _n_.
- The ordinary <tt>\\n</tt> notation applies only for _n_ in range (1..9).
- The <tt>MatchData[n]</tt> notation applies for any non-negative _n_.

- <tt>\0</tt> is a special backreference, referring to the entire matched string;
it may not be used within the regexp itself,
Expand All @@ -661,7 +661,7 @@ A regexp may contain any number of groups:

As seen above, a capture can be referred to by its number.
A capture can also have a name,
prefixed as <tt>?<_name_></tt> or <tt>?'_name_'</tt>,
prefixed as <tt>?<name></tt> or <tt>?'name'</tt>,
and the name (symbolized) may be used as an index in <tt>MatchData[]</tt>:

md = /\$(?<dollars>\d+)\.(?'cents'\d+)/.match("$3.67")
Expand All @@ -676,7 +676,7 @@ When a regexp contains a named capture, there are no unnamed captures:
/\$(?<dollars>\d+)\.(\d+)/.match("$3.67")
# => #<MatchData "$3.67" dollars:"3">

A named group may be backreferenced as <tt>\k<_name_></tt>:
A named group may be backreferenced as <tt>\k<name></tt>:

/(?<vowel>[aeiou]).\k<vowel>.\k<vowel>/.match('ototomy')
# => #<MatchData "ototo" vowel:"o">
Expand Down Expand Up @@ -732,10 +732,10 @@ see {Atomic Group}[https://www.regular-expressions.info/atomic.html].

==== Subexpression Calls

As seen above, a backreference number (<tt>\\_n_</tt>) or name (<tt>\k<_name_></tt>)
As seen above, a backreference number (<tt>\\n</tt>) or name (<tt>\k<name></tt>)
gives access to a captured _substring_;
the corresponding regexp _subexpression_ may also be accessed,
via the number (<tt>\\g<i>n</i></tt>) or name (<tt>\g<_name_></tt>):
via the number n (<tt>\\gn</tt>) or name (<tt>\g<name></tt>):

/\A(?<paren>\(\g<paren>*\))*\z/.match('(())')
# ^1
Expand Down Expand Up @@ -768,12 +768,12 @@ See {Subexpression calls}[https://learnbyexample.github.io/Ruby_Regexp/groupings

==== Conditionals

The conditional construct takes the form <tt>(?(_cond_)_yes_|_no_)</tt>, where:
The conditional construct takes the form <tt>(?(cond)yes|no)</tt>, where:

- _cond_ may be a capture number or name.
- The match to be applied is _yes_ if _cond_ is captured;
otherwise the match to be applied is _no_.
- If not needed, <tt>|_no_</tt> may be omitted.
- If not needed, <tt>|no</tt> may be omitted.

Examples:

Expand Down Expand Up @@ -802,7 +802,7 @@ The absence operator is a special group that matches anything which does _not_ m

==== Unicode Properties

The <tt>/\p{_property_name_}/</tt> construct (with lowercase +p+)
The <tt>/\p{property_name}/</tt> construct (with lowercase +p+)
matches characters using a Unicode property name,
much like a character class;
property +Alpha+ specifies alphabetic characters:
Expand Down Expand Up @@ -1033,23 +1033,23 @@ See also {Extended Mode}[rdoc-ref:Regexp@Extended+Mode].

Each of these modifiers sets a mode for the regexp:

- +i+: <tt>/_pattern_/i</tt> sets
- +i+: <tt>/pattern/i</tt> sets
{Case-Insensitive Mode}[rdoc-ref:Regexp@Case-Insensitive+Mode].
- +m+: <tt>/_pattern_/m</tt> sets
- +m+: <tt>/pattern/m</tt> sets
{Multiline Mode}[rdoc-ref:Regexp@Multiline+Mode].
- +x+: <tt>/_pattern_/x</tt> sets
- +x+: <tt>/pattern/x</tt> sets
{Extended Mode}[rdoc-ref:Regexp@Extended+Mode].
- +o+: <tt>/_pattern_/o</tt> sets
- +o+: <tt>/pattern/o</tt> sets
{Interpolation Mode}[rdoc-ref:Regexp@Interpolation+Mode].

Any, all, or none of these may be applied.

Modifiers +i+, +m+, and +x+ may be applied to subexpressions:

- <tt>(?_modifier_)</tt> turns the mode "on" for ensuing subexpressions
- <tt>(?-_modifier_)</tt> turns the mode "off" for ensuing subexpressions
- <tt>(?_modifier_:_subexp_)</tt> turns the mode "on" for _subexp_ within the group
- <tt>(?-_modifier_:_subexp_)</tt> turns the mode "off" for _subexp_ within the group
- <tt>(?modifier)</tt> turns the mode "on" for ensuing subexpressions
- <tt>(?-modifier)</tt> turns the mode "off" for ensuing subexpressions
- <tt>(?modifier:subexp)</tt> turns the mode "on" for _subexp_ within the group
- <tt>(?-modifier:subexp)</tt> turns the mode "off" for _subexp_ within the group

Example:

Expand Down Expand Up @@ -1166,22 +1166,22 @@ A regular expression containing non-US-ASCII characters
is assumed to use the source encoding.
This can be overridden with one of the following modifiers.

- <tt>/_pat_/n</tt>: US-ASCII if only containing US-ASCII characters,
- <tt>/pat/n</tt>: US-ASCII if only containing US-ASCII characters,
otherwise ASCII-8BIT:

/foo/n.encoding # => #<Encoding:US-ASCII>
/foo\xff/n.encoding # => #<Encoding:ASCII-8BIT>
/foo\x7f/n.encoding # => #<Encoding:US-ASCII>

- <tt>/_pat_/u</tt>: UTF-8
- <tt>/pat/u</tt>: UTF-8

/foo/u.encoding # => #<Encoding:UTF-8>

- <tt>/_pat_/e</tt>: EUC-JP
- <tt>/pat/e</tt>: EUC-JP

/foo/e.encoding # => #<Encoding:EUC-JP>

- <tt>/_pat_/s</tt>: Windows-31J
- <tt>/pat/s</tt>: Windows-31J

/foo/s.encoding # => #<Encoding:Windows-31J>

Expand Down
14 changes: 7 additions & 7 deletions doc/language/encodings.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ These keyword-value pairs specify encoding options:

- <tt>:replace: nil</tt> (default): Set replacement string to default value:
<tt>"\uFFFD"</tt> ("�") for a Unicode encoding, <tt>'?'</tt> otherwise.
- <tt>:replace: _some_string_</tt>: Set replacement string to the given +some_string+;
- <tt>:replace: some_string</tt>: Set replacement string to the given +some_string+;
overrides +:fallback+.

Examples:
Expand All @@ -407,12 +407,12 @@ These keyword-value pairs specify encoding options:
One of these may be specified:

- <tt>:fallback: nil</tt> (default): No replacement fallback.
- <tt>:fallback: _hash_like_object_</tt>: Set replacement fallback to the given
+hash_like_object+; the replacement string is <tt>_hash_like_object_[X]</tt>.
- <tt>:fallback: _method_</tt>: Set replacement fallback to the given
+method+; the replacement string is <tt>_method_(X)</tt>.
- <tt>:fallback: _proc_</tt>: Set replacement fallback to the given
+proc+; the replacement string is <tt>_proc_[X]</tt>.
- <tt>:fallback: hash_like_object</tt>: Set replacement fallback to the given
+hash_like_object+; the replacement string is <tt>hash_like_object[X]</tt>.
- <tt>:fallback: method</tt>: Set replacement fallback to the given
+method+; the replacement string is <tt>method(X)</tt>.
- <tt>:fallback: proc</tt>: Set replacement fallback to the given
+proc+; the replacement string is <tt>proc[X]</tt>.

Examples:

Expand Down
26 changes: 13 additions & 13 deletions doc/language/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ require 'English'

### Matched \Data

| Variable | \English | Contains | Initially | Read-Only | Reset By |
|:-------------:|:-------------------:|-----------------------------------|:---------:|:---------:|-----------------|
| `$~` | `$LAST_MATCH_INFO` | \MatchData object or `nil` | `nil` | No | Matcher methods |
| `$&` | `$MATCH` | Matched substring or `nil` | `nil` | No | Matcher methods |
| `` $` `` | `$PRE_MATCH` | Substring left of match or `nil` | `nil` | No | Matcher methods |
| `$'` | `$POST_MATCH` | Substring right of match or `nil` | `nil` | No | Matcher methods |
| `$+` | `$LAST_PAREN_MATCH` | Last group matched or `nil` | `nil` | No | Matcher methods |
| `$1` | | First group matched or `nil` | `nil` | Yes | Matcher methods |
| `$2` | | Second group matched or `nil` | `nil` | Yes | Matcher methods |
| <tt>$_n_</tt> | | <i>n</i>th group matched or `nil` | `nil` | Yes | Matcher methods |
| Variable | \English | Contains | Initially | Read-Only | Reset By |
|:---------:|:-------------------:|-----------------------------------|:---------:|:---------:|-----------------|
| `$~` | `$LAST_MATCH_INFO` | \MatchData object or `nil` | `nil` | No | Matcher methods |
| `$&` | `$MATCH` | Matched substring or `nil` | `nil` | No | Matcher methods |
| `` $` `` | `$PRE_MATCH` | Substring left of match or `nil` | `nil` | No | Matcher methods |
| `$'` | `$POST_MATCH` | Substring right of match or `nil` | `nil` | No | Matcher methods |
| `$+` | `$LAST_PAREN_MATCH` | Last group matched or `nil` | `nil` | No | Matcher methods |
| `$1` | | First group matched or `nil` | `nil` | Yes | Matcher methods |
| `$2` | | Second group matched or `nil` | `nil` | Yes | Matcher methods |
| `$n` | | <i>n</i>th group matched or `nil` | `nil` | Yes | Matcher methods |

### Separators

Expand Down Expand Up @@ -167,7 +167,7 @@ English - `$LAST_PAREN_MATCH`.

### `$1`, `$2`, \Etc. (Matched Group)

For <tt>$_n_</tt> the <i>n</i>th group of the match.
For <tt>$n</tt> the <i>n</i>th group of the match.

No \English.

Expand Down Expand Up @@ -282,9 +282,9 @@ by Kernel#load and Kernel#require.
Singleton method `$LOAD_PATH.resolve_feature_path(feature)`
returns:

- <tt>[:rb, _path_]</tt>, where `path` is the path to the Ruby file to be
- <tt>[:rb, path]</tt>, where `path` is the path to the Ruby file to be
loaded for the given `feature`.
- <tt>[:so, _path_]</tt>, where `path` is the path to the shared object file
- <tt>[:so, path]</tt>, where `path` is the path to the shared object file
to be loaded for the given `feature`.
- `nil` if there is no such `feature` and `path`.

Expand Down
4 changes: 2 additions & 2 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -7963,11 +7963,11 @@ Init_File(void)
*
* ==== File::FNM_EXTGLOB
*
* Flag File::FNM_EXTGLOB enables pattern <tt>'{_a_,_b_}'</tt>,
* Flag File::FNM_EXTGLOB enables pattern <tt>'{a,b}'</tt>,
* which matches pattern '_a_' and pattern '_b_';
* behaves like
* a {regexp union}[rdoc-ref:Regexp.union]
* (e.g., <tt>'(?:_a_|_b_)'</tt>):
* (e.g., <tt>'(?:a|b)'</tt>):
*
* pattern = '{LEGAL,BSDL}'
* Dir.glob(pattern) # => ["LEGAL", "BSDL"]
Expand Down
25 changes: 14 additions & 11 deletions gc/mmtk/mmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,7 @@ rb_mmtk_vm_live_bytes(void)
static void
make_final_job(struct objspace *objspace, VALUE obj, VALUE table)
{
RUBY_ASSERT(RB_FL_TEST(obj, RUBY_FL_FINALIZE));
RUBY_ASSERT(mmtk_is_reachable((MMTk_ObjectReference)table));
RUBY_ASSERT(RB_BUILTIN_TYPE(table) == T_ARRAY);

RB_FL_UNSET(obj, RUBY_FL_FINALIZE);
MMTK_ASSERT(RB_BUILTIN_TYPE(table) == T_ARRAY);

struct MMTk_final_job *job = xmalloc(sizeof(struct MMTk_final_job));
job->next = objspace->finalizer_jobs;
Expand All @@ -365,15 +361,16 @@ make_final_job(struct objspace *objspace, VALUE obj, VALUE table)
static int
rb_mmtk_update_finalizer_table_i(st_data_t key, st_data_t value, st_data_t data, int error)
{
RUBY_ASSERT(RB_FL_TEST(key, RUBY_FL_FINALIZE));
RUBY_ASSERT(mmtk_is_reachable((MMTk_ObjectReference)value));
RUBY_ASSERT(RB_BUILTIN_TYPE(value) == T_ARRAY);
MMTK_ASSERT(mmtk_is_reachable((MMTk_ObjectReference)value));
MMTK_ASSERT(RB_BUILTIN_TYPE(value) == T_ARRAY);

struct objspace *objspace = (struct objspace *)data;

if (mmtk_is_reachable((MMTk_ObjectReference)key)) {
VALUE new_key_location = rb_mmtk_call_object_closure((VALUE)key, false);

MMTK_ASSERT(RB_FL_TEST(new_key_location, RUBY_FL_FINALIZE));

if (new_key_location != key) {
return ST_REPLACE;
}
Expand Down Expand Up @@ -445,7 +442,7 @@ rb_mmtk_update_global_tables_replace_i(VALUE *ptr, void *data)
static void
rb_mmtk_update_global_tables(int table)
{
RUBY_ASSERT(table < RB_GC_VM_WEAK_TABLE_COUNT);
MMTK_ASSERT(table < RB_GC_VM_WEAK_TABLE_COUNT);

// TODO: set weak_only to true for non-moving GC
rb_gc_vm_weak_table_foreach(
Expand Down Expand Up @@ -606,7 +603,13 @@ rb_gc_impl_ractor_cache_free(void *objspace_ptr, void *cache_ptr)

ccan_list_del(&cache->list_node);

RUBY_ASSERT(objspace->live_ractor_cache_count > 1);
if (ruby_free_at_exit_p()) {
MMTK_ASSERT(objspace->live_ractor_cache_count > 0);
}
else {
MMTK_ASSERT(objspace->live_ractor_cache_count > 1);
}

objspace->live_ractor_cache_count--;

mmtk_destroy_mutator(cache->mutator);
Expand Down Expand Up @@ -1502,7 +1505,7 @@ rb_gc_impl_object_metadata(void *objspace_ptr, VALUE obj)
size_t n = 0;

#define SET_ENTRY(na, v) do { \
RUBY_ASSERT(n <= RB_GC_OBJECT_METADATA_ENTRY_COUNT); \
MMTK_ASSERT(n <= RB_GC_OBJECT_METADATA_ENTRY_COUNT); \
object_metadata_entries[n].name = ID_##na; \
object_metadata_entries[n].val = v; \
n++; \
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/sentence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def inner_inspect(ary, r)
# returns new sentence object which
# _target_ is substituted by the block.
#
# Sentence#subst invokes <tt>_target_ === _string_</tt> for each
# Sentence#subst invokes <tt>target === string</tt> for each
# string in the sentence.
# The strings which === returns true are substituted by the block.
# The block is invoked with the substituting string.
Expand Down