diff -uNr a/tinyscheme/scheme-private.h b/tinyscheme/scheme-private.h --- a/tinyscheme/scheme-private.h cfd3ed45f7a9fd06fc15908f04d951f3c5e6d4bdf67f0d34a05dbb62dd4948952f771071f0baadb050c3094ad20ba58042c677585c5ee6988e6725e227934fe2 +++ b/tinyscheme/scheme-private.h c74450e18ab91f7c226108e76075162d2dd9b111b10d42af58fbfe5c2f18c71667e42cd865138daa7339bacf158411642d62e742b208aa5133316b879081bb90 @@ -26,6 +26,7 @@ union { struct { FILE *file; + int interactive; int closeit; #if SHOW_ERROR_LINE int curr_line; diff -uNr a/tinyscheme/scheme.c b/tinyscheme/scheme.c --- a/tinyscheme/scheme.c ef5203068d238dba559384accc5655416fc64845ba7960c1cf65965148ebead9064596006322dffd0db24fefb7c0e9273d10aacfdc52fba42156ecebfaf85077 +++ b/tinyscheme/scheme.c 6fd96891d2f0c28183f034b595636c7d53fa0867354702c6d9b72117c6203ddd205ac1b3a9572976f4e451345ad3eb2df538be8391280276879294c9e42145e1 @@ -13,13 +13,11 @@ */ #define _SCHEME_SOURCE + #include "scheme-private.h" -#ifndef WIN32 -# include -#endif -#ifdef WIN32 -#define snprintf _snprintf -#endif +#include +#include + #if USE_MATH # include #endif @@ -35,6 +33,8 @@ # endif #endif +const char* tiny_scheme_version = PACKAGE_VERSION; + /* Used for documentation purposes, to signal functions in 'interface' */ #define INTERFACE @@ -1359,7 +1359,7 @@ } static int file_interactive(scheme *sc) { - return sc->file_i==0 && sc->load_stack[0].rep.stdio.file==stdin + return sc->file_i==0 && sc->load_stack[0].rep.stdio.interactive /* sc->load_stack[0].rep.stdio.file==stdin */ && sc->inport->_object._port->kind&port_file; } @@ -1380,6 +1380,7 @@ } pt=port_rep_from_file(sc,f,prop); pt->rep.stdio.closeit=1; + pt->rep.stdio.interactive=0; #if SHOW_ERROR_LINE if(fn) @@ -1410,6 +1411,7 @@ pt->kind = port_file | prop; pt->rep.stdio.file = f; pt->rep.stdio.closeit = 0; + pt->rep.stdio.interactive=sc->interactive_repl; return pt; } @@ -1565,6 +1567,8 @@ port *pt=sc->outport->_object._port; if(pt->kind&port_file) { fputs(s,pt->rep.stdio.file); + if( pt->rep.stdio.interactive ) + fflush( pt->rep.stdio.file ); } else { for(;*s;s++) { if(pt->rep.string.curr!=pt->rep.string.past_the_end) { @@ -4635,6 +4639,9 @@ int i, n=sizeof(dispatch_table)/sizeof(dispatch_table[0]); pointer x; + /* fix unitialized free under Mac OS X */ + memset( sc->load_stack, 0, sizeof(port) * MAXFIL ); + num_zero.is_fixnum=1; num_zero.value.ivalue=0; num_one.is_fixnum=1; @@ -4801,15 +4808,17 @@ { scheme_load_named_file(sc,fin,0); } void scheme_load_named_file(scheme *sc, FILE *fin, const char *filename) { + int interactive_repl = sc->interactive_repl && !filename; dump_stack_reset(sc); sc->envir = sc->global_env; sc->file_i=0; sc->load_stack[0].kind=port_input|port_file; sc->load_stack[0].rep.stdio.file=fin; + sc->load_stack[0].rep.stdio.interactive=interactive_repl; sc->loadport=mk_port(sc,sc->load_stack); sc->retcode=0; - if(fin==stdin) { - sc->interactive_repl=1; + if(interactive_repl) { + sc->interactive_repl=interactive_repl; } #if SHOW_ERROR_LINE