diff options
author | Philipp Janda <siffiejoe@gmx.net> | 2016-01-22 15:58:48 +0100 |
---|---|---|
committer | Philipp Janda <siffiejoe@gmx.net> | 2016-01-22 15:58:48 +0100 |
commit | ca85188590e677edcc9290d29e69a3692187c826 (patch) | |
tree | 6223894654ff62468f1086423caf31f459e7861b /lprefix.h | |
parent | abf4ea9645ce3ff0c390a57ab3e3e4f82d9a4035 (diff) | |
download | lua-compat-5.3-ca85188590e677edcc9290d29e69a3692187c826.tar.gz lua-compat-5.3-ca85188590e677edcc9290d29e69a3692187c826.tar.bz2 lua-compat-5.3-ca85188590e677edcc9290d29e69a3692187c826.zip |
Update backports.
The backports of lstrlib.c, ltablib.c, and lutf8lib.c have been updated
to Lua version 5.3.2.
Diffstat (limited to 'lprefix.h')
-rw-r--r-- | lprefix.h | 58 |
1 files changed, 43 insertions, 15 deletions
@@ -48,6 +48,7 @@ | |||
48 | #undef LUAMOD_API | 48 | #undef LUAMOD_API |
49 | #define LUAMOD_API extern | 49 | #define LUAMOD_API extern |
50 | 50 | ||
51 | |||
51 | #ifdef lutf8lib_c | 52 | #ifdef lutf8lib_c |
52 | # define luaopen_utf8 luaopen_compat53_utf8 | 53 | # define luaopen_utf8 luaopen_compat53_utf8 |
53 | # include <stdarg.h> | 54 | # include <stdarg.h> |
@@ -81,24 +82,18 @@ static const char *compat53_utf8_escape (lua_State* L, ...) { | |||
81 | compat53_utf8_escape(L, l) | 82 | compat53_utf8_escape(L, l) |
82 | #endif | 83 | #endif |
83 | 84 | ||
85 | |||
84 | #ifdef ltablib_c | 86 | #ifdef ltablib_c |
85 | # define luaopen_table luaopen_compat53_table | 87 | # define luaopen_table luaopen_compat53_table |
86 | /* lua_rawgeti in compat53.h is implemented as a macro, so the | 88 | # ifndef LUA_MAXINTEGER |
87 | * function signature doesn't match when you use a function pointer | 89 | /* conservative estimate: */ |
88 | */ | 90 | # define LUA_MAXINTEGER INT_MAX |
89 | static int compat53_rawgeti (lua_State *L, int i, lua_Integer n) { | 91 | # endif |
90 | return lua_rawgeti(L, i, n); | ||
91 | } | ||
92 | # undef lua_rawgeti | ||
93 | # define lua_rawgeti compat53_rawgeti | ||
94 | static void compat53_rawseti (lua_State *L, int i, lua_Integer n) { | ||
95 | lua_rawseti(L, i, (int)n); | ||
96 | } | ||
97 | # undef lua_rawseti | ||
98 | # define lua_rawseti compat53_rawseti | ||
99 | #endif /* ltablib_c */ | 92 | #endif /* ltablib_c */ |
100 | 93 | ||
94 | |||
101 | #ifdef lstrlib_c | 95 | #ifdef lstrlib_c |
96 | #include <locale.h> | ||
102 | #include <lualib.h> | 97 | #include <lualib.h> |
103 | /* move the string library open function out of the way (we only take | 98 | /* move the string library open function out of the way (we only take |
104 | * the string packing functions)! | 99 | * the string packing functions)! |
@@ -112,8 +107,33 @@ static void compat53_rawseti (lua_State *L, int i, lua_Integer n) { | |||
112 | # if LUA_VERSION_NUM < 503 | 107 | # if LUA_VERSION_NUM < 503 |
113 | /* lstrlib assumes that lua_Integer and lua_Unsigned have the same | 108 | /* lstrlib assumes that lua_Integer and lua_Unsigned have the same |
114 | * size, so we use the unsigned equivalent of ptrdiff_t! */ | 109 | * size, so we use the unsigned equivalent of ptrdiff_t! */ |
115 | # define lua_Unsigned size_t | 110 | # define lua_Unsigned size_t |
116 | # endif | 111 | # endif |
112 | # ifndef l_mathlim | ||
113 | # ifdef LUA_NUMBER_DOUBLE | ||
114 | # define l_mathlim(n) (DBL_##n) | ||
115 | # else | ||
116 | # define l_mathlim(n) (FLT_##n) | ||
117 | # endif | ||
118 | # endif | ||
119 | # ifndef l_mathop | ||
120 | # ifdef LUA_NUMBER_DOUBLE | ||
121 | # define l_mathop(op) op | ||
122 | # else | ||
123 | # define l_mathop(op) op##f | ||
124 | # endif | ||
125 | # endif | ||
126 | # ifndef lua_getlocaledecpoint | ||
127 | # define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) | ||
128 | # endif | ||
129 | # ifndef l_sprintf | ||
130 | # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L | ||
131 | # define l_sprintf(s,sz,f,i) (snprintf(s, sz, f, i)) | ||
132 | # else | ||
133 | # define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s, f, i)) | ||
134 | # endif | ||
135 | # endif | ||
136 | |||
117 | static int str_pack (lua_State *L); | 137 | static int str_pack (lua_State *L); |
118 | static int str_packsize (lua_State *L); | 138 | static int str_packsize (lua_State *L); |
119 | static int str_unpack (lua_State *L); | 139 | static int str_unpack (lua_State *L); |
@@ -127,12 +147,20 @@ LUAMOD_API int luaopen_compat53_string (lua_State *L) { | |||
127 | luaL_newlib(L, funcs); | 147 | luaL_newlib(L, funcs); |
128 | return 1; | 148 | return 1; |
129 | } | 149 | } |
150 | /* fake CLANG feature detection on other compilers */ | ||
151 | # ifndef __has_attribute | ||
152 | # define __has_attribute(x) 0 | ||
153 | # endif | ||
130 | /* make luaopen_string(_XXX) static, so it (and all other referenced | 154 | /* make luaopen_string(_XXX) static, so it (and all other referenced |
131 | * string functions) won't be included in the resulting dll | 155 | * string functions) won't be included in the resulting dll |
132 | * (hopefully). | 156 | * (hopefully). |
133 | */ | 157 | */ |
134 | # undef LUAMOD_API | 158 | # undef LUAMOD_API |
135 | # define LUAMOD_API static | 159 | # if defined(__GNUC__) || __has_attribute(__unused__) |
160 | # define LUAMOD_API __attribute__((__unused__)) static | ||
161 | # else | ||
162 | # define LUAMOD_API static | ||
163 | # endif | ||
136 | #endif /* lstrlib.c */ | 164 | #endif /* lstrlib.c */ |
137 | 165 | ||
138 | #endif | 166 | #endif |