home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume26 / tclx / part06 < prev    next >
Encoding:
Text File  |  1991-11-19  |  50.0 KB  |  1,348 lines

  1. Newsgroups: comp.sources.misc
  2. From: karl@sugar.neosoft.com (Karl Lehenbauer)
  3. Subject:  v26i006:  tclx - extensions and on-line help for tcl 6.1, Part06/23
  4. Message-ID: <1991Nov19.005357.8648@sparky.imd.sterling.com>
  5. X-Md4-Signature: a7489b2c20ae22aa00501ba6d226e57f
  6. Date: Tue, 19 Nov 1991 00:53:57 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
  10. Posting-number: Volume 26, Issue 6
  11. Archive-name: tclx/part06
  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 6 (of 23)."
  21. # Contents:  extended/tcllib/help/commands/case
  22. #   extended/tcllib/help/commands/open
  23. #   extended/tcllib/help/commands/regexp
  24. #   extended/tcllib/help/commands/regsub
  25. #   extended/tcllib/help/commands/uplevel
  26. #   extended/tcllib/help/extended/ctype
  27. #   extended/tcllib/help/extended/scanmatch
  28. #   extended/tcllib/help/intro/syntax
  29. #   extended/tcllib/help/intro/variables extended/tclsrc/setfuncs.tcl
  30. #   extended/tests/loop.test extended/tests/select.test
  31. #   extended/tests/setfuncs.test extended/tests/string.test
  32. #   extended/tests/testutil.tcl
  33. # Wrapped by karl@one on Wed Nov 13 21:50:17 1991
  34. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  35. if test -f 'extended/tcllib/help/commands/case' -a "${1}" != "-c" ; then 
  36.   echo shar: Will not clobber existing file \"'extended/tcllib/help/commands/case'\"
  37. else
  38. echo shar: Extracting \"'extended/tcllib/help/commands/case'\" \(2577 characters\)
  39. sed "s/^X//" >'extended/tcllib/help/commands/case' <<'END_OF_FILE'
  40. X          case string ?in? patList body ?patList body ...?
  41. X
  42. X          case string ?in? {patList body ?patList body ...?}
  43. X               Match string against each of the patList  arguments  in
  44. X               order.   If  one  matches,  then evaluate the following
  45. X               body argument by passing  it  recursively  to  the  Tcl
  46. X               interpreter,  and return the result of that evaluation.
  47. X               Each patList argument consists of a single  pattern  or
  48. X               list  of patterns.  Each pattern may contain any of the
  49. X               wild-cards described under string match.  If a  patList
  50. X               argument  is  default,  the  corresponding body will be
  51. X               evaluated if no patList matches string.  If no  patList
  52. X               argument  matches  string and no default is given, then
  53. X               the case command returns an empty string.
  54. X
  55. X               Two syntaxes are provided.  The first uses  a  separate
  56. X               argument  for  each  of the patterns and commands; this
  57. X               form is convenient if substitutions are desired on some
  58. X               of  the  patterns  or commands.  The second form places
  59. X               all of the patterns and commands together into a single
  60. X               argument; the argument must have proper list structure,
  61. X               with the elements of the list being  the  patterns  and
  62. X               commands.   The  second form makes it easy to construct
  63. X               multi-line case commands, since the braces  around  the
  64. X               whole  list  make it unnecessary to include a backslash
  65. X               at the end of each line.  Since the  patList  arguments
  66. X               are  in  braces  in  the  second  form,  no  command or
  67. X               variable substitutions are  performed  on  them;   this
  68. X               makes  the  behavior  of the second form different than
  69. X               the first form in some cases.
  70. X
  71. X               Below are some examples of case commands:
  72. X
  73. X                 case abc in {a b} {format 1} default {format 2} a* {format 3}
  74. X
  75. X               will return 3,
  76. X
  77. X                    case a in {
  78. X                      {a b} {format 1}
  79. X                      default {format 2}
  80. X                      a* {format 3}
  81. X                    }
  82. X
  83. X               will return 1, and
  84. X
  85. X                    case xyz {
  86. X                      {a b}
  87. X                        {format 1}
  88. X                      default
  89. X                        {format 2}
  90. X                      a*
  91. X                        {format 3}
  92. X                    }
  93. X
  94. X               will return 2.
  95. X
  96. END_OF_FILE
  97. if test 2577 -ne `wc -c <'extended/tcllib/help/commands/case'`; then
  98.     echo shar: \"'extended/tcllib/help/commands/case'\" unpacked with wrong size!
  99. fi
  100. # end of 'extended/tcllib/help/commands/case'
  101. fi
  102. if test -f 'extended/tcllib/help/commands/open' -a "${1}" != "-c" ; then 
  103.   echo shar: Will not clobber existing file \"'extended/tcllib/help/commands/open'\"
  104. else
  105. echo shar: Extracting \"'extended/tcllib/help/commands/open'\" \(2794 characters\)
  106. sed "s/^X//" >'extended/tcllib/help/commands/open' <<'END_OF_FILE'
  107. X          open fileName ?access?
  108. X               Opens a file and returns an identifier that may be used
  109. X               in future invocations of commands like read, write, and
  110. X               close.  FileName gives the name of the file to open; if
  111. X               it  starts  with  a  tilde  then  tilde substitution is
  112. X               performed as  described  for  Tcl_TildeSubst.   If  the
  113. X               first character of fileName is ``|'' then the remaining
  114. X               characters  of  fileName  are  treated  as  a   command
  115. X               pipeline  to invoke, in the same style as for exec.  In
  116. X               this case, the identifier returned by open may be  used
  117. X               to  write  to the command's input pipe or read from its
  118. X               output pipe.  The access argument indicates the way  in
  119. X               which the file (or command pipeline) is to be accessed.
  120. X               It may have any of the following values:
  121. X
  122. X               r
  123. X                    Open  the  file  for  reading  only; the file must
  124. X                    already exist.
  125. X
  126. X               r+
  127. X                    Open  the  file  for both reading and writing; the
  128. X                    file must already exist.
  129. X
  130. X               w
  131. X                    Open the file for writing only.  Truncate it if it
  132. X                    exists.  If it doesn't exist, create a new file.
  133. X
  134. X               w+
  135. X                    Open  the  file for reading and writing.  Truncate
  136. X                    it if it exists.  If it doesn't  exist,  create  a
  137. X                    new file.
  138. X
  139. X               a
  140. X                    Open  the  file  for  writing only.  The file must
  141. X                    already exist, and the file is positioned so  that
  142. X                    new data is appended to the file.
  143. X
  144. X               a+
  145. X                    Open  the  file for reading and writing.  The file
  146. X                    must  already  exist,  and  the   initial   access
  147. X                    position is set to the end of the file.
  148. X
  149. X               Access defaults to r.  If a file  is  opened  for  both
  150. X               reading  and writing, then seek must be invoked between
  151. X               a read and a write, or  vice  versa  (this  restriction
  152. X               does  not apply to command pipelines opened with open).
  153. X               When  fileName  specifies  a  command  pipeline  and  a
  154. X               write-only  access  is  used, then standard output from
  155. X               the pipeline is directed to the current standard output
  156. X               unless   overridden  by  the  command.   When  fileName
  157. X               specifies a command pipeline and a read-only access  is
  158. X               used,  then  standard  input from the pipeline is taken
  159. X               from the current standard input  unless  overridden  by
  160. X               the command.
  161. END_OF_FILE
  162. if test 2794 -ne `wc -c <'extended/tcllib/help/commands/open'`; then
  163.     echo shar: \"'extended/tcllib/help/commands/open'\" unpacked with wrong size!
  164. fi
  165. # end of 'extended/tcllib/help/commands/open'
  166. fi
  167. if test -f 'extended/tcllib/help/commands/regexp' -a "${1}" != "-c" ; then 
  168.   echo shar: Will not clobber existing file \"'extended/tcllib/help/commands/regexp'\"
  169. else
  170. echo shar: Extracting \"'extended/tcllib/help/commands/regexp'\" \(2353 characters\)
  171. sed "s/^X//" >'extended/tcllib/help/commands/regexp' <<'END_OF_FILE'
  172. X          regexp ?-indices? ?-nocase? exp string ?matchVar? ?subMatchVar...?
  173. X               Determines whether the regular expression  exp  matches
  174. X               part or all of string and returns 1 if it does, 0 if it
  175. X               doesn't.  See REGULAR EXPRESSIONS  above  for  complete
  176. X               information  on the syntax of exp and how it is matched
  177. X               against string.
  178. X               If the -nocase  switch  is  specified  then  upper-case
  179. X               characters  in  string are treated as lower case during
  180. X               the matching  process.   The  -nocase  switch  must  be
  181. X               specified before exp and may not be abbreviated.
  182. X
  183. X               If additional arguments are specified after string then
  184. X               they  are  treated  as the names of variables to use to
  185. X               return  information  about  which  part(s)  of   string
  186. X               matched  exp.   MatchVar  will  be  set to the range of
  187. X               string that matched all of exp.  The first  subMatchVar
  188. X               will  contain the characters in string that matched the
  189. X               leftmost parenthesized subexpression  within  exp,  the
  190. X               next  subMatchVar  will  contain  the  characters  that
  191. X               matched the next  parenthesized  subexpression  to  the
  192. X               right in exp, and so on.
  193. X
  194. X               Normally, matchVar and the subMatchVars are set to hold
  195. X               the  matching  characters from string.  However, if the
  196. X               -indices switch is specified then  each  variable  will
  197. X               contain  a  list  of  two  decimal  strings  giving the
  198. X               indices in string of the first and last  characters  in
  199. X               the  matching range of characters.  The -indices switch
  200. X               must be specified before the exp argument and  may  not
  201. X               be abbreviated.
  202. X
  203. X               If there are more more subMatchVar's than parenthesized
  204. X               subexpressions   within   exp,   or   if  a  particular
  205. X               subexpression in exp doesn't  match  the  string  (e.g.
  206. X               because  it  was  in  a  portion of the expression that
  207. X               wasn't matched),  then  the  corresponding  subMatchVar
  208. X               will be set to ``-1 -1'' if -indices has been specified
  209. X               or to an empty string otherwise.
  210. END_OF_FILE
  211. if test 2353 -ne `wc -c <'extended/tcllib/help/commands/regexp'`; then
  212.     echo shar: \"'extended/tcllib/help/commands/regexp'\" unpacked with wrong size!
  213. fi
  214. # end of 'extended/tcllib/help/commands/regexp'
  215. fi
  216. if test -f 'extended/tcllib/help/commands/regsub' -a "${1}" != "-c" ; then 
  217.   echo shar: Will not clobber existing file \"'extended/tcllib/help/commands/regsub'\"
  218. else
  219. echo shar: Extracting \"'extended/tcllib/help/commands/regsub'\" \(2319 characters\)
  220. sed "s/^X//" >'extended/tcllib/help/commands/regsub' <<'END_OF_FILE'
  221. X          regsub ?-all? ?-nocase? exp string subSpec varName
  222. X               This command matches the regular expression exp against
  223. X               string using the rules described in REGULAR EXPRESSIONS
  224. X               above.   If there is no match, then the command returns
  225. X               0 and does nothing else.  If there is a match, then the
  226. X               command  returns  1  and  also  copies  string  to  the
  227. X               variable whose name is given by varName.  When  copying
  228. X               string,  the  portion  of  string  that  matched exp is
  229. X               replaced with subSpec.  If subSpec contains a ``&''  or
  230. X               ``\0'',  then  it  is replaced in the substitution with
  231. X               the portion of string that  matched  exp.   If  subSpec
  232. X               contains  a ``\n'', where n is a digit between 1 and 9,
  233. X               then it  is  replaced  in  the  substitution  with  the
  234. X               portion  of  string that matched the n-th parenthesized
  235. X               subexpression of exp.  Additional  backslashes  may  be
  236. X               used  in  subSpec  to prevent special interpretation of
  237. X               ``&'' or ``\0'' or ``\n'' or  backslash.   The  use  of
  238. X               backslashes in subSpec tends to interact badly with the
  239. X               Tcl parser's use  of  backslashes,  so  it's  generally
  240. X               safest  to  enclose  subSpec  in  braces if it includes
  241. X               backslashes.  If the -all argument is  specified,  then
  242. X               all  ranges  in  string  that  match  exp are found and
  243. X               substitution is performed for  each  of  these  ranges;
  244. X               otherwise  only  the  first matching range is found and
  245. X               substituted.  If -all  is  specified,  then  ``&''  and
  246. X               ``\n''  sequences  are  handled  for  each substitution
  247. X               using the information from the corresponding match.  If
  248. X               the  -nocase  argument  is  specified,  then upper-case
  249. X               characters in string are converted to lower-case before
  250. X               matching against exp;  however, substitutions specified
  251. X               by subSpec use the original unconverted form of string.
  252. X               The  -all  and  -nocase  arguments  must  be  specified
  253. X               exactly:  no abbreviations are permitted.
  254. END_OF_FILE
  255. if test 2319 -ne `wc -c <'extended/tcllib/help/commands/regsub'`; then
  256.     echo shar: \"'extended/tcllib/help/commands/regsub'\" unpacked with wrong size!
  257. fi
  258. # end of 'extended/tcllib/help/commands/regsub'
  259. fi
  260. if test -f 'extended/tcllib/help/commands/uplevel' -a "${1}" != "-c" ; then 
  261.   echo shar: Will not clobber existing file \"'extended/tcllib/help/commands/uplevel'\"
  262. else
  263. echo shar: Extracting \"'extended/tcllib/help/commands/uplevel'\" \(2471 characters\)
  264. sed "s/^X//" >'extended/tcllib/help/commands/uplevel' <<'END_OF_FILE'
  265. X          uplevel ?level? command ?command ...?
  266. X               All of the command arguments  are  concatenated  as  if
  267. X               they  had  been  passed  to  concat; the result is then
  268. X               evaluated in the variable context indicated  by  level.
  269. X               Uplevel  returns  the  result  of  that evaluation.  If
  270. X               level is an integer, then it gives a distance  (up  the
  271. X               procedure  calling  stack) to move before executing the
  272. X               command.  If level consists of # followed by  a  number
  273. X               then  the  number  gives  an absolute level number.  If
  274. X               level is omitted then it defaults to 1.   Level  cannot
  275. X               be  defaulted if the first command argument starts with
  276. X               a digit or #.  For example, suppose  that  procedure  a
  277. X               was  invoked  from top-level, and that it called b, and
  278. X               that b called c.  Suppose that c  invokes  the  uplevel
  279. X               command.   If  level  is  1 or #2  or omitted, then the
  280. X               command will be executed in the variable context of  b.
  281. X               If  level  is 2 or #1 then the command will be executed
  282. X               in the variable context of a.  If level is 3 or #0 then
  283. X               the  command will be executed at top-level (only global
  284. X               variables will be visible).  The uplevel command causes
  285. X               the  invoking procedure to disappear from the procedure
  286. X               calling stack while the command is being executed.   In
  287. X               the above example, suppose c invokes the command
  288. X
  289. X                    uplevel 1 {set x 43; d}
  290. X
  291. X               where d is another Tcl procedure.  The set command will
  292. X               modify  the  variable  x  in  b's  context,  and d will
  293. X               execute at level 3, as if called from b.  If it in turn
  294. X               executes the command
  295. X
  296. X                    uplevel {set x 42}
  297. X               then the set command will modify the same variable x in
  298. X               b's  context:  the procedure c does not appear to be on
  299. X               the call stack when d is executing.  The command ``info
  300. X               level''  may be used to obtain the level of the current
  301. X               procedure.  Uplevel makes it possible to implement  new
  302. X               control  constructs  as  Tcl  procedures  (for example,
  303. X               uplevel could be used to implement the while  construct
  304. X               as a Tcl procedure).
  305. END_OF_FILE
  306. if test 2471 -ne `wc -c <'extended/tcllib/help/commands/uplevel'`; then
  307.     echo shar: \"'extended/tcllib/help/commands/uplevel'\" unpacked with wrong size!
  308. fi
  309. # end of 'extended/tcllib/help/commands/uplevel'
  310. fi
  311. if test -f 'extended/tcllib/help/extended/ctype' -a "${1}" != "-c" ; then 
  312.   echo shar: Will not clobber existing file \"'extended/tcllib/help/extended/ctype'\"
  313. else
  314. echo shar: Extracting \"'extended/tcllib/help/extended/ctype'\" \(3082 characters\)
  315. sed "s/^X//" >'extended/tcllib/help/extended/ctype' <<'END_OF_FILE'
  316. X
  317. X
  318. X          ctype class string
  319. X               Determine if all characters in string are in of the
  320. X               specified class.  Returns 1 if they are all of class
  321. X               and 0 if they are not or if the string is null. This
  322. X               command also provides another method (besides format
  323. X               and scan) of converting between an ASCII character and
  324. X               its numeric value.  The following ctype commands are
  325. X               available.
  326. X
  327. X               ctype alnum string
  328. X                    Tests that all characters are alphabetic or
  329. X                    numeric characters as defined by the character
  330. X                    set.
  331. X
  332. X               ctype alpha string
  333. X                    Tests that all characters are alphabetic
  334. X                    characters as defined by the character set.
  335. X
  336. X               ctype ascii string
  337. X                    Tests that all characters are an ASCII character
  338. X                    (a non-negative number less than 0200).
  339. X
  340. X               ctype char number
  341. X                    Converts the numeric value, string, to an ASCII
  342. X                    character.  Number must be in the range 0 through
  343. X                    255.
  344. X
  345. X               ctype cntrl string
  346. X                    Tests that all characters are ``control
  347. X                    characters'' as defined by the character set.
  348. X
  349. X               ctype digit string
  350. X                    Tests that all characters are valid decimal
  351. X                    digits, i.e. 0 through 9.
  352. X
  353. X               ctype graph string
  354. X                    Tests that all characters within are any character
  355. X                    for which ctype print is true, except for space
  356. X                    characters.
  357. X
  358. X               ctype lower string
  359. X                    Tests that all characters are lowercase letters as
  360. X                    defined by the character set.
  361. X
  362. X               ctype ord character
  363. X                    Convert a character into its decimal numeric
  364. X                    value.  The string must be one character long.
  365. X
  366. X               ctype space string
  367. X                    Tests that all characters are either a space,
  368. X                    horizontal-tab, carriage return, newline,
  369. X                    vertical-tab, or form-feed.
  370. X
  371. X               ctype print string
  372. X                    Tests that all characters are a space or any
  373. X                    character for which ctype alnum or ctype punct is
  374. X                    true or other ``printing character'' as defined by
  375. X                    the character set.
  376. X
  377. X               ctype punct string
  378. X                    Tests that all characters are made up of any of
  379. X                    the characters other than the ones for which
  380. X                    alnum, cntrl, or space is true.
  381. X
  382. X               ctype upper string
  383. X                    Tests that all characters are uppercase letters as
  384. X                    defined by the character set.
  385. X
  386. X               ctype xdigit string
  387. X                    Tests that all characters are valid hexadecimal
  388. X                    digits, that is 0 through 9, a through f or A
  389. X                    through F.
  390. END_OF_FILE
  391. if test 3082 -ne `wc -c <'extended/tcllib/help/extended/ctype'`; then
  392.     echo shar: \"'extended/tcllib/help/extended/ctype'\" unpacked with wrong size!
  393. fi
  394. # end of 'extended/tcllib/help/extended/ctype'
  395. fi
  396. if test -f 'extended/tcllib/help/extended/scanmatch' -a "${1}" != "-c" ; then 
  397.   echo shar: Will not clobber existing file \"'extended/tcllib/help/extended/scanmatch'\"
  398. else
  399. echo shar: Extracting \"'extended/tcllib/help/extended/scanmatch'\" \(2373 characters\)
  400. sed "s/^X//" >'extended/tcllib/help/extended/scanmatch' <<'END_OF_FILE'
  401. X
  402. X
  403. X          scanmatch [-nocase] contexthandle [regexp] commands
  404. X               Specify Tcl commands, to be evaluated when regexp is
  405. X               matched by a scanfile command.  The match is added to
  406. X               the scan context specified by contexthandle.  Several
  407. X               match statements may be specified for a give context.
  408. X               Regexp is a regular expression (see the regexp
  409. X               command).  If -nocase is specified as the first
  410. X               argument, the pattern is matched regardless of
  411. X               alphabetic case.
  412. X
  413. X               If regexp is not specified, then a default match is
  414. X               specified for the scan context.  The default match will
  415. X               be executed when a line of the file does not match any
  416. X               of the specified regular expressions.
  417. X
  418. X               The array, matchInfo, is available when the Tcl code is
  419. X               executed and contains information about the file being
  420. X               scanned.  It is local to the top level of the match
  421. X               command unless declared global at that level.  If it is
  422. X               to be used as a global it must be declared global
  423. X               before scanfile is called (since scanfile sets the
  424. X               matchInfo before the match code is executed, a
  425. X               subsequent global will override the local variable).
  426. X               The text of the file line that was matched is in
  427. X               matchInfo(line).  The byte offset into the file of the
  428. X               line that was matched is in matchInfo(offset).  The
  429. X               line number of the line that was matched is in
  430. X               matchInfo(linenum). This is relative to the first line
  431. X               scanned, not the first line of the file.  The first
  432. X               line is line number one.  The file handle of the file
  433. X               being scanned is in matchInfo(handle).
  434. X
  435. X          All scanmatch patterns that match a line will be processed
  436. X          in the order that the specifications were added to the scan
  437. X          context.  The remainder of the scanmatch pattern-command
  438. X          pairs may be skipped for a file line if a continue is
  439. X          executed in the match command.  If a return is executed in
  440. X          the body of the match command, the scanfile command in
  441. X          progress returns with the value passed to return as it's
  442. X          value.
  443. END_OF_FILE
  444. if test 2373 -ne `wc -c <'extended/tcllib/help/extended/scanmatch'`; then
  445.     echo shar: \"'extended/tcllib/help/extended/scanmatch'\" unpacked with wrong size!
  446. fi
  447. # end of 'extended/tcllib/help/extended/scanmatch'
  448. fi
  449. if test -f 'extended/tcllib/help/intro/syntax' -a "${1}" != "-c" ; then 
  450.   echo shar: Will not clobber existing file \"'extended/tcllib/help/intro/syntax'\"
  451. else
  452. echo shar: Extracting \"'extended/tcllib/help/intro/syntax'\" \(2552 characters\)
  453. sed "s/^X//" >'extended/tcllib/help/intro/syntax' <<'END_OF_FILE'
  454. X     BASIC COMMAND SYNTAX
  455. X          The Tcl language has syntactic similarities to both the Unix
  456. X          shells and Lisp.  However, the interpretation of commands is
  457. X          different in Tcl than in either of those other two  systems.
  458. X          A  Tcl  command  string  consists  of  one  or more commands
  459. X          separated  by  newline  characters  or  semi-colons.    Each
  460. X          command  consists  of  a  collection  of fields separated by
  461. X          white space (spaces or tabs).  The first field must  be  the
  462. X          name  of  a  command, and the additional fields, if any, are
  463. X          arguments that will be passed to that command.  For example,
  464. X          the command
  465. X
  466. X               set a 22
  467. X
  468. X          has three fields:  the first, set, is  the  name  of  a  Tcl
  469. X          command,  and  the  last  two,  a  and 22, will be passed as
  470. X          arguments to the set command.  The command  name  may  refer
  471. X          either  to  a  built-in Tcl command, an application-specific
  472. X          command   bound    in    with    the    library    procedure
  473. X          Tcl_CreateCommand,  or  a command procedure defined with the
  474. X          proc built-in command.  Arguments are  passed  literally  as
  475. X          text  strings.   Individual  commands  may  interpret  those
  476. X          strings in any fashion they  wish.   The  set  command,  for
  477. X          example,  will  treat  its  first  argument as the name of a
  478. X          variable and its second argument as a string value to assign
  479. X          to  that  variable.   For  other  commands  arguments may be
  480. X          interpreted as integers, lists, file names, or Tcl commands.
  481. X
  482. X          Command names should normally be typed completely  (e.g.  no
  483. X          abbreviations).   However,  if  the  Tcl  interpreter cannot
  484. X          locate a command it invokes a special command named  unknown
  485. X          which  attempts to find or create the command.  For example,
  486. X          at  many  sites  unknown   will   search   through   library
  487. X          directories  for  the desired command and create it as a Tcl
  488. X          procedure  if  it  is  found.   The  unknown  command  often
  489. X          provides  automatic  completion of abbreviated commands, but
  490. X          usually only for commands  that  were  typed  interactively.
  491. X          It's  probably  a  bad  idea to use abbreviations in command
  492. X          scripts and other forms that  will  be  re-used  over  time:
  493. X          changes to the command set may cause abbreviations to become
  494. X          ambiguous, resulting in scripts that no longer work.
  495. END_OF_FILE
  496. if test 2552 -ne `wc -c <'extended/tcllib/help/intro/syntax'`; then
  497.     echo shar: \"'extended/tcllib/help/intro/syntax'\" unpacked with wrong size!
  498. fi
  499. # end of 'extended/tcllib/help/intro/syntax'
  500. fi
  501. if test -f 'extended/tcllib/help/intro/variables' -a "${1}" != "-c" ; then 
  502.   echo shar: Will not clobber existing file \"'extended/tcllib/help/intro/variables'\"
  503. else
  504. echo shar: Extracting \"'extended/tcllib/help/intro/variables'\" \(2641 characters\)
  505. sed "s/^X//" >'extended/tcllib/help/intro/variables' <<'END_OF_FILE'
  506. X     VARIABLES - SCALARS AND ARRAYS
  507. X          Tcl allows the definition of variables and the use of  their
  508. X          values either through $-style variable substitution, the set
  509. X          command, or a few other mechanisms.  Variables need  not  be
  510. X          declared:  a new variable will automatically be created each
  511. X          time a new variable name is used.
  512. X
  513. X          Tcl supports two types of variables:  scalars and arrays.  A
  514. X          scalar  variable  has  a  single  value,  whereas  an  array
  515. X          variable can have any number of elements, each with  a  name
  516. X          (called  its  ``index'')  and a value.  Array indexes may be
  517. X          arbitrary strings; they need not  be  numeric.   Parentheses
  518. X          are  used  refer  to  array  elements  in Tcl commands.  For
  519. X          example, the command
  520. X
  521. X               set x(first) 44
  522. X
  523. X          will modify the element of x whose index is  first  so  that
  524. X          its   new  value  is  44.   Two-dimensional  arrays  can  be
  525. X          simulated in Tcl by  using  indexes  that  contain  multiple
  526. X          concatenated values.  For example, the commands
  527. X
  528. X               set a(2,3) 1
  529. X               set a(3,6) 2
  530. X          set the elements of a whose indexes are 2,3 and 3,6.
  531. X
  532. X          In general, array elements may be used anywhere in Tcl  that
  533. X          scalar variables may be used.  If an array is defined with a
  534. X          particular name, then there may not  be  a  scalar  variable
  535. X          with  the  same  name.   Similarly,  if  there  is  a scalar
  536. X          variable with a particular name then it is not  possible  to
  537. X          make  array references to the variable.  To convert a scalar
  538. X          variable to an array or  vice  versa,  remove  the  existing
  539. X          variable with the unset command.
  540. X
  541. X          The array command provides several features for dealing with
  542. X          arrays,  such  as  querying the names of all the elements of
  543. X          the array and searching through the array one element  at  a
  544. X          time.
  545. X
  546. X          Variables may be either global or local.  If a variable name
  547. X          is  used  when  a  procedure  isn't  being executed, then it
  548. X          automatically refers to a global variable.   Variable  names
  549. X          used  within  a  procedure normally refer to local variables
  550. X          associated with that invocation  of  the  procedure.   Local
  551. X          variables  are  deleted  whenever  a  procedure  exits.  The
  552. X          global command may be used to request that a name refer to a
  553. X          global  variable  for  the duration of the current procedure
  554. X          (this is somewhat analogous to extern in C).
  555. END_OF_FILE
  556. if test 2641 -ne `wc -c <'extended/tcllib/help/intro/variables'`; then
  557.     echo shar: \"'extended/tcllib/help/intro/variables'\" unpacked with wrong size!
  558. fi
  559. # end of 'extended/tcllib/help/intro/variables'
  560. fi
  561. if test -f 'extended/tclsrc/setfuncs.tcl' -a "${1}" != "-c" ; then 
  562.   echo shar: Will not clobber existing file \"'extended/tclsrc/setfuncs.tcl'\"
  563. else
  564. echo shar: Extracting \"'extended/tclsrc/setfuncs.tcl'\" \(2706 characters\)
  565. sed "s/^X//" >'extended/tclsrc/setfuncs.tcl' <<'END_OF_FILE'
  566. X#@package: set_functions union intersect intersect3 lrmdups
  567. X
  568. X#
  569. X# return the logical union of two lists, removing any duplicates
  570. X#
  571. Xproc union {lista listb} {
  572. X    set full_list [lsort [concat $lista $listb]]
  573. X    set check_element [lindex $full_list 0]
  574. X    set outlist $check_element
  575. X    foreach element [lrange $full_list 1 end] {
  576. X    if {$check_element == $element} continue
  577. X    lappend outlist $element
  578. X    set check_element $element
  579. X    }
  580. X    return $outlist
  581. X}
  582. X
  583. X#
  584. X# sort a list, returning the sorted version minus any duplicates
  585. X#
  586. Xproc lrmdups {list} {
  587. X    # guarantee last doesn't match the first element
  588. X    set last "NOMATCH[lindex $list 0]"
  589. X    set result ""
  590. X    foreach element [lsort $list] {
  591. X    if {$last != $element} {
  592. X        lappend result $element
  593. X        set last $element
  594. X    }
  595. X    }
  596. X    return $result
  597. X}
  598. X
  599. X#
  600. X# intersect3 - perform the intersecting of two lists, returning a list
  601. X# containing three lists.  The first list is everything in the first
  602. X# list that wasn't in the second, the second list contains the intersection
  603. X# of the two lists, the third list contains everything in the second list
  604. X# that wasn't in the first.
  605. X#
  606. X
  607. Xproc intersect3 {list1 list2} {
  608. X    set list1Result ""
  609. X    set list2Result ""
  610. X    set intersectList ""
  611. X
  612. X    set list1 [lrmdups $list1]
  613. X    set list2 [lrmdups $list2]
  614. X
  615. X    while {1} {
  616. X        if [lempty $list1] {
  617. X            if ![lempty $list2] {
  618. X                set list2Result [concat $list2Result $list2]
  619. X            }
  620. X            break
  621. X        }
  622. X        if [lempty $list2] {
  623. X        set list1Result [concat $list1Result $list1]
  624. X            break
  625. X        }
  626. X        set compareResult [string compare [lindex $list1 0] [lindex $list2 0]]
  627. X
  628. X        if {$compareResult < 0} {
  629. X            lappend list1Result [lvarpop list1]
  630. X            continue
  631. X        }
  632. X        if {$compareResult > 0} {
  633. X            lappend list2Result [lvarpop list2]
  634. X            continue
  635. X        }
  636. X        lappend intersectList [lvarpop list1]
  637. X        lvarpop list2
  638. X    }
  639. X    return [list $list1Result $intersectList $list2Result]
  640. X}
  641. X
  642. X#
  643. X# intersect - perform an intersection of two lists, returning a list
  644. X# containing every element that was present in both lists
  645. X#
  646. Xproc intersect {list1 list2} {
  647. X    set intersectList ""
  648. X
  649. X    set list1 [lsort $list1]
  650. X    set list2 [lsort $list2]
  651. X
  652. X    while {1} {
  653. X        if {[lempty $list1] || [lempty $list2]} break
  654. X
  655. X        set compareResult [string compare [lindex $list1 0] [lindex $list2 0]]
  656. X
  657. X        if {$compareResult < 0} {
  658. X            lvarpop list1
  659. X            continue
  660. X        }
  661. X
  662. X        if {$compareResult > 0} {
  663. X            lvarpop list2
  664. X            continue
  665. X        }
  666. X
  667. X        lappend intersectList [lvarpop list1]
  668. X        lvarpop list2
  669. X    }
  670. X    return $intersectList
  671. X}
  672. X
  673. END_OF_FILE
  674. if test 2706 -ne `wc -c <'extended/tclsrc/setfuncs.tcl'`; then
  675.     echo shar: \"'extended/tclsrc/setfuncs.tcl'\" unpacked with wrong size!
  676. fi
  677. # end of 'extended/tclsrc/setfuncs.tcl'
  678. fi
  679. if test -f 'extended/tests/loop.test' -a "${1}" != "-c" ; then 
  680.   echo shar: Will not clobber existing file \"'extended/tests/loop.test'\"
  681. else
  682. echo shar: Extracting \"'extended/tests/loop.test'\" \(2692 characters\)
  683. sed "s/^X//" >'extended/tests/loop.test' <<'END_OF_FILE'
  684. X#
  685. X# loop.test
  686. X#
  687. X# Tests for the loop command.
  688. X#---------------------------------------------------------------------------
  689. X# Copyright 1991 Karl Lehenbauer and Mark Diekhans.
  690. X#
  691. X# Permission to use, copy, modify, and distribute this software and its
  692. X# documentation for any purpose and without fee is hereby granted, provided
  693. X# that the above copyright notice appear in all copies.  Karl Lehenbauer and
  694. X# Mark Diekhans make no representations about the suitability of this
  695. X# software for any purpose.  It is provided "as is" without express or
  696. X# implied warranty.
  697. X#
  698. X
  699. Xglobal ModuleName
  700. Xset ModuleName "loop"
  701. Xsource testutil.tcl
  702. X
  703. X# Check "loop" and its use of continue and break.
  704. X
  705. Xset a {}
  706. Xset i 1
  707. Xloop i 1 6 {
  708. X    set a [concat $a $i]
  709. X    set i [expr $i+1]
  710. X}
  711. Xcheck $a {1 2 3 4 5} 1.1
  712. X
  713. Xset a {}
  714. Xloop i 1 6 {
  715. X    if $i==4 {set i [expr $i+1];continue}
  716. X    set a [concat $a $i]
  717. X    set i [expr $i+1]
  718. X}
  719. Xcheck $a {1 2 3 5} 1.2
  720. X
  721. Xset a {}
  722. Xloop i 1 6 {
  723. X    if $i==4 break
  724. X    set a [concat $a $i]
  725. X    set i [expr $i+1]
  726. X}
  727. X
  728. Xcheck $a {1 2 3} 1.3
  729. Xdo1cmd {loop 1 2 3} msg 1.4
  730. Xset b {wrong # args: loop var lo hi [incr] command}
  731. Xcheck $msg $b 1.4
  732. Xdo1cmd {loop 1 2 3 4 5 6} msg 1.5
  733. Xcheck $msg $b 1.5
  734. X
  735. Xset a {xyz}
  736. Xloop i 1 6 {
  737. X    set i [expr $i+1]
  738. X}
  739. Xcheck $a xyz 1.6
  740. X
  741. Xset a {}
  742. Xloop i 1 6 {
  743. X    set a [concat $a $i]
  744. X    set i [expr $i+1]
  745. X    if $i==4 break
  746. X}
  747. Xcheck $a {1 2 3} 1.7
  748. X
  749. Xset a {}
  750. Xset i 1
  751. Xloop i 1 6 1 {
  752. X    set a [concat $a $i]
  753. X    set i [expr $i+1]
  754. X}
  755. Xcheck $a {1 2 3 4 5} 2.1
  756. X
  757. Xset a {}
  758. Xloop i 1 6 1 {
  759. X    if $i==4 {set i [expr $i+1];continue}
  760. X    set a [concat $a $i]
  761. X    set i [expr $i+1]
  762. X}
  763. Xcheck $a {1 2 3 5} 2.2
  764. X
  765. Xset a {}
  766. Xloop i 1 6 1 {
  767. X    if $i==4 break
  768. X    set a [concat $a $i]
  769. X    set i [expr $i+1]
  770. X}
  771. Xcheck $a {1 2 3} 2.3
  772. X
  773. Xset a {xyz}
  774. Xloop i 1 6 1 {
  775. X    set i [expr $i+1]
  776. X}
  777. Xcheck $a xyz 2.4
  778. X
  779. Xset a {}
  780. Xloop i 1 6 1 {
  781. X    set a [concat $a $i]
  782. X    set i [expr $i+1]
  783. X    if $i==4 break
  784. X}
  785. Xcheck $a {1 2 3} 2.5
  786. X
  787. Xset a {}
  788. Xset i 1
  789. Xloop i 6 1 -1 {
  790. X    set a [concat $a $i]
  791. X    set i [expr $i+1]
  792. X}
  793. Xcheck $a {6 5 4 3 2} 3.1
  794. X
  795. Xset a {}
  796. Xloop i 6 1 -1 {
  797. X    if $i==4 {set i [expr $i+1];continue}
  798. X    set a [concat $a $i]
  799. X    set i [expr $i+1]
  800. X}
  801. Xcheck $a {6 5 3 2} 3.2
  802. X
  803. Xset a {}
  804. Xloop i 6 1 -1 {
  805. X    if $i==4 break
  806. X    set a [concat $a $i]
  807. X    set i [expr $i+1]
  808. X}
  809. Xcheck $a {6 5} 3.3
  810. X
  811. Xset a {xyz}
  812. Xloop i 6 1 -1 {
  813. X    set i [expr $i+1]
  814. X}
  815. Xcheck $a xyz 3.4
  816. X
  817. Xset a {}
  818. Xloop i 6 1 -1 {
  819. X    if $i==4 break
  820. X    set a [concat $a $i]
  821. X    set i [expr $i+1]
  822. X}
  823. Xcheck $a {6 5} 3.5
  824. X
  825. Xset j 0
  826. Xloop i 65536 65556 {
  827. X    incr j
  828. X}
  829. Xcheck $j 20 4.1
  830. X
  831. Xset j 0
  832. Xloop i 65556 65536 -1 {
  833. X    incr j 1
  834. X}
  835. Xcheck $j 20 4.2
  836. X
  837. Xset j 0
  838. Xloop i 0 655360 65536 {
  839. X    incr j 1
  840. X}
  841. Xcheck $j 10 4.3
  842. X
  843. Xset j 0
  844. Xloop i 655360 0 -65536 {
  845. X    incr j 1
  846. X}
  847. Xcheck $j 10 4.4
  848. X
  849. END_OF_FILE
  850. if test 2692 -ne `wc -c <'extended/tests/loop.test'`; then
  851.     echo shar: \"'extended/tests/loop.test'\" unpacked with wrong size!
  852. fi
  853. # end of 'extended/tests/loop.test'
  854. fi
  855. if test -f 'extended/tests/select.test' -a "${1}" != "-c" ; then 
  856.   echo shar: Will not clobber existing file \"'extended/tests/select.test'\"
  857. else
  858. echo shar: Extracting \"'extended/tests/select.test'\" \(2818 characters\)
  859. sed "s/^X//" >'extended/tests/select.test' <<'END_OF_FILE'
  860. X#
  861. X# select.test
  862. X#
  863. X# Tests for the select command.
  864. X#---------------------------------------------------------------------------
  865. X# Copyright 1991 Karl Lehenbauer and Mark Diekhans.
  866. X#
  867. X# Permission to use, copy, modify, and distribute this software and its
  868. X# documentation for any purpose and without fee is hereby granted, provided
  869. X# that the above copyright notice appear in all copies.  Karl Lehenbauer and
  870. X# Mark Diekhans make no representations about the suitability of this
  871. X# software for any purpose.  It is provided "as is" without express or
  872. X# implied warranty.
  873. X#
  874. Xif {[info procs test] != "test"} then {source defs}
  875. X
  876. Xcatch {select} msg
  877. Xif {"$msg" == "select is not available on this version of Unix"} {
  878. X    echo "**** $msg"
  879. X    echo "**** tests skipped"
  880. X    return
  881. X}
  882. X
  883. Xpipe pipe1ReadFh pipe1WriteFh
  884. Xfcntl $pipe1ReadFh  nobuf 1
  885. Xfcntl $pipe1WriteFh nobuf 1
  886. X
  887. Xpipe pipe2ReadFh pipe2WriteFh
  888. Xfcntl $pipe2ReadFh  nobuf 1
  889. Xfcntl $pipe2WriteFh nobuf 1
  890. X
  891. Xset pipeReadList   [list $pipe1ReadFh  $pipe2ReadFh]
  892. Xset pipeWriteList  [list $pipe1WriteFh $pipe2WriteFh]
  893. X
  894. Xtest iocmds-1.1 {select tests} {
  895. X    select $pipeReadList $pipeWriteList {} 0.5
  896. X} [list {} $pipeWriteList {}]
  897. X
  898. Xtest iocmds-1.2 {select tests} {
  899. X    puts $pipe1WriteFh "Written to pipe 1"
  900. X    set ret [select $pipeReadList $pipeWriteList {} 0.5]
  901. X    list $ret [gets $pipe1ReadFh]
  902. X} [list [list $pipe1ReadFh $pipeWriteList {}] "Written to pipe 1"]
  903. X
  904. Xtest iocmds-1.3 {select tests} {
  905. X    puts $pipe2WriteFh "Written to pipe 2"
  906. X    set ret [select $pipeReadList $pipeWriteList {} 0.5]
  907. X    list $ret [gets $pipe2ReadFh]
  908. X} [list [list $pipe2ReadFh $pipeWriteList {}] "Written to pipe 2"]
  909. X
  910. Xtest iocmds-1.4 {select tests} {
  911. X    puts $pipe1WriteFh "Written to pipe 1"
  912. X    puts $pipe2WriteFh "Written to pipe 2"
  913. X    set ret [select $pipeReadList $pipeWriteList {} 0.5]
  914. X    list $ret [gets $pipe1ReadFh] [gets $pipe2ReadFh]
  915. X}  [list [list $pipeReadList $pipeWriteList {}] "Written to pipe 1" \
  916. X         "Written to pipe 2"]
  917. X
  918. Xtest iocmds-1.5 {select tests} {
  919. X    select $pipeReadList $pipeWriteList {} 0
  920. X} [list {} $pipeWriteList {}]
  921. X
  922. Xtest iocmds-1.6 {select tests} {
  923. X    puts $pipe1WriteFh "Written to pipe 1"
  924. X    set ret [select $pipeReadList $pipeWriteList]
  925. X    list $ret [gets $pipe1ReadFh]
  926. X} [list [list $pipe1ReadFh $pipeWriteList {}] "Written to pipe 1"]
  927. X
  928. Xtest iocmds-1.7 {select tests} {
  929. X    puts $pipe1WriteFh "Written to pipe 1"
  930. X    set ret [select $pipeReadList $pipeWriteList {} 0]
  931. X    list $ret [gets $pipe1ReadFh]
  932. X} [list [list $pipe1ReadFh $pipeWriteList {}] "Written to pipe 1"]
  933. X
  934. Xtest iocmds-1.8 {select tests} {
  935. X    list [catch {select foo $pipeWriteList {} 0} msg] $msg
  936. X} {1 {bad file identifier "foo"}}
  937. X
  938. Xtest iocmds-1.8 {select tests} {
  939. X    list [catch {select $pipeReadList $pipeWriteList {} X} msg] $msg
  940. X} {1 {expected floating-point number but got "X"}}
  941. X
  942. END_OF_FILE
  943. if test 2818 -ne `wc -c <'extended/tests/select.test'`; then
  944.     echo shar: \"'extended/tests/select.test'\" unpacked with wrong size!
  945. fi
  946. # end of 'extended/tests/select.test'
  947. fi
  948. if test -f 'extended/tests/setfuncs.test' -a "${1}" != "-c" ; then 
  949.   echo shar: Will not clobber existing file \"'extended/tests/setfuncs.test'\"
  950. else
  951. echo shar: Extracting \"'extended/tests/setfuncs.test'\" \(3165 characters\)
  952. sed "s/^X//" >'extended/tests/setfuncs.test' <<'END_OF_FILE'
  953. X#
  954. X# setfuncs.test
  955. X#
  956. X# Tests for tcl.tlib set functions.
  957. X#---------------------------------------------------------------------------
  958. X# Copyright 1991 Karl Lehenbauer and Mark Diekhans.
  959. X#
  960. X# Permission to use, copy, modify, and distribute this software and its
  961. X# documentation for any purpose and without fee is hereby granted, provided
  962. X# that the above copyright notice appear in all copies.  Karl Lehenbauer and
  963. X# Mark Diekhans make no representations about the suitability of this
  964. X# software for any purpose.  It is provided "as is" without express or
  965. X# implied warranty.
  966. X#
  967. X
  968. Xif {[string compare test [info procs test]] == 1} then {source defs}
  969. Xrename SAVED_UNKNOWN unknown
  970. X
  971. Xtest setfuncs-1.1 {union command} {
  972. X    union "" ""
  973. X} ""
  974. X
  975. Xtest setfuncs-1.2 {union command} {
  976. X    union a ""
  977. X} "a"
  978. X
  979. Xtest setfuncs-1.3 {union command} {
  980. X    union "a b" "b c"
  981. X} "a b c"
  982. X
  983. Xtest setfuncs-1.4 {union command} {
  984. X    union "a b c d" "a b c d"
  985. X} "a b c d"
  986. X
  987. Xtest setfuncs-1.5 {union command} {
  988. X    union "a d c d b" "b d c a a b d a b c d"
  989. X} "a b c d"
  990. X
  991. Xtest setfuncs-1.6 {union command} {
  992. X    union "d c b a e f" ""
  993. X} "a b c d e f"
  994. X
  995. Xtest setfuncs-1.7 {union command} {
  996. X    union "" "f e d c b a"
  997. X} "a b c d e f"
  998. X
  999. Xtest setfuncs-1.8 {union command} {
  1000. X    union "{n p}" "f e d c b a"
  1001. X} "a b c d e f {n p}"
  1002. X
  1003. Xtest setfuncs-1.9 {union command} {
  1004. X    union "{n p}" "f e d c {n p} b a"
  1005. X} "a b c d e f {n p}"
  1006. X
  1007. Xtest setfuncs-1.10 {union command} {
  1008. X    union "{n p} z {n p} z" "f e d c {n p} b a"
  1009. X} "a b c d e f {n p} z"
  1010. X
  1011. X
  1012. Xtest setfuncs-2.1 {intersect command} {
  1013. X    intersect "" ""
  1014. X} ""
  1015. X
  1016. Xtest setfuncs-2.2 {intersect command} {
  1017. X    intersect "a b c" ""
  1018. X} ""
  1019. X
  1020. Xtest setfuncs-2.3 {intersect command} {
  1021. X    intersect "" "a b c"
  1022. X} ""
  1023. X
  1024. Xtest setfuncs-2.4 {intersect command} {
  1025. X    intersect "d f b" "a b c"
  1026. X} "b"
  1027. X
  1028. Xtest setfuncs-2.5 {intersect command} {
  1029. X    intersect "a p q d v m b n o z t d f b" "a b c"
  1030. X} "a b"
  1031. X
  1032. Xtest setfuncs-2.6 {intersect command} {
  1033. X    intersect "d c b a e f" "{n p}"
  1034. X} ""
  1035. X
  1036. Xtest setfuncs-2.7 {intersect command} {
  1037. X    intersect "d c" "f e d c b a"
  1038. X} "c d"
  1039. X
  1040. Xtest setfuncs-2.8 {intersect command} {
  1041. X    intersect "a f {n p} e" "f e d c b a"
  1042. X} "a e f"
  1043. X
  1044. Xtest setfuncs-2.9 {intersect command} {
  1045. X    intersect "{n p} f d" "f e d c {n p} b a"
  1046. X} "d f {n p}"
  1047. X
  1048. Xtest setfuncs-2.10 {intersect command} {
  1049. X    intersect "{n p} z {n p} z" "f e d c {n p} b a"
  1050. X} "{n p}"
  1051. X
  1052. Xtest setfuncs-3.1 {intersect3 command} {
  1053. X    intersect3 "" ""
  1054. X} "{} {} {}"
  1055. X
  1056. Xtest setfuncs-3.2 {intersect3 command} {
  1057. X    intersect3 "a b c" ""
  1058. X} "{a b c} {} {}"
  1059. X
  1060. Xtest setfuncs-3.3 {intersect3 command} {
  1061. X    intersect3 "" "a b c"
  1062. X} "{} {} {a b c}"
  1063. X
  1064. Xtest setfuncs-3.4 {intersect3 command} {
  1065. X    intersect3 "d f b" "a b c"
  1066. X} "{d f} b {a c}"
  1067. X
  1068. Xtest setfuncs-3.5 {intersect3 command} {
  1069. X    intersect3 "a p q d v m b n o z t d f b" "a b c"
  1070. X} "{d f m n o p q t v z} {a b} c"
  1071. X
  1072. Xtest setfuncs-4.1 {lrmdups command} {
  1073. X    lrmdups {a d b c eee b d 1}
  1074. X} {1 a b c d eee}
  1075. X
  1076. Xtest setfuncs-4.2 {lrmdups command} {
  1077. X    lrmdups {aaa aaa aaaa aaa aaa }
  1078. X} {aaa aaaa}
  1079. X
  1080. Xtest setfuncs-4.3 {lrmdups command} {
  1081. X    lrmdups {{} aaa {} aaa aaa }
  1082. X} {{} aaa}
  1083. X
  1084. Xtest setfuncs-4.4 {lrmdups command} {
  1085. X    lrmdups {aaa}
  1086. X} {aaa}
  1087. X
  1088. Xrename unknown SAVED_UNKNOWN
  1089. X
  1090. END_OF_FILE
  1091. if test 3165 -ne `wc -c <'extended/tests/setfuncs.test'`; then
  1092.     echo shar: \"'extended/tests/setfuncs.test'\" unpacked with wrong size!
  1093. fi
  1094. # end of 'extended/tests/setfuncs.test'
  1095. fi
  1096. if test -f 'extended/tests/string.test' -a "${1}" != "-c" ; then 
  1097.   echo shar: Will not clobber existing file \"'extended/tests/string.test'\"
  1098. else
  1099. echo shar: Extracting \"'extended/tests/string.test'\" \(3025 characters\)
  1100. sed "s/^X//" >'extended/tests/string.test' <<'END_OF_FILE'
  1101. X#
  1102. X# string.test
  1103. X#
  1104. X# Tests for the cindex, clength, crange, replicate, csubstr, and translit
  1105. X# commands.
  1106. X#---------------------------------------------------------------------------
  1107. X# Copyright 1991 Karl Lehenbauer and Mark Diekhans.
  1108. X#
  1109. X# Permission to use, copy, modify, and distribute this software and its
  1110. X# documentation for any purpose and without fee is hereby granted, provided
  1111. X# that the above copyright notice appear in all copies.  Karl Lehenbauer and
  1112. X# Mark Diekhans make no representations about the suitability of this
  1113. X# software for any purpose.  It is provided "as is" without express or
  1114. X# implied warranty.
  1115. X#
  1116. Xif {[info procs test] != "test"} then {source defs}
  1117. X
  1118. X# Test the 'cindex' command.
  1119. X
  1120. Xtest string-1.1 {cindex tests} {
  1121. X    cindex ABCDEFG 1
  1122. X} {B}
  1123. X
  1124. Xtest string-1.2 {cindex tests} {
  1125. X    cindex ABCDEFG 4
  1126. X} {E}
  1127. X
  1128. Xtest string-1.3 {cindex tests} {
  1129. X    cindex ABCDEFG 6
  1130. X} {G}
  1131. X
  1132. Xtest string-1.4 {cindex tests} {
  1133. X    cindex ABCDEFG 7
  1134. X} {}
  1135. X
  1136. X# Test the 'clength' command.
  1137. X
  1138. Xtest string-2.1 {clength tests} {
  1139. X    clength ABCDEFG
  1140. X} {7}
  1141. X
  1142. Xtest string-2.2 {clength tests} {
  1143. X    clength "ABCD XYZ"
  1144. X} {8}
  1145. X
  1146. Xtest string-2.3 {clength tests} {
  1147. X    list [catch {clength} msg] $msg
  1148. X} {1 {wrong # args: clength string}}
  1149. X
  1150. X# Test the crange command.
  1151. X
  1152. Xtest string-3.1 {crange tests} {
  1153. X    crange ABCDEFG 1 3
  1154. X} {BCD}
  1155. X
  1156. Xtest string-3.2 {crange tests} {
  1157. X    crange ABCDEFG 2 end
  1158. X} {CDEFG}
  1159. X
  1160. Xtest string-3.3 {crange tests} {
  1161. X    set foo [replicate ABCD 500]
  1162. X    crange $foo 100 499 
  1163. X} [replicate ABCD 100]
  1164. X
  1165. Xtest string-3.4 {crange tests} {
  1166. X    list [catch {crange} msg] $msg
  1167. X} {1 {wrong # args: crange string first last}}
  1168. X
  1169. Xtest string-3.5 {crange tests} {
  1170. X    crange ABCD 4 1
  1171. X} {}
  1172. X
  1173. X# Test the 'replicate' command
  1174. X
  1175. Xtest string-4.1 {replicate tests} {
  1176. X    replicate AbCd 4
  1177. X} {AbCdAbCdAbCdAbCd}
  1178. X
  1179. Xtest string-4.2 {replicate tests} {
  1180. X    replicate X 1000
  1181. X} "[replicate X 250][replicate X 250][replicate X 250][replicate X 250]"
  1182. X
  1183. Xtest string-4.3 {replicate tests} {
  1184. X    list [catch {replicate X} msg] $msg
  1185. X} {1 {wrong # args: replicate string count}}
  1186. X
  1187. X# Test the csubstr command.
  1188. X
  1189. Xtest string-5.1 {csubstr tests} {
  1190. X    csubstr ABCDEFG 1 3
  1191. X} {BCD}
  1192. X
  1193. Xtest string-5.2 {csubstr tests} {
  1194. X    csubstr ABCDEFG 2 end
  1195. X} {CDEFG}
  1196. X
  1197. Xtest string-5.3 {csubstr tests} {
  1198. X    set foo [replicate ABCD 500]
  1199. X    csubstr $foo 100 400
  1200. X} [replicate ABCD 100]
  1201. X
  1202. Xtest string-5.4 {csubstr tests} {
  1203. X    list [catch {csubstr} msg] $msg
  1204. X} {1 {wrong # args: csubstr string first length}}
  1205. X
  1206. Xtest string-5.5 {csubstr tests} {
  1207. X    csubstr ABCD 4 1
  1208. X} {}
  1209. X
  1210. Xtest string-5.6 {translit tests} {
  1211. X    set str "Captain Midnight Secret Decoder Ring"
  1212. X    translit {A-MN-Za-mn-z} {N-ZA-Mn-za-m} $str
  1213. X} {Pncgnva Zvqavtug Frperg Qrpbqre Evat}
  1214. X
  1215. Xtest string-5.7 {translit tests} {
  1216. X    set str "Captain Midnight Secret Decoder Ring"
  1217. X    set str2 [translit {A-MN-Za-mn-z} {N-ZA-Mn-za-m} $str]
  1218. X    translit {A-MN-Za-mn-z} {N-ZA-Mn-za-m} $str2
  1219. X} {Captain Midnight Secret Decoder Ring}
  1220. X
  1221. Xtest string-5.8 {translit tests} {
  1222. X    list [catch {translit} msg] $msg
  1223. X} {1 {wrong # args: translit from to string}}
  1224. X
  1225. END_OF_FILE
  1226. if test 3025 -ne `wc -c <'extended/tests/string.test'`; then
  1227.     echo shar: \"'extended/tests/string.test'\" unpacked with wrong size!
  1228. fi
  1229. # end of 'extended/tests/string.test'
  1230. fi
  1231. if test -f 'extended/tests/testutil.tcl' -a "${1}" != "-c" ; then 
  1232.   echo shar: Will not clobber existing file \"'extended/tests/testutil.tcl'\"
  1233. else
  1234. echo shar: Extracting \"'extended/tests/testutil.tcl'\" \(2468 characters\)
  1235. sed "s/^X//" >'extended/tests/testutil.tcl' <<'END_OF_FILE'
  1236. X# testutil.tcl --
  1237. X#
  1238. X# Utility procedures for TCL test packages.  These procedures all expect a 
  1239. X# global "ModuleName" to be define, which contains the name of the test package
  1240. X# being run.  This may be a short string.
  1241. X
  1242. X
  1243. X# Check that a value is equal to what was expected.  If not, generate
  1244. X# an error
  1245. X
  1246. Xproc check {got expect idnum} {
  1247. X    global ModuleName currentTestNumber
  1248. X    set currentTestNumber $idnum
  1249. X    if {"$got" != "$expect"} {
  1250. X        echo [replicate "-" 70]
  1251. X        echo [format {%s test error %s: wanted "%s", got "%s"} \
  1252. X               $ModuleName $idnum $expect $got]
  1253. X        echo [replicate "-" 70]
  1254. X    }
  1255. X}
  1256. X
  1257. X
  1258. X# Check that a numeric value is equal to what was expected.  If not, generate
  1259. X# an error
  1260. X
  1261. Xproc checknum {got expect idnum} {
  1262. X    global ModuleName currentTestNumber
  1263. X    set currentTestNumber $idnum
  1264. X    if {$got != $expect} {
  1265. X        echo [replicate "-" 70]
  1266. X        echo [format {%s test error %s: wanted "%s", got "%s"} \
  1267. X              $ModuleName $idnum $expect $got]
  1268. X        echo [replicate "-" 70]
  1269. X    }
  1270. X}
  1271. X
  1272. X# Run and verify a command that should return TCL_ERROR, pass back the returned
  1273. X# error message
  1274. X
  1275. Xproc do1cmd {cmd msgvar idnum} {
  1276. X    global ModuleName currentTestCommand currentTestNumber
  1277. X    set currentTestCommand $cmd
  1278. X    set currentTestNumber $idnum
  1279. X    if {[catch {uplevel $cmd} msg] != 1} {
  1280. X        echo [replicate "-" 70]
  1281. X        echo [format {%s test error %s: No error returned: %s} \
  1282. X              $ModuleName $idnum $cmd]
  1283. X        echo [replicate "-" 70]
  1284. X    }
  1285. X    uplevel set $msgvar [list $msg]
  1286. X}
  1287. X
  1288. X
  1289. X# Increment a name.  This takes a name and "adds one" to it, that is advancing
  1290. X# each digit lexically through "0"..."9" -> "A"-"Z" -> "a"..."z".  When one
  1291. X# digit wraps, the next one is advanced.  Optional arg forces upper case only
  1292. X# if true and start with all upper case or digits.
  1293. X
  1294. Xproc IncrName {Name args} {
  1295. X    set Upper [expr {([llength $args] == 1) && [lindex $args 0]}]
  1296. X    set Last  [expr [clength $Name]-1]
  1297. X    set Begin [csubstr $Name 0 $Last]
  1298. X    set Digit [cindex $Name $Last]
  1299. X    set Recurse 0
  1300. X    case $Digit in {
  1301. X        {9}     {set Digit A}
  1302. X        {Z}     {if {$Upper} {set Recurse 1} else {set Digit a}}
  1303. X        {z}     {set Recurse 1}
  1304. X        default {set Digit [ctype char [expr [ctype ord $Digit]+1]]}
  1305. X    }
  1306. X    if {$Recurse} {
  1307. X        if {$Last == 0} then {
  1308. X            return 0 ;# Wrap around
  1309. X        } else {
  1310. X            return "[IncrName $Begin]0"
  1311. X        }
  1312. X    }
  1313. X    return "$Begin$Digit"
  1314. X}
  1315. X
  1316. X
  1317. END_OF_FILE
  1318. if test 2468 -ne `wc -c <'extended/tests/testutil.tcl'`; then
  1319.     echo shar: \"'extended/tests/testutil.tcl'\" unpacked with wrong size!
  1320. fi
  1321. # end of 'extended/tests/testutil.tcl'
  1322. fi
  1323. echo shar: End of archive 6 \(of 23\).
  1324. cp /dev/null ark6isdone
  1325. MISSING=""
  1326. 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 ; do
  1327.     if test ! -f ark${I}isdone ; then
  1328.     MISSING="${MISSING} ${I}"
  1329.     fi
  1330. done
  1331. if test "${MISSING}" = "" ; then
  1332.     echo You have unpacked all 23 archives.
  1333.     echo "Now cd to "extended", edit the makefile, then do a "make""
  1334.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1335. else
  1336.     echo You still need to unpack the following archives:
  1337.     echo "        " ${MISSING}
  1338. fi
  1339. ##  End of shell archive.
  1340. exit 0
  1341.  
  1342. exit 0 # Just in case...
  1343. -- 
  1344. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1345. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1346. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1347. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1348.