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
66a099b1
Unverified
Commit
66a099b1
authored
Dec 29, 2021
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
string.c: reorganize `str_convert_range` using `mrb_ensure_int_type`
parent
b6d31810
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
12 deletions
+3
-12
src/string.c
src/string.c
+3
-12
No files found.
src/string.c
View file @
66a099b1
...
@@ -1108,6 +1108,9 @@ str_convert_range(mrb_state *mrb, mrb_value str, mrb_value indx, mrb_value alen,
...
@@ -1108,6 +1108,9 @@ str_convert_range(mrb_state *mrb, mrb_value str, mrb_value indx, mrb_value alen,
}
}
else
{
else
{
switch
(
mrb_type
(
indx
))
{
switch
(
mrb_type
(
indx
))
{
default:
indx
=
mrb_ensure_int_type
(
mrb
,
indx
);
/* fall through */
case
MRB_TT_INTEGER
:
case
MRB_TT_INTEGER
:
*
beg
=
mrb_integer
(
indx
);
*
beg
=
mrb_integer
(
indx
);
*
len
=
1
;
*
len
=
1
;
...
@@ -1120,16 +1123,6 @@ str_convert_range(mrb_state *mrb, mrb_value str, mrb_value indx, mrb_value alen,
...
@@ -1120,16 +1123,6 @@ str_convert_range(mrb_state *mrb, mrb_value str, mrb_value indx, mrb_value alen,
return
STR_BYTE_RANGE_CORRECTED
;
return
STR_BYTE_RANGE_CORRECTED
;
case
MRB_TT_RANGE
:
case
MRB_TT_RANGE
:
goto
range_arg
;
default:
indx
=
mrb_to_integer
(
mrb
,
indx
);
if
(
mrb_integer_p
(
indx
))
{
*
beg
=
mrb_integer
(
indx
);
*
len
=
1
;
return
STR_CHAR_RANGE
;
}
range_arg:
*
len
=
RSTRING_CHAR_LEN
(
str
);
*
len
=
RSTRING_CHAR_LEN
(
str
);
switch
(
mrb_range_beg_len
(
mrb
,
indx
,
beg
,
len
,
*
len
,
TRUE
))
{
switch
(
mrb_range_beg_len
(
mrb
,
indx
,
beg
,
len
,
*
len
,
TRUE
))
{
case
MRB_RANGE_OK
:
case
MRB_RANGE_OK
:
...
@@ -1139,8 +1132,6 @@ range_arg:
...
@@ -1139,8 +1132,6 @@ range_arg:
default:
default:
break
;
break
;
}
}
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"can't convert to Integer"
);
}
}
}
}
return
STR_OUT_OF_RANGE
;
return
STR_OUT_OF_RANGE
;
...
...
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