summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorstanton <stanton>1998-09-21 23:39:52 (GMT)
committerstanton <stanton>1998-09-21 23:39:52 (GMT)
commit494c2de3a748b449c69ce322a1a741f5a31fd4d5 (patch)
treec3ece48c0ae3f4ba54787e0e8e729b65752ef3f9 /doc
parent7a698c0488d99c0af42022714638ae1ba2afaa49 (diff)
downloadtcl-494c2de3a748b449c69ce322a1a741f5a31fd4d5.zip
tcl-494c2de3a748b449c69ce322a1a741f5a31fd4d5.tar.gz
tcl-494c2de3a748b449c69ce322a1a741f5a31fd4d5.tar.bz2
Added contents of Tcl 8.1a2
Diffstat (limited to 'doc')
-rw-r--r--doc/Backslash.330
-rw-r--r--doc/ByteArrObj.391
-rw-r--r--doc/CrtChannel.346
-rw-r--r--doc/CrtObjCmd.319
-rw-r--r--doc/Encoding.3464
-rw-r--r--doc/Eval.3190
-rw-r--r--doc/EvalObj.391
-rw-r--r--doc/Exit.346
-rw-r--r--doc/GetIndex.331
-rw-r--r--doc/ObjSetVar.3162
-rw-r--r--doc/Object.311
-rw-r--r--doc/OpenFileChnl.3325
-rw-r--r--doc/ParseCmd.3426
-rw-r--r--doc/SaveResult.365
-rw-r--r--doc/SetVar.3194
-rw-r--r--doc/StringObj.332
-rw-r--r--doc/Tcl.n66
-rw-r--r--doc/Thread.397
-rw-r--r--doc/ToUpper.390
-rw-r--r--doc/TraceVar.342
-rw-r--r--doc/Translate.38
-rw-r--r--doc/Utf.3160
-rw-r--r--doc/binary.n2
-rw-r--r--doc/exec.n17
-rw-r--r--doc/fconfigure.n194
-rw-r--r--doc/glob.n19
-rw-r--r--doc/man.macros4
-rw-r--r--doc/pkgMkIndex.n39
-rw-r--r--doc/regexp.n555
-rw-r--r--doc/resource.n4
-rw-r--r--doc/safe.n5
31 files changed, 2727 insertions, 798 deletions
diff --git a/doc/Backslash.3 b/doc/Backslash.3
index e7ac1f7..8823e41 100644
--- a/doc/Backslash.3
+++ b/doc/Backslash.3
@@ -5,10 +5,10 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) Backslash.3 1.16 96/03/25 19:57:09
+'\" SCCS: @(#) Backslash.3 1.17 97/10/15 10:16:29
'\"
.so man.macros
-.TH Tcl_Backslash 3 "" Tcl "Tcl Library Procedures"
+.TH Tcl_Backslash 3 "8.1" Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_Backslash \- parse a backslash sequence
@@ -30,16 +30,24 @@ the backslash character.
.SH DESCRIPTION
.PP
-This is a utility procedure used by several of the Tcl
-commands. It parses a backslash sequence and returns
-the single character corresponding to the sequence.
-\fBTcl_Backslash\fR modifies \fI*countPtr\fR to contain the number
-of characters in the backslash sequence.
+.VS 8.1
+The use of \fBTcl_Backslash\fR is deprecated in favor of
+\fBTcl_UtfBackslash\fR.
.PP
-See the Tcl manual entry for information on the valid
-backslash sequences.
-All of the sequences described in the Tcl
-manual entry are supported by \fBTcl_Backslash\fR.
+This is a utility procedure provided for backwards compatibilty with
+non-internationalized Tcl extensions. It parses a backslash sequence and
+returns the low byte of the Unicode character corresponding to the sequence.
+.VE
+\fBTcl_Backslash\fR modifies \fI*countPtr\fR to contain the number of
+characters in the backslash sequence.
+.PP
+See the Tcl manual entry for information on the valid backslash sequences.
+All of the sequences described in the Tcl manual entry are supported by
+\fBTcl_Backslash\fR.
+.VS 8.1 br
+.SH "SEE ALSO"
+Tcl(n), Tcl_UtfBackslash(3)
+.VE
.SH KEYWORDS
backslash, parse
diff --git a/doc/ByteArrObj.3 b/doc/ByteArrObj.3
new file mode 100644
index 0000000..ccc304d
--- /dev/null
+++ b/doc/ByteArrObj.3
@@ -0,0 +1,91 @@
+'\"
+'\" Copyright (c) 1997 Sun Microsystems, Inc.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+'\" SCCS: @(#) ByteArrObj.3 1.2 97/10/20 15:29:23
+'\"
+.so man.macros
+.TH Tcl_ByteArrayObj 3 8.1 Tcl "Tcl Library Procedures"
+.BS
+.SH NAME
+Tcl_NewByteArrayObj, Tcl_SetByteArrayObj, Tcl_GetByteArrayFromObj, Tcl_SetByteArrayLength \- manipulate Tcl objects as a arrays of bytes
+.SH SYNOPSIS
+.nf
+\fB#include <tcl.h>\fR
+.sp
+Tcl_Obj *
+\fBTcl_NewByteArrayObj\fR(\fIbytes, length\fR)
+.sp
+void
+\fBTcl_SetByteArrayObj\fR(\fIobjPtr, bytes, length\fR)
+.sp
+unsigned char *
+\fBTcl_GetByteArrayFromObj\fR(\fIobjPtr, lengthPtr\fR)
+.sp
+unsigned char *
+\fBTcl_SetByteArrayLength\fR(\fIobjPtr, length\fR)
+.SH ARGUMENTS
+.AS "unsigned char" *lengthPtr in/out
+.AP "unsigned char" *bytes in
+The array of bytes used to initialize or set a byte-array object.
+.AP int length in
+The length of the array of bytes. It must be >= 0.
+.AP Tcl_Obj *objPtr in/out
+For \fBTcl_SetByteArrayObj\fR, this points to the object to be converted to
+byte-array type. For \fBTcl_GetByteArrayFromObj\fR and
+\fBTcl_SetByteArrayLength\fR, this points to the object from which to get
+the byte-array value; if \fIobjPtr\fR does not already point to a byte-array
+object, it will be converted to one.
+.AP int *lengthPtr out
+If non-NULL, filled with the length of the array of bytes in the object.
+.BE
+
+.SH DESCRIPTION
+.PP
+These procedures are used to create, modify, and read Tcl byte-array objects
+from C code. Byte-array objects are typically used to hold the
+results of binary IO operations or data structures created with the
+\fBbinary\fR command. In Tcl, an array of bytes is not equivalent to a
+string. Conceptually, a string is an array of Unicode characters, while a
+byte-array is an array of 8-bit quantities with no implicit meaning.
+Accesser functions are provided to get the string representation of a
+byte-array or to convert an arbitrary object to a byte-array. Obtaining the
+string representation of a byte-array object (by calling
+\fBTcl_GetStringFromObj\fR) produces a properly formed UTF-8 sequence with a
+one-to-one mapping between the bytes in the internal representation and the
+UTF-8 characters in the string representation.
+.PP
+\fBTcl_NewByteArrayObj\fR and \fBTcl_SetByteArrayObj\fR will
+create a new object of byte-array type or modify an existing object to have a
+byte-array type. Both of these procedures set the object's type to be
+byte-array and set the object's internal representation to a copy of the
+array of bytes given by \fIbytes\fR. \fBTcl_NewByteArrayObj\fR returns a
+pointer to a newly allocated object with a reference count of zero.
+\fBTcl_SetByteArrayObj\fR invalidates any old string representation and, if
+the object is not already a byte-array object, frees any old internal
+representation.
+.PP
+\fBTcl_GetByteArrayFromObj\fR converts a Tcl object to byte-array type and
+returns a pointer to the object's new internal representation as an array of
+bytes. The length of this array is stored in \fIlengthPtr\fR if
+\fIlengthPtr\fR is non-NULL. The storage for the array of bytes is owned by
+the object and should not be freed. The contents of the array may be
+modified by the caller only if the object is not shared and the caller
+invalidates the string representation.
+.PP
+\fBTcl_SetByteArrayLength\fR converts the Tcl object to byte-array type
+and changes the length of the object's internal representation as an
+array of bytes. If \fIlength\fR is greater than the space currently
+allocated for the array, the array is reallocated to the new length; the
+newly allocated bytes at the end of the array have arbitrary values. If
+\fIlength\fR is less than the space currently allocated for the array,
+the length of array is reduced to the new length. The return value is a
+pointer to the object's new array of bytes.
+
+.SH "SEE ALSO"
+Tcl_GetStringFromObj, Tcl_NewObj, Tcl_IncrRefCount, Tcl_DecrRefCount
+
+.SH KEYWORDS
+object, byte array, utf, unicode, internationalization
diff --git a/doc/CrtChannel.3 b/doc/CrtChannel.3
index 354665a..dbec17b 100644
--- a/doc/CrtChannel.3
+++ b/doc/CrtChannel.3
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) CrtChannel.3 1.29 97/06/20 13:37:45
+'\" SCCS: @(#) CrtChannel.3 1.30 97/12/11 13:10:02
.so man.macros
.TH Tcl_CreateChannel 3 8.0 Tcl "Tcl Library Procedures"
.BS
@@ -221,16 +221,19 @@ typedef struct Tcl_ChannelType {
Tcl_DriverGetOptionProc *\fIgetOptionProc\fR;
Tcl_DriverWatchProc *\fIwatchProc\fR;
Tcl_DriverGetHandleProc *\fIgetHandleProc\fR;
+ Tcl_DriverClose2Proc *\fIclose2Proc\fR;
} Tcl_ChannelType;
.CE
.VE
.PP
The driver must provide implementations for all functions except
-\fIblockModeProc\fR, \fIseekProc\fR, \fIsetOptionProc\fR, and
-\fIgetOptionProc\fR, which may be specified as NULL to indicate that the
-channel does not support seeking. Other functions that can not be
-implemented for this type of device should return \fBEINVAL\fR when invoked
-to indicate that they are not implemented.
+\fIblockModeProc\fR, \fIseekProc\fR, \fIsetOptionProc\fR,
+.VS
+\fIgetOptionProc\fR, and \fIclose2Proc\fR, which may be specified as
+.VE
+NULL. Other functions that can not be implemented for this type of
+device should return \fBEINVAL\fR when invoked to indicate that they
+are not implemented.
.SH TYPENAME
.PP
@@ -264,7 +267,7 @@ For some device types, the blocking and nonblocking behavior can be
implemented by the underlying operating system; for other device types, the
behavior must be emulated in the channel driver.
-.SH CLOSEPROC
+.SH CLOSEPROC AND CLOSE2PROC
.PP
The \fIcloseProc\fR field contains the address of a function called by the
generic layer to clean up driver-related information when the channel is
@@ -286,6 +289,35 @@ calling the \fIcloseProc\fR. If the close operation is successful, the
procedure should return zero; otherwise it should return a nonzero POSIX
error code. In addition, if an error occurs and \fIinterp\fR is not NULL,
the procedure should store an error message in \fIinterp->result\fR.
+.PP
+.VS
+Alternatively, channels that support closing the read and write sides
+independently may set \fIcloseProc\fR to \fBTCL_CLOSE2PROC\fR and set
+\fIclose2Proc\fR to the address of a function that matches the
+following prototype:
+.PP
+.CS
+typedef int Tcl_DriverClose2Proc(
+ ClientData \fIinstanceData\fR,
+ Tcl_Interp *\fIinterp\fR,
+ int \fIflags\fR);
+.CE
+.PP
+The \fIclose2Proc\fR will be called with \fIflags\fR set to an OR'ed
+combination of \fBTCL_CLOSE_READ\fR or \fBTCL_CLOSE_WRITE\fR to
+indicate that the driver should close the read and/or write side of
+the channel. The channel driver may be invoked to perform
+additional operations on the channel after \fIclose2Proc\fR is
+called to close one or both sides of the channel. If \fIflags\fR is
+\fB0\fR (zero), the driver should close the channel in the manner
+described above for \fIcloseProc\fR. No further operations will be
+invoked on this instance after \fIclose2Proc\fR is called with all
+flags cleared. In all cases, the \fIclose2Proc\fR function should
+return zero if the close operation was successful; otherwise it should
+return a nonzero POSIX error code. In addition, if an error occurs and
+\fIinterp\fR is not NULL, the procedure should store an error message
+in \fIinterp->result\fR.
+.VE
.SH INPUTPROC
.PP
diff --git a/doc/CrtObjCmd.3 b/doc/CrtObjCmd.3
index 78fe6f8..0fe9611 100644
--- a/doc/CrtObjCmd.3
+++ b/doc/CrtObjCmd.3
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) @(#) CrtObjCmd.3 1.10 97/07/31 14:10:38
+'\" SCCS: @(#) @(#) CrtObjCmd.3 1.11 97/11/10 11:19:57
'\"
.so man.macros
.TH Tcl_CreateObjCommand 3 8.0 Tcl "Tcl Library Procedures"
@@ -62,8 +62,10 @@ such that whenever \fIname\fR is
invoked as a Tcl command (e.g., via a call to \fBTcl_EvalObj\fR)
the Tcl interpreter will call \fIproc\fR to process the command.
.PP
-\fBTcl_CreateObjCommand\fR will delete any command \fIname\fR
-already associated with the interpreter.
+\fBTcl_CreateObjCommand\fR deletes any existing command
+\fIname\fR already associated with the interpreter
+(however see below for an exception where the existing command
+is not deleted).
It returns a token that may be used to refer
to the command in subsequent calls to \fBTcl_GetCommandName\fR.
If \fIname\fR contains any \fB::\fR namespace qualifiers,
@@ -128,6 +130,17 @@ not modify them.
Call \fBTcl_SetObjResult\fR if you want
to return something from the \fIobjv\fR array.
.PP
+Ordinarily, \fBTcl_CreateObjCommand\fR deletes any existing command
+\fIname\fR already associated with the interpreter.
+However, if the existing command was created by a previous call to
+\fBTcl_CreateCommand\fR,
+\fBTcl_CreateObjCommand\fR does not delete the command
+but instead arranges for the Tcl interpreter to call the
+\fBTcl_ObjCmdProc\fR \fIproc\fR in the future.
+The old string-based \fBTcl_CmdProc\fR associated with the command
+is retained and its address can be obtained by subsequent
+\fBTcl_GetCommandInfo\fR calls. This is done for backwards compatibility.
+.PP
\fIDeleteProc\fR will be invoked when (if) \fIname\fR is deleted.
This can occur through a call to \fBTcl_DeleteCommand\fR,
\fBTcl_DeleteCommandFromToken\fR, or \fBTcl_DeleteInterp\fR,
diff --git a/doc/Encoding.3 b/doc/Encoding.3
new file mode 100644
index 0000000..e1d08d3
--- /dev/null
+++ b/doc/Encoding.3
@@ -0,0 +1,464 @@
+'\"
+'\" Copyright (c) 1997-1998 Sun Microsystems, Inc.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+'\" SCCS: @(#) Encoding.3 1.8 98/02/18 16:11:20
+'\"
+.so man.macros
+.TH Tcl_GetEncoding 3 "8.1" Tcl "Tcl Library Procedures"
+.BS
+.SH NAME
+Tcl_GetEncoding, Tcl_FreeEncoding, Tcl_ExternalToUtfDString, Tcl_ExternalToUtf, Tcl_UtfToExternalDString, Tcl_UtfToExternal, Tcl_GetEncodingName, Tcl_SetSystemEncoding, Tcl_GetEncodingNames, Tcl_CreateEncoding \- procedures for creating and using encodings.
+.SH SYNOPSIS
+.nf
+\fB#include <tcl.h>\fR
+.sp
+Tcl_Encoding
+\fBTcl_GetEncoding\fR(\fIinterp, name\fR)
+.sp
+void
+\fBTcl_FreeEncoding\fR(\fIencoding\fR)
+.sp
+void
+\fBTcl_ExternalToUtfDString\fR(\fIencoding, src, srcLen, dstPtr\fR)
+.sp
+int
+\fBTcl_ExternalToUtf\fR(\fIinterp, encoding, src, srcLen, flags, statePtr, dst, dstLen, srcReadPtr, dstWrotePtr,
+ dstCharsPtr\fR)
+.sp
+void
+\fBTcl_UtfToExternalDString\fR(\fIencoding, src, srcLen, dstPtr\fR)
+.sp
+int
+\fBTcl_UtfToExternal\fR(\fIinterp, encoding, src, srcLen, flags, statePtr, dst, dstLen, srcReadPtr, dstWrotePtr,
+ dstCharsPtr\fR)
+.sp
+char *
+\fBTcl_GetEncodingName\fR(\fIencoding\fR)
+.sp
+int
+\fBTcl_SetSystemEncoding\fR(\fIinterp, name\fR)
+.sp
+void
+\fBTcl_GetEncodingNames\fR(\fIinterp\fR)
+.sp
+Tcl_Encoding
+\fBTcl_CreateEncoding\fR(\fItypePtr\fR)
+.SH ARGUMENTS
+.AS Tcl_EncodingState *dstWrotePtr
+.AP Tcl_Interp *interp in
+Interpreter to use for error reporting, or NULL if no error reporting is
+desired.
+.AP "CONST char" *name in
+Name of encoding to load.
+.AP Tcl_Encoding encoding in
+The encoding to query, free, or use for converting text. If \fIencoding\fR is
+NULL, the current system encoding is used.
+.AP "CONST char" *src in
+For the \fBTcl_ExternalToUtf\fR functions, an array of bytes in the
+specified encoding that are to be converted to UTF-8. For the
+\fBTcl_UtfToExternal\fR functions, an array of UTF-8 characters to be
+converted to the specified encoding.
+.AP int srcLen in
+Length of \fIsrc\fR in bytes. If the length is negative, the
+encoding-specific length of the string is used.
+.AP Tcl_DString *dstPtr out
+Pointer to an uninitialized or free \fBTcl_DString\fR in which the converted
+result will be stored.
+.AP int flags in
+Various flag bits OR-ed together.
+TCL_ENCODING_START signifies that the
+source buffer is the first block in a (potentially multi-block) input
+stream, telling the conversion routine to reset to an initial state and
+perform any initialization that needs to occur before the first byte is
+converted. TCL_ENCODING_END signifies that the source buffer is the last
+block in a (potentially multi-block) input stream, telling the conversion
+routine to perform any finalization that needs to occur after the last
+byte is converted and then to reset to an initial state.
+TCL_ENCODING_STOPONERROR signifies that the conversion routine should
+return immediately upon reading a source character that doesn't exist in
+the target encoding; otherwise a default fallback character will
+automatically be substituted.
+.AP Tcl_EncodingState *statePtr in/out
+Used when converting a (generally long or indefinite length) byte stream
+in a piece by piece fashion. The conversion routine stores its current
+state in \fI*statePtr\fR after \fIsrc\fR (the buffer containing the
+current piece) has been converted; that state information must be passed
+back when converting the next piece of the stream so the conversion
+routine knows what state it was in when it left off at the end of the
+last piece. May be NULL, in which case the value specified for \fIflags\fR
+is ignored and the source buffer is assumed to contain the complete string to
+convert.
+.AP char *dst out
+Buffer in which the converted result will be stored. No more than
+\fIdstLen\fR bytes will be stored in \fIdst\fR.
+.AP int dstLen in
+The maximum length of the output buffer \fIdst\fR in bytes.
+.AP int *srcReadPtr out
+Filled with the number of bytes from \fIsrc\fR that were actually
+converted. This may be less than the original source length if there was
+a problem converting some source characters. May be NULL.
+.AP int *dstWrotePtr out
+Filled with the number of bytes that were actually stored in the output
+buffer as a result of the conversion. May be NULL.
+.AP int *dstCharsPtr out
+Filled with the number of characters that correspond to the number of bytes
+stored in the output buffer. May be NULL.
+.AP Tcl_EncodingType *typePtr in
+Structure that defines a new type of encoding.
+.BE
+.SH INTRODUCTION
+.PP
+These routines convert between Tcl's internal character representation,
+UTF-8, and character representations used by various operating systems or
+file systems, such as Unicode, ASCII, or Shift-JIS. When operating on
+strings, such as such as obtaining the names of files or displaying
+characters using international fonts, the strings must be translated into
+one or possibly multiple formats that the various system calls can use. For
+instance, on a Japanese Unix workstation, a user might obtain a filename
+represented in the EUC-JP file encoding and then translate the characters to
+the jisx0208 font encoding in order to display the filename in a Tk widget.
+The purpose of the encoding package is to help bridge the translation gap.
+UTF-8 provides an intermediate staging ground for all the various
+encodings. In the example above, text would be translated into UTF-8 from
+whatever file encoding the operating system is using. Then it would be
+translated from UTF-8 into whatever font encoding the display routines
+require.
+.PP
+Some basic encodings are compiled into Tcl. Others can be defined by the
+user or dynamically loaded from encoding files in a
+platform-independent manner.
+.SH DESCRIPTION
+.PP
+\fBTcl_GetEncoding\fR finds an encoding given its \fIname\fR. The name may
+refer to a builtin Tcl encoding, a user-defined encoding registered by
+calling \fBTcl_CreateEncoding\fR, or a dynamically-loadable encoding
+file. The return value is a token that represents the encoding and can be
+used in subsequent calls to procedures such as \fBTcl_GetEncodingName\fR,
+\fBTcl_FreeEncoding\fR, and \fBTcl_UtfToExternal\fR. If the name did not
+refer to any known or loadable encoding, NULL is returned and an error
+message is returned in \fIinterp\fR.
+.PP
+The encoding package maintains a database of all encodings currently in use.
+The first time \fIname\fR is seen, \fBTcl_GetEncoding\fR returns an
+encoding with a reference count of 1. If the same \fIname\fR is requested
+further times, then the reference count for that encoding is incremented
+without the overhead of allocating a new encoding and all its associated
+data structures.
+.PP
+When an \fIencoding\fR is no longer needed, \fBTcl_FreeEncoding\fR
+should be called to release it. When an \fIencoding\fR is no longer in use
+anywhere (i.e., it has been freed as many times as it has been gotten)
+\fBTcl_FreeEncoding\fR will release all storage the encoding was using
+and delete it from the database.
+.PP
+\fBTcl_ExternalToUtfDString\fR converts a source buffer \fIsrc\fR from the
+specified \fIencoding\fR into UTF-8. The converted bytes are stored in
+\fIdstPtr\fR, which is then NULL terminated. The caller should eventually
+call \fBTcl_DStringFree\fR to free any information stored in \fIdstPtr\fR.
+When converting, if any of the characters in the source buffer cannot be
+represented in the target encoding, a default fallback character will be
+used.
+.PP
+\fBTcl_ExternalToUtf\fR converts a source buffer \fIsrc\fR from the specified
+\fIencoding\fR into UTF-8. Up to \fIsrcLen\fR bytes are converted from the
+source buffer and up to \fIdstLen\fR converted bytes are stored in \fIdst\fR.
+In all cases, \fI*srcReadPtr\fR is filled with the number of bytes that were
+successfully converted from \fIsrc\fR and \fI*dstWrotePtr\fR is filled with
+the corresponding number of bytes that were stored in \fIdst\fR. The return
+value is one of the following:
+.RS
+.IP \fBTCL_OK\fR 29
+All bytes of \fIsrc\fR were converted.
+.IP \fBTCL_CONVERT_NOSPACE\fR 29
+The destination buffer was not large enough for all of the converted data; as
+many characters as could fit were converted though.
+.IP \fBTCL_CONVERT_MULTIBYTE\fR 29
+The last fews bytes in the source buffer were the beginning of a multibyte
+sequence, but more bytes were needed to complete this sequence. A
+subsequent call to the conversion routine should pass a buffer containing
+the unconverted bytes that remained in \fIsrc\fR plus some further bytes
+from the source stream to properly convert the formerly split-up multibyte
+sequence.
+.IP \fBTCL_CONVERT_SYNTAX\fR 29
+The source buffer contained an invalid character sequence. This may occur
+if the input stream has been damaged or if the input encoding method was
+misidentified.
+.IP \fBTCL_CONVERT_UNKNOWN\fR 29
+The source buffer contained a character that could not be represented in
+the target encoding and TCL_ENCODING_STOPONERROR was specified.
+.RE
+.LP
+\fBTcl_UtfToExternalDString\fR converts a source buffer \fIsrc\fR from UTF-8
+into the specified \fIencoding\fR. The converted bytes are stored in
+\fIdstPtr\fR, which is then terminated with the appropriate encoding-specific
+NULL. The caller should eventually call \fBTcl_DStringFree\fR to free any
+information stored in \fIdstPtr\fR. When converting, if any of the
+characters in the source buffer cannot be represented in the target
+encoding, a default fallback character will be used.
+.PP
+\fBTcl_UtfToExternal\fR converts a source buffer \fIsrc\fR from UTF-8 into
+the specified \fIencoding\fR. Up to \fIsrcLen\fR bytes are converted from
+the source buffer and up to \fIdstLen\fR converted bytes are stored in
+\fIdst\fR. In all cases, \fI*srcReadPtr\fR is filled with the number of
+bytes that were successfully converted from \fIsrc\fR and \fI*dstWrotePtr\fR
+is filled with the corresponding number of bytes that were stored in
+\fIdst\fR. The return values are the same as the return values for
+\fBTcl_ExternalToUtf\fR.
+.PP
+\fBTcl_GetEncodingName\fR is roughly the inverse of \fBTk_GetEncoding\fR.
+Given an \fIencoding\fR, the return value is the \fIname\fR argument that
+was used to create the encoding. The string returned by
+\fBTcl_GetEncodingName\fR is only guaranteed to persist until the
+\fIencoding\fR is deleted. The caller must not modify this string.
+.PP
+\fBTcl_SetSystemEncoding\fR sets the default encoding that should be used
+whenever the user passes a NULL value for the \fIencoding\fR argument to
+any of the other encoding functions. If \fIname\fR is NULL, the system
+encoding is reset to the default system encoding, \fBbinary\fR. If the
+name did not refer to any known or loadable encoding, TCL_ERROR is
+returned and an error message is left in \fIinterp\fR. Otherwise, this
+procedure increments the reference count of the new system encoding,
+decrements the reference count of the old system encoding, and returns
+TCL_OK.
+.PP
+\fBTcl_GetEncodingNames\fR sets the \fIinterp\fR result to a list
+consisting of the names of all the encodings that are currently defined
+or can be dynamically loaded, searching the encoding path specified by
+\fBTcl_SetEncodingPath\fR. This procedure does not ensure that the
+dynamically-loadable encoding files contain valid data, but merely that they
+exist.
+.PP
+\fBTcl_CreateEncoding\fR defines a new encoding and registers the C
+procedures that are called back to convert between the encoding and
+UTF-8. Encodings created by \fBTcl_CreateEncodingType\fR are thereafter
+visible in the database used by \fBTcl_GetEncoding\fR. Just as with the
+\fBTcl_GetEncoding\fR procedure, the return value is a token that
+represents the encoding and can be used in subsequent calls to other
+encoding functions. \fBTcl_CreateEncoding\fR returns an encoding with a
+reference count of 1. If an encoding with the specified \fIname\fR
+already exists, then its entry in the database is replaced with the new
+encoding; the token for the old encoding will remain valid and continue
+to behave as before, but users of the new token will now call the new
+encoding procedures.
+.PP
+The \fItypePtr\fR argument to \fBTcl_CreateEncoding\fR contains information
+about the name of the encoding and the procedures that will be called to
+convert between this encoding and UTF-8. It is defined as follows:
+.PP
+.CS
+typedef struct Tcl_EncodingType {
+ CONST char *\fIencodingName\fR;
+ Tcl_EncodingConvertProc *\fItoUtfProc\fR;
+ Tcl_EncodingConvertProc *\fIfromUtfProc\fR;
+ Tcl_EncodingFreeProc *\fIfreeProc\fR;
+ ClientData \fIclientData\fR;
+ int \fInullSize\fR;
+} Tcl_EncodingType;
+.CE
+.PP
+The \fIencodingName\fR provides a string name for the encoding, by
+which it can be referred in other procedures such as
+\fBTcl_GetEncoding\fR. The \fItoUtfProc\fR refers to a callback
+procedure to invoke to convert text from this encoding into UTF-8.
+The \fIfromUtfProc\fR refers to a callback procedure to invoke to
+convert text from UTF-8 into this encoding. The \fIfreeProc\fR refers
+to a callback procedure to invoke when this encoding is deleted. The
+\fIfreeProc\fR field may be NULL. The \fIclientData\fR contains an
+arbitrary one-word value passed to \fItoUtfProc\fR, \fIfromUtfProc\fR,
+and \fIfreeProc\fR whenever they are called. Typically, this is a
+pointer to a data structure containing encoding-specific information
+that can be used by the callback procedures. For instance, two very
+similar encodings such as \fBascii\fR and \fBmacRoman\fR may use the
+same callback procedure, but use different values of \fIclientData\fR
+to control its behavior. The \fInullSize\fR specifies the number of
+zero bytes that signify end-of-string in this encoding. It must be
+\fB1\fR (for single-byte or multi-byte encodings like ASCII or
+Shift-JIS) or \fB2\fR (for double-byte encodings like Unicode).
+Constant-sized encodings with 3 or more bytes per character (such as
+CNS11643) are not accepted.
+.PP
+The callback procedures \fItoUtfProc\fR and \fIfromUtfProc\fR should match the
+type \fBTcl_EncodingConvertProc\fR:
+.PP
+.CS
+typedef int Tcl_EncodingConvertProc(
+ ClientData \fIclientData\fR,
+ CONST char *\fIsrc\fR,
+ int \fIsrcLen\fR,
+ int \fIflags\fR,
+ Tcl_Encoding *\fIstatePtr\fR,
+ char *\fIdst\fR,
+ int \fIdstLen\fR,
+ int *\fIsrcReadPtr\fR,
+ int *\fIdstWrotePtr\fR,
+ int *\fIdstCharsPtr\fR);
+.CE
+.PP
+The \fItoUtfProc\fR and \fIfromUtfProc\fR procedures are called by the
+\fBTcl_ExternalToUtf\fR or \fBTcl_UtfToExternal\fR family of functions to
+perform the actual conversion. The \fIclientData\fR parameter to these
+procedures is the same as the \fIclientData\fR field specified to
+\fBTcl_CreateEncoding\fR when the encoding was created. The remaining
+arguments to the callback procedures are the same as the arguments,
+documented at the top, to \fBTcl_ExternalToUtf\fR or
+\fBTcl_UtfToExternal\fR, with the following exceptions. If the
+\fIsrcLen\fR argument to one of those high-level functions is negative,
+the value passed to the callback procedure will be the appropriate
+encoding-specific string length of \fIsrc\fR. If any of the \fIsrcReadPtr\fR,
+\fIdstWrotePtr\fR, or \fIdstCharsPtr\fR arguments to one of the high-level
+functions is NULL, the corresponding value passed to the callback
+procedure will be a non-NULL location.
+.PP
+The callback procedure \fIfreeProc\fR, if non-NULL, should match the type
+\fBTcl_EncodingFreeProc\fR:
+.CS
+typedef void Tcl_EncodingFreeProc(
+ ClientData \fIclientData\fR);
+.CE
+.PP
+This \fIfreeProc\fR function is called when the encoding is deleted. The
+\fIclientData\fR parameter is the same as the \fIclientData\fR field
+specified to \fBTcl_CreateEncoding\fR when the encoding was created.
+.PP
+.SH ENCODING FILES
+Space would prohibit precompiling into Tcl every possible encoding
+algorithm, so many encodings are stored on disk as dynamically-loadable
+encoding files. This behavior also allows the user to create additional
+encoding files that can be loaded using the same mechanism. These
+encoding files contain information about the tables and/or escape
+sequences used to map between an external encoding and Unicode. The
+external encoding may consist of single-byte, multi-byte, or double-byte
+characters.
+.PP
+Each dynamically-loadable encoding is represented as a text file. The
+initial line of the file, beginning with a ``#'' symbol, is a comment
+that provides a human-readable description of the file. The next line
+identifies the type of encoding file. It can be one of the following
+letters:
+.IP "[1] \fBS\fR"
+A single-byte encoding, where one character is always one byte long in the
+encoding. An example is \fBiso8859-1\fR, used by many European languages.
+.IP "[2] \fBD\fR"
+A double-byte encoding, where one character is always two bytes long in the
+encoding. An example is \fBbig5\fR, used for Chinese text.
+.IP "[3] \fBM\fR"
+A multi-byte encoding, where one character may be either one or two bytes long.
+Certain bytes are a lead bytes, indicating that another byte must follow
+and that together the two bytes represent one character. Other bytes are not
+lead bytes and represent themselves. An example is \fBshiftjis\fR, used by
+many Japanese computers.
+.IP "[4] \fBE\fR"
+An escape-sequence encoding, specifying that certain sequences of bytes
+do not represent characters, but commands that describe how following bytes
+should be interpreted.
+.PP
+The rest of the lines in the file depend on the type.
+.PP
+Cases [1], [2], and [3] are collectively referred to as table-based encoding
+files. The lines in a table-based encoding file are in the same
+format as this example taken from the \fBshiftjis\fR encoding (this is not
+the complete file):
+.CS
+\fL
+# Encoding file: shiftjis, multi-byte
+M
+003F 0 40
+00
+0000000100020003000400050006000700080009000A000B000C000D000E000F
+0010001100120013001400150016001700180019001A001B001C001D001E001F
+0020002100220023002400250026002700280029002A002B002C002D002E002F
+0030003100320033003400350036003700380039003A003B003C003D003E003F
+0040004100420043004400450046004700480049004A004B004C004D004E004F
+0050005100520053005400550056005700580059005A005B005C005D005E005F
+0060006100620063006400650066006700680069006A006B006C006D006E006F
+0070007100720073007400750076007700780079007A007B007C007D203E007F
+0080000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000FF61FF62FF63FF64FF65FF66FF67FF68FF69FF6AFF6BFF6CFF6DFF6EFF6F
+FF70FF71FF72FF73FF74FF75FF76FF77FF78FF79FF7AFF7BFF7CFF7DFF7EFF7F
+FF80FF81FF82FF83FF84FF85FF86FF87FF88FF89FF8AFF8BFF8CFF8DFF8EFF8F
+FF90FF91FF92FF93FF94FF95FF96FF97FF98FF99FF9AFF9BFF9CFF9DFF9EFF9F
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+81
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+300030013002FF0CFF0E30FBFF1AFF1BFF1FFF01309B309C00B4FF4000A8FF3E
+FFE3FF3F30FD30FE309D309E30034EDD30053006300730FC20152010FF0F005C
+301C2016FF5C2026202520182019201C201DFF08FF0930143015FF3BFF3DFF5B
+FF5D30083009300A300B300C300D300E300F30103011FF0B221200B100D70000
+00F7FF1D2260FF1CFF1E22662267221E22342642264000B0203220332103FFE5
+FF0400A200A3FF05FF03FF06FF0AFF2000A72606260525CB25CF25CE25C725C6
+25A125A025B325B225BD25BC203B301221922190219121933013000000000000
+000000000000000000000000000000002208220B2286228722822283222A2229
+000000000000000000000000000000002227222800AC21D221D4220022030000
+0000000000000000000000000000000000000000222022A52312220222072261
+2252226A226B221A223D221D2235222B222C0000000000000000000000000000
+212B2030266F266D266A2020202100B6000000000000000025EF000000000000
+.CE
+.PP
+The third line of the file is three numbers. The first number is the
+fallback character (in base 16) to use when converting from UTF-8 to this
+encoding. The second number is a \fB1\fR if this file represents the
+encoding for a symbol font, or \fB0\fR otherwise. The last number (in base
+10) is how many pages of data follow.
+.PP
+Subsequent lines in the example above are pages that describe how to map
+from the encoding into 2-byte Unicode. The first line in a page identifies
+the page number. Following it are 256 double-byte numbers, arranged as 16
+rows of 16 numbers. Given a character in the encoding, the high byte of
+that character is used to select which page, and the low byte of that
+character is used as an index to select one of the double-byte numbers in
+that page \- the value obtained being the corresponding Unicode character.
+By examination of the example above, one can see that the characters 0x7E
+and 0x8163 in \fBshiftjis\fR map to 203E and 2026 in Unicode, respectively.
+.PP
+Following the first page will be all the other pages, each in the same
+format as the first: one number identifying the page followed by 256
+double-byte Unicode characters. If a character in the encoding maps to the
+Unicode character 0000, it means that the character doesn't actually exist.
+If all characters on a page would map to 0000, that page can be omitted.
+.PP
+Case [4] is the escape-sequence encoding file. The lines in an this type of
+file are in the same format as this example taken from the \fBiso2022-jp\fR
+encoding:
+.CS
+\fL
+.ta 1.5i
+# Encoding file: iso2022-jp, escape-driven
+E
+init {}
+final {}
+iso8859-1 \\x1b(B
+jis0201 \\x1b(J
+jis0208 \\x1b$@
+jis0208 \\x1b$B
+jis0212 \\x1b$(D
+gb2312 \\x1b$A
+ksc5601 \\x1b$(C
+.CE
+.PP
+In the file, the first column represents an option and the second column
+is the associated value. \fBinit\fR is a string to emit or expect before
+the first character is converted, while \fBfinal\fR is a string to emit
+or expect after the last character. All other options are names of
+table-based encodings; the associated value is the escape-sequence that
+marks that encoding. Tcl syntax is used for the values; in the above
+example, for instance, ``\fB{}\fR'' represents the empty string and
+``\fB\\x1b\fR'' represents character 27.
+.PP
+When \fBTcl_GetEncoding\fR encounters an encoding \fIname\fR that has not
+been loaded, it attempts to load an encoding file called \fIname\fB.enc\fR
+from the \fBencoding\fR subdirectory of each directory specified in the
+library path \fB$tcl_libPath\fR. If the encoding file exists, but is
+malformed, an error message will be left in \fIinterp\fR.
+.SH KEYWORDS
+utf, encoding, convert
+
+
+
diff --git a/doc/Eval.3 b/doc/Eval.3
index f100697..3054a44 100644
--- a/doc/Eval.3
+++ b/doc/Eval.3
@@ -5,88 +5,171 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) Eval.3 1.21 97/01/22 14:22:03
+'\" SCCS: @(#) Eval.3 1.24 97/10/21 11:04:19
'\"
.so man.macros
-.TH Tcl_Eval 3 7.0 Tcl "Tcl Library Procedures"
+.TH Tcl_Eval 3 8.1 Tcl "Tcl Library Procedures"
.BS
.SH NAME
-Tcl_Eval, Tcl_VarEval, Tcl_EvalFile, Tcl_GlobalEval \- execute Tcl commands
+Tcl_EvalObj, Tcl_EvalFile, Tcl_EvalObjv, Tcl_Eval, Tcl_Eval2, Tcl_GlobalEval, Tcl_VarEval \- execute Tcl scripts
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
+.VS
int
-\fBTcl_Eval\fR(\fIinterp, cmd\fR)
+\fBTcl_EvalObj\fR(\fIinterp, objPtr, flags\fR)
.sp
int
-\fBTcl_VarEval\fR(\fIinterp, string, string, ... \fB(char *) NULL\fR)
+\fBTcl_EvalFile\fR(\fIinterp, fileName\fR)
.sp
int
-\fBTcl_EvalFile\fR(\fIinterp, fileName\fR)
+\fBTcl_EvalObjv\fR(\fIinterp, objc, objv, command, numBytes, flags\fR)
+.sp
+int
+\fBTcl_Eval\fR(\fIinterp, script\fR)
+.sp
+int
+\fBTcl_Eval2\fR(\fIinterp, script, numBytes, flags\fR)
.sp
int
-\fBTcl_GlobalEval\fR(\fIinterp, cmd\fR)
+\fBTcl_GlobalEval\fR(\fIinterp, script\fR)
+.sp
+int
+\fBTcl_VarEval\fR(\fIinterp, string, string, ... \fB(char *) NULL\fR)
.SH ARGUMENTS
.AS Tcl_Interp **termPtr;
.AP Tcl_Interp *interp in
-Interpreter in which to execute the command.
-A string result will be stored in \fIinterp->result\fR.
-.AP char *cmd in
-Command (or sequence of commands) to execute. Must be in writable
-memory (\fBTcl_Eval\fR makes temporary modifications to the command).
-.AP char *string in
-String forming part of Tcl command.
+Interpreter in which to execute the script. The interpreter's result is
+modified to hold the result or error message from the script.
+.AP Tcl_Obj *objPtr in
+A Tcl object containing the script to execute.
+.AP int flags in
+ORed combination of flag bits that specify additional options.
+\fBTCL_EVAL_GLOBAL\fR and \fBTCL_EVAL_DIRECT\fR are currently supported.
.AP char *fileName in
-Name of file containing Tcl command string.
+Name of a file containing a Tcl script.
+.AP int *objc in
+The number of objects in the array pointed to by \fIobjPtr\fR;
+this is also the number of words in the command.
+.AP Tcl_Obj **objv in
+Points to an array of pointers to objects; each object holds the
+value of a single word in the command to execute.
+.AP char *command in
+Points to the beginning of the string representation of the
+command, if there is one. If the string representation of the
+command is unknown then an empty string should be supplied.
+This information is used for command tracing.
+.AP int numBytes in
+The number of bytes in \fIcommand\fR or \fIscript\fR, not including any
+null terminating character. If \-1, then all characters up to the
+first null byte are used.
+.AP char *script in
+Points to first byte of script to execute. This script must be in
+writable memory: temporary modifications are made to it during
+parsing.
+.AP char *string in
+String forming part of a Tcl script.
.BE
.SH DESCRIPTION
.PP
-All four of these procedures execute Tcl commands.
-\fBTcl_Eval\fR is the core procedure and is used by all the others.
-It executes the commands in the script held by \fIcmd\fR
-until either an error occurs or it reaches the end of the script.
+The procedures described here are invoked to execute Tcl scripts in
+various forms.
+\fBTcl_EvalObj\fR is the core procedure and is used by many of the others.
+It executes the commands in the script stored in \fIobjPtr\fR
+until either an error occurs or the end of the script is reached.
+If this is the first time \fIobjPtr\fR has been executed,
+its commands are compiled into bytecode instructions
+which are then executed. The
+bytecodes are saved in \fIobjPtr\fR so that the compilation step
+can be skipped if the object is evaluated again in the future.
+.PP
+The return value from \fBTcl_EvalObj\fR (and all the other procedures
+described here) is a Tcl completion code with
+one of the values \fBTCL_OK\fR, \fBTCL_ERROR\fR, \fBTCL_RETURN\fR,
+\fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR.
+In addition, a result value or error message is left in \fIinterp\fR's
+result; it can be retrieved using \fBTcl_GetObjResult\fR.
.PP
-Note that \fBTcl_Eval\fR and \fBTcl_GlobalEval\fR
-have been largely replaced by the
-object-based procedures \fBTcl_EvalObj\fR and \fBTcl_GlobalEvalObj\fR.
-Those object-based procedures evaluate a script held in a Tcl object
-instead of a string.
-The object argument can retain the bytecode instructions for the script
-and so avoid reparsing the script each time it is executed.
-\fBTcl_Eval\fR is implemented using \fBTcl_EvalObj\fR
-but is slower because it must reparse the script each time
-since there is no object to retain the bytecode instructions.
+\fBTcl_EvalFile\fR reads the file given by \fIfileName\fR and evaluates
+its contents as a Tcl script. It returns the same information as
+\fBTcl_EvalObj\fR.
+If the file couldn't be read then a Tcl error is returned to describe
+why the file couldn't be read.
+.PP
+\fBTcl_EvalObjv\fR executes a single pre-parsed command instead of a
+script. The \fIobjc\fR and \fIobjv\fR arguments contain the values
+of the words for the Tcl command, one word in each object in
+\fIobjv\fR. \fBTcl_EvalObjv\fR evaluates the command and returns
+a completion code and result just like \fBTcl_EvalObj\fR.
+The \fIcommand\fR argument is used only to provide contextual information
+to command traces. Note: unlike the other procedures described here,
+\fBTcl_EvalObjv\fR does not add any information to the \fBerrorInfo\fR
+variable after an error. It is up to the caller to do this, if it
+wishes.
.PP
-The return value from \fBTcl_Eval\fR is one of the Tcl return codes
-\fBTCL_OK\fR, \fBTCL_ERROR\fR, \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or
-\fBTCL_CONTINUE\fR, and \fIinterp->result\fR will point to
-a string with additional information (a result value or error message).
-If an error occurs during compilation, this return information
-describes the error.
-Otherwise, this return information corresponds to the last command
-executed from \fIcmd\fR.
+\fBTcl_Eval\fR is similar to \fBTcl_EvalObj\fR except that
+the script to be executed is supplied as a string instead of an
+object and no compilation occurs. The string is parsed and executed
+directly (using \fBTcl_EvalObjv\fR) instead of compiling it and
+executing the bytecodes. In situations where it is known that the
+script will never be executed again, \fBTcl_Eval\fR may be
+faster than \fBTcl_EvalObj\fR. \fBTcl_Eval\fR returns a completion
+code and result just like \fBTcl_EvalObj\fR. Note: for backward
+compatibility with versions before Tcl 8.0, \fBTcl_Eval\fR
+copies the object result in \fIinterp\fR to \fIinterp->result\fR
+where it can be accessed directly. This makes \fBTcl_Eval\fR somewhat
+slower than \fBTcl_Eval2\fR, which doesn't do the copy.
+.PP
+\fBTcl_Eval2\fR is an extended version of \fBTcl_Eval\fR that takes
+additional arguments \fInumBytes\fR and \fIflags\fR. For the
+efficiency reason given above, \fBTcl_Eval2\fR is generally preferred
+over \fBTcl_Eval\fR.
+.PP
+\fBTcl_GlobalEval\fR is an older procedure that is now deprecated.
+It is similar to \fBTcl_Eval\fR except that the script is evaluated in
+the global namespace and its variable context consists of global
+variables only (it ignores any Tcl procedures that are active).
+Like \fBTcl_Eval\fR, it leaves a null-terminated
+string version of the result in \fIinterp->result\fR where it can
+be accessed directly.
.PP
\fBTcl_VarEval\fR takes any number of string arguments
of any length, concatenates them into a single string,
then calls \fBTcl_Eval\fR to execute that string as a Tcl command.
It returns the result of the command and also modifies
-\fIinterp->result\fR in the usual fashion for Tcl commands.
+\fIinterp->result\fR in the same way as \fBTcl_Eval\fR.
The last argument to \fBTcl_VarEval\fR must be NULL to indicate the end
-of arguments.
-.PP
-\fBTcl_EvalFile\fR reads the file given by \fIfileName\fR and evaluates
-its contents as a Tcl command by calling \fBTcl_Eval\fR. It returns
-a standard Tcl result that reflects the result of evaluating the file.
-If the file couldn't be read then a Tcl error is returned to describe
-why the file couldn't be read.
+of arguments. \fBTcl_VarEval\fR is now deprecated.
+
+.SH "FLAG BITS"
+Any ORed combination of the following values may be used for the
+\fIflags\fR argument to procedures such as \fBTcl_EvalObj\fR:
+.TP 23
+\fBTCL_EVAL_DIRECT\fR
+This flag is only used by \fBTcl_EvalObj\fR; it is ignored by
+other procedures. If this flag bit is set, the script is not
+compiled to bytecodes; instead it is executed directly
+as is done by \fBTcl_Eval2\fR. The
+\fBTCL_EVAL_DIRECT\fR flag is useful in situations where the
+contents of an object are going to change immediately, so the
+bytecodes won't be reused in a future execution. In this case,
+it's faster to execute the script directly.
+.TP 23
+\fBTCL_EVAL_GLOBAL\fR
+If this flag is set, the script is processed at global level. This
+means that it is evaluated in the global namespace and its variable
+context consists of global variables only (it ignores any Tcl
+procedures at are active).
+
+.SH "MISCELLANEOUS DETAILS"
.PP
During the processing of a Tcl command it is legal to make nested
calls to evaluate other commands (this is how procedures and
some control structures are implemented).
If a code other than \fBTCL_OK\fR is returned
-from a nested \fBTcl_Eval\fR invocation,
+from a nested \fBTcl_EvalObj\fR invocation,
then the caller should normally return immediately,
passing that same return code back to its caller,
and so on until the top-level application is reached.
@@ -94,21 +177,18 @@ A few commands, like \fBfor\fR, will check for certain
return codes, like \fBTCL_BREAK\fR and \fBTCL_CONTINUE\fR, and process them
specially without returning.
.PP
-\fBTcl_Eval\fR keeps track of how many nested \fBTcl_Eval\fR
+\fBTcl_EvalObj\fR keeps track of how many nested \fBTcl_EvalObj\fR
invocations are in progress for \fIinterp\fR.
If a code of \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR is
-about to be returned from the topmost \fBTcl_Eval\fR
+about to be returned from the topmost \fBTcl_EvalObj\fR
invocation for \fIinterp\fR,
it converts the return code to \fBTCL_ERROR\fR
-and sets \fIinterp->result\fR
-to point to an error message indicating that
+and sets \fIinterp\fR's result to an error message indicating that
the \fBreturn\fR, \fBbreak\fR, or \fBcontinue\fR command was
invoked in an inappropriate place.
This means that top-level applications should never see a return code
-from \fBTcl_Eval\fR other then \fBTCL_OK\fR or \fBTCL_ERROR\fR.
-
-.SH "SEE ALSO"
-Tcl_EvalObj, Tcl_GlobalEvalObj
+from \fBTcl_EvalObj\fR other then \fBTCL_OK\fR or \fBTCL_ERROR\fR.
+.VE
.SH KEYWORDS
-command, execute, file, global, object, object result, variable
+execute, file, global, object, result, script
diff --git a/doc/EvalObj.3 b/doc/EvalObj.3
deleted file mode 100644
index 8cb8f82..0000000
--- a/doc/EvalObj.3
+++ /dev/null
@@ -1,91 +0,0 @@
-'\"
-'\" Copyright (c) 1996-1997 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" SCCS: @(#) EvalObj.3 1.4 97/01/22 15:18:44
-'\"
-.so man.macros
-.TH Tcl_EvalObj 3 8.0 Tcl "Tcl Library Procedures"
-.BS
-.SH NAME
-Tcl_EvalObj, Tcl_GlobalEvalObj \- execute Tcl commands
-.SH SYNOPSIS
-.nf
-\fB#include <tcl.h>\fR
-.sp
-int
-\fBTcl_EvalObj\fR(\fIinterp, objPtr\fR)
-.sp
-int
-\fBTcl_GlobalEvalObj\fR(\fIinterp, objPtr\fR)
-.SH ARGUMENTS
-.AS Tcl_Interp **termPtr;
-.AP Tcl_Interp *interp in
-Interpreter in which to execute the command.
-The command's result will be stored in the interpreter's result object
-and can be retrieved using \fBTcl_GetObjResult\fR.
-.AP Tcl_Obj *objPtr in
-A Tcl object containing a command string
-(or sequence of commands in a string) to execute.
-.BE
-
-.SH DESCRIPTION
-.PP
-These two procedures execute Tcl commands.
-\fBTcl_EvalObj\fR is the core procedure
-and is used by \fBTcl_GlobalEvalObj\fR.
-It executes the commands in the script held by \fIobjPtr\fR
-until either an error occurs or it reaches the end of the script.
-If this is the first time \fIobjPtr\fR has been executed,
-its commands are compiled into bytecode instructions
-that are then executed if there are no compilation errors.
-.PP
-The return value from \fBTcl_EvalObj\fR is one of the Tcl return codes
-\fBTCL_OK\fR, \fBTCL_ERROR\fR, \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or
-\fBTCL_CONTINUE\fR,
-and a result object containing additional information
-(a result value or error message)
-that can be retrieved using \fBTcl_GetObjResult\fR.
-If an error occurs during compilation, this return information
-describes the error.
-Otherwise, this return information corresponds to the last command
-executed from \fIobjPtr\fR.
-.PP
-\fBTcl_GlobalEvalObj\fR is similar to \fBTcl_EvalObj\fR except that it
-processes the command at global level.
-This means that the variable context for the command consists of
-global variables only (it ignores any Tcl procedure that is active).
-This produces an effect similar to the Tcl command ``\fBuplevel 0\fR''.
-.PP
-During the processing of a Tcl command it is legal to make nested
-calls to evaluate other commands (this is how procedures and
-some control structures are implemented).
-If a code other than \fBTCL_OK\fR is returned
-from a nested \fBTcl_EvalObj\fR invocation,
-then the caller should normally return immediately,
-passing that same return code back to its caller,
-and so on until the top-level application is reached.
-A few commands, like \fBfor\fR, will check for certain
-return codes, like \fBTCL_BREAK\fR and \fBTCL_CONTINUE\fR, and process them
-specially without returning.
-.PP
-\fBTcl_EvalObj\fR keeps track of how many nested \fBTcl_EvalObj\fR
-invocations are in progress for \fIinterp\fR.
-If a code of \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR is
-about to be returned from the topmost \fBTcl_EvalObj\fR
-invocation for \fIinterp\fR,
-it converts the return code to \fBTCL_ERROR\fR
-and sets the interpreter's result object
-to point to an error message indicating that
-the \fBreturn\fR, \fBbreak\fR, or \fBcontinue\fR command was
-invoked in an inappropriate place.
-This means that top-level applications should never see a return code
-from \fBTcl_EvalObj\fR other then \fBTCL_OK\fR or \fBTCL_ERROR\fR.
-
-.SH "SEE ALSO"
-Tcl_GetObjResult, Tcl_SetObjResult
-
-.SH KEYWORDS
-command, execute, file, global, object, object result, variable
diff --git a/doc/Exit.3 b/doc/Exit.3
index 1d3e26d..22976e0 100644
--- a/doc/Exit.3
+++ b/doc/Exit.3
@@ -4,13 +4,13 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) Exit.3 1.8 96/12/10 07:37:23
+'\" SCCS: @(#) Exit.3 1.10 98/02/19 16:29:41
'\"
.so man.macros
-.TH Tcl_Exit 3 7.7 Tcl "Tcl Library Procedures"
+.TH Tcl_Exit 3 8.1 Tcl "Tcl Library Procedures"
.BS
.SH NAME
-Tcl_Exit, Tcl_Finalize, Tcl_CreateExitHandler, Tcl_DeleteExitHandler \- end the application (and invoke exit handlers)
+Tcl_Exit, Tcl_Finalize, Tcl_FinalizeThread, Tcl_CreateExitHandler, Tcl_DeleteExitHandler, Tcl_CreateThreadExitHandler, Tcl_DeleteThreadExitHandler \- end the application or thread (and invoke exit handlers)
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -22,10 +22,19 @@ Tcl_Exit, Tcl_Finalize, Tcl_CreateExitHandler, Tcl_DeleteExitHandler \- end the
\fBTcl_CreateExitHandler\fR(\fIproc, clientData\fR)
.sp
\fBTcl_DeleteExitHandler\fR(\fIproc, clientData\fR)
+.sp
+\fBTcl_ExitThread\fR(\fIstatus\fR)
+.sp
+\fBTcl_FinalizeThread\fR()
+.sp
+\fBTcl_CreateThreadExitHandler\fR(\fIproc, clientData\fR)
+.sp
+\fBTcl_DeleteThreadExitHandler\fR(\fIproc, clientData\fR)
.SH ARGUMENTS
.AS Tcl_ExitProc clientData
.AP int status in
-Provides information about why application exited. Exact meaning may
+Provides information about why the application or thread exited.
+Exact meaning may
be platform-specific. 0 usually means a normal exit, any nonzero value
usually means that an error occurred.
.AP Tcl_ExitProc *proc in
@@ -51,7 +60,6 @@ otherwise causes the application to terminate without calling
\fBTcl_Exit\fR internally invokes the \fBexit\fR system call, thus it never
returns control to its caller.
.PP
-.VS
\fBTcl_Finalize\fR is similar to \fBTcl_Exit\fR except that it does not
exit from the current process.
It is useful for cleaning up when a process is finished using \fBTcl\fR but
@@ -64,10 +72,20 @@ However, to ensure portability, your code should always invoke
\fBTcl_Finalize\fR when \fBTcl\fR is being unloaded, to ensure that the
code will work on all platforms. \fBTcl_Finalize\fR can be safely called
more than once.
+.PP
+.VS
+\fBTcl_ExitThread\fR is used to terminate the current thread and invoke
+per-thread exit handlers. This finalization is done by
+\fBTcl_FinalizeThread\fR, which you can call if you just want to clean
+up per-thread state and invoke the thread exit handlers.
+\fBTcl_Finalize\fR calls \fBTcl_FinalizeThread\fR for the current
+thread automatically.
.VE
.PP
\fBTcl_CreateExitHandler\fR arranges for \fIproc\fR to be invoked
by \fBTcl_Finalize\fR and \fBTcl_Exit\fR.
+\fBTcl_CreateThreadExitHandler\fR arranges for \fIproc\fR to be invoked
+by \fBTcl_FinalizeThread\fR and \fBTcl_ExitThread\fR.
This provides a hook for cleanup operations such as flushing buffers
and freeing global memory.
\fIProc\fR should match the type \fBTcl_ExitProc\fR:
@@ -76,16 +94,18 @@ typedef void Tcl_ExitProc(ClientData \fIclientData\fR);
.CE
The \fIclientData\fR parameter to \fIproc\fR is a
copy of the \fIclientData\fR argument given to
-\fBTcl_CreateExitHandler\fR when the callback
+\fBTcl_CreateExitHandler\fR or \fBTcl_CreateThreadExitHandler\fR when
+the callback
was created. Typically, \fIclientData\fR points to a data
structure containing application-specific information about
what to do in \fIproc\fR.
.PP
-\fBTcl_DeleteExitHandler\fR may be called to delete a
+\fBTcl_DeleteExitHandler\fR and \fBTcl_DeleteThreadExitHandler\fR may be
+called to delete a
previously-created exit handler. It removes the handler
indicated by \fIproc\fR and \fIclientData\fR so that no call
to \fIproc\fR will be made. If no such handler exists then
-\fBTcl_DeleteExitHandler\fR does nothing.
+\fBTcl_DeleteExitHandler\fR or \fBTcl_DeleteThreadExitHandler\fR does nothing.
.PP
.VS
.PP
@@ -98,6 +118,14 @@ If extension \fBA\fR registers its exit handlers before loading extension
\fBB\fR, this ensures that any exit handlers for \fBB\fR will be executed
before the exit handlers for \fBA\fR.
.VE
+.VS
+.PP
+\fBTcl_Finalize\fR and \fBTcl_Exit\fR call \fBTcl_FinalizeThread\fR
+and the thread exit handlers \fIafter\fR
+the process-wide exit handlers. This is because thread finalization shuts
+down the I/O channel system, so any attempt at I/O by the global exit
+handlers will vanish into the bitbucket.
+.VE
.SH KEYWORDS
-callback, cleanup, dynamic loading, end application, exit, unloading
+callback, cleanup, dynamic loading, end application, exit, unloading, thread
diff --git a/doc/GetIndex.3 b/doc/GetIndex.3
index 9ca7927..3879103 100644
--- a/doc/GetIndex.3
+++ b/doc/GetIndex.3
@@ -4,10 +4,10 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) @(#) GetIndex.3 1.3 97/07/30 16:21:05
+'\" SCCS: @(#) @(#) GetIndex.3 1.4 97/10/16 17:43:40
'\"
.so man.macros
-.TH Tcl_GetIndexFromObj 3 8.0 Tcl "Tcl Library Procedures"
+.TH Tcl_GetIndexFromObj 3 8.1 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_GetIndexFromObj \- lookup string in table of keywords
@@ -16,7 +16,14 @@ Tcl_GetIndexFromObj \- lookup string in table of keywords
\fB#include <tcl.h>\fR
.sp
int
-\fBTcl_GetIndexFromObj\fR(\fIinterp, objPtr, tablePtr, msg, flags, indexPtr\fR)
+\fBTcl_GetIndexFromObj\fR(\fIinterp, objPtr, tablePtr, msg, flags,
+indexPtr\fR)
+.VS
+.sp
+int
+\fBTcl_GetIndexFromObjStruct\fR(\fIinterp, objPtr, tablePtr, offset,
+msg, flags, indexPtr\fR)
+.VE
.SH ARGUMENTS
.AS Tcl_Interp **tablePtr
.AP Tcl_Interp *interp in
@@ -29,6 +36,11 @@ table entry.
.AP char **tablePtr in
An array of null-terminated strings. The end of the array is marked
by a NULL string pointer.
+.VS
+.AP int offset in
+The offset to add to tablePtr to get to the next string in the
+list. The end of the array is marked by a NULL string pointer.
+.VE
.AP char *msg in
Null-terminated string describing what is being looked up, such as
\fBoption\fR. This string is included in error messages.
@@ -68,7 +80,18 @@ is invoked again with the same \fIobjPtr\fR and \fItablePtr\fR
arguments (e.g. during a reinvocation of a Tcl command), it returns
the matching index immediately without having to redo the lookup
operation. Note: \fBTcl_GetIndexFromObj\fR assumes that the entries
-in \fItablePtr\fR are static: they must not change between invocations.
+in \fItablePtr\fR are static: they must not change between
+invocations.
+.VS
+.PP
+\fBTcl_GetIndexFromObjStruct\fR works just like
+\fBTcl_GetIndexFromObj\fR, except that instead of treating
+\fItablePtr\fR as an array of string pointers, it treats it as the
+first in a series of string ptrs that are spaced apart by \fIoffset\fR
+bytes. This is particularly useful when processing things like
+\fBTk_ConfigurationSpec\fR, whose string keys are in the same place in
+each of several array elements.
+.VE
.SH "SEE ALSO"
Tcl_WrongNumArgs
diff --git a/doc/ObjSetVar.3 b/doc/ObjSetVar.3
deleted file mode 100644
index 49dd82d..0000000
--- a/doc/ObjSetVar.3
+++ /dev/null
@@ -1,162 +0,0 @@
-'\"
-'\" Copyright (c) 1996-1997 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" SCCS: @(#) ObjSetVar.3 1.6 97/05/19 17:35:44
-'\"
-.so man.macros
-.TH Tcl_ObjSetVar2 3 8.0 Tcl "Tcl Library Procedures"
-.BS
-.SH NAME
-Tcl_ObjSetVar2, Tcl_ObjGetVar2 \- manipulate Tcl variables
-.SH SYNOPSIS
-.nf
-\fB#include <tcl.h>\fR
-.sp
-Tcl_Obj *
-\fBTcl_ObjSetVar2\fR(\fIinterp, part1Ptr, part2Ptr, newValuePtr, flags\fR)
-.sp
-Tcl_Obj *
-\fBTcl_ObjGetVar2\fR(\fIinterp, part1Ptr, part2Ptr, flags\fR)
-.SH ARGUMENTS
-.AS Tcl_Interp *newValuePtr
-.AP Tcl_Interp *interp in
-Interpreter containing variable.
-.AP Tcl_Obj *part1Ptr in
-Points to a Tcl object containing the variable's name.
-The name may include a series of \fB::\fR namespace qualifiers
-to specify a variable in a particular namespace.
-May refer to a scalar variable or an element of an array variable.
-.AP Tcl_Obj *part2Ptr in
-If non-NULL, points to an object containing the name of an element
-within an array and \fIpart1Ptr\fR must refer to an array variable.
-.AP Tcl_Obj *newValuePtr in
-Points to a Tcl object containing the new value for the variable.
-.AP int flags in
-OR-ed combination of bits providing additional information for
-operation. See below for valid values.
-.BE
-
-.SH DESCRIPTION
-.PP
-These two procedures may be used to read and modify
-Tcl variables from C code.
-\fBTcl_ObjSetVar2\fR will create a new variable or modify an existing one.
-It sets the specified variable to
-the object referenced by \fInewValuePtr\fR
-and returns a pointer to the object which is the variable's new value.
-The returned object may not be the same one
-referenced by \fInewValuePtr\fR;
-this might happen because variable traces may modify the variable's value.
-The reference count for the variable's old value is decremented
-and the reference count for its new value is incremented.
-If the new value for the variable
-is not the same one referenced by \fInewValuePtr\fR
-(perhaps as a result of a variable trace),
-then \fInewValuePtr\fR's reference count is left unchanged.
-The reference count for the returned object is not incremented
-to reflect the returned reference.
-If the caller needs to keep a reference to the object,
-say in a data structure,
-it must increment its reference count using \fBTcl_IncrRefCount\fR.
-If an error occurs in setting the variable
-(e.g. an array variable is referenced
-without giving an index into the array),
-then NULL is returned.
-.PP
-The variable name specified to \fBTcl_ObjSetVar2\fR consists of two parts.
-\fIpart1Ptr\fR contains the name of a scalar or array variable.
-If \fIpart2Ptr\fR is NULL, the variable must be a scalar.
-If \fIpart2Ptr\fR is not NULL,
-it contains the name of an element in the array named by \fIpart2Ptr\fR.
-As a special case, if the flag TCL_PARSE_PART1 is specified,
-\fIpart1Ptr\fR may contain both an array and an element name:
-if the name contains an open parenthesis and ends with a
-close parenthesis, then the value between the parentheses is
-treated as an element name (which can have any string value) and
-the characters before the first open
-parenthesis are treated as the name of an array variable.
-If the flag TCL_PARSE_PART1 is given,
-\fIpart2Ptr\fR should be NULL since the array and element names
-are taken from \fIpart2Ptr\fR.
-.PP
-The \fIflags\fR argument may be used to specify any of several
-options to the procedures.
-It consists of an OR-ed combination of any of the following
-bits:
-.TP
-\fBTCL_GLOBAL_ONLY\fR
-Under normal circumstances the procedures look up variables as follows:
-If a procedure call is active in \fIinterp\fR,
-a variable is looked up at the current level of procedure call.
-Otherwise, a variable is looked up first in the current namespace,
-then in the global namespace.
-However, if this bit is set in \fIflags\fR then the variable
-is looked up only in the global namespace
-even if there is a procedure call active.
-If both \fBTCL_GLOBAL_ONLY\fR and \fBTCL_NAMESPACE_ONLY\fR are given,
-\fBTCL_GLOBAL_ONLY\fR is ignored.
-.TP
-\fBTCL_NAMESPACE_ONLY\fR
-Under normal circumstances the procedures look up variables as follows:
-If a procedure call is active in \fIinterp\fR,
-a variable is looked up at the current level of procedure call.
-Otherwise, a variable is looked up first in the current namespace,
-then in the global namespace.
-However, if this bit is set in \fIflags\fR then the variable
-is looked up only in the current namespace
-even if there is a procedure call active.
-.TP
-\fBTCL_LEAVE_ERR_MSG\fR
-If an error is returned and this bit is set in \fIflags\fR, then
-an error message will be left in the interpreter's result,
-where it can be retrieved with \fBTcl_GetObjResult\fR
-or \fBTcl_GetStringResult\fR.
-If this flag bit isn't set then no error message is left
-and the interpreter's result will not be modified.
-.TP
-\fBTCL_APPEND_VALUE\fR
-If this bit is set then \fInewValuePtr\fR is appended to the current
-value, instead of replacing it.
-If the variable is currently undefined, then this bit is ignored.
-.TP
-\fBTCL_LIST_ELEMENT\fR
-If this bit is set, then \fInewValuePtr\fR is converted to a valid
-Tcl list element before setting (or appending to) the variable.
-A separator space is appended before the new list element unless
-the list element is going to be the first element in a list or
-sublist (i.e. the variable's current value is empty, or contains
-the single character ``{'', or ends in `` }'').
-.TP
-\fBTCL_PARSE_PART1\fR
-If this bit is set,
-then \fBTcl_ObjGetVar2\fR and \fBTcl_ObjSetVar2\fR
-will parse \fIpart1Ptr\fR
-to obtain both an array name and an element name.
-If the name in \fIpart1Ptr\fR contains an open parenthesis
-and ends with a close parenthesis,
-the name is treated as the name of an element of an array;
-otherwise, the name in \fIpart1Ptr\fR
-is interpreted as the name of a scalar variable.
-When this bit is set,
-\fIpart2Ptr\fR is ignored.
-.PP
-\fBTcl_ObjGetVar2\fR returns the value of the specified variable.
-Its arguments are treated the same way as those for \fBTcl_ObjSetVar2\fR.
-It returns a pointer to the object which is the variable's value.
-The reference count for the returned object is not incremented.
-If the caller needs to keep a reference to the object,
-say in a data structure,
-it must increment the reference count using \fBTcl_IncrRefCount\fR.
-If an error occurs in setting the variable
-(e.g. an array variable is referenced
-without giving an index into the array),
-then NULL is returned.
-
-.SH "SEE ALSO"
-Tcl_GetObjResult, Tcl_GetStringResult, Tcl_GetVar, Tcl_GetVar2, Tcl_SetVar, Tcl_SetVar2, Tcl_TraceVar, Tcl_UnsetVar, Tcl_UnsetVar2
-
-.SH KEYWORDS
-array, interpreter, object, scalar, set, unset, variable
diff --git a/doc/Object.3 b/doc/Object.3
index 1fed7a6..df930dd 100644
--- a/doc/Object.3
+++ b/doc/Object.3
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) @(#) Object.3 1.10 97/07/22 11:40:10
+'\" SCCS: @(#) @(#) Object.3 1.11 97/12/19 11:07:43
'\"
.so man.macros
.TH Tcl_Obj 3 8.0 Tcl "Tcl Library Procedures"
@@ -85,7 +85,7 @@ Because of this representation invalidation and regeneration,
it is dangerous for extension writers to access
\fBTcl_Obj\fR fields directly.
It is better to access Tcl_Obj information using
-procedures like \fBTcl_GetStringFromObj\fR.
+procedures like \fBTcl_GetStringFromObj\fR and \fBTcl_GetString\fR.
.PP
Objects are allocated on the heap
and are referenced using a pointer to their \fBTcl_Obj\fR structure.
@@ -138,7 +138,7 @@ The byte array must always have a null after the last byte,
at offset \fIlength\fR;
this allows string representations that do not contain nulls
to be treated as conventional null-terminated C strings.
-C programs use \fBTcl_GetStringFromObj\fR to get
+C programs use \fBTcl_GetStringFromObj\fR and \fBTcl_GetString\fR to get
an object's string representation.
If \fIbytes\fR is NULL,
the string representation is invalid.
@@ -177,7 +177,8 @@ An object typically starts out containing only a string representation:
it is untyped and has a NULL \fItypePtr\fR.
An object containing an empty string or a copy of a specified string
is created using \fBTcl_NewObj\fR or \fBTcl_NewStringObj\fR respectively.
-An object's string value is gotten with \fBTcl_GetStringFromObj\fR
+An object's string value is gotten with
+\fBTcl_GetStringFromObj\fR or \fBTcl_GetString\fR
and changed with \fBTcl_SetStringObj\fR.
If the object is later passed to a procedure like \fBTcl_GetIntFromObj\fR
that requires a specific internal representation,
@@ -187,7 +188,7 @@ An object's two representations are duals of each other:
changes made to one are reflected in the other.
For example, \fBTcl_ListObjReplace\fR will modify an object's
internal representation and the next call to \fBTcl_GetStringFromObj\fR
-will reflect that change.
+or \fBTcl_GetString\fR will reflect that change.
.PP
Representations are recomputed lazily for efficiency.
A change to one representation made by a procedure
diff --git a/doc/OpenFileChnl.3 b/doc/OpenFileChnl.3
index 6cf9b80..a6052eb 100644
--- a/doc/OpenFileChnl.3
+++ b/doc/OpenFileChnl.3
@@ -4,13 +4,13 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) OpenFileChnl.3 1.40 97/09/29 11:22:49
+'\" SCCS: @(#) OpenFileChnl.3 1.43 98/01/13 20:02:00
.so man.macros
-.TH Tcl_OpenFileChannel 3 8.0 Tcl "Tcl Library Procedures"
+.TH Tcl_OpenFileChannel 3 8.1 Tcl "Tcl Library Procedures"
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
-Tcl_OpenFileChannel, Tcl_OpenCommandChannel, Tcl_MakeFileChannel, Tcl_GetChannel, Tcl_RegisterChannel, Tcl_UnregisterChannel, Tcl_Close, Tcl_Read, Tcl_Gets, Tcl_Write, Tcl_Flush, Tcl_Seek, Tcl_Tell, Tcl_Eof, Tcl_InputBlocked, Tcl_InputBuffered, Tcl_GetChannelOption, Tcl_SetChannelOption \- buffered I/O facilities using channels
+Tcl_OpenFileChannel, Tcl_OpenCommandChannel, Tcl_MakeFileChannel, Tcl_GetChannel, Tcl_RegisterChannel, Tcl_UnregisterChannel, Tcl_Close, Tcl_ReadChars, Tcl_Read, Tcl_GetsObj, Tcl_Gets, Tcl_WriteObj, Tcl_WriteChars, Tcl_Write, Tcl_Flush, Tcl_Seek, Tcl_Tell, Tcl_GetChannelOption, Tcl_SetChannelOption, Tcl_Eof, Tcl_InputBlocked, Tcl_InputBuffered, \- buffered I/O facilities using channels
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -22,7 +22,7 @@ Tcl_Channel
.sp
Tcl_Channel
\fBTcl_OpenCommandChannel\fR(\fIinterp, argc, argv, flags\fR)
-.VS
+.VS 8.0
.sp
Tcl_Channel
\fBTcl_MakeFileChannel\fR(\fIhandle, readOrWrite\fR)
@@ -40,17 +40,28 @@ int
int
\fBTcl_Close\fR(\fIinterp, channel\fR)
.sp
+.VS 8.1
int
-\fBTcl_Read\fR(\fIchannel, buf, toRead\fR)
+\fBTcl_ReadChars\fR(\fIchannel, readObjPtr, charsToRead, appendFlag\fR)
.sp
int
-\fBTcl_Gets\fR(\fIchannel, lineRead\fR)
+\fBTcl_Read\fR(\fIchannel, byteBuf, bytesToRead\fR)
.sp
int
\fBTcl_GetsObj\fR(\fIchannel, lineObjPtr\fR)
.sp
int
-\fBTcl_Write\fR(\fIchannel, buf, toWrite\fR)
+\fBTcl_Gets\fR(\fIchannel, lineRead\fR)
+.sp
+int
+\fBTcl_WriteObj\fR(\fIchannel, writeObjPtr\fR)
+.sp
+int
+\fBTcl_WriteChars\fR(\fIchannel, charBuf, bytesToWrite\fR)
+.sp
+int
+\fBTcl_Write\fR(\fIchannel, byteBuf, bytesToWrite\fR)
+.VE
.sp
int
\fBTcl_Flush\fR(\fIchannel\fR)
@@ -83,37 +94,36 @@ Used for error reporting and to look up a channel registered in it.
.AP char *fileName in
The name of a local or network file.
.AP char *mode in
-Specifies how the file is to be accessed. May have any of the
-values allowed for the \fImode\fR argument to the Tcl
-\fBopen\fR command.
-For \fBTcl_OpenCommandChannel\fR, may be NULL.
+Specifies how the file is to be accessed. May have any of the values
+allowed for the \fImode\fR argument to the Tcl \fBopen\fR command. For
+\fBTcl_OpenCommandChannel\fR, may be NULL.
.AP int permissions in
-POSIX-style permission flags such as 0644.
-If a new file is created, these permissions will be set on the
-created file.
+POSIX-style permission flags such as 0644. If a new file is created, these
+permissions will be set on the created file.
.AP int argc in
The number of elements in \fIargv\fR.
.AP char **argv in
-Arguments for constructing a command pipeline.
-These values have the same meaning as the non-switch arguments
-to the Tcl \fBexec\fR command.
+Arguments for constructing a command pipeline. These values have the same
+meaning as the non-switch arguments to the Tcl \fBexec\fR command.
.AP int flags in
Specifies the disposition of the stdio handles in pipeline: OR-ed
-combination of \fBTCL_STDIN\fR, \fBTCL_STDOUT\fR, \fBTCL_STDERR\fR,
-and \fBTCL_ENFORCE_MODE\fR. If \fBTCL_STDIN\fR is set, stdin for
-the first child in the pipe is the pipe channel, otherwise it is the same
-as the standard input of the invoking process; likewise for
-\fBTCL_STDOUT\fR and \fBTCL_STDERR\fR. If \fBTCL_ENFORCE_MODE\fR is not set,
-then the pipe can redirect stdio handles to override the stdio handles for
-which \fBTCL_STDIN\fR, \fBTCL_STDOUT\fR and \fBTCL_STDERR\fR have been set.
-If it is set, then such redirections cause an error.
-.VS
+combination of \fBTCL_STDIN\fR, \fBTCL_STDOUT\fR, \fBTCL_STDERR\fR, and
+\fBTCL_ENFORCE_MODE\fR. If \fBTCL_STDIN\fR is set, stdin for the first child
+in the pipe is the pipe channel, otherwise it is the same as the standard
+input of the invoking process; likewise for \fBTCL_STDOUT\fR and
+\fBTCL_STDERR\fR. If \fBTCL_ENFORCE_MODE\fR is not set, then the pipe can
+redirect stdio handles to override the stdio handles for which
+\fBTCL_STDIN\fR, \fBTCL_STDOUT\fR and \fBTCL_STDERR\fR have been set. If it
+is set, then such redirections cause an error.
+.VS 8.0
.AP ClientData handle in
Operating system specific handle for I/O to a file. For Unix this is a
file descriptor, for Windows it is a HANDLE.
.AP int readOrWrite in
OR-ed combination of \fBTCL_READABLE\fR and \fBTCL_WRITABLE\fR to indicate
what operations are valid on \fIhandle\fR.
+.AP char *channelName in
+The name of the channel.
.VE
.AP int *modePtr out
Points at an integer variable that will receive an OR-ed combination of
@@ -122,26 +132,40 @@ open for reading and writing.
.AP Tcl_Channel channel in
A Tcl channel for input or output. Must have been the return value
from a procedure such as \fBTcl_OpenFileChannel\fR.
-.AP char *buf in
-An array of bytes in which to store channel input, or from which
-to read channel output.
-.AP int len in
-The length of the input or output.
-.AP int atEnd in
-If nonzero, store the input at the end of the input queue, otherwise store
-it at the head of the input queue.
-.AP int toRead in
-The number of bytes to read from the channel.
-.AP Tcl_DString *lineRead in
-A pointer to a Tcl dynamic string in which to store the line read from the
-channel. Must have been initialized by the caller. The line read
-will be appended to any data already in the dynamic string.
-.AP Tcl_Obj *linePtrObj in
+.VS 8.1 br
+.AP Tcl_Obj *readObjPtr in/out
+A pointer to a Tcl Object in which to store the characters read from the
+channel.
+.AP int charsToRead in
+The number of characters to read from the channel. If the channel's encoding
+is \fBbinary\fR, this is equivalent to the number of bytes to read from the
+channel.
+.AP int appendFlag in
+If non-zero, data read from the channel will be appended to the object.
+Otherwise, the data will replace the existing contents of the object.
+.AP char *readBuf out
+A buffer in which to store the bytes read from the channel.
+.AP int bytesToRead in
+The number of bytes to read from the channel. The buffer \fIreadBuf\fR must
+be large enough to hold this many bytes.
+.AP Tcl_Obj *lineObjPtr in/out
A pointer to a Tcl object in which to store the line read from the
channel. The line read will be appended to the current value of the
object.
-.AP int toWrite in
-The number of bytes to read from \fIbuf\fR and output to the channel.
+.AP Tcl_DString *lineRead in/out
+A pointer to a Tcl dynamic string in which to store the line read from the
+channel. Must have been initialized by the caller. The line read will be
+appended to any data already in the dynamic string.
+.AP Tcl_Obj *writeObjPtr in
+A pointer to a Tcl Object whose contents will be output to the channel.
+.AP "CONST char" *charBuf in
+A buffer containing the characters to output to the channel.
+.AP char *byteBuf in
+A buffer containing the bytes to output to the channel.
+.AP int bytesToWrite in
+The number of bytes to consume from \fIcharBuf\fR or \fIbyteBuf\fR and
+output to the channel.
+.VE
.AP int offset in
How far to move the access point in the channel at which the next input or
output operation will be applied, measured in bytes from the position
@@ -169,7 +193,7 @@ types.
The channel mechanism is extensible to new channel types, by
providing a low level channel driver for the new type; the channel driver
interface is described in the manual entry for \fBTcl_CreateChannel\fR. The
-channel mechanism provides a buffering scheme modelled after
+channel mechanism provides a buffering scheme modeled after
Unix's standard I/O, and it also allows for nonblocking I/O on
channels.
.PP
@@ -182,7 +206,7 @@ channels, see the manual entry for \fBTcl_CreateChannel\fR.
.PP
\fBTcl_OpenFileChannel\fR opens a file specified by \fIfileName\fR and
returns a channel handle that can be used to perform input and output on
-the file. This API is modelled after the \fBfopen\fR procedure of
+the file. This API is modeled after the \fBfopen\fR procedure of
the Unix standard I/O library.
The syntax and meaning of all arguments is similar to those
given in the Tcl \fBopen\fR command when opening a file.
@@ -190,7 +214,7 @@ If an error occurs while opening the channel, \fBTcl_OpenFileChannel\fR
returns NULL and records a POSIX error code that can be
retrieved with \fBTcl_GetErrno\fR.
In addition, if \fIinterp\fR is non-NULL, \fBTcl_OpenFileChannel\fR
-leaves an error message in \fIinterp->result\fR after any error.
+leaves an error message in \fIinterp\fR's result after any error.
.PP
The newly created channel is not registered in the supplied interpreter; to
register it, use \fBTcl_RegisterChannel\fR, described below.
@@ -310,93 +334,136 @@ left in \fIinterp->result\fR.
.PP
Note: it is not safe to call \fBTcl_Close\fR on a channel that has been
registered using \fBTcl_RegisterChannel\fR; see the documentation for
-\fBTcl_RegisterChannel\fR, above, for details. If the channel has ever been
-given as the \fBchan\fR argument in a call to \fBTcl_RegisterChannel\fR,
-you should instead use \fBTcl_UnregisterChannel\fR, which will internally
-call \fBTcl_Close\fR when all calls to \fBTcl_RegisterChannel\fR have been
-matched by corresponding calls to \fBTcl_UnregisterChannel\fR.
+\fBTcl_RegisterChannel\fR, above, for details. If the channel has ever
+been given as the \fBchan\fR argument in a call to
+\fBTcl_RegisterChannel\fR, you should instead use
+\fBTcl_UnregisterChannel\fR, which will internally call \fBTcl_Close\fR
+when all calls to \fBTcl_RegisterChannel\fR have been matched by
+corresponding calls to \fBTcl_UnregisterChannel\fR.
-.SH TCL_READ
-.PP
-\fBTcl_Read\fR consumes up to \fItoRead\fR bytes of data from
-\fIchannel\fR and stores it at \fIbuf\fR.
-The return value of \fBTcl_Read\fR is the number of characters written
-at \fIbuf\fR.
-The buffer produced by \fBTcl_Read\fR is not NULL terminated. Its contents
-are valid from the zeroth position up to and excluding the position
-indicated by the return value.
-If an error occurs, the return value is -1 and \fBTcl_Read\fR records
-a POSIX error code that can be retrieved with \fBTcl_GetErrno\fR.
-.PP
-The return value may be smaller than the value of \fItoRead\fR, indicating
-that less data than requested was available, also called a \fIshort
-read\fR.
-In blocking mode, this can only happen on an end-of-file.
-In nonblocking mode, a short read can also occur if there is not
-enough input currently available: \fBTcl_Read\fR returns a short
-count rather than waiting for more data.
-.PP
-If the channel is in blocking mode, a return value of zero indicates an end
-of file condition. If the channel is in nonblocking mode, a return value of
-zero indicates either that no input is currently available or an end of
-file condition. Use \fBTcl_Eof\fR and \fBTcl_InputBlocked\fR
-to tell which of these conditions actually occurred.
-.PP
-\fBTcl_Read\fR translates platform-specific end-of-line representations
-into the canonical \fB\en\fR internal representation according to the
-current end-of-line recognition mode. End-of-line recognition and the
-various platform-specific modes are described in the manual entry for the
-Tcl \fBfconfigure\fR command.
+.VS 8.1 br
+.SH TCL_READCHARS AND TCL_READ
+.PP
+\fBTcl_ReadChars\fR consumes bytes from \fIchannel\fR, converting the bytes
+to UTF-8 based on the channel's encoding and storing the produced data in
+\fIreadObjPtr\fR's string representation. The return value of
+\fBTcl_ReadChars\fR is the number of characters, up to \fIcharsToRead\fR,
+that were stored in \fIobjPtr\fR. If an error occurs while reading, the
+return value is \-1 and \fBTcl_ReadChars\fR records a POSIX error code that
+can be retrieved with \fBTcl_GetErrno\fR.
+.PP
+The return value may be smaller than the value to read, indicating that less
+data than requested was available. This is called a \fIshort read\fR. In
+blocking mode, this can only happen on an end-of-file. In nonblocking mode,
+a short read can also occur if there is not enough input currently
+available: \fBTcl_ReadChars\fR returns a short count rather than waiting
+for more data.
+.PP
+If the channel is in blocking mode, a return value of zero indicates an
+end-of-file condition. If the channel is in nonblocking mode, a return
+value of zero indicates either that no input is currently available or an
+end-of-file condition. Use \fBTcl_Eof\fR and \fBTcl_InputBlocked\fR to tell
+which of these conditions actually occurred.
+.PP
+\fBTcl_ReadChars\fR translates the various end-of-line representations into
+the canonical \fB\en\fR internal representation according to the current
+end-of-line recognition mode. End-of-line recognition and the various
+platform-specific modes are described in the manual entry for the Tcl
+\fBfconfigure\fR command.
+.PP
+As a performance optimization, when reading from a channel with the encoding
+\fBbinary\fR, the bytes are not converted to UTF-8 as they are read.
+Instead, they are stored in \fIreadObjPtr\fR's internal representation as a
+byte-array object. The string representation of this object will only be
+constructed if it is needed (e.g., because of a call to
+\fBTcl_GetStringFromObj\fR). In this way, byte-oriented data can be read
+from a channel, manipulated by calling \fBTcl_GetByteArrayFromObj\fR and
+related functions, and then written to a channel without the expense of ever
+converting to or from UTF-8.
+.PP
+\fBTcl_Read\fR is similar to \fBTcl_ReadChars\fR, except that it doesn't do
+encoding conversions, regardless of the channel's encoding. It is deprecated
+and exists for backwards compatibility with non-internationalized Tcl
+extensions. It consumes bytes from \fIchannel\fR and stores them in
+\fIbuf\fR, performing end-of-line translations on the way. The return value
+of \fBTcl_Read\fR is the number of bytes, up to \fItoRead\fR, written in
+\fIbuf\fR. The buffer produced by \fBTcl_Read\fR is not NULL terminated.
+Its contents are valid from the zeroth position up to and excluding the
+position indicated by the return value.
-.SH TCL_GETS AND TCL_GETSOBJ
-.PP
-\fBTcl_Gets\fR reads a line of input from a channel and appends all of
-the characters of the line except for the terminating end-of-line character(s)
-to the dynamic string given by \fIdsPtr\fR.
-The end-of-line character(s) are read and discarded.
+.SH TCL_GETSOBJ AND TCL_GETS
+.PP
+\fBTcl_GetsObj\fR consumes bytes from \fIchannel\fR, converting the bytes to
+UTF-8 based on the channel's encoding, until a full line of input has been
+seen. If the channel's encoding is \fBbinary\fR, each byte read from the
+channel is treated as an individual Unicode character. All of the
+characters of the line except for the terminating end-of-line character(s)
+are appended to \fIlineObjPtr\fR's string representation. The end-of-line
+character(s) are read and discarded.
+.PP
+If a line was successfully read, the return value is greater than or equal
+to zero and indicates the number of bytes stored in \fIlineObjPtr\fR. If an
+error occurs, \fBTcl_GetsObj\fR returns \-1 and records a POSIX error code
+that can be retrieved with \fBTcl_GetErrno\fR. \fBTcl_GetsObj\fR also
+returns \-1 if the end of the file is reached; the \fBTcl_Eof\fR procedure
+can be used to distinguish an error from an end-of-file condition.
+.PP
+If the channel is in nonblocking mode, the return value can also be \-1 if
+no data was available or the data that was available did not contain an
+end-of-line character. When \-1 is returned, the \fBTcl_InputBlocked\fR
+procedure may be invoked to determine if the channel is blocked because
+of input unavailability.
+.PP
+\fBTcl_Gets\fR is the same as \fBTcl_GetsObj\fR except the resulting
+characters are appended to the appended to the dynamic string given by
+\fIdsPtr\fR rather than a Tcl object.
+
+.SH TCL_WRITECHARS, TCL_WRITEOBJ, AND TCL_WRITE
.PP
-If a line was successfully read, the return value is greater than or
-equal to zero, and it indicates the number of characters stored
-in the dynamic string.
-If an error occurs, \fBTcl_Gets\fR returns -1 and records a POSIX error
-code that can be retrieved with \fBTcl_GetErrno\fR.
-\fBTcl_Gets\fR also returns -1 if the end of the file is reached;
-the \fBTcl_Eof\fR procedure can be used to distinguish an error
-from an end-of-file condition.
-.PP
-If the channel is in nonblocking mode, the return value can also
-be -1 if no data was available or the data that was available
-did not contain an end-of-line character.
-When -1 is returned, the \fBTcl_InputBlocked\fR procedure may be
-invoked to determine if the channel is blocked because of input
-unavailability.
-.PP
-\fBTcl_GetsObj\fR is the same as \fBTcl_Gets\fR except the resulting
-characters are appended to a Tcl object \fBlineObjPtr\fR rather than a
-dynamic string.
-.SH TCL_WRITE
-.PP
-\fBTcl_Write\fR accepts \fItoWrite\fR bytes of data at \fIbuf\fR for output
-on \fIchannel\fR. This data may not appear on the output device
-immediately. If the data should appear immediately, call \fBTcl_Flush\fR
-after the call to \fBTcl_Write\fR, or set the \fB-buffering\fR option on
-the channel to \fBnone\fR. If you wish the data to appear as soon as an end
-of line is accepted for output, set the \fB\-buffering\fR option on the
-channel to \fBline\fR mode.
-.PP
-The \fItoWrite\fR argument specifies how many bytes of data are provided in
-the \fIbuf\fR argument. If it is negative, \fBTcl_Write\fR expects the data
+\fBTcl_WriteChars\fR accepts \fIbytesToWrite\fR bytes of character data at
+\fIcharBuf\fR. The UTF-8 characters in the buffer are converted to the
+channel's encoding and queued for output to \fIchannel\fR. If
+\fIbytesToWrite\fR is negative, \fBTcl_WriteChars\fR expects \fIcharBuf\fR
to be NULL terminated and it outputs everything up to the NULL.
.PP
-The return value of \fBTcl_Write\fR is a count of how many
-characters were accepted for output to the channel. This is either equal to
-\fItoWrite\fR or -1 to indicate that an error occurred.
-If an error occurs, \fBTcl_Write\fR also records a POSIX error code
-that may be retrieved with \fBTcl_GetErrno\fR.
+Data queued for output may not appear on the output device immediately, due
+to internal buffering. If the data should appear immediately, call
+\fBTcl_Flush\fR after the call to \fBTcl_WriteChars\fR, or set the
+\fB\-buffering\fR option on the channel to \fBnone\fR. If you wish the data
+to appear as soon as a complete line is accepted for output, set the
+\fB\-buffering\fR option on the channel to \fBline\fR mode.
+.PP
+The return value of \fBTcl_WriteChars\fR is a count of how many bytes were
+accepted for output to the channel. This is either greater than zero to
+indicate success or \-1 to indicate that an error occurred. If an error
+occurs, \fBTcl_WriteChars\fR records a POSIX error code that may be
+retrieved with \fBTcl_GetErrno\fR.
.PP
Newline characters in the output data are translated to platform-specific
-end-of-line sequences according to the \fB\-translation\fR option for
-the channel.
+end-of-line sequences according to the \fB\-translation\fR option for the
+channel. This is done even if the channel has no encoding.
+.PP
+\fBTcl_WriteObj\fR is similar to \fBTcl_WriteChars\fR except it
+accepts a Tcl object whose contents will be output to the channel. The
+UTF-8 characters in \fIwriteObjPtr\fR's string representation are converted
+to the channel's encoding and queued for output to \fIchannel\fR.
+As a performance optimization, when writing to a channel with the encoding
+\fBbinary\fR, UTF-8 characters are not converted as they are written.
+Instead, the bytes in \fIwriteObjPtr\fR's internal representation as a
+byte-array object are written to the channel. The byte-array representation
+of the object will be constructed if it is needed. In this way,
+byte-oriented data can be read from a channel, manipulated by calling
+\fBTcl_GetByteArrayFromObj\fR and related functions, and then written to a
+channel without the expense of ever converting to or from UTF-8.
+.PP
+\fBTcl_Write\fR is similar to \fBTcl_WriteChars\fR except that it doesn't do
+encoding conversions, regardless of the channel's encoding. It is
+deprecated and exists for backwards compatibility with non-internationalized
+Tcl extensions. It accepts \fIbytesToWrite\fR bytes of data at
+\fIbyteBuf\fR and queues them for output to \fIchannel\fR. If
+\fIbytesToWrite\fR is negative, \fBTcl_Write\fR expects \fIbyteBuf\fR to be
+NULL terminated and it outputs everything up to the NULL.
+.VE
.SH TCL_FLUSH
.PP
@@ -419,14 +486,14 @@ data will be read or written. Buffered output is flushed to the channel and
buffered input is discarded, prior to the seek operation.
.PP
\fBTcl_Seek\fR normally returns the new access point.
-If an error occurs, \fBTcl_Seek\fR returns -1 and records a POSIX error
+If an error occurs, \fBTcl_Seek\fR returns \-1 and records a POSIX error
code that can be retrieved with \fBTcl_GetErrno\fR.
After an error, the access point may or may not have been moved.
.SH TCL_TELL
.PP
\fBTcl_Tell\fR returns the current access point for a channel. The returned
-value is -1 if the channel does not support seeking.
+value is \-1 if the channel does not support seeking.
.SH TCL_GETCHANNELOPTION
.PP
@@ -477,7 +544,7 @@ The call always returns zero if the channel is in blocking mode.
buffered in the internal buffers for a channel. If the channel is not open
for reading, this function always returns zero.
-.VS
+.VS 8.0
.SH "PLATFORM ISSUES"
.PP
The handles returned from \fBTcl_GetChannelHandle\fR depend on the
diff --git a/doc/ParseCmd.3 b/doc/ParseCmd.3
new file mode 100644
index 0000000..74cc64e
--- /dev/null
+++ b/doc/ParseCmd.3
@@ -0,0 +1,426 @@
+'\"
+'\" Copyright (c) 1997 Sun Microsystems, Inc.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+'\" SCCS: @(#) ParseCmd.3 1.6 97/12/19 19:11:18
+'\"
+.so man.macros
+.TH Tcl_ParseCommand 3 8.1 Tcl "Tcl Library Procedures"
+.BS
+.SH NAME
+Tcl_ParseCommand, Tcl_ParseExpr, Tcl_ParseBraces, Tcl_ParseQuotedString, Tcl_ParseVarName, Tcl_FreeParse, Tcl_EvalTokens \- parse Tcl scripts and expressions
+.SH SYNOPSIS
+.nf
+\fB#include <tcl.h>\fR
+.sp
+int
+\fBTcl_ParseCommand\fR(\fIinterp, string, numBytes, nested, parsePtr\fR)
+.sp
+int
+\fBTcl_ParseExpr\fR(\fIinterp, string, numBytes, parsePtr\fR)
+.sp
+int
+\fBTcl_ParseBraces\fR(\fIinterp, string, numBytes, parsePtr, append, termPtr\fR)
+.sp
+int
+\fBTcl_ParseQuotedString\fR(\fIinterp, string, numBytes, parsePtr, append, termPtr\fR)
+.sp
+int
+\fBTcl_ParseVarName\fR(\fIinterp, string, numBytes, parsePtr, append\fR)
+.sp
+\fBTcl_FreeParse\fR(\fIusedParsePtr\fR)
+.sp
+Tcl_Obj *
+\fBTcl_EvalTokens\fR(\fIinterp, tokenPtr, numTokens\fR)
+.SH ARGUMENTS
+.AS Tcl_Interp *usedParsePtr
+.AP Tcl_Interp *interp out
+For procedures other than \fBTcl_FreeParse\fR and \fBTcl_EvalTokens\fR,
+used only for error reporting;
+if NULL, then no error messages are left after errors.
+For \fBTcl_EvalTokens\fR, determines the context for evaluating the
+script and also is used for error reporting; must not be NULL.
+.AP char *string in
+Pointer to first character in string to parse.
+.AP int numBytes in
+Number of bytes in \fIstring\fR, not including any terminating null
+character. If less than 0 then the script consists of all characters
+in \fIstring\fR up to the first null character.
+.AP int nested in
+Non-zero means that the script is part of a command substitution so an
+unquoted close bracket should be treated as a command terminator. If zero,
+close brackets have no special meaning.
+.AP int append in
+Non-zero means that \fI*parsePtr\fR already contains valid tokens; the new
+tokens should be appended to those already present. Zero means that
+\fI*parsePtr\fR is uninitialized; any information in it is ignored.
+This argument is normally 0.
+.AP Tcl_Parse *parsePtr out
+Points to structure to fill in with information about the parsed
+command, expression, variable name, etc.
+Any previous information in this structure
+is ignored, unless \fIappend\fR is non-zero in a call to
+\fBTcl_ParseBraces\fR, \fBTcl_ParseQuotedString\fR,
+or \fBTcl_ParseVarName\fR.
+.AP char **termPtr out
+If not NULL, points to a location where
+\fBTcl_ParseBraces\fR and \fBTcl_ParseQuotedString\fR
+will store a pointer to the character
+just after the terminating close-brace or close-quote (respectively)
+if the parse was successful.
+.AP Tcl_Parse *usedParsePtr in
+Points to structure that was filled in by a previous call to
+\fBTcl_ParseCommand\fR, \fBTcl_ParseExpr\fR, \fBTcl_ParseVarName\fR, etc.
+.BE
+
+.SH DESCRIPTION
+.PP
+These procedures parse Tcl commands or portions of Tcl commands such as
+expressions or references to variables.
+Each procedure takes a pointer to a script (or portion thereof)
+and fills in the structure pointed to by \fIparsePtr\fR
+with a collection of tokens describing the information that was parsed.
+The procedures normally return \fBTCL_OK\fR.
+However, if an error occurs then they return \fBTCL_ERROR\fR,
+leave an error message in \fIinterp's\fR result
+(if \fIinterp\fR is not NULL),
+and leave nothing in \fIparsePtr\fR.
+.PP
+\fBTcl_ParseCommand\fR is a procedure that parses Tcl
+scripts. Given a pointer to a script, it
+parses the first command from the script. If the command was parsed
+successfully, \fBTcl_ParseCommand\fR returns \fBTCL_OK\fR and fills in the
+structure pointed to by \fIparsePtr\fR with information about the
+structure of the command (see below for details).
+If an error occurred in parsing the command then
+\fBTCL_ERROR\fR is returned, an error message is left in \fIinterp\fR's
+result, and no information is left at \fI*parsePtr\fR.
+.PP
+\fBTcl_ParseExpr\fR parses Tcl expressions.
+Given a pointer to a script containing an expression,
+\fBTcl_ParseCommand\fR parses the expression.
+If the expression was parsed successfully,
+\fBTcl_ParseExpr\fR returns \fBTCL_OK\fR and fills in the
+structure pointed to by \fIparsePtr\fR with information about the
+structure of the expression (see below for details).
+If an error occurred in parsing the command then
+\fBTCL_ERROR\fR is returned, an error message is left in \fIinterp\fR's
+result, and no information is left at \fI*parsePtr\fR.
+.PP
+\fBTcl_ParseBraces\fR parses a string or command argument
+enclosed in braces such as
+\fB{hello}\fR or \fB{string \\t with \\t tabs}\fR
+from the beginning of its argument \fIstring\fR.
+The first character of \fIstring\fR must be \fB{\fR.
+If the braced string was parsed successfully,
+\fBTcl_ParseBraces\fR returns \fBTCL_OK\fR,
+fills in the structure pointed to by \fIparsePtr\fR
+with information about the structure of the string
+(see below for details),
+and stores a pointer to the character just after the terminating \fB}\fR
+in the location given by \fI*termPtr\fR.
+If an error occurrs while parsing the string
+then \fBTCL_ERROR\fR is returned,
+an error message is left in \fIinterp\fR's result,
+and no information is left at \fI*parsePtr\fR or \fI*termPtr\fR.
+.PP
+\fBTcl_ParseQuotedString\fR parses a double-quoted string such as
+\fB"sum is [expr $a+$b]"\fR
+from the beginning of the argument \fIstring\fR.
+The first character of \fIstring\fR must be \fB"\fR.
+If the double-quoted string was parsed successfully,
+\fBTcl_ParseQuotedString\fR returns \fBTCL_OK\fR,
+fills in the structure pointed to by \fIparsePtr\fR
+with information about the structure of the string
+(see below for details),
+and stores a pointer to the character just after the terminating \fB"\fR
+in the location given by \fI*termPtr\fR.
+If an error occurrs while parsing the string
+then \fBTCL_ERROR\fR is returned,
+an error message is left in \fIinterp\fR's result,
+and no information is left at \fI*parsePtr\fR or \fI*termPtr\fR.
+.PP
+\fBTcl_ParseVarName\fR parses a Tcl variable reference such as
+\fB$abc\fR or \fB$x([expr $index + 1])\fR from the beginning of its
+\fIstring\fR argument.
+The first character of \fIstring\fR must be \fB$\fR.
+If a variable name was parsed successfully, \fBTcl_ParseVarName\fR
+returns \fBTCL_OK\fR and fills in the structure pointed to by
+\fIparsePtr\fR with information about the structure of the variable name
+(see below for details). If an error
+occurrs while parsing the command then \fBTCL_ERROR\fR is returned, an
+error message is left in \fIinterp\fR's result (if \fIinterp\fR isn't
+NULL), and no information is left at \fI*parsePtr\fR.
+.PP
+The information left at \fI*parsePtr\fR
+by \fBTcl_ParseCommand\fR, \fBTcl_ParseExpr\fR, \fBTcl_ParseBraces\fR,
+\fBTcl_ParseQuotedString\fR, and \fBTcl_ParseVarName\fR
+may include dynamically allocated memory.
+If these five parsing procedures return \fBTCL_OK\fR
+then the caller must invoke \fBTcl_FreeParse\fR to release
+the storage at \fI*parsePtr\fR.
+These procedures ignore any existing information in
+\fI*parsePtr\fR (unless \fIappend\fR is non-zero),
+so if repeated calls are being made to any of them
+then \fBTcl_FreeParse\fR must be invoked once after each call.
+.PP
+\fBTcl_EvalTokens\fR evaluates a sequence of parse tokens from a Tcl_Parse
+structure. The tokens typically consist
+of all the tokens in a word or all the tokens that make up the index for
+a reference to an array variable. \fBTcl_EvalTokens\fR performs the
+substitutions requested by the tokens, concatenates the
+resulting values, and returns the result in a new Tcl_Obj. The
+reference count of the object returned as result has been
+incremented, so the caller must
+invoke \fBTcl_DecrRefCount\fR when it is finished with the object.
+If an error occurs while evaluating the tokens (such as a reference to
+a non-existent variable) then the return value is NULL and an error
+message is left in \fIinterp\fR's result.
+
+.SH TCL_PARSE STRUCTURE
+.PP
+\fBTcl_ParseCommand\fR, \fBTcl_ParseExpr\fR, \fBTcl_ParseBraces\fR,
+\fBTcl_ParseQuotedString\fR, and \fBTcl_ParseVarName\fR
+return parse information in two data structures, Tcl_Parse and Tcl_Token:
+.CS
+typedef struct Tcl_Parse {
+ char *\fIcommentStart\fR;
+ int \fIcommentSize\fR;
+ char *\fIcommandStart\fR;
+ int \fIcommandSize\fR;
+ int \fInumWords\fR;
+ Tcl_Token *\fItokenPtr\fR;
+ int \fInumTokens\fR;
+ ...
+} Tcl_Parse;
+
+typedef struct Tcl_Token {
+ int \fItype\fR;
+ char *\fIstart\fR;
+ int \fIsize\fR;
+ int \fInumComponents\fR;
+} Tcl_Token;
+.CE
+.PP
+The first five fields of a Tcl_Parse structure
+are filled in only by \fBTcl_ParseCommand\fR.
+These fields are not used by the other parsing procedures.
+.PP
+\fBTcl_ParseCommand\fR fills in a Tcl_Parse structure
+with information that describes one Tcl command and any comments that
+precede the command.
+If there are comments,
+the \fIcommentStart\fR field points to the \fB#\fR character that begins
+the first comment and \fIcommentSize\fR indicates the number of bytes
+in all of the comments preceding the command, including the newline
+character that terminates the last comment.
+If the command is not preceded by any comments, \fIcommentSize\fR is 0.
+\fBTcl_ParseCommand\fR also sets the \fIcommandStart\fR field
+to point to the first character of the first
+word in the command (skipping any comments and leading space) and
+\fIcommandSize\fR gives the total number of bytes in the command,
+including the character pointed to by \fIcommandStart\fR up to and
+including the newline, close bracket, or semicolon character that
+terminates the command. The \fInumWords\fR field gives the
+total number of words in the command.
+.PP
+All parsing procedures set the remaining fields,
+\fItokenPtr\fR and \fInumTokens\fR.
+The \fItokenPtr\fR field points to the first in an array of Tcl_Token
+structures that describe the components of the entity being parsed.
+The \fInumTokens\fR field gives the total number of tokens
+present in the array.
+Each token contains four fields.
+The \fItype\fR field selects one of several token types
+that are described below. The \fIstart\fR field
+points to the first character in the token and the \fIsize\fR field
+gives the total number of characters in the token. Some token types,
+such as \fBTCL_TOKEN_WORD\fR and \fBTCL_TOKEN_VARIABLE\fR, consist of
+several component tokens, which immediately follow the parent token;
+the \fInumComponents\fR field describes how many of these there are.
+The \fItype\fR field has one of the following values:
+.TP 20
+\fBTCL_TOKEN_WORD\fR
+This token ordinarily describes one word of a command
+but it may also describe a quoted or braced string in an expression.
+The token describes a component of the script that is
+the result of concatenating together a sequence of subcomponents,
+each described by a separate subtoken.
+The token starts with the first non-blank
+character of the component (which may be a double-quote or open brace)
+and includes all characters in the component up to but not including the
+space, semicolon, close bracket, close quote, or close brace that
+terminates the component. The \fInumComponents\fR field counts the total
+number of sub-tokens that make up the word, including sub-tokens
+of \fBTCL_TOKEN_VARIABLE\fR and \fBTCL_TOKEN_BS\fR tokens.
+.TP
+\fBTCL_TOKEN_SIMPLE_WORD\fR
+This token has the same meaning as \fBTCL_TOKEN_WORD\fR, except that
+the word is guaranteed to consist of a single \fBTCL_TOKEN_TEXT\fR
+sub-token. The \fInumComponents\fR field is always 1.
+.TP
+\fBTCL_TOKEN_TEXT\fR
+The token describes a range of literal text that is part of a word.
+The \fInumComponents\fR field is always 0.
+.TP
+\fBTCL_TOKEN_BS\fR
+The token describes a backslash sequence such as \fB\en\fR or \fB\e0xa3\fR.
+The \fInumComponents\fR field is always 0.
+.TP
+\fBTCL_TOKEN_COMMAND\fR
+The token describes a command whose result result must be substituted into
+the word. The token includes the square brackets that surround the
+command. The \fInumComponents\fR field is always 0 (the nested command
+is not parsed; call \fBTcl_ParseCommand\fR recursively if you want to
+see its tokens).
+.TP
+\fBTCL_TOKEN_VARIABLE\fR
+The token describes a variable substitution, including the
+\fB$\fR, variable name, and array index (if there is one) up through the
+close parenthesis that terminates the index. This token is followed
+by one or more additional tokens that describe the variable name and
+array index. If \fInumComponents\fR is 1 then the variable is a
+scalar and the next token is a \fBTCL_TOKEN_TEXT\fR token that gives the
+variable name. If \fInumComponents\fR is greater than 1 then the
+variable is an array: the first sub-token is a \fBTCL_TOKEN_TEXT\fR
+token giving the array name and the remaining sub-tokens are
+\fBTCL_TOKEN_TEXT\fR, \fBTCL_TOKEN_BS\fR, \fBTCL_TOKEN_COMMAND\fR, and
+\fBTCL_TOKEN_VARIABLE\fR tokens that must be concatenated to produce the
+array index. The \fInumComponents\fR field includes nested sub-tokens
+that are part of \fBTCL_TOKEN_VARIABLE\fR tokens in the array index.
+.TP
+\fBTCL_TOKEN_SUB_EXPR\fR
+The token describes one subexpression of an expression
+(or an entire expression).
+A subexpression may consist of a value
+such as an integer literal, variable substitution,
+or parenthesized subexpression;
+it may also consist of an operator and its operands.
+The token starts with the first non-blank character of the subexpression
+up to but not including the space, brace, close-paren, or bracket
+that terminates the subexpression.
+This token is followed by one or more additional tokens
+that describe the subexpression.
+If the first sub-token after the \fBTCL_TOKEN_SUB_EXPR\fR token
+is a \fBTCL_TOKEN_OPERATOR\fR token,
+the subexpression consists of an operator and its token operands.
+If the operator has no operands, the subexpression consists of
+just the \fBTCL_TOKEN_OPERATOR\fR token.
+Each operand is described by a \fBTCL_TOKEN_SUB_EXPR\fR token.
+Otherwise, the subexpression is a value described by
+one of the token types \fBTCL_TOKEN_WORD\fR, \fBTCL_TOKEN_TEXT\fR,
+\fBTCL_TOKEN_BS\fR, \fBTCL_TOKEN_COMMAND\fR,
+\fBTCL_TOKEN_VARIABLE\fR, and \fBTCL_TOKEN_SUB_EXPR\fR.
+The \fInumComponents\fR field
+counts the total number of sub-tokens that make up the subexpression;
+this includes the sub-tokens for any nested \fBTCL_TOKEN_SUB_EXPR\fR tokens.
+.TP
+\fBTCL_TOKEN_OPERATOR\fR
+The token describes one operator of an expression
+such as \fB&&\fR or \fBhypot\fR.
+An \fBTCL_TOKEN_OPERATOR\fR token is always preceeded by a
+\fBTCL_TOKEN_SUB_EXPR\fR token
+that describes the operator and its operands;
+the \fBTCL_TOKEN_SUB_EXPR\fR token's \fInumComponents\fR field
+can be used to determine the number of operands.
+A binary operator such as \fB*\fR
+is followed by two \fBTCL_TOKEN_SUB_EXPR\fR tokens
+that describe its operands.
+A unary operator like \fB-\fR
+is followed by a single \fBTCL_TOKEN_SUB_EXPR\fR token
+for its operand.
+If the operator is a math function such as \fBlog10\fR,
+the \fBTCL_TOKEN_OPERATOR\fR token will give its name and
+the following \fBTCL_TOKEN_SUB_EXPR\fR tokens will describe
+its operands;
+if there are no operands (as with \fBrand\fR),
+no \fBTCL_TOKEN_SUB_EXPR\fR tokens follow.
+There is one trinary operator, \fB?\fR,
+that appears in if-then-else subexpressions
+such as \fIx\fB?\fIy\fB:\fIz\fR;
+in this case, the \fB?\fR \fBTCL_TOKEN_OPERATOR\fR token
+is followed by three \fBTCL_TOKEN_SUB_EXPR\fR tokens for the operands
+\fIx\fR, \fIy\fR, and \fIz\fR.
+The \fInumComponents\fR field for a \fBTCL_TOKEN_OPERATOR\fR token
+is always 0.
+.PP
+After \fBTcl_ParseCommand\fR returns, the first token pointed to by
+the \fItokenPtr\fR field of the
+Tcl_Parse structure always has type \fBTCL_TOKEN_WORD\fR or
+\fBTCL_TOKEN_SIMPLE_WORD\fR. It is followed by the sub-tokens
+that must be concatenated to produce the value of that word.
+The next token is the \fBTCL_TOKEN_WORD\fR or \fBTCL_TOKEN_SIMPLE_WORD\fR
+token for the second word, followed by sub-tokens for that
+word, and so on until all \fInumWords\fR have been accounted
+for.
+.PP
+After \fBTcl_ParseExpr\fR returns, the first token pointed to by
+the \fItokenPtr\fR field of the
+Tcl_Parse structure always has type \fBTCL_TOKEN_SUB_EXPR\fR.
+It is followed by the sub-tokens that must be evaluated
+to produce the value of the expression.
+Only the token information in the Tcl_Parse structure
+is modified: the \fIcommentStart\fR, \fIcommentSize\fR,
+\fIcommandStart\fR, and \fIcommandSize\fR fields are not modified
+by \fBTcl_ParseExpr\fR.
+.PP
+After \fBTcl_ParseBraces\fR returns,
+the array of tokens pointed to by the \fItokenPtr\fR field of the
+Tcl_Parse structure will contain a single \fBTCL_TOKEN_TEXT\fR token
+if the braced string does not contain any backslash-newlines.
+If the string does contain backslash-newlines,
+the array of tokens will contain one or more
+\fBTCL_TOKEN_TEXT\fR or \fBTCL_TOKEN_BS\fR sub-tokens
+that must be concatenated to produce the value of the string.
+If the braced string was just \fB{}\fR
+(that is, the string was empty),
+the single \fBTCL_TOKEN_TEXT\fR token will have a \fIsize\fR field
+containing zero;
+this ensures that at least one token appears
+to describe the braced string.
+Only the token information in the Tcl_Parse structure
+is modified: the \fIcommentStart\fR, \fIcommentSize\fR,
+\fIcommandStart\fR, and \fIcommandSize\fR fields are not modified
+by \fBTcl_ParseBraces\fR.
+.PP
+After \fBTcl_ParseQuotedString\fR returns,
+the array of tokens pointed to by the \fItokenPtr\fR field of the
+Tcl_Parse structure depends on the contents of the quoted string.
+It will consist of one or more \fBTCL_TOKEN_TEXT\fR, \fBTCL_TOKEN_BS\fR,
+\fBTCL_TOKEN_COMMAND\fR, and \fBTCL_TOKEN_VARIABLE\fR sub-tokens.
+The array always contains at least one token;
+for example, if the argument \fIstring\fR is empty,
+the array returned consists of a single \fBTCL_TOKEN_TEXT\fR token
+with a zero \fIsize\fR field.
+Only the token information in the Tcl_Parse structure
+is modified: the \fIcommentStart\fR, \fIcommentSize\fR,
+\fIcommandStart\fR, and \fIcommandSize\fR fields are not modified.
+.PP
+After \fBTcl_ParseVarName\fR returns, the first token pointed to by
+the \fItokenPtr\fR field of the
+Tcl_Parse structure always has type \fBTCL_TOKEN_VARIABLE\fR. It
+is followed by the sub-tokens that make up the variable name as
+described above. The total length of the variable name is
+contained in the \fIsize\fR field of the first token.
+As in \fBTcl_ParseExpr\fR,
+only the token information in the Tcl_Parse structure
+is modified by \fBTcl_ParseVarName\fR:
+the \fIcommentStart\fR, \fIcommentSize\fR,
+\fIcommandStart\fR, and \fIcommandSize\fR fields are not modified.
+.PP
+All of the character pointers in the
+Tcl_Parse and Tcl_Token structures refer
+to characters in the \fIstring\fR argument passed to
+\fBTcl_ParseCommand\fR, \fBTcl_ParseExpr\fR, \fBTcl_ParseBraces\fR,
+\fBTcl_ParseQuotedString\fR, and \fBTcl_ParseVarName\fR.
+.PP
+There are additional fields in the Tcl_Parse structure after the
+\fInumTokens\fR field, but these are for the private use of
+\fBTcl_ParseCommand\fR, \fBTcl_ParseExpr\fR, \fBTcl_ParseBraces\fR,
+\fBTcl_ParseQuotedString\fR, and \fBTcl_ParseVarName\fR; they should not be
+referenced by code outside of these procedures.
+
+.SH KEYWORDS
+backslash substitution, braces, command, expression, parse, token, variable substitution
diff --git a/doc/SaveResult.3 b/doc/SaveResult.3
new file mode 100644
index 0000000..cd123b8
--- /dev/null
+++ b/doc/SaveResult.3
@@ -0,0 +1,65 @@
+'\"
+'\" Copyright (c) 1997 by Sun Microsystems, Inc.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+'\" SCCS: @(#) SaveResult.3 1.2 97/11/14 16:11:46
+'\"
+.so man.macros
+.TH Tcl_SaveResult 3 8.1 Tcl "Tcl Library Procedures"
+.BS
+.SH NAME
+Tcl_SaveResult, Tcl_RestoreResult, Tcl_DiscardResult \- save and restore an interpreter's result
+.SH SYNOPSIS
+.nf
+\fB#include <tcl.h>\fR
+.sp
+\fBTcl_SaveResult(\fIinterp, statePtr\fB)\fR
+.sp
+\fBTcl_RestoreResult(\fIinterp, statePtr\fB)\fR
+.sp
+\fBTcl_DiscardResult(\fIstatePtr\fB)\fR
+.SH ARGUMENTS
+.AS Tcl_SavedResult statePtr
+.AP Tcl_Interp *interp in
+Interpreter for which state should be saved.
+.AP Tcl_SavedResult *statePtr in
+Pointer to location where interpreter result should be saved or restored.
+.BE
+
+.SH DESCRIPTION
+.PP
+These routines allows a C procedure to take a snapshot of the current
+interpreter result so that it can be restored after a call
+to \fBTcl_Eval\fR or some other routine that modifies the interpreter
+result. These routines are passed a pointer to a structure that is
+used to store enough information to restore the interpreter result
+state. This structure can be allocated on the stack of the calling
+procedure. These routines do not save the state of any error
+information in the interpreter (e.g. the \fBerrorCode\fR or
+\fBerrorInfo\fR variables).
+.PP
+\fBTcl_SaveResult\fR moves the string and object results
+of \fIinterp\fR into the location specified by \fIstatePtr\fR.
+\fBTcl_SaveResult\fR clears the result for \fIinterp\fR and
+leaves the result in its normal empty initialized state.
+.PP
+\fBTcl_RestoreResult\fR moves the string and object results from
+\fIstatePtr\fR back into \fIinterp\fR. Any result or error that was
+already in the interpreter will be cleared. The \fIstatePtr\fR is left
+in an uninitialized state and cannot be used until another call to
+\fBTcl_SaveResult\fR.
+.PP
+\fBTcl_DiscardResult\fR releases the saved interpreter state
+stored at \fBstatePtr\fR. The state structure is left in an
+uninitialized state and cannot be used until another call to
+\fBTcl_SaveResult\fR.
+.PP
+Once \fBTcl_SaveResult\fR is called to save the interpreter
+result, either \fBTcl_RestoreResult\fR or
+\fBTcl_DiscardResult\fR must be called to properly clean up the
+memory associated with the saved state.
+
+.SH KEYWORDS
+result, state, interp
diff --git a/doc/SetVar.3 b/doc/SetVar.3
index 32e7a4c..5f4de76 100644
--- a/doc/SetVar.3
+++ b/doc/SetVar.3
@@ -5,23 +5,33 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) SetVar.3 1.30 97/10/10 16:10:36
+'\" SCCS: @(#) SetVar.3 1.32 98/02/05 20:55:24
'\"
.so man.macros
-.TH Tcl_SetVar 3 7.4 Tcl "Tcl Library Procedures"
+.TH Tcl_SetVar 3 8.1 Tcl "Tcl Library Procedures"
.BS
.SH NAME
-Tcl_SetVar, Tcl_SetVar2, Tcl_GetVar, Tcl_GetVar2, Tcl_UnsetVar, Tcl_UnsetVar2 \- manipulate Tcl variables
+Tcl_SetObjVar2, Tcl_SetVar, Tcl_SetVar2, Tcl_GetObjVar2, Tcl_GetVar, Tcl_GetVar2, Tcl_UnsetVar, Tcl_UnsetVar2 \- manipulate Tcl variables
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
+.VS 8.1
+Tcl_Obj *
+\fBTcl_SetObjVar2\fR(\fIinterp, name1, name2, newValuePtr, flags\fR)
+.VE
+.sp
char *
\fBTcl_SetVar\fR(\fIinterp, varName, newValue, flags\fR)
.sp
char *
\fBTcl_SetVar2\fR(\fIinterp, name1, name2, newValue, flags\fR)
.sp
+.VS 8.1
+Tcl_Obj *
+\fBTcl_GetObjVar2\fR(\fIinterp, name1, name2, flags\fR)
+.VE
+.sp
char *
\fBTcl_GetVar\fR(\fIinterp, varName, flags\fR)
.sp
@@ -34,64 +44,100 @@ int
int
\fBTcl_UnsetVar2\fR(\fIinterp, name1, name2, flags\fR)
.SH ARGUMENTS
-.AS Tcl_Interp *newValue
+.AS Tcl_Interp *newValuePtr
.AP Tcl_Interp *interp in
Interpreter containing variable.
+.AP char *name1 in
+Contains the name of an array variable (if \fIname2\fR is non-NULL)
+or (if \fIname2\fR is NULL) either the name of a scalar variable
+or a complete name including both variable name and index.
+May include \fB::\fR namespace qualifiers
+to specify a variable in a particular namespace.
+.AP char *name2 in
+If non-NULL, gives name of element within array; in this
+case \fIname1\fR must refer to an array variable.
+.AP Tcl_Obj *newValuePtr in
+.VS 8.1
+Points to a Tcl object containing the new value for the variable.
+.VE
+.AP int flags in
+OR-ed combination of bits providing additional information. See below
+for valid values.
.AP char *varName in
Name of variable.
-May include a series of \fB::\fR namespace qualifiers
+May include \fB::\fR namespace qualifiers
to specify a variable in a particular namespace.
May refer to a scalar variable or an element of
-an array variable.
-If the name references an element of an array, then it
+an array.
+If the name references an element of an array, then the name
must be in writable memory: Tcl will make temporary modifications
to it while looking up the name.
.AP char *newValue in
-New value for variable.
-.AP int flags in
-OR-ed combination of bits providing additional information for
-operation. See below for valid values.
-.AP char *name1 in
-Name of scalar variable, or name of array variable if \fIname2\fR
-is non-NULL.
-May include a series of \fB::\fR namespace qualifiers
-to specify a variable in a particular namespace.
-.AP char *name2 in
-If non-NULL, gives name of element within array and \fIname1\fR
-must refer to an array variable.
+New value for variable, specified as a NULL-terminated string.
+A copy of this value is stored in the variable.
.BE
.SH DESCRIPTION
.PP
-These procedures may be used to create, modify, read, and delete
+These procedures are used to create, modify, read, and delete
Tcl variables from C code.
.PP
-Note that \fBTcl_GetVar\fR and \fBTcl_SetVar\fR
-have been largely replaced by the
-object-based procedures \fBTcl_ObjGetVar2\fR and \fBTcl_ObjSetVar2\fR.
-Those object-based procedures read, modify, and create
-a variable whose name is held in a Tcl object instead of a string.
-They also return a pointer to the object
-which is the variable's value instead of returning a string.
-Operations on objects can be faster since objects
-hold an internal representation that can be manipulated more efficiently.
-.PP
-\fBTcl_SetVar\fR and \fBTcl_SetVar2\fR
+.VS 8.1
+\fBTcl_SetObjVar2\fR, \fBTcl_SetVar\fR, and \fBTcl_SetVar2\fR
will create a new variable or modify an existing one.
-Both of these procedures set the given variable to the value
-given by \fInewValue\fR, and they return a pointer to a
-copy of the variable's new value, which is stored in Tcl's
+These procedures set the given variable to the value
+given by \fInewValuePtr\fR or \fInewValue\fR and return a
+pointer to the variable's new value, which is stored in Tcl's
variable structure.
-Tcl keeps a private copy of the variable's value, so the caller
-may change \fInewValue\fR after these procedures return without
-affecting the value of the variable.
+\fBTcl_SetObjVar2\fR takes the new value as a Tcl_Obj and returns
+a pointer to a Tcl_Obj. \fBTcl_SetVar\fR and \fBTcl_SetVar2\fR
+take the new value as a string and return a string; they are
+usually less efficient than \fBTcl_SetObjVar2\fR. Note that the
+return value may be different than the \fInewValuePtr\fR or
+.VE
+\fInewValue\fR argument, due to modifications made by write traces.
If an error occurs in setting the variable (e.g. an array
-variable is referenced without giving an index into the array),
-they return NULL.
+variable is referenced without giving an index into the array)
+NULL is returned and an error message is left in \fIinterp\fR's
+result if the \fBTCL_LEAVE_ERR_MSG\fR \fIflag\fR bit is set.
+.PP
+.VS 8.1
+\fBTcl_GetObjVar2\fR, \fBTcl_GetVar\fR, and \fBTcl_GetVar2\fR
+return the current value of a variable.
+The arguments to these procedures are treated in the same way
+as the arguments as the procedures above.
+Under normal circumstances, the return value is a pointer
+to the variable's value. For \fBTcl_GetObjVar2\fR the value is
+returned as a pointer to a Tcl_Obj. For \fBTcl_GetVar\fR and
+\fBTcl_GetVar2\fR the value is returned as a string; this is
+usually less efficient, so \fBTcl_GetObjVar2\fR is preferred.
+.VE
+If an error occurs while reading the variable (e.g. the variable
+doesn't exist or an array element is specified for a scalar
+variable), then NULL is returned and an error message is left
+in \fIinterp\fR's result if the \fBTCL_LEAVE_ERR_MSG\fR \fIflag\fR
+bit is set.
.PP
-The name of the variable may be specified to
-\fBTcl_SetVar\fR and \fBTcl_SetVar2\fR in either of two ways.
-If \fBTcl_SetVar\fR is called, the variable name is given as
+\fBTcl_UnsetVar\fR and \fBTcl_UnsetVar2\fR may be used to remove
+a variable, so that future attempts to read the variable will return
+an error.
+The arguments to these procedures are treated in the same way
+as the arguments to the procedures above.
+If the variable is successfully removed then TCL_OK is returned.
+If the variable cannot be removed because it doesn't exist then
+TCL_ERROR is returned and an error message is left
+in \fIinterp\fR's result if the \fBTCL_LEAVE_ERR_MSG\fR \fIflag\fR
+bit is set.
+If an array element is specified, the given element is removed
+but the array remains.
+If an array name is specified without an index, then the entire
+array is removed.
+.PP
+The name of a variable may be specified to these procedures in
+four ways:
+.IP [1]
+If \fBTcl_SetVar\fR, \fBTcl_GetVar\fR, or \fBTcl_UnsetVar\fR
+is invoked, the variable name is given as
a single string, \fIvarName\fR.
If \fIvarName\fR contains an open parenthesis and ends with a
close parenthesis, then the value between the parentheses is
@@ -100,22 +146,31 @@ the characters before the first open
parenthesis are treated as the name of an array variable.
If \fIvarName\fR doesn't have parentheses as described above, then
the entire string is treated as the name of a scalar variable.
-If \fBTcl_SetVar2\fR is called, then the array name and index
-have been separated by the caller into two separate strings,
-\fIname1\fR and \fIname2\fR respectively; if \fIname2\fR is
-zero it means that a scalar variable is being referenced.
+.IP [2]
+If the \fIname1\fR and \fIname2\fR arguments are provided and
+\fIname2\fR is non-NULL, then an array element is specified and
+the array name and index have
+already been separated by the caller: \fIname1\fR contains the
+name and \fIname2\fR contains the index.
+.VS 8.1
+An error is generated
+if \fIname1\fR contains an open parenthesis and ends with a
+close parenthesis (array element) and \fIname2\fR is non-NULL.
+.IP [3]
+If \fIname2\fR is NULL, \fIname1\fR is treated just like
+\fIvarName\fR in case [1] above (it can be either a scalar or an array
+element variable name).
+.VE
.PP
The \fIflags\fR argument may be used to specify any of several
options to the procedures.
It consists of an OR-ed combination of the following bits.
-Note that the flag bit TCL_PARSE_PART1 is only meaningful
-for the procedures Tcl_SetVar2 and Tcl_GetVar2.
.TP
\fBTCL_GLOBAL_ONLY\fR
-Under normal circumstances the procedures look up variables as follows:
+Under normal circumstances the procedures look up variables as follows.
If a procedure call is active in \fIinterp\fR,
-a variable is looked up at the current level of procedure call.
-Otherwise, a variable is looked up first in the current namespace,
+the variable is looked up at the current level of procedure call.
+Otherwise, the variable is looked up first in the current namespace,
then in the global namespace.
However, if this bit is set in \fIflags\fR then the variable
is looked up only in the global namespace
@@ -124,14 +179,10 @@ If both \fBTCL_GLOBAL_ONLY\fR and \fBTCL_NAMESPACE_ONLY\fR are given,
\fBTCL_GLOBAL_ONLY\fR is ignored.
.TP
\fBTCL_NAMESPACE_ONLY\fR
-Under normal circumstances the procedures look up variables as follows:
-If a procedure call is active in \fIinterp\fR,
-a variable is looked up at the current level of procedure call.
-Otherwise, a variable is looked up first in the current namespace,
-then in the global namespace.
-However, if this bit is set in \fIflags\fR then the variable
-is looked up only in the current namespace
-even if there is a procedure call active.
+If this bit is set in \fIflags\fR then the variable
+is looked up only in the current namespace; if a procedure is active
+its variables are ignored, and the global namespace is also ignored unless
+it is the current namespace.
.TP
\fBTCL_LEAVE_ERR_MSG\fR
If an error is returned and this bit is set in \fIflags\fR, then
@@ -142,9 +193,10 @@ If this flag bit isn't set then no error message is left
and the interpreter's result will not be modified.
.TP
\fBTCL_APPEND_VALUE\fR
-If this bit is set then \fInewValue\fR is appended to the current
-value, instead of replacing it.
-If the variable is currently undefined, then this bit is ignored.
+If this bit is set then \fInewValuePtr\fR or \fInewValue\fR is
+appended to the current value instead of replacing it.
+If the variable is currently undefined, then the bit is ignored.
+This bit is only used by the \fBTcl_Set*\fR procedures.
.TP
\fBTCL_LIST_ELEMENT\fR
If this bit is set, then \fInewValue\fR is converted to a valid
@@ -153,18 +205,6 @@ A separator space is appended before the new list element unless
the list element is going to be the first element in a list or
sublist (i.e. the variable's current value is empty, or contains
the single character ``{'', or ends in `` }'').
-.TP
-\fBTCL_PARSE_PART1\fR
-If this bit is set when calling \fITcl_SetVar2\fR and \fITcl_GetVar2\fR,
-\fIname1\fR may contain both an array and an element name:
-if the name contains an open parenthesis and ends with a
-close parenthesis, then the value between the parentheses is
-treated as an element name (which can have any string value) and
-the characters before the first open
-parenthesis are treated as the name of an array variable.
-If the flag TCL_PARSE_PART1 is given,
-\fIname2\fR should be NULL since the array and element names
-are taken from \fIname1\fR.
.PP
\fBTcl_GetVar\fR and \fBTcl_GetVar2\fR
return the current value of a variable.
@@ -178,8 +218,6 @@ or \fBTcl_SetVar2\fR).
and TCL_LEAVE_ERR_MSG, both of
which have
the same meaning as for \fBTcl_SetVar\fR.
-In addition, \fBTcl_GetVar2\fR uses the bit TCL_PARSE_PART1,
-which has the same meaning as for \fBTcl_SetVar2\fR.
If an error occurs in reading the variable (e.g. the variable
doesn't exist or an array element is specified for a scalar
variable), then NULL is returned.
@@ -198,7 +236,7 @@ If an array name is specified without an index, then the entire
array is removed.
.SH "SEE ALSO"
-Tcl_GetObjResult, Tcl_GetStringResult, Tcl_ObjGetVar2, Tcl_ObjSetVar2, Tcl_TraceVar
+Tcl_GetObjResult, Tcl_GetStringResult, Tcl_TraceVar
.SH KEYWORDS
-array, interpreter, object, scalar, set, unset, variable
+array, get variable, interpreter, object, scalar, set, unset, variable
diff --git a/doc/StringObj.3 b/doc/StringObj.3
index a98fc46..1f654c2 100644
--- a/doc/StringObj.3
+++ b/doc/StringObj.3
@@ -4,13 +4,13 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) @(#) StringObj.3 1.13 97/06/25 13:40:25
+'\" SCCS: @(#) @(#) StringObj.3 1.16 98/01/26 19:39:49
'\"
.so man.macros
-.TH Tcl_StringObj 3 8.0 Tcl "Tcl Library Procedures"
+.TH Tcl_StringObj 3 8.1 Tcl "Tcl Library Procedures"
.BS
.SH NAME
-Tcl_NewStringObj, Tcl_SetStringObj, Tcl_GetStringFromObj, Tcl_AppendToObj, Tcl_AppendStringsToObj, Tcl_SetObjLength, TclConcatObj \- manipulate Tcl objects as strings
+Tcl_NewStringObj, Tcl_SetStringObj, Tcl_GetStringFromObj, Tcl_GetString, Tcl_AppendToObj, Tcl_AppendStringsToObj, Tcl_AppendObjToObj, Tcl_SetObjLength, Tcl_ConcatObj \- manipulate Tcl objects as strings
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -23,7 +23,14 @@ Tcl_Obj *
char *
\fBTcl_GetStringFromObj\fR(\fIobjPtr, lengthPtr\fR)
.sp
+char *
+\fBTcl_GetString\fR(\fIobjPtr\fR)
+.sp
\fBTcl_AppendToObj\fR(\fIobjPtr, bytes, length\fR)
+.VS
+.sp
+\fBTcl_AppendObjToObj\fR(\fIobjPtr, appendObjPtr\fR)
+.VE
.sp
\fBTcl_AppendStringsToObj\fR(\fIobjPtr, string, string, ... \fB(char *) NULL\fR)
.sp
@@ -32,7 +39,7 @@ char *
Tcl_Obj *
\fBTcl_ConcatObj\fR(\fIobjc, objv\fR)
.SH ARGUMENTS
-.AS Tcl_Interp *lengthPtr out
+.AS Tcl_Interp *appendObjPtr in/out
.AP char *bytes in
Points to the first byte of an array of bytes
used to set or append to a string object.
@@ -44,6 +51,10 @@ initializing, setting, or appending to a string object.
If negative, all bytes up to the first null are used.
.AP Tcl_Obj *objPtr in/out
Points to an object to manipulate.
+.VS
+.AP Tcl_Obj *appendObjPtr in
+The object to append to \fIobjPtr\fR in \fBTcl_AppendObjToObj\fR.
+.VE
.AP int *lengthPtr out
If non-NULL, the location where \fBTcl_GetStringFromObj\fR will store
the the length of an object's string representation.
@@ -76,21 +87,30 @@ Both procedures set the object to hold a copy of the specified string.
\fBTcl_SetStringObj\fR frees any old string representation
as well as any old internal representation of the object.
.PP
-\fBTcl_GetStringFromObj\fR returns an object's string representation.
+\fBTcl_GetStringFromObj\fR and \fBTcl_GetString\fR
+return an object's string representation.
This is given by the returned byte pointer
-and length, which is stored in \fIlengthPtr\fR if it is non-NULL.
+and (for \fBTcl_GetStringFromObj\fR) length,
+which is stored in \fIlengthPtr\fR if it is non-NULL.
If the object's string representation is invalid
(its byte pointer is NULL),
the string representation is regenerated from the
object's internal representation.
The storage referenced by the returned byte pointer
is owned by the object manager and should not be modified by the caller.
+The procedure \fBTcl_GetString\fR is used in the common case
+where the caller does not need the length of the string representation.
.PP
\fBTcl_AppendToObj\fR appends the data given by \fIbytes\fR and
\fIlength\fR to the object specified by \fIobjPtr\fR. It does this
in a way that handles repeated calls relatively efficiently (it
overallocates the string space to avoid repeated reallocations
and copies of object's string value).
+.VS
+.PP
+\fBTcl_AppendObjToObj\fR is similar to \fBTcl_AppendToObj\fR, but it
+appends the string value of \fIappendObjPtr\fR to \fIobjPtr\fR.
+.VE
.PP
\fBTcl_AppendStringsToObj\fR is similar to \fBTcl_AppendToObj\fR
except that it can be passed more than one value to append and
diff --git a/doc/Tcl.n b/doc/Tcl.n
index 610fe1b..18e5b10 100644
--- a/doc/Tcl.n
+++ b/doc/Tcl.n
@@ -5,10 +5,10 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) Tcl.n 1.128 96/08/26 12:59:50
+'\" SCCS: @(#) Tcl.n 1.130 97/10/15 10:16:41
'
.so man.macros
-.TH Tcl n "" Tcl "Tcl Built-In Commands"
+.TH Tcl n "8.1" Tcl "Tcl Built-In Commands"
.BS
.SH NAME
Tcl \- Summary of Tcl language syntax.
@@ -111,47 +111,61 @@ special processing.
The following table lists the backslash sequences that are
handled specially, along with the value that replaces each sequence.
.RS
-.TP 6
+.TP 7
\e\fBa\fR
Audible alert (bell) (0x7).
-.TP 6
+.TP 7
\e\fBb\fR
Backspace (0x8).
-.TP 6
+.TP 7
\e\fBf\fR
Form feed (0xc).
-.TP 6
+.TP 7
\e\fBn\fR
Newline (0xa).
-.TP 6
+.TP 7
\e\fBr\fR
Carriage-return (0xd).
-.TP 6
+.TP 7
\e\fBt\fR
Tab (0x9).
-.TP 6
+.TP 7
\e\fBv\fR
Vertical tab (0xb).
-.TP 6
+.TP 7
\e\fB<newline>\fIwhiteSpace\fR
-A single space character replaces the backslash, newline, and all
-spaces and tabs after the newline.
-This backslash sequence is unique in that it is replaced in a separate
-pre-pass before the command is actually parsed.
-This means that it will be replaced even when it occurs between
-braces, and the resulting space will be treated as a word separator
-if it isn't in braces or quotes.
-.TP 6
+.
+A single space character replaces the backslash, newline, and all spaces
+and tabs after the newline. This backslash sequence is unique in that it
+is replaced in a separate pre-pass before the command is actually parsed.
+This means that it will be replaced even when it occurs between braces,
+and the resulting space will be treated as a word separator if it isn't
+in braces or quotes.
+.TP 7
\e\e
Backslash (``\e'').
-.TP 6
-\e\fIooo\fR
-The digits \fIooo\fR (one, two, or three of them) give the octal value of
-the character.
-.TP 6
-\e\fBx\fIhh\fR
-The hexadecimal digits \fIhh\fR give the hexadecimal value of
-the character. Any number of digits may be present.
+.VS 8.1 br
+.TP 7
+\e\fIooo\fR
+.
+The digits \fIooo\fR (one, two, or three of them) give an eight-bit octal
+value for the Unicode character that will be inserted. The upper bits of the
+Unicode character will be 0.
+.TP 7
+\e\fBx\fIhh\fR
+.
+The hexadecimal digits \fIhh\fR give an eight-bit hexadecimal value for the
+Unicode character that will be inserted. Any number of hexadecimal digits
+may be present; however, all but the last two are ignored (the result is
+always a one-byte quantity). The upper bits of the Unicode character will
+be 0.
+.TP 7
+\e\fBu\fIhhhh\fR
+.
+The hexadecimal digits \fIhhhh\fR (one, two, three, or four of them) give a
+sixteen-bit hexadecimal value for the Unicode character that will be
+inserted.
+.VE
.LP
Backslash substitution is not performed on words enclosed in braces,
except for backslash-newline as described above.
diff --git a/doc/Thread.3 b/doc/Thread.3
new file mode 100644
index 0000000..99648a1
--- /dev/null
+++ b/doc/Thread.3
@@ -0,0 +1,97 @@
+'\"
+'\" Copyright (c) 1998 Sun Microsystems, Inc.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+'\" SCCS: @(#) Thread.3 1.2 98/02/19 14:02:17
+'\"
+.so man.macros
+.TH Tcl_ConditionNotify 3 "" Tcl "Tcl Library Procedures"
+.BS
+.SH NAME
+Tcl_ConditionNotify, Tcl_ConditionWait, Tcl_GetThreadData, Tcl_MutexLock, Tcl_MutexUnlock \- thread synchronization support.
+.SH SYNOPSIS
+.nf
+\fB#include <tcl.h>\fR
+.sp
+void
+\fBTcl_ConditionNotify\fR(\fIcondPtr\fR)
+.sp
+void
+\fBTcl_ConditionWait\fR(\fIcondPtr, mutexPtr, timePtr\fR)
+.sp
+VOID *
+\fBTcl_GetThreadData\fR(\fIkeyPtr, size\fR)
+.sp
+void
+\fBTcl_MutexLock\fR(\fImutexPtr\fR)
+.sp
+void
+\fBTcl_MutexUnlock\fR(\fImutexPtr\fR)
+.SH ARGUMENTS
+.AS Tcl_ThreadDataKey *keyPtr
+.AP Tcl_Condition *condPtr in
+A condition variable, which must be associated with a mutex lock.
+.AP Tcl_Condition *mutexPtr in
+A mutex lock.
+.AP Tcl_Time *timePtr in
+A time limit on the condition wait. NULL to wait forever.
+Note that a polling value of 0 seconds doesn't make much sense.
+.AP Tcl_ThreadDataKey *keyPtr in
+This identifies a block of thread local storage. The key should be
+static and process-wide, yet each thread will end up associating
+a different block of storage with this key.
+.AP int *size in
+The size of the thread local storage block. This amount of data
+is allocated and initialized to zero the first time each thread
+calls \fBTcl_GetThreadData\fR.
+.BE
+
+.SH DESCRIPTION
+.PP
+A mutex is a lock that is used to serialize all threads through a piece
+of code by calling \fBTcl_MutexLock\fR and \fBTcl_MutexUnlock\fR.
+If one thread holds a mutex, any other thread calling \fBTcl_MutexLock\fR will
+block until \fBTcl_MutexUnlock\fR is called. A thread can deadlock
+on itself if it tries to lock the mutex twice.
+\fBTcl_MutexLock\fR and \fBTcl_MutexUnlock\fR
+procedures are defined as empty macros if not compiling with threads enabled.
+.PP
+A condition variable is used as a signaling mechanism:
+a thread can lock a mutex and then wait on a condition variable
+with \fBTcl_ConditionWait\fR. This atomically releases the mutex lock
+and blocks the waiting thread until another thread calls
+\fBTcl_ConditionNotify\fR. The caller of \fBTcl_ConditionNotify\fR should
+have the associated mutex held by previously calling \fBTcl_MutexLock\fR,
+but this is not enforced. Notifying the
+condition variable unblocks all threads waiting on the condition variable,
+but they do not proceed until the mutex is released with \fBTcl_MutexUnlock\fR.
+The implementation of \fBTcl_ConditionWait\fR automatically locks
+the mutex before returning.
+.PP
+The caller of \fBTcl_ConditionWait\fR should be prepared for spurious
+notifications by calling \fBTcl_ConditionWait\fR within a while loop
+that tests some invariant.
+.PP
+The \fBTcl_GetThreadData\fR call returns a pointer to a block of
+thread-private data. Its argument is a key that is shared by all threads
+and a size for the block of storage. The storage is automatically
+allocated and initialized to all zeros the first time each thread asks for it.
+The storage is automatically deallocated by \fBTcl_FinalizeThread\fR
+.SH INITIALIZATION
+.PP
+.PP
+All of these synchronization objects are self initializing.
+They are implemented as opaque pointers that should be NULL
+upon first use.
+The mutexes and condition variables are
+cleaned up by process exit handlers. Thread local storage is
+reclaimed during \fBTcl_FinalizeThread\fR.
+.SH CREATING THREADS
+The API to create threads is not finalized at this time.
+There are private facilities to create threads that contain a new
+Tcl interpreter, and to send scripts among threads.
+Dive into tclThreadTest.c and tclThread.c for examples.
+.SH KEYWORDS
+thread, mutex, condition variable, thread local storage
diff --git a/doc/ToUpper.3 b/doc/ToUpper.3
new file mode 100644
index 0000000..971eb5a
--- /dev/null
+++ b/doc/ToUpper.3
@@ -0,0 +1,90 @@
+'\"
+'\" Copyright (c) 1997 by Sun Microsystems, Inc.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+'\" SCCS: @(#) ToUpper.3 1.1 98/01/12 17:17:02
+'\"
+.so man.macros
+.TH Tcl_UtfToUpper 3 "8.1" Tcl "Tcl Library Procedures"
+.BS
+.SH NAME
+Tcl_UniCharToUpper, Tcl_UniCharToLower, Tcl_UniCharToTitle, Tcl_UtfToUpper, Tcl_UtfToLower, Tcl_UtfToTitle \- routines for manipulating the case of Unicode characters and UTF-8 strings.
+.SH SYNOPSIS
+.nf
+\fB#include <tcl.h>\fR
+.sp
+Tcl_UniChar
+\fBTcl_UniCharToUpper\fR(\fIch\fR)
+.sp
+Tcl_UniChar
+\fBTcl_UniCharToLower\fR(\fIch\fR)
+.sp
+Tcl_UniChar
+\fBTcl_UniCharToTitle\fR(\fIch\fR)
+.sp
+int
+\fBTcl_UtfToUpper\fR(\fIstr\fR)
+.sp
+int
+\fBTcl_UtfToLower\fR(\fIstr\fR)
+.sp
+int
+\fBTcl_UtfToTitle\fR(\fIstr\fR)
+.SH ARGUMENTS
+.AS char *str in/out
+.AP int ch in
+The Tcl_UniChar to be converted.
+.AP char *str in/out
+Pointer to UTF-8 string to be converted in place.
+.BE
+
+.SH DESCRIPTION
+.PP
+The first three routines convert the case of individual Unicode characters:
+.PP
+If \fIch\fR represents a lower-case character,
+\fBTcl_UniCharToUpper\fR returns the corresponding upper-case
+character. If no upper-case character is defined, it returns the
+character unchanged.
+.PP
+If \fIch\fR represents an upper-case character,
+\fBTcl_UniCharToLower\fR returns the corresponding lower-case
+character. If no lower-case character is defined, it returns the
+character unchanged.
+.PP
+If \fIch\fR represents a lower-case character,
+\fBTcl_UniCharToTitle\fR returns the corresponding title-case
+character. If no title-case character is defined, it returns the
+corresponding upper-case character. If no upper-case character is
+defined, it returns the character unchanged. Title-case is defined
+for a small number of characters that have a different appearance when
+they are at the beginning of a capitalized word.
+.PP
+The next three routines convert the case of UTF-8 strings in place in
+memory:
+.PP
+\fBTcl_UtfToUpper\fR changes every UTF-8 character in \fIstr\fR to
+upper-case. Because changing the case of a character may change its
+size, the byte offset of each character in the resulting string may
+differ from its original location. \fBTcl_UtfToUpper\fR writes a null
+byte at the end of the converted string. \fBTcl_UtfToUpper\fR returns
+the new length of the string in bytes. This new length is guaranteed
+to be no longer than the original string length.
+.PP
+\fBTcl_UtfToLower\fR is the same as \fBTcl_UtfToUpper\fR except it
+turns each character in the string into its lower-case equivalent.
+.PP
+\fBTcl_UtfToTitle\fR is the same as \fBTcl_UtfToUpper\fR except it
+turns the first character in the string into its title-case equivalent
+and all following characters into their lower-case equivalents.
+
+.SH BUGS
+.PP
+At this time, the case conversions are only defined for the ISO8859-1
+characters. Unicode characters above 0x00ff are not modified by these
+routines.
+
+.SH KEYWORDS
+utf, unicode, toupper, tolower, totitle, case
diff --git a/doc/TraceVar.3 b/doc/TraceVar.3
index 976be4f..c0d7c3a 100644
--- a/doc/TraceVar.3
+++ b/doc/TraceVar.3
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) TraceVar.3 1.27 97/10/10 15:05:37
+'\" SCCS: @(#) TraceVar.3 1.29 98/02/19 13:20:48
'\"
.so man.macros
.TH Tcl_TraceVar 3 7.4 Tcl "Tcl Library Procedures"
@@ -44,7 +44,7 @@ must be in writable memory: Tcl will make temporary modifications
to it while looking up the name.
.AP int flags in
OR-ed combination of the values TCL_TRACE_READS, TCL_TRACE_WRITES, and
-TCL_TRACE_UNSETS, TCL_PARSE_PART1, and TCL_GLOBAL_ONLY.
+TCL_TRACE_UNSETS, TCL_TRACE_ARRAY, and TCL_GLOBAL_ONLY.
Not all flags are used by all
procedures. See below for more information.
.AP Tcl_VarTraceProc *proc in
@@ -96,6 +96,12 @@ A variable may be unset either explicitly by an \fBunset\fR command,
or implicitly when a procedure returns (its local variables are
automatically unset) or when the interpreter is deleted (all
variables are automatically unset).
+.TP
+\fBTCL_TRACE_ARRAY\fR
+Invoke \fIproc\fR whenever the array command is invoked.
+This gives the trace procedure a chance to update the array before
+array names or array get is called. Note that this is called
+before an array set, but that will trigger write traces.
.PP
Whenever one of the specified operations occurs on the variable,
\fIproc\fR will be invoked.
@@ -120,7 +126,8 @@ in the normal two-part form (see the description of \fBTcl_TraceVar2\fR
below for details).
\fIFlags\fR is an OR-ed combination of bits providing several
pieces of information.
-One of the bits TCL_TRACE_READS, TCL_TRACE_WRITES, or TCL_TRACE_UNSETS
+One of the bits TCL_TRACE_READS, TCL_TRACE_WRITES, TCL_TRACE_ARRAY,
+or TCL_TRACE_UNSETS
will be set in \fIflags\fR to indicate which operation is being performed
on the variable.
The bit TCL_GLOBAL_ONLY will be set whenever the variable being
@@ -175,24 +182,26 @@ The procedures \fBTcl_TraceVar2\fR, \fBTcl_UntraceVar2\fR, and
except that the name of the variable consists of two parts.
\fIName1\fR gives the name of a scalar variable or array,
and \fIname2\fR gives the name of an element within an array.
-If \fIname2\fR is NULL it means that either the variable is
-a scalar or the trace is to be set on the entire array rather
-than an individual element (see WHOLE-ARRAY TRACES below for
-more information).
-As a special case, if the flag TCL_PARSE_PART1 is specified,
+.VS 8.1
+When \fIname2\fR is NULL,
\fIname1\fR may contain both an array and an element name:
if the name contains an open parenthesis and ends with a
close parenthesis, then the value between the parentheses is
treated as an element name (which can have any string value) and
the characters before the first open
parenthesis are treated as the name of an array variable.
-If the flag TCL_PARSE_PART1 is given,
-\fIname2\fR should be NULL since the array and element names
-are taken from \fIname1\fR.
+If \fIname2\fR is NULL and \fIname1\fR does not refer
+to an array element
+.VE
+it means that either the variable is
+a scalar or the trace is to be set on the entire array rather
+than an individual element (see WHOLE-ARRAY TRACES below for
+more information).
+
.SH "ACCESSING VARIABLES DURING TRACES"
.PP
-During read and write traces, the
+During read, write, and array traces, the
trace procedure can read, write, or unset the traced
variable using \fBTcl_GetVar2\fR, \fBTcl_SetVar2\fR, and
other procedures.
@@ -245,6 +254,12 @@ access.
If it deletes the variable then the traced access will return
an empty string.
.PP
+When array tracing has been specified, the trace procedure
+will be invoked at the beginning of the array command implementation,
+before any of the operations like get, set, or names have been invoked.
+The trace procedure can modify the array elements with \fBTcl_SetVar\fR
+and \fBTcl_SetVar2\fR.
+.PP
When unset tracing has been specified, the trace procedure
will be invoked whenever the variable is destroyed.
The traces will be called after the variable has been
@@ -343,6 +358,9 @@ to clean up and free their own internal data structures.
Tcl doesn't do any error checking to prevent trace procedures
from misusing the interpreter during traces with TCL_INTERP_DESTROYED
set.
+.PP
+Array traces are not yet integrated with the Tcl "info exists" command,
+nor is there Tcl-level access to array traces.
.SH KEYWORDS
clientData, trace, variable
diff --git a/doc/Translate.3 b/doc/Translate.3
index 6330ee9..0b7b918 100644
--- a/doc/Translate.3
+++ b/doc/Translate.3
@@ -1,14 +1,14 @@
'\"
'\" Copyright (c) 1989-1993 The Regents of the University of California.
-'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
+'\" Copyright (c) 1994-1998 Sun Microsystems, Inc.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) Translate.3 1.22 96/08/26 12:59:51
+'\" SCCS: @(#) Translate.3 1.24 98/01/16 23:58:06
'\"
.so man.macros
-.TH Tcl_TranslateFileName 3 7.5 Tcl "Tcl Library Procedures"
+.TH Tcl_TranslateFileName 3 8.1 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_TranslateFileName \- convert file name to native form and replace tilde with home directory
@@ -26,7 +26,7 @@ Interpreter in which to report an error, if any.
File name, which may start with a ``~''.
.AP Tcl_DString *bufferPtr in/out
If needed, this dynamic string is used to store the new file name.
-At the time of the call it should be uninitialized or empty. The
+At the time of the call it should be uninitialized or free. The
caller must eventually call \fBTcl_DStringFree\fR to free up
anything stored here.
.BE
diff --git a/doc/Utf.3 b/doc/Utf.3
new file mode 100644
index 0000000..062efa2
--- /dev/null
+++ b/doc/Utf.3
@@ -0,0 +1,160 @@
+'\"
+'\" Copyright (c) 1997 Sun Microsystems, Inc.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+'\" SCCS: @(#) Utf.3 1.4 98/01/19 14:35:31
+'\"
+.so man.macros
+.TH Utf 3 "8.1" Tcl "Tcl Library Procedures"
+.BS
+.SH NAME
+Tcl_UniChar, Tcl_UniCharToUtf, Tcl_UtfToUniChar, Tcl_UtfCharComplete, Tcl_NumUtfChars, Tcl_UtfFindFirst, Tcl_UtfFindLast, Tcl_UtfNext, Tcl_UtfPrev, Tcl_UniCharAtIndex, Tcl_UtfAtIndex, Tcl_UtfBackslash \- routines for manipulating UTF-8 strings.
+.SH SYNOPSIS
+.nf
+\fB#include <tcl.h>\fR
+.sp
+typedef ... Tcl_UniChar;
+.sp
+int
+\fBTcl_UniCharToUtf\fR(\fIch, buf\fR)
+.sp
+int
+\fBTcl_UtfToUniChar\fR(\fIsrc, chPtr\fR)
+.sp
+int
+\fBTcl_UtfCharComplete\fR(\fIsrc, len\fR)
+.sp
+int
+\fBTcl_NumUtfChars\fR(\fIsrc, len\fR)
+.sp
+char *
+\fBTcl_UtfFindFirst\fR(\fIsrc, ch\fR)
+.sp
+char *
+\fBTcl_UtfFindLast\fR(\fIsrc, ch\fR)
+.sp
+char *
+\fBTcl_UtfNext\fR(\fIsrc\fR)
+.sp
+char *
+\fBTcl_UtfPrev\fR(\fIsrc, start\fR)
+.sp
+Tcl_UniChar
+\fBTcl_UniCharAtIndex\fR(\fIsrc, index\fR)
+.sp
+char *
+\fBTcl_UtfAtIndex\fR(\fIsrc, index\fR)
+.sp
+int
+\fBTcl_UtfBackslash\fR(\fIsrc, readPtr, dst\fR)
+.SH ARGUMENTS
+.AS "CONST char" *chPtr out
+.AP char *buf out
+Buffer in which the UTF-8 representation of the Tcl_UniChar is stored. At most
+TCL_UTF_MAX bytes are stored in the buffer.
+.AP int ch in
+The Tcl_UniChar to be converted or examined.
+.AP Tcl_UniChar *chPtr out
+Filled with the Tcl_UniChar represented by the head of the UTF-8 string.
+.AP "CONST char" *src in
+Pointer to a UTF-8 string.
+.AP int len in
+The length of the UTF-8 string in bytes (not UTF-8 characters). If
+negative, all bytes up to the first null byte are used.
+.AP "CONST char" *start in
+Pointer to the beginning of a UTF-8 string.
+.AP int index in
+The index of a character (not byte) in the UTF-8 string.
+.AP int *readPtr out
+If non-NULL, filled with the number of bytes in the backslash sequence,
+including the backslash character.
+.AP char *dst out
+Buffer in which the bytes represented by the backslash sequence are stored.
+At most TCL_UTF_MAX bytes are stored in the buffer.
+.BE
+
+.SH DESCRIPTION
+.PP
+These routines convert between UTF-8 strings and Tcl_UniChars. A
+Tcl_UniChar is a Unicode character represented as an unsigned, fixed-size
+quantity. A UTF-8 character is a Unicode character represented as
+a varying-length sequence of up to TCL_UTF_MAX bytes. A multibyte UTF-8
+sequence consists of a lead byte followed by some number of trail bytes.
+.PP
+\fBTCL_UTF_MAX\fR is the maximum number of bytes that it takes to
+represent one Unicode character in the UTF-8 representation.
+.PP
+\fBTcl_UniCharToUtf\fR stores the Tcl_UniChar \fIch\fR as a UTF-8 string
+in starting at \fIbuf\fR. The return value is the number of bytes stored
+in \fIbuf\fR.
+.PP
+\fBTcl_UtfToUniChar\fR reads one UTF-8 character starting at \fIsrc\fR
+and stores it as a Tcl_UniChar in \fI*chPtr\fR. The return value is the
+number of bytes read from \fIsrc\fR.. The caller must ensure that the
+source buffer is long enough such that this routine does not run off the
+end and dereference non-existent or random memory; if the source buffer
+is known to be null terminated, this will not happen. If the input is
+not in proper UTF-8 format, \fBTcl_UtfToUniChar\fR will store the first
+byte of \fIsrc\fR in \fI*chPtr\fR as a Tcl_UniChar between 0x0000 and
+0x00ff and return 1.
+.PP
+\fBTcl_UtfCharComplete\fR returns 1 if the source UTF-8 string \fIsrc\fR
+of length \fIlen\fR bytes is long enough to be decoded by
+\fBTcl_UtfToUniChar\fR, or 0 otherwise. This function does not guarantee
+that the UTF-8 string is properly formed. This routine is used by
+procedures that are operating on a byte at a time and need to know if a
+full Tcl_UniChar has been seen.
+.PP
+\fBTcl_NumUtfChars\fR corresponds to \fBstrlen\fR for UTF-8 strings. It
+returns the number of Tcl_UniChars that are represented by the UTF-8 string
+\fIsrc\fR. The length of the source string is \fIlen\fR bytes. If the
+length is negative, all bytes up to the first NULL byte are used.
+.PP
+\fBTcl_UtfFindFirst\fR corresponds to \fBstrchr\fR for UTF-8 strings. It
+returns a pointer to the first occurance of the Tcl_UniChar \fIch\fR
+in the NULL-terminated UTF-8 string \fIsrc\fR. The NULL terminator is
+considered part of the UTF-8 string.
+.PP
+\fBTcl_UtfFindLast\fR corresponds to \fBstrrchr\fR for UTF-8 strings. It
+returns a pointer to the last occurance of the Tcl_UniChar \fIch\fR
+in the NULL terminated UTF-8 string \fIsrc\fR. The NULL terminator is
+considered part of the UTF-8 string.
+.PP
+Given \fIsrc\fR, a pointer to some location in a UTF-8 string,
+\fBTcl_UtfNext\fR returns a pointer to the next UTF-8 character in the
+string. The caller must not ask for the next character after the last
+character in the string.
+.PP
+Given \fIsrc\fR, a pointer to some location in a UTF-8 string,
+\fBTcl_UtfPrev\fR returns a pointer to the previous UTF-8 character in the
+string. This function will not back up to a position before \fIstart\fR,
+the start of the UTF-8 string. If \fIsrc\fR was already at \fIstart\fR, the
+return value will be \fIstart\fR.
+.PP
+\fBTcl_UniCharAtIndex\fR corresponds to a C string array dereference or the
+Pascal Ord() function. It returns the Tcl_UniChar represented at the
+specified character (not byte) \fIindex\fR in the UTF-8 string
+\fIsrc\fR. The source string must contain at least \fIindex\fR
+characters.
+.PP
+\fBTcl_UtfAtIndex\fR returns a pointer to the specified character (not
+byte) \fIindex\fR in the UTF-8 string \fIsrc\fR. The source string must
+contain at least \fIindex\fR characters. This is equivalent to calling
+\fBTcl_UtfNext\fR \fIindex\fR times.
+.PP
+\fBTcl_UtfBackslash\fR is a utility procedure used by several of the Tcl
+commands. It parses a backslash sequence and stores the properly formed
+UTF-8 character represented by the backslash sequence in the output
+buffer \fIdst\fR. At most TCL_UTF_MAX bytes are stored in the buffer.
+\fBTcl_UtfBackslash\fR modifies \fI*readPtr\fR to contain the number
+of bytes in the backslash sequence, including the backslash character.
+The return value is the number of bytes stored in the output buffer.
+.PP
+See the \fBTcl\fR manual entry for information on the valid backslash
+sequences. All of the sequences described in the Tcl manual entry are
+supported by \fBTcl_UtfBackslash\fR.
+
+.SH KEYWORDS
+utf, unicode, backslash
diff --git a/doc/binary.n b/doc/binary.n
index 067c52e..2833eed 100644
--- a/doc/binary.n
+++ b/doc/binary.n
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) binary.n 1.7 97/11/11 19:08:47
+'\" SCCS: @(#) binary.n 1.8 97/11/20 12:35:30
'\"
.so man.macros
.TH binary n 8.0 Tcl "Tcl Built-In Commands"
diff --git a/doc/exec.n b/doc/exec.n
index 22caf80..4dede37 100644
--- a/doc/exec.n
+++ b/doc/exec.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) exec.n 1.17 96/09/18 15:21:17
+'\" SCCS: @(#) exec.n 1.18 96/11/25 14:18:47
'\"
.so man.macros
.TH exec n 7.6 Tcl "Tcl Built-In Commands"
@@ -202,10 +202,11 @@ instead of ``applbakery.default'').
Two or more forward or backward slashes in a row in a path refer to a
network path. For example, a simple concatenation of the root directory
\fBc:/\fR with a subdirectory \fB/windows/system\fR will yield
-\fBc://windows/system\fR (two slashes together), which refers to the
-directory \fB/system\fR on the machine \fBwindows\fR (and the \fBc:/\fR is
-ignored), and is not equivalent to \fBc:/windows/system\fR, which describes
-a directory on the current computer.
+\fBc://windows/system\fR (two slashes together), which refers to the mount
+point called \fBsystem\fR on the machine called \fBwindows\fR (and the
+\fBc:/\fR is ignored), and is not equivalent to \fBc:/windows/system\fR,
+which describes a directory on the current computer. The \fBfile join\fR
+command should be used to concatenate path components.
.TP
\fBWindows NT\fR
.
@@ -264,7 +265,7 @@ the caller must prepend ``\fBcommand.com /c\0\fR'' to the desired command.
Once a 16-bit DOS application has read standard input from a console and
then quit, all subsequently run 16-bit DOS applications will see the
standard input as already closed. 32-bit applications do not have this
-problem and will run correctly even after a 16-bit DOS application thinks
+problem and will run correctly, even after a 16-bit DOS application thinks
that standard input is closed. There is no known workaround for this bug
at this time.
.sp
@@ -282,8 +283,8 @@ other end of the pipe must be closed before the 16-bit DOS application
begins executing. All standard output or error from a 16-bit DOS
application to a pipe is collected into temporary files; the application
must terminate before the temporary files are redirected to the next stage
-of the pipeline. This is due to a workaround for a Windows 95 bug in the
-implementation of pipes, and is how the Windows 95 command line interpreter
+of the pipeline. This is due to a workaround for a Windows 95 bug in the
+implementation of pipes, and is how the standard Windows 95 DOS shell
handles pipes itself.
.sp
Certain applications, such as \fBcommand.com\fR, should not be executed
diff --git a/doc/fconfigure.n b/doc/fconfigure.n
index 1c187ac..414efb1 100644
--- a/doc/fconfigure.n
+++ b/doc/fconfigure.n
@@ -4,10 +4,10 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) fconfigure.n 1.23 96/04/16 08:20:07
+'\" SCCS: @(#) fconfigure.n 1.25 97/10/20 15:22:10
'\"
.so man.macros
-.TH fconfigure n 7.5 Tcl "Tcl Built-In Commands"
+.TH fconfigure n 8.1 Tcl "Tcl Built-In Commands"
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
@@ -51,122 +51,143 @@ using the Tcl event loop (e.g. by calling \fBTcl_DoOneEvent\fR or
invoking the \fBvwait\fR command).
.TP
\fB\-buffering\fR \fInewValue\fR
+.
If \fInewValue\fR is \fBfull\fR then the I/O system will buffer output
until its internal buffer is full or until the \fBflush\fR command is
invoked. If \fInewValue\fR is \fBline\fR, then the I/O system will
automatically flush output for the channel whenever a newline character
is output. If \fInewValue\fR is \fBnone\fR, the I/O system will flush
-automatically after every output operation.
-The default is for \fB\-buffering\fR to be set to \fBfull\fR except for
-channels that connect to terminal-like devices; for these channels the
-initial setting is \fBline\fR.
+automatically after every output operation. The default is for
+\fB\-buffering\fR to be set to \fBfull\fR except for channels that
+connect to terminal-like devices; for these channels the initial setting
+is \fBline\fR.
.TP
\fB\-buffersize\fR \fInewSize\fR
+.
\fINewvalue\fR must be an integer; its value is used to set the size of
buffers, in bytes, subsequently allocated for this channel to store input
or output. \fINewvalue\fR must be between ten and one million, allowing
buffers of ten to one million bytes in size.
+.VS 8.1 br
+.TP
+\fB\-encoding\fR \fIname\fR
+.
+This option is used to specify the encoding of the channel, so that the data
+can be converted to and from Unicode for use in Tcl. For instance, in
+order for Tcl to read characters from a Japanese file in \fBshiftjis\fR
+and properly process and display the contents, the encoding would be set
+to \fBshiftjis\fR. Thereafter, when reading from the channel, the bytes in
+the Japanese file would be converted to Unicode as they are read.
+Writing is also supported \- as Tcl strings are written to the channel they
+will automatically be converted to the specified encoding on output.
+.RS
+.PP
+If a file contains pure binary data (for instance, a JPEG image), the
+encoding for the channel should be configured to be \fBbinary\fR. Tcl
+will then assign no interpretation to the data in the file and simply read or
+write raw bytes. The Tcl \fBbinary\fR command can be used to manipulate this
+byte-oriented data.
+.PP
+The default encoding for newly opened channels is the same platform- and
+locale-dependent system encoding used for interfacing with the operating
+system.
+.RE
+.VE
.TP
\fB\-eofchar\fR \fIchar\fR
.TP
\fB\-eofchar\fR \fB{\fIinChar outChar\fB}\fR
-This option supports DOS file systems that use Control-z (\ex1a) as
-an end of file marker.
-If \fIchar\fR is not an empty string, then this character signals
-end of file when it is encountered during input.
-For output, the end of file character is output when
-the channel is closed.
-If \fIchar\fR is the empty string, then there is no special
-end of file character marker.
-For read-write channels, a two-element list specifies
-the end of file marker for input and output, respectively.
-As a convenience, when setting the end-of-file character
-for a read-write channel
-you can specify a single value that will apply to both reading and writing.
-When querying the end-of-file character of a read-write channel,
-a two-element list will always be returned.
-The default value for \fB\-eofchar\fR is the empty string in all
-cases except for files under Windows. In that case the \fB\-eofchar\fR
-is Control-z (\ex1a) for reading and the empty string for writing.
+.
+This option supports DOS file systems that use Control-z (\ex1a) as an
+end of file marker. If \fIchar\fR is not an empty string, then this
+character signals end-of-file when it is encountered during input. For
+output, the end-of-file character is output when the channel is closed.
+If \fIchar\fR is the empty string, then there is no special end of file
+character marker. For read-write channels, a two-element list specifies
+the end of file marker for input and output, respectively. As a
+convenience, when setting the end-of-file character for a read-write
+channel you can specify a single value that will apply to both reading
+and writing. When querying the end-of-file character of a read-write
+channel, a two-element list will always be returned. The default value
+for \fB\-eofchar\fR is the empty string in all cases except for files
+under Windows. In that case the \fB\-eofchar\fR is Control-z (\ex1a) for
+reading and the empty string for writing.
.TP
\fB\-translation\fR \fImode\fR
.TP
-\fB\-translation\fR \fB{\fIinMode outMode\fB}\fR
-In Tcl scripts the end of a line is always represented using a
-single newline character (\en).
-However, in actual files and devices the end of a line may be
-represented differently on different platforms, or even for
-different devices on the same platform. For example, under UNIX
-newlines are used in files, whereas carriage-return-linefeed
-sequences are normally used in network connections.
-On input (i.e., with \fBgets\fP and \fBread\fP)
-the Tcl I/O system automatically translates the external end-of-line
-representation into newline characters.
-Upon output (i.e., with \fBputs\fP),
-the I/O system translates newlines to the external
-end-of-line representation.
-The default translation mode, \fBauto\fP, handles all the common
-cases automatically, but the \fB\-translation\fR option provides
-explicit control over the end of line translations.
+\fB\-translation\fR \fB{\fIinMode outMode\fB}\fR
+.
+In Tcl scripts the end of a line is always represented using a single
+newline character (\en). However, in actual files and devices the end of
+a line may be represented differently on different platforms, or even for
+different devices on the same platform. For example, under UNIX newlines
+are used in files, whereas carriage-return-linefeed sequences are
+normally used in network connections. On input (i.e., with \fBgets\fP
+and \fBread\fP) the Tcl I/O system automatically translates the external
+end-of-line representation into newline characters. Upon output (i.e.,
+with \fBputs\fP), the I/O system translates newlines to the external
+end-of-line representation. The default translation mode, \fBauto\fP,
+handles all the common cases automatically, but the \fB\-translation\fR
+option provides explicit control over the end of line translations.
.RS
.PP
The value associated with \fB\-translation\fR is a single item for
-read-only and write-only channels.
-The value is a two-element list for read-write channels;
-the read translation mode is the first element of the list,
-and the write translation mode is the second element.
-As a convenience, when setting the translation mode for a read-write channel
-you can specify a single value that will apply to both reading and writing.
-When querying the translation mode of a read-write channel,
-a two-element list will always be returned.
-The following values are currently supported:
+read-only and write-only channels. The value is a two-element list for
+read-write channels; the read translation mode is the first element of
+the list, and the write translation mode is the second element. As a
+convenience, when setting the translation mode for a read-write channel
+you can specify a single value that will apply to both reading and
+writing. When querying the translation mode of a read-write channel, a
+two-element list will always be returned. The following values are
+currently supported:
.TP
\fBauto\fR
-As the input translation mode, \fBauto\fR treats any of newline (\fBlf\fP),
-carriage return (\fBcr\fP), or carriage return followed by a newline (\fBcrlf\fP)
-as the end of line representation. The end of line representation can
-even change from line-to-line, and all cases are translated to a newline.
-As the output translation mode, \fBauto\fR chooses a platform specific
-representation; for sockets on all platforms Tcl
-chooses \fBcrlf\fR, for all Unix flavors, it chooses \fBlf\fR, for the
+.
+As the input translation mode, \fBauto\fR treats any of newline
+(\fBlf\fP), carriage return (\fBcr\fP), or carriage return followed by a
+newline (\fBcrlf\fP) as the end of line representation. The end of line
+representation can even change from line-to-line, and all cases are
+translated to a newline. As the output translation mode, \fBauto\fR
+chooses a platform specific representation; for sockets on all platforms
+Tcl chooses \fBcrlf\fR, for all Unix flavors, it chooses \fBlf\fR, for the
Macintosh platform it chooses \fBcr\fR and for the various flavors of
-Windows it chooses \fBcrlf\fR.
-The default setting for \fB\-translation\fR is \fBauto\fR for both
-input and output.
+Windows it chooses \fBcrlf\fR. The default setting for
+\fB\-translation\fR is \fBauto\fR for both input and output.
+.VS 8.1 br
.TP
-\fBbinary\fR
+\fBbinary\fR
+.
No end-of-line translations are performed. This is nearly identical to
\fBlf\fP mode, except that in addition \fBbinary\fP mode also sets the
-end of file character to the empty string, which disables it.
-See the description of
-\fB\-eofchar\fP for more information.
+end-of-file character to the empty string (which disables it) and sets the
+encoding to \fBbinary\fR (which disables encoding filtering). See the
+description of \fB\-eofchar\fR and \fB\-encoding\fR for more information.
+.VE
.TP
\fBcr\fR
-The end of a line in the underlying file or device is represented
-by a single carriage return character.
-As the input translation mode, \fBcr\fP mode converts carriage returns
-to newline characters.
-As the output translation mode, \fBcr\fP mode
-translates newline characters to carriage returns.
-This mode is typically used on Macintosh platforms.
+.
+The end of a line in the underlying file or device is represented by a
+single carriage return character. As the input translation mode,
+\fBcr\fP mode converts carriage returns to newline characters. As the
+output translation mode, \fBcr\fP mode translates newline characters to
+carriage returns. This mode is typically used on Macintosh platforms.
.TP
\fBcrlf\fR
-The end of a line in the underlying file or device is represented
-by a carriage return character followed by a linefeed character.
-As the input translation mode, \fBcrlf\fP mode converts
-carriage-return-linefeed sequences
-to newline characters.
-As the output translation mode, \fBcrlf\fP mode
-translates newline characters to
-carriage-return-linefeed sequences.
-This mode is typically used on Windows platforms and for network
-connections.
+.
+The end of a line in the underlying file or device is represented by a
+carriage return character followed by a linefeed character. As the input
+translation mode, \fBcrlf\fP mode converts carriage-return-linefeed
+sequences to newline characters. As the output translation mode,
+\fBcrlf\fP mode translates newline characters to carriage-return-linefeed
+sequences. This mode is typically used on Windows platforms and for
+network connections.
.TP
\fBlf\fR
-The end of a line in the underlying file or device is represented
-by a single newline (linefeed) character.
-In this mode no translations occur during either input or output.
-This mode is typically used on UNIX platforms.
+.
+The end of a line in the underlying file or device is represented by a
+single newline (linefeed) character. In this mode no translations occur
+during either input or output. This mode is typically used on UNIX
+platforms.
.RE
.PP
@@ -175,4 +196,5 @@ close(n), flush(n), gets(n), puts(n), read(n), socket(n)
.SH KEYWORDS
blocking, buffering, carriage return, end of line, flushing, linemode,
-newline, nonblocking, platform, translation
+newline, nonblocking, platform, translation, encoding, filter, byte array,
+binary
diff --git a/doc/glob.n b/doc/glob.n
index 2097534..5e7effd 100644
--- a/doc/glob.n
+++ b/doc/glob.n
@@ -5,10 +5,10 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) glob.n 1.11 96/08/26 12:59:59
+'\" SCCS: @(#) glob.n 1.12 97/10/17 16:52:29
'\"
.so man.macros
-.TH glob n 7.5 Tcl "Tcl Built-In Commands"
+.TH glob n 8.1 Tcl "Tcl Built-In Commands"
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
@@ -76,9 +76,18 @@ contains a ?, *, or [] construct.
Unlike other Tcl commands that will accept both network and native
style names (see the \fBfilename\fR manual entry for details on how
native and network names are specified), the \fBglob\fR command only
-accepts native names. Also, for Windows UNC names, the servername and
-sharename components of the path may not contain ?, *, or []
-constructs.
+accepts native names.
+.VS 8.1
+.TP
+\fBWindows\fR
+.
+For Windows UNC names, the servername and sharename components of the path
+may not contain ?, *, or [] constructs. On Windows NT, if \fIpattern\fR is
+of the form ``\fB~\fIusername\fB@\fIdomain\fR'' it refers to the home
+directory of the user whose account information resides on the specified NT
+domain server. Otherwise, user account information is obtained from
+the local computer.
+.VE
.SH KEYWORDS
exist, file, glob, pattern
diff --git a/doc/man.macros b/doc/man.macros
index 3af2da9..a0db675 100644
--- a/doc/man.macros
+++ b/doc/man.macros
@@ -59,7 +59,7 @@
'\" .UL arg1 arg2
'\" Print arg1 underlined, then print arg2 normally.
'\"
-'\" SCCS: @(#) man.macros 1.9 97/08/22 18:50:59
+'\" SCCS: @(#) man.macros 1.10 97/09/02 16:37:14
'\"
'\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
.if t .wh -1.3i ^B
@@ -72,8 +72,8 @@
. ie !"\\$2"" .TP \\n()Cu
. el .TP 15
.\}
-.ie !"\\$3"" \{\
.ta \\n()Au \\n()Bu
+.ie !"\\$3"" \{\
\&\\$1 \\fI\\$2\\fP (\\$3)
.\".b
.\}
diff --git a/doc/pkgMkIndex.n b/doc/pkgMkIndex.n
index 702c657..23cd063 100644
--- a/doc/pkgMkIndex.n
+++ b/doc/pkgMkIndex.n
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) pkgMkIndex.n 1.8 97/10/31 12:51:13
+'\" SCCS: @(#) pkgMkIndex.n 1.10 98/01/28 17:23:37
'\"
.so man.macros
.TH pkg_mkIndex n 7.6 Tcl "Tcl Built-In Commands"
@@ -14,7 +14,9 @@
pkg_mkIndex \- Build an index for automatic loading of packages
.SH SYNOPSIS
.nf
-\fBpkg_mkIndex \fIdir\fR \fIpattern \fR?\fIpattern pattern ...\fR?
+.VS 8.1
+\fBpkg_mkIndex ?\fI-direct\fR? \fIdir\fR ?\fIpattern pattern ...\fR?
+.VE
.fi
.BE
@@ -39,6 +41,12 @@ Create the index by invoking \fBpkg_mkIndex\fR.
The \fIdir\fR argument gives the name of a directory and each
\fIpattern\fR argument is a \fBglob\fR-style pattern that selects
script or binary files in \fIdir\fR.
+.VS 8.1
+The default pattern is \fB*.tcl\fR and \fB*.[info sharedlibextension]\fR.
+If the optional \fI-direct\fR argument is given, the generated index
+will manage to load the package immediately upon \fBpackage require\fR
+instead of delaying loading until actual use of one of the commands.
+.VE
\fBPkg_mkIndex\fR will create a file \fBpkgIndex.tcl\fR in \fIdir\fR
with package information about all the files given by the \fIpattern\fR
arguments.
@@ -46,7 +54,6 @@ It does this by loading each file and seeing what packages
and new commands appear (this is why it is essential to have
\fBpackage provide\fR commands or \fBTcl_PkgProvide\fR calls
in the files, as described above).
-.VS "" br
.IP [3]
Install the package as a subdirectory of one of the directories given by
the \fBtcl_pkgPath\fR variable. If \fB$tcl_pkgPath\fR contains more
@@ -63,14 +70,13 @@ directory in \fB$tcl_pkgPath\fR it will automatically be found during
.RS
.LP
If you install the package anywhere else, then you must ensure that
-the directory contaiingn the package is in the \fBauto_path\fR global variable
+the directory contain the package is in the \fBauto_path\fR global variable
or an immediate subdirectory of one of the directories in \fBauto_path\fR.
\fBAuto_path\fR contains a list of directories that are searched
by both the auto-loader and the package loader; by default it
includes \fB$tcl_pkgPath\fR.
The package loader also checks all of the subdirectories of the
directories in \fBauto_path\fR.
-.VE
You can add a directory to \fBauto_path\fR explicitly in your
application, or you can add the directory to your \fBTCLLIBPATH\fR
environment variable: if this environment variable is present,
@@ -124,12 +130,31 @@ commands for each version of each available package; these commands
invoke \fBpackage provide\fR commands to announce the
availability of the package, and they setup auto-loader
information to load the files of the package.
-A given file of a given version of a given package isn't
+.VS
+Unless the \fI-direct\fR flag was provided when the \fBpkgIndex.tcl\fR
+was generated,
+.VE
+a given file of a given version of a given package isn't
actually loaded until the first time one of its commands
is invoked.
-Thus, after invoking \fBpackage require\fR you won't see
+Thus, after invoking \fBpackage require\fR you
+.VS 8.1
+may
+.VE
+not see
the package's commands in the interpreter, but you will be able
to invoke the commands and they will be auto-loaded.
+.VS 8.1
+.SH "DIRECT LOADING"
+.PP
+Some packages, for instance packages which use namespaces and export
+commands or those which require special initialization, might select
+that their package files be loaded immediately upon \fBpackage require\fR
+instead of delaying the actual loading to the first use of one of the
+package's command. This mode is enabled when generating the package
+index by specifying the \fI-direct\fR argument.
+.VE
+
.SH KEYWORDS
auto-load, index, package, version
diff --git a/doc/regexp.n b/doc/regexp.n
index f3951ee..ea2e0d5 100644
--- a/doc/regexp.n
+++ b/doc/regexp.n
@@ -1,18 +1,18 @@
'\"
-'\" Copyright (c) 1993 The Regents of the University of California.
-'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
+'\" Copyright (c) 1998 Sun Microsystems, Inc.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) regexp.n 1.12 96/08/26 13:00:10
+'\" SCCS: @(#) regexp.n 1.15 98/01/22 16:51:23
'\"
.so man.macros
-.TH regexp n "" Tcl "Tcl Built-In Commands"
+.TH regexp n 8.1 Tcl "Tcl Built-In Commands"
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
regexp \- Match a regular expression against a string
+
.SH SYNOPSIS
\fBregexp \fR?\fIswitches\fR? \fIexp string \fR?\fImatchVar\fR? ?\fIsubMatchVar subMatchVar ...\fR?
.BE
@@ -59,87 +59,478 @@ portion of the expression that wasn't matched), then the corresponding
\fIsubMatchVar\fR will be set to ``\fB\-1 \-1\fR'' if \fB\-indices\fR
has been specified or to an empty string otherwise.
-.SH "REGULAR EXPRESSIONS"
-.PP
-Regular expressions are implemented using Henry Spencer's package
-(thanks, Henry!),
-and much of the description of regular expressions below is copied verbatim
-from his manual entry.
-.PP
-A regular expression is zero or more \fIbranches\fR, separated by ``|''.
-It matches anything that matches one of the branches.
-.PP
-A branch is zero or more \fIpieces\fR, concatenated.
-It matches a match for the first, followed by a match for the second, etc.
-.PP
-A piece is an \fIatom\fR possibly followed by ``*'', ``+'', or ``?''.
-An atom followed by ``*'' matches a sequence of 0 or more matches of the atom.
-An atom followed by ``+'' matches a sequence of 1 or more matches of the atom.
-An atom followed by ``?'' matches a match of the atom, or the null string.
-.PP
-An atom is a regular expression in parentheses (matching a match for the
-regular expression), a \fIrange\fR (see below), ``.''
-(matching any single character), ``^'' (matching the null string at the
-beginning of the input string), ``$'' (matching the null string at the
-end of the input string), a ``\e'' followed by a single character (matching
-that character), or a single character with no other significance
-(matching that character).
-.PP
-A \fIrange\fR is a sequence of characters enclosed in ``[]''.
-It normally matches any single character from the sequence.
-If the sequence begins with ``^'',
-it matches any single character \fInot\fR from the rest of the sequence.
-If two characters in the sequence are separated by ``\-'', this is shorthand
-for the full list of ASCII characters between them
-(e.g. ``[0-9]'' matches any decimal digit).
-To include a literal ``]'' in the sequence, make it the first character
-(following a possible ``^'').
-To include a literal ``\-'', make it the first or last character.
+.SH DIFFERENT FLAVORS OF REs
+.VS 8.1
+Regular expressions (``RE''s),
+as defined by POSIX, come in two flavors:
+\fIextended\fR
+REs (roughly those of
+\fIegrep\fR),
+``EREs'',
+and
+\fIbasic\fR
+REs (roughly those of
+\fIed\fR),
+``BREs''.
+This implementation adds a third flavor,
+\fIadvanced\fR
+REs, ``AREs'', that offer a syntax for specifying BREs and EREs. The
+following primarily describes AREs.
+.PP
+BREs mostly exist for backward compatibility in some old programs;
+they will be discussed at the end.
+POSIX EREs are
+\fIalmost\fR
+an exact subset of AREs;
+.SH "REGULAR EXPRESSION SYNTAX"
+.PP
+Regular expressions are implemented using the package written by Henry
+Spencer, based on the 1003.2 spec and some (not quite all) of the
+Perl5 extensions (thanks, Henry!). Much of the description of regular
+expressions below is copied verbatim from his manual entry.
+.PP
+An ARE is one or more \fIbranches\fR,
+separated by `|'.
+It matches anything that matches any of the branches.
+.PP
+A branch is zero or more \fIitems\fR, concatenated.
+It matches a match for the first, followed by a match for the second, etc;
+an empty branch matches the empty string.
+.PP
+An item is an \fIatom\fR possibly followed
+by a single
+\fIquantifier\fR:
+`*', `+', `?', or a \fIbound\fR.
+An atom followed by `*' matches a sequence of 0 or more matches of the atom.
+An atom followed by `+' matches a sequence of 1 or more matches of the atom.
+An atom followed by `?' matches a sequence of 0 or 1 matches of the atom.
+.PP
+A \fIbound\fR is `{' followed by an unsigned decimal integer,
+possibly followed by `,'
+possibly followed by another unsigned decimal integer,
+always followed by `}'.
+The integers must lie between 0 and 255 inclusive,
+and if there are two of them, the first may not exceed the second.
+An atom followed by a bound containing one integer \fIi\fR
+and no comma matches
+a sequence of exactly \fIi\fR matches of the atom.
+An atom followed by a bound
+containing one integer \fIi\fR and a comma matches
+a sequence of \fIi\fR or more matches of the atom.
+An atom followed by a bound
+containing two integers \fIi\fR and \fIj\fR matches
+a sequence of \fIi\fR through \fIj\fR (inclusive) matches of the atom.
+.PP
+A quantifier followed by `?' (that is, `*?', `+?', `??', `{...}?') is
+a \fInon-greedy quantifier\fR, which matches the same possibilities,
+but prefers the smallest number rather than the largest number
+of matches.
+.PP
+An atom is a regular expression enclosed in `()' (matching a match for the
+regular expression, with the match noted for possible reporting),
+an empty set of `()' (matching an empty string,
+again noted for possible reporting),
+either form with the leading parenthesis replaced by `(?:'
+(``non-capturing parentheses'',
+as opposed to the plainer ``capturing'' form;
+they have the same matching semantics but do no reporting),
+a \fIbracket expression\fR (see next section),
+`.' (matching any single character),
+a \fIconstraint\fR (see below),
+a `\e' followed by any non-alphanumeric character
+(matching that character taken as an ordinary character,
+e.g. `\e\e' matches a backslash character),
+an \fIescape\fR (see later section) beginning with `\e' followed by an
+alphanumeric character,
+or a single character with no other significance (matching that character).
+.PP
+A \fIconstraint\fR matches an empty string when specific conditions
+are met.
+(Some more constraints are described later.)
+`^' matches at the beginning of a line,
+and `$' matches at the end of a line;
+these constraints are also known as \fIanchors\fR.
+A regular expression enclosed in `(?=' and `)'
+(\fIpositive lookahead\fR) matches at any point
+where a string matching that regular expression begins.
+A regular expression enclosed in `(?!' and `)'
+(\fInegative lookahead\fR) matches at any point
+where a string \fInot\fR matching that regular expression begins.
+Lookahead constraints may not contain back references (see later),
+and all parentheses within them are treated as non-capturing.
+A constraint may not be followed by a quantifier.
+.PP
+A `{' followed by a character other than a digit is an ordinary
+character, not the beginning of a bound.
+An RE may not end with an `\e'.
+.SH "BRACKET EXPRESSIONS"
+A \fIbracket expression\fR is a list of characters enclosed in `[]'.
+It normally matches any single character from the list (but see below).
+If the list begins with `^',
+it matches any single character
+(but see below) \fInot\fR from the rest of the list.
+If two characters in the list are separated by `\-', this is shorthand
+for the full \fIrange\fR of characters between those two (inclusive) in the
+collating sequence,
+e.g. `[0\-9]' in ASCII matches any decimal digit.
+Two ranges may not share an
+endpoint, e.g. `a\-c\-e'.
+Ranges are very collating-sequence-dependent,
+and portable programs should avoid relying on them.
+.PP
+To include a literal `]' in the list, make it the first character
+(following a possible `^'),
+or precede it with `\e'.
+To include a literal `\-', make it the first or last character,
+or the second endpoint of a range,
+or precede it with `\e'.
+To use a literal `\-' as the first endpoint of a range,
+enclose it in `[.' and `.]' to make it a collating element (see below),
+or precede it with `\e'.
+With the exception of these, some combinations using `[' (see next
+paragraphs), and escapes,
+all other special characters lose their
+special significance within a bracket expression.
+.PP
+Within a bracket expression, a collating element (a character,
+a multi-character sequence that collates as if it were a single character,
+or a collating-sequence name for either)
+enclosed in `[.' and `.]' stands for the
+sequence of characters of that collating element.
+The sequence is a single element of the bracket expression's list.
+A bracket expression in a locale which has
+multi-character collating elements
+can thus match more than one character.
+Most insidiously, if `^' is used,
+this can happen even if no collating
+elements appear in the bracket expression!
+If the collating sequence includes a `ch' collating element,
+then the RE `[[.ch.]]*c' matches the first five characters
+of `chchcc',
+and the RE `[^c]b' matches all of `chb'.
+.PP
+Within a bracket expression, a collating element enclosed in `[=' and
+`=]' is an equivalence class, standing for the sequences of characters
+of all collating elements equivalent to that one, including itself.
+(If there are no other equivalent collating elements,
+the treatment is as if the enclosing delimiters were `[.' and `.]'.)
+For example, if o and \o'o^' are the members of an equivalence class,
+then `[[=o=]]', `[[=\o'o^'=]]', and `[o\o'o^']' are all synonymous.
+An equivalence class may not be an endpoint
+of a range.
+.PP
+Within a bracket expression, the name of a \fIcharacter class\fR enclosed
+in `[:' and `:]' stands for the list of all characters belonging to that
+class.
+Standard character class names are:
+.PP
+.RS
+.nf
+.ta 3c 6c 9c
+alnum digit punct
+alpha graph space
+blank lower upper
+cntrl print xdigit
+.fi
+.RE
+.PP
+These stand for the character classes defined in
+\fIctype\fR(3).
+A locale may provide others.
+A character class may not be used as an endpoint of a range.
+.PP
+There are two special cases of bracket expressions:
+the bracket expressions `[[:<:]]' and `[[:>:]]'
+are constraints, matching empty strings at
+the beginning and end of a word respectively.
+A word is defined as a sequence of
+word characters
+which is neither preceded nor followed by
+word characters.
+A word character is an
+\fIalnum\fR
+character (as defined by
+\fIctype\fR(3))
+or an underscore.
+This is an extension, and its use is deprecated;
+users of AREs should use constraint escapes instead (see below).
+.SH ESCAPES
+Escapes, which begin with a `\e' followed by an alphanumeric character,
+come in several varieties:
+character entry, class shorthands, constraint, and back references.
+A `\e' followed by an alphanumeric character but not constituting
+a valid escape is illegal in AREs.
+In EREs, there are no escapes:
+outside a bracket expression,
+a `\e' followed by an alphanumeric character merely stands for that
+character as an ordinary character,
+and inside a bracket expression, `\e' is an ordinary character.
+(The latter is the one actual incompatibility between POSIX and AREs.)
+.PP
+Character-entry escapes exist to make it easier to specify
+non-printing and otherwise inconvenient characters in REs.
+The Standard C escapes
+`\ea' (alert, aka bell),
+`\eb' (backspace),
+`\ef' (formfeed),
+`\en' (newline),
+`\er' (carriage return),
+`\et' (horizontal tab), and
+`\ev' (vertical tab)
+are all available.
+`\ee' represents the character whose collating-sequence name
+is ``ESC'', or failing that, the character with octal value 033.
+`\eE' represents `\e' (reducing the backslash doubling in some
+applications where there are multiple levels of backslash processing).
+.PP
+`\ecX', where X is any character, represents the character whose
+low-order 5 bits are the same as those of X,
+and whose other bits are all zero.
+`\e0', `\eXY' and `\eXYZ', where X, Y, and Z are octal digits (0-7),
+represent the characters whose octal values are 0, 0XY, and 0XYZ
+respectively.
+(See below for why `\eX' isn't in the list here.)
+`\exHHH', where HHH is any sequence of hexadecimal digits (0-9, A-F, a-f),
+represents the character whose hexadecimal value is 0xHHH
+(a single character no matter how many hexadecimal digits are used).
+`\euWXYZ', where WXYZ is exactly four hexadecimal digits,
+represents the Unicode character U+WXYZ in the local byte ordering.
+`\eUstuvwxyz', where stuvwxyz is exactly eight hexadecimal digits,
+is reserved for a somewhat-hypothetical Unicode extension to 32 bits.
+.PP
+The character-entry escapes are always taken as ordinary characters.
+For example, `\e135' is `]' in ASCII,
+but `\e135' does not terminate a bracket expression.
+Beware, however, that some applications \- e.g., C compilers\-interpret
+such sequences themselves before the regular-expression package
+gets to see them.
+.PP
+Class-shorthand escapes provide shorthands for certain commonly-used
+character classes.
+`\ed', `\es', and `\ew', outside bracket expressions, represent
+`[[:digit:]]', `[[:space:]]', and `[[:alnum:]_]' respectively
+(note the underscore in `\ew').
+`\eD', `\eS', and `\eW', outside bracket expressions, represent
+the complementary classes:
+`[^[:digit:]]', `[^[:space:]]', and `[^[:alnum:]_]' respectively.
+Within bracket expressions,
+`\ed', `\es', and `\ew' lose their outer brackets, representing
+`[:digit:]', `[:space:]', and `[:alnum:]_' respectively;
+`\eD', `\eS', and `\eW' are illegal within bracket expressions.
+.PP
+A constraint escape is a constraint,
+matching the empty string if specific conditions are met,
+written as an escape.
+`\eA' matches only at the beginning of the string, and
+`\eZ' matches only at the end of the string
+(see MATCHING, below, for how they differ from `^' and `$').
+`\ey' matches only at the beginning or end of a word, and
+`\eY' matches only at a point which is not the beginning or end of a word.
+A word is defined as in the specification of [[:<:]] and [[:>:]] above.
+Constraint escapes are illegal within bracket expressions.
+.PP
+A back reference is of the form `\eM', where M is a nonzero digit (1-9),
+or `\eMNN', where MNN is some number of
+digits (first 1-9, rest 0-9) and the value MNN
+is not greater than the number of closing capturing parentheses seen so far.
+A back reference matches the same string matched by the parenthesized
+subexpression specified by the number,
+so that (e.g.) `([bc])\e1' matches `bb' or `cc' but not `bc'.
+The subexpression must entirely precede the back reference in the RE.
+Subexpressions are numbered in the order of their leading parentheses.
+Non-capturing parentheses do not define subexpressions.
+.PP
+There is an inherent historical ambiguity between octal character-entry
+escapes and back references, which is resolved by heuristics.
+A single non-zero digit, not followed by another digit,
+is always taken as a back reference.
+A leading zero always indicates an octal escape.
+A multi-digit sequence not starting with a zero is taken as a back
+reference if it comes after a suitable subexpression
+(i.e. the number is in the legal range for a back reference),
+and otherwise is taken as octal.
+.SH "METASYNTAX"
+In addition to the main syntax described above, there are some special
+forms and miscellaneous syntactic facilities available.
+These are extensions, compatible with but not specified by POSIX.
+.PP
+Normally the flavor of RE being used is specified by
+application-dependent means.
+However, this can be overridden by a \fIdirector\fR.
+If an RE of any flavor begins with `***:', the rest of the RE is an ARE.
+If an RE of any flavor begins with `***=',
+the rest of the RE is taken to be a literal string,
+with all characters considered ordinary characters.
+.PP
+An ARE may begin with \fIembedded options\fR:
+the sequence `(?xyz)', where xyz is one or more alphabetic characters,
+specifies options affecting the rest of the RE.
+These supplement, and can override,
+options specified by the application in application-specific ways.
+The available option letters are:
+.RS
+.IP b 3
+rest of RE is a BRE
+.IP c
+case-sensitive matching (usual default)
+.IP e
+rest of RE is an ERE
+.IP i
+case-insensitive matching (see MATCHING, below)
+.IP m
+historical synonym for `n'
+.IP n
+newline-sensitive matching (see MATCHING, below)
+.IP p
+partial newline-sensitive matching (see MATCHING, below)
+.IP q
+rest of RE is a literal (``quoted'') string, all ordinary characters
+.IP s
+non-newline-sensitive matching (usual default)
+.IP t
+tight syntax (usual default; see below)
+.IP w
+inverse partial newline-sensitive (``weird'') matching (see MATCHING, below)
+.IP x
+expanded syntax (see below)
+.RE
+.PP
+In addition to the usual (\fItight\fR) RE syntax, in which all characters are
+significant, there is an \fIexpanded\fR syntax,
+available in all flavors of RE
+by application-specified option, or in AREs by embedded x option.
+In the expanded syntax,
+any white-space character
+not preceded by `\e'
+and not within a bracket expression is ignored,
+so a complex RE can be paragraphed legibly.
+There is one exception: white space is not allowed within multi-character
+symbols like the ARE `(?:' or the BRE `\e('.
+White-space characters are blank, tab, newline, etc. \- any character
+defined as \fIspace\fR by
+\fIctype\fR(3).
+In addition, all characters between a non-backslashed non-bracket-expression
+`#' and the following newline (or the end of the RE) are ignored,
+so comments can be inserted conveniently.
+Exactly how a multi-line expanded-syntax RE can be entered by a user,
+if at all, is application-specific;
+this is primarily a programming facility.
+.PP
+Finally, in an ARE,
+outside bracket expressions, the sequence `(?#ttt)',
+where ttt is any text not containing a `)', is a comment,
+completely ignored.
+Again, this is not allowed between the characters of
+multi-character symbols like `(?:'.
+Such comments are more a historical artifact than a useful facility,
+and their use is deprecated;
+use the expanded syntax instead.
+.PP
+\fINone\fR of these metasyntax extensions are available if the application
+(or an initial `***=' director)
+has specified that the user's input be treated as a literal string
+rather than as an RE.
.SH "CHOOSING AMONG ALTERNATIVE MATCHES"
+In the event that an RE could match more than one substring of a given
+string,
+the RE matches the one starting earliest in the string.
+If the RE could match more than one substring starting at that point,
+it matches the longest.
+Subexpressions also match the longest possible substrings, subject to
+the constraint that the whole match be as long as possible,
+with subexpressions starting earlier in the RE taking priority over
+ones starting later.
+Note that higher-level subexpressions thus take priority over
+their lower-level component subexpressions.
.PP
-In general there may be more than one way to match a regular expression
-to an input string. For example, consider the command
-.CS
-\fBregexp (a*)b* aabaaabb x y\fR
-.CE
-Considering only the rules given so far, \fBx\fR and \fBy\fR could
-end up with the values \fBaabb\fR and \fBaa\fR, \fBaaab\fR and \fBaaa\fR,
-\fBab\fR and \fBa\fR, or any of several other combinations.
-To resolve this potential ambiguity \fBregexp\fR chooses among
-alternatives using the rule ``first then longest''.
-In other words, it considers the possible matches in order working
-from left to right across the input string and the pattern, and it
-attempts to match longer pieces of the input string before shorter
-ones. More specifically, the following rules apply in decreasing
-order of priority:
-.IP [1]
-If a regular expression could match two different parts of an input string
-then it will match the one that begins earliest.
-.IP [2]
-If a regular expression contains \fB|\fR operators then the leftmost
-matching sub-expression is chosen.
-.IP [3]
-In \fB*\fR, \fB+\fR, and \fB?\fR constructs, longer matches are chosen
-in preference to shorter ones.
-.IP [4]
-In sequences of expression components the components are considered
-from left to right.
-.LP
-In the example from above, \fB(a*)b*\fR matches \fBaab\fR: the \fB(a*)\fR
-portion of the pattern is matched first and it consumes the leading
-\fBaa\fR; then the \fBb*\fR portion of the pattern consumes the
-next \fBb\fR. Or, consider the following example:
-.CS
-\fBregexp (ab|a)(b*)c abc x y z\fR
-.CE
-After this command \fBx\fR will be \fBabc\fR, \fBy\fR will be
-\fBab\fR, and \fBz\fR will be an empty string.
-Rule 4 specifies that \fB(ab|a)\fR gets first shot at the input
-string and Rule 2 specifies that the \fBab\fR sub-expression
-is checked before the \fBa\fR sub-expression.
-Thus the \fBb\fR has already been claimed before the \fB(b*)\fR
-component is checked and \fB(b*)\fR must match an empty string.
+Match lengths are measured in characters, not collating elements.
+An empty string is considered longer than no match at all.
+For example,
+`bb*' matches the three middle characters of `abbbc',
+`(week|wee)(night|knights)' matches all ten characters of `weeknights',
+when `(.*).*' is matched against `abc' the parenthesized subexpression
+matches all three characters, and
+when `(a*)*' is matched against `bc' both the whole RE and the parenthesized
+subexpression match an empty string.
+.PP
+If case-independent matching is specified,
+the effect is much as if all case distinctions had vanished from the
+alphabet.
+When an alphabetic that exists in multiple cases appears as an
+ordinary character outside a bracket expression, it is effectively
+transformed into a bracket expression containing both cases,
+e.g. `x' becomes `[xX]'.
+When it appears inside a bracket expression, all case counterparts
+of it are added to the bracket expression, so that (e.g.) `[x]'
+becomes `[xX]' and `[^x]' becomes `[^xX]'.
+.PP
+If newline-sensitive matching is specified,
+and the string supplied for matching contains newlines,
+`.' and complemented bracket expressions (`[^...]')
+will never match the newline character,
+and `^' and `$' will match the empty string after and before a newline
+respectively, in addition to matching at beginning and end of string
+respectively.
+ARE `\eA' and `\eZ' continue to match beginning or end of string \fIonly\fR.
+.PP
+If partial newline-sensitive matching is specified,
+this affects `.' and complemented bracket expressions as with
+newline-sensitive matching, but not `^' and `$'.
+.PP
+If inverse partial newline-sensitive matching is specified,
+this affects `^' and `$' as with
+newline-sensitive matching,
+but not `.' and complemented bracket expressions.
+This isn't very useful but is provided for symmetry.
+
+.SH BASIC REGULAR EXPRESSIONS
+BREs differ from EREs in several respects.
+`|', `+', and `?' are ordinary characters and there is no equivalent
+for their functionality.
+The delimiters for bounds are `\e{' and `\e}',
+with `{' and `}' by themselves ordinary characters.
+The parentheses for nested subexpressions are `\e(' and `\e)',
+with `(' and `)' by themselves ordinary characters.
+`^' is an ordinary character except at the beginning of the
+RE or the beginning of a parenthesized subexpression,
+`$' is an ordinary character except at the end of the
+RE or the end of a parenthesized subexpression,
+and `*' is an ordinary character if it appears at the beginning of the
+RE or the beginning of a parenthesized subexpression
+(after a possible leading `^').
+Finally,
+single-digit back references (but no other escapes) are available.
+.SH "LIMITS AND BACKWARD COMPATIBILITY"
+No particular limit is imposed on the length of REs or the number
+paired parentheses, brackets, or braces.
+.PP
+In AREs, a `\e' inside [...] is an escape,
+so a literal `\e' within `[]' must be written `\e\e'.
+.PP
+In AREs, some escapes mean special things in a bracket expression
+(i.e. `\ed', `\es', `\ew') and others are illegal (i.e. `\eD', `\eS',
+`\eW', `\eA', `\eZ').
+.PP
+In AREs, a `{' followed by a digit will not match those two characters
+but will instead start a bound. Such sequences should be rare, and
+will often result in an error because following characters will not
+look like a valid bound.
+.PP
+In AREs, a `\e' followed by an alphanumeric character is either an
+escape or an error. A bunch of new escapes were treated as literal
+characters in old versions of Tcl.
+.PP
+The longest-leftmost match is found in AREs. Old versions of Tcl
+found the first-leftmost match. This may affect some old REs which
+were written in the expectation that the first match would be
+reported. The careful crafting of old REs to optimize the search
+order for fast matching is obsolete. AREs examine all possible
+matches in parallel, and their performance is largely insensitive to
+their complexity, but cases where the search order was exploited to
+deliberately find a match which was \fInot\fR the longest will need
+rewriting.
+.VE
.SH KEYWORDS
match, regular expression, string
diff --git a/doc/resource.n b/doc/resource.n
index 0062992..05a69e1 100644
--- a/doc/resource.n
+++ b/doc/resource.n
@@ -3,7 +3,7 @@
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\" SCCS: @(#) resource.n 1.4 97/09/10 15:22:18
+'\" SCCS: @(#) resource.n 1.5 98/01/28 12:47:09
'\"
.so man.macros
.TH resource n 8.0 Tcl "Tcl Built-In Commands"
@@ -55,7 +55,7 @@ If the \fB-file\fR option is specified then the resource will be
deleted from the file pointed to by \fIresourceRef\fR. Otherwise the
first resource with the given \fIresourceName\fR and or
\fIresourceId\fR which is found on the resource file path will be
-deleted. To inspect the file path, use the \fIresource files\fB command.
+deleted. To inspect the file path, use the \fIresource files\fR command.
.RE
.TP
\fBresource files ?\fIresourceRef\fR?
diff --git a/doc/safe.n b/doc/safe.n
index 3be9c5f..57ee651 100644
--- a/doc/safe.n
+++ b/doc/safe.n
@@ -4,16 +4,15 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" SCCS: @(#) safe.n 1.11 97/10/31 12:51:13
+'\" SCCS: @(#) safe.n 1.12 98/01/28 12:46:57
'\"
.so man.macros
.TH "Safe Tcl" n 8.0 Tcl "Tcl Built-In Commands"
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
-Safe Base \- A mechanism for creating and manipulating safe interpreters.
+Safe\ Base \- A mechanism for creating and manipulating safe interpreters.
.SH SYNOPSIS
-.PP
\fB::safe::interpCreate\fR ?\fIslave\fR? ?\fIoptions...\fR?
.sp
\fB::safe::interpInit\fR \fIslave\fR ?\fIoptions...\fR?