X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=tclmain.c;h=c782cf45b73234e7ad8be6de1fe5c7d25819dcf2;hb=5ab718625d35ca64c34d9962427feeaaa1b00086;hp=70d0db1662a7124ecea6267e1751d4ef76700c15;hpb=b018d91ad37afe044cfb7a32874ea54bf4c4b7f2;p=ir-tcl-moved-to-github.git diff --git a/tclmain.c b/tclmain.c index 70d0db1..c782cf4 100644 --- a/tclmain.c +++ b/tclmain.c @@ -2,7 +2,10 @@ * IR toolkit for tcl/tk * (c) Index Data 1995 * - * $Id: tclmain.c,v 1.2 1995-03-08 07:28:37 adam Exp $ + * $Log: tclmain.c,v $ + * Revision 1.4 1995-03-17 07:50:31 adam + * Headers have changed a little. + * */ #include @@ -35,26 +38,22 @@ int main (int argc, char **argv) int code; interp = Tcl_CreateInterp(); + Tcl_SetVar (interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); + if (argc == 2) + fileName = argv[1]; - if (argc != 2) - { - fprintf (stderr, "Script file expected\n"); - exit (1); - } - fileName = argv[1]; - if (fileName == NULL) - { - fprintf (stderr, "No filename specified\n"); - exit (1); - } if (Tcl_AppInit(interp) != TCL_OK) { fprintf(stderr, "Tcl_AppInit failed: %s\n", interp->result); } - code = Tcl_EvalFile (interp, fileName); - if (*interp->result != 0) - printf ("%s\n", interp->result); - if (code != TCL_OK) - exit (1); + if (fileName) + { + code = Tcl_EvalFile (interp, fileName); + if (*interp->result != 0) + printf ("%s\n", interp->result); + if (code != TCL_OK) + exit (1); + } + Tcl_SetVar (interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY); tcl_mainloop (interp); exit (0); } @@ -110,7 +109,10 @@ void tcl_mainloop (Tcl_Interp *interp) { int code = Tcl_Eval (interp, Tcl_DStringValue (&command)); Tcl_DStringFree (&command); - printf ("[RES:%s]\n", interp->result); + if (code) + printf ("[ERR:%s]\n", interp->result); + else + printf ("[RES:%s]\n", interp->result); printf ("[TCL]"); fflush (stdout); } }