mirror of
https://github.com/lua/lua
synced 2024-12-26 20:29:43 +03:00
new macro to control format for `read"*n"'
This commit is contained in:
parent
37f3a1c045
commit
61a036eaa5
4
liolib.c
4
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;
|
||||
}
|
||||
|
14
lua.h
14
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 */
|
||||
#ifndef LUA_NUMBER_FMT
|
||||
#define LUA_NUMBER_FMT "%.16g"
|
||||
/*
|
||||
** formats for Lua numbers
|
||||
*/
|
||||
#ifndef LUA_SCAN_NUMBER
|
||||
#define LUA_SCAN_NUMBER "%lf"
|
||||
#endif
|
||||
#ifndef LUA_NUMBER_FMT
|
||||
#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
|
||||
|
Loading…
Reference in New Issue
Block a user