Compare commits

...
Author SHA1 Message Date
Joe Mistachkin ebb646039f Also finalize the condition variables for each notifier thread. 2013-10-29 00:30:40 +00:00
Joe Mistachkin e175267bec Some cleanup of the previous assumptions. 2013-10-29 00:19:22 +00:00
Joe Mistachkin 65878c47af Add experimental new Tcl API Tcl_UnsetThreadData. 2013-10-28 23:39:40 +00:00
Joe Mistachkin 543cd3200b Another attempt to cleanup stale remnants of the notifier subsystem. 2013-10-28 22:40:14 +00:00
Joe Mistachkin d75c345663 Try resetting all the 'one time' locks as well. 2013-10-28 21:45:52 +00:00
Joe Mistachkin 1172c3966d Attempt to make sure the notifier gets fully re-initialized. 2013-10-28 21:01:47 +00:00
andreask d0abfbe72a Tweak to the fix. Tcl_InitNotifier() hangs. Removed. Fixes exec. Unclear about Rivet with original case. 2013-10-28 20:21:13 +00:00
Joe Mistachkin 18aadfce45 Prototype of fix for ticket [414d10346b]. 2013-10-28 19:34:15 +00:00
jan.nijtmans c4047c81e6 Bump tcltest version to 2.3.6 (should have been done just before the 8.5.15 release, just as in Tcl 8.6.1).
Don't fix eol-style for Makefile.in in "make dist", if the file system is case-insensitive/case-preserving.
2013-10-28 10:55:37 +00:00
jan.nijtmans 216ade8493 Fix [3eb2ec1449]: Allow upper case scheme names in url. http -> 2.7.13 2013-10-25 12:57:19 +00:00
dkf 383f020ee8 [3556215]: Made [scan] match [format] better in what it accepts as a format
string, by allowing uppercase %X, %E and %G.
2013-10-22 18:55:02 +00:00
jan.nijtmans edbfaa468e Fix execute permission on many files which shouldn't have it. 2013-10-17 09:28:11 +00:00
jan.nijtmans 9d1312440e Update to Unicode 6.3 tables 2013-10-09 21:57:26 +00:00
jan.nijtmans 3ad87b0a02 Fix for [d4e464ae48]: tcl 8.5.15/8.6.1 breaks python make check on darwin 2013-10-07 14:23:00 +00:00
jan.nijtmans c83af8f8d4 First attempt to fix bug [d4e464ae48]: tcl 8.5.15/8.61 breaks python make check on darwin 2013-10-06 19:27:50 +00:00
Kevin B Kenny 7413854f34 Advance to tzdata2013g 2013-10-05 16:22:16 +00:00
jan.nijtmans 73b02508fa When compiling with MSVC++, no longer link the stub library with msvcrt??.dll.
This way, workarounds in extensions like [http://core.tcl.tk/itcl/info/a961f0729c] are no longer necessary.
2013-10-03 15:17:43 +00:00
jan.nijtmans 5e1eaa44bc Fix compilation with latest MinGW-w64 version 3.0: Conflict on EXCEPTION_REGISTRATION typedef, which means something completely different in MinGW-w64. 2013-10-02 07:58:50 +00:00
jan.nijtmans c5f68dde5c Disable command line globbing on MinGW compiles: this saves startup time, since the result of the glob is not used anywhere. 2013-09-30 14:03:56 +00:00
jan.nijtmans 878c0cff52 Cherrypick [87d1313df3] from trunk:
Workaround for [http://sourceforge.net/p/mingw/bugs/2065/|MinGW bug #2065]. 
Both MinGW and MinGW-w64 (32-bit) are affected. 
Even though Win64 is not affected, adding -static-libgcc doesn't harm there, and we don't want to distrubute additional dll's with MinGW-compiled Tcl anyway.
2013-09-27 09:35:05 +00:00
dkf ce9b84204c [d614d63989] Ensure that there are no trailing colons as that causes chaos when a deleteProc is specified. 2013-09-25 22:54:29 +00:00
dgp e929b91222 Test demonstrating need for "adjust" manipulation in TclSubstTokens. 2013-09-25 16:39:26 +00:00
jan.nijtmans 96fec1a88c workaround for mingw bug [http://comments.gmane.org/gmane.comp.gnu.mingw.user/41724] 2013-09-23 11:12:12 +00:00
dgp c91c7b7cf1 Line numbers wrong in compiled [global] and [variable]. 2013-09-19 16:33:36 +00:00
dgp bfcb6b40d2 renumber tests for branch merge 2013-09-19 16:06:53 +00:00
dgp 2440231062 Line numbers wrong in compiled [namespace upvar]. 2013-09-19 16:04:48 +00:00
dgp aed9fbb19c Line numbers wrong in compiled [upvar]. 2013-09-19 15:44:21 +00:00
dgp e4dfb0d689 Line numbers wrong in compiled [dict update]. 2013-09-19 15:04:47 +00:00
dgp 7887926261 Line numbers wrong in compiled [dict for]. 2013-09-19 14:55:05 +00:00
dgp cb5d76ed2b Line numbers wrong in compiled [dict get]. 2013-09-19 14:48:02 +00:00
dgp 657b49a9d1 Stop segfault due to OBOE in CompileWord() calls in [dict incr] compiler. 2013-09-19 14:06:46 +00:00
dgp 1b0845930c Line numbers wrong in compiled [dict set]. 2013-09-19 13:06:06 +00:00
jan.nijtmans ad07565ec0 consistant use of capitals. 2013-09-19 12:37:13 +00:00
dgp a414da9341 Line numbers wrong in compiled foreach body. 2013-09-19 12:20:13 +00:00
dgp 134ada8ff9 Stop segfault due to OBOE in CompileWord() calls in [dict lappend] compiler. 2013-09-19 04:20:53 +00:00
dgp 7bc81bcbb0 [3487626] Backport fix for knownBug test dict-23.2. 2013-09-19 04:03:57 +00:00
dgp 6d44125712 merge release 2013-09-18 19:13:31 +00:00
dgp 08390e5c47 Added note to ChangeLog pointing to the fossil timeline for better logging. 2013-09-13 16:02:11 +00:00
dgp a52254cce9 merge 8.5; update changes 2013-09-13 14:14:24 +00:00
dgp bcb4faa32f [bdd91c7e43] Stop crash due to error in execution stack memory management.
Thanks to azazel for the fix.
2013-09-13 14:09:09 +00:00
jan.nijtmans fa65ef51ba Suggested fix for [bdd91c7e43]: tclsh crashes in [interp delete] 2013-09-13 10:53:32 +00:00
dgp a8bbc9486a merge 8.5. update changes. 2013-09-08 03:26:12 +00:00
dgp bb55ca2e95 [86ceb4e2b6] Improve reaction when multiple *tm files purport to offer the
same version of the same package.  Prefer the file that comes first on
the tm path.  Makes TCL*_TM_PATH variables more useful.  Thanks to
Gustaf Neumann for the suggestion.
2013-09-07 21:36:37 +00:00
dgp 0288a572d8 merge trunk 2013-09-07 21:19:47 +00:00
dgp 1ecf461e41 Partial revert of [a16752c252] bug fix to stop crashes in buggy tclcompiler. 2013-09-07 18:49:55 +00:00
dgp 97f9595151 Partial revert of [a16752c252] bug fix to stop crashes in buggy tclcompiler. 2013-09-05 17:21:41 +00:00
dgp 30710a181c Use ne instead of [string length] for less shimmer risk. 2013-09-05 15:47:29 +00:00
dgp 493b04cbc0 Error in order of #include lines broke some windows builds. 2013-09-05 12:45:11 +00:00
dgp 8938dbcc25 Merge commits to the correct branch -- trunk 2013-09-05 12:35:24 +00:00
dgp db738e7756 [010f4162ef] Repair effect of trace errors on -errorinfo and -errorstack. 2013-09-05 12:31:46 +00:00
dgp c6bb98e763 Cleaned up test command trying to make valgrind happy. 2013-09-04 12:45:51 +00:00
dkf c938932757 [98c8b3ec12] Make test fail in less catastrophic manner. 2013-09-04 09:36:22 +00:00
jan.nijtmans 9878106deb Fix 3 trivial (possible) errors, discovered by covertity.com 2013-09-04 07:22:45 +00:00
dgp 53dc4dcdee Favor timeline over ChangeLog 2013-09-03 16:45:56 +00:00
dgp a313e78ffa some missed changes 2013-09-03 16:04:06 +00:00
dgp 2c3dbea378 Add test and improve errorInfo. 2013-09-02 18:47:07 +00:00
dgp 8520e69f32 [010f4162ef] First step of fix on stammering errorstack. errorstack fixed.
errorinfo revision still under consideration.
2013-09-02 17:59:42 +00:00
jan.nijtmans 54223a5f7e typo 2013-09-02 14:01:00 +00:00
dkf 22515fc47f [b98fa55285]: Fix handling of whitespace at end of hex strings to decode. 2013-09-01 20:08:50 +00:00
dgp 6b45d21b4b Bump to tcltest 2.3.6 to account for changes since Tcl 8.6.0 release. 2013-08-30 21:57:26 +00:00
dgp 3adc645802 fix date 2013-08-30 14:31:06 +00:00
dgp 743ced9da3 changes 2013-08-30 14:16:05 +00:00
dgp b9ef276505 Bump to 8.5.15 for release. 2013-08-29 20:08:04 +00:00
dgp ebd7e8a86b [2486550] NR-enable same-interp invokehidden. Also, reroute all objProc
invocation through the common routines of EvalObjvCore and Dispatch.
2013-08-29 19:19:32 +00:00
dgp 4096bf5d01 New internal eval flag value so that all TclNREvalObjv() callers that
pre-resolve command names can choose whether or not TclNREvalObjv() should
attempt to re-do the resolution from objv[0] when something goes wrong.
2013-08-29 17:59:36 +00:00
dgp 6dcfcb8be9 Rework the re-resolution after enter traces machinery with cleaner
separations and neater interfaces.
2013-08-28 18:05:07 +00:00
dgp 24cec35f7b Clarfy and prettify influence of flag settings and command lookups. 2013-08-28 02:44:50 +00:00
dgp 367ade79ed Tidy up indenting for clarity in refactoring. 2013-08-27 20:25:15 +00:00
dgp e6af5d333b Exceptions raised from enter traces take priority over re-resolution games. 2013-08-27 20:06:08 +00:00
dgp 24be1383da Inline TEOV_RunEnterTraces() so its interface can be redesigned. 2013-08-27 20:03:57 +00:00
dgp 28384139ba Add test for Bug 2486550. 2013-08-27 18:11:53 +00:00
dgp e5b2f21fe9 merge trunk 2013-08-26 18:32:55 +00:00
dkf ccbbb5d288 Unbreak doc; the apropos index entry *must* be one line.
(This is an external constraint forced by the requirement to fit into the standard Unix manual system.)
2013-08-24 09:42:43 +00:00
dgp 2d27ea7088 merge trunk 2013-08-23 16:33:34 +00:00
dgp a33a94ec85 Make sure all Tcl_NR*Eval*() routines do a schedule only. No errors raised. 2013-08-23 16:23:47 +00:00
mig f36f801d24 fix NRE docs 2013-08-23 13:08:15 +00:00
dgp 841e525556 merge trunk 2013-08-23 12:04:12 +00:00
dgp 55b0c17067 Remove complications that no longer server any required purpose. 2013-08-23 05:59:48 +00:00
dgp 993b39c491 merge trunk 2013-08-22 20:41:02 +00:00
dgp 272b2008ad compiler warning 2013-08-22 20:34:30 +00:00
dgp f7cf1b2bae Make Dispatch() the single point for calling a Tcl_ObjCmdProc, and attach
the DTRACE machinery there (one place, not two).
2013-08-22 20:21:15 +00:00
dgp 8173bccfd9 Remove assertion that is not true in some circumstances (--enable-dtrace). 2013-08-22 16:13:29 +00:00
dgp a5b75dfa9a More coroutine tests. 2013-08-22 13:01:31 +00:00
dkf 52b97dd00b Correction to documentation 2013-08-22 08:07:33 +00:00
dgp 987eb68977 merge trunk 2013-08-22 01:13:13 +00:00
dgp f632850eb8 [8ff0cb9fe1] Make Tcl_NREvalObj() (and friends) behave as documented, by
only scheduling evaluation and not doing any of it until the caller routine
returns.  This fixes some serious errors in [coroutine] too.
2013-08-21 19:30:01 +00:00
dgp ed72e77b7d Tidy the code and add a test. 2013-08-21 19:18:28 +00:00
dgp 83d427e824 Don't allocate memory until you know you're going to use it and arrange for
it to be freed.  Leak!
2013-08-21 19:00:17 +00:00
dgp f18c1126d5 Don't use automatic storage to hold the invocation words of oo::define.
That practice doesn't agree with NRE execution.
2013-08-21 18:27:23 +00:00
dgp 62e1b3723e merge trunk 2013-08-21 13:34:19 +00:00
dkf 4d6aaa2e8b [3612422]: Refer to correct part of tclvars(n) rather than page itself. 2013-08-21 10:25:18 +00:00
dgp 4bf79aef9b Push out a trial patch for more eyes to see. 2013-08-20 14:00:05 +00:00
dgp 066a4b7b35 Revise execution trace handling to take account of the new reality in
Tcl 8.6 that callers can pre-resolve a cmdPtr for us.  In that case
a re-resolution in the form of another command name lookup isn't the right
thing.
2013-08-19 16:34:10 +00:00
dgp a6f2dee7fb Testing doing away with the NRRunObjProc routine, which looks like a
useless extra bounce on the NRE trampoline.

Normal testing has no problem with it, but debug-enabled testing
triggers an assert failure.

Either it would be good to have a normal test that fails in the conditions
of the assert failure, or it would be good to discover the assert is
asserting something not actually required, and then make the purge.
2013-08-19 15:22:15 +00:00
dgp a7e397556b merge trunk 2013-08-15 20:00:34 +00:00
dgp c084f0ea75 Make sure the errors raised by execution traces become errors raised by the
traced command, as documented. Deletion of the traced command was supressing
that.
2013-08-15 19:59:32 +00:00
dgp 5cdaf0e05b Make sure the errors raised by execution traces become errors raised by
the traced command, as documented.  Deletion of the traced command was
supressing that.
2013-08-15 19:55:26 +00:00
dgp 200e0742b8 merge trunk 2013-08-15 17:43:39 +00:00
dgp fe60431f53 The fix for [3610404] leads to a simplification in the implementation of
forward methods.
2013-08-15 14:05:02 +00:00
dgp 160ba1cb95 merge trunk 2013-08-14 20:31:16 +00:00
dgp 058f0df44d Add several tests to check consistency of stack traces. 2013-08-14 20:20:11 +00:00
dgp ff926f2b01 merge trunk 2013-08-14 19:07:01 +00:00
dgp bee5c35f44 [3610404] Re-resolution of command after enter traces invalidate epoch.
Make sure context is such that correct resolution happens.
2013-08-14 19:01:38 +00:00
dgp 8971b5cdea merge trunk 2013-08-14 18:44:51 +00:00
dgp b2e3f2fa04 merge trunk 2013-08-14 18:00:45 +00:00
dgp 0c1e275cdf [a16752c252] Correct failure to call cmd deletion callbacks. 2013-08-14 17:07:00 +00:00
dgp a2400fbe30 [a16752c252] Correct failure to call cmd deletion callbacks. 2013-08-14 17:02:41 +00:00
dgp 211f7d6466 Arrange for both execution traces and [info frame] to get their pre-subst
source strings from a common routine.
2013-08-14 12:43:22 +00:00
dgp 6dee5b3e07 Consolidate some helper routines. 2013-08-14 12:15:59 +00:00
dgp 9d1f38c3e3 Only schedule leave traces if enter traces complete successfully.
This avoids a memleak, and opens a data slot, so we can pass objc, objv
without the need to copy them into a list value.
2013-08-14 04:13:21 +00:00
dgp 33647e79c8 Use a new flag value TCL_EVAL_SOURCE_IN_FRAME passed in by callers to
determine whether the pre-subst source information in a CmdFrame is to
be used.  This takes the place of numLevels cross checking, so that field
is removed.  Routines are consolidated as well.
2013-08-12 20:00:14 +00:00
dgp f440a6ef41 merge trunk 2013-08-12 15:52:28 +00:00
jan.nijtmans c086de021c Never guess non-existing timezone name "America/Brasilia" on Windows. Reported by Arnulf Wiedemann 2013-08-11 14:42:24 +00:00
jan.nijtmans 97eb71a629 Never guess non-existing timezone name "America/Brasilia" on Windows. Reported by Arnulf Wiedemann 2013-08-11 14:41:10 +00:00
dgp e62b40c808 Arrange for both execution traces and [info frame] to get their pre-subst
source strings from a common routine, with care taken to reduce copying
by that routine.
2013-08-10 05:16:38 +00:00
dgp 234fb04984 Revised GetCommandSource() can (and thus should) return a normal zero
refcount value.
2013-08-09 16:48:30 +00:00
dgp 1b7d424507 Revise GetCommandSource() to return a normal Tcl_Obj value. 2013-08-07 20:27:30 +00:00
dgp 5797625e42 Give (objc, objv) their own ride from enter to leave traces. 2013-08-07 19:45:13 +00:00
dgp 987422a01f Many simplifications to the TIP 280 machinery.
* Removed support for non-NULL invoker when TCL_EVAL_DIRECT requested.
   * Eliminated TCL_EVAL_CTX eval flag.
   * Removed Tcl_Preserve-ability of ContLineLoc pointers.
   * Removed clLoc field of CompileEnv struct.
2013-08-07 17:11:21 +00:00
dgp 5f6b71f3f2 Remove Tcl_Preserve support for ContLineLoc values. It's not needed.
This allows the clLoc field of CompileEnv struct to go away too.
2013-08-07 16:44:03 +00:00
dgp f6f0891fff Test for TclContinuationsGet() usage, and simplifications. 2013-08-07 16:01:53 +00:00
dgp 27c5ada57e Replace potentially memleak creating safety check of a "cannot happen"
condition with an assertion.
2013-08-07 14:41:46 +00:00
dgp 5f2f5b63c3 Add comment stating new limitation on Tcl(NR)EvalObjEx() interface. 2013-08-07 12:44:42 +00:00
dgp 59f7320bdd All use of the evalFlag value TCL_EVAL_CTX is unused by the code and
unreachable by extensions.  This checkin removes all the code supporting
that flag value.

The consequence is that all the calls to TclNREvalObjEx() and its callers
that are currently choosing not to pass the TCL_EVAL_DIRECT flag in when
they pass in a non-NULL invoker will no longer be free to change their
mind.  That might be reason not to adopt this change.
2013-08-06 17:24:40 +00:00
dgp 00546e5e21 The value TCL_LOCATION_EVAL_LIST in the type field of a CmdFrame appears to
exist only for the sake of taking great pains to make sure that pure list
values remain pure list values.

The value of pure list values is no longer what it once was. For a long long
time now, any canonical list values have been equally good.
2013-08-06 16:41:41 +00:00
dgp a63563bd9a Add assertions that will guide and protect more discovery of dead code for elimination. 2013-08-06 16:20:59 +00:00
dgp 1d99884b08 Drop TCL_LOCATION_EVAL_LIST now that it is unused. 2013-08-06 13:30:36 +00:00
dgp 8bd533d76e Eliminate the union that is no longer needed. 2013-08-06 13:20:36 +00:00
dgp 23d61a10c2 Revert the changes that went too far and broke things. 2013-08-06 13:08:54 +00:00
dgp 0ee8df700b The value TCL_LOCATION_EVAL_LIST in the type field of a CmdFrame appears to
exist only for the sake of taking great pains to make sure that pure list
values remain pure list values.

The value of pure list values is no longer what it once was.  For a long long
time now, any canonical list values have been equally good.  This branch
is Work In Progress eliminating the complication of the additional type value.

Currently some minor botches are breaking execution tracing tests.
2013-08-06 04:15:16 +00:00
jan.nijtmans 50a950f2b1 Mark unixforkevent-1.1 nonPortable, until proven on more platforms.
Make sure that when testing for pthread_atfork the thread library is taken into account.
2013-08-05 22:00:58 +00:00
jan.nijtmans c74640849e Mark unixforkevent-1.1 nonPortable, until proven on more platforms. 2013-08-05 21:58:21 +00:00
dkf 861b34625c [3611643fff]: Support TclOO in autoload mechanism. 2013-08-03 15:27:40 +00:00
dkf 0958b92b37 Deal with the elaborate rip-apart-a-metaclass case as well. 2013-08-02 20:19:44 +00:00
dkf 6d9ae4aa16 [9d61624b3d]: Stop crashes when emptying the superclass slot. 2013-08-02 14:58:58 +00:00
dgp 965128fe34 [1905562] [8d2c0da36d] Raise the recursion limits on regexps to allow
existing regexps "in the wild" to continue working with Tcl 8.6.
Latest example comes from DejaGnu.
2013-08-01 19:18:02 +00:00
jan.nijtmans ebc5b27c8c Tcl_InitNotifier: Bug [a0bc856dcd]. Start notifier thread again if we were forked, to solve Rivet bug 55153 2013-08-01 12:54:16 +00:00
jan.nijtmans 3916ce9d4c Tcl_InitNotifier: Bug [a0bc856dcd].
Start notifier thread again if we were forked, to solve Rivet bug 55153
2013-08-01 12:38:04 +00:00
jan.nijtmans 4bd227bc12 Make sure that "string is space \u202f" will continue to return "1", even if in future Unicode this character (NARROW_NO_BREAK_SPACE) will cease to be a space. See: [http://www.unicode.org/review/pri249/].
Don't hardcode "tclWinError.o" for Cygwin
2013-07-29 10:12:12 +00:00
jan.nijtmans 84e92af6dc Make sure that "string is space \u202f" will continue to return "1", even if in future Unicode this character (NARROW_NO_BREAK_SPACE) will cease to be a space. See: [http://www.unicode.org/review/pri249/] 2013-07-29 09:29:16 +00:00
dgp 15ca940ca7 Simplify AuxData access with a macro. 2013-07-27 20:29:42 +00:00
dgp 525bc7c9b5 [6585b21ca8] [regexp {(\w).*?\1} abb] failed to match. Thanks to Tom Lane for passing on the discovery in Postgres. 2013-07-26 13:24:19 +00:00
dgp 6adf3b8c6c [6585b21ca8] [regexp {(\w).*?\1} abb] failed to match.
Thanks to Tom Lane for passing on the discovery in Postgres.
2013-07-26 13:21:30 +00:00
jan.nijtmans 3d14dd6bc9 Move test for pthread_atfork inside SC_ENABLE_THREADS 2013-07-26 09:20:28 +00:00
oehhar 41afeeec2b Fixed test case variable clash with 'folder' 2013-07-25 17:20:02 +00:00
jan.nijtmans 623c1cbe5b rebase 2013-07-25 14:25:47 +00:00
jan.nijtmans 60ef39d24a Move test for pthread_atfork inside SC_ENABLE_THREADS 2013-07-25 14:24:39 +00:00
jan.nijtmans 889454ec06 Make sure that the notifierMutex and notifierCV in a forked child cannot block anything, even though the initialization of the Notifier Thread in the parent is not finished yet. 2013-07-25 08:29:56 +00:00
jan.nijtmans 752ab085d6 rebase 2013-07-25 07:02:59 +00:00
jan.nijtmans c019848148 Put Cygwin's tclWinError.o in PLAT_OBJS, not in DL_OBJS 2013-07-25 06:59:08 +00:00
dgp fd1c7c2fb3 Demonstrate and fix memory leak in Tcl_ParseVar(). 2013-07-24 16:56:59 +00:00
dgp 8f2d19b951 Demonstrate and fix memory leak in Tcl_ParseVar(). 2013-07-24 16:51:04 +00:00
dgp f2bea640bb Mark commands with potential to compile expansion arguments (as [list] does). 2013-07-24 13:58:35 +00:00
dgp d818803502 more disabled code removal 2013-07-24 12:13:01 +00:00
dgp e0437fdf58 Remove outdated, disabled code. 2013-07-23 20:11:00 +00:00
dgp 8163234efd Remove outdated comment. Stack depths are well checked now. 2013-07-23 18:03:39 +00:00
dgp f796ad762c Stop checking stack depth in [catch] compiler.
Stack depth is checked in compiles of *all* Tcl commands/scripts/bodies
in debug builds already.
2013-07-23 18:01:36 +00:00
jan.nijtmans 0185dd6477 rebase 2013-07-23 09:54:05 +00:00
jan.nijtmans 07d10b8a58 Add "testfork" test command. Not used in any test-case yet 2013-07-23 09:27:59 +00:00
jan.nijtmans bc28cd1ac8 Add "testfork" test command. Not used in any test-case yet 2013-07-23 09:07:21 +00:00
jan.nijtmans 9350513d16 Tcl_InitNotifier() call in TestforkObjCmd() is only necessary when pthread_atfork() is not available. 2013-07-22 11:11:10 +00:00
jan.nijtmans 4fb5d04b2f Use pthread_atfork() when available. 2013-07-22 10:57:44 +00:00
jan.nijtmans f287d8cb0f Test-case should pass on Darwin or with non-threaded build as well. 2013-07-22 10:11:05 +00:00
jan.nijtmans 0c2e553e8f Fix bug which hangs iocmd.tf-32.1 2013-07-22 10:10:00 +00:00
oehhar 915c6abe66 Test file tests/unixForkEvent.test added 2013-07-22 08:45:37 +00:00
jan.nijtmans 0070244914 Rebase to core-8-5-branch
Add "testfork" test command to be usable in testcase.
2013-07-21 14:52:57 +00:00
dgp 17ebc3cd20 Rewrite of the TclCompileScript() routine.
Primarily this breaks that large, rather convoluted routine into many
smaller more single-purpose routines for greater clarity.  This also
permits more sharing of function components.  Ensemble compiles now share
the same low level routines as top-level command compiles.  This refactoring
should also have the benefit of easing merging between branches by better
locating patches according to what function or data structure they tweak.

Also in this checkin:
    Minimized calls to Tcl_ResetResult() during compile.
    Several commands compile their detected syntax errors into
	bytecode that reports the syntax error.
    Significant reform to the TIP 280 machinery, including elimination
	of the litInfo hash table.  Its function of finding the index
	of a compiled command in a script from a pc value has been redone
	using the codeDelta information already stored in ByteCode.
2013-07-18 20:27:01 +00:00
dgp 5e9e003379 [assemble] compile syntax error into bytecode reporting syntax error message. 2013-07-18 18:25:24 +00:00
dgp 2aed1acbd1 merge trunk 2013-07-18 15:42:54 +00:00
dgp 81a1a91361 [Bug 1c17fbba5d] Fix -errorinfo from syntax errors so that the error is
not obscured.  Instead highlight it by making it the last character quoted.
2013-07-18 15:05:18 +00:00
oehhar 9a19e4cba0 Start notifier thread again if we were forked, to solve Rivet bug 55153 - RFE [a0bc856dcd] 2013-07-17 16:02:36 +00:00
dgp c2d6c48dd9 Factor out the call to a compileProc into one place used by both ensemble
subcommand compiles and toplevel command compiles in TclCompileScript.
2013-07-17 13:57:23 +00:00
dgp d383707870 Streamline the housekeeping on the operands of INST_START_CMD.
For example, do only incr on success, not incr on attempt + decr on error.
2013-07-16 20:48:37 +00:00
dgp c33f97005c Simplify the ensemble subcommand compile. There's no need to be
crafting synthetic Tcl_Parse and copying tokens.  Some pointer shifts will do.
2013-07-16 17:21:12 +00:00
dgp 3f126895fb Simplify arguments to TclContinuationsEnterDerived(). 2013-07-16 14:52:33 +00:00
dgp d848f30c45 Eliminate the litInfo table and all the code tending to its care and feeding.
The pc -> command index mapping function it provided can be achieved using
other data already in the ByteCode struct.
2013-07-16 14:07:41 +00:00
dgp d860a2c3a4 Build CompileBasicNArgCommand on top of TclCompileInvocation. 2013-07-15 20:16:11 +00:00
dgp 009f2adf3d merge trunk 2013-07-15 19:40:33 +00:00
dgp 5684ad8d94 Possible improvement in light of [86ceb4e2b6]. 2013-07-15 19:09:59 +00:00
dgp 774c402365 Prefer CompileWord() over CompileTokens() when possible. 2013-07-15 17:07:51 +00:00
dgp 740d1811bc Global replace: CompileBody() -> BODY(). 2013-07-12 18:44:15 +00:00
dgp 451ab6927c Tests demonstrating the need for the last two SetLineInformation() calls. 2013-07-12 16:25:51 +00:00
dgp f302557ad5 Revise the CompileWord() and PushVarNameWord() macros to make explicit the
SetLineInformation() that's in each of them.
2013-07-11 23:19:14 +00:00
dgp d061b31460 Have TclMakeEnsemble() set ENSEMBLE_COMPILE at creation, not as a separate
epoch-bumping step.
2013-07-11 17:06:35 +00:00
dgp 783aea7d3a merge trunk 2013-07-11 04:12:01 +00:00
dgp 34c17bad36 Add a test for each call to SetLineInformation() demonstrating the need
for it to be there.  Fixed bugs revealed by the new tests.

What's still missing are more tests demonstrating the need for other
SetLineInformation() calls that are not there yet. ;)
2013-07-11 04:07:39 +00:00
dgp f0992177e4 Revert the revised macros used in developing the new tests. 2013-07-11 04:00:57 +00:00
dgp 6f4f296706 Add tests for the SetLineInformation() calls in tclEnsemble.c, and fix
the bugs around those calls exposed by the tests.
2013-07-11 03:48:40 +00:00
dgp 75bc23d59c Add tests for SetLineInformation() calls in tclCompCmdsSZ.c as well as some
obvious refactoring improvements.
2013-07-10 20:33:45 +00:00
dgp 9d91a3db0b Add tests for SetLineInformation() calls in tclCompCmdsGR.c. 2013-07-10 19:43:56 +00:00
dgp 1dc19d8370 Add tests for, and fix bugs in, the SetLineInformation() calls in tclCompCmds.c. 2013-07-10 19:34:55 +00:00
dgp 458197828b merge trunk 2013-07-10 18:02:20 +00:00
dgp c079ab076f Fix for [86fb5ea28e]. Test will eventually merge in from tip280-test-coverage. 2013-07-10 17:58:45 +00:00
dgp d69c39d52e Next attempt. Appears to have uncovered a bug. 2013-07-10 16:43:01 +00:00
dgp 7a53c36e3a First additional test. Remove dup macros in tclEnsemble.c. 2013-07-10 16:27:09 +00:00
dgp ee74db1cbf Disabling the SetLineInformation() macro entirely causes only 3 tests
in the test suite to fail.  Restoring just 2 SetLineInformation() calls
fixes those failures.  The need for all the other SLI() calls is not
demonstrated by any test.  Without more complete test coverage, it is
difficult to confidently tweak the TIP 280 implementation without fear
that changes are introducing breakage.
2013-07-10 16:17:12 +00:00
dgp 1e62f5ac76 Remove the (now unused) wlineat arguments. 2013-07-10 03:28:37 +00:00
dgp afad6ffbb4 Revise the litInfo table so that it gets built later (in TclInitByteCodeObj)
from a simpler store of data that can unwind.
2013-07-10 03:17:57 +00:00
dgp d72d5f8b7a Tentative Work In Progress unwinding TIP 280 line information. 2013-07-09 20:37:37 +00:00
dgp c46c774126 Use the TokenAfter() macro. 2013-07-08 23:02:44 +00:00
dgp ba3bf9b61f Use TIP 280 macros. 2013-07-08 22:36:55 +00:00
dgp 82bddf4dca merge trunk 2013-07-08 19:54:50 +00:00
dgp e10479f3d7 Factor out compiling the Command literal. 2013-07-08 19:29:01 +00:00
jan.nijtmans 7183692271 Unbreak MSVC6 debug build (thanks Andreas Kupries!) 2013-07-08 18:56:13 +00:00
jan.nijtmans b7fbf3c433 Unbreak MSVC6 debug build (thanks Andreas Kupries!) 2013-07-08 18:55:23 +00:00
dgp c10c796a46 Plug memory leak; Break three compilation mechanisms into routines. 2013-07-08 18:08:01 +00:00
dgp 582824087d Move TIP 280 and command extent housekeeping to the periphery. 2013-07-08 15:39:55 +00:00
dgp da4296c06f Defer expansion request detection as much as possible. 2013-07-08 15:24:56 +00:00
dgp 0dec640514 Consolidate the StartExpanding() calls. 2013-07-08 15:00:02 +00:00
dgp d2b490f552 The routines StartExpanding() and EnterCmdWordData() are orthogonal, so it's
ok to reverse the order in which they are called.
2013-07-08 14:31:14 +00:00
dgp 4cfafc3002 merge trunk 2013-07-08 12:55:06 +00:00
jan.nijtmans fb3fc7d5d3 Build stub objects with -DSTATIC_BUILD on all platforms. Only important on win32 (already done) and cygwin, on other platforms it should not have any effect. 2013-07-08 06:51:16 +00:00
jan.nijtmans de31df63e7 Build stub objects with -DSTATIC_BUILD on all platforms. Only important on win32 (already done) and cygwin, on other platforms it should not have any effect. 2013-07-08 06:49:44 +00:00
jan.nijtmans a7bebaafdb merge-mark 2013-07-07 09:15:37 +00:00
stwo bd6afa9af5 OpenBSD/m88k is now elf. Remove unneeded elf check. 2013-07-07 02:19:20 +00:00
stwo c8629fcad6 OpenBSD/m88k is now elf. Remove unneeded elf check. 2013-07-07 02:11:57 +00:00
Kevin B Kenny b52ba9ae90 Merge mark 2013-07-06 22:29:36 +00:00
Kevin B Kenny a6fe3119b2 http://www.iana.org/time-zones/repository/releases/tzdata2013d.tar.gz 2013-07-06 22:24:52 +00:00
Kevin B Kenny 28bc2e5adf http://www.iana.org/time-zones/repository/releases/tzdata2013d.tar.gz 2013-07-06 22:22:01 +00:00
dgp 191c6d2137 merge trunk 2013-07-05 19:56:12 +00:00
dgp 7eab500306 merge trunk 2013-07-05 19:54:56 +00:00
jan.nijtmans 421cc90918 Use X11/Xlib.h for checking where X11 can be found in stead of X11/XIntrinsic.h. Suggested by Pietro Cerutti.
(backported from tclconfig)
2013-07-05 14:56:24 +00:00
jan.nijtmans e26d6e29c1 Use X11/Xlib.h for checking where X11 can be found in stead of X11/XIntrinsic.h. Suggested by Pietro Cerutti.
(Backported from tclconfig)
2013-07-05 14:52:07 +00:00
jan.nijtmans 57f4decd9b CONST -> const in one place 2013-07-05 14:04:03 +00:00
jan.nijtmans e0373f12ec Allow successfull compilation, even if Tcl_GetErrorLine/Tcl_SetErrorLine are redefined as macros. 2013-07-05 14:02:59 +00:00
jan.nijtmans fa8b071f04 Bug [817249]: bring tclXtNotify.c up to date with Tcl_SetNotifier() change 2013-07-03 10:43:49 +00:00
jan.nijtmans 6f68b762d3 Bug [817249]: bring tclXtNotify.c up to date with Tcl_SetNotifier() change 2013-07-03 10:39:50 +00:00
jan.nijtmans ade4e6d9bb Fix compiler warning when compiling Itcl 4.0:
In file included from ./generic/itcl2TclOO.c:12:0:
/Tcl/include/tclInt.h:3012:8: warning: ‘struct addrinfo’ declared inside parameter list [enabled by default]
        const char **errorMsgPtr);
        ^
2013-07-03 08:59:09 +00:00
jan.nijtmans a6b67f2ef2 Fix compiler warning when compiling Cygwin port with -Wwrite-strings 2013-07-03 08:56:34 +00:00
dgp 88731d9d93 comment improvements 2013-07-02 10:36:32 +00:00
jan.nijtmans 73faa3bbb6 Bug [32afa6e256]: dirent64 check is incorrect in tcl.m4. Thanks to Brian Griffin. 2013-07-02 07:17:19 +00:00
jan.nijtmans 89b2fc0982 Don't forget ChangeLog for previous commit 2013-07-02 07:16:22 +00:00
jan.nijtmans 7d8dff7c72 Bug [32afa6e256]: dirent64 check is incorrect in tcl.m4. Thanks to Brian Griffin. 2013-07-02 07:14:59 +00:00
dgp aec5846c12 More Work In Progress. 2013-07-01 20:58:15 +00:00
dgp 05fb0c0810 More elimination of error message litter to fix [Bug 20a81392ec]. 2013-06-28 02:58:15 +00:00
dgp a47b03577b Stop the compileProc routines leaving behind error messages in interp.
(Nicer way to solve [Bug 20a81392ec].)  Make simplifications in 
TclCompileScript() make possible by the new structure.  Still a work
in progress.
2013-06-27 20:10:41 +00:00
dgp fda71d6d4c merge trunk 2013-06-27 13:12:09 +00:00
dgp 7070acfea1 plug memory leaks 2013-06-27 13:11:53 +00:00
jan.nijtmans eec0dcb530 Fix [34538ba43f] 2013-06-27 12:35:47 +00:00
jan.nijtmans c0f408b9cd Fix [34538ba43f] 2013-06-27 12:34:49 +00:00
dgp ddd130e532 merge trunk 2013-06-27 12:05:00 +00:00
jan.nijtmans e592a6c9d5 Bug [9b2e636361]: Tcl_CreateInterp() needs initialized encodings. 2013-06-27 08:51:40 +00:00
jan.nijtmans 5ea3e8b570 Bug [9b2e636361]: Tcl_CreateInterp() needs initialized encodings. 2013-06-27 08:28:42 +00:00
dgp 324ca57f3d merge trunk 2013-06-26 20:20:23 +00:00
dgp a9f49cd781 Stop buffer overrun into undefined values detected by valgrind. 2013-06-26 20:13:57 +00:00
dgp b3fea91162 Correct typo detected by valgrind. 2013-06-26 17:26:16 +00:00
dgp ae7b32a706 Fix bytecode ranges in the cmdMapPtr. still leaky. 2013-06-26 16:06:44 +00:00
jan.nijtmans eaf387ef13 typos.
On Cygwin, Tcl_SetPanicProc(NULL) should set back the panic proc to its default, which is not NULL.
2013-06-26 14:24:20 +00:00
jan.nijtmans 78b0a4a13c formatting, typo 2013-06-26 14:20:26 +00:00
jan.nijtmans f7fd65de47 Allocate encoding name, so caller of Tcl_RegisterConfig() doesn't need to keep it forever.
Fix some comments.
2013-06-26 08:10:36 +00:00
jan.nijtmans d751f58f9d Proposed solution for [9b2e636361] 2013-06-26 07:42:53 +00:00
dgp 5eecd400b7 A few bug fixes from failing tests; still leaky. 2013-06-26 03:46:54 +00:00
dgp 3f19b90244 merge trunk 2013-06-25 20:22:59 +00:00
dgp 11f1a88c12 Nearly functional now, but leaky and not yet as tidy as I'm hoping for. 2013-06-25 20:22:31 +00:00
dgp c012287fc8 Replace always true test with assertion. 2013-06-25 19:23:24 +00:00
dgp 9fd3e86565 merge trunk 2013-06-25 15:01:31 +00:00
dgp adb4b18477 Make more use of the CompileTokens() macro. 2013-06-25 15:01:03 +00:00
dgp dc4782f595 Branch for rewriting TclCompileScript() and related routines, with the
intent to generally simplify and make more readable, as well as find and
eliminate duplication with ensemble machinery and improve mergeability
to other branches.  Work in Progress.  Doesn't work at all right now.
2013-06-25 14:19:39 +00:00
jan.nijtmans 708da35f79 Don't use deprecated Tcl_DStringTrunc any more 2013-06-25 12:06:07 +00:00
jan.nijtmans 07bfe18a21 Don't use deprecated Tcl_DStringTrunc any more. 2013-06-25 12:02:56 +00:00
jan.nijtmans 9497794406 Remove TclInitStubTable() function (but keep it in the "initsubsystems" branch). 2013-06-25 10:02:14 +00:00
jan.nijtmans 8d8c38c7c7 Don't use TclpInetNtoa any more, use inet_ntoa in stead. Since IP6 support it's even not necessary any more (except for fake-rfc2553, but mutexes are used here already) , but it's in the internal stub table so we cannot remove it until 9.0 2013-06-21 11:57:59 +00:00
jan.nijtmans dcb4da22fa Modify internal TclStubInfoType type: use TclStubs * in stead of ClientData, so less type casts are needed in the code.
Disadvantage: somewhat more code duplication, but it makes the code much more understandable.
2013-06-21 11:53:11 +00:00
dgp 130c6dd203 TclCompileScript() should not overwrite envPtr->numSrcBytes.
The envPtr already has the right value stored in it.
2013-06-20 14:20:59 +00:00
dgp bbca4ec51b TclCompileScript() should not overwrite envPtr->numSrcBytes.
The envPtr already has the right value stored in it.
2013-06-20 14:17:05 +00:00
dkf 4a6f1d02be Fixed bug with optimizing with INST_START_CMD about. 2013-06-19 22:44:42 +00:00
dgp 202a7c4db1 More use of simplifying macros.
Replace dynamic allocation with automatic storage on the call stack.
2013-06-19 19:33:21 +00:00
jan.nijtmans 4d9fc81c0f Eliminate a lot of dead code (for Windows 95/98/ME only).
Eliminate all usage of TclWinSetInterfaces(), which does exactly the same as TclpSetInterfaces(), but keep exported symbol and stub entry.
2013-06-19 12:53:53 +00:00
jan.nijtmans cdd8467ca9 Fix [3611974]: InitSubsystems multiple thread issue 2013-06-18 10:36:06 +00:00
jan.nijtmans 099345d98c Fix [3611974]: InitSubsystems multiple thread issue 2013-06-18 10:33:33 +00:00
jan.nijtmans 76df95e6e4 Fix uniClass tool which was the real cause for [a876646efe], and add test-case for it. 2013-06-18 07:50:19 +00:00
jan.nijtmans 7243b34d80 Fix uniClass tool which was the real cause for [a876646efe], and add test-case for it. 2013-06-18 07:43:59 +00:00
jan.nijtmans 6a445a3fe6 Better place to put vsnprintf switch, so it is usable by all *.c files.
Fix comment on _ANSI_ARGS_ which is no longer true since 8.6.
2013-06-18 07:00:04 +00:00
dgp d6ca452640 Updates to redirect bug reports to the new tracker location. 2013-06-17 17:05:07 +00:00
jan.nijtmans 7b9871647a Fix [42b8083613] 2013-06-17 17:03:49 +00:00
dgp 5f13065a33 Updates to redirect bug reports to the new tracker location. 2013-06-17 17:03:18 +00:00
jan.nijtmans e80db5fa35 Use more portable TclIsSpaceProc() in stead of isspace(). 2013-06-17 13:29:39 +00:00
jan.nijtmans 3215339ef0 Use more portable TclIsSpaceProc() in stead of isspace().
Make sure that "string is space \u180e" continues to return 1 for whatever unicode version.
2013-06-17 13:23:29 +00:00
jan.nijtmans b7289f092d Fix [a876646efe]: re_expr character class [:cntrl:] should contain \u0000 - \u001f 2013-06-17 04:54:35 +00:00
jan.nijtmans ded13430f9 Fix [a876646efe]: re_expr character class [:cntrl:] should contain \u0000 - \u001f 2013-06-17 04:52:01 +00:00
jan.nijtmans 6eb0e8555d On 32-bit platforms, 12 characters for version is enough, on 64-bit platforms it will be aligned to 16 characters anyway. 2013-06-17 04:41:57 +00:00
jan.nijtmans c05b753e95 link tclsh with stub library, just like xttest and tcltest, in order to allow additional static stub-enabled libraries to be linked with it. 2013-06-16 20:48:57 +00:00
jan.nijtmans f332c17690 split off TclInitStubTable() as separate function - which does the actual stub table initialization - previously part of Tcl_InitStubs(). 2013-06-16 20:32:50 +00:00
jan.nijtmans df6a99b1f7 Don't use deprecated stricmp/strnicmp any more, but underscored variant for non-GNU compilers.
Some formatting - improved comments.
2013-06-14 10:15:50 +00:00
jan.nijtmans 07096327dc Don't use deprecated stricmp/strnicmp any more, but underscored variant for non-GNU compilers. 2013-06-14 10:11:08 +00:00
jan.nijtmans a831b299f7 Fix env.test when running mingw-w64 (AMD64 build) test-suite on wine64.
Fix some gcc warnings which become visible with -Wextra
2013-06-13 07:23:08 +00:00
jan.nijtmans b6b9185fa8 Fix some gcc warnings which become visible with -Wextra 2013-06-13 07:13:09 +00:00
jan.nijtmans bd6f6a89c6 Fix env.test when running mingw-w64 (AMD64 build) test-suite on wine64 2013-06-12 19:36:49 +00:00
jan.nijtmans 169288808b Workaround for mingw-w64 (AMD64-only) bug: It appears that zdll.lib (as produced by Microsoft tools) doesn't import the zlib symbols correctly, so use "libz.dll.a" produced with mingw-w64 tools in stead. 2013-06-12 12:24:23 +00:00
jan.nijtmans 615ab1a0d4 Silence various warnings when doing a 64-bit build with MSVC: Those warnings can only _really_ be fixed in "novem" (so, don't silence them there).
Use vsnprintf (more portable) in stead of _vsnprintf, except on MSVC
2013-06-12 10:29:01 +00:00
jan.nijtmans c961880a26 Silence various warnings when doing a 64-bit build with MSVC: Those warnings can only _really_ be fixed in "novem" (so, don't silence them there) 2013-06-12 10:24:52 +00:00
dgp f118d91a3d Revise INST_EXPAND_STKTOP so that it no longer makes use of its operand.
All the information required to do a proper expansion of the exec stack
to support expanded command invocation is already present.  The operand
doesn't provide any essential information.  By ignoring it, we eliminate
the risk that the compiler might fill in the operand with a bad stack depth
estimate value.  INST_EXPAND_STKTOP doesn't need an operand, but in order
to support loading of existing bytecodes we cannot change it now.  There's
also no need to change what the compiler tries to place in the operand,
though changing it to always be zeros would be acceptable now.
2013-06-11 22:47:22 +00:00
dgp 3c473ee0c4 Select improvements in stack depth estimates brought over from mig-review.
Mostly these are just simplifications, removing code that wasn't needed.
Some changes make the stack depth estimate more accurate instruction by
instruction.
2013-06-11 20:38:00 +00:00
dgp 67264f1e10 Repairs to compile/exec debugging output. 2013-06-11 19:41:55 +00:00
dgp 9cccd5fd91 Stack housekeeping repair for last checkin. 2013-06-11 17:58:49 +00:00
dgp 470fc04dd0 [33b7abb8a2] [7174354ecb] Rewrite TclCompileThrowCmd(). 2013-06-11 16:44:34 +00:00
jan.nijtmans 46db2c3edd Improve compatibility detection for <time.h> and <sys/stat.h>:
- Move <time.h> before other includes on Windows, so we are sure the time_t definition being checked doesn't come from <sys/types.h>. 
- Padding at the end of Tcl_StatBuf doesn't influcence binary compatibility, so relax panic check accordingly.
2013-06-11 08:12:09 +00:00
jan.nijtmans 52ce2fdeb0 Improve compatibility detection for <time.h> and <sys/stat.h>:
- Move <time.h> before other includes on Windows, so we are sure the time_t definition being checked doesn't come from <sys/types.h>. 
- Padding at the end of Tcl_StatBuf doesn't influcence binary compatibility, so relax panic check accordingly.
2013-06-11 07:58:01 +00:00
dkf d8bed612b0 [779d38b996]: Make the 'try' compiler handle -during right and compile some
more cases than it did before.
2013-06-09 17:34:10 +00:00
dkf 41da12e756 Fix the problems with code generation; behavior now appears correct. 2013-06-09 17:21:07 +00:00
dkf 18fcba4c82 Improving tests, fixed one case. 2013-06-09 08:15:43 +00:00
dkf 41462bf4fa Working on a better compiler for [try]; found some bugs in previous compilation
code which aren't resolved yet.
2013-06-08 23:43:29 +00:00
dkf 4e13219dfb More informative comment describing INST_SYNTAX. 2013-06-08 23:35:02 +00:00
dkf 854eec9e0f Factor out stereotypical ways of getting variable indices. 2013-06-08 13:17:26 +00:00
dkf 849acd6e96 Simplify stack depth management. 2013-06-07 12:48:58 +00:00
dkf b5c0305e8b More efficient instruction sequence for [dict for] with correct exception depth handling. 2013-06-06 21:01:04 +00:00
dgp a8ee0b7831 3614382 Fix stack management of compiled [dict for] by shifting limits
of the catch range.
2013-06-06 16:55:08 +00:00
dgp a989f1616a 3614360 Repair stack demands of optimized compiled [return LITERAL]. 2013-06-06 14:24:35 +00:00
dkf af76b69dcd Working on the optimizer. 2013-06-06 09:09:48 +00:00
dkf ab224ed8ee Minor grammar fix. 2013-06-06 06:56:20 +00:00
dkf 68dfdc609e Split the optimizer up. Remove the dreaded 'goto' from which doesn't need it. 2013-06-06 06:53:55 +00:00
dkf 10ccda4936 Added optimizing of jump-to-nop and jump-to-jump cases. Ta to AK for suggesting. 2013-06-05 23:05:58 +00:00
dkf c718bb66ac Working on the optimizer, and finding a few bugs in bytecode generation. 2013-06-05 21:42:29 +00:00
dkf 5dad1c5205 Added the optimizer... 2013-06-05 21:05:41 +00:00
dkf 270a615a09 Corrected wrong information about instruction width that was causing an optimizer crash. 2013-06-05 20:55:29 +00:00
dkf 4a21f51055 merge fixes 2013-06-05 20:23:41 +00:00
dgp 532b8988c1 [Bugs 2835313, 3614226, 3614342]: Complete the construction of break/continue
compilers that get the stack cleanup right, even when there's expansion going
on.
2013-06-05 15:22:53 +00:00
dgp b2423f72cf Repair TCL_COMPILE_DEBUG guards 2013-06-05 15:07:40 +00:00
dgp 3903b017ec Stack Depth fixups. 2013-06-05 14:50:39 +00:00
dkf 3c76eb88e8 More cleaning up; factor out optimizer to new file. Some weird problems still. 2013-06-05 12:34:21 +00:00
dkf 544626ba84 [Bugs 2835313, 3614226]: Complete the construction of break/continue compilers
that get the stack cleanup right, even when there's expansion going on.
2013-06-05 08:11:06 +00:00
dkf b5f51d5007 merge trunk 2013-06-05 07:57:06 +00:00
dkf a20873ddab Even better tests 2013-06-05 07:51:06 +00:00
dkf 68d7745b27 Stack cleanup works now even in the most evil expansion cases. 2013-06-05 07:19:02 +00:00
jan.nijtmans c8b0ad64d1 Eliminate NO_VIZ macro as current zlib uses HAVE_HIDDEN in stead.
One more last-moment fix for FreeBSD by Pietro Cerutti
2013-06-04 08:33:16 +00:00
dgp a097532afd merge 8.5 2013-06-03 20:31:58 +00:00
dgp 7b43d03c2b merge 8.4 2013-06-03 20:31:31 +00:00
mig fdf63d1e28 fix for perf bug detected by Kieran (https://groups.google.com/forum/?fromgroups#!topic/comp.lang.tcl/vfpI3bc-DkQ) 2013-06-03 16:52:48 +00:00
mig 17f4b04d10 fix for perf bug detected by Kieran (https://groups.google.com/forum/?fromgroups#!topic/comp.lang.tcl/vfpI3bc-DkQ) 2013-06-03 16:10:30 +00:00
dkf 2a3000c25e Next stage of fixing the break/continue generation. 2013-06-03 14:57:48 +00:00
dkf d2b951b436 merge back from trunk 2013-06-03 12:55:05 +00:00
dkf 79f58ebfb3 Merge back the improved [break] and [continue] compilation. 2013-06-03 09:46:10 +00:00
dkf 2797b611e3 Generate [continue] optimally in [for] next clauses. Add tests for Bug 3614226. 2013-06-03 09:37:14 +00:00
dkf 7da4d96216 Fix a stack depth calculation. 2013-06-02 21:32:16 +00:00
dkf 15425ace0b Remove useless macro, use existing macro where it makes sense. 2013-06-02 18:54:09 +00:00
dkf 7390940817 Many improvements to code generation of efficient break and continue. 2013-06-02 17:41:14 +00:00
dkf 7484715183 Getting better at doing more efficient break/continue instruction handling. 2013-06-01 21:05:55 +00:00
dkf bcc14fb740 derp 2013-05-30 10:57:13 +00:00
dkf 90dba8327c Working towards the next batch of optimizations. 2013-05-30 10:55:39 +00:00
dkf db5a66dd2c Corrected code generation when doing the second run with an 'infinite' loop. 2013-05-30 10:29:41 +00:00
dgp 82c027f092 Simplifications and tidying up of stack management issues. Work in progress. 2013-05-29 20:36:05 +00:00
dgp e7da373e0c 3614102 - Reset stack housekeeping when compileProc fails. 2013-05-29 17:20:29 +00:00
andreask 2a26edf602 Fix C99 comment-ism breaking the native AIX compiler. HPUX likely as well. 2013-05-29 16:24:34 +00:00
dgp c929650e2f Stop emitting the instructions INST_*_SCALAR_STK*. They are identical to
their INST_*_STK* counterparts.
Having done that, it is clear the "simpleVarName" return from TclPushVarName
provides nothing of use to any of its callers.  Eliminate that.  Also make
TPVN return void, instead of int.
Bring the TPVN header comments up to date; they were quite rotten.
2013-05-29 14:37:58 +00:00
dgp b1a3a83b3d Use the routines that provide "basic compile" instead of reinventing them. 2013-05-28 19:21:22 +00:00
dgp fb728f1f53 Plug the memory leak. Greater ambitions to improve this routine are proving
more difficult than expected.
2013-05-28 14:29:01 +00:00
dgp b3b9cb8d35 Missed bits of dup code elimination. 2013-05-28 14:04:02 +00:00
jan.nijtmans 251b09c99a Move changelog entry to correct date. 2013-05-28 07:24:08 +00:00
jan.nijtmans 43cea24ef3 3036566 - Get msgcat locale for Win Vista+ first from gui language registry key.
Bumped msgcat to version 1.5.2.
Minor manpage corrections.
2013-05-28 07:18:42 +00:00
oehhar 2debf51b24 3036566 - Get msgcat locale for Win Vista+ first from gui language registry key.
Bumped msgcat to version 1.5.2.
Minor manpage corrections.
2013-05-27 20:45:08 +00:00
dgp f677af67e2 Repair some stack depth housekeeping. 2013-05-25 03:26:21 +00:00
dgp 622cb44fa4 3613854 - Fixup stack maintenance /code generation for [array set x $oddList].
Postscript - I see that this commit created a memory leak.
Will commit a fix within a few days.
2013-05-24 18:37:19 +00:00
dgp 50c73b80d3 Spare developers the burden and error risk of counting bytes in string
literals, or having to type them twice.
2013-05-23 20:24:56 +00:00
dgp b24c54bed3 Eliminate code duplication. 2013-05-23 18:32:19 +00:00
jan.nijtmans c74bb69040 merge-mark 2013-05-23 11:40:40 +00:00
jan.nijtmans 4b5869de07 merge-mark 2013-05-23 11:39:08 +00:00
andreask 6c3b503dbd Removed const qualifier causing the HP native cc to error out (error 1675: Duplicate type qualifier "const"). 2013-05-22 16:39:01 +00:00
dgp 68afad0c67 silence compiler warning 2013-05-22 13:34:46 +00:00
dgp 7965559c05 silence compiler warning 2013-05-22 13:14:18 +00:00
dkf 18b0700dbe [3613609]: Replace strcasecmp() with UTF-8-aware version. 2013-05-22 13:07:33 +00:00
dkf 4ee4a959b9 [3613609]: Replace strcasecmp() with UTF-8-aware version. 2013-05-22 12:59:45 +00:00
dkf 0a18b6e286 Fixed the weird edge case. 2013-05-22 12:55:50 +00:00
dkf 5c0e6b295a Improved tests. 2013-05-22 12:32:28 +00:00
dkf 45e4dfd471 * doc/file.n: [Bug 3613671]: Added note to portability section on the
fact that [file owned] does not produce useful results on Windows.
2013-05-22 10:36:55 +00:00
jan.nijtmans 89acc1c033 Slight improvement: if cs = "\xC0\x80" and ct = "\x00", loop would continue after NUL-byte, this should not happen. 2013-05-21 09:38:05 +00:00
jan.nijtmans be69161b43 Proposed solution for 3613609: lsort -nocase does not sort non-ASCII correctly 2013-05-21 09:27:15 +00:00
dgp 025d1997eb 3613569 Handle case when TclpTempFileNameForLibrary returns NULL. 2013-05-20 15:10:18 +00:00
dkf 648841a413 [3613567]: Corrected sense of test on results of access() in temp file creation. 2013-05-20 14:17:06 +00:00
jan.nijtmans 276bcea418 Don't #define VOID on VxWorks, as it is already typdef'd to void. Eliminate possibly conflicting LOCAL/OFFSET 2013-05-19 20:37:08 +00:00
jan.nijtmans 1ac9419646 Don't #define VOID on VxWorks, as it is already typdef'd to void. Eliminate possibly conflicting LOCAL/OFFSET 2013-05-19 20:26:29 +00:00
jan.nijtmans c0b55c5efd Fix for FreeBSD, and remove support for older FreeBSD versions. Patch by Pietro Cerutti 2013-05-19 19:09:25 +00:00
jan.nijtmans 643a9ae4b0 Fix for FreeBSD, and remove support for older FreeBSD versions. Patch by Pietro Cerutti 2013-05-19 19:03:05 +00:00
dkf 72a0fab411 Split tclCompCmds.c into two roughly-equal-sized pieces. 2013-05-18 13:25:11 +00:00
dkf 06cfc15d05 Remove useless variables. 2013-05-17 11:02:40 +00:00
jan.nijtmans c52117cb0c Revert defining _HAVE_32BIT_TIME_T especially for mingw-4.0-rc1: Although it works, it has the side-effect that tcl8?.dll depends on msvcrt.dll symbols which are only available in later versions of msvcrt.dll. This is undesired, it really should be fixed in the mingw headers. 2013-05-17 07:24:31 +00:00
jan.nijtmans 143dd064c6 Revert defining _HAVE_32BIT_TIME_T especially for mingw-4.0-rc1: Although it works, it has the side-effect that tcl8?.dll depends on msvcrt.dll symbols which are only available in later versions of msvcrt.dll. This is undesired, it really should be fixed in the mingw headers. 2013-05-17 07:21:27 +00:00
andreask a425618034 Sigh. Fix version number of package "platform" in the Makefile.n files. Future: Write a small tcl script tool to extract the version information directly from the code. 2013-05-16 17:43:23 +00:00
andreask b5f1bdb187 Sigh. Fix version number of package "platform" in the Makefile.n files. Future: Write a small tcl script tool to extract the version information directly from the code. 2013-05-16 17:39:44 +00:00
dgp 007c00ed28 Confirmed that every caller of TclProcCompileProc() arranges for the
procPtr and nsPtr arguments: nsPtr == procPtr->cmdPtr->nsPtr.
This makes the test in TclCompileScript() useless. TCS() will always
compile in the current namespace of the interp.  Remove the code that
obfuscates that fact.
2013-05-16 13:24:28 +00:00
jan.nijtmans 13a2a82c81 Add support for the latest mingw-4.0-rc1. See: [http://sourceforge.net/p/mingw/mingw-org-wsl/ci/4.0-rc1/tree/NEWS] 2013-05-16 12:33:05 +00:00
jan.nijtmans b55a06a8a5 _USE_32BIT_TIME_T is already defined in tclWinPort.h 2013-05-16 12:28:33 +00:00
jan.nijtmans 87d602d36b Add support for the latest mingw-4.0-rc1. See: [http://sourceforge.net/p/mingw/mingw-org-wsl/ci/4.0-rc1/tree/NEWS] 2013-05-16 12:22:51 +00:00
andreask 06130c47bf Fix platform version mismatch between code and index. 2013-05-15 16:55:43 +00:00
andreask bf048c0574 Fix platform version mismatch between code and index. 2013-05-15 16:49:49 +00:00
dgp 11832ca791 Disabled some code in TclCompileScript(). Test suite results are unaffected.
Does this indicate a gap in the test suite, or is this code truly useless?
2013-05-15 15:18:00 +00:00
dkf e516af3ee3 Removing a few changes that were not actually needed, and correcting comments. 2013-05-15 10:56:41 +00:00
dkf 27e4c0fd0a merge-mark 2013-05-15 10:44:17 +00:00
dkf 5f10b318a9 A better technique for [list {*}blah]. Remove the INST_LIST_EXPANDED opcode (and the complex machinery associated with it) as as it is no longer needed. 2013-05-15 10:41:52 +00:00
jan.nijtmans 45f9ea1e07 merge-mark 2013-05-15 10:41:42 +00:00
dkf 37a7a15bca merge trunk 2013-05-15 10:41:03 +00:00
dkf b3ef3c7cfa A better technique for [list {*}blah]. Remove the INST_LIST_EXPANDED opcode (and the complex machinery associated with it) as as it is no longer needed. 2013-05-15 10:38:25 +00:00
jan.nijtmans 9cebbfe5c2 merge-mark 2013-05-15 10:37:06 +00:00
dgp 609b6c70bb make dist 2013-05-14 18:44:17 +00:00
andreask 761c9d604a Merged fix to bytecode engine problem. Details in merged revision. 2013-05-13 16:59:34 +00:00
andreask 9ba818c1f1 Fixed bug in parent revision [832a1994c7] unpredictably breaking the
execution of precompiled bytecode (i.e. tbcload'ed bytecode).

The semi-inversion of a guard condition dropped the part about
TCL_BYTECODE_PRECOMPILED of the original condition, allowing the core
to attempt to recompile code for which there are no script sources
(anymore), which then fails.
2013-05-13 16:51:23 +00:00
dgp 063786234c compiler warning 2013-05-13 14:23:45 +00:00
jan.nijtmans bbf3672694 Upgrade to zlib 1.2.8 2013-05-13 14:07:56 +00:00
dkf db5f6dd1cd Optimizations and general bytecode generation improvements. 2013-05-12 00:44:22 +00:00
dkf f0b3ddae4d Corrected the stack balancing in the special [list {*} ] compiler. 2013-05-12 00:42:53 +00:00
dkf 4c0c922a42 Fix implementation of INST_LIST_EXPANDED. 2013-05-12 00:04:27 +00:00
dkf ef11e6258e Partial fix: still ongoing 2013-05-11 20:02:43 +00:00
dkf aca7dea901 Optimizations and general bytecode generation improvements. 2013-05-10 12:57:38 +00:00
oehhar b12676f0d0 Corrected args -> arg arg ... in msgcat doc 2013-05-08 15:47:31 +00:00
oehhar cac74426e8 Document mcunknown format parameters 2013-05-08 14:52:51 +00:00
oehhar 41c4cbfb48 Add install references and changes entry 2013-05-08 08:40:22 +00:00
oehhar 64e39b2d5a Also get msgcat locale from Vista+ registry key "HCU/Control Panel/Desktop : PreferredUILanguages" to honor installed language packs. msgcat now 1.5.2 2013-05-08 08:24:54 +00:00
jan.nijtmans a15d02780a No longer link Cygwin executables with zlib1.dll, but with cygz.dll.
On Cygwin64 this doesn't work, and on Cygwin32 it was a bad idea anyway.
2013-05-07 11:38:35 +00:00
jan.nijtmans b1d48abeb3 Add support for Cygwin64, which has a 64-bit "long" type.
Binary compatibility with win64 requires that all stub entries use 32-bit long's, therefore the	need for various wrapper functions/macros. 
For Tcl 9 a better solution is needed, but that cannot be done without introducing binary incompatibility.
2013-05-06 07:33:02 +00:00
jan.nijtmans 8001283708 Add support for Cygwin64, which has a 64-bit "long" type.
Binary compatibility with win64 requires that all stub entries use 32-bit long's, therefore the	need for various wrapper functions/macros. 
For Tcl 9 a better solution is needed, but that cannot be done without introducing binary incompatibility.
2013-05-06 07:22:17 +00:00
jan.nijtmans 70044260ae merge-mark 2013-05-06 06:48:34 +00:00
ferrieux 1f2616960d Backport 8.6's fix [checkin 5af0d249de] to [Bug 2901998]: Inconsistent buffered I/O. Tcl's I/O now flushes buffered output before reading, discards buffered input before writing, etc. 2013-05-01 21:13:03 +00:00
andreask e6565ad233 (::platform::LibcVersion): Followup to the 2013-01-30 change. The RE
become too restrictive again. SuSe added a timestamp after the
version. Loosened up a bit. Bumped package to version 1.0.12.
2013-04-30 18:49:08 +00:00
andreask ddae63135f (::platform::LibcVersion): Followup to the 2013-01-30 change. The RE
become too restrictive again. SuSe added a timestamp after the
version. Loosened up a bit. Bumped package to version 1.0.12.
2013-04-30 18:46:44 +00:00
dkf 5420285485 Improve code generation for [array set] in a common case. 2013-04-29 09:31:53 +00:00
jan.nijtmans 13c0e41521 merge-mark 2013-04-25 07:40:04 +00:00
jan.nijtmans 2fb979594a merge-mark 2013-04-25 07:32:21 +00:00
jan.nijtmans 6a412a3168 Implement Tcl_NewBooleanObj, Tcl_DbNewBooleanObj and Tcl_SetBooleanObj as macros using Tcl_NewIntObj, Tcl_DbNewLongObj and Tcl_SetIntObj.
Starting with Tcl 8.5, this is exactly the same, it only eliminates code duplication. 
Eliminate use of NO_WIDE_TYPE everywhere: It's exactly the same as TCL_WIDE_INT_IS_LONG
2013-04-23 14:15:14 +00:00
jan.nijtmans 7554f7ffb1 Split ChangeLog in 3 parts, just as already done on trunk 2013-04-23 13:30:50 +00:00
jan.nijtmans 2c6aa5c960 Implement Tcl_NewBooleanObj, Tcl_DbNewBooleanObj and Tcl_SetBooleanObj as macros using Tcl_NewIntObj, Tcl_DbNewLongObj and Tcl_SetIntObj.
Starting with Tcl 8.5, this is exactly the same, it only eliminates code duplication.
2013-04-23 10:39:33 +00:00
jan.nijtmans 8474c20bc6 Implement many Tcl_*Var* functions and Tcl_GetIndexFromObj as (faster/stack-saving) macros around resp their Tcl_*Var*2 equivalent and Tcl_GetIndexFromObjStruct 2013-04-19 09:12:12 +00:00
jan.nijtmans 1197921203 Implement many Tcl_*Var* functions and Tcl_GetIndexFromObj as (faster/stack-saving) macros around resp their Tcl_*Var*2 equivalent and Tcl_GetIndexFromObjStruct 2013-04-19 08:41:15 +00:00
dgp 1de5433c5d merge-mark 2013-04-16 20:20:39 +00:00
dgp 5cbeb42aff 3610404 When we let go of commandPtr in TclEvalObjvInternal, NULL out the
variable so we don't mistakenly try to use the value later after we freed it.
2013-04-16 20:18:19 +00:00
dgp cc984c4e6e merge trunk 2013-04-16 17:34:32 +00:00
jan.nijtmans 6b60065860 Implement Tcl_Pkg* functions as macro's around Tcl_Pkg*Ex. This saves stack space, is (marginally) faster, while still being fully up/down compatible. It makes pkgb.so loadable in "novem" without the need to change the Tcl_PkgProvide() call to Tcl_PkgProvideEx(). 2013-04-12 11:27:37 +00:00
jan.nijtmans 9b0ea3ca88 Implement Tcl_Pkg* functions as macro's around Tcl_Pkg*Ex. This saves stack space, is (marginally) faster, while still being fully up/down compatible. It makes pkgb.so loadable in "novem" without the need to change the Tcl_PkgProvide() call to Tcl_PkgProvideEx(). 2013-04-12 11:22:43 +00:00
dgp 64bf3c8f4a More progress. NR-enable [interp] and [$slave], completely with
invokehidden subcommand.  Test suite passes with no errors.
2013-04-11 21:30:40 +00:00
dgp 064f7e5513 More revisions let multi-interp test case work, but at cost of panics
and segfaults.  Pushing the NRE-envelope.
2013-04-11 19:36:37 +00:00
dgp 6597872335 New internal routine TclNRInvoke() - NR-enabled path through the machinery
behind invokehidden commands.
2013-04-11 14:39:56 +00:00
dgp 5044035ec0 merge trunk 2013-04-11 13:35:41 +00:00
dgp 5c4737c8d8 merge mark 2013-04-11 12:26:45 +00:00
dkf b6b0d1b8dd added some test cases, based on bug report 2013-04-09 20:01:08 +00:00
dgp 1ddb66bfda Use the double-secret iPtr->lookupNsPtr field to get post-enter-trace
re-resolutions of commands done in the right context for oo forwards.
2013-04-09 19:04:04 +00:00
jan.nijtmans f2aea5424e merge-mark 2013-04-09 11:06:43 +00:00
jan.nijtmans 71d2777cfd fix http package installation 2013-04-08 20:29:44 +00:00
dgp 1ba9a90c6e 3610026 Stop crash when the number of "colors" in a regular expression
overflows a short int.  Thanks to Heikki Linnakangas for the report and
the patch.
2013-04-08 20:07:07 +00:00
dgp 55102c2b83 3610026 Stop crash when the number of "colors" in a regular expression
overflows a short int.  Thanks to Heikki Linnakangas for the report and
the patch.
2013-04-08 19:59:03 +00:00
dgp 6b17a1e25a Revise TclNREvalObjv so that pre-resolution of the Command by a caller
does not force suppression of exception handling.  Let those be separable
demands.  Aim is to bring TclObjInvoke*() into the fold.
2013-04-08 18:11:33 +00:00
dgp 93b8f2696a Documentation fix. 2013-04-08 15:58:47 +00:00
dgp e6f4d201ce merge-mark 2013-04-04 17:18:35 +00:00
max e0dbb5bd62 Allow URLs that don't have a path, but a query,
e.g. http://example.com?foo=bar and bump http to 2.7.12.
2013-04-04 17:08:43 +00:00
max 8b102ddebc Bump http to 2.8.7 in the other dozen places as well. 2013-04-04 15:00:49 +00:00
max ddfc3d80c5 Bump http to 2.8.7 2013-04-04 14:52:54 +00:00
max 2eed34dc23 Allow URLs that don't have a path, but a query query, e.g. http://example.com?foo=bar . 2013-04-04 14:42:19 +00:00
jan.nijtmans b065abd46c Make Tcl_EvalObj/Tcl_GlobalEvalObj a macro always, not only when using stubs. 2013-04-04 07:07:28 +00:00
jan.nijtmans b5b700cbbd Make Tcl_EvalObj/Tcl_GlobalEvalObj a macro always, not only when using stubs. 2013-04-04 07:03:05 +00:00
jan.nijtmans bce112e425 some more "ignore-glob" patterns 2013-04-03 20:50:43 +00:00
jan.nijtmans a5be6def4c some more "ignore-glob" patterns 2013-04-03 20:48:38 +00:00
jan.nijtmans 5d03958f22 merge-mark 2013-04-03 13:27:25 +00:00
jan.nijtmans a411cd47dc [Bug 3205320]: stack space detection defeated by inlining. Now fixed in the cross-compile case as well. 2013-04-03 13:26:16 +00:00
dgp 776001cd14 merge-mark 2013-04-03 13:15:47 +00:00
dgp f786fd625e merge release to 8.5 2013-04-03 13:12:47 +00:00
jan.nijtmans 6c3c75da93 Prevent inlining of StackGrowsDown(), in case of cross-compiling 2013-04-02 10:57:56 +00:00
dgp 10d04319d3 Redate. Retag RC1. 2013-03-29 15:08:29 +00:00
dgp be834cf113 Merge 8.5. Tag RC1. 2013-03-28 18:31:02 +00:00
jan.nijtmans a76ebfc825 merge-mark 2013-03-28 14:49:44 +00:00
jan.nijtmans 8f82227afd Undo [6a9ee3273c]. Last commit in Tk's core-8-5-branch makes this change no longer necessary. 2013-03-28 14:48:08 +00:00
dgp 3105dcac7e Tolerate NULL interps 2013-03-27 18:48:07 +00:00
jan.nijtmans 79ad7f2edc merge-mark 2013-03-27 14:13:04 +00:00
jan.nijtmans 6da116b888 Add dummy (undocumented) TclCanceled function in stub table (not exported as symbol or macro), which always returns TCL_OK. Needed for Tk 8.5.14 when running in Tcl 8.6 for properly clean-up when a (Tcl 8.6) thread is canceled. 2013-03-27 14:06:03 +00:00
jan.nijtmans de97184949 merge-mark 2013-03-27 10:49:47 +00:00
jan.nijtmans 0c849580cb remove unneccessary duplication 2013-03-27 10:48:00 +00:00
dgp 0c75115ede Update tzdata and release tags 2013-03-23 20:25:04 +00:00
venkat 4c095a869b Update to tzdata2013b 2013-03-22 23:08:53 +00:00
venkat 1a456da516 Update to tzdata2013b 2013-03-22 23:05:52 +00:00
dgp bbe81d1e5e Tag for release 2013-03-22 16:11:02 +00:00
jan.nijtmans 52cbdda306 If TCL_NO_DEPRECATED is defined, don't depend on Tcl_CreateMathFunc()/Tcl_SaveResult() in testcases any more.
Prevent endless loop in Tcl_AddObjErrorInfo, when TCL_NO_DEPRECATED is defined.
2013-03-22 13:22:40 +00:00
dgp eea431a4b8 Completed changes. 2013-03-22 12:47:36 +00:00
dkf 817b517764 Minor: version number correction. 2013-03-22 09:30:41 +00:00
dgp 0a4e67a3e5 changes WIP 2013-03-22 04:18:04 +00:00
dgp 423209e9fe Release branch for Tcl 8.5.14. 2013-03-21 19:09:25 +00:00
jan.nijtmans 88a893a388 merge-mark 2013-03-21 14:56:44 +00:00
jan.nijtmans 12d983adae Tcl 8.5 doesn't have [try] 2013-03-21 14:56:00 +00:00
jan.nijtmans 453c878fa9 Remove duplicated tests. The enhancements to fCmd-30.[12] and the new test case fCmd-30.3 were backported from Tcl8.6, but the original tests were not removed. 2013-03-21 14:45:09 +00:00
dgp d9db7b2587 test suite hygiene 2013-03-21 14:42:07 +00:00
dgp 29a0269cc5 test suite hygiene 2013-03-21 14:39:17 +00:00
dgp 4c35f9a03a 2102614 Add ensemble indexing support to [auto_mkindex]. Thanks Brian Griffin. 2013-03-21 14:35:34 +00:00
jan.nijtmans f13a861181 Remove duplicated tests. The enhancements to fCmd-30.[12] and the new test case fCmd-30.3 were backported from Tcl8.6, but the original tests were not removed. 2013-03-21 14:32:32 +00:00
jan.nijtmans 4102bfec1a Remove duplicated tests. The enhancements to fCmd-30.[12] and the new test case fCmd-30.3 were backported from Tcl8.6, but the original tests were not removed. 2013-03-21 14:30:27 +00:00
dgp fff161d582 2102614 Add ensemble indexing support to [auto_mkindex]. Thanks Brian Griffin. 2013-03-21 14:28:59 +00:00
dgp fc2ae2acaf Bring forward tests to trunk 2013-03-20 15:39:48 +00:00
dgp f47c327136 dup test names 2013-03-20 15:26:57 +00:00
jan.nijtmans 09d7c9d217 Slightly more correct: If FindFirstFile() fails, the error should be "no such file or directory" (ENOENT) not "permission denied" (EACCES). 2013-03-20 13:41:50 +00:00
jan.nijtmans 4146517b3b Slightly more correct: If FindFirstFile() fails, the error should be "no such file or directory" (ENOENT) not "permission denied" (EACCES). 2013-03-20 13:39:50 +00:00
jan.nijtmans c988bb3c5d Handle the (unlikely) case that the file is deleted in between. Suggested by Harald Oehlmann (Thanks!) 2013-03-19 14:59:26 +00:00
jan.nijtmans 2c75cac14e Handle the (unlikely) case that the file is deleted in between. Suggested by Harald Oehlmann (Thanks!) 2013-03-19 14:57:45 +00:00
dgp 06a824d706 3597000 Consistent [file copy] result. 2013-03-19 14:39:09 +00:00
dgp a0b87265ce 3597000 Consistent [file copy] result. 2013-03-19 14:31:56 +00:00
jan.nijtmans 39e89c1b69 [Bug 3608360]: Incompatible behaviour of "file exists". 2013-03-19 13:57:30 +00:00
jan.nijtmans ddc36ee473 [Bug 2893771]: file stat fails on locked files on win32. 2013-03-19 13:48:37 +00:00
dgp dbafb5fcfc Test independence in fCmd.test 2013-03-19 13:13:37 +00:00
dgp 6f7bddf8cd Test independence in fCmd.test. 2013-03-19 13:11:44 +00:00
jan.nijtmans 2d0dd29466 Back out bug fix for [Bug 2893771], because it was the cause of the regression. 2013-03-19 11:55:47 +00:00
dkf 28d2c1e4cf [Bug 3606390]: Fix isolation of test string-6.37. 2013-03-19 10:18:18 +00:00
dkf db361019ca [Bug 3606390]: Fix isolation of test string-6.37. 2013-03-19 10:16:12 +00:00
dkf a01b89976f [Bug 3606387]: Fix isolation of test scan-7.4. 2013-03-19 10:06:01 +00:00
dkf b2c63a9461 [Bug 3606387]: Fix isolation of test scan-7.4.
Also updated scan.test to use tcltest 2 properly.
2013-03-19 10:01:26 +00:00
dgp aad97a767b Test independence in fileSystem.test 2013-03-18 18:37:39 +00:00
dgp 8a98d2846f Test independence in fileSystem.test 2013-03-18 18:35:09 +00:00
dgp 3d4bb88f48 Test independence in unixFCmd.test 2013-03-18 18:00:12 +00:00
dgp 520932e706 Test independence in unixFCmd.test. 2013-03-18 17:59:25 +00:00
dkf f8b482aafe [Bug 3608360]: Test to make sure we never let [file exists] do globbing. 2013-03-18 14:30:32 +00:00
dkf 04b2d343ff [Bug 3608360]: Test to make sure we never let [file exists] do globbing. 2013-03-18 14:25:54 +00:00
jan.nijtmans 84d3dc55fc Patch by Andrew Shadura, providing better support for three architectures they have in Debian. 2013-03-12 08:47:52 +00:00
jan.nijtmans 57769fb109 Patch by Andrew Shadura, providing better support for three architectures they have in Debian. 2013-03-12 08:45:04 +00:00
dgp a3d5ba530a 3606391 trace.test test independence. 2013-03-11 19:06:23 +00:00
dgp 1ef6ae9359 3606391 trace.test test independence 2013-03-11 19:05:11 +00:00
dgp 852b1c4ad2 Greater protection against double TclFreeObj() calls in TCL_MEM_DEBUG mode. 2013-03-11 17:40:14 +00:00
dgp 4830e0f883 Greater protection against double TclFreeObj() calls in TCL_MEM_DEBUG mode. 2013-03-11 17:37:15 +00:00
dgp b2f133f23c 3607246,3607372 Unbalanced refcounts of literals in the global literal table. 2013-03-11 12:55:29 +00:00
dgp 21601a3a4a 3607372 Correct literal refcounting. 2013-03-08 21:14:07 +00:00
jan.nijtmans 57fa6f9669 msvc compiler warning: signed-unsigned mismatch. 2013-03-08 20:57:11 +00:00
dgp 1355f9df46 Correct unbalanced effect of TclInvalidateCmdLiteral() on the refcounts
of literals in the global table.
2013-03-07 21:16:29 +00:00
dgp 31f7c64e7d Cleaner error handling in fixempties(). 2013-03-06 21:55:29 +00:00
dgp 1bee0d67c6 Cleaner error handling in fixempties(). 2013-03-06 21:54:37 +00:00
dgp 1d6248a516 3604074,3606683 Rewrite of the fixempties() routine (and supporting routines)
to completely eliminate the infinite loop hazard.  Thanks to Tom Lane for the
much improved solution.
2013-03-06 20:50:53 +00:00
dgp 7cd2194d47 3604074,3606683 Rewrite of the fixempties() routine (and supporting routines)
to completely eliminate the infinite loop hazard.  Thanks to Tom Lane for the
much improved solution.
2013-03-06 20:28:10 +00:00
dgp b9e95ae529 merge trunk 2013-03-06 20:25:37 +00:00
dgp f233a71161 Rework into Tcl 8.5+ coding style. 2013-03-06 20:19:34 +00:00
dgp 1446f739b6 merge 8.5 2013-03-06 19:56:31 +00:00
dgp 69524610e8 Rework into Tcl 8.5+ coding style. 2013-03-06 19:53:42 +00:00
dgp 41cb679571 Indent reduction in fixempties() 2013-03-06 18:10:30 +00:00
dgp c16dc009d7 Indent reduction in fixempties() 2013-03-06 18:01:24 +00:00
dgp 7b9e7f283b Use flag argument to combine copy(nonempty)* routines into copy* routines. 2013-03-06 17:33:39 +00:00
dgp 2fbb537054 Use flag argument to combine copy(nonempty)* routines into copy* routines. 2013-03-06 17:30:14 +00:00
dgp 1a11145339 New routine hasnonemptyout() for minor improvement to new fixempties(). 2013-03-06 16:27:38 +00:00
dgp 55174c7e8a New routine hasnonemptyout() for minor improvement to new fixempties(). 2013-03-06 16:26:18 +00:00
jan.nijtmans eb2860258b Tell fossil and Eclipse that the default eol-convention is LF.
Tell fossil which files are binary and which files should never be committed. 
Tell Eclipse that the default encoding is UTF-8
2013-03-06 12:26:23 +00:00
jan.nijtmans 0af55d7cf3 Add Eclipse .project too 2013-03-06 12:22:55 +00:00
jan.nijtmans 79e3f7f55b Tell fossil and Eclipse that the default eol-convention is LF.
Tell fossil which files are binary and which files should never be committed. 
Tell Eclipse that the default encoding is UTF-8
2013-03-06 12:19:02 +00:00
dgp 86eba6192a New internal routine TclFetchLiteral() for better CompileEnv encapsulation. 2013-03-05 22:13:30 +00:00
dgp b96c6536cb Remove from tclCompile.h declarations used in only one source file. 2013-03-05 20:19:14 +00:00
dgp ec4c4a2957 Remove from tclCompile.h declarations used in only one source file. 2013-03-05 20:16:41 +00:00
dgp 48a03a59dc Remove TclInitCompilation() declaration with no definition. 2013-03-05 19:48:42 +00:00
dgp af80656fbe Remove TclInitCompilation() declaration with no definition. 2013-03-05 19:44:57 +00:00
dgp 5281598746 Contributed regexp engine patch from Tom Lane. Backports clean from trunk. 2013-03-05 14:04:17 +00:00
dgp 78af51451a Contributed patch from Tom Lane <tgl@users.sf.net>.
Rewrites parts of the regexp engine to avoid infinite loops.
2013-03-05 14:01:48 +00:00
dgp 64e9416261 merge mark 2013-03-04 15:41:59 +00:00
dgp 8141863583 merge mark 2013-03-04 15:40:57 +00:00
jenglish 3562bfb14b unix/configure: regenerated. 2013-03-03 17:58:34 +00:00
joe 80b3ef95a8 Unix terminal and serial port I/O: retire obsolete termio and sgtty code,
general cleanup.  See SF [Bug 3606258] for details.
2013-03-03 17:57:45 +00:00
joe d98d74151e ... which means struct TtyState can be replaced with struct FileState. 2013-03-02 20:32:43 +00:00
joe bf38d5992f Member TtyState.savedState set in TtyInit() but never subsequently used.
This can go away...
2013-03-02 20:06:09 +00:00
jenglish cd57fb7f7d TtyParseMode signature simplification: take single pointer to struct TtyAttrs
instead of separate pointers to each member.
2013-03-02 07:52:05 +00:00
jenglish 87cfb6b250 More ifdef shuffling: GETREADQUEUE and GETWRITEQEUE always defined,
dummy implementations return 0 if the requisite ioctls are not present.
2013-03-02 07:30:15 +00:00
jenglish 22e4896294 Do not use strncasecmp(). It is nonstandard and not portable.
Use Tcl_UtfNcasecmp() instead.
2013-03-02 07:22:21 +00:00
jenglish 05d33e0fe7 unix/configure: regenerated. 2013-03-01 23:57:13 +00:00
jenglish 82b98d6ede Replace broken SC_SERIAL_PORT macro with plain AC_CHECK_HEADERS tests. 2013-03-01 23:53:49 +00:00
jenglish 38d26a919e ifdef shuffling: TIOCMC[GS]ET ioctls are not specified by POSIX,
so we can't assume they are present just because we HAVE_TERMIOS_H.
Conversely, if they are present then the subsidiary flags
TIOCM_{DTR|RTS} are almost certainly there as well, so that
ifdeffery can be removed.

And lastly, ifdefs for TIOCSBRK/TIOCCBRK are still needed.
(Those are logically separate functions even though TIP#35
lumped them together with DTR and RTS in -ttycontrol.
POSIX provides tcsendbreak() for this purpose, but that
interface doesn't fit with the TIP#35 API.)

KNOWN DEFECT: if a hypothetical Unix system is missing TIOCMCGET
but has TIOCSBRK/TIOCCBRK, the latter function will nevertheless
be unavailable.  Accounting for this possibility does not strike
me as being worth the ifdefs.
2013-03-01 21:13:45 +00:00
dkf ab629d99ba [Bug 3606397]: Make test work in isolation, and corrected what was being tested. 2013-03-01 18:47:20 +00:00
dkf 4b31536c4a [Bug 3606542]: Add missing constraint to test. 2013-03-01 18:33:36 +00:00
dkf 4ec51224f4 [Bug 3606542]: Add missing constraint to test. 2013-03-01 18:30:40 +00:00
jenglish a30cdc4ccf TtyGetOptionProc: remove inoperative comment "The string returned by
this function is in static storage [...]"; this is not the case
(and apparently never has been)
2013-02-28 21:52:02 +00:00
dgp 09ea3ba2ca Revise TclReleaseLiteral() to tolerate a NULL interp argument.
Update callers and revise mistaken comments.
2013-02-28 17:08:43 +00:00
mig 0fa1988fb0 fix coroutine-4.6 so that it runs in isolation, [Bug 3606395] 2013-02-28 14:19:04 +00:00
jan.nijtmans d3a0c83f09 Allow Tcl to be compiled even if Tcl_Eval, Tcl_GetVar, ... are macros. 2013-02-28 08:29:35 +00:00
jenglish 5436b7c33b TtyGetBaud(), TtyGetSpeed(): use POSIX speed_t typedef
instead of 'unsigned long'.
2013-02-27 23:48:00 +00:00
jenglish 5efbf356ec Remove IOSTATE facade: it's always a struct termios. 2013-02-27 22:30:47 +00:00
jenglish 172de00de5 ifdef reduction - missed a couple spots (#if ... defined(USE_TERMIO)) 2013-02-27 22:12:43 +00:00
jenglish 4a2ab86325 ifdef reduction: SUPPORTS_TTY defined if and only if USE_TERMIOS defined. 2013-02-27 21:09:24 +00:00
jenglish 6765f7766a For termios, we never want DIRECT_BAUD; always use the symbolic constants
as prescribed by POSIX.
2013-02-27 20:33:33 +00:00
jenglish d19847932e termios cleanup step 1: remove USE_TERMIO and USE_SGTTY conditional sections
(mechanical change, done with `unifdef`).
2013-02-27 19:53:04 +00:00
dkf 627504c503 minor: formatting tweaks in the change log 2013-02-27 17:48:10 +00:00
dgp 19a639608f Somewhat tidier, less daunting test. 2013-02-27 15:33:06 +00:00
dgp 900bc4a968 Somewhat tidier, less daunting test. 2013-02-27 15:18:37 +00:00
jan.nijtmans c04398e133 Wrap test-case over multiple lines 2013-02-27 13:26:26 +00:00
jan.nijtmans 04cf158092 Wrap test-case over multiple lines 2013-02-27 13:23:48 +00:00
jan.nijtmans 268394dbb5 Some VOID -> void, Tcl_TraceVar -> Tcl_TraceVar2 and Tcl_VarTraceInfo -> Tcl_VarTraceInfo2 conversions. 2013-02-27 11:42:39 +00:00
jan.nijtmans 5789086c24 [Bug 3606139]: missing error check allows regexp to crash Tcl. Thanks to Tom Lane for providing the test-case and the patch. 2013-02-27 08:19:27 +00:00
jan.nijtmans 40259312fe [Bug 3606139]: missing error check allows regexp to crash Tcl. Thanks to Tom Lane for providing the test-case and the patch. 2013-02-27 08:12:33 +00:00
dgp db61e9a4be Remove from tclIO.h structs used only in tclIO.c. 2013-02-26 17:48:09 +00:00
dgp da40794df6 structs *ChannelHandler* GetsState CopyState used only locally.
Remove from tclIO.h.
2013-02-26 17:37:40 +00:00
dkf ba5b356435 [Bug 3605120]: Stop test chan-io-28.7 from hanging when run standalone. 2013-02-26 13:37:42 +00:00
jan.nijtmans 71c78f086f Don't panic if Tcl_ConvertToType is called for a type that doesn't have a setFromAnyProc, create a proper error message. 2013-02-26 10:17:39 +00:00
jan.nijtmans 93c840992c Don't panic if Tcl_ConvertToType is called for a type that doesn't have a setFromAnyProc, create a proper error message. 2013-02-26 10:15:44 +00:00
dkf 482a2c710e [Bug 3605721]: Test independence fixes for binary-41.* 2013-02-25 18:31:45 +00:00
dgp 39e3f11942 Repair linked list management in Tcl_DeleteCloseHandler().
CloseCallback struct used only locally.  Remove from tclIO.h.
2013-02-25 18:17:26 +00:00
dgp e794120698 Repair linked list management in Tcl_DeleteCloseHandler().
CloseCallback struct used only locally.  Remove from tclIO.h.
2013-02-25 18:15:36 +00:00
dgp 96417ebbb8 LimitHandler struct used only locally. Remove from tclInt.h 2013-02-25 16:41:46 +00:00
dgp f974fd8969 LimitHandler struct used only locally. Remove from tclInt.h. 2013-02-25 16:35:07 +00:00
dgp fc262ab6bb Remove unused struct InterpList. 2013-02-25 16:00:48 +00:00
dgp ca06debb81 Remove unused struct InterpList. 2013-02-25 15:57:07 +00:00
dgp 712b68cc80 Array Search struct used only locally. Remove from tclInt.h. 2013-02-25 15:45:13 +00:00
dgp 1136551973 ArraySearch struct used only locally. Remove from tclInt.h. 2013-02-25 15:37:41 +00:00
dgp b436f14398 3605719,3605720 Test independence. Thanks Rolf Ade for patches. 2013-02-25 14:55:17 +00:00
dgp cf7969886b 3605719,3605720 Test independence. Thanks Rolf Ade for patches. 2013-02-25 14:54:14 +00:00
jan.nijtmans e594dd2267 For Unicode 6.3, mongolian vowel separator (U+180e) is nominated to change character class from Space to Control character.
Make sure that "string is space" will continue to return 1 for this character. See TIP #413.
2013-02-25 13:16:21 +00:00
jan.nijtmans ef6c187c6e Bug [3599194]: compat/fake-rfc2553.c is broken 2013-02-23 20:00:49 +00:00
dgp 1a5673d6d1 unused variables 2013-02-22 19:10:32 +00:00
dgp 4cc2a56649 Shift more burden of smart cleanup onto the TclFreeCompileEnv() routine.
Stop crashes when the hookProc raises an error.
2013-02-22 19:05:56 +00:00
dgp 65c016d4a0 Restore the ReleaseCmdWordData cleanup routine from 8.4, to plug very
rare memory leak.
2013-02-22 18:54:56 +00:00
dgp 290b2159a2 Shift more burden of smart cleanup onto the TclFreeCompileEnv() routine.
Stop crashes when the hookProc raises an error.
2013-02-22 18:26:10 +00:00
dgp cf93250674 3605447 Make sure the -clear option to [namespace export] always clears,
whether or not new export patterns are specified.
2013-02-21 03:24:19 +00:00
dgp 3e947f695b 3605447 Make sure the -clear option to [namespace export] always clears,
whether or not new export patterns are specified.
2013-02-21 03:16:21 +00:00
jan.nijtmans e878a050b2 [Bug 3605401]: Compiler error with latest mingw-w64 headers. 2013-02-20 11:43:28 +00:00
jan.nijtmans 4144a690cb [Bug 3605401]: Compiler error with latest mingw-w64 headers. 2013-02-20 11:40:10 +00:00
jan.nijtmans 8c18c33bb8 Bug 3605401: Compiler error with latest mingw-w64 headers 2013-02-20 10:25:59 +00:00
jan.nijtmans 1973e8e40f Fix bug #2438181: Incorrect error reporting in traces.
Test-case and fix provided by Poor Yorick.
2013-02-19 11:36:12 +00:00
jan.nijtmans a01b1afbdd revert mangling with "code" variable. This caused unrelated var.test failures. 2013-02-19 10:53:29 +00:00
jan.nijtmans a2fa2a169f Fix bug #2438181: Incorrect error reporting in traces.
Test-case and fix provided by Poor Yorick.
2013-02-19 10:34:31 +00:00
jan.nijtmans 08bc505b41 Use (preferred) Tcl_ObjSetVar2 in stead of Tcl_SetVar in tclAppInit.c, both UNIX and Win. 2013-02-17 21:03:56 +00:00
dgp 76602aa738 3604074 Fix regexp optimization to stop hanging on the expression
((((((((a)*)*)*)*)*)*)*)* .  Thanks to Bjørn Grathwohl for discovery.
2013-02-15 15:32:30 +00:00
dgp 24e58b6dcd 3604074 Fix regexp optimization to stop hanging on the expression
((((((((a)*)*)*)*)*)*)*)* .  Thanks to Bjørn Grathwohl for discovery.
2013-02-15 15:27:07 +00:00
jan.nijtmans 339bf30461 Eliminate last use of Tcl_SetResult (except the use in the Test suite)
Fix depreciation message in tcl.h
2013-02-15 13:01:43 +00:00
jan.nijtmans c5687412d6 merge-mark 2013-02-14 13:49:11 +00:00
oehhar 4396044600 ChangeLog corrected: msgcat issue must not be XP specific 2013-02-14 13:24:40 +00:00
oehhar f2d8afbb5b ChangeLog corrected: msgcat issue must not be XP specific 2013-02-14 13:23:54 +00:00
jan.nijtmans 882dc5449d [Bug 3604576]: msgcat-1.5.0.tm error on windows XP 2013-02-14 12:11:55 +00:00
jan.nijtmans e03c7973a6 [Bug 3604576]: msgcat-1.5.0.tm error on windows XP 2013-02-14 12:09:19 +00:00
oehhar 930ffee5b9 Finer granulated catch 2013-02-14 11:09:31 +00:00
jan.nijtmans 04d8202a78 Suggested fix for bug 3604576: msgcat -1.5.0.tm error on windows XP, inclusive bump to version 1.5.1.
Changelog entry still missing.
2013-02-14 09:38:11 +00:00
jan.nijtmans 54cce1ee0e Improve some comments and quoting, no change in functionality.
Only check for refCount == 0x61616161 for TCL_MEM_DEBUG build.
2013-02-14 09:01:37 +00:00
jan.nijtmans 5070f0a86a Improve some comments and quoting, no change in functionality 2013-02-14 08:26:30 +00:00
jan.nijtmans cb19aec8e5 merge-mark 2013-02-12 23:21:56 +00:00
dkf 3b9c3fb04e Fix [Bug 3603553]. 2013-02-11 08:57:53 +00:00
dkf 200b0db200 Correction to comment in re key buffer size. 2013-02-11 08:54:09 +00:00
dkf deb93dc75c [Bug 3603553]: Ensure that data gets written to the underlying stream by
compressing transforms when the amount of data to be written is one
buffer's-worth; problem was particularly likely to occur when compressing
large quantities of not-very-compressible data.

Many thanks to Piera Poggio (vampiera) for reporting.
2013-02-11 08:11:28 +00:00
jan.nijtmans a5a7ae5f47 Unbreak msvc builds, by depending on tclPort.h for inclusion of <sys/stat.h> 2013-02-10 13:26:33 +00:00
jan.nijtmans 41ac300db8 Unbreak msvc builds, by depending on tclPort.h for inclusion of <sys/stat.h>. 2013-02-10 13:12:20 +00:00
dkf 9a43dd0c3b [Bug 3603695]: Change the way that the [oo::object] 'varname' method is
implemented so that there are no longer problems with interactions due to the
resolver. Thanks to Taylor Venable <tcvena@gmail.com> for identifying the
problem.
2013-02-09 12:30:32 +00:00
dkf 9ec95d17f8 Apply a fix for the bug. Passes the test suite now. 2013-02-09 12:25:36 +00:00
dkf 995e26088f characterize bug 2013-02-08 14:07:10 +00:00
dkf 2015734692 [3603804]: Improve example to actually be capable of throwing the trapped errors 2013-02-08 09:23:56 +00:00
dkf 9f0660744c [3603557]: Increase the maximum depth of recursion used when duplicating an
automaton in response to encountering a "wild" RE that hit the previous limit.
Allow the limit (DUPTRAVERSE_MAX_DEPTH) to be set by defining its value in the
Makefile. Problem reported by Jonathan Mills.
2013-02-08 01:44:17 +00:00
jan.nijtmans 52c2de3cb8 Tcl_InvalidateStringRep -> TclInvalidateStringRep 2013-02-07 13:55:38 +00:00
jan.nijtmans ae8888b894 Tcl_InvalidateStringRep -> TclInvalidateStringRep 2013-02-07 13:53:08 +00:00
dgp aee7d6fea4 [Bug 3603434] Make sure TclpObjNormalizePath() properly declares "a:/" to
be normalized, even when no "A:" drive is present on the system.
2013-02-05 16:56:01 +00:00
dgp 765de9e2ef [Bug 3603434] Make sure TclpObjNormalizePath() properly declares "a:/" to
be normalized, even when no "A:" drive is present on the system.
2013-02-05 16:55:32 +00:00
dkf 1226e764ba [3433012]: Added dummy version of TclpLoadMemory to use in the event that a
platform thinks it can load from memory but cannot actually do so due to it
being disabled at configuration time.
2013-02-05 09:21:13 +00:00
dkf 7da7ccee61 [Bug 3433012]: Added dummy version of TclpLoadMemory to use in the event that a
platform thinks it can load from memory but cannot actually do so due to it
being disabled at configuration time.
2013-02-05 09:17:44 +00:00
dgp bfab34ad8b Merge in fix for 3602706 2013-02-04 20:48:50 +00:00
dgp a65850c981 Fix for Bug 3602706. 2013-02-04 18:51:00 +00:00
dgp 2a2af35014 Cherrypick again. Add test. 2013-02-04 18:38:41 +00:00
dgp ccbed687ed Cherrypick the refcount fixes and comments from mig-review.
I also find the revised "createPart2" values in *Lookup* calls appealing,
but I'm too fearful of breaking things without understanding the implications.
This approach just focuses on fixing the things I broke, without trying
to "fix" things long "broken" in multiple years of releases.
2013-02-04 17:13:49 +00:00
dkf 57a9d5c7a9 [3603163]: Stop crash in weird case where [eval] is used to make [array set]
get confused about whether there is a local variable table or not. Thanks to
Poor Yorick for identifying a reproducible crashing case.
2013-02-04 14:40:40 +00:00
dkf e24489dcce [3603163]: Prevent odd crashes in 'eval {array set ...}' 2013-02-04 14:30:05 +00:00
jan.nijtmans 9e6725acf0 Eliminate all Tcl_ConvertToType calls and all direct calls to typePtr->setFromAnyProc (except the call from inside the Tcl_ConvertToType function) from the Tcl core. 2013-02-04 10:51:00 +00:00
jan.nijtmans 9088907888 More symmetric Tcl_(Incr|Decr)RefCount call, preventing bugs like #3601260 and #3602706 2013-02-03 11:34:01 +00:00
jan.nijtmans 7ee439ce0f re-apply [8aca9a8e96], while backporting [d91c86d0da] from trunk.
This fixes bugs #3601260 and #3602706
2013-02-03 11:31:47 +00:00
dkf 877a5f8149 merge trunk 2013-02-01 15:32:19 +00:00
jan.nijtmans 618bdeb4c0 cherry-pick [0f098031c3] 2013-01-31 15:04:52 +00:00
dgp 81d4ce37d0 Branch for fixing 3602706 2013-01-31 14:57:55 +00:00
stwo 271de3bc89 Bug [3598282]: Stop using installData.tcl to install the timezone files. 2013-01-31 13:52:15 +00:00
stwo 8f72fe1eb9 Bug [3598282]: Stop using installData.tcl to install the timezone files. 2013-01-31 13:50:38 +00:00
jan.nijtmans 9a5465ed60 merge-mark 2013-01-31 10:32:43 +00:00
jan.nijtmans 16869d9a05 merge core-8-5-branch 2013-01-31 10:31:55 +00:00
jan.nijtmans cc94362836 Fix bug #3601260 and #3602706 by reverting [8aca9a8e96]. This gives time to investigate the issue without too many people being hindered by that. 2013-01-31 09:49:50 +00:00
jan.nijtmans abc1ba4c1c Use twoPtrValue.ptr1 in stead of otherValuePtr everywhere. This is exactly the same field, but it allows twoPtrValue.ptr2 to be used for other purposes. 2013-01-31 09:42:20 +00:00
dgp 4eaaa750d1 For traces and embedding support, select modernizations from Patrick Fradin. 2013-01-31 04:34:11 +00:00
dgp 8f86b72df7 For embedding support, select modernizations from Patrick Fradin 2013-01-31 04:29:30 +00:00
dgp 6d259f9319 Better testevent cleanup and event loop management 2013-01-31 04:07:11 +00:00
dgp b9069b9577 Remove old vars and tests, now unused, one that collides with tcltest. 2013-01-30 22:40:06 +00:00
dgp c241c33749 missing testevent delete 2013-01-30 22:08:05 +00:00
dgp 37ba1458ac For traces, select modernizations from Patrick Fradlin. 2013-01-30 21:34:24 +00:00
dgp 3c9637c2fe For Parse/eval & msgcat, select modernizations from Patrick Fradin + -debug fix 2013-01-30 20:51:43 +00:00
dgp f034dfb455 For msgcat, select modernizations from Patrick Fradin + -debug fix. 2013-01-30 20:49:03 +00:00
dgp 972b9eeb07 For Parse/eval, select modernizations from Patrick Fradin. 2013-01-30 20:42:10 +00:00
andreask a071678d02 (::platform::LibcVersion): See [Bug 3599098]: Fixed the RE extracting
the version to avoid issues with recent changes to the glibc
banner. Now targeting a less variable part of the string. Bumped
package to version 1.0.11.
2013-01-30 19:27:34 +00:00
andreask 9023ee32ce (::platform::LibcVersion): See [Bug 3599098]: Fixed the RE extracting
the version to avoid issues with recent changes to the glibc
banner. Now targeting a less variable part of the string. Bumped
package to version 1.0.11.
2013-01-30 19:18:52 +00:00
dgp 7c1d7acf56 For [package] etc., select modernizations from Patrick Fradin. 2013-01-30 19:00:27 +00:00
dgp 62d19c65eb For [package] etc., select modernizations from Patrick Fradin. 2013-01-30 18:58:37 +00:00
dgp aee1b56cc2 In the script library, selected modernizations from Patrick Fradin. 2013-01-30 17:58:00 +00:00
dgp 91a7a404d2 In the script library, selected modernizations from Patrick Fradin. 2013-01-30 17:46:30 +00:00
dgp 7a00fde1d2 More improvements found browsing tcltest 2013-01-30 17:22:49 +00:00
dgp 1f7f9de685 More improvements found browsing tcltest. 2013-01-30 17:15:06 +00:00
dgp 4e523443fe Fradin improvements in test suite too 2013-01-30 16:52:11 +00:00
dgp 16ee47efcc Fradin improvements in test suite too. 2013-01-30 16:51:36 +00:00
dgp 804b3bb41e For tcltest, selected modernizations and style improvements from Patrick Fradin. 2013-01-30 16:34:10 +00:00
dgp b220f67a4e For tcltest, selected modernizations and style improvements from Patrick Fradin. 2013-01-30 16:27:54 +00:00
mig 1e68029cac empty, to jump over mistake 2013-01-29 17:50:15 +00:00
dkf e87a46437e Improve code generation for some ensemble subcommands in cases where full
compilation is impossible yet full ensemble invoking is unnecessary.
Also fix a few minor doc formatting bugs.
2013-01-28 15:16:59 +00:00
dkf 1139530e78 More extensive use of the techniques to improve other edge cases in ensemble compilation. 2013-01-28 11:43:59 +00:00
dkf 5887924a63 Slightly better compilation of some [array] cases. 2013-01-28 01:27:32 +00:00
dkf 5fea85e6d3 merge trunk 2013-01-28 00:57:04 +00:00
jan.nijtmans 13dcbf7d2f [Bug 3601804]: platformCPUID segmentation fault on Darwin 2013-01-26 16:55:24 +00:00
jan.nijtmans fedbfcec36 [Bug 3601804]: platformCPUID segmentation fault on Darwin 2013-01-26 16:53:59 +00:00
mig 28bc611c7b remove unused code 2013-01-25 18:47:45 +00:00
jan.nijtmans 9177f9a41b Another memory leak, and one Tcl_Free -> ckfree 2013-01-25 13:07:59 +00:00
jan.nijtmans 6ec16f5f96 fix minor memory leak 2013-01-25 11:53:41 +00:00
jan.nijtmans 6abe764edc Eliminate some unneeded usages of Tcl_SetResult, Tcl_AddObjErrorInfo
Fix "make test-packages" on cygwin
2013-01-25 11:48:29 +00:00
jan.nijtmans a0eb86a864 new version of cpuid, which doesn't use the edi register any more. Hopefully that works better on some Darwin. 2013-01-24 22:02:30 +00:00
jan.nijtmans f20449d17d new version of cpuid, which doesn't use the edi register any more. Hopefully that works better on some Darwin. 2013-01-24 22:01:38 +00:00
jan.nijtmans f028c958cc revert [8e83219e38]: it doesn't work on i386 2013-01-24 21:31:09 +00:00
jan.nijtmans 9663c3b502 revert [f3509c3d35]: it doesn't work on i386 2013-01-24 21:29:56 +00:00
dgp 1a0cb53eec Silence some compiler warnings. 2013-01-24 20:46:58 +00:00
dgp ba7881d6ea Silence come compiler warnings. 2013-01-24 19:09:33 +00:00
jan.nijtmans a199dc464d merge core-8-5-branch 2013-01-24 14:56:10 +00:00
jan.nijtmans 587cef5259 Simplify STRING_AT macro.
Protect Tcl_GetIndexFromObjStruct from invalid "offset" values, like 0 or -1. Undocumented, because I don't want to promote people start using that.
2013-01-24 08:22:40 +00:00
jan.nijtmans 53cba5d9ba Simplify STRING_AT macro.
Protect Tcl_GetIndexFromObjStruct from invalid "offset" values, like 0 or -1. Undocumented, because I don't want to promote people start using that.
2013-01-24 08:05:42 +00:00
jan.nijtmans 3a39b4007c Fix [2911139]: connect asynchronously, but without unnecessary internal waits. 2013-01-23 14:04:27 +00:00
dkf 1d751279fa Fix [2911139]: connect asynchronously, but without unnecessary internal waits. 2013-01-23 09:03:46 +00:00
jan.nijtmans 8a8a8b6a83 Now really fix test-case http-4.14 2013-01-22 22:53:26 +00:00
jan.nijtmans 6c54d4f137 Bug [3601804]: platformCPUID segmentation fault on Darwin 2013-01-22 21:58:18 +00:00
jan.nijtmans 3a2c58f0e3 Bug [3601804]: platformCPUID segmentation fault on Darwin 2013-01-22 21:57:27 +00:00
jan.nijtmans 357b0f7709 Fix test-case http-4.14 2013-01-22 08:16:44 +00:00
jan.nijtmans 9085296627 Put back Tcl[GS]etStartupScript(Path|FileName) in private stub table, so extensions using this (like Tk 8.4) will continue to work in all Tcl 8.x versions.
Extensions using this still cannot be compiled against Tcl 8.6 headers.
2013-01-21 13:51:11 +00:00
dkf e262c66df2 merge main 8.5 branch 2013-01-19 22:25:58 +00:00
jan.nijtmans 98a40cff2c fix Bug 3598300 on MacOSX too 2013-01-19 17:49:16 +00:00
jan.nijtmans b6eebed4e6 fix Bug 3598300 on MacOSX too 2013-01-19 17:48:11 +00:00
jan.nijtmans 21c3f3fee2 Proposed solution for Bug 3598300 on MacOSX 2013-01-18 15:07:18 +00:00
jan.nijtmans 581c5b94ab [Bug 3598300]: unix: tcl.h does not include sys/stat.h.
(with an exception for OSX, for now)
2013-01-18 14:44:45 +00:00
jan.nijtmans 6b531a4b27 ... and fix cygwin build 2013-01-18 14:30:25 +00:00
jan.nijtmans 816626b12f [Bug 3598300]: unix: tcl.h does not include sys/stat.h.
(with an exception for OSX, for now)
2013-01-18 13:58:32 +00:00
mig a6461e6b0d COMPILE_DEBUG big: fix bug in stack verification for {*} 2013-01-17 15:13:40 +00:00
dkf 0a8b2b3150 [3600328]: Fix problems caused by buggy [array] compilation inside a buggy
ensemble compilation (which had the net result of producing *very* wrong code).
2013-01-17 15:08:46 +00:00
jan.nijtmans 928a5b1970 Bug 3601260: Reverting [8aca9a8e96] fixes it. 2013-01-17 14:56:59 +00:00
dkf d31e503f35 merge trunk 2013-01-17 13:46:52 +00:00
jan.nijtmans 43ce79f987 Proposed fix, by kakaroto, for Bug 2911139: http::geturl abuses vwait on async call 2013-01-17 13:29:07 +00:00
jan.nijtmans 6949095cb4 revert [8abba84224], and make sure that every source file that uses Tcl_StatBuf has an "#include <sys/stat.h>" before including tcl.h 2013-01-17 08:38:41 +00:00
jan.nijtmans d1e73c6065 revert [8abba84224], and make sure that every source file that uses Tcl_StatBuf has an "#include <sys/stat.h>" before including tcl.h 2013-01-17 08:28:41 +00:00
dkf de9162b578 merge trunk 2013-01-16 14:16:34 +00:00
dkf f3fe26d49f [Bug 3601086]: Register zlib config as iso8859-1 (a superset of ascii) as that
is an encoding we guarantee to support without loading encoding files.
2013-01-16 11:01:46 +00:00
jan.nijtmans 423ee90c6a Allow win32 build with -DTCL_NO_DEPRECATED, just as the UNIX build, off by default.
Define Tcl_EvalObj and Tcl_GlobalEvalObj as macros, even when TCL_NO_DEPRECATED is defined, so Tk can benefit from it too.
2013-01-16 09:58:26 +00:00
jan.nijtmans 3bbe089a07 Allow win32 build with -DTCL_NO_DEPRECATED, just as the UNIX build, off by default.
Define Tcl_EvalObj and Tcl_GlobalEvalObj as macros, even when TCL_NO_DEPRECATED is defined, so Tk can benefit from it too (this is not what TCL_NO_DEPRECATED is supposed to do).
2013-01-16 09:17:25 +00:00
jan.nijtmans eebca1b422 [Bug 3598300]: unix: tcl.h does not include sys/stat.h 2013-01-15 21:06:32 +00:00
mig 0da09b361f peephole INST_START_CMD before entering the big switch in tebc 2013-01-15 19:37:30 +00:00
mig d7bd3ea929 merge trunk 2013-01-15 19:35:52 +00:00
mig 4a942632c1 remove [4522b11989], it breaks the build on linux 2013-01-15 19:26:45 +00:00
jan.nijtmans 19ba6d24b8 REMOVED FROM TRUNK: buggy, breaks the build on linux. [Bug 3598300]: unix: tcl.h does not include sys/stat.h 2013-01-15 17:38:57 +00:00
jan.nijtmans 5d8dc198ff [Bug 3598300]: unix: tcl.h does not include sys/stat.h 2013-01-15 17:32:13 +00:00
jan.nijtmans 5d071002e5 More flexible search for win32 tclConfig.sh, backported from TEA (not actually used in Tcl, only for Tk) 2013-01-14 20:13:41 +00:00
jan.nijtmans 1415e8eb0e merge trunk
remove some EXTERN and CONST usages in tclUnixPort.h
2013-01-14 19:56:43 +00:00
jan.nijtmans 89971c7559 forgot two #undef's 2013-01-14 15:23:41 +00:00
jan.nijtmans e267380dad Put back Tcl_[GS]etStartupScript in internal stub table, so extensions using this, compiled against 8.5 headers still run in Tcl 8.6. 2013-01-14 15:19:18 +00:00
mig 0e4e7f881d Various bits of cleanup, efficiencies, and comment documentation in tclVar.c (from mig-review) 2013-01-13 23:26:02 +00:00
mig 9a14873b85 Various bits of cleanup, efficiencies, and comment documentation in tclVar.c (from mig-review) 2013-01-13 23:15:10 +00:00
ferrieux 89369231f5 Clarify readable fileevent "false positives" in the case of multibyte encodings/transforms [Bug 3436609]. 2013-01-13 18:12:41 +00:00
jan.nijtmans a2021967ac If TCL_NO_DEPRECATED is defined, make sure that TIP #139 functions all are taken from the public stub table, even if the inclusion is through tclInt.h. 2013-01-13 09:13:45 +00:00
jan.nijtmans 3327b4aa93 If TCL_NO_DEPRECATED is defined, make sure that TIP #139 functions all are taken from the public stub table, even if the inclusion is through tclInt.h. 2013-01-13 09:04:10 +00:00
jan.nijtmans 9822c32dd0 Put back TclBackgroundException in internal stub table, so extensions using this, compiled against 8.5 headers still run in Tcl 8.6. 2013-01-12 21:57:24 +00:00
mig 25ab9d5408 discouraging the compiler from re-reading *pc in the peephole loop, part2 (any diff?) 2013-01-12 10:53:23 +00:00
mig 7715309bee discouraging the compiler from re-reading *pc in the peephole loop 2013-01-12 10:49:25 +00:00
mig b4e2d9a5f7 even better ... or so I hope: also inlining INST_PUSH1 in the peephole, checking for ISC after LOAD1 and PUSH1 2013-01-12 10:14:06 +00:00
mig e81a0740ec merge trunk 2013-01-11 23:29:46 +00:00
mig d81457480e better comments 2013-01-11 21:16:07 +00:00
mig eff3ee2c12 fix for consecutive ISC (produced by [while 1 {...}) 2013-01-11 18:05:50 +00:00
dgp e5f2221983 Test for Bug 1884496 (not buggy on trunk). 2013-01-11 17:27:38 +00:00
mig 216a40de66 testing a cheaper(?) INST_START_COMMAND 2013-01-11 15:37:10 +00:00
dkf 793f8e5aba merge trunk 2013-01-11 14:15:12 +00:00
dkf ee55e0197b First attempt at fixing problems caused by [array set] inside [namespace eval],
which caused partial bytecode generation followed by a reject which triggered
the issuing of generic ensemble code with an extra push of the variable name at
the start (which got the stack depth wrong).
2013-01-11 14:04:33 +00:00
mig 43988caaa2 Name functions according to 'what' instead of 'how' in the [tailcall]
machinery, in view of making public some parts of it.
2013-01-11 12:42:14 +00:00
mig d562dc0f60 tailcall now running in a simpler model, with no eval-flags and no nre-stack rewriting; yieldto also requires one fewer bounce. Mostly from mig-nre-mods 2013-01-10 21:18:52 +00:00
mig 9f0eb68928 fix off-by-one error introduced in bd7d7a2061 2013-01-10 18:17:33 +00:00
jan.nijtmans 5c3966aa9c merge-mark 2013-01-09 21:31:23 +00:00
jan.nijtmans 8f2f7117fc [Bug 3599395]: http assumes status line is a proper tcl list. 2013-01-09 14:07:08 +00:00
jan.nijtmans 34d5896205 [Bug 3599395]: http assumes status line is a proper tcl list.
Bump http package to 2.7.11.
2013-01-09 14:00:15 +00:00
jan.nijtmans 24b681cb7a $builddir is a local variable 2013-01-08 13:03:01 +00:00
jan.nijtmans f1b40ee639 [Bug 3092089]: [file normalize] can remove path components.
[Bug 3587096] win vista/7: "can't find init.tcl" when called via junction.
2013-01-08 10:27:42 +00:00
jan.nijtmans 638edeffa4 [Bug 3092089]: [file normalize] can remove path components.
[Bug 3587096] win vista/7: "can't find init.tcl" when called via junction.
2013-01-08 10:17:54 +00:00
jan.nijtmans ada7e74894 mSys doesn't have $PWD. Reported by Rene Zaumseil on Tcl Core list 2013-01-08 08:08:28 +00:00
jan.nijtmans 978558169e Restrict the stub library to only use Tcl_PkgRequireEx, Tcl_ResetResult and Tcl_AppendResult, not any other function.
This puts least restrictions on eventual Tcl 9 stubs re-organization, and it works on the widest range of Tcl versions.
2013-01-07 14:40:56 +00:00
jan.nijtmans 0d214a0a14 merge-mark. Hoping trunk is OK now, again ;-( 2013-01-07 13:00:26 +00:00
jan.nijtmans 4087d33e18 Extend the public stub table with dummy NULL entries, up to the size of the Tcl 8.6 stub tables.
This makes it easier to debug extensions which use Tcl 8.6 features but (erroneously) are attempted to be loaded in Tcl 8.5.
2013-01-07 11:16:50 +00:00
jan.nijtmans b2dabdc1eb Don't depend on Spencer-specific regexp syntax (/u and /U) any more in unrelated places
.  Bump http package to 2.8.6.
2013-01-06 20:40:57 +00:00
dkf 4a7aba80a6 merge trunk 2013-01-05 18:16:06 +00:00
mig a8a9d42601 improved stack checking under TCL_COMPILE_DEBUG 2013-01-05 03:43:05 +00:00
jan.nijtmans d223d51178 merge fork 2013-01-05 00:39:21 +00:00
mig 7fbeaf9528 fix the new assertion, it should not trigger when an expansion is in progress 2013-01-05 00:36:25 +00:00
jan.nijtmans 2c5cd34ebe adjust stub library version number 2013-01-05 00:36:25 +00:00
jan.nijtmans 13adf38211 adjust stub library version number 2013-01-05 00:33:21 +00:00
mig 9b6ebeae02 Add an assertion that checks the stack depth under TCL_COMPILE_DEBUG *before* stack cleanup. It currently triggers at several spots in the testsuite! 2013-01-05 00:15:19 +00:00
dkf 5bce11a1c8 Fix memory leak in [format] compiler. 2013-01-04 15:01:57 +00:00
dkf 32cc5d8d3c Fix bad memory access problems found by Miguel Sofer when valgrinding. 2013-01-04 14:38:37 +00:00
dkf e2e14fde2d merge trunk 2013-01-04 11:14:59 +00:00
dkf 679963704f Improve code generation for many simple core ensemble subcommands. 2013-01-04 11:14:21 +00:00
dkf 32df42787e Add super-simple compiler to many ensemble subcommands to allow better code
generation where we can detect that we're not in the WrongNumArgs case.
The compiler just checks that the argument count is in the right range and
issues a standard dispatch; that's enough to do an efficient job.
2013-01-04 11:06:14 +00:00
mig 0cf062c388 Insure that PURIFY builds cannot exploit the Tcl stack to hide mem defects. 2013-01-04 05:26:40 +00:00
dkf 207412c303 "Mine eyes deceive, but others catch me when I fall." -- Someone or other 2013-01-03 14:35:07 +00:00
dkf bf368d9079 Channel buffer min size is 1. Issue found by Schelte Bron. 2013-01-03 14:24:48 +00:00
dgp 45c7f36909 speling ficks 2013-01-03 14:02:21 +00:00
dgp 285dd19c62 speling ficks 2013-01-03 14:00:37 +00:00
dkf 240695b9f5 merge trunk 2013-01-03 10:25:23 +00:00
dkf 3aba154e26 Added mechanism for pre-parsing built-in ensembles even when they are not going
to generate specific code. This provides a good speedup in some cases.
2013-01-03 10:23:01 +00:00
jan.nijtmans 1bef171761 test case for bug-3598580: Tcl_ListObjReplace may release deleted elements too early 2013-01-03 09:46:57 +00:00
dkf 3ce1c8d98b Got the test suite passing cleanly. Excellent. 2013-01-03 00:37:29 +00:00
mig ef5aee8d47 no changes, sync with core-8-5-branch to signal the backported fix 2013-01-02 19:28:57 +00:00
mig 8d4878fee6 remove stray calls to Tcl_Alloc and friends: the core should only use ckalloc to allow MEM_DEBUG to work properly 2013-01-02 19:20:54 +00:00
dkf b0465ff0e8 merge trunk 2013-01-02 18:35:39 +00:00
dkf f9651e0da6 All tests pass except one; not sure what's wrong there. 2013-01-02 18:33:27 +00:00
dkf 18ab8f43a0 Passing more tests. 2013-01-02 15:10:00 +00:00
jan.nijtmans 77014e3f62 test Tcl_GetErrorLine() forwards/backwards compatibility in pkgb.so as well.
Don't free ctrl.script if thread creation fails: it is a constant string "testthread wait" normally.
2013-01-02 14:37:23 +00:00
dkf c0845253a0 Marked some string subcommands as obsolete, following discussion on tcl-core. 2012-12-31 12:32:13 +00:00
dkf 38ba6bd5d4 Working towards more efficient treatment of non-bytecoded ensemble subcommands. 2012-12-31 02:39:40 +00:00
jan.nijtmans 0c64074372 restore refcounts as they were before the Tcl_ListObjReplace call, in the error situation.
In Tcl9, make this a true Tcl_DecrRefCount, which properly cleans objects with refCount 0
2012-12-29 09:23:24 +00:00
jan.nijtmans d12ee9da30 [Bug 3598580]: Tcl_ListObjReplace may release deleted elements too early 2012-12-27 15:04:11 +00:00
jan.nijtmans d83a20092e proposed fix for Bug 3598300 2012-12-26 10:07:54 +00:00
jan.nijtmans 65013d771a eliminate dependancy of compat/*.h on tcl.h 2012-12-26 09:59:44 +00:00
dkf 74cca07e35 merge trunk 2012-12-23 08:18:10 +00:00
dkf e2e451e2e5 Change back to using an isDigit function. We simply don't need to make any
(formally non-portable) assumptions about what happens when an unsigned zero
is decremented, and the code isn't in a performance-critical area.

Remark by jan.nijtmans: The macro is perfectly portable! Not portable is the
exact result of the substraction ('\xB0' - '0' might give 0x80 on some platforms and 0xffffff80 on others), but comparing <= 9 always gives the correct result. We are only checking for digits here! The macro correctly inlines with any compiler, so it's better anyway.

Remark by dkf: But it's less clear. In this code, that's more important than a teeny bit of speed from inlining in a non-critical location.
2012-12-23 08:17:17 +00:00
ferrieux ed156a09fa Stop leaking allocated space when objifying a zero-length DString. [Bug 3598150] spotted by afredd. 2012-12-22 19:05:34 +00:00
dkf 8f40b2b313 merge release 2012-12-22 15:21:56 +00:00
jan.nijtmans 21bd9cf5ad Inline compat Tcl_GetDefaultEncodingDir.
Eliminate unnecessary static HasStubSupport() and isDigit() functions, just do the same inline.
2012-12-21 09:13:31 +00:00
dgp f3a3f7b9e8 merge release 2012-12-21 06:16:00 +00:00
dkf a2afb09b3c Improved the sequence of instructions issued for [subst] when dealing with
simple variable references.
2012-12-18 14:02:43 +00:00
dkf 81a67b9cf4 Better version that can handle simple composite array keys as well. As long as
they are free of command substitutions, we can still safely omit the exception
processor code.
2012-12-18 10:21:34 +00:00
dkf 569360bf40 Generate better code for the common case of subst-ed variables where the
variable is a simple scalar or an array with a simple literal element name.
2012-12-18 09:37:42 +00:00
dkf 59e42de547 merge trunk 2012-12-18 09:02:38 +00:00
dkf fa7a06447d Simpler code to do installation of [info class] and [info object].
We know this is a safe thing to do as we know this is inside Tcl_CreateInterp()
and so no confounding code could have been run.
2012-12-17 14:40:17 +00:00
dkf b13b1c6020 Slim down the code a bit more; we can make more safe assumptions. 2012-12-17 14:27:44 +00:00
dgp d67ebaffd4 merge trunk, update changes and re-tag 2012-12-14 19:25:04 +00:00
dgp 237b1ee14a Various bits of cleanup, efficiencies, and comment documentation in tclVar.c 2012-12-14 17:47:55 +00:00
dgp 8890130ab8 TIP 400 suffered from the same segfaulting flaw as 3595576.
Segfaulting test and fix committed.
2012-12-13 20:20:46 +00:00
dgp 093fb49d43 Simplify the [info object] and [info class] additions. 2012-12-13 19:43:43 +00:00
dgp 0ccb6618bd Restore clarity to macro test. 2012-12-13 16:17:13 +00:00
dgp af92fc0c28 Merge 3595576 tests from 8.5. 2012-12-13 16:08:13 +00:00
mig 1d29f93257 Fix for [Bug 3595576], found by andrewsh 2012-12-13 13:37:19 +00:00
jan.nijtmans 9918a06afa Changelog entry, and change macro variable to not conflict with possible outside variable names 2012-12-13 12:14:37 +00:00
jan.nijtmans eace9319cb Fix Tcl_DecrRefCount macro, not to refer to its objPtr parameter twice. 2012-12-13 11:02:15 +00:00
dgp 6428006e92 Prefer to extract package data from the *contents* not the directory name. 2012-12-12 20:16:13 +00:00
dgp 78a3c34ca2 Tag 8.6.0 for release 2012-12-11 21:31:18 +00:00
dgp c13ee047c8 update changes 2012-12-11 21:19:11 +00:00
dkf c1784e6b4c Improve the generation of HTML documentation in 8.6, allowing for contributed
packages whose non-version name parts are prefixes of others. Also ensure that
documentation builds are complete after distribution, and that we generate a
better error message when using the wrong tclsh version to do the build.
2012-12-10 23:23:50 +00:00
dgp 498562a0e5 merge trunk 2012-12-10 15:58:23 +00:00
dgp 15f02f424c Restore the initialization of tclStubsPtr from the "Tcl" package clientData
so that we don't close off a potential avenue of future innovations.
2012-12-10 14:17:19 +00:00
ferrieux 2fd9e3776b [Bug 3594188] Clarifications about commas. 2012-12-09 19:44:57 +00:00
ferrieux 16df5aebc9 Clean up unwanted eofchar side-effect of chan-4.6 leading to a spurious "'" at end of chan.test under certain conditions (see [Bug 3389289] and [Bug 3389251]). 2012-12-09 11:52:04 +00:00
ferrieux 8a282bbf9e Fix busyloop at exit under TCL_FINALIZE_ON_EXIT when there are unflushed nonblocking channels. Thanks Miguel for spotting. 2012-12-08 17:13:03 +00:00
jan.nijtmans 5e55e0d280 just lost one MODULE_SCOPE in the merge 2012-12-07 22:14:26 +00:00
jan.nijtmans bd8d73a7d5 only set tclStubsPtr if all version checks pass 2012-12-07 21:36:34 +00:00
dgp aa34213e75 merge trunk 2012-12-07 19:26:49 +00:00
dgp b54c784f20 3593703 Don't crash on bad input to Tcl_PkgRequire*(). 2012-12-07 18:08:48 +00:00
dgp c46c79caa2 Source compat, rather than stubs compat demo. 2012-12-07 17:03:39 +00:00
mig 2adea0d04e small correction in doc/NRE.3 2012-12-07 15:56:13 +00:00
jan.nijtmans 7720b5d9df fix failing test 2012-12-07 15:53:29 +00:00
jan.nijtmans f894c98ebc add proper runtime-detection to pkgb.so 2012-12-07 15:51:25 +00:00
dgp 1aa7610988 Extended test of [load]ing Tcl 8 compiled extension into Tcl 9 interp. 2012-12-07 14:53:40 +00:00
jan.nijtmans 02929519ba Turn pkgb.so into a Tcl9 interoperability test
library: Whatever Tcl9 looks like, loading pkgb.so in Tcl 9 should
either result in an error-message, either succeed, but never crash.
2012-12-07 09:56:39 +00:00
dgp 22f216f372 Tcl_InitStubs("8.5",1) would succeed in an "8.50" interp. Fixed. 2012-12-06 21:10:19 +00:00
dgp 5240308ed2 merge trunk 2012-12-04 20:40:50 +00:00
dgp fcf174f284 merge trunk 2012-11-26 15:28:12 +00:00
dgp 52e06a03d8 merge trunk 2012-11-22 17:27:03 +00:00
dkf 6e2667d4d2 merge trunk 2012-11-19 22:10:10 +00:00
dgp b670d49ae2 merge trunk 2012-11-19 17:30:33 +00:00
dgp 91d791cd85 merge trunk 2012-11-16 12:52:39 +00:00
dgp 275cdefdd7 merge trunk: 2012-11-15 01:54:58 +00:00
dgp f14b389544 merge trunk 2012-11-14 16:57:23 +00:00
dgp b8076815be merge trunk 2012-11-13 21:31:30 +00:00
dgp 6734623337 merge trunk 2012-11-08 15:44:09 +00:00
dgp ea58b7b66f Declare TclOO portion of the Tcl API to be stable -> TclOO 1.0 2012-11-08 15:43:45 +00:00
dgp 7635c56e5d Create Tcl 8.6.0 release branch 2012-11-08 15:25:30 +00:00
dkf ec58b631ce merge trunk: INST_TAILCALL has bug 2012-11-05 21:47:12 +00:00
dkf 49dd27a4ea merge trunk 2012-11-05 15:17:26 +00:00
1546 changed files with 419251 additions and 137110 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tcl8.4</name>
<name>tcl8.5</name>
<comment></comment>
<projects>
</projects>
+2750 -11449
View File
File diff suppressed because it is too large Load Diff
+1315 -1379
View File
File diff suppressed because it is too large Load Diff
+906 -950
View File
File diff suppressed because it is too large Load Diff
+1450 -1559
View File
File diff suppressed because it is too large Load Diff
+4741
View File
File diff suppressed because it is too large Load Diff
+3349
View File
File diff suppressed because it is too large Load Diff
+4619
View File
File diff suppressed because it is too large Load Diff
+3822
View File
File diff suppressed because it is too large Load Diff
+5921
View File
File diff suppressed because it is too large Load Diff
+1529
View File
File diff suppressed because it is too large Load Diff
+22 -23
View File
@@ -1,8 +1,7 @@
README: Tcl
This is the Tcl 8.4.19 source distribution.
http://tcl.sourceforge.net/
You can get any source release of Tcl from the file distributions
link at the above URL.
This is the Tcl 8.5.15 source distribution.
http://sourceforge.net/projects/tcl/files/Tcl/
You can get any source release of Tcl from the URL above.
Contents
--------
@@ -22,14 +21,19 @@ Contents
Tcl provides a powerful platform for creating integration applications that
tie together diverse applications, protocols, devices, and frameworks.
When paired with the Tk toolkit, Tcl provides the fastest and most powerful
way to create GUI applications that run on PCs, Unix, and the Macintosh.
way to create GUI applications that run on PCs, Unix, and Mac OS X.
Tcl can also be used for a variety of web-related tasks and for creating
powerful command languages for applications.
Tcl is maintained, enhanced, and distributed freely by the Tcl community.
The home for Tcl/Tk releases and bug/patch database is on SourceForge:
Source code development and tracking of bug reports and feature requests
takes place at:
http://tcl.sourceforge.net/
http://core.tcl.tk/
Tcl/Tk release and mailing list services are hosted by SourceForge:
http://sourceforge.net/projects/tcl/
with the Tcl Developer Xchange hosted at:
@@ -45,11 +49,11 @@ and selling it either in whole or in part. See the file
Extensive documentation is available at our website.
The home page for this release, including new features, is
http://www.tcl.tk/software/tcltk/8.4.html
http://www.tcl.tk/software/tcltk/8.5.html
Detailed release notes can be found at the file distributions page
by clicking on the relevant version.
http://sourceforge.net/projects/tcl/files/
http://sourceforge.net/projects/tcl/files/Tcl/
Information about Tcl itself can be found at
http://www.tcl.tk/about/
@@ -57,9 +61,9 @@ Information about Tcl itself can be found at
There have been many Tcl books on the market. Many are mentioned in the Wiki:
http://wiki.tcl.tk/_/ref?N=25206
To view the complete set of reference manual entries for Tcl 8.4 online,
To view the complete set of reference manual entries for Tcl 8.5 online,
visit the URL:
http://www.tcl.tk/man/tcl8.4/
http://www.tcl.tk/man/tcl8.5/
2a. Unix Documentation
----------------------
@@ -118,8 +122,8 @@ information about Tcl, Tk, and related applications. The newsgroup is a
great place to ask general information questions. For bug reports, please
see the "Support and bug fixes" section below.
6. The Tcler's Wiki
-------------------
6. Tcl'ers Wiki
---------------
A Wiki-based open community site covering all aspects of Tcl/Tk is at:
@@ -146,18 +150,13 @@ and go to the Mailing Lists page.
------------------------
We are very interested in receiving bug reports, patches, and suggestions
for improvements. We prefer that you send this information to us via the
bug form at SourceForge, rather than emailing us directly. The bug
database is at:
for improvements. We prefer that you send this information to us as
tickets entered into our tracker at:
http://tcl.sourceforge.net/
The bug form was designed to give uniform structure to bug reports as
well as to solicit enough information to minimize followup questions.
http://core.tcl.tk/tcl/reportlist
We will log and follow-up on each bug, although we cannot promise a
specific turn-around time. Enhancements, reported via the Feature
Requests form at the same web site, may take longer and may not happen
specific turn-around time. Enhancements may take longer and may not happen
at all unless there is widespread support for them (we're trying to
slow the rate at which Tcl/Tk turns into a kitchen sink). It's very
difficult to make incompatible changes to Tcl/Tk at this point, due to
@@ -167,7 +166,7 @@ The Tcl community is too large for us to provide much individual support
for users. If you need help we suggest that you post questions to
comp.lang.tcl. We read the newsgroup and will attempt to answer esoteric
questions for which no one else is likely to know the answer. In addition,
see the following page on the Wiki for links to other organizations that offer
see the following Web site for links to other organizations that offer
Tcl/Tk training:
http://wiki.tcl.tk/training
+1451 -186
View File
File diff suppressed because it is too large Load Diff
+3 -7
View File
@@ -14,10 +14,6 @@
#ifndef _DIRENT
#define _DIRENT
#ifndef _TCL
#include <tcl.h>
#endif
/*
* Dirent structure, which holds information about a single
* directory entry.
@@ -50,8 +46,8 @@ typedef struct _dirdesc {
* Procedures defined for reading directories:
*/
extern void closedir _ANSI_ARGS_((DIR *dirp));
extern DIR * opendir _ANSI_ARGS_((char *name));
extern struct dirent * readdir _ANSI_ARGS_((DIR *dirp));
extern void closedir (DIR *dirp);
extern DIR * opendir (char *name);
extern struct dirent * readdir (DIR *dirp);
#endif /* _DIRENT */
+7 -12
View File
@@ -1,4 +1,4 @@
/*
/*
* dlfcn.h --
*
* This file provides a replacement for the header file "dlfcn.h"
@@ -19,7 +19,6 @@
*/
/*
* @(#)dlfcn.h 1.4 revision of 95/04/25 09:36:52
* This is an unpublished work copyright (c) 1992 HELIOS Software GmbH
* 30159 Hannover, Germany
*/
@@ -27,10 +26,6 @@
#ifndef __dlfcn_h__
#define __dlfcn_h__
#ifndef _TCL
#include <tcl.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
@@ -47,14 +42,14 @@ extern "C" {
* that contains functions to be called to initialize and terminate.
*/
struct dl_info {
void (*init) _ANSI_ARGS_((void));
void (*fini) _ANSI_ARGS_((void));
void (*init) (void);
void (*fini) (void);
};
VOID *dlopen _ANSI_ARGS_((const char *path, int mode));
VOID *dlsym _ANSI_ARGS_((void *handle, const char *symbol));
char *dlerror _ANSI_ARGS_((void));
int dlclose _ANSI_ARGS_((void *handle));
void *dlopen (const char *path, int mode);
void *dlsym (void *handle, const char *symbol);
char *dlerror (void);
int dlclose (void *handle);
#ifdef __cplusplus
}
+4 -4
View File
@@ -20,12 +20,12 @@
* somes systems (e.g. SunOS 4.1.4) stdlib.h doesn't declare strtod.
*/
extern double strtod();
extern double strtod(char *, char **);
double
fixstrtod(string, endPtr)
char *string;
char **endPtr;
fixstrtod(
char *string,
char **endPtr)
{
double d;
d = strtod(string, endPtr);
+4 -4
View File
@@ -10,18 +10,18 @@
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tcl.h"
#include "tclPort.h"
#include <sys/timeb.h>
#undef timezone
int
gettimeofday(tp, tz)
struct timeval *tp;
struct timezone *tz;
gettimeofday(
struct timeval *tp,
struct timezone *tz)
{
struct timeb t;
ftime(&t);
tp->tv_sec = t.time;
tp->tv_usec = t. millitm * 1000;
+22 -18
View File
@@ -1,24 +1,21 @@
/*
/*
* memcmp.c --
*
* Source code for the "memcmp" library routine.
*
* Copyright (c) 1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tcl.h"
#include "tclPort.h"
/*
* Here is the prototype just in case it is not included
* in tclPort.h.
* Here is the prototype just in case it is not included in tclPort.h.
*/
int memcmp _ANSI_ARGS_((CONST VOID *s1,
CONST VOID *s2, size_t n));
int memcmp(CONST VOID *s1, CONST VOID *s2, size_t n);
/*
*----------------------------------------------------------------------
@@ -28,11 +25,10 @@ int memcmp _ANSI_ARGS_((CONST VOID *s1,
* Compares two bytes sequences.
*
* Results:
* compares its arguments, looking at the first n
* bytes (each interpreted as an unsigned char), and returns
* an integer less than, equal to, or greater than 0, accord-
* ing as s1 is less than, equal to, or
* greater than s2 when taken to be unsigned 8 bit numbers.
* Compares its arguments, looking at the first n bytes (each interpreted
* as an unsigned char), and returns an integer less than, equal to, or
* greater than 0, according as s1 is less than, equal to, or greater
* than s2 when taken to be unsigned 8 bit numbers.
*
* Side effects:
* None.
@@ -41,10 +37,10 @@ int memcmp _ANSI_ARGS_((CONST VOID *s1,
*/
int
memcmp(s1, s2, n)
CONST VOID *s1; /* First string. */
CONST VOID *s2; /* Second string. */
size_t n; /* Length to compare. */
memcmp(
CONST VOID *s1, /* First string. */
CONST VOID *s2, /* Second string. */
size_t n) /* Length to compare. */
{
CONST unsigned char *ptr1 = (CONST unsigned char *) s1;
CONST unsigned char *ptr2 = (CONST unsigned char *) s2;
@@ -52,9 +48,17 @@ memcmp(s1, s2, n)
for ( ; n-- ; ptr1++, ptr2++) {
unsigned char u1 = *ptr1, u2 = *ptr2;
if ( u1 != u2) {
if (u1 != u2) {
return (u1-u2);
}
}
return 0;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
+65 -60
View File
@@ -1,14 +1,12 @@
/*
* opendir.c --
*
* This file provides dirent-style directory-reading procedures
* for V7 Unix systems that don't have such procedures. The
* origin of this code is unclear, but it seems to have come
* originally from Larry Wall.
* This file provides dirent-style directory-reading procedures for V7
* Unix systems that don't have such procedures. The origin of this code
* is unclear, but it seems to have come originally from Larry Wall.
*/
#include "tclInt.h"
#include "tclPort.h"
#undef DIRSIZ
#define DIRSIZ(dp) \
@@ -17,24 +15,28 @@
/*
* open a directory.
*/
DIR *
opendir(name)
char *name;
{
register DIR *dirp;
register int fd;
char *myname;
myname = ((*name == '\0') ? "." : name);
if ((fd = open(myname, 0, 0)) == -1)
return NULL;
if ((dirp = (DIR *)ckalloc(sizeof(DIR))) == NULL) {
close (fd);
return NULL;
}
dirp->dd_fd = fd;
dirp->dd_loc = 0;
return dirp;
DIR *
opendir(
char *name)
{
register DIR *dirp;
register int fd;
char *myname;
myname = ((*name == '\0') ? "." : name);
if ((fd = open(myname, 0, 0)) == -1) {
return NULL;
}
dirp = (DIR *) ckalloc(sizeof(DIR));
if (dirp == NULL) {
/* unreachable? */
close(fd);
return NULL;
}
dirp->dd_fd = fd;
dirp->dd_loc = 0;
return dirp;
}
/*
@@ -44,62 +46,65 @@ char *name;
#define ODIRSIZ 14
struct olddirect {
ino_t od_ino;
char od_name[ODIRSIZ];
ino_t od_ino;
char od_name[ODIRSIZ];
};
#else /* a Pyramid in the ATT universe */
#define ODIRSIZ 248
struct olddirect {
long od_ino;
short od_fill1, od_fill2;
char od_name[ODIRSIZ];
long od_ino;
short od_fill1, od_fill2;
char od_name[ODIRSIZ];
};
#endif
/*
* get next entry in a directory.
*/
struct dirent *
readdir(dirp)
register DIR *dirp;
{
register struct olddirect *dp;
static struct dirent dir;
for (;;) {
if (dirp->dd_loc == 0) {
dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
DIRBLKSIZ);
if (dirp->dd_size <= 0)
return NULL;
}
if (dirp->dd_loc >= dirp->dd_size) {
dirp->dd_loc = 0;
continue;
}
dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
dirp->dd_loc += sizeof(struct olddirect);
if (dp->od_ino == 0)
continue;
dir.d_ino = dp->od_ino;
strncpy(dir.d_name, dp->od_name, ODIRSIZ);
dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
dir.d_namlen = strlen(dir.d_name);
dir.d_reclen = DIRSIZ(&dir);
return (&dir);
struct dirent *
readdir(
register DIR *dirp)
{
register struct olddirect *dp;
static struct dirent dir;
for (;;) {
if (dirp->dd_loc == 0) {
dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ);
if (dirp->dd_size <= 0) {
return NULL;
}
}
if (dirp->dd_loc >= dirp->dd_size) {
dirp->dd_loc = 0;
continue;
}
dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
dirp->dd_loc += sizeof(struct olddirect);
if (dp->od_ino == 0) {
continue;
}
dir.d_ino = dp->od_ino;
strncpy(dir.d_name, dp->od_name, ODIRSIZ);
dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
dir.d_namlen = strlen(dir.d_name);
dir.d_reclen = DIRSIZ(&dir);
return &dir;
}
}
/*
* close a directory.
*/
void
closedir(dirp)
register DIR *dirp;
closedir(
register DIR *dirp)
{
close(dirp->dd_fd);
dirp->dd_fd = -1;
dirp->dd_loc = 0;
ckfree((char *) dirp);
close(dirp->dd_fd);
dirp->dd_fd = -1;
dirp->dd_loc = 0;
ckfree((char *) dirp);
}
+22 -29
View File
@@ -1,43 +1,36 @@
/*
* stdlib.h --
*
* Declares facilities exported by the "stdlib" portion of
* the C library. This file isn't complete in the ANSI-C
* sense; it only declares things that are needed by Tcl.
* This file is needed even on many systems with their own
* stdlib.h (e.g. SunOS) because not all stdlib.h files
* declare all the procedures needed here (such as strtod).
* Declares facilities exported by the "stdlib" portion of the C library.
* This file isn't complete in the ANSI-C sense; it only declares things
* that are needed by Tcl. This file is needed even on many systems with
* their own stdlib.h (e.g. SunOS) because not all stdlib.h files declare
* all the procedures needed here (such as strtod).
*
* Copyright (c) 1991 The Regents of the University of California.
* Copyright (c) 1994-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _STDLIB
#define _STDLIB
#include <tcl.h>
extern void abort _ANSI_ARGS_((void));
extern double atof _ANSI_ARGS_((CONST char *string));
extern int atoi _ANSI_ARGS_((CONST char *string));
extern long atol _ANSI_ARGS_((CONST char *string));
extern char * calloc _ANSI_ARGS_((unsigned int numElements,
unsigned int size));
extern void exit _ANSI_ARGS_((int status));
extern int free _ANSI_ARGS_((char *blockPtr));
extern char * getenv _ANSI_ARGS_((CONST char *name));
extern char * malloc _ANSI_ARGS_((unsigned int numBytes));
extern void qsort _ANSI_ARGS_((VOID *base, int n, int size,
int (*compar)(CONST VOID *element1, CONST VOID
*element2)));
extern char * realloc _ANSI_ARGS_((char *ptr, unsigned int numBytes));
extern double strtod _ANSI_ARGS_((CONST char *string, char **endPtr));
extern long strtol _ANSI_ARGS_((CONST char *string, char **endPtr,
int base));
extern unsigned long strtoul _ANSI_ARGS_((CONST char *string,
char **endPtr, int base));
extern void abort(void);
extern double atof(const char *string);
extern int atoi(const char *string);
extern long atol(const char *string);
extern char * calloc(unsigned int numElements, unsigned int size);
extern void exit(int status);
extern int free(char *blockPtr);
extern char * getenv(const char *name);
extern char * malloc(unsigned int numBytes);
extern void qsort(void *base, int n, int size, int (*compar)(
const void *element1, const void *element2));
extern char * realloc(char *ptr, unsigned int numBytes);
extern double strtod(const char *string, char **endPtr);
extern long strtol(const char *string, char **endPtr, int base);
extern unsigned long strtoul(const char *string, char **endPtr, int base);
#endif /* _STDLIB */
-518
View File
@@ -1,518 +0,0 @@
/*
* strftime.c --
*
* This file contains a modified version of the BSD 4.4 strftime
* function.
*
* This file is a modified version of the strftime.c file from the BSD 4.4
* source. See the copyright notice below for details on redistribution
* restrictions. The "license.terms" file does not apply to this file.
*
* Changes 2002 Copyright (c) 2002 ActiveState Corporation.
*/
/*
* Copyright (c) 1989 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(_WIN32) && !defined(_WIN64)
# define _USE_32BIT_TIME_T
#endif
#include <time.h>
#include <string.h>
#include <locale.h>
#include "tclInt.h"
#include "tclPort.h"
#define TM_YEAR_BASE 1900
#define IsLeapYear(x) ((x % 4 == 0) && (x % 100 != 0 || x % 400 == 0))
typedef struct {
const char *abday[7];
const char *day[7];
const char *abmon[12];
const char *mon[12];
const char *am_pm[2];
const char *d_t_fmt;
const char *d_fmt;
const char *t_fmt;
const char *t_fmt_ampm;
} _TimeLocale;
/*
* This is the C locale default. On Windows, if we wanted to make this
* localized, we would use GetLocaleInfo to get the correct values.
* It may be acceptable to do localization of month/day names, as the
* numerical values would be considered the locale-independent versions.
*/
static const _TimeLocale _DefaultTimeLocale =
{
{
"Sun","Mon","Tue","Wed","Thu","Fri","Sat",
},
{
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"
},
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
},
{
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
},
{
"AM", "PM"
},
"%a %b %d %H:%M:%S %Y",
"%m/%d/%y",
"%H:%M:%S",
"%I:%M:%S %p"
};
static const _TimeLocale *_CurrentTimeLocale = &_DefaultTimeLocale;
static int isGMT;
static size_t gsize;
static char *pt;
static int _add _ANSI_ARGS_((const char* str));
static int _conv _ANSI_ARGS_((int n, int digits, int pad));
static int _secs _ANSI_ARGS_((const struct tm *t));
static size_t _fmt _ANSI_ARGS_((const char *format,
const struct tm *t));
static int ISO8601Week _ANSI_ARGS_((CONST struct tm* t, int *year ));
size_t
TclpStrftime(s, maxsize, format, t, useGMT)
char *s;
size_t maxsize;
const char *format;
const struct tm *t;
int useGMT;
{
if (format[0] == '%' && format[1] == 'Q') {
/* Format as a stardate */
sprintf(s, "Stardate %2d%03d.%01d",
(((t->tm_year + TM_YEAR_BASE) + 377) - 2323),
(((t->tm_yday + 1) * 1000) /
(365 + IsLeapYear((t->tm_year + TM_YEAR_BASE)))),
(((t->tm_hour * 60) + t->tm_min)/144));
return(strlen(s));
}
isGMT = useGMT;
/*
* We may be able to skip this for useGMT, but it should be harmless.
* -- hobbs
*/
tzset();
pt = s;
if ((gsize = maxsize) < 1)
return(0);
if (_fmt(format, t)) {
*pt = '\0';
return(maxsize - gsize);
}
return(0);
}
#define SUN_WEEK(t) (((t)->tm_yday + 7 - \
((t)->tm_wday)) / 7)
#define MON_WEEK(t) (((t)->tm_yday + 7 - \
((t)->tm_wday ? (t)->tm_wday - 1 : 6)) / 7)
static size_t
_fmt(format, t)
const char *format;
const struct tm *t;
{
#ifdef WIN32
#define BUF_SIZ 256
TCHAR buf[BUF_SIZ];
SYSTEMTIME syst = {
t->tm_year + 1900,
t->tm_mon + 1,
t->tm_wday,
t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec,
0,
};
#endif
for (; *format; ++format) {
if (*format == '%') {
++format;
if (*format == 'E') {
/* Alternate Era */
++format;
} else if (*format == 'O') {
/* Alternate numeric symbols */
++format;
}
switch(*format) {
case '\0':
--format;
break;
case 'A':
if (t->tm_wday < 0 || t->tm_wday > 6)
return(0);
if (!_add(_CurrentTimeLocale->day[t->tm_wday]))
return(0);
continue;
case 'a':
if (t->tm_wday < 0 || t->tm_wday > 6)
return(0);
if (!_add(_CurrentTimeLocale->abday[t->tm_wday]))
return(0);
continue;
case 'B':
if (t->tm_mon < 0 || t->tm_mon > 11)
return(0);
if (!_add(_CurrentTimeLocale->mon[t->tm_mon]))
return(0);
continue;
case 'b':
case 'h':
if (t->tm_mon < 0 || t->tm_mon > 11)
return(0);
if (!_add(_CurrentTimeLocale->abmon[t->tm_mon]))
return(0);
continue;
case 'C':
if (!_conv((t->tm_year + TM_YEAR_BASE) / 100,
2, '0'))
return(0);
continue;
case 'D':
if (!_fmt("%m/%d/%y", t))
return(0);
continue;
case 'd':
if (!_conv(t->tm_mday, 2, '0'))
return(0);
continue;
case 'e':
if (!_conv(t->tm_mday, 2, ' '))
return(0);
continue;
case 'g':
{
int year;
ISO8601Week( t, &year );
if ( !_conv( year%100, 2, '0' ) ) {
return( 0 );
}
continue;
}
case 'G':
{
int year;
ISO8601Week( t, &year );
if ( !_conv( year, 4, '0' ) ) {
return( 0 );
}
continue;
}
case 'H':
if (!_conv(t->tm_hour, 2, '0'))
return(0);
continue;
case 'I':
if (!_conv(t->tm_hour % 12 ?
t->tm_hour % 12 : 12, 2, '0'))
return(0);
continue;
case 'j':
if (!_conv(t->tm_yday + 1, 3, '0'))
return(0);
continue;
case 'k':
if (!_conv(t->tm_hour, 2, ' '))
return(0);
continue;
case 'l':
if (!_conv(t->tm_hour % 12 ?
t->tm_hour % 12: 12, 2, ' '))
return(0);
continue;
case 'M':
if (!_conv(t->tm_min, 2, '0'))
return(0);
continue;
case 'm':
if (!_conv(t->tm_mon + 1, 2, '0'))
return(0);
continue;
case 'n':
if (!_add("\n"))
return(0);
continue;
case 'p':
if (!_add(_CurrentTimeLocale->am_pm[t->tm_hour >= 12]))
return(0);
continue;
case 'R':
if (!_fmt("%H:%M", t))
return(0);
continue;
case 'r':
if (!_fmt(_CurrentTimeLocale->t_fmt_ampm, t))
return(0);
continue;
case 'S':
if (!_conv(t->tm_sec, 2, '0'))
return(0);
continue;
case 's':
if (!_secs(t))
return(0);
continue;
case 'T':
if (!_fmt("%H:%M:%S", t))
return(0);
continue;
case 't':
if (!_add("\t"))
return(0);
continue;
case 'U':
if (!_conv(SUN_WEEK(t), 2, '0'))
return(0);
continue;
case 'u':
if (!_conv(t->tm_wday ? t->tm_wday : 7, 1, '0'))
return(0);
continue;
case 'V':
{
int week = ISO8601Week( t, NULL );
if (!_conv(week, 2, '0'))
return(0);
continue;
}
case 'W':
if (!_conv(MON_WEEK(t), 2, '0'))
return(0);
continue;
case 'w':
if (!_conv(t->tm_wday, 1, '0'))
return(0);
continue;
#ifdef WIN32
/*
* To properly handle the localized time routines on Windows,
* we must make use of the special localized calls.
*/
case 'c':
if (!GetDateFormat(LOCALE_USER_DEFAULT,
DATE_LONGDATE | LOCALE_USE_CP_ACP,
&syst, NULL, buf, BUF_SIZ)
|| !_add(buf)
|| !_add(" ")) {
return(0);
}
/*
* %c is created with LONGDATE + " " + TIME on Windows,
* so continue to %X case here.
*/
case 'X':
if (!GetTimeFormat(LOCALE_USER_DEFAULT,
LOCALE_USE_CP_ACP,
&syst, NULL, buf, BUF_SIZ)
|| !_add(buf)) {
return(0);
}
continue;
case 'x':
if (!GetDateFormat(LOCALE_USER_DEFAULT,
DATE_SHORTDATE | LOCALE_USE_CP_ACP,
&syst, NULL, buf, BUF_SIZ)
|| !_add(buf)) {
return(0);
}
continue;
#else
case 'c':
if (!_fmt(_CurrentTimeLocale->d_t_fmt, t))
return(0);
continue;
case 'x':
if (!_fmt(_CurrentTimeLocale->d_fmt, t))
return(0);
continue;
case 'X':
if (!_fmt(_CurrentTimeLocale->t_fmt, t))
return(0);
continue;
#endif
case 'y':
if (!_conv((t->tm_year + TM_YEAR_BASE) % 100,
2, '0'))
return(0);
continue;
case 'Y':
if (!_conv((t->tm_year + TM_YEAR_BASE), 4, '0'))
return(0);
continue;
case 'Z': {
char *name = (isGMT ? "GMT" : TclpGetTZName(t->tm_isdst));
int wrote;
Tcl_UtfToExternal(NULL, NULL, name, -1, 0, NULL,
pt, gsize, NULL, &wrote, NULL);
pt += wrote;
gsize -= wrote;
continue;
}
case '%':
/*
* X311J/88-090 (4.12.3.5): if conversion char is
* undefined, behavior is undefined. Print out the
* character itself as printf(3) does.
*/
default:
break;
}
}
if (!gsize--)
return(0);
*pt++ = *format;
}
return(gsize);
}
static int
_secs(t)
const struct tm *t;
{
static char buf[15];
register time_t s;
register char *p;
struct tm tmp;
/* Make a copy, mktime(3) modifies the tm struct. */
tmp = *t;
s = mktime(&tmp);
for (p = buf + sizeof(buf) - 2; s > 0 && p > buf; s /= 10)
*p-- = (char)(s % 10 + '0');
return(_add(++p));
}
static int
_conv(n, digits, pad)
int n, digits;
int pad;
{
static char buf[10];
register char *p;
p = buf + sizeof( buf ) - 1;
*p-- = '\0';
if ( n == 0 ) {
*p-- = '0'; --digits;
} else {
for (; n > 0 && p > buf; n /= 10, --digits)
*p-- = (char)(n % 10 + '0');
}
while (p > buf && digits-- > 0)
*p-- = (char) pad;
return(_add(++p));
}
static int
_add(str)
const char *str;
{
for (;; ++pt, --gsize) {
if (!gsize)
return(0);
if (!(*pt = *str++))
return(1);
}
}
static int
ISO8601Week( t, year )
CONST struct tm* t;
int* year;
{
/* Find the day-of-year of the Thursday in
* the week in question. */
int ydayThursday;
int week;
if ( t->tm_wday == 0 ) {
ydayThursday = t->tm_yday - 3;
} else {
ydayThursday = t->tm_yday - t->tm_wday + 4;
}
if ( ydayThursday < 0 ) {
/* This is the last week of the previous year. */
if ( IsLeapYear(( t->tm_year + TM_YEAR_BASE - 1 )) ) {
ydayThursday += 366;
} else {
ydayThursday += 365;
}
week = ydayThursday / 7 + 1;
if ( year != NULL ) {
*year = t->tm_year + 1899;
}
} else if ( ( IsLeapYear(( t -> tm_year + TM_YEAR_BASE ))
&& ydayThursday >= 366 )
|| ( !IsLeapYear(( t -> tm_year
+ TM_YEAR_BASE ))
&& ydayThursday >= 365 ) ) {
/* This is week 1 of the following year */
week = 1;
if ( year != NULL ) {
*year = t->tm_year + 1901;
}
} else {
week = ydayThursday / 7 + 1;
if ( year != NULL ) {
*year = t->tm_year + 1900;
}
}
return week;
}
+30 -44
View File
@@ -6,66 +6,52 @@
* Copyright (c) 1991-1993 The Regents of the University of California.
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _STRING
#define _STRING
#include <tcl.h>
/*
* The following #include is needed to define size_t. (This used to
* include sys/stdtypes.h but that doesn't exist on older versions
* of SunOS, e.g. 4.0.2, so I'm trying sys/types.h now.... hopefully
* it exists everywhere)
* The following #include is needed to define size_t. (This used to include
* sys/stdtypes.h but that doesn't exist on older versions of SunOS, e.g.
* 4.0.2, so I'm trying sys/types.h now.... hopefully it exists everywhere)
*/
#include <sys/types.h>
#ifdef __APPLE__
extern VOID * memchr _ANSI_ARGS_((CONST VOID *s, int c, size_t n));
extern void * memchr(const void *s, int c, size_t n);
#else
extern char * memchr _ANSI_ARGS_((CONST VOID *s, int c, size_t n));
extern char * memchr(const void *s, int c, size_t n);
#endif
extern int memcmp _ANSI_ARGS_((CONST VOID *s1, CONST VOID *s2,
size_t n));
extern char * memcpy _ANSI_ARGS_((VOID *t, CONST VOID *f, size_t n));
extern int memcmp(const void *s1, const void *s2, size_t n);
extern char * memcpy(void *t, const void *f, size_t n);
#ifdef NO_MEMMOVE
#define memmove(d, s, n) bcopy ((s), (d), (n))
#define memmove(d,s,n) (bcopy((s), (d), (n)))
#else
extern char * memmove _ANSI_ARGS_((VOID *t, CONST VOID *f,
size_t n));
extern char * memmove(void *t, const void *f, size_t n);
#endif
extern char * memset _ANSI_ARGS_((VOID *s, int c, size_t n));
extern char * memset(void *s, int c, size_t n);
extern int strcasecmp _ANSI_ARGS_((CONST char *s1,
CONST char *s2));
extern char * strcat _ANSI_ARGS_((char *dst, CONST char *src));
extern char * strchr _ANSI_ARGS_((CONST char *string, int c));
extern int strcmp _ANSI_ARGS_((CONST char *s1, CONST char *s2));
extern char * strcpy _ANSI_ARGS_((char *dst, CONST char *src));
extern size_t strcspn _ANSI_ARGS_((CONST char *string,
CONST char *chars));
extern char * strdup _ANSI_ARGS_((CONST char *string));
extern char * strerror _ANSI_ARGS_((int error));
extern size_t strlen _ANSI_ARGS_((CONST char *string));
extern int strncasecmp _ANSI_ARGS_((CONST char *s1,
CONST char *s2, size_t n));
extern char * strncat _ANSI_ARGS_((char *dst, CONST char *src,
size_t numChars));
extern int strncmp _ANSI_ARGS_((CONST char *s1, CONST char *s2,
size_t nChars));
extern char * strncpy _ANSI_ARGS_((char *dst, CONST char *src,
size_t numChars));
extern char * strpbrk _ANSI_ARGS_((CONST char *string,
CONST char *chars));
extern char * strrchr _ANSI_ARGS_((CONST char *string, int c));
extern size_t strspn _ANSI_ARGS_((CONST char *string,
CONST char *chars));
extern char * strstr _ANSI_ARGS_((CONST char *string,
CONST char *substring));
extern char * strtok _ANSI_ARGS_((char *s, CONST char *delim));
extern int strcasecmp(const char *s1, const char *s2);
extern char * strcat(char *dst, const char *src);
extern char * strchr(const char *string, int c);
extern int strcmp(const char *s1, const char *s2);
extern char * strcpy(char *dst, const char *src);
extern size_t strcspn(const char *string, const char *chars);
extern char * strdup(const char *string);
extern char * strerror(int error);
extern size_t strlen(const char *string);
extern int strncasecmp(const char *s1, const char *s2, size_t n);
extern char * strncat(char *dst, const char *src, size_t numChars);
extern int strncmp(const char *s1, const char *s2, size_t nChars);
extern char * strncpy(char *dst, const char *src, size_t numChars);
extern char * strpbrk(const char *string, const char *chars);
extern char * strrchr(const char *string, int c);
extern size_t strspn(const char *string, const char *chars);
extern char * strstr(const char *string, const char *substring);
extern char * strtok(char *s, const char *delim);
#endif /* _STRING */
+20 -24
View File
@@ -6,16 +6,16 @@
* Copyright (c) 1988-1993 The Regents of the University of California.
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tclPort.h"
/*
* This array is designed for mapping upper and lower case letter
* together for a case independent comparison. The mappings are
* based upon ASCII character sequences.
* This array is designed for mapping upper and lower case letter together for
* a case independent comparison. The mappings are based upon ASCII character
* sequences.
*/
static unsigned char charmap[] = {
@@ -54,14 +54,11 @@ static unsigned char charmap[] = {
};
/*
* Here are the prototypes just in case they are not included
* in tclPort.h.
* Here are the prototypes just in case they are not included in tclPort.h.
*/
int strncasecmp _ANSI_ARGS_((CONST char *s1,
CONST char *s2, size_t n));
int strcasecmp _ANSI_ARGS_((CONST char *s1,
CONST char *s2));
int strncasecmp(CONST char *s1, CONST char *s2, size_t n);
int strcasecmp(CONST char *s1, CONST char *s2);
/*
*----------------------------------------------------------------------
@@ -71,9 +68,8 @@ int strcasecmp _ANSI_ARGS_((CONST char *s1,
* Compares two strings, ignoring case differences.
*
* Results:
* Compares two null-terminated strings s1 and s2, returning -1, 0,
* or 1 if s1 is lexicographically less than, equal to, or greater
* than s2.
* Compares two null-terminated strings s1 and s2, returning -1, 0, or 1
* if s1 is lexicographically less than, equal to, or greater than s2.
*
* Side effects:
* None.
@@ -82,9 +78,9 @@ int strcasecmp _ANSI_ARGS_((CONST char *s1,
*/
int
strcasecmp(s1, s2)
CONST char *s1; /* First string. */
CONST char *s2; /* Second string. */
strcasecmp(
CONST char *s1, /* First string. */
CONST char *s2) /* Second string. */
{
unsigned char u1, u2;
@@ -106,9 +102,9 @@ strcasecmp(s1, s2)
* Compares two strings, ignoring case differences.
*
* Results:
* Compares up to length chars of s1 and s2, returning -1, 0, or 1
* if s1 is lexicographically less than, equal to, or greater
* than s2 over those characters.
* Compares up to length chars of s1 and s2, returning -1, 0, or 1 if s1
* is lexicographically less than, equal to, or greater than s2 over
* those characters.
*
* Side effects:
* None.
@@ -117,10 +113,10 @@ strcasecmp(s1, s2)
*/
int
strncasecmp(s1, s2, length)
CONST char *s1; /* First string. */
CONST char *s2; /* Second string. */
size_t length; /* Maximum number of characters to compare
strncasecmp(
CONST char *s1, /* First string. */
CONST char *s2, /* Second string. */
size_t length) /* Maximum number of characters to compare
* (stop earlier if the end of either string
* is reached). */
{
+14 -15
View File
@@ -6,11 +6,11 @@
* Copyright (c) 1988-1993 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include <tcl.h>
#include "tcl.h"
#ifndef NULL
#define NULL 0
#endif
@@ -23,12 +23,10 @@
* Locate the first instance of a substring in a string.
*
* Results:
* If string contains substring, the return value is the
* location of the first matching instance of substring
* in string. If string doesn't contain substring, the
* return value is 0. Matching is done on an exact
* character-for-character basis with no wildcards or special
* characters.
* If string contains substring, the return value is the location of the
* first matching instance of substring in string. If string doesn't
* contain substring, the return value is 0. Matching is done on an exact
* character-for-character basis with no wildcards or special characters.
*
* Side effects:
* None.
@@ -37,15 +35,16 @@
*/
char *
strstr(string, substring)
register char *string; /* String to search. */
char *substring; /* Substring to try to find in string. */
strstr(
register char *string, /* String to search. */
char *substring) /* Substring to try to find in string. */
{
register char *a, *b;
/* First scan quickly through the two strings looking for a
* single-character match. When it's found, then compare the
* rest of the substring.
/*
* First scan quickly through the two strings looking for a
* single-character match. When it's found, then compare the rest of the
* substring.
*/
b = substring;
+29 -33
View File
@@ -11,7 +11,6 @@
*/
#include "tclInt.h"
#include "tclPort.h"
#include <ctype.h>
#ifndef TRUE
@@ -61,20 +60,19 @@ static double powersOf10[] = { /* Table giving binary powers of 10. Entry */
*/
double
strtod(string, endPtr)
CONST char *string; /* A decimal ASCII floating-point number,
* optionally preceded by white space.
* Must have form "-I.FE-X", where I is the
* integer part of the mantissa, F is the
* fractional part of the mantissa, and X
* is the exponent. Either of the signs
* may be "+", "-", or omitted. Either I
* or F may be omitted, or both. The decimal
* point isn't necessary unless F is present.
* The "E" may actually be an "e". E and X
* may both be omitted (but not just one).
*/
char **endPtr; /* If non-NULL, store terminating character's
strtod(
CONST char *string, /* A decimal ASCII floating-point number,
* optionally preceded by white space. Must
* have form "-I.FE-X", where I is the integer
* part of the mantissa, F is the fractional
* part of the mantissa, and X is the
* exponent. Either of the signs may be "+",
* "-", or omitted. Either I or F may be
* omitted, or both. The decimal point isn't
* necessary unless F is present. The "E" may
* actually be an "e". E and X may both be
* omitted (but not just one). */
char **endPtr) /* If non-NULL, store terminating character's
* address here. */
{
int sign, expSign = FALSE;
@@ -83,19 +81,19 @@ strtod(string, endPtr)
register int c;
int exp = 0; /* Exponent read from "EX" field. */
int fracExp = 0; /* Exponent that derives from the fractional
* part. Under normal circumstatnces, it is
* part. Under normal circumstatnces, it is
* the negative of the number of digits in F.
* However, if I is very long, the last digits
* of I get dropped (otherwise a long I with a
* large negative exponent could cause an
* unnecessary overflow on I alone). In this
* unnecessary overflow on I alone). In this
* case, fracExp is incremented one for each
* dropped digit. */
int mantSize; /* Number of digits in mantissa. */
int decPt; /* Number of mantissa digits BEFORE decimal
* point. */
CONST char *pExp; /* Temporarily holds location of exponent
* in string. */
CONST char *pExp; /* Temporarily holds location of exponent in
* string. */
/*
* Strip off leading blanks and check for a sign.
@@ -134,10 +132,10 @@ strtod(string, endPtr)
}
/*
* Now suck up the digits in the mantissa. Use two integers to
* collect 9 digits each (this is faster than using floating-point).
* If the mantissa has more than 18 digits, ignore the extras, since
* they can't affect the value anyway.
* Now suck up the digits in the mantissa. Use two integers to collect 9
* digits each (this is faster than using floating-point). If the mantissa
* has more than 18 digits, ignore the extras, since they can't affect the
* value anyway.
*/
pExp = p;
@@ -145,7 +143,7 @@ strtod(string, endPtr)
if (decPt < 0) {
decPt = mantSize;
} else {
mantSize -= 1; /* One of the digits was the point. */
mantSize -= 1; /* One of the digits was the point. */
}
if (mantSize > 18) {
fracExp = decPt - 18;
@@ -159,9 +157,9 @@ strtod(string, endPtr)
goto done;
} else {
int frac1, frac2;
frac1 = 0;
for ( ; mantSize > 9; mantSize -= 1)
{
for ( ; mantSize > 9; mantSize -= 1) {
c = *p;
p += 1;
if (c == '.') {
@@ -171,8 +169,7 @@ strtod(string, endPtr)
frac1 = 10*frac1 + (c - '0');
}
frac2 = 0;
for (; mantSize > 0; mantSize -= 1)
{
for (; mantSize > 0; mantSize -= 1) {
c = *p;
p += 1;
if (c == '.') {
@@ -216,10 +213,9 @@ strtod(string, endPtr)
}
/*
* Generate a floating-point number that represents the exponent.
* Do this by processing the exponent one bit at a time to combine
* many powers of 2 of 10. Then combine the exponent with the
* fraction.
* Generate a floating-point number that represents the exponent. Do this
* by processing the exponent one bit at a time to combine many powers of
* 2 of 10. Then combine the exponent with the fraction.
*/
if (exp < 0) {
@@ -244,7 +240,7 @@ strtod(string, endPtr)
fraction *= dblExp;
}
done:
done:
if (endPtr != NULL) {
*endPtr = (char *) p;
}
+17 -22
View File
@@ -6,14 +6,12 @@
* Copyright (c) 1988 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include <ctype.h>
#include "tclInt.h"
#include "tclPort.h"
/*
*----------------------------------------------------------------------
@@ -23,11 +21,10 @@
* Convert an ASCII string into an integer.
*
* Results:
* The return value is the integer equivalent of string. If endPtr
* is non-NULL, then *endPtr is filled in with the character
* after the last one that was part of the integer. If string
* doesn't contain a valid integer value, then zero is returned
* and *endPtr is set to string.
* The return value is the integer equivalent of string. If endPtr is
* non-NULL, then *endPtr is filled in with the character after the last
* one that was part of the integer. If string doesn't contain a valid
* integer value, then zero is returned and *endPtr is set to string.
*
* Side effects:
* None.
@@ -36,20 +33,18 @@
*/
long int
strtol(string, endPtr, base)
CONST char *string; /* String of ASCII digits, possibly
* preceded by white space. For bases
* greater than 10, either lower- or
* upper-case digits may be used.
*/
char **endPtr; /* Where to store address of terminating
strtol(
CONST char *string, /* String of ASCII digits, possibly preceded
* by white space. For bases greater than 10,
* either lower- or upper-case digits may be
* used. */
char **endPtr, /* Where to store address of terminating
* character, or NULL. */
int base; /* Base for conversion. Must be less
* than 37. If 0, then the base is chosen
* from the leading characters of string:
* "0x" means hex, "0" means octal, anything
* else means decimal.
*/
int base) /* Base for conversion. Must be less than 37.
* If 0, then the base is chosen from the
* leading characters of string: "0x" means
* hex, "0" means octal, anything else means
* decimal. */
{
register CONST char *p;
long result;
-109
View File
@@ -1,109 +0,0 @@
/*
* strtoll.c --
*
* Source code for the "strtoll" library procedure.
*
* Copyright (c) 1988 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tcl.h"
#include "tclPort.h"
#include <ctype.h>
#define TCL_WIDEINT_MAX (((Tcl_WideUInt)Tcl_LongAsWide(-1))>>1)
/*
*----------------------------------------------------------------------
*
* strtoll --
*
* Convert an ASCII string into an integer.
*
* Results:
* The return value is the integer equivalent of string. If endPtr
* is non-NULL, then *endPtr is filled in with the character
* after the last one that was part of the integer. If string
* doesn't contain a valid integer value, then zero is returned
* and *endPtr is set to string.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
#if TCL_WIDE_INT_IS_LONG
long long
#else
Tcl_WideInt
#endif
strtoll(string, endPtr, base)
CONST char *string; /* String of ASCII digits, possibly
* preceded by white space. For bases
* greater than 10, either lower- or
* upper-case digits may be used.
*/
char **endPtr; /* Where to store address of terminating
* character, or NULL. */
int base; /* Base for conversion. Must be less
* than 37. If 0, then the base is chosen
* from the leading characters of string:
* "0x" means hex, "0" means octal, anything
* else means decimal.
*/
{
register CONST char *p;
Tcl_WideInt result = Tcl_LongAsWide(0);
Tcl_WideUInt uwResult;
/*
* Skip any leading blanks.
*/
p = string;
while (isspace(UCHAR(*p))) {
p += 1;
}
/*
* Check for a sign.
*/
errno = 0;
if (*p == '-') {
p += 1;
uwResult = strtoull(p, endPtr, base);
if (errno != ERANGE) {
if (uwResult > TCL_WIDEINT_MAX+1) {
errno = ERANGE;
return Tcl_LongAsWide(-1);
} else if (uwResult > TCL_WIDEINT_MAX) {
return ~((Tcl_WideInt)TCL_WIDEINT_MAX);
} else {
result = -((Tcl_WideInt) uwResult);
}
}
} else {
if (*p == '+') {
p += 1;
}
uwResult = strtoull(p, endPtr, base);
if (errno != ERANGE) {
if (uwResult > TCL_WIDEINT_MAX) {
errno = ERANGE;
return Tcl_LongAsWide(-1);
} else {
result = uwResult;
}
}
}
if ((result == 0) && (endPtr != 0) && (*endPtr == p)) {
*endPtr = (char *) string;
}
return result;
}
+34 -36
View File
@@ -6,17 +6,16 @@
* Copyright (c) 1988 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tclInt.h"
#include "tclPort.h"
/*
* The table below is used to convert from ASCII digits to a
* numerical equivalent. It maps from '0' through 'z' to integers
* (100 for non-digit characters).
* The table below is used to convert from ASCII digits to a numerical
* equivalent. It maps from '0' through 'z' to integers (100 for non-digit
* characters).
*/
static char cvtIn[] = {
@@ -38,11 +37,10 @@ static char cvtIn[] = {
* Convert an ASCII string into an integer.
*
* Results:
* The return value is the integer equivalent of string. If endPtr
* is non-NULL, then *endPtr is filled in with the character
* after the last one that was part of the integer. If string
* doesn't contain a valid integer value, then zero is returned
* and *endPtr is set to string.
* The return value is the integer equivalent of string. If endPtr is
* non-NULL, then *endPtr is filled in with the character after the last
* one that was part of the integer. If string doesn't contain a valid
* integer value, then zero is returned and *endPtr is set to string.
*
* Side effects:
* None.
@@ -51,20 +49,18 @@ static char cvtIn[] = {
*/
unsigned long int
strtoul(string, endPtr, base)
CONST char *string; /* String of ASCII digits, possibly
* preceded by white space. For bases
* greater than 10, either lower- or
* upper-case digits may be used.
*/
char **endPtr; /* Where to store address of terminating
strtoul(
CONST char *string, /* String of ASCII digits, possibly preceded
* by white space. For bases greater than 10,
* either lower- or upper-case digits may be
* used. */
char **endPtr, /* Where to store address of terminating
* character, or NULL. */
int base; /* Base for conversion. Must be less
* than 37. If 0, then the base is chosen
* from the leading characters of string:
* "0x" means hex, "0" means octal, anything
* else means decimal.
*/
int base) /* Base for conversion. Must be less than 37.
* If 0, then the base is chosen from the
* leading characters of string: "0x" means
* hex, "0" means octal, anything else means
* decimal. */
{
register CONST char *p;
register unsigned long int result = 0;
@@ -91,31 +87,29 @@ strtoul(string, endPtr, base)
}
/*
* If no base was provided, pick one from the leading characters
* of the string.
* If no base was provided, pick one from the leading characters of the
* string.
*/
if (base == 0)
{
if (base == 0) {
if (*p == '0') {
p += 1;
if ((*p == 'x') || (*p == 'X')) {
p += 1;
base = 16;
} else {
/*
* Must set anyDigits here, otherwise "0" produces a
* "no digits" error.
* Must set anyDigits here, otherwise "0" produces a "no
* digits" error.
*/
anyDigits = 1;
base = 8;
}
} else {
base = 10;
}
else base = 10;
} else if (base == 16) {
/*
* Skip a leading "0x" from hex numbers.
*/
@@ -126,12 +120,13 @@ strtoul(string, endPtr, base)
}
/*
* Sorry this code is so messy, but speed seems important. Do
* different things for base 8, 10, 16, and other.
* Sorry this code is so messy, but speed seems important. Do different
* things for base 8, 10, 16, and other.
*/
if (base == 8) {
unsigned long maxres = ULONG_MAX >> 3;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > 7) {
@@ -145,6 +140,7 @@ strtoul(string, endPtr, base)
}
} else if (base == 10) {
unsigned long maxres = ULONG_MAX / 10;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > 9) {
@@ -158,6 +154,7 @@ strtoul(string, endPtr, base)
}
} else if (base == 16) {
unsigned long maxres = ULONG_MAX >> 4;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
@@ -173,8 +170,9 @@ strtoul(string, endPtr, base)
result += digit;
anyDigits = 1;
}
} else if ( base >= 2 && base <= 36 ) {
} else if (base >= 2 && base <= 36) {
unsigned long maxres = ULONG_MAX / base;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
-259
View File
@@ -1,259 +0,0 @@
/*
* strtoull.c --
*
* Source code for the "strtoull" library procedure.
*
* Copyright (c) 1988 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tcl.h"
#include "tclPort.h"
#include <ctype.h>
/*
* The table below is used to convert from ASCII digits to a
* numerical equivalent. It maps from '0' through 'z' to integers
* (100 for non-digit characters).
*/
static char cvtIn[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* '0' - '9' */
100, 100, 100, 100, 100, 100, 100, /* punctuation */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 'A' - 'Z' */
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35,
100, 100, 100, 100, 100, 100, /* punctuation */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 'a' - 'z' */
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35};
/*
*----------------------------------------------------------------------
*
* strtoull --
*
* Convert an ASCII string into an integer.
*
* Results:
* The return value is the integer equivalent of string. If endPtr
* is non-NULL, then *endPtr is filled in with the character
* after the last one that was part of the integer. If string
* doesn't contain a valid integer value, then zero is returned
* and *endPtr is set to string.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
#if TCL_WIDE_INT_IS_LONG
unsigned long long
#else
Tcl_WideUInt
#endif
strtoull(string, endPtr, base)
CONST char *string; /* String of ASCII digits, possibly
* preceded by white space. For bases
* greater than 10, either lower- or
* upper-case digits may be used.
*/
char **endPtr; /* Where to store address of terminating
* character, or NULL. */
int base; /* Base for conversion. Must be less
* than 37. If 0, then the base is chosen
* from the leading characters of string:
* "0x" means hex, "0" means octal, anything
* else means decimal.
*/
{
register CONST char *p;
register Tcl_WideUInt result = 0;
register unsigned digit;
register Tcl_WideUInt shifted;
int anyDigits = 0, negative = 0;
/*
* Skip any leading blanks.
*/
p = string;
while (isspace(UCHAR(*p))) { /* INTL: locale-dependent */
p += 1;
}
/*
* Check for a sign.
*/
if (*p == '-') {
p += 1;
negative = 1;
} else {
if (*p == '+') {
p += 1;
}
}
/*
* If no base was provided, pick one from the leading characters
* of the string.
*/
if (base == 0) {
if (*p == '0') {
p += 1;
if (*p == 'x' || *p == 'X') {
p += 1;
base = 16;
} else {
/*
* Must set anyDigits here, otherwise "0" produces a
* "no digits" error.
*/
anyDigits = 1;
base = 8;
}
} else {
base = 10;
}
} else if (base == 16) {
/*
* Skip a leading "0x" from hex numbers.
*/
if ((p[0] == '0') && (p[1] == 'x' || *p == 'X')) {
p += 2;
}
}
/*
* Sorry this code is so messy, but speed seems important. Do
* different things for base 8, 10, 16, and other.
*/
if (base == 8) {
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > 7) {
break;
}
shifted = result << 3;
if ((shifted >> 3) != result) {
goto overflow;
}
result = shifted + digit;
if ( result < shifted ) {
goto overflow;
}
anyDigits = 1;
}
} else if (base == 10) {
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > 9) {
break;
}
shifted = 10 * result;
if ((shifted / 10) != result) {
goto overflow;
}
result = shifted + digit;
if ( result < shifted ) {
goto overflow;
}
anyDigits = 1;
}
} else if (base == 16) {
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
break;
}
digit = cvtIn[digit];
if (digit > 15) {
break;
}
shifted = result << 4;
if ((shifted >> 4) != result) {
goto overflow;
}
result = shifted + digit;
if ( result < shifted ) {
goto overflow;
}
anyDigits = 1;
}
} else if ( base >= 2 && base <= 36 ) {
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
break;
}
digit = cvtIn[digit];
if (digit >= (unsigned) base) {
break;
}
shifted = result * base;
if ((shifted/base) != result) {
goto overflow;
}
result = shifted + digit;
if ( result < shifted ) {
goto overflow;
}
anyDigits = 1;
}
}
/*
* Negate if we found a '-' earlier.
*/
if (negative) {
result = (Tcl_WideUInt)(-((Tcl_WideInt)result));
}
/*
* See if there were any digits at all.
*/
if (!anyDigits) {
p = string;
}
if (endPtr != 0) {
*endPtr = (char *) p;
}
return result;
/*
* On overflow generate the right output
*/
overflow:
errno = ERANGE;
if (endPtr != 0) {
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
break;
}
digit = cvtIn[digit];
if (digit >= (unsigned) base) {
break;
}
}
*endPtr = (char *) p;
}
return (Tcl_WideUInt)Tcl_LongAsWide(-1);
}
-97
View File
@@ -1,97 +0,0 @@
/*
* tclErrno.h --
*
* This header file contains the various POSIX errno definitions that
* are used by Tcl. This file is derived from the spec POSIX 2.4 and
* previous implementations for Berkeley UNIX.
*
* Copyright (c) 1982, 1986, 1989 Regents of the University of California.
* Copyright (c) 1996 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
extern int errno; /* global error number */
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* Input/output error */
#define ENXIO 6 /* Device not configured */
#define E2BIG 7 /* Argument list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file descriptor */
#define ECHILD 10 /* No child processes */
#define EDEADLK 11 /* Resource deadlock avoided */
/* 11 was EAGAIN */
#define ENOMEM 12 /* Cannot allocate memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Device busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* Operation not supported by device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* Too many open files in system */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Inappropriate ioctl for device */
#define ETXTBSY 26 /* Text file busy */
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
#define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
#define EDOM 33 /* Numerical argument out of domain */
#define ERANGE 34 /* Result too large */
#define EAGAIN 35 /* Resource temporarily unavailable */
#define EWOULDBLOCK EAGAIN /* Operation would block */
#define EINPROGRESS 36 /* Operation now in progress */
#define EALREADY 37 /* Operation already in progress */
#define ENOTSOCK 38 /* Socket operation on non-socket */
#define EDESTADDRREQ 39 /* Destination address required */
#define EMSGSIZE 40 /* Message too long */
#define EPROTOTYPE 41 /* Protocol wrong type for socket */
#define ENOPROTOOPT 42 /* Protocol not available */
#define EPROTONOSUPPORT 43 /* Protocol not supported */
#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
#define EOPNOTSUPP 45 /* Operation not supported on socket */
#define EPFNOSUPPORT 46 /* Protocol family not supported */
#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
#define EADDRINUSE 48 /* Address already in use */
#define EADDRNOTAVAIL 49 /* Can't assign requested address */
#define ENETDOWN 50 /* Network is down */
#define ENETUNREACH 51 /* Network is unreachable */
#define ENETRESET 52 /* Network dropped connection on reset */
#define ECONNABORTED 53 /* Software caused connection abort */
#define ECONNRESET 54 /* Connection reset by peer */
#define ENOBUFS 55 /* No buffer space available */
#define EISCONN 56 /* Socket is already connected */
#define ENOTCONN 57 /* Socket is not connected */
#define ESHUTDOWN 58 /* Can't send after socket shutdown */
#define ETOOMANYREFS 59 /* Too many references: can't splice */
#define ETIMEDOUT 60 /* Connection timed out */
#define ECONNREFUSED 61 /* Connection refused */
#define ELOOP 62 /* Too many levels of symbolic links */
#define ENAMETOOLONG 63 /* File name too long */
#define EHOSTDOWN 64 /* Host is down */
#define EHOSTUNREACH 65 /* No route to host */
#define ENOTEMPTY 66 /* Directory not empty */
#define EPROCLIM 67 /* Too many processes */
#define EUSERS 68 /* Too many users */
#define EDQUOT 69 /* Disc quota exceeded */
#define ESTALE 70 /* Stale NFS file handle */
#define EREMOTE 71 /* Too many levels of remote in path */
#define EBADRPC 72 /* RPC struct is bad */
#define ERPCMISMATCH 73 /* RPC version wrong */
#define EPROGUNAVAIL 74 /* RPC prog. not avail */
#define EPROGMISMATCH 75 /* Program version wrong */
#define EPROCUNAVAIL 76 /* Bad procedure for program */
#define ENOLCK 77 /* No locks available */
#define ENOSYS 78 /* Function not implemented */
#define EOVERFLOW 79 /* Value too large to be stored in data type */
-40
View File
@@ -1,40 +0,0 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific written prior permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <stdio.h>
/*
* Use /tmp instead of /usr/tmp, because L_tmpname is only 14 chars
* on some machines (like NeXT machines) and /usr/tmp will cause
* buffer overflows.
*/
#ifdef P_tmpdir
# undef P_tmpdir
#endif
#define P_tmpdir "/tmp"
char *
tmpnam(s)
char *s;
{
static char name[50];
char *mktemp();
if (!s)
s = name;
(void)sprintf(s, "%s/XXXXXX", P_tmpdir);
return(mktemp(s));
}
+53 -59
View File
@@ -1,82 +1,76 @@
/*
* unistd.h --
*
* Macros, CONSTants and prototypes for Posix conformance.
* Macros, constants and prototypes for Posix conformance.
*
* Copyright 1989 Regents of the University of California
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. The University of California
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
* Copyright 1989 Regents of the University of California Permission to use,
* copy, modify, and distribute this software and its documentation for any
* purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies. The University of California makes
* no representations about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*/
#ifndef _UNISTD
#define _UNISTD
#include <sys/types.h>
#ifndef _TCL
# include "tcl.h"
#endif
#ifndef NULL
#define NULL 0
#endif
/*
* Strict POSIX stuff goes here. Extensions go down below, in the
* ifndef _POSIX_SOURCE section.
* Strict POSIX stuff goes here. Extensions go down below, in the ifndef
* _POSIX_SOURCE section.
*/
extern void _exit _ANSI_ARGS_((int status));
extern int access _ANSI_ARGS_((CONST char *path, int mode));
extern int chdir _ANSI_ARGS_((CONST char *path));
extern int chown _ANSI_ARGS_((CONST char *path, uid_t owner, gid_t group));
extern int close _ANSI_ARGS_((int fd));
extern int dup _ANSI_ARGS_((int oldfd));
extern int dup2 _ANSI_ARGS_((int oldfd, int newfd));
extern int execl _ANSI_ARGS_((CONST char *path, ...));
extern int execle _ANSI_ARGS_((CONST char *path, ...));
extern int execlp _ANSI_ARGS_((CONST char *file, ...));
extern int execv _ANSI_ARGS_((CONST char *path, char **argv));
extern int execve _ANSI_ARGS_((CONST char *path, char **argv, char **envp));
extern int execvp _ANSI_ARGS_((CONST char *file, char **argv));
extern pid_t fork _ANSI_ARGS_((void));
extern char *getcwd _ANSI_ARGS_((char *buf, size_t size));
extern gid_t getegid _ANSI_ARGS_((void));
extern uid_t geteuid _ANSI_ARGS_((void));
extern gid_t getgid _ANSI_ARGS_((void));
extern int getgroups _ANSI_ARGS_((int bufSize, int *buffer));
extern pid_t getpid _ANSI_ARGS_((void));
extern uid_t getuid _ANSI_ARGS_((void));
extern int isatty _ANSI_ARGS_((int fd));
extern long lseek _ANSI_ARGS_((int fd, long offset, int whence));
extern int pipe _ANSI_ARGS_((int *fildes));
extern int read _ANSI_ARGS_((int fd, char *buf, size_t size));
extern int setgid _ANSI_ARGS_((gid_t group));
extern int setuid _ANSI_ARGS_((uid_t user));
extern unsigned sleep _ANSI_ARGS_ ((unsigned seconds));
extern char *ttyname _ANSI_ARGS_((int fd));
extern int unlink _ANSI_ARGS_((CONST char *path));
extern int write _ANSI_ARGS_((int fd, CONST char *buf, size_t size));
extern void _exit(int status);
extern int access(const char *path, int mode);
extern int chdir(const char *path);
extern int chown(const char *path, uid_t owner, gid_t group);
extern int close(int fd);
extern int dup(int oldfd);
extern int dup2(int oldfd, int newfd);
extern int execl(const char *path, ...);
extern int execle(const char *path, ...);
extern int execlp(const char *file, ...);
extern int execv(const char *path, char **argv);
extern int execve(const char *path, char **argv, char **envp);
extern int execvpw(const char *file, char **argv);
extern pid_t fork(void);
extern char * getcwd(char *buf, size_t size);
extern gid_t getegid(void);
extern uid_t geteuid(void);
extern gid_t getgid(void);
extern int getgroups(int bufSize, int *buffer);
extern pid_t getpid(void);
extern uid_t getuid(void);
extern int isatty(int fd);
extern long lseek(int fd, long offset, int whence);
extern int pipe(int *fildes);
extern int read(int fd, char *buf, size_t size);
extern int setgid(gid_t group);
extern int setuid(uid_t user);
extern unsigned sleep(unsigned seconds);
extern char * ttyname(int fd);
extern int unlink(const char *path);
extern int write(int fd, const char *buf, size_t size);
#ifndef _POSIX_SOURCE
extern char *crypt _ANSI_ARGS_((CONST char *, CONST char *));
extern int fchown _ANSI_ARGS_((int fd, uid_t owner, gid_t group));
extern int flock _ANSI_ARGS_((int fd, int operation));
extern int ftruncate _ANSI_ARGS_((int fd, unsigned long length));
extern int ioctl _ANSI_ARGS_((int fd, int request, ...));
extern int readlink _ANSI_ARGS_((CONST char *path, char *buf, int bufsize));
extern int setegid _ANSI_ARGS_((gid_t group));
extern int seteuid _ANSI_ARGS_((uid_t user));
extern int setreuid _ANSI_ARGS_((int ruid, int euid));
extern int symlink _ANSI_ARGS_((CONST char *, CONST char *));
extern int ttyslot _ANSI_ARGS_((void));
extern int truncate _ANSI_ARGS_((CONST char *path, unsigned long length));
extern int vfork _ANSI_ARGS_((void));
extern char * crypt(const char *, const char *);
extern int fchown(int fd, uid_t owner, gid_t group);
extern int flock(int fd, int operation);
extern int ftruncate(int fd, unsigned long length);
extern int ioctl(int fd, int request, ...);
extern int readlink(const char *path, char *buf, int bufsize);
extern int setegid(gid_t group);
extern int seteuidw(uid_t user);
extern int setreuid(int ruid, int euid);
extern int symlink(const char *, const char *);
extern int ttyslot(void);
extern int truncate(const char *path, unsigned long length);
extern int vfork(void);
#endif /* _POSIX_SOURCE */
#endif /* _UNISTD */
+44 -48
View File
@@ -1,19 +1,17 @@
/*
* waitpid.c --
*
* This procedure emulates the POSIX waitpid kernel call on
* BSD systems that don't have waitpid but do have wait3.
* This code is based on a prototype version written by
* Mark Diekhans and Karl Lehenbauer.
* This procedure emulates the POSIX waitpid kernel call on BSD systems
* that don't have waitpid but do have wait3. This code is based on a
* prototype version written by Mark Diekhans and Karl Lehenbauer.
*
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tclInt.h"
#include "tclPort.h"
#ifndef pid_t
@@ -21,40 +19,37 @@
#endif
/*
* A linked list of the following structures is used to keep track
* of processes for which we received notification from the kernel,
* but the application hasn't waited for them yet (this can happen
* because wait may not return the process we really want). We
* save the information here until the application finally does
* wait for the process.
* A linked list of the following structures is used to keep track of
* processes for which we received notification from the kernel, but the
* application hasn't waited for them yet (this can happen because wait may
* not return the process we really want). We save the information here until
* the application finally does wait for the process.
*/
typedef struct WaitInfo {
pid_t pid; /* Pid of process that exited. */
WAIT_STATUS_TYPE status; /* Status returned when child exited
* or suspended. */
struct WaitInfo *nextPtr; /* Next in list of exited processes. */
pid_t pid; /* Pid of process that exited. */
WAIT_STATUS_TYPE status; /* Status returned when child exited or
* suspended. */
struct WaitInfo *nextPtr; /* Next in list of exited processes. */
} WaitInfo;
static WaitInfo *deadList = NULL; /* First in list of all dead
* processes. */
static WaitInfo *deadList = NULL;
/* First in list of all dead processes. */
/*
*----------------------------------------------------------------------
*
* waitpid --
*
* This procedure emulates the functionality of the POSIX
* waitpid kernel call, using the BSD wait3 kernel call.
* Note: it doesn't emulate absolutely all of the waitpid
* functionality, in that it doesn't support pid's of 0
* or < -1.
* This procedure emulates the functionality of the POSIX waitpid kernel
* call, using the BSD wait3 kernel call. Note: it doesn't emulate
* absolutely all of the waitpid functionality, in that it doesn't
* support pid's of 0 or < -1.
*
* Results:
* -1 is returned if there is an error in the wait kernel call.
* Otherwise the pid of an exited or suspended process is
* returned and *statusPtr is set to the status value of the
* process.
* -1 is returned if there is an error in the wait kernel call. Otherwise
* the pid of an exited or suspended process is returned and *statusPtr
* is set to the status value of the process.
*
* Side effects:
* None.
@@ -67,12 +62,12 @@ static WaitInfo *deadList = NULL; /* First in list of all dead
#endif
pid_t
waitpid(pid, statusPtr, options)
pid_t pid; /* The pid to wait on. Must be -1 or
* greater than zero. */
int *statusPtr; /* Where to store wait status for the
waitpid(
pid_t pid, /* The pid to wait on. Must be -1 or greater
* than zero. */
int *statusPtr, /* Where to store wait status for the
* process. */
int options; /* OR'ed combination of WNOHANG and
int options) /* OR'ed combination of WNOHANG and
* WUNTRACED. */
{
register WaitInfo *waitPtr, *prevPtr;
@@ -85,9 +80,9 @@ waitpid(pid, statusPtr, options)
}
/*
* See if there's a suitable process that has already stopped or
* exited. If so, remove it from the list of exited processes and
* return its information.
* See if there's a suitable process that has already stopped or exited.
* If so, remove it from the list of exited processes and return its
* information.
*/
for (waitPtr = deadList, prevPtr = NULL; waitPtr != NULL;
@@ -110,12 +105,12 @@ waitpid(pid, statusPtr, options)
}
/*
* Wait for any process to stop or exit. If it's an acceptable one
* then return it to the caller; otherwise store information about it
* in the list of exited processes and try again. On systems that
* have only wait but not wait3, there are several situations we can't
* handle, but we do the best we can (e.g. can still handle some
* combinations of options by invoking wait instead of wait3).
* Wait for any process to stop or exit. If it's an acceptable one then
* return it to the caller; otherwise store information about it in the
* list of exited processes and try again. On systems that have only wait
* but not wait3, there are several situations we can't handle, but we do
* the best we can (e.g. can still handle some combinations of options by
* invoking wait instead of wait3).
*/
while (1) {
@@ -148,13 +143,13 @@ waitpid(pid, statusPtr, options)
return result;
/*
* Can't return this info to caller. Save it in the list of
* stopped or exited processes. Tricky point: first check for
* an existing entry for the process and overwrite it if it
* exists (e.g. a previously stopped process might now be dead).
* Can't return this info to caller. Save it in the list of stopped or
* exited processes. Tricky point: first check for an existing entry
* for the process and overwrite it if it exists (e.g. a previously
* stopped process might now be dead).
*/
saveInfo:
saveInfo:
for (waitPtr = deadList; waitPtr != NULL; waitPtr = waitPtr->nextPtr) {
if (waitPtr->pid == result) {
waitPtr->status = status;
@@ -167,6 +162,7 @@ waitpid(pid, statusPtr, options)
waitPtr->nextPtr = deadList;
deadList = waitPtr;
waitAgain: continue;
waitAgain:
continue;
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ int
int
\fBTcl_Stat\fR(\fIpath\fR, \fIstatPtr\fR)
.SH ARGUMENTS
.AS "struct stat" *statPtr in
.AS "struct stat" *statPtr out
.AP char *path in
Native name of the file to check the attributes of.
.AP int mode in
+194 -83
View File
@@ -6,17 +6,29 @@
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.so man.macros
.TH Tcl_AddErrorInfo 3 8.0 Tcl "Tcl Library Procedures"
.TH Tcl_AddErrorInfo 3 8.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_AddObjErrorInfo, Tcl_AddErrorInfo, Tcl_SetObjErrorCode, Tcl_SetErrorCode, Tcl_SetErrorCodeVA, Tcl_PosixError, Tcl_LogCommandInfo \- record information about errors
Tcl_GetReturnOptions, Tcl_SetReturnOptions, Tcl_AddErrorInfo, Tcl_AppendObjToErrorInfo, Tcl_AddObjErrorInfo, Tcl_SetObjErrorCode, Tcl_SetErrorCode, Tcl_SetErrorCodeVA, Tcl_PosixError, Tcl_LogCommandInfo \- retrieve or record information about errors and other return options
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.VS 8.5
.sp
\fBTcl_AddObjErrorInfo\fR(\fIinterp, message, length\fR)
Tcl_Obj *
\fBTcl_GetReturnOptions\fR(\fIinterp, code\fR)
.sp
int
\fBTcl_SetReturnOptions\fR(\fIinterp, options\fR)
.VE 8.5
.sp
\fBTcl_AddErrorInfo\fR(\fIinterp, message\fR)
.VS 8.5
.sp
\fBTcl_AppendObjToErrorInfo\fR(\fIinterp, objPtr\fR)
.VE 8.5
.sp
\fBTcl_AddObjErrorInfo\fR(\fIinterp, message, length\fR)
.sp
\fBTcl_SetObjErrorCode\fR(\fIinterp, errorObjPtr\fR)
.sp
@@ -24,38 +36,47 @@ Tcl_AddObjErrorInfo, Tcl_AddErrorInfo, Tcl_SetObjErrorCode, Tcl_SetErrorCode, Tc
.sp
\fBTcl_SetErrorCodeVA\fR(\fIinterp, argList\fR)
.sp
CONST char *
const char *
\fBTcl_PosixError\fR(\fIinterp\fR)
.sp
void
\fBTcl_LogCommandInfo\fR(\fIinterp, script, command, commandLength\fR)
.SH ARGUMENTS
.AS Tcl_Interp *message
.AS Tcl_Interp commandLength
.AP Tcl_Interp *interp in
Interpreter in which to record information.
.AP int code
The code returned from script evaluation.
.AP Tcl_Obj *options
A dictionary of return options.
.AP char *message in
For \fBTcl_AddErrorInfo\fR,
this is a conventional C string to append to the \fB\-errorinfo\fR return option.
For \fBTcl_AddObjErrorInfo\fR,
this points to the first byte of an array of bytes
containing a string to record in the \fBerrorInfo\fR variable.
this points to the first byte of an array of \fIlength\fR bytes
containing a string to append to the \fB\-errorinfo\fR return option.
This byte array may contain embedded null bytes
unless \fIlength\fR is negative.
For \fBTcl_AddErrorInfo\fR,
this is a conventional C string to record in the \fBerrorInfo\fR variable.
.VS 8.5
.AP Tcl_Obj *objPtr in
A message to be appended to the \fB\-errorinfo\fR return option
in the form of a Tcl_Obj value.
.VE 8.5
.AP int length in
The number of bytes to copy from \fImessage\fR when
setting the \fBerrorInfo\fR variable.
appending to the \fB\-errorinfo\fR return option.
If negative, all bytes up to the first null byte are used.
.AP Tcl_Obj *errorObjPtr in
This variable \fBerrorCode\fR will be set to this value.
The \fB\-errorcode\fR return option will be set to this value.
.AP char *element in
String to record as one element of \fBerrorCode\fR variable.
String to record as one element of the \fB\-errorcode\fR return option.
Last \fIelement\fR argument must be NULL.
.AP va_list argList in
An argument list which must have been initialized using
\fBTCL_VARARGS_START\fR, and cleared using \fBva_end\fR.
.AP "CONST char" *script in
\fBva_start\fR, and cleared using \fBva_end\fR.
.AP "const char" *script in
Pointer to first character in script containing command (must be <= command)
.AP "CONST char" *command in
.AP "const char" *command in
Pointer to first character in command that generated the error
.AP int commandLength in
Number of bytes in command; -1 means use all bytes up to first null byte
@@ -63,70 +84,156 @@ Number of bytes in command; -1 means use all bytes up to first null byte
.SH DESCRIPTION
.PP
These procedures are used to manipulate two Tcl global variables
that hold information about errors.
The variable \fBerrorInfo\fR holds a stack trace of the
.VS 8.5
The \fBTcl_SetReturnOptions\fR and \fBTcl_GetReturnOptions\fR
routines expose the same capabilities as the \fBreturn\fR and
\fBcatch\fR commands, respectively, in the form of a C interface.
.PP
\fBTcl_GetReturnOptions\fR retrieves the dictionary of return options
from an interpreter following a script evaluation.
Routines such as \fBTcl_Eval\fR are called to evaluate a
script in an interpreter. These routines return an integer
completion code. These routines also leave in the interpreter
both a result and a dictionary of return options generated
by script evaluation. Just as \fBTcl_GetObjResult\fR retrieves
the result, \fBTcl_GetReturnOptions\fR retrieves the dictionary
of return options. The integer completion code should be
passed as the \fIcode\fR argument to \fBTcl_GetReturnOptions\fR
so that all required options will be present in the dictionary.
Specifically, a \fIcode\fR value of \fBTCL_ERROR\fR will
ensure that entries for the keys \fB\-errorinfo\fR,
\fB\-errorcode\fR, and \fB\-errorline\fR will appear in the
dictionary. Also, the entries for the keys \fB\-code\fR
and \fB\-level\fR will be adjusted if necessary to agree
with the value of \fIcode\fR. The \fB(Tcl_Obj *)\fR returned
by \fBTcl_GetReturnOptions\fR points to an unshared
\fBTcl_Obj\fR with reference count of zero. The dictionary
may be written to, either adding, removing, or overwriting
any entries in it, without the need to check for a shared object.
.PP
A typical usage for \fBTcl_GetReturnOptions\fR is to
retrieve the stack trace when script evaluation returns
\fBTCL_ERROR\fR, like so:
.CS
int code = Tcl_Eval(interp, script);
if (code == TCL_ERROR) {
Tcl_Obj *options = Tcl_GetReturnOptions(interp, code);
Tcl_Obj *key = Tcl_NewStringObj("-errorinfo", -1);
Tcl_Obj *stackTrace;
Tcl_IncrRefCount(key);
Tcl_DictObjGet(NULL, options, key, &stackTrace);
Tcl_DecrRefCount(key);
/* Do something with stackTrace */
}
.CE
.PP
\fBTcl_SetReturnOptions\fR sets the return options
of \fIinterp\fR to be \fIoptions\fR. If \fIoptions\fR
contains any invalid value for any key, TCL_ERROR will
be returned, and the interp result will be set to an
appropriate error message. Otherwise, a completion code
in agreement with the \fB\-code\fR and \fB\-level\fR
keys in \fIoptions\fR will be returned.
.PP
As an example, Tcl's \fBreturn\fR command itself could
be implemented in terms of \fBTcl_SetReturnOptions\fR
like so:
.CS
if ((objc % 2) == 0) { /* explicit result argument */
objc--;
Tcl_SetObjResult(interp, objv[objc]);
}
return Tcl_SetReturnOptions(interp, Tcl_NewListObj(objc-1, objv+1));
.CE
(It is not really implemented that way. Internal access
privileges allow for a more efficient alternative that meshes
better with the bytecode compiler.)
.PP
Note that a newly created \fBTcl_Obj\fR may be passed
in as the \fIoptions\fR argument without the need to tend
to any reference counting. This is analogous to
\fBTcl_SetObjResult\fR.
.PP
While \fBTcl_SetReturnOptions\fR provides a general interface
to set any collection of return options, there are a handful
of return options that are very frequently used. Most
notably the \fB\-errorinfo\fR and \fB\-errorcode\fR return
options should be set properly when the command procedure
of a command returns \fBTCL_ERROR\fR. Tcl provides several
simpler interfaces to more directly set these return options.
.VE 8.5
.PP
The \fB\-errorinfo\fR option holds a stack trace of the
operations that were in progress when an error occurred,
and is intended to be human-readable.
The variable \fBerrorCode\fR holds a list of items that
The \fB\-errorcode\fR option holds a list of items that
are intended to be machine-readable.
The first item in \fBerrorCode\fR identifies the class of
The first item in the \fB\-errorcode\fR value identifies the class of
error that occurred
(e.g. POSIX means an error occurred in a POSIX system call)
and additional elements in \fBerrorCode\fR hold additional pieces
and additional elements hold additional pieces
of information that depend on the class.
See the Tcl overview manual entry for details on the various
formats for \fBerrorCode\fR.
See the tclvars manual entry for details on the various
formats for the \fB\-errorcode\fR option used by
Tcl's built-in commands.
.PP
The \fBerrorInfo\fR variable is gradually built up as an
The \fB\-errorinfo\fR option value is gradually built up as an
error unwinds through the nested operations.
Each time an error code is returned to \fBTcl_EvalObjEx\fR
(or \fBTcl_Eval\fR, which calls \fBTcl_EvalObjEx\fR)
it calls the procedure \fBTcl_AddObjErrorInfo\fR to add
additional text to \fBerrorInfo\fR describing the
Each time an error code is returned to \fBTcl_Eval\fR, or
any of the routines that performs script evaluation,
the procedure \fBTcl_AddErrorInfo\fR is called to add
additional text to the \fB\-errorinfo\fR value describing the
command that was being executed when the error occurred.
By the time the error has been passed all the way back
to the application, it will contain a complete trace
of the activity in progress when the error occurred.
.PP
It is sometimes useful to add additional information to
\fBerrorInfo\fR beyond what can be supplied automatically
by \fBTcl_EvalObjEx\fR.
\fBTcl_AddObjErrorInfo\fR may be used for this purpose:
its \fImessage\fR and \fIlength\fR arguments describe an additional
string to be appended to \fBerrorInfo\fR.
For example, the \fBsource\fR command calls \fBTcl_AddObjErrorInfo\fR
to record the name of the file being processed and the
line number on which the error occurred;
for Tcl procedures, the procedure name and line number
the \fB\-errorinfo\fR value beyond what can be supplied automatically
by the script evaluation routines.
\fBTcl_AddErrorInfo\fR may be used for this purpose:
its \fImessage\fR argument is an additional
string to be appended to the \fB\-errorinfo\fR option.
For example, when an error arises during the \fBsource\fR command,
the procedure \fBTcl_AddErrorInfo\fR is called to
record the name of the file being processed and the
line number on which the error occurred.
Likewise, when an error arises during evaluation of a
Tcl procedures, the procedure name and line number
within the procedure are recorded, and so on.
The best time to call \fBTcl_AddObjErrorInfo\fR is just after
\fBTcl_EvalObjEx\fR has returned \fBTCL_ERROR\fR.
In calling \fBTcl_AddObjErrorInfo\fR, you may find it useful to
use the \fBerrorLine\fR field of the interpreter (see the
\fBTcl_Interp\fR manual entry for details).
The best time to call \fBTcl_AddErrorInfo\fR is just after
a script evaluation routine has returned \fBTCL_ERROR\fR.
The value of the \fB\-errorline\fR return option (retrieved
via a call to \fBTcl_GetReturnOptions\fR) often makes up
a useful part of the \fImessage\fR passed to \fBTcl_AddErrorInfo\fR.
.PP
\fBTcl_AddErrorInfo\fR resembles \fBTcl_AddObjErrorInfo\fR
but differs in initializing \fBerrorInfo\fR from the string
value of the interpreter's result
if the error is just starting to be logged.
It does not use the result as a Tcl object
so any embedded null characters in the result
will cause information to be lost.
It also takes a conventional C string in \fImessage\fR
instead of \fBTcl_AddObjErrorInfo\fR's counted string.
.VS 8.5
\fBTcl_AppendObjToErrorInfo\fR is an alternative interface to the
same functionality as \fBTcl_AddErrorInfo\fR. \fBTcl_AppendObjToErrorInfo\fR
is called when the string value to be appended to the \fB\-errorinfo\fR option
is available as a \fBTcl_Obj\fR instead of as a \fBchar\fR array.
.VE 8.5
.PP
\fBTcl_AddObjErrorInfo\fR is nearly identical
to \fBTcl_AddErrorInfo\fR, except that it has an additional \fIlength\fR
argument. This allows the \fImessage\fR string to contain
embedded null bytes. This is essentially never a good idea.
If the \fImessage\fR needs to contain the null character \fBU+0000\fR,
Tcl's usual internal encoding rules should be used to avoid
the need for a null byte. If the \fBTcl_AddObjErrorInfo\fR
interface is used at all, it should be with a negative \fIlength\fR value.
.PP
The procedure \fBTcl_SetObjErrorCode\fR is used to set the
\fBerrorCode\fR variable. \fIerrorObjPtr\fR contains a list object
built up by the caller. \fBerrorCode\fR is set to this
value. \fBTcl_SetObjErrorCode\fR is typically invoked just
before returning an error in an object command. If an error is
\fB\-errorcode\fR return option to the list object \fIerrorObjPtr\fR
built up by the caller.
\fBTcl_SetObjErrorCode\fR is typically invoked just
before returning an error. If an error is
returned without calling \fBTcl_SetObjErrorCode\fR or
\fBTcl_SetErrorCode\fR the Tcl interpreter automatically sets
\fBerrorCode\fR to \fBNONE\fR.
the \fB\-errorcode\fR return option to \fBNONE\fR.
.PP
The procedure \fBTcl_SetErrorCode\fR is also used to set the
\fBerrorCode\fR variable. However, it takes one or more strings to
\fB\-errorcode\fR return option. However, it takes one or more strings to
record instead of an object. Otherwise, it is similar to
\fBTcl_SetObjErrorCode\fR in behavior.
.PP
@@ -134,9 +241,10 @@ record instead of an object. Otherwise, it is similar to
instead of taking a variable number of arguments it takes an argument list.
.PP
\fBTcl_PosixError\fR
sets the \fBerrorCode\fR variable after an error in a POSIX kernel call.
sets the \fB\-errorcode\fR variable after an error in a POSIX kernel call.
It reads the value of the \fBerrno\fR C variable and calls
\fBTcl_SetErrorCode\fR to set \fBerrorCode\fR in the \fBPOSIX\fR format.
\fBTcl_SetErrorCode\fR to set the \fB\-errorcode\fR return
option in the \fBPOSIX\fR format.
The caller must previously have called \fBTcl_SetErrno\fR to set
\fBerrno\fR; this is necessary on some platforms (e.g. Windows) where Tcl
is linked into an application as a shared library, or when the error
@@ -146,41 +254,44 @@ occurs in a dynamically loaded extension. See the manual entry for
\fBTcl_PosixError\fR returns a human-readable diagnostic message
for the error
(this is the same value that will appear as the third element
in \fBerrorCode\fR).
in the \fB\-errorcode\fR value).
It may be convenient to include this string as part of the
error message returned to the application in
the interpreter's result.
.PP
\fBTcl_LogCommandInfo\fR is invoked after an error occurs in an
interpreter. It adds information about the command that was being
executed when the error occurred to the \fBerrorInfo\fR variable, and
the line number stored internally in the interpreter is set. On the
first call to \fBTcl_LogCommandInfo\fR or \fBTcl_AddObjErrorInfo\fR
since an error occurred, the old information in \fBerrorInfo\fR is
deleted.
executed when the error occurred to the \fB\-errorinfo\fR value, and
the line number stored internally in the interpreter is set.
.PP
It is important to call the procedures described here rather than
In older releases of Tcl, there was no \fBTcl_GetReturnOptions\fR
routine. In its place, the global Tcl variables \fBerrorInfo\fR
and \fBerrorCode\fR were the only place to retrieve the error
information. Much existing code written for older Tcl releases
still access this information via those global variables.
.PP
It is important to realize that while reading from those
global variables remains a supported way to access these
return option values, it is important not to assume that
writing to those global variables will properly set the
corresponding return options. It has long been emphasized
in this manual page that it is important to
call the procedures described here rather than
setting \fBerrorInfo\fR or \fBerrorCode\fR directly with
\fBTcl_ObjSetVar2\fR.
The reason for this is that the Tcl interpreter keeps information
about whether these procedures have been called.
For example, the first time \fBTcl_AddObjErrorInfo\fR is called
for an error, it clears the existing value of \fBerrorInfo\fR
and adds the error message in the interpreter's result to the variable
before appending \fImessage\fR;
in subsequent calls, it just appends the new \fImessage\fR.
When \fBTcl_SetErrorCode\fR is called, it sets a flag indicating
that \fBerrorCode\fR has been set;
this allows the Tcl interpreter to set \fBerrorCode\fR to \fBNONE\fR
if it receives an error return
when \fBTcl_SetErrorCode\fR hasn't been called.
.PP
If the procedure \fBTcl_ResetResult\fR is called,
it clears all of the state associated with
\fBerrorInfo\fR and \fBerrorCode\fR
(but it doesn't actually modify the variables).
If an error had occurred, this will clear the error state to
make it appear as if no error had occurred after all.
it clears all of the state of the interpreter associated with
script evaluation, including the entire return options dictionary.
In particular, the \fB\-errorinfo\fR and \fB\-errorcode\fR options
are reset.
If an error had occurred, the \fBTcl_ResetResult\fR call will
clear the error state to make it appear as if no error had
occurred after all.
The global variables \fBerrorInfo\fR and
\fBerrorCode\fR are not modified by \fBTcl_ResetResult\fR
so they continue to hold a record of information about the
most recent error seen in an interpreter.
.SH "SEE ALSO"
Tcl_DecrRefCount, Tcl_IncrRefCount, Tcl_Interp, Tcl_ResetResult, Tcl_SetErrno
+6 -4
View File
@@ -67,22 +67,24 @@ further allocation.
\fBTcl_Realloc\fR changes the size of the block pointed to by
\fIptr\fR to \fIsize\fR bytes and returns a pointer to the new block.
The contents will be unchanged up to the lesser of the new and old
sizes. The returned location may be different from \fIptr\fR.
sizes. The returned location may be different from \fIptr\fR. If
\fIptr\fR is NULL, this is equivalent to calling \fBTcl_Alloc\fR with
just the \fIsize\fR argument.
.PP
\fBTcl_AttemptAlloc\fR and \fBTcl_AttemptRealloc\fR are identical in
function to \fBTcl_Alloc\fR and \fBTcl_Realloc\fR, except that
\fBTcl_AttemptAlloc\fR and \fBTcl_AttemptRealloc\fR will not cause the Tcl
interpreter to \fBpanic\fR if the memory allocation fails. If the
allocation fails, these functions will return NULL. Note that on some
platforms, attempting to allocate a block of memory will also cause
these functions to return NULL.
platforms, but not all, attempting to allocate a zero-sized block of
memory will also cause these functions to return NULL.
.PP
The procedures \fBckalloc\fR, \fBckfree\fR, \fBckrealloc\fR,
\fBattemptckalloc\fR, and \fBattemptckrealloc\fR are implemented
as macros. Normally, they are synonyms for the corresponding
procedures documented on this page. When Tcl and all modules
calling Tcl are compiled with \fBTCL_MEM_DEBUG\fR defined, however,
these macros are redefined to be special debugging versions of
these macros are redefined to be special debugging versions
of these procedures. To support Tcl's memory debugging within a
module, use the macros rather than direct calls to \fBTcl_Alloc\fR, etc.
+4 -4
View File
@@ -16,7 +16,7 @@ Tcl_AllowExceptions \- allow all exceptions in next script evaluation
.sp
\fBTcl_AllowExceptions\fR(\fIinterp\fR)
.SH ARGUMENTS
.AS Tcl_Interp *doublePtr
.AS Tcl_Interp *interp
.AP Tcl_Interp *interp in
Interpreter in which script will be evaluated.
.BE
@@ -25,8 +25,8 @@ Interpreter in which script will be evaluated.
.PP
If a script is evaluated at top-level (i.e. no other scripts are
pending evaluation when the script is invoked), and if the script
terminates with a completion code other than TCL_OK, TCL_ERROR
or TCL_RETURN, then Tcl normally converts this into a TCL_ERROR
terminates with a completion code other than \fBTCL_OK\fR, \fBTCL_ERROR\fR
or \fBTCL_RETURN\fR, then Tcl normally converts this into a \fBTCL_ERROR\fR
return with an appropriate message. The particular script
evaluation procedures of Tcl that act in the manner are
\fBTcl_EvalObjEx\fR, \fBTcl_EvalObjv\fR, \fBTcl_Eval\fR, \fBTcl_EvalEx\fR,
@@ -38,7 +38,7 @@ calling one of those a procedures, then arbitrary completion
codes are permitted from the script, and they are returned without
modification.
This is useful in cases where the caller can deal with exceptions
such as TCL_BREAK or TCL_CONTINUE in a meaningful way.
such as \fBTCL_BREAK\fR or \fBTCL_CONTINUE\fR in a meaningful way.
.SH KEYWORDS
continue, break, exception, interpreter
+6 -4
View File
@@ -24,7 +24,9 @@ Interpreter for the application.
.SH DESCRIPTION
.PP
\fBTcl_AppInit\fR is a ``hook'' procedure that is invoked by
\fBTcl_AppInit\fR is a
.QW hook
procedure that is invoked by
the main programs for Tcl applications such as \fBtclsh\fR and \fBwish\fR.
Its purpose is to allow new Tcl applications to be created without
modifying the main programs provided as part of Tcl and Tk.
@@ -47,8 +49,8 @@ Tcl variables \fBargv\fR and \fBargv0\fR in \fIinterp\fR.
.IP [3]
Invoke a startup script to initialize the application.
.LP
\fBTcl_AppInit\fR returns TCL_OK or TCL_ERROR.
If it returns TCL_ERROR then it must leave an error message in
\fBTcl_AppInit\fR returns \fBTCL_OK\fR or \fBTCL_ERROR\fR.
If it returns \fBTCL_ERROR\fR then it must leave an error message in
for the interpreter's result; otherwise the result is ignored.
.PP
In addition to \fBTcl_AppInit\fR, your application should also contain
@@ -58,7 +60,7 @@ Tcl_Main(argc, argv, Tcl_AppInit);
.CE
The third argument to \fBTcl_Main\fR gives the address of the
application-specific initialization procedure to invoke.
This means that you don't have to use the name \fBTcl_AppInit\fR
This means that you do not have to use the name \fBTcl_AppInit\fR
for the procedure, but in practice the name is nearly always
\fBTcl_AppInit\fR (in versions before Tcl 7.4 the name \fBTcl_AppInit\fR
was implicit; there was no way to specify the procedure explicitly).
+5 -9
View File
@@ -8,9 +8,7 @@
.TH Tcl_SetAssocData 3 7.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_GetAssocData, Tcl_SetAssocData, Tcl_DeleteAssocData \- manage
associations of string keys and user specified data with Tcl
interpreters.
Tcl_GetAssocData, Tcl_SetAssocData, Tcl_DeleteAssocData \- manage associations of string keys and user specified data with Tcl interpreters
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -22,12 +20,10 @@ ClientData
.sp
\fBTcl_DeleteAssocData\fR(\fIinterp, key\fR)
.SH ARGUMENTS
.AS Tcl_InterpDeleteProc *delProcPtr
.AS Tcl_InterpDeleteProc **delProcPtr
.AP Tcl_Interp *interp in
Interpreter in which to execute the specified command.
.VS 8.4
.AP "CONST char" *key in
.VE
.AP "const char" *key in
Key for association with which to store data or from which to delete or
retrieve data. Typically the module prefix for a package.
.AP Tcl_InterpDeleteProc *delProc in
@@ -67,8 +63,8 @@ is deleted. \fIDeleteProc\fR should have arguments and result that match
the type \fBTcl_InterpDeleteProc\fR:
.CS
typedef void Tcl_InterpDeleteProc(
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR);
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR);
.CE
When \fIdeleteProc\fR is invoked the \fIclientData\fR and \fIinterp\fR
arguments will be the same as the corresponding arguments passed to
+7 -9
View File
@@ -48,9 +48,9 @@ or 0 if \fIinterp\fR is NULL.
These procedures provide a safe mechanism for dealing with
asynchronous events such as signals.
If an event such as a signal occurs while a Tcl script is being
evaluated then it isn't safe to take any substantive action to
evaluated then it is not safe to take any substantive action to
process the event.
For example, it isn't safe to evaluate a Tcl script since the
For example, it is not safe to evaluate a Tcl script since the
interpreter may already be in the middle of evaluating a script;
it may not even be safe to allocate memory, since a memory
allocation could have been in progress when the event occurred.
@@ -140,7 +140,6 @@ If new handlers become ready while handlers are executing,
\fBTcl_AsyncInvoke\fR will invoke them all; at each point it
invokes the highest-priority (oldest) ready handler, repeating
this over and over until there are no longer any ready handlers.
.SH WARNING
.PP
It is almost always a bad idea for an asynchronous event
@@ -150,12 +149,11 @@ This sort of behavior can disrupt the execution of scripts in
subtle ways and result in bugs that are extremely difficult
to track down.
If an asynchronous event handler needs to evaluate Tcl scripts
then it should first save the interpreter's result plus the values
of the variables \fBerrorInfo\fR and \fBerrorCode\fR (this can
be done, for example, by storing them in dynamic strings).
then it should first save the interpreter's state by calling
\fBTcl_SaveInterpState\fR, passing in the \fIcode\fR argument.
When the asynchronous handler is finished it should restore
the interpreter's result, \fBerrorInfo\fR, and \fBerrorCode\fR,
and return the \fIcode\fR argument.
the interpreter's state by calling \fBTcl_RestoreInterpState\fR,
and then returning the \fIcode\fR argument.
.SH KEYWORDS
asynchronous event, handler, signal
asynchronous event, handler, signal, Tcl_SaveInterpState, thread
+19 -14
View File
@@ -24,7 +24,8 @@ Interpreter in which the error occurred.
.SH DESCRIPTION
.PP
This procedure is typically invoked when a Tcl error occurs during
``background processing'' such as executing an event handler.
.QW "background processing"
such as executing an event handler.
When such an error occurs, the error condition is reported to Tcl
or to a widget or some other C code, and there is not usually any
obvious way for that code to report the error to the user.
@@ -32,25 +33,29 @@ In these cases the code calls \fBTcl_BackgroundError\fR with an
\fIinterp\fR argument identifying the interpreter in which the
error occurred. At the time \fBTcl_BackgroundError\fR is invoked,
the interpreter's result is expected to contain an error message.
\fBTcl_BackgroundError\fR will invoke the \fBbgerror\fR
Tcl command to report the error in an application-specific fashion.
If no \fBbgerror\fR command exists, or if it returns with an error condition,
then \fBTcl_BackgroundError\fR reports the error itself by printing
a message on the standard error file.
\fBTcl_BackgroundError\fR will invoke the command registered
in that interpreter to handle background errors by the
\fBinterp bgerror\fR command.
The registered handler command is meant to report the error
in an application-specific fashion. The handler command
receives two arguments, the result of the interp, and the
return options of the interp at the time the error occurred.
If the application registers no handler command, the default
handler command will attempt to call \fBbgerror\fR to report
the error. If an error condition arises while invoking the
handler command, then \fBTcl_BackgroundError\fR reports the
error itself by printing a message on the standard error file.
.PP
\fBTcl_BackgroundError\fR does not invoke \fBbgerror\fR immediately
\fBTcl_BackgroundError\fR does not invoke the handler command immediately
because this could potentially interfere with scripts that are in process
at the time the error occurred.
Instead, it invokes \fBbgerror\fR later as an idle callback.
\fBTcl_BackgroundError\fR saves the values of the \fBerrorInfo\fR and
\fBerrorCode\fR variables and restores these values just before
invoking \fBbgerror\fR.
Instead, it invokes the handler command later as an idle callback.
.PP
It is possible for many background errors to accumulate before
\fBbgerror\fR is invoked. When this happens, each of the errors
is processed in order. However, if \fBbgerror\fR returns a
the handler command is invoked. When this happens, each of the errors
is processed in order. However, if the handle command returns a
break exception, then all remaining error reports for the
interpreter are skipped.
.SH KEYWORDS
background, bgerror, error
background, bgerror, error, interp
+2 -6
View File
@@ -17,35 +17,31 @@ Tcl_Backslash \- parse a backslash sequence
char
\fBTcl_Backslash\fR(\fIsrc, countPtr\fR)
.SH ARGUMENTS
.AS char *countPtr
.AS char *countPtr out
.AP char *src in
Pointer to a string starting with a backslash.
.AP int *countPtr out
If \fIcountPtr\fR isn't NULL, \fI*countPtr\fR gets filled
If \fIcountPtr\fR is not NULL, \fI*countPtr\fR gets filled
in with number of characters in the backslash sequence, including
the backslash character.
.BE
.SH DESCRIPTION
.PP
.VS 8.1
The use of \fBTcl_Backslash\fR is deprecated in favor of
\fBTcl_UtfBackslash\fR.
.PP
This is a utility procedure provided for backwards compatibility with
non-internationalized Tcl extensions. It parses a backslash sequence and
returns the low byte of the Unicode character corresponding to the sequence.
.VE
\fBTcl_Backslash\fR modifies \fI*countPtr\fR to contain the number of
characters in the backslash sequence.
.PP
See the Tcl manual entry for information on the valid backslash sequences.
All of the sequences described in the Tcl manual entry are supported by
\fBTcl_Backslash\fR.
.VS 8.1 br
.SH "SEE ALSO"
Tcl(n), Tcl_UtfBackslash(3)
.VE
.SH KEYWORDS
backslash, parse
+57 -49
View File
@@ -1,14 +1,15 @@
'\"
'\" Copyright (c) 1996-1997 Sun Microsystems, Inc.
'\" Contributions from Don Porter, NIST, 2005. (not subject to US copyright)
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.so man.macros
.TH Tcl_BooleanObj 3 8.0 Tcl "Tcl Library Procedures"
.TH Tcl_BooleanObj 3 8.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_NewBooleanObj, Tcl_SetBooleanObj, Tcl_GetBooleanFromObj \- manipulate Tcl objects as boolean values
Tcl_NewBooleanObj, Tcl_SetBooleanObj, Tcl_GetBooleanFromObj \- store/retrieve boolean value in a Tcl_Obj
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -21,20 +22,14 @@ Tcl_Obj *
int
\fBTcl_GetBooleanFromObj\fR(\fIinterp, objPtr, boolPtr\fR)
.SH ARGUMENTS
.AS Tcl_Interp *interp
.AS Tcl_Interp boolValue in/out
.AP int boolValue in
Integer value used to initialize or set a boolean object.
If the integer is nonzero, the boolean object is set to 1;
otherwise the boolean object is set to 0.
Integer value to be stored as a boolean value in a Tcl_Obj.
.AP Tcl_Obj *objPtr in/out
For \fBTcl_SetBooleanObj\fR, this points to the object to be converted
to boolean type.
For \fBTcl_GetBooleanFromObj\fR, this refers to the object
from which to get a boolean value;
if \fIobjPtr\fR does not already point to a boolean object,
an attempt will be made to convert it to one.
Points to the Tcl_Obj in which to store, or from which to
retrieve a boolean value.
.AP Tcl_Interp *interp in/out
If an error occurs during conversion,
If a boolean value cannot be retrieved,
an error message is left in the interpreter's result object
unless \fIinterp\fR is NULL.
.AP int *boolPtr out
@@ -44,44 +39,57 @@ stores the boolean value (0 or 1) obtained from \fIobjPtr\fR.
.SH DESCRIPTION
.PP
These procedures are used to create, modify, and read
boolean Tcl objects from C code.
\fBTcl_NewBooleanObj\fR and \fBTcl_SetBooleanObj\fR
will create a new object of boolean type
or modify an existing object to have boolean type.
Both of these procedures set the object to have the
boolean value (0 or 1) specified by \fIboolValue\fR;
if \fIboolValue\fR is nonzero, the object is set to 1,
otherwise to 0.
\fBTcl_NewBooleanObj\fR returns a pointer to a newly created object
with reference count zero.
Both procedures set the object's type to be boolean
and assign the boolean value to the object's internal representation
\fIlongValue\fR member.
\fBTcl_SetBooleanObj\fR invalidates any old string representation
and, if the object is not already a boolean object,
frees any old internal representation.
These procedures are used to pass boolean values to and from
Tcl as Tcl_Obj's. When storing a boolean value into a Tcl_Obj,
any non-zero integer value in \fIboolValue\fR is taken to be
the boolean value \fB1\fR, and the integer value \fB0\fR is
taken to be the boolean value \fB0\fR.
.PP
\fBTcl_GetBooleanFromObj\fR attempts to return a boolean value
from the Tcl object \fIobjPtr\fR.
If the object is not already a boolean object,
it will attempt to convert it to one.
If an error occurs during conversion, it returns \fBTCL_ERROR\fR
and leaves an error message in the interpreter's result object
unless \fIinterp\fR is NULL.
Otherwise, \fBTcl_GetBooleanFromObj\fR returns \fBTCL_OK\fR
and stores the boolean value in the address given by \fIboolPtr\fR.
If the object is not already a boolean object,
the conversion will free any old internal representation.
Objects having a string representation equal to any of \fB0\fR,
\fBfalse\fR, \fBno\fR, or \fBoff\fR have a boolean value 0; if the
string representation is any of \fB1\fR, \fBtrue\fR, \fByes\fR, or
\fBon\fR the boolean value is 1.
Any of these string values may be abbreviated, and upper-case spellings
are also acceptable.
\fBTcl_NewBooleanObj\fR creates a new Tcl_Obj, stores the boolean
value \fIboolValue\fR in it, and returns a pointer to the new Tcl_Obj.
The new Tcl_Obj has reference count of zero.
.PP
\fBTcl_SetBooleanObj\fR accepts \fIobjPtr\fR, a pointer to
an existing Tcl_Obj, and stores in the Tcl_Obj \fI*objPtr\fR
the boolean value \fIboolValue\fR. This is a write operation
on \fI*objPtr\fR, so \fIobjPtr\fR must be unshared. Attempts to
write to a shared Tcl_Obj will panic. A successful write
of \fIboolValue\fR into \fI*objPtr\fR implies the freeing of
any former value stored in \fI*objPtr\fR.
.PP
\fBTcl_GetBooleanFromObj\fR attempts to retrieve a boolean value
from the value stored in \fI*objPtr\fR.
If \fIobjPtr\fR holds a string value recognized by \fBTcl_GetBoolean\fR,
then the recognized boolean value is written at the address given
by \fIboolPtr\fR.
If \fIobjPtr\fR holds any value recognized as
a number by Tcl, then if that value is zero a 0 is written at
the address given by \fIboolPtr\fR and if that
value is non-zero a 1 is written at the address given by \fIboolPtr\fR.
In all cases where a value is written at the address given
by \fIboolPtr\fR, \fBTcl_GetBooleanFromObj\fR returns \fBTCL_OK\fR.
If the value of \fIobjPtr\fR does not meet any of the conditions
above, then \fBTCL_ERROR\fR is returned and an error message is
left in the interpreter's result unless \fIinterp\fR is NULL.
\fBTcl_GetBooleanFromObj\fR may also make changes to the internal
fields of \fI*objPtr\fR so that future calls to
\fBTcl_GetBooleanFromObj\fR on the same \fIobjPtr\fR can be
performed more efficiently.
.PP
Note that the routines \fBTcl_GetBooleanFromObj\fR and
\fBTcl_GetBoolean\fR are not functional equivalents.
The set of values for which \fBTcl_GetBooleanFromObj\fR
will return \fBTCL_OK\fR is strictly larger than
the set of values for which \fBTcl_GetBoolean\fR will do the same.
For example, the value
.QW 5
passed to \fBTcl_GetBooleanFromObj\fR
will lead to a \fBTCL_OK\fR return (and the boolean value 1),
while the same value passed to \fBTcl_GetBoolean\fR will lead to
a \fBTCL_ERROR\fR return.
.SH "SEE ALSO"
Tcl_NewObj, Tcl_DecrRefCount, Tcl_IncrRefCount, Tcl_GetObjResult
Tcl_NewObj, Tcl_IsShared, Tcl_GetBoolean
.SH KEYWORDS
boolean, boolean object, boolean type, internal representation, object, object type, string representation
boolean, object
+3 -3
View File
@@ -25,8 +25,8 @@ unsigned char *
unsigned char *
\fBTcl_SetByteArrayLength\fR(\fIobjPtr, length\fR)
.SH ARGUMENTS
.AS "unsigned char" *lengthPtr in/out
.AP "CONST unsigned char" *bytes in
.AS "const unsigned char" *lengthPtr in/out
.AP "const unsigned char" *bytes in
The array of bytes used to initialize or set a byte-array object.
.AP int length in
The length of the array of bytes. It must be >= 0.
@@ -48,7 +48,7 @@ results of binary IO operations or data structures created with the
\fBbinary\fR command. In Tcl, an array of bytes is not equivalent to a
string. Conceptually, a string is an array of Unicode characters, while a
byte-array is an array of 8-bit quantities with no implicit meaning.
Accesser functions are provided to get the string representation of a
Accessor functions are provided to get the string representation of a
byte-array or to convert an arbitrary object to a byte-array. Obtaining the
string representation of a byte-array object (by calling
\fBTcl_GetStringFromObj\fR) produces a properly formed UTF-8 sequence with a
+3 -3
View File
@@ -38,8 +38,8 @@ time of the call.
type \fBTcl_InterpDeleteProc\fR:
.CS
typedef void Tcl_InterpDeleteProc(
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR);
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR);
.CE
The \fIclientData\fR and \fIinterp\fR parameters are
copies of the \fIclientData\fR and \fIinterp\fR arguments given
@@ -51,7 +51,7 @@ interpreter is about to go away.
.PP
\fBTcl_DontCallWhenDeleted\fR cancels a previous call to
\fBTcl_CallWhenDeleted\fR with the same arguments, so that
\fIproc\fR won't be called after all when \fIinterp\fR is
\fIproc\fR will not be called after all when \fIinterp\fR is
deleted.
If there is no deletion callback that matches \fIinterp\fR,
\fIproc\fR, and \fIclientData\fR then the call to
+10 -10
View File
@@ -8,7 +8,7 @@
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_StackChannel, Tcl_UnstackChannel, Tcl_GetStackedChannel, Tcl_GetTopChannel \- stack an I/O channel on top of another, and undo it
Tcl_StackChannel, Tcl_UnstackChannel, Tcl_GetStackedChannel, Tcl_GetTopChannel \- manipulate stacked I/O channels
.SH SYNOPSIS
.nf
.nf
@@ -27,17 +27,17 @@ Tcl_Channel
\fBTcl_GetTopChannel\fR(\fIchannel\fR)
.sp
.SH ARGUMENTS
.AS Tcl_ChannelType
.AS Tcl_ChannelType clientData
.AP Tcl_Interp *interp in
Interpreter for error reporting.
.AP Tcl_ChannelType *typePtr in
The new channel I/O procedures to use for \fIchannel\fP.
The new channel I/O procedures to use for \fIchannel\fR.
.AP ClientData clientData in
Arbitrary one-word value to pass to channel I/O procedures.
.AP int mask in
Conditions under which \fIchannel\fR will be used: OR-ed combination of
\fBTCL_READABLE\fR, \fBTCL_WRITABLE\fR and \fBTCL_EXCEPTION\fR.
This can be a subset of the operations currently allowed on \fIchannel\fP.
This can be a subset of the operations currently allowed on \fIchannel\fR.
.AP Tcl_Channel channel in
An existing Tcl channel such as returned by \fBTcl_CreateChannel\fR.
.BE
@@ -55,9 +55,9 @@ stacked channels. Anyone using stacked channels or creating stacked
channel drivers should update to the new \fBTCL_CHANNEL_VERSION_2\fR
\fBTcl_ChannelType\fR structure. See \fBTcl_CreateChannel\fR for details.
.PP
\fBTcl_StackChannel\fR stacks a new \fIchannel\fP on an existing channel
with the same name that was registered for \fIchannel\fP by
\fBTcl_RegisterChannel\fP.
\fBTcl_StackChannel\fR stacks a new \fIchannel\fR on an existing channel
with the same name that was registered for \fIchannel\fR by
\fBTcl_RegisterChannel\fR.
.PP
\fBTcl_StackChannel\fR works by creating a new channel structure and
placing itself on top of the channel stack. EOL translation, encoding and
@@ -68,7 +68,7 @@ remain at the top of the channel stack. A pointer to the new top channel
structure is returned. If an error occurs when stacking the channel, NULL
is returned instead.
.PP
The \fImask\fP parameter specifies the operations that are allowed on the
The \fImask\fR parameter specifies the operations that are allowed on the
new channel. These can be a subset of the operations allowed on the
original channel. For example, a read-write channel may become read-only
after the \fBTcl_StackChannel\fR call.
@@ -77,10 +77,10 @@ Closing a channel closes the channels stacked below it. The close of
stacked channels is executed in a way that allows buffered data to be
properly flushed.
.PP
\fBTcl_UnstackChannel\fP reverses the process. The old channel is
\fBTcl_UnstackChannel\fR reverses the process. The old channel is
associated with the channel name, and the processing module added by
\fBTcl_StackChannel\fR is destroyed. If there is no old channel, then
\fBTcl_UnstackChannel\fP is equivalent to \fBTcl_Close\fP. If an error
\fBTcl_UnstackChannel\fR is equivalent to \fBTcl_Close\fR. If an error
occurs unstacking the channel, \fBTCL_ERROR\fR is returned, otherwise
\fBTCL_OK\fR is returned.
.PP
+2 -2
View File
@@ -17,8 +17,8 @@ Tcl_CommandComplete \- Check for unmatched braces in a Tcl command
int
\fBTcl_CommandComplete\fR(\fIcmd\fR)
.SH ARGUMENTS
.AS "CONST char" *cmd
.AP "CONST char" *cmd in
.AS "const char" *cmd
.AP "const char" *cmd in
Command string to test for completeness.
.BE
+3 -5
View File
@@ -14,12 +14,13 @@ Tcl_Concat \- concatenate a collection of strings
.nf
\fB#include <tcl.h>\fR
.sp
CONST char *
const char *
\fBTcl_Concat\fR(\fIargc, argv\fR)
.SH ARGUMENTS
.AS "const char *const" argv[]
.AP int argc in
Number of strings.
.AP "CONST char * CONST" argv[] in
.AP "const char *const" argv[] in
Array of strings to concatenate. Must have \fIargc\fR entries.
.BE
@@ -41,12 +42,9 @@ copies strings from \fBargv\fR to the result. If an element of
is ignored entirely. This white-space removal was added to make
the output of the \fBconcat\fR command cleaner-looking.
.PP
.VS
The result string is dynamically allocated
using \fBTcl_Alloc\fR; the caller must eventually release the space
by calling \fBTcl_Free\fR.
.VE
.VS
.SH "SEE ALSO"
Tcl_ConcatObj
.SH KEYWORDS
+193 -182
View File
@@ -9,7 +9,7 @@
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_CreateChannel, Tcl_GetChannelInstanceData, Tcl_GetChannelType, Tcl_GetChannelName, Tcl_GetChannelHandle, Tcl_GetChannelMode, Tcl_GetChannelBufferSize, Tcl_SetChannelBufferSize, Tcl_NotifyChannel, Tcl_BadChannelOption, Tcl_ChannelName, Tcl_ChannelVersion, Tcl_ChannelBlockModeProc, Tcl_ChannelCloseProc, Tcl_ChannelClose2Proc, Tcl_ChannelInputProc, Tcl_ChannelOutputProc, Tcl_ChannelSeekProc, Tcl_ChannelWideSeekProc, Tcl_ChannelSetOptionProc, Tcl_ChannelGetOptionProc, Tcl_ChannelWatchProc, Tcl_ChannelGetHandleProc, Tcl_ChannelFlushProc, Tcl_ChannelHandlerProc, Tcl_ChannelThreadActionProc, Tcl_IsChannelShared, Tcl_IsChannelRegistered, Tcl_CutChannel, Tcl_SpliceChannel, Tcl_IsChannelExisting, Tcl_ClearChannelHandlers, Tcl_GetChannelThread, Tcl_ChannelBuffered \- procedures for creating and manipulating channels
Tcl_CreateChannel, Tcl_GetChannelInstanceData, Tcl_GetChannelType, Tcl_GetChannelName, Tcl_GetChannelHandle, Tcl_GetChannelMode, Tcl_GetChannelBufferSize, Tcl_SetChannelBufferSize, Tcl_NotifyChannel, Tcl_BadChannelOption, Tcl_ChannelName, Tcl_ChannelVersion, Tcl_ChannelBlockModeProc, Tcl_ChannelCloseProc, Tcl_ChannelClose2Proc, Tcl_ChannelInputProc, Tcl_ChannelOutputProc, Tcl_ChannelSeekProc, Tcl_ChannelWideSeekProc, Tcl_ChannelTruncateProc, Tcl_ChannelSetOptionProc, Tcl_ChannelGetOptionProc, Tcl_ChannelWatchProc, Tcl_ChannelGetHandleProc, Tcl_ChannelFlushProc, Tcl_ChannelHandlerProc, Tcl_ChannelThreadActionProc, Tcl_IsChannelShared, Tcl_IsChannelRegistered, Tcl_CutChannel, Tcl_SpliceChannel, Tcl_IsChannelExisting, Tcl_ClearChannelHandlers, Tcl_GetChannelThread, Tcl_ChannelBuffered \- procedures for creating and manipulating channels
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -23,16 +23,14 @@ ClientData
Tcl_ChannelType *
\fBTcl_GetChannelType\fR(\fIchannel\fR)
.sp
CONST char *
const char *
\fBTcl_GetChannelName\fR(\fIchannel\fR)
.sp
int
\fBTcl_GetChannelHandle\fR(\fIchannel, direction, handlePtr\fR)
.sp
.VS 8.4
Tcl_ThreadId
\fBTcl_GetChannelThread\fR(\fIchannel\fR)
.VE 8.4
.sp
int
\fBTcl_GetChannelMode\fR(\fIchannel\fR)
@@ -46,7 +44,6 @@ int
.sp
int
\fBTcl_BadChannelOption\fR(\fIinterp, optionName, optionList\fR)
.VS 8.4
.sp
int
\fBTcl_IsChannelShared\fR(\fIchannel\fR)
@@ -65,12 +62,11 @@ void
.sp
void
\fBTcl_ClearChannelHandlers\fR(\fIchannel\fR)
.VE 8.4
.sp
int
\fBTcl_ChannelBuffered\fR(\fIchannel\fR)
.sp
CONST char *
const char *
\fBTcl_ChannelName\fR(\fItypePtr\fR)
.sp
Tcl_ChannelTypeVersion
@@ -94,13 +90,16 @@ Tcl_DriverOutputProc *
Tcl_DriverSeekProc *
\fBTcl_ChannelSeekProc\fR(\fItypePtr\fR)
.sp
.VS 8.4
Tcl_DriverWideSeekProc *
\fBTcl_ChannelWideSeekProc\fR(\fItypePtr\fR)
.sp
Tcl_DriverThreadActionProc *
\fBTcl_ChannelThreadActionProc\fR(\fItypePtr\fR)
.VE 8.4
.sp
.VS 8.5
Tcl_DriverTruncateProc *
\fBTcl_ChannelTruncateProc\fR(\fItypePtr\fR)
.VE 8.5
.sp
Tcl_DriverSetOptionProc *
\fBTcl_ChannelSetOptionProc\fR(\fItypePtr\fR)
@@ -121,11 +120,11 @@ Tcl_DriverHandlerProc *
\fBTcl_ChannelHandlerProc\fR(\fItypePtr\fR)
.sp
.SH ARGUMENTS
.AS Tcl_ChannelType *channelName in
.AP Tcl_ChannelType *typePtr in
.AS "const Tcl_ChannelType" *channelName
.AP "const Tcl_ChannelType" *typePtr in
Points to a structure containing the addresses of procedures that
can be called to perform I/O and other functions on the channel.
.AP "CONST char" *channelName in
.AP "const char" *channelName in
The name of this channel, such as \fBfile3\fR; must not be in use
by any other channel. Can be NULL, in which case the channel is
created without a name.
@@ -151,10 +150,11 @@ and \fBTCL_EXCEPTION\fR that indicates events that have occurred on
this channel.
.AP Tcl_Interp *interp in
Current interpreter. (can be NULL)
.AP "CONST char" *optionName in
.AP "const char" *optionName in
Name of the invalid option.
.AP "CONST char" *optionList in
Specific options list (space separated words, without "-")
.AP "const char" *optionList in
Specific options list (space separated words, without
.QW \- )
to append to the standard generic options list.
Can be NULL for generic options error message only.
@@ -178,7 +178,7 @@ driver provides a \fBTcl_ChannelType\fR structure containing pointers to
functions implementing the various operations used by the generic layer to
communicate with the channel driver. The \fBTcl_ChannelType\fR structure
and the functions referenced by it are described in the section
TCL_CHANNELTYPE, below.
\fBTCL_CHANNELTYPE\fR, below.
.PP
Second, channel drivers usually provide a Tcl command to create
instances of that type of channel. For example, the Tcl \fBopen\fR
@@ -205,7 +205,7 @@ structure to perform operations on the channel.
\fItypePtr\fR and \fIinstanceData\fR with it. The channel is opened in the
mode indicated by \fImask\fR.
For a discussion of channel drivers, their operations and the
\fBTcl_ChannelType\fR structure, see the section TCL_CHANNELTYPE, below.
\fBTcl_ChannelType\fR structure, see the section \fBTCL_CHANNELTYPE\fR, below.
.PP
\fBTcl_CreateChannel\fR interacts with the code managing the standard
channels. Once a standard channel was initialized either through a
@@ -237,11 +237,9 @@ then \fBTCL_ERROR\fR is returned instead. Different channel drivers
will return different types of handle. Refer to the manual entries
for each driver to determine what type of handle is returned.
.PP
.VS 8.4
\fBTcl_GetChannelThread\fR returns the id of the thread currently managing
the specified \fIchannel\fR. This allows channel drivers to send their file
events to the correct event queue even for a multi-threaded core.
.VE 8.4
.PP
\fBTcl_GetChannelMode\fR returns an OR-ed combination of \fBTCL_READABLE\fR
and \fBTCL_WRITABLE\fR, indicating whether the channel is open for input
@@ -265,15 +263,15 @@ occurred on the channel. Channel drivers are responsible for invoking
this function whenever the channel handlers need to be called for the
channel. See \fBWATCHPROC\fR below for more details.
.PP
\fBTcl_BadChannelOption\fR is called from driver specific set or get option
procs to generate a complete error message.
\fBTcl_BadChannelOption\fR is called from driver specific
\fIsetOptionProc\fR or \fIgetOptionProc\fR to generate a complete
error message.
.PP
\fBTcl_ChannelBuffered\fR returns the number of bytes of input
currently buffered in the internal buffer (push back area) of the
channel itself. It does not report about the data in the overall
buffers for the stack of channels the supplied channel is part of.
.PP
.VS 8.4
\fBTcl_IsChannelShared\fR checks the refcount of the specified
\fIchannel\fR and returns whether the \fIchannel\fR was shared among
multiple interpreters (result == 1) or not (result == 0).
@@ -290,26 +288,24 @@ name is registered in the (thread)-global list of all channels (result
(thread)global list of all channels (of the current thread).
Application to a channel still registered in some interpreter
is not allowed.
.VS 8.4
.VS 8.5
Also notifies the driver if the \fBTcl_ChannelType\fR version is
\fBTCL_CHANNEL_VERSION_4\fR (or higher), and
\fBTcl_DriverThreadActionProc\fR is defined for it.
.VE 8.4
.VE 8.5
.PP
\fBTcl_SpliceChannel\fR adds the specified \fIchannel\fR to the
(thread)global list of all channels (of the current thread).
Application to a channel registered in some interpreter is not allowed.
.VS 8.4
.VS 8.5
Also notifies the driver if the \fBTcl_ChannelType\fR version is
\fBTCL_CHANNEL_VERSION_4\fR (or higher), and
\fBTcl_DriverThreadActionProc\fR is defined for it.
.VE 8.4
.VE 8.5
.PP
\fBTcl_ClearChannelHandlers\fR removes all channelhandlers and event
\fBTcl_ClearChannelHandlers\fR removes all channel handlers and event
scripts associated with the specified \fIchannel\fR, thus shutting
down all event processing for this channel.
.VE 8.4
.SH TCL_CHANNELTYPE
.PP
A channel driver provides a \fBTcl_ChannelType\fR structure that contains
@@ -322,22 +318,25 @@ details about the old structure.
The \fBTcl_ChannelType\fR structure contains the following fields:
.CS
typedef struct Tcl_ChannelType {
char *\fItypeName\fR;
Tcl_ChannelTypeVersion \fIversion\fR;
Tcl_DriverCloseProc *\fIcloseProc\fR;
Tcl_DriverInputProc *\fIinputProc\fR;
Tcl_DriverOutputProc *\fIoutputProc\fR;
Tcl_DriverSeekProc *\fIseekProc\fR;
Tcl_DriverSetOptionProc *\fIsetOptionProc\fR;
Tcl_DriverGetOptionProc *\fIgetOptionProc\fR;
Tcl_DriverWatchProc *\fIwatchProc\fR;
Tcl_DriverGetHandleProc *\fIgetHandleProc\fR;
Tcl_DriverClose2Proc *\fIclose2Proc\fR;
Tcl_DriverBlockModeProc *\fIblockModeProc\fR;
Tcl_DriverFlushProc *\fIflushProc\fR;
Tcl_DriverHandlerProc *\fIhandlerProc\fR;
Tcl_DriverWideSeekProc *\fIwideSeekProc\fR;
Tcl_DriverThreadActionProc *\fIthreadActionProc\fR;
char *\fItypeName\fR;
Tcl_ChannelTypeVersion \fIversion\fR;
Tcl_DriverCloseProc *\fIcloseProc\fR;
Tcl_DriverInputProc *\fIinputProc\fR;
Tcl_DriverOutputProc *\fIoutputProc\fR;
Tcl_DriverSeekProc *\fIseekProc\fR;
Tcl_DriverSetOptionProc *\fIsetOptionProc\fR;
Tcl_DriverGetOptionProc *\fIgetOptionProc\fR;
Tcl_DriverWatchProc *\fIwatchProc\fR;
Tcl_DriverGetHandleProc *\fIgetHandleProc\fR;
Tcl_DriverClose2Proc *\fIclose2Proc\fR;
Tcl_DriverBlockModeProc *\fIblockModeProc\fR;
Tcl_DriverFlushProc *\fIflushProc\fR;
Tcl_DriverHandlerProc *\fIhandlerProc\fR;
Tcl_DriverWideSeekProc *\fIwideSeekProc\fR;
Tcl_DriverThreadActionProc *\fIthreadActionProc\fR;
.VS 8.5
Tcl_DriverTruncateProc *\fItruncateProc\fR;
.VE 8.5
} Tcl_ChannelType;
.CE
.PP
@@ -345,11 +344,11 @@ It is not necessary to provide implementations for all channel
operations. Those which are not necessary may be set to NULL in the
struct: \fIblockModeProc\fR, \fIseekProc\fR, \fIsetOptionProc\fR,
\fIgetOptionProc\fR, and \fIclose2Proc\fR, in addition to
\fIflushProc\fR, \fIhandlerProc\fR, and \fIthreadActionProc\fR. Other
functions that cannot be implemented in a meaningful way should return
\fBEINVAL\fR when called, to indicate that the operations they
represent are not available. Also note that \fIwideSeekProc\fR can be
NULL if \fIseekProc\fR is.
\fIflushProc\fR, \fIhandlerProc\fR, \fIthreadActionProc\fR, and
\fItruncateProc\fR. Other functions that cannot be implemented in a
meaningful way should return \fBEINVAL\fR when called, to indicate
that the operations they represent are not available. Also note that
\fIwideSeekProc\fR can be NULL if \fIseekProc\fR is.
.PP
The user should only use the above structure for \fBTcl_ChannelType\fR
instantiation. When referencing fields in a \fBTcl_ChannelType\fR
@@ -358,20 +357,19 @@ structure, the following functions should be used to obtain the values:
\fBTcl_ChannelBlockModeProc\fR, \fBTcl_ChannelCloseProc\fR,
\fBTcl_ChannelClose2Proc\fR, \fBTcl_ChannelInputProc\fR,
\fBTcl_ChannelOutputProc\fR, \fBTcl_ChannelSeekProc\fR,
.VS 8.4
\fBTcl_ChannelWideSeekProc\fR,
\fBTcl_ChannelThreadActionProc\fR,
.VE 8.4
\fBTcl_ChannelWideSeekProc\fR, \fBTcl_ChannelThreadActionProc\fR,
.VS 8.5
\fBTcl_ChannelTruncateProc\fR,
.VE 8.5
\fBTcl_ChannelSetOptionProc\fR, \fBTcl_ChannelGetOptionProc\fR,
\fBTcl_ChannelWatchProc\fR, \fBTcl_ChannelGetHandleProc\fR,
\fBTcl_ChannelFlushProc\fR, or \fBTcl_ChannelHandlerProc\fR.
.PP
The change to the structures was made in such a way that standard channel
types are binary compatible. However, channel types that use stacked
channels (ie: TLS, Trf) have new versions to correspond to the above change
channels (i.e. TLS, Trf) have new versions to correspond to the above change
since the previous code for stacked channels had problems.
.SH TYPENAME
.SS TYPENAME
.PP
The \fItypeName\fR field contains a null-terminated string that
identifies the type of the device implemented by this driver, e.g.
@@ -379,19 +377,19 @@ identifies the type of the device implemented by this driver, e.g.
.PP
This value can be retrieved with \fBTcl_ChannelName\fR, which returns
a pointer to the string.
.SH VERSION
.SS VERSION
.PP
The \fIversion\fR field should be set to the version of the structure
that you require. \fBTCL_CHANNEL_VERSION_2\fR is the minimum recommended.
.VS 8.4
\fBTCL_CHANNEL_VERSION_3\fR must be set to specifiy the \fIwideSeekProc\fR member.
.VE 8.4
.VS 8.4
\fBTCL_CHANNEL_VERSION_4\fR must be set to specifiy the
\fIthreadActionProc\fR member (includes \fIwideSeekProc\fR).
.VE 8.4
\fBTCL_CHANNEL_VERSION_3\fR must be set to specify the \fIwideSeekProc\fR member.
\fBTCL_CHANNEL_VERSION_4\fR must be set to specify the \fIthreadActionProc\fR member
(includes \fIwideSeekProc\fR).
.VS 8.5
\fBTCL_CHANNEL_VERSION_5\fR must be set to specify the
\fItruncateProc\fR members (includes
\fIwideSeekProc\fR and \fIthreadActionProc\fR).
.VE 8.5
If it is not set to any of these, then this
\fBTcl_ChannelType\fR is assumed to have the original structure. See
\fBOLD CHANNEL TYPES\fR for more details. While Tcl will recognize
@@ -399,12 +397,14 @@ and function with either structures, stacked channels must be of at
least \fBTCL_CHANNEL_VERSION_2\fR to function correctly.
.PP
This value can be retrieved with \fBTcl_ChannelVersion\fR, which returns
.VS 8.4
one of \fBTCL_CHANNEL_VERSION_4\fR, \fBTCL_CHANNEL_VERSION_3\fR,
.VE 8.4
\fBTCL_CHANNEL_VERSION_2\fR, or \fBTCL_CHANNEL_VERSION_1\fR.
.SH BLOCKMODEPROC
one of
.VS 8.5
\fBTCL_CHANNEL_VERSION_5\fR,
.VE 8.5
\fBTCL_CHANNEL_VERSION_4\fR,
\fBTCL_CHANNEL_VERSION_3\fR,
\fBTCL_CHANNEL_VERSION_2\fR or \fBTCL_CHANNEL_VERSION_1\fR.
.SS BLOCKMODEPROC
.PP
The \fIblockModeProc\fR field contains the address of a function called by
the generic layer to set blocking and nonblocking mode on the device.
@@ -412,8 +412,8 @@ the generic layer to set blocking and nonblocking mode on the device.
.PP
.CS
typedef int Tcl_DriverBlockModeProc(
ClientData \fIinstanceData\fR,
int \fImode\fR);
ClientData \fIinstanceData\fR,
int \fImode\fR);
.CE
.PP
The \fIinstanceData\fR is the same as the value passed to
@@ -437,11 +437,9 @@ A channel driver \fBnot\fR supplying a \fIblockModeProc\fR has to be
very, very careful. It has to tell the generic layer exactly which
blocking mode is acceptable to it, and should this also document for
the user so that the blocking mode of the channel is not changed to an
inacceptable value. Any confusion here may lead the interpreter into a
unacceptable value. Any confusion here may lead the interpreter into a
(spurious and difficult to find) deadlock.
.SH "CLOSEPROC AND CLOSE2PROC"
.SS "CLOSEPROC AND CLOSE2PROC"
.PP
The \fIcloseProc\fR field contains the address of a function called by the
generic layer to clean up driver-related information when the channel is
@@ -449,8 +447,8 @@ closed. \fICloseProc\fR must match the following prototype:
.PP
.CS
typedef int Tcl_DriverCloseProc(
ClientData \fIinstanceData\fR,
Tcl_Interp *\fIinterp\fR);
ClientData \fIinstanceData\fR,
Tcl_Interp *\fIinterp\fR);
.CE
.PP
The \fIinstanceData\fR argument is the same as the value provided to
@@ -471,9 +469,9 @@ following prototype:
.PP
.CS
typedef int Tcl_DriverClose2Proc(
ClientData \fIinstanceData\fR,
Tcl_Interp *\fIinterp\fR,
int \fIflags\fR);
ClientData \fIinstanceData\fR,
Tcl_Interp *\fIinterp\fR,
int \fIflags\fR);
.CE
.PP
The \fIclose2Proc\fR will be called with \fIflags\fR set to an OR'ed
@@ -491,11 +489,10 @@ return a nonzero POSIX error code. In addition, if an error occurs and
\fIinterp\fR is not NULL, the procedure should store an error message
in the interpreter's result.
.PP
These value can be retrieved with \fBTcl_ChannelCloseProc\fR or
\fBTcl_ChannelClose2Proc\fR, which returns a pointer to the respective
function.
.SH INPUTPROC
The \fIcloseProc\fR and \fIclose2Proc\fR values can be retrieved with
\fBTcl_ChannelCloseProc\fR or \fBTcl_ChannelClose2Proc\fR, which
return a pointer to the respective function.
.SS INPUTPROC
.PP
The \fIinputProc\fR field contains the address of a function called by the
generic layer to read data from the file or device and store it in an
@@ -503,10 +500,10 @@ internal buffer. \fIInputProc\fR must match the following prototype:
.PP
.CS
typedef int Tcl_DriverInputProc(
ClientData \fIinstanceData\fR,
char *\fIbuf\fR,
int \fIbufSize\fR,
int *\fIerrorCodePtr\fR);
ClientData \fIinstanceData\fR,
char *\fIbuf\fR,
int \fIbufSize\fR,
int *\fIerrorCodePtr\fR);
.CE
.PP
\fIInstanceData\fR is the same as the value passed to
@@ -539,8 +536,7 @@ blocking.
.PP
This value can be retrieved with \fBTcl_ChannelInputProc\fR, which returns
a pointer to the function.
.SH OUTPUTPROC
.SS OUTPUTPROC
.PP
The \fIoutputProc\fR field contains the address of a function called by the
generic layer to transfer data from an internal buffer to the output device.
@@ -548,10 +544,10 @@ generic layer to transfer data from an internal buffer to the output device.
.PP
.CS
typedef int Tcl_DriverOutputProc(
ClientData \fIinstanceData\fR,
CONST char *\fIbuf\fR,
int \fItoWrite\fR,
int *\fIerrorCodePtr\fR);
ClientData \fIinstanceData\fR,
const char *\fIbuf\fR,
int \fItoWrite\fR,
int *\fIerrorCodePtr\fR);
.CE
.PP
\fIInstanceData\fR is the same as the value passed to
@@ -578,8 +574,7 @@ without writing any data.
.PP
This value can be retrieved with \fBTcl_ChannelOutputProc\fR, which returns
a pointer to the function.
.SH "SEEKPROC AND WIDESEEKPROC"
.SS "SEEKPROC AND WIDESEEKPROC"
.PP
The \fIseekProc\fR field contains the address of a function called by the
generic layer to move the access point at which subsequent input or output
@@ -588,10 +583,10 @@ prototype:
.PP
.CS
typedef int Tcl_DriverSeekProc(
ClientData \fIinstanceData\fR,
long \fIoffset\fR,
int \fIseekMode\fR,
int *\fIerrorCodePtr\fR);
ClientData \fIinstanceData\fR,
long \fIoffset\fR,
int \fIseekMode\fR,
int *\fIerrorCodePtr\fR);
.CE
.PP
The \fIinstanceData\fR argument is the same as the value given to
@@ -608,7 +603,6 @@ does not implement seeking.
The return value is the new access point or -1 in case of error. If an
error occurred, the function should not move the access point.
.PP
.VS 8.4
If there is a non-NULL \fIseekProc\fR field, the \fIwideSeekProc\fR
field may contain the address of an alternative function to use which
handles wide (i.e. larger than 32-bit) offsets, so allowing seeks
@@ -619,10 +613,10 @@ following prototype:
.PP
.CS
typedef Tcl_WideInt Tcl_DriverWideSeekProc(
ClientData \fIinstanceData\fR,
Tcl_WideInt \fIoffset\fR,
int \fIseekMode\fR,
int *\fIerrorCodePtr\fR);
ClientData \fIinstanceData\fR,
Tcl_WideInt \fIoffset\fR,
int \fIseekMode\fR,
int *\fIerrorCodePtr\fR);
.CE
.PP
The arguments and return values mean the same thing as with
@@ -633,9 +627,7 @@ The \fIseekProc\fR value can be retrieved with
\fBTcl_ChannelSeekProc\fR, which returns a pointer to the function,
and similarly the \fIwideSeekProc\fR can be retrieved with
\fBTcl_ChannelWideSeekProc\fR.
.VE 8.4
.SH SETOPTIONPROC
.SS SETOPTIONPROC
.PP
The \fIsetOptionProc\fR field contains the address of a function called by
the generic layer to set a channel type specific option on a channel.
@@ -643,10 +635,10 @@ the generic layer to set a channel type specific option on a channel.
.PP
.CS
typedef int Tcl_DriverSetOptionProc(
ClientData \fIinstanceData\fR,
Tcl_Interp *\fIinterp\fR,
CONST char *\fIoptionName\fR,
CONST char *\fInewValue\fR);
ClientData \fIinstanceData\fR,
Tcl_Interp *\fIinterp\fR,
const char *\fIoptionName\fR,
const char *\fInewValue\fR);
.CE
.PP
\fIoptionName\fR is the name of an option to set, and \fInewValue\fR is
@@ -656,7 +648,7 @@ created. The function should do whatever channel type specific action is
required to implement the new value of the option.
.PP
Some options are handled by the generic code and this function is never
called to set them, e.g. \fB-blockmode\fR. Other options are specific to
called to set them, e.g. \fB\-blockmode\fR. Other options are specific to
each channel type and the \fIsetOptionProc\fR procedure of the channel
driver will get called to implement them. The \fIsetOptionProc\fR field can
be NULL, which indicates that this channel type supports no type specific
@@ -676,8 +668,7 @@ error code.
.PP
This value can be retrieved with \fBTcl_ChannelSetOptionProc\fR, which returns
a pointer to the function.
.SH GETOPTIONPROC
.SS GETOPTIONPROC
.PP
The \fIgetOptionProc\fR field contains the address of a function called by
the generic layer to get the value of a channel type specific option on a
@@ -685,10 +676,10 @@ channel. \fIgetOptionProc\fR must match the following prototype:
.PP
.CS
typedef int Tcl_DriverGetOptionProc(
ClientData \fIinstanceData\fR,
Tcl_Interp *\fIinterp\fR,
CONST char *\fIoptionName\fR,
Tcl_DString *\fIoptionValue\fR);
ClientData \fIinstanceData\fR,
Tcl_Interp *\fIinterp\fR,
const char *\fIoptionName\fR,
Tcl_DString *\fIoptionValue\fR);
.CE
.PP
\fIOptionName\fR is the name of an option supported by this type of
@@ -706,7 +697,7 @@ function should also call \fBTcl_SetErrno\fR to store an appropriate POSIX
error code.
.PP
Some options are handled by the generic code and this function is never
called to retrieve their value, e.g. \fB-blockmode\fR. Other options are
called to retrieve their value, e.g. \fB\-blockmode\fR. Other options are
specific to each channel type and the \fIgetOptionProc\fR procedure of the
channel driver will get called to implement them. The \fIgetOptionProc\fR
field can be NULL, which indicates that this channel type supports no type
@@ -714,8 +705,7 @@ specific options.
.PP
This value can be retrieved with \fBTcl_ChannelGetOptionProc\fR, which returns
a pointer to the function.
.SH WATCHPROC
.SS WATCHPROC
.PP
The \fIwatchProc\fR field contains the address of a function called
by the generic layer to initialize the event notification mechanism to
@@ -724,8 +714,8 @@ notice events of interest on this channel.
.PP
.CS
typedef void Tcl_DriverWatchProc(
ClientData \fIinstanceData\fR,
int \fImask\fR);
ClientData \fIinstanceData\fR,
int \fImask\fR);
.CE
.PP
The \fIinstanceData\fR is the same as the value passed to
@@ -747,8 +737,7 @@ details on how to queue an event.
.PP
This value can be retrieved with \fBTcl_ChannelWatchProc\fR, which returns
a pointer to the function.
.SH GETHANDLEPROC
.SS GETHANDLEPROC
.PP
The \fIgetHandleProc\fR field contains the address of a function called by
the generic layer to retrieve a device-specific handle from the channel.
@@ -756,9 +745,9 @@ the generic layer to retrieve a device-specific handle from the channel.
.PP
.CS
typedef int Tcl_DriverGetHandleProc(
ClientData \fIinstanceData\fR,
int \fIdirection\fR,
ClientData *\fIhandlePtr\fR);
ClientData \fIinstanceData\fR,
int \fIdirection\fR,
ClientData *\fIhandlePtr\fR);
.CE
.PP
\fIInstanceData\fR is the same as the value passed to
@@ -777,8 +766,7 @@ device handles, the function should return \fBTCL_ERROR\fR.
.PP
This value can be retrieved with \fBTcl_ChannelGetHandleProc\fR, which returns
a pointer to the function.
.SH FLUSHPROC
.SS FLUSHPROC
.PP
The \fIflushProc\fR field is currently reserved for future use.
It should be set to NULL.
@@ -786,13 +774,12 @@ It should be set to NULL.
.PP
.CS
typedef int Tcl_DriverFlushProc(
ClientData \fIinstanceData\fR);
ClientData \fIinstanceData\fR);
.CE
.PP
This value can be retrieved with \fBTcl_ChannelFlushProc\fR, which returns
a pointer to the function.
.SH HANDLERPROC
.SS HANDLERPROC
.PP
The \fIhandlerProc\fR field contains the address of a function called by
the generic layer to notify the channel that an event occurred. It should
@@ -802,8 +789,8 @@ that occur on the underlying (stacked) channel.
.PP
.CS
typedef int Tcl_DriverHandlerProc(
ClientData \fIinstanceData\fR,
int \fIinterestMask\fR);
ClientData \fIinstanceData\fR,
int \fIinterestMask\fR);
.CE
.PP
\fIInstanceData\fR is the same as the value passed to \fBTcl_CreateChannel\fR
@@ -814,8 +801,7 @@ type of event occurred on this channel.
This value can be retrieved with \fBTcl_ChannelHandlerProc\fR, which returns
a pointer to the function.
.VS 8.4
.SH "THREADACTIONPROC"
.SS "THREADACTIONPROC"
.PP
The \fIthreadActionProc\fR field contains the address of the function
called by the generic layer when a channel is created, closed, or
@@ -832,8 +818,8 @@ might be maintaining using the calling thread as the associate. See
.PP
.CS
typedef void Tcl_DriverThreadActionProc(
ClientData \fIinstanceData\fR,
int \fIaction\fR);
ClientData \fIinstanceData\fR,
int \fIaction\fR);
.CE
.PP
\fIInstanceData\fR is the same as the value passed to
@@ -841,53 +827,79 @@ typedef void Tcl_DriverThreadActionProc(
.PP
These values can be retrieved with \fBTcl_ChannelThreadActionProc\fR,
which returns a pointer to the function.
.VE 8.4
.SS "TRUNCATEPROC"
.PP
The \fItruncateProc\fR field contains the address of the function
called by the generic layer when a channel is truncated to some
length. It can be NULL.
.PP
.CS
typedef int Tcl_DriverTruncateProc(
ClientData \fIinstanceData\fR,
Tcl_WideInt \fIlength\fR);
.CE
.PP
\fIInstanceData\fR is the same as the value passed to
\fBTcl_CreateChannel\fR when this channel was created, and
\fIlength\fR is the new length of the underlying file, which should
not be negative. The result should be 0 on success or an errno code
(suitable for use with \fBTcl_SetErrno\fR) on failure.
.PP
These values can be retrieved with \fBTcl_ChannelTruncateProc\fR,
which returns a pointer to the function.
.SH TCL_BADCHANNELOPTION
.PP
This procedure generates a "bad option" error message in an
This procedure generates a
.QW "bad option"
error message in an
(optional) interpreter. It is used by channel drivers when
a invalid Set/Get option is requested. Its purpose is to concatenate
an invalid Set/Get option is requested. Its purpose is to concatenate
the generic options list to the specific ones and factorize
the generic options error message string.
.PP
It always return \fBTCL_ERROR\fR
It always returns \fBTCL_ERROR\fR
.PP
An error message is generated in \fIinterp\fR's result object to
indicate that a command was invoked with the a bad option
indicate that a command was invoked with a bad option.
The message has the form
.CS
bad option "blah": should be one of
<...generic options...>+<...specific options...>
.CE
so you get for instance:
.CS
bad option "-blah": should be one of -blocking,
-buffering, -buffersize, -eofchar, -translation,
-peername, or -sockname
when called with \fIoptionList\fR="peername sockname"
.CE
``blah'' is the \fIoptionName\fR argument and ``<specific options>''
when called with \fIoptionList\fR equal to
.QW "peername sockname"
.PP
.QW blah
is the \fIoptionName\fR argument and
.QW "<specific options>"
is a space separated list of specific option words.
The function takes good care of inserting minus signs before
each option, commas after, and an ``or'' before the last option.
each option, commas after, and an
.QW or
before the last option.
.SH "OLD CHANNEL TYPES"
The original (8.3.1 and below) \fBTcl_ChannelType\fR structure contains
the following fields:
.PP
.CS
typedef struct Tcl_ChannelType {
char *\fItypeName\fR;
Tcl_DriverBlockModeProc *\fIblockModeProc\fR;
Tcl_DriverCloseProc *\fIcloseProc\fR;
Tcl_DriverInputProc *\fIinputProc\fR;
Tcl_DriverOutputProc *\fIoutputProc\fR;
Tcl_DriverSeekProc *\fIseekProc\fR;
Tcl_DriverSetOptionProc *\fIsetOptionProc\fR;
Tcl_DriverGetOptionProc *\fIgetOptionProc\fR;
Tcl_DriverWatchProc *\fIwatchProc\fR;
Tcl_DriverGetHandleProc *\fIgetHandleProc\fR;
Tcl_DriverClose2Proc *\fIclose2Proc\fR;
char *\fItypeName\fR;
Tcl_DriverBlockModeProc *\fIblockModeProc\fR;
Tcl_DriverCloseProc *\fIcloseProc\fR;
Tcl_DriverInputProc *\fIinputProc\fR;
Tcl_DriverOutputProc *\fIoutputProc\fR;
Tcl_DriverSeekProc *\fIseekProc\fR;
Tcl_DriverSetOptionProc *\fIsetOptionProc\fR;
Tcl_DriverGetOptionProc *\fIgetOptionProc\fR;
Tcl_DriverWatchProc *\fIwatchProc\fR;
Tcl_DriverGetHandleProc *\fIgetHandleProc\fR;
Tcl_DriverClose2Proc *\fIclose2Proc\fR;
} Tcl_ChannelType;
.CE
.PP
@@ -897,33 +909,32 @@ the new \fBTcl_ChannelType\fR structure if you are creating a stacked
channel driver, due to problems with the earlier stacked channel
implementation (in 8.2.0 to 8.3.1).
.PP
.VS 8.4
Prior to 8.4.0 (i.e. during the later releases of 8.3 and early part
of the 8.4 development cycle) the \fBTcl_ChannelType\fR structure
contained the following fields:
.PP
.CS
typedef struct Tcl_ChannelType {
char *\fItypeName\fR;
Tcl_ChannelTypeVersion \fIversion\fR;
Tcl_DriverCloseProc *\fIcloseProc\fR;
Tcl_DriverInputProc *\fIinputProc\fR;
Tcl_DriverOutputProc *\fIoutputProc\fR;
Tcl_DriverSeekProc *\fIseekProc\fR;
Tcl_DriverSetOptionProc *\fIsetOptionProc\fR;
Tcl_DriverGetOptionProc *\fIgetOptionProc\fR;
Tcl_DriverWatchProc *\fIwatchProc\fR;
Tcl_DriverGetHandleProc *\fIgetHandleProc\fR;
Tcl_DriverClose2Proc *\fIclose2Proc\fR;
Tcl_DriverBlockModeProc *\fIblockModeProc\fR;
Tcl_DriverFlushProc *\fIflushProc\fR;
Tcl_DriverHandlerProc *\fIhandlerProc\fR;
char *\fItypeName\fR;
Tcl_ChannelTypeVersion \fIversion\fR;
Tcl_DriverCloseProc *\fIcloseProc\fR;
Tcl_DriverInputProc *\fIinputProc\fR;
Tcl_DriverOutputProc *\fIoutputProc\fR;
Tcl_DriverSeekProc *\fIseekProc\fR;
Tcl_DriverSetOptionProc *\fIsetOptionProc\fR;
Tcl_DriverGetOptionProc *\fIgetOptionProc\fR;
Tcl_DriverWatchProc *\fIwatchProc\fR;
Tcl_DriverGetHandleProc *\fIgetHandleProc\fR;
Tcl_DriverClose2Proc *\fIclose2Proc\fR;
Tcl_DriverBlockModeProc *\fIblockModeProc\fR;
Tcl_DriverFlushProc *\fIflushProc\fR;
Tcl_DriverHandlerProc *\fIhandlerProc\fR;
Tcl_DriverTruncateProc *\fItruncateProc\fR;
} Tcl_ChannelType;
.CE
.PP
When the above structure is registered as a channel type, the
\fIversion\fR field should always be \fBTCL_CHANNEL_VERSION_2\fR.
.VE 8.4
.SH "SEE ALSO"
Tcl_Close(3), Tcl_OpenFileChannel(3), Tcl_SetErrno(3), Tcl_QueueEvent(3), Tcl_StackChannel(3), Tcl_GetStdChannel(3)
+3 -3
View File
@@ -48,8 +48,8 @@ what it means for a channel to be readable or writable.
\fIProc\fR must conform to the following prototype:
.CS
typedef void Tcl_ChannelProc(
ClientData \fIclientData\fR,
int \fImask\fR);
ClientData \fIclientData\fR,
int \fImask\fR);
.CE
.PP
The \fIclientData\fR argument is the same as the value passed to
@@ -62,7 +62,7 @@ contain a subset of the bits from the \fImask\fR argument to
.PP
Each channel handler is identified by a unique combination of \fIchannel\fR,
\fIproc\fR and \fIclientData\fR.
There may be many handlers for a given channel as long as they don't
There may be many handlers for a given channel as long as they do not
have the same \fIchannel\fR, \fIproc\fR, and \fIclientData\fR.
If \fBTcl_CreateChannelHandler\fR is invoked when there is already a handler
for \fIchannel\fR, \fIproc\fR, and \fIclientData\fR, then no new
+2 -2
View File
@@ -21,7 +21,7 @@ void
\fBTcl_DeleteCloseHandler\fR(\fIchannel, proc, clientData\fR)
.sp
.SH ARGUMENTS
.AS Tcl_CloseProc callbackData in
.AS Tcl_CloseProc clientData
.AP Tcl_Channel channel in
The channel for which to create or delete a close callback.
.AP Tcl_CloseProc *proc in
@@ -39,7 +39,7 @@ Arbitrary one-word value to pass to \fIproc\fR.
.PP
.CS
typedef void Tcl_CloseProc(
ClientData \fIclientData\fR);
ClientData \fIclientData\fR);
.CE
.PP
The \fIclientData\fR is the same as the value provided in the call to
+12 -17
View File
@@ -17,12 +17,10 @@ Tcl_CreateCommand \- implement new commands in C
Tcl_Command
\fBTcl_CreateCommand\fR(\fIinterp, cmdName, proc, clientData, deleteProc\fR)
.SH ARGUMENTS
.AS Tcl_CmdDeleteProc **deleteProcPtr
.AS Tcl_CmdDeleteProc *deleteProc
.AP Tcl_Interp *interp in
Interpreter in which to create new command.
.VS 8.4
.AP "CONST char" *cmdName in
.VE
.AP "const char" *cmdName in
Name of command.
.AP Tcl_CmdProc *proc in
Implementation of new command: \fIproc\fR will be called whenever
@@ -79,10 +77,10 @@ and it returns NULL.
\fBTcl_CmdProc\fR:
.CS
typedef int Tcl_CmdProc(
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
int \fIargc\fR,
CONST char *\fIargv\fR[]);
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
int \fIargc\fR,
const char *\fIargv\fR[]);
.CE
When \fIproc\fR is invoked the \fIclientData\fR and \fIinterp\fR
parameters will be copies of the \fIclientData\fR and \fIinterp\fR
@@ -95,26 +93,23 @@ the command name) and \fIargv\fR giving the values of the arguments
as strings. The \fIargv\fR array will contain \fIargc\fR+1 values;
the first \fIargc\fR values point to the argument strings, and the
last value is NULL.
.VS
Note that the argument strings should not be modified as they may
point to constant strings or may be shared with other parts of the
interpreter.
.VE
.PP
.VS
Note that the argument strings are encoded in normalized UTF-8 since
version 8.1 of Tcl.
.VE
.PP
\fIProc\fR must return an integer code that is either \fBTCL_OK\fR, \fBTCL_ERROR\fR,
\fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR. See the Tcl overview man page
\fIProc\fR must return an integer code that is expected to be one of
\fBTCL_OK\fR, \fBTCL_ERROR\fR, \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or
\fBTCL_CONTINUE\fR. See the Tcl overview man page
for details on what these codes mean. Most normal commands will only
return \fBTCL_OK\fR or \fBTCL_ERROR\fR. In addition, \fIproc\fR must set
the interpreter result to point to a string value;
in the case of a \fBTCL_OK\fR return code this gives the result
of the command, and in the case of \fBTCL_ERROR\fR it gives an error message.
The \fBTcl_SetResult\fR procedure provides an easy interface for setting
the return value; for complete details on how the the interpreter result
the return value; for complete details on how the interpreter result
field is managed, see the \fBTcl_Interp\fR man page.
Before invoking a command procedure,
\fBTcl_Eval\fR sets the interpreter result to point to an empty string,
@@ -135,11 +130,11 @@ application an opportunity to release any structures associated
with the command. \fIDeleteProc\fR should have arguments and
result that match the type \fBTcl_CmdDeleteProc\fR:
.CS
typedef void Tcl_CmdDeleteProc(ClientData \fIclientData\fR);
typedef void Tcl_CmdDeleteProc(
ClientData \fIclientData\fR);
.CE
The \fIclientData\fR argument will be the same as the \fIclientData\fR
argument passed to \fBTcl_CreateCommand\fR.
.PP
.SH "SEE ALSO"
Tcl_CreateObjCommand, Tcl_DeleteCommand, Tcl_GetCommandInfo, Tcl_SetCommandInfo, Tcl_GetCommandName, Tcl_SetObjResult
+3 -11
View File
@@ -13,18 +13,14 @@ Tcl_CreateFileHandler, Tcl_DeleteFileHandler \- associate procedure callbacks wi
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.VS
.sp
\fBTcl_CreateFileHandler\fR(\fIfd, mask, proc, clientData\fR)
.sp
\fBTcl_DeleteFileHandler\fR(\fIfd\fR)
.VE
.SH ARGUMENTS
.AS Tcl_FileProc clientData
.VS
.AP int fd in
Unix file descriptor for an open file or device.
.VE
.AP int mask in
Conditions under which \fIproc\fR should be called:
OR-ed combination of \fBTCL_READABLE\fR, \fBTCL_WRITABLE\fR,
@@ -39,12 +35,10 @@ Arbitrary one-word value to pass to \fIproc\fR.
.SH DESCRIPTION
.PP
.VS
\fBTcl_CreateFileHandler\fR arranges for \fIproc\fR to be
invoked in the future whenever I/O becomes possible on a file
or an exceptional condition exists for the file. The file
is indicated by \fIfd\fR, and the conditions of interest
.VE
are indicated by \fImask\fR. For example, if \fImask\fR
is \fBTCL_READABLE\fR, \fIproc\fR will be called when
the file is readable.
@@ -57,8 +51,8 @@ as \fBvwait\fR.
type \fBTcl_FileProc\fR:
.CS
typedef void Tcl_FileProc(
ClientData \fIclientData\fR,
int \fImask\fR);
ClientData \fIclientData\fR,
int \fImask\fR);
.CE
The \fIclientData\fR parameter to \fIproc\fR is a copy
of the \fIclientData\fR
@@ -85,14 +79,12 @@ events while waiting for files to become ready for I/O. For this to work
correctly, the application may need to use non-blocking I/O operations on
the files for which handlers are declared. Otherwise the application may
block if it reads or writes too much data; while waiting for the I/O to
complete the application won't be able to service other events. Use
complete the application will not be able to service other events. Use
\fBTcl_SetChannelOption\fR with \fB\-blocking\fR to set the channel into
blocking or nonblocking mode as required.
.PP
.VS
Note that these interfaces are only supported by the Unix
implementation of the Tcl notifier.
.VE
.SH KEYWORDS
callback, file, handler
+44 -47
View File
@@ -17,20 +17,17 @@ Tcl_CreateMathFunc, Tcl_GetMathFuncInfo, Tcl_ListMathFuncs \- Define, query and
void
\fBTcl_CreateMathFunc\fR(\fIinterp, name, numArgs, argTypes, proc, clientData\fR)
.sp
.VS 8.4
int
\fBTcl_GetMathFuncInfo\fR(\fIinterp, name, numArgsPtr, argTypesPtr, procPtr, clientDataPtr\fR)
\fBTcl_GetMathFuncInfo\fR(\fIinterp, name, numArgsPtr, argTypesPtr, procPtr,
clientDataPtr\fR)
.sp
Tcl_Obj *
\fBTcl_ListMathFuncs\fR(\fIinterp, pattern\fR)
.VE
.SH ARGUMENTS
.AS Tcl_ValueType *clientDataPtr
.AS Tcl_ValueType *clientDataPtr out
.AP Tcl_Interp *interp in
Interpreter in which new function will be defined.
.VS 8.4
.AP "CONST char" *name in
.VE
.AP "const char" *name in
Name for new function.
.AP int numArgs in
Number of arguments to new function; also gives size of \fIargTypes\fR array.
@@ -51,12 +48,12 @@ will need to be freed up using \fITcl_Free\fR.
.AP Tcl_MathProc **procPtr out
Points to a variable that will be set to contain a pointer to the
implementation code for the function (or NULL if the function is
implemented directly in bytecode.)
implemented directly in bytecode).
.AP ClientData *clientDataPtr out
Points to a variable that will be set to contain the clientData
argument passed to \fITcl_CreateMathFunc\fR when the function was
created if the function is not implemented directly in bytecode.
.AP "CONST char" *pattern in
.AP "const char" *pattern in
Pattern to match against function names so as to filter them (by
passing to \fITcl_StringMatch\fR), or NULL to not apply any filter.
.BE
@@ -65,71 +62,70 @@ passing to \fITcl_StringMatch\fR), or NULL to not apply any filter.
.PP
Tcl allows a number of mathematical functions to be used in
expressions, such as \fBsin\fR, \fBcos\fR, and \fBhypot\fR.
\fBTcl_CreateMathFunc\fR allows applications to add additional functions
These functions are represented by commands in the namespace,
\fBtcl::mathfunc\fR. The \fBTcl_CreateMathFunc\fR function is
an obsolete way for applications to add additional functions
to those already provided by Tcl or to replace existing functions.
It should not be used by new applications, which should create
math functions using \fBTcl_CreateObjCommand\fR to create a command
in the \fBtcl::mathfunc\fR namespace.
.PP
In the \fBTcl_CreateMathFunc\fR interface,
\fIName\fR is the name of the function as it will appear in expressions.
If \fIname\fR doesn't already exist as a function then a new function
is created. If it does exist, then the existing function is replaced.
If \fIname\fR does not already exist in the \fB::tcl::mathfunc\fR
namespace, then a new command is created in that namespace.
If \fIname\fR does exist, then the existing function is replaced.
\fINumArgs\fR and \fIargTypes\fR describe the arguments to the function.
Each entry in the \fIargTypes\fR array must be
.VS 8.4
one of TCL_INT, TCL_DOUBLE, TCL_WIDE_INT,
or TCL_EITHER to indicate whether the corresponding argument must be an
one of \fBTCL_INT\fR, \fBTCL_DOUBLE\fR, \fBTCL_WIDE_INT\fR,
or \fBTCL_EITHER\fR to indicate whether the corresponding argument must be an
integer, a double-precision floating value, a wide (64-bit) integer,
or any, respectively.
.VE 8.4
.PP
Whenever the function is invoked in an expression Tcl will invoke
\fIproc\fR. \fIProc\fR should have arguments and result that match
the type \fBTcl_MathProc\fR:
.CS
typedef int Tcl_MathProc(
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
Tcl_Value *\fIargs\fR,
Tcl_Value *\fIresultPtr\fR);
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
Tcl_Value *\fIargs\fR,
Tcl_Value *\fIresultPtr\fR);
.CE
.PP
When \fIproc\fR is invoked the \fIclientData\fR and \fIinterp\fR
arguments will be the same as those passed to \fBTcl_CreateMathFunc\fR.
\fIArgs\fR will point to an array of \fInumArgs\fR Tcl_Value structures,
which describe the actual arguments to the function:
.VS 8.4
.CS
typedef struct Tcl_Value {
Tcl_ValueType \fItype\fR;
long \fIintValue\fR;
double \fIdoubleValue\fR;
Tcl_WideInt \fIwideValue\fR;
Tcl_ValueType \fItype\fR;
long \fIintValue\fR;
double \fIdoubleValue\fR;
Tcl_WideInt \fIwideValue\fR;
} Tcl_Value;
.CE
.PP
The \fItype\fR field indicates the type of the argument and is
one of TCL_INT, TCL_DOUBLE or TCL_WIDE_INT.
.VE 8.4
one of \fBTCL_INT\fR, \fBTCL_DOUBLE\fR or \fBTCL_WIDE_INT\fR.
It will match the \fIargTypes\fR value specified for the function unless
the \fIargTypes\fR value was TCL_EITHER. Tcl converts
the \fIargTypes\fR value was \fBTCL_EITHER\fR. Tcl converts
the argument supplied in the expression to the type requested in
\fIargTypes\fR, if that is necessary.
Depending on the value of the \fItype\fR field, the \fIintValue\fR,
.VS 8.4
\fIdoubleValue\fR or \fIwideValue\fR
.VE 8.4
field will contain the actual value of the argument.
.PP
\fIProc\fR should compute its result and store it either as an integer
in \fIresultPtr->intValue\fR or as a floating value in
\fIresultPtr->doubleValue\fR.
It should set also \fIresultPtr->type\fR to one of
.VS 8.4
TCL_INT, TCL_DOUBLE or TCL_WIDE_INT
.VE 8.4
\fBTCL_INT\fR, \fBTCL_DOUBLE\fR or \fBTCL_WIDE_INT\fR
to indicate which value was set.
Under normal circumstances \fIproc\fR should return TCL_OK.
Under normal circumstances \fIproc\fR should return \fBTCL_OK\fR.
If an error occurs while executing the function, \fIproc\fR should
return TCL_ERROR and leave an error message in the interpreter's result.
return \fBTCL_ERROR\fR and leave an error message in the interpreter's result.
.PP
.VS 8.4
\fBTcl_GetMathFuncInfo\fR retrieves the values associated with
function \fIname\fR that were passed to a preceding
\fBTcl_CreateMathFunc\fR call. Normally, the return code is
@@ -140,20 +136,21 @@ result.
If an error did not occur, the array reference placed in the variable
pointed to by \fIargTypesPtr\fR is newly allocated, and should be
released by passing it to \fBTcl_Free\fR. Some functions (the
standard set implemented in the core) are implemented directly at the
bytecode level; attempting to retrieve values for them causes a NULL
to be stored in the variable pointed to by \fIprocPtr\fR and the
variable pointed to by \fIclientDataPtr\fR will not be modified.
standard set implemented in the core, and those defined by placing
commands in the \fBtcl::mathfunc\fR namespace) do not have
argument type information; attempting to retrieve values for
them causes a NULL to be stored in the variable pointed to by
\fIprocPtr\fR and the variable pointed to by \fIclientDataPtr\fR
will not be modified. The variable pointed to by \fInumArgsPointer\fR
will contain -1, and no argument types will be stored in the variable
pointed to by \fIargTypesPointer\fR.
.PP
\fBTcl_ListMathFuncs\fR returns a Tcl object containing a list of all
the math functions defined in the interpreter whose name matches
\fIpattern\fR. In the case of an error, NULL is returned and an error
message is left in the interpreter result, and otherwise the returned
object will have a reference count of zero.
.VE
\fIpattern\fR. The returned object has a reference count of zero.
.SH "SEE ALSO"
expr(n), info(n), Tcl_CreateObjCommand(3), Tcl_Free(3), Tcl_NewListObj(3)
.SH KEYWORDS
expression, mathematical function
.SH "SEE ALSO"
expr(n), info(n), Tcl_Free(3), Tcl_NewListObj(3)
+22 -29
View File
@@ -28,17 +28,13 @@ int
int
\fBTcl_SetCommandInfo\fR(\fIinterp, cmdName, infoPtr\fR)
.sp
.VS 8.4
int
\fBTcl_GetCommandInfoFromToken\fR(\fItoken, infoPtr\fR)
.sp
int
\fBTcl_SetCommandInfoFromToken\fR(\fItoken, infoPtr\fR)
.VE
.sp
.VS 8.4
CONST char *
.VE
const char *
\fBTcl_GetCommandName\fR(\fIinterp, token\fR)
.sp
void
@@ -47,12 +43,10 @@ void
Tcl_Command
\fBTcl_GetCommandFromObj\fR(\fIinterp, objPtr\fR)
.SH ARGUMENTS
.AS Tcl_ObjCmdProc *deleteProc in/out
.AS Tcl_CmdDeleteProc *deleteProc in/out
.AP Tcl_Interp *interp in
Interpreter in which to create a new command or that contains a command.
.VS 8.4
.AP char *cmdName in
.VE
Name of command.
.AP Tcl_ObjCmdProc *proc in
Implementation of the new command: \fIproc\fR will be called whenever
@@ -96,11 +90,10 @@ and it returns NULL.
\fBTcl_ObjCmdProc\fR:
.CS
typedef int Tcl_ObjCmdProc(
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
int \fIobjc\fR,
.VS
Tcl_Obj *CONST \fIobjv\fR[]);
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
int \fIobjc\fR,
Tcl_Obj *const \fIobjv\fR[]);
.CE
When \fIproc\fR is invoked, the \fIclientData\fR and \fIinterp\fR parameters
will be copies of the \fIclientData\fR and \fIinterp\fR arguments given to
@@ -117,7 +110,7 @@ Additionally, when \fIproc\fR is invoked, it must not modify the contents
of the \fIobjv\fR array by assigning new pointer values to any element of the
array (for example, \fIobjv\fR[\fB2\fR] = \fBNULL\fR) because this will
cause memory to be lost and the runtime stack to be corrupted. The
\fBCONST\fR in the declaration of \fIobjv\fR will cause ANSI-compliant
\fBconst\fR in the declaration of \fIobjv\fR will cause ANSI-compliant
compilers to report any such attempted assignment as an error. However,
it is acceptable to modify the internal representation of any individual
object argument. For instance, the user may call
@@ -125,7 +118,6 @@ object argument. For instance, the user may call
representation of that object; that call may change the type of the object
that \fIobjv\fR[\fB2\fR] points at, but will not change where
\fIobjv\fR[\fB2\fR] points.
.VE
.PP
\fIproc\fR must return an integer code that is either \fBTCL_OK\fR,
\fBTCL_ERROR\fR, \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR.
@@ -168,7 +160,8 @@ application an opportunity to release any structures associated
with the command. \fIDeleteProc\fR should have arguments and
result that match the type \fBTcl_CmdDeleteProc\fR:
.CS
typedef void Tcl_CmdDeleteProc(ClientData \fIclientData\fR);
typedef void Tcl_CmdDeleteProc(
ClientData \fIclientData\fR);
.CE
The \fIclientData\fR argument will be the same as the \fIclientData\fR
argument passed to \fBTcl_CreateObjCommand\fR.
@@ -176,7 +169,7 @@ argument passed to \fBTcl_CreateObjCommand\fR.
\fBTcl_DeleteCommand\fR deletes a command from a command interpreter.
Once the call completes, attempts to invoke \fIcmdName\fR in
\fIinterp\fR will result in errors.
If \fIcmdName\fR isn't bound as a command in \fIinterp\fR then
If \fIcmdName\fR is not bound as a command in \fIinterp\fR then
\fBTcl_DeleteCommand\fR does nothing and returns -1; otherwise
it returns 0.
There are no restrictions on \fIcmdName\fR: it may refer to
@@ -206,14 +199,14 @@ pointed to by \fIinfoPtr\fR and returns 1.
A \fBTcl_CmdInfo\fR structure has the following fields:
.CS
typedef struct Tcl_CmdInfo {
int isNativeObjectProc;
Tcl_ObjCmdProc *objProc;
ClientData objClientData;
Tcl_CmdProc *proc;
ClientData clientData;
Tcl_CmdDeleteProc *deleteProc;
ClientData deleteData;
Tcl_Namespace *namespacePtr;
int \fIisNativeObjectProc\fR;
Tcl_ObjCmdProc *\fIobjProc\fR;
ClientData \fIobjClientData\fR;
Tcl_CmdProc *\fIproc\fR;
ClientData \fIclientData\fR;
Tcl_CmdDeleteProc *\fIdeleteProc\fR;
ClientData \fIdeleteData\fR;
Tcl_Namespace *\fInamespacePtr\fR;
} Tcl_CmdInfo;
.CE
The \fIisNativeObjectProc\fR field has the value 1
@@ -285,16 +278,16 @@ This name does not include any \fB::\fR namespace qualifiers.
The command corresponding to \fItoken\fR must not have been deleted.
The string returned by \fBTcl_GetCommandName\fR is in dynamic memory
owned by Tcl and is only guaranteed to retain its value as long as the
command isn't deleted or renamed; callers should copy the string if
command is not deleted or renamed; callers should copy the string if
they need to keep it for a long time.
.PP
\fBTcl_GetCommandFullName\fR produces the fully-qualified name
\fBTcl_GetCommandFullName\fR produces the fully qualified name
of a command from a command token.
The name, including all namespace prefixes,
is appended to the object specified by \fIobjPtr\fP.
is appended to the object specified by \fIobjPtr\fR.
.PP
\fBTcl_GetCommandFromObj\fR returns a token for the command
specified by the name in a \fBTcl_Obj\fP.
specified by the name in a \fBTcl_Obj\fR.
The command name is resolved relative to the current namespace.
Returns NULL if the command is not found.
.SH "SEE ALSO"
+33 -34
View File
@@ -8,7 +8,7 @@
.TH Tcl_CreateSlave 3 7.6 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_IsSafe, Tcl_MakeSafe, Tcl_CreateSlave, Tcl_GetSlave, Tcl_GetMaster, Tcl_GetInterpPath, Tcl_CreateAlias, Tcl_CreateAliasObj, Tcl_GetAlias, Tcl_GetAliasObj, Tcl_ExposeCommand, Tcl_HideCommand \- manage multiple Tcl interpreters, aliases and hidden commands.
Tcl_IsSafe, Tcl_MakeSafe, Tcl_CreateSlave, Tcl_GetSlave, Tcl_GetMaster, Tcl_GetInterpPath, Tcl_CreateAlias, Tcl_CreateAliasObj, Tcl_GetAlias, Tcl_GetAliasObj, Tcl_ExposeCommand, Tcl_HideCommand \- manage multiple Tcl interpreters, aliases and hidden commands
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -31,20 +31,21 @@ Tcl_Interp *
int
\fBTcl_GetInterpPath\fR(\fIaskingInterp, slaveInterp\fR)
.sp
.VS
int
\fBTcl_CreateAlias\fR(\fIslaveInterp, slaveCmd, targetInterp, targetCmd, argc, argv\fR)
\fBTcl_CreateAlias\fR(\fIslaveInterp, slaveCmd, targetInterp, targetCmd,
argc, argv\fR)
.sp
int
\fBTcl_CreateAliasObj\fR(\fIslaveInterp, slaveCmd, targetInterp, targetCmd, objc, objv\fR)
.VE
\fBTcl_CreateAliasObj\fR(\fIslaveInterp, slaveCmd, targetInterp, targetCmd,
objc, objv\fR)
.sp
int
\fBTcl_GetAlias\fR(\fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr, argcPtr, argvPtr\fR)
\fBTcl_GetAlias\fR(\fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr,
argcPtr, argvPtr\fR)
.sp
.VS
int
\fBTcl_GetAliasObj\fR(\fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr, objcPtr, objvPtr\fR)
\fBTcl_GetAliasObj\fR(\fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr,
objcPtr, objvPtr\fR)
.sp
int
\fBTcl_ExposeCommand\fR(\fIinterp, hiddenCmdName, cmdName\fR)
@@ -52,44 +53,46 @@ int
int
\fBTcl_HideCommand\fR(\fIinterp, cmdName, hiddenCmdName\fR)
.SH ARGUMENTS
.AS Tcl_InterpDeleteProc **hiddenCmdName
.AS "const char *const" **targetInterpPtr out
.AP Tcl_Interp *interp in
Interpreter in which to execute the specified command.
.AP "CONST char" *slaveName in
.AP "const char" *slaveName in
Name of slave interpreter to create or manipulate.
.AP int isSafe in
If non-zero, a ``safe'' slave that is suitable for running untrusted code
If non-zero, a
.QW safe
slave that is suitable for running untrusted code
is created, otherwise a trusted slave is created.
.AP Tcl_Interp *slaveInterp in
Interpreter to use for creating the source command for an alias (see
below).
.AP "CONST char" *slaveCmd in
.AP "const char" *slaveCmd in
Name of source command for alias.
.AP Tcl_Interp *targetInterp in
Interpreter that contains the target command for an alias.
.AP "CONST char" *targetCmd in
.AP "const char" *targetCmd in
Name of target command for alias in \fItargetInterp\fR.
.AP int argc in
Count of additional arguments to pass to the alias command.
.AP "CONST char * CONST" *argv in
.AP "const char *const" *argv in
Vector of strings, the additional arguments to pass to the alias command.
This storage is owned by the caller.
.AP int objc in
Count of additional object arguments to pass to the alias object command.
.AP Tcl_Object **objv in
.AP Tcl_Obj **objv in
Vector of Tcl_Obj structures, the additional object arguments to pass to
the alias object command.
This storage is owned by the caller.
.AP Tcl_Interp **targetInterpPtr in
Pointer to location to store the address of the interpreter where a target
command is defined for an alias.
.AP "CONST char" **targetCmdPtr out
.AP "const char" **targetCmdPtr out
Pointer to location to store the address of the name of the target command
for an alias.
.AP int *argcPtr out
Pointer to location to store count of additional arguments to be passed to
the alias. The location is in storage owned by the caller.
.AP "CONST char" ***argvPtr out
.AP "const char" ***argvPtr out
Pointer to location to store a vector of strings, the additional arguments
to pass to an alias. The location is in storage owned by the caller, the
vector of strings is owned by the called function.
@@ -101,17 +104,11 @@ Pointer to location to store a vector of Tcl_Obj structures, the additional
arguments to pass to an object alias command. The location is in storage
owned by the caller, the vector of Tcl_Obj structures is owned by the
called function.
.VS
.VS 8.4
.AP "CONST char" *cmdName in
.VE
.AP "const char" *cmdName in
Name of an exposed command to hide or create.
.VS 8.4
.AP "CONST char" *hiddenCmdName in
.VE
.AP "const char" *hiddenCmdName in
Name under which a hidden command is stored and with which it can be
exposed or invoked.
.VE
.BE
.SH DESCRIPTION
@@ -129,16 +126,21 @@ It also creates a slave command named \fIslaveName\fR in \fIinterp\fR which
allows \fIinterp\fR to manipulate the new slave.
If \fIisSafe\fR is zero, the command creates a trusted slave in which Tcl
code has access to all the Tcl commands.
If it is \fB1\fR, the command creates a ``safe'' slave in which Tcl code
has access only to set of Tcl commands defined as ``Safe Tcl''; see the
manual entry for the Tcl \fBinterp\fR command for details.
If it is \fB1\fR, the command creates a
.QW safe
slave in which Tcl code has access only to set of Tcl commands defined as
.QW "Safe Tcl" ;
see the manual entry for the Tcl \fBinterp\fR command for details.
If the creation of the new slave interpreter failed, \fBNULL\fR is returned.
.PP
\fBTcl_IsSafe\fR returns \fB1\fR if \fIinterp\fR is ``safe'' (was created
with the \fBTCL_SAFE_INTERPRETER\fR flag specified),
\fBTcl_IsSafe\fR returns \fB1\fR if \fIinterp\fR is
.QW safe
(was created with the \fBTCL_SAFE_INTERPRETER\fR flag specified),
\fB0\fR otherwise.
.PP
\fBTcl_MakeSafe\fR marks \fIinterp\fR as ``safe'', so that future
\fBTcl_MakeSafe\fR marks \fIinterp\fR as
.QW safe ,
so that future
calls to \fBTcl_IsSafe\fR will return 1. It also removes all known
potentially-unsafe core functionality (both commands and variables)
from \fIinterp\fR. However, it cannot know what parts of an extension
@@ -163,7 +165,6 @@ of the relative path succeeds, \fBTCL_OK\fR is returned, else
\fBTCL_ERROR\fR is returned and the \fIresult\fR field in
\fIaskingInterp\fR contains the error message.
.PP
.VS
\fBTcl_CreateAlias\fR creates an object command named \fIslaveCmd\fR in
\fIslaveInterp\fR that when invoked, will cause the command \fItargetCmd\fR
to be invoked in \fItargetInterp\fR. The arguments specified by the strings
@@ -180,7 +181,6 @@ restrictions on how they are related.
\fBTcl_CreateAliasObj\fR is similar to \fBTcl_CreateAlias\fR except
that it takes a vector of objects to pass as additional arguments instead
of a vector of strings.
.VE
.PP
\fBTcl_GetAlias\fR returns information about an alias \fIaliasName\fR
in \fIinterp\fR. Any of the result fields can be \fBNULL\fR, in
@@ -188,7 +188,6 @@ which case the corresponding datum is not returned. If a result field is
non\-\fBNULL\fR, the address indicated is set to the corresponding datum.
For example, if \fItargetNamePtr\fR is non\-\fBNULL\fR it is set to a
pointer to the string containing the name of the target command.
.VS
.PP
\fBTcl_GetAliasObj\fR is similar to \fBTcl_GetAlias\fR except that it
returns a pointer to a vector of Tcl_Obj structures instead of a vector of
+4 -5
View File
@@ -9,8 +9,7 @@
.TH Tcl_CreateTimerHandler 3 7.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_CreateTimerHandler, Tcl_DeleteTimerHandler \- call a procedure at a
given time
Tcl_CreateTimerHandler, Tcl_DeleteTimerHandler \- call a procedure at a given time
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -28,7 +27,7 @@ Procedure to invoke after \fImilliseconds\fR have elapsed.
.AP ClientData clientData in
Arbitrary one-word value to pass to \fIproc\fR.
.AP Tcl_TimerToken token in
Token for previously-created timer handler (the return value
Token for previously created timer handler (the return value
from some previous call to \fBTcl_CreateTimerHandler\fR).
.BE
@@ -43,7 +42,7 @@ dispatch events through \fBTcl_DoOneEvent\fR or through Tcl commands
such as \fBvwait\fR.
The call to \fIproc\fR may not be made at the exact time given by
\fImilliseconds\fR: it will be made at the next opportunity
after that time. For example, if \fBTcl_DoOneEvent\fR isn't
after that time. For example, if \fBTcl_DoOneEvent\fR is not
called until long after the time has elapsed, or if there
are other pending events to process before the call to
\fIproc\fR, then the call to \fIproc\fR will be delayed.
@@ -61,7 +60,7 @@ structure containing application-specific information about
what to do in \fIproc\fR.
.PP
\fBTcl_DeleteTimerHandler\fR may be called to delete a
previously-created timer handler. It deletes the handler
previously created timer handler. It deletes the handler
indicated by \fItoken\fR so that no call to \fIproc\fR
will be made; if that handler no longer exists
(e.g. because the time period has already elapsed and \fIproc\fR
+21 -22
View File
@@ -1,7 +1,7 @@
'\"
'\" Copyright (c) 1989-1993 The Regents of the University of California.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
'\" Copyright (c) 2002 by Kevin B. Kenny. All rights reserved.
'\" Copyright (c) 2002 by Kevin B. Kenny <kennykb@acm.org>. All rights reserved.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -23,7 +23,7 @@ Tcl_Trace
.sp
\fBTcl_DeleteTrace\fR(\fIinterp, trace\fR)
.SH ARGUMENTS
.AS Tcl_CmdObjTraceDeleteProc (clientData)()
.AS Tcl_CmdObjTraceDeleteProc *deleteProc
.AP Tcl_Interp *interp in
Interpreter containing command to be traced or untraced.
.AP int level in
@@ -36,14 +36,14 @@ A value of 0 means that commands at any level are traced.
.AP int flags in
Flags governing the trace execution. See below for details.
.AP Tcl_CmdObjTraceProc *objProc in
Procedure to call for each command that's executed. See below for
Procedure to call for each command that is executed. See below for
details of the calling sequence.
.AP Tcl_CmdTraceProc *proc in
Procedure to call for each command that's executed. See below for
Procedure to call for each command that is executed. See below for
details on the calling sequence.
.AP ClientData clientData in
Arbitrary one-word value to pass to \fIobjProc\fR or \fIproc\fR.
.AP Tcl_CmdObjTraceDeleteProc *deleteProc
.AP Tcl_CmdObjTraceDeleteProc *deleteProc in
Procedure to call when the trace is deleted. See below for details of
the calling sequence. A NULL pointer is permissible and results in no
callback when the trace is deleted.
@@ -65,13 +65,13 @@ interpreter.
\fBTcl_CmdObjTraceProc\fR:
.CS
typedef int \fBTcl_CmdObjTraceProc\fR(
\fBClientData\fR \fIclientData\fR,
\fBTcl_Interp\fR* \fIinterp\fR,
int \fIlevel\fR,
CONST char* \fIcommand\fR,
\fBTcl_Command\fR \fIcommandToken\fR,
int \fIobjc\fR,
\fBTcl_Obj\fR *CONST \fIobjv\fR[] );
\fBClientData\fR \fIclientData\fR,
\fBTcl_Interp\fR* \fIinterp\fR,
int \fIlevel\fR,
const char *\fIcommand\fR,
\fBTcl_Command\fR \fIcommandToken\fR,
int \fIobjc\fR,
\fBTcl_Obj\fR *const \fIobjv\fR[] );
.CE
The \fIclientData\fR and \fIinterp\fR parameters are copies of the
corresponding arguments given to \fBTcl_CreateTrace\fR.
@@ -141,8 +141,7 @@ When \fBTcl_DeleteTrace\fR is called, the interpreter invokes the
\fBTcl_CmdObjTraceDeleteProc\fR:
.CS
typedef void \fBTcl_CmdObjTraceDeleteProc\fR(
\fBClientData\fR \fIclientData\fR
);
\fBClientData\fR \fIclientData\fR);
.CE
The \fIclientData\fR parameter will be the same as the
\fIclientData\fR parameter that was originally passed to
@@ -156,14 +155,14 @@ that its \fIproc\fR parameter should have arguments and result that
match the type \fBTcl_CmdTraceProc\fR:
.CS
typedef void Tcl_CmdTraceProc(
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
int \fIlevel\fR,
char *\fIcommand\fR,
Tcl_CmdProc *\fIcmdProc\fR,
ClientData \fIcmdClientData\fR,
int \fIargc\fR,
CONST char *\fIargv\fR[]);
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
int \fIlevel\fR,
char *\fIcommand\fR,
Tcl_CmdProc *\fIcmdProc\fR,
ClientData \fIcmdClientData\fR,
int \fIargc\fR,
const char *\fIargv\fR[]);
.CE
The parameters to the \fIproc\fR callback are similar to those of the
\fIobjProc\fR callback above. The \fIcommandToken\fR is
+16 -12
View File
@@ -17,10 +17,10 @@ Tcl_DStringInit, Tcl_DStringAppend, Tcl_DStringAppendElement, Tcl_DStringStartSu
\fBTcl_DStringInit\fR(\fIdsPtr\fR)
.sp
char *
\fBTcl_DStringAppend\fR(\fIdsPtr, string, length\fR)
\fBTcl_DStringAppend\fR(\fIdsPtr, bytes, length\fR)
.sp
char *
\fBTcl_DStringAppendElement\fR(\fIdsPtr, string\fR)
\fBTcl_DStringAppendElement\fR(\fIdsPtr, element\fR)
.sp
\fBTcl_DStringStartSublist\fR(\fIdsPtr\fR)
.sp
@@ -42,13 +42,15 @@ char *
.sp
\fBTcl_DStringGetResult\fR(\fIinterp, dsPtr\fR)
.SH ARGUMENTS
.AS Tcl_DString newLength
.AS Tcl_DString newLength in/out
.AP Tcl_DString *dsPtr in/out
Pointer to structure that is used to manage a dynamic string.
.AP "CONST char" *string in
Pointer to characters to add to dynamic string.
.AP "const char" *bytes in
Pointer to characters to append to dynamic string.
.AP "const char" *element in
Pointer to characters to append as list element to dynamic string.
.AP int length in
Number of characters from string to add to dynamic string. If -1,
Number of bytes from \fIbytes\fR to add to dynamic string. If -1,
add all characters up to null terminating character.
.AP int newLength in
New length for dynamic string, not including null terminating
@@ -75,7 +77,7 @@ string.
.PP
\fBTcl_DStringAppend\fR adds new information to a dynamic string,
allocating more memory for the string if needed.
If \fIlength\fR is less than zero then everything in \fIstring\fR
If \fIlength\fR is less than zero then everything in \fIbytes\fR
is appended to the dynamic string; otherwise \fIlength\fR
specifies the number of bytes to append.
\fBTcl_DStringAppend\fR returns a pointer to the characters of
@@ -83,14 +85,16 @@ the new string. The string can also be retrieved from the
\fIstring\fR field of the Tcl_DString structure.
.PP
\fBTcl_DStringAppendElement\fR is similar to \fBTcl_DStringAppend\fR
except that it doesn't take a \fIlength\fR argument (it appends
all of \fIstring\fR) and it converts the string to a proper list element
except that it does not take a \fIlength\fR argument (it appends
all of \fIelement\fR) and it converts the string to a proper list element
before appending.
\fBTcl_DStringAppendElement\fR adds a separator space before the
new list element unless the new list element is the first in a
list or sub-list (i.e. either the current string is empty, or it
contains the single character ``{'', or the last two characters of
the current string are `` {'').
contains the single character
.QW { ,
or the last two characters of the current string are
.QW " {" ).
\fBTcl_DStringAppendElement\fR returns a pointer to the
characters of the new string.
.PP
@@ -128,7 +132,7 @@ will still need to be called.
This procedure is now deprecated. \fBTcl_DStringSetLength\fR should
be used instead.
.PP
\fBTcl_DStringFree\fR should be called when you're finished using
\fBTcl_DStringFree\fR should be called when you are finished using
the string. It frees up any memory that was allocated for the string
and reinitializes the string's value to an empty string.
.PP
+8 -8
View File
@@ -19,18 +19,18 @@ Tcl_DetachPids, Tcl_ReapDetachedProcs, Tcl_WaitPid \- manage child processes in
\fBTcl_ReapDetachedProcs\fR()
.sp
Tcl_Pid
\fBTcl_WaitPid\fR(\fIpid, statPtr, options\fR)
\fBTcl_WaitPid\fR(\fIpid, statusPtr, options\fR)
.SH ARGUMENTS
.AS int *statusPtr
.AS Tcl_Pid *statusPtr out
.AP int numPids in
Number of process ids contained in the array pointed to by \fIpidPtr\fR.
.AP int *pidPtr in
Address of array containing \fInumPids\fR process ids.
.AP Tcl_Pid pid in
The id of the process (pipe) to wait for.
.AP int* statPtr out
.AP int *statusPtr out
The result of waiting on a process (pipe). Either 0 or ECHILD.
.AP int options
.AP int options in
The options controlling the wait. WNOHANG specifies not to wait when
checking the process.
.BE
@@ -49,16 +49,16 @@ overflow, even if all the children have exited.
\fBTcl_DetachPids\fR may be called to ask Tcl to take responsibility
for one or more processes whose process ids are contained in the
\fIpidPtr\fR array passed as argument. The caller presumably
has started these processes running in background and doesn't
has started these processes running in background and does not
want to have to deal with them again.
.PP
\fBTcl_ReapDetachedProcs\fR invokes the \fBwaitpid\fR kernel call
on each of the background processes so that its state can be cleaned
up if it has exited. If the process hasn't exited yet,
\fBTcl_ReapDetachedProcs\fR doesn't wait for it to exit; it will check again
up if it has exited. If the process has not exited yet,
\fBTcl_ReapDetachedProcs\fR does not wait for it to exit; it will check again
the next time it is invoked.
Tcl automatically calls \fBTcl_ReapDetachedProcs\fR each time the
\fBexec\fR command is executed, so in most cases it isn't necessary
\fBexec\fR command is executed, so in most cases it is not necessary
for any code outside of Tcl to invoke \fBTcl_ReapDetachedProcs\fR.
However, if you call \fBTcl_DetachPids\fR in situations where the
\fBexec\fR command may never get executed, you may wish to call
+234
View File
@@ -0,0 +1,234 @@
'\"
'\" Copyright (c) 2003 Donal K. Fellows
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.so man.macros
.TH Tcl_DictObj 3 8.5 Tcl "Tcl Library Procedures"
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_NewDictObj, Tcl_DictObjPut, Tcl_DictObjGet, Tcl_DictObjRemove, Tcl_DictObjSize, Tcl_DictObjFirst, Tcl_DictObjNext, Tcl_DictObjDone, Tcl_DictObjPutKeyList, Tcl_DictObjRemoveKeyList \- manipulate Tcl objects as dictionaries
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
Tcl_Obj *
\fBTcl_NewDictObj\fR()
.sp
int
\fBTcl_DictObjGet\fR(\fIinterp, dictPtr, keyPtr, valuePtrPtr\fR)
.sp
int
\fBTcl_DictObjPut\fR(\fIinterp, dictPtr, keyPtr, valuePtr\fR)
.sp
int
\fBTcl_DictObjRemove\fR(\fIinterp, dictPtr, keyPtr\fR)
.sp
int
\fBTcl_DictObjSize\fR(\fIinterp, dictPtr, sizePtr\fR)
.sp
int
\fBTcl_DictObjFirst\fR(\fIinterp, dictPtr, searchPtr,
keyPtrPtr, valuePtrPtr, donePtr\fR)
.sp
void
\fBTcl_DictObjNext\fR(\fIsearchPtr, keyPtrPtr, valuePtrPtr, donePtr\fR)
.sp
void
\fBTcl_DictObjDone\fR(\fIsearchPtr\fR)
.sp
int
\fBTcl_DictObjPutKeyList\fR(\fIinterp, dictPtr, keyc, keyv, valuePtr\fR)
.sp
int
\fBTcl_DictObjRemoveKeyList\fR(\fIinterp, dictPtr, keyc, keyv\fR)
.SH ARGUMENTS
.AS Tcl_DictSearch "**valuePtrPtr" in/out
.AP Tcl_Interp *interp in
If an error occurs while converting an object to be a dictionary object,
an error message is left in the interpreter's result object
unless \fIinterp\fR is NULL.
.AP Tcl_Obj *dictPtr in/out
Points to the dictionary object to be manipulated.
If \fIdictPtr\fR does not already point to a dictionary object,
an attempt will be made to convert it to one.
.AP Tcl_Obj *keyPtr in
Points to the key for the key/value pair being manipulated within the
dictionary object.
.AP Tcl_Obj **keyPtrPtr out
Points to a variable that will have the key from a key/value pair
placed within it. May be NULL to indicate that the caller is not
interested in the key.
.AP Tcl_Obj *valuePtr in
Points to the value for the key/value pair being manipulate within the
dictionary object (or sub-object, in the case of
\fBTcl_DictObjPutKeyList\fR.)
.AP Tcl_Obj **valuePtrPtr out
Points to a variable that will have the value from a key/value pair
placed within it. For \fBTcl_DictObjFirst\fR and
\fBTcl_DictObjNext\fR, this may be NULL to indicate that the caller is
not interested in the value.
.AP int *sizePtr out
Points to a variable that will have the number of key/value pairs
contained within the dictionary placed within it.
.AP Tcl_DictSearch *searchPtr in/out
Pointer to record to use to keep track of progress in enumerating all
key/value pairs in a dictionary. The contents of the record will be
initialized by the call to \fBTcl_DictObjFirst\fR. If the enumerating
is to be terminated before all values in the dictionary have been
returned, the search record \fImust\fR be passed to
\fBTcl_DictObjDone\fR to enable the internal locks to be released.
.AP int *donePtr out
Points to a variable that will have a non-zero value written into it
when the enumeration of the key/value pairs in a dictionary has
completed, and a zero otherwise.
.AP int keyc in
Indicates the number of keys that will be supplied in the \fIkeyv\fR
array.
.AP "Tcl_Obj *const" *keyv in
Array of \fIkeyc\fR pointers to objects that
\fBTcl_DictObjPutKeyList\fR and \fBTcl_DictObjRemoveKeyList\fR will
use to locate the key/value pair to manipulate within the
sub-dictionaries of the main dictionary object passed to them.
.BE
.SH DESCRIPTION
.PP
Tcl dictionary objects have an internal representation that supports
efficient mapping from keys to values and which guarantees that the
particular ordering of keys within the dictionary remains the same
modulo any keys being deleted (which removes them from the order) or
added (which adds them to the end of the order). If reinterpreted as a
list, the values at the even-valued indices in the list will be the
keys of the dictionary, and each will be followed (in the odd-valued
index) by the value associated with that key.
.PP
The procedures described in this man page are used to
create, modify, index, and iterate over dictionary objects from C code.
.PP
\fBTcl_NewDictObj\fR creates a new, empty dictionary object. The
string representation of the object will be invalid, and the reference
count of the object will be zero.
.PP
\fBTcl_DictObjGet\fR looks up the given key within the given
dictionary and writes a pointer to the value associated with that key
into the variable pointed to by \fIvaluePtrPtr\fR, or a NULL if the
key has no mapping within the dictionary. The result of this
procedure is \fBTCL_OK\fR, or \fBTCL_ERROR\fR if the \fIdictPtr\fR cannot be
converted to a dictionary.
.PP
\fBTcl_DictObjPut\fR updates the given dictionary so that the given
key maps to the given value; any key may exist at most once in any
particular dictionary. The dictionary must not be shared, but the key
and value may be. This procedure may increase the reference count of
both key and value if it proves necessary to store them. Neither key
nor value should be NULL. The result of this procedure is \fBTCL_OK\fR, or
\fBTCL_ERROR\fR if the \fIdictPtr\fR cannot be converted to a dictionary.
.PP
\fBTcl_DictObjRemove\fR updates the given dictionary so that the given
key has no mapping to any value. The dictionary must not be shared,
but the key may be. The key actually stored in the dictionary will
have its reference count decremented if it was present. It is not an
error if the key did not previously exist. The result of this
procedure is \fBTCL_OK\fR, or \fBTCL_ERROR\fR if the \fIdictPtr\fR cannot be
converted to a dictionary.
.PP
\fBTcl_DictObjSize\fR updates the given variable with the number of
key/value pairs currently in the given dictionary. The result of this
procedure is \fBTCL_OK\fR, or \fBTCL_ERROR\fR if the \fIdictPtr\fR cannot be
converted to a dictionary.
.PP
\fBTcl_DictObjFirst\fR commences an iteration across all the key/value
pairs in the given dictionary, placing the key and value in the
variables pointed to by the \fIkeyPtrPtr\fR and \fIvaluePtrPtr\fR
arguments (which may be NULL to indicate that the caller is
uninterested in they key or variable respectively.) The next
key/value pair in the dictionary may be retrieved with
\fBTcl_DictObjNext\fR. Concurrent updates of the dictionary's
internal representation will not modify the iteration processing
unless the dictionary is unshared, when this will trigger premature
termination of the iteration instead (which Tcl scripts cannot trigger
via the \fBdict\fR command.) The \fIsearchPtr\fR argument points to a
piece of context that is used to identify which particular iteration
is being performed, and is initialized by the call to
\fBTcl_DictObjFirst\fR. The \fIdonePtr\fR argument points to a
variable that is updated to be zero of there are further key/value
pairs to be iterated over, or non-zero if the iteration is complete.
The order of iteration is implementation-defined. If the
\fIdictPtr\fR argument cannot be converted to a dictionary,
\fBTcl_DictObjFirst\fR returns \fBTCL_ERROR\fR and the iteration is not
commenced, and otherwise it returns \fBTCL_OK\fR.
.PP
When \fBTcl_DictObjFirst\fR is called upon a dictionary, a lock is placed on
the dictionary to enable that dictionary to be iterated over safely without
regard for whether the dictionary is modified during the iteration. Because of
this, once the iteration over a dictionary's keys has finished (whether
because all values have been iterated over as indicated by the variable
indicated by the \fIdonePtr\fR argument being set to one, or because no
further values are required) the \fBTcl_DictObjDone\fR function must be called
with the same \fIsearchPtr\fR as was passed to \fBTcl_DictObjFirst\fR so that
the internal locks can be released. Once a particular \fIsearchPtr\fR is
passed to \fBTcl_DictObjDone\fR, passing it to \fBTcl_DictObjNext\fR (without
first initializing it with \fBTcl_DictObjFirst\fR) will result in no values
being produced and the variable pointed to by \fIdonePtr\fR being set to one.
It is safe to call \fBTcl_DictObjDone\fR multiple times on the same
\fIsearchPtr\fR for each call to \fBTcl_DictObjFirst\fR.
.PP
The procedures \fBTcl_DictObjPutKeyList\fR and
\fBTcl_DictObjRemoveKeyList\fR are the close analogues of
\fBTcl_DictObjPut\fR and \fBTcl_DictObjRemove\fR respectively, except
that instead of working with a single dictionary, they are designed to
operate on a nested tree of dictionaries, with inner dictionaries
stored as values inside outer dictionaries. The \fIkeyc\fR and
\fIkeyv\fR arguments specify a list of keys (with outermost keys
first) that acts as a path to the key/value pair to be affected. Note
that there is no corresponding operation for reading a value for a
path as this is easy to construct from repeated use of
\fBTcl_DictObjGet\fR. With \fBTcl_DictObjPutKeyList\fR, nested
dictionaries are created for non-terminal keys where they do not
already exist. With \fBTcl_DictObjRemoveKeyList\fR, all non-terminal
keys must exist and have dictionaries as their values.
.SH EXAMPLE
Using the dictionary iteration interface to search determine if there
is a key that maps to itself:
.PP
.CS
Tcl_DictSearch search;
Tcl_Obj *key, *value;
int done;
/*
* Assume interp and objPtr are parameters. This is the
* idiomatic way to start an iteration over the dictionary; it
* sets a lock on the internal representation that ensures that
* there are no concurrent modification issues when normal
* reference count management is also used. The lock is
* released automatically when the loop is finished, but must
* be released manually when an exceptional exit from the loop
* is performed. However it is safe to try to release the lock
* even if we've finished iterating over the loop.
*/
if (\fBTcl_DictObjFirst\fR(interp, objPtr, &search,
&key, &value, &done) != TCL_OK) {
return TCL_ERROR;
}
for (; !done ; \fBTcl_DictObjNext\fR(&search, &key, &value, &done)) {
/*
* Note that strcmp() is not a good way of comparing
* objects and is just used here for demonstration
* purposes.
*/
if (!strcmp(Tcl_GetString(key), Tcl_GetString(value))) {
break;
}
}
\fBTcl_DictObjDone\fR(&search);
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(!done));
return TCL_OK;
.CE
.SH "SEE ALSO"
Tcl_NewObj, Tcl_DecrRefCount, Tcl_IncrRefCount, Tcl_InitObjHashTable
.SH KEYWORDS
dict, dict object, dictionary, dictionary object, hash table, iteration, object
+4 -4
View File
@@ -21,9 +21,9 @@ int
.AP int flags in
This parameter is normally zero. It may be an OR-ed combination
of any of the following flag bits:
TCL_WINDOW_EVENTS,
TCL_FILE_EVENTS, TCL_TIMER_EVENTS, TCL_IDLE_EVENTS, TCL_ALL_EVENTS, or
TCL_DONT_WAIT.
\fBTCL_WINDOW_EVENTS\fR, \fBTCL_FILE_EVENTS\fR,
\fBTCL_TIMER_EVENTS\fR, \fBTCL_IDLE_EVENTS\fR, \fBTCL_ALL_EVENTS\fR,
or \fBTCL_DONT_WAIT\fR.
.BE
.SH DESCRIPTION
@@ -71,7 +71,7 @@ Process all kinds of events: equivalent to OR-ing together all of the
above flags or specifying none of them.
.TP 27
\fBTCL_DONT_WAIT\fR \-
Don't sleep: process only events that are ready at the time of the
Do not sleep: process only events that are ready at the time of the
call.
.LP
If any of the flags \fBTCL_WINDOW_EVENTS\fR, \fBTCL_FILE_EVENTS\fR,
+2 -2
View File
@@ -30,7 +30,7 @@ Arbitrary one-word value to pass to \fIproc\fR.
\fBTcl_DoWhenIdle\fR arranges for \fIproc\fR to be invoked
when the application becomes idle. The application is
considered to be idle when \fBTcl_DoOneEvent\fR has been
called, couldn't find any events to handle, and is about
called, could not find any events to handle, and is about
to go to sleep waiting for an event to occur. At this
point all pending \fBTcl_DoWhenIdle\fR handlers are
invoked. For each call to \fBTcl_DoWhenIdle\fR there will
@@ -59,7 +59,7 @@ all of the handlers are removed. If no existing handlers match
\fIproc\fR and \fIclientData\fR then nothing happens.
.PP
\fBTcl_DoWhenIdle\fR is most useful in situations where
(a) a piece of work will have to be done but (b) it's
(a) a piece of work will have to be done but (b) it is
possible that something will happen in the near future
that will change what has to be done or require something
different to be done. \fBTcl_DoWhenIdle\fR allows the
+26 -39
View File
@@ -23,55 +23,42 @@ int
.SH ARGUMENTS
.AS Tcl_Interp doubleValue in/out
.AP double doubleValue in
A double-precision floating point value used to initialize or set a double object.
A double-precision floating-point value used to initialize or set a Tcl object.
.AP Tcl_Obj *objPtr in/out
For \fBTcl_SetDoubleObj\fR, this points to the object to be converted
to double type.
For \fBTcl_SetDoubleObj\fR, this points to the object in which to store a
double value.
For \fBTcl_GetDoubleFromObj\fR, this refers to the object
from which to get a double value;
if \fIobjPtr\fR does not already point to a double object,
an attempt will be made to convert it to one.
from which to retrieve a double value.
.AP Tcl_Interp *interp in/out
If an error occurs during conversion,
an error message is left in the interpreter's result object
unless \fIinterp\fR is NULL.
When non-NULL, an error message is left here when double value retrieval fails.
.AP double *doublePtr out
Points to place to store the double value
obtained from \fIobjPtr\fR.
Points to place to store the double value obtained from \fIobjPtr\fR.
.BE
.SH DESCRIPTION
.PP
These procedures are used to create, modify, and read
double Tcl objects from C code.
\fBTcl_NewDoubleObj\fR and \fBTcl_SetDoubleObj\fR
will create a new object of double type
or modify an existing object to have double type.
Both of these procedures set the object to have the
double-precision floating point value given by \fIdoubleValue\fR;
\fBTcl_NewDoubleObj\fR returns a pointer to a newly created object
with reference count zero.
Both procedures set the object's type to be double
and assign the double value to the object's internal representation
\fIdoubleValue\fR member.
\fBTcl_SetDoubleObj\fR invalidates any old string representation
and, if the object is not already a double object,
frees any old internal representation.
These procedures are used to create, modify, and read Tcl objects that
hold double-precision floating-point values.
.PP
\fBTcl_GetDoubleFromObj\fR attempts to return a double value
from the Tcl object \fIobjPtr\fR.
If the object is not already a double object,
it will attempt to convert it to one.
If an error occurs during conversion, it returns \fBTCL_ERROR\fR
and leaves an error message in the interpreter's result object
unless \fIinterp\fR is NULL.
Otherwise, it returns \fBTCL_OK\fR and stores the double value
in the address given by \fIdoublePtr\fR.
If the object is not already a double object,
the conversion will free any old internal representation.
\fBTcl_NewDoubleObj\fR creates and returns a new Tcl object initialized to
the double value \fIdoubleValue\fR. The returned Tcl object is unshared.
.PP
\fBTcl_SetDoubleObj\fR sets the value of an existing Tcl object pointed to
by \fIobjPtr\fR to the double value \fIdoubleValue\fR. The \fIobjPtr\fR
argument must point to an unshared Tcl object. Any attempt to set the value
of a shared Tcl object violates Tcl's copy-on-write policy. Any existing
string representation or internal representation in the unshared Tcl object
will be freed as a consequence of setting the new value.
.PP
\fBTcl_GetDoubleFromObj\fR attempts to retrieve a double value from the
Tcl object \fIobjPtr\fR. If the attempt succeeds, then \fBTCL_OK\fR is
returned, and the double value is written to the storage pointed to by
\fIdoublePtr\fR. If the attempt fails, then \fBTCL_ERROR\fR is returned,
and if \fIinterp\fR is non-NULL, an error message is left in \fIinterp\fR.
The \fBTcl_ObjType\fR of \fIobjPtr\fR may be changed to make subsequent
calls to \fBTcl_GetDoubleFromObj\fR more efficient.
'\" TODO: add discussion of treatment of NaN value
.SH "SEE ALSO"
Tcl_NewObj, Tcl_DecrRefCount, Tcl_IncrRefCount, Tcl_GetObjResult
.SH KEYWORDS
double, double object, double type, internal representation, object, object type, string representation
+3 -2
View File
@@ -7,7 +7,7 @@
.TH "Tcl_DumpActiveMemory" 3 8.1 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_DumpActiveMemory, Tcl_InitMemory, Tcl_ValidateAllMemory \- Validated memory allocation interface.
Tcl_DumpActiveMemory, Tcl_InitMemory, Tcl_ValidateAllMemory \- Validated memory allocation interface
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -22,9 +22,10 @@ void
\fBTcl_ValidateAllMemory\fR(\fIfileName, line\fR)
.SH ARGUMENTS
.AS Tcl_Interp *fileName
.AP Tcl_Interp *interp in
Tcl interpreter in which to add commands.
.AP "CONST char" *fileName in
.AP "const char" *fileName in
For \fBTcl_DumpActiveMemory\fR, name of the file to which memory
information will be written. For \fBTcl_ValidateAllMemory\fR, name of
the file from which the call is being made (normally \fB__FILE__\fR).
+164 -77
View File
@@ -8,7 +8,7 @@
.TH Tcl_GetEncoding 3 "8.1" Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_GetEncoding, Tcl_FreeEncoding, Tcl_ExternalToUtfDString, Tcl_ExternalToUtf, Tcl_UtfToExternalDString, Tcl_UtfToExternal, Tcl_WinTCharToUtf, Tcl_WinUtfToTChar, Tcl_GetEncodingName, Tcl_SetSystemEncoding, Tcl_GetEncodingNames, Tcl_CreateEncoding, Tcl_GetDefaultEncodingDir, Tcl_SetDefaultEncodingDir \- procedures for creating and using encodings.
Tcl_GetEncoding, Tcl_FreeEncoding, Tcl_GetEncodingFromObj, Tcl_ExternalToUtfDString, Tcl_ExternalToUtf, Tcl_UtfToExternalDString, Tcl_UtfToExternal, Tcl_WinTCharToUtf, Tcl_WinUtfToTChar, Tcl_GetEncodingName, Tcl_SetSystemEncoding, Tcl_GetEncodingNameFromEnvironment, Tcl_GetEncodingNames, Tcl_CreateEncoding, Tcl_GetEncodingSearchPath, Tcl_SetEncodingSearchPath, Tcl_GetDefaultEncodingDir, Tcl_SetDefaultEncodingDir \- procedures for creating and using encodings
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -19,19 +19,24 @@ Tcl_Encoding
void
\fBTcl_FreeEncoding\fR(\fIencoding\fR)
.sp
.VS 8.5
int
\fBTcl_GetEncodingFromObj\fR(\fIinterp, objPtr, encodingPtr\fR)
.VE 8.5
.sp
char *
\fBTcl_ExternalToUtfDString\fR(\fIencoding, src, srcLen, dstPtr\fR)
.sp
int
\fBTcl_ExternalToUtf\fR(\fIinterp, encoding, src, srcLen, flags, statePtr, dst, dstLen, srcReadPtr, dstWrotePtr,
dstCharsPtr\fR)
.sp
char *
char *
\fBTcl_UtfToExternalDString\fR(\fIencoding, src, srcLen, dstPtr\fR)
.sp
int
\fBTcl_UtfToExternal\fR(\fIinterp, encoding, src, srcLen, flags, statePtr, dst, dstLen, srcReadPtr, dstWrotePtr,
dstCharsPtr\fR)
\fBTcl_ExternalToUtf\fR(\fIinterp, encoding, src, srcLen, flags, statePtr,
dst, dstLen, srcReadPtr, dstWrotePtr, dstCharsPtr\fR)
.sp
int
\fBTcl_UtfToExternal\fR(\fIinterp, encoding, src, srcLen, flags, statePtr,
dst, dstLen, srcReadPtr, dstWrotePtr, dstCharsPtr\fR)
.sp
char *
\fBTcl_WinTCharToUtf\fR(\fItsrc, srcLen, dstPtr\fR)
@@ -39,41 +44,60 @@ char *
TCHAR *
\fBTcl_WinUtfToTChar\fR(\fIsrc, srcLen, dstPtr\fR)
.sp
CONST char *
const char *
\fBTcl_GetEncodingName\fR(\fIencoding\fR)
.sp
int
\fBTcl_SetSystemEncoding\fR(\fIinterp, name\fR)
.sp
.VS 8.5
const char *
\fBTcl_GetEncodingNameFromEnvironment\fR(\fIbufPtr\fR)
.VE 8.5
.sp
void
\fBTcl_GetEncodingNames\fR(\fIinterp\fR)
.sp
Tcl_Encoding
\fBTcl_CreateEncoding\fR(\fItypePtr\fR)
.sp
CONST char *
.VS 8.5
Tcl_Obj *
\fBTcl_GetEncodingSearchPath\fR()
.sp
int
\fBTcl_SetEncodingSearchPath\fR(\fIsearchPath\fR)
.VE 8.5
.sp
const char *
\fBTcl_GetDefaultEncodingDir\fR(\fIvoid\fR)
.sp
void
\fBTcl_SetDefaultEncodingDir\fR(\fIpath\fR)
.SH ARGUMENTS
.AS Tcl_EncodingState *dstWrotePtr
.AS "const Tcl_EncodingType" *dstWrotePtr in/out
.AP Tcl_Interp *interp in
Interpreter to use for error reporting, or NULL if no error reporting is
desired.
.AP "CONST char" *name in
.AP "const char" *name in
Name of encoding to load.
.AP Tcl_Encoding encoding in
The encoding to query, free, or use for converting text. If \fIencoding\fR is
NULL, the current system encoding is used.
.AP "CONST char" *src in
.AP Tcl_Obj *objPtr in
.VS 8.5
Name of encoding to get token for.
.VE 8.5
.AP Tcl_Encoding *encodingPtr out
.VS 8.5
Points to storage where encoding token is to be written.
.VE 8.5
.AP "const char" *src in
For the \fBTcl_ExternalToUtf\fR functions, an array of bytes in the
specified encoding that are to be converted to UTF-8. For the
\fBTcl_UtfToExternal\fR and \fBTcl_WinUtfToTChar\fR functions, an array of
UTF-8 characters to be converted to the specified encoding.
.AP "CONST TCHAR" *tsrc in
.AP "const TCHAR" *tsrc in
An array of Windows TCHAR characters to convert to UTF-8.
.AP int srcLen in
Length of \fIsrc\fR or \fItsrc\fR in bytes. If the length is negative, the
@@ -83,21 +107,21 @@ Pointer to an uninitialized or free \fBTcl_DString\fR in which the converted
result will be stored.
.AP int flags in
Various flag bits OR-ed together.
TCL_ENCODING_START signifies that the
\fBTCL_ENCODING_START\fR signifies that the
source buffer is the first block in a (potentially multi-block) input
stream, telling the conversion routine to reset to an initial state and
perform any initialization that needs to occur before the first byte is
converted. TCL_ENCODING_END signifies that the source buffer is the last
converted. \fBTCL_ENCODING_END\fR signifies that the source buffer is the last
block in a (potentially multi-block) input stream, telling the conversion
routine to perform any finalization that needs to occur after the last
byte is converted and then to reset to an initial state.
TCL_ENCODING_STOPONERROR signifies that the conversion routine should
return immediately upon reading a source character that doesn't exist in
\fBTCL_ENCODING_STOPONERROR\fR signifies that the conversion routine should
return immediately upon reading a source character that does not exist in
the target encoding; otherwise a default fallback character will
automatically be substituted.
.AP Tcl_EncodingState *statePtr in/out
Used when converting a (generally long or indefinite length) byte stream
in a piece by piece fashion. The conversion routine stores its current
in a piece-by-piece fashion. The conversion routine stores its current
state in \fI*statePtr\fR after \fIsrc\fR (the buffer containing the
current piece) has been converted; that state information must be passed
back when converting the next piece of the stream so the conversion
@@ -120,9 +144,17 @@ buffer as a result of the conversion. May be NULL.
.AP int *dstCharsPtr out
Filled with the number of characters that correspond to the number of bytes
stored in the output buffer. May be NULL.
.AP Tcl_EncodingType *typePtr in
.AP Tcl_DString *bufPtr out
.VS 8.5
Storage for the prescribed system encoding name.
.VE 8.5
.AP "const Tcl_EncodingType" *typePtr in
Structure that defines a new type of encoding.
.AP "CONST char" *path in
.AP Tcl_Obj *searchPath in
.VS 8.5
List of filesystem directories in which to search for encoding data files.
.VE 8.5
.AP "const char" *path in
A path to the location of the encoding file.
.BE
.SH INTRODUCTION
@@ -149,7 +181,7 @@ platform-independent manner.
.SH DESCRIPTION
.PP
\fBTcl_GetEncoding\fR finds an encoding given its \fIname\fR. The name may
refer to a builtin Tcl encoding, a user-defined encoding registered by
refer to a built-in Tcl encoding, a user-defined encoding registered by
calling \fBTcl_CreateEncoding\fR, or a dynamically-loadable encoding
file. The return value is a token that represents the encoding and can be
used in subsequent calls to procedures such as \fBTcl_GetEncodingName\fR,
@@ -170,6 +202,20 @@ anywhere (i.e., it has been freed as many times as it has been gotten)
\fBTcl_FreeEncoding\fR will release all storage the encoding was using
and delete it from the database.
.PP
.VS 8.5
\fBTcl_GetEncodingFromObj\fR treats the string representation of
\fIobjPtr\fR as an encoding name, and finds an encoding with that
name, just as \fBTcl_GetEncoding\fR does. When an encoding is found,
it is cached within the \fBobjPtr\fR value for future reference, the
\fBTcl_Encoding\fR token is written to the storage pointed to by
\fIencodingPtr\fR, and the value \fBTCL_OK\fR is returned. If no such
encoding is found, the value \fBTCL_ERROR\fR is returned, and no
writing to \fB*\fR\fIencodingPtr\fR takes place. Just as with
\fBTcl_GetEncoding\fR, the caller should call \fBTcl_FreeEncoding\fR
on the resulting encoding token when that token will no longer be
used.
.VE 8.5
.PP
\fBTcl_ExternalToUtfDString\fR converts a source buffer \fIsrc\fR from the
specified \fIencoding\fR into UTF-8. The converted bytes are stored in
\fIdstPtr\fR, which is then null-terminated. The caller should eventually
@@ -192,7 +238,7 @@ All bytes of \fIsrc\fR were converted.
The destination buffer was not large enough for all of the converted data; as
many characters as could fit were converted though.
.IP \fBTCL_CONVERT_MULTIBYTE\fR 29
The last fews bytes in the source buffer were the beginning of a multibyte
The last few bytes in the source buffer were the beginning of a multibyte
sequence, but more bytes were needed to complete this sequence. A
subsequent call to the conversion routine should pass a buffer containing
the unconverted bytes that remained in \fIsrc\fR plus some further bytes
@@ -204,7 +250,7 @@ if the input stream has been damaged or if the input encoding method was
misidentified.
.IP \fBTCL_CONVERT_UNKNOWN\fR 29
The source buffer contained a character that could not be represented in
the target encoding and TCL_ENCODING_STOPONERROR was specified.
the target encoding and \fBTCL_ENCODING_STOPONERROR\fR was specified.
.RE
.LP
\fBTcl_UtfToExternalDString\fR converts a source buffer \fIsrc\fR from UTF-8
@@ -228,19 +274,26 @@ is filled with the corresponding number of bytes that were stored in
\fBTcl_WinUtfToTChar\fR and \fBTcl_WinTCharToUtf\fR are
Windows-only convenience
functions for converting between UTF-8 and Windows strings. On Windows 95
(as with the Macintosh and Unix operating systems),
all strings exchanged between Tcl and the operating system are "char"
(as with the Unix operating system),
all strings exchanged between Tcl and the operating system are
.QW "char"
based. On Windows NT, some strings exchanged between Tcl and the
operating system are "char" oriented while others are in Unicode. By
operating system are
.QW "char"
oriented while others are in Unicode. By
convention, in Windows a TCHAR is a character in the ANSI code page
on Windows 95 and a Unicode character on Windows NT.
.PP
If you planned to use the same "char" based interfaces on both Windows
If you planned to use the same
.QW "char"
based interfaces on both Windows
95 and Windows NT, you could use \fBTcl_UtfToExternal\fR and
\fBTcl_ExternalToUtf\fR (or their \fBTcl_DString\fR equivalents) with an
encoding of NULL (the current system encoding). On the other hand,
if you planned to use the Unicode interface when running on Windows NT
and the "char" interfaces when running on Windows 95, you would have
and the
.QW "char"
interfaces when running on Windows 95, you would have
to perform the following type of test over and over in your program
(as represented in pseudo-code):
.CS
@@ -250,6 +303,7 @@ if (running NT) {
Tcl_FreeEncoding(encoding);
} else {
nativeBuffer <- Tcl_UtfToExternal(NULL, utfBuffer);
}
.CE
\fBTcl_WinUtfToTChar\fR and \fBTcl_WinTCharToUtf\fR automatically
handle this test and use the proper encoding based on the current
@@ -269,11 +323,20 @@ was used to create the encoding. The string returned by
whenever the user passes a NULL value for the \fIencoding\fR argument to
any of the other encoding functions. If \fIname\fR is NULL, the system
encoding is reset to the default system encoding, \fBbinary\fR. If the
name did not refer to any known or loadable encoding, TCL_ERROR is
name did not refer to any known or loadable encoding, \fBTCL_ERROR\fR is
returned and an error message is left in \fIinterp\fR. Otherwise, this
procedure increments the reference count of the new system encoding,
decrements the reference count of the old system encoding, and returns
TCL_OK.
\fBTCL_OK\fR.
.PP
.VS 8.5
\fBTcl_GetEncodingNameFromEnvironment\fR provides a means for the Tcl
library to report the encoding name it believes to be the correct one
to use as the system encoding, based on system calls and examination of
the environment suitable for the platform. It accepts \fIbufPtr\fR,
a pointer to an uninitialized or freed \fBTcl_DString\fR and writes
the encoding name to it. The \fBTcl_DStringValue\fR is returned.
.VE 8.5
.PP
\fBTcl_GetEncodingNames\fR sets the \fIinterp\fR result to a list
consisting of the names of all the encodings that are currently defined
@@ -301,12 +364,12 @@ convert between this encoding and UTF-8. It is defined as follows:
.PP
.CS
typedef struct Tcl_EncodingType {
CONST char *\fIencodingName\fR;
Tcl_EncodingConvertProc *\fItoUtfProc\fR;
Tcl_EncodingConvertProc *\fIfromUtfProc\fR;
Tcl_EncodingFreeProc *\fIfreeProc\fR;
ClientData \fIclientData\fR;
int \fInullSize\fR;
const char *\fIencodingName\fR;
Tcl_EncodingConvertProc *\fItoUtfProc\fR;
Tcl_EncodingConvertProc *\fIfromUtfProc\fR;
Tcl_EncodingFreeProc *\fIfreeProc\fR;
ClientData \fIclientData\fR;
int \fInullSize\fR;
} Tcl_EncodingType;
.CE
.PP
@@ -336,16 +399,16 @@ type \fBTcl_EncodingConvertProc\fR:
.PP
.CS
typedef int Tcl_EncodingConvertProc(
ClientData \fIclientData\fR,
CONST char *\fIsrc\fR,
int \fIsrcLen\fR,
int \fIflags\fR,
Tcl_Encoding *\fIstatePtr\fR,
char *\fIdst\fR,
int \fIdstLen\fR,
int *\fIsrcReadPtr\fR,
int *\fIdstWrotePtr\fR,
int *\fIdstCharsPtr\fR);
ClientData \fIclientData\fR,
const char *\fIsrc\fR,
int \fIsrcLen\fR,
int \fIflags\fR,
Tcl_EncodingState *\fIstatePtr\fR,
char *\fIdst\fR,
int \fIdstLen\fR,
int *\fIsrcReadPtr\fR,
int *\fIdstWrotePtr\fR,
int *\fIdstCharsPtr\fR);
.CE
.PP
The \fItoUtfProc\fR and \fIfromUtfProc\fR procedures are called by the
@@ -367,20 +430,42 @@ The callback procedure \fIfreeProc\fR, if non-NULL, should match the type
\fBTcl_EncodingFreeProc\fR:
.CS
typedef void Tcl_EncodingFreeProc(
ClientData \fIclientData\fR);
ClientData \fIclientData\fR);
.CE
.PP
This \fIfreeProc\fR function is called when the encoding is deleted. The
\fIclientData\fR parameter is the same as the \fIclientData\fR field
specified to \fBTcl_CreateEncoding\fR when the encoding was created.
.PP
.VS 8.5
\fBTcl_GetEncodingSearchPath\fR and \fBTcl_SetEncodingSearchPath\fR
are called to access and set the list of filesystem directories searched
for encoding data files.
.PP
The value returned by \fBTcl_GetEncodingSearchPath\fR
is the value stored by the last successful call to
\fBTcl_SetEncodingSearchPath\fR. If no calls to
\fBTcl_SetEncodingSearchPath\fR have occurred, Tcl will compute an initial
value based on the environment. There is one encoding search path for the
entire process, shared by all threads in the process.
.PP
\fBTcl_SetEncodingSearchPath\fR stores \fIsearchPath\fR and returns
\fBTCL_OK\fR, unless \fIsearchPath\fR is not a valid Tcl list, which
causes \fBTCL_ERROR\fR to be returned. The elements of \fIsearchPath\fR
are not verified as existing readable filesystem directories. When
searching for encoding data files takes place, and non-existent or
non-readable filesystem directories on the \fIsearchPath\fR are silently
ignored.
.PP
\fBTcl_GetDefaultEncodingDir\fR and \fBTcl_SetDefaultEncodingDir\fR
access and set the directory to use when locating the default encoding
files. If this value is not NULL, the \fBTclpInitLibraryPath\fR routine
appends the path to the head of the search path, and uses this path as
the first place to look into when trying to locate the encoding file.
are obsolete interfaces best replaced with calls to
\fBTcl_GetEncodingSearchPath\fR and \fBTcl_SetEncodingSearchPath\fR.
They are called to access and set the first element of the \fIsearchPath\fR
list. Since Tcl searches \fIsearchPath\fR for encoding data files in
list order, these routines establish the
.QW default
directory in which to find encoding data files.
.VE 8.5
.SH "ENCODING FILES"
Space would prohibit precompiling into Tcl every possible encoding
algorithm, so many encodings are stored on disk as dynamically-loadable
@@ -392,23 +477,25 @@ external encoding may consist of single-byte, multi-byte, or double-byte
characters.
.PP
Each dynamically-loadable encoding is represented as a text file. The
initial line of the file, beginning with a ``#'' symbol, is a comment
initial line of the file, beginning with a
.QW #
symbol, is a comment
that provides a human-readable description of the file. The next line
identifies the type of encoding file. It can be one of the following
letters:
.IP "[1] \fBS\fR"
.IP "[1] \fBS\fR"
A single-byte encoding, where one character is always one byte long in the
encoding. An example is \fBiso8859-1\fR, used by many European languages.
.IP "[2] \fBD\fR"
.IP "[2] \fBD\fR"
A double-byte encoding, where one character is always two bytes long in the
encoding. An example is \fBbig5\fR, used for Chinese text.
.IP "[3] \fBM\fR"
.IP "[3] \fBM\fR"
A multi-byte encoding, where one character may be either one or two bytes long.
Certain bytes are a lead bytes, indicating that another byte must follow
Certain bytes are lead bytes, indicating that another byte must follow
and that together the two bytes represent one character. Other bytes are not
lead bytes and represent themselves. An example is \fBshiftjis\fR, used by
many Japanese computers.
.IP "[4] \fBE\fR"
.IP "[4] \fBE\fR"
An escape-sequence encoding, specifying that certain sequences of bytes
do not represent characters, but commands that describe how following bytes
should be interpreted.
@@ -478,7 +565,7 @@ and 0x8163 in \fBshiftjis\fR map to 203E and 2026 in Unicode, respectively.
Following the first page will be all the other pages, each in the same
format as the first: one number identifying the page followed by 256
double-byte Unicode characters. If a character in the encoding maps to the
Unicode character 0000, it means that the character doesn't actually exist.
Unicode character 0000, it means that the character does not actually exist.
If all characters on a page would map to 0000, that page can be omitted.
.PP
Case [4] is the escape-sequence encoding file. The lines in an this type of
@@ -490,13 +577,13 @@ encoding:
E
init {}
final {}
iso8859-1 \\x1b(B
jis0201 \\x1b(J
jis0208 \\x1b$@
jis0208 \\x1b$B
jis0212 \\x1b$(D
gb2312 \\x1b$A
ksc5601 \\x1b$(C
iso8859-1 \ex1b(B
jis0201 \ex1b(J
jis0208 \ex1b$@
jis0208 \ex1b$B
jis0212 \ex1b$(D
gb2312 \ex1b$A
ksc5601 \ex1b$(C
.CE
.PP
In the file, the first column represents an option and the second column
@@ -505,16 +592,16 @@ the first character is converted, while \fBfinal\fR is a string to emit
or expect after the last character. All other options are names of
table-based encodings; the associated value is the escape-sequence that
marks that encoding. Tcl syntax is used for the values; in the above
example, for instance, ``\fB{}\fR'' represents the empty string and
``\fB\\x1b\fR'' represents character 27.
example, for instance,
.QW \fB{}\fR
represents the empty string and
.QW \fB\ex1b\fR
represents character 27.
.PP
When \fBTcl_GetEncoding\fR encounters an encoding \fIname\fR that has not
been loaded, it attempts to load an encoding file called \fIname\fB.enc\fR
from the \fBencoding\fR subdirectory of each directory specified in the
library path \fB$tcl_libPath\fR. If the encoding file exists, but is
from the \fBencoding\fR subdirectory of each directory that Tcl searches
for its script library. If the encoding file exists, but is
malformed, an error message will be left in \fIinterp\fR.
.SH KEYWORDS
utf, encoding, convert
+188
View File
@@ -0,0 +1,188 @@
'\"
'\" Copyright (c) 2005 Donal K. Fellows
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
'\" This documents the C API introduced in TIP#235
'\"
.so man.macros
.TH Tcl_Ensemble 3 8.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_CreateEnsemble, Tcl_FindEnsemble, Tcl_GetEnsembleFlags, Tcl_GetEnsembleMappingDict, Tcl_GetEnsembleNamespace, Tcl_GetEnsembleUnknownHandler, Tcl_GetEnsembleSubcommandList, Tcl_IsEnsemble, Tcl_SetEnsembleFlags, Tcl_SetEnsembleMappingDict, Tcl_SetEnsembleSubcommandList, Tcl_SetEnsembleUnknownHandler \- manipulate ensemble commands
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
Tcl_Command
\fBTcl_CreateEnsemble\fR(\fIinterp, name, namespacePtr, ensFlags\fR)
.sp
Tcl_Command
\fBTcl_FindEnsemble\fR(\fIinterp, cmdNameObj, flags\fR)
.sp
int
\fBTcl_IsEnsemble\fR(\fItoken\fR)
.sp
int
\fBTcl_GetEnsembleFlags\fR(\fIinterp, token, ensFlagsPtr\fR)
.sp
int
\fBTcl_SetEnsembleFlags\fR(\fIinterp, token, ensFlags\fR)
.sp
int
\fBTcl_GetEnsembleMappingDict\fR(\fIinterp, token, dictObjPtr\fR)
.sp
int
\fBTcl_SetEnsembleMappingDict\fR(\fIinterp, token, dictObj\fR)
.sp
int
\fBTcl_GetEnsembleSubcommandList\fR(\fIinterp, token, listObjPtr\fR)
.sp
int
\fBTcl_SetEnsembleSubcommandList\fR(\fIinterp, token, listObj\fR)
.sp
int
\fBTcl_GetEnsembleUnknownHandler\fR(\fIinterp, token, listObjPtr\fR)
.sp
int
\fBTcl_SetEnsembleUnknownHandler\fR(\fIinterp, token, listObj\fR)
.sp
int
\fBTcl_GetEnsembleNamespace\fR(\fIinterp, token, namespacePtrPtr\fR)
.SH ARGUMENTS
.AS Tcl_Namespace **namespacePtrPtr in/out
.AP Tcl_Interp *interp in/out
The interpreter in which the ensemble is to be created or found. Also
where error result messages are written. The functions whose names
start with \fBTcl_GetEnsemble\fR may have a NULL for the \fIinterp\fR,
but all other functions must not.
.AP "const char" *name in
The name of the ensemble command to be created.
.AP Tcl_Namespace *namespacePtr in
The namespace to which the ensemble command is to be bound, or NULL
for the current namespace.
.AP int ensFlags in
An ORed set of flag bits describing the basic configuration of the
ensemble. Currently only one bit has meaning, TCL_ENSEMBLE_PREFIX,
which is present when the ensemble command should also match
unambiguous prefixes of subcommands.
.AP Tcl_Obj *cmdNameObj in
A value holding the name of the ensemble command to look up.
.AP int flags in
An ORed set of flag bits controlling the behavior of
\fBTcl_FindEnsemble\fR. Currently only TCL_LEAVE_ERR_MSG is supported.
.AP Tcl_Command token in
A normal command token that refers to an ensemble command, or which
you wish to use for testing as an ensemble command in \fBTcl_IsEnsemble\fR.
.AP int *ensFlagsPtr out
Pointer to a variable into which to write the current ensemble flag
bits; currently only the bit TCL_ENSEMBLE_PREFIX is defined.
.AP Tcl_Obj *dictObj in
A dictionary value to use for the subcommand to implementation command
prefix mapping dictionary in the ensemble. May be NULL if the mapping
dictionary is to be removed.
.AP Tcl_Obj **dictObjPtr out
Pointer to a variable into which to write the current ensemble mapping
dictionary.
.AP Tcl_Obj *listObj in
A list value to use for the defined list of subcommands in the
dictionary or the unknown subcommmand handler command prefix. May be
NULL if the subcommand list or unknown handler are to be removed.
.AP Tcl_Obj **listObjPtr out
Pointer to a variable into which to write the current defiend list of
subcommands or the current unknown handler prefix.
.AP Tcl_Namespace **namespacePtrPtr out
Pointer to a variable into which to write the handle of the namespace
to which the ensemble is bound.
.BE
.SH DESCRIPTION
An ensemble is a command, bound to some namespace, which consists of a
collection of subcommands implemented by other Tcl commands. The first
argument to the ensemble command is always interpreted as a selector
that states what subcommand to execute.
.PP
Ensembles are created using \fBTcl_CreateEnsemble\fR, which takes four
arguments: the interpreter to work within, the name of the ensemble to
create, the namespace within the interpreter to bind the ensemble to,
and the default set of ensemble flags. The result of the function is
the command token for the ensemble, which may be used to further
configure the ensemble using the API described below in \fBENSEMBLE
PROPERTIES\fR.
.PP
Given the name of an ensemble command, the token for that command may
be retrieved using \fBTcl_FindEnsemble\fR. If the given command name
(in \fIcmdNameObj\fR) does not refer to an ensemble command, the
result of the function is NULL and (if the TCL_LEAVE_ERR_MSG bit is
set in \fIflags\fR) an error message is left in the interpreter
result.
.PP
A command token may be checked to see if it refers to an ensemble
using \fBTcl_IsEnsemble\fR. This returns 1 if the token refers to an
ensemble, or 0 otherwise.
.SS "ENSEMBLE PROPERTIES"
Every ensemble has four read-write properties and a read-only
property. The properties are:
.TP
\fBflags\fR (read-write)
The set of flags for the ensemble, expressed as a
bit-field. Currently, the only public flag is TCL_ENSEMBLE_PREFIX
which is set when unambiguous prefixes of subcommands are permitted to
be resolved to implementations as well as exact matches. The flags may
be read and written using \fBTcl_GetEnsembleFlags\fR and
\fBTcl_SetEnsembleFlags\fR respectively. The result of both of those
functions is a Tcl result code (TCL_OK, or TCL_ERROR if the token does
not refer to an ensemble).
.TP
\fBmapping dictionary\fR (read-write)
A dictionary containing a mapping from subcommand names to lists of
words to use as a command prefix (replacing the first two words of the
command which are the ensemble command itself and the subcommand
name), or NULL if every subcommand is to be mapped to the command with
the same unqualified name in the ensemble's bound namespace. Defaults
to NULL. May be read and written using
\fBTcl_GetEnsembleMappingDict\fR and \fBTcl_SetEnsembleMappingDict\fR
respectively. The result of both of those functions is a Tcl result
code (TCL_OK, or TCL_ERROR if the token does not refer to an
ensemble) and the dictionary obtained from
\fBTcl_GetEnsembleMappingDict\fR should always be treated as immutable
even if it is unshared.
All command names in prefixes set via \fBTcl_SetEnsembleMappingDict\fR
must be fully qualified.
.TP
\fBsubcommand list\fR (read-write)
A list of all the subcommand names for the ensemble, or NULL if this
is to be derived from either the keys of the mapping dictionary (see
above) or (if that is also NULL) from the set of commands exported by
the bound namespace. May be read and written using
\fBTcl_GetEnsembleSubcommandList\fR and
\fBTcl_SetEnsembleSubcommandList\fR respectively. The result of both
of those functions is a Tcl result code (TCL_OK, or TCL_ERROR if the
token does not refer to an ensemble) and the list obtained from
\fBTcl_GetEnsembleSubcommandList\fR should always be treated as
immutable even if it is unshared.
.TP
\fBunknown subcommand handler command prefix\fR (read-write)
A list of words to prepend on the front of any subcommand when the
subcommand is unknown to the ensemble (according to the current prefix
handling rule); see the \fBnamespace ensemble\fR command for more
details. If NULL, the default behavior \- generate a suitable error
message \- will be used when an unknown subcommand is encountered. May
be read and written using \fBTcl_GetEnsembleUnknownHandler\fR and
\fBTcl_SetEnsembleUnknownHandler\fR respectively. The result of both
functions is a Tcl result code (TCL_OK, or TCL_ERROR if the token does
not refer to an ensemble) and the list obtained from
\fBTcl_GetEnsembleUnknownHandler\fR should always be treated as
immutable even if it is unshared.
.TP
\fBbound namespace\fR (read-only)
The namespace to which the ensemble is bound; when the namespace is
deleted, so too will the ensemble, and this namespace is also the
namespace whose list of exported commands is used if both the mapping
dictionary and the subcommand list properties are NULL. May be read
using \fBTcl_GetEnsembleNamespace\fR which returns a Tcl result code
(TCL_OK, or TCL_ERROR if the token does not refer to an ensemble).
.SH "SEE ALSO"
namespace(n), Tcl_DeleteCommandFromToken(3)
+12 -8
View File
@@ -14,21 +14,25 @@ Tcl_PutEnv \- procedures to manipulate the environment
\fB#include <tcl.h>\fR
.sp
int
\fBTcl_PutEnv\fR(\fIstring\fR)
\fBTcl_PutEnv\fR(\fIassignment\fR)
.SH ARGUMENTS
.AP "CONST char" *string in
Info about environment variable in the form NAME=value.
The \fIstring\fR argument is in the system encoding.
.AS "const char" *assignment
.AP "const char" *assignment in
Info about environment variable in the format
.QW \fINAME\fB=\fIvalue\fR .
The \fIassignment\fR argument is in the system encoding.
.BE
.SH DESCRIPTION
.PP
\fBTcl_PutEnv\fR sets an environment variable. The information is
passed in a single string of the form NAME=value. This procedure is
passed in a single string of the form
.QW \fINAME\fB=\fIvalue\fR .
This procedure is
intended to be a stand-in for the UNIX \fBputenv\fR system call. All
tcl-based applications using \fBputenv\fR should redefine it to
Tcl-based applications using \fBputenv\fR should redefine it to
\fBTcl_PutEnv\fR so that they will interface properly to the Tcl
runtime.
.SH "SEE ALSO"
tclvars(n)
.SH KEYWORDS
environment, variable
+26 -21
View File
@@ -15,7 +15,6 @@ Tcl_EvalObjEx, Tcl_EvalFile, Tcl_EvalObjv, Tcl_Eval, Tcl_EvalEx, Tcl_GlobalEval,
.nf
\fB#include <tcl.h>\fR
.sp
.VS
int
\fBTcl_EvalObjEx\fR(\fIinterp, objPtr, flags\fR)
.sp
@@ -38,12 +37,12 @@ int
\fBTcl_GlobalEvalObj\fR(\fIinterp, objPtr\fR)
.sp
int
\fBTcl_VarEval\fR(\fIinterp, string, string, ... \fB(char *) NULL\fR)
\fBTcl_VarEval\fR(\fIinterp, part, part, ... \fB(char *) NULL\fR)
.sp
int
\fBTcl_VarEvalVA\fR(\fIinterp, argList\fR)
.SH ARGUMENTS
.AS Tcl_Interp **termPtr;
.AS Tcl_Interp **termPtr
.AP Tcl_Interp *interp in
Interpreter in which to execute the script. The interpreter's result is
modified to hold the result or error message from the script.
@@ -52,7 +51,7 @@ A Tcl object containing the script to execute.
.AP int flags in
ORed combination of flag bits that specify additional options.
\fBTCL_EVAL_GLOBAL\fR and \fBTCL_EVAL_DIRECT\fR are currently supported.
.AP "CONST char" *fileName in
.AP "const char" *fileName in
Name of a file containing a Tcl script.
.AP int objc in
The number of objects in the array pointed to by \fIobjPtr\fR;
@@ -64,13 +63,13 @@ value of a single word in the command to execute.
The number of bytes in \fIscript\fR, not including any
null terminating character. If \-1, then all characters up to the
first null byte are used.
.AP "CONST char" *script in
.AP "const char" *script in
Points to first byte of script to execute (null-terminated and UTF-8).
.AP char *string in
.AP char *part in
String forming part of a Tcl script.
.AP va_list argList in
An argument list which must have been initialised using
\fBTCL_VARARGS_START\fR, and cleared using \fBva_end\fR.
An argument list which must have been initialized using
\fBva_start\fR, and cleared using \fBva_end\fR.
.BE
.SH DESCRIPTION
@@ -97,26 +96,33 @@ result; it can be retrieved using \fBTcl_GetObjResult\fR.
\fBTcl_EvalFile\fR reads the file given by \fIfileName\fR and evaluates
its contents as a Tcl script. It returns the same information as
\fBTcl_EvalObjEx\fR.
If the file couldn't be read then a Tcl error is returned to describe
why the file couldn't be read.
.VS 8.4
The eofchar for files is '\\32' (^Z) for all platforms.
If you require a ``^Z'' in code for string comparison, you can use
``\\032'' or ``\\u001a'', which will be safely substituted by the Tcl
interpreter into ``^Z''.
.VE 8.4
If the file could not be read then a Tcl error is returned to describe
why the file could not be read.
The eofchar for files is
.QW \e32
(^Z) for all platforms. If you require a
.QW ^Z
in code for string comparison, you can use
.QW \e032
or
.QW \eu001a ,
which will be safely substituted by the Tcl interpreter into
.QW ^Z .
.PP
\fBTcl_EvalObjv\fR executes a single pre-parsed command instead of a
script. The \fIobjc\fR and \fIobjv\fR arguments contain the values
of the words for the Tcl command, one word in each object in
\fIobjv\fR. \fBTcl_EvalObjv\fR evaluates the command and returns
a completion code and result just like \fBTcl_EvalObjEx\fR.
The caller of \fBTcl_EvalObjv\fR has to manage the reference count of the
elements of \fIobjv\fR, insuring that the objects are valid until
\fBTcl_EvalObjv\fR returns.
.PP
\fBTcl_Eval\fR is similar to \fBTcl_EvalObjEx\fR except that the script to
be executed is supplied as a string instead of an object and no compilation
occurs. The string should be a proper UTF-8 string as converted by
\fBTcl_ExternalToUtfDString\fR or \fBTcl_ExternalToUtf\fR when it is known
to possibly contain upper ASCII characters who's possible combinations
to possibly contain upper ASCII characters whose possible combinations
might be a UTF-8 special code. The string is parsed and executed directly
(using \fBTcl_EvalObjv\fR) instead of compiling it and executing the
bytecodes. In situations where it is known that the script will never be
@@ -126,7 +132,7 @@ executed again, \fBTcl_Eval\fR may be faster than \fBTcl_EvalObjEx\fR.
Tcl 8.0, \fBTcl_Eval\fR copies the object result in \fIinterp\fR to
\fIinterp->result\fR (use is deprecated) where it can be accessed directly.
This makes \fBTcl_Eval\fR somewhat slower than \fBTcl_EvalEx\fR, which
doesn't do the copy.
does not do the copy.
.PP
\fBTcl_EvalEx\fR is an extended version of \fBTcl_Eval\fR that takes
additional arguments \fInumBytes\fR and \fIflags\fR. For the
@@ -163,8 +169,8 @@ compiled to bytecodes; instead it is executed directly
as is done by \fBTcl_EvalEx\fR. The
\fBTCL_EVAL_DIRECT\fR flag is useful in situations where the
contents of an object are going to change immediately, so the
bytecodes won't be reused in a future execution. In this case,
it's faster to execute the script directly.
bytecodes will not be reused in a future execution. In this case,
it is faster to execute the script directly.
.TP 23
\fBTCL_EVAL_GLOBAL\fR
If this flag is set, the script is processed at global level. This
@@ -197,7 +203,6 @@ the \fBreturn\fR, \fBbreak\fR, or \fBcontinue\fR command was
invoked in an inappropriate place.
This means that top-level applications should never see a return code
from \fBTcl_EvalObjEx\fR other then \fBTCL_OK\fR or \fBTCL_ERROR\fR.
.VE
.SH KEYWORDS
execute, file, global, object, result, script
+27 -9
View File
@@ -5,10 +5,10 @@
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.so man.macros
.TH Tcl_Exit 3 8.1 Tcl "Tcl Library Procedures"
.TH Tcl_Exit 3 8.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_Exit, Tcl_Finalize, Tcl_CreateExitHandler, Tcl_DeleteExitHandler, Tcl_ExitThread, Tcl_FinalizeThread, Tcl_CreateThreadExitHandler, Tcl_DeleteThreadExitHandler \- end the application or thread (and invoke exit handlers)
Tcl_Exit, Tcl_Finalize, Tcl_CreateExitHandler, Tcl_DeleteExitHandler, Tcl_ExitThread, Tcl_FinalizeThread, Tcl_CreateThreadExitHandler, Tcl_DeleteThreadExitHandler, Tcl_SetExitProc \- end the application or thread (and invoke exit handlers)
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -28,6 +28,11 @@ Tcl_Exit, Tcl_Finalize, Tcl_CreateExitHandler, Tcl_DeleteExitHandler, Tcl_ExitTh
\fBTcl_CreateThreadExitHandler\fR(\fIproc, clientData\fR)
.sp
\fBTcl_DeleteThreadExitHandler\fR(\fIproc, clientData\fR)
.sp
.VS 8.5
Tcl_ExitProc *
\fBTcl_SetExitProc\fR(\fIproc\fR)
.VE 8.5
.SH ARGUMENTS
.AS Tcl_ExitProc clientData
.AP int status in
@@ -36,7 +41,9 @@ Exact meaning may
be platform-specific. 0 usually means a normal exit, any nonzero value
usually means that an error occurred.
.AP Tcl_ExitProc *proc in
Procedure to invoke before exiting application.
Procedure to invoke before exiting application, or (for
\fBTcl_SetExitProc\fR) NULL to uninstall the current application exit
procedure.
.AP ClientData clientData in
Arbitrary one-word value to pass to \fIproc\fR.
.BE
@@ -57,6 +64,12 @@ otherwise causes the application to terminate without calling
\fBTcl_Exit\fR, the exit handlers will not be run.
\fBTcl_Exit\fR internally invokes the \fBexit\fR system call, thus it never
returns control to its caller.
.VS 8.5
If an application exit handler has been installed (see
\fBTcl_SetExitProc\fR), that handler is invoked with an argument
consisting of the exit status (cast to ClientData); the application
exit handler should not return control to Tcl.
.VE 8.5
.PP
\fBTcl_Finalize\fR is similar to \fBTcl_Exit\fR except that it does not
exit from the current process.
@@ -71,14 +84,12 @@ However, to ensure portability, your code should always invoke
code will work on all platforms. \fBTcl_Finalize\fR can be safely called
more than once.
.PP
.VS
\fBTcl_ExitThread\fR is used to terminate the current thread and invoke
per-thread exit handlers. This finalization is done by
\fBTcl_FinalizeThread\fR, which you can call if you just want to clean
up per-thread state and invoke the thread exit handlers.
\fBTcl_Finalize\fR calls \fBTcl_FinalizeThread\fR for the current
thread automatically.
.VE
.PP
\fBTcl_CreateExitHandler\fR arranges for \fIproc\fR to be invoked
by \fBTcl_Finalize\fR and \fBTcl_Exit\fR.
@@ -105,7 +116,6 @@ indicated by \fIproc\fR and \fIclientData\fR so that no call
to \fIproc\fR will be made. If no such handler exists then
\fBTcl_DeleteExitHandler\fR or \fBTcl_DeleteThreadExitHandler\fR does nothing.
.PP
.VS
.PP
\fBTcl_Finalize\fR and \fBTcl_Exit\fR execute all registered exit handlers,
in reverse order from the order in which they were registered.
@@ -115,15 +125,23 @@ unloads \fBB\fR before it itself is unloaded.
If extension \fBA\fR registers its exit handlers before loading extension
\fBB\fR, this ensures that any exit handlers for \fBB\fR will be executed
before the exit handlers for \fBA\fR.
.VE
.VS
.PP
\fBTcl_Finalize\fR and \fBTcl_Exit\fR call \fBTcl_FinalizeThread\fR
and the thread exit handlers \fIafter\fR
the process-wide exit handlers. This is because thread finalization shuts
down the I/O channel system, so any attempt at I/O by the global exit
handlers will vanish into the bitbucket.
.VE
.PP
.VS 8.5
\fBTcl_SetExitProc\fR installs an application exit handler, returning
the previously-installed application exit handler or NULL if no
application handler was installed. If an application exit handler is
installed, that exit handler takes over complete responsibility for
finalization of Tcl's subsystems via \fBTcl_Finalize\fR at an
appropriate time. The argument passed to \fIproc\fR when it is
invoked will be the exit status code (as passed to \fBTcl_Exit\fR)
cast to a ClientData value.
.VE 8.5
.SH KEYWORDS
callback, cleanup, dynamic loading, end application, exit, unloading, thread
+13 -11
View File
@@ -15,23 +15,21 @@ Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean, Tcl_ExprString \- evaluate an exp
\fB#include <tcl.h>\fR
.sp
int
\fBTcl_ExprLong\fR(\fIinterp, string, longPtr\fR)
\fBTcl_ExprLong\fR(\fIinterp, expr, longPtr\fR)
.sp
int
\fBTcl_ExprDouble\fR(\fIinterp, string, doublePtr\fR)
\fBTcl_ExprDouble\fR(\fIinterp, expr, doublePtr\fR)
.sp
int
\fBTcl_ExprBoolean\fR(\fIinterp, string, booleanPtr\fR)
\fBTcl_ExprBoolean\fR(\fIinterp, expr, booleanPtr\fR)
.sp
int
\fBTcl_ExprString\fR(\fIinterp, string\fR)
\fBTcl_ExprString\fR(\fIinterp, expr\fR)
.SH ARGUMENTS
.AS Tcl_Interp *booleanPtr
.AS Tcl_Interp *booleanPtr out
.AP Tcl_Interp *interp in
Interpreter in whose context to evaluate \fIstring\fR.
.VS 8.4
.AP "CONST char" *string in
.VE
Interpreter in whose context to evaluate \fIexpr\fR.
.AP "const char" *expr in
Expression to be evaluated.
.AP long *longPtr out
Pointer to location in which to store the integer value of the
@@ -47,7 +45,7 @@ expression.
.SH DESCRIPTION
.PP
These four procedures all evaluate the expression
given by the \fIstring\fR argument
given by the \fIexpr\fR argument
and return the result in one of four different forms.
The expression can have any of the forms accepted by the \fBexpr\fR command.
Note that these procedures have been largely replaced by the
@@ -92,7 +90,11 @@ number, then they store 0 at \fI*booleanPtr\fR if
the value was zero and 1 otherwise.
If the expression's actual value is a non-numeric string then
it must be one of the values accepted by \fBTcl_GetBoolean\fR
such as ``yes'' or ``no'', or else an error occurs.
such as
.QW yes
or
.QW no ,
or else an error occurs.
.PP
\fBTcl_ExprString\fR returns the value of the expression as a
string stored in the interpreter's result.
+5 -1
View File
@@ -86,7 +86,11 @@ number, then they store 0 at \fI*booleanPtr\fR if
the value was zero and 1 otherwise.
If the expression's actual value is a non-numeric string then
it must be one of the values accepted by \fBTcl_GetBoolean\fR
such as ``yes'' or ``no'', or else an error occurs.
such as
.QW yes
or
.QW no ,
or else an error occurs.
.PP
If \fBTcl_ExprObj\fR successfully evaluates the expression,
it stores a pointer to the Tcl object
+612 -444
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -16,10 +16,10 @@ Tcl_FindExecutable, Tcl_GetNameOfExecutable \- identify or return the name of th
void
\fBTcl_FindExecutable\fR(\fIargv0\fR)
.sp
CONST char *
const char *
\fBTcl_GetNameOfExecutable\fR()
.SH ARGUMENTS
.AS char *argv0 in
.AS char *argv0
.AP char *argv0 in
The first command-line argument to the program, which gives the
application's name.
Executable → Regular
+2 -2
View File
@@ -19,7 +19,7 @@ char *
int
\fBTcl_Chdir\fR(\fIpath\fR)
.SH ARGUMENTS
.AS Tcl_DString *bufferPtr
.AS Tcl_DString *bufferPtr in/out
.AP Tcl_Interp *interp in
Interpreter in which to report an error, if any.
.AP Tcl_DString *bufferPtr in/out
@@ -39,7 +39,7 @@ the same functionality as the Tcl \fBpwd\fR command.
.PP
\fBTcl_GetCwd\fR returns a pointer to a string specifying the current
directory, or NULL if the current directory could not be determined.
If NULL is returned, an error message is left in the interp's result.
If NULL is returned, an error message is left in the \fIinterp\fR's result.
Storage for the result string is allocated in bufferPtr; the caller
must call \fBTcl_DStringFree()\fR when the result is no longer needed.
The format of the path is UTF\-8.
+1 -1
View File
@@ -11,7 +11,7 @@ Tcl_GetHostName \- get the name of the local host
.nf
\fB#include <tcl.h>\fR
.sp
CONST char *
const char *
\fBTcl_GetHostName\fR()
.BE
+18 -21
View File
@@ -16,14 +16,12 @@ Tcl_GetIndexFromObj, Tcl_GetIndexFromObjStruct \- lookup string in table of keyw
int
\fBTcl_GetIndexFromObj\fR(\fIinterp, objPtr, tablePtr, msg, flags,
indexPtr\fR)
.VS
.sp
int
\fBTcl_GetIndexFromObjStruct\fR(\fIinterp, objPtr, structTablePtr, offset,
msg, flags, indexPtr\fR)
.VE
msg, flags, indexPtr\fR)
.SH ARGUMENTS
.AS "CONST char" **tablePtr
.AS "const char" *structTablePtr in/out
.AP Tcl_Interp *interp in
Interpreter to use for error reporting; if NULL, then no message is
provided on errors.
@@ -31,25 +29,23 @@ provided on errors.
The string value of this object is used to search through \fItablePtr\fR.
The internal representation is modified to hold the index of the matching
table entry.
.AP "CONST char" **tablePtr in
.AP "const char" **tablePtr in
An array of null-terminated strings. The end of the array is marked
by a NULL string pointer.
Note that references to the \fItablePtr\fR may be retained in the
internal representation of \fIobjPtr\fR, so this should represent the
address of a statically-allocated array.
.AP "CONST VOID" *structTablePtr in
An array of arbitrary type, typically some \fBstruct\fP type.
.AP "const void" *structTablePtr in
An array of arbitrary type, typically some \fBstruct\fR type.
The first member of the structure must be a null-terminated string.
The size of the structure is given by \fIoffset\fP.
The size of the structure is given by \fIoffset\fR.
Note that references to the \fIstructTablePtr\fR may be retained in the
internal representation of \fIobjPtr\fR, so this should represent the
address of a statically-allocated array of structures.
.VS
.AP int offset in
The offset to add to structTablePtr to get to the next entry.
The end of the array is marked by a NULL string pointer.
.VE
.AP "CONST char" *msg in
.AP "const char" *msg in
Null-terminated string describing what is being looked up, such as
\fBoption\fR. This string is included in error messages.
.AP int flags in
@@ -72,14 +68,14 @@ the strings in \fItablePtr\fR to find a match. A match occurs if
for exactly one of the strings in \fItablePtr\fR and the
\fBTCL_EXACT\fR flag was not specified; in either case
the index of the matching entry is stored at \fI*indexPtr\fR
and TCL_OK is returned.
and \fBTCL_OK\fR is returned.
.PP
If there is no matching entry,
TCL_ERROR is returned and an error message is left in \fIinterp\fR's
result if \fIinterp\fR isn't NULL. \fIMsg\fR is included in the
\fBTCL_ERROR\fR is returned and an error message is left in \fIinterp\fR's
result if \fIinterp\fR is not NULL. \fIMsg\fR is included in the
error message to indicate what was being looked up. For example,
if \fImsg\fR is \fBoption\fR the error message will have a form like
\fBbad option "firt": must be first, second, or third\fR.
.QW "\fBbad option \N'34'firt\N'34': must be first, second, or third\fR" .
.PP
If \fBTcl_GetIndexFromObj\fR completes successfully it modifies the
internal representation of \fIobjPtr\fR to hold the address of
@@ -91,17 +87,18 @@ operation. Note: \fBTcl_GetIndexFromObj\fR assumes that the entries
in \fItablePtr\fR are static: they must not change between
invocations. If the value of \fIobjPtr\fR is the empty string,
\fBTcl_GetIndexFromObj\fR will treat it as a non-matching value
and return TCL_ERROR.
.VS
and return \fBTCL_ERROR\fR.
.PP
\fBTcl_GetIndexFromObjStruct\fR works just like
\fBTcl_GetIndexFromObj\fR, except that instead of treating
\fItablePtr\fR as an array of string pointers, it treats it as the
first in a series of string ptrs that are spaced apart by \fIoffset\fR
bytes. This is particularly useful when processing things like
\fItablePtr\fR as an array of string pointers, it treats it as a
pointer to the first string in a series of strings that have
\fIoffset\fR bytes between them (i.e. that there is a pointer to the
first array of characters at \fItablePtr\fR, a pointer to the second
array of characters at \fItablePtr\fR+\fIoffset\fR bytes, etc.)
This is particularly useful when processing things like
\fBTk_ConfigurationSpec\fR, whose string keys are in the same place in
each of several array elements.
.VE
.SH "SEE ALSO"
Tcl_WrongNumArgs
+31 -24
View File
@@ -15,62 +15,69 @@ Tcl_GetInt, Tcl_GetDouble, Tcl_GetBoolean \- convert from string to integer, dou
\fB#include <tcl.h>\fR
.sp
int
\fBTcl_GetInt\fR(\fIinterp, string, intPtr\fR)
\fBTcl_GetInt\fR(\fIinterp, src, intPtr\fR)
.sp
int
\fBTcl_GetDouble\fR(\fIinterp, string, doublePtr\fR)
\fBTcl_GetDouble\fR(\fIinterp, src, doublePtr\fR)
.sp
int
\fBTcl_GetBoolean\fR(\fIinterp, string, boolPtr\fR)
\fBTcl_GetBoolean\fR(\fIinterp, src, boolPtr\fR)
.SH ARGUMENTS
.AS Tcl_Interp *doublePtr
.AS Tcl_Interp *doublePtr out
.AP Tcl_Interp *interp in
Interpreter to use for error reporting.
.AP "CONST char" *string in
.AP "const char" *src in
Textual value to be converted.
.AP int *intPtr out
Points to place to store integer value converted from \fIstring\fR.
Points to place to store integer value converted from \fIsrc\fR.
.AP double *doublePtr out
Points to place to store double-precision floating-point
value converted from \fIstring\fR.
value converted from \fIsrc\fR.
.AP int *boolPtr out
Points to place to store boolean value (0 or 1) converted from \fIstring\fR.
Points to place to store boolean value (0 or 1) converted from \fIsrc\fR.
.BE
.SH DESCRIPTION
.PP
These procedures convert from strings to integers or double-precision
floating-point values or booleans (represented as 0- or 1-valued
integers). Each of the procedures takes a \fIstring\fR argument,
integers). Each of the procedures takes a \fIsrc\fR argument,
converts it to an internal form of a particular type, and stores
the converted value at the location indicated by the procedure's
third argument. If all goes well, each of the procedures returns
TCL_OK. If \fIstring\fR doesn't have the proper syntax for the
desired type then TCL_ERROR is returned, an error message is left
\fBTCL_OK\fR. If \fIsrc\fR does not have the proper syntax for the
desired type then \fBTCL_ERROR\fR is returned, an error message is left
in the interpreter's result, and nothing is stored at *\fIintPtr\fR
or *\fIdoublePtr\fR or *\fIboolPtr\fR.
.PP
\fBTcl_GetInt\fR expects \fIstring\fR to consist of a collection
\fBTcl_GetInt\fR expects \fIsrc\fR to consist of a collection
of integer digits, optionally signed and optionally preceded by
white space. If the first two characters of \fIstring\fR are ``0x''
then \fIstring\fR is expected to be in hexadecimal form; otherwise,
if the first character of \fIstring\fR is ``0'' then \fIstring\fR
is expected to be in octal form; otherwise, \fIstring\fR is
white space. If the first two characters of \fIsrc\fR
after the optional white space and sign are
.QW 0x
then \fIsrc\fR is expected to be in hexadecimal form; otherwise,
if the first such character is
.QW 0
then \fIsrc\fR
is expected to be in octal form; otherwise, \fIsrc\fR is
expected to be in decimal form.
.PP
\fBTcl_GetDouble\fR expects \fIstring\fR to consist of a floating-point
\fBTcl_GetDouble\fR expects \fIsrc\fR to consist of a floating-point
number, which is: white space; a sign; a sequence of digits; a
decimal point; a sequence of digits; the letter ``e''; and a
signed decimal exponent. Any of the fields may be omitted, except that
decimal point; a sequence of digits; the letter
.QW e ;
a signed decimal exponent; and more white space.
Any of the fields may be omitted, except that
the digits either before or after the decimal point must be present
and if the ``e'' is present then it must be followed by the
exponent number.
and if the
.QW e
is present then it must be followed by the exponent number.
.PP
\fBTcl_GetBoolean\fR expects \fIstring\fR to specify a boolean
value. If \fIstring\fR is any of \fB0\fR, \fBfalse\fR,
\fBTcl_GetBoolean\fR expects \fIsrc\fR to specify a boolean
value. If \fIsrc\fR is any of \fB0\fR, \fBfalse\fR,
\fBno\fR, or \fBoff\fR, then \fBTcl_GetBoolean\fR stores a zero
value at \fI*boolPtr\fR.
If \fIstring\fR is any of \fB1\fR, \fBtrue\fR, \fByes\fR, or \fBon\fR,
If \fIsrc\fR is any of \fB1\fR, \fBtrue\fR, \fByes\fR, or \fBon\fR,
then 1 is stored at \fI*boolPtr\fR.
Any of these values may be abbreviated, and upper-case spellings
are also acceptable.
+10 -12
View File
@@ -8,29 +8,29 @@
.TH Tcl_GetOpenFile 3 8.0 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_GetOpenFile \- Get a standard IO File * handle from a channel. (Unix only)
Tcl_GetOpenFile \- Return a FILE* for a channel registered in the given interpreter (Unix only)
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
int
\fBTcl_GetOpenFile\fR(\fIinterp, string, write, checkUsage, filePtr\fR)
\fBTcl_GetOpenFile\fR(\fIinterp, chanID, write, checkUsage, filePtr\fR)
.sp
.SH ARGUMENTS
.AS Tcl_Interp checkUsage
.AS Tcl_Interp checkUsage out
.AP Tcl_Interp *interp in
Tcl interpreter from which file handle is to be obtained.
.AP "CONST char" *string in
.AP "const char" *chanID in
String identifying channel, such as \fBstdin\fR or \fBfile4\fR.
.AP int write in
Non-zero means the file will be used for writing, zero means it will
be used for reading.
.AP int checkUsage in
If non-zero, then an error will be generated if the file wasn't opened
If non-zero, then an error will be generated if the file was not opened
for the access indicated by \fIwrite\fR.
.AP ClientData *filePtr out
Points to word in which to store pointer to FILE structure for
the file given by \fIstring\fR.
the file given by \fIchanID\fR.
.BE
.SH DESCRIPTION
@@ -44,17 +44,15 @@ be used for reading or writing.
In some cases, such as a channel that connects to a pipeline of
subprocesses, different FILE pointers will be returned for reading
and writing.
\fBTcl_GetOpenFile\fR normally returns TCL_OK.
If an error occurs in \fBTcl_GetOpenFile\fR (e.g. \fIstring\fR didn't
make any sense or \fIcheckUsage\fR was set and the file wasn't opened
for the access specified by \fIwrite\fR) then TCL_ERROR is returned
\fBTcl_GetOpenFile\fR normally returns \fBTCL_OK\fR.
If an error occurs in \fBTcl_GetOpenFile\fR (e.g. \fIchanID\fR did not
make any sense or \fIcheckUsage\fR was set and the file was not opened
for the access specified by \fIwrite\fR) then \fBTCL_ERROR\fR is returned
and the interpreter's result will contain an error message.
In the current implementation \fIcheckUsage\fR is ignored and consistency
checks are always performed.
.VS
.PP
Note that this interface is only supported on the Unix platform.
.VE
.SH KEYWORDS
channel, file handle, permissions, pipeline, read, write
+1 -2
View File
@@ -20,7 +20,7 @@ Tcl_Channel
\fBTcl_SetStdChannel\fR(\fIchannel, type\fR)
.sp
.SH ARGUMENTS
.AS Tcl_Channel channel in
.AS Tcl_Channel channel
.AP int type in
The identifier for the standard channel to retrieve or modify. Must be one of
\fBTCL_STDIN\fR, \fBTCL_STDOUT\fR, or \fBTCL_STDERR\fR.
@@ -76,7 +76,6 @@ standard error being last.
.PP
See \fBTcl_StandardChannels\fR for a general treatise about standard
channels and the behaviour of the Tcl library with regard to them.
.PP
.SH "SEE ALSO"
Tcl_Close(3), Tcl_CreateChannel(3), Tcl_Main(3), tclsh(1)
+53 -4
View File
@@ -1,5 +1,5 @@
'\"
'\" Copyright (c) 2001 by Kevin B. Kenny.
'\" Copyright (c) 2001 by Kevin B. Kenny <kennykb@acm.org>.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -8,16 +8,39 @@
.TH Tcl_GetTime 3 8.4 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_GetTime \- get date and time
Tcl_GetTime, Tcl_SetTimeProc, Tcl_QueryTimeProc \- get date and time
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
\fBTcl_GetTime\fR(\fI timePtr \fR)
\fBTcl_GetTime\fR(\fItimePtr\fR)
.sp
\fBTcl_SetTimeProc\fR(\fIgetProc, scaleProc, clientData\fR)
.sp
\fBTcl_QueryTimeProc\fR(\fIgetProcPtr, scaleProcPtr, clientDataPtr\fR)
.SH ARGUMENTS
.AS "Tcl_Time *" timePtr
.AS "Tcl_Time *" timePtr out
.AP "Tcl_Time *" timePtr out
Points to memory in which to store the date and time information.
.AS "Tcl_GetTimeProc *" getProc in
.AP "Tcl_GetTimeProc *" getProc in
Pointer to handler function replacing \fBTcl_GetTime\fR's access to the OS.
.AS "Tcl_ScaleTimeProc *" scaleProc in
.AP "Tcl_ScaleTimeProc *" scaleProc in
Pointer to handler function for the conversion of time delays in the
virtual domain to real-time.
.AS "ClientData *" clientData in
.AP "ClientData *" clientData in
Value passed through to the two handler functions.
.AS "Tcl_GetTimeProc **" getProcPtr inout
.AP "Tcl_GetTimeProc **" getProcPtr inout
Pointer to place the currently registered get handler function into.
.AS "Tcl_ScaleTimeProc **" scaleProcPtr inout
.AP "Tcl_ScaleTimeProc **" scaleProcPtr inout
Pointer to place the currently registered scale handler function into.
.AS "ClientData **" clientDataPtr inout
.AP "ClientData **" clientDataPtr inout
Pointer to place the currently registered pass-through value into.
.BE
.SH DESCRIPTION
.PP
@@ -45,6 +68,32 @@ computer system. On multiprocessor variants of Windows, this number
may be limited to the 10- or 20-ms granularity of the system clock.
(On single-processor Windows systems, the \fIusec\fR field is derived
from a performance counter and is highly precise.)
.PP
The \fBTcl_SetTime\fR function registers two related handler functions
with the core. The first handler function is a replacement for
\fBTcl_GetTime\fR, or rather the OS access made by
\fBTcl_GetTime\fR. The other handler function is used by the Tcl
notifier to convert wait/block times from the virtual domain into real
time.
.PP
The \fBTcl_QueryTime\fR function returns the currently registered
handler functions. If no external handlers were set then this will
return the standard handlers accessing and processing the native time
of the OS. The arguments to the function are allowed to be NULL; and
any argument which is NULL is ignored and not set.
.PP
Any handler pair specified has to return data which is consistent
between them. In other words, setting one handler of the pair to
something assuming a 10-times slowdown, and the other handler of the
pair to something assuming a two-times slowdown is wrong and not
allowed.
.PP
The set handler functions are allowed to run the delivered time
backwards, however this should be avoided. We have to allow it as the
native time can run backwards as the user can fiddle with the system
time one way or other. Note that the insertion of the hooks will not
change the behaviour of the Tcl core with regard to this situation,
i.e. the existing behaviour is retained.
.SH "SEE ALSO"
clock
.SH KEYWORDS
Executable → Regular
+1
View File
@@ -15,6 +15,7 @@ Tcl_GetVersion \- get the version of the library at runtime
.sp
\fBTcl_GetVersion\fR(\fImajor, minor, patchLevel, type\fR)
.SH ARGUMENTS
.AS Tcl_ReleaseType *patchLevel out
.AP int *major out
Major version number of the Tcl library.
.AP int *minor out
+82 -59
View File
@@ -44,21 +44,21 @@ Tcl_HashEntry *
Tcl_HashEntry *
\fBTcl_NextHashEntry\fR(\fIsearchPtr\fR)
.sp
CONST char *
char *
\fBTcl_HashStats\fR(\fItablePtr\fR)
.SH ARGUMENTS
.AS Tcl_HashSearch *searchPtr
.AS Tcl_HashKeyType *searchPtr out
.AP Tcl_HashTable *tablePtr in
Address of hash table structure (for all procedures but
\fBTcl_InitHashTable\fR, this must have been initialized by
previous call to \fBTcl_InitHashTable\fR).
.AP int keyType in
Kind of keys to use for new hash table. Must be either
TCL_STRING_KEYS, TCL_ONE_WORD_KEYS, TCL_CUSTOM_TYPE_KEYS,
TCL_CUSTOM_PTR_KEYS, or an integer value greater than 1.
\fBTCL_STRING_KEYS\fR, \fBTCL_ONE_WORD_KEYS\fR, \fBTCL_CUSTOM_TYPE_KEYS\fR,
\fBTCL_CUSTOM_PTR_KEYS\fR, or an integer value greater than 1.
.AP Tcl_HashKeyType *typePtr in
Address of structure which defines the behaviour of the hash table.
.AP "CONST char" *key in
.AP "const char" *key in
Key to use for probe into table. Exact form depends on
\fIkeyType\fR used to create table.
.AP int *newPtr out
@@ -86,7 +86,9 @@ STRUCTURE\fR below). All of the keys in a given table have the same
form, which is specified when the table is initialized.
.PP
The value of a hash table entry can be anything that fits in the same
space as a ``char *'' pointer. Values for hash table entries are
space as a
.QW "char *"
pointer. Values for hash table entries are
managed entirely by clients, not by the hash module itself. Typically
each entry's value is a pointer to a data structure managed by client
code.
@@ -122,8 +124,10 @@ They are passed to hashing routines using the address of the
first character of the string.
.IP \fBTCL_ONE_WORD_KEYS\fR 25
Keys are single-word values; they are passed to hashing routines
and stored in hash table entries as ``char *'' values.
The pointer value is the key; it need not (and usually doesn't)
and stored in hash table entries as
.QW "char *"
values.
The pointer value is the key; it need not (and usually does not)
actually point to a string.
.IP \fBTCL_CUSTOM_TYPE_KEYS\fR 25
Keys are of arbitrary type, and are stored in the entry. Hashing
@@ -138,7 +142,9 @@ structure is described in the section
.IP \fIother\fR 25
If \fIkeyType\fR is not one of the above,
then it must be an integer value greater than 1.
In this case the keys will be arrays of ``int'' values, where
In this case the keys will be arrays of
.QW int
values, where
\fIkeyType\fR gives the number of ints in each key.
This allows structures to be used as keys.
All keys must have the same size.
@@ -159,7 +165,7 @@ before deleting the table.
.PP
\fBTcl_CreateHashEntry\fR locates the entry corresponding to a
particular key, creating a new entry in the table if there
wasn't already one with the given key.
was not already one with the given key.
If an entry already existed with the given key then \fI*newPtr\fR
is set to zero.
If a new entry was created, then \fI*newPtr\fR is set to a non-zero
@@ -175,28 +181,34 @@ the client is responsible for any cleanup associated with the
entry's value, such as freeing a structure that it points to.
.PP
\fBTcl_FindHashEntry\fR is similar to \fBTcl_CreateHashEntry\fR
except that it doesn't create a new entry if the key doesn't exist;
except that it does not create a new entry if the key doesn't exist;
instead, it returns NULL as result.
.PP
\fBTcl_GetHashValue\fR and \fBTcl_SetHashValue\fR are used to
read and write an entry's value, respectively.
Values are stored and retrieved as type ``ClientData'', which is
Values are stored and retrieved as type
.QW ClientData ,
which is
large enough to hold a pointer value. On almost all machines this is
large enough to hold an integer value too.
.PP
\fBTcl_GetHashKey\fR returns the key for a given hash table entry,
either as a pointer to a string, a one-word (``char *'') key, or
either as a pointer to a string, a one-word
.PQ "char *"
key, or
as a pointer to the first word of an array of integers, depending
on the \fIkeyType\fR used to create a hash table.
In all cases \fBTcl_GetHashKey\fR returns a result with type
``char *''.
.QW "char *" .
When the key is a string or array, the result of \fBTcl_GetHashKey\fR
points to information in the table entry; this information will
remain valid until the entry is deleted or its table is deleted.
.PP
\fBTcl_FirstHashEntry\fR and \fBTcl_NextHashEntry\fR may be used
to scan all of the entries in a hash table.
A structure of type ``Tcl_HashSearch'', provided by the client,
A structure of type
.QW Tcl_HashSearch ,
provided by the client,
is used to keep track of progress through the table.
\fBTcl_FirstHashEntry\fR initializes the search record and
returns the first entry in the table (or NULL if the table is
@@ -207,9 +219,10 @@ NULL if the end of the table has been reached.
A call to \fBTcl_FirstHashEntry\fR followed by calls to
\fBTcl_NextHashEntry\fR will return each of the entries in
the table exactly once, in an arbitrary order.
It is unadvisable to modify the structure of the table, e.g.
by creating or deleting entries, while the search is in
progress.
It is inadvisable to modify the structure of the table, e.g.
by creating or deleting entries, while the search is in progress,
with the exception of deleting the entry returned by
\fBTcl_FirstHashEntry\fR or \fBTcl_NextHashEntry\fR.
.PP
\fBTcl_HashStats\fR returns a dynamically-allocated string with
overall information about a hash table, such as the number of
@@ -228,10 +241,10 @@ to any of the fields of any of the hash-related data structures;
use the procedures and macros defined here.
.SH "THE TCL_HASHKEYTYPE STRUCTURE"
.PP
Extension writers can define new hash key types by defining four
procedures, initializing a Tcl_HashKeyType structure to describe
the type, and calling \fBTcl_InitCustomHashTable\fR.
The \fBTcl_HashKeyType\fR structure is defined as follows:
Extension writers can define new hash key types by defining four procedures,
initializing a \fBTcl_HashKeyType\fR structure to describe the type, and
calling \fBTcl_InitCustomHashTable\fR. The \fBTcl_HashKeyType\fR structure is
defined as follows:
.CS
typedef struct Tcl_HashKeyType {
int \fIversion\fR;
@@ -243,61 +256,71 @@ typedef struct Tcl_HashKeyType {
} Tcl_HashKeyType;
.CE
.PP
The \fIversion\fR member is the version of the table. If this
structure is extended in future then the version can be used
to distinguish between different structures. It should be set
to \fBTCL_HASH_KEY_TYPE_VERSION\fR.
The \fIversion\fR member is the version of the table. If this structure is
extended in future then the version can be used to distinguish between
different structures. It should be set to \fBTCL_HASH_KEY_TYPE_VERSION\fR.
.PP
The \fIflags\fR member is one or more of the following values OR'ed together:
The \fIflags\fR member is 0 or one or more of the following values OR'ed
together:
.IP \fBTCL_HASH_KEY_RANDOMIZE_HASH\fR 25
There are some things, pointers for example which don't hash well
because they do not use the lower bits. If this flag is set then the
hash table will attempt to rectify this by randomising the bits and
then using the upper N bits as the index into the table.
There are some things, pointers for example which do not hash well because
they do not use the lower bits. If this flag is set then the hash table will
attempt to rectify this by randomizing the bits and then using the upper N
bits as the index into the table.
.IP \fBTCL_HASH_KEY_SYSTEM_HASH\fR 25
.VS 8.5
This flag forces Tcl to use the memory allocation procedures provided by the
operating system when allocating and freeing memory used to store the hash
table data structures, and not any of Tcl's own customized memory allocation
routines. This is important if the hash table is to be used in the
implementation of a custom set of allocation routines, or something that a
custom set of allocation routines might depend on, in order to avoid any
circular dependency.
.VE 8.5
.PP
The \fIhashKeyProc\fR member contains the address of a function
called to calculate a hash value for the key.
The \fIhashKeyProc\fR member contains the address of a function called to
calculate a hash value for the key.
.CS
typedef unsigned int (Tcl_HashKeyProc) (
Tcl_HashTable *\fItablePtr\fR,
VOID *\fIkeyPtr\fR);
Tcl_HashTable *\fItablePtr\fR,
void *\fIkeyPtr\fR);
.CE
If this is NULL then \fIkeyPtr\fR is used and
If this is NULL then \fIkeyPtr\fR is used and
\fBTCL_HASH_KEY_RANDOMIZE_HASH\fR is assumed.
.PP
The \fIcompareKeysProc\fR member contains the address of a function
called to compare two keys.
The \fIcompareKeysProc\fR member contains the address of a function called to
compare two keys.
.CS
typedef int (Tcl_CompareHashKeysProc) (VOID *\fIkeyPtr\fR,
Tcl_HashEntry *\fIhPtr\fR);
typedef int (Tcl_CompareHashKeysProc) (
void *\fIkeyPtr\fR,
Tcl_HashEntry *\fIhPtr\fR);
.CE
If this is NULL then the \fIkeyPtr\fR pointers are compared.
If the keys don't match then the function returns 0, otherwise
it returns 1.
If this is NULL then the \fIkeyPtr\fR pointers are compared. If the keys do
not match then the function returns 0, otherwise it returns 1.
.PP
The \fIallocEntryProc\fR member contains the address of a function
called to allocate space for an entry and initialise the key.
The \fIallocEntryProc\fR member contains the address of a function called to
allocate space for an entry and initialize the key and clientData.
.CS
typedef Tcl_HashEntry *(Tcl_AllocHashEntryProc) (
Tcl_HashTable *\fItablePtr\fR, VOID *\fIkeyPtr\fR);
Tcl_HashTable *\fItablePtr\fR,
void *\fIkeyPtr\fR);
.CE
If this is NULL then Tcl_Alloc is used to allocate enough space for a
Tcl_HashEntry and the key pointer is assigned to key.oneWordValue.
String keys and array keys use this function to allocate enough
space for the entry and the key in one block, rather than doing
it in two blocks. This saves space for a pointer to the key from
the entry and another memory allocation. Tcl_Obj * keys use this
function to allocate enough space for an entry and increment the
reference count on the object.
If
Tcl_HashEntry, the key pointer is assigned to key.oneWordValue and the
clientData is set to NULL. String keys and array keys use this function to
allocate enough space for the entry and the key in one block, rather than
doing it in two blocks. This saves space for a pointer to the key from the
entry and another memory allocation. Tcl_Obj* keys use this function to
allocate enough space for an entry and increment the reference count on the
object.
.PP
The \fIfreeEntryProc\fR member contains the address of a function
called to free space for an entry.
The \fIfreeEntryProc\fR member contains the address of a function called to
free space for an entry.
.CS
typedef void (Tcl_FreeHashEntryProc) (Tcl_HashEntry *\fIhPtr\fR);
.CE
If this is NULL then Tcl_Free is used to free the space for the
entry. Tcl_Obj * keys use this function to decrement the
reference count on the object.
If this is NULL then Tcl_Free is used to free the space for the entry.
Tcl_Obj* keys use this function to decrement the reference count on the
object.
.SH KEYWORDS
hash table, key, lookup, search, value
+3 -2
View File
@@ -14,15 +14,16 @@ Tcl_Init \- find and source initialization script
int
\fBTcl_Init\fR(\fIinterp\fR)
.SH ARGUMENTS
.AS Tcl_Interp *interp
.AP Tcl_Interp *interp in
Interpreter to initialize.
.BE
.SH DESCRIPTION
.PP
\fBTcl_Init\fR is a helper procedure that finds and \fBsource\fR's the
\fBTcl_Init\fR is a helper procedure that finds and \fBsource\fRs the
\fBinit.tcl\fR script, which should exist somewhere on the Tcl library
path.
path.
.PP
\fBTcl_Init\fR is typically called from \fBTcl_AppInit\fR procedures.
+7 -7
View File
@@ -13,13 +13,13 @@ Tcl_InitStubs \- initialize the Tcl stubs mechanism
.nf
\fB#include <tcl.h>\fR
.sp
CONST char *
const char *
\fBTcl_InitStubs\fR(\fIinterp, version, exact\fR)
.SH ARGUMENTS
.AS Tcl_Interp *interp in
.AS Tcl_Interp *interp
.AP Tcl_Interp *interp in
Tcl interpreter handle.
.AP "CONST char" *version in
.AP "const char" *version in
A version string consisting of one or more decimal numbers
separated by dots.
.AP int exact in
@@ -59,13 +59,13 @@ steps:
Call \fBTcl_InitStubs\fR in the extension before calling any other
Tcl functions.
.IP 2) 5
Define the USE_TCL_STUBS symbol. Typically, you would include the
-DUSE_TCL_STUBS flag when compiling the extension.
Define the \fBUSE_TCL_STUBS\fR symbol. Typically, you would include the
\fB\-DUSE_TCL_STUBS\fR flag when compiling the extension.
.IP 3) 5
Link the extension with the Tcl stubs library instead of the standard
Tcl library. On Unix platforms, the library name is
\fIlibtclstub8.4.a\fR; on Windows platforms, the library name is
\fItclstub84.lib\fR.
\fIlibtclstub8.5.a\fR; on Windows platforms, the library name is
\fItclstub85.lib\fR.
.PP
If the extension also requires the Tk API, it must also call
\fBTk_InitStubs\fR to initialize the Tk stubs interface and link
+106 -93
View File
@@ -5,10 +5,10 @@
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.so man.macros
.TH Tcl_IntObj 3 8.0 Tcl "Tcl Library Procedures"
.TH Tcl_IntObj 3 8.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_NewIntObj, Tcl_NewLongObj, Tcl_NewWideIntObj, Tcl_SetIntObj, Tcl_SetLongObj, Tcl_SetWideIntObj, Tcl_GetIntFromObj, Tcl_GetLongFromObj, Tcl_GetWideIntFromObj \- manipulate Tcl objects as integers and wide integers
Tcl_NewIntObj, Tcl_NewLongObj, Tcl_NewWideIntObj, Tcl_SetIntObj, Tcl_SetLongObj, Tcl_SetWideIntObj, Tcl_GetIntFromObj, Tcl_GetLongFromObj, Tcl_GetWideIntFromObj, Tcl_NewBignumObj, Tcl_SetBignumObj, Tcl_GetBignumFromObj, Tcl_TakeBignumFromObj \- manipulate Tcl objects as integer values
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -19,18 +19,14 @@ Tcl_Obj *
Tcl_Obj *
\fBTcl_NewLongObj\fR(\fIlongValue\fR)
.sp
.VS 8.4
Tcl_Obj *
\fBTcl_NewWideIntObj\fR(\fIwideValue\fR)
.VE 8.4
.sp
\fBTcl_SetIntObj\fR(\fIobjPtr, intValue\fR)
.sp
\fBTcl_SetLongObj\fR(\fIobjPtr, longValue\fR)
.sp
.VS 8.4
\fBTcl_SetWideIntObj\fR(\fIobjPtr, wideValue\fR)
.VE 8.4
.sp
int
\fBTcl_GetIntFromObj\fR(\fIinterp, objPtr, intPtr\fR)
@@ -38,110 +34,127 @@ int
int
\fBTcl_GetLongFromObj\fR(\fIinterp, objPtr, longPtr\fR)
.sp
.VS 8.4
int
\fBTcl_GetWideIntFromObj\fR(\fIinterp, objPtr, widePtr\fR)
.VE 8.4
.sp
.sp
.VS 8.5
\fB#include <tclTomMath.h>\fR
.sp
Tcl_Obj *
\fBTcl_NewBignumObj\fR(\fIbigValue\fR)
.sp
\fBTcl_SetBignumObj\fR(\fIobjPtr, bigValue\fR)
.sp
int
\fBTcl_GetBignumFromObj\fR(\fIinterp, objPtr, bigValue\fR)
.sp
int
\fBTcl_TakeBignumFromObj\fR(\fIinterp, objPtr, bigValue\fR)
.sp
int
\fBTcl_InitBignumFromDouble\fR(\fIinterp, doubleValue, bigValue\fR)
.VE 8.5
.SH ARGUMENTS
.AS Tcl_WideInt *interp
.AS Tcl_WideInt doubleValue in/out
.AP int intValue in
Integer value used to initialize or set an integer object.
Integer value used to initialize or set a Tcl object.
.AP long longValue in
Long integer value used to initialize or set an integer object.
Long integer value used to initialize or set a Tcl object.
.AP Tcl_WideInt wideValue in
.VS 8.4
Wide integer value (minimum 64-bits wide where supported by the
compiler) used to initialize or set a wide integer object.
.VE 8.4
Wide integer value used to initialize or set a Tcl object.
.AP Tcl_Obj *objPtr in/out
For \fBTcl_SetIntObj\fR, \fBTcl_SetLongObj\fR, and
.VS 8.4
\fBTcl_SetWideIntObj\fR, this points to the object to be converted to
integer type. For \fBTcl_GetIntFromObj\fR, \fBTcl_GetLongFromObj\fR,
and \fBTcl_GetWideIntFromObj\fR, this refers to the object from which
to get an integer or long integer value; if \fIobjPtr\fR does not
already point to an integer object (or a wide integer object in the
case of \fBTcl_SetWideIntObj\fR and \fBTcl_GetWideIntFromObj\fR,) an
.VE 8.4
attempt will be made to convert it to one.
For \fBTcl_SetIntObj\fR, \fBTcl_SetLongObj\fR, \fBTcl_SetWideIntObj\fR,
and \fBTcl_SetBignumObj\fR, this points to the object in which to store an
integral value. For \fBTcl_GetIntFromObj\fR, \fBTcl_GetLongFromObj\fR,
\fBTcl_GetWideIntFromObj\fR, \fBTcl_GetBignumFromObj\fR, and
\fBTcl_TakeBignumFromObj\fR, this refers to the object from which
to retrieve an integral value.
.AP Tcl_Interp *interp in/out
If an error occurs during conversion,
an error message is left in the interpreter's result object
unless \fIinterp\fR is NULL.
When non-NULL, an error message is left here when integral value
retrieval fails.
.AP int *intPtr out
Points to place to store the integer value
obtained by \fBTcl_GetIntFromObj\fR from \fIobjPtr\fR.
Points to place to store the integer value retrieved from \fIobjPtr\fR.
.AP long *longPtr out
Points to place to store the long integer value
obtained by \fBTcl_GetLongFromObj\fR from \fIobjPtr\fR.
Points to place to store the long integer value retrieved from \fIobjPtr\fR.
.AP Tcl_WideInt *widePtr out
.VS 8.4
Points to place to store the wide integer value
obtained by \fBTcl_GetWideIntFromObj\fR from \fIobjPtr\fR.
.VE 8.4
Points to place to store the wide integer value retrieved from \fIobjPtr\fR.
.AP mp_int *bigValue in/out
.VS 8.5
Points to a multi-precision integer structure declared by the LibTomMath
library.
.VE 8.5
.AP double doubleValue in
.VS 8.5
Double value from which the integer part is determined and
used to initialize a multi-precision integer value.
.VE 8.5
.BE
.SH DESCRIPTION
.PP
These procedures are used to create, modify, and read
integer and wide integer Tcl objects from C code.
\fBTcl_NewIntObj\fR, \fBTcl_NewLongObj\fR,
\fBTcl_SetIntObj\fR, and \fBTcl_SetLongObj\fR
create a new object of integer type
or modify an existing object to have integer type,
.VS 8.4
and \fBTcl_NewWideIntObj\fR and \fBTcl_SetWideIntObj\fR create a new
object of wide integer type or modify an existing object to have wide
integer type.
.VE 8.4
\fBTcl_NewIntObj\fR and \fBTcl_SetIntObj\fR set the object to have the
integer value given by \fIintValue\fR,
\fBTcl_NewLongObj\fR and \fBTcl_SetLongObj\fR
set the object to have the
long integer value given by \fIlongValue\fR,
.VS 8.4
and \fBTcl_NewWideIntObj\fR and \fBTcl_SetWideIntObj\fR set the object
to have the wide integer value given by \fIwideValue\fR.
\fBTcl_NewIntObj\fR, \fBTcl_NewLongObj\fR and \fBTcl_NewWideIntObj\fR
return a pointer to a newly created object with reference count zero.
These procedures set the object's type to be integer
and assign the integer value to the object's internal representation
\fIlongValue\fR or \fIwideValue\fR member (as appropriate).
\fBTcl_SetIntObj\fR, \fBTcl_SetLongObj\fR
and \fBTcl_SetWideIntObj\fR
.VE 8.4
invalidate any old string representation and,
if the object is not already an integer object,
free any old internal representation.
.VS 8.5
These procedures are used to create, modify, and read Tcl objects
that hold integral values.
.PP
\fBTcl_GetIntFromObj\fR and \fBTcl_GetLongFromObj\fR
attempt to return an integer value from the Tcl object \fIobjPtr\fR,
.VS 8.4
and \fBTcl_GetWideIntFromObj\fR attempts to return a wide integer
value from the Tcl object \fIobjPtr\fR.
If the object is not already an integer object,
or a wide integer object in the case of \fBTcl_GetWideIntFromObj\fR
.VE 8.4
they will attempt to convert it to one.
If an error occurs during conversion, they return \fBTCL_ERROR\fR
and leave an error message in the interpreter's result object
unless \fIinterp\fR is NULL.
Also, if the long integer held in the object's internal representation
\fIlongValue\fR member can not be represented in a (non-long) integer,
\fBTcl_GetIntFromObj\fR returns \fBTCL_ERROR\fR
and leaves an error message in the interpreter's result object
unless \fIinterp\fR is NULL.
Otherwise, all three procedures return \fBTCL_OK\fR and
store the integer, long integer value
.VS 8.4
or wide integer in the address given by \fIintPtr\fR, \fIlongPtr\fR
and \fIwidePtr\fR
.VE 8.4
respectively. If the object is not already an integer or wide integer
object, the conversion will free any old internal representation.
The different routines exist to accommodate different integral types in C
with which values might be exchanged. The C integral types for which Tcl
provides value exchange routines are \fBint\fR, \fBlong int\fR,
\fBTcl_WideInt\fR, and \fBmp_int\fR. The \fBint\fR and \fBlong int\fR types
are provided by the C language standard. The \fBTcl_WideInt\fR type is a
typedef defined to be whatever signed integral type covers at least the
64-bit integer range (-9223372036854775808 to 9223372036854775807). Depending
on the platform and the C compiler, the actual type might be
\fBlong int\fR, \fBlong long int\fR, \fBint64\fR, or something else.
The \fBmp_int\fR type is a multiple-precision integer type defined
by the LibTomMath multiple-precision integer library.
.PP
The \fBTcl_NewIntObj\fR, \fBTcl_NewLongObj\fR, \fBTcl_NewWideIntObj\fR,
and \fBTcl_NewBignumObj\fR routines each create and return a new
Tcl object initialized to the integral value of the argument. The
returned Tcl object is unshared.
.PP
The \fBTcl_SetIntObj\fR, \fBTcl_SetLongObj\fR, \fBTcl_SetWideIntObj\fR,
and \fBTcl_SetBignumObj\fR routines each set the value of an existing
Tcl object pointed to by \fIobjPtr\fR to the integral value provided
by the other argument. The \fIobjPtr\fR argument must point to an
unshared Tcl object. Any attempt to set the value of a shared Tcl object
violates Tcl's copy-on-write policy. Any existing string representation
or internal representation in the unshared Tcl object will be freed
as a consequence of setting the new value.
.PP
The \fBTcl_GetIntFromObj\fR, \fBTcl_GetLongFromObj\fR,
\fBTcl_GetWideIntFromObj\fR, \fBTcl_GetBignumFromObj\fR, and
\fBTcl_TakeBignumFromObj\fR routines attempt to retrieve an integral
value of the appropriate type from the Tcl object \fIobjPtr\fR. If the
attempt succeeds, then \fBTCL_OK\fR is returned, and the value is
written to the storage provided by the caller. The attempt might
fail if \fIobjPtr\fR does not hold an integral value, or if the
value exceeds the range of the target type. If the attempt fails,
then \fBTCL_ERROR\fR is returned, and if \fIinterp\fR is non-NULL,
an error message is left in \fIinterp\fR. The \fBTcl_ObjType\fR
of \fIobjPtr\fR may be changed to make subsequent calls to the
same routine more efficient. Unlike the other functions,
\fBTcl_TakeBignumFromObj\fR may set the content of the Tcl object
\fIobjPtr\fR to an empty string in the process of retrieving the
multiple-precision integer value.
.PP
The choice between \fBTcl_GetBignumFromObj\fR and
\fBTcl_TakeBignumFromObj\fR is governed by how the caller will
continue to use \fIobjPtr\fR. If after the \fBmp_int\fR value
is retrieved from \fIobjPtr\fR, the caller will make no more
use of \fIobjPtr\fR, then using \fBTcl_TakeBignumFromObj\fR
permits Tcl to detect when an unshared \fIobjPtr\fR permits the
value to be moved instead of copied, which should be more efficient.
If anything later in the caller requires
\fIobjPtr\fR to continue to hold the same value, then
\fBTcl_GetBignumFromObj\fR must be chosen.
.PP
The \fBTcl_InitBignumFromDouble\fR routine is a utility procedure
that extracts the integer part of \fIdoubleValue\fR and stores that
integer value in the \fBmp_int\fR value \fIbigValue\fR.
.VE 8.5
.SH "SEE ALSO"
Tcl_NewObj, Tcl_DecrRefCount, Tcl_IncrRefCount, Tcl_GetObjResult
.SH KEYWORDS
integer, integer object, integer type, internal representation, object, object type, string representation
+11 -9
View File
@@ -15,9 +15,9 @@ Tcl_Interp \- client-visible fields of interpreter structures
\fB#include <tcl.h>\fR
.sp
typedef struct {
char *\fIresult\fR;
Tcl_FreeProc *\fIfreeProc\fR;
int \fIerrorLine\fR;
char *\fIresult\fR;
Tcl_FreeProc *\fIfreeProc\fR;
int \fIerrorLine\fR;
} Tcl_Interp;
typedef void Tcl_FreeProc(char *\fIblockPtr\fR);
@@ -28,17 +28,23 @@ typedef void Tcl_FreeProc(char *\fIblockPtr\fR);
The \fBTcl_CreateInterp\fR procedure returns a pointer to a Tcl_Interp
structure. This pointer is then passed into other Tcl procedures
to process commands in the interpreter and perform other operations
on the interpreter. Interpreter structures contain many many fields
on the interpreter. Interpreter structures contain many fields
that are used by Tcl, but only three that may be accessed by
clients: \fIresult\fR, \fIfreeProc\fR, and \fIerrorLine\fR.
.PP
.VS 8.5
\fBNote that access to all three fields, \fIresult\fB, \fIfreeProc\fB and
\fIerrorLine\fB is deprecated.\fR Use \fBTcl_SetResult\fR,
\fBTcl_GetResult\fR, and \fBTcl_GetReturnOptions\fR instead.
.VE 8.5
.PP
The \fIresult\fR and \fIfreeProc\fR fields are used to return
results or error messages from commands.
This information is returned by command procedures back to \fBTcl_Eval\fR,
and by \fBTcl_Eval\fR back to its callers.
The \fIresult\fR field points to the string that represents the
result or error message, and the \fIfreeProc\fR field tells how
to dispose of the storage for the string when it isn't needed anymore.
to dispose of the storage for the string when it is not needed anymore.
The easiest way for command procedures to manipulate these
fields is to call procedures like \fBTcl_SetResult\fR
or \fBTcl_AppendResult\fR; they
@@ -55,7 +61,6 @@ should point to an empty string.
Normally, results are assumed to be statically allocated,
which means that the contents will not change before the next time
\fBTcl_Eval\fR is called or some other command procedure is invoked.
.VS
In this case, the \fIfreeProc\fR field must be zero.
Alternatively, a command procedure may dynamically
allocate its return value (e.g. using \fBTcl_Alloc\fR)
@@ -64,7 +69,6 @@ In this case, the command procedure must also set \fIinterp->freeProc\fR
to the address of a procedure that can free the value, or \fBTCL_DYNAMIC\fR
if the storage was allocated directly by Tcl or by a call to
\fBTcl_Alloc\fR.
.VE
If \fIinterp->freeProc\fR is non-zero, then Tcl will call \fIfreeProc\fR
to free the space pointed to by \fIinterp->result\fR before it
invokes the next command.
@@ -76,10 +80,8 @@ macro should be used for this purpose).
\fIFreeProc\fR should have arguments and result that match the
\fBTcl_FreeProc\fR declaration above: it receives a single
argument which is a pointer to the result value to free.
.VS
In most applications \fBTCL_DYNAMIC\fR is the only non-zero value ever
used for \fIfreeProc\fR.
.VE
However, an application may store a different procedure address
in \fIfreeProc\fR in order to use an alternate memory allocator
or in order to do other cleanup when the result memory is freed.
+194
View File
@@ -0,0 +1,194 @@
'\"
'\" Copyright (c) 2004 Donal K. Fellows
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.so man.macros
.TH Tcl_LimitCheck 3 8.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_LimitAddHandler, Tcl_LimitCheck, Tcl_LimitExceeded, Tcl_LimitGetCommands, Tcl_LimitGetGranularity, Tcl_LimitGetTime, Tcl_LimitReady, Tcl_LimitRemoveHandler, Tcl_LimitSetCommands, Tcl_LimitSetGranularity, Tcl_LimitSetTime, Tcl_LimitTypeEnabled, Tcl_LimitTypeExceeded, Tcl_LimitTypeReset, Tcl_LimitTypeSet \- manage and check resource limits on interpreters
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
int
\fBTcl_LimitCheck\fR(\fIinterp\fR)
.sp
int
\fBTcl_LimitReady\fR(\fIinterp\fR)
.sp
int
\fBTcl_LimitExceeded\fR(\fIinterp\fR)
.sp
int
\fBTcl_LimitTypeExceeded\fR(\fIinterp, type\fR)
.sp
int
\fBTcl_LimitTypeEnabled\fR(\fIinterp, type\fR)
.sp
void
\fBTcl_LimitTypeSet\fR(\fIinterp, type\fR)
.sp
void
\fBTcl_LimitTypeReset\fR(\fIinterp, type\fR)
.sp
int
\fBTcl_LimitGetCommands\fR(\fIinterp\fR)
.sp
void
\fBTcl_LimitSetCommands\fR(\fIinterp, commandLimit\fR)
.sp
void
\fBTcl_LimitGetTime\fR(\fIinterp, timeLimitPtr\fR)
.sp
void
\fBTcl_LimitSetTime\fR(\fIinterp, timeLimitPtr\fR)
.sp
int
\fBTcl_LimitGetGranularity\fR(\fIinterp, type\fR)
.sp
void
\fBTcl_LimitSetGranularity\fR(\fIinterp, type, granularity\fR)
.sp
void
\fBTcl_LimitAddHandler\fR(\fIinterp, type, handlerProc, clientData, deleteProc\fR)
.sp
void
\fBTcl_LimitRemoveHandler\fR(\fIinterp, type, handlerProc, clientData\fR)
.SH ARGUMENTS
.AS Tcl_LimitHandlerDeleteProc commandLimit in/out
.AP Tcl_Interp *interp in
Interpreter that the limit being managed applies to or that will have
its limits checked.
.AP int type in
The type of limit that the operation refers to. This must be either
\fBTCL_LIMIT_COMMANDS\fR or \fBTCL_LIMIT_TIME\fR.
.AP int commandLimit in
The maximum number of commands (as reported by \fBinfo cmdcount\fR)
that may be executed in the interpreter.
.AP Tcl_Time *timeLimitPtr in/out
A pointer to a structure that will either have the new time limit read
from (\fBTcl_LimitSetTime\fR) or the current time limit written to
(\fBTcl_LimitGetTime\fR).
.AP int granularity in
Divisor that indicates how often a particular limit should really be
checked. Must be at least 1.
.AP Tcl_LimitHandlerProc *handlerProc in
Function to call when a particular limit is exceeded. If the
\fIhandlerProc\fR removes or raises the limit during its processing,
the limited interpreter will be permitted to continue to process after
the handler returns. Many handlers may be attached to the same
interpreter limit; their order of execution is not defined, and they
must be identified by \fIhandlerProc\fR and \fIclientData\fR when they
are deleted.
.AP ClientData clientData in
Arbitrary pointer-sized word used to pass some context to the
\fIhandlerProc\fR function.
.AP Tcl_LimitHandlerDeleteProc *deleteProc in
Function to call whenever a handler is deleted. May be NULL if the
\fIclientData\fR requires no deletion.
.BE
.SH DESCRIPTION
.PP
Tcl's interpreter resource limit subsystem allows for close control
over how much computation time a script may use, and is useful for
cases where a program is divided into multiple pieces where some parts
are more trusted than others (e.g. web application servers).
.PP
Every interpreter may have a limit on the wall-time for execution, and
a limit on the number of commands that the interpreter may execute.
Since checking of these limits is potentially expensive (especially
the time limit), each limit also has a checking granularity, which is
a divisor for an internal count of the number of points in the core
where a check may be performed (which is immediately before executing
a command and at an unspecified frequency between running commands,
which can happen in empty-bodied \fBwhile\fR loops).
.PP
The final component of the limit engine is a callback scheme which
allows for notifications of when a limit has been exceeded. These
callbacks can just provide logging, or may allocate more resources to
the interpreter to permit it to continue processing longer.
.PP
When a limit is exceeded (and the callbacks have run; the order of
execution of the callbacks is unspecified) execution in the limited
interpreter is stopped by raising an error and setting a flag that
prevents the \fBcatch\fR command in that interpreter from trapping
that error. It is up to the context that started execution in that
interpreter (typically a master interpreter) to handle the error.
.SH "LIMIT CHECKING API"
.PP
To check the resource limits for an interpreter, call
\fBTcl_LimitCheck\fR, which returns \fBTCL_OK\fR if the limit was not
exceeded (after processing callbacks) and \fBTCL_ERROR\fR if the limit was
exceeded (in which case an error message is also placed in the
interpreter result). That function should only be called when
\fBTcl_LimitReady\fR returns non-zero so that granularity policy is
enforced. This API is designed to be similar in usage to
\fBTcl_AsyncReady\fR and \fBTcl_AsyncInvoke\fR.
.PP
When writing code that may behave like \fBcatch\fR in respect of
errors, you should only trap an error if \fBTcl_LimitExceeded\fR
returns zero. If it returns non-zero, the interpreter is in a
limit-exceeded state and errors should be allowed to propagate to the
calling context. You can also check whether a particular type of
limit has been exceeded using \fBTcl_LimitTypeExceeded\fR.
.SH "LIMIT CONFIGURATION"
.PP
To check whether a limit has been set (but not whether it has actually
been exceeded) on an interpreter, call \fBTcl_LimitTypeEnabled\fR with
the type of limit you want to check. To enable a particular limit
call \fBTcl_LimitTypeSet\fR, and to disable a limit call
\fBTcl_LimitTypeReset\fR.
.PP
The level of a command limit may be set using
\fBTcl_LimitSetCommands\fR, and retrieved using
\fBTcl_LimitGetCommands\fR. Similarly for a time limit with
\fBTcl_LimitSetTime\fR and \fBTcl_LimitGetTime\fR respectively, but
with that API the time limit is copied from and to the Tcl_Time
structure that the \fItimeLimitPtr\fR argument points to.
.PP
The checking granularity for a particular limit may be set using
\fBTcl_LimitSetGranularity\fR and retrieved using
\fBTcl_LimitGetGranularity\fR. Note that granularities must always be
positive.
.SS "LIMIT CALLBACKS"
.PP
To add a handler callback to be invoked when a limit is exceeded, call
\fBTcl_LimitAddHandler\fR. The \fIhandlerProc\fR argument describes
the function that will actually be called; it should have the
following prototype:
.PP
.CS
typedef void Tcl_LimitHandlerProc(
ClientData \fIclientData\fR,
Tcl_Interp *\fIinterp\fR);
.CE
.PP
The \fIclientData\fR argument to the handler will be whatever is
passed to the \fIclientData\fR argument to \fBTcl_LimitAddHandler\fR,
and the \fIinterp\fR is the interpreter that had its limit exceeded.
.PP
The \fIdeleteProc\fR argument to \fBTcl_LimitAddHandler\fR is a
function to call to delete the \fIclientData\fR value. It may be
\fBTCL_STATIC\fR or NULL if no deletion action is necessary, or
\fBTCL_DYNAMIC\fR if all that is necessary is to free the structure with
\fBTcl_Free\fR. Otherwise, it should refer to a function with the
following prototype:
.PP
.CS
typedef void Tcl_LimitHandlerDeleteProc(
ClientData \fIclientData\fR);
.CE
.PP
A limit handler may be deleted using \fBTcl_LimitRemoveHandler\fR; the
handler removed will be the first one found (out of the handlers added
with \fBTcl_LimitAddHandler\fR) with exactly matching \fItype\fR,
\fIhandlerProc\fR and \fIclientData\fR arguments. This function
always invokes the \fIdeleteProc\fR on the \fIclientData\fR (unless
the \fIdeleteProc\fR was NULL or \fBTCL_STATIC\fR).
.SH KEYWORDS
interpreter, resource, limit, commands, time, callback
+103 -19
View File
@@ -25,17 +25,24 @@ int
.AP Tcl_Interp *interp in
Interpreter that contains \fIvarName\fR.
Also used by \fBTcl_LinkVar\fR to return error messages.
.AP "CONST char" *varName in
Name of global variable.
.AP "const char" *varName in
Name of global variable.
.AP char *addr in
Address of C variable that is to be linked to \fIvarName\fR.
.AP int type in
Type of C variable. Must be one of TCL_LINK_INT, TCL_LINK_DOUBLE,
.VS 8.4
TCL_LINK_WIDE_INT,
.VE 8.4
TCL_LINK_BOOLEAN, or TCL_LINK_STRING, optionally OR'ed with
TCL_LINK_READ_ONLY to make Tcl variable read-only.
Type of C variable. Must be one of \fBTCL_LINK_INT\fR,
.VS 8.5
\fBTCL_LINK_UINT\fR, \fBTCL_LINK_CHAR\fR, \fBTCL_LINK_UCHAR\fR,
\fBTCL_LINK_SHORT\fR, \fBTCL_LINK_USHORT\fR, \fBTCL_LINK_LONG\fR,
\fBTCL_LINK_ULONG\fR,
.VE 8.5
\fBTCL_LINK_WIDE_INT\fR,
.VS 8.5
\fBTCL_LINK_WIDE_UINT\fR, \fBTCL_LINK_FLOAT\fR,
.VE 8.5
\fBTCL_LINK_DOUBLE\fR, \fBTCL_LINK_BOOLEAN\fR, or
\fBTCL_LINK_STRING\fR, optionally OR'ed with \fBTCL_LINK_READ_ONLY\fR
to make Tcl variable read-only.
.BE
.SH DESCRIPTION
@@ -46,14 +53,14 @@ given by \fIaddr\fR.
Whenever the Tcl variable is read the value of the C variable will
be returned, and whenever the Tcl variable is written the C
variable will be updated to have the same value.
\fBTcl_LinkVar\fR normally returns TCL_OK; if an error occurs
\fBTcl_LinkVar\fR normally returns \fBTCL_OK\fR; if an error occurs
while setting up the link (e.g. because \fIvarName\fR is the
name of array) then TCL_ERROR is returned and the interpreter's result
name of array) then \fBTCL_ERROR\fR is returned and the interpreter's result
contains an error message.
.PP
The \fItype\fR argument specifies the type of the C variable,
and must have one of the following values, optionally OR'ed with
TCL_LINK_READ_ONLY:
\fBTCL_LINK_READ_ONLY\fR:
.TP
\fBTCL_LINK_INT\fR
The C variable is of type \fBint\fR.
@@ -61,6 +68,61 @@ Any value written into the Tcl variable must have a proper integer
form acceptable to \fBTcl_GetIntFromObj\fR; attempts to write
non-integer values into \fIvarName\fR will be rejected with
Tcl errors.
.VS 8.5
.TP
\fBTCL_LINK_UINT\fR
The C variable is of type \fBunsigned int\fR.
Any value written into the Tcl variable must have a proper unsigned
integer form acceptable to \fBTcl_GetWideIntFromObj\fR and in the
platform's defined range for the \fBunsigned int\fR type; attempts to
write non-integer values (or values outside the range) into
\fIvarName\fR will be rejected with Tcl errors.
.TP
\fBTCL_LINK_CHAR\fR
The C variable is of type \fBchar\fR.
Any value written into the Tcl variable must have a proper integer
form acceptable to \fBTcl_GetIntFromObj\fR and be in the range of the
\fBchar\fR datatype; attempts to write non-integer or out-of-range
values into \fIvarName\fR will be rejected with Tcl errors.
.TP
\fBTCL_LINK_UCHAR\fR
The C variable is of type \fBunsigned char\fR.
Any value written into the Tcl variable must have a proper unsigned
integer form acceptable to \fBTcl_GetIntFromObj\fR and in the
platform's defined range for the \fBunsigned char\fR type; attempts to
write non-integer values (or values outside the range) into
\fIvarName\fR will be rejected with Tcl errors.
.TP
\fBTCL_LINK_SHORT\fR
The C variable is of type \fBshort\fR.
Any value written into the Tcl variable must have a proper integer
form acceptable to \fBTcl_GetIntFromObj\fR and be in the range of the
\fBshort\fR datatype; attempts to write non-integer or out-of-range
values into \fIvarName\fR will be rejected with Tcl errors.
.TP
\fBTCL_LINK_USHORT\fR
The C variable is of type \fBunsigned short\fR.
Any value written into the Tcl variable must have a proper unsigned
integer form acceptable to \fBTcl_GetIntFromObj\fR and in the
platform's defined range for the \fBunsigned short\fR type; attempts to
write non-integer values (or values outside the range) into
\fIvarName\fR will be rejected with Tcl errors.
.TP
\fBTCL_LINK_LONG\fR
The C variable is of type \fBlong\fR.
Any value written into the Tcl variable must have a proper integer
form acceptable to \fBTcl_GetLongFromObj\fR; attempts to write
non-integer or out-of-range
values into \fIvarName\fR will be rejected with Tcl errors.
.TP
\fBTCL_LINK_ULONG\fR
The C variable is of type \fBunsigned long\fR.
Any value written into the Tcl variable must have a proper unsigned
integer form acceptable to \fBTcl_GetWideIntFromObj\fR and in the
platform's defined range for the \fBunsigned long\fR type; attempts to
write non-integer values (or values outside the range) into
\fIvarName\fR will be rejected with Tcl errors.
.VE 8.5
.TP
\fBTCL_LINK_DOUBLE\fR
The C variable is of type \fBdouble\fR.
@@ -68,21 +130,44 @@ Any value written into the Tcl variable must have a proper real
form acceptable to \fBTcl_GetDoubleFromObj\fR; attempts to write
non-real values into \fIvarName\fR will be rejected with
Tcl errors.
.VS 8.5
.TP
\fBTCL_LINK_FLOAT\fR
The C variable is of type \fBfloat\fR.
Any value written into the Tcl variable must have a proper real
form acceptable to \fBTcl_GetDoubleFromObj\fR and must be within the
range acceptable for a \fBfloat\fR; attempts to
write non-real values (or values outside the range) into
\fIvarName\fR will be rejected with Tcl errors.
.VE 8.5
.TP
\fBTCL_LINK_WIDE_INT\fR
.VS 8.4
The C variable is of type \fBTcl_WideInt\fR (which is an integer type
at least 64-bits wide on all platforms that can support it.)
Any value written into the Tcl variable must have a proper integer
form acceptable to \fBTcl_GetWideIntFromObj\fR; attempts to write
non-integer values into \fIvarName\fR will be rejected with
Tcl errors.
.VE 8.4
.VS 8.5
.TP
\fBTCL_LINK_WIDE_UINT\fR
The C variable is of type \fBTcl_WideUInt\fR (which is an unsigned
integer type at least 64-bits wide on all platforms that can support
it.)
Any value written into the Tcl variable must have a proper unsigned
integer form acceptable to \fBTcl_GetWideIntFromObj\fR (it will be
cast to unsigned);
.\" FIXME! Use bignums instead.
attempts to write non-integer values into \fIvarName\fR will be
rejected with Tcl errors.
.VE 8.5
.TP
\fBTCL_LINK_BOOLEAN\fR
The C variable is of type \fBint\fR.
If its value is zero then it will read from Tcl as ``0'';
otherwise it will read from Tcl as ``1''.
If its value is zero then it will read from Tcl as
.QW 0 ;
otherwise it will read from Tcl as
.QW 1 .
Whenever \fIvarName\fR is
modified, the C variable will be set to a 0 or 1 value.
Any value written into the Tcl variable must have a proper boolean
@@ -92,17 +177,16 @@ Tcl errors.
.TP
\fBTCL_LINK_STRING\fR
The C variable is of type \fBchar *\fR.
.VS
If its value is not NULL then it must be a pointer to a string
allocated with \fBTcl_Alloc\fR or \fBckalloc\fR.
.VE
Whenever the Tcl variable is modified the current C string will be
freed and new memory will be allocated to hold a copy of the variable's
new value.
If the C variable contains a NULL pointer then the Tcl variable
will read as ``NULL''.
will read as
.QW NULL .
.PP
If the TCL_LINK_READ_ONLY flag is present in \fItype\fR then the
If the \fBTCL_LINK_READ_ONLY\fR flag is present in \fItype\fR then the
variable will be read-only from Tcl, so that its value can only be
changed by modifying the C variable.
Attempts to write the variable from Tcl will be rejected with errors.
+16 -11
View File
@@ -36,7 +36,7 @@ int
int
\fBTcl_ListObjReplace\fR(\fIinterp, listPtr, first, count, objc, objv\fR)
.SH ARGUMENTS
.AS Tcl_Interp "*CONST objv[]" out
.AS "Tcl_Obj *const" *elemListPtr in/out
.AP Tcl_Interp *interp in
If an error occurs while converting an object to be a list object,
an error message is left in the interpreter's result object
@@ -71,13 +71,11 @@ will insert into a new list object,
and \fBTcl_ListObjReplace\fR will insert into \fIlistPtr\fR.
For \fBTcl_SetListObj\fR,
the number of Tcl objects to insert into \fIobjPtr\fR.
.VS
.AP Tcl_Obj "*CONST\ objv[]" in
.AP "Tcl_Obj *const" objv[] in
An array of pointers to objects.
\fBTcl_NewListObj\fR will insert these objects into a new list object
and \fBTcl_ListObjReplace\fR will insert them into an existing \fIlistPtr\fR.
Each object will become a separate list element.
.VE
.AP int *intPtr out
Points to location where \fBTcl_ListObjLength\fR
stores the length of the list.
@@ -151,8 +149,9 @@ has reference count zero.
the elements in a list object. It returns the count by storing it in the
address \fIobjcPtr\fR. Similarly, it returns the array pointer by storing
it in the address \fIobjvPtr\fR.
The memory pointed to is managed by Tcl and should not be freed by the
caller.
The memory pointed to is managed by Tcl and should not be freed or written
to by the caller. If the list is empty, 0 is stored at \fIobjcPtr\fR
and NULL at \fIobjvPtr\fR.
If \fIlistPtr\fR is not already a list object, \fBTcl_ListObjGetElements\fR
will attempt to convert it to one; if the conversion fails, it returns
\fBTCL_ERROR\fR and leaves an error message in the interpreter's result
@@ -219,27 +218,33 @@ it can be used to implement a number of list operations.
For example, the following code inserts the \fIobjc\fR objects
referenced by the array of object pointers \fIobjv\fR
just before the element \fIindex\fR of the list referenced by \fIlistPtr\fR:
.PP
.CS
result = Tcl_ListObjReplace(interp, listPtr, index, 0, objc, objv);
result = Tcl_ListObjReplace(interp, listPtr, index, 0,
objc, objv);
.CE
.PP
Similarly, the following code appends the \fIobjc\fR objects
referenced by the array \fIobjv\fR
to the end of the list \fIlistPtr\fR:
.PP
.CS
result = Tcl_ListObjLength(interp, listPtr, &length);
if (result == TCL_OK) {
result = Tcl_ListObjReplace(interp, listPtr, length, 0, objc, objv);
result = Tcl_ListObjReplace(interp, listPtr, length, 0,
objc, objv);
}
.CE
.PP
The \fIcount\fR list elements starting at \fIfirst\fR can be deleted
by simply calling \fBTcl_ListObjReplace\fR
with a NULL \fIobjvPtr\fR:
.PP
.CS
result = Tcl_ListObjReplace(interp, listPtr, first, count, 0, NULL);
result = Tcl_ListObjReplace(interp, listPtr, first, count,
0, NULL);
.CE
.SH "SEE ALSO"
Tcl_NewObj, Tcl_DecrRefCount, Tcl_IncrRefCount, Tcl_GetObjResult
.SH KEYWORDS
append, index, insert, internal representation, length, list, list object, list type, object, object type, replace, string representation
+165
View File
@@ -0,0 +1,165 @@
'\"
'\" Copyright (c) 2003 Donal K. Fellows
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
'\" Note that some of these functions do not seem to belong, but they
'\" were all introduced with the same TIP (#139)
'\"
.so man.macros
.TH Tcl_Namespace 3 8.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_AppendExportList, Tcl_CreateNamespace, Tcl_DeleteNamespace, Tcl_Export, Tcl_FindCommand, Tcl_FindNamespace, Tcl_ForgetImport, Tcl_GetCurrentNamespace, Tcl_GetGlobalNamespace, Tcl_GetNamespaceUnknownHandler, Tcl_Import, Tcl_SetNamespaceUnknownHandler \- manipulate namespaces
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
Tcl_Namespace *
\fBTcl_CreateNamespace\fR(\fIinterp, name, clientData, deleteProc\fR)
.sp
\fBTcl_DeleteNamespace\fR(\fInsPtr\fR)
.sp
int
\fBTcl_AppendExportList\fR(\fIinterp, nsPtr, objPtr\fR)
.sp
int
\fBTcl_Export\fR(\fIinterp, nsPtr, pattern, resetListFirst\fR)
.sp
int
\fBTcl_Import\fR(\fIinterp, nsPtr, pattern, allowOverwrite\fR)
.sp
int
\fBTcl_ForgetImport\fR(\fIinterp, nsPtr, pattern\fR)
.sp
Tcl_Namespace *
\fBTcl_GetCurrentNamespace\fR(\fIinterp\fR)
.sp
Tcl_Namespace *
\fBTcl_GetGlobalNamespace\fR(\fIinterp\fR)
.sp
Tcl_Namespace *
\fBTcl_FindNamespace\fR(\fIinterp, name, contextNsPtr, flags\fR)
.sp
Tcl_Command
\fBTcl_FindCommand\fR(\fIinterp, name, contextNsPtr, flags\fR)
.sp
Tcl_Obj *
\fBTcl_GetNamespaceUnknownHandler(\fIinterp, nsPtr\fR)
.sp
int
\fBTcl_SetNamespaceUnknownHandler(\fIinterp, nsPtr, handlerPtr\fR)
.SH ARGUMENTS
.AS Tcl_NamespaceDeleteProc allowOverwrite in/out
.AP Tcl_Interp *interp in/out
The interpreter in which the namespace exists and where name lookups
are performed. Also where error result messages are written.
.AP "const char" *name in
The name of the namespace or command to be created or accessed.
.AP ClientData clientData in
A context pointer by the creator of the namespace. Not interpreted by
Tcl at all.
.AP Tcl_NamespaceDeleteProc *deleteProc in
A pointer to function to call when the namespace is deleted, or NULL
if no such callback is to be performed.
.AP Tcl_Namespace *nsPtr in
The namespace to be manipulated, or NULL (for other than
\fBTcl_DeleteNamespace\fR) to manipulate the current namespace.
.AP Tcl_Obj *objPtr out
A reference to an unshared object to which the function output will be
written.
.AP "const char" *pattern in
The glob-style pattern (see \fBTcl_StringMatch\fR) that describes the
commands to be imported or exported.
.AP int resetListFirst in
Whether the list of export patterns should be reset before adding the
current pattern to it.
.AP int allowOverwrite in
Whether new commands created by this import action can overwrite
existing commands.
.AP Tcl_Namespace *contextNsPtr in
The location in the namespace hierarchy where the search for a
namespace or command should be conducted relative to when the search
term is not rooted at the global namespace. NULL indicates the
current namespace.
.AP int flags in
OR-ed combination of bits controlling how the search is to be
performed. The following flags are supported: \fBTCL_GLOBAL_ONLY\fR
(indicates that the search is always to be conducted relative to the
global namespace), \fBTCL_NAMESPACE_ONLY\fR (just for \fBTcl_FindCommand\fR;
indicates that the search is always to be conducted relative to the
context namespace), and \fBTCL_LEAVE_ERR_MSG\fR (indicates that an error
message should be left in the interpreter if the search fails.)
.AP Tcl_Obj *handlerPtr in
A script fragment to be installed as the unknown command handler for the
namespace, or NULL to reset the handler to its default.
.BE
.SH DESCRIPTION
.PP
Namespaces are hierarchic naming contexts that can contain commands
and variables. They also maintain a list of patterns that describes
what commands are exported, and can import commands that have been
exported by other namespaces. Namespaces can also be manipulated
through the Tcl command \fBnamespace\fR.
.PP
The \fITcl_Namespace\fR structure encapsulates a namespace, and is
guaranteed to have the following fields in it: \fIname\fR (the local
name of the namespace, with no namespace separator characters in it,
with empty denoting the global namespace), \fIfullName\fR (the fully
specified name of the namespace), \fIclientData\fR, \fIdeleteProc\fR
(the values specified in the call to \fBTcl_CreateNamespace\fR), and
\fIparentPtr\fR (a pointer to the containing namespace, or NULL for
the global namespace.)
.PP
\fBTcl_CreateNamespace\fR creates a new namespace. The
\fIdeleteProc\fR will have the following type signature:
.CS
typedef void (Tcl_NamespaceDeleteProc) (ClientData clientData);
.CE
.PP
\fBTcl_DeleteNamespace\fR deletes a namespace.
.PP
\fBTcl_AppendExportList\fR retrieves the export patterns for a
namespace given namespace and appends them (as list items) to
\fIobjPtr\fR.
.PP
\fBTcl_Export\fR sets and appends to the export patterns for a
namespace. Patterns are appended unless the \fIresetListFirst\fR flag
is true.
.PP
\fBTcl_Import\fR imports commands matching a pattern into a
namespace. Note that the pattern must include the name of the
namespace to import from. This function returns an error if
an attempt to import a command over an existing command is made,
unless the \fIallowOverwrite\fR flag has been set.
.PP
\fBTcl_ForgetImport\fR removes imports matching a pattern.
.PP
\fBTcl_GetCurrentNamespace\fR returns the current namespace for an
interpreter.
.PP
\fBTcl_GetGlobalNamespace\fR returns the global namespace for an
interpreter.
.PP
\fBTcl_FindNamespace\fR searches for a namespace named \fIname\fR
within the context of the namespace \fIcontextNsPtr\fR. If the
namespace cannot be found, NULL is returned.
.PP
\fBTcl_FindCommand\fR searches for a command named \fIname\fR within
the context of the namespace \fIcontextNsPtr\fR. If the command
cannot be found, NULL is returned.
.PP
\fBTcl_GetNamespaceUnknownHandler\fR returns the unknown command handler
for the namespace, or NULL if none is set.
.PP
\fBTcl_SetNamespaceUnknownHandler\fR sets the unknown command handler for
the namespace. If \fIhandlerPtr\fR is NULL, then the handler is reset to
its default.
.SH "SEE ALSO"
Tcl_CreateCommand, Tcl_ListObjAppendElements, Tcl_SetVar
.SH KEYWORDS
namespace, command
+84 -57
View File
@@ -25,7 +25,6 @@ void
.sp
void
\fBTcl_QueueEvent\fR(\fIevPtr, position\fR)
.VS 8.1
.sp
void
\fBTcl_ThreadQueueEvent\fR(\fIthreadId, evPtr, position\fR)
@@ -63,12 +62,16 @@ int
int
\fBTcl_GetServiceMode\fR()
.sp
int
int
\fBTcl_SetServiceMode\fR(\fImode\fR)
.VE
.sp
void
\fBTcl_ServiceModeHook\fR(\fImode\fR)
.sp
void
\fBTcl_SetNotifier\fR(\fInotifierProcPtr\fR)
.SH ARGUMENTS
.AS Tcl_EventDeleteProc milliseconds
.AS Tcl_EventDeleteProc *notifierProcPtr
.AP Tcl_EventSetupProc *setupProc in
Procedure to invoke to prepare for event wait in \fBTcl_DoOneEvent\fR.
.AP Tcl_EventCheckProc *checkProc in
@@ -97,11 +100,13 @@ Procedure to invoke for each queued event in \fBTcl_DeleteEvents\fR.
.AP int flags in
What types of events to service. These flags are the same as those
passed to \fBTcl_DoOneEvent\fR.
.VS 8.1
.AP int mode in
Indicates whether events should be serviced by \fBTcl_ServiceAll\fR.
Must be one of \fBTCL_SERVICE_NONE\fR or \fBTCL_SERVICE_ALL\fR.
.VE
.AP Tcl_NotifierProcs* notifierProcPtr in
Structure of function pointers describing notifier procedures that are
to replace the ones installed in the executable. See
\fBREPLACING THE NOTIFIER\fR for details.
.BE
.SH INTRODUCTION
@@ -135,9 +140,7 @@ sources place events onto the queue so that they may be processed in
order at appropriate times during the event loop. The event queue
guarantees a fair discipline of event handling, so that no event
source can starve the others. It also allows events to be saved for
servicing at a future time.
.VS 8.1
Threaded applications work in a
servicing at a future time. Threaded applications work in a
similar manner, except that there is a separate event queue for
each thread containing a Tcl interpreter.
\fBTcl_QueueEvent\fR is used (primarily
@@ -169,7 +172,6 @@ The procedures \fBTcl_ServiceAll\fR, \fBTcl_ServiceEvent\fR,
to help connect Tcl's event loop to an external event loop such as
Motif's.
.SH "NOTIFIER BASICS"
.VE
.PP
The easiest way to understand how the notifier works is to consider
what happens when \fBTcl_DoOneEvent\fR is called.
@@ -180,17 +182,13 @@ things:
.IP [1]
Check the event queue to see if it contains any events that can
be serviced. If so, service the first possible event, remove it
.VS 8.1
from the queue, and return. It does this by calling
\fBTcl_ServiceEvent\fR and passing in the \fIflags\fR argument.
.VE
.IP [2]
Prepare to block for an event. To do this, \fBTcl_DoOneEvent\fR
invokes a \fIsetup procedure\fR in each event source.
The event source will perform event-source specific initialization and
.VS 8.1
possibly call \fBTcl_SetMaxBlockTime\fR to limit how long
.VE
\fBTcl_WaitForEvent\fR will block if no new events occur.
.IP [3]
Call \fBTcl_WaitForEvent\fR. This procedure is implemented differently
@@ -233,8 +231,8 @@ the event source.
\fISetupProc\fR should match the following prototype:
.CS
typedef void Tcl_EventSetupProc(
ClientData \fIclientData\fR,
int \fIflags\fR);
ClientData \fIclientData\fR,
int \fIflags\fR);
.CE
The \fIclientData\fR argument will be the same as the \fIclientData\fR
argument to \fBTcl_CreateEventSource\fR; it is typically used to
@@ -243,7 +241,7 @@ The \fIflags\fR argument will be the same as the \fIflags\fR
argument passed to \fBTcl_DoOneEvent\fR except that it will never
be 0 (\fBTcl_DoOneEvent\fR replaces 0 with \fBTCL_ALL_EVENTS\fR).
\fIFlags\fR indicates what kinds of events should be considered;
if the bit corresponding to this event source isn't set, the event
if the bit corresponding to this event source is not set, the event
source should return immediately without doing anything. For
example, the file event source checks for the \fBTCL_FILE_EVENTS\fR
bit.
@@ -256,7 +254,6 @@ request notification with a Windows event. For timer-driven event
sources such as timer events or any polled event, the event source
can call \fBTcl_SetMaxBlockTime\fR to force the application to wake
up after a specified time even if no events have occurred.
.VS 8.1
If no event source calls \fBTcl_SetMaxBlockTime\fR
then \fBTcl_WaitForEvent\fR will wait as long as necessary for an
event to occur; otherwise, it will only wait as long as the shortest
@@ -268,28 +265,24 @@ events already queued. If there are, it calls
\fBTcl_SetMaxBlockTime\fR with a 0 block time so that
\fBTcl_WaitForEvent\fR does not block if there is no new data on the X
connection.
.VE
The \fItimePtr\fR argument to \fBTcl_WaitForEvent\fR points to
a structure that describes a time interval in seconds and
microseconds:
.CS
typedef struct Tcl_Time {
long \fIsec\fR;
long \fIusec\fR;
long \fIsec\fR;
long \fIusec\fR;
} Tcl_Time;
.CE
The \fIusec\fR field should be less than 1000000.
.PP
.VS 8.1
Information provided to \fBTcl_SetMaxBlockTime\fR
is only used for the next call to \fBTcl_WaitForEvent\fR; it is
discarded after \fBTcl_WaitForEvent\fR returns.
.VE
The next time an event wait is done each of the event sources'
setup procedures will be called again, and they can specify new
information for that event wait.
.PP
.VS 8.1
If the application uses an external event loop rather than
\fBTcl_DoOneEvent\fR, the event sources may need to call
\fBTcl_SetMaxBlockTime\fR at other times. For example, if a new event
@@ -305,7 +298,6 @@ platform-specific procedures may also be available for
\fIsetupProc\fR, if there is additional information needed by
\fBTcl_WaitForEvent\fR on that platform. For example, on Unix systems
the \fBTcl_CreateFileHandler\fR interface can be used to wait for file events.
.VE
.PP
The second procedure provided by each event source is its check
procedure, indicated by the \fIcheckProc\fR argument to
@@ -313,8 +305,8 @@ procedure, indicated by the \fIcheckProc\fR argument to
following prototype:
.CS
typedef void Tcl_EventCheckProc(
ClientData \fIclientData\fR,
int \fIflags\fR);
ClientData \fIclientData\fR,
int \fIflags\fR);
.CE
The arguments to this procedure are the same as those for \fIsetupProc\fR.
\fBCheckProc\fR is invoked by \fBTcl_DoOneEvent\fR after it has waited
@@ -363,24 +355,20 @@ events at the front of the queue, such as a series of
Enter and Leave events synthesized during a grab or ungrab operation
in Tk.
.PP
.VS 8.1
When it is time to handle an event from the queue (steps 1 and 4
above) \fBTcl_ServiceEvent\fR will invoke the \fIproc\fR specified
.VE
in the first queued \fBTcl_Event\fR structure.
\fIProc\fR must match the following prototype:
.CS
typedef int Tcl_EventProc(
Tcl_Event *\fIevPtr\fR,
int \fIflags\fR);
Tcl_Event *\fIevPtr\fR,
int \fIflags\fR);
.CE
The first argument to \fIproc\fR is a pointer to the event, which will
be the same as the first argument to the \fBTcl_QueueEvent\fR call that
added the event to the queue.
The second argument to \fIproc\fR is the \fIflags\fR argument for the
.VS 8.1
current call to \fBTcl_ServiceEvent\fR; this is used by the event source
.VE
to return immediately if its events are not relevant.
.PP
It is up to \fIproc\fR to handle the event, typically by invoking
@@ -389,20 +377,17 @@ Once the event source has finished handling the event it returns 1
to indicate that the event can be removed from the queue.
If for some reason the event source decides that the event cannot
be handled at this time, it may return 0 to indicate that the event
.VS 8.1
should be deferred for processing later; in this case \fBTcl_ServiceEvent\fR
.VE
will go on to the next event in the queue and attempt to service it.
There are several reasons why an event source might defer an event.
One possibility is that events of this type are excluded by the
\fIflags\fR argument.
For example, the file event source will always return 0 if the
\fBTCL_FILE_EVENTS\fR bit isn't set in \fIflags\fR.
\fBTCL_FILE_EVENTS\fR bit is not set in \fIflags\fR.
Another example of deferring events happens in Tk if
\fBTk_RestrictEvents\fR has been invoked to defer certain kinds
of window events.
.PP
.VS 8.1
When \fIproc\fR returns 1, \fBTcl_ServiceEvent\fR will remove the
event from the event queue and free its storage.
Note that the storage for an event must be allocated by
@@ -422,8 +407,9 @@ Tcl_ThreadID for the current thread, use the \fBTcl_GetCurrentThread\fR
procedure. (A thread would then need to pass this identifier to other
threads for those threads to be able to add events to its queue.)
After adding an event to another thread's queue, you then typically
need to call \fBTcl_ThreadAlert\fR to "wake up" that thread's notifier to
alert it to the new event.
need to call \fBTcl_ThreadAlert\fR to
.QW "wake up"
that thread's notifier to alert it to the new event.
.PP
\fBTcl_DeleteEvents\fR can be used to explicitly remove one or more
events from the event queue. \fBTcl_DeleteEvents\fR calls \fIproc\fR
@@ -432,8 +418,8 @@ returns 1. Events for which the procedure returns 0 are left in the
queue. \fIProc\fR should match the following prototype:
.CS
typedef int Tcl_EventDeleteProc(
Tcl_Event *\fIevPtr\fR,
ClientData \fIclientData\fR);
Tcl_Event *\fIevPtr\fR,
ClientData \fIclientData\fR);
.CE
The \fIclientData\fR argument will be the same as the \fIclientData\fR
argument to \fBTcl_DeleteEvents\fR; it is typically used to point to
@@ -444,23 +430,21 @@ point to the next event in the queue.
\fIcheckProc\fR, and \fIclientData\fR arguments must exactly match those
provided to the \fBTcl_CreateEventSource\fR for the event source to be deleted.
If no such source exists, \fBTcl_DeleteEventSource\fR has no effect.
.VE
.SH "CREATING A NEW NOTIFIER"
.PP
The notifier consists of all the procedures described in this manual
entry, plus \fBTcl_DoOneEvent\fR and \fBTcl_Sleep\fR, which are
.VS 8.1
available on all platforms, and \fBTcl_CreateFileHandler\fR and
\fBTcl_DeleteFileHandler\fR, which are Unix-specific. Most of these
procedures are generic, in that they are the same for all notifiers.
However, eight of the procedures are notifier-dependent:
\fBTcl_InitNotifier\fR, \fBTcl_AlertNotifier\fR, \fBTcl_FinalizeNotifier\fR,
\fBTcl_SetTimer\fR, \fBTcl_Sleep\fR, \fBTcl_WaitForEvent\fR,
\fBTcl_CreateFileHandler\fR and \fBTcl_DeleteFileHandler\fR. To
support a new platform or to integrate Tcl with an
application-specific event loop, you must write new versions of these
procedures.
However, none of the procedures are notifier-dependent:
\fBTcl_InitNotifier\fR, \fBTcl_AlertNotifier\fR,
\fBTcl_FinalizeNotifier\fR, \fBTcl_SetTimer\fR, \fBTcl_Sleep\fR,
\fBTcl_WaitForEvent\fR, \fBTcl_CreateFileHandler\fR,
\fBTcl_DeleteFileHandler\fR and \fBTcl_ServiceModeHook\fR. To support a
new platform or to integrate Tcl with an application-specific event loop,
you must write new versions of these procedures.
.PP
\fBTcl_InitNotifier\fR initializes the notifier state and returns
a handle to the notifier state. Tcl calls this
@@ -469,7 +453,9 @@ procedure when initializing a Tcl interpreter. Similarly,
called by \fBTcl_Finalize\fR when shutting down a Tcl interpreter.
.PP
\fBTcl_WaitForEvent\fR is the lowest-level procedure in the notifier;
it is responsible for waiting for an ``interesting'' event to occur or
it is responsible for waiting for an
.QW interesting
event to occur or
for a given time to elapse. Before \fBTcl_WaitForEvent\fR is invoked,
each of the event sources' setup procedure will have been invoked.
The \fItimePtr\fR argument to
@@ -483,13 +469,13 @@ to occur; it should not actually process the event in any way.
Later on, the
event sources will process the raw events and create Tcl_Events on
the event queue in their \fIcheckProc\fR procedures.
However, on some platforms (such as Windows) this isn't possible;
However, on some platforms (such as Windows) this is not possible;
events may be processed in \fBTcl_WaitForEvent\fR, including queuing
Tcl_Events and more (for example, callbacks for native widgets may be
invoked). The return value from \fBTcl_WaitForEvent\fR must be either
0, 1, or \-1. On platforms such as Windows where events get processed in
\fBTcl_WaitForEvent\fR, a return value of 1 means that there may be more
events still pending that haven't been processed. This is a sign to the
events still pending that have not been processed. This is a sign to the
caller that it must call \fBTcl_WaitForEvent\fR again if it wants all
pending events to be processed. A 0 return value means that calling
\fBTcl_WaitForEvent\fR again will not have any effect: either this is a
@@ -504,7 +490,9 @@ forever because there were no active event sources and the timeout was
infinite.
.PP
\fBTcl_AlertNotifier\fR is used in multithreaded applications to allow
any thread to "wake up" the notifier to alert it to new events on its
any thread to
.QW "wake up"
the notifier to alert it to new events on its
queue. \fBTcl_AlertNotifier\fR requires as an argument the notifier
handle returned by \fBTcl_InitNotifier\fR.
.PP
@@ -514,11 +502,18 @@ invoked by \fBTcl_SetMaxBlockTime\fR whenever the maximum blocking
time has been reduced. \fBTcl_SetTimer\fR should arrange for the
external event loop to invoke \fBTcl_ServiceAll\fR after the specified
interval even if no events have occurred. This interface is needed
because \fBTcl_WaitForEvent\fR isn't invoked when there is an external
because \fBTcl_WaitForEvent\fR is not invoked when there is an external
event loop. If the
notifier will only be used from \fBTcl_DoOneEvent\fR, then
\fBTcl_SetTimer\fR need not do anything.
.PP
\fBTcl_ServiceModeHook\fR is called by the platform-independent portion
of the notifier when client code makes a call to
\fBTcl_SetServiceMode\fR. This hook is provided to support operating
systems that require special event handling when the application is in
a modal loop (the Windows notifier, for instance, uses this hook to
create a communication window).
.PP
On Unix systems, the file event source also needs support from the
notifier. The file event source consists of the
\fBTcl_CreateFileHandler\fR and \fBTcl_DeleteFileHandler\fR
@@ -532,6 +527,38 @@ The easiest way to create a new notifier is to look at the code
for an existing notifier, such as the files \fBunix/tclUnixNotfy.c\fR
or \fBwin/tclWinNotify.c\fR in the Tcl source distribution.
.SH "REPLACING THE NOTIFIER"
.PP
A notifier that has been written according to the conventions above
can also be installed in a running process in place of the standard
notifier. This mechanism is used so that a single executable can be
used (with the standard notifier) as a stand-alone program and reused
(with a replacement notifier in a loadable extension) as an extension
to another program, such as a Web browser plugin.
.PP
To do this, the extension makes a call to \fBTcl_SetNotifier\fR
passing a pointer to a \fBTcl_NotifierProcs\fR data structure. The
structure has the following layout:
.CS
typedef struct Tcl_NotifierProcs {
Tcl_SetTimerProc *setTimerProc;
Tcl_WaitForEventProc *waitForEventProc;
Tcl_CreateFileHandlerProc *createFileHandlerProc;
Tcl_DeleteFileHandlerProc *deleteFileHandlerProc;
Tcl_InitNotifierProc *initNotifierProc;
Tcl_FinalizeNotifierProc *finalizeNotifierProc;
Tcl_AlertNotifierProc *alertNotifierProc;
Tcl_ServiceModeHookProc *serviceModeHookProc;
} Tcl_NotifierProcs;
.CE
Following the call to \fBTcl_SetNotifier\fR, the pointers given in
the \fBTcl_NotifierProcs\fR structure replace whatever notifier had
been installed in the process.
.PP
It is extraordinarily unwise to replace a running notifier. Normally,
\fBTcl_SetNotifier\fR should be called at process initialization time
before the first call to \fBTcl_InitNotifier\fR.
.SH "EXTERNAL EVENT LOOPS"
.PP
The notifier interfaces are designed so that Tcl can be embedded into
@@ -592,7 +619,7 @@ then calls to \fBTcl_ServiceAll\fR will behave normally.
mode, which should be restored when the recursive loop exits.
\fBTcl_GetServiceMode\fR returns the current value of the service
mode.
.VE
.SH "SEE ALSO"
\fBTcl_CreateFileHandler\fR, \fBTcl_DeleteFileHandler\fR, \fBTcl_Sleep\fR,
\fBTcl_DoOneEvent\fR, \fBThread(3)\fR
+39 -35
View File
@@ -5,7 +5,7 @@
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.so man.macros
.TH Tcl_Obj 3 8.1 Tcl "Tcl Library Procedures"
.TH Tcl_Obj 3 8.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_NewObj, Tcl_DuplicateObj, Tcl_IncrRefCount, Tcl_DecrRefCount, Tcl_IsShared, Tcl_InvalidateStringRep \- manipulate Tcl objects
@@ -28,7 +28,7 @@ int
.sp
\fBTcl_InvalidateStringRep\fR(\fIobjPtr\fR)
.SH ARGUMENTS
.AS Tcl_Obj *objPtr in
.AS Tcl_Obj *objPtr
.AP Tcl_Obj *objPtr in
Points to an object;
must have been the result of a previous call to \fBTcl_NewObj\fR.
@@ -100,34 +100,37 @@ reclaim an object's storage.
.PP
Tcl objects are typed.
An object's internal representation is controlled by its type.
Seven types are predefined in the Tcl core
Several types are predefined in the Tcl core
including integer, double, list, and bytecode.
Extension writers can extend the set of types
by using the procedure \fBTcl_RegisterObjType\fR .
by defining their own \fBTcl_ObjType\fR structs.
.SH "THE TCL_OBJ STRUCTURE"
.PP
Each Tcl object is represented by a \fBTcl_Obj\fR structure
which is defined as follows.
.CS
typedef struct Tcl_Obj {
int \fIrefCount\fR;
char *\fIbytes\fR;
int \fIlength\fR;
Tcl_ObjType *\fItypePtr\fR;
union {
long \fIlongValue\fR;
double \fIdoubleValue\fR;
VOID *\fIotherValuePtr\fR;
struct {
VOID *\fIptr1\fR;
VOID *\fIptr2\fR;
} \fItwoPtrValue\fR;
} \fIinternalRep\fR;
int \fIrefCount\fR;
char *\fIbytes\fR;
int \fIlength\fR;
Tcl_ObjType *\fItypePtr\fR;
union {
long \fIlongValue\fR;
double \fIdoubleValue\fR;
void *\fIotherValuePtr\fR;
Tcl_WideInt \fIwideValue\fR;
struct {
void *\fIptr1\fR;
void *\fIptr2\fR;
} \fItwoPtrValue\fR;
struct {
void *\fIptr\fR;
unsigned long \fIvalue\fR;
} \fIptrAndLongRep\fR;
} \fIinternalRep\fR;
} Tcl_Obj;
.CE
The \fIbytes\fR and the \fIlength\fR members together hold
.VS 8.1
an object's UTF-8 string representation,
which is a \fIcounted string\fR not containing null bytes (UTF-8 null
characters should be encoded as a two byte sequence: 192, 128.)
@@ -137,7 +140,6 @@ The byte array must always have a null byte after the last data byte,
at offset \fIlength\fR;
this allows string representations
to be treated as conventional null-terminated C strings.
.VE 8.1
C programs use \fBTcl_GetStringFromObj\fR and \fBTcl_GetString\fR to get
an object's string representation.
If \fIbytes\fR is NULL,
@@ -151,10 +153,11 @@ the internal representation is invalid.
.PP
The \fIinternalRep\fR union member holds
an object's internal representation.
This is either a (long) integer, a double-precision floating point number,
This is either a (long) integer, a double-precision floating-point number,
a pointer to a value containing additional information
needed by the object's type to represent the object,
or two arbitrary pointers.
needed by the object's type to represent the object, a Tcl_WideInt
integer, two arbitrary pointers, or a pair made up of an unsigned long
integer and a pointer.
.PP
The \fIrefCount\fR member is used to tell when it is safe to free
an object's storage.
@@ -224,7 +227,6 @@ creates a new internal representation for an object
and changes its \fItypePtr\fR.
See the man page for \fBTcl_RegisterObjType\fR
to see how to create a new object type.
.SH "EXAMPLE OF THE LIFETIME OF AN OBJECT"
.PP
As an example of the lifetime of an object,
@@ -262,9 +264,8 @@ no longer corresponds to the internal representation.
.CE
The string representation of \fIx\fR's object is needed
and is recomputed.
The string representation is now \fB124\fR.
The string representation is now \fB124\fR
and both representations are again valid.
.SH "STORAGE MANAGEMENT OF OBJECTS"
.PP
Tcl objects are allocated on the heap and are shared as much as possible
@@ -281,7 +282,7 @@ if the object's reference count drops to zero, frees its storage.
An object shared by different code or data structures has
\fIrefCount\fR greater than 1.
Incrementing an object's reference count ensures that
it won't be freed too early or have its value change accidently.
it will not be freed too early or have its value change accidentally.
.PP
As an example, the bytecode interpreter shares argument objects
between calling and called Tcl procedures to avoid having to copy objects.
@@ -297,7 +298,7 @@ When an object's reference count drops less than or equal to zero,
\fBTcl_DecrRefCount\fR reclaims its storage.
Most command procedures do not have to be concerned about
reference counting since they use an object's value immediately
and don't retain a pointer to the object after they return.
and do not retain a pointer to the object after they return.
However, if they do retain a pointer to an object in a data structure,
they must be careful to increment its reference count
since the retained pointer is a new reference.
@@ -312,26 +313,29 @@ by using \fBTcl_DuplicateObj\fR;
this returns a new duplicate of the original object
that has \fIrefCount\fR 0.
If the object is not shared,
the command procedure "owns" the object and can safely modify it directly.
the command procedure
.QW "owns"
the object and can safely modify it directly.
For example, the following code appears in the command procedure
that implements \fBlinsert\fR.
This procedure modifies the list object passed to it in \fIobjv[1]\fR
by inserting \fIobjc-3\fR new elements before \fIindex\fR.
.PP
.CS
listPtr = objv[1];
if (Tcl_IsShared(listPtr)) {
listPtr = Tcl_DuplicateObj(listPtr);
listPtr = Tcl_DuplicateObj(listPtr);
}
result = Tcl_ListObjReplace(interp, listPtr, index, 0, (objc-3), &(objv[3]));
result = Tcl_ListObjReplace(interp, listPtr, index, 0,
(objc-3), &(objv[3]));
.CE
.PP
As another example, \fBincr\fR's command procedure
must check whether the variable's object is shared before
incrementing the integer in its internal representation.
If it is shared, it needs to duplicate the object
in order to avoid accidently changing values in other data structures.
in order to avoid accidentally changing values in other data structures.
.SH "SEE ALSO"
Tcl_ConvertToType, Tcl_GetIntFromObj, Tcl_ListObjAppendElement, Tcl_ListObjIndex, Tcl_ListObjReplace, Tcl_RegisterObjType
Tcl_ConvertToType(3), Tcl_GetIntFromObj(3), Tcl_ListObjAppendElement(3), Tcl_ListObjIndex(3), Tcl_ListObjReplace(3), Tcl_RegisterObjType(3)
.SH KEYWORDS
internal representation, object, object creation, object type, reference counting, string representation, type conversion
+100 -47
View File
@@ -24,12 +24,12 @@ int
int
\fBTcl_ConvertToType\fR(\fIinterp, objPtr, typePtr\fR)
.SH ARGUMENTS
.AS Tcl_ObjType *typeName in
.AS "const char" *typeName
.AP Tcl_ObjType *typePtr in
Points to the structure containing information about the Tcl object type.
This storage must live forever,
typically by being statically allocated.
.AP "CONST char" *typeName in
.AP "const char" *typeName in
The name of a Tcl object type that \fBTcl_GetObjType\fR should look up.
.AP Tcl_Interp *interp in
Interpreter to use for error reporting.
@@ -43,12 +43,14 @@ must have been the result of a previous call to \fBTcl_NewObj\fR.
.SH DESCRIPTION
.PP
The procedures in this man page manage Tcl object types.
The are used to register new object types,
look up types,
They are used to register new object types, look up types,
and force conversions from one type to another.
.PP
\fBTcl_RegisterObjType\fR registers a new Tcl object type
in the table of all object types supported by Tcl.
in the table of all object types that \fBTcl_GetObjType\fR
can look up by name. There are other object types supported by Tcl
as well, which Tcl chooses not to register. Extensions can likewise
choose to register the object types they create or not.
The argument \fItypePtr\fR points to a Tcl_ObjType structure that
describes the new type by giving its name
and by supplying pointers to four procedures
@@ -59,11 +61,11 @@ it is replaced with the new type.
The Tcl_ObjType structure is described
in the section \fBTHE TCL_OBJTYPE STRUCTURE\fR below.
.PP
\fBTcl_GetObjType\fR returns a pointer to the Tcl_ObjType
\fBTcl_GetObjType\fR returns a pointer to the registered Tcl_ObjType
with name \fItypeName\fR.
It returns NULL if no type with that name is registered.
.PP
\fBTcl_AppendAllObjTypes\fR appends the name of each object type
\fBTcl_AppendAllObjTypes\fR appends the name of each registered object type
as a list element onto the Tcl object referenced by \fIobjPtr\fR.
The return value is \fBTCL_OK\fR unless there was an error
converting \fIobjPtr\fR to a list object;
@@ -73,7 +75,8 @@ in that case \fBTCL_ERROR\fR is returned.
if possible.
It creates a new internal representation for \fIobjPtr\fR
appropriate for the target type \fItypePtr\fR
and sets its \fItypePtr\fR member to that type.
and sets its \fItypePtr\fR member as determined by calling the
\fItypePtr->setFromAnyProc\fR routine.
Any internal representation for \fIobjPtr\fR's old type is freed.
If an error occurs during conversion, it returns \fBTCL_ERROR\fR
and leaves an error message in the result object for \fIinterp\fR
@@ -81,118 +84,168 @@ unless \fIinterp\fR is NULL.
Otherwise, it returns \fBTCL_OK\fR.
Passing a NULL \fIinterp\fR allows this procedure to be used
as a test whether the conversion can be done (and in fact was done).
.VS 8.5
.PP
In many cases, the \fItypePtr->setFromAnyProc\fR routine will
set \fIobjPtr->typePtr\fR to the argument value \fItypePtr\fR,
but that is no longer guaranteed. The \fIsetFromAnyProc\fR is
free to set the internal representation for \fIobjPtr\fR to make
use of another related Tcl_ObjType, if it sees fit.
.VE 8.5
.SH "THE TCL_OBJTYPE STRUCTURE"
.PP
Extension writers can define new object types by defining four
procedures,
initializing a Tcl_ObjType structure to describe the type,
and calling \fBTcl_RegisterObjType\fR.
procedures and
initializing a Tcl_ObjType structure to describe the type.
Extension writers may also pass a pointer to their Tcl_ObjType
structure to \fBTcl_RegisterObjType\fR if they wish to permit
other extensions to look up their Tcl_ObjType by name with
the \fBTcl_GetObjType\fR routine.
The \fBTcl_ObjType\fR structure is defined as follows:
.PP
.CS
typedef struct Tcl_ObjType {
char *\fIname\fR;
Tcl_FreeInternalRepProc *\fIfreeIntRepProc\fR;
Tcl_DupInternalRepProc *\fIdupIntRepProc\fR;
Tcl_UpdateStringProc *\fIupdateStringProc\fR;
Tcl_SetFromAnyProc *\fIsetFromAnyProc\fR;
char *\fIname\fR;
Tcl_FreeInternalRepProc *\fIfreeIntRepProc\fR;
Tcl_DupInternalRepProc *\fIdupIntRepProc\fR;
Tcl_UpdateStringProc *\fIupdateStringProc\fR;
Tcl_SetFromAnyProc *\fIsetFromAnyProc\fR;
} Tcl_ObjType;
.CE
.SS "THE NAME FIELD"
.PP
The \fIname\fR member describes the name of the type, e.g. \fBint\fR.
Extension writers can look up an object type using its name
with the \fBTcl_GetObjType\fR procedure.
When a type is registered, this is the name used by callers
of \fBTcl_GetObjType\fR to lookup the type. For unregistered
types, the \fIname\fR field is primarily of value for debugging.
The remaining four members are pointers to procedures
called by the generic Tcl object code:
.SS "THE SETFROMANYPROC FIELD"
.PP
The \fIsetFromAnyProc\fR member contains the address of a function
called to create a valid internal representation
from an object's string representation.
.PP
.CS
typedef int (Tcl_SetFromAnyProc) (Tcl_Interp *\fIinterp\fR, Tcl_Obj *\fIobjPtr\fR);
typedef int (Tcl_SetFromAnyProc) (Tcl_Interp *\fIinterp\fR,
Tcl_Obj *\fIobjPtr\fR);
.CE
If an internal representation can't be created from the string,
.PP
If an internal representation cannot be created from the string,
it returns \fBTCL_ERROR\fR and puts a message
describing the error in the result object for \fIinterp\fR
unless \fIinterp\fR is NULL.
If \fIsetFromAnyProc\fR is successful,
it stores the new internal representation,
sets \fIobjPtr\fR's \fItypePtr\fR member to point to
\fIsetFromAnyProc\fR's \fBTcl_ObjType\fR, and returns \fBTCL_OK\fR.
the \fBTcl_ObjType\fR struct corresponding to the new
internal representation, and returns \fBTCL_OK\fR.
Before setting the new internal representation,
the \fIsetFromAnyProc\fR must free any internal representation
of \fIobjPtr\fR's old type;
it does this by calling the old type's \fIfreeIntRepProc\fR
if it is not NULL.
As an example, the \fIsetFromAnyProc\fR for the builtin Tcl integer type
.PP
As an example, the \fIsetFromAnyProc\fR for the built-in Tcl list type
gets an up-to-date string representation for \fIobjPtr\fR
by calling \fBTcl_GetStringFromObj\fR.
It parses the string to obtain an integer and,
if this succeeds,
stores the integer in \fIobjPtr\fR's internal representation
and sets \fIobjPtr\fR's \fItypePtr\fR member to point to the integer type's
It parses the string to verify it is in a valid list format and
to obtain each element value in the list, and, if this succeeds,
stores the list elements in \fIobjPtr\fR's internal representation
and sets \fIobjPtr\fR's \fItypePtr\fR member to point to the list type's
Tcl_ObjType structure.
.PP
Do not release \fIobjPtr\fR's old internal representation unless you
replace it with a new one or reset the \fItypePtr\fR member to NULL.
.PP
The \fIsetFromAnyProc\fR member may be set to NULL, if the routines
making use of the internal representation have no need to derive that
internal representation from an arbitrary string value. However, in
this case, passing a pointer to the type to Tcl_ConvertToType() will
lead to a panic, so to avoid this possibility, the type
should \fInot\fR be registered.
.SS "THE UPDATESTRINGPROC FIELD"
.PP
The \fIupdateStringProc\fR member contains the address of a function
called to create a valid string representation
from an object's internal representation.
.PP
.CS
typedef void (Tcl_UpdateStringProc) (Tcl_Obj *\fIobjPtr\fR);
.CE
.PP
\fIobjPtr\fR's \fIbytes\fR member is always NULL when it is called.
It must always set \fIbytes\fR non-NULL before returning.
We require the string representation's byte array
to have a null after the last byte, at offset \fIlength\fR;
this allows string representations that do not contain null bytes
to have a null after the last byte, at offset \fIlength\fR,
and to have no null bytes before that; this allows string representations
to be treated as conventional null character-terminated C strings.
These restrictions are easily met by using Tcl's internal UTF encoding
for the string representation, same as one would do for other
Tcl routines accepting string values as arguments.
Storage for the byte array must be allocated in the heap by \fBTcl_Alloc\fR
or \fBckalloc\fR. Note that \fIupdateStringProc\fRs must allocate
enough storage for the string's bytes and the terminating null byte.
The \fIupdateStringProc\fR for Tcl's builtin list type, for example,
builds an array of strings for each element object
and then calls \fBTcl_Merge\fR
to construct a string with proper Tcl list structure.
It stores this string as the list object's string representation.
.PP
The \fIupdateStringProc\fR for Tcl's built-in double type, for example,
calls Tcl_PrintDouble to write to a buffer of size TCL_DOUBLE_SPACE,
then allocates and copies the string representation to just enough
space to hold it. A pointer to the allocated space is stored in
the \fIbytes\fR member.
.PP
The \fIupdateStringProc\fR member may be set to NULL, if the routines
making use of the internal representation are written so that the
string representation is never invalidated. Failure to meet this
obligation will lead to panics or crashes when \fBTcl_GetStringFromObj\fR
or other similar routines ask for the string representation.
.SS "THE DUPINTREPPROC FIELD"
.PP
The \fIdupIntRepProc\fR member contains the address of a function
called to copy an internal representation from one object to another.
.PP
.CS
typedef void (Tcl_DupInternalRepProc) (Tcl_Obj *\fIsrcPtr\fR, Tcl_Obj *\fIdupPtr\fR);
typedef void (Tcl_DupInternalRepProc) (Tcl_Obj *\fIsrcPtr\fR,
Tcl_Obj *\fIdupPtr\fR);
.CE
.PP
\fIdupPtr\fR's internal representation is made a copy of \fIsrcPtr\fR's
internal representation.
Before the call,
\fIsrcPtr\fR's internal representation is valid and \fIdupPtr\fR's is not.
\fIsrcPtr\fR's object type determines what
copying its internal representation means.
.PP
For example, the \fIdupIntRepProc\fR for the Tcl integer type
simply copies an integer.
The builtin list type's \fIdupIntRepProc\fR
allocates a new array that points at the original element objects;
the elements are shared between the two lists
(and their reference counts are incremented to reflect the new references).
The built-in list type's \fIdupIntRepProc\fR uses a far more
sophisticated scheme to continue sharing storage as much as it
reasonably can.
.SS "THE FREEINTREPPROC FIELD"
.PP
The \fIfreeIntRepProc\fR member contains the address of a function
that is called when an object is freed.
.PP
.CS
typedef void (Tcl_FreeInternalRepProc) (Tcl_Obj *\fIobjPtr\fR);
.CE
.PP
The \fIfreeIntRepProc\fR function can deallocate the storage
for the object's internal representation
and do other type-specific processing necessary when an object is freed.
For example, Tcl list objects have an \fIinternalRep.otherValuePtr\fR
that points to an array of pointers to each element in the list.
The list type's \fIfreeIntRepProc\fR decrements
the reference count for each element object
(since the list will no longer refer to those objects),
then deallocates the storage for the array of pointers.
.PP
For example, the list type's \fIfreeIntRepProc\fR respects
the storage sharing scheme established by the \fIdupIntRepProc\fR
so that it only frees storage when the last object sharing it
is being freed.
.PP
The \fIfreeIntRepProc\fR member can be set to NULL
to indicate that the internal representation does not require freeing.
The \fIfreeIntRepProc\fR implementation must not access the
\fIbytes\fR member of the object, since Tcl makes its own internal
uses of that field during object deletion. The defined tasks for
the \fIfreeIntRepProc\fR have no need to consult the \fIbytes\fR
member.
.SH "SEE ALSO"
Tcl_NewObj, Tcl_DecrRefCount, Tcl_IncrRefCount
.SH KEYWORDS
internal representation, object, object type, string representation, type conversion
+38 -43
View File
@@ -9,7 +9,7 @@
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_OpenFileChannel, Tcl_OpenCommandChannel, Tcl_MakeFileChannel, Tcl_GetChannel, Tcl_GetChannelNames, Tcl_GetChannelNamesEx, Tcl_RegisterChannel, Tcl_UnregisterChannel, Tcl_DetachChannel, Tcl_IsStandardChannel, Tcl_Close, Tcl_ReadChars, Tcl_Read, Tcl_GetsObj, Tcl_Gets, Tcl_WriteObj, Tcl_WriteChars, Tcl_Write, Tcl_Flush, Tcl_Seek, Tcl_Tell, Tcl_GetChannelOption, Tcl_SetChannelOption, Tcl_Eof, Tcl_InputBlocked, Tcl_InputBuffered, Tcl_OutputBuffered, Tcl_Ungets, Tcl_ReadRaw, Tcl_WriteRaw \- buffered I/O facilities using channels
Tcl_OpenFileChannel, Tcl_OpenCommandChannel, Tcl_MakeFileChannel, Tcl_GetChannel, Tcl_GetChannelNames, Tcl_GetChannelNamesEx, Tcl_RegisterChannel, Tcl_UnregisterChannel, Tcl_DetachChannel, Tcl_IsStandardChannel, Tcl_Close, Tcl_ReadChars, Tcl_Read, Tcl_GetsObj, Tcl_Gets, Tcl_WriteObj, Tcl_WriteChars, Tcl_Write, Tcl_Flush, Tcl_Seek, Tcl_Tell, Tcl_TruncateChannel, Tcl_GetChannelOption, Tcl_SetChannelOption, Tcl_Eof, Tcl_InputBlocked, Tcl_InputBuffered, Tcl_OutputBuffered, Tcl_Ungets, Tcl_ReadRaw, Tcl_WriteRaw \- buffered I/O facilities using channels
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -25,14 +25,12 @@ Tcl_Channel
.sp
Tcl_Channel
\fBTcl_GetChannel\fR(\fIinterp, channelName, modePtr\fR)
.VS 8.3
.sp
int
\fBTcl_GetChannelNames\fR(\fIinterp\fR)
.sp
int
\fBTcl_GetChannelNamesEx\fR(\fIinterp, pattern\fR)
.VE
.sp
void
\fBTcl_RegisterChannel\fR(\fIinterp, channel\fR)
@@ -49,7 +47,6 @@ int
int
\fBTcl_Close\fR(\fIinterp, channel\fR)
.sp
.VS 8.1
int
\fBTcl_ReadChars\fR(\fIchannel, readObjPtr, charsToRead, appendFlag\fR)
.sp
@@ -73,15 +70,12 @@ int
.sp
int
\fBTcl_Write\fR(\fIchannel, byteBuf, bytesToWrite\fR)
.VE
.VS 8.3.2
.sp
int
\fBTcl_ReadRaw\fR(\fIchannel, readBuf, bytesToRead\fR)
.sp
int
\fBTcl_WriteRaw\fR(\fIchannel, byteBuf, bytesToWrite\fR)
.VE
.sp
int
\fBTcl_Eof\fR(\fIchannel\fR)
@@ -94,19 +88,20 @@ int
.sp
int
\fBTcl_InputBuffered\fR(\fIchannel\fR)
.VS 8.4
.sp
int
\fBTcl_OutputBuffered\fR(\fIchannel\fR)
.VE
.sp
.VS 8.4
Tcl_WideInt
\fBTcl_Seek\fR(\fIchannel, offset, seekMode\fR)
.sp
Tcl_WideInt
\fBTcl_Tell\fR(\fIchannel\fR)
.VE 8.4
.sp
.VS 8.5
int
\fBTcl_TruncateChannel\fR(\fIchannel, length\fR)
.VE 8.5
.sp
int
\fBTcl_GetChannelOption\fR(\fIinterp, channel, optionName, optionValue\fR)
@@ -115,12 +110,12 @@ int
\fBTcl_SetChannelOption\fR(\fIinterp, channel, optionName, newValue\fR)
.sp
.SH ARGUMENTS
.AS Tcl_ChannelType newClientProcPtr in
.AS Tcl_DString *channelName in/out
.AP Tcl_Interp *interp in
Used for error reporting and to look up a channel registered in it.
.AP "CONST char" *fileName in
.AP "const char" *fileName in
The name of a local or network file.
.AP "CONST char" *mode in
.AP "const char" *mode in
Specifies how the file is to be accessed. May have any of the values
allowed for the \fImode\fR argument to the Tcl \fBopen\fR command.
.AP int permissions in
@@ -128,7 +123,7 @@ POSIX-style permission flags such as 0644. If a new file is created, these
permissions will be set on the created file.
.AP int argc in
The number of elements in \fIargv\fR.
.AP "CONST char" **argv in
.AP "const char" **argv in
Arguments for constructing a command pipeline. These values have the same
meaning as the non-switch arguments to the Tcl \fBexec\fR command.
.AP int flags in
@@ -147,20 +142,17 @@ file descriptor, for Windows it is a HANDLE.
.AP int readOrWrite in
OR-ed combination of \fBTCL_READABLE\fR and \fBTCL_WRITABLE\fR to indicate
what operations are valid on \fIhandle\fR.
.AP "CONST char" *channelName in
.AP "const char" *channelName in
The name of the channel.
.AP int *modePtr out
Points at an integer variable that will receive an OR-ed combination of
\fBTCL_READABLE\fR and \fBTCL_WRITABLE\fR denoting whether the channel is
open for reading and writing.
.VS 8.3
.AP "CONST char" *pattern in
.AP "const char" *pattern in
The pattern to match on, passed to Tcl_StringMatch, or NULL.
.VE
.AP Tcl_Channel channel in
A Tcl channel for input or output. Must have been the return value
from a procedure such as \fBTcl_OpenFileChannel\fR.
.VS 8.1 br
.AP Tcl_Obj *readObjPtr in/out
A pointer to a Tcl Object in which to store the characters read from the
channel.
@@ -184,25 +176,22 @@ object.
A pointer to a Tcl dynamic string in which to store the line read from the
channel. Must have been initialized by the caller. The line read will be
appended to any data already in the dynamic string.
.VS 8.3
.AP "CONST char" *input in
.AP "const char" *input in
The input to add to a channel buffer.
.AP int inputLen in
Length of the input
.AP int addAtEnd in
Flag indicating whether the input should be added to the end or
beginning of the channel buffer.
.VE
.AP Tcl_Obj *writeObjPtr in
A pointer to a Tcl Object whose contents will be output to the channel.
.AP "CONST char" *charBuf in
.AP "const char" *charBuf in
A buffer containing the characters to output to the channel.
.AP "CONST char" *byteBuf in
.AP "const char" *byteBuf in
A buffer containing the bytes to output to the channel.
.AP int bytesToWrite in
The number of bytes to consume from \fIcharBuf\fR or \fIbyteBuf\fR and
output to the channel.
.VE
.AP Tcl_WideInt offset in
How far to move the access point in the channel at which the next input or
output operation will be applied, measured in bytes from the position
@@ -211,13 +200,15 @@ given by \fIseekMode\fR. May be either positive or negative.
Relative to which point to seek; used with \fIoffset\fR to calculate the new
access point for the channel. Legal values are \fBSEEK_SET\fR,
\fBSEEK_CUR\fR, and \fBSEEK_END\fR.
.AP "CONST char" *optionName in
.AP Tcl_WideInt length in
The (non-negative) length to truncate the channel the channel to.
.AP "const char" *optionName in
The name of an option applicable to this channel, such as \fB\-blocking\fR.
May have any of the values accepted by the \fBfconfigure\fR command.
.AP Tcl_DString *optionValue in
Where to store the value of an option or a list of all options and their
values. Must have been initialized by the caller.
.AP "CONST char" *newValue in
.AP "const char" *newValue in
New value for the option given by \fIoptionName\fR.
.BE
@@ -228,7 +219,7 @@ platform-independent mechanism for performing buffered input
and output operations on a variety of file, socket, and device
types.
The channel mechanism is extensible to new channel types, by
providing a low level channel driver for the new type; the channel driver
providing a low-level channel driver for the new type; the channel driver
interface is described in the manual entry for \fBTcl_CreateChannel\fR. The
channel mechanism provides a buffering scheme modeled after
Unix's standard I/O, and it also allows for nonblocking I/O on
@@ -254,8 +245,6 @@ In addition, if \fIinterp\fR is non-NULL, \fBTcl_OpenFileChannel\fR
leaves an error message in \fIinterp\fR's result after any error.
As of Tcl 8.4, the object-based API \fBTcl_FSOpenFileChannel\fR should
be used in preference to \fBTcl_OpenFileChannel\fR wherever possible.
.PP
.PP
The newly created channel is not registered in the supplied interpreter; to
register it, use \fBTcl_RegisterChannel\fR, described below.
@@ -349,7 +338,7 @@ reference to a channel that is also registered in a Tcl interpreter.
.PP
This procedure interacts with the code managing the standard
channels. If no standard channels were initialized before the first
call to \fBTcl_RegisterChannel\fR they will get initialized by that
call to \fBTcl_RegisterChannel\fR, they will get initialized by that
call. See \fBTcl_StandardChannels\fR for a general treatise about
standard channels and the behaviour of the Tcl library with regard to
them.
@@ -376,7 +365,7 @@ accessible in \fIinterp\fR. After this call, Tcl programs will no longer be
able to use the channel's name to refer to the channel in that interpreter.
Beyond that, this command has no further effect. It cannot be used on
the standard channels (stdout, stderr, stdin), and will return
TCL_ERROR if passed one of those channels.
\fBTCL_ERROR\fR if passed one of those channels.
.PP
Code not associated with a Tcl interpreter can call
\fBTcl_DetachChannel\fR with \fIinterp\fR as NULL, to indicate to Tcl
@@ -423,7 +412,6 @@ been given as the \fBchan\fR argument in a call to
when all calls to \fBTcl_RegisterChannel\fR have been matched by
corresponding calls to \fBTcl_UnregisterChannel\fR.
.VS 8.1 br
.SH "TCL_READCHARS AND TCL_READ"
.PP
\fBTcl_ReadChars\fR consumes bytes from \fIchannel\fR, converting the bytes
@@ -434,7 +422,7 @@ that were stored in \fIreadObjPtr\fR. If an error occurs while reading, the
return value is \-1 and \fBTcl_ReadChars\fR records a POSIX error code that
can be retrieved with \fBTcl_GetErrno\fR.
.PP
Setting \fIcharsToRead\fR to \fB-1\fR will cause the command to read
Setting \fIcharsToRead\fR to \fB\-1\fR will cause the command to read
all characters currently available (non-blocking) or everything until
eof (blocking mode).
.PP
@@ -467,7 +455,7 @@ from a channel, manipulated by calling \fBTcl_GetByteArrayFromObj\fR and
related functions, and then written to a channel without the expense of ever
converting to or from UTF-8.
.PP
\fBTcl_Read\fR is similar to \fBTcl_ReadChars\fR, except that it doesn't do
\fBTcl_Read\fR is similar to \fBTcl_ReadChars\fR, except that it does not do
encoding conversions, regardless of the channel's encoding. It is deprecated
and exists for backwards compatibility with non-internationalized Tcl
extensions. It consumes bytes from \fIchannel\fR and stores them in
@@ -519,9 +507,11 @@ at either the head or tail of the queue. The pointer \fIinput\fR points
to the data that is to be added. The length of the input to add is given
by \fIinputLen\fR. A non-zero value of \fIaddAtEnd\fR indicates that the
data is to be added at the end of queue; otherwise it will be added at the
head of the queue. If \fIchannel\fR has a "sticky" EOF set, no data will be
head of the queue. If \fIchannel\fR has a
.QW sticky
EOF set, no data will be
added to the input queue. \fBTcl_Ungets\fR returns \fIinputLen\fR or
-1 if an error occurs.
\-1 if an error occurs.
.SH "TCL_WRITECHARS, TCL_WRITEOBJ, AND TCL_WRITE"
.PP
@@ -561,7 +551,7 @@ byte-oriented data can be read from a channel, manipulated by calling
\fBTcl_GetByteArrayFromObj\fR and related functions, and then written to a
channel without the expense of ever converting to or from UTF-8.
.PP
\fBTcl_Write\fR is similar to \fBTcl_WriteChars\fR except that it doesn't do
\fBTcl_Write\fR is similar to \fBTcl_WriteChars\fR except that it does not do
encoding conversions, regardless of the channel's encoding. It is
deprecated and exists for backwards compatibility with non-internationalized
Tcl extensions. It accepts \fIbytesToWrite\fR bytes of data at
@@ -577,7 +567,6 @@ not. Thus this function is \fBonly\fR usable for transformational
channel drivers, i.e. drivers used in the middle of a stack of
channels, to move data from the transformation into the channel below
it.
.VE
.SH TCL_FLUSH
.PP
@@ -609,6 +598,14 @@ After an error, the access point may or may not have been moved.
\fBTcl_Tell\fR returns the current access point for a channel. The returned
value is \-1 if the channel does not support seeking.
.SH TCL_TRUNCATECHANNEL
.PP
.VS 8.5
\fBTcl_TruncateChannel\fR truncates the file underlying \fIchannel\fR
to a given \fIlength\fR of bytes. It returns \fBTCL_OK\fR if the
operation succeeded, and \fBTCL_ERROR\fR otherwise.
.VE 8.5
.SH TCL_GETCHANNELOPTION
.PP
\fBTcl_GetChannelOption\fR retrieves, in \fIoptionValue\fR, the value of one of
@@ -658,11 +655,9 @@ buffered in the internal buffers for a channel. If the channel is not open
for reading, this function always returns zero.
.SH TCL_OUTPUTBUFFERED
.VS 8.4
\fBTcl_OutputBuffered\fR returns the number of bytes of output
currently buffered in the internal buffers for a channel. If the
channel is not open for writing, this function always returns zero.
.VE
.SH "PLATFORM ISSUES"
.PP
@@ -673,7 +668,7 @@ call. On Windows platforms, the handle is a file \fBHANDLE\fR when
the channel was created with \fBTcl_OpenFileChannel\fR,
\fBTcl_OpenCommandChannel\fR, or \fBTcl_MakeFileChannel\fR. Other
channel types may return a different type of handle on Windows
platforms.
platforms.
.SH "SEE ALSO"
DString(3), fconfigure(n), filename(n), fopen(3), Tcl_CreateChannel(3)
+11 -13
View File
@@ -24,18 +24,18 @@ Tcl_Channel
\fBTcl_OpenTcpServer\fR(\fIinterp, port, myaddr, proc, clientData\fR)
.sp
.SH ARGUMENTS
.AS Tcl_ChannelType newClientProcPtr in
.AS Tcl_TcpAcceptProc clientData
.AP Tcl_Interp *interp in
Tcl interpreter to use for error reporting. If non-NULL and an
error occurs, an error message is left in the interpreter's result.
.AP int port in
A port number to connect to as a client or to listen on as a server.
.AP "CONST char" *host in
.AP "const char" *host in
A string specifying a host name or address for the remote end of the connection.
.AP int myport in
A port number for the client's end of the socket. If 0, a port number
is allocated at random.
.AP "CONST char" *myaddr in
.AP "const char" *myaddr in
A string specifying the host name or address for network interface to use
for the local end of the connection. If NULL, a default interface is
chosen.
@@ -113,24 +113,24 @@ replacement for the standard channel.
.PP
\fBTcl_OpenTcpServer\fR opens a TCP socket on the local host on a specified
\fIport\fR and uses the Tcl event mechanism to accept requests from clients
to connect to it. The \fImyaddr\fP argument specifies the network interface.
If \fImyaddr\fP is NULL the special address INADDR_ANY should be used to
to connect to it. The \fImyaddr\fR argument specifies the network interface.
If \fImyaddr\fR is NULL the special address INADDR_ANY should be used to
allow connections from any network interface.
Each time a client connects to this socket, Tcl creates a channel
for the new connection and invokes \fIproc\fR with information about
the channel. \fIProc\fR must match the following prototype:
the channel. \fIProc\fR must match the following prototype:
.CS
typedef void Tcl_TcpAcceptProc(
ClientData \fIclientData\fR,
Tcl_Channel \fIchannel\fR,
char *\fIhostName\fR,
int \fIport\fP);
ClientData \fIclientData\fR,
Tcl_Channel \fIchannel\fR,
char *\fIhostName\fR,
int \fIport\fR);
.CE
.PP
The \fIclientData\fR argument will be the same as the \fIclientData\fR
argument to \fBTcl_OpenTcpServer\fR, \fIchannel\fR will be the handle
for the new channel, \fIhostName\fR points to a string containing
the name of the client host making the connection, and \fIport\fP
the name of the client host making the connection, and \fIport\fR
will contain the client's port number.
The new channel
is opened for both input and output.
@@ -162,13 +162,11 @@ If one of the standard channels, \fBstdin, stdout\fR or \fBstderr\fR was
previously closed, the act of creating the new channel also assigns it as a
replacement for the standard channel.
.VS
.SH "PLATFORM ISSUES"
.PP
On Unix platforms, the socket handle is a Unix file descriptor as
returned by the \fBsocket\fR system call. On the Windows platform, the
socket handle is a \fBSOCKET\fR as defined in the WinSock API.
.VE
.SH "SEE ALSO"
Tcl_OpenFileChannel(3), Tcl_RegisterChannel(3), vwait(n)
+7 -17
View File
@@ -7,7 +7,7 @@
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_Panic, Tcl_PanicVA, Tcl_SetPanicProc, panic, panicVA \- report fatal error and abort
Tcl_Panic, Tcl_PanicVA, Tcl_SetPanicProc \- report fatal error and abort
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -21,21 +21,15 @@ void
void
\fBTcl_SetPanicProc\fR(\fIpanicProc\fR)
.sp
void
\fBpanic\fR(\fIformat\fR, \fIarg\fR, \fIarg\fR, \fI...\fR)
.sp
void
\fBpanicVA\fR(\fIformat\fR, \fIargList\fR)
.sp
.SH ARGUMENTS
.AS Tcl_PanicProc *panicProc
.AP "CONST char*" format in
.AP "const char*" format in
A printf-style format string.
.AP "" arg in
Arguments matching the format string.
.AP va_list argList in
An argument list of arguments matching the format string.
Must have been initialized using \fBTCL_VARARGS_START\fR,
Must have been initialized using \fBva_start\fR,
and cleared using \fBva_end\fR.
.AP Tcl_PanicProc *panicProc in
Procedure to report fatal error message and abort.
@@ -51,7 +45,7 @@ to display a message describing the error and abort the process. The
\fIformat\fR argument is a format string describing how to format the
remaining arguments \fIarg\fR into an error message, according to the
same formatting rules used by the \fBprintf\fR family of functions. The
same formatting rules are also used by the builtin Tcl command
same formatting rules are also used by the built-in Tcl command
\fBformat\fR.
.PP
In a freshly loaded Tcl library, \fBTcl_Panic\fR prints the formatted
@@ -65,8 +59,8 @@ type \fBTcl_PanicProc\fR:
.PP
.CS
typedef void Tcl_PanicProc(
CONST char *\fBformat\fR,
\fBarg\fR, \fBarg\fR,...);
const char *\fBformat\fR,
\fBarg\fR, \fBarg\fR,...);
.CE
.PP
After \fBTcl_SetPanicProc\fR returns, any future calls to
@@ -92,11 +86,7 @@ have a panic message displayed the same way that panic messages from Tcl
will be displayed.
.PP
\fBTcl_PanicVA\fR is the same as \fBTcl_Panic\fR except that instead of
taking a variable number of arguments it takes an argument list. The
procedures \fBpanic\fR and \fBpanicVA\fR are synonyms (implemented as
macros) for \fBTcl_Panic\fR and \fBTcl_PanicVA\fR, respectively. They
exist to support old code; new code should use direct calls to
\fBTcl_Panic\fR or \fBTcl_PanicVA\fR.
taking a variable number of arguments it takes an argument list.
.SH "SEE ALSO"
abort(3), printf(3), exec(n), format(n)
+59 -45
View File
@@ -14,22 +14,22 @@ Tcl_ParseCommand, Tcl_ParseExpr, Tcl_ParseBraces, Tcl_ParseQuotedString, Tcl_Par
\fB#include <tcl.h>\fR
.sp
int
\fBTcl_ParseCommand\fR(\fIinterp, string, numBytes, nested, parsePtr\fR)
\fBTcl_ParseCommand\fR(\fIinterp, start, numBytes, nested, parsePtr\fR)
.sp
int
\fBTcl_ParseExpr\fR(\fIinterp, string, numBytes, parsePtr\fR)
\fBTcl_ParseExpr\fR(\fIinterp, start, numBytes, parsePtr\fR)
.sp
int
\fBTcl_ParseBraces\fR(\fIinterp, string, numBytes, parsePtr, append, termPtr\fR)
\fBTcl_ParseBraces\fR(\fIinterp, start, numBytes, parsePtr, append, termPtr\fR)
.sp
int
\fBTcl_ParseQuotedString\fR(\fIinterp, string, numBytes, parsePtr, append, termPtr\fR)
\fBTcl_ParseQuotedString\fR(\fIinterp, start, numBytes, parsePtr, append, termPtr\fR)
.sp
int
\fBTcl_ParseVarName\fR(\fIinterp, string, numBytes, parsePtr, append\fR)
\fBTcl_ParseVarName\fR(\fIinterp, start, numBytes, parsePtr, append\fR)
.sp
CONST char *
\fBTcl_ParseVar\fR(\fIinterp, string, termPtr\fR)
const char *
\fBTcl_ParseVar\fR(\fIinterp, start, termPtr\fR)
.sp
\fBTcl_FreeParse\fR(\fIusedParsePtr\fR)
.sp
@@ -39,7 +39,7 @@ Tcl_Obj *
int
\fBTcl_EvalTokensStandard\fR(\fIinterp, tokenPtr, numTokens\fR)
.SH ARGUMENTS
.AS Tcl_Interp *usedParsePtr
.AS Tcl_Interp *usedParsePtr out
.AP Tcl_Interp *interp out
For procedures other than \fBTcl_FreeParse\fR, \fBTcl_EvalTokens\fR
and \fBTcl_EvalTokensStandard\fR, used only for error reporting;
@@ -47,12 +47,12 @@ if NULL, then no error messages are left after errors.
For \fBTcl_EvalTokens\fR and \fBTcl_EvalTokensStandard\fR,
determines the context for evaluating the
script and also is used for error reporting; must not be NULL.
.AP "CONST char" *string in
.AP "const char" *start in
Pointer to first character in string to parse.
.AP int numBytes in
Number of bytes in \fIstring\fR, not including any terminating null
Number of bytes in string to parse, not including any terminating null
character. If less than 0 then the script consists of all characters
in \fIstring\fR up to the first null character.
following \fIstart\fR up to the first null character.
.AP int nested in
Non-zero means that the script is part of a command substitution so an
unquoted close bracket should be treated as a command terminator. If zero,
@@ -69,7 +69,7 @@ Any previous information in this structure
is ignored, unless \fIappend\fR is non-zero in a call to
\fBTcl_ParseBraces\fR, \fBTcl_ParseQuotedString\fR,
or \fBTcl_ParseVarName\fR.
.AP "CONST char" **termPtr out
.AP "const char" **termPtr out
If not NULL, points to a location where
\fBTcl_ParseBraces\fR, \fBTcl_ParseQuotedString\fR, and
\fBTcl_ParseVar\fR will store a pointer to the character
@@ -90,7 +90,7 @@ and fills in the structure pointed to by \fIparsePtr\fR
with a collection of tokens describing the information that was parsed.
The procedures normally return \fBTCL_OK\fR.
However, if an error occurs then they return \fBTCL_ERROR\fR,
leave an error message in \fIinterp's\fR result
leave an error message in \fIinterp\fR's result
(if \fIinterp\fR is not NULL),
and leave nothing in \fIparsePtr\fR.
.PP
@@ -117,9 +117,9 @@ result, and no information is left at \fI*parsePtr\fR.
.PP
\fBTcl_ParseBraces\fR parses a string or command argument
enclosed in braces such as
\fB{hello}\fR or \fB{string \\t with \\t tabs}\fR
from the beginning of its argument \fIstring\fR.
The first character of \fIstring\fR must be \fB{\fR.
\fB{hello}\fR or \fB{string \et with \et tabs}\fR
from the beginning of its argument \fIstart\fR.
The first character of \fIstart\fR must be \fB{\fR.
If the braced string was parsed successfully,
\fBTcl_ParseBraces\fR returns \fBTCL_OK\fR,
fills in the structure pointed to by \fIparsePtr\fR
@@ -133,15 +133,15 @@ an error message is left in \fIinterp\fR's result,
and no information is left at \fI*parsePtr\fR or \fI*termPtr\fR.
.PP
\fBTcl_ParseQuotedString\fR parses a double-quoted string such as
\fB"sum is [expr $a+$b]"\fR
from the beginning of the argument \fIstring\fR.
The first character of \fIstring\fR must be \fB"\fR.
\fB"sum is [expr {$a+$b}]"\fR
from the beginning of the argument \fIstart\fR.
The first character of \fIstart\fR must be \fB\N'34'\fR.
If the double-quoted string was parsed successfully,
\fBTcl_ParseQuotedString\fR returns \fBTCL_OK\fR,
fills in the structure pointed to by \fIparsePtr\fR
with information about the structure of the string
(see below for details),
and stores a pointer to the character just after the terminating \fB"\fR
and stores a pointer to the character just after the terminating \fB\N'34'\fR
in the location given by \fI*termPtr\fR.
If an error occurs while parsing the string
then \fBTCL_ERROR\fR is returned,
@@ -149,20 +149,20 @@ an error message is left in \fIinterp\fR's result,
and no information is left at \fI*parsePtr\fR or \fI*termPtr\fR.
.PP
\fBTcl_ParseVarName\fR parses a Tcl variable reference such as
\fB$abc\fR or \fB$x([expr $index + 1])\fR from the beginning of its
\fIstring\fR argument.
The first character of \fIstring\fR must be \fB$\fR.
\fB$abc\fR or \fB$x([expr {$index + 1}])\fR from the beginning of its
\fIstart\fR argument.
The first character of \fIstart\fR must be \fB$\fR.
If a variable name was parsed successfully, \fBTcl_ParseVarName\fR
returns \fBTCL_OK\fR and fills in the structure pointed to by
\fIparsePtr\fR with information about the structure of the variable name
(see below for details). If an error
occurs while parsing the command then \fBTCL_ERROR\fR is returned, an
error message is left in \fIinterp\fR's result (if \fIinterp\fR isn't
error message is left in \fIinterp\fR's result (if \fIinterp\fR is not
NULL), and no information is left at \fI*parsePtr\fR.
.PP
\fBTcl_ParseVar\fR parse a Tcl variable reference such as \fB$abc\fR
or \fB$x([expr $index + 1])\fR from the beginning of its \fIstring\fR
argument. The first character of \fIstring\fR must be \fB$\fR. If
or \fB$x([expr {$index + 1}])\fR from the beginning of its \fIstart\fR
argument. The first character of \fIstart\fR must be \fB$\fR. If
the variable name is parsed successfully, \fBTcl_ParseVar\fR returns a
pointer to the string value of the variable. If an error occurs while
parsing, then NULL is returned and an error message is left in
@@ -210,21 +210,21 @@ of \fBTcl_EvalTokens\fR is deprecated.
return parse information in two data structures, Tcl_Parse and Tcl_Token:
.CS
typedef struct Tcl_Parse {
CONST char *\fIcommentStart\fR;
int \fIcommentSize\fR;
CONST char *\fIcommandStart\fR;
int \fIcommandSize\fR;
int \fInumWords\fR;
Tcl_Token *\fItokenPtr\fR;
int \fInumTokens\fR;
...
const char *\fIcommentStart\fR;
int \fIcommentSize\fR;
const char *\fIcommandStart\fR;
int \fIcommandSize\fR;
int \fInumWords\fR;
Tcl_Token *\fItokenPtr\fR;
int \fInumTokens\fR;
...
} Tcl_Parse;
typedef struct Tcl_Token {
int \fItype\fR;
CONST char *\fIstart\fR;
int \fIsize\fR;
int \fInumComponents\fR;
int \fItype\fR;
const char *\fIstart\fR;
int \fIsize\fR;
int \fInumComponents\fR;
} Tcl_Token;
.CE
.PP
@@ -285,6 +285,16 @@ This token has the same meaning as \fBTCL_TOKEN_WORD\fR, except that
the word is guaranteed to consist of a single \fBTCL_TOKEN_TEXT\fR
sub-token. The \fInumComponents\fR field is always 1.
.TP
\fBTCL_TOKEN_EXPAND_WORD\fR
.VS 8.5
This token has the same meaning as \fBTCL_TOKEN_WORD\fR, except that
the command parser notes this word began with the expansion
prefix \fB{*}\fR, indicating that after substitution,
the list value of this word should be expanded to form multiple
arguments in command evaluation. This
token type can only be created by Tcl_ParseCommand.
.VE 8.5
.TP
\fBTCL_TOKEN_TEXT\fR
The token describes a range of literal text that is part of a word.
The \fInumComponents\fR field is always 0.
@@ -294,7 +304,7 @@ The token describes a backslash sequence such as \fB\en\fR or \fB\e0xa3\fR.
The \fInumComponents\fR field is always 0.
.TP
\fBTCL_TOKEN_COMMAND\fR
The token describes a command whose result result must be substituted into
The token describes a command whose result must be substituted into
the word. The token includes the square brackets that surround the
command. The \fInumComponents\fR field is always 0 (the nested command
is not parsed; call \fBTcl_ParseCommand\fR recursively if you want to
@@ -344,7 +354,7 @@ this includes the sub-tokens for any nested \fBTCL_TOKEN_SUB_EXPR\fR tokens.
\fBTCL_TOKEN_OPERATOR\fR
The token describes one operator of an expression
such as \fB&&\fR or \fBhypot\fR.
An \fBTCL_TOKEN_OPERATOR\fR token is always preceded by a
A \fBTCL_TOKEN_OPERATOR\fR token is always preceded by a
\fBTCL_TOKEN_SUB_EXPR\fR token
that describes the operator and its operands;
the \fBTCL_TOKEN_SUB_EXPR\fR token's \fInumComponents\fR field
@@ -352,7 +362,7 @@ can be used to determine the number of operands.
A binary operator such as \fB*\fR
is followed by two \fBTCL_TOKEN_SUB_EXPR\fR tokens
that describe its operands.
A unary operator like \fB-\fR
A unary operator like \fB\-\fR
is followed by a single \fBTCL_TOKEN_SUB_EXPR\fR token
for its operand.
If the operator is a math function such as \fBlog10\fR,
@@ -373,12 +383,16 @@ is always 0.
After \fBTcl_ParseCommand\fR returns, the first token pointed to by
the \fItokenPtr\fR field of the
Tcl_Parse structure always has type \fBTCL_TOKEN_WORD\fR or
\fBTCL_TOKEN_SIMPLE_WORD\fR. It is followed by the sub-tokens
.VS 8.5
\fBTCL_TOKEN_SIMPLE_WORD\fR or \fBTCL_TOKEN_EXPAND_WORD\fR.
It is followed by the sub-tokens
that must be concatenated to produce the value of that word.
The next token is the \fBTCL_TOKEN_WORD\fR or \fBTCL_TOKEN_SIMPLE_WORD\fR
token for the second word, followed by sub-tokens for that
of \fBTCL_TOKEN_EXPAND_WORD\fR token for the second word,
followed by sub-tokens for that
word, and so on until all \fInumWords\fR have been accounted
for.
.VE 8.5
.PP
After \fBTcl_ParseExpr\fR returns, the first token pointed to by
the \fItokenPtr\fR field of the
@@ -415,7 +429,7 @@ Tcl_Parse structure depends on the contents of the quoted string.
It will consist of one or more \fBTCL_TOKEN_TEXT\fR, \fBTCL_TOKEN_BS\fR,
\fBTCL_TOKEN_COMMAND\fR, and \fBTCL_TOKEN_VARIABLE\fR sub-tokens.
The array always contains at least one token;
for example, if the argument \fIstring\fR is empty,
for example, if the argument \fIstart\fR is empty,
the array returned consists of a single \fBTCL_TOKEN_TEXT\fR token
with a zero \fIsize\fR field.
Only the token information in the Tcl_Parse structure
@@ -436,7 +450,7 @@ the \fIcommentStart\fR, \fIcommentSize\fR,
.PP
All of the character pointers in the
Tcl_Parse and Tcl_Token structures refer
to characters in the \fIstring\fR argument passed to
to characters in the \fIstart\fR argument passed to
\fBTcl_ParseCommand\fR, \fBTcl_ParseExpr\fR, \fBTcl_ParseBraces\fR,
\fBTcl_ParseQuotedString\fR, and \fBTcl_ParseVarName\fR.
.PP
+23 -10
View File
@@ -8,21 +8,24 @@
.TH Tcl_PkgRequire 3 7.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_PkgRequire, Tcl_PkgRequireEx, Tcl_PkgPresent, Tcl_PkgPresentEx, Tcl_PkgProvide, Tcl_PkgProvideEx \- package version control
Tcl_PkgRequire, Tcl_PkgRequireEx, Tcl_PkgRequireProc, Tcl_PkgPresent, Tcl_PkgPresentEx, Tcl_PkgProvide, Tcl_PkgProvideEx \- package version control
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
CONST char *
const char *
\fBTcl_PkgRequire\fR(\fIinterp, name, version, exact\fR)
.sp
CONST char *
const char *
\fBTcl_PkgRequireEx\fR(\fIinterp, name, version, exact, clientDataPtr\fR)
.sp
CONST char *
int
\fBTcl_PkgRequireProc\fR(\fIinterp, name, objc, objv, clientDataPtr\fR)
.sp
const char *
\fBTcl_PkgPresent\fR(\fIinterp, name, version, exact\fR)
.sp
CONST char *
const char *
\fBTcl_PkgPresentEx\fR(\fIinterp, name, version, exact, clientDataPtr\fR)
.sp
int
@@ -31,12 +34,12 @@ int
int
\fBTcl_PkgProvideEx\fR(\fIinterp, name, version, clientData\fR)
.SH ARGUMENTS
.AS ClientData clientDataPtr
.AS ClientData clientDataPtr out
.AP Tcl_Interp *interp in
Interpreter where package is needed or available.
.AP "CONST char" *name in
.AP "const char" *name in
Name of package.
.AP "CONST char" *version in
.AP "const char" *version in
A version string consisting of one or more decimal numbers
separated by dots.
.AP int exact in
@@ -51,7 +54,12 @@ Arbitrary value to be associated with the package.
Pointer to place to store the value associated with the matching
package. It is only changed if the pointer is not NULL and the
function completed successfully.
.AP int objc in
Number of requirements.
.AP Tcl_Obj* objv[] in
Array of requirements.
.BE
.SH DESCRIPTION
.PP
These procedures provide C-level interfaces to Tcl's package and
@@ -71,13 +79,18 @@ that is provided in the interpreter (which may be different than
\fIversion\fR); if an error occurs they return NULL and leave an error
message in the interpreter's result.
.PP
\fBTcl_PkgProvide\fR returns TCL_OK if it completes successfully;
if an error occurs it returns TCL_ERROR and leaves an error message
\fBTcl_PkgProvide\fR returns \fBTCL_OK\fR if it completes successfully;
if an error occurs it returns \fBTCL_ERROR\fR and leaves an error message
in the interpreter's result.
.PP
\fBTcl_PkgProvideEx\fR, \fBTcl_PkgPresentEx\fR and \fBTcl_PkgRequireEx\fR
allow the setting and retrieving of the client data associated with
the package. In all other respects they are equivalent to the matching
functions.
.PP
\fBTcl_PkgRequireProc\fR is the form of \fBpackage require\fR handling
multiple requirements. The other forms are present for backward
compatibility and translate their invocations to this form.
.SH KEYWORDS
package, present, provide, require, version
+2 -2
View File
@@ -9,7 +9,7 @@
.TH Tcl_Preserve 3 7.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_Preserve, Tcl_Release, Tcl_EventuallyFree \- avoid freeing storage while it's being used
Tcl_Preserve, Tcl_Release, Tcl_EventuallyFree \- avoid freeing storage while it is being used
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -36,7 +36,7 @@ having to do with widget deletion, but are also useful in many other
situations. When a widget is deleted, its
widget record (the structure holding information specific to the
widget) must be returned to the storage allocator.
However, it's possible that the widget record is in active use
However, it is possible that the widget record is in active use
by one of the procedures on the stack at the time of the deletion.
This can happen, for example, if the command associated with a button
widget causes the button to be destroyed: an X event causes an

Some files were not shown because too many files have changed in this diff Show More