diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-04 12:33:07 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-04 12:33:07 +0900 |
| commit | d6cb4f9cf2027eb20f67238aa6c051448602e7e6 (patch) | |
| tree | c025d53534298097aadc3d7699de964bd8a7225f /mrbgems/mruby-sprintf/src/sprintf.c | |
| parent | 388d26d77027feaa3e107abf7209e2681868bbe6 (diff) | |
| parent | a751f7f196e35cf85ac6f5c0d855edeb68b2bf53 (diff) | |
| download | mruby-d6cb4f9cf2027eb20f67238aa6c051448602e7e6.tar.gz mruby-d6cb4f9cf2027eb20f67238aa6c051448602e7e6.zip | |
Merge branch '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 |
