]>
git.zerfleddert.de Git - micropolis/blob - src/tcl/tcltest.c
fd61f4054b98f4a4b8d9c7d580b30bbceebe0086
6 * Copyright 1987-1991 Regents of the University of California
9 * Permission to use, copy, modify, and distribute this
10 * software and its documentation for any purpose and without
11 * fee is hereby granted, provided that the above copyright
12 * notice appears in all copies. The University of California
13 * makes no representations about the suitability of this
14 * software for any purpose. It is provided "as is" without
15 * express or implied warranty.
19 static char rcsid
[] = "$Header: /user6/ouster/tcl/tclTest/RCS/tclTest.c,v 1.21 92/01/19 14:15:27 ouster Exp $ SPRITE (Berkeley)";
28 extern int Tcl_DumpActiveMemory();
36 "if [file exists [info library]/init.tcl] {source [info library]/init.tcl}";
40 cmdCheckmem(clientData
, interp
, argc
, argv
)
41 ClientData clientData
;
47 Tcl_AppendResult(interp
, "wrong # args: should be \"", argv
[0],
48 " fileName\"", (char *) NULL
);
51 strcpy(dumpFile
, argv
[1]);
58 cmdEcho(clientData
, interp
, argc
, argv
)
59 ClientData clientData
;
67 if (argv
[i
] == NULL
) {
70 sprintf(interp
->result
,
71 "argument list wasn't properly NULL-terminated in \"%s\" command",
79 fputs(argv
[i
], stdout
);
91 char line
[1000], *cmd
;
92 int result
, gotPartial
;
94 interp
= Tcl_CreateInterp();
96 Tcl_InitMemory(interp
);
98 Tcl_CreateCommand(interp
, "echo", cmdEcho
, (ClientData
) "echo",
99 (Tcl_CmdDeleteProc
*) NULL
);
100 Tcl_CreateCommand(interp
, "checkmem", cmdCheckmem
, (ClientData
) 0,
101 (Tcl_CmdDeleteProc
*) NULL
);
102 buffer
= Tcl_CreateCmdBuf();
103 #ifndef TCL_GENERIC_ONLY
104 result
= Tcl_Eval(interp
, initCmd
, 0, (char **) NULL
);
105 if (result
!= TCL_OK
) {
106 printf("%s\n", interp
->result
);
118 if (fgets(line
, 1000, stdin
) == NULL
) {
124 cmd
= Tcl_AssembleCmd(buffer
, line
);
131 result
= Tcl_RecordAndEval(interp
, cmd
, 0);
132 if (result
== TCL_OK
) {
133 if (*interp
->result
!= 0) {
134 printf("%s\n", interp
->result
);
137 Tcl_DeleteInterp(interp
);
138 Tcl_DeleteCmdBuf(buffer
);
140 Tcl_DumpActiveMemory(dumpFile
);
145 if (result
== TCL_ERROR
) {
148 printf("Error %d", result
);
150 if (*interp
->result
!= 0) {
151 printf(": %s\n", interp
->result
);