home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-14 | 50.6 KB | 1,699 lines |
- Newsgroups: comp.sources.misc
- From: karl@sugar.neosoft.com (Karl Lehenbauer)
- Subject: v25i078: tcl - tool command language, version 6.1, Part10/33
- Message-ID: <1991Nov14.202931.23807@sparky.imd.sterling.com>
- X-Md4-Signature: 0397d6eea7e54883fadb4e9d916b5f53
- Date: Thu, 14 Nov 1991 20:29:31 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
- Posting-number: Volume 25, Issue 78
- Archive-name: tcl/part10
- Environment: UNIX
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 10 (of 33)."
- # Contents: tcl6.1/compat/strerror.c tcl6.1/doc/Hash.man
- # tcl6.1/tests/format.test tcl6.1/tests/parse.test
- # Wrapped by karl@one on Tue Nov 12 19:44:19 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'tcl6.1/compat/strerror.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tcl6.1/compat/strerror.c'\"
- else
- echo shar: Extracting \"'tcl6.1/compat/strerror.c'\" \(11480 characters\)
- sed "s/^X//" >'tcl6.1/compat/strerror.c' <<'END_OF_FILE'
- X/*
- X * strerror.c --
- X *
- X * Source code for the "strerror" library routine.
- X *
- X * Copyright 1988-1991 Regents of the University of California
- X * Permission to use, copy, modify, and distribute this
- X * software and its documentation for any purpose and without
- X * fee is hereby granted, provided that the above copyright
- X * notice appears in all copies. The University of California
- X * makes no representations about the suitability of this
- X * software for any purpose. It is provided "as is" without
- X * express or implied warranty.
- X */
- X
- X#ifndef lint
- Xstatic char rcsid[] = "$Header: /sprite/src/lib/tcl/compat/RCS/strerror.c,v 1.1 91/09/19 16:22:10 ouster Exp $ SPRITE (Berkeley)";
- X#endif /* not lint */
- X
- X#include <tclInt.h>
- X#include <tclUnix.h>
- X
- X/*
- X *----------------------------------------------------------------------
- X *
- X * strerror --
- X *
- X * Map an integer error number into a printable string.
- X *
- X * Results:
- X * The return value is a pointer to a string describing
- X * error. The first character of string isn't capitalized.
- X *
- X * Side effects:
- X * Each call to this procedure may overwrite the value returned
- X * by the previous call.
- X *
- X *----------------------------------------------------------------------
- X */
- X
- Xchar *
- Xstrerror(error)
- X int error; /* Integer identifying error (must be
- X * one of the officially-defined Sprite
- X * errors, as defined in errno.h). */
- X{
- X static char msg[50];
- X
- X#if TCL_SYS_ERRLIST
- X if ((error <= sys_nerr) && (error > 0)) {
- X return sys_errlist[error];
- X }
- X#else
- X switch (error) {
- X#ifdef E2BIG
- X case E2BIG: return "argument list too long";
- X#endif
- X#ifdef EACCES
- X case EACCES: return "permission denied";
- X#endif
- X#ifdef EADDRINUSE
- X case EADDRINUSE: return "address already in use";
- X#endif
- X#ifdef EADDRNOTAVAIL
- X case EADDRNOTAVAIL: return "can't assign requested address";
- X#endif
- X#ifdef EADV
- X case EADV: return "advertise error";
- X#endif
- X#ifdef EAFNOSUPPORT
- X case EAFNOSUPPORT: return "address family not supported by protocol family";
- X#endif
- X#ifdef EAGAIN
- X case EAGAIN: return "no more processes";
- X#endif
- X#ifdef EALIGN
- X case EALIGN: return "EALIGN";
- X#endif
- X#ifdef EALREADY
- X case EALREADY: return "operation already in progress";
- X#endif
- X#ifdef EBADE
- X case EBADE: return "bad exchange descriptor";
- X#endif
- X#ifdef EBADF
- X case EBADF: return "bad file number";
- X#endif
- X#ifdef EBADFD
- X case EBADFD: return "file descriptor in bad state";
- X#endif
- X#ifdef EBADMSG
- X case EBADMSG: return "not a data message";
- X#endif
- X#ifdef EBADR
- X case EBADR: return "bad request descriptor";
- X#endif
- X#ifdef EBADRPC
- X case EBADRPC: return "RPC structure is bad";
- X#endif
- X#ifdef EBADRQC
- X case EBADRQC: return "bad request code";
- X#endif
- X#ifdef EBADSLT
- X case EBADSLT: return "invalid slot";
- X#endif
- X#ifdef EBFONT
- X case EBFONT: return "bad font file format";
- X#endif
- X#ifdef EBUSY
- X case EBUSY: return "mount device busy";
- X#endif
- X#ifdef ECHILD
- X case ECHILD: return "no children";
- X#endif
- X#ifdef ECHRNG
- X case ECHRNG: return "channel number out of range";
- X#endif
- X#ifdef ECOMM
- X case ECOMM: return "communication error on send";
- X#endif
- X#ifdef ECONNABORTED
- X case ECONNABORTED: return "software caused connection abort";
- X#endif
- X#ifdef ECONNREFUSED
- X case ECONNREFUSED: return "connection refused";
- X#endif
- X#ifdef ECONNRESET
- X case ECONNRESET: return "connection reset by peer";
- X#endif
- X#ifdef EDEADLK
- X#ifndef EWOULDBLOCK
- X case EDEADLK: return "resource deadlock avoided";
- X#else
- X#if EWOULDBLOCK != EDEADLK
- X case EDEADLK: return "resource deadlock avoided";
- X#endif /* EWOULDBLOCK != EDEADLK */
- X#endif /* EWOULDBLOCK */
- X#endif /* EDEADLK */
- X#ifdef EDEADLOCK
- X case EDEADLOCK: return "resource deadlock avoided";
- X#endif
- X#ifdef EDESTADDRREQ
- X case EDESTADDRREQ: return "destination address required";
- X#endif
- X#ifdef EDIRTY
- X case EDIRTY: return "mounting a dirty fs w/o force";
- X#endif
- X#ifdef EDOM
- X case EDOM: return "math argument out of range";
- X#endif
- X#ifdef EDOTDOT
- X case EDOTDOT: return "cross mount point";
- X#endif
- X#ifdef EDQUOT
- X case EDQUOT: return "disk quota exceeded";
- X#endif
- X#ifdef EDUPPKG
- X case EDUPPKG: return "duplicate package name";
- X#endif
- X#ifdef EEXIST
- X case EEXIST: return "file already exists";
- X#endif
- X#ifdef EFAULT
- X case EFAULT: return "bad address in system call argument";
- X#endif
- X#ifdef EFBIG
- X case EFBIG: return "file too large";
- X#endif
- X#ifdef EHOSTDOWN
- X case EHOSTDOWN: return "host is down";
- X#endif
- X#ifdef EHOSTUNREACH
- X case EHOSTUNREACH: return "host is unreachable";
- X#endif
- X#ifdef EIDRM
- X case EIDRM: return "identifier removed";
- X#endif
- X#ifdef EINIT
- X case EINIT: return "initialization error";
- X#endif
- X#ifdef EINPROGRESS
- X case EINPROGRESS: return "operation now in progress";
- X#endif
- X#ifdef EINTR
- X case EINTR: return "interrupted system call";
- X#endif
- X#ifdef EINVAL
- X case EINVAL: return "invalid argument";
- X#endif
- X#ifdef EIO
- X case EIO: return "I/O error";
- X#endif
- X#ifdef EISCONN
- X case EISCONN: return "socket is already connected";
- X#endif
- X#ifdef EISDIR
- X case EISDIR: return "illegal operation on a directory";
- X#endif
- X#ifdef EISNAME
- X case EISNAM: return "is a name file";
- X#endif
- X#ifdef ELBIN
- X case ELBIN: return "ELBIN";
- X#endif
- X#ifdef EL2HLT
- X case EL2HLT: return "level 2 halted";
- X#endif
- X#ifdef EL2NSYNC
- X case EL2NSYNC: return "level 2 not synchronized";
- X#endif
- X#ifdef EL3HLT
- X case EL3HLT: return "level 3 halted";
- X#endif
- X#ifdef EL3RST
- X case EL3RST: return "level 3 reset";
- X#endif
- X#ifdef ELIBACC
- X case ELIBACC: return "can not access a needed shared library";
- X#endif
- X#ifdef ELIBBAD
- X case ELIBBAD: return "accessing a corrupted shared library";
- X#endif
- X#ifdef ELIBEXEC
- X case ELIBEXEC: return "can not exec a shared library directly";
- X#endif
- X#ifdef ELIBMAX
- X case ELIBMAX: return
- X "attempting to link in more shared libraries than system limit";
- X#endif
- X#ifdef ELIBSCN
- X case ELIBSCN: return ".lib section in a.out corrupted";
- X#endif
- X#ifdef ELNRNG
- X case ELNRNG: return "link number out of range";
- X#endif
- X#ifdef ELOOP
- X case ELOOP: return "too many levels of symbolic links";
- X#endif
- X#ifdef EMFILE
- X case EMFILE: return "too many open files";
- X#endif
- X#ifdef EMLINK
- X case EMLINK: return "too many links";
- X#endif
- X#ifdef EMSGSIZE
- X case EMSGSIZE: return "message too long";
- X#endif
- X#ifdef EMULTIHOP
- X case EMULTIHOP: return "multihop attempted";
- X#endif
- X#ifdef ENAMETOOLONG
- X case ENAMETOOLONG: return "file name too long";
- X#endif
- X#ifdef ENAVAIL
- X case ENAVAIL: return "not available";
- X#endif
- X#ifdef ENET
- X case ENET: return "ENET";
- X#endif
- X#ifdef ENETDOWN
- X case ENETDOWN: return "network is down";
- X#endif
- X#ifdef ENETRESET
- X case ENETRESET: return "network dropped connection on reset";
- X#endif
- X#ifdef ENETUNREACH
- X case ENETUNREACH: return "network is unreachable";
- X#endif
- X#ifdef ENFILE
- X case ENFILE: return "file table overflow";
- X#endif
- X#ifdef ENOANO
- X case ENOANO: return "anode table overflow";
- X#endif
- X#if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
- X case ENOBUFS: return "no buffer space available";
- X#endif
- X#ifdef ENOCSI
- X case ENOCSI: return "no CSI structure available";
- X#endif
- X#ifdef ENODATA
- X case ENODATA: return "no data available";
- X#endif
- X#ifdef ENODEV
- X case ENODEV: return "no such device";
- X#endif
- X#ifdef ENOENT
- X case ENOENT: return "no such file or directory";
- X#endif
- X#ifdef ENOEXEC
- X case ENOEXEC: return "exec format error";
- X#endif
- X#ifdef ENOLCK
- X case ENOLCK: return "no locks available";
- X#endif
- X#ifdef ENOLINK
- X case ENOLINK: return "link has be severed";
- X#endif
- X#ifdef ENOMEM
- X case ENOMEM: return "not enough memory";
- X#endif
- X#ifdef ENOMSG
- X case ENOMSG: return "no message of desired type";
- X#endif
- X#ifdef ENONET
- X case ENONET: return "machine is not on the network";
- X#endif
- X#ifdef ENOPKG
- X case ENOPKG: return "package not installed";
- X#endif
- X#ifdef ENOPROTOOPT
- X case ENOPROTOOPT: return "bad proocol option";
- X#endif
- X#ifdef ENOSPC
- X case ENOSPC: return "no space left on device";
- X#endif
- X#ifdef ENOSR
- X case ENOSR: return "out of stream resources";
- X#endif
- X#ifdef ENOSTR
- X case ENOSTR: return "not a stream device";
- X#endif
- X#ifdef ENOSYM
- X case ENOSYM: return "unresolved symbol name";
- X#endif
- X#ifdef ENOSYS
- X case ENOSYS: return "function not implemented";
- X#endif
- X#ifdef ENOTBLK
- X case ENOTBLK: return "block device required";
- X#endif
- X#ifdef ENOTCONN
- X case ENOTCONN: return "socket is not connected";
- X#endif
- X#ifdef ENOTDIR
- X case ENOTDIR: return "not a directory";
- X#endif
- X#ifdef ENOTEMPTY
- X case ENOTEMPTY: return "directory not empty";
- X#endif
- X#ifdef ENOTNAM
- X case ENOTNAM: return "not a name file";
- X#endif
- X#ifdef ENOTSOCK
- X case ENOTSOCK: return "socket operation on non-socket";
- X#endif
- X#ifdef ENOTTY
- X case ENOTTY: return "inappropriate device for ioctl";
- X#endif
- X#ifdef ENOTUNIQ
- X case ENOTUNIQ: return "name not unique on network";
- X#endif
- X#ifdef ENXIO
- X case ENXIO: return "no such device or address";
- X#endif
- X#ifdef EOPNOTSUPP
- X case EOPNOTSUPP: return "operation not supported on socket";
- X#endif
- X#ifdef EPERM
- X case EPERM: return "not owner";
- X#endif
- X#ifdef EPFNOSUPPORT
- X case EPFNOSUPPORT: return "protocol family not supported";
- X#endif
- X#ifdef EPIPE
- X case EPIPE: return "broken pipe";
- X#endif
- X#ifdef EPROCLIM
- X case EPROCLIM: return "too many processes";
- X#endif
- X#ifdef EPROCUNAVAIL
- X case EPROCUNAVAIL: return "bad procedure for program";
- X#endif
- X#ifdef EPROGMISMATCH
- X case EPROGMISMATCH: return "program version wrong";
- X#endif
- X#ifdef EPROGUNAVAIL
- X case EPROGUNAVAIL: return "RPC program not available";
- X#endif
- X#ifdef EPROTO
- X case EPROTO: return "protocol error";
- X#endif
- X#ifdef EPROTONOSUPPORT
- X case EPROTONOSUPPORT: return "protocol not suppored";
- X#endif
- X#ifdef EPROTOTYPE
- X case EPROTOTYPE: return "protocol wrong type for socket";
- X#endif
- X#ifdef ERANGE
- X case ERANGE: return "math result unrepresentable";
- X#endif
- X#ifdef EREFUSED
- X case EREFUSED: return "EREFUSED";
- X#endif
- X#ifdef EREMCHG
- X case EREMCHG: return "remote address changed";
- X#endif
- X#ifdef EREMDEV
- X case EREMDEV: return "remote device";
- X#endif
- X#ifdef EREMOTE
- X case EREMOTE: return "pathname hit remote file system";
- X#endif
- X#ifdef EREMOTEIO
- X case EREMOTEIO: return "remote i/o error";
- X#endif
- X#ifdef EREMOTERELEASE
- X case EREMOTERELEASE: return "EREMOTERELEASE";
- X#endif
- X#ifdef EROFS
- X case EROFS: return "read-only file system";
- X#endif
- X#ifdef ERPCMISMATCH
- X case ERPCMISMATCH: return "RPC version is wrong";
- X#endif
- X#ifdef ERREMOTE
- X case ERREMOTE: return "object is remote";
- X#endif
- X#ifdef ESHUTDOWN
- X case ESHUTDOWN: return "can't send afer socket shutdown";
- X#endif
- X#ifdef ESOCKTNOSUPPORT
- X case ESOCKTNOSUPPORT: return "socket type not supported";
- X#endif
- X#ifdef ESPIPE
- X case ESPIPE: return "invalid seek";
- X#endif
- X#ifdef ESRCH
- X case ESRCH: return "no such process";
- X#endif
- X#ifdef ESRMNT
- X case ESRMNT: return "srmount error";
- X#endif
- X#ifdef ESTALE
- X case ESTALE: return "stale remote file handle";
- X#endif
- X#ifdef ESUCCESS
- X case ESUCCESS: return "Error 0";
- X#endif
- X#ifdef ETIME
- X case ETIME: return "timer expired";
- X#endif
- X#ifdef ETIMEDOUT
- X case ETIMEDOUT: return "connection timed out";
- X#endif
- X#ifdef ETOOMANYREFS
- X case ETOOMANYREFS: return "too many references: can't splice";
- X#endif
- X#ifdef ETXTBSY
- X case ETXTBSY: return "text file or pseudo-device busy";
- X#endif
- X#ifdef EUCLEAN
- X case EUCLEAN: return "structure needs cleaning";
- X#endif
- X#ifdef EUNATCH
- X case EUNATCH: return "protocol driver not attached";
- X#endif
- X#ifdef EUSERS
- X case EUSERS: return "too many users";
- X#endif
- X#ifdef EVERSION
- X case EVERSION: return "version mismatch";
- X#endif
- X#ifdef EWOULDBLOCK
- X case EWOULDBLOCK: return "operation would block";
- X#endif
- X#ifdef EXDEV
- X case EXDEV: return "cross-domain link";
- X#endif
- X#ifdef EXFULL
- X case EXFULL: return "message tables full";
- X#endif
- X }
- X#endif /* ! TCL_SYS_ERRLIST */
- X sprintf(msg, "unknown error (%d)", error);
- X return msg;
- X}
- END_OF_FILE
- if test 11480 -ne `wc -c <'tcl6.1/compat/strerror.c'`; then
- echo shar: \"'tcl6.1/compat/strerror.c'\" unpacked with wrong size!
- fi
- # end of 'tcl6.1/compat/strerror.c'
- fi
- if test -f 'tcl6.1/doc/Hash.man' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tcl6.1/doc/Hash.man'\"
- else
- echo shar: Extracting \"'tcl6.1/doc/Hash.man'\" \(12084 characters\)
- sed "s/^X//" >'tcl6.1/doc/Hash.man' <<'END_OF_FILE'
- X'\" Copyright 1989 Regents of the University of California
- X'\" Permission to use, copy, modify, and distribute this
- X'\" documentation for any purpose and without fee is hereby
- X'\" granted, provided that this notice appears in all copies.
- X'\" The University of California makes no representations about
- X'\" the suitability of this material for any purpose. It is
- X'\" provided "as is" without express or implied warranty.
- X'\"
- X'\" $Header: /user6/ouster/tcl/doc/RCS/Hash.man,v 1.3 91/08/27 10:41:42 ouster Exp $ SPRITE (Berkeley)
- X'\"
- X.\" The definitions below are for supplemental macros used in Sprite
- X.\" manual entries.
- X.\"
- X.\" .HS name section [date [version]]
- X.\" Replacement for .TH in other man pages. See below for valid
- X.\" section names.
- X.\"
- X.\" .AP type name in/out [indent]
- X.\" Start paragraph describing an argument to a library procedure.
- X.\" type is type of argument (int, etc.), in/out is either "in", "out",
- X.\" or "in/out" to describe whether procedure reads or modifies arg,
- X.\" and indent is equivalent to second arg of .IP (shouldn't ever be
- X.\" needed; use .AS below instead)
- X.\"
- X.\" .AS [type [name]]
- X.\" Give maximum sizes of arguments for setting tab stops. Type and
- X.\" name are examples of largest possible arguments that will be passed
- X.\" to .AP later. If args are omitted, default tab stops are used.
- X.\"
- X.\" .BS
- X.\" Start box enclosure. From here until next .BE, everything will be
- X.\" enclosed in one large box.
- X.\"
- X.\" .BE
- X.\" End of box enclosure.
- X.\"
- X.\" .VS
- X.\" Begin vertical sidebar, for use in marking newly-changed parts
- X.\" of man pages.
- X.\"
- X.\" .VE
- X.\" End of vertical sidebar.
- X.\"
- X.\" .DS
- X.\" Begin an indented unfilled display.
- X.\"
- X.\" .DE
- X.\" End of indented unfilled display.
- X.\"
- X' # Heading for Sprite man pages
- X.de HS
- X.if '\\$2'cmds' .TH \\$1 1 \\$3 \\$4
- X.if '\\$2'lib' .TH \\$1 3 \\$3 \\$4
- X.if '\\$2'tcl' .TH \\$1 3 \\$3 \\$4
- X.if '\\$2'tk' .TH \\$1 3 \\$3 \\$4
- X.if t .wh -1.3i ^B
- X.nr ^l \\n(.l
- X.ad b
- X..
- X' # Start an argument description
- X.de AP
- X.ie !"\\$4"" .TP \\$4
- X.el \{\
- X. ie !"\\$2"" .TP \\n()Cu
- X. el .TP 15
- X.\}
- X.ie !"\\$3"" \{\
- X.ta \\n()Au \\n()Bu
- X\&\\$1 \\fI\\$2\\fP (\\$3)
- X.\".b
- X.\}
- X.el \{\
- X.br
- X.ie !"\\$2"" \{\
- X\&\\$1 \\fI\\$2\\fP
- X.\}
- X.el \{\
- X\&\\fI\\$1\\fP
- X.\}
- X.\}
- X..
- X' # define tabbing values for .AP
- X.de AS
- X.nr )A 10n
- X.if !"\\$1"" .nr )A \\w'\\$1'u+3n
- X.nr )B \\n()Au+15n
- X.\"
- X.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
- X.nr )C \\n()Bu+\\w'(in/out)'u+2n
- X..
- X' # BS - start boxed text
- X' # ^y = starting y location
- X' # ^b = 1
- X.de BS
- X.br
- X.mk ^y
- X.nr ^b 1u
- X.if n .nf
- X.if n .ti 0
- X.if n \l'\\n(.lu\(ul'
- X.if n .fi
- X..
- X' # BE - end boxed text (draw box now)
- X.de BE
- X.nf
- X.ti 0
- X.mk ^t
- X.ie n \l'\\n(^lu\(ul'
- X.el \{\
- X.\" Draw four-sided box normally, but don't draw top of
- X.\" box if the box started on an earlier page.
- X.ie !\\n(^b-1 \{\
- X\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
- X.\}
- X.el \}\
- X\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
- X.\}
- X.\}
- X.fi
- X.br
- X.nr ^b 0
- X..
- X' # VS - start vertical sidebar
- X' # ^Y = starting y location
- X' # ^v = 1 (for troff; for nroff this doesn't matter)
- X.de VS
- X.mk ^Y
- X.ie n 'mc \s12\(br\s0
- X.el .nr ^v 1u
- X..
- X' # VE - end of vertical sidebar
- X.de VE
- X.ie n 'mc
- X.el \{\
- X.ev 2
- X.nf
- X.ti 0
- X.mk ^t
- X\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
- X.sp -1
- X.fi
- X.ev
- X.\}
- X.nr ^v 0
- X..
- X' # Special macro to handle page bottom: finish off current
- X' # box/sidebar if in box/sidebar mode, then invoked standard
- X' # page bottom macro.
- X.de ^B
- X.ev 2
- X'ti 0
- X'nf
- X.mk ^t
- X.if \\n(^b \{\
- X.\" Draw three-sided box if this is the box's first page,
- X.\" draw two sides but no top otherwise.
- X.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
- X.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
- X.\}
- X.if \\n(^v \{\
- X.nr ^x \\n(^tu+1v-\\n(^Yu
- X\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
- X.\}
- X.bp
- X'fi
- X.ev
- X.if \\n(^b \{\
- X.mk ^y
- X.nr ^b 2
- X.\}
- X.if \\n(^v \{\
- X.mk ^Y
- X.\}
- X..
- X' # DS - begin display
- X.de DS
- X.RS
- X.nf
- X.sp
- X..
- X' # DE - end display
- X.de DE
- X.fi
- X.RE
- X.sp .5
- X..
- X.HS Tcl_Hash tcl
- X.BS
- X.SH NAME
- X.na
- XTcl_InitHashTable, Tcl_DeleteHashTable, Tcl_CreateHashEntry, \
- XTcl_DeleteHashEntry, Tcl_FindHashEntry, Tcl_GetHashValue, Tcl_SetHashValue, \
- XTcl_GetHashKey, Tcl_FirstHashEntry, Tcl_NextHashEntry, \
- XTcl_HashStats \- procedures to manage hash tables
- X.SH SYNOPSIS
- X.nf
- X\fB#include <tclHash.h>\fR
- X.sp
- X\fBTcl_InitHashTable\fR(\fItablePtr, keyType\fR)
- X.sp
- X\fBTcl_DeleteHashTable\fR(\fItablePtr\fR)
- X.sp
- XTcl_HashEntry *
- X\fBTcl_CreateHashEntry\fR(\fItablePtr, key, newPtr\fR)
- X.sp
- X\fBTcl_DeleteHashEntry\fR(\fIentryPtr\fR)
- X.sp
- XTcl_HashEntry *
- X\fBTcl_FindHashEntry\fR(\fItablePtr, key\fR)
- X.sp
- XClientData
- X\fBTcl_GetHashValue\fR(\fIentryPtr\fR)
- X.sp
- X\fBTcl_SetHashValue\fR(\fIentryPtr, value\fR)
- X.sp
- Xchar *
- X\fBTcl_GetHashKey\fR(\fItablePtr, entryPtr\fR)
- X.sp
- XTcl_HashEntry *
- X\fBTcl_FirstHashEntry\fR(\fItablePtr, searchPtr\fR)
- X.sp
- XTcl_HashEntry *
- X\fBTcl_NextHashEntry\fR(\fIsearchPtr\fR)
- X.sp
- Xchar *
- X\fBTcl_HashStats\fR(\fItablePtr\fR)
- X.SH ARGUMENTS
- X.AS Tcl_HashSearch *searchPtr
- X.AP Tcl_HashTable *tablePtr in
- XAddress of hash table structure (for all procedures but
- X\fBTcl_InitHashTable\fR, this must have been initialized by
- Xprevious call to \fBTcl_InitHashTable\fR).
- X.AP int keyType in
- XKind of keys to use for new hash table. Must be either
- XTCL_STRING_KEYS, TCL_ONE_WORD_KEYS, or an integer value
- Xgreater than 1.
- X.AP char *key in
- XKey to use for probe into table. Exact form depends on
- X\fIkeyType\fR used to create table.
- X.AP int *newPtr out
- XThe word at \fI*newPtr\fR is set to 1 if a new entry was created
- Xand 0 if there was already an entry for \fIkey\fR.
- X.AP Tcl_HashEntry *entryPtr in
- XPointer to hash table entry.
- X.AP ClientData value in
- XNew value to assign to hash table entry. Need not have type
- XClientData, but must fit in same space as ClientData.
- X.AP Tcl_HashSearch *searchPtr in
- XPointer to record to use to keep track of progress in enumerating
- Xall the entries in a hash table.
- X.BE
- X
- X.SH DESCRIPTION
- X.PP
- XA hash table consists of zero or more entries, each consisting of
- Xa key and a value.
- XGiven the key for an entry, the hashing routines can very quickly
- Xlocate the entry, and hence its value.
- XThere may be at most one entry in a hash table with a
- Xparticular key, but many entries may have the same value.
- XKeys can take one of three forms: strings,
- Xone-word values, or integer arrays.
- XAll of the keys in a given table have the same form, which is
- Xspecified when the table is initialized.
- X.PP
- XThe value of a hash table entry can be anything that fits in
- Xthe same space as a ``char *'' pointer.
- XValues for hash table entries are managed entirely by clients,
- Xnot by the hash module itself.
- XTypically each entry's value is a pointer to a data structure
- Xmanaged by client code.
- X.PP
- XHash tables grow gracefully as the number of entries increases,
- Xso that there are always less than three entries per hash bucket,
- Xon average.
- XThis allows for fast lookups regardless of the number of entries
- Xin a table.
- X.PP
- X\fBTcl_InitHashTable\fR initializes a structure that describes
- Xa new hash table.
- XThe space for the structure is provided by the caller, not by
- Xthe hash module.
- XThe value of \fIkeyType\fR indicates what kinds of keys will
- Xbe used for all entries in the table. \fIKeyType\fR must have
- Xone of the following values:
- X.IP \fBTCL_STRING_KEYS\fR 25
- XKeys are null-terminated ASCII strings.
- XThey are passed to hashing routines using the address of the
- Xfirst character of the string.
- X.IP \fBTCL_ONE_WORD_KEYS\fR 25
- XKeys are single-word values; they are passed to hashing routines
- Xand stored in hash table entries as ``char *'' values.
- XThe pointer value is the key; it need not (and usually doesn't)
- Xactually point to a string.
- X.IP \fIother\fR 25
- XIf \fIkeyType\fR is not TCL_STRING_KEYS or TCL_ONE_WORD_KEYS,
- Xthen it must be an integer value greater than 1.
- XIn this case the keys will be arrays of ``int'' values, where
- X\fIkeyType\fR gives the number of ints in each key.
- XThis allows structures to be used as keys.
- XAll keys must have the same size.
- XArray keys are passed into hashing functions using the address
- Xof the first int in the array.
- X.PP
- X\fBTcl_DeleteHashTable\fR deletes all of the entries in a hash
- Xtable and frees up the memory associated with the table's
- Xbucket array and entries.
- XIt does not free the actual table structure (pointed to
- Xby \fItablePtr\fR), since that memory is assumed to be managed
- Xby the client.
- X\fBTcl_DeleteHashTable\fR also does not free or otherwise
- Xmanipulate the values of the hash table entries.
- XIf the entry values point to dynamically-allocated memory, then
- Xit is the client's responsibility to free these structures
- Xbefore deleting the table.
- X.PP
- X\fBTcl_CreateHashEntry\fR locates the entry corresponding to a
- Xparticular key, creating a new entry in the table if there
- Xwasn't already one with the given key.
- XIf an entry already existed with the given key then \fI*newPtr\fR
- Xis set to zero.
- XIf a new entry was created, then \fI*newPtr\fR is set to a non-zero
- Xvalue and the value of the new entry will be set to zero.
- XThe return value from \fBTcl_CreateHashEntry\fR is a pointer to
- Xthe entry, which may be used to retrieve and modify the entry's
- Xvalue or to delete the entry from the table.
- X.PP
- X\fBTcl_DeleteHashEntry\fR will remove an existing entry from a
- Xtable.
- XThe memory associated with the entry itself will be freed, but
- Xthe client is responsible for any cleanup associated with the
- Xentry's value, such as freeing a structure that it points to.
- X.PP
- X\fBTcl_FindHashEntry\fR is similar to \fBTcl_CreateHashEntry\fR
- Xexcept that it doesn't create a new entry if the key doesn't exist;
- Xinstead, it returns NULL as result.
- X.PP
- X\fBTcl_GetHashValue\fR and \fBTcl_SetHashValue\fR are used to
- Xread and write an entry's value, respectively.
- XValues are stored and retrieved as type ``ClientData'', which is
- Xlarge enough to hold a pointer value. On almost all machines this is
- Xlarge enough to hold an integer value too.
- X.PP
- X\fBTcl_GetHashKey\fR returns the key for a given hash table entry,
- Xeither as a pointer to a string, a one-word (``char *'') key, or
- Xas a pointer to the first word of an array of integers, depending
- Xon the \fIkeyType\fR used to create a hash table.
- XIn all cases \fBTcl_GetHashKey\fR returns a result with type
- X``char *''.
- XWhen the key is a string or array, the result of \fBTcl_GetHashKey\fR
- Xpoints to information in the table entry; this information will
- Xremain valid until the entry is deleted or its table is deleted.
- X.PP
- X\fBTcl_FirstHashEntry\fR and \fBTcl_NextHashEntry\fR may be used
- Xto scan all of the entries in a hash table.
- XA structure of type ``Tcl_HashSearch'', provided by the client,
- Xis used to keep track of progress through the table.
- X\fBTcl_FirstHashEntry\fR initializes the search record and
- Xreturns the first entry in the table (or NULL if the table is
- Xempty).
- XEach susequent call to \fBTcl_NextHashEntry\fR returns the
- Xnext entry in the table or
- XNULL if the end of the table has been reached.
- XA call to \fBTcl_FirstHashEntry\fR followed by calls to
- X\fBTcl_NextHashEntry\fR will return each of the entries in
- Xthe table exactly once, in an arbitrary order.
- XIt is unadvisable to modify the structure of the table, e.g.
- Xby creating or deleting entries, while the search is in
- Xprogress.
- X.PP
- X\fBTcl_HashStats\fR returns a dynamically-allocated string with
- Xoverall information about a hash table, such as the number of
- Xentries it contains, the number of buckets in its hash array,
- Xand the utilization of the buckets.
- XIt is the caller's responsibility to free the result string
- Xby passing it to \fBfree\fR.
- X.PP
- XThe header file \fBtclHash.h\fR defines the actual data structures
- Xused to implement hash tables.
- XThis is necessary so that clients can allocate Tcl_HashTable
- Xstructures and so that macros can be used to read and write
- Xthe values of entries.
- XHowever, users of the hashing routines should never refer directly
- Xto any of the fields of any of the hash-related data structures;
- Xuse the procedures and macros defined here.
- X
- X.SH KEYWORDS
- Xhash table, key, lookup, search, value
- END_OF_FILE
- if test 12084 -ne `wc -c <'tcl6.1/doc/Hash.man'`; then
- echo shar: \"'tcl6.1/doc/Hash.man'\" unpacked with wrong size!
- fi
- # end of 'tcl6.1/doc/Hash.man'
- fi
- if test -f 'tcl6.1/tests/format.test' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tcl6.1/tests/format.test'\"
- else
- echo shar: Extracting \"'tcl6.1/tests/format.test'\" \(11548 characters\)
- sed "s/^X//" >'tcl6.1/tests/format.test' <<'END_OF_FILE'
- X# Commands covered: format
- X#
- X# This file contains a collection of tests for one or more of the Tcl
- X# built-in commands. Sourcing this file into Tcl runs the tests and
- X# generates output for errors. No output means no errors were found.
- X#
- X# Copyright 1991 Regents of the University of California
- X# Permission to use, copy, modify, and distribute this
- X# software and its documentation for any purpose and without
- X# fee is hereby granted, provided that this copyright notice
- X# appears in all copies. The University of California makes no
- X# representations about the suitability of this software for any
- X# purpose. It is provided "as is" without express or implied
- X# warranty.
- X#
- X# $Header: /sprite/src/lib/tcl/tests/RCS/format.test,v 1.6 91/09/17 11:32:01 ouster Exp $ (Berkeley)
- X
- Xif {[string compare test [info procs test]] == 1} then {source defs}
- X
- X# The following code is needed because some versions of SCO Unix have
- X# a round-off error in sprintf which would cause some of the tests to
- X# fail. Someday I hope this code shouldn't be necessary (code added
- X# 9/9/91).
- X
- Xset roundOffBug 0
- Xif {"[format %7.1e 68.514]" == "6.8e+01"} {
- X puts stdout "Note: this system has a sprintf round-off bug, some tests skipped\n"
- X set roundOffBug 1
- X}
- X
- Xtest format-1.1 {integer formatting} {
- X format "%*d %d %d %d" 6 34 16923 -12 -1
- X} { 34 16923 -12 -1}
- Xtest format-1.2 {integer formatting} {
- X format "%4d %4d %4d %4d %d %#x %#X" 6 34 16923 -12 -1 0 0
- X} { 6 34 16923 -12 -1 0 0}
- Xtest format-1.3 {integer formatting} {
- X format "%4u %4u %4u %4u %d %#o" 6 34 16923 -12 -1 0
- X} { 6 34 16923 4294967284 -1 0}
- Xtest format-1.4 {integer formatting} {
- X format "%-4d %-4d %-4d %-4ld" 6 34 16923 -12 -1
- X} {6 34 16923 -12 }
- Xtest format-1.5 {integer formatting} {
- X format "%04d %04d %04d %04d" 6 34 16923 -12 -1
- X} {0006 0034 16923 -012}
- Xtest format-1.6 {integer formatting} {
- X format "%00*d" 6 34
- X} {000034}
- Xtest format-1.7 {integer formatting} {
- X format "%4x %4x %4x %4x" 6 34 16923 -12 -1
- X} { 6 22 421b fffffff4}
- Xtest format-1.8 {integer formatting} {
- X format "%#x %#X %#X %#x" 6 34 16923 -12 -1
- X} {0x6 0X22 0X421B 0xfffffff4}
- Xtest format-1.9 {integer formatting} {
- X format "%#20x %#20x %#20x %#20x" 6 34 16923 -12 -1
- X} { 0x6 0x22 0x421b 0xfffffff4}
- Xtest format-1.10 {integer formatting} {
- X format "%-#20x %-#20x %-#20x %-#20x" 6 34 16923 -12 -1
- X} {0x6 0x22 0x421b 0xfffffff4 }
- Xtest format-1.11 {integer formatting} {
- X format "%-#20o %#-20o %#-20o %#-20o" 6 34 16923 -12 -1
- X} {06 042 041033 037777777764 }
- X
- Xtest format-2.1 {string formatting} {
- X format "%s %s %c %s" abcd {This is a very long test string.} 120 x
- X} {abcd This is a very long test string. x x}
- Xtest format-2.2 {string formatting} {
- X format "%20s %20s %20c %20s" abcd {This is a very long test string.} 120 x
- X} { abcd This is a very long test string. x x}
- Xtest format-2.3 {string formatting} {
- X format "%.10s %.10s %c %.10s" abcd {This is a very long test string.} 120 x
- X} {abcd This is a x x}
- Xtest format-2.4 {string formatting} {
- X format "%s %s %% %c %s" abcd {This is a very long test string.} 120 x
- X} {abcd This is a very long test string. % x x}
- X
- Xtest format-3.1 {e and f formats} {
- X format "%e %e %e %e" 34.2e12 68.514 -.125 -16000. .000053
- X} {3.420000e+13 6.851400e+01 -1.250000e-01 -1.600000e+04}
- Xtest format-3.2 {e and f formats} {
- X format "%20e %20e %20e %20e" 34.2e12 68.514 -.125 -16000. .000053
- X} { 3.420000e+13 6.851400e+01 -1.250000e-01 -1.600000e+04}
- Xif {!$roundOffBug} {
- X test format-3.3 {e and f formats} {
- X format "%.1e %.1e %.1e %.1e" 34.2e12 68.514 -.126 -16000. .000053
- X } {3.4e+13 6.9e+01 -1.3e-01 -1.6e+04}
- X test format-3.4 {e and f formats} {
- X format "%020e %020e %020e %020e" 34.2e12 68.514 -.126 -16000. .000053
- X } {000000003.420000e+13 000000006.851400e+01 -00000001.260000e-01 -00000001.600000e+04}
- X test format-3.5 {e and f formats} {
- X format "%7.1e %7.1e %7.1e %7.1e" 34.2e12 68.514 -.126 -16000. .000053
- X } {3.4e+13 6.9e+01 -1.3e-01 -1.6e+04}
- X test format-3.6 {e and f formats} {
- X format "%f %f %f %f" 34.2e12 68.514 -.125 -16000. .000053
- X } {34200000000000.000000 68.514000 -0.125000 -16000.000000}
- X}
- Xtest format-3.7 {e and f formats} {
- X format "%.4f %.4f %.4f %.4f %.4f" 34.2e12 68.514 -.125 -16000. .000053
- X} {34200000000000.0000 68.5140 -0.1250 -16000.0000 0.0001}
- Xtest format-3.8 {e and f formats} {
- X format "%.4e %.5e %.6e" -9.99996 -9.99996 9.99996
- X} {-1.0000e+01 -9.99996e+00 9.999960e+00}
- Xtest format-3.9 {e and f formats} {
- X format "%.4f %.5f %.6f" -9.99996 -9.99996 9.99996
- X} {-10.0000 -9.99996 9.999960}
- Xtest format-3.10 {e and f formats} {
- X format "%20f %-20f %020f" -9.99996 -9.99996 9.99996
- X} { -9.999960 -9.999960 0000000000009.999960}
- Xtest format-3.11 {e and f formats} {
- X format "%-020f %020f" -9.99996 -9.99996 9.99996
- X} {-9.999960 -000000000009.999960}
- Xtest format-3.12 {e and f formats} {
- X format "%.0e %#.0e" -9.99996 -9.99996 9.99996
- X} {-1e+01 -1.e+01}
- Xtest format-3.13 {e and f formats} {
- X format "%.0f %#.0f" -9.99996 -9.99996 9.99996
- X} {-10 -10.}
- Xtest format-3.14 {e and f formats} {
- X format "%.4f %.5f %.6f" -9.99996 -9.99996 9.99996
- X} {-10.0000 -9.99996 9.999960}
- Xtest format-3.15 {e and f formats} {
- X format "%3.0f %3.0f %3.0f %3.0f" 1.0 1.1 1.01 1.001
- X} { 1 1 1 1}
- Xtest format-3.16 {e and f formats} {
- X format "%3.1f %3.1f %3.1f %3.1f" 0.0 0.1 0.01 0.001
- X} {0.0 0.1 0.0 0.0}
- X
- Xtest format-4.1 {g-format} {
- X format "%.3g" 12341.0
- X} {1.23e+04}
- Xtest format-4.2 {g-format} {
- X format "%.3G" 1234.12345
- X} {1.23E+03}
- Xtest format-4.3 {g-format} {
- X format "%.3g" 123.412345
- X} {123}
- Xtest format-4.4 {g-format} {
- X format "%.3g" 12.3412345
- X} {12.3}
- Xtest format-4.5 {g-format} {
- X format "%.3g" 1.23412345
- X} {1.23}
- Xtest format-4.6 {g-format} {
- X format "%.3g" 1.23412345
- X} {1.23}
- Xtest format-4.7 {g-format} {
- X format "%.3g" .123412345
- X} {0.123}
- Xtest format-4.8 {g-format} {
- X format "%.3g" .012341
- X} {0.0123}
- Xtest format-4.9 {g-format} {
- X format "%.3g" .0012341
- X} {0.00123}
- Xtest format-4.10 {g-format} {
- X format "%.3g" .00012341
- X} {0.000123}
- Xtest format-4.11 {g-format} {
- X format "%.3g" .00001234
- X} {1.23e-05}
- Xtest format-4.12 {g-format} {
- X format "%.4g" 9999.6
- X} {1e+04}
- Xtest format-4.13 {g-format} {
- X format "%.4g" 999.96
- X} {1000}
- Xtest format-4.14 {g-format} {
- X format "%.3g" 1.0
- X} {1}
- Xtest format-4.15 {g-format} {
- X format "%.3g" .1
- X} {0.1}
- Xtest format-4.16 {g-format} {
- X format "%.3g" .01
- X} {0.01}
- Xtest format-4.17 {g-format} {
- X format "%.3g" .001
- X} {0.001}
- Xtest format-4.19 {g-format} {
- X format "%.3g" .00001
- X} {1e-05}
- Xtest format-4.20 {g-format} {
- X format "%#.3g" 1234.0
- X} {1.23e+03}
- Xtest format-4.21 {g-format} {
- X format "%#.3G" 9999.5
- X} {1.00E+04}
- X
- Xtest format-5.1 {floating-point zeroes} {
- X format "%e %f %g" 0.0 0.0 0.0 0.0
- X} {0.000000e+00 0.000000 0}
- Xtest format-5.2 {floating-point zeroes} {
- X format "%.4e %.4f %.4g" 0.0 0.0 0.0 0.0
- X} {0.0000e+00 0.0000 0}
- Xtest format-5.3 {floating-point zeroes} {
- X format "%#.4e %#.4f %#.4g" 0.0 0.0 0.0 0.0
- X} {0.0000e+00 0.0000 0.000}
- Xtest format-5.4 {floating-point zeroes} {
- X format "%.0e %.0f %.0g" 0.0 0.0 0.0 0.0
- X} {0e+00 0 0}
- Xtest format-5.5 {floating-point zeroes} {
- X format "%#.0e %#.0f %#.0g" 0.0 0.0 0.0 0.0
- X} {0.e+00 0. 0.}
- Xtest format-5.6 {floating-point zeroes} {
- X format "%3.0f %3.0f %3.0f %3.0f" 0.0 0.0 0.0 0.0
- X} { 0 0 0 0}
- Xtest format-5.7 {floating-point zeroes} {
- X format "%3.0f %3.0f %3.0f %3.0f" 1.0 1.1 1.01 1.001
- X} { 1 1 1 1}
- Xtest format-5.8 {floating-point zeroes} {
- X format "%3.1f %3.1f %3.1f %3.1f" 0.0 0.1 0.01 0.001
- X} {0.0 0.1 0.0 0.0}
- X
- Xtest format-6.1 {various syntax features} {
- X format "%*.*f" 12 3 12.345678901
- X} { 12.346}
- Xtest format-6.2 {various syntax features} {
- X format "%0*.*f" 12 3 12.345678901
- X} {00000012.346}
- X
- Xtest format-7.1 {error conditions} {
- X catch format
- X} 1
- Xtest format-7.2 {error conditions} {
- X catch format msg
- X set msg
- X} {wrong # args: should be "format formatString ?arg arg ...?"}
- Xtest format-7.3 {error conditions} {
- X catch {format %*d}
- X} 1
- Xtest format-7.4 {error conditions} {
- X catch {format %*d} msg
- X set msg
- X} {not enough arguments for all format specifiers}
- Xtest format-7.5 {error conditions} {
- X catch {format %*.*f 12}
- X} 1
- Xtest format-7.6 {error conditions} {
- X catch {format %*.*f 12} msg
- X set msg
- X} {not enough arguments for all format specifiers}
- Xtest format-7.7 {error conditions} {
- X catch {format %*.*f 12 3}
- X} 1
- Xtest format-7.8 {error conditions} {
- X catch {format %*.*f 12 3} msg
- X set msg
- X} {not enough arguments for all format specifiers}
- Xtest format-7.9 {error conditions} {
- X list [catch {format %*d x 3} msg] $msg
- X} {1 {expected integer but got "x"}}
- Xtest format-7.10 {error conditions} {
- X list [catch {format %*.*f 2 xyz 3} msg] $msg
- X} {1 {expected integer but got "xyz"}}
- Xtest format-7.11 {error conditions} {
- X catch {format %d 2a}
- X} 1
- Xtest format-7.12 {error conditions} {
- X catch {format %d 2a} msg
- X set msg
- X} {expected integer but got "2a"}
- Xtest format-7.13 {error conditions} {
- X catch {format %c 2x}
- X} 1
- Xtest format-7.14 {error conditions} {
- X catch {format %c 2x} msg
- X set msg
- X} {expected integer but got "2x"}
- Xtest format-7.15 {error conditions} {
- X catch {format %f 2.1z}
- X} 1
- Xtest format-7.16 {error conditions} {
- X catch {format %f 2.1z} msg
- X set msg
- X} {expected floating-point number but got "2.1z"}
- Xtest format-7.17 {error conditions} {
- X catch {format ab%}
- X} 1
- Xtest format-7.18 {error conditions} {
- X catch {format ab% 12} msg
- X set msg
- X} {format string ended in middle of field specifier}
- Xtest format-7.19 {error conditions} {
- X catch {format %q x}
- X} 1
- Xtest format-7.20 {error conditions} {
- X catch {format %q x} msg
- X set msg
- X} {bad field specifier "q"}
- Xtest format-7.21 {error conditions} {
- X catch {format %d}
- X} 1
- Xtest format-7.22 {error conditions} {
- X catch {format %d} msg
- X set msg
- X} {not enough arguments for all format specifiers}
- X
- Xtest format-8.1 {long result} {
- X set a {1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 \
- X3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E \
- XF G H I J K L M N O P Q R S T U V W X Y Z}
- X format {1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd \
- Xeeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss \
- Xtttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF \
- XGGGG %s %s %s} $a $a $a
- X} {1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff \
- Xgggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu \
- Xvvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG \
- X1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 3 4 5 6 \
- X7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H \
- XI J K L M N O P Q R S T U V W X Y Z \
- X1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 3 4 5 6 7 \
- X8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I \
- XJ K L M N O P Q R S T U V W X Y Z \
- X1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 3 4 5 6 7 \
- X8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I \
- XJ K L M N O P Q R S T U V W X Y Z}
- END_OF_FILE
- if test 11548 -ne `wc -c <'tcl6.1/tests/format.test'`; then
- echo shar: \"'tcl6.1/tests/format.test'\" unpacked with wrong size!
- fi
- # end of 'tcl6.1/tests/format.test'
- fi
- if test -f 'tcl6.1/tests/parse.test' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tcl6.1/tests/parse.test'\"
- else
- echo shar: Extracting \"'tcl6.1/tests/parse.test'\" \(11404 characters\)
- sed "s/^X//" >'tcl6.1/tests/parse.test' <<'END_OF_FILE'
- X# Commands covered: set (plus basic command syntax)
- X#
- X# This file contains a collection of tests for one or more of the Tcl
- X# built-in commands. Sourcing this file into Tcl runs the tests and
- X# generates output for errors. No output means no errors were found.
- X#
- X# Copyright 1991 Regents of the University of California
- X# Permission to use, copy, modify, and distribute this
- X# software and its documentation for any purpose and without
- X# fee is hereby granted, provided that this copyright notice
- X# appears in all copies. The University of California makes no
- X# representations about the suitability of this software for any
- X# purpose. It is provided "as is" without express or implied
- X# warranty.
- X#
- X# $Header: /user6/ouster/tcl/tests/RCS/parse.test,v 1.21 91/10/31 16:40:37 ouster Exp $ (Berkeley)
- X
- Xif {[string compare test [info procs test]] == 1} then {source defs}
- X
- Xproc fourArgs {a b c d} {
- X global arg1 arg2 arg3 arg4
- X set arg1 $a
- X set arg2 $b
- X set arg3 $c
- X set arg4 $d
- X}
- X
- Xproc getArgs args {
- X global argv
- X set argv $args
- X}
- X
- X# Basic argument parsing.
- X
- Xtest parse-1.1 {basic argument parsing} {
- X set arg1 {}
- X fourArgs a b c d
- X list $arg1 $arg2 $arg3 $arg4
- X} {a b c d}
- Xtest parse-1.2 {basic argument parsing} {
- X set arg1 {}
- X eval "fourArgs 123\v4\f56\r7890"
- X list $arg1 $arg2 $arg3 $arg4
- X} {123 4 56 7890}
- X
- X# Quotes.
- X
- Xtest parse-2.1 {quotes and variable-substitution} {
- X getArgs "a b c" d
- X set argv
- X} {{a b c} d}
- Xtest parse-2.2 {quotes and variable-substitution} {
- X set a 101
- X getArgs "a$a b c"
- X set argv
- X} {{a101 b c}}
- Xtest parse-2.3 {quotes and variable-substitution} {
- X set argv "xy[format xabc]"
- X set argv
- X} {xyxabc}
- Xtest parse-2.4 {quotes and variable-substitution} {
- X set argv "xy\t"
- X set argv
- X} xy\t
- Xtest parse-2.5 {quotes and variable-substitution} {
- X set argv "a b c
- Xd e f"
- X set argv
- X} a\ b\tc\nd\ e\ f
- Xtest parse-2.6 {quotes and variable-substitution} {
- X set argv a"bcd"e
- X set argv
- X} {a"bcd"e}
- X
- X# Braces.
- X
- Xtest parse-3.1 {braces} {
- X getArgs {a b c} d
- X set argv
- X} "{a b c} d"
- Xtest parse-3.2 {braces} {
- X set a 101
- X set argv {a$a b c}
- X set b [string index $argv 1]
- X set b
- X} {$}
- Xtest parse-3.3 {braces} {
- X set argv {a[format xyz] b}
- X string length $argv
- X} 15
- Xtest parse-3.4 {braces} {
- X set argv {a\nb\}}
- X string length $argv
- X} 6
- Xtest parse-3.5 {braces} {
- X set argv {{{{}}}}
- X set argv
- X} "{{{}}}"
- Xtest parse-3.6 {braces} {
- X set argv a{{}}b
- X set argv
- X} "a{{}}b"
- Xtest parse-3.7 {braces} {
- X set a [format "last]"]
- X set a
- X} {last]}
- X
- X# Command substitution.
- X
- Xtest parse-4.1 {command substitution} {
- X set a [format xyz]
- X set a
- X} xyz
- Xtest parse-4.2 {command substitution} {
- X set a a[format xyz]b[format q]
- X set a
- X} axyzbq
- Xtest parse-4.3 {command substitution} {
- X set a a[
- Xset b 22;
- Xformat %s $b
- X
- X]b
- X set a
- X} a22b
- X
- X# Variable substitution.
- X
- Xtest parse-5.1 {variable substitution} {
- X set a 123
- X set b $a
- X set b
- X} 123
- Xtest parse-5.2 {variable substitution} {
- X set a 345
- X set b x$a.b
- X set b
- X} x345.b
- Xtest parse-5.3 {variable substitution} {
- X set _123z xx
- X set b $_123z^
- X set b
- X} xx^
- Xtest parse-5.4 {variable substitution} {
- X set a 78
- X set b a${a}b
- X set b
- X} a78b
- Xtest parse-5.5 {variable substitution} {catch {$_non_existent_} msg} 1
- Xtest parse-5.6 {variable substitution} {
- X catch {$_non_existent_} msg
- X set msg
- X} {can't read "_non_existent_": no such variable}
- Xtest parse-5.7 {array variable substitution} {
- X catch {unset a}
- X set a(xyz) 123
- X set b $a(xyz)foo
- X set b
- X} 123foo
- Xtest parse-5.8 {array variable substitution} {
- X catch {unset a}
- X set "a(x y z)" 123
- X set b $a(x y z)foo
- X set b
- X} 123foo
- Xtest parse-5.9 {array variable substitution} {
- X catch {unset a}; catch {unset qqq}
- X set "a(x y z)" qqq
- X set $a([format x]\ y [format z]) foo
- X set qqq
- X} foo
- Xtest parse-5.10 {array variable substitution} {
- X catch {unset a}
- X list [catch {set b $a(22)} msg] $msg
- X} {1 {can't read "a(22)": no such variable}}
- Xtest parse-5.11 {array variable substitution} {
- X set b a$!
- X set b
- X} {a$!}
- Xtest parse-5.12 {array variable substitution} {
- X set b a$()
- X set b
- X} {a$()}
- Xcatch {unset a}
- Xtest parse-5.13 {array variable substitution} {
- X catch {unset a}
- X set long {This is a very long variable, long enough to cause storage \
- X allocation to occur in Tcl_ParseVar. If that storage isn't getting \
- X freed up correctly, then a core leak will occur when this test is \
- X run. This text is probably beginning to sound like drivel, but I've \
- X run out of things to say and I need more characters still.}
- X set a($long) 777
- X set b $a($long)
- X list $b [array names a]
- X} {777 {{This is a very long variable, long enough to cause storage \
- X allocation to occur in Tcl_ParseVar. If that storage isn't getting \
- X freed up correctly, then a core leak will occur when this test is \
- X run. This text is probably beginning to sound like drivel, but I've \
- X run out of things to say and I need more characters still.}}}
- Xtest parse-5.14 {array variable substitution} {
- X catch {unset a}; catch {unset b}; catch {unset a1}
- X set a1(22) foo
- X set a(foo) bar
- X set b $a($a1(22))
- X set b
- X} bar
- Xcatch {unset a}; catch {unset a1}
- X
- X# Backslash substitution.
- X
- Xset errNum 1
- Xproc bsCheck {char num} {
- X global errNum
- X test parse-6.$errNum {backslash substitution} {
- X scan $char %c value
- X set value
- X } $num
- X set errNum [expr $errNum+1]
- X}
- X
- XbsCheck \b 8
- XbsCheck \e 27
- XbsCheck \f 12
- XbsCheck \n 10
- XbsCheck \r 13
- XbsCheck \t 9
- XbsCheck \v 11
- XbsCheck \{ 123
- XbsCheck \} 125
- XbsCheck \[ 91
- XbsCheck \] 93
- XbsCheck \$ 36
- XbsCheck \ 32
- XbsCheck \; 59
- XbsCheck \\ 92
- XbsCheck \Ca 1
- XbsCheck \Ma 225
- XbsCheck \CMa 129
- XbsCheck \14 12
- XbsCheck \00a 97
- XbsCheck b\0 98
- XbsCheck \x 92
- XbsCheck \
- Xa 97
- X
- Xtest parse-7.1 {backslash substitution} {
- X set a "\a\c\n\]\}"
- X string length $a
- X} 7
- Xtest parse-7.2 {backslash substitution} {
- X set a {\a\c\n\]\}}
- X string length $a
- X} 10
- Xtest parse-7.3 {backslash substitution} {
- X set a "abc\
- Xdef"
- X set a
- X} abcdef
- Xtest parse-7.4 {backslash substitution} {
- X set a {abc\
- Xdef}
- X set a
- X} "abcdef"
- Xtest parse-7.5 {backslash substitution} {
- X set msg {}
- X set a xxx
- X set error [catch {if {24 < \
- X 35} {set a 22} {set \
- X a 33}} msg]
- X list $error $msg $a
- X} {0 22 22}
- X
- X# Semi-colon.
- X
- Xtest parse-8.1 {semi-colons} {
- X set b 0
- X getArgs a;set b 2
- X set argv
- X} a
- Xtest parse-8.2 {semi-colons} {
- X set b 0
- X getArgs a;set b 2
- X set b
- X} 2
- Xtest parse-8.3 {semi-colons} {
- X getArgs a b ; set b 1
- X set argv
- X} {a b}
- Xtest parse-8.4 {semi-colons} {
- X getArgs a b ; set b 1
- X set b
- X} 1
- X
- X# The following checks are to ensure that the interpreter's result
- X# gets re-initialized by Tcl_Eval in all the right places.
- X
- Xtest parse-9.1 {result initialization} {concat abc} abc
- Xtest parse-9.2 {result initialization} {concat abc; proc foo {} {}} {}
- Xtest parse-9.3 {result initialization} {concat abc; proc foo {} $a} {}
- Xtest parse-9.4 {result initialization} {proc foo {} [concat abc]} {}
- Xtest parse-9.5 {result initialization} {concat abc; } abc
- Xtest parse-9.6 {result initialization} {
- X eval {
- X concat abc
- X}} abc
- Xtest parse-9.7 {result initialization} {} {}
- Xtest parse-9.8 {result initialization} {concat abc; ; ;} abc
- X
- X# Syntax errors.
- X
- Xtest parse-10.1 {syntax errors} {catch "set a \{bcd" msg} 1
- Xtest parse-10.2 {syntax errors} {
- X catch "set a \{bcd" msg
- X set msg
- X} {missing close-brace}
- Xtest parse-10.3 {syntax errors} {catch {set a "bcd} msg} 1
- Xtest parse-10.4 {syntax errors} {
- X catch {set a "bcd} msg
- X set msg
- X} {missing "}
- Xtest parse-10.5 {syntax errors} {catch {set a "bcd"xy} msg} 1
- Xtest parse-10.6 {syntax errors} {
- X catch {set a "bcd"xy} msg
- X set msg
- X} {extra characters after close-quote}
- Xtest parse-10.7 {syntax errors} {catch "set a {bcd}xy" msg} 1
- Xtest parse-10.8 {syntax errors} {
- X catch "set a {bcd}xy" msg
- X set msg
- X} {extra characters after close-brace}
- Xtest parse-10.9 {syntax errors} {catch {set a [format abc} msg} 1
- Xtest parse-10.10 {syntax errors} {
- X catch {set a [format abc} msg
- X set msg
- X} {missing close-bracket}
- Xtest parse-10.11 {syntax errors} {catch gorp-a-lot msg} 1
- Xtest parse-10.12 {syntax errors} {
- X catch gorp-a-lot msg
- X set msg
- X} {invalid command name: "gorp-a-lot"}
- Xtest parse-10.13 {syntax errors} {
- X set a [concat {a}\
- X {b}]
- X set a
- X} {a b}
- Xtest parse-10.14 {syntax errors} {catch "concat \{a\}\\\n{b}" msg} 1
- Xtest parse-10.15 {syntax errors} {
- X catch "concat \{a\}\\\n{b}" msg
- X set msg
- X} {extra characters after close-brace}
- X
- X# Long values (stressing storage management)
- X
- Xset a {1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee \
- Xffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt \
- Xuuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH}
- X
- Xtest parse-11.1 {long values} {
- X string length $a
- X} 214
- Xtest parse-11.2 {long values} {
- X llength $a
- X} 43
- Xtest parse-1a1.3 {long values} {
- X set b "1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd \
- Xeeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss \
- Xtttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH"
- X set b
- X} $a
- Xtest parse-11.4 {long values} {
- X set b "$a"
- X set b
- X} $a
- Xtest parse-11.5 {long values} {
- X set b [set a]
- X set b
- X} $a
- Xtest parse-11.6 {long values} {
- X set b [concat 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb \
- Xcccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq \
- Xrrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF \
- XGGGG HHHH]
- X string length $b
- X} 214
- Xtest parse-11.7 {long values} {
- X set b [concat 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb \
- Xcccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq \
- Xrrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF \
- XGGGG HHHH]
- X llength $b
- X} 43
- Xtest parse-11.8 {long values} {
- X set b
- X} $a
- Xtest parse-11.9 {long values} {
- X set a [concat 0000 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa \
- Xbbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp \
- Xqqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE \
- XFFFF GGGG HHHH IIII JJJJ KKKK LLLL MMMM NNNN OOOO PPPP QQQQ RRRR SSSS TTTT \
- XUUUU VVVV WWWW XXXX YYYY ZZZZ]
- X llength $a
- X} 62
- Xset i 0
- Xforeach j [concat 0000 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa \
- Xbbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp \
- Xqqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE \
- XFFFF GGGG HHHH IIII JJJJ KKKK LLLL MMMM NNNN OOOO PPPP QQQQ RRRR SSSS TTTT \
- XUUUU VVVV WWWW XXXX YYYY ZZZZ] {
- X set test [string index 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ $i]
- X set test $test$test$test$test
- X set i [expr $i+1]
- X test parse-11.10 {long values} {
- X set j
- X } $test
- X}
- Xtest parse-11.10 {test buffer overflow in backslashes in braces} {
- X expr {"a" == {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
- Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
- Xxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\
- Xyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\
- X\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\
- X\101\101\101\101\101\101\101}}
- X} 0
- END_OF_FILE
- if test 11404 -ne `wc -c <'tcl6.1/tests/parse.test'`; then
- echo shar: \"'tcl6.1/tests/parse.test'\" unpacked with wrong size!
- fi
- # end of 'tcl6.1/tests/parse.test'
- fi
- echo shar: End of archive 10 \(of 33\).
- cp /dev/null ark10isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 33 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-