mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fixed a typo in lib/soap/mimemessage.rb -- conent -> content
Backported BigDecimal fixes to bugs with BigDecimal handling of very large inputs; these bugs caused bad things to happen in combination with Date. Tests were added to the rubyspec project to cover these fixed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@23652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
eb7f867981
commit
b160da8d0b
4 changed files with 64 additions and 27 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
Mon Jun 8 12:46:00 2009 Kirk Haines <khaines@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/soap/mimemessage.rb: Fixed a typo -- conent -> content
|
||||||
|
|
||||||
|
* ext/bigdecimal/bigdecimal.c: Backported a number of bug fixes
|
||||||
|
dealing with large input to BigDecimal.new causing segfaults.
|
||||||
|
|
||||||
Thu Mar 31 18:18:18 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Mar 31 18:18:18 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/mkmf.rb (mkintpath): new function which converts native path
|
* lib/mkmf.rb (mkintpath): new function which converts native path
|
||||||
|
|
|
||||||
|
|
@ -306,17 +306,22 @@ static VALUE
|
||||||
BigDecimal_dump(int argc, VALUE *argv, VALUE self)
|
BigDecimal_dump(int argc, VALUE *argv, VALUE self)
|
||||||
{
|
{
|
||||||
ENTER(5);
|
ENTER(5);
|
||||||
char sz[50];
|
|
||||||
Real *vp;
|
Real *vp;
|
||||||
char *psz;
|
char *psz;
|
||||||
VALUE dummy;
|
VALUE dummy;
|
||||||
|
volatile VALUE dump;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "01", &dummy);
|
rb_scan_args(argc, argv, "01", &dummy);
|
||||||
GUARD_OBJ(vp,GetVpValue(self,1));
|
GUARD_OBJ(vp,GetVpValue(self,1));
|
||||||
sprintf(sz,"%lu:",VpMaxPrec(vp)*VpBaseFig());
|
|
||||||
psz = ALLOCA_N(char,(unsigned int)VpNumOfChars(vp,"E")+strlen(sz));
|
dump = rb_str_new(0,VpNumOfChars(vp,"E")+50);
|
||||||
sprintf(psz,"%s",sz);
|
psz = RSTRING_PTR(dump);
|
||||||
|
sprintf(psz,"%lu:",VpMaxPrec(vp)*VpBaseFig());
|
||||||
|
|
||||||
VpToString(vp, psz+strlen(psz), 0, 0);
|
VpToString(vp, psz+strlen(psz), 0, 0);
|
||||||
return rb_str_new2(psz);
|
|
||||||
|
rb_str_resize(dump, strlen(psz));
|
||||||
|
return dump;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -520,6 +525,7 @@ BigDecimal_to_i(VALUE self)
|
||||||
ENTER(5);
|
ENTER(5);
|
||||||
int e,n,i,nf;
|
int e,n,i,nf;
|
||||||
U_LONG v,b,j;
|
U_LONG v,b,j;
|
||||||
|
volatile VALUE str;
|
||||||
char *psz,*pch;
|
char *psz,*pch;
|
||||||
Real *p;
|
Real *p;
|
||||||
|
|
||||||
|
|
@ -544,10 +550,12 @@ BigDecimal_to_i(VALUE self)
|
||||||
e = VpGetSign(p)*p->frac[0];
|
e = VpGetSign(p)*p->frac[0];
|
||||||
return INT2FIX(e);
|
return INT2FIX(e);
|
||||||
}
|
}
|
||||||
psz = ALLOCA_N(char,(unsigned int)(e+nf+2));
|
|
||||||
|
|
||||||
|
str = rb_str_new(0, e+nf+2);
|
||||||
|
psz = RSTRING_PTR(str);
|
||||||
n = (e+nf-1)/nf;
|
n = (e+nf-1)/nf;
|
||||||
pch = psz;
|
pch = psz;
|
||||||
|
|
||||||
if(VpGetSign(p)<0) *pch++ = '-';
|
if(VpGetSign(p)<0) *pch++ = '-';
|
||||||
for(i=0;i<n;++i) {
|
for(i=0;i<n;++i) {
|
||||||
b = VpBaseVal()/10;
|
b = VpBaseVal()/10;
|
||||||
|
|
@ -567,6 +575,7 @@ BigDecimal_to_i(VALUE self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*pch++ = 0;
|
*pch++ = 0;
|
||||||
|
|
||||||
return rb_cstr2inum(psz,10);
|
return rb_cstr2inum(psz,10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -589,14 +598,19 @@ BigDecimal_to_f(VALUE self)
|
||||||
double d;
|
double d;
|
||||||
S_LONG e;
|
S_LONG e;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
volatile VALUE str;
|
||||||
|
|
||||||
GUARD_OBJ(p,GetVpValue(self,1));
|
GUARD_OBJ(p,GetVpValue(self,1));
|
||||||
if(VpVtoD(&d, &e, p)!=1) return rb_float_new(d);
|
if(VpVtoD(&d, &e, p)!=1) return rb_float_new(d);
|
||||||
buf = ALLOCA_N(char,(unsigned int)VpNumOfChars(p,"E"));
|
if (e > DBL_MAX_10_EXP) goto erange;
|
||||||
|
str = rb_str_new(0, VpNumOfChars(p,"E"));
|
||||||
|
buf = RSTRING_PTR(str);
|
||||||
|
|
||||||
VpToString(p, buf, 0, 0);
|
VpToString(p, buf, 0, 0);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
d = strtod(buf, 0);
|
d = strtod(buf, 0);
|
||||||
if(errno == ERANGE) {
|
if(errno == ERANGE) {
|
||||||
|
erange:
|
||||||
VpException(VP_EXCEPTION_OVERFLOW,"BigDecimal to Float conversion",0);
|
VpException(VP_EXCEPTION_OVERFLOW,"BigDecimal to Float conversion",0);
|
||||||
if(d>0.0) return rb_float_new(DBL_MAX);
|
if(d>0.0) return rb_float_new(DBL_MAX);
|
||||||
else return rb_float_new(-DBL_MAX);
|
else return rb_float_new(-DBL_MAX);
|
||||||
|
|
@ -1491,6 +1505,7 @@ BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
|
||||||
int fmt=0; /* 0:E format */
|
int fmt=0; /* 0:E format */
|
||||||
int fPlus=0; /* =0:default,=1: set ' ' before digits ,set '+' before digits. */
|
int fPlus=0; /* =0:default,=1: set ' ' before digits ,set '+' before digits. */
|
||||||
Real *vp;
|
Real *vp;
|
||||||
|
volatile VALUE str;
|
||||||
char *psz;
|
char *psz;
|
||||||
char ch;
|
char ch;
|
||||||
U_LONG nc;
|
U_LONG nc;
|
||||||
|
|
@ -1527,14 +1542,17 @@ BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
|
||||||
}
|
}
|
||||||
if(mc>0) nc += (nc + mc - 1) / mc + 1;
|
if(mc>0) nc += (nc + mc - 1) / mc + 1;
|
||||||
|
|
||||||
psz = ALLOCA_N(char,(unsigned int)nc);
|
str = rb_str_new(0, nc);
|
||||||
|
psz = RSTRING_PTR(str);
|
||||||
|
|
||||||
if(fmt) {
|
if(fmt) {
|
||||||
VpToFString(vp, psz, mc, fPlus);
|
VpToFString(vp, psz, mc, fPlus);
|
||||||
} else {
|
} else {
|
||||||
VpToString (vp, psz, mc, fPlus);
|
VpToString (vp, psz, mc, fPlus);
|
||||||
}
|
}
|
||||||
return rb_str_new2(psz);
|
|
||||||
|
rb_str_resize(str, strlen(psz));
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Splits a BigDecimal number into four parts, returned as an array of values.
|
/* Splits a BigDecimal number into four parts, returned as an array of values.
|
||||||
|
|
@ -1566,24 +1584,29 @@ BigDecimal_split(VALUE self)
|
||||||
{
|
{
|
||||||
ENTER(5);
|
ENTER(5);
|
||||||
Real *vp;
|
Real *vp;
|
||||||
VALUE obj,obj1;
|
VALUE obj,str;
|
||||||
S_LONG e;
|
S_LONG e;
|
||||||
S_LONG s;
|
S_LONG s;
|
||||||
char *psz1;
|
char *psz1;
|
||||||
|
|
||||||
GUARD_OBJ(vp,GetVpValue(self,1));
|
GUARD_OBJ(vp,GetVpValue(self,1));
|
||||||
psz1 = ALLOCA_N(char,(unsigned int)VpNumOfChars(vp,"E"));
|
str = rb_str_new(0, VpNumOfChars(vp,"E"));
|
||||||
|
psz1 = RSTRING_PTR(str);
|
||||||
|
|
||||||
VpSzMantissa(vp,psz1);
|
VpSzMantissa(vp,psz1);
|
||||||
s = 1;
|
s = 1;
|
||||||
if(psz1[0]=='-') {
|
if(psz1[0]=='-') {
|
||||||
s = -1; ++psz1;
|
int len = strlen(psz1+1);
|
||||||
|
memmove(psz1, psz1+1, len);
|
||||||
|
psz1[len] = '\0';
|
||||||
|
s = -1;
|
||||||
}
|
}
|
||||||
if(psz1[0]=='N') s=0; /* NaN */
|
if(psz1[0]=='N') s=0; /* NaN */
|
||||||
e = VpExponent10(vp);
|
e = VpExponent10(vp);
|
||||||
obj1 = rb_str_new2(psz1);
|
|
||||||
obj = rb_ary_new2(4);
|
obj = rb_ary_new2(4);
|
||||||
rb_ary_push(obj, INT2FIX(s));
|
rb_ary_push(obj, INT2FIX(s));
|
||||||
rb_ary_push(obj, obj1);
|
rb_ary_push(obj, str);
|
||||||
|
rb_str_resize(str, strlen(psz1));
|
||||||
rb_ary_push(obj, INT2FIX(10));
|
rb_ary_push(obj, INT2FIX(10));
|
||||||
rb_ary_push(obj, INT2NUM(e));
|
rb_ary_push(obj, INT2NUM(e));
|
||||||
return obj;
|
return obj;
|
||||||
|
|
@ -1616,20 +1639,23 @@ BigDecimal_inspect(VALUE self)
|
||||||
{
|
{
|
||||||
ENTER(5);
|
ENTER(5);
|
||||||
Real *vp;
|
Real *vp;
|
||||||
VALUE obj;
|
volatile VALUE obj;
|
||||||
unsigned int nc;
|
unsigned int nc;
|
||||||
char *psz1;
|
char *psz, *tmp;
|
||||||
char *pszAll;
|
|
||||||
|
|
||||||
GUARD_OBJ(vp,GetVpValue(self,1));
|
GUARD_OBJ(vp,GetVpValue(self,1));
|
||||||
nc = VpNumOfChars(vp,"E");
|
nc = VpNumOfChars(vp,"E");
|
||||||
nc +=(nc + 9) / 10;
|
nc +=(nc + 9) / 10;
|
||||||
|
|
||||||
psz1 = ALLOCA_N(char,nc);
|
obj = rb_str_new(0, nc+256);
|
||||||
pszAll = ALLOCA_N(char,nc+256);
|
psz = RSTRING_PTR(obj);
|
||||||
VpToString(vp, psz1, 10, 0);
|
sprintf(psz,"#<BigDecimal:%lx,'",self);
|
||||||
sprintf(pszAll,"#<BigDecimal:%lx,'%s',%lu(%lu)>",self,psz1,VpPrec(vp)*VpBaseFig(),VpMaxPrec(vp)*VpBaseFig());
|
tmp = psz + strlen(psz);
|
||||||
obj = rb_str_new2(pszAll);
|
VpToString(vp, tmp, 10, 0);
|
||||||
|
tmp += strlen(tmp);
|
||||||
|
sprintf(tmp,"',%lu(%lu)>",VpPrec(vp)*VpBaseFig(),VpMaxPrec(vp)*VpBaseFig());
|
||||||
|
rb_str_resize(obj, strlen(psz));
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2482,6 +2508,7 @@ VpAlloc(U_LONG mx, const char *szVal)
|
||||||
int sign=1;
|
int sign=1;
|
||||||
Real *vp = NULL;
|
Real *vp = NULL;
|
||||||
U_LONG mf = VpGetPrecLimit();
|
U_LONG mf = VpGetPrecLimit();
|
||||||
|
volatile VALUE buf;
|
||||||
|
|
||||||
mx = (mx + BASE_FIG - 1) / BASE_FIG + 1; /* Determine allocation unit. */
|
mx = (mx + BASE_FIG - 1) / BASE_FIG + 1; /* Determine allocation unit. */
|
||||||
if(szVal) {
|
if(szVal) {
|
||||||
|
|
@ -2509,7 +2536,9 @@ VpAlloc(U_LONG mx, const char *szVal)
|
||||||
|
|
||||||
/* Skip all '_' after digit: 2006-6-30 */
|
/* Skip all '_' after digit: 2006-6-30 */
|
||||||
ni = 0;
|
ni = 0;
|
||||||
psz = ALLOCA_N(char,strlen(szVal)+1);
|
buf = rb_str_new(0,strlen(szVal)+1);
|
||||||
|
psz = RSTRING_PTR(buf);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
ipn = 0;
|
ipn = 0;
|
||||||
while((psz[i]=szVal[ipn])!=0) {
|
while((psz[i]=szVal[ipn])!=0) {
|
||||||
|
|
@ -3778,6 +3807,7 @@ VpToSpecialString(Real *a,char *psz,int fPlus)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VP_EXPORT void
|
VP_EXPORT void
|
||||||
VpToString(Real *a,char *psz,int fFmt,int fPlus)
|
VpToString(Real *a,char *psz,int fFmt,int fPlus)
|
||||||
/* fPlus =0:default, =1: set ' ' before digits , =2:set '+' before digits. */
|
/* fPlus =0:default, =1: set ' ' before digits , =2:set '+' before digits. */
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@ class MIMEMessage
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
str = headers_str + "\r\n\r\n" + conent_str
|
str = headers_str + "\r\n\r\n" + content_str
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define RUBY_RELEASE_DATE "2009-03-31"
|
#define RUBY_RELEASE_DATE "2009-03-31"
|
||||||
#define RUBY_VERSION_CODE 186
|
#define RUBY_VERSION_CODE 186
|
||||||
#define RUBY_RELEASE_CODE 20090331
|
#define RUBY_RELEASE_CODE 20090331
|
||||||
#define RUBY_PATCHLEVEL 368
|
#define RUBY_PATCHLEVEL 369
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
#define RUBY_VERSION_MINOR 8
|
#define RUBY_VERSION_MINOR 8
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue