]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - exec.c
Some cleanups and smaller binaries!
[xonotic/gmqcc.git] / exec.c
diff --git a/exec.c b/exec.c
index 05d6d8df1a6dd0701650cc5d866a755c9907d20e..fad760a357a4f60b790eec3c5f21a371a633854f 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -56,7 +56,7 @@ qc_program* prog_load(const char *filename, bool skipversion)
 {
     qc_program   *prog;
     prog_header   header;
-    FILE         *file   = fs_file_open(filename, "rb");
+    FILE         *file  = fs_file_open(filename, "rb");
 
     if (!file)
         return NULL;
@@ -144,6 +144,8 @@ error:
     vec_free(prog->entitydata);
     vec_free(prog->entitypool);
     mem_d(prog);
+
+    fs_file_close(file);
     return NULL;
 }
 
@@ -302,7 +304,9 @@ static void trace_print_global(qc_program *prog, unsigned int glob, int vtype) {
     int       len;
 
     if (!glob) {
-        len = printf("<null>,");
+        if ((len = printf("<null>,")) == -1)
+            len = 0;
+
         goto done;
     }
 
@@ -354,7 +358,7 @@ done:
 }
 
 static void prog_print_statement(qc_program *prog, prog_section_statement *st) {
-    if (st->opcode >= (sizeof(asm_instr)/sizeof(asm_instr[0]))) {
+    if (st->opcode >= VINSTR_END) {
         printf("<illegal instruction %d>\n", st->opcode);
         return;
     }
@@ -364,7 +368,7 @@ static void prog_print_statement(qc_program *prog, prog_section_statement *st) {
             printf("->");
         printf("%s:", vec_last(prog->function_stack));
     }
-    printf(" <> %-12s", asm_instr[st->opcode].m);
+    printf(" <> %-12s", util_instr_str[st->opcode]);
     if (st->opcode >= INSTR_IF &&
         st->opcode <= INSTR_IFNOT)
     {
@@ -1046,6 +1050,8 @@ int main(int argc, char **argv) {
                 p.vtype = TYPE_STRING;
             else if (argv[1][1] == 'v')
                 p.vtype = TYPE_VECTOR;
+            else
+                p.vtype = TYPE_VOID;
 
             --argc;
             ++argv;