Skip to content

Commit 7c8a91f

Browse files
committed
numeric.c: restore fmt argument for backward compatibility.
`mrb_float_to_str()` used to take `fmt` argument. We thought no one used the function, and OK to remove the argument. But at least `mruby-redis` gem used the function.
1 parent 50b6faf commit 7c8a91f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

include/mruby/numeric.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ MRB_API mrb_float mrb_as_float(mrb_state *mrb, mrb_value x);
166166

167167
/* internal functions */
168168
mrb_float mrb_div_float(mrb_float x, mrb_float y);
169-
mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x);
169+
mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
170170
int mrb_format_float(mrb_float f, char *buf, size_t buf_size, char fmt, int prec, char sign);
171171

172172
/* obsolete functions; will be removed */

src/numeric.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,9 @@ flo_div(mrb_state *mrb, mrb_value x)
277277
return mrb_float_value(mrb, a);
278278
}
279279

280-
MRB_API mrb_value
281-
mrb_float_to_str(mrb_state *mrb, mrb_value flo)
280+
/* the argument `fmt` is no longer used; you can pass `NULL` */
281+
mrb_value
282+
mrb_float_to_str(mrb_state *mrb, mrb_value flo, const char *fmt)
282283
{
283284
char buf[25];
284285
#ifdef MRB_USE_FLOAT32
@@ -330,7 +331,7 @@ flo_to_s(mrb_state *mrb, mrb_value flt)
330331
str = mrb_str_new_lit(mrb, "NaN");
331332
}
332333
else {
333-
str = mrb_float_to_str(mrb, flt);
334+
str = mrb_float_to_str(mrb, flt, NULL);
334335
}
335336

336337
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));

0 commit comments

Comments
 (0)