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

ruby-changes:10972

From: yugui <ko1@a...>
Date: Sun, 22 Feb 2009 23:05:36 +0900 (JST)
Subject: [ruby-changes:10972] Ruby:r22550 (ruby_1_9_1): merges r22471 from trunk into ruby_1_9_1.

yugui	2009-02-22 23:05:23 +0900 (Sun, 22 Feb 2009)

  New Revision: 22550

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22550

  Log:
    merges r22471 from trunk into ruby_1_9_1.
    * util.c (rv_alloc, freedtoa): use our normal xmalloc()/xfree() because
      couldn't free the returned pointer from ruby_dtoa().
    * missing/vsnprintf.c (cvt): receive buffer and use/return it instead
      of returning the pointer returned from BSD__dtoa().
    
    * missing/vsnprintf.c (BSD_vfprintf): pass buf to cvt() as the buffer.
      [ruby-core:22184]

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/missing/vsnprintf.c
    branches/ruby_1_9_1/util.c

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 22549)
+++ ruby_1_9_1/ChangeLog	(revision 22550)
@@ -1,3 +1,14 @@
+Fri Feb 20 23:28:11 2009  NAKAMURA Usaku  <usa@r...>
+
+	* util.c (rv_alloc, freedtoa): use our normal xmalloc()/xfree() because
+	  couldn't free the returned pointer from ruby_dtoa().
+
+	* missing/vsnprintf.c (cvt): receive buffer and use/return it instead
+	  of returning the pointer returned from BSD__dtoa().
+
+	* missing/vsnprintf.c (BSD_vfprintf): pass buf to cvt() as the buffer.
+	  [ruby-core:22184]
+
 Thu Feb 19 15:39:50 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/openssl/ossl_ocsp.c (ossl_ocspbres_verify): OCSP_basic_verify
Index: ruby_1_9_1/util.c
===================================================================
--- ruby_1_9_1/util.c	(revision 22549)
+++ ruby_1_9_1/util.c	(revision 22550)
@@ -3058,20 +3058,11 @@
 static char *
 rv_alloc(int i)
 {
-    int j, k, *r;
-
-    j = sizeof(ULong);
-    for (k = 0;
-            sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i;
-            j <<= 1)
-        k++;
-    r = (int*)Balloc(k);
-    *r = k;
     return
 #ifndef MULTIPLE_THREADS
         dtoa_result =
 #endif
-        (char *)(r+1);
+        xmalloc(i);
 }
 
 static char *
@@ -3096,9 +3087,7 @@
 static void
 freedtoa(char *s)
 {
-    Bigint *b = (Bigint *)((int *)s - 1);
-    b->maxwds = 1 << (b->k = *(int*)b);
-    Bfree(b);
+    xfree(s);
 }
 #endif
 
Index: ruby_1_9_1/missing/vsnprintf.c
===================================================================
--- ruby_1_9_1/missing/vsnprintf.c	(revision 22549)
+++ ruby_1_9_1/missing/vsnprintf.c	(revision 22550)
@@ -494,7 +494,7 @@
 #define	BUF		(MAXEXP+MAXFRACT+1)	/* + decimal point */
 #define	DEFPREC		6
 
-static char *cvt __P((double, int, int, char *, int *, int, int *));
+static char *cvt __P((double, int, int, char *, int *, int, int *, char *));
 static int exponent __P((char *, int, int));
 
 #else /* no FLOATING_POINT */
@@ -783,7 +783,7 @@
 			}
 			flags |= FPT;
 			cp = cvt(_double, prec, flags, &softsign,
-				&expt, ch, &ndig);
+				&expt, ch, &ndig, buf);
 			if (ch == 'g' || ch == 'G') {
 				if (expt <= -4 || (expt > prec && expt > 1))
 					ch = (ch == 'g') ? 'e' : 'E';
@@ -1076,10 +1076,10 @@
 extern char *BSD__dtoa __P((double, int, int, int *, int *, char **));
 
 static char *
-cvt(value, ndigits, flags, sign, decpt, ch, length)
+cvt(value, ndigits, flags, sign, decpt, ch, length, buf)
 	double value;
 	int ndigits, flags, *decpt, ch, *length;
-	char *sign;
+	char *sign, *buf;
 {
 	int mode, dsgn;
 	char *digits, *bp, *rve;
@@ -1098,6 +1098,10 @@
 	    *sign = '\000';
 	}
 	digits = BSD__dtoa(value, mode, ndigits, decpt, &dsgn, &rve);
+	memcpy(buf, digits, rve - digits);
+	xfree(digits);
+	rve = buf + (rve - digits);
+	digits = buf;
 	if (flags & ALT) {	/* Print trailing zeros */
 		bp = digits + ndigits;
 		if (ch == 'f') {

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

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