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

  1. Newsgroups: comp.sources.misc
  2. From: karl@sugar.neosoft.com (Karl Lehenbauer)
  3. Subject:  v25i076:  tcl - tool command language, version 6.1, Part08/33
  4. Message-ID: <1991Nov14.202831.23669@sparky.imd.sterling.com>
  5. X-Md4-Signature: a92a88a7189035c173b1d62f27300529
  6. Date: Thu, 14 Nov 1991 20:28:31 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
  10. Posting-number: Volume 25, Issue 76
  11. Archive-name: tcl/part08
  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 8 (of 33)."
  21. # Contents:  tcl6.1/README tcl6.1/doc/SetResult.man
  22. #   tcl6.1/doc/SetVar.man tcl6.1/tests/string.test
  23. # Wrapped by karl@one on Tue Nov 12 19:44:17 1991
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'tcl6.1/README' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'tcl6.1/README'\"
  27. else
  28. echo shar: Extracting \"'tcl6.1/README'\" \(10992 characters\)
  29. sed "s/^X//" >'tcl6.1/README' <<'END_OF_FILE'
  30. XTcl
  31. X
  32. Xby John Ousterhout
  33. XUniversity of California at Berkeley
  34. Xouster@sprite.berkeley.edu
  35. X
  36. X1. Introduction
  37. X---------------
  38. X
  39. XThis directory contains the sources and documentation for Tcl, an
  40. Xembeddable tool command language.  The information here corresponds
  41. Xto release 6.1.  The 6.x releases of Tcl are different in many ways
  42. Xfrom releases before 6.0.  See below for general information on potential
  43. Xincompatibilies.  The file "changes" has a complete list of all changes
  44. Xmade to Tcl, with incompatible changes specially marked.  Tcl 6.1 has
  45. Xonly one incompatible change relative to 6.0, concerning the "regexp"
  46. Xcommand.
  47. X
  48. XFor an introduction to the facilities provided by Tcl, see the paper
  49. X``Tcl:  An Embeddable Command Language'', in the Proceedings of the
  50. X1990 Winter USENIX Conference.  A copy of that paper is included here
  51. Xin Postscript form in the file "doc/usenix.ps" and in text form in the
  52. Xfile "doc/usenix.text".  However, the paper corresponds to a much
  53. Xearlier version of Tcl (approximately version 3.0), so some details
  54. Xof the paper may not be correct anymore and there are many new features
  55. Xnot documented in the paper.
  56. X
  57. X2. Documentation
  58. X----------------
  59. X
  60. XThe "doc" subdirectory contains a complete set of manual entries
  61. Xfor Tcl.  The file "doc/Tcl.man" gives an overall description of the
  62. XTcl language and describes the core Tcl commands.  The other ".man"
  63. Xfiles in "doc" describe the library procedures that Tcl provides for
  64. XTcl-based applications.  Read the "Tcl" man page first.  To print any
  65. Xof the man pages, cd to the "doc" directory and invoke your favorite
  66. Xvariant of troff using the normal -man macros, for example
  67. X
  68. X        ditroff -man <file>
  69. X
  70. Xwhere <file> is the name of the man page you'd like to print.
  71. X
  72. X3. Machines supported
  73. X---------------------
  74. X
  75. XIf you follow the directions below, this release should compile
  76. Xand run on the following configurations either "out of the box"
  77. Xor with only trivial changes:
  78. X
  79. X    - Sun-3's, Sun-4's, SPARCstation-1's and SPARCstation-2's running
  80. X      many variants of SunOS, such as 4.1.
  81. X    - DECstation-3100's and DECstation-5000's running many versions of
  82. X      Ultrix, such as 2.0 and 4.2.
  83. X    - DEC VAXes running many versions of Ultrix or BSD UNIX. 
  84. X    - Intel 386 based systems running SCO Unix 3.2v2.
  85. X    - Intel 386 based systems running SCO Xenix 2.3.3.
  86. X    - Intel 386 based systems running Bell-Tech (now Intel) Unix 3.2.0.
  87. X    - Silicon Graphics systems running IRIX 4.0.
  88. X    - Various H-P machines running versions of HP-UX such as 7.05
  89. X
  90. XIf you find problems running Tcl on any of the above configurations,
  91. Xplease let me know.  Also, if you are able to compile Tcl and run the
  92. Xtest suite successfully on configurations not listed above, please
  93. Xlet me know and tell me what changes, if any, you needed to make to
  94. Xdo it.  I'd like to keep the above list up-to-date and continue to
  95. Ximprove the portability of Tcl.
  96. X
  97. X4. Compiling Tcl
  98. X----------------
  99. X
  100. XTo compile Tcl on any of the configurations listed above, or systems
  101. Xsimilar to them, do the following:
  102. X
  103. X    (a) Edit the "set" commands at the beginning of the file "config"
  104. X        if necessary to correspond to your system configuration (they
  105. X    should already be right for most versions of Unix).
  106. X
  107. X    (b) Type "./config" in the top-level directory. "Config" is a script
  108. X        that pokes around in your system to see if certain almost-standard
  109. X    things are missing (header files, library procedures, etc.);
  110. X    if your system doesn't seem to have them, it configures Tcl to
  111. X    use its own copies of these things instead (Tcl's copies are
  112. X    kept in the "compat" subdirectory).  Config prints out messages
  113. X    for all the substitutions it made.  You can ignore any of the
  114. X    messages unless they say "ERROR!!";  in this case something is
  115. X    fundamentally wrong and the config script couldn't handle your
  116. X    system configuration.
  117. X
  118. X    (c) Type "make" to compile the library.  This will create the Tcl
  119. X    library in "libtcl.a".  The Makefile should work without any
  120. X    modifications but you may wish to personalize it, e.g. to
  121. X    turn on compiler optimization.
  122. X
  123. X    (d) If the combination of "config" and "make" doesn't work for you,
  124. X        then I suggest the following approach:
  125. X        - Start again with a fresh copy of the distribution.
  126. X        - Set the #defines that appear at the very front of
  127. X          tclUnix.h (before the first #include) to correspond
  128. X          to your system.
  129. X        - Modify Makefile to set CC, CFLAGS, etc. for your system.
  130. X        - If things don't compile or don't link, then you may need
  131. X          to copy some of the .c or .h files from the "compat"
  132. X          directory into the main Tcl directory to compensate for
  133. X          files missing from your system.  Modify the COMPAT_OBJS
  134. X          definition in Makefile to include a .o name for each of
  135. X          the .c files that you copied up from the compat directory.
  136. X
  137. X    (e) Create a directory /usr/local/lib/tcl and copy all the files
  138. X        from the "library" subdirectory to /usr/local/lib/tcl.  Or,
  139. X    you can use some other directory as library, but you'll need
  140. X    to modify the Makefile to reflect this fact (change the
  141. X    TCL_LIBRARY definition).
  142. X
  143. X    (f) Type "make tclTest", which will create a simple test program that
  144. X    you can use to try out the Tcl facilities.  TclTest is just a
  145. X    main-program sandwich around the Tcl library.  It reads standard
  146. X    input until it reaches the end of a line where parentheses and
  147. X    backslashes are balanced, then sends everything it's read to the
  148. X    Tcl interpreter.  When the Tcl interpreter returns, tclTest prints
  149. X    the return value or error message.  TclTest defines a few other
  150. X    additional commands, most notably:
  151. X    
  152. X            echo arg arg ...
  153. X    
  154. X    The "echo" command prints its arguments on standard output,
  155. X    separated by spaces.
  156. X
  157. X5. Test suite
  158. X-------------
  159. X
  160. XThere is a relatively complete test suite for all of the Tcl core in
  161. Xthe subdirectory "tests".  To use it, run tclTest in this directory
  162. Xand then type the following commands:
  163. X
  164. X    cd tests
  165. X    source all
  166. X
  167. XYou should then see a printout of the test files processed.  If any
  168. Xerrors occur, you'll see a much more substantial printout for each
  169. Xerror.  Tcl should pass the test suite cleanly on all of the systems
  170. Xlisted in Section 3.  See the README file in the "tests" directory
  171. Xfor more information on the test suite.
  172. X
  173. X6. Compiling on non-UNIX systems
  174. X--------------------------------
  175. X
  176. XThe Tcl features that depend on system calls peculiar to UNIX (stat,
  177. Xfork, exec, times, etc.) are now separate from the main body of Tcl,
  178. Xwhich only requires a few generic library procedures such as malloc
  179. Xand strcpy.  Thus it should be relatively easy to compile Tcl for
  180. Xthese machines, although a number of UNIX-specific commands will
  181. Xbe absent (e.g.  exec, time, and glob).  See the comments at the
  182. Xtop of Makefile for information on how to compile without the UNIX
  183. Xfeatures.
  184. X
  185. X7. Major changes for release 6.0
  186. X--------------------------------
  187. X
  188. XVersion 6.0 is a major new release with a number of improvements over
  189. Xearlier releases and several changes that are not backward compatible.
  190. XIf you've been using earlier releases of Tcl you'll need to make changes
  191. Xto both your Tcl scripts and to your C application code in order to
  192. Xuse this release.  In general, a change in the major release number
  193. X(e.g. from 5.x to 6.x) means that there are significant incompatibilities
  194. Xbetween the new release and old releases.
  195. X
  196. XA complete list of all changes to Tcl can be found in the file "changes",
  197. Xin chronological order.  In addition, the manual entries contain change
  198. Xbars in the right margins for all recent changes (the "changes" file
  199. Xindicates the last time that all the change bars were removed from the
  200. Xdocumentation).  Here is a short list of some of the most significant
  201. Xenhancements in Tcl 6.0:
  202. X
  203. X    - Floating-point support in expressions
  204. X    - Associative arrays
  205. X    - Support in "exec" for pipelines, background, redirection
  206. X    - Support for regular expressions and other forms of string manipulation
  207. X    - New commands for file I/O (open, close, gets, puts, etc.)
  208. X    - Support for demand-loading of Tcl scripts
  209. X    - Several new list-manipulation commands
  210. X    - Improved portability, especially to System-V systems
  211. X    - ANSI C function prototypes
  212. X    - Improved test suite
  213. X    - Many other new commands
  214. X
  215. XHere is a list of the most important incompatibilities introduced by
  216. XTcl 6.0:
  217. X
  218. X    - Newlines inside bracketed commands used to be treated as word
  219. X      separators;  they are now treated as command separators (this is
  220. X      consistent with the way newlines are treated elsewhere in Tcl).
  221. X    - The order of arguments to the "file" command has been changed so
  222. X      that the "option" argument is first instead of second (this makes
  223. X      "file" consistent with all other Tcl commands).
  224. X    - The "index", "length", "print", and "range" commands have all been
  225. X      deleted (similar effects can be achieved using other commands).
  226. X    - Command abbreviations are no longer supported directly (but they
  227. X      can be added using the "unknown" command and are supported in the
  228. X      library version of "unknown").
  229. X    - The "<" notation in "exec" has been changed to "<<".
  230. X    - The "exec" command deletes the last character of program output if
  231. X      it is a newline (in most cases this makes it easier to parse the
  232. X      program output).
  233. X    - The variable-tracing mechanism has been totally changed to accommodate
  234. X      associative arrays;  most of the C interfaces to Tcl variables have
  235. X      changed at least slightly.
  236. X    - The C interfaces to the expression evaluator and to Tcl_Eval have
  237. X      changed slightly.
  238. X
  239. X8. Special thanks
  240. X-----------------
  241. X
  242. XMark Diekhans and Karl Lehenbauer of Santa Cruz Operation deserve special
  243. Xthanks for all their help during the development of Tcl 6.0.  Many of the
  244. Xnew features in Tcl 6.0 were inspired by an enhanced version of Tcl 3.3
  245. Xcalled Extended Tcl 4.0, which was created by Mark, Karl, and Peter
  246. Xda Silva.  Mark and Karl explained these features to me and provided
  247. Xexcellent (and challenging) feedback during the 6.0 development process.
  248. XThey were also a great help in finding and fixing portability problems.
  249. XWithout their ideas and assistance Tcl 6.0 would be much less powerful.
  250. X
  251. X9. Support
  252. X----------
  253. X
  254. XThere is no official support organization for Tcl, and I can't promise
  255. Xto provide much hand-holding to people learning Tcl.  However, I'm very
  256. Xinterested in receiving bug reports and suggestions for improvements.
  257. XBugs usually get fixed quickly (particularly if they are serious), but
  258. Xenhancements may take a while and may not happen at all unless there
  259. Xis widespread support for them.
  260. X
  261. X10. Tcl mailing list
  262. X--------------------
  263. X
  264. XI maintain a mail alias of people interested in exchanging ideas and
  265. Xexperiences with Tcl and Tcl-based applications (such as the Tk
  266. Xtoolkit).  If you would like to join the mailing list, send a
  267. Xrequest to "tcl-request@sprite.berkeley.edu".  Traffic on the
  268. Xmailing list is moderate to low: a few messages per week, on average.
  269. XThere will be a "comp.lang.tcl" newsgroup soon.
  270. END_OF_FILE
  271. if test 10992 -ne `wc -c <'tcl6.1/README'`; then
  272.     echo shar: \"'tcl6.1/README'\" unpacked with wrong size!
  273. fi
  274. # end of 'tcl6.1/README'
  275. fi
  276. if test -f 'tcl6.1/doc/SetResult.man' -a "${1}" != "-c" ; then 
  277.   echo shar: Will not clobber existing file \"'tcl6.1/doc/SetResult.man'\"
  278. else
  279. echo shar: Extracting \"'tcl6.1/doc/SetResult.man'\" \(9903 characters\)
  280. sed "s/^X//" >'tcl6.1/doc/SetResult.man' <<'END_OF_FILE'
  281. X'\" Copyright 1989 Regents of the University of California
  282. X'\" Permission to use, copy, modify, and distribute this
  283. X'\" documentation for any purpose and without fee is hereby
  284. X'\" granted, provided that this notice appears in all copies.
  285. X'\" The University of California makes no representations about
  286. X'\" the suitability of this material for any purpose.  It is
  287. X'\" provided "as is" without express or implied warranty.
  288. X'\" 
  289. X'\" $Header: /user6/ouster/tcl/doc/RCS/SetResult.man,v 1.6 91/09/04 16:37:49 ouster Exp $ SPRITE (Berkeley)
  290. X'\" 
  291. X.\" The definitions below are for supplemental macros used in Sprite
  292. X.\" manual entries.
  293. X.\"
  294. X.\" .HS name section [date [version]]
  295. X.\"    Replacement for .TH in other man pages.  See below for valid
  296. X.\"    section names.
  297. X.\"
  298. X.\" .AP type name in/out [indent]
  299. X.\"    Start paragraph describing an argument to a library procedure.
  300. X.\"    type is type of argument (int, etc.), in/out is either "in", "out",
  301. X.\"    or "in/out" to describe whether procedure reads or modifies arg,
  302. X.\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  303. X.\"    needed;  use .AS below instead)
  304. X.\"
  305. X.\" .AS [type [name]]
  306. X.\"    Give maximum sizes of arguments for setting tab stops.  Type and
  307. X.\"    name are examples of largest possible arguments that will be passed
  308. X.\"    to .AP later.  If args are omitted, default tab stops are used.
  309. X.\"
  310. X.\" .BS
  311. X.\"    Start box enclosure.  From here until next .BE, everything will be
  312. X.\"    enclosed in one large box.
  313. X.\"
  314. X.\" .BE
  315. X.\"    End of box enclosure.
  316. X.\"
  317. X.\" .VS
  318. X.\"    Begin vertical sidebar, for use in marking newly-changed parts
  319. X.\"    of man pages.
  320. X.\"
  321. X.\" .VE
  322. X.\"    End of vertical sidebar.
  323. X.\"
  324. X.\" .DS
  325. X.\"    Begin an indented unfilled display.
  326. X.\"
  327. X.\" .DE
  328. X.\"    End of indented unfilled display.
  329. X.\"
  330. X'    # Heading for Sprite man pages
  331. X.de HS
  332. X.if '\\$2'cmds'       .TH \\$1 1 \\$3 \\$4
  333. X.if '\\$2'lib'        .TH \\$1 3 \\$3 \\$4
  334. X.if '\\$2'tcl'        .TH \\$1 3 \\$3 \\$4
  335. X.if '\\$2'tk'         .TH \\$1 3 \\$3 \\$4
  336. X.if t .wh -1.3i ^B
  337. X.nr ^l \\n(.l
  338. X.ad b
  339. X..
  340. X'    # Start an argument description
  341. X.de AP
  342. X.ie !"\\$4"" .TP \\$4
  343. X.el \{\
  344. X.   ie !"\\$2"" .TP \\n()Cu
  345. X.   el          .TP 15
  346. X.\}
  347. X.ie !"\\$3"" \{\
  348. X.ta \\n()Au \\n()Bu
  349. X\&\\$1    \\fI\\$2\\fP    (\\$3)
  350. X.\".b
  351. X.\}
  352. X.el \{\
  353. X.br
  354. X.ie !"\\$2"" \{\
  355. X\&\\$1    \\fI\\$2\\fP
  356. X.\}
  357. X.el \{\
  358. X\&\\fI\\$1\\fP
  359. X.\}
  360. X.\}
  361. X..
  362. X'    # define tabbing values for .AP
  363. X.de AS
  364. X.nr )A 10n
  365. X.if !"\\$1"" .nr )A \\w'\\$1'u+3n
  366. X.nr )B \\n()Au+15n
  367. X.\"
  368. X.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  369. X.nr )C \\n()Bu+\\w'(in/out)'u+2n
  370. X..
  371. X'    # BS - start boxed text
  372. X'    # ^y = starting y location
  373. X'    # ^b = 1
  374. X.de BS
  375. X.br
  376. X.mk ^y
  377. X.nr ^b 1u
  378. X.if n .nf
  379. X.if n .ti 0
  380. X.if n \l'\\n(.lu\(ul'
  381. X.if n .fi
  382. X..
  383. X'    # BE - end boxed text (draw box now)
  384. X.de BE
  385. X.nf
  386. X.ti 0
  387. X.mk ^t
  388. X.ie n \l'\\n(^lu\(ul'
  389. X.el \{\
  390. X.\"    Draw four-sided box normally, but don't draw top of
  391. X.\"    box if the box started on an earlier page.
  392. X.ie !\\n(^b-1 \{\
  393. X\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  394. X.\}
  395. X.el \}\
  396. X\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  397. X.\}
  398. X.\}
  399. X.fi
  400. X.br
  401. X.nr ^b 0
  402. X..
  403. X'    # VS - start vertical sidebar
  404. X'    # ^Y = starting y location
  405. X'    # ^v = 1 (for troff;  for nroff this doesn't matter)
  406. X.de VS
  407. X.mk ^Y
  408. X.ie n 'mc \s12\(br\s0
  409. X.el .nr ^v 1u
  410. X..
  411. X'    # VE - end of vertical sidebar
  412. X.de VE
  413. X.ie n 'mc
  414. X.el \{\
  415. X.ev 2
  416. X.nf
  417. X.ti 0
  418. X.mk ^t
  419. X\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  420. X.sp -1
  421. X.fi
  422. X.ev
  423. X.\}
  424. X.nr ^v 0
  425. X..
  426. X'    # Special macro to handle page bottom:  finish off current
  427. X'    # box/sidebar if in box/sidebar mode, then invoked standard
  428. X'    # page bottom macro.
  429. X.de ^B
  430. X.ev 2
  431. X'ti 0
  432. X'nf
  433. X.mk ^t
  434. X.if \\n(^b \{\
  435. X.\"    Draw three-sided box if this is the box's first page,
  436. X.\"    draw two sides but no top otherwise.
  437. 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
  438. X.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  439. X.\}
  440. X.if \\n(^v \{\
  441. X.nr ^x \\n(^tu+1v-\\n(^Yu
  442. X\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  443. X.\}
  444. X.bp
  445. X'fi
  446. X.ev
  447. X.if \\n(^b \{\
  448. X.mk ^y
  449. X.nr ^b 2
  450. X.\}
  451. X.if \\n(^v \{\
  452. X.mk ^Y
  453. X.\}
  454. X..
  455. X'    # DS - begin display
  456. X.de DS
  457. X.RS
  458. X.nf
  459. X.sp
  460. X..
  461. X'    # DE - end display
  462. X.de DE
  463. X.fi
  464. X.RE
  465. X.sp .5
  466. X..
  467. X.HS Tcl_SetResult tcl
  468. X.BS
  469. X.SH NAME
  470. XTcl_SetResult, Tcl_AppendResult, Tcl_AppendElement, Tcl_ResetResult \- manipulate Tcl result string
  471. X.SH SYNOPSIS
  472. X.nf
  473. X\fB#include <tcl.h>\fR
  474. X.sp
  475. X.VS
  476. X\fBTcl_SetResult\fR(\fIinterp, string, freeProc\fR)
  477. X.VE
  478. X.sp
  479. X\fBTcl_AppendResult(\fIinterp, string, string, ... , \fB(char *) NULL\fR)
  480. X.sp
  481. X.VS
  482. X\fBTcl_AppendElement\fR(\fIinterp, string, noSep\fR)
  483. X.sp
  484. X\fBTcl_ResetResult\fR(\fIinterp\fR)
  485. X.sp
  486. X\fBTcl_FreeResult\fR(\fIinterp\fR)
  487. X.VE
  488. X.SH ARGUMENTS
  489. X.AS Tcl_FreeProc freeProc
  490. X.AP Tcl_Interp *interp out
  491. XInterpreter whose result is to be modified.
  492. X.AP char *string in
  493. XString value to be become result for \fIinterp\fR or to be
  494. Xappended to existing result.
  495. X.AP Tcl_FreeProc freeProc in
  496. X.VS
  497. XAddress of procedure to call to release storage at
  498. X\fIstring\fR, or \fBTCL_STATIC\fR, \fBTCL_DYNAMIC\fR, or
  499. X\fBTCL_VOLATILE\fR.
  500. X.AP int noSep in
  501. XIf non-zero then don't output a space character before this element,
  502. Xeven if the element isn't the first thing in the result string.
  503. X.VE
  504. X.BE
  505. X
  506. X.SH DESCRIPTION
  507. X.PP
  508. XThe procedures described here are utilities for setting the
  509. Xresult/error string in a Tcl interpreter.
  510. X.PP
  511. X\fBTcl_SetResult\fR
  512. Xarranges for \fIstring\fR to be the return string for the current Tcl
  513. Xcommand in \fIinterp\fR, replacing any existing result.
  514. X.VS
  515. XIf \fIfreeProc\fR is \fBTCL_STATIC\fR it means that \fIstring\fR
  516. Xrefers to an area of static storage that is guaranteed not to be
  517. Xmodified until at least the next call to \fBTcl_Eval\fR.
  518. XIf \fIfreeProc\fR
  519. Xis \fBTCL_DYNAMIC\fR it means that \fIstring\fR was allocated with a call
  520. Xto \fBmalloc()\fR and is now the property of the Tcl system.
  521. X\fBTcl_SetResult\fR will arrange for the string's storage to be
  522. Xreleased by calling \fBfree()\fR when it is no longer needed.
  523. XIf \fIfreeProc\fR is \fBTCL_VOLATILE\fR it means that \fIstring\fR
  524. Xpoints to an area of memory that is likely to be overwritten when
  525. X\fBTcl_SetResult\fR returns (e.g. it points to something in a stack frame).
  526. XIn this case \fBTcl_SetResult\fR will make a copy of the string in
  527. Xdynamically allocated storage and arrange for the copy to be the
  528. Xreturn string for the current Tcl command.
  529. X.PP
  530. XIf \fIfreeProc\fR isn't one of the values \fBTCL_STATIC\fR,
  531. X\fBTCL_DYNAMIC\fR, and \fBTCL_VOLATILE\fR, then it is the address
  532. Xof a procedure that Tcl should call to free the string.
  533. XThis allows applications to use non-standard storage allocators.
  534. XWhen Tcl no longer needs the storage for the string, it will
  535. Xcall \fIfreeProc\fR.  \fIFreeProc\fR should have arguments and
  536. Xresult that match the type \fBTcl_FreeProc\fR:
  537. X.nf
  538. X.RS
  539. X
  540. Xtypedef void Tcl_FreeProc(char *\fIblockPtr\fR);
  541. X
  542. X.RE
  543. X.fi
  544. XWhen \fIfreeProc\fR is called, its \fIblockPtr\fR will be set to
  545. Xthe value of \fIstring\fR passed to \fBTcl_SetResult\fR.
  546. X.VE
  547. X.PP
  548. XIf \fIstring\fR is \fBNULL\fR, then \fIfreeProc\fR is ignored
  549. Xand \fBTcl_SetResult\fR
  550. Xre-initializes \fIinterp\fR's result to point to the pre-allocated result
  551. Xarea, with an empty string in the result area.
  552. X.PP
  553. X.VS
  554. XIf \fBTcl_SetResult\fR is called at a time when \fIinterp\fR holds a
  555. Xresult, \fBTcl_SetResult\fR does whatever is necessary to dispose
  556. Xof the old result (see the \fBTcl_Interp\fR manual entry for details
  557. Xon this).
  558. X.VE
  559. X.PP
  560. X\fBTcl_AppendResult\fR makes it easy to build up Tcl results in pieces.
  561. XIt takes each of its \fIstring\fR arguments and appends them in order
  562. Xto the current result associated with \fIinterp\fR.
  563. X.VS
  564. XIf the result is in its initialized empty state (e.g. a command procedure
  565. Xwas just invoked or \fBTcl_ResetResult\fR was just called),
  566. Xthen \fBTcl_AppendResult\fR sets the result to the concatenation of
  567. Xits \fIstring\fR arguments.
  568. X.VE
  569. X\fBTcl_AppendResult\fR may be called repeatedly as additional pieces
  570. Xof the result are produced.
  571. X\fBTcl_AppendResult\fR takes care of all the
  572. Xstorage management issues associated with managing \fIinterp\fR's
  573. Xresult, such as allocating a larger result area if necessary.
  574. XAny number of \fIstring\fR arguments may be passed in a single
  575. Xcall;  the last argument in the list must be a NULL pointer.
  576. X.PP
  577. X\fBTcl_AppendElement\fR is similar to \fBTcl_AppendResult\fR in
  578. X.VS
  579. Xthat it allows results to be built up in pieces.
  580. XHowever, \fBTcl_AppendElement\fR takes only a single \fIstring\fR
  581. Xargument and it appends that argument to the current result
  582. Xas a proper Tcl list element.
  583. X\fBTcl_AppendElement\fR adds backslashes or braces if necessary
  584. Xto ensure that \fIinterp\fR's result can be parsed as a list and that
  585. X\fIstring\fR will be extracted as a single element.
  586. XUnder normal conditions, \fBTcl_AppendElement\fR will add a space
  587. Xcharacter to \fIinterp\fR's result just before adding the new
  588. Xlist element, so that the list elements in the result are properly
  589. Xseparated.
  590. XHowever, if \fIinterp\fR's result is empty when \fBTcl_AppendElement\fR
  591. Xis called, or if the \fInoSep\fR argument is 1, then no space
  592. Xis added.
  593. X.PP
  594. X\fBTcl_ResetResult\fR clears the result for \fIinterp\fR,
  595. Xfreeing the memory associated with it if the current result was
  596. Xdynamically allocated.
  597. XIt leaves the result in its normal initialized state with
  598. X\fIinterp->result\fR pointing to a static buffer containing
  599. X\fBTCL_RESULT_SIZE\fR characters, of which the first character
  600. Xis zero.
  601. X\fBTcl_ResetResult\fR also clears the error state managed by
  602. X\fBTcl_AddErrorInfo\fR and \fBTcl_SetErrorCode\fR.
  603. X.PP
  604. X\fBTcl_FreeResult\fR is a macro that performs part of the work
  605. Xof \fBTcl_ResetResult\fR.
  606. XIt frees up the memory associated with \fIinterp\fR's result
  607. Xand sets \fIinterp->freeProc\fR to zero, but it doesn't
  608. Xchange \fIinterp->result\fR or clear error state.
  609. X\fBTcl_FreeResult\fR is most commonly used when a procedure
  610. Xis about to replace one result value with another.
  611. X.VE
  612. X
  613. X.SH "SEE ALSO"
  614. XTcl_AddErrorInfo, Tcl_SetErrorCode, Tcl_Interp
  615. X
  616. X.SH KEYWORDS
  617. Xappend, command, element, list, result, return value, interpreter
  618. END_OF_FILE
  619. if test 9903 -ne `wc -c <'tcl6.1/doc/SetResult.man'`; then
  620.     echo shar: \"'tcl6.1/doc/SetResult.man'\" unpacked with wrong size!
  621. fi
  622. # end of 'tcl6.1/doc/SetResult.man'
  623. fi
  624. if test -f 'tcl6.1/doc/SetVar.man' -a "${1}" != "-c" ; then 
  625.   echo shar: Will not clobber existing file \"'tcl6.1/doc/SetVar.man'\"
  626. else
  627. echo shar: Extracting \"'tcl6.1/doc/SetVar.man'\" \(9653 characters\)
  628. sed "s/^X//" >'tcl6.1/doc/SetVar.man' <<'END_OF_FILE'
  629. X'\" Copyright 1989 Regents of the University of California
  630. X'\" Permission to use, copy, modify, and distribute this
  631. X'\" documentation for any purpose and without fee is hereby
  632. X'\" granted, provided that this notice appears in all copies.
  633. X'\" The University of California makes no representations about
  634. X'\" the suitability of this material for any purpose.  It is
  635. X'\" provided "as is" without express or implied warranty.
  636. X'\" 
  637. X'\" $Header: /user6/ouster/tcl/man/RCS/SetVar.man,v 1.7 91/11/01 14:40:53 ouster Exp $ SPRITE (Berkeley)
  638. X'\" 
  639. X.\" The definitions below are for supplemental macros used in Sprite
  640. X.\" manual entries.
  641. X.\"
  642. X.\" .HS name section [date [version]]
  643. X.\"    Replacement for .TH in other man pages.  See below for valid
  644. X.\"    section names.
  645. X.\"
  646. X.\" .AP type name in/out [indent]
  647. X.\"    Start paragraph describing an argument to a library procedure.
  648. X.\"    type is type of argument (int, etc.), in/out is either "in", "out",
  649. X.\"    or "in/out" to describe whether procedure reads or modifies arg,
  650. X.\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  651. X.\"    needed;  use .AS below instead)
  652. X.\"
  653. X.\" .AS [type [name]]
  654. X.\"    Give maximum sizes of arguments for setting tab stops.  Type and
  655. X.\"    name are examples of largest possible arguments that will be passed
  656. X.\"    to .AP later.  If args are omitted, default tab stops are used.
  657. X.\"
  658. X.\" .BS
  659. X.\"    Start box enclosure.  From here until next .BE, everything will be
  660. X.\"    enclosed in one large box.
  661. X.\"
  662. X.\" .BE
  663. X.\"    End of box enclosure.
  664. X.\"
  665. X.\" .VS
  666. X.\"    Begin vertical sidebar, for use in marking newly-changed parts
  667. X.\"    of man pages.
  668. X.\"
  669. X.\" .VE
  670. X.\"    End of vertical sidebar.
  671. X.\"
  672. X.\" .DS
  673. X.\"    Begin an indented unfilled display.
  674. X.\"
  675. X.\" .DE
  676. X.\"    End of indented unfilled display.
  677. X.\"
  678. X'    # Heading for Sprite man pages
  679. X.de HS
  680. X.if '\\$2'cmds'       .TH \\$1 1 \\$3 \\$4
  681. X.if '\\$2'lib'        .TH \\$1 3 \\$3 \\$4
  682. X.if '\\$2'tcl'        .TH \\$1 3 \\$3 \\$4
  683. X.if '\\$2'tk'         .TH \\$1 3 \\$3 \\$4
  684. X.if t .wh -1.3i ^B
  685. X.nr ^l \\n(.l
  686. X.ad b
  687. X..
  688. X'    # Start an argument description
  689. X.de AP
  690. X.ie !"\\$4"" .TP \\$4
  691. X.el \{\
  692. X.   ie !"\\$2"" .TP \\n()Cu
  693. X.   el          .TP 15
  694. X.\}
  695. X.ie !"\\$3"" \{\
  696. X.ta \\n()Au \\n()Bu
  697. X\&\\$1    \\fI\\$2\\fP    (\\$3)
  698. X.\".b
  699. X.\}
  700. X.el \{\
  701. X.br
  702. X.ie !"\\$2"" \{\
  703. X\&\\$1    \\fI\\$2\\fP
  704. X.\}
  705. X.el \{\
  706. X\&\\fI\\$1\\fP
  707. X.\}
  708. X.\}
  709. X..
  710. X'    # define tabbing values for .AP
  711. X.de AS
  712. X.nr )A 10n
  713. X.if !"\\$1"" .nr )A \\w'\\$1'u+3n
  714. X.nr )B \\n()Au+15n
  715. X.\"
  716. X.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  717. X.nr )C \\n()Bu+\\w'(in/out)'u+2n
  718. X..
  719. X'    # BS - start boxed text
  720. X'    # ^y = starting y location
  721. X'    # ^b = 1
  722. X.de BS
  723. X.br
  724. X.mk ^y
  725. X.nr ^b 1u
  726. X.if n .nf
  727. X.if n .ti 0
  728. X.if n \l'\\n(.lu\(ul'
  729. X.if n .fi
  730. X..
  731. X'    # BE - end boxed text (draw box now)
  732. X.de BE
  733. X.nf
  734. X.ti 0
  735. X.mk ^t
  736. X.ie n \l'\\n(^lu\(ul'
  737. X.el \{\
  738. X.\"    Draw four-sided box normally, but don't draw top of
  739. X.\"    box if the box started on an earlier page.
  740. X.ie !\\n(^b-1 \{\
  741. X\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  742. X.\}
  743. X.el \}\
  744. X\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  745. X.\}
  746. X.\}
  747. X.fi
  748. X.br
  749. X.nr ^b 0
  750. X..
  751. X'    # VS - start vertical sidebar
  752. X'    # ^Y = starting y location
  753. X'    # ^v = 1 (for troff;  for nroff this doesn't matter)
  754. X.de VS
  755. X.mk ^Y
  756. X.ie n 'mc \s12\(br\s0
  757. X.el .nr ^v 1u
  758. X..
  759. X'    # VE - end of vertical sidebar
  760. X.de VE
  761. X.ie n 'mc
  762. X.el \{\
  763. X.ev 2
  764. X.nf
  765. X.ti 0
  766. X.mk ^t
  767. X\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  768. X.sp -1
  769. X.fi
  770. X.ev
  771. X.\}
  772. X.nr ^v 0
  773. X..
  774. X'    # Special macro to handle page bottom:  finish off current
  775. X'    # box/sidebar if in box/sidebar mode, then invoked standard
  776. X'    # page bottom macro.
  777. X.de ^B
  778. X.ev 2
  779. X'ti 0
  780. X'nf
  781. X.mk ^t
  782. X.if \\n(^b \{\
  783. X.\"    Draw three-sided box if this is the box's first page,
  784. X.\"    draw two sides but no top otherwise.
  785. 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
  786. X.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  787. X.\}
  788. X.if \\n(^v \{\
  789. X.nr ^x \\n(^tu+1v-\\n(^Yu
  790. X\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  791. X.\}
  792. X.bp
  793. X'fi
  794. X.ev
  795. X.if \\n(^b \{\
  796. X.mk ^y
  797. X.nr ^b 2
  798. X.\}
  799. X.if \\n(^v \{\
  800. X.mk ^Y
  801. X.\}
  802. X..
  803. X'    # DS - begin display
  804. X.de DS
  805. X.RS
  806. X.nf
  807. X.sp
  808. X..
  809. X'    # DE - end display
  810. X.de DE
  811. X.fi
  812. X.RE
  813. X.sp .5
  814. X..
  815. X.HS Tcl_SetVar tcl
  816. X.BS
  817. X.VS
  818. X.SH NAME
  819. XTcl_SetVar, Tcl_SetVar2, Tcl_GetVar, Tcl_GetVar2, Tcl_UnsetVar, Tcl_UnsetVar2 \- manipulate Tcl variables
  820. X.SH SYNOPSIS
  821. X.nf
  822. X\fB#include <tcl.h>\fR
  823. X.sp
  824. Xchar *
  825. X\fBTcl_SetVar\fR(\fIinterp, varName, newValue, flags\fR)
  826. X.sp
  827. Xchar *
  828. X\fBTcl_SetVar2\fR(\fIinterp, name1, name2, newValue, flags\fR)
  829. X.sp
  830. Xchar *
  831. X\fBTcl_GetVar\fR(\fIinterp, varName, flags\fR)
  832. X.sp
  833. Xchar *
  834. X\fBTcl_GetVar2\fR(\fIinterp, name1, name2, flags\fR)
  835. X.sp
  836. Xint
  837. X\fBTcl_UnsetVar\fR(\fIinterp, varName, flags\fR)
  838. X.sp
  839. Xint
  840. X\fBTcl_UnsetVar2\fR(\fIinterp, name1, name2, flags\fR)
  841. X.SH ARGUMENTS
  842. X.AS Tcl_Interp *interp
  843. X.AP Tcl_Interp *interp in
  844. XInterpreter containing variable.
  845. X.AP char *varName in
  846. XName of variable.  May refer to a scalar variable or an element of
  847. Xan array variable.
  848. X.AP char *newValue in
  849. XNew value for variable.
  850. X.AP int flags in
  851. XOR-ed combination of bits providing additional information for
  852. Xoperation. See below for valid values.
  853. X.AP char *name1 in
  854. XName of scalar variable, or name of array variable if \fIname2\fR
  855. Xis non-NULL.
  856. X.AP char *name2 in
  857. XIf non-NULL, gives name of element within array and \fIname1\fR
  858. Xmust refer to an array variable.
  859. X.BE
  860. X
  861. X.SH DESCRIPTION
  862. X.PP
  863. XThese procedures may be used to create, modify, read, and delete
  864. XTcl variables from C code.
  865. X\fBTcl_SetVar\fR and \fBTcl_SetVar2\fR will create a new variable
  866. Xor modify an existing one.
  867. XBoth of these procedures set the given variable to the value
  868. Xgiven by \fInewValue\fR, and they return a pointer to a
  869. Xcopy of the variable's new value, which is stored in Tcl's
  870. Xvariable structure.
  871. XTcl keeps a private copy of the variable's value, so the caller
  872. Xmay change \fInewValue\fR after these procedures return without
  873. Xaffecting the value of the variable.
  874. XIf an error occurs in setting the variable (e.g. an array
  875. Xvariable is referenced without giving an index into the array),
  876. Xthen NULL is returned.
  877. X.PP
  878. XThe name of the variable may be specified in either of two ways.
  879. XIf \fBTcl_SetVar\fR is called, the variable name is given as
  880. Xa single string, \fIvarName\fR.
  881. XIf \fIvarName\fR contains an open parenthesis and ends with a
  882. Xclose parenthesis, then the value between the parentheses is
  883. Xtreated as an index (which can have any string value) and
  884. Xthe characters before the first open
  885. Xparenthesis are treated as the name of an array variable.
  886. XIf \fIvarName\fR doesn't have parentheses as described above, then
  887. Xthe entire string is treated as the name of a scalar variable.
  888. XIf \fBTcl_SetVar2\fR is called, then the array name and index
  889. Xhave been separated by the caller into two separate strings,
  890. X\fIname1\fR and \fIname2\fR respectively;  if \fIname2\fR is
  891. Xzero it means that a scalar variable is being referenced.
  892. X.PP
  893. XThe \fIflags\fR argument may be used to specify any of several
  894. Xoptions to the procedures.
  895. XIt consists of an OR-ed combination of any of the following
  896. Xbits:
  897. X.IP TCL_GLOBAL_ONLY
  898. XUnder normal circumstances the procedures look up variables
  899. Xat the current level of procedure call for \fIinterp\fR, or
  900. Xat global level if there is no call active.
  901. XHowever, if this bit is set in \fIflags\fR then the variable
  902. Xis looked up at global level even if there is a procedure
  903. Xcall active.
  904. X.IP TCL_LEAVE_ERR_MSG
  905. XIf an error is returned and this bit is set in \fIflags\fR, then
  906. Xan error message will be left in \fI\%interp->result\fR.  If this
  907. Xflag bit isn't set then no error message is left (\fI\%interp->result\fR
  908. Xwill not be modified).
  909. X.IP TCL_APPEND_VALUE
  910. XIf this bit is set then \fInewValue\fR is appended to the current
  911. Xvalue, instead of replacing it.
  912. XIf the variable is currently undefined, then this bit is ignored.
  913. X.IP TCL_LIST_ELEMENT
  914. XIf this bit is set, then \fInewValue\fR is converted to a valid
  915. XTcl list element before setting (or appending to) the variable.
  916. XIf the list element is being appended to an non-empty value, then
  917. Xa space character is appended before the new list element to
  918. Xseparate it from previous elements.
  919. X.IP TCL_NO_SPACE
  920. XIf this bit is set, it prevents the output of a separating space
  921. Xcharacter in TCL_LIST_ELEMENT appends.
  922. XThis bit has no effect if the TCL_LIST_ELEMENT bit isn't set.
  923. X.PP
  924. X\fBTcl_GetVar\fR and \fBTcl_GetVar2\fR return the current value
  925. Xof a variable.
  926. XThe arguments to these procedures are treated in the same way
  927. Xas the arguments to \fBTcl_SetVar\fR and \fBTcl_SetVar2\fR.
  928. XUnder normal circumstances, the return value is a pointer
  929. Xto the variable's value (which is stored in Tcl's variable
  930. Xstructure and will not change before the next call to \fBTcl_SetVar\fR
  931. Xor \fBTcl_SetVar2\fR).
  932. XThe only bits of \fIflags\fR that are used are TCL_GLOBAL_ONLY
  933. Xand TCL_LEAVE_ERR_MSG, both of
  934. Xwhich have
  935. Xthe same meaning as for \fBTcl_SetVar\fR.
  936. XIf an error occurs in reading the variable (e.g. the variable
  937. Xdoesn't exist or an array element is specified for a scalar
  938. Xvariable), then NULL is returned.
  939. X.PP
  940. X\fBTcl_UnsetVar\fR and \fBTcl_UnsetVar2\fR may be used to remove
  941. Xa variable, so that future calls to \fBTcl_GetVar\fR or \fBTcl_GetVar2\fR
  942. Xfor the variable will return an error.
  943. XThe arguments to these procedures are treated in the same way
  944. Xas the arguments to \fBTcl_GetVar\fR and \fBTcl_GetVar2\fR.
  945. XIf the variable is successfully removed then 0 is returned.
  946. XIf the variable cannot be removed because it doesn't exist
  947. Xor because a trace is active for it, then -1 is returned.
  948. XIf an array element is specified, the given element is removed
  949. Xbut the array remains.
  950. XIf an array name is specified without an index, then the entire
  951. Xarray is removed.
  952. X
  953. X.SH "SEE ALSO"
  954. XTcl_TraceVar
  955. X
  956. X.SH KEYWORDS
  957. Xarray, interpreter, scalar, set, unset, variable
  958. X.VE
  959. END_OF_FILE
  960. if test 9653 -ne `wc -c <'tcl6.1/doc/SetVar.man'`; then
  961.     echo shar: \"'tcl6.1/doc/SetVar.man'\" unpacked with wrong size!
  962. fi
  963. # end of 'tcl6.1/doc/SetVar.man'
  964. fi
  965. if test -f 'tcl6.1/tests/string.test' -a "${1}" != "-c" ; then 
  966.   echo shar: Will not clobber existing file \"'tcl6.1/tests/string.test'\"
  967. else
  968. echo shar: Extracting \"'tcl6.1/tests/string.test'\" \(9785 characters\)
  969. sed "s/^X//" >'tcl6.1/tests/string.test' <<'END_OF_FILE'
  970. X# Commands covered:  string
  971. X#
  972. X# This file contains a collection of tests for one or more of the Tcl
  973. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  974. X# generates output for errors.  No output means no errors were found.
  975. X#
  976. X# Copyright 1991 Regents of the University of California
  977. X# Permission to use, copy, modify, and distribute this
  978. X# software and its documentation for any purpose and without
  979. X# fee is hereby granted, provided that this copyright notice
  980. X# appears in all copies.  The University of California makes no
  981. X# representations about the suitability of this software for any
  982. X# purpose.  It is provided "as is" without express or implied
  983. X# warranty.
  984. X#
  985. X# $Header: /sprite/src/lib/tcl/tests/RCS/string.test,v 1.5 91/09/11 16:45:17 ouster Exp $ (Berkeley)
  986. X
  987. Xif {[string compare test [info procs test]] == 1} then {source defs}
  988. X
  989. Xtest string-1.1 {string compare} {
  990. X    string compare abcde abdef
  991. X} -1
  992. Xtest string-1.2 {string compare} {
  993. X    string c abcde ABCDE
  994. X} 1
  995. Xtest string-1.3 {string compare} {
  996. X    string compare abcde abcde
  997. X} 0
  998. Xtest string-1.4 {string compare} {
  999. X    list [catch {string compare a} msg] $msg
  1000. X} {1 {wrong # args: should be "string compare string1 string2"}}
  1001. Xtest string-1.5 {string compare} {
  1002. X    list [catch {string compare a b c} msg] $msg
  1003. X} {1 {wrong # args: should be "string compare string1 string2"}}
  1004. X
  1005. Xtest string-2.1 {string first} {
  1006. X    string first bq abcdefgbcefgbqrs
  1007. X} 12
  1008. Xtest string-2.2 {string first} {
  1009. X    string fir bcd abcdefgbcefgbqrs
  1010. X} 1
  1011. Xtest string-2.3 {string first} {
  1012. X    string f b abcdefgbcefgbqrs
  1013. X} 1
  1014. Xtest string-2.4 {string first} {
  1015. X    string first xxx x123xx345xxx789xxx012
  1016. X} 9
  1017. Xtest string-2.5 {string first} {
  1018. X    list [catch {string first a} msg] $msg
  1019. X} {1 {wrong # args: should be "string first string1 string2"}}
  1020. Xtest string-2.6 {string first} {
  1021. X    list [catch {string first a b c} msg] $msg
  1022. X} {1 {wrong # args: should be "string first string1 string2"}}
  1023. X
  1024. Xtest string-3.1 {string index} {
  1025. X    string index abcde 0
  1026. X} a
  1027. Xtest string-3.2 {string index} {
  1028. X    string i abcde 4
  1029. X} e
  1030. Xtest string-3.3 {string index} {
  1031. X    string index abcde 5
  1032. X} {}
  1033. Xtest string-3.4 {string index} {
  1034. X    list [catch {string index abcde -10} msg] $msg
  1035. X} {0 {}}
  1036. Xtest string-3.5 {string index} {
  1037. X    list [catch {string index} msg] $msg
  1038. X} {1 {wrong # args: should be "string index string charIndex"}}
  1039. Xtest string-3.6 {string index} {
  1040. X    list [catch {string index a b c} msg] $msg
  1041. X} {1 {wrong # args: should be "string index string charIndex"}}
  1042. Xtest string-3.7 {string index} {
  1043. X    list [catch {string index a xyz} msg] $msg
  1044. X} {1 {expected integer but got "xyz"}}
  1045. X
  1046. Xtest string-4.1 {string last} {
  1047. X    string la xxx xxxx123xx345x678
  1048. X} 1
  1049. Xtest string-4.2 {string last} {
  1050. X    string last xx xxxx123xx345x678
  1051. X} 7
  1052. Xtest string-4.3 {string last} {
  1053. X    string las x xxxx123xx345x678
  1054. X} 12
  1055. Xtest string-4.4 {string last} {
  1056. X    list [catch {string last a} msg] $msg
  1057. X} {1 {wrong # args: should be "string last string1 string2"}}
  1058. Xtest string-4.5 {string last} {
  1059. X    list [catch {string last a b c} msg] $msg
  1060. X} {1 {wrong # args: should be "string last string1 string2"}}
  1061. X
  1062. Xtest string-5.1 {string length} {
  1063. X    string length "a little string"
  1064. X} 15
  1065. Xtest string-5.2 {string length} {
  1066. X    string le ""
  1067. X} 0
  1068. Xtest string-5.3 {string length} {
  1069. X    list [catch {string length} msg] $msg
  1070. X} {1 {wrong # args: should be "string length string"}}
  1071. Xtest string-5.4 {string length} {
  1072. X    list [catch {string length a b} msg] $msg
  1073. X} {1 {wrong # args: should be "string length string"}}
  1074. X
  1075. Xtest string-6.1 {string match} {
  1076. X    string match abc abc
  1077. X} 1
  1078. Xtest string-6.2 {string match} {
  1079. X    string m abc abd
  1080. X} 0
  1081. Xtest string-6.3 {string match} {
  1082. X    string match ab*c abc
  1083. X} 1
  1084. Xtest string-6.4 {string match} {
  1085. X    string match ab**c abc
  1086. X} 1
  1087. Xtest string-6.5 {string match} {
  1088. X    string match ab* abcdef
  1089. X} 1
  1090. Xtest string-6.6 {string match} {
  1091. X    string match *c abc
  1092. X} 1
  1093. Xtest string-6.7 {string match} {
  1094. X    string match *3*6*9 0123456789
  1095. X} 1
  1096. Xtest string-6.8 {string match} {
  1097. X    string match *3*6*9 01234567890
  1098. X} 0
  1099. Xtest string-6.9 {string match} {
  1100. X    string match a?c abc
  1101. X} 1
  1102. Xtest string-6.10 {string match} {
  1103. X    string match a??c abc
  1104. X} 0
  1105. Xtest string-6.11 {string match} {
  1106. X    string match ?1??4???8? 0123456789
  1107. X} 1
  1108. Xtest string-6.12 {string match} {
  1109. X    string match {[abc]bc} abc
  1110. X} 1
  1111. Xtest string-6.13 {string match} {
  1112. X    string match {a[abc]c} abc
  1113. X} 1
  1114. Xtest string-6.14 {string match} {
  1115. X    string match {a[xyz]c} abc
  1116. X} 0
  1117. Xtest string-6.15 {string match} {
  1118. X    string match {12[2-7]45} 12345
  1119. X} 1
  1120. Xtest string-6.16 {string match} {
  1121. X    string match {12[ab2-4cd]45} 12345
  1122. X} 1
  1123. Xtest string-6.17 {string match} {
  1124. X    string match {12[ab2-4cd]45} 12b45
  1125. X} 1
  1126. Xtest string-6.18 {string match} {
  1127. X    string match {12[ab2-4cd]45} 12d45
  1128. X} 1
  1129. Xtest string-6.19 {string match} {
  1130. X    string match {12[ab2-4cd]45} 12145
  1131. X} 0
  1132. Xtest string-6.20 {string match} {
  1133. X    string match {12[ab2-4cd]45} 12545
  1134. X} 0
  1135. Xtest string-6.21 {string match} {
  1136. X    string match {a\*b} a*b
  1137. X} 1
  1138. Xtest string-6.22 {string match} {
  1139. X    string match {a\*b} ab
  1140. X} 0
  1141. Xtest string-6.23 {string match} {
  1142. X    string match {a\*\?\[\]\\\x} "a*?\[\]\\x"
  1143. X} 1
  1144. Xtest string-6.24 {string match} {
  1145. X    list [catch {string match a} msg] $msg
  1146. X} {1 {wrong # args: should be "string match pattern string"}}
  1147. Xtest string-6.25 {string match} {
  1148. X    list [catch {string match a b c} msg] $msg
  1149. X} {1 {wrong # args: should be "string match pattern string"}}
  1150. X
  1151. Xtest string-7.1 {string range} {
  1152. X    string range abcdefghijklmnop 2 14
  1153. X} {cdefghijklmno}
  1154. Xtest string-7.2 {string range} {
  1155. X    string range abcdefghijklmnop 7 1000
  1156. X} {hijklmnop}
  1157. Xtest string-7.3 {string range} {
  1158. X    string range abcdefghijklmnop 10 e
  1159. X} {klmnop}
  1160. Xtest string-7.4 {string range} {
  1161. X    string range abcdefghijklmnop 10 9
  1162. X} {}
  1163. Xtest string-7.5 {string range} {
  1164. X    string range abcdefghijklmnop -3 2
  1165. X} {abc}
  1166. Xtest string-7.6 {string range} {
  1167. X    string range abcdefghijklmnop -3 -2
  1168. X} {}
  1169. Xtest string-7.7 {string range} {
  1170. X    string range abcdefghijklmnop 1000 1010
  1171. X} {}
  1172. Xtest string-7.8 {string range} {
  1173. X    string range abcdefghijklmnop -100 end
  1174. X} {abcdefghijklmnop}
  1175. Xtest string-7.9 {string range} {
  1176. X    list [catch {string range} msg] $msg
  1177. X} {1 {wrong # args: should be "string range string first last"}}
  1178. Xtest string-7.10 {string range} {
  1179. X    list [catch {string range a 1} msg] $msg
  1180. X} {1 {wrong # args: should be "string range string first last"}}
  1181. Xtest string-7.11 {string range} {
  1182. X    list [catch {string range a 1 2 3} msg] $msg
  1183. X} {1 {wrong # args: should be "string range string first last"}}
  1184. Xtest string-7.12 {string range} {
  1185. X    list [catch {string range abc abc 1} msg] $msg
  1186. X} {1 {expected integer but got "abc"}}
  1187. Xtest string-7.13 {string range} {
  1188. X    list [catch {string range abc 1 eof} msg] $msg
  1189. X} {1 {expected integer or "end" but got "eof"}}
  1190. X
  1191. Xtest string-8.1 {string trim} {
  1192. X    string trim "    XYZ      "
  1193. X} {XYZ}
  1194. Xtest string-8.2 {string trim} {
  1195. X    string trim "\t\nXYZ\t\n\r\n"
  1196. X} {XYZ}
  1197. Xtest string-8.3 {string trim} {
  1198. X    string trim "  A XYZ A    "
  1199. X} {A XYZ A}
  1200. Xtest string-8.4 {string trim} {
  1201. X    string trim "XXYYZZABC XXYYZZ" ZYX
  1202. X} {ABC }
  1203. Xtest string-8.5 {string trim} {
  1204. X    string trim "    \t\r      "
  1205. X} {}
  1206. Xtest string-8.6 {string trim} {
  1207. X    string trim {abcdefg} {}
  1208. X} {abcdefg}
  1209. Xtest string-8.7 {string trim} {
  1210. X    string trim {}
  1211. X} {}
  1212. Xtest string-8.8 {string trim} {
  1213. X    string trim ABC DEF
  1214. X} {ABC}
  1215. Xtest string-8.9 {string trim} {
  1216. X    list [catch {string trim} msg] $msg
  1217. X} {1 {wrong # args: should be "string trim string ?chars?"}}
  1218. Xtest string-8.10 {string trim} {
  1219. X    list [catch {string trim a b c} msg] $msg
  1220. X} {1 {wrong # args: should be "string trim string ?chars?"}}
  1221. X
  1222. Xtest string-9.1 {string trimleft} {
  1223. X    string trimleft "    XYZ      "
  1224. X} {XYZ      }
  1225. Xtest string-9.2 {string trimleft} {
  1226. X    list [catch {string triml} msg] $msg
  1227. X} {1 {wrong # args: should be "string trimleft string ?chars?"}}
  1228. X
  1229. Xtest string-10.1 {string trimright} {
  1230. X    string trimright "    XYZ      "
  1231. X} {    XYZ}
  1232. Xtest string-10.2 {string trimright} {
  1233. X    string trimright "   "
  1234. X} {}
  1235. Xtest string-10.3 {string trimright} {
  1236. X    string trimright ""
  1237. X} {}
  1238. Xtest string-10.4 {string trimright errors} {
  1239. X    list [catch {string trimr} msg] $msg
  1240. X} {1 {wrong # args: should be "string trimright string ?chars?"}}
  1241. Xtest string-10.5 {string trimright errors} {
  1242. X    list [catch {string trimg a} msg] $msg
  1243. X} {1 {bad option "trimg": should be compare, first, index, last, length, \
  1244. Xmatch, range, tolower, toupper, trim, trimleft, or trimright}}
  1245. X
  1246. Xtest string-11.1 {string tolower} {
  1247. X    string tolower ABCDeF
  1248. X} {abcdef}
  1249. Xtest string-11.2 {string tolower} {
  1250. X    string tolower "ABC  XyZ"
  1251. X} {abc  xyz}
  1252. Xtest string-11.3 {string tolower} {
  1253. X    string tolower {123#$&*()}
  1254. X} {123#$&*()}
  1255. Xtest string-11.4 {string tolower} {
  1256. X    list [catch {string tolower} msg] $msg
  1257. X} {1 {wrong # args: should be "string tolower string"}}
  1258. Xtest string-11.5 {string tolower} {
  1259. X    list [catch {string tolower a b} msg] $msg
  1260. X} {1 {wrong # args: should be "string tolower string"}}
  1261. X
  1262. Xtest string-12.1 {string toupper} {
  1263. X    string toupper abCDEf
  1264. X} {ABCDEF}
  1265. Xtest string-12.2 {string toupper} {
  1266. X    string toupper "abc xYz"
  1267. X} {ABC XYZ}
  1268. Xtest string-12.3 {string toupper} {
  1269. X    string toupper {123#$&*()}
  1270. X} {123#$&*()}
  1271. Xtest string-12.4 {string toupper} {
  1272. X    list [catch {string toupper} msg] $msg
  1273. X} {1 {wrong # args: should be "string toupper string"}}
  1274. Xtest string-12.5 {string toupper} {
  1275. X    list [catch {string toupper a b} msg] $msg
  1276. X} {1 {wrong # args: should be "string toupper string"}}
  1277. X
  1278. Xtest string-13.1 {error conditions} {
  1279. X    list [catch {string gorp a b} msg] $msg
  1280. X} {1 {bad option "gorp": should be compare, first, index, last, length, \
  1281. Xmatch, range, tolower, toupper, trim, trimleft, or trimright}}
  1282. Xtest string-13.2 {error conditions} {
  1283. X    list [catch {string} msg] $msg
  1284. X} {1 {wrong # args: should be "string option arg ?arg ...?"}}
  1285. END_OF_FILE
  1286. if test 9785 -ne `wc -c <'tcl6.1/tests/string.test'`; then
  1287.     echo shar: \"'tcl6.1/tests/string.test'\" unpacked with wrong size!
  1288. fi
  1289. # end of 'tcl6.1/tests/string.test'
  1290. fi
  1291. echo shar: End of archive 8 \(of 33\).
  1292. cp /dev/null ark8isdone
  1293. MISSING=""
  1294. 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
  1295.     if test ! -f ark${I}isdone ; then
  1296.     MISSING="${MISSING} ${I}"
  1297.     fi
  1298. done
  1299. if test "${MISSING}" = "" ; then
  1300.     echo You have unpacked all 33 archives.
  1301.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1302. else
  1303.     echo You still need to unpack the following archives:
  1304.     echo "        " ${MISSING}
  1305. fi
  1306. ##  End of shell archive.
  1307. exit 0
  1308.  
  1309. exit 0 # Just in case...
  1310. -- 
  1311. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1312. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1313. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1314. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1315.