diff options
author | Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> | 1996-02-26 16:44:17 -0300 |
---|---|---|
committer | Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> | 1996-02-26 16:44:17 -0300 |
commit | 3e429699792218af45a0f399542e14563c1a173b (patch) | |
tree | e714974ae46aec875ce8209f4ee6e0a3a668642e | |
parent | 712ac505e0d3fc06b328af3b773a9d2eecb3d190 (diff) | |
download | lua-3e429699792218af45a0f399542e14563c1a173b.tar.gz lua-3e429699792218af45a0f399542e14563c1a173b.tar.bz2 lua-3e429699792218af45a0f399542e14563c1a173b.zip |
main always reads "luac.out"
-rw-r--r-- | undump.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** load bytecodes from files | 3 | ** load bytecodes from files |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_undump="$Id: undump.c,v 1.3 1996/02/24 03:46:57 lhf Exp lhf $"; | 6 | char *rcs_undump="$Id: undump.c,v 1.4 1996/02/24 16:44:28 lhf Exp lhf $"; |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
@@ -60,10 +60,10 @@ static TFunc *lastF=NULL; | |||
60 | static void LoadFunction(FILE *D) | 60 | static void LoadFunction(FILE *D) |
61 | { | 61 | { |
62 | TFunc *tf=new(TFunc); | 62 | TFunc *tf=new(TFunc); |
63 | tf->size=LoadWord(D); | 63 | tf->size=LoadWord(D); /* TODO: Long? */ |
64 | tf->marked=LoadWord(D); | 64 | tf->marked=LoadWord(D); |
65 | tf->lineDefined=LoadWord(D); | 65 | tf->lineDefined=LoadWord(D); |
66 | tf->fileName=LoadString(D); | 66 | tf->fileName=LoadString(D); /* TODO: not needed if not main */ |
67 | tf->code=LoadBlock(tf->size,D); | 67 | tf->code=LoadBlock(tf->size,D); |
68 | tf->next=NULL; | 68 | tf->next=NULL; |
69 | if (tf->lineDefined==0) /* new main */ | 69 | if (tf->lineDefined==0) /* new main */ |
@@ -123,11 +123,13 @@ static void LoadChunk(FILE *D) | |||
123 | int c=getc(D); | 123 | int c=getc(D); |
124 | if (c=='F') LoadFunction(D); else { ungetc(c,D); break; } | 124 | if (c=='F') LoadFunction(D); else { ungetc(c,D); break; } |
125 | } | 125 | } |
126 | #if 1 | ||
126 | { /* TODO: run Main? */ | 127 | { /* TODO: run Main? */ |
127 | TFunc *tf; | 128 | TFunc *tf; |
128 | for (tf=Main; tf!=NULL; tf=tf->next) | 129 | for (tf=Main; tf!=NULL; tf=tf->next) |
129 | PrintFunction(tf); | 130 | PrintFunction(tf); |
130 | } | 131 | } |
132 | #endif | ||
131 | } | 133 | } |
132 | 134 | ||
133 | void luaI_undump(FILE *D) | 135 | void luaI_undump(FILE *D) |
@@ -143,6 +145,13 @@ void luaI_undump(FILE *D) | |||
143 | 145 | ||
144 | int main(int argc, char* argv[]) | 146 | int main(int argc, char* argv[]) |
145 | { | 147 | { |
148 | FILE *f=freopen("luac.out","rb",stdin); | ||
149 | if (f==NULL) | ||
150 | { | ||
151 | fprintf(stderr,"undump: cannot open "); | ||
152 | perror("luac.out"); | ||
153 | exit(1); | ||
154 | } | ||
146 | luaI_undump(stdin); | 155 | luaI_undump(stdin); |
147 | return 0; | 156 | return 0; |
148 | } | 157 | } |