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
2add8641
Commit
2add8641
authored
Jul 16, 2019
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow `mruby-range-ext` to work with `MRB_WITHOUT_FLOAT`; ref #4576
parent
5eef75b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
mrbgems/mruby-range-ext/src/range.c
mrbgems/mruby-range-ext/src/range.c
+23
-4
No files found.
mrbgems/mruby-range-ext/src/range.c
View file @
2add8641
#ifdef MRB_WITHOUT_FLOAT
# error Conflict 'MRB_WITHOUT_FLOAT' configuration in your 'build_config.rb'
#endif
#include <mruby.h>
#include <mruby/range.h>
#include <math.h>
...
...
@@ -110,6 +106,7 @@ range_last(mrb_state *mrb, mrb_value range)
* ('a'..'z').size #=> nil
*/
#ifndef MRB_WITHOUT_FLOAT
static
mrb_value
range_size
(
mrb_state
*
mrb
,
mrb_value
range
)
{
...
...
@@ -162,6 +159,28 @@ range_size(mrb_state *mrb, mrb_value range)
}
return
mrb_nil_value
();
}
#else
static
mrb_value
range_size
(
mrb_state
*
mrb
,
mrb_value
range
)
{
struct
RRange
*
r
=
mrb_range_ptr
(
mrb
,
range
);
mrb_value
beg
,
end
;
mrb_int
excl
;
beg
=
RANGE_BEG
(
r
);
end
=
RANGE_END
(
r
);
excl
=
RANGE_EXCL
(
r
)
?
0
:
1
;
if
(
mrb_fixnum_p
(
beg
)
&&
mrb_fixnum_p
(
end
))
{
mrb_int
a
=
mrb_fixnum
(
beg
);
mrb_int
b
=
mrb_fixnum
(
end
);
mrb_int
c
=
b
-
a
+
excl
;
return
mrb_fixnum_value
(
c
);
}
return
mrb_nil_value
();
}
#endif
/* MRB_WITHOUT_FLOAT */
void
mrb_mruby_range_ext_gem_init
(
mrb_state
*
mrb
)
...
...
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