diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 09:51:10 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 09:51:10 +0000 |
commit | d9f4570bddeb4d21e30936991adbc6e9d079ae4e (patch) | |
tree | 10acfab54dec1c884d2f0451362bdeab8991d335 /numeric.c | |
parent | 4e541c9dabff680cfc831a6d157ce75c21b8b951 (diff) |
merges r20909 and r20910 from trunk into ruby_1_9_1.
* configure.in (mingw): no longer uses snprintf and vsnprintf of
msvcrt.
* win32/win32.c (rb_w32_vsnprintf, rb_w32_snprintf): removed.
* win32/Makefile.sub (config.h): vsnprintf exists in VC7 or later.
* win32/mkexports.rb (Exports#initialize): aliases
rb_w32_vsnprintf and rb_w32_snprintf for binary compatibility.
* sprintf.c (rb_str_format): uses snprintf instead of sprintf.
* numeric.c (flo_to_s, rb_num2long, rb_num2ll): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -530,12 +530,12 @@ flo_to_s(VALUE flt) else if(isnan(value)) return rb_usascii_str_new2("NaN"); - sprintf(buf, "%#.15g", value); /* ensure to print decimal point */ + snprintf(buf, sizeof(buf), "%#.15g", value); /* ensure to print decimal point */ if (!(e = strchr(buf, 'e'))) { e = buf + strlen(buf); } if (!ISDIGIT(e[-1])) { /* reformat if ended with decimal point (ex 111111111111111.) */ - sprintf(buf, "%#.14e", value); + snprintf(buf, sizeof(buf), "%#.14e", value); if (!(e = strchr(buf, 'e'))) { e = buf + strlen(buf); } @@ -1553,7 +1553,7 @@ rb_num2long(VALUE val) char buf[24]; char *s; - sprintf(buf, "%-.10g", RFLOAT_VALUE(val)); + snprintf(buf, sizeof(buf), "%-.10g", RFLOAT_VALUE(val)); if ((s = strchr(buf, ' ')) != 0) *s = '\0'; rb_raise(rb_eRangeError, "float %s out of range of integer", buf); } @@ -1699,7 +1699,7 @@ rb_num2ll(VALUE val) char buf[24]; char *s; - sprintf(buf, "%-.10g", RFLOAT_VALUE(val)); + snprintf(buf, sizeof(buf), "%-.10g", RFLOAT_VALUE(val)); if ((s = strchr(buf, ' ')) != 0) *s = '\0'; rb_raise(rb_eRangeError, "float %s out of range of long long", buf); } |