diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-28 18:13:13 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-28 18:13:13 -0200 |
commit | 72659a06050632da1a9b4c492302be46ac283f6b (patch) | |
tree | bac06b4ea523ba5443564d0869e392180d4b7b77 /lauxlib.c | |
parent | dfaf8c5291fa8aef5bedbfa375853475364ac76e (diff) | |
download | lua-72659a06050632da1a9b4c492302be46ac283f6b.tar.gz lua-72659a06050632da1a9b4c492302be46ac283f6b.tar.bz2 lua-72659a06050632da1a9b4c492302be46ac283f6b.zip |
no more explicit support for wide-chars; too much troble...
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 45 |
1 files changed, 22 insertions, 23 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.52 2001/10/26 17:33:30 roberto Exp $ | 2 | ** $Id: lauxlib.c,v 1.53 2001/10/31 19:40:14 roberto Exp $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -14,7 +14,6 @@ | |||
14 | ** With care, these functions can be used by other libraries. | 14 | ** With care, these functions can be used by other libraries. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LUA_PRIVATE | ||
18 | #include "lua.h" | 17 | #include "lua.h" |
19 | 18 | ||
20 | #include "lauxlib.h" | 19 | #include "lauxlib.h" |
@@ -23,7 +22,7 @@ | |||
23 | 22 | ||
24 | 23 | ||
25 | 24 | ||
26 | LUALIB_API int luaL_findstring (const l_char *name, const l_char *const list[]) { | 25 | LUALIB_API int luaL_findstring (const char *name, const char *const list[]) { |
27 | int i; | 26 | int i; |
28 | for (i=0; list[i]; i++) | 27 | for (i=0; list[i]; i++) |
29 | if (strcmp(list[i], name) == 0) | 28 | if (strcmp(list[i], name) == 0) |
@@ -31,20 +30,20 @@ LUALIB_API int luaL_findstring (const l_char *name, const l_char *const list[]) | |||
31 | return -1; /* name not found */ | 30 | return -1; /* name not found */ |
32 | } | 31 | } |
33 | 32 | ||
34 | LUALIB_API void luaL_argerror (lua_State *L, int narg, const l_char *extramsg) { | 33 | LUALIB_API void luaL_argerror (lua_State *L, int narg, const char *extramsg) { |
35 | lua_Debug ar; | 34 | lua_Debug ar; |
36 | lua_getstack(L, 0, &ar); | 35 | lua_getstack(L, 0, &ar); |
37 | lua_getinfo(L, l_s("n"), &ar); | 36 | lua_getinfo(L, "n", &ar); |
38 | if (ar.name == NULL) | 37 | if (ar.name == NULL) |
39 | ar.name = l_s("?"); | 38 | ar.name = "?"; |
40 | luaL_verror(L, l_s("bad argument #%d to `%.50s' (%.100s)"), | 39 | luaL_verror(L, "bad argument #%d to `%.50s' (%.100s)", |
41 | narg, ar.name, extramsg); | 40 | narg, ar.name, extramsg); |
42 | } | 41 | } |
43 | 42 | ||
44 | 43 | ||
45 | LUALIB_API void luaL_typerror (lua_State *L, int narg, const l_char *tname) { | 44 | LUALIB_API void luaL_typerror (lua_State *L, int narg, const char *tname) { |
46 | l_char buff[80]; | 45 | char buff[80]; |
47 | sprintf(buff, l_s("%.25s expected, got %.25s"), tname, lua_type(L,narg)); | 46 | sprintf(buff, "%.25s expected, got %.25s", tname, lua_type(L,narg)); |
48 | luaL_argerror(L, narg, buff); | 47 | luaL_argerror(L, narg, buff); |
49 | } | 48 | } |
50 | 49 | ||
@@ -54,9 +53,9 @@ static void tag_error (lua_State *L, int narg, int tag) { | |||
54 | } | 53 | } |
55 | 54 | ||
56 | 55 | ||
57 | LUALIB_API void luaL_check_stack (lua_State *L, int space, const l_char *mes) { | 56 | LUALIB_API void luaL_check_stack (lua_State *L, int space, const char *mes) { |
58 | if (space > lua_stackspace(L)) | 57 | if (space > lua_stackspace(L)) |
59 | luaL_verror(L, l_s("stack overflow (%.30s)"), mes); | 58 | luaL_verror(L, "stack overflow (%.30s)", mes); |
60 | } | 59 | } |
61 | 60 | ||
62 | 61 | ||
@@ -68,27 +67,27 @@ LUALIB_API void luaL_check_rawtype(lua_State *L, int narg, int t) { | |||
68 | 67 | ||
69 | LUALIB_API void luaL_check_any (lua_State *L, int narg) { | 68 | LUALIB_API void luaL_check_any (lua_State *L, int narg) { |
70 | if (lua_rawtag(L, narg) == LUA_TNONE) | 69 | if (lua_rawtag(L, narg) == LUA_TNONE) |
71 | luaL_argerror(L, narg, l_s("value expected")); | 70 | luaL_argerror(L, narg, "value expected"); |
72 | } | 71 | } |
73 | 72 | ||
74 | 73 | ||
75 | LUALIB_API void *luaL_check_userdata (lua_State *L, int narg, | 74 | LUALIB_API void *luaL_check_userdata (lua_State *L, int narg, |
76 | const l_char *name) { | 75 | const char *name) { |
77 | if (strcmp(lua_type(L, narg), name) != 0) | 76 | if (strcmp(lua_type(L, narg), name) != 0) |
78 | luaL_typerror(L, narg, name); | 77 | luaL_typerror(L, narg, name); |
79 | return lua_touserdata(L, narg); | 78 | return lua_touserdata(L, narg); |
80 | } | 79 | } |
81 | 80 | ||
82 | 81 | ||
83 | LUALIB_API const l_char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { | 82 | LUALIB_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { |
84 | const l_char *s = lua_tostring(L, narg); | 83 | const char *s = lua_tostring(L, narg); |
85 | if (!s) tag_error(L, narg, LUA_TSTRING); | 84 | if (!s) tag_error(L, narg, LUA_TSTRING); |
86 | if (len) *len = lua_strlen(L, narg); | 85 | if (len) *len = lua_strlen(L, narg); |
87 | return s; | 86 | return s; |
88 | } | 87 | } |
89 | 88 | ||
90 | 89 | ||
91 | LUALIB_API const l_char *luaL_opt_lstr (lua_State *L, int narg, const l_char *def, size_t *len) { | 90 | LUALIB_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, size_t *len) { |
92 | if (lua_isnull(L, narg)) { | 91 | if (lua_isnull(L, narg)) { |
93 | if (len) | 92 | if (len) |
94 | *len = (def ? strlen(def) : 0); | 93 | *len = (def ? strlen(def) : 0); |
@@ -119,8 +118,8 @@ LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l, int n) { | |||
119 | } | 118 | } |
120 | 119 | ||
121 | 120 | ||
122 | LUALIB_API void luaL_verror (lua_State *L, const l_char *fmt, ...) { | 121 | LUALIB_API void luaL_verror (lua_State *L, const char *fmt, ...) { |
123 | l_char buff[500]; | 122 | char buff[500]; |
124 | va_list argp; | 123 | va_list argp; |
125 | va_start(argp, fmt); | 124 | va_start(argp, fmt); |
126 | vsprintf(buff, fmt, argp); | 125 | vsprintf(buff, fmt, argp); |
@@ -174,20 +173,20 @@ static void adjuststack (luaL_Buffer *B) { | |||
174 | } | 173 | } |
175 | 174 | ||
176 | 175 | ||
177 | LUALIB_API l_char *luaL_prepbuffer (luaL_Buffer *B) { | 176 | LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { |
178 | if (emptybuffer(B)) | 177 | if (emptybuffer(B)) |
179 | adjuststack(B); | 178 | adjuststack(B); |
180 | return B->buffer; | 179 | return B->buffer; |
181 | } | 180 | } |
182 | 181 | ||
183 | 182 | ||
184 | LUALIB_API void luaL_addlstring (luaL_Buffer *B, const l_char *s, size_t l) { | 183 | LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { |
185 | while (l--) | 184 | while (l--) |
186 | luaL_putchar(B, *s++); | 185 | luaL_putchar(B, *s++); |
187 | } | 186 | } |
188 | 187 | ||
189 | 188 | ||
190 | LUALIB_API void luaL_addstring (luaL_Buffer *B, const l_char *s) { | 189 | LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { |
191 | luaL_addlstring(B, s, strlen(s)); | 190 | luaL_addlstring(B, s, strlen(s)); |
192 | } | 191 | } |
193 | 192 | ||
@@ -236,7 +235,7 @@ LUALIB_API int luaL_ref (lua_State *L, int t) { | |||
236 | } | 235 | } |
237 | else { /* no free elements */ | 236 | else { /* no free elements */ |
238 | ref = lua_getn(L, t) + 1; /* use next `n' */ | 237 | ref = lua_getn(L, t) + 1; /* use next `n' */ |
239 | lua_pushliteral(L, l_s("n")); | 238 | lua_pushliteral(L, "n"); |
240 | lua_pushnumber(L, ref); | 239 | lua_pushnumber(L, ref); |
241 | lua_settable(L, t); /* n = n+1 */ | 240 | lua_settable(L, t); /* n = n+1 */ |
242 | } | 241 | } |