diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-30 11:42:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-30 11:42:44 -0300 |
commit | d86170662017645cf22884641f33a9d6b48d16e6 (patch) | |
tree | 80782cb7bfc8c31a0f6068f99ff47c0ca705b591 /lvm.h | |
parent | 34ac039fb84e3c12fb8c96c9c99c34224c09872b (diff) | |
download | lua-d86170662017645cf22884641f33a9d6b48d16e6.tar.gz lua-d86170662017645cf22884641f33a9d6b48d16e6.tar.bz2 lua-d86170662017645cf22884641f33a9d6b48d16e6.zip |
new macro 'cvt2num' to better control whether strings are convertible
to numbers
Diffstat (limited to 'lvm.h')
-rw-r--r-- | lvm.h | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.h,v 2.31 2014/05/26 17:10:22 roberto Exp roberto $ | 2 | ** $Id: lvm.h,v 2.32 2014/07/30 14:00:14 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -13,6 +13,20 @@ | |||
13 | #include "ltm.h" | 13 | #include "ltm.h" |
14 | 14 | ||
15 | 15 | ||
16 | #if !defined(LUA_NOCVTN2S) | ||
17 | #define cvt2str(o) ttisnumber(o) | ||
18 | #else | ||
19 | #define cvt2str(o) 0 /* no convertion from numbers to strings */ | ||
20 | #endif | ||
21 | |||
22 | |||
23 | #if !defined(LUA_NOCVTS2N) | ||
24 | #define cvt2num(o) ttisstring(o) | ||
25 | #else | ||
26 | #define cvt2num(o) 0 /* no convertion from strings to numbers */ | ||
27 | #endif | ||
28 | |||
29 | |||
16 | #define tonumber(o,n) \ | 30 | #define tonumber(o,n) \ |
17 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) | 31 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) |
18 | 32 | ||
@@ -24,13 +38,6 @@ | |||
24 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) | 38 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) |
25 | 39 | ||
26 | 40 | ||
27 | #if !defined(LUA_NOCVTN2S) | ||
28 | #define cvt2str(o) ttisnumber(o) | ||
29 | #else | ||
30 | #define cvt2str(o) 0 /* no convertion from numbers to strings */ | ||
31 | #endif | ||
32 | |||
33 | |||
34 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); | 41 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); |
35 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); | 42 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); |
36 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); | 43 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); |