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
0c924b92
Commit
0c924b92
authored
Nov 24, 2016
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed a bug in self modifying Array#[]=; fix #3274
parent
cb5c9d34
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
src/array.c
src/array.c
+17
-1
No files found.
src/array.c
View file @
0c924b92
...
@@ -309,9 +309,12 @@ ary_replace(mrb_state *mrb, struct RArray *a, mrb_value *argv, mrb_int len)
...
@@ -309,9 +309,12 @@ ary_replace(mrb_state *mrb, struct RArray *a, mrb_value *argv, mrb_int len)
MRB_API
void
MRB_API
void
mrb_ary_replace
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
other
)
mrb_ary_replace
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
other
)
{
{
struct
RArray
*
a1
=
mrb_ary_ptr
(
self
);
struct
RArray
*
a2
=
mrb_ary_ptr
(
other
);
struct
RArray
*
a2
=
mrb_ary_ptr
(
other
);
ary_replace
(
mrb
,
mrb_ary_ptr
(
self
),
a2
->
ptr
,
a2
->
len
);
if
(
a1
!=
a2
)
{
ary_replace
(
mrb
,
a1
,
a2
->
ptr
,
a2
->
len
);
}
}
}
static
mrb_value
static
mrb_value
...
@@ -554,6 +557,15 @@ mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val)
...
@@ -554,6 +557,15 @@ mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val)
mrb_field_write_barrier_value
(
mrb
,
(
struct
RBasic
*
)
a
,
val
);
mrb_field_write_barrier_value
(
mrb
,
(
struct
RBasic
*
)
a
,
val
);
}
}
static
struct
RArray
*
ary_dup
(
mrb_state
*
mrb
,
struct
RArray
*
a
)
{
struct
RArray
*
d
=
ary_new_capa
(
mrb
,
a
->
len
);
ary_replace
(
mrb
,
d
,
a
->
ptr
,
a
->
len
);
return
d
;
}
MRB_API
mrb_value
MRB_API
mrb_value
mrb_ary_splice
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
head
,
mrb_int
len
,
mrb_value
rpl
)
mrb_ary_splice
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
head
,
mrb_int
len
,
mrb_value
rpl
)
{
{
...
@@ -583,6 +595,10 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val
...
@@ -583,6 +595,10 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val
if
(
mrb_array_p
(
rpl
))
{
if
(
mrb_array_p
(
rpl
))
{
argc
=
RARRAY_LEN
(
rpl
);
argc
=
RARRAY_LEN
(
rpl
);
argv
=
RARRAY_PTR
(
rpl
);
argv
=
RARRAY_PTR
(
rpl
);
if
(
argv
==
a
->
ptr
)
{
struct
RArray
*
r
=
ary_dup
(
mrb
,
a
);
argv
=
r
->
ptr
;
}
}
}
else
{
else
{
argc
=
1
;
argc
=
1
;
...
...
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