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
f6c41c18
Unverified
Commit
f6c41c18
authored
Aug 03, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Aug 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4611 from shuujii/fix-mrb_vformat%f-with-MRB_USE_FLOAT
Fix `mrb_vformat("%f")` with `MRB_USE_FLOAT`
parents
d5695a84
a4243360
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
mrbgems/mruby-test/vformat.c
mrbgems/mruby-test/vformat.c
+5
-0
src/error.c
src/error.c
+3
-1
test/t/vformat.rb
test/t/vformat.rb
+5
-3
No files found.
mrbgems/mruby-test/vformat.c
View file @
f6c41c18
...
...
@@ -4,6 +4,11 @@
#include <mruby/data.h>
#include <mruby/string.h>
#ifdef MRB_WITHOUT_FLOAT
typedef
mrb_int
mrb_float
;
#define mrb_float(o) mrb_fixnum(o)
#endif
#define NATIVE_TYPES \
char c; \
int d; \
...
...
src/error.c
View file @
f6c41c18
...
...
@@ -328,9 +328,11 @@ mrb_vformat(mrb_state *mrb, const char *format, va_list ap)
i
=
*
p
==
'd'
?
(
mrb_int
)
va_arg
(
ap
,
int
)
:
va_arg
(
ap
,
mrb_int
);
obj
=
mrb_fixnum_value
(
i
);
goto
L_cat_obj
;
#ifndef MRB_WITHOUT_FLOAT
case
'f'
:
obj
=
mrb_float_value
(
mrb
,
va_arg
(
ap
,
mrb_float
));
obj
=
mrb_float_value
(
mrb
,
(
mrb_float
)
va_arg
(
ap
,
double
));
goto
L_cat_obj
;
#endif
case
'l'
:
chars
=
va_arg
(
ap
,
char
*
);
len
=
va_arg
(
ap
,
mrb_int
);
...
...
test/t/vformat.rb
View file @
f6c41c18
...
...
@@ -35,15 +35,12 @@ assert('mrb_vformat') do
assert_format
'`d`: -79'
,
[
'`d`: %d'
,
n
.
d
(
-
79
)]
assert_format
'`i`: 514'
,
[
'`i`: %i'
,
n
.
i
(
514
)]
assert_format
'`i`: -83'
,
[
'`i`: %i'
,
n
.
i
(
-
83
)]
assert_format
'`f`: 0.0125'
,
[
'`f`: %f'
,
n
.
f
(
0.0125
)]
assert_format
'`t`: NilClass'
,
[
'`t`: %t'
,
nil
]
assert_format
'`t`: FalseClass'
,
[
'`t`: %t'
,
false
]
assert_format
'`t`: TrueClass'
,
[
'`t`: %t'
,
true
]
assert_format
'`t`: Fixnum'
,
[
'`t`: %t'
,
0
]
assert_format
'`t`: Hash'
,
[
'`t`: %t'
,
k:
"value"
]
assert_format_pattern
'#<Class:#<Class:#<Hash:0x*>>>'
,
[
'%t'
,
sclass
({})]
assert_format
'-Infinity'
,
[
'%f'
,
n
.
f
(
-
Float
::
INFINITY
)]
assert_format
'NaN: Not a Number'
,
[
'%f: Not a Number'
,
n
.
f
(
Float
::
NAN
)]
assert_format
'string and length'
,
[
'string %l length'
,
n
.
s
(
'andante'
),
n
.
i
(
3
)]
assert_format
'`n`: sym'
,
[
'`n`: %n'
,
n
.
n
(
:sym
)]
assert_format
'%C文字列%'
,
[
'%s'
,
n
.
s
(
'%C文字列%'
)]
...
...
@@ -87,4 +84,9 @@ assert('mrb_vformat') do
assert_implementation_dependent
'termination is \\'
,
[
'termination is \\'
]
assert_implementation_dependent
'termination is %'
,
[
'termination is %'
]
assert_implementation_dependent
'termination is %!'
,
[
'termination is %!'
]
skip
unless
Object
.
const_defined?
(
:Float
)
assert_format
'`f`: 0.0125'
,
[
'`f`: %f'
,
n
.
f
(
0.0125
)]
assert_format
'-Infinity'
,
[
'%f'
,
n
.
f
(
-
Float
::
INFINITY
)]
assert_format
'NaN: Not a Number'
,
[
'%f: Not a Number'
,
n
.
f
(
Float
::
NAN
)]
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