diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-04 11:49:25 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-04 11:49:25 +0900 |
| commit | de2363a9f0c7d368ee9002f86931d124e644a243 (patch) | |
| tree | 2112928a80786a109ecac4b3ce200f45ac75e2cb /mrbgems/mruby-sprintf/src/sprintf.c | |
| parent | 388d26d77027feaa3e107abf7209e2681868bbe6 (diff) | |
| parent | 625f9f6fa314872968632c5adbee7fb3823268b8 (diff) | |
| download | mruby-de2363a9f0c7d368ee9002f86931d124e644a243.tar.gz mruby-de2363a9f0c7d368ee9002f86931d124e644a243.zip | |
Merge branch 'mrb_without_float' of https://github.com/pandax381/mruby into pandax381-mrb_without_float
Diffstat (limited to 'mrbgems/mruby-sprintf/src/sprintf.c')
| -rw-r--r-- | mrbgems/mruby-sprintf/src/sprintf.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mrbgems/mruby-sprintf/src/sprintf.c b/mrbgems/mruby-sprintf/src/sprintf.c index efa0b3d34..7eea1a1f3 100644 --- a/mrbgems/mruby-sprintf/src/sprintf.c +++ b/mrbgems/mruby-sprintf/src/sprintf.c @@ -12,7 +12,9 @@ #include <mruby/string.h> #include <mruby/hash.h> #include <mruby/numeric.h> +#ifndef MRB_WITHOUT_FLOAT #include <math.h> +#endif #include <ctype.h> #define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */ @@ -20,7 +22,9 @@ #define EXTENDSIGN(n, l) (((~0U << (n)) >> (((n)*(l)) % BITSPERDIG)) & ~(~0U << (n))) mrb_value mrb_str_format(mrb_state *, mrb_int, const mrb_value *, mrb_value); +#ifndef MRB_WITHOUT_FLOAT static void fmt_setup(char*,size_t,int,int,mrb_int,mrb_int); +#endif static char* remove_sign_bits(char *str, int base) @@ -814,10 +818,12 @@ retry: bin_retry: switch (mrb_type(val)) { +#ifndef MRB_WITHOUT_FLOAT case MRB_TT_FLOAT: val = mrb_flo_to_fixnum(mrb, val); if (mrb_fixnum_p(val)) goto bin_retry; break; +#endif case MRB_TT_STRING: val = mrb_str_to_inum(mrb, val, 0, TRUE); goto bin_retry; @@ -990,6 +996,7 @@ retry: } break; +#ifndef MRB_WITHOUT_FLOAT case 'f': case 'g': case 'G': @@ -1069,6 +1076,7 @@ retry: blen += n; } break; +#endif } flags = FNONE; } @@ -1088,6 +1096,7 @@ retry: return result; } +#ifndef MRB_WITHOUT_FLOAT static void fmt_setup(char *buf, size_t size, int c, int flags, mrb_int width, mrb_int prec) { @@ -1114,3 +1123,4 @@ fmt_setup(char *buf, size_t size, int c, int flags, mrb_int width, mrb_int prec) *buf++ = c; *buf = '\0'; } +#endif |
