From: nain Date: Fri, 6 Dec 2013 05:20:13 +0000 (+0900) Subject: zdd overflow対策 X-Git-Tag: mining_1.3 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c68f96d652131f200cd029b7b8bd79e2df0d4fa4;p=nysol%2Fmining.git zdd overflow対策 --- diff --git a/Makefile b/Makefile index be05f21..775a658 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -version = 1.2 +version = 1.3 # 共有ライブラリの拡張子を自動設定 ifeq ($(shell uname),Linux) diff --git a/revison_hash b/revison_hash index 1e04e75..3fce83a 100644 --- a/revison_hash +++ b/revison_hash @@ -1 +1 @@ -commit 8c34166f0be1d754582695083d96f774921f4ff7 +commit 6d4b686a97d30fcbe0c92d73169f45ad1e21f409 diff --git a/zdd/lib/gensrc.rb b/zdd/lib/gensrc.rb index 3743653..1c58218 100755 --- a/zdd/lib/gensrc.rb +++ b/zdd/lib/gensrc.rb @@ -534,8 +534,25 @@ func['| u_expr TOTALVAL'] =<<'SCP_EOF' VALUE vsop_totalval(VALUE self){ Vsop_Ruby* rmod; Data_Get_Struct(self,Vsop_Ruby,rmod); - int val = rmod->cmod->TotalVal().GetInt(); - return INT2NUM(val); + + CtoI a = rmod->cmod->TotalVal(); + if(a.IsConst()) + { + if(a.TopItem() > 0) a = a.MaxVal(); + int d = a.TopDigit() / 3 + 14; + kgAutoPtr2 a_ptr; + char *s; + try{ + a_ptr.set(new char[d]); + s = a_ptr.get(); + }catch(...){ + rb_raise(rb_eRuntimeError,\"memory allocation error\"); + } + int err = a.StrNum10(s); + if (err) { rb_raise(rb_eRuntimeError,\"StrNum10 error\"); } + return rb_cstr2inum(s,10); + } + return 0; } " SCP_EOF diff --git a/zdd/lib/zdd_so.cxx b/zdd/lib/zdd_so.cxx index f1fa795..47a7868 100644 --- a/zdd/lib/zdd_so.cxx +++ b/zdd/lib/zdd_so.cxx @@ -1601,9 +1601,22 @@ VALUE vsop_const_to_i(VALUE self){ Vsop_Ruby* rmod; Data_Get_Struct(self,Vsop_Ruby,rmod); - if(rmod->cmod->IsConst()){ - int val = rmod->cmod->GetInt(); - return INT2NUM(val); + CtoI a = *(rmod->cmod); + + if(a.IsConst()){ + if(a.TopItem() > 0) a = a.MaxVal(); + int d = a.TopDigit() / 3 + 14; + kgAutoPtr2 a_ptr; + char *s; + try{ + a_ptr.set(new char[d]); + s = a_ptr.get(); + }catch(...){ + rb_raise(rb_eRuntimeError,"memory allocation error"); + } + int err = a.StrNum10(s); + if (err) { rb_raise(rb_eRuntimeError,"StrNum10 error"); } + return rb_cstr2inum(s,10); }else{ return Qnil; }