[前][次][番号順一覧][スレッド一覧]

ruby-changes:53990

From: mrkn <ko1@a...>
Date: Wed, 5 Dec 2018 13:01:58 +0900 (JST)
Subject: [ruby-changes:53990] mrkn:r66210 (trunk): Revert bigdecimal 1.4.0 related commits

mrkn	2018-12-05 13:01:53 +0900 (Wed, 05 Dec 2018)

  New Revision: 66210

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66210

  Log:
    Revert bigdecimal 1.4.0 related commits
    
    * Revert "Remove unnecessary linker flags"
    
      This reverts commit 49efa01579272d52d28bd361c498d96ca92e986e.
    
    * Revert "Move dependency on gemspec"
    
      This reverts commit bfb64d476578eadd61a738149726da37840f068d.
    
    * Revert "Remove unnecessary directory listing"
    
      This reverts commit 86661b5c60b8da6e5641c9c772b57857a1f988f4.
    
    * Revert "* expand tabs."
    
      This reverts commit 35ada33f8386b56611f10b1a0a4e5667e9b08071.
    
    * Revert "Import bigdecimal-1.4.0.pre-20181204a"
    
      This reverts commit 8891bb3bd602bdbabd24260cf1e431475dc027c8.
    
    * Revert "ext/bigdecimal/bigdecimal.c: drop unused function"
    
      This reverts commit 5ceeea4da1179193c2c7ddcebfd67019128473e3.
    
    * Revert "* expand tabs."
    
      This reverts commit e021386e905b6d6799a84dfbc2f0592e42626366.
    
    * Revert "Import bigdecimal-1.4.0.pre-20181130a"
    
      This reverts commit a0e438cd3c28d2eaf4efa18243d5b6edafa14d88.
    
    * Revert "NEWS: write about bigdecimal updates"
    
      This reverts commit 89455ff2ba973f2a9ee7b79657e0e6f1f31501f9.
    
    * Revert "Fix rubyspec of bigdecimal for ruby <2.6"
    
      This reverts commit 4bcdeeb65e57de4da306d347652898c767162e74.
    
    * Revert "Fix rubyspec against bigdecimal updates"
    
      This reverts commit c8fb30fc9e0ee14e87be1e231869a12aaef1eedf.

  Added files:
    trunk/spec/ruby/library/bigdecimal/ver_spec.rb
  Removed files:
    trunk/ext/bigdecimal/bigdecimal.def
    trunk/ext/bigdecimal/util/extconf.rb
    trunk/ext/bigdecimal/util/util.c
  Modified files:
    trunk/NEWS
    trunk/ext/bigdecimal/bigdecimal.c
    trunk/ext/bigdecimal/bigdecimal.gemspec
    trunk/ext/bigdecimal/bigdecimal.h
    trunk/ext/bigdecimal/depend
    trunk/ext/bigdecimal/extconf.rb
    trunk/ext/bigdecimal/lib/bigdecimal/jacobian.rb
    trunk/ext/bigdecimal/lib/bigdecimal/util.rb
    trunk/ext/bigdecimal/sample/linear.rb
    trunk/ext/bigdecimal/sample/nlsolve.rb
    trunk/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
    trunk/test/bigdecimal/test_bigdecimal.rb
    trunk/test/bigdecimal/test_bigdecimal_util.rb
Index: ext/bigdecimal/bigdecimal.def
===================================================================
--- ext/bigdecimal/bigdecimal.def	(revision 66209)
+++ ext/bigdecimal/bigdecimal.def	(nonexistent)
@@ -1,3 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.def#L0
-EXPORTS
-rmpd_util_str_to_d
-Init_bigdecimal

Property changes on: ext/bigdecimal/bigdecimal.def
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-LF
\ No newline at end of property
Index: ext/bigdecimal/util/util.c
===================================================================
--- ext/bigdecimal/util/util.c	(revision 66209)
+++ ext/bigdecimal/util/util.c	(nonexistent)
@@ -1,9 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/util/util.c#L0
-#include "ruby.h"
-
-RUBY_EXTERN VALUE rmpd_util_str_to_d(VALUE str);
-
-void
-Init_util(void)
-{
-  rb_define_method(rb_cString, "to_d", rmpd_util_str_to_d, 0);
-}

