aboutsummaryrefslogtreecommitdiff
path: root/development/ieee-pilot/gencode.diff
blob: 0f9943678963991e273f6f73bcd395fdc68173ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
diff --git a/gencode.c b/gencode.c
index 0909641..4d4ec8b 100644
--- a/gencode.c
+++ b/gencode.c
@@ -529,8 +529,11 @@ void solhook(char *s) {
 				    vp->v.label.addr <= ftell(yyin) &&
 				    vp->v.label.addr >=
 				        ftell(yyin) - (int)strlen(s)) {
-					(void)fprintf(yyout, "plt_%s:\n",
-					              vp->name);
+					static char *last_emitted;
+					if(last_emitted != vp->name) {
+					     (void)fprintf(yyout, "plt_%s:\n", vp->name);
+					     last_emitted = vp->name;
+					}
 				}
 			}
 
@@ -1227,6 +1230,10 @@ int execfile(char *t) {
 		(void)fprintf(yyout, "/* %s -- generated C code for %s */\n",
 		              outfile, source);
 		(void)fputs("#include <stdio.h>\n", yyout);
+		(void)fputs("#include <string.h>\n", yyout);
+		(void)fputs("#include <unistd.h>\n", yyout);
+		(void)fputs("#include <stdlib.h>\n", yyout);
+		(void)fputs("extern char *gets(char *s);\n", yyout);
 		(void)fputs("#include \"pilot.h\"\n", yyout);
 
 		/* generate declarations for all non-system variables */
@@ -1256,7 +1263,7 @@ int execfile(char *t) {
 			(void)fputs(PASS2, stderr);
 		}
 
-		(void)fputs("\nmain()\n{\n    do_scrinit();\n", yyout);
+		(void)fputs("\nint main(int argc, char **argv)\n{\n    do_scrinit();\n", yyout);
 		indent = 1;
 	}