Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
35be8b25
Commit
35be8b25
authored
Aug 07, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the corner case bug in `String#{gsub!,sub!}`.
`"a".sub!("a", "a")` should not return `nil`.
parent
54246db0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
mrblib/string.rb
mrblib/string.rb
+2
-2
No files found.
mrblib/string.rb
View file @
35be8b25
...
@@ -99,7 +99,7 @@ class String
...
@@ -99,7 +99,7 @@ class String
raise
FrozenError
,
"can't modify frozen String"
if
frozen?
raise
FrozenError
,
"can't modify frozen String"
if
frozen?
return
to_enum
(
:gsub!
,
*
args
)
if
args
.
length
==
1
&&
!
block
return
to_enum
(
:gsub!
,
*
args
)
if
args
.
length
==
1
&&
!
block
str
=
self
.
gsub
(
*
args
,
&
block
)
str
=
self
.
gsub
(
*
args
,
&
block
)
return
nil
if
str
==
self
return
nil
unless
self
.
index
(
args
[
0
])
self
.
replace
(
str
)
self
.
replace
(
str
)
end
end
...
@@ -161,7 +161,7 @@ class String
...
@@ -161,7 +161,7 @@ class String
def
sub!
(
*
args
,
&
block
)
def
sub!
(
*
args
,
&
block
)
raise
FrozenError
,
"can't modify frozen String"
if
frozen?
raise
FrozenError
,
"can't modify frozen String"
if
frozen?
str
=
self
.
sub
(
*
args
,
&
block
)
str
=
self
.
sub
(
*
args
,
&
block
)
return
nil
if
str
==
self
return
nil
unless
self
.
index
(
args
[
0
])
self
.
replace
(
str
)
self
.
replace
(
str
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment