From 39b79783297bee79db9853b63d199e120a009a8f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 23 Feb 2001 14:17:25 -0300 Subject: first (big) step to support wide chars --- lauxlib.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index d36424d2..5e9f4e89 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.46 2001/02/02 19:02:40 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.47 2001/02/14 17:04:11 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -18,10 +18,11 @@ #include "lauxlib.h" #include "luadebug.h" +#include "lualib.h" -LUALIB_API int luaL_findstring (const char *name, const char *const list[]) { +LUALIB_API int luaL_findstring (const l_char *name, const l_char *const list[]) { int i; for (i=0; list[i]; i++) if (strcmp(list[i], name) == 0) @@ -29,20 +30,20 @@ LUALIB_API int luaL_findstring (const char *name, const char *const list[]) { return -1; /* name not found */ } -LUALIB_API void luaL_argerror (lua_State *L, int narg, const char *extramsg) { +LUALIB_API void luaL_argerror (lua_State *L, int narg, const l_char *extramsg) { lua_Debug ar; lua_getstack(L, 0, &ar); - lua_getinfo(L, "n", &ar); + lua_getinfo(L, l_s("n"), &ar); if (ar.name == NULL) - ar.name = "?"; - luaL_verror(L, "bad argument #%d to `%.50s' (%.100s)", + ar.name = l_s("?"); + luaL_verror(L, l_s("bad argument #%d to `%.50s' (%.100s)"), narg, ar.name, extramsg); } -static void type_error (lua_State *L, int narg, const char *tname) { - char buff[80]; - sprintf(buff, "%.25s expected, got %.25s", tname, lua_xtype(L, narg)); +static void type_error (lua_State *L, int narg, const l_char *tname) { + l_char buff[80]; + sprintf(buff, l_s("%.25s expected, got %.25s"), tname, lua_xtype(L, narg)); luaL_argerror(L, narg, buff); } @@ -52,9 +53,9 @@ static void tag_error (lua_State *L, int narg, int tag) { } -LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { +LUALIB_API void luaL_checkstack (lua_State *L, int space, const l_char *mes) { if (space > lua_stackspace(L)) - luaL_verror(L, "stack overflow (%.30s)", mes); + luaL_verror(L, l_s("stack overflow (%.30s)"), mes); } @@ -66,27 +67,27 @@ LUALIB_API void luaL_checktype(lua_State *L, int narg, int t) { LUALIB_API void luaL_checkany (lua_State *L, int narg) { if (lua_type(L, narg) == LUA_TNONE) - luaL_argerror(L, narg, "value expected"); + luaL_argerror(L, narg, l_s("value expected")); } LUALIB_API void *luaL_check_userdata (lua_State *L, int narg, - const char *name) { + const l_char *name) { if (strcmp(lua_xtype(L, narg), name) != 0) type_error(L, narg, name); return lua_touserdata(L, narg); } -LUALIB_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { - const char *s = lua_tostring(L, narg); +LUALIB_API const l_char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { + const l_char *s = lua_tostring(L, narg); if (!s) tag_error(L, narg, LUA_TSTRING); if (len) *len = lua_strlen(L, narg); return s; } -LUALIB_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, size_t *len) { +LUALIB_API const l_char *luaL_opt_lstr (lua_State *L, int narg, const l_char *def, size_t *len) { if (lua_isnull(L, narg)) { if (len) *len = (def ? strlen(def) : 0); @@ -117,8 +118,8 @@ LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l, int n) { } -LUALIB_API void luaL_verror (lua_State *L, const char *fmt, ...) { - char buff[500]; +LUALIB_API void luaL_verror (lua_State *L, const l_char *fmt, ...) { + l_char buff[500]; va_list argp; va_start(argp, fmt); vsprintf(buff, fmt, argp); @@ -172,20 +173,20 @@ static void adjuststack (luaL_Buffer *B) { } -LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { +LUALIB_API l_char *luaL_prepbuffer (luaL_Buffer *B) { if (emptybuffer(B)) adjuststack(B); return B->buffer; } -LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const l_char *s, size_t l) { while (l--) luaL_putchar(B, *s++); } -LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { +LUALIB_API void luaL_addstring (luaL_Buffer *B, const l_char *s) { luaL_addlstring(B, s, strlen(s)); } -- cgit v1.2.3-55-g6feb