aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Janda <siffiejoe@gmx.net>2016-02-05 13:50:08 +0100
committerPhilipp Janda <siffiejoe@gmx.net>2016-02-05 13:50:08 +0100
commit2c732b8c8831e656863a40530de2548615fa1ceb (patch)
treecb0669c1fda87e41f353fea53fa202616805da4a
parentaf8c4896960770c0268ac3281d0622a0c0694dc5 (diff)
downloadlua-compat-5.3-2c732b8c8831e656863a40530de2548615fa1ceb.tar.gz
lua-compat-5.3-2c732b8c8831e656863a40530de2548615fa1ceb.tar.bz2
lua-compat-5.3-2c732b8c8831e656863a40530de2548615fa1ceb.zip
Simplify utf8 helper function.
There's no need for `compat_utf8_escape()` to be a vararg function. Remove default templates from `package.path`.
-rw-r--r--lprefix.h8
-rwxr-xr-xtests/test.lua2
2 files changed, 2 insertions, 8 deletions
diff --git a/lprefix.h b/lprefix.h
index cba5bbc..9f970c4 100644
--- a/lprefix.h
+++ b/lprefix.h
@@ -51,16 +51,10 @@
51 51
52#ifdef lutf8lib_c 52#ifdef lutf8lib_c
53# define luaopen_utf8 luaopen_compat53_utf8 53# define luaopen_utf8 luaopen_compat53_utf8
54# include <stdarg.h>
55/* we don't support the %U format string of lua_pushfstring! 54/* we don't support the %U format string of lua_pushfstring!
56 * code below adapted from the Lua 5.3 sources: 55 * code below adapted from the Lua 5.3 sources:
57 */ 56 */
58static const char *compat53_utf8_escape (lua_State* L, ...) { 57static const char *compat53_utf8_escape (lua_State* L, long x) {
59 long x = 0;
60 va_list argp;
61 va_start(argp, L);
62 x = (long)va_arg(argp, long);
63 va_end(argp);
64 if (x < 0x80) { /* ASCII */ 58 if (x < 0x80) { /* ASCII */
65 char c = (char)x; 59 char c = (char)x;
66 lua_pushlstring(L, &c, 1); 60 lua_pushlstring(L, &c, 1);
diff --git a/tests/test.lua b/tests/test.lua
index f2094b9..8adad1a 100755
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -42,7 +42,7 @@ if arg[1] == "module" then
42end 42end
43 43
44 44
45package.path = "../?.lua;../?/init.lua;"..package.path 45package.path = "../?.lua;../?/init.lua"
46package.cpath = "./?-"..V..".so;./?-"..V..".dll;./?.so;./?.dll" 46package.cpath = "./?-"..V..".so;./?-"..V..".dll;./?.so;./?.dll"
47if mode == "module" then 47if mode == "module" then
48 print("testing Lua API using `compat53.module` ...") 48 print("testing Lua API using `compat53.module` ...")