Property changes on: ext/bigdecimal/util/util.c
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-LF
\ No newline at end of property
Index: ext/bigdecimal/util/extconf.rb
===================================================================
--- ext/bigdecimal/util/extconf.rb	(revision 66209)
+++ ext/bigdecimal/util/extconf.rb	(nonexistent)
@@ -1,24 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/util/extconf.rb#L0
-# frozen_string_literal: false
-require 'mkmf'
-
-checking_for(checking_message("Windows")) do
-  case RUBY_PLATFORM
-  when /cygwin|mingw/
-    if defined?($extlist)
-      build_dir = "$(TARGET_SO_DIR)../"
-    else
-      base_dir = File.expand_path('../../../..', __FILE__)
-      build_dir = File.join(base_dir, "tmp", RUBY_PLATFORM, "bigdecimal", RUBY_VERSION, "")
-    end
-    $libs << " #{build_dir}bigdecimal.so"
-    true
-  when /mswin/
-    $DLDFLAGS << " -libpath:.."
-    $libs << " bigdecimal-$(arch).lib"
-    true
-  else
-    false
-  end
-end
-
-create_makefile('bigdecimal/util')

Property changes on: ext/bigdecimal/util/extconf.rb
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-LF
\ No newline at end of property
Index: ext/bigdecimal/depend
===================================================================
--- ext/bigdecimal/depend	(revision 66209)
+++ ext/bigdecimal/depend	(revision 66210)
@@ -1,5 +1,3 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/depend#L1
-extconf.h: $(srcdir)/$(GEMSPEC)
-
 # AUTOGENERATED DEPENDENCIES START
 bigdecimal.o: $(RUBY_EXTCONF_H)
 bigdecimal.o: $(arch_hdrdir)/ruby/config.h
Index: ext/bigdecimal/bigdecimal.c
===================================================================
--- ext/bigdecimal/bigdecimal.c	(revision 66209)
+++ ext/bigdecimal/bigdecimal.c	(revision 66210)
@@ -136,6 +136,24 @@ rb_rational_den(VALUE rat) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L136
 #define DoSomeOne(x,y,f) rb_num_coerce_bin(x,y,f)
 
 /*
+ * Returns the BigDecimal version number.
+ */
+static VALUE
+BigDecimal_version(VALUE self)
+{
+  /*
+   * 1.0.0: Ruby 1.8.0
+   * 1.0.1: Ruby 1.8.1
+   * 1.1.0: Ruby 1.9.3
+   */
+#ifndef RUBY_BIGDECIMAL_VERSION
+# error RUBY_BIGDECIMAL_VERSION is not defined
+#endif
+  rb_warning("BigDecimal.ver is deprecated; use BigDecimal::VERSION instead.");
+  return rb_str_new2(RUBY_BIGDECIMAL_VERSION);
+}
+
+/*
  *   VP routines used in BigDecimal part
  */
 static unsigned short VpGetException(void);
@@ -646,10 +664,9 @@ VP_EXPORT Real * https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L664
 VpNewRbClass(size_t mx, const char *str, VALUE klass)
 {
     VALUE obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, 0);
-    Real *pv = VpAlloc(mx, str, 1, 1);
+    Real *pv = VpAlloc(mx,str);
     RTYPEDDATA_DATA(obj) = pv;
     pv->obj = obj;
-    RB_OBJ_FREEZE(obj);
     return pv;
 }
 
@@ -2148,10 +2165,15 @@ BigDecimal_exponent(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2165
     return INT2NUM(e);
 }
 
-/* Returns a string representation of self.
+/* Returns debugging information about the value as a string of comma-separated
+ * values in angle brackets with a leading #:
  *
  *   BigDecimal("1234.5678").inspect
  *     #=> "0.12345678e4"
+ *
+ * The first part is the address, the second is the value as a string, and
+ * the final part ss(mm) is the current number of significant digits and the
+ * maximum number of significant digits, respectively.
  */
 static VALUE
 BigDecimal_inspect(VALUE self)
