no more explicit support for wide-chars; too much troble...

This commit is contained in:
Roberto Ierusalimschy
2001-11-28 18:13:13 -02:00
parent dfaf8c5291
commit 72659a0605
39 changed files with 1161 additions and 1210 deletions

43
ltm.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: ltm.c,v 1.78 2001/08/31 19:46:07 roberto Exp $
** $Id: ltm.c,v 1.80 2001/10/11 21:41:21 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -8,7 +8,6 @@
#include <stdio.h>
#include <string.h>
#define LUA_PRIVATE
#include "lua.h"
#include "ldo.h"
@@ -20,16 +19,16 @@
#include "ltm.h"
const l_char *const luaT_eventname[] = { /* ORDER TM */
l_s("gettable"), l_s("settable"), l_s("index"), l_s("getglobal"),
l_s("setglobal"), l_s("add"), l_s("sub"), l_s("mul"), l_s("div"),
l_s("pow"), l_s("unm"), l_s("lt"), l_s("concat"), l_s("gc"),
l_s("function"),
const char *const luaT_eventname[] = { /* ORDER TM */
"gettable", "settable", "index", "getglobal",
"setglobal", "add", "sub", "mul", "div",
"pow", "unm", "lt", "concat", "gc",
"function",
NULL
};
static int findevent (const l_char *name) {
static int findevent (const char *name) {
int i;
for (i=0; luaT_eventname[i]; i++)
if (strcmp(luaT_eventname[i], name) == 0)
@@ -38,10 +37,10 @@ static int findevent (const l_char *name) {
}
static int luaI_checkevent (lua_State *L, const l_char *name) {
static int luaI_checkevent (lua_State *L, const char *name) {
int e = findevent(name);
if (e < 0)
luaO_verror(L, l_s("`%.50s' is not a valid event name"), name);
luaO_verror(L, "`%.50s' is not a valid event name", name);
return e;
}
@@ -66,9 +65,9 @@ static int luaT_validevent (int t, int e) { /* ORDER LUA_T */
void luaT_init (lua_State *L) {
static const l_char *const typenames[NUM_TAGS] = {
l_s("userdata"), l_s("nil"), l_s("number"), l_s("string"),
l_s("table"), l_s("function")
static const char *const typenames[NUM_TAGS] = {
"userdata", "nil", "number", "string",
"table", "function"
};
int i;
for (i=0; i<NUM_TAGS; i++)
@@ -76,12 +75,12 @@ void luaT_init (lua_State *L) {
}
int luaT_newtag (lua_State *L, const l_char *name, int basictype) {
int luaT_newtag (lua_State *L, const char *name, int basictype) {
int tag;
int i;
TString *ts = NULL;
luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM,
MAX_INT, l_s("tag table overflow"));
MAX_INT, "tag table overflow");
tag = G(L)->ntag;
if (name) {
const TObject *v;
@@ -104,7 +103,7 @@ int luaT_newtag (lua_State *L, const l_char *name, int basictype) {
static void checktag (lua_State *L, int tag) {
if (!(0 <= tag && tag < G(L)->ntag))
luaO_verror(L, l_s("%d is not a valid tag"), tag);
luaO_verror(L, "%d is not a valid tag", tag);
}
@@ -118,7 +117,7 @@ int luaT_tag (const TObject *o) {
}
const l_char *luaT_typename (global_State *G, const TObject *o) {
const char *luaT_typename (global_State *G, const TObject *o) {
int t = ttype(o);
int tag;
TString *ts;
@@ -139,7 +138,7 @@ const l_char *luaT_typename (global_State *G, const TObject *o) {
}
LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) {
LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) {
int e;
lua_lock(L);
e = luaI_checkevent(L, event);
@@ -154,16 +153,16 @@ LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) {
}
LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) {
LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) {
int e;
lua_lock(L);
e = luaI_checkevent(L, event);
checktag(L, t);
if (!luaT_validevent(t, e))
luaO_verror(L, l_s("cannot change `%.20s' tag method for type `%.20s'%.20s"),
luaO_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s",
luaT_eventname[e], typenamebytag(G(L), t),
(t == LUA_TTABLE || t == LUA_TUSERDATA) ?
l_s(" with default tag") : l_s(""));
" with default tag" : "");
switch (ttype(L->top - 1)) {
case LUA_TNIL:
luaT_gettm(G(L), t, e) = NULL;
@@ -172,7 +171,7 @@ LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) {
luaT_gettm(G(L), t, e) = clvalue(L->top - 1);
break;
default:
luaD_error(L, l_s("tag method must be a function (or nil)"));
luaD_error(L, "tag method must be a function (or nil)");
}
L->top--;
lua_unlock(L);