aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-05-20 14:39:23 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-05-20 14:39:23 -0300
commit99391e24ea25641b0cf419334229452cef9e8581 (patch)
tree6e7db5e57f3fabb4c03270d19e280a91969608ae /lstrlib.c
parent0ec12c1bd1ff5f42450703bdbd48f29a2d5e78f8 (diff)
downloadlua-99391e24ea25641b0cf419334229452cef9e8581.tar.gz
lua-99391e24ea25641b0cf419334229452cef9e8581.tar.bz2
lua-99391e24ea25641b0cf419334229452cef9e8581.zip
new configuration macro 'l_mathlim' (simplifies some dependencies
on float type)
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/lstrlib.c b/lstrlib.c
index fb6c54c2..ec9c7d20 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.227 2015/03/28 19:14:47 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.228 2015/04/03 18:41:57 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -11,6 +11,7 @@
11 11
12 12
13#include <ctype.h> 13#include <ctype.h>
14#include <float.h>
14#include <limits.h> 15#include <limits.h>
15#include <stddef.h> 16#include <stddef.h>
16#include <stdio.h> 17#include <stdio.h>
@@ -812,12 +813,10 @@ static int str_gsub (lua_State *L) {
812/* 813/*
813** Number of bits that goes into the first digit. It can be any value 814** Number of bits that goes into the first digit. It can be any value
814** between 1 and 4; the following definition tries to align the number 815** between 1 and 4; the following definition tries to align the number
815** to nibble boundaries. The default is 1 bit, that aligns double 816** to nibble boundaries by making what is left after that first digit a
816** (1+52-bit mantissa) and quad precision (1+112-bit mantissa). For 817** multiple of 4.
817** float (24-bit mantissa) and 80-bit long double (64-bit mantissa), 4
818** does the alignment.
819*/ 818*/
820#define L_NBFD ((sizeof(lua_Number) == 4 || sizeof(lua_Number) == 12) ? 4 : 1) 819#define L_NBFD ((l_mathlim(MANT_DIG) - 1)%4 + 1)
821 820
822 821
823/* 822/*
@@ -881,11 +880,9 @@ static int lua_number2strx (lua_State *L, char *buff, const char *fmt,
881/* 880/*
882** Maximum size of each formatted item. This maximum size is produced 881** Maximum size of each formatted item. This maximum size is produced
883** by format('%.99f', minfloat), and is equal to 99 + 2 ('-' and '.') + 882** by format('%.99f', minfloat), and is equal to 99 + 2 ('-' and '.') +
884** number of decimal digits to represent minfloat (which is ~308 for 883** number of decimal digits to represent minfloat.
885** a double and ~4932 for long double).
886*/ 884*/
887#define MAX_ITEM \ 885#define MAX_ITEM (120 + l_mathlim(MAX_10_EXP))
888 (sizeof(lua_Number) <= 4 ? 150 : sizeof(lua_Number) <= 8 ? 450 : 5050)
889 886
890 887
891/* valid flags in a format specification */ 888/* valid flags in a format specification */