From b9bfa39d146db783083940e943e2224dfd81518b Mon Sep 17 00:00:00 2001 From: yugui Date: Thu, 25 Dec 2008 09:51:10 +0000 Subject: 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@20998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index c2f5e60c1..bf9452e5b 100644 --- a/numeric.c +++ b/numeric.c @@ -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); } -- cgit