Overview
| Artifact ID: | 765379560a34988e60a33c6861154fa3bfe096fc |
|---|---|
| Ticket: | 3307281fffffffffffffffffffffffffffffffff |
| Date: | 2011-05-25 12:14:34 |
| User: | anonymous |
| Artifact Attached: | f815ee9a9fe50724cd243dced252ff6dd4fdf109 |
| Filename: | tout5.c |
| Description: | reduced test. |
Content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39#include <tcl.h> char hard_coded_script [] = "\ puts \"initializing\"\n\ \n\ proc doit_ok {} {\n\ puts stdout \"proc doit_ok called (this will get redirected).\"\n\ }\n\ proc doit_notok {} {\n\ puts \"proc doit_notok called (this wont get redirected).\"\n\ }\n"; int Tcl_AppInit(Tcl_Interp* interp) { Tcl_Channel old_stdout = Tcl_GetStdChannel(TCL_STDOUT); Tcl_Eval(interp, hard_coded_script); Tcl_Channel ch = Tcl_OpenFileChannel(interp, "toutdemo.txt", "w", 0644); Tcl_RegisterChannel(interp, ch); Tcl_SetStdChannel(ch, TCL_STDOUT); // this output gets redirected. // this has 'stdout' listed as file handle. Tcl_Eval(interp, "doit_ok"); // this output should also get redirected, but it doesn't. // this has puts without 'stdout' as file handle Tcl_Eval(interp, "doit_notok"); Tcl_SetStdChannel(old_stdout, TCL_STDOUT); Tcl_Eval(interp, "puts {now exit this using ^D and cat toutdemo.txt.}"); return TCL_OK; } int main(int argc, char* argv[]) { Tcl_Main(argc, argv, Tcl_AppInit); return 0; }
