diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 5a69189..ead5cd6 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -649,8 +649,10 @@ int pc_compile(int argc, char *argv[]) error(13); /* no entry point (no public functions) */ cleanup: - if (inpf!=NULL) /* main source file is not closed, do it now */ + if (inpf!=NULL) { /* main source file is not closed, do it now */ pc_closesrc(inpf); + inpf=NULL; + } /* write the binary file (the file is already open) */ if (!(sc_asmfile || sc_listing) && errnum==0 && jmpcode==0) { assert(binf!=NULL); diff --git a/source/compiler/sc6.c b/source/compiler/sc6.c index 795c8f0..85c714a 100644 --- a/source/compiler/sc6.c +++ b/source/compiler/sc6.c @@ -211,6 +211,21 @@ static char *stripcomment(char *str) return str; } +static char *stripwhitespace(char *str) +{ + if (*str!='\0') { + size_t len = strlen(str); + size_t i; + for (i=len-1; i>=0; i--) { + if (!isspace(str[i])) { + str[i+1]='\0'; + break; + } + } + } + return str; +} + static void write_encoded(FILE *fbin,ucell *c,int num) { #if PAWN_CELL_SIZE == 16 @@ -1016,7 +1031,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin) /* nothing */; assert(params>instr); i=findopcode(instr,(int)(params-instr)); - assert(opcodelist[i].name!=NULL); + if (opcodelist[i].name==NULL) + error(104, stripwhitespace(instr)); /* invalid assembler instruction */ if (opcodelist[i].segment==pass) opcodelist[i].func(fout,skipwhitespace(params),opcodelist[i].opcode); } /* while */