Browse Source

LUA_SMALL_* changed to LUA_*SIZE + added support for long double + better

support for ANSI systems
pull/9/head
Roberto Ierusalimschy 12 years ago
parent
commit
2b4975dca7
  1. 64
      luaconf.h

64
luaconf.h

@ -1,5 +1,5 @@
/* /*
** $Id: luaconf.h,v 1.183 2013/06/20 15:02:49 roberto Exp roberto $ ** $Id: luaconf.h,v 1.184 2013/06/21 17:42:28 roberto Exp roberto $
** Configuration file for Lua ** Configuration file for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -384,11 +384,12 @@
*/ */
/* /*
@@ LUA_SMALL_INT true makes Lua use a 32-bit integer type @@ LUA_INTSIZE defines size for Lua integer: 1=int, 2=long, 3=long long
@@ LUA_SMALL_FLOAT true makes Lua use a 32-bit float type @@ LUA_FLOATSIZE defines size for Lua float: 1=float, 2=double, 3=long double
** Default is long long + double
*/ */
#define LUA_SMALL_FLOAT 0 #define LUA_INTSIZE 3
#define LUA_SMALL_INT 0 #define LUA_FLOATSIZE 2
/* /*
@ -405,14 +406,9 @@
@@ l_mathop allows the addition of an 'l' or 'f' to all math operations @@ l_mathop allows the addition of an 'l' or 'f' to all math operations
** **
@@ lua_str2number converts a decimal numeric string to a number. @@ lua_str2number converts a decimal numeric string to a number.
@@ lua_strx2number converts an hexadecimal numeric string to a number.
** In C99, 'strtod' does both conversions. C89, however, has no function
** to convert floating hexadecimal strings to numbers. For these
** systems, you can leave 'lua_strx2number' undefined and Lua will
** provide its own implementation.
*/ */
#if LUA_SMALL_FLOAT /* { */ #if LUA_FLOATSIZE == 1 /* { single float */
#define LUA_NUMBER float #define LUA_NUMBER float
@ -423,13 +419,26 @@
#define LUA_NUMBER_FMT "%.7g" #define LUA_NUMBER_FMT "%.7g"
#define l_mathop(op) op##f #define l_mathop(op) op##f
#define l_floor(x) (floorf(x))
#define lua_str2number(s,p) strtof((s), (p)) #define lua_str2number(s,p) strtof((s), (p))
#else /* }{ */
#define LUA_NUMBER_DOUBLE #elif LUA_FLOATSIZE == 3 /* }{ long double */
#define LUA_NUMBER long double
#define LUAI_UACNUMBER long double
#define LUA_NUMBER_FRMLEN "L"
#define LUA_NUMBER_SCAN "%Lf"
#define LUA_NUMBER_FMT "%.19Lg"
#define l_mathop(op) op##l
#define lua_str2number(s,p) strtold((s), (p))
#else /* }{ default: double */
#define LUA_NUMBER double #define LUA_NUMBER double
#define LUAI_UACNUMBER double #define LUAI_UACNUMBER double
@ -439,18 +448,28 @@
#define LUA_NUMBER_FMT "%.14g" #define LUA_NUMBER_FMT "%.14g"
#define l_mathop(op) op #define l_mathop(op) op
#define l_floor(x) (floor(x))
#define lua_str2number(s,p) strtod((s), (p)) #define lua_str2number(s,p) strtod((s), (p))
#endif /* } */ #endif /* } */
#if defined(LUA_USE_STRTODHEX) #if defined(LUA_ANSI)
#define lua_strx2number(s,p) lua_str2number(s,p) /* C89 does not support 'opf' variants for math functions */
#undef l_mathop
#define l_mathop(op) (lua_Number)op
#endif #endif
#if defined(LUA_ANSI) || defined(_WIN32)
/* C89 and Windows do not support 'strtof'... */
#undef lua_str2number
#define lua_str2number(s,p) ((lua_Number)strtod((s), (p)))
#endif
#define l_floor(x) (l_mathop(floor)(x))
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
@ -492,27 +511,24 @@
@@ lua_integer2str converts an integer to a string. @@ lua_integer2str converts an integer to a string.
*/ */
#if LUA_SMALL_INT /* { */ #if LUA_INTSIZE == 1 /* { int */
#if LUAI_BITSINT >= 32
#define LUA_INTEGER int #define LUA_INTEGER int
#define LUA_INTEGER_FRMLEN "" #define LUA_INTEGER_FRMLEN ""
#else #elif LUA_INTSIZE == 2 /* }{ long */
#define LUA_INTEGER long #define LUA_INTEGER long
#define LUA_INTEGER_FRMLEN "l" #define LUA_INTEGER_FRMLEN "l"
#endif #else /* }{ default: long long */
#else /* }{ */
#define LUA_INTEGER long long #define LUA_INTEGER long long
#define LUA_INTEGER_FRMLEN "ll" #define LUA_INTEGER_FRMLEN "ll"
#endif /* } */ #endif /* } */
#define LUA_INTEGER_SCAN "%" LUA_INTEGER_FRMLEN "d" #define LUA_INTEGER_SCAN "%" LUA_INTEGER_FRMLEN "d"
#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" #define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
#define lua_integer2str(s,n) sprintf((s), LUA_INTEGER_FMT, (n)) #define lua_integer2str(s,n) sprintf((s), LUA_INTEGER_FMT, (n))

Loading…
Cancel
Save