aboutsummaryrefslogtreecommitdiff
path: root/lundump.c
diff options
context:
space:
mode:
Diffstat (limited to 'lundump.c')
-rw-r--r--lundump.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/lundump.c b/lundump.c
index 95690033..d8f74758 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 1.27 2000/09/04 18:53:41 roberto Exp roberto $ 2** $Id: lundump.c,v 1.28 2000/09/11 17:38:42 roberto Exp roberto $
3** load bytecodes from files 3** load bytecodes from files
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -7,7 +7,6 @@
7#include <stdio.h> 7#include <stdio.h>
8#include <string.h> 8#include <string.h>
9 9
10#include "lauxlib.h"
11#include "lfunc.h" 10#include "lfunc.h"
12#include "lmem.h" 11#include "lmem.h"
13#include "lopcodes.h" 12#include "lopcodes.h"
@@ -26,7 +25,7 @@ static const char* ZNAME(ZIO* Z)
26 25
27static void unexpectedEOZ (lua_State* L, ZIO* Z) 26static void unexpectedEOZ (lua_State* L, ZIO* Z)
28{ 27{
29 luaL_verror(L,"unexpected end of file in `%.255s'",ZNAME(Z)); 28 luaO_verror(L,"unexpected end of file in `%.255s'",ZNAME(Z));
30} 29}
31 30
32static int ezgetc (lua_State* L, ZIO* Z) 31static int ezgetc (lua_State* L, ZIO* Z)
@@ -100,7 +99,7 @@ static void LoadCode (lua_State* L, Proto* tf, ZIO* Z, int swap)
100#if 0 99#if 0
101 if (swap) SwapBytes(tf->code,sizeof(*tf->code),size); 100 if (swap) SwapBytes(tf->code,sizeof(*tf->code),size);
102#endif 101#endif
103 if (tf->code[size-1]!=OP_END) luaL_verror(L,"bad code in `%.255s'",ZNAME(Z)); 102 if (tf->code[size-1]!=OP_END) luaO_verror(L,"bad code in `%.255s'",ZNAME(Z));
104} 103}
105 104
106static void LoadLocals (lua_State* L, Proto* tf, ZIO* Z, int swap) 105static void LoadLocals (lua_State* L, Proto* tf, ZIO* Z, int swap)
@@ -167,14 +166,14 @@ static void LoadSignature (lua_State* L, ZIO* Z)
167 const char* s=SIGNATURE; 166 const char* s=SIGNATURE;
168 while (*s!=0 && ezgetc(L,Z)==*s) 167 while (*s!=0 && ezgetc(L,Z)==*s)
169 ++s; 168 ++s;
170 if (*s!=0) luaL_verror(L,"bad signature in `%.255s'",ZNAME(Z)); 169 if (*s!=0) luaO_verror(L,"bad signature in `%.255s'",ZNAME(Z));
171} 170}
172 171
173static void TestSize (lua_State* L, int s, const char* what, ZIO* Z) 172static void TestSize (lua_State* L, int s, const char* what, ZIO* Z)
174{ 173{
175 int r=ezgetc(L,Z); 174 int r=ezgetc(L,Z);
176 if (r!=s) 175 if (r!=s)
177 luaL_verror(L,"virtual machine mismatch in `%.255s':\n" 176 luaO_verror(L,"virtual machine mismatch in `%.255s':\n"
178 " %s is %d but read %d",ZNAME(Z),what,r,s); 177 " %s is %d but read %d",ZNAME(Z),what,r,s);
179} 178}
180 179
@@ -188,11 +187,11 @@ static int LoadHeader (lua_State* L, ZIO* Z)
188 LoadSignature(L,Z); 187 LoadSignature(L,Z);
189 version=ezgetc(L,Z); 188 version=ezgetc(L,Z);
190 if (version>VERSION) 189 if (version>VERSION)
191 luaL_verror(L,"`%.255s' too new:\n" 190 luaO_verror(L,"`%.255s' too new:\n"
192 " read version %d.%d; expected at most %d.%d", 191 " read version %d.%d; expected at most %d.%d",
193 ZNAME(Z),V(version),V(VERSION)); 192 ZNAME(Z),V(version),V(VERSION));
194 if (version<VERSION0) /* check last major change */ 193 if (version<VERSION0) /* check last major change */
195 luaL_verror(L,"`%.255s' too old:\n" 194 luaO_verror(L,"`%.255s' too old:\n"
196 " read version %d.%d; expected at least %d.%d", 195 " read version %d.%d; expected at least %d.%d",
197 ZNAME(Z),V(version),V(VERSION)); 196 ZNAME(Z),V(version),V(VERSION));
198 swap=(luaU_endianess()!=ezgetc(L,Z)); /* need to swap bytes? */ 197 swap=(luaU_endianess()!=ezgetc(L,Z)); /* need to swap bytes? */
@@ -205,7 +204,7 @@ static int LoadHeader (lua_State* L, ZIO* Z)
205 TESTSIZE(sizeof(Number)); 204 TESTSIZE(sizeof(Number));
206 f=LoadNumber(L,Z,swap); 205 f=LoadNumber(L,Z,swap);
207 if ((long)f!=(long)tf) /* disregard errors in last bit of fraction */ 206 if ((long)f!=(long)tf) /* disregard errors in last bit of fraction */
208 luaL_verror(L,"unknown number format in `%.255s':\n" 207 luaO_verror(L,"unknown number format in `%.255s':\n"
209 " read " NUMBER_FMT "; expected " NUMBER_FMT, 208 " read " NUMBER_FMT "; expected " NUMBER_FMT,
210 ZNAME(Z),f,tf); 209 ZNAME(Z),f,tf);
211 return swap; 210 return swap;
@@ -226,7 +225,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z)
226 if (c==ID_CHUNK) 225 if (c==ID_CHUNK)
227 return LoadChunk(L,Z); 226 return LoadChunk(L,Z);
228 else if (c!=EOZ) 227 else if (c!=EOZ)
229 luaL_verror(L,"`%.255s' is not a precompiled Lua chunk",ZNAME(Z)); 228 luaO_verror(L,"`%.255s' is not a precompiled Lua chunk",ZNAME(Z));
230 return NULL; 229 return NULL;
231} 230}
232 231