diff --git a/interpreters/bas/bas.c b/interpreters/bas/bas.c index 63f9c69d8..0ab8eaf3d 100644 --- a/interpreters/bas/bas.c +++ b/interpreters/bas/bas.c @@ -2468,6 +2468,8 @@ void bas_interpreter(void) void bas_exit(void) { + /* Release resources */ + Auto_destroy(&g_stack); Global_destroy(&g_globals); Program_destroy(&g_program); @@ -2477,6 +2479,10 @@ void bas_exit(void) g_labelstack = (struct labelstack_s *)0; } + /* Close files and devices. NOTE that STDCHANNEL is also close here and + * can no longer be use + */ + FS_closefiles(); FS_close(LPCHANNEL); FS_close(STDCHANNEL); diff --git a/interpreters/bas/main.c b/interpreters/bas/main.c index c772119eb..fce6dd672 100644 --- a/interpreters/bas/main.c +++ b/interpreters/bas/main.c @@ -192,6 +192,12 @@ int bas_main(int argc, char *argv[]) bas_interpreter(); } + /* Terminate the output stream with a newline BEFORE closing devices */ + + FS_putChar(STDCHANNEL, '\n'); + + /* Release resouces and close files and devices */ + bas_exit(); - return (0); + return 0; }