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

  1. Newsgroups: comp.sources.misc
  2. From: karl@sugar.neosoft.com (Karl Lehenbauer)
  3. Subject:  v26i008:  tclx - extensions and on-line help for tcl 6.1, Part08/23
  4. Message-ID: <1991Nov19.005438.8786@sparky.imd.sterling.com>
  5. X-Md4-Signature: bfcbd47886d3f1ec60c297ee541d3826
  6. Date: Tue, 19 Nov 1991 00:54:38 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
  10. Posting-number: Volume 26, Issue 8
  11. Archive-name: tclx/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 23)."
  21. # Contents:  extended/man/CreateExte.man extended/src/general.c
  22. #   extended/src/math.c extended/src/tcl++.C extended/src/tclExtend.h
  23. #   extended/tcllib/TclInit.tcl extended/tcllib/help/commands/file
  24. #   extended/tcllib/help/intro/regexps extended/tests/cmdtrace.test
  25. # Wrapped by karl@one on Wed Nov 13 21:50:20 1991
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'extended/man/CreateExte.man' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'extended/man/CreateExte.man'\"
  29. else
  30. echo shar: Extracting \"'extended/man/CreateExte.man'\" \(4315 characters\)
  31. sed "s/^X//" >'extended/man/CreateExte.man' <<'END_OF_FILE'
  32. X.\"----------------------------------------------------------------------------
  33. X.\" The definitions below are for supplemental macros used in Sprite
  34. X.\" manual entries.
  35. X.\"
  36. X.\" .HS name section [date [version]]
  37. X.\"    Replacement for .TH in other man pages.  See below for valid
  38. X.\"    section names.
  39. X.\"
  40. X.\" .AP type name in/out [indent]
  41. X.\"    Start paragraph describing an argument to a library procedure.
  42. X.\"    type is type of argument (int, etc.), in/out is either "in", "out",
  43. X.\"    or "in/out" to describe whether procedure reads or modifies arg,
  44. X.\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  45. X.\"    needed;  use .AS below instead)
  46. X.\"
  47. X.\" .AS [type [name]]
  48. X.\"    Give maximum sizes of arguments for setting tab stops.  Type and
  49. X.\"    name are examples of largest possible arguments that will be passed
  50. X.\"    to .AP later.  If args are omitted, default tab stops are used.
  51. X.\"
  52. X.\" .BS
  53. X.\"    Start box enclosure.  From here until next .BE, everything will be
  54. X.\"    enclosed in one large box.
  55. X.\"
  56. X.\" .BE
  57. X.\"    End of box enclosure.
  58. X.\"
  59. X.\" .VS
  60. X.\"    Begin vertical sidebar, for use in marking newly-changed parts
  61. X.\"    of man pages.
  62. X.\"
  63. X.\" .VE
  64. X.\"    End of vertical sidebar.
  65. X.\"
  66. X.\" .DS
  67. X.\"    Begin an indented unfilled display.
  68. X.\"
  69. X.\" .DE
  70. X.\"    End of indented unfilled display.
  71. X.\"
  72. X'    # Heading for Sprite man pages
  73. X.de HS
  74. X.if '\\$2'cmds'       .TH \\$1 1 \\$3 \\$4
  75. X.if '\\$2'lib'        .TH \\$1 3 \\$3 \\$4
  76. X.if '\\$2'tcl'        .TH \\$1 3 \\$3 \\$4
  77. X.if '\\$2'tk'         .TH \\$1 3 \\$3 \\$4
  78. X.if t .wh -1.3i ^B
  79. X.nr ^l \\n(.l
  80. X.ad b
  81. X..
  82. X'    # Start an argument description
  83. X.de AP
  84. X.ie !"\\$4"" .TP \\$4
  85. X.el \{\
  86. X.   ie !"\\$2"" .TP \\n()Cu
  87. X.   el          .TP 15
  88. X.\}
  89. X.ie !"\\$3"" \{\
  90. X.ta \\n()Au \\n()Bu
  91. X\&\\$1    \\fI\\$2\\fP    (\\$3)
  92. X.\".b
  93. X.\}
  94. X.el \{\
  95. X.br
  96. X.ie !"\\$2"" \{\
  97. X\&\\$1    \\fI\\$2\\fP
  98. X.\}
  99. X.el \{\
  100. X\&\\fI\\$1\\fP
  101. X.\}
  102. X.\}
  103. X..
  104. X'    # define tabbing values for .AP
  105. X.de AS
  106. X.nr )A 10n
  107. X.if !"\\$1"" .nr )A \\w'\\$1'u+3n
  108. X.nr )B \\n()Au+15n
  109. X.\"
  110. X.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  111. X.nr )C \\n()Bu+\\w'(in/out)'u+2n
  112. X..
  113. X'    # BS - start boxed text
  114. X'    # ^y = starting y location
  115. X'    # ^b = 1
  116. X.de BS
  117. X.br
  118. X.mk ^y
  119. X.nr ^b 1u
  120. X.if n .nf
  121. X.if n .ti 0
  122. X.if n \l'\\n(.lu\(ul'
  123. X.if n .fi
  124. X..
  125. X'    # BE - end boxed text (draw box now)
  126. X.de BE
  127. X.nf
  128. X.ti 0
  129. X.mk ^t
  130. X.ie n \l'\\n(^lu\(ul'
  131. X.el \{\
  132. X.\"    Draw four-sided box normally, but don't draw top of
  133. X.\"    box if the box started on an earlier page.
  134. X.ie !\\n(^b-1 \{\
  135. X\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  136. X.\}
  137. X.el \}\
  138. X\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  139. X.\}
  140. X.\}
  141. X.fi
  142. X.br
  143. X.nr ^b 0
  144. X..
  145. X'    # VS - start vertical sidebar
  146. X'    # ^Y = starting y location
  147. X'    # ^v = 1 (for troff;  for nroff this doesn't matter)
  148. X.de VS
  149. X.mk ^Y
  150. X.ie n 'mc \s12\(br\s0
  151. X.el .nr ^v 1u
  152. X..
  153. X'    # VE - end of vertical sidebar
  154. X.de VE
  155. X.ie n 'mc
  156. X.el \{\
  157. X.ev 2
  158. X.nf
  159. X.ti 0
  160. X.mk ^t
  161. X\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  162. X.sp -1
  163. X.fi
  164. X.ev
  165. X.\}
  166. X.nr ^v 0
  167. X..
  168. X'    # Special macro to handle page bottom:  finish off current
  169. X'    # box/sidebar if in box/sidebar mode, then invoked standard
  170. X'    # page bottom macro.
  171. X.de ^B
  172. X.ev 2
  173. X'ti 0
  174. X'nf
  175. X.mk ^t
  176. X.if \\n(^b \{\
  177. X.\"    Draw three-sided box if this is the box's first page,
  178. X.\"    draw two sides but no top otherwise.
  179. 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
  180. X.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  181. X.\}
  182. X.if \\n(^v \{\
  183. X.nr ^x \\n(^tu+1v-\\n(^Yu
  184. X\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  185. X.\}
  186. X.bp
  187. X'fi
  188. X.ev
  189. X.if \\n(^b \{\
  190. X.mk ^y
  191. X.nr ^b 2
  192. X.\}
  193. X.if \\n(^v \{\
  194. X.mk ^Y
  195. X.\}
  196. X..
  197. X'    # DS - begin display
  198. X.de DS
  199. X.RS
  200. X.nf
  201. X.sp
  202. X..
  203. X'    # DE - end display
  204. X.de DE
  205. X.fi
  206. X.RE
  207. X.sp .5
  208. X..
  209. X.\"----------------------------------------------------------------------------
  210. X.HS Tcl_CreateExtendedInterp tcl
  211. X.BS
  212. X'@index: Tcl_CreateExtendedInterp
  213. X.SH NAME
  214. XTcl_CreateExtendedInterp \- set up a new Tcl command interpreter and 
  215. Xinitialized all Extended Tcl commands.
  216. X.SH SYNOPSIS
  217. X.nf
  218. X\fB#include <tclExtend.h>\fR
  219. X.sp
  220. XTcl_Interp *
  221. X\fBTcl_CreateExtendedInterp\fR()
  222. X.BE
  223. X
  224. X.SH DESCRIPTION
  225. X.PP
  226. X\fBTcl_CreateExtendedInterp\fR creates a new interpreter structure and returns
  227. Xa pointer to the interpreter data stucture, as with \fBTcl_CreateInterp\fR.
  228. XIn addition, all Extended Tcl commands will be added to the interpreter.
  229. X
  230. X.SH KEYWORDS
  231. Xcommand, create, interpreter
  232. END_OF_FILE
  233. if test 4315 -ne `wc -c <'extended/man/CreateExte.man'`; then
  234.     echo shar: \"'extended/man/CreateExte.man'\" unpacked with wrong size!
  235. fi
  236. # end of 'extended/man/CreateExte.man'
  237. fi
  238. if test -f 'extended/src/general.c' -a "${1}" != "-c" ; then 
  239.   echo shar: Will not clobber existing file \"'extended/src/general.c'\"
  240. else
  241. echo shar: Extracting \"'extended/src/general.c'\" \(5075 characters\)
  242. sed "s/^X//" >'extended/src/general.c' <<'END_OF_FILE'
  243. X/* 
  244. X * general.c --
  245. X *
  246. X *      Contains general extensions to the basic TCL command set.
  247. X *---------------------------------------------------------------------------
  248. X * Copyright 1991 Karl Lehenbauer and Mark Diekhans.
  249. X *
  250. X * Permission to use, copy, modify, and distribute this software and its
  251. X * documentation for any purpose and without fee is hereby granted, provided
  252. X * that the above copyright notice appear in all copies.  Karl Lehenbauer and
  253. X * Mark Diekhans make no representations about the suitability of this
  254. X * software for any purpose.  It is provided "as is" without express or
  255. X * implied warranty.
  256. X */
  257. X
  258. X#include "tclExtdInt.h"
  259. X
  260. X/*
  261. X * These globals must be set by main for the information to be defined.
  262. X */
  263. X
  264. Xchar *tclxVersion       = "?";  /* Extended Tcl version number.            */
  265. Xchar *tclxPatchlevel    = "?";  /* Extended Tcl patch level.               */
  266. X
  267. Xchar *tclAppName        = "?";  /* Application name                        */
  268. Xchar *tclAppLongname    = "?";  /* Long, natural language application name */
  269. Xchar *tclAppVersion     = "?";  /* Version number of the application       */
  270. X
  271. X
  272. X/*
  273. X *----------------------------------------------------------------------
  274. X *
  275. X * Tcl_EchoCmd --
  276. X *    Implements the TCL echo command:
  277. X *        echo str1 [str2..]
  278. X *
  279. X * Results:
  280. X *      Always returns TCL_OK.
  281. X *
  282. X *----------------------------------------------------------------------
  283. X */
  284. Xint
  285. XTcl_EchoCmd(clientData, interp, argc, argv)
  286. X    ClientData  clientData;
  287. X    Tcl_Interp *interp;
  288. X    int         argc;
  289. X    char      **argv;
  290. X{
  291. X    int idx;
  292. X
  293. X    for (idx = 1; idx < argc; idx++) {
  294. X        fputs (argv [idx], stdout);
  295. X        if (idx < (argc - 1))
  296. X            printf(" ");
  297. X    }
  298. X    printf("\n");
  299. X    return TCL_OK;
  300. X}
  301. X
  302. X/*
  303. X *----------------------------------------------------------------------
  304. X *
  305. X * Tcl_InfoxCmd --
  306. X *    Implements the TCL infox command:
  307. X *        infox option
  308. X *
  309. X *----------------------------------------------------------------------
  310. X */
  311. Xint
  312. XTcl_InfoxCmd (clientData, interp, argc, argv)
  313. X    ClientData  clientData;
  314. X    Tcl_Interp *interp;
  315. X    int         argc;
  316. X    char      **argv;
  317. X{
  318. X    if (argc != 2) {
  319. X        Tcl_AppendResult (interp, "wrong # args: ", argv [0], 
  320. X                          " option", (char *) NULL);
  321. X        return TCL_ERROR;
  322. X    }
  323. X
  324. X    if (STREQU ("version", argv [1])) {
  325. X        Tcl_SetResult (interp, tclxVersion, TCL_STATIC);
  326. X    } else if (STREQU ("patchlevel", argv [1])) {
  327. X        Tcl_SetResult (interp, tclxPatchlevel, TCL_STATIC);
  328. X    } else if (STREQU ("appname", argv [1])) {
  329. X        Tcl_SetResult (interp, tclAppName, TCL_STATIC);
  330. X    } else if (STREQU ("applongname", argv [1])) {
  331. X        Tcl_SetResult (interp, tclAppLongname, TCL_STATIC);
  332. X    } else if (STREQU ("appversion", argv [1])) {
  333. X        Tcl_SetResult (interp, tclAppVersion, TCL_STATIC);
  334. X    } else {
  335. X        Tcl_AppendResult (interp, "illegal option \"", argv [1], 
  336. X                          "\" expect one of: version, patchlevel, appname, ",
  337. X                          "applongname, or appversion", (char *) NULL);
  338. X        return TCL_ERROR;
  339. X    }
  340. X    return TCL_OK;
  341. X}
  342. X
  343. X/*
  344. X *----------------------------------------------------------------------
  345. X *
  346. X * Tcl_LoopCmd --
  347. X *     Implements the TCL loop command:
  348. X *         loop var start end [increment] command
  349. X *
  350. X * Results:
  351. X *      Standard TCL results.
  352. X *
  353. X *----------------------------------------------------------------------
  354. X */
  355. Xint
  356. XTcl_LoopCmd (dummy, interp, argc, argv)
  357. X    ClientData  dummy;
  358. X    Tcl_Interp *interp;
  359. X    int         argc;
  360. X    char      **argv;
  361. X{
  362. X    int   result = TCL_OK;
  363. X    long  i, lo, hi, incr = 1;
  364. X    char *command;
  365. X
  366. X    if ((argc < 5) || (argc > 6)) {
  367. X        Tcl_AppendResult (interp, "wrong # args: ", argv [0], 
  368. X                          " var lo hi [incr] command", (char *) NULL);
  369. X        return TCL_ERROR;
  370. X    }
  371. X
  372. X    if (Tcl_GetLong (interp, argv[2], &lo) != TCL_OK)
  373. X        return TCL_ERROR;
  374. X    if (Tcl_GetLong (interp, argv[3], &hi) != TCL_OK)
  375. X        return TCL_ERROR;
  376. X    if (argc == 5)
  377. X        command = argv[4];
  378. X    else {
  379. X        if (Tcl_GetLong (interp, argv[4], &incr) != TCL_OK)
  380. X            return TCL_ERROR;
  381. X        command = argv[5];
  382. X    }
  383. X
  384. X    for (i = lo; (((i < hi) && (incr > 0)) || ((i > hi) && (incr < 0)));
  385. X             i += incr) {
  386. X        char itxt[12];
  387. X
  388. X        sprintf(itxt,"%ld",i);
  389. X        if (Tcl_SetVar(interp, argv[1], itxt, TCL_LEAVE_ERR_MSG) == NULL)
  390. X            return TCL_ERROR;
  391. X
  392. X        result = Tcl_Eval(interp, command, 0, (char **) NULL);
  393. X        if (result != TCL_OK) {
  394. X            if (result == TCL_CONTINUE) {
  395. X                result = TCL_OK;
  396. X            } else if (result == TCL_BREAK) {
  397. X                result = TCL_OK;
  398. X                break;
  399. X            } else if (result == TCL_ERROR) {
  400. X                char buf [64];
  401. X
  402. X                sprintf (buf, "\n    (\"loop\" body line %d)", 
  403. X                         interp->errorLine);
  404. X                Tcl_AddErrorInfo (interp, buf);
  405. X                break;
  406. X            } else {
  407. X                break;
  408. X            }
  409. X        }
  410. X    }
  411. X    return result;
  412. X}
  413. END_OF_FILE
  414. if test 5075 -ne `wc -c <'extended/src/general.c'`; then
  415.     echo shar: \"'extended/src/general.c'\" unpacked with wrong size!
  416. fi
  417. # end of 'extended/src/general.c'
  418. fi
  419. if test -f 'extended/src/math.c' -a "${1}" != "-c" ; then 
  420.   echo shar: Will not clobber existing file \"'extended/src/math.c'\"
  421. else
  422. echo shar: Extracting \"'extended/src/math.c'\" \(4921 characters\)
  423. sed "s/^X//" >'extended/src/math.c' <<'END_OF_FILE'
  424. X/*
  425. X * math.c --
  426. X *
  427. X * Mathematical Tcl commands.
  428. X *---------------------------------------------------------------------------
  429. X * Copyright 1991 Karl Lehenbauer and Mark Diekhans.
  430. X *
  431. X * Permission to use, copy, modify, and distribute this software and its
  432. X * documentation for any purpose and without fee is hereby granted, provided
  433. X * that the above copyright notice appear in all copies.  Karl Lehenbauer and
  434. X * Mark Diekhans make no representations about the suitability of this
  435. X * software for any purpose.  It is provided "as is" without express or
  436. X * implied warranty.
  437. X */
  438. X
  439. X#include "tclExtdInt.h"
  440. X
  441. Xextern int rand();
  442. X
  443. X/*
  444. X * Prototypes of internal functions.
  445. X */
  446. Xint 
  447. Xreally_random _ANSI_ARGS_((int my_range));
  448. X
  449. X
  450. X/*
  451. X *----------------------------------------------------------------------
  452. X *
  453. X * Tcl_MaxCmd --
  454. X *      Implements the TCL max command:
  455. X *        max num1 num2 [..numN]
  456. X *
  457. X * Results:
  458. X *      Standard TCL results.
  459. X *
  460. X *----------------------------------------------------------------------
  461. X */
  462. Xint
  463. XTcl_MaxCmd (clientData, interp, argc, argv)
  464. X    ClientData  clientData;
  465. X    Tcl_Interp *interp;
  466. X    int         argc;
  467. X    char      **argv;
  468. X{
  469. X    double value, maxVal = MINDOUBLE;
  470. X    int    idx, maxIdx = 1;
  471. X
  472. X
  473. X    if (argc < 3) {
  474. X        Tcl_AppendResult (interp, "wrong # args: ", argv [0], 
  475. X                          " num1 num2 [..numN]", (char *) NULL);
  476. X        return TCL_ERROR;
  477. X    }
  478. X
  479. X    for (idx = 1; idx < argc; idx++) {
  480. X        if (Tcl_GetDouble (interp, argv[idx], &value) != TCL_OK)
  481. X            return TCL_ERROR;
  482. X        if (value > maxVal) {
  483. X            maxVal = value;
  484. X            maxIdx = idx;
  485. X            }
  486. X        }
  487. X    strcpy (interp->result, argv[maxIdx]);
  488. X    return TCL_OK;
  489. X}
  490. X
  491. X/*
  492. X *----------------------------------------------------------------------
  493. X *
  494. X * Tcl_MinCmd --
  495. X *     Implements the TCL min command:
  496. X *         min num1 num2 [..numN]
  497. X *
  498. X * Results:
  499. X *      Standard TCL results.
  500. X *
  501. X *----------------------------------------------------------------------
  502. X */
  503. Xint
  504. XTcl_MinCmd (clientData, interp, argc, argv)
  505. X    ClientData  clientData;
  506. X    Tcl_Interp *interp;
  507. X    int     argc;
  508. X    char      **argv;
  509. X{
  510. X    double value, minVal = MAXDOUBLE;
  511. X    int    idx, minIdx = 1;
  512. X
  513. X    if (argc < 3) {
  514. X        Tcl_AppendResult (interp, "wrong # args: ", argv [0], 
  515. X                          " num1 num2 [..numN]", (char *) NULL);
  516. X        return TCL_ERROR;
  517. X    }
  518. X
  519. X    for (idx = 1; idx < argc; idx++) {
  520. X        if (Tcl_GetDouble (interp, argv[idx], &value) != TCL_OK)
  521. X            return TCL_ERROR;
  522. X        if (value < minVal) {
  523. X            minVal = value;
  524. X            minIdx = idx;
  525. X            }
  526. X        }
  527. X    strcpy (interp->result, argv[minIdx]);
  528. X    return TCL_OK;
  529. X}
  530. X
  531. X/*
  532. X *----------------------------------------------------------------------
  533. X *
  534. X * ReallyRandom --
  535. X *     Insure a good random return for a range, unlike an arbitrary
  536. X *     random() % n, thanks to Ken Arnold, Unix Review, October 1987.
  537. X *
  538. X *----------------------------------------------------------------------
  539. X */
  540. X#ifdef TCL_32_BIT_RANDOM
  541. X#    define RANDOM_RANGE ((1 << 31) - 1)
  542. X#else
  543. X#    define RANDOM_RANGE ((1 << 15) - 1)
  544. X#endif
  545. X
  546. Xstatic int 
  547. X
  548. XReallyRandom (myRange)
  549. X    int myRange;
  550. X{
  551. X    int maxMultiple, rnum;
  552. X
  553. X    maxMultiple = RANDOM_RANGE / myRange;
  554. X    maxMultiple *= myRange;
  555. X    while ((rnum = rand()) >= maxMultiple)
  556. X        continue;
  557. X    return (rnum % myRange);
  558. X}
  559. X
  560. X/*
  561. X *----------------------------------------------------------------------
  562. X *
  563. X * Tcl_RandomCmd  --
  564. X *     Implements the TCL random command:
  565. X *     random limit
  566. X *
  567. X * Results:
  568. X *  Standard TCL results.
  569. X *
  570. X *----------------------------------------------------------------------
  571. X */
  572. Xint
  573. XTcl_RandomCmd (clientData, interp, argc, argv)
  574. X    ClientData  clientData;
  575. X    Tcl_Interp *interp;
  576. X    int         argc;
  577. X    char      **argv;
  578. X{
  579. X    unsigned range;
  580. X
  581. X    if ((argc < 2) || (argc > 3))
  582. X        goto invalidArgs;
  583. X
  584. X    if (STREQU (argv [1], "seed")) {
  585. X        long seed;
  586. X
  587. X        if (argc == 3) {
  588. X            if (Tcl_GetLong (interp, argv[2], &seed) != TCL_OK)
  589. X                return TCL_ERROR;
  590. X        } else
  591. X            seed = (unsigned) (getpid() + time((time_t *)NULL));
  592. X
  593. X        srand(seed);
  594. X
  595. X    } else {
  596. X        if (argc != 2)
  597. X            goto invalidArgs;
  598. X        if (Tcl_GetUnsigned (interp, argv[1], &range) != TCL_OK)
  599. X            return TCL_ERROR;
  600. X        if ((range == 0) || (range > RANDOM_RANGE))
  601. X            goto outOfRange;
  602. X
  603. X        sprintf (interp->result, "%d", ReallyRandom (range));
  604. X    }
  605. X    return TCL_OK;
  606. X
  607. XinvalidArgs:
  608. X    Tcl_AppendResult (interp, "wrong # args: ", argv [0], 
  609. X                      " limit | seed [seedval]", (char *) NULL);
  610. X    return TCL_ERROR;
  611. XoutOfRange:
  612. X    {
  613. X        char buf [18];
  614. X
  615. X        sprintf (buf, "%d", RANDOM_RANGE);
  616. X        Tcl_AppendResult (interp, argv [0], ": range must be > 0 and <= ",
  617. X                          buf, (char *) NULL);
  618. X        return TCL_ERROR;
  619. X    }
  620. X}
  621. END_OF_FILE
  622. if test 4921 -ne `wc -c <'extended/src/math.c'`; then
  623.     echo shar: \"'extended/src/math.c'\" unpacked with wrong size!
  624. fi
  625. # end of 'extended/src/math.c'
  626. fi
  627. if test -f 'extended/src/tcl++.C' -a "${1}" != "-c" ; then 
  628.   echo shar: Will not clobber existing file \"'extended/src/tcl++.C'\"
  629. else
  630. echo shar: Extracting \"'extended/src/tcl++.C'\" \(4062 characters\)
  631. sed "s/^X//" >'extended/src/tcl++.C' <<'END_OF_FILE'
  632. X/*
  633. X * tcl++.C --
  634. X *
  635. X *   File to test it the C++ definitions compile.  It is an alternative to the
  636. X *   existing main.c to set up the Tcl shell and may be used as a example on
  637. X *   how to use tcl++.h
  638. X *      
  639. X *---------------------------------------------------------------------------
  640. X * Copyright 1991 Karl Lehenbauer and Mark Diekhans.
  641. X *
  642. X * Permission to use, copy, modify, and distribute this software and its
  643. X * documentation for any purpose and without fee is hereby granted, provided
  644. X * that the above copyright notice appear in all copies.  Karl Lehenbauer,
  645. X * Mark Diekhans, and Peter da Silva make no representations about the
  646. X * suitability of this software for any purpose.  It is provided "as is"
  647. X * without express or implied warranty.
  648. X *---------------------------------------------------------------------------
  649. X * Based on Tcl C++ classes developed by Parag Patel.
  650. X */
  651. X
  652. X#include "tcl++.h"
  653. X#include "patchlevel.h"
  654. X
  655. Xextern errno;
  656. X
  657. X/*
  658. X * These globals are used by the infox command.
  659. X */
  660. X
  661. Xextern char *tclxVersion;        /* Extended Tcl version number.            */
  662. Xextern char *tclxPatchlevel;     /* Extended Tcl patch level.               */
  663. X
  664. Xextern char *tclAppName;         /* Application name                        */
  665. Xextern char *tclAppLongname;     /* Long, natural language application name */
  666. Xextern char *tclAppVersion;      /* Version number of the application       */
  667. X
  668. X/*
  669. X * If set to be a pointer to the procedure Tcl_RecordAndEval, will link in
  670. X * history
  671. X */
  672. Xextern int (*tclShellCmdEvalProc) ();
  673. X
  674. Xint
  675. Xmain (int     argc,
  676. X      char  **argv)
  677. X{
  678. X    TclInterp_cl *interpPtr;
  679. X    char         *defaultFile;
  680. X
  681. X
  682. X    /*
  683. X     * Set values to return from the infox command.
  684. X     */
  685. X    tclxVersion = ckalloc (strlen (TCL_VERSION) + 
  686. X                           strlen (TCL_EXTD_VERSION_SUFFIX) + 1);
  687. X    strcpy (tclxVersion, TCL_VERSION);
  688. X    strcat (tclxVersion, TCL_EXTD_VERSION_SUFFIX);
  689. X
  690. X    tclxPatchlevel = "PATCHLEVEL";
  691. X
  692. X    /*
  693. X     * Path name for default file.  A version number is normally appended.
  694. X     *        >>>> MAYBE MODIFIED FOR a specific application <<<
  695. X     */
  696. X
  697. X    defaultFile = ckalloc (strlen (TCL_DEFAULT) + strlen (TCL_VERSION) +
  698. X                           strlen (TCL_EXTD_VERSION_SUFFIX) + 1);
  699. X    strcpy (defaultFile, TCL_DEFAULT);
  700. X    strcat (defaultFile, TCL_VERSION);
  701. X    strcat (defaultFile, TCL_EXTD_VERSION_SUFFIX);
  702. X
  703. X    /*
  704. X     * Set application specific values to return from the infox command.
  705. X     *        >>>> MAYBE MODIFIED FOR a specific application <<<
  706. X     */
  707. X    tclAppName = "TclX";
  708. X    tclAppLongname = "Extended Tcl Shell";
  709. X    tclAppVersion = tclxVersion;
  710. X
  711. X    /*
  712. X     * If history is to be used, then set the eval procedure pointer that
  713. X     * Tcl_CommandLoop so that history will be recorded.  This reference
  714. X     * also brings in history from Tcl.a.
  715. X     */
  716. X#ifndef TCL_NOHISTORY
  717. X     tclShellCmdEvalProc = (int (*)())Tcl_RecordAndEval;
  718. X#endif
  719. X
  720. X    /* 
  721. X     * Create a Tcl interpreter for the session, with all extended commands
  722. X     * initialized.  This can be replaced with Tcl_CreateInterp followed
  723. X     * by a subset of the extended command initializaton procedures if 
  724. X     * desired.
  725. X     */
  726. X    interpPtr = new TclInterp_cl;
  727. X
  728. X    /*
  729. X     *   >>>>>> INITIALIZE APPLICATION SPECIFIC COMMANDS HERE <<<<<<
  730. X     */
  731. X
  732. X    /*
  733. X     * Load the tcl startup code, this should pull in all of the tcl
  734. X     * procs, paths, command line processing, autoloads, packages, etc.
  735. X     * If Tcl was invoked interactively, Tcl_Startup will give it
  736. X     * a command loop .
  737. X     */
  738. X
  739. X    interpPtr->Startup (argc, argv, defaultFile);
  740. X
  741. X    /* 
  742. X     * Delete the interpreter (not neccessary under Unix, but we do
  743. X     * it if TCL_MEM_DEBUG is set to better enable us to catch memory
  744. X     * corruption problems)
  745. X     */
  746. X
  747. X#ifdef TCL_MEM_DEBUG
  748. X    delete interpPtr;
  749. X#endif
  750. X
  751. X#ifdef TCL_SHELL_MEM_LEAK
  752. X    printf (" >>> Dumping active memory list to mem.lst <<<\n");
  753. X    if (Tcl_DumpActiveMemory ("mem.lst") != TCL_OK)
  754. X        panic ("error accessing `mem.lst': %s", strerror (errno));
  755. X#endif
  756. X
  757. X    exit(0);
  758. X}
  759. X
  760. END_OF_FILE
  761. if test 4062 -ne `wc -c <'extended/src/tcl++.C'`; then
  762.     echo shar: \"'extended/src/tcl++.C'\" unpacked with wrong size!
  763. fi
  764. # end of 'extended/src/tcl++.C'
  765. fi
  766. if test -f 'extended/src/tclExtend.h' -a "${1}" != "-c" ; then 
  767.   echo shar: Will not clobber existing file \"'extended/src/tclExtend.h'\"
  768. else
  769. echo shar: Extracting \"'extended/src/tclExtend.h'\" \(4591 characters\)
  770. sed "s/^X//" >'extended/src/tclExtend.h' <<'END_OF_FILE'
  771. X/* 
  772. X * tclExtend.h
  773. X *
  774. X *    External declarations for the extended Tcl library.
  775. X *---------------------------------------------------------------------------
  776. X * Copyright 1991 Karl Lehenbauer and Mark Diekhans.
  777. X *
  778. X * Permission to use, copy, modify, and distribute this software and its
  779. X * documentation for any purpose and without fee is hereby granted, provided
  780. X * that the above copyright notice appear in all copies.  Karl Lehenbauer and
  781. X * Mark Diekhans make no representations about the suitability of this
  782. X * software for any purpose.  It is provided "as is" without express or
  783. X * implied warranty.
  784. X */
  785. X
  786. X#ifndef TCLEXTEND_H
  787. X#define TCLEXTEND_H
  788. X
  789. X#include <stdio.h>
  790. X#include "tcl.h"
  791. X
  792. X/*
  793. X * Version suffix for extended Tcl, this is appended to the standard Tcl
  794. X * version to form the actual extended Tcl version.
  795. X */
  796. X
  797. X#define TCL_EXTD_VERSION_SUFFIX "a"   /* 6.1a */
  798. X
  799. Xtypedef void *void_pt;
  800. X
  801. X/*
  802. X * Exported Extended Tcl functions.
  803. X */
  804. X
  805. XEXTERN void 
  806. XTcl_CommandLoop _ANSI_ARGS_((Tcl_Interp *interp,
  807. X                             FILE       *in,
  808. X                             FILE       *out,
  809. X                             int         interactive));
  810. X
  811. XEXTERN Tcl_Interp * 
  812. XTcl_CreateExtendedInterp ();
  813. X
  814. XEXTERN char *
  815. XTcl_DeleteKeyedListField _ANSI_ARGS_((Tcl_Interp  *interp,
  816. X                                      CONST char  *fieldName,
  817. X                                      CONST char  *keyedList));
  818. XEXTERN char * 
  819. XTcl_DownShift _ANSI_ARGS_((char       *targetStr,
  820. X                           CONST char *sourceStr));
  821. X
  822. XEXTERN char * 
  823. XTcl_UpShift _ANSI_ARGS_((char       *targetStr,
  824. X                         CONST char *sourceStr));
  825. X
  826. XEXTERN int
  827. XTcl_GetKeyedListField _ANSI_ARGS_((Tcl_Interp  *interp,
  828. X                                   CONST char  *fieldName,
  829. X                                   CONST char  *keyedList,
  830. X                                   char       **fieldValuePtr));
  831. X
  832. XEXTERN int 
  833. XTcl_GetLong _ANSI_ARGS_((Tcl_Interp  *interp,
  834. X                         CONST char *string,
  835. X                         long        *longPtr));
  836. X
  837. XEXTERN int 
  838. XTcl_GetUnsigned _ANSI_ARGS_((Tcl_Interp  *interp,
  839. X                             CONST char *string,
  840. X                             unsigned   *unsignedPtr));
  841. X
  842. XEXTERN char *
  843. XTcl_SetKeyedListField _ANSI_ARGS_((Tcl_Interp  *interp,
  844. X                                   CONST char  *fieldName,
  845. X                                   CONST char  *fieldvalue,
  846. X                                   CONST char  *keyedList));
  847. X
  848. XEXTERN int
  849. XTcl_StrToLong _ANSI_ARGS_((CONST char *string,
  850. X                           int          base,
  851. X                           long        *longPtr));
  852. X
  853. XEXTERN int
  854. XTcl_StrToInt _ANSI_ARGS_((CONST char *string,
  855. X                          int         base,
  856. X                          int        *intPtr));
  857. X
  858. XEXTERN int
  859. XTcl_StrToUnsigned _ANSI_ARGS_((CONST char *string,
  860. X                               int         base,
  861. X                               unsigned   *unsignedPtr));
  862. X
  863. XEXTERN int
  864. XTcl_StrToDouble _ANSI_ARGS_((CONST char  *string,
  865. X                             double      *doublePtr));
  866. X
  867. XEXTERN void_pt  
  868. XTcl_HandleAlloc _ANSI_ARGS_((void_pt   headerPtr,
  869. X                             char     *handlePtr));
  870. X
  871. XEXTERN void 
  872. XTcl_HandleFree _ANSI_ARGS_((void_pt  headerPtr,
  873. X                            void_pt  entryPtr));
  874. X
  875. XEXTERN void_pt
  876. XTcl_HandleTblInit _ANSI_ARGS_((CONST char *handleBase,
  877. X                               int         entrySize,
  878. X                               int         initEntries));
  879. X
  880. XEXTERN void
  881. XTcl_HandleTblRelease _ANSI_ARGS_((void_pt headerPtr));
  882. X
  883. XEXTERN int
  884. XTcl_HandleTblUseCount _ANSI_ARGS_((void_pt headerPtr,
  885. X                                   int     amount));
  886. X
  887. XEXTERN void_pt
  888. XTcl_HandleWalk _ANSI_ARGS_((void_pt   headerPtr,
  889. X                            int      *walkKeyPtr));
  890. X
  891. XEXTERN void
  892. XTcl_WalkKeyToHandle _ANSI_ARGS_((void_pt   headerPtr,
  893. X                                 int       walkKey,
  894. X                                 char     *handlePtr));
  895. X
  896. XEXTERN void_pt
  897. XTcl_HandleXlate _ANSI_ARGS_((Tcl_Interp  *interp,
  898. X                             void_pt      headerPtr,
  899. X                             CONST  char *handle));
  900. X
  901. XEXTERN int
  902. XTcl_MathError _ANSI_ARGS_((char *functionName,
  903. X                           int   errorType));
  904. X
  905. XEXTERN int
  906. XTcl_SigNameToNum _ANSI_ARGS_((char *sigName));
  907. X
  908. XEXTERN void 
  909. XTcl_Startup _ANSI_ARGS_((Tcl_Interp   *interp,
  910. X                         int           argc,
  911. X                         CONST char  **argv,
  912. X                         CONST char   *defaultFile));
  913. X
  914. XEXTERN int
  915. XTcl_System _ANSI_ARGS_((Tcl_Interp *interp,
  916. X                        char       *command));
  917. X
  918. X#endif
  919. END_OF_FILE
  920. if test 4591 -ne `wc -c <'extended/src/tclExtend.h'`; then
  921.     echo shar: \"'extended/src/tclExtend.h'\" unpacked with wrong size!
  922. fi
  923. # end of 'extended/src/tclExtend.h'
  924. fi
  925. if test -f 'extended/tcllib/TclInit.tcl' -a "${1}" != "-c" ; then 
  926.   echo shar: Will not clobber existing file \"'extended/tcllib/TclInit.tcl'\"
  927. else
  928. echo shar: Extracting \"'extended/tcllib/TclInit.tcl'\" \(4434 characters\)
  929. sed "s/^X//" >'extended/tcllib/TclInit.tcl' <<'END_OF_FILE'
  930. X# TclInit.tcl -- Extended Tcl initialization (see tclshell man page)
  931. X
  932. Xglobal env TCLENV
  933. Xset TCLENV(inUnknown) 0
  934. Xset TCLENV(packageIndexesLoaded) 0
  935. X
  936. X#
  937. X# Define a package (called from .tndx file only)
  938. X#
  939. Xproc TCLSH:defpkg {packageName libName offset length args} {
  940. X    global TCLENV
  941. X    set TCLENV(PKG:$packageName) [list $libName $offset $length]
  942. X    foreach i $args {
  943. X        set TCLENV(PROC:$i) [list P $packageName]
  944. X    }
  945. X}
  946. X
  947. X#
  948. X# Load Ousterhout style index.
  949. X#
  950. Xproc TCLSH:LoadOusterIndex {dir} {
  951. X    global TCLENV
  952. X
  953. X    set fileHdl [open $dir/tclIndex]
  954. X    while {[gets $fileHdl line] >= 0} {
  955. X        if {([string index $line 0] == "#") || ([llength $line] != 2)} {
  956. X            continue}
  957. X        set filename [lindex $line 1]
  958. X        if {"$filename" == "init.tcl"} {
  959. X            continue}
  960. X        set TCLENV(PROC:[lindex $line 0]) [list F $filename]
  961. X
  962. X    }
  963. X    close $fileHdl
  964. X}
  965. X
  966. X#
  967. X# Load a package library index.
  968. X#
  969. Xproc loadlibindex {libFile} {
  970. X    set indexFile [file root $libFile].tndx
  971. X    if {![file readable $indexFile] || ([file mtime $indexFile] <
  972. X             [file mtime $libFile])} {
  973. X        demand_load buildpackageindex
  974. X        buildpackageindex $libFile
  975. X    }
  976. X    source $indexFile
  977. X}
  978. X
  979. X#
  980. X# Load library indexes along path.
  981. X#
  982. Xproc TCLSH:LoadPackageIndexes {} {
  983. X    global TCLPATH
  984. X    foreach dir $TCLPATH {
  985. X        foreach libFile [glob -nocomplain $dir/*.tlib] {
  986. X            loadlibindex $libFile
  987. X        }
  988. X        if {[file readable $dir/tclIndex]} {
  989. X            TCLSH:LoadOusterIndex $dir
  990. X        }
  991. X    }
  992. X}
  993. X
  994. X#
  995. X# Unknown command trap handler.
  996. X#
  997. Xproc unknown {cmdName args} {
  998. X    global TCLENV
  999. X    if $TCLENV(inUnknown) {
  1000. X        error "recursive unknown command trap: \"$cmdName\""}
  1001. X    set TCLENV(inUnknown) 1
  1002. X
  1003. X    if [demand_load $cmdName] {
  1004. X        set TCLENV(inUnknown) 0
  1005. X        return [uplevel 1 [list eval $cmdName $args]]
  1006. X    }
  1007. X
  1008. X    global env interactiveSession noAutoExec
  1009. X
  1010. X    if {$interactiveSession && ([info level] == 1) && ([info script] == "") &&
  1011. X            (!([info exists noAutoExec] && [set noAutoExec]))} {
  1012. X        if {[file rootname $cmdName] == "$cmdName"} {
  1013. X            if [info exists env(PATH)] {
  1014. X                set binpath [searchpath [split $env(PATH) :] $cmdName]
  1015. X            } else {
  1016. X                set binpath [searchpath "." $cmdName]
  1017. X            }
  1018. X        } else {
  1019. X            set binpath $cmdName
  1020. X        }
  1021. X        if {[file executable $binpath]} {
  1022. X            uplevel 1 [list system [concat $cmdName $args]]
  1023. X            set TCLENV(inUnknown) 0
  1024. X            return
  1025. X        }
  1026. X    }
  1027. X    set TCLENV(inUnknown) 0
  1028. X    error "invalid command name: \"$cmdName\""
  1029. X}
  1030. X
  1031. X#
  1032. X# Search a path list for a file.
  1033. X#
  1034. Xproc searchpath {pathlist file} {
  1035. X    foreach dir $pathlist {
  1036. X        if {"$dir" == ""} {set dir .}
  1037. X        if [file exists $dir/$file] {
  1038. X            return $dir/$file
  1039. X        }
  1040. X    }
  1041. X    return {}
  1042. X}
  1043. X
  1044. X#
  1045. X# Define a proc to be available for demand_load.
  1046. X#
  1047. Xproc autoload {filenam args} {
  1048. X    global TCLENV
  1049. X    foreach i $args {
  1050. X        set TCLENV(PROC:$i) [list F $filenam]
  1051. X    }
  1052. X}
  1053. X
  1054. X#
  1055. X# Load a proc from library or autoload file.
  1056. X#
  1057. Xproc demand_load {name} {
  1058. X    global TCLENV
  1059. X    if [info exists TCLENV(PROC:$name)] {
  1060. X        set autoloadRecord $TCLENV(PROC:$name)
  1061. X        if {[lindex $autoloadRecord 0] == "F"} {
  1062. X            load [lindex $autoloadRecord 1]
  1063. X        } else {
  1064. X            set pkgInfo $TCLENV(PKG:[lindex $autoloadRecord 1])
  1065. X            uplevel #0 sourcepart [lindex $pkgInfo 0] [lindex $pkgInfo 1] [lindex $pkgInfo 2]
  1066. X            if {"[info procs $name]" == ""} {
  1067. X                return 0}
  1068. X        }
  1069. X        return 1
  1070. X    }
  1071. X
  1072. X    # Slow path load index file and try again.
  1073. X
  1074. X    if {!$TCLENV(packageIndexesLoaded)} {
  1075. X        TCLSH:LoadPackageIndexes
  1076. X        set TCLENV(packageIndexesLoaded) 1
  1077. X        return [demand_load $name]
  1078. X    }
  1079. X    return 0
  1080. X}
  1081. X
  1082. X#
  1083. X# Search TCLPATH for a file to source.
  1084. X#
  1085. Xproc load {name} {
  1086. X    global TCLPATH errorCode
  1087. X    set where [searchpath $TCLPATH $name]
  1088. X    if [lempty $where] {
  1089. X        error "couldn't find $name in Tcl search path" "" "TCLSH FILE_NOT_FOUND"
  1090. X    }
  1091. X    uplevel #0 source $where
  1092. X}
  1093. X
  1094. Xautoload buildidx.tcl buildpackageindex
  1095. X
  1096. X# == Put any code you want all Tcl programs to include here. ==
  1097. X
  1098. Xif !$interactiveSession return
  1099. X
  1100. X# == Interactive Tcl session initialization ==
  1101. X
  1102. Xif [file exists ~/.tclrc] {source ~/.tclrc}
  1103. X
  1104. Xset TCLENV(topLevelPromptHook) {global programName; concat "$programName>" }
  1105. X
  1106. Xset TCLENV(downLevelPromptHook) {concat "=>"}
  1107. X
  1108. END_OF_FILE
  1109. if test 4434 -ne `wc -c <'extended/tcllib/TclInit.tcl'`; then
  1110.     echo shar: \"'extended/tcllib/TclInit.tcl'\" unpacked with wrong size!
  1111. fi
  1112. # end of 'extended/tcllib/TclInit.tcl'
  1113. fi
  1114. if test -f 'extended/tcllib/help/commands/file' -a "${1}" != "-c" ; then 
  1115.   echo shar: Will not clobber existing file \"'extended/tcllib/help/commands/file'\"
  1116. else
  1117. echo shar: Extracting \"'extended/tcllib/help/commands/file'\" \(4731 characters\)
  1118. sed "s/^X//" >'extended/tcllib/help/commands/file' <<'END_OF_FILE'
  1119. X          file option name ?arg arg ...?
  1120. X               Operate on a file or a file name.  Name is the name  of
  1121. X               a   file;  if  it  starts  with  a  tilde,  then  tilde
  1122. X               substitution is done before executing the command  (see
  1123. X               the  manual  entry  for  Tcl_TildeSubst  for  details).
  1124. X               Option indicates what to do with the  file  name.   Any
  1125. X               unique  abbreviation  for  option  is  acceptable.  The
  1126. X               valid options are:
  1127. X
  1128. X               file atime name
  1129. X                    Return  a  decimal string giving the time at which
  1130. X                    file name was last accessed.  The time is measured
  1131. X                    in  the  standard  UNIX  fashion as seconds from a
  1132. X                    fixed starting time (often January 1,  1970).   If
  1133. X                    the  file  doesn't exist or its access time cannot
  1134. X                    be queried then an error is generated.
  1135. X
  1136. X               file dirname name
  1137. X                    Return all of the characters in name up to but not
  1138. X                    including the last slash character.  If there  are
  1139. X                    no slashes in name then return ``.''.  If the last
  1140. X                    slash in name is its first character, then  return
  1141. X                    ``/''.
  1142. X
  1143. X               file executable name
  1144. X                    Return 1 if file name is executable by the current
  1145. X                    user, 0 otherwise.
  1146. X
  1147. X               file exists name
  1148. X                    Return  1 if file name exists and the current user
  1149. X                    has search privileges for the directories  leading
  1150. X                    to it, 0 otherwise.
  1151. X
  1152. X               file extension name
  1153. X                    Return  all  of  the  characters in name after and
  1154. X                    including the last dot in name.  If  there  is  no
  1155. X                    dot in name then return the empty string.
  1156. X
  1157. X               file isdirectory name
  1158. X                    Return 1 if file name is a directory, 0 otherwise.
  1159. X
  1160. X               file isfile name
  1161. X                    Return  1  if  file  name  is  a  regular  file, 0
  1162. X                    otherwise.
  1163. X
  1164. X               file mtime name
  1165. X                    Return  a  decimal string giving the time at which
  1166. X                    file name was last modified.  The time is measured
  1167. X                    in  the  standard  UNIX  fashion as seconds from a
  1168. X                    fixed starting time (often January 1,  1970).   If
  1169. X                    the file doesn't exist or its modified time cannot
  1170. X                    be queried then an error is generated.
  1171. X
  1172. X               file owned name
  1173. X                    Return  1  if  file  name  is owned by the current
  1174. X                    user, 0 otherwise.
  1175. X
  1176. X               file readable name
  1177. X                    Return  1  if file name is readable by the current
  1178. X                    user, 0 otherwise.
  1179. X
  1180. X               file rootname name
  1181. X                    Return all of the characters in name up to but not
  1182. X                    including the last ``.'' character  in  the  name.
  1183. X                    If name doesn't contain a dot, then return name.
  1184. X
  1185. X               file size name
  1186. X                    Return  a  decimal  string giving the size of file
  1187. X                    name in bytes.  If the file doesn't exist  or  its
  1188. X                    size cannot be queried then an error is generated.
  1189. X
  1190. X               file stat  namevarName
  1191. X                    Invoke  the  stat kernel call on name, and use the
  1192. X                    variable given  by  varName  to  hold  information
  1193. X                    returned from the kernel call.  VarName is treated
  1194. X                    as an array variable, and the  following  elements
  1195. X                    of  that variable are set: atime, ctime, dev, gid,
  1196. X                    ino, mode, mtime, nlink, size, uid.  Each  element
  1197. X                    is   a  decimal  string  with  the  value  of  the
  1198. X                    corresponding   field   from   the   stat   return
  1199. X                    structure;  see  the  manual  entry  for  stat for
  1200. X                    details on  the  meanings  of  the  values.   This
  1201. X                    command returns an empty string.
  1202. X
  1203. X               file tail name
  1204. X                    Return  all  of  the  characters in name after the
  1205. X                    last slash.  If  name  contains  no  slashes  then
  1206. X                    return name.
  1207. X
  1208. X               file writable name
  1209. X                    Return  1  if file name is writable by the current
  1210. X                    user, 0 otherwise.
  1211. X
  1212. X               The  file  commands  that  return 0/1 results are often
  1213. X               used in conditional or looping commands, for example:
  1214. X
  1215. X                    if {![file exists foo]} then {error {bad file name}}
  1216. X
  1217. X
  1218. END_OF_FILE
  1219. if test 4731 -ne `wc -c <'extended/tcllib/help/commands/file'`; then
  1220.     echo shar: \"'extended/tcllib/help/commands/file'\" unpacked with wrong size!
  1221. fi
  1222. # end of 'extended/tcllib/help/commands/file'
  1223. fi
  1224. if test -f 'extended/tcllib/help/intro/regexps' -a "${1}" != "-c" ; then 
  1225.   echo shar: Will not clobber existing file \"'extended/tcllib/help/intro/regexps'\"
  1226. else
  1227. echo shar: Extracting \"'extended/tcllib/help/intro/regexps'\" \(4341 characters\)
  1228. sed "s/^X//" >'extended/tcllib/help/intro/regexps' <<'END_OF_FILE'
  1229. X     REGULAR EXPRESSIONS
  1230. X          Tcl provides two commands that support string matching using
  1231. X          egrep-style regular expressions: regexp and regsub.  Regular
  1232. X          expressions are implemented using Henry  Spencer's  package,
  1233. X          and  the  description of regular expressions below is copied
  1234. X          verbatim from his manual entry.
  1235. X
  1236. X          A regular expression is zero or more branches, separated  by
  1237. X          ``|''.    It  matches  anything  that  matches  one  of  the
  1238. X          branches.
  1239. X
  1240. X          A branch is zero or more pieces, concatenated.  It matches a
  1241. X          match  for  the  first,  followed by a match for the second,
  1242. X          etc.
  1243. X
  1244. X          A piece is an atom possibly followed  by  ``*'',  ``+'',  or
  1245. X          ``?''.  An atom followed by ``*'' matches a sequence of 0 or
  1246. X          more matches of the atom.  An atom followed by ``+'' matches
  1247. X          a  sequence  of  1  or  more  matches  of the atom.  An atom
  1248. X          followed by ``?'' matches a match of the atom, or  the  null
  1249. X          string.
  1250. X
  1251. X          An atom is a regular expression in parentheses  (matching  a
  1252. X          match  for  the  regular  expression),  a range (see below),
  1253. X          ``.'' (matching any single character), ``^''  (matching  the
  1254. X          null  string  at  the  beginning of the input string), ``$''
  1255. X          (matching the null string at the end of the input string), a
  1256. X          ``\''   followed   by  a  single  character  (matching  that
  1257. X          character), or a single character with no other significance
  1258. X          (matching that character).
  1259. X
  1260. X          A range is a sequence of characters enclosed in ``[]''.   It
  1261. X          normally matches any single character from the sequence.  If
  1262. X          the sequence  begins  with  ``^'',  it  matches  any  single
  1263. X          character  not  from  the  rest  of  the  sequence.   If two
  1264. X          characters in the sequence are separated by ``-'',  this  is
  1265. X          shorthand for the full list of ASCII characters between them
  1266. X          (e.g. ``[0-9]'' matches any decimal digit).   To  include  a
  1267. X          literal  ``]''  in the sequence, make it the first character
  1268. X          (following a possible ``^'').  To include a  literal  ``-'',
  1269. X          make it the first or last character.
  1270. X
  1271. X          If a regular expression could match two different parts of a
  1272. X          string,  it  will  match  the one which begins earliest.  If
  1273. X          both begin in the same place but match different lengths, or
  1274. X          match  the same length in different ways, life gets messier,
  1275. X          as follows.
  1276. X
  1277. X          In general, the possibilities in  a  list  of  branches  are
  1278. X          considered  in  left-to-right  order,  the possibilities for
  1279. X          ``*'', ``+'', and ``?'' are considered longest-first, nested
  1280. X          constructs   are  considered  from  the  outermost  in,  and
  1281. X          concatenated constructs are considered leftmost-first.   The
  1282. X          match  that will be chosen is the one that uses the earliest
  1283. X          possibility in the first choice that has  to  be  made.   If
  1284. X          there  is more than one choice, the next will be made in the
  1285. X          same manner (earliest possibility) subject to  the  decision
  1286. X          on the first choice.  And so forth.
  1287. X
  1288. X          For example, ``(ab|a)b*c'' could match ``abc'' in one of two
  1289. X          ways.   The  first choice is between ``ab'' and ``a''; since
  1290. X          ``ab'' is earlier, and does lead  to  a  successful  overall
  1291. X          match, it is chosen.  Since the ``b'' is already spoken for,
  1292. X          the  ``b*''  must  match  its  last  possibility-the   empty
  1293. X          string-since it must respect the earlier choice.
  1294. X
  1295. X          In the particular case where no ``|''s are present and there
  1296. X          is  only  one ``*'', ``+'', or ``?'', the net effect is that
  1297. X          the longest possible match  will  be  chosen.   So  ``ab*'',
  1298. X          presented with ``xabbbby'', will match ``abbbb''.  Note that
  1299. X          if ``ab*'' is tried against  ``xabyabbbz'',  it  will  match
  1300. X          ``ab''  just  after  ``x'', due to the begins-earliest rule.
  1301. X          (In effect, the decision on where to start the match is  the
  1302. X          first  choice  to  be  made,  hence  subsequent choices must
  1303. X          respect  it  even  if  this  leads  them  to  less-preferred
  1304. X          alternatives.)
  1305. END_OF_FILE
  1306. if test 4341 -ne `wc -c <'extended/tcllib/help/intro/regexps'`; then
  1307.     echo shar: \"'extended/tcllib/help/intro/regexps'\" unpacked with wrong size!
  1308. fi
  1309. # end of 'extended/tcllib/help/intro/regexps'
  1310. fi
  1311. if test -f 'extended/tests/cmdtrace.test' -a "${1}" != "-c" ; then 
  1312.   echo shar: Will not clobber existing file \"'extended/tests/cmdtrace.test'\"
  1313. else
  1314. echo shar: Extracting \"'extended/tests/cmdtrace.test'\" \(4633 characters\)
  1315. sed "s/^X//" >'extended/tests/cmdtrace.test' <<'END_OF_FILE'
  1316. X#
  1317. X# cmdtrace.test
  1318. X#
  1319. X# Tests for the cmdtrace command.
  1320. X#---------------------------------------------------------------------------
  1321. X# Copyright 1991 Karl Lehenbauer and Mark Diekhans.
  1322. X#
  1323. X# Permission to use, copy, modify, and distribute this software and its
  1324. X# documentation for any purpose and without fee is hereby granted, provided
  1325. X# that the above copyright notice appear in all copies.  Karl Lehenbauer and
  1326. X# Mark Diekhans make no representations about the suitability of this
  1327. X# software for any purpose.  It is provided "as is" without express or
  1328. X# implied warranty.
  1329. X#
  1330. X
  1331. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1332. X
  1333. X#
  1334. X# Proc to do something to trace.
  1335. X#
  1336. Xproc DoStuff {} {
  1337. X    set foo [replicate "-TheString-" 10]
  1338. X    set baz $foo
  1339. X    set wap 1
  1340. X    if {$wap} {
  1341. X        set wap 0
  1342. X    } else {
  1343. X        set wap 1
  1344. X    }
  1345. X}
  1346. Xproc DoStuff1 {} {DoStuff}
  1347. Xproc DoStuff2 {} {DoStuff1}
  1348. Xproc DoStuff3 {} {DoStuff2}
  1349. Xproc DoStuff4 {} {DoStuff3}
  1350. X
  1351. X#
  1352. X# Proc to retrieve the output of a trace.  It determines the level of the first
  1353. X# line.  This is used to strip off level number and identation from each line.
  1354. X# so that all lines will be indented the same amount.  It also closes the
  1355. X# trace file.
  1356. X
  1357. Xproc GetTrace {cmdtraceFH} {
  1358. X    set result {}
  1359. X    seek $cmdtraceFH 0 start
  1360. X    if {([gets $cmdtraceFH line] < 2) ||
  1361. X            ([scan $line "%d" level] != 1)} {
  1362. X        error "*Incorrect format for first line of the trace*"
  1363. X    }
  1364. X    set nuke [expr ($level*2)+2]
  1365. X    seek $cmdtraceFH 0 start
  1366. X    while {[gets $cmdtraceFH line] >= 0} {
  1367. X        set linelen [clength $line]
  1368. X        if {$linelen == 0} {
  1369. X            continue}
  1370. X        if {$linelen < $nuke} {
  1371. X            error "invalid trace line: `$line'"}
  1372. X        append result "[crange $line $nuke end]\n"
  1373. X    }
  1374. X    close $cmdtraceFH
  1375. X    return $result
  1376. X}
  1377. X
  1378. Xtest cmdtrace-1.1 {command trace: evaluated, truncated} {
  1379. X    set cmdtraceFH [open CMDTRACE.OUT w+]
  1380. X    cmdtrace on $cmdtraceFH
  1381. X    DoStuff4
  1382. X    cmdtrace off
  1383. X    GetTrace $cmdtraceFH
  1384. X} {DoStuff4
  1385. X  DoStuff3
  1386. X    DoStuff2
  1387. X      DoStuff1
  1388. X        DoStuff
  1389. X            replicate -TheString- 10
  1390. X          set foo -TheString--TheString--TheString--TheStr...
  1391. X          set baz -TheString--TheString--TheString--TheStr...
  1392. X          set wap 1
  1393. X          if $wap {\n        set wap 0\n    } else {\n        set wap 1\n    }
  1394. X            set wap 0
  1395. Xcmdtrace off
  1396. X}
  1397. X
  1398. Xtest cmdtrace-1.2 {command trace: not evaluated, truncated} {
  1399. X    set cmdtraceFH [open CMDTRACE.OUT w+]
  1400. X    cmdtrace on $cmdtraceFH noeval flush
  1401. X    DoStuff4
  1402. X    cmdtrace off
  1403. X    GetTrace $cmdtraceFH
  1404. X} "DoStuff4
  1405. X  DoStuff3
  1406. X    DoStuff2
  1407. X      DoStuff1
  1408. X        DoStuff
  1409. X            replicate \"-TheString-\" 10
  1410. X          set foo \[replicate \"-TheString-\" 10\]
  1411. X          set baz \$foo
  1412. X          set wap 1
  1413. X          if {\$wap} {\\n        set wap 0\\n    } else {\\n        set wap 1...
  1414. X            set wap 0
  1415. Xcmdtrace off
  1416. X"
  1417. X
  1418. Xtest cmdtrace-1.3 {command trace: evaluated, not truncated} {
  1419. X    set cmdtraceFH [open CMDTRACE.OUT w+]
  1420. X    cmdtrace on $cmdtraceFH notruncate
  1421. X    DoStuff4
  1422. X    cmdtrace off
  1423. X    GetTrace $cmdtraceFH
  1424. X} {DoStuff4
  1425. X  DoStuff3
  1426. X    DoStuff2
  1427. X      DoStuff1
  1428. X        DoStuff
  1429. X            replicate -TheString- 10
  1430. X          set foo -TheString--TheString--TheString--TheString--TheString--TheString--TheString--TheString--TheString--TheString-
  1431. X          set baz -TheString--TheString--TheString--TheString--TheString--TheString--TheString--TheString--TheString--TheString-
  1432. X          set wap 1
  1433. X          if $wap {\n        set wap 0\n    } else {\n        set wap 1\n    }
  1434. X            set wap 0
  1435. Xcmdtrace off
  1436. X}
  1437. X
  1438. Xtest cmdtrace-1.4 {command trace: not evaluated, not truncated} {
  1439. X    set cmdtraceFH [open CMDTRACE.OUT w+]
  1440. X    cmdtrace on $cmdtraceFH notruncate noeval flush
  1441. X    DoStuff4
  1442. X    cmdtrace off
  1443. X    GetTrace $cmdtraceFH
  1444. X} {DoStuff4
  1445. X  DoStuff3
  1446. X    DoStuff2
  1447. X      DoStuff1
  1448. X        DoStuff
  1449. X            replicate "-TheString-" 10
  1450. X          set foo [replicate "-TheString-" 10]
  1451. X          set baz $foo
  1452. X          set wap 1
  1453. X          if {$wap} {\n        set wap 0\n    } else {\n        set wap 1\n    }
  1454. X            set wap 0
  1455. Xcmdtrace off
  1456. X}
  1457. X
  1458. Xtest cmdtrace-1.5 {command trace argument error checking} {
  1459. X    list [catch {cmdtrace foo} msg] $msg
  1460. X} {1 {expected integer but got "foo"}}
  1461. X
  1462. Xtest cmdtrace-1.6 {command trace argument error checking} {
  1463. X    list [catch {cmdtrace on foo} msg] $msg
  1464. X} {1 {cmdtrace:invalid option: expected one of noeval, notruncate, flush or a file handle}}
  1465. X
  1466. Xtest cmdtrace-1.6 {command trace argument error checking} {
  1467. X    catch {close file20}
  1468. X    list [catch {cmdtrace on file20} msg] $msg
  1469. X} {1 {file "file20" isn't open}}
  1470. X
  1471. Xunlink CMDTRACE.OUT
  1472. END_OF_FILE
  1473. if test 4633 -ne `wc -c <'extended/tests/cmdtrace.test'`; then
  1474.     echo shar: \"'extended/tests/cmdtrace.test'\" unpacked with wrong size!
  1475. fi
  1476. # end of 'extended/tests/cmdtrace.test'
  1477. fi
  1478. echo shar: End of archive 8 \(of 23\).
  1479. cp /dev/null ark8isdone
  1480. MISSING=""
  1481. 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
  1482.     if test ! -f ark${I}isdone ; then
  1483.     MISSING="${MISSING} ${I}"
  1484.     fi
  1485. done
  1486. if test "${MISSING}" = "" ; then
  1487.     echo You have unpacked all 23 archives.
  1488.     echo "Now cd to "extended", edit the makefile, then do a "make""
  1489.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1490. else
  1491.     echo You still need to unpack the following archives:
  1492.     echo "        " ${MISSING}
  1493. fi
  1494. ##  End of shell archive.
  1495. exit 0
  1496.  
  1497. exit 0 # Just in case...
  1498. -- 
  1499. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1500. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1501. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1502. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1503.