commit 61a036eaa5918bdf5d7f01443b43288030337d20
parent 37f3a1c0452439bce1f5c2069ca015af148bf62f
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 28 Jun 2001 11:45:22 -0300
new macro to control format for `read"*n"'
Diffstat:
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/liolib.c b/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 1.115 2001/06/08 16:48:32 roberto Exp roberto $
+** $Id: liolib.c,v 1.116 2001/06/22 13:49:42 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -263,7 +263,7 @@ static int read_until (lua_State *L, FILE *f, const l_char *p, int pl) {
static int read_number (lua_State *L, FILE *f) {
double d;
- if (fscanf(f, l_s("%lf"), &d) == 1) {
+ if (fscanf(f, l_s(LUA_SCAN_NUMBER), &d) == 1) {
lua_pushnumber(L, d);
return 1;
}
diff --git a/lua.h b/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.97 2001/04/23 16:35:45 roberto Exp roberto $
+** $Id: lua.h,v 1.98 2001/06/06 18:00:19 roberto Exp roberto $
** Lua - An Extensible Extension Language
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
** e-mail: info@lua.org
@@ -292,10 +292,16 @@ LUA_API void lua_pushusertag (lua_State *L, void *u, int tag);
#define l_charint int
#endif
-/* function to convert a lua_Number to a string */
+/*
+** formats for Lua numbers
+*/
+#ifndef LUA_SCAN_NUMBER
+#define LUA_SCAN_NUMBER "%lf"
+#endif
#ifndef LUA_NUMBER_FMT
-#define LUA_NUMBER_FMT "%.16g"
+#define LUA_NUMBER_FMT "%.16g"
#endif
+/* function to convert a lua_Number to a string */
#ifndef lua_number2str
#define lua_number2str(s,n) sprintf((s), l_s(LUA_NUMBER_FMT), (n))
#endif