dtoa.c: make compilable independently

Except for `-Dxmalloc=malloc -Dxfree=free`.
This commit is contained in:
Nobuyoshi Nakada 2021-01-10 15:46:23 +09:00
Родитель 01aa036023
Коммит 63abb5c227
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7CD2805BFA3770C6
1 изменённых файлов: 18 добавлений и 6 удалений

Просмотреть файл

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