summaryrefslogtreecommitdiff
path: root/undump.c
diff options
context:
space:
mode:
authorLuiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>1996-11-14 09:44:34 -0200
committerLuiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>1996-11-14 09:44:34 -0200
commitd991def36c313a5d10bc9f6769fc3ec2307dd60b (patch)
tree66345b0c545604de1a7fb5f0225d7712be827ad1 /undump.c
parent8b195533d2b9576b339c8cf95c03bf13aec955a2 (diff)
downloadlua-github-d991def36c313a5d10bc9f6769fc3ec2307dd60b.tar.gz
added 3 new bytes to header (sizeof's)
Diffstat (limited to 'undump.c')
-rw-r--r--undump.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/undump.c b/undump.c
index 1b22b9b1..b92f146d 100644
--- a/undump.c
+++ b/undump.c
@@ -3,7 +3,7 @@
** load bytecodes from files
*/
-char* rcs_undump="$Id: undump.c,v 1.15 1996/11/07 13:59:51 lhf Exp lhf $";
+char* rcs_undump="$Id: undump.c,v 1.16 1996/11/07 14:13:28 lhf Exp lhf $";
#include <stdio.h>
#include <string.h>
@@ -90,7 +90,7 @@ static void FixCode(Byte* code, Byte* end) /* swap words */
p+=3;
break;
case PUSHFUNCTION:
- p+=5;
+ p+=5; /* TODO: use sizeof(TFunc*) or old? */
break;
case PUSHWORD:
case PUSHSELF:
@@ -111,7 +111,7 @@ static void FixCode(Byte* code, Byte* end) /* swap words */
p+=3;
break;
}
- case PUSHFLOAT:
+ case PUSHFLOAT: /* assumes sizeof(float)==4 */
{
Byte t;
t=p[1]; p[1]=p[4]; p[4]=t;
@@ -250,8 +250,18 @@ static void LoadHeader(FILE* D) /* TODO: error handling */
{
Word w,tw=TEST_WORD;
float f,tf=TEST_FLOAT;
+ int version;
LoadSignature(D);
- getc(D); /* skip version */
+ version=getc(D);
+ if (version>23) /* after 2.5 */
+ {
+ int oldsizeofI=getc(D);
+ int oldsizeofF=getc(D);
+ int oldsizeofP=getc(D);
+ if (oldsizeofF!=4) lua_error("sizeof(float)!=4. not an IEEE machine?");
+ if (oldsizeofFP!=sizeof(TFunc*)) /* TODO: pack */
+ lua_error("different pointer sizes");
+ }
fread(&w,sizeof(w),1,D); /* test word */
if (w!=tw)
{