home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume25 / tcl / part03 < prev    next >
Encoding:
Text File  |  1991-11-14  |  51.4 KB  |  1,730 lines

  1. Newsgroups: comp.sources.misc
  2. From: karl@sugar.neosoft.com (Karl Lehenbauer)
  3. Subject:  v25i071:  tcl - tool command language, version 6.1, Part03/33
  4. Message-ID: <1991Nov14.202607.23225@sparky.imd.sterling.com>
  5. X-Md4-Signature: 5431be559e1574f4be32411910916f5d
  6. Date: Thu, 14 Nov 1991 20:26:07 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
  10. Posting-number: Volume 25, Issue 71
  11. Archive-name: tcl/part03
  12. Environment: UNIX
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 3 (of 33)."
  21. # Contents:  tcl6.1/compat/strtoul.c tcl6.1/doc/StrMatch.man
  22. #   tcl6.1/library/init.tcl tcl6.1/tclGet.c tcl6.1/tclHash.h
  23. #   tcl6.1/tests/README tcl6.1/tests/error.test tcl6.1/tests/for.test
  24. #   tcl6.1/tests/glob.test tcl6.1/tests/if.test
  25. # Wrapped by karl@one on Tue Nov 12 19:44:12 1991
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'tcl6.1/compat/strtoul.c' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'tcl6.1/compat/strtoul.c'\"
  29. else
  30. echo shar: Extracting \"'tcl6.1/compat/strtoul.c'\" \(4318 characters\)
  31. sed "s/^X//" >'tcl6.1/compat/strtoul.c' <<'END_OF_FILE'
  32. X/* 
  33. X * strtoul.c --
  34. X *
  35. X *    Source code for the "strtoul" library procedure.
  36. X *
  37. X * Copyright 1988 Regents of the University of California
  38. X * Permission to use, copy, modify, and distribute this
  39. X * software and its documentation for any purpose and without
  40. X * fee is hereby granted, provided that the above copyright
  41. X * notice appear in all copies.  The University of California
  42. X * makes no representations about the suitability of this
  43. X * software for any purpose.  It is provided "as is" without
  44. X * express or implied warranty.
  45. X */
  46. X
  47. X#ifndef lint
  48. Xstatic char rcsid[] = "$Header: /sprite/src/lib/tcl/compat/RCS/strtoul.c,v 1.2 91/09/22 14:04:43 ouster Exp $ SPRITE (Berkeley)";
  49. X#endif /* not lint */
  50. X
  51. X#include <ctype.h>
  52. X
  53. X/*
  54. X * The table below is used to convert from ASCII digits to a
  55. X * numerical equivalent.  It maps from '0' through 'z' to integers
  56. X * (100 for non-digit characters).
  57. X */
  58. X
  59. Xstatic char cvtIn[] = {
  60. X    0, 1, 2, 3, 4, 5, 6, 7, 8, 9,        /* '0' - '9' */
  61. X    100, 100, 100, 100, 100, 100, 100,        /* punctuation */
  62. X    10, 11, 12, 13, 14, 15, 16, 17, 18, 19,    /* 'A' - 'Z' */
  63. X    20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
  64. X    30, 31, 32, 33, 34, 35,
  65. X    100, 100, 100, 100, 100, 100,        /* punctuation */
  66. X    10, 11, 12, 13, 14, 15, 16, 17, 18, 19,    /* 'a' - 'z' */
  67. X    20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
  68. X    30, 31, 32, 33, 34, 35};
  69. X
  70. X/*
  71. X *----------------------------------------------------------------------
  72. X *
  73. X * strtoul --
  74. X *
  75. X *    Convert an ASCII string into an integer.
  76. X *
  77. X * Results:
  78. X *    The return value is the integer equivalent of string.  If endPtr
  79. X *    is non-NULL, then *endPtr is filled in with the character
  80. X *    after the last one that was part of the integer.  If string
  81. X *    doesn't contain a valid integer value, then zero is returned
  82. X *    and *endPtr is set to string.
  83. X *
  84. X * Side effects:
  85. X *    None.
  86. X *
  87. X *----------------------------------------------------------------------
  88. X */
  89. X
  90. Xunsigned long int
  91. Xstrtoul(string, endPtr, base)
  92. X    char *string;        /* String of ASCII digits, possibly
  93. X                 * preceded by white space.  For bases
  94. X                 * greater than 10, either lower- or
  95. X                 * upper-case digits may be used.
  96. X                 */
  97. X    char **endPtr;        /* Where to store address of terminating
  98. X                 * character, or NULL. */
  99. X    int base;            /* Base for conversion.  Must be less
  100. X                 * than 37.  If 0, then the base is chosen
  101. X                 * from the leading characters of string:
  102. X                 * "0x" means hex, "0" means octal, anything
  103. X                 * else means decimal.
  104. X                 */
  105. X{
  106. X    register char *p;
  107. X    register unsigned long int result = 0;
  108. X    register unsigned digit;
  109. X    int anyDigits = 0;
  110. X
  111. X    /*
  112. X     * Skip any leading blanks.
  113. X     */
  114. X
  115. X    p = string;
  116. X    while (isspace(*p)) {
  117. X    p += 1;
  118. X    }
  119. X
  120. X    /*
  121. X     * If no base was provided, pick one from the leading characters
  122. X     * of the string.
  123. X     */
  124. X    
  125. X    if (base == 0)
  126. X    {
  127. X    if (*p == '0') {
  128. X        p += 1;
  129. X        if (*p == 'x') {
  130. X        p += 1;
  131. X        base = 16;
  132. X        } else {
  133. X
  134. X        /*
  135. X         * Must set anyDigits here, otherwise "0" produces a
  136. X         * "no digits" error.
  137. X         */
  138. X
  139. X        anyDigits = 1;
  140. X        base = 8;
  141. X        }
  142. X    }
  143. X    else base = 10;
  144. X    } else if (base == 16) {
  145. X
  146. X    /*
  147. X     * Skip a leading "0x" from hex numbers.
  148. X     */
  149. X
  150. X    if ((p[0] == '0') && (p[1] == 'x')) {
  151. X        p += 2;
  152. X    }
  153. X    }
  154. X
  155. X    /*
  156. X     * Sorry this code is so messy, but speed seems important.  Do
  157. X     * different things for base 8, 10, 16, and other.
  158. X     */
  159. X
  160. X    if (base == 8) {
  161. X    for ( ; ; p += 1) {
  162. X        digit = *p - '0';
  163. X        if (digit > 7) {
  164. X        break;
  165. X        }
  166. X        result = (result << 3) + digit;
  167. X        anyDigits = 1;
  168. X    }
  169. X    } else if (base == 10) {
  170. X    for ( ; ; p += 1) {
  171. X        digit = *p - '0';
  172. X        if (digit > 9) {
  173. X        break;
  174. X        }
  175. X        result = (10*result) + digit;
  176. X        anyDigits = 1;
  177. X    }
  178. X    } else if (base == 16) {
  179. X    for ( ; ; p += 1) {
  180. X        digit = *p - '0';
  181. X        if (digit > ('z' - '0')) {
  182. X        break;
  183. X        }
  184. X        digit = cvtIn[digit];
  185. X        if (digit > 15) {
  186. X        break;
  187. X        }
  188. X        result = (result << 4) + digit;
  189. X        anyDigits = 1;
  190. X    }
  191. X    } else {
  192. X    for ( ; ; p += 1) {
  193. X        digit = *p - '0';
  194. X        if (digit > ('z' - '0')) {
  195. X        break;
  196. X        }
  197. X        digit = cvtIn[digit];
  198. X        if (digit >= base) {
  199. X        break;
  200. X        }
  201. X        result = result*base + digit;
  202. X        anyDigits = 1;
  203. X    }
  204. X    }
  205. X
  206. X    /*
  207. X     * See if there were any digits at all.
  208. X     */
  209. X
  210. X    if (!anyDigits) {
  211. X    p = string;
  212. X    }
  213. X
  214. X    if (endPtr != 0) {
  215. X    *endPtr = p;
  216. X    }
  217. X
  218. X    return result;
  219. X}
  220. END_OF_FILE
  221. if test 4318 -ne `wc -c <'tcl6.1/compat/strtoul.c'`; then
  222.     echo shar: \"'tcl6.1/compat/strtoul.c'\" unpacked with wrong size!
  223. fi
  224. # end of 'tcl6.1/compat/strtoul.c'
  225. fi
  226. if test -f 'tcl6.1/doc/StrMatch.man' -a "${1}" != "-c" ; then 
  227.   echo shar: Will not clobber existing file \"'tcl6.1/doc/StrMatch.man'\"
  228. else
  229. echo shar: Extracting \"'tcl6.1/doc/StrMatch.man'\" \(4906 characters\)
  230. sed "s/^X//" >'tcl6.1/doc/StrMatch.man' <<'END_OF_FILE'
  231. X'\" Copyright 1989 Regents of the University of California
  232. X'\" Permission to use, copy, modify, and distribute this
  233. X'\" documentation for any purpose and without fee is hereby
  234. X'\" granted, provided that this notice appears in all copies.
  235. X'\" The University of California makes no representations about
  236. X'\" the suitability of this material for any purpose.  It is
  237. X'\" provided "as is" without express or implied warranty.
  238. X'\" 
  239. X'\" $Header: /user6/ouster/tcl/doc/RCS/StrMatch.man,v 1.2 91/04/03 15:14:14 ouster Exp $ SPRITE (Berkeley)
  240. X'\" 
  241. X.\" The definitions below are for supplemental macros used in Sprite
  242. X.\" manual entries.
  243. X.\"
  244. X.\" .HS name section [date [version]]
  245. X.\"    Replacement for .TH in other man pages.  See below for valid
  246. X.\"    section names.
  247. X.\"
  248. X.\" .AP type name in/out [indent]
  249. X.\"    Start paragraph describing an argument to a library procedure.
  250. X.\"    type is type of argument (int, etc.), in/out is either "in", "out",
  251. X.\"    or "in/out" to describe whether procedure reads or modifies arg,
  252. X.\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  253. X.\"    needed;  use .AS below instead)
  254. X.\"
  255. X.\" .AS [type [name]]
  256. X.\"    Give maximum sizes of arguments for setting tab stops.  Type and
  257. X.\"    name are examples of largest possible arguments that will be passed
  258. X.\"    to .AP later.  If args are omitted, default tab stops are used.
  259. X.\"
  260. X.\" .BS
  261. X.\"    Start box enclosure.  From here until next .BE, everything will be
  262. X.\"    enclosed in one large box.
  263. X.\"
  264. X.\" .BE
  265. X.\"    End of box enclosure.
  266. X.\"
  267. X.\" .VS
  268. X.\"    Begin vertical sidebar, for use in marking newly-changed parts
  269. X.\"    of man pages.
  270. X.\"
  271. X.\" .VE
  272. X.\"    End of vertical sidebar.
  273. X.\"
  274. X.\" .DS
  275. X.\"    Begin an indented unfilled display.
  276. X.\"
  277. X.\" .DE
  278. X.\"    End of indented unfilled display.
  279. X.\"
  280. X'    # Heading for Sprite man pages
  281. X.de HS
  282. X.if '\\$2'cmds'       .TH \\$1 1 \\$3 \\$4
  283. X.if '\\$2'lib'        .TH \\$1 3 \\$3 \\$4
  284. X.if '\\$2'tcl'        .TH \\$1 3 \\$3 \\$4
  285. X.if '\\$2'tk'         .TH \\$1 3 \\$3 \\$4
  286. X.if t .wh -1.3i ^B
  287. X.nr ^l \\n(.l
  288. X.ad b
  289. X..
  290. X'    # Start an argument description
  291. X.de AP
  292. X.ie !"\\$4"" .TP \\$4
  293. X.el \{\
  294. X.   ie !"\\$2"" .TP \\n()Cu
  295. X.   el          .TP 15
  296. X.\}
  297. X.ie !"\\$3"" \{\
  298. X.ta \\n()Au \\n()Bu
  299. X\&\\$1    \\fI\\$2\\fP    (\\$3)
  300. X.\".b
  301. X.\}
  302. X.el \{\
  303. X.br
  304. X.ie !"\\$2"" \{\
  305. X\&\\$1    \\fI\\$2\\fP
  306. X.\}
  307. X.el \{\
  308. X\&\\fI\\$1\\fP
  309. X.\}
  310. X.\}
  311. X..
  312. X'    # define tabbing values for .AP
  313. X.de AS
  314. X.nr )A 10n
  315. X.if !"\\$1"" .nr )A \\w'\\$1'u+3n
  316. X.nr )B \\n()Au+15n
  317. X.\"
  318. X.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  319. X.nr )C \\n()Bu+\\w'(in/out)'u+2n
  320. X..
  321. X'    # BS - start boxed text
  322. X'    # ^y = starting y location
  323. X'    # ^b = 1
  324. X.de BS
  325. X.br
  326. X.mk ^y
  327. X.nr ^b 1u
  328. X.if n .nf
  329. X.if n .ti 0
  330. X.if n \l'\\n(.lu\(ul'
  331. X.if n .fi
  332. X..
  333. X'    # BE - end boxed text (draw box now)
  334. X.de BE
  335. X.nf
  336. X.ti 0
  337. X.mk ^t
  338. X.ie n \l'\\n(^lu\(ul'
  339. X.el \{\
  340. X.\"    Draw four-sided box normally, but don't draw top of
  341. X.\"    box if the box started on an earlier page.
  342. X.ie !\\n(^b-1 \{\
  343. X\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  344. X.\}
  345. X.el \}\
  346. X\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  347. X.\}
  348. X.\}
  349. X.fi
  350. X.br
  351. X.nr ^b 0
  352. X..
  353. X'    # VS - start vertical sidebar
  354. X'    # ^Y = starting y location
  355. X'    # ^v = 1 (for troff;  for nroff this doesn't matter)
  356. X.de VS
  357. X.mk ^Y
  358. X.ie n 'mc \s12\(br\s0
  359. X.el .nr ^v 1u
  360. X..
  361. X'    # VE - end of vertical sidebar
  362. X.de VE
  363. X.ie n 'mc
  364. X.el \{\
  365. X.ev 2
  366. X.nf
  367. X.ti 0
  368. X.mk ^t
  369. X\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  370. X.sp -1
  371. X.fi
  372. X.ev
  373. X.\}
  374. X.nr ^v 0
  375. X..
  376. X'    # Special macro to handle page bottom:  finish off current
  377. X'    # box/sidebar if in box/sidebar mode, then invoked standard
  378. X'    # page bottom macro.
  379. X.de ^B
  380. X.ev 2
  381. X'ti 0
  382. X'nf
  383. X.mk ^t
  384. X.if \\n(^b \{\
  385. X.\"    Draw three-sided box if this is the box's first page,
  386. X.\"    draw two sides but no top otherwise.
  387. 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
  388. X.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  389. X.\}
  390. X.if \\n(^v \{\
  391. X.nr ^x \\n(^tu+1v-\\n(^Yu
  392. X\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  393. X.\}
  394. X.bp
  395. X'fi
  396. X.ev
  397. X.if \\n(^b \{\
  398. X.mk ^y
  399. X.nr ^b 2
  400. X.\}
  401. X.if \\n(^v \{\
  402. X.mk ^Y
  403. X.\}
  404. X..
  405. X'    # DS - begin display
  406. X.de DS
  407. X.RS
  408. X.nf
  409. X.sp
  410. X..
  411. X'    # DE - end display
  412. X.de DE
  413. X.fi
  414. X.RE
  415. X.sp .5
  416. X..
  417. X.HS Tcl_StringMatch tcl
  418. X.BS
  419. X.SH NAME
  420. XTcl_StringMatch \- test whether a string matches a pattern
  421. X.SH SYNOPSIS
  422. X.nf
  423. X\fB#include <tcl.h>\fR
  424. X.sp
  425. Xint
  426. X\Tcl_StringMatch\fR(\fIstring\fR, \fIpattern\fR)
  427. X.SH ARGUMENTS
  428. X.AP char *string in
  429. XString to test.
  430. X.AP char *pattern in
  431. XPattern to match against string.  May contain special
  432. Xcharacters from the set *?\e[].
  433. X.BE
  434. X
  435. X.SH DESCRIPTION
  436. X.PP
  437. XThis utility procedure determines whether a string matches
  438. Xa given pattern.  If it does, then \fBTcl_StringMatch\fR returns
  439. X1.  Otherwise \fBTcl_StringMatch\fR returns 0.  The algorithm
  440. Xused for matching is the same algorithm used in the ``string match''
  441. XTcl command and is similar to the algorithm used by the C-shell
  442. Xfor file name matching;  see the Tcl manual entry for details.
  443. X
  444. X.SH KEYWORDS
  445. Xmatch, pattern, string
  446. END_OF_FILE
  447. if test 4906 -ne `wc -c <'tcl6.1/doc/StrMatch.man'`; then
  448.     echo shar: \"'tcl6.1/doc/StrMatch.man'\" unpacked with wrong size!
  449. fi
  450. # end of 'tcl6.1/doc/StrMatch.man'
  451. fi
  452. if test -f 'tcl6.1/library/init.tcl' -a "${1}" != "-c" ; then 
  453.   echo shar: Will not clobber existing file \"'tcl6.1/library/init.tcl'\"
  454. else
  455. echo shar: Extracting \"'tcl6.1/library/init.tcl'\" \(3973 characters\)
  456. sed "s/^X//" >'tcl6.1/library/init.tcl' <<'END_OF_FILE'
  457. X# init.tcl --
  458. X#
  459. X# Default system startup file for Tcl-based applications.  Defines
  460. X# "unknown" procedure and auto-load facilities.
  461. X#
  462. X# $Header: /sprite/src/lib/tcl/scripts/RCS/init.tcl,v 1.2 91/09/26 10:05:45 ouster Exp $ SPRITE (Berkeley)
  463. X#
  464. X# Copyright 1991 Regents of the University of California
  465. X# Permission to use, copy, modify, and distribute this
  466. X# software and its documentation for any purpose and without
  467. X# fee is hereby granted, provided that this copyright
  468. X# notice appears in all copies.  The University of California
  469. X# makes no representations about the suitability of this
  470. X# software for any purpose.  It is provided "as is" without
  471. X# express or implied warranty.
  472. X#
  473. X
  474. X# unknown:
  475. X# Invoked when a Tcl command is invoked that doesn't exist in the
  476. X# interpreter:
  477. X#
  478. X#    1. See if the autoload facility can locate the command in a
  479. X#       Tcl script file.  If so, load it and execute it.
  480. X#    2. See if the command exists as an executable UNIX program.
  481. X#       If so, "exec" the command.
  482. X#    3. See if the command is a valid abbreviation for another command.
  483. X#       if so, invoke the command.  However, only permit abbreviations
  484. X#       at top-level.
  485. X
  486. Xproc unknown args {
  487. X    global auto_noexec auto_noload env unknown_active
  488. X
  489. X    if [info exists unknown_active] {
  490. X    unset unknown_active
  491. X    error "unexpected recursion in \"unknown\" command"
  492. X    }
  493. X    set unknown_active 1
  494. X    set name [lindex $args 0]
  495. X    if ![info exists auto_noload] {
  496. X    if [auto_load $name] {
  497. X        unset unknown_active
  498. X        return [uplevel $args]
  499. X    }
  500. X    }
  501. X    if ![info exists auto_noexec] {
  502. X    if [auto_execok $name] {
  503. X        unset unknown_active
  504. X        return [uplevel exec $args]
  505. X    }
  506. X    }
  507. X    if {([info level] == 1) && ([info script] == "")} {
  508. X    set cmds [info commands $name*]
  509. X    if {[llength $cmds] == 1} {
  510. X        unset unknown_active
  511. X        return [uplevel [lreplace $args 0 0 $cmds]]
  512. X    }
  513. X    if {[llength $cmds] != 0} {
  514. X        unset unknown_active
  515. X        error "ambiguous command name \"$name\": $cmds"
  516. X    }
  517. X    }
  518. X    unset unknown_active
  519. X    error "invalid command name \"$name\""
  520. X}
  521. X
  522. X# auto_load:
  523. X# Checks a collection of library directories to see if a procedure
  524. X# is defined in one of them.  If so, it sources the appropriate
  525. X# library file to create the procedure.  Returns 1 if it successfully
  526. X# loaded the procedure, 0 otherwise.
  527. X
  528. Xproc auto_load cmd {
  529. X    global auto_index auto_path env
  530. X
  531. X    if [info exists auto_index($cmd)] {
  532. X    source $auto_index($cmd)
  533. X    return 1
  534. X    }
  535. X    if [catch {set path $auto_path}] {
  536. X    if [catch {set path $env(TCLLIBPATH)}] {
  537. X        if [catch {set path [info library]}] {
  538. X        return 0
  539. X        }
  540. X    }
  541. X    }
  542. X    foreach dir $path {
  543. X    set f ""
  544. X    catch {
  545. X        set f [open $dir/tclIndex]
  546. X        if {[gets $f] != "# Tcl autoload index file: each line identifies a Tcl"} {
  547. X        puts stdout "Bad id line in file $dir/tclIndex"
  548. X        error done
  549. X        }
  550. X        while {[gets $f line] >= 0} {
  551. X        if {([string index $line 0] == "#") || ([llength $line] != 2)} {
  552. X            continue
  553. X        }
  554. X        set name [lindex $line 0]
  555. X        if {![info exists auto_index($name)]} {
  556. X            set auto_index($name) $dir/[lindex $line 1]
  557. X        }
  558. X        }
  559. X    }
  560. X    if {$f != ""} {
  561. X        close $f
  562. X    }
  563. X    }
  564. X    if [info exists auto_index($cmd)] {
  565. X    source $auto_index($cmd)
  566. X    return 1
  567. X    }
  568. X    return 0
  569. X}
  570. X
  571. X# auto_execok:
  572. X# Returns 1 if there's an executable in the current path for the
  573. X# given name, 0 otherwise.  Builds an associative array auto_execs
  574. X# that caches information about previous checks, for speed.
  575. X
  576. Xproc auto_execok name {
  577. X    global auto_execs env
  578. X
  579. X    if [info exists auto_execs($name)] {
  580. X    return $auto_execs($name)
  581. X    }
  582. X    set auto_execs($name) 0
  583. X    foreach dir [split $env(PATH) :] {
  584. X    if {[file executable $dir/$name] && ![file isdirectory $dir/$name]} {
  585. X        set auto_execs($name) 1
  586. X        return 1
  587. X    }
  588. X    }
  589. X    return 0
  590. X}
  591. X
  592. X# auto_reset:
  593. X# Destroy all cached information for auto-loading and auto-execution,
  594. X# so that the information gets recomputed the next time it's needed.
  595. X
  596. Xproc auto_reset {} {
  597. X    global auto_execs auto_index
  598. X    unset auto_execs auto_index
  599. X}
  600. END_OF_FILE
  601. if test 3973 -ne `wc -c <'tcl6.1/library/init.tcl'`; then
  602.     echo shar: \"'tcl6.1/library/init.tcl'\" unpacked with wrong size!
  603. fi
  604. # end of 'tcl6.1/library/init.tcl'
  605. fi
  606. if test -f 'tcl6.1/tclGet.c' -a "${1}" != "-c" ; then 
  607.   echo shar: Will not clobber existing file \"'tcl6.1/tclGet.c'\"
  608. else
  609. echo shar: Extracting \"'tcl6.1/tclGet.c'\" \(5017 characters\)
  610. sed "s/^X//" >'tcl6.1/tclGet.c' <<'END_OF_FILE'
  611. X/* 
  612. X * tclGet.c --
  613. X *
  614. X *    This file contains procedures to convert strings into
  615. X *    other forms, like integers or floating-point numbers or
  616. X *    booleans, doing syntax checking along the way.
  617. X *
  618. X * Copyright 1990-1991 Regents of the University of California
  619. X * Permission to use, copy, modify, and distribute this
  620. X * software and its documentation for any purpose and without
  621. X * fee is hereby granted, provided that the above copyright
  622. X * notice appear in all copies.  The University of California
  623. X * makes no representations about the suitability of this
  624. X * software for any purpose.  It is provided "as is" without
  625. X * express or implied warranty.
  626. X */
  627. X
  628. X#ifndef lint
  629. Xstatic char rcsid[] = "$Header: /sprite/src/lib/tcl/RCS/tclGet.c,v 1.10 91/09/04 16:53:25 ouster Exp $ SPRITE (Berkeley)";
  630. X#endif /* not lint */
  631. X
  632. X#include "tclInt.h"
  633. X
  634. Xdouble strtod();
  635. X
  636. X
  637. X/*
  638. X *----------------------------------------------------------------------
  639. X *
  640. X * Tcl_GetInt --
  641. X *
  642. X *    Given a string, produce the corresponding integer value.
  643. X *
  644. X * Results:
  645. X *    The return value is normally TCL_OK;  in this case *intPtr
  646. X *    will be set to the integer value equivalent to string.  If
  647. X *    string is improperly formed then TCL_ERROR is returned and
  648. X *    an error message will be left in interp->result.
  649. X *
  650. X * Side effects:
  651. X *    None.
  652. X *
  653. X *----------------------------------------------------------------------
  654. X */
  655. X
  656. Xint
  657. XTcl_GetInt(interp, string, intPtr)
  658. X    Tcl_Interp *interp;        /* Interpreter to use for error reporting. */
  659. X    char *string;        /* String containing a (possibly signed)
  660. X                 * integer in a form acceptable to strtol. */
  661. X    int *intPtr;        /* Place to store converted result. */
  662. X{
  663. X    char *end;
  664. X    int i;
  665. X
  666. X    i = strtol(string, &end, 0);
  667. X    while ((*end != '\0') && isspace(*end)) {
  668. X    end++;
  669. X    }
  670. X    if ((end == string) || (*end != 0)) {
  671. X    Tcl_AppendResult(interp, "expected integer but got \"", string,
  672. X        "\"", (char *) NULL);
  673. X    return TCL_ERROR;
  674. X    }
  675. X    *intPtr = i;
  676. X    return TCL_OK;
  677. X}
  678. X
  679. X/*
  680. X *----------------------------------------------------------------------
  681. X *
  682. X * Tcl_GetDouble --
  683. X *
  684. X *    Given a string, produce the corresponding double-precision
  685. X *    floating-point value.
  686. X *
  687. X * Results:
  688. X *    The return value is normally TCL_OK;  in this case *doublePtr
  689. X *    will be set to the double-precision value equivalent to string.
  690. X *    If string is improperly formed then TCL_ERROR is returned and
  691. X *    an error message will be left in interp->result.
  692. X *
  693. X * Side effects:
  694. X *    None.
  695. X *
  696. X *----------------------------------------------------------------------
  697. X */
  698. X
  699. Xint
  700. XTcl_GetDouble(interp, string, doublePtr)
  701. X    Tcl_Interp *interp;        /* Interpreter to use for error reporting. */
  702. X    char *string;        /* String containing a floating-point number
  703. X                 * in a form acceptable to strtod. */
  704. X    double *doublePtr;        /* Place to store converted result. */
  705. X{
  706. X    char *end;
  707. X    double d;
  708. X
  709. X    d = strtod(string, &end);
  710. X    while ((*end != '\0') && isspace(*end)) {
  711. X    end++;
  712. X    }
  713. X    if ((end == string) || (*end != 0)) {
  714. X    Tcl_AppendResult(interp, "expected floating-point number but got \"",
  715. X        string, "\"", (char *) NULL);
  716. X    return TCL_ERROR;
  717. X    }
  718. X    *doublePtr = d;
  719. X    return TCL_OK;
  720. X}
  721. X
  722. X/*
  723. X *----------------------------------------------------------------------
  724. X *
  725. X * Tcl_GetBoolean --
  726. X *
  727. X *    Given a string, return a 0/1 boolean value corresponding
  728. X *    to the string.
  729. X *
  730. X * Results:
  731. X *    The return value is normally TCL_OK;  in this case *boolPtr
  732. X *    will be set to the 0/1 value equivalent to string.  If
  733. X *    string is improperly formed then TCL_ERROR is returned and
  734. X *    an error message will be left in interp->result.
  735. X *
  736. X * Side effects:
  737. X *    None.
  738. X *
  739. X *----------------------------------------------------------------------
  740. X */
  741. X
  742. Xint
  743. XTcl_GetBoolean(interp, string, boolPtr)
  744. X    Tcl_Interp *interp;        /* Interpreter to use for error reporting. */
  745. X    char *string;        /* String containing a boolean number
  746. X                 * specified either as 1/0 or true/false or
  747. X                 * yes/no. */
  748. X    int *boolPtr;        /* Place to store converted result, which
  749. X                 * will be 0 or 1. */
  750. X{
  751. X    char c;
  752. X    char lowerCase[10];
  753. X    int i, length;
  754. X
  755. X    /*
  756. X     * Convert the input string to all lower-case.
  757. X     */
  758. X
  759. X    for (i = 0; i < 9; i++) {
  760. X    c = string[i];
  761. X    if (c == 0) {
  762. X        break;
  763. X    }
  764. X    if ((c >= 'A') && (c <= 'Z')) {
  765. X        c += 'a' - 'A';
  766. X    }
  767. X    lowerCase[i] = c;
  768. X    }
  769. X    lowerCase[i] = 0;
  770. X
  771. X    length = strlen(lowerCase);
  772. X    c = lowerCase[0];
  773. X    if ((c == '0') && (lowerCase[1] == '\0')) {
  774. X    *boolPtr = 0;
  775. X    } else if ((c == '1') && (lowerCase[1] == '\0')) {
  776. X    *boolPtr = 1;
  777. X    } else if ((c == 'y') && (strncmp(lowerCase, "yes", length) == 0)) {
  778. X    *boolPtr = 1;
  779. X    } else if ((c == 'n') && (strncmp(lowerCase, "no", length) == 0)) {
  780. X    *boolPtr = 0;
  781. X    } else if ((c == 't') && (strncmp(lowerCase, "true", length) == 0)) {
  782. X    *boolPtr = 1;
  783. X    } else if ((c == 'f') && (strncmp(lowerCase, "false", length) == 0)) {
  784. X    *boolPtr = 0;
  785. X    } else {
  786. X    Tcl_AppendResult(interp, "expected boolean value but got \"",
  787. X        string, "\"", (char *) NULL);
  788. X    return TCL_ERROR;
  789. X    }
  790. X    return TCL_OK;
  791. X}
  792. END_OF_FILE
  793. if test 5017 -ne `wc -c <'tcl6.1/tclGet.c'`; then
  794.     echo shar: \"'tcl6.1/tclGet.c'\" unpacked with wrong size!
  795. fi
  796. # end of 'tcl6.1/tclGet.c'
  797. fi
  798. if test -f 'tcl6.1/tclHash.h' -a "${1}" != "-c" ; then 
  799.   echo shar: Will not clobber existing file \"'tcl6.1/tclHash.h'\"
  800. else
  801. echo shar: Extracting \"'tcl6.1/tclHash.h'\" \(4968 characters\)
  802. sed "s/^X//" >'tcl6.1/tclHash.h' <<'END_OF_FILE'
  803. X/*
  804. X * tclHash.h --
  805. X *
  806. X *    This header file declares the facilities provided by the
  807. X *    Tcl hash table procedures.
  808. X *
  809. X * Copyright 1991 Regents of the University of California
  810. X * Permission to use, copy, modify, and distribute this
  811. X * software and its documentation for any purpose and without
  812. X * fee is hereby granted, provided that the above copyright
  813. X * notice appear in all copies.  The University of California
  814. X * makes no representations about the suitability of this
  815. X * software for any purpose.  It is provided "as is" without
  816. X * express or implied warranty.
  817. X *
  818. X * $Header: /sprite/src/lib/tcl/RCS/tclHash.h,v 1.3 91/08/27 11:36:04 ouster Exp $ SPRITE (Berkeley)
  819. X */
  820. X
  821. X#ifndef _TCLHASH
  822. X#define _TCLHASH
  823. X
  824. X#ifndef _TCL
  825. X#include <tcl.h>
  826. X#endif
  827. X
  828. X/*
  829. X * Structure definition for an entry in a hash table.  No-one outside
  830. X * Tcl should access any of these fields directly;  use the macros
  831. X * defined below.
  832. X */
  833. X
  834. Xtypedef struct Tcl_HashEntry {
  835. X    struct Tcl_HashEntry *nextPtr;    /* Pointer to next entry in this
  836. X                     * hash bucket, or NULL for end of
  837. X                     * chain. */
  838. X    struct Tcl_HashTable *tablePtr;    /* Pointer to table containing entry. */
  839. X    struct Tcl_HashEntry **bucketPtr;    /* Pointer to bucket that points to
  840. X                     * first entry in this entry's chain:
  841. X                     * used for deleting the entry. */
  842. X    ClientData clientData;        /* Application stores something here
  843. X                     * with Tcl_SetHashValue. */
  844. X    union {                /* Key has one of these forms: */
  845. X    char *oneWordValue;        /* One-word value for key. */
  846. X    int words[1];            /* Multiple integer words for key.
  847. X                     * The actual size will be as large
  848. X                     * as necessary for this table's
  849. X                     * keys. */
  850. X    char string[4];            /* String for key.  The actual size
  851. X                     * will be as large as needed to hold
  852. X                     * the key. */
  853. X    } key;                /* MUST BE LAST FIELD IN RECORD!! */
  854. X} Tcl_HashEntry;
  855. X
  856. X/*
  857. X * Structure definition for a hash table.  Must be in tcl.h so clients
  858. X * can allocate space for these structures, but clients should never
  859. X * access any fields in this structure.
  860. X */
  861. X
  862. X#define TCL_SMALL_HASH_TABLE 4
  863. Xtypedef struct Tcl_HashTable {
  864. X    Tcl_HashEntry **buckets;        /* Pointer to bucket array.  Each
  865. X                     * element points to first entry in
  866. X                     * bucket's hash chain, or NULL. */
  867. X    Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
  868. X                    /* Bucket array used for small tables
  869. X                     * (to avoid mallocs and frees). */
  870. X    int numBuckets;            /* Total number of buckets allocated
  871. X                     * at **bucketPtr. */
  872. X    int numEntries;            /* Total number of entries present
  873. X                     * in table. */
  874. X    int rebuildSize;            /* Enlarge table when numEntries gets
  875. X                     * to be this large. */
  876. X    int downShift;            /* Shift count used in hashing
  877. X                     * function.  Designed to use high-
  878. X                     * order bits of randomized keys. */
  879. X    int mask;                /* Mask value used in hashing
  880. X                     * function. */
  881. X    int keyType;            /* Type of keys used in this table. 
  882. X                     * It's either TCL_STRING_KEYS,
  883. X                     * TCL_ONE_WORD_KEYS, or an integer
  884. X                     * giving the number of ints in a
  885. X                     */
  886. X    Tcl_HashEntry *(*findProc) _ANSI_ARGS_((struct Tcl_HashTable *tablePtr,
  887. X        char *key));
  888. X    Tcl_HashEntry *(*createProc) _ANSI_ARGS_((struct Tcl_HashTable *tablePtr,
  889. X        char *key, int *newPtr));
  890. X} Tcl_HashTable;
  891. X
  892. X/*
  893. X * Structure definition for information used to keep track of searches
  894. X * through hash tables:
  895. X */
  896. X
  897. Xtypedef struct Tcl_HashSearch {
  898. X    Tcl_HashTable *tablePtr;        /* Table being searched. */
  899. X    int nextIndex;            /* Index of next bucket to be
  900. X                     * enumerated after present one. */
  901. X    Tcl_HashEntry *nextEntryPtr;    /* Next entry to be enumerated in the
  902. X                     * the current bucket. */
  903. X} Tcl_HashSearch;
  904. X
  905. X/*
  906. X * Acceptable key types for hash tables:
  907. X */
  908. X
  909. X#define TCL_STRING_KEYS        0
  910. X#define TCL_ONE_WORD_KEYS    1
  911. X
  912. X/*
  913. X * Macros for clients to use to access fields of hash entries:
  914. X */
  915. X
  916. X#define Tcl_GetHashValue(h) ((h)->clientData)
  917. X#define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value))
  918. X#define Tcl_GetHashKey(tablePtr, h) \
  919. X    ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) ? (h)->key.oneWordValue \
  920. X                        : (h)->key.string))
  921. X
  922. X/*
  923. X * Macros to use for clients to use to invoke find and create procedures
  924. X * for hash tables:
  925. X */
  926. X
  927. X#define Tcl_FindHashEntry(tablePtr, key) \
  928. X    (*((tablePtr)->findProc))(tablePtr, key)
  929. X#define Tcl_CreateHashEntry(tablePtr, key, newPtr) \
  930. X    (*((tablePtr)->createProc))(tablePtr, key, newPtr)
  931. X
  932. X/*
  933. X * Exported procedures:
  934. X */
  935. X
  936. Xextern void        Tcl_DeleteHashEntry _ANSI_ARGS_((
  937. X                Tcl_HashEntry *entryPtr));
  938. Xextern void        Tcl_DeleteHashTable _ANSI_ARGS_((
  939. X                Tcl_HashTable *tablePtr));
  940. Xextern Tcl_HashEntry *    Tcl_FirstHashEntry _ANSI_ARGS_((
  941. X                Tcl_HashTable *tablePtr,
  942. X                Tcl_HashSearch *searchPtr));
  943. Xextern char *        Tcl_HashStats _ANSI_ARGS_((Tcl_HashTable *tablePtr));
  944. Xextern void        Tcl_InitHashTable _ANSI_ARGS_((Tcl_HashTable *tablePtr,
  945. X                int keyType));
  946. Xextern Tcl_HashEntry *    Tcl_NextHashEntry _ANSI_ARGS_((
  947. X                Tcl_HashSearch *searchPtr));
  948. X
  949. X#endif /* _TCLHASH */
  950. END_OF_FILE
  951. if test 4968 -ne `wc -c <'tcl6.1/tclHash.h'`; then
  952.     echo shar: \"'tcl6.1/tclHash.h'\" unpacked with wrong size!
  953. fi
  954. # end of 'tcl6.1/tclHash.h'
  955. fi
  956. if test -f 'tcl6.1/tests/README' -a "${1}" != "-c" ; then 
  957.   echo shar: Will not clobber existing file \"'tcl6.1/tests/README'\"
  958. else
  959. echo shar: Extracting \"'tcl6.1/tests/README'\" \(3434 characters\)
  960. sed "s/^X//" >'tcl6.1/tests/README' <<'END_OF_FILE'
  961. XTcl Test Suite
  962. X--------------
  963. X
  964. XThis directory contains a set of validation tests for the Tcl
  965. Xcommands.  Each of the files whose name ends in ".test" is
  966. Xintended to fully exercise one or a few Tcl commands.  The
  967. Xcommands tested by a given file are listed in the first line
  968. Xof the file.
  969. X
  970. XThe simplest way to run a test is to start up tclTest in this
  971. Xdirectory and "source" the test file (for example, type "source
  972. Xparse.test").  To run all of the tests, type "source all".  If
  973. Xall goes well then no output will appear.  If there are errors
  974. Xthen messages will appear in the format described below.
  975. X
  976. XThe rest of this file provides additional information on the
  977. Xfeatures of the testing environment.
  978. X
  979. XThis approach to testing was designed and initially implemented
  980. Xby Mary Ann May-Pumphrey of Sun Microsystems.  Many thanks to
  981. Xher for donating her work back to the public Tcl release.
  982. X
  983. XDefinitions file:
  984. X-----------------
  985. X
  986. XThe file "defs" defines a collection of procedures and variables
  987. Xused to run the tests.  It is read in automatically by each of the
  988. X.test files if needed, but once it has been read once it will not
  989. Xbe read again by the .test files.  If you change defs while running
  990. Xtests you'll have to "source" it by hand to load its new contents.
  991. X
  992. XTest output:
  993. X------------
  994. X
  995. XNormally, output only appears when there are errors.  However, if
  996. Xthe variable VERBOSE is set to 1 then tests will be run in "verbose"
  997. Xmode and output will be generated for each test regardless of
  998. Xwhether it succeeded or failed.  Test output consists of the
  999. Xfollowing information:
  1000. X
  1001. X    - the test identifier (which can be used to locate the test code
  1002. X        in the .test file)
  1003. X    - a brief description of the test
  1004. X    - the contents of the test code
  1005. X    - the actual results produced by the tests
  1006. X    - a "PASSED" or "FAILED" message
  1007. X    - the expected results (if the test failed)
  1008. X
  1009. XYou can set VERBOSE either interactively (after the defs file has been
  1010. Xread in), or you can change the default value in "defs".
  1011. X
  1012. XSelecting tests for execution:
  1013. X------------------------------
  1014. X
  1015. XNormally, all the tests in a file are run whenever the file is
  1016. X"source"d.  However, you can select a specific set of tests using
  1017. Xthe global variable TESTS.  This variable contains a pattern;  any
  1018. Xtest whose identifier matches TESTS will be run.  For example,
  1019. Xthe following interactive command causes all of the "for" tests in
  1020. Xgroups 2 and 4 to be executed:
  1021. X
  1022. X    set TESTS {for-[24]*}
  1023. X
  1024. XTESTS defaults to *, but you can change the default in "defs" if
  1025. Xyou wish.
  1026. X
  1027. XSaving keystrokes:
  1028. X------------------
  1029. X
  1030. XA convenience procedure named "dotests" is included in file
  1031. X"defs".  It takes two arguments--the name of the test file (such
  1032. Xas "parse.test"), and a pattern selecting the tests you want to
  1033. Xexecute.  It sets TESTS to the second argument, calls "source" on
  1034. Xthe file specified in the first argument, and restores TESTS to
  1035. Xits pre-call value at the end.
  1036. X
  1037. XBatch vs. interactive execution:
  1038. X--------------------------------
  1039. X
  1040. XThe tests can be run in either batch or interactive mode.  Batch
  1041. Xmode refers to using I/O redirection from a UNIX shell.  For example,
  1042. Xthe following command causes the tests in the file named "parse.test"
  1043. Xto be executed:
  1044. X
  1045. X    tclTest < parse.test > parse.test.results
  1046. X
  1047. XUsers who want to execute the tests in this fashion need to first
  1048. Xensure that the file "defs" has proper values for the global
  1049. Xvariables that control the testing environment (VERBOSE and TESTS).
  1050. END_OF_FILE
  1051. if test 3434 -ne `wc -c <'tcl6.1/tests/README'`; then
  1052.     echo shar: \"'tcl6.1/tests/README'\" unpacked with wrong size!
  1053. fi
  1054. # end of 'tcl6.1/tests/README'
  1055. fi
  1056. if test -f 'tcl6.1/tests/error.test' -a "${1}" != "-c" ; then 
  1057.   echo shar: Will not clobber existing file \"'tcl6.1/tests/error.test'\"
  1058. else
  1059. echo shar: Extracting \"'tcl6.1/tests/error.test'\" \(5000 characters\)
  1060. sed "s/^X//" >'tcl6.1/tests/error.test' <<'END_OF_FILE'
  1061. X# Commands covered:  error, catch
  1062. X#
  1063. X# This file contains a collection of tests for one or more of the Tcl
  1064. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  1065. X# generates output for errors.  No output means no errors were found.
  1066. X#
  1067. X# Copyright 1991 Regents of the University of California
  1068. X# Permission to use, copy, modify, and distribute this
  1069. X# software and its documentation for any purpose and without
  1070. X# fee is hereby granted, provided that this copyright notice
  1071. X# appears in all copies.  The University of California makes no
  1072. X# representations about the suitability of this software for any
  1073. X# purpose.  It is provided "as is" without express or implied
  1074. X# warranty.
  1075. X#
  1076. X# $Header: /sprite/src/lib/tcl/tests/RCS/error.test,v 1.11 91/08/20 14:18:52 ouster Exp $ (Berkeley)
  1077. X
  1078. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1079. X
  1080. Xproc foo {} {
  1081. X    global errorInfo
  1082. X    set a [catch {format [error glorp2]} b]
  1083. X    error {Human-generated}
  1084. X}
  1085. X
  1086. Xproc foo2 {} {
  1087. X    global errorInfo
  1088. X    set a [catch {format [error glorp2]} b]
  1089. X    error {Human-generated} $errorInfo
  1090. X}
  1091. X
  1092. X# Catch errors occurring in commands and errors from "error" command
  1093. X
  1094. Xtest error-1.1 {simple errors from commands} {
  1095. X    catch {format [string compare]} b
  1096. X} 1
  1097. X
  1098. Xtest error-1.2 {simple errors from commands} {
  1099. X    catch {format [string compare]} b
  1100. X    set b
  1101. X} {wrong # args: should be "string compare string1 string2"}
  1102. X
  1103. Xtest error-1.3 {simple errors from commands} {
  1104. X    catch {format [string compare]} b
  1105. X    set errorInfo
  1106. X} {wrong # args: should be "string compare string1 string2"
  1107. X    while executing
  1108. X"string compare"
  1109. X    invoked from within
  1110. X"format [string compare]..."}
  1111. X
  1112. Xtest error-1.4 {simple errors from commands} {
  1113. X    catch {error glorp} b
  1114. X} 1
  1115. X
  1116. Xtest error-1.5 {simple errors from commands} {
  1117. X    catch {error glorp} b
  1118. X    set b
  1119. X} glorp
  1120. X
  1121. Xtest error-1.6 {simple errors from commands} {
  1122. X    catch {catch a b c} b
  1123. X} 1
  1124. X
  1125. Xtest error-1.7 {simple errors from commands} {
  1126. X    catch {catch a b c} b
  1127. X    set b
  1128. X} {wrong # args: should be "catch command ?varName?"}
  1129. X
  1130. Xtest error-2.1 {simple errors from commands} {
  1131. X    catch catch
  1132. X} 1
  1133. X
  1134. X# Check errors nested in procedures.  Also check the optional argument
  1135. X# to "error" to generate a new error trace.
  1136. X
  1137. Xtest error-2.1 {errors in nested procedures} {
  1138. X    catch foo b
  1139. X} 1
  1140. X
  1141. Xtest error-2.2 {errors in nested procedures} {
  1142. X    catch foo b
  1143. X    set b
  1144. X} {Human-generated}
  1145. X
  1146. Xtest error-2.3 {errors in nested procedures} {
  1147. X    catch foo b
  1148. X    set errorInfo
  1149. X} {Human-generated
  1150. X    while executing
  1151. X"error {Human-generated}"
  1152. X    (procedure "foo" line 4)
  1153. X    invoked from within
  1154. X"foo"}
  1155. X
  1156. Xtest error-2.4 {errors in nested procedures} {
  1157. X    catch foo2 b
  1158. X} 1
  1159. X
  1160. Xtest error-2.5 {errors in nested procedures} {
  1161. X    catch foo2 b
  1162. X    set b
  1163. X} {Human-generated}
  1164. X
  1165. Xtest error-2.6 {errors in nested procedures} {
  1166. X    catch foo2 b
  1167. X    set errorInfo
  1168. X} {glorp2
  1169. X    while executing
  1170. X"error glorp2"
  1171. X    invoked from within
  1172. X"format [error glorp2]..."
  1173. X    (procedure "foo2" line 1)
  1174. X    invoked from within
  1175. X"foo2"}
  1176. X
  1177. X# Error conditions related to "catch".
  1178. X
  1179. Xtest error-3.1 {errors in catch command} {
  1180. X    list [catch {catch} msg] $msg
  1181. X} {1 {wrong # args: should be "catch command ?varName?"}}
  1182. Xtest error-3.2 {errors in catch command} {
  1183. X    list [catch {catch a b c} msg] $msg
  1184. X} {1 {wrong # args: should be "catch command ?varName?"}}
  1185. Xtest error-3.3 {errors in catch command} {
  1186. X    catch {unset a}
  1187. X    set a(0) 22
  1188. X    list [catch {catch {format 44} a} msg] $msg
  1189. X} {1 {couldn't save command result in variable}}
  1190. Xcatch {unset a}
  1191. X
  1192. X# More tests related to errorInfo and errorCode
  1193. X
  1194. Xtest error-4.1 {errorInfo and errorCode variables} {
  1195. X    list [catch {error msg1 msg2 msg3} msg] $msg $errorInfo $errorCode
  1196. X} {1 msg1 msg2 msg3}
  1197. Xtest error-4.2 {errorInfo and errorCode variables} {
  1198. X    list [catch {error msg1 {} msg3} msg] $msg $errorInfo $errorCode
  1199. X} {1 msg1 {msg1
  1200. X    while executing
  1201. X"error msg1 {} msg3"} msg3}
  1202. Xtest error-4.3 {errorInfo and errorCode variables} {
  1203. X    list [catch {error msg1 {}} msg] $msg $errorInfo $errorCode
  1204. X} {1 msg1 {msg1
  1205. X    while executing
  1206. X"error msg1 {}"} NONE}
  1207. Xtest error-4.4 {errorInfo and errorCode variables} {
  1208. X    set errorCode bogus
  1209. X    list [catch {error msg1} msg] $msg $errorInfo $errorCode
  1210. X} {1 msg1 {msg1
  1211. X    while executing
  1212. X"error msg1"} NONE}
  1213. Xtest error-4.5 {errorInfo and errorCode variables} {
  1214. X    set errorCode bogus
  1215. X    list [catch {error msg1 msg2 {}} msg] $msg $errorInfo $errorCode
  1216. X} {1 msg1 msg2 {}}
  1217. X
  1218. X# Errors in error command itself
  1219. X
  1220. Xtest error-5.1 {errors in error command} {
  1221. X    list [catch {error} msg] $msg
  1222. X} {1 {wrong # args: should be "error message ?errorInfo? ?errorCode?"}}
  1223. Xtest error-5.2 {errors in error command} {
  1224. X    list [catch {error a b c d} msg] $msg
  1225. X} {1 {wrong # args: should be "error message ?errorInfo? ?errorCode?"}}
  1226. X
  1227. X# Make sure that catch resets error information
  1228. X
  1229. Xtest error-6.1 {catch must reset error state} {
  1230. X    catch {error outer [catch {error inner inner.errorInfo inner.errorCode}]}
  1231. X    list $errorCode $errorInfo
  1232. X} {NONE 1}
  1233. X
  1234. Xreturn ""
  1235. END_OF_FILE
  1236. if test 5000 -ne `wc -c <'tcl6.1/tests/error.test'`; then
  1237.     echo shar: \"'tcl6.1/tests/error.test'\" unpacked with wrong size!
  1238. fi
  1239. # end of 'tcl6.1/tests/error.test'
  1240. fi
  1241. if test -f 'tcl6.1/tests/for.test' -a "${1}" != "-c" ; then 
  1242.   echo shar: Will not clobber existing file \"'tcl6.1/tests/for.test'\"
  1243. else
  1244. echo shar: Extracting \"'tcl6.1/tests/for.test'\" \(4309 characters\)
  1245. sed "s/^X//" >'tcl6.1/tests/for.test' <<'END_OF_FILE'
  1246. X# Commands covered:  foreach, for, continue, break
  1247. X#
  1248. X# This file contains a collection of tests for one or more of the Tcl
  1249. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  1250. X# generates output for errors.  No output means no errors were found.
  1251. X#
  1252. X# Copyright 1991 Regents of the University of California
  1253. X# Permission to use, copy, modify, and distribute this
  1254. X# software and its documentation for any purpose and without
  1255. X# fee is hereby granted, provided that this copyright notice
  1256. X# appears in all copies.  The University of California makes no
  1257. X# representations about the suitability of this software for any
  1258. X# purpose.  It is provided "as is" without express or implied
  1259. X# warranty.
  1260. X#
  1261. X# $Header: /sprite/src/lib/tcl/tests/RCS/for.test,v 1.7 91/07/23 21:01:05 ouster Exp $ (Berkeley)
  1262. X
  1263. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1264. X
  1265. X# Basic "foreach" operation.
  1266. X
  1267. Xtest for-1.1 {basic foreach tests} {
  1268. X    set a {}
  1269. X    foreach i {a b c d} {
  1270. X    set a [concat $a $i]
  1271. X    }
  1272. X    set a
  1273. X} {a b c d}
  1274. Xtest for-1.2 {basic foreach tests} {
  1275. X    set a {}
  1276. X    foreach i {a b {{c d} e} {123 {{x}}}} {
  1277. X    set a [concat $a $i]
  1278. X    }
  1279. X    set a
  1280. X} {a b {c d} e 123 {{x}}}
  1281. Xtest for-1.3 {basic foreach tests} {catch {foreach} msg} 1
  1282. Xtest for-1.4 {basic foreach tests} {
  1283. X    catch {foreach} msg
  1284. X    set msg
  1285. X} {wrong # args: should be "foreach varName list command"}
  1286. Xtest for-1.5 {basic foreach tests} {catch {foreach i} msg} 1
  1287. Xtest for-1.6 {basic foreach tests} {
  1288. X    catch {foreach i} msg
  1289. X    set msg
  1290. X} {wrong # args: should be "foreach varName list command"}
  1291. Xtest for-1.7 {basic foreach tests} {catch {foreach i j} msg} 1
  1292. Xtest for-1.8 {basic foreach tests} {
  1293. X    catch {foreach i j} msg
  1294. X    set msg
  1295. X} {wrong # args: should be "foreach varName list command"}
  1296. Xtest for-1.9 {basic foreach tests} {catch {foreach i j k l} msg} 1
  1297. Xtest for-1.10 {basic foreach tests} {
  1298. X    catch {foreach i j k l} msg
  1299. X    set msg
  1300. X} {wrong # args: should be "foreach varName list command"}
  1301. Xtest for-1.11 {basic foreach tests} {
  1302. X    set a {}
  1303. X    foreach i {} {
  1304. X    set a [concat $a $i]
  1305. X    }
  1306. X    set a
  1307. X} {}
  1308. Xtest for-1.11 {foreach errors} {
  1309. X    catch {unset a}
  1310. X    set a(0) 44
  1311. X    list [catch {foreach a {1 2 3} {}} msg] $msg
  1312. X} {1 {couldn't set loop variable}}
  1313. Xcatch {unset a}
  1314. X
  1315. X# Check "continue".
  1316. X
  1317. Xtest for-2.1 {continue tests} {catch continue} 4
  1318. Xtest for-2.2 {continue tests} {
  1319. X    set a {}
  1320. X    foreach i {a b c d} {
  1321. X    if {[string compare $i "b"] == 0} continue
  1322. X    set a [concat $a $i]
  1323. X    }
  1324. X    set a
  1325. X} {a c d}
  1326. Xtest for-2.3 {continue tests} {
  1327. X    set a {}
  1328. X    foreach i {a b c d} {
  1329. X    if {[string compare $i "b"] != 0} continue
  1330. X    set a [concat $a $i]
  1331. X    }
  1332. X    set a
  1333. X} {b}
  1334. Xtest for-2.4 {continue tests} {catch {continue foo} msg} 1
  1335. Xtest for-2.5 {continue tests} {
  1336. X    catch {continue foo} msg
  1337. X    set msg
  1338. X} {wrong # args: should be "continue"}
  1339. X
  1340. X# Check "break".
  1341. X
  1342. Xtest for-3.1 {break tests} {catch break} 3
  1343. Xtest for-3.2 {break tests} {
  1344. X    set a {}
  1345. X    foreach i {a b c d} {
  1346. X    if {[string compare $i "c"] == 0} break
  1347. X    set a [concat $a $i]
  1348. X    }
  1349. X    set a
  1350. X} {a b}
  1351. Xtest for-3.3 {break tests} {catch {break foo} msg} 1
  1352. Xtest for-3.4 {break tests} {
  1353. X    catch {break foo} msg
  1354. X    set msg
  1355. X} {wrong # args: should be "break"}
  1356. X
  1357. X# Check "for" and its use of continue and break.
  1358. X
  1359. Xtest for-4.1 {for tests} {
  1360. X    set a {}
  1361. X    for {set i 1} {$i<6} {set i [expr $i+1]} {
  1362. X    set a [concat $a $i]
  1363. X    }
  1364. X    set a
  1365. X} {1 2 3 4 5}
  1366. Xtest for-4.2 {for tests} {
  1367. X    set a {}
  1368. X    for {set i 1} {$i<6} {set i [expr $i+1]} {
  1369. X    if $i==4 continue
  1370. X    set a [concat $a $i]
  1371. X    }
  1372. X    set a
  1373. X} {1 2 3 5}
  1374. Xtest for-4.3 {for tests} {
  1375. X    set a {}
  1376. X    for {set i 1} {$i<6} {set i [expr $i+1]} {
  1377. X    if $i==4 break
  1378. X    set a [concat $a $i]
  1379. X    }
  1380. X    set a
  1381. X} {1 2 3}
  1382. Xtest for-4.4 {for tests} {catch {for 1 2 3} msg} 1
  1383. Xtest for-4.5 {for tests} {
  1384. X    catch {for 1 2 3} msg
  1385. X    set msg
  1386. X} {wrong # args: should be "for start test next command"}
  1387. Xtest for-4.6 {for tests} {catch {for 1 2 3 4 5} msg} 1
  1388. Xtest for-4.7 {for tests} {
  1389. X    catch {for 1 2 3 4 5} msg
  1390. X    set msg
  1391. X} {wrong # args: should be "for start test next command"}
  1392. Xtest for-4.8 {for tests} {
  1393. X    set a {xyz}
  1394. X    for {set i 1} {$i<6} {set i [expr $i+1]} {}
  1395. X    set a
  1396. X} xyz
  1397. Xtest for-4.9 {for tests} {
  1398. X    set a {}
  1399. X    for {set i 1} {$i<6} {set i [expr $i+1]; if $i==4 break} {
  1400. X    set a [concat $a $i]
  1401. X    }
  1402. X    set a
  1403. X} {1 2 3}
  1404. END_OF_FILE
  1405. if test 4309 -ne `wc -c <'tcl6.1/tests/for.test'`; then
  1406.     echo shar: \"'tcl6.1/tests/for.test'\" unpacked with wrong size!
  1407. fi
  1408. # end of 'tcl6.1/tests/for.test'
  1409. fi
  1410. if test -f 'tcl6.1/tests/glob.test' -a "${1}" != "-c" ; then 
  1411.   echo shar: Will not clobber existing file \"'tcl6.1/tests/glob.test'\"
  1412. else
  1413. echo shar: Extracting \"'tcl6.1/tests/glob.test'\" \(4230 characters\)
  1414. sed "s/^X//" >'tcl6.1/tests/glob.test' <<'END_OF_FILE'
  1415. X# Commands covered:  glob
  1416. X#
  1417. X# This file contains a collection of tests for one or more of the Tcl
  1418. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  1419. X# generates output for errors.  No output means no errors were found.
  1420. X#
  1421. X# Copyright 1991 Regents of the University of California
  1422. X# Permission to use, copy, modify, and distribute this
  1423. X# software and its documentation for any purpose and without
  1424. X# fee is hereby granted, provided that this copyright notice
  1425. X# appears in all copies.  The University of California makes no
  1426. X# representations about the suitability of this software for any
  1427. X# purpose.  It is provided "as is" without express or implied
  1428. X# warranty.
  1429. X#
  1430. X# $Header: /user6/ouster/tcl/tests/RCS/glob.test,v 1.15 91/10/17 16:22:32 ouster Exp $ (Berkeley)
  1431. X
  1432. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1433. X
  1434. X# First, create some subdirectories to use for testing.
  1435. X
  1436. Xexec rm -rf globTest
  1437. Xexec mkdir globTest globTest/a1 globTest/a2 globTest/a3
  1438. Xexec mkdir globTest/a1/b1 globTest/a1/b2 globTest/a2/b3
  1439. Xexec cat << abc > globTest/x1.c
  1440. Xexec cat << abc > globTest/y1.c
  1441. Xexec cat << abc > globTest/z1.c
  1442. Xexec cat << abc > "globTest/weird name.c"
  1443. Xexec cat << abc > globTest/.1
  1444. Xexec cat << abc > globTest/a1/b1/x2.c
  1445. Xexec cat << abc > globTest/a1/b2/y2.c
  1446. X
  1447. Xtest glob-1.1 {simple globbing} {glob a} a
  1448. Xtest glob-1.2 {simple globbing} {glob aaa bbb ccc} {aaa bbb ccc}
  1449. X
  1450. Xtest glob-2.1 {globbing with braces} {glob "{a1,a2}"} "a1 a2"
  1451. Xtest glob-2.2 {globbing with braces} {glob a/{x,y}{123,456}/z} \
  1452. X    "a/x123/z a/x456/z a/y123/z a/y456/z"
  1453. X
  1454. Xtest glob-3.1 {asterisks and question marks} {glob g*/*.c} \
  1455. X    "globTest/x1.c globTest/y1.c globTest/z1.c {globTest/weird name.c}"
  1456. Xtest glob-3.2 {asterisks and question marks} {glob globTest/?1.c} \
  1457. X    "globTest/x1.c globTest/y1.c globTest/z1.c"
  1458. Xtest glob-3.3 {asterisks and question marks} {glob */*/*/*.c} \
  1459. X    "globTest/a1/b1/x2.c globTest/a1/b2/y2.c"
  1460. Xtest glob-3.4 {asterisks and question marks} {glob globTest/*} \
  1461. X    "globTest/a1 globTest/a2 globTest/a3 globTest/x1.c globTest/y1.c globTest/z1.c {globTest/weird name.c}"
  1462. Xtest glob-3.5 {asterisks and question marks} {glob globTest/.*} \
  1463. X    "globTest/. globTest/.. globTest/.1"
  1464. Xtest glob-3.6 {asterisks and question marks} {glob globTest/*/*} \
  1465. X    "globTest/a1/b1 globTest/a1/b2 globTest/a2/b3"
  1466. Xtest glob-3.7 {asterisks and question marks} {glob {globTest/[xy]1.*}} \
  1467. X    "globTest/x1.c globTest/y1.c"
  1468. X
  1469. X# The tests immediately below can only be run at Berkeley, where
  1470. X# the file-system structure is well-known.
  1471. X
  1472. Xif {[string compare [glob ~] /users/ouster] == 0} {
  1473. X    test glob-4.1 {tildes} {glob ~/.csh*} "/users/ouster/.cshrc"
  1474. X    test glob-4.2 {tildes} {glob ~/.csh*} "/users/ouster/.cshrc"
  1475. X} 
  1476. X
  1477. Xtest glob-5.1 {error conditions} {
  1478. X    list [catch {glob} msg] $msg
  1479. X} {1 {wrong # args: should be "glob ?-nocomplain? name ?name ...?"}}
  1480. Xtest glob-5.2 {error conditions} {
  1481. X    list [catch {glob a/{b,c,d}/\{} msg] $msg
  1482. X} {1 {unmatched open-brace in file name}}
  1483. Xtest glob-5.3 {error conditions} {
  1484. X    list [catch {glob goo/*} msg] $msg
  1485. X} {1 {no files matched glob pattern(s)}}
  1486. Xtest glob-5.4 {error conditions} {
  1487. X    list [catch {glob globTest/*.c goo/*} msg] $msg
  1488. X} {0 {globTest/x1.c globTest/y1.c globTest/z1.c {globTest/weird name.c}}}
  1489. Xtest glob-5.5 {error conditions} {
  1490. X    list [catch {glob ~no-one} msg] $msg
  1491. X} {1 {user "no-one" doesn't exist}}
  1492. Xtest glob-5.6 {error conditions} {
  1493. X    set home $env(HOME)
  1494. X    unset env(HOME)
  1495. X    set x [list [catch {glob ~/*} msg] $msg]
  1496. X    set env(HOME) $home
  1497. X    set x
  1498. X} {1 {couldn't find HOME environment variable to expand "~/*"}}
  1499. X
  1500. Xexec chmod 000 globTest
  1501. Xif {$user != "root"} {
  1502. X    test glob-6.1 {setting errorCode variable} {
  1503. X    string tolower [list [catch {glob globTest/*} msg]  $msg $errorCode]
  1504. X    } {1 {couldn't read directory "globtest/": permission denied} {unix eacces {permission denied}}}
  1505. X}
  1506. Xexec chmod 755 globTest
  1507. X
  1508. Xtest glob-7.1 {-nocomplain option} {
  1509. X    list [catch {glob -nocomplai} msg] $msg
  1510. X} {0 -nocomplai}
  1511. Xtest glob-7.2 {-nocomplain option} {
  1512. X    list [catch {glob -nocomplain} msg] $msg
  1513. X} {1 {wrong # args: should be "glob ?-nocomplain? name ?name ...?"}}
  1514. Xtest glob-7.3 {-nocomplain option} {
  1515. X    list [catch {glob -nocomplain goo/*} msg] $msg
  1516. X} {0 {}}
  1517. X
  1518. Xexec rm -rf globTest
  1519. END_OF_FILE
  1520. if test 4230 -ne `wc -c <'tcl6.1/tests/glob.test'`; then
  1521.     echo shar: \"'tcl6.1/tests/glob.test'\" unpacked with wrong size!
  1522. fi
  1523. # end of 'tcl6.1/tests/glob.test'
  1524. fi
  1525. if test -f 'tcl6.1/tests/if.test' -a "${1}" != "-c" ; then 
  1526.   echo shar: Will not clobber existing file \"'tcl6.1/tests/if.test'\"
  1527. else
  1528. echo shar: Extracting \"'tcl6.1/tests/if.test'\" \(4547 characters\)
  1529. sed "s/^X//" >'tcl6.1/tests/if.test' <<'END_OF_FILE'
  1530. X# Commands covered:  if
  1531. X#
  1532. X# This file contains a collection of tests for one or more of the Tcl
  1533. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  1534. X# generates output for errors.  No output means no errors were found.
  1535. X#
  1536. X# Copyright 1991 Regents of the University of California
  1537. X# Permission to use, copy, modify, and distribute this
  1538. X# software and its documentation for any purpose and without
  1539. X# fee is hereby granted, provided that this copyright notice
  1540. X# appears in all copies.  The University of California makes no
  1541. X# representations about the suitability of this software for any
  1542. X# purpose.  It is provided "as is" without express or implied
  1543. X# warranty.
  1544. X#
  1545. X# $Header: /sprite/src/lib/tcl/tests/RCS/if.test,v 1.3 91/08/20 14:19:03 ouster Exp $ (Berkeley)
  1546. X
  1547. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1548. X
  1549. Xtest if-1.1 {taking proper branch} {
  1550. X    set a {}
  1551. X    if 0 {set a 1} else {set a 2}
  1552. X    set a
  1553. X} 2
  1554. Xtest if-1.2 {taking proper branch} {
  1555. X    set a {}
  1556. X    if 1 {set a 1} else {set a 2}
  1557. X    set a
  1558. X} 1
  1559. Xtest if-1.3 {taking proper branch} {
  1560. X    set a {}
  1561. X    if 1<2 {set a 1}
  1562. X    set a
  1563. X} 1
  1564. Xtest if-1.4 {taking proper branch} {
  1565. X    set a {}
  1566. X    if 1>2 {set a 1}
  1567. X    set a
  1568. X} {}
  1569. Xtest if-1.4 {taking proper branch} {
  1570. X    set a {}
  1571. X    if 1>2 {set a 1} else {}
  1572. X    set a
  1573. X} {}
  1574. X
  1575. Xtest if-2.1 {optional then-else args} {
  1576. X    set a 44
  1577. X    if 1==3 then {set a 1} else {set a 2}
  1578. X    set a
  1579. X} 2
  1580. Xtest if-2.2 {optional then-else args} {
  1581. X    set a 44
  1582. X    if 1!=3 then {set a 1} else {set a 2}
  1583. X    set a
  1584. X} 1
  1585. Xtest if-2.3 {optional then-else args} {
  1586. X    set a 44
  1587. X    if 1==3 {set a 1} else {set a 2}
  1588. X    set a
  1589. X} 2
  1590. Xtest if-2.4 {optional then-else args} {
  1591. X    set a 44
  1592. X    if 1!=3 {set a 1} else {set a 2}
  1593. X    set a
  1594. X} 1
  1595. Xtest if-2.5 {optional then-else args} {
  1596. X    set a 44
  1597. X    if 1==3 then {set a 1} {set a 2}
  1598. X    set a
  1599. X} 2
  1600. Xtest if-2.6 {optional then-else args} {
  1601. X    set a 44
  1602. X    if 1!=3 then {set a 1} {set a 2}
  1603. X    set a
  1604. X} 1
  1605. Xtest if-2.7 {optional then-else args} {
  1606. X    set a 44
  1607. X    if 1==3 {set a 1} {set a 2}
  1608. X    set a
  1609. X} 2
  1610. Xtest if-2.8 {optional then-else args} {
  1611. X    set a 44
  1612. X    if 1!=3 {set a 1} {set a 2}
  1613. X    set a
  1614. X} 1
  1615. Xtest if-2.9 {optional then-else args} {
  1616. X    set a 44
  1617. X    if 1==3 t {set a 1} e {set a 2}
  1618. X    set a
  1619. X} 2
  1620. X
  1621. Xtest if-3.1 {error conditions} {
  1622. X    catch {if 2}
  1623. X} 1
  1624. Xtest if-3.2 {error conditions} {
  1625. X    catch {if 2} msg
  1626. X    set msg
  1627. X} {wrong # args: should be "if bool ?then? command ?else? ?command?"}
  1628. Xtest if-3.3 {error conditions} {
  1629. X    catch {if 1 then}
  1630. X} 1
  1631. Xtest if-3.4 {error conditions} {
  1632. X    catch {if 1 then} msg
  1633. X    set msg
  1634. X} {wrong # args: should be "if bool ?then? command ?else? ?command?"}
  1635. Xtest if-3.5 {error conditions} {
  1636. X    catch {if 1 {set a b} else}
  1637. X} 1
  1638. Xtest if-3.6 {error conditions} {
  1639. X    catch {if 1 {set a b} else} msg
  1640. X    set msg
  1641. X} {wrong # args: should be "if bool ?then? command ?else? ?command?"}
  1642. Xtest if-3.7 {error conditions} {
  1643. X    catch {if {[error "error in condition"]} foo}
  1644. X} 1
  1645. Xtest if-3.8 {error conditions} {
  1646. X    catch {if {[error "error in condition"]} foo} msg
  1647. X    set msg
  1648. X} {error in condition}
  1649. Xtest if-3.9 {error conditions} {
  1650. X    catch {if {[error "error in condition"]} foo} msg
  1651. X    set errorInfo
  1652. X} {error in condition
  1653. X    while executing
  1654. X"error "error in condition""
  1655. X    ("if" test line 1)
  1656. X    invoked from within
  1657. X"if {[error "error in condition"]} foo"}
  1658. Xtest if-3.10 {error conditions} {
  1659. X    catch {if 1 then {error "error in then clause"}}
  1660. X} 1
  1661. Xtest if-3.11 {error conditions} {
  1662. X    catch {if 1 then {error "error in then clause"}} msg
  1663. X    set msg
  1664. X} {error in then clause}
  1665. Xtest if-3.12 {error conditions} {
  1666. X    catch {if 1 then {error "error in then clause"}} msg
  1667. X    set errorInfo
  1668. X} {error in then clause
  1669. X    while executing
  1670. X"error "error in then clause""
  1671. X    ("then" clause line 1)
  1672. X    invoked from within
  1673. X"if 1 then {error "error in then clause"}"}
  1674. Xtest if-3.13 {error conditions} {
  1675. X    catch {if 0 {} {error "error in else clause"}}
  1676. X} 1
  1677. Xtest if-3.14 {error conditions} {
  1678. X    catch {if 0 {} {error "error in else clause"}} msg
  1679. X    set msg
  1680. X} {error in else clause}
  1681. Xtest if-3.15 {error conditions} {
  1682. X    catch {if 0 {} {error "error in else clause"}} msg
  1683. X    set errorInfo
  1684. X} {error in else clause
  1685. X    while executing
  1686. X"error "error in else clause""
  1687. X    ("else" clause line 1)
  1688. X    invoked from within
  1689. X"if 0 {} {error "error in else clause"}"}
  1690. X
  1691. Xtest if-4.1 {return value} {
  1692. X    if 1 then {set a 22; format abc}
  1693. X} abc
  1694. Xtest if-4.2 {return value} {
  1695. X    if 0 then {set a 22; format abc} else {format def}
  1696. X} def
  1697. Xtest if-4.3 {return value} {
  1698. X    if 0 then {set a 22; format abc}
  1699. X} {}
  1700. END_OF_FILE
  1701. if test 4547 -ne `wc -c <'tcl6.1/tests/if.test'`; then
  1702.     echo shar: \"'tcl6.1/tests/if.test'\" unpacked with wrong size!
  1703. fi
  1704. # end of 'tcl6.1/tests/if.test'
  1705. fi
  1706. echo shar: End of archive 3 \(of 33\).
  1707. cp /dev/null ark3isdone
  1708. MISSING=""
  1709. 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
  1710.     if test ! -f ark${I}isdone ; then
  1711.     MISSING="${MISSING} ${I}"
  1712.     fi
  1713. done
  1714. if test "${MISSING}" = "" ; then
  1715.     echo You have unpacked all 33 archives.
  1716.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1717. else
  1718.     echo You still need to unpack the following archives:
  1719.     echo "        " ${MISSING}
  1720. fi
  1721. ##  End of shell archive.
  1722. exit 0
  1723.  
  1724. exit 0 # Just in case...
  1725. -- 
  1726. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1727. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1728. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1729. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1730.