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

ruby-changes:64815

From: Nobuyoshi <ko1@a...>
Date: Sun, 10 Jan 2021 16:30:24 +0900 (JST)
Subject: [ruby-changes:64815] 63abb5c227 (master): dtoa.c: make compilable independently

https://git.ruby-lang.org/ruby.git/commit/?id=63abb5c227

From 63abb5c227e5c20d18d0debf699251da93ca64b5 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 10 Jan 2021 15:46:23 +0900
Subject: dtoa.c: make compilable independently

Except for `-Dxmalloc=malloc -Dxfree=free`.

diff --git a/missing/dtoa.c b/missing/dtoa.c
index cbee13e..6d91087 100644
--- a/missing/dtoa.c
+++ b/missing/dtoa.c
@@ -183,12 +183,16 @@ https://github.com/ruby/ruby/blob/trunk/missing/dtoa.c#L183
 #undef Long
 #undef ULong
 
-#if SIZEOF_INT == 4
+#include <limits.h>
+
+#if (INT_MAX >> 30) && !(INT_MAX >> 31)
 #define Long int
 #define ULong unsigned int
-#elif SIZEOF_LONG == 4
+#elif (LONG_MAX >> 30) && !(LONG_MAX >> 31)
 #define Long long int
 #define ULong unsigned long int
+#else
+#error No 32bit integer
 #endif
 
 #if HAVE_LONG_LONG
@@ -202,6 +206,11 @@ https://github.com/ruby/ruby/blob/trunk/missing/dtoa.c#L206
 #define Bug(x) {fprintf(stderr, "%s\n", (x)); exit(EXIT_FAILURE);}
 #endif
 
+#ifndef ISDIGIT
+#include <ctype.h>
+#define ISDIGIT(c) isdigit(c)
+#endif
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -219,6 +228,9 @@ extern void FREE(void*); https://github.com/ruby/ruby/blob/trunk/missing/dtoa.c#L228
 #else
 #define FREE xfree
 #endif
+#ifndef NO_SANITIZE
+#define NO_SANITIZE(x, y) y
+#endif
 
 #ifndef Omit_Private_Memory
 #ifndef PRIVATE_MEM
@@ -280,7 +292,7 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/missing/dtoa.c#L292
 #endif
 
 #ifndef hexdigit
-static const char hexdigits[] = "0123456789abcdef0123456789ABCDEF";
+static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
 #endif
 
 #if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + defined(IBM) != 1
@@ -2520,10 +2532,10 @@ static char *dtoa_result; https://github.com/ruby/ruby/blob/trunk/missing/dtoa.c#L2532
 static char *
 rv_alloc(int i)
 {
-    return dtoa_result = xmalloc(i);
+    return dtoa_result = MALLOC(i);
 }
 #else
-#define rv_alloc(i) xmalloc(i)
+#define rv_alloc(i) MALLOC(i)
 #endif
 
 static char *
@@ -2550,7 +2562,7 @@ nrv_alloc(const char *s, char **rve, size_t n) https://github.com/ruby/ruby/blob/trunk/missing/dtoa.c#L2562
 static void
 freedtoa(char *s)
 {
-    xfree(s);
+    FREE(s);
 }
 #endif
 
-- 
cgit v0.10.2


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

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