aboutsummaryrefslogtreecommitdiff
path: root/lundump.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-02-28 09:25:12 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-02-28 09:25:12 -0300
commit93e28031de81efacb7f84b142f57d5c2cdf4744e (patch)
treeed4a1a629e0f23f2404619be44f537533fe0312c /lundump.c
parentde84b3fecb9eb96f2d65bb754851dba8d815bb6d (diff)
downloadlua-93e28031de81efacb7f84b142f57d5c2cdf4744e.tar.gz
lua-93e28031de81efacb7f84b142f57d5c2cdf4744e.tar.bz2
lua-93e28031de81efacb7f84b142f57d5c2cdf4744e.zip
all chars used in binary dumps are unsigned ('lu_byte')
Diffstat (limited to 'lundump.c')
-rw-r--r--lundump.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lundump.c b/lundump.c
index a976e6dd..1fd1eb18 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 2.26 2014/02/27 16:56:20 roberto Exp roberto $ 2** $Id: lundump.c,v 2.27 2014/02/27 18:56:15 roberto Exp roberto $
3** load precompiled Lua chunks 3** load precompiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -34,7 +34,6 @@ static l_noret error(LoadState* S, const char* why)
34} 34}
35 35
36#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) 36#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
37#define LoadByte(S) (lu_byte)LoadChar(S)
38#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) 37#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
39#define LoadVector(S,b,n,size) LoadMem(S,b,n,size) 38#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
40 39
@@ -47,9 +46,9 @@ static void LoadBlock(LoadState* S, void* b, size_t size)
47 if (luaZ_read(S->Z,b,size)!=0) error(S,"truncated"); 46 if (luaZ_read(S->Z,b,size)!=0) error(S,"truncated");
48} 47}
49 48
50static int LoadChar(LoadState* S) 49static lu_byte LoadByte(LoadState* S)
51{ 50{
52 char x; 51 lu_byte x;
53 LoadVar(S,x); 52 LoadVar(S,x);
54 return x; 53 return x;
55} 54}
@@ -110,14 +109,14 @@ static void LoadConstants(LoadState* S, Proto* f)
110 for (i=0; i<n; i++) 109 for (i=0; i<n; i++)
111 { 110 {
112 TValue* o=&f->k[i]; 111 TValue* o=&f->k[i];
113 int t=LoadChar(S); 112 int t=LoadByte(S);
114 switch (t) 113 switch (t)
115 { 114 {
116 case LUA_TNIL: 115 case LUA_TNIL:
117 setnilvalue(o); 116 setnilvalue(o);
118 break; 117 break;
119 case LUA_TBOOLEAN: 118 case LUA_TBOOLEAN:
120 setbvalue(o,LoadChar(S)); 119 setbvalue(o,LoadByte(S));
121 break; 120 break;
122 case LUA_TNUMFLT: 121 case LUA_TNUMFLT:
123 setnvalue(o,LoadNumber(S)); 122 setnvalue(o,LoadNumber(S));