File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ extern int changedmaholescalled;
6565int maxpasses = 2 ;
6666
6767#define PREPROC_BUFFER_SIZE (256 * 1024) // 256KB buffer for preprocessed file
68- static char * preproc_buffer = NULL ;
68+ char * preproc_buffer = NULL ;
6969
7070#define BASIC_VERSION_INFO "7800basic v0.39"
7171
@@ -451,22 +451,18 @@ int main (int argc, char *argv[])
451451
452452 prout ("7800basic compilation complete.\n" );
453453 freemem (deallocate_mem );
454+ // Explicitly close the main assembly file at the end of each pass.
455+ if (main_asm_fp != NULL ) {
456+ fclose (main_asm_fp );
457+ main_asm_fp = NULL ;
458+ current_output_fp = NULL ;
459+ }
454460 }
455461
456462 header_write (header , filename );
457463 create_includes (includes_file );
458464
459465 lastrites ();
460466
461- // Final cleanup of the preprocessed file descriptor and its buffer
462- if (preprocessedfd != NULL && preprocessedfd != stdin ) {
463- fclose (preprocessedfd );
464- }
465-
466- if (preproc_buffer != NULL ) {
467- free (preproc_buffer );
468- preproc_buffer = NULL ;
469- }
470-
471467 return 0 ;
472468}
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ char savelinesname[MAXINCBASIC][MAXINCBASIC];
3232extern char stdoutfilename [256 ];
3333extern FILE * preprocessedfd ;
3434extern FILE * main_asm_fp ;
35+ extern char * preproc_buffer ;
3536extern FILE * current_output_fp ;
3637extern char backupname [256 ];
3738extern int maxpasses ;
@@ -12373,17 +12374,16 @@ void lastrites()
1237312374 remove ("7800hole.1.asm" );
1237412375 remove ("7800hole.2.asm" );
1237512376
12376- // Close all our managed file pointers
12377- if (current_output_fp != NULL )
12377+ // Final cleanup of the preprocessed file descriptor and its buffer.
12378+ if (preprocessedfd != NULL && preprocessedfd != stdin )
1237812379 {
12379- fflush (current_output_fp );
12380- if (current_output_fp != main_asm_fp )
12381- fclose (current_output_fp );
12382- current_output_fp = NULL ;
12380+ fclose (preprocessedfd );
12381+ preprocessedfd = NULL ;
1238312382 }
12384- if (main_asm_fp != NULL )
12383+
12384+ if (preproc_buffer != NULL )
1238512385 {
12386- fclose ( main_asm_fp );
12387- main_asm_fp = NULL ;
12386+ free ( preproc_buffer );
12387+ preproc_buffer = NULL ;
1238812388 }
1238912389}
You can’t perform that action at this time.
0 commit comments