aboutsummaryrefslogtreecommitdiff
path: root/luaconf.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-06-18 11:26:05 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-06-18 11:26:05 -0300
commit19eb6ae5801a6e3c57031065c104f91de7f2c5e8 (patch)
tree0aa166d1cc94ea0093486f7b0f4223e16b8cf74e /luaconf.h
parentcbe05b48bbfe98b0aac3947a877a4d493f80ab63 (diff)
downloadlua-19eb6ae5801a6e3c57031065c104f91de7f2c5e8.tar.gz
lua-19eb6ae5801a6e3c57031065c104f91de7f2c5e8.tar.bz2
lua-19eb6ae5801a6e3c57031065c104f91de7f2c5e8.zip
using 'snprintf' in C99 (both for documentation of buffer sizes
and some complains from tools)
Diffstat (limited to 'luaconf.h')
-rw-r--r--luaconf.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/luaconf.h b/luaconf.h
index 5d8ce755..63000f08 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.250 2015/04/03 18:41:57 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.251 2015/05/20 17:39:23 roberto Exp roberto $
3** Configuration file for Lua 3** Configuration file for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -145,7 +145,7 @@
145 145
146#if !defined(LUA_FLOAT_TYPE) 146#if !defined(LUA_FLOAT_TYPE)
147#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE 147#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
148#endif /* } */ 148#endif
149 149
150/* }================================================================== */ 150/* }================================================================== */
151 151
@@ -470,7 +470,7 @@
470 470
471#define l_floor(x) (l_mathop(floor)(x)) 471#define l_floor(x) (l_mathop(floor)(x))
472 472
473#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) 473#define lua_number2str(s,sz,n) l_sprintf((s), sz, LUA_NUMBER_FMT, (n))
474 474
475 475
476/* 476/*
@@ -506,7 +506,7 @@
506/* The following definitions are good for most cases here */ 506/* The following definitions are good for most cases here */
507 507
508#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" 508#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
509#define lua_integer2str(s,n) sprintf((s), LUA_INTEGER_FMT, (n)) 509#define lua_integer2str(s,sz,n) l_sprintf((s), sz, LUA_INTEGER_FMT, (n))
510 510
511#define LUAI_UACINT LUA_INTEGER 511#define LUAI_UACINT LUA_INTEGER
512 512
@@ -578,13 +578,24 @@
578*/ 578*/
579 579
580/* 580/*
581@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89.
582** (All uses in Lua have only one format item.)
583*/
584#if !defined(LUA_USE_C89)
585#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i)
586#else
587#define l_sprintf(s,sz,f,i) sprintf(s,f,i)
588#endif
589
590
591/*
581@@ lua_strx2number converts an hexadecimal numeric string to a number. 592@@ lua_strx2number converts an hexadecimal numeric string to a number.
582** In C99, 'strtod' does that conversion. Otherwise, you can 593** In C99, 'strtod' does that conversion. Otherwise, you can
583** leave 'lua_strx2number' undefined and Lua will provide its own 594** leave 'lua_strx2number' undefined and Lua will provide its own
584** implementation. 595** implementation.
585*/ 596*/
586#if !defined(LUA_USE_C89) 597#if !defined(LUA_USE_C89)
587#define lua_strx2number(s,p) lua_str2number(s,p) 598#define lua_strx2number(s,p) lua_str2number(s,p)
588#endif 599#endif
589 600
590 601
@@ -595,7 +606,7 @@
595** provide its own implementation. 606** provide its own implementation.
596*/ 607*/
597#if !defined(LUA_USE_C89) 608#if !defined(LUA_USE_C89)
598#define lua_number2strx(L,b,f,n) sprintf(b,f,n) 609#define lua_number2strx(L,b,sz,f,n) l_sprintf(b,sz,f,n)
599#endif 610#endif
600 611
601 612