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 --- lundump.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'lundump.c') diff --git a/lundump.c b/lundump.c index 1711e4f0..353e746e 100644 --- a/lundump.c +++ b/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 1.37 2000/12/28 12:59:41 roberto Exp roberto $ +** $Id: lundump.c,v 1.38 2001/01/15 16:13:24 roberto Exp roberto $ ** load bytecodes from files ** See Copyright Notice in lua.h */ @@ -15,15 +15,15 @@ #define LoadByte ezgetc -static const char* ZNAME (ZIO* Z) +static const l_char* ZNAME (ZIO* Z) { - const char* s=zname(Z); - return (*s=='@') ? s+1 : s; + const l_char* s=zname(Z); + return (*s==l_c('@')) ? s+1 : s; } static void unexpectedEOZ (lua_State* L, ZIO* Z) { - luaO_verror(L,"unexpected end of file in `%.99s'",ZNAME(Z)); + luaO_verror(L,l_s("unexpected end of file in `%.99s'"),ZNAME(Z)); } static int ezgetc (lua_State* L, ZIO* Z) @@ -43,9 +43,9 @@ static void LoadBlock (lua_State* L, void* b, size_t size, ZIO* Z, int swap) { if (swap) { - char *p=(char *) b+size-1; + l_char *p=(l_char *) b+size-1; int n=size; - while (n--) *p--=(char)ezgetc(L,Z); + while (n--) *p--=(l_char)ezgetc(L,Z); } else ezread(L,Z,b,size); @@ -55,12 +55,12 @@ static void LoadVector (lua_State* L, void* b, int m, size_t size, ZIO* Z, int s { if (swap) { - char *q=(char *) b; + l_char *q=(l_char *) b; while (m--) { - char *p=q+size-1; + l_char *p=q+size-1; int n=size; - while (n--) *p--=(char)ezgetc(L,Z); + while (n--) *p--=(l_char)ezgetc(L,Z); q+=size; } } @@ -96,9 +96,9 @@ static TString* LoadString (lua_State* L, ZIO* Z, int swap) return NULL; else { - char* s=luaO_openspace(L,size); + l_char* s=luaO_openspace(L,size); LoadBlock(L,s,size,Z,0); - return luaS_newlstr(L,s,size-1); /* remove trailing '\0' */ + return luaS_newlstr(L,s,size-1); /* remove trailing l_c('\0') */ } } @@ -171,18 +171,18 @@ static Proto* LoadFunction (lua_State* L, ZIO* Z, int swap) static void LoadSignature (lua_State* L, ZIO* Z) { - const char* s=SIGNATURE; + const l_char* s=SIGNATURE; while (*s!=0 && ezgetc(L,Z)==*s) ++s; - if (*s!=0) luaO_verror(L,"bad signature in `%.99s'",ZNAME(Z)); + if (*s!=0) luaO_verror(L,l_s("bad signature in `%.99s'"),ZNAME(Z)); } -static void TestSize (lua_State* L, int s, const char* what, ZIO* Z) +static void TestSize (lua_State* L, int s, const l_char* what, ZIO* Z) { int r=ezgetc(L,Z); if (r!=s) - luaO_verror(L,"virtual machine mismatch in `%.99s':\n" - " %.20s is %d but read %d",ZNAME(Z),what,s,r); + luaO_verror(L,l_s("virtual machine mismatch in `%.99s':\n") + l_s(" %.20s is %d but read %d"),ZNAME(Z),what,s,r); } #define TESTSIZE(s) TestSize(L,s,#s,Z) @@ -195,12 +195,12 @@ static int LoadHeader (lua_State* L, ZIO* Z) LoadSignature(L,Z); version=ezgetc(L,Z); if (version>VERSION) - luaO_verror(L,"`%.99s' too new:\n" - " read version %d.%d; expected at most %d.%d", + luaO_verror(L,l_s("`%.99s' too new:\n") + l_s(" read version %d.%d; expected at most %d.%d"), ZNAME(Z),V(version),V(VERSION)); if (version