home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-14 | 48.8 KB | 1,610 lines |
- Newsgroups: comp.sources.misc
- From: karl@sugar.neosoft.com (Karl Lehenbauer)
- Subject: v25i077: tcl - tool command language, version 6.1, Part09/33
- Message-ID: <1991Nov14.202859.23738@sparky.imd.sterling.com>
- X-Md4-Signature: a1f8db06c7db444232fb176a01e9bd61
- Date: Thu, 14 Nov 1991 20:28:59 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
- Posting-number: Volume 25, Issue 77
- Archive-name: tcl/part09
- Environment: UNIX
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 9 (of 33)."
- # Contents: tcl6.1/doc/library.man tcl6.1/tcl.h tcl6.1/tclEnv.c
- # tcl6.1/tests/info.test
- # Wrapped by karl@one on Tue Nov 12 19:44:18 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'tcl6.1/doc/library.man' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tcl6.1/doc/library.man'\"
- else
- echo shar: Extracting \"'tcl6.1/doc/library.man'\" \(11210 characters\)
- sed "s/^X//" >'tcl6.1/doc/library.man' <<'END_OF_FILE'
- X'\" Copyright 1991 Regents of the University of California
- X'\" Permission to use, copy, modify, and distribute this
- X'\" documentation for any purpose and without fee is hereby
- X'\" granted, provided that this notice appears in all copies.
- X'\" The University of California makes no representations about
- X'\" the suitability of this material for any purpose. It is
- X'\" provided "as is" without express or implied warranty.
- X'\"
- X'\" $Header: /user6/ouster/tcl/doc/RCS/library.man,v 1.1 91/09/26 11:12:39 ouster Exp $ SPRITE (Berkeley)
- X'
- X.\" The definitions below are for supplemental macros used in Sprite
- X.\" manual entries.
- X.\"
- X.\" .HS name section [date [version]]
- X.\" Replacement for .TH in other man pages. See below for valid
- X.\" section names.
- X.\"
- X.\" .AP type name in/out [indent]
- X.\" Start paragraph describing an argument to a library procedure.
- X.\" type is type of argument (int, etc.), in/out is either "in", "out",
- X.\" or "in/out" to describe whether procedure reads or modifies arg,
- X.\" and indent is equivalent to second arg of .IP (shouldn't ever be
- X.\" needed; use .AS below instead)
- X.\"
- X.\" .AS [type [name]]
- X.\" Give maximum sizes of arguments for setting tab stops. Type and
- X.\" name are examples of largest possible arguments that will be passed
- X.\" to .AP later. If args are omitted, default tab stops are used.
- X.\"
- X.\" .BS
- X.\" Start box enclosure. From here until next .BE, everything will be
- X.\" enclosed in one large box.
- X.\"
- X.\" .BE
- X.\" End of box enclosure.
- X.\"
- X.\" .VS
- X.\" Begin vertical sidebar, for use in marking newly-changed parts
- X.\" of man pages.
- X.\"
- X.\" .VE
- X.\" End of vertical sidebar.
- X.\"
- X.\" .DS
- X.\" Begin an indented unfilled display.
- X.\"
- X.\" .DE
- X.\" End of indented unfilled display.
- X.\"
- X' # Heading for Sprite man pages
- X.de HS
- X.if '\\$2'cmds' .TH \\$1 1 \\$3 \\$4
- X.if '\\$2'lib' .TH \\$1 3 \\$3 \\$4
- X.if '\\$2'tcl' .TH \\$1 3 \\$3 \\$4
- X.if '\\$2'tk' .TH \\$1 3 \\$3 \\$4
- X.if t .wh -1.3i ^B
- X.nr ^l \\n(.l
- X.ad b
- X..
- X' # Start an argument description
- X.de AP
- X.ie !"\\$4"" .TP \\$4
- X.el \{\
- X. ie !"\\$2"" .TP \\n()Cu
- X. el .TP 15
- X.\}
- X.ie !"\\$3"" \{\
- X.ta \\n()Au \\n()Bu
- X\&\\$1 \\fI\\$2\\fP (\\$3)
- X.\".b
- X.\}
- X.el \{\
- X.br
- X.ie !"\\$2"" \{\
- X\&\\$1 \\fI\\$2\\fP
- X.\}
- X.el \{\
- X\&\\fI\\$1\\fP
- X.\}
- X.\}
- X..
- X' # define tabbing values for .AP
- X.de AS
- X.nr )A 10n
- X.if !"\\$1"" .nr )A \\w'\\$1'u+3n
- X.nr )B \\n()Au+15n
- X.\"
- X.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
- X.nr )C \\n()Bu+\\w'(in/out)'u+2n
- X..
- X' # BS - start boxed text
- X' # ^y = starting y location
- X' # ^b = 1
- X.de BS
- X.br
- X.mk ^y
- X.nr ^b 1u
- X.if n .nf
- X.if n .ti 0
- X.if n \l'\\n(.lu\(ul'
- X.if n .fi
- X..
- X' # BE - end boxed text (draw box now)
- X.de BE
- X.nf
- X.ti 0
- X.mk ^t
- X.ie n \l'\\n(^lu\(ul'
- X.el \{\
- X.\" Draw four-sided box normally, but don't draw top of
- X.\" box if the box started on an earlier page.
- X.ie !\\n(^b-1 \{\
- X\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
- X.\}
- X.el \}\
- X\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
- X.\}
- X.\}
- X.fi
- X.br
- X.nr ^b 0
- X..
- X' # VS - start vertical sidebar
- X' # ^Y = starting y location
- X' # ^v = 1 (for troff; for nroff this doesn't matter)
- X.de VS
- X.mk ^Y
- X.ie n 'mc \s12\(br\s0
- X.el .nr ^v 1u
- X..
- X' # VE - end of vertical sidebar
- X.de VE
- X.ie n 'mc
- X.el \{\
- X.ev 2
- X.nf
- X.ti 0
- X.mk ^t
- X\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
- X.sp -1
- X.fi
- X.ev
- X.\}
- X.nr ^v 0
- X..
- X' # Special macro to handle page bottom: finish off current
- X' # box/sidebar if in box/sidebar mode, then invoked standard
- X' # page bottom macro.
- X.de ^B
- X.ev 2
- X'ti 0
- X'nf
- X.mk ^t
- X.if \\n(^b \{\
- X.\" Draw three-sided box if this is the box's first page,
- X.\" draw two sides but no top otherwise.
- X.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
- X.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
- X.\}
- X.if \\n(^v \{\
- X.nr ^x \\n(^tu+1v-\\n(^Yu
- X\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
- X.\}
- X.bp
- X'fi
- X.ev
- X.if \\n(^b \{\
- X.mk ^y
- X.nr ^b 2
- X.\}
- X.if \\n(^v \{\
- X.mk ^Y
- X.\}
- X..
- X' # DS - begin display
- X.de DS
- X.RS
- X.nf
- X.sp
- X..
- X' # DE - end display
- X.de DE
- X.fi
- X.RE
- X.sp .5
- X..
- X.de UL
- X\\$1\l'|0\(ul'\\$2
- X..
- X.HS library tcl
- X.BS
- X.SH NAME
- Xlibrary \- standard library of Tcl procedures
- X.SH SYNOPSIS
- X.VS
- X.nf
- X\fBauto_execok \fIcmd\fR
- X\fBauto_load \fIcmd\fR
- X\fBauto_mkindex \fIdir pattern\fR
- X\fBauto_reset\fR
- X\fBparray \fIarrayName\fR
- X\fBunknown \fIcmd \fR?\fIarg arg ...\fR?
- X.fi
- X.BE
- X
- X.SH INTRODUCTION
- X.PP
- XTcl includes a library of Tcl procedures for commonly-needed functions.
- XThe procedures defined in the Tcl library are generic ones suitable
- Xfor use by many different applications.
- XThe location of the Tcl library is returned by the \fBinfo library\fR
- Xcommand.
- XIn addition to the Tcl library, each application will normally have
- Xits own library of support procedures as well; the location of this
- Xlibrary is normally given by the value of the \fB$appLibrary\fR
- Xglobal variable.
- X.PP
- XTo access the procedures in the Tcl library, an application should
- Xsource the file \fBinit.tcl\fR in the library, for example with
- Xthe Tcl command
- X.DS
- X\fBsource [info library]/init.tcl
- X.DE
- XThis will define the \fBunknown\fR procedure and arrange for the
- Xother procedures to be loaded on-demand using the auto-load
- Xmechanism defined below.
- X
- X.SH "COMMAND PROCEDURES"
- X.PP
- XThe following procedures are provided in the Tcl library:
- X.TP
- X\fBauto_execok \fIcmd\fR
- XDetermines whether there is an executable file by the name \fIcmd\fR.
- XThis command examines the directories in the current search path
- X(given by the PATH enviornment variable) to see if there is an
- Xexecutable file named \fIcmd\fR in any of those directories.
- XIf so, it returns 1; if not it returns 0. \fBAuto_exec\fR
- Xremembers information about previous searches in an array
- Xnamed \fBauto_execs\fR; this avoids the path search in
- Xfuture calls for the same \fIcmd\fR. The command \fBauto_reset\fR
- Xmay be used to force \fBauto_execok\fR to forget its cached
- Xinformation.
- X.TP
- X\fBauto_load \fIcmd\fR
- XThis command attempts to load the definition for a Tcl procedure named
- X\fIcmd\fR.
- XTo do this, it searches an \fIauto-load path\fR, which is a list of
- Xone or more directories.
- XThe auto-load path is given by the global variable \fB$auto_path\fR
- Xif it exists.
- XIf there is no \fB$auto_path\fR variable, then the TCLLIBPATH environment
- Xvariable is used, if it exists.
- XOtherwise the auto-load path consists of just the Tcl library directory.
- XWithin each directory in the auto-load path there must be a file
- X\fBtclIndex\fR that describes the procedures defined in that directory
- Xand the file in which each procedure is defined. The \fBtclIndex\fR
- Xfile should be generated with the \fBauto_mkindex\fR command.
- XIf \fIcmd\fR is found in an index file, then the appropriate
- Xscript is \fBsource\fRd to create the procedure.
- XThe \fBauto_load\fR command returns 1 if the script was successfully
- Xsourced and \fIcmd\fR now exists.
- XThe command returns 0 if there was no index entry for \fIcmd\fR
- Xor if the script didn't actually define \fIcmd\fR (e.g. because
- Xindex information is out of date).
- XIf an error occurs while processing the script, then that error
- Xis returned.
- X\fBAuto_load\fR only reads the index information once and saves it
- Xin the array \fBauto_index\fR; future calls to \fBauto_load\fR
- Xcheck for \fIcmd\fR in the array rather than re-reading the index
- Xfiles.
- XThe cached index information may be deleted with the command
- X\fBauto_reset\fR.
- XThis will force the next \fBauto_load\fR command to reload the
- Xindex database from disk.
- X.TP
- X\fBauto_mkindex \fIdir pattern\fR
- XGenerates an index suitable for use by \fBauto_load\fR.
- XThe command searches \fIdir\fR for all files whose names match
- X\fIpattern\fR (matching is done with the \fBglob\fR command),
- Xgenerates an index of all the Tcl command
- Xprocedures defined in all the matching files, and stores the
- Xindex information in a file named \fBtclIndex\fR in \fIdir\fR.
- XFor example, the command
- X.RS
- X.DS
- X\fBauto_mkindex foo *.tcl\fR
- X.DE
- X.LP
- Xwill read all the \fB.tcl\fR files in subdirectory \fBfoo\fR
- Xand generate a new index file \fBfoo/tclIndex\fR.
- X.PP
- X\fBAuto_mkindex\fR parses the Tcl scripts in a relatively
- Xunsophisticated way: if any line contains the word \fBproc\fR
- Xas its first characters then it is assumed to be a procedure
- Xdefinition and the next word of the line is taken as the
- Xprocedure's name.
- XProcedure definitions that don't appear in this way (e.g. they
- Xhave spaces before the \fBproc\fR) will not be indexed.
- X.RE
- X.TP
- X\fBauto_reset\fR
- XDestroys all the information cached by \fBauto_execok\fR and
- X\fBauto_load\fR.
- XThis information will be re-read from disk the next time it is
- Xneeded.
- X.TP
- X\fBparray \fIarrayName\fR
- XPrints on standard output the names and values of all the elements
- Xin the array \fIarrayName\fR.
- X\fBArrayName\fR must be a global array.
- X.TP
- X\fBunknown \fIcmd \fR?\fIarg arg ...\fR?
- XThis procedure is invoked automatically by the Tcl interpreter
- Xwhenever the name of a command doesn't exist.
- XThe \fBunknown\fR procedure receives as its arguments the
- Xname and arguments of the missing command.
- X\fBUnknown\fR first calls \fBauto_load\fR to load a procedure for
- Xthe command.
- XIf this succeeds, then it executes the original command with its
- Xoriginal arguments.
- XIf the auto-load fails then \fBunknown\fR calls \fBauto_execok\fR
- Xto see if there is an executable file by the name \fIcmd\fR.
- XIf so, it invokes the Tcl \fBexec\fR command
- Xwith \fIcmd\fR and all the \fIargs\fR as arguments.
- XIf \fIcmd\fR can't be auto-executed, \fBunknown\fR checks to see if \fIcmd\fR is
- Xa unique abbreviation for an existing Tcl command.
- XIf so, it expands the command name and executes the command with
- Xthe original arguments.
- XFinally, if none of the above efforts has been able to execute
- Xthe command, \fBunknown\fR generates an error return.
- XIf the global variable \fBauto_noload\fR is defined, then the auto-load
- Xstep is skipped.
- XIf the global variable \fBauto_noexec\fR is defined then the
- Xauto-exec step is skipped.
- XUnder normal circumstances the return value from \fBunknown\fR
- Xis the return value from the command that was eventually
- Xexecuted.
- X
- X.SH "VARIABLES"
- X.PP
- XThe following global variables are defined or used by the procedures in
- Xthe Tcl library:
- X.TP
- X\fBauto_execs\fR
- XUsed by \fBauto_execok\fR to record information about whether
- Xparticular commands exist as executable files.
- X.TP
- X\fBauto_index\fR
- XUsed by \fBauto_load\fR to save the index information read from
- Xdisk.
- X.TP
- X\fBauto_noexec\fR
- XIf set to any value, then \fBunknown\fR will not attempt to auto-exec
- Xany commands.
- X.TP
- X\fBauto_noload\fR
- XIf set to any value, then \fBunknown\fR will not attempt to auto-load
- Xany commands.
- X.TP
- X\fBauto_path\fR
- XIf set, then it must contain a valid Tcl list giving directories to
- Xsearch during auto-load operations.
- X.TP
- X\fBenv(TCLLIBPATH)\fR
- XIf set, then it must contain a valid Tcl list giving directories to
- Xsearch during auto-load operations.
- XThis variable is only used if \fBauto_path\fR is not defined.
- X.TP
- X\fBunknown_active\fR
- XThis variable is set by \fBunknown\fR to indicate that it is active.
- XIt is used to detect errors where \fBunknown\fR recurses on itself
- Xinfinitely.
- XThe variable is unset before \fBunknown\fR returns.
- X
- X.SH KEYWORDS
- Xauto-exec, auto-load, library, unknown
- X.VE
- END_OF_FILE
- if test 11210 -ne `wc -c <'tcl6.1/doc/library.man'`; then
- echo shar: \"'tcl6.1/doc/library.man'\" unpacked with wrong size!
- fi
- # end of 'tcl6.1/doc/library.man'
- fi
- if test -f 'tcl6.1/tcl.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tcl6.1/tcl.h'\"
- else
- echo shar: Extracting \"'tcl6.1/tcl.h'\" \(11364 characters\)
- sed "s/^X//" >'tcl6.1/tcl.h' <<'END_OF_FILE'
- X/*
- X * tcl.h --
- X *
- X * This header file describes the externally-visible facilities
- X * of the Tcl interpreter.
- X *
- X * Copyright 1987-1991 Regents of the University of California
- X * Permission to use, copy, modify, and distribute this
- X * software and its documentation for any purpose and without
- X * fee is hereby granted, provided that the above copyright
- X * notice appear in all copies. The University of California
- X * makes no representations about the suitability of this
- X * software for any purpose. It is provided "as is" without
- X * express or implied warranty.
- X *
- X * $Header: /user6/ouster/tcl/RCS/tcl.h,v 1.76 91/11/05 10:12:30 ouster Exp $ SPRITE (Berkeley)
- X */
- X
- X#ifndef _TCL
- X#define _TCL
- X
- X#define TCL_VERSION "6.1"
- X
- X/*
- X * Definitions that allow this header file to be used either with or
- X * without ANSI C features like function prototypes.
- X */
- X
- X#undef _ANSI_ARGS_
- X#undef const
- X#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus)
- X# define _ANSI_ARGS_(x) x
- X# define CONST const
- X# ifdef __cplusplus
- X# define VARARGS (...)
- X# else
- X# define VARARGS ()
- X# endif
- X#else
- X# define _ANSI_ARGS_(x) ()
- X# define CONST
- X#endif
- X
- X#ifdef __cplusplus
- X# define EXTERN extern "C"
- X#else
- X# define EXTERN extern
- X#endif
- X
- X/*
- X * Miscellaneous declarations (to allow Tcl to be used stand-alone,
- X * without the rest of Sprite).
- X */
- X
- X#ifndef NULL
- X#define NULL 0
- X#endif
- X
- X#ifndef _CLIENTDATA
- Xtypedef int *ClientData;
- X#define _CLIENTDATA
- X#endif
- X
- X/*
- X * Data structures defined opaquely in this module. The definitions
- X * below just provide dummy types. A few fields are made visible in
- X * Tcl_Interp structures, namely those for returning string values.
- X * Note: any change to the Tcl_Interp definition below must be mirrored
- X * in the "real" definition in tclInt.h.
- X */
- X
- Xtypedef struct Tcl_Interp{
- X char *result; /* Points to result string returned by last
- X * command. */
- X void (*freeProc) _ANSI_ARGS_((char *blockPtr));
- X /* Zero means result is statically allocated.
- X * If non-zero, gives address of procedure
- X * to invoke to free the result. Must be
- X * freed by Tcl_Eval before executing next
- X * command. */
- X int errorLine; /* When TCL_ERROR is returned, this gives
- X * the line number within the command where
- X * the error occurred (1 means first line). */
- X} Tcl_Interp;
- X
- Xtypedef int *Tcl_Trace;
- Xtypedef int *Tcl_CmdBuf;
- X
- X/*
- X * When a TCL command returns, the string pointer interp->result points to
- X * a string containing return information from the command. In addition,
- X * the command procedure returns an integer value, which is one of the
- X * following:
- X *
- X * TCL_OK Command completed normally; interp->result contains
- X * the command's result.
- X * TCL_ERROR The command couldn't be completed successfully;
- X * interp->result describes what went wrong.
- X * TCL_RETURN The command requests that the current procedure
- X * return; interp->result contains the procedure's
- X * return value.
- X * TCL_BREAK The command requests that the innermost loop
- X * be exited; interp->result is meaningless.
- X * TCL_CONTINUE Go on to the next iteration of the current loop;
- X * interp->result is meaninless.
- X */
- X
- X#define TCL_OK 0
- X#define TCL_ERROR 1
- X#define TCL_RETURN 2
- X#define TCL_BREAK 3
- X#define TCL_CONTINUE 4
- X
- X#define TCL_RESULT_SIZE 199
- X
- X/*
- X * Procedure types defined by Tcl:
- X */
- X
- Xtypedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData));
- Xtypedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData,
- X Tcl_Interp *interp, int argc, char *argv[]));
- Xtypedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData,
- X Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc,
- X ClientData cmdClientData, int argc, char *argv[]));
- Xtypedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr));
- Xtypedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData,
- X Tcl_Interp *interp, char *name1, char *name2, int flags));
- X
- X/*
- X * Flag values passed to Tcl_Eval (see the man page for details; also
- X * see tclInt.h for additional flags that are only used internally by
- X * Tcl):
- X */
- X
- X#define TCL_BRACKET_TERM 1
- X
- X/*
- X * Flag value passed to Tcl_RecordAndEval to request no evaluation
- X * (record only).
- X */
- X
- X#define TCL_NO_EVAL -1
- X
- X/*
- X * Specil freeProc values that may be passed to Tcl_SetResult (see
- X * the man page for details):
- X */
- X
- X#define TCL_VOLATILE ((Tcl_FreeProc *) -1)
- X#define TCL_STATIC ((Tcl_FreeProc *) 0)
- X#define TCL_DYNAMIC ((Tcl_FreeProc *) free)
- X
- X/*
- X * Flag values passed to variable-related procedures.
- X */
- X
- X#define TCL_GLOBAL_ONLY 1
- X#define TCL_APPEND_VALUE 2
- X#define TCL_LIST_ELEMENT 4
- X#define TCL_NO_SPACE 8
- X#define TCL_TRACE_READS 0x10
- X#define TCL_TRACE_WRITES 0x20
- X#define TCL_TRACE_UNSETS 0x40
- X#define TCL_TRACE_DESTROYED 0x80
- X#define TCL_INTERP_DESTROYED 0x100
- X#define TCL_LEAVE_ERR_MSG 0x200
- X
- X/*
- X * Additional flag passed back to variable watchers. This flag must
- X * not overlap any of the TCL_TRACE_* flags defined above or the
- X * TRACE_* flags defined in tclInt.h.
- X */
- X
- X#define TCL_VARIABLE_UNDEFINED 8
- X
- X/*
- X * The following declarations either map ckalloc and ckfree to
- X * malloc and free, or they map them to procedures with all sorts
- X * of debugging hooks defined in tclCkalloc.c.
- X */
- X
- X#ifdef TCL_MEM_DEBUG
- X
- XEXTERN char * Tcl_DbCkalloc _ANSI_ARGS_((unsigned int size,
- X char *file, int line));
- XEXTERN int Tcl_DbCkfree _ANSI_ARGS_((char *ptr,
- X char *file, int line));
- X# define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
- X# define ckfree(x) Tcl_DbCkfree(x, __FILE__, __LINE__)
- X
- X#else
- X
- X# define ckalloc(x) malloc(x)
- X# define ckfree(x) free(x)
- X
- X#endif /* TCL_MEM_DEBUG */
- X
- X/*
- X * Macro to free up result of interpreter.
- X */
- X
- X#define Tcl_FreeResult(interp) \
- X if ((interp)->freeProc != 0) { \
- X if ((interp)->freeProc == (Tcl_FreeProc *) free) { \
- X ckfree((interp)->result); \
- X } else { \
- X (*(interp)->freeProc)((interp)->result); \
- X } \
- X (interp)->freeProc = 0; \
- X }
- X
- X/*
- X * Exported Tcl procedures:
- X */
- X
- XEXTERN void Tcl_AppendElement _ANSI_ARGS_((Tcl_Interp *interp,
- X char *string, int noSep));
- XEXTERN void Tcl_AppendResult _ANSI_ARGS_(VARARGS);
- XEXTERN char * Tcl_AssembleCmd _ANSI_ARGS_((Tcl_CmdBuf buffer,
- X char *string));
- XEXTERN void Tcl_AddErrorInfo _ANSI_ARGS_((Tcl_Interp *interp,
- X char *message));
- XEXTERN char Tcl_Backslash _ANSI_ARGS_((char *src,
- X int *readPtr));
- XEXTERN char * Tcl_Concat _ANSI_ARGS_((int argc, char **argv));
- XEXTERN int Tcl_ConvertElement _ANSI_ARGS_((char *src,
- X char *dst, int flags));
- XEXTERN Tcl_CmdBuf Tcl_CreateCmdBuf _ANSI_ARGS_((void));
- XEXTERN void Tcl_CreateCommand _ANSI_ARGS_((Tcl_Interp *interp,
- X char *cmdName, Tcl_CmdProc *proc,
- X ClientData clientData,
- X Tcl_CmdDeleteProc *deleteProc));
- XEXTERN Tcl_Interp * Tcl_CreateInterp _ANSI_ARGS_((void));
- XEXTERN int Tcl_CreatePipeline _ANSI_ARGS_((Tcl_Interp *interp,
- X int argc, char **argv, int **pidArrayPtr,
- X int *inPipePtr, int *outPipePtr,
- X int *errFilePtr));
- XEXTERN Tcl_Trace Tcl_CreateTrace _ANSI_ARGS_((Tcl_Interp *interp,
- X int level, Tcl_CmdTraceProc *proc,
- X ClientData clientData));
- XEXTERN void Tcl_DeleteCmdBuf _ANSI_ARGS_((Tcl_CmdBuf buffer));
- XEXTERN int Tcl_DeleteCommand _ANSI_ARGS_((Tcl_Interp *interp,
- X char *cmdName));
- XEXTERN void Tcl_DeleteInterp _ANSI_ARGS_((Tcl_Interp *interp));
- XEXTERN void Tcl_DeleteTrace _ANSI_ARGS_((Tcl_Interp *interp,
- X Tcl_Trace trace));
- XEXTERN void Tcl_DetachPids _ANSI_ARGS_((int numPids, int *pidPtr));
- XEXTERN char * Tcl_ErrnoId _ANSI_ARGS_((void));
- XEXTERN int Tcl_Eval _ANSI_ARGS_((Tcl_Interp *interp, char *cmd,
- X int flags, char **termPtr));
- XEXTERN int Tcl_EvalFile _ANSI_ARGS_((Tcl_Interp *interp,
- X char *fileName));
- XEXTERN int Tcl_ExprBoolean _ANSI_ARGS_((Tcl_Interp *interp,
- X char *string, int *ptr));
- XEXTERN int Tcl_ExprDouble _ANSI_ARGS_((Tcl_Interp *interp,
- X char *string, double *ptr));
- XEXTERN int Tcl_ExprLong _ANSI_ARGS_((Tcl_Interp *interp,
- X char *string, long *ptr));
- XEXTERN int Tcl_ExprString _ANSI_ARGS_((Tcl_Interp *interp,
- X char *string));
- XEXTERN int Tcl_Fork _ANSI_ARGS_((void));
- XEXTERN int Tcl_GetBoolean _ANSI_ARGS_((Tcl_Interp *interp,
- X char *string, int *boolPtr));
- XEXTERN int Tcl_GetDouble _ANSI_ARGS_((Tcl_Interp *interp,
- X char *string, double *doublePtr));
- XEXTERN int Tcl_GetInt _ANSI_ARGS_((Tcl_Interp *interp,
- X char *string, int *intPtr));
- XEXTERN char * Tcl_GetVar _ANSI_ARGS_((Tcl_Interp *interp,
- X char *varName, int flags));
- XEXTERN char * Tcl_GetVar2 _ANSI_ARGS_((Tcl_Interp *interp,
- X char *name1, char *name2, int flags));
- XEXTERN void Tcl_InitHistory _ANSI_ARGS_((Tcl_Interp *interp));
- XEXTERN void Tcl_InitMemory _ANSI_ARGS_((Tcl_Interp *interp));
- XEXTERN char * Tcl_Merge _ANSI_ARGS_((int argc, char **argv));
- XEXTERN char * Tcl_ParseVar _ANSI_ARGS_((Tcl_Interp *interp,
- X char *string, char **termPtr));
- XEXTERN int Tcl_RecordAndEval _ANSI_ARGS_((Tcl_Interp *interp,
- X char *cmd, int flags));
- XEXTERN void Tcl_ResetResult _ANSI_ARGS_((Tcl_Interp *interp));
- X#define Tcl_Return Tcl_SetResult
- XEXTERN int Tcl_ScanElement _ANSI_ARGS_((char *string,
- X int *flagPtr));
- XEXTERN void Tcl_SetErrorCode _ANSI_ARGS_(VARARGS);
- XEXTERN void Tcl_SetResult _ANSI_ARGS_((Tcl_Interp *interp,
- X char *string, Tcl_FreeProc *freeProc));
- XEXTERN char * Tcl_SetVar _ANSI_ARGS_((Tcl_Interp *interp,
- X char *varName, char *newValue, int flags));
- XEXTERN char * Tcl_SetVar2 _ANSI_ARGS_((Tcl_Interp *interp,
- X char *name1, char *name2, char *newValue,
- X int flags));
- XEXTERN char * Tcl_SignalId _ANSI_ARGS_((int sig));
- XEXTERN char * Tcl_SignalMsg _ANSI_ARGS_((int sig));
- XEXTERN int Tcl_SplitList _ANSI_ARGS_((Tcl_Interp *interp,
- X char *list, int *argcPtr, char ***argvPtr));
- XEXTERN int Tcl_StringMatch _ANSI_ARGS_((char *string,
- X char *pattern));
- XEXTERN char * Tcl_TildeSubst _ANSI_ARGS_((Tcl_Interp *interp,
- X char *name));
- XEXTERN int Tcl_TraceVar _ANSI_ARGS_((Tcl_Interp *interp,
- X char *varName, int flags, Tcl_VarTraceProc *proc,
- X ClientData clientData));
- XEXTERN int Tcl_TraceVar2 _ANSI_ARGS_((Tcl_Interp *interp,
- X char *name1, char *name2, int flags,
- X Tcl_VarTraceProc *proc, ClientData clientData));
- XEXTERN char * Tcl_UnixError _ANSI_ARGS_((Tcl_Interp *interp));
- XEXTERN int Tcl_UnsetVar _ANSI_ARGS_((Tcl_Interp *interp,
- X char *varName, int flags));
- XEXTERN int Tcl_UnsetVar2 _ANSI_ARGS_((Tcl_Interp *interp,
- X char *name1, char *name2, int flags));
- XEXTERN void Tcl_UntraceVar _ANSI_ARGS_((Tcl_Interp *interp,
- X char *varName, int flags, Tcl_VarTraceProc *proc,
- X ClientData clientData));
- XEXTERN void Tcl_UntraceVar2 _ANSI_ARGS_((Tcl_Interp *interp,
- X char *name1, char *name2, int flags,
- X Tcl_VarTraceProc *proc, ClientData clientData));
- XEXTERN int Tcl_VarEval _ANSI_ARGS_(VARARGS);
- XEXTERN ClientData Tcl_VarTraceInfo _ANSI_ARGS_((Tcl_Interp *interp,
- X char *varName, int flags,
- X Tcl_VarTraceProc *procPtr,
- X ClientData prevClientData));
- XEXTERN ClientData Tcl_VarTraceInfo2 _ANSI_ARGS_((Tcl_Interp *interp,
- X char *name1, char *name2, int flags,
- X Tcl_VarTraceProc *procPtr,
- X ClientData prevClientData));
- XEXTERN int Tcl_WaitPids _ANSI_ARGS_((int numPids, int *pidPtr,
- X int *statusPtr));
- X
- X#endif /* _TCL */
- END_OF_FILE
- if test 11364 -ne `wc -c <'tcl6.1/tcl.h'`; then
- echo shar: \"'tcl6.1/tcl.h'\" unpacked with wrong size!
- fi
- # end of 'tcl6.1/tcl.h'
- fi
- if test -f 'tcl6.1/tclEnv.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tcl6.1/tclEnv.c'\"
- else
- echo shar: Extracting \"'tcl6.1/tclEnv.c'\" \(11191 characters\)
- sed "s/^X//" >'tcl6.1/tclEnv.c' <<'END_OF_FILE'
- X/*
- X * tclEnv.c --
- X *
- X * Tcl support for environment variables, including a setenv
- X * procedure.
- X *
- X * Copyright 1991 Regents of the University of California
- X * Permission to use, copy, modify, and distribute this
- X * software and its documentation for any purpose and without
- X * fee is hereby granted, provided that this copyright
- X * notice appears in all copies. The University of California
- X * makes no representations about the suitability of this
- X * software for any purpose. It is provided "as is" without
- X * express or implied warranty.
- X */
- X
- X#ifndef lint
- Xstatic char rcsid[] = "$Header: /sprite/src/lib/tcl/RCS/tclEnv.c,v 1.7 91/09/23 11:22:21 ouster Exp $ SPRITE (Berkeley)";
- X#endif /* not lint */
- X
- X#include "tclInt.h"
- X#include "tclUnix.h"
- X
- X/*
- X * The structure below is used to keep track of all of the interpereters
- X * for which we're managing the "env" array. It's needed so that they
- X * can all be updated whenever an environment variable is changed
- X * anywhere.
- X */
- X
- Xtypedef struct EnvInterp {
- X Tcl_Interp *interp; /* Interpreter for which we're managing
- X * the env array. */
- X struct EnvInterp *nextPtr; /* Next in list of all such interpreters,
- X * or zero. */
- X} EnvInterp;
- X
- Xstatic EnvInterp *firstInterpPtr;
- X /* First in list of all managed interpreters,
- X * or NULL if none. */
- X
- Xstatic int environSize = 0; /* Non-zero means that the all of the
- X * environ-related information is malloc-ed
- X * and the environ array itself has this
- X * many total entries allocated to it (not
- X * all may be in use at once). Zero means
- X * that the environment array is in its
- X * original static state. */
- X
- X/*
- X * Declarations for local procedures defined in this file:
- X */
- X
- Xstatic void EnvInit _ANSI_ARGS_((void));
- Xstatic char * EnvTraceProc _ANSI_ARGS_((ClientData clientData,
- X Tcl_Interp *interp, char *name1, char *name2,
- X int flags));
- Xstatic int FindVariable _ANSI_ARGS_((char *name, int *lengthPtr));
- Xvoid setenv _ANSI_ARGS_((char *name, char *value));
- Xvoid unsetenv _ANSI_ARGS_((char *name));
- X
- X/*
- X *----------------------------------------------------------------------
- X *
- X * TclSetupEnv --
- X *
- X * This procedure is invoked for an interpreter to make environment
- X * variables accessible from that interpreter via the "env"
- X * associative array.
- X *
- X * Results:
- X * None.
- X *
- X * Side effects:
- X * The interpreter is added to a list of interpreters managed
- X * by us, so that its view of envariables can be kept consistent
- X * with the view in other interpreters. If this is the first
- X * call to Tcl_SetupEnv, then additional initialization happens,
- X * such as copying the environment to dynamically-allocated space
- X * for ease of management.
- X *
- X *----------------------------------------------------------------------
- X */
- X
- Xvoid
- XTclSetupEnv(interp)
- X Tcl_Interp *interp; /* Interpreter whose "env" array is to be
- X * managed. */
- X{
- X EnvInterp *eiPtr;
- X int i;
- X
- X /*
- X * First, initialize our environment-related information, if
- X * necessary.
- X */
- X
- X if (environSize == 0) {
- X EnvInit();
- X }
- X
- X /*
- X * Next, add the interpreter to the list of those that we manage.
- X */
- X
- X eiPtr = (EnvInterp *) ckalloc(sizeof(EnvInterp));
- X eiPtr->interp = interp;
- X eiPtr->nextPtr = firstInterpPtr;
- X firstInterpPtr = eiPtr;
- X
- X /*
- X * Store the environment variable values into the interpreter's
- X * "env" array, and arrange for us to be notified on future
- X * writes and unsets to that array.
- X */
- X
- X (void) Tcl_UnsetVar2(interp, "env", (char *) NULL, TCL_GLOBAL_ONLY);
- X for (i = 0; ; i++) {
- X char *p, *p2;
- X
- X p = environ[i];
- X if (p == NULL) {
- X break;
- X }
- X for (p2 = p; *p2 != '='; p2++) {
- X /* Empty loop body. */
- X }
- X *p2 = 0;
- X (void) Tcl_SetVar2(interp, "env", p, p2+1, TCL_GLOBAL_ONLY);
- X *p2 = '=';
- X }
- X Tcl_TraceVar2(interp, "env", (char *) NULL,
- X TCL_GLOBAL_ONLY | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
- X EnvTraceProc, (ClientData) NULL);
- X}
- X
- X/*
- X *----------------------------------------------------------------------
- X *
- X * FindVariable --
- X *
- X * Locate the entry in environ for a given name.
- X *
- X * Results:
- X * The return value is the index in environ of an entry with the
- X * name "name", or -1 if there is no such entry. The integer at
- X * *lengthPtr is filled in with the length of name (if a matching
- X * entry is found) or the length of the environ array (if no matching
- X * entry is found).
- X *
- X * Side effects:
- X * None.
- X *
- X *----------------------------------------------------------------------
- X */
- X
- Xstatic int
- XFindVariable(name, lengthPtr)
- X char *name; /* Name of desired environment variable. */
- X int *lengthPtr; /* Used to return length of name (for
- X * successful searches) or number of non-NULL
- X * entries in environ (for unsuccessful
- X * searches). */
- X{
- X int i;
- X register char *p1, *p2;
- X
- X for (i = 0, p1 = environ[i]; p1 != NULL; i++, p1 = environ[i]) {
- X for (p2 = name; *p2 == *p1; p1++, p2++) {
- X /* NULL loop body. */
- X }
- X if ((*p1 == '=') && (*p2 == '\0')) {
- X *lengthPtr = p2-name;
- X return i;
- X }
- X }
- X *lengthPtr = i;
- X return -1;
- X}
- X
- X/*
- X *----------------------------------------------------------------------
- X *
- X * setenv --
- X *
- X * Set an environment variable, replacing an existing value
- X * or creating a new variable if there doesn't exist a variable
- X * by the given name.
- X *
- X * Results:
- X * None.
- X *
- X * Side effects:
- X * The environ array gets updated, as do all of the interpreters
- X * that we manage.
- X *
- X *----------------------------------------------------------------------
- X */
- X
- Xvoid
- Xsetenv(name, value)
- X char *name; /* Name of variable whose value is to be
- X * set. */
- X char *value; /* New value for variable. */
- X{
- X int index, length, nameLength;
- X char *p;
- X EnvInterp *eiPtr;
- X
- X if (environSize == 0) {
- X EnvInit();
- X }
- X
- X /*
- X * Figure out where the entry is going to go. If the name doesn't
- X * already exist, enlarge the array if necessary to make room. If
- X * the name exists, free its old entry.
- X */
- X
- X index = FindVariable(name, &length);
- X if (index == -1) {
- X if ((length+2) > environSize) {
- X char **newEnviron;
- X
- X newEnviron = (char **) ckalloc((unsigned)
- X ((length+5) * sizeof(char *)));
- X memcpy((VOID *) newEnviron, (VOID *) environ,
- X length*sizeof(char *));
- X ckfree((char *) environ);
- X environ = newEnviron;
- X environSize = length+5;
- X }
- X index = length;
- X environ[index+1] = NULL;
- X nameLength = strlen(name);
- X } else {
- X ckfree(environ[index]);
- X nameLength = length;
- X }
- X
- X /*
- X * Create a new entry and enter it into the table.
- X */
- X
- X p = (char *) ckalloc((unsigned) (nameLength + strlen(value) + 2));
- X environ[index] = p;
- X strcpy(p, name);
- X p += nameLength;
- X *p = '=';
- X strcpy(p+1, value);
- X
- X /*
- X * Update all of the interpreters.
- X */
- X
- X for (eiPtr= firstInterpPtr; eiPtr != NULL; eiPtr = eiPtr->nextPtr) {
- X (void) Tcl_SetVar2(eiPtr->interp, "env", name, p+1, TCL_GLOBAL_ONLY);
- X }
- X}
- X
- X/*
- X *----------------------------------------------------------------------
- X *
- X * unsetenv --
- X *
- X * Remove an environment variable, updating the "env" arrays
- X * in all interpreters managed by us.
- X *
- X * Results:
- X * None.
- X *
- X * Side effects:
- X * Interpreters are updated, as is environ.
- X *
- X *----------------------------------------------------------------------
- X */
- X
- Xvoid
- Xunsetenv(name)
- X char *name; /* Name of variable to remove. */
- X{
- X int index, dummy;
- X char **envPtr;
- X EnvInterp *eiPtr;
- X
- X if (environSize == 0) {
- X EnvInit();
- X }
- X
- X /*
- X * Update the environ array.
- X */
- X
- X index = FindVariable(name, &dummy);
- X if (index == -1) {
- X return;
- X }
- X ckfree(environ[index]);
- X for (envPtr = environ+index+1; ; envPtr++) {
- X envPtr[-1] = *envPtr;
- X if (*envPtr == NULL) {
- X break;
- X }
- X }
- X
- X /*
- X * Update all of the interpreters.
- X */
- X
- X for (eiPtr = firstInterpPtr; eiPtr != NULL; eiPtr = eiPtr->nextPtr) {
- X (void) Tcl_UnsetVar2(eiPtr->interp, "env", name, TCL_GLOBAL_ONLY);
- X }
- X}
- X
- X/*
- X *----------------------------------------------------------------------
- X *
- X * EnvTraceProc --
- X *
- X * This procedure is invoked whenever an environment variable
- X * is modified or deleted. It propagates the change to the
- X * "environ" array and to any other interpreters for whom
- X * we're managing an "env" array.
- X *
- X * Results:
- X * Always returns NULL to indicate success.
- X *
- X * Side effects:
- X * Environment variable changes get propagated. If the whole
- X * "env" array is deleted, then we stop managing things for
- X * this interpreter (usually this happens because the whole
- X * interpreter is being deleted).
- X *
- X *----------------------------------------------------------------------
- X */
- X
- X /* ARGSUSED */
- Xstatic char *
- XEnvTraceProc(clientData, interp, name1, name2, flags)
- X ClientData clientData; /* Not used. */
- X Tcl_Interp *interp; /* Interpreter whose "env" variable is
- X * being modified. */
- X char *name1; /* Better be "env". */
- X char *name2; /* Name of variable being modified, or
- X * NULL if whole array is being deleted. */
- X int flags; /* Indicates what's happening. */
- X{
- X /*
- X * First see if the whole "env" variable is being deleted. If
- X * so, just forget about this interpreter.
- X */
- X
- X if (name2 == NULL) {
- X register EnvInterp *eiPtr, *prevPtr;
- X
- X if ((flags & (TCL_TRACE_UNSETS|TCL_TRACE_DESTROYED))
- X != (TCL_TRACE_UNSETS|TCL_TRACE_DESTROYED)) {
- X panic("EnvTraceProc called with confusing arguments");
- X }
- X eiPtr = firstInterpPtr;
- X if (eiPtr->interp == interp) {
- X firstInterpPtr = eiPtr->nextPtr;
- X } else {
- X for (prevPtr = eiPtr, eiPtr = eiPtr->nextPtr; ;
- X prevPtr = eiPtr, eiPtr = eiPtr->nextPtr) {
- X if (eiPtr == NULL) {
- X panic("EnvTraceProc couldn't find interpreter");
- X }
- X if (eiPtr->interp == interp) {
- X prevPtr->nextPtr = eiPtr->nextPtr;
- X break;
- X }
- X }
- X }
- X ckfree((char *) eiPtr);
- X return NULL;
- X }
- X
- X /*
- X * If a value is being set, call setenv to do all of the work.
- X */
- X
- X if (flags & TCL_TRACE_WRITES) {
- X setenv(name2, Tcl_GetVar2(interp, "env", name2, TCL_GLOBAL_ONLY));
- X }
- X
- X if (flags & TCL_TRACE_UNSETS) {
- X unsetenv(name2);
- X }
- X return NULL;
- X}
- X
- X/*
- X *----------------------------------------------------------------------
- X *
- X * EnvInit --
- X *
- X * This procedure is called to initialize our management
- X * of the environ array.
- X *
- X * Results:
- X * None.
- X *
- X * Side effects:
- X * Environ gets copied to malloc-ed storage, so that in
- X * the future we don't have to worry about which entries
- X * are malloc-ed and which are static.
- X *
- X *----------------------------------------------------------------------
- X */
- X
- Xstatic void
- XEnvInit()
- X{
- X char **newEnviron;
- X int i, length;
- X
- X if (environSize != 0) {
- X return;
- X }
- X for (length = 0; environ[length] != NULL; length++) {
- X /* Empty loop body. */
- X }
- X environSize = length+5;
- X newEnviron = (char **) ckalloc((unsigned)
- X (environSize * sizeof(char *)));
- X for (i = 0; i < length; i++) {
- X newEnviron[i] = (char *) ckalloc((unsigned) (strlen(environ[i]) + 1));
- X strcpy(newEnviron[i], environ[i]);
- X }
- X newEnviron[length] = NULL;
- X environ = newEnviron;
- X}
- END_OF_FILE
- if test 11191 -ne `wc -c <'tcl6.1/tclEnv.c'`; then
- echo shar: \"'tcl6.1/tclEnv.c'\" unpacked with wrong size!
- fi
- # end of 'tcl6.1/tclEnv.c'
- fi
- if test -f 'tcl6.1/tests/info.test' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tcl6.1/tests/info.test'\"
- else
- echo shar: Extracting \"'tcl6.1/tests/info.test'\" \(11222 characters\)
- sed "s/^X//" >'tcl6.1/tests/info.test' <<'END_OF_FILE'
- X# Commands covered: info
- X#
- X# This file contains a collection of tests for one or more of the Tcl
- X# built-in commands. Sourcing this file into Tcl runs the tests and
- X# generates output for errors. No output means no errors were found.
- X#
- X# Copyright 1991 Regents of the University of California
- X# Permission to use, copy, modify, and distribute this
- X# software and its documentation for any purpose and without
- X# fee is hereby granted, provided that this copyright notice
- X# appears in all copies. The University of California makes no
- X# representations about the suitability of this software for any
- X# purpose. It is provided "as is" without express or implied
- X# warranty.
- X#
- X# $Header: /sprite/src/lib/tcl/tests/RCS/info.test,v 1.10 91/09/23 13:06:05 ouster Exp $ (Berkeley)
- X
- Xif {[string compare test [info procs test]] == 1} then {source defs}
- X
- Xtest info-1.1 {info args option} {
- X proc t1 {a bbb c} {return foo}
- X info args t1
- X} {a bbb c}
- Xtest info-1.2 {info args option} {
- X proc t1 {{a default1} {bbb default2} {c default3} args} {return foo}
- X info a t1
- X} {a bbb c args}
- Xtest info-1.3 {info args option} {
- X proc t1 "" {return foo}
- X info args t1
- X} {}
- Xtest info-1.4 {info args option} {
- X catch {rename t1 {}}
- X list [catch {info args t1} msg] $msg
- X} {1 {"t1" isn't a procedure}}
- Xtest info-1.5 {info args option} {
- X list [catch {info args set} msg] $msg
- X} {1 {"set" isn't a procedure}}
- X
- Xtest info-2.1 {info body option} {
- X proc t1 {} {body of t1}
- X info body t1
- X} {body of t1}
- Xtest info-2.2 {info body option} {
- X list [catch {info body set} msg] $msg
- X} {1 {"set" isn't a procedure}}
- Xtest info-2.3 {info body option} {
- X list [catch {info args set 1} msg] $msg
- X} {1 {wrong # args: should be "info args procname"}}
- X
- Xtest info-3.1 {info cmdcount option} {
- X set x [info cmdcount]
- X set y 12345
- X set z [info cm]
- X expr $z-$x
- X} 3
- Xtest info-3.2 {info body option} {
- X list [catch {info cmdcount 1} msg] $msg
- X} {1 {wrong # args: should be "info cmdcount"}}
- X
- Xtest info-4.1 {info commands option} {
- X proc t1 {} {}
- X proc t2 {} {}
- X set x " [info commands] "
- X list [string match {* t1 *} $x] [string match {* t2 *} $x] \
- X [string match {* set *} $x] [string match {* list *} $x]
- X} {1 1 1 1}
- Xtest info-4.2 {info commands option} {
- X proc t1 {} {}
- X rename t1 {}
- X set x [info co]
- X string match {* t1 *} $x
- X} 0
- Xtest info-4.3 {info commands option} {
- X proc _t1_ {} {}
- X proc _t2_ {} {}
- X info commands _t1_
- X} _t1_
- Xtest info-4.4 {info commands option} {
- X proc _t1_ {} {}
- X proc _t2_ {} {}
- X lsort [info commands _t*]
- X} {_t1_ _t2_}
- Xcatch {rename _t1_ {}}
- Xcatch {rename _t2_ {}}
- Xtest info-4.5 {info commands option} {
- X list [catch {info commands a b} msg] $msg
- X} {1 {wrong # args: should be "info commands [pattern]"}}
- X
- Xtest info-5.1 {info default option} {
- X proc t1 {a b {c d} {e "long default value"}} {}
- X info default t1 a value
- X} 0
- Xtest info-5.2 {info default option} {
- X proc t1 {a b {c d} {e "long default value"}} {}
- X set value 12345
- X info d t1 a value
- X set value
- X} {}
- Xtest info-5.3 {info default option} {
- X proc t1 {a b {c d} {e "long default value"}} {}
- X info default t1 c value
- X} 1
- Xtest info-5.4 {info default option} {
- X proc t1 {a b {c d} {e "long default value"}} {}
- X set value 12345
- X info default t1 c value
- X set value
- X} d
- Xtest info-5.5 {info default option} {
- X proc t1 {a b {c d} {e "long default value"}} {}
- X set value 12345
- X set x [info default t1 e value]
- X list $x $value
- X} {1 {long default value}}
- Xtest info-5.6 {info default option} {
- X list [catch {info default a b} msg] $msg
- X} {1 {wrong # args: should be "info default procname arg varname"}}
- Xtest info-5.7 {info default option} {
- X list [catch {info default _nonexistent_ a b} msg] $msg
- X} {1 {"_nonexistent_" isn't a procedure}}
- Xtest info-5.8 {info default option} {
- X proc t1 {a b} {}
- X list [catch {info default t1 x value} msg] $msg
- X} {1 {procedure "t1" doesn't have an argument "x"}}
- Xtest info-5.9 {info default option} {
- X catch {unset a}
- X set a(0) 88
- X proc t1 {a b} {}
- X list [catch {info default t1 a a} msg] $msg
- X} {1 {couldn't store default value in variable "a"}}
- Xtest info-5.10 {info default option} {
- X catch {unset a}
- X set a(0) 88
- X proc t1 {{a 18} b} {}
- X list [catch {info default t1 a a} msg] $msg
- X} {1 {couldn't store default value in variable "a"}}
- Xcatch {unset a}
- X
- Xtest info-6.1 {info exists option} {
- X set value foo
- X info exists value
- X} 1
- Xcatch {unset _nonexistent_}
- Xtest info-6.2 {info exists option} {
- X info exists _nonexistent_
- X} 0
- Xtest info-6.3 {info exists option} {
- X proc t1 {x} {return [info exists x]}
- X t1 2
- X} 1
- Xtest info-6.4 {info exists option} {
- X proc t1 {x} {
- X global _nonexistent_
- X return [info exists _nonexistent_]
- X }
- X t1 2
- X} 0
- Xtest info-6.5 {info exists option} {
- X proc t1 {x} {
- X set y 47
- X return [info exists y]
- X }
- X t1 2
- X} 1
- Xtest info-6.6 {info exists option} {
- X proc t1 {x} {return [info exists value]}
- X t1 2
- X} 0
- Xtest info-6.7 {info exists option} {
- X catch {unset x}
- X set x(2) 44
- X list [info exists x] [info exists x(1)] [info exists x(2)]
- X} {1 0 1}
- Xcatch {unset x}
- Xtest info-6.8 {info exists option} {
- X list [catch {info exists} msg] $msg
- X} {1 {wrong # args: should be "info exists varName"}}
- Xtest info-6.9 {info exists option} {
- X list [catch {info exists 1 2} msg] $msg
- X} {1 {wrong # args: should be "info exists varName"}}
- X
- Xtest info-7.1 {info globals option} {
- X set x 1
- X set y 2
- X set value 23
- X set a " [info globals] "
- X list [string match {* x *} $a] [string match {* y *} $a] \
- X [string match {* value *} $a] [string match {* _foobar_ *} $a]
- X} {1 1 1 0}
- Xtest info-7.2 {info globals option} {
- X set _xxx1 1
- X set _xxx2 2
- X lsort [info g _xxx*]
- X} {_xxx1 _xxx2}
- Xtest info-7.3 {info globals option} {
- X list [catch {info globals 1 2} msg] $msg
- X} {1 {wrong # args: should be "info globals [pattern]"}}
- X
- Xtest info-8.1 {info level option} {
- X info level
- X} 0
- Xtest info-8.2 {info level option} {
- X proc t1 {a b} {
- X set x [info le]
- X set y [info level 1]
- X list $x $y
- X }
- X t1 146 testString
- X} {1 {t1 146 testString}}
- Xtest info-8.3 {info level option} {
- X proc t1 {a b} {
- X t2 [expr $a*2] $b
- X }
- X proc t2 {x y} {
- X list [info level] [info level 1] [info level 2] [info level -1] \
- X [info level 0]
- X }
- X t1 146 {a {b c} {{{c}}}}
- X} {2 {t1 146 {a {b c} {{{c}}}}} {t2 292 {a {b c} {{{c}}}}} {t1 146 {a {b c} {{{c}}}}} {t2 292 {a {b c} {{{c}}}}}}
- Xtest info-8.4 {info level option} {
- X proc t1 {} {
- X set x [info level]
- X set y [info level 1]
- X list $x $y
- X }
- X t1
- X} {1 t1}
- Xtest info-8.5 {info level option} {
- X list [catch {info level 1 2} msg] $msg
- X} {1 {wrong # args: should be "info level [number]"}}
- Xtest info-8.6 {info level option} {
- X list [catch {info level 123a} msg] $msg
- X} {1 {expected integer but got "123a"}}
- Xtest info-8.7 {info level option} {
- X list [catch {info level 0} msg] $msg
- X} {1 {bad level "0"}}
- Xtest info-8.8 {info level option} {
- X proc t1 {} {info level -1}
- X list [catch {t1} msg] $msg
- X} {1 {bad level "-1"}}
- Xtest info-8.9 {info level option} {
- X proc t1 {x} {info level $x}
- X list [catch {t1 -3} msg] $msg
- X} {1 {bad level "-3"}}
- X
- Xtest info-9.1 {info library option} {
- X list [catch {info library x} msg] $msg
- X} {1 {wrong # args: should be "info library"}}
- X
- X# The following check can only be done at Berkeley, where the exact
- X# location of the library is known.
- X
- Xif {[glob ~] == "/users/ouster"} {
- X test info-9.2 {info library option} {
- X info li
- X } /sprite/lib/tcl
- X}
- X
- Xtest info-10.1 {info locals option} {
- X set a 22
- X proc t1 {x y} {
- X set b 13
- X set c testing
- X global a
- X return [info locals]
- X }
- X lsort [t1 23 24]
- X} {b c x y}
- Xtest info-10.2 {info locals option} {
- X proc t1 {x y} {
- X set xx1 2
- X set xx2 3
- X set y 4
- X return [info lo x*]
- X }
- X lsort [t1 2 3]
- X} {x xx1 xx2}
- Xtest info-10.3 {info locals option} {
- X list [catch {info locals 1 2} msg] $msg
- X} {1 {wrong # args: should be "info locals [pattern]"}}
- Xtest info-10.4 {info locals option} {
- X info locals
- X} {}
- Xtest info-10.5 {info locals option} {
- X proc t1 {} {return [info locals]}
- X t1
- X} {}
- X
- Xtest info-11.1 {info procs option} {
- X proc t1 {} {}
- X proc t2 {} {}
- X set x " [info procs] "
- X list [string match {* t1 *} $x] [string match {* t2 *} $x] \
- X [string match {* _undefined_ *} $x]
- X} {1 1 0}
- Xtest info-11.2 {info procs option} {
- X proc _tt1 {} {}
- X proc _tt2 {} {}
- X lsort [info p _tt*]
- X} {_tt1 _tt2}
- Xcatch {rename _tt1 {}}
- Xcatch {rename _tt2 {}}
- Xtest info-11.3 {info procs option} {
- X list [catch {info procs 2 3} msg] $msg
- X} {1 {wrong # args: should be "info procs [pattern]"}}
- X
- Xtest info-12.1 {info script option} {
- X list [catch {info script x} msg] $msg
- X} {1 {wrong # args: should be "info script"}}
- Xtest info-12.2 {info script option} {
- X file tail [info s]
- X} info.test
- Xcatch {exec rm -f gorp.info}
- Xexec cat > gorp.info << "info script\n"
- Xtest info-12.3 {info script option} {
- X list [source gorp.info] [file tail [info script]]
- X} {gorp.info info.test}
- Xtest info-12.4 {resetting "info script" after errors} {
- X catch {source ~_nobody_/foo}
- X file tail [info script]
- X} {info.test}
- Xtest info-12.5 {resetting "info script" after errors} {
- X catch {source _nonexistent_}
- X file tail [info script]
- X} {info.test}
- Xexec rm -f gorp.info
- X
- Xtest info-13.1 {info tclversion option} {
- X set x [info tclversion]
- X scan $x "%d.%d%c" a b c
- X} 2
- Xtest info-13.2 {info tclversion option} {
- X list [catch {info t 2} msg] $msg
- X} {1 {wrong # args: should be "info tclversion"}}
- X
- Xtest info-14.1 {info vars option} {
- X set a 1
- X set b 2
- X proc t1 {x y} {
- X global a b
- X set c 33
- X return [info vars]
- X }
- X lsort [t1 18 19]
- X} {a b c x y}
- Xtest info-14.2 {info vars option} {
- X set xxx1 1
- X set xxx2 2
- X proc t1 {xxa y} {
- X global xxx1 xxx2
- X set c 33
- X return [info vars x*]
- X }
- X lsort [t1 18 19]
- X} {xxa xxx1 xxx2}
- Xtest info-14.3 {info vars option} {
- X lsort [info vars]
- X} [lsort [info globals]]
- Xtest info-14.4 {info vars option} {
- X list [catch {info vars a b} msg] $msg
- X} {1 {wrong # args: should be "info vars [pattern]"}}
- X
- Xtest info-15.1 {miscellaneous error conditions} {
- X list [catch {info} msg] $msg
- X} {1 {wrong # args: should be "info option ?arg arg ...?"}}
- Xtest info-15.2 {miscellaneous error conditions} {
- X list [catch {info gorp} msg] $msg
- X} {1 {bad option "gorp": should be args, body, commands, cmdcount, default, \
- Xexists, globals, level, library, locals, procs, script, tclversion, or vars}}
- Xtest info-15.3 {miscellaneous error conditions} {
- X list [catch {info c} msg] $msg
- X} {1 {bad option "c": should be args, body, commands, cmdcount, default, \
- Xexists, globals, level, library, locals, procs, script, tclversion, or vars}}
- Xtest info-15.4 {miscellaneous error conditions} {
- X list [catch {info l} msg] $msg
- X} {1 {bad option "l": should be args, body, commands, cmdcount, default, \
- Xexists, globals, level, library, locals, procs, script, tclversion, or vars}}
- END_OF_FILE
- if test 11222 -ne `wc -c <'tcl6.1/tests/info.test'`; then
- echo shar: \"'tcl6.1/tests/info.test'\" unpacked with wrong size!
- fi
- # end of 'tcl6.1/tests/info.test'
- fi
- echo shar: End of archive 9 \(of 33\).
- cp /dev/null ark9isdone
- MISSING=""
- for I in 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 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 33 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-