@@ -2313,7 +2335,7 @@ BigDecimal_power(int argc, VALUE*argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2335
     n = NIL_P(prec) ? (ssize_t)(x->Prec*VpBaseFig()) : NUM2SSIZET(prec);
 
     if (VpIsNaN(x)) {
-        y = VpCreateRbObject(n, "0");
+	y = VpCreateRbObject(n, "0#");
 	RB_GC_GUARD(y->obj);
 	VpSetNaN(y);
 	return ToValue(y);
@@ -2437,7 +2459,7 @@ BigDecimal_power(int argc, VALUE*argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2459
 	    }
 	}
 	else {
-            y = VpCreateRbObject(n, "0");
+	    y = VpCreateRbObject(n, "0#");
 	    if (BIGDECIMAL_NEGATIVE_P(x)) {
 		if (is_integer(vexp)) {
 		    if (is_even(vexp)) {
@@ -2470,7 +2492,7 @@ BigDecimal_power(int argc, VALUE*argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2492
 	}
 	else if (RTEST(rb_funcall(abs_value, '<', 1, INT2FIX(1)))) {
 	    if (is_negative(vexp)) {
-                y = VpCreateRbObject(n, "0");
+		y = VpCreateRbObject(n, "0#");
 		if (is_even(vexp)) {
 		    VpSetInf(y, VpGetSign(x));
 		}
@@ -2488,7 +2510,7 @@ BigDecimal_power(int argc, VALUE*argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2510
 	}
 	else {
 	    if (is_positive(vexp)) {
-                y = VpCreateRbObject(n, "0");
+		y = VpCreateRbObject(n, "0#");
 		if (is_even(vexp)) {
 		    VpSetInf(y, VpGetSign(x));
 		}
@@ -2538,6 +2560,72 @@ BigDecimal_power_op(VALUE self, VALUE ex https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2560
     return BigDecimal_power(1, &exp, self);
 }
 
+static VALUE
+BigDecimal_s_allocate(VALUE klass)
+{
+    return VpNewRbClass(0, NULL, klass)->obj;
+}
+
+static Real *BigDecimal_new(int argc, VALUE *argv);
+
+/* call-seq:
+ *   new(initial, digits)
+ *
+ * Create a new BigDecimal object.
+ *
+ * initial:: The initial value, as an Integer, a Float, a Rational,
+ *           a BigDecimal, or a String.
+ *
+ *           If it is a String, spaces are ignored and unrecognized characters
+ *           terminate the value.
+ *
+ * digits:: The number of significant digits, as an Integer. If omitted or 0,
+ *          the number of significant digits is determined from the initial
+ *          value.
+ *
+ * The actual number of significant digits used in computation is usually
+ * larger than the specified number.
+ *
+ * ==== Exceptions
+ *
+ * TypeError:: If the +initial+ type is neither Integer, Float,
+ *             Rational, nor BigDecimal, this exception is raised.
+ *
+ * TypeError:: If the +digits+ is not an Integer, this exception is raised.
+ *
+ * ArgumentError:: If +initial+ is a Float, and the +digits+ is larger than
+ *                 Float::DIG + 1, this exception is raised.
+ *
+ * ArgumentError:: If the +initial+ is a Float or Rational, and the +digits+
+ *                 value is omitted, this exception is raised.
+ */
+static VALUE
+BigDecimal_s_new(int argc, VALUE *argv, VALUE self)
+{
+  rb_warning("BigDecimal.new is deprecated; use Kernel.BigDecimal method instead.");
+  return rb_call_super(argc, argv);
+}
+
+static VALUE
+BigDecimal_initialize(int argc, VALUE *argv, VALUE self)
+{
+    ENTER(1);
+    Real *pv = rb_check_typeddata(self, &BigDecimal_data_type);
+    Real *x;
+
+    GUARD_OBJ(x, BigDecimal_new(argc, argv));
+    if (ToValue(x)) {
+	pv = VpCopy(pv, x);
+    }
+    else {
+	VpFree(pv);
+	pv = x;
+    }
+    DATA_PTR(self) = pv;
+    pv->obj = self;
+    return self;
+}
+
 /* :nodoc:
  *
  * private method for dup and clone the provided BigDecimal +other+
@@ -2560,60 +2648,19 @@ BigDecimal_clone(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2648
   return self;
 }
 
-static int
-opts_exception_p(VALUE opts)
-{
-    static ID kwds[1];
-    VALUE exception;
-    if (!kwds[0]) {
-        kwds[0] = rb_intern_const("exception");
-    }
-    rb_get_kwargs(opts, kwds, 0, 1, &exception);
-    return exception != Qfalse;
-}
-
 static Real *
 BigDecimal_new(int argc, VALUE *argv)
 {
     size_t mf;
-    VALUE  opts = Qnil;
     VALUE  nFig;
     VALUE  iniValue;
     double d;
-    int    exc;
 
-    argc = rb_scan_args(argc, argv, "11:", &iniValue, &nFig, &opts);
-    exc = opts_exception_p(opts);
-
-    if (argc == 1) {
+    if (rb_scan_args(argc, argv, "11", &iniValue, &nFig) == 1) {
         mf = 0;
     }
     else {
-        /* expand GetPrecisionInt for exception suppression */
-        ssize_t n = NUM2INT(nFig);
-        if (n < 0) {
-            if (!exc) {
-                return NULL;
-            }
-            rb_raise(rb_eArgError, "negative precision");
-        }
-        mf = (size_t)n;
-    }
-
-    if (SPECIAL_CONST_P(iniValue)) {
-        switch (iniValue) {
-          case Qnil:
-            if (!exc) return NULL;
-            rb_raise(rb_eTypeError, "can't convert nil into BigDecimal");
-          case Qtrue:
-            if (!exc) return NULL;
-            rb_raise(rb_eTypeError, "can't convert true into BigDecimal");
-          case Qfalse:
-            if (!exc) return NULL;
-            rb_raise(rb_eTypeError, "can't convert false into BigDecimal");
-          default:
-            break;
-        }
+        mf = GetPrecisionInt(nFig);
     }
 
     switch (TYPE(iniValue)) {
@@ -2636,17 +2683,11 @@ BigDecimal_new(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2683
             return pv;
         }
 	if (mf > DBL_DIG+1) {
-            if (!exc) {
-                return NULL;
-            }
 	    rb_raise(rb_eArgError, "precision too large.");
 	}
 	/* fall through */
       case T_RATIONAL:
 	if (NIL_P(nFig)) {
-            if (!exc) {
-                return NULL;
-            }
 	    rb_raise(rb_eArgError,
 		     "can't omit precision for a %"PRIsVALUE".",
 		     RB_OBJ_CLASSNAME(iniValue));
@@ -2658,60 +2699,22 @@ BigDecimal_new(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2699
       default:
 	break;
     }
-    /* TODO: support to_d */
-    if (!exc) {
-        iniValue = rb_check_convert_type(iniValue, T_STRING, "String", "to_str");
-        if (NIL_P(iniValue)) return NULL;
-    }
     StringValueCStr(iniValue);
-    return VpAlloc(mf, RSTRING_PTR(iniValue), 1, exc);
+    return VpAlloc(mf, RSTRING_PTR(iniValue));
 }
 
-/* call-seq:
- *   BigDecimal(initial, digits)
- *
- * Create a new BigDecimal object.
- *
- * initial:: The initial value, as an Integer, a Float, a Rational,
- *           a BigDecimal, or a String.
- *
- *           If it is a String, spaces are ignored and unrecognized characters
- *           terminate the value.
- *
- * digits:: The number of significant digits, as an Integer. If omitted or 0,
- *          the number of significant digits is determined from the initial
- *          value.
- *
- * The actual number of significant digits used in computation is usually
- * larger than the specified number.
- *
- * ==== Exceptions
- *
- * TypeError:: If the +initial+ type is neither Integer, Float,
- *             Rational, nor BigDecimal, this exception is raised.
- *
- * TypeError:: If the +digits+ is not an Integer, this exception is raised.
- *
- * ArgumentError:: If +initial+ is a Float, and the +digits+ is larger than
- *                 Float::DIG + 1, this exception is raised.
- *
- * ArgumentError:: If the +initial+ is a Float or Rational, and the +digits+
- *                 value is omitted, this exception is raised.
- */
+/* See also BigDecimal.new */
 static VALUE
-f_BigDecimal(int argc, VALUE *argv, VALUE self)
+BigDecimal_global_new(int argc, VALUE *argv, VALUE self)
 {
     ENTER(1);
     Real *pv;
     VALUE obj;
 
     obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, 0);
-    pv = BigDecimal_new(argc, argv);
-    if (pv == NULL) return Qnil;
-    SAVE(pv);
+    GUARD_OBJ(pv, BigDecimal_new(argc, argv));
     if (ToValue(pv)) pv = VpCopy(NULL, pv);
     RTYPEDDATA_DATA(obj) = pv;
-    RB_OBJ_FREEZE(obj);
     return pv->obj = obj;
 }
 
@@ -3135,21 +3138,6 @@ get_vp_value: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3138
     return y;
 }
 
-VALUE
-rmpd_util_str_to_d(VALUE str)
-{
-  ENTER(1);
-  char const *c_str;
-  Real *pv;
-  VALUE obj;
-
-  c_str = StringValueCStr(str);
-  GUARD_OBJ(pv, VpAlloc(0, c_str, 0, 1));
-  obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, pv);
-  RB_OBJ_FREEZE(obj);
-  return obj;
-}
-
 /* Document-class: BigDecimal
  * BigDecimal provides arbitrary-precision floating point decimal arithmetic.
  *
@@ -3289,17 +3277,18 @@ Init_bigdecimal(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3277
 
     /* Class and method registration */
     rb_cBigDecimal = rb_define_class("BigDecimal", rb_cNumeric);
+    rb_define_alloc_func(rb_cBigDecimal, BigDecimal_s_allocate);
 
     /* Global function */
-    rb_define_global_function("BigDecimal", f_BigDecimal, -1);
+    rb_define_global_function("BigDecimal", BigDecimal_global_new, -1);
 
     /* Class methods */
-    rb_undef_method(CLASS_OF(rb_cBigDecimal), "allocate");
-    rb_undef_method(CLASS_OF(rb_cBigDecimal), "new");
+    rb_define_singleton_method(rb_cBigDecimal, "new", BigDecimal_s_new, -1);
     rb_define_singleton_method(rb_cBigDecimal, "mode", BigDecimal_mode, -1);
     rb_define_singleton_method(rb_cBigDecimal, "limit", BigDecimal_limit, -1);
     rb_define_singleton_method(rb_cBigDecimal, "double_fig", BigDecimal_double_fig, 0);
     rb_define_singleton_method(rb_cBigDecimal, "_load", BigDecimal_load, 1);
+    rb_define_singleton_method(rb_cBigDecimal, "ver", BigDecimal_version, 0);
 
     rb_define_singleton_method(rb_cBigDecimal, "save_exception_mode", BigDecimal_save_exception_mode, 0);
     rb_define_singleton_method(rb_cBigDecimal, "save_rounding_mode", BigDecimal_save_rounding_mode, 0);
@@ -3419,13 +3408,14 @@ Init_bigdecimal(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3408
 
     arg = rb_str_new2("+Infinity");
     /* Positive infinity value. */
-    rb_define_const(rb_cBigDecimal, "INFINITY", f_BigDecimal(1, &arg, rb_cBigDecimal));
+    rb_define_const(rb_cBigDecimal, "INFINITY", BigDecimal_global_new(1, &arg, rb_cBigDecimal));
     arg = rb_str_new2("NaN");
     /* 'Not a Number' value. */
-    rb_define_const(rb_cBigDecimal, "NAN", f_BigDecimal(1, &arg, rb_cBigDecimal));
+    rb_define_const(rb_cBigDecimal, "NAN", BigDecimal_global_new(1, &arg, rb_cBigDecimal));
 
 
     /* instance methods */
+    rb_define_method(rb_cBigDecimal, "initialize", BigDecimal_initialize, -1);
     rb_define_method(rb_cBigDecimal, "initialize_copy", BigDecimal_initialize_copy, 1);
     rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0);
 
@@ -3724,7 +3714,13 @@ VpSetRoundMode(unsigned short n) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3714
  *    (to let the compiler know they may be changed in outside
  *    (... but not actually..)).
  */
+volatile const double gZero_ABCED9B1_CE73__00400511F31D = 0.0;
 volatile const double gOne_ABCED9B4_CE73__00400511F31D  = 1.0;
+static double
+Zero(void)
+{
+    return gZero_ABCED9B1_CE73__00400511F31D;
+}
 
 static double
 One(void)
@@ -3749,19 +3745,25 @@ One(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3745
 VP_EXPORT double
 VpGetDoubleNaN(void) /* Returns the value of NaN */
 {
-    return nan("");
+    static double fNaN = 0.0;
+    if (fNaN == 0.0) fNaN = Zero()/Zero();
+    return fNaN;
 }
 
 VP_EXPORT double
 VpGetDoublePosInf(void) /* Returns the value of +Infinity */
 {
-    return HUGE_VAL;
+    static double fInf = 0.0;
+    if (fInf == 0.0) fInf = One()/Zero();
+    return fInf;
 }
 
 VP_EXPORT double
 VpGetDoubleNegInf(void) /* Returns the value of -Infinity */
 {
-    return -HUGE_VAL;
+    static double fInf = 0.0;
+    if (fInf == 0.0) fInf = -(One()/Zero());
+    return fInf;
 }
 
 VP_EXPORT double
@@ -3962,8 +3964,8 @@ VpInit(BDIGIT BaseVal) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3964
     VpGetDoubleNegZero();
 
     /* Allocates Vp constants. */
-    VpConstOne = VpAlloc(1UL, "1", 1, 1);
-    VpPt5 = VpAlloc(1UL, ".5", 1, 1);
+    VpConstOne = VpAlloc(1UL, "1");
+    VpPt5 = VpAlloc(1UL, ".5");
 
 #ifdef BIGDECIMAL_DEBUG
     gnAlloc = 0;
@@ -4027,52 +4029,6 @@ overflow: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4029
     return VpException(VP_EXCEPTION_OVERFLOW, "Exponent overflow", 0);
 }
 
-Real *
-rmpd_parse_special_string(const char *str)
-{
-    static const struct {
-        const char *str;
-        size_t len;
-        int sign;
-    } table[] = {
-        { SZ_INF,  sizeof(SZ_INF)  - 1, VP_SIGN_POSITIVE_INFINITE },
-        { SZ_PINF, sizeof(SZ_PINF) - 1, VP_SIGN_POSITIVE_INFINITE },
-        { SZ_NINF, sizeof(SZ_NINF) - 1, VP_SIGN_NEGATIVE_INFINITE },
-        { SZ_NaN,  sizeof(SZ_NaN)  - 1, VP_SIGN_NaN               }
-    };
-    static const size_t table_length = sizeof(table) / sizeof(table[0]);
-    size_t i;
-
-    for (i = 0; i < table_length; ++i) {
-        const char *p;
-        if (strncmp(str, table[i].str, table[i].len) != 0) {
-            continue;
-        }
-
-        p = str + table[i].len;
-        while (*p && ISSPACE(*p)) ++p;
-        if (*p == '\0') {
-            Real *vp = VpAllocReal(1);
-            vp->MaxPrec = 1;
-            switch (table[i].sign) {
-              default:
-                UNREACHABLE; break;
-              case VP_SIGN_POSITIVE_INFINITE:
-                VpSetPosInf(vp);
-                return vp;
-              case VP_SIGN_NEGATIVE_INFINITE:
-                VpSetNegInf(vp);
-                return vp;
-              case VP_SIGN_NaN:
-                VpSetNaN(vp);
-                return vp;
-            }
-        }
-    }
-
-    return NULL;
-}
-
 /*
  * Allocates variable.
  * [Input]
@@ -4087,10 +4043,10 @@ rmpd_parse_special_string(const char *st https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4043
  *   NULL be returned if memory allocation is failed,or any error.
  */
 VP_EXPORT Real *
-VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
+VpAlloc(size_t mx, const char *szVal)
 {
     const char *orig_szVal = szVal;
-    size_t i, j, ni, ipf, nf, ipe, ne, dot_seen, exp_seen, nalloc;
+    size_t i, ni, ipn, ipf, nf, ipe, ne, dot_seen, exp_seen, nalloc;
     char v, *psz;
     int  sign=1;
     Real *vp = NULL;
@@ -4101,10 +4057,7 @@ VpAlloc(size_t mx, const char *szVal, in https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4057
     if (mx == 0) ++mx;
 
     if (szVal) {
-        /* Skipping leading spaces */
         while (ISSPACE(*szVal)) szVal++;
-
-        /* Processing the leading one `#` */
         if (*szVal != '#') {
             if (mf) {
                 mf = (mf + BASE_FIG - 1) / BASE_FIG + 2; /* Needs 1 more for div */
@@ -4118,7 +4071,6 @@ VpAlloc(size_t mx, const char *szVal, in https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4071
         }
     }
     else {
-      return_zero:
         /* necessary to be able to store */
         /* at least mx digits. */
         /* szVal==NULL ==> allocate zero value. */
@@ -4129,168 +4081,105 @@ VpAlloc(size_t mx, const char *szVal, in https://github.com/ruby/ruby/blob/trunk/ext/bi (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]