Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Partial sync-up with trunk. |
|---|---|
| Timelines: | family | ancestors | descendants | both | tip-636-tcl9-644 |
| Files: | files | file ages | folders |
| SHA3-256: |
82fe864420ab5a70408168d80449810c |
| User & Date: | griffin 2023-04-30 23:09:13.538 |
Context
|
2023-05-03
| ||
| 02:01 | merge trunk check-in: d4c2e9791a user: griffin tags: tip-636-tcl9-644 | |
|
2023-04-30
| ||
| 23:09 | Partial sync-up with trunk. check-in: 82fe864420 user: griffin tags: tip-636-tcl9-644 | |
|
2023-04-26
| ||
| 16:18 | Fix index descrepencies (bug-fa00fbbbabe). Fix inconsistent rounding (bug-e5f06285de). check-in: a610e50b2f user: griffin tags: trunk, main | |
|
2023-04-23
| ||
| 08:13 | Fix gcc type mismatch warnings exposed by disabling casts using disabletcl8api check-in: 44c8ea9887 user: apnadkarni tags: trunk, main | |
| 05:23 | Merge 8.7 - [d90fee06d0] (lassign) and [203792a48c] (Utf32ToUtf) check-in: 8b91a4a3c6 user: apnadkarni tags: trunk, main | |
|
2023-04-19
| ||
| 03:36 | TIP 660 accepted. check-in: 1842599320 user: apnadkarni tags: trunk, main | |
|
2023-04-12
| ||
| 14:25 | Correct spelling errors in comments and documentation, but also a non-comment corrections in history... check-in: d65da06a77 user: pooryorick tags: trunk, main | |
|
2023-03-26
| ||
| 19:14 | Fix memory leak in Tcl_JoinObjCmd(). check-in: aa1a1096ac user: pooryorick tags: trunk, main | |
|
2023-03-25
| ||
| 00:29 | Merge trunk check-in: f6aa53859c user: griffin tags: tip-636-tcl9-644 | |
Changes
Changes to ChangeLog.
| ︙ | ︙ | |||
1378 1379 1380 1381 1382 1383 1384 | 2012-04-28 Alexandre Ferrieux <ferrieux@users.sourceforge.net> * generic/tclIO.c: Properly close nonblocking channels even when not flushing them. 2012-05-03 Jan Nijtmans <nijtmans@users.sf.net> | | | 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 | 2012-04-28 Alexandre Ferrieux <ferrieux@users.sourceforge.net> * generic/tclIO.c: Properly close nonblocking channels even when not flushing them. 2012-05-03 Jan Nijtmans <nijtmans@users.sf.net> * compat/zlib/*: Upgrade to zlib 1.2.7 (prebuilt dll is still 1.2.5, will be upgraded as soon as the official build is available) 2012-05-03 Don Porter <dgp@users.sourceforge.net> * tests/socket.test: [Bug 3428754]: Test socket-14.2 tolerate [socket -async] connection that connects synchronously. |
| ︙ | ︙ | |||
5478 5479 5480 5481 5482 5483 5484 | checking for the exact error message. 2010-03-30 Andreas Kupries <andreask@activestate.com> * generic/tclIORChan.c (ReflectClose, ReflectInput, ReflectOutput, (ReflectSeekWide, ReflectWatch, ReflectBlock, ReflectSetOption, (ReflectGetOption, ForwardProc): [Bug 2978773]: Preserve | | | 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 | checking for the exact error message. 2010-03-30 Andreas Kupries <andreask@activestate.com> * generic/tclIORChan.c (ReflectClose, ReflectInput, ReflectOutput, (ReflectSeekWide, ReflectWatch, ReflectBlock, ReflectSetOption, (ReflectGetOption, ForwardProc): [Bug 2978773]: Preserve ReflectedChannel* structures across handler invocations, to avoid crashes when the handler implementation induces nested callbacks and destruction of the channel deep inside such a nesting. 2010-03-30 Don Porter <dgp@users.sourceforge.net> * generic/tclObj.c (Tcl_GetCommandFromObj): [Bug 2979402]: Reorder the validity tests on internal rep of a "cmdName" value to avoid |
| ︙ | ︙ | |||
6359 6360 6361 6362 6363 6364 6365 | * generic/tclBinary.c: [Bug 2922555]: Handle completely invalid input * tests/binary.test: to the decode methods. 2009-12-28 Donal K. Fellows <dkf@users.sf.net> * unix/Makefile.in (trace-shell, trace-test): [FRQ 1083288]: Added | | | 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 | * generic/tclBinary.c: [Bug 2922555]: Handle completely invalid input * tests/binary.test: to the decode methods. 2009-12-28 Donal K. Fellows <dkf@users.sf.net> * unix/Makefile.in (trace-shell, trace-test): [FRQ 1083288]: Added targets to allow easier tracing of shell and test invocations. * unix/configure.in: [Bug 942170]: Detect the st_blocks field of * generic/tclCmdAH.c (StoreStatData): 'struct stat' correctly. * generic/tclFileName.c (Tcl_GetBlocksFromStat): * generic/tclIOUtil.c (Tcl_Stat): * generic/tclInterp.c (TimeLimitCallback): [Bug 2891362]: Ensure that |
| ︙ | ︙ | |||
6843 6844 6845 6846 6847 6848 6849 | * tools/tclZIC.tcl * tools/tsdPerf.c 2009-11-17 Andreas Kupries <andreask@activestate.com> * unix/tclUnixChan.c (TtyParseMode): Partial undo of Donal's tidy-up from a few days ago (2009-11-9, not in ChangeLog). It seems that | | | 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 | * tools/tclZIC.tcl * tools/tsdPerf.c 2009-11-17 Andreas Kupries <andreask@activestate.com> * unix/tclUnixChan.c (TtyParseMode): Partial undo of Donal's tidy-up from a few days ago (2009-11-9, not in ChangeLog). It seems that strchr is apparently a macro on AIX and reacts badly to preprocessor directives in its arguments. 2009-11-16 Alexandre Ferrieux <ferrieux@users.sourceforge.net> * generic/tclEncoding.c: [Bug 2891556]: Fix and improve test to * generic/tclTest.c: detect similar manifestations in the future. * tests/encoding.test: Add tcltest support for finalization. |
| ︙ | ︙ | |||
7137 7138 7139 7140 7141 7142 7143 | 2009-10-20 Don Porter <dgp@users.sourceforge.net> * unix/Makefile.in: Removed the long outdated and broken targets package-* that were for building Solaris packages. Appears that the pieces needed for these targets to function have never been present in the current era of Tcl development and belong completely to Tcl | | | 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 | 2009-10-20 Don Porter <dgp@users.sourceforge.net> * unix/Makefile.in: Removed the long outdated and broken targets package-* that were for building Solaris packages. Appears that the pieces needed for these targets to function have never been present in the current era of Tcl development and belong completely to Tcl prehistory. 2009-10-19 Don Porter <dgp@users.sourceforge.net> * generic/tclIO.c: [Patch 2107634]: Revised ReadChars and FilterInputBytes routines to permit reads to continue up to the string limits of Tcl values. Before revisions, large read attempts could panic when as little as half the limiting value length was reached. |
| ︙ | ︙ | |||
8705 8706 8707 8708 8709 8710 8711 | customize SHLIB_VERSION on BSD-derived systems. Thanks to Stuart Cassoff for his help. * unix/configure: Autoconf 2.59 2009-01-19 David Gravereaux <davygrvy@pobox.com> * win/build.vc.bat: Improved tools detection and error message | | | 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 | customize SHLIB_VERSION on BSD-derived systems. Thanks to Stuart Cassoff for his help. * unix/configure: Autoconf 2.59 2009-01-19 David Gravereaux <davygrvy@pobox.com> * win/build.vc.bat: Improved tools detection and error message * win/makefile.vc: Reorganized the $(TCLOBJ) file list into separate parts for easier maintenance. Matched all sources built using -GL to both $(lib) and $(link) to use -LTCG and avoid a warning message. Addressed the over-building nature of the htmlhelp target by moving from a pseudo target to a real target dependent on the entire docs/ directory contents. * win/nmakehlp.c: Removed -g option and GrepForDefine() func as it isn't being used anymore. The -V option method is much better. |
| ︙ | ︙ |
Changes to ChangeLog.1999.
| ︙ | ︙ | |||
384 385 386 387 388 389 390 | of the variable. * tests/autoMkindex.test: * tests/pkgMkIndex.test: Explicitly cd to ::tcltest::testsDirectory at the beginning of the test run * tests/basic.test: Use version information defined in tcltest instead | | | 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | of the variable. * tests/autoMkindex.test: * tests/pkgMkIndex.test: Explicitly cd to ::tcltest::testsDirectory at the beginning of the test run * tests/basic.test: Use version information defined in tcltest instead of hard-coded version number * tests/socket.test: package require tcltest before attempting to use variable defined in tcltest namespace * tests/unixInit.test: * tests/unixNotfy.test: Added explicit exits needed to avoid problems when the tests area run in wish. |
| ︙ | ︙ |
Changes to ChangeLog.2000.
| ︙ | ︙ | |||
99 100 101 102 103 104 105 | 2000-11-23 Donal K. Fellows <fellowsd@cs.man.ac.uk> * generic/tclCmdIL.c (Tcl_LsortObjCmd): Fixed memory leak from [Bug 119398] * library/init.tcl (unknown): Added specific level parameters to | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | 2000-11-23 Donal K. Fellows <fellowsd@cs.man.ac.uk> * generic/tclCmdIL.c (Tcl_LsortObjCmd): Fixed memory leak from [Bug 119398] * library/init.tcl (unknown): Added specific level parameters to all uplevel invocation to boost performance; didn't dare touch the "namespace inscope" stuff though, since it looks sensitive to me! Should fix [Bug 123217], though testing is tricky... 2000-11-21 Andreas Kupries <a.kupries@westend.com> All of the changes below are described in TIP #7 ~ Specification and result from the application of the patch contained therein. Creator of |
| ︙ | ︙ | |||
344 345 346 347 348 349 350 | * doc/tcltest2.n: Code and documentation cleanup. Modified -verbose to take list of keywords as well as string of letters. Removed Tcl version information from tcltest. Removed tcltest::grep from tcltest package. Added optional 3rd directory argument to makeFile/makeDirectory and removeFile/removeDirectory. * tests/basic.test: Changed references to tcltest::tclVersion to | | | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | * doc/tcltest2.n: Code and documentation cleanup. Modified -verbose to take list of keywords as well as string of letters. Removed Tcl version information from tcltest. Removed tcltest::grep from tcltest package. Added optional 3rd directory argument to makeFile/makeDirectory and removeFile/removeDirectory. * tests/basic.test: Changed references to tcltest::tclVersion to hard-coded numbers. * generic/tcl.h: Changed reference to tcltest2.tcl and tcltest.tcl in comments to tests/basic.test. 2000-10-06 David Gravereaux <davygrvy@ajubasolutions.com> * win/tclWinChan.c: moved Win2K bug case test with GetStdHandle() from TclpGetDefaultStdChannel into Tcl_MakeFileChannel to enable a more |
| ︙ | ︙ | |||
1117 1118 1119 1120 1121 1122 1123 | * library/msgcat1.0/msgcat.tcl: Applied patches from Laurent Duperval, to add mcmax function, which computes the length of the longest of several translated strings. Bumped version number to 1.1. 2000-06-27 Eric Melski <ericm@scriptics.com> | | | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | * library/msgcat1.0/msgcat.tcl: Applied patches from Laurent Duperval, to add mcmax function, which computes the length of the longest of several translated strings. Bumped version number to 1.1. 2000-06-27 Eric Melski <ericm@scriptics.com> * tests/stringObj.test: Tweaked tests to avoid hard-coded high-ASCII characters (which will fail in multibyte locales); instead used \uXXXX syntax. [Bug: 3842]. 2000-06-26 Eric Melski <ericm@scriptics.com> * doc/package.n: Corrected information about [package forget] arguments [Bug: 5418]. |
| ︙ | ︙ | |||
1542 1543 1544 1545 1546 1547 1548 | Tcl_InitMemory, and Tcl_ValidateAllMemory [Bug: 1816, 1835]. * generic/tclCkalloc.c: Fixed some function headers. * unix/mkLinks: Regen'd with new mkLinks.tcl. * unix/mkLinks.tcl: Fixed indentation, made link setup more | | | 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 | Tcl_InitMemory, and Tcl_ValidateAllMemory [Bug: 1816, 1835]. * generic/tclCkalloc.c: Fixed some function headers. * unix/mkLinks: Regen'd with new mkLinks.tcl. * unix/mkLinks.tcl: Fixed indentation, made link setup more intelligent (only do one existence test per man page, instead of one per function). * doc/library.n: Fixed .SH NAME macro to include each function documented on the page, so that mkLinks will know about the functions listed there, and so that the Windows help file index will get set up correctly [Bug: 1898, 5273]. |
| ︙ | ︙ | |||
1637 1638 1639 1640 1641 1642 1643 | fixed http::ncode so that it actually gives you back the http return code (i.e. 200, 404, etc.) instead of the first digit of the version of HTTP being used (i.e. 1). 2000-04-21 Brent Welch <welch@scriptics.com> * library/http2.1/http.tcl: More thrashing with the "server closes | | | 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 | fixed http::ncode so that it actually gives you back the http return code (i.e. 200, 404, etc.) instead of the first digit of the version of HTTP being used (i.e. 1). 2000-04-21 Brent Welch <welch@scriptics.com> * library/http2.1/http.tcl: More thrashing with the "server closes without reading post data" scenario. Reverted to the previous fileevent configuratiuon, which seems to work better with small amounts of post data. 2000-04-20 Jeff Hobbs <hobbs@scriptics.com> * generic/tclAlloc.c: wrapped caddr_t define to not be done on Unix * unix/tclUnixPort.h: added Tclp*Alloc defines to allow the use of |
| ︙ | ︙ | |||
2263 2264 2265 2266 2267 2268 2269 | * tests/pkg/magicchar.tcl: * tests/autoMkindex.test: Test for fix for bug #2611. * library/auto.tcl: Fixed the regular expression that performs $ escaping before sourcing a file to index. It was erroneously adding \ escapes even to $'s that were already escaped, effectively | | | 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 | * tests/pkg/magicchar.tcl: * tests/autoMkindex.test: Test for fix for bug #2611. * library/auto.tcl: Fixed the regular expression that performs $ escaping before sourcing a file to index. It was erroneously adding \ escapes even to $'s that were already escaped, effectively "unescaping" those $'s. (bug #2611). 2000-01-27 Eric Melski <ericm@scriptics.com> * tests/autoMkindex.test: * library/auto.tcl: Applied patch (with slight modification) from bug #2701: auto_mkIndex uses platform dependent file paths. Added test for fix. |
| ︙ | ︙ | |||
2374 2375 2376 2377 2378 2379 2380 | #981). * doc/upvar.n: Expanded explanation of upvar behavior with respect to variable traces. (bugs 3917 1433 2110). * generic/tclVar.c: Changed behavior of variable command when name refers to an element in an array (ie, "variable foo(x)") to always | | | 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 | #981). * doc/upvar.n: Expanded explanation of upvar behavior with respect to variable traces. (bugs 3917 1433 2110). * generic/tclVar.c: Changed behavior of variable command when name refers to an element in an array (ie, "variable foo(x)") to always return an error, regardless of existence of that element in the array (now behavior is consistant with docs too) (bug #981). 2000-01-20 Jeff Hobbs <hobbs@scriptics.com> * generic/tclCmdIL.c (InfoBodyCmd): made [info body] return a string if the body has been bytecompiled. * generic/tclBasic.c (Tcl_EvalObjEx): added pedantic check for |
| ︙ | ︙ |
Changes to ChangeLog.2002.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 | 2002-12-16 David Gravereaux <davygrvy@pobox.com> * generic/tclPipe.c (TclCleanupChildren): * tests/winPipe.test: * win/tclWinPipe.c (Tcl_WaitPid): * win/tclWinTest.c: Gave Tcl_WaitPid the ability to return a Win32 | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 2002-12-16 David Gravereaux <davygrvy@pobox.com> * generic/tclPipe.c (TclCleanupChildren): * tests/winPipe.test: * win/tclWinPipe.c (Tcl_WaitPid): * win/tclWinTest.c: Gave Tcl_WaitPid the ability to return a Win32 exception code translated into a Posix-style SIG*. This allows [close] to report "CHILDKILLED" without the meaning getting lost in a truncated exit code. In TclCleanupChildren(), TclpGetPid() had to get moved to before Tcl_WaitPid() as the the handle is removed from the list taking away the ability to get the process id after the wait is done. This shouldn't effect the unix implimentaion unless waitpid is called with a pid of zero, meaning "any". I don't think it is.. |
| ︙ | ︙ | |||
1937 1938 1939 1940 1941 1942 1943 | * library/tcltest/tcltest.tcl: Change [configure -match] to stop treating an empty list as a list of the single pattern "*". Changed the default value to [list *] so default operation remains the same. * tests/pkg/samename.tcl: restored. needed by pkgMkIndex.test. | | | | | 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 | * library/tcltest/tcltest.tcl: Change [configure -match] to stop treating an empty list as a list of the single pattern "*". Changed the default value to [list *] so default operation remains the same. * tests/pkg/samename.tcl: restored. needed by pkgMkIndex.test. * library/tcltest/tcltest.tcl: restored writability testing of -tmpdir, augmented by a special exception for the deafault value. 2002-07-01 Donal K. Fellows <fellowsd@cs.man.ac.uk> * doc/concat.n: Documented the *real* behaviour of [concat]! 2002-06-30 Don Porter <dgp@users.sourceforge.net> * doc/tcltest.n: more work in progress updating tcltest docs. * tests/README: Updated the instructions on running and * tests/cmdMZ.test: adding to the test suite. Also updated * tests/encoding.test: several tests, mostly to correctly create * tests/fCmd.test: and destroy any temporary files in the * tests/info.test: [temporaryDirectory] of tcltest. * tests/interp.test: * library/tcltest/tcltest.tcl: Stopped checking for writability of -tmpdir value because no default directory can be guaranteed to be writable. * tests/autoMkindex.tcl: removed. * tests/pkg/samename.tcl: removed. * tests/pkg/magicchar.tcl: removed. * tests/pkg/magicchar2.tcl: removed. * tests/autoMkindex.test: Updated auto_mkIndex tests to use [makeFile] and [removeFile] so tests are done in [temporaryDirecotry] where write |
| ︙ | ︙ | |||
2465 2466 2467 2468 2469 2470 2471 | 2002-06-06 Daniel Steffen <das@users.sourceforge.net> * unix/tclUnixThrd.c (TclpReaddir, TclpLocaltime, TclpGmtime): added mutex wrapped calls to readdir, localtime & gmtime in case their thread-safe *_r counterparts are not available. * unix/tcl.m4: added configure check for readdir_r * unix/tcl.m4 (Darwin): set TCL_DEFAULT_ENCODING to utf-8 on MacOSX | | | 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 | 2002-06-06 Daniel Steffen <das@users.sourceforge.net> * unix/tclUnixThrd.c (TclpReaddir, TclpLocaltime, TclpGmtime): added mutex wrapped calls to readdir, localtime & gmtime in case their thread-safe *_r counterparts are not available. * unix/tcl.m4: added configure check for readdir_r * unix/tcl.m4 (Darwin): set TCL_DEFAULT_ENCODING to utf-8 on MacOSX (where Posix file apis expect utf-8, not iso8859-1). * unix/configure: regen * unix/Makefile.in: set DYLD_LIBRARY_PATH in parallel to LD_LIBRARY_PATH for MacOSX dynamic linker. * generic/tclEnv.c (TclSetEnv): fix env var setting on MacOSX (adapted from [Patch 524352] by jkbonfield). 2002-06-05 Don Porter <dgp@users.sourceforge.net> |
| ︙ | ︙ | |||
3679 3680 3681 3682 3683 3684 3685 | * win/makefile.vc: * win/rules.vc: Added a new "loimpact" option that sets the -ws:aggressive linker option. Off by default. It's said to keep the heap use low at the expense of alloc speed. * win/tclAppInit.c: Changed #include "tcl.h" to be tclPort.h to remove the raw windows.h include. tclPort.h brings in windows.h already and | | | 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 | * win/makefile.vc: * win/rules.vc: Added a new "loimpact" option that sets the -ws:aggressive linker option. Off by default. It's said to keep the heap use low at the expense of alloc speed. * win/tclAppInit.c: Changed #include "tcl.h" to be tclPort.h to remove the raw windows.h include. tclPort.h brings in windows.h already and lessens the precompiled-header mush and the randomly useless #pragma comment (lib,...) references throughout the big windows.h tree (as observed at high linker warning levels). 2002-02-21 Donal K. Fellows <fellowsd@cs.man.ac.uk> * generic/tcl.h: Better guessing of LP64/ILP32 architecture, but now sensitive to presence of (suitable) <limits.h> |
| ︙ | ︙ | |||
3789 3790 3791 3792 3793 3794 3795 | * generic/tclCmdAH.c: 64-bit handling in [file] and [format] commands. * generic/tclBasic.c: New "wordSize" entry in ::tcl_platform. * generic/tclFCmd.c: Large-file support (with many consequences.) * generic/tclIO.c: Large-file support (with many consequences.) * compat/strtoll.c, compat/strtoull.c: New support functions. * unix/tcl.m4, unix/configure: 64-bit support and greatly enhanced | | | 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 | * generic/tclCmdAH.c: 64-bit handling in [file] and [format] commands. * generic/tclBasic.c: New "wordSize" entry in ::tcl_platform. * generic/tclFCmd.c: Large-file support (with many consequences.) * generic/tclIO.c: Large-file support (with many consequences.) * compat/strtoll.c, compat/strtoull.c: New support functions. * unix/tcl.m4, unix/configure: 64-bit support and greatly enhanced caching. Most other changes, including all those in doc/* and test/* as well as the majority in the platform directories, follow on from these. Also coming out of the woodwork: * generic/tclIndex.c: Better support for Cray PVP. * win/tclWinMtherr.c: Better Borland support. |
| ︙ | ︙ |
Changes to ChangeLog.2003.
| ︙ | ︙ | |||
264 265 266 267 268 269 270 | 2003-11-17 Don Porter <dgp@users.sourceforge.net> * tests/reg.test: Added tests for [Bugs 230589, 504785, 505048, 840258] recently fixed by 2003-11-15 commit to regcomp.c by Pavel Goran. His notes on the fix: This bug results from an error in code that splits states into "progress" and "no-progress" ones. This error causes an | | | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | 2003-11-17 Don Porter <dgp@users.sourceforge.net> * tests/reg.test: Added tests for [Bugs 230589, 504785, 505048, 840258] recently fixed by 2003-11-15 commit to regcomp.c by Pavel Goran. His notes on the fix: This bug results from an error in code that splits states into "progress" and "no-progress" ones. This error causes an interesting situation with the precollected single-linked list of states to be splitted: many items were added to the list, but only several of them are accessible from the list beginning, since the "tmp" member of struct state (which is used here to hold a pointer to the next list item) gets overwritten, which results in a "looped" chain. As a result, not all of states are splitted, and one state is splitted two times, causing incorrect "no-progress" flag values. |
| ︙ | ︙ | |||
2327 2328 2329 2330 2331 2332 2333 | parsing and substitution procedures as normal script evaluation. Tcl_SubstObj() moved to tclParse.c. New routine TclSubstTokens() created in tclParse.c which implements all substantial functioning of Tcl_EvalTokensStandard(). TclCompileScript() loses its "nested" argument, the Tcl_Interp struct loses its termOffset field and the TCL_BRACKET_TERM flag in the evalFlags field, all of which were only used (indirectly) by Tcl_SubstObj(). Tests subst-8.7,8.8,11.4,11.5 | | | 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 | parsing and substitution procedures as normal script evaluation. Tcl_SubstObj() moved to tclParse.c. New routine TclSubstTokens() created in tclParse.c which implements all substantial functioning of Tcl_EvalTokensStandard(). TclCompileScript() loses its "nested" argument, the Tcl_Interp struct loses its termOffset field and the TCL_BRACKET_TERM flag in the evalFlags field, all of which were only used (indirectly) by Tcl_SubstObj(). Tests subst-8.7,8.8,11.4,11.5 modified to accommodate the only behavior change: reporting of parse errors now takes precedence over [return] and [continue] exceptions. All other behavior should remain compatible. [RFE 536831,684982] [Bug 685106] * generic/tcl.h: Removed TCL_PREFIX_IDENT and TCL_DEBUG_IDENT * win/tclWinPipe.c: from tcl.h -- they are not part of Tcl's public interface. Put them in win/tclWinPipe.c where they are used. |
| ︙ | ︙ | |||
2567 2568 2569 2570 2571 2572 2573 | * generic/tclCmdMZ.c (TraceCommandProc): Fix mem leak when deleting a command that had trace on it. [Bug 693564] (sofer) 2003-02-25 Don Porter <dgp@users.sourceforge.net> * doc/pkgMkIndex.n: Modified [pkg_mkIndex] to use -nocase matching | | | 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 | * generic/tclCmdMZ.c (TraceCommandProc): Fix mem leak when deleting a command that had trace on it. [Bug 693564] (sofer) 2003-02-25 Don Porter <dgp@users.sourceforge.net> * doc/pkgMkIndex.n: Modified [pkg_mkIndex] to use -nocase matching * library/package.tcl: of -load patterns, to better accommodate common user errors due to confusion between [package names] names and [info loaded] names. 2003-02-25 Andreas Kupries <andreask@pliers.activestate.com> * tests/pid.test: See below [Bug 678412]. * tests/io.test: Made more robust against spaces in paths [Bug 678400] |
| ︙ | ︙ |
Changes to ChangeLog.2004.
| ︙ | ︙ | |||
373 374 375 376 377 378 379 | 2004-11-26 Donal K. Fellows <donal.k.fellows@man.ac.uk> * unix/configure.in: Simplify the code to check for correctness of strstr, strtoul and strtod. * unix/tcl.m4 (SC_TCL_CHECK_BROKEN_FUNC): Split a complex stanza out of configure.in into its own function. Also force it to do the right | | | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | 2004-11-26 Donal K. Fellows <donal.k.fellows@man.ac.uk> * unix/configure.in: Simplify the code to check for correctness of strstr, strtoul and strtod. * unix/tcl.m4 (SC_TCL_CHECK_BROKEN_FUNC): Split a complex stanza out of configure.in into its own function. Also force it to do the right thing with caching of results of AC_TRY_RUN to deal with issue raised in [Patch 1073524] * doc/foreach.n: Added simple example. [FRQ 1073334] 2004-11-25 Donal K. Fellows <donal.k.fellows@man.ac.uk> * generic/tclProc.c (TclObjInterpProc): Make it so that only |
| ︙ | ︙ | |||
1971 1972 1973 1974 1975 1976 1977 | Mikhail Kolesnitchenko. [Patch 1018486] 2004-08-31 Vince Darley <vincentdarley@users.sourceforge.net> * doc/FileSystem.3: * generic/tclIOUtil.c: Clarified documentation regarding ability of a filesystem to say that it doesn't support a given operation using the | | | 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 | Mikhail Kolesnitchenko. [Patch 1018486] 2004-08-31 Vince Darley <vincentdarley@users.sourceforge.net> * doc/FileSystem.3: * generic/tclIOUtil.c: Clarified documentation regarding ability of a filesystem to say that it doesn't support a given operation using the EXDEV Posix error code (copyFileProc, renameFileProc, etc), and updated one piece of code to ensure correct behaviour when an operation is not supported [Bug 1017072] * tests/fCmd.test: fix to test suite problem [Bug 1002884] 2004-08-31 Daniel Steffen <das@users.sourceforge.net> |
| ︙ | ︙ | |||
2273 2274 2275 2276 2277 2278 2279 | 2004-07-17 Vince Darley <vincentdarley@users.sourceforge.net> * generic/tclIOUtil.c: fix to rare 'cd' infinite loop in normalization with vfs [Bug 991420]. * tests/fileSystem.test: added test for above bug. | | | 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 | 2004-07-17 Vince Darley <vincentdarley@users.sourceforge.net> * generic/tclIOUtil.c: fix to rare 'cd' infinite loop in normalization with vfs [Bug 991420]. * tests/fileSystem.test: added test for above bug. * doc/FileSystem.3: clarified documentation of Posix error codes in 'remove directory' FS proc - 'EEXIST' is used to signify a non-empty directory error (bug reported against tclvfs). 2004-07-16 Jeff Hobbs <jeffh@ActiveState.com> * unix/Makefile.in, unix/tcl.m4: move (C|LD)FLAGS after their * unix/configure.in, unix/configure: _DEFAULT to allow for env setting |
| ︙ | ︙ | |||
4335 4336 4337 4338 4339 4340 4341 |
* tests/winPipe.test: more pass-thru commandline verifications.
* win/tclWinPipe.c (BuildCommandLine): Special case quoting for '{'
not required by the c-runtimes's parse_cmdline().
* win/tclAppInit.c: Removed our custom setargv() in favor of the work
provided by the c-runtime. [Bug 672938]
* win/nmakehlp.c: defensive techniques to avoid static buffer
| | | 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 |
* tests/winPipe.test: more pass-thru commandline verifications.
* win/tclWinPipe.c (BuildCommandLine): Special case quoting for '{'
not required by the c-runtimes's parse_cmdline().
* win/tclAppInit.c: Removed our custom setargv() in favor of the work
provided by the c-runtime. [Bug 672938]
* win/nmakehlp.c: defensive techniques to avoid static buffer
overflows and a couple envars upsetting invocations of cl.exe and
link.exe. [Bug 885537]
* tests/winPipe.test: Added proof that BuildCommandLine() is not doing
the "N backslashes followed a quote -> insert N * 2 + 1 backslashes
then a quote" rule needed for the crt's parse_cmdline().
* win/tclWinPipe.c: Fixed BuildCommandLine() to pass the new cases.
|
| ︙ | ︙ | |||
4544 4545 4546 4547 4548 4549 4550 | operation. * generic/tclCompCmds.c: Rewrote TclCompileReturnCmd() to call TclMergeReturnOptions() at compile time so the return options dictionary is computed at compile time (when it is fully known). The dictionary is pushed on the stack along with the result, and the code and level values are included in the bytecode as operands. Also | | | 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 | operation. * generic/tclCompCmds.c: Rewrote TclCompileReturnCmd() to call TclMergeReturnOptions() at compile time so the return options dictionary is computed at compile time (when it is fully known). The dictionary is pushed on the stack along with the result, and the code and level values are included in the bytecode as operands. Also supports optimized compilation of un[catch]ed [return]s from procs with default options into the INST_DONE instruction. * generic/tclExecute.c: Rewrote INST_RETURN instruction to retrieve the code and level operands, pop the return options from the stack, and call TclProcessReturn() to perform the [return] operation. * generic/tclCompile.h: New utilities include TclEmitInt4 macro |
| ︙ | ︙ |
Changes to ChangeLog.2005.
| ︙ | ︙ | |||
225 226 227 228 229 230 231 | since when the list of opcodes changes it is usually useful to rebuild everything that depends on it (but which is nonetheless a small fraction of the total set of Tcl source files). ***POTENTIAL INCOMPATIBILITY*** for bytecode savers/loaders. See below * generic/tclCompCmds.c (TclCompileSwitchCmd): Arrange for very simple | | | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | since when the list of opcodes changes it is usually useful to rebuild everything that depends on it (but which is nonetheless a small fraction of the total set of Tcl source files). ***POTENTIAL INCOMPATIBILITY*** for bytecode savers/loaders. See below * generic/tclCompCmds.c (TclCompileSwitchCmd): Arrange for very simple [switch] invocations to be compiled into hash lookups into jump tables; only a very specific kind of [switch] can be safely compiled this way, but that happens to be the most common kind. This makes around 5-10% difference to the speed of execution of clock.test. * generic/tclExecute.c (TEBC:INST_JUMP_TABLE): New instruction to allow for jumps to locations looked up in a hashtable. Requires a new AuxData type, tclJumptableInfoType (supported by the functions DupJumptableInfo and FreeJumptableInfo in tclCompCmds.c) so anything that saves bytecode |
| ︙ | ︙ |
Changes to ChangeLog.2007.
| ︙ | ︙ | |||
1422 1423 1424 1425 1426 1427 1428 | an expr syntax error (masked by a [catch]). * generic/tclCompCmds.c (TclCompileReturnCmd): Added crash protection to handle callers other than TclCompileScript() failing to meet the initialization assumptions of the TIP 280 code in CompileWord(). * generic/tclCompExpr.c: Suppress the attempt to convert to | | | 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 | an expr syntax error (masked by a [catch]). * generic/tclCompCmds.c (TclCompileReturnCmd): Added crash protection to handle callers other than TclCompileScript() failing to meet the initialization assumptions of the TIP 280 code in CompileWord(). * generic/tclCompExpr.c: Suppress the attempt to convert to numeric when precompiling a constant expression indicates an error. 2007-08-22 Miguel Sofer <msofer@users.sf.net> * generic/tclExecute.c (TEBC): disable the new shortcut to frequent INSTs for debug builds. REVERTED (collision with alternative fix) 2007-08-21 Don Porter <dgp@users.sourceforge.net> |
| ︙ | ︙ | |||
2823 2824 2825 2826 2827 2828 2829 | * generic/tclCmdMZ.c (STR_MAP): Replace ckalloc calls with TclStackAlloc calls. 2007-03-24 Zoran Vasiljevic <vasiljevic@users.sourceforge.net> * win/tclWinThrd.c: Thread exit handler marks the current thread as | | | | 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 | * generic/tclCmdMZ.c (STR_MAP): Replace ckalloc calls with TclStackAlloc calls. 2007-03-24 Zoran Vasiljevic <vasiljevic@users.sourceforge.net> * win/tclWinThrd.c: Thread exit handler marks the current thread as uninitialized. This allows exit handlers that are registered later to reinitialize this subsystem in case they need to use some sync primitives (cond variables) from this file again. 2007-03-23 Miguel Sofer <msofer@users.sf.net> * generic/tclBasic.c (DeleteInterpProc): pop the root frame pointer before deleting the global namespace [Bug 1658572] |
| ︙ | ︙ | |||
4934 4935 4936 4937 4938 4939 4940 | namespace creation faster. Plus selected other minor improvements to code quality. [Patch 1352382] 2006-08-10 Donal K. Fellows <donal.k.fellows@manchester.ac.uk> Misc patches to make code more efficient. [Bug 1530474] (afredd) * generic/*.c, macosx/tclMacOSXNotify.c, unix/tclUnixNotfy.c, | | | 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 | namespace creation faster. Plus selected other minor improvements to code quality. [Patch 1352382] 2006-08-10 Donal K. Fellows <donal.k.fellows@manchester.ac.uk> Misc patches to make code more efficient. [Bug 1530474] (afredd) * generic/*.c, macosx/tclMacOSXNotify.c, unix/tclUnixNotfy.c, * win/tclWinThrd.c: Tidy up invocations of Tcl_Panic() to promote string constant sharing and consistent style. * generic/tclBasic.c (Tcl_CreateInterp): More efficient handling of * generic/tclClock.c (TclClockInit): registration of commands not in global namespace. * generic/tclVar.c (Tcl_UnsetObjCmd): Remove unreachable clause. 2006-08-09 Don Porter <dgp@users.sourceforge.net> |
| ︙ | ︙ | |||
5012 5013 5014 5015 5016 5017 5018 | * generic/tclExecute.c: Corrected flawed overflow detection in * tests/expr.test: INST_EXPON that caused [expr 2**64] to return 0 instead of the same value as [expr 1<<64]. 2006-07-24 Don Porter <dgp@users.sourceforge.net> | | | 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 | * generic/tclExecute.c: Corrected flawed overflow detection in * tests/expr.test: INST_EXPON that caused [expr 2**64] to return 0 instead of the same value as [expr 1<<64]. 2006-07-24 Don Porter <dgp@users.sourceforge.net> * win/tclWinSock.c: Correct uninitialized Tcl_DString. Thanks to afredd. [Bug 1518166] 2006-07-21 Miguel Sofer <msofer@users.sf.net> * generic/tclExecute.c: * tests/execute.test (execute-9.1): dgp's fix for [Bug 1522803]. |
| ︙ | ︙ |
Changes to ChangeLog.2008.
| ︙ | ︙ | |||
1203 1204 1205 1206 1207 1208 1209 | * generic/tclCompCmds.c (TclCompileEnsemble) * generic/tclNamesp.c (NamespaceEnsembleCmd) (Tcl_SetEnsembleParameterList, Tcl_GetEnsembleParameterList) (NsEnsembleImplementationCmdNR): * generic/tcl.decls, doc/Ensemble.3, doc/namespace.n * tests/namespace.test: Allow the handling of a (fixed) number of formal parameters between an ensemble's command and subcommand at | | | 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 | * generic/tclCompCmds.c (TclCompileEnsemble) * generic/tclNamesp.c (NamespaceEnsembleCmd) (Tcl_SetEnsembleParameterList, Tcl_GetEnsembleParameterList) (NsEnsembleImplementationCmdNR): * generic/tcl.decls, doc/Ensemble.3, doc/namespace.n * tests/namespace.test: Allow the handling of a (fixed) number of formal parameters between an ensemble's command and subcommand at invocation time. [Patch 1901783] 2008-09-28 Miguel Sofer <msofer@users.sf.net> * generic/tclBasic.c: Fix the numLevels computations on * generic/tclInt.h: coroutine yield/resume * tests/unsupported.test: |
| ︙ | ︙ | |||
3248 3249 3250 3251 3252 3253 3254 | * generic/tclBinary.c: [Bug 1923966] - crash in binary format * tests/binary.test: Added tests for the above crash condition. 2008-03-21 Donal K. Fellows <dkf@users.sf.net> * doc/switch.n: Clarified documentation in respect of two-argument | | | 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 | * generic/tclBinary.c: [Bug 1923966] - crash in binary format * tests/binary.test: Added tests for the above crash condition. 2008-03-21 Donal K. Fellows <dkf@users.sf.net> * doc/switch.n: Clarified documentation in respect of two-argument invocation. [Bug 1899962] * tests/switch.test: Added more tests of regexp-mode compilation of the [switch] command. [Bug 1854435] 2008-03-20 Donal K. Fellows <dkf@users.sf.net> * generic/tcl.h, generic/tclThreadAlloc.c: Tidied up the declarations |
| ︙ | ︙ |
Changes to changes.
| ︙ | ︙ | |||
2482 2483 2484 2485 2486 2487 2488 | to implement the safe base, instead of deleting the commands from a safe interpreter. (JL) 11/15/96 (new feature) Implemented the safe base, a mechanism for installing and requesting security policies, purely in Tcl code. Overloads the package command to also allow an interpreter to "require" a policy. The following new library commands are provided: | | | 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 | to implement the safe base, instead of deleting the commands from a safe interpreter. (JL) 11/15/96 (new feature) Implemented the safe base, a mechanism for installing and requesting security policies, purely in Tcl code. Overloads the package command to also allow an interpreter to "require" a policy. The following new library commands are provided: tcl_safeCreateInterp -- creates a slave and initializes the policy mechanism. tcl_safeInitInterp -- initializes an existing slave with the policy mechanism. tcl_safeDeleteInterp -- deletes a slave and deinitializes the policy mechanism. Added a new file to the library, safeinit.tcl, to hold implementation. (JL) On 7/9/97, removed the policy loading mechanism from the Safe Base. Left |
| ︙ | ︙ | |||
3024 3025 3026 3027 3028 3029 3030 |
6/19/97 (bug fix) Fixed a panic due to the following four line script:
interp create x
x alias foo bar
x eval rename foo blotz
x alias foo {}
The problem was that the interp code was not using the actual current name
| | | 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 |
6/19/97 (bug fix) Fixed a panic due to the following four line script:
interp create x
x alias foo bar
x eval rename foo blotz
x alias foo {}
The problem was that the interp code was not using the actual current name
of the command to be deleted as a result of unaliasing foo. (JL)
6/19/97 (feature change) Pass interp down to the ChannelOption and
driver specific calls so system errors can be differentiated from syntax
ones. Changed Tcl_DriverGetOptionProc type. Affects Tcl_GetChannelOption,
TcpGetOptionProc, TtyGetOptionProc, etc. (DL)
*** POTENTIAL INCOMPATIBILITY ***
|
| ︙ | ︙ | |||
4163 4164 4165 4166 4167 4168 4169 |
- Modifying the TclpInitLibraryPath routines.
(surles)
3/14/99 (feature change) Added hooks for TclPro Wrapper to initialize
the location of the encoding files and libraries. This fix included:
- Adding the TclSetPerInitScript routine.
- Modifying the Tcl_Init routines to evaluate the non-NULL
| | | 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 |
- Modifying the TclpInitLibraryPath routines.
(surles)
3/14/99 (feature change) Added hooks for TclPro Wrapper to initialize
the location of the encoding files and libraries. This fix included:
- Adding the TclSetPerInitScript routine.
- Modifying the Tcl_Init routines to evaluate the non-NULL
preinit script.
- Adding the Tcl_SetdefaultEncodingDir and Tcl_GetDefaultEncodingDir
routines.
- Modifying the TclpInitLibrary routines to append the default
encoding dir.
(surles)
3/14/99 (feature change) Test suite now uses "test" namespace to
|
| ︙ | ︙ | |||
6973 6974 6975 6976 6977 6978 6979 | 2007-08-14 (platform support) Darwin [load] from VFS on intel & 64bit (steffen) 2007-08-15 (bug fix)[1773127] corrected open mode "a+" (rottman,fellows) 2007-08-16 (bug fix)[1773040] ::errorInfo trace crash (janssen,porter) | | | 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 | 2007-08-14 (platform support) Darwin [load] from VFS on intel & 64bit (steffen) 2007-08-15 (bug fix)[1773127] corrected open mode "a+" (rottman,fellows) 2007-08-16 (bug fix)[1773040] ::errorInfo trace crash (janssen,porter) 2007-08-16 (performance)[1564517] precompile constant expressions (porter) 2007-08-21 (bug fix)[1775878] 'puts \' in interactive tclsh failed to move to prompt for continuation line (porter) 2007-08-25 (bug fix)[1781282] [clock scan] case senstivity (kenny) 2007-08-25 (performance)[1767293] ** on native integer types (kenny) |
| ︙ | ︙ | |||
8681 8682 8683 8684 8685 8686 8687 |
2016-07-02 (enhancement)[09fabc] Sort order of -relateddir (lanam)
2016-07-07 (bug)[5d7ca0] Win: [file executable] for .cmd and .ps1 (nadkarni)
*** POTENTIAL INCOMPATIBILITY ***
2016-07-08 (bug)[a47641] [file normalize] & Windows junctions (nadkarni)
| | | 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 |
2016-07-02 (enhancement)[09fabc] Sort order of -relateddir (lanam)
2016-07-07 (bug)[5d7ca0] Win: [file executable] for .cmd and .ps1 (nadkarni)
*** POTENTIAL INCOMPATIBILITY ***
2016-07-08 (bug)[a47641] [file normalize] & Windows junctions (nadkarni)
2016-07-09 [ae61a6] [file] handling of Win hard-coded names (CON) (nadkarni)
*** POTENTIAL INCOMPATIBILITY ***
2016-07-09 [3613671] [file owned] (more) useful on Win (nadkarni)
2016-07-09 (bug)[1493a4] [namespace upvar] use of resolvers (beric,fellows)
*** POTENTIAL INCOMPATIBILITY ***
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/minizip.c.
| ︙ | ︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
#endif
#include "zip.h"
#ifdef _WIN32
#define USEWIN32IOAPI
#include "iowin32.h"
#endif
#define WRITEBUFFERSIZE (16384)
#define MAXFILENAME (256)
| > > > | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
#endif
#include "zip.h"
#ifdef _WIN32
#define USEWIN32IOAPI
#include "iowin32.h"
# if defined(_MSC_VER)
# define snprintf _snprintf
# endif
#endif
#define WRITEBUFFERSIZE (16384)
#define MAXFILENAME (256)
|
| ︙ | ︙ | |||
361 362 363 364 365 366 367 |
}
}
void addPathToZip(zipFile zf, const char *filenameinzip, const char *password, int opt_exclude_path,int opt_compress_level) {
tinydir_dir dir;
int i;
| | | | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
}
}
void addPathToZip(zipFile zf, const char *filenameinzip, const char *password, int opt_exclude_path,int opt_compress_level) {
tinydir_dir dir;
int i;
char newname[MAXFILENAME+1+MAXFILENAME+1];
tinydir_open_sorted(&dir, filenameinzip);
for (i = 0; i < dir.n_files; i++)
{
tinydir_file file;
tinydir_readfile_n(&dir, &file, i);
if(strcmp(file.name,".")==0) continue;
if(strcmp(file.name,"..")==0) continue;
snprintf(newname, sizeof(newname), "%.*s/%.*s", MAXFILENAME, dir.path, MAXFILENAME, file.name);
if (file.is_dir)
{
addPathToZip(zf,newname,password,opt_exclude_path,opt_compress_level);
} else {
addFileToZip(zf,newname,password,opt_exclude_path,opt_compress_level);
}
}
|
| ︙ | ︙ |
Changes to doc/AddErrInfo.3.
| ︙ | ︙ | |||
50 51 52 53 54 55 56 | .AP "const 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 \fIlength\fR bytes containing a string to append to the \fB\-errorinfo\fR return option. This byte array may contain embedded null bytes | | | | < < < | | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | .AP "const 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 \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. .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. .AP Tcl_Size length in The number of bytes to copy from \fImessage\fR when 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 The \fB\-errorcode\fR return option will be set to this value. .AP "const char" *element in String to record as one element of the \fB\-errorcode\fR return option. Last \fIelement\fR argument must be NULL. .AP int lineNum The line number of a script where an error occurred. .AP "const char" *script in Pointer to first character in script containing command (must be <= command) .AP "const char" *command in Pointer to first character in command that generated the error .AP Tcl_Size commandLength in Number of bytes in command; a negative value means use all bytes up to first null byte .BE .SH DESCRIPTION .PP 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 |
| ︙ | ︙ | |||
223 224 225 226 227 228 229 | \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 | | | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | \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 \fB\-errorcode\fR return option to the list value \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 |
| ︙ | ︙ |
Changes to doc/ByteArrObj.3.
| ︙ | ︙ | |||
30 31 32 33 34 35 36 | unsigned char * \fBTcl_SetByteArrayLength\fR(\fIobjPtr, numBytes\fR) .SH ARGUMENTS .AS "const unsigned char" *numBytesPtr in/out .AP "const unsigned char" *bytes in The array of bytes used to initialize or set a byte-array value. May be NULL even if \fInumBytes\fR is non-zero. | | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | unsigned char * \fBTcl_SetByteArrayLength\fR(\fIobjPtr, numBytes\fR) .SH ARGUMENTS .AS "const unsigned char" *numBytesPtr in/out .AP "const unsigned char" *bytes in The array of bytes used to initialize or set a byte-array value. May be NULL even if \fInumBytes\fR is non-zero. .AP Tcl_Size numBytes in The number of bytes in the array. .AP Tcl_Obj *objPtr in/out For \fBTcl_SetByteArrayObj\fR, this points to an unshared value to be overwritten by a byte-array value. For \fBTcl_GetBytesFromObj\fR, \fBTcl_GetByteArrayFromObj\fR and \fBTcl_SetByteArrayLength\fR, this points to the value from which to extract an array of bytes. .AP Tcl_Interp *interp in Interpreter to use for error reporting. .AP "Tcl_Size \&| int" *numBytesPtr out Points to space where the number of bytes in the array may be written. Caller may pass NULL when it does not need this information. .BE .SH DESCRIPTION .PP These routines are used to create, modify, store, transfer, and retrieve |
| ︙ | ︙ | |||
130 131 132 133 134 135 136 | has not been disturbed. The pointer may be used to overwrite the byte contents of the internal representation, so long as the value is unshared and any string representation is invalidated. .PP On success, both \fBTcl_GetBytesFromObj\fR and \fBTcl_GetByteArrayFromObj\fR write the number of bytes in the byte-array value of \fIobjPtr\fR to the space pointed to by \fInumBytesPtr\fR. This space may be of type | | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | has not been disturbed. The pointer may be used to overwrite the byte contents of the internal representation, so long as the value is unshared and any string representation is invalidated. .PP On success, both \fBTcl_GetBytesFromObj\fR and \fBTcl_GetByteArrayFromObj\fR write the number of bytes in the byte-array value of \fIobjPtr\fR to the space pointed to by \fInumBytesPtr\fR. This space may be of type \fBTcl_Size\fR or of type \fBint\fR. It is recommended that callers provide a \fBTcl_Size\fR space for this purpose. If the caller provides only an \fBint\fR space and the number of bytes in the byte-array value of \fIobjPtr\fR is greater than \fBINT_MAX\fR, the routine will fail due to being unable to correctly report the byte-array size to the caller. The ability to provide an \fBint\fR space is best considered a migration aid for codebases constrained to continue operating with Tcl releases older than 8.7. .PP |
| ︙ | ︙ |
Changes to doc/Cancel.3.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | .AP Tcl_Interp *interp in Interpreter in which to cancel the script. .AP Tcl_Obj *resultObjPtr in Error message to use in the cancellation, or NULL to use a default message. If not NULL, this object will have its reference count decremented before \fBTcl_CancelEval\fR returns. .AP int flags in | | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | .AP Tcl_Interp *interp in Interpreter in which to cancel the script. .AP Tcl_Obj *resultObjPtr in Error message to use in the cancellation, or NULL to use a default message. If not NULL, this object will have its reference count decremented before \fBTcl_CancelEval\fR returns. .AP int flags in OR'ed combination of flag bits that specify additional options. For \fBTcl_CancelEval\fR, only \fBTCL_CANCEL_UNWIND\fR is currently supported. For \fBTcl_Canceled\fR, only \fBTCL_LEAVE_ERR_MSG\fR and \fBTCL_CANCEL_UNWIND\fR are currently supported. .AP void *clientData in Currently reserved for future use. It should be set to NULL. .BE .SH DESCRIPTION .PP \fBTcl_CancelEval\fR cancels or unwinds the script in progress soon after the next invocation of asynchronous handlers, causing \fBTCL_ERROR\fR to be the return code for that script. This function is thread-safe and may be called from any thread in the process. .PP \fBTcl_Canceled\fR checks if the script in progress has been canceled and returns \fBTCL_ERROR\fR if it has. Otherwise, \fBTCL_OK\fR is returned. Extensions can use this function to check to see if they should abort a long running command. This function is thread sensitive and may only be called from the thread the interpreter was created in. .SS "FLAG BITS" Any OR'ed combination of the following values may be used for the \fIflags\fR argument to procedures such as \fBTcl_CancelEval\fR: .TP 20 \fBTCL_CANCEL_UNWIND\fR . This flag is used by \fBTcl_CancelEval\fR and \fBTcl_Canceled\fR. For \fBTcl_CancelEval\fR, if this flag is set, the script in progress is canceled and the evaluation stack for the interpreter is unwound. |
| ︙ | ︙ |
Changes to doc/Class.3.
| ︙ | ︙ | |||
77 78 79 80 81 82 83 | .AP "const char" *name in The name of the object to create, or NULL if a new unused name is to be automatically selected. .AP "const char" *nsName in The name of the namespace to create for the object's private use, or NULL if a new unused name is to be automatically selected. The namespace must not already exist. | | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | .AP "const char" *name in The name of the object to create, or NULL if a new unused name is to be automatically selected. .AP "const char" *nsName in The name of the namespace to create for the object's private use, or NULL if a new unused name is to be automatically selected. The namespace must not already exist. .AP Tcl_Size objc in The number of elements in the \fIobjv\fR array. .AP "Tcl_Obj *const" *objv in The arguments to the command to create the instance of the class. .AP Tcl_Size skip in The number of arguments at the start of the argument array, \fIobjv\fR, that are not arguments to any constructors. This allows the generation of correct error messages even when complicated calling patterns are used (e.g., via the \fBnext\fR command). .AP Tcl_ObjectMetadataType *metaTypePtr in The type of \fImetadata\fR being set with \fBTcl_ClassSetMetadata\fR or retrieved with \fBTcl_ClassGetMetadata\fR. |
| ︙ | ︙ |
Changes to doc/Concat.3.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 | .nf \fB#include <tcl.h>\fR .sp const char * \fBTcl_Concat\fR(\fIargc, argv\fR) .SH ARGUMENTS .AS "const char *const" argv[] | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | .nf \fB#include <tcl.h>\fR .sp const char * \fBTcl_Concat\fR(\fIargc, argv\fR) .SH ARGUMENTS .AS "const char *const" argv[] .AP Tcl_Size argc in Number of strings. .AP "const char *const" argv[] in Array of strings to concatenate. Must have \fIargc\fR entries. .BE .SH DESCRIPTION .PP |
| ︙ | ︙ |
Changes to doc/CrtAlias.3.
| ︙ | ︙ | |||
65 66 67 68 69 70 71 | below). .AP "const char" *childCmd 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 Name of target command for alias in \fItargetInterp\fR. | | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | below). .AP "const char" *childCmd 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 Name of target command for alias in \fItargetInterp\fR. .AP Tcl_Size argc in Count of additional arguments to pass to the alias command. .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 Tcl_Size objc in Count of additional value arguments to pass to the aliased command. .AP Tcl_Obj **objv in Vector of Tcl_Obj structures, the additional value arguments to pass to the aliased 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 |
| ︙ | ︙ |
Changes to doc/CrtChannel.3.
| ︙ | ︙ | |||
137 138 139 140 141 142 143 | The channel to operate on. .AP int direction in \fBTCL_READABLE\fR means the input handle is wanted; \fBTCL_WRITABLE\fR means the output handle is wanted. .AP void **handlePtr out Points to the location where the desired OS-specific handle should be stored. | | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | The channel to operate on. .AP int direction in \fBTCL_READABLE\fR means the input handle is wanted; \fBTCL_WRITABLE\fR means the output handle is wanted. .AP void **handlePtr out Points to the location where the desired OS-specific handle should be stored. .AP Tcl_Size size in The size, in bytes, of buffers to allocate in this channel. .AP int mask in An OR-ed combination of \fBTCL_READABLE\fR, \fBTCL_WRITABLE\fR and \fBTCL_EXCEPTION\fR that indicates events that have occurred on this channel. .AP Tcl_Interp *interp in Current interpreter. (can be NULL) |
| ︙ | ︙ |
Changes to doc/CrtObjCmd.3.
| ︙ | ︙ | |||
183 184 185 186 187 188 189 |
\fBTcl_CreateObjCommand2\fR does the same as \fBTcl_CreateObjCommand\fR,
except its \fIproc2\fR argument is of type \fBTcl_ObjCmdProc2\fR.
.PP
.CS
typedef int \fBTcl_ObjCmdProc2\fR(
void *\fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
| | | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
\fBTcl_CreateObjCommand2\fR does the same as \fBTcl_CreateObjCommand\fR,
except its \fIproc2\fR argument is of type \fBTcl_ObjCmdProc2\fR.
.PP
.CS
typedef int \fBTcl_ObjCmdProc2\fR(
void *\fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
ptrdiff_t \fIobjc\fR,
Tcl_Obj *const \fIobjv\fR[]);
.CE
.PP
\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 is not bound as a command in \fIinterp\fR then
|
| ︙ | ︙ |
Changes to doc/CrtTrace.3.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 | \fBTcl_CreateObjTrace2\fR(\fIinterp, level, flags, objProc2, clientData, deleteProc\fR) .sp \fBTcl_DeleteTrace\fR(\fIinterp, trace\fR) .SH ARGUMENTS .AS Tcl_CmdObjTraceDeleteProc *deleteProc .AP Tcl_Interp *interp in Interpreter containing command to be traced or untraced. | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | \fBTcl_CreateObjTrace2\fR(\fIinterp, level, flags, objProc2, clientData, deleteProc\fR) .sp \fBTcl_DeleteTrace\fR(\fIinterp, trace\fR) .SH ARGUMENTS .AS Tcl_CmdObjTraceDeleteProc *deleteProc .AP Tcl_Interp *interp in Interpreter containing command to be traced or untraced. .AP Tcl_Size level in Only commands at or below this nesting level will be traced unless 0 is specified. 1 means top-level commands only, 2 means top-level commands or those that are invoked as immediate consequences of executing top-level commands (procedure bodies, bracketed commands, etc.) and so on. A value of 0 means that commands at any level are traced. .AP int flags in |
| ︙ | ︙ | |||
84 85 86 87 88 89 90 |
\fIobjProc2\fR should have arguments and result that match the type,
\fBTcl_CmdObjTraceProc2\fR:
.PP
.CS
typedef int \fBTcl_CmdObjTraceProc2\fR(
\fBvoid *\fR \fIclientData\fR,
\fBTcl_Interp\fR* \fIinterp\fR,
| | | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
\fIobjProc2\fR should have arguments and result that match the type,
\fBTcl_CmdObjTraceProc2\fR:
.PP
.CS
typedef int \fBTcl_CmdObjTraceProc2\fR(
\fBvoid *\fR \fIclientData\fR,
\fBTcl_Interp\fR* \fIinterp\fR,
ptrdiff_t \fIlevel\fR,
const char *\fIcommand\fR,
\fBTcl_Command\fR \fIcommandToken\fR,
ptrdiff_t \fIobjc\fR,
\fBTcl_Obj\fR *const \fIobjv\fR[]);
.CE
.PP
The \fIclientData\fR and \fIinterp\fR parameters are copies of the
corresponding arguments given to \fBTcl_CreateTrace\fR.
\fIclientData\fR typically points to an application-specific data
structure that describes what to do when \fIobjProc\fR is invoked. The
|
| ︙ | ︙ |
Changes to doc/DString.3.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | char * \fBTcl_DStringAppendElement\fR(\fIdsPtr, element\fR) .sp \fBTcl_DStringStartSublist\fR(\fIdsPtr\fR) .sp \fBTcl_DStringEndSublist\fR(\fIdsPtr\fR) .sp | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | char * \fBTcl_DStringAppendElement\fR(\fIdsPtr, element\fR) .sp \fBTcl_DStringStartSublist\fR(\fIdsPtr\fR) .sp \fBTcl_DStringEndSublist\fR(\fIdsPtr\fR) .sp Tcl_Size \fBTcl_DStringLength\fR(\fIdsPtr\fR) .sp char * \fBTcl_DStringValue\fR(\fIdsPtr\fR) .sp \fBTcl_DStringSetLength\fR(\fIdsPtr, newLength\fR) .sp |
| ︙ | ︙ | |||
47 48 49 50 51 52 53 | .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" *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. | | | | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | .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" *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 Tcl_Size length in Number of bytes from \fIbytes\fR to add to dynamic string. If negative, add all characters up to null terminating character. .AP Tcl_Size newLength in New length for dynamic string, not including null terminating character. .AP Tcl_Interp *interp in/out Interpreter whose result is to be set from or moved to the dynamic string. .BE |
| ︙ | ︙ | |||
138 139 140 141 142 143 144 | the dynamic string given by \fIdsPtr\fR. It does this by moving a pointer from \fIdsPtr\fR to the interpreter's result. This saves the cost of allocating new memory and copying the string. \fBTcl_DStringResult\fR also reinitializes the dynamic string to an empty string. Since the dynamic string is reinitialized, there is no need to further call \fBTcl_DStringFree\fR on it and it can be reused without | | > | | | < | | | < | > > | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | the dynamic string given by \fIdsPtr\fR. It does this by moving a pointer from \fIdsPtr\fR to the interpreter's result. This saves the cost of allocating new memory and copying the string. \fBTcl_DStringResult\fR also reinitializes the dynamic string to an empty string. Since the dynamic string is reinitialized, there is no need to further call \fBTcl_DStringFree\fR on it and it can be reused without calling \fBTcl_DStringInit\fR. The caller must ensure that the dynamic string stored in \fIdsPtr\fR is encoded in Tcl's internal UTF-8 format. .PP \fBTcl_DStringGetResult\fR does the opposite of \fBTcl_DStringResult\fR. It sets the value of \fIdsPtr\fR to the result of \fIinterp\fR and it clears \fIinterp\fR's result. If possible it does this by moving a pointer rather than by copying the string. .PP \fBTcl_DStringToObj\fR returns a \fBTcl_Obj\fR containing the value of the dynamic string given by \fIdsPtr\fR. It does this by moving a pointer from \fIdsPtr\fR to a newly allocated \fBTcl_Obj\fR and reinitializing to dynamic string to an empty string. This saves the cost of allocating new memory and copying the string. Since the dynamic string is reinitialized, there is no need to further call \fBTcl_DStringFree\fR on it and it can be reused without calling \fBTcl_DStringInit\fR. The returned \fBTcl_Obj\fR has a reference count of 0. The caller must ensure that the dynamic string stored in \fIdsPtr\fR is encoded in Tcl's internal UTF-8 format. .SH KEYWORDS append, dynamic string, free, result |
Changes to doc/DetachPids.3.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | .sp \fBTcl_ReapDetachedProcs\fR() .sp Tcl_Pid \fBTcl_WaitPid\fR(\fIpid, statusPtr, options\fR) .SH ARGUMENTS .AS Tcl_Pid *statusPtr out | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | .sp \fBTcl_ReapDetachedProcs\fR() .sp Tcl_Pid \fBTcl_WaitPid\fR(\fIpid, statusPtr, options\fR) .SH ARGUMENTS .AS Tcl_Pid *statusPtr out .AP Tcl_Size 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 *statusPtr out The result of waiting on a process (pipe). Either 0 or ECHILD. |
| ︙ | ︙ |
Changes to doc/DictObj.3.
| ︙ | ︙ | |||
66 67 68 69 70 71 72 | dictionary value (or sub-value, 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. | | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | dictionary value (or sub-value, 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 "Tcl_Size \&| 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 Tcl_Size 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 values 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 value passed to them. |
| ︙ | ︙ |
Changes to doc/Encoding.3.
1 2 3 4 5 6 7 8 9 10 | '\" '\" Copyright (c) 1997-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. '\" .TH Tcl_GetEncoding 3 "8.1" Tcl "Tcl Library Procedures" .so man.macros .BS .SH NAME | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
'\"
'\" Copyright (c) 1997-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.
'\"
.TH Tcl_GetEncoding 3 "8.1" Tcl "Tcl Library Procedures"
.so man.macros
.BS
.SH NAME
Tcl_GetEncoding, Tcl_FreeEncoding, Tcl_GetEncodingFromObj, Tcl_ExternalToUtfDString, Tcl_ExternalToUtfDStringEx, Tcl_ExternalToUtf, Tcl_UtfToExternalDString, Tcl_UtfToExternalDStringEx, Tcl_UtfToExternal, Tcl_GetEncodingName, Tcl_SetSystemEncoding, Tcl_GetEncodingNameFromEnvironment, Tcl_GetEncodingNames, Tcl_CreateEncoding, Tcl_GetEncodingSearchPath, Tcl_SetEncodingSearchPath \- procedures for creating and using encodings
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
Tcl_Encoding
\fBTcl_GetEncoding\fR(\fIinterp, name\fR)
.sp
void
\fBTcl_FreeEncoding\fR(\fIencoding\fR)
.sp
int
\fBTcl_GetEncodingFromObj\fR(\fIinterp, objPtr, encodingPtr\fR)
.sp
char *
\fBTcl_ExternalToUtfDString\fR(\fIencoding, src, srcLen, dstPtr\fR)
.sp
int
\fBTcl_ExternalToUtfDStringEx\fR(\fIinterp, encoding, src, srcLen, flags, dstPtr, errorIdxPtr\fR)
.sp
char *
\fBTcl_UtfToExternalDString\fR(\fIencoding, src, srcLen, dstPtr\fR)
.sp
int
\fBTcl_UtfToExternalDStringEx\fR(\fIinterp, encoding, src, srcLen, flags, dstPtr, errorIdxPtr\fR)
.sp
int
\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
const char *
\fBTcl_GetEncodingName\fR(\fIencoding\fR)
.sp
Tcl_Size
\fBTcl_GetEncodingNulLength\fR(\fIencoding\fR)
.sp
int
\fBTcl_SetSystemEncoding\fR(\fIinterp, name\fR)
.sp
const char *
\fBTcl_GetEncodingNameFromEnvironment\fR(\fIbufPtr\fR)
|
| ︙ | ︙ | |||
82 83 84 85 86 87 88 | .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 function, an array of UTF-8 characters to be converted to the specified encoding. .AP "const TCHAR" *tsrc in An array of Windows TCHAR characters to convert to UTF-8. | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | .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 function, an array of UTF-8 characters to be converted to the specified encoding. .AP "const TCHAR" *tsrc in An array of Windows TCHAR characters to convert to UTF-8. .AP Tcl_Size srcLen in Length of \fIsrc\fR or \fItsrc\fR in bytes. If the length is negative, the encoding-specific length of the string is used. .AP Tcl_DString *dstPtr out Pointer to an uninitialized or free \fBTcl_DString\fR in which the converted result will be stored. .AP int flags in This is a bit mask passed in to control the operation of the encoding functions. |
| ︙ | ︙ | |||
343 344 345 346 347 348 349 |
.CS
typedef struct Tcl_EncodingType {
const char *\fIencodingName\fR;
Tcl_EncodingConvertProc *\fItoUtfProc\fR;
Tcl_EncodingConvertProc *\fIfromUtfProc\fR;
Tcl_EncodingFreeProc *\fIfreeProc\fR;
void *\fIclientData\fR;
| | | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
.CS
typedef struct Tcl_EncodingType {
const char *\fIencodingName\fR;
Tcl_EncodingConvertProc *\fItoUtfProc\fR;
Tcl_EncodingConvertProc *\fIfromUtfProc\fR;
Tcl_EncodingFreeProc *\fIfreeProc\fR;
void *\fIclientData\fR;
Tcl_Size \fInullSize\fR;
} \fBTcl_EncodingType\fR;
.CE
.PP
The \fIencodingName\fR provides a string name for the encoding, by
which it can be referred in other procedures such as
\fBTcl_GetEncoding\fR. The \fItoUtfProc\fR refers to a callback
procedure to invoke to convert text from this encoding into UTF-8.
|
| ︙ | ︙ |
Changes to doc/Ensemble.3.
| ︙ | ︙ | |||
65 66 67 68 69 70 71 | 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 | | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 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 OR'ed set of flag bits describing the basic configuration of the ensemble. Currently only one bit has meaning, \fBTCL_ENSEMBLE_PREFIX\fR, 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 OR'ed set of flag bits controlling the behavior of \fBTcl_FindEnsemble\fR. Currently only \fBTCL_LEAVE_ERR_MSG\fR 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 \fBTCL_ENSEMBLE_PREFIX\fR is defined. |
| ︙ | ︙ |
Changes to doc/Eval.3.
| ︙ | ︙ | |||
42 43 44 45 46 47 48 | .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. .AP Tcl_Obj *objPtr in A Tcl value containing the script to execute. .AP int flags in | | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | .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. .AP Tcl_Obj *objPtr in A Tcl value containing the script to execute. .AP int flags in OR'ed 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 Name of a file containing a Tcl script. .AP Tcl_Size objc in The number of values in the array pointed to by \fIobjv\fR; this is also the number of words in the command. .AP Tcl_Obj **objv in Points to an array of pointers to values; each value holds the value of a single word in the command to execute. .AP int numBytes in The number of bytes in \fIscript\fR, not including any |
| ︙ | ︙ | |||
97 98 99 100 101 102 103 | (^Z) for all platforms. If you require a .QW ^Z in code for string comparison, you can use .QW \ex1A , which will be safely substituted by the Tcl interpreter into .QW ^Z . .PP | | | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | (^Z) for all platforms. If you require a .QW ^Z in code for string comparison, you can use .QW \ex1A , which will be safely substituted by the Tcl interpreter into .QW ^Z . .PP \fBTcl_EvalObjv\fR executes a single preparsed 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 value 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 values are valid until \fBTcl_EvalObjv\fR returns. |
| ︙ | ︙ | |||
138 139 140 141 142 143 144 | It returns the result of the command and also modifies the interpreter result in the same way as \fBTcl_Eval\fR. The last argument to \fBTcl_VarEval\fR must be NULL to indicate the end of arguments. \fBTcl_VarEval\fR is now deprecated. .SH "FLAG BITS" .PP | | | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | It returns the result of the command and also modifies the interpreter result in the same way as \fBTcl_Eval\fR. The last argument to \fBTcl_VarEval\fR must be NULL to indicate the end of arguments. \fBTcl_VarEval\fR is now deprecated. .SH "FLAG BITS" .PP Any OR'ed combination of the following values may be used for the \fIflags\fR argument to procedures such as \fBTcl_EvalObjEx\fR: .TP 23 \fBTCL_EVAL_DIRECT\fR . This flag is only used by \fBTcl_EvalObjEx\fR; it is ignored by other procedures. If this flag bit is set, the script is not compiled to bytecodes; instead it is executed directly |
| ︙ | ︙ |
Changes to doc/FileSystem.3.
| ︙ | ︙ | |||
216 217 218 219 220 221 222 | The first of two path values to compare. The value may be converted to \fBpath\fR type. .AP Tcl_Obj *secondPtr in The second of two path values to compare. The value may be converted to \fBpath\fR type. .AP Tcl_Obj *listObj in The list of path elements to operate on with a \fBjoin\fR operation. | | | | | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | The first of two path values to compare. The value may be converted to \fBpath\fR type. .AP Tcl_Obj *secondPtr in The second of two path values to compare. The value may be converted to \fBpath\fR type. .AP Tcl_Obj *listObj in The list of path elements to operate on with a \fBjoin\fR operation. .AP Tcl_Size elements in The number of elements in the \fIlistObj\fR which should be joined together. If negative, then all elements are joined. .AP Tcl_Obj **errorPtr out In the case of an error, filled with a value containing the name of the file which caused an error in the various copy/rename operations. .AP int index in The index of the attribute in question. .AP Tcl_Obj *objPtr in The value to set in the operation. .AP Tcl_Obj **objPtrRef out Filled with a value containing the result of the operation. .AP Tcl_Obj *resultPtr out Preallocated value in which to store (using \fBTcl_ListObjAppendElement\fR) the list of files or directories which are successfully matched. .AP int mode in Mask consisting of one or more of R_OK, W_OK, X_OK and F_OK. R_OK, W_OK and X_OK request checking whether the file exists and has read, write and execute permissions, respectively. F_OK just requests checking for the existence of the file. |
| ︙ | ︙ | |||
265 266 267 268 269 270 271 | used to set those values for a given file. .AP "const char" *modeString 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 POSIX-style permission flags such as 0644. If a new file is created, these permissions will be set on the created file. | | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | used to set those values for a given file. .AP "const char" *modeString 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 POSIX-style permission flags such as 0644. If a new file is created, these permissions will be set on the created file. .AP "Tcl_Size \&| int" *lenPtr out If non-NULL, filled with the number of elements in the split path. .AP Tcl_Obj *basePtr in The base path on to which to join the given elements. May be NULL. .AP Tcl_Size objc in The number of elements in \fIobjv\fR. .AP "Tcl_Obj *const" objv[] in The elements to join to the given base path. .AP Tcl_Obj *linkNamePtr in The name of the link to be created or read. .AP Tcl_Obj *toPtr in What the link called \fIlinkNamePtr\fR should be linked to, or NULL if |
| ︙ | ︙ | |||
479 480 481 482 483 484 485 | .QW "read link" action is performed. The result is a Tcl_Obj specifying the contents of the symbolic link given by \fIlinkNamePtr\fR, or NULL if the link could not be read. The result is owned by the caller, which should call \fBTcl_DecrRefCount\fR when the result is no longer needed. If the \fItoPtr\fR is not NULL, Tcl should create a link of one of the types passed in in the \fIlinkAction\fR flag. This flag is | | | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | .QW "read link" action is performed. The result is a Tcl_Obj specifying the contents of the symbolic link given by \fIlinkNamePtr\fR, or NULL if the link could not be read. The result is owned by the caller, which should call \fBTcl_DecrRefCount\fR when the result is no longer needed. If the \fItoPtr\fR is not NULL, Tcl should create a link of one of the types passed in in the \fIlinkAction\fR flag. This flag is an OR'ed combination of \fBTCL_CREATE_SYMBOLIC_LINK\fR and \fBTCL_CREATE_HARD_LINK\fR. Where a choice exists (i.e.\ more than one flag is passed in), the Tcl convention is to prefer symbolic links. When a link is successfully created, the return value should be \fItoPtr\fR (which is therefore already owned by the caller). If unsuccessful, NULL is returned. .PP \fBTcl_FSLstat\fR fills the \fITcl_StatBuf\fR structure \fIstatPtr\fR with information about the specified file. You do not need any access rights to the |
| ︙ | ︙ | |||
674 675 676 677 678 679 680 | passed into this function (\fIpathPtr\fR or \fIpath\fR elements) have a reference count of zero, they will be freed when this function returns. .PP \fBTcl_FSConvertToPathType\fR tries to convert the given Tcl_Obj to a valid Tcl path type, taking account of the fact that the cwd may have changed even if this value is already supposedly of the correct type. | < < < < < | 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | passed into this function (\fIpathPtr\fR or \fIpath\fR elements) have a reference count of zero, they will be freed when this function returns. .PP \fBTcl_FSConvertToPathType\fR tries to convert the given Tcl_Obj to a valid Tcl path type, taking account of the fact that the cwd may have changed even if this value is already supposedly of the correct type. .PP If the conversion succeeds (i.e.\ the value is a valid path in one of the current filesystems), then \fBTCL_OK\fR is returned. Otherwise \fBTCL_ERROR\fR is returned, and an error message may be left in the interpreter. .PP \fBTcl_FSGetInternalRep\fR extracts the internal representation of a given |
| ︙ | ︙ | |||
700 701 702 703 704 705 706 | not require additional conversions. .PP \fBTcl_FSGetTranslatedPath\fR attempts to extract the translated path from the given Tcl_Obj. .PP If the translation succeeds (i.e.\ the value is a valid path), then it is returned. Otherwise NULL will be returned, and an error message may be | | < < < < < < < | 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | not require additional conversions. .PP \fBTcl_FSGetTranslatedPath\fR attempts to extract the translated path from the given Tcl_Obj. .PP If the translation succeeds (i.e.\ the value is a valid path), then it is returned. Otherwise NULL will be returned, and an error message may be left in the interpreter. The value returned is owned by the caller, which must store it or call \fBTcl_DecrRefCount\fR to ensure memory is freed. This function is of little practical use, and \fBTcl_FSGetNormalizedPath\fR or \fBTcl_FSGetNativePath\fR are usually better functions to use for most purposes. .PP \fBTcl_FSGetTranslatedStringPath\fR does the same as \fBTcl_FSGetTranslatedPath\fR, but returns a character string or NULL. |
| ︙ | ︙ | |||
846 847 848 849 850 851 852 |
.SS "THE TCL_FILESYSTEM STRUCTURE"
.PP
The \fBTcl_Filesystem\fR structure contains the following fields:
.PP
.CS
typedef struct Tcl_Filesystem {
const char *\fItypeName\fR;
| | | 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 |
.SS "THE TCL_FILESYSTEM STRUCTURE"
.PP
The \fBTcl_Filesystem\fR structure contains the following fields:
.PP
.CS
typedef struct Tcl_Filesystem {
const char *\fItypeName\fR;
Tcl_Size \fIstructureLength\fR;
Tcl_FSVersion \fIversion\fR;
Tcl_FSPathInFilesystemProc *\fIpathInFilesystemProc\fR;
Tcl_FSDupInternalRepProc *\fIdupInternalRepProc\fR;
Tcl_FSFreeInternalRepProc *\fIfreeInternalRepProc\fR;
Tcl_FSInternalToNormalizedProc *\fIinternalToNormalizedProc\fR;
Tcl_FSCreateInternalRepProc *\fIcreateInternalRepProc\fR;
Tcl_FSNormalizePathProc *\fInormalizePathProc\fR;
|
| ︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | path value. In Tcl, every .QW path must have a single unique .QW normalized string representation. Depending on the filesystem, there may be more than one unnormalized string representation which refers to that path (e.g.\ a relative path, a path with different | | < < | 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | path value. In Tcl, every .QW path must have a single unique .QW normalized string representation. Depending on the filesystem, there may be more than one unnormalized string representation which refers to that path (e.g.\ a relative path, a path with different character case if the filesystem is case insensitive, a path containing symbolic links, etc). If the very last component in the path is a symbolic link, it should not be converted into the value it points to (but its case or other aspects should be made unique). All other path components should be converted from symbolic links. This one exception is required to agree with Tcl's semantics with \fBfile delete\fR, \fBfile rename\fR, \fBfile copy\fR operating on symbolic links. |
| ︙ | ︙ |
Changes to doc/IntObj.3.
| ︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | .sp int \fBTcl_GetWideIntFromObj\fR(\fIinterp, objPtr, widePtr\fR) .sp int \fBTcl_GetWideUIntFromObj\fR(\fIinterp, objPtr, uwidePtr\fR) .sp .sp \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) .SH ARGUMENTS .AS Tcl_WideInt doubleValue in/out | > > > | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | .sp int \fBTcl_GetWideIntFromObj\fR(\fIinterp, objPtr, widePtr\fR) .sp int \fBTcl_GetWideUIntFromObj\fR(\fIinterp, objPtr, uwidePtr\fR) .sp int \fBTcl_GetSizeIntFromObj\fR(\fIinterp, objPtr, sizePtr\fR) .sp .sp \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) .SH ARGUMENTS .AS Tcl_WideInt doubleValue in/out .AP Tcl_Size endValue in \fBTcl_GetIntForIndex\fR will return this when the input value is "end". .AP int intValue in Integer value used to initialize or set a Tcl value. .AP long longValue in Long integer value used to initialize or set a Tcl value. .AP Tcl_WideInt wideValue in Wide integer value used to initialize or set a Tcl value. |
| ︙ | ︙ | |||
79 80 81 82 83 84 85 | .AP Tcl_Interp *interp in/out 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 retrieved from \fIobjPtr\fR. .AP long *longPtr out Points to place to store the long integer value retrieved from \fIobjPtr\fR. | | | > > | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | .AP Tcl_Interp *interp in/out 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 retrieved from \fIobjPtr\fR. .AP long *longPtr out Points to place to store the long integer value retrieved from \fIobjPtr\fR. .AP Tcl_Size *indexPtr out Points to place to store the Tcl_Size value retrieved from \fIobjPtr\fR. .AP Tcl_WideInt *widePtr out Points to place to store the wide integer value retrieved from \fIobjPtr\fR. .AP Tcl_WideUInt *uwidePtr out Points to place to store the unsigned wide integer value retrieved from \fIobjPtr\fR. .AP Tcl_Size *sizePtr out Points to place to store the \fBTcl_Size\fR integer value retrieved from \fIobjPtr\fR. .AP mp_int *bigValue in/out Points to a multi-precision integer structure declared by the LibTomMath library. .AP double doubleValue in Double value from which the integer part is determined and used to initialize a multi-precision integer value. .BE |
| ︙ | ︙ | |||
134 135 136 137 138 139 140 | \fIobjPtr\fR does not hold an index value. 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. .PP The \fBTcl_GetIntFromObj\fR, \fBTcl_GetLongFromObj\fR, | | > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | \fIobjPtr\fR does not hold an index value. 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. .PP The \fBTcl_GetIntFromObj\fR, \fBTcl_GetLongFromObj\fR, \fBTcl_GetWideIntFromObj\fR, \fBTcl_GetSizeIntFromObj\fR, \fBTcl_GetBignumFromObj\fR, and \fBTcl_TakeBignumFromObj\fR routines attempt to retrieve an integral value of the appropriate type from the Tcl value \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, |
| ︙ | ︙ |
Changes to doc/Limit.3.
| ︙ | ︙ | |||
61 62 63 64 65 66 67 | .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. | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | .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 Tcl_Size 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 |
| ︙ | ︙ |
Changes to doc/LinkVar.3.
| ︙ | ︙ | |||
55 56 57 58 59 60 61 | In \fBTcl_LinkArray\fR, the additional linked types \fBTCL_LINK_CHARS\fR and \fBTCL_LINK_BINARY\fR may be used. .VE "TIP 312" .sp All the above for both functions may be optionally OR'ed with \fBTCL_LINK_READ_ONLY\fR to make the Tcl variable read-only. | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | In \fBTcl_LinkArray\fR, the additional linked types \fBTCL_LINK_CHARS\fR and \fBTCL_LINK_BINARY\fR may be used. .VE "TIP 312" .sp All the above for both functions may be optionally OR'ed with \fBTCL_LINK_READ_ONLY\fR to make the Tcl variable read-only. .AP Tcl_Size size in .VS "TIP 312" The number of elements in the C array. Must be greater than zero. .VE "TIP 312" .BE .SH DESCRIPTION .PP \fBTcl_LinkVar\fR uses variable traces to keep the Tcl variable |
| ︙ | ︙ |
Changes to doc/ListObj.3.
| ︙ | ︙ | |||
55 56 57 58 59 60 61 | an attempt will be made to convert it to one. .AP Tcl_Obj *objPtr in For \fBTcl_ListObjAppendElement\fR, points to the Tcl value that will be appended to \fIlistPtr\fR. For \fBTcl_SetListObj\fR, this points to the Tcl value that will be converted to a list value containing the \fIobjc\fR elements of the array referenced by \fIobjv\fR. | | | | | | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | an attempt will be made to convert it to one. .AP Tcl_Obj *objPtr in For \fBTcl_ListObjAppendElement\fR, points to the Tcl value that will be appended to \fIlistPtr\fR. For \fBTcl_SetListObj\fR, this points to the Tcl value that will be converted to a list value containing the \fIobjc\fR elements of the array referenced by \fIobjv\fR. .AP "Tcl_Size \&| int" *objcPtr in Points to location where \fBTcl_ListObjGetElements\fR stores the number of element values in \fIlistPtr\fR. .AP Tcl_Obj ***objvPtr out A location where \fBTcl_ListObjGetElements\fR stores a pointer to an array of pointers to the element values of \fIlistPtr\fR. .AP Tcl_Size objc in The number of Tcl values that \fBTcl_NewListObj\fR will insert into a new list value, and \fBTcl_ListObjReplace\fR will insert into \fIlistPtr\fR. For \fBTcl_SetListObj\fR, the number of Tcl values to insert into \fIobjPtr\fR. .AP "Tcl_Obj *const" objv[] in An array of pointers to values. \fBTcl_NewListObj\fR will insert these values into a new list value and \fBTcl_ListObjReplace\fR will insert them into an existing \fIlistPtr\fR. Each value will become a separate list element. .AP "Tcl_Size \&| int" *lengthPtr out Points to location where \fBTcl_ListObjLength\fR stores the length of the list. .AP Tcl_Size index in Index of the list element that \fBTcl_ListObjIndex\fR is to return. The first element has index 0. .AP Tcl_Obj **objPtrPtr out Points to place where \fBTcl_ListObjIndex\fR is to store a pointer to the resulting list element value. .AP Tcl_Size first in Index of the starting list element that \fBTcl_ListObjReplace\fR is to replace. The list's first element has index 0. .AP Tcl_Size count in The number of elements that \fBTcl_ListObjReplace\fR is to replace. .BE .SH DESCRIPTION .PP Tcl list values have an internal representation that supports |
| ︙ | ︙ | |||
180 181 182 183 184 185 186 | in the address \fIobjPtrPtr\fR. If \fIlistPtr\fR does not already refer to a list value, \fBTcl_ListObjIndex\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 value if \fIinterp\fR is not NULL. If the index is out of range, | | | | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | in the address \fIobjPtrPtr\fR. If \fIlistPtr\fR does not already refer to a list value, \fBTcl_ListObjIndex\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 value if \fIinterp\fR is not NULL. If the index is out of range, that is, \fIindex\fR is negative or greater than or equal to the number of elements in the list, \fBTcl_ListObjIndex\fR stores a NULL in \fIobjPtrPtr\fR and returns \fBTCL_OK\fR. Otherwise it returns \fBTCL_OK\fR after storing the element's value pointer. The reference count for the list element is not incremented; the caller must do that if it needs to retain a pointer to the element. .PP \fBTcl_ListObjReplace\fR replaces zero or more elements of the list referenced by \fIlistPtr\fR with the \fIobjc\fR values in the array referenced by \fIobjv\fR. If \fIlistPtr\fR does not point to a list value, \fBTcl_ListObjReplace\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 value if \fIinterp\fR is not NULL. Otherwise, it returns \fBTCL_OK\fR after replacing the values. If \fIobjv\fR is NULL, no new elements are added. If the argument \fIfirst\fR is zero or negative, it refers to the first element. If \fIfirst\fR is greater than or equal to the number of elements in the list, then no elements are deleted; the new elements are appended to the list. \fIcount\fR gives the number of elements to replace. If \fIcount\fR is zero or negative then no elements are deleted; the new elements are simply inserted before the one designated by \fIfirst\fR. \fBTcl_ListObjReplace\fR invalidates \fIlistPtr\fR's old string representation. The reference counts of any elements inserted from \fIobjv\fR are incremented since the resulting list now refers to them. Similarly, the reference counts for any replaced values are decremented. |
| ︙ | ︙ |
Changes to doc/Method.3.
| ︙ | ︙ | |||
54 55 56 57 58 59 60 | .sp Tcl_Method \fBTcl_ObjectContextMethod\fR(\fIcontext\fR) .sp Tcl_Object \fBTcl_ObjectContextObject\fR(\fIcontext\fR) .sp | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | .sp Tcl_Method \fBTcl_ObjectContextMethod\fR(\fIcontext\fR) .sp Tcl_Object \fBTcl_ObjectContextObject\fR(\fIcontext\fR) .sp Tcl_Size \fBTcl_ObjectContextSkippedArgs\fR(\fIcontext\fR) .SH ARGUMENTS .AS void *clientData in .AP Tcl_Interp *interp in/out The interpreter holding the object or class to create or update a method in. .AP Tcl_Object object in The object to create the method in. |
| ︙ | ︙ | |||
91 92 93 94 95 96 97 | when the method was created. If NULL, the \fIclientData\fR value will not be retrieved. .AP Tcl_Method method in A reference to a method to query. .AP Tcl_ObjectContext context in A reference to a method-call context. Note that client code \fImust not\fR retain a reference to a context. | | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | when the method was created. If NULL, the \fIclientData\fR value will not be retrieved. .AP Tcl_Method method in A reference to a method to query. .AP Tcl_ObjectContext context in A reference to a method-call context. Note that client code \fImust not\fR retain a reference to a context. .AP Tcl_Size objc in The number of arguments to pass to the method implementation. .AP "Tcl_Obj *const" *objv in An array of arguments to pass to the method implementation. .AP Tcl_Size skip in The number of arguments passed to the method implementation that do not represent "real" arguments. .BE .SH DESCRIPTION .PP A method is an operation carried out on an object that is associated with the object. Every method must be attached to either an object or a class; methods |
| ︙ | ︙ |
Changes to doc/NRE.3.
| ︙ | ︙ | |||
65 66 67 68 69 70 71 | Called instead of \fIproc2\fR when a trampoline is already in use. .AP void *clientData in Arbitrary one-word value passed to \fIproc\fR, \fInreProc\fR, \fIdeleteProc\fR and \fIobjProc\fR. .AP Tcl_CmdDeleteProc *deleteProc in/out Called before \fIcmdName\fR is deleted from the interpreter, allowing for command-specific cleanup. May be NULL. | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | Called instead of \fIproc2\fR when a trampoline is already in use. .AP void *clientData in Arbitrary one-word value passed to \fIproc\fR, \fInreProc\fR, \fIdeleteProc\fR and \fIobjProc\fR. .AP Tcl_CmdDeleteProc *deleteProc in/out Called before \fIcmdName\fR is deleted from the interpreter, allowing for command-specific cleanup. May be NULL. .AP Tcl_Size objc in Number of items in \fIobjv\fR. .AP Tcl_Obj **objv in Words in the command. .AP Tcl_Obj *objPtr in A script or expression to evaluate. .AP int flags in As described for \fITcl_EvalObjv\fR. |
| ︙ | ︙ |
Changes to doc/Number.3.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 | .SH ARGUMENTS .AS Tcl_Interp clientDataPtr out .AP Tcl_Interp *interp out When non-NULL, error information is recorded here when the value is not in any of the numeric formats recognized by Tcl. .AP "const char" *bytes in Points to first byte of the string value to be examined. | | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | .SH ARGUMENTS .AS Tcl_Interp clientDataPtr out .AP Tcl_Interp *interp out When non-NULL, error information is recorded here when the value is not in any of the numeric formats recognized by Tcl. .AP "const char" *bytes in Points to first byte of the string value to be examined. .AP Tcl_Size numBytes in The number of bytes, starting at \fIbytes\fR, that should be examined. If \fBnumBytes\fR is negative, then all bytes should be examined until the first \fBNUL\fR byte terminates examination. .AP "void *" *clientDataPtr out Points to space where a pointer value may be written through which a numeric value is available to read. .AP int *typePtr out Points to space where a value may be written reporting what type of numeric storage is available to read. |
| ︙ | ︙ | |||
59 60 61 62 63 64 65 | multiple-precision integer library, included with Tcl. .PP The routines \fBTcl_GetNumber\fR and \fBTcl_GetNumberFromObj\fR perform the same function. They differ only in how the arguments present the Tcl value to be examined. \fBTcl_GetNumber\fR accepts a counted string value in the arguments \fIbytes\fR and \fInumBytes\fR (or a \fBNUL\fR-terminated string value when \fInumBytes\fR is | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | multiple-precision integer library, included with Tcl. .PP The routines \fBTcl_GetNumber\fR and \fBTcl_GetNumberFromObj\fR perform the same function. They differ only in how the arguments present the Tcl value to be examined. \fBTcl_GetNumber\fR accepts a counted string value in the arguments \fIbytes\fR and \fInumBytes\fR (or a \fBNUL\fR-terminated string value when \fInumBytes\fR is negative). \fBTcl_GetNumberFromObj\fR accepts the Tcl value in \fIobjPtr\fR. .PP Both routines examine the Tcl value and determine whether Tcl recognizes it as a number. If not, both routines return \fBTCL_ERROR\fR and (when \fIinterp\fR is not NULL) record an error message and error code in \fIinterp\fR. .PP |
| ︙ | ︙ |
Changes to doc/Object.3.
| ︙ | ︙ | |||
107 108 109 110 111 112 113 |
.SH "THE TCL_OBJ STRUCTURE"
.PP
Each Tcl value is represented by a \fBTcl_Obj\fR structure
which is defined as follows.
.PP
.CS
typedef struct Tcl_Obj {
| | | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
.SH "THE TCL_OBJ STRUCTURE"
.PP
Each Tcl value is represented by a \fBTcl_Obj\fR structure
which is defined as follows.
.PP
.CS
typedef struct Tcl_Obj {
Tcl_Size \fIrefCount\fR;
char *\fIbytes\fR;
Tcl_Size \fIlength\fR;
const Tcl_ObjType *\fItypePtr\fR;
union {
long \fIlongValue\fR;
double \fIdoubleValue\fR;
void *\fIotherValuePtr\fR;
Tcl_WideInt \fIwideValue\fR;
struct {
|
| ︙ | ︙ |
Changes to doc/OpenFileChnl.3.
| ︙ | ︙ | |||
49 50 51 52 53 54 55 | .sp int \fBTcl_ReadChars\fR(\fIchannel, readObjPtr, charsToRead, appendFlag\fR) .sp int \fBTcl_Read\fR(\fIchannel, readBuf, bytesToRead\fR) .sp | | | | | | | | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | .sp int \fBTcl_ReadChars\fR(\fIchannel, readObjPtr, charsToRead, appendFlag\fR) .sp int \fBTcl_Read\fR(\fIchannel, readBuf, bytesToRead\fR) .sp Tcl_Size \fBTcl_GetsObj\fR(\fIchannel, lineObjPtr\fR) .sp Tcl_Size \fBTcl_Gets\fR(\fIchannel, lineRead\fR) .sp Tcl_Size \fBTcl_Ungets\fR(\fIchannel, input, inputLen, addAtEnd\fR) .sp Tcl_Size \fBTcl_WriteObj\fR(\fIchannel, writeObjPtr\fR) .sp Tcl_Size \fBTcl_WriteChars\fR(\fIchannel, charBuf, bytesToWrite\fR) .sp Tcl_Size \fBTcl_Write\fR(\fIchannel, byteBuf, bytesToWrite\fR) .sp Tcl_Size \fBTcl_ReadRaw\fR(\fIchannel, readBuf, bytesToRead\fR) .sp Tcl_Size \fBTcl_WriteRaw\fR(\fIchannel, byteBuf, bytesToWrite\fR) .sp int \fBTcl_Eof\fR(\fIchannel\fR) .sp int \fBTcl_Flush\fR(\fIchannel\fR) |
| ︙ | ︙ | |||
115 116 117 118 119 120 121 | The name of a local or network file. .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 POSIX-style permission flags such as 0644. If a new file is created, these permissions will be set on the created file. | | | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | The name of a local or network file. .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 POSIX-style permission flags such as 0644. If a new file is created, these permissions will be set on the created file. .AP Tcl_Size argc in The number of elements in \fIargv\fR. .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 Specifies the disposition of the stdio handles in pipeline: OR-ed combination of \fBTCL_STDIN\fR, \fBTCL_STDOUT\fR, \fBTCL_STDERR\fR, and |
| ︙ | ︙ | |||
150 151 152 153 154 155 156 | The pattern to match on, passed to Tcl_StringMatch, or NULL. .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. .AP Tcl_Obj *readObjPtr in/out A pointer to a Tcl value in which to store the characters read from the channel. | | | | | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | The pattern to match on, passed to Tcl_StringMatch, or NULL. .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. .AP Tcl_Obj *readObjPtr in/out A pointer to a Tcl value in which to store the characters read from the channel. .AP Tcl_Size charsToRead in The number of characters to read from the channel. If the channel's encoding is \fBbinary\fR, this is equivalent to the number of bytes to read from the channel. .AP int appendFlag in If non-zero, data read from the channel will be appended to the value. Otherwise, the data will replace the existing contents of the value. .AP char *readBuf out A buffer in which to store the bytes read from the channel. .AP Tcl_Size bytesToRead in The number of bytes to read from the channel. The buffer \fIreadBuf\fR must be large enough to hold this many bytes. .AP Tcl_Obj *lineObjPtr in/out A pointer to a Tcl value in which to store the line read from the channel. The line read will be appended to the current value of the value. .AP Tcl_DString *lineRead in/out 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. .AP "const char" *input in The input to add to a channel buffer. .AP Tcl_Size 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. .AP Tcl_Obj *writeObjPtr in A pointer to a Tcl value whose contents will be output to the channel. .AP "const char" *charBuf in A buffer containing the characters to output to the channel. .AP "const char" *byteBuf in A buffer containing the bytes to output to the channel. .AP Tcl_Size bytesToWrite in The number of bytes to consume from \fIcharBuf\fR or \fIbyteBuf\fR and output to the channel. .AP "long long" 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 given by \fIseekMode\fR. May be either positive or negative. .AP int seekMode in |
| ︙ | ︙ | |||
402 403 404 405 406 407 408 | .SH "TCL_READCHARS AND TCL_READ" .PP \fBTcl_ReadChars\fR consumes bytes from \fIchannel\fR, converting the bytes to UTF-8 based on the channel's encoding and storing the produced data in \fIreadObjPtr\fR's string representation. The return value of \fBTcl_ReadChars\fR is the number of characters, up to \fIcharsToRead\fR, that were stored in \fIreadObjPtr\fR. If an error occurs while reading, the | | | | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | .SH "TCL_READCHARS AND TCL_READ" .PP \fBTcl_ReadChars\fR consumes bytes from \fIchannel\fR, converting the bytes to UTF-8 based on the channel's encoding and storing the produced data in \fIreadObjPtr\fR's string representation. The return value of \fBTcl_ReadChars\fR is the number of characters, up to \fIcharsToRead\fR, 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 -1 will cause the command to read all characters currently available (non-blocking) or everything until eof (blocking mode). .PP The return value may be smaller than the value to read, indicating that less data than requested was available. This is called a \fIshort read\fR. In blocking mode, this can only happen on an end-of-file. In nonblocking mode, a short read can also occur if there is not enough input currently |
| ︙ | ︙ | |||
467 468 469 470 471 472 473 | channel is treated as an individual Unicode character. All of the characters of the line except for the terminating end-of-line character(s) are appended to \fIlineObjPtr\fR's string representation. The end-of-line character(s) are read and discarded. .PP If a line was successfully read, the return value is greater than or equal to zero and indicates the number of bytes stored in \fIlineObjPtr\fR. If an | | | | | | | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | channel is treated as an individual Unicode character. All of the characters of the line except for the terminating end-of-line character(s) are appended to \fIlineObjPtr\fR's string representation. The end-of-line character(s) are read and discarded. .PP If a line was successfully read, the return value is greater than or equal to zero and indicates the number of bytes stored in \fIlineObjPtr\fR. If an error occurs, \fBTcl_GetsObj\fR returns -1 and records a POSIX error code that can be retrieved with \fBTcl_GetErrno\fR. \fBTcl_GetsObj\fR also returns -1 if the end of the file is reached; the \fBTcl_Eof\fR procedure can be used to distinguish an error from an end-of-file condition. .PP If the channel is in nonblocking mode, the return value can also be -1 if no data was available or the data that was available did not contain an end-of-line character. When -1 is returned, the \fBTcl_InputBlocked\fR procedure may be invoked to determine if the channel is blocked because of input unavailability. .PP \fBTcl_Gets\fR is the same as \fBTcl_GetsObj\fR except the resulting characters are appended to the dynamic string given by \fIlineRead\fR rather than a Tcl value. .SH "TCL_UNGETS" .PP \fBTcl_Ungets\fR is used to add data to the input queue of a channel, 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 .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. .SH "TCL_WRITECHARS, TCL_WRITEOBJ, AND TCL_WRITE" .PP \fBTcl_WriteChars\fR accepts \fIbytesToWrite\fR bytes of character data at \fIcharBuf\fR. The UTF-8 characters in the buffer are converted to the channel's encoding and queued for output to \fIchannel\fR. If \fIbytesToWrite\fR is negative, \fBTcl_WriteChars\fR expects \fIcharBuf\fR to be null-terminated and it outputs everything up to the null. .PP Data queued for output may not appear on the output device immediately, due to internal buffering. If the data should appear immediately, call \fBTcl_Flush\fR after the call to \fBTcl_WriteChars\fR, or set the \fB\-buffering\fR option on the channel to \fBnone\fR. If you wish the data to appear as soon as a complete line is accepted for output, set the \fB\-buffering\fR option on the channel to \fBline\fR mode. .PP The return value of \fBTcl_WriteChars\fR is a count of how many bytes were accepted for output to the channel. This is either -1 to indicate that an error occurred or another number greater than zero to indicate success. If an error occurs, \fBTcl_WriteChars\fR records a POSIX error code that may be retrieved with \fBTcl_GetErrno\fR. .PP Newline characters in the output data are translated to platform-specific end-of-line sequences according to the \fB\-translation\fR option for the channel. This is done even if the channel has no encoding. |
| ︙ | ︙ | |||
595 596 597 598 599 600 601 | \fIoptionName\fR is NULL, the function stores an alternating list of option names and their values in \fIoptionValue\fR, using a series of calls to \fBTcl_DStringAppendElement\fR. The various preexisting options and their possible values are described in the manual entry for the Tcl \fBfconfigure\fR command. Other options can be added by each channel type. These channel type specific options are described in the manual entry for the Tcl command that creates a channel of that type; for example, the | | | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | \fIoptionName\fR is NULL, the function stores an alternating list of option names and their values in \fIoptionValue\fR, using a series of calls to \fBTcl_DStringAppendElement\fR. The various preexisting options and their possible values are described in the manual entry for the Tcl \fBfconfigure\fR command. Other options can be added by each channel type. These channel type specific options are described in the manual entry for the Tcl command that creates a channel of that type; for example, the additional options for TCP-based channels are described in the manual entry for the Tcl \fBsocket\fR command. The procedure normally returns \fBTCL_OK\fR. If an error occurs, it returns \fBTCL_ERROR\fR and calls \fBTcl_SetErrno\fR to store an appropriate POSIX error code. .SH TCL_SETCHANNELOPTION .PP \fBTcl_SetChannelOption\fR sets a new value \fInewValue\fR |
| ︙ | ︙ |
Changes to doc/Panic.3.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 | .sp .SH ARGUMENTS .AS Tcl_PanicProc *panicProc .AP "const char*" format in A printf-style format string. .AP "" arg in Arguments matching the format string. | < < < < | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | .sp .SH ARGUMENTS .AS Tcl_PanicProc *panicProc .AP "const char*" format in A printf-style format string. .AP "" arg in Arguments matching the format string. .AP Tcl_PanicProc *panicProc in Procedure to report fatal error message and abort. .BE .SH DESCRIPTION .PP When the Tcl library detects that its internal data structures are in an inconsistent state, or that its C procedures have been called in a |
| ︙ | ︙ |
Changes to doc/ParseArgs.3.
| ︙ | ︙ | |||
17 18 19 20 21 22 23 | \fBTcl_ParseArgsObjv\fR(\fIinterp, argTable, objcPtr, objv, remObjv\fR) .SH ARGUMENTS .AS "const Tcl_ArgvInfo" ***remObjv in/out .AP Tcl_Interp *interp out Where to store error messages. .AP "const Tcl_ArgvInfo" *argTable in Pointer to array of option descriptors. | | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | \fBTcl_ParseArgsObjv\fR(\fIinterp, argTable, objcPtr, objv, remObjv\fR) .SH ARGUMENTS .AS "const Tcl_ArgvInfo" ***remObjv in/out .AP Tcl_Interp *interp out Where to store error messages. .AP "const Tcl_ArgvInfo" *argTable in Pointer to array of option descriptors. .AP "Tcl_Size \&| int" *objcPtr in/out A pointer to variable holding number of arguments in \fIobjv\fR. Will be modified to hold number of arguments left in the unprocessed argument list stored in \fIremObjv\fR. .AP "Tcl_Obj *const" *objv in The array of arguments to be parsed. .AP Tcl_Obj ***remObjv out Pointer to a variable that will hold the array of unprocessed arguments. |
| ︙ | ︙ |
Changes to doc/ParseCmd.3.
| ︙ | ︙ | |||
41 42 43 44 45 46 47 | For procedures other than \fBTcl_FreeParse\fR and \fBTcl_EvalTokensStandard\fR, used only for error reporting; if NULL, then no error messages are left after errors. For \fBTcl_EvalTokensStandard\fR, determines the context for evaluating the script and also is used for error reporting; must not be NULL. .AP "const char" *start in Pointer to first character in string to parse. | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | For procedures other than \fBTcl_FreeParse\fR and \fBTcl_EvalTokensStandard\fR, used only for error reporting; if NULL, then no error messages are left after errors. For \fBTcl_EvalTokensStandard\fR, determines the context for evaluating the script and also is used for error reporting; must not be NULL. .AP "const char" *start in Pointer to first character in string to parse. .AP Tcl_Size numBytes in Number of bytes in string to parse, not including any terminating null character. If less than 0 then the script consists of all characters 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, close brackets have no special meaning. |
| ︙ | ︙ | |||
192 193 194 195 196 197 198 |
\fBTcl_ParseCommand\fR, \fBTcl_ParseExpr\fR, \fBTcl_ParseBraces\fR,
\fBTcl_ParseQuotedString\fR, and \fBTcl_ParseVarName\fR
return parse information in two data structures, Tcl_Parse and Tcl_Token:
.PP
.CS
typedef struct Tcl_Parse {
const char *\fIcommentStart\fR;
| | | | | | | | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
\fBTcl_ParseCommand\fR, \fBTcl_ParseExpr\fR, \fBTcl_ParseBraces\fR,
\fBTcl_ParseQuotedString\fR, and \fBTcl_ParseVarName\fR
return parse information in two data structures, Tcl_Parse and Tcl_Token:
.PP
.CS
typedef struct Tcl_Parse {
const char *\fIcommentStart\fR;
Tcl_Size \fIcommentSize\fR;
const char *\fIcommandStart\fR;
Tcl_Size \fIcommandSize\fR;
Tcl_Size \fInumWords\fR;
Tcl_Token *\fItokenPtr\fR;
Tcl_Size \fInumTokens\fR;
...
} \fBTcl_Parse\fR;
typedef struct Tcl_Token {
int \fItype\fR;
const char *\fIstart\fR;
Tcl_Size \fIsize\fR;
Tcl_Size \fInumComponents\fR;
} \fBTcl_Token\fR;
.CE
.PP
The first five fields of a Tcl_Parse structure
are filled in only by \fBTcl_ParseCommand\fR.
These fields are not used by the other parsing procedures.
.PP
|
| ︙ | ︙ |
Changes to doc/PkgRequire.3.
| ︙ | ︙ | |||
51 52 53 54 55 56 57 | .AP "const void" *clientData in Arbitrary value to be associated with the package. .AP void *clientDataPtr out 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. The storage can be any pointer type with the same size as a void pointer. | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | .AP "const void" *clientData in Arbitrary value to be associated with the package. .AP void *clientDataPtr out 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. The storage can be any pointer type with the same size as a void pointer. .AP Tcl_Size 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 |
| ︙ | ︙ |
Changes to doc/RegExp.3.
| ︙ | ︙ | |||
60 61 62 63 64 65 66 | by \fBTcl_GetRegExpFromObj\fR or \fBTcl_RegExpCompile\fR. .AP "const char" *start in If \fItext\fR is just a portion of some other string, this argument identifies the beginning of the larger string. If it is not the same as \fItext\fR, then no .QW \fB^\fR matches will be allowed. | | | | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | by \fBTcl_GetRegExpFromObj\fR or \fBTcl_RegExpCompile\fR. .AP "const char" *start in If \fItext\fR is just a portion of some other string, this argument identifies the beginning of the larger string. If it is not the same as \fItext\fR, then no .QW \fB^\fR matches will be allowed. .AP Tcl_Size index in Specifies which range is desired: 0 means the range of the entire match, 1 or greater means the range that matched a parenthesized sub-expression. .AP "const char" **startPtr out The address of the first character in the range is stored here, or NULL if there is no such range. .AP "const char" **endPtr out The address of the character just after the last one in the range is stored here, or NULL if there is no such range. .AP int cflags in OR-ed combination of the compilation flags \fBTCL_REG_ADVANCED\fR, \fBTCL_REG_EXTENDED\fR, \fBTCL_REG_BASIC\fR, \fBTCL_REG_EXPANDED\fR, \fBTCL_REG_QUOTE\fR, \fBTCL_REG_NOCASE\fR, \fBTCL_REG_NEWLINE\fR, \fBTCL_REG_NLSTOP\fR, \fBTCL_REG_NLANCH\fR, \fBTCL_REG_NOSUB\fR, and \fBTCL_REG_CANMATCH\fR. See below for more information. .AP Tcl_Size offset in The character offset into the text where matching should begin. The value of the offset has no impact on \fB^\fR matches. This behavior is controlled by \fIeflags\fR. .AP Tcl_Size nmatches in The number of matching subexpressions that should be remembered for later use. If this value is 0, then no subexpression match information will be computed. If the value is negative, then all of the matching subexpressions will be remembered. Any other value will be taken as the maximum number of subexpressions to remember. .AP int eflags in OR-ed combination of the execution flags \fBTCL_REG_NOTBOL\fR and \fBTCL_REG_NOTEOL\fR. See below for more information. .AP Tcl_RegExpInfo *infoPtr out |
| ︙ | ︙ | |||
333 334 335 336 337 338 339 |
\fBTcl_RegExpGetInfo\fR retrieves information about the last match
performed with a given regular expression \fIregexp\fR. The
\fIinfoPtr\fR argument contains a pointer to a structure that is
defined as follows:
.PP
.CS
typedef struct Tcl_RegExpInfo {
| | | | | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
\fBTcl_RegExpGetInfo\fR retrieves information about the last match
performed with a given regular expression \fIregexp\fR. The
\fIinfoPtr\fR argument contains a pointer to a structure that is
defined as follows:
.PP
.CS
typedef struct Tcl_RegExpInfo {
Tcl_Size \fInsubs\fR;
Tcl_RegExpIndices *\fImatches\fR;
Tcl_Size \fIextendStart\fR;
} \fBTcl_RegExpInfo\fR;
.CE
.PP
The \fInsubs\fR field contains a count of the number of parenthesized
subexpressions within the regular expression. If the \fBTCL_REG_NOSUB\fR
was used, then this value will be zero. The \fImatches\fR field
points to an array of \fInsubs\fR+1 values that indicate the bounds of each
subexpression matched. The first element in the array refers to the
range matched by the entire regular expression, and subsequent elements
refer to the parenthesized subexpressions in the order that they
appear in the pattern. Each element is a structure that is defined as
follows:
.PP
.CS
typedef struct Tcl_RegExpIndices {
Tcl_Size \fIstart\fR;
Tcl_Size \fIend\fR;
} \fBTcl_RegExpIndices\fR;
.CE
.PP
The \fIstart\fR and \fIend\fR values are Unicode character indices
relative to the offset location within \fIobjPtr\fR where matching began.
The \fIstart\fR index identifies the first character of the matched
subexpression. The \fIend\fR index identifies the first character
|
| ︙ | ︙ |
Changes to doc/SetRecLmt.3.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | .BS .SH NAME Tcl_SetRecursionLimit \- set maximum allowable nesting depth in interpreter .SH SYNOPSIS .nf \fB#include <tcl.h>\fR .sp | | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | .BS .SH NAME Tcl_SetRecursionLimit \- set maximum allowable nesting depth in interpreter .SH SYNOPSIS .nf \fB#include <tcl.h>\fR .sp Tcl_Size \fBTcl_SetRecursionLimit\fR(\fIinterp, depth\fR) .SH ARGUMENTS .AS Tcl_Interp *interp .AP Tcl_Interp *interp in Interpreter whose recursion limit is to be set. Must be greater than zero. .AP Tcl_Size depth in New limit for nested calls to \fBTcl_Eval\fR for \fIinterp\fR. .BE .SH DESCRIPTION .PP At any given time Tcl enforces a limit on the number of recursive calls that may be active for \fBTcl_Eval\fR and related procedures |
| ︙ | ︙ |
Changes to doc/SetResult.3.
| ︙ | ︙ | |||
30 31 32 33 34 35 36 | .sp \fBTcl_TransferResult\fR(\fIsourceInterp, code, targetInterp\fR) .sp \fBTcl_AppendElement\fR(\fIinterp, element\fR) .SH ARGUMENTS .AS Tcl_FreeProc sourceInterp out .AP Tcl_Interp *interp out | | | < | | | | < < < < | | | | < | < | < | < | < | < > | < < < < < < < < | | < < < | < | < < < | | < | | < < | < > | < | < < < < < < | | < | | < | < < < < < | < < | | | < | | | | < < < | | > > < | | < | | < < < | | < < | | | < | | | < < < < < < < < < < | < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
.sp
\fBTcl_TransferResult\fR(\fIsourceInterp, code, targetInterp\fR)
.sp
\fBTcl_AppendElement\fR(\fIinterp, element\fR)
.SH ARGUMENTS
.AS Tcl_FreeProc sourceInterp out
.AP Tcl_Interp *interp out
The interpreter get or set the result for.
.AP Tcl_Obj *objPtr in
A value to set the result to.
.AP char *result in
The string value set the result to, or to append to the existing result.
.AP "const char" *element in
The string value to append as a list element
to the existing result of \fIinterp\fR.
.AP Tcl_FreeProc *freeProc in
Pointer to a procedure to call to release storage at
\fIresult\fR.
.AP Tcl_Interp *sourceInterp in
The interpreter to transfer the result and return options from.
.AP Tcl_Interp *targetInterp in
The interpreter to transfer the result and return options to.
.AP int code in
Return code value that controls transfer of return options.
.BE
.SH DESCRIPTION
.PP
These procedures manipulate the result of an interpreter. Some procedures
provide a Tcl_Obj interface while others provide a string interface. For
example, \fBTcl_SetObjResult\fR accepts a Tcl_Obj and \fBTcl_SetResult\fR
accepts a char *. Similarly, \fBTcl_GetObjResult\fR produces a Tcl_Obj * and
\fBTcl_GetStringResult\fR produces a char *. The procedures can be mixed and
matched. For example, if \fBTcl_SetObjResult\fR is called to set the result to
a Tcl_Obj value, and then \fBTcl_GetStringResult\fR is called, it returns a
char * (but see caveats below).
.PP
\fBTcl_SetObjResult\fR sets \fIobjPtr\fR as the result for \fIinterp\fR,
replacing any existing result.
.PP
\fBTcl_GetObjResult\fR returns the result for \fIinterp\fR, without
incrementing its reference count.
.PP
\fBTcl_SetResult\fR sets \fIresult\fR as the result for \fIinterp\fR, replacing
any existing result, and calls \fIfreeProc\fR to free \fIresult\fR. See \fBTHE
TCL_FREEPROC ARGUMENT TO TCL_SETRESULT\fR below. If \fIresult\fR is
\fBNULL\fR, ignores \fIfreeProc\fR and sets the result for \fIinterp\fR to
point to the empty string.
.PP
\fBTcl_GetStringResult\fR returns the result for \fIinterp\fR as a string, i.e.
the bytes of the Tcl_Obj for the result, which can be decoded using
\fBTcl_UtfToExternal\fR. This value is freed when its corresponding Tcl_Obj is
freed.Programmers are encouraged to use the newer Tcl_Obj API procedures, e.g.
to call \fBTcl_GetObjResult\fR instead.
.PP
\fBTcl_ResetResult\fR sets the empty string as the result for \fIinterp\fR and
clears the error state managed by \fBTcl_AddErrorInfo\fR,
\fBTcl_AddObjErrorInfo\fR, and \fBTcl_SetErrorCode\fR.
.PP
\fBTcl_AppendResult\fR builds up a result from smaller pieces, appending each
\fIresult\fR in order to the current result for \fIinterp\fR. It may be called
repeatedly as additional pieces of the result are produced, and manages the
storage for the \fIinterp\fR's result, allocating a larger result area if
necessary. It also manages conversion to and from the \fIresult\fR field of
the \fIinterp\fR to handle backward-compatibility with old-style extensions.
Any number of \fIresult\fR arguments may be passed in a single call; the last
argument in the list must be a NULL pointer.
.PP
\fBTcl_TransferResult\fR transfers interpreter state from \fIsourceInterp\fR to
\fItargetInterp\fR, both of which must have been created in the same thread,
resets the result in \fIsourceInterp\fR, and moves the return options
dictionary as controlled by the return code value \fIcode\fR in the same manner
as \fBTcl_GetReturnOptions\fR.
.PP
If \fIsourceInterp\fR and \fItargetInterp\fR are the same, nothing is done.
.SH "DEPRECATED INTERFACES"
.SS "OLD STRING PROCEDURES"
.PP
The following procedures are deprecated since they manipulate the Tcl result as
a string. Procedures such as \fBTcl_SetObjResult\fR can be significantly more
efficient.
.PP
\fBTcl_AppendElement\fR is like \fBTcl_AppendResult\fR, but it appends only one
piece, and also appends that piece as a list item.
\fBTcl_AppendElement\fR adds backslashes or braces as necessary to ensure that
\fIelement\fR is properly formatted as a list item. Under normal conditions,
\fBTcl_AppendElement\fR adds a space character to \fIinterp\fR's result just
before adding the new list element, so that the list elements in the result are
properly separated. However if the new list element is the first item in the
list or sublist (i.e. \fIinterp\fR's current result is empty, or consists of
the single character
.QW { ,
or ends in the characters
.QW " {" )
then no space is added.
.SH "THE TCL_FREEPROC ARGUMENT TO TCL_SETRESULT"
.PP
\fIFreeProc\fR has the following type:
.PP
.CS
typedef void \fBTcl_FreeProc\fR(
char *\fIblockPtr\fR);
.CE
.PP
When \fIfreeProc\fR is called, \fIblockPtr\fR is the \fIresult\fR value passed
to \fBTcl_SetResult\fR.
.SH "SEE ALSO"
Tcl_AddErrorInfo, Tcl_CreateObjCommand, Tcl_SetErrorCode, Tcl_Interp,
Tcl_GetReturnOptions
.SH KEYWORDS
append, command, element, list, value, result, return value, interpreter
|
Changes to doc/SetVar.3.
| ︙ | ︙ | |||
246 247 248 249 250 251 252 | .PP The result of \fBTcl_SetVar2Ex\fR, \fBTcl_ObjSetVar2\fR, \fBTcl_GetVar2Ex\fR, and \fBTcl_ObjGetVar2\fR is (if non-NULL) a value with a reference of at least 1, where that reference is held by the variable that the function has just operated upon. .PP The \fInewValuePtr\fR argument to \fBTcl_SetVar2Ex\fR and \fBTcl_ObjSetVar2\fR | | | | | | < | | | > | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | .PP The result of \fBTcl_SetVar2Ex\fR, \fBTcl_ObjSetVar2\fR, \fBTcl_GetVar2Ex\fR, and \fBTcl_ObjGetVar2\fR is (if non-NULL) a value with a reference of at least 1, where that reference is held by the variable that the function has just operated upon. .PP The \fInewValuePtr\fR argument to \fBTcl_SetVar2Ex\fR and \fBTcl_ObjSetVar2\fR may be an arbitrary reference count value. Its reference count is incremented on success. On failure, if its reference count is zero, it is decremented and freed so the caller need do nothing with it. .PP The \fIpart1Ptr\fR argument to \fBTcl_ObjSetVar2\fR and \fBTcl_ObjGetVar2\fR can have any reference count. These functions never modify it. .PP The \fIpart2Ptr\fR argument to \fBTcl_ObjSetVar2\fR and \fBTcl_ObjGetVar2\fR, if non-NULL, should not have a zero reference count as these functions may retain a reference to it, particularly when it is used to create an array element that did not previously exist, and decrementing the reference count later would leave them pointing to a freed Tcl_Obj. .SH "SEE ALSO" Tcl_GetObjResult, Tcl_GetStringResult, Tcl_TraceVar .SH KEYWORDS array, get variable, interpreter, scalar, set, unset, value, variable |
Changes to doc/SplitList.3.
| ︙ | ︙ | |||
16 17 18 19 20 21 22 | .sp int \fBTcl_SplitList\fR(\fIinterp, list, argcPtr, argvPtr\fR) .sp char * \fBTcl_Merge\fR(\fIargc, argv\fR) .sp | | | | | | | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | .sp int \fBTcl_SplitList\fR(\fIinterp, list, argcPtr, argvPtr\fR) .sp char * \fBTcl_Merge\fR(\fIargc, argv\fR) .sp Tcl_Size \fBTcl_ScanElement\fR(\fIsrc, flagsPtr\fR) .sp Tcl_Size \fBTcl_ScanCountedElement\fR(\fIsrc, length, flagsPtr\fR) .sp Tcl_Size \fBTcl_ConvertElement\fR(\fIsrc, dst, flags\fR) .sp Tcl_Size \fBTcl_ConvertCountedElement\fR(\fIsrc, length, dst, flags\fR) .SH ARGUMENTS .AS "const char *const" ***argvPtr out .AP Tcl_Interp *interp out Interpreter to use for error reporting. If NULL, then no error message is left. .AP "const char" *list in Pointer to a string with proper list structure. .AP "Tcl_Size \&| int" *argcPtr out Filled in with number of elements in \fIlist\fR. .AP "const char" ***argvPtr out \fI*argvPtr\fR will be filled in with the address of an array of pointers to the strings that are the extracted elements of \fIlist\fR. There will be \fI*argcPtr\fR valid entries in the array, followed by a NULL entry. .AP Tcl_Size argc in Number of elements in \fIargv\fR. .AP "const char *const" *argv in Array of strings to merge together into a single list. Each string will become a separate element of the list. .AP "const char" *src in String that is to become an element of a list. .AP int *flagsPtr in Pointer to word to fill in with information about \fIsrc\fR. The value of *\fIflagsPtr\fR must be passed to \fBTcl_ConvertElement\fR. .AP Tcl_Size length in Number of bytes in string \fIsrc\fR. .AP char *dst in Place to copy converted list element. Must contain enough characters to hold converted string. .AP int flags in Information about \fIsrc\fR. Must be value returned by previous call to \fBTcl_ScanElement\fR, possibly OR-ed |
| ︙ | ︙ | |||
77 78 79 80 81 82 83 | addition to the array of pointers, it also holds copies of all the list elements. It is the caller's responsibility to free up all of this storage. For example, suppose that you have called \fBTcl_SplitList\fR with the following code: .PP .CS | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | addition to the array of pointers, it also holds copies of all the list elements. It is the caller's responsibility to free up all of this storage. For example, suppose that you have called \fBTcl_SplitList\fR with the following code: .PP .CS Tcl_Size argc; int code; char *string; char **argv; \&... code = \fBTcl_SplitList\fR(interp, string, &argc, &argv); .CE .PP |
| ︙ | ︙ |
Changes to doc/SplitPath.3.
| ︙ | ︙ | |||
21 22 23 24 25 26 27 | Tcl_PathType \fBTcl_GetPathType\fR(\fIpath\fR) .SH ARGUMENTS .AS "const char *const" ***argvPtr in/out .AP "const char" *path in File path in a form appropriate for the current platform (see the \fBfilename\fR manual entry for acceptable forms for path names). | | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | Tcl_PathType \fBTcl_GetPathType\fR(\fIpath\fR) .SH ARGUMENTS .AS "const char *const" ***argvPtr in/out .AP "const char" *path in File path in a form appropriate for the current platform (see the \fBfilename\fR manual entry for acceptable forms for path names). .AP "Tcl_Size \&| int" *argcPtr out Filled in with number of path elements in \fIpath\fR. .AP "const char" ***argvPtr out \fI*argvPtr\fR will be filled in with the address of an array of pointers to the strings that are the extracted elements of \fIpath\fR. There will be \fI*argcPtr\fR valid entries in the array, followed by a NULL entry. .AP Tcl_Size argc in Number of elements in \fIargv\fR. .AP "const char *const" *argv in Array of path elements to merge together into a single path. .AP Tcl_DString *resultPtr in/out A pointer to an initialized \fBTcl_DString\fR to which the result of \fBTcl_JoinPath\fR will be appended. .BE |
| ︙ | ︙ | |||
57 58 59 60 61 62 63 | dynamically allocated; in addition to the array of pointers, it also holds copies of all the path elements. It is the caller's responsibility to free all of this storage. For example, suppose that you have called \fBTcl_SplitPath\fR with the following code: .PP .CS | | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | dynamically allocated; in addition to the array of pointers, it also holds copies of all the path elements. It is the caller's responsibility to free all of this storage. For example, suppose that you have called \fBTcl_SplitPath\fR with the following code: .PP .CS Tcl_Size argc; char *path; char **argv; \&... Tcl_SplitPath(string, &argc, &argv); .CE .PP Then you should eventually free the storage with a call like the |
| ︙ | ︙ |
Changes to doc/StringObj.3.
| ︙ | ︙ | |||
36 37 38 39 40 41 42 | .sp Tcl_UniChar * \fBTcl_GetUnicode\fR(\fIobjPtr\fR) .sp int \fBTcl_GetUniChar\fR(\fIobjPtr, index\fR) .sp | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | .sp Tcl_UniChar * \fBTcl_GetUnicode\fR(\fIobjPtr\fR) .sp int \fBTcl_GetUniChar\fR(\fIobjPtr, index\fR) .sp Tcl_Size \fBTcl_GetCharLength\fR(\fIobjPtr\fR) .sp Tcl_Obj * \fBTcl_GetRange\fR(\fIobjPtr, first, last\fR) .sp void \fBTcl_AppendToObj\fR(\fIobjPtr, bytes, length\fR) |
| ︙ | ︙ | |||
83 84 85 86 87 88 89 | \fBTcl_ConcatObj\fR(\fIobjc, objv\fR) .SH ARGUMENTS .AS "const Tcl_UniChar" *appendObjPtr in/out .AP "const char" *bytes in Points to the first byte of an array of UTF-8-encoded bytes used to set or append to a string value. This byte array may contain embedded null characters | | | | | | | | | | | | | < < < | | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | \fBTcl_ConcatObj\fR(\fIobjc, objv\fR) .SH ARGUMENTS .AS "const Tcl_UniChar" *appendObjPtr in/out .AP "const char" *bytes in Points to the first byte of an array of UTF-8-encoded bytes used to set or append to a string value. This byte array may contain embedded null characters unless \fInumChars\fR is negative. (Applications needing null bytes should represent them as the two-byte sequence \fI\e300\e200\fR, use \fBTcl_ExternalToUtf\fR to convert, or \fBTcl_NewByteArrayObj\fR if the string is a collection of uninterpreted bytes.) .AP Tcl_Size length in The number of bytes to copy from \fIbytes\fR when initializing, setting, or appending to a string value. If negative, all bytes up to the first null are used. .AP "const Tcl_UniChar" *unicode in Points to the first byte of an array of Unicode characters used to set or append to a string value. This byte array may contain embedded null characters unless \fInumChars\fR is negative. .AP Tcl_Size numChars in The number of Unicode characters to copy from \fIunicode\fR when initializing, setting, or appending to a string value. If negative, all characters up to the first null character are used. .AP Tcl_Size index in The index of the Unicode character to return. .AP Tcl_Size first in The index of the first Unicode character in the Unicode range to be returned as a new value. If negative, behave the same as if the value was 0. .AP Tcl_Size last in The index of the last Unicode character in the Unicode range to be returned as a new value. If negative, take all characters up to the last one available. .AP Tcl_Obj *objPtr in/out Points to a value to manipulate. .AP Tcl_Obj *appendObjPtr in The value to append to \fIobjPtr\fR in \fBTcl_AppendObjToObj\fR. .AP "Tcl_Size \&| int" *lengthPtr out The location where \fBTcl_GetStringFromObj\fR will store the length of a value's string representation. May be (int *)NULL when not used. .AP "const char" *string in Null-terminated string value to append to \fIobjPtr\fR. .AP Tcl_Size limit in Maximum number of bytes to be appended. .AP "const char" *ellipsis in Suffix to append when the limit leads to string truncation. If NULL is passed then the suffix .QW "..." is used. .AP "const char" *format in Format control string including % conversion specifiers. .AP Tcl_Size objc in The number of elements to format or concatenate. .AP Tcl_Obj *objv[] in The array of values to format or concatenate. .AP Tcl_Size newLength in New length for the string value of \fIobjPtr\fR, not including the final null character. .BE .SH DESCRIPTION .PP The procedures described in this manual entry allow Tcl values to be manipulated as string values. They use the internal representation |
| ︙ | ︙ | |||
209 210 211 212 213 214 215 | value's Unicode representation. If the index is out of range or it references a low surrogate preceded by a high surrogate, it returns -1; .PP \fBTcl_GetRange\fR returns a newly created value comprised of the characters between \fIfirst\fR and \fIlast\fR (inclusive) in the value's Unicode representation. If the value's Unicode representation is invalid, the Unicode representation is regenerated from the value's | | | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | value's Unicode representation. If the index is out of range or it references a low surrogate preceded by a high surrogate, it returns -1; .PP \fBTcl_GetRange\fR returns a newly created value comprised of the characters between \fIfirst\fR and \fIlast\fR (inclusive) in the value's Unicode representation. If the value's Unicode representation is invalid, the Unicode representation is regenerated from the value's string representation. If \fIfirst\fR is negative, then the returned string starts at the beginning of the value. If \fIlast\fR negative, then the returned string ends at the end of the value. .PP \fBTcl_GetCharLength\fR returns the number of characters (as opposed to bytes) in the string value. .PP \fBTcl_AppendToObj\fR appends the data given by \fIbytes\fR and \fIlength\fR to the string representation of the value specified by |
| ︙ | ︙ | |||
259 260 261 262 263 264 265 | end result should be kept short enough to be read. Bytes from \fIbytes\fR are appended to \fIobjPtr\fR, but no more than \fIlimit\fR bytes total are to be appended. If the limit prevents all \fIlength\fR bytes that are available from being appended, then the appending is done so that the last bytes appended are from the string \fIellipsis\fR. This allows for an indication of the truncation to be left in the string. | | | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | end result should be kept short enough to be read. Bytes from \fIbytes\fR are appended to \fIobjPtr\fR, but no more than \fIlimit\fR bytes total are to be appended. If the limit prevents all \fIlength\fR bytes that are available from being appended, then the appending is done so that the last bytes appended are from the string \fIellipsis\fR. This allows for an indication of the truncation to be left in the string. When \fIlength\fR is negative, all bytes up to the first zero byte are appended, subject to the limit. When \fIellipsis\fR is NULL, the default string \fB...\fR is used. When \fIellipsis\fR is non-NULL, it must point to a zero-byte-terminated string in Tcl's internal UTF encoding. The number of bytes appended can be less than the lesser of \fIlength\fR and \fIlimit\fR when appending fewer bytes is necessary to append only whole multi-byte characters. .PP |
| ︙ | ︙ | |||
302 303 304 305 306 307 308 | functionality is needed. .PP \fBTcl_ObjPrintf\fR serves as a replacement for the common sequence .PP .CS char buf[SOME_SUITABLE_LENGTH]; sprintf(buf, format, ...); | | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | functionality is needed. .PP \fBTcl_ObjPrintf\fR serves as a replacement for the common sequence .PP .CS char buf[SOME_SUITABLE_LENGTH]; sprintf(buf, format, ...); \fBTcl_NewStringObj\fR(buf, -1); .CE .PP but with greater convenience and no need to determine \fBSOME_SUITABLE_LENGTH\fR. The formatting is done with the same core formatting engine used by \fBTcl_Format\fR. This means the set of supported conversion specifiers is that of the \fBformat\fR command and not that of the \fBsprintf\fR routine where the two sets differ. When a |
| ︙ | ︙ |
Changes to doc/SubstObj.3.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | .AP Tcl_Interp *interp in Interpreter in which to execute Tcl scripts and lookup variables. If an error occurs, the interpreter's result is modified to hold an error message. .AP Tcl_Obj *objPtr in A Tcl value containing the string to perform substitutions on. .AP int flags in | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | .AP Tcl_Interp *interp in Interpreter in which to execute Tcl scripts and lookup variables. If an error occurs, the interpreter's result is modified to hold an error message. .AP Tcl_Obj *objPtr in A Tcl value containing the string to perform substitutions on. .AP int flags in OR'ed combination of flag bits that specify which substitutions to perform. The flags \fBTCL_SUBST_COMMANDS\fR, \fBTCL_SUBST_VARIABLES\fR and \fBTCL_SUBST_BACKSLASHES\fR are currently supported, and \fBTCL_SUBST_ALL\fR is provided as a convenience for the common case where all substitutions are desired. .BE .SH DESCRIPTION .PP |
| ︙ | ︙ |
Changes to doc/TclZlib.3.
| ︙ | ︙ | |||
84 85 86 87 88 89 90 | section \fBGZIP OPTIONS DICTIONARY\fR for details about the contents of this dictionary. .AP "unsigned int" initValue in The initial value for the checksum algorithm. .AP "unsigned char" *bytes in An array of bytes to run the checksum algorithm over, or NULL to get the recommended initial value for the checksum algorithm. | | | | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | section \fBGZIP OPTIONS DICTIONARY\fR for details about the contents of this dictionary. .AP "unsigned int" initValue in The initial value for the checksum algorithm. .AP "unsigned char" *bytes in An array of bytes to run the checksum algorithm over, or NULL to get the recommended initial value for the checksum algorithm. .AP Tcl_Size length in The number of bytes in the array. .AP int mode in What mode to operate the stream in. Should be either \fBTCL_ZLIB_STREAM_DEFLATE\fR for a compressing stream or \fBTCL_ZLIB_STREAM_INFLATE\fR for a decompressing stream. .AP Tcl_ZlibStream *zshandlePtr out A pointer to a variable in which to write the abstract token for the stream upon successful creation. .AP Tcl_ZlibStream zshandle in The abstract token for the stream to operate on. .AP int flush in Whether and how to flush the stream after writing the data to it. Must be one of: \fBTCL_ZLIB_NO_FLUSH\fR if no flushing is to be done, \fBTCL_ZLIB_FLUSH\fR if the currently compressed data must be made available for access using \fBTcl_ZlibStreamGet\fR, \fBTCL_ZLIB_FULLFLUSH\fR if the stream must be put into a state where the decompressor can recover from on corruption, or \fBTCL_ZLIB_FINALIZE\fR to ensure that the stream is finished and that any trailer demanded by the format is written. .AP Tcl_Size count in The maximum number of bytes to get from the stream, or -1 to get all remaining bytes from the stream's buffers. .AP Tcl_Obj *compDict in A byte array value that is the compression dictionary to use with the stream. Note that this is \fInot a Tcl dictionary\fR, and it is recommended that this only ever be used with streams that were created with their \fIformat\fR set to \fBTCL_ZLIB_FORMAT_ZLIB\fR because the other formats have no mechanism to indicate whether a compression dictionary was present other than to fail on |
| ︙ | ︙ |
Changes to doc/Tcl_Main.3.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 | .sp Tcl_Obj * \fBTcl_GetStartupScript\fR(\fIencodingPtr\fR) .sp \fBTcl_SetMainLoop\fR(\fImainLoopProc\fR) .SH ARGUMENTS .AS Tcl_MainLoopProc *mainLoopProc | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | .sp Tcl_Obj * \fBTcl_GetStartupScript\fR(\fIencodingPtr\fR) .sp \fBTcl_SetMainLoop\fR(\fImainLoopProc\fR) .SH ARGUMENTS .AS Tcl_MainLoopProc *mainLoopProc .AP Tcl_Size argc in Number of elements in \fIargv\fR. .AP char *argv[] in Array of strings containing command-line arguments. On Windows, when using -DUNICODE, the parameter type changes to wchar_t *. .AP char *charargv[] in As argv, but does not change type to wchar_t. .AP char *wideargv[] in |
| ︙ | ︙ |
Changes to doc/ToUpper.3.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | .sp int \fBTcl_UniCharToLower\fR(\fIch\fR) .sp int \fBTcl_UniCharToTitle\fR(\fIch\fR) .sp | | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | .sp int \fBTcl_UniCharToLower\fR(\fIch\fR) .sp int \fBTcl_UniCharToTitle\fR(\fIch\fR) .sp Tcl_Size \fBTcl_UtfToUpper\fR(\fIstr\fR) .sp Tcl_Size \fBTcl_UtfToLower\fR(\fIstr\fR) .sp Tcl_Size \fBTcl_UtfToTitle\fR(\fIstr\fR) .SH ARGUMENTS .AS char *str in/out .AP int ch in The Unicode character to be converted. .AP char *str in/out Pointer to UTF-8 string to be converted in place. |
| ︙ | ︙ |
Changes to doc/Translate.3.
| ︙ | ︙ | |||
17 18 19 20 21 22 23 | char * \fBTcl_TranslateFileName\fR(\fIinterp\fR, \fIname\fR, \fIbufferPtr\fR) .SH ARGUMENTS .AS Tcl_DString *bufferPtr in/out .AP Tcl_Interp *interp in Interpreter in which to report an error, if any. .AP "const char" *name in | | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | char * \fBTcl_TranslateFileName\fR(\fIinterp\fR, \fIname\fR, \fIbufferPtr\fR) .SH ARGUMENTS .AS Tcl_DString *bufferPtr in/out .AP Tcl_Interp *interp in Interpreter in which to report an error, if any. .AP "const char" *name in File name .AP Tcl_DString *bufferPtr in/out If needed, this dynamic string is used to store the new file name. At the time of the call it should be uninitialized or free. The caller must eventually call \fBTcl_DStringFree\fR to free up anything stored here. .BE .SH DESCRIPTION |
| ︙ | ︙ |
Changes to doc/Utf.3.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 | Tcl_UniChar, Tcl_UniCharToUtf, Tcl_UtfToUniChar, Tcl_UtfToChar16, Tcl_UtfToWChar, Tcl_UniCharToUtfDString, Tcl_UtfToUniCharDString, Tcl_Char16ToUtfDString, Tcl_UtfToWCharDString, Tcl_UtfToChar16DString, Tcl_WCharLen, Tcl_Char16Len, Tcl_UniCharLen, Tcl_UniCharNcmp, Tcl_UniCharNcasecmp, Tcl_UniCharCaseMatch, Tcl_UtfNcmp, Tcl_UtfNcasecmp, Tcl_UtfCharComplete, Tcl_NumUtfChars, Tcl_UtfFindFirst, Tcl_UtfFindLast, Tcl_UtfNext, Tcl_UtfPrev, Tcl_UniCharAtIndex, Tcl_UtfAtIndex, Tcl_UtfBackslash \- routines for manipulating UTF-8 strings .SH SYNOPSIS .nf \fB#include <tcl.h>\fR .sp typedef ... \fBTcl_UniChar\fR; .sp | | | | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | Tcl_UniChar, Tcl_UniCharToUtf, Tcl_UtfToUniChar, Tcl_UtfToChar16, Tcl_UtfToWChar, Tcl_UniCharToUtfDString, Tcl_UtfToUniCharDString, Tcl_Char16ToUtfDString, Tcl_UtfToWCharDString, Tcl_UtfToChar16DString, Tcl_WCharLen, Tcl_Char16Len, Tcl_UniCharLen, Tcl_UniCharNcmp, Tcl_UniCharNcasecmp, Tcl_UniCharCaseMatch, Tcl_UtfNcmp, Tcl_UtfNcasecmp, Tcl_UtfCharComplete, Tcl_NumUtfChars, Tcl_UtfFindFirst, Tcl_UtfFindLast, Tcl_UtfNext, Tcl_UtfPrev, Tcl_UniCharAtIndex, Tcl_UtfAtIndex, Tcl_UtfBackslash \- routines for manipulating UTF-8 strings .SH SYNOPSIS .nf \fB#include <tcl.h>\fR .sp typedef ... \fBTcl_UniChar\fR; .sp Tcl_Size \fBTcl_UniCharToUtf\fR(\fIch, buf\fR) .sp Tcl_Size \fBTcl_UtfToUniChar\fR(\fIsrc, chPtr\fR) .sp Tcl_Size \fBTcl_UtfToChar16\fR(\fIsrc, uPtr\fR) .sp Tcl_Size \fBTcl_UtfToWChar\fR(\fIsrc, wPtr\fR) .sp char * \fBTcl_UniCharToUtfDString\fR(\fIuniStr, uniLength, dsPtr\fR) .sp char * \fBTcl_Char16ToUtfDString\fR(\fIuStr, uniLength, dsPtr\fR) |
| ︙ | ︙ | |||
89 90 91 92 93 94 95 | .sp int \fBTcl_UniCharAtIndex\fR(\fIsrc, index\fR) .sp const char * \fBTcl_UtfAtIndex\fR(\fIsrc, index\fR) .sp | | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | .sp int \fBTcl_UniCharAtIndex\fR(\fIsrc, index\fR) .sp const char * \fBTcl_UtfAtIndex\fR(\fIsrc, index\fR) .sp Tcl_Size \fBTcl_UtfBackslash\fR(\fIsrc, readPtr, dst\fR) .SH ARGUMENTS .AS "const Tcl_UniChar" *uniPattern in/out .AP char *buf out Buffer in which the UTF-8 representation of the Tcl_UniChar is stored. At most 4 bytes are stored in the buffer. .AP int ch in |
| ︙ | ︙ | |||
128 129 130 131 132 133 134 | A null-terminated wchar_t string. .AP "const unsigned short" *utf16s in A null-terminated utf-16 string. .AP "const unsigned short" *utf16t in A null-terminated utf-16 string. .AP "const unsigned short" *utf16Pattern in A null-terminated utf-16 string. | | | | | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | A null-terminated wchar_t string. .AP "const unsigned short" *utf16s in A null-terminated utf-16 string. .AP "const unsigned short" *utf16t in A null-terminated utf-16 string. .AP "const unsigned short" *utf16Pattern in A null-terminated utf-16 string. .AP Tcl_Size length in The length of the UTF-8 string in bytes (not UTF-8 characters). If negative, all bytes up to the first null byte are used. .AP Tcl_Size uniLength in The length of the Unicode string in characters. .AP "Tcl_DString" *dsPtr in/out A pointer to a previously initialized \fBTcl_DString\fR. .AP "const char" *start in Pointer to the beginning of a UTF-8 string. .AP Tcl_Size index in The index of a character (not byte) in the UTF-8 string. .AP int *readPtr out If non-NULL, filled with the number of bytes in the backslash sequence, including the backslash character. .AP char *dst out Buffer in which the bytes represented by the backslash sequence are stored. At most 4 bytes are stored in the buffer. |
| ︙ | ︙ | |||
250 251 252 253 254 255 256 | does not guarantee that the UTF-8 string is properly formed. This routine is used by procedures that are operating on a byte at a time and need to know if a full Unicode character has been seen. .PP \fBTcl_NumUtfChars\fR corresponds to \fBstrlen\fR for UTF-8 strings. It returns the number of Tcl_UniChars that are represented by the UTF-8 string \fIsrc\fR. The length of the source string is \fIlength\fR bytes. If the | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | does not guarantee that the UTF-8 string is properly formed. This routine is used by procedures that are operating on a byte at a time and need to know if a full Unicode character has been seen. .PP \fBTcl_NumUtfChars\fR corresponds to \fBstrlen\fR for UTF-8 strings. It returns the number of Tcl_UniChars that are represented by the UTF-8 string \fIsrc\fR. The length of the source string is \fIlength\fR bytes. If the length is negative, all bytes up to the first null byte are used. .PP \fBTcl_UtfFindFirst\fR corresponds to \fBstrchr\fR for UTF-8 strings. It returns a pointer to the first occurrence of the Unicode character \fIch\fR in the null-terminated UTF-8 string \fIsrc\fR. The null terminator is considered part of the UTF-8 string. .PP \fBTcl_UtfFindLast\fR corresponds to \fBstrrchr\fR for UTF-8 strings. It |
| ︙ | ︙ | |||
295 296 297 298 299 300 301 | byte \fIsrc[0]\fR nor the byte \fIstart[-1]\fR nor the byte \fIsrc[-5]\fR. .PP \fBTcl_UniCharAtIndex\fR corresponds to a C string array dereference or the Pascal Ord() function. It returns the Unicode character represented at the specified character (not byte) \fIindex\fR in the UTF-8 string \fIsrc\fR. The source string must contain at least \fIindex\fR | | | | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | byte \fIsrc[0]\fR nor the byte \fIstart[-1]\fR nor the byte \fIsrc[-5]\fR. .PP \fBTcl_UniCharAtIndex\fR corresponds to a C string array dereference or the Pascal Ord() function. It returns the Unicode character represented at the specified character (not byte) \fIindex\fR in the UTF-8 string \fIsrc\fR. The source string must contain at least \fIindex\fR characters. If \fIindex\fR is negative or \fIindex\fR points to the second half of a surrogate pair, it returns -1. .PP \fBTcl_UtfAtIndex\fR returns a pointer to the specified character (not byte) \fIindex\fR in the UTF-8 string \fIsrc\fR. The source string must contain at least \fIindex\fR characters. This is equivalent to calling \fBTcl_UtfToUniChar\fR \fIindex\fR times. If \fIindex\fR is negative, the return pointer points to the first character in the source string. .PP \fBTcl_UtfBackslash\fR is a utility procedure used by several of the Tcl commands. It parses a backslash sequence and stores the properly formed UTF-8 character represented by the backslash sequence in the output buffer \fIdst\fR. At most 4 bytes are stored in the buffer. \fBTcl_UtfBackslash\fR modifies \fI*readPtr\fR to contain the number |
| ︙ | ︙ |
Changes to doc/WrongNumArgs.3.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 | .sp \fBTcl_WrongNumArgs\fR(\fIinterp, objc, objv, message\fR) .SH ARGUMENTS .AS "Tcl_Obj *const" *message .AP Tcl_Interp interp in Interpreter in which error will be reported: error message gets stored in its result value. | | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | .sp \fBTcl_WrongNumArgs\fR(\fIinterp, objc, objv, message\fR) .SH ARGUMENTS .AS "Tcl_Obj *const" *message .AP Tcl_Interp interp in Interpreter in which error will be reported: error message gets stored in its result value. .AP Tcl_Size objc in Number of leading arguments from \fIobjv\fR to include in error message. .AP "Tcl_Obj *const" objv[] in Arguments to command that had the wrong number of arguments. .AP "const char" *message in Additional error information to print after leading arguments from \fIobjv\fR. This typically gives the acceptable syntax |
| ︙ | ︙ |
Changes to doc/cd.n.
| ︙ | ︙ | |||
24 25 26 27 28 29 30 | \fBcd\fR command changes the working directory for all interpreters and all threads. .SH EXAMPLES .PP Change to the home directory of the user \fBfred\fR: .PP .CS | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | \fBcd\fR command changes the working directory for all interpreters and all threads. .SH EXAMPLES .PP Change to the home directory of the user \fBfred\fR: .PP .CS \fBcd\fR [file home fred] .CE .PP Change to the directory \fBlib\fR that is a sibling directory of the current one: .PP .CS \fBcd\fR ../lib |
| ︙ | ︙ |
Changes to doc/chan.n.
| ︙ | ︙ | |||
120 121 122 123 124 125 126 | Sets the encoding of the channel. \fIname\fR is either one of the names returned by \fBencoding names\fR, or .QW \fBbinary\fR \&. Input is converted from the encoding into Unicode, and output is converted from Unicode to the encoding. .RS .PP | | < < < < < < < < | < < | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | Sets the encoding of the channel. \fIname\fR is either one of the names returned by \fBencoding names\fR, or .QW \fBbinary\fR \&. Input is converted from the encoding into Unicode, and output is converted from Unicode to the encoding. .RS .PP \fBbinary\fR is an alias for \fBiso8859-1\fR. This alone is not sufficient for working with binary data. Use \fB\-translation binary\fR instead. .PP The encoding of a new channel is the value of \fBencoding system\fR, which returns the platform- and locale-dependent system encoding used to interface with the operating system, .RE .TP \fB\-eofchar\fR \fIchar\fR |
| ︙ | ︙ | |||
192 193 194 195 196 197 198 | translated into a line feed. For output, each line feed is translated into a platform-specific representation: For all Unix variants it is \fBlf\fR, and for all Windows variants it is \fBcrlf\fR, except that for sockets on all platforms it is \fBcrlf\fR for both input and output. .TP \fBbinary\fR . | | | | | > > > > > > > | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | translated into a line feed. For output, each line feed is translated into a platform-specific representation: For all Unix variants it is \fBlf\fR, and for all Windows variants it is \fBcrlf\fR, except that for sockets on all platforms it is \fBcrlf\fR for both input and output. .TP \fBbinary\fR . Like \fBlf\fR, no end-of-line translation is performed, but in addition, sets \fB\-eofchar\fR to the empty string to disable it, sets \fB\-encoding\fR to \fBiso8859-1\fR, and sets \fB-profile\fR to \fBstrict\fR so the the channel is fully configured for binary input and output: Each byte read from the channel becomes the Unicode character having the same value as that byte, and each character written to the channel becomes a single byte in the output. This makes it possible to work seamlessly with binary data as long as each character in the data remains in the range of 0 to 255 so that there is no distinction between binary data and text. For example, A JPEG image can be read from a such a channel, manipulated, and then written back to such a channel. .TP \fBcr\fR . The end of a line is represented in the external data by a single carriage return character. For input, each carriage return is translated to a line feed, and for output each line feed character is translated to a carriage return. |
| ︙ | ︙ | |||
222 223 224 225 226 227 228 | translations occur during either input or output. This translation is typically used on UNIX platforms, .RE .RE .TP \fBchan copy \fIinputChan outputChan\fR ?\fB\-size \fIsize\fR? ?\fB\-command \fIcallback\fR? . | | > > | | < < < | < < | | | | | | | | > | > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > < < > | > | < > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < < > > > | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
translations occur during either input or output. This translation is
typically used on UNIX platforms,
.RE
.RE
.TP
\fBchan copy \fIinputChan outputChan\fR ?\fB\-size \fIsize\fR? ?\fB\-command \fIcallback\fR?
.
Reads characters from \fIinputChan\fR and writes them to \fIoutputChan\fR until
all characters are copied, blocking until the copy is complete and returning
the number of characters copied. Leverages internal buffers to avoid extra
copies and to avoid buffering too much data in main memory when copying large
files to slow destinations like network sockets.
.RS
.PP
\fB\-size\fR limits the number of characters copied.
.PP
If \fB\-command\fR is gviven, \fBchan copy\fR returns immediately, works in the
background, and calls \fIcallback\fR when the copy completes, providing as an
additional argument the number of characters written to \fIoutputChan\fR. If
an error occurres during the background copy, another argument provides message
for the error. \fIinputChan\fR and \fIoutputChan\fR are automatically
configured for non-blocking mode if needed. Background copying only works
correctly if events are being processed, e.g. via \fBvwait\fR or Tk.
.PP
During a background copy no other read operation may be performed on
\fIinputChan\fR, and no write operation may be performed on
\fIoutputChan\fR. However, write operations may by performed on
\fIinputChan\fR and read operations may be performed on \fIoutputChan\fR, as
exhibited by the bidirectional copy example below.
.PP
If either \fIinputChan\fR or \fIoutputChan\fR is closed while the copy is in
progress, copying ceases and \fBno\fR callback is made. If \fIinputChan\fR is
closed all data already queued is written to \fIoutputChan\fR.
.PP
There should be no event handler established for \fIinputChan\fR because it
may become readable during a background copy. An attempt to read or write from
within an event handler results result in the error, "channel busy". Any
wrong-sided I/O attempted (by a \fBfileevent\fR handler or otherwise) results
in a
.QW "channel busy"
error.
.PP
.PP
.IP \fBEXAMPLES\fR
.PP
The first example transfers the contents of one channel exactly to
another. Note that when copying one file to another, it is better to
use \fBfile copy\fR which also copies file metadata (e.g. the file
access permissions) where possible.
.PP
.CS
fconfigure $in -translation binary
fconfigure $out -translation binary
\fBfcopy\fR $in $out
.CE
.PP
This second example shows how the callback gets
passed the number of bytes transferred.
It also uses vwait to put the application into the event loop.
Of course, this simplified example could be done without the command
callback.
.PP
.CS
proc Cleanup {in out bytes {error {}}} {
global total
set total $bytes
close $in
close $out
if {[string length $error] != 0} {
# error occurred during the copy
}
}
set in [open $file1]
set out [socket $server $port]
\fBfcopy\fR $in $out -command [list Cleanup $in $out]
vwait total
.CE
.PP
The third example copies in chunks and tests for end of file
in the command callback.
.PP
.CS
proc CopyMore {in out chunk bytes {error {}}} {
global total done
incr total $bytes
if {([string length $error] != 0) || [eof $in]} {
set done $total
close $in
close $out
} else {
\fBfcopy\fR $in $out -size $chunk \e
-command [list CopyMore $in $out $chunk]
}
}
set in [open $file1]
set out [socket $server $port]
set chunk 1024
set total 0
\fBfcopy\fR $in $out -size $chunk \e
-command [list CopyMore $in $out $chunk]
vwait done
.CE
.PP
The fourth example starts an asynchronous, bidirectional fcopy between
two sockets. Those could also be pipes from two [open "|hal 9000" r+]
(though their conversation would remain secret to the script, since
all four fileevent slots are busy).
.PP
.CS
set flows 2
proc Done {dir args} {
global flows done
puts "$dir is over."
incr flows -1
if {$flows<=0} {set done 1}
}
\fBfcopy\fR $sok1 $sok2 -command [list Done UP]
\fBfcopy\fR $sok2 $sok1 -command [list Done DOWN]
vwait done
.CE
.RE
.TP
\fBchan create \fImode cmdPrefix\fR
.
Creates a new channel, called a \fBreflected\fR channel, with \fIcmdPrefix\fR
as its handler, and returns the name of the channel. \fBcmdPrefix\fR is the
first words of a command that provides the interface for a \fBrefchan\fR.
|
| ︙ | ︙ |
Changes to doc/cookiejar.n.
| ︙ | ︙ | |||
174 175 176 177 178 179 180 | The simplest way of using a cookie jar is to just permanently configure it at the start of the application. .PP .CS package require http \fBpackage require cookiejar\fR | | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | The simplest way of using a cookie jar is to just permanently configure it at the start of the application. .PP .CS package require http \fBpackage require cookiejar\fR set cookiedb [file join [file home] cookiejar] http::configure -cookiejar [\fBhttp::cookiejar new\fR $cookiedb] # No further explicit steps are required to use cookies set tok [http::geturl http://core.tcl-lang.org/] .CE .PP To only allow a particular domain to use cookies, perhaps because you only |
| ︙ | ︙ | |||
197 198 199 200 201 202 203 |
superclass \fBhttp::cookiejar\fR
method \fBpolicyAllow\fR {operation domain path} {
return [expr {$domain eq "my.example.com"}]
}
}
| | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
superclass \fBhttp::cookiejar\fR
method \fBpolicyAllow\fR {operation domain path} {
return [expr {$domain eq "my.example.com"}]
}
}
set cookiedb [file join [file home] cookiejar]
http::configure -cookiejar [MyCookieJar new $cookiedb]
# No further explicit steps are required to use cookies
set tok [http::geturl http://core.tcl-lang.org/]
.CE
.SH "SEE ALSO"
http(n), oo::class(n), sqlite3(n)
.SH KEYWORDS
cookie, internet, security policy, www
'\" Local Variables:
'\" mode: nroff
'\" fill-column: 78
'\" End:
|
Changes to doc/encoding.n.
1 2 3 4 5 6 7 8 9 10 | '\" '\" Copyright (c) 1998 Scriptics Corporation. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" .TH encoding n "8.1" Tcl "Tcl Built-In Commands" .so man.macros .BS .SH NAME | | | | > > > > > | | > | > > > > < < > > | > > | > > > > > | < < | | | | < < | < | < | | | | < < | | < < < | | | | < < | | < | > | | | | < < < | | < < < < < < < < < < < < < < | < | < | < | > | | | | | | < | | < < | < < < < < | < < | < | | | < | | | | | | < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
'\"
'\" Copyright (c) 1998 Scriptics Corporation.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.TH encoding n "8.1" Tcl "Tcl Built-In Commands"
.so man.macros
.BS
.SH NAME
encoding \- Work with encodings
.SH SYNOPSIS
\fBencoding \fIoperation\fR ?\fIarg arg ...\fR?
.BE
.SH INTRODUCTION
.PP
In Tcl every string is composed of Unicode values. Text may be encoded into an
encoding such as cp1252, iso8859-1, Shitf\-JIS, utf-8, utf-16, etc. Not every
Unicode vealue is encodable in every encoding, and some encodings can encode
values that are not available in Unicode.
.PP
Even though Unicode is for encoding the written texts of human languages, any
sequence of bytes can be encoded as the first 255 Unicode values. iso8859-1 an
encoding for a subset of Unicode in which each byte is a Unicode value of 255
or less. Thus, any sequence of bytes can be considered to be a Unicode string
encoded in iso8859-1. To work with binary data in Tcl, decode it from
iso8859-1 when reading it in, and encode it into iso8859-1 when writing it out,
ensuring that each character in the string has a value of 255 or less.
Decoding such a string does nothing, and encoding encoding such a string also
does nothing.
.PP
For example, the following is true:
.CS
set text {In Tcl binary data is treated as Unicode text and it just works.}
set encoded [encoding convertto iso8859-1 $text]
expr {$text eq $encoded}; #-> 1
.CE
The following is also true:
.CS
set decoded [encoding convertfrom iso8859-1 $text]
expr {$text eq $decoded}; #-> 1
.CE
.SH DESCRIPTION
.PP
Performs one of the following encoding \fIoperations\fR:
.TP
\fBencoding convertfrom\fR ?\fIencoding\fR? \fIdata\fR
.TP
\fBencoding convertfrom\fR ?\fB-profile \fIprofile\fR? ?\fB-failindex var\fR? \fIencoding\fR \fIdata\fR
.
Decodes \fIdata\fR encoded in \fIencoding\fR. If \fIencoding\fR is not
specified the current system encoding is used.
.VS "TCL8.7 TIP607, TIP656"
\fB-profile\fR determines how invalid data for the encoding are handled. See
the \fBPROFILES\fR section below for details. Returns an error if decoding
fails. However, if \fB-failindex\fR given, returns the result of the
conversion up to the point of termination, and stores in \fBvar\fR the index of
the character that could not be converted. If no errors are encountered the
entire result of the conversion is returned and the value \fB-1\fR is stored in
\fBvar\fR.
.VE "TCL8.7 TIP607, TIP656"
.TP
\fBencoding convertto\fR ?\fIencoding\fR? \fIdata\fR
.TP
\fBencoding convertto\fR ?\fB-profile \fIprofile\fR? ?\fB-failindex var\fR? \fIencoding\fR \fIdata\fR
.
Converts \fIstring\fR to \fIencoding\fR. If \fIencoding\fR is not given, the
current system encoding is used.
.VS "TCL8.7 TIP607, TIP656"
See \fBencoding convertfrom\fR for the meaning of \fB-profile\fR and \fB-failindex\fR.
.VE "TCL8.7 TIP607, TIP656"
.TP
\fBencoding dirs\fR ?\fIdirectoryList\fR?
.
Sets the search path for \fB*.enc\fR encoding data files to the list of
directories given by \fIdirectoryList\fR. If \fIdirectoryList\fR is not given,
returns the current list of directories that make up the search path. It is
not an error for an item in \fIdirectoryList\fR to not refer to a readable,
searchable directory.
.TP
\fBencoding names\fR
.
Returns a list of the names of available encodings.
The encodings
.QW utf-8
and
.QW iso8859-1
are guaranteed to be present in the list.
.VS "TCL8.7 TIP656"
.TP
\fBencoding profiles\fR
Returns a list of names of available encoding profiles. See \fBPROFILES\fR
below.
.VE "TCL8.7 TIP656"
.TP
\fBencoding system\fR ?\fIencoding\fR?
.
Sets the system encoding to \fIencoding\fR. If \fIencoding\fR is not given,
returns the current system encoding. The system encoding is used to pass
strings to system calls.
.\" Do not put .VS on whole section as that messes up the bullet list alignment
.SH PROFILES
.PP
.VS "TCL8.7 TIP656"
Each \fIprofile\fR is a distinct strategy for dealing with invalid data for an
encoding.
.PP
The following profiles are currently implemented.
.VS "TCL8.7 TIP656"
.TP
\fBtcl8\fR
.
The default profile. Provides for behaviour identical to that of Tcl 8.6: When
decoding, for encodings \fBother than utf-8\fR, each invalid byte is interpreted
as the Unicode value given by that one byte. For example, the byte 0x80, which
is invalid in the ASCII encoding would be mapped to the Unicode value U+0080.
For \fButf-8\fR, each invalid byte that is a valid CP1252 character is
interpreted as the Unicode value for that character, while each byte that is
not is treated as the Unicode value given by that one byte. For example, byte
0x80 is defined by CP1252 and is therefore mapped to its Unicode equivalent
U+20AC while byte 0x81 which is not defined by CP1252 is mapped to U+0081. As
an additional special case, the sequence 0xC0 0x80 is mapped to U+0000.
When encoding, each character that cannot be represented in the encoding is
replaced by an encoding-dependent character, usually the question mark \fB?\fR.
.TP
\fBstrict\fR
.
The operation fails when invalid data for the encoding are encountered.
.TP
\fBreplace\fR
.
When decoding, invalid bytes are replaced by U+FFFD, the Unicode REPLACEMENT
CHARACTER.
When encoding, Unicode values that cannot be represented in the target encoding
are transformed to an encoding-specific fallback character, U+FFFD REPLACEMENT
CHARACTER for UTF targets, and generally `?` for other encodings.
.VE "TCL8.7 TIP656"
.SH EXAMPLES
.PP
These examples use the utility proc below that prints the Unicode value for
each character in a string.
.PP
.CS
proc codepoints s {join [lmap c [split $s {}] {
string cat U+ [format %.6X [scan $c %c]]}]
}
.CE
.PP
Example 1: Convert from euc-jp:
.PP
.CS
% codepoints [\fBencoding convertfrom\fR euc-jp \exA4\exCF]
U+00306F
.CE
.PP
The result is the Unicode value
.QW "\eu306F" ,
which is the Hiragana letter HA.
.VS "TCL8.7 TIP607, TIP656"
.PP
Example 2: Error handling based on profiles:
.PP
The letter \fBA\fR is Unicode character U+0041 and the byte "\ex80" is invalid
in ASCII encoding.
.PP
.CS
% codepoints [encoding convertfrom -profile tcl8 ascii A\ex80]
U+000041 U+000080
% codepoints [encoding convertfrom -profile replace ascii A\ex80]
U+000041 U+00FFFD
% codepoints [encoding convertfrom -profile strict ascii A\ex80]
unexpected byte sequence starting at index 1: '\ex80'
.CE
|
| ︙ | ︙ |
Changes to doc/exec.n.
| ︙ | ︙ | |||
445 446 447 448 449 450 451 | Many programs on Windows require filename arguments to be passed in with backslashes as pathname separators. This is done with the help of the \fBfile nativename\fR command. For example, to make a directory (on NTFS) encrypted so that only the current user can access it requires use of the \fICIPHER\fR command, like this: .PP .CS | | | 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | Many programs on Windows require filename arguments to be passed in with backslashes as pathname separators. This is done with the help of the \fBfile nativename\fR command. For example, to make a directory (on NTFS) encrypted so that only the current user can access it requires use of the \fICIPHER\fR command, like this: .PP .CS set secureDir [file join [file home] Desktop/SecureDirectory] file mkdir $secureDir \fBexec\fR CIPHER /e /s:[file nativename $secureDir] .CE .SH "SEE ALSO" error(n), file(n), open(n) .SH KEYWORDS execute, pipeline, redirection, subprocess |
| ︙ | ︙ |
Changes to doc/fcopy.n.
| ︙ | ︙ | |||
8 9 10 11 12 13 14 | .TH fcopy n 8.0 Tcl "Tcl Built-In Commands" .so man.macros .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME fcopy \- Copy data from one channel to another .SH SYNOPSIS | | | > | | | < < < < < < | < < < < < | < | < < | | | | < < < | < | < > > > | < | | < | > | < < > | > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | .TH fcopy n 8.0 Tcl "Tcl Built-In Commands" .so man.macros .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME fcopy \- Copy data from one channel to another .SH SYNOPSIS \fBfcopy \fIinputChan\fR \fIoutputChan\fR ?\fB\-size \fIsize\fR? ?\fB\-command \fIcallback\fR? .BE .SH DESCRIPTION .PP Reads characters from \fIinputChan\fR and writes them to \fIoutputChan\fR until all characters are copied, blocking until the copy is complete and returning the number of characters copied. Leverages internal buffers to avoid extra copies and to avoid buffering too much data in main memory when copying large files to slow destinations like network sockets. .PP \fB\-size\fR limits the number of characters copied. .PP \fB\-command\fR makes \fBfcopy\fR return immediately, work in the background, and call \fIcallback\fR when the copy completes, providing as an additional argument the number of characters written to \fIoutputChan\fR. If an error occurres during the background copy, another argument provides the message for the error. \fIinputChan\fR and \fIoutputChan\fR are automatically configured for non-blocking mode if needed. Background copying only works correctly if events are being processed e.g. via \fBvwait\fR or Tk. .PP During a background copy no other read operation may be performed on \fIinputChan\fR, and no other write operation may be performed on \fIoutputChan\fR. However, write operations may by performed on \fIinputChan\fR and read operations may be performed on \fIoutputChan\fR, as exhibited by the bidirectional copy example below. .PP If either \fIinputChan\fR or \fIoutputChan\fR is closed while the copy is in progress, copying ceases and \fBno\fR callback is made. If \fIinputChan\fR is closed all data already queued is written to \fIoutputChan\fR. .PP There should be no event handler established for \fIinputChan\fR because it may become readable during a background copy. An attempt to read or write from within an event handler results result in the error, "channel busy". Any wrong-sided I/O attempted (by a \fBfileevent\fR handler or otherwise) results in a .QW "channel busy" error. .SH EXAMPLES .PP The first example transfers the contents of one channel exactly to another. Note that when copying one file to another, it is better to use \fBfile copy\fR which also copies file metadata (e.g. the file access permissions) where possible. .PP |
| ︙ | ︙ | |||
140 141 142 143 144 145 146 |
incr total $bytes
if {([string length $error] != 0) || [eof $in]} {
set done $total
close $in
close $out
} else {
\fBfcopy\fR $in $out -size $chunk \e
| | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
incr total $bytes
if {([string length $error] != 0) || [eof $in]} {
set done $total
close $in
close $out
} else {
\fBfcopy\fR $in $out -size $chunk \e
-command [list CopyMore $in $out $chunk]
}
}
set in [open $file1]
set out [socket $server $port]
set chunk 1024
set total 0
\fBfcopy\fR $in $out -size $chunk \e
-command [list CopyMore $in $out $chunk]
vwait done
.CE
.PP
The fourth example starts an asynchronous, bidirectional fcopy between
two sockets. Those could also be pipes from two [open "|hal 9000" r+]
(though their conversation would remain secret to the script, since
all four fileevent slots are busy).
|
| ︙ | ︙ |
Changes to doc/file.n.
| ︙ | ︙ | |||
238 239 240 241 242 243 244 | .QW \fB\-hard\fR . .PP On Unix, symbolic links can be made to relative paths, and those paths must be relative to the actual \fIlinkName\fR's location (not to the cwd), but on all other platforms where relative links are not supported, target paths will always be converted to absolute, normalized form before the link is created (and therefore relative paths are interpreted | < < < | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | .QW \fB\-hard\fR . .PP On Unix, symbolic links can be made to relative paths, and those paths must be relative to the actual \fIlinkName\fR's location (not to the cwd), but on all other platforms where relative links are not supported, target paths will always be converted to absolute, normalized form before the link is created (and therefore relative paths are interpreted as relative to the cwd). When creating links on filesystems that either do not support any links, or do not support the specific type requested, an error message will be returned. Most Unix platforms support both symbolic and hard links (the latter for files only). Windows supports symbolic directory links and hard file links on NTFS drives. .RE .TP \fBfile lstat \fIname ?varName?\fR |
| ︙ | ︙ | |||
567 568 569 570 571 572 573 | On Windows, a file can be .QW started easily enough (equivalent to double-clicking on it in the Explorer interface) but the name passed to the operating system must be in native format: .PP .CS | | | 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
On Windows, a file can be
.QW started
easily enough (equivalent to double-clicking on it in the Explorer
interface) but the name passed to the operating system must be in
native format:
.PP
.CS
exec {*}[auto_execok start] {} [\fBfile nativename\fR C:/Users/fred/example.txt]
.CE
.SH "SEE ALSO"
filename(n), open(n), close(n), eof(n), gets(n), tell(n), seek(n),
fblocked(n), flush(n)
.SH KEYWORDS
attributes, copy files, delete files, directory, file, move files, name,
rename files, stat, user
'\" Local Variables:
'\" mode: nroff
'\" fill-column: 78
'\" End:
|
Changes to doc/glob.n.
| ︙ | ︙ | |||
68 69 70 71 72 73 74 | named in any \fB\-directory\fR or \fB\-path\fR path specification. Thus .QW "\fBglob \-tails \-directory $dir *\fR" is equivalent to .QW "\fBset pwd [pwd]; cd $dir; glob *; cd $pwd\fR" . For \fB\-path\fR specifications, the returned names will include the last path segment, so | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | named in any \fB\-directory\fR or \fB\-path\fR path specification. Thus .QW "\fBglob \-tails \-directory $dir *\fR" is equivalent to .QW "\fBset pwd [pwd]; cd $dir; glob *; cd $pwd\fR" . For \fB\-path\fR specifications, the returned names will include the last path segment, so .QW "\fBglob \-tails \-path [file rootname /home/fred/foo.tex] .*\fR" will return paths like \fBfoo.aux foo.bib foo.tex\fR etc. .TP \fB\-types\fR \fItypeList\fR . Only list files or directories which match \fItypeList\fR, where the items in the list have two forms. The first form is like the \-type option of the Unix find command: |
| ︙ | ︙ | |||
164 165 166 167 168 169 170 | and .QW .. \| which must be matched explicitly (this is to avoid a recursive pattern like .QW "glob \-join * * * *" from recursing up the directory hierarchy as well as down). In addition, all .QW / characters must be matched explicitly. | < < < < < < < < < < | < < < < < < | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | and .QW .. \| which must be matched explicitly (this is to avoid a recursive pattern like .QW "glob \-join * * * *" from recursing up the directory hierarchy as well as down). In addition, all .QW / characters must be matched explicitly. .PP The \fBglob\fR command differs from csh globbing in two ways. First, it does not sort its result list (use the \fBlsort\fR command if you want the list sorted). Second, \fBglob\fR only returns the names of files that actually exist; in csh no check for existence is made unless a pattern contains a ?, *, or [] construct. .SH "WINDOWS PORTABILITY ISSUES" .PP For Windows UNC names, the servername and sharename components of the path may not contain ?, *, or [] constructs. .PP Since the backslash character has a special meaning to the glob command, glob patterns containing Windows style path separators need special care. The pattern .QW \fIC:\e\efoo\e\e*\fR is interpreted as .QW \fIC:\efoo\e*\fR |
| ︙ | ︙ | |||
225 226 227 228 229 230 231 | \fBglob\fR *.tcl .CE .PP Find all the Tcl files in the user's home directory, irrespective of what the current directory is: .PP .CS | | | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | \fBglob\fR *.tcl .CE .PP Find all the Tcl files in the user's home directory, irrespective of what the current directory is: .PP .CS \fBglob\fR \-directory [file home] *.tcl .CE .PP Find all subdirectories of the current directory: .PP .CS \fBglob\fR \-type d * .CE |
| ︙ | ︙ |
Changes to doc/info.n.
| ︙ | ︙ | |||
168 169 170 171 172 173 174 | .TP \fBeval\fR\0\0\0\0\0\0\0\0 . The body of a script provided to \fBeval\fR or \fBuplevel\fR. .TP \fBprecompiled\fR\0\0\0\0\0\0\0\0 . | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | .TP \fBeval\fR\0\0\0\0\0\0\0\0 . The body of a script provided to \fBeval\fR or \fBuplevel\fR. .TP \fBprecompiled\fR\0\0\0\0\0\0\0\0 . A precompiled script (loadable by the package \fBtbcload\fR), and no further information is available. .RE .TP \fBline\fR . The line number of of the command inside its script. Not available for \fBprecompiled\fR commands. When the type is \fBsource\fR, the line number is |
| ︙ | ︙ |
Changes to doc/memory.n.
| ︙ | ︙ | |||
37 38 39 40 41 42 43 | Tcl began, the current packets allocated (the current number of calls to \fBTcl_Alloc\fR not met by a corresponding call to \fBTcl_Free\fR), the current bytes allocated, and the maximum number of packets and bytes allocated. .TP \fBmemory init \fR[\fBon\fR|\fBoff\fR] . | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | Tcl began, the current packets allocated (the current number of calls to \fBTcl_Alloc\fR not met by a corresponding call to \fBTcl_Free\fR), the current bytes allocated, and the maximum number of packets and bytes allocated. .TP \fBmemory init \fR[\fBon\fR|\fBoff\fR] . Turn on or off the preinitialization of all allocated memory with bogus bytes. Useful for detecting the use of uninitialized values. .TP \fBmemory objs \fIfile\fR . Causes a list of all allocated Tcl_Obj values to be written to the specified \fIfile\fR immediately, together with where they were allocated. Useful for |
| ︙ | ︙ |
Changes to doc/namespace.n.
| ︙ | ︙ | |||
157 158 159 160 161 162 163 | current namespace that were imported from a different namespace. For .QW "qualified patterns" , this command first finds the matching exported commands. It then checks whether any of those commands were previously imported by the current namespace. If so, this command deletes the corresponding imported commands. | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | current namespace that were imported from a different namespace. For .QW "qualified patterns" , this command first finds the matching exported commands. It then checks whether any of those commands were previously imported by the current namespace. If so, this command deletes the corresponding imported commands. In effect, this undoes the action of a \fBnamespace import\fR command. .TP \fBnamespace import \fR?\fB\-force\fR? ?\fIpattern\fR \fIpattern ...\fR? . Imports commands into a namespace, or queries the set of imported commands in a namespace. When no arguments are present, \fBnamespace import\fR returns the list of commands in the current namespace that have been imported from other |
| ︙ | ︙ |
Changes to doc/next.n.
| ︙ | ︙ | |||
92 93 94 95 96 97 98 | a filter and once as a normal method. .PP Each filter should decide for itself whether to permit the execution to go forward to the proper implementation of the method (which it does by invoking the \fBnext\fR command as filters are inserted into the front of the method call chain) and is responsible for returning the result of \fBnext\fR. .PP | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | a filter and once as a normal method. .PP Each filter should decide for itself whether to permit the execution to go forward to the proper implementation of the method (which it does by invoking the \fBnext\fR command as filters are inserted into the front of the method call chain) and is responsible for returning the result of \fBnext\fR. .PP Filters are invoked when processing an invocation of the \fBunknown\fR method because of a failure to locate a method implementation, but \fInot\fR when invoking either constructors or destructors. (Note however that the \fBdestroy\fR method is a conventional method, and filters are invoked as normal when it is called.) .SH EXAMPLES .PP This example demonstrates how to use the \fBnext\fR command to call the |
| ︙ | ︙ |
Changes to doc/pkgMkIndex.n.
| ︙ | ︙ | |||
104 105 106 107 108 109 110 | \fB\-lazy\fR The generated index will manage to delay loading the package until the use of one of the commands provided by the package, instead of loading it immediately upon \fBpackage require\fR. This is not compatible with the use of \fIauto_reset\fR, and therefore its use is discouraged. .TP 15 \fB\-load \fIpkgPat\fR | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | \fB\-lazy\fR The generated index will manage to delay loading the package until the use of one of the commands provided by the package, instead of loading it immediately upon \fBpackage require\fR. This is not compatible with the use of \fIauto_reset\fR, and therefore its use is discouraged. .TP 15 \fB\-load \fIpkgPat\fR The index process will preload any packages that exist in the current interpreter and match \fIpkgPat\fR into the child interpreter used to generate the index. The pattern match uses string match rules, but without making case distinctions. See \fBCOMPLEX CASES\fR below. .TP 15 \fB\-verbose\fR Generate output during the indexing process. Output is via |
| ︙ | ︙ |
Changes to doc/refchan.n.
| ︙ | ︙ | |||
49 50 51 52 53 54 55 | (e.g.,\ \fBbreak\fR, etc.) is treated as (and converted to) an error. .PP \fBNote:\fR If the creation of the channel was aborted due to failures here, then the \fBfinalize\fR subcommand will not be called. .PP The \fImode\fR argument tells the handler whether the channel was opened for reading, writing, or both. It is a list containing any of | | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | (e.g.,\ \fBbreak\fR, etc.) is treated as (and converted to) an error. .PP \fBNote:\fR If the creation of the channel was aborted due to failures here, then the \fBfinalize\fR subcommand will not be called. .PP The \fImode\fR argument tells the handler whether the channel was opened for reading, writing, or both. It is a list containing any of the strings \fBread\fR or \fBwrite\fR. The list may be empty, but will usually contain at least one element. .PP The subcommand must throw an error if the chosen mode is not supported by the \fIcmdPrefix\fR. .RE .TP \fIcmdPrefix \fBfinalize \fIchannelId\fR . |
| ︙ | ︙ |
Changes to doc/tcltest.n.
| ︙ | ︙ | |||
621 622 623 624 625 626 627 | way to define any conditions required for the test to be possible or meaningful. For example, a \fBtest\fR with \fB\-constraints unix\fR will only be run if the constraint \fBunix\fR is true, which indicates the test suite is being run on a Unix platform. .PP Each \fBtest\fR should include whatever \fB\-constraints\fR are required to constrain it to run only where appropriate. Several | | | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | way to define any conditions required for the test to be possible or meaningful. For example, a \fBtest\fR with \fB\-constraints unix\fR will only be run if the constraint \fBunix\fR is true, which indicates the test suite is being run on a Unix platform. .PP Each \fBtest\fR should include whatever \fB\-constraints\fR are required to constrain it to run only where appropriate. Several constraints are predefined in the \fBtcltest\fR package, listed below. The registration of user-defined constraints is performed by the \fBtestConstraint\fR command. User-defined constraints may appear within a test file, or within the script specified by the \fBconfigure \-load\fR or \fBconfigure \-loadfile\fR options. .PP The following is a list of constraints predefined by the \fBtcltest\fR package itself: .TP \fIsingleTestInterp\fR . This test can only be run if all test files are sourced into a single interpreter. .TP |
| ︙ | ︙ |
Changes to doc/tclvars.n.
| ︙ | ︙ | |||
69 70 71 72 73 74 75 | will not work on Windows and is discouraged for cross-platform usage. .PP The following elements of \fBenv\fR are special to Tcl: .TP \fBenv(HOME)\fR . This environment variable, if set, gives the location of the directory | | < < | | > > | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | will not work on Windows and is discouraged for cross-platform usage. .PP The following elements of \fBenv\fR are special to Tcl: .TP \fBenv(HOME)\fR . This environment variable, if set, gives the location of the directory considered to be the current user's home directory. The value of this variable is returned by the \fBfile home\fR command. Most platforms set this correctly by default; it does not normally need to be set by user code. On Windows, if not already set, it is set to the value of the \fBUSERPROFILE\fR environment variable. .TP \fBenv(TCL_LIBRARY)\fR . If set, then it specifies the location of the directory containing library scripts (the value of this variable will be assigned to the \fBtcl_library\fR variable and therefore returned by the command \fBinfo library\fR). If this variable is not set then |
| ︙ | ︙ |
Changes to generic/regc_nfa.c.
| ︙ | ︙ | |||
483 484 485 486 487 488 489 |
victim->freechain = from->free;
from->free = victim;
}
/*
* changearctarget - flip an arc to have a different to state
*
| | | 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
victim->freechain = from->free;
from->free = victim;
}
/*
* changearctarget - flip an arc to have a different to state
*
* Caller must have verified that there is no preexisting duplicate arc.
*
* Note that because we store arcs in their from state, we can't easily have
* a similar changearcsource function.
*/
static void
changearctarget(struct arc * a, struct state * newto)
{
|
| ︙ | ︙ | |||
1511 1512 1513 1514 1515 1516 1517 | /* - pull - pull a back constraint backward past its source state * * Returns 1 if successful (which it always is unless the source is the * start state or we have an internal error), 0 if nothing happened. * | | | 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 | /* - pull - pull a back constraint backward past its source state * * Returns 1 if successful (which it always is unless the source is the * start state or we have an internal error), 0 if nothing happened. * * A significant property of this function is that it deletes no preexisting * states, and no outarcs of the constraint's from state other than the given * constraint arc. This makes the loops in pullback() safe, at the cost that * we may leave useless states behind. Therefore, we leave it to pullback() * to delete such states. * * If the from state has multiple back-constraint outarcs, and/or multiple * compatible constraint inarcs, we only need to create one new intermediate |
| ︙ | ︙ | |||
1690 1691 1692 1693 1694 1695 1696 | /* - push - push a forward constraint forward past its destination state * * Returns 1 if successful (which it always is unless the destination is the * post state or we have an internal error), 0 if nothing happened. * | | | 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 | /* - push - push a forward constraint forward past its destination state * * Returns 1 if successful (which it always is unless the destination is the * post state or we have an internal error), 0 if nothing happened. * * A significant property of this function is that it deletes no preexisting * states, and no inarcs of the constraint's to state other than the given * constraint arc. This makes the loops in pushfwd() safe, at the cost that * we may leave useless states behind. Therefore, we leave it to pushfwd() * to delete such states. * * If the to state has multiple forward-constraint inarcs, and/or multiple * compatible constraint outarcs, we only need to create one new intermediate |
| ︙ | ︙ | |||
2463 2464 2465 2466 2467 2468 2469 | * For each cloned successor state, we transiently create a "donemap" that is * a boolean array showing which source states we've already visited for this * clone state. This prevents infinite recursion as well as useless repeat * visits to the same state subtree (which can add up fast, since typical NFAs * have multiple redundant arc pathways). Each donemap is a char array * indexed by state number. The donemaps are all of the same size "nstates", * which is nfa->nstates as of the start of the recursion. This is enough to | | | 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 | * For each cloned successor state, we transiently create a "donemap" that is * a boolean array showing which source states we've already visited for this * clone state. This prevents infinite recursion as well as useless repeat * visits to the same state subtree (which can add up fast, since typical NFAs * have multiple redundant arc pathways). Each donemap is a char array * indexed by state number. The donemaps are all of the same size "nstates", * which is nfa->nstates as of the start of the recursion. This is enough to * have entries for all preexisting states, but *not* entries for clone * states created during the recursion. That's okay since we have no need to * mark those. * * curdonemap is NULL when recursing to a new sclone state, or sclone's * donemap when we are recursing without having created a new state (which we * do when we decide we can merge a successor state into the current clone * state). outerdonemap is NULL at the top level and otherwise the parent |
| ︙ | ︙ | |||
2770 2771 2772 2773 2774 2775 2776 |
}
}
/*
- analyze - ascertain potentially-useful facts about an optimized NFA
^ static long analyze(struct nfa *);
*/
| | | 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 |
}
}
/*
- analyze - ascertain potentially-useful facts about an optimized NFA
^ static long analyze(struct nfa *);
*/
static long /* re_info bits to be OR'ed in */
analyze(
struct nfa *nfa)
{
struct arc *a;
struct arc *aa;
if (nfa->pre->outs == NULL) {
|
| ︙ | ︙ |
Changes to generic/regcomp.c.
| ︙ | ︙ | |||
2180 2181 2182 2183 2184 2185 2186 |
* Big enough for hex int or decimal t->id?
*/
if (bufsize < sizeof(void*)*2 + 3 || bufsize < sizeof(t->id)*3 + 1) {
return "unable";
}
if (t->id != 0) {
| | | | 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 |
* Big enough for hex int or decimal t->id?
*/
if (bufsize < sizeof(void*)*2 + 3 || bufsize < sizeof(t->id)*3 + 1) {
return "unable";
}
if (t->id != 0) {
snprintf(buf, bufsize, "%d", t->id);
} else {
snprintf(buf, bufsize, "%p", t);
}
return buf;
}
#include "regc_lex.c"
#include "regc_color.c"
#include "regc_nfa.c"
|
| ︙ | ︙ |
Changes to generic/regerror.c.
| ︙ | ︙ | |||
69 70 71 72 73 74 75 |
switch (code) {
case REG_ATOI: /* Convert name to number */
for (r = rerrs; r->code >= 0; r++) {
if (strcmp(r->name, errbuf) == 0) {
break;
}
}
| | | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
switch (code) {
case REG_ATOI: /* Convert name to number */
for (r = rerrs; r->code >= 0; r++) {
if (strcmp(r->name, errbuf) == 0) {
break;
}
}
snprintf(convbuf, sizeof(convbuf), "%d", r->code); /* -1 for unknown */
msg = convbuf;
break;
case REG_ITOA: /* Convert number to name */
icode = atoi(errbuf); /* Not our problem if this fails */
for (r = rerrs; r->code >= 0; r++) {
if (r->code == icode) {
break;
}
}
if (r->code >= 0) {
msg = r->name;
} else { /* Unknown; tell him the number */
snprintf(convbuf, sizeof(convbuf), "REG_%u", icode);
msg = convbuf;
}
break;
default: /* A real, normal error code */
for (r = rerrs; r->code >= 0; r++) {
if (r->code == code) {
break;
}
}
if (r->code >= 0) {
msg = r->explain;
} else { /* Unknown; say so */
snprintf(convbuf, sizeof(convbuf), unk, code);
msg = convbuf;
}
break;
}
len = strlen(msg) + 1; /* Space needed, including NUL */
if (errbuf_size > 0) {
|
| ︙ | ︙ |
Changes to generic/regguts.h.
| ︙ | ︙ | |||
254 255 256 257 258 259 260 |
struct state *next; /* chain for traversing all */
struct state *prev; /* back chain */
struct arcbatch oas; /* first arcbatch, avoid malloc in easy case */
size_t noas; /* number of arcs used in first arcbatch */
};
struct nfa {
| | | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
struct state *next; /* chain for traversing all */
struct state *prev; /* back chain */
struct arcbatch oas; /* first arcbatch, avoid malloc in easy case */
size_t noas; /* number of arcs used in first arcbatch */
};
struct nfa {
struct state *pre; /* preinitial state */
struct state *init; /* initial state */
struct state *final; /* final state */
struct state *post; /* postfinal state */
size_t nstates; /* for numbering states */
struct state *states; /* state-chain header */
struct state *slast; /* tail of the chain */
struct state *free; /* free list */
struct colormap *cm; /* the color map */
color bos[2]; /* colors, if any, assigned to BOS and BOL */
color eos[2]; /* colors, if any, assigned to EOS and EOL */
|
| ︙ | ︙ |
Changes to generic/tcl.decls.
| ︙ | ︙ | |||
55 56 57 58 59 60 61 |
void Tcl_DbCkfree(void *ptr, const char *file, int line)
}
declare 8 {
void *Tcl_DbCkrealloc(void *ptr, TCL_HASH_TYPE size,
const char *file, int line)
}
| | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
void Tcl_DbCkfree(void *ptr, const char *file, int line)
}
declare 8 {
void *Tcl_DbCkrealloc(void *ptr, TCL_HASH_TYPE size,
const char *file, int line)
}
# Tcl_CreateFileHandler and Tcl_DeleteFileHandler are only available on Unix,
# but they are part of the old generic interface, so we include them here for
# compatibility reasons.
declare 9 {
void Tcl_CreateFileHandler(int fd, int mask, Tcl_FileProc *proc,
void *clientData)
}
|
| ︙ | ︙ | |||
2468 2469 2470 2471 2472 2473 2474 |
# TIP #568
declare 649 {
unsigned char *TclGetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
int *numBytesPtr)
}
declare 650 {
unsigned char *Tcl_GetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
| | | | | | 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 |
# TIP #568
declare 649 {
unsigned char *TclGetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
int *numBytesPtr)
}
declare 650 {
unsigned char *Tcl_GetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
Tcl_Size *numBytesPtr)
}
# TIP #481
declare 651 {
char *Tcl_GetStringFromObj(Tcl_Obj *objPtr, Tcl_Size *lengthPtr)
}
declare 652 {
Tcl_UniChar *Tcl_GetUnicodeFromObj(Tcl_Obj *objPtr, Tcl_Size *lengthPtr)
}
# Only available in Tcl 8.x, NULL in Tcl 9.0
declare 653 {
unsigned char *Tcl_GetByteArrayFromObj(Tcl_Obj *objPtr, Tcl_Size *numBytesPtr)
}
# TIP #575
declare 654 {
int Tcl_UtfCharComplete(const char *src, Tcl_Size length)
}
declare 655 {
|
| ︙ | ︙ | |||
2517 2518 2519 2520 2521 2522 2523 |
declare 660 {
int Tcl_AsyncMarkFromSignal(Tcl_AsyncHandler async, int sigNumber)
}
# TIP #616
declare 661 {
int Tcl_ListObjGetElements(Tcl_Interp *interp, Tcl_Obj *listPtr,
| | | | | | | | | 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 |
declare 660 {
int Tcl_AsyncMarkFromSignal(Tcl_AsyncHandler async, int sigNumber)
}
# TIP #616
declare 661 {
int Tcl_ListObjGetElements(Tcl_Interp *interp, Tcl_Obj *listPtr,
Tcl_Size *objcPtr, Tcl_Obj ***objvPtr)
}
declare 662 {
int Tcl_ListObjLength(Tcl_Interp *interp, Tcl_Obj *listPtr,
Tcl_Size *lengthPtr)
}
declare 663 {
int Tcl_DictObjSize(Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_Size *sizePtr)
}
declare 664 {
int Tcl_SplitList(Tcl_Interp *interp, const char *listStr, Tcl_Size *argcPtr,
const char ***argvPtr)
}
declare 665 {
void Tcl_SplitPath(const char *path, Tcl_Size *argcPtr, const char ***argvPtr)
}
declare 666 {
Tcl_Obj *Tcl_FSSplitPath(Tcl_Obj *pathPtr, Tcl_Size *lenPtr)
}
declare 667 {
int Tcl_ParseArgsObjv(Tcl_Interp *interp, const Tcl_ArgvInfo *argTable,
Tcl_Size *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv)
}
# TIP #617
declare 668 {
Tcl_Size Tcl_UniCharLen(const int *uniStr)
}
declare 669 {
|
| ︙ | ︙ | |||
2588 2589 2590 2591 2592 2593 2594 |
Tcl_Command Tcl_NRCreateCommand2(Tcl_Interp *interp,
const char *cmdName, Tcl_ObjCmdProc2 *proc,
Tcl_ObjCmdProc2 *nreProc2, void *clientData,
Tcl_CmdDeleteProc *deleteProc)
}
declare 679 {
int Tcl_NRCallObjProc2(Tcl_Interp *interp, Tcl_ObjCmdProc2 *objProc2,
| | | | 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 |
Tcl_Command Tcl_NRCreateCommand2(Tcl_Interp *interp,
const char *cmdName, Tcl_ObjCmdProc2 *proc,
Tcl_ObjCmdProc2 *nreProc2, void *clientData,
Tcl_CmdDeleteProc *deleteProc)
}
declare 679 {
int Tcl_NRCallObjProc2(Tcl_Interp *interp, Tcl_ObjCmdProc2 *objProc2,
void *clientData, ptrdiff_t objc, Tcl_Obj *const objv[])
}
# TIP #638.
declare 680 {
int Tcl_GetNumberFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
void **clientDataPtr, int *typePtr)
}
declare 681 {
int Tcl_GetNumber(Tcl_Interp *interp, const char *bytes, Tcl_Size numBytes,
void **clientDataPtr, int *typePtr)
}
# TIP #220.
declare 682 {
int Tcl_RemoveChannelMode(Tcl_Interp *interp, Tcl_Channel chan, int mode)
}
|
| ︙ | ︙ | |||
2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 |
Tcl_WideUInt *uwidePtr)
}
# TIP 651
declare 685 {
Tcl_Obj *Tcl_DStringToObj(Tcl_DString *dsPtr)
}
# ----- BASELINE -- FOR -- 8.7.0 / 9.0.0 ----- #
| > > > > > > | | 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 |
Tcl_WideUInt *uwidePtr)
}
# TIP 651
declare 685 {
Tcl_Obj *Tcl_DStringToObj(Tcl_DString *dsPtr)
}
# TIP 660
declare 686 {
int Tcl_GetSizeIntFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
Tcl_Size *sizePtr)
}
# ----- BASELINE -- FOR -- 8.7.0 / 9.0.0 ----- #
declare 688 {
void TclUnusedStubEntry(void)
}
##############################################################################
# Define the platform specific public Tcl interface. These functions are only
# available on the designated platform.
|
| ︙ | ︙ |
Changes to generic/tcl.h.
| ︙ | ︙ | |||
302 303 304 305 306 307 308 309 310 311 312 313 314 | # define TCL_Z_MODIFIER "z" # elif defined(_WIN64) # define TCL_Z_MODIFIER TCL_LL_MODIFIER # else # define TCL_Z_MODIFIER "" # endif #endif /* !TCL_Z_MODIFIER */ #define Tcl_WideAsLong(val) ((long)((Tcl_WideInt)(val))) #define Tcl_LongAsWide(val) ((Tcl_WideInt)((long)(val))) #define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val))) #define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val))) #if TCL_MAJOR_VERSION < 9 | > > > > > > > > > > | > > | > > | | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# define TCL_Z_MODIFIER "z"
# elif defined(_WIN64)
# define TCL_Z_MODIFIER TCL_LL_MODIFIER
# else
# define TCL_Z_MODIFIER ""
# endif
#endif /* !TCL_Z_MODIFIER */
#ifndef TCL_T_MODIFIER
# if defined(__GNUC__) && !defined(_WIN32)
# define TCL_T_MODIFIER "t"
# elif defined(_WIN64)
# define TCL_T_MODIFIER TCL_LL_MODIFIER
# else
# define TCL_T_MODIFIER TCL_Z_MODIFIER
# endif
#endif /* !TCL_T_MODIFIER */
#define Tcl_WideAsLong(val) ((long)((Tcl_WideInt)(val)))
#define Tcl_LongAsWide(val) ((Tcl_WideInt)((long)(val)))
#define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val)))
#define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val)))
#if TCL_MAJOR_VERSION < 9
typedef int Tcl_Size;
# define TCL_SIZE_MODIFIER ""
# define TCL_SIZE_MAX INT_MAX
#else
typedef ptrdiff_t Tcl_Size;
# define TCL_SIZE_MAX PTRDIFF_MAX
# define TCL_SIZE_MODIFIER TCL_T_MODIFIER
#endif /* TCL_MAJOR_VERSION */
#ifdef _WIN32
# if TCL_MAJOR_VERSION > 8 || defined(_WIN64) || defined(_USE_64BIT_TIME_T)
typedef struct __stat64 Tcl_StatBuf;
# elif defined(_USE_32BIT_TIME_T)
typedef struct _stati64 Tcl_StatBuf;
# else
|
| ︙ | ︙ | |||
446 447 448 449 450 451 452 | /* * Structures filled in by Tcl_RegExpInfo. Note that all offset values are * relative to the start of the match string, not the beginning of the entire * string. */ | < > > > > > > < < < < < < < < < < < < | < < > | 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
/*
* Structures filled in by Tcl_RegExpInfo. Note that all offset values are
* relative to the start of the match string, not the beginning of the entire
* string.
*/
typedef struct Tcl_RegExpIndices {
#if TCL_MAJOR_VERSION > 8
Tcl_Size start; /* Character offset of first character in
* match. */
Tcl_Size end; /* Character offset of first character after
* the match. */
#else
long start;
long end;
#endif
} Tcl_RegExpIndices;
typedef struct Tcl_RegExpInfo {
Tcl_Size nsubs; /* Number of subexpressions in the compiled
* expression. */
Tcl_RegExpIndices *matches; /* Array of nsubs match offset pairs. */
#if TCL_MAJOR_VERSION > 8
Tcl_Size extendStart; /* The offset at which a subsequent match
* might begin. */
#else
long extendStart;
long reserved; /* Reserved for later use. */
#endif
} Tcl_RegExpInfo;
/*
* Picky compilers complain if this typdef doesn't appear before the struct's
* reference in tclDecls.h.
*/
typedef Tcl_StatBuf *Tcl_Stat_;
|
| ︙ | ︙ | |||
551 552 553 554 555 556 557 | typedef void (Tcl_CmdTraceProc) (void *clientData, Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc, void *cmdClientData, int argc, const char *argv[]); typedef int (Tcl_CmdObjTraceProc) (void *clientData, Tcl_Interp *interp, int level, const char *command, Tcl_Command commandInfo, int objc, struct Tcl_Obj *const *objv); typedef int (Tcl_CmdObjTraceProc2) (void *clientData, Tcl_Interp *interp, | | | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | typedef void (Tcl_CmdTraceProc) (void *clientData, Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc, void *cmdClientData, int argc, const char *argv[]); typedef int (Tcl_CmdObjTraceProc) (void *clientData, Tcl_Interp *interp, int level, const char *command, Tcl_Command commandInfo, int objc, struct Tcl_Obj *const *objv); typedef int (Tcl_CmdObjTraceProc2) (void *clientData, Tcl_Interp *interp, ptrdiff_t level, const char *command, Tcl_Command commandInfo, ptrdiff_t objc, struct Tcl_Obj *const *objv); typedef void (Tcl_CmdObjTraceDeleteProc) (void *clientData); typedef void (Tcl_DupInternalRepProc) (struct Tcl_Obj *srcPtr, struct Tcl_Obj *dupPtr); typedef int (Tcl_EncodingConvertProc) (void *clientData, const char *src, int srcLen, int flags, Tcl_EncodingState *statePtr, char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr); |
| ︙ | ︙ | |||
576 577 578 579 580 581 582 | typedef void (Tcl_IdleProc) (void *clientData); typedef void (Tcl_InterpDeleteProc) (void *clientData, Tcl_Interp *interp); typedef void (Tcl_NamespaceDeleteProc) (void *clientData); typedef int (Tcl_ObjCmdProc) (void *clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj *const *objv); typedef int (Tcl_ObjCmdProc2) (void *clientData, Tcl_Interp *interp, | | | 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | typedef void (Tcl_IdleProc) (void *clientData); typedef void (Tcl_InterpDeleteProc) (void *clientData, Tcl_Interp *interp); typedef void (Tcl_NamespaceDeleteProc) (void *clientData); typedef int (Tcl_ObjCmdProc) (void *clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj *const *objv); typedef int (Tcl_ObjCmdProc2) (void *clientData, Tcl_Interp *interp, ptrdiff_t objc, struct Tcl_Obj *const *objv); typedef int (Tcl_LibraryInitProc) (Tcl_Interp *interp); typedef int (Tcl_LibraryUnloadProc) (Tcl_Interp *interp, int flags); typedef void (Tcl_PanicProc) (const char *format, ...); typedef void (Tcl_TcpAcceptProc) (void *callbackData, Tcl_Channel chan, char *address, int port); typedef void (Tcl_TimerProc) (void *clientData); typedef int (Tcl_SetFromAnyProc) (Tcl_Interp *interp, struct Tcl_Obj *objPtr); |
| ︙ | ︙ | |||
1819 1820 1821 1822 1823 1824 1825 | * is described by a TCL_TOKEN_SUB_EXPR token * followed by the TCL_TOKEN_OPERATOR token for * the operator, then TCL_TOKEN_SUB_EXPR tokens * for the left then the right operands. * TCL_TOKEN_OPERATOR - The token describes one expression operator. * An operator might be the name of a math * function such as "abs". A TCL_TOKEN_OPERATOR | | | 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 |
* is described by a TCL_TOKEN_SUB_EXPR token
* followed by the TCL_TOKEN_OPERATOR token for
* the operator, then TCL_TOKEN_SUB_EXPR tokens
* for the left then the right operands.
* TCL_TOKEN_OPERATOR - The token describes one expression operator.
* An operator might be the name of a math
* function such as "abs". A TCL_TOKEN_OPERATOR
* token is always preceded by one
* TCL_TOKEN_SUB_EXPR token for the operator's
* subexpression, and is followed by zero or more
* TCL_TOKEN_SUB_EXPR tokens for the operator's
* operands. NumComponents is always 0.
* TCL_TOKEN_EXPAND_WORD - This token is just like TCL_TOKEN_WORD except
* that it marks a word that began with the
* literal character prefix "{*}". This word is
|
| ︙ | ︙ | |||
2038 2039 2040 2041 2042 2043 2044 | * routine should pass the beginning of this * unconverted sequence plus additional bytes * from the source stream to properly convert the * formerly split-up multibyte sequence. * TCL_CONVERT_SYNTAX - The source stream contained an invalid * character sequence. This may occur if the * input stream has been damaged or if the input | | < < | < | | | | | | 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 | * routine should pass the beginning of this * unconverted sequence plus additional bytes * from the source stream to properly convert the * formerly split-up multibyte sequence. * TCL_CONVERT_SYNTAX - The source stream contained an invalid * character sequence. This may occur if the * input stream has been damaged or if the input * encoding method was misidentified. * TCL_CONVERT_UNKNOWN - The source string contained a character that * could not be represented in the target * encoding. */ #define TCL_CONVERT_MULTIBYTE (-1) #define TCL_CONVERT_SYNTAX (-2) #define TCL_CONVERT_UNKNOWN (-3) #define TCL_CONVERT_NOSPACE (-4) /* * The maximum number of bytes that are necessary to represent a single * Unicode character in UTF-8. The valid values are 3 and 4 * (or perhaps 1 if we want to support a non-unicode enabled core). If > 3, * then Tcl_UniChar must be 4-bytes in size (UCS-4) (the default). If == 3, * then Tcl_UniChar must be 2-bytes in size (UTF-16). Since Tcl 9.0, UCS-4 * mode is the default and recommended mode. */ #ifndef TCL_UTF_MAX # if TCL_MAJOR_VERSION > 8 # define TCL_UTF_MAX 4 # else # define TCL_UTF_MAX 3 # endif #endif /* * This represents a Unicode character. Any changes to this should also be * reflected in regcustom.h. */ |
| ︙ | ︙ | |||
2368 2369 2370 2371 2372 2373 2374 | EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); #endif #if defined(_WIN32) && defined(UNICODE) #ifndef USE_TCL_STUBS # define Tcl_FindExecutable(arg) ((Tcl_FindExecutable)((const char *)(arg))) #endif # define Tcl_MainEx Tcl_MainExW | | | | 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 |
EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv);
#endif
#if defined(_WIN32) && defined(UNICODE)
#ifndef USE_TCL_STUBS
# define Tcl_FindExecutable(arg) ((Tcl_FindExecutable)((const char *)(arg)))
#endif
# define Tcl_MainEx Tcl_MainExW
EXTERN TCL_NORETURN void Tcl_MainExW(Tcl_Size argc, wchar_t **argv,
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
#endif
#if defined(USE_TCL_STUBS) && (TCL_MAJOR_VERSION > 8)
#define Tcl_SetPanicProc(panicProc) \
TclInitStubTable(((const char *(*)(Tcl_PanicProc *))TclStubCall((void *)panicProc))(panicProc))
#define Tcl_InitSubsystems() \
TclInitStubTable(((const char *(*)(void))TclStubCall((void *)1))())
#define Tcl_FindExecutable(argv0) \
TclInitStubTable(((const char *(*)(const char *))TclStubCall((void *)2))(argv0))
#define TclZipfs_AppHook(argcp, argvp) \
TclInitStubTable(((const char *(*)(int *, void *))TclStubCall((void *)3))(argcp, argvp))
#define Tcl_MainExW(argc, argv, appInitProc, interp) \
(void)((const char *(*)(Tcl_Size, const void *, Tcl_AppInitProc *, Tcl_Interp *)) \
TclStubCall((void *)4))(argc, argv, appInitProc, interp)
#if !defined(_WIN32) || !defined(UNICODE)
#define Tcl_MainEx(argc, argv, appInitProc, interp) \
(void)((const char *(*)(size_t, const void *, Tcl_AppInitProc *, Tcl_Interp *)) \
TclStubCall((void *)5))(argc, argv, appInitProc, interp)
#endif
#define Tcl_StaticLibrary(interp, pkgName, initProc, safeInitProc) \
|
| ︙ | ︙ |
Changes to generic/tclAlloc.c.
| ︙ | ︙ | |||
112 113 114 115 116 117 118 |
static struct block *blockList; /* Tracks the suballocated blocks. */
static struct block bigBlocks={ /* Big blocks aren't suballocated. */
&bigBlocks, &bigBlocks
};
/*
* The allocator is protected by a special mutex that must be explicitly
| | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
static struct block *blockList; /* Tracks the suballocated blocks. */
static struct block bigBlocks={ /* Big blocks aren't suballocated. */
&bigBlocks, &bigBlocks
};
/*
* The allocator is protected by a special mutex that must be explicitly
* initialized. Furthermore, because Tcl_Alloc may be used before anything else
* in Tcl, we make this module self-initializing after all with the allocInit
* variable.
*/
#if TCL_THREADS
static Tcl_Mutex *allocMutexPtr;
#endif
|
| ︙ | ︙ | |||
506 507 508 509 510 511 512 | * None. * *---------------------------------------------------------------------- */ void * TclpRealloc( | | | 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
* None.
*
*----------------------------------------------------------------------
*/
void *
TclpRealloc(
void *oldPtr, /* Pointer to alloc'ed block. */
size_t numBytes) /* New size of memory. */
{
int i;
union overhead *overPtr;
struct block *bigBlockPtr;
int expensive;
size_t maxSize;
|
| ︙ | ︙ | |||
605 606 607 608 609 610 611 |
}
memcpy(newPtr, oldPtr, numBytes);
TclpFree(oldPtr);
return newPtr;
}
/*
| | | 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
}
memcpy(newPtr, oldPtr, numBytes);
TclpFree(oldPtr);
return newPtr;
}
/*
* No need to copy. It fits as-is.
*/
#ifndef NDEBUG
overPtr->realBlockSize = (numBytes + RSLOP - 1) & ~(RSLOP - 1);
BLOCK_END(overPtr) = RMAGIC;
#endif
|
| ︙ | ︙ |
Changes to generic/tclArithSeries.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* * tclArithSeries.c -- * * This file contains the ArithSeries concrete abstract list * implementation. It implements the inner workings of the lseq command. * * Copyright © 2022 Brian S. Griffin. * * 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 <assert.h> /* * The structure below defines the arithmetic series Tcl object type by * means of procedures that can be invoked by generic object code. * * The arithmetic series object is a special case of Tcl list representing * an interval of an arithmetic series in constant space. | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /* * tclArithSeries.c -- * * This file contains the ArithSeries concrete abstract list * implementation. It implements the inner workings of the lseq command. * * Copyright © 2022 Brian S. Griffin. * * 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 "tclInt.h" #include <assert.h> #include <math.h> /* * The structure below defines the arithmetic series Tcl object type by * means of procedures that can be invoked by generic object code. * * The arithmetic series object is a special case of Tcl list representing * an interval of an arithmetic series in constant space. |
| ︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 |
typedef struct {
Tcl_Size len;
Tcl_Obj **elements;
int isDouble;
double start;
double end;
double step;
} ArithSeriesDbl;
| > | | < < < < < < < < | | > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
typedef struct {
Tcl_Size len;
Tcl_Obj **elements;
int isDouble;
double start;
double end;
double step;
int precision;
} ArithSeriesDbl;
/* -------------------------- ArithSeries object ---------------------------- */
static int TclArithSeriesObjIndex(TCL_UNUSED(Tcl_Interp *), Tcl_Obj *arithSeriesObj,
Tcl_Size index, Tcl_Obj **elemObj);
static Tcl_Size ArithSeriesObjLength(Tcl_Obj *arithSeriesObj);
static int TclArithSeriesObjRange(Tcl_Interp *interp, Tcl_Obj *arithSeriesObj,
Tcl_Size fromIdx, Tcl_Size toIdx, Tcl_Obj **newObjPtr);
static int TclArithSeriesObjReverse(Tcl_Interp *interp, Tcl_Obj *arithSeriesObj, Tcl_Obj **newObjPtr);
static int TclArithSeriesGetElements(Tcl_Interp *interp,
Tcl_Obj *objPtr, Tcl_Size *objcPtr, Tcl_Obj ***objvPtr);
static void DupArithSeriesInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr);
|
| ︙ | ︙ | |||
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
TclArithSeriesObjReverse,
TclArithSeriesGetElements,
NULL, // SetElement
NULL, // Replace
NULL) // GetDouble
};
/*
*----------------------------------------------------------------------
*
* ArithSeriesLen --
*
* Compute the length of the equivalent list where
* every element is generated starting from *start*,
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
TclArithSeriesObjReverse,
TclArithSeriesGetElements,
NULL, // SetElement
NULL, // Replace
NULL) // GetDouble
};
/*
* Helper functions
*
* - ArithRound -- Round doubles to the number of significant fractional
* digits
* - ArithSeriesIndexDbl -- base list indexing operation for doubles
* - ArithSeriesIndexInt -- " " " " " integers
* - ArithSeriesGetInternalRep -- Return the internal rep from a Tcl_Obj
* - Precision -- determine the number of factional digits for the given
* double value
* - maxPrecision -- Using the values provide, determine the longest percision
* in the arithSeries
*/
static inline double
ArithRound(double d, unsigned int n) {
double scalefactor = pow(10, n);
return round(d*scalefactor)/scalefactor;
}
static inline double
ArithSeriesIndexDbl(
ArithSeries *arithSeriesRepPtr,
Tcl_WideInt index)
{
ArithSeriesDbl *dblRepPtr = (ArithSeriesDbl*)arithSeriesRepPtr;
if (arithSeriesRepPtr->isDouble) {
double d = dblRepPtr->start + (index * dblRepPtr->step);
unsigned n = (dblRepPtr->precision > 0 ? dblRepPtr->precision : 0);
return ArithRound(d, n);
} else {
return (double)(arithSeriesRepPtr->start + (index * arithSeriesRepPtr->step));
}
}
static inline Tcl_WideInt
ArithSeriesIndexInt(
ArithSeries *arithSeriesRepPtr,
Tcl_WideInt index)
{
ArithSeriesDbl *dblRepPtr = (ArithSeriesDbl*)arithSeriesRepPtr;
if (arithSeriesRepPtr->isDouble) {
return (Tcl_WideInt)(dblRepPtr->start + ((index) * dblRepPtr->step));
} else {
return (arithSeriesRepPtr->start + (index * arithSeriesRepPtr->step));
}
}
static inline ArithSeries*
ArithSeriesGetInternalRep(Tcl_Obj *objPtr)
{
const Tcl_ObjInternalRep *irPtr;
irPtr = TclFetchInternalRep((objPtr), &arithSeriesType);
return irPtr ? (ArithSeries *)irPtr->twoPtrValue.ptr1 : NULL;
}
static inline int
Precision(double d)
{
char tmp[TCL_DOUBLE_SPACE+2], *off;
tmp[0] = 0;
Tcl_PrintDouble(NULL,d,tmp);
off = strchr(tmp, '.');
return (off ? strlen(off+1) : 0);
}
static inline int
maxPrecision(double start, double end, double step)
{
// Find longest number of digits after the decimal point.
int dp = Precision(step);
int i = Precision(start);
dp = i>dp ? i : dp;
i = Precision(end);
dp = i>dp ? i : dp;
return dp;
}
static int TclArithSeriesObjStep(Tcl_Obj *arithSeriesObj, Tcl_Obj **stepObj);
/*
*----------------------------------------------------------------------
*
* ArithSeriesLen --
*
* Compute the length of the equivalent list where
* every element is generated starting from *start*,
|
| ︙ | ︙ | |||
123 124 125 126 127 128 129 | * Side effects: * * None. * *---------------------------------------------------------------------- */ static Tcl_WideInt | | > > > > > > > > > > > > > | | < | | > > | | | | < < | > | | < | > | | > > > > | > > | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
* Side effects:
*
* None.
*
*----------------------------------------------------------------------
*/
static Tcl_WideInt
ArithSeriesLenInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step)
{
Tcl_WideInt len;
if (step == 0) {
return 0;
}
len = 1 + ((end-start)/step);
return (len < 0) ? -1 : len;
}
static Tcl_WideInt
ArithSeriesLenDbl(double start, double end, double step)
{
Tcl_WideInt len;
if (step == 0) {
return 0;
}
len = ((end-start+step)/step);
return (len < 0) ? -1 : len;
}
/*
*----------------------------------------------------------------------
*
* DupArithSeriesInternalRep --
*
* Initialize the internal representation of a arithseries Tcl_Obj to a
* copy of the internal representation of an existing arithseries object.
*
* Results:
* None.
*
* Side effects:
* We set "copyPtr"s internal rep to a pointer to a
* newly allocated ArithSeries structure.
*----------------------------------------------------------------------
*/
static void
DupArithSeriesInternalRep(
Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
Tcl_Obj *copyPtr) /* Object with internal rep to set. */
{
ArithSeries *srcArithSeriesRepPtr =
(ArithSeries *) srcPtr->internalRep.twoPtrValue.ptr1;
/*
* Allocate a new ArithSeries structure. */
if (srcArithSeriesRepPtr->isDouble) {
ArithSeriesDbl *srcArithSeriesDblRepPtr =
(ArithSeriesDbl *)srcArithSeriesRepPtr;
ArithSeriesDbl *copyArithSeriesDblRepPtr =
(ArithSeriesDbl *) Tcl_Alloc(sizeof(ArithSeriesDbl));
*copyArithSeriesDblRepPtr = *srcArithSeriesDblRepPtr;
copyArithSeriesDblRepPtr->elements = NULL;
copyPtr->internalRep.twoPtrValue.ptr1 = copyArithSeriesDblRepPtr;
} else {
ArithSeries *copyArithSeriesRepPtr =
(ArithSeries *) Tcl_Alloc(sizeof(ArithSeries));
*copyArithSeriesRepPtr = *srcArithSeriesRepPtr;
copyArithSeriesRepPtr->elements = NULL;
copyPtr->internalRep.twoPtrValue.ptr1 = copyArithSeriesRepPtr;
}
copyPtr->internalRep.twoPtrValue.ptr2 = NULL;
copyPtr->typePtr = &arithSeriesType;
}
/*
*----------------------------------------------------------------------
*
* FreeArithSeriesInternalRep --
*
|
| ︙ | ︙ | |||
228 229 230 231 232 233 234 |
* None.
*----------------------------------------------------------------------
*/
static
Tcl_Obj *
NewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_WideInt len)
{
| | > > > | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
* None.
*----------------------------------------------------------------------
*/
static
Tcl_Obj *
NewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_WideInt len)
{
Tcl_WideInt length;
Tcl_Obj *arithSeriesObj;
ArithSeries *arithSeriesRepPtr;
length = len>=0 ? len : -1;
if (length < 0) length = -1;
TclNewObj(arithSeriesObj);
if (length <= 0) {
return arithSeriesObj;
}
arithSeriesRepPtr = (ArithSeries*) Tcl_Alloc(sizeof (ArithSeries));
|
| ︙ | ︙ | |||
272 273 274 275 276 277 278 279 280 281 282 |
* A NULL pointer of the range is invalid.
*
* Side Effects:
*
* None.
*----------------------------------------------------------------------
*/
static
Tcl_Obj *
NewArithSeriesDbl(double start, double end, double step, Tcl_WideInt len)
{
| > | > > > > > > > | > | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
* A NULL pointer of the range is invalid.
*
* Side Effects:
*
* None.
*----------------------------------------------------------------------
*/
static
Tcl_Obj *
NewArithSeriesDbl(double start, double end, double step, Tcl_WideInt len)
{
Tcl_WideInt length;
Tcl_Obj *arithSeriesObj;
ArithSeriesDbl *arithSeriesRepPtr;
length = len>=0 ? len : -1;
if (length < 0) {
length = -1;
}
TclNewObj(arithSeriesObj);
if (length <= 0) {
return arithSeriesObj;
}
arithSeriesRepPtr = (ArithSeriesDbl*) Tcl_Alloc(sizeof (ArithSeriesDbl));
arithSeriesRepPtr->isDouble = 1;
arithSeriesRepPtr->start = start;
arithSeriesRepPtr->end = end;
arithSeriesRepPtr->step = step;
arithSeriesRepPtr->len = length;
arithSeriesRepPtr->elements = NULL;
arithSeriesRepPtr->precision = maxPrecision(start,end,step);
arithSeriesObj->internalRep.twoPtrValue.ptr1 = arithSeriesRepPtr;
arithSeriesObj->internalRep.twoPtrValue.ptr2 = NULL;
arithSeriesObj->typePtr = &arithSeriesType;
if (length > 0) {
Tcl_InvalidateStringRep(arithSeriesObj);
}
return arithSeriesObj;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
383 384 385 386 387 388 389 |
Tcl_Obj *startObj, /* Starting value */
Tcl_Obj *endObj, /* Ending limit */
Tcl_Obj *stepObj, /* increment value */
Tcl_Obj *lenObj) /* Number of elements */
{
double dstart, dend, dstep;
Tcl_WideInt start, end, step;
| | | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
Tcl_Obj *startObj, /* Starting value */
Tcl_Obj *endObj, /* Ending limit */
Tcl_Obj *stepObj, /* increment value */
Tcl_Obj *lenObj) /* Number of elements */
{
double dstart, dend, dstep;
Tcl_WideInt start, end, step;
Tcl_WideInt len = -1;
if (startObj) {
assignNumber(useDoubles, &start, &dstart, startObj);
} else {
start = 0;
dstart = start;
}
|
| ︙ | ︙ | |||
425 426 427 428 429 430 431 |
step = (start < end) ? 1 : -1;
dstep = step;
}
}
assert(dstep!=0);
if (!lenObj) {
if (useDoubles) {
| | | | > | | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
step = (start < end) ? 1 : -1;
dstep = step;
}
}
assert(dstep!=0);
if (!lenObj) {
if (useDoubles) {
len = ArithSeriesLenDbl(dstart, dend, dstep);
} else {
len = ArithSeriesLenInt(start, end, step);
}
}
}
if (!endObj) {
if (useDoubles) {
dend = dstart + (dstep * (len-1));
end = dend;
} else {
end = start + (step * (len-1));
dend = end;
}
}
if ((TCL_MAJOR_VERSION < 9 && ((len > ListSizeT_MAX))) ||
(len > TCL_SIZE_MAX)) {
Tcl_SetObjResult(
interp,
Tcl_NewStringObj("max length of a Tcl list exceeded", -1));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
return TCL_ERROR;
}
if (arithSeriesObj) {
*arithSeriesObj = (useDoubles)
? NewArithSeriesDbl(dstart, dend, dstep, len)
|
| ︙ | ︙ | |||
482 483 484 485 486 487 488 | * On success, the integer pointed by *element is modified. * *---------------------------------------------------------------------- */ int TclArithSeriesObjIndex( | | | | | > > | < < | 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
* On success, the integer pointed by *element is modified.
*
*----------------------------------------------------------------------
*/
int
TclArithSeriesObjIndex(
TCL_UNUSED(Tcl_Interp *),/* Used for error reporting if not NULL. */
Tcl_Obj *arithSeriesObj, /* List obj */
Tcl_Size index, /* index to element of interest */
Tcl_Obj **elemObj) /* Return value */
{
ArithSeries *arithSeriesRepPtr = ArithSeriesGetInternalRep(arithSeriesObj);
if (index < 0 || arithSeriesRepPtr->len <= index) {
*elemObj = Tcl_NewObj();
} else {
/* List[i] = Start + (Step * index) */
if (arithSeriesRepPtr->isDouble) {
*elemObj = Tcl_NewDoubleObj(ArithSeriesIndexDbl(arithSeriesRepPtr, index));
} else {
*elemObj = Tcl_NewWideIntObj(ArithSeriesIndexInt(arithSeriesRepPtr, index));
}
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
551 552 553 554 555 556 557 |
*/
int
TclArithSeriesObjStep(
Tcl_Obj *arithSeriesObj,
Tcl_Obj **stepObj)
{
| | > | 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
*/
int
TclArithSeriesObjStep(
Tcl_Obj *arithSeriesObj,
Tcl_Obj **stepObj)
{
ArithSeries *arithSeriesRepPtr = ArithSeriesGetInternalRep(arithSeriesObj);
if (arithSeriesRepPtr->isDouble) {
*stepObj = Tcl_NewDoubleObj(((ArithSeriesDbl*)(arithSeriesRepPtr))->step);
} else {
*stepObj = Tcl_NewWideIntObj(arithSeriesRepPtr->step);
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* SetArithSeriesFromAny --
*
* The Arithmetic Series object is just an way to optimize
|
| ︙ | ︙ | |||
623 624 625 626 627 628 629 |
Tcl_Obj **newObjPtr) /* return value */
{
ArithSeries *arithSeriesRepPtr;
Tcl_Obj *startObj, *endObj, *stepObj;
(void)interp; /* silence compiler */
| | > > > > > > > > > > | 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 |
Tcl_Obj **newObjPtr) /* return value */
{
ArithSeries *arithSeriesRepPtr;
Tcl_Obj *startObj, *endObj, *stepObj;
(void)interp; /* silence compiler */
arithSeriesRepPtr = ArithSeriesGetInternalRep(arithSeriesObj);
if (fromIdx == TCL_INDEX_NONE) {
fromIdx = 0;
}
if (toIdx >= arithSeriesRepPtr->len) {
toIdx = arithSeriesRepPtr->len-1;
}
if (fromIdx > toIdx ||
fromIdx >= arithSeriesRepPtr->len) {
TclNewObj(*newObjPtr);
return TCL_OK;
}
if (fromIdx < 0) {
fromIdx = 0;
}
if (toIdx < 0) {
toIdx = 0;
}
if (toIdx > arithSeriesRepPtr->len-1) {
toIdx = arithSeriesRepPtr->len-1;
}
TclArithSeriesObjIndex(interp, arithSeriesObj, fromIdx, &startObj);
Tcl_IncrRefCount(startObj);
TclArithSeriesObjIndex(interp, arithSeriesObj, toIdx, &endObj);
Tcl_IncrRefCount(endObj);
TclArithSeriesObjStep(arithSeriesObj, &stepObj);
Tcl_IncrRefCount(stepObj);
|
| ︙ | ︙ | |||
669 670 671 672 673 674 675 |
* Even if nothing below causes any changes, we still want the
* string-canonizing effect of [lrange 0 end].
*/
TclInvalidateStringRep(arithSeriesObj);
if (arithSeriesRepPtr->isDouble) {
| | > > | | | 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 |
* Even if nothing below causes any changes, we still want the
* string-canonizing effect of [lrange 0 end].
*/
TclInvalidateStringRep(arithSeriesObj);
if (arithSeriesRepPtr->isDouble) {
ArithSeriesDbl *arithSeriesDblRepPtr = (ArithSeriesDbl*)arithSeriesRepPtr;
double start, end, step;
Tcl_GetDoubleFromObj(NULL, startObj, &start);
Tcl_GetDoubleFromObj(NULL, endObj, &end);
Tcl_GetDoubleFromObj(NULL, stepObj, &step);
arithSeriesDblRepPtr->start = start;
arithSeriesDblRepPtr->end = end;
arithSeriesDblRepPtr->step = step;
arithSeriesDblRepPtr->precision = maxPrecision(start, end, step);
arithSeriesDblRepPtr->len = ArithSeriesLenDbl(start, end, step);
arithSeriesDblRepPtr->elements = NULL;
} else {
Tcl_WideInt start, end, step;
Tcl_GetWideIntFromObj(NULL, startObj, &start);
Tcl_GetWideIntFromObj(NULL, endObj, &end);
Tcl_GetWideIntFromObj(NULL, stepObj, &step);
arithSeriesRepPtr->start = start;
arithSeriesRepPtr->end = end;
arithSeriesRepPtr->step = step;
arithSeriesRepPtr->len = ArithSeriesLenInt(start, end, step);
arithSeriesRepPtr->elements = NULL;
}
Tcl_DecrRefCount(startObj);
Tcl_DecrRefCount(endObj);
Tcl_DecrRefCount(stepObj);
|
| ︙ | ︙ | |||
744 745 746 747 748 749 750 |
* pointers to the list's objects. */
{
if (TclHasInternalRep(objPtr,&arithSeriesType)) {
ArithSeries *arithSeriesRepPtr;
Tcl_Obj **objv;
int i, objc;
| | | | 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 |
* pointers to the list's objects. */
{
if (TclHasInternalRep(objPtr,&arithSeriesType)) {
ArithSeries *arithSeriesRepPtr;
Tcl_Obj **objv;
int i, objc;
arithSeriesRepPtr = ArithSeriesGetInternalRep(objPtr);
objc = arithSeriesRepPtr->len;
if (objc > 0) {
if (arithSeriesRepPtr->elements) {
/* If this exists, it has already been populated */
objv = arithSeriesRepPtr->elements;
} else {
/* Construct the elements array */
objv = (Tcl_Obj **)Tcl_Alloc(sizeof(Tcl_Obj*) * objc);
if (objv == NULL) {
if (interp) {
Tcl_SetObjResult(
interp,
Tcl_NewStringObj("max length of a Tcl list exceeded", -1));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
return TCL_ERROR;
}
arithSeriesRepPtr->elements = objv;
for (i = 0; i < objc; i++) {
int status = TclArithSeriesObjIndex(interp, objPtr, i, &objv[i]);
|
| ︙ | ︙ | |||
812 813 814 815 816 817 818 |
(void)interp;
if (newObjPtr == NULL) {
return TCL_ERROR;
}
| | | 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
(void)interp;
if (newObjPtr == NULL) {
return TCL_ERROR;
}
arithSeriesRepPtr = ArithSeriesGetInternalRep(arithSeriesObj);
isDouble = arithSeriesRepPtr->isDouble;
len = arithSeriesRepPtr->len;
TclArithSeriesObjIndex(NULL, arithSeriesObj, (len-1), &startObj);
Tcl_IncrRefCount(startObj);
TclArithSeriesObjIndex(NULL, arithSeriesObj, 0, &endObj);
|
| ︙ | ︙ | |||
923 924 925 926 927 928 929 |
*----------------------------------------------------------------------
*/
static void
UpdateStringOfArithSeries(Tcl_Obj *arithSeriesObjPtr)
{
ArithSeries *arithSeriesRepPtr = (ArithSeries*)Tcl_ObjGetConcreteRep(arithSeriesObjPtr);
| | | < | | | | > | > | | < | > | < > | | > | > > | | > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 |
*----------------------------------------------------------------------
*/
static void
UpdateStringOfArithSeries(Tcl_Obj *arithSeriesObjPtr)
{
ArithSeries *arithSeriesRepPtr = (ArithSeries*)Tcl_ObjGetConcreteRep(arithSeriesObjPtr);
char *p;
Tcl_Obj *eleObj;
Tcl_Size i, bytlen = 0;
/*
* Pass 1: estimate space.
*/
if (!arithSeriesRepPtr->isDouble) {
for (i = 0; i < arithSeriesRepPtr->len; i++) {
double d = ArithSeriesIndexDbl(arithSeriesRepPtr, i);
size_t slen = d>0 ? log10(d)+1 : d<0 ? log10((0-d))+2 : 1;
bytlen += slen;
}
} else {
for (i = 0; i < arithSeriesRepPtr->len; i++) {
double d = ArithSeriesIndexDbl(arithSeriesRepPtr, i);
char tmp[TCL_DOUBLE_SPACE+2];
tmp[0] = 0;
Tcl_PrintDouble(NULL,d,tmp);
if ((bytlen + strlen(tmp)) > TCL_SIZE_MAX) {
break; // overflow
}
bytlen += strlen(tmp);
}
}
bytlen += arithSeriesRepPtr->len; // Space for each separator
/*
* Pass 2: generate the string repr.
*/
p = Tcl_InitStringRep(arithSeriesObjPtr, NULL, bytlen);
for (i = 0; i < arithSeriesRepPtr->len; i++) {
if (TclArithSeriesObjIndex(NULL, arithSeriesObjPtr, i, &eleObj) == TCL_OK) {
Tcl_Size slen;
char *str = Tcl_GetStringFromObj(eleObj, &slen);
strcpy(p, str);
p[slen] = ' ';
p += slen+1;
Tcl_DecrRefCount(eleObj);
} // else TODO: report error here?
}
if (bytlen > 0) arithSeriesObjPtr->bytes[bytlen-1] = '\0';
arithSeriesObjPtr->length = bytlen-1;
}
/*
*----------------------------------------------------------------------
*
* TclArithSeriesObjCopy --
*
* Makes a "pure arithSeries" copy of an ArithSeries value. This provides for the C
* level a counterpart of the [lrange $list 0 end] command, while using
* internals details to be as efficient as possible.
*
* Results:
*
* Normally returns a pointer to a new Tcl_Obj, that contains the same
* arithSeries value as *arithSeriesObj does. The returned Tcl_Obj has a
* refCount of zero. If *arithSeriesObj does not hold an arithSeries,
* NULL is returned, and if interp is non-NULL, an error message is
* recorded there.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclArithSeriesObjCopy(
Tcl_Interp *interp, /* Used to report errors if not NULL. */
Tcl_Obj *arithSeriesObj) /* List object for which an element array is
* to be returned. */
{
Tcl_Obj *copyPtr;
ArithSeries *arithSeriesRepPtr;
arithSeriesRepPtr = ArithSeriesGetInternalRep(arithSeriesObj);
if (NULL == arithSeriesRepPtr) {
if (SetArithSeriesFromAny(interp, arithSeriesObj) != TCL_OK) {
/* We know this is going to panic, but it's the message we want */
return NULL;
}
}
TclNewObj(copyPtr);
TclInvalidateStringRep(copyPtr);
DupArithSeriesInternalRep(arithSeriesObj, copyPtr);
return copyPtr;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
|
Changes to generic/tclAssembly.c.
| ︙ | ︙ | |||
218 219 220 221 222 223 224 |
typedef struct AssemblyEnv {
CompileEnv* envPtr; /* Compilation environment being used for code
* generation */
Tcl_Parse* parsePtr; /* Parse of the current line of source */
Tcl_HashTable labelHash; /* Hash table whose keys are labels and whose
* values are 'label' objects storing the code
* offsets of the labels. */
| | | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
typedef struct AssemblyEnv {
CompileEnv* envPtr; /* Compilation environment being used for code
* generation */
Tcl_Parse* parsePtr; /* Parse of the current line of source */
Tcl_HashTable labelHash; /* Hash table whose keys are labels and whose
* values are 'label' objects storing the code
* offsets of the labels. */
Tcl_Size cmdLine; /* Current line number within the assembly
* code */
int* clNext; /* Invisible continuation line for
* [info frame] */
BasicBlock* head_bb; /* First basic block in the code */
BasicBlock* curr_bb; /* Current basic block */
int maxDepth; /* Maximum stack depth encountered */
int curCatchDepth; /* Current depth of catches */
|
| ︙ | ︙ | |||
853 854 855 856 857 858 859 |
CompileEnv compEnv; /* Compilation environment structure */
ByteCode *codePtr = NULL;
/* Bytecode resulting from the assembly */
Namespace* namespacePtr; /* Namespace in which variable and command
* names in the bytecode resolve */
int status; /* Status return from Tcl_AssembleCode */
const char* source; /* String representation of the source code */
| | | 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 |
CompileEnv compEnv; /* Compilation environment structure */
ByteCode *codePtr = NULL;
/* Bytecode resulting from the assembly */
Namespace* namespacePtr; /* Namespace in which variable and command
* names in the bytecode resolve */
int status; /* Status return from Tcl_AssembleCode */
const char* source; /* String representation of the source code */
Tcl_Size sourceLen; /* Length of the source code in bytes */
/*
* Get the expression ByteCode from the object. If it exists, make sure it
* is valid in the current context.
*/
ByteCodeGetInternalRep(objPtr, &assembleCodeType, codePtr);
|
| ︙ | ︙ | |||
1265 1266 1267 1268 1269 1270 1271 |
Tcl_Obj* instNameObj; /* Name of the instruction */
int tblIdx; /* Index in TalInstructionTable of the
* instruction */
TalInstType instType; /* Type of the instruction */
Tcl_Obj* operand1Obj = NULL;
/* First operand to the instruction */
const char* operand1; /* String rep of the operand */
| | | | 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 |
Tcl_Obj* instNameObj; /* Name of the instruction */
int tblIdx; /* Index in TalInstructionTable of the
* instruction */
TalInstType instType; /* Type of the instruction */
Tcl_Obj* operand1Obj = NULL;
/* First operand to the instruction */
const char* operand1; /* String rep of the operand */
Tcl_Size operand1Len; /* String length of the operand */
int opnd; /* Integer representation of an operand */
int litIndex; /* Literal pool index of a constant */
Tcl_Size localVar; /* LVT index of a local variable */
int flags; /* Flags for a basic block */
JumptableInfo* jtPtr; /* Pointer to a jumptable */
int infoIndex; /* Index of the jumptable in auxdata */
int status = TCL_ERROR; /* Return value from this function */
/*
* Make sure that the instruction name is known at compile time.
|
| ︙ | ︙ | |||
1363 1364 1365 1366 1367 1368 1369 |
Tcl_WrongNumArgs(interp, 1, &instNameObj, "boolean varName");
goto cleanup;
}
if (GetBooleanOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
| | | | 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 |
Tcl_WrongNumArgs(interp, 1, &instNameObj, "boolean varName");
goto cleanup;
}
if (GetBooleanOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
if (localVar < 0) {
goto cleanup;
}
BBEmitInstInt1(assemEnvPtr, tblIdx, opnd, 0);
TclEmitInt4(localVar, envPtr);
break;
case ASSEM_CLOCK_READ:
if (parsePtr->numWords != 2) {
Tcl_WrongNumArgs(interp, 1, &instNameObj, "imm8");
goto cleanup;
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
if (opnd < 0 || opnd > 3) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("operand must be [0..3]", -1));
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "OPERAND<0,>3", NULL);
goto cleanup;
}
BBEmitInstInt1(assemEnvPtr, tblIdx, opnd, opnd);
break;
case ASSEM_CONCAT1:
|
| ︙ | ︙ | |||
1423 1424 1425 1426 1427 1428 1429 |
goto cleanup;
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK
|| CheckStrictlyPositive(interp, opnd) != TCL_OK) {
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
| | | | 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 |
goto cleanup;
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK
|| CheckStrictlyPositive(interp, opnd) != TCL_OK) {
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
if (localVar < 0) {
goto cleanup;
}
BBEmitInstInt4(assemEnvPtr, tblIdx, opnd, opnd+1);
TclEmitInt4(localVar, envPtr);
break;
case ASSEM_DICT_UNSET:
if (parsePtr->numWords != 3) {
Tcl_WrongNumArgs(interp, 1, &instNameObj, "count varName");
goto cleanup;
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK
|| CheckStrictlyPositive(interp, opnd) != TCL_OK) {
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
if (localVar < 0) {
goto cleanup;
}
BBEmitInstInt4(assemEnvPtr, tblIdx, opnd, opnd);
TclEmitInt4(localVar, envPtr);
break;
case ASSEM_END_CATCH:
|
| ︙ | ︙ | |||
1621 1622 1623 1624 1625 1626 1627 |
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
if (opnd < 2) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp,
| | | | | | | 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 |
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
if (opnd < 2) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("operand must be >=2", -1));
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "OPERAND>=2", NULL);
}
goto cleanup;
}
BBEmitInstInt4(assemEnvPtr, tblIdx, opnd, opnd);
break;
case ASSEM_LVT:
if (parsePtr->numWords != 2) {
Tcl_WrongNumArgs(interp, 1, &instNameObj, "varname");
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
if (localVar < 0) {
goto cleanup;
}
BBEmitInst1or4(assemEnvPtr, tblIdx, localVar, 0);
break;
case ASSEM_LVT1:
if (parsePtr->numWords != 2) {
Tcl_WrongNumArgs(interp, 1, &instNameObj, "varname");
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
if (localVar < 0 || CheckOneByte(interp, localVar)) {
goto cleanup;
}
BBEmitInstInt1(assemEnvPtr, tblIdx, localVar, 0);
break;
case ASSEM_LVT1_SINT1:
if (parsePtr->numWords != 3) {
Tcl_WrongNumArgs(interp, 1, &instNameObj, "varName imm8");
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
if (localVar < 0 || CheckOneByte(interp, localVar)
|| GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK
|| CheckSignedOneByte(interp, opnd)) {
goto cleanup;
}
BBEmitInstInt1(assemEnvPtr, tblIdx, localVar, 0);
TclEmitInt1(opnd, envPtr);
break;
case ASSEM_LVT4:
if (parsePtr->numWords != 2) {
Tcl_WrongNumArgs(interp, 1, &instNameObj, "varname");
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
if (localVar < 0) {
goto cleanup;
}
BBEmitInstInt4(assemEnvPtr, tblIdx, localVar, 0);
break;
case ASSEM_OVER:
if (parsePtr->numWords != 2) {
|
| ︙ | ︙ | |||
1738 1739 1740 1741 1742 1743 1744 |
Tcl_WrongNumArgs(interp, 1, &instNameObj, "count varName");
goto cleanup;
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
| | | 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 |
Tcl_WrongNumArgs(interp, 1, &instNameObj, "count varName");
goto cleanup;
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
localVar = FindLocalVar(assemEnvPtr, &tokenPtr);
if (localVar < 0) {
goto cleanup;
}
BBEmitInstInt4(assemEnvPtr, tblIdx, opnd, 0);
TclEmitInt4(localVar, envPtr);
break;
default:
|
| ︙ | ︙ | |||
1965 1966 1967 1968 1969 1970 1971 |
*/
static int
CreateMirrorJumpTable(
AssemblyEnv* assemEnvPtr, /* Assembly environment */
Tcl_Obj* jumps) /* List of alternating keywords and labels */
{
| | | | 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 |
*/
static int
CreateMirrorJumpTable(
AssemblyEnv* assemEnvPtr, /* Assembly environment */
Tcl_Obj* jumps) /* List of alternating keywords and labels */
{
Tcl_Size objc; /* Number of elements in the 'jumps' list */
Tcl_Obj** objv; /* Pointers to the elements in the list */
CompileEnv* envPtr = assemEnvPtr->envPtr;
/* Compilation environment */
Tcl_Interp* interp = (Tcl_Interp*) envPtr->iPtr;
/* Tcl interpreter */
BasicBlock* bbPtr = assemEnvPtr->curr_bb;
/* Current basic block */
JumptableInfo* jtPtr;
Tcl_HashTable* jtHashPtr; /* Hashtable in the JumptableInfo */
Tcl_HashEntry* hashEntry; /* Entry for a key in the hashtable */
int isNew; /* Flag==1 if the key is not yet in the
* table. */
Tcl_Size i;
if (TclListObjLengthM(interp, jumps, &objc) != TCL_OK) {
return TCL_ERROR;
}
if (objc % 2 != 0) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
| ︙ | ︙ | |||
2103 2104 2105 2106 2107 2108 2109 |
Tcl_Obj* operandObj;
TclNewObj(operandObj);
if (!TclWordKnownAtCompileTime(*tokenPtrPtr, operandObj)) {
Tcl_DecrRefCount(operandObj);
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 |
Tcl_Obj* operandObj;
TclNewObj(operandObj);
if (!TclWordKnownAtCompileTime(*tokenPtrPtr, operandObj)) {
Tcl_DecrRefCount(operandObj);
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"assembly code may not contain substitutions", -1));
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NOSUBST", NULL);
}
return TCL_ERROR;
}
*tokenPtrPtr = TokenAfter(*tokenPtrPtr);
Tcl_IncrRefCount(operandObj);
*operandObjPtr = operandObj;
|
| ︙ | ︙ | |||
2309 2310 2311 2312 2313 2314 2315 |
Tcl_Interp* interp = (Tcl_Interp*) envPtr->iPtr;
/* Tcl interpreter */
Tcl_Token* tokenPtr = *tokenPtrPtr;
/* INOUT: Pointer to the next token in the
* source code. */
Tcl_Obj* varNameObj; /* Name of the variable */
const char* varNameStr;
| | | | | | 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 |
Tcl_Interp* interp = (Tcl_Interp*) envPtr->iPtr;
/* Tcl interpreter */
Tcl_Token* tokenPtr = *tokenPtrPtr;
/* INOUT: Pointer to the next token in the
* source code. */
Tcl_Obj* varNameObj; /* Name of the variable */
const char* varNameStr;
Tcl_Size varNameLen;
Tcl_Size localVar; /* Index of the variable in the LVT */
if (GetNextOperand(assemEnvPtr, tokenPtrPtr, &varNameObj) != TCL_OK) {
return TCL_INDEX_NONE;
}
varNameStr = Tcl_GetStringFromObj(varNameObj, &varNameLen);
if (CheckNamespaceQualifiers(interp, varNameStr, varNameLen)) {
Tcl_DecrRefCount(varNameObj);
return TCL_INDEX_NONE;
}
localVar = TclFindCompiledLocal(varNameStr, varNameLen, 1, envPtr);
Tcl_DecrRefCount(varNameObj);
if (localVar < 0) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot use this instruction to create a variable"
" in a non-proc context", -1));
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "LVT", NULL);
}
return TCL_INDEX_NONE;
}
*tokenPtrPtr = TokenAfter(tokenPtr);
return localVar;
}
|
| ︙ | ︙ | |||
2396 2397 2398 2399 2400 2401 2402 |
CheckOneByte(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
int value) /* Value to check */
{
Tcl_Obj* result; /* Error message */
if (value < 0 || value > 0xFF) {
| | | 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 |
CheckOneByte(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
int value) /* Value to check */
{
Tcl_Obj* result; /* Error message */
if (value < 0 || value > 0xFF) {
result = Tcl_NewStringObj("operand does not fit in one byte", -1);
Tcl_SetObjResult(interp, result);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "1BYTE", NULL);
return TCL_ERROR;
}
return TCL_OK;
}
|
| ︙ | ︙ | |||
2431 2432 2433 2434 2435 2436 2437 |
CheckSignedOneByte(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
int value) /* Value to check */
{
Tcl_Obj* result; /* Error message */
if (value > 0x7F || value < -0x80) {
| | | 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 |
CheckSignedOneByte(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
int value) /* Value to check */
{
Tcl_Obj* result; /* Error message */
if (value > 0x7F || value < -0x80) {
result = Tcl_NewStringObj("operand does not fit in one byte", -1);
Tcl_SetObjResult(interp, result);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "1BYTE", NULL);
return TCL_ERROR;
}
return TCL_OK;
}
|
| ︙ | ︙ | |||
2464 2465 2466 2467 2468 2469 2470 |
CheckNonNegative(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
int value) /* Value to check */
{
Tcl_Obj* result; /* Error message */
if (value < 0) {
| | | 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 |
CheckNonNegative(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
int value) /* Value to check */
{
Tcl_Obj* result; /* Error message */
if (value < 0) {
result = Tcl_NewStringObj("operand must be nonnegative", -1);
Tcl_SetObjResult(interp, result);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NONNEGATIVE", NULL);
return TCL_ERROR;
}
return TCL_OK;
}
|
| ︙ | ︙ | |||
2497 2498 2499 2500 2501 2502 2503 |
CheckStrictlyPositive(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
int value) /* Value to check */
{
Tcl_Obj* result; /* Error message */
if (value <= 0) {
| | | 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 |
CheckStrictlyPositive(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
int value) /* Value to check */
{
Tcl_Obj* result; /* Error message */
if (value <= 0) {
result = Tcl_NewStringObj("operand must be positive", -1);
Tcl_SetObjResult(interp, result);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "POSITIVE", NULL);
return TCL_ERROR;
}
return TCL_OK;
}
|
| ︙ | ︙ | |||
3317 3318 3319 3320 3321 3322 3323 |
static int
CheckStack(
AssemblyEnv* assemEnvPtr) /* Assembly environment */
{
CompileEnv* envPtr = assemEnvPtr->envPtr;
/* Compilation environment */
| | | 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 |
static int
CheckStack(
AssemblyEnv* assemEnvPtr) /* Assembly environment */
{
CompileEnv* envPtr = assemEnvPtr->envPtr;
/* Compilation environment */
Tcl_Size maxDepth; /* Maximum stack depth overall */
/*
* Checking the head block will check all the other blocks recursively.
*/
assemEnvPtr->maxDepth = 0;
if (StackCheckBasicBlock(assemEnvPtr, assemEnvPtr->head_bb, NULL,
|
| ︙ | ︙ | |||
3410 3411 3412 3413 3414 3415 3416 |
*/
if (blockPtr->initialStackDepth == initialStackDepth) {
return TCL_OK;
}
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 |
*/
if (blockPtr->initialStackDepth == initialStackDepth) {
return TCL_OK;
}
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"inconsistent stack depths on two execution paths", -1));
/*
* TODO - add execution trace of both paths
*/
Tcl_SetErrorLine(interp, blockPtr->startLine);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACK", NULL);
|
| ︙ | ︙ | |||
3439 3440 3441 3442 3443 3444 3445 |
/*
* Calculate minimum stack depth, and flag an error if the block
* underflows the stack.
*/
if (initialStackDepth + blockPtr->minStackDepth < 0) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
| | | | | 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 |
/*
* Calculate minimum stack depth, and flag an error if the block
* underflows the stack.
*/
if (initialStackDepth + blockPtr->minStackDepth < 0) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("stack underflow", -1));
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACK", NULL);
AddBasicBlockRangeToErrorInfo(assemEnvPtr, blockPtr);
Tcl_SetErrorLine(interp, blockPtr->startLine);
}
return TCL_ERROR;
}
/*
* Make sure that the block doesn't try to pop below the stack level of an
* enclosing catch.
*/
if (blockPtr->enclosingCatch != 0 &&
initialStackDepth + blockPtr->minStackDepth
< (blockPtr->enclosingCatch->initialStackDepth
+ blockPtr->enclosingCatch->finalStackDepth)) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"code pops stack below level of enclosing catch", -1));
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACKINCATCH", -1);
AddBasicBlockRangeToErrorInfo(assemEnvPtr, blockPtr);
Tcl_SetErrorLine(interp, blockPtr->startLine);
}
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
3730 3731 3732 3733 3734 3735 3736 |
if (bbPtr->catchState == BBCS_UNKNOWN) {
bbPtr->enclosingCatch = enclosing;
} else if (bbPtr->enclosingCatch != enclosing) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"execution reaches an instruction in inconsistent "
| | | 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 |
if (bbPtr->catchState == BBCS_UNKNOWN) {
bbPtr->enclosingCatch = enclosing;
} else if (bbPtr->enclosingCatch != enclosing) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"execution reaches an instruction in inconsistent "
"exception contexts", -1));
Tcl_SetErrorLine(interp, bbPtr->startLine);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADCATCH", NULL);
}
return TCL_ERROR;
}
if (state > bbPtr->catchState) {
bbPtr->catchState = state;
|
| ︙ | ︙ | |||
3789 3790 3791 3792 3793 3794 3795 |
* If the block ends a catch, the state for the successor is whatever
* the state was on entry to the catch.
*/
if (enclosing == NULL) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 |
* If the block ends a catch, the state for the successor is whatever
* the state was on entry to the catch.
*/
if (enclosing == NULL) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"endCatch without a corresponding beginCatch", -1));
Tcl_SetErrorLine(interp, bbPtr->startLine);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADENDCATCH", NULL);
}
return TCL_ERROR;
}
fallThruEnclosing = enclosing->enclosingCatch;
fallThruState = enclosing->catchState;
|
| ︙ | ︙ | |||
3864 3865 3866 3867 3868 3869 3870 |
/* Compilation environment */
Tcl_Interp* interp = (Tcl_Interp*) envPtr->iPtr;
/* Tcl interpreter */
if (assemEnvPtr->curr_bb->catchState >= BBCS_INCATCH) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 |
/* Compilation environment */
Tcl_Interp* interp = (Tcl_Interp*) envPtr->iPtr;
/* Tcl interpreter */
if (assemEnvPtr->curr_bb->catchState >= BBCS_INCATCH) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"catch still active on exit from assembly code", -1));
Tcl_SetErrorLine(interp,
assemEnvPtr->curr_bb->enclosingCatch->startLine);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "UNCLOSEDCATCH", NULL);
}
return TCL_ERROR;
}
return TCL_OK;
|
| ︙ | ︙ |
Changes to generic/tclBasic.c.
| ︙ | ︙ | |||
89 90 91 92 93 94 95 |
typedef struct {
Tcl_Interp *interp; /* Interp this struct belongs to. */
Tcl_AsyncHandler async; /* Async handler token for script
* cancellation. */
char *result; /* The script cancellation result or NULL for
* a default result. */
| | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
typedef struct {
Tcl_Interp *interp; /* Interp this struct belongs to. */
Tcl_AsyncHandler async; /* Async handler token for script
* cancellation. */
char *result; /* The script cancellation result or NULL for
* a default result. */
Tcl_Size length; /* Length of the above error message. */
void *clientData; /* Not used. */
int flags; /* Additional flags */
} CancelInfo;
static Tcl_HashTable cancelTable;
static int cancelTableInitialized = 0; /* 0 means not yet initialized. */
TCL_DECLARE_MUTEX(cancelLock);
|
| ︙ | ︙ | |||
216 217 218 219 220 221 222 | * Magical counts for the number of arguments accepted by a coroutine command * after particular kinds of [yield]. */ #define CORO_ACTIVATE_YIELD NULL #define CORO_ACTIVATE_YIELDM INT2PTR(1) | | | | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
* Magical counts for the number of arguments accepted by a coroutine command
* after particular kinds of [yield].
*/
#define CORO_ACTIVATE_YIELD NULL
#define CORO_ACTIVATE_YIELDM INT2PTR(1)
#define COROUTINE_ARGUMENTS_SINGLE_OPTIONAL (-1)
#define COROUTINE_ARGUMENTS_ARBITRARY (-2)
/*
* The following structure define the commands in the Tcl core.
*/
typedef struct {
const char *name; /* Name of object-based command. */
|
| ︙ | ︙ | |||
609 610 611 612 613 614 615 |
*----------------------------------------------------------------------
*/
static int
buildInfoObjCmd2(
void *clientData,
Tcl_Interp *interp, /* Current interpreter. */
| | | | | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
*----------------------------------------------------------------------
*/
static int
buildInfoObjCmd2(
void *clientData,
Tcl_Interp *interp, /* Current interpreter. */
Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?option?");
return TCL_ERROR;
}
if (objc == 2) {
Tcl_Size len;
const char *arg = Tcl_GetStringFromObj(objv[1], &len);
if (len == 7 && !strcmp(arg, "version")) {
char buf[80];
const char *p = strchr((char *)clientData, '.');
if (p) {
const char *q = strchr(p+1, '.');
const char *r = strchr(p+1, '+');
|
| ︙ | ︙ | |||
698 699 700 701 702 703 704 |
static int
buildInfoObjCmd(
void *clientData,
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 |
static int
buildInfoObjCmd(
void *clientData,
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
return buildInfoObjCmd2(clientData, interp, objc, objv);
}
/*
*----------------------------------------------------------------------
*
* Tcl_CreateInterp --
*
|
| ︙ | ︙ | |||
1027 1028 1029 1030 1031 1032 1033 |
iPtr->pendingObjDataPtr = NULL;
iPtr->asyncReadyPtr = TclGetAsyncReadyPtr();
iPtr->deferredCallbacks = NULL;
/*
* Create the core commands. Do it here, rather than calling
* Tcl_CreateCommand, because it's faster (there's no need to check for a
| | | 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
iPtr->pendingObjDataPtr = NULL;
iPtr->asyncReadyPtr = TclGetAsyncReadyPtr();
iPtr->deferredCallbacks = NULL;
/*
* Create the core commands. Do it here, rather than calling
* Tcl_CreateCommand, because it's faster (there's no need to check for a
* preexisting command by the same name). If a command has a Tcl_CmdProc
* but no Tcl_ObjCmdProc, set the Tcl_ObjCmdProc to
* TclInvokeStringCommand. This is an object-based wrapper function that
* extracts strings, calls the string function, and creates an object for
* the result. Similarly, if a command has a Tcl_ObjCmdProc but no
* Tcl_CmdProc, set the Tcl_CmdProc to TclInvokeObjectCommand.
*/
|
| ︙ | ︙ | |||
1495 1496 1497 1498 1499 1500 1501 |
int *assocDataCounterPtr =
(int *)Tcl_GetThreadData(&assocDataCounterKey, sizeof(int));
int isNew;
char buffer[32 + TCL_INTEGER_SPACE];
AssocData *dPtr = (AssocData *)Tcl_Alloc(sizeof(AssocData));
Tcl_HashEntry *hPtr;
| | | 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 |
int *assocDataCounterPtr =
(int *)Tcl_GetThreadData(&assocDataCounterKey, sizeof(int));
int isNew;
char buffer[32 + TCL_INTEGER_SPACE];
AssocData *dPtr = (AssocData *)Tcl_Alloc(sizeof(AssocData));
Tcl_HashEntry *hPtr;
snprintf(buffer, sizeof(buffer), "Assoc Data Key #%d", *assocDataCounterPtr);
(*assocDataCounterPtr)++;
if (iPtr->assocData == NULL) {
iPtr->assocData = (Tcl_HashTable *)Tcl_Alloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(iPtr->assocData, TCL_STRING_KEYS);
}
hPtr = Tcl_CreateHashEntry(iPtr->assocData, buffer, &isNew);
|
| ︙ | ︙ | |||
1795 1796 1797 1798 1799 1800 1801 |
Tcl_Interp *interp) /* Interpreter to delete. */
{
Interp *iPtr = (Interp *) interp;
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
Tcl_HashTable *hTablePtr;
ResolverScheme *resPtr, *nextResPtr;
| | | 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 |
Tcl_Interp *interp) /* Interpreter to delete. */
{
Interp *iPtr = (Interp *) interp;
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
Tcl_HashTable *hTablePtr;
ResolverScheme *resPtr, *nextResPtr;
Tcl_Size i;
/*
* Punt if there is an error in the Tcl_Release/Tcl_Preserve matchup,
* unless we are exiting.
*/
if ((iPtr->numLevels > 0) && !TclInExit()) {
|
| ︙ | ︙ | |||
2148 2149 2150 2151 2152 2153 2154 |
* the source, in order to avoid potential confusion, lets prevent "::" in
* the token too. - dl
*/
if (strstr(hiddenCmdToken, "::") != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot use namespace qualifiers in hidden command"
| | | 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 |
* the source, in order to avoid potential confusion, lets prevent "::" in
* the token too. - dl
*/
if (strstr(hiddenCmdToken, "::") != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot use namespace qualifiers in hidden command"
" token (rename)", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "HIDDENTOKEN", NULL);
return TCL_ERROR;
}
/*
* Find the command to hide. An error is returned if cmdName can't be
* found. Look up the command only from the global namespace. Full path of
|
| ︙ | ︙ | |||
2205 2206 2207 2208 2209 2210 2211 |
"hidden command named \"%s\" already exists",
hiddenCmdToken));
Tcl_SetErrorCode(interp, "TCL", "HIDE", "ALREADY_HIDDEN", NULL);
return TCL_ERROR;
}
/*
| | | | | 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 |
"hidden command named \"%s\" already exists",
hiddenCmdToken));
Tcl_SetErrorCode(interp, "TCL", "HIDE", "ALREADY_HIDDEN", NULL);
return TCL_ERROR;
}
/*
* NB: This code is currently 'like' a rename to a special separate name
* table. Changes here and in TclRenameCommand must be kept in synch until
* the common parts are actually factorized out.
*/
/*
* Remove the hash entry for the command from the interpreter command
* table. This is like deleting the command, so bump its command epoch
* to invalidate any cached references that point to the command.
*/
if (cmdPtr->hPtr != NULL) {
Tcl_DeleteHashEntry(cmdPtr->hPtr);
cmdPtr->hPtr = NULL;
cmdPtr->cmdEpoch++;
}
|
| ︙ | ︙ | |||
2334 2335 2336 2337 2338 2339 2340 |
* Check that we have a true global namespace command (enforced by
* Tcl_HideCommand but let's double check. (If it was not, we would not
* really know how to handle it).
*/
if (cmdPtr->nsPtr != iPtr->globalNsPtr) {
/*
| | | 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 |
* Check that we have a true global namespace command (enforced by
* Tcl_HideCommand but let's double check. (If it was not, we would not
* really know how to handle it).
*/
if (cmdPtr->nsPtr != iPtr->globalNsPtr) {
/*
* This case is theoretically impossible, we might rather Tcl_Panic
* than 'nicely' erroring out ?
*/
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"trying to expose a non-global command namespace command",
-1));
return TCL_ERROR;
|
| ︙ | ︙ | |||
2440 2441 2442 2443 2444 2445 2446 | * future calls to Tcl_GetCommandName. * * Side effects: * If a command named cmdName already exists for interp, it is deleted. * In the future, when cmdName is seen as the name of a command by * Tcl_Eval, proc will be called. To support the bytecode interpreter, * the command is created with a wrapper Tcl_ObjCmdProc | | | 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 | * future calls to Tcl_GetCommandName. * * Side effects: * If a command named cmdName already exists for interp, it is deleted. * In the future, when cmdName is seen as the name of a command by * Tcl_Eval, proc will be called. To support the bytecode interpreter, * the command is created with a wrapper Tcl_ObjCmdProc * (TclInvokeStringCommand) that eventually calls proc. When the command * is deleted from the table, deleteProc will be called. See the manual * entry for details on the calling sequence. * *---------------------------------------------------------------------- */ Tcl_Command |
| ︙ | ︙ | |||
2661 2662 2663 2664 2665 2666 2667 |
int objc,
Tcl_Obj * const *objv)
{
CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
if (objc < 0) {
objc = -1;
}
| | | 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 |
int objc,
Tcl_Obj * const *objv)
{
CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
if (objc < 0) {
objc = -1;
}
return info->proc(info->clientData, interp, objc, objv);
}
static void cmdWrapperDeleteProc(void *clientData) {
CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
clientData = info->deleteData;
Tcl_CmdDeleteProc *deleteProc = info->deleteProc;
|
| ︙ | ︙ | |||
3184 3185 3186 3187 3188 3189 3190 |
* The trace function needs to get a fully qualified name for old and new
* commands [Tcl bug #651271], or else there's no way for the trace
* function to get the namespace from which the old command is being
* renamed!
*/
Tcl_DStringInit(&newFullName);
| | | | 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 |
* The trace function needs to get a fully qualified name for old and new
* commands [Tcl bug #651271], or else there's no way for the trace
* function to get the namespace from which the old command is being
* renamed!
*/
Tcl_DStringInit(&newFullName);
Tcl_DStringAppend(&newFullName, newNsPtr->fullName, -1);
if (newNsPtr != iPtr->globalNsPtr) {
TclDStringAppendLiteral(&newFullName, "::");
}
Tcl_DStringAppend(&newFullName, newTail, -1);
cmdPtr->refCount++;
CallCommandTraces(iPtr, cmdPtr, TclGetString(oldFullName),
Tcl_DStringValue(&newFullName), TCL_TRACE_RENAME);
Tcl_DStringFree(&newFullName);
/*
* The new command name is okay, so remove the command from its current
|
| ︙ | ︙ | |||
3287 3288 3289 3290 3291 3292 3293 |
*----------------------------------------------------------------------
*/
static int
invokeObj2Command(
void *clientData, /* Points to command's Command structure. */
Tcl_Interp *interp, /* Current interpreter. */
| | | | | 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 |
*----------------------------------------------------------------------
*/
static int
invokeObj2Command(
void *clientData, /* Points to command's Command structure. */
Tcl_Interp *interp, /* Current interpreter. */
Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int result;
Command *cmdPtr = (Command *) clientData;
if (objc > INT_MAX) {
objc = TCL_INDEX_NONE; /* TODO - why? Should error, not truncate */
}
if (cmdPtr->objProc != NULL) {
result = cmdPtr->objProc(cmdPtr->objClientData, interp, objc, objv);
} else {
result = Tcl_NRCallObjProc(interp, cmdPtr->nreProc,
cmdPtr->objClientData, objc, objv);
}
return result;
}
static int cmdWrapper2Proc(void *clientData,
Tcl_Interp *interp,
Tcl_Size objc,
Tcl_Obj *const objv[])
{
Command *cmdPtr = (Command *)clientData;
return cmdPtr->objProc(cmdPtr->objClientData, interp, objc, objv);
}
int
|
| ︙ | ︙ | |||
3549 3550 3551 3552 3553 3554 3555 |
/*
* Add the full name of the containing namespace, followed by the "::"
* separator, and the command name.
*/
if ((cmdPtr != NULL) && TclRoutineHasName(cmdPtr)) {
if (cmdPtr->nsPtr != NULL) {
| | | | 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 |
/*
* Add the full name of the containing namespace, followed by the "::"
* separator, and the command name.
*/
if ((cmdPtr != NULL) && TclRoutineHasName(cmdPtr)) {
if (cmdPtr->nsPtr != NULL) {
Tcl_AppendToObj(objPtr, cmdPtr->nsPtr->fullName, -1);
if (cmdPtr->nsPtr != iPtr->globalNsPtr) {
Tcl_AppendToObj(objPtr, "::", 2);
}
}
if (cmdPtr->hPtr != NULL) {
name = (char *)Tcl_GetHashKey(cmdPtr->hPtr->tablePtr, cmdPtr->hPtr);
Tcl_AppendToObj(objPtr, name, -1);
}
}
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
3927 3928 3929 3930 3931 3932 3933 | * interpreter is still able to execute further commands after the * cancelation is cleared (unlike if it is deleted). * * Results: * The value given for the code argument. * * Side effects: | | | 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 |
* interpreter is still able to execute further commands after the
* cancelation is cleared (unlike if it is deleted).
*
* Results:
* The value given for the code argument.
*
* Side effects:
* Transfers a message from the cancellation message to the interpreter.
*
*----------------------------------------------------------------------
*/
static int
CancelEvalProc(
void *clientData, /* Interp to cancel the script in progress. */
|
| ︙ | ︙ | |||
4057 4058 4059 4060 4061 4062 4063 |
/*
* If the interpreter has been deleted, return an error.
*/
if (iPtr->flags & DELETED) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 |
/*
* If the interpreter has been deleted, return an error.
*/
if (iPtr->flags & DELETED) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to call eval in deleted interpreter", -1));
Tcl_SetErrorCode(interp, "TCL", "IDELETE",
"attempt to call eval in deleted interpreter", NULL);
return TCL_ERROR;
}
if (iPtr->execEnvPtr->rewind) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
4086 4087 4088 4089 4090 4091 4092 |
*/
if ((iPtr->numLevels <= iPtr->maxNestingDepth)) {
return TCL_OK;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 |
*/
if ((iPtr->numLevels <= iPtr->maxNestingDepth)) {
return TCL_OK;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"too many nested evaluations (infinite loop?)", -1));
Tcl_SetErrorCode(interp, "TCL", "LIMIT", "STACK", NULL);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
4195 4196 4197 4198 4199 4200 4201 |
/*
* If the TCL_LEAVE_ERR_MSG flags bit is set, place an error in the
* interp's result; otherwise, we leave it alone.
*/
if (flags & TCL_LEAVE_ERR_MSG) {
const char *id, *message = NULL;
| | | 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 |
/*
* If the TCL_LEAVE_ERR_MSG flags bit is set, place an error in the
* interp's result; otherwise, we leave it alone.
*/
if (flags & TCL_LEAVE_ERR_MSG) {
const char *id, *message = NULL;
Tcl_Size length;
/*
* Setup errorCode variables so that we can differentiate between
* being canceled and unwound.
*/
if (iPtr->asyncCancelMsg != NULL) {
|
| ︙ | ︙ | |||
4220 4221 4222 4223 4224 4225 4226 |
} else {
id = "ICANCEL";
if (length == 0) {
message = "eval canceled";
}
}
| | | 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 |
} else {
id = "ICANCEL";
if (length == 0) {
message = "eval canceled";
}
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(message, -1));
Tcl_SetErrorCode(interp, "TCL", "CANCEL", id, message, NULL);
}
/*
* Return TCL_ERROR to the caller (not necessarily just the Tcl core
* itself) that indicates further processing of the script or command in
* progress should halt gracefully and as soon as possible.
|
| ︙ | ︙ | |||
4366 4367 4368 4369 4370 4371 4372 |
*----------------------------------------------------------------------
*/
int
Tcl_EvalObjv(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* command. Also used for error reporting. */
| | | | 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 |
*----------------------------------------------------------------------
*/
int
Tcl_EvalObjv(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* command. Also used for error reporting. */
Tcl_Size objc, /* Number of words in command. */
Tcl_Obj *const objv[], /* An array of pointers to objects that are
* the words that make up the command. */
int flags) /* Collection of OR-ed bits that control the
* evaluation of the script. Only
* TCL_EVAL_GLOBAL, TCL_EVAL_INVOKE and
* TCL_EVAL_NOERR are currently supported. */
{
int result;
NRE_callback *rootPtr = TOP_CB(interp);
result = TclNREvalObjv(interp, objc, objv, flags, NULL);
return TclNRRunCallbacks(interp, result, rootPtr);
}
int
TclNREvalObjv(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* command. Also used for error reporting. */
Tcl_Size objc, /* Number of words in command. */
Tcl_Obj *const objv[], /* An array of pointers to objects that are
* the words that make up the command. */
int flags, /* Collection of OR-ed bits that control the
* evaluation of the script. Only
* TCL_EVAL_GLOBAL, TCL_EVAL_INVOKE and
* TCL_EVAL_NOERR are currently supported. */
Command *cmdPtr) /* NULL if the Command is to be looked up
|
| ︙ | ︙ | |||
4793 4794 4795 4796 4797 4798 4799 |
void *data[],
Tcl_Interp *interp,
int result)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *listPtr;
const char *cmdString;
| | | 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 |
void *data[],
Tcl_Interp *interp,
int result)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *listPtr;
const char *cmdString;
Tcl_Size cmdLen;
int objc = PTR2INT(data[0]);
Tcl_Obj **objv = (Tcl_Obj **)data[1];
if ((result == TCL_ERROR) && !(iPtr->flags & ERR_ALREADY_LOGGED)) {
/*
* If there was an error, a command string will be needed for the
* error log: get it out of the itemPtr. The details depend on the
|
| ︙ | ︙ | |||
4822 4823 4824 4825 4826 4827 4828 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[],
Namespace *lookupNsPtr)
{
Command * cmdPtr;
Interp *iPtr = (Interp *) interp;
| | | 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[],
Namespace *lookupNsPtr)
{
Command * cmdPtr;
Interp *iPtr = (Interp *) interp;
Tcl_Size i, newObjc, handlerObjc;
Tcl_Obj **newObjv, **handlerObjv;
CallFrame *varFramePtr = iPtr->varFramePtr;
Namespace *currNsPtr = NULL;/* Used to check for and invoke any registered
* unknown command handler for the current
* namespace (TIP 181). */
Namespace *savedNsPtr = NULL;
|
| ︙ | ︙ | |||
4850 4851 4852 4853 4854 4855 4856 |
if (currNsPtr->unknownHandlerPtr == NULL) {
TclNewLiteralStringObj(currNsPtr->unknownHandlerPtr, "::unknown");
Tcl_IncrRefCount(currNsPtr->unknownHandlerPtr);
}
/*
* Get the list of words for the unknown handler and allocate enough space
| | | 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 |
if (currNsPtr->unknownHandlerPtr == NULL) {
TclNewLiteralStringObj(currNsPtr->unknownHandlerPtr, "::unknown");
Tcl_IncrRefCount(currNsPtr->unknownHandlerPtr);
}
/*
* Get the list of words for the unknown handler and allocate enough space
* to hold both the handler prefix and all words of the command invocation
* itself.
*/
TclListObjGetElementsM(NULL, currNsPtr->unknownHandlerPtr,
&handlerObjc, &handlerObjv);
newObjc = objc + handlerObjc;
newObjv = (Tcl_Obj **)TclStackAlloc(interp, sizeof(Tcl_Obj *) * newObjc);
|
| ︙ | ︙ | |||
4949 4950 4951 4952 4953 4954 4955 |
Command **cmdPtrPtr,
Tcl_Obj *commandPtr,
int objc,
Tcl_Obj *const objv[])
{
Interp *iPtr = (Interp *) interp;
Command *cmdPtr = *cmdPtrPtr;
| | | 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 |
Command **cmdPtrPtr,
Tcl_Obj *commandPtr,
int objc,
Tcl_Obj *const objv[])
{
Interp *iPtr = (Interp *) interp;
Command *cmdPtr = *cmdPtrPtr;
Tcl_Size length, newEpoch, cmdEpoch = cmdPtr->cmdEpoch;
int traceCode = TCL_OK;
const char *command = Tcl_GetStringFromObj(commandPtr, &length);
/*
* Call trace functions.
* Execute any command or execution traces. Note that we bump up the
* command's reference count for the duration of the calling of the
|
| ︙ | ︙ | |||
5002 5003 5004 5005 5006 5007 5008 |
{
Interp *iPtr = (Interp *) interp;
int traceCode = TCL_OK;
int objc = PTR2INT(data[0]);
Tcl_Obj *commandPtr = (Tcl_Obj *)data[1];
Command *cmdPtr = (Command *)data[2];
Tcl_Obj **objv = (Tcl_Obj **)data[3];
| | | 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 |
{
Interp *iPtr = (Interp *) interp;
int traceCode = TCL_OK;
int objc = PTR2INT(data[0]);
Tcl_Obj *commandPtr = (Tcl_Obj *)data[1];
Command *cmdPtr = (Command *)data[2];
Tcl_Obj **objv = (Tcl_Obj **)data[3];
Tcl_Size length;
const char *command = Tcl_GetStringFromObj(commandPtr, &length);
if (!(cmdPtr->flags & CMD_DYING)) {
if (cmdPtr->flags & CMD_HAS_EXEC_TRACES) {
traceCode = TclCheckExecutionTraces(interp, command, length,
cmdPtr, result, TCL_TRACE_LEAVE_EXEC, objc, objv);
}
|
| ︙ | ︙ | |||
5085 5086 5087 5088 5089 5090 5091 |
int
Tcl_EvalTokensStandard(
Tcl_Interp *interp, /* Interpreter in which to lookup variables,
* execute nested commands, and report
* errors. */
Tcl_Token *tokenPtr, /* Pointer to first in an array of tokens to
* evaluate and concatenate. */
| | | 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 |
int
Tcl_EvalTokensStandard(
Tcl_Interp *interp, /* Interpreter in which to lookup variables,
* execute nested commands, and report
* errors. */
Tcl_Token *tokenPtr, /* Pointer to first in an array of tokens to
* evaluate and concatenate. */
Tcl_Size count) /* Number of tokens to consider at tokenPtr.
* Must be at least 1. */
{
return TclSubstTokens(interp, tokenPtr, count, /* numLeftPtr */ NULL, 1,
NULL, NULL);
}
/*
|
| ︙ | ︙ | |||
5118 5119 5120 5121 5122 5123 5124 |
*/
int
Tcl_EvalEx(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* script. Also used for error reporting. */
const char *script, /* First character of script to evaluate. */
| | | | | | | 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 |
*/
int
Tcl_EvalEx(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* script. Also used for error reporting. */
const char *script, /* First character of script to evaluate. */
Tcl_Size numBytes, /* Number of bytes in script. If -1, the
* script consists of all bytes up to the
* first null character. */
int flags) /* Collection of OR-ed bits that control the
* evaluation of the script. Only
* TCL_EVAL_GLOBAL is currently supported. */
{
return TclEvalEx(interp, script, numBytes, flags, 1, NULL, script);
}
int
TclEvalEx(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* script. Also used for error reporting. */
const char *script, /* First character of script to evaluate. */
Tcl_Size numBytes, /* Number of bytes in script. If -1, the
* script consists of all bytes up to the
* first NUL character. */
int flags, /* Collection of OR-ed bits that control the
* evaluation of the script. Only
* TCL_EVAL_GLOBAL is currently supported. */
Tcl_Size line, /* The line the script starts on. */
int *clNextOuter, /* Information about an outer context for */
const char *outerScript) /* continuation line data. This is set only in
* TclSubstTokens(), to properly handle
* [...]-nested commands. The 'outerScript'
* refers to the most-outer script containing
* the embedded command, which is referred to
* by 'script'. The 'clNextOuter' refers to
* the current entry in the table of
* continuation lines in this "main script",
* and the character offsets are relative to
* the 'outerScript' as well.
*
* If outerScript == script, then this call is
* for the outer-most script/command. See
* Tcl_EvalEx() and TclEvalObjEx() for places
* generating arguments for which this is
* true. */
{
Interp *iPtr = (Interp *) interp;
const char *p, *next;
const unsigned int minObjs = 20;
Tcl_Obj **objv, **objvSpace;
int *expand, *lines, *lineSpace;
Tcl_Token *tokenPtr;
int bytesLeft, expandRequested, code = TCL_OK;
Tcl_Size commandLength;
CallFrame *savedVarFramePtr;/* Saves old copy of iPtr->varFramePtr in case
* TCL_EVAL_GLOBAL was set. */
int allowExceptions = (iPtr->evalFlags & TCL_ALLOW_EXCEPTIONS);
int gotParse = 0;
TCL_HASH_TYPE i, objectsUsed = 0;
/* These variables keep track of how much
* state has been allocated while evaluating
|
| ︙ | ︙ | |||
5199 5200 5201 5202 5203 5204 5205 |
if (clNextOuter) {
clNext = clNextOuter;
} else {
clNext = &iPtr->scriptCLLocPtr->loc[0];
}
}
| | | 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 |
if (clNextOuter) {
clNext = clNextOuter;
} else {
clNext = &iPtr->scriptCLLocPtr->loc[0];
}
}
if (numBytes < 0) {
numBytes = strlen(script);
}
Tcl_ResetResult(interp);
savedVarFramePtr = iPtr->varFramePtr;
if (flags & TCL_EVAL_GLOBAL) {
iPtr->varFramePtr = iPtr->rootFramePtr;
|
| ︙ | ︙ | |||
5305 5306 5307 5308 5309 5310 5311 | /* * TIP #280. Track lines within the words of the current * command. We use a separate pointer into the table of * continuation line locations to not lose our position for the * per-command parsing. */ | | | 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 | /* * TIP #280. Track lines within the words of the current * command. We use a separate pointer into the table of * continuation line locations to not lose our position for the * per-command parsing. */ Tcl_Size wordLine = line; const char *wordStart = parsePtr->commandStart; int *wordCLNext = clNext; unsigned int objectsNeeded = 0; unsigned int numWords = parsePtr->numWords; /* * Generate an array of objects for the words of the command. |
| ︙ | ︙ | |||
5360 5361 5362 5363 5364 5365 5366 |
if (code != TCL_OK) {
break;
}
objv[objectsUsed] = Tcl_GetObjResult(interp);
Tcl_IncrRefCount(objv[objectsUsed]);
if (tokenPtr->type == TCL_TOKEN_EXPAND_WORD) {
| | | 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 |
if (code != TCL_OK) {
break;
}
objv[objectsUsed] = Tcl_GetObjResult(interp);
Tcl_IncrRefCount(objv[objectsUsed]);
if (tokenPtr->type == TCL_TOKEN_EXPAND_WORD) {
Tcl_Size numElements;
code = TclListObjLengthM(interp, objv[objectsUsed],
&numElements);
if (code == TCL_ERROR) {
/*
* Attempt to expand a non-list.
*/
|
| ︙ | ︙ | |||
5411 5412 5413 5414 5415 5416 5417 |
(Tcl_Obj **)Tcl_Alloc(objectsNeeded * sizeof(Tcl_Obj *));
lines = lineSpace = (int *)Tcl_Alloc(objectsNeeded * sizeof(int));
}
objectsUsed = 0;
while (wordIdx--) {
if (expand[wordIdx]) {
| | | 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 |
(Tcl_Obj **)Tcl_Alloc(objectsNeeded * sizeof(Tcl_Obj *));
lines = lineSpace = (int *)Tcl_Alloc(objectsNeeded * sizeof(int));
}
objectsUsed = 0;
while (wordIdx--) {
if (expand[wordIdx]) {
Tcl_Size numElements;
Tcl_Obj **elements, *temp = copy[wordIdx];
TclListObjGetElementsM(NULL, temp, &numElements,
&elements);
objectsUsed += numElements;
while (numElements--) {
lines[objIdx] = -1;
|
| ︙ | ︙ | |||
5604 5605 5606 5607 5608 5609 5610 | * * TIP #280 *---------------------------------------------------------------------- */ void TclAdvanceLines( | | | 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 |
*
* TIP #280
*----------------------------------------------------------------------
*/
void
TclAdvanceLines(
Tcl_Size *line,
const char *start,
const char *end)
{
const char *p;
for (p = start; p < end; p++) {
if (*p == '\n') {
|
| ︙ | ︙ | |||
5639 5640 5641 5642 5643 5644 5645 | * * TIP #280 *---------------------------------------------------------------------- */ void TclAdvanceContinuations( | | | 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 |
*
* TIP #280
*----------------------------------------------------------------------
*/
void
TclAdvanceContinuations(
Tcl_Size *line,
int **clNextPtrPtr,
int loc)
{
/*
* Track the invisible continuation lines embedded in a script, if any.
* Here they are just spaces (already). They were removed by
* TclSubstTokens via TclParseBackslash.
|
| ︙ | ︙ | |||
5711 5712 5713 5714 5715 5716 5717 |
Tcl_HashEntry *hPtr;
CFWord *cfwPtr;
for (i = 1; i < objc; i++) {
/*
* Ignore argument words without line information (= dynamic). If they
* are variables they may have location information associated with
| | | | 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 |
Tcl_HashEntry *hPtr;
CFWord *cfwPtr;
for (i = 1; i < objc; i++) {
/*
* Ignore argument words without line information (= dynamic). If they
* are variables they may have location information associated with
* that, either through globally recorded 'set' invocations, or
* literals in bytecode. Either way there is no need to record
* something here.
*/
if (cfPtr->line[i] < 0) {
continue;
}
hPtr = Tcl_CreateHashEntry(iPtr->lineLAPtr, objv[i], &isNew);
|
| ︙ | ︙ | |||
5819 5820 5821 5822 5823 5824 5825 |
TclArgumentBCEnter(
Tcl_Interp *interp,
Tcl_Obj *objv[],
int objc,
void *codePtr,
CmdFrame *cfPtr,
int cmd,
| | | 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 |
TclArgumentBCEnter(
Tcl_Interp *interp,
Tcl_Obj *objv[],
int objc,
void *codePtr,
CmdFrame *cfPtr,
int cmd,
Tcl_Size pc)
{
ExtCmdLoc *eclPtr;
int word;
ECL *ePtr;
CFWordBC *lastPtr = NULL;
Interp *iPtr = (Interp *) interp;
Tcl_HashEntry *hePtr =
|
| ︙ | ︙ | |||
5848 5849 5850 5851 5852 5853 5854 |
* ensemble dispatch. Ensemble subcommands that lead to script
* evaluation are not supposed to get compiled, because a command
* such as [info level] in the script can expose some of the dispatch
* shenanigans. This means that we don't have to tend to the
* housekeeping, and can escape now.
*/
| | | 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 |
* ensemble dispatch. Ensemble subcommands that lead to script
* evaluation are not supposed to get compiled, because a command
* such as [info level] in the script can expose some of the dispatch
* shenanigans. This means that we don't have to tend to the
* housekeeping, and can escape now.
*/
if (ePtr->nline != objc) {
return;
}
/*
* Having disposed of the ensemble cases, we can state...
* A few truths ...
* (1) ePtr->nline == objc
|
| ︙ | ︙ | |||
6108 6109 6110 6111 6112 6113 6114 |
* This function consists of three independent blocks for: direct
* evaluation of canonical lists, compilation and bytecode execution and
* finally direct evaluation. Precisely one of these blocks will be run.
*/
if (TclListObjIsCanonical(objPtr)) {
CmdFrame *eoFramePtr = NULL;
| | | 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 |
* This function consists of three independent blocks for: direct
* evaluation of canonical lists, compilation and bytecode execution and
* finally direct evaluation. Precisely one of these blocks will be run.
*/
if (TclListObjIsCanonical(objPtr)) {
CmdFrame *eoFramePtr = NULL;
Tcl_Size objc;
Tcl_Obj *listPtr, **objv;
/*
* Canonical List Optimization: In this case, we
* can safely use Tcl_EvalObjv instead and get an appreciable
* improvement in execution speed. This is because it allows us to
* avoid a setFromAny step that would just pack everything into a
|
| ︙ | ︙ | |||
6218 6219 6220 6221 6222 6223 6224 | /* * We're not supposed to use the compiler or byte-code * interpreter. Let Tcl_EvalEx evaluate the command directly (and * probably more slowly). */ const char *script; | | | 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 | /* * We're not supposed to use the compiler or byte-code * interpreter. Let Tcl_EvalEx evaluate the command directly (and * probably more slowly). */ const char *script; Tcl_Size numSrcBytes; /* * Now we check if we have data about invisible continuation lines for * the script, and make it available to the direct script parser and * evaluator we are about to call, if so. * * It may be possible that the script Tcl_Obj* can be free'd while the |
| ︙ | ︙ | |||
6272 6273 6274 6275 6276 6277 6278 |
if (iPtr->numLevels == 0) {
if (result == TCL_RETURN) {
result = TclUpdateReturnInfo(iPtr);
}
if ((result != TCL_OK) && (result != TCL_ERROR) && !allowExceptions) {
const char *script;
| | | 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 |
if (iPtr->numLevels == 0) {
if (result == TCL_RETURN) {
result = TclUpdateReturnInfo(iPtr);
}
if ((result != TCL_OK) && (result != TCL_ERROR) && !allowExceptions) {
const char *script;
Tcl_Size numSrcBytes;
ProcessUnexpectedResult(interp, result);
result = TCL_ERROR;
script = Tcl_GetStringFromObj(objPtr, &numSrcBytes);
Tcl_LogCommandInfo(interp, script, script, numSrcBytes);
}
|
| ︙ | ︙ | |||
6357 6358 6359 6360 6361 6362 6363 |
int returnCode) /* The unexpected result code. */
{
char buf[TCL_INTEGER_SPACE];
Tcl_ResetResult(interp);
if (returnCode == TCL_BREAK) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 |
int returnCode) /* The unexpected result code. */
{
char buf[TCL_INTEGER_SPACE];
Tcl_ResetResult(interp);
if (returnCode == TCL_BREAK) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"invoked \"break\" outside of a loop", -1));
} else if (returnCode == TCL_CONTINUE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"invoked \"continue\" outside of a loop", -1));
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"command returned bad code: %d", returnCode));
}
snprintf(buf, sizeof(buf), "%d", returnCode);
Tcl_SetErrorCode(interp, "TCL", "UNEXPECTED_RESULT_CODE", buf, NULL);
}
/*
*---------------------------------------------------------------------------
*
* Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean --
|
| ︙ | ︙ | |||
6406 6407 6408 6409 6410 6411 6412 |
if (*exprstring == '\0') {
/*
* Legacy compatibility - return 0 for the zero-length string.
*/
*ptr = 0;
} else {
| | | 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 |
if (*exprstring == '\0') {
/*
* Legacy compatibility - return 0 for the zero-length string.
*/
*ptr = 0;
} else {
exprPtr = Tcl_NewStringObj(exprstring, -1);
Tcl_IncrRefCount(exprPtr);
result = Tcl_ExprLongObj(interp, exprPtr, ptr);
Tcl_DecrRefCount(exprPtr);
}
return result;
}
|
| ︙ | ︙ | |||
6431 6432 6433 6434 6435 6436 6437 |
if (*exprstring == '\0') {
/*
* Legacy compatibility - return 0 for the zero-length string.
*/
*ptr = 0.0;
} else {
| | | 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 |
if (*exprstring == '\0') {
/*
* Legacy compatibility - return 0 for the zero-length string.
*/
*ptr = 0.0;
} else {
exprPtr = Tcl_NewStringObj(exprstring, -1);
Tcl_IncrRefCount(exprPtr);
result = Tcl_ExprDoubleObj(interp, exprPtr, ptr);
Tcl_DecrRefCount(exprPtr);
/* Discard the expression object. */
}
return result;
}
|
| ︙ | ︙ | |||
6456 6457 6458 6459 6460 6461 6462 |
* An empty string. Just set the result boolean to 0 (false).
*/
*ptr = 0;
return TCL_OK;
} else {
int result;
| | | 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 |
* An empty string. Just set the result boolean to 0 (false).
*/
*ptr = 0;
return TCL_OK;
} else {
int result;
Tcl_Obj *exprPtr = Tcl_NewStringObj(exprstring, -1);
Tcl_IncrRefCount(exprPtr);
result = Tcl_ExprBooleanObj(interp, exprPtr, ptr);
Tcl_DecrRefCount(exprPtr);
return result;
}
}
|
| ︙ | ︙ | |||
6669 6670 6671 6672 6673 6674 6675 |
* or TCL_INVOKE_NO_TRACEBACK. */
{
if (interp == NULL) {
return TCL_ERROR;
}
if ((objc < 1) || (objv == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 |
* or TCL_INVOKE_NO_TRACEBACK. */
{
if (interp == NULL) {
return TCL_ERROR;
}
if ((objc < 1) || (objv == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal argument vector", -1));
return TCL_ERROR;
}
if ((flags & TCL_INVOKE_HIDDEN) == 0) {
Tcl_Panic("TclObjInvoke: called without TCL_INVOKE_HIDDEN");
}
return Tcl_NRCallObjProc(interp, TclNRInvoke, NULL, objc, objv);
}
|
| ︙ | ︙ | |||
6768 6769 6770 6771 6772 6773 6774 |
if (expr[0] == '\0') {
/*
* An empty string. Just set the interpreter's result to 0.
*/
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
} else {
| | | 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 |
if (expr[0] == '\0') {
/*
* An empty string. Just set the interpreter's result to 0.
*/
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
} else {
Tcl_Obj *resultPtr, *exprObj = Tcl_NewStringObj(expr, -1);
Tcl_IncrRefCount(exprObj);
code = Tcl_ExprObj(interp, exprObj, &resultPtr);
Tcl_DecrRefCount(exprObj);
if (code == TCL_OK) {
Tcl_SetObjResult(interp, resultPtr);
Tcl_DecrRefCount(resultPtr);
|
| ︙ | ︙ | |||
6806 6807 6808 6809 6810 6811 6812 |
void
Tcl_AppendObjToErrorInfo(
Tcl_Interp *interp, /* Interpreter to which error information
* pertains. */
Tcl_Obj *objPtr) /* Message to record. */
{
| | | 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 |
void
Tcl_AppendObjToErrorInfo(
Tcl_Interp *interp, /* Interpreter to which error information
* pertains. */
Tcl_Obj *objPtr) /* Message to record. */
{
Tcl_Size length;
const char *message = Tcl_GetStringFromObj(objPtr, &length);
Interp *iPtr = (Interp *) interp;
Tcl_IncrRefCount(objPtr);
/*
* If we are just starting to log an error, errorInfo is initialized from
|
| ︙ | ︙ | |||
6882 6883 6884 6885 6886 6887 6888 |
Tcl_DStringInit(&buf);
while (1) {
string = va_arg(argList, char *);
if (string == NULL) {
break;
}
| | | | 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 |
Tcl_DStringInit(&buf);
while (1) {
string = va_arg(argList, char *);
if (string == NULL) {
break;
}
Tcl_DStringAppend(&buf, string, -1);
}
result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
Tcl_DStringFree(&buf);
return result;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
6907 6908 6909 6910 6911 6912 6913 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | | | 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
Tcl_SetRecursionLimit(
Tcl_Interp *interp, /* Interpreter whose nesting limit is to be
* set. */
Tcl_Size depth) /* New value for maximimum depth. */
{
Interp *iPtr = (Interp *) interp;
Tcl_Size old;
old = iPtr->maxNestingDepth;
if (depth > 0) {
iPtr->maxNestingDepth = depth;
}
return old;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
7188 7189 7190 7191 7192 7193 7194 |
}
Tcl_SetObjResult(interp, Tcl_NewBignumObj(&root));
}
return TCL_OK;
negarg:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 |
}
Tcl_SetObjResult(interp, Tcl_NewBignumObj(&root));
}
return TCL_OK;
negarg:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"square root of negative argument", -1));
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"domain error: argument not in valid range", NULL);
return TCL_ERROR;
}
static int
ExprSqrtFunc(
|
| ︙ | ︙ | |||
7390 7391 7392 7393 7394 7395 7396 |
if (type == TCL_NUMBER_INT) {
Tcl_WideInt l = *((const Tcl_WideInt *) ptr);
if (l > 0) {
goto unChanged;
} else if (l == 0) {
if (TclHasStringRep(objv[1])) {
| | | 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 |
if (type == TCL_NUMBER_INT) {
Tcl_WideInt l = *((const Tcl_WideInt *) ptr);
if (l > 0) {
goto unChanged;
} else if (l == 0) {
if (TclHasStringRep(objv[1])) {
Tcl_Size numBytes;
const char *bytes = Tcl_GetStringFromObj(objv[1], &numBytes);
while (numBytes) {
if (*bytes == '-') {
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
return TCL_OK;
}
|
| ︙ | ︙ | |||
8470 8471 8472 8473 8474 8475 8476 |
*/
int
Tcl_NRCallObjProc(
Tcl_Interp *interp,
Tcl_ObjCmdProc *objProc,
void *clientData,
| | | 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 |
*/
int
Tcl_NRCallObjProc(
Tcl_Interp *interp,
Tcl_ObjCmdProc *objProc,
void *clientData,
Tcl_Size objc,
Tcl_Obj *const objv[])
{
NRE_callback *rootPtr = TOP_CB(interp);
TclNRAddCallback(interp, Dispatch, objProc, clientData,
INT2PTR(objc), objv);
return TclNRRunCallbacks(interp, TCL_OK, rootPtr);
|
| ︙ | ︙ | |||
8493 8494 8495 8496 8497 8498 8499 |
CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
clientData = info->clientData;
Tcl_ObjCmdProc2 *proc = info->proc;
Tcl_Free(info);
if (objc < 0) {
objc = -1;
}
| | | | 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 |
CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
clientData = info->clientData;
Tcl_ObjCmdProc2 *proc = info->proc;
Tcl_Free(info);
if (objc < 0) {
objc = -1;
}
return proc(clientData, interp, (Tcl_Size)objc, objv);
}
int
Tcl_NRCallObjProc2(
Tcl_Interp *interp,
Tcl_ObjCmdProc2 *objProc,
void *clientData,
ptrdiff_t objc,
Tcl_Obj *const objv[])
{
if (objc > INT_MAX) {
Tcl_WrongNumArgs(interp, 1, objv, "?args?");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
8557 8558 8559 8560 8561 8562 8563 |
int objc,
Tcl_Obj *const objv[])
{
CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
if (objc < 0) {
objc = -1;
}
| | | 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 |
int objc,
Tcl_Obj *const objv[])
{
CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
if (objc < 0) {
objc = -1;
}
return info->nreProc(info->clientData, interp, objc, objv);
}
Tcl_Command
Tcl_NRCreateCommand2(
Tcl_Interp *interp, /* Token for command interpreter (returned by
* previous call to Tcl_CreateInterp). */
const char *cmdName, /* Name of command. If it contains namespace
|
| ︙ | ︙ | |||
8653 8654 8655 8656 8657 8658 8659 |
return TclNREvalObjEx(interp, objPtr, flags, NULL, INT_MIN);
}
int
Tcl_NREvalObjv(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* command. Also used for error reporting. */
| | | | 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 |
return TclNREvalObjEx(interp, objPtr, flags, NULL, INT_MIN);
}
int
Tcl_NREvalObjv(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* command. Also used for error reporting. */
Tcl_Size objc, /* Number of words in command. */
Tcl_Obj *const objv[], /* An array of pointers to objects that are
* the words that make up the command. */
int flags) /* Collection of OR-ed bits that control the
* evaluation of the script. Only
* TCL_EVAL_GLOBAL, TCL_EVAL_INVOKE and
* TCL_EVAL_NOERR are currently supported. */
{
return TclNREvalObjv(interp, objc, objv, flags, NULL);
}
int
Tcl_NRCmdSwap(
Tcl_Interp *interp,
Tcl_Command cmd,
Tcl_Size objc,
Tcl_Obj *const objv[],
int flags)
{
return TclNREvalObjv(interp, objc, objv, flags|TCL_EVAL_NOERR,
(Command *) cmd);
}
|
| ︙ | ︙ | |||
8802 8803 8804 8805 8806 8807 8808 |
if (objc < 1) {
Tcl_WrongNumArgs(interp, 1, objv, "?command? ?arg ...?");
return TCL_ERROR;
}
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 |
if (objc < 1) {
Tcl_WrongNumArgs(interp, 1, objv, "?command? ?arg ...?");
return TCL_ERROR;
}
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"tailcall can only be called from a proc, lambda or method", -1));
Tcl_SetErrorCode(interp, "TCL", "TAILCALL", "ILLEGAL", NULL);
return TCL_ERROR;
}
/*
* Invocation without args just clears a scheduled tailcall; invocation
* with an argument replaces any previously scheduled tailcall.
|
| ︙ | ︙ | |||
8832 8833 8834 8835 8836 8837 8838 |
Tcl_Namespace *nsPtr = (Tcl_Namespace *) iPtr->varFramePtr->nsPtr;
/*
* The tailcall data is in a Tcl list: the first element is the
* namespace, the rest the command to be tailcalled.
*/
| | | 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 |
Tcl_Namespace *nsPtr = (Tcl_Namespace *) iPtr->varFramePtr->nsPtr;
/*
* The tailcall data is in a Tcl list: the first element is the
* namespace, the rest the command to be tailcalled.
*/
nsObjPtr = Tcl_NewStringObj(nsPtr->fullName, -1);
listPtr = Tcl_NewListObj(objc, objv);
TclListObjSetElement(interp, listPtr, 0, nsObjPtr);
iPtr->varFramePtr->tailcallPtr = listPtr;
}
return TCL_RETURN;
}
|
| ︙ | ︙ | |||
8860 8861 8862 8863 8864 8865 8866 |
void *data[],
Tcl_Interp *interp,
int result)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *listPtr = (Tcl_Obj *)data[0], *nsObjPtr;
Tcl_Namespace *nsPtr;
| | | 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 |
void *data[],
Tcl_Interp *interp,
int result)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *listPtr = (Tcl_Obj *)data[0], *nsObjPtr;
Tcl_Namespace *nsPtr;
Tcl_Size objc;
Tcl_Obj **objv;
TclListObjGetElementsM(interp, listPtr, &objc, &objv);
nsObjPtr = objv[0];
if (result == TCL_OK) {
result = TclGetNamespaceFromObj(interp, nsObjPtr, &nsPtr);
|
| ︙ | ︙ | |||
8964 8965 8966 8967 8968 8969 8970 |
if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?returnValue?");
return TCL_ERROR;
}
if (!corPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 |
if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?returnValue?");
return TCL_ERROR;
}
if (!corPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"yield can only be called in a coroutine", -1));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD", NULL);
return TCL_ERROR;
}
if (objc == 2) {
Tcl_SetObjResult(interp, objv[1]);
}
|
| ︙ | ︙ | |||
8997 8998 8999 9000 9001 9002 9003 |
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "command ?arg ...?");
return TCL_ERROR;
}
if (!corPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 |
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "command ?arg ...?");
return TCL_ERROR;
}
if (!corPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"yieldto can only be called in a coroutine", -1));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD", NULL);
return TCL_ERROR;
}
if (((Namespace *) nsPtr)->flags & NS_DYING) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"yieldto called in deleted namespace", -1));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "YIELDTO_IN_DELETED",
NULL);
return TCL_ERROR;
}
/*
* Add the tailcall in the caller env, then just yield.
*
* This is essentially code from TclNRTailcallObjCmd
*/
listPtr = Tcl_NewListObj(objc, objv);
nsObjPtr = Tcl_NewStringObj(nsPtr->fullName, -1);
TclListObjSetElement(interp, listPtr, 0, nsObjPtr);
/*
* Add the callback in the caller's env, then instruct TEBC to yield.
*/
iPtr->execEnvPtr = corPtr->callerEEPtr;
|
| ︙ | ︙ | |||
9208 9209 9210 9211 9212 9213 9214 |
/*
* Record the stackLevel at which the resume is happening, then swap
* the interp's environment to make it suitable to run this coroutine.
*/
corPtr->stackLevel = &corPtr;
| | | 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 |
/*
* Record the stackLevel at which the resume is happening, then swap
* the interp's environment to make it suitable to run this coroutine.
*/
corPtr->stackLevel = &corPtr;
Tcl_Size numLevels = corPtr->auxNumLevels;
corPtr->auxNumLevels = iPtr->numLevels;
SAVE_CONTEXT(corPtr->caller);
corPtr->callerEEPtr = iPtr->execEnvPtr;
RESTORE_CONTEXT(corPtr->running);
iPtr->execEnvPtr = corPtr->eePtr;
iPtr->numLevels += numLevels;
|
| ︙ | ︙ | |||
9239 9240 9241 9242 9243 9244 9245 |
}
}
}
iPtr->execEnvPtr = corPtr->eePtr;
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 |
}
}
}
iPtr->execEnvPtr = corPtr->eePtr;
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot yield: C stack busy", -1));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "CANT_YIELD",
NULL);
return TCL_ERROR;
}
void *type = data[1];
if (type == CORO_ACTIVATE_YIELD) {
corPtr->nargs = COROUTINE_ARGUMENTS_SINGLE_OPTIONAL;
} else if (type == CORO_ACTIVATE_YIELDM) {
corPtr->nargs = COROUTINE_ARGUMENTS_ARBITRARY;
} else {
Tcl_Panic("Yield received an option which is not implemented");
}
corPtr->yieldPtr = NULL;
corPtr->stackLevel = NULL;
Tcl_Size numLevels = iPtr->numLevels;
iPtr->numLevels = corPtr->auxNumLevels;
corPtr->auxNumLevels = numLevels - corPtr->auxNumLevels;
iPtr->execEnvPtr = corPtr->callerEEPtr;
}
return TCL_OK;
|
| ︙ | ︙ | |||
9284 9285 9286 9287 9288 9289 9290 |
static int
TclNREvalList(
void *data[],
Tcl_Interp *interp,
TCL_UNUSED(int) /*result*/)
{
| | | 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 |
static int
TclNREvalList(
void *data[],
Tcl_Interp *interp,
TCL_UNUSED(int) /*result*/)
{
Tcl_Size objc;
Tcl_Obj **objv;
Tcl_Obj *listPtr = (Tcl_Obj *)data[0];
Tcl_IncrRefCount(listPtr);
TclMarkTailcall(interp);
TclNRAddCallback(interp, TclNRReleaseValues, listPtr, NULL, NULL,NULL);
|
| ︙ | ︙ | |||
9328 9329 9330 9331 9332 9333 9334 |
/*
* Look up the coroutine.
*/
cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, objv[1]);
if ((!cmdPtr) || (cmdPtr->nreProc != TclNRInterpCoroutine)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | | | 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 |
/*
* Look up the coroutine.
*/
cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, objv[1]);
if ((!cmdPtr) || (cmdPtr->nreProc != TclNRInterpCoroutine)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can only get coroutine type of a coroutine", -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COROUTINE",
TclGetString(objv[1]), NULL);
return TCL_ERROR;
}
/*
* An active coroutine is "active". Can't tell what it might do in the
* future.
*/
corPtr = (CoroutineData *)cmdPtr->objClientData;
if (!COR_IS_SUSPENDED(corPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("active", -1));
return TCL_OK;
}
/*
* Inactive coroutines are classified by the (effective) command used to
* suspend them, which matters when you're injecting a probe.
*/
switch (corPtr->nargs) {
case COROUTINE_ARGUMENTS_SINGLE_OPTIONAL:
Tcl_SetObjResult(interp, Tcl_NewStringObj("yield", -1));
return TCL_OK;
case COROUTINE_ARGUMENTS_ARBITRARY:
Tcl_SetObjResult(interp, Tcl_NewStringObj("yieldto", -1));
return TCL_OK;
default:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unknown coroutine type", -1));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "BAD_TYPE", NULL);
return TCL_ERROR;
}
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
9388 9389 9390 9391 9392 9393 9394 |
/*
* How to get a coroutine from its handle.
*/
Command *cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, objPtr);
if ((!cmdPtr) || (cmdPtr->nreProc != TclNRInterpCoroutine)) {
| | | 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 |
/*
* How to get a coroutine from its handle.
*/
Command *cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, objPtr);
if ((!cmdPtr) || (cmdPtr->nreProc != TclNRInterpCoroutine)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(errMsg, -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COROUTINE",
TclGetString(objPtr), NULL);
return NULL;
}
return (CoroutineData *)cmdPtr->objClientData;
}
|
| ︙ | ︙ | |||
9422 9423 9424 9425 9426 9427 9428 |
corPtr = GetCoroutineFromObj(interp, objv[1],
"can only inject a command into a coroutine");
if (!corPtr) {
return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 |
corPtr = GetCoroutineFromObj(interp, objv[1],
"can only inject a command into a coroutine");
if (!corPtr) {
return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can only inject a command into a suspended coroutine", -1));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", NULL);
return TCL_ERROR;
}
/*
* Add the callback to the coro's execEnv, so that it is the first thing
* to happen when the coro is resumed.
|
| ︙ | ︙ | |||
9500 9501 9502 9503 9504 9505 9506 |
/*
* Record the stackLevel at which the resume is happening, then swap
* the interp's environment to make it suitable to run this coroutine.
*/
corPtr->stackLevel = &corPtr;
| | | 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 |
/*
* Record the stackLevel at which the resume is happening, then swap
* the interp's environment to make it suitable to run this coroutine.
*/
corPtr->stackLevel = &corPtr;
Tcl_Size numLevels = corPtr->auxNumLevels;
corPtr->auxNumLevels = iPtr->numLevels;
/*
* Do the actual stack swap.
*/
SAVE_CONTEXT(corPtr->caller);
|
| ︙ | ︙ | |||
9544 9545 9546 9547 9548 9549 9550 |
InjectHandler(
void *data[],
Tcl_Interp *interp,
TCL_UNUSED(int) /*result*/)
{
CoroutineData *corPtr = (CoroutineData *)data[0];
Tcl_Obj *listPtr = (Tcl_Obj *)data[1];
| | | | 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 |
InjectHandler(
void *data[],
Tcl_Interp *interp,
TCL_UNUSED(int) /*result*/)
{
CoroutineData *corPtr = (CoroutineData *)data[0];
Tcl_Obj *listPtr = (Tcl_Obj *)data[1];
Tcl_Size nargs = PTR2INT(data[2]);
void *isProbe = data[3];
Tcl_Size objc;
Tcl_Obj **objv;
if (!isProbe) {
/*
* If this is [coroinject], add the extra arguments now.
*/
|
| ︙ | ︙ | |||
9591 9592 9593 9594 9595 9596 9597 |
InjectHandlerPostCall(
void *data[],
Tcl_Interp *interp,
int result)
{
CoroutineData *corPtr = (CoroutineData *)data[0];
Tcl_Obj *listPtr = (Tcl_Obj *)data[1];
| | | 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 |
InjectHandlerPostCall(
void *data[],
Tcl_Interp *interp,
int result)
{
CoroutineData *corPtr = (CoroutineData *)data[0];
Tcl_Obj *listPtr = (Tcl_Obj *)data[1];
Tcl_Size nargs = PTR2INT(data[2]);
void *isProbe = data[3];
/*
* Delete the command words for what we just executed.
*/
Tcl_DecrRefCount(listPtr);
|
| ︙ | ︙ | |||
9614 9615 9616 9617 9618 9619 9620 |
if (isProbe) {
if (result == TCL_ERROR) {
Tcl_AddErrorInfo(interp,
"\n (injected coroutine probe command)");
}
corPtr->nargs = nargs;
corPtr->stackLevel = NULL;
| | | 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 |
if (isProbe) {
if (result == TCL_ERROR) {
Tcl_AddErrorInfo(interp,
"\n (injected coroutine probe command)");
}
corPtr->nargs = nargs;
corPtr->stackLevel = NULL;
Tcl_Size numLevels = iPtr->numLevels;
iPtr->numLevels = corPtr->auxNumLevels;
corPtr->auxNumLevels = numLevels - corPtr->auxNumLevels;
iPtr->execEnvPtr = corPtr->callerEEPtr;
}
return result;
}
|
| ︙ | ︙ | |||
9659 9660 9661 9662 9663 9664 9665 |
corPtr = GetCoroutineFromObj(interp, objv[1],
"can only inject a command into a coroutine");
if (!corPtr) {
return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 |
corPtr = GetCoroutineFromObj(interp, objv[1],
"can only inject a command into a coroutine");
if (!corPtr) {
return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can only inject a command into a suspended coroutine", -1));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", NULL);
return TCL_ERROR;
}
/*
* Add the callback to the coro's execEnv, so that it is the first thing
* to happen when the coro is resumed.
|
| ︙ | ︙ | |||
9710 9711 9712 9713 9714 9715 9716 |
Tcl_SetObjResult(interp, objv[1]);
} else if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?arg?");
return TCL_ERROR;
}
break;
default:
| | | | 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 |
Tcl_SetObjResult(interp, objv[1]);
} else if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?arg?");
return TCL_ERROR;
}
break;
default:
if (corPtr->nargs + 1 != objc) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("wrong coro nargs; how did we get here? "
"not implemented!", -1));
Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
return TCL_ERROR;
}
/* fallthrough */
case COROUTINE_ARGUMENTS_ARBITRARY:
if (objc > 1) {
Tcl_SetObjResult(interp, Tcl_NewListObj(objc-1, objv+1));
|
| ︙ | ︙ |
Changes to generic/tclBinary.c.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | #include <assert.h> /* * The following constants are used by GetFormatSpec to indicate various * special conditions in the parsing of a format specifier. */ | | | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include <assert.h> /* * The following constants are used by GetFormatSpec to indicate various * special conditions in the parsing of a format specifier. */ #define BINARY_ALL -1 /* Use all elements in the argument. */ #define BINARY_NOCOUNT -2 /* No count was specified in format. */ /* * The following flags may be OR'ed together and returned by GetFormatSpec */ #define BINARY_SIGNED 0 /* Field to be read as signed data */ #define BINARY_UNSIGNED 1 /* Field to be read as unsigned data */ /* * The following defines the maximum number of different (integer) numbers * placed in the object cache by 'binary scan' before it bails out and * switches back to Plan A (creating a new object for each value.) * Theoretically, it would be possible to keep the cache about for the values * that are already in it, but that makes the code slower in practice when * overflow happens, and makes little odds the rest of the time (as measured * on my machine.) It is also slower (on the sample I tried at least) to grow * the cache to hold all items we might want to put in it; presumably the * extra cost of managing the memory for the enlarged table outweighs the * benefit from allocating fewer objects. This is probably because as the * number of objects increases, the likelihood of reuse of any particular one * drops, and there is very little gain from larger maximum cache sizes (the |
| ︙ | ︙ | |||
57 58 59 60 61 62 63 | static void DupProperByteArrayInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static int FormatNumber(Tcl_Interp *interp, int type, Tcl_Obj *src, unsigned char **cursorPtr); static void FreeProperByteArrayInternalRep(Tcl_Obj *objPtr); static int GetFormatSpec(const char **formatPtr, char *cmdPtr, | | | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | static void DupProperByteArrayInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static int FormatNumber(Tcl_Interp *interp, int type, Tcl_Obj *src, unsigned char **cursorPtr); static void FreeProperByteArrayInternalRep(Tcl_Obj *objPtr); static int GetFormatSpec(const char **formatPtr, char *cmdPtr, Tcl_Size *countPtr, int *flagsPtr); static Tcl_Obj * ScanNumber(unsigned char *buffer, int type, int flags, Tcl_HashTable **numberCachePtr); static int SetByteArrayFromAny(Tcl_Interp *interp, Tcl_Size limit, Tcl_Obj *objPtr); static void UpdateStringOfByteArray(Tcl_Obj *listPtr); static void DeleteScanNumberCache(Tcl_HashTable *numberCachePtr); static int NeedReversing(int format); static void CopyNumber(const void *from, void *to, size_t length, int type); /* Binary ensemble commands */ |
| ︙ | ︙ | |||
170 171 172 173 174 175 176 |
* The following structure is the internal rep for a ByteArray object. Keeps
* track of how much memory has been used and how much has been allocated for
* the byte array to enable growing and shrinking of the ByteArray object with
* fewer mallocs.
*/
typedef struct {
| | | > < > | | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
* The following structure is the internal rep for a ByteArray object. Keeps
* track of how much memory has been used and how much has been allocated for
* the byte array to enable growing and shrinking of the ByteArray object with
* fewer mallocs.
*/
typedef struct {
Tcl_Size used; /* The number of bytes used in the byte
* array. */
Tcl_Size allocated; /* The amount of space actually allocated
* minus 1 byte. */
unsigned char bytes[TCLFLEXARRAY]; /* The array of bytes. The actual size of this
* field depends on the 'allocated' field
* above. */
} ByteArray;
#define BYTEARRAY_MAX_LEN (TCL_SIZE_MAX - (Tcl_Size)offsetof(ByteArray, bytes))
#define BYTEARRAY_SIZE(len) \
( (len < 0 || BYTEARRAY_MAX_LEN < (len)) \
? (Tcl_Panic("negative length specified or max size of a Tcl value exceeded"), 0) \
: (offsetof(ByteArray, bytes) + (len)) )
#define GET_BYTEARRAY(irPtr) ((ByteArray *) (irPtr)->twoPtrValue.ptr1)
#define SET_BYTEARRAY(irPtr, baPtr) \
(irPtr)->twoPtrValue.ptr1 = (baPtr)
int
TclIsPureByteArray(
|
| ︙ | ︙ | |||
218 219 220 221 222 223 224 |
#undef Tcl_NewByteArrayObj
Tcl_Obj *
Tcl_NewByteArrayObj(
const unsigned char *bytes, /* The array of bytes used to initialize the
* new object. */
| | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
#undef Tcl_NewByteArrayObj
Tcl_Obj *
Tcl_NewByteArrayObj(
const unsigned char *bytes, /* The array of bytes used to initialize the
* new object. */
Tcl_Size numBytes) /* Number of bytes in the array */
{
#ifdef TCL_MEM_DEBUG
return Tcl_DbNewByteArrayObj(bytes, numBytes, "unknown", 0);
#else /* if not TCL_MEM_DEBUG */
Tcl_Obj *objPtr;
TclNewObj(objPtr);
|
| ︙ | ︙ | |||
261 262 263 264 265 266 267 |
*/
#ifdef TCL_MEM_DEBUG
Tcl_Obj *
Tcl_DbNewByteArrayObj(
const unsigned char *bytes, /* The array of bytes used to initialize the
* new object. */
| | | | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
*/
#ifdef TCL_MEM_DEBUG
Tcl_Obj *
Tcl_DbNewByteArrayObj(
const unsigned char *bytes, /* The array of bytes used to initialize the
* new object. */
Tcl_Size numBytes, /* Number of bytes in the array */
const char *file, /* The name of the source file calling this
* procedure; used for debugging. */
int line) /* Line number in the source file; used for
* debugging. */
{
Tcl_Obj *objPtr;
TclDbNewObj(objPtr, file, line);
Tcl_SetByteArrayObj(objPtr, bytes, numBytes);
return objPtr;
}
#else /* if not TCL_MEM_DEBUG */
Tcl_Obj *
Tcl_DbNewByteArrayObj(
const unsigned char *bytes, /* The array of bytes used to initialize the
* new object. */
Tcl_Size numBytes, /* Number of bytes in the array */
TCL_UNUSED(const char *) /*file*/,
TCL_UNUSED(int) /*line*/)
{
return Tcl_NewByteArrayObj(bytes, numBytes);
}
#endif /* TCL_MEM_DEBUG */
|
| ︙ | ︙ | |||
309 310 311 312 313 314 315 |
*/
void
Tcl_SetByteArrayObj(
Tcl_Obj *objPtr, /* Object to initialize as a ByteArray. */
const unsigned char *bytes, /* The array of bytes to use as the new value.
* May be NULL even if numBytes > 0. */
| | > > | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
*/
void
Tcl_SetByteArrayObj(
Tcl_Obj *objPtr, /* Object to initialize as a ByteArray. */
const unsigned char *bytes, /* The array of bytes to use as the new value.
* May be NULL even if numBytes > 0. */
Tcl_Size numBytes) /* Number of bytes in the array.
* Must be >= 0 */
{
ByteArray *byteArrayPtr;
Tcl_ObjInternalRep ir;
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_SetByteArrayObj");
}
TclInvalidateStringRep(objPtr);
assert(numBytes >= 0);
byteArrayPtr = (ByteArray *)Tcl_Alloc(BYTEARRAY_SIZE(numBytes));
byteArrayPtr->used = numBytes;
byteArrayPtr->allocated = numBytes;
if ((bytes != NULL) && (numBytes > 0)) {
memcpy(byteArrayPtr->bytes, bytes, numBytes);
}
|
| ︙ | ︙ | |||
353 354 355 356 357 358 359 |
*/
#undef Tcl_GetBytesFromObj
unsigned char *
Tcl_GetBytesFromObj(
Tcl_Interp *interp, /* For error reporting */
Tcl_Obj *objPtr, /* Value to extract from */
| | > | | > | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
*/
#undef Tcl_GetBytesFromObj
unsigned char *
Tcl_GetBytesFromObj(
Tcl_Interp *interp, /* For error reporting */
Tcl_Obj *objPtr, /* Value to extract from */
Tcl_Size *numBytesPtr) /* If non-NULL, write the number of bytes
* in the array here */
{
ByteArray *baPtr;
const Tcl_ObjInternalRep *irPtr
= TclFetchInternalRep(objPtr, &properByteArrayType);
if (irPtr == NULL) {
if (TCL_ERROR == SetByteArrayFromAny(interp, TCL_INDEX_NONE, objPtr)) {
return NULL;
}
irPtr = TclFetchInternalRep(objPtr, &properByteArrayType);
}
baPtr = GET_BYTEARRAY(irPtr);
if (numBytesPtr != NULL) {
*numBytesPtr = baPtr->used;
}
return baPtr->bytes;
}
#if !defined(TCL_NO_DEPRECATED)
unsigned char *
TclGetBytesFromObj(
Tcl_Interp *interp, /* For error reporting */
Tcl_Obj *objPtr, /* Value to extract from */
int *numBytesPtr) /* If non-NULL, write the number of bytes
* in the array here */
{
Tcl_Size numBytes = 0;
unsigned char *bytes = Tcl_GetBytesFromObj(interp, objPtr, &numBytes);
if (bytes && numBytesPtr) {
if (numBytes > INT_MAX) {
/* Caller asked for numBytes to be written to an int, but the
* value is outside the int range. */
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"byte sequence length exceeds INT_MAX", -1));
Tcl_SetErrorCode(interp, "TCL", "API", "OUTDATED", NULL);
}
return NULL;
} else {
*numBytesPtr = (int) numBytes;
}
}
return bytes;
}
#endif
/*
*----------------------------------------------------------------------
*
* Tcl_SetByteArrayLength --
*
* This procedure changes the length of the byte array for this object.
|
| ︙ | ︙ | |||
427 428 429 430 431 432 433 |
*
*----------------------------------------------------------------------
*/
unsigned char *
Tcl_SetByteArrayLength(
Tcl_Obj *objPtr, /* The ByteArray object. */
| | > > | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
*
*----------------------------------------------------------------------
*/
unsigned char *
Tcl_SetByteArrayLength(
Tcl_Obj *objPtr, /* The ByteArray object. */
Tcl_Size numBytes) /* Number of bytes in resized array
* Must be >= 0 */
{
ByteArray *byteArrayPtr;
Tcl_ObjInternalRep *irPtr;
assert(numBytes >= 0);
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_SetByteArrayLength");
}
irPtr = TclFetchInternalRep(objPtr, &properByteArrayType);
if (irPtr == NULL) {
if (TCL_ERROR == SetByteArrayFromAny(NULL, numBytes, objPtr)) {
|
| ︙ | ︙ | |||
462 463 464 465 466 467 468 | /* *---------------------------------------------------------------------- * * MakeByteArray -- * * Generate a ByteArray internal rep from the string rep of objPtr. | | | | | < | | 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
/*
*----------------------------------------------------------------------
*
* MakeByteArray --
*
* Generate a ByteArray internal rep from the string rep of objPtr.
* The generated byte sequence may have no more than limit bytes.
* A negative value for limit indicates no limit imposed. If
* boolean argument demandProper is true, then no byte sequence should
* be output to the caller (write NULL instead). When no bytes sequence
* is output and interp is not NULL, leave an error message and error
* code in interp explaining why a proper byte sequence could not be
* made.
*
* Results:
* Returns a boolean indicating whether the bytes generated (up to
* limit bytes) are a proper representation of (a limited prefix of)
* the string. Writes a pointer to the generated ByteArray to
* *byteArrayPtrPtr. If not NULL it needs to be released with Tcl_Free().
*
*----------------------------------------------------------------------
*/
static int
MakeByteArray(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
Tcl_Size limit,
int demandProper,
ByteArray **byteArrayPtrPtr)
{
Tcl_Size length;
const char *src = Tcl_GetStringFromObj(objPtr, &length);
Tcl_Size numBytes = (limit >= 0 && limit < length) ? limit : length;
ByteArray *byteArrayPtr = (ByteArray *)Tcl_Alloc(BYTEARRAY_SIZE(numBytes));
unsigned char *dst = byteArrayPtr->bytes;
unsigned char *dstEnd = dst + numBytes;
const char *srcEnd = src + length;
int proper = 1;
for (; src < srcEnd && dst < dstEnd; ) {
|
| ︙ | ︙ | |||
565 566 567 568 569 570 571 |
*
*----------------------------------------------------------------------
*/
static int
SetByteArrayFromAny(
Tcl_Interp *interp, /* For error reporting. */
| | | 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
*
*----------------------------------------------------------------------
*/
static int
SetByteArrayFromAny(
Tcl_Interp *interp, /* For error reporting. */
Tcl_Size limit, /* Create no more than this many bytes */
Tcl_Obj *objPtr) /* The object to convert to type ByteArray. */
{
ByteArray *byteArrayPtr;
Tcl_ObjInternalRep ir;
if (0 == MakeByteArray(interp, objPtr, limit, 1, &byteArrayPtr)) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
626 627 628 629 630 631 632 |
*/
static void
DupProperByteArrayInternalRep(
Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
Tcl_Obj *copyPtr) /* Object with internal rep to set. */
{
| | | 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
*/
static void
DupProperByteArrayInternalRep(
Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
Tcl_Obj *copyPtr) /* Object with internal rep to set. */
{
Tcl_Size length;
ByteArray *srcArrayPtr, *copyArrayPtr;
Tcl_ObjInternalRep ir;
srcArrayPtr = GET_BYTEARRAY(TclFetchInternalRep(srcPtr, &properByteArrayType));
length = srcArrayPtr->used;
copyArrayPtr = (ByteArray *)Tcl_Alloc(BYTEARRAY_SIZE(length));
|
| ︙ | ︙ | |||
667 668 669 670 671 672 673 |
UpdateStringOfByteArray(
Tcl_Obj *objPtr) /* ByteArray object whose string rep to
* update. */
{
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objPtr, &properByteArrayType);
ByteArray *byteArrayPtr = GET_BYTEARRAY(irPtr);
unsigned char *src = byteArrayPtr->bytes;
| | | | 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
UpdateStringOfByteArray(
Tcl_Obj *objPtr) /* ByteArray object whose string rep to
* update. */
{
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objPtr, &properByteArrayType);
ByteArray *byteArrayPtr = GET_BYTEARRAY(irPtr);
unsigned char *src = byteArrayPtr->bytes;
Tcl_Size i, length = byteArrayPtr->used;
Tcl_Size size = length;
/*
* How much space will string rep need?
*/
for (i = 0; i < length; i++) {
if ((src[i] == 0) || (src[i] > 127)) {
|
| ︙ | ︙ | |||
717 718 719 720 721 722 723 |
*----------------------------------------------------------------------
*/
void
TclAppendBytesToByteArray(
Tcl_Obj *objPtr,
const unsigned char *bytes,
| | | | | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
*----------------------------------------------------------------------
*/
void
TclAppendBytesToByteArray(
Tcl_Obj *objPtr,
const unsigned char *bytes,
Tcl_Size len)
{
ByteArray *byteArrayPtr;
Tcl_Size needed;
Tcl_ObjInternalRep *irPtr;
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object","TclAppendBytesToByteArray");
}
if (len < 0) {
Tcl_Panic("%s must be called with definite number of bytes to append",
"TclAppendBytesToByteArray");
}
if (len == 0) {
/*
* Append zero bytes is a no-op.
*/
|
| ︙ | ︙ | |||
751 752 753 754 755 756 757 |
}
byteArrayPtr = GET_BYTEARRAY(irPtr);
/*
* If we need to, resize the allocated space in the byte array.
*/
| < | | | > | | > | > | > > | | < | | | 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
}
byteArrayPtr = GET_BYTEARRAY(irPtr);
/*
* If we need to, resize the allocated space in the byte array.
*/
if ((BYTEARRAY_MAX_LEN - byteArrayPtr->used) < len) {
/* Will wrap around !! */
Tcl_Panic("max size of a byte array exceeded");
}
needed = byteArrayPtr->used + len;
if (needed > byteArrayPtr->allocated) {
ByteArray *ptr = NULL;
/*
* Try to allocate double the total space that is needed.
*/
Tcl_Size attempt;
/* Make sure we do not wrap when doubling */
if (needed <= (BYTEARRAY_MAX_LEN - needed)) {
attempt = 2 * needed;
ptr = (ByteArray *) Tcl_AttemptRealloc(byteArrayPtr,
BYTEARRAY_SIZE(attempt));
}
if (ptr == NULL) {
/*
* Try to allocate double the increment that is needed.
* (Originally TCL_MIN_GROWTH was added as well but that would
* need one more separate overflow check so forget it.)
*/
if (len <= (BYTEARRAY_MAX_LEN - needed)) {
attempt = needed + len;
ptr = (ByteArray *)Tcl_AttemptRealloc(byteArrayPtr,
BYTEARRAY_SIZE(attempt));
}
}
if (ptr == NULL) {
/*
* Last chance: Try to allocate exactly what is needed.
*/
|
| ︙ | ︙ | |||
857 858 859 860 861 862 863 |
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int arg; /* Index of next argument to consume. */
int value = 0; /* Current integer value to be packed.
* Initialized to avoid compiler warning. */
char cmd; /* Current format character. */
| | | | 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 |
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int arg; /* Index of next argument to consume. */
int value = 0; /* Current integer value to be packed.
* Initialized to avoid compiler warning. */
char cmd; /* Current format character. */
Tcl_Size count; /* Count associated with current format
* character. */
int flags; /* Format field flags */
const char *format; /* Pointer to current position in format
* string. */
Tcl_Obj *resultPtr = NULL; /* Object holding result buffer. */
unsigned char *buffer; /* Start of result buffer. */
unsigned char *cursor; /* Current position within result buffer. */
unsigned char *maxPos; /* Greatest position within result buffer that
* cursor has visited.*/
const char *errorString;
const char *errorValue, *str;
Tcl_Size offset, size, length;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "formatString ?arg ...?");
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
967 968 969 970 971 972 973 |
* non-list value.
*/
if (count == BINARY_NOCOUNT) {
arg++;
count = 1;
} else {
| | | 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 |
* non-list value.
*/
if (count == BINARY_NOCOUNT) {
arg++;
count = 1;
} else {
Tcl_Size listc;
Tcl_Obj **listv;
/*
* The macro evals its args more than once: avoid arg++
*/
if (TclListObjLengthM(interp, objv[arg], &listc
|
| ︙ | ︙ | |||
999 1000 1001 1002 1003 1004 1005 |
}
offset += count*size;
break;
case 'x':
if (count == BINARY_ALL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
}
offset += count*size;
break;
case 'x':
if (count == BINARY_ALL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot use \"*\" in format string with \"x\"", -1));
return TCL_ERROR;
} else if (count == BINARY_NOCOUNT) {
count = 1;
}
offset += count;
break;
case 'X':
|
| ︙ | ︙ | |||
1043 1044 1045 1046 1047 1048 1049 |
length = offset;
}
if (length == 0) {
return TCL_OK;
}
/*
| | | 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
length = offset;
}
if (length == 0) {
return TCL_OK;
}
/*
* Prepare the result object by preallocating the calculated number of
* bytes and filling with nulls.
*/
TclNewObj(resultPtr);
buffer = Tcl_SetByteArrayLength(resultPtr, length);
memset(buffer, 0, length);
|
| ︙ | ︙ | |||
1249 1250 1251 1252 1253 1254 1255 |
case 'W':
case 'r':
case 'R':
case 'd':
case 'q':
case 'Q':
case 'f': {
| | | 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 |
case 'W':
case 'r':
case 'R':
case 'd':
case 'q':
case 'Q':
case 'f': {
Tcl_Size listc, i;
Tcl_Obj **listv;
if (count == BINARY_NOCOUNT) {
/*
* Note that we are casting away the const-ness of objv, but
* this is safe since we aren't going to modify the array.
*/
|
| ︙ | ︙ | |||
1290 1291 1292 1293 1294 1295 1296 |
case 'X':
if (cursor > maxPos) {
maxPos = cursor;
}
if (count == BINARY_NOCOUNT) {
count = 1;
}
| | | 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 |
case 'X':
if (cursor > maxPos) {
maxPos = cursor;
}
if (count == BINARY_NOCOUNT) {
count = 1;
}
if ((count == BINARY_ALL) || (count > (cursor - buffer))) {
cursor = buffer;
} else {
cursor -= count;
}
break;
case '@':
if (cursor > maxPos) {
|
| ︙ | ︙ | |||
1339 1340 1341 1342 1343 1344 1345 |
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad field specifier \"%s\"", buf));
return TCL_ERROR;
}
error:
| | | 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 |
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad field specifier \"%s\"", buf));
return TCL_ERROR;
}
error:
Tcl_SetObjResult(interp, Tcl_NewStringObj(errorString, -1));
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* BinaryScanCmd --
|
| ︙ | ︙ | |||
1370 1371 1372 1373 1374 1375 1376 |
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int arg; /* Index of next argument to consume. */
int value = 0; /* Current integer value to be packed.
* Initialized to avoid compiler warning. */
char cmd; /* Current format character. */
| | | | 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 |
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int arg; /* Index of next argument to consume. */
int value = 0; /* Current integer value to be packed.
* Initialized to avoid compiler warning. */
char cmd; /* Current format character. */
Tcl_Size count; /* Count associated with current format
* character. */
int flags; /* Format field flags */
const char *format; /* Pointer to current position in format
* string. */
Tcl_Obj *resultPtr = NULL; /* Object holding result buffer. */
unsigned char *buffer; /* Start of result buffer. */
const char *errorString;
const char *str;
Tcl_Size offset, size, length = 0, i;
Tcl_Obj *valuePtr, *elementPtr;
Tcl_HashTable numberCacheHash;
Tcl_HashTable *numberCachePtr;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv,
|
| ︙ | ︙ | |||
1488 1489 1490 1491 1492 1493 1494 |
}
if (count == BINARY_ALL) {
count = (length - offset) * 8;
} else {
if (count == BINARY_NOCOUNT) {
count = 1;
}
| | | 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 |
}
if (count == BINARY_ALL) {
count = (length - offset) * 8;
} else {
if (count == BINARY_NOCOUNT) {
count = 1;
}
if (count > (length - offset) * 8) {
goto done;
}
}
src = buffer + offset;
TclNewObj(valuePtr);
Tcl_SetObjLength(valuePtr, count);
dest = TclGetString(valuePtr);
|
| ︙ | ︙ | |||
1619 1620 1621 1622 1623 1624 1625 |
scanNumber:
if (arg >= objc) {
DeleteScanNumberCache(numberCachePtr);
goto badIndex;
}
if (count == BINARY_NOCOUNT) {
| | | 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 |
scanNumber:
if (arg >= objc) {
DeleteScanNumberCache(numberCachePtr);
goto badIndex;
}
if (count == BINARY_NOCOUNT) {
if (length < size + offset) {
goto done;
}
valuePtr = ScanNumber(buffer+offset, cmd, flags,
&numberCachePtr);
offset += size;
} else {
if (count == BINARY_ALL) {
|
| ︙ | ︙ | |||
1720 1721 1722 1723 1724 1725 1726 |
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad field specifier \"%s\"", buf));
return TCL_ERROR;
}
error:
| | | 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 |
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad field specifier \"%s\"", buf));
return TCL_ERROR;
}
error:
Tcl_SetObjResult(interp, Tcl_NewStringObj(errorString, -1));
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* GetFormatSpec --
|
| ︙ | ︙ | |||
1749 1750 1751 1752 1753 1754 1755 |
*----------------------------------------------------------------------
*/
static int
GetFormatSpec(
const char **formatPtr, /* Pointer to format string. */
char *cmdPtr, /* Pointer to location of command char. */
| | | 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 |
*----------------------------------------------------------------------
*/
static int
GetFormatSpec(
const char **formatPtr, /* Pointer to format string. */
char *cmdPtr, /* Pointer to location of command char. */
Tcl_Size *countPtr, /* Pointer to repeat count value. */
int *flagsPtr) /* Pointer to field flags */
{
/*
* Skip any leading blanks.
*/
while (**formatPtr == ' ') {
|
| ︙ | ︙ | |||
1782 1783 1784 1785 1786 1787 1788 |
(*formatPtr)++;
*flagsPtr |= BINARY_UNSIGNED;
}
if (**formatPtr == '*') {
(*formatPtr)++;
*countPtr = BINARY_ALL;
} else if (isdigit(UCHAR(**formatPtr))) { /* INTL: digit */
| | | | | | | | 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 |
(*formatPtr)++;
*flagsPtr |= BINARY_UNSIGNED;
}
if (**formatPtr == '*') {
(*formatPtr)++;
*countPtr = BINARY_ALL;
} else if (isdigit(UCHAR(**formatPtr))) { /* INTL: digit */
unsigned long long count;
errno = 0;
count = strtoull(*formatPtr, (char **) formatPtr, 10);
if (errno || (count > TCL_SIZE_MAX)) {
*countPtr = TCL_SIZE_MAX;
} else {
*countPtr = count;
}
} else {
*countPtr = BINARY_NOCOUNT;
}
return 1;
}
/*
*----------------------------------------------------------------------
*
* NeedReversing --
*
* This routine determines, if bytes of a number need to be re-ordered,
* and returns a numeric code indicating the re-ordering to be done.
* This depends on the endianness of the machine and the desired format.
* It is in effect a table (whose contents depend on the endianness of
* the system) describing whether a value needs reversing or not. Anyone
* porting the code to a big-endian platform should take care to make
* sure that they define WORDS_BIGENDIAN though this is already done by
* configure for the Unix build; little-endian platforms (including
* Windows) don't need to do anything.
*
|
| ︙ | ︙ | |||
2453 2454 2455 2456 2457 2458 2459 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *resultObj = NULL;
unsigned char *data = NULL;
unsigned char *cursor = NULL;
| | | 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *resultObj = NULL;
unsigned char *data = NULL;
unsigned char *cursor = NULL;
Tcl_Size offset = 0, count = 0;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "data");
return TCL_ERROR;
}
data = Tcl_GetBytesFromObj(interp, objv[1], &count);
|
| ︙ | ︙ | |||
2502 2503 2504 2505 2506 2507 2508 |
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *resultObj = NULL;
unsigned char *data, *datastart, *dataend;
unsigned char *begin, *cursor, c;
int i, index, value, pure = 1, strict = 0;
| | | 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 |
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *resultObj = NULL;
unsigned char *data, *datastart, *dataend;
unsigned char *begin, *cursor, c;
int i, index, value, pure = 1, strict = 0;
Tcl_Size size, cut = 0, count = 0;
int ucs4;
enum {OPT_STRICT };
static const char *const optStrings[] = { "-strict", NULL };
if (objc < 2 || objc > 3) {
Tcl_WrongNumArgs(interp, 1, objv, "?options? data");
return TCL_ERROR;
|
| ︙ | ︙ | |||
2625 2626 2627 2628 2629 2630 2631 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *resultObj;
unsigned char *data, *limit;
| | | | | | | | 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *resultObj;
unsigned char *data, *limit;
Tcl_Size maxlen = 0;
const char *wrapchar = "\n";
Tcl_Size wrapcharlen = 1;
int index, purewrap = 1;
Tcl_Size i, offset, size, outindex = 0, count = 0;
enum { OPT_MAXLEN, OPT_WRAPCHAR };
static const char *const optStrings[] = { "-maxlen", "-wrapchar", NULL };
if (objc < 2 || objc % 2 != 0) {
Tcl_WrongNumArgs(interp, 1, objv,
"?-maxlen len? ?-wrapchar char? data");
return TCL_ERROR;
}
for (i = 1; i < objc - 1; i += 2) {
if (Tcl_GetIndexFromObj(interp, objv[i], optStrings, "option",
TCL_EXACT, &index) != TCL_OK) {
return TCL_ERROR;
}
switch (index) {
case OPT_MAXLEN:
if (Tcl_GetSizeIntFromObj(interp, objv[i + 1], &maxlen) != TCL_OK) {
return TCL_ERROR;
}
if (maxlen < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"line length out of range", -1));
Tcl_SetErrorCode(interp, "TCL", "BINARY", "ENCODE",
"LINE_LENGTH", NULL);
return TCL_ERROR;
}
break;
case OPT_WRAPCHAR:
wrapchar = (const char *)Tcl_GetByteArrayFromObj(
|
| ︙ | ︙ | |||
2751 2752 2753 2754 2755 2756 2757 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *resultObj;
unsigned char *data, *start, *cursor;
| | | | 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *resultObj;
unsigned char *data, *start, *cursor;
int i, bits, index;
unsigned int n;
int lineLength = 61;
const unsigned char SingleNewline[] = { UCHAR('\n') };
const unsigned char *wrapchar = SingleNewline;
Tcl_Size j, rawLength, offset, count = 0, wrapcharlen = sizeof(SingleNewline);
enum { OPT_MAXLEN, OPT_WRAPCHAR };
static const char *const optStrings[] = { "-maxlen", "-wrapchar", NULL };
if (objc < 2 || objc % 2 != 0) {
Tcl_WrongNumArgs(interp, 1, objv,
"?-maxlen len? ?-wrapchar char? data");
return TCL_ERROR;
|
| ︙ | ︙ | |||
2778 2779 2780 2781 2782 2783 2784 |
case OPT_MAXLEN:
if (Tcl_GetIntFromObj(interp, objv[i + 1],
&lineLength) != TCL_OK) {
return TCL_ERROR;
}
if (lineLength < 5 || lineLength > 85) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 |
case OPT_MAXLEN:
if (Tcl_GetIntFromObj(interp, objv[i + 1],
&lineLength) != TCL_OK) {
return TCL_ERROR;
}
if (lineLength < 5 || lineLength > 85) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"line length out of range", -1));
Tcl_SetErrorCode(interp, "TCL", "BINARY", "ENCODE",
"LINE_LENGTH", NULL);
return TCL_ERROR;
}
lineLength = ((lineLength - 1) & -4) + 1; /* 5, 9, 13 ... */
break;
case OPT_WRAPCHAR:
wrapchar = (const unsigned char *) Tcl_GetStringFromObj(
objv[i + 1], &wrapcharlen);
{
const unsigned char *p = wrapchar;
Tcl_Size numBytes = wrapcharlen;
while (numBytes) {
switch (*p) {
case '\t':
case '\v':
case '\f':
case '\r':
|
| ︙ | ︙ | |||
2846 2847 2848 2849 2850 2851 2852 |
* Encode the data. Each output line first has the length of raw data
* encoded by the output line described in it by one encoded byte, then
* the encoded data follows (encoding each 6 bits as one character).
* Encoded lines are always terminated by a newline.
*/
while (offset < count) {
| | | 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 |
* Encode the data. Each output line first has the length of raw data
* encoded by the output line described in it by one encoded byte, then
* the encoded data follows (encoding each 6 bits as one character).
* Encoded lines are always terminated by a newline.
*/
while (offset < count) {
Tcl_Size lineLen = count - offset;
if (lineLen > rawLength) {
lineLen = rawLength;
}
*cursor++ = UueDigits[lineLen];
for (i = 0 ; i < lineLen ; i++) {
n <<= 8;
|
| ︙ | ︙ | |||
2905 2906 2907 2908 2909 2910 2911 |
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *resultObj = NULL;
unsigned char *data, *datastart, *dataend;
unsigned char *begin, *cursor;
int i, index, pure = 1, strict = 0, lineLen;
| | | 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 |
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *resultObj = NULL;
unsigned char *data, *datastart, *dataend;
unsigned char *begin, *cursor;
int i, index, pure = 1, strict = 0, lineLen;
Tcl_Size size, count = 0;
unsigned char c;
int ucs4;
enum { OPT_STRICT };
static const char *const optStrings[] = { "-strict", NULL };
if (objc < 2 || objc > 3) {
Tcl_WrongNumArgs(interp, 1, objv, "?options? data");
|
| ︙ | ︙ | |||
3081 3082 3083 3084 3085 3086 3087 |
{
Tcl_Obj *resultObj = NULL;
unsigned char *data, *datastart, *dataend, c = '\0';
unsigned char *begin = NULL;
unsigned char *cursor = NULL;
int pure = 1, strict = 0;
int i, index, cut = 0;
| | | 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 |
{
Tcl_Obj *resultObj = NULL;
unsigned char *data, *datastart, *dataend, c = '\0';
unsigned char *begin = NULL;
unsigned char *cursor = NULL;
int pure = 1, strict = 0;
int i, index, cut = 0;
Tcl_Size size, count = 0;
int ucs4;
enum { OPT_STRICT };
static const char *const optStrings[] = { "-strict", NULL };
if (objc < 2 || objc > 3) {
Tcl_WrongNumArgs(interp, 1, objv, "?options? data");
return TCL_ERROR;
|
| ︙ | ︙ |
Changes to generic/tclCkalloc.c.
| ︙ | ︙ | |||
168 169 170 171 172 173 174 |
int flags)
{
char buf[1024];
if (clientData == NULL) {
return 0;
}
| | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
int flags)
{
char buf[1024];
if (clientData == NULL) {
return 0;
}
snprintf(buf, sizeof(buf),
"total mallocs %10" TCL_Z_MODIFIER "u\n"
"total frees %10" TCL_Z_MODIFIER "u\n"
"current packets allocated %10" TCL_Z_MODIFIER "u\n"
"current bytes allocated %10" TCL_Z_MODIFIER "u\n"
"maximum packets allocated %10" TCL_Z_MODIFIER "u\n"
"maximum bytes allocated %10" TCL_Z_MODIFIER "u\n",
total_mallocs,
total_frees,
current_malloc_packets,
current_bytes_malloced,
maximum_malloc_packets,
maximum_bytes_malloced);
if (flags == 0) {
fprintf((FILE *)clientData, "%s", buf);
} else {
/* Assume objPtr to append to */
Tcl_AppendToObj((Tcl_Obj *) clientData, buf, -1);
}
return 1;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ |
Changes to generic/tclClock.c.
| ︙ | ︙ | |||
139 140 141 142 143 144 145 | /* * Function prototypes for local procedures in this file: */ static int ConvertUTCToLocal(Tcl_Interp *, TclDateFields *, Tcl_Obj *, int); static int ConvertUTCToLocalUsingTable(Tcl_Interp *, | | | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | /* * Function prototypes for local procedures in this file: */ static int ConvertUTCToLocal(Tcl_Interp *, TclDateFields *, Tcl_Obj *, int); static int ConvertUTCToLocalUsingTable(Tcl_Interp *, TclDateFields *, Tcl_Size, Tcl_Obj *const[]); static int ConvertUTCToLocalUsingC(Tcl_Interp *, TclDateFields *, int); static int ConvertLocalToUTC(Tcl_Interp *, TclDateFields *, Tcl_Obj *, int); static int ConvertLocalToUTCUsingTable(Tcl_Interp *, TclDateFields *, Tcl_Size, Tcl_Obj *const[]); static int ConvertLocalToUTCUsingC(Tcl_Interp *, TclDateFields *, int); static Tcl_Obj * LookupLastTransition(Tcl_Interp *, Tcl_WideInt, Tcl_Size, Tcl_Obj *const *); static void GetYearWeekDay(TclDateFields *, int); static void GetGregorianEraYearDay(TclDateFields *, int); static void GetMonthDay(TclDateFields *); static void GetJulianDayFromEraYearWeekDay(TclDateFields *, int); static void GetJulianDayFromEraYearMonthDay(TclDateFields *, int); static int IsGregorianLeapYear(TclDateFields *); static int WeekdayOnOrBefore(int, int); |
| ︙ | ︙ | |||
724 725 726 727 728 729 730 |
static int
ConvertLocalToUTC(
Tcl_Interp *interp, /* Tcl interpreter */
TclDateFields *fields, /* Fields of the time */
Tcl_Obj *tzdata, /* Time zone data */
int changeover) /* Julian Day of the Gregorian transition */
{
| | | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 |
static int
ConvertLocalToUTC(
Tcl_Interp *interp, /* Tcl interpreter */
TclDateFields *fields, /* Fields of the time */
Tcl_Obj *tzdata, /* Time zone data */
int changeover) /* Julian Day of the Gregorian transition */
{
Tcl_Size rowc; /* Number of rows in tzdata */
Tcl_Obj **rowv; /* Pointers to the rows */
/*
* Unpack the tz data.
*/
if (TclListObjGetElementsM(interp, tzdata, &rowc, &rowv) != TCL_OK) {
|
| ︙ | ︙ | |||
769 770 771 772 773 774 775 |
*----------------------------------------------------------------------
*/
static int
ConvertLocalToUTCUsingTable(
Tcl_Interp *interp, /* Tcl interpreter */
TclDateFields *fields, /* Time to convert, with 'seconds' filled in */
| | | | 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 |
*----------------------------------------------------------------------
*/
static int
ConvertLocalToUTCUsingTable(
Tcl_Interp *interp, /* Tcl interpreter */
TclDateFields *fields, /* Time to convert, with 'seconds' filled in */
Tcl_Size rowc, /* Number of points at which time changes */
Tcl_Obj *const rowv[]) /* Points at which time changes */
{
Tcl_Obj *row;
Tcl_Size cellc;
Tcl_Obj **cellv;
int have[8];
int nHave = 0;
int i;
int found;
/*
|
| ︙ | ︙ | |||
927 928 929 930 931 932 933 |
static int
ConvertUTCToLocal(
Tcl_Interp *interp, /* Tcl interpreter */
TclDateFields *fields, /* Fields of the time */
Tcl_Obj *tzdata, /* Time zone data */
int changeover) /* Julian Day of the Gregorian transition */
{
| | | 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 |
static int
ConvertUTCToLocal(
Tcl_Interp *interp, /* Tcl interpreter */
TclDateFields *fields, /* Fields of the time */
Tcl_Obj *tzdata, /* Time zone data */
int changeover) /* Julian Day of the Gregorian transition */
{
Tcl_Size rowc; /* Number of rows in tzdata */
Tcl_Obj **rowv; /* Pointers to the rows */
/*
* Unpack the tz data.
*/
if (TclListObjGetElementsM(interp, tzdata, &rowc, &rowv) != TCL_OK) {
|
| ︙ | ︙ | |||
972 973 974 975 976 977 978 |
*----------------------------------------------------------------------
*/
static int
ConvertUTCToLocalUsingTable(
Tcl_Interp *interp, /* Tcl interpreter */
TclDateFields *fields, /* Fields of the date */
| | | | 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 |
*----------------------------------------------------------------------
*/
static int
ConvertUTCToLocalUsingTable(
Tcl_Interp *interp, /* Tcl interpreter */
TclDateFields *fields, /* Fields of the date */
Tcl_Size rowc, /* Number of rows in the conversion table
* (>= 1) */
Tcl_Obj *const rowv[]) /* Rows of the conversion table */
{
Tcl_Obj *row; /* Row containing the current information */
Tcl_Size cellc; /* Count of cells in the row (must be 4) */
Tcl_Obj **cellv; /* Pointers to the cells */
/*
* Look up the nearest transition time.
*/
row = LookupLastTransition(interp, fields->seconds, rowc, rowv);
|
| ︙ | ︙ | |||
1082 1083 1084 1085 1086 1087 1088 |
fields->tzOffset = diff;
if (diff < 0) {
*buffer = '-';
diff = -diff;
} else {
*buffer = '+';
}
| | | | | 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 |
fields->tzOffset = diff;
if (diff < 0) {
*buffer = '-';
diff = -diff;
} else {
*buffer = '+';
}
snprintf(buffer+1, sizeof(buffer) - 1, "%02d", diff / 3600);
diff %= 3600;
snprintf(buffer+3, sizeof(buffer) - 3, "%02d", diff / 60);
diff %= 60;
if (diff > 0) {
snprintf(buffer+5, sizeof(buffer) - 5, "%02d", diff);
}
fields->tzName = Tcl_NewStringObj(buffer, -1);
Tcl_IncrRefCount(fields->tzName);
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
1112 1113 1114 1115 1116 1117 1118 |
*----------------------------------------------------------------------
*/
static Tcl_Obj *
LookupLastTransition(
Tcl_Interp *interp, /* Interpreter for error messages */
Tcl_WideInt tick, /* Time from the epoch */
| | | | | 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 |
*----------------------------------------------------------------------
*/
static Tcl_Obj *
LookupLastTransition(
Tcl_Interp *interp, /* Interpreter for error messages */
Tcl_WideInt tick, /* Time from the epoch */
Tcl_Size rowc, /* Number of rows of tzdata */
Tcl_Obj *const *rowv) /* Rows in tzdata */
{
Tcl_Size l;
Tcl_Size u;
Tcl_Obj *compObj;
Tcl_WideInt compVal;
/*
* Examine the first row to make sure we're in bounds.
*/
|
| ︙ | ︙ |
Changes to generic/tclCmdAH.c.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 |
* The state structure used by [foreach]. Note that the actual structure has
* all its working arrays appended afterwards so they can be allocated and
* freed in a single step.
*/
struct ForeachState {
Tcl_Obj *bodyPtr; /* The script body of the command. */
| | | | | | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
* The state structure used by [foreach]. Note that the actual structure has
* all its working arrays appended afterwards so they can be allocated and
* freed in a single step.
*/
struct ForeachState {
Tcl_Obj *bodyPtr; /* The script body of the command. */
Tcl_Size bodyIdx; /* The argument index of the body. */
Tcl_Size j, maxj; /* Number of loop iterations. */
Tcl_Size numLists; /* Count of value lists. */
Tcl_Size *index; /* Array of value list indices. */
Tcl_Size *varcList; /* # loop variables per list. */
Tcl_Obj ***varvList; /* Array of var name lists. */
Tcl_Obj **vCopyList; /* Copies of var name list arguments. */
Tcl_Size *argcList; /* Array of value list sizes. */
Tcl_Obj ***argvList; /* Array of value lists. */
Tcl_Obj **aCopyList; /* Copies of value list arguments. */
Tcl_Obj *resultList; /* List of result values from the loop body,
* or NULL if we're not collecting them
* ([lmap] vs [foreach]). */
};
|
| ︙ | ︙ | |||
525 526 527 528 529 530 531 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *data; /* Byte array to convert */
Tcl_DString ds; /* Buffer to hold the string */
Tcl_Encoding encoding; /* Encoding to use */
| | | 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *data; /* Byte array to convert */
Tcl_DString ds; /* Buffer to hold the string */
Tcl_Encoding encoding; /* Encoding to use */
Tcl_Size length = 0; /* Length of the byte array being converted */
const char *bytesPtr; /* Pointer to the first byte of the array */
int flags;
int result;
Tcl_Obj *failVarObj;
Tcl_Size errorLocation;
if (EncodingConvertParseOptions(
|
| ︙ | ︙ | |||
625 626 627 628 629 630 631 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *data; /* String to convert */
Tcl_DString ds; /* Buffer to hold the byte array */
Tcl_Encoding encoding; /* Encoding to use */
| | | 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *data; /* String to convert */
Tcl_DString ds; /* Buffer to hold the byte array */
Tcl_Encoding encoding; /* Encoding to use */
Tcl_Size length; /* Length of the string being converted */
const char *stringPtr; /* Pointer to the first byte of the string */
int result;
int flags;
Tcl_Obj *failVarObj;
Tcl_Size errorLocation;
if (EncodingConvertParseOptions(
|
| ︙ | ︙ | |||
2059 2060 2061 2062 2063 2064 2065 |
{
Tcl_Obj *res;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "name");
return TCL_ERROR;
}
| | | 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 |
{
Tcl_Obj *res;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "name");
return TCL_ERROR;
}
res = Tcl_FSSplitPath(objv[1], NULL);
if (res == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"could not read \"%s\": no such file or directory",
TclGetString(objv[1])));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PATHSPLIT", "NONESUCH",
NULL);
return TCL_ERROR;
|
| ︙ | ︙ | |||
2728 2729 2730 2731 2732 2733 2734 |
int collect, /* Select collecting or accumulating mode
* (TCL_EACH_*) */
int objc, /* The arguments being passed in... */
Tcl_Obj *const objv[])
{
int numLists = (objc-2) / 2;
struct ForeachState *statePtr;
| | > | 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 |
int collect, /* Select collecting or accumulating mode
* (TCL_EACH_*) */
int objc, /* The arguments being passed in... */
Tcl_Obj *const objv[])
{
int numLists = (objc-2) / 2;
struct ForeachState *statePtr;
int i, result;
Tcl_Size j;
if (objc < 4 || (objc%2 != 0)) {
Tcl_WrongNumArgs(interp, 1, objv,
"varList list ?varList list ...? command");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2752 2753 2754 2755 2756 2757 2758 |
*
* The setting up of all of these pointers is moderately messy, but allows
* the rest of this code to be simple and for us to use a single memory
* allocation for better performance.
*/
statePtr = (struct ForeachState *)TclStackAlloc(interp,
| | | | | 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 |
*
* The setting up of all of these pointers is moderately messy, but allows
* the rest of this code to be simple and for us to use a single memory
* allocation for better performance.
*/
statePtr = (struct ForeachState *)TclStackAlloc(interp,
sizeof(struct ForeachState) + 3 * numLists * sizeof(Tcl_Size)
+ 2 * numLists * (sizeof(Tcl_Obj **) + sizeof(Tcl_Obj *)));
memset(statePtr, 0,
sizeof(struct ForeachState) + 3 * numLists * sizeof(Tcl_Size)
+ 2 * numLists * (sizeof(Tcl_Obj **) + sizeof(Tcl_Obj *)));
statePtr->varvList = (Tcl_Obj ***) (statePtr + 1);
statePtr->argvList = statePtr->varvList + numLists;
statePtr->vCopyList = (Tcl_Obj **) (statePtr->argvList + numLists);
statePtr->aCopyList = statePtr->vCopyList + numLists;
statePtr->index = (Tcl_Size *) (statePtr->aCopyList + numLists);
statePtr->varcList = statePtr->index + numLists;
statePtr->argcList = statePtr->varcList + numLists;
statePtr->numLists = numLists;
statePtr->bodyPtr = objv[objc - 1];
statePtr->bodyIdx = objc - 1;
|
| ︙ | ︙ | |||
2883 2884 2885 2886 2887 2888 2889 |
switch (result) {
case TCL_CONTINUE:
result = TCL_OK;
break;
case TCL_OK:
if (statePtr->resultList != NULL) {
| | | > > > > | 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 |
switch (result) {
case TCL_CONTINUE:
result = TCL_OK;
break;
case TCL_OK:
if (statePtr->resultList != NULL) {
result = Tcl_ListObjAppendElement(
interp, statePtr->resultList, Tcl_GetObjResult(interp));
if (result != TCL_OK) {
/* e.g. memory alloc failure on big data tests */
goto done;
}
}
break;
case TCL_BREAK:
result = TCL_OK;
goto finish;
case TCL_ERROR:
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
|
| ︙ | ︙ |
Changes to generic/tclCmdIL.c.
| ︙ | ︙ | |||
46 47 48 49 50 51 52 | /* * These function pointer types are used with the "lsearch" and "lsort" * commands to facilitate the "-nocase" option. */ typedef int (*SortStrCmpFn_t) (const char *, const char *); | | | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
/*
* These function pointer types are used with the "lsearch" and "lsort"
* commands to facilitate the "-nocase" option.
*/
typedef int (*SortStrCmpFn_t) (const char *, const char *);
typedef int (*SortMemCmpFn_t) (const void *, const void *, Tcl_Size);
/*
* The "lsort" command needs to pass certain information down to the function
* that compares two list elements, and the comparison function needs to pass
* success or failure information back up to the top-level "lsort" command.
* The following structure is used to pass this information.
*/
typedef struct {
int isIncreasing; /* Nonzero means sort in increasing order. */
int sortMode; /* The sort mode. One of SORTMODE_* values
* defined below. */
Tcl_Obj *compareCmdPtr; /* The Tcl comparison command when sortMode is
* SORTMODE_COMMAND. Preinitialized to hold
* base of command. */
int *indexv; /* If the -index option was specified, this
* holds an encoding of the indexes contained
* in the list supplied as an argument to
* that option.
* NULL if no indexes supplied, and points to
* singleIndex field when only one
* supplied. */
Tcl_Size indexc; /* Number of indexes in indexv array. */
int singleIndex; /* Static space for common index case. */
int unique;
int numElements;
Tcl_Interp *interp; /* The interpreter in which the sort is being
* done. */
int resultCode; /* Completion code for the lsort command. If
* an error occurs during the sort this is
|
| ︙ | ︙ | |||
499 500 501 502 503 504 505 |
*/
listObjPtr = Tcl_NewListObj(0, NULL);
for (localPtr = procPtr->firstLocalPtr; localPtr != NULL;
localPtr = localPtr->nextPtr) {
if (TclIsVarArgument(localPtr)) {
Tcl_ListObjAppendElement(interp, listObjPtr,
| | | 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
*/
listObjPtr = Tcl_NewListObj(0, NULL);
for (localPtr = procPtr->firstLocalPtr; localPtr != NULL;
localPtr = localPtr->nextPtr) {
if (TclIsVarArgument(localPtr)) {
Tcl_ListObjAppendElement(interp, listObjPtr,
Tcl_NewStringObj(localPtr->name, -1));
}
}
Tcl_SetObjResult(interp, listObjPtr);
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
536 537 538 539 540 541 542 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Interp *iPtr = (Interp *) interp;
const char *name, *bytes;
Proc *procPtr;
| | | 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Interp *iPtr = (Interp *) interp;
const char *name, *bytes;
Proc *procPtr;
Tcl_Size numBytes;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "procname");
return TCL_ERROR;
}
name = TclGetString(objv[1]);
|
| ︙ | ︙ | |||
646 647 648 649 650 651 652 |
Tcl_HashSearch search;
Namespace *nsPtr;
Namespace *globalNsPtr = (Namespace *) Tcl_GetGlobalNamespace(interp);
Namespace *currNsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
Tcl_Obj *listPtr, *elemObjPtr;
int specificNsInPattern = 0;/* Init. to avoid compiler warning. */
Tcl_Command cmd;
| | | 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 |
Tcl_HashSearch search;
Namespace *nsPtr;
Namespace *globalNsPtr = (Namespace *) Tcl_GetGlobalNamespace(interp);
Namespace *currNsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
Tcl_Obj *listPtr, *elemObjPtr;
int specificNsInPattern = 0;/* Init. to avoid compiler warning. */
Tcl_Command cmd;
Tcl_Size i;
/*
* Get the pattern and find the "effective namespace" in which to list
* commands.
*/
if (objc == 1) {
|
| ︙ | ︙ | |||
711 712 713 714 715 716 717 |
if (entryPtr != NULL) {
if (specificNsInPattern) {
cmd = (Tcl_Command)Tcl_GetHashValue(entryPtr);
elemObjPtr = Tcl_NewObj();
Tcl_GetCommandFullName(interp, cmd, elemObjPtr);
} else {
cmdName = (const char *)Tcl_GetHashKey(&nsPtr->cmdTable, entryPtr);
| | | 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 |
if (entryPtr != NULL) {
if (specificNsInPattern) {
cmd = (Tcl_Command)Tcl_GetHashValue(entryPtr);
elemObjPtr = Tcl_NewObj();
Tcl_GetCommandFullName(interp, cmd, elemObjPtr);
} else {
cmdName = (const char *)Tcl_GetHashKey(&nsPtr->cmdTable, entryPtr);
elemObjPtr = Tcl_NewStringObj(cmdName, -1);
}
Tcl_ListObjAppendElement(interp, listPtr, elemObjPtr);
Tcl_SetObjResult(interp, listPtr);
return TCL_OK;
}
if ((nsPtr != globalNsPtr) && !specificNsInPattern) {
Tcl_HashTable *tablePtr = NULL; /* Quell warning. */
|
| ︙ | ︙ | |||
739 740 741 742 743 744 745 |
if (entryPtr == NULL) {
tablePtr = &globalNsPtr->cmdTable;
entryPtr = Tcl_FindHashEntry(tablePtr, simplePattern);
}
if (entryPtr != NULL) {
cmdName = (const char *)Tcl_GetHashKey(tablePtr, entryPtr);
Tcl_ListObjAppendElement(interp, listPtr,
| | | 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 |
if (entryPtr == NULL) {
tablePtr = &globalNsPtr->cmdTable;
entryPtr = Tcl_FindHashEntry(tablePtr, simplePattern);
}
if (entryPtr != NULL) {
cmdName = (const char *)Tcl_GetHashKey(tablePtr, entryPtr);
Tcl_ListObjAppendElement(interp, listPtr,
Tcl_NewStringObj(cmdName, -1));
Tcl_SetObjResult(interp, listPtr);
return TCL_OK;
}
}
} else if (nsPtr->commandPathLength == 0 || specificNsInPattern) {
/*
* The pattern is non-trivial, but either there is no explicit path or
|
| ︙ | ︙ | |||
761 762 763 764 765 766 767 |
if ((simplePattern == NULL)
|| Tcl_StringMatch(cmdName, simplePattern)) {
if (specificNsInPattern) {
cmd = (Tcl_Command)Tcl_GetHashValue(entryPtr);
elemObjPtr = Tcl_NewObj();
Tcl_GetCommandFullName(interp, cmd, elemObjPtr);
} else {
| | | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 |
if ((simplePattern == NULL)
|| Tcl_StringMatch(cmdName, simplePattern)) {
if (specificNsInPattern) {
cmd = (Tcl_Command)Tcl_GetHashValue(entryPtr);
elemObjPtr = Tcl_NewObj();
Tcl_GetCommandFullName(interp, cmd, elemObjPtr);
} else {
elemObjPtr = Tcl_NewStringObj(cmdName, -1);
}
Tcl_ListObjAppendElement(interp, listPtr, elemObjPtr);
}
entryPtr = Tcl_NextHashEntry(&search);
}
/*
|
| ︙ | ︙ | |||
784 785 786 787 788 789 790 |
entryPtr = Tcl_FirstHashEntry(&globalNsPtr->cmdTable, &search);
while (entryPtr != NULL) {
cmdName = (const char *)Tcl_GetHashKey(&globalNsPtr->cmdTable, entryPtr);
if ((simplePattern == NULL)
|| Tcl_StringMatch(cmdName, simplePattern)) {
if (Tcl_FindHashEntry(&nsPtr->cmdTable,cmdName) == NULL) {
Tcl_ListObjAppendElement(interp, listPtr,
| | | 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 |
entryPtr = Tcl_FirstHashEntry(&globalNsPtr->cmdTable, &search);
while (entryPtr != NULL) {
cmdName = (const char *)Tcl_GetHashKey(&globalNsPtr->cmdTable, entryPtr);
if ((simplePattern == NULL)
|| Tcl_StringMatch(cmdName, simplePattern)) {
if (Tcl_FindHashEntry(&nsPtr->cmdTable,cmdName) == NULL) {
Tcl_ListObjAppendElement(interp, listPtr,
Tcl_NewStringObj(cmdName, -1));
}
}
entryPtr = Tcl_NextHashEntry(&search);
}
}
} else {
/*
|
| ︙ | ︙ | |||
813 814 815 816 817 818 819 |
Tcl_InitObjHashTable(&addedCommandsTable);
entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search);
while (entryPtr != NULL) {
cmdName = (const char *)Tcl_GetHashKey(&nsPtr->cmdTable, entryPtr);
if ((simplePattern == NULL)
|| Tcl_StringMatch(cmdName, simplePattern)) {
| | | 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 |
Tcl_InitObjHashTable(&addedCommandsTable);
entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search);
while (entryPtr != NULL) {
cmdName = (const char *)Tcl_GetHashKey(&nsPtr->cmdTable, entryPtr);
if ((simplePattern == NULL)
|| Tcl_StringMatch(cmdName, simplePattern)) {
elemObjPtr = Tcl_NewStringObj(cmdName, -1);
Tcl_ListObjAppendElement(interp, listPtr, elemObjPtr);
(void) Tcl_CreateHashEntry(&addedCommandsTable,
elemObjPtr, &isNew);
}
entryPtr = Tcl_NextHashEntry(&search);
}
|
| ︙ | ︙ | |||
839 840 841 842 843 844 845 |
foundGlobal = 1;
}
entryPtr = Tcl_FirstHashEntry(&pathNsPtr->cmdTable, &search);
while (entryPtr != NULL) {
cmdName = (const char *)Tcl_GetHashKey(&pathNsPtr->cmdTable, entryPtr);
if ((simplePattern == NULL)
|| Tcl_StringMatch(cmdName, simplePattern)) {
| | | 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 |
foundGlobal = 1;
}
entryPtr = Tcl_FirstHashEntry(&pathNsPtr->cmdTable, &search);
while (entryPtr != NULL) {
cmdName = (const char *)Tcl_GetHashKey(&pathNsPtr->cmdTable, entryPtr);
if ((simplePattern == NULL)
|| Tcl_StringMatch(cmdName, simplePattern)) {
elemObjPtr = Tcl_NewStringObj(cmdName, -1);
(void) Tcl_CreateHashEntry(&addedCommandsTable,
elemObjPtr, &isNew);
if (isNew) {
Tcl_ListObjAppendElement(interp, listPtr, elemObjPtr);
} else {
TclDecrRefCount(elemObjPtr);
}
|
| ︙ | ︙ | |||
866 867 868 869 870 871 872 |
if (!foundGlobal) {
entryPtr = Tcl_FirstHashEntry(&globalNsPtr->cmdTable, &search);
while (entryPtr != NULL) {
cmdName = (const char *)Tcl_GetHashKey(&globalNsPtr->cmdTable, entryPtr);
if ((simplePattern == NULL)
|| Tcl_StringMatch(cmdName, simplePattern)) {
| | | 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
if (!foundGlobal) {
entryPtr = Tcl_FirstHashEntry(&globalNsPtr->cmdTable, &search);
while (entryPtr != NULL) {
cmdName = (const char *)Tcl_GetHashKey(&globalNsPtr->cmdTable, entryPtr);
if ((simplePattern == NULL)
|| Tcl_StringMatch(cmdName, simplePattern)) {
elemObjPtr = Tcl_NewStringObj(cmdName, -1);
if (Tcl_FindHashEntry(&addedCommandsTable,
(char *) elemObjPtr) == NULL) {
Tcl_ListObjAppendElement(interp, listPtr, elemObjPtr);
} else {
TclDecrRefCount(elemObjPtr);
}
}
|
| ︙ | ︙ | |||
1286 1287 1288 1289 1290 1291 1292 |
switch (framePtr->type) {
case TCL_LOCATION_EVAL:
/*
* Evaluation, dynamic script. Type, line, cmd, the latter through
* str.
*/
| | | | 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 |
switch (framePtr->type) {
case TCL_LOCATION_EVAL:
/*
* Evaluation, dynamic script. Type, line, cmd, the latter through
* str.
*/
ADD_PAIR("type", Tcl_NewStringObj(typeString[framePtr->type], -1));
if (framePtr->line) {
ADD_PAIR("line", Tcl_NewWideIntObj(framePtr->line[0]));
} else {
ADD_PAIR("line", Tcl_NewWideIntObj(1));
}
ADD_PAIR("cmd", TclGetSourceFromFrame(framePtr, 0, NULL));
break;
case TCL_LOCATION_PREBC:
/*
* Precompiled. Result contains the type as signal, nothing else.
*/
ADD_PAIR("type", Tcl_NewStringObj(typeString[framePtr->type], -1));
break;
case TCL_LOCATION_BC: {
/*
* Execution of bytecode. Talk to the BC engine to fill out the frame.
*/
|
| ︙ | ︙ | |||
1325 1326 1327 1328 1329 1330 1331 | TclGetSrcInfoForPc(fPtr); /* * Now filled: cmd.str.(cmd,len), line * Possibly modified: type, path! */ | | | 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 |
TclGetSrcInfoForPc(fPtr);
/*
* Now filled: cmd.str.(cmd,len), line
* Possibly modified: type, path!
*/
ADD_PAIR("type", Tcl_NewStringObj(typeString[fPtr->type], -1));
if (fPtr->line) {
ADD_PAIR("line", Tcl_NewWideIntObj(fPtr->line[0]));
}
if (fPtr->type == TCL_LOCATION_SOURCE) {
ADD_PAIR("file", fPtr->data.eval.path);
|
| ︙ | ︙ | |||
1353 1354 1355 1356 1357 1358 1359 |
}
case TCL_LOCATION_SOURCE:
/*
* Evaluation of a script file.
*/
| | | 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 |
}
case TCL_LOCATION_SOURCE:
/*
* Evaluation of a script file.
*/
ADD_PAIR("type", Tcl_NewStringObj(typeString[framePtr->type], -1));
ADD_PAIR("line", Tcl_NewWideIntObj(framePtr->line[0]));
ADD_PAIR("file", framePtr->data.eval.path);
/*
* Refcount framePtr->data.eval.path goes up when lv is converted into
* the result list object.
*/
|
| ︙ | ︙ | |||
1391 1392 1393 1394 1395 1396 1397 |
TclNewObj(procNameObj);
Tcl_GetCommandFullName(interp, (Tcl_Command) procPtr->cmdPtr,
procNameObj);
ADD_PAIR("proc", procNameObj);
} else if (procPtr->cmdPtr->clientData) {
ExtraFrameInfo *efiPtr = (ExtraFrameInfo *)procPtr->cmdPtr->clientData;
| | | | 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 |
TclNewObj(procNameObj);
Tcl_GetCommandFullName(interp, (Tcl_Command) procPtr->cmdPtr,
procNameObj);
ADD_PAIR("proc", procNameObj);
} else if (procPtr->cmdPtr->clientData) {
ExtraFrameInfo *efiPtr = (ExtraFrameInfo *)procPtr->cmdPtr->clientData;
Tcl_Size i;
/*
* This is a non-standard command. Luckily, it's told us how to
* render extra information about its frame.
*/
for (i=0 ; i<efiPtr->length ; i++) {
lv[lc++] = Tcl_NewStringObj(efiPtr->fields[i].name, -1);
if (efiPtr->fields[i].proc) {
lv[lc++] =
efiPtr->fields[i].proc(efiPtr->fields[i].clientData);
} else {
lv[lc++] = (Tcl_Obj *)efiPtr->fields[i].clientData;
}
}
|
| ︙ | ︙ | |||
1487 1488 1489 1490 1491 1492 1493 |
" ::foreach cmd [::info commands tcl::mathfunc::$pattern] {\n"
" ::set cmd [::namespace tail $cmd]\n"
" ::if {$cmd ni $cmds} {\n"
" ::lappend cmds $cmd\n"
" }\n"
" }\n"
" ::return $cmds\n"
| | | 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 |
" ::foreach cmd [::info commands tcl::mathfunc::$pattern] {\n"
" ::set cmd [::namespace tail $cmd]\n"
" ::if {$cmd ni $cmds} {\n"
" ::lappend cmds $cmd\n"
" }\n"
" }\n"
" ::return $cmds\n"
" } [::namespace current]] ", -1);
if (objc == 2) {
Tcl_Obj *arg = Tcl_NewListObj(1, &(objv[1]));
Tcl_AppendObjToObj(script, arg);
Tcl_DecrRefCount(arg);
}
|
| ︙ | ︙ | |||
1540 1541 1542 1543 1544 1545 1546 |
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
name = Tcl_GetHostName();
if (name) {
| | | | 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 |
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
name = Tcl_GetHostName();
if (name) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1));
return TCL_OK;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unable to determine name of host", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "HOSTNAME", "UNKNOWN", NULL);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
1660 1661 1662 1663 1664 1665 1666 |
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
libDirName = Tcl_GetVar2(interp, "tcl_library", NULL, TCL_GLOBAL_ONLY);
if (libDirName != NULL) {
| | | | 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 |
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
libDirName = Tcl_GetVar2(interp, "tcl_library", NULL, TCL_GLOBAL_ONLY);
if (libDirName != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(libDirName, -1));
return TCL_OK;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"no library has been specified for Tcl", -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARIABLE", "tcl_library",NULL);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
1792 1793 1794 1795 1796 1797 1798 |
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
patchlevel = Tcl_GetVar2(interp, "tcl_patchLevel", NULL,
(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
if (patchlevel != NULL) {
| | | 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 |
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
patchlevel = Tcl_GetVar2(interp, "tcl_patchLevel", NULL,
(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
if (patchlevel != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(patchlevel, -1));
return TCL_OK;
}
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
1905 1906 1907 1908 1909 1910 1911 |
} else {
simpleProcOK:
if (specificNsInPattern) {
elemObjPtr = Tcl_NewObj();
Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr,
elemObjPtr);
} else {
| | | 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 |
} else {
simpleProcOK:
if (specificNsInPattern) {
elemObjPtr = Tcl_NewObj();
Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr,
elemObjPtr);
} else {
elemObjPtr = Tcl_NewStringObj(simplePattern, -1);
}
Tcl_ListObjAppendElement(interp, listPtr, elemObjPtr);
}
}
} else
#endif /* !INFO_PROCS_SEARCH_GLOBAL_NS */
{
|
| ︙ | ︙ | |||
1933 1934 1935 1936 1937 1938 1939 |
} else {
procOK:
if (specificNsInPattern) {
elemObjPtr = Tcl_NewObj();
Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr,
elemObjPtr);
} else {
| | | 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 |
} else {
procOK:
if (specificNsInPattern) {
elemObjPtr = Tcl_NewObj();
Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr,
elemObjPtr);
} else {
elemObjPtr = Tcl_NewStringObj(cmdName, -1);
}
Tcl_ListObjAppendElement(interp, listPtr, elemObjPtr);
}
}
entryPtr = Tcl_NextHashEntry(&search);
}
|
| ︙ | ︙ | |||
1972 1973 1974 1975 1976 1977 1978 |
cmdPtr = (Command *)Tcl_GetHashValue(entryPtr);
realCmdPtr = (Command *) TclGetOriginalCommand(
(Tcl_Command) cmdPtr);
if (TclIsProc(cmdPtr) || ((realCmdPtr != NULL)
&& TclIsProc(realCmdPtr))) {
Tcl_ListObjAppendElement(interp, listPtr,
| | | 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 |
cmdPtr = (Command *)Tcl_GetHashValue(entryPtr);
realCmdPtr = (Command *) TclGetOriginalCommand(
(Tcl_Command) cmdPtr);
if (TclIsProc(cmdPtr) || ((realCmdPtr != NULL)
&& TclIsProc(realCmdPtr))) {
Tcl_ListObjAppendElement(interp, listPtr,
Tcl_NewStringObj(cmdName, -1));
}
}
}
entryPtr = Tcl_NextHashEntry(&search);
}
}
#endif
|
| ︙ | ︙ | |||
2070 2071 2072 2073 2074 2075 2076 |
{
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
#ifdef TCL_SHLIB_EXT
| | | 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 |
{
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
#ifdef TCL_SHLIB_EXT
Tcl_SetObjResult(interp, Tcl_NewStringObj(TCL_SHLIB_EXT, -1));
#endif
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
2167 2168 2169 2170 2171 2172 2173 |
*/
if (Tcl_IsSafe(interp)
&& (((Command *) command)->objProc == TclAliasObjCmd)) {
Tcl_AppendResult(interp, "native", NULL);
} else {
Tcl_SetObjResult(interp,
| | | 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 |
*/
if (Tcl_IsSafe(interp)
&& (((Command *) command)->objProc == TclAliasObjCmd)) {
Tcl_AppendResult(interp, "native", NULL);
} else {
Tcl_SetObjResult(interp,
Tcl_NewStringObj(TclGetCommandTypeName(command), -1));
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
2196 2197 2198 2199 2200 2201 2202 |
int
Tcl_JoinObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
| | | 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 |
int
Tcl_JoinObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
Tcl_Size length, listLen;
int isAbstractList = 0;
Tcl_Obj *resObjPtr = NULL, *joinObjPtr, **elemPtrs;
if ((objc < 2) || (objc > 3)) {
Tcl_WrongNumArgs(interp, 1, objv, "list ?joinString?");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2249 2250 2251 2252 2253 2254 2255 |
joinObjPtr = (objc == 2) ? Tcl_NewStringObj(" ", 1) : objv[2];
Tcl_IncrRefCount(joinObjPtr);
(void) Tcl_GetStringFromObj(joinObjPtr, &length);
if (length == 0) {
resObjPtr = TclStringCat(interp, listLen, elemPtrs, 0);
} else {
| | | 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 |
joinObjPtr = (objc == 2) ? Tcl_NewStringObj(" ", 1) : objv[2];
Tcl_IncrRefCount(joinObjPtr);
(void) Tcl_GetStringFromObj(joinObjPtr, &length);
if (length == 0) {
resObjPtr = TclStringCat(interp, listLen, elemPtrs, 0);
} else {
Tcl_Size i;
resObjPtr = Tcl_NewObj();
for (i = 0; i < listLen; i++) {
if (i > 0) {
/*
* NOTE: This code is relying on Tcl_AppendObjToObj() **NOT**
|
| ︙ | ︙ | |||
2301 2302 2303 2304 2305 2306 2307 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *listCopyPtr;
Tcl_Obj **listObjv; /* The contents of the list. */
| | > > > | 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *listCopyPtr;
Tcl_Obj **listObjv; /* The contents of the list. */
Tcl_Size listObjc; /* The length of the list. */
Tcl_Size origListObjc; /* Original length */
int code = TCL_OK;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "list ?varName ...?");
return TCL_ERROR;
}
listCopyPtr = TclListObjCopy(interp, objv[1]);
if (listCopyPtr == NULL) {
return TCL_ERROR;
}
Tcl_IncrRefCount(listCopyPtr); /* Important! fs */
TclListObjGetElementsM(NULL, listCopyPtr, &listObjc, &listObjv);
origListObjc = listObjc;
objc -= 2;
objv += 2;
while (code == TCL_OK && objc > 0 && listObjc > 0) {
if (Tcl_ObjSetVar2(interp, *objv++, NULL, *listObjv++,
TCL_LEAVE_ERR_MSG) == NULL) {
code = TCL_ERROR;
|
| ︙ | ︙ | |||
2342 2343 2344 2345 2346 2347 2348 |
code = TCL_ERROR;
}
}
Tcl_DecrRefCount(emptyObj);
}
if (code == TCL_OK && listObjc > 0) {
| > > > > > | > | 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 |
code = TCL_ERROR;
}
}
Tcl_DecrRefCount(emptyObj);
}
if (code == TCL_OK && listObjc > 0) {
Tcl_Obj *resultObjPtr = TclListObjRange(
interp, listCopyPtr, origListObjc - listObjc, origListObjc - 1);
if (resultObjPtr == NULL) {
code = TCL_ERROR;
} else {
Tcl_SetObjResult(interp, resultObjPtr);
}
}
Tcl_DecrRefCount(listCopyPtr);
return code;
}
/*
|
| ︙ | ︙ | |||
2432 2433 2434 2435 2436 2437 2438 |
Tcl_LinsertObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *listPtr;
| | | 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 |
Tcl_LinsertObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *listPtr;
Tcl_Size len, index;
int result;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "list index ?element ...?");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2455 2456 2457 2458 2459 2460 2461 |
* appended to the list.
*/
result = TclGetIntForIndexM(interp, objv[2], /*end*/ len, &index);
if (result != TCL_OK) {
return result;
}
| | | 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 |
* appended to the list.
*/
result = TclGetIntForIndexM(interp, objv[2], /*end*/ len, &index);
if (result != TCL_OK) {
return result;
}
if (index > len) {
index = len;
}
/*
* If the list object is unshared we can modify it directly. Otherwise we
* create a copy to modify: this is "copy on write".
*/
|
| ︙ | ︙ | |||
2551 2552 2553 2554 2555 2556 2557 |
Tcl_LlengthObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[])
/* Argument objects. */
{
| | | 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 |
Tcl_LlengthObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[])
/* Argument objects. */
{
Tcl_Size listLen;
int result;
Tcl_Obj *objPtr;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "list");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2600 2601 2602 2603 2604 2605 2606 |
Tcl_LpopObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[])
/* Argument objects. */
{
| | | 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 |
Tcl_LpopObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[])
/* Argument objects. */
{
Tcl_Size listLen;
int result;
Tcl_Obj *elemPtr, *stored;
Tcl_Obj *listPtr, **elemPtrs;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "listvar ?index?");
return TCL_ERROR;
|
| ︙ | ︙ | |||
2629 2630 2631 2632 2633 2634 2635 |
* TclLindexFlat adds a ref count which is handled.
*/
if (objc == 2) {
if (!listLen) {
/* empty list, throw the same error as with index "end" */
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 |
* TclLindexFlat adds a ref count which is handled.
*/
if (objc == 2) {
if (!listLen) {
/* empty list, throw the same error as with index "end" */
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"index \"end\" out of range", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX"
"OUTOFRANGE", NULL);
return TCL_ERROR;
}
elemPtr = elemPtrs[listLen - 1];
Tcl_IncrRefCount(elemPtr);
} else {
|
| ︙ | ︙ | |||
2703 2704 2705 2706 2707 2708 2709 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[])
/* Argument objects. */
{
int result;
| | | 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[])
/* Argument objects. */
{
int result;
Tcl_Size listLen, first, last;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv, "list first last");
return TCL_ERROR;
}
result = TclListObjLengthM(interp, objv[1], &listLen);
if (result != TCL_OK) {
|
| ︙ | ︙ | |||
2735 2736 2737 2738 2739 2740 2741 |
int status = Tcl_ObjTypeSlice(interp, objv[1], first, last, &resultObj);
if (status == TCL_OK) {
Tcl_SetObjResult(interp, resultObj);
} else {
return TCL_ERROR;
}
} else {
| > > > > | | 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 |
int status = Tcl_ObjTypeSlice(interp, objv[1], first, last, &resultObj);
if (status == TCL_OK) {
Tcl_SetObjResult(interp, resultObj);
} else {
return TCL_ERROR;
}
} else {
Tcl_Obj *resultObj = TclListObjRange(interp, objv[1], first, last);
if (resultObj == NULL) {
return TCL_ERROR;
}
Tcl_SetObjResult(interp, resultObj);
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
2762 2763 2764 2765 2766 2767 2768 |
*/
static int
LremoveIndexCompare(
const void *el1Ptr,
const void *el2Ptr)
{
| | | | | | 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 |
*/
static int
LremoveIndexCompare(
const void *el1Ptr,
const void *el2Ptr)
{
Tcl_Size idx1 = *((const Tcl_Size *) el1Ptr);
Tcl_Size idx2 = *((const Tcl_Size *) el2Ptr);
/*
* This will put the larger element first.
*/
return (idx1 < idx2) ? 1 : (idx1 > idx2) ? -1 : 0;
}
int
Tcl_LremoveObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size i, idxc, prevIdx, first, num;
Tcl_Size *idxv, listLen;
Tcl_Obj *listObj;
/*
* Parse the arguments.
*/
if (objc < 2) {
|
| ︙ | ︙ | |||
2802 2803 2804 2805 2806 2807 2808 |
}
idxc = objc - 2;
if (idxc == 0) {
Tcl_SetObjResult(interp, listObj);
return TCL_OK;
}
| | | | | | 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 |
}
idxc = objc - 2;
if (idxc == 0) {
Tcl_SetObjResult(interp, listObj);
return TCL_OK;
}
idxv = (Tcl_Size *)Tcl_Alloc((objc - 2) * sizeof(*idxv));
for (i = 2; i < objc; i++) {
if (TclGetIntForIndexM(interp, objv[i], /*endValue*/ listLen - 1,
&idxv[i - 2]) != TCL_OK) {
Tcl_Free(idxv);
return TCL_ERROR;
}
}
/*
* Sort the indices, large to small so that when we remove an index we
* don't change the indices still to be processed.
*/
if (idxc > 1) {
qsort(idxv, idxc, sizeof(*idxv), LremoveIndexCompare);
}
/*
* Make our working copy, then do the actual removes piecemeal.
*/
if (Tcl_IsShared(listObj)) {
listObj = TclListObjCopy(NULL, listObj);
}
num = 0;
first = listLen;
for (i = 0, prevIdx = -1 ; i < idxc ; i++) {
Tcl_Size idx = idxv[i];
/*
* Repeated index and sanity check.
*/
if (idx == prevIdx) {
continue;
}
prevIdx = idx;
if (idx < 0 || idx >= listLen) {
continue;
}
/*
* Coalesce adjacent removes to reduce the number of copies.
*/
|
| ︙ | ︙ | |||
2899 2900 2901 2902 2903 2904 2905 |
Tcl_LrepeatObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[])
/* The argument objects. */
{
| | | | | | | 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 |
Tcl_LrepeatObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[])
/* The argument objects. */
{
Tcl_Size elementCount, i, totalElems;
Tcl_Obj *listPtr, **dataArray = NULL;
/*
* Check arguments for legality:
* lrepeat count ?value ...?
*/
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "count ?value ...?");
return TCL_ERROR;
}
if (TCL_OK != TclGetSizeIntFromObj(interp, objv[1], &elementCount)) {
return TCL_ERROR;
}
if (elementCount < 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad count \"%" TCL_SIZE_MODIFIER "d\": must be integer >= 0", elementCount));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LREPEAT", "NEGARG",
NULL);
return TCL_ERROR;
}
/*
* Skip forward to the interesting arguments now we've finished parsing.
*/
objc -= 2;
objv += 2;
/* Final sanity check. Do not exceed limits on max list length. */
if (elementCount && objc > LIST_MAX/elementCount) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"max length of a Tcl list (%" TCL_SIZE_MODIFIER "d elements) exceeded", LIST_MAX));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
return TCL_ERROR;
}
totalElems = objc * elementCount;
/*
* Get an empty list object that is allocated large enough to hold each
|
| ︙ | ︙ | |||
2973 2974 2975 2976 2977 2978 2979 |
Tcl_Obj *tmpPtr = objv[0];
tmpPtr->refCount += elementCount;
for (i=0 ; i<elementCount ; i++) {
dataArray[i] = tmpPtr;
}
} else {
| | | 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 |
Tcl_Obj *tmpPtr = objv[0];
tmpPtr->refCount += elementCount;
for (i=0 ; i<elementCount ; i++) {
dataArray[i] = tmpPtr;
}
} else {
Tcl_Size j, k = 0;
for (i=0 ; i<elementCount ; i++) {
for (j=0 ; j<objc ; j++) {
Tcl_IncrRefCount(objv[j]);
dataArray[k++] = objv[j];
}
}
|
| ︙ | ︙ | |||
3013 3014 3015 3016 3017 3018 3019 |
Tcl_LreplaceObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *listPtr;
| | | 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 |
Tcl_LreplaceObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *listPtr;
Tcl_Size numToDelete, listLen, first, last;
int result;
if (objc < 4) {
Tcl_WrongNumArgs(interp, 1, objv,
"list first last ?element ...?");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
3043 3044 3045 3046 3047 3048 3049 |
}
result = TclGetIntForIndexM(interp, objv[3], /*end*/ listLen-1, &last);
if (result != TCL_OK) {
return result;
}
| | | | | 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 |
}
result = TclGetIntForIndexM(interp, objv[3], /*end*/ listLen-1, &last);
if (result != TCL_OK) {
return result;
}
if (first < 0) {
first = 0;
} else if (first > listLen) {
first = listLen;
}
if (last >= listLen) {
last = listLen - 1;
}
if (first <= last) {
numToDelete = last - first + 1;
} else {
numToDelete = 0;
}
/*
* If the list object is unshared we can modify it directly, otherwise we
|
| ︙ | ︙ | |||
3114 3115 3116 3117 3118 3119 3120 |
Tcl_LreverseObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
Tcl_Obj **elemv;
| | | 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 |
Tcl_LreverseObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
Tcl_Obj **elemv;
Tcl_Size elemc, i, j;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "list");
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
3217 3218 3219 3220 3221 3222 3223 |
Tcl_LsearchObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
const char *bytes, *patternBytes;
| | > | | 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 |
Tcl_LsearchObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
const char *bytes, *patternBytes;
int match, result=TCL_OK, bisect;
Tcl_Size i, length = 0, listc, elemLen, start, index;
Tcl_Size groupSize, groupOffset, lower, upper;
int allocatedIndexVector = 0;
int isIncreasing;
Tcl_WideInt patWide, objWide, wide;
int allMatches, inlineReturn, negatedMatch, returnSubindices, noCase;
double patDouble, objDouble;
SortInfo sortInfo;
Tcl_Obj *patObj, **listv, *listPtr, *startPtr, *itemPtr;
|
| ︙ | ︙ | |||
3277 3278 3279 3280 3281 3282 3283 |
sortInfo.indexc = 0;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "?-option value ...? list pattern");
return TCL_ERROR;
}
| | | 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 |
sortInfo.indexc = 0;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "?-option value ...? list pattern");
return TCL_ERROR;
}
for (i = 1; i < objc-2; i++) {
enum lsearchoptions idx;
if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", 0, &idx)
!= TCL_OK) {
result = TCL_ERROR;
goto done;
}
switch (idx) {
|
| ︙ | ︙ | |||
3347 3348 3349 3350 3351 3352 3353 |
* because it will either be replaced or there will be an error.
*/
if (startPtr != NULL) {
Tcl_DecrRefCount(startPtr);
startPtr = NULL;
}
| | | | | | | | | 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 |
* because it will either be replaced or there will be an error.
*/
if (startPtr != NULL) {
Tcl_DecrRefCount(startPtr);
startPtr = NULL;
}
if (i > objc-4) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing starting index", -1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
result = TCL_ERROR;
goto done;
}
i++;
if (objv[i] == objv[objc - 2]) {
/*
* Take copy to prevent shimmering problems. Note that it does
* not matter if the index obj is also a component of the list
* being searched. We only need to copy where the list and the
* index are one-and-the-same.
*/
startPtr = Tcl_DuplicateObj(objv[i]);
} else {
startPtr = objv[i];
}
Tcl_IncrRefCount(startPtr);
break;
case LSEARCH_STRIDE: /* -stride */
if (i > objc-4) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-stride\" option must be "
"followed by stride length", -1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
result = TCL_ERROR;
goto done;
}
if (Tcl_GetWideIntFromObj(interp, objv[i+1], &wide) != TCL_OK) {
result = TCL_ERROR;
goto done;
}
if (wide < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"stride length must be at least 1", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSEARCH",
"BADSTRIDE", NULL);
result = TCL_ERROR;
goto done;
}
groupSize = wide;
i++;
break;
case LSEARCH_INDEX: { /* -index */
Tcl_Obj **indices;
Tcl_Size j;
if (allocatedIndexVector) {
TclStackFree(interp, sortInfo.indexv);
allocatedIndexVector = 0;
}
if (i > objc-4) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-index\" option must be followed by list index",
-1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
result = TCL_ERROR;
goto done;
}
|
| ︙ | ︙ | |||
3474 3475 3476 3477 3478 3479 3480 |
/*
* Subindices only make sense if asked for with -index option set.
*/
if (returnSubindices && sortInfo.indexc==0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 |
/*
* Subindices only make sense if asked for with -index option set.
*/
if (returnSubindices && sortInfo.indexc==0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"-subindices cannot be used without -index option", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSEARCH",
"BAD_OPTION_MIX", NULL);
result = TCL_ERROR;
goto done;
}
if (bisect && (allMatches || negatedMatch)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"-bisect is not compatible with -all or -not", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSEARCH",
"BAD_OPTION_MIX", NULL);
result = TCL_ERROR;
goto done;
}
if (mode == REGEXP) {
|
| ︙ | ︙ | |||
3550 3551 3552 3553 3554 3555 3556 |
if (sortInfo.indexc > 0) {
/*
* Use the first value in the list supplied to -index as the
* offset of the element within each group by which to sort.
*/
groupOffset = TclIndexDecode(sortInfo.indexv[0], groupSize - 1);
| | | | 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 |
if (sortInfo.indexc > 0) {
/*
* Use the first value in the list supplied to -index as the
* offset of the element within each group by which to sort.
*/
groupOffset = TclIndexDecode(sortInfo.indexv[0], groupSize - 1);
if (groupOffset < 0 || groupOffset >= groupSize) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"when used with \"-stride\", the leading \"-index\""
" value must be within the group", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSEARCH",
"BADINDEX", NULL);
result = TCL_ERROR;
goto done;
}
if (sortInfo.indexc == 1) {
sortInfo.indexc = 0;
|
| ︙ | ︙ | |||
3590 3591 3592 3593 3594 3595 3596 | } /* * If the search started past the end of the list, we just return a * "did not match anything at all" result straight away. [Bug 1374778] */ | | | 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 |
}
/*
* If the search started past the end of the list, we just return a
* "did not match anything at all" result straight away. [Bug 1374778]
*/
if (start >= listc) {
if (allMatches || inlineReturn) {
Tcl_ResetResult(interp);
} else {
TclNewIntObj(itemPtr, -1);
Tcl_SetObjResult(interp, itemPtr);
}
goto done;
|
| ︙ | ︙ | |||
3881 3882 3883 3884 3885 3886 3887 |
Tcl_ListObjReplace(interp, listPtr, LIST_MAX, 0,
groupSize, &listv[i]);
} else {
itemPtr = listv[i];
Tcl_ListObjAppendElement(interp, listPtr, itemPtr);
}
} else if (returnSubindices) {
| | | 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 |
Tcl_ListObjReplace(interp, listPtr, LIST_MAX, 0,
groupSize, &listv[i]);
} else {
itemPtr = listv[i];
Tcl_ListObjAppendElement(interp, listPtr, itemPtr);
}
} else if (returnSubindices) {
Tcl_Size j;
TclNewIndexObj(itemPtr, i+groupOffset);
for (j=0 ; j<sortInfo.indexc ; j++) {
Tcl_Obj *elObj;
size_t elValue = TclIndexDecode(sortInfo.indexv[j], listc);
TclNewIndexObj(elObj, elValue);
Tcl_ListObjAppendElement(interp, itemPtr, elObj);
|
| ︙ | ︙ | |||
3905 3906 3907 3908 3909 3910 3911 |
* Return everything or a single value.
*/
if (allMatches) {
Tcl_SetObjResult(interp, listPtr);
} else if (!inlineReturn) {
if (returnSubindices) {
| | | 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 |
* Return everything or a single value.
*/
if (allMatches) {
Tcl_SetObjResult(interp, listPtr);
} else if (!inlineReturn) {
if (returnSubindices) {
Tcl_Size j;
TclNewIndexObj(itemPtr, index+groupOffset);
for (j=0 ; j<sortInfo.indexc ; j++) {
Tcl_Obj *elObj;
size_t elValue = TclIndexDecode(sortInfo.indexv[j], listc);
TclNewIndexObj(elObj, elValue);
Tcl_ListObjAppendElement(interp, itemPtr, elObj);
|
| ︙ | ︙ | |||
4463 4464 4465 4466 4467 4468 4469 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
int indices, nocase = 0, indexc;
int sortMode = SORTMODE_ASCII;
int group, allocatedIndexVector = 0;
| | | | 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
int indices, nocase = 0, indexc;
int sortMode = SORTMODE_ASCII;
int group, allocatedIndexVector = 0;
Tcl_Size j, idx, groupSize, groupOffset, length;
Tcl_WideInt wide;
Tcl_Obj *resultPtr, *cmdPtr, **listObjPtrs, *listObj, *indexPtr;
Tcl_Size i, elmArrSize;
SortElement *elementArray = NULL, *elementPtr;
SortInfo sortInfo; /* Information about this sort that needs to
* be passed to the comparison function. */
# define MAXCALLOC 1024000
# define NUM_LISTS 30
SortElement *subList[NUM_LISTS+1];
/* This array holds pointers to temporary
|
| ︙ | ︙ | |||
4510 4511 4512 4513 4514 4515 4516 |
sortInfo.resultCode = TCL_OK;
cmdPtr = NULL;
indices = 0;
group = 0;
groupSize = 1;
groupOffset = 0;
indexPtr = NULL;
| | | | | | | 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 |
sortInfo.resultCode = TCL_OK;
cmdPtr = NULL;
indices = 0;
group = 0;
groupSize = 1;
groupOffset = 0;
indexPtr = NULL;
for (i = 1; i < objc-1; i++) {
if (Tcl_GetIndexFromObj(interp, objv[i], switches, "option", 0,
&index) != TCL_OK) {
sortInfo.resultCode = TCL_ERROR;
goto done;
}
switch (index) {
case LSORT_ASCII:
sortInfo.sortMode = SORTMODE_ASCII;
break;
case LSORT_COMMAND:
if (i == objc-2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-command\" option must be followed "
"by comparison command", -1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
sortInfo.sortMode = SORTMODE_COMMAND;
cmdPtr = objv[i+1];
i++;
break;
case LSORT_DECREASING:
sortInfo.isIncreasing = 0;
break;
case LSORT_DICTIONARY:
sortInfo.sortMode = SORTMODE_DICTIONARY;
break;
case LSORT_INCREASING:
sortInfo.isIncreasing = 1;
break;
case LSORT_INDEX: {
Tcl_Size sortindex;
Tcl_Obj **indexv;
if (i == objc-2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-index\" option must be followed by list index",
-1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
|
| ︙ | ︙ | |||
4608 4609 4610 4611 4612 4613 4614 | case LSORT_UNIQUE: sortInfo.unique = 1; break; case LSORT_INDICES: indices = 1; break; case LSORT_STRIDE: | | | | | 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 |
case LSORT_UNIQUE:
sortInfo.unique = 1;
break;
case LSORT_INDICES:
indices = 1;
break;
case LSORT_STRIDE:
if (i == objc-2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-stride\" option must be "
"followed by stride length", -1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
if (Tcl_GetWideIntFromObj(interp, objv[i+1], &wide) != TCL_OK) {
sortInfo.resultCode = TCL_ERROR;
goto done;
}
if (wide < 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"stride length must be at least 2", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSORT",
"BADSTRIDE", NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
groupSize = wide;
group = 1;
|
| ︙ | ︙ | |||
4741 4742 4743 4744 4745 4746 4747 |
if (sortInfo.indexc > 0) {
/*
* Use the first value in the list supplied to -index as the
* offset of the element within each group by which to sort.
*/
groupOffset = TclIndexDecode(sortInfo.indexv[0], groupSize - 1);
| | | | 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 |
if (sortInfo.indexc > 0) {
/*
* Use the first value in the list supplied to -index as the
* offset of the element within each group by which to sort.
*/
groupOffset = TclIndexDecode(sortInfo.indexv[0], groupSize - 1);
if (groupOffset < 0 || groupOffset >= groupSize) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"when used with \"-stride\", the leading \"-index\""
" value must be within the group", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSORT",
"BADINDEX", NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
if (sortInfo.indexc == 1) {
sortInfo.indexc = 0;
|
| ︙ | ︙ | |||
4866 4867 4868 4869 4870 4871 4872 |
if (indices || group) {
elementArray[i].payload.index = idx;
} else {
elementArray[i].payload.objPtr = listObjPtrs[idx];
}
/*
| | | 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 |
if (indices || group) {
elementArray[i].payload.index = idx;
} else {
elementArray[i].payload.objPtr = listObjPtrs[idx];
}
/*
* Merge this element in the preexisting sublists (and merge together
* sublists when we have two of the same size).
*/
elementArray[i].nextPtr = NULL;
elementPtr = &elementArray[i];
for (j=0 ; subList[j] ; j++) {
elementPtr = MergeLists(subList[j], elementPtr, &sortInfo);
|
| ︙ | ︙ | |||
4985 4986 4987 4988 4989 4990 4991 |
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
Tcl_Obj *listPtr; /* Pointer to the list being altered. */
Tcl_Obj *finalValuePtr; /* Value finally assigned to the variable. */
int createdNewObj;
int result;
| | | | | | 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 |
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
Tcl_Obj *listPtr; /* Pointer to the list being altered. */
Tcl_Obj *finalValuePtr; /* Value finally assigned to the variable. */
int createdNewObj;
int result;
Tcl_Size first;
Tcl_Size last;
Tcl_Size listLen;
Tcl_Size numToDelete;
if (objc < 4) {
Tcl_WrongNumArgs(interp, 1, objv,
"listVar first last ?element ...?");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
5021 5022 5023 5024 5025 5026 5027 |
}
result = TclGetIntForIndexM(interp, objv[3], /*end*/ listLen-1, &last);
if (result != TCL_OK) {
return result;
}
| | | | | 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 |
}
result = TclGetIntForIndexM(interp, objv[3], /*end*/ listLen-1, &last);
if (result != TCL_OK) {
return result;
}
if (first < 0) {
first = 0;
} else if (first > listLen) {
first = listLen;
}
/* The +1 in comparisons are necessitated by indices being unsigned */
if (last >= listLen) {
last = listLen - 1;
}
if (first <= last) {
numToDelete = last - first + 1;
} else {
numToDelete = 0;
}
if (Tcl_IsShared(listPtr)) {
listPtr = TclListObjCopy(NULL, listPtr);
|
| ︙ | ︙ | |||
5184 5185 5186 5187 5188 5189 5190 | * * SortCompare -- * * This procedure is invoked by MergeLists to determine the proper * ordering between two elements. * * Results: | | | 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 | * * SortCompare -- * * This procedure is invoked by MergeLists to determine the proper * ordering between two elements. * * Results: * A negative results means the first element comes before the * second, and a positive results means that the second element should * come first. A result of zero means the two elements are equal and it * doesn't matter which comes first. * * Side effects: * None, unless a user-defined comparison command does something weird. * |
| ︙ | ︙ | |||
5227 5228 5229 5230 5231 5232 5233 |
double a, b;
a = elemPtr1->collationKey.doubleValue;
b = elemPtr2->collationKey.doubleValue;
order = ((a >= b) - (a <= b));
} else {
Tcl_Obj **objv, *paramObjv[2];
| | | 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 |
double a, b;
a = elemPtr1->collationKey.doubleValue;
b = elemPtr2->collationKey.doubleValue;
order = ((a >= b) - (a <= b));
} else {
Tcl_Obj **objv, *paramObjv[2];
Tcl_Size objc;
Tcl_Obj *objPtr1, *objPtr2;
if (infoPtr->resultCode != TCL_OK) {
/*
* Once an error has occurred, skip any future comparisons so as
* to preserve the error message in sortInterp->result.
*/
|
| ︙ | ︙ | |||
5271 5272 5273 5274 5275 5276 5277 |
/*
* Parse the result of the command.
*/
if (TclGetIntFromObj(infoPtr->interp,
Tcl_GetObjResult(infoPtr->interp), &order) != TCL_OK) {
Tcl_SetObjResult(infoPtr->interp, Tcl_NewStringObj(
| | | 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 |
/*
* Parse the result of the command.
*/
if (TclGetIntFromObj(infoPtr->interp,
Tcl_GetObjResult(infoPtr->interp), &order) != TCL_OK) {
Tcl_SetObjResult(infoPtr->interp, Tcl_NewStringObj(
"-compare command returned non-integer result", -1));
Tcl_SetErrorCode(infoPtr->interp, "TCL", "OPERATION", "LSORT",
"COMPARISONFAILED", NULL);
infoPtr->resultCode = TCL_ERROR;
return 0;
}
}
if (!infoPtr->isIncreasing) {
|
| ︙ | ︙ | |||
5386 5387 5388 5389 5390 5391 5392 |
if ((*left != '\0') && (*right != '\0')) {
left += TclUtfToUCS4(left, &uniLeft);
right += TclUtfToUCS4(right, &uniRight);
/*
* Convert both chars to lower for the comparison, because
| | | 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 |
if ((*left != '\0') && (*right != '\0')) {
left += TclUtfToUCS4(left, &uniLeft);
right += TclUtfToUCS4(right, &uniRight);
/*
* Convert both chars to lower for the comparison, because
* dictionary sorts are case-insensitive. Covert to lower, not
* upper, so chars between Z and a will sort before A (where most
* other interesting punctuations occur).
*/
uniLeftLower = Tcl_UniCharToLower(uniLeft);
uniRightLower = Tcl_UniCharToLower(uniRight);
} else {
|
| ︙ | ︙ | |||
5445 5446 5447 5448 5449 5450 5451 |
static Tcl_Obj *
SelectObjFromSublist(
Tcl_Obj *objPtr, /* Obj to select sublist from. */
SortInfo *infoPtr) /* Information passed from the top-level
* "lsearch" or "lsort" command. */
{
| | | | | 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 |
static Tcl_Obj *
SelectObjFromSublist(
Tcl_Obj *objPtr, /* Obj to select sublist from. */
SortInfo *infoPtr) /* Information passed from the top-level
* "lsearch" or "lsort" command. */
{
Tcl_Size i;
/*
* Quick check for case when no "-index" option is there.
*/
if (infoPtr->indexc == 0) {
return objPtr;
}
/*
* Iterate over the indices, traversing through the nested sublists as we
* go.
*/
for (i=0 ; i<infoPtr->indexc ; i++) {
Tcl_Size listLen;
int index;
Tcl_Obj *currentObj;
if (TclListObjLengthM(infoPtr->interp, objPtr, &listLen) != TCL_OK) {
infoPtr->resultCode = TCL_ERROR;
return NULL;
}
index = TclIndexDecode(infoPtr->indexv[i], listLen - 1);
if (Tcl_ListObjIndex(infoPtr->interp, objPtr, index,
¤tObj) != TCL_OK) {
infoPtr->resultCode = TCL_ERROR;
return NULL;
}
if (currentObj == NULL) {
if (index == TCL_INDEX_NONE) {
index = TCL_INDEX_END - infoPtr->indexv[i];
Tcl_SetObjResult(infoPtr->interp, Tcl_ObjPrintf(
"element end-%d missing from sublist \"%s\"",
index, TclGetString(objPtr)));
} else {
Tcl_SetObjResult(infoPtr->interp, Tcl_ObjPrintf(
"element %d missing from sublist \"%s\"",
|
| ︙ | ︙ |
Changes to generic/tclCmdMZ.c.
| ︙ | ︙ | |||
124 125 126 127 128 129 130 |
int
Tcl_RegexpObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
int
Tcl_RegexpObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size offset, stringLength, matchLength, cflags, eflags;
int i, indices, match, about, all, doinline, numMatchesSaved;
Tcl_RegExp regExpr;
Tcl_Obj *objPtr, *startIndex = NULL, *resultPtr = NULL;
Tcl_RegExpInfo info;
static const char *const options[] = {
"-all", "-about", "-indices", "-inline",
"-expanded", "-line", "-linestop", "-lineanchor",
|
| ︙ | ︙ | |||
187 188 189 190 191 192 193 |
case REGEXP_LINESTOP:
cflags |= TCL_REG_NLSTOP;
break;
case REGEXP_LINEANCHOR:
cflags |= TCL_REG_NLANCH;
break;
case REGEXP_START: {
| | | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
case REGEXP_LINESTOP:
cflags |= TCL_REG_NLSTOP;
break;
case REGEXP_LINEANCHOR:
cflags |= TCL_REG_NLANCH;
break;
case REGEXP_START: {
Tcl_Size temp;
if (++i >= objc) {
goto endOfForLoop;
}
if (TclGetIntForIndexM(interp, objv[i], TCL_SIZE_MAX - 1, &temp) != TCL_OK) {
goto optionError;
}
if (startIndex) {
Tcl_DecrRefCount(startIndex);
}
startIndex = objv[i];
Tcl_IncrRefCount(startIndex);
|
| ︙ | ︙ | |||
223 224 225 226 227 228 229 |
/*
* Check if the user requested -inline, but specified match variables; a
* no-no.
*/
if (doinline && ((objc - 2) != 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
/*
* Check if the user requested -inline, but specified match variables; a
* no-no.
*/
if (doinline && ((objc - 2) != 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"regexp match variables not allowed when using -inline", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "REGEXP",
"MIX_VAR_INLINE", NULL);
goto optionError;
}
/*
* Handle the odd about case separately.
|
| ︙ | ︙ | |||
257 258 259 260 261 262 263 |
objPtr = objv[1];
stringLength = Tcl_GetCharLength(objPtr);
if (startIndex) {
TclGetIntForIndexM(interp, startIndex, stringLength, &offset);
Tcl_DecrRefCount(startIndex);
| | | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
objPtr = objv[1];
stringLength = Tcl_GetCharLength(objPtr);
if (startIndex) {
TclGetIntForIndexM(interp, startIndex, stringLength, &offset);
Tcl_DecrRefCount(startIndex);
if (offset < 0) {
offset = TCL_INDEX_START;
}
}
regExpr = Tcl_GetRegExpFromObj(interp, objv[0], cflags);
if (regExpr == NULL) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
304 305 306 307 308 309 310 |
* considered the start of the line. If for example the pattern {^} is
* passed and -start is positive, then the pattern will not match the
* start of the string unless the previous character is a newline.
*/
if (offset == TCL_INDEX_START) {
eflags = 0;
| | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
* considered the start of the line. If for example the pattern {^} is
* passed and -start is positive, then the pattern will not match the
* start of the string unless the previous character is a newline.
*/
if (offset == TCL_INDEX_START) {
eflags = 0;
} else if (offset > stringLength) {
eflags = TCL_REG_NOTBOL;
} else if (Tcl_GetUniChar(objPtr, offset-1) == '\n') {
eflags = 0;
} else {
eflags = TCL_REG_NOTBOL;
}
|
| ︙ | ︙ | |||
360 361 362 363 364 365 366 |
resultPtr = Tcl_NewObj();
}
}
for (i = 0; i < objc; i++) {
Tcl_Obj *newPtr;
if (indices) {
| | | | | | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
resultPtr = Tcl_NewObj();
}
}
for (i = 0; i < objc; i++) {
Tcl_Obj *newPtr;
if (indices) {
Tcl_Size start, end;
Tcl_Obj *objs[2];
/*
* Only adjust the match area if there was a match for that
* area. (Scriptics Bug 4391/SF Bug #219232)
*/
if (i <= (int)info.nsubs && info.matches[i].start >= 0) {
start = offset + info.matches[i].start;
end = offset + info.matches[i].end;
/*
* Adjust index so it refers to the last character in the
* match instead of the first character after the match.
*/
if (end >= offset) {
end--;
}
} else {
start = TCL_INDEX_NONE;
end = TCL_INDEX_NONE;
}
TclNewIndexObj(objs[0], start);
TclNewIndexObj(objs[1], end);
newPtr = Tcl_NewListObj(2, objs);
} else {
if ((i <= (int)info.nsubs) && (info.matches[i].end > 0)) {
newPtr = Tcl_GetRange(objPtr,
offset + info.matches[i].start,
offset + info.matches[i].end - 1);
} else {
newPtr = Tcl_NewObj();
}
}
|
| ︙ | ︙ | |||
423 424 425 426 427 428 429 |
/*
* Adjust the offset to the character just after the last one in the
* matchVar and increment all to count how many times we are making a
* match. We always increment the offset by at least one to prevent
* endless looping (as in the case: regexp -all {a*} a). Otherwise,
* when we match the NULL string at the end of the input string, we
| | | | 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
/*
* Adjust the offset to the character just after the last one in the
* matchVar and increment all to count how many times we are making a
* match. We always increment the offset by at least one to prevent
* endless looping (as in the case: regexp -all {a*} a). Otherwise,
* when we match the NULL string at the end of the input string, we
* will loop indefinitely (because the length of the match is 0, so
* offset never changes).
*/
matchLength = (info.matches[0].end - info.matches[0].start);
offset += info.matches[0].end;
/*
* A match of length zero could happen for {^} {$} or {.*} and in
* these cases we always want to bump the index up one.
*/
if (matchLength == 0) {
offset++;
}
all++;
if (offset >= stringLength) {
break;
}
}
/*
* Set the interpreter's object result to an integer object with value 1
* if -all wasn't specified, otherwise it's all-1 (the number of times
|
| ︙ | ︙ | |||
484 485 486 487 488 489 490 |
Tcl_RegsubObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int result, cflags, all, match, command;
| | | | 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
Tcl_RegsubObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int result, cflags, all, match, command;
Tcl_Size idx, wlen, wsublen = 0, offset, numMatches, numParts;
Tcl_Size start, end, subStart, subEnd;
Tcl_RegExp regExpr;
Tcl_RegExpInfo info;
Tcl_Obj *resultPtr, *subPtr, *objPtr, *startIndex = NULL;
Tcl_UniChar ch, *wsrc, *wfirstChar, *wstring, *wsubspec = 0, *wend;
static const char *const options[] = {
"-all", "-command", "-expanded", "-line",
|
| ︙ | ︙ | |||
508 509 510 511 512 513 514 |
cflags = TCL_REG_ADVANCED;
all = 0;
offset = TCL_INDEX_START;
command = 0;
resultPtr = NULL;
| | | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
cflags = TCL_REG_ADVANCED;
all = 0;
offset = TCL_INDEX_START;
command = 0;
resultPtr = NULL;
for (idx = 1; idx < objc; idx++) {
const char *name;
name = TclGetString(objv[idx]);
if (name[0] != '-') {
break;
}
if (Tcl_GetIndexFromObj(interp, objv[idx], options, "option",
|
| ︙ | ︙ | |||
542 543 544 545 546 547 548 |
case REGSUB_LINESTOP:
cflags |= TCL_REG_NLSTOP;
break;
case REGSUB_LINEANCHOR:
cflags |= TCL_REG_NLANCH;
break;
case REGSUB_START: {
| | | | | | | | | | | 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
case REGSUB_LINESTOP:
cflags |= TCL_REG_NLSTOP;
break;
case REGSUB_LINEANCHOR:
cflags |= TCL_REG_NLANCH;
break;
case REGSUB_START: {
Tcl_Size temp;
if (++idx >= objc) {
goto endOfForLoop;
}
if (TclGetIntForIndexM(interp, objv[idx], TCL_SIZE_MAX - 1, &temp) != TCL_OK) {
goto optionError;
}
if (startIndex) {
Tcl_DecrRefCount(startIndex);
}
startIndex = objv[idx];
Tcl_IncrRefCount(startIndex);
break;
}
case REGSUB_LAST:
idx++;
goto endOfForLoop;
}
}
endOfForLoop:
if (objc < idx + 3 || objc > idx + 4) {
Tcl_WrongNumArgs(interp, 1, objv,
"?-option ...? exp string subSpec ?varName?");
optionError:
if (startIndex) {
Tcl_DecrRefCount(startIndex);
}
return TCL_ERROR;
}
objc -= idx;
objv += idx;
if (startIndex) {
Tcl_Size stringLength = Tcl_GetCharLength(objv[1]);
TclGetIntForIndexM(interp, startIndex, stringLength, &offset);
Tcl_DecrRefCount(startIndex);
if (offset < 0) {
offset = 0;
}
}
if (all && (offset == 0) && (command == 0)
&& (strpbrk(TclGetString(objv[2]), "&\\") == NULL)
&& (strpbrk(TclGetString(objv[0]), "*+?{}()[].\\|^$") == NULL)) {
/*
* This is a simple one pair string map situation. We make use of a
* slightly modified version of the one pair STR_MAP code.
*/
Tcl_Size slen;
int nocase, wsrclc;
int (*strCmpFn)(const Tcl_UniChar*,const Tcl_UniChar*,size_t);
Tcl_UniChar *p;
numMatches = 0;
nocase = (cflags & TCL_REG_NOCASE);
strCmpFn = nocase ? TclUniCharNcasecmp : TclUniCharNcmp;
|
| ︙ | ︙ | |||
770 771 772 773 774 775 776 |
* arguments to the subSpec to form a command, that is then executed
* and the result used as the string to substitute in. Actually,
* everything is passed through Tcl_EvalObjv, as that's much faster.
*/
if (command) {
Tcl_Obj **args = NULL, **parts;
| | | | 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 |
* arguments to the subSpec to form a command, that is then executed
* and the result used as the string to substitute in. Actually,
* everything is passed through Tcl_EvalObjv, as that's much faster.
*/
if (command) {
Tcl_Obj **args = NULL, **parts;
Tcl_Size numArgs;
TclListObjGetElementsM(interp, subPtr, &numParts, &parts);
numArgs = numParts + info.nsubs + 1;
args = (Tcl_Obj **)Tcl_Alloc(sizeof(Tcl_Obj*) * numArgs);
memcpy(args, parts, sizeof(Tcl_Obj*) * numParts);
for (idx = 0 ; idx <= info.nsubs ; idx++) {
subStart = info.matches[idx].start;
subEnd = info.matches[idx].end;
if ((subStart >= 0) && (subEnd >= 0)) {
args[idx + numParts] = Tcl_NewUnicodeObj(
wstring + offset + subStart, subEnd - subStart);
} else {
args[idx + numParts] = Tcl_NewObj();
}
Tcl_IncrRefCount(args[idx + numParts]);
}
|
| ︙ | ︙ | |||
884 885 886 887 888 889 890 |
Tcl_AppendUnicodeToObj(resultPtr, wfirstChar,
wsrc - wfirstChar);
}
if (idx <= info.nsubs) {
subStart = info.matches[idx].start;
subEnd = info.matches[idx].end;
| | | 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 |
Tcl_AppendUnicodeToObj(resultPtr, wfirstChar,
wsrc - wfirstChar);
}
if (idx <= info.nsubs) {
subStart = info.matches[idx].start;
subEnd = info.matches[idx].end;
if ((subStart >= 0) && (subEnd >= 0)) {
Tcl_AppendUnicodeToObj(resultPtr,
wstring + offset + subStart, subEnd - subStart);
}
}
if (*wsrc == '\\') {
wsrc++;
|
| ︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 |
Tcl_Obj *const objv[]) /* Argument objects. */
{
int ch = 0;
int len;
const char *splitChars;
const char *stringPtr;
const char *end;
| | | 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 |
Tcl_Obj *const objv[]) /* Argument objects. */
{
int ch = 0;
int len;
const char *splitChars;
const char *stringPtr;
const char *end;
Tcl_Size splitCharLen, stringLen;
Tcl_Obj *listPtr, *objPtr;
if (objc == 2) {
splitChars = " \n\t\r";
splitCharLen = 4;
} else if (objc == 3) {
splitChars = Tcl_GetStringFromObj(objv[2], &splitCharLen);
|
| ︙ | ︙ | |||
1235 1236 1237 1238 1239 1240 1241 |
Tcl_DeleteHashTable(&charReuseTable);
} else if (splitCharLen == 1) {
const char *p;
/*
* Handle the special case of splitting on a single character. This is
| | | | 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 |
Tcl_DeleteHashTable(&charReuseTable);
} else if (splitCharLen == 1) {
const char *p;
/*
* Handle the special case of splitting on a single character. This is
* only true for the one-char ASCII case, as one Unicode char is > 1
* byte in length.
*/
while (*stringPtr && (p=strchr(stringPtr,*splitChars)) != NULL) {
objPtr = Tcl_NewStringObj(stringPtr, p - stringPtr);
Tcl_ListObjAppendElement(NULL, listPtr, objPtr);
stringPtr = p + 1;
}
TclNewStringObj(objPtr, stringPtr, end - stringPtr);
Tcl_ListObjAppendElement(NULL, listPtr, objPtr);
} else {
const char *element, *p, *splitEnd;
Tcl_Size splitLen;
int splitChar;
/*
* Normal case: split on any of a given set of characters. Discard
* instances of the split characters.
*/
|
| ︙ | ︙ | |||
1303 1304 1305 1306 1307 1308 1309 |
static int
StringFirstCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | | 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 |
static int
StringFirstCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size start = TCL_INDEX_START;
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv,
"needleString haystackString ?startIndex?");
return TCL_ERROR;
}
if (objc == 4) {
Tcl_Size end = Tcl_GetCharLength(objv[2]) - 1;
if (TCL_OK != TclGetIntForIndexM(interp, objv[3], end, &start)) {
return TCL_ERROR;
}
}
Tcl_SetObjResult(interp, TclStringFirst(objv[1], objv[2], start));
return TCL_OK;
|
| ︙ | ︙ | |||
1347 1348 1349 1350 1351 1352 1353 |
static int
StringLastCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | | 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 |
static int
StringLastCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size last = TCL_SIZE_MAX;
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv,
"needleString haystackString ?lastIndex?");
return TCL_ERROR;
}
if (objc == 4) {
Tcl_Size end = Tcl_GetCharLength(objv[2]) - 1;
if (TCL_OK != TclGetIntForIndexM(interp, objv[3], end, &last)) {
return TCL_ERROR;
}
}
Tcl_SetObjResult(interp, TclStringLast(objv[1], objv[2], last));
return TCL_OK;
|
| ︙ | ︙ | |||
1391 1392 1393 1394 1395 1396 1397 |
static int
StringIndexCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | | 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 |
static int
StringIndexCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size index, end;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "string charIndex");
return TCL_ERROR;
}
/*
* Get the char length to calculate what 'end' means.
*/
end = Tcl_GetCharLength(objv[1]) - 1;
if (TclGetIntForIndexM(interp, objv[2], end, &index) != TCL_OK) {
return TCL_ERROR;
}
if ((index >= 0) && (index <= end)) {
int ch = Tcl_GetUniChar(objv[1], index);
if (ch == -1) {
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
1463 1464 1465 1466 1467 1468 1469 |
static int
StringInsertCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter */
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
{
| | | | | 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 |
static int
StringInsertCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter */
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
{
Tcl_Size length; /* String length */
Tcl_Size index; /* Insert index */
Tcl_Obj *outObj; /* Output object */
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv, "string index insertString");
return TCL_ERROR;
}
length = Tcl_GetCharLength(objv[1]);
if (TclGetIntForIndexM(interp, objv[2], length, &index) != TCL_OK) {
return TCL_ERROR;
}
if (index < 0) {
index = TCL_INDEX_START;
}
if (index > length) {
index = length;
}
outObj = TclStringReplace(interp, objv[1], index, 0, objv[3],
|
| ︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *string1, *end, *stop;
int (*chcomp)(int) = NULL; /* The UniChar comparison function. */
int i, result = 1, strict = 0;
| | | 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *string1, *end, *stop;
int (*chcomp)(int) = NULL; /* The UniChar comparison function. */
int i, result = 1, strict = 0;
Tcl_Size failat = 0, length1, length2, length3;
Tcl_Obj *objPtr, *failVarObj = NULL;
Tcl_WideInt w;
static const char *const isClasses[] = {
"alnum", "alpha", "ascii", "control",
"boolean", "dict", "digit", "double",
"entier", "false", "graph", "integer",
|
| ︙ | ︙ | |||
1585 1586 1587 1588 1589 1590 1591 |
}
}
}
/*
* We get the objPtr so that we can short-cut for some classes by checking
* the object type (int and double), but we need the string otherwise,
| | | 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 |
}
}
}
/*
* We get the objPtr so that we can short-cut for some classes by checking
* the object type (int and double), but we need the string otherwise,
* because we don't want any conversion of type occurring (as, for example,
* Tcl_Get*FromObj would do).
*/
objPtr = objv[objc-1];
/*
* When entering here, result == 1 and failat == 0.
|
| ︙ | ︙ | |||
1626 1627 1628 1629 1630 1631 1632 |
}
break;
case STR_IS_CONTROL:
chcomp = Tcl_UniCharIsControl;
break;
case STR_IS_DICT: {
int dresult;
| | | < | 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 |
}
break;
case STR_IS_CONTROL:
chcomp = Tcl_UniCharIsControl;
break;
case STR_IS_DICT: {
int dresult;
Tcl_Size dsize;
dresult = Tcl_DictObjSize(interp, objPtr, &dsize);
Tcl_ResetResult(interp);
result = (dresult == TCL_OK) ? 1 : 0;
if (dresult != TCL_OK && failVarObj != NULL) {
/*
* Need to figure out where the list parsing failed, which is
* fairly expensive. This is adapted from the core of
* SetDictFromAny().
*/
const char *elemStart, *nextElem;
Tcl_Size lenRemain, elemSize;
const char *p;
string1 = Tcl_GetStringFromObj(objPtr, &length1);
end = string1 + length1;
failat = -1;
for (p=string1, lenRemain=length1; lenRemain > 0;
p=nextElem, lenRemain=end-nextElem) {
|
| ︙ | ︙ | |||
1820 1821 1822 1823 1824 1825 1826 | /* * Need to figure out where the list parsing failed, which is * fairly expensive. This is adapted from the core of * SetListFromAny(). */ const char *elemStart, *nextElem; | | | | 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 |
/*
* Need to figure out where the list parsing failed, which is
* fairly expensive. This is adapted from the core of
* SetListFromAny().
*/
const char *elemStart, *nextElem;
Tcl_Size lenRemain;
Tcl_Size elemSize;
const char *p;
string1 = Tcl_GetStringFromObj(objPtr, &length1);
end = string1 + length1;
failat = -1;
for (p=string1, lenRemain=length1; lenRemain > 0;
p=nextElem, lenRemain=end-nextElem) {
|
| ︙ | ︙ | |||
1956 1957 1958 1959 1960 1961 1962 |
static int
StringMapCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 |
static int
StringMapCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size length1, length2, mapElemc, index;
int nocase = 0, mapWithDict = 0, copySource = 0;
Tcl_Obj **mapElemv, *sourceObj, *resultPtr;
Tcl_UniChar *ustring1, *ustring2, *p, *end;
int (*strCmpFn)(const Tcl_UniChar*, const Tcl_UniChar*, size_t);
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "?-nocase? charMap string");
|
| ︙ | ︙ | |||
1989 1990 1991 1992 1993 1994 1995 |
/*
* This test is tricky, but has to be that way or you get other strange
* inconsistencies (see test string-10.20.1 for illustration why!)
*/
if (!TclHasStringRep(objv[objc-2])
&& TclHasInternalRep(objv[objc-2], &tclDictType)) {
| | | 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 |
/*
* This test is tricky, but has to be that way or you get other strange
* inconsistencies (see test string-10.20.1 for illustration why!)
*/
if (!TclHasStringRep(objv[objc-2])
&& TclHasInternalRep(objv[objc-2], &tclDictType)) {
Tcl_Size i;
int done;
Tcl_DictSearch search;
/*
* We know the type exactly, so all dict operations will succeed for
* sure. This shortens this code quite a bit.
*/
|
| ︙ | ︙ | |||
2024 2025 2026 2027 2028 2029 2030 |
Tcl_DictObjFirst(interp, objv[objc-2], &search, mapElemv+0,
mapElemv+1, &done);
for (index=2 ; index<mapElemc ; index+=2) {
Tcl_DictObjNext(&search, mapElemv+index, mapElemv+index+1, &done);
}
Tcl_DictObjDone(&search);
} else {
| | | | 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 |
Tcl_DictObjFirst(interp, objv[objc-2], &search, mapElemv+0,
mapElemv+1, &done);
for (index=2 ; index<mapElemc ; index+=2) {
Tcl_DictObjNext(&search, mapElemv+index, mapElemv+index+1, &done);
}
Tcl_DictObjDone(&search);
} else {
Tcl_Size i;
if (TclListObjGetElementsM(interp, objv[objc-2], &i,
&mapElemv) != TCL_OK) {
return TCL_ERROR;
}
mapElemc = i;
if (mapElemc == 0) {
/*
* empty charMap, just return whatever string was given.
*/
Tcl_SetObjResult(interp, objv[objc-1]);
return TCL_OK;
} else if (mapElemc & 1) {
/*
* The charMap must be an even number of key/value items.
*/
Tcl_SetObjResult(interp,
Tcl_NewStringObj("char map list unbalanced", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "MAP",
"UNBALANCED", NULL);
return TCL_ERROR;
}
}
/*
|
| ︙ | ︙ | |||
2087 2088 2089 2090 2091 2092 2093 | /* * Special case for one map pair which avoids the extra for loop and * extra calls to get Unicode data. The algorithm is otherwise * identical to the multi-pair case. This will be >30% faster on * larger strings. */ | | | 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 |
/*
* Special case for one map pair which avoids the extra for loop and
* extra calls to get Unicode data. The algorithm is otherwise
* identical to the multi-pair case. This will be >30% faster on
* larger strings.
*/
Tcl_Size mapLen;
int u2lc;
Tcl_UniChar *mapString;
ustring2 = Tcl_GetUnicodeFromObj(mapElemv[0], &length2);
p = ustring1;
if ((length2 > length1) || (length2 == 0)) {
/*
|
| ︙ | ︙ | |||
2121 2122 2123 2124 2125 2126 2127 |
Tcl_AppendUnicodeToObj(resultPtr, mapString, mapLen);
}
}
}
} else {
Tcl_UniChar **mapStrings;
| | | | | 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 |
Tcl_AppendUnicodeToObj(resultPtr, mapString, mapLen);
}
}
}
} else {
Tcl_UniChar **mapStrings;
Tcl_Size *mapLens;
int *u2lc = 0;
/*
* Precompute pointers to the Unicode string and length. This saves us
* repeated function calls later, significantly speeding up the
* algorithm. We only need the lowercase first char in the nocase
* case.
*/
mapStrings = (Tcl_UniChar **)TclStackAlloc(interp, mapElemc*sizeof(Tcl_UniChar *)*2);
mapLens = (Tcl_Size *)TclStackAlloc(interp, mapElemc * sizeof(Tcl_Size) * 2);
if (nocase) {
u2lc = (int *)TclStackAlloc(interp, mapElemc * sizeof(int));
}
for (index = 0; index < mapElemc; index++) {
mapStrings[index] = Tcl_GetUnicodeFromObj(mapElemv[index],
mapLens+index);
if (nocase && ((index % 2) == 0)) {
|
| ︙ | ︙ | |||
2154 2155 2156 2157 2158 2159 2160 | */ ustring2 = mapStrings[index]; length2 = mapLens[index]; if ((length2 > 0) && ((*ustring1 == *ustring2) || (nocase && (Tcl_UniCharToLower(*ustring1) == u2lc[index/2]))) && /* Restrict max compare length. */ | | | | 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 |
*/
ustring2 = mapStrings[index];
length2 = mapLens[index];
if ((length2 > 0) && ((*ustring1 == *ustring2) || (nocase &&
(Tcl_UniCharToLower(*ustring1) == u2lc[index/2]))) &&
/* Restrict max compare length. */
((end-ustring1) >= length2) && ((length2 == 1) ||
!strCmpFn(ustring2, ustring1, length2))) {
if (p != ustring1) {
/*
* Put the skipped chars onto the result first.
*/
Tcl_AppendUnicodeToObj(resultPtr, p, ustring1-p);
p = ustring1 + length2;
} else {
p += length2;
}
/*
* Adjust len to be full length of matched string.
*/
ustring1 = p - 1;
/*
* Append the map value to the Unicode string.
*/
Tcl_AppendUnicodeToObj(resultPtr,
mapStrings[index+1], mapLens[index+1]);
break;
}
}
|
| ︙ | ︙ | |||
2240 2241 2242 2243 2244 2245 2246 |
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "?-nocase? pattern string");
return TCL_ERROR;
}
if (objc == 4) {
| | | 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 |
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "?-nocase? pattern string");
return TCL_ERROR;
}
if (objc == 4) {
Tcl_Size length;
const char *string = Tcl_GetStringFromObj(objv[1], &length);
if ((length > 1) &&
strncmp(string, "-nocase", length) == 0) {
nocase = TCL_MATCH_NOCASE;
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
| ︙ | ︙ | |||
2284 2285 2286 2287 2288 2289 2290 |
static int
StringRangeCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | | 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 |
static int
StringRangeCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size first, last, end;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv, "string first last");
return TCL_ERROR;
}
/*
* Get the length in actual characters; Then reduce it by one because
* 'end' refers to the last character, not one past it.
*/
end = Tcl_GetCharLength(objv[1]) - 1;
if (TclGetIntForIndexM(interp, objv[2], end, &first) != TCL_OK ||
TclGetIntForIndexM(interp, objv[3], end, &last) != TCL_OK) {
return TCL_ERROR;
}
if (last >= 0) {
Tcl_SetObjResult(interp, Tcl_GetRange(objv[1], first, last));
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
2390 2391 2392 2393 2394 2395 2396 |
static int
StringRplcCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | | | | | | 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 |
static int
StringRplcCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size first, last, end;
if (objc < 4 || objc > 5) {
Tcl_WrongNumArgs(interp, 1, objv, "string first last ?string?");
return TCL_ERROR;
}
end = Tcl_GetCharLength(objv[1]) - 1;
if (TclGetIntForIndexM(interp, objv[2], end, &first) != TCL_OK ||
TclGetIntForIndexM(interp, objv[3], end, &last) != TCL_OK) {
return TCL_ERROR;
}
/*
* The following test screens out most empty substrings as candidates for
* replacement. When they are detected, no replacement is done, and the
* result is the original string.
*/
if ((last < 0) || /* Range ends before start of string */
(first > end) || /* Range begins after end of string */
(last < first)) { /* Range begins after it starts */
/*
* BUT!!! when (end < 0) -- an empty original string -- we can
* have (first <= end < 0 <= last) and an empty string is permitted
* to be replaced.
*/
Tcl_SetObjResult(interp, objv[1]);
} else {
Tcl_Obj *resultPtr;
if (first < 0) {
first = TCL_INDEX_START;
}
if (last > end) {
last = end;
}
resultPtr = TclStringReplace(interp, objv[1], first,
last + 1 - first, (objc == 5) ? objv[4] : NULL,
TCL_STRING_IN_PLACE);
|
| ︙ | ︙ | |||
2502 2503 2504 2505 2506 2507 2508 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int ch;
const Tcl_UniChar *p, *string;
| | | | | 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int ch;
const Tcl_UniChar *p, *string;
Tcl_Size cur, index, length;
Tcl_Obj *obj;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "string index");
return TCL_ERROR;
}
string = Tcl_GetUnicodeFromObj(objv[1], &length);
if (TclGetIntForIndexM(interp, objv[2], length-1, &index) != TCL_OK) {
return TCL_ERROR;
}
if (index >= length) {
index = length - 1;
}
cur = 0;
if (index > 0) {
p = &string[index];
(void)TclUniCharToUCS4(p, &ch);
for (cur = index; cur != TCL_INDEX_NONE; cur--) {
int delta = 0;
const Tcl_UniChar *next;
|
| ︙ | ︙ | |||
2572 2573 2574 2575 2576 2577 2578 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int ch;
const Tcl_UniChar *p, *end, *string;
| | | | | | 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int ch;
const Tcl_UniChar *p, *end, *string;
Tcl_Size cur, index, length;
Tcl_Obj *obj;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "string index");
return TCL_ERROR;
}
string = Tcl_GetUnicodeFromObj(objv[1], &length);
if (TclGetIntForIndexM(interp, objv[2], length-1, &index) != TCL_OK) {
return TCL_ERROR;
}
if (index < 0) {
index = 0;
}
if (index < length) {
p = &string[index];
end = string+length;
for (cur = index; p < end; cur++) {
p += TclUniCharToUCS4(p, &ch);
if (!Tcl_UniCharIsWordChar(ch)) {
break;
}
|
| ︙ | ︙ | |||
2639 2640 2641 2642 2643 2644 2645 |
/*
* Remember to keep code here in some sync with the byte-compiled versions
* in tclExecute.c (INST_STR_EQ, INST_STR_NEQ and INST_STR_CMP as well as
* the expr string comparison in INST_EQ/INST_NEQ/INST_LT/...).
*/
const char *string2;
| | | | | 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 |
/*
* Remember to keep code here in some sync with the byte-compiled versions
* in tclExecute.c (INST_STR_EQ, INST_STR_NEQ and INST_STR_CMP as well as
* the expr string comparison in INST_EQ/INST_NEQ/INST_LT/...).
*/
const char *string2;
int i, match, nocase = 0;
Tcl_Size length, reqlength = -1;
if (objc < 3 || objc > 6) {
str_cmp_args:
Tcl_WrongNumArgs(interp, 1, objv,
"?-nocase? ?-length int? string1 string2");
return TCL_ERROR;
}
for (i = 1; i < objc-2; i++) {
string2 = Tcl_GetStringFromObj(objv[i], &length);
if ((length > 1) && !strncmp(string2, "-nocase", length)) {
nocase = 1;
} else if ((length > 1)
&& !strncmp(string2, "-length", length)) {
if (i+1 >= objc-2) {
goto str_cmp_args;
}
i++;
if (TclGetSizeIntFromObj(interp, objv[i], &reqlength) != TCL_OK) {
return TCL_ERROR;
}
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad option \"%s\": must be -nocase or -length",
string2));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option",
|
| ︙ | ︙ | |||
2714 2715 2716 2717 2718 2719 2720 |
{
/*
* Remember to keep code here in some sync with the byte-compiled versions
* in tclExecute.c (INST_STR_EQ, INST_STR_NEQ and INST_STR_CMP as well as
* the expr string comparison in INST_EQ/INST_NEQ/INST_LT/...).
*/
| | > | | | 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 |
{
/*
* Remember to keep code here in some sync with the byte-compiled versions
* in tclExecute.c (INST_STR_EQ, INST_STR_NEQ and INST_STR_CMP as well as
* the expr string comparison in INST_EQ/INST_NEQ/INST_LT/...).
*/
int match, nocase, status;
Tcl_Size reqlength;
status = TclStringCmpOpts(interp, objc, objv, &nocase, &reqlength);
if (status != TCL_OK) {
return status;
}
objv += objc-2;
match = TclStringCmp(objv[0], objv[1], 0, nocase, reqlength);
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(match));
return TCL_OK;
}
int
TclStringCmpOpts(
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects. */
int *nocase,
Tcl_Size *reqlength)
{
int i;
Tcl_Size length;
const char *string;
*reqlength = -1;
*nocase = 0;
if (objc < 3 || objc > 6) {
str_cmp_args:
Tcl_WrongNumArgs(interp, 1, objv,
|
| ︙ | ︙ | |||
2758 2759 2760 2761 2762 2763 2764 |
*nocase = 1;
} else if ((length > 1)
&& !strncmp(string, "-length", length)) {
if (i+1 >= objc-2) {
goto str_cmp_args;
}
i++;
| | | 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 |
*nocase = 1;
} else if ((length > 1)
&& !strncmp(string, "-length", length)) {
if (i+1 >= objc-2) {
goto str_cmp_args;
}
i++;
if (TclGetSizeIntFromObj(interp, objv[i], reqlength) != TCL_OK) {
return TCL_ERROR;
}
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad option \"%s\": must be -nocase or -length",
string));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option",
|
| ︙ | ︙ | |||
2876 2877 2878 2879 2880 2881 2882 |
static int
StringLowerCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | | | | | | 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 |
static int
StringLowerCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size length1, length2;
const char *string1;
char *string2;
if (objc < 2 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "string ?first? ?last?");
return TCL_ERROR;
}
string1 = Tcl_GetStringFromObj(objv[1], &length1);
if (objc == 2) {
Tcl_Obj *resultPtr = Tcl_NewStringObj(string1, length1);
length1 = Tcl_UtfToLower(TclGetString(resultPtr));
Tcl_SetObjLength(resultPtr, length1);
Tcl_SetObjResult(interp, resultPtr);
} else {
Tcl_Size first, last;
const char *start, *end;
Tcl_Obj *resultPtr;
length1 = Tcl_NumUtfChars(string1, length1) - 1;
if (TclGetIntForIndexM(interp,objv[2],length1, &first) != TCL_OK) {
return TCL_ERROR;
}
if (first < 0) {
first = 0;
}
last = first;
if ((objc == 4) && (TclGetIntForIndexM(interp, objv[3], length1,
&last) != TCL_OK)) {
return TCL_ERROR;
}
if (last >= length1) {
last = length1;
}
if (last < first) {
Tcl_SetObjResult(interp, objv[1]);
return TCL_OK;
}
string1 = Tcl_GetStringFromObj(objv[1], &length1);
start = Tcl_UtfAtIndex(string1, first);
end = Tcl_UtfAtIndex(start, last - first + 1);
resultPtr = Tcl_NewStringObj(string1, end - string1);
string2 = TclGetString(resultPtr) + (start - string1);
length2 = Tcl_UtfToLower(string2);
Tcl_SetObjLength(resultPtr, length2 + (start - string1));
Tcl_AppendToObj(resultPtr, end, -1);
Tcl_SetObjResult(interp, resultPtr);
}
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
2961 2962 2963 2964 2965 2966 2967 |
static int
StringUpperCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | | | | | | | 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 |
static int
StringUpperCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size length1, length2;
const char *string1;
char *string2;
if (objc < 2 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "string ?first? ?last?");
return TCL_ERROR;
}
string1 = Tcl_GetStringFromObj(objv[1], &length1);
if (objc == 2) {
Tcl_Obj *resultPtr = Tcl_NewStringObj(string1, length1);
length1 = Tcl_UtfToUpper(TclGetString(resultPtr));
Tcl_SetObjLength(resultPtr, length1);
Tcl_SetObjResult(interp, resultPtr);
} else {
Tcl_Size first, last;
const char *start, *end;
Tcl_Obj *resultPtr;
length1 = Tcl_NumUtfChars(string1, length1) - 1;
if (TclGetIntForIndexM(interp,objv[2],length1, &first) != TCL_OK) {
return TCL_ERROR;
}
if (first < 0) {
first = 0;
}
last = first;
if ((objc == 4) && (TclGetIntForIndexM(interp, objv[3], length1,
&last) != TCL_OK)) {
return TCL_ERROR;
}
if (last >= length1) {
last = length1;
}
if (last < first) {
Tcl_SetObjResult(interp, objv[1]);
return TCL_OK;
}
string1 = Tcl_GetStringFromObj(objv[1], &length1);
start = Tcl_UtfAtIndex(string1, first);
end = Tcl_UtfAtIndex(start, last - first + 1);
resultPtr = Tcl_NewStringObj(string1, end - string1);
string2 = TclGetString(resultPtr) + (start - string1);
length2 = Tcl_UtfToUpper(string2);
Tcl_SetObjLength(resultPtr, length2 + (start - string1));
Tcl_AppendToObj(resultPtr, end, -1);
Tcl_SetObjResult(interp, resultPtr);
}
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
3046 3047 3048 3049 3050 3051 3052 |
static int
StringTitleCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | | | | | | | 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 |
static int
StringTitleCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size length1, length2;
const char *string1;
char *string2;
if (objc < 2 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "string ?first? ?last?");
return TCL_ERROR;
}
string1 = Tcl_GetStringFromObj(objv[1], &length1);
if (objc == 2) {
Tcl_Obj *resultPtr = Tcl_NewStringObj(string1, length1);
length1 = Tcl_UtfToTitle(TclGetString(resultPtr));
Tcl_SetObjLength(resultPtr, length1);
Tcl_SetObjResult(interp, resultPtr);
} else {
Tcl_Size first, last;
const char *start, *end;
Tcl_Obj *resultPtr;
length1 = Tcl_NumUtfChars(string1, length1) - 1;
if (TclGetIntForIndexM(interp,objv[2],length1, &first) != TCL_OK) {
return TCL_ERROR;
}
if (first < 0) {
first = 0;
}
last = first;
if ((objc == 4) && (TclGetIntForIndexM(interp, objv[3], length1,
&last) != TCL_OK)) {
return TCL_ERROR;
}
if (last >= length1) {
last = length1;
}
if (last < first) {
Tcl_SetObjResult(interp, objv[1]);
return TCL_OK;
}
string1 = Tcl_GetStringFromObj(objv[1], &length1);
start = Tcl_UtfAtIndex(string1, first);
end = Tcl_UtfAtIndex(start, last - first + 1);
resultPtr = Tcl_NewStringObj(string1, end - string1);
string2 = TclGetString(resultPtr) + (start - string1);
length2 = Tcl_UtfToTitle(string2);
Tcl_SetObjLength(resultPtr, length2 + (start - string1));
Tcl_AppendToObj(resultPtr, end, -1);
Tcl_SetObjResult(interp, resultPtr);
}
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
3132 3133 3134 3135 3136 3137 3138 |
StringTrimCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *string1, *string2;
| | | 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 |
StringTrimCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *string1, *string2;
Tcl_Size triml, trimr, length1, length2;
if (objc == 3) {
string2 = Tcl_GetStringFromObj(objv[2], &length2);
} else if (objc == 2) {
string2 = tclDefaultTrimSet;
length2 = strlen(tclDefaultTrimSet);
} else {
|
| ︙ | ︙ | |||
3180 3181 3182 3183 3184 3185 3186 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *string1, *string2;
int trim;
| | | 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *string1, *string2;
int trim;
Tcl_Size length1, length2;
if (objc == 3) {
string2 = Tcl_GetStringFromObj(objv[2], &length2);
} else if (objc == 2) {
string2 = tclDefaultTrimSet;
length2 = strlen(tclDefaultTrimSet);
} else {
|
| ︙ | ︙ | |||
3227 3228 3229 3230 3231 3232 3233 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *string1, *string2;
int trim;
| | | 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *string1, *string2;
int trim;
Tcl_Size length1, length2;
if (objc == 3) {
string2 = Tcl_GetStringFromObj(objv[2], &length2);
} else if (objc == 2) {
string2 = tclDefaultTrimSet;
length2 = strlen(tclDefaultTrimSet);
} else {
|
| ︙ | ︙ | |||
3324 3325 3326 3327 3328 3329 3330 |
*
*----------------------------------------------------------------------
*/
int
TclSubstOptions(
Tcl_Interp *interp,
| | < | 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 |
*
*----------------------------------------------------------------------
*/
int
TclSubstOptions(
Tcl_Interp *interp,
Tcl_Size numOpts,
Tcl_Obj *const opts[],
int *flagPtr)
{
static const char *const substOptions[] = {
"-nobackslashes", "-nocommands", "-novariables", NULL
};
enum {
SUBST_NOBACKSLASHES, SUBST_NOCOMMANDS, SUBST_NOVARS
};
int i, flags = TCL_SUBST_ALL;
for (i = 0; i < numOpts; i++) {
int optionIndex;
if (Tcl_GetIndexFromObj(interp, opts[i], substOptions, "option", 0,
&optionIndex) != TCL_OK) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
3428 3429 3430 3431 3432 3433 3434 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int i, mode, foundmode, splitObjs, numMatchesSaved;
int noCase;
| | | 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int i, mode, foundmode, splitObjs, numMatchesSaved;
int noCase;
Tcl_Size patternLength, j;
const char *pattern;
Tcl_Obj *stringObj, *indexVarObj, *matchVarObj;
Tcl_Obj *const *savedObjv = objv;
Tcl_RegExp regExpr = NULL;
Interp *iPtr = (Interp *) interp;
int pc = 0;
int bidx = 0; /* Index of body argument. */
|
| ︙ | ︙ | |||
3576 3577 3578 3579 3580 3581 3582 |
* the same data for the list word itself. The cmdFramePtr line
* information is manipulated directly.
*/
splitObjs = 0;
if (objc == 1) {
Tcl_Obj **listv;
| | | 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 |
* the same data for the list word itself. The cmdFramePtr line
* information is manipulated directly.
*/
splitObjs = 0;
if (objc == 1) {
Tcl_Obj **listv;
Tcl_Size listc;
blist = objv[0];
if (TclListObjLengthM(interp, objv[0], &listc) != TCL_OK) {
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
3608 3609 3610 3611 3612 3613 3614 |
* Complain if there is an odd number of words in the list of patterns and
* bodies.
*/
if (objc % 2) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 |
* Complain if there is an odd number of words in the list of patterns and
* bodies.
*/
if (objc % 2) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"extra switch pattern with no body", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH", "BADARM",
NULL);
/*
* Check if this can be due to a badly placed comment in the switch
* block.
*
* The following is an heuristic to detect the infamous "comment in
* switch" error: just check if a pattern begins with '#'.
*/
if (splitObjs) {
for (i=0 ; i<objc ; i+=2) {
if (TclGetString(objv[i])[0] == '#') {
Tcl_AppendToObj(Tcl_GetObjResult(interp),
", this may be due to a comment incorrectly"
" placed outside of a switch body - see the"
" \"switch\" documentation", -1);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH",
"BADARM", "COMMENT?", NULL);
break;
}
}
}
|
| ︙ | ︙ | |||
3744 3745 3746 3747 3748 3749 3750 |
TclNewObj(indicesObj);
}
for (j=0 ; j<=info.nsubs ; j++) {
if (indexVarObj != NULL) {
Tcl_Obj *rangeObjAry[2];
| | | | 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 |
TclNewObj(indicesObj);
}
for (j=0 ; j<=info.nsubs ; j++) {
if (indexVarObj != NULL) {
Tcl_Obj *rangeObjAry[2];
if (info.matches[j].end > 0) {
TclNewIndexObj(rangeObjAry[0], info.matches[j].start);
TclNewIndexObj(rangeObjAry[1], info.matches[j].end-1);
} else {
TclNewIntObj(rangeObjAry[1], -1);
rangeObjAry[0] = rangeObjAry[1];
}
/*
* Never fails; the object is always clean at this point.
*/
Tcl_ListObjAppendElement(NULL, indicesObj,
Tcl_NewListObj(2, rangeObjAry));
}
if (matchVarObj != NULL) {
Tcl_Obj *substringObj;
if (info.matches[j].end > 0) {
substringObj = Tcl_GetRange(stringObj,
info.matches[j].start, info.matches[j].end-1);
} else {
TclNewObj(substringObj);
}
/*
|
| ︙ | ︙ | |||
3868 3869 3870 3871 3872 3873 3874 |
for (k=0; k < objc; k++) {
ctxPtr->line[k] = -1;
}
}
}
for (j = i + 1; ; j += 2) {
| | | 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 |
for (k=0; k < objc; k++) {
ctxPtr->line[k] = -1;
}
}
}
for (j = i + 1; ; j += 2) {
if (j >= objc) {
/*
* This shouldn't happen since we've checked that the last body is
* not a continuation...
*/
Tcl_Panic("fall-out when searching for body to match pattern");
}
|
| ︙ | ︙ | |||
3902 3903 3904 3905 3906 3907 3908 |
{
/* Unpack the preserved data */
int splitObjs = PTR2INT(data[0]);
CmdFrame *ctxPtr = (CmdFrame *)data[1];
int pc = PTR2INT(data[2]);
const char *pattern = (const char *)data[3];
| | | 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 |
{
/* Unpack the preserved data */
int splitObjs = PTR2INT(data[0]);
CmdFrame *ctxPtr = (CmdFrame *)data[1];
int pc = PTR2INT(data[2]);
const char *pattern = (const char *)data[3];
Tcl_Size patternLength = strlen(pattern);
/*
* Clean up TIP 280 context information
*/
if (splitObjs) {
Tcl_Free(ctxPtr->line);
|
| ︙ | ︙ | |||
3924 3925 3926 3927 3928 3929 3930 |
}
/*
* Generate an error message if necessary.
*/
if (result == TCL_ERROR) {
| | | | 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 |
}
/*
* Generate an error message if necessary.
*/
if (result == TCL_ERROR) {
int limit = 50;
int overflow = (patternLength > limit);
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (\"%.*s%s\" arm line %d)",
(int) (overflow ? limit : patternLength), pattern,
(overflow ? "..." : ""), Tcl_GetErrorLine(interp)));
}
TclStackFree(interp, ctxPtr);
return result;
}
/*
|
| ︙ | ︙ | |||
3961 3962 3963 3964 3965 3966 3967 |
Tcl_ThrowObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *options;
| | | | 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 |
Tcl_ThrowObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *options;
Tcl_Size len;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "type message");
return TCL_ERROR;
}
/*
* The type must be a list of at least length 1.
*/
if (TclListObjLengthM(interp, objv[1], &len) != TCL_OK) {
return TCL_ERROR;
} else if (len < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"type must be non-empty list", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "THROW", "BADEXCEPTION",
NULL);
return TCL_ERROR;
}
/*
* Now prepare the result options dictionary. We use the list API as it is
|
| ︙ | ︙ | |||
4678 4679 4680 4681 4682 4683 4684 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *bodyObj, *handlersObj, *finallyObj = NULL;
int i, bodyShared, haveHandlers, code;
| | | 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *bodyObj, *handlersObj, *finallyObj = NULL;
int i, bodyShared, haveHandlers, code;
Tcl_Size dummy;
static const char *const handlerNames[] = {
"finally", "on", "trap", NULL
};
enum Handlers {
TryFinally, TryOn, TryTrap
};
|
| ︙ | ︙ | |||
4714 4715 4716 4717 4718 4719 4720 |
Tcl_DecrRefCount(handlersObj);
return TCL_ERROR;
}
switch (type) {
case TryFinally: /* finally script */
if (i < objc-2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 |
Tcl_DecrRefCount(handlersObj);
return TCL_ERROR;
}
switch (type) {
case TryFinally: /* finally script */
if (i < objc-2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"finally clause must be last", -1));
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "FINALLY",
"NONTERMINAL", NULL);
return TCL_ERROR;
} else if (i == objc-1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"wrong # args to finally clause: must be"
" \"... finally script\"", -1));
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "FINALLY",
"ARGUMENT", NULL);
return TCL_ERROR;
}
finallyObj = objv[++i];
break;
case TryOn: /* on code variableList script */
if (i > objc-4) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"wrong # args to on clause: must be \"... on code"
" variableList script\"", -1));
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "ON",
"ARGUMENT", NULL);
return TCL_ERROR;
}
if (TclGetCompletionCodeFromObj(interp, objv[i+1],
&code) != TCL_OK) {
|
| ︙ | ︙ | |||
4796 4797 4798 4799 4800 4801 4802 |
haveHandlers = 1;
i += 3;
break;
}
}
if (bodyShared) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 |
haveHandlers = 1;
i += 3;
break;
}
}
if (bodyShared) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"last non-finally clause must not have a body of \"-\"", -1));
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "BADFALLTHROUGH",
NULL);
return TCL_ERROR;
}
if (!haveHandlers) {
Tcl_DecrRefCount(handlersObj);
|
| ︙ | ︙ | |||
4876 4877 4878 4879 4880 4881 4882 |
TryPostBody(
void *data[],
Tcl_Interp *interp,
int result)
{
Tcl_Obj *resultObj, *options, *handlersObj, *finallyObj, *cmdObj, **objv;
int code, objc;
| | | 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 |
TryPostBody(
void *data[],
Tcl_Interp *interp,
int result)
{
Tcl_Obj *resultObj, *options, *handlersObj, *finallyObj, *cmdObj, **objv;
int code, objc;
Tcl_Size i, numHandlers = 0;
handlersObj = (Tcl_Obj *)data[0];
finallyObj = (Tcl_Obj *)data[1];
objv = (Tcl_Obj **)data[2];
objc = PTR2INT(data[3]);
cmdObj = objv[0];
|
| ︙ | ︙ | |||
4926 4927 4928 4929 4930 4931 4932 |
if (handlersObj != NULL) {
int found = 0;
Tcl_Obj **handlers, **info;
TclListObjGetElementsM(NULL, handlersObj, &numHandlers, &handlers);
for (i=0 ; i<numHandlers ; i++) {
Tcl_Obj *handlerBodyObj;
| | | | 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 |
if (handlersObj != NULL) {
int found = 0;
Tcl_Obj **handlers, **info;
TclListObjGetElementsM(NULL, handlersObj, &numHandlers, &handlers);
for (i=0 ; i<numHandlers ; i++) {
Tcl_Obj *handlerBodyObj;
Tcl_Size numElems = 0;
TclListObjGetElementsM(NULL, handlers[i], &numElems, &info);
if (!found) {
Tcl_GetIntFromObj(NULL, info[1], &code);
if (code != result) {
continue;
}
/*
* When processing an error, we must also perform list-prefix
* matching of the errorcode list. However, if this was an
* 'on' handler, the list that we are matching against will be
* empty.
*/
if (code == TCL_ERROR) {
Tcl_Obj *errorCodeName, *errcode, **bits1, **bits2;
Tcl_Size len1, len2, j;
TclNewLiteralStringObj(errorCodeName, "-errorcode");
Tcl_DictObjGet(NULL, options, errorCodeName, &errcode);
Tcl_DecrRefCount(errorCodeName);
TclListObjGetElementsM(NULL, info[2], &len1, &bits1);
if (TclListObjGetElementsM(NULL, errcode, &len2,
&bits2) != TCL_OK) {
|
| ︙ | ︙ | |||
5298 5299 5300 5301 5302 5303 5304 |
*/
void
TclListLines(
Tcl_Obj *listObj, /* Pointer to obj holding a string with list
* structure. Assumed to be valid. Assumed to
* contain n elements. */
| | | 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 |
*/
void
TclListLines(
Tcl_Obj *listObj, /* Pointer to obj holding a string with list
* structure. Assumed to be valid. Assumed to
* contain n elements. */
Tcl_Size line, /* Line the list as a whole starts on. */
int n, /* #elements in lines */
int *lines, /* Array of line numbers, to fill. */
Tcl_Obj *const *elems) /* The list elems as Tcl_Obj*, in need of
* derived continuation data */
{
const char *listStr = TclGetString(listObj);
const char *listHead = listStr;
|
| ︙ | ︙ |
Changes to generic/tclCompCmds.c.
| ︙ | ︙ | |||
226 227 228 229 230 231 232 | } /* *---------------------------------------------------------------------- * * TclCompileArray*Cmd -- * | | | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | } /* *---------------------------------------------------------------------- * * TclCompileArray*Cmd -- * * Functions called to compile "array" subcommands. * * Results: * All return TCL_OK for a successful compile, and TCL_ERROR to defer * evaluation to runtime. * * Side effects: * Instructions are added to envPtr to execute the "array" subcommand at |
| ︙ | ︙ | |||
283 284 285 286 287 288 289 |
* compiled. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *varTokenPtr, *dataTokenPtr;
int isScalar, localIndex, code = TCL_OK;
int isDataLiteral, isDataValid, isDataEven;
| | | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
* compiled. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *varTokenPtr, *dataTokenPtr;
int isScalar, localIndex, code = TCL_OK;
int isDataLiteral, isDataValid, isDataEven;
Tcl_Size len;
int keyVar, valVar, infoIndex;
int fwd, offsetBack, offsetFwd;
Tcl_Obj *literalObj;
ForeachInfo *infoPtr;
if (parsePtr->numWords != 3) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
389 390 391 392 393 394 395 |
*/
keyVar = AnonymousLocal(envPtr);
valVar = AnonymousLocal(envPtr);
infoPtr = (ForeachInfo *)Tcl_Alloc(offsetof(ForeachInfo, varLists) + sizeof(ForeachVarList *));
infoPtr->numLists = 1;
| | | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
*/
keyVar = AnonymousLocal(envPtr);
valVar = AnonymousLocal(envPtr);
infoPtr = (ForeachInfo *)Tcl_Alloc(offsetof(ForeachInfo, varLists) + sizeof(ForeachVarList *));
infoPtr->numLists = 1;
infoPtr->varLists[0] = (ForeachVarList *)Tcl_Alloc(offsetof(ForeachVarList, varIndexes) + 2 * sizeof(Tcl_Size));
infoPtr->varLists[0]->numVars = 2;
infoPtr->varLists[0]->varIndexes[0] = keyVar;
infoPtr->varLists[0]->varIndexes[1] = valVar;
infoIndex = TclCreateAuxData(infoPtr, &newForeachInfoType, envPtr);
/*
* Start issuing instructions to write to the array.
|
| ︙ | ︙ | |||
631 632 633 634 635 636 637 |
* Otherwise, compile instructions to substitute the body text before
* starting the catch, then BEGIN_CATCH, and then EVAL_STK to evaluate the
* substituted body.
* Care has to be taken to make sure that substitution happens outside the
* catch range so that errors in the substitution are not caught.
* [Bug 219184]
* The reason for duplicating the script is that EVAL_STK would otherwise
| | | 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
* Otherwise, compile instructions to substitute the body text before
* starting the catch, then BEGIN_CATCH, and then EVAL_STK to evaluate the
* substituted body.
* Care has to be taken to make sure that substitution happens outside the
* catch range so that errors in the substitution are not caught.
* [Bug 219184]
* The reason for duplicating the script is that EVAL_STK would otherwise
* begin by underflowing the stack below the mark set by BEGIN_CATCH4.
*/
range = TclCreateExceptRange(CATCH_EXCEPTION_RANGE, envPtr);
if (cmdTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) {
TclEmitInstInt4( INST_BEGIN_CATCH4, range, envPtr);
ExceptionRangeStarts(envPtr, range);
BODY(cmdTokenPtr, 1);
|
| ︙ | ︙ | |||
887 888 889 890 891 892 893 |
break;
}
(void) Tcl_ListObjAppendElement(NULL, listObj, objPtr);
}
if (listObj != NULL) {
Tcl_Obj **objs;
const char *bytes;
| | | 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
break;
}
(void) Tcl_ListObjAppendElement(NULL, listObj, objPtr);
}
if (listObj != NULL) {
Tcl_Obj **objs;
const char *bytes;
Tcl_Size len, slen;
TclListObjGetElementsM(NULL, listObj, &len, &objs);
objPtr = Tcl_ConcatObj(len, objs);
Tcl_DecrRefCount(listObj);
bytes = Tcl_GetStringFromObj(objPtr, &slen);
PushLiteral(envPtr, bytes, slen);
Tcl_DecrRefCount(objPtr);
|
| ︙ | ︙ | |||
979 980 981 982 983 984 985 | } /* *---------------------------------------------------------------------- * * TclCompileDict*Cmd -- * | | | 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | } /* *---------------------------------------------------------------------- * * TclCompileDict*Cmd -- * * Functions called to compile "dict" subcommands. * * Results: * All return TCL_OK for a successful compile, and TCL_ERROR to defer * evaluation to runtime. * * Side effects: * Instructions are added to envPtr to execute the "dict" subcommand at |
| ︙ | ︙ | |||
1074 1075 1076 1077 1078 1079 1080 |
/*
* Parse the increment amount, if present.
*/
if (parsePtr->numWords == 4) {
const char *word;
| | | 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
/*
* Parse the increment amount, if present.
*/
if (parsePtr->numWords == 4) {
const char *word;
Tcl_Size numBytes;
int code;
Tcl_Token *incrTokenPtr;
Tcl_Obj *intObj;
incrTokenPtr = TokenAfter(keyTokenPtr);
if (incrTokenPtr->type != TCL_TOKEN_SIMPLE_WORD) {
return TclCompileBasic2Or3ArgCmd(interp, parsePtr,cmdPtr, envPtr);
|
| ︙ | ︙ | |||
1289 1290 1291 1292 1293 1294 1295 |
{
DefineLineInformation; /* TIP #280 */
int worker; /* Temp var for building the value in. */
Tcl_Token *tokenPtr;
Tcl_Obj *keyObj, *valueObj, *dictObj;
const char *bytes;
int i;
| | | 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 |
{
DefineLineInformation; /* TIP #280 */
int worker; /* Temp var for building the value in. */
Tcl_Token *tokenPtr;
Tcl_Obj *keyObj, *valueObj, *dictObj;
const char *bytes;
int i;
Tcl_Size len;
if ((parsePtr->numWords & 1) == 0) {
return TCL_ERROR;
}
/*
* See if we can build the value at compile time...
|
| ︙ | ︙ | |||
1524 1525 1526 1527 1528 1529 1530 |
* construct a new dictionary with the loop
* body result. */
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *varsTokenPtr, *dictTokenPtr, *bodyTokenPtr;
int keyVarIndex, valueVarIndex, nameChars, loopRange, catchRange;
int infoIndex, jumpDisplacement, bodyTargetOffset, emptyTargetOffset;
| | | 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 |
* construct a new dictionary with the loop
* body result. */
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *varsTokenPtr, *dictTokenPtr, *bodyTokenPtr;
int keyVarIndex, valueVarIndex, nameChars, loopRange, catchRange;
int infoIndex, jumpDisplacement, bodyTargetOffset, emptyTargetOffset;
Tcl_Size numVars;
int endTargetOffset;
int collectVar = -1; /* Index of temp var holding the result
* dict. */
const char **argv;
Tcl_DString buffer;
/*
|
| ︙ | ︙ | |||
1686 1687 1688 1689 1690 1691 1692 |
jumpDisplacement = bodyTargetOffset - CurrentOffset(envPtr);
TclEmitInstInt4( INST_JUMP_FALSE4, jumpDisplacement, envPtr);
endTargetOffset = CurrentOffset(envPtr);
TclEmitInstInt1( INST_JUMP1, 0, envPtr);
/*
* Error handler "finally" clause, which force-terminates the iteration
| | | 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 |
jumpDisplacement = bodyTargetOffset - CurrentOffset(envPtr);
TclEmitInstInt4( INST_JUMP_FALSE4, jumpDisplacement, envPtr);
endTargetOffset = CurrentOffset(envPtr);
TclEmitInstInt1( INST_JUMP1, 0, envPtr);
/*
* Error handler "finally" clause, which force-terminates the iteration
* and re-throws the error.
*/
TclAdjustStackDepth(-1, envPtr);
ExceptionRangeTarget(envPtr, catchRange, catchOffset);
TclEmitOpcode( INST_PUSH_RETURN_OPTIONS, envPtr);
TclEmitOpcode( INST_PUSH_RESULT, envPtr);
TclEmitOpcode( INST_END_CATCH, envPtr);
|
| ︙ | ︙ | |||
1858 1859 1860 1861 1862 1863 1864 |
*/
TclEmitForwardJump(envPtr, TCL_UNCONDITIONAL_JUMP, &jumpFixup);
/*
* Termination code for non-ok returns: stash the result and return
* options in the stack, bring up the key list, finish the update code,
| | | 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 |
*/
TclEmitForwardJump(envPtr, TCL_UNCONDITIONAL_JUMP, &jumpFixup);
/*
* Termination code for non-ok returns: stash the result and return
* options in the stack, bring up the key list, finish the update code,
* and finally return with the caught return data
*/
ExceptionRangeTarget(envPtr, range, catchOffset);
TclEmitOpcode( INST_PUSH_RESULT, envPtr);
TclEmitOpcode( INST_PUSH_RETURN_OPTIONS, envPtr);
TclEmitOpcode( INST_END_CATCH, envPtr);
TclEmitInstInt4( INST_REVERSE, 3, envPtr);
|
| ︙ | ︙ | |||
1904 1905 1906 1907 1908 1909 1910 |
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr;
int i, dictVarIndex;
/*
* There must be at least two argument after the command. And we impose an
| | | 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 |
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr;
int i, dictVarIndex;
/*
* There must be at least two argument after the command. And we impose an
* (arbitrary) safe limit; anyone exceeding it should stop worrying about
* speed quite so much. ;-)
*/
/* TODO: Consider support for compiling expanded args. */
if ((int)parsePtr->numWords<4 || (int)parsePtr->numWords>100) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2292 2293 2294 2295 2296 2297 2298 |
PrintDictUpdateInfo(
void *clientData,
Tcl_Obj *appendObj,
TCL_UNUSED(ByteCode *),
TCL_UNUSED(size_t))
{
DictUpdateInfo *duiPtr = (DictUpdateInfo *)clientData;
| | | | | | 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 |
PrintDictUpdateInfo(
void *clientData,
Tcl_Obj *appendObj,
TCL_UNUSED(ByteCode *),
TCL_UNUSED(size_t))
{
DictUpdateInfo *duiPtr = (DictUpdateInfo *)clientData;
Tcl_Size i;
for (i=0 ; i<duiPtr->length ; i++) {
if (i) {
Tcl_AppendToObj(appendObj, ", ", -1);
}
Tcl_AppendPrintfToObj(appendObj, "%%v%" TCL_Z_MODIFIER "u", duiPtr->varIndices[i]);
}
}
static void
DisassembleDictUpdateInfo(
void *clientData,
Tcl_Obj *dictObj,
TCL_UNUSED(ByteCode *),
TCL_UNUSED(size_t))
{
DictUpdateInfo *duiPtr = (DictUpdateInfo *)clientData;
Tcl_Size i;
Tcl_Obj *variables;
TclNewObj(variables);
for (i=0 ; i<duiPtr->length ; i++) {
Tcl_ListObjAppendElement(NULL, variables,
Tcl_NewWideIntObj(duiPtr->varIndices[i]));
}
Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("variables", -1),
variables);
}
/*
*----------------------------------------------------------------------
*
* TclCompileErrorCmd --
|
| ︙ | ︙ | |||
2686 2687 2688 2689 2690 2691 2692 |
ForeachInfo *infoPtr=NULL; /* Points to the structure describing this
* foreach command. Stored in a AuxData
* record in the ByteCode. */
Tcl_Token *tokenPtr, *bodyTokenPtr;
int jumpBackOffset, infoIndex, range;
int numWords, numLists, i, code = TCL_OK;
| | | 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 |
ForeachInfo *infoPtr=NULL; /* Points to the structure describing this
* foreach command. Stored in a AuxData
* record in the ByteCode. */
Tcl_Token *tokenPtr, *bodyTokenPtr;
int jumpBackOffset, infoIndex, range;
int numWords, numLists, i, code = TCL_OK;
Tcl_Size j;
Tcl_Obj *varListObj = NULL;
/*
* If the foreach command isn't in a procedure, don't compile it inline:
* the payoff is too small.
*/
|
| ︙ | ︙ | |||
2738 2739 2740 2741 2742 2743 2744 |
*/
TclNewObj(varListObj);
for (i = 0, tokenPtr = parsePtr->tokenPtr;
i < numWords-1;
i++, tokenPtr = TokenAfter(tokenPtr)) {
ForeachVarList *varListPtr;
| | | | | 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 |
*/
TclNewObj(varListObj);
for (i = 0, tokenPtr = parsePtr->tokenPtr;
i < numWords-1;
i++, tokenPtr = TokenAfter(tokenPtr)) {
ForeachVarList *varListPtr;
Tcl_Size numVars;
if (i%2 != 1) {
continue;
}
/*
* If the variable list is empty, we can enter an infinite loop when
* the interpreted version would not. Take care to ensure this does
* not happen. [Bug 1671138]
*/
if (!TclWordKnownAtCompileTime(tokenPtr, varListObj) ||
TCL_OK != TclListObjLengthM(NULL, varListObj, &numVars) ||
numVars == 0) {
code = TCL_ERROR;
goto done;
}
varListPtr = (ForeachVarList *)Tcl_Alloc(offsetof(ForeachVarList, varIndexes)
+ numVars * sizeof(varListPtr->varIndexes[0]));
varListPtr->numVars = numVars;
infoPtr->varLists[i/2] = varListPtr;
infoPtr->numLists++;
for (j = 0; j < numVars; j++) {
Tcl_Obj *varNameObj;
const char *bytes;
int varIndex;
Tcl_Size length;
Tcl_ListObjIndex(NULL, varListObj, j, &varNameObj);
bytes = Tcl_GetStringFromObj(varNameObj, &length);
varIndex = LocalScalar(bytes, length, envPtr);
if (varIndex < 0) {
code = TCL_ERROR;
|
| ︙ | ︙ | |||
2976 2977 2978 2979 2980 2981 2982 |
void *clientData,
Tcl_Obj *appendObj,
TCL_UNUSED(ByteCode *),
TCL_UNUSED(size_t))
{
ForeachInfo *infoPtr = (ForeachInfo *)clientData;
ForeachVarList *varsPtr;
| | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 |
void *clientData,
Tcl_Obj *appendObj,
TCL_UNUSED(ByteCode *),
TCL_UNUSED(size_t))
{
ForeachInfo *infoPtr = (ForeachInfo *)clientData;
ForeachVarList *varsPtr;
Tcl_Size i, j;
Tcl_AppendToObj(appendObj, "data=[", -1);
for (i=0 ; i<infoPtr->numLists ; i++) {
if (i) {
Tcl_AppendToObj(appendObj, ", ", -1);
}
Tcl_AppendPrintfToObj(appendObj, "%%v%" TCL_Z_MODIFIER "u",
(infoPtr->firstValueTemp + i));
}
Tcl_AppendPrintfToObj(appendObj, "], loop=%%v%" TCL_Z_MODIFIER "u",
infoPtr->loopCtTemp);
for (i=0 ; i<infoPtr->numLists ; i++) {
if (i) {
Tcl_AppendToObj(appendObj, ",", -1);
}
Tcl_AppendPrintfToObj(appendObj, "\n\t\t it%%v%" TCL_Z_MODIFIER "u\t[",
(infoPtr->firstValueTemp + i));
varsPtr = infoPtr->varLists[i];
for (j=0 ; j<varsPtr->numVars ; j++) {
if (j) {
Tcl_AppendToObj(appendObj, ", ", -1);
}
Tcl_AppendPrintfToObj(appendObj, "%%v%" TCL_Z_MODIFIER "u",
varsPtr->varIndexes[j]);
}
Tcl_AppendToObj(appendObj, "]", -1);
}
}
static void
PrintNewForeachInfo(
void *clientData,
Tcl_Obj *appendObj,
TCL_UNUSED(ByteCode *),
TCL_UNUSED(size_t))
{
ForeachInfo *infoPtr = (ForeachInfo *)clientData;
ForeachVarList *varsPtr;
Tcl_Size i, j;
Tcl_AppendPrintfToObj(appendObj, "jumpOffset=%+" TCL_Z_MODIFIER "d, vars=",
infoPtr->loopCtTemp);
for (i=0 ; i<infoPtr->numLists ; i++) {
if (i) {
Tcl_AppendToObj(appendObj, ",", -1);
}
Tcl_AppendToObj(appendObj, "[", -1);
varsPtr = infoPtr->varLists[i];
for (j=0 ; j<varsPtr->numVars ; j++) {
if (j) {
Tcl_AppendToObj(appendObj, ",", -1);
}
Tcl_AppendPrintfToObj(appendObj, "%%v%" TCL_Z_MODIFIER "u",
varsPtr->varIndexes[j]);
}
Tcl_AppendToObj(appendObj, "]", -1);
}
}
static void
DisassembleForeachInfo(
void *clientData,
Tcl_Obj *dictObj,
TCL_UNUSED(ByteCode *),
TCL_UNUSED(size_t))
{
ForeachInfo *infoPtr = (ForeachInfo *)clientData;
ForeachVarList *varsPtr;
Tcl_Size i, j;
Tcl_Obj *objPtr, *innerPtr;
/*
* Data stores.
*/
TclNewObj(objPtr);
for (i=0 ; i<infoPtr->numLists ; i++) {
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj(infoPtr->firstValueTemp + i));
}
Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("data", -1), objPtr);
/*
* Loop counter.
*/
Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("loop", -1),
Tcl_NewWideIntObj(infoPtr->loopCtTemp));
/*
* Assignment targets.
*/
TclNewObj(objPtr);
for (i=0 ; i<infoPtr->numLists ; i++) {
TclNewObj(innerPtr);
varsPtr = infoPtr->varLists[i];
for (j=0 ; j<varsPtr->numVars ; j++) {
Tcl_ListObjAppendElement(NULL, innerPtr,
Tcl_NewWideIntObj(varsPtr->varIndexes[j]));
}
Tcl_ListObjAppendElement(NULL, objPtr, innerPtr);
}
Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("assign", -1), objPtr);
}
static void
DisassembleNewForeachInfo(
void *clientData,
Tcl_Obj *dictObj,
TCL_UNUSED(ByteCode *),
TCL_UNUSED(size_t))
{
ForeachInfo *infoPtr = (ForeachInfo *)clientData;
ForeachVarList *varsPtr;
Tcl_Size i, j;
Tcl_Obj *objPtr, *innerPtr;
/*
* Jump offset.
*/
Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("jumpOffset", -1),
Tcl_NewWideIntObj(infoPtr->loopCtTemp));
/*
* Assignment targets.
*/
TclNewObj(objPtr);
for (i=0 ; i<infoPtr->numLists ; i++) {
TclNewObj(innerPtr);
varsPtr = infoPtr->varLists[i];
for (j=0 ; j<varsPtr->numVars ; j++) {
Tcl_ListObjAppendElement(NULL, innerPtr,
Tcl_NewWideIntObj(varsPtr->varIndexes[j]));
}
Tcl_ListObjAppendElement(NULL, objPtr, innerPtr);
}
Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("assign", -1), objPtr);
}
/*
*----------------------------------------------------------------------
*
* TclCompileFormatCmd --
*
|
| ︙ | ︙ | |||
3152 3153 3154 3155 3156 3157 3158 |
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
Tcl_Obj **objv, *formatObj, *tmpObj;
const char *bytes, *start;
int i, j;
| | | 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 |
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
Tcl_Obj **objv, *formatObj, *tmpObj;
const char *bytes, *start;
int i, j;
Tcl_Size len;
/*
* Don't handle any guaranteed-error cases.
*/
if ((int)parsePtr->numWords < 2) {
return TCL_ERROR;
|
| ︙ | ︙ |
Changes to generic/tclCompCmdsGR.c.
| ︙ | ︙ | |||
412 413 414 415 416 417 418 |
*/
for (j = jumpEndFixupArray.next; j > 0; j--) {
jumpIndex = (j - 1); /* i.e. process the closest jump first. */
if (TclFixupForwardJumpToHere(envPtr,
jumpEndFixupArray.fixup + jumpIndex, 127)) {
/*
| | | 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
*/
for (j = jumpEndFixupArray.next; j > 0; j--) {
jumpIndex = (j - 1); /* i.e. process the closest jump first. */
if (TclFixupForwardJumpToHere(envPtr,
jumpEndFixupArray.fixup + jumpIndex, 127)) {
/*
* Adjust the immediately preceding "ifFalse" jump. We moved it's
* target (just after this jump) down three bytes.
*/
unsigned char *ifFalsePc = envPtr->codeStart
+ jumpFalseFixupArray.fixup[jumpIndex].codeOffset;
unsigned char opCode = *ifFalsePc;
|
| ︙ | ︙ | |||
615 616 617 618 619 620 621 |
if (bytes[0] != ':' || bytes[1] != ':' || !TclMatchIsTrivial(bytes)) {
goto notCompilable;
}
Tcl_DecrRefCount(objPtr);
/*
| | | | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
if (bytes[0] != ':' || bytes[1] != ':' || !TclMatchIsTrivial(bytes)) {
goto notCompilable;
}
Tcl_DecrRefCount(objPtr);
/*
* Confirmed as a literal that will not frighten the horses. Compile.
* The result must be made into a list.
*/
/* TODO: Just push the known value */
CompileWord(envPtr, tokenPtr, interp, 1);
TclEmitOpcode( INST_RESOLVE_COMMAND, envPtr);
TclEmitOpcode( INST_DUP, envPtr);
TclEmitOpcode( INST_STR_LEN, envPtr);
|
| ︙ | ︙ | |||
2109 2110 2111 2112 2113 2114 2115 |
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr, *stringTokenPtr;
Tcl_Obj *patternObj = NULL, *replacementObj = NULL;
Tcl_DString pattern;
const char *bytes;
int exact, quantified, result = TCL_ERROR;
| | | 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 |
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr, *stringTokenPtr;
Tcl_Obj *patternObj = NULL, *replacementObj = NULL;
Tcl_DString pattern;
const char *bytes;
int exact, quantified, result = TCL_ERROR;
Tcl_Size len;
if ((int)parsePtr->numWords < 5 || (int)parsePtr->numWords > 6) {
return TCL_ERROR;
}
/*
* Parse the "-all", which must be the first argument (other options not
|
| ︙ | ︙ | |||
2264 2265 2266 2267 2268 2269 2270 |
{
DefineLineInformation; /* TIP #280 */
/*
* General syntax: [return ?-option value ...? ?result?]
* An even number of words means an explicit result argument is present.
*/
int level, code, objc, status = TCL_OK;
| | | 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 |
{
DefineLineInformation; /* TIP #280 */
/*
* General syntax: [return ?-option value ...? ?result?]
* An even number of words means an explicit result argument is present.
*/
int level, code, objc, status = TCL_OK;
Tcl_Size size;
int numWords = parsePtr->numWords;
int explicitResult = (0 == (numWords % 2));
int numOptionWords = numWords - 1 - explicitResult;
Tcl_Obj *returnOpts, **objv;
Tcl_Token *wordTokenPtr = TokenAfter(parsePtr->tokenPtr);
/*
|
| ︙ | ︙ | |||
2474 2475 2476 2477 2478 2479 2480 |
void
TclCompileSyntaxError(
Tcl_Interp *interp,
CompileEnv *envPtr)
{
Tcl_Obj *msg = Tcl_GetObjResult(interp);
| | | 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 |
void
TclCompileSyntaxError(
Tcl_Interp *interp,
CompileEnv *envPtr)
{
Tcl_Obj *msg = Tcl_GetObjResult(interp);
Tcl_Size numBytes;
const char *bytes = Tcl_GetStringFromObj(msg, &numBytes);
TclErrorStackResetIf(interp, bytes, numBytes);
TclEmitPush(TclRegisterLiteral(envPtr, bytes, numBytes, 0), envPtr);
CompileReturnInternal(envPtr, INST_SYNTAX, TCL_ERROR, 0,
TclNoErrorStack(interp, Tcl_GetReturnOptions(interp, TCL_ERROR)));
Tcl_ResetResult(interp);
|
| ︙ | ︙ | |||
2701 2702 2703 2704 2705 2706 2707 |
TCL_UNUSED(Tcl_Interp *),
Tcl_Token *varTokenPtr, /* Token representing the variable name */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
Tcl_Obj *tailPtr;
const char *tailName, *p;
int n = varTokenPtr->numComponents;
| | | 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 |
TCL_UNUSED(Tcl_Interp *),
Tcl_Token *varTokenPtr, /* Token representing the variable name */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
Tcl_Obj *tailPtr;
const char *tailName, *p;
int n = varTokenPtr->numComponents;
Tcl_Size len;
Tcl_Token *lastTokenPtr;
int full, localIndex;
/*
* Determine if the tail is (a) known at compile time, and (b) not an
* array element. Should any of these fail, return an error so that the
* non-compiled command will be called at runtime.
|
| ︙ | ︙ |
Changes to generic/tclCompCmdsSZ.c.
| ︙ | ︙ | |||
248 249 250 251 252 253 254 |
Tcl_DecrRefCount(obj);
} else {
folded = obj;
}
} else {
Tcl_DecrRefCount(obj);
if (folded) {
| | | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
Tcl_DecrRefCount(obj);
} else {
folded = obj;
}
} else {
Tcl_DecrRefCount(obj);
if (folded) {
Tcl_Size len;
const char *bytes = Tcl_GetStringFromObj(folded, &len);
PushLiteral(envPtr, bytes, len);
Tcl_DecrRefCount(folded);
folded = NULL;
numArgs ++;
}
CompileWord(envPtr, wordTokenPtr, interp, i);
numArgs ++;
if (numArgs >= 254) { /* 254 to take care of the possible +1 of "folded" above */
TclEmitInstInt1(INST_STR_CONCAT1, numArgs, envPtr);
numArgs = 1; /* concat pushes 1 obj, the result */
}
}
wordTokenPtr = TokenAfter(wordTokenPtr);
}
if (folded) {
Tcl_Size len;
const char *bytes = Tcl_GetStringFromObj(folded, &len);
PushLiteral(envPtr, bytes, len);
Tcl_DecrRefCount(folded);
folded = NULL;
numArgs ++;
}
|
| ︙ | ︙ | |||
893 894 895 896 897 898 899 | * something with backslashes). Just push the actual character (not * byte) length. */ char buf[TCL_INTEGER_SPACE]; size_t len = Tcl_GetCharLength(objPtr); | | | 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 |
* something with backslashes). Just push the actual character (not
* byte) length.
*/
char buf[TCL_INTEGER_SPACE];
size_t len = Tcl_GetCharLength(objPtr);
len = snprintf(buf, sizeof(buf), "%" TCL_Z_MODIFIER "u", len);
PushLiteral(envPtr, buf, len);
} else {
SetLineInformation(1);
CompileTokens(envPtr, tokenPtr, interp);
TclEmitOpcode(INST_STR_LEN, envPtr);
}
TclDecrRefCount(objPtr);
|
| ︙ | ︙ | |||
917 918 919 920 921 922 923 |
* compiled. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *mapTokenPtr, *stringTokenPtr;
Tcl_Obj *mapObj, **objv;
const char *bytes;
| | | 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 |
* compiled. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *mapTokenPtr, *stringTokenPtr;
Tcl_Obj *mapObj, **objv;
const char *bytes;
Tcl_Size len, slen;
/*
* We only handle the case:
*
* string map {foo bar} $thing
*
* That is, a literal two-element list (doesn't need to be brace-quoted,
|
| ︙ | ︙ | |||
1513 1514 1515 1516 1517 1518 1519 |
return TCL_OK;
}
void
TclSubstCompile(
Tcl_Interp *interp,
const char *bytes,
| | | | | 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 |
return TCL_OK;
}
void
TclSubstCompile(
Tcl_Interp *interp,
const char *bytes,
Tcl_Size numBytes,
int flags,
Tcl_Size line,
CompileEnv *envPtr)
{
Tcl_Token *endTokenPtr, *tokenPtr;
int breakOffset = 0, count = 0;
Tcl_Size bline = line;
Tcl_Parse parse;
Tcl_InterpState state = NULL;
TclSubstParse(interp, bytes, numBytes, flags, &parse, &state);
if (state != NULL) {
Tcl_ResetResult(interp);
}
|
| ︙ | ︙ | |||
1545 1546 1547 1548 1549 1550 1551 |
if (tokenPtr->type != TCL_TOKEN_TEXT && tokenPtr->type != TCL_TOKEN_BS) {
PUSH("");
count++;
}
for (endTokenPtr = tokenPtr + parse.numTokens;
tokenPtr < endTokenPtr; tokenPtr = TokenAfter(tokenPtr)) {
| | | 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 |
if (tokenPtr->type != TCL_TOKEN_TEXT && tokenPtr->type != TCL_TOKEN_BS) {
PUSH("");
count++;
}
for (endTokenPtr = tokenPtr + parse.numTokens;
tokenPtr < endTokenPtr; tokenPtr = TokenAfter(tokenPtr)) {
Tcl_Size length;
int literal, catchRange, breakJump;
char buf[4] = "";
JumpFixup startFixup, okFixup, returnFixup, breakFixup;
JumpFixup continueFixup, otherFixup, endFixup;
switch (tokenPtr->type) {
case TCL_TOKEN_TEXT:
|
| ︙ | ︙ | |||
1577 1578 1579 1580 1581 1582 1583 |
* TCL_OK or TCL_ERROR from the substituted variable read; if so,
* there is no need to generate elaborate exception-management
* code. Note that the first component of TCL_TOKEN_VARIABLE is
* always TCL_TOKEN_TEXT...
*/
if (tokenPtr->numComponents > 1) {
| | | 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 |
* TCL_OK or TCL_ERROR from the substituted variable read; if so,
* there is no need to generate elaborate exception-management
* code. Note that the first component of TCL_TOKEN_VARIABLE is
* always TCL_TOKEN_TEXT...
*/
if (tokenPtr->numComponents > 1) {
Tcl_Size i;
int foundCommand = 0;
for (i=2 ; i<=tokenPtr->numComponents ; i++) {
if (tokenPtr[i].type == TCL_TOKEN_COMMAND) {
foundCommand = 1;
break;
}
|
| ︙ | ︙ | |||
1941 1942 1943 1944 1945 1946 1947 |
* copies of the string from the input token for the generated tokens (it
* causes a crash during exception handling). When multiple tokens are
* available at this point, this is pretty easy.
*/
if (numWords == 1) {
const char *bytes;
| | | | 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 |
* copies of the string from the input token for the generated tokens (it
* causes a crash during exception handling). When multiple tokens are
* available at this point, this is pretty easy.
*/
if (numWords == 1) {
const char *bytes;
Tcl_Size maxLen, numBytes;
Tcl_Size bline; /* TIP #280: line of the pattern/action list,
* and start of list for when tracking the
* location. This list comes immediately after
* the value we switch on. */
if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2378 2379 2380 2381 2382 2383 2384 |
Tcl_DString buffer;
Tcl_HashEntry *hPtr;
/*
* Compile the switch by using a jump table, which is basically a
* hashtable that maps from literal values to match against to the offset
* (relative to the INST_JUMP_TABLE instruction) to jump to. The jump
| | | 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 |
Tcl_DString buffer;
Tcl_HashEntry *hPtr;
/*
* Compile the switch by using a jump table, which is basically a
* hashtable that maps from literal values to match against to the offset
* (relative to the INST_JUMP_TABLE instruction) to jump to. The jump
* table itself is independent of any invocation of the bytecode, and as
* such is stored in an auxData block.
*
* Start by allocating the jump table itself, plus some workspace.
*/
jtPtr = (JumptableInfo *)Tcl_Alloc(sizeof(JumptableInfo));
Tcl_InitHashTable(&jtPtr->hashTable, TCL_STRING_KEYS);
|
| ︙ | ︙ | |||
2600 2601 2602 2603 2604 2605 2606 |
hPtr = Tcl_FirstHashEntry(&jtPtr->hashTable, &search);
for (; hPtr ; hPtr = Tcl_NextHashEntry(&search)) {
keyPtr = (const char *)Tcl_GetHashKey(&jtPtr->hashTable, hPtr);
offset = PTR2INT(Tcl_GetHashValue(hPtr));
if (i++) {
| | | | 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 |
hPtr = Tcl_FirstHashEntry(&jtPtr->hashTable, &search);
for (; hPtr ; hPtr = Tcl_NextHashEntry(&search)) {
keyPtr = (const char *)Tcl_GetHashKey(&jtPtr->hashTable, hPtr);
offset = PTR2INT(Tcl_GetHashValue(hPtr));
if (i++) {
Tcl_AppendToObj(appendObj, ", ", -1);
if (i%4==0) {
Tcl_AppendToObj(appendObj, "\n\t\t", -1);
}
}
Tcl_AppendPrintfToObj(appendObj, "\"%s\"->pc %" TCL_Z_MODIFIER "u",
keyPtr, pcOffset + offset);
}
}
|
| ︙ | ︙ | |||
2629 2630 2631 2632 2633 2634 2635 |
size_t offset;
TclNewObj(mapping);
hPtr = Tcl_FirstHashEntry(&jtPtr->hashTable, &search);
for (; hPtr ; hPtr = Tcl_NextHashEntry(&search)) {
keyPtr = (const char *)Tcl_GetHashKey(&jtPtr->hashTable, hPtr);
offset = PTR2INT(Tcl_GetHashValue(hPtr));
| | | | 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 |
size_t offset;
TclNewObj(mapping);
hPtr = Tcl_FirstHashEntry(&jtPtr->hashTable, &search);
for (; hPtr ; hPtr = Tcl_NextHashEntry(&search)) {
keyPtr = (const char *)Tcl_GetHashKey(&jtPtr->hashTable, hPtr);
offset = PTR2INT(Tcl_GetHashValue(hPtr));
Tcl_DictObjPut(NULL, mapping, Tcl_NewStringObj(keyPtr, -1),
Tcl_NewWideIntObj(offset));
}
Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("mapping", -1), mapping);
}
/*
*----------------------------------------------------------------------
*
* TclCompileTailcallCmd --
*
|
| ︙ | ︙ | |||
2712 2713 2714 2715 2716 2717 2718 |
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation; /* TIP #280 */
int numWords = parsePtr->numWords;
Tcl_Token *codeToken, *msgToken;
Tcl_Obj *objPtr;
int codeKnown, codeIsList, codeIsValid;
| | | 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 |
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation; /* TIP #280 */
int numWords = parsePtr->numWords;
Tcl_Token *codeToken, *msgToken;
Tcl_Obj *objPtr;
int codeKnown, codeIsList, codeIsValid;
Tcl_Size len;
if (numWords != 3) {
return TCL_ERROR;
}
codeToken = TokenAfter(parsePtr->tokenPtr);
msgToken = TokenAfter(codeToken);
|
| ︙ | ︙ | |||
2853 2854 2855 2856 2857 2858 2859 |
memset(matchClauses, 0, sizeof(Tcl_Obj *) * numHandlers);
matchCodes = (int *)TclStackAlloc(interp, sizeof(int) * numHandlers);
resultVarIndices = (int *)TclStackAlloc(interp, sizeof(int) * numHandlers);
optionVarIndices = (int *)TclStackAlloc(interp, sizeof(int) * numHandlers);
for (i=0 ; i<numHandlers ; i++) {
Tcl_Obj *tmpObj, **objv;
| | | 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 |
memset(matchClauses, 0, sizeof(Tcl_Obj *) * numHandlers);
matchCodes = (int *)TclStackAlloc(interp, sizeof(int) * numHandlers);
resultVarIndices = (int *)TclStackAlloc(interp, sizeof(int) * numHandlers);
optionVarIndices = (int *)TclStackAlloc(interp, sizeof(int) * numHandlers);
for (i=0 ; i<numHandlers ; i++) {
Tcl_Obj *tmpObj, **objv;
Tcl_Size objc;
if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) {
goto failedToCompile;
}
if (tokenPtr[1].size == 4
&& !strncmp(tokenPtr[1].start, "trap", 4)) {
/*
|
| ︙ | ︙ | |||
2918 2919 2920 2921 2922 2923 2924 |
}
if (TclListObjGetElementsM(NULL, tmpObj, &objc, &objv) != TCL_OK
|| (objc > 2)) {
TclDecrRefCount(tmpObj);
goto failedToCompile;
}
if (objc > 0) {
| | | | 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 |
}
if (TclListObjGetElementsM(NULL, tmpObj, &objc, &objv) != TCL_OK
|| (objc > 2)) {
TclDecrRefCount(tmpObj);
goto failedToCompile;
}
if (objc > 0) {
Tcl_Size len;
const char *varname = Tcl_GetStringFromObj(objv[0], &len);
resultVarIndices[i] = LocalScalar(varname, len, envPtr);
if (resultVarIndices[i] < 0) {
TclDecrRefCount(tmpObj);
goto failedToCompile;
}
} else {
resultVarIndices[i] = -1;
}
if (objc == 2) {
Tcl_Size len;
const char *varname = Tcl_GetStringFromObj(objv[1], &len);
optionVarIndices[i] = LocalScalar(varname, len, envPtr);
if (optionVarIndices[i] < 0) {
TclDecrRefCount(tmpObj);
goto failedToCompile;
}
|
| ︙ | ︙ | |||
3052 3053 3054 3055 3056 3057 3058 |
int *resultVars,
int *optionVars,
Tcl_Token **handlerTokens)
{
DefineLineInformation; /* TIP #280 */
int range, resultVar, optionsVar;
int i, j, forwardsNeedFixing = 0, trapZero = 0, afterBody = 0;
| | | 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 |
int *resultVars,
int *optionVars,
Tcl_Token **handlerTokens)
{
DefineLineInformation; /* TIP #280 */
int range, resultVar, optionsVar;
int i, j, forwardsNeedFixing = 0, trapZero = 0, afterBody = 0;
Tcl_Size slen, len;
int *addrsToFix, *forwardsToFix, notCodeJumpSource, notECJumpSource;
int *noError;
char buf[TCL_INTEGER_SPACE];
resultVar = AnonymousLocal(envPtr);
optionsVar = AnonymousLocal(envPtr);
if (resultVar < 0 || optionsVar < 0) {
|
| ︙ | ︙ | |||
3120 3121 3122 3123 3124 3125 3126 |
addrsToFix = (int *)TclStackAlloc(interp, sizeof(int)*numHandlers);
forwardsToFix = (int *)TclStackAlloc(interp, sizeof(int)*numHandlers);
noError = (int *)TclStackAlloc(interp, sizeof(int)*numHandlers);
for (i=0 ; i<numHandlers ; i++) {
noError[i] = -1;
| | | 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 |
addrsToFix = (int *)TclStackAlloc(interp, sizeof(int)*numHandlers);
forwardsToFix = (int *)TclStackAlloc(interp, sizeof(int)*numHandlers);
noError = (int *)TclStackAlloc(interp, sizeof(int)*numHandlers);
for (i=0 ; i<numHandlers ; i++) {
noError[i] = -1;
snprintf(buf, sizeof(buf), "%d", matchCodes[i]);
OP( DUP);
PushLiteral(envPtr, buf, strlen(buf));
OP( EQ);
JUMP4( JUMP_FALSE, notCodeJumpSource);
if (matchClauses[i]) {
const char *p;
TclListObjLengthM(NULL, matchClauses[i], &len);
|
| ︙ | ︙ | |||
3266 3267 3268 3269 3270 3271 3272 |
Tcl_Token *finallyToken) /* Not NULL */
{
DefineLineInformation; /* TIP #280 */
int range, resultVar, optionsVar, i, j, forwardsNeedFixing = 0;
int trapZero = 0, afterBody = 0, finalOK, finalError, noFinalError;
int *addrsToFix, *forwardsToFix, notCodeJumpSource, notECJumpSource;
char buf[TCL_INTEGER_SPACE];
| | | 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 |
Tcl_Token *finallyToken) /* Not NULL */
{
DefineLineInformation; /* TIP #280 */
int range, resultVar, optionsVar, i, j, forwardsNeedFixing = 0;
int trapZero = 0, afterBody = 0, finalOK, finalError, noFinalError;
int *addrsToFix, *forwardsToFix, notCodeJumpSource, notECJumpSource;
char buf[TCL_INTEGER_SPACE];
Tcl_Size slen, len;
resultVar = AnonymousLocal(envPtr);
optionsVar = AnonymousLocal(envPtr);
if (resultVar < 0 || optionsVar < 0) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
3333 3334 3335 3336 3337 3338 3339 |
addrsToFix = (int *)TclStackAlloc(interp, sizeof(int)*numHandlers);
forwardsToFix = (int *)TclStackAlloc(interp, sizeof(int)*numHandlers);
for (i=0 ; i<numHandlers ; i++) {
int noTrapError, trapError;
const char *p;
| | | 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 |
addrsToFix = (int *)TclStackAlloc(interp, sizeof(int)*numHandlers);
forwardsToFix = (int *)TclStackAlloc(interp, sizeof(int)*numHandlers);
for (i=0 ; i<numHandlers ; i++) {
int noTrapError, trapError;
const char *p;
snprintf(buf, sizeof(buf), "%d", matchCodes[i]);
OP( DUP);
PushLiteral(envPtr, buf, strlen(buf));
OP( EQ);
JUMP4( JUMP_FALSE, notCodeJumpSource);
if (matchClauses[i]) {
TclListObjLengthM(NULL, matchClauses[i], &len);
|
| ︙ | ︙ | |||
3676 3677 3678 3679 3680 3681 3682 |
continue;
}
}
return TCL_ERROR;
}
if (varCount == 0) {
const char *bytes;
| | | 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 |
continue;
}
}
return TCL_ERROR;
}
if (varCount == 0) {
const char *bytes;
Tcl_Size len;
bytes = Tcl_GetStringFromObj(leadingWord, &len);
if (i == 1 && len == 11 && !strncmp("-nocomplain", bytes, 11)) {
flags = 0;
haveFlags++;
} else if (i == (2 - flags) && len == 2 && !strncmp("--", bytes, 2)) {
haveFlags++;
|
| ︙ | ︙ | |||
4069 4070 4071 4072 4073 4074 4075 |
Tcl_Parse *parsePtr,
const char *identity,
int instruction,
CompileEnv *envPtr)
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
| | | | | 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 |
Tcl_Parse *parsePtr,
const char *identity,
int instruction,
CompileEnv *envPtr)
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
Tcl_Size words;
/* TODO: Consider support for compiling expanded args. */
for (words=1 ; words<parsePtr->numWords ; words++) {
tokenPtr = TokenAfter(tokenPtr);
CompileWord(envPtr, tokenPtr, interp, words);
}
if (parsePtr->numWords <= 2) {
PushLiteral(envPtr, identity, -1);
words++;
}
if (words > 3) {
/*
* Reverse order of arguments to get precise agreement with [expr] in
* calculations, including roundoff errors.
*/
OP4( REVERSE, words-1);
}
while (--words > 1) {
TclEmitOpcode(instruction, envPtr);
}
|
| ︙ | ︙ | |||
4172 4173 4174 4175 4176 4177 4178 |
/*
* No local variable space!
*/
return TCL_ERROR;
} else {
int tmpIndex = AnonymousLocal(envPtr);
| | | 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 |
/*
* No local variable space!
*/
return TCL_ERROR;
} else {
int tmpIndex = AnonymousLocal(envPtr);
Tcl_Size words;
tokenPtr = TokenAfter(parsePtr->tokenPtr);
CompileWord(envPtr, tokenPtr, interp, 1);
tokenPtr = TokenAfter(tokenPtr);
CompileWord(envPtr, tokenPtr, interp, 2);
STORE(tmpIndex);
TclEmitOpcode(instruction, envPtr);
|
| ︙ | ︙ | |||
4308 4309 4310 4311 4312 4313 4314 |
Tcl_Interp *interp,
Tcl_Parse *parsePtr,
TCL_UNUSED(Command *),
CompileEnv *envPtr)
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
| | | 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 |
Tcl_Interp *interp,
Tcl_Parse *parsePtr,
TCL_UNUSED(Command *),
CompileEnv *envPtr)
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
Tcl_Size words;
/*
* This one has its own implementation because the ** operator is the only
* one with right associativity.
*/
for (words=1 ; words<parsePtr->numWords ; words++) {
|
| ︙ | ︙ | |||
4509 4510 4511 4512 4513 4514 4515 |
Tcl_Interp *interp,
Tcl_Parse *parsePtr,
TCL_UNUSED(Command *),
CompileEnv *envPtr)
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
| | | 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 |
Tcl_Interp *interp,
Tcl_Parse *parsePtr,
TCL_UNUSED(Command *),
CompileEnv *envPtr)
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
Tcl_Size words;
/* TODO: Consider support for compiling expanded args. */
if (parsePtr->numWords == 1) {
/*
* Fallback to direct eval to report syntax error.
*/
|
| ︙ | ︙ | |||
4534 4535 4536 4537 4538 4539 4540 |
if (words == 3) {
TclEmitOpcode(INST_SUB, envPtr);
return TCL_OK;
}
/*
* Reverse order of arguments to get precise agreement with [expr] in
| | | | 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 |
if (words == 3) {
TclEmitOpcode(INST_SUB, envPtr);
return TCL_OK;
}
/*
* Reverse order of arguments to get precise agreement with [expr] in
* calculations, including roundoff errors.
*/
TclEmitInstInt4(INST_REVERSE, words-1, envPtr);
while (--words > 1) {
TclEmitInstInt4(INST_REVERSE, 2, envPtr);
TclEmitOpcode(INST_SUB, envPtr);
}
return TCL_OK;
}
int
TclCompileDivOpCmd(
Tcl_Interp *interp,
Tcl_Parse *parsePtr,
TCL_UNUSED(Command *),
CompileEnv *envPtr)
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
Tcl_Size words;
/* TODO: Consider support for compiling expanded args. */
if (parsePtr->numWords == 1) {
/*
* Fallback to direct eval to report syntax error.
*/
|
| ︙ | ︙ | |||
4578 4579 4580 4581 4582 4583 4584 |
if (words <= 3) {
TclEmitOpcode(INST_DIV, envPtr);
return TCL_OK;
}
/*
* Reverse order of arguments to get precise agreement with [expr] in
| | | 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 |
if (words <= 3) {
TclEmitOpcode(INST_DIV, envPtr);
return TCL_OK;
}
/*
* Reverse order of arguments to get precise agreement with [expr] in
* calculations, including roundoff errors.
*/
TclEmitInstInt4(INST_REVERSE, words-1, envPtr);
while (--words > 1) {
TclEmitInstInt4(INST_REVERSE, 2, envPtr);
TclEmitOpcode(INST_DIV, envPtr);
}
|
| ︙ | ︙ |
Changes to generic/tclCompExpr.c.
| ︙ | ︙ | |||
92 93 94 95 96 97 98 | * * While the parse tree is being constructed, the same memory space is used to * hold the p.prev field which chains together a stack of incomplete trees * awaiting their right operands. * * The lexeme field is filled in with the lexeme of the operator that is * returned by the ParseLexeme() routine. Only lexemes for unary and binary | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | * * While the parse tree is being constructed, the same memory space is used to * hold the p.prev field which chains together a stack of incomplete trees * awaiting their right operands. * * The lexeme field is filled in with the lexeme of the operator that is * returned by the ParseLexeme() routine. Only lexemes for unary and binary * operators get stored in an OpNode. Other lexmes get different treatment. * * The precedence field provides a place to store the precedence of the * operator, so it need not be looked up again and again. * * The mark field is use to control the traversal of the tree, so that it can * be done non-recursively. The mark values are: */ |
| ︙ | ︙ | |||
153 154 155 156 157 158 159 | /* Uncategorized lexemes */ #define PLUS 1 /* Ambiguous. Resolves to UNARY_PLUS or * BINARY_PLUS according to context. */ #define MINUS 2 /* Ambiguous. Resolves to UNARY_MINUS or * BINARY_MINUS according to context. */ | | | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | /* Uncategorized lexemes */ #define PLUS 1 /* Ambiguous. Resolves to UNARY_PLUS or * BINARY_PLUS according to context. */ #define MINUS 2 /* Ambiguous. Resolves to UNARY_MINUS or * BINARY_MINUS according to context. */ #define BAREWORD 3 /* Ambiguous. Resolves to BOOLEAN or to * FUNCTION or a parse error according to * context and value. */ #define INCOMPLETE 4 /* A parse error. Used only when the single * "=" is encountered. */ #define INVALID 5 /* A parse error. Used when any punctuation * appears that's not a supported operator. */ #define COMMENT 6 /* Comment. Lasts to end of line or end of |
| ︙ | ︙ | |||
507 508 509 510 511 512 513 | * Declarations for local functions to this file: */ static void CompileExprTree(Tcl_Interp *interp, OpNode *nodes, int index, Tcl_Obj *const **litObjvPtr, Tcl_Obj *const *funcObjv, Tcl_Token *tokenPtr, CompileEnv *envPtr, int optimize); | | | | | 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | * Declarations for local functions to this file: */ static void CompileExprTree(Tcl_Interp *interp, OpNode *nodes, int index, Tcl_Obj *const **litObjvPtr, Tcl_Obj *const *funcObjv, Tcl_Token *tokenPtr, CompileEnv *envPtr, int optimize); static void ConvertTreeToTokens(const char *start, Tcl_Size numBytes, OpNode *nodes, Tcl_Token *tokenPtr, Tcl_Parse *parsePtr); static int ExecConstantExprTree(Tcl_Interp *interp, OpNode *nodes, int index, Tcl_Obj * const **litObjvPtr); static int ParseExpr(Tcl_Interp *interp, const char *start, Tcl_Size numBytes, OpNode **opTreePtr, Tcl_Obj *litList, Tcl_Obj *funcList, Tcl_Parse *parsePtr, int parseOnly); static Tcl_Size ParseLexeme(const char *start, Tcl_Size numBytes, unsigned char *lexemePtr, Tcl_Obj **literalPtr); /* *---------------------------------------------------------------------- * * ParseExpr -- * |
| ︙ | ︙ | |||
554 555 556 557 558 559 560 |
*----------------------------------------------------------------------
*/
static int
ParseExpr(
Tcl_Interp *interp, /* Used for error reporting. */
const char *start, /* Start of source string to parse. */
| | | | | 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
*----------------------------------------------------------------------
*/
static int
ParseExpr(
Tcl_Interp *interp, /* Used for error reporting. */
const char *start, /* Start of source string to parse. */
Tcl_Size numBytes, /* Number of bytes in string. */
OpNode **opTreePtr, /* Points to space where a pointer to the
* allocated OpNode tree should go. */
Tcl_Obj *litList, /* List to append literals to. */
Tcl_Obj *funcList, /* List to append function names to. */
Tcl_Parse *parsePtr, /* Structure to fill with tokens representing
* those operands that require run time
* substitutions. */
int parseOnly) /* A boolean indicating whether the caller's
* aim is just a parse, or whether it will go
* on to compile the expression. Different
* optimizations are appropriate for the two
* scenarios. */
{
OpNode *nodes = NULL; /* Pointer to the OpNode storage array where
* we build the parse tree. */
unsigned int nodesAvailable = 64; /* Initial size of the storage array. This
* value establishes a minimum tree memory
* cost of only about 1 kilobyte, and is large
* enough for most expressions to parse with
* no need for array growth and
* reallocation. */
unsigned int nodesUsed = 0; /* Number of OpNodes filled. */
Tcl_Size scanned = 0; /* Capture number of byte scanned by parsing
* routines. */
int lastParsed; /* Stores info about what the lexeme parsed
* the previous pass through the parsing loop
* was. If it was an operator, lastParsed is
* the index of the OpNode for that operator.
* If it was not an operator, lastParsed holds
* an OperandTypes value encoding what we need
|
| ︙ | ︙ | |||
621 622 623 624 625 626 627 |
* message where the error location is
* reported, this "mark" substring is inserted
* into the string being parsed to aid in
* pinpointing the location of the syntax
* error in the expression. */
int insertMark = 0; /* A boolean controlling whether the "mark"
* should be inserted. */
| | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
* message where the error location is
* reported, this "mark" substring is inserted
* into the string being parsed to aid in
* pinpointing the location of the syntax
* error in the expression. */
int insertMark = 0; /* A boolean controlling whether the "mark"
* should be inserted. */
const int limit = 25; /* Portions of the error message are
* constructed out of substrings of the
* original expression. In order to keep the
* error message readable, we impose this
* limit on the substring size we extract. */
TclParseInit(interp, start, numBytes, parsePtr);
|
| ︙ | ︙ | |||
773 774 775 776 777 778 779 |
Tcl_ListObjAppendElement(NULL, funcList, literal);
scanned = scanned2 - 1;
break;
}
Tcl_DecrRefCount(literal);
msg = Tcl_ObjPrintf("invalid bareword \"%.*s%s\"",
| | | | | | | | | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
Tcl_ListObjAppendElement(NULL, funcList, literal);
scanned = scanned2 - 1;
break;
}
Tcl_DecrRefCount(literal);
msg = Tcl_ObjPrintf("invalid bareword \"%.*s%s\"",
(int)((scanned < limit) ? scanned : limit - 3), start,
(scanned < limit) ? "" : "...");
post = Tcl_ObjPrintf(
"should be \"$%.*s%s\" or \"{%.*s%s}\"",
(int) ((scanned < limit) ? scanned : limit - 3),
start, (scanned < limit) ? "" : "...",
(int) ((scanned < limit) ? scanned : limit - 3),
start, (scanned < limit) ? "" : "...");
Tcl_AppendPrintfToObj(post, " or \"%.*s%s(...)\" or ...",
(int) ((scanned < limit) ? scanned : limit - 3),
start, (scanned < limit) ? "" : "...");
errCode = "BAREWORD";
if (start[0] == '0') {
const char *stop;
TclParseNumber(NULL, NULL, NULL, start, scanned,
&stop, TCL_PARSE_NO_WHITESPACE);
if (isdigit(UCHAR(*stop)) || (stop == start + 1)) {
switch (start[1]) {
case 'b':
Tcl_AppendToObj(post,
" (invalid binary number?)", -1);
parsePtr->errorType = TCL_PARSE_BAD_NUMBER;
errCode = "BADNUMBER";
subErrCode = "BINARY";
break;
case 'o':
Tcl_AppendToObj(post,
" (invalid octal number?)", -1);
parsePtr->errorType = TCL_PARSE_BAD_NUMBER;
errCode = "BADNUMBER";
subErrCode = "OCTAL";
break;
default:
if (isdigit(UCHAR(start[1]))) {
Tcl_AppendToObj(post,
" (invalid octal number?)", -1);
parsePtr->errorType = TCL_PARSE_BAD_NUMBER;
errCode = "BADNUMBER";
subErrCode = "OCTAL";
}
break;
}
}
|
| ︙ | ︙ | |||
1458 1459 1460 1461 1462 1463 1464 |
(start + scanned + limit > parsePtr->end) ? "" : "...");
/*
* Next, append any postscript message.
*/
if (post != NULL) {
| | | 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 |
(start + scanned + limit > parsePtr->end) ? "" : "...");
/*
* Next, append any postscript message.
*/
if (post != NULL) {
Tcl_AppendToObj(msg, ";\n", -1);
Tcl_AppendObjToObj(msg, post);
Tcl_DecrRefCount(post);
}
Tcl_SetObjResult(interp, msg);
/*
* Finally, place context information in the errorInfo.
|
| ︙ | ︙ | |||
1508 1509 1510 1511 1512 1513 1514 |
*
*----------------------------------------------------------------------
*/
static void
ConvertTreeToTokens(
const char *start,
| | | 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 |
*
*----------------------------------------------------------------------
*/
static void
ConvertTreeToTokens(
const char *start,
Tcl_Size numBytes,
OpNode *nodes,
Tcl_Token *tokenPtr,
Tcl_Parse *parsePtr)
{
int subExprTokenIdx = 0;
OpNode *nodePtr = nodes;
int next = nodePtr->right;
|
| ︙ | ︙ | |||
1856 1857 1858 1859 1860 1861 1862 |
*----------------------------------------------------------------------
*/
int
Tcl_ParseExpr(
Tcl_Interp *interp, /* Used for error reporting. */
const char *start, /* Start of source string to parse. */
| | | | 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 |
*----------------------------------------------------------------------
*/
int
Tcl_ParseExpr(
Tcl_Interp *interp, /* Used for error reporting. */
const char *start, /* Start of source string to parse. */
Tcl_Size numBytes, /* Number of bytes in string. If -1, the
* string consists of all bytes up to the
* first null character. */
Tcl_Parse *parsePtr) /* Structure to fill with information about
* the parsed expression; any previous
* information in the structure is ignored. */
{
int code;
OpNode *opTree = NULL; /* Will point to the tree of operators. */
Tcl_Obj *litList; /* List to hold the literals. */
Tcl_Obj *funcList; /* List to hold the functon names. */
Tcl_Parse *exprParsePtr = (Tcl_Parse *)TclStackAlloc(interp, sizeof(Tcl_Parse));
/* Holds the Tcl_Tokens of substitutions. */
TclNewObj(litList);
TclNewObj(funcList);
if (numBytes < 0) {
numBytes = (start ? strlen(start) : 0);
}
code = ParseExpr(interp, start, numBytes, &opTree, litList, funcList,
exprParsePtr, 1 /* parseOnly */);
Tcl_DecrRefCount(funcList);
Tcl_DecrRefCount(litList);
|
| ︙ | ︙ | |||
1908 1909 1910 1911 1912 1913 1914 | * Parse a single lexeme from the start of a string, scanning no more * than numBytes bytes. * * Results: * Returns the number of bytes scanned to produce the lexeme. * * Side effects: | | | | | 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 |
* Parse a single lexeme from the start of a string, scanning no more
* than numBytes bytes.
*
* Results:
* Returns the number of bytes scanned to produce the lexeme.
*
* Side effects:
* Code identifying lexeme parsed is written to *lexemePtr.
*
*----------------------------------------------------------------------
*/
static Tcl_Size
ParseLexeme(
const char *start, /* Start of lexeme to parse. */
Tcl_Size numBytes, /* Number of bytes in string. */
unsigned char *lexemePtr, /* Write code of parsed lexeme to this
* storage. */
Tcl_Obj **literalPtr) /* Write corresponding literal value to this
storage, if non-NULL. */
{
const char *end;
int ch;
|
| ︙ | ︙ | |||
1941 1942 1943 1944 1945 1946 1947 |
return 1;
}
switch (byte) {
case '#': {
/*
* Scan forward over the comment contents.
*/
| | | 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 |
return 1;
}
switch (byte) {
case '#': {
/*
* Scan forward over the comment contents.
*/
Tcl_Size size;
for (size = 0; byte != '\n' && byte != 0 && size < numBytes; size++) {
byte = UCHAR(start[size]);
}
*lexemePtr = COMMENT;
return size - (byte == '\n');
}
|
| ︙ | ︙ | |||
2143 2144 2145 2146 2147 2148 2149 |
/*
* We reject leading underscores in bareword. No sensible reason why.
* Might be inspired by reserved identifier rules in C, which of course
* have no direct relevance here.
*/
if (!TclIsBareword(*start) || *start == '_') {
| | | 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 |
/*
* We reject leading underscores in bareword. No sensible reason why.
* Might be inspired by reserved identifier rules in C, which of course
* have no direct relevance here.
*/
if (!TclIsBareword(*start) || *start == '_') {
Tcl_Size scanned;
if (Tcl_UtfCharComplete(start, numBytes)) {
scanned = TclUtfToUCS4(start, &ch);
} else {
char utfBytes[8];
memcpy(utfBytes, start, numBytes);
utfBytes[numBytes] = '\0';
|
| ︙ | ︙ | |||
2193 2194 2195 2196 2197 2198 2199 |
*----------------------------------------------------------------------
*/
void
TclCompileExpr(
Tcl_Interp *interp, /* Used for error reporting. */
const char *script, /* The source script to compile. */
| | | | 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 |
*----------------------------------------------------------------------
*/
void
TclCompileExpr(
Tcl_Interp *interp, /* Used for error reporting. */
const char *script, /* The source script to compile. */
Tcl_Size numBytes, /* Number of bytes in script. */
CompileEnv *envPtr, /* Holds resulting instructions. */
int optimize) /* 0 for one-off expressions. */
{
OpNode *opTree = NULL; /* Will point to the tree of operators */
Tcl_Obj *litList; /* List to hold the literals */
Tcl_Obj *funcList; /* List to hold the functon names*/
Tcl_Parse *parsePtr = (Tcl_Parse *)TclStackAlloc(interp, sizeof(Tcl_Parse));
/* Holds the Tcl_Tokens of substitutions */
int code;
TclNewObj(litList);
TclNewObj(funcList);
code = ParseExpr(interp, script, numBytes, &opTree, litList,
funcList, parsePtr, 0 /* parseOnly */);
if (code == TCL_OK) {
/*
* Valid parse; compile the tree.
*/
Tcl_Size objc;
Tcl_Obj *const *litObjv;
Tcl_Obj **funcObjv;
/* TIP #280 : Track Lines within the expression */
TclAdvanceLines(&envPtr->line, script,
script + TclParseAllWhiteSpace(script, numBytes));
|
| ︙ | ︙ | |||
2344 2345 2346 2347 2348 2349 2350 |
} else if (nodePtr->mark == MARK_RIGHT) {
next = nodePtr->right;
switch (nodePtr->lexeme) {
case FUNCTION: {
Tcl_DString cmdName;
const char *p;
| | | 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 |
} else if (nodePtr->mark == MARK_RIGHT) {
next = nodePtr->right;
switch (nodePtr->lexeme) {
case FUNCTION: {
Tcl_DString cmdName;
const char *p;
Tcl_Size length;
Tcl_DStringInit(&cmdName);
TclDStringAppendLiteral(&cmdName, "tcl::mathfunc::");
p = Tcl_GetStringFromObj(*funcObjv, &length);
funcObjv++;
Tcl_DStringAppend(&cmdName, p, length);
TclEmitPush(TclRegisterLiteral(envPtr,
|
| ︙ | ︙ | |||
2503 2504 2505 2506 2507 2508 2509 |
numWords = 1; /* No arguments, so just the command */
break;
case OT_LITERAL: {
Tcl_Obj *const *litObjv = *litObjvPtr;
Tcl_Obj *literal = *litObjv;
if (optimize) {
| | | 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 |
numWords = 1; /* No arguments, so just the command */
break;
case OT_LITERAL: {
Tcl_Obj *const *litObjv = *litObjvPtr;
Tcl_Obj *literal = *litObjv;
if (optimize) {
Tcl_Size length;
const char *bytes = Tcl_GetStringFromObj(literal, &length);
int idx = TclRegisterLiteral(envPtr, bytes, length, 0);
Tcl_Obj *objPtr = TclFetchLiteral(envPtr, idx);
if ((objPtr->typePtr == NULL) && (literal->typePtr != NULL)) {
/*
* Would like to do this:
|
| ︙ | ︙ | |||
2562 2563 2564 2565 2566 2567 2568 |
/*
* Don't generate a string rep, but if we have one
* already, then use it to share via the literal table.
*/
if (TclHasStringRep(objPtr)) {
Tcl_Obj *tableValue;
| | | 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 |
/*
* Don't generate a string rep, but if we have one
* already, then use it to share via the literal table.
*/
if (TclHasStringRep(objPtr)) {
Tcl_Obj *tableValue;
Tcl_Size numBytes;
const char *bytes
= Tcl_GetStringFromObj(objPtr, &numBytes);
idx = TclRegisterLiteral(envPtr, bytes, numBytes, 0);
tableValue = TclFetchLiteral(envPtr, idx);
if ((tableValue->typePtr == NULL) &&
(objPtr->typePtr != NULL)) {
|
| ︙ | ︙ |
Changes to generic/tclCompile.c.
| ︙ | ︙ | |||
676 677 678 679 680 681 682 | static ByteCode * CompileSubstObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int flags); static void DupByteCodeInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static unsigned char * EncodeCmdLocMap(CompileEnv *envPtr, ByteCode *codePtr, unsigned char *startPtr); static void EnterCmdExtentData(CompileEnv *envPtr, | | | | | | 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | static ByteCode * CompileSubstObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int flags); static void DupByteCodeInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static unsigned char * EncodeCmdLocMap(CompileEnv *envPtr, ByteCode *codePtr, unsigned char *startPtr); static void EnterCmdExtentData(CompileEnv *envPtr, Tcl_Size cmdNumber, Tcl_Size numSrcBytes, Tcl_Size numCodeBytes); static void EnterCmdStartData(CompileEnv *envPtr, Tcl_Size cmdNumber, Tcl_Size srcOffset, Tcl_Size codeOffset); static void FreeByteCodeInternalRep(Tcl_Obj *objPtr); static void FreeSubstCodeInternalRep(Tcl_Obj *objPtr); static int GetCmdLocEncodingSize(CompileEnv *envPtr); static int IsCompactibleCompileEnv(CompileEnv *envPtr); static void PreventCycle(Tcl_Obj *objPtr, CompileEnv *envPtr); #ifdef TCL_COMPILE_STATS static void RecordByteCodeStats(ByteCode *codePtr); #endif /* TCL_COMPILE_STATS */ static int SetByteCodeFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static void StartExpanding(CompileEnv *envPtr); /* * TIP #280: Helper for building the per-word line information of all compiled * commands. */ static void EnterCmdWordData(ExtCmdLoc *eclPtr, Tcl_Size srcOffset, Tcl_Token *tokenPtr, const char *cmd, Tcl_Size numWords, Tcl_Size line, int *clNext, int **lines, CompileEnv *envPtr); static void ReleaseCmdWordData(ExtCmdLoc *eclPtr); /* * tclByteCodeType provides the standard type management procedures for the * bytecode type. */ |
| ︙ | ︙ | |||
772 773 774 775 776 777 778 |
Tcl_Obj *objPtr, /* The object to make a ByteCode object. */
CompileHookProc *hookProc, /* Procedure to invoke after compilation. */
void *clientData) /* Hook procedure private data. */
{
Interp *iPtr = (Interp *) interp;
CompileEnv compEnv; /* Compilation environment structure allocated
* in frame. */
| | | 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 |
Tcl_Obj *objPtr, /* The object to make a ByteCode object. */
CompileHookProc *hookProc, /* Procedure to invoke after compilation. */
void *clientData) /* Hook procedure private data. */
{
Interp *iPtr = (Interp *) interp;
CompileEnv compEnv; /* Compilation environment structure allocated
* in frame. */
Tcl_Size length;
int result = TCL_OK;
const char *stringPtr;
Proc *procPtr = iPtr->compiledProcPtr;
ContLineLoc *clLocPtr;
#ifdef TCL_COMPILE_DEBUG
if (!traceInitialized) {
|
| ︙ | ︙ | |||
1324 1325 1326 1327 1328 1329 1330 |
iPtr->varFramePtr->localCachePtr)) {
Tcl_StoreInternalRep(objPtr, &substCodeType, NULL);
codePtr = NULL;
}
}
if (codePtr == NULL) {
CompileEnv compEnv;
| | | 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 |
iPtr->varFramePtr->localCachePtr)) {
Tcl_StoreInternalRep(objPtr, &substCodeType, NULL);
codePtr = NULL;
}
}
if (codePtr == NULL) {
CompileEnv compEnv;
Tcl_Size numBytes;
const char *bytes = Tcl_GetStringFromObj(objPtr, &numBytes);
/* TODO: Check for more TIP 280 */
TclInitCompileEnv(interp, &compEnv, bytes, numBytes, NULL, 0);
TclSubstCompile(interp, bytes, numBytes, flags, 1, &compEnv);
|
| ︙ | ︙ | |||
1387 1388 1389 1390 1391 1392 1393 |
TclReleaseByteCode(codePtr);
}
static void
ReleaseCmdWordData(
ExtCmdLoc *eclPtr)
{
| | | 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 |
TclReleaseByteCode(codePtr);
}
static void
ReleaseCmdWordData(
ExtCmdLoc *eclPtr)
{
Tcl_Size i;
if (eclPtr->type == TCL_LOCATION_SOURCE) {
Tcl_DecrRefCount(eclPtr->path);
}
for (i=0 ; i<eclPtr->nuloc ; i++) {
Tcl_Free(eclPtr->loc[i].line);
}
|
| ︙ | ︙ | |||
1549 1550 1551 1552 1553 1554 1555 | * ctx.data.tebc.codePtr is used instead. */ TclGetSrcInfoForPc(ctxPtr); pc = 1; } | | | 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 |
* ctx.data.tebc.codePtr is used instead.
*/
TclGetSrcInfoForPc(ctxPtr);
pc = 1;
}
if ((ctxPtr->nline <= word) || (ctxPtr->line[word] < 0)) {
/*
* Word is not a literal, relative counting.
*/
envPtr->line = 1;
envPtr->extCmdMapPtr->type =
(envPtr->procPtr ? TCL_LOCATION_PROC : TCL_LOCATION_BC);
|
| ︙ | ︙ | |||
1643 1644 1645 1646 1647 1648 1649 |
}
if (envPtr->iPtr) {
/*
* We never converted to Bytecode, so free the things we would
* have transferred to it.
*/
| | | 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 |
}
if (envPtr->iPtr) {
/*
* We never converted to Bytecode, so free the things we would
* have transferred to it.
*/
Tcl_Size i;
LiteralEntry *entryPtr = envPtr->literalArrayPtr;
AuxData *auxDataPtr = envPtr->auxDataArrayPtr;
for (i = 0; i < envPtr->literalArrayNext; i++) {
TclReleaseLiteral((Tcl_Interp *)envPtr->iPtr, entryPtr->objPtr);
entryPtr++;
}
|
| ︙ | ︙ | |||
1808 1809 1810 1811 1812 1813 1814 |
Tcl_Interp *interp,
Tcl_Obj *cmdObj,
CompileEnv *envPtr)
{
const char *bytes;
Command *cmdPtr;
int cmdLitIdx, extraLiteralFlags = LITERAL_CMD_NAME;
| | | 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 |
Tcl_Interp *interp,
Tcl_Obj *cmdObj,
CompileEnv *envPtr)
{
const char *bytes;
Command *cmdPtr;
int cmdLitIdx, extraLiteralFlags = LITERAL_CMD_NAME;
Tcl_Size length;
cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, cmdObj);
if ((cmdPtr != NULL) && (cmdPtr->flags & CMD_VIA_RESOLVER)) {
extraLiteralFlags |= LITERAL_UNSHARED;
}
bytes = Tcl_GetStringFromObj(cmdObj, &length);
|
| ︙ | ︙ | |||
2033 2034 2035 2036 2037 2038 2039 |
int *clNext = envPtr->clNext;
int cmdIdx = envPtr->numCommands;
int startCodeOffset = envPtr->codeNext - envPtr->codeStart;
int depth = TclGetStackDepth(envPtr);
assert ((int)parsePtr->numWords > 0);
| | | 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 |
int *clNext = envPtr->clNext;
int cmdIdx = envPtr->numCommands;
int startCodeOffset = envPtr->codeNext - envPtr->codeStart;
int depth = TclGetStackDepth(envPtr);
assert ((int)parsePtr->numWords > 0);
/* Precompile */
TclNewObj(cmdObj);
envPtr->numCommands++;
EnterCmdStartData(envPtr, cmdIdx,
parsePtr->commandStart - envPtr->source, startCodeOffset);
/*
|
| ︙ | ︙ | |||
2132 2133 2134 2135 2136 2137 2138 |
void
TclCompileScript(
Tcl_Interp *interp, /* Used for error and status reporting. Also
* serves as context for finding and compiling
* commands. May not be NULL. */
const char *script, /* The source script to compile. */
| | | 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 |
void
TclCompileScript(
Tcl_Interp *interp, /* Used for error and status reporting. Also
* serves as context for finding and compiling
* commands. May not be NULL. */
const char *script, /* The source script to compile. */
Tcl_Size numBytes, /* Number of bytes in script. If -1, the
* script consists of all bytes up to the
* first null character. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
int lastCmdIdx = -1; /* Index into envPtr->cmdMapPtr of the last
* command this routine compiles into bytecode.
* Initial value of -1 indicates this routine
|
| ︙ | ︙ | |||
2157 2158 2159 2160 2161 2162 2163 |
* nested calls of TclCompileScript, considering interp recursionlimit.
* Use factor 5/4 (1.25) to avoid being too mistaken when recognizing the
* limit during "mixed" evaluation and compilation process (nested
* eval+compile) and is good enough for default recursionlimit (1000).
*/
if (iPtr->numLevels / 5 > iPtr->maxNestingDepth / 4) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 |
* nested calls of TclCompileScript, considering interp recursionlimit.
* Use factor 5/4 (1.25) to avoid being too mistaken when recognizing the
* limit during "mixed" evaluation and compilation process (nested
* eval+compile) and is good enough for default recursionlimit (1000).
*/
if (iPtr->numLevels / 5 > iPtr->maxNestingDepth / 4) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"too many nested compilations (infinite loop?)", -1));
Tcl_SetErrorCode(interp, "TCL", "LIMIT", "STACK", NULL);
TclCompileSyntaxError(interp, envPtr);
return;
}
/* Each iteration compiles one command from the script. */
if (numBytes > 0) {
/*
* Don't use system stack (size of Tcl_Parse is ca. 400 bytes), so
* many nested compilations (body enclosed in body) can cause abnormal
* program termination with a stack overflow exception, bug [fec0c17d39].
*/
Tcl_Parse *parsePtr = (Tcl_Parse *)Tcl_Alloc(sizeof(Tcl_Parse));
|
| ︙ | ︙ | |||
2319 2320 2321 2322 2323 2324 2325 |
void
TclCompileVarSubst(
Tcl_Interp *interp,
Tcl_Token *tokenPtr,
CompileEnv *envPtr)
{
const char *p, *name = tokenPtr[1].start;
| | | | 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 |
void
TclCompileVarSubst(
Tcl_Interp *interp,
Tcl_Token *tokenPtr,
CompileEnv *envPtr)
{
const char *p, *name = tokenPtr[1].start;
Tcl_Size i, nameBytes = tokenPtr[1].size;
Tcl_Size localVar;
int localVarName = 1;
/*
* Determine how the variable name should be handled: if it contains any
* namespace qualifiers it is not a local variable (localVarName=-1); if
* it looks like an array element and the token has a single component, it
* should not be created here [Bug 569438] (localVarName=0); otherwise,
|
| ︙ | ︙ | |||
2348 2349 2350 2351 2352 2353 2354 |
}
/*
* Either push the variable's name, or find its index in the array
* of local variables in a procedure frame.
*/
| | | | | | 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 |
}
/*
* Either push the variable's name, or find its index in the array
* of local variables in a procedure frame.
*/
localVar = -1;
if (localVarName != -1) {
localVar = TclFindCompiledLocal(name, nameBytes, localVarName, envPtr);
}
if (localVar < 0) {
PushLiteral(envPtr, name, nameBytes);
}
/*
* Emit instructions to load the variable.
*/
TclAdvanceLines(&envPtr->line, tokenPtr[1].start,
tokenPtr[1].start + tokenPtr[1].size);
if (tokenPtr->numComponents == 1) {
if (localVar < 0) {
TclEmitOpcode(INST_LOAD_STK, envPtr);
} else if (localVar <= 255) {
TclEmitInstInt1(INST_LOAD_SCALAR1, localVar, envPtr);
} else {
TclEmitInstInt4(INST_LOAD_SCALAR4, localVar, envPtr);
}
} else {
TclCompileTokens(interp, tokenPtr+2, tokenPtr->numComponents-1, envPtr);
if (localVar < 0) {
TclEmitOpcode(INST_LOAD_ARRAY_STK, envPtr);
} else if (localVar <= 255) {
TclEmitInstInt1(INST_LOAD_ARRAY1, localVar, envPtr);
} else {
TclEmitInstInt4(INST_LOAD_ARRAY4, localVar, envPtr);
}
}
|
| ︙ | ︙ | |||
2405 2406 2407 2408 2409 2410 2411 |
#define NUM_STATIC_POS 20
int isLiteral, maxNumCL, numCL;
int *clPosition = NULL;
int depth = TclGetStackDepth(envPtr);
int count = count1;
/*
| | | | 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 |
#define NUM_STATIC_POS 20
int isLiteral, maxNumCL, numCL;
int *clPosition = NULL;
int depth = TclGetStackDepth(envPtr);
int count = count1;
/*
* If this is actually a literal, handle continuation lines by
* preallocating a small table to store the locations of any continuation
* lines found in this literal. The table is extended if needed.
*
* Note: In contrast with the analagous code in 'TclSubstTokens()' the
* 'adjust' variable seems unneeded here. The code which merges
* continuation line information of multiple words which concat'd at
* runtime also seems unneeded. Either that or I have not managed to find a
* test case for these two possibilities yet. It might be a difference
* between compile- versus run-time processing.
|
| ︙ | ︙ | |||
2772 2773 2774 2775 2776 2777 2778 |
*/
static void
PreventCycle(
Tcl_Obj *objPtr,
CompileEnv *envPtr)
{
| | | | 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 |
*/
static void
PreventCycle(
Tcl_Obj *objPtr,
CompileEnv *envPtr)
{
Tcl_Size i;
for (i = 0; i < envPtr->literalArrayNext; i++) {
if (objPtr == TclFetchLiteral(envPtr, i)) {
/*
* Prevent circular reference where the bytecode internalrep of
* a value contains a literal which is that same value.
* If this is allowed to happen, refcount decrements may not
* reach zero, and memory may leak. Bugs 467523, 3357771
*
* NOTE: [Bugs 3392070, 3389764] We make a copy based completely
* on the string value, and do not call Tcl_DuplicateObj() so we
* can be sure we do not have any lingering cycles hiding in
* the internalrep.
*/
Tcl_Size numBytes;
const char *bytes = Tcl_GetStringFromObj(objPtr, &numBytes);
Tcl_Obj *copyPtr = Tcl_NewStringObj(bytes, numBytes);
Tcl_IncrRefCount(copyPtr);
TclReleaseLiteral((Tcl_Interp *)envPtr->iPtr, objPtr);
envPtr->literalArrayPtr[i].objPtr = copyPtr;
|
| ︙ | ︙ | |||
2989 2990 2991 2992 2993 2994 2995 | * Side effects: * Creates and registers a new local variable if create is 1 and the * variable is unknown, or if the name is NULL. * *---------------------------------------------------------------------- */ | | | | | | | | 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 |
* Side effects:
* Creates and registers a new local variable if create is 1 and the
* variable is unknown, or if the name is NULL.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclFindCompiledLocal(
const char *name, /* Points to first character of the name of a
* scalar or array variable. If NULL, a
* temporary var should be created. */
Tcl_Size nameBytes, /* Number of bytes in the name. */
int create, /* If 1, allocate a local frame entry for the
* variable if it is new. */
CompileEnv *envPtr) /* Points to the current compile environment*/
{
CompiledLocal *localPtr;
Tcl_Size localVar = TCL_INDEX_NONE;
Tcl_Size i;
Proc *procPtr;
/*
* If not creating a temporary, does a local variable of the specified
* name already exist?
*/
procPtr = envPtr->procPtr;
if (procPtr == NULL) {
/*
* Compiling a non-body script: give it read access to the LVT in the
* current localCache
*/
LocalCache *cachePtr = envPtr->iPtr->varFramePtr->localCachePtr;
const char *localName;
Tcl_Obj **varNamePtr;
Tcl_Size len;
if (!cachePtr || !name) {
return TCL_INDEX_NONE;
}
varNamePtr = &cachePtr->varName0;
for (i=0; i < cachePtr->numVars; varNamePtr++, i++) {
if (*varNamePtr) {
localName = Tcl_GetStringFromObj(*varNamePtr, &len);
if ((len == nameBytes) && !strncmp(name, localName, len)) {
return i;
}
}
}
return TCL_INDEX_NONE;
}
if (name != NULL) {
Tcl_Size localCt = procPtr->numCompiledLocals;
localPtr = procPtr->firstLocalPtr;
for (i = 0; i < localCt; i++) {
if (!TclIsVarTemporary(localPtr)) {
char *localName = localPtr->name;
if ((nameBytes == localPtr->nameLength) &&
|
| ︙ | ︙ | |||
3167 3168 3169 3170 3171 3172 3173 |
*/
static void
EnterCmdStartData(
CompileEnv *envPtr, /* Points to the compilation environment
* structure in which to enter command
* location information. */
| | | | | | 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 |
*/
static void
EnterCmdStartData(
CompileEnv *envPtr, /* Points to the compilation environment
* structure in which to enter command
* location information. */
Tcl_Size cmdIndex, /* Index of the command whose start data is
* being set. */
Tcl_Size srcOffset, /* Offset of first char of the command. */
Tcl_Size codeOffset) /* Offset of first byte of command code. */
{
CmdLocation *cmdLocPtr;
if (cmdIndex < 0 || cmdIndex >= envPtr->numCommands) {
Tcl_Panic("EnterCmdStartData: bad command index %" TCL_Z_MODIFIER "u", cmdIndex);
}
if (cmdIndex >= envPtr->cmdMapEnd) {
/*
* Expand the command location array by allocating more storage from
* the heap. The currently allocated CmdLocation entries are stored
|
| ︙ | ︙ | |||
3246 3247 3248 3249 3250 3251 3252 |
*/
static void
EnterCmdExtentData(
CompileEnv *envPtr, /* Points to the compilation environment
* structure in which to enter command
* location information. */
| | | | | | 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 |
*/
static void
EnterCmdExtentData(
CompileEnv *envPtr, /* Points to the compilation environment
* structure in which to enter command
* location information. */
Tcl_Size cmdIndex, /* Index of the command whose source and code
* length data is being set. */
Tcl_Size numSrcBytes, /* Number of command source chars. */
Tcl_Size numCodeBytes) /* Offset of last byte of command code. */
{
CmdLocation *cmdLocPtr;
if (cmdIndex < 0 || cmdIndex >= envPtr->numCommands) {
Tcl_Panic("EnterCmdExtentData: bad command index %" TCL_Z_MODIFIER "u", cmdIndex);
}
if (cmdIndex > envPtr->cmdMapEnd) {
Tcl_Panic("EnterCmdExtentData: missing start data for command %" TCL_Z_MODIFIER "u",
cmdIndex);
}
|
| ︙ | ︙ | |||
3292 3293 3294 3295 3296 3297 3298 |
*/
static void
EnterCmdWordData(
ExtCmdLoc *eclPtr, /* Points to the map environment structure in
* which to enter command location
* information. */
| | | | | | 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 |
*/
static void
EnterCmdWordData(
ExtCmdLoc *eclPtr, /* Points to the map environment structure in
* which to enter command location
* information. */
Tcl_Size srcOffset, /* Offset of first char of the command. */
Tcl_Token *tokenPtr,
const char *cmd,
Tcl_Size numWords,
Tcl_Size line,
int *clNext,
int **wlines,
CompileEnv *envPtr)
{
ECL *ePtr;
const char *last;
Tcl_Size wordIdx, wordLine;
int *wwlines, *wordNext;
if (eclPtr->nuloc >= eclPtr->nloc) {
/*
* Expand the ECL array by allocating more storage from the heap. The
* currently allocated ECL entries are stored from eclPtr->loc[0] up
* to eclPtr->loc[eclPtr->nuloc-1] (inclusive).
|
| ︙ | ︙ | |||
3369 3370 3371 3372 3373 3374 3375 | * the array in expanded: a new array of double the size is allocated, if * envPtr->mallocedExceptArray is non-zero the old array is freed, and * ExceptionRange entries are copied from the old array to the new one. * *---------------------------------------------------------------------- */ | | | | 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 |
* the array in expanded: a new array of double the size is allocated, if
* envPtr->mallocedExceptArray is non-zero the old array is freed, and
* ExceptionRange entries are copied from the old array to the new one.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclCreateExceptRange(
ExceptionRangeType type, /* The kind of ExceptionRange desired. */
CompileEnv *envPtr)/* Points to CompileEnv for which to create a
* new ExceptionRange structure. */
{
ExceptionRange *rangePtr;
ExceptionAux *auxPtr;
Tcl_Size index = envPtr->exceptArrayNext;
if (index >= envPtr->exceptArrayEnd) {
/*
* Expand the ExceptionRange array. The currently allocated entries
* are stored between elements 0 and (envPtr->exceptArrayNext - 1)
* [inclusive].
*/
|
| ︙ | ︙ | |||
3730 3731 3732 3733 3734 3735 3736 | * * Side effects: * If there is not enough room in the CompileEnv's AuxData array, its size * is doubled. *---------------------------------------------------------------------- */ | | | | 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 |
*
* Side effects:
* If there is not enough room in the CompileEnv's AuxData array, its size
* is doubled.
*----------------------------------------------------------------------
*/
Tcl_Size
TclCreateAuxData(
void *clientData, /* The compilation auxiliary data to store in
* the new aux data record. */
const AuxDataType *typePtr, /* Pointer to the type to attach to this
* AuxData */
CompileEnv *envPtr)/* Points to the CompileEnv for which a new
* aux data structure is to be allocated. */
{
Tcl_Size index; /* Index for the new AuxData structure. */
AuxData *auxDataPtr;
/* Points to the new AuxData structure */
index = envPtr->auxDataArrayNext;
if (index >= envPtr->auxDataArrayEnd) {
/*
* Expand the AuxData array. The currently allocated entries are
|
| ︙ | ︙ | |||
4412 4413 4414 4415 4416 4417 4418 |
ByteCode *codePtr, /* ByteCode in which to encode envPtr's
* command location information. */
unsigned char *startPtr) /* Points to the first byte in codePtr's
* memory block where the location information
* is to be stored. */
{
CmdLocation *mapPtr = envPtr->cmdMapPtr;
| | | | | | 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 |
ByteCode *codePtr, /* ByteCode in which to encode envPtr's
* command location information. */
unsigned char *startPtr) /* Points to the first byte in codePtr's
* memory block where the location information
* is to be stored. */
{
CmdLocation *mapPtr = envPtr->cmdMapPtr;
Tcl_Size i, codeDelta, codeLen, srcLen, prevOffset;
Tcl_Size numCmds = envPtr->numCommands;
unsigned char *p = startPtr;
int srcDelta;
/*
* Encode the code offset for each command as a sequence of deltas.
*/
codePtr->codeDeltaStart = p;
prevOffset = 0;
for (i = 0; i < numCmds; i++) {
codeDelta = mapPtr[i].codeOffset - prevOffset;
if (codeDelta < 0) {
Tcl_Panic("EncodeCmdLocMap: bad code offset");
} else if (codeDelta <= 127) {
TclStoreInt1AtPtr(codeDelta, p);
p++;
} else {
TclStoreInt1AtPtr(0xFF, p);
p++;
TclStoreInt4AtPtr(codeDelta, p);
p += 4;
}
prevOffset = mapPtr[i].codeOffset;
}
/*
* Encode the code length for each command.
*/
codePtr->codeLengthStart = p;
for (i = 0; i < numCmds; i++) {
codeLen = mapPtr[i].numCodeBytes;
if (codeLen < 0) {
Tcl_Panic("EncodeCmdLocMap: bad code length");
} else if (codeLen <= 127) {
TclStoreInt1AtPtr(codeLen, p);
p++;
} else {
TclStoreInt1AtPtr(0xFF, p);
p++;
|
| ︙ | ︙ | |||
4486 4487 4488 4489 4490 4491 4492 |
/*
* Encode the source length for each command.
*/
codePtr->srcLengthStart = p;
for (i = 0; i < numCmds; i++) {
srcLen = mapPtr[i].numSrcBytes;
| | | 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 |
/*
* Encode the source length for each command.
*/
codePtr->srcLengthStart = p;
for (i = 0; i < numCmds; i++) {
srcLen = mapPtr[i].numSrcBytes;
if (srcLen < 0) {
Tcl_Panic("EncodeCmdLocMap: bad source length");
} else if (srcLen <= 127) {
TclStoreInt1AtPtr(srcLen, p);
p++;
} else {
TclStoreInt1AtPtr(0xFF, p);
p++;
|
| ︙ | ︙ |
Changes to generic/tclCompile.h.
| ︙ | ︙ | |||
440 441 442 443 444 445 446 |
* code when new namespace resolution rules
* are put into effect. */
Tcl_Size refCount; /* Reference count: set 1 when created plus 1
* for each execution of the code currently
* active. This structure can be freed when
* refCount becomes zero. */
unsigned int flags; /* flags describing state for the codebyte.
| | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
* code when new namespace resolution rules
* are put into effect. */
Tcl_Size refCount; /* Reference count: set 1 when created plus 1
* for each execution of the code currently
* active. This structure can be freed when
* refCount becomes zero. */
unsigned int flags; /* flags describing state for the codebyte.
* this variable holds OR'ed values from the
* TCL_BYTECODE_ masks defined above */
const char *source; /* The source string from which this ByteCode
* was compiled. Note that this pointer is not
* owned by the ByteCode and must not be freed
* or modified by it. */
Proc *procPtr; /* If the ByteCode was compiled from a
* procedure body, this is a pointer to its
|
| ︙ | ︙ | |||
1080 1081 1082 1083 1084 1085 1086 | *---------------------------------------------------------------- * Procedures shared among Tcl bytecode compilation and execution modules but * not used outside: *---------------------------------------------------------------- */ MODULE_SCOPE int TclAttemptCompileProc(Tcl_Interp *interp, | | | | | | | | | | 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 | *---------------------------------------------------------------- * Procedures shared among Tcl bytecode compilation and execution modules but * not used outside: *---------------------------------------------------------------- */ MODULE_SCOPE int TclAttemptCompileProc(Tcl_Interp *interp, Tcl_Parse *parsePtr, Tcl_Size depth, Command *cmdPtr, CompileEnv *envPtr); MODULE_SCOPE void TclCleanupStackForBreakContinue(CompileEnv *envPtr, ExceptionAux *auxPtr); MODULE_SCOPE void TclCompileCmdWord(Tcl_Interp *interp, Tcl_Token *tokenPtr, size_t count, CompileEnv *envPtr); MODULE_SCOPE void TclCompileExpr(Tcl_Interp *interp, const char *script, Tcl_Size numBytes, CompileEnv *envPtr, int optimize); MODULE_SCOPE void TclCompileExprWords(Tcl_Interp *interp, Tcl_Token *tokenPtr, size_t numWords, CompileEnv *envPtr); MODULE_SCOPE void TclCompileInvocation(Tcl_Interp *interp, Tcl_Token *tokenPtr, Tcl_Obj *cmdObj, size_t numWords, CompileEnv *envPtr); MODULE_SCOPE void TclCompileScript(Tcl_Interp *interp, const char *script, Tcl_Size numBytes, CompileEnv *envPtr); MODULE_SCOPE void TclCompileSyntaxError(Tcl_Interp *interp, CompileEnv *envPtr); MODULE_SCOPE void TclCompileTokens(Tcl_Interp *interp, Tcl_Token *tokenPtr, size_t count, CompileEnv *envPtr); MODULE_SCOPE void TclCompileVarSubst(Tcl_Interp *interp, Tcl_Token *tokenPtr, CompileEnv *envPtr); MODULE_SCOPE Tcl_Size TclCreateAuxData(void *clientData, const AuxDataType *typePtr, CompileEnv *envPtr); MODULE_SCOPE Tcl_Size TclCreateExceptRange(ExceptionRangeType type, CompileEnv *envPtr); MODULE_SCOPE ExecEnv * TclCreateExecEnv(Tcl_Interp *interp, size_t size); MODULE_SCOPE Tcl_Obj * TclCreateLiteral(Interp *iPtr, const char *bytes, Tcl_Size length, size_t hash, int *newPtr, Namespace *nsPtr, int flags, LiteralEntry **globalPtrPtr); MODULE_SCOPE void TclDeleteExecEnv(ExecEnv *eePtr); MODULE_SCOPE void TclDeleteLiteralTable(Tcl_Interp *interp, LiteralTable *tablePtr); MODULE_SCOPE void TclEmitForwardJump(CompileEnv *envPtr, TclJumpType jumpType, JumpFixup *jumpFixupPtr); MODULE_SCOPE void TclEmitInvoke(CompileEnv *envPtr, int opcode, ...); MODULE_SCOPE ExceptionRange * TclGetExceptionRangeForPc(unsigned char *pc, int catchOnly, ByteCode *codePtr); MODULE_SCOPE void TclExpandJumpFixupArray(JumpFixupArray *fixupArrayPtr); MODULE_SCOPE int TclNRExecuteByteCode(Tcl_Interp *interp, ByteCode *codePtr); MODULE_SCOPE Tcl_Obj * TclFetchLiteral(CompileEnv *envPtr, Tcl_Size index); MODULE_SCOPE Tcl_Size TclFindCompiledLocal(const char *name, Tcl_Size nameChars, int create, CompileEnv *envPtr); MODULE_SCOPE int TclFixupForwardJump(CompileEnv *envPtr, JumpFixup *jumpFixupPtr, int jumpDist, int distThreshold); MODULE_SCOPE void TclFreeCompileEnv(CompileEnv *envPtr); MODULE_SCOPE void TclFreeJumpFixupArray(JumpFixupArray *fixupArrayPtr); MODULE_SCOPE int TclGetIndexFromToken(Tcl_Token *tokenPtr, |
| ︙ | ︙ | |||
1167 1168 1169 1170 1171 1172 1173 | #ifdef TCL_COMPILE_DEBUG MODULE_SCOPE void TclPrintByteCodeObj(Tcl_Interp *interp, Tcl_Obj *objPtr); #endif MODULE_SCOPE int TclPrintInstruction(ByteCode *codePtr, const unsigned char *pc); MODULE_SCOPE void TclPrintObject(FILE *outFile, | | | | 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 | #ifdef TCL_COMPILE_DEBUG MODULE_SCOPE void TclPrintByteCodeObj(Tcl_Interp *interp, Tcl_Obj *objPtr); #endif MODULE_SCOPE int TclPrintInstruction(ByteCode *codePtr, const unsigned char *pc); MODULE_SCOPE void TclPrintObject(FILE *outFile, Tcl_Obj *objPtr, Tcl_Size maxChars); MODULE_SCOPE void TclPrintSource(FILE *outFile, const char *string, Tcl_Size maxChars); MODULE_SCOPE void TclPushVarName(Tcl_Interp *interp, Tcl_Token *varTokenPtr, CompileEnv *envPtr, int flags, int *localIndexPtr, int *isScalarPtr); MODULE_SCOPE void TclPreserveByteCode(ByteCode *codePtr); MODULE_SCOPE void TclReleaseByteCode(ByteCode *codePtr); MODULE_SCOPE void TclReleaseLiteral(Tcl_Interp *interp, Tcl_Obj *objPtr); |
| ︙ | ︙ | |||
1191 1192 1193 1194 1195 1196 1197 | MODULE_SCOPE void TclVerifyGlobalLiteralTable(Interp *iPtr); MODULE_SCOPE void TclVerifyLocalLiteralTable(CompileEnv *envPtr); #endif MODULE_SCOPE int TclWordKnownAtCompileTime(Tcl_Token *tokenPtr, Tcl_Obj *valuePtr); MODULE_SCOPE void TclLogCommandInfo(Tcl_Interp *interp, const char *script, const char *command, | | | | 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 | MODULE_SCOPE void TclVerifyGlobalLiteralTable(Interp *iPtr); MODULE_SCOPE void TclVerifyLocalLiteralTable(CompileEnv *envPtr); #endif MODULE_SCOPE int TclWordKnownAtCompileTime(Tcl_Token *tokenPtr, Tcl_Obj *valuePtr); MODULE_SCOPE void TclLogCommandInfo(Tcl_Interp *interp, const char *script, const char *command, Tcl_Size length, const unsigned char *pc, Tcl_Obj **tosPtr); MODULE_SCOPE Tcl_Obj *TclGetInnerContext(Tcl_Interp *interp, const unsigned char *pc, Tcl_Obj **tosPtr); MODULE_SCOPE Tcl_Obj *TclNewInstNameObj(unsigned char inst); MODULE_SCOPE int TclPushProcCallFrame(void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[], int isLambda); #endif /* TCL_MAJOR_VERSION > 8 */ /* *---------------------------------------------------------------- * Macros and flag values used by Tcl bytecode compilation and execution |
| ︙ | ︙ | |||
1813 1814 1815 1816 1817 1818 1819 |
#define TCL_DTRACE_DEBUG_LOG() \
int tclDTraceDebugEnabled = TCL_DTRACE_DEBUG_LOG_ENABLED; \
int tclDTraceDebugIndent = 0; \
FILE *tclDTraceDebugLog = NULL; \
void TclDTraceOpenDebugLog(void) { \
char n[35]; \
| | | 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 |
#define TCL_DTRACE_DEBUG_LOG() \
int tclDTraceDebugEnabled = TCL_DTRACE_DEBUG_LOG_ENABLED; \
int tclDTraceDebugIndent = 0; \
FILE *tclDTraceDebugLog = NULL; \
void TclDTraceOpenDebugLog(void) { \
char n[35]; \
snprintf(n, sizeof(n), "/tmp/tclDTraceDebug-%" TCL_Z_MODIFIER "u.log", \
(size_t) getpid()); \
tclDTraceDebugLog = fopen(n, "a"); \
}
#define TclDTraceDbgMsg(p, m, ...) \
do { \
if (tclDTraceDebugEnabled) { \
|
| ︙ | ︙ |
Changes to generic/tclConfig.c.
| ︙ | ︙ | |||
81 82 83 84 85 86 87 |
cdPtr->interp = interp;
if (valEncoding) {
cdPtr->encoding = (char *)Tcl_Alloc(strlen(valEncoding)+1);
strcpy(cdPtr->encoding, valEncoding);
} else {
cdPtr->encoding = NULL;
}
| | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
cdPtr->interp = interp;
if (valEncoding) {
cdPtr->encoding = (char *)Tcl_Alloc(strlen(valEncoding)+1);
strcpy(cdPtr->encoding, valEncoding);
} else {
cdPtr->encoding = NULL;
}
cdPtr->pkg = Tcl_NewStringObj(pkgName, -1);
/*
* Phase I: Adding the provided information to the internal database of
* package meta data.
*
* Phase II: Create a command for querying this database, specific to the
* package registering its configuration. This is the approved interface
|
| ︙ | ︙ | |||
123 124 125 126 127 128 129 |
/*
* Extend the package configuration...
* We cannot assume that the encodings are initialized, therefore
* store the value as-is in a byte array. See Bug [9b2e636361].
*/
for (cfg=configuration ; cfg->key!=NULL && cfg->key[0]!='\0' ; cfg++) {
| | | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
/*
* Extend the package configuration...
* We cannot assume that the encodings are initialized, therefore
* store the value as-is in a byte array. See Bug [9b2e636361].
*/
for (cfg=configuration ; cfg->key!=NULL && cfg->key[0]!='\0' ; cfg++) {
Tcl_DictObjPut(interp, pkgDict, Tcl_NewStringObj(cfg->key, -1),
Tcl_NewByteArrayObj((unsigned char *)cfg->value, strlen(cfg->value)));
}
/*
* Write the changes back into the overall database.
*/
Tcl_DictObjPut(interp, pDB, cdPtr->pkg, pkgDict);
/*
* Now create the interface command for retrieval of the package
* information.
*/
Tcl_DStringInit(&cmdName);
TclDStringAppendLiteral(&cmdName, "::");
Tcl_DStringAppend(&cmdName, pkgName, -1);
/*
* The incomplete command name is the name of the namespace to place it
* in.
*/
if (Tcl_FindNamespace(interp, Tcl_DStringValue(&cmdName), NULL,
|
| ︙ | ︙ | |||
177 178 179 180 181 182 183 | * * QueryConfigObjCmd -- * * Implementation of "::<package>::pkgconfig", the command to query * configuration information embedded into a library. * * Results: | | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
*
* QueryConfigObjCmd --
*
* Implementation of "::<package>::pkgconfig", the command to query
* configuration information embedded into a library.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the manual for what this command does.
*
*----------------------------------------------------------------------
*/
static int
QueryConfigObjCmd(
void *clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
QCCD *cdPtr = (QCCD *)clientData;
Tcl_Obj *pkgName = cdPtr->pkg;
Tcl_Obj *pDB, *pkgDict, *val, *listPtr;
Tcl_Size m, n = 0;
static const char *const subcmdStrings[] = {
"get", "list", NULL
};
enum subcmds {
CFG_GET, CFG_LIST
} index;
Tcl_DString conv;
|
| ︙ | ︙ | |||
223 224 225 226 227 228 229 |
if (Tcl_DictObjGet(interp, pDB, pkgName, &pkgDict) != TCL_OK
|| pkgDict == NULL) {
/*
* Maybe a Tcl_Panic is better, because the package data has to be
* present.
*/
| | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
if (Tcl_DictObjGet(interp, pDB, pkgName, &pkgDict) != TCL_OK
|| pkgDict == NULL) {
/*
* Maybe a Tcl_Panic is better, because the package data has to be
* present.
*/
Tcl_SetObjResult(interp, Tcl_NewStringObj("package not known", -1));
Tcl_SetErrorCode(interp, "TCL", "FATAL", "PKGCFG_BASE",
TclGetString(pkgName), NULL);
return TCL_ERROR;
}
switch (index) {
case CFG_GET:
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "key");
return TCL_ERROR;
}
if (Tcl_DictObjGet(interp, pkgDict, objv[2], &val) != TCL_OK
|| val == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("key not known", -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CONFIG",
TclGetString(objv[2]), NULL);
return TCL_ERROR;
}
if (cdPtr->encoding) {
venc = Tcl_GetEncoding(interp, cdPtr->encoding);
|
| ︙ | ︙ | |||
275 276 277 278 279 280 281 |
}
Tcl_DictObjSize(interp, pkgDict, &m);
listPtr = Tcl_NewListObj(m, NULL);
if (!listPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
}
Tcl_DictObjSize(interp, pkgDict, &m);
listPtr = Tcl_NewListObj(m, NULL);
if (!listPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"insufficient memory to create list", -1));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
return TCL_ERROR;
}
if (m) {
Tcl_DictSearch s;
Tcl_Obj *key;
|
| ︙ | ︙ |
Changes to generic/tclDate.c.
| ︙ | ︙ | |||
2421 2422 2423 2424 2425 2426 2427 |
{ "bt", tZONE, -HOUR( 3) }, /* Baghdad, USSR Zone 2 */
{ "it", tZONE, -HOUR( 7/2) }, /* Iran */
{ "zp4", tZONE, -HOUR( 4) }, /* USSR Zone 3 */
{ "zp5", tZONE, -HOUR( 5) }, /* USSR Zone 4 */
{ "ist", tZONE, -HOUR(11/2) }, /* Indian Standard */
{ "zp6", tZONE, -HOUR( 6) }, /* USSR Zone 5 */
#if 0
| | | 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 |
{ "bt", tZONE, -HOUR( 3) }, /* Baghdad, USSR Zone 2 */
{ "it", tZONE, -HOUR( 7/2) }, /* Iran */
{ "zp4", tZONE, -HOUR( 4) }, /* USSR Zone 3 */
{ "zp5", tZONE, -HOUR( 5) }, /* USSR Zone 4 */
{ "ist", tZONE, -HOUR(11/2) }, /* Indian Standard */
{ "zp6", tZONE, -HOUR( 6) }, /* USSR Zone 5 */
#if 0
/* For completeness. NST is also Newfoundland Standard, and SST is
* also Swedish Summer. */
{ "nst", tZONE, -HOUR(13/2) }, /* North Sumatra */
{ "sst", tZONE, -HOUR( 7) }, /* South Sumatra, USSR Zone 6 */
#endif /* 0 */
{ "wast", tZONE, -HOUR( 7) }, /* West Australian Standard */
{ "wadt", tDAYZONE, -HOUR( 7) }, /* West Australian Daylight */
{ "jt", tZONE, -HOUR(15/2) }, /* Java (3pm in Cronusland!) */
|
| ︙ | ︙ |
Changes to generic/tclDecls.h.
| ︙ | ︙ | |||
1743 1744 1745 1746 1747 1748 1749 | EXTERN int * Tcl_UtfToUniCharDString(const char *src, Tcl_Size length, Tcl_DString *dsPtr); /* 649 */ EXTERN unsigned char * TclGetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *numBytesPtr); /* 650 */ EXTERN unsigned char * Tcl_GetBytesFromObj(Tcl_Interp *interp, | | | | | | 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 | EXTERN int * Tcl_UtfToUniCharDString(const char *src, Tcl_Size length, Tcl_DString *dsPtr); /* 649 */ EXTERN unsigned char * TclGetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *numBytesPtr); /* 650 */ EXTERN unsigned char * Tcl_GetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *numBytesPtr); /* 651 */ EXTERN char * Tcl_GetStringFromObj(Tcl_Obj *objPtr, Tcl_Size *lengthPtr); /* 652 */ EXTERN Tcl_UniChar * Tcl_GetUnicodeFromObj(Tcl_Obj *objPtr, Tcl_Size *lengthPtr); /* 653 */ EXTERN unsigned char * Tcl_GetByteArrayFromObj(Tcl_Obj *objPtr, Tcl_Size *numBytesPtr); /* 654 */ EXTERN int Tcl_UtfCharComplete(const char *src, Tcl_Size length); /* 655 */ EXTERN const char * Tcl_UtfNext(const char *src); /* 656 */ EXTERN const char * Tcl_UtfPrev(const char *src, const char *start); /* 657 */ |
| ︙ | ︙ | |||
1778 1779 1780 1781 1782 1783 1784 | Tcl_DString *dsPtr, Tcl_Size *errorLocationPtr); /* 660 */ EXTERN int Tcl_AsyncMarkFromSignal(Tcl_AsyncHandler async, int sigNumber); /* 661 */ EXTERN int Tcl_ListObjGetElements(Tcl_Interp *interp, | | | | | | | | | 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 | Tcl_DString *dsPtr, Tcl_Size *errorLocationPtr); /* 660 */ EXTERN int Tcl_AsyncMarkFromSignal(Tcl_AsyncHandler async, int sigNumber); /* 661 */ EXTERN int Tcl_ListObjGetElements(Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size *objcPtr, Tcl_Obj ***objvPtr); /* 662 */ EXTERN int Tcl_ListObjLength(Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size *lengthPtr); /* 663 */ EXTERN int Tcl_DictObjSize(Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_Size *sizePtr); /* 664 */ EXTERN int Tcl_SplitList(Tcl_Interp *interp, const char *listStr, Tcl_Size *argcPtr, const char ***argvPtr); /* 665 */ EXTERN void Tcl_SplitPath(const char *path, Tcl_Size *argcPtr, const char ***argvPtr); /* 666 */ EXTERN Tcl_Obj * Tcl_FSSplitPath(Tcl_Obj *pathPtr, Tcl_Size *lenPtr); /* 667 */ EXTERN int Tcl_ParseArgsObjv(Tcl_Interp *interp, const Tcl_ArgvInfo *argTable, Tcl_Size *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv); /* 668 */ EXTERN Tcl_Size Tcl_UniCharLen(const int *uniStr); /* 669 */ EXTERN Tcl_Size Tcl_NumUtfChars(const char *src, Tcl_Size length); /* 670 */ EXTERN Tcl_Size Tcl_GetCharLength(Tcl_Obj *objPtr); |
| ︙ | ︙ | |||
1838 1839 1840 1841 1842 1843 1844 | EXTERN Tcl_Command Tcl_NRCreateCommand2(Tcl_Interp *interp, const char *cmdName, Tcl_ObjCmdProc2 *proc, Tcl_ObjCmdProc2 *nreProc2, void *clientData, Tcl_CmdDeleteProc *deleteProc); /* 679 */ EXTERN int Tcl_NRCallObjProc2(Tcl_Interp *interp, Tcl_ObjCmdProc2 *objProc2, void *clientData, | | | > > > | | | 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 |
EXTERN Tcl_Command Tcl_NRCreateCommand2(Tcl_Interp *interp,
const char *cmdName, Tcl_ObjCmdProc2 *proc,
Tcl_ObjCmdProc2 *nreProc2, void *clientData,
Tcl_CmdDeleteProc *deleteProc);
/* 679 */
EXTERN int Tcl_NRCallObjProc2(Tcl_Interp *interp,
Tcl_ObjCmdProc2 *objProc2, void *clientData,
ptrdiff_t objc, Tcl_Obj *const objv[]);
/* 680 */
EXTERN int Tcl_GetNumberFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, void **clientDataPtr,
int *typePtr);
/* 681 */
EXTERN int Tcl_GetNumber(Tcl_Interp *interp, const char *bytes,
Tcl_Size numBytes, void **clientDataPtr,
int *typePtr);
/* 682 */
EXTERN int Tcl_RemoveChannelMode(Tcl_Interp *interp,
Tcl_Channel chan, int mode);
/* 683 */
EXTERN Tcl_Size Tcl_GetEncodingNulLength(Tcl_Encoding encoding);
/* 684 */
EXTERN int Tcl_GetWideUIntFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, Tcl_WideUInt *uwidePtr);
/* 685 */
EXTERN Tcl_Obj * Tcl_DStringToObj(Tcl_DString *dsPtr);
/* 686 */
EXTERN int Tcl_GetSizeIntFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, Tcl_Size *sizePtr);
/* Slot 687 is reserved */
/* 688 */
EXTERN void TclUnusedStubEntry(void);
typedef struct {
const struct TclPlatStubs *tclPlatStubs;
const struct TclIntStubs *tclIntStubs;
const struct TclIntPlatStubs *tclIntPlatStubs;
} TclStubHooks;
|
| ︙ | ︙ | |||
2521 2522 2523 2524 2525 2526 2527 |
int (*tcl_IsShared) (Tcl_Obj *objPtr); /* 643 */
int (*tcl_LinkArray) (Tcl_Interp *interp, const char *varName, void *addr, int type, Tcl_Size size); /* 644 */
int (*tcl_GetIntForIndex) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size endValue, Tcl_Size *indexPtr); /* 645 */
Tcl_Size (*tcl_UtfToUniChar) (const char *src, int *chPtr); /* 646 */
char * (*tcl_UniCharToUtfDString) (const int *uniStr, Tcl_Size uniLength, Tcl_DString *dsPtr); /* 647 */
int * (*tcl_UtfToUniCharDString) (const char *src, Tcl_Size length, Tcl_DString *dsPtr); /* 648 */
unsigned char * (*tclGetBytesFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *numBytesPtr); /* 649 */
| | | | | | | | | | | | | | > | | | 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 |
int (*tcl_IsShared) (Tcl_Obj *objPtr); /* 643 */
int (*tcl_LinkArray) (Tcl_Interp *interp, const char *varName, void *addr, int type, Tcl_Size size); /* 644 */
int (*tcl_GetIntForIndex) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size endValue, Tcl_Size *indexPtr); /* 645 */
Tcl_Size (*tcl_UtfToUniChar) (const char *src, int *chPtr); /* 646 */
char * (*tcl_UniCharToUtfDString) (const int *uniStr, Tcl_Size uniLength, Tcl_DString *dsPtr); /* 647 */
int * (*tcl_UtfToUniCharDString) (const char *src, Tcl_Size length, Tcl_DString *dsPtr); /* 648 */
unsigned char * (*tclGetBytesFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *numBytesPtr); /* 649 */
unsigned char * (*tcl_GetBytesFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *numBytesPtr); /* 650 */
char * (*tcl_GetStringFromObj) (Tcl_Obj *objPtr, Tcl_Size *lengthPtr); /* 651 */
Tcl_UniChar * (*tcl_GetUnicodeFromObj) (Tcl_Obj *objPtr, Tcl_Size *lengthPtr); /* 652 */
unsigned char * (*tcl_GetByteArrayFromObj) (Tcl_Obj *objPtr, Tcl_Size *numBytesPtr); /* 653 */
int (*tcl_UtfCharComplete) (const char *src, Tcl_Size length); /* 654 */
const char * (*tcl_UtfNext) (const char *src); /* 655 */
const char * (*tcl_UtfPrev) (const char *src, const char *start); /* 656 */
int (*tcl_UniCharIsUnicode) (int ch); /* 657 */
int (*tcl_ExternalToUtfDStringEx) (Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, int flags, Tcl_DString *dsPtr, Tcl_Size *errorLocationPtr); /* 658 */
int (*tcl_UtfToExternalDStringEx) (Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, int flags, Tcl_DString *dsPtr, Tcl_Size *errorLocationPtr); /* 659 */
int (*tcl_AsyncMarkFromSignal) (Tcl_AsyncHandler async, int sigNumber); /* 660 */
int (*tcl_ListObjGetElements) (Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size *objcPtr, Tcl_Obj ***objvPtr); /* 661 */
int (*tcl_ListObjLength) (Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size *lengthPtr); /* 662 */
int (*tcl_DictObjSize) (Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_Size *sizePtr); /* 663 */
int (*tcl_SplitList) (Tcl_Interp *interp, const char *listStr, Tcl_Size *argcPtr, const char ***argvPtr); /* 664 */
void (*tcl_SplitPath) (const char *path, Tcl_Size *argcPtr, const char ***argvPtr); /* 665 */
Tcl_Obj * (*tcl_FSSplitPath) (Tcl_Obj *pathPtr, Tcl_Size *lenPtr); /* 666 */
int (*tcl_ParseArgsObjv) (Tcl_Interp *interp, const Tcl_ArgvInfo *argTable, Tcl_Size *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv); /* 667 */
Tcl_Size (*tcl_UniCharLen) (const int *uniStr); /* 668 */
Tcl_Size (*tcl_NumUtfChars) (const char *src, Tcl_Size length); /* 669 */
Tcl_Size (*tcl_GetCharLength) (Tcl_Obj *objPtr); /* 670 */
const char * (*tcl_UtfAtIndex) (const char *src, Tcl_Size index); /* 671 */
Tcl_Obj * (*tcl_GetRange) (Tcl_Obj *objPtr, Tcl_Size first, Tcl_Size last); /* 672 */
int (*tcl_GetUniChar) (Tcl_Obj *objPtr, Tcl_Size index); /* 673 */
int (*tcl_GetBool) (Tcl_Interp *interp, const char *src, int flags, char *charPtr); /* 674 */
int (*tcl_GetBoolFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int flags, char *charPtr); /* 675 */
Tcl_Command (*tcl_CreateObjCommand2) (Tcl_Interp *interp, const char *cmdName, Tcl_ObjCmdProc2 *proc2, void *clientData, Tcl_CmdDeleteProc *deleteProc); /* 676 */
Tcl_Trace (*tcl_CreateObjTrace2) (Tcl_Interp *interp, Tcl_Size level, int flags, Tcl_CmdObjTraceProc2 *objProc2, void *clientData, Tcl_CmdObjTraceDeleteProc *delProc); /* 677 */
Tcl_Command (*tcl_NRCreateCommand2) (Tcl_Interp *interp, const char *cmdName, Tcl_ObjCmdProc2 *proc, Tcl_ObjCmdProc2 *nreProc2, void *clientData, Tcl_CmdDeleteProc *deleteProc); /* 678 */
int (*tcl_NRCallObjProc2) (Tcl_Interp *interp, Tcl_ObjCmdProc2 *objProc2, void *clientData, ptrdiff_t objc, Tcl_Obj *const objv[]); /* 679 */
int (*tcl_GetNumberFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, void **clientDataPtr, int *typePtr); /* 680 */
int (*tcl_GetNumber) (Tcl_Interp *interp, const char *bytes, Tcl_Size numBytes, void **clientDataPtr, int *typePtr); /* 681 */
int (*tcl_RemoveChannelMode) (Tcl_Interp *interp, Tcl_Channel chan, int mode); /* 682 */
Tcl_Size (*tcl_GetEncodingNulLength) (Tcl_Encoding encoding); /* 683 */
int (*tcl_GetWideUIntFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_WideUInt *uwidePtr); /* 684 */
Tcl_Obj * (*tcl_DStringToObj) (Tcl_DString *dsPtr); /* 685 */
int (*tcl_GetSizeIntFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *sizePtr); /* 686 */
void (*reserved687)(void);
void (*tclUnusedStubEntry) (void); /* 688 */
} TclStubs;
extern const TclStubs *tclStubsPtr;
#ifdef __cplusplus
}
#endif
|
| ︙ | ︙ | |||
3883 3884 3885 3886 3887 3888 3889 | (tclStubsPtr->tcl_RemoveChannelMode) /* 682 */ #define Tcl_GetEncodingNulLength \ (tclStubsPtr->tcl_GetEncodingNulLength) /* 683 */ #define Tcl_GetWideUIntFromObj \ (tclStubsPtr->tcl_GetWideUIntFromObj) /* 684 */ #define Tcl_DStringToObj \ (tclStubsPtr->tcl_DStringToObj) /* 685 */ | > > | | | 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 | (tclStubsPtr->tcl_RemoveChannelMode) /* 682 */ #define Tcl_GetEncodingNulLength \ (tclStubsPtr->tcl_GetEncodingNulLength) /* 683 */ #define Tcl_GetWideUIntFromObj \ (tclStubsPtr->tcl_GetWideUIntFromObj) /* 684 */ #define Tcl_DStringToObj \ (tclStubsPtr->tcl_DStringToObj) /* 685 */ #define Tcl_GetSizeIntFromObj \ (tclStubsPtr->tcl_GetSizeIntFromObj) /* 686 */ /* Slot 687 is reserved */ #define TclUnusedStubEntry \ (tclStubsPtr->tclUnusedStubEntry) /* 688 */ #endif /* defined(USE_TCL_STUBS) */ /* !END!: Do not edit above this line. */ #undef TclUnusedStubEntry |
| ︙ | ︙ | |||
3932 3933 3934 3935 3936 3937 3938 | #define Tcl_UntraceVar(interp, varName, flags, proc, clientData) \ Tcl_UntraceVar2(interp, varName, NULL, flags, proc, clientData) #define Tcl_VarTraceInfo(interp, varName, flags, proc, prevClientData) \ Tcl_VarTraceInfo2(interp, varName, NULL, flags, proc, prevClientData) #define Tcl_UpVar(interp, frameName, varName, localName, flags) \ Tcl_UpVar2(interp, frameName, varName, NULL, localName, flags) #define Tcl_AddErrorInfo(interp, message) \ | | | | 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 |
#define Tcl_UntraceVar(interp, varName, flags, proc, clientData) \
Tcl_UntraceVar2(interp, varName, NULL, flags, proc, clientData)
#define Tcl_VarTraceInfo(interp, varName, flags, proc, prevClientData) \
Tcl_VarTraceInfo2(interp, varName, NULL, flags, proc, prevClientData)
#define Tcl_UpVar(interp, frameName, varName, localName, flags) \
Tcl_UpVar2(interp, frameName, varName, NULL, localName, flags)
#define Tcl_AddErrorInfo(interp, message) \
Tcl_AppendObjToErrorInfo(interp, Tcl_NewStringObj(message, -1))
#define Tcl_AddObjErrorInfo(interp, message, length) \
Tcl_AppendObjToErrorInfo(interp, Tcl_NewStringObj(message, length))
#define Tcl_Eval(interp, objPtr) \
Tcl_EvalEx(interp, objPtr, TCL_INDEX_NONE, 0)
#define Tcl_GlobalEval(interp, objPtr) \
Tcl_EvalEx(interp, objPtr, TCL_INDEX_NONE, TCL_EVAL_GLOBAL)
#define Tcl_GetStringResult(interp) Tcl_GetString(Tcl_GetObjResult(interp))
#define Tcl_SetResult(interp, result, freeProc) \
do { \
const char *__result = result; \
Tcl_FreeProc *__freeProc = freeProc; \
Tcl_SetObjResult(interp, Tcl_NewStringObj(__result, -1)); \
if (__result != NULL && __freeProc != NULL && __freeProc != TCL_VOLATILE) { \
if (__freeProc == TCL_DYNAMIC) { \
Tcl_Free((char *)__result); \
} else { \
(*__freeProc)((char *)__result); \
} \
} \
|
| ︙ | ︙ | |||
4016 4017 4018 4019 4020 4021 4022 | #undef Tcl_GetString #undef Tcl_GetUnicode #define Tcl_GetString(objPtr) \ Tcl_GetStringFromObj(objPtr, (Tcl_Size *)NULL) #define Tcl_GetUnicode(objPtr) \ Tcl_GetUnicodeFromObj(objPtr, (Tcl_Size *)NULL) | > | > > > < < > | | | | > > > > > > > > > < < < < | | < < < < | | | | | 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 |
#undef Tcl_GetString
#undef Tcl_GetUnicode
#define Tcl_GetString(objPtr) \
Tcl_GetStringFromObj(objPtr, (Tcl_Size *)NULL)
#define Tcl_GetUnicode(objPtr) \
Tcl_GetUnicodeFromObj(objPtr, (Tcl_Size *)NULL)
#if TCL_MAJOR_VERSION < 9 || !defined(TCL_NO_DEPRECATED)
# undef Tcl_GetBytesFromObj
# undef Tcl_GetStringFromObj
# undef Tcl_GetUnicodeFromObj
#endif
#undef Tcl_GetIndexFromObjStruct
#undef Tcl_GetBooleanFromObj
#undef Tcl_GetBoolean
#undef TclGetByteArrayFromObj
#undef Tcl_GetByteArrayFromObj
#if defined(USE_TCL_STUBS)
# if TCL_MAJOR_VERSION < 9 || !defined(TCL_NO_DEPRECATED)
# define Tcl_GetBytesFromObj(interp, objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetBytesFromObj(interp, objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tcl_GetBytesFromObj(interp, objPtr, (Tcl_Size *)(void *)(sizePtr)))
# define Tcl_GetStringFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetStringFromObj(objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tcl_GetStringFromObj(objPtr, (Tcl_Size *)(void *)(sizePtr)))
# define Tcl_GetUnicodeFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetUnicodeFromObj(objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tcl_GetUnicodeFromObj(objPtr, (Tcl_Size *)(void *)(sizePtr)))
# endif
#define Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, indexPtr) \
(tclStubsPtr->tcl_GetIndexFromObjStruct((interp), (objPtr), (tablePtr), (offset), (msg), \
(flags)|(int)(sizeof(*(indexPtr))<<1), (indexPtr)))
#define Tcl_GetBooleanFromObj(interp, objPtr, boolPtr) \
((sizeof(*(boolPtr)) == sizeof(int) && (TCL_MAJOR_VERSION == 8)) ? tclStubsPtr->tcl_GetBooleanFromObj(interp, objPtr, (int *)(boolPtr)) : \
Tcl_GetBoolFromObj(interp, objPtr, (TCL_NULL_OK-2)&(int)sizeof((*(boolPtr))), (char *)(boolPtr)))
#define Tcl_GetBoolean(interp, src, boolPtr) \
((sizeof(*(boolPtr)) == sizeof(int) && (TCL_MAJOR_VERSION == 8)) ? tclStubsPtr->tcl_GetBoolean(interp, src, (int *)(boolPtr)) : \
Tcl_GetBool(interp, src, (TCL_NULL_OK-2)&(int)sizeof((*(boolPtr))), (char *)(boolPtr)))
#if TCL_MAJOR_VERSION > 8
#define Tcl_GetByteArrayFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetBytesFromObj(NULL, objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tcl_GetBytesFromObj(NULL, objPtr, (Tcl_Size *)(void *)(sizePtr)))
#else
#define Tcl_GetByteArrayFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetByteArrayFromObj(objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tcl_GetByteArrayFromObj(objPtr, (Tcl_Size *)(void *)(sizePtr)))
#endif
#else
#define Tcl_GetBytesFromObj(interp, objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetBytesFromObj(interp, objPtr, (int *)(void *)(sizePtr)) : \
(Tcl_GetBytesFromObj)(interp, objPtr, (Tcl_Size *)(void *)(sizePtr)))
#define Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, indexPtr) \
((Tcl_GetIndexFromObjStruct)((interp), (objPtr), (tablePtr), (offset), (msg), \
(flags)|(int)(sizeof(*(indexPtr))<<1), (indexPtr)))
#define Tcl_GetBooleanFromObj(interp, objPtr, boolPtr) \
((sizeof(*(boolPtr)) == sizeof(int) && (TCL_MAJOR_VERSION == 8)) ? Tcl_GetBooleanFromObj(interp, objPtr, (int *)(boolPtr)) : \
Tcl_GetBoolFromObj(interp, objPtr, (TCL_NULL_OK-2)&(int)sizeof((*(boolPtr))), (char *)(boolPtr)))
#define Tcl_GetBoolean(interp, src, boolPtr) \
((sizeof(*(boolPtr)) == sizeof(int) && (TCL_MAJOR_VERSION == 8)) ? Tcl_GetBoolean(interp, src, (int *)(boolPtr)) : \
Tcl_GetBool(interp, src, (TCL_NULL_OK-2)&(int)sizeof((*(boolPtr))), (char *)(boolPtr)))
#define Tcl_GetStringFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetStringFromObj(objPtr, (int *)(void *)(sizePtr)) : \
(Tcl_GetStringFromObj)(objPtr, (Tcl_Size *)(void *)(sizePtr)))
#define Tcl_GetByteArrayFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetBytesFromObj(NULL, objPtr, (int *)(void *)(sizePtr)) : \
(Tcl_GetBytesFromObj)(NULL, objPtr, (Tcl_Size *)(void *)(sizePtr)))
#define Tcl_GetUnicodeFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetUnicodeFromObj(objPtr, (int *)(void *)(sizePtr)) : \
(Tcl_GetUnicodeFromObj)(objPtr, (Tcl_Size *)(void *)(sizePtr)))
#endif
#ifdef TCL_MEM_DEBUG
# undef Tcl_Alloc
# define Tcl_Alloc(x) \
(Tcl_DbCkalloc((x), __FILE__, __LINE__))
# undef Tcl_Free
|
| ︙ | ︙ | |||
4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 | : (wchar_t *(*)(const char *, Tcl_Size, Tcl_DString *))Tcl_UtfToChar16DString) # define Tcl_UtfToWChar (sizeof(wchar_t) != sizeof(short) \ ? (Tcl_Size (*)(const char *, wchar_t *))tclStubsPtr->tcl_UtfToUniChar \ : (Tcl_Size (*)(const char *, wchar_t *))Tcl_UtfToChar16) # define Tcl_WCharLen (sizeof(wchar_t) != sizeof(short) \ ? (Tcl_Size (*)(wchar_t *))tclStubsPtr->tcl_UniCharLen \ : (Tcl_Size (*)(wchar_t *))Tcl_Char16Len) # undef Tcl_ListObjGetElements # define Tcl_ListObjGetElements(interp, listPtr, objcPtr, objvPtr) (sizeof(*(objcPtr)) == sizeof(int) \ ? tclStubsPtr->tclListObjGetElements((interp), (listPtr), (int *)(void *)(objcPtr), (objvPtr)) \ | > | | | | | | | > | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > > > > > | 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 |
: (wchar_t *(*)(const char *, Tcl_Size, Tcl_DString *))Tcl_UtfToChar16DString)
# define Tcl_UtfToWChar (sizeof(wchar_t) != sizeof(short) \
? (Tcl_Size (*)(const char *, wchar_t *))tclStubsPtr->tcl_UtfToUniChar \
: (Tcl_Size (*)(const char *, wchar_t *))Tcl_UtfToChar16)
# define Tcl_WCharLen (sizeof(wchar_t) != sizeof(short) \
? (Tcl_Size (*)(wchar_t *))tclStubsPtr->tcl_UniCharLen \
: (Tcl_Size (*)(wchar_t *))Tcl_Char16Len)
#if TCL_MAJOR_VERSION < 9 || !defined(TCL_NO_DEPRECATED)
# undef Tcl_ListObjGetElements
# define Tcl_ListObjGetElements(interp, listPtr, objcPtr, objvPtr) (sizeof(*(objcPtr)) == sizeof(int) \
? tclStubsPtr->tclListObjGetElements((interp), (listPtr), (int *)(void *)(objcPtr), (objvPtr)) \
: tclStubsPtr->tcl_ListObjGetElements((interp), (listPtr), (Tcl_Size *)(void *)(objcPtr), (objvPtr)))
# undef Tcl_ListObjLength
# define Tcl_ListObjLength(interp, listPtr, lengthPtr) (sizeof(*(lengthPtr)) == sizeof(int) \
? tclStubsPtr->tclListObjLength((interp), (listPtr), (int *)(void *)(lengthPtr)) \
: tclStubsPtr->tcl_ListObjLength((interp), (listPtr), (Tcl_Size *)(void *)(lengthPtr)))
# undef Tcl_DictObjSize
# define Tcl_DictObjSize(interp, dictPtr, sizePtr) (sizeof(*(sizePtr)) == sizeof(int) \
? tclStubsPtr->tclDictObjSize((interp), (dictPtr), (int *)(void *)(sizePtr)) \
: tclStubsPtr->tcl_DictObjSize((interp), (dictPtr), (Tcl_Size *)(void *)(sizePtr)))
# undef Tcl_SplitList
# define Tcl_SplitList(interp, listStr, argcPtr, argvPtr) (sizeof(*(argcPtr)) == sizeof(int) \
? tclStubsPtr->tclSplitList((interp), (listStr), (int *)(void *)(argcPtr), (argvPtr)) \
: tclStubsPtr->tcl_SplitList((interp), (listStr), (Tcl_Size *)(void *)(argcPtr), (argvPtr)))
# undef Tcl_SplitPath
# define Tcl_SplitPath(path, argcPtr, argvPtr) (sizeof(*(argcPtr)) == sizeof(int) \
? tclStubsPtr->tclSplitPath((path), (int *)(void *)(argcPtr), (argvPtr)) \
: tclStubsPtr->tcl_SplitPath((path), (Tcl_Size *)(void *)(argcPtr), (argvPtr)))
# undef Tcl_FSSplitPath
# define Tcl_FSSplitPath(pathPtr, lenPtr) (sizeof(*(lenPtr)) == sizeof(int) \
? tclStubsPtr->tclFSSplitPath((pathPtr), (int *)(void *)(lenPtr)) \
: tclStubsPtr->tcl_FSSplitPath((pathPtr), (Tcl_Size *)(void *)(lenPtr)))
# undef Tcl_ParseArgsObjv
# define Tcl_ParseArgsObjv(interp, argTable, objcPtr, objv, remObjv) (sizeof(*(objcPtr)) == sizeof(int) \
? tclStubsPtr->tclParseArgsObjv((interp), (argTable), (int *)(void *)(objcPtr), (objv), (remObjv)) \
: tclStubsPtr->tcl_ParseArgsObjv((interp), (argTable), (Tcl_Size *)(void *)(objcPtr), (objv), (remObjv)))
#endif /* TCL_MAJOR_VERSION < 9 || !defined(TCL_NO_DEPRECATED) */
#else
# define Tcl_WCharToUtfDString (sizeof(wchar_t) != sizeof(short) \
? (char *(*)(const wchar_t *, Tcl_Size, Tcl_DString *))Tcl_UniCharToUtfDString \
: (char *(*)(const wchar_t *, Tcl_Size, Tcl_DString *))Tcl_Char16ToUtfDString)
# define Tcl_UtfToWCharDString (sizeof(wchar_t) != sizeof(short) \
? (wchar_t *(*)(const char *, Tcl_Size, Tcl_DString *))Tcl_UtfToUniCharDString \
: (wchar_t *(*)(const char *, Tcl_Size, Tcl_DString *))Tcl_UtfToChar16DString)
# define Tcl_UtfToWChar (sizeof(wchar_t) != sizeof(short) \
? (Tcl_Size (*)(const char *, wchar_t *))Tcl_UtfToUniChar \
: (Tcl_Size (*)(const char *, wchar_t *))Tcl_UtfToChar16)
# define Tcl_WCharLen (sizeof(wchar_t) != sizeof(short) \
? (Tcl_Size (*)(wchar_t *))Tcl_UniCharLen \
: (Tcl_Size (*)(wchar_t *))Tcl_Char16Len)
#if !defined(BUILD_tcl) && !defined(TCL_NO_DEPRECATED)
# define Tcl_ListObjGetElements(interp, listPtr, objcPtr, objvPtr) (sizeof(*(objcPtr)) == sizeof(int) \
? TclListObjGetElements((interp), (listPtr), (int *)(void *)(objcPtr), (objvPtr)) \
: (Tcl_ListObjGetElements)((interp), (listPtr), (Tcl_Size *)(void *)(objcPtr), (objvPtr)))
# define Tcl_ListObjLength(interp, listPtr, lengthPtr) (sizeof(*(lengthPtr)) == sizeof(int) \
? TclListObjLength((interp), (listPtr), (int *)(void *)(lengthPtr)) \
: (Tcl_ListObjLength)((interp), (listPtr), (Tcl_Size *)(void *)(lengthPtr)))
# define Tcl_DictObjSize(interp, dictPtr, sizePtr) (sizeof(*(sizePtr)) == sizeof(int) \
? TclDictObjSize((interp), (dictPtr), (int *)(void *)(sizePtr)) \
: (Tcl_DictObjSize)((interp), (dictPtr), (Tcl_Size *)(void *)(sizePtr)))
# define Tcl_SplitList(interp, listStr, argcPtr, argvPtr) (sizeof(*(argcPtr)) == sizeof(int) \
? TclSplitList((interp), (listStr), (int *)(void *)(argcPtr), (argvPtr)) \
: (Tcl_SplitList)((interp), (listStr), (Tcl_Size *)(void *)(argcPtr), (argvPtr)))
# define Tcl_SplitPath(path, argcPtr, argvPtr) (sizeof(*(argcPtr)) == sizeof(int) \
? TclSplitPath((path), (int *)(void *)(argcPtr), (argvPtr)) \
: (Tcl_SplitPath)((path), (Tcl_Size *)(void *)(argcPtr), (argvPtr)))
# define Tcl_FSSplitPath(pathPtr, lenPtr) (sizeof(*(lenPtr)) == sizeof(int) \
? TclFSSplitPath((pathPtr), (int *)(void *)(lenPtr)) \
: (Tcl_FSSplitPath)((pathPtr), (Tcl_Size *)(void *)(lenPtr)))
# define Tcl_ParseArgsObjv(interp, argTable, objcPtr, objv, remObjv) (sizeof(*(objcPtr)) == sizeof(int) \
? TclParseArgsObjv((interp), (argTable), (int *)(void *)(objcPtr), (objv), (remObjv)) \
: (Tcl_ParseArgsObjv)((interp), (argTable), (Tcl_Size *)(void *)(objcPtr), (objv), (remObjv)))
#endif /* !defined(BUILD_tcl) */
#endif
/*
* Deprecated Tcl procedures:
*/
#define Tcl_EvalObj(interp, objPtr) \
Tcl_EvalObjEx(interp, objPtr, 0)
#define Tcl_GlobalEvalObj(interp, objPtr) \
Tcl_EvalObjEx(interp, objPtr, TCL_EVAL_GLOBAL)
#if TCL_MAJOR_VERSION > 8
# undef Tcl_Close
# define Tcl_Close(interp, chan) Tcl_CloseEx(interp, chan, 0)
#endif
#undef TclUtfCharComplete
#undef TclUtfNext
#undef TclUtfPrev
#ifndef TCL_NO_DEPRECATED
# define Tcl_CreateSlave Tcl_CreateChild
# define Tcl_GetSlave Tcl_GetChild
# define Tcl_GetMaster Tcl_GetParent
#endif
/* TIP #660 for 8.7 */
#if TCL_MAJOR_VERSION < 9
# undef Tcl_GetSizeIntFromObj
# define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj
#endif
#endif /* _TCLDECLS */
|
Changes to generic/tclDictObj.c.
| ︙ | ︙ | |||
499 500 501 502 503 504 505 |
Tcl_Obj *dictPtr)
{
#define LOCAL_SIZE 64
char localFlags[LOCAL_SIZE], *flagPtr = NULL;
Dict *dict;
ChainEntry *cPtr;
Tcl_Obj *keyPtr, *valuePtr;
| | | | 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
Tcl_Obj *dictPtr)
{
#define LOCAL_SIZE 64
char localFlags[LOCAL_SIZE], *flagPtr = NULL;
Dict *dict;
ChainEntry *cPtr;
Tcl_Obj *keyPtr, *valuePtr;
Tcl_Size i, length;
TCL_HASH_TYPE bytesNeeded = 0;
const char *elem;
char *dst;
/*
* This field is the most useful one in the whole hash structure, and it
* is not exposed by any API function...
*/
Tcl_Size numElems;
DictGetInternalRep(dictPtr, dict);
assert (dict != NULL);
numElems = dict->table.numEntries * 2;
|
| ︙ | ︙ | |||
614 615 616 617 618 619 620 |
/*
* Since lists and dictionaries have very closely-related string
* representations (i.e. the same parsing code) we can safely special-case
* the conversion from lists to dictionaries.
*/
if (TclHasInternalRep(objPtr, &tclListType)) {
| | | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
/*
* Since lists and dictionaries have very closely-related string
* representations (i.e. the same parsing code) we can safely special-case
* the conversion from lists to dictionaries.
*/
if (TclHasInternalRep(objPtr, &tclListType)) {
Tcl_Size objc, i;
Tcl_Obj **objv;
/* Cannot fail, we already know the Tcl_ObjType is "list". */
TclListObjGetElementsM(NULL, objPtr, &objc, &objv);
if (objc & 1) {
goto missingValue;
}
|
| ︙ | ︙ | |||
644 645 646 647 648 649 650 |
TclDecrRefCount(discardedValue);
}
Tcl_SetHashValue(hPtr, objv[i+1]);
Tcl_IncrRefCount(objv[i+1]); /* Since hash now holds ref to it */
}
} else {
| | | | 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
TclDecrRefCount(discardedValue);
}
Tcl_SetHashValue(hPtr, objv[i+1]);
Tcl_IncrRefCount(objv[i+1]); /* Since hash now holds ref to it */
}
} else {
Tcl_Size length;
const char *nextElem = Tcl_GetStringFromObj(objPtr, &length);
const char *limit = (nextElem + length);
while (nextElem < limit) {
Tcl_Obj *keyPtr, *valuePtr;
const char *elemStart;
Tcl_Size elemSize;
int literal;
if (TclFindDictElement(interp, nextElem, (limit - nextElem),
&elemStart, &nextElem, &elemSize, &literal) != TCL_OK) {
goto errorInFindDictElement;
}
if (elemStart == limit) {
|
| ︙ | ︙ | |||
727 728 729 730 731 732 733 |
dict->refCount = 1;
DictSetInternalRep(objPtr, dict);
return TCL_OK;
missingValue:
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
dict->refCount = 1;
DictSetInternalRep(objPtr, dict);
return TCL_OK;
missingValue:
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing value to go with key", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DICTIONARY", NULL);
}
errorInFindDictElement:
DeleteChainTable(dict);
Tcl_Free(dict);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
779 780 781 782 783 784 785 | * effects (other than potential conversion of objects to dictionaries.) * If the flags argument is DICT_PATH_UPDATE, the following additional * side effects occur. Shared dictionaries along the path are converted * into unshared objects, and a backward-pointing chain is built using * the chain fields of the dictionaries (for easy invalidation of string * representations using InvalidateDictChain). If the flags argument has * the DICT_PATH_CREATE bits set (and not the DICT_PATH_EXISTS bit), | | | | | 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
* effects (other than potential conversion of objects to dictionaries.)
* If the flags argument is DICT_PATH_UPDATE, the following additional
* side effects occur. Shared dictionaries along the path are converted
* into unshared objects, and a backward-pointing chain is built using
* the chain fields of the dictionaries (for easy invalidation of string
* representations using InvalidateDictChain). If the flags argument has
* the DICT_PATH_CREATE bits set (and not the DICT_PATH_EXISTS bit),
* non-extant keys will be inserted with a value of an empty
* dictionary, resulting in the path being built.
*
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclTraceDictPath(
Tcl_Interp *interp,
Tcl_Obj *dictPtr,
Tcl_Size keyc,
Tcl_Obj *const keyv[],
int flags)
{
Dict *dict, *newDict;
Tcl_Size i;
DictGetInternalRep(dictPtr, dict);
if (dict == NULL) {
if (SetDictFromAny(interp, dictPtr) != TCL_OK) {
return NULL;
}
DictGetInternalRep(dictPtr, dict);
|
| ︙ | ︙ | |||
872 873 874 875 876 877 878 | } /* *---------------------------------------------------------------------- * * InvalidateDictChain -- * | | | 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 | } /* *---------------------------------------------------------------------- * * InvalidateDictChain -- * * Go through a dictionary chain (built by an updating invocation of * TclTraceDictPath) and invalidate the string representations of all the * dictionaries on the chain. * * Results: * None * * Side effects: |
| ︙ | ︙ | |||
1078 1079 1080 1081 1082 1083 1084 |
*/
#undef Tcl_DictObjSize
int
Tcl_DictObjSize(
Tcl_Interp *interp,
Tcl_Obj *dictPtr,
| | | 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
*/
#undef Tcl_DictObjSize
int
Tcl_DictObjSize(
Tcl_Interp *interp,
Tcl_Obj *dictPtr,
Tcl_Size *sizePtr)
{
Dict *dict;
dict = GetDictFromObj(interp, dictPtr);
if (dict == NULL) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1198 1199 1200 1201 1202 1203 1204 |
* written into when there are no further
* values in the dictionary, or a 0
* otherwise. */
{
ChainEntry *cPtr;
/*
| | | 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
* written into when there are no further
* values in the dictionary, or a 0
* otherwise. */
{
ChainEntry *cPtr;
/*
* If the search is done; we do no work.
*/
if (!searchPtr->epoch) {
*donePtr = 1;
return;
}
|
| ︙ | ︙ | |||
1291 1292 1293 1294 1295 1296 1297 |
*----------------------------------------------------------------------
*/
int
Tcl_DictObjPutKeyList(
Tcl_Interp *interp,
Tcl_Obj *dictPtr,
| | | | 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 |
*----------------------------------------------------------------------
*/
int
Tcl_DictObjPutKeyList(
Tcl_Interp *interp,
Tcl_Obj *dictPtr,
Tcl_Size keyc,
Tcl_Obj *const keyv[],
Tcl_Obj *valuePtr)
{
Dict *dict;
Tcl_HashEntry *hPtr;
int isNew;
if (Tcl_IsShared(dictPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_DictObjPutKeyList");
}
if (keyc < 1) {
Tcl_Panic("%s called with empty key list", "Tcl_DictObjPutKeyList");
}
dictPtr = TclTraceDictPath(interp, dictPtr, keyc-1,keyv, DICT_PATH_CREATE);
if (dictPtr == NULL) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1352 1353 1354 1355 1356 1357 1358 |
*----------------------------------------------------------------------
*/
int
Tcl_DictObjRemoveKeyList(
Tcl_Interp *interp,
Tcl_Obj *dictPtr,
| | | 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 |
*----------------------------------------------------------------------
*/
int
Tcl_DictObjRemoveKeyList(
Tcl_Interp *interp,
Tcl_Obj *dictPtr,
Tcl_Size keyc,
Tcl_Obj *const keyv[])
{
Dict *dict;
if (Tcl_IsShared(dictPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_DictObjRemoveKeyList");
}
|
| ︙ | ︙ | |||
2035 2036 2037 2038 2039 2040 2041 |
DictSizeCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
int result;
| | | 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 |
DictSizeCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
int result;
Tcl_Size size;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "dictionary");
return TCL_ERROR;
}
result = Tcl_DictObjSize(interp, objv[1], &size);
if (result == TCL_OK) {
|
| ︙ | ︙ | |||
2129 2130 2131 2132 2133 2134 2135 |
dict = GetDictFromObj(interp, objv[1]);
if (dict == NULL) {
return TCL_ERROR;
}
statsStr = Tcl_HashStats(&dict->table);
| | | 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 |
dict = GetDictFromObj(interp, objv[1]);
if (dict == NULL) {
return TCL_ERROR;
}
statsStr = Tcl_HashStats(&dict->table);
Tcl_SetObjResult(interp, Tcl_NewStringObj(statsStr, -1));
Tcl_Free(statsStr);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
2473 2474 2475 2476 2477 2478 2479 |
int objc,
Tcl_Obj *const *objv)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *scriptObj, *keyVarObj, *valueVarObj;
Tcl_Obj **varv, *keyObj, *valueObj;
Tcl_DictSearch *searchPtr;
| | | | 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 |
int objc,
Tcl_Obj *const *objv)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *scriptObj, *keyVarObj, *valueVarObj;
Tcl_Obj **varv, *keyObj, *valueObj;
Tcl_DictSearch *searchPtr;
Tcl_Size varc;
int done;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv,
"{keyVarName valueVarName} dictionary script");
return TCL_ERROR;
}
/*
* Parse arguments.
*/
if (TclListObjGetElementsM(interp, objv[1], &varc, &varv) != TCL_OK) {
return TCL_ERROR;
}
if (varc != 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must have exactly two variable names", -1));
Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "for", NULL);
return TCL_ERROR;
}
searchPtr = (Tcl_DictSearch *)TclStackAlloc(interp, sizeof(Tcl_DictSearch));
if (Tcl_DictObjFirst(interp, objv[2], searchPtr, &keyObj, &valueObj,
&done) != TCL_OK) {
TclStackFree(interp, searchPtr);
|
| ︙ | ︙ | |||
2668 2669 2670 2671 2672 2673 2674 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj **varv, *keyObj, *valueObj;
DictMapStorage *storagePtr;
| | | | 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj **varv, *keyObj, *valueObj;
DictMapStorage *storagePtr;
Tcl_Size varc;
int done;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv,
"{keyVarName valueVarName} dictionary script");
return TCL_ERROR;
}
/*
* Parse arguments.
*/
if (TclListObjGetElementsM(interp, objv[1], &varc, &varv) != TCL_OK) {
return TCL_ERROR;
}
if (varc != 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must have exactly two variable names", -1));
Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "map", NULL);
return TCL_ERROR;
}
storagePtr = (DictMapStorage *)TclStackAlloc(interp, sizeof(DictMapStorage));
if (Tcl_DictObjFirst(interp, objv[2], &storagePtr->search, &keyObj,
&valueObj, &done) != TCL_OK) {
TclStackFree(interp, storagePtr);
|
| ︙ | ︙ | |||
3008 3009 3010 3011 3012 3013 3014 |
enum FilterTypes {
FILTER_KEYS, FILTER_SCRIPT, FILTER_VALUES
} index;
Tcl_Obj *scriptObj, *keyVarObj, *valueVarObj;
Tcl_Obj **varv, *keyObj = NULL, *valueObj = NULL, *resultObj, *boolObj;
Tcl_DictSearch search;
int done, result, satisfied;
| | | 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 |
enum FilterTypes {
FILTER_KEYS, FILTER_SCRIPT, FILTER_VALUES
} index;
Tcl_Obj *scriptObj, *keyVarObj, *valueVarObj;
Tcl_Obj **varv, *keyObj = NULL, *valueObj = NULL, *resultObj, *boolObj;
Tcl_DictSearch search;
int done, result, satisfied;
Tcl_Size varc;
const char *pattern;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "dictionary filterType ?arg ...?");
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[2], filters, "filterType",
|
| ︙ | ︙ | |||
3126 3127 3128 3129 3130 3131 3132 |
*/
if (TclListObjGetElementsM(interp, objv[3], &varc, &varv) != TCL_OK) {
return TCL_ERROR;
}
if (varc != 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 |
*/
if (TclListObjGetElementsM(interp, objv[3], &varc, &varv) != TCL_OK) {
return TCL_ERROR;
}
if (varc != 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must have exactly two variable names", -1));
Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "filter", NULL);
return TCL_ERROR;
}
keyVarObj = varv[0];
valueVarObj = varv[1];
scriptObj = objv[4];
|
| ︙ | ︙ | |||
3286 3287 3288 3289 3290 3291 3292 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *dictPtr, *objPtr;
int i;
| | | 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *dictPtr, *objPtr;
int i;
Tcl_Size dummy;
if (objc < 5 || !(objc & 1)) {
Tcl_WrongNumArgs(interp, 1, objv,
"dictVarName key varName ?key varName ...? script");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
3339 3340 3341 3342 3343 3344 3345 |
FinalizeDictUpdate(
void *data[],
Tcl_Interp *interp,
int result)
{
Tcl_Obj *dictPtr, *objPtr, **objv;
Tcl_InterpState state;
| | | 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 |
FinalizeDictUpdate(
void *data[],
Tcl_Interp *interp,
int result)
{
Tcl_Obj *dictPtr, *objPtr, **objv;
Tcl_InterpState state;
Tcl_Size i, objc;
Tcl_Obj *varName = (Tcl_Obj *)data[0];
Tcl_Obj *argsObj = (Tcl_Obj *)data[1];
/*
* ErrorInfo handling.
*/
|
| ︙ | ︙ | |||
3489 3490 3491 3492 3493 3494 3495 |
static int
FinalizeDictWith(
void *data[],
Tcl_Interp *interp,
int result)
{
Tcl_Obj **pathv;
| | | 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 |
static int
FinalizeDictWith(
void *data[],
Tcl_Interp *interp,
int result)
{
Tcl_Obj **pathv;
Tcl_Size pathc;
Tcl_InterpState state;
Tcl_Obj *varName = (Tcl_Obj *)data[0];
Tcl_Obj *keysPtr = (Tcl_Obj *)data[1];
Tcl_Obj *pathPtr = (Tcl_Obj *)data[2];
Var *varPtr, *arrayPtr;
if (result == TCL_ERROR) {
|
| ︙ | ︙ | |||
3566 3567 3568 3569 3570 3571 3572 |
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclDictWithInit(
Tcl_Interp *interp,
Tcl_Obj *dictPtr,
| | | | 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 |
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclDictWithInit(
Tcl_Interp *interp,
Tcl_Obj *dictPtr,
Tcl_Size pathc,
Tcl_Obj *const pathv[])
{
Tcl_DictSearch s;
Tcl_Obj *keyPtr, *valPtr, *keysPtr;
int done;
if (pathc > 0) {
dictPtr = TclTraceDictPath(interp, dictPtr, pathc, pathv,
DICT_PATH_READ);
if (dictPtr == NULL) {
return NULL;
}
}
|
| ︙ | ︙ | |||
3653 3654 3655 3656 3657 3658 3659 |
int pathc, /* The number of elements in the path into the
* dictionary. */
Tcl_Obj *const pathv[], /* The elements of the path to the subdict. */
Tcl_Obj *keysPtr) /* List of keys to be synchronized. This is
* the result value from TclDictWithInit. */
{
Tcl_Obj *dictPtr, *leafPtr, *valPtr;
| | | 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 |
int pathc, /* The number of elements in the path into the
* dictionary. */
Tcl_Obj *const pathv[], /* The elements of the path to the subdict. */
Tcl_Obj *keysPtr) /* List of keys to be synchronized. This is
* the result value from TclDictWithInit. */
{
Tcl_Obj *dictPtr, *leafPtr, *valPtr;
Tcl_Size i, allocdict, keyc;
Tcl_Obj **keyv;
/*
* If the dictionary variable doesn't exist, drop everything silently.
*/
dictPtr = TclPtrGetVarIdx(interp, varPtr, arrayPtr, part1Ptr, part2Ptr,
|
| ︙ | ︙ | |||
3684 3685 3686 3687 3688 3689 3690 |
} else {
allocdict = 0;
}
if (pathc > 0) {
/*
* Want to get to the dictionary which we will update; need to do
| | | | | 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 |
} else {
allocdict = 0;
}
if (pathc > 0) {
/*
* Want to get to the dictionary which we will update; need to do
* prepare-for-update unsharing along the path *but* avoid generating
* an error on a non-extant path (we'll treat that the same as a
* non-extant variable. Luckily, the unsharing operation isn't
* deeply damaging if we don't go on to update; it's just less than
* perfectly efficient (but no memory should be leaked).
*/
leafPtr = TclTraceDictPath(interp, dictPtr, pathc, pathv,
DICT_PATH_EXISTS | DICT_PATH_UPDATE);
if (leafPtr == NULL) {
|
| ︙ | ︙ |
Changes to generic/tclDisassemble.c.
| ︙ | ︙ | |||
24 25 26 27 28 29 30 | static Tcl_Obj * DisassembleByteCodeAsDicts(Tcl_Obj *objPtr); static Tcl_Obj * DisassembleByteCodeObj(Tcl_Obj *objPtr); static int FormatInstruction(ByteCode *codePtr, const unsigned char *pc, Tcl_Obj *bufferObj); static void GetLocationInformation(Proc *procPtr, Tcl_Obj **fileObjPtr, int *linePtr); static void PrintSourceToObj(Tcl_Obj *appendObj, | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | static Tcl_Obj * DisassembleByteCodeAsDicts(Tcl_Obj *objPtr); static Tcl_Obj * DisassembleByteCodeObj(Tcl_Obj *objPtr); static int FormatInstruction(ByteCode *codePtr, const unsigned char *pc, Tcl_Obj *bufferObj); static void GetLocationInformation(Proc *procPtr, Tcl_Obj **fileObjPtr, int *linePtr); static void PrintSourceToObj(Tcl_Obj *appendObj, const char *stringPtr, Tcl_Size maxChars); static void UpdateStringOfInstName(Tcl_Obj *objPtr); /* * The structure below defines an instruction name Tcl object to allow * reporting of inner contexts in errorstack without string allocation. */ |
| ︙ | ︙ | |||
190 191 192 193 194 195 196 |
*/
void
TclPrintObject(
FILE *outFile, /* The file to print the source to. */
Tcl_Obj *objPtr, /* Points to the Tcl object whose string
* representation should be printed. */
| | | | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
*/
void
TclPrintObject(
FILE *outFile, /* The file to print the source to. */
Tcl_Obj *objPtr, /* Points to the Tcl object whose string
* representation should be printed. */
Tcl_Size maxChars) /* Maximum number of chars to print. */
{
char *bytes;
Tcl_Size length;
bytes = Tcl_GetStringFromObj(objPtr, &length);
TclPrintSource(outFile, bytes, TclMin(length, maxChars));
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
221 222 223 224 225 226 227 |
*----------------------------------------------------------------------
*/
void
TclPrintSource(
FILE *outFile, /* The file to print the source to. */
const char *stringPtr, /* The string to print. */
| | | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
*----------------------------------------------------------------------
*/
void
TclPrintSource(
FILE *outFile, /* The file to print the source to. */
const char *stringPtr, /* The string to print. */
Tcl_Size maxChars) /* Maximum number of chars to print. */
{
Tcl_Obj *bufferObj;
TclNewObj(bufferObj);
PrintSourceToObj(bufferObj, stringPtr, maxChars);
fprintf(outFile, "%s", TclGetString(bufferObj));
Tcl_DecrRefCount(bufferObj);
|
| ︙ | ︙ | |||
276 277 278 279 280 281 282 |
/*
* Print header lines describing the ByteCode.
*/
Tcl_AppendPrintfToObj(bufferObj,
"ByteCode %p, refCt %" TCL_Z_MODIFIER "u, epoch %" TCL_Z_MODIFIER "u, interp %p (epoch %" TCL_Z_MODIFIER "u)\n",
codePtr, codePtr->refCount, codePtr->compileEpoch, iPtr, iPtr->compileEpoch);
| | | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
/*
* Print header lines describing the ByteCode.
*/
Tcl_AppendPrintfToObj(bufferObj,
"ByteCode %p, refCt %" TCL_Z_MODIFIER "u, epoch %" TCL_Z_MODIFIER "u, interp %p (epoch %" TCL_Z_MODIFIER "u)\n",
codePtr, codePtr->refCount, codePtr->compileEpoch, iPtr, iPtr->compileEpoch);
Tcl_AppendToObj(bufferObj, " Source ", -1);
PrintSourceToObj(bufferObj, codePtr->source,
TclMin(codePtr->numSrcBytes, 55));
GetLocationInformation(codePtr->procPtr, &fileObj, &line);
if (line >= 0 && fileObj != NULL) {
Tcl_AppendPrintfToObj(bufferObj, "\n File \"%s\" Line %d",
TclGetString(fileObj), line);
}
|
| ︙ | ︙ | |||
335 336 337 338 339 340 341 |
(localPtr->flags & (VAR_ARRAY|VAR_LINK)) ? "" : ", scalar",
(localPtr->flags & VAR_ARRAY) ? ", array" : "",
(localPtr->flags & VAR_LINK) ? ", link" : "",
(localPtr->flags & VAR_ARGUMENT) ? ", arg" : "",
(localPtr->flags & VAR_TEMPORARY) ? ", temp" : "",
(localPtr->flags & VAR_RESOLVED) ? ", resolved" : "");
if (TclIsVarTemporary(localPtr)) {
| | | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
(localPtr->flags & (VAR_ARRAY|VAR_LINK)) ? "" : ", scalar",
(localPtr->flags & VAR_ARRAY) ? ", array" : "",
(localPtr->flags & VAR_LINK) ? ", link" : "",
(localPtr->flags & VAR_ARGUMENT) ? ", arg" : "",
(localPtr->flags & VAR_TEMPORARY) ? ", temp" : "",
(localPtr->flags & VAR_RESOLVED) ? ", resolved" : "");
if (TclIsVarTemporary(localPtr)) {
Tcl_AppendToObj(bufferObj, "\n", -1);
} else {
Tcl_AppendPrintfToObj(bufferObj, ", \"%s\"\n",
localPtr->name);
}
localPtr = localPtr->nextPtr;
}
}
|
| ︙ | ︙ | |||
385 386 387 388 389 390 391 |
* If there were no commands (e.g., an expression or an empty string was
* compiled), just print all instructions and return.
*/
if (numCmds == 0) {
pc = codeStart;
while (pc < codeLimit) {
| | | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
* If there were no commands (e.g., an expression or an empty string was
* compiled), just print all instructions and return.
*/
if (numCmds == 0) {
pc = codeStart;
while (pc < codeLimit) {
Tcl_AppendToObj(bufferObj, " ", -1);
pc += FormatInstruction(codePtr, pc, bufferObj);
}
return bufferObj;
}
/*
* Print table showing the code offset, source offset, and source length
|
| ︙ | ︙ | |||
447 448 449 450 451 452 453 |
Tcl_AppendPrintfToObj(bufferObj, "%s%4d: pc %d-%d, src %d-%d",
((i % 2)? " " : "\n "),
(i+1), codeOffset, (codeOffset + codeLen - 1),
srcOffset, (srcOffset + srcLen - 1));
}
if (numCmds > 0) {
| | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
Tcl_AppendPrintfToObj(bufferObj, "%s%4d: pc %d-%d, src %d-%d",
((i % 2)? " " : "\n "),
(i+1), codeOffset, (codeOffset + codeLen - 1),
srcOffset, (srcOffset + srcLen - 1));
}
if (numCmds > 0) {
Tcl_AppendToObj(bufferObj, "\n", -1);
}
/*
* Print each instruction. If the instruction corresponds to the start of
* a command, print the command's source. Note that we don't need the code
* length here.
*/
|
| ︙ | ︙ | |||
496 497 498 499 500 501 502 |
}
/*
* Print instructions before command i.
*/
while ((pc-codeStart) < codeOffset) {
| | | | | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
}
/*
* Print instructions before command i.
*/
while ((pc-codeStart) < codeOffset) {
Tcl_AppendToObj(bufferObj, " ", -1);
pc += FormatInstruction(codePtr, pc, bufferObj);
}
Tcl_AppendPrintfToObj(bufferObj, " Command %d: ", i+1);
PrintSourceToObj(bufferObj, (codePtr->source + srcOffset),
TclMin(srcLen, 55));
Tcl_AppendToObj(bufferObj, "\n", -1);
}
if (pc < codeLimit) {
/*
* Print instructions after the last command.
*/
while (pc < codeLimit) {
Tcl_AppendToObj(bufferObj, " ", -1);
pc += FormatInstruction(codePtr, pc, bufferObj);
}
}
return bufferObj;
}
/*
|
| ︙ | ︙ | |||
567 568 569 570 571 572 573 |
case OPERAND_UINT1:
opnd = TclGetUInt1AtPtr(pc+numBytes); numBytes++;
Tcl_AppendPrintfToObj(bufferObj, "%u ", opnd);
break;
case OPERAND_UINT4:
opnd = TclGetUInt4AtPtr(pc+numBytes); numBytes += 4;
if (opCode == INST_START_CMD) {
| | | | | | 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
case OPERAND_UINT1:
opnd = TclGetUInt1AtPtr(pc+numBytes); numBytes++;
Tcl_AppendPrintfToObj(bufferObj, "%u ", opnd);
break;
case OPERAND_UINT4:
opnd = TclGetUInt4AtPtr(pc+numBytes); numBytes += 4;
if (opCode == INST_START_CMD) {
snprintf(suffixBuffer+strlen(suffixBuffer), sizeof(suffixBuffer) - strlen(suffixBuffer),
", %u cmds start here", opnd);
}
Tcl_AppendPrintfToObj(bufferObj, "%u ", opnd);
break;
case OPERAND_OFFSET1:
opnd = TclGetInt1AtPtr(pc+numBytes); numBytes++;
snprintf(suffixBuffer, sizeof(suffixBuffer), "pc %u", pcOffset+opnd);
Tcl_AppendPrintfToObj(bufferObj, "%+d ", opnd);
break;
case OPERAND_OFFSET4:
opnd = TclGetInt4AtPtr(pc+numBytes); numBytes += 4;
if (opCode == INST_START_CMD) {
snprintf(suffixBuffer, sizeof(suffixBuffer), "next cmd at pc %u", pcOffset+opnd);
} else {
snprintf(suffixBuffer, sizeof(suffixBuffer), "pc %u", pcOffset+opnd);
}
Tcl_AppendPrintfToObj(bufferObj, "%+d ", opnd);
break;
case OPERAND_LIT1:
opnd = TclGetUInt1AtPtr(pc+numBytes); numBytes++;
suffixObj = codePtr->objArrayPtr[opnd];
Tcl_AppendPrintfToObj(bufferObj, "%u ", opnd);
|
| ︙ | ︙ | |||
628 629 630 631 632 633 634 |
Tcl_Panic("FormatInstruction: bad local var index %u (%u locals)",
opnd, localCt);
}
for (j = 0; j < opnd; j++) {
localPtr = localPtr->nextPtr;
}
if (TclIsVarTemporary(localPtr)) {
| | | | | | | | | 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 |
Tcl_Panic("FormatInstruction: bad local var index %u (%u locals)",
opnd, localCt);
}
for (j = 0; j < opnd; j++) {
localPtr = localPtr->nextPtr;
}
if (TclIsVarTemporary(localPtr)) {
snprintf(suffixBuffer, sizeof(suffixBuffer), "temp var %u", opnd);
} else {
snprintf(suffixBuffer, sizeof(suffixBuffer), "var ");
suffixSrc = localPtr->name;
}
}
Tcl_AppendPrintfToObj(bufferObj, "%%v%u ", opnd);
break;
case OPERAND_SCLS1:
opnd = TclGetUInt1AtPtr(pc+numBytes); numBytes++;
Tcl_AppendPrintfToObj(bufferObj, "%s ",
tclStringClassTable[opnd].name);
break;
case OPERAND_NONE:
default:
break;
}
}
if (suffixObj) {
const char *bytes;
Tcl_Size length;
Tcl_AppendToObj(bufferObj, "\t# ", -1);
bytes = Tcl_GetStringFromObj(codePtr->objArrayPtr[opnd], &length);
PrintSourceToObj(bufferObj, bytes, TclMin(length, 40));
} else if (suffixBuffer[0]) {
Tcl_AppendPrintfToObj(bufferObj, "\t# %s", suffixBuffer);
if (suffixSrc) {
PrintSourceToObj(bufferObj, suffixSrc, 40);
}
}
Tcl_AppendToObj(bufferObj, "\n", -1);
if (auxPtr && auxPtr->type->printProc) {
Tcl_AppendToObj(bufferObj, "\t\t[", -1);
auxPtr->type->printProc(auxPtr->clientData, bufferObj, codePtr,
pcOffset);
Tcl_AppendToObj(bufferObj, "]\n", -1);
}
return numBytes;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
686 687 688 689 690 691 692 |
Tcl_Obj *
TclGetInnerContext(
Tcl_Interp *interp,
const unsigned char *pc,
Tcl_Obj **tosPtr)
{
| | | 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 |
Tcl_Obj *
TclGetInnerContext(
Tcl_Interp *interp,
const unsigned char *pc,
Tcl_Obj **tosPtr)
{
Tcl_Size objc = 0;
Tcl_Obj *result;
Interp *iPtr = (Interp *) interp;
switch (*pc) {
case INST_STR_LEN:
case INST_LNOT:
case INST_BITNOT:
|
| ︙ | ︙ | |||
755 756 757 758 759 760 761 |
result = iPtr->innerContext;
if (Tcl_IsShared(result)) {
Tcl_DecrRefCount(result);
iPtr->innerContext = result = Tcl_NewListObj(objc + 1, NULL);
Tcl_IncrRefCount(result);
} else {
| | | 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 |
result = iPtr->innerContext;
if (Tcl_IsShared(result)) {
Tcl_DecrRefCount(result);
iPtr->innerContext = result = Tcl_NewListObj(objc + 1, NULL);
Tcl_IncrRefCount(result);
} else {
Tcl_Size len;
/*
* Reset while keeping the list internalrep as much as possible.
*/
TclListObjLengthM(interp, result, &len);
Tcl_ListObjReplace(interp, result, 0, len, 0, NULL);
|
| ︙ | ︙ | |||
832 833 834 835 836 837 838 |
char *dst;
InstNameGetInternalRep(objPtr, inst);
if (inst >= LAST_INST_OPCODE) {
dst = Tcl_InitStringRep(objPtr, NULL, TCL_INTEGER_SPACE + 5);
TclOOM(dst, TCL_INTEGER_SPACE + 5);
| | | 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
char *dst;
InstNameGetInternalRep(objPtr, inst);
if (inst >= LAST_INST_OPCODE) {
dst = Tcl_InitStringRep(objPtr, NULL, TCL_INTEGER_SPACE + 5);
TclOOM(dst, TCL_INTEGER_SPACE + 5);
snprintf(dst, TCL_INTEGER_SPACE + 5, "inst_%" TCL_Z_MODIFIER "u", inst);
(void) Tcl_InitStringRep(objPtr, NULL, strlen(dst));
} else {
const char *s = tclInstructionTable[inst].name;
size_t len = strlen(s);
dst = Tcl_InitStringRep(objPtr, s, len);
TclOOM(dst, len);
}
|
| ︙ | ︙ | |||
856 857 858 859 860 861 862 |
*----------------------------------------------------------------------
*/
static void
PrintSourceToObj(
Tcl_Obj *appendObj, /* The object to print the source to. */
const char *stringPtr, /* The string to print. */
| | | | | | | | | | | | | | 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 |
*----------------------------------------------------------------------
*/
static void
PrintSourceToObj(
Tcl_Obj *appendObj, /* The object to print the source to. */
const char *stringPtr, /* The string to print. */
Tcl_Size maxChars) /* Maximum number of chars to print. */
{
const char *p;
Tcl_Size i = 0, len;
if (stringPtr == NULL) {
Tcl_AppendToObj(appendObj, "\"\"", -1);
return;
}
Tcl_AppendToObj(appendObj, "\"", -1);
p = stringPtr;
for (; (*p != '\0') && (i < maxChars); p+=len) {
int ucs4;
len = TclUtfToUCS4(p, &ucs4);
switch (ucs4) {
case '"':
Tcl_AppendToObj(appendObj, "\\\"", -1);
i += 2;
continue;
case '\f':
Tcl_AppendToObj(appendObj, "\\f", -1);
i += 2;
continue;
case '\n':
Tcl_AppendToObj(appendObj, "\\n", -1);
i += 2;
continue;
case '\r':
Tcl_AppendToObj(appendObj, "\\r", -1);
i += 2;
continue;
case '\t':
Tcl_AppendToObj(appendObj, "\\t", -1);
i += 2;
continue;
case '\v':
Tcl_AppendToObj(appendObj, "\\v", -1);
i += 2;
continue;
default:
if (ucs4 > 0xFFFF) {
Tcl_AppendPrintfToObj(appendObj, "\\U%08x", ucs4);
i += 10;
} else if (ucs4 < 0x20 || ucs4 >= 0x7F) {
Tcl_AppendPrintfToObj(appendObj, "\\u%04x", ucs4);
i += 6;
} else {
Tcl_AppendPrintfToObj(appendObj, "%c", ucs4);
i++;
}
continue;
}
}
if (*p != '\0') {
Tcl_AppendToObj(appendObj, "...", -1);
}
Tcl_AppendToObj(appendObj, "\"", -1);
}
/*
*----------------------------------------------------------------------
*
* DisassembleByteCodeAsDicts --
*
|
| ︙ | ︙ | |||
968 969 970 971 972 973 974 |
for (i=0 ; i<localCount ; i++,localPtr=localPtr->nextPtr) {
Tcl_Obj *descriptor[2];
TclNewObj(descriptor[0]);
if (!(localPtr->flags & (VAR_ARRAY|VAR_LINK))) {
Tcl_ListObjAppendElement(NULL, descriptor[0],
| | | | | | | | | | 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 |
for (i=0 ; i<localCount ; i++,localPtr=localPtr->nextPtr) {
Tcl_Obj *descriptor[2];
TclNewObj(descriptor[0]);
if (!(localPtr->flags & (VAR_ARRAY|VAR_LINK))) {
Tcl_ListObjAppendElement(NULL, descriptor[0],
Tcl_NewStringObj("scalar", -1));
}
if (localPtr->flags & VAR_ARRAY) {
Tcl_ListObjAppendElement(NULL, descriptor[0],
Tcl_NewStringObj("array", -1));
}
if (localPtr->flags & VAR_LINK) {
Tcl_ListObjAppendElement(NULL, descriptor[0],
Tcl_NewStringObj("link", -1));
}
if (localPtr->flags & VAR_ARGUMENT) {
Tcl_ListObjAppendElement(NULL, descriptor[0],
Tcl_NewStringObj("arg", -1));
}
if (localPtr->flags & VAR_TEMPORARY) {
Tcl_ListObjAppendElement(NULL, descriptor[0],
Tcl_NewStringObj("temp", -1));
}
if (localPtr->flags & VAR_RESOLVED) {
Tcl_ListObjAppendElement(NULL, descriptor[0],
Tcl_NewStringObj("resolved", -1));
}
if (localPtr->flags & VAR_TEMPORARY) {
Tcl_ListObjAppendElement(NULL, variables,
Tcl_NewListObj(1, descriptor));
} else {
descriptor[1] = Tcl_NewStringObj(localPtr->name, -1);
Tcl_ListObjAppendElement(NULL, variables,
Tcl_NewListObj(2, descriptor));
}
}
}
/*
* Get the instructions from the bytecode.
*/
TclNewObj(instructions);
for (pc=codePtr->codeStart; pc<codePtr->codeStart+codePtr->numCodeBytes;){
const InstructionDesc *instDesc = &tclInstructionTable[*pc];
int address = pc - codePtr->codeStart;
TclNewObj(inst);
Tcl_ListObjAppendElement(NULL, inst, Tcl_NewStringObj(
instDesc->name, -1));
opnd = pc + 1;
for (i=0 ; i<instDesc->numOperands ; i++) {
switch (instDesc->opTypes[i]) {
case OPERAND_INT1:
val = TclGetInt1AtPtr(opnd);
opnd += 1;
goto formatNumber;
|
| ︙ | ︙ | |||
1078 1079 1080 1081 1082 1083 1084 |
val = TclGetInt4AtPtr(opnd);
opnd += 4;
if (val >= -1) {
Tcl_ListObjAppendElement(NULL, inst, Tcl_ObjPrintf(
".%d", val));
} else if (val == -2) {
Tcl_ListObjAppendElement(NULL, inst, Tcl_NewStringObj(
| | | 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
val = TclGetInt4AtPtr(opnd);
opnd += 4;
if (val >= -1) {
Tcl_ListObjAppendElement(NULL, inst, Tcl_ObjPrintf(
".%d", val));
} else if (val == -2) {
Tcl_ListObjAppendElement(NULL, inst, Tcl_NewStringObj(
".end", -1));
} else {
Tcl_ListObjAppendElement(NULL, inst, Tcl_ObjPrintf(
".end-%d", -2-val));
}
break;
case OPERAND_AUX4:
val = TclGetInt4AtPtr(opnd);
|
| ︙ | ︙ | |||
1111 1112 1113 1114 1115 1116 1117 |
/*
* Get the auxiliary data from the bytecode.
*/
TclNewObj(aux);
for (i=0 ; i<(int)codePtr->numAuxDataItems ; i++) {
AuxData *auxData = &codePtr->auxDataArrayPtr[i];
| | | | 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 |
/*
* Get the auxiliary data from the bytecode.
*/
TclNewObj(aux);
for (i=0 ; i<(int)codePtr->numAuxDataItems ; i++) {
AuxData *auxData = &codePtr->auxDataArrayPtr[i];
Tcl_Obj *auxDesc = Tcl_NewStringObj(auxData->type->name, -1);
if (auxData->type->disassembleProc) {
Tcl_Obj *desc;
TclNewObj(desc);
Tcl_DictObjPut(NULL, desc, Tcl_NewStringObj("name", -1), auxDesc);
auxDesc = desc;
auxData->type->disassembleProc(auxData->clientData, auxDesc,
codePtr, 0);
} else if (auxData->type->printProc) {
Tcl_Obj *desc;
TclNewObj(desc);
|
| ︙ | ︙ | |||
1184 1185 1186 1187 1188 1189 1190 | Tcl_Obj *cmd; codeOffset += Decode(codeOffPtr); codeLength = Decode(codeLenPtr); sourceOffset += Decode(srcOffPtr); sourceLength = Decode(srcLenPtr); TclNewObj(cmd); | | | | | | | | | | | | | | | | | | | | 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
Tcl_Obj *cmd;
codeOffset += Decode(codeOffPtr);
codeLength = Decode(codeLenPtr);
sourceOffset += Decode(srcOffPtr);
sourceLength = Decode(srcLenPtr);
TclNewObj(cmd);
Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("codefrom", -1),
Tcl_NewWideIntObj(codeOffset));
Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("codeto", -1),
Tcl_NewWideIntObj(codeOffset + codeLength - 1));
/*
* Convert byte offsets to character offsets; important if multibyte
* characters are present in the source!
*/
Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("scriptfrom", -1),
Tcl_NewWideIntObj(Tcl_NumUtfChars(codePtr->source,
sourceOffset)));
Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("scriptto", -1),
Tcl_NewWideIntObj(Tcl_NumUtfChars(codePtr->source,
sourceOffset + sourceLength - 1)));
Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("script", -1),
Tcl_NewStringObj(codePtr->source+sourceOffset, sourceLength));
Tcl_ListObjAppendElement(NULL, commands, cmd);
}
#undef Decode
/*
* Get the source file and line number information from the CmdFrame
* system if it is available.
*/
GetLocationInformation(codePtr->procPtr, &file, &line);
/*
* Build the overall result.
*/
TclNewObj(description);
Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("literals", -1),
literals);
Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("variables", -1),
variables);
Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("exception", -1), exn);
Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("instructions", -1),
instructions);
Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("auxiliary", -1), aux);
Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("commands", -1),
commands);
Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("script", -1),
Tcl_NewStringObj(codePtr->source, codePtr->numSrcBytes));
Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("namespace", -1),
Tcl_NewStringObj(codePtr->nsPtr->fullName, -1));
Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("stackdepth", -1),
Tcl_NewWideIntObj(codePtr->maxStackDepth));
Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("exceptdepth", -1),
Tcl_NewWideIntObj(codePtr->maxExceptDepth));
if (line >= 0) {
Tcl_DictObjPut(NULL, description,
Tcl_NewStringObj("initiallinenumber", -1),
Tcl_NewWideIntObj(line));
}
if (file) {
Tcl_DictObjPut(NULL, description,
Tcl_NewStringObj("sourcefile", -1), file);
}
return description;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
1406 1407 1408 1409 1410 1411 1412 |
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"CONSRUCTOR", NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod(methodPtr);
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 |
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"CONSRUCTOR", NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod(methodPtr);
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"body not available for this kind of constructor", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"METHODTYPE", NULL);
return TCL_ERROR;
}
/*
* Compile if necessary.
|
| ︙ | ︙ | |||
1471 1472 1473 1474 1475 1476 1477 |
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"DESRUCTOR", NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod(methodPtr);
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 |
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"DESRUCTOR", NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod(methodPtr);
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"body not available for this kind of destructor", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"METHODTYPE", NULL);
return TCL_ERROR;
}
/*
* Compile if necessary.
|
| ︙ | ︙ | |||
1561 1562 1563 1564 1565 1566 1567 |
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(objv[3]), NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod((Method *)Tcl_GetHashValue(hPtr));
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 |
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(objv[3]), NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod((Method *)Tcl_GetHashValue(hPtr));
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"body not available for this kind of method", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"METHODTYPE", NULL);
return TCL_ERROR;
}
if (!TclHasInternalRep(procPtr->bodyPtr, &tclByteCodeType)) {
Command cmd;
|
| ︙ | ︙ | |||
1598 1599 1600 1601 1602 1603 1604 |
* Do the actual disassembly.
*/
ByteCodeGetInternalRep(codeObjPtr, &tclByteCodeType, codePtr);
if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 |
* Do the actual disassembly.
*/
ByteCodeGetInternalRep(codeObjPtr, &tclByteCodeType, codePtr);
if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may not disassemble prebuilt bytecode", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"BYTECODE", NULL);
return TCL_ERROR;
}
if (clientData) {
Tcl_SetObjResult(interp,
DisassembleByteCodeAsDicts(codeObjPtr));
|
| ︙ | ︙ |
Changes to generic/tclEncoding.c.
| ︙ | ︙ | |||
606 607 608 609 610 611 612 |
type.encodingName = "utf-8";
type.toUtfProc = UtfToUtfProc;
type.fromUtfProc = UtfToUtfProc;
type.freeProc = NULL;
type.nullSize = 1;
type.clientData = INT2PTR(ENCODING_UTF);
Tcl_CreateEncoding(&type);
| | | | | | | | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
type.encodingName = "utf-8";
type.toUtfProc = UtfToUtfProc;
type.fromUtfProc = UtfToUtfProc;
type.freeProc = NULL;
type.nullSize = 1;
type.clientData = INT2PTR(ENCODING_UTF);
Tcl_CreateEncoding(&type);
type.clientData = NULL;
type.encodingName = "cesu-8";
Tcl_CreateEncoding(&type);
type.toUtfProc = Utf16ToUtfProc;
type.fromUtfProc = UtfToUcs2Proc;
type.freeProc = NULL;
type.nullSize = 2;
type.encodingName = "ucs-2le";
type.clientData = INT2PTR(TCL_ENCODING_LE);
Tcl_CreateEncoding(&type);
type.encodingName = "ucs-2be";
type.clientData = NULL;
Tcl_CreateEncoding(&type);
type.encodingName = "ucs-2";
type.clientData = INT2PTR(leFlags);
Tcl_CreateEncoding(&type);
type.toUtfProc = Utf32ToUtfProc;
type.fromUtfProc = UtfToUtf32Proc;
type.freeProc = NULL;
type.nullSize = 4;
type.encodingName = "utf-32le";
type.clientData = INT2PTR(TCL_ENCODING_LE);
Tcl_CreateEncoding(&type);
type.encodingName = "utf-32be";
type.clientData = NULL;
Tcl_CreateEncoding(&type);
type.encodingName = "utf-32";
type.clientData = INT2PTR(leFlags);
Tcl_CreateEncoding(&type);
type.toUtfProc = Utf16ToUtfProc;
type.fromUtfProc = UtfToUtf16Proc;
type.freeProc = NULL;
type.nullSize = 2;
type.encodingName = "utf-16le";
type.clientData = INT2PTR(TCL_ENCODING_LE);
Tcl_CreateEncoding(&type);
type.encodingName = "utf-16be";
type.clientData = NULL;
Tcl_CreateEncoding(&type);
type.encodingName = "utf-16";
type.clientData = INT2PTR(leFlags);
Tcl_CreateEncoding(&type);
#ifndef TCL_NO_DEPRECATED
type.encodingName = "unicode";
Tcl_CreateEncoding(&type);
#endif
|
| ︙ | ︙ | |||
1295 1296 1297 1298 1299 1300 1301 |
* wants to know error location.
*/
*errorLocPtr = result == TCL_OK ? TCL_INDEX_NONE : nBytesProcessed;
} else {
/* Caller wants error message on failure */
if (result != TCL_OK && interp != NULL) {
char buf[TCL_INTEGER_SPACE];
| | | 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 |
* wants to know error location.
*/
*errorLocPtr = result == TCL_OK ? TCL_INDEX_NONE : nBytesProcessed;
} else {
/* Caller wants error message on failure */
if (result != TCL_OK && interp != NULL) {
char buf[TCL_INTEGER_SPACE];
snprintf(buf, sizeof(buf), "%" TCL_Z_MODIFIER "u", nBytesProcessed);
Tcl_SetObjResult(
interp,
Tcl_ObjPrintf("unexpected byte sequence starting at index %"
TCL_Z_MODIFIER "u: '\\x%02X'",
nBytesProcessed,
UCHAR(srcStart[nBytesProcessed])));
Tcl_SetErrorCode(
|
| ︙ | ︙ | |||
1411 1412 1413 1414 1415 1416 1417 |
dstCharsPtr = &dstChars;
flags &= ~TCL_ENCODING_CHAR_LIMIT;
} else if (charLimited) {
maxChars = *dstCharsPtr;
}
if (!noTerminate) {
| | | | | 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 |
dstCharsPtr = &dstChars;
flags &= ~TCL_ENCODING_CHAR_LIMIT;
} else if (charLimited) {
maxChars = *dstCharsPtr;
}
if (!noTerminate) {
if (dstLen < 1) {
return TCL_CONVERT_NOSPACE;
}
/*
* If there are any null characters in the middle of the buffer,
* they will converted to the UTF-8 null character (\xC0\x80). To get
* the actual \0 at the end of the destination buffer, we need to
* append it manually. First make room for it...
*/
|
| ︙ | ︙ | |||
1608 1609 1610 1611 1612 1613 1614 |
* of a multibyte character
* In both cases we have to grow buffer, move the input source pointer
* and loop. Otherwise, return the result we got.
*/
if ((result != TCL_CONVERT_NOSPACE) &&
!(result == TCL_CONVERT_MULTIBYTE && (flags & TCL_ENCODING_END))) {
Tcl_Size nBytesProcessed = (src - srcStart);
| | | | | 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 |
* of a multibyte character
* In both cases we have to grow buffer, move the input source pointer
* and loop. Otherwise, return the result we got.
*/
if ((result != TCL_CONVERT_NOSPACE) &&
!(result == TCL_CONVERT_MULTIBYTE && (flags & TCL_ENCODING_END))) {
Tcl_Size nBytesProcessed = (src - srcStart);
Tcl_Size i = soFar + encodingPtr->nullSize - 1;
/* Loop as DStringSetLength only stores one nul byte at a time */
while (i >= soFar) {
Tcl_DStringSetLength(dstPtr, i--);
}
if (errorLocPtr) {
/*
* Do not write error message into interpreter if caller
* wants to know error location.
*/
*errorLocPtr = result == TCL_OK ? TCL_INDEX_NONE : nBytesProcessed;
} else {
/* Caller wants error message on failure */
if (result != TCL_OK && interp != NULL) {
Tcl_Size pos = Tcl_NumUtfChars(srcStart, nBytesProcessed);
int ucs4;
char buf[TCL_INTEGER_SPACE];
TclUtfToUCS4(&srcStart[nBytesProcessed], &ucs4);
snprintf(buf, sizeof(buf), "%" TCL_Z_MODIFIER "u", nBytesProcessed);
Tcl_SetObjResult(
interp,
Tcl_ObjPrintf(
"unexpected character at index %" TCL_Z_MODIFIER
"u: 'U+%06X'",
pos,
ucs4));
|
| ︙ | ︙ | |||
2566 2567 2568 2569 2570 2571 2572 |
} else {
/* PROFILE_STRICT */
result = TCL_CONVERT_SYNTAX;
break;
}
} else {
/*
| | < | 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 |
} else {
/* PROFILE_STRICT */
result = TCL_CONVERT_SYNTAX;
break;
}
} else {
/*
* For output convert 0xC080 to a real null.
*/
*dst++ = 0;
src += 2;
}
} else if (!Tcl_UtfCharComplete(src, srcEnd - src)) {
/*
|
| ︙ | ︙ | |||
2783 2784 2785 2786 2787 2788 2789 |
break;
}
#if TCL_UTF_MAX < 4
int prev = ch;
#endif
if (flags & TCL_ENCODING_LE) {
| | | | 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 |
break;
}
#if TCL_UTF_MAX < 4
int prev = ch;
#endif
if (flags & TCL_ENCODING_LE) {
ch = (unsigned int)(src[3] & 0xFF) << 24 | (src[2] & 0xFF) << 16 | (src[1] & 0xFF) << 8 | (src[0] & 0xFF);
} else {
ch = (unsigned int)(src[0] & 0xFF) << 24 | (src[1] & 0xFF) << 16 | (src[2] & 0xFF) << 8 | (src[3] & 0xFF);
}
#if TCL_UTF_MAX < 4
if (HIGH_SURROGATE(prev) && !LOW_SURROGATE(ch)) {
/* Bug [10c2c17c32]. If Hi surrogate not followed by Lo surrogate, finish 3-byte UTF-8 */
dst += Tcl_UniCharToUtf(-1, dst);
}
#endif
|
| ︙ | ︙ | |||
2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 |
* Special case for 1-byte utf chars for speed. Make sure we work with
* unsigned short-size data.
*/
if ((unsigned)ch - 1 < 0x7F) {
*dst++ = (ch & 0xFF);
} else {
dst += Tcl_UniCharToUtf(ch, dst);
}
src += 4;
}
/*
* If we had a truncated code unit at the end AND this is the last
| > > > > > | 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 |
* Special case for 1-byte utf chars for speed. Make sure we work with
* unsigned short-size data.
*/
if ((unsigned)ch - 1 < 0x7F) {
*dst++ = (ch & 0xFF);
} else {
#if TCL_UTF_MAX < 4
if (!HIGH_SURROGATE(prev) && LOW_SURROGATE(ch)) {
*dst = 0; /* In case of lower surrogate, don't try to combine */
}
#endif
dst += Tcl_UniCharToUtf(ch, dst);
}
src += 4;
}
/*
* If we had a truncated code unit at the end AND this is the last
|
| ︙ | ︙ | |||
3471 3472 3473 3474 3475 3476 3477 |
ch = UNICODE_REPLACE_CHAR;
} else {
ch = (Tcl_UniChar)byte;
}
}
/*
| | | 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 |
ch = UNICODE_REPLACE_CHAR;
} else {
ch = (Tcl_UniChar)byte;
}
}
/*
* Special case for 1-byte Utf chars for speed.
*/
if ((unsigned)ch - 1 < 0x7F) {
*dst++ = (char) ch;
} else {
dst += Tcl_UniCharToUtf(ch, dst);
}
|
| ︙ | ︙ |
Changes to generic/tclEnsemble.c.
| ︙ | ︙ | |||
102 103 104 105 106 107 108 |
/*
* The internal rep for caching ensemble subcommand lookups and spelling
* corrections.
*/
typedef struct {
| | | | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
/*
* The internal rep for caching ensemble subcommand lookups and spelling
* corrections.
*/
typedef struct {
Tcl_Size epoch; /* Used to confirm when the data in this
* really structure matches up with the
* ensemble. */
Command *token; /* Reference to the command for which this
* structure is a cache of the resolution. */
Tcl_Obj *fix; /* Corrected spelling, if needed. */
Tcl_HashEntry *hPtr; /* Direct link to entry in the subcommand hash
* table. */
} EnsembleCmdRep;
static inline Tcl_Obj *
NewNsObj(
Tcl_Namespace *namespacePtr)
{
Namespace *nsPtr = (Namespace *) namespacePtr;
if (namespacePtr == TclGetGlobalNamespace(nsPtr->interp)) {
return Tcl_NewStringObj("::", 2);
}
return Tcl_NewStringObj(nsPtr->fullName, -1);
}
/*
*----------------------------------------------------------------------
*
* TclNamespaceEnsembleCmd --
*
|
| ︙ | ︙ | |||
185 186 187 188 189 190 191 |
"subcommand", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
switch (index) {
case ENS_CREATE: {
const char *name;
| | | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
"subcommand", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
switch (index) {
case ENS_CREATE: {
const char *name;
Tcl_Size len;
int allocatedMapFlag = 0;
/*
* Defaults
*/
Tcl_Obj *subcmdObj = NULL;
Tcl_Obj *mapObj = NULL;
int permitPrefix = 1;
|
| ︙ | ︙ | |||
285 286 287 288 289 290 291 |
Tcl_DecrRefCount(mapObj);
}
return TCL_ERROR;
}
if (len < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"ensemble subcommand implementations "
| | | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
Tcl_DecrRefCount(mapObj);
}
return TCL_ERROR;
}
if (len < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"ensemble subcommand implementations "
"must be non-empty lists", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE",
"EMPTY_TARGET", NULL);
Tcl_DictObjDone(&search);
if (patchedDict) {
Tcl_DecrRefCount(patchedDict);
}
if (allocatedMapFlag) {
|
| ︙ | ︙ | |||
456 457 458 459 460 461 462 | Tcl_Obj *resultObj, *tmpObj = NULL; /* silence gcc 4 warning */ int flags = 0; /* silence gcc 4 warning */ TclNewObj(resultObj); /* -map option */ Tcl_ListObjAppendElement(NULL, resultObj, | | | | | | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
Tcl_Obj *resultObj, *tmpObj = NULL; /* silence gcc 4 warning */
int flags = 0; /* silence gcc 4 warning */
TclNewObj(resultObj);
/* -map option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(ensembleConfigOptions[CONF_MAP], -1));
Tcl_GetEnsembleMappingDict(NULL, token, &tmpObj);
Tcl_ListObjAppendElement(NULL, resultObj,
(tmpObj != NULL) ? tmpObj : Tcl_NewObj());
/* -namespace option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(ensembleConfigOptions[CONF_NAMESPACE],
-1));
namespacePtr = NULL; /* silence gcc 4 warning */
Tcl_GetEnsembleNamespace(NULL, token, &namespacePtr);
Tcl_ListObjAppendElement(NULL, resultObj, NewNsObj(namespacePtr));
/* -parameters option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(ensembleConfigOptions[CONF_PARAM], -1));
Tcl_GetEnsembleParameterList(NULL, token, &tmpObj);
Tcl_ListObjAppendElement(NULL, resultObj,
(tmpObj != NULL) ? tmpObj : Tcl_NewObj());
/* -prefix option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(ensembleConfigOptions[CONF_PREFIX], -1));
Tcl_GetEnsembleFlags(NULL, token, &flags);
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewBooleanObj(flags & TCL_ENSEMBLE_PREFIX));
/* -subcommands option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(ensembleConfigOptions[CONF_SUBCMDS],-1));
Tcl_GetEnsembleSubcommandList(NULL, token, &tmpObj);
Tcl_ListObjAppendElement(NULL, resultObj,
(tmpObj != NULL) ? tmpObj : Tcl_NewObj());
/* -unknown option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(ensembleConfigOptions[CONF_UNKNOWN],-1));
Tcl_GetEnsembleUnknownHandler(NULL, token, &tmpObj);
Tcl_ListObjAppendElement(NULL, resultObj,
(tmpObj != NULL) ? tmpObj : Tcl_NewObj());
Tcl_SetObjResult(interp, resultObj);
} else {
Tcl_Size len;
int allocatedMapFlag = 0;
Tcl_Obj *subcmdObj = NULL, *mapObj = NULL, *paramObj = NULL,
*unknownObj = NULL; /* Defaults, silence gcc 4 warnings */
int permitPrefix, flags = 0; /* silence gcc 4 warning */
Tcl_GetEnsembleSubcommandList(NULL, token, &subcmdObj);
Tcl_GetEnsembleMappingDict(NULL, token, &mapObj);
|
| ︙ | ︙ | |||
573 574 575 576 577 578 579 |
Tcl_DecrRefCount(patchedDict);
}
goto freeMapAndError;
}
if (len < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"ensemble subcommand implementations "
| | | 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
Tcl_DecrRefCount(patchedDict);
}
goto freeMapAndError;
}
if (len < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"ensemble subcommand implementations "
"must be non-empty lists", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE",
"EMPTY_TARGET", NULL);
Tcl_DictObjDone(&search);
if (patchedDict) {
Tcl_DecrRefCount(patchedDict);
}
goto freeMapAndError;
|
| ︙ | ︙ | |||
621 622 623 624 625 626 627 |
if (patchedDict) {
allocatedMapFlag = 1;
}
continue;
}
case CONF_NAMESPACE:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
if (patchedDict) {
allocatedMapFlag = 1;
}
continue;
}
case CONF_NAMESPACE:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"option -namespace is read-only", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "READ_ONLY",
NULL);
goto freeMapAndError;
case CONF_PREFIX:
if (Tcl_GetBooleanFromObj(interp, objv[1],
&permitPrefix) != TCL_OK) {
goto freeMapAndError;
|
| ︙ | ︙ | |||
794 795 796 797 798 799 800 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldList;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldList;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
return TCL_ERROR;
}
if (subcmdList != NULL) {
Tcl_Size length;
if (TclListObjLengthM(interp, subcmdList, &length) != TCL_OK) {
return TCL_ERROR;
}
if (length < 1) {
subcmdList = NULL;
}
|
| ︙ | ︙ | |||
866 867 868 869 870 871 872 |
Tcl_Interp *interp,
Tcl_Command token,
Tcl_Obj *paramList)
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldList;
| | | | 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
Tcl_Interp *interp,
Tcl_Command token,
Tcl_Obj *paramList)
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldList;
Tcl_Size length;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
return TCL_ERROR;
}
if (paramList == NULL) {
length = 0;
} else {
if (TclListObjLengthM(interp, paramList, &length) != TCL_OK) {
|
| ︙ | ︙ | |||
946 947 948 949 950 951 952 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldDict;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldDict;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
return TCL_ERROR;
}
if (mapDict != NULL) {
Tcl_Size size;
int done;
Tcl_DictSearch search;
Tcl_Obj *valuePtr;
if (Tcl_DictObjSize(interp, mapDict, &size) != TCL_OK) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1046 1047 1048 1049 1050 1051 1052 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldList;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldList;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
return TCL_ERROR;
}
if (unknownList != NULL) {
Tcl_Size length;
if (TclListObjLengthM(interp, unknownList, &length) != TCL_OK) {
return TCL_ERROR;
}
if (length < 1) {
unknownList = NULL;
}
|
| ︙ | ︙ | |||
1112 1113 1114 1115 1116 1117 1118 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
int wasCompiled;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
int wasCompiled;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
return TCL_ERROR;
}
ensemblePtr = (EnsembleConfig *)cmdPtr->objClientData;
wasCompiled = ensemblePtr->flags & ENSEMBLE_COMPILE;
|
| ︙ | ︙ | |||
1189 1190 1191 1192 1193 1194 1195 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
}
return TCL_ERROR;
}
ensemblePtr = (EnsembleConfig *)cmdPtr->objClientData;
*subcmdListPtr = ensemblePtr->subcmdList;
|
| ︙ | ︙ | |||
1231 1232 1233 1234 1235 1236 1237 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
}
return TCL_ERROR;
}
ensemblePtr = (EnsembleConfig *)cmdPtr->objClientData;
*paramListPtr = ensemblePtr->parameterList;
|
| ︙ | ︙ | |||
1273 1274 1275 1276 1277 1278 1279 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
}
return TCL_ERROR;
}
ensemblePtr = (EnsembleConfig *)cmdPtr->objClientData;
*mapDictPtr = ensemblePtr->subcommandDict;
|
| ︙ | ︙ | |||
1314 1315 1316 1317 1318 1319 1320 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
}
return TCL_ERROR;
}
ensemblePtr = (EnsembleConfig *)cmdPtr->objClientData;
*unknownListPtr = ensemblePtr->unknownHandler;
|
| ︙ | ︙ | |||
1355 1356 1357 1358 1359 1360 1361 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
}
return TCL_ERROR;
}
ensemblePtr = (EnsembleConfig *)cmdPtr->objClientData;
*flagsPtr = ensemblePtr->flags;
|
| ︙ | ︙ | |||
1396 1397 1398 1399 1400 1401 1402 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 |
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
}
return TCL_ERROR;
}
ensemblePtr = (EnsembleConfig *)cmdPtr->objClientData;
*namespacePtrPtr = (Tcl_Namespace *) ensemblePtr->nsPtr;
|
| ︙ | ︙ | |||
1535 1536 1537 1538 1539 1540 1541 |
const EnsembleImplMap map[]) /* The subcommands to create */
{
Tcl_Command ensemble;
Tcl_Namespace *ns;
Tcl_DString buf, hiddenBuf;
const char **nameParts = NULL;
const char *cmdName = NULL;
| | | | | | 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 |
const EnsembleImplMap map[]) /* The subcommands to create */
{
Tcl_Command ensemble;
Tcl_Namespace *ns;
Tcl_DString buf, hiddenBuf;
const char **nameParts = NULL;
const char *cmdName = NULL;
Tcl_Size i, nameCount = 0;
int ensembleFlags = 0, hiddenLen;
/*
* Construct the path for the ensemble namespace and create it.
*/
Tcl_DStringInit(&buf);
Tcl_DStringInit(&hiddenBuf);
TclDStringAppendLiteral(&hiddenBuf, "tcl:");
Tcl_DStringAppend(&hiddenBuf, name, -1);
TclDStringAppendLiteral(&hiddenBuf, ":");
hiddenLen = Tcl_DStringLength(&hiddenBuf);
if (name[0] == ':' && name[1] == ':') {
/*
* An absolute name, so use it directly.
*/
cmdName = name;
Tcl_DStringAppend(&buf, name, -1);
ensembleFlags = TCL_ENSEMBLE_PREFIX;
} else {
/*
* Not an absolute name, so do munging of it. Note that this treats a
* multi-word list differently to a single word.
*/
TclDStringAppendLiteral(&buf, "::tcl");
if (Tcl_SplitList(NULL, name, &nameCount, &nameParts) != TCL_OK) {
Tcl_Panic("invalid ensemble name '%s'", name);
}
for (i = 0; i < nameCount; ++i) {
TclDStringAppendLiteral(&buf, "::");
Tcl_DStringAppend(&buf, nameParts[i], -1);
}
}
ns = Tcl_FindNamespace(interp, Tcl_DStringValue(&buf), NULL,
TCL_CREATE_NS_IF_UNKNOWN);
if (!ns) {
Tcl_Panic("unable to find or create %s namespace!",
|
| ︙ | ︙ | |||
1615 1616 1617 1618 1619 1620 1621 |
if (ensemble != NULL) {
Tcl_Obj *mapDict, *fromObj, *toObj;
Command *cmdPtr;
TclDStringAppendLiteral(&buf, "::");
TclNewObj(mapDict);
for (i=0 ; map[i].name != NULL ; i++) {
| | | | | 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 |
if (ensemble != NULL) {
Tcl_Obj *mapDict, *fromObj, *toObj;
Command *cmdPtr;
TclDStringAppendLiteral(&buf, "::");
TclNewObj(mapDict);
for (i=0 ; map[i].name != NULL ; i++) {
fromObj = Tcl_NewStringObj(map[i].name, -1);
TclNewStringObj(toObj, Tcl_DStringValue(&buf),
Tcl_DStringLength(&buf));
Tcl_AppendToObj(toObj, map[i].name, -1);
Tcl_DictObjPut(NULL, mapDict, fromObj, toObj);
if (map[i].proc || map[i].nreProc) {
/*
* If the command is unsafe, hide it when we're in a safe
* interpreter. The code to do this is really hokey! It also
* doesn't work properly yet; this function is always
* currently called before the safe-interp flag is set so the
* Tcl_IsSafe check fails.
*/
if (map[i].unsafe && Tcl_IsSafe(interp)) {
cmdPtr = (Command *)
Tcl_NRCreateCommand(interp, "___tmp", map[i].proc,
map[i].nreProc, map[i].clientData, NULL);
Tcl_DStringSetLength(&hiddenBuf, hiddenLen);
if (Tcl_HideCommand(interp, "___tmp",
Tcl_DStringAppend(&hiddenBuf, map[i].name, -1))) {
Tcl_Panic("%s", Tcl_GetStringResult(interp));
}
} else {
/*
* Not hidden, so just create it. Yay!
*/
|
| ︙ | ︙ | |||
1714 1715 1716 1717 1718 1719 1720 |
* subcommand. */
Tcl_HashEntry *hPtr; /* Used for efficient lookup of fully
* specified but not yet cached command
* names. */
int reparseCount = 0; /* Number of reparses. */
Tcl_Obj *errorObj; /* Used for building error messages. */
Tcl_Obj *subObj;
| | | | | | 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 |
* subcommand. */
Tcl_HashEntry *hPtr; /* Used for efficient lookup of fully
* specified but not yet cached command
* names. */
int reparseCount = 0; /* Number of reparses. */
Tcl_Obj *errorObj; /* Used for building error messages. */
Tcl_Obj *subObj;
Tcl_Size subIdx;
/*
* Must recheck objc since numParameters might have changed. See test
* namespace-53.9.
*/
restartEnsembleParse:
subIdx = 1 + ensemblePtr->numParameters;
if (objc < subIdx + 1) {
/*
* No subcommand argument. Make error message.
*/
Tcl_DString buf; /* Message being built */
Tcl_DStringInit(&buf);
if (ensemblePtr->parameterList) {
Tcl_DStringAppend(&buf,
TclGetString(ensemblePtr->parameterList), -1);
TclDStringAppendLiteral(&buf, " ");
}
TclDStringAppendLiteral(&buf, "subcommand ?arg ...?");
Tcl_WrongNumArgs(interp, 1, objv, Tcl_DStringValue(&buf));
Tcl_DStringFree(&buf);
return TCL_ERROR;
}
if (ensemblePtr->nsPtr->flags & NS_DEAD) {
/*
* Don't know how we got here, but make things give up quickly.
*/
if (!Tcl_InterpDeleted(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"ensemble activated for deleted namespace", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "DEAD", NULL);
}
return TCL_ERROR;
}
/*
* If the table of subcommands is valid just lookup up the command there
|
| ︙ | ︙ | |||
1817 1818 1819 1820 1821 1822 1823 | * the export table, scan the sorted array for matches. */ const char *subcmdName; /* Name of the subcommand or unique prefix of * it (a non-unique prefix produces an error). */ char *fullName = NULL; /* Full name of the subcommand. */ | | | | 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 |
* the export table, scan the sorted array for matches.
*/
const char *subcmdName; /* Name of the subcommand or unique prefix of
* it (a non-unique prefix produces an error).
*/
char *fullName = NULL; /* Full name of the subcommand. */
Tcl_Size stringLength, i;
Tcl_Size tableLength = ensemblePtr->subcommandTable.numEntries;
Tcl_Obj *fix;
subcmdName = Tcl_GetStringFromObj(subObj, &stringLength);
for (i=0 ; i<tableLength ; i++) {
int cmp = strncmp(subcmdName,
ensemblePtr->subcommandArrayPtr[i],
stringLength);
|
| ︙ | ︙ | |||
1865 1866 1867 1868 1869 1870 1871 | fullName); } /* * Record the spelling correction for usage message. */ | | | 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 | fullName); } /* * Record the spelling correction for usage message. */ fix = Tcl_NewStringObj(fullName, -1); /* * Cache for later in the subcommand object. */ MakeCachedEnsembleCommand(subObj, ensemblePtr, hPtr, fix); TclSpellFix(interp, objv, objc, subIdx, subObj, fix); |
| ︙ | ︙ | |||
1888 1889 1890 1891 1892 1893 1894 |
* not be the same length as the number of arguments to this ensemble
* command, and then handing it to the main command-lookup engine. In
* theory, the command could be looked up right here using the namespace in
* which it is guaranteed to exist,
*
* ((Q: That's not true if the -map option is used, is it?))
*
| | | | 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 |
* not be the same length as the number of arguments to this ensemble
* command, and then handing it to the main command-lookup engine. In
* theory, the command could be looked up right here using the namespace in
* which it is guaranteed to exist,
*
* ((Q: That's not true if the -map option is used, is it?))
*
* but don't do that because caching of the command object should help.
*/
{
Tcl_Obj *copyPtr; /* The list of words to dispatch on.
* Will be freed by the dispatch engine. */
Tcl_Obj **copyObjv;
Tcl_Size copyObjc, prefixObjc;
TclListObjLengthM(NULL, prefixObj, &prefixObjc);
if (objc == 2) {
copyPtr = TclListObjCopy(NULL, prefixObj);
} else {
copyPtr = Tcl_NewListObj(objc - 2 + prefixObjc, NULL);
|
| ︙ | ︙ | |||
1976 1977 1978 1979 1980 1981 1982 |
ensemblePtr->nsPtr->fullName));
return TCL_ERROR;
}
errorObj = Tcl_ObjPrintf("unknown%s subcommand \"%s\": must be ",
(ensemblePtr->flags & TCL_ENSEMBLE_PREFIX ? " or ambiguous" : ""),
TclGetString(subObj));
if (ensemblePtr->subcommandTable.numEntries == 1) {
| | | | | 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 |
ensemblePtr->nsPtr->fullName));
return TCL_ERROR;
}
errorObj = Tcl_ObjPrintf("unknown%s subcommand \"%s\": must be ",
(ensemblePtr->flags & TCL_ENSEMBLE_PREFIX ? " or ambiguous" : ""),
TclGetString(subObj));
if (ensemblePtr->subcommandTable.numEntries == 1) {
Tcl_AppendToObj(errorObj, ensemblePtr->subcommandArrayPtr[0], -1);
} else {
Tcl_Size i;
for (i=0 ; i<ensemblePtr->subcommandTable.numEntries-1 ; i++) {
Tcl_AppendToObj(errorObj, ensemblePtr->subcommandArrayPtr[i], -1);
Tcl_AppendToObj(errorObj, ", ", 2);
}
Tcl_AppendPrintfToObj(errorObj, "or %s",
ensemblePtr->subcommandArrayPtr[i]);
}
Tcl_SetObjResult(interp, errorObj);
return TCL_ERROR;
|
| ︙ | ︙ | |||
2023 2024 2025 2026 2027 2028 2029 |
*
*----------------------------------------------------------------------
*/
int
TclInitRewriteEnsemble(
Tcl_Interp *interp,
| | | | | 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 |
*
*----------------------------------------------------------------------
*/
int
TclInitRewriteEnsemble(
Tcl_Interp *interp,
Tcl_Size numRemoved,
Tcl_Size numInserted,
Tcl_Obj *const *objv)
{
Interp *iPtr = (Interp *) interp;
int isRootEnsemble = (iPtr->ensembleRewrite.sourceObjs == NULL);
if (isRootEnsemble) {
iPtr->ensembleRewrite.sourceObjs = objv;
iPtr->ensembleRewrite.numRemovedObjs = numRemoved;
iPtr->ensembleRewrite.numInsertedObjs = numInserted;
} else {
Tcl_Size numIns = iPtr->ensembleRewrite.numInsertedObjs;
if (numIns < numRemoved) {
iPtr->ensembleRewrite.numRemovedObjs += numRemoved - numIns;
iPtr->ensembleRewrite.numInsertedObjs = numInserted;
} else {
iPtr->ensembleRewrite.numInsertedObjs += numInserted - numRemoved;
}
|
| ︙ | ︙ | |||
2115 2116 2117 2118 2119 2120 2121 |
return result;
}
void
TclSpellFix(
Tcl_Interp *interp,
Tcl_Obj *const *objv,
| | | | | | 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 |
return result;
}
void
TclSpellFix(
Tcl_Interp *interp,
Tcl_Obj *const *objv,
Tcl_Size objc,
Tcl_Size badIdx,
Tcl_Obj *bad,
Tcl_Obj *fix)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *const *search;
Tcl_Obj **store;
Tcl_Size idx;
Tcl_Size size;
if (iPtr->ensembleRewrite.sourceObjs == NULL) {
iPtr->ensembleRewrite.sourceObjs = objv;
iPtr->ensembleRewrite.numRemovedObjs = 0;
iPtr->ensembleRewrite.numInsertedObjs = 0;
}
|
| ︙ | ︙ | |||
2240 2241 2242 2243 2244 2245 2246 |
*----------------------------------------------------------------------
*/
Tcl_Obj *const *
TclFetchEnsembleRoot(
Tcl_Interp *interp,
Tcl_Obj *const *objv,
| | | | 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 |
*----------------------------------------------------------------------
*/
Tcl_Obj *const *
TclFetchEnsembleRoot(
Tcl_Interp *interp,
Tcl_Obj *const *objv,
Tcl_Size objc,
Tcl_Size *objcPtr)
{
Tcl_Obj *const *sourceObjs;
Interp *iPtr = (Interp *) interp;
if (iPtr->ensembleRewrite.sourceObjs) {
*objcPtr = objc + iPtr->ensembleRewrite.numRemovedObjs
- iPtr->ensembleRewrite.numInsertedObjs;
|
| ︙ | ︙ | |||
2291 2292 2293 2294 2295 2296 2297 |
EnsembleUnknownCallback(
Tcl_Interp *interp,
EnsembleConfig *ensemblePtr,
int objc,
Tcl_Obj *const objv[],
Tcl_Obj **prefixObjPtr)
{
| | | | | | 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 |
EnsembleUnknownCallback(
Tcl_Interp *interp,
EnsembleConfig *ensemblePtr,
int objc,
Tcl_Obj *const objv[],
Tcl_Obj **prefixObjPtr)
{
Tcl_Size paramc;
int result;
Tcl_Size i, prefixObjc;
Tcl_Obj **paramv, *unknownCmd, *ensObj;
/*
* Create the "unknown" command callback to determine what to do.
*/
unknownCmd = Tcl_DuplicateObj(ensemblePtr->unknownHandler);
TclNewObj(ensObj);
Tcl_GetCommandFullName(interp, ensemblePtr->token, ensObj);
Tcl_ListObjAppendElement(NULL, unknownCmd, ensObj);
for (i = 1 ; i < objc ; i++) {
Tcl_ListObjAppendElement(NULL, unknownCmd, objv[i]);
}
TclListObjGetElementsM(NULL, unknownCmd, ¶mc, ¶mv);
Tcl_IncrRefCount(unknownCmd);
/*
* Call the "unknown" handler. No attempt to NRE-enable this as deep
* recursion through unknown handlers is perverse. It is always an error
* for an unknown handler to delete its ensemble. Don't do that.
*/
Tcl_Preserve(ensemblePtr);
TclSkipTailcall(interp);
result = Tcl_EvalObjv(interp, paramc, paramv, 0);
if ((result == TCL_OK) && (ensemblePtr->flags & ENSEMBLE_DEAD)) {
if (!Tcl_InterpDeleted(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unknown subcommand handler deleted its ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "UNKNOWN_DELETED",
NULL);
}
result = TCL_ERROR;
}
Tcl_Release(ensemblePtr);
|
| ︙ | ︙ | |||
2370 2371 2372 2373 2374 2375 2376 |
* Convert exceptional result to an error.
*/
if (!Tcl_InterpDeleted(interp)) {
if (result != TCL_ERROR) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | | 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 |
* Convert exceptional result to an error.
*/
if (!Tcl_InterpDeleted(interp)) {
if (result != TCL_ERROR) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unknown subcommand handler returned bad code: ", -1));
switch (result) {
case TCL_RETURN:
Tcl_AppendToObj(Tcl_GetObjResult(interp), "return", -1);
break;
case TCL_BREAK:
Tcl_AppendToObj(Tcl_GetObjResult(interp), "break", -1);
break;
case TCL_CONTINUE:
Tcl_AppendToObj(Tcl_GetObjResult(interp), "continue", -1);
break;
default:
Tcl_AppendPrintfToObj(Tcl_GetObjResult(interp), "%d", result);
}
Tcl_AddErrorInfo(interp, "\n result of "
"ensemble unknown subcommand handler: ");
Tcl_AppendObjToErrorInfo(interp, unknownCmd);
|
| ︙ | ︙ | |||
2581 2582 2583 2584 2585 2586 2587 |
static void
BuildEnsembleConfig(
EnsembleConfig *ensemblePtr)
{
Tcl_HashSearch search; /* Used for scanning the commands in
* the namespace for this ensemble. */
| | | | 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 |
static void
BuildEnsembleConfig(
EnsembleConfig *ensemblePtr)
{
Tcl_HashSearch search; /* Used for scanning the commands in
* the namespace for this ensemble. */
Tcl_Size i, j;
int isNew;
Tcl_HashTable *hash = &ensemblePtr->subcommandTable;
Tcl_HashEntry *hPtr;
Tcl_Obj *mapDict = ensemblePtr->subcommandDict;
Tcl_Obj *subList = ensemblePtr->subcmdList;
ClearTable(ensemblePtr);
Tcl_InitHashTable(hash, TCL_STRING_KEYS);
if (subList) {
Tcl_Size subc;
Tcl_Obj **subv, *target, *cmdObj, *cmdPrefixObj;
const char *name;
/*
* There is a list of exactly what subcommands go in the table.
* Determine the target for each.
*/
|
| ︙ | ︙ | |||
2621 2622 2623 2624 2625 2626 2627 |
}
Tcl_SetHashValue(hPtr, subv[i+1]);
Tcl_IncrRefCount(subv[i+1]);
name = TclGetString(subv[i+1]);
hPtr = Tcl_CreateHashEntry(hash, name, &isNew);
if (isNew) {
| | | 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 |
}
Tcl_SetHashValue(hPtr, subv[i+1]);
Tcl_IncrRefCount(subv[i+1]);
name = TclGetString(subv[i+1]);
hPtr = Tcl_CreateHashEntry(hash, name, &isNew);
if (isNew) {
cmdObj = Tcl_NewStringObj(name, -1);
cmdPrefixObj = Tcl_NewListObj(1, &cmdObj);
Tcl_SetHashValue(hPtr, cmdPrefixObj);
Tcl_IncrRefCount(cmdPrefixObj);
}
}
} else {
/*
|
| ︙ | ︙ | |||
2659 2660 2661 2662 2663 2664 2665 |
/*
* Target was not in the dictionary. Map onto the namespace.
* In this case there is no guarantee that the command
* is actually there. It is the responsibility of the
* programmer (or [::unknown] of course) to provide the procedure.
*/
| | | 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 |
/*
* Target was not in the dictionary. Map onto the namespace.
* In this case there is no guarantee that the command
* is actually there. It is the responsibility of the
* programmer (or [::unknown] of course) to provide the procedure.
*/
cmdObj = Tcl_NewStringObj(name, -1);
cmdPrefixObj = Tcl_NewListObj(1, &cmdObj);
Tcl_SetHashValue(hPtr, cmdPrefixObj);
Tcl_IncrRefCount(cmdPrefixObj);
}
}
} else if (mapDict) {
/*
|
| ︙ | ︙ | |||
2924 2925 2926 2927 2928 2929 2930 |
Tcl_Token *tokenPtr = TokenAfter(parsePtr->tokenPtr);
Tcl_Obj *mapObj, *subcmdObj, *targetCmdObj, *listObj, **elems;
Tcl_Obj *replaced, *replacement;
Tcl_Command ensemble = (Tcl_Command) cmdPtr;
Command *oldCmdPtr = cmdPtr, *newCmdPtr;
int result, flags = 0, depth = 1, invokeAnyway = 0;
int ourResult = TCL_ERROR;
| | | | 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 |
Tcl_Token *tokenPtr = TokenAfter(parsePtr->tokenPtr);
Tcl_Obj *mapObj, *subcmdObj, *targetCmdObj, *listObj, **elems;
Tcl_Obj *replaced, *replacement;
Tcl_Command ensemble = (Tcl_Command) cmdPtr;
Command *oldCmdPtr = cmdPtr, *newCmdPtr;
int result, flags = 0, depth = 1, invokeAnyway = 0;
int ourResult = TCL_ERROR;
Tcl_Size i, len, numBytes;
const char *word;
TclNewObj(replaced);
Tcl_IncrRefCount(replaced);
if (parsePtr->numWords <= depth) {
goto failed;
}
if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) {
/*
* Too hard.
*/
|
| ︙ | ︙ | |||
2994 2995 2996 2997 2998 2999 3000 |
* Check to see if there's also a subcommand list; must check to see if
* the subcommand we are calling is in that list if it exists, since that
* list filters the entries in the map.
*/
(void) Tcl_GetEnsembleSubcommandList(NULL, ensemble, &listObj);
if (listObj != NULL) {
| | | 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 |
* Check to see if there's also a subcommand list; must check to see if
* the subcommand we are calling is in that list if it exists, since that
* list filters the entries in the map.
*/
(void) Tcl_GetEnsembleSubcommandList(NULL, ensemble, &listObj);
if (listObj != NULL) {
Tcl_Size sclen;
const char *str;
Tcl_Obj *matchObj = NULL;
if (TclListObjGetElementsM(NULL, listObj, &len, &elems) != TCL_OK) {
goto failed;
}
for (i=0 ; i<len ; i++) {
|
| ︙ | ︙ | |||
3251 3252 3253 3254 3255 3256 3257 |
return ourResult;
}
int
TclAttemptCompileProc(
Tcl_Interp *interp,
Tcl_Parse *parsePtr,
| | | | | | | | 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 |
return ourResult;
}
int
TclAttemptCompileProc(
Tcl_Interp *interp,
Tcl_Parse *parsePtr,
Tcl_Size depth,
Command *cmdPtr,
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation;
int result;
Tcl_Size i;
Tcl_Token *saveTokenPtr = parsePtr->tokenPtr;
Tcl_Size savedStackDepth = envPtr->currStackDepth;
unsigned savedCodeNext = envPtr->codeNext - envPtr->codeStart;
Tcl_Size savedAuxDataArrayNext = envPtr->auxDataArrayNext;
Tcl_Size savedExceptArrayNext = envPtr->exceptArrayNext;
#ifdef TCL_COMPILE_DEBUG
Tcl_Size savedExceptDepth = envPtr->exceptDepth;
#endif
if (cmdPtr->compileProc == NULL) {
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
3394 3395 3396 3397 3398 3399 3400 |
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation;
Tcl_Token *tokPtr;
Tcl_Obj *objPtr, **words;
const char *bytes;
int cmdLit, extraLiteralFlags = LITERAL_CMD_NAME;
| | | 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 |
CompileEnv *envPtr) /* Holds resulting instructions. */
{
DefineLineInformation;
Tcl_Token *tokPtr;
Tcl_Obj *objPtr, **words;
const char *bytes;
int cmdLit, extraLiteralFlags = LITERAL_CMD_NAME;
Tcl_Size i, numWords, length;
/*
* Push the words of the command. Take care; the command words may be
* scripts that have backslashes in them, and [info frame 0] can see the
* difference. Hence the call to TclContinuationsEnterDerived...
*/
|
| ︙ | ︙ |
Changes to generic/tclEnv.c.
| ︙ | ︙ | |||
46 47 48 49 50 51 52 |
char **cache; /* Array containing all of the environment
* strings that Tcl has allocated. */
#ifndef USE_PUTENV
techar **ourEnviron; /* Cache of the array that we allocate. We
* need to track this in case another
* subsystem swaps around the environ array
* like we do. */
| | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
char **cache; /* Array containing all of the environment
* strings that Tcl has allocated. */
#ifndef USE_PUTENV
techar **ourEnviron; /* Cache of the array that we allocate. We
* need to track this in case another
* subsystem swaps around the environ array
* like we do. */
Tcl_Size ourEnvironSize; /* Non-zero means that the environ array was
* malloced and has this many total entries
* allocated to it (not all may be in use at
* once). Zero means that the environment
* array is in its original static state. */
#endif
} env;
|
| ︙ | ︙ | |||
181 182 183 184 185 186 187 |
if (strcasecmp(p1, "PATH") == 0) {
p1 = "PATH";
} else if (strcasecmp(p1, "COMSPEC") == 0) {
p1 = "COMSPEC";
}
#endif
| | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
if (strcasecmp(p1, "PATH") == 0) {
p1 = "PATH";
} else if (strcasecmp(p1, "COMSPEC") == 0) {
p1 = "COMSPEC";
}
#endif
obj1 = Tcl_NewStringObj(p1, -1);
obj2 = Tcl_NewStringObj(p2, -1);
Tcl_DStringFree(&envString);
Tcl_IncrRefCount(obj1);
Tcl_IncrRefCount(obj2);
Tcl_ObjSetVar2(interp, varNamePtr, obj1, obj2, TCL_GLOBAL_ONLY);
hPtr = Tcl_FindHashEntry(&namesHash, obj1);
if (hPtr != NULL) {
|
| ︙ | ︙ | |||
249 250 251 252 253 254 255 |
void
TclSetEnv(
const char *name, /* Name of variable whose value is to be set
* (UTF-8). */
const char *value) /* New value for variable (UTF-8). */
{
Tcl_DString envString;
| | | | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
void
TclSetEnv(
const char *name, /* Name of variable whose value is to be set
* (UTF-8). */
const char *value) /* New value for variable (UTF-8). */
{
Tcl_DString envString;
Tcl_Size nameLength, valueLength;
Tcl_Size index, length;
char *p, *oldValue;
const techar *p2;
/*
* Figure out where the entry is going to go. If the name doesn't already
* exist, enlarge the array if necessary to make room. If the name exists,
* free its old entry.
|
| ︙ | ︙ | |||
398 399 400 401 402 403 404 |
char *value;
if (assignment == NULL) {
return 0;
}
/*
| | | 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
char *value;
if (assignment == NULL) {
return 0;
}
/*
* First convert the native string to Utf. Then separate the string into
* name and value parts, and call TclSetEnv to do all of the real work.
*/
name = Tcl_ExternalToUtfDString(NULL, assignment, TCL_INDEX_NONE, &nameString);
value = (char *)strchr(name, '=');
if ((value != NULL) && (value != name)) {
|
| ︙ | ︙ | |||
449 450 451 452 453 454 455 |
*/
void
TclUnsetEnv(
const char *name) /* Name of variable to remove (UTF-8). */
{
char *oldValue;
| | | | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
*/
void
TclUnsetEnv(
const char *name) /* Name of variable to remove (UTF-8). */
{
char *oldValue;
Tcl_Size length, index;
#ifdef USE_PUTENV_FOR_UNSET
Tcl_DString envString;
char *string;
#else
char **envPtr;
#endif /* USE_PUTENV_FOR_UNSET */
Tcl_MutexLock(&envMutex);
index = TclpFindVariable(name, &length);
/*
* First make sure that the environment variable exists to avoid doing
* needless work and to avoid recursion on the unset.
*/
if (index == -1) {
Tcl_MutexUnlock(&envMutex);
return;
}
/*
* Remember the old value so we can free it if Tcl created the string.
*/
|
| ︙ | ︙ | |||
564 565 566 567 568 569 570 |
TclGetEnv(
const char *name, /* Name of environment variable to find
* (UTF-8). */
Tcl_DString *valuePtr) /* Uninitialized or free DString in which the
* value of the environment variable is
* stored. */
{
| | | | | 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
TclGetEnv(
const char *name, /* Name of environment variable to find
* (UTF-8). */
Tcl_DString *valuePtr) /* Uninitialized or free DString in which the
* value of the environment variable is
* stored. */
{
Tcl_Size length, index;
const char *result;
Tcl_MutexLock(&envMutex);
index = TclpFindVariable(name, &length);
result = NULL;
if (index != -1) {
Tcl_DString envStr;
result = tenviron2utfdstr(tenviron[index], -1, &envStr);
result += length;
if (*result == '=') {
result++;
Tcl_DStringInit(valuePtr);
Tcl_DStringAppend(valuePtr, result, -1);
result = Tcl_DStringValue(valuePtr);
} else {
result = NULL;
}
Tcl_DStringFree(&envStr);
}
Tcl_MutexUnlock(&envMutex);
|
| ︙ | ︙ |
Changes to generic/tclEvent.c.
| ︙ | ︙ | |||
220 221 222 223 224 225 226 |
* that could lead us here.
*/
Tcl_Preserve(assocPtr);
Tcl_Preserve(interp);
while (assocPtr->firstBgPtr != NULL) {
int code;
| | | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
* that could lead us here.
*/
Tcl_Preserve(assocPtr);
Tcl_Preserve(interp);
while (assocPtr->firstBgPtr != NULL) {
int code;
Tcl_Size prefixObjc;
Tcl_Obj **prefixObjv, **tempObjv;
/*
* Note we copy the handler command prefix each pass through, so we do
* support one handler setting another handler.
*/
|
| ︙ | ︙ | |||
277 278 279 280 281 282 283 | TclNewLiteralStringObj(keyPtr, "-errorinfo"); Tcl_IncrRefCount(keyPtr); Tcl_DictObjGet(NULL, options, keyPtr, &valuePtr); Tcl_DecrRefCount(keyPtr); Tcl_WriteChars(errChannel, | | | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
TclNewLiteralStringObj(keyPtr, "-errorinfo");
Tcl_IncrRefCount(keyPtr);
Tcl_DictObjGet(NULL, options, keyPtr, &valuePtr);
Tcl_DecrRefCount(keyPtr);
Tcl_WriteChars(errChannel,
"error in background error handler:\n", -1);
if (valuePtr) {
Tcl_WriteObj(errChannel, valuePtr);
} else {
Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp));
}
Tcl_WriteChars(errChannel, "\n", 1);
Tcl_Flush(errChannel);
|
| ︙ | ︙ | |||
339 340 341 342 343 344 345 |
TclNewLiteralStringObj(keyPtr, "-level");
Tcl_IncrRefCount(keyPtr);
result = Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
Tcl_DecrRefCount(keyPtr);
if (result != TCL_OK || valuePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
TclNewLiteralStringObj(keyPtr, "-level");
Tcl_IncrRefCount(keyPtr);
result = Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
Tcl_DecrRefCount(keyPtr);
if (result != TCL_OK || valuePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing return option \"-level\"", -1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, valuePtr, &level) == TCL_ERROR) {
return TCL_ERROR;
}
TclNewLiteralStringObj(keyPtr, "-code");
Tcl_IncrRefCount(keyPtr);
result = Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
Tcl_DecrRefCount(keyPtr);
if (result != TCL_OK || valuePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing return option \"-code\"", -1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, valuePtr, &code) == TCL_ERROR) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
470 471 472 473 474 475 476 |
Tcl_IncrRefCount(resultPtr);
if (Tcl_FindCommand(interp, "bgerror", NULL,
TCL_GLOBAL_ONLY) == NULL) {
Tcl_RestoreInterpState(interp, saved);
Tcl_WriteObj(errChannel, Tcl_GetVar2Ex(interp,
"errorInfo", NULL, TCL_GLOBAL_ONLY));
| | | | | | | | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
Tcl_IncrRefCount(resultPtr);
if (Tcl_FindCommand(interp, "bgerror", NULL,
TCL_GLOBAL_ONLY) == NULL) {
Tcl_RestoreInterpState(interp, saved);
Tcl_WriteObj(errChannel, Tcl_GetVar2Ex(interp,
"errorInfo", NULL, TCL_GLOBAL_ONLY));
Tcl_WriteChars(errChannel, "\n", -1);
} else {
Tcl_DiscardInterpState(saved);
Tcl_WriteChars(errChannel,
"bgerror failed to handle background error.\n", -1);
Tcl_WriteChars(errChannel, " Original error: ", -1);
Tcl_WriteObj(errChannel, tempObjv[1]);
Tcl_WriteChars(errChannel, "\n", -1);
Tcl_WriteChars(errChannel, " Error in bgerror: ", -1);
Tcl_WriteObj(errChannel, resultPtr);
Tcl_WriteChars(errChannel, "\n", -1);
}
Tcl_DecrRefCount(resultPtr);
Tcl_Flush(errChannel);
} else {
Tcl_DiscardInterpState(saved);
}
}
|
| ︙ | ︙ | |||
585 586 587 588 589 590 591 | /* *---------------------------------------------------------------------- * * BgErrorDeleteProc -- * * This function is associated with the "tclBgError" assoc data for an * interpreter; it is invoked when the interpreter is deleted in order to | | | 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | /* *---------------------------------------------------------------------- * * BgErrorDeleteProc -- * * This function is associated with the "tclBgError" assoc data for an * interpreter; it is invoked when the interpreter is deleted in order to * free the information associated with any pending error reports. * * Results: * None. * * Side effects: * Background error information is freed: if there were any pending error * reports, they are canceled. |
| ︙ | ︙ | |||
953 954 955 956 957 958 959 |
Tcl_MutexLock(&exitMutex);
currentAppExitPtr = appExitPtr;
Tcl_MutexUnlock(&exitMutex);
/*
* Warning: this function SHOULD NOT return, as there is code that depends
* on Tcl_Exit never returning. In fact, we will Tcl_Panic if anyone
| | | 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
Tcl_MutexLock(&exitMutex);
currentAppExitPtr = appExitPtr;
Tcl_MutexUnlock(&exitMutex);
/*
* Warning: this function SHOULD NOT return, as there is code that depends
* on Tcl_Exit never returning. In fact, we will Tcl_Panic if anyone
* returns, so critical is this dependency.
*
* If subsystems are not (yet) initialized, proper Tcl-finalization is
* impossible, so fallback to system exit, see bug-[f8a33ce3db5d8cc2].
*/
if (currentAppExitPtr) {
|
| ︙ | ︙ | |||
1118 1119 1120 1121 1122 1123 1124 |
{
if (inExit != 0) {
Tcl_Panic("Tcl_InitSubsystems called while exiting");
}
if (subsystemsInitialized == 0) {
/*
| | | 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
{
if (inExit != 0) {
Tcl_Panic("Tcl_InitSubsystems called while exiting");
}
if (subsystemsInitialized == 0) {
/*
* Double check inside the mutex. There are definitely calls back into
* this routine from some of the functions below.
*/
TclpInitLock();
if (subsystemsInitialized == 0) {
/*
|
| ︙ | ︙ | |||
1568 1569 1570 1571 1572 1573 1574 |
if (Tcl_GetIntFromObj(interp, objv[i], &timeout) != TCL_OK) {
result = TCL_ERROR;
goto done;
}
if (timeout < 0) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 |
if (Tcl_GetIntFromObj(interp, objv[i], &timeout) != TCL_OK) {
result = TCL_ERROR;
goto done;
}
if (timeout < 0) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"timeout must be positive", -1));
Tcl_SetErrorCode(interp, "TCL", "EVENT", "NEGTIME", NULL);
result = TCL_ERROR;
goto done;
}
break;
case OPT_LAST:
i++;
|
| ︙ | ︙ | |||
1648 1649 1650 1651 1652 1653 1654 |
}
}
endOfOptionLoop:
if ((mask & (TCL_FILE_EVENTS | TCL_IDLE_EVENTS |
TCL_TIMER_EVENTS | TCL_WINDOW_EVENTS)) == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 |
}
}
endOfOptionLoop:
if ((mask & (TCL_FILE_EVENTS | TCL_IDLE_EVENTS |
TCL_TIMER_EVENTS | TCL_WINDOW_EVENTS)) == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't wait: would block forever", -1));
Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_SOURCES", NULL);
result = TCL_ERROR;
goto done;
}
if ((timeout > 0) && ((mask & TCL_TIMER_EVENTS) == 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"timer events disabled with timeout specified", -1));
Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_TIME", NULL);
result = TCL_ERROR;
goto done;
}
for (result = TCL_OK; i < objc; i++) {
result = Tcl_TraceVar2(interp, TclGetString(objv[i]), NULL,
|
| ︙ | ︙ | |||
1684 1685 1686 1687 1688 1689 1690 |
goto done;
}
if (!(mask & TCL_FILE_EVENTS)) {
for (i = 0; i < numItems; i++) {
if (vwaitItems[i].mask) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 |
goto done;
}
if (!(mask & TCL_FILE_EVENTS)) {
for (i = 0; i < numItems; i++) {
if (vwaitItems[i].mask) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"file events disabled with channel(s) specified", -1));
Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_FILE_EVENT", NULL);
result = TCL_ERROR;
goto done;
}
}
}
|
| ︙ | ︙ | |||
1723 1724 1725 1726 1727 1728 1729 |
((!any && (done < numItems)) || (any && !done))) {
foundEvent = Tcl_DoOneEvent(mask);
if (Tcl_Canceled(interp, TCL_LEAVE_ERR_MSG) == TCL_ERROR) {
break;
}
if (Tcl_LimitExceeded(interp)) {
Tcl_ResetResult(interp);
| | | 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 |
((!any && (done < numItems)) || (any && !done))) {
foundEvent = Tcl_DoOneEvent(mask);
if (Tcl_Canceled(interp, TCL_LEAVE_ERR_MSG) == TCL_ERROR) {
break;
}
if (Tcl_LimitExceeded(interp)) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj("limit exceeded", -1));
Tcl_SetErrorCode(interp, "TCL", "EVENT", "LIMIT", NULL);
break;
}
if ((numItems == 0) && (timeout == 0)) {
/*
* Behavior like "update": clear interpreter's result because
* event handlers could have executed commands.
|
| ︙ | ︙ | |||
1971 1972 1973 1974 1975 1976 1977 |
while (Tcl_DoOneEvent(flags) != 0) {
if (Tcl_Canceled(interp, TCL_LEAVE_ERR_MSG) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tcl_LimitExceeded(interp)) {
Tcl_ResetResult(interp);
| | | 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 |
while (Tcl_DoOneEvent(flags) != 0) {
if (Tcl_Canceled(interp, TCL_LEAVE_ERR_MSG) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tcl_LimitExceeded(interp)) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj("limit exceeded", -1));
return TCL_ERROR;
}
}
/*
* Must clear the interpreter's result because event handlers could have
* executed commands.
|
| ︙ | ︙ | |||
2043 2044 2045 2046 2047 2048 2049 |
*----------------------------------------------------------------------
*/
int
Tcl_CreateThread(
Tcl_ThreadId *idPtr, /* Return, the ID of the thread */
Tcl_ThreadCreateProc *proc, /* Main() function of the thread */
| | | | 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 |
*----------------------------------------------------------------------
*/
int
Tcl_CreateThread(
Tcl_ThreadId *idPtr, /* Return, the ID of the thread */
Tcl_ThreadCreateProc *proc, /* Main() function of the thread */
void *clientData, /* The one argument to Main() */
Tcl_Size stackSize, /* Size of stack for the new thread */
int flags) /* Flags controlling behaviour of the new
* thread. */
{
#if TCL_THREADS
ThreadClientData *cdPtr = (ThreadClientData *)Tcl_Alloc(sizeof(ThreadClientData));
int result;
|
| ︙ | ︙ |
Changes to generic/tclExecute.c.
| ︙ | ︙ | |||
630 631 632 633 634 635 636 | Tcl_Obj *valuePtr, Tcl_Obj *value2Ptr); static Tcl_Obj * ExecuteExtendedUnaryMathOp(int opcode, Tcl_Obj *valuePtr); static void FreeExprCodeInternalRep(Tcl_Obj *objPtr); static ExceptionRange * GetExceptRangeForPc(const unsigned char *pc, int searchMode, ByteCode *codePtr); static const char * GetSrcInfoForPc(const unsigned char *pc, | | | 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | Tcl_Obj *valuePtr, Tcl_Obj *value2Ptr); static Tcl_Obj * ExecuteExtendedUnaryMathOp(int opcode, Tcl_Obj *valuePtr); static void FreeExprCodeInternalRep(Tcl_Obj *objPtr); static ExceptionRange * GetExceptRangeForPc(const unsigned char *pc, int searchMode, ByteCode *codePtr); static const char * GetSrcInfoForPc(const unsigned char *pc, ByteCode *codePtr, Tcl_Size *lengthPtr, const unsigned char **pcBeg, int *cmdIdxPtr); static Tcl_Obj ** GrowEvaluationStack(ExecEnv *eePtr, size_t growth, int move); static void IllegalExprOperandType(Tcl_Interp *interp, const unsigned char *pc, Tcl_Obj *opndPtr); static void InitByteCodeExecution(Tcl_Interp *interp); static inline int wordSkip(void *ptr); |
| ︙ | ︙ | |||
1220 1221 1222 1223 1224 1225 1226 |
eePtr->execStackPtr = esPtr;
}
}
void *
TclStackAlloc(
Tcl_Interp *interp,
| | | | | | 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 |
eePtr->execStackPtr = esPtr;
}
}
void *
TclStackAlloc(
Tcl_Interp *interp,
Tcl_Size numBytes)
{
Interp *iPtr = (Interp *) interp;
Tcl_Size numWords;
if (iPtr == NULL || iPtr->execEnvPtr == NULL) {
return (void *) Tcl_Alloc(numBytes);
}
numWords = (numBytes + (sizeof(Tcl_Obj *) - 1))/sizeof(Tcl_Obj *);
return StackAllocWords(interp, numWords);
}
void *
TclStackRealloc(
Tcl_Interp *interp,
void *ptr,
Tcl_Size numBytes)
{
Interp *iPtr = (Interp *) interp;
ExecEnv *eePtr;
ExecStack *esPtr;
Tcl_Obj **markerPtr;
Tcl_Size numWords;
if (iPtr == NULL || iPtr->execEnvPtr == NULL) {
return Tcl_Realloc(ptr, numBytes);
}
eePtr = iPtr->execEnvPtr;
esPtr = eePtr->execStackPtr;
|
| ︙ | ︙ | |||
1433 1434 1435 1436 1437 1438 1439 |
}
if (codePtr == NULL) {
/*
* TIP #280: No invoker (yet) - Expression compilation.
*/
| | | 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 |
}
if (codePtr == NULL) {
/*
* TIP #280: No invoker (yet) - Expression compilation.
*/
Tcl_Size length;
const char *string = Tcl_GetStringFromObj(objPtr, &length);
TclInitCompileEnv(interp, &compEnv, string, length, NULL, 0);
TclCompileExpr(interp, string, length, &compEnv, 0);
/*
* Successful compilation. If the expression yielded no instructions,
|
| ︙ | ︙ | |||
1630 1631 1632 1633 1634 1635 1636 | * has to be recompiled to get the correct locations. Not doing this * will execute the saved bytecode with data for a different location, * causing 'info frame' to point to the wrong place in the sources. * * Future optimizations ... * (1) Save the location data (ExtCmdLoc) keyed by start line. In that * case we recompile once per location of the literal, but not | | | 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 | * has to be recompiled to get the correct locations. Not doing this * will execute the saved bytecode with data for a different location, * causing 'info frame' to point to the wrong place in the sources. * * Future optimizations ... * (1) Save the location data (ExtCmdLoc) keyed by start line. In that * case we recompile once per location of the literal, but not * continuously, because the moment we have all locations we do not * need to recompile any longer. * * (2) Alternative: Do not recompile, tell the execution engine the * offset between saved starting line and actual one. Then modify * the users to adjust the locations they have by this offset. * * (3) Alternative 2: Do not fully recompile, adjust just the location |
| ︙ | ︙ | |||
1676 1677 1678 1679 1680 1681 1682 | */ Tcl_DecrRefCount(ctxCopyPtr->data.eval.path); ctxCopyPtr->data.eval.path = NULL; } } | | | 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 |
*/
Tcl_DecrRefCount(ctxCopyPtr->data.eval.path);
ctxCopyPtr->data.eval.path = NULL;
}
}
if (word < ctxCopyPtr->nline) {
/*
* Note: We do not care if the line[word] is -1. This is a
* difference and requires a recompile (location changed from
* absolute to relative, literal is used fixed and through
* variable)
*
* Example:
|
| ︙ | ︙ | |||
1728 1729 1730 1731 1732 1733 1734 | } /* *---------------------------------------------------------------------- * * TclIncrObj -- * | | | | 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 |
}
/*
*----------------------------------------------------------------------
*
* TclIncrObj --
*
* Increment an integral value in a Tcl_Obj by an integral value held
* in another Tcl_Obj. Caller is responsible for making sure we can
* update the first object.
*
* Results:
* TCL_ERROR if either object is non-integer, and TCL_OK otherwise. On
* error, an error message is left in the interpreter (if it is not NULL,
* of course).
*
* Side effects:
* valuePtr gets the new incremented value.
*
*----------------------------------------------------------------------
*/
int
TclIncrObj(
Tcl_Interp *interp,
|
| ︙ | ︙ | |||
2045 2046 2047 2048 2049 2050 2051 |
* Locals - variables that are used within opcodes or bounded sections of
* the file (jumps between opcodes within a family).
* NOTE: These are now mostly defined locally where needed.
*/
Tcl_Obj *objPtr, *valuePtr, *value2Ptr, *part1Ptr, *part2Ptr, *tmpPtr;
Tcl_Obj **objv = NULL;
| | | 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 |
* Locals - variables that are used within opcodes or bounded sections of
* the file (jumps between opcodes within a family).
* NOTE: These are now mostly defined locally where needed.
*/
Tcl_Obj *objPtr, *valuePtr, *value2Ptr, *part1Ptr, *part2Ptr, *tmpPtr;
Tcl_Obj **objv = NULL;
Tcl_Size length, objc = 0;
int opnd, pcAdjustment;
Var *varPtr, *arrayPtr;
#ifdef TCL_COMPILE_DEBUG
char cmdNameBuf[21];
#endif
#ifdef TCL_COMPILE_DEBUG
|
| ︙ | ︙ | |||
2373 2374 2375 2376 2377 2378 2379 |
case INST_YIELD:
corPtr = iPtr->execEnvPtr->corPtr;
TRACE(("%.30s => ", O2S(OBJ_AT_TOS)));
if (!corPtr) {
TRACE_APPEND(("ERROR: yield outside coroutine\n"));
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | | | | | 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 |
case INST_YIELD:
corPtr = iPtr->execEnvPtr->corPtr;
TRACE(("%.30s => ", O2S(OBJ_AT_TOS)));
if (!corPtr) {
TRACE_APPEND(("ERROR: yield outside coroutine\n"));
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"yield can only be called in a coroutine", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD",
NULL);
CACHE_STACK_INFO();
goto gotError;
}
#ifdef TCL_COMPILE_DEBUG
if (tclTraceExec >= 2) {
if (traceInstructions) {
TRACE_APPEND(("YIELD...\n"));
} else {
fprintf(stdout, "%" TCL_Z_MODIFIER "d: (%" TCL_T_MODIFIER "u) yielding value \"%.30s\"\n",
iPtr->numLevels, (pc - codePtr->codeStart),
Tcl_GetString(OBJ_AT_TOS));
}
fflush(stdout);
}
#endif
yieldParameter = NULL; /*==CORO_ACTIVATE_YIELD*/
Tcl_SetObjResult(interp, OBJ_AT_TOS);
goto doYield;
case INST_YIELD_TO_INVOKE:
corPtr = iPtr->execEnvPtr->corPtr;
valuePtr = OBJ_AT_TOS;
if (!corPtr) {
TRACE(("[%.30s] => ERROR: yield outside coroutine\n",
O2S(valuePtr)));
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"yieldto can only be called in a coroutine", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD",
NULL);
CACHE_STACK_INFO();
goto gotError;
}
if (((Namespace *)TclGetCurrentNamespace(interp))->flags & NS_DYING) {
TRACE(("[%.30s] => ERROR: yield in deleted\n",
O2S(valuePtr)));
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"yieldto called in deleted namespace", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "YIELDTO_IN_DELETED",
NULL);
CACHE_STACK_INFO();
goto gotError;
}
#ifdef TCL_COMPILE_DEBUG
if (tclTraceExec >= 2) {
if (traceInstructions) {
TRACE(("[%.30s] => YIELD...\n", O2S(valuePtr)));
} else {
/* FIXME: What is the right thing to trace? */
fprintf(stdout, "%" TCL_Z_MODIFIER "d: (%" TCL_T_MODIFIER "u) yielding to [%.30s]\n",
iPtr->numLevels, (pc - codePtr->codeStart),
TclGetString(valuePtr));
}
fflush(stdout);
}
#endif
/*
|
| ︙ | ︙ | |||
2478 2479 2480 2481 2482 2483 2484 |
Tcl_Obj *listPtr, *nsObjPtr;
opnd = TclGetUInt1AtPtr(pc+1);
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
TRACE(("%d => ERROR: tailcall in non-proc context\n", opnd));
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 |
Tcl_Obj *listPtr, *nsObjPtr;
opnd = TclGetUInt1AtPtr(pc+1);
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
TRACE(("%d => ERROR: tailcall in non-proc context\n", opnd));
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"tailcall can only be called from a proc or lambda", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "TAILCALL", "ILLEGAL", NULL);
CACHE_STACK_INFO();
goto gotError;
}
#ifdef TCL_COMPILE_DEBUG
|
| ︙ | ︙ | |||
2507 2508 2509 2510 2511 2512 2513 | /* * Push the evaluation of the called command into the NR callback * stack. */ listPtr = Tcl_NewListObj(opnd, &OBJ_AT_DEPTH(opnd-1)); | | | 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 |
/*
* Push the evaluation of the called command into the NR callback
* stack.
*/
listPtr = Tcl_NewListObj(opnd, &OBJ_AT_DEPTH(opnd-1));
nsObjPtr = Tcl_NewStringObj(iPtr->varFramePtr->nsPtr->fullName, -1);
TclListObjSetElement(interp, listPtr, 0, nsObjPtr);
if (iPtr->varFramePtr->tailcallPtr) {
Tcl_DecrRefCount(iPtr->varFramePtr->tailcallPtr);
}
iPtr->varFramePtr->tailcallPtr = listPtr;
result = TCL_RETURN;
|
| ︙ | ︙ | |||
2658 2659 2660 2661 2662 2663 2664 |
/* Ugly abuse! */
starting = 1;
#endif
TRACE(("=> drop %" TCL_Z_MODIFIER "u items\n", objc));
NEXT_INST_V(1, objc, 0);
case INST_EXPAND_STKTOP: {
| | | 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 |
/* Ugly abuse! */
starting = 1;
#endif
TRACE(("=> drop %" TCL_Z_MODIFIER "u items\n", objc));
NEXT_INST_V(1, objc, 0);
case INST_EXPAND_STKTOP: {
Tcl_Size i;
TEBCdata *newTD;
ptrdiff_t oldCatchTopOff, oldTosPtrOff;
/*
* Make sure that the element at stackTop is a list; if not, just
* leave with an error. Note that the element from the expand list
* will be removed at checkForCatch.
|
| ︙ | ︙ | |||
2785 2786 2787 2788 2789 2790 2791 |
doInvocation:
objv = &OBJ_AT_DEPTH(objc-1);
cleanup = objc;
#ifdef TCL_COMPILE_DEBUG
if (tclTraceExec >= 2) {
| | | | | 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 |
doInvocation:
objv = &OBJ_AT_DEPTH(objc-1);
cleanup = objc;
#ifdef TCL_COMPILE_DEBUG
if (tclTraceExec >= 2) {
Tcl_Size i;
if (traceInstructions) {
strncpy(cmdNameBuf, TclGetString(objv[0]), 20);
TRACE(("%" TCL_Z_MODIFIER "u => call ", objc));
} else {
fprintf(stdout, "%" TCL_Z_MODIFIER "d: (%" TCL_T_MODIFIER "u) invoking ", iPtr->numLevels,
(pc - codePtr->codeStart));
}
for (i = 0; i < objc; i++) {
TclPrintObject(stdout, objv[i], 15);
fprintf(stdout, " ");
}
fprintf(stdout, "\n");
fflush(stdout);
|
| ︙ | ︙ | |||
2832 2833 2834 2835 2836 2837 2838 |
objc = TclGetUInt4AtPtr(pc+1);
opnd = TclGetUInt1AtPtr(pc+5);
objPtr = POP_OBJECT();
objv = &OBJ_AT_DEPTH(objc-1);
cleanup = objc;
#ifdef TCL_COMPILE_DEBUG
if (tclTraceExec >= 2) {
| | | | | | 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 |
objc = TclGetUInt4AtPtr(pc+1);
opnd = TclGetUInt1AtPtr(pc+5);
objPtr = POP_OBJECT();
objv = &OBJ_AT_DEPTH(objc-1);
cleanup = objc;
#ifdef TCL_COMPILE_DEBUG
if (tclTraceExec >= 2) {
Tcl_Size i;
if (traceInstructions) {
strncpy(cmdNameBuf, TclGetString(objv[0]), 20);
TRACE(("%" TCL_Z_MODIFIER "u => call (implementation %s) ", objc, O2S(objPtr)));
} else {
fprintf(stdout,
"%" TCL_Z_MODIFIER "d: (%" TCL_T_MODIFIER "u) invoking (using implementation %s) ",
iPtr->numLevels, (pc - codePtr->codeStart),
O2S(objPtr));
}
for (i = 0; i < objc; i++) {
if (i < opnd) {
fprintf(stdout, "<");
TclPrintObject(stdout, objv[i], 15);
fprintf(stdout, ">");
} else {
TclPrintObject(stdout, objv[i], 15);
}
fprintf(stdout, " ");
|
| ︙ | ︙ | |||
3043 3044 3045 3046 3047 3048 3049 |
* WARNING: more 'goto' here than your doctor recommended! The different
* instructions set the value of some variables and then jump to somme
* common execution code.
*/
{
int storeFlags;
| | | 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 |
* WARNING: more 'goto' here than your doctor recommended! The different
* instructions set the value of some variables and then jump to somme
* common execution code.
*/
{
int storeFlags;
Tcl_Size len;
case INST_STORE_ARRAY4:
opnd = TclGetUInt4AtPtr(pc+1);
pcAdjustment = 5;
goto doStoreArrayDirect;
case INST_STORE_ARRAY1:
|
| ︙ | ︙ | |||
3459 3460 3461 3462 3463 3464 3465 |
/*
* End of INST_STORE and related instructions.
* -----------------------------------------------------------------
* Start of INST_INCR instructions.
*
* WARNING: more 'goto' here than your doctor recommended! The different
| | | 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 |
/*
* End of INST_STORE and related instructions.
* -----------------------------------------------------------------
* Start of INST_INCR instructions.
*
* WARNING: more 'goto' here than your doctor recommended! The different
* instructions set the value of some variables and then jump to some
* common execution code.
*/
/*TODO: Consider more untangling here; merge with LOAD and STORE ? */
{
Tcl_Obj *incrPtr;
|
| ︙ | ︙ | |||
4348 4349 4350 4351 4352 4353 4354 |
* Start of TclOO support instructions.
*/
{
Object *oPtr;
CallFrame *framePtr;
CallContext *contextPtr;
| | | 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 |
* Start of TclOO support instructions.
*/
{
Object *oPtr;
CallFrame *framePtr;
CallContext *contextPtr;
Tcl_Size skip, newDepth;
case INST_TCLOO_SELF:
framePtr = iPtr->varFramePtr;
if (framePtr == NULL ||
!(framePtr->isProcCallFrame & FRAME_IS_METHOD)) {
TRACE(("=> ERROR: no TclOO call context\n"));
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
| ︙ | ︙ | |||
4400 4401 4402 4403 4404 4405 4406 |
oPtr = (Object *) Tcl_GetObjectFromObj(interp, valuePtr);
if (oPtr == NULL) {
TRACE_APPEND(("ERROR: \"%.30s\" not object\n", O2S(valuePtr)));
goto gotError;
} else {
Class *classPtr = oPtr->classPtr;
struct MInvoke *miPtr;
| | | 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 |
oPtr = (Object *) Tcl_GetObjectFromObj(interp, valuePtr);
if (oPtr == NULL) {
TRACE_APPEND(("ERROR: \"%.30s\" not object\n", O2S(valuePtr)));
goto gotError;
} else {
Class *classPtr = oPtr->classPtr;
struct MInvoke *miPtr;
Tcl_Size i;
const char *methodType;
if (classPtr == NULL) {
TRACE_APPEND(("ERROR: \"%.30s\" not class\n", O2S(valuePtr)));
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"\"%s\" is not a class", TclGetString(valuePtr)));
DECACHE_STACK_INFO();
|
| ︙ | ︙ | |||
4427 4428 4429 4430 4431 4432 4433 |
if (traceInstructions) {
strncpy(cmdNameBuf, TclGetString(objv[0]), 20);
} else {
fprintf(stdout, "%" TCL_Z_MODIFIER "d: (%" TCL_Z_MODIFIER "u) invoking ",
iPtr->numLevels,
(size_t)(pc - codePtr->codeStart));
}
| | | 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 |
if (traceInstructions) {
strncpy(cmdNameBuf, TclGetString(objv[0]), 20);
} else {
fprintf(stdout, "%" TCL_Z_MODIFIER "d: (%" TCL_Z_MODIFIER "u) invoking ",
iPtr->numLevels,
(size_t)(pc - codePtr->codeStart));
}
for (i = 0; i < opnd; i++) {
TclPrintObject(stdout, objv[i], 15);
fprintf(stdout, " ");
}
fprintf(stdout, "\n");
fflush(stdout);
}
#endif /*TCL_COMPILE_DEBUG*/
|
| ︙ | ︙ | |||
4623 4624 4625 4626 4627 4628 4629 |
* End of TclOO support instructions.
* -----------------------------------------------------------------
* Start of INST_LIST and related instructions.
*/
{
int numIndices, nocase, match, cflags;
| | | 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 |
* End of TclOO support instructions.
* -----------------------------------------------------------------
* Start of INST_LIST and related instructions.
*/
{
int numIndices, nocase, match, cflags;
Tcl_Size slength, length2, fromIdx, toIdx, index, s1len, s2len;
const char *s1, *s2;
case INST_LIST:
/*
* Pop the opnd (objc) top stack elements into a new list obj and then
* decrement their ref counts.
*/
|
| ︙ | ︙ | |||
4751 4752 4753 4754 4755 4756 4757 |
/* Decode end-offset index values. */
index = TclIndexDecode(opnd, objc - 1);
pcAdjustment = 5;
lindexFastPath:
| | | 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 |
/* Decode end-offset index values. */
index = TclIndexDecode(opnd, objc - 1);
pcAdjustment = 5;
lindexFastPath:
if (index >= 0 && index < objc) {
objResultPtr = objv[index];
} else {
TclNewObj(objResultPtr);
}
lindexFastPath2:
|
| ︙ | ︙ | |||
4925 4926 4927 4928 4929 4930 4931 |
TclNewObj(objResultPtr);
TRACE_APPEND(("\"%.30s\"", O2S(objResultPtr)));
NEXT_INST_F(9, 1, 1);
}
toIdx = TclIndexDecode(toIdx, objc - 1);
if (toIdx == TCL_INDEX_NONE) {
goto emptyList;
| | | | < | > > > > | | 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 |
TclNewObj(objResultPtr);
TRACE_APPEND(("\"%.30s\"", O2S(objResultPtr)));
NEXT_INST_F(9, 1, 1);
}
toIdx = TclIndexDecode(toIdx, objc - 1);
if (toIdx == TCL_INDEX_NONE) {
goto emptyList;
} else if (toIdx >= objc) {
toIdx = objc - 1;
}
assert (toIdx >= 0 && toIdx < objc);
/*
assert ( fromIdx != TCL_INDEX_NONE );
*
* Extra safety for legacy bytecodes:
*/
if (fromIdx == TCL_INDEX_NONE) {
fromIdx = TCL_INDEX_START;
}
fromIdx = TclIndexDecode(fromIdx, objc - 1);
if (ABSTRACTLIST_PROC(valuePtr, sliceProc)) {
if (Tcl_ObjTypeSlice(interp, valuePtr, fromIdx, toIdx, &objResultPtr) != TCL_OK) {
objResultPtr = NULL;
}
} else {
objResultPtr = TclListObjRange(interp, valuePtr, fromIdx, toIdx);
}
if (objResultPtr == NULL) {
TRACE_ERROR(interp);
goto gotError;
}
TRACE_APPEND(("\"%.30s\"", O2S(objResultPtr)));
NEXT_INST_F(9, 1, 1);
case INST_LIST_IN:
case INST_LIST_NOT_IN: /* Basic list containment operators. */
value2Ptr = OBJ_AT_TOS;
valuePtr = OBJ_UNDER_TOS;
s1 = Tcl_GetStringFromObj(valuePtr, &s1len);
TRACE(("\"%.30s\" \"%.30s\" => ", O2S(valuePtr), O2S(value2Ptr)));
if (TclListObjLengthM(interp, value2Ptr, &length) != TCL_OK) {
TRACE_ERROR(interp);
goto gotError;
}
match = 0;
if (length > 0) {
Tcl_Size i = 0;
Tcl_Obj *o;
int isAbstractList = ABSTRACTLIST_PROC(value2Ptr,indexProc) != NULL;
/*
* An empty list doesn't match anything.
*/
|
| ︙ | ︙ | |||
5147 5148 5149 5150 5151 5152 5153 |
stringCompare:
value2Ptr = OBJ_AT_TOS;
valuePtr = OBJ_UNDER_TOS;
{
int checkEq = ((*pc == INST_EQ) || (*pc == INST_NEQ)
|| (*pc == INST_STR_EQ) || (*pc == INST_STR_NEQ));
| | | 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 |
stringCompare:
value2Ptr = OBJ_AT_TOS;
valuePtr = OBJ_UNDER_TOS;
{
int checkEq = ((*pc == INST_EQ) || (*pc == INST_NEQ)
|| (*pc == INST_STR_EQ) || (*pc == INST_STR_NEQ));
match = TclStringCmp(valuePtr, value2Ptr, checkEq, 0, -1);
}
/*
* Make sure only -1,0,1 is returned
* TODO: consider peephole opt.
*/
|
| ︙ | ︙ | |||
5257 5258 5259 5260 5261 5262 5263 |
case INST_STR_INDEX:
value2Ptr = OBJ_AT_TOS;
valuePtr = OBJ_UNDER_TOS;
TRACE(("\"%.20s\" %.20s => ", O2S(valuePtr), O2S(value2Ptr)));
/*
| | | | 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 |
case INST_STR_INDEX:
value2Ptr = OBJ_AT_TOS;
valuePtr = OBJ_UNDER_TOS;
TRACE(("\"%.20s\" %.20s => ", O2S(valuePtr), O2S(value2Ptr)));
/*
* Get char length to calculate what 'end' means.
*/
slength = Tcl_GetCharLength(valuePtr);
DECACHE_STACK_INFO();
if (TclGetIntForIndexM(interp, value2Ptr, slength-1, &index)!=TCL_OK) {
CACHE_STACK_INFO();
TRACE_ERROR(interp);
goto gotError;
}
CACHE_STACK_INFO();
if (index < 0 || index >= slength) {
TclNewObj(objResultPtr);
} else if (TclIsPureByteArray(valuePtr)) {
objResultPtr = Tcl_NewByteArrayObj(
Tcl_GetByteArrayFromObj(valuePtr, (size_t *)NULL)+index, 1);
} else if (valuePtr->bytes && slength == valuePtr->length) {
objResultPtr = Tcl_NewStringObj((const char *)
valuePtr->bytes+index, 1);
|
| ︙ | ︙ | |||
5357 5358 5359 5360 5361 5362 5363 |
objResultPtr = Tcl_GetRange(valuePtr, fromIdx, toIdx);
}
TRACE_APPEND(("%.30s\n", O2S(objResultPtr)));
NEXT_INST_F(9, 1, 1);
{
Tcl_UniChar *ustring1, *ustring2, *ustring3, *end, *p;
| | | 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 |
objResultPtr = Tcl_GetRange(valuePtr, fromIdx, toIdx);
}
TRACE_APPEND(("%.30s\n", O2S(objResultPtr)));
NEXT_INST_F(9, 1, 1);
{
Tcl_UniChar *ustring1, *ustring2, *ustring3, *end, *p;
Tcl_Size length3;
Tcl_Obj *value3Ptr;
case INST_STR_REPLACE:
value3Ptr = POP_OBJECT();
valuePtr = OBJ_AT_DEPTH(2);
slength = Tcl_GetCharLength(valuePtr) - 1;
TRACE(("\"%.20s\" %s %s \"%.20s\" => ", O2S(valuePtr),
|
| ︙ | ︙ | |||
5382 5383 5384 5385 5386 5387 5388 | } CACHE_STACK_INFO(); TclDecrRefCount(OBJ_AT_TOS); (void) POP_OBJECT(); TclDecrRefCount(OBJ_AT_TOS); (void) POP_OBJECT(); | | | | | | | | | 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 |
}
CACHE_STACK_INFO();
TclDecrRefCount(OBJ_AT_TOS);
(void) POP_OBJECT();
TclDecrRefCount(OBJ_AT_TOS);
(void) POP_OBJECT();
if ((toIdx < 0) ||
(fromIdx > slength) ||
(toIdx < fromIdx)) {
TRACE_APPEND(("\"%.30s\"\n", O2S(valuePtr)));
TclDecrRefCount(value3Ptr);
NEXT_INST_F(1, 0, 0);
}
if (fromIdx < 0) {
fromIdx = 0;
}
if (toIdx > slength) {
toIdx = slength;
}
if ((fromIdx == 0) && (toIdx == slength)) {
TclDecrRefCount(OBJ_AT_TOS);
OBJ_AT_TOS = value3Ptr;
TRACE_APPEND(("\"%.30s\"\n", O2S(value3Ptr)));
NEXT_INST_F(1, 0, 0);
}
objResultPtr = TclStringReplace(interp, valuePtr, fromIdx,
|
| ︙ | ︙ | |||
5455 5456 5457 5458 5459 5460 5461 |
objResultPtr = Tcl_NewUnicodeObj(ustring1, 0);
p = ustring1;
end = ustring1 + slength;
for (; ustring1 < end; ustring1++) {
if ((*ustring1 == *ustring2) &&
/* Fix bug [69218ab7b]: restrict max compare length. */
| | | 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 |
objResultPtr = Tcl_NewUnicodeObj(ustring1, 0);
p = ustring1;
end = ustring1 + slength;
for (; ustring1 < end; ustring1++) {
if ((*ustring1 == *ustring2) &&
/* Fix bug [69218ab7b]: restrict max compare length. */
((end-ustring1) >= length2) && (length2==1 ||
memcmp(ustring1, ustring2, sizeof(Tcl_UniChar) * length2)
== 0)) {
if (p != ustring1) {
Tcl_AppendUnicodeToObj(objResultPtr, p, ustring1-p);
p = ustring1 + length2;
} else {
p += length2;
|
| ︙ | ︙ | |||
5562 5563 5564 5565 5566 5567 5568 |
* Peep-hole optimisation: if you're about to jump, do jump from here.
*/
JUMP_PEEPHOLE_F(match, 2, 2);
{
const char *string1, *string2;
| | | 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 |
* Peep-hole optimisation: if you're about to jump, do jump from here.
*/
JUMP_PEEPHOLE_F(match, 2, 2);
{
const char *string1, *string2;
Tcl_Size trim1, trim2;
case INST_STR_TRIM_LEFT:
valuePtr = OBJ_UNDER_TOS; /* String */
value2Ptr = OBJ_AT_TOS; /* TrimSet */
string2 = Tcl_GetStringFromObj(value2Ptr, &length2);
string1 = Tcl_GetStringFromObj(valuePtr, &slength);
trim1 = TclTrimLeft(string1, slength, string2, length2);
|
| ︙ | ︙ | |||
5841 5842 5843 5844 5845 5846 5847 |
goto wideResultOfArithmetic;
}
break;
case INST_RSHIFT:
if (w2 < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 |
goto wideResultOfArithmetic;
}
break;
case INST_RSHIFT:
if (w2 < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"negative shift argument", -1));
#ifdef ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"domain error: argument not in valid range",
NULL);
CACHE_STACK_INFO();
#endif /* ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR */
|
| ︙ | ︙ | |||
5890 5891 5892 5893 5894 5895 5896 |
goto wideResultOfArithmetic;
}
break;
case INST_LSHIFT:
if (w2 < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 |
goto wideResultOfArithmetic;
}
break;
case INST_LSHIFT:
if (w2 < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"negative shift argument", -1));
#ifdef ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"domain error: argument not in valid range",
NULL);
CACHE_STACK_INFO();
#endif /* ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR */
|
| ︙ | ︙ | |||
5913 5914 5915 5916 5917 5918 5919 | * Technically, we could hold the value (1 << (INT_MAX+1)) * in an mp_int, but since we're using mp_mul_2d() to do * the work, and it takes only an int argument, that's a * good place to draw the line. */ Tcl_SetObjResult(interp, Tcl_NewStringObj( | | | 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 | * Technically, we could hold the value (1 << (INT_MAX+1)) * in an mp_int, but since we're using mp_mul_2d() to do * the work, and it takes only an int argument, that's a * good place to draw the line. */ Tcl_SetObjResult(interp, Tcl_NewStringObj( "integer value too large to represent", -1)); #ifdef ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR DECACHE_STACK_INFO(); Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", "integer value too large to represent", NULL); CACHE_STACK_INFO(); #endif /* ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR */ goto gotError; |
| ︙ | ︙ | |||
6372 6373 6374 6375 6376 6377 6378 |
TRACE(("=> CONTINUE!\n"));
goto processExceptionReturn;
{
ForeachInfo *infoPtr;
Tcl_Obj *listPtr, **elements;
ForeachVarList *varListPtr;
| | | | | 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 |
TRACE(("=> CONTINUE!\n"));
goto processExceptionReturn;
{
ForeachInfo *infoPtr;
Tcl_Obj *listPtr, **elements;
ForeachVarList *varListPtr;
Tcl_Size numLists, listLen, numVars, listTmpDepth;
Tcl_Size iterNum, iterMax, iterTmp;
Tcl_Size varIndex, valIndex, i, j;
case INST_FOREACH_START:
/*
* Initialize the data for the looping construct, pushing the
* corresponding Tcl_Objs to the stack.
*/
|
| ︙ | ︙ | |||
6637 6638 6639 6640 6641 6642 6643 |
/*
* -----------------------------------------------------------------
* Start of dictionary-related instructions.
*/
{
int opnd2, allocateDict, done, allocdict;
| | | | 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 |
/*
* -----------------------------------------------------------------
* Start of dictionary-related instructions.
*/
{
int opnd2, allocateDict, done, allocdict;
Tcl_Size i;
Tcl_Obj *dictPtr, *statePtr, *keyPtr, *listPtr, *varNamePtr, *keysPtr;
Tcl_Obj *emptyPtr, **keyPtrPtr;
Tcl_DictSearch *searchPtr;
DictUpdateInfo *duiPtr;
case INST_DICT_VERIFY: {
Tcl_Size size;
dictPtr = OBJ_AT_TOS;
TRACE(("\"%.30s\" => ", O2S(dictPtr)));
if (Tcl_DictObjSize(interp, dictPtr, &size) != TCL_OK) {
TRACE_APPEND(("ERROR verifying dictionary nature of \"%.30s\": %s\n",
O2S(dictPtr), O2S(Tcl_GetObjResult(interp))));
goto gotError;
}
|
| ︙ | ︙ | |||
7063 7064 7065 7066 7067 7068 7069 |
PUSH_OBJECT(valuePtr);
PUSH_OBJECT(keyPtr);
}
TRACE_APPEND(("\"%.30s\" \"%.30s\" %d\n",
O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), done));
/*
| | | 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 |
PUSH_OBJECT(valuePtr);
PUSH_OBJECT(keyPtr);
}
TRACE_APPEND(("\"%.30s\" \"%.30s\" %d\n",
O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), done));
/*
* The INST_DICT_FIRST and INST_DICT_NEXT instructions are always
* followed by a conditional jump, so we can take advantage of this to
* do some peephole optimization (note that we're careful to not close
* out someone doing something else).
*/
JUMP_PEEPHOLE_F(done, 5, 0);
|
| ︙ | ︙ | |||
7419 7420 7421 7422 7423 7424 7425 |
/*
* Division by zero in an expression. Control only reaches this point
* by "goto divideByZero".
*/
divideByZero:
| | | | | 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 |
/*
* Division by zero in an expression. Control only reaches this point
* by "goto divideByZero".
*/
divideByZero:
Tcl_SetObjResult(interp, Tcl_NewStringObj("divide by zero", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DIVZERO", "divide by zero", NULL);
CACHE_STACK_INFO();
goto gotError;
outOfMemory:
Tcl_SetObjResult(interp, Tcl_NewStringObj("out of memory", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "OUTOFMEMORY", "out of memory", NULL);
CACHE_STACK_INFO();
goto gotError;
/*
* Exponentiation of zero by negative number in an expression. Control
* only reaches this point by "goto exponOfZero".
*/
exponOfZero:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"exponentiation of zero by negative power", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"exponentiation of zero by negative power", NULL);
CACHE_STACK_INFO();
/*
* Almost all error paths feed through here rather than assigning to
|
| ︙ | ︙ | |||
7467 7468 7469 7470 7471 7472 7473 |
checkForCatch:
if (iPtr->execEnvPtr->rewind) {
goto abnormalReturn;
}
if ((result == TCL_ERROR) && !(iPtr->flags & ERR_ALREADY_LOGGED)) {
const unsigned char *pcBeg;
| | | 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 |
checkForCatch:
if (iPtr->execEnvPtr->rewind) {
goto abnormalReturn;
}
if ((result == TCL_ERROR) && !(iPtr->flags & ERR_ALREADY_LOGGED)) {
const unsigned char *pcBeg;
Tcl_Size xxx1length;
bytes = GetSrcInfoForPc(pc, codePtr, &xxx1length, &pcBeg, NULL);
DECACHE_STACK_INFO();
TclLogCommandInfo(interp, codePtr->source, bytes,
bytes ? xxx1length : 0, pcBeg, tosPtr);
CACHE_STACK_INFO();
}
|
| ︙ | ︙ | |||
7634 7635 7636 7637 7638 7639 7640 |
* case INST_START_CMD:
*/
instStartCmdFailed:
{
const char *bytes;
| | | 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 |
* case INST_START_CMD:
*/
instStartCmdFailed:
{
const char *bytes;
Tcl_Size xxx1length;
xxx1length = 0;
if (TclInterpReady(interp) == TCL_ERROR) {
goto gotError;
}
|
| ︙ | ︙ | |||
8000 8001 8002 8003 8004 8005 8006 |
break;
default:
/* Unused, here to silence compiler warning */
invalid = 0;
}
if (invalid) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 |
break;
default:
/* Unused, here to silence compiler warning */
invalid = 0;
}
if (invalid) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"negative shift argument", -1));
return GENERAL_ARITHMETIC_ERROR;
}
/*
* Zero shifted any number of bits is still zero.
*/
|
| ︙ | ︙ | |||
8031 8032 8033 8034 8035 8036 8037 | * Technically, we could hold the value (1 << (INT_MAX+1)) in * an mp_int, but since we're using mp_mul_2d() to do the * work, and it takes only an int argument, that's a good * place to draw the line. */ Tcl_SetObjResult(interp, Tcl_NewStringObj( | | | 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 | * Technically, we could hold the value (1 << (INT_MAX+1)) in * an mp_int, but since we're using mp_mul_2d() to do the * work, and it takes only an int argument, that's a good * place to draw the line. */ Tcl_SetObjResult(interp, Tcl_NewStringObj( "integer value too large to represent", -1)); return GENERAL_ARITHMETIC_ERROR; } shift = (int)(*((const Tcl_WideInt *)ptr2)); /* * Handle shifts within the native wide range. */ |
| ︙ | ︙ | |||
8279 8280 8281 8282 8283 8284 8285 |
* range of the long int type. This means any numeric Tcl_Obj value
* not using TCL_NUMBER_INT type must hold a value larger than we
* accept.
*/
if (type2 != TCL_NUMBER_INT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 |
* range of the long int type. This means any numeric Tcl_Obj value
* not using TCL_NUMBER_INT type must hold a value larger than we
* accept.
*/
if (type2 != TCL_NUMBER_INT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"exponent too large", -1));
return GENERAL_ARITHMETIC_ERROR;
}
/* From here (up to overflowExpon) w1 and exponent w2 are wide-int's. */
assert(type1 == TCL_NUMBER_INT && type2 == TCL_NUMBER_INT);
if (w1 == 2) {
|
| ︙ | ︙ | |||
8359 8360 8361 8362 8363 8364 8365 |
overflowExpon:
if ((TclGetWideIntFromObj(NULL, value2Ptr, &w2) != TCL_OK)
|| (value2Ptr->typePtr != &tclIntType)
|| (Tcl_WideUInt)w2 >= (1<<28)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 |
overflowExpon:
if ((TclGetWideIntFromObj(NULL, value2Ptr, &w2) != TCL_OK)
|| (value2Ptr->typePtr != &tclIntType)
|| (Tcl_WideUInt)w2 >= (1<<28)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"exponent too large", -1));
return GENERAL_ARITHMETIC_ERROR;
}
Tcl_TakeBignumFromObj(NULL, valuePtr, &big1);
err = mp_init(&bigResult);
if (err == MP_OKAY) {
err = mp_expt_u32(&big1, (unsigned int)w2, &bigResult);
}
|
| ︙ | ︙ | |||
9065 9066 9067 9068 9069 9070 9071 | /* * We now have the command. We can get the srcOffset back and from * there find the list of word locations for this command. */ ExtCmdLoc *eclPtr; ECL *locPtr = NULL; | | | 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 |
/*
* We now have the command. We can get the srcOffset back and from
* there find the list of word locations for this command.
*/
ExtCmdLoc *eclPtr;
ECL *locPtr = NULL;
Tcl_Size srcOffset;
int i;
Interp *iPtr = (Interp *) *codePtr->interpHandle;
Tcl_HashEntry *hePtr =
Tcl_FindHashEntry(iPtr->lineBCPtr, codePtr);
if (!hePtr) {
return;
|
| ︙ | ︙ | |||
9112 9113 9114 9115 9116 9117 9118 |
GetSrcInfoForPc(
const unsigned char *pc, /* The program counter value for which to
* return the closest command's source info.
* This points within a bytecode instruction
* in codePtr's code. */
ByteCode *codePtr, /* The bytecode sequence in which to look up
* the command source for the pc. */
| | | | | | 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 |
GetSrcInfoForPc(
const unsigned char *pc, /* The program counter value for which to
* return the closest command's source info.
* This points within a bytecode instruction
* in codePtr's code. */
ByteCode *codePtr, /* The bytecode sequence in which to look up
* the command source for the pc. */
Tcl_Size *lengthPtr, /* If non-NULL, the location where the length
* of the command's source should be stored.
* If NULL, no length is stored. */
const unsigned char **pcBeg,/* If non-NULL, the bytecode location
* where the current instruction starts.
* If NULL; no pointer is stored. */
int *cmdIdxPtr) /* If non-NULL, the location where the index
* of the command containing the pc should
* be stored. */
{
Tcl_Size pcOffset = pc - codePtr->codeStart;
Tcl_Size numCmds = codePtr->numCommands;
unsigned char *codeDeltaNext, *codeLengthNext;
unsigned char *srcDeltaNext, *srcLengthNext;
Tcl_Size codeOffset, codeLen, codeEnd, srcOffset, srcLen, delta, i;
int bestDist = INT_MAX; /* Distance of pc to best cmd's start pc. */
int bestSrcOffset = -1; /* Initialized to avoid compiler warning. */
int bestSrcLength = -1; /* Initialized to avoid compiler warning. */
int bestCmdIdx = -1;
/* The pc must point within the bytecode */
assert (pcOffset < codePtr->numCodeBytes);
|
| ︙ | ︙ | |||
9366 9367 9368 9369 9370 9371 9372 |
double value) /* Value returned after error; used to
* distinguish underflows from overflows. */
{
const char *s;
if ((errno == EDOM) || isnan(value)) {
s = "domain error: argument not in valid range";
| | | | | 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 |
double value) /* Value returned after error; used to
* distinguish underflows from overflows. */
{
const char *s;
if ((errno == EDOM) || isnan(value)) {
s = "domain error: argument not in valid range";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", s, NULL);
} else if ((errno == ERANGE) || isinf(value)) {
if (value == 0.0) {
s = "floating-point value too small to represent";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
Tcl_SetErrorCode(interp, "ARITH", "UNDERFLOW", s, NULL);
} else {
s = "floating-point value too large to represent";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
Tcl_SetErrorCode(interp, "ARITH", "OVERFLOW", s, NULL);
}
} else {
Tcl_Obj *objPtr = Tcl_ObjPrintf(
"unknown floating-point error, errno = %d", errno);
Tcl_SetErrorCode(interp, "ARITH", "UNKNOWN",
|
| ︙ | ︙ |
Changes to generic/tclFCmd.c.
| ︙ | ︙ | |||
217 218 219 220 221 222 223 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Used for error reporting. */
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument strings passed to Tcl_FileCmd. */
{
Tcl_Obj *errfile = NULL;
int result, i;
| | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Used for error reporting. */
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument strings passed to Tcl_FileCmd. */
{
Tcl_Obj *errfile = NULL;
int result, i;
Tcl_Size j, pobjc;
Tcl_Obj *split = NULL;
Tcl_Obj *target = NULL;
Tcl_StatBuf statBuf;
result = TCL_OK;
for (i = 1; i < objc; i++) {
if (Tcl_FSConvertToPathType(interp, objv[i]) != TCL_OK) {
|
| ︙ | ︙ | |||
422 423 424 425 426 427 428 |
result = TCL_ERROR;
break;
}
}
if (result != TCL_OK) {
if (errfile == NULL) {
/*
| | | 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
result = TCL_ERROR;
break;
}
}
if (result != TCL_OK) {
if (errfile == NULL) {
/*
* We try to accommodate poor error results from our Tcl_FS calls.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error deleting unknown file: %s",
Tcl_PosixError(interp)));
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
| ︙ | ︙ | |||
870 871 872 873 874 875 876 |
*/
static Tcl_Obj *
FileBasename(
TCL_UNUSED(Tcl_Interp *), /* Interp, for error return. */
Tcl_Obj *pathPtr) /* Path whose basename to extract. */
{
| | | 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
*/
static Tcl_Obj *
FileBasename(
TCL_UNUSED(Tcl_Interp *), /* Interp, for error return. */
Tcl_Obj *pathPtr) /* Path whose basename to extract. */
{
Tcl_Size objc;
Tcl_Obj *splitPtr;
Tcl_Obj *resultPtr = NULL;
splitPtr = Tcl_FSSplitPath(pathPtr, &objc);
Tcl_IncrRefCount(splitPtr);
if (objc != 0) {
|
| ︙ | ︙ | |||
943 944 945 946 947 948 949 |
int objc, /* Number of command line arguments. */
Tcl_Obj *const objv[]) /* The command line objects. */
{
int result;
const char *const *attributeStrings;
const char **attributeStringsAllocated = NULL;
Tcl_Obj *objStrings = NULL;
| | | 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 |
int objc, /* Number of command line arguments. */
Tcl_Obj *const objv[]) /* The command line objects. */
{
int result;
const char *const *attributeStrings;
const char **attributeStringsAllocated = NULL;
Tcl_Obj *objStrings = NULL;
Tcl_Size numObjStrings = TCL_INDEX_NONE;
Tcl_Obj *filePtr;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "name ?-option value ...?");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
967 968 969 970 971 972 973 |
/*
* Get the set of attribute names from the filesystem.
*/
attributeStrings = Tcl_FSFileAttrStrings(filePtr, &objStrings);
if (attributeStrings == NULL) {
| | | 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 |
/*
* Get the set of attribute names from the filesystem.
*/
attributeStrings = Tcl_FSFileAttrStrings(filePtr, &objStrings);
if (attributeStrings == NULL) {
Tcl_Size index;
Tcl_Obj *objPtr;
if (objStrings == NULL) {
if (Tcl_GetErrno() != 0) {
/*
* There was an error, probably that the filePtr is not
* accepted by any filesystem
|
| ︙ | ︙ | |||
1038 1039 1040 1041 1042 1043 1044 |
Tcl_ResetResult(interp);
}
res = Tcl_FSFileAttrsGet(interp, index, filePtr, &objPtrAttr);
if (res == TCL_OK) {
Tcl_Obj *objPtr =
| | | 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 |
Tcl_ResetResult(interp);
}
res = Tcl_FSFileAttrsGet(interp, index, filePtr, &objPtrAttr);
if (res == TCL_OK) {
Tcl_Obj *objPtr =
Tcl_NewStringObj(attributeStrings[index], -1);
Tcl_ListObjAppendElement(interp, listPtr, objPtr);
Tcl_ListObjAppendElement(interp, listPtr, objPtrAttr);
nbAtts++;
}
}
|
| ︙ | ︙ | |||
1208 1209 1210 1211 1212 1213 1214 |
* Create link from source to target.
*/
contents = Tcl_FSLink(objv[index], objv[index+1], linkAction);
if (contents == NULL) {
/*
* We handle three common error cases specially, and for all other
| | | 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 |
* Create link from source to target.
*/
contents = Tcl_FSLink(objv[index], objv[index+1], linkAction);
if (contents == NULL) {
/*
* We handle three common error cases specially, and for all other
* errors, we use the standard Posix error message.
*/
if (errno == EEXIST) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"could not create new link \"%s\": that path already"
" exists", TclGetString(objv[index])));
Tcl_PosixError(interp);
|
| ︙ | ︙ | |||
1377 1378 1379 1380 1381 1382 1383 |
}
if (objc > 1) {
nameVarObj = objv[1];
TclNewObj(nameObj);
}
if (objc > 2) {
| | | 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 |
}
if (objc > 1) {
nameVarObj = objv[1];
TclNewObj(nameObj);
}
if (objc > 2) {
Tcl_Size length;
Tcl_Obj *templateObj = objv[2];
const char *string = Tcl_GetStringFromObj(templateObj, &length);
/*
* Treat an empty string as if it wasn't there.
*/
|
| ︙ | ︙ | |||
1488 1489 1490 1491 1492 1493 1494 |
if (nameVarObj != NULL) {
if (Tcl_ObjSetVar2(interp, nameVarObj, NULL, nameObj,
TCL_LEAVE_ERR_MSG) == NULL) {
Tcl_UnregisterChannel(interp, chan);
return TCL_ERROR;
}
}
| | | 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 |
if (nameVarObj != NULL) {
if (Tcl_ObjSetVar2(interp, nameVarObj, NULL, nameObj,
TCL_LEAVE_ERR_MSG) == NULL) {
Tcl_UnregisterChannel(interp, chan);
return TCL_ERROR;
}
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(Tcl_GetChannelName(chan), -1));
return TCL_OK;
}
/*
*---------------------------------------------------------------------------
*
* TclFileTempDirCmd --
|
| ︙ | ︙ | |||
1529 1530 1531 1532 1533 1534 1535 |
if (objc < 1 || objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?template?");
return TCL_ERROR;
}
if (objc > 1) {
| | | 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 |
if (objc < 1 || objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?template?");
return TCL_ERROR;
}
if (objc > 1) {
Tcl_Size length;
Tcl_Obj *templateObj = objv[1];
const char *string = Tcl_GetStringFromObj(templateObj, &length);
const int onWindows = (tclPlatform == TCL_PLATFORM_WINDOWS);
/*
* Treat an empty string as if it wasn't there.
*/
|
| ︙ | ︙ |
Changes to generic/tclFileName.c.
| ︙ | ︙ | |||
91 92 93 94 95 96 97 | * * Matches the root portion of a Windows path and appends it to the * specified Tcl_DString. * * Results: * Returns the position in the path immediately after the root including * any trailing slashes. Appends a cleaned up version of the root to the | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | * * Matches the root portion of a Windows path and appends it to the * specified Tcl_DString. * * Results: * Returns the position in the path immediately after the root including * any trailing slashes. Appends a cleaned up version of the root to the * Tcl_DString at the specified offset. * * Side effects: * Modifies the specified Tcl_DString. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ | |||
377 378 379 380 381 382 383 |
*
*----------------------------------------------------------------------
*/
Tcl_PathType
TclpGetNativePathType(
Tcl_Obj *pathPtr, /* Native path of interest */
| | | | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
*
*----------------------------------------------------------------------
*/
Tcl_PathType
TclpGetNativePathType(
Tcl_Obj *pathPtr, /* Native path of interest */
Tcl_Size *driveNameLengthPtr, /* Returns length of drive, if non-NULL and
* path was absolute */
Tcl_Obj **driveNameRef)
{
Tcl_PathType type = TCL_PATH_ABSOLUTE;
const char *path = TclGetString(pathPtr);
switch (tclPlatform) {
case TCL_PLATFORM_UNIX: {
|
| ︙ | ︙ | |||
461 462 463 464 465 466 467 |
*
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclpNativeSplitPath(
Tcl_Obj *pathPtr, /* Path to split. */
| | | 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
*
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclpNativeSplitPath(
Tcl_Obj *pathPtr, /* Path to split. */
Tcl_Size *lenPtr) /* int to store number of path elements. */
{
Tcl_Obj *resultPtr = NULL; /* Needed only to prevent gcc warnings. */
/*
* Perform platform specific splitting.
*/
|
| ︙ | ︙ | |||
518 519 520 521 522 523 524 |
*----------------------------------------------------------------------
*/
#undef Tcl_SplitPath
void
Tcl_SplitPath(
const char *path, /* Pointer to string containing a path. */
| | | | | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
*----------------------------------------------------------------------
*/
#undef Tcl_SplitPath
void
Tcl_SplitPath(
const char *path, /* Pointer to string containing a path. */
Tcl_Size *argcPtr, /* Pointer to location to fill in with the
* number of elements in the path. */
const char ***argvPtr) /* Pointer to place to store pointer to array
* of pointers to path elements. */
{
Tcl_Obj *resultPtr = NULL; /* Needed only to prevent gcc warnings. */
Tcl_Obj *tmpPtr, *eltPtr;
Tcl_Size i, size, len;
char *p;
const char *str;
/*
* Perform the splitting, using objectified, vfs-aware code.
*/
tmpPtr = Tcl_NewStringObj(path, -1);
Tcl_IncrRefCount(tmpPtr);
resultPtr = Tcl_FSSplitPath(tmpPtr, argcPtr);
Tcl_IncrRefCount(resultPtr);
Tcl_DecrRefCount(tmpPtr);
/*
* Calculate space required for the result.
|
| ︙ | ︙ | |||
754 755 756 757 758 759 760 |
*
*---------------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_FSJoinToPath(
Tcl_Obj *pathPtr, /* Valid path or NULL. */
| | | | 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 |
*
*---------------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_FSJoinToPath(
Tcl_Obj *pathPtr, /* Valid path or NULL. */
Tcl_Size objc, /* Number of array elements to join */
Tcl_Obj *const objv[]) /* Path elements to join. */
{
if (pathPtr == NULL) {
return TclJoinPath(objc, objv, 0);
}
if (objc == 0) {
return TclJoinPath(1, &pathPtr, 0);
}
if (objc == 1) {
Tcl_Obj *pair[2];
pair[0] = pathPtr;
pair[1] = objv[0];
return TclJoinPath(2, pair, 0);
} else {
Tcl_Size elemc = objc + 1;
Tcl_Obj *ret, **elemv = (Tcl_Obj**)Tcl_Alloc(elemc*sizeof(Tcl_Obj *));
elemv[0] = pathPtr;
memcpy(elemv+1, objv, objc*sizeof(Tcl_Obj *));
ret = TclJoinPath(elemc, elemv, 0);
Tcl_Free(elemv);
return ret;
|
| ︙ | ︙ | |||
803 804 805 806 807 808 809 |
void
TclpNativeJoinPath(
Tcl_Obj *prefix,
const char *joining)
{
int needsSep;
| | | 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
void
TclpNativeJoinPath(
Tcl_Obj *prefix,
const char *joining)
{
int needsSep;
Tcl_Size length;
char *dest;
const char *p;
const char *start;
start = Tcl_GetStringFromObj(prefix, &length);
/*
|
| ︙ | ︙ | |||
844 845 846 847 848 849 850 | } needsSep = 0; /* * Append the element, eliminating duplicate and trailing slashes. */ | | | 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 |
}
needsSep = 0;
/*
* Append the element, eliminating duplicate and trailing slashes.
*/
Tcl_SetObjLength(prefix, length + strlen(p));
dest = TclGetString(prefix) + length;
for (; *p != '\0'; p++) {
if (*p == '/') {
while (p[1] == '/') {
p++;
}
|
| ︙ | ︙ | |||
923 924 925 926 927 928 929 | * Modifies the Tcl_DString. * *---------------------------------------------------------------------- */ char * Tcl_JoinPath( | | | | | 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 |
* Modifies the Tcl_DString.
*
*----------------------------------------------------------------------
*/
char *
Tcl_JoinPath(
Tcl_Size argc,
const char *const *argv,
Tcl_DString *resultPtr) /* Pointer to previously initialized DString */
{
Tcl_Size i, len;
Tcl_Obj *listObj;
Tcl_Obj *resultObj;
const char *resultStr;
/*
* Build the list of paths.
*/
TclNewObj(listObj);
for (i = 0; i < argc; i++) {
Tcl_ListObjAppendElement(NULL, listObj,
Tcl_NewStringObj(argv[i], -1));
}
/*
* Ask the objectified code to join the paths.
*/
Tcl_IncrRefCount(listObj);
|
| ︙ | ︙ | |||
999 1000 1001 1002 1003 1004 1005 |
const char *name, /* File name, which may begin with "~" (to
* indicate current user's home directory) or
* "~<user>" (to indicate any user's home
* directory). */
Tcl_DString *bufferPtr) /* Uninitialized or free DString filled with
* name. */
{
| | | 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 |
const char *name, /* File name, which may begin with "~" (to
* indicate current user's home directory) or
* "~<user>" (to indicate any user's home
* directory). */
Tcl_DString *bufferPtr) /* Uninitialized or free DString filled with
* name. */
{
Tcl_Obj *path = Tcl_NewStringObj(name, -1);
Tcl_Obj *transPtr;
Tcl_IncrRefCount(path);
transPtr = Tcl_FSGetTranslatedPath(interp, path);
if (transPtr == NULL) {
Tcl_DecrRefCount(path);
return NULL;
|
| ︙ | ︙ | |||
1114 1115 1116 1117 1118 1119 1120 |
Tcl_GlobObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int i, globFlags, join, dir, result;
| | | 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 |
Tcl_GlobObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int i, globFlags, join, dir, result;
Tcl_Size length;
char *string;
const char *separators;
Tcl_Obj *typePtr, *look;
Tcl_Obj *pathOrDir = NULL;
Tcl_DString prefix;
static const char *const options[] = {
"-directory", "-join", "-nocomplain", "-path", "-tails",
|
| ︙ | ︙ | |||
1167 1168 1169 1170 1171 1172 1173 |
* Do nothing; This is normal operations in Tcl 9.
* Keep accepting as a no-op option to accommodate old scripts.
*/
break;
case GLOB_DIR: /* -dir */
if (i == (objc-1)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 |
* Do nothing; This is normal operations in Tcl 9.
* Keep accepting as a no-op option to accommodate old scripts.
*/
break;
case GLOB_DIR: /* -dir */
if (i == (objc-1)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing argument to \"-directory\"", -1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
return TCL_ERROR;
}
if (dir != PATH_NONE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
dir == PATH_DIR
? "\"-directory\" may only be used once"
|
| ︙ | ︙ | |||
1195 1196 1197 1198 1199 1200 1201 |
break;
case GLOB_TAILS: /* -tails */
globFlags |= TCL_GLOBMODE_TAILS;
break;
case GLOB_PATH: /* -path */
if (i == (objc-1)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | | 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 |
break;
case GLOB_TAILS: /* -tails */
globFlags |= TCL_GLOBMODE_TAILS;
break;
case GLOB_PATH: /* -path */
if (i == (objc-1)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing argument to \"-path\"", -1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
return TCL_ERROR;
}
if (dir != PATH_NONE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
dir == PATH_GENERAL
? "\"-path\" may only be used once"
: "\"-path\" cannot be used with \"-dictionary\"",
-1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB",
"BADOPTIONCOMBINATION", NULL);
return TCL_ERROR;
}
dir = PATH_GENERAL;
pathOrDir = objv[i+1];
i++;
break;
case GLOB_TYPE: /* -types */
if (i == (objc-1)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing argument to \"-types\"", -1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL);
return TCL_ERROR;
}
typePtr = objv[i+1];
if (TclListObjLengthM(interp, typePtr, &length) != TCL_OK) {
return TCL_ERROR;
}
i++;
break;
case GLOB_LAST: /* -- */
i++;
goto endOfForLoop;
}
}
endOfForLoop:
if ((globFlags & TCL_GLOBMODE_TAILS) && (pathOrDir == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-tails\" must be used with either "
"\"-directory\" or \"-path\"", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB",
"BADOPTIONCOMBINATION", NULL);
return TCL_ERROR;
}
separators = NULL;
switch (tclPlatform) {
case TCL_PLATFORM_UNIX:
separators = "/";
break;
case TCL_PLATFORM_WINDOWS:
separators = "/\\:";
break;
}
if (dir == PATH_GENERAL) {
Tcl_Size pathlength;
const char *last;
const char *first = Tcl_GetStringFromObj(pathOrDir,&pathlength);
/*
* Find the last path separator in the path
*/
|
| ︙ | ︙ | |||
1287 1288 1289 1290 1291 1292 1293 | /* * The whole thing is a prefix. This means we must remove any * 'tails' flag too, since it is irrelevant now (the same * effect will happen without it), but in particular its use * in TclGlob requires a non-NULL pathOrDir. */ | | | 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 |
/*
* The whole thing is a prefix. This means we must remove any
* 'tails' flag too, since it is irrelevant now (the same
* effect will happen without it), but in particular its use
* in TclGlob requires a non-NULL pathOrDir.
*/
Tcl_DStringAppend(&pref, first, -1);
globFlags &= ~TCL_GLOBMODE_TAILS;
pathOrDir = NULL;
} else {
/*
* Have to split off the end.
*/
|
| ︙ | ︙ | |||
1326 1327 1328 1329 1330 1331 1332 |
Tcl_DStringAppend(&prefix, find, 1);
search = find+1;
if (*search == '\0') {
break;
}
}
if (*search != '\0') {
| | | 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 |
Tcl_DStringAppend(&prefix, find, 1);
search = find+1;
if (*search == '\0') {
break;
}
}
if (*search != '\0') {
Tcl_DStringAppend(&prefix, search, -1);
}
Tcl_DStringFree(&pref);
}
}
if (pathOrDir != NULL) {
Tcl_IncrRefCount(pathOrDir);
|
| ︙ | ︙ | |||
1354 1355 1356 1357 1358 1359 1360 |
globTypes = (Tcl_GlobTypeData *)TclStackAlloc(interp, sizeof(Tcl_GlobTypeData));
globTypes->type = 0;
globTypes->perm = 0;
globTypes->macType = NULL;
globTypes->macCreator = NULL;
while (length-- > 0) {
| | | 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 |
globTypes = (Tcl_GlobTypeData *)TclStackAlloc(interp, sizeof(Tcl_GlobTypeData));
globTypes->type = 0;
globTypes->perm = 0;
globTypes->macType = NULL;
globTypes->macCreator = NULL;
while (length-- > 0) {
Tcl_Size len;
const char *str;
Tcl_ListObjIndex(interp, typePtr, length, &look);
str = Tcl_GetStringFromObj(look, &len);
if (strcmp("readonly", str) == 0) {
globTypes->perm |= TCL_GLOB_PERM_RONLY;
} else if (strcmp("hidden", str) == 0) {
|
| ︙ | ︙ | |||
1412 1413 1414 1415 1416 1417 1418 |
goto badMacTypesArg;
}
globTypes->macType = look;
Tcl_IncrRefCount(look);
} else {
Tcl_Obj *item;
| | | 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 |
goto badMacTypesArg;
}
globTypes->macType = look;
Tcl_IncrRefCount(look);
} else {
Tcl_Obj *item;
Tcl_Size llen;
if ((TclListObjLengthM(NULL, look, &llen) == TCL_OK)
&& (llen == 3)) {
Tcl_ListObjIndex(interp, look, 0, &item);
if (!strcmp("macintosh", TclGetString(item))) {
Tcl_ListObjIndex(interp, look, 1, &item);
if (!strcmp("type", TclGetString(item))) {
|
| ︙ | ︙ | |||
1456 1457 1458 1459 1460 1461 1462 | result = TCL_ERROR; join = 0; goto endOfGlob; badMacTypesArg: Tcl_SetObjResult(interp, Tcl_NewStringObj( "only one MacOS type or creator argument" | | | 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 |
result = TCL_ERROR;
join = 0;
goto endOfGlob;
badMacTypesArg:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"only one MacOS type or creator argument"
" to \"-types\" allowed", -1));
result = TCL_ERROR;
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "BAD", NULL);
join = 0;
goto endOfGlob;
}
}
}
|
| ︙ | ︙ | |||
1636 1637 1638 1639 1640 1641 1642 |
}
p++;
}
tail = p;
Tcl_IncrRefCount(pathPrefix);
} else if (pathPrefix == NULL && (tail[0] == '/'
|| (tail[0] == '\\' && tail[1] == '\\'))) {
| | | | 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 |
}
p++;
}
tail = p;
Tcl_IncrRefCount(pathPrefix);
} else if (pathPrefix == NULL && (tail[0] == '/'
|| (tail[0] == '\\' && tail[1] == '\\'))) {
Tcl_Size driveNameLen;
Tcl_Obj *driveName;
Tcl_Obj *temp = Tcl_NewStringObj(tail, -1);
Tcl_IncrRefCount(temp);
switch (TclGetPathType(temp, NULL, &driveNameLen, &driveName)) {
case TCL_PATH_VOLUME_RELATIVE: {
/*
* Volume relative path which is equivalent to a path in the
* root of the cwd's volume. We will actually return
|
| ︙ | ︙ | |||
1704 1705 1706 1707 1708 1709 1710 |
/*
* Finally if we still haven't managed to generate a path prefix, check if
* the path starts with a current volume.
*/
if (pathPrefix == NULL) {
| | | | 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 |
/*
* Finally if we still haven't managed to generate a path prefix, check if
* the path starts with a current volume.
*/
if (pathPrefix == NULL) {
Tcl_Size driveNameLen;
Tcl_Obj *driveName;
if (TclFSNonnativePathType(tail, strlen(tail), NULL,
&driveNameLen, &driveName) == TCL_PATH_ABSOLUTE) {
pathPrefix = driveName;
tail += driveNameLen;
}
}
/*
* To process a [glob] invocation, this function may be called multiple
* times. Each time, the previously discovered filenames are in the
* interpreter result. We stash that away here so the result is free for
* error messages.
*/
savedResultObj = Tcl_GetObjResult(interp);
Tcl_IncrRefCount(savedResultObj);
Tcl_ResetResult(interp);
TclNewObj(filenamesObj);
Tcl_IncrRefCount(filenamesObj);
|
| ︙ | ︙ | |||
1789 1790 1791 1792 1793 1794 1795 |
* that would add a lot of complexity to the code. This way is a little
* slower (when the -tails flag is given), but much simpler to code.
*
* We do it by rewriting the result list in-place.
*/
if (globFlags & TCL_GLOBMODE_TAILS) {
| | | | 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 |
* that would add a lot of complexity to the code. This way is a little
* slower (when the -tails flag is given), but much simpler to code.
*
* We do it by rewriting the result list in-place.
*/
if (globFlags & TCL_GLOBMODE_TAILS) {
Tcl_Size objc, i;
Tcl_Obj **objv;
Tcl_Size prefixLen;
const char *pre;
/*
* If this length has never been set, set it here.
*/
if (pathPrefix == NULL) {
|
| ︙ | ︙ | |||
1819 1820 1821 1822 1823 1824 1825 |
|| (pre[1] != ':')) {
prefixLen++;
}
}
TclListObjGetElementsM(NULL, filenamesObj, &objc, &objv);
for (i = 0; i< objc; i++) {
| | | 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 |
|| (pre[1] != ':')) {
prefixLen++;
}
}
TclListObjGetElementsM(NULL, filenamesObj, &objc, &objv);
for (i = 0; i< objc; i++) {
Tcl_Size len;
const char *oldStr = Tcl_GetStringFromObj(objv[i], &len);
Tcl_Obj *elem;
if (len == prefixLen) {
if ((pattern[0] == '\0')
|| (strchr(separators, pattern[0]) == NULL)) {
TclNewLiteralStringObj(elem, ".");
|
| ︙ | ︙ | |||
2029 2030 2031 2032 2033 2034 2035 | * Balanced braces. */ closeBrace = p; break; } Tcl_SetObjResult(interp, Tcl_NewStringObj( | | | | 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 |
* Balanced braces.
*/
closeBrace = p;
break;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unmatched open-brace in file name", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB", "BALANCE",
NULL);
return TCL_ERROR;
} else if (*p == '}') {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unmatched close-brace in file name", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB", "BALANCE",
NULL);
return TCL_ERROR;
}
}
/*
|
| ︙ | ︙ | |||
2068 2069 2070 2071 2072 2073 2074 |
*closeBrace = '\0';
for (p = openBrace; p != closeBrace; ) {
p++;
element = p;
SkipToChar(&p, ',');
Tcl_DStringSetLength(&newName, baseLength);
Tcl_DStringAppend(&newName, element, p-element);
| | | 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 |
*closeBrace = '\0';
for (p = openBrace; p != closeBrace; ) {
p++;
element = p;
SkipToChar(&p, ',');
Tcl_DStringSetLength(&newName, baseLength);
Tcl_DStringAppend(&newName, element, p-element);
Tcl_DStringAppend(&newName, closeBrace+1, -1);
result = DoGlob(interp, matchesObj, separators, pathPtr, flags,
Tcl_DStringValue(&newName), types);
if (result != TCL_OK) {
break;
}
}
*closeBrace = '}';
|
| ︙ | ︙ | |||
2143 2144 2145 2146 2147 2148 2149 |
*p = '\0';
TclNewObj(subdirsPtr);
Tcl_IncrRefCount(subdirsPtr);
result = Tcl_FSMatchInDirectory(interp, subdirsPtr, pathPtr,
pattern, &dirOnly);
*p = save;
if (result == TCL_OK) {
| | | | | | 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 |
*p = '\0';
TclNewObj(subdirsPtr);
Tcl_IncrRefCount(subdirsPtr);
result = Tcl_FSMatchInDirectory(interp, subdirsPtr, pathPtr,
pattern, &dirOnly);
*p = save;
if (result == TCL_OK) {
Tcl_Size i, subdirc, repair = -1;
Tcl_Obj **subdirv;
result = TclListObjGetElementsM(interp, subdirsPtr,
&subdirc, &subdirv);
for (i=0; result==TCL_OK && i<subdirc; i++) {
Tcl_Obj *copy = NULL;
result = DoGlob(interp, matchesObj, separators, subdirv[i],
1, p+1, types);
if (copy) {
Tcl_Size end;
Tcl_DecrRefCount(subdirv[i]);
subdirv[i] = copy;
TclListObjLengthM(NULL, matchesObj, &end);
while (repair < end) {
const char *bytes;
Tcl_Size numBytes;
Tcl_Obj *fixme, *newObj;
Tcl_ListObjIndex(NULL, matchesObj, repair, &fixme);
bytes = Tcl_GetStringFromObj(fixme, &numBytes);
newObj = Tcl_NewStringObj(bytes+2, numBytes-2);
Tcl_ListObjReplace(NULL, matchesObj, repair, 1,
1, &newObj);
|
| ︙ | ︙ | |||
2184 2185 2186 2187 2188 2189 2190 |
}
/*
* We reach here with no pattern char in current section
*/
if (*p == '\0') {
| | | 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 |
}
/*
* We reach here with no pattern char in current section
*/
if (*p == '\0') {
Tcl_Size length;
Tcl_DString append;
/*
* This is the code path reached by a command like 'glob foo'.
*
* There are no more wildcards in the pattern and no more unprocessed
* characters in the pattern, so now we can construct the path, and
|
| ︙ | ︙ | |||
2248 2249 2250 2251 2252 2253 2254 |
} else {
joinedPtr = Tcl_DuplicateObj(pathPtr);
if (strchr(separators, Tcl_DStringValue(&append)[0]) == NULL) {
/*
* The current prefix must end in a separator.
*/
| | | 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 |
} else {
joinedPtr = Tcl_DuplicateObj(pathPtr);
if (strchr(separators, Tcl_DStringValue(&append)[0]) == NULL) {
/*
* The current prefix must end in a separator.
*/
Tcl_Size len;
const char *joined = Tcl_GetStringFromObj(joinedPtr,&len);
if ((len > 0) && (strchr(separators, joined[len-1]) == NULL)) {
Tcl_AppendToObj(joinedPtr, "/", 1);
}
}
Tcl_AppendToObj(joinedPtr, Tcl_DStringValue(&append),
|
| ︙ | ︙ | |||
2285 2286 2287 2288 2289 2290 2291 | * The current prefix must end in a separator, unless this is a * volume-relative path. In particular globbing in Windows shares, * when not using -dir or -path, e.g. 'glob [file join * //machine/share/subdir *]' requires adding a separator here. * This behaviour is not currently tested for in the test suite. */ | | | 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 |
* The current prefix must end in a separator, unless this is a
* volume-relative path. In particular globbing in Windows shares,
* when not using -dir or -path, e.g. 'glob [file join
* //machine/share/subdir *]' requires adding a separator here.
* This behaviour is not currently tested for in the test suite.
*/
Tcl_Size len;
const char *joined = Tcl_GetStringFromObj(joinedPtr,&len);
if ((len > 0) && (strchr(separators, joined[len-1]) == NULL)) {
if (Tcl_FSGetPathType(pathPtr) != TCL_PATH_VOLUME_RELATIVE) {
Tcl_AppendToObj(joinedPtr, "/", 1);
}
}
|
| ︙ | ︙ |
Changes to generic/tclFileSystem.h.
| ︙ | ︙ | |||
44 45 46 47 48 49 50 | /* * Private shared functions for use by tclIOUtil.c, tclPathObj.c and * tclFileName.c, and any platform-specific filesystem code. */ MODULE_SCOPE Tcl_PathType TclFSGetPathType(Tcl_Obj *pathPtr, const Tcl_Filesystem **filesystemPtrPtr, | | | | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | /* * Private shared functions for use by tclIOUtil.c, tclPathObj.c and * tclFileName.c, and any platform-specific filesystem code. */ MODULE_SCOPE Tcl_PathType TclFSGetPathType(Tcl_Obj *pathPtr, const Tcl_Filesystem **filesystemPtrPtr, Tcl_Size *driveNameLengthPtr); MODULE_SCOPE Tcl_PathType TclFSNonnativePathType(const char *pathPtr, Tcl_Size pathLen, const Tcl_Filesystem **filesystemPtrPtr, Tcl_Size *driveNameLengthPtr, Tcl_Obj **driveNameRef); MODULE_SCOPE Tcl_PathType TclGetPathType(Tcl_Obj *pathPtr, const Tcl_Filesystem **filesystemPtrPtr, Tcl_Size *driveNameLengthPtr, Tcl_Obj **driveNameRef); MODULE_SCOPE int TclFSEpochOk(size_t filesystemEpoch); MODULE_SCOPE int TclFSCwdIsNative(void); MODULE_SCOPE Tcl_Obj * TclWinVolumeRelativeNormalize(Tcl_Interp *interp, const char *path, Tcl_Obj **useThisCwdPtr); MODULE_SCOPE Tcl_FSPathInFilesystemProc TclNativePathInFilesystem; MODULE_SCOPE Tcl_FSCreateInternalRepProc TclNativeCreateNativeRep; |
| ︙ | ︙ |
Changes to generic/tclHash.c.
| ︙ | ︙ | |||
434 435 436 437 438 439 440 |
void
Tcl_DeleteHashTable(
Tcl_HashTable *tablePtr) /* Table to delete. */
{
Tcl_HashEntry *hPtr, *nextPtr;
const Tcl_HashKeyType *typePtr;
| | | 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
void
Tcl_DeleteHashTable(
Tcl_HashTable *tablePtr) /* Table to delete. */
{
Tcl_HashEntry *hPtr, *nextPtr;
const Tcl_HashKeyType *typePtr;
Tcl_Size i;
if (tablePtr->keyType == TCL_STRING_KEYS) {
typePtr = &tclStringHashKeyType;
} else if (tablePtr->keyType == TCL_ONE_WORD_KEYS) {
typePtr = &tclOneWordHashKeyType;
} else if (tablePtr->keyType == TCL_CUSTOM_TYPE_KEYS
|| tablePtr->keyType == TCL_CUSTOM_PTR_KEYS) {
|
| ︙ | ︙ | |||
583 584 585 586 587 588 589 |
*/
char *
Tcl_HashStats(
Tcl_HashTable *tablePtr) /* Table for which to produce stats. */
{
#define NUM_COUNTERS 10
| | | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
*/
char *
Tcl_HashStats(
Tcl_HashTable *tablePtr) /* Table for which to produce stats. */
{
#define NUM_COUNTERS 10
Tcl_Size i;
TCL_HASH_TYPE count[NUM_COUNTERS], overflow, j;
double average, tmp;
Tcl_HashEntry *hPtr;
char *result, *p;
/*
* Compute a histogram of bucket usage.
|
| ︙ | ︙ | |||
619 620 621 622 623 624 625 |
}
/*
* Print out the histogram and a few other pieces of information.
*/
result = (char *)Tcl_Alloc((NUM_COUNTERS * 60) + 300);
| | | | | | 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
}
/*
* Print out the histogram and a few other pieces of information.
*/
result = (char *)Tcl_Alloc((NUM_COUNTERS * 60) + 300);
snprintf(result, 60, "%" TCL_Z_MODIFIER "u entries in table, %" TCL_Z_MODIFIER "u buckets\n",
tablePtr->numEntries, tablePtr->numBuckets);
p = result + strlen(result);
for (i = 0; i < NUM_COUNTERS; i++) {
snprintf(p, 60, "number of buckets with %" TCL_Z_MODIFIER "u entries: %" TCL_Z_MODIFIER "u\n",
i, count[i]);
p += strlen(p);
}
snprintf(p, 60, "number of buckets with %d or more entries: %" TCL_Z_MODIFIER "u\n",
NUM_COUNTERS, overflow);
p += strlen(p);
snprintf(p, 60, "average search distance for entry: %.1f", average);
return result;
}
/*
*----------------------------------------------------------------------
*
* AllocArrayEntry --
|
| ︙ | ︙ |
Changes to generic/tclHistory.c.
| ︙ | ︙ | |||
65 66 67 68 69 70 71 |
int result;
if (cmd[0]) {
/*
* Call Tcl_RecordAndEvalObj to do the actual work.
*/
| | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
int result;
if (cmd[0]) {
/*
* Call Tcl_RecordAndEvalObj to do the actual work.
*/
cmdPtr = Tcl_NewStringObj(cmd, -1);
Tcl_IncrRefCount(cmdPtr);
result = Tcl_RecordAndEvalObj(interp, cmdPtr, flags);
/*
* Discard the Tcl object created to hold the command.
*/
|
| ︙ | ︙ |
Changes to generic/tclIO.c.
| ︙ | ︙ | |||
170 171 172 173 174 175 176 177 178 179 180 181 182 183 | int errorCode); static int CloseChannelPart(Tcl_Interp *interp, Channel *chanPtr, int errorCode, int flags); static int CloseWrite(Tcl_Interp *interp, Channel *chanPtr); static void CommonGetsCleanup(Channel *chanPtr); static int CopyData(CopyState *csPtr, int mask); static void DeleteTimerHandler(ChannelState *statePtr); static int MoveBytes(CopyState *csPtr); static void MBCallback(CopyState *csPtr, Tcl_Obj *errObj); static void MBError(CopyState *csPtr, int mask, int errorCode); static int MBRead(CopyState *csPtr); static int MBWrite(CopyState *csPtr); static void MBEvent(void *clientData, int mask); | > > | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | int errorCode); static int CloseChannelPart(Tcl_Interp *interp, Channel *chanPtr, int errorCode, int flags); static int CloseWrite(Tcl_Interp *interp, Channel *chanPtr); static void CommonGetsCleanup(Channel *chanPtr); static int CopyData(CopyState *csPtr, int mask); static void DeleteTimerHandler(ChannelState *statePtr); int Lossless(ChannelState *inStatePtr, ChannelState *outStatePtr, long long toRead); static int MoveBytes(CopyState *csPtr); static void MBCallback(CopyState *csPtr, Tcl_Obj *errObj); static void MBError(CopyState *csPtr, int mask, int errorCode); static int MBRead(CopyState *csPtr); static int MBWrite(CopyState *csPtr); static void MBEvent(void *clientData, int mask); |
| ︙ | ︙ | |||
192 193 194 195 196 197 198 | static int DetachChannel(Tcl_Interp *interp, Tcl_Channel chan); static void DiscardInputQueued(ChannelState *statePtr, int discardSavedBuffers); static void DiscardOutputQueued(ChannelState *chanPtr); static Tcl_Size DoRead(Channel *chanPtr, char *dst, Tcl_Size bytesToRead, int allowShortReads); static Tcl_Size DoReadChars(Channel *chan, Tcl_Obj *objPtr, Tcl_Size toRead, | | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | static int DetachChannel(Tcl_Interp *interp, Tcl_Channel chan); static void DiscardInputQueued(ChannelState *statePtr, int discardSavedBuffers); static void DiscardOutputQueued(ChannelState *chanPtr); static Tcl_Size DoRead(Channel *chanPtr, char *dst, Tcl_Size bytesToRead, int allowShortReads); static Tcl_Size DoReadChars(Channel *chan, Tcl_Obj *objPtr, Tcl_Size toRead, int allowShortReads, int appendFlag); static int FilterInputBytes(Channel *chanPtr, GetsState *statePtr); static int FlushChannel(Tcl_Interp *interp, Channel *chanPtr, int calledFromAsyncFlush); static int TclGetsObjBinary(Tcl_Channel chan, Tcl_Obj *objPtr); static Tcl_Encoding GetBinaryEncoding(void); static Tcl_ExitProc FreeBinaryEncoding; |
| ︙ | ︙ | |||
334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
FreeChannelInternalRep, /* freeIntRepProc */
DupChannelInternalRep, /* dupIntRepProc */
NULL, /* updateStringProc */
NULL, /* setFromAnyProc */
TCL_OBJTYPE_V0
};
#define ChanSetInternalRep(objPtr, resPtr) \
do { \
Tcl_ObjInternalRep ir; \
(resPtr)->refCount++; \
ir.twoPtrValue.ptr1 = (resPtr); \
ir.twoPtrValue.ptr2 = NULL; \
Tcl_StoreInternalRep((objPtr), &chanObjType, &ir); \
| > > > | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
FreeChannelInternalRep, /* freeIntRepProc */
DupChannelInternalRep, /* dupIntRepProc */
NULL, /* updateStringProc */
NULL, /* setFromAnyProc */
TCL_OBJTYPE_V0
};
#define GetIso88591() \
(binaryEncoding ? Tcl_GetEncoding(NULL, "iso8859-1") : binaryEncoding)
#define ChanSetInternalRep(objPtr, resPtr) \
do { \
Tcl_ObjInternalRep ir; \
(resPtr)->refCount++; \
ir.twoPtrValue.ptr1 = (resPtr); \
ir.twoPtrValue.ptr2 = NULL; \
Tcl_StoreInternalRep((objPtr), &chanObjType, &ir); \
|
| ︙ | ︙ | |||
960 961 962 963 964 965 966 | * an interpreter is deleted, via the AssocData cleanup mechanism. * * Results: * None. * * Side effects: * Deletes the hash table of channels. May close channels. May flush | | | 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 | * an interpreter is deleted, via the AssocData cleanup mechanism. * * Results: * None. * * Side effects: * Deletes the hash table of channels. May close channels. May flush * output on closed channels. Removes any channelEvent handlers that were * registered in this interpreter. * *---------------------------------------------------------------------- */ static void DeleteChannelTable( |
| ︙ | ︙ | |||
993 994 995 996 997 998 999 |
hTblPtr = (Tcl_HashTable *)clientData;
for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); hPtr != NULL;
hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch)) {
chanPtr = (Channel *)Tcl_GetHashValue(hPtr);
statePtr = chanPtr->state;
/*
| | | 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 |
hTblPtr = (Tcl_HashTable *)clientData;
for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); hPtr != NULL;
hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch)) {
chanPtr = (Channel *)Tcl_GetHashValue(hPtr);
statePtr = chanPtr->state;
/*
* Remove any file events registered in this interpreter.
*/
for (sPtr = statePtr->scriptRecordPtr, prevPtr = NULL;
sPtr != NULL; sPtr = nextPtr) {
nextPtr = sPtr->nextPtr;
if (sPtr->interp == interp) {
if (prevPtr == NULL) {
|
| ︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 |
statePtr = ((Channel *) chan)->state->bottomChanPtr->state;
if (GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal recursive call to close through close-handler"
| | | 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 |
statePtr = ((Channel *) chan)->state->bottomChanPtr->state;
if (GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal recursive call to close through close-handler"
" of channel", -1));
}
return TCL_ERROR;
}
if (DetachChannel(interp, chan) != TCL_OK) {
return TCL_OK;
}
|
| ︙ | ︙ | |||
1412 1413 1414 1415 1416 1417 1418 |
Tcl_Channel
Tcl_GetChannel(
Tcl_Interp *interp, /* Interpreter in which to find or create the
* channel. */
const char *chanName, /* The name of the channel. */
int *modePtr) /* Where to store the mode in which the
| | | 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 |
Tcl_Channel
Tcl_GetChannel(
Tcl_Interp *interp, /* Interpreter in which to find or create the
* channel. */
const char *chanName, /* The name of the channel. */
int *modePtr) /* Where to store the mode in which the
* channel was opened? Will contain an OR'ed
* combination of TCL_READABLE and
* TCL_WRITABLE, if non-NULL. */
{
Channel *chanPtr; /* The actual channel. */
Tcl_HashTable *hTblPtr; /* Hash table of channels. */
Tcl_HashEntry *hPtr; /* Search variable. */
const char *name; /* Translated name. */
|
| ︙ | ︙ | |||
1495 1496 1497 1498 1499 1500 1501 |
int
TclGetChannelFromObj(
Tcl_Interp *interp, /* Interpreter in which to find or create the
* channel. */
Tcl_Obj *objPtr,
Tcl_Channel *channelPtr,
int *modePtr, /* Where to store the mode in which the
| | | 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 |
int
TclGetChannelFromObj(
Tcl_Interp *interp, /* Interpreter in which to find or create the
* channel. */
Tcl_Obj *objPtr,
Tcl_Channel *channelPtr,
int *modePtr, /* Where to store the mode in which the
* channel was opened? Will contain an OR'ed
* combination of TCL_READABLE and
* TCL_WRITABLE, if non-NULL. */
TCL_UNUSED(int) /*flags*/)
{
ChannelState *statePtr;
ResolvedChanName *resPtr = NULL;
Tcl_Channel chan;
|
| ︙ | ︙ | |||
1666 1667 1668 1669 1670 1671 1672 |
* Note the strange bit of protection taking place here. If the system
* encoding name is reported back as "binary", something weird is
* happening. Tcl provides no "binary" encoding, so someone else has
* provided one. We ignore it so as not to interfere with the "magic"
* interpretation that Tcl_Channels give to the "-encoding binary" option.
*/
| < < | < | 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 |
* Note the strange bit of protection taking place here. If the system
* encoding name is reported back as "binary", something weird is
* happening. Tcl provides no "binary" encoding, so someone else has
* provided one. We ignore it so as not to interfere with the "magic"
* interpretation that Tcl_Channels give to the "-encoding binary" option.
*/
name = Tcl_GetEncodingName(NULL);
statePtr->encoding = Tcl_GetEncoding(NULL, name);
statePtr->inputEncodingState = NULL;
statePtr->inputEncodingFlags = TCL_ENCODING_START;
CHANNEL_PROFILE_SET(statePtr->inputEncodingFlags,
TCL_ENCODING_PROFILE_DEFAULT);
statePtr->outputEncodingState = NULL;
statePtr->outputEncodingFlags = TCL_ENCODING_START;
CHANNEL_PROFILE_SET(statePtr->outputEncodingFlags,
|
| ︙ | ︙ | |||
1907 1908 1909 1910 1911 1912 1913 |
* are not only useless but actually distorts our view of the system.
*
* To preserve the information without having to read them again and to
* avoid problems with the location in the channel (seeking might be
* impossible) we move the buffers from the common state structure into
* the channel itself. We use the buffers in the channel below the new
* transformation to hold the data. In the future this allows us to write
| | | 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 |
* are not only useless but actually distorts our view of the system.
*
* To preserve the information without having to read them again and to
* avoid problems with the location in the channel (seeking might be
* impossible) we move the buffers from the common state structure into
* the channel itself. We use the buffers in the channel below the new
* transformation to hold the data. In the future this allows us to write
* transformations which preread data and push the unused part back when
* they are going away.
*/
if (((mask & TCL_READABLE) != 0) && (statePtr->inQueueHead != NULL)) {
/*
* When statePtr->inQueueHead is not NULL, we know
* prevChanPtr->inQueueHead must be NULL.
|
| ︙ | ︙ | |||
2016 2017 2018 2019 2020 2021 2022 | * Unstacks an entry in the hash table for a Tcl_Channel record. This is * the reverse to 'Tcl_StackChannel'. * * Results: * A standard Tcl result. * * Side effects: | | | 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 | * Unstacks an entry in the hash table for a Tcl_Channel record. This is * the reverse to 'Tcl_StackChannel'. * * Results: * A standard Tcl result. * * Side effects: * If TCL_ERROR is returned, the Posix error code will be set with * Tcl_SetErrno. May leave a message in interp result as well. * *---------------------------------------------------------------------- */ int Tcl_UnstackChannel( |
| ︙ | ︙ | |||
2039 2040 2041 2042 2043 2044 2045 |
* This operation should occur at the top of a channel stack.
*/
chanPtr = statePtr->topChanPtr;
if (chanPtr->downChanPtr != NULL) {
/*
| | | 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 |
* This operation should occur at the top of a channel stack.
*/
chanPtr = statePtr->topChanPtr;
if (chanPtr->downChanPtr != NULL) {
/*
* Instead of manipulating the per-thread / per-interp list/hash table
* of registered channels we wind down the state of the
* transformation, and then restore the state of underlying channel
* into the old structure.
*
* TODO: Figure out how to handle the situation where the chan
* operations called below by this unstacking operation cause
* another unstacking recursively. In that case the downChanPtr
|
| ︙ | ︙ | |||
2583 2584 2585 2586 2587 2588 2589 |
if (mustDiscard) {
ReleaseChannelBuffer(bufPtr);
return;
}
/*
| | | | 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 |
if (mustDiscard) {
ReleaseChannelBuffer(bufPtr);
return;
}
/*
* Only save buffers which have the requested buffer size for the channel.
* This is to honor dynamic changes of the buffe rsize made by the user.
*/
if ((bufPtr->bufLength) != statePtr->bufSize + BUFFER_PADDING) {
ReleaseChannelBuffer(bufPtr);
return;
}
|
| ︙ | ︙ | |||
2697 2698 2699 2700 2701 2702 2703 |
if (!GotFlag(statePtr, CHANNEL_DEAD)) {
return 0;
}
Tcl_SetErrno(EINVAL);
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 |
if (!GotFlag(statePtr, CHANNEL_DEAD)) {
return 0;
}
Tcl_SetErrno(EINVAL);
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unable to access channel: invalid channel", -1));
}
return 1;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
2744 2745 2746 2747 2748 2749 2750 |
int wroteSome = 0; /* Set to one if any data was written to the
* driver. */
int bufExists;
/*
* Prevent writing on a dead channel -- a channel that has been closed but
* not yet deallocated. This can occur if the exit handler for the channel
| | | 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 |
int wroteSome = 0; /* Set to one if any data was written to the
* driver. */
int bufExists;
/*
* Prevent writing on a dead channel -- a channel that has been closed but
* not yet deallocated. This can occur if the exit handler for the channel
* deallocation runs before all channels are unregistered in all
* interpreters.
*/
if (CheckForDeadChannel(interp, statePtr)) {
return -1;
}
|
| ︙ | ︙ | |||
2859 2860 2861 2862 2863 2864 2865 |
/*
* Decide whether to report the error upwards or defer it.
*/
if (calledFromAsyncFlush) {
/*
* TIP #219, Tcl Channel Reflection API.
| | | | 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 |
/*
* Decide whether to report the error upwards or defer it.
*/
if (calledFromAsyncFlush) {
/*
* TIP #219, Tcl Channel Reflection API.
* When deferring the error copy a message from the bypass into
* the unreported area. Or discard it if the new error is to
* be ignored in favor of an earlier deferred error.
*/
Tcl_Obj *msg = statePtr->chanMsg;
if (statePtr->unreportedError == 0) {
statePtr->unreportedError = errorCode;
statePtr->unreportedMsg = msg;
|
| ︙ | ︙ | |||
2895 2896 2897 2898 2899 2900 2901 |
* regular message if nothing was found in the bypasses.
*/
Tcl_SetErrno(errorCode);
if (interp != NULL && !TclChanCaughtErrorBypass(interp,
(Tcl_Channel) chanPtr)) {
Tcl_SetObjResult(interp,
| | | 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 |
* regular message if nothing was found in the bypasses.
*/
Tcl_SetErrno(errorCode);
if (interp != NULL && !TclChanCaughtErrorBypass(interp,
(Tcl_Channel) chanPtr)) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj(Tcl_PosixError(interp), -1));
}
/*
* An unreportable bypassed message is kept, for the caller of
* Tcl_Seek, Tcl_Write, etc.
*/
}
|
| ︙ | ︙ | |||
3205 3206 3207 3208 3209 3210 3211 | * Side effects: * Resets the field 'nextCSPtr' of the specified channel state to NULL. * * NOTE: * The channel to cut out of the list must not be referenced in any * interpreter. This is something this procedure cannot check (despite * the refcount) because the caller usually wants fiddle with the channel | | | | 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 |
* Side effects:
* Resets the field 'nextCSPtr' of the specified channel state to NULL.
*
* NOTE:
* The channel to cut out of the list must not be referenced in any
* interpreter. This is something this procedure cannot check (despite
* the refcount) because the caller usually wants fiddle with the channel
* (like transferring it to a different thread) and thus keeps the
* refcount artificially high to prevent its destruction.
*
*----------------------------------------------------------------------
*/
static void
CutChannel(
Tcl_Channel chan) /* The channel being removed. Must not be
|
| ︙ | ︙ | |||
3320 3321 3322 3323 3324 3325 3326 | * * Side effects: * Nothing. * * NOTE: * The channel to splice into the list must not be referenced in any * interpreter. This is something this procedure cannot check (despite | | | | | 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 |
*
* Side effects:
* Nothing.
*
* NOTE:
* The channel to splice into the list must not be referenced in any
* interpreter. This is something this procedure cannot check (despite
* the refcount) because the caller usually wants fiddle with the channel
* (like transferring it to a different thread) and thus keeps the
* refcount artificially high to prevent its destruction.
*
*----------------------------------------------------------------------
*/
static void
SpliceChannel(
Tcl_Channel chan) /* The channel being added. Must not be
|
| ︙ | ︙ | |||
3458 3459 3460 3461 3462 3463 3464 |
Tcl_Panic("called Tcl_Close on channel with refCount > 0");
}
if (GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal recursive call to close through close-handler"
| | | > | 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 |
Tcl_Panic("called Tcl_Close on channel with refCount > 0");
}
if (GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal recursive call to close through close-handler"
" of channel", -1));
}
return TCL_ERROR;
}
SetFlag(statePtr, CHANNEL_INCLOSE);
/*
* When the channel has an escape sequence driven encoding such as
* iso2022, the terminated escape sequence must write to the buffer.
*/
stickyError = 0;
if (GotFlag(statePtr, TCL_WRITABLE)
&& (statePtr->encoding != GetBinaryEncoding())
&& !(statePtr->outputEncodingFlags & TCL_ENCODING_START)) {
int code = CheckChannelErrors(statePtr, TCL_WRITABLE);
if (code == 0) {
statePtr->outputEncodingFlags |= TCL_ENCODING_END;
code = WriteChars(chanPtr, "", 0);
statePtr->outputEncodingFlags &= ~TCL_ENCODING_END;
|
| ︙ | ︙ | |||
3561 3562 3563 3564 3565 3566 3567 |
result = EINVAL;
}
if (stickyError != 0) {
Tcl_SetErrno(stickyError);
if (interp != NULL) {
Tcl_SetObjResult(interp,
| | | | 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 |
result = EINVAL;
}
if (stickyError != 0) {
Tcl_SetErrno(stickyError);
if (interp != NULL) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj(Tcl_PosixError(interp), -1));
}
return TCL_ERROR;
}
/*
* Bug 97069ea11a: set error message if a flush code is set and no error
* message set up to now.
*/
if (flushcode != 0) {
/* flushcode has precedence, if available */
result = flushcode;
}
if ((result != 0) && (result != TCL_ERROR) && (interp != NULL)
&& 0 == Tcl_GetCharLength(Tcl_GetObjResult(interp))) {
Tcl_SetErrno(result);
Tcl_SetObjResult(interp,
Tcl_NewStringObj(Tcl_PosixError(interp), -1));
}
if (result != 0) {
return TCL_ERROR;
}
return TCL_OK;
}
|
| ︙ | ︙ | |||
3651 3652 3653 3654 3655 3656 3657 |
/*
* Is the channel unstacked ? If not we fail.
*/
if (chanPtr != statePtr->topChanPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 |
/*
* Is the channel unstacked ? If not we fail.
*/
if (chanPtr != statePtr->topChanPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"half-close not applicable to stack of transformations", -1));
return TCL_ERROR;
}
/*
* Check direction against channel mode. It is an error if we try to close
* a direction not supported by the channel (already closed, or never
* opened for that direction).
|
| ︙ | ︙ | |||
3684 3685 3686 3687 3688 3689 3690 |
* That won't do.
*/
if (GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal recursive call to close through close-handler"
| | | 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 |
* That won't do.
*/
if (GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal recursive call to close through close-handler"
" of channel", -1));
}
return TCL_ERROR;
}
if (flags & TCL_CLOSE_READ) {
/*
* Call the finalization code directly. There are no events to handle,
|
| ︙ | ︙ | |||
3733 3734 3735 3736 3737 3738 3739 | * A standard Tcl result. * * Side effects: * Closes the write side of the channel. * * NOTE: * CloseWrite removes the channel as far as the user is concerned. | | | 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 | * A standard Tcl result. * * Side effects: * Closes the write side of the channel. * * NOTE: * CloseWrite removes the channel as far as the user is concerned. * However, the output data structures may continue to exist for a while * longer if it has a background flush scheduled. The device itself is * eventually closed and the channel structures modified, in * CloseChannelPart, below. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ | |||
4175 4176 4177 4178 4179 4180 4181 |
if (statePtr->encoding) {
return WriteChars(chanPtr, src, len);
}
/*
* Inefficient way to convert UTF-8 to byte-array, but the code
* parallels the way it is done for objects. Special case for 1-byte
| | | 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 |
if (statePtr->encoding) {
return WriteChars(chanPtr, src, len);
}
/*
* Inefficient way to convert UTF-8 to byte-array, but the code
* parallels the way it is done for objects. Special case for 1-byte
* (used by e.g. [puts] for the \n) could be extended to more efficient
* translation of the src string.
*/
if ((len == 1) && (UCHAR(*src) < 0xC0)) {
return WriteBytes(chanPtr, src, len);
}
|
| ︙ | ︙ | |||
4260 4261 4262 4263 4264 4265 4266 |
/*
* Note original code always called WriteChars even if srcLen 0
* so we will too.
*/
do {
int chunkSize = srcLen > INT_MAX ? INT_MAX : srcLen;
int written;
| < < < | < | 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 |
/*
* Note original code always called WriteChars even if srcLen 0
* so we will too.
*/
do {
int chunkSize = srcLen > INT_MAX ? INT_MAX : srcLen;
int written;
written = WriteChars(chanPtr, src, chunkSize);
if (written < 0) {
return TCL_INDEX_NONE;
}
totalWritten += written;
srcLen -= chunkSize;
} while (srcLen);
return totalWritten;
|
| ︙ | ︙ | |||
4418 4419 4420 4421 4422 4423 4424 | * See io-75.2, TCL bug 6978c01b65. * Check, if an encoding error occured and should be reported to the * script level. * This happens, if a written character may not be represented by the * current output encoding and strict encoding is active. */ | > | < < < | < | > | 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 |
* See io-75.2, TCL bug 6978c01b65.
* Check, if an encoding error occured and should be reported to the
* script level.
* This happens, if a written character may not be represented by the
* current output encoding and strict encoding is active.
*/
if (
(result == TCL_CONVERT_UNKNOWN || result == TCL_CONVERT_SYNTAX)
||
/*
* We're reading from invalid/incomplete UTF-8.
*/
((result != TCL_OK) && (srcRead + dstWrote == 0))
) {
encodingError = 1;
result = TCL_OK;
}
bufPtr->nextAdded += dstWrote;
src += srcRead;
srcLen -= srcRead;
|
| ︙ | ︙ | |||
4487 4488 4489 4490 4491 4492 4493 | * When translating from UTF-8 to external encoding, we allowed * the translation to produce a character that crossed the end of * the output buffer, so that we would get a completely full * buffer before flushing it. The extra bytes will be moved to the * beginning of the next buffer. */ | | | | 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 |
* When translating from UTF-8 to external encoding, we allowed
* the translation to produce a character that crossed the end of
* the output buffer, so that we would get a completely full
* buffer before flushing it. The extra bytes will be moved to the
* beginning of the next buffer.
*/
saved = -SpaceLeft(bufPtr);
memcpy(safe, dst + dstLen, saved);
bufPtr->nextAdded = bufPtr->bufLength;
}
if ((srcLen + saved == 0) && (result == TCL_OK)) {
endEncoding = 0;
}
if (IsBufferFull(bufPtr)) {
if (FlushChannel(NULL, chanPtr, 0) != 0) {
return -1;
}
flushed += statePtr->bufSize;
/*
* We just flushed. So if we have needNlFlush set to record that
* we need to flush because there is a (translated) newline in the
* buffer, that's likely not true any more. But there is a tricky
* exception. If we have saved bytes that did not really get
* flushed and those bytes came from a translation of a newline as
* the last thing taken from the src array, then needNlFlush needs
* to remain set to flag that the next buffer still needs a
* newline flush.
*/
|
| ︙ | ︙ | |||
4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 |
Tcl_Size oldLength;
Tcl_Encoding encoding;
char *dst, *dstEnd, *eol, *eof;
Tcl_EncodingState oldState;
if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR)) {
UpdateInterest(chanPtr);
Tcl_SetErrno(EILSEQ);
return TCL_INDEX_NONE;
}
if (CheckChannelErrors(statePtr, TCL_READABLE) != 0) {
return TCL_INDEX_NONE;
}
| > | 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 |
Tcl_Size oldLength;
Tcl_Encoding encoding;
char *dst, *dstEnd, *eol, *eof;
Tcl_EncodingState oldState;
if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR)) {
UpdateInterest(chanPtr);
ResetFlag(statePtr, CHANNEL_EOF|CHANNEL_ENCODING_ERROR);
Tcl_SetErrno(EILSEQ);
return TCL_INDEX_NONE;
}
if (CheckChannelErrors(statePtr, TCL_READABLE) != 0) {
return TCL_INDEX_NONE;
}
|
| ︙ | ︙ | |||
4644 4645 4646 4647 4648 4649 4650 |
/*
* A binary version of Tcl_GetsObj. This could also handle encodings that
* are ascii-7 pure (iso8859, utf-8, ...) with a final encoding conversion
* done on objPtr.
*/
| | | 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 |
/*
* A binary version of Tcl_GetsObj. This could also handle encodings that
* are ascii-7 pure (iso8859, utf-8, ...) with a final encoding conversion
* done on objPtr.
*/
if (statePtr->encoding == GetBinaryEncoding()
&& ((statePtr->inputTranslation == TCL_TRANSLATE_LF)
|| (statePtr->inputTranslation == TCL_TRANSLATE_CR))
&& Tcl_GetByteArrayFromObj(objPtr, (size_t *)NULL) != NULL) {
return TclGetsObjBinary(chan, objPtr);
}
/*
|
| ︙ | ︙ | |||
4674 4675 4676 4677 4678 4679 4680 |
oldFlags = statePtr->inputEncodingFlags;
oldState = statePtr->inputEncodingState;
oldRemoved = BUFFER_PADDING;
if (bufPtr != NULL) {
oldRemoved = bufPtr->nextRemoved;
}
| < < < < < < < < < | 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 |
oldFlags = statePtr->inputEncodingFlags;
oldState = statePtr->inputEncodingState;
oldRemoved = BUFFER_PADDING;
if (bufPtr != NULL) {
oldRemoved = bufPtr->nextRemoved;
}
/*
* Object used by FilterInputBytes to keep track of how much data has been
* consumed from the channel buffers.
*/
gs.objPtr = objPtr;
gs.dstPtr = &dst;
|
| ︙ | ︙ | |||
4758 4759 4760 4761 4762 4763 4764 |
case TCL_TRANSLATE_CRLF:
for (eol = dst; eol < dstEnd; eol++) {
if (*eol == '\r') {
eol++;
/*
* If a CR is at the end of the buffer, then check for a
| | | 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 |
case TCL_TRANSLATE_CRLF:
for (eol = dst; eol < dstEnd; eol++) {
if (*eol == '\r') {
eol++;
/*
* If a CR is at the end of the buffer, then check for a
* LF at the beginning of the next buffer, unless EOF char
* was found already.
*/
if (eol >= dstEnd) {
Tcl_Size offset;
if (eol != eof) {
|
| ︙ | ︙ | |||
4880 4881 4882 4883 4884 4885 4886 |
goto done;
}
goto gotEOL;
} else if (gs.bytesWrote == 0
&& GotFlag(statePtr, CHANNEL_ENCODING_ERROR)
&& !GotFlag(statePtr, CHANNEL_NONBLOCKING)) {
/* Set eol to the position that caused the encoding error, and then
| | | | 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 |
goto done;
}
goto gotEOL;
} else if (gs.bytesWrote == 0
&& GotFlag(statePtr, CHANNEL_ENCODING_ERROR)
&& !GotFlag(statePtr, CHANNEL_NONBLOCKING)) {
/* Set eol to the position that caused the encoding error, and then
* continue to gotEOL, which stores the data that was decoded
* without error to objPtr. This allows the caller to do something
* useful with the data decoded so far, and also results in the
* position of the file being the first byte that was not
* successfully decoded, allowing further processing at exactly that
* point, if desired.
*/
eol = dstEnd;
goto gotEOL;
}
dst = dstEnd;
}
|
| ︙ | ︙ | |||
5005 5006 5007 5008 5009 5010 5011 |
if (chanPtr != statePtr->topChanPtr) {
TclChannelRelease((Tcl_Channel)chanPtr);
chanPtr = statePtr->topChanPtr;
TclChannelPreserve((Tcl_Channel)chanPtr);
}
UpdateInterest(chanPtr);
TclChannelRelease((Tcl_Channel)chanPtr);
| | | > | 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 |
if (chanPtr != statePtr->topChanPtr) {
TclChannelRelease((Tcl_Channel)chanPtr);
chanPtr = statePtr->topChanPtr;
TclChannelPreserve((Tcl_Channel)chanPtr);
}
UpdateInterest(chanPtr);
TclChannelRelease((Tcl_Channel)chanPtr);
if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && gs.bytesWrote == 0) {
bufPtr->nextRemoved = oldRemoved;
Tcl_SetErrno(EILSEQ);
copiedTotal = -1;
}
ResetFlag(statePtr, CHANNEL_ENCODING_ERROR);
return copiedTotal;
}
/*
*---------------------------------------------------------------------------
*
* TclGetsObjBinary --
|
| ︙ | ︙ | |||
5229 5230 5231 5232 5233 5234 5235 |
bufPtr->nextRemoved += rawLen + skip;
/*
* Convert the buffer if there was an encoding.
* XXX - unimplemented.
*/
| | | 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 |
bufPtr->nextRemoved += rawLen + skip;
/*
* Convert the buffer if there was an encoding.
* XXX - unimplemented.
*/
if (statePtr->encoding != GetBinaryEncoding()) {
}
/*
* Recycle all the emptied buffers.
*/
CommonGetsCleanup(chanPtr);
|
| ︙ | ︙ | |||
5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 |
result = Tcl_ExternalToUtf(NULL, gsPtr->encoding, raw, rawLen,
statePtr->inputEncodingFlags | TCL_ENCODING_NO_TERMINATE,
&statePtr->inputEncodingState, dst, spaceLeft, &gsPtr->rawRead,
&gsPtr->bytesWrote, &gsPtr->charsWrote);
if (result == TCL_CONVERT_UNKNOWN || result == TCL_CONVERT_SYNTAX) {
SetFlag(statePtr, CHANNEL_ENCODING_ERROR);
result = TCL_OK;
}
/*
* Make sure that if we go through 'gets', that we reset the
* TCL_ENCODING_START flag still. [Bug #523988]
*/
| > > | 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 |
result = Tcl_ExternalToUtf(NULL, gsPtr->encoding, raw, rawLen,
statePtr->inputEncodingFlags | TCL_ENCODING_NO_TERMINATE,
&statePtr->inputEncodingState, dst, spaceLeft, &gsPtr->rawRead,
&gsPtr->bytesWrote, &gsPtr->charsWrote);
if (result == TCL_CONVERT_UNKNOWN || result == TCL_CONVERT_SYNTAX) {
SetFlag(statePtr, CHANNEL_ENCODING_ERROR);
ResetFlag(statePtr, CHANNEL_STICKY_EOF);
ResetFlag(statePtr, CHANNEL_EOF);
result = TCL_OK;
}
/*
* Make sure that if we go through 'gets', that we reset the
* TCL_ENCODING_START flag still. [Bug #523988]
*/
|
| ︙ | ︙ | |||
5798 5799 5800 5801 5802 5803 5804 |
}
RecycleBuffer(chanPtr->state, bufPtr, 0);
}
}
/*
* Go to the driver only if we got nothing from pushback. Have to do it
| | | 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 |
}
RecycleBuffer(chanPtr->state, bufPtr, 0);
}
}
/*
* Go to the driver only if we got nothing from pushback. Have to do it
* this way to avoid EOF mistimings when we consider the ability that EOF
* may not be a permanent condition in the driver, and in that case we
* have to synchronize.
*/
if (copied) {
return copied;
}
|
| ︙ | ︙ | |||
5897 5898 5899 5900 5901 5902 5903 |
* data in the buffers.
*/
UpdateInterest(chanPtr);
return TCL_INDEX_NONE;
}
| | | 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 |
* data in the buffers.
*/
UpdateInterest(chanPtr);
return TCL_INDEX_NONE;
}
return DoReadChars(chanPtr, objPtr, toRead, 0, appendFlag);
}
/*
*---------------------------------------------------------------------------
*
* DoReadChars --
*
* Reads from the channel until the requested number of characters have
|
| ︙ | ︙ | |||
5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 |
static Tcl_Size
DoReadChars(
Channel *chanPtr, /* The channel to read. */
Tcl_Obj *objPtr, /* Input data is stored in this object. */
Tcl_Size toRead, /* Maximum number of characters to store, or
* TCL_INDEX_NONE to read all available data (up to EOF or
* when channel blocks). */
int appendFlag) /* If non-zero, data read from the channel
* will be appended to the object. Otherwise,
* the data will replace the existing contents
* of the object. */
{
ChannelState *statePtr = chanPtr->state;
/* State info for channel */
ChannelBuffer *bufPtr;
Tcl_Size copied;
int result;
Tcl_Encoding encoding = statePtr->encoding;
int binaryMode;
#define UTF_EXPANSION_FACTOR 1024
int factor = UTF_EXPANSION_FACTOR;
| > < < < < < < < < < < < < < < < < < < < < < < < < < < > | 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 |
static Tcl_Size
DoReadChars(
Channel *chanPtr, /* The channel to read. */
Tcl_Obj *objPtr, /* Input data is stored in this object. */
Tcl_Size toRead, /* Maximum number of characters to store, or
* TCL_INDEX_NONE to read all available data (up to EOF or
* when channel blocks). */
int allowShortReads, /* Allow half-blocking (pipes,sockets) */
int appendFlag) /* If non-zero, data read from the channel
* will be appended to the object. Otherwise,
* the data will replace the existing contents
* of the object. */
{
ChannelState *statePtr = chanPtr->state;
/* State info for channel */
ChannelBuffer *bufPtr;
Tcl_Size copied;
int result;
Tcl_Encoding encoding = statePtr->encoding;
int binaryMode;
#define UTF_EXPANSION_FACTOR 1024
int factor = UTF_EXPANSION_FACTOR;
if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR)) {
ResetFlag(statePtr, CHANNEL_EOF|CHANNEL_ENCODING_ERROR);
/* TODO: We don't need this call? */
UpdateInterest(chanPtr);
Tcl_SetErrno(EILSEQ);
return -1;
}
/*
* Early out when next read will see eofchar.
|
| ︙ | ︙ | |||
6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 |
/*
* This operation should occur at the top of a channel stack.
*/
chanPtr = statePtr->topChanPtr;
TclChannelPreserve((Tcl_Channel)chanPtr);
/*
* Must clear the BLOCKED|EOF flags here since we check before reading.
*/
if (GotFlag(statePtr, CHANNEL_EOF)) {
statePtr->inputEncodingFlags |= TCL_ENCODING_START;
| > > > > > > > > > > > > > > > > | 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 |
/*
* This operation should occur at the top of a channel stack.
*/
chanPtr = statePtr->topChanPtr;
TclChannelPreserve((Tcl_Channel)chanPtr);
binaryMode = (encoding == GetBinaryEncoding())
&& (statePtr->inputTranslation == TCL_TRANSLATE_LF)
&& (statePtr->inEofChar == '\0');
if (appendFlag) {
if (binaryMode && (NULL == Tcl_GetByteArrayFromObj(objPtr, (size_t *)NULL))) {
binaryMode = 0;
}
} else {
if (binaryMode) {
Tcl_SetByteArrayLength(objPtr, 0);
} else {
Tcl_SetObjLength(objPtr, 0);
}
}
/*
* Must clear the BLOCKED|EOF flags here since we check before reading.
*/
if (GotFlag(statePtr, CHANNEL_EOF)) {
statePtr->inputEncodingFlags |= TCL_ENCODING_START;
|
| ︙ | ︙ | |||
6055 6056 6057 6058 6059 6060 6061 | * then CHANNEL_ENCODING_ERROR was caused by data that occurred * after the EOF character was encountered, so it doesn't count as * a real error. */ if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && !GotFlag(statePtr, CHANNEL_STICKY_EOF) | | < < < < | | | 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 |
* then CHANNEL_ENCODING_ERROR was caused by data that occurred
* after the EOF character was encountered, so it doesn't count as
* a real error.
*/
if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR)
&& !GotFlag(statePtr, CHANNEL_STICKY_EOF)
&& (!GotFlag(statePtr, CHANNEL_NONBLOCKING))) {
goto finish;
}
}
if (copiedNow < 0) {
if (GotFlag(statePtr, CHANNEL_EOF)) {
break;
}
if ((GotFlag(statePtr, CHANNEL_NONBLOCKING) || allowShortReads)
&& GotFlag(statePtr, CHANNEL_BLOCKED)) {
break;
}
result = GetInput(chanPtr);
if (chanPtr != statePtr->topChanPtr) {
TclChannelRelease((Tcl_Channel)chanPtr);
chanPtr = statePtr->topChanPtr;
TclChannelPreserve((Tcl_Channel)chanPtr);
|
| ︙ | ︙ | |||
6104 6105 6106 6107 6108 6109 6110 |
*/
if (toRead == 0) {
ResetFlag(statePtr, CHANNEL_BLOCKED);
}
/*
| | | 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 |
*/
if (toRead == 0) {
ResetFlag(statePtr, CHANNEL_BLOCKED);
}
/*
* Regenerate chanPtr in case it was changed due to
* self-modifying reflected transforms.
*/
if (chanPtr != statePtr->topChanPtr) {
TclChannelRelease((Tcl_Channel)chanPtr);
chanPtr = statePtr->topChanPtr;
TclChannelPreserve((Tcl_Channel)chanPtr);
|
| ︙ | ︙ | |||
6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 |
assert(!GotFlag(statePtr, CHANNEL_EOF)
|| GotFlag(statePtr, CHANNEL_STICKY_EOF)
|| GotFlag(statePtr, CHANNEL_ENCODING_ERROR)
|| Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0);
assert(!(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)
== (CHANNEL_EOF|CHANNEL_BLOCKED)));
UpdateInterest(chanPtr);
if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR)
&& (!copied || !GotFlag(statePtr, CHANNEL_NONBLOCKING))) {
Tcl_SetErrno(EILSEQ);
copied = -1;
}
TclChannelRelease((Tcl_Channel)chanPtr);
return copied;
}
| > > > > > > > | 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 |
assert(!GotFlag(statePtr, CHANNEL_EOF)
|| GotFlag(statePtr, CHANNEL_STICKY_EOF)
|| GotFlag(statePtr, CHANNEL_ENCODING_ERROR)
|| Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0);
assert(!(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)
== (CHANNEL_EOF|CHANNEL_BLOCKED)));
UpdateInterest(chanPtr);
/* This must comes after UpdateInterest(), which may set errno */
if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR)
&& (!copied || !GotFlag(statePtr, CHANNEL_NONBLOCKING))) {
/* Channel either is blocking or is nonblocking with no data
* succesfully red before the error. Return an error so that callers
* like [read] can also return an error.
*/
ResetFlag(statePtr, CHANNEL_EOF|CHANNEL_ENCODING_ERROR);
Tcl_SetErrno(EILSEQ);
copied = -1;
}
TclChannelRelease((Tcl_Channel)chanPtr);
return copied;
}
|
| ︙ | ︙ | |||
6225 6226 6227 6228 6229 6230 6231 |
int charsToRead, /* Maximum number of characters to store, or
* TCL_INDEX_NONE to get all available characters.
* Characters are obtained from the first
* buffer in the queue -- even if this number
* is larger than the number of characters
* available in the first buffer, only the
* characters from the first buffer are
| | | < | 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 |
int charsToRead, /* Maximum number of characters to store, or
* TCL_INDEX_NONE to get all available characters.
* Characters are obtained from the first
* buffer in the queue -- even if this number
* is larger than the number of characters
* available in the first buffer, only the
* characters from the first buffer are
* returned. The exception is when there is
* not any complete character in the first
* buffer. In that case, a recursive call
* effectively obtains chars from the
* second buffer. */
int *factorPtr) /* On input, contains a guess of how many
* bytes need to be allocated to hold the
* result of converting N source bytes to
* UTF-8. On output, contains another guess
* based on the data seen so far. */
{
Tcl_Encoding encoding = statePtr->encoding;
Tcl_EncodingState savedState = statePtr->inputEncodingState;
ChannelBuffer *bufPtr = statePtr->inQueueHead;
int savedIEFlags = statePtr->inputEncodingFlags;
int savedFlags = statePtr->flags;
char *dst, *src = RemovePoint(bufPtr);
Tcl_Size numBytes;
int srcLen = BytesLeft(bufPtr);
|
| ︙ | ︙ | |||
6267 6268 6269 6270 6271 6272 6273 |
int factor = *factorPtr;
int dstLimit = TCL_UTF_MAX - 1 + toRead * factor / UTF_EXPANSION_FACTOR;
(void) Tcl_GetStringFromObj(objPtr, &numBytes);
Tcl_AppendToObj(objPtr, NULL, dstLimit);
if (toRead == srcLen) {
| | | 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 |
int factor = *factorPtr;
int dstLimit = TCL_UTF_MAX - 1 + toRead * factor / UTF_EXPANSION_FACTOR;
(void) Tcl_GetStringFromObj(objPtr, &numBytes);
Tcl_AppendToObj(objPtr, NULL, dstLimit);
if (toRead == srcLen) {
Tcl_Size size;
dst = TclGetStringStorage(objPtr, &size) + numBytes;
dstLimit = (size - numBytes) > INT_MAX ? INT_MAX : (size - numBytes);
} else {
dst = TclGetString(objPtr) + numBytes;
}
|
| ︙ | ︙ | |||
6320 6321 6322 6323 6324 6325 6326 | assert(bufPtr->nextPtr == NULL || BytesLeft(bufPtr->nextPtr) == 0 || (statePtr->inputEncodingFlags & TCL_ENCODING_END) == 0); code = Tcl_ExternalToUtf(NULL, encoding, src, srcLen, flags, &statePtr->inputEncodingState, dst, dstLimit, &srcRead, &dstDecoded, &numChars); | | > > > > > | 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 |
assert(bufPtr->nextPtr == NULL || BytesLeft(bufPtr->nextPtr) == 0
|| (statePtr->inputEncodingFlags & TCL_ENCODING_END) == 0);
code = Tcl_ExternalToUtf(NULL, encoding, src, srcLen,
flags, &statePtr->inputEncodingState,
dst, dstLimit, &srcRead, &dstDecoded, &numChars);
if (code == TCL_CONVERT_UNKNOWN || code == TCL_CONVERT_SYNTAX
|| (
code == TCL_CONVERT_MULTIBYTE
&& GotFlag(statePtr, CHANNEL_EOF
))
) {
SetFlag(statePtr, CHANNEL_ENCODING_ERROR);
code = TCL_OK;
}
/*
* Perform the translation transformation in place. Read no more than
* the dstDecoded bytes the encoding transformation actually produced.
|
| ︙ | ︙ | |||
6563 6564 6565 6566 6567 6568 6569 | * * Note that the BUFFER_PADDING (See AllocChannelBuffer) is used * to prevent exactly this situation. I.e. it should never happen. * Therefore it is ok to panic should it happen despite the * precautions. */ | | | 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 |
*
* Note that the BUFFER_PADDING (See AllocChannelBuffer) is used
* to prevent exactly this situation. I.e. it should never happen.
* Therefore it is ok to panic should it happen despite the
* precautions.
*/
if (nextPtr->nextRemoved < srcLen) {
Tcl_Panic("Buffer Underflow, BUFFER_PADDING not enough");
}
nextPtr->nextRemoved -= srcLen;
memcpy(RemovePoint(nextPtr), src, srcLen);
RecycleBuffer(statePtr, bufPtr, 0);
statePtr->inQueueHead = nextPtr;
|
| ︙ | ︙ | |||
7071 7072 7073 7074 7075 7076 7077 |
if (bufPtr == NULL) {
bufPtr = AllocChannelBuffer(statePtr->bufSize);
}
bufPtr->nextPtr = NULL;
toRead = SpaceLeft(bufPtr);
| | | 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 |
if (bufPtr == NULL) {
bufPtr = AllocChannelBuffer(statePtr->bufSize);
}
bufPtr->nextPtr = NULL;
toRead = SpaceLeft(bufPtr);
assert((Tcl_Size)toRead == statePtr->bufSize);
if (statePtr->inQueueTail == NULL) {
statePtr->inQueueHead = bufPtr;
} else {
statePtr->inQueueTail->nextPtr = bufPtr;
}
statePtr->inQueueTail = bufPtr;
|
| ︙ | ︙ | |||
7408 7409 7410 7411 7412 7413 7414 |
Tcl_SetErrno(EINVAL);
return TCL_ERROR;
}
/*
* Seek first to force a total flush of all pending buffers and ditch any
| | | 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 |
Tcl_SetErrno(EINVAL);
return TCL_ERROR;
}
/*
* Seek first to force a total flush of all pending buffers and ditch any
* preread input data.
*/
WillWrite(chanPtr);
if (WillRead(chanPtr) == -1) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
7468 7469 7470 7471 7472 7473 7474 |
if (statePtr->unreportedError != 0) {
Tcl_SetErrno(statePtr->unreportedError);
statePtr->unreportedError = 0;
/*
* TIP #219, Tcl Channel Reflection API.
| | | 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 |
if (statePtr->unreportedError != 0) {
Tcl_SetErrno(statePtr->unreportedError);
statePtr->unreportedError = 0;
/*
* TIP #219, Tcl Channel Reflection API.
* Move a deferred error message back into the channel bypass.
*/
if (statePtr->chanMsg != NULL) {
TclDecrRefCount(statePtr->chanMsg);
}
statePtr->chanMsg = statePtr->unreportedMsg;
statePtr->unreportedMsg = NULL;
|
| ︙ | ︙ | |||
7606 7607 7608 7609 7610 7611 7612 |
for (bytesBuffered = 0, bufPtr = statePtr->inQueueHead; bufPtr != NULL;
bufPtr = bufPtr->nextPtr) {
bytesBuffered += BytesLeft(bufPtr);
}
/*
| | | 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 |
for (bytesBuffered = 0, bufPtr = statePtr->inQueueHead; bufPtr != NULL;
bufPtr = bufPtr->nextPtr) {
bytesBuffered += BytesLeft(bufPtr);
}
/*
* Remember the bytes in the topmost pushback area.
*/
for (bufPtr = statePtr->topChanPtr->inQueueHead; bufPtr != NULL;
bufPtr = bufPtr->nextPtr) {
bytesBuffered += BytesLeft(bufPtr);
}
|
| ︙ | ︙ | |||
7722 7723 7724 7725 7726 7727 7728 |
{
ChannelState *statePtr; /* State of real channel structure. */
/*
* Clip the buffer size to force it into the [1,1M] range
*/
| | | 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 |
{
ChannelState *statePtr; /* State of real channel structure. */
/*
* Clip the buffer size to force it into the [1,1M] range
*/
if (sz < 1) {
sz = 1;
} else if (sz > MAX_CHANNEL_BUFFER_SIZE) {
sz = MAX_CHANNEL_BUFFER_SIZE;
}
statePtr = ((Channel *) chan)->state;
|
| ︙ | ︙ | |||
7796 7797 7798 7799 7800 7801 7802 | * * Results: * TCL_ERROR. * * Side effects: * An error message is generated in interp's result object to indicate | | | 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 | * * Results: * TCL_ERROR. * * Side effects: * An error message is generated in interp's result object to indicate * that a command was invoked with a bad option. The message has the * form: * bad option "blah": should be one of * <...generic options...>+<...specific options...> * "blah" is the optionName argument and "<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. |
| ︙ | ︙ | |||
7825 7826 7827 7828 7829 7830 7831 |
"blocking buffering buffersize encoding eofchar profile translation";
const char **argv;
Tcl_Size argc, i;
Tcl_DString ds;
Tcl_Obj *errObj;
Tcl_DStringInit(&ds);
| | | | 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 |
"blocking buffering buffersize encoding eofchar profile translation";
const char **argv;
Tcl_Size argc, i;
Tcl_DString ds;
Tcl_Obj *errObj;
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, genericopt, -1);
if (optionList && (*optionList)) {
TclDStringAppendLiteral(&ds, " ");
Tcl_DStringAppend(&ds, optionList, -1);
}
if (Tcl_SplitList(interp, Tcl_DStringValue(&ds),
&argc, &argv) != TCL_OK) {
Tcl_Panic("malformed option list in channel driver");
}
Tcl_ResetResult(interp);
errObj = Tcl_ObjPrintf("bad option \"%s\": should be one of ",
|
| ︙ | ︙ | |||
7878 7879 7880 7881 7882 7883 7884 |
Tcl_GetChannelOption(
Tcl_Interp *interp, /* For error reporting - can be NULL. */
Tcl_Channel chan, /* Channel on which to get option. */
const char *optionName, /* Option to get. */
Tcl_DString *dsPtr) /* Where to store value(s). */
{
size_t len; /* Length of optionName string. */
| | | 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 |
Tcl_GetChannelOption(
Tcl_Interp *interp, /* For error reporting - can be NULL. */
Tcl_Channel chan, /* Channel on which to get option. */
const char *optionName, /* Option to get. */
Tcl_DString *dsPtr) /* Where to store value(s). */
{
size_t len; /* Length of optionName string. */
char optionVal[128]; /* Buffer for snprintf. */
Channel *chanPtr = (Channel *) chan;
ChannelState *statePtr = chanPtr->state;
/* State info for channel */
int flags;
/*
* Disallow options on dead channels -- channels that have been closed but
|
| ︙ | ︙ | |||
7963 7964 7965 7966 7967 7968 7969 |
return TCL_OK;
}
}
if (len == 0 || HaveOpt(2, "-encoding")) {
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-encoding");
}
| < < < | | < | | | 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 |
return TCL_OK;
}
}
if (len == 0 || HaveOpt(2, "-encoding")) {
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-encoding");
}
Tcl_DStringAppendElement(dsPtr,
Tcl_GetEncodingName(statePtr->encoding));
if (len > 0) {
return TCL_OK;
}
}
if (len == 0 || HaveOpt(2, "-eofchar")) {
char buf[4] = "";
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-eofchar");
}
if ((flags & TCL_READABLE) && (statePtr->inEofChar != 0)) {
snprintf(buf, sizeof(buf), "%c", statePtr->inEofChar);
}
if (len > 0) {
Tcl_DStringAppend(dsPtr, buf, -1);
return TCL_OK;
}
Tcl_DStringAppendElement(dsPtr, buf);
}
if (len == 0 || HaveOpt(1, "-profile")) {
int profile;
const char *profileName;
|
| ︙ | ︙ | |||
8110 8111 8112 8113 8114 8115 8116 |
* If the channel is in the middle of a background copy, fail.
*/
if (statePtr->csPtrR || statePtr->csPtrW) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unable to set channel options: background copy in"
| | | 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 |
* If the channel is in the middle of a background copy, fail.
*/
if (statePtr->csPtrR || statePtr->csPtrW) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unable to set channel options: background copy in"
" progress", -1));
}
return TCL_ERROR;
}
/*
* Disallow options on dead channels -- channels that have been closed but
* not yet been deallocated. Such channels can be found if the exit
|
| ︙ | ︙ | |||
8161 8162 8163 8164 8165 8166 8167 |
} else if ((newValue[0] == 'n') &&
(strncmp(newValue, "none", len) == 0)) {
ResetFlag(statePtr, CHANNEL_LINEBUFFERED);
SetFlag(statePtr, CHANNEL_UNBUFFERED);
} else if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -buffering: must be one of"
| | | 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 |
} else if ((newValue[0] == 'n') &&
(strncmp(newValue, "none", len) == 0)) {
ResetFlag(statePtr, CHANNEL_LINEBUFFERED);
SetFlag(statePtr, CHANNEL_UNBUFFERED);
} else if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -buffering: must be one of"
" full, line, or none", -1));
return TCL_ERROR;
}
return TCL_OK;
} else if (HaveOpt(7, "-buffersize")) {
Tcl_WideInt newBufferSize;
Tcl_Obj obj;
int code;
|
| ︙ | ︙ | |||
8188 8189 8190 8191 8192 8193 8194 |
Tcl_SetChannelBufferSize(chan, newBufferSize);
return TCL_OK;
} else if (HaveOpt(2, "-encoding")) {
Tcl_Encoding encoding;
int profile;
if ((newValue[0] == '\0') || (strcmp(newValue, "binary") == 0)) {
| | > > > > > > | | 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 |
Tcl_SetChannelBufferSize(chan, newBufferSize);
return TCL_OK;
} else if (HaveOpt(2, "-encoding")) {
Tcl_Encoding encoding;
int profile;
if ((newValue[0] == '\0') || (strcmp(newValue, "binary") == 0)) {
encoding = Tcl_GetEncoding(NULL, "iso8859-1");
CHANNEL_PROFILE_SET(statePtr->inputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->inputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
CHANNEL_PROFILE_SET(statePtr->outputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->outputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
} else {
encoding = Tcl_GetEncoding(interp, newValue);
if (encoding == NULL) {
return TCL_ERROR;
}
}
/*
* When the channel has an escape sequence driven encoding such as
* iso2022, the terminated escape sequence must write to the buffer.
*/
if ((statePtr->encoding != GetBinaryEncoding())
&& !(statePtr->outputEncodingFlags & TCL_ENCODING_START)
&& (CheckChannelErrors(statePtr, TCL_WRITABLE) == 0)) {
statePtr->outputEncodingFlags |= TCL_ENCODING_END;
WriteChars(chanPtr, "", 0);
}
Tcl_FreeEncoding(statePtr->encoding);
statePtr->encoding = encoding;
|
| ︙ | ︙ | |||
8232 8233 8234 8235 8236 8237 8238 |
if (GotFlag(statePtr, TCL_READABLE)) {
statePtr->inEofChar = newValue[0];
}
} else {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -eofchar: must be non-NUL ASCII"
| | | 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 |
if (GotFlag(statePtr, TCL_READABLE)) {
statePtr->inEofChar = newValue[0];
}
} else {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -eofchar: must be non-NUL ASCII"
" character", -1));
}
Tcl_Free((void *)argv);
return TCL_ERROR;
}
if (argv != NULL) {
Tcl_Free((void *)argv);
}
|
| ︙ | ︙ | |||
8279 8280 8281 8282 8283 8284 8285 |
} else if (argc == 2) {
readMode = GotFlag(statePtr, TCL_READABLE) ? argv[0] : NULL;
writeMode = GotFlag(statePtr, TCL_WRITABLE) ? argv[1] : NULL;
} else {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -translation: must be a one or two"
| | | > > > > > > | | 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 |
} else if (argc == 2) {
readMode = GotFlag(statePtr, TCL_READABLE) ? argv[0] : NULL;
writeMode = GotFlag(statePtr, TCL_WRITABLE) ? argv[1] : NULL;
} else {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -translation: must be a one or two"
" element list", -1));
}
Tcl_Free((void *)argv);
return TCL_ERROR;
}
if (readMode) {
TclEolTranslation translation;
if (*readMode == '\0') {
translation = statePtr->inputTranslation;
} else if (strcmp(readMode, "auto") == 0) {
translation = TCL_TRANSLATE_AUTO;
} else if (strcmp(readMode, "binary") == 0) {
translation = TCL_TRANSLATE_LF;
statePtr->inEofChar = 0;
Tcl_FreeEncoding(statePtr->encoding);
statePtr->encoding = Tcl_GetEncoding(NULL, "iso8859-1");
CHANNEL_PROFILE_SET(statePtr->inputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->inputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
CHANNEL_PROFILE_SET(statePtr->outputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->outputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
} else if (strcmp(readMode, "lf") == 0) {
translation = TCL_TRANSLATE_LF;
} else if (strcmp(readMode, "cr") == 0) {
translation = TCL_TRANSLATE_CR;
} else if (strcmp(readMode, "crlf") == 0) {
translation = TCL_TRANSLATE_CRLF;
} else if (strcmp(readMode, "platform") == 0) {
translation = TCL_PLATFORM_TRANSLATION;
} else {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -translation: must be one of "
"auto, binary, cr, lf, crlf, or platform", -1));
}
Tcl_Free((void *)argv);
return TCL_ERROR;
}
/*
* Reset the EOL flags since we need to look at any buffered data
|
| ︙ | ︙ | |||
8345 8346 8347 8348 8349 8350 8351 |
statePtr->outputTranslation = TCL_TRANSLATE_CRLF;
} else {
statePtr->outputTranslation = TCL_PLATFORM_TRANSLATION;
}
} else if (strcmp(writeMode, "binary") == 0) {
statePtr->outputTranslation = TCL_TRANSLATE_LF;
Tcl_FreeEncoding(statePtr->encoding);
| | > > > > > > | | 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 |
statePtr->outputTranslation = TCL_TRANSLATE_CRLF;
} else {
statePtr->outputTranslation = TCL_PLATFORM_TRANSLATION;
}
} else if (strcmp(writeMode, "binary") == 0) {
statePtr->outputTranslation = TCL_TRANSLATE_LF;
Tcl_FreeEncoding(statePtr->encoding);
statePtr->encoding = Tcl_GetEncoding(NULL, "iso8859-1");
CHANNEL_PROFILE_SET(statePtr->inputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->inputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
CHANNEL_PROFILE_SET(statePtr->outputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->outputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
} else if (strcmp(writeMode, "lf") == 0) {
statePtr->outputTranslation = TCL_TRANSLATE_LF;
} else if (strcmp(writeMode, "cr") == 0) {
statePtr->outputTranslation = TCL_TRANSLATE_CR;
} else if (strcmp(writeMode, "crlf") == 0) {
statePtr->outputTranslation = TCL_TRANSLATE_CRLF;
} else if (strcmp(writeMode, "platform") == 0) {
statePtr->outputTranslation = TCL_PLATFORM_TRANSLATION;
} else {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -translation: must be one of "
"auto, binary, cr, lf, crlf, or platform", -1));
}
Tcl_Free((void *)argv);
return TCL_ERROR;
}
}
Tcl_Free((void *)argv);
return TCL_OK;
|
| ︙ | ︙ | |||
9361 9362 9363 9364 9365 9366 9367 |
/*
* Make sure the output side is unbuffered.
*/
ResetFlag(outStatePtr, CHANNEL_LINEBUFFERED);
SetFlag(outStatePtr, CHANNEL_UNBUFFERED);
| < < < < < | < < < < < < < < < < < | 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 |
/*
* Make sure the output side is unbuffered.
*/
ResetFlag(outStatePtr, CHANNEL_LINEBUFFERED);
SetFlag(outStatePtr, CHANNEL_UNBUFFERED);
moveBytes = Lossless(inStatePtr, outStatePtr, toRead);
/*
* Allocate a new CopyState to maintain info about the current copy in
* progress. This structure will be deallocated when the copy is
* completed.
*/
|
| ︙ | ︙ | |||
9682 9683 9684 9685 9686 9687 9688 |
Tcl_Interp *interp;
Tcl_Obj *cmdPtr, *errObj = NULL, *bufObj = NULL, *msg = NULL;
Tcl_Channel inChan, outChan;
ChannelState *inStatePtr, *outStatePtr;
int result = TCL_OK;
Tcl_Size sizeb;
Tcl_WideInt total;
| | | < | < < < < | | 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 |
Tcl_Interp *interp;
Tcl_Obj *cmdPtr, *errObj = NULL, *bufObj = NULL, *msg = NULL;
Tcl_Channel inChan, outChan;
ChannelState *inStatePtr, *outStatePtr;
int result = TCL_OK;
Tcl_Size sizeb;
Tcl_WideInt total;
Tcl_WideInt size;
const char *buffer;
int moveBytes;
int underflow; /* Input underflow */
inChan = (Tcl_Channel) csPtr->readPtr;
outChan = (Tcl_Channel) csPtr->writePtr;
inStatePtr = csPtr->readPtr->state;
outStatePtr = csPtr->writePtr->state;
interp = csPtr->interp;
cmdPtr = csPtr->cmdPtr;
/*
* Copy the data the slow way, using the translation mechanism.
*
* Note: We have make sure that we use the topmost channel in a stack for
* the copying. The caller uses Tcl_GetChannel to access it, and thus gets
* the bottom of the stack.
*/
moveBytes = Lossless(inStatePtr, outStatePtr, csPtr->toRead);
if (!moveBytes) {
TclNewObj(bufObj);
Tcl_IncrRefCount(bufObj);
}
while (csPtr->toRead != (Tcl_WideInt) 0) {
/*
* Check for unreported background errors.
|
| ︙ | ︙ | |||
9750 9751 9752 9753 9754 9755 9756 |
* underflow instead to prime the readable fileevent.
*/
size = 0;
underflow = 1;
} else {
/*
| | | > | | | 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 |
* underflow instead to prime the readable fileevent.
*/
size = 0;
underflow = 1;
} else {
/*
* Read up to bufSize characters.
*/
if ((csPtr->toRead == (Tcl_WideInt) -1)
|| (csPtr->toRead > (Tcl_WideInt) csPtr->bufSize)) {
sizeb = csPtr->bufSize;
} else {
sizeb = csPtr->toRead;
}
if (moveBytes) {
size = DoRead(inStatePtr->topChanPtr, csPtr->buffer, sizeb,
!GotFlag(inStatePtr, CHANNEL_NONBLOCKING));
} else {
size = DoReadChars(inStatePtr->topChanPtr, bufObj, sizeb,
!GotFlag(inStatePtr, CHANNEL_NONBLOCKING)
,0 /* No append */);
}
underflow = (size >= 0) && (size < sizeb); /* Input underflow */
}
if (size < 0) {
readError:
if (interp) {
TclNewObj(errObj);
Tcl_AppendStringsToObj(errObj, "error reading \"",
|
| ︙ | ︙ | |||
9826 9827 9828 9829 9830 9831 9832 | } } /* * Now write the buffer out. */ | | | < < < < < | | | | | | 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 |
}
}
/*
* Now write the buffer out.
*/
if (moveBytes) {
buffer = csPtr->buffer;
sizeb = WriteBytes(outStatePtr->topChanPtr, buffer, size);
} else {
buffer = Tcl_GetStringFromObj(bufObj, &sizeb);
sizeb = WriteChars(outStatePtr->topChanPtr, buffer, sizeb);
}
/*
* [Bug 2895565]. At this point 'size' still contains the number of
* characters which have been read. We keep this to later to
* update the totals and toRead information, see marker (UP) below. We
* must not overwrite it with 'sizeb', which is the number of written
* characters, and both EOL translation and encoding
* conversion may have changed this number unpredictably in relation
* to 'size' (It can be smaller or larger, in the latter case able to
* drive toRead below -1, causing infinite looping). Completely
* unsuitable for updating totals and toRead.
*/
if (sizeb < 0) {
writeError:
if (interp) {
TclNewObj(errObj);
Tcl_AppendStringsToObj(errObj, "error writing \"",
Tcl_GetChannelName(outChan), "\": ", NULL);
if (msg != NULL) {
Tcl_AppendObjToObj(errObj, msg);
} else {
Tcl_AppendStringsToObj(errObj, Tcl_PosixError(interp),
NULL);
}
}
if (msg != NULL) {
Tcl_DecrRefCount(msg);
}
break;
}
/*
* Update the current character count. Do it now so the count is valid
* before a return or break takes us out of the loop. The invariant at
* the top of the loop should be that csPtr->toRead holds the number
* of characters left to copy.
*/
if (csPtr->toRead != -1) {
csPtr->toRead -= size;
}
csPtr->total += size;
|
| ︙ | ︙ | |||
9941 9942 9943 9944 9945 9946 9947 |
if (bufObj != NULL) {
TclDecrRefCount(bufObj);
bufObj = NULL;
}
/*
| | | | 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 |
if (bufObj != NULL) {
TclDecrRefCount(bufObj);
bufObj = NULL;
}
/*
* Make the callback or return the number of characters transferred. The
* local total is used because StopCopy frees csPtr.
*/
total = csPtr->total;
if (cmdPtr && interp) {
int code;
/*
|
| ︙ | ︙ | |||
10083 10084 10085 10086 10087 10088 10089 | /* * Don't read more data if we have what we need. */ while (!bufPtr || /* We got no buffer! OR */ (!IsBufferFull(bufPtr) && /* Our buffer has room AND */ | | | 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 |
/*
* Don't read more data if we have what we need.
*/
while (!bufPtr || /* We got no buffer! OR */
(!IsBufferFull(bufPtr) && /* Our buffer has room AND */
((Tcl_Size) BytesLeft(bufPtr) < bytesToRead))) {
/* Not enough bytes in it yet
* to fill the dst */
int code;
moreData:
code = GetInput(chanPtr);
bufPtr = statePtr->inQueueHead;
|
| ︙ | ︙ | |||
10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 |
static void
CopyEventProc(
void *clientData,
int mask)
{
(void) CopyData((CopyState *)clientData, mask);
}
/*
*----------------------------------------------------------------------
*
* StopCopy --
*
* This routine halts a copy that is in progress.
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 |
static void
CopyEventProc(
void *clientData,
int mask)
{
(void) CopyData((CopyState *)clientData, mask);
}
/*
*----------------------------------------------------------------------
*
* Lossless --
*
* Determines whether copying characters between two channel states would
* be lossless, i.e. whether one byte corresponds to one character, every
* character appears in the Unicode character set, there are no
* translations to be performed, and no inline signals to respond to.
*
* Result:
* True if copying would be lossless.
*
*----------------------------------------------------------------------
*/
int
Lossless(
ChannelState *inStatePtr,
ChannelState *outStatePtr,
long long toRead)
{
return inStatePtr->inEofChar == '\0' /* No eofChar to stop input */
&& inStatePtr->inputTranslation == TCL_TRANSLATE_LF
&& outStatePtr->outputTranslation == TCL_TRANSLATE_LF
&& (
(
inStatePtr->encoding == GetBinaryEncoding()
&&
outStatePtr->encoding == GetBinaryEncoding()
)
||
(
toRead == -1
&& inStatePtr->encoding == outStatePtr->encoding
&& CHANNEL_PROFILE_GET(inStatePtr->inputEncodingFlags) == TCL_ENCODING_PROFILE_TCL8
&& CHANNEL_PROFILE_GET(outStatePtr->inputEncodingFlags) == TCL_ENCODING_PROFILE_TCL8
)
);
}
/*
*----------------------------------------------------------------------
*
* StopCopy --
*
* This routine halts a copy that is in progress.
|
| ︙ | ︙ | |||
10518 10519 10520 10521 10522 10523 10524 |
hTblPtr = GetChannelTable(interp);
TclNewObj(resultPtr);
if ((pattern != NULL) && TclMatchIsTrivial(pattern)
&& !((pattern[0] == 's') && (pattern[1] == 't')
&& (pattern[2] == 'd'))) {
if ((Tcl_FindHashEntry(hTblPtr, pattern) != NULL)
&& (Tcl_ListObjAppendElement(interp, resultPtr,
| | | 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 |
hTblPtr = GetChannelTable(interp);
TclNewObj(resultPtr);
if ((pattern != NULL) && TclMatchIsTrivial(pattern)
&& !((pattern[0] == 's') && (pattern[1] == 't')
&& (pattern[2] == 'd'))) {
if ((Tcl_FindHashEntry(hTblPtr, pattern) != NULL)
&& (Tcl_ListObjAppendElement(interp, resultPtr,
Tcl_NewStringObj(pattern, -1)) != TCL_OK)) {
goto error;
}
goto done;
}
for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); hPtr != NULL;
hPtr = Tcl_NextHashEntry(&hSearch)) {
|
| ︙ | ︙ | |||
10545 10546 10547 10548 10549 10550 10551 | */ name = statePtr->channelName; } if (((pattern == NULL) || Tcl_StringMatch(name, pattern)) && (Tcl_ListObjAppendElement(interp, resultPtr, | | | 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 |
*/
name = statePtr->channelName;
}
if (((pattern == NULL) || Tcl_StringMatch(name, pattern)) &&
(Tcl_ListObjAppendElement(interp, resultPtr,
Tcl_NewStringObj(name, -1)) != TCL_OK)) {
error:
TclDecrRefCount(resultPtr);
return TCL_ERROR;
}
}
done:
|
| ︙ | ︙ | |||
11130 11131 11132 11133 11134 11135 11136 |
/*
* Process the caught message.
*
* Syntax = (option value)... ?message?
*
* Bad message syntax causes a panic, because the other side uses
| | | 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 |
/*
* Process the caught message.
*
* Syntax = (option value)... ?message?
*
* Bad message syntax causes a panic, because the other side uses
* Tcl_GetReturnOptions and list construction functions to marshal the
* information. Hence an error means that we've got serious breakage.
*/
res = TclListObjGetElementsM(NULL, msg, &lc, &lv);
if (res != TCL_OK) {
Tcl_Panic("Tcl_SetChannelError: bad syntax of message");
}
|
| ︙ | ︙ | |||
11199 11200 11201 11202 11203 11204 11205 |
if (newcode >= 0) {
lcn += 2;
}
lvn = (Tcl_Obj **)Tcl_Alloc(lcn * sizeof(Tcl_Obj *));
/*
| | | | 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 |
if (newcode >= 0) {
lcn += 2;
}
lvn = (Tcl_Obj **)Tcl_Alloc(lcn * sizeof(Tcl_Obj *));
/*
* New level/code information is spliced into the first occurrence of
* -level, -code, further occurrences are ignored. The options cannot be
* not present, we would not come here. Options which are ok are simply
* copied over.
*/
lignore = cignore = 0;
for (i=0, j=0; i<numOptions; i+=2) {
if (0 == strcmp(TclGetString(lv[i]), "-level")) {
|
| ︙ | ︙ |
Changes to generic/tclIO.h.
| ︙ | ︙ | |||
32 33 34 35 36 37 38 |
/*
* struct ChannelBuffer:
*
* Buffers data being sent to or from a channel.
*/
typedef struct ChannelBuffer {
| | | | | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
/*
* struct ChannelBuffer:
*
* Buffers data being sent to or from a channel.
*/
typedef struct ChannelBuffer {
Tcl_Size refCount; /* Current uses count */
Tcl_Size nextAdded; /* The next position into which a character
* will be put in the buffer. */
Tcl_Size nextRemoved; /* Position of next byte to be removed from
* the buffer. */
Tcl_Size bufLength; /* How big is the buffer? */
struct ChannelBuffer *nextPtr;
/* Next buffer in chain. */
char buf[TCLFLEXARRAY]; /* Placeholder for real buffer. The real
* buffer occupies this space + bufSize-1
* bytes. This must be the last field in the
* structure. */
} ChannelBuffer;
#define CHANNELBUFFER_HEADER_SIZE offsetof(ChannelBuffer, buf)
/*
|
| ︙ | ︙ | |||
109 110 111 112 113 114 115 |
* Intermediate buffers to hold pre-read data for consumption by a newly
* stacked transformation. See 'Tcl_StackChannel'.
*/
ChannelBuffer *inQueueHead; /* Points at first buffer in input queue. */
ChannelBuffer *inQueueTail; /* Points at last buffer in input queue. */
| | | | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
* Intermediate buffers to hold pre-read data for consumption by a newly
* stacked transformation. See 'Tcl_StackChannel'.
*/
ChannelBuffer *inQueueHead; /* Points at first buffer in input queue. */
ChannelBuffer *inQueueTail; /* Points at last buffer in input queue. */
Tcl_Size refCount;
} Channel;
/*
* struct ChannelState:
*
* One of these structures is allocated for each open channel. It contains
* data specific to the channel but which belongs to the generic part of the
* Tcl channel mechanism, and it points at an instance specific (and type
* specific) instance data, and at a channel type structure.
*/
typedef struct ChannelState {
char *channelName; /* The name of the channel instance in Tcl
* commands. Storage is owned by the generic
* IO code, is dynamically allocated. */
int flags; /* OR'ed combination of the flags defined
* below. */
Tcl_Encoding encoding; /* Encoding to apply when reading or writing
* data on this channel. NULL means no
* encoding is applied to data. */
Tcl_EncodingState inputEncodingState;
/* Current encoding state, used when
* converting input data bytes to UTF-8. */
|
| ︙ | ︙ | |||
161 162 163 164 165 166 167 |
#if TCL_MAJOR_VERSION < 9
int outEofChar; /* If nonzero, append this to the channel when
* it is closed if it is open for writing. For Tcl 8.x only */
#endif
int unreportedError; /* Non-zero if an error report was deferred
* because it happened in the background. The
* value is the POSIX error code. */
| | | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
#if TCL_MAJOR_VERSION < 9
int outEofChar; /* If nonzero, append this to the channel when
* it is closed if it is open for writing. For Tcl 8.x only */
#endif
int unreportedError; /* Non-zero if an error report was deferred
* because it happened in the background. The
* value is the POSIX error code. */
Tcl_Size refCount; /* How many interpreters hold references to
* this IO channel? */
struct CloseCallback *closeCbPtr;
/* Callbacks registered to be called when the
* channel is closed. */
char *outputStage; /* Temporary staging buffer used when
* translating EOL before converting from
* UTF-8 to external form. */
|
| ︙ | ︙ | |||
184 185 186 187 188 189 190 |
struct ChannelHandler *chPtr;/* List of channel handlers registered for
* this channel. */
int interestMask; /* Mask of all events this channel has
* handlers for. */
EventScriptRecord *scriptRecordPtr;
/* Chain of all scripts registered for event
* handlers ("fileevent") on this channel. */
| | | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
struct ChannelHandler *chPtr;/* List of channel handlers registered for
* this channel. */
int interestMask; /* Mask of all events this channel has
* handlers for. */
EventScriptRecord *scriptRecordPtr;
/* Chain of all scripts registered for event
* handlers ("fileevent") on this channel. */
Tcl_Size bufSize; /* What size buffers to allocate? */
Tcl_TimerToken timer; /* Handle to wakeup timer for this channel. */
Channel *timerChanPtr; /* Needed in order to decrement the refCount of
the right channel when the timer is
deleted. */
struct CopyState *csPtrR; /* State of background copy for which channel
* is input, or NULL. */
struct CopyState *csPtrW; /* State of background copy for which channel
|
| ︙ | ︙ | |||
207 208 209 210 211 212 213 |
Tcl_ThreadId managingThread;/* TIP #10: Id of the thread managing this
* stack of channels. */
/*
* TIP #219 ... Info for the I/O system ...
* Error message set by channel drivers, for the propagation of arbitrary
* Tcl errors. This information, if present (chanMsg not NULL), takes
| | | | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
Tcl_ThreadId managingThread;/* TIP #10: Id of the thread managing this
* stack of channels. */
/*
* TIP #219 ... Info for the I/O system ...
* Error message set by channel drivers, for the propagation of arbitrary
* Tcl errors. This information, if present (chanMsg not NULL), takes
* precedence over a Posix error code returned by a channel operation.
*/
Tcl_Obj* chanMsg;
Tcl_Obj* unreportedMsg; /* Non-NULL if an error report was deferred
* because it happened in the background. The
* value is the chanMg, if any. #219's
* companion to 'unreportedError'. */
size_t epoch; /* Used to test validity of stored channelname
* lookup results. */
int maxPerms; /* TIP #220: Max access privileges
* the channel was created with. */
} ChannelState;
/*
* Values for the flags field in Channel. Any OR'ed combination of the
* following flags can be stored in the field. These flags record various
* options and state bits about the channel. In addition to the flags below,
* the channel can also have TCL_READABLE (1<<1) and TCL_WRITABLE (1<<2) set.
*/
#define CHANNEL_NONBLOCKING (1<<3) /* Channel is currently in nonblocking
* mode. */
|
| ︙ | ︙ |
Changes to generic/tclIOCmd.c.
| ︙ | ︙ | |||
103 104 105 106 107 108 109 |
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Channel chan; /* The channel to puts on. */
Tcl_Obj *string; /* String to write. */
Tcl_Obj *chanObjPtr = NULL; /* channel object. */
int newline; /* Add a newline at end? */
| | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Channel chan; /* The channel to puts on. */
Tcl_Obj *string; /* String to write. */
Tcl_Obj *chanObjPtr = NULL; /* channel object. */
int newline; /* Add a newline at end? */
Tcl_Size result; /* Result of puts operation. */
int mode; /* Mode in which channel is opened. */
switch (objc) {
case 2: /* [puts $x] */
string = objv[1];
newline = 1;
break;
|
| ︙ | ︙ | |||
277 278 279 280 281 282 283 |
Tcl_GetsObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Channel chan; /* The channel to read from. */
| | | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
Tcl_GetsObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Channel chan; /* The channel to read from. */
Tcl_Size lineLen; /* Length of line just read. */
int mode; /* Mode in which channel is opened. */
Tcl_Obj *linePtr, *chanObjPtr;
int code = TCL_OK;
if ((objc != 2) && (objc != 3)) {
Tcl_WrongNumArgs(interp, 1, objv, "channelId ?varName?");
return TCL_ERROR;
|
| ︙ | ︙ | |||
365 366 367 368 369 370 371 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Channel chan; /* The channel to read from. */
int newline, i; /* Discard newline at end? */
Tcl_WideInt toRead; /* How many bytes to read? */
| | | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Channel chan; /* The channel to read from. */
int newline, i; /* Discard newline at end? */
Tcl_WideInt toRead; /* How many bytes to read? */
Tcl_Size charactersRead; /* How many characters were read? */
int mode; /* Mode in which channel is opened. */
Tcl_Obj *resultPtr, *chanObjPtr;
if ((objc != 2) && (objc != 3)) {
Interp *iPtr;
argerror:
|
| ︙ | ︙ | |||
426 427 428 429 430 431 432 |
TclGetString(objv[i])));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL);
return TCL_ERROR;
}
}
TclNewObj(resultPtr);
| < > < | < | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
TclGetString(objv[i])));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL);
return TCL_ERROR;
}
}
TclNewObj(resultPtr);
TclChannelPreserve(chan);
charactersRead = Tcl_ReadChars(chan, resultPtr, toRead, 0);
if (charactersRead == TCL_IO_FAILURE) {
Tcl_DecrRefCount(resultPtr);
/*
* TIP #219.
* Capture error messages put by the driver into the bypass area and
* put them into the regular interpreter result. Fall back to the
* regular message if nothing was found in the bypass.
*/
if (!TclChanCaughtErrorBypass(interp, chan)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error reading \"%s\": %s",
TclGetString(chanObjPtr), Tcl_PosixError(interp)));
}
TclChannelRelease(chan);
return TCL_ERROR;
}
/*
* If requested, remove the last newline in the channel if at EOF.
*/
if ((charactersRead > 0) && (newline != 0)) {
const char *result;
Tcl_Size length;
result = Tcl_GetStringFromObj(resultPtr, &length);
if (result[length - 1] == '\n') {
Tcl_SetObjLength(resultPtr, length - 1);
}
}
Tcl_SetObjResult(interp, resultPtr);
TclChannelRelease(chan);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_SeekObjCmd --
|
| ︙ | ︙ | |||
696 697 698 699 700 701 702 | * messages produced by drivers during the closing of a channel, * because the Tcl convention is that such error messages do not have * a terminating newline. */ Tcl_Obj *resultPtr = Tcl_GetObjResult(interp); const char *string; | | | 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
* messages produced by drivers during the closing of a channel,
* because the Tcl convention is that such error messages do not have
* a terminating newline.
*/
Tcl_Obj *resultPtr = Tcl_GetObjResult(interp);
const char *string;
Tcl_Size len;
if (Tcl_IsShared(resultPtr)) {
resultPtr = Tcl_DuplicateObj(resultPtr);
Tcl_SetObjResult(interp, resultPtr);
}
string = Tcl_GetStringFromObj(resultPtr, &len);
if ((len > 0) && (string[len - 1] == '\n')) {
|
| ︙ | ︙ | |||
856 857 858 859 860 861 862 |
{
Tcl_Obj *resultPtr;
const char **argv; /* An array for the string arguments. Stored
* on the _Tcl_ stack. */
const char *string;
Tcl_Channel chan;
int argc, background, i, index, keepNewline, result, skip, ignoreStderr;
| | | 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 |
{
Tcl_Obj *resultPtr;
const char **argv; /* An array for the string arguments. Stored
* on the _Tcl_ stack. */
const char *string;
Tcl_Channel chan;
int argc, background, i, index, keepNewline, result, skip, ignoreStderr;
Tcl_Size length;
static const char *const options[] = {
"-ignorestderr", "-keepnewline", "--", NULL
};
enum execOptionsEnum {
EXEC_IGNORESTDERR, EXEC_KEEPNEWLINE, EXEC_LAST
};
|
| ︙ | ︙ | |||
1005 1006 1007 1008 1009 1010 1011 | * the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * Sets interp's result to boolean true or false depending on whether the | | | 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 |
* the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* Sets interp's result to boolean true or false depending on whether the
* preceding input operation on the channel would have blocked.
*
*---------------------------------------------------------------------------
*/
int
Tcl_FblockedObjCmd(
TCL_UNUSED(void *),
|
| ︙ | ︙ | |||
1079 1080 1081 1082 1083 1084 1085 |
if (objc == 2) {
modeString = "r";
} else {
modeString = TclGetString(objv[2]);
if (objc == 4) {
const char *permString = TclGetString(objv[3]);
int code = TCL_ERROR;
| | | 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
if (objc == 2) {
modeString = "r";
} else {
modeString = TclGetString(objv[2]);
if (objc == 4) {
const char *permString = TclGetString(objv[3]);
int code = TCL_ERROR;
int scanned = TclParseAllWhiteSpace(permString, -1);
/*
* Support legacy octal numbers.
*/
if ((permString[scanned] == '0')
&& (permString[scanned+1] >= '0')
|
| ︙ | ︙ | |||
1117 1118 1119 1120 1121 1122 1123 |
* Open the file or create a process pipeline.
*/
if (!pipeline) {
chan = Tcl_FSOpenFileChannel(interp, objv[1], modeString, prot);
} else {
int mode, seekFlag, binary;
| | | 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 |
* Open the file or create a process pipeline.
*/
if (!pipeline) {
chan = Tcl_FSOpenFileChannel(interp, objv[1], modeString, prot);
} else {
int mode, seekFlag, binary;
Tcl_Size cmdObjc;
const char **cmdArgv;
if (Tcl_SplitList(interp, what+1, &cmdObjc, &cmdArgv) != TCL_OK) {
return TCL_ERROR;
}
mode = TclGetOpenModeEx(interp, modeString, &seekFlag, &binary);
|
| ︙ | ︙ |
Changes to generic/tclIOGT.c.
| ︙ | ︙ | |||
254 255 256 257 258 259 260 |
Tcl_Interp *interp, /* Interpreter for result. */
Tcl_Channel chan, /* Channel to transform. */
Tcl_Obj *cmdObjPtr) /* Script to use for transform. */
{
Channel *chanPtr; /* The actual channel. */
ChannelState *statePtr; /* State info for channel. */
int mode; /* Read/write mode of the channel. */
| | | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
Tcl_Interp *interp, /* Interpreter for result. */
Tcl_Channel chan, /* Channel to transform. */
Tcl_Obj *cmdObjPtr) /* Script to use for transform. */
{
Channel *chanPtr; /* The actual channel. */
ChannelState *statePtr; /* State info for channel. */
int mode; /* Read/write mode of the channel. */
Tcl_Size objc;
TransformChannelData *dataPtr;
Tcl_DString ds;
if (chan == NULL) {
return TCL_ERROR;
}
if (TCL_OK != TclListObjLengthM(interp, cmdObjPtr, &objc)) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("-command value is not a list", -1));
return TCL_ERROR;
}
chanPtr = (Channel *) chan;
statePtr = chanPtr->state;
chanPtr = statePtr->topChanPtr;
chan = (Tcl_Channel) chanPtr;
|
| ︙ | ︙ | |||
393 394 395 396 397 398 399 |
*/
if (preserve == P_PRESERVE) {
state = Tcl_SaveInterpState(eval, res);
}
Tcl_IncrRefCount(command);
| | | | | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
*/
if (preserve == P_PRESERVE) {
state = Tcl_SaveInterpState(eval, res);
}
Tcl_IncrRefCount(command);
Tcl_ListObjAppendElement(NULL, command, Tcl_NewStringObj((char *) op, -1));
/*
* Use a byte-array to prevent the misinterpretation of binary data coming
* through as Utf while at the tcl level.
*/
Tcl_ListObjAppendElement(NULL, command, Tcl_NewByteArrayObj(buf, bufLen));
/*
* Step 2, execute the command at the global level of the interpreter used
* to create the transformation. Destroy the command afterward. If an
* error occurred and the current interpreter is defined and not equal to
* the interpreter for the callback, then copy the error message into
* current interpreter. Don't copy if in preservation mode.
*/
res = Tcl_EvalObjEx(eval, command, TCL_EVAL_GLOBAL);
Tcl_DecrRefCount(command);
command = NULL;
|
| ︙ | ︙ | |||
569 570 571 572 573 574 575 |
dataPtr->timer = NULL;
}
/*
* Now flush data waiting in internal buffers to output and input. The
* input must be done despite the fact that there is no real receiver for
* it anymore. But the scripts might have sideeffects other parts of the
| | | 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 |
dataPtr->timer = NULL;
}
/*
* Now flush data waiting in internal buffers to output and input. The
* input must be done despite the fact that there is no real receiver for
* it anymore. But the scripts might have sideeffects other parts of the
* system rely on (f.e. signalling the close to interested parties).
*/
PreserveData(dataPtr);
if (dataPtr->mode & TCL_WRITABLE) {
ExecuteCallback(dataPtr, interp, A_FLUSH_WRITE, NULL, 0,
TRANSMIT_DOWN, P_PRESERVE);
}
|
| ︙ | ︙ | |||
1011 1012 1013 1014 1015 1016 1017 |
void *instanceData, /* Channel to watch. */
int mask) /* Events of interest. */
{
TransformChannelData *dataPtr = (TransformChannelData *)instanceData;
Tcl_Channel downChan;
/*
| | | 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 |
void *instanceData, /* Channel to watch. */
int mask) /* Events of interest. */
{
TransformChannelData *dataPtr = (TransformChannelData *)instanceData;
Tcl_Channel downChan;
/*
* The caller expressed interest in events occurring for this channel. We
* are forwarding the call to the underlying channel now.
*/
dataPtr->watchMask = mask;
/*
* No channel handlers any more. We will be notified automatically about
|
| ︙ | ︙ | |||
1118 1119 1120 1121 1122 1123 1124 |
*----------------------------------------------------------------------
*/
static int
TransformNotifyProc(
void *clientData, /* The state of the notified
* transformation. */
| | | | 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 |
*----------------------------------------------------------------------
*/
static int
TransformNotifyProc(
void *clientData, /* The state of the notified
* transformation. */
int mask) /* The mask of occurring events. */
{
TransformChannelData *dataPtr = (TransformChannelData *)clientData;
/*
* An event occurred in the underlying channel. This transformation doesn't
* process such events thus returns the incoming mask unchanged.
*/
if (dataPtr->timer != NULL) {
/*
* Delete an existing timer. It was not fired, yet we are here, so the
* channel below generated such an event and we don't have to. The
|
| ︙ | ︙ | |||
1213 1214 1215 1216 1217 1218 1219 | /* *---------------------------------------------------------------------- * * ResultInit -- * * Initializes the specified buffer structure. The structure will contain | | | 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | /* *---------------------------------------------------------------------- * * ResultInit -- * * Initializes the specified buffer structure. The structure will contain * valid information for an empty buffer. * * Side effects: * See above. * * Result: * None. * |
| ︙ | ︙ |
Changes to generic/tclIORChan.c.
1 2 3 4 5 6 7 8 9 10 11 12 | /* * tclIORChan.c -- * * This file contains the implementation of Tcl's generic channel * reflection code, which allows the implementation of Tcl channels in * Tcl code. * * Parts of this file are based on code contributed by Jean-Claude * Wippler. * * See TIP #219 for the specification of this functionality. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * tclIORChan.c -- * * This file contains the implementation of Tcl's generic channel * reflection code, which allows the implementation of Tcl channels in * Tcl code. * * Parts of this file are based on code contributed by Jean-Claude * Wippler. * * See TIP #219 for the specification of this functionality. * * Copyright © 2004-2005 ActiveState, a division of Sophos * * 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 "tclIO.h" |
| ︙ | ︙ | |||
127 128 129 130 131 132 133 |
/*
* Note regarding the usage of timers.
*
* Most channel implementations need a timer in the C level to ensure that
* data in buffers is flushed out through the generation of fake file
* events.
*
| | | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
/*
* Note regarding the usage of timers.
*
* Most channel implementations need a timer in the C level to ensure that
* data in buffers is flushed out through the generation of fake file
* events.
*
* See 'refchan', 'memchan', etc.
*
* A timer is used here as well in order to ensure at least on pass through
* the event loop when a channel becomes ready. See issues 67a5eabbd3d1 and
* ef28eb1f1516.
*/
} ReflectedChannel;
/*
* Structure of the table mapping from channel handles to reflected
* channels. Each interpreter which has the handler command for one or more
* reflected channels records them in such a table, so that 'chan postevent'
* is able to find them even if the actual channel was moved to a different
* interpreter and/or thread.
*
* The table is reachable via the standard interpreter AssocData, the key is
* defined below.
|
| ︙ | ︙ | |||
262 263 264 265 266 267 268 |
* ForwardParamBase. Where an operation does not need any special types, it
* has no "subtype" and just uses ForwardParamBase, as listed above.)
*/
struct ForwardParamInput {
ForwardParamBase base; /* "Supertype". MUST COME FIRST. */
char *buf; /* O: Where to store the read bytes */
| | | | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
* ForwardParamBase. Where an operation does not need any special types, it
* has no "subtype" and just uses ForwardParamBase, as listed above.)
*/
struct ForwardParamInput {
ForwardParamBase base; /* "Supertype". MUST COME FIRST. */
char *buf; /* O: Where to store the read bytes */
Tcl_Size toRead; /* I: #bytes to read,
* O: #bytes actually read */
};
struct ForwardParamOutput {
ForwardParamBase base; /* "Supertype". MUST COME FIRST. */
const char *buf; /* I: Where the bytes to write come from */
Tcl_Size toWrite; /* I: #bytes to write,
* O: #bytes actually written */
};
struct ForwardParamSeek {
ForwardParamBase base; /* "Supertype". MUST COME FIRST. */
int seekMode; /* I: How to seek */
Tcl_WideInt offset; /* I: Where to seek,
* O: New location */
|
| ︙ | ︙ | |||
509 510 511 512 513 514 515 |
Tcl_Obj *rcId; /* Handle of the new channel */
int mode; /* R/W mode of new channel. Has to match
* abilities of handler commands */
Tcl_Obj *cmdObj; /* Command prefix, list of words */
Tcl_Obj *cmdNameObj; /* Command name */
Tcl_Channel chan; /* Token for the new channel */
Tcl_Obj *modeObj; /* mode in obj form for method call */
| | | 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
Tcl_Obj *rcId; /* Handle of the new channel */
int mode; /* R/W mode of new channel. Has to match
* abilities of handler commands */
Tcl_Obj *cmdObj; /* Command prefix, list of words */
Tcl_Obj *cmdNameObj; /* Command name */
Tcl_Channel chan; /* Token for the new channel */
Tcl_Obj *modeObj; /* mode in obj form for method call */
Tcl_Size listc; /* Result of 'initialize', and of */
Tcl_Obj **listv; /* its sublist in the 2nd element */
int methIndex; /* Encoded method name */
int result; /* Result code for 'initialize' */
Tcl_Obj *resObj; /* Result data for 'initialize' */
int methods; /* Bitmask for supported methods. */
Channel *chanPtr; /* 'chan' resolved to internal struct. */
Tcl_Obj *err; /* Error message */
|
| ︙ | ︙ | |||
545 546 547 548 549 550 551 |
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "mode cmdprefix");
return TCL_ERROR;
}
/*
* First argument is a list of modes. Allowed entries are "read", "write".
| | | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "mode cmdprefix");
return TCL_ERROR;
}
/*
* First argument is a list of modes. Allowed entries are "read", "write".
* Empty list is uncommon, but allowed. Abbreviations are ok.
*/
modeObj = objv[MODE];
if (EncodeEventMask(interp, "mode", objv[MODE], &mode) != TCL_OK) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
883 884 885 886 887 888 889 |
* (2) Is the post event issued from the interpreter holding the handler
* of the reflected channel?
*
* A successful search answers yes to both. Because the map holds only
* handles of reflected channels, and only of such whose handler is
* defined in this interpreter.
*
| | | | 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 |
* (2) Is the post event issued from the interpreter holding the handler
* of the reflected channel?
*
* A successful search answers yes to both. Because the map holds only
* handles of reflected channels, and only of such whose handler is
* defined in this interpreter.
*
* We keep the old checks for both, for paranoia, but abort now instead of
* throwing errors, as failure now means that our internal data structures
* have gone seriously haywire.
*/
chan = (Tcl_Channel)Tcl_GetHashValue(hPtr);
chanTypePtr = Tcl_GetChannelType(chan);
/*
|
| ︙ | ︙ | |||
917 918 919 920 921 922 923 924 925 926 927 928 929 930 |
/*
* Second argument is a list of events. Allowed entries are "read",
* "write". Expect at least one list element. Abbreviations are ok.
*/
if (EncodeEventMask(interp, "event", objv[EVENT], &events) != TCL_OK) {
return TCL_ERROR;
}
/*
* Check that the channel is actually interested in the provided events.
*/
if (events & ~rcPtr->interest) {
| > > > > > | 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 |
/*
* Second argument is a list of events. Allowed entries are "read",
* "write". Expect at least one list element. Abbreviations are ok.
*/
if (EncodeEventMask(interp, "event", objv[EVENT], &events) != TCL_OK) {
return TCL_ERROR;
}
if (events == 0) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("bad event list: is empty", -1));
return TCL_ERROR;
}
/*
* Check that the channel is actually interested in the provided events.
*/
if (events & ~rcPtr->interest) {
|
| ︙ | ︙ | |||
1043 1044 1045 1046 1047 1048 1049 |
}
static void
UnmarshallErrorResult(
Tcl_Interp *interp,
Tcl_Obj *msgObj)
{
| | | | | 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
}
static void
UnmarshallErrorResult(
Tcl_Interp *interp,
Tcl_Obj *msgObj)
{
Tcl_Size lc;
Tcl_Obj **lv;
int explicitResult;
Tcl_Size numOptions;
/*
* Process the caught message.
*
* Syntax = (option value)... ?message?
*
* Bad syntax causes a panic. This is OK because the other side uses
* Tcl_GetReturnOptions and list construction functions to marshal the
* information; if we panic here, something has gone badly wrong already.
*/
if (TclListObjGetElementsM(interp, msgObj, &lc, &lv) != TCL_OK) {
Tcl_Panic("TclChanCaughtErrorBypass: Bad syntax of caught result");
}
if (interp == NULL) {
|
| ︙ | ︙ | |||
1145 1146 1147 1148 1149 1150 1151 | * * ReflectClose -- * * This function is invoked when the channel is closed, to delete the * driver-specific instance data. * * Results: | | | 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 | * * ReflectClose -- * * This function is invoked when the channel is closed, to delete the * driver-specific instance data. * * Results: * A Posix error. * * Side effects: * Releases memory. Arbitrary, as it calls upon a script. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ | |||
1322 1323 1324 1325 1326 1327 1328 |
void *clientData,
char *buf,
int toRead,
int *errorCodePtr)
{
ReflectedChannel *rcPtr = (ReflectedChannel *)clientData;
Tcl_Obj *toReadObj;
| | | 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 |
void *clientData,
char *buf,
int toRead,
int *errorCodePtr)
{
ReflectedChannel *rcPtr = (ReflectedChannel *)clientData;
Tcl_Obj *toReadObj;
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
Tcl_Obj *resObj; /* Result data for 'read' */
/*
* Are we in the correct thread?
*/
|
| ︙ | ︙ | |||
1384 1385 1386 1387 1388 1389 1390 |
}
bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
if (bytev == NULL) {
SetChannelErrorStr(rcPtr->chan, msg_read_nonbyte);
goto invalid;
| | | | 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 |
}
bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
if (bytev == NULL) {
SetChannelErrorStr(rcPtr->chan, msg_read_nonbyte);
goto invalid;
} else if (toRead < bytec) {
SetChannelErrorStr(rcPtr->chan, msg_read_toomuch);
goto invalid;
}
*errorCodePtr = EOK;
if (bytec > 0) {
memcpy(buf, bytev, bytec);
}
stop:
Tcl_DecrRefCount(toReadObj);
Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
Tcl_Release(rcPtr);
|
| ︙ | ︙ | |||
1709 1710 1711 1712 1713 1714 1715 | * * ReflectBlock -- * * This function is invoked to tell the channel which blocking behaviour * is required of it. * * Results: | | | 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 | * * ReflectBlock -- * * This function is invoked to tell the channel which blocking behaviour * is required of it. * * Results: * A Posix error number. * * Side effects: * Allocates memory. Arbitrary, as it calls upon a script. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ | |||
1908 1909 1910 1911 1912 1913 1914 |
* This code is special. It has regular passing of Tcl result, and errors.
* The bypass functions are not required.
*/
ReflectedChannel *rcPtr = (ReflectedChannel *)clientData;
Tcl_Obj *optionObj;
Tcl_Obj *resObj; /* Result data for 'configure' */
| | | 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 |
* This code is special. It has regular passing of Tcl result, and errors.
* The bypass functions are not required.
*/
ReflectedChannel *rcPtr = (ReflectedChannel *)clientData;
Tcl_Obj *optionObj;
Tcl_Obj *resObj; /* Result data for 'configure' */
Tcl_Size listc;
int result = TCL_OK;
Tcl_Obj **listv;
MethodName method;
/*
* Are we in the correct thread?
*/
|
| ︙ | ︙ | |||
2002 2003 2004 2005 2006 2007 2008 | /* * Odd number of elements is wrong. */ Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Expected list with even number of " | | | | 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 |
/*
* Odd number of elements is wrong.
*/
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"Expected list with even number of "
"elements, got %" TCL_SIZE_MODIFIER "u element%s instead", listc,
(listc == 1 ? "" : "s")));
goto error;
} else {
Tcl_Size len;
const char *str = Tcl_GetStringFromObj(resObj, &len);
if (len) {
TclDStringAppendLiteral(dsPtr, " ");
Tcl_DStringAppend(dsPtr, str, len);
}
goto ok;
|
| ︙ | ︙ | |||
2107 2108 2109 2110 2111 2112 2113 | /* *---------------------------------------------------------------------- * * EncodeEventMask -- * * This function takes a list of event items and constructs the | | | | | | < < < < < < | 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 |
/*
*----------------------------------------------------------------------
*
* EncodeEventMask --
*
* This function takes a list of event items and constructs the
* equivalent internal bitmask. The list may be empty but will usually
* contain at least one element. Valid elements are "read", "write", or
* any unique abbreviation of them. Note that the bitmask is not changed
* if problems are encountered.
*
* Results:
* A standard Tcl error code. A bitmask where TCL_READABLE and/or
* TCL_WRITABLE can be set.
*
* Side effects:
* May shimmer 'obj' to a list representation. May place an error message
* into the interp result.
*
*----------------------------------------------------------------------
*/
static int
EncodeEventMask(
Tcl_Interp *interp,
const char *objName,
Tcl_Obj *obj,
int *mask)
{
int events; /* Mask of events to post */
Tcl_Size listc; /* #elements in eventspec list */
Tcl_Obj **listv; /* Elements of eventspec list */
int evIndex; /* Id of event for an element of the eventspec
* list. */
if (TclListObjGetElementsM(interp, obj, &listc, &listv) != TCL_OK) {
return TCL_ERROR;
}
events = 0;
while (listc > 0) {
if (Tcl_GetIndexFromObj(interp, listv[listc-1], eventOptions,
objName, 0, &evIndex) != TCL_OK) {
return TCL_ERROR;
}
switch (evIndex) {
|
| ︙ | ︙ | |||
2282 2283 2284 2285 2286 2287 2288 | * reflected channel. * * Results: * A Tcl_Obj containing the string of the new channel handle. The * refcount of the returned object is -- zero --. * * Side effects: | | | 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 | * reflected channel. * * Results: * A Tcl_Obj containing the string of the new channel handle. The * refcount of the returned object is -- zero --. * * Side effects: * May allocate memory. Mutex-protected critical section locks out other * threads for a short time. * *---------------------------------------------------------------------- */ static Tcl_Obj * NextHandle(void) |
| ︙ | ︙ | |||
2336 2337 2338 2339 2340 2341 2342 | /* *---------------------------------------------------------------------- * * InvokeTclMethod -- * * This function is used to invoke the Tcl level of a reflected channel. | | | 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 | /* *---------------------------------------------------------------------- * * InvokeTclMethod -- * * This function is used to invoke the Tcl level of a reflected channel. * It handles all the command assembly, invocation, and generic state and * result mgmt. It does *not* handle thread redirection; that is the * responsibility of clients of this function. * * Results: * Result code and data as returned by the method. * * Side effects: |
| ︙ | ︙ | |||
2364 2365 2366 2367 2368 2369 2370 |
MethodName method,
Tcl_Obj *argOneObj, /* NULL'able */
Tcl_Obj *argTwoObj, /* NULL'able */
Tcl_Obj **resultObjPtr) /* NULL'able */
{
Tcl_Obj *methObj = NULL; /* Method name in object form */
Tcl_InterpState sr; /* State of handler interp */
| | | | 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 |
MethodName method,
Tcl_Obj *argOneObj, /* NULL'able */
Tcl_Obj *argTwoObj, /* NULL'able */
Tcl_Obj **resultObjPtr) /* NULL'able */
{
Tcl_Obj *methObj = NULL; /* Method name in object form */
Tcl_InterpState sr; /* State of handler interp */
int result; /* Result code of method invocation */
Tcl_Obj *resObj = NULL; /* Result of method invocation. */
Tcl_Obj *cmd;
if (rcPtr->dead) {
/*
* The channel is marked as dead. Bail out immediately, with an
* appropriate error.
*/
|
| ︙ | ︙ | |||
2448 2449 2450 2451 2452 2453 2454 |
* the full state of the result, including additional options.
*
* This is complex and ugly, and would be completely unnecessary
* if we only added support for a TCL_FORBID_EXCEPTIONS flag.
*/
if (result != TCL_ERROR) {
| | | 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 |
* the full state of the result, including additional options.
*
* This is complex and ugly, and would be completely unnecessary
* if we only added support for a TCL_FORBID_EXCEPTIONS flag.
*/
if (result != TCL_ERROR) {
Tcl_Size cmdLen;
const char *cmdString = Tcl_GetStringFromObj(cmd, &cmdLen);
Tcl_IncrRefCount(cmd);
Tcl_ResetResult(rcPtr->interp);
Tcl_SetObjResult(rcPtr->interp, Tcl_ObjPrintf(
"chan handler returned bad code: %d", result));
Tcl_LogCommandInfo(rcPtr->interp, cmdString, cmdString,
|
| ︙ | ︙ | |||
2584 2585 2586 2587 2588 2589 2590 | * an interpreter is deleted, via the AssocData cleanup mechanism. * * Results: * None. * * Side effects: * Deletes the hash table of channels. May close channels. May flush | | | 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 | * an interpreter is deleted, via the AssocData cleanup mechanism. * * Results: * None. * * Side effects: * Deletes the hash table of channels. May close channels. May flush * output on closed channels. Removes any channelEvent handlers that were * registered in this interpreter. * *---------------------------------------------------------------------- */ static void MarkDead( |
| ︙ | ︙ | |||
3121 3122 3123 3124 3125 3126 3127 |
}
paramPtr->input.toRead = TCL_IO_FAILURE;
} else {
/*
* Process a regular result.
*/
| | | | 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 |
}
paramPtr->input.toRead = TCL_IO_FAILURE;
} else {
/*
* Process a regular result.
*/
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
if (bytev == NULL) {
ForwardSetStaticError(paramPtr, msg_read_nonbyte);
paramPtr->input.toRead = -1;
} else if (paramPtr->input.toRead < bytec) {
ForwardSetStaticError(paramPtr, msg_read_toomuch);
paramPtr->input.toRead = TCL_IO_FAILURE;
} else {
if (bytec > 0) {
memcpy(paramPtr->input.buf, bytev, bytec);
}
paramPtr->input.toRead = bytec;
}
}
Tcl_Release(rcPtr);
Tcl_DecrRefCount(toReadObj);
|
| ︙ | ︙ | |||
3303 3304 3305 3306 3307 3308 3309 |
ForwardSetObjError(paramPtr, resObj);
} else {
/*
* Extract list, validate that it is a list, and #elements. See
* NOTE (4) as well.
*/
| | | | | | 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 |
ForwardSetObjError(paramPtr, resObj);
} else {
/*
* Extract list, validate that it is a list, and #elements. See
* NOTE (4) as well.
*/
Tcl_Size listc;
Tcl_Obj **listv;
if (TclListObjGetElementsM(interp, resObj, &listc,
&listv) != TCL_OK) {
Tcl_DecrRefCount(resObj);
resObj = MarshallError(interp);
ForwardSetObjError(paramPtr, resObj);
} else if ((listc % 2) == 1) {
/*
* Odd number of elements is wrong. [x].
*/
char *buf = (char *)Tcl_Alloc(200);
snprintf(buf, 200,
"{Expected list with even number of elements, got %" TCL_SIZE_MODIFIER "u %s instead}",
listc, (listc == 1 ? "element" : "elements"));
ForwardSetDynamicError(paramPtr, buf);
} else {
Tcl_Size len;
const char *str = Tcl_GetStringFromObj(resObj, &len);
if (len) {
TclDStringAppendLiteral(paramPtr->getOpt.value, " ");
Tcl_DStringAppend(paramPtr->getOpt.value, str, len);
}
}
|
| ︙ | ︙ | |||
3435 3436 3437 3438 3439 3440 3441 |
}
static void
ForwardSetObjError(
ForwardParam *paramPtr,
Tcl_Obj *obj)
{
| | | 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 |
}
static void
ForwardSetObjError(
ForwardParam *paramPtr,
Tcl_Obj *obj)
{
Tcl_Size len;
const char *msgStr = Tcl_GetStringFromObj(obj, &len);
len++;
ForwardSetDynamicError(paramPtr, Tcl_Alloc(len));
memcpy(paramPtr->base.msgStr, msgStr, len);
}
#endif
|
| ︙ | ︙ |
Changes to generic/tclIORTrans.c.
| ︙ | ︙ | |||
507 508 509 510 511 512 513 |
int mode; /* R/W mode of parent, later the new channel.
* Has to match the abilities of the handler
* commands */
Tcl_Obj *cmdObj; /* Command prefix, list of words */
Tcl_Obj *cmdNameObj; /* Command name */
Tcl_Obj *rtId; /* Handle of the new transform (channel) */
Tcl_Obj *modeObj; /* mode in obj form for method call */
| | | 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
int mode; /* R/W mode of parent, later the new channel.
* Has to match the abilities of the handler
* commands */
Tcl_Obj *cmdObj; /* Command prefix, list of words */
Tcl_Obj *cmdNameObj; /* Command name */
Tcl_Obj *rtId; /* Handle of the new transform (channel) */
Tcl_Obj *modeObj; /* mode in obj form for method call */
Tcl_Size listc; /* Result of 'initialize', and of */
Tcl_Obj **listv; /* its sublist in the 2nd element */
int methIndex; /* Encoded method name */
int result; /* Result code for 'initialize' */
Tcl_Obj *resObj; /* Result data for 'initialize' */
int methods; /* Bitmask for supported methods. */
ReflectedTransformMap *rtmPtr;
/* Map of reflected transforms with handlers
|
| ︙ | ︙ | |||
630 631 632 633 634 635 636 |
TclGetString(cmdObj)));
goto error;
}
/*
* Mode tell us what the parent channel supports. The methods tell us what
* the handler supports. We remove the non-supported bits from the mode
| | | 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
TclGetString(cmdObj)));
goto error;
}
/*
* Mode tell us what the parent channel supports. The methods tell us what
* the handler supports. We remove the non-supported bits from the mode
* and check that the channel is not completely inaccessible. Afterward the
* mode tells us which methods are still required, and these methods will
* also be supported by the handler, by design of the check.
*/
if (!HAS(methods, METH_READ)) {
mode &= ~TCL_READABLE;
}
|
| ︙ | ︙ | |||
816 817 818 819 820 821 822 |
}
static void
UnmarshallErrorResult(
Tcl_Interp *interp,
Tcl_Obj *msgObj)
{
| | | | 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
}
static void
UnmarshallErrorResult(
Tcl_Interp *interp,
Tcl_Obj *msgObj)
{
Tcl_Size lc;
Tcl_Obj **lv;
int explicitResult;
Tcl_Size numOptions;
/*
* Process the caught message.
*
* Syntax = (option value)... ?message?
*
* Bad syntax causes a panic. This is OK because the other side uses
|
| ︙ | ︙ | |||
862 863 864 865 866 867 868 | * * ReflectClose -- * * This function is invoked when the channel is closed, to delete the * driver specific instance data. * * Results: | | | 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 | * * ReflectClose -- * * This function is invoked when the channel is closed, to delete the * driver specific instance data. * * Results: * A Posix error. * * Side effects: * Releases memory. Arbitrary, as it calls upon a script. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ | |||
981 982 983 984 985 986 987 |
return EINVAL;
}
return EOK;
}
#endif /* TCL_THREADS */
/*
| | | 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 |
return EINVAL;
}
return EOK;
}
#endif /* TCL_THREADS */
/*
* Do the actual invocation of "finalize" now; we're in the right thread.
*/
result = InvokeTclMethod(rtPtr, "finalize", NULL, NULL, &resObj);
if ((result != TCL_OK) && (interp != NULL)) {
Tcl_SetChannelErrorInterp(interp, resObj);
}
|
| ︙ | ︙ | |||
1445 1446 1447 1448 1449 1450 1451 | * * ReflectBlock -- * * This function is invoked to tell the channel which blocking behaviour * is required of it. * * Results: | | | 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 | * * ReflectBlock -- * * This function is invoked to tell the channel which blocking behaviour * is required of it. * * Results: * A Posix error number. * * Side effects: * Allocates memory. Arbitrary, as it calls upon a script. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ | |||
1532 1533 1534 1535 1536 1537 1538 |
*----------------------------------------------------------------------
*/
static int
ReflectGetOption(
void *clientData, /* Channel to query */
Tcl_Interp *interp, /* Interpreter to leave error messages in */
| | | 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 |
*----------------------------------------------------------------------
*/
static int
ReflectGetOption(
void *clientData, /* Channel to query */
Tcl_Interp *interp, /* Interpreter to leave error messages in */
const char *optionName, /* Name of requested option */
Tcl_DString *dsPtr) /* String to place the result into */
{
ReflectedTransform *rtPtr = (ReflectedTransform *)clientData;
/*
* Transformations have no options. Thus the call is passed down unchanged
* to the parent channel for processing. Its results are passed back
|
| ︙ | ︙ | |||
1587 1588 1589 1590 1591 1592 1593 |
int direction,
void **handlePtr)
{
ReflectedTransform *rtPtr = (ReflectedTransform *)clientData;
/*
* Transformations have no handle of their own. As such we simply query
| | | 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 |
int direction,
void **handlePtr)
{
ReflectedTransform *rtPtr = (ReflectedTransform *)clientData;
/*
* Transformations have no handle of their own. As such we simply query
* the parent channel for it. This way the query will ripple down through
* all transformations until reaches the base channel. Which then returns
* its handle, or fails. The former will then ripple up the stack.
*
* This all happens in the thread we are in. As the Tcl level is not
* involved no forwarding is required.
*/
|
| ︙ | ︙ | |||
1621 1622 1623 1624 1625 1626 1627 |
ReflectNotify(
void *clientData,
int mask)
{
ReflectedTransform *rtPtr = (ReflectedTransform *)clientData;
/*
| | | 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 |
ReflectNotify(
void *clientData,
int mask)
{
ReflectedTransform *rtPtr = (ReflectedTransform *)clientData;
/*
* An event occurred in the underlying channel.
*
* We delete our timer. It was not fired, yet we are here, so the channel
* below generated such an event and we don't have to. The renewal of the
* interest after the execution of channel handlers will eventually cause
* us to recreate the timer (in ReflectWatch).
*/
|
| ︙ | ︙ | |||
1715 1716 1717 1718 1719 1720 1721 |
Tcl_Interp *interp,
Tcl_Obj *cmdpfxObj,
TCL_UNUSED(int) /*mode*/,
Tcl_Obj *handleObj,
Tcl_Channel parentChan)
{
ReflectedTransform *rtPtr;
| | | 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 |
Tcl_Interp *interp,
Tcl_Obj *cmdpfxObj,
TCL_UNUSED(int) /*mode*/,
Tcl_Obj *handleObj,
Tcl_Channel parentChan)
{
ReflectedTransform *rtPtr;
Tcl_Size i, listc;
Tcl_Obj **listv;
rtPtr = (ReflectedTransform *)Tcl_Alloc(sizeof(ReflectedTransform));
/* rtPtr->chan: Assigned by caller. Dummy data here. */
/* rtPtr->methods: Assigned by caller. Dummy data here. */
|
| ︙ | ︙ | |||
1883 1884 1885 1886 1887 1888 1889 | /* *---------------------------------------------------------------------- * * InvokeTclMethod -- * * This function is used to invoke the Tcl level of a reflected channel. | | | 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 | /* *---------------------------------------------------------------------- * * InvokeTclMethod -- * * This function is used to invoke the Tcl level of a reflected channel. * It handles all the command assembly, invocation, and generic state and * result mgmt. It does *not* handle thread redirection; that is the * responsibility of clients of this function. * * Results: * Result code and data as returned by the method. * * Side effects: |
| ︙ | ︙ | |||
1915 1916 1917 1918 1919 1920 1921 |
Tcl_Obj *argOneObj, /* NULL'able */
Tcl_Obj *argTwoObj, /* NULL'able */
Tcl_Obj **resultObjPtr) /* NULL'able */
{
int cmdc; /* #words in constructed command */
Tcl_Obj *methObj = NULL; /* Method name in object form */
Tcl_InterpState sr; /* State of handler interp */
| | | | 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 |
Tcl_Obj *argOneObj, /* NULL'able */
Tcl_Obj *argTwoObj, /* NULL'able */
Tcl_Obj **resultObjPtr) /* NULL'able */
{
int cmdc; /* #words in constructed command */
Tcl_Obj *methObj = NULL; /* Method name in object form */
Tcl_InterpState sr; /* State of handler interp */
int result; /* Result code of method invocation */
Tcl_Obj *resObj = NULL; /* Result of method invocation. */
if (rtPtr->dead) {
/*
* The transform is marked as dead. Bail out immediately, with an
* appropriate error.
*/
|
| ︙ | ︙ | |||
1940 1941 1942 1943 1944 1945 1946 |
* NOTE (5): Decide impl. issue: Cache objects with method names?
* Requires TSD data as reflections can be created in many different
* threads.
* NO: Caching of command resolutions means storage per channel.
*/
/*
| | | 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 |
* NOTE (5): Decide impl. issue: Cache objects with method names?
* Requires TSD data as reflections can be created in many different
* threads.
* NO: Caching of command resolutions means storage per channel.
*/
/*
* Insert method into the preallocated area, after the command prefix,
* before the channel id.
*/
methObj = Tcl_NewStringObj(method, -1);
Tcl_IncrRefCount(methObj);
rtPtr->argv[rtPtr->argc - 2] = methObj;
|
| ︙ | ︙ | |||
1967 1968 1969 1970 1971 1972 1973 |
if (argTwoObj) {
rtPtr->argv[cmdc] = argTwoObj;
cmdc++;
}
}
/*
| | | 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 |
if (argTwoObj) {
rtPtr->argv[cmdc] = argTwoObj;
cmdc++;
}
}
/*
* And run the handler... This is done in a manner which leaves any
* existing state intact.
*/
sr = Tcl_SaveInterpState(rtPtr->interp, 0 /* Dummy */);
Tcl_Preserve(rtPtr);
Tcl_Preserve(rtPtr->interp);
result = Tcl_EvalObjv(rtPtr->interp, cmdc, rtPtr->argv, TCL_EVAL_GLOBAL);
|
| ︙ | ︙ | |||
2000 2001 2002 2003 2004 2005 2006 |
* the full state of the result, including additional options.
*
* This is complex and ugly, and would be completely unnecessary
* if we only added support for a TCL_FORBID_EXCEPTIONS flag.
*/
if (result != TCL_ERROR) {
Tcl_Obj *cmd = Tcl_NewListObj(cmdc, rtPtr->argv);
| | | 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 |
* the full state of the result, including additional options.
*
* This is complex and ugly, and would be completely unnecessary
* if we only added support for a TCL_FORBID_EXCEPTIONS flag.
*/
if (result != TCL_ERROR) {
Tcl_Obj *cmd = Tcl_NewListObj(cmdc, rtPtr->argv);
Tcl_Size cmdLen;
const char *cmdString = Tcl_GetStringFromObj(cmd, &cmdLen);
Tcl_IncrRefCount(cmd);
Tcl_ResetResult(rtPtr->interp);
Tcl_SetObjResult(rtPtr->interp, Tcl_ObjPrintf(
"chan handler returned bad code: %d", result));
Tcl_LogCommandInfo(rtPtr->interp, cmdString, cmdString, cmdLen);
|
| ︙ | ︙ | |||
2766 2767 2768 2769 2770 2771 2772 |
}
static void
ForwardSetObjError(
ForwardParam *paramPtr,
Tcl_Obj *obj)
{
| | | 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 |
}
static void
ForwardSetObjError(
ForwardParam *paramPtr,
Tcl_Obj *obj)
{
Tcl_Size len;
const char *msgStr = Tcl_GetStringFromObj(obj, &len);
len++;
ForwardSetDynamicError(paramPtr, Tcl_Alloc(len));
memcpy(paramPtr->base.msgStr, msgStr, len);
}
#endif /* TCL_THREADS */
|
| ︙ | ︙ | |||
2869 2870 2871 2872 2873 2874 2875 | /* *---------------------------------------------------------------------- * * ResultInit -- * * Initializes the specified buffer structure. The structure will contain | | | 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 | /* *---------------------------------------------------------------------- * * ResultInit -- * * Initializes the specified buffer structure. The structure will contain * valid information for an empty buffer. * * Side effects: * See above. * * Result: * None. * |
| ︙ | ︙ |
Changes to generic/tclIOSock.c.
| ︙ | ︙ | |||
113 114 115 116 117 118 119 |
#if !defined(_WIN32) && !defined(__CYGWIN__)
# define SOCKET int
#endif
int
TclSockMinimumBuffers(
void *sock, /* Socket file descriptor */
| | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
#if !defined(_WIN32) && !defined(__CYGWIN__)
# define SOCKET int
#endif
int
TclSockMinimumBuffers(
void *sock, /* Socket file descriptor */
Tcl_Size size1) /* Minimum buffer size */
{
int current;
socklen_t len;
int size = size1;
if (size != size1) {
return TCL_ERROR;
}
len = sizeof(int);
getsockopt((SOCKET)(size_t) sock, SOL_SOCKET, SO_SNDBUF,
(char *) ¤t, &len);
if (current < size) {
len = sizeof(int);
|
| ︙ | ︙ |
Changes to generic/tclIOUtil.c.
| ︙ | ︙ | |||
174 175 176 177 178 179 180 |
(Tcl_FSGetCwdProc *) TclpGetNativeCwd,
TclpObjChdir
};
/*
* An initial record in the linked list for the native filesystem. Remains at
* the tail of the list and is never freed. Currently the native filesystem is
| | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
(Tcl_FSGetCwdProc *) TclpGetNativeCwd,
TclpObjChdir
};
/*
* An initial record in the linked list for the native filesystem. Remains at
* the tail of the list and is never freed. Currently the native filesystem is
* hard-coded. It may make sense to modify this to accommodate unconventional
* uses of Tcl that provide no native filesystem.
*/
static FilesystemRecord nativeFilesystemRecord = {
NULL,
&tclNativeFilesystem,
NULL,
|
| ︙ | ︙ | |||
289 290 291 292 293 294 295 | } # undef OUT_OF_RANGE # undef OUT_OF_URANGE #endif /* !TCL_WIDE_INT_IS_LONG */ /* | | | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | } # undef OUT_OF_RANGE # undef OUT_OF_URANGE #endif /* !TCL_WIDE_INT_IS_LONG */ /* * Copy across all supported fields, with possible type coercion on * those fields that change between the normal and lf64 versions of * the stat structure (on Solaris at least). This is slow when the * structure sizes coincide, but that's what you get for using an * obsolete interface. */ oldStyleBuf->st_mode = buf.st_mode; |
| ︙ | ︙ | |||
517 518 519 520 521 522 523 |
if (pathPtrPtr == NULL) {
return (tsdPtr->cwdPathPtr == NULL);
}
if (tsdPtr->cwdPathPtr == *pathPtrPtr) {
return 1;
} else {
| | | 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
if (pathPtrPtr == NULL) {
return (tsdPtr->cwdPathPtr == NULL);
}
if (tsdPtr->cwdPathPtr == *pathPtrPtr) {
return 1;
} else {
Tcl_Size len1, len2;
const char *str1, *str2;
str1 = Tcl_GetStringFromObj(tsdPtr->cwdPathPtr, &len1);
str2 = Tcl_GetStringFromObj(*pathPtrPtr, &len2);
if ((len1 == len2) && !memcmp(str1, str2, len1)) {
/*
* The values are equal but the objects are different. Cache the
|
| ︙ | ︙ | |||
659 660 661 662 663 664 665 |
*/
static void
FsUpdateCwd(
Tcl_Obj *cwdObj,
void *clientData)
{
| | | 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 |
*/
static void
FsUpdateCwd(
Tcl_Obj *cwdObj,
void *clientData)
{
Tcl_Size len = 0;
const char *str = NULL;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&fsDataKey);
if (cwdObj != NULL) {
str = Tcl_GetStringFromObj(cwdObj, &len);
}
|
| ︙ | ︙ | |||
985 986 987 988 989 990 991 |
* of the correct type. */
Tcl_GlobTypeData *types) /* Specifies acceptable types.
* May be NULL. The directory flag is
* particularly significant. */
{
const Tcl_Filesystem *fsPtr;
Tcl_Obj *cwd, *tmpResultPtr, **elemsPtr;
| | | 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
* of the correct type. */
Tcl_GlobTypeData *types) /* Specifies acceptable types.
* May be NULL. The directory flag is
* particularly significant. */
{
const Tcl_Filesystem *fsPtr;
Tcl_Obj *cwd, *tmpResultPtr, **elemsPtr;
Tcl_Size resLength, i;
int ret = -1;
if (types != NULL && (types->type & TCL_GLOB_TYPE_MOUNT)) {
/*
* Currently external callers may not query mounts, which would be a
* valuable future step. This is the only routine that knows about
* mounts, so we're being called recursively by ourself. Return no
|
| ︙ | ︙ | |||
1102 1103 1104 1105 1106 1107 1108 |
* not be shared. */
Tcl_Obj *pathPtr, /* The directory that was searched. */
const char *pattern, /* Pattern to match mounts against. */
Tcl_GlobTypeData *types) /* Acceptable types. May be NULL. The
* directory flag is particularly significant.
*/
{
| | | | 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
* not be shared. */
Tcl_Obj *pathPtr, /* The directory that was searched. */
const char *pattern, /* Pattern to match mounts against. */
Tcl_GlobTypeData *types) /* Acceptable types. May be NULL. The
* directory flag is particularly significant.
*/
{
Tcl_Size mLength, gLength, i;
int dir = (types == NULL || (types->type & TCL_GLOB_TYPE_DIR));
Tcl_Obj *mounts = FsListMounts(pathPtr, pattern);
if (mounts == NULL) {
return;
}
if (TclListObjLengthM(NULL, mounts, &mLength) != TCL_OK || mLength == 0) {
goto endOfMounts;
}
if (TclListObjLengthM(NULL, resultPtr, &gLength) != TCL_OK) {
goto endOfMounts;
}
for (i=0 ; i<mLength ; i++) {
Tcl_Obj *mElt;
Tcl_Size j;
int found = 0;
Tcl_ListObjIndex(NULL, mounts, i, &mElt);
for (j=0 ; j<gLength ; j++) {
Tcl_Obj *gElt;
|
| ︙ | ︙ | |||
1142 1143 1144 1145 1146 1147 1148 |
gLength--;
}
break; /* Break out of for loop. */
}
}
if (!found && dir) {
Tcl_Obj *norm;
| | | 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 |
gLength--;
}
break; /* Break out of for loop. */
}
}
if (!found && dir) {
Tcl_Obj *norm;
Tcl_Size len, mlen;
/*
* mElt is normalized and lies inside pathPtr so
* add to the result the right representation of mElt,
* i.e. the representation relative to pathPtr.
*/
|
| ︙ | ︙ | |||
1299 1300 1301 1302 1303 1304 1305 | * Stores the resulting pathname in pathPtr and returns the offset of the * last byte processed in pathPtr. * * Side effects: * None (beyond the memory allocation for the result). * * Special notes: | | | | 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 |
* Stores the resulting pathname in pathPtr and returns the offset of the
* last byte processed in pathPtr.
*
* Side effects:
* None (beyond the memory allocation for the result).
*
* Special notes:
* If the filesystem-specific normalizePathProcs can reintroduce ../, ./
* components into the pathname, this function does not return the correct
* result. This may be possible with symbolic links on unix.
*
*
*---------------------------------------------------------------------------
*/
int
TclFSNormalizeToUniquePath(
Tcl_Interp *interp, /* Used for error messages. */
Tcl_Obj *pathPtr, /* An Pathname to normalize in-place. Must be
* unshared. */
int startAt) /* Offset the string of pathPtr to start at.
* Must either be 0 or offset of a directory
* separator at the end of a pathname part that
* is already normalized, I.e. not the index of
* the byte just after the separator. */
{
FilesystemRecord *fsRecPtr, *firstFsRecPtr;
Tcl_Size i;
int isVfsPath = 0;
const char *path;
/*
* Pathnames starting with a UNC prefix and ending with a colon character
* are reserved for VFS use. These names can not conflict with real UNC
* pathnames per https://msdn.microsoft.com/en-us/library/gg465305.aspx and
|
| ︙ | ︙ | |||
1471 1472 1473 1474 1475 1476 1477 |
int *seekFlagPtr, /* Sets this to 1 to tell the the caller to seek to
* EOF after opening the file, and 0 otherwise. */
int *binaryPtr) /* Sets this to 1 to tell the caller to
* configure the channel for binary
* operations after opening the file. */
{
int mode, c, gotRW;
| | | 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 |
int *seekFlagPtr, /* Sets this to 1 to tell the the caller to seek to
* EOF after opening the file, and 0 otherwise. */
int *binaryPtr) /* Sets this to 1 to tell the caller to
* configure the channel for binary
* operations after opening the file. */
{
int mode, c, gotRW;
Tcl_Size modeArgc, i;
const char **modeArgv, *flag;
#define RW_MODES (O_RDONLY|O_WRONLY|O_RDWR)
/*
* Check for the simpler fopen-like access modes like "r" which are
* distinguished from the POSIX access modes by the presence of a
* lower-case first letter.
|
| ︙ | ︙ | |||
1682 1683 1684 1685 1686 1687 1688 |
Tcl_Interp *interp, /* Interpreter that evaluates the script. */
Tcl_Obj *pathPtr, /* Pathname of the file to process.
* Tilde-substitution is performed on this
* pathname. */
const char *encodingName) /* Either the name of an encoding or NULL to
use the utf-8 encoding. */
{
| | | | 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 |
Tcl_Interp *interp, /* Interpreter that evaluates the script. */
Tcl_Obj *pathPtr, /* Pathname of the file to process.
* Tilde-substitution is performed on this
* pathname. */
const char *encodingName) /* Either the name of an encoding or NULL to
use the utf-8 encoding. */
{
Tcl_Size length;
int result = TCL_ERROR;
Tcl_StatBuf statBuf;
Tcl_Obj *oldScriptFile;
Interp *iPtr;
const char *string;
Tcl_Channel chan;
Tcl_Obj *objPtr;
|
| ︙ | ︙ | |||
1798 1799 1800 1801 1802 1803 1804 |
} else if (result == TCL_ERROR) {
/*
* Record information about where the error occurred.
*/
const char *pathString = Tcl_GetStringFromObj(pathPtr, &length);
unsigned limit = 150;
| | | 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 |
} else if (result == TCL_ERROR) {
/*
* Record information about where the error occurred.
*/
const char *pathString = Tcl_GetStringFromObj(pathPtr, &length);
unsigned limit = 150;
int overflow = ((unsigned)length > limit);
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (file \"%.*s%s\" line %d)",
(overflow ? limit : (unsigned)length), pathString,
(overflow ? "..." : ""), Tcl_GetErrorLine(interp)));
}
|
| ︙ | ︙ | |||
1948 1949 1950 1951 1952 1953 1954 |
if (result == TCL_RETURN) {
result = TclUpdateReturnInfo(iPtr);
} else if (result == TCL_ERROR) {
/*
* Record information about where the error occurred.
*/
| | | | 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 |
if (result == TCL_RETURN) {
result = TclUpdateReturnInfo(iPtr);
} else if (result == TCL_ERROR) {
/*
* Record information about where the error occurred.
*/
Tcl_Size length;
const char *pathString = Tcl_GetStringFromObj(pathPtr, &length);
const unsigned limit = 150;
int overflow = (length > limit);
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (file \"%.*s%s\" line %d)",
(overflow ? limit : (unsigned int)length), pathString,
(overflow ? "..." : ""), Tcl_GetErrorLine(interp)));
}
|
| ︙ | ︙ | |||
2059 2060 2061 2062 2063 2064 2065 | /* *---------------------------------------------------------------------- * * Tcl_FSStat -- * Calls 'statProc' of the filesystem corresponding to pathPtr. * | | < | 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 | /* *---------------------------------------------------------------------- * * Tcl_FSStat -- * Calls 'statProc' of the filesystem corresponding to pathPtr. * * Replaces the standard library "stat" routine. * * Results: * See stat documentation. * * Side effects: * See stat documentation. * |
| ︙ | ︙ | |||
2455 2456 2457 2458 2459 2460 2461 |
}
if (attrTable != NULL) {
/*
* It's a constant attribute table, so use T_GIFO.
*/
| | | | 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 |
}
if (attrTable != NULL) {
/*
* It's a constant attribute table, so use T_GIFO.
*/
Tcl_Obj *tmpObj = Tcl_NewStringObj(attributeName, -1);
int result;
result = Tcl_GetIndexFromObj(NULL, tmpObj, attrTable, NULL, TCL_EXACT,
indexPtr);
TclDecrRefCount(tmpObj);
if (listObj != NULL) {
TclDecrRefCount(listObj);
}
return result;
} else if (listObj != NULL) {
/*
* It's a non-constant attribute list, so do a literal search.
*/
Tcl_Size i, objc;
Tcl_Obj **objv;
if (TclListObjGetElementsM(NULL, listObj, &objc, &objv) != TCL_OK) {
TclDecrRefCount(listObj);
return TCL_ERROR;
}
for (i=0 ; i<objc ; i++) {
|
| ︙ | ︙ | |||
2791 2792 2793 2794 2795 2796 2797 | * Determine whether the filesystem's answer is the same as the * cached local value. Since both 'norm' and 'tsdPtr->cwdPathPtr' * are normalized pathnames, do something more efficient than * calling 'Tcl_FSEqualPaths', and in addition avoid a nasty * infinite loop bug when trying to normalize tsdPtr->cwdPathPtr. */ | | | 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 |
* Determine whether the filesystem's answer is the same as the
* cached local value. Since both 'norm' and 'tsdPtr->cwdPathPtr'
* are normalized pathnames, do something more efficient than
* calling 'Tcl_FSEqualPaths', and in addition avoid a nasty
* infinite loop bug when trying to normalize tsdPtr->cwdPathPtr.
*/
Tcl_Size len1, len2;
const char *str1, *str2;
str1 = Tcl_GetStringFromObj(tsdPtr->cwdPathPtr, &len1);
str2 = Tcl_GetStringFromObj(norm, &len2);
if ((len1 == len2) && (strcmp(str1, str2) == 0)) {
/*
* The pathname values are equal so retain the old pathname
|
| ︙ | ︙ | |||
3288 3289 3290 3291 3292 3293 3294 |
* Try to delete the file we probably created and then exit.
*/
Tcl_FSDeleteFile(copyToPtr);
Tcl_DecrRefCount(copyToPtr);
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 |
* Try to delete the file we probably created and then exit.
*/
Tcl_FSDeleteFile(copyToPtr);
Tcl_DecrRefCount(copyToPtr);
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"couldn't load from current filesystem", -1));
}
return TCL_ERROR;
}
if (TclCrossFilesystemCopy(interp, pathPtr, copyToPtr) != TCL_OK) {
Tcl_FSDeleteFile(copyToPtr);
Tcl_DecrRefCount(copyToPtr);
|
| ︙ | ︙ | |||
3872 3873 3874 3875 3876 3877 3878 |
*---------------------------------------------------------------------------
*/
#undef Tcl_FSSplitPath
Tcl_Obj *
Tcl_FSSplitPath(
Tcl_Obj *pathPtr, /* The pathname to split. */
| | | | 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 |
*---------------------------------------------------------------------------
*/
#undef Tcl_FSSplitPath
Tcl_Obj *
Tcl_FSSplitPath(
Tcl_Obj *pathPtr, /* The pathname to split. */
Tcl_Size *lenPtr) /* A place to hold the number of pathname
* elements. */
{
Tcl_Obj *result = NULL; /* Just to squelch gcc warnings. */
const Tcl_Filesystem *fsPtr;
char separator = '/';
Tcl_Size driveNameLength;
const char *p;
/*
* Perform platform-specific splitting.
*/
if (TclFSGetPathType(pathPtr, &fsPtr,
|
| ︙ | ︙ | |||
3924 3925 3926 3927 3928 3929 3930 |
/*
* Add the remaining pathname elements to the list.
*/
for (;;) {
const char *elementStart = p;
| | | 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 |
/*
* Add the remaining pathname elements to the list.
*/
for (;;) {
const char *elementStart = p;
Tcl_Size length;
while ((*p != '\0') && (*p != separator)) {
p++;
}
length = p - elementStart;
if (length > 0) {
Tcl_Obj *nextElt;
|
| ︙ | ︙ | |||
3969 3970 3971 3972 3973 3974 3975 |
Tcl_PathType
TclGetPathType(
Tcl_Obj *pathPtr, /* Pathname to determine type of. */
const Tcl_Filesystem **filesystemPtrPtr,
/* If not NULL, a place in which to store a
* pointer to the filesystem for this pathname
* if it is absolute. */
| | | | 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 |
Tcl_PathType
TclGetPathType(
Tcl_Obj *pathPtr, /* Pathname to determine type of. */
const Tcl_Filesystem **filesystemPtrPtr,
/* If not NULL, a place in which to store a
* pointer to the filesystem for this pathname
* if it is absolute. */
Tcl_Size *driveNameLengthPtr, /* If not NULL, a place in which to store the
* length of the volume name. */
Tcl_Obj **driveNameRef) /* If not NULL, for an absolute pathname, a
* place to store a pointer to an object with a
* refCount of 1, and whose value is the name
* of the volume. */
{
Tcl_Size pathLen;
const char *path = Tcl_GetStringFromObj(pathPtr, &pathLen);
Tcl_PathType type;
type = TclFSNonnativePathType(path, pathLen, filesystemPtrPtr,
driveNameLengthPtr, driveNameRef);
if (type != TCL_PATH_ABSOLUTE) {
|
| ︙ | ︙ | |||
4018 4019 4020 4021 4022 4023 4024 |
*
*----------------------------------------------------------------------
*/
Tcl_PathType
TclFSNonnativePathType(
const char *path, /* Pathname to determine the type of. */
| | | | 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 |
*
*----------------------------------------------------------------------
*/
Tcl_PathType
TclFSNonnativePathType(
const char *path, /* Pathname to determine the type of. */
Tcl_Size pathLen, /* Length of the pathname. */
const Tcl_Filesystem **filesystemPtrPtr,
/* If not NULL, a place to store a pointer to
* the filesystem for this pathname when it is
* an absolute pathname. */
Tcl_Size *driveNameLengthPtr,/* If not NULL, a place to store the length of
* the volume name if the pathname is absolute.
*/
Tcl_Obj **driveNameRef) /* If not NULL, a place to store a pointer to
* an object having its its refCount already
* incremented, and contining the name of the
* volume if the pathname is absolute. */
{
|
| ︙ | ︙ | |||
4060 4061 4062 4063 4064 4065 4066 |
* no reason to waste time doing that in this frequently-called
* function. It is better to save the overhead of the native
* filesystem continuously returning a list of volumes.
*/
if ((fsRecPtr->fsPtr != &tclNativeFilesystem)
&& (fsRecPtr->fsPtr->listVolumesProc != NULL)) {
| | | | | 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 |
* no reason to waste time doing that in this frequently-called
* function. It is better to save the overhead of the native
* filesystem continuously returning a list of volumes.
*/
if ((fsRecPtr->fsPtr != &tclNativeFilesystem)
&& (fsRecPtr->fsPtr->listVolumesProc != NULL)) {
Tcl_Size numVolumes;
Tcl_Obj *thisFsVolumes = fsRecPtr->fsPtr->listVolumesProc();
if (thisFsVolumes != NULL) {
if (TclListObjLengthM(NULL, thisFsVolumes, &numVolumes)
!= TCL_OK) {
/*
* This is VERY bad; the listVolumesProc didn't return a
* valid list. Set numVolumes to -1 to skip the loop below
* and just return with the current value of 'type'.
*
* It would be better to signal an error here, but
* Tcl_Panic seems a bit excessive.
*/
numVolumes = TCL_INDEX_NONE;
}
while (numVolumes > 0) {
Tcl_Obj *vol;
Tcl_Size len;
const char *strVol;
numVolumes--;
Tcl_ListObjIndex(NULL, thisFsVolumes, numVolumes, &vol);
strVol = Tcl_GetStringFromObj(vol,&len);
if (pathLen < len) {
continue;
|
| ︙ | ︙ | |||
4426 4427 4428 4429 4430 4431 4432 |
return -1;
}
if (recursive) {
Tcl_Obj *cwdPtr = Tcl_FSGetCwd(NULL);
if (cwdPtr != NULL) {
const char *cwdStr, *normPathStr;
| | | 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 |
return -1;
}
if (recursive) {
Tcl_Obj *cwdPtr = Tcl_FSGetCwd(NULL);
if (cwdPtr != NULL) {
const char *cwdStr, *normPathStr;
Tcl_Size cwdLen, normLen;
Tcl_Obj *normPath = Tcl_FSGetNormalizedPath(NULL, pathPtr);
if (normPath != NULL) {
normPathStr = Tcl_GetStringFromObj(normPath, &normLen);
cwdStr = Tcl_GetStringFromObj(cwdPtr, &cwdLen);
if ((cwdLen >= normLen) && (strncmp(normPathStr, cwdStr,
normLen) == 0)) {
|
| ︙ | ︙ | |||
4608 4609 4610 4611 4612 4613 4614 |
if (fsPtr == NULL) {
return NULL;
}
resPtr = Tcl_NewListObj(0, NULL);
Tcl_ListObjAppendElement(NULL, resPtr,
| | | 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 |
if (fsPtr == NULL) {
return NULL;
}
resPtr = Tcl_NewListObj(0, NULL);
Tcl_ListObjAppendElement(NULL, resPtr,
Tcl_NewStringObj(fsPtr->typeName, -1));
if (fsPtr->filesystemPathTypeProc != NULL) {
Tcl_Obj *typePtr = fsPtr->filesystemPathTypeProc(pathPtr);
if (typePtr != NULL) {
Tcl_ListObjAppendElement(NULL, resPtr, typePtr);
}
|
| ︙ | ︙ |
Changes to generic/tclIndexObj.c.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 | * Copyright © 2006 Sam Bromley. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tclInt.h" /* * Prototypes for functions defined later in this file: */ static int GetIndexFromObjList(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Obj *tableObjPtr, | > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * Copyright © 2006 Sam Bromley. * * 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 <assert.h> /* * Prototypes for functions defined later in this file: */ static int GetIndexFromObjList(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Obj *tableObjPtr, |
| ︙ | ︙ | |||
51 52 53 54 55 56 57 |
* pointer to one of these structures.
*
* Keep this structure declaration in sync with tclTestObj.c
*/
typedef struct {
void *tablePtr; /* Pointer to the table of strings */
| | | | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
* pointer to one of these structures.
*
* Keep this structure declaration in sync with tclTestObj.c
*/
typedef struct {
void *tablePtr; /* Pointer to the table of strings */
Tcl_Size offset; /* Offset between table entries */
Tcl_Size index; /* Selected index into table. */
} IndexRep;
/*
* The following macros greatly simplify moving through a table...
*/
#define STRING_AT(table, offset) \
|
| ︙ | ︙ | |||
103 104 105 106 107 108 109 |
* value of objPtr. */
const char *msg, /* Identifying word to use in error
* messages. */
int flags, /* 0 or TCL_EXACT */
int *indexPtr) /* Place to store resulting integer index. */
{
| | | > > > | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
* value of objPtr. */
const char *msg, /* Identifying word to use in error
* messages. */
int flags, /* 0 or TCL_EXACT */
int *indexPtr) /* Place to store resulting integer index. */
{
Tcl_Size objc, t;
int result;
Tcl_Obj **objv;
const char **tablePtr;
/*
* Use Tcl_GetIndexFromObjStruct to do the work to avoid duplicating most
* of the code there. This is a bit inefficient but simpler.
*/
result = TclListObjGetElementsM(interp, tableObjPtr, &objc, &objv);
if (result != TCL_OK) {
return result;
}
/* Return type is int* so caller should not be passing larger table */
assert(objc <= INT_MAX);
/*
* Build a string table from the list.
*/
tablePtr = (const char **)Tcl_Alloc((objc + 1) * sizeof(char *));
for (t = 0; t < objc; t++) {
if (objv[t] == objPtr) {
/*
* An exact match is always chosen, so we can stop here.
*/
Tcl_Free((void *)tablePtr);
*indexPtr = (int) t;
return TCL_OK;
}
tablePtr[t] = TclGetString(objv[t]);
}
tablePtr[objc] = NULL;
|
| ︙ | ︙ | |||
183 184 185 186 187 188 189 |
Tcl_Interp *interp, /* Used for error reporting if not NULL. */
Tcl_Obj *objPtr, /* Object containing the string to lookup. */
const void *tablePtr, /* The first string in the table. The second
* string will be at this address plus the
* offset, the third plus the offset again,
* etc. The last entry must be NULL and there
* must not be duplicate entries. */
| | | < | | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
Tcl_Interp *interp, /* Used for error reporting if not NULL. */
Tcl_Obj *objPtr, /* Object containing the string to lookup. */
const void *tablePtr, /* The first string in the table. The second
* string will be at this address plus the
* offset, the third plus the offset again,
* etc. The last entry must be NULL and there
* must not be duplicate entries. */
Tcl_Size offset, /* The number of bytes between entries */
const char *msg, /* Identifying word to use in error
* messages. */
int flags, /* 0, TCL_EXACT, TCL_NULL_OK or TCL_INDEX_TEMP_TABLE */
void *indexPtr) /* Place to store resulting index. */
{
Tcl_Size index, idx, numAbbrev;
const char *key, *p1;
const char *p2;
const char *const *entryPtr;
Tcl_Obj *resultPtr;
IndexRep *indexRep;
const Tcl_ObjInternalRep *irPtr;
if (offset < (Tcl_Size) sizeof(char *)) {
return TclIndexInvalidError(interp, "struct offset", offset);
}
/*
* See if there is a valid cached result from a previous lookup.
*/
if (objPtr && !(flags & TCL_INDEX_TEMP_TABLE)) {
irPtr = TclFetchInternalRep(objPtr, &indexType);
|
| ︙ | ︙ | |||
501 502 503 504 505 506 507 |
PrefixMatchObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int flags = 0, result, dummy, i;
| | | 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
PrefixMatchObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int flags = 0, result, dummy, i;
Tcl_Size dummyLength, errorLength;
Tcl_Obj *errorPtr = NULL;
const char *message = "option";
Tcl_Obj *tablePtr, *objPtr, *resultPtr;
static const char *const matchOptions[] = {
"-error", "-exact", "-message", NULL
};
enum matchOptionsEnum {
|
| ︙ | ︙ | |||
529 530 531 532 533 534 535 |
switch (index) {
case PRFMATCH_EXACT:
flags |= TCL_EXACT;
break;
case PRFMATCH_MESSAGE:
if (i > objc-4) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
switch (index) {
case PRFMATCH_EXACT:
flags |= TCL_EXACT;
break;
case PRFMATCH_MESSAGE:
if (i > objc-4) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing value for -message", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "NOARG", NULL);
return TCL_ERROR;
}
i++;
message = TclGetString(objv[i]);
break;
case PRFMATCH_ERROR:
if (i > objc-4) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing value for -error", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "NOARG", NULL);
return TCL_ERROR;
}
i++;
result = TclListObjLengthM(interp, objv[i], &errorLength);
if (result != TCL_OK) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
625 626 627 628 629 630 631 |
PrefixAllObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int result;
| | | 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 |
PrefixAllObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int result;
Tcl_Size length, elemLength, tableObjc, t;
const char *string, *elemString;
Tcl_Obj **tableObjv, *resultPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "table string");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
683 684 685 686 687 688 689 |
PrefixLongestObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int result;
| | | 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 |
PrefixLongestObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int result;
Tcl_Size i, length, elemLength, resultLength, tableObjc, t;
const char *string, *elemString, *resultString;
Tcl_Obj **tableObjv;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "table string");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
798 799 800 801 802 803 804 |
*
*----------------------------------------------------------------------
*/
void
Tcl_WrongNumArgs(
Tcl_Interp *interp, /* Current interpreter. */
| | | | | | | | 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 |
*
*----------------------------------------------------------------------
*/
void
Tcl_WrongNumArgs(
Tcl_Interp *interp, /* Current interpreter. */
Tcl_Size objc, /* Number of arguments to print from objv. */
Tcl_Obj *const objv[], /* Initial argument objects, which should be
* included in the error message. */
const char *message) /* Error message to print after the leading
* objects in objv. The message may be
* NULL. */
{
Tcl_Obj *objPtr;
Tcl_Size i, len, elemLen;
char flags;
Interp *iPtr = (Interp *)interp;
const char *elementStr;
TclNewObj(objPtr);
if (iPtr->flags & INTERP_ALTERNATE_WRONG_ARGS) {
iPtr->flags &= ~INTERP_ALTERNATE_WRONG_ARGS;
Tcl_AppendObjToObj(objPtr, Tcl_GetObjResult(interp));
Tcl_AppendToObj(objPtr, " or \"", -1);
} else {
Tcl_AppendToObj(objPtr, "wrong # args: should be \"", -1);
}
/*
* If processing an an ensemble implementation, rewrite the results in
* terms of how the ensemble was invoked.
*/
if (iPtr->ensembleRewrite.sourceObjs != NULL) {
Tcl_Size toSkip = iPtr->ensembleRewrite.numInsertedObjs;
Tcl_Size toPrint = iPtr->ensembleRewrite.numRemovedObjs;
Tcl_Obj *const *origObjv = TclEnsembleGetRewriteValues(interp);
/*
* Only do rewrite the command if all the replaced objects are
* actually arguments (in objv) to this function. Otherwise it just
* gets too complicated and it's to just give a slightly
* confusing error message...
|
| ︙ | ︙ | |||
885 886 887 888 889 890 891 | } /* * Add a space if the word is not the last one (which has a * moderately complex condition here). */ | | | 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 |
}
/*
* Add a space if the word is not the last one (which has a
* moderately complex condition here).
*/
if (i<toPrint-1 || objc!=0 || message!=NULL) {
Tcl_AppendStringsToObj(objPtr, " ", NULL);
}
}
}
/*
* Now add the arguments (other than those rewritten) that the caller took
|
| ︙ | ︙ | |||
983 984 985 986 987 988 989 |
#undef Tcl_ParseArgsObjv
int
Tcl_ParseArgsObjv(
Tcl_Interp *interp, /* Place to store error message. */
const Tcl_ArgvInfo *argTable,
/* Array of option descriptions. */
| | | | | | | | 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 |
#undef Tcl_ParseArgsObjv
int
Tcl_ParseArgsObjv(
Tcl_Interp *interp, /* Place to store error message. */
const Tcl_ArgvInfo *argTable,
/* Array of option descriptions. */
Tcl_Size *objcPtr, /* Number of arguments in objv. Modified to
* hold # args left in objv at end. */
Tcl_Obj *const *objv, /* Array of arguments to be parsed. */
Tcl_Obj ***remObjv) /* Pointer to array of arguments that were not
* processed here. Should be NULL if no return
* of arguments is desired. */
{
Tcl_Obj **leftovers; /* Array to write back to remObjv on
* successful exit. Will include the name of
* the command. */
Tcl_Size nrem; /* Size of leftovers.*/
const Tcl_ArgvInfo *infoPtr;
/* Pointer to the current entry in the table
* of argument descriptions. */
const Tcl_ArgvInfo *matchPtr;
/* Descriptor that matches current argument */
Tcl_Obj *curArg; /* Current argument */
const char *str = NULL;
char c; /* Second character of current arg (used for
* quick check for matching; use 2nd char.
* because first char. will almost always be
* '-'). */
Tcl_Size srcIndex; /* Location from which to read next argument
* from objv. */
Tcl_Size dstIndex; /* Used to keep track of current arguments
* being processed, primarily for error
* reporting. */
Tcl_Size objc; /* # arguments in objv still to process. */
Tcl_Size length; /* Number of characters in current argument */
if (remObjv != NULL) {
/*
* Then we should copy the name of the command (0th argument). The
* upper bound on the number of elements is known, and (undocumented,
* but historically true) there should be a NULL argument after the
* last result. [Bug 3413857]
|
| ︙ | ︙ | |||
1164 1165 1166 1167 1168 1169 1170 |
if (handlerProc(infoPtr->clientData, argObj, infoPtr->dstPtr)) {
srcIndex++;
objc--;
}
break;
}
case TCL_ARGV_GENFUNC: {
| < | | | 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 |
if (handlerProc(infoPtr->clientData, argObj, infoPtr->dstPtr)) {
srcIndex++;
objc--;
}
break;
}
case TCL_ARGV_GENFUNC: {
if (objc > INT_MAX) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"too many (%" TCL_SIZE_MODIFIER "d) arguments for TCL_ARGV_GENFUNC", objc));
goto error;
}
Tcl_ArgvGenFuncProc *handlerProc = (Tcl_ArgvGenFuncProc *)
infoPtr->srcPtr;
int i = handlerProc(infoPtr->clientData, interp, (int) objc,
&objv[srcIndex], infoPtr->dstPtr);
if (i < 0) {
goto error;
}
objc = i;
break;
}
|
| ︙ | ︙ | |||
1270 1271 1272 1273 1274 1275 1276 |
/*
* First, compute the width of the widest option key, so that we can make
* everything line up.
*/
width = 4;
for (infoPtr = argTable; infoPtr->type != TCL_ARGV_END; infoPtr++) {
| | | | | | 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 |
/*
* First, compute the width of the widest option key, so that we can make
* everything line up.
*/
width = 4;
for (infoPtr = argTable; infoPtr->type != TCL_ARGV_END; infoPtr++) {
Tcl_Size length;
if (infoPtr->keyStr == NULL) {
continue;
}
length = strlen(infoPtr->keyStr);
if (length > width) {
width = length;
}
}
/*
* Now add the option information, with pretty-printing.
*/
msg = Tcl_NewStringObj("Command-specific options:", -1);
for (infoPtr = argTable; infoPtr->type != TCL_ARGV_END; infoPtr++) {
if ((infoPtr->type == TCL_ARGV_HELP) && (infoPtr->keyStr == NULL)) {
Tcl_AppendPrintfToObj(msg, "\n%s", infoPtr->helpStr);
continue;
}
Tcl_AppendPrintfToObj(msg, "\n %s:", infoPtr->keyStr);
numSpaces = width + 1 - strlen(infoPtr->keyStr);
while (numSpaces > 0) {
if (numSpaces >= NUM_SPACES) {
Tcl_AppendToObj(msg, spaces, NUM_SPACES);
} else {
Tcl_AppendToObj(msg, spaces, numSpaces);
}
numSpaces -= NUM_SPACES;
}
Tcl_AppendToObj(msg, infoPtr->helpStr, -1);
switch (infoPtr->type) {
case TCL_ARGV_INT:
Tcl_AppendPrintfToObj(msg, "\n\t\tDefault value: %d",
*((int *) infoPtr->dstPtr));
break;
case TCL_ARGV_FLOAT:
Tcl_AppendPrintfToObj(msg, "\n\t\tDefault value: %g",
|
| ︙ | ︙ |
Changes to generic/tclInt.decls.
| ︙ | ︙ | |||
345 346 347 348 349 350 351 352 |
declare 141 {
const char *TclpGetCwd(Tcl_Interp *interp, Tcl_DString *cwdPtr)
}
declare 142 {
int TclSetByteCodeFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr,
CompileHookProc *hookProc, void *clientData)
}
declare 143 {
| > | | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
declare 141 {
const char *TclpGetCwd(Tcl_Interp *interp, Tcl_DString *cwdPtr)
}
declare 142 {
int TclSetByteCodeFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr,
CompileHookProc *hookProc, void *clientData)
}
# Do NOT change width of the size. TclEmitPush cannot handle it
declare 143 {
int TclAddLiteralObj(struct CompileEnv *envPtr, Tcl_Obj *objPtr,
LiteralEntry **litPtrPtr)
}
declare 144 {
void TclHideLiteral(Tcl_Interp *interp, struct CompileEnv *envPtr,
int index)
}
declare 145 {
|
| ︙ | ︙ | |||
659 660 661 662 663 664 665 666 |
}
# TIP #285: Script cancellation support.
declare 250 {
void TclSetChildCancelFlags(Tcl_Interp *interp, int flags, int force)
}
# Allow extensions for optimization
declare 251 {
| > | | 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
}
# TIP #285: Script cancellation support.
declare 250 {
void TclSetChildCancelFlags(Tcl_Interp *interp, int flags, int force)
}
# Allow extensions for optimization
# Do NOT change width of the size. TclEmitPush cannot handle it
declare 251 {
int TclRegisterLiteral(void *envPtr,
const char *bytes, Tcl_Size length, int flags)
}
# Exporting of the internal API to variables.
declare 252 {
Tcl_Obj *TclPtrGetVar(Tcl_Interp *interp, Tcl_Var varPtr,
|
| ︙ | ︙ |
Changes to generic/tclInt.h.
| ︙ | ︙ | |||
104 105 106 107 108 109 110 | # endif #endif /* * Maximum *signed* value that can be stored in a Tcl_Size type. This is * primarily used for checking overflows in dynamically allocating memory. */ | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | # endif #endif /* * Maximum *signed* value that can be stored in a Tcl_Size type. This is * primarily used for checking overflows in dynamically allocating memory. */ #define TCL_SIZE_SMAX ((((Tcl_Size) 1) << ((8*(Tcl_Size)sizeof(Tcl_Size)) - 1)) - 1) /* * Macros used to cast between pointers and integers (e.g. when storing an int * in ClientData), on 64-bit architectures they avoid gcc warning about "cast * to/from pointer from/to integer of different size". */ |
| ︙ | ︙ | |||
127 128 129 130 131 132 133 134 135 136 137 138 139 140 | #endif #if !defined(PTR2UINT) # define PTR2UINT(p) ((size_t)(p)) #endif #if defined(_WIN32) && defined(_MSC_VER) # define vsnprintf _vsnprintf #endif #if !defined(TCL_THREADS) # define TCL_THREADS 1 #endif #if !TCL_THREADS # undef TCL_DECLARE_MUTEX | > | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | #endif #if !defined(PTR2UINT) # define PTR2UINT(p) ((size_t)(p)) #endif #if defined(_WIN32) && defined(_MSC_VER) # define vsnprintf _vsnprintf # define snprintf _snprintf #endif #if !defined(TCL_THREADS) # define TCL_THREADS 1 #endif #if !TCL_THREADS # undef TCL_DECLARE_MUTEX |
| ︙ | ︙ | |||
217 218 219 220 221 222 223 | *---------------------------------------------------------------- */ typedef struct Tcl_Ensemble Tcl_Ensemble; typedef struct NamespacePathEntry NamespacePathEntry; /* | | | | | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
*----------------------------------------------------------------
*/
typedef struct Tcl_Ensemble Tcl_Ensemble;
typedef struct NamespacePathEntry NamespacePathEntry;
/*
* Special hashtable for variables: This is just a Tcl_HashTable with nsPtr
* and arrayPtr fields added at the end so that variables can find their
* namespace and possibly containing array without having to copy a pointer in
* their struct by accessing them via their hPtr->tablePtr.
*/
typedef struct TclVarHashTable {
Tcl_HashTable table;
struct Namespace *nsPtr;
#if TCL_MAJOR_VERSION > 8
struct Var *arrayPtr;
|
| ︙ | ︙ | |||
474 475 476 477 478 479 480 |
struct EnsembleConfig *next;/* The next ensemble in the linked list of
* ensembles associated with a namespace. If
* this field points to this ensemble, the
* structure has already been unlinked from
* all lists, and cannot be found by scanning
* the list from the namespace's ensemble
* field. */
| | | 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
struct EnsembleConfig *next;/* The next ensemble in the linked list of
* ensembles associated with a namespace. If
* this field points to this ensemble, the
* structure has already been unlinked from
* all lists, and cannot be found by scanning
* the list from the namespace's ensemble
* field. */
int flags; /* OR'ed combo of TCL_ENSEMBLE_PREFIX,
* ENSEMBLE_DEAD and ENSEMBLE_COMPILE. */
/* OBJECT FIELDS FOR ENSEMBLE CONFIGURATION */
Tcl_Obj *subcommandDict; /* Dictionary providing mapping from
* subcommands to their implementing command
* prefixes, or NULL if we are to build the
|
| ︙ | ︙ | |||
501 502 503 504 505 506 507 | * NULL to use the default error-generating * behaviour. The script execution gets all * the arguments to the ensemble command * (including objv[0]) and will have the * results passed directly back to the caller * (including the error code) unless the code * is TCL_CONTINUE in which case the | | | 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
* NULL to use the default error-generating
* behaviour. The script execution gets all
* the arguments to the ensemble command
* (including objv[0]) and will have the
* results passed directly back to the caller
* (including the error code) unless the code
* is TCL_CONTINUE in which case the
* subcommand will be re-parsed by the ensemble
* core, presumably because the ensemble
* itself has been updated. */
Tcl_Obj *parameterList; /* List of ensemble parameter names. */
Tcl_Size numParameters; /* Cached number of parameters. This is either
* 0 (if the parameterList field is NULL) or
* the length of the list in the parameterList
* field. */
|
| ︙ | ︙ | |||
645 646 647 648 649 650 651 |
* trace active on variable, and 1 if the
* variable is a namespace variable. This
* record can't be deleted until refCount
* becomes 0. */
Tcl_HashEntry entry; /* The hash table entry that refers to this
* variable. This is used to find the name of
* the variable and to delete it from its
| | | | | | | 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 |
* trace active on variable, and 1 if the
* variable is a namespace variable. This
* record can't be deleted until refCount
* becomes 0. */
Tcl_HashEntry entry; /* The hash table entry that refers to this
* variable. This is used to find the name of
* the variable and to delete it from its
* hash table if it is no longer needed. It
* also holds the variable's name. */
} VarInHash;
/*
* Flag bits for variables. The first two (VAR_ARRAY and VAR_LINK) are
* mutually exclusive and give the "type" of the variable. If none is set,
* this is a scalar variable.
*
* VAR_ARRAY - 1 means this is an array variable rather than
* a scalar variable or link. The "tablePtr"
* field points to the array's hash table for its
* elements.
* VAR_LINK - 1 means this Var structure contains a pointer
* to another Var structure that either has the
* real value or is itself another VAR_LINK
* pointer. Variables like this come about
* through "upvar" and "global" commands, or
* through references to variables in enclosing
* namespaces.
*
* Flags that indicate the type and status of storage; none is set for
* compiled local variables (Var structs).
*
* VAR_IN_HASHTABLE - 1 means this variable is in a hash table and
* the Var structure is malloc'ed. 0 if it is a
* local variable that was assigned a slot in a
* procedure frame by the compiler so the Var
* storage is part of the call frame.
* VAR_DEAD_HASH 1 means that this var's entry in the hash table
* has already been deleted.
* VAR_ARRAY_ELEMENT - 1 means that this variable is an array
* element, so it is not legal for it to be an
* array itself (the VAR_ARRAY flag had better
* not be set).
* VAR_NAMESPACE_VAR - 1 means that this variable was declared as a
* namespace variable. This flag ensures it
|
| ︙ | ︙ | |||
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | * - passed to Tcl_CreateObjTrace to set up * "leavestep" traces. */ #define TCL_TRACE_ENTER_EXEC 1 #define TCL_TRACE_LEAVE_EXEC 2 #define ABSTRACTLIST_PROC(objPtr, proc) (((objPtr)->typePtr \ && ((offsetof(Tcl_ObjType, proc) < offsetof(Tcl_ObjType, version)) \ || ((objPtr)->typePtr->version > offsetof(Tcl_ObjType, proc)))) ? \ ((objPtr)->typePtr)->proc : NULL) | > > > > > > > > | | 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 |
* - passed to Tcl_CreateObjTrace to set up
* "leavestep" traces.
*/
#define TCL_TRACE_ENTER_EXEC 1
#define TCL_TRACE_LEAVE_EXEC 2
typedef struct { /* For internal core use only */
Tcl_ObjType objType;
struct {
Tcl_Size (*lengthProc)(Tcl_Obj *obj);
} abstractList;
} TclObjTypeWithAbstractList;
#define TCL_OBJTYPE_V0_1(lengthProc) (sizeof(TclObjTypeWithAbstractList)) \
}, {lengthProc /* For internal core use only */
#define ABSTRACTLIST_PROC(objPtr, proc) (((objPtr)->typePtr \
&& ((offsetof(Tcl_ObjType, proc) < offsetof(Tcl_ObjType, version)) \
|| ((objPtr)->typePtr->version > offsetof(Tcl_ObjType, proc)))) ? \
((objPtr)->typePtr)->proc : NULL)
MODULE_SCOPE Tcl_Size TclLengthOne(Tcl_Obj *);
/*
* Abstract List
*
* This structure provides the functions used in List operations to emulate a
* List for AbstractList types.
|
| ︙ | ︙ | |||
1341 1342 1343 1344 1345 1346 1347 |
Tcl_Size pc; /* Instruction pointer of a command in
* ExtCmdLoc.loc[.] */
Tcl_Size word; /* Index of word in
* ExtCmdLoc.loc[cmd]->line[.] */
struct CFWordBC *prevPtr; /* Previous entry in stack for same Tcl_Obj. */
struct CFWordBC *nextPtr; /* Next entry for same command call. See
* CmdFrame litarg field for the list start. */
| | | | 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 |
Tcl_Size pc; /* Instruction pointer of a command in
* ExtCmdLoc.loc[.] */
Tcl_Size word; /* Index of word in
* ExtCmdLoc.loc[cmd]->line[.] */
struct CFWordBC *prevPtr; /* Previous entry in stack for same Tcl_Obj. */
struct CFWordBC *nextPtr; /* Next entry for same command call. See
* CmdFrame litarg field for the list start. */
Tcl_Obj *obj; /* Back reference to hash table key */
} CFWordBC;
/*
* Structure to record the locations of invisible continuation lines in
* literal scripts, as character offset from the beginning of the script. Both
* compiler and direct evaluator use this information to adjust their line
* counters when tracking through the script, because when it is invoked the
* continuation line marker as a whole has been removed already, meaning that
* the \n which was part of it is gone as well, breaking regular line
* tracking.
*
* These structures are allocated and filled by both the function
* TclSubstTokens() in the file "tclParse.c" and its caller TclEvalEx() in the
* file "tclBasic.c", and stored in the thread-global hash table "lineCLPtr" in
* file "tclObj.c". They are used by the functions TclSetByteCodeFromAny() and
* TclCompileScript(), both found in the file "tclCompile.c". Their memory is
* released by the function TclFreeObj(), in the file "tclObj.c", and also by
* the function TclThreadFinalizeObjects(), in the same file.
*/
#define CLL_END (-1)
|
| ︙ | ︙ | |||
2525 2526 2527 2528 2529 2530 2531 |
#define LISTSTORE_CANONICAL 0x1 /* All Tcl_Obj's referencing this
store have their string representation
derived from the list representation */
/* Max number of elements that can be contained in a list */
#define LIST_MAX \
| | < | | | 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 |
#define LISTSTORE_CANONICAL 0x1 /* All Tcl_Obj's referencing this
store have their string representation
derived from the list representation */
/* Max number of elements that can be contained in a list */
#define LIST_MAX \
((Tcl_Size)((ListSizeT_MAX - offsetof(ListStore, slots)) / sizeof(Tcl_Obj *)))
/* Memory size needed for a ListStore to hold numSlots_ elements */
#define LIST_SIZE(numSlots_) \
((Tcl_Size)(offsetof(ListStore, slots) + ((numSlots_) * sizeof(Tcl_Obj *))))
/*
* ListSpan --
* See comments above for ListStore
*/
typedef struct ListSpan {
Tcl_Size spanStart; /* Starting index of the span */
Tcl_Size spanLength; /* Number of elements in the span */
Tcl_Size refCount; /* Count of references to this span record */
} ListSpan;
#ifndef LIST_SPAN_THRESHOLD /* May be set on build line */
#define LIST_SPAN_THRESHOLD 101
#endif
/*
* ListRep --
|
| ︙ | ︙ | |||
2724 2725 2726 2727 2728 2729 2730 |
(((objPtr)->typePtr == &tclIntType \
&& (objPtr)->internalRep.wideValue >= (Tcl_WideInt)(INT_MIN) \
&& (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(INT_MAX)) \
? ((*(intPtr) = (int)(objPtr)->internalRep.wideValue), TCL_OK) \
: Tcl_GetIntFromObj((interp), (objPtr), (intPtr)))
#define TclGetIntForIndexM(interp, objPtr, endValue, idxPtr) \
((((objPtr)->typePtr == &tclIntType) && ((objPtr)->internalRep.wideValue >= 0) \
| | | 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 |
(((objPtr)->typePtr == &tclIntType \
&& (objPtr)->internalRep.wideValue >= (Tcl_WideInt)(INT_MIN) \
&& (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(INT_MAX)) \
? ((*(intPtr) = (int)(objPtr)->internalRep.wideValue), TCL_OK) \
: Tcl_GetIntFromObj((interp), (objPtr), (intPtr)))
#define TclGetIntForIndexM(interp, objPtr, endValue, idxPtr) \
((((objPtr)->typePtr == &tclIntType) && ((objPtr)->internalRep.wideValue >= 0) \
&& ((objPtr)->internalRep.wideValue <= endValue)) \
? ((*(idxPtr) = (objPtr)->internalRep.wideValue), TCL_OK) \
: Tcl_GetIntForIndex((interp), (objPtr), (endValue), (idxPtr)))
/*
* Macro used to save a function call for common uses of
* Tcl_GetWideIntFromObj(). The ANSI C "prototype" is:
*
|
| ︙ | ︙ | |||
3077 3078 3079 3080 3081 3082 3083 | *---------------------------------------------------------------- * Procedures shared among Tcl modules but not used by the outside world: *---------------------------------------------------------------- */ #if TCL_MAJOR_VERSION > 8 MODULE_SCOPE void TclAppendBytesToByteArray(Tcl_Obj *objPtr, | | | | | | | | | | | | | 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 | *---------------------------------------------------------------- * Procedures shared among Tcl modules but not used by the outside world: *---------------------------------------------------------------- */ #if TCL_MAJOR_VERSION > 8 MODULE_SCOPE void TclAppendBytesToByteArray(Tcl_Obj *objPtr, const unsigned char *bytes, Tcl_Size len); MODULE_SCOPE int TclNREvalCmd(Tcl_Interp *interp, Tcl_Obj *objPtr, int flags); MODULE_SCOPE void TclAdvanceContinuations(Tcl_Size *line, int **next, int loc); MODULE_SCOPE void TclAdvanceLines(Tcl_Size *line, const char *start, const char *end); MODULE_SCOPE void TclArgumentEnter(Tcl_Interp *interp, Tcl_Obj *objv[], int objc, CmdFrame *cf); MODULE_SCOPE void TclArgumentRelease(Tcl_Interp *interp, Tcl_Obj *objv[], int objc); MODULE_SCOPE void TclArgumentBCEnter(Tcl_Interp *interp, Tcl_Obj *objv[], int objc, void *codePtr, CmdFrame *cfPtr, int cmd, Tcl_Size pc); MODULE_SCOPE void TclArgumentBCRelease(Tcl_Interp *interp, CmdFrame *cfPtr); MODULE_SCOPE void TclArgumentGet(Tcl_Interp *interp, Tcl_Obj *obj, CmdFrame **cfPtrPtr, int *wordPtr); MODULE_SCOPE int TclAsyncNotifier(int sigNumber, Tcl_ThreadId threadId, void *clientData, int *flagPtr, int value); MODULE_SCOPE void TclAsyncMarkFromNotifier(void); MODULE_SCOPE double TclBignumToDouble(const void *bignum); MODULE_SCOPE int TclByteArrayMatch(const unsigned char *string, Tcl_Size strLen, const unsigned char *pattern, Tcl_Size ptnLen, int flags); MODULE_SCOPE double TclCeil(const void *a); MODULE_SCOPE void TclChannelPreserve(Tcl_Channel chan); MODULE_SCOPE void TclChannelRelease(Tcl_Channel chan); MODULE_SCOPE int TclCheckArrayTraces(Tcl_Interp *interp, Var *varPtr, Var *arrayPtr, Tcl_Obj *name, int index); MODULE_SCOPE int TclCheckEmptyString(Tcl_Obj *objPtr); MODULE_SCOPE int TclChanCaughtErrorBypass(Tcl_Interp *interp, Tcl_Channel chan); MODULE_SCOPE Tcl_ObjCmdProc TclChannelNamesCmd; MODULE_SCOPE Tcl_NRPostProc TclClearRootEnsemble; MODULE_SCOPE int TclCompareTwoNumbers(Tcl_Obj *valuePtr, Tcl_Obj *value2Ptr); MODULE_SCOPE ContLineLoc *TclContinuationsEnter(Tcl_Obj *objPtr, Tcl_Size num, int *loc); MODULE_SCOPE void TclContinuationsEnterDerived(Tcl_Obj *objPtr, int start, int *clNext); MODULE_SCOPE ContLineLoc *TclContinuationsGet(Tcl_Obj *objPtr); MODULE_SCOPE void TclContinuationsCopy(Tcl_Obj *objPtr, Tcl_Obj *originObjPtr); MODULE_SCOPE Tcl_Size TclConvertElement(const char *src, Tcl_Size length, char *dst, int flags); MODULE_SCOPE Tcl_Command TclCreateObjCommandInNs(Tcl_Interp *interp, const char *cmdName, Tcl_Namespace *nsPtr, Tcl_ObjCmdProc *proc, void *clientData, Tcl_CmdDeleteProc *deleteProc); MODULE_SCOPE Tcl_Command TclCreateEnsembleInNs(Tcl_Interp *interp, const char *name, Tcl_Namespace *nameNamespacePtr, Tcl_Namespace *ensembleNamespacePtr, int flags); MODULE_SCOPE void TclDeleteNamespaceVars(Namespace *nsPtr); MODULE_SCOPE void TclDeleteNamespaceChildren(Namespace *nsPtr); MODULE_SCOPE int TclFindDictElement(Tcl_Interp *interp, const char *dict, Tcl_Size dictLength, const char **elementPtr, const char **nextPtr, Tcl_Size *sizePtr, int *literalPtr); /* TIP #280 - Modified token based evaluation, with line information. */ MODULE_SCOPE int TclEvalEx(Tcl_Interp *interp, const char *script, Tcl_Size numBytes, int flags, Tcl_Size line, int *clNextOuter, const char *outerScript); MODULE_SCOPE Tcl_ObjCmdProc TclFileAttrsCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileCopyCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileDeleteCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileLinkCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileMakeDirsCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileReadLinkCmd; |
| ︙ | ︙ | |||
3160 3161 3162 3163 3164 3165 3166 | MODULE_SCOPE void TclDeleteLateExitHandler(Tcl_ExitProc *proc, void *clientData); MODULE_SCOPE char * TclDStringAppendObj(Tcl_DString *dsPtr, Tcl_Obj *objPtr); MODULE_SCOPE char * TclDStringAppendDString(Tcl_DString *dsPtr, Tcl_DString *toAppendPtr); MODULE_SCOPE Tcl_Obj *const *TclFetchEnsembleRoot(Tcl_Interp *interp, | | | 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 | MODULE_SCOPE void TclDeleteLateExitHandler(Tcl_ExitProc *proc, void *clientData); MODULE_SCOPE char * TclDStringAppendObj(Tcl_DString *dsPtr, Tcl_Obj *objPtr); MODULE_SCOPE char * TclDStringAppendDString(Tcl_DString *dsPtr, Tcl_DString *toAppendPtr); MODULE_SCOPE Tcl_Obj *const *TclFetchEnsembleRoot(Tcl_Interp *interp, Tcl_Obj *const *objv, Tcl_Size objc, Tcl_Size *objcPtr); MODULE_SCOPE Tcl_Obj *const *TclEnsembleGetRewriteValues(Tcl_Interp *interp); MODULE_SCOPE Tcl_Namespace *TclEnsureNamespace(Tcl_Interp *interp, Tcl_Namespace *namespacePtr); MODULE_SCOPE void TclFinalizeAllocSubsystem(void); MODULE_SCOPE void TclFinalizeAsync(void); MODULE_SCOPE void TclFinalizeDoubleConversion(void); MODULE_SCOPE void TclFinalizeEncodingSubsystem(void); |
| ︙ | ︙ | |||
3214 3215 3216 3217 3218 3219 3220 | MODULE_SCOPE int TclGetOpenModeEx(Tcl_Interp *interp, const char *modeString, int *seekFlagPtr, int *binaryPtr); MODULE_SCOPE Tcl_Obj * TclGetProcessGlobalValue(ProcessGlobalValue *pgvPtr); MODULE_SCOPE Tcl_Obj * TclGetSourceFromFrame(CmdFrame *cfPtr, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE char * TclGetStringStorage(Tcl_Obj *objPtr, | | | 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 | MODULE_SCOPE int TclGetOpenModeEx(Tcl_Interp *interp, const char *modeString, int *seekFlagPtr, int *binaryPtr); MODULE_SCOPE Tcl_Obj * TclGetProcessGlobalValue(ProcessGlobalValue *pgvPtr); MODULE_SCOPE Tcl_Obj * TclGetSourceFromFrame(CmdFrame *cfPtr, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE char * TclGetStringStorage(Tcl_Obj *objPtr, Tcl_Size *sizePtr); MODULE_SCOPE int TclGetLoadedLibraries(Tcl_Interp *interp, const char *targetName, const char *packageName); MODULE_SCOPE int TclGetWideBitsFromObj(Tcl_Interp *, Tcl_Obj *, Tcl_WideInt *); MODULE_SCOPE int TclIncrObj(Tcl_Interp *interp, Tcl_Obj *valuePtr, Tcl_Obj *incrPtr); |
| ︙ | ︙ | |||
3244 3245 3246 3247 3248 3249 3250 | MODULE_SCOPE void TclInitLimitSupport(Tcl_Interp *interp); MODULE_SCOPE void TclInitNamespaceSubsystem(void); MODULE_SCOPE void TclInitNotifier(void); MODULE_SCOPE void TclInitObjSubsystem(void); MODULE_SCOPE int TclInterpReady(Tcl_Interp *interp); MODULE_SCOPE int TclIsDigitProc(int byte); MODULE_SCOPE int TclIsBareword(int byte); | | | | | | | | | | | | | | | | 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 |
MODULE_SCOPE void TclInitLimitSupport(Tcl_Interp *interp);
MODULE_SCOPE void TclInitNamespaceSubsystem(void);
MODULE_SCOPE void TclInitNotifier(void);
MODULE_SCOPE void TclInitObjSubsystem(void);
MODULE_SCOPE int TclInterpReady(Tcl_Interp *interp);
MODULE_SCOPE int TclIsDigitProc(int byte);
MODULE_SCOPE int TclIsBareword(int byte);
MODULE_SCOPE Tcl_Obj * TclJoinPath(Tcl_Size elements, Tcl_Obj * const objv[],
int forceRelative);
MODULE_SCOPE int MakeTildeRelativePath(Tcl_Interp *interp, const char *user,
const char *subPath, Tcl_DString *dsPtr);
MODULE_SCOPE Tcl_Obj * TclGetHomeDirObj(Tcl_Interp *interp, const char *user);
MODULE_SCOPE Tcl_Obj * TclResolveTildePath(Tcl_Interp *interp,
Tcl_Obj *pathObj);
MODULE_SCOPE Tcl_Obj * TclResolveTildePathList(Tcl_Obj *pathsObj);
MODULE_SCOPE int TclJoinThread(Tcl_ThreadId id, int *result);
MODULE_SCOPE void TclLimitRemoveAllHandlers(Tcl_Interp *interp);
MODULE_SCOPE Tcl_Obj * TclLindexList(Tcl_Interp *interp,
Tcl_Obj *listPtr, Tcl_Obj *argPtr);
MODULE_SCOPE Tcl_Obj * TclLindexFlat(Tcl_Interp *interp, Tcl_Obj *listPtr,
Tcl_Size indexCount, Tcl_Obj *const indexArray[]);
/* TIP #280 */
MODULE_SCOPE void TclListLines(Tcl_Obj *listObj, Tcl_Size line, int n,
int *lines, Tcl_Obj *const *elems);
MODULE_SCOPE Tcl_Obj * TclListObjCopy(Tcl_Interp *interp, Tcl_Obj *listPtr);
MODULE_SCOPE int TclListObjAppendElements(Tcl_Interp *interp,
Tcl_Obj *toObj, Tcl_Size elemCount,
Tcl_Obj *const elemObjv[]);
MODULE_SCOPE Tcl_Obj * TclListObjRange(Tcl_Interp *interp, Tcl_Obj *listPtr,
Tcl_Size fromIdx, Tcl_Size toIdx);
MODULE_SCOPE Tcl_Obj * TclLsetList(Tcl_Interp *interp, Tcl_Obj *listPtr,
Tcl_Obj *indexPtr, Tcl_Obj *valuePtr);
MODULE_SCOPE Tcl_Obj * TclLsetFlat(Tcl_Interp *interp, Tcl_Obj *listPtr,
Tcl_Size indexCount, Tcl_Obj *const indexArray[],
Tcl_Obj *valuePtr);
MODULE_SCOPE Tcl_Command TclMakeEnsemble(Tcl_Interp *interp, const char *name,
const EnsembleImplMap map[]);
MODULE_SCOPE int TclMakeSafe(Tcl_Interp *interp);
MODULE_SCOPE Tcl_Size TclMaxListLength(const char *bytes, Tcl_Size numBytes,
const char **endPtr);
MODULE_SCOPE int TclMergeReturnOptions(Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[], Tcl_Obj **optionsPtrPtr,
int *codePtr, int *levelPtr);
MODULE_SCOPE Tcl_Obj * TclNoErrorStack(Tcl_Interp *interp, Tcl_Obj *options);
MODULE_SCOPE int TclNokia770Doubles(void);
MODULE_SCOPE void TclNsDecrRefCount(Namespace *nsPtr);
MODULE_SCOPE int TclNamespaceDeleted(Namespace *nsPtr);
MODULE_SCOPE void TclObjVarErrMsg(Tcl_Interp *interp, Tcl_Obj *part1Ptr,
Tcl_Obj *part2Ptr, const char *operation,
const char *reason, int index);
MODULE_SCOPE int TclObjInvokeNamespace(Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[],
Tcl_Namespace *nsPtr, int flags);
MODULE_SCOPE int TclObjUnsetVar2(Tcl_Interp *interp,
Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags);
MODULE_SCOPE int TclParseBackslash(const char *src,
Tcl_Size numBytes, Tcl_Size *readPtr, char *dst);
MODULE_SCOPE int TclParseHex(const char *src, Tcl_Size numBytes,
int *resultPtr);
MODULE_SCOPE int TclParseNumber(Tcl_Interp *interp, Tcl_Obj *objPtr,
const char *expected, const char *bytes,
Tcl_Size numBytes, const char **endPtrPtr, int flags);
MODULE_SCOPE void TclParseInit(Tcl_Interp *interp, const char *string,
Tcl_Size numBytes, Tcl_Parse *parsePtr);
MODULE_SCOPE Tcl_Size TclParseAllWhiteSpace(const char *src, Tcl_Size numBytes);
MODULE_SCOPE int TclProcessReturn(Tcl_Interp *interp,
int code, int level, Tcl_Obj *returnOpts);
MODULE_SCOPE int TclpObjLstat(Tcl_Obj *pathPtr, Tcl_StatBuf *buf);
MODULE_SCOPE Tcl_Obj * TclpTempFileName(void);
MODULE_SCOPE Tcl_Obj * TclpTempFileNameForLibrary(Tcl_Interp *interp,
Tcl_Obj* pathPtr);
MODULE_SCOPE int TclNewArithSeriesObj(Tcl_Interp *interp, Tcl_Obj **arithSeriesPtr,
int useDoubles, Tcl_Obj *startObj, Tcl_Obj *endObj,
Tcl_Obj *stepObj, Tcl_Obj *lenObj);
MODULE_SCOPE Tcl_Obj * TclNewFSPathObj(Tcl_Obj *dirPtr, const char *addStrRep,
Tcl_Size len);
MODULE_SCOPE void TclpAlertNotifier(void *clientData);
MODULE_SCOPE void *TclpNotifierData(void);
MODULE_SCOPE void TclpServiceModeHook(int mode);
MODULE_SCOPE void TclpSetTimer(const Tcl_Time *timePtr);
MODULE_SCOPE int TclpWaitForEvent(const Tcl_Time *timePtr);
MODULE_SCOPE void TclpCreateFileHandler(int fd, int mask,
Tcl_FileProc *proc, void *clientData);
|
| ︙ | ︙ | |||
3339 3340 3341 3342 3343 3344 3345 | MODULE_SCOPE int TclCreateSocketAddress(Tcl_Interp *interp, struct addrinfo **addrlist, const char *host, int port, int willBind, const char **errorMsgPtr); MODULE_SCOPE int TclpThreadCreate(Tcl_ThreadId *idPtr, Tcl_ThreadCreateProc *proc, void *clientData, size_t stackSize, int flags); | | | | | 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 | MODULE_SCOPE int TclCreateSocketAddress(Tcl_Interp *interp, struct addrinfo **addrlist, const char *host, int port, int willBind, const char **errorMsgPtr); MODULE_SCOPE int TclpThreadCreate(Tcl_ThreadId *idPtr, Tcl_ThreadCreateProc *proc, void *clientData, size_t stackSize, int flags); MODULE_SCOPE Tcl_Size TclpFindVariable(const char *name, Tcl_Size *lengthPtr); MODULE_SCOPE void TclpInitLibraryPath(char **valuePtr, TCL_HASH_TYPE *lengthPtr, Tcl_Encoding *encodingPtr); MODULE_SCOPE void TclpInitLock(void); MODULE_SCOPE void *TclpInitNotifier(void); MODULE_SCOPE void TclpInitPlatform(void); MODULE_SCOPE void TclpInitUnlock(void); MODULE_SCOPE Tcl_Obj * TclpObjListVolumes(void); MODULE_SCOPE void TclpGlobalLock(void); MODULE_SCOPE void TclpGlobalUnlock(void); MODULE_SCOPE int TclpMatchFiles(Tcl_Interp *interp, char *separators, Tcl_DString *dirPtr, char *pattern, char *tail); MODULE_SCOPE int TclpObjNormalizePath(Tcl_Interp *interp, Tcl_Obj *pathPtr, int nextCheckpoint); MODULE_SCOPE void TclpNativeJoinPath(Tcl_Obj *prefix, const char *joining); MODULE_SCOPE Tcl_Obj * TclpNativeSplitPath(Tcl_Obj *pathPtr, Tcl_Size *lenPtr); MODULE_SCOPE Tcl_PathType TclpGetNativePathType(Tcl_Obj *pathPtr, Tcl_Size *driveNameLengthPtr, Tcl_Obj **driveNameRef); MODULE_SCOPE int TclCrossFilesystemCopy(Tcl_Interp *interp, Tcl_Obj *source, Tcl_Obj *target); MODULE_SCOPE int TclpMatchInDirectory(Tcl_Interp *interp, Tcl_Obj *resultPtr, Tcl_Obj *pathPtr, const char *pattern, Tcl_GlobTypeData *types); MODULE_SCOPE void *TclpGetNativeCwd(void *clientData); MODULE_SCOPE Tcl_FSDupInternalRepProc TclNativeDupInternalRep; |
| ︙ | ︙ | |||
3387 3388 3389 3390 3391 3392 3393 | void *data); MODULE_SCOPE TCL_NORETURN void TclpThreadExit(int status); MODULE_SCOPE void TclRememberCondition(Tcl_Condition *mutex); MODULE_SCOPE void TclRememberJoinableThread(Tcl_ThreadId id); MODULE_SCOPE void TclRememberMutex(Tcl_Mutex *mutex); MODULE_SCOPE void TclRemoveScriptLimitCallbacks(Tcl_Interp *interp); MODULE_SCOPE int TclReToGlob(Tcl_Interp *interp, const char *reStr, | | | | | | | | | | | | | | | | | | | | 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 |
void *data);
MODULE_SCOPE TCL_NORETURN void TclpThreadExit(int status);
MODULE_SCOPE void TclRememberCondition(Tcl_Condition *mutex);
MODULE_SCOPE void TclRememberJoinableThread(Tcl_ThreadId id);
MODULE_SCOPE void TclRememberMutex(Tcl_Mutex *mutex);
MODULE_SCOPE void TclRemoveScriptLimitCallbacks(Tcl_Interp *interp);
MODULE_SCOPE int TclReToGlob(Tcl_Interp *interp, const char *reStr,
Tcl_Size reStrLen, Tcl_DString *dsPtr, int *flagsPtr,
int *quantifiersFoundPtr);
MODULE_SCOPE Tcl_Size TclScanElement(const char *string, Tcl_Size length,
char *flagPtr);
MODULE_SCOPE void TclSetBgErrorHandler(Tcl_Interp *interp,
Tcl_Obj *cmdPrefix);
MODULE_SCOPE void TclSetBignumInternalRep(Tcl_Obj *objPtr,
void *bignumValue);
MODULE_SCOPE int TclSetBooleanFromAny(Tcl_Interp *interp,
Tcl_Obj *objPtr);
MODULE_SCOPE void TclSetCmdNameObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
Command *cmdPtr);
MODULE_SCOPE void TclSetDuplicateObj(Tcl_Obj *dupPtr, Tcl_Obj *objPtr);
MODULE_SCOPE void TclSetProcessGlobalValue(ProcessGlobalValue *pgvPtr,
Tcl_Obj *newValue, Tcl_Encoding encoding);
MODULE_SCOPE void TclSignalExitThread(Tcl_ThreadId id, int result);
MODULE_SCOPE void TclSpellFix(Tcl_Interp *interp,
Tcl_Obj *const *objv, Tcl_Size objc, Tcl_Size subIdx,
Tcl_Obj *bad, Tcl_Obj *fix);
MODULE_SCOPE void * TclStackRealloc(Tcl_Interp *interp, void *ptr,
Tcl_Size numBytes);
typedef int (*memCmpFn_t)(const void*, const void*, size_t);
MODULE_SCOPE int TclStringCmp(Tcl_Obj *value1Ptr, Tcl_Obj *value2Ptr,
int checkEq, int nocase, Tcl_Size reqlength);
MODULE_SCOPE int TclStringCmpOpts(Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[], int *nocase,
Tcl_Size *reqlength);
MODULE_SCOPE int TclStringMatch(const char *str, Tcl_Size strLen,
const char *pattern, int ptnLen, int flags);
MODULE_SCOPE int TclStringMatchObj(Tcl_Obj *stringObj,
Tcl_Obj *patternObj, int flags);
MODULE_SCOPE void TclSubstCompile(Tcl_Interp *interp, const char *bytes,
Tcl_Size numBytes, int flags, Tcl_Size line,
struct CompileEnv *envPtr);
MODULE_SCOPE int TclSubstOptions(Tcl_Interp *interp, Tcl_Size numOpts,
Tcl_Obj *const opts[], int *flagPtr);
MODULE_SCOPE void TclSubstParse(Tcl_Interp *interp, const char *bytes,
Tcl_Size numBytes, int flags, Tcl_Parse *parsePtr,
Tcl_InterpState *statePtr);
MODULE_SCOPE int TclSubstTokens(Tcl_Interp *interp, Tcl_Token *tokenPtr,
Tcl_Size count, int *tokensLeftPtr, Tcl_Size line,
int *clNextOuter, const char *outerScript);
MODULE_SCOPE Tcl_Size TclTrim(const char *bytes, Tcl_Size numBytes,
const char *trim, Tcl_Size numTrim, Tcl_Size *trimRight);
MODULE_SCOPE Tcl_Size TclTrimLeft(const char *bytes, Tcl_Size numBytes,
const char *trim, Tcl_Size numTrim);
MODULE_SCOPE Tcl_Size TclTrimRight(const char *bytes, Tcl_Size numBytes,
const char *trim, Tcl_Size numTrim);
MODULE_SCOPE const char*TclGetCommandTypeName(Tcl_Command command);
MODULE_SCOPE void TclRegisterCommandTypeName(
Tcl_ObjCmdProc *implementationProc,
const char *nameStr);
MODULE_SCOPE int TclUtfCmp(const char *cs, const char *ct);
MODULE_SCOPE int TclUtfCasecmp(const char *cs, const char *ct);
MODULE_SCOPE int TclUtfCount(int ch);
#if TCL_UTF_MAX > 3
# define TclUtfToUCS4 Tcl_UtfToUniChar
# define TclUniCharToUCS4(src, ptr) (*ptr = *(src),1)
# define TclUCS4Prev(src, ptr) (((src) > (ptr)) ? ((src) - 1) : (src))
#else
MODULE_SCOPE int TclUtfToUCS4(const char *, int *);
MODULE_SCOPE int TclUniCharToUCS4(const Tcl_UniChar *, int *);
|
| ︙ | ︙ | |||
3488 3489 3490 3491 3492 3493 3494 | MODULE_SCOPE int TclZlibInit(Tcl_Interp *interp); MODULE_SCOPE void * TclpThreadCreateKey(void); MODULE_SCOPE void TclpThreadDeleteKey(void *keyPtr); MODULE_SCOPE void TclpThreadSetGlobalTSD(void *tsdKeyPtr, void *ptr); MODULE_SCOPE void * TclpThreadGetGlobalTSD(void *tsdKeyPtr); MODULE_SCOPE void TclErrorStackResetIf(Tcl_Interp *interp, | | | 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 | MODULE_SCOPE int TclZlibInit(Tcl_Interp *interp); MODULE_SCOPE void * TclpThreadCreateKey(void); MODULE_SCOPE void TclpThreadDeleteKey(void *keyPtr); MODULE_SCOPE void TclpThreadSetGlobalTSD(void *tsdKeyPtr, void *ptr); MODULE_SCOPE void * TclpThreadGetGlobalTSD(void *tsdKeyPtr); MODULE_SCOPE void TclErrorStackResetIf(Tcl_Interp *interp, const char *msg, Tcl_Size length); /* Tip 430 */ MODULE_SCOPE int TclZipfs_Init(Tcl_Interp *interp); /* * Many parsing tasks need a common definition of whitespace. * Use this routine and macro to achieve that and place |
| ︙ | ︙ | |||
3537 3538 3539 3540 3541 3542 3543 | MODULE_SCOPE Tcl_ObjCmdProc TclDefaultBgErrorHandlerObjCmd; MODULE_SCOPE Tcl_Command TclInitDictCmd(Tcl_Interp *interp); MODULE_SCOPE int TclDictWithFinish(Tcl_Interp *interp, Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int index, int pathc, Tcl_Obj *const pathv[], Tcl_Obj *keysPtr); MODULE_SCOPE Tcl_Obj * TclDictWithInit(Tcl_Interp *interp, Tcl_Obj *dictPtr, | | | 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 | MODULE_SCOPE Tcl_ObjCmdProc TclDefaultBgErrorHandlerObjCmd; MODULE_SCOPE Tcl_Command TclInitDictCmd(Tcl_Interp *interp); MODULE_SCOPE int TclDictWithFinish(Tcl_Interp *interp, Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int index, int pathc, Tcl_Obj *const pathv[], Tcl_Obj *keysPtr); MODULE_SCOPE Tcl_Obj * TclDictWithInit(Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_Size pathc, Tcl_Obj *const pathv[]); MODULE_SCOPE Tcl_ObjCmdProc Tcl_DisassembleObjCmd; /* Assemble command function */ MODULE_SCOPE Tcl_ObjCmdProc Tcl_AssembleObjCmd; MODULE_SCOPE Tcl_ObjCmdProc TclNRAssembleObjCmd; MODULE_SCOPE Tcl_Command TclInitEncodingCmd(Tcl_Interp *interp); MODULE_SCOPE Tcl_ObjCmdProc Tcl_EofObjCmd; |
| ︙ | ︙ | |||
4060 4061 4062 4063 4064 4065 4066 | struct CompileEnv *envPtr); /* * Routines that provide the [string] ensemble functionality. Possible * candidates for public interface. */ | | | | | | | 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 | struct CompileEnv *envPtr); /* * Routines that provide the [string] ensemble functionality. Possible * candidates for public interface. */ MODULE_SCOPE Tcl_Obj * TclStringCat(Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[], int flags); MODULE_SCOPE Tcl_Obj * TclStringFirst(Tcl_Obj *needle, Tcl_Obj *haystack, Tcl_Size start); MODULE_SCOPE Tcl_Obj * TclStringLast(Tcl_Obj *needle, Tcl_Obj *haystack, Tcl_Size last); MODULE_SCOPE Tcl_Obj * TclStringRepeat(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size count, int flags); MODULE_SCOPE Tcl_Obj * TclStringReplace(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size first, Tcl_Size count, Tcl_Obj *insertPtr, int flags); MODULE_SCOPE Tcl_Obj * TclStringReverse(Tcl_Obj *objPtr, int flags); /* Flag values for the [string] ensemble functions. */ #define TCL_STRING_MATCH_NOCASE TCL_MATCH_NOCASE /* (1<<0) in tcl.h */ #define TCL_STRING_IN_PLACE (1<<1) |
| ︙ | ︙ | |||
4196 4197 4198 4199 4200 4201 4202 | /* * Utility routines for encoding index values as integers. Used by both * some of the command compilers and by [lsort] and [lsearch]. */ MODULE_SCOPE int TclIndexEncode(Tcl_Interp *interp, Tcl_Obj *objPtr, | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 |
/*
* Utility routines for encoding index values as integers. Used by both
* some of the command compilers and by [lsort] and [lsearch].
*/
MODULE_SCOPE int TclIndexEncode(Tcl_Interp *interp, Tcl_Obj *objPtr,
int before, int after, int *indexPtr);
MODULE_SCOPE Tcl_Size TclIndexDecode(int encoded, Tcl_Size endValue);
MODULE_SCOPE int TclIndexInvalidError(Tcl_Interp *interp,
const char *idxType, Tcl_Size idx);
#endif /* TCL_MAJOR_VERSION > 8 */
/* Constants used in index value encoding routines. */
#define TCL_INDEX_END ((Tcl_Size)-2)
#define TCL_INDEX_START ((Tcl_Size)0)
/*
*------------------------------------------------------------------------
*
* TclGetSizeIntFromObj --
*
* Extract a Tcl_Size from a Tcl_Obj
*
* Results:
* TCL_OK / TCL_ERROR
*
* Side effects:
* On success, the integer value is stored in *sizePtr. On error,
* an error message in interp it it is not NULL.
*
*------------------------------------------------------------------------
*/
static inline int TclGetSizeIntFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *sizePtr) {
#if TCL_SIZE_MAX == INT_MAX
return TclGetIntFromObj(interp, objPtr, sizePtr);
#else
Tcl_WideInt wide;
if (TclGetWideIntFromObj(interp, objPtr, &wide) != TCL_OK) {
return TCL_ERROR;
}
*sizePtr = (Tcl_Size)wide;
return TCL_OK;
#endif
}
/*
*----------------------------------------------------------------------
*
* TclScaleTime --
*
* TIP #233 (Virtualized Time): Wrapper around the time virutalisation
|
| ︙ | ︙ | |||
4625 4626 4627 4628 4629 4630 4631 4632 4633 |
#endif
/* Token growth tuning, default to the general value. */
#ifndef TCL_MIN_TOKEN_GROWTH
#define TCL_MIN_TOKEN_GROWTH TCL_MIN_GROWTH/sizeof(Tcl_Token)
#endif
#define TclGrowTokenArray(tokenPtr, used, available, append, staticPtr) \
do { \
| > | | | 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 |
#endif
/* Token growth tuning, default to the general value. */
#ifndef TCL_MIN_TOKEN_GROWTH
#define TCL_MIN_TOKEN_GROWTH TCL_MIN_GROWTH/sizeof(Tcl_Token)
#endif
/* TODO - code below does not check for integer overflow */
#define TclGrowTokenArray(tokenPtr, used, available, append, staticPtr) \
do { \
Tcl_Size _needed = (used) + (append); \
if (_needed > (available)) { \
Tcl_Size allocated = 2 * _needed; \
Tcl_Token *oldPtr = (tokenPtr); \
Tcl_Token *newPtr; \
if (oldPtr == (staticPtr)) { \
oldPtr = NULL; \
} \
newPtr = (Tcl_Token *)Tcl_AttemptRealloc((char *) oldPtr, \
allocated * sizeof(Tcl_Token)); \
|
| ︙ | ︙ | |||
4687 4688 4689 4690 4691 4692 4693 | /* *---------------------------------------------------------------- * Macro counterpart of the Tcl_NumUtfChars() function. To be used in speed- * -sensitive points where it pays to avoid a function call in the common case * of counting along a string of all one-byte characters. The ANSI C * "prototype" for this macro is: * | | | > | | | 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 |
/*
*----------------------------------------------------------------
* Macro counterpart of the Tcl_NumUtfChars() function. To be used in speed-
* -sensitive points where it pays to avoid a function call in the common case
* of counting along a string of all one-byte characters. The ANSI C
* "prototype" for this macro is:
*
* MODULE_SCOPE void TclNumUtfCharsM(Tcl_Size numChars, const char *bytes,
* Tcl_Size numBytes);
* numBytes must be >= 0
*----------------------------------------------------------------
*/
#define TclNumUtfCharsM(numChars, bytes, numBytes) \
do { \
Tcl_Size _count = 0, _i = (numBytes); \
unsigned char *_str = (unsigned char *) (bytes); \
while (_i > 0 && (*_str < 0xC0)) { _i--; _str++; } \
_count = (numBytes) - _i; \
if (_i) { \
_count += Tcl_NumUtfChars((bytes) + _count, _i); \
} \
(numChars) = _count; \
} while (0);
|
| ︙ | ︙ | |||
4876 4877 4878 4879 4880 4881 4882 |
(objPtr)->internalRep.wideValue = (Tcl_WideInt)(uw_); \
(objPtr)->typePtr = &tclIntType; \
} \
TCL_DTRACE_OBJ_CREATE(objPtr); \
} while (0)
#define TclNewIndexObj(objPtr, uw) \
| < < < | < < < < < < < < < < < < < < < < < | 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 |
(objPtr)->internalRep.wideValue = (Tcl_WideInt)(uw_); \
(objPtr)->typePtr = &tclIntType; \
} \
TCL_DTRACE_OBJ_CREATE(objPtr); \
} while (0)
#define TclNewIndexObj(objPtr, uw) \
TclNewIntObj(objPtr, uw)
#define TclNewDoubleObj(objPtr, d) \
do { \
TclIncrObjsAllocated(); \
TclAllocObjStorage(objPtr); \
(objPtr)->refCount = 0; \
(objPtr)->bytes = NULL; \
|
| ︙ | ︙ | |||
4939 4940 4941 4942 4943 4944 4945 |
} \
} else { \
(objPtr) = Tcl_NewWideIntObj(uw_); \
} \
} while (0)
#define TclNewIndexObj(objPtr, w) \
| < < < | < < < < | 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 |
} \
} else { \
(objPtr) = Tcl_NewWideIntObj(uw_); \
} \
} while (0)
#define TclNewIndexObj(objPtr, w) \
TclNewIntObj(objPtr, w)
#define TclNewDoubleObj(objPtr, d) \
(objPtr) = Tcl_NewDoubleObj(d)
#define TclNewStringObj(objPtr, s, len) \
(objPtr) = Tcl_NewStringObj((s), (len))
#endif /* TCL_MEM_DEBUG */
|
| ︙ | ︙ | |||
5221 5222 5223 5224 5225 5226 5227 | * Other externals. */ MODULE_SCOPE size_t TclEnvEpoch; /* Epoch of the tcl environment * (if changed with tcl-env). */ #endif /* _TCLINT */ | | | 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 | * Other externals. */ MODULE_SCOPE size_t TclEnvEpoch; /* Epoch of the tcl environment * (if changed with tcl-env). */ #endif /* _TCLINT */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tclIntDecls.h.
| ︙ | ︙ | |||
305 306 307 308 309 310 311 | /* 141 */ EXTERN const char * TclpGetCwd(Tcl_Interp *interp, Tcl_DString *cwdPtr); /* 142 */ EXTERN int TclSetByteCodeFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr, CompileHookProc *hookProc, void *clientData); /* 143 */ | | | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | /* 141 */ EXTERN const char * TclpGetCwd(Tcl_Interp *interp, Tcl_DString *cwdPtr); /* 142 */ EXTERN int TclSetByteCodeFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr, CompileHookProc *hookProc, void *clientData); /* 143 */ EXTERN int TclAddLiteralObj(struct CompileEnv *envPtr, Tcl_Obj *objPtr, LiteralEntry **litPtrPtr); /* 144 */ EXTERN void TclHideLiteral(Tcl_Interp *interp, struct CompileEnv *envPtr, int index); /* 145 */ EXTERN const struct AuxDataType * TclGetAuxDataType(const char *typeName); /* 146 */ |
| ︙ | ︙ | |||
540 541 542 543 544 545 546 | /* 249 */ EXTERN char * TclDoubleDigits(double dv, int ndigits, int flags, int *decpt, int *signum, char **endPtr); /* 250 */ EXTERN void TclSetChildCancelFlags(Tcl_Interp *interp, int flags, int force); /* 251 */ | | | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | /* 249 */ EXTERN char * TclDoubleDigits(double dv, int ndigits, int flags, int *decpt, int *signum, char **endPtr); /* 250 */ EXTERN void TclSetChildCancelFlags(Tcl_Interp *interp, int flags, int force); /* 251 */ EXTERN int TclRegisterLiteral(void *envPtr, const char *bytes, Tcl_Size length, int flags); /* 252 */ EXTERN Tcl_Obj * TclPtrGetVar(Tcl_Interp *interp, Tcl_Var varPtr, Tcl_Var arrayPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags); /* 253 */ EXTERN Tcl_Obj * TclPtrSetVar(Tcl_Interp *interp, Tcl_Var varPtr, |
| ︙ | ︙ | |||
727 728 729 730 731 732 733 |
void (*reserved136)(void);
void (*reserved137)(void);
const char * (*tclGetEnv) (const char *name, Tcl_DString *valuePtr); /* 138 */
void (*reserved139)(void);
void (*reserved140)(void);
const char * (*tclpGetCwd) (Tcl_Interp *interp, Tcl_DString *cwdPtr); /* 141 */
int (*tclSetByteCodeFromAny) (Tcl_Interp *interp, Tcl_Obj *objPtr, CompileHookProc *hookProc, void *clientData); /* 142 */
| | | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
void (*reserved136)(void);
void (*reserved137)(void);
const char * (*tclGetEnv) (const char *name, Tcl_DString *valuePtr); /* 138 */
void (*reserved139)(void);
void (*reserved140)(void);
const char * (*tclpGetCwd) (Tcl_Interp *interp, Tcl_DString *cwdPtr); /* 141 */
int (*tclSetByteCodeFromAny) (Tcl_Interp *interp, Tcl_Obj *objPtr, CompileHookProc *hookProc, void *clientData); /* 142 */
int (*tclAddLiteralObj) (struct CompileEnv *envPtr, Tcl_Obj *objPtr, LiteralEntry **litPtrPtr); /* 143 */
void (*tclHideLiteral) (Tcl_Interp *interp, struct CompileEnv *envPtr, int index); /* 144 */
const struct AuxDataType * (*tclGetAuxDataType) (const char *typeName); /* 145 */
TclHandle (*tclHandleCreate) (void *ptr); /* 146 */
void (*tclHandleFree) (TclHandle handle); /* 147 */
TclHandle (*tclHandlePreserve) (TclHandle handle); /* 148 */
void (*tclHandleRelease) (TclHandle handle); /* 149 */
int (*tclRegAbout) (Tcl_Interp *interp, Tcl_RegExp re); /* 150 */
|
| ︙ | ︙ | |||
835 836 837 838 839 840 841 |
Tcl_HashTable * (*tclGetNamespaceChildTable) (Tcl_Namespace *nsPtr); /* 244 */
Tcl_HashTable * (*tclGetNamespaceCommandTable) (Tcl_Namespace *nsPtr); /* 245 */
int (*tclInitRewriteEnsemble) (Tcl_Interp *interp, Tcl_Size numRemoved, Tcl_Size numInserted, Tcl_Obj *const *objv); /* 246 */
void (*tclResetRewriteEnsemble) (Tcl_Interp *interp, int isRootEnsemble); /* 247 */
int (*tclCopyChannel) (Tcl_Interp *interp, Tcl_Channel inChan, Tcl_Channel outChan, long long toRead, Tcl_Obj *cmdPtr); /* 248 */
char * (*tclDoubleDigits) (double dv, int ndigits, int flags, int *decpt, int *signum, char **endPtr); /* 249 */
void (*tclSetChildCancelFlags) (Tcl_Interp *interp, int flags, int force); /* 250 */
| | | 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 |
Tcl_HashTable * (*tclGetNamespaceChildTable) (Tcl_Namespace *nsPtr); /* 244 */
Tcl_HashTable * (*tclGetNamespaceCommandTable) (Tcl_Namespace *nsPtr); /* 245 */
int (*tclInitRewriteEnsemble) (Tcl_Interp *interp, Tcl_Size numRemoved, Tcl_Size numInserted, Tcl_Obj *const *objv); /* 246 */
void (*tclResetRewriteEnsemble) (Tcl_Interp *interp, int isRootEnsemble); /* 247 */
int (*tclCopyChannel) (Tcl_Interp *interp, Tcl_Channel inChan, Tcl_Channel outChan, long long toRead, Tcl_Obj *cmdPtr); /* 248 */
char * (*tclDoubleDigits) (double dv, int ndigits, int flags, int *decpt, int *signum, char **endPtr); /* 249 */
void (*tclSetChildCancelFlags) (Tcl_Interp *interp, int flags, int force); /* 250 */
int (*tclRegisterLiteral) (void *envPtr, const char *bytes, Tcl_Size length, int flags); /* 251 */
Tcl_Obj * (*tclPtrGetVar) (Tcl_Interp *interp, Tcl_Var varPtr, Tcl_Var arrayPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags); /* 252 */
Tcl_Obj * (*tclPtrSetVar) (Tcl_Interp *interp, Tcl_Var varPtr, Tcl_Var arrayPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, Tcl_Obj *newValuePtr, int flags); /* 253 */
Tcl_Obj * (*tclPtrIncrObjVar) (Tcl_Interp *interp, Tcl_Var varPtr, Tcl_Var arrayPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, Tcl_Obj *incrPtr, int flags); /* 254 */
int (*tclPtrObjMakeUpvar) (Tcl_Interp *interp, Tcl_Var otherPtr, Tcl_Obj *myNamePtr, int myFlags); /* 255 */
int (*tclPtrUnsetVar) (Tcl_Interp *interp, Tcl_Var varPtr, Tcl_Var arrayPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags); /* 256 */
void (*tclStaticLibrary) (Tcl_Interp *interp, const char *prefix, Tcl_LibraryInitProc *initProc, Tcl_LibraryInitProc *safeInitProc); /* 257 */
Tcl_Obj * (*tclpCreateTemporaryDirectory) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj); /* 258 */
|
| ︙ | ︙ |
Changes to generic/tclInterp.c.
| ︙ | ︙ | |||
56 57 58 59 60 61 62 |
* interpreter. Additional arguments specified
* when calling the alias in the child interp
* will be appended to the prefix before the
* command is invoked. */
Tcl_Obj *objPtr; /* The first actual prefix object - the target
* command name; this has to be at the end of
* the structure, which will be extended to
| | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
* interpreter. Additional arguments specified
* when calling the alias in the child interp
* will be appended to the prefix before the
* command is invoked. */
Tcl_Obj *objPtr; /* The first actual prefix object - the target
* command name; this has to be at the end of
* the structure, which will be extended to
* accommodate the remaining objects in the
* prefix. */
} Alias;
/*
*
* Child:
*
|
| ︙ | ︙ | |||
193 194 195 196 197 198 199 |
* handlers. */
LimitHandler *nextPtr; /* Next item in linked list of handlers. */
};
/*
* Values for the LimitHandler flags field.
* LIMIT_HANDLER_ACTIVE - Whether the handler is currently being
| | | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
* handlers. */
LimitHandler *nextPtr; /* Next item in linked list of handlers. */
};
/*
* Values for the LimitHandler flags field.
* LIMIT_HANDLER_ACTIVE - Whether the handler is currently being
* processed; handlers are never to be reentered.
* LIMIT_HANDLER_DELETED - Whether the handler has been deleted. This
* should not normally be observed because when a handler is
* deleted it is also spliced out of the list of handlers, but
* even so we will be careful.
*/
#define LIMIT_HANDLER_ACTIVE 0x01
|
| ︙ | ︙ | |||
828 829 830 831 832 833 834 |
* for the interpreter does not collide with an existing command
* in the parent interpreter.
*/
for (i = 0; ; i++) {
Tcl_CmdInfo cmdInfo;
| | | | 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 |
* for the interpreter does not collide with an existing command
* in the parent interpreter.
*/
for (i = 0; ; i++) {
Tcl_CmdInfo cmdInfo;
snprintf(buf, sizeof(buf), "interp%d", i);
if (Tcl_GetCommandInfo(interp, buf, &cmdInfo) == 0) {
break;
}
}
childPtr = Tcl_NewStringObj(buf, -1);
}
if (ChildCreate(interp, childPtr, safe) == NULL) {
if (buf[0] != '\0') {
Tcl_DecrRefCount(childPtr);
}
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
868 869 870 871 872 873 874 |
for (i = 2; i < objc; i++) {
childInterp = GetInterp(interp, objv[i]);
if (childInterp == NULL) {
return TCL_ERROR;
} else if (childInterp == interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 |
for (i = 2; i < objc; i++) {
childInterp = GetInterp(interp, objv[i]);
if (childInterp == NULL) {
return TCL_ERROR;
} else if (childInterp == interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot delete the current interpreter", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"DELETESELF", NULL);
return TCL_ERROR;
}
iiPtr = (InterpInfo *) ((Interp *) childInterp)->interpInfo;
Tcl_DeleteCommandFromToken(iiPtr->child.parentInterp,
iiPtr->child.interpCmd);
|
| ︙ | ︙ | |||
1049 1050 1051 1052 1053 1054 1055 |
}
iiPtr = (InterpInfo *) ((Interp *) childInterp)->interpInfo;
TclNewObj(resultPtr);
hPtr = Tcl_FirstHashEntry(&iiPtr->parent.childTable, &hashSearch);
for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&hashSearch)) {
string = (char *)Tcl_GetHashKey(&iiPtr->parent.childTable, hPtr);
Tcl_ListObjAppendElement(NULL, resultPtr,
| | | 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 |
}
iiPtr = (InterpInfo *) ((Interp *) childInterp)->interpInfo;
TclNewObj(resultPtr);
hPtr = Tcl_FirstHashEntry(&iiPtr->parent.childTable, &hashSearch);
for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&hashSearch)) {
string = (char *)Tcl_GetHashKey(&iiPtr->parent.childTable, hPtr);
Tcl_ListObjAppendElement(NULL, resultPtr,
Tcl_NewStringObj(string, -1));
}
Tcl_SetObjResult(interp, resultPtr);
return TCL_OK;
}
case OPT_TRANSFER:
case OPT_SHARE: {
Tcl_Interp *parentInterp; /* The parent of the child. */
|
| ︙ | ︙ | |||
1193 1194 1195 1196 1197 1198 1199 |
int
Tcl_CreateAlias(
Tcl_Interp *childInterp, /* Interpreter for source command. */
const char *childCmd, /* Command to install in child. */
Tcl_Interp *targetInterp, /* Interpreter for target command. */
const char *targetCmd, /* Name of target command. */
| | | | | | | 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 |
int
Tcl_CreateAlias(
Tcl_Interp *childInterp, /* Interpreter for source command. */
const char *childCmd, /* Command to install in child. */
Tcl_Interp *targetInterp, /* Interpreter for target command. */
const char *targetCmd, /* Name of target command. */
Tcl_Size argc, /* How many additional arguments? */
const char *const *argv) /* These are the additional args. */
{
Tcl_Obj *childObjPtr, *targetObjPtr;
Tcl_Obj **objv;
Tcl_Size i;
int result;
objv = (Tcl_Obj **)TclStackAlloc(childInterp, sizeof(Tcl_Obj *) * argc);
for (i = 0; i < argc; i++) {
objv[i] = Tcl_NewStringObj(argv[i], -1);
Tcl_IncrRefCount(objv[i]);
}
childObjPtr = Tcl_NewStringObj(childCmd, -1);
Tcl_IncrRefCount(childObjPtr);
targetObjPtr = Tcl_NewStringObj(targetCmd, -1);
Tcl_IncrRefCount(targetObjPtr);
result = AliasCreate(childInterp, childInterp, targetInterp, childObjPtr,
targetObjPtr, argc, objv);
for (i = 0; i < argc; i++) {
Tcl_DecrRefCount(objv[i]);
|
| ︙ | ︙ | |||
1248 1249 1250 1251 1252 1253 1254 |
int
Tcl_CreateAliasObj(
Tcl_Interp *childInterp, /* Interpreter for source command. */
const char *childCmd, /* Command to install in child. */
Tcl_Interp *targetInterp, /* Interpreter for target command. */
const char *targetCmd, /* Name of target command. */
| | | | | 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 |
int
Tcl_CreateAliasObj(
Tcl_Interp *childInterp, /* Interpreter for source command. */
const char *childCmd, /* Command to install in child. */
Tcl_Interp *targetInterp, /* Interpreter for target command. */
const char *targetCmd, /* Name of target command. */
Tcl_Size objc, /* How many additional arguments? */
Tcl_Obj *const objv[]) /* Argument vector. */
{
Tcl_Obj *childObjPtr, *targetObjPtr;
int result;
childObjPtr = Tcl_NewStringObj(childCmd, -1);
Tcl_IncrRefCount(childObjPtr);
targetObjPtr = Tcl_NewStringObj(targetCmd, -1);
Tcl_IncrRefCount(targetObjPtr);
result = AliasCreate(childInterp, childInterp, targetInterp, childObjPtr,
targetObjPtr, objc, objv);
Tcl_DecrRefCount(childObjPtr);
Tcl_DecrRefCount(targetObjPtr);
|
| ︙ | ︙ | |||
2112 2113 2114 2115 2116 2117 2118 |
Tcl_Interp *interp, /* Interpreter to start search at. */
const char *childPath, /* Name of child to create. */
int isSafe) /* Should new child be "safe" ? */
{
Tcl_Obj *pathPtr;
Tcl_Interp *childInterp;
| | | 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 |
Tcl_Interp *interp, /* Interpreter to start search at. */
const char *childPath, /* Name of child to create. */
int isSafe) /* Should new child be "safe" ? */
{
Tcl_Obj *pathPtr;
Tcl_Interp *childInterp;
pathPtr = Tcl_NewStringObj(childPath, -1);
childInterp = ChildCreate(interp, pathPtr, isSafe);
Tcl_DecrRefCount(pathPtr);
return childInterp;
}
/*
|
| ︙ | ︙ | |||
2143 2144 2145 2146 2147 2148 2149 |
Tcl_GetChild(
Tcl_Interp *interp, /* Interpreter to start search from. */
const char *childPath) /* Path of child to find. */
{
Tcl_Obj *pathPtr;
Tcl_Interp *childInterp;
| | | 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 |
Tcl_GetChild(
Tcl_Interp *interp, /* Interpreter to start search from. */
const char *childPath) /* Path of child to find. */
{
Tcl_Obj *pathPtr;
Tcl_Interp *childInterp;
pathPtr = Tcl_NewStringObj(childPath, -1);
childInterp = GetInterp(interp, pathPtr);
Tcl_DecrRefCount(pathPtr);
return childInterp;
}
/*
|
| ︙ | ︙ | |||
2289 2290 2291 2292 2293 2294 2295 |
}
iiPtr = (InterpInfo *) ((Interp *) targetInterp)->interpInfo;
if (Tcl_GetInterpPath(interp, iiPtr->child.parentInterp) != TCL_OK){
return TCL_ERROR;
}
Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp),
Tcl_NewStringObj((const char *)Tcl_GetHashKey(&iiPtr->parent.childTable,
| | | 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 |
}
iiPtr = (InterpInfo *) ((Interp *) targetInterp)->interpInfo;
if (Tcl_GetInterpPath(interp, iiPtr->child.parentInterp) != TCL_OK){
return TCL_ERROR;
}
Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp),
Tcl_NewStringObj((const char *)Tcl_GetHashKey(&iiPtr->parent.childTable,
iiPtr->child.childEntryPtr), -1));
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* GetInterp --
|
| ︙ | ︙ | |||
2319 2320 2321 2322 2323 2324 2325 |
Tcl_Interp *interp, /* Interp. to start search from. */
Tcl_Obj *pathPtr) /* List object containing name of interp. to
* be found. */
{
Tcl_HashEntry *hPtr; /* Search element. */
Child *childPtr; /* Interim child record. */
Tcl_Obj **objv;
| | | 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 |
Tcl_Interp *interp, /* Interp. to start search from. */
Tcl_Obj *pathPtr) /* List object containing name of interp. to
* be found. */
{
Tcl_HashEntry *hPtr; /* Search element. */
Child *childPtr; /* Interim child record. */
Tcl_Obj **objv;
Tcl_Size objc, i;
Tcl_Interp *searchInterp; /* Interim storage for interp. to find. */
InterpInfo *parentInfoPtr;
if (TclListObjGetElementsM(interp, pathPtr, &objc, &objv) != TCL_OK) {
return NULL;
}
|
| ︙ | ︙ | |||
2377 2378 2379 2380 2381 2382 2383 |
ChildBgerror(
Tcl_Interp *interp, /* Interp for error return. */
Tcl_Interp *childInterp, /* Interp in which limit is set/queried. */
int objc, /* Set or Query. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
if (objc) {
| | | | 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 |
ChildBgerror(
Tcl_Interp *interp, /* Interp for error return. */
Tcl_Interp *childInterp, /* Interp in which limit is set/queried. */
int objc, /* Set or Query. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
if (objc) {
Tcl_Size length;
if (TCL_ERROR == TclListObjLengthM(NULL, objv[0], &length)
|| (length < 1)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cmdPrefix must be list of length >= 1", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BGERRORFORMAT", NULL);
return TCL_ERROR;
}
TclSetBgErrorHandler(childInterp, objv[0]);
}
Tcl_SetObjResult(interp, TclGetBgErrorHandler(childInterp));
|
| ︙ | ︙ | |||
2424 2425 2426 2427 2428 2429 2430 |
{
Tcl_Interp *parentInterp, *childInterp;
Child *childPtr;
InterpInfo *parentInfoPtr;
Tcl_HashEntry *hPtr;
const char *path;
int isNew;
| | | 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 |
{
Tcl_Interp *parentInterp, *childInterp;
Child *childPtr;
InterpInfo *parentInfoPtr;
Tcl_HashEntry *hPtr;
const char *path;
int isNew;
Tcl_Size objc;
Tcl_Obj **objv;
if (TclListObjGetElementsM(interp, pathPtr, &objc, &objv) != TCL_OK) {
return NULL;
}
if (objc < 2) {
parentInterp = interp;
|
| ︙ | ︙ | |||
2827 2828 2829 2830 2831 2832 2833 |
Interp *iPtr;
Tcl_Obj *resultPtr;
iPtr = (Interp *) childInterp;
if (objc == 0) {
TclNewObj(resultPtr);
Tcl_ListObjAppendElement(NULL, resultPtr,
| | | 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 |
Interp *iPtr;
Tcl_Obj *resultPtr;
iPtr = (Interp *) childInterp;
if (objc == 0) {
TclNewObj(resultPtr);
Tcl_ListObjAppendElement(NULL, resultPtr,
Tcl_NewStringObj("-frame", -1));
Tcl_ListObjAppendElement(NULL, resultPtr,
Tcl_NewBooleanObj(iPtr->flags & INTERP_DEBUG_FRAME));
Tcl_SetObjResult(interp, resultPtr);
} else {
if (Tcl_GetIndexFromObj(interp, objv[0], debugTypes, "debug option",
0, &debugType) != TCL_OK) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
2997 2998 2999 3000 3001 3002 3003 |
{
Interp *iPtr;
Tcl_WideInt limit;
if (objc) {
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("permission denied: "
| | | | | > | < | | | 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 |
{
Interp *iPtr;
Tcl_WideInt limit;
if (objc) {
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("permission denied: "
"safe interpreters cannot change recursion limit", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "UNSAFE",
NULL);
return TCL_ERROR;
}
if (TclGetWideIntFromObj(interp, objv[0], &limit) == TCL_ERROR) {
return TCL_ERROR;
}
if (limit <= 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"recursion limit must be > 0", -1));
Tcl_SetErrorCode(
interp, "TCL", "OPERATION", "INTERP", "BADLIMIT", NULL);
return TCL_ERROR;
}
Tcl_SetRecursionLimit(childInterp, limit);
iPtr = (Interp *) childInterp;
if (interp == childInterp && iPtr->numLevels > limit) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"falling back due to new recursion limit", -1));
Tcl_SetErrorCode(interp, "TCL", "RECURSION", NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, objv[0]);
return TCL_OK;
} else {
limit = Tcl_SetRecursionLimit(childInterp, 0);
|
| ︙ | ︙ | |||
3106 3107 3108 3109 3110 3111 3112 |
TclNewObj(listObjPtr);
hTblPtr = ((Interp *) childInterp)->hiddenCmdTablePtr;
if (hTblPtr != NULL) {
for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch);
hPtr != NULL;
hPtr = Tcl_NextHashEntry(&hSearch)) {
Tcl_ListObjAppendElement(NULL, listObjPtr,
| | | 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 |
TclNewObj(listObjPtr);
hTblPtr = ((Interp *) childInterp)->hiddenCmdTablePtr;
if (hTblPtr != NULL) {
for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch);
hPtr != NULL;
hPtr = Tcl_NextHashEntry(&hSearch)) {
Tcl_ListObjAppendElement(NULL, listObjPtr,
Tcl_NewStringObj((const char *)Tcl_GetHashKey(hTblPtr, hPtr), -1));
}
}
Tcl_SetObjResult(interp, listObjPtr);
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
3321 3322 3323 3324 3325 3326 3327 |
Tcl_UnsetVar2(interp, "tcl_platform", "os", TCL_GLOBAL_ONLY);
Tcl_UnsetVar2(interp, "tcl_platform", "osVersion", TCL_GLOBAL_ONLY);
Tcl_UnsetVar2(interp, "tcl_platform", "machine", TCL_GLOBAL_ONLY);
Tcl_UnsetVar2(interp, "tcl_platform", "user", TCL_GLOBAL_ONLY);
/*
| | | 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 |
Tcl_UnsetVar2(interp, "tcl_platform", "os", TCL_GLOBAL_ONLY);
Tcl_UnsetVar2(interp, "tcl_platform", "osVersion", TCL_GLOBAL_ONLY);
Tcl_UnsetVar2(interp, "tcl_platform", "machine", TCL_GLOBAL_ONLY);
Tcl_UnsetVar2(interp, "tcl_platform", "user", TCL_GLOBAL_ONLY);
/*
* Unset path information variables (the only one remaining is [info
* nameofexecutable])
*/
Tcl_UnsetVar2(interp, "tclDefaultLibrary", NULL, TCL_GLOBAL_ONLY);
Tcl_UnsetVar2(interp, "tcl_library", NULL, TCL_GLOBAL_ONLY);
Tcl_UnsetVar2(interp, "tcl_pkgPath", NULL, TCL_GLOBAL_ONLY);
|
| ︙ | ︙ | |||
3475 3476 3477 3478 3479 3480 3481 |
iPtr->limit.exceeded |= TCL_LIMIT_COMMANDS;
Tcl_Preserve(interp);
RunLimitHandlers(iPtr->limit.cmdHandlers, interp);
if (iPtr->limit.cmdCount >= iPtr->cmdCount) {
iPtr->limit.exceeded &= ~TCL_LIMIT_COMMANDS;
} else if (iPtr->limit.exceeded & TCL_LIMIT_COMMANDS) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 |
iPtr->limit.exceeded |= TCL_LIMIT_COMMANDS;
Tcl_Preserve(interp);
RunLimitHandlers(iPtr->limit.cmdHandlers, interp);
if (iPtr->limit.cmdCount >= iPtr->cmdCount) {
iPtr->limit.exceeded &= ~TCL_LIMIT_COMMANDS;
} else if (iPtr->limit.exceeded & TCL_LIMIT_COMMANDS) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command count limit exceeded", -1));
Tcl_SetErrorCode(interp, "TCL", "LIMIT", "COMMANDS", NULL);
Tcl_Release(interp);
return TCL_ERROR;
}
Tcl_Release(interp);
}
|
| ︙ | ︙ | |||
3501 3502 3503 3504 3505 3506 3507 |
RunLimitHandlers(iPtr->limit.timeHandlers, interp);
if (iPtr->limit.time.sec > now.sec ||
(iPtr->limit.time.sec == now.sec &&
iPtr->limit.time.usec >= now.usec)) {
iPtr->limit.exceeded &= ~TCL_LIMIT_TIME;
} else if (iPtr->limit.exceeded & TCL_LIMIT_TIME) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 |
RunLimitHandlers(iPtr->limit.timeHandlers, interp);
if (iPtr->limit.time.sec > now.sec ||
(iPtr->limit.time.sec == now.sec &&
iPtr->limit.time.usec >= now.usec)) {
iPtr->limit.exceeded &= ~TCL_LIMIT_TIME;
} else if (iPtr->limit.exceeded & TCL_LIMIT_TIME) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"time limit exceeded", -1));
Tcl_SetErrorCode(interp, "TCL", "LIMIT", "TIME", NULL);
Tcl_Release(interp);
return TCL_ERROR;
}
Tcl_Release(interp);
}
}
|
| ︙ | ︙ | |||
3981 3982 3983 3984 3985 3986 3987 |
*
*----------------------------------------------------------------------
*/
void
Tcl_LimitSetCommands(
Tcl_Interp *interp,
| | | 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 |
*
*----------------------------------------------------------------------
*/
void
Tcl_LimitSetCommands(
Tcl_Interp *interp,
Tcl_Size commandLimit)
{
Interp *iPtr = (Interp *) interp;
iPtr->limit.cmdCount = commandLimit;
iPtr->limit.exceeded &= ~TCL_LIMIT_COMMANDS;
}
|
| ︙ | ︙ | |||
4285 4286 4287 4288 4289 4290 4291 | * interpreter through this mechanism (though as many interpreters may be * limited as the programmer chooses overall). * * Results: * None. * * Side effects: | | | 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 | * interpreter through this mechanism (though as many interpreters may be * limited as the programmer chooses overall). * * Results: * None. * * Side effects: * A limit callback implemented as an invocation of a Tcl script in * another interpreter is either installed or removed. * *---------------------------------------------------------------------- */ static void SetScriptLimitCallback( |
| ︙ | ︙ | |||
4504 4505 4506 4507 4508 4509 4510 |
* interpreter's limits; it may only manipulate its children. Note that
* the low level API enforces this with Tcl_Panic, which we want to
* avoid. [Bug 3398794]
*/
if (interp == childInterp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | | | | 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 |
* interpreter's limits; it may only manipulate its children. Note that
* the low level API enforces this with Tcl_Panic, which we want to
* avoid. [Bug 3398794]
*/
if (interp == childInterp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"limits on current interpreter inaccessible", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "SELF", NULL);
return TCL_ERROR;
}
if (objc == consumedObjc) {
Tcl_Obj *dictPtr;
TclNewObj(dictPtr);
key.interp = childInterp;
key.type = TCL_LIMIT_COMMANDS;
hPtr = Tcl_FindHashEntry(&iPtr->limit.callbacks, &key);
if (hPtr != NULL) {
limitCBPtr = (ScriptLimitCallback *)Tcl_GetHashValue(hPtr);
if (limitCBPtr != NULL && limitCBPtr->scriptObj != NULL) {
Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[0], -1),
limitCBPtr->scriptObj);
} else {
goto putEmptyCommandInDict;
}
} else {
Tcl_Obj *empty;
putEmptyCommandInDict:
TclNewObj(empty);
Tcl_DictObjPut(NULL, dictPtr,
Tcl_NewStringObj(options[0], -1), empty);
}
Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[1], -1),
Tcl_NewWideIntObj(Tcl_LimitGetGranularity(childInterp,
TCL_LIMIT_COMMANDS)));
if (Tcl_LimitTypeEnabled(childInterp, TCL_LIMIT_COMMANDS)) {
Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[2], -1),
Tcl_NewWideIntObj(Tcl_LimitGetCommands(childInterp)));
} else {
Tcl_Obj *empty;
TclNewObj(empty);
Tcl_DictObjPut(NULL, dictPtr,
Tcl_NewStringObj(options[2], -1), empty);
}
Tcl_SetObjResult(interp, dictPtr);
return TCL_OK;
} else if (objc == consumedObjc+1) {
if (Tcl_GetIndexFromObj(interp, objv[consumedObjc], options, "option",
0, &index) != TCL_OK) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
4582 4583 4584 4585 4586 4587 4588 |
}
return TCL_OK;
} else if ((objc-consumedObjc) & 1 /* isOdd(objc-consumedObjc) */) {
Tcl_WrongNumArgs(interp, consumedObjc, objv, "?-option value ...?");
return TCL_ERROR;
} else {
int i;
| | | | | 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 |
}
return TCL_OK;
} else if ((objc-consumedObjc) & 1 /* isOdd(objc-consumedObjc) */) {
Tcl_WrongNumArgs(interp, consumedObjc, objv, "?-option value ...?");
return TCL_ERROR;
} else {
int i;
Tcl_Size scriptLen = 0, limitLen = 0;
Tcl_Obj *scriptObj = NULL, *granObj = NULL, *limitObj = NULL;
int gran = 0, limit = 0;
for (i=consumedObjc ; i<objc ; i+=2) {
if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", 0,
&index) != TCL_OK) {
return TCL_ERROR;
}
switch (index) {
case OPT_CMD:
scriptObj = objv[i+1];
(void) Tcl_GetStringFromObj(scriptObj, &scriptLen);
break;
case OPT_GRAN:
granObj = objv[i+1];
if (TclGetIntFromObj(interp, objv[i+1], &gran) != TCL_OK) {
return TCL_ERROR;
}
if (gran < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"granularity must be at least 1", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADVALUE", NULL);
return TCL_ERROR;
}
break;
case OPT_VAL:
limitObj = objv[i+1];
(void) Tcl_GetStringFromObj(objv[i+1], &limitLen);
if (limitLen == 0) {
break;
}
if (TclGetIntFromObj(interp, objv[i+1], &limit) != TCL_OK) {
return TCL_ERROR;
}
if (limit < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command limit value must be at least 0", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADVALUE", NULL);
return TCL_ERROR;
}
break;
}
}
|
| ︙ | ︙ | |||
4692 4693 4694 4695 4696 4697 4698 |
* interpreter's limits; it may only manipulate its children. Note that
* the low level API enforces this with Tcl_Panic, which we want to
* avoid. [Bug 3398794]
*/
if (interp == childInterp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | | | | | | 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 |
* interpreter's limits; it may only manipulate its children. Note that
* the low level API enforces this with Tcl_Panic, which we want to
* avoid. [Bug 3398794]
*/
if (interp == childInterp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"limits on current interpreter inaccessible", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "SELF", NULL);
return TCL_ERROR;
}
if (objc == consumedObjc) {
Tcl_Obj *dictPtr;
TclNewObj(dictPtr);
key.interp = childInterp;
key.type = TCL_LIMIT_TIME;
hPtr = Tcl_FindHashEntry(&iPtr->limit.callbacks, &key);
if (hPtr != NULL) {
limitCBPtr = (ScriptLimitCallback *)Tcl_GetHashValue(hPtr);
if (limitCBPtr != NULL && limitCBPtr->scriptObj != NULL) {
Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[0], -1),
limitCBPtr->scriptObj);
} else {
goto putEmptyCommandInDict;
}
} else {
Tcl_Obj *empty;
putEmptyCommandInDict:
TclNewObj(empty);
Tcl_DictObjPut(NULL, dictPtr,
Tcl_NewStringObj(options[0], -1), empty);
}
Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[1], -1),
Tcl_NewWideIntObj(Tcl_LimitGetGranularity(childInterp,
TCL_LIMIT_TIME)));
if (Tcl_LimitTypeEnabled(childInterp, TCL_LIMIT_TIME)) {
Tcl_Time limitMoment;
Tcl_LimitGetTime(childInterp, &limitMoment);
Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[2], -1),
Tcl_NewWideIntObj(limitMoment.usec/1000));
Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[3], -1),
Tcl_NewWideIntObj(limitMoment.sec));
} else {
Tcl_Obj *empty;
TclNewObj(empty);
Tcl_DictObjPut(NULL, dictPtr,
Tcl_NewStringObj(options[2], -1), empty);
Tcl_DictObjPut(NULL, dictPtr,
Tcl_NewStringObj(options[3], -1), empty);
}
Tcl_SetObjResult(interp, dictPtr);
return TCL_OK;
} else if (objc == consumedObjc+1) {
if (Tcl_GetIndexFromObj(interp, objv[consumedObjc], options, "option",
0, &index) != TCL_OK) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
4787 4788 4789 4790 4791 4792 4793 |
}
return TCL_OK;
} else if ((objc-consumedObjc) & 1 /* isOdd(objc-consumedObjc) */) {
Tcl_WrongNumArgs(interp, consumedObjc, objv, "?-option value ...?");
return TCL_ERROR;
} else {
int i;
| | | 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 |
}
return TCL_OK;
} else if ((objc-consumedObjc) & 1 /* isOdd(objc-consumedObjc) */) {
Tcl_WrongNumArgs(interp, consumedObjc, objv, "?-option value ...?");
return TCL_ERROR;
} else {
int i;
Tcl_Size scriptLen = 0, milliLen = 0, secLen = 0;
Tcl_Obj *scriptObj = NULL, *granObj = NULL;
Tcl_Obj *milliObj = NULL, *secObj = NULL;
int gran = 0;
Tcl_Time limitMoment;
Tcl_WideInt tmp;
Tcl_LimitGetTime(childInterp, &limitMoment);
|
| ︙ | ︙ | |||
4812 4813 4814 4815 4816 4817 4818 |
case OPT_GRAN:
granObj = objv[i+1];
if (TclGetIntFromObj(interp, objv[i+1], &gran) != TCL_OK) {
return TCL_ERROR;
}
if (gran < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 |
case OPT_GRAN:
granObj = objv[i+1];
if (TclGetIntFromObj(interp, objv[i+1], &gran) != TCL_OK) {
return TCL_ERROR;
}
if (gran < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"granularity must be at least 1", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADVALUE", NULL);
return TCL_ERROR;
}
break;
case OPT_MILLI:
milliObj = objv[i+1];
|
| ︙ | ︙ | |||
4866 4867 4868 4869 4870 4871 4872 |
* Setting -milliseconds but clearing -seconds, or resetting
* -milliseconds but not resetting -seconds? Bad voodoo!
*/
if (secObj != NULL && secLen == 0 && milliLen > 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may only set -milliseconds if -seconds is not "
| | | | 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 |
* Setting -milliseconds but clearing -seconds, or resetting
* -milliseconds but not resetting -seconds? Bad voodoo!
*/
if (secObj != NULL && secLen == 0 && milliLen > 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may only set -milliseconds if -seconds is not "
"also being reset", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADUSAGE", NULL);
return TCL_ERROR;
}
if (milliLen == 0 && (secObj == NULL || secLen > 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may only reset -milliseconds if -seconds is "
"also being reset", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADUSAGE", NULL);
return TCL_ERROR;
}
}
if (milliLen > 0 || secLen > 0) {
|
| ︙ | ︙ |
Changes to generic/tclLink.c.
| ︙ | ︙ | |||
29 30 31 32 33 34 35 |
Tcl_Interp *interp; /* Interpreter containing Tcl variable. */
Namespace *nsPtr; /* Namespace containing Tcl variable */
Tcl_Obj *varName; /* Name of variable (must be global). This is
* needed during trace callbacks, since the
* actual variable may be aliased at that time
* via upvar. */
void *addr; /* Location of C variable. */
| | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
Tcl_Interp *interp; /* Interpreter containing Tcl variable. */
Namespace *nsPtr; /* Namespace containing Tcl variable */
Tcl_Obj *varName; /* Name of variable (must be global). This is
* needed during trace callbacks, since the
* actual variable may be aliased at that time
* via upvar. */
void *addr; /* Location of C variable. */
Tcl_Size bytes; /* Size of C variable array. This is 0 when
* single variables, and >0 used for array
* variables. */
Tcl_Size numElems; /* Number of elements in C variable array.
* Zero for single variables. */
int type; /* Type of link (TCL_LINK_INT, etc.). */
union {
char c;
unsigned char uc;
int i;
unsigned int ui;
|
| ︙ | ︙ | |||
171 172 173 174 175 176 177 |
"variable '%s' is already linked", varName));
return TCL_ERROR;
}
linkPtr = (Link *)Tcl_Alloc(sizeof(Link));
linkPtr->interp = interp;
linkPtr->nsPtr = NULL;
| | | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
"variable '%s' is already linked", varName));
return TCL_ERROR;
}
linkPtr = (Link *)Tcl_Alloc(sizeof(Link));
linkPtr->interp = interp;
linkPtr->nsPtr = NULL;
linkPtr->varName = Tcl_NewStringObj(varName, -1);
Tcl_IncrRefCount(linkPtr->varName);
linkPtr->addr = addr;
linkPtr->type = type & ~TCL_LINK_READ_ONLY;
#if !defined(TCL_NO_DEPRECATED) && (defined(TCL_WIDE_INT_IS_LONG) \
|| defined(_WIN32) || defined(__CYGWIN__))
if (linkPtr->type == 11 /* legacy TCL_LINK_LONG */) {
linkPtr->type = TCL_LINK_LONG;
|
| ︙ | ︙ | |||
242 243 244 245 246 247 248 |
const char *varName, /* Name of a global variable in interp. */
void *addr, /* Address of a C variable to be linked to
* varName. If NULL then the necessary space
* will be allocated and returned as the
* interpreter result. */
int type, /* Type of C variable: TCL_LINK_INT, etc. Also
* may have TCL_LINK_READ_ONLY OR'ed in. */
| | | | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
const char *varName, /* Name of a global variable in interp. */
void *addr, /* Address of a C variable to be linked to
* varName. If NULL then the necessary space
* will be allocated and returned as the
* interpreter result. */
int type, /* Type of C variable: TCL_LINK_INT, etc. Also
* may have TCL_LINK_READ_ONLY OR'ed in. */
Tcl_Size size) /* Size of C variable array, >1 if array */
{
Tcl_Obj *objPtr;
Link *linkPtr;
Namespace *dummy;
const char *name;
int code;
if (size < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"wrong array size given", -1));
return TCL_ERROR;
}
linkPtr = (Link *)Tcl_Alloc(sizeof(Link));
linkPtr->type = type & ~TCL_LINK_READ_ONLY;
#if !defined(TCL_NO_DEPRECATED) && (defined(TCL_WIDE_INT_IS_LONG) \
|| defined(_WIN32) || defined(__CYGWIN__))
|
| ︙ | ︙ | |||
336 337 338 339 340 341 342 |
case TCL_LINK_CHARS:
case TCL_LINK_BINARY:
linkPtr->bytes = size * sizeof(char);
break;
default:
LinkFree(linkPtr);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
case TCL_LINK_CHARS:
case TCL_LINK_BINARY:
linkPtr->bytes = size * sizeof(char);
break;
default:
LinkFree(linkPtr);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad linked array variable type", -1));
return TCL_ERROR;
}
/*
* Allocate C variable space in case no address is given
*/
|
| ︙ | ︙ | |||
376 377 378 379 380 381 382 |
}
/*
* Set common structure values.
*/
linkPtr->interp = interp;
| | | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
}
/*
* Set common structure values.
*/
linkPtr->interp = interp;
linkPtr->varName = Tcl_NewStringObj(varName, -1);
Tcl_IncrRefCount(linkPtr->varName);
TclGetNamespaceForQualName(interp, varName, NULL, TCL_GLOBAL_ONLY,
&(linkPtr->nsPtr), &dummy, &dummy, &name);
linkPtr->nsPtr->refCount++;
objPtr = ObjValue(linkPtr);
|
| ︙ | ︙ | |||
588 589 590 591 592 593 594 |
static int
SetInvalidRealFromAny(
TCL_UNUSED(Tcl_Interp *),
Tcl_Obj *objPtr)
{
const char *str;
const char *endPtr;
| | | 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
static int
SetInvalidRealFromAny(
TCL_UNUSED(Tcl_Interp *),
Tcl_Obj *objPtr)
{
const char *str;
const char *endPtr;
Tcl_Size length;
str = Tcl_GetStringFromObj(objPtr, &length);
if ((length == 1) && (str[0] == '.')) {
objPtr->typePtr = &invalidRealType;
objPtr->internalRep.doubleValue = 0.0;
return TCL_OK;
}
|
| ︙ | ︙ | |||
634 635 636 637 638 639 640 |
*/
static int
GetInvalidIntFromObj(
Tcl_Obj *objPtr,
int *intPtr)
{
| | | 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
*/
static int
GetInvalidIntFromObj(
Tcl_Obj *objPtr,
int *intPtr)
{
Tcl_Size length;
const char *str = Tcl_GetStringFromObj(objPtr, &length);
if ((length == 0) || ((length == 2) && (str[0] == '0')
&& strchr("xXbBoOdD", str[1]))) {
*intPtr = 0;
return TCL_OK;
} else if ((length == 1) && strchr("+-", str[0])) {
|
| ︙ | ︙ | |||
711 712 713 714 715 716 717 |
/* Links can only be made to global variables,
* so we can find them with need to resolve
* caller-supplied name in caller context. */
int flags) /* Miscellaneous additional information. */
{
Link *linkPtr = (Link *)clientData;
int changed;
| | | | 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 |
/* Links can only be made to global variables,
* so we can find them with need to resolve
* caller-supplied name in caller context. */
int flags) /* Miscellaneous additional information. */
{
Link *linkPtr = (Link *)clientData;
int changed;
Tcl_Size valueLength = 0;
const char *value;
char **pp;
Tcl_Obj *valueObj;
int valueInt;
Tcl_WideInt valueWide;
Tcl_WideUInt valueUWide;
double valueDouble;
Tcl_Size objc, i;
Tcl_Obj **objv;
/*
* If the variable is being unset, then just re-create it (with a trace)
* unless the whole interpreter is going away.
*/
|
| ︙ | ︙ | |||
826 827 828 829 830 831 832 |
}
return NULL;
}
/*
* For writes, first make sure that the variable is writable. Then convert
* the Tcl value to C if possible. If the variable isn't writable or can't
| | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 |
}
return NULL;
}
/*
* For writes, first make sure that the variable is writable. Then convert
* the Tcl value to C if possible. If the variable isn't writable or can't
* be converted, then restore the variable's old value and return an
* error. Another tricky thing: we have to save and restore the interp's
* result, since the variable access could occur when the result has been
* partially set.
*/
if (linkPtr->flags & LINK_READ_ONLY) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
| ︙ | ︙ | |||
1245 1246 1247 1248 1249 1250 1251 |
static Tcl_Obj *
ObjValue(
Link *linkPtr) /* Structure describing linked variable. */
{
char *p;
Tcl_Obj *resultObj, **objv;
| | | 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 |
static Tcl_Obj *
ObjValue(
Link *linkPtr) /* Structure describing linked variable. */
{
char *p;
Tcl_Obj *resultObj, **objv;
Tcl_Size i;
switch (linkPtr->type) {
case TCL_LINK_INT:
if (linkPtr->flags & LINK_ALLOC_LAST) {
memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
objv = (Tcl_Obj **)Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *));
for (i=0; i < linkPtr->numElems; i++) {
|
| ︙ | ︙ | |||
1429 1430 1431 1432 1433 1434 1435 |
case TCL_LINK_STRING:
p = LinkedVar(char *);
if (p == NULL) {
TclNewLiteralStringObj(resultObj, "NULL");
return resultObj;
}
| | | 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 |
case TCL_LINK_STRING:
p = LinkedVar(char *);
if (p == NULL) {
TclNewLiteralStringObj(resultObj, "NULL");
return resultObj;
}
return Tcl_NewStringObj(p, -1);
case TCL_LINK_CHARS:
if (linkPtr->flags & LINK_ALLOC_LAST) {
memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
linkPtr->lastValue.cPtr[linkPtr->bytes-1] = '\0';
/* take care of proper string end */
return Tcl_NewStringObj(linkPtr->lastValue.cPtr, linkPtr->bytes);
|
| ︙ | ︙ |
Changes to generic/tclListObj.c.
| ︙ | ︙ | |||
45 46 47 48 49 50 51 |
* being passed AFTER validation. On Tcl9 length types are unsigned hence
* the checks against LIST_MAX. On Tcl8 length types are signed hence the
* also checks against 0.
*/
#define LIST_INDEX_ASSERT(idxarg_) \
do { \
Tcl_Size idx_ = (idxarg_); /* To guard against ++ etc. */ \
| | | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
* being passed AFTER validation. On Tcl9 length types are unsigned hence
* the checks against LIST_MAX. On Tcl8 length types are signed hence the
* also checks against 0.
*/
#define LIST_INDEX_ASSERT(idxarg_) \
do { \
Tcl_Size idx_ = (idxarg_); /* To guard against ++ etc. */ \
LIST_ASSERT(idx_ >= 0 && idx_ < LIST_MAX); \
} while (0)
/* Ditto for counts except upper limit is different */
#define LIST_COUNT_ASSERT(countarg_) \
do { \
Tcl_Size count_ = (countarg_); /* To guard against ++ etc. */ \
LIST_ASSERT(count_ >= 0 && count_ <= LIST_MAX); \
} while (0)
#else
#define LIST_ASSERT(cond_) ((void) 0)
#define LIST_INDEX_ASSERT(idx_) ((void) 0)
#define LIST_COUNT_ASSERT(count_) ((void) 0)
|
| ︙ | ︙ | |||
138 139 140 141 142 143 144 | static ListStore *ListStoreReallocate(ListStore *storePtr, Tcl_Size numSlots); static void ListRepValidate(const ListRep *repPtr, const char *file, int lineNum); static void DupListInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void FreeListInternalRep(Tcl_Obj *listPtr); static int SetListFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static void UpdateStringOfList(Tcl_Obj *listPtr); | | | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | static ListStore *ListStoreReallocate(ListStore *storePtr, Tcl_Size numSlots); static void ListRepValidate(const ListRep *repPtr, const char *file, int lineNum); static void DupListInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void FreeListInternalRep(Tcl_Obj *listPtr); static int SetListFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static void UpdateStringOfList(Tcl_Obj *listPtr); static Tcl_Size ListLength(Tcl_Obj *listPtr); /* * The structure below defines the list Tcl object type by means of functions * that can be invoked by generic object code. * * The internal representation of a list object is ListRep defined in tcl.h. */ |
| ︙ | ︙ | |||
528 529 530 531 532 533 534 |
*/
static int
ListLimitExceededError(Tcl_Interp *interp)
{
if (interp != NULL) {
Tcl_SetObjResult(
interp,
| | | 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
*/
static int
ListLimitExceededError(Tcl_Interp *interp)
{
if (interp != NULL) {
Tcl_SetObjResult(
interp,
Tcl_NewStringObj("max length of a Tcl list exceeded", -1));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
return TCL_ERROR;
}
/*
*------------------------------------------------------------------------
|
| ︙ | ︙ | |||
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 |
{
Tcl_Size newCapacity;
ListStore *newStorePtr;
newCapacity = ListStoreUpSize(numSlots);
newStorePtr =
(ListStore *)Tcl_AttemptRealloc(storePtr, LIST_SIZE(newCapacity));
if (newStorePtr == NULL) {
newCapacity = numSlots;
newStorePtr = (ListStore *)Tcl_AttemptRealloc(storePtr,
LIST_SIZE(newCapacity));
if (newStorePtr == NULL)
return NULL;
}
/* Only the capacity has changed, fix it in the header */
| > > > > > > > > > > > > | 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 |
{
Tcl_Size newCapacity;
ListStore *newStorePtr;
newCapacity = ListStoreUpSize(numSlots);
newStorePtr =
(ListStore *)Tcl_AttemptRealloc(storePtr, LIST_SIZE(newCapacity));
/*
* In case above failed keep looping reducing the requested extra space
* by half every time.
*/
while (newStorePtr == NULL && (newCapacity > (numSlots+1))) {
/* Because of loop condition newCapacity can't overflow */
newCapacity = numSlots + ((newCapacity - numSlots) / 2);
newStorePtr =
(ListStore *)Tcl_AttemptRealloc(storePtr, LIST_SIZE(newCapacity));
}
if (newStorePtr == NULL) {
/* Last resort - allcate what was asked */
newCapacity = numSlots;
newStorePtr = (ListStore *)Tcl_AttemptRealloc(storePtr,
LIST_SIZE(newCapacity));
if (newStorePtr == NULL)
return NULL;
}
/* Only the capacity has changed, fix it in the header */
|
| ︙ | ︙ | |||
1439 1440 1441 1442 1443 1444 1445 |
/* Take the opportunity to garbage collect */
/* TODO - we probably do not need the preserveSrcRep here unlike later */
if (!preserveSrcRep) {
/* T:listrep-1.{4,5,8,9},2.{4:7},3.{15:18},4.{7,8} */
ListRepFreeUnreferenced(srcRepPtr);
} /* else T:listrep-2.{4.2,4.3,5.2,5.3,6.2,7.2,8.1} */
| | | | | 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 |
/* Take the opportunity to garbage collect */
/* TODO - we probably do not need the preserveSrcRep here unlike later */
if (!preserveSrcRep) {
/* T:listrep-1.{4,5,8,9},2.{4:7},3.{15:18},4.{7,8} */
ListRepFreeUnreferenced(srcRepPtr);
} /* else T:listrep-2.{4.2,4.3,5.2,5.3,6.2,7.2,8.1} */
if (rangeStart < 0) {
rangeStart = 0;
}
if (rangeEnd >= numSrcElems) {
rangeEnd = numSrcElems - 1;
}
if (rangeStart > rangeEnd) {
/* Empty list of capacity 1. */
ListRepInit(1, NULL, LISTREP_PANIC_ON_FAIL, rangeRepPtr);
return;
}
rangeLen = rangeEnd - rangeStart + 1;
|
| ︙ | ︙ | |||
1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 |
* to a list object.
*
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclListObjRange(
Tcl_Obj *listObj, /* List object to take a range from. */
Tcl_Size rangeStart, /* Index of first element to include. */
Tcl_Size rangeEnd) /* Index of last element to include. */
{
ListRep listRep;
ListRep resultRep;
int isShared;
| > | | 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 |
* to a list object.
*
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclListObjRange(
Tcl_Interp *interp, /* May be NULL. Used for error messages */
Tcl_Obj *listObj, /* List object to take a range from. */
Tcl_Size rangeStart, /* Index of first element to include. */
Tcl_Size rangeEnd) /* Index of last element to include. */
{
ListRep listRep;
ListRep resultRep;
int isShared;
if (TclListObjGetRep(interp, listObj, &listRep) != TCL_OK)
return NULL;
isShared = Tcl_IsShared(listObj);
ListRepRange(&listRep, rangeStart, rangeEnd, isShared, &resultRep);
if (isShared) {
|
| ︙ | ︙ | |||
1774 1775 1776 1777 1778 1779 1780 |
if (Tcl_IsShared(toObj)) {
Tcl_Panic("%s called with shared object", "TclListObjAppendElements");
}
if (TclListObjGetRep(interp, toObj, &listRep) != TCL_OK)
return TCL_ERROR; /* Cannot be converted to a list */
| | | 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 |
if (Tcl_IsShared(toObj)) {
Tcl_Panic("%s called with shared object", "TclListObjAppendElements");
}
if (TclListObjGetRep(interp, toObj, &listRep) != TCL_OK)
return TCL_ERROR; /* Cannot be converted to a list */
if (elemCount <= 0)
return TCL_OK; /* Nothing to do. Note AFTER check for list above */
ListRepElements(&listRep, toLen, toObjv);
if (elemCount > LIST_MAX || toLen > (LIST_MAX - elemCount)) {
return ListLimitExceededError(interp);
}
|
| ︙ | ︙ | |||
1862 1863 1864 1865 1866 1867 1868 |
*/
if (ListRepInit(finalLen,
NULL,
listRep.spanPtr ? LISTREP_SPACE_FAVOR_BACK
: LISTREP_SPACE_ONLY_BACK,
&listRep)
!= TCL_OK) {
| | | 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 |
*/
if (ListRepInit(finalLen,
NULL,
listRep.spanPtr ? LISTREP_SPACE_FAVOR_BACK
: LISTREP_SPACE_ONLY_BACK,
&listRep)
!= TCL_OK) {
return MemoryAllocationError(interp, finalLen);
}
LIST_ASSERT(listRep.storePtr->numAllocated >= finalLen);
if (toLen) {
/* T:listrep-2.{2,9},4.5 */
ObjArrayCopy(ListRepSlotPtr(&listRep, 0), toLen, toObjv);
}
|
| ︙ | ︙ | |||
1887 1888 1889 1890 1891 1892 1893 | } /* *---------------------------------------------------------------------- * * Tcl_ListObjAppendElement -- * | | < < < | > | > > > > > | | | < | > > | < | | | | 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 |
}
/*
*----------------------------------------------------------------------
*
* Tcl_ListObjAppendElement --
*
* Like 'Tcl_ListObjAppendList', but Appends a single value to a list.
*
* Value
*
* TCL_OK
*
* 'objPtr' is appended to the elements of 'listPtr'.
*
* TCL_ERROR
*
* listPtr does not refer to a list object and the object can not be
* converted to one. An error message will be left in the
* interpreter's result if interp is not NULL.
*
* Effect
*
* If 'listPtr' is not already of type 'tclListType', it is converted.
* The 'refCount' of 'objPtr' is incremented as it is added to 'listPtr'.
* Appending the new element may cause the array of element pointers
* in 'listObj' to grow. Any preexisting string representation of
* 'listPtr' is invalidated.
*
*----------------------------------------------------------------------
*/
int
Tcl_ListObjAppendElement(
Tcl_Interp *interp, /* Used to report errors if not NULL. */
Tcl_Obj *toObj, /* List object to append elemObj to. */
|
| ︙ | ︙ | |||
1926 1927 1928 1929 1930 1931 1932 | } /* *---------------------------------------------------------------------- * * Tcl_ListObjIndex -- * | | | < < < | > | > | > | | | > > > | | | > | | 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 |
}
/*
*----------------------------------------------------------------------
*
* Tcl_ListObjIndex --
*
* Retrieve a pointer to the element of 'listPtr' at 'index'. The index
* of the first element is 0.
*
* Value
*
* TCL_OK
*
* A pointer to the element at 'index' is stored in 'objPtrPtr'. If
* 'index' is out of range, NULL is stored in 'objPtrPtr'. This
* object should be treated as readonly and its 'refCount' is _not_
* incremented. The caller must do that if it holds on to the
* reference.
*
* TCL_ERROR
*
* 'listPtr' is not a valid list. An error message is left in the
* interpreter's result if 'interp' is not NULL.
*
* Effect
*
* If 'listPtr' is not already of type 'tclListType', it is converted.
*
*----------------------------------------------------------------------
*/
int
Tcl_ListObjIndex(
Tcl_Interp *interp, /* Used to report errors if not NULL. */
Tcl_Obj *listObj, /* List object to index into. */
|
| ︙ | ︙ | |||
1967 1968 1969 1970 1971 1972 1973 |
* other hand, this code will be faster for the case where the object
* is currently a dict. Benchmark the two cases.
*/
if (TclListObjGetElementsM(interp, listObj, &numElems, &elemObjs)
!= TCL_OK) {
return TCL_ERROR;
}
| | | 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 |
* other hand, this code will be faster for the case where the object
* is currently a dict. Benchmark the two cases.
*/
if (TclListObjGetElementsM(interp, listObj, &numElems, &elemObjs)
!= TCL_OK) {
return TCL_ERROR;
}
if (index < 0 || index >= numElems) {
*objPtrPtr = NULL;
} else {
*objPtrPtr = elemObjs[index];
}
return TCL_OK;
}
|
| ︙ | ︙ | |||
2007 2008 2009 2010 2011 2012 2013 |
Tcl_ListObjLength(
Tcl_Interp *interp, /* Used to report errors if not NULL. */
Tcl_Obj *listObj, /* List object whose #elements to return. */
Tcl_Size *lenPtr) /* The resulting length is stored here. */
{
ListRep listRep;
| | | | | | | 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 |
Tcl_ListObjLength(
Tcl_Interp *interp, /* Used to report errors if not NULL. */
Tcl_Obj *listObj, /* List object whose #elements to return. */
Tcl_Size *lenPtr) /* The resulting length is stored here. */
{
ListRep listRep;
Tcl_Size (*lengthProc)(Tcl_Obj *obj) = ABSTRACTLIST_PROC(listObj, lengthProc);
if (lengthProc) {
*lenPtr = lengthProc(listObj);
return TCL_OK;
}
/*
* TODO
* Unlike the original list code, this does not optimize for lindex'ing
* an empty string when the internal rep is not already a list. On the
* other hand, this code will be faster for the case where the object
* is currently a dict. Benchmark the two cases.
*/
if (TclListObjGetRep(interp, listObj, &listRep) != TCL_OK) {
return TCL_ERROR;
}
*lenPtr = ListRepLength(&listRep);
return TCL_OK;
}
Tcl_Size
ListLength(Tcl_Obj *listPtr)
{
ListRep listRep;
ListObjGetRep(listPtr, &listRep);
return ListRepLength(&listRep);
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
2109 2110 2111 2112 2113 2114 2115 |
if (TclListObjGetRep(interp, listObj, &listRep) != TCL_OK)
return TCL_ERROR; /* Cannot be converted to a list */
/* TODO - will need modification if Tcl9 sticks to unsigned indices */
/* Make limits sane */
origListLen = ListRepLength(&listRep);
| | | | 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 |
if (TclListObjGetRep(interp, listObj, &listRep) != TCL_OK)
return TCL_ERROR; /* Cannot be converted to a list */
/* TODO - will need modification if Tcl9 sticks to unsigned indices */
/* Make limits sane */
origListLen = ListRepLength(&listRep);
if (first < 0) {
first = 0;
}
if (first > origListLen) {
first = origListLen; /* So we'll insert after last element. */
}
if (numToDelete < 0) {
numToDelete = 0;
} else if (first > ListSizeT_MAX - numToDelete /* Handle integer overflow */
|| origListLen < first + numToDelete) {
numToDelete = origListLen - first;
}
if (numToInsert > ListSizeT_MAX - (origListLen - numToDelete)) {
|
| ︙ | ︙ | |||
2359 2360 2361 2362 2363 2364 2365 |
/*
* TODO - below the moves are optimized but this may result in needing a
* span allocation. Perhaps for small lists, it may be more efficient to
* just move everything up front and save on allocating a span.
*/
/*
| | | 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 |
/*
* TODO - below the moves are optimized but this may result in needing a
* span allocation. Perhaps for small lists, it may be more efficient to
* just move everything up front and save on allocating a span.
*/
/*
* Calculate shifts if necessary to accommodate insertions.
* NOTE: all indices are relative to listObjs which is not necessarily the
* start of the ListStore storage area.
*
* leadShift - how much to shift the lead segment
* tailShift - how much to shift the tail segment
* insertTarget - index where to insert.
*/
|
| ︙ | ︙ | |||
2648 2649 2650 2651 2652 2653 2654 |
*
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclLindexFlat(
Tcl_Interp *interp, /* Tcl interpreter. */
Tcl_Obj *listObj, /* Tcl object representing the list. */
| | | 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 |
*
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclLindexFlat(
Tcl_Interp *interp, /* Tcl interpreter. */
Tcl_Obj *listObj, /* Tcl object representing the list. */
Tcl_Size indexCount, /* Count of indices. */
Tcl_Obj *const indexArray[])/* Array of pointers to Tcl objects that
* represent the indices in the list. */
{
Tcl_Size i;
/* Handle AbstractList as special case */
if (ABSTRACTLIST_PROC(listObj,indexProc)) {
|
| ︙ | ︙ | |||
2703 2704 2705 2706 2707 2708 2709 |
break;
}
LIST_ASSERT_TYPE(sublistCopy);
ListObjGetElements(sublistCopy, listLen, elemPtrs);
if (TclGetIntForIndexM(interp, indexArray[i], /*endValue*/ listLen-1,
&index) == TCL_OK) {
| | | 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 |
break;
}
LIST_ASSERT_TYPE(sublistCopy);
ListObjGetElements(sublistCopy, listLen, elemPtrs);
if (TclGetIntForIndexM(interp, indexArray[i], /*endValue*/ listLen-1,
&index) == TCL_OK) {
if (index < 0 || index >= listLen) {
/*
* Index is out of range. Break out of loop with empty result.
* First check remaining indices for validity
*/
while (++i < indexCount) {
if (TclGetIntForIndexM(
|
| ︙ | ︙ | |||
2950 2951 2952 2953 2954 2955 2956 | /* ...the index we're trying to use isn't an index at all. */ result = TCL_ERROR; indexArray++; /* Why bother with this increment? TBD */ break; } indexArray++; | | | 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 |
/* ...the index we're trying to use isn't an index at all. */
result = TCL_ERROR;
indexArray++; /* Why bother with this increment? TBD */
break;
}
indexArray++;
if (index < 0 || index > elemCount
|| (valueObj == NULL && index >= elemCount)) {
/* ...the index points outside the sublist. */
if (interp != NULL) {
Tcl_SetObjResult(interp,
Tcl_ObjPrintf("index \"%s\" out of range",
Tcl_GetString(indexArray[-1])));
Tcl_SetErrorCode(interp,
|
| ︙ | ︙ | |||
3441 3442 3443 3444 3445 3446 3447 | } /* *---------------------------------------------------------------------- * * UpdateStringOfList -- * | | > | | | < < | | | < | 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 |
}
/*
*----------------------------------------------------------------------
*
* UpdateStringOfList --
*
* Update the string representation for a list object.
*
* Any previously-existing string representation is not invalidated, so
* storage is lost if this has not been taken care of.
*
* Effect
*
* The string representation of 'listPtr' is set to the resulting string.
* This string will be empty if the list has no elements. It is assumed
* that the list internal representation is not NULL.
*
*----------------------------------------------------------------------
*/
static void
UpdateStringOfList(
Tcl_Obj *listObj) /* List object with string rep to update. */
{
|
| ︙ | ︙ |
Changes to generic/tclLiteral.c.
| ︙ | ︙ | |||
174 175 176 177 178 179 180 |
*/
Tcl_Obj *
TclCreateLiteral(
Interp *iPtr,
const char *bytes, /* The start of the string. Note that this is
* not a NUL-terminated string. */
| | | | | | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
*/
Tcl_Obj *
TclCreateLiteral(
Interp *iPtr,
const char *bytes, /* The start of the string. Note that this is
* not a NUL-terminated string. */
Tcl_Size length, /* Number of bytes in the string. */
TCL_HASH_TYPE hash, /* The string's hash. If the value is
* TCL_INDEX_NONE, it will be computed here. */
int *newPtr,
Namespace *nsPtr,
int flags,
LiteralEntry **globalPtrPtr)
{
LiteralTable *globalTablePtr = &iPtr->literalTable;
LiteralEntry *globalPtr;
size_t globalHash;
Tcl_Obj *objPtr;
/*
* Is it in the interpreter's global literal table?
*/
if (hash == (TCL_HASH_TYPE) TCL_INDEX_NONE) {
hash = HashString(bytes, length);
}
globalHash = (hash & globalTablePtr->mask);
for (globalPtr=globalTablePtr->buckets[globalHash] ; globalPtr!=NULL;
globalPtr = globalPtr->nextPtr) {
objPtr = globalPtr->objPtr;
if (globalPtr->nsPtr == nsPtr) {
/*
* Literals should always have UTF-8 representations... but this
* is not guaranteed so we need to be careful anyway.
*
* https://stackoverflow.com/q/54337750/301832
*/
Tcl_Size objLength;
const char *objBytes = Tcl_GetStringFromObj(objPtr, &objLength);
if ((objLength == length) && ((length == 0)
|| ((objBytes[0] == bytes[0])
&& (memcmp(objBytes, bytes, length) == 0)))) {
/*
* A literal was found: return it
|
| ︙ | ︙ | |||
347 348 349 350 351 352 353 |
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclFetchLiteral(
CompileEnv *envPtr, /* Points to the CompileEnv from which to
* fetch the registered literal value. */
| | | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclFetchLiteral(
CompileEnv *envPtr, /* Points to the CompileEnv from which to
* fetch the registered literal value. */
Tcl_Size index) /* Index of the desired literal, as returned
* by prior call to TclRegisterLiteral() */
{
if (index >= envPtr->literalArrayNext) {
return NULL;
}
return envPtr->literalArrayPtr[index].objPtr;
}
|
| ︙ | ︙ | |||
383 384 385 386 387 388 389 | * is set directly from string, otherwise the string is freed. Typically, * a caller sets LITERAL_ON_HEAP if "string" is an already heap-allocated * buffer holding the result of backslash substitutions. * *---------------------------------------------------------------------- */ | | | | | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
* is set directly from string, otherwise the string is freed. Typically,
* a caller sets LITERAL_ON_HEAP if "string" is an already heap-allocated
* buffer holding the result of backslash substitutions.
*
*----------------------------------------------------------------------
*/
int /* Do NOT change this type. Should not be wider than TclEmitPush operand*/
TclRegisterLiteral(
void *ePtr, /* Points to the CompileEnv in whose object
* array an object is found or created. */
const char *bytes, /* Points to string for which to find or
* create an object in CompileEnv's object
* array. */
Tcl_Size length, /* Number of bytes in the string. If -1, the
* string consists of all bytes up to the
* first null character. */
int flags) /* If LITERAL_ON_HEAP then the caller already
* malloc'd bytes and ownership is passed to
* this function. If LITERAL_CMD_NAME then
* the literal should not be shared across
* namespaces. */
{
CompileEnv *envPtr = (CompileEnv *)ePtr;
Interp *iPtr = envPtr->iPtr;
LiteralTable *localTablePtr = &envPtr->localLitTable;
LiteralEntry *globalPtr, *localPtr;
Tcl_Obj *objPtr;
size_t hash, localHash, objIndex;
int isNew;
Namespace *nsPtr;
if (length < 0) {
length = (bytes ? strlen(bytes) : 0);
}
hash = HashString(bytes, length);
/*
* Is the literal already in the CompileEnv's local literal array? If so,
* just return its index.
|
| ︙ | ︙ | |||
433 434 435 436 437 438 439 440 441 442 443 444 445 |
Tcl_Free((void *)bytes);
}
objIndex = (localPtr - envPtr->literalArrayPtr);
#ifdef TCL_COMPILE_DEBUG
TclVerifyLocalLiteralTable(envPtr);
#endif /*TCL_COMPILE_DEBUG*/
return objIndex;
}
}
/*
* The literal is new to this CompileEnv. If it is a command name, avoid
| > > > | | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
Tcl_Free((void *)bytes);
}
objIndex = (localPtr - envPtr->literalArrayPtr);
#ifdef TCL_COMPILE_DEBUG
TclVerifyLocalLiteralTable(envPtr);
#endif /*TCL_COMPILE_DEBUG*/
if (objIndex > INT_MAX) {
Tcl_Panic("Literal table index too large. Cannot be handled by TclEmitPush");
}
return objIndex;
}
}
/*
* The literal is new to this CompileEnv. If it is a command name, avoid
* sharing it across namespaces, and try not to share it with non-cmd
* literals. Note that FQ command names can be shared, so that we register
* the namespace as the interp's global NS.
*/
if ((flags & LITERAL_CMD_NAME)) {
if ((length >= 2) && (bytes[0] == ':') && (bytes[1] == ':')) {
nsPtr = iPtr->globalNsPtr;
|
| ︙ | ︙ | |||
471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
if (globalPtr != NULL && (globalPtr->refCount + 1 < 2)) {
Tcl_Panic("%s: global literal \"%.*s\" had bad refCount %" TCL_Z_MODIFIER "u",
"TclRegisterLiteral", (length>60? 60 : (int)length), bytes,
globalPtr->refCount);
}
TclVerifyLocalLiteralTable(envPtr);
#endif /*TCL_COMPILE_DEBUG*/
return objIndex;
}
#ifdef TCL_COMPILE_DEBUG
/*
*----------------------------------------------------------------------
*
| > > > > | 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
if (globalPtr != NULL && (globalPtr->refCount + 1 < 2)) {
Tcl_Panic("%s: global literal \"%.*s\" had bad refCount %" TCL_Z_MODIFIER "u",
"TclRegisterLiteral", (length>60? 60 : (int)length), bytes,
globalPtr->refCount);
}
TclVerifyLocalLiteralTable(envPtr);
#endif /*TCL_COMPILE_DEBUG*/
if (objIndex > INT_MAX) {
Tcl_Panic(
"Literal table index too large. Cannot be handled by TclEmitPush");
}
return objIndex;
}
#ifdef TCL_COMPILE_DEBUG
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
549 550 551 552 553 554 555 |
CompileEnv *envPtr,/* Points to CompileEnv whose literal array
* contains the entry being hidden. */
int index) /* The index of the entry in the literal
* array. */
{
LiteralEntry **nextPtrPtr, *entryPtr, *lPtr;
LiteralTable *localTablePtr = &envPtr->localLitTable;
| | > | 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
CompileEnv *envPtr,/* Points to CompileEnv whose literal array
* contains the entry being hidden. */
int index) /* The index of the entry in the literal
* array. */
{
LiteralEntry **nextPtrPtr, *entryPtr, *lPtr;
LiteralTable *localTablePtr = &envPtr->localLitTable;
size_t localHash;
Tcl_Size length;
const char *bytes;
Tcl_Obj *newObjPtr;
lPtr = &envPtr->literalArrayPtr[index];
/*
* To avoid unwanted sharing we need to copy the object and remove it from
|
| ︙ | ︙ | |||
603 604 605 606 607 608 609 | * Side effects: * Expands the literal array if necessary. Increments the refcount on the * literal object. * *---------------------------------------------------------------------- */ | | > > > > | 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
* Side effects:
* Expands the literal array if necessary. Increments the refcount on the
* literal object.
*
*----------------------------------------------------------------------
*/
int
TclAddLiteralObj(
CompileEnv *envPtr,/* Points to CompileEnv in whose literal array
* the object is to be inserted. */
Tcl_Obj *objPtr, /* The object to insert into the array. */
LiteralEntry **litPtrPtr) /* The location where the pointer to the new
* literal entry should be stored. May be
* NULL. */
{
LiteralEntry *lPtr;
size_t objIndex;
if (envPtr->literalArrayNext >= envPtr->literalArrayEnd) {
ExpandLocalLiteralArray(envPtr);
}
objIndex = envPtr->literalArrayNext;
envPtr->literalArrayNext++;
if (objIndex > INT_MAX) {
Tcl_Panic(
"Literal table index too large. Cannot be handled by TclEmitPush");
}
lPtr = &envPtr->literalArrayPtr[objIndex];
lPtr->objPtr = objPtr;
Tcl_IncrRefCount(objPtr);
lPtr->refCount = TCL_INDEX_NONE; /* i.e., unused */
lPtr->nextPtr = NULL;
|
| ︙ | ︙ | |||
822 823 824 825 826 827 828 |
* previously created by a call to
* TclRegisterLiteral. */
{
Interp *iPtr = (Interp *) interp;
LiteralTable *globalTablePtr;
LiteralEntry *entryPtr, *prevPtr;
const char *bytes;
| | > | 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 |
* previously created by a call to
* TclRegisterLiteral. */
{
Interp *iPtr = (Interp *) interp;
LiteralTable *globalTablePtr;
LiteralEntry *entryPtr, *prevPtr;
const char *bytes;
size_t index;
Tcl_Size length;
if (iPtr == NULL) {
goto done;
}
globalTablePtr = &iPtr->literalTable;
bytes = Tcl_GetStringFromObj(objPtr, &length);
|
| ︙ | ︙ | |||
965 966 967 968 969 970 971 |
/* Local or global table to enlarge. */
{
LiteralEntry **oldBuckets;
LiteralEntry **oldChainPtr, **newChainPtr;
LiteralEntry *entryPtr;
LiteralEntry **bucketPtr;
const char *bytes;
| | > | 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 |
/* Local or global table to enlarge. */
{
LiteralEntry **oldBuckets;
LiteralEntry **oldChainPtr, **newChainPtr;
LiteralEntry *entryPtr;
LiteralEntry **bucketPtr;
const char *bytes;
size_t oldSize, count, index;
Tcl_Size length;
oldSize = tablePtr->numBuckets;
oldBuckets = tablePtr->buckets;
/*
* Allocate and initialize the new bucket array, and set up hashing
* constants for new array size.
|
| ︙ | ︙ | |||
1124 1125 1126 1127 1128 1129 1130 |
}
/*
* Print out the histogram and a few other pieces of information.
*/
result = (char *)Tcl_Alloc(NUM_COUNTERS*60 + 300);
| | | | | | 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 |
}
/*
* Print out the histogram and a few other pieces of information.
*/
result = (char *)Tcl_Alloc(NUM_COUNTERS*60 + 300);
snprintf(result, 60, "%" TCL_Z_MODIFIER "u entries in table, %" TCL_Z_MODIFIER "u buckets\n",
tablePtr->numEntries, tablePtr->numBuckets);
p = result + strlen(result);
for (i=0 ; i<NUM_COUNTERS ; i++) {
snprintf(p, 60, "number of buckets with %" TCL_Z_MODIFIER "u entries: %" TCL_Z_MODIFIER "u\n",
i, count[i]);
p += strlen(p);
}
snprintf(p, 60, "number of buckets with %d or more entries: %" TCL_Z_MODIFIER "u\n",
NUM_COUNTERS, overflow);
p += strlen(p);
snprintf(p, 60, "average search distance for entry: %.1f", average);
return result;
}
#endif /*TCL_COMPILE_STATS*/
#ifdef TCL_COMPILE_DEBUG
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ |
Changes to generic/tclLoad.c.
| ︙ | ︙ | |||
188 189 190 191 192 193 194 |
prefix = TclGetString(objv[2]);
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
prefix = TclGetString(objv[2]);
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must specify either file name or prefix", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD", "NOLIBRARY",
NULL);
code = TCL_ERROR;
goto done;
}
/*
|
| ︙ | ︙ | |||
228 229 230 231 232 233 234 |
defaultPtr = NULL;
for (libraryPtr = firstLibraryPtr; libraryPtr != NULL; libraryPtr = libraryPtr->nextPtr) {
if (prefix == NULL) {
namesMatch = 0;
} else {
TclDStringClear(&pfx);
| | | | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
defaultPtr = NULL;
for (libraryPtr = firstLibraryPtr; libraryPtr != NULL; libraryPtr = libraryPtr->nextPtr) {
if (prefix == NULL) {
namesMatch = 0;
} else {
TclDStringClear(&pfx);
Tcl_DStringAppend(&pfx, prefix, -1);
TclDStringClear(&tmp);
Tcl_DStringAppend(&tmp, libraryPtr->prefix, -1);
if (strcmp(Tcl_DStringValue(&tmp),
Tcl_DStringValue(&pfx)) == 0) {
namesMatch = 1;
} else {
namesMatch = 0;
}
}
|
| ︙ | ︙ | |||
303 304 305 306 307 308 309 |
}
/*
* Figure out the prefix if it wasn't provided explicitly.
*/
if (prefix != NULL) {
| | | | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
}
/*
* Figure out the prefix if it wasn't provided explicitly.
*/
if (prefix != NULL) {
Tcl_DStringAppend(&pfx, prefix, -1);
} else {
Tcl_Obj *splitPtr, *pkgGuessPtr;
Tcl_Size pElements;
const char *pkgGuess;
/*
* Threading note - this call used to be protected by a mutex.
*/
/*
|
| ︙ | ︙ | |||
483 484 485 486 487 488 489 |
Interp *iPtr = (Interp *) target;
if (iPtr->legacyResult && *(iPtr->legacyResult) && !iPtr->legacyFreeProc) {
/*
* A call to Tcl_InitStubs() determined the caller extension and
* this interp are incompatible in their stubs mechanisms, and
* recorded the error in the oldest legacy place we have to do so.
*/
| | | 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
Interp *iPtr = (Interp *) target;
if (iPtr->legacyResult && *(iPtr->legacyResult) && !iPtr->legacyFreeProc) {
/*
* A call to Tcl_InitStubs() determined the caller extension and
* this interp are incompatible in their stubs mechanisms, and
* recorded the error in the oldest legacy place we have to do so.
*/
Tcl_SetObjResult(target, Tcl_NewStringObj(iPtr->legacyResult, -1));
iPtr->legacyResult = NULL;
iPtr->legacyFreeProc = (void (*) (void))-1;
}
Tcl_TransferResult(target, code, interp);
goto done;
}
|
| ︙ | ︙ | |||
621 622 623 624 625 626 627 |
prefix = TclGetString(objv[i+1]);
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
prefix = TclGetString(objv[i+1]);
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must specify either file name or prefix", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NOLIBRARY",
NULL);
code = TCL_ERROR;
goto done;
}
/*
|
| ︙ | ︙ | |||
661 662 663 664 665 666 667 |
for (libraryPtr = firstLibraryPtr; libraryPtr != NULL; libraryPtr = libraryPtr->nextPtr) {
int namesMatch, filesMatch;
if (prefix == NULL) {
namesMatch = 0;
} else {
TclDStringClear(&pfx);
| | | | 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
for (libraryPtr = firstLibraryPtr; libraryPtr != NULL; libraryPtr = libraryPtr->nextPtr) {
int namesMatch, filesMatch;
if (prefix == NULL) {
namesMatch = 0;
} else {
TclDStringClear(&pfx);
Tcl_DStringAppend(&pfx, prefix, -1);
TclDStringClear(&tmp);
Tcl_DStringAppend(&tmp, libraryPtr->prefix, -1);
if (strcmp(Tcl_DStringValue(&tmp),
Tcl_DStringValue(&pfx)) == 0) {
namesMatch = 1;
} else {
namesMatch = 0;
}
}
|
| ︙ | ︙ | |||
1117 1118 1119 1120 1121 1122 1123 |
Tcl_Obj *resultObj, *pkgDesc[2];
if (targetName == NULL) {
TclNewObj(resultObj);
Tcl_MutexLock(&libraryMutex);
for (libraryPtr = firstLibraryPtr; libraryPtr != NULL;
libraryPtr = libraryPtr->nextPtr) {
| | | | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
Tcl_Obj *resultObj, *pkgDesc[2];
if (targetName == NULL) {
TclNewObj(resultObj);
Tcl_MutexLock(&libraryMutex);
for (libraryPtr = firstLibraryPtr; libraryPtr != NULL;
libraryPtr = libraryPtr->nextPtr) {
pkgDesc[0] = Tcl_NewStringObj(libraryPtr->fileName, -1);
pkgDesc[1] = Tcl_NewStringObj(libraryPtr->prefix, -1);
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewListObj(2, pkgDesc));
}
Tcl_MutexUnlock(&libraryMutex);
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
|
| ︙ | ︙ | |||
1143 1144 1145 1146 1147 1148 1149 |
if (prefix) {
resultObj = NULL;
for (; ipPtr != NULL; ipPtr = ipPtr->nextPtr) {
libraryPtr = ipPtr->libraryPtr;
if (!strcmp(prefix, libraryPtr->prefix)) {
| | | | | 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 |
if (prefix) {
resultObj = NULL;
for (; ipPtr != NULL; ipPtr = ipPtr->nextPtr) {
libraryPtr = ipPtr->libraryPtr;
if (!strcmp(prefix, libraryPtr->prefix)) {
resultObj = Tcl_NewStringObj(libraryPtr->fileName, -1);
break;
}
}
if (resultObj) {
Tcl_SetObjResult(interp, resultObj);
}
return TCL_OK;
}
/*
* Return information about only the libraries that are loaded in a given
* interpreter.
*/
TclNewObj(resultObj);
for (; ipPtr != NULL; ipPtr = ipPtr->nextPtr) {
libraryPtr = ipPtr->libraryPtr;
pkgDesc[0] = Tcl_NewStringObj(libraryPtr->fileName, -1);
pkgDesc[1] = Tcl_NewStringObj(libraryPtr->prefix, -1);
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewListObj(2, pkgDesc));
}
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
/*
|
| ︙ | ︙ |
Changes to generic/tclLoadNone.c.
| ︙ | ︙ | |||
77 78 79 80 81 82 83 |
TCL_UNUSED(int),
TCL_UNUSED(Tcl_LoadHandle *),
TCL_UNUSED(Tcl_FSUnloadFileProc **),
TCL_UNUSED(int))
{
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("dynamic loading from memory "
| | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
TCL_UNUSED(int),
TCL_UNUSED(Tcl_LoadHandle *),
TCL_UNUSED(Tcl_FSUnloadFileProc **),
TCL_UNUSED(int))
{
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("dynamic loading from memory "
"is not available on this system", -1));
}
return TCL_ERROR;
}
#endif /* TCL_LOAD_FROM_MEMORY */
/*
|
| ︙ | ︙ |
Changes to generic/tclMain.c.
| ︙ | ︙ | |||
276 277 278 279 280 281 282 | * interpreted. * *---------------------------------------------------------------------- */ TCL_NORETURN void Tcl_MainEx( | | | | | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
* interpreted.
*
*----------------------------------------------------------------------
*/
TCL_NORETURN void
Tcl_MainEx(
Tcl_Size argc, /* Number of arguments. */
TCHAR **argv, /* Array of argument strings. */
Tcl_AppInitProc *appInitProc,
/* Application-specific initialization
* function to call after most initialization
* but before starting to execute commands. */
Tcl_Interp *interp)
{
Tcl_Size i=0; /* argv[i] index */
Tcl_Obj *path, *resultPtr, *argvPtr, *appName;
const char *encodingName = NULL;
int code, exitCode = 0;
Tcl_MainLoopProc *mainLoopProc;
Tcl_Channel chan;
InteractiveState is;
TclpSetInitialEncodings();
if (argc > 0) {
--argc; /* consume argv[0] */
++i;
}
TclpFindExecutable ((const char *)argv [0]); /* nb: this could be NULL
* w/ (eg) an empty argv
* supplied to execve() */
|
| ︙ | ︙ | |||
322 323 324 325 326 327 328 | * Check whether first 3 args (argv[1] - argv[3]) look like * -encoding ENCODING FILENAME * or like * FILENAME */ /* mind argc is being adjusted as we proceed */ | | | | | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
* Check whether first 3 args (argv[1] - argv[3]) look like
* -encoding ENCODING FILENAME
* or like
* FILENAME
*/
/* mind argc is being adjusted as we proceed */
if ((argc >= 3) && (0 == _tcscmp(TEXT("-encoding"), argv[1]))
&& ('-' != argv[3][0])) {
Tcl_Obj *value = NewNativeObj(argv[2]);
Tcl_SetStartupScript(NewNativeObj(argv[3]),
TclGetString(value));
Tcl_DecrRefCount(value);
argc -= 3;
i += 3;
} else if ((argc >= 1) && ('-' != argv[1][0])) {
Tcl_SetStartupScript(NewNativeObj(argv[1]), NULL);
argc--;
i++;
}
}
path = Tcl_GetStartupScript(&encodingName);
if (path != NULL) {
appName = path;
} else if (argv[0]) {
appName = NewNativeObj(argv[0]);
} else {
appName = Tcl_NewStringObj("tclsh", -1);
}
Tcl_SetVar2Ex(interp, "argv0", NULL, appName, TCL_GLOBAL_ONLY);
Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewWideIntObj(argc), TCL_GLOBAL_ONLY);
argvPtr = Tcl_NewListObj(0, NULL);
while (argc--) {
Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(argv[i++]));
}
Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
/*
* Set the "tcl_interactive" variable.
*/
|
| ︙ | ︙ | |||
450 451 452 453 454 455 456 |
*/
Tcl_LinkVar(interp, "tcl_interactive", &is.tty, TCL_LINK_BOOLEAN);
is.input = Tcl_GetStdChannel(TCL_STDIN);
while ((is.input != NULL) && !Tcl_InterpDeleted(interp)) {
mainLoopProc = TclGetMainLoop();
if (mainLoopProc == NULL) {
| | | | 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
*/
Tcl_LinkVar(interp, "tcl_interactive", &is.tty, TCL_LINK_BOOLEAN);
is.input = Tcl_GetStdChannel(TCL_STDIN);
while ((is.input != NULL) && !Tcl_InterpDeleted(interp)) {
mainLoopProc = TclGetMainLoop();
if (mainLoopProc == NULL) {
Tcl_Size length;
if (is.tty) {
Prompt(interp, &is);
if (Tcl_InterpDeleted(interp)) {
break;
}
if (Tcl_LimitExceeded(interp)) {
break;
}
is.input = Tcl_GetStdChannel(TCL_STDIN);
if (is.input == NULL) {
break;
}
}
if (Tcl_IsShared(is.commandPtr)) {
Tcl_DecrRefCount(is.commandPtr);
is.commandPtr = Tcl_DuplicateObj(is.commandPtr);
Tcl_IncrRefCount(is.commandPtr);
}
length = Tcl_GetsObj(is.input, is.commandPtr);
if (length < 0) {
if (Tcl_InputBlocked(is.input)) {
/*
* This can only happen if stdin has been set to
* non-blocking. In that case cycle back and try again.
* This sets up a tight polling loop (since we have no
* event loop running). If this causes bad CPU hogging, we
* might try toggling the blocking on stdin instead.
|
| ︙ | ︙ | |||
736 737 738 739 740 741 742 |
static void
StdinProc(
void *clientData, /* The state of interactive cmd line */
TCL_UNUSED(int) /*mask*/)
{
int code;
| | | | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
static void
StdinProc(
void *clientData, /* The state of interactive cmd line */
TCL_UNUSED(int) /*mask*/)
{
int code;
Tcl_Size length;
InteractiveState *isPtr = (InteractiveState *)clientData;
Tcl_Channel chan = isPtr->input;
Tcl_Obj *commandPtr = isPtr->commandPtr;
Tcl_Interp *interp = isPtr->interp;
if (Tcl_IsShared(commandPtr)) {
Tcl_DecrRefCount(commandPtr);
commandPtr = Tcl_DuplicateObj(commandPtr);
Tcl_IncrRefCount(commandPtr);
}
length = Tcl_GetsObj(chan, commandPtr);
if (length < 0) {
if (Tcl_InputBlocked(chan)) {
return;
}
if (isPtr->tty) {
/*
* Would be better to find a way to exit the mainLoop? Or perhaps
* evaluate [exit]? Leaving as is for now due to compatibility
|
| ︙ | ︙ |
Changes to generic/tclNamesp.c.
| ︙ | ︙ | |||
406 407 408 409 410 411 412 |
/*
* Decrement the namespace's count of active call frames. If the namespace
* is "dying" and there are no more active call frames, call
* Tcl_DeleteNamespace to destroy it.
*/
nsPtr = framePtr->nsPtr;
| | | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
/*
* Decrement the namespace's count of active call frames. If the namespace
* is "dying" and there are no more active call frames, call
* Tcl_DeleteNamespace to destroy it.
*/
nsPtr = framePtr->nsPtr;
if ((--nsPtr->activationCount <= (nsPtr == iPtr->globalNsPtr))
&& (nsPtr->flags & NS_DYING)) {
Tcl_DeleteNamespace((Tcl_Namespace *) nsPtr);
}
framePtr->nsPtr = NULL;
if (framePtr->tailcallPtr) {
/* Reusing the existing reference count from framePtr->tailcallPtr, so
|
| ︙ | ︙ | |||
694 695 696 697 698 699 700 |
* Ensure that there are no trailing colons as that causes chaos when a
* deleteProc is specified. [Bug d614d63989]
*/
if (deleteProc != NULL) {
nameStr = name + strlen(name) - 2;
if (nameStr >= name && nameStr[1] == ':' && nameStr[0] == ':') {
| | | | 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 |
* Ensure that there are no trailing colons as that causes chaos when a
* deleteProc is specified. [Bug d614d63989]
*/
if (deleteProc != NULL) {
nameStr = name + strlen(name) - 2;
if (nameStr >= name && nameStr[1] == ':' && nameStr[0] == ':') {
Tcl_DStringAppend(&tmpBuffer, name, -1);
while ((nameLen = Tcl_DStringLength(&tmpBuffer)) > 0
&& Tcl_DStringValue(&tmpBuffer)[nameLen-1] == ':') {
Tcl_DStringSetLength(&tmpBuffer, nameLen-1);
}
name = Tcl_DStringValue(&tmpBuffer);
}
}
/*
* If we've ended up with an empty string now, we're attempting to create
* the global namespace despite the global namespace existing. That's
* naughty!
*/
if (*name == '\0') {
Tcl_SetObjResult(interp, Tcl_NewStringObj("can't create namespace"
" \"\": only global namespace can have empty name", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "NAMESPACE",
"CREATEGLOBAL", NULL);
Tcl_DStringFree(&tmpBuffer);
return NULL;
}
/*
|
| ︙ | ︙ | |||
829 830 831 832 833 834 835 |
buffPtr = &buffer2;
for (ancestorPtr = nsPtr; ancestorPtr != NULL;
ancestorPtr = ancestorPtr->parentPtr) {
if (ancestorPtr != globalNsPtr) {
Tcl_DString *tempPtr = namePtr;
TclDStringAppendLiteral(buffPtr, "::");
| | | 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 |
buffPtr = &buffer2;
for (ancestorPtr = nsPtr; ancestorPtr != NULL;
ancestorPtr = ancestorPtr->parentPtr) {
if (ancestorPtr != globalNsPtr) {
Tcl_DString *tempPtr = namePtr;
TclDStringAppendLiteral(buffPtr, "::");
Tcl_DStringAppend(buffPtr, ancestorPtr->name, -1);
TclDStringAppendDString(buffPtr, namePtr);
/*
* Clear the unwanted buffer or we end up appending to previous
* results, making the namespace fullNames of nested namespaces
* very wrong (and strange).
*/
|
| ︙ | ︙ | |||
1002 1003 1004 1005 1006 1007 1008 |
* nonzero, the namespace's commands and variables are deleted but the
* structure isn't freed. Instead, NS_DEAD is OR'd into the structure's
* flags to allow the namespace resolution code to recognize that the
* namespace is "deleted". The structure's storage is freed by
* FreeNsNameInternalRep when its refCount reaches 0.
*/
| | | 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
* nonzero, the namespace's commands and variables are deleted but the
* structure isn't freed. Instead, NS_DEAD is OR'd into the structure's
* flags to allow the namespace resolution code to recognize that the
* namespace is "deleted". The structure's storage is freed by
* FreeNsNameInternalRep when its refCount reaches 0.
*/
if (nsPtr->activationCount > (nsPtr == globalNsPtr)) {
nsPtr->flags |= NS_DYING;
if (nsPtr->parentPtr != NULL) {
entryPtr = Tcl_FindHashEntry(
TclGetNamespaceChildTable((Tcl_Namespace *)
nsPtr->parentPtr), nsPtr->name);
if (entryPtr != NULL) {
Tcl_DeleteHashEntry(entryPtr);
|
| ︙ | ︙ | |||
1181 1182 1183 1184 1185 1186 1187 |
TclTeardownNamespace(
Namespace *nsPtr) /* Points to the namespace to be dismantled
* and unlinked from its parent. */
{
Interp *iPtr = (Interp *) nsPtr->interp;
Tcl_HashEntry *entryPtr;
Tcl_HashSearch search;
| | | | 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 |
TclTeardownNamespace(
Namespace *nsPtr) /* Points to the namespace to be dismantled
* and unlinked from its parent. */
{
Interp *iPtr = (Interp *) nsPtr->interp;
Tcl_HashEntry *entryPtr;
Tcl_HashSearch search;
Tcl_Size i;
/*
* Start by destroying the namespace's variable table, since variables
* might trigger traces. Variable table should be cleared but not freed!
* TclDeleteNamespaceVars frees it, so we reinitialize it afterwards.
*/
TclDeleteNamespaceVars(nsPtr);
TclInitVarHashTable(&nsPtr->varTable, nsPtr);
/*
* Delete all commands in this namespace. Be careful when traversing the
* hash table: when each command is deleted, it removes itself from the
* command table. Because of traces (and the desire to avoid the quadratic
* problems of just using Tcl_FirstHashEntry over and over, [Bug
* f97d4ee020]) we copy to a temporary array and then delete all those
* commands.
*/
while (nsPtr->cmdTable.numEntries > 0) {
Tcl_Size length = nsPtr->cmdTable.numEntries;
Command **cmds = (Command **)TclStackAlloc((Tcl_Interp *) iPtr,
sizeof(Command *) * length);
i = 0;
for (entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search);
entryPtr != NULL;
entryPtr = Tcl_NextHashEntry(&search)) {
|
| ︙ | ︙ | |||
1392 1393 1394 1395 1396 1397 1398 |
* list before appending. */
{
#define INIT_EXPORT_PATTERNS 5
Namespace *nsPtr, *exportNsPtr, *dummyPtr;
Namespace *currNsPtr = (Namespace *) TclGetCurrentNamespace(interp);
const char *simplePattern;
char *patternCpy;
| | | 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 |
* list before appending. */
{
#define INIT_EXPORT_PATTERNS 5
Namespace *nsPtr, *exportNsPtr, *dummyPtr;
Namespace *currNsPtr = (Namespace *) TclGetCurrentNamespace(interp);
const char *simplePattern;
char *patternCpy;
Tcl_Size neededElems, len, i;
/*
* If the specified namespace is NULL, use the current namespace.
*/
if (namespacePtr == NULL) {
nsPtr = (Namespace *) currNsPtr;
|
| ︙ | ︙ | |||
1519 1520 1521 1522 1523 1524 1525 |
Tcl_Namespace *namespacePtr,/* Points to the namespace whose export
* pattern list is appended onto objPtr. NULL
* for the current namespace. */
Tcl_Obj *objPtr) /* Points to the Tcl object onto which the
* export pattern list is appended. */
{
Namespace *nsPtr;
| | | | 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 |
Tcl_Namespace *namespacePtr,/* Points to the namespace whose export
* pattern list is appended onto objPtr. NULL
* for the current namespace. */
Tcl_Obj *objPtr) /* Points to the Tcl object onto which the
* export pattern list is appended. */
{
Namespace *nsPtr;
Tcl_Size i;
int result;
/*
* If the specified namespace is NULL, use the current namespace.
*/
if (namespacePtr == NULL) {
nsPtr = (Namespace *) TclGetCurrentNamespace(interp);
} else {
nsPtr = (Namespace *) namespacePtr;
}
/*
* Append the export pattern list onto objPtr.
*/
for (i = 0; i < nsPtr->numExportPatterns; i++) {
result = Tcl_ListObjAppendElement(interp, objPtr,
Tcl_NewStringObj(nsPtr->exportArrayPtr[i], -1));
if (result != TCL_OK) {
return result;
}
}
return TCL_OK;
}
|
| ︙ | ︙ | |||
1617 1618 1619 1620 1621 1622 1623 |
*/
if (Tcl_FindCommand(interp,"auto_import",NULL,TCL_GLOBAL_ONLY) != NULL) {
Tcl_Obj *objv[2];
int result;
TclNewLiteralStringObj(objv[0], "auto_import");
| | | 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 |
*/
if (Tcl_FindCommand(interp,"auto_import",NULL,TCL_GLOBAL_ONLY) != NULL) {
Tcl_Obj *objv[2];
int result;
TclNewLiteralStringObj(objv[0], "auto_import");
objv[1] = Tcl_NewStringObj(pattern, -1);
Tcl_IncrRefCount(objv[0]);
Tcl_IncrRefCount(objv[1]);
result = Tcl_EvalObjv(interp, 2, objv, TCL_GLOBAL_ONLY);
Tcl_DecrRefCount(objv[0]);
Tcl_DecrRefCount(objv[1]);
|
| ︙ | ︙ | |||
1722 1723 1724 1725 1726 1727 1728 |
Namespace *nsPtr,
Tcl_HashEntry *hPtr,
const char *cmdName,
const char *pattern,
Namespace *importNsPtr,
int allowOverwrite)
{
| | | 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 |
Namespace *nsPtr,
Tcl_HashEntry *hPtr,
const char *cmdName,
const char *pattern,
Namespace *importNsPtr,
int allowOverwrite)
{
Tcl_Size i = 0, exported = 0;
Tcl_HashEntry *found;
/*
* The command cmdName in the source namespace matches the pattern. Check
* whether it was exported. If it wasn't, we ignore it.
*/
|
| ︙ | ︙ | |||
1758 1759 1760 1761 1762 1763 1764 | Tcl_DString ds; Tcl_Command importedCmd; ImportedCmdData *dataPtr; Command *cmdPtr; ImportRef *refPtr; Tcl_DStringInit(&ds); | | | | 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 |
Tcl_DString ds;
Tcl_Command importedCmd;
ImportedCmdData *dataPtr;
Command *cmdPtr;
ImportRef *refPtr;
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, nsPtr->fullName, -1);
if (nsPtr != ((Interp *) interp)->globalNsPtr) {
TclDStringAppendLiteral(&ds, "::");
}
Tcl_DStringAppend(&ds, cmdName, -1);
/*
* Check whether creating the new imported command in the current
* namespace would create a cycle of imported command references.
*/
cmdPtr = (Command *)Tcl_GetHashValue(hPtr);
|
| ︙ | ︙ | |||
2634 2635 2636 2637 2638 2639 2640 |
/*
* Find the namespace(s) that contain the command.
*/
cmdPtr = NULL;
if (cxtNsPtr->commandPathLength!=0 && strncmp(name, "::", 2)
&& !(flags & TCL_NAMESPACE_ONLY)) {
| | | 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 |
/*
* Find the namespace(s) that contain the command.
*/
cmdPtr = NULL;
if (cxtNsPtr->commandPathLength!=0 && strncmp(name, "::", 2)
&& !(flags & TCL_NAMESPACE_ONLY)) {
Tcl_Size i;
Namespace *pathNsPtr, *realNsPtr, *dummyNsPtr;
(void) TclGetNamespaceForQualName(interp, name, cxtNsPtr,
TCL_NAMESPACE_ONLY, &realNsPtr, &dummyNsPtr, &dummyNsPtr,
&simpleName);
if ((realNsPtr != NULL) && (simpleName != NULL)) {
if ((cxtNsPtr == realNsPtr)
|
| ︙ | ︙ | |||
3045 3046 3047 3048 3049 3050 3051 |
Tcl_DStringInit(&buffer);
if (objc == 3) {
const char *name = TclGetString(objv[2]);
if ((*name == ':') && (*(name+1) == ':')) {
pattern = name;
} else {
| | | | 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 |
Tcl_DStringInit(&buffer);
if (objc == 3) {
const char *name = TclGetString(objv[2]);
if ((*name == ':') && (*(name+1) == ':')) {
pattern = name;
} else {
Tcl_DStringAppend(&buffer, nsPtr->fullName, -1);
if (nsPtr != globalNsPtr) {
TclDStringAppendLiteral(&buffer, "::");
}
Tcl_DStringAppend(&buffer, name, -1);
pattern = Tcl_DStringValue(&buffer);
}
}
/*
* Create a list containing the full names of all child namespaces whose
* names match the specified pattern, if any.
|
| ︙ | ︙ | |||
3075 3076 3077 3078 3079 3080 3081 |
Tcl_FindHashEntry(&nsPtr->childTable, pattern+length) != NULL
#else
nsPtr->childTablePtr != NULL &&
Tcl_FindHashEntry(nsPtr->childTablePtr, pattern+length) != NULL
#endif
) {
Tcl_ListObjAppendElement(interp, listPtr,
| | | | 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 |
Tcl_FindHashEntry(&nsPtr->childTable, pattern+length) != NULL
#else
nsPtr->childTablePtr != NULL &&
Tcl_FindHashEntry(nsPtr->childTablePtr, pattern+length) != NULL
#endif
) {
Tcl_ListObjAppendElement(interp, listPtr,
Tcl_NewStringObj(pattern, -1));
}
goto searchDone;
}
#ifndef BREAK_NAMESPACE_COMPAT
entryPtr = Tcl_FirstHashEntry(&nsPtr->childTable, &search);
#else
if (nsPtr->childTablePtr == NULL) {
goto searchDone;
}
entryPtr = Tcl_FirstHashEntry(nsPtr->childTablePtr, &search);
#endif
while (entryPtr != NULL) {
childNsPtr = (Namespace *)Tcl_GetHashValue(entryPtr);
if ((pattern == NULL)
|| Tcl_StringMatch(childNsPtr->fullName, pattern)) {
elemPtr = Tcl_NewStringObj(childNsPtr->fullName, -1);
Tcl_ListObjAppendElement(interp, listPtr, elemPtr);
}
entryPtr = Tcl_NextHashEntry(&search);
}
searchDone:
Tcl_SetObjResult(interp, listPtr);
|
| ︙ | ︙ | |||
3141 3142 3143 3144 3145 3146 3147 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Namespace *currNsPtr;
Tcl_Obj *listPtr, *objPtr;
const char *arg;
| | | 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Namespace *currNsPtr;
Tcl_Obj *listPtr, *objPtr;
const char *arg;
Tcl_Size length;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "arg");
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
3181 3182 3183 3184 3185 3186 3187 |
TclNewLiteralStringObj(objPtr, "inscope");
Tcl_ListObjAppendElement(interp, listPtr, objPtr);
currNsPtr = (Namespace *) TclGetCurrentNamespace(interp);
if (currNsPtr == (Namespace *) TclGetGlobalNamespace(interp)) {
TclNewLiteralStringObj(objPtr, "::");
} else {
| | | 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 |
TclNewLiteralStringObj(objPtr, "inscope");
Tcl_ListObjAppendElement(interp, listPtr, objPtr);
currNsPtr = (Namespace *) TclGetCurrentNamespace(interp);
if (currNsPtr == (Namespace *) TclGetGlobalNamespace(interp)) {
TclNewLiteralStringObj(objPtr, "::");
} else {
objPtr = Tcl_NewStringObj(currNsPtr->fullName, -1);
}
Tcl_ListObjAppendElement(interp, listPtr, objPtr);
Tcl_ListObjAppendElement(interp, listPtr, objv[1]);
Tcl_SetObjResult(interp, listPtr);
return TCL_OK;
|
| ︙ | ︙ | |||
3239 3240 3241 3242 3243 3244 3245 |
* namespace [namespace current]::bar { ... }
*/
currNsPtr = (Namespace *) TclGetCurrentNamespace(interp);
if (currNsPtr == (Namespace *) TclGetGlobalNamespace(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("::", 2));
} else {
| | | 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 |
* namespace [namespace current]::bar { ... }
*/
currNsPtr = (Namespace *) TclGetCurrentNamespace(interp);
if (currNsPtr == (Namespace *) TclGetGlobalNamespace(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("::", 2));
} else {
Tcl_SetObjResult(interp, Tcl_NewStringObj(currNsPtr->fullName, -1));
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
3995 3996 3997 3998 3999 4000 4001 |
/*
* Report the parent of the specified namespace.
*/
if (nsPtr->parentPtr != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 |
/*
* Report the parent of the specified namespace.
*/
if (nsPtr->parentPtr != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
nsPtr->parentPtr->fullName, -1));
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
4035 4036 4037 4038 4039 4040 4041 |
NamespacePathCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Namespace *nsPtr = (Namespace *) TclGetCurrentNamespace(interp);
| | | | 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 |
NamespacePathCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Namespace *nsPtr = (Namespace *) TclGetCurrentNamespace(interp);
Tcl_Size nsObjc, i;
int result = TCL_ERROR;
Tcl_Obj **nsObjv;
Tcl_Namespace **namespaceList = NULL;
if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?pathList?");
return TCL_ERROR;
}
/*
* If no path is given, return the current path.
*/
if (objc == 1) {
Tcl_Obj *resultObj;
TclNewObj(resultObj);
for (i=0 ; i<nsPtr->commandPathLength ; i++) {
if (nsPtr->commandPathArray[i].nsPtr != NULL) {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
nsPtr->commandPathArray[i].nsPtr->fullName, -1));
}
}
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
4119 4120 4121 4122 4123 4124 4125 |
*
*----------------------------------------------------------------------
*/
void
TclSetNsPath(
Namespace *nsPtr, /* Namespace whose path is to be set. */
| | | | 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 |
*
*----------------------------------------------------------------------
*/
void
TclSetNsPath(
Namespace *nsPtr, /* Namespace whose path is to be set. */
Tcl_Size pathLength, /* Length of pathAry. */
Tcl_Namespace *pathAry[]) /* Array of namespaces that are the path. */
{
if (pathLength != 0) {
NamespacePathEntry *tmpPathArray =
(NamespacePathEntry *)Tcl_Alloc(sizeof(NamespacePathEntry) * pathLength);
Tcl_Size i;
for (i=0 ; i<pathLength ; i++) {
tmpPathArray[i].nsPtr = (Namespace *) pathAry[i];
tmpPathArray[i].creatorNsPtr = nsPtr;
tmpPathArray[i].prevPtr = NULL;
tmpPathArray[i].nextPtr =
tmpPathArray[i].nsPtr->commandPathSourceList;
|
| ︙ | ︙ | |||
4176 4177 4178 4179 4180 4181 4182 |
*----------------------------------------------------------------------
*/
static void
UnlinkNsPath(
Namespace *nsPtr)
{
| | | 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 |
*----------------------------------------------------------------------
*/
static void
UnlinkNsPath(
Namespace *nsPtr)
{
Tcl_Size i;
for (i=0 ; i<nsPtr->commandPathLength ; i++) {
NamespacePathEntry *nsPathPtr = &nsPtr->commandPathArray[i];
if (nsPathPtr->prevPtr != NULL) {
nsPathPtr->prevPtr->nextPtr = nsPathPtr->nextPtr;
}
if (nsPathPtr->nextPtr != NULL) {
|
| ︙ | ︙ | |||
4209 4210 4211 4212 4213 4214 4215 | * * Results: * nothing * * Side effects: * Increments the command reference epoch in each namespace whose path * includes the given namespace. This causes any cached resolved names | | | 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 | * * Results: * nothing * * Side effects: * Increments the command reference epoch in each namespace whose path * includes the given namespace. This causes any cached resolved names * whose root caching context starts at that namespace to be recomputed * the next time they are used. * *---------------------------------------------------------------------- */ void TclInvalidateNsPath( |
| ︙ | ︙ | |||
4282 4283 4284 4285 4286 4287 4288 |
for (p = name; *p != '\0'; p++) {
/* empty body */
}
while (--p >= name) {
if ((*p == ':') && (p > name) && (*(p-1) == ':')) {
p -= 2; /* Back up over the :: */
while ((p >= name) && (*p == ':')) {
| | | 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 |
for (p = name; *p != '\0'; p++) {
/* empty body */
}
while (--p >= name) {
if ((*p == ':') && (p > name) && (*(p-1) == ':')) {
p -= 2; /* Back up over the :: */
while ((p >= name) && (*p == ':')) {
p--; /* Back up over the preceding : */
}
break;
}
}
if (p >= name) {
length = p-name+1;
|
| ︙ | ︙ | |||
4427 4428 4429 4430 4431 4432 4433 |
int
Tcl_SetNamespaceUnknownHandler(
Tcl_Interp *interp, /* Interpreter in which the namespace
* exists. */
Tcl_Namespace *nsPtr, /* Namespace which is being updated. */
Tcl_Obj *handlerPtr) /* The new handler, or NULL to reset. */
{
| | | 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 |
int
Tcl_SetNamespaceUnknownHandler(
Tcl_Interp *interp, /* Interpreter in which the namespace
* exists. */
Tcl_Namespace *nsPtr, /* Namespace which is being updated. */
Tcl_Obj *handlerPtr) /* The new handler, or NULL to reset. */
{
Tcl_Size lstlen = 0;
Namespace *currNsPtr = (Namespace *) nsPtr;
/*
* Ensure that we check for errors *first* before we change anything.
*/
if (handlerPtr != NULL) {
|
| ︙ | ︙ | |||
4540 4541 4542 4543 4544 4545 4546 |
if ((*p == ':') && (*(p-1) == ':')) {
p++; /* Just after the last "::" */
break;
}
}
if (p >= name) {
| | | | 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 |
if ((*p == ':') && (*(p-1) == ':')) {
p++; /* Just after the last "::" */
break;
}
}
if (p >= name) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(p, -1));
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* NamespaceUpvarCmd --
*
* Invoked to implement the "namespace upvar" command, that creates
* variables in the current scope linked to variables in another
* namespace. Handles the following syntax:
*
* namespace upvar ns otherVar myVar ?otherVar myVar ...?
*
* Results:
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
* Creates new variables in the current scope, linked to the
* corresponding variables in the stipulated namespace. If anything goes
* wrong, the result is an error message.
*
*----------------------------------------------------------------------
*/
static int
NamespaceUpvarCmd(
|
| ︙ | ︙ | |||
4923 4924 4925 4926 4927 4928 4929 |
void
TclLogCommandInfo(
Tcl_Interp *interp, /* Interpreter in which to log information. */
const char *script, /* First character in script containing
* command (must be <= command). */
const char *command, /* First character in command that generated
* the error. */
| | | | 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 |
void
TclLogCommandInfo(
Tcl_Interp *interp, /* Interpreter in which to log information. */
const char *script, /* First character in script containing
* command (must be <= command). */
const char *command, /* First character in command that generated
* the error. */
Tcl_Size length, /* Number of bytes in command (< 0 means use
* all bytes up to first null byte).
*/
const unsigned char *pc, /* Current pc of bytecode execution context */
Tcl_Obj **tosPtr) /* Current stack of bytecode execution
* context */
{
const char *p;
Interp *iPtr = (Interp *) interp;
|
| ︙ | ︙ | |||
4956 4957 4958 4959 4960 4961 4962 |
iPtr->errorLine = 1;
for (p = script; p != command; p++) {
if (*p == '\n') {
iPtr->errorLine++;
}
}
| | | | 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 |
iPtr->errorLine = 1;
for (p = script; p != command; p++) {
if (*p == '\n') {
iPtr->errorLine++;
}
}
if (length < 0) {
length = strlen(command);
}
overflow = (length > limit);
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n %s\n\"%.*s%s\"", ((iPtr->errorInfo == NULL)
? "while executing" : "invoked from within"),
(overflow ? limit : (int)length), command,
(overflow ? "..." : "")));
varPtr = TclObjLookupVarEx(interp, iPtr->eiVar, NULL, TCL_GLOBAL_ONLY,
|
| ︙ | ︙ | |||
5009 5010 5011 5012 5013 5014 5015 |
newObj = Tcl_DuplicateObj(iPtr->errorStack);
Tcl_DecrRefCount(iPtr->errorStack);
Tcl_IncrRefCount(newObj);
iPtr->errorStack = newObj;
}
if (iPtr->resetErrorStack) {
| | | 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 |
newObj = Tcl_DuplicateObj(iPtr->errorStack);
Tcl_DecrRefCount(iPtr->errorStack);
Tcl_IncrRefCount(newObj);
iPtr->errorStack = newObj;
}
if (iPtr->resetErrorStack) {
Tcl_Size len;
iPtr->resetErrorStack = 0;
TclListObjLengthM(interp, iPtr->errorStack, &len);
/*
* Reset while keeping the list internalrep as much as possible.
*/
|
| ︙ | ︙ | |||
5081 5082 5083 5084 5085 5086 5087 |
*----------------------------------------------------------------------
*/
void
TclErrorStackResetIf(
Tcl_Interp *interp,
const char *msg,
| | | | 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 |
*----------------------------------------------------------------------
*/
void
TclErrorStackResetIf(
Tcl_Interp *interp,
const char *msg,
Tcl_Size length)
{
Interp *iPtr = (Interp *) interp;
if (Tcl_IsShared(iPtr->errorStack)) {
Tcl_Obj *newObj;
newObj = Tcl_DuplicateObj(iPtr->errorStack);
Tcl_DecrRefCount(iPtr->errorStack);
Tcl_IncrRefCount(newObj);
iPtr->errorStack = newObj;
}
if (iPtr->resetErrorStack) {
Tcl_Size len;
iPtr->resetErrorStack = 0;
TclListObjLengthM(interp, iPtr->errorStack, &len);
/*
* Reset while keeping the list internalrep as much as possible.
*/
|
| ︙ | ︙ | |||
5136 5137 5138 5139 5140 5141 5142 |
void
Tcl_LogCommandInfo(
Tcl_Interp *interp, /* Interpreter in which to log information. */
const char *script, /* First character in script containing
* command (must be <= command). */
const char *command, /* First character in command that generated
* the error. */
| | | 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 |
void
Tcl_LogCommandInfo(
Tcl_Interp *interp, /* Interpreter in which to log information. */
const char *script, /* First character in script containing
* command (must be <= command). */
const char *command, /* First character in command that generated
* the error. */
Tcl_Size length) /* Number of bytes in command (-1 means use
* all bytes up to first null byte). */
{
TclLogCommandInfo(interp, script, command, length, NULL, NULL);
}
/*
|
| ︙ | ︙ |
Changes to generic/tclNotify.c.
| ︙ | ︙ | |||
1023 1024 1025 1026 1027 1028 1029 |
}
}
if (flags & TCL_DONT_WAIT) {
break;
}
/*
| | | | | | | | 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 |
}
}
if (flags & TCL_DONT_WAIT) {
break;
}
/*
* If Tcl_WaitForEvent has returned 1, indicating that one system event
* has been dispatched (and thus that some Tcl code might have been
* indirectly executed), we break out of the loop in order, e.g. to
* give vwait a chance to determine whether that system event had the
* side effect of changing the variable (so the vwait can return and
* unwind properly).
*
* NB: We will process idle events if any first, because otherwise we
* might never do the idle events if the notifier always gets
* system events.
*/
if (result) {
|
| ︙ | ︙ |
Changes to generic/tclOO.c.
| ︙ | ︙ | |||
348 349 350 351 352 353 354 |
/*
* Create the subcommands in the oo::define and oo::objdefine spaces.
*/
Tcl_DStringInit(&buffer);
for (i = 0 ; defineCmds[i].name ; i++) {
TclDStringAppendLiteral(&buffer, "::oo::define::");
| | | | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
/*
* Create the subcommands in the oo::define and oo::objdefine spaces.
*/
Tcl_DStringInit(&buffer);
for (i = 0 ; defineCmds[i].name ; i++) {
TclDStringAppendLiteral(&buffer, "::oo::define::");
Tcl_DStringAppend(&buffer, defineCmds[i].name, -1);
Tcl_CreateObjCommand(interp, Tcl_DStringValue(&buffer),
defineCmds[i].objProc, INT2PTR(defineCmds[i].flag), NULL);
Tcl_DStringFree(&buffer);
}
for (i = 0 ; objdefCmds[i].name ; i++) {
TclDStringAppendLiteral(&buffer, "::oo::objdefine::");
Tcl_DStringAppend(&buffer, objdefCmds[i].name, -1);
Tcl_CreateObjCommand(interp, Tcl_DStringValue(&buffer),
objdefCmds[i].objProc, INT2PTR(objdefCmds[i].flag), NULL);
Tcl_DStringFree(&buffer);
}
Tcl_CallWhenDeleted(interp, KillFoundation, NULL);
|
| ︙ | ︙ | |||
650 651 652 653 654 655 656 |
}
Tcl_ResetResult(interp);
}
while (1) {
char objName[10 + TCL_INTEGER_SPACE];
| | | 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
}
Tcl_ResetResult(interp);
}
while (1) {
char objName[10 + TCL_INTEGER_SPACE];
snprintf(objName, sizeof(objName), "::oo::Obj%" TCL_Z_MODIFIER "u", ++fPtr->tsdPtr->nsCount);
oPtr->namespacePtr = Tcl_CreateNamespace(interp, objName, oPtr, NULL);
if (oPtr->namespacePtr != NULL) {
creationEpoch = fPtr->tsdPtr->nsCount;
break;
}
/*
|
| ︙ | ︙ | |||
956 957 958 959 960 961 962 |
void
TclOOReleaseClassContents(
Tcl_Interp *interp, /* The interpreter containing the class. */
Object *oPtr) /* The object representing the class. */
{
FOREACH_HASH_DECLS;
| | | 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 |
void
TclOOReleaseClassContents(
Tcl_Interp *interp, /* The interpreter containing the class. */
Object *oPtr) /* The object representing the class. */
{
FOREACH_HASH_DECLS;
Tcl_Size i;
Class *clsPtr = oPtr->classPtr, *tmpClsPtr;
Method *mPtr;
Foundation *fPtr = oPtr->fPtr;
Tcl_Obj *variableObj;
PrivateVariableMapping *privateVariable;
/*
|
| ︙ | ︙ | |||
1117 1118 1119 1120 1121 1122 1123 |
Foundation *fPtr = oPtr->fPtr;
FOREACH_HASH_DECLS;
Class *mixinPtr;
Method *mPtr;
Tcl_Obj *filterObj, *variableObj;
PrivateVariableMapping *privateVariable;
Tcl_Interp *interp = oPtr->fPtr->interp;
| | | | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 |
Foundation *fPtr = oPtr->fPtr;
FOREACH_HASH_DECLS;
Class *mixinPtr;
Method *mPtr;
Tcl_Obj *filterObj, *variableObj;
PrivateVariableMapping *privateVariable;
Tcl_Interp *interp = oPtr->fPtr->interp;
Tcl_Size i;
if (Destructing(oPtr)) {
/*
* TODO: Can ObjectNamespaceDeleted ever be called twice? If not,
* this guard could be removed.
*/
return;
}
/*
* One rule for the teardown routines is that if an object is in the
* process of being deleted, nothing else may modify its bookkeeping
* records. This is the flag that
*/
oPtr->flags |= OBJECT_DESTRUCTING;
/*
* Let the dominoes fall!
|
| ︙ | ︙ | |||
1183 1184 1185 1186 1187 1188 1189 |
* still exists) because otherwise its pointer to the object points into
* freed memory.
*/
if (((Command *) oPtr->command)->flags && CMD_DYING) {
/*
* Something has already started the command deletion process. We can
| | | 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 |
* still exists) because otherwise its pointer to the object points into
* freed memory.
*/
if (((Command *) oPtr->command)->flags && CMD_DYING) {
/*
* Something has already started the command deletion process. We can
* go ahead and clean up the namespace,
*/
} else {
/*
* The namespace must have been deleted directly. Delete the command
* as well.
*/
|
| ︙ | ︙ | |||
1358 1359 1360 1361 1362 1363 1364 |
int
TclOORemoveFromInstances(
Object *oPtr, /* The instance to remove. */
Class *clsPtr) /* The class (possibly) containing the
* reference to the instance. */
{
| | | 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 |
int
TclOORemoveFromInstances(
Object *oPtr, /* The instance to remove. */
Class *clsPtr) /* The class (possibly) containing the
* reference to the instance. */
{
Tcl_Size i;
int res = 0;
Object *instPtr;
FOREACH(instPtr, clsPtr->instances) {
if (oPtr == instPtr) {
RemoveItem(Object, clsPtr->instances, i);
TclOODecrRefCount(oPtr);
|
| ︙ | ︙ | |||
1421 1422 1423 1424 1425 1426 1427 |
int
TclOORemoveFromMixins(
Class *mixinPtr, /* The mixin to remove. */
Object *oPtr) /* The object (possibly) containing the
* reference to the mixin. */
{
| | | 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 |
int
TclOORemoveFromMixins(
Class *mixinPtr, /* The mixin to remove. */
Object *oPtr) /* The object (possibly) containing the
* reference to the mixin. */
{
Tcl_Size i;
int res = 0;
Class *mixPtr;
FOREACH(mixPtr, oPtr->mixins) {
if (mixinPtr == mixPtr) {
RemoveItem(Class, oPtr->mixins, i);
TclOODecrRefCount(mixPtr->thisPtr);
|
| ︙ | ︙ | |||
1457 1458 1459 1460 1461 1462 1463 |
int
TclOORemoveFromSubclasses(
Class *subPtr, /* The subclass to remove. */
Class *superPtr) /* The superclass to possibly remove the
* subclass reference from. */
{
| | | 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 |
int
TclOORemoveFromSubclasses(
Class *subPtr, /* The subclass to remove. */
Class *superPtr) /* The superclass to possibly remove the
* subclass reference from. */
{
Tcl_Size i;
int res = 0;
Class *subclsPtr;
FOREACH(subclsPtr, superPtr->subclasses) {
if (subPtr == subclsPtr) {
RemoveItem(Class, superPtr->subclasses, i);
TclOODecrRefCount(subPtr->thisPtr);
|
| ︙ | ︙ | |||
1522 1523 1524 1525 1526 1527 1528 |
int
TclOORemoveFromMixinSubs(
Class *subPtr, /* The subclass to remove. */
Class *superPtr) /* The superclass to possibly remove the
* subclass reference from. */
{
| | | 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 |
int
TclOORemoveFromMixinSubs(
Class *subPtr, /* The subclass to remove. */
Class *superPtr) /* The superclass to possibly remove the
* subclass reference from. */
{
Tcl_Size i;
int res = 0;
Class *subclsPtr;
FOREACH(subclsPtr, superPtr->mixinSubs) {
if (subPtr == subclsPtr) {
RemoveItem(Class, superPtr->mixinSubs, i);
TclOODecrRefCount(subPtr->thisPtr);
|
| ︙ | ︙ | |||
1663 1664 1665 1666 1667 1668 1669 |
Tcl_Interp *interp, /* Interpreter context. */
Tcl_Class cls, /* Class to create an instance of. */
const char *nameStr, /* Name of object to create, or NULL to ask
* the code to pick its own unique name. */
const char *nsNameStr, /* Name of namespace to create inside object,
* or NULL to ask the code to pick its own
* unique name. */
| | | | 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 |
Tcl_Interp *interp, /* Interpreter context. */
Tcl_Class cls, /* Class to create an instance of. */
const char *nameStr, /* Name of object to create, or NULL to ask
* the code to pick its own unique name. */
const char *nsNameStr, /* Name of namespace to create inside object,
* or NULL to ask the code to pick its own
* unique name. */
Tcl_Size objc, /* Number of arguments. Negative value means
* do not call constructor. */
Tcl_Obj *const *objv, /* Argument list. */
Tcl_Size skip) /* Number of arguments to _not_ pass to the
* constructor. */
{
Class *classPtr = (Class *) cls;
Object *oPtr;
void *clientData[4];
oPtr = TclNewObjectInstanceCommon(interp, classPtr, nameStr, nsNameStr);
|
| ︙ | ︙ | |||
1731 1732 1733 1734 1735 1736 1737 |
Tcl_Interp *interp, /* Interpreter context. */
Tcl_Class cls, /* Class to create an instance of. */
const char *nameStr, /* Name of object to create, or NULL to ask
* the code to pick its own unique name. */
const char *nsNameStr, /* Name of namespace to create inside object,
* or NULL to ask the code to pick its own
* unique name. */
| | | | | 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 |
Tcl_Interp *interp, /* Interpreter context. */
Tcl_Class cls, /* Class to create an instance of. */
const char *nameStr, /* Name of object to create, or NULL to ask
* the code to pick its own unique name. */
const char *nsNameStr, /* Name of namespace to create inside object,
* or NULL to ask the code to pick its own
* unique name. */
Tcl_Size objc, /* Number of arguments. Negative value means
* do not call constructor. */
Tcl_Obj *const *objv, /* Argument list. */
Tcl_Size skip, /* Number of arguments to _not_ pass to the
* constructor. */
Tcl_Object *objectPtr) /* Place to write the object reference upon
* successful allocation. */
{
Class *classPtr = (Class *) cls;
CallContext *contextPtr;
Tcl_InterpState state;
Object *oPtr;
oPtr = TclNewObjectInstanceCommon(interp, classPtr, nameStr, nsNameStr);
if (oPtr == NULL) {
return TCL_ERROR;
}
/*
* Run constructors, except when objc == TCL_INDEX_NONE (a special flag case used for
* object cloning only). If there aren't any constructors, we do nothing.
*/
if (objc < 0) {
*objectPtr = (Tcl_Object) oPtr;
return TCL_OK;
}
contextPtr = TclOOGetCallContext(oPtr, NULL, CONSTRUCTOR, NULL, NULL, NULL);
if (contextPtr == NULL) {
*objectPtr = (Tcl_Object) oPtr;
return TCL_OK;
|
| ︙ | ︙ | |||
1866 1867 1868 1869 1870 1871 1872 |
/*
* Ensure an error if the object was deleted in the constructor. Don't
* want to lose errors by accident. [Bug 2903011]
*/
if (result != TCL_ERROR && Destructing(oPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 |
/*
* Ensure an error if the object was deleted in the constructor. Don't
* want to lose errors by accident. [Bug 2903011]
*/
if (result != TCL_ERROR && Destructing(oPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"object deleted in constructor", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "STILLBORN", NULL);
result = TCL_ERROR;
}
if (result != TCL_OK) {
Tcl_DiscardInterpState(state);
/*
|
| ︙ | ︙ | |||
1928 1929 1930 1931 1932 1933 1934 |
Object *oPtr = (Object *) sourceObject, *o2Ptr;
FOREACH_HASH_DECLS;
Method *mPtr;
Class *mixinPtr;
CallContext *contextPtr;
Tcl_Obj *keyPtr, *filterObj, *variableObj, *args[3];
PrivateVariableMapping *privateVariable;
| | | | | 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 |
Object *oPtr = (Object *) sourceObject, *o2Ptr;
FOREACH_HASH_DECLS;
Method *mPtr;
Class *mixinPtr;
CallContext *contextPtr;
Tcl_Obj *keyPtr, *filterObj, *variableObj, *args[3];
PrivateVariableMapping *privateVariable;
Tcl_Size i;
int result;
/*
* Sanity check.
*/
if (IsRootClass(oPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may not clone the class of classes", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "CLONING_CLASS", NULL);
return NULL;
}
/*
* Build the instance. Note that this does not run any constructors.
*/
o2Ptr = (Object *) Tcl_NewObjectInstance(interp,
(Tcl_Class) oPtr->selfCls, targetName, targetNamespaceName, TCL_INDEX_NONE,
NULL, -1);
if (o2Ptr == NULL) {
return NULL;
}
/*
* Copy the object-local methods to the new object.
*/
|
| ︙ | ︙ | |||
2552 2553 2554 2555 2556 2557 2558 |
* invoke from, or NULL to traverse the whole
* chain including filters. */
int publicPrivate, /* Whether this is an invoke from a public
* context (PUBLIC_METHOD), a private context
* (PRIVATE_METHOD), or a *really* private
* context (any other value; conventionally
* 0). */
| | | 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 |
* invoke from, or NULL to traverse the whole
* chain including filters. */
int publicPrivate, /* Whether this is an invoke from a public
* context (PUBLIC_METHOD), a private context
* (PRIVATE_METHOD), or a *really* private
* context (any other value; conventionally
* 0). */
Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const *objv) /* Array of argument objects. It is assumed
* that the name of the method to invoke will
* be at index 1. */
{
switch (publicPrivate) {
case PUBLIC_METHOD:
return TclOOObjectCmdCore((Object *) object, interp, objc, objv,
|
| ︙ | ︙ | |||
2623 2624 2625 2626 2627 2628 2629 |
* ----------------------------------------------------------------------
*/
int
TclOOObjectCmdCore(
Object *oPtr, /* The object being invoked. */
Tcl_Interp *interp, /* The interpreter containing the object. */
| | | | 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 |
* ----------------------------------------------------------------------
*/
int
TclOOObjectCmdCore(
Object *oPtr, /* The object being invoked. */
Tcl_Interp *interp, /* The interpreter containing the object. */
Tcl_Size objc, /* How many arguments are being passed in. */
Tcl_Obj *const *objv, /* The array of arguments. */
int flags, /* Whether this is an invocation through the
* public or the private command interface. */
Class *startCls) /* Where to start in the call chain, or NULL
* if we are to start at the front with
* filters and the object's methods (which is
* the normal case). */
{
CallContext *contextPtr;
Tcl_Obj *methodNamePtr;
CallFrame *framePtr = ((Interp *) interp)->varFramePtr;
Object *callerObjPtr = NULL;
Class *callerClsPtr = NULL;
int result;
/*
* If we've no method name, throw this directly into the unknown
* processing.
*/
if (objc < 2) {
flags |= FORCE_UNKNOWN;
methodNamePtr = NULL;
goto noMapping;
}
/*
* Determine if we're in a context that can see the extra, private methods
|
| ︙ | ︙ | |||
2745 2746 2747 2748 2749 2750 2751 |
}
if (miPtr->mPtr->declaringClassPtr == startCls) {
break;
}
}
if (contextPtr->index >= contextPtr->callPtr->numChain) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 |
}
if (miPtr->mPtr->declaringClassPtr == startCls) {
break;
}
}
if (contextPtr->index >= contextPtr->callPtr->numChain) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"no valid method implementation", -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(methodNamePtr), NULL);
TclOODeleteContext(contextPtr);
return TCL_ERROR;
}
}
|
| ︙ | ︙ | |||
2795 2796 2797 2798 2799 2800 2801 |
* ----------------------------------------------------------------------
*/
int
Tcl_ObjectContextInvokeNext(
Tcl_Interp *interp,
Tcl_ObjectContext context,
| | | | 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 |
* ----------------------------------------------------------------------
*/
int
Tcl_ObjectContextInvokeNext(
Tcl_Interp *interp,
Tcl_ObjectContext context,
Tcl_Size objc,
Tcl_Obj *const *objv,
Tcl_Size skip)
{
CallContext *contextPtr = (CallContext *) context;
size_t savedIndex = contextPtr->index;
size_t savedSkip = contextPtr->skip;
int result;
if (contextPtr->index + 1 >= contextPtr->callPtr->numChain) {
|
| ︙ | ︙ | |||
2867 2868 2869 2870 2871 2872 2873 |
return result;
}
int
TclNRObjectContextInvokeNext(
Tcl_Interp *interp,
Tcl_ObjectContext context,
| | | | 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 |
return result;
}
int
TclNRObjectContextInvokeNext(
Tcl_Interp *interp,
Tcl_ObjectContext context,
Tcl_Size objc,
Tcl_Obj *const *objv,
Tcl_Size skip)
{
CallContext *contextPtr = (CallContext *) context;
if (contextPtr->index + 1 >= contextPtr->callPtr->numChain) {
/*
* We're at the end of the chain; generate an error message unless the
* interpreter is being torn down, in which case we might be getting
|
| ︙ | ︙ | |||
2996 2997 2998 2999 3000 3001 3002 |
*/
int
TclOOIsReachable(
Class *targetPtr,
Class *startPtr)
{
| | | 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 |
*/
int
TclOOIsReachable(
Class *targetPtr,
Class *startPtr)
{
Tcl_Size i;
Class *superPtr;
tailRecurse:
if (startPtr == targetPtr) {
return 1;
}
if (startPtr->superclasses.num == 1 && startPtr->mixins.num == 0) {
|
| ︙ | ︙ | |||
3089 3090 3091 3092 3093 3094 3095 |
Tcl_Object
Tcl_ObjectContextObject(
Tcl_ObjectContext context)
{
return (Tcl_Object) ((CallContext *)context)->oPtr;
}
| | | 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 |
Tcl_Object
Tcl_ObjectContextObject(
Tcl_ObjectContext context)
{
return (Tcl_Object) ((CallContext *)context)->oPtr;
}
Tcl_Size
Tcl_ObjectContextSkippedArgs(
Tcl_ObjectContext context)
{
return ((CallContext *)context)->skip;
}
Tcl_Namespace *
|
| ︙ | ︙ |
Changes to generic/tclOO.decls.
| ︙ | ︙ | |||
64 65 66 67 68 69 70 |
declare 12 {
Tcl_Method Tcl_NewMethod(Tcl_Interp *interp, Tcl_Class cls,
Tcl_Obj *nameObj, int flags, const Tcl_MethodType *typePtr,
void *clientData)
}
declare 13 {
Tcl_Object Tcl_NewObjectInstance(Tcl_Interp *interp, Tcl_Class cls,
| | | | | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
declare 12 {
Tcl_Method Tcl_NewMethod(Tcl_Interp *interp, Tcl_Class cls,
Tcl_Obj *nameObj, int flags, const Tcl_MethodType *typePtr,
void *clientData)
}
declare 13 {
Tcl_Object Tcl_NewObjectInstance(Tcl_Interp *interp, Tcl_Class cls,
const char *nameStr, const char *nsNameStr, Tcl_Size objc,
Tcl_Obj *const *objv, Tcl_Size skip)
}
declare 14 {
int Tcl_ObjectDeleted(Tcl_Object object)
}
declare 15 {
int Tcl_ObjectContextIsFiltering(Tcl_ObjectContext context)
}
declare 16 {
Tcl_Method Tcl_ObjectContextMethod(Tcl_ObjectContext context)
}
declare 17 {
Tcl_Object Tcl_ObjectContextObject(Tcl_ObjectContext context)
}
declare 18 {
Tcl_Size Tcl_ObjectContextSkippedArgs(Tcl_ObjectContext context)
}
declare 19 {
void *Tcl_ClassGetMetadata(Tcl_Class clazz,
const Tcl_ObjectMetadataType *typePtr)
}
declare 20 {
void Tcl_ClassSetMetadata(Tcl_Class clazz,
const Tcl_ObjectMetadataType *typePtr, void *metadata)
}
declare 21 {
void *Tcl_ObjectGetMetadata(Tcl_Object object,
const Tcl_ObjectMetadataType *typePtr)
}
declare 22 {
void Tcl_ObjectSetMetadata(Tcl_Object object,
const Tcl_ObjectMetadataType *typePtr, void *metadata)
}
declare 23 {
int Tcl_ObjectContextInvokeNext(Tcl_Interp *interp,
Tcl_ObjectContext context, Tcl_Size objc, Tcl_Obj *const *objv,
Tcl_Size skip)
}
declare 24 {
Tcl_ObjectMapMethodNameProc *Tcl_ObjectGetMethodNameMapper(
Tcl_Object object)
}
declare 25 {
void Tcl_ObjectSetMethodNameMapper(Tcl_Object object,
|
| ︙ | ︙ | |||
180 181 182 183 184 185 186 |
}
declare 4 {
Method *TclOONewProcMethod(Tcl_Interp *interp, Class *clsPtr,
int flags, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj,
ProcedureMethod **pmPtrPtr)
}
declare 5 {
| | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
}
declare 4 {
Method *TclOONewProcMethod(Tcl_Interp *interp, Class *clsPtr,
int flags, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj,
ProcedureMethod **pmPtrPtr)
}
declare 5 {
int TclOOObjectCmdCore(Object *oPtr, Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const *objv, int publicOnly, Class *startCls)
}
declare 6 {
int TclOOIsReachable(Class *targetPtr, Class *startPtr)
}
declare 7 {
Method *TclOONewForwardMethod(Tcl_Interp *interp, Class *clsPtr,
|
| ︙ | ︙ | |||
210 211 212 213 214 215 216 |
TclOO_PreCallProc *preCallPtr, TclOO_PostCallProc *postCallPtr,
ProcErrorProc *errProc, void *clientData, Tcl_Obj *nameObj,
Tcl_Obj *argsObj, Tcl_Obj *bodyObj, int flags,
void **internalTokenPtr)
}
declare 11 {
int TclOOInvokeObject(Tcl_Interp *interp, Tcl_Object object,
| | | | | | | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
TclOO_PreCallProc *preCallPtr, TclOO_PostCallProc *postCallPtr,
ProcErrorProc *errProc, void *clientData, Tcl_Obj *nameObj,
Tcl_Obj *argsObj, Tcl_Obj *bodyObj, int flags,
void **internalTokenPtr)
}
declare 11 {
int TclOOInvokeObject(Tcl_Interp *interp, Tcl_Object object,
Tcl_Class startCls, int publicPrivate, Tcl_Size objc,
Tcl_Obj *const *objv)
}
declare 12 {
void TclOOObjectSetFilters(Object *oPtr, Tcl_Size numFilters,
Tcl_Obj *const *filters)
}
declare 13 {
void TclOOClassSetFilters(Tcl_Interp *interp, Class *classPtr,
Tcl_Size numFilters, Tcl_Obj *const *filters)
}
declare 14 {
void TclOOObjectSetMixins(Object *oPtr, Tcl_Size numMixins,
Class *const *mixins)
}
declare 15 {
void TclOOClassSetMixins(Tcl_Interp *interp, Class *classPtr,
Tcl_Size numMixins, Class *const *mixins)
}
return
# Local Variables:
# mode: tcl
# End:
|
Changes to generic/tclOO.h.
| ︙ | ︙ | |||
59 60 61 62 63 64 65 | * implementation. These are used to implement custom types of method calls * and to allow the attachment of arbitrary data to objects and classes. */ typedef int (Tcl_MethodCallProc)(void *clientData, Tcl_Interp *interp, Tcl_ObjectContext objectContext, int objc, Tcl_Obj *const *objv); typedef int (Tcl_MethodCallProc2)(void *clientData, Tcl_Interp *interp, | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | * implementation. These are used to implement custom types of method calls * and to allow the attachment of arbitrary data to objects and classes. */ typedef int (Tcl_MethodCallProc)(void *clientData, Tcl_Interp *interp, Tcl_ObjectContext objectContext, int objc, Tcl_Obj *const *objv); typedef int (Tcl_MethodCallProc2)(void *clientData, Tcl_Interp *interp, Tcl_ObjectContext objectContext, ptrdiff_t objc, Tcl_Obj *const *objv); typedef void (Tcl_MethodDeleteProc)(void *clientData); typedef int (Tcl_CloneProc)(Tcl_Interp *interp, void *oldClientData, void **newClientData); typedef void (Tcl_ObjectMetadataDeleteProc)(void *clientData); typedef int (Tcl_ObjectMapMethodNameProc)(Tcl_Interp *interp, Tcl_Object object, Tcl_Class *startClsPtr, Tcl_Obj *methodNameObj); |
| ︙ | ︙ |
Changes to generic/tclOOBasic.c.
| ︙ | ︙ | |||
96 97 98 99 100 101 102 |
}
/*
* Make the class definition delegate. This is special; it doesn't reenter
* here (and the class definition delegate doesn't run any constructors).
*/
| | | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
}
/*
* Make the class definition delegate. This is special; it doesn't reenter
* here (and the class definition delegate doesn't run any constructors).
*/
nameObj = Tcl_NewStringObj(oPtr->namespacePtr->fullName, -1);
Tcl_AppendToObj(nameObj, ":: oo ::delegate", -1);
Tcl_NewObjectInstance(interp, (Tcl_Class) oPtr->fPtr->classCls,
TclGetString(nameObj), NULL, -1, NULL, -1);
Tcl_DecrRefCount(nameObj);
/*
* Delegate to [oo::define] to do the work.
*/
invoke = (Tcl_Obj **)Tcl_Alloc(3 * sizeof(Tcl_Obj *));
|
| ︙ | ︙ | |||
144 145 146 147 148 149 150 |
Object *oPtr = (Object *)data[1];
Tcl_InterpState saved;
int code;
TclDecrRefCount(invoke[0]);
TclDecrRefCount(invoke[1]);
TclDecrRefCount(invoke[2]);
| | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
Object *oPtr = (Object *)data[1];
Tcl_InterpState saved;
int code;
TclDecrRefCount(invoke[0]);
TclDecrRefCount(invoke[1]);
TclDecrRefCount(invoke[2]);
invoke[0] = Tcl_NewStringObj("::oo::MixinClassDelegates", -1);
invoke[1] = TclOOObjectName(interp, oPtr);
Tcl_IncrRefCount(invoke[0]);
Tcl_IncrRefCount(invoke[1]);
saved = Tcl_SaveInterpState(interp, result);
code = Tcl_EvalObjv(interp, 2, invoke, 0);
TclDecrRefCount(invoke[0]);
TclDecrRefCount(invoke[1]);
|
| ︙ | ︙ | |||
181 182 183 184 185 186 187 |
* also used for error reporting. */
Tcl_ObjectContext context, /* The object/call context. */
int objc, /* Number of arguments. */
Tcl_Obj *const *objv) /* The actual arguments. */
{
Object *oPtr = (Object *) Tcl_ObjectContextObject(context);
const char *objName;
| | | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
* also used for error reporting. */
Tcl_ObjectContext context, /* The object/call context. */
int objc, /* Number of arguments. */
Tcl_Obj *const *objv) /* The actual arguments. */
{
Object *oPtr = (Object *) Tcl_ObjectContextObject(context);
const char *objName;
Tcl_Size len;
/*
* Sanity check; should not be possible to invoke this method on a
* non-class.
*/
if (oPtr->classPtr == NULL) {
Tcl_Obj *cmdnameObj = TclOOObjectName(interp, oPtr);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"object \"%s\" is not a class", TclGetString(cmdnameObj)));
Tcl_SetErrorCode(interp, "TCL", "OO", "INSTANTIATE_NONCLASS", NULL);
return TCL_ERROR;
}
/*
* Check we have the right number of (sensible) arguments.
*/
if (objc < 1 + Tcl_ObjectContextSkippedArgs(context)) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"objectName ?arg ...?");
return TCL_ERROR;
}
objName = Tcl_GetStringFromObj(
objv[Tcl_ObjectContextSkippedArgs(context)], &len);
if (len == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"object name must not be empty", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "EMPTY_NAME", NULL);
return TCL_ERROR;
}
/*
* Make the object and return its name.
*/
|
| ︙ | ︙ | |||
246 247 248 249 250 251 252 |
* also used for error reporting. */
Tcl_ObjectContext context, /* The object/call context. */
int objc, /* Number of arguments. */
Tcl_Obj *const *objv) /* The actual arguments. */
{
Object *oPtr = (Object *) Tcl_ObjectContextObject(context);
const char *objName, *nsName;
| | | | | | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
* also used for error reporting. */
Tcl_ObjectContext context, /* The object/call context. */
int objc, /* Number of arguments. */
Tcl_Obj *const *objv) /* The actual arguments. */
{
Object *oPtr = (Object *) Tcl_ObjectContextObject(context);
const char *objName, *nsName;
Tcl_Size len;
/*
* Sanity check; should not be possible to invoke this method on a
* non-class.
*/
if (oPtr->classPtr == NULL) {
Tcl_Obj *cmdnameObj = TclOOObjectName(interp, oPtr);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"object \"%s\" is not a class", TclGetString(cmdnameObj)));
Tcl_SetErrorCode(interp, "TCL", "OO", "INSTANTIATE_NONCLASS", NULL);
return TCL_ERROR;
}
/*
* Check we have the right number of (sensible) arguments.
*/
if (objc + 1 < Tcl_ObjectContextSkippedArgs(context) + 3) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"objectName namespaceName ?arg ...?");
return TCL_ERROR;
}
objName = Tcl_GetStringFromObj(
objv[Tcl_ObjectContextSkippedArgs(context)], &len);
if (len == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"object name must not be empty", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "EMPTY_NAME", NULL);
return TCL_ERROR;
}
nsName = Tcl_GetStringFromObj(
objv[Tcl_ObjectContextSkippedArgs(context)+1], &len);
if (len == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"namespace name must not be empty", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "EMPTY_NAME", NULL);
return TCL_ERROR;
}
/*
* Make the object and return its name.
*/
|
| ︙ | ︙ | |||
596 597 598 599 600 601 602 |
return TCL_ERROR;
}
errorMsg = Tcl_ObjPrintf("unknown method \"%s\": must be ",
TclGetString(objv[skip]));
for (i=0 ; i<numMethodNames-1 ; i++) {
if (i) {
| | | | | | 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
return TCL_ERROR;
}
errorMsg = Tcl_ObjPrintf("unknown method \"%s\": must be ",
TclGetString(objv[skip]));
for (i=0 ; i<numMethodNames-1 ; i++) {
if (i) {
Tcl_AppendToObj(errorMsg, ", ", -1);
}
Tcl_AppendToObj(errorMsg, methodNames[i], -1);
}
if (i) {
Tcl_AppendToObj(errorMsg, " or ", -1);
}
Tcl_AppendToObj(errorMsg, methodNames[i], -1);
Tcl_Free((void *)methodNames);
Tcl_SetObjResult(interp, errorMsg);
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(objv[skip]), NULL);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
633 634 635 636 637 638 639 |
Tcl_ObjectContext context, /* The object/call context. */
int objc, /* Number of arguments. */
Tcl_Obj *const *objv) /* The actual arguments. */
{
Interp *iPtr = (Interp *) interp;
Tcl_Object object = Tcl_ObjectContextObject(context);
Namespace *savedNsPtr;
| | | | | 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
Tcl_ObjectContext context, /* The object/call context. */
int objc, /* Number of arguments. */
Tcl_Obj *const *objv) /* The actual arguments. */
{
Interp *iPtr = (Interp *) interp;
Tcl_Object object = Tcl_ObjectContextObject(context);
Namespace *savedNsPtr;
Tcl_Size i;
if (objc < Tcl_ObjectContextSkippedArgs(context)) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"?varName ...?");
return TCL_ERROR;
}
/*
* A sanity check. Shouldn't ever happen. (This is all that remains of a
* more complex check inherited from [global] after we have applied the
* fix for [Bug 2903811]; note that the fix involved *removing* code.)
*/
if (iPtr->varFramePtr == NULL) {
return TCL_OK;
}
for (i = Tcl_ObjectContextSkippedArgs(context) ; i < objc ; i++) {
Var *varPtr, *aryPtr;
const char *varName = TclGetString(objv[i]);
/*
* The variable name must not contain a '::' since that's illegal in
* local names.
*/
|
| ︙ | ︙ | |||
776 777 778 779 780 781 782 |
if (framePtr->isProcCallFrame & FRAME_IS_METHOD) {
Object *oPtr = (Object *) Tcl_ObjectContextObject(context);
CallContext *callerContext = (CallContext *)framePtr->clientData;
Method *mPtr = callerContext->callPtr->chain[
callerContext->index].mPtr;
PrivateVariableMapping *pvPtr;
| | | 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 |
if (framePtr->isProcCallFrame & FRAME_IS_METHOD) {
Object *oPtr = (Object *) Tcl_ObjectContextObject(context);
CallContext *callerContext = (CallContext *)framePtr->clientData;
Method *mPtr = callerContext->callPtr->chain[
callerContext->index].mPtr;
PrivateVariableMapping *pvPtr;
Tcl_Size i;
if (mPtr->declaringObjectPtr == oPtr) {
FOREACH_STRUCT(pvPtr, oPtr->privateVariables) {
if (!strcmp(TclGetString(pvPtr->variableObj),
TclGetString(argPtr))) {
argPtr = pvPtr->fullNameObj;
break;
|
| ︙ | ︙ | |||
812 813 814 815 816 817 818 | break; } } } } } | | | 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 |
break;
}
}
}
}
}
varNamePtr = Tcl_NewStringObj(namespacePtr->fullName, -1);
Tcl_AppendToObj(varNamePtr, "::", 2);
Tcl_AppendObjToObj(varNamePtr, argPtr);
}
Tcl_IncrRefCount(varNamePtr);
varPtr = TclObjLookupVar(interp, varNamePtr, NULL,
TCL_NAMESPACE_ONLY|TCL_LEAVE_ERR_MSG, "refer to", 1, 1, &aryVar);
Tcl_DecrRefCount(varNamePtr);
|
| ︙ | ︙ | |||
838 839 840 841 842 843 844 |
if (aryVar != NULL) {
Tcl_GetVariableFullName(interp, (Tcl_Var) aryVar, varNamePtr);
/*
* WARNING! This code pokes inside the implementation of hash tables!
*/
| | | | 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 |
if (aryVar != NULL) {
Tcl_GetVariableFullName(interp, (Tcl_Var) aryVar, varNamePtr);
/*
* WARNING! This code pokes inside the implementation of hash tables!
*/
Tcl_AppendToObj(varNamePtr, "(", -1);
Tcl_AppendObjToObj(varNamePtr, ((VarInHash *)
varPtr)->entry.key.objPtr);
Tcl_AppendToObj(varNamePtr, ")", -1);
} else {
Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, varNamePtr);
}
Tcl_SetObjResult(interp, varNamePtr);
return TCL_OK;
}
|
| ︙ | ︙ | |||
908 909 910 911 912 913 914 |
int objc,
Tcl_Obj *const *objv)
{
Interp *iPtr = (Interp *) interp;
CallFrame *framePtr = iPtr->varFramePtr;
Class *classPtr;
CallContext *contextPtr;
| | | 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 |
int objc,
Tcl_Obj *const *objv)
{
Interp *iPtr = (Interp *) interp;
CallFrame *framePtr = iPtr->varFramePtr;
Class *classPtr;
CallContext *contextPtr;
Tcl_Size i;
Tcl_Object object;
const char *methodType;
/*
* Start with sanity checks on the calling context to make sure that we
* are invoked from a suitable method context. If so, we can safely
* retrieve the handle to the object call context.
|
| ︙ | ︙ | |||
1088 1089 1090 1091 1092 1093 1094 |
switch (index) {
case SELF_OBJECT:
Tcl_SetObjResult(interp, TclOOObjectName(interp, contextPtr->oPtr));
return TCL_OK;
case SELF_NS:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | | | | 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 |
switch (index) {
case SELF_OBJECT:
Tcl_SetObjResult(interp, TclOOObjectName(interp, contextPtr->oPtr));
return TCL_OK;
case SELF_NS:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
contextPtr->oPtr->namespacePtr->fullName, -1));
return TCL_OK;
case SELF_CLASS: {
Class *clsPtr = CurrentlyInvoked(contextPtr).mPtr->declaringClassPtr;
if (clsPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"method not defined by a class", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "UNMATCHED_CONTEXT", NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, TclOOObjectName(interp, clsPtr->thisPtr));
return TCL_OK;
}
case SELF_METHOD:
if (contextPtr->callPtr->flags & CONSTRUCTOR) {
Tcl_SetObjResult(interp, contextPtr->oPtr->fPtr->constructorName);
} else if (contextPtr->callPtr->flags & DESTRUCTOR) {
Tcl_SetObjResult(interp, contextPtr->oPtr->fPtr->destructorName);
} else {
Tcl_SetObjResult(interp,
CurrentlyInvoked(contextPtr).mPtr->namePtr);
}
return TCL_OK;
case SELF_FILTER:
if (!CurrentlyInvoked(contextPtr).isFilter) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"not inside a filtering context", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "UNMATCHED_CONTEXT", NULL);
return TCL_ERROR;
} else {
struct MInvoke *miPtr = &CurrentlyInvoked(contextPtr);
Object *oPtr;
const char *type;
if (miPtr->filterDeclarer != NULL) {
oPtr = miPtr->filterDeclarer->thisPtr;
type = "class";
} else {
oPtr = contextPtr->oPtr;
type = "object";
}
result[0] = TclOOObjectName(interp, oPtr);
result[1] = Tcl_NewStringObj(type, -1);
result[2] = miPtr->mPtr->namePtr;
Tcl_SetObjResult(interp, Tcl_NewListObj(3, result));
return TCL_OK;
}
case SELF_CALLER:
if ((framePtr->callerVarPtr == NULL) ||
!(framePtr->callerVarPtr->isProcCallFrame & FRAME_IS_METHOD)){
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"caller is not an object", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "CONTEXT_REQUIRED", NULL);
return TCL_ERROR;
} else {
CallContext *callerPtr = (CallContext *)framePtr->callerVarPtr->clientData;
Method *mPtr = callerPtr->callPtr->chain[callerPtr->index].mPtr;
Object *declarerPtr;
if (mPtr->declaringClassPtr != NULL) {
declarerPtr = mPtr->declaringClassPtr->thisPtr;
} else if (mPtr->declaringObjectPtr != NULL) {
declarerPtr = mPtr->declaringObjectPtr;
} else {
/*
* This should be unreachable code.
*/
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"method without declarer!", -1));
return TCL_ERROR;
}
result[0] = TclOOObjectName(interp, declarerPtr);
result[1] = TclOOObjectName(interp, callerPtr->oPtr);
if (callerPtr->callPtr->flags & CONSTRUCTOR) {
result[2] = declarerPtr->fPtr->constructorName;
|
| ︙ | ︙ | |||
1192 1193 1194 1195 1196 1197 1198 |
declarerPtr = mPtr->declaringObjectPtr;
} else {
/*
* This should be unreachable code.
*/
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | | 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 |
declarerPtr = mPtr->declaringObjectPtr;
} else {
/*
* This should be unreachable code.
*/
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"method without declarer!", -1));
return TCL_ERROR;
}
result[0] = TclOOObjectName(interp, declarerPtr);
if (contextPtr->callPtr->flags & CONSTRUCTOR) {
result[1] = declarerPtr->fPtr->constructorName;
} else if (contextPtr->callPtr->flags & DESTRUCTOR) {
result[1] = declarerPtr->fPtr->destructorName;
} else {
result[1] = mPtr->namePtr;
}
Tcl_SetObjResult(interp, Tcl_NewListObj(2, result));
}
return TCL_OK;
case SELF_TARGET:
if (!CurrentlyInvoked(contextPtr).isFilter) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"not inside a filtering context", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "UNMATCHED_CONTEXT", NULL);
return TCL_ERROR;
} else {
Method *mPtr;
Object *declarerPtr;
Tcl_Size i;
for (i=contextPtr->index ; i<contextPtr->callPtr->numChain ; i++){
if (!contextPtr->callPtr->chain[i].isFilter) {
break;
}
}
if (i == contextPtr->callPtr->numChain) {
Tcl_Panic("filtering call chain without terminal non-filter");
}
mPtr = contextPtr->callPtr->chain[i].mPtr;
if (mPtr->declaringClassPtr != NULL) {
declarerPtr = mPtr->declaringClassPtr->thisPtr;
} else if (mPtr->declaringObjectPtr != NULL) {
declarerPtr = mPtr->declaringObjectPtr;
} else {
/*
* This should be unreachable code.
*/
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"method without declarer!", -1));
return TCL_ERROR;
}
result[0] = TclOOObjectName(interp, declarerPtr);
result[1] = mPtr->namePtr;
Tcl_SetObjResult(interp, Tcl_NewListObj(2, result));
return TCL_OK;
}
|
| ︙ | ︙ |
Changes to generic/tclOOCall.c.
| ︙ | ︙ | |||
323 324 325 326 327 328 329 |
/*
* If this is the first step along the chain, we preserve the method
* entries in the chain so that they do not get deleted out from under our
* feet.
*/
if (contextPtr->index == 0) {
| | | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
/*
* If this is the first step along the chain, we preserve the method
* entries in the chain so that they do not get deleted out from under our
* feet.
*/
if (contextPtr->index == 0) {
Tcl_Size i;
for (i = 0 ; i < contextPtr->callPtr->numChain ; i++) {
AddRef(contextPtr->callPtr->chain[i].mPtr);
}
/*
* Ensure that the method name itself is part of the arguments when
|
| ︙ | ︙ | |||
405 406 407 408 409 410 411 |
static int
FinalizeMethodRefs(
void *data[],
TCL_UNUSED(Tcl_Interp *),
int result)
{
CallContext *contextPtr = (CallContext *)data[0];
| | | 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
static int
FinalizeMethodRefs(
void *data[],
TCL_UNUSED(Tcl_Interp *),
int result)
{
CallContext *contextPtr = (CallContext *)data[0];
Tcl_Size i;
for (i = 0 ; i < contextPtr->callPtr->numChain ; i++) {
TclOODelMethodRef(contextPtr->callPtr->chain[i].mPtr);
}
return result;
}
|
| ︙ | ︙ | |||
446 447 448 449 450 451 452 |
Tcl_HashTable names; /* Tcl_Obj* method name to "wanted in list"
* mapping. */
Tcl_HashTable examinedClasses;
/* Used to track what classes have been looked
* at. Is set-like in nature and keyed by
* pointer to class. */
FOREACH_HASH_DECLS;
| | | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
Tcl_HashTable names; /* Tcl_Obj* method name to "wanted in list"
* mapping. */
Tcl_HashTable examinedClasses;
/* Used to track what classes have been looked
* at. Is set-like in nature and keyed by
* pointer to class. */
FOREACH_HASH_DECLS;
Tcl_Size i, numStrings;
Class *mixinPtr;
Tcl_Obj *namePtr;
Method *mPtr;
Tcl_InitObjHashTable(&names);
Tcl_InitHashTable(&examinedClasses, TCL_ONE_WORD_KEYS);
|
| ︙ | ︙ | |||
687 688 689 690 691 692 693 |
* semantics are handled correctly. */
Tcl_HashTable *const examinedClassesPtr)
/* Hash table that tracks what classes have
* already been looked at. The keys are the
* pointers to the classes, and the values are
* immaterial. */
{
| | | 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 |
* semantics are handled correctly. */
Tcl_HashTable *const examinedClassesPtr)
/* Hash table that tracks what classes have
* already been looked at. The keys are the
* pointers to the classes, and the values are
* immaterial. */
{
Tcl_Size i;
/*
* If we've already started looking at this class, stop working on it now
* to prevent repeated work.
*/
if (Tcl_FindHashEntry(examinedClassesPtr, clsPtr)) {
|
| ︙ | ︙ | |||
878 879 880 881 882 883 884 |
/* Where to record what call chain entries
* have been processed. */
int flags, /* What sort of call chain are we building. */
Class *const filterDecl) /* The class that declared the filter. If
* NULL, either the filter was declared by the
* object or this isn't a filter. */
{
| | | 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 |
/* Where to record what call chain entries
* have been processed. */
int flags, /* What sort of call chain are we building. */
Class *const filterDecl) /* The class that declared the filter. If
* NULL, either the filter was declared by the
* object or this isn't a filter. */
{
Tcl_Size i;
int foundPrivate = 0, blockedUnexported = 0;
Tcl_HashEntry *hPtr;
Method *mPtr;
if (!(flags & (KNOWN_STATE | SPECIAL)) && oPtr->methodsPtr) {
hPtr = Tcl_FindHashEntry(oPtr->methodsPtr, methodNameObj);
|
| ︙ | ︙ | |||
971 972 973 974 975 976 977 |
* only. Mixin-consistent means that either
* we're looking to add things from a mixin
* and we have passed a mixin, or we're not
* looking to add things from a mixin and have
* not passed a mixin. */
{
CallChain *callPtr = cbPtr->callChainPtr;
| | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 |
* only. Mixin-consistent means that either
* we're looking to add things from a mixin
* and we have passed a mixin, or we're not
* looking to add things from a mixin and have
* not passed a mixin. */
{
CallChain *callPtr = cbPtr->callChainPtr;
Tcl_Size i;
/*
* Return if this is just an entry used to record whether this is a public
* method. If so, there's nothing real to call and so nothing to add to
* the call chain.
*
* This is also where we enforce mixin-consistency.
|
| ︙ | ︙ | |||
1151 1152 1153 1154 1155 1156 1157 |
Tcl_Obj *cacheInThisObj) /* What object to cache in, or NULL if it is
* to be in the same object as the
* methodNameObj. */
{
CallContext *contextPtr;
CallChain *callPtr;
struct ChainBuilder cb;
| | | 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 |
Tcl_Obj *cacheInThisObj) /* What object to cache in, or NULL if it is
* to be in the same object as the
* methodNameObj. */
{
CallContext *contextPtr;
CallChain *callPtr;
struct ChainBuilder cb;
Tcl_Size i, count;
int doFilters, donePrivate = 0;
Tcl_HashEntry *hPtr;
Tcl_HashTable doneFilters;
if (cacheInThisObj == NULL) {
cacheInThisObj = methodNameObj;
}
|
| ︙ | ︙ | |||
1412 1413 1414 1415 1416 1417 1418 |
int flags) /* What sort of context are we looking for.
* Only the bits PUBLIC_METHOD, CONSTRUCTOR,
* PRIVATE_METHOD, DESTRUCTOR and
* FILTER_HANDLING are useful. */
{
CallChain *callPtr;
struct ChainBuilder cb;
| | | 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 |
int flags) /* What sort of context are we looking for.
* Only the bits PUBLIC_METHOD, CONSTRUCTOR,
* PRIVATE_METHOD, DESTRUCTOR and
* FILTER_HANDLING are useful. */
{
CallChain *callPtr;
struct ChainBuilder cb;
Tcl_Size count;
Foundation *fPtr = clsPtr->thisPtr->fPtr;
Tcl_HashEntry *hPtr;
Tcl_HashTable doneFilters;
Object obj;
/*
* Synthesize a temporary stereotypical object so that we can use existing
|
| ︙ | ︙ | |||
1492 1493 1494 1495 1496 1497 1498 |
flags|BUILDING_MIXINS, NULL);
AddSimpleChainToCallContext(&obj, NULL, methodNameObj, &cb, NULL, flags,
NULL);
/*
* Check to see if the method has no implementation. If so, we probably
* need to add in a call to the unknown method. Otherwise, set up the
| | | 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 |
flags|BUILDING_MIXINS, NULL);
AddSimpleChainToCallContext(&obj, NULL, methodNameObj, &cb, NULL, flags,
NULL);
/*
* Check to see if the method has no implementation. If so, we probably
* need to add in a call to the unknown method. Otherwise, set up the
* caching of the method implementation (if relevant).
*/
if (count == callPtr->numChain) {
AddSimpleChainToCallContext(&obj, NULL, fPtr->unknownMethodNameObj,
&cb, NULL, BUILDING_MIXINS, NULL);
AddSimpleChainToCallContext(&obj, NULL, fPtr->unknownMethodNameObj,
&cb, NULL, 0, NULL);
|
| ︙ | ︙ | |||
1547 1548 1549 1550 1551 1552 1553 |
Tcl_HashTable *const doneFilters,
/* Where to record what filters have been
* processed. Keys are objects, values are
* ignored. */
int flags) /* Whether we've gone along a mixin link
* yet. */
{
| | | 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 |
Tcl_HashTable *const doneFilters,
/* Where to record what filters have been
* processed. Keys are objects, values are
* ignored. */
int flags) /* Whether we've gone along a mixin link
* yet. */
{
Tcl_Size i;
int clearedFlags =
flags & ~(TRAVERSED_MIXIN|OBJECT_MIXIN|BUILDING_MIXINS);
Class *superPtr, *mixinPtr;
Tcl_Obj *filterObj;
tailRecurse:
if (clsPtr == NULL) {
|
| ︙ | ︙ | |||
1636 1637 1638 1639 1640 1641 1642 |
/* Where to record what call chain entries
* have been processed. */
int flags, /* What sort of call chain are we building. */
Class *const filterDecl) /* The class that declared the filter. If
* NULL, either the filter was declared by the
* object or this isn't a filter. */
{
| | | 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 |
/* Where to record what call chain entries
* have been processed. */
int flags, /* What sort of call chain are we building. */
Class *const filterDecl) /* The class that declared the filter. If
* NULL, either the filter was declared by the
* object or this isn't a filter. */
{
Tcl_Size i;
Class *superPtr;
/*
* We hard-code the tail-recursive form. It's by far the most common case
* *and* it is much more gentle on the stack.
*
* Note that mixins must be processed before the main class hierarchy.
|
| ︙ | ︙ | |||
1714 1715 1716 1717 1718 1719 1720 |
/* Where to record what call chain entries
* have been processed. */
int flags, /* What sort of call chain are we building. */
Class *const filterDecl) /* The class that declared the filter. If
* NULL, either the filter was declared by the
* object or this isn't a filter. */
{
| | | 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 |
/* Where to record what call chain entries
* have been processed. */
int flags, /* What sort of call chain are we building. */
Class *const filterDecl) /* The class that declared the filter. If
* NULL, either the filter was declared by the
* object or this isn't a filter. */
{
Tcl_Size i;
int privateDanger = 0;
Class *superPtr;
/*
* We hard-code the tail-recursive form. It's by far the most common case
* *and* it is much more gentle on the stack.
*
|
| ︙ | ︙ | |||
1800 1801 1802 1803 1804 1805 1806 |
TclOORenderCallChain(
Tcl_Interp *interp,
CallChain *callPtr)
{
Tcl_Obj *filterLiteral, *methodLiteral, *objectLiteral, *privateLiteral;
Tcl_Obj *resultObj, *descObjs[4], **objv;
Foundation *fPtr = TclOOGetFoundation(interp);
| | | 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 |
TclOORenderCallChain(
Tcl_Interp *interp,
CallChain *callPtr)
{
Tcl_Obj *filterLiteral, *methodLiteral, *objectLiteral, *privateLiteral;
Tcl_Obj *resultObj, *descObjs[4], **objv;
Foundation *fPtr = TclOOGetFoundation(interp);
Tcl_Size i;
/*
* Allocate the literals (potentially) used in our description.
*/
TclNewLiteralStringObj(filterLiteral, "filter");
Tcl_IncrRefCount(filterLiteral);
|
| ︙ | ︙ | |||
1828 1829 1830 1831 1832 1833 1834 |
* special because it's a filter method). The second word is the name of
* the method in question (which differs for "unknown" and "filter" types)
* and the third word is the full name of the class that declares the
* method (or "object" if it is declared on the instance).
*/
objv = (Tcl_Obj **)TclStackAlloc(interp, callPtr->numChain * sizeof(Tcl_Obj *));
| | | | 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 |
* special because it's a filter method). The second word is the name of
* the method in question (which differs for "unknown" and "filter" types)
* and the third word is the full name of the class that declares the
* method (or "object" if it is declared on the instance).
*/
objv = (Tcl_Obj **)TclStackAlloc(interp, callPtr->numChain * sizeof(Tcl_Obj *));
for (i = 0 ; i < callPtr->numChain ; i++) {
struct MInvoke *miPtr = &callPtr->chain[i];
descObjs[0] =
miPtr->isFilter ? filterLiteral :
callPtr->flags & OO_UNKNOWN_METHOD ? fPtr->unknownMethodNameObj :
IS_PRIVATE(miPtr->mPtr) ? privateLiteral :
methodLiteral;
descObjs[1] =
callPtr->flags & CONSTRUCTOR ? fPtr->constructorName :
callPtr->flags & DESTRUCTOR ? fPtr->destructorName :
miPtr->mPtr->namePtr;
descObjs[2] = miPtr->mPtr->declaringClassPtr
? Tcl_GetObjectName(interp,
(Tcl_Object) miPtr->mPtr->declaringClassPtr->thisPtr)
: objectLiteral;
descObjs[3] = Tcl_NewStringObj(miPtr->mPtr->typePtr->name, -1);
objv[i] = Tcl_NewListObj(4, descObjs);
}
/*
* Drop the local references to the literals; if they're actually used,
* they'll live on the description itself.
|
| ︙ | ︙ | |||
1956 1957 1958 1959 1960 1961 1962 |
Object *const oPtr, /* Object to add define chain entries for. */
DefineChain *const definePtr,
/* Where to add the define chain entries. */
int flags) /* What sort of define chain are we
* building. */
{
Class *mixinPtr;
| | | 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 |
Object *const oPtr, /* Object to add define chain entries for. */
DefineChain *const definePtr,
/* Where to add the define chain entries. */
int flags) /* What sort of define chain are we
* building. */
{
Class *mixinPtr;
Tcl_Size i;
FOREACH(mixinPtr, oPtr->mixins) {
AddSimpleClassDefineNamespaces(mixinPtr, definePtr,
flags | TRAVERSED_MIXIN);
}
AddSimpleClassDefineNamespaces(oPtr->selfCls, definePtr, flags);
|
| ︙ | ︙ | |||
1985 1986 1987 1988 1989 1990 1991 |
AddSimpleClassDefineNamespaces(
Class *classPtr, /* Class to add the define chain entries for. */
DefineChain *const definePtr,
/* Where to add the define chain entries. */
int flags) /* What sort of define chain are we
* building. */
{
| | | 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 |
AddSimpleClassDefineNamespaces(
Class *classPtr, /* Class to add the define chain entries for. */
DefineChain *const definePtr,
/* Where to add the define chain entries. */
int flags) /* What sort of define chain are we
* building. */
{
Tcl_Size i;
Class *superPtr;
/*
* We hard-code the tail-recursive form. It's by far the most common case
* *and* it is much more gentle on the stack.
*/
|
| ︙ | ︙ |
Changes to generic/tclOODecls.h.
| ︙ | ︙ | |||
65 66 67 68 69 70 71 | TCLAPI Tcl_Method Tcl_NewMethod(Tcl_Interp *interp, Tcl_Class cls, Tcl_Obj *nameObj, int flags, const Tcl_MethodType *typePtr, void *clientData); /* 13 */ TCLAPI Tcl_Object Tcl_NewObjectInstance(Tcl_Interp *interp, Tcl_Class cls, const char *nameStr, | | | | | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | TCLAPI Tcl_Method Tcl_NewMethod(Tcl_Interp *interp, Tcl_Class cls, Tcl_Obj *nameObj, int flags, const Tcl_MethodType *typePtr, void *clientData); /* 13 */ TCLAPI Tcl_Object Tcl_NewObjectInstance(Tcl_Interp *interp, Tcl_Class cls, const char *nameStr, const char *nsNameStr, Tcl_Size objc, Tcl_Obj *const *objv, Tcl_Size skip); /* 14 */ TCLAPI int Tcl_ObjectDeleted(Tcl_Object object); /* 15 */ TCLAPI int Tcl_ObjectContextIsFiltering( Tcl_ObjectContext context); /* 16 */ TCLAPI Tcl_Method Tcl_ObjectContextMethod(Tcl_ObjectContext context); /* 17 */ TCLAPI Tcl_Object Tcl_ObjectContextObject(Tcl_ObjectContext context); /* 18 */ TCLAPI Tcl_Size Tcl_ObjectContextSkippedArgs( Tcl_ObjectContext context); /* 19 */ TCLAPI void * Tcl_ClassGetMetadata(Tcl_Class clazz, const Tcl_ObjectMetadataType *typePtr); /* 20 */ TCLAPI void Tcl_ClassSetMetadata(Tcl_Class clazz, const Tcl_ObjectMetadataType *typePtr, void *metadata); /* 21 */ TCLAPI void * Tcl_ObjectGetMetadata(Tcl_Object object, const Tcl_ObjectMetadataType *typePtr); /* 22 */ TCLAPI void Tcl_ObjectSetMetadata(Tcl_Object object, const Tcl_ObjectMetadataType *typePtr, void *metadata); /* 23 */ TCLAPI int Tcl_ObjectContextInvokeNext(Tcl_Interp *interp, Tcl_ObjectContext context, Tcl_Size objc, Tcl_Obj *const *objv, Tcl_Size skip); /* 24 */ TCLAPI Tcl_ObjectMapMethodNameProc * Tcl_ObjectGetMethodNameMapper( Tcl_Object object); /* 25 */ TCLAPI void Tcl_ObjectSetMethodNameMapper(Tcl_Object object, Tcl_ObjectMapMethodNameProc *mapMethodNameProc); /* 26 */ |
| ︙ | ︙ | |||
155 156 157 158 159 160 161 |
Tcl_Class (*tcl_MethodDeclarerClass) (Tcl_Method method); /* 6 */
Tcl_Object (*tcl_MethodDeclarerObject) (Tcl_Method method); /* 7 */
int (*tcl_MethodIsPublic) (Tcl_Method method); /* 8 */
int (*tcl_MethodIsType) (Tcl_Method method, const Tcl_MethodType *typePtr, void **clientDataPtr); /* 9 */
Tcl_Obj * (*tcl_MethodName) (Tcl_Method method); /* 10 */
Tcl_Method (*tcl_NewInstanceMethod) (Tcl_Interp *interp, Tcl_Object object, Tcl_Obj *nameObj, int flags, const Tcl_MethodType *typePtr, void *clientData); /* 11 */
Tcl_Method (*tcl_NewMethod) (Tcl_Interp *interp, Tcl_Class cls, Tcl_Obj *nameObj, int flags, const Tcl_MethodType *typePtr, void *clientData); /* 12 */
| | | | | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
Tcl_Class (*tcl_MethodDeclarerClass) (Tcl_Method method); /* 6 */
Tcl_Object (*tcl_MethodDeclarerObject) (Tcl_Method method); /* 7 */
int (*tcl_MethodIsPublic) (Tcl_Method method); /* 8 */
int (*tcl_MethodIsType) (Tcl_Method method, const Tcl_MethodType *typePtr, void **clientDataPtr); /* 9 */
Tcl_Obj * (*tcl_MethodName) (Tcl_Method method); /* 10 */
Tcl_Method (*tcl_NewInstanceMethod) (Tcl_Interp *interp, Tcl_Object object, Tcl_Obj *nameObj, int flags, const Tcl_MethodType *typePtr, void *clientData); /* 11 */
Tcl_Method (*tcl_NewMethod) (Tcl_Interp *interp, Tcl_Class cls, Tcl_Obj *nameObj, int flags, const Tcl_MethodType *typePtr, void *clientData); /* 12 */
Tcl_Object (*tcl_NewObjectInstance) (Tcl_Interp *interp, Tcl_Class cls, const char *nameStr, const char *nsNameStr, Tcl_Size objc, Tcl_Obj *const *objv, Tcl_Size skip); /* 13 */
int (*tcl_ObjectDeleted) (Tcl_Object object); /* 14 */
int (*tcl_ObjectContextIsFiltering) (Tcl_ObjectContext context); /* 15 */
Tcl_Method (*tcl_ObjectContextMethod) (Tcl_ObjectContext context); /* 16 */
Tcl_Object (*tcl_ObjectContextObject) (Tcl_ObjectContext context); /* 17 */
Tcl_Size (*tcl_ObjectContextSkippedArgs) (Tcl_ObjectContext context); /* 18 */
void * (*tcl_ClassGetMetadata) (Tcl_Class clazz, const Tcl_ObjectMetadataType *typePtr); /* 19 */
void (*tcl_ClassSetMetadata) (Tcl_Class clazz, const Tcl_ObjectMetadataType *typePtr, void *metadata); /* 20 */
void * (*tcl_ObjectGetMetadata) (Tcl_Object object, const Tcl_ObjectMetadataType *typePtr); /* 21 */
void (*tcl_ObjectSetMetadata) (Tcl_Object object, const Tcl_ObjectMetadataType *typePtr, void *metadata); /* 22 */
int (*tcl_ObjectContextInvokeNext) (Tcl_Interp *interp, Tcl_ObjectContext context, Tcl_Size objc, Tcl_Obj *const *objv, Tcl_Size skip); /* 23 */
Tcl_ObjectMapMethodNameProc * (*tcl_ObjectGetMethodNameMapper) (Tcl_Object object); /* 24 */
void (*tcl_ObjectSetMethodNameMapper) (Tcl_Object object, Tcl_ObjectMapMethodNameProc *mapMethodNameProc); /* 25 */
void (*tcl_ClassSetConstructor) (Tcl_Interp *interp, Tcl_Class clazz, Tcl_Method method); /* 26 */
void (*tcl_ClassSetDestructor) (Tcl_Interp *interp, Tcl_Class clazz, Tcl_Method method); /* 27 */
Tcl_Obj * (*tcl_GetObjectName) (Tcl_Interp *interp, Tcl_Object object); /* 28 */
int (*tcl_MethodIsPrivate) (Tcl_Method method); /* 29 */
Tcl_Class (*tcl_GetClassOfObject) (Tcl_Object object); /* 30 */
|
| ︙ | ︙ |
Changes to generic/tclOODefineCmds.c.
| ︙ | ︙ | |||
245 246 247 248 249 250 251 |
*
* ----------------------------------------------------------------------
*/
void
TclOOObjectSetFilters(
Object *oPtr,
| | | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
*
* ----------------------------------------------------------------------
*/
void
TclOOObjectSetFilters(
Object *oPtr,
Tcl_Size numFilters,
Tcl_Obj *const *filters)
{
Tcl_Size i;
if (oPtr->filters.num) {
Tcl_Obj *filterObj;
FOREACH(filterObj, oPtr->filters) {
Tcl_DecrRefCount(filterObj);
}
|
| ︙ | ︙ | |||
305 306 307 308 309 310 311 |
* ----------------------------------------------------------------------
*/
void
TclOOClassSetFilters(
Tcl_Interp *interp,
Class *classPtr,
| | | | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
* ----------------------------------------------------------------------
*/
void
TclOOClassSetFilters(
Tcl_Interp *interp,
Class *classPtr,
Tcl_Size numFilters,
Tcl_Obj *const *filters)
{
Tcl_Size i;
if (classPtr->filters.num) {
Tcl_Obj *filterObj;
FOREACH(filterObj, classPtr->filters) {
Tcl_DecrRefCount(filterObj);
}
|
| ︙ | ︙ | |||
367 368 369 370 371 372 373 |
*
* ----------------------------------------------------------------------
*/
void
TclOOObjectSetMixins(
Object *oPtr,
| | | | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
*
* ----------------------------------------------------------------------
*/
void
TclOOObjectSetMixins(
Object *oPtr,
Tcl_Size numMixins,
Class *const *mixins)
{
Class *mixinPtr;
Tcl_Size i;
if (numMixins == 0) {
if (oPtr->mixins.num != 0) {
FOREACH(mixinPtr, oPtr->mixins) {
TclOORemoveFromInstances(oPtr, mixinPtr);
TclOODecrRefCount(mixinPtr->thisPtr);
}
|
| ︙ | ︙ | |||
428 429 430 431 432 433 434 |
* ----------------------------------------------------------------------
*/
void
TclOOClassSetMixins(
Tcl_Interp *interp,
Class *classPtr,
| | | | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
* ----------------------------------------------------------------------
*/
void
TclOOClassSetMixins(
Tcl_Interp *interp,
Class *classPtr,
Tcl_Size numMixins,
Class *const *mixins)
{
Class *mixinPtr;
Tcl_Size i;
if (numMixins == 0) {
if (classPtr->mixins.num != 0) {
FOREACH(mixinPtr, classPtr->mixins) {
TclOORemoveFromMixinSubs(classPtr, mixinPtr);
TclOODecrRefCount(mixinPtr->thisPtr);
}
|
| ︙ | ︙ | |||
481 482 483 484 485 486 487 |
* Helpers for installing standard and private variable maps.
*
* ----------------------------------------------------------------------
*/
static inline void
InstallStandardVariableMapping(
VariableNameList *vnlPtr,
| | | | 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
* Helpers for installing standard and private variable maps.
*
* ----------------------------------------------------------------------
*/
static inline void
InstallStandardVariableMapping(
VariableNameList *vnlPtr,
Tcl_Size varc,
Tcl_Obj *const *varv)
{
Tcl_Obj *variableObj;
Tcl_Size i, n;
int created;
Tcl_HashTable uniqueTable;
for (i=0 ; i<varc ; i++) {
Tcl_IncrRefCount(varv[i]);
}
FOREACH(variableObj, *vnlPtr) {
|
| ︙ | ︙ | |||
531 532 533 534 535 536 537 |
Tcl_DeleteHashTable(&uniqueTable);
}
}
static inline void
InstallPrivateVariableMapping(
PrivateVariableList *pvlPtr,
| | | | 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
Tcl_DeleteHashTable(&uniqueTable);
}
}
static inline void
InstallPrivateVariableMapping(
PrivateVariableList *pvlPtr,
Tcl_Size varc,
Tcl_Obj *const *varv,
int creationEpoch)
{
PrivateVariableMapping *privatePtr;
Tcl_Size i, n;
int created;
Tcl_HashTable uniqueTable;
for (i=0 ; i<varc ; i++) {
Tcl_IncrRefCount(varv[i]);
}
FOREACH_STRUCT(privatePtr, *pvlPtr) {
|
| ︙ | ︙ | |||
629 630 631 632 633 634 635 |
}
if (toPtr) {
newHPtr = Tcl_CreateHashEntry(oPtr->methodsPtr, toPtr,
&isNew);
if (hPtr == newHPtr) {
renameToSelf:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 |
}
if (toPtr) {
newHPtr = Tcl_CreateHashEntry(oPtr->methodsPtr, toPtr,
&isNew);
if (hPtr == newHPtr) {
renameToSelf:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot rename method to itself", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "RENAME_TO_SELF", NULL);
return TCL_ERROR;
} else if (!isNew) {
renameToExisting:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"method called %s already exists",
TclGetString(toPtr)));
|
| ︙ | ︙ | |||
700 701 702 703 704 705 706 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
Namespace *nsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
Tcl_HashSearch search;
Tcl_HashEntry *hPtr;
| | | | 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
Namespace *nsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
Tcl_HashSearch search;
Tcl_HashEntry *hPtr;
Tcl_Size soughtLen;
const char *soughtStr, *matchedStr = NULL;
if (objc < 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad call of unknown handler", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "BAD_UNKNOWN", NULL);
return TCL_ERROR;
}
if (TclOOGetDefineCmdContext(interp) == NULL) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
739 740 741 742 743 744 745 | * Got one match, and only one match! */ Tcl_Obj **newObjv = (Tcl_Obj **) TclStackAlloc(interp, sizeof(Tcl_Obj*) * (objc - 1)); int result; | | | 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 |
* Got one match, and only one match!
*/
Tcl_Obj **newObjv = (Tcl_Obj **)
TclStackAlloc(interp, sizeof(Tcl_Obj*) * (objc - 1));
int result;
newObjv[0] = Tcl_NewStringObj(matchedStr, -1);
Tcl_IncrRefCount(newObjv[0]);
if (objc > 2) {
memcpy(newObjv + 1, objv + 2, sizeof(Tcl_Obj *) * (objc - 2));
}
result = Tcl_EvalObjv(interp, objc - 1, newObjv, 0);
Tcl_DecrRefCount(newObjv[0]);
TclStackFree(interp, newObjv);
|
| ︙ | ︙ | |||
774 775 776 777 778 779 780 |
static Tcl_Command
FindCommand(
Tcl_Interp *interp,
Tcl_Obj *stringObj,
Tcl_Namespace *const namespacePtr)
{
| | | 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 |
static Tcl_Command
FindCommand(
Tcl_Interp *interp,
Tcl_Obj *stringObj,
Tcl_Namespace *const namespacePtr)
{
Tcl_Size length;
const char *nameStr, *string = Tcl_GetStringFromObj(stringObj, &length);
Namespace *const nsPtr = (Namespace *) namespacePtr;
FOREACH_HASH_DECLS;
Tcl_Command cmd, cmd2;
/*
* If someone is playing games, we stop playing right now.
|
| ︙ | ︙ | |||
842 843 844 845 846 847 848 |
int objc,
Tcl_Obj *const objv[])
{
CallFrame *framePtr, **framePtrPtr = &framePtr;
if (namespacePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 |
int objc,
Tcl_Obj *const objv[])
{
CallFrame *framePtr, **framePtrPtr = &framePtr;
if (namespacePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"no definition namespace available", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
/*
* framePtrPtr is needed to satisfy GCC 3.3's strict aliasing rules.
*/
|
| ︙ | ︙ | |||
883 884 885 886 887 888 889 |
Tcl_Object object;
if ((iPtr->varFramePtr == NULL)
|| (iPtr->varFramePtr->isProcCallFrame != FRAME_IS_OO_DEFINE
&& iPtr->varFramePtr->isProcCallFrame != PRIVATE_FRAME)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"this command may only be called from within the context of"
| | | | 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 |
Tcl_Object object;
if ((iPtr->varFramePtr == NULL)
|| (iPtr->varFramePtr->isProcCallFrame != FRAME_IS_OO_DEFINE
&& iPtr->varFramePtr->isProcCallFrame != PRIVATE_FRAME)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"this command may only be called from within the context of"
" an ::oo::define or ::oo::objdefine command", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return NULL;
}
object = (Tcl_Object)iPtr->varFramePtr->clientData;
if (Tcl_ObjectDeleted(object)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"this command cannot be called when the object has been"
" deleted", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return NULL;
}
return object;
}
/*
|
| ︙ | ︙ | |||
934 935 936 937 938 939 940 |
}
oPtr = (Object *) Tcl_GetObjectFromObj(interp, className);
iPtr->varFramePtr = savedFramePtr;
if (oPtr == NULL) {
return NULL;
}
if (oPtr->classPtr == NULL) {
| | | 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 |
}
oPtr = (Object *) Tcl_GetObjectFromObj(interp, className);
iPtr->varFramePtr = savedFramePtr;
if (oPtr == NULL) {
return NULL;
}
if (oPtr->classPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(errMsg, -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CLASS",
TclGetString(className), NULL);
return NULL;
}
return oPtr->classPtr;
}
|
| ︙ | ︙ | |||
993 994 995 996 997 998 999 |
* current name (post-execution) has to be
* used. This matters, because the object
* could have been renamed... */
const char *typeOfSubject) /* Part of the message, saying whether it was
* an object, class or class-as-object that
* was being configured. */
{
| | | | | 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
* current name (post-execution) has to be
* used. This matters, because the object
* could have been renamed... */
const char *typeOfSubject) /* Part of the message, saying whether it was
* an object, class or class-as-object that
* was being configured. */
{
Tcl_Size length;
Tcl_Obj *realNameObj = Tcl_ObjectDeleted((Tcl_Object) oPtr)
? savedNameObj : TclOOObjectName(interp, oPtr);
const char *objName = Tcl_GetStringFromObj(realNameObj, &length);
int limit = OBJNAME_LENGTH_IN_ERRORINFO_LIMIT;
int overflow = (length > limit);
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (in definition script for %s \"%.*s%s\" line %d)",
typeOfSubject, (overflow ? limit : (int)length), objName,
(overflow ? "..." : ""), Tcl_GetErrorLine(interp)));
}
/*
* ----------------------------------------------------------------------
*
* MagicDefinitionInvoke --
|
| ︙ | ︙ | |||
1030 1031 1032 1033 1034 1035 1036 |
int cmdIndex,
int objc,
Tcl_Obj *const *objv)
{
Tcl_Obj *objPtr, *obj2Ptr, **objs;
Tcl_Command cmd;
int isRoot, result, offset = cmdIndex + 1;
| | | 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
int cmdIndex,
int objc,
Tcl_Obj *const *objv)
{
Tcl_Obj *objPtr, *obj2Ptr, **objs;
Tcl_Command cmd;
int isRoot, result, offset = cmdIndex + 1;
Tcl_Size dummy;
/*
* More than one argument: fire them through the ensemble processing
* engine so that everything appears to be good and proper in error
* messages. Note that we cannot just concatenate and send through
* Tcl_EvalObjEx, as that doesn't do ensemble processing, and we cannot go
* through Tcl_EvalObjv without the extra work to pre-find the command, as
|
| ︙ | ︙ | |||
1433 1434 1435 1436 1437 1438 1439 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (oPtr->flags & ROOT_OBJECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | | 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (oPtr->flags & ROOT_OBJECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may not modify the class of the root object class", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
if (oPtr->flags & ROOT_CLASS) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may not modify the class of the class of classes", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
/*
* Parse the argument to get the class to set the object's class to.
*/
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "className");
return TCL_ERROR;
}
clsPtr = GetClassInOuterContext(interp, objv[1],
"the class of an object must be a class");
if (clsPtr == NULL) {
return TCL_ERROR;
}
if (oPtr == clsPtr->thisPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may not change classes into an instance of themselves", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
/*
* Set the object's class.
*/
|
| ︙ | ︙ | |||
1530 1531 1532 1533 1534 1535 1536 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr;
Class *clsPtr;
Tcl_Method method;
| | | 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr;
Class *clsPtr;
Tcl_Method method;
Tcl_Size bodyLength;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "arguments body");
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
1612 1613 1614 1615 1616 1617 1618 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
if (oPtr->flags & (ROOT_OBJECT | ROOT_CLASS)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may not modify the definition namespace of the root classes",
-1));
|
| ︙ | ︙ | |||
1643 1644 1645 1646 1647 1648 1649 |
if (!TclGetString(objv[objc - 1])[0]) {
nsNamePtr = NULL;
} else {
nsPtr = GetNamespaceInOuterContext(interp, objv[objc - 1]);
if (nsPtr == NULL) {
return TCL_ERROR;
}
| | | 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 |
if (!TclGetString(objv[objc - 1])[0]) {
nsNamePtr = NULL;
} else {
nsPtr = GetNamespaceInOuterContext(interp, objv[objc - 1]);
if (nsPtr == NULL) {
return TCL_ERROR;
}
nsNamePtr = Tcl_NewStringObj(nsPtr->fullName, -1);
Tcl_IncrRefCount(nsNamePtr);
}
/*
* Update the correct field of the class definition.
*/
|
| ︙ | ︙ | |||
1696 1697 1698 1699 1700 1701 1702 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceDeleteMethod && !oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceDeleteMethod && !oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
for (i = 1; i < objc; i++) {
/*
* Delete the method structure from the appropriate hash table.
|
| ︙ | ︙ | |||
1741 1742 1743 1744 1745 1746 1747 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr;
Class *clsPtr;
Tcl_Method method;
| | | 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr;
Class *clsPtr;
Tcl_Method method;
Tcl_Size bodyLength;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "body");
return TCL_ERROR;
}
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
|
| ︙ | ︙ | |||
1822 1823 1824 1825 1826 1827 1828 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
clsPtr = oPtr->classPtr;
if (!isInstanceExport && !clsPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
clsPtr = oPtr->classPtr;
if (!isInstanceExport && !clsPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
for (i = 1; i < objc; i++) {
/*
* Exporting is done by adding the PUBLIC_METHOD flag to the method
|
| ︙ | ︙ | |||
1916 1917 1918 1919 1920 1921 1922 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceForward && !oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceForward && !oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
isPublic = Tcl_StringMatch(TclGetString(objv[1]), PUBLIC_PATTERN)
? PUBLIC_METHOD : 0;
if (IsPrivateDefine(interp)) {
isPublic = TRUE_PRIVATE_METHOD;
|
| ︙ | ︙ | |||
1994 1995 1996 1997 1998 1999 2000 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceMethod && !oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceMethod && !oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
if (objc == 5) {
if (Tcl_GetIndexFromObj(interp, objv[2], exportModes, "export flag",
0, &exportMode) != TCL_OK) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
2073 2074 2075 2076 2077 2078 2079 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceRenameMethod && !oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceRenameMethod && !oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
/*
* Delete the method entry from the appropriate hash table, and transfer
* the thing it points to to its new entry. To do this, we first need to
|
| ︙ | ︙ | |||
2135 2136 2137 2138 2139 2140 2141 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
clsPtr = oPtr->classPtr;
if (!isInstanceUnexport && !clsPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
clsPtr = oPtr->classPtr;
if (!isInstanceUnexport && !clsPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
for (i = 1; i < objc; i++) {
/*
* Unexporting is done by removing the PUBLIC_METHOD flag from the
|
| ︙ | ︙ | |||
2264 2265 2266 2267 2268 2269 2270 |
*/
int
TclOODefineSlots(
Foundation *fPtr)
{
const struct DeclaredSlot *slotInfoPtr;
| | | | | 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 |
*/
int
TclOODefineSlots(
Foundation *fPtr)
{
const struct DeclaredSlot *slotInfoPtr;
Tcl_Obj *getName = Tcl_NewStringObj("Get", -1);
Tcl_Obj *setName = Tcl_NewStringObj("Set", -1);
Tcl_Obj *resolveName = Tcl_NewStringObj("Resolve", -1);
Class *slotCls;
slotCls = ((Object *) Tcl_NewObjectInstance(fPtr->interp, (Tcl_Class)
fPtr->classCls, "::oo::Slot", NULL, TCL_INDEX_NONE, NULL, 0))->classPtr;
if (slotCls == NULL) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2320 2321 2322 2323 2324 2325 2326 |
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj, *filterObj;
| | | | | 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 |
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj, *filterObj;
Tcl_Size i;
if (Tcl_ObjectContextSkippedArgs(context) != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
NULL);
return TCL_ERROR;
}
if (oPtr == NULL) {
return TCL_ERROR;
} else if (!oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
TclNewObj(resultObj);
FOREACH(filterObj, oPtr->classPtr->filters) {
Tcl_ListObjAppendElement(NULL, resultObj, filterObj);
|
| ︙ | ︙ | |||
2353 2354 2355 2356 2357 2358 2359 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
| | | | | 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Size filterc;
Tcl_Obj **filterv;
if (Tcl_ObjectContextSkippedArgs(context) + 1 != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"filterList");
return TCL_ERROR;
}
objv += Tcl_ObjectContextSkippedArgs(context);
if (oPtr == NULL) {
return TCL_ERROR;
} else if (!oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
} else if (TclListObjGetElementsM(interp, objv[0], &filterc,
&filterv) != TCL_OK) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2401 2402 2403 2404 2405 2406 2407 |
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj;
Class *mixinPtr;
| | | | | 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 |
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj;
Class *mixinPtr;
Tcl_Size i;
if (Tcl_ObjectContextSkippedArgs(context) != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
NULL);
return TCL_ERROR;
}
if (oPtr == NULL) {
return TCL_ERROR;
} else if (!oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
TclNewObj(resultObj);
FOREACH(mixinPtr, oPtr->classPtr->mixins) {
Tcl_ListObjAppendElement(NULL, resultObj,
|
| ︙ | ︙ | |||
2436 2437 2438 2439 2440 2441 2442 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
| | | | | | 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Size mixinc, i;
Tcl_Obj **mixinv;
Class **mixins;
if (Tcl_ObjectContextSkippedArgs(context) + 1 != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"mixinList");
return TCL_ERROR;
}
objv += Tcl_ObjectContextSkippedArgs(context);
if (oPtr == NULL) {
return TCL_ERROR;
} else if (!oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
} else if (TclListObjGetElementsM(interp, objv[0], &mixinc,
&mixinv) != TCL_OK) {
return TCL_ERROR;
}
mixins = (Class **)TclStackAlloc(interp, sizeof(Class *) * mixinc);
for (i = 0; i < mixinc; i++) {
mixins[i] = GetClassInOuterContext(interp, mixinv[i],
"may only mix in classes");
if (mixins[i] == NULL) {
i--;
goto freeAndError;
}
if (TclOOIsReachable(oPtr->classPtr, mixins[i])) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may not mix a class into itself", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "SELF_MIXIN", NULL);
goto freeAndError;
}
}
TclOOClassSetMixins(interp, oPtr->classPtr, mixinc, mixins);
TclStackFree(interp, mixins);
|
| ︙ | ︙ | |||
2507 2508 2509 2510 2511 2512 2513 |
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj;
Class *superPtr;
| | | | | 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 |
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj;
Class *superPtr;
Tcl_Size i;
if (Tcl_ObjectContextSkippedArgs(context) != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
NULL);
return TCL_ERROR;
}
if (oPtr == NULL) {
return TCL_ERROR;
} else if (!oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
TclNewObj(resultObj);
FOREACH(superPtr, oPtr->classPtr->superclasses) {
Tcl_ListObjAppendElement(NULL, resultObj,
|
| ︙ | ︙ | |||
2541 2542 2543 2544 2545 2546 2547 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
| | | | | | | 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Size superc, j;
Tcl_Size i;
Tcl_Obj **superv;
Class **superclasses, *superPtr;
if (Tcl_ObjectContextSkippedArgs(context) + 1 != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"superclassList");
return TCL_ERROR;
}
objv += Tcl_ObjectContextSkippedArgs(context);
if (oPtr == NULL) {
return TCL_ERROR;
} else if (!oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
} else if (oPtr == oPtr->fPtr->objectCls->thisPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may not modify the superclass of the root object", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
} else if (TclListObjGetElementsM(interp, objv[0], &superc,
&superv) != TCL_OK) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2610 2611 2612 2613 2614 2615 2616 |
-1));
Tcl_SetErrorCode(interp, "TCL", "OO", "REPETITIOUS",NULL);
goto failedAfterAlloc;
}
}
if (TclOOIsReachable(oPtr->classPtr, superclasses[i])) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 |
-1));
Tcl_SetErrorCode(interp, "TCL", "OO", "REPETITIOUS",NULL);
goto failedAfterAlloc;
}
}
if (TclOOIsReachable(oPtr->classPtr, superclasses[i])) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to form circular dependency graph", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "CIRCULARITY", NULL);
failedAfterAlloc:
for (; i-- > 0 ;) {
TclOODecrRefCount(superclasses[i]->thisPtr);
}
Tcl_Free(superclasses);
return TCL_ERROR;
|
| ︙ | ︙ | |||
2674 2675 2676 2677 2678 2679 2680 |
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj;
| | | | | 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 |
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj;
Tcl_Size i;
if (Tcl_ObjectContextSkippedArgs(context) != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
NULL);
return TCL_ERROR;
}
if (oPtr == NULL) {
return TCL_ERROR;
} else if (!oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
}
TclNewObj(resultObj);
if (IsPrivateDefine(interp)) {
PrivateVariableMapping *privatePtr;
|
| ︙ | ︙ | |||
2717 2718 2719 2720 2721 2722 2723 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
| | | | | | 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Size i;
Tcl_Size varc;
Tcl_Obj **varv;
if (Tcl_ObjectContextSkippedArgs(context) + 1 != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"filterList");
return TCL_ERROR;
}
objv += Tcl_ObjectContextSkippedArgs(context);
if (oPtr == NULL) {
return TCL_ERROR;
} else if (!oPtr->classPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"attempt to misuse API", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
return TCL_ERROR;
} else if (TclListObjGetElementsM(interp, objv[0], &varc,
&varv) != TCL_OK) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2789 2790 2791 2792 2793 2794 2795 |
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj, *filterObj;
| | | | 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 |
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj, *filterObj;
Tcl_Size i;
if (Tcl_ObjectContextSkippedArgs(context) != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
NULL);
return TCL_ERROR;
} else if (oPtr == NULL) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2816 2817 2818 2819 2820 2821 2822 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
| | | | 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Size filterc;
Tcl_Obj **filterv;
if (Tcl_ObjectContextSkippedArgs(context) + 1 != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"filterList");
return TCL_ERROR;
} else if (oPtr == NULL) {
return TCL_ERROR;
}
objv += Tcl_ObjectContextSkippedArgs(context);
|
| ︙ | ︙ | |||
2858 2859 2860 2861 2862 2863 2864 |
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj;
Class *mixinPtr;
| | | | 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 |
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj;
Class *mixinPtr;
Tcl_Size i;
if (Tcl_ObjectContextSkippedArgs(context) != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
NULL);
return TCL_ERROR;
} else if (oPtr == NULL) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2888 2889 2890 2891 2892 2893 2894 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
| | | | | 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Size i;
Tcl_Size mixinc;
Tcl_Obj **mixinv;
Class **mixins;
if (Tcl_ObjectContextSkippedArgs(context) + 1 != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"mixinList");
return TCL_ERROR;
} else if (oPtr == NULL) {
return TCL_ERROR;
}
objv += Tcl_ObjectContextSkippedArgs(context);
|
| ︙ | ︙ | |||
2943 2944 2945 2946 2947 2948 2949 |
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj;
| | | | 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 |
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Obj *resultObj;
Tcl_Size i;
if (Tcl_ObjectContextSkippedArgs(context) != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
NULL);
return TCL_ERROR;
} else if (oPtr == NULL) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2980 2981 2982 2983 2984 2985 2986 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
| | | | 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
Tcl_ObjectContext context,
int objc,
Tcl_Obj *const *objv)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
Tcl_Size varc, i;
Tcl_Obj **varv;
if (Tcl_ObjectContextSkippedArgs(context) + 1 != objc) {
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"variableList");
return TCL_ERROR;
} else if (oPtr == NULL) {
return TCL_ERROR;
}
objv += Tcl_ObjectContextSkippedArgs(context);
|
| ︙ | ︙ |
Changes to generic/tclOOInfo.c.
| ︙ | ︙ | |||
116 117 118 119 120 121 122 |
/*
* Install into the [info] ensemble.
*/
infoCmd = Tcl_FindCommand(interp, "info", NULL, TCL_GLOBAL_ONLY);
if (infoCmd) {
Tcl_GetEnsembleMappingDict(NULL, infoCmd, &mapDict);
| | | | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
/*
* Install into the [info] ensemble.
*/
infoCmd = Tcl_FindCommand(interp, "info", NULL, TCL_GLOBAL_ONLY);
if (infoCmd) {
Tcl_GetEnsembleMappingDict(NULL, infoCmd, &mapDict);
Tcl_DictObjPut(NULL, mapDict, Tcl_NewStringObj("object", -1),
Tcl_NewStringObj("::oo::InfoObject", -1));
Tcl_DictObjPut(NULL, mapDict, Tcl_NewStringObj("class", -1),
Tcl_NewStringObj("::oo::InfoClass", -1));
Tcl_SetEnsembleMappingDict(interp, infoCmd, mapDict);
}
}
/*
* ----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
190 191 192 193 194 195 196 |
if (objc == 2) {
Tcl_SetObjResult(interp,
TclOOObjectName(interp, oPtr->selfCls->thisPtr));
return TCL_OK;
} else {
Class *mixinPtr, *o2clsPtr;
| | | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
if (objc == 2) {
Tcl_SetObjResult(interp,
TclOOObjectName(interp, oPtr->selfCls->thisPtr));
return TCL_OK;
} else {
Class *mixinPtr, *o2clsPtr;
Tcl_Size i;
o2clsPtr = GetClassFromObj(interp, objv[2]);
if (o2clsPtr == NULL) {
return TCL_ERROR;
}
FOREACH(mixinPtr, oPtr->mixins) {
|
| ︙ | ︙ | |||
260 261 262 263 264 265 266 |
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(objv[2]), NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod((Method *)Tcl_GetHashValue(hPtr));
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(objv[2]), NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod((Method *)Tcl_GetHashValue(hPtr));
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"definition not available for this kind of method", -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(objv[2]), NULL);
return TCL_ERROR;
}
TclNewObj(resultObjs[0]);
for (localPtr=procPtr->firstLocalPtr; localPtr!=NULL;
localPtr=localPtr->nextPtr) {
if (TclIsVarArgument(localPtr)) {
Tcl_Obj *argObj;
TclNewObj(argObj);
Tcl_ListObjAppendElement(NULL, argObj,
Tcl_NewStringObj(localPtr->name, -1));
if (localPtr->defValuePtr != NULL) {
Tcl_ListObjAppendElement(NULL, argObj, localPtr->defValuePtr);
}
Tcl_ListObjAppendElement(NULL, resultObjs[0], argObj);
}
}
resultObjs[1] = TclOOGetMethodBody((Method *)Tcl_GetHashValue(hPtr));
|
| ︙ | ︙ | |||
303 304 305 306 307 308 309 |
static int
InfoObjectFiltersCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
| | | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
static int
InfoObjectFiltersCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Tcl_Size i;
Tcl_Obj *filterObj, *resultObj;
Object *oPtr;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "objName");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
407 408 409 410 411 412 413 |
"class", "metaclass", "mixin", "object", "typeof", NULL
};
enum IsACats {
IsClass, IsMetaclass, IsMixin, IsObject, IsType
} idx;
Object *oPtr, *o2Ptr;
int result = 0;
| | | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
"class", "metaclass", "mixin", "object", "typeof", NULL
};
enum IsACats {
IsClass, IsMetaclass, IsMixin, IsObject, IsType
} idx;
Object *oPtr, *o2Ptr;
int result = 0;
Tcl_Size i;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "category objName ?arg ...?");
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[1], categories, "category", 0,
&idx) != TCL_OK) {
|
| ︙ | ︙ | |||
606 607 608 609 610 611 612 |
if (recurse) {
const char **names;
int i, numNames = TclOOGetSortedMethodList(oPtr, NULL, NULL, flag,
&names);
for (i=0 ; i<numNames ; i++) {
Tcl_ListObjAppendElement(NULL, resultObj,
| | | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
if (recurse) {
const char **names;
int i, numNames = TclOOGetSortedMethodList(oPtr, NULL, NULL, flag,
&names);
for (i=0 ; i<numNames ; i++) {
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(names[i], -1));
}
if (numNames > 0) {
Tcl_Free((void *)names);
}
} else if (oPtr->methodsPtr) {
FOREACH_HASH(namePtr, mPtr, oPtr->methodsPtr) {
if (mPtr->typePtr && (mPtr->flags & SCOPE_FLAGS) == flag) {
|
| ︙ | ︙ | |||
675 676 677 678 679 680 681 |
* Special entry for visibility control: pretend the method doesnt
* exist.
*/
goto unknownMethod;
}
| | | 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 |
* Special entry for visibility control: pretend the method doesnt
* exist.
*/
goto unknownMethod;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(mPtr->typePtr->name, -1));
return TCL_OK;
}
/*
* ----------------------------------------------------------------------
*
* InfoObjectMixinsCmd --
|
| ︙ | ︙ | |||
699 700 701 702 703 704 705 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Class *mixinPtr;
Object *oPtr;
Tcl_Obj *resultObj;
| | | 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 |
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Class *mixinPtr;
Object *oPtr;
Tcl_Obj *resultObj;
Tcl_Size i;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "objName");
return TCL_ERROR;
}
oPtr = (Object *) Tcl_GetObjectFromObj(interp, objv[1]);
if (oPtr == NULL) {
|
| ︙ | ︙ | |||
783 784 785 786 787 788 789 |
}
oPtr = (Object *) Tcl_GetObjectFromObj(interp, objv[1]);
if (oPtr == NULL) {
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
| | | 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 |
}
oPtr = (Object *) Tcl_GetObjectFromObj(interp, objv[1]);
if (oPtr == NULL) {
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
Tcl_NewStringObj(oPtr->namespacePtr->fullName, -1));
return TCL_OK;
}
/*
* ----------------------------------------------------------------------
*
* InfoObjectVariablesCmd --
|
| ︙ | ︙ | |||
806 807 808 809 810 811 812 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Object *oPtr;
Tcl_Obj *resultObj;
| | | 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Object *oPtr;
Tcl_Obj *resultObj;
Tcl_Size i;
int isPrivate = 0;
if (objc != 2 && objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "objName ?-private?");
return TCL_ERROR;
}
if (objc == 3) {
|
| ︙ | ︙ | |||
939 940 941 942 943 944 945 |
}
if (clsPtr->constructorPtr == NULL) {
return TCL_OK;
}
procPtr = TclOOGetProcFromMethod(clsPtr->constructorPtr);
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 |
}
if (clsPtr->constructorPtr == NULL) {
return TCL_OK;
}
procPtr = TclOOGetProcFromMethod(clsPtr->constructorPtr);
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"definition not available for this kind of method", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "METHOD_TYPE", NULL);
return TCL_ERROR;
}
TclNewObj(resultObjs[0]);
for (localPtr=procPtr->firstLocalPtr; localPtr!=NULL;
localPtr=localPtr->nextPtr) {
if (TclIsVarArgument(localPtr)) {
Tcl_Obj *argObj;
TclNewObj(argObj);
Tcl_ListObjAppendElement(NULL, argObj,
Tcl_NewStringObj(localPtr->name, -1));
if (localPtr->defValuePtr != NULL) {
Tcl_ListObjAppendElement(NULL, argObj, localPtr->defValuePtr);
}
Tcl_ListObjAppendElement(NULL, resultObjs[0], argObj);
}
}
resultObjs[1] = TclOOGetMethodBody(clsPtr->constructorPtr);
|
| ︙ | ︙ | |||
1006 1007 1008 1009 1010 1011 1012 |
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(objv[2]), NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod((Method *)Tcl_GetHashValue(hPtr));
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 |
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(objv[2]), NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod((Method *)Tcl_GetHashValue(hPtr));
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"definition not available for this kind of method", -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(objv[2]), NULL);
return TCL_ERROR;
}
TclNewObj(resultObjs[0]);
for (localPtr=procPtr->firstLocalPtr; localPtr!=NULL;
localPtr=localPtr->nextPtr) {
if (TclIsVarArgument(localPtr)) {
Tcl_Obj *argObj;
TclNewObj(argObj);
Tcl_ListObjAppendElement(NULL, argObj,
Tcl_NewStringObj(localPtr->name, -1));
if (localPtr->defValuePtr != NULL) {
Tcl_ListObjAppendElement(NULL, argObj, localPtr->defValuePtr);
}
Tcl_ListObjAppendElement(NULL, resultObjs[0], argObj);
}
}
resultObjs[1] = TclOOGetMethodBody((Method *)Tcl_GetHashValue(hPtr));
|
| ︙ | ︙ | |||
1117 1118 1119 1120 1121 1122 1123 |
if (clsPtr->destructorPtr == NULL) {
return TCL_OK;
}
procPtr = TclOOGetProcFromMethod(clsPtr->destructorPtr);
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 |
if (clsPtr->destructorPtr == NULL) {
return TCL_OK;
}
procPtr = TclOOGetProcFromMethod(clsPtr->destructorPtr);
if (procPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"definition not available for this kind of method", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "METHOD_TYPE", NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, TclOOGetMethodBody(clsPtr->destructorPtr));
return TCL_OK;
}
|
| ︙ | ︙ | |||
1143 1144 1145 1146 1147 1148 1149 |
static int
InfoClassFiltersCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
| | | 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 |
static int
InfoClassFiltersCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Tcl_Size i;
Tcl_Obj *filterObj, *resultObj;
Class *clsPtr;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "className");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1234 1235 1236 1237 1238 1239 1240 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Object *oPtr;
Class *clsPtr;
| | | 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Object *oPtr;
Class *clsPtr;
Tcl_Size i;
const char *pattern = NULL;
Tcl_Obj *resultObj;
if (objc != 2 && objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "className ?pattern?");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1357 1358 1359 1360 1361 1362 1363 |
break;
}
}
TclNewObj(resultObj);
if (recurse) {
const char **names;
| | | | 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 |
break;
}
}
TclNewObj(resultObj);
if (recurse) {
const char **names;
Tcl_Size i, numNames = TclOOGetSortedClassMethodList(clsPtr, flag, &names);
for (i=0 ; i<numNames ; i++) {
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(names[i], -1));
}
if (numNames > 0) {
Tcl_Free((void *)names);
}
} else {
FOREACH_HASH_DECLS;
|
| ︙ | ︙ | |||
1427 1428 1429 1430 1431 1432 1433 |
/*
* Special entry for visibility control: pretend the method doesnt
* exist.
*/
goto unknownMethod;
}
| | | 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 |
/*
* Special entry for visibility control: pretend the method doesnt
* exist.
*/
goto unknownMethod;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(mPtr->typePtr->name, -1));
return TCL_OK;
}
/*
* ----------------------------------------------------------------------
*
* InfoClassMixinsCmd --
|
| ︙ | ︙ | |||
1450 1451 1452 1453 1454 1455 1456 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Class *clsPtr, *mixinPtr;
Tcl_Obj *resultObj;
| | | 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Class *clsPtr, *mixinPtr;
Tcl_Obj *resultObj;
Tcl_Size i;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "className");
return TCL_ERROR;
}
clsPtr = GetClassFromObj(interp, objv[1]);
if (clsPtr == NULL) {
|
| ︙ | ︙ | |||
1492 1493 1494 1495 1496 1497 1498 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Class *clsPtr, *subclassPtr;
Tcl_Obj *resultObj;
| | | 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Class *clsPtr, *subclassPtr;
Tcl_Obj *resultObj;
Tcl_Size i;
const char *pattern = NULL;
if (objc != 2 && objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "className ?pattern?");
return TCL_ERROR;
}
clsPtr = GetClassFromObj(interp, objv[1]);
|
| ︙ | ︙ | |||
1547 1548 1549 1550 1551 1552 1553 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Class *clsPtr, *superPtr;
Tcl_Obj *resultObj;
| | | 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Class *clsPtr, *superPtr;
Tcl_Obj *resultObj;
Tcl_Size i;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "className");
return TCL_ERROR;
}
clsPtr = GetClassFromObj(interp, objv[1]);
if (clsPtr == NULL) {
|
| ︙ | ︙ | |||
1586 1587 1588 1589 1590 1591 1592 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Class *clsPtr;
Tcl_Obj *resultObj;
| | | 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 |
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Class *clsPtr;
Tcl_Obj *resultObj;
Tcl_Size i;
int isPrivate = 0;
if (objc != 2 && objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "className ?-private?");
return TCL_ERROR;
}
if (objc == 3) {
|
| ︙ | ︙ | |||
1659 1660 1661 1662 1663 1664 1665 |
* Get the call context and render its call chain.
*/
contextPtr = TclOOGetCallContext(oPtr, objv[2], PUBLIC_METHOD, NULL, NULL,
NULL);
if (contextPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 |
* Get the call context and render its call chain.
*/
contextPtr = TclOOGetCallContext(oPtr, objv[2], PUBLIC_METHOD, NULL, NULL,
NULL);
if (contextPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot construct any call chain", -1));
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
TclOORenderCallChain(interp, contextPtr->callPtr));
TclOODeleteContext(contextPtr);
return TCL_OK;
}
|
| ︙ | ︙ | |||
1704 1705 1706 1707 1708 1709 1710 |
/*
* Get an render the stereotypical call chain.
*/
callPtr = TclOOGetStereotypeCallChain(clsPtr, objv[2], PUBLIC_METHOD);
if (callPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 |
/*
* Get an render the stereotypical call chain.
*/
callPtr = TclOOGetStereotypeCallChain(clsPtr, objv[2], PUBLIC_METHOD);
if (callPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot construct any call chain", -1));
return TCL_ERROR;
}
Tcl_SetObjResult(interp, TclOORenderCallChain(interp, callPtr));
TclOODeleteChain(callPtr);
return TCL_OK;
}
|
| ︙ | ︙ |
Changes to generic/tclOOInt.h.
| ︙ | ︙ | |||
42 43 44 45 46 47 48 |
*/
typedef struct Method {
const Tcl_MethodType *typePtr;
/* The type of method. If NULL, this is a
* special flag record which is just used for
* the setting of the flags field. */
| | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
*/
typedef struct Method {
const Tcl_MethodType *typePtr;
/* The type of method. If NULL, this is a
* special flag record which is just used for
* the setting of the flags field. */
Tcl_Size refCount;
void *clientData; /* Type-specific data. */
Tcl_Obj *namePtr; /* Name of the method. */
struct Object *declaringObjectPtr;
/* The object that declares this method, or
* NULL if it was declared by a class. */
struct Class *declaringClassPtr;
/* The class that declares this method, or
|
| ︙ | ︙ | |||
79 80 81 82 83 84 85 |
typedef struct ProcedureMethod {
int version; /* Version of this structure. Currently must
* be 0. */
Proc *procPtr; /* Core of the implementation of the method;
* includes the argument definition and the
* body bytecodes. */
int flags; /* Flags to control features. */
| | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
typedef struct ProcedureMethod {
int version; /* Version of this structure. Currently must
* be 0. */
Proc *procPtr; /* Core of the implementation of the method;
* includes the argument definition and the
* body bytecodes. */
int flags; /* Flags to control features. */
Tcl_Size refCount;
void *clientData;
TclOO_PmCDDeleteProc *deleteClientdataProc;
TclOO_PmCDCloneProc *cloneClientdataProc;
ProcErrorProc *errProc; /* Replacement error handler. */
TclOO_PreCallProc *preCallProc;
/* Callback to allow for additional setup
* before the method executes. */
|
| ︙ | ︙ | |||
145 146 147 148 149 150 151 | * * The "num" field always counts the number of listType_t elements used in the * "list" field. When a "size" field exists, it describes how many elements * are present in the list; when absent, exactly "num" elements are present. */ #define LIST_STATIC(listType_t) \ | | | | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
*
* The "num" field always counts the number of listType_t elements used in the
* "list" field. When a "size" field exists, it describes how many elements
* are present in the list; when absent, exactly "num" elements are present.
*/
#define LIST_STATIC(listType_t) \
struct { Tcl_Size num; listType_t *list; }
#define LIST_DYNAMIC(listType_t) \
struct { Tcl_Size num, size; listType_t *list; }
/*
* These types are needed in function arguments.
*/
typedef LIST_STATIC(Tcl_Obj *) VariableNameList;
typedef LIST_STATIC(PrivateVariableMapping) PrivateVariableList;
|
| ︙ | ︙ | |||
180 181 182 183 184 185 186 |
LIST_STATIC(struct Class *) mixins;
/* Classes mixed into this object. */
LIST_STATIC(Tcl_Obj *) filters;
/* List of filter names. */
struct Class *classPtr; /* This is non-NULL for all classes, and NULL
* for everything else. It points to the class
* structure. */
| | | | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
LIST_STATIC(struct Class *) mixins;
/* Classes mixed into this object. */
LIST_STATIC(Tcl_Obj *) filters;
/* List of filter names. */
struct Class *classPtr; /* This is non-NULL for all classes, and NULL
* for everything else. It points to the class
* structure. */
Tcl_Size refCount; /* Number of strong references to this object.
* Note that there may be many more weak
* references; this mechanism exists to
* avoid Tcl_Preserve. */
int flags;
Tcl_Size creationEpoch; /* Unique value to make comparisons of objects
* easier. */
Tcl_Size epoch; /* Per-object epoch, incremented when the way
* an object should resolve call chains is
* changed. */
Tcl_HashTable *metadataPtr; /* Mapping from pointers to metadata type to
* the void *values that are the values
* of each piece of attached metadata. This
* field starts out as NULL and is only
* allocated if metadata is attached. */
|
| ︙ | ︙ | |||
325 326 327 328 329 330 331 |
* The foundation of the object system within an interpreter contains
* references to the key classes and namespaces, together with a few other
* useful bits and pieces. Probably ought to eventually go in the Interp
* structure itself.
*/
typedef struct ThreadLocalData {
| | | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
* The foundation of the object system within an interpreter contains
* references to the key classes and namespaces, together with a few other
* useful bits and pieces. Probably ought to eventually go in the Interp
* structure itself.
*/
typedef struct ThreadLocalData {
Tcl_Size nsCount; /* Epoch counter is used for keeping
* the values used in Tcl_Obj internal
* representations sane. Must be thread-local
* because Tcl_Objs can cross interpreter
* boundaries within a thread (objects don't
* generally cross threads). */
} ThreadLocalData;
|
| ︙ | ︙ | |||
349 350 351 352 353 354 355 |
Tcl_Namespace *objdefNs; /* Namespace containing special commands for
* manipulating objects and classes. The
* "oo::objdefine" command acts as a special
* kind of ensemble for this namespace. */
Tcl_Namespace *helpersNs; /* Namespace containing the commands that are
* only valid when executing inside a
* procedural method. */
| | | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
Tcl_Namespace *objdefNs; /* Namespace containing special commands for
* manipulating objects and classes. The
* "oo::objdefine" command acts as a special
* kind of ensemble for this namespace. */
Tcl_Namespace *helpersNs; /* Namespace containing the commands that are
* only valid when executing inside a
* procedural method. */
Tcl_Size epoch; /* Used to invalidate method chains when the
* class structure changes. */
ThreadLocalData *tsdPtr; /* Counter so we can allocate a unique
* namespace to each object. */
Tcl_Obj *unknownMethodNameObj;
/* Shared object containing the name of the
* unknown method handler method. */
Tcl_Obj *constructorName; /* Shared object containing the "name" of a
|
| ︙ | ︙ | |||
383 384 385 386 387 388 389 |
* record. */
int isFilter; /* Whether this is a filter invocation. */
Class *filterDeclarer; /* What class decided to add the filter; if
* NULL, it was added by the object. */
};
typedef struct CallChain {
| | | | | | | | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
* record. */
int isFilter; /* Whether this is a filter invocation. */
Class *filterDeclarer; /* What class decided to add the filter; if
* NULL, it was added by the object. */
};
typedef struct CallChain {
Tcl_Size objectCreationEpoch;/* The object's creation epoch. Note that the
* object reference is not stored in the call
* chain; it is in the call context. */
Tcl_Size objectEpoch; /* Local (object structure) epoch counter
* snapshot. */
Tcl_Size epoch; /* Global (class structure) epoch counter
* snapshot. */
int flags; /* Assorted flags, see below. */
Tcl_Size refCount; /* Reference count. */
Tcl_Size numChain; /* Size of the call chain. */
struct MInvoke *chain; /* Array of call chain entries. May point to
* staticChain if the number of entries is
* small. */
struct MInvoke staticChain[CALL_CHAIN_STATIC_SIZE];
} CallChain;
typedef struct CallContext {
Object *oPtr; /* The object associated with this call. */
Tcl_Size index; /* Index into the call chain of the currently
* executing method implementation. */
Tcl_Size skip; /* Current number of arguments to skip; can
* vary depending on whether it is a direct
* method call or a continuation via the
* [next] command. */
CallChain *callPtr; /* The actual call chain. */
} CallContext;
/*
|
| ︙ | ︙ | |||
501 502 503 504 505 506 507 |
void *clientData);
MODULE_SCOPE Tcl_Method TclNewMethod(Tcl_Interp *interp, Tcl_Class cls,
Tcl_Obj *nameObj, int flags,
const Tcl_MethodType *typePtr,
void *clientData);
MODULE_SCOPE int TclNRNewObjectInstance(Tcl_Interp *interp,
Tcl_Class cls, const char *nameStr,
| | | | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
void *clientData);
MODULE_SCOPE Tcl_Method TclNewMethod(Tcl_Interp *interp, Tcl_Class cls,
Tcl_Obj *nameObj, int flags,
const Tcl_MethodType *typePtr,
void *clientData);
MODULE_SCOPE int TclNRNewObjectInstance(Tcl_Interp *interp,
Tcl_Class cls, const char *nameStr,
const char *nsNameStr, Tcl_Size objc,
Tcl_Obj *const *objv, Tcl_Size skip,
Tcl_Object *objectPtr);
MODULE_SCOPE Object * TclNewObjectInstanceCommon(Tcl_Interp *interp,
Class *classPtr,
const char *nameStr,
const char *nsNameStr);
MODULE_SCOPE int TclOODecrRefCount(Object *oPtr);
MODULE_SCOPE int TclOOObjectDestroyed(Object *oPtr);
|
| ︙ | ︙ | |||
540 541 542 543 544 545 546 | const char ***stringsPtr); MODULE_SCOPE int TclOOInit(Tcl_Interp *interp); MODULE_SCOPE void TclOOInitInfo(Tcl_Interp *interp); MODULE_SCOPE int TclOOInvokeContext(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE int TclNRObjectContextInvokeNext(Tcl_Interp *interp, | | | | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | const char ***stringsPtr); MODULE_SCOPE int TclOOInit(Tcl_Interp *interp); MODULE_SCOPE void TclOOInitInfo(Tcl_Interp *interp); MODULE_SCOPE int TclOOInvokeContext(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE int TclNRObjectContextInvokeNext(Tcl_Interp *interp, Tcl_ObjectContext context, Tcl_Size objc, Tcl_Obj *const *objv, Tcl_Size skip); MODULE_SCOPE void TclOONewBasicMethod(Tcl_Interp *interp, Class *clsPtr, const DeclaredClassMethod *dcm); MODULE_SCOPE Tcl_Obj * TclOOObjectName(Tcl_Interp *interp, Object *oPtr); MODULE_SCOPE void TclOOReleaseClassContents(Tcl_Interp *interp, Object *oPtr); MODULE_SCOPE int TclOORemoveFromInstances(Object *oPtr, Class *clsPtr); MODULE_SCOPE int TclOORemoveFromMixins(Class *mixinPtr, Object *oPtr); |
| ︙ | ︙ | |||
574 575 576 577 578 579 580 | */ #define AddRef(ptr) ((ptr)->refCount++) /* * A convenience macro for iterating through the lists used in the internal * memory management of objects. | | | | 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 |
*/
#define AddRef(ptr) ((ptr)->refCount++)
/*
* A convenience macro for iterating through the lists used in the internal
* memory management of objects.
* REQUIRES DECLARATION: Tcl_Size i;
*/
#define FOREACH(var,ary) \
for(i=0 ; i<(ary).num; i++) if ((ary).list[i] == NULL) { \
continue; \
} else if ((var) = (ary).list[i], 1)
/*
* A variation where the array is an array of structs. There's no issue with
* possible NULLs; every element of the array will be iterated over and the
* varable set to a pointer to each of those elements in turn.
* REQUIRES DECLARATION: Tcl_Size i;
*/
#define FOREACH_STRUCT(var,ary) \
for(i=0 ; var=&((ary).list[i]), i<(ary).num; i++)
/*
* Convenience macros for iterating through hash tables. FOREACH_HASH_DECLS
|
| ︙ | ︙ |
Changes to generic/tclOOIntDecls.h.
| ︙ | ︙ | |||
38 39 40 41 42 43 44 | /* 4 */ TCLAPI Method * TclOONewProcMethod(Tcl_Interp *interp, Class *clsPtr, int flags, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, ProcedureMethod **pmPtrPtr); /* 5 */ TCLAPI int TclOOObjectCmdCore(Object *oPtr, Tcl_Interp *interp, | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /* 4 */ TCLAPI Method * TclOONewProcMethod(Tcl_Interp *interp, Class *clsPtr, int flags, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, ProcedureMethod **pmPtrPtr); /* 5 */ TCLAPI int TclOOObjectCmdCore(Object *oPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const *objv, int publicOnly, Class *startCls); /* 6 */ TCLAPI int TclOOIsReachable(Class *targetPtr, Class *startPtr); /* 7 */ TCLAPI Method * TclOONewForwardMethod(Tcl_Interp *interp, Class *clsPtr, int isPublic, Tcl_Obj *nameObj, Tcl_Obj *prefixObj); |
| ︙ | ︙ | |||
71 72 73 74 75 76 77 | ProcErrorProc *errProc, void *clientData, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, int flags, void **internalTokenPtr); /* 11 */ TCLAPI int TclOOInvokeObject(Tcl_Interp *interp, Tcl_Object object, Tcl_Class startCls, | | | | | | | | | | | | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
ProcErrorProc *errProc, void *clientData,
Tcl_Obj *nameObj, Tcl_Obj *argsObj,
Tcl_Obj *bodyObj, int flags,
void **internalTokenPtr);
/* 11 */
TCLAPI int TclOOInvokeObject(Tcl_Interp *interp,
Tcl_Object object, Tcl_Class startCls,
int publicPrivate, Tcl_Size objc,
Tcl_Obj *const *objv);
/* 12 */
TCLAPI void TclOOObjectSetFilters(Object *oPtr,
Tcl_Size numFilters, Tcl_Obj *const *filters);
/* 13 */
TCLAPI void TclOOClassSetFilters(Tcl_Interp *interp,
Class *classPtr, Tcl_Size numFilters,
Tcl_Obj *const *filters);
/* 14 */
TCLAPI void TclOOObjectSetMixins(Object *oPtr,
Tcl_Size numMixins, Class *const *mixins);
/* 15 */
TCLAPI void TclOOClassSetMixins(Tcl_Interp *interp,
Class *classPtr, Tcl_Size numMixins,
Class *const *mixins);
typedef struct TclOOIntStubs {
int magic;
void *hooks;
Tcl_Object (*tclOOGetDefineCmdContext) (Tcl_Interp *interp); /* 0 */
Tcl_Method (*tclOOMakeProcInstanceMethod) (Tcl_Interp *interp, Object *oPtr, int flags, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, const Tcl_MethodType *typePtr, void *clientData, Proc **procPtrPtr); /* 1 */
Tcl_Method (*tclOOMakeProcMethod) (Tcl_Interp *interp, Class *clsPtr, int flags, Tcl_Obj *nameObj, const char *namePtr, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, const Tcl_MethodType *typePtr, void *clientData, Proc **procPtrPtr); /* 2 */
Method * (*tclOONewProcInstanceMethod) (Tcl_Interp *interp, Object *oPtr, int flags, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, ProcedureMethod **pmPtrPtr); /* 3 */
Method * (*tclOONewProcMethod) (Tcl_Interp *interp, Class *clsPtr, int flags, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, ProcedureMethod **pmPtrPtr); /* 4 */
int (*tclOOObjectCmdCore) (Object *oPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const *objv, int publicOnly, Class *startCls); /* 5 */
int (*tclOOIsReachable) (Class *targetPtr, Class *startPtr); /* 6 */
Method * (*tclOONewForwardMethod) (Tcl_Interp *interp, Class *clsPtr, int isPublic, Tcl_Obj *nameObj, Tcl_Obj *prefixObj); /* 7 */
Method * (*tclOONewForwardInstanceMethod) (Tcl_Interp *interp, Object *oPtr, int isPublic, Tcl_Obj *nameObj, Tcl_Obj *prefixObj); /* 8 */
Tcl_Method (*tclOONewProcInstanceMethodEx) (Tcl_Interp *interp, Tcl_Object oPtr, TclOO_PreCallProc *preCallPtr, TclOO_PostCallProc *postCallPtr, ProcErrorProc *errProc, void *clientData, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, int flags, void **internalTokenPtr); /* 9 */
Tcl_Method (*tclOONewProcMethodEx) (Tcl_Interp *interp, Tcl_Class clsPtr, TclOO_PreCallProc *preCallPtr, TclOO_PostCallProc *postCallPtr, ProcErrorProc *errProc, void *clientData, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, int flags, void **internalTokenPtr); /* 10 */
int (*tclOOInvokeObject) (Tcl_Interp *interp, Tcl_Object object, Tcl_Class startCls, int publicPrivate, Tcl_Size objc, Tcl_Obj *const *objv); /* 11 */
void (*tclOOObjectSetFilters) (Object *oPtr, Tcl_Size numFilters, Tcl_Obj *const *filters); /* 12 */
void (*tclOOClassSetFilters) (Tcl_Interp *interp, Class *classPtr, Tcl_Size numFilters, Tcl_Obj *const *filters); /* 13 */
void (*tclOOObjectSetMixins) (Object *oPtr, Tcl_Size numMixins, Class *const *mixins); /* 14 */
void (*tclOOClassSetMixins) (Tcl_Interp *interp, Class *classPtr, Tcl_Size numMixins, Class *const *mixins); /* 15 */
} TclOOIntStubs;
extern const TclOOIntStubs *tclOOIntStubsPtr;
#ifdef __cplusplus
}
#endif
|
| ︙ | ︙ |
Changes to generic/tclOOMethod.c.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 | #endif #include "tclInt.h" #include "tclOOInt.h" #include "tclCompile.h" /* * Structure used to help delay computing names of objects or classes for | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#endif
#include "tclInt.h"
#include "tclOOInt.h"
#include "tclCompile.h"
/*
* Structure used to help delay computing names of objects or classes for
* [info frame] until needed, making invocation faster in the normal case.
*/
struct PNI {
Tcl_Interp *interp; /* Interpreter in which to compute the name of
* a method. */
Tcl_Method method; /* Method to compute the name of. */
};
|
| ︙ | ︙ | |||
383 384 385 386 387 388 389 |
TclOONewBasicMethod(
Tcl_Interp *interp,
Class *clsPtr, /* Class to attach the method to. */
const DeclaredClassMethod *dcm)
/* Name of the method, whether it is public,
* and the function to implement it. */
{
| | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
TclOONewBasicMethod(
Tcl_Interp *interp,
Class *clsPtr, /* Class to attach the method to. */
const DeclaredClassMethod *dcm)
/* Name of the method, whether it is public,
* and the function to implement it. */
{
Tcl_Obj *namePtr = Tcl_NewStringObj(dcm->name, -1);
Tcl_IncrRefCount(namePtr);
TclNewMethod(interp, (Tcl_Class) clsPtr, namePtr,
(dcm->isPublic ? PUBLIC_METHOD : 0), &dcm->definition, NULL);
Tcl_DecrRefCount(namePtr);
}
|
| ︙ | ︙ | |||
417 418 419 420 421 422 423 |
Tcl_Obj *bodyObj, /* The body of the method, which must not be
* NULL. */
ProcedureMethod **pmPtrPtr) /* Place to write pointer to procedure method
* structure to allow for deeper tuning of the
* structure's contents. NULL if caller is not
* interested. */
{
| | | 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
Tcl_Obj *bodyObj, /* The body of the method, which must not be
* NULL. */
ProcedureMethod **pmPtrPtr) /* Place to write pointer to procedure method
* structure to allow for deeper tuning of the
* structure's contents. NULL if caller is not
* interested. */
{
Tcl_Size argsLen;
ProcedureMethod *pmPtr;
Tcl_Method method;
if (TclListObjLengthM(interp, argsObj, &argsLen) != TCL_OK) {
return NULL;
}
pmPtr = (ProcedureMethod *)Tcl_Alloc(sizeof(ProcedureMethod));
|
| ︙ | ︙ | |||
469 470 471 472 473 474 475 |
Tcl_Obj *bodyObj, /* The body of the method, which must not be
* NULL. */
ProcedureMethod **pmPtrPtr) /* Place to write pointer to procedure method
* structure to allow for deeper tuning of the
* structure's contents. NULL if caller is not
* interested. */
{
| | | 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
Tcl_Obj *bodyObj, /* The body of the method, which must not be
* NULL. */
ProcedureMethod **pmPtrPtr) /* Place to write pointer to procedure method
* structure to allow for deeper tuning of the
* structure's contents. NULL if caller is not
* interested. */
{
Tcl_Size argsLen; /* TCL_INDEX_NONE => delete argsObj before exit */
ProcedureMethod *pmPtr;
const char *procName;
Tcl_Method method;
if (argsObj == NULL) {
argsLen = TCL_INDEX_NONE;
TclNewObj(argsObj);
|
| ︙ | ︙ | |||
1070 1071 1072 1073 1074 1075 1076 |
Interp *iPtr = (Interp *) interp;
CallFrame *framePtr = iPtr->varFramePtr;
CallContext *contextPtr;
Tcl_Obj *variableObj;
PrivateVariableMapping *privateVar;
Tcl_HashEntry *hPtr;
int isNew, cacheIt;
| | | 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 |
Interp *iPtr = (Interp *) interp;
CallFrame *framePtr = iPtr->varFramePtr;
CallContext *contextPtr;
Tcl_Obj *variableObj;
PrivateVariableMapping *privateVar;
Tcl_HashEntry *hPtr;
int isNew, cacheIt;
Tcl_Size i, varLen, len;
const char *match, *varName;
/*
* Check that the variable is being requested in a context that is also a
* method call; if not (i.e. we're evaluating in the object's namespace or
* in a procedure of that namespace) then we do nothing.
*/
|
| ︙ | ︙ | |||
1184 1185 1186 1187 1188 1189 1190 |
Tcl_Free(infoPtr);
}
static int
ProcedureMethodCompiledVarResolver(
TCL_UNUSED(Tcl_Interp *),
const char *varName,
| | | 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 |
Tcl_Free(infoPtr);
}
static int
ProcedureMethodCompiledVarResolver(
TCL_UNUSED(Tcl_Interp *),
const char *varName,
Tcl_Size length,
TCL_UNUSED(Tcl_Namespace *),
Tcl_ResolvedVarInfo **rPtrPtr)
{
OOResVarInfo *infoPtr;
Tcl_Obj *variableObj = Tcl_NewStringObj(varName, length);
/*
|
| ︙ | ︙ | |||
1265 1266 1267 1268 1269 1270 1271 |
static void
MethodErrorHandler(
Tcl_Interp *interp,
TCL_UNUSED(Tcl_Obj *) /*methodNameObj*/)
/* We pull the method name out of context instead of from argument */
{
| | | 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 |
static void
MethodErrorHandler(
Tcl_Interp *interp,
TCL_UNUSED(Tcl_Obj *) /*methodNameObj*/)
/* We pull the method name out of context instead of from argument */
{
Tcl_Size nameLen, objectNameLen;
CallContext *contextPtr = (CallContext *)((Interp *) interp)->varFramePtr->clientData;
Method *mPtr = contextPtr->callPtr->chain[contextPtr->index].mPtr;
const char *objectName, *kindName, *methodName =
Tcl_GetStringFromObj(mPtr->namePtr, &nameLen);
Object *declarerPtr;
if (mPtr->declaringObjectPtr != NULL) {
|
| ︙ | ︙ | |||
1301 1302 1303 1304 1305 1306 1307 |
TCL_UNUSED(Tcl_Obj *) /*methodNameObj*/)
/* Ignore. We know it is the constructor. */
{
CallContext *contextPtr = (CallContext *)((Interp *) interp)->varFramePtr->clientData;
Method *mPtr = contextPtr->callPtr->chain[contextPtr->index].mPtr;
Object *declarerPtr;
const char *objectName, *kindName;
| | | 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 |
TCL_UNUSED(Tcl_Obj *) /*methodNameObj*/)
/* Ignore. We know it is the constructor. */
{
CallContext *contextPtr = (CallContext *)((Interp *) interp)->varFramePtr->clientData;
Method *mPtr = contextPtr->callPtr->chain[contextPtr->index].mPtr;
Object *declarerPtr;
const char *objectName, *kindName;
Tcl_Size objectNameLen;
if (mPtr->declaringObjectPtr != NULL) {
declarerPtr = mPtr->declaringObjectPtr;
kindName = "object";
} else {
if (mPtr->declaringClassPtr == NULL) {
Tcl_Panic("method not declared in class or object");
|
| ︙ | ︙ | |||
1331 1332 1333 1334 1335 1336 1337 |
TCL_UNUSED(Tcl_Obj *) /*methodNameObj*/)
/* Ignore. We know it is the destructor. */
{
CallContext *contextPtr = (CallContext *)((Interp *) interp)->varFramePtr->clientData;
Method *mPtr = contextPtr->callPtr->chain[contextPtr->index].mPtr;
Object *declarerPtr;
const char *objectName, *kindName;
| | | 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 |
TCL_UNUSED(Tcl_Obj *) /*methodNameObj*/)
/* Ignore. We know it is the destructor. */
{
CallContext *contextPtr = (CallContext *)((Interp *) interp)->varFramePtr->clientData;
Method *mPtr = contextPtr->callPtr->chain[contextPtr->index].mPtr;
Object *declarerPtr;
const char *objectName, *kindName;
Tcl_Size objectNameLen;
if (mPtr->declaringObjectPtr != NULL) {
declarerPtr = mPtr->declaringObjectPtr;
kindName = "object";
} else {
if (mPtr->declaringClassPtr == NULL) {
Tcl_Panic("method not declared in class or object");
|
| ︙ | ︙ | |||
1406 1407 1408 1409 1410 1411 1412 |
for (localPtr=pmPtr->procPtr->firstLocalPtr; localPtr!=NULL;
localPtr=localPtr->nextPtr) {
if (TclIsVarArgument(localPtr)) {
Tcl_Obj *argObj;
TclNewObj(argObj);
Tcl_ListObjAppendElement(NULL, argObj,
| | | 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 |
for (localPtr=pmPtr->procPtr->firstLocalPtr; localPtr!=NULL;
localPtr=localPtr->nextPtr) {
if (TclIsVarArgument(localPtr)) {
Tcl_Obj *argObj;
TclNewObj(argObj);
Tcl_ListObjAppendElement(NULL, argObj,
Tcl_NewStringObj(localPtr->name, -1));
if (localPtr->defValuePtr != NULL) {
Tcl_ListObjAppendElement(NULL, argObj, localPtr->defValuePtr);
}
Tcl_ListObjAppendElement(NULL, argsObj, argObj);
}
}
|
| ︙ | ︙ | |||
1469 1470 1471 1472 1473 1474 1475 |
Tcl_Interp *interp, /* Interpreter for error reporting. */
Object *oPtr, /* The object to attach the method to. */
int flags, /* Whether the method is public or not. */
Tcl_Obj *nameObj, /* The name of the method. */
Tcl_Obj *prefixObj) /* List of arguments that form the command
* prefix to forward to. */
{
| | | | 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 |
Tcl_Interp *interp, /* Interpreter for error reporting. */
Object *oPtr, /* The object to attach the method to. */
int flags, /* Whether the method is public or not. */
Tcl_Obj *nameObj, /* The name of the method. */
Tcl_Obj *prefixObj) /* List of arguments that form the command
* prefix to forward to. */
{
Tcl_Size prefixLen;
ForwardMethod *fmPtr;
if (TclListObjLengthM(interp, prefixObj, &prefixLen) != TCL_OK) {
return NULL;
}
if (prefixLen < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"method forward prefix must be non-empty", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "BAD_FORWARD", NULL);
return NULL;
}
fmPtr = (ForwardMethod *)Tcl_Alloc(sizeof(ForwardMethod));
fmPtr->prefixObj = prefixObj;
Tcl_IncrRefCount(prefixObj);
|
| ︙ | ︙ | |||
1508 1509 1510 1511 1512 1513 1514 |
Tcl_Interp *interp, /* Interpreter for error reporting. */
Class *clsPtr, /* The class to attach the method to. */
int flags, /* Whether the method is public or not. */
Tcl_Obj *nameObj, /* The name of the method. */
Tcl_Obj *prefixObj) /* List of arguments that form the command
* prefix to forward to. */
{
| | | | 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 |
Tcl_Interp *interp, /* Interpreter for error reporting. */
Class *clsPtr, /* The class to attach the method to. */
int flags, /* Whether the method is public or not. */
Tcl_Obj *nameObj, /* The name of the method. */
Tcl_Obj *prefixObj) /* List of arguments that form the command
* prefix to forward to. */
{
Tcl_Size prefixLen;
ForwardMethod *fmPtr;
if (TclListObjLengthM(interp, prefixObj, &prefixLen) != TCL_OK) {
return NULL;
}
if (prefixLen < 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"method forward prefix must be non-empty", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "BAD_FORWARD", NULL);
return NULL;
}
fmPtr = (ForwardMethod *)Tcl_Alloc(sizeof(ForwardMethod));
fmPtr->prefixObj = prefixObj;
Tcl_IncrRefCount(prefixObj);
|
| ︙ | ︙ | |||
1550 1551 1552 1553 1554 1555 1556 |
Tcl_ObjectContext context, /* The method calling context. */
int objc, /* Number of arguments. */
Tcl_Obj *const *objv) /* Arguments as actually seen. */
{
CallContext *contextPtr = (CallContext *) context;
ForwardMethod *fmPtr = (ForwardMethod *)clientData;
Tcl_Obj **argObjs, **prefixObjs;
| | | 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 |
Tcl_ObjectContext context, /* The method calling context. */
int objc, /* Number of arguments. */
Tcl_Obj *const *objv) /* Arguments as actually seen. */
{
CallContext *contextPtr = (CallContext *) context;
ForwardMethod *fmPtr = (ForwardMethod *)clientData;
Tcl_Obj **argObjs, **prefixObjs;
Tcl_Size numPrefixes, skip = contextPtr->skip;
int len;
/*
* Build the real list of arguments to use. Note that we know that the
* prefixObj field of the ForwardMethod structure holds a reference to a
* non-empty list, so there's a whole class of failures ("not a list") we
* can ignore here.
|
| ︙ | ︙ |
Changes to generic/tclObj.c.
| ︙ | ︙ | |||
76 77 78 79 80 81 82 |
* The structure defined below is used in this file only.
*/
typedef struct {
Tcl_HashTable *lineCLPtr; /* This table remembers for each Tcl_Obj
* generated by a call to the function
* TclSubstTokens() from a literal text
| | | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
* The structure defined below is used in this file only.
*/
typedef struct {
Tcl_HashTable *lineCLPtr; /* This table remembers for each Tcl_Obj
* generated by a call to the function
* TclSubstTokens() from a literal text
* where bs+nl sequences occurred in it, if
* any. I.e. this table keeps track of
* invisible and stripped continuation lines.
* Its keys are Tcl_Obj pointers, the values
* are ContLineLoc pointers. See the file
* tclCompile.h for the definition of this
* structure, and for references to all
* related places in the core. */
|
| ︙ | ︙ | |||
107 108 109 110 111 112 113 |
* structure; every thread will have its own structure instance. The purpose
* of this structure is to allow deeply nested collections of Tcl_Objs to be
* freed without taking a vast depth of C stack (which could cause all sorts
* of breakage.)
*/
typedef struct PendingObjData {
| | | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
* structure; every thread will have its own structure instance. The purpose
* of this structure is to allow deeply nested collections of Tcl_Objs to be
* freed without taking a vast depth of C stack (which could cause all sorts
* of breakage.)
*/
typedef struct PendingObjData {
int deletionCount; /* Count of the number of invocations of
* TclFreeObj() are on the stack (at least
* conceptually; many are actually expanded
* macros). */
Tcl_Obj *deletionStack; /* Stack of objects that have had TclFreeObj()
* invoked upon them but which can't be
* deleted yet because they are in a nested
* invocation of TclFreeObj(). By postponing
* this way, we limit the maximum overall C
* stack depth when deleting a complex object.
* The down-side is that we alter the overall
* behaviour by altering the order in which
* objects are deleted, and we change the
* order in which the string rep and the
* internal rep of an object are deleted. Note
|
| ︙ | ︙ | |||
353 354 355 356 357 358 359 |
* the referenced command). NULL if the name
* is fully qualified.*/
size_t refNsId; /* refNsPtr's unique namespace id. Used to
* verify that refNsPtr is still valid (e.g.,
* it's possible that the cmd's containing
* namespace was deleted and a new one created
* at the same address). */
| | | > > > > > > > > > > > > | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
* the referenced command). NULL if the name
* is fully qualified.*/
size_t refNsId; /* refNsPtr's unique namespace id. Used to
* verify that refNsPtr is still valid (e.g.,
* it's possible that the cmd's containing
* namespace was deleted and a new one created
* at the same address). */
Tcl_Size refNsCmdEpoch; /* Value of the referencing namespace's
* cmdRefEpoch when the pointer was cached.
* Before using the cached pointer, we check
* if the namespace's epoch was incremented;
* if so, this cached pointer is invalid. */
Tcl_Size cmdEpoch; /* Value of the command's cmdEpoch when this
* pointer was cached. Before using the cached
* pointer, we check if the cmd's epoch was
* incremented; if so, the cmd was renamed,
* deleted, hidden, or exposed, and so the
* pointer is invalid. */
size_t refCount; /* Reference count: 1 for each cmdName object
* that has a pointer to this ResolvedCmdName
* structure as its internal rep. This
* structure can be freed when refCount
* becomes zero. */
} ResolvedCmdName;
#ifdef TCL_MEM_DEBUG
/*
* Filler matches the value used for filling freed memory in tclCkalloc.
* On 32-bit systems, the ref counts do not cross 0x7fffffff. On 64-bit
* implementations, ref counts will never reach this value (unless explicitly
* incremented without actual references!)
*/
#define FREEDREFCOUNTFILLER \
(Tcl_Size)(sizeof(objPtr->refCount) == 4 ? 0xe8e8e8e8 : 0xe8e8e8e8e8e8e8e8)
#endif
/*
*-------------------------------------------------------------------------
*
* TclInitObjectSubsystem --
*
* This function is invoked to perform once-only initialization of the
|
| ︙ | ︙ | |||
571 572 573 574 575 576 577 |
* TIP #280
*----------------------------------------------------------------------
*/
ContLineLoc *
TclContinuationsEnter(
Tcl_Obj *objPtr,
| | | | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
* TIP #280
*----------------------------------------------------------------------
*/
ContLineLoc *
TclContinuationsEnter(
Tcl_Obj *objPtr,
Tcl_Size num,
int *loc)
{
int newEntry;
ThreadSpecificData *tsdPtr = TclGetContLineTable();
Tcl_HashEntry *hPtr =
Tcl_CreateHashEntry(tsdPtr->lineCLPtr, objPtr, &newEntry);
ContLineLoc *clLocPtr = (ContLineLoc *)Tcl_Alloc(offsetof(ContLineLoc, loc) + (num + 1U) *sizeof(int));
if (!newEntry) {
/*
* We're entering ContLineLoc data for the same value more than one
* time. Taking care not to leak the old entry.
*
* This can happen when literals in a proc body are shared. See for
* example test info-30.19 where the action (code) for all branches of
* the switch command is identical, mapping them all to the same
* literal. An interesting result of this is that the number and
* locations (offset) of invisible continuation lines in the literal
* are the same for all occurrences.
*
* Note that while reusing the existing entry is possible it requires
* the same actions as for a new entry because we have to copy the
* incoming num/loc data even so. Because we are called from
* TclContinuationsEnterDerived for this case, which modified the
* stored locations (Rebased to the proper relative offset). Just
* returning the stored entry would rebase them a second time, or
|
| ︙ | ︙ | |||
638 639 640 641 642 643 644 |
void
TclContinuationsEnterDerived(
Tcl_Obj *objPtr,
int start,
int *clNext)
{
| | | 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
void
TclContinuationsEnterDerived(
Tcl_Obj *objPtr,
int start,
int *clNext)
{
Tcl_Size length;
int end, num;
int *wordCLLast = clNext;
/*
* We have to handle invisible continuations lines here as well, despite
* the code we have in TclSubstTokens (TST) for that. Why ? Nesting. If
* our script is the sole argument to an 'eval' command, for example, the
|
| ︙ | ︙ | |||
881 882 883 884 885 886 887 |
Tcl_Interp *interp, /* Interpreter used for error reporting. */
Tcl_Obj *objPtr) /* Points to the Tcl object onto which the
* name of each registered type is appended as
* a list element. */
{
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
| | | | 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 |
Tcl_Interp *interp, /* Interpreter used for error reporting. */
Tcl_Obj *objPtr) /* Points to the Tcl object onto which the
* name of each registered type is appended as
* a list element. */
{
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
Tcl_Size numElems;
/*
* Get the test for a valid list out of the way first.
*/
if (TclListObjLengthM(interp, objPtr, &numElems) != TCL_OK) {
return TCL_ERROR;
}
/*
* Type names are NUL-terminated, not counted strings. This code relies on
* that.
*/
Tcl_MutexLock(&tableMutex);
for (hPtr = Tcl_FirstHashEntry(&typeTable, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj((char *)Tcl_GetHashKey(&typeTable, hPtr), -1));
}
Tcl_MutexUnlock(&tableMutex);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
1049 1050 1051 1052 1053 1054 1055 | /* *---------------------------------------------------------------------- * * TclDbInitNewObj -- * * Called via the TclNewObj or TclDbNewObj macros when TCL_MEM_DEBUG is * enabled. This function will initialize the members of a Tcl_Obj | | | 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 | /* *---------------------------------------------------------------------- * * TclDbInitNewObj -- * * Called via the TclNewObj or TclDbNewObj macros when TCL_MEM_DEBUG is * enabled. This function will initialize the members of a Tcl_Obj * struct. Initialization would be done inline via the TclNewObj macro * when compiling without TCL_MEM_DEBUG. * * Results: * The Tcl_Obj struct members are initialized. * * Side effects: * None. |
| ︙ | ︙ | |||
1346 1347 1348 1349 1350 1351 1352 |
/*
* Check for a double free of the same value. This is slightly tricky
* because it is customary to free a Tcl_Obj when its refcount falls
* either from 1 to 0, or from 0 to -1. Falling from -1 to -2, though,
* and so on, is always a sign of a botch in the caller.
*/
| | | 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 |
/*
* Check for a double free of the same value. This is slightly tricky
* because it is customary to free a Tcl_Obj when its refcount falls
* either from 1 to 0, or from 0 to -1. Falling from -1 to -2, though,
* and so on, is always a sign of a botch in the caller.
*/
if (objPtr->refCount == (Tcl_Size)-2) {
Tcl_Panic("Reference count for %p was negative", objPtr);
}
/*
* Now, in case we just approved drop from 1 to 0 as acceptable, make
* sure we do not accept a second free when falling from 0 to -1.
* Skip that possibility so any double free will trigger the panic.
*/
|
| ︙ | ︙ | |||
1401 1402 1403 1404 1405 1406 1407 |
/*
* We cannot use TclGetContinuationTable() here, because that may
* re-initialize the thread-data for calls coming after the finalization.
* We have to access it using the low-level call and then check for
* validity. This function can be called after TclFinalizeThreadData() has
* already killed the thread-global data structures. Performing
| | | 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 |
/*
* We cannot use TclGetContinuationTable() here, because that may
* re-initialize the thread-data for calls coming after the finalization.
* We have to access it using the low-level call and then check for
* validity. This function can be called after TclFinalizeThreadData() has
* already killed the thread-global data structures. Performing
* TCL_TSD_INIT will leave us with an uninitialized memory block upon
* which we crash (if we where to access the uninitialized hashtable).
*/
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
Tcl_HashEntry *hPtr;
|
| ︙ | ︙ | |||
1492 1493 1494 1495 1496 1497 1498 |
/*
* We cannot use TclGetContinuationTable() here, because that may
* re-initialize the thread-data for calls coming after the finalization.
* We have to access it using the low-level call and then check for
* validity. This function can be called after TclFinalizeThreadData() has
* already killed the thread-global data structures. Performing
| | | 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 |
/*
* We cannot use TclGetContinuationTable() here, because that may
* re-initialize the thread-data for calls coming after the finalization.
* We have to access it using the low-level call and then check for
* validity. This function can be called after TclFinalizeThreadData() has
* already killed the thread-global data structures. Performing
* TCL_TSD_INIT will leave us with an uninitialized memory block upon
* which we crash (if we where to access the uninitialized hashtable).
*/
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
Tcl_HashEntry *hPtr;
|
| ︙ | ︙ | |||
1686 1687 1688 1689 1690 1691 1692 | * Side effects: * May call the object's updateStringProc to update the string * representation from the internal representation. * *---------------------------------------------------------------------- */ | | | 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 |
* Side effects:
* May call the object's updateStringProc to update the string
* representation from the internal representation.
*
*----------------------------------------------------------------------
*/
#if !defined(TCL_NO_DEPRECATED)
char *
TclGetStringFromObj(
Tcl_Obj *objPtr, /* Object whose string rep byte pointer should
* be returned. */
int *lengthPtr) /* If non-NULL, the location where the string
* rep's byte array length should * be stored.
* If NULL, no length is stored. */
|
| ︙ | ︙ | |||
1723 1724 1725 1726 1727 1728 1729 |
"failed to create a valid string rep",
objPtr->typePtr->name);
}
}
if (lengthPtr != NULL) {
if (objPtr->length > INT_MAX) {
Tcl_Panic("Tcl_GetStringFromObj with 'int' lengthPtr"
| | > | | 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 |
"failed to create a valid string rep",
objPtr->typePtr->name);
}
}
if (lengthPtr != NULL) {
if (objPtr->length > INT_MAX) {
Tcl_Panic("Tcl_GetStringFromObj with 'int' lengthPtr"
" cannot handle such long strings. Please use 'size_t'");
}
*lengthPtr = (int)objPtr->length;
}
return objPtr->bytes;
}
#endif /* !defined(TCL_NO_DEPRECATED) */
#undef Tcl_GetStringFromObj
char *
Tcl_GetStringFromObj(
Tcl_Obj *objPtr, /* Object whose string rep byte pointer should
* be returned. */
Tcl_Size *lengthPtr) /* If non-NULL, the location where the string
* rep's byte array length should * be stored.
* If NULL, no length is stored. */
{
if (objPtr->bytes == NULL) {
/*
* Note we do not check for objPtr->typePtr == NULL. An invariant
* of a properly maintained Tcl_Obj is that at least one of
|
| ︙ | ︙ | |||
2159 2160 2161 2162 2163 2164 2165 |
if (ParseBoolean(objPtr) == TCL_OK) {
return TCL_OK;
}
badBoolean:
if (interp != NULL) {
| | | | | 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 |
if (ParseBoolean(objPtr) == TCL_OK) {
return TCL_OK;
}
badBoolean:
if (interp != NULL) {
Tcl_Size length;
const char *str = Tcl_GetStringFromObj(objPtr, &length);
Tcl_Obj *msg;
TclNewLiteralStringObj(msg, "expected boolean value but got \"");
Tcl_AppendLimitedToObj(msg, str, length, 50, "");
Tcl_AppendToObj(msg, "\"", -1);
Tcl_SetObjResult(interp, msg);
Tcl_SetErrorCode(interp, "TCL", "VALUE", "BOOLEAN", NULL);
}
return TCL_ERROR;
}
static int
ParseBoolean(
Tcl_Obj *objPtr) /* The object to parse/convert. */
{
int newBool;
char lowerCase[6];
Tcl_Size i, length;
const char *str = Tcl_GetStringFromObj(objPtr, &length);
if ((length == 0) || (length > 5)) {
/*
* Longest valid boolean string rep. is "false".
*/
|
| ︙ | ︙ | |||
2458 2459 2460 2461 2462 2463 2464 |
if (dblProc) {
return dblProc(interp, objPtr, dblPtr);
}
if (objPtr->typePtr == &tclDoubleType) {
if (isnan(objPtr->internalRep.doubleValue)) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 |
if (dblProc) {
return dblProc(interp, objPtr, dblPtr);
}
if (objPtr->typePtr == &tclDoubleType) {
if (isnan(objPtr->internalRep.doubleValue)) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"floating point value is Not a Number", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DOUBLE", "NAN",
NULL);
}
return TCL_ERROR;
}
*dblPtr = (double) objPtr->internalRep.doubleValue;
return TCL_OK;
|
| ︙ | ︙ | |||
2590 2591 2592 2593 2594 2595 2596 |
if (TclGetLongFromObj(interp, objPtr, &l) != TCL_OK) {
return TCL_ERROR;
}
if ((ULONG_MAX > UINT_MAX) && ((l > UINT_MAX) || (l < INT_MIN))) {
if (interp != NULL) {
const char *s =
"integer value too large to represent";
| | | 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 |
if (TclGetLongFromObj(interp, objPtr, &l) != TCL_OK) {
return TCL_ERROR;
}
if ((ULONG_MAX > UINT_MAX) && ((l > UINT_MAX) || (l < INT_MIN))) {
if (interp != NULL) {
const char *s =
"integer value too large to represent";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, NULL);
}
return TCL_ERROR;
}
*intPtr = (int) l;
return TCL_OK;
#endif
|
| ︙ | ︙ | |||
2755 2756 2757 2758 2759 2760 2761 |
}
}
#ifndef TCL_WIDE_INT_IS_LONG
tooLarge:
#endif
if (interp != NULL) {
const char *s = "integer value too large to represent";
| | | 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 |
}
}
#ifndef TCL_WIDE_INT_IS_LONG
tooLarge:
#endif
if (interp != NULL) {
const char *s = "integer value too large to represent";
Tcl_Obj *msg = Tcl_NewStringObj(s, -1);
Tcl_SetObjResult(interp, msg);
Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, NULL);
}
return TCL_ERROR;
}
} while (TclParseNumber(interp, objPtr, "integer", NULL, -1, NULL,
|
| ︙ | ︙ | |||
2990 2991 2992 2993 2994 2995 2996 |
*wideIntPtr = (Tcl_WideInt)value;
return TCL_OK;
}
}
}
if (interp != NULL) {
const char *s = "integer value too large to represent";
| | | 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 |
*wideIntPtr = (Tcl_WideInt)value;
return TCL_OK;
}
}
}
if (interp != NULL) {
const char *s = "integer value too large to represent";
Tcl_Obj *msg = Tcl_NewStringObj(s, -1);
Tcl_SetObjResult(interp, msg);
Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, NULL);
}
return TCL_ERROR;
}
} while (TclParseNumber(interp, objPtr, "integer", NULL, -1, NULL,
|
| ︙ | ︙ | |||
3074 3075 3076 3077 3078 3079 3080 |
}
*wideUIntPtr = (Tcl_WideUInt)value;
return TCL_OK;
}
if (interp != NULL) {
const char *s = "integer value too large to represent";
| | | 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 |
}
*wideUIntPtr = (Tcl_WideUInt)value;
return TCL_OK;
}
if (interp != NULL) {
const char *s = "integer value too large to represent";
Tcl_Obj *msg = Tcl_NewStringObj(s, -1);
Tcl_SetObjResult(interp, msg);
Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, NULL);
}
return TCL_ERROR;
}
} while (TclParseNumber(interp, objPtr, "integer", NULL, -1, NULL,
|
| ︙ | ︙ | |||
3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 |
TCL_PARSE_INTEGER_ONLY)==TCL_OK);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* FreeBignum --
*
* This function frees the internal rep of a bignum.
*
* Results:
* None.
*
| > > > > > > > > > > > > > > > > > > > > > > > > > | 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 |
TCL_PARSE_INTEGER_ONLY)==TCL_OK);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetSizeIntFromObj --
*
* Attempt to return a Tcl_Size from the Tcl object "objPtr".
*
* Results:
* TCL_OK - the converted Tcl_Size value is stored in *sizePtr
* TCL_ERROR - the error message is stored in interp
*
* Side effects:
* The function may free up any existing internal representation.
*
*----------------------------------------------------------------------
*/
int
Tcl_GetSizeIntFromObj(
Tcl_Interp *interp, /* Used for error reporting if not NULL. */
Tcl_Obj *objPtr, /* The object from which to get a int. */
Tcl_Size *sizePtr) /* Place to store resulting int. */
{
return TclGetSizeIntFromObj(interp, objPtr, sizePtr);
}
/*
*----------------------------------------------------------------------
*
* FreeBignum --
*
* This function frees the internal rep of a bignum.
*
* Results:
* None.
*
|
| ︙ | ︙ | |||
3194 3195 3196 3197 3198 3199 3200 | * * This function duplicates the internal rep of a bignum. * * Results: * None. * * Side effects: | | | 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 |
*
* This function duplicates the internal rep of a bignum.
*
* Results:
* None.
*
* Side effects:
* The destination object receives a copy of the source object
*
*----------------------------------------------------------------------
*/
static void
DupBignum(
Tcl_Obj *srcPtr,
|
| ︙ | ︙ | |||
3273 3274 3275 3276 3277 3278 3279 | } /* *---------------------------------------------------------------------- * * Tcl_NewBignumObj -- * | | | 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 | } /* *---------------------------------------------------------------------- * * Tcl_NewBignumObj -- * * Creates and initializes a bignum object. * * Results: * Returns the newly created object. * * Side effects: * The bignum value is cleared, since ownership has transferred to Tcl. * |
| ︙ | ︙ | |||
3470 3471 3472 3473 3474 3475 3476 | * the object if necessary. * * Results: * Returns TCL_OK if the conversion is successful, TCL_ERROR otherwise. * * Side effects: * A copy of bignum is stored in *bignumValue, which is expected to be | | | 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 | * the object if necessary. * * Results: * Returns TCL_OK if the conversion is successful, TCL_ERROR otherwise. * * Side effects: * A copy of bignum is stored in *bignumValue, which is expected to be * uninitialized or cleared. If conversion fails and the 'interp' * argument is not NULL, an error message is stored in the interpreter * result. * * It is expected that the caller will NOT have invoked mp_init on the * bignum value before passing it in. Tcl will initialize the mp_int as * it sets the value. The value is transferred from the internals of * objPtr to the caller, passing responsibility of the caller to call |
| ︙ | ︙ | |||
3645 3646 3647 3648 3649 3650 3651 |
return TCL_ERROR;
}
int
Tcl_GetNumber(
Tcl_Interp *interp,
const char *bytes,
| | | | 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 |
return TCL_ERROR;
}
int
Tcl_GetNumber(
Tcl_Interp *interp,
const char *bytes,
Tcl_Size numBytes,
void **clientDataPtr,
int *typePtr)
{
static Tcl_ThreadDataKey numberCacheKey;
Tcl_Obj *objPtr = (Tcl_Obj *)Tcl_GetThreadData(&numberCacheKey,
sizeof(Tcl_Obj));
Tcl_FreeInternalRep(objPtr);
if (bytes == NULL) {
bytes = &tclEmptyString;
numBytes = 0;
}
if (numBytes < 0) {
numBytes = strlen(bytes);
}
if (numBytes > INT_MAX) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"max size for a Tcl value (%d bytes) exceeded", INT_MAX));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
| ︙ | ︙ | |||
3773 3774 3775 3776 3777 3778 3779 |
Tcl_Obj *objPtr, /* The object we are registering a reference
* to. */
const char *file, /* The name of the source file calling this
* function; used for debugging. */
int line) /* Line number in the source file; used for
* debugging. */
{
| | | 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 |
Tcl_Obj *objPtr, /* The object we are registering a reference
* to. */
const char *file, /* The name of the source file calling this
* function; used for debugging. */
int line) /* Line number in the source file; used for
* debugging. */
{
if (objPtr->refCount == FREEDREFCOUNTFILLER) {
fprintf(stderr, "file = %s, line = %d\n", file, line);
fflush(stderr);
Tcl_Panic("incrementing refCount of previously disposed object");
}
#if TCL_THREADS
/*
|
| ︙ | ︙ | |||
3846 3847 3848 3849 3850 3851 3852 |
Tcl_Obj *objPtr, /* The object we are releasing a reference
* to. */
const char *file, /* The name of the source file calling this
* function; used for debugging. */
int line) /* Line number in the source file; used for
* debugging. */
{
| | | 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 |
Tcl_Obj *objPtr, /* The object we are releasing a reference
* to. */
const char *file, /* The name of the source file calling this
* function; used for debugging. */
int line) /* Line number in the source file; used for
* debugging. */
{
if (objPtr->refCount == FREEDREFCOUNTFILLER) {
fprintf(stderr, "file = %s, line = %d\n", file, line);
fflush(stderr);
Tcl_Panic("decrementing refCount of previously disposed object");
}
#if TCL_THREADS
/*
|
| ︙ | ︙ | |||
3928 3929 3930 3931 3932 3933 3934 |
* debugging. */
#else
TCL_UNUSED(const char *) /*file*/,
TCL_UNUSED(int) /*line*/)
#endif
{
#ifdef TCL_MEM_DEBUG
| | | 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 |
* debugging. */
#else
TCL_UNUSED(const char *) /*file*/,
TCL_UNUSED(int) /*line*/)
#endif
{
#ifdef TCL_MEM_DEBUG
if (objPtr->refCount == FREEDREFCOUNTFILLER) {
fprintf(stderr, "file = %s, line = %d\n", file, line);
fflush(stderr);
Tcl_Panic("checking whether previously disposed object is shared");
}
#if TCL_THREADS
/*
|
| ︙ | ︙ | |||
4144 4145 4146 4147 4148 4149 4150 |
TCL_HASH_TYPE
TclHashObjKey(
TCL_UNUSED(Tcl_HashTable *),
void *keyPtr) /* Key from which to compute hash value. */
{
Tcl_Obj *objPtr = (Tcl_Obj *)keyPtr;
| | | 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 |
TCL_HASH_TYPE
TclHashObjKey(
TCL_UNUSED(Tcl_HashTable *),
void *keyPtr) /* Key from which to compute hash value. */
{
Tcl_Obj *objPtr = (Tcl_Obj *)keyPtr;
Tcl_Size length;
const char *string = Tcl_GetStringFromObj(objPtr, &length);
TCL_HASH_TYPE result = 0;
/*
* I tried a zillion different hash functions and asked many other people
* for advice. Many people had their own favorite functions, all
* different, but no-one had much idea why they were good ones. I chose
|
| ︙ | ︙ | |||
4285 4286 4287 4288 4289 4290 4291 | * Modify an object to be an CmdName object that refers to the argument * Command structure. * * Results: * None. * * Side effects: | | | 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 | * Modify an object to be an CmdName object that refers to the argument * Command structure. * * Results: * None. * * Side effects: * The object's old internal rep is freed. Its string rep is not * changed. The refcount in the Command structure is incremented to keep * it from being freed if the command is later deleted until * TclNRExecuteByteCode has a chance to recognize that it was deleted. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ | |||
4576 4577 4578 4579 4580 4581 4582 |
Tcl_AppendPrintfToObj(descObj, ", internal representation %p:%p",
(void *) objv[1]->internalRep.twoPtrValue.ptr1,
(void *) objv[1]->internalRep.twoPtrValue.ptr2);
}
}
if (objv[1]->bytes) {
| | | | | 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 |
Tcl_AppendPrintfToObj(descObj, ", internal representation %p:%p",
(void *) objv[1]->internalRep.twoPtrValue.ptr1,
(void *) objv[1]->internalRep.twoPtrValue.ptr2);
}
}
if (objv[1]->bytes) {
Tcl_AppendToObj(descObj, ", string representation \"", -1);
Tcl_AppendLimitedToObj(descObj, objv[1]->bytes, objv[1]->length,
16, "...");
Tcl_AppendToObj(descObj, "\"", -1);
} else {
Tcl_AppendToObj(descObj, ", no string representation", -1);
}
Tcl_SetObjResult(interp, descObj);
return TCL_OK;
}
/*
|
| ︙ | ︙ |
Changes to generic/tclOptimize.c.
| ︙ | ︙ | |||
51 52 53 54 55 56 57 |
static void
LocateTargetAddresses(
CompileEnv *envPtr,
Tcl_HashTable *tablePtr)
{
unsigned char *currentInstPtr, *targetInstPtr;
int isNew;
| | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
static void
LocateTargetAddresses(
CompileEnv *envPtr,
Tcl_HashTable *tablePtr)
{
unsigned char *currentInstPtr, *targetInstPtr;
int isNew;
Tcl_Size i;
Tcl_HashEntry *hPtr;
Tcl_HashSearch hSearch;
Tcl_InitHashTable(tablePtr, TCL_ONE_WORD_KEYS);
/*
* The starts of commands represent target addresses.
|
| ︙ | ︙ | |||
228 229 230 231 232 233 234 |
case INST_PUSH1:
if (nextInst == INST_POP) {
blank = size + InstLength(nextInst);
} else if (nextInst == INST_STR_CONCAT1
&& TclGetUInt1AtPtr(currentInstPtr + size + 1) == 2) {
Tcl_Obj *litPtr = TclFetchLiteral(envPtr,
TclGetUInt1AtPtr(currentInstPtr + 1));
| | | | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
case INST_PUSH1:
if (nextInst == INST_POP) {
blank = size + InstLength(nextInst);
} else if (nextInst == INST_STR_CONCAT1
&& TclGetUInt1AtPtr(currentInstPtr + size + 1) == 2) {
Tcl_Obj *litPtr = TclFetchLiteral(envPtr,
TclGetUInt1AtPtr(currentInstPtr + 1));
Tcl_Size numBytes;
(void) Tcl_GetStringFromObj(litPtr, &numBytes);
if (numBytes == 0) {
blank = size + InstLength(nextInst);
}
}
break;
case INST_PUSH4:
if (nextInst == INST_POP) {
blank = size + 1;
} else if (nextInst == INST_STR_CONCAT1
&& TclGetUInt1AtPtr(currentInstPtr + size + 1) == 2) {
Tcl_Obj *litPtr = TclFetchLiteral(envPtr,
TclGetUInt4AtPtr(currentInstPtr + 1));
Tcl_Size numBytes;
(void) Tcl_GetStringFromObj(litPtr, &numBytes);
if (numBytes == 0) {
blank = size + InstLength(nextInst);
}
}
break;
|
| ︙ | ︙ |
Changes to generic/tclPanic.c.
| ︙ | ︙ | |||
62 63 64 65 66 67 68 | * Side effects: * The process dies, entering the debugger if possible. * *---------------------------------------------------------------------- */ /* | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
* Side effects:
* The process dies, entering the debugger if possible.
*
*----------------------------------------------------------------------
*/
/*
* The following comment is here so that Coverity's static analyzer knows that
* a Tcl_Panic() call can never return and avoids lots of false positives.
*/
/* coverity[+kill] */
void
Tcl_Panic(
const char *format,
|
| ︙ | ︙ |
Changes to generic/tclParse.c.
| ︙ | ︙ | |||
116 117 118 119 120 121 122 |
TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
};
/*
* Prototypes for local functions defined in this file:
*/
| | | | | | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
};
/*
* Prototypes for local functions defined in this file:
*/
static int CommandComplete(const char *script, Tcl_Size numBytes);
static Tcl_Size ParseComment(const char *src, Tcl_Size numBytes,
Tcl_Parse *parsePtr);
static int ParseTokens(const char *src, Tcl_Size numBytes, int mask,
int flags, Tcl_Parse *parsePtr);
static Tcl_Size ParseWhiteSpace(const char *src, Tcl_Size numBytes,
int *incompletePtr, char *typePtr);
static Tcl_Size ParseAllWhiteSpace(const char *src, Tcl_Size numBytes,
int *incompletePtr);
static int ParseHex(const char *src, Tcl_Size numBytes,
int *resultPtr);
/*
*----------------------------------------------------------------------
*
* TclParseInit --
*
|
| ︙ | ︙ | |||
148 149 150 151 152 153 154 |
*----------------------------------------------------------------------
*/
void
TclParseInit(
Tcl_Interp *interp, /* Interpreter to use for error reporting */
const char *start, /* Start of string to be parsed. */
| | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
*----------------------------------------------------------------------
*/
void
TclParseInit(
Tcl_Interp *interp, /* Interpreter to use for error reporting */
const char *start, /* Start of string to be parsed. */
Tcl_Size numBytes, /* Total number of bytes in string. If -1,
* the script consists of all bytes up to the
* first null character. */
Tcl_Parse *parsePtr) /* Points to struct to initialize */
{
parsePtr->numWords = 0;
parsePtr->tokenPtr = parsePtr->staticTokens;
parsePtr->numTokens = 0;
|
| ︙ | ︙ | |||
194 195 196 197 198 199 200 |
int
Tcl_ParseCommand(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
const char *start, /* First character of string containing one or
* more Tcl commands. */
| | | | | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
int
Tcl_ParseCommand(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
const char *start, /* First character of string containing one or
* more Tcl commands. */
Tcl_Size numBytes, /* Total number of bytes in string. If -1,
* the script consists of all bytes up to the
* first null character. */
int nested, /* Non-zero means this is a nested command:
* close bracket should be considered a
* command terminator. If zero, then close
* bracket has no special meaning. */
Tcl_Parse *parsePtr)
/* Structure to fill in with information about
* the parsed command; any previous
* information in the structure is ignored. */
{
const char *src; /* Points to current character in the
* command. */
char type; /* Result returned by CHAR_TYPE(*src). */
Tcl_Token *tokenPtr; /* Pointer to token being filled in. */
int wordIndex; /* Index of word token for current word. */
int terminators; /* CHAR_TYPE bits that indicate the end of a
* command. */
const char *termPtr; /* Set by Tcl_ParseBraces/QuotedString to
* point to char after terminating one. */
Tcl_Size scanned;
if (numBytes < 0 && start) {
numBytes = strlen(start);
}
TclParseInit(interp, start, numBytes, parsePtr);
if ((start == NULL) && (numBytes != 0)) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't parse a NULL pointer", -1));
}
return TCL_ERROR;
}
parsePtr->commentStart = NULL;
parsePtr->commentSize = 0;
parsePtr->commandStart = NULL;
parsePtr->commandSize = 0;
|
| ︙ | ︙ | |||
278 279 280 281 282 283 284 |
/* Are we missing white space after previous word? */
if (scanned == 0) {
if (src[-1] == '"') {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
/* Are we missing white space after previous word? */
if (scanned == 0) {
if (src[-1] == '"') {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"extra characters after close-quote", -1));
}
parsePtr->errorType = TCL_PARSE_QUOTE_EXTRA;
} else {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"extra characters after close-brace", -1));
}
parsePtr->errorType = TCL_PARSE_BRACE_EXTRA;
}
parsePtr->term = src;
error:
Tcl_FreeParse(parsePtr);
parsePtr->commandSize = parsePtr->end - parsePtr->commandStart;
|
| ︙ | ︙ | |||
378 379 380 381 382 383 384 |
* case of a word consisting of a single range of literal text.
*/
tokenPtr = &parsePtr->tokenPtr[wordIndex];
tokenPtr->size = src - tokenPtr->start;
tokenPtr->numComponents = (int)parsePtr->numTokens - (wordIndex + 1);
if (expandWord) {
| | | 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
* case of a word consisting of a single range of literal text.
*/
tokenPtr = &parsePtr->tokenPtr[wordIndex];
tokenPtr->size = src - tokenPtr->start;
tokenPtr->numComponents = (int)parsePtr->numTokens - (wordIndex + 1);
if (expandWord) {
Tcl_Size i;
int isLiteral = 1;
/*
* When a command includes a word that is an expanded literal; for
* example, {*}{1 2 3}, the parser performs that expansion
* immediately, generating several TCL_TOKEN_SIMPLE_WORDs instead
* of a single TCL_TOKEN_EXPAND_WORD that the Tcl_ParseCommand()
|
| ︙ | ︙ | |||
425 426 427 428 429 430 431 |
/*
* Step through the literal string, parsing and counting list
* elements.
*/
while (nextElem < listEnd) {
| | | 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
/*
* Step through the literal string, parsing and counting list
* elements.
*/
while (nextElem < listEnd) {
Tcl_Size size;
code = TclFindElement(NULL, nextElem, listEnd - nextElem,
&elemStart, &nextElem, &size, &literal);
if ((code != TCL_OK) || !literal) {
break;
}
if (elemStart < listEnd) {
|
| ︙ | ︙ | |||
617 618 619 620 621 622 623 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static Tcl_Size
ParseWhiteSpace(
const char *src, /* First character to parse. */
Tcl_Size numBytes, /* Max number of bytes to scan. */
int *incompletePtr, /* Set this boolean memory to true if parsing
* indicates an incomplete command. */
char *typePtr) /* Points to location to store character type
* of character that ends run of whitespace */
{
char type = TYPE_NORMAL;
const char *p = src;
|
| ︙ | ︙ | |||
671 672 673 674 675 676 677 | * * Results: * Returns the number of bytes recognized as white space. * *---------------------------------------------------------------------- */ | | | | | | | 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
*
* Results:
* Returns the number of bytes recognized as white space.
*
*----------------------------------------------------------------------
*/
static Tcl_Size
ParseAllWhiteSpace(
const char *src, /* First character to parse. */
Tcl_Size numBytes, /* Max number of byes to scan */
int *incompletePtr) /* Set true if parse is incomplete. */
{
char type;
const char *p = src;
do {
Tcl_Size scanned = ParseWhiteSpace(p, numBytes, incompletePtr, &type);
p += scanned;
numBytes -= scanned;
} while (numBytes && (*p == '\n') && (p++, --numBytes));
return (p-src);
}
Tcl_Size
TclParseAllWhiteSpace(
const char *src, /* First character to parse. */
Tcl_Size numBytes) /* Max number of byes to scan */
{
int dummy;
return ParseAllWhiteSpace(src, numBytes, &dummy);
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
723 724 725 726 727 728 729 |
*
*----------------------------------------------------------------------
*/
int
ParseHex(
const char *src, /* First character to parse. */
| | | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
*
*----------------------------------------------------------------------
*/
int
ParseHex(
const char *src, /* First character to parse. */
Tcl_Size numBytes, /* Max number of byes to scan */
int *resultPtr) /* Points to storage provided by caller where
* the character resulting from the
* conversion is to be written. */
{
int result = 0;
const char *p = src;
|
| ︙ | ︙ | |||
777 778 779 780 781 782 783 | * None. * *---------------------------------------------------------------------- */ int TclParseBackslash( | | | | | | 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 |
* None.
*
*----------------------------------------------------------------------
*/
int
TclParseBackslash(
const char *src, /* Points to the backslash character of a
* backslash sequence. */
Tcl_Size numBytes, /* Max number of bytes to scan. */
Tcl_Size *readPtr, /* NULL, or points to storage where the number
* of bytes scanned should be written. */
char *dst) /* NULL, or points to buffer where the UTF-8
* encoding of the backslash sequence is to be
* written. At most 4 bytes will be written there. */
{
const char *p = src+1;
int unichar;
int result;
Tcl_Size count;
char buf[4] = "";
if (numBytes == 0) {
if (readPtr != NULL) {
*readPtr = 0;
}
return 0;
|
| ︙ | ︙ | |||
977 978 979 980 981 982 983 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | | 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static Tcl_Size
ParseComment(
const char *src, /* First character to parse. */
Tcl_Size numBytes, /* Max number of bytes to scan. */
Tcl_Parse *parsePtr) /* Information about parse in progress.
* Updated if parsing indicates an incomplete
* command. */
{
const char *p = src;
int incomplete = parsePtr->incomplete;
while (numBytes) {
Tcl_Size scanned = ParseAllWhiteSpace(p, numBytes, &incomplete);
p += scanned;
numBytes -= scanned;
if ((numBytes == 0) || (*p != '#')) {
break;
}
if (parsePtr->commentStart == NULL) {
|
| ︙ | ︙ | |||
1053 1054 1055 1056 1057 1058 1059 |
*
*----------------------------------------------------------------------
*/
static int
ParseTokens(
const char *src, /* First character to parse. */
| | | 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 |
*
*----------------------------------------------------------------------
*/
static int
ParseTokens(
const char *src, /* First character to parse. */
Tcl_Size numBytes, /* Max number of bytes to scan. */
int mask, /* Specifies when to stop parsing. The parse
* stops at the first unquoted character whose
* CHAR_TYPE contains any of the bits in
* mask. */
int flags, /* OR-ed bits indicating what substitutions to
* perform: TCL_SUBST_COMMANDS,
* TCL_SUBST_VARIABLES, and
|
| ︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 |
&& (*(nestedPtr->term) == ']')
&& !(nestedPtr->incomplete)) {
break;
}
if (numBytes == 0) {
if (parsePtr->interp != NULL) {
Tcl_SetObjResult(parsePtr->interp, Tcl_NewStringObj(
| | | 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 |
&& (*(nestedPtr->term) == ']')
&& !(nestedPtr->incomplete)) {
break;
}
if (numBytes == 0) {
if (parsePtr->interp != NULL) {
Tcl_SetObjResult(parsePtr->interp, Tcl_NewStringObj(
"missing close-bracket", -1));
}
parsePtr->errorType = TCL_PARSE_MISSING_BRACKET;
parsePtr->term = tokenPtr->start;
parsePtr->incomplete = 1;
TclStackFree(parsePtr->interp, nestedPtr);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1331 1332 1333 1334 1335 1336 1337 |
int
Tcl_ParseVarName(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
const char *start, /* Start of variable substitution string.
* First character must be "$". */
| | | | 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 |
int
Tcl_ParseVarName(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
const char *start, /* Start of variable substitution string.
* First character must be "$". */
Tcl_Size numBytes, /* Total number of bytes in string. If -1,
* the string consists of all bytes up to the
* first null character. */
Tcl_Parse *parsePtr, /* Structure to fill in with information about
* the variable name. */
int append) /* Non-zero means append tokens to existing
* information in parsePtr; zero means ignore
* existing tokens in parsePtr and
* reinitialize it. */
{
Tcl_Token *tokenPtr;
const char *src;
int varIndex;
unsigned array;
if (numBytes < 0 && start) {
numBytes = strlen(start);
}
if (!append) {
TclParseInit(interp, start, numBytes, parsePtr);
}
if ((numBytes == 0) || (start == NULL)) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
1421 1422 1423 1424 1425 1426 1427 |
numBytes--;
src++;
ch= *src;
}
if (numBytes == 0) {
if (parsePtr->interp != NULL) {
Tcl_SetObjResult(parsePtr->interp, Tcl_NewStringObj(
| | | 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 |
numBytes--;
src++;
ch= *src;
}
if (numBytes == 0) {
if (parsePtr->interp != NULL) {
Tcl_SetObjResult(parsePtr->interp, Tcl_NewStringObj(
"missing close-brace for variable name", -1));
}
parsePtr->errorType = TCL_PARSE_MISSING_VAR_BRACE;
parsePtr->term = tokenPtr->start-1;
parsePtr->incomplete = 1;
goto error;
}
tokenPtr->size = src - tokenPtr->start;
|
| ︙ | ︙ | |||
1479 1480 1481 1482 1483 1484 1485 |
if (TCL_OK != ParseTokens(src+1, numBytes-1, TYPE_BAD_ARRAY_INDEX,
TCL_SUBST_ALL, parsePtr)) {
goto error;
}
if (parsePtr->term == src+numBytes){
if (parsePtr->interp != NULL) {
Tcl_SetObjResult(parsePtr->interp, Tcl_NewStringObj(
| | | | 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 |
if (TCL_OK != ParseTokens(src+1, numBytes-1, TYPE_BAD_ARRAY_INDEX,
TCL_SUBST_ALL, parsePtr)) {
goto error;
}
if (parsePtr->term == src+numBytes){
if (parsePtr->interp != NULL) {
Tcl_SetObjResult(parsePtr->interp, Tcl_NewStringObj(
"missing )", -1));
}
parsePtr->errorType = TCL_PARSE_MISSING_PAREN;
parsePtr->term = src;
parsePtr->incomplete = 1;
goto error;
} else if ((*parsePtr->term != ')')){
if (parsePtr->interp != NULL) {
Tcl_SetObjResult(parsePtr->interp, Tcl_NewStringObj(
"invalid character in array index", -1));
}
parsePtr->errorType = TCL_PARSE_SYNTAX;
parsePtr->term = src;
goto error;
}
src = parsePtr->term + 1;
}
|
| ︙ | ︙ | |||
1629 1630 1631 1632 1633 1634 1635 |
int
Tcl_ParseBraces(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
const char *start, /* Start of string enclosed in braces. The
* first character must be {'. */
| | | | | 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 |
int
Tcl_ParseBraces(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
const char *start, /* Start of string enclosed in braces. The
* first character must be {'. */
Tcl_Size numBytes, /* Total number of bytes in string. If -1,
* the string consists of all bytes up to the
* first null character. */
Tcl_Parse *parsePtr,
/* Structure to fill in with information about
* the string. */
int append, /* Non-zero means append tokens to existing
* information in parsePtr; zero means ignore
* existing tokens in parsePtr and
* reinitialize it. */
const char **termPtr) /* If non-NULL, points to word in which to
* store a pointer to the character just after
* the terminating '}' if the parse was
* successful. */
{
Tcl_Token *tokenPtr;
const char *src;
int startIndex, level;
Tcl_Size length;
if (numBytes < 0 && start) {
numBytes = strlen(start);
}
if (!append) {
TclParseInit(interp, start, numBytes, parsePtr);
}
if ((numBytes == 0) || (start == NULL)) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
1761 1762 1763 1764 1765 1766 1767 |
* error message in.
*/
goto error;
}
Tcl_SetObjResult(parsePtr->interp, Tcl_NewStringObj(
| | | 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 |
* error message in.
*/
goto error;
}
Tcl_SetObjResult(parsePtr->interp, Tcl_NewStringObj(
"missing close-brace", -1));
/*
* Guess if the problem is due to comments by searching the source string
* for a possible open brace within the context of a comment. Since we
* aren't performing a full Tcl parse, just look for an open brace
* preceded by a '<whitespace>#' on the same line.
*/
|
| ︙ | ︙ | |||
1784 1785 1786 1787 1788 1789 1790 |
break;
case '\n':
openBrace = 0;
break;
case '#' :
if (openBrace && TclIsSpaceProcM(src[-1])) {
Tcl_AppendToObj(Tcl_GetObjResult(parsePtr->interp),
| | | 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 |
break;
case '\n':
openBrace = 0;
break;
case '#' :
if (openBrace && TclIsSpaceProcM(src[-1])) {
Tcl_AppendToObj(Tcl_GetObjResult(parsePtr->interp),
": possible unbalanced brace in comment", -1);
goto error;
}
break;
}
}
}
|
| ︙ | ︙ | |||
1831 1832 1833 1834 1835 1836 1837 |
int
Tcl_ParseQuotedString(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
const char *start, /* Start of the quoted string. The first
* character must be '"'. */
| | | | | 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 |
int
Tcl_ParseQuotedString(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
const char *start, /* Start of the quoted string. The first
* character must be '"'. */
Tcl_Size numBytes, /* Total number of bytes in string. If -1,
* the string consists of all bytes up to the
* first null character. */
Tcl_Parse *parsePtr,
/* Structure to fill in with information about
* the string. */
int append, /* Non-zero means append tokens to existing
* information in parsePtr; zero means ignore
* existing tokens in parsePtr and
* reinitialize it. */
const char **termPtr) /* If non-NULL, points to word in which to
* store a pointer to the character just after
* the quoted string's terminating close-quote
* if the parse succeeds. */
{
if (numBytes < 0 && start) {
numBytes = strlen(start);
}
if (!append) {
TclParseInit(interp, start, numBytes, parsePtr);
}
if ((numBytes == 0) || (start == NULL)) {
return TCL_ERROR;
}
if (TCL_OK != ParseTokens(start+1, numBytes-1, TYPE_QUOTE, TCL_SUBST_ALL,
parsePtr)) {
goto error;
}
if (*parsePtr->term != '"') {
if (parsePtr->interp != NULL) {
Tcl_SetObjResult(parsePtr->interp, Tcl_NewStringObj(
"missing \"", -1));
}
parsePtr->errorType = TCL_PARSE_MISSING_QUOTE;
parsePtr->term = start;
parsePtr->incomplete = 1;
goto error;
}
if (termPtr != NULL) {
|
| ︙ | ︙ | |||
1912 1913 1914 1915 1916 1917 1918 |
*----------------------------------------------------------------------
*/
void
TclSubstParse(
Tcl_Interp *interp,
const char *bytes,
| | | | 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 |
*----------------------------------------------------------------------
*/
void
TclSubstParse(
Tcl_Interp *interp,
const char *bytes,
Tcl_Size numBytes,
int flags,
Tcl_Parse *parsePtr,
Tcl_InterpState *statePtr)
{
Tcl_Size length = numBytes;
const char *p = bytes;
TclParseInit(interp, p, length, parsePtr);
/*
* First parse the string rep of objPtr, as if it were enclosed as a
* "-quoted word in a normal Tcl command. Honor flags that selectively
|
| ︙ | ︙ | |||
2111 2112 2113 2114 2115 2116 2117 |
int
TclSubstTokens(
Tcl_Interp *interp, /* Interpreter in which to lookup variables,
* execute nested commands, and report
* errors. */
Tcl_Token *tokenPtr, /* Pointer to first in an array of tokens to
* evaluate and concatenate. */
| | | | 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 |
int
TclSubstTokens(
Tcl_Interp *interp, /* Interpreter in which to lookup variables,
* execute nested commands, and report
* errors. */
Tcl_Token *tokenPtr, /* Pointer to first in an array of tokens to
* evaluate and concatenate. */
Tcl_Size count, /* Number of tokens to consider at tokenPtr.
* Must be at least 1. */
int *tokensLeftPtr, /* If not NULL, points to memory where an
* integer representing the number of tokens
* left to be substituted will be written */
Tcl_Size line, /* The line the script starts on. */
int *clNextOuter, /* Information about an outer context for */
const char *outerScript) /* continuation line data. This is set by
* EvalEx() to properly handle [...]-nested
* commands. The 'outerScript' refers to the
* most-outer script containing the embedded
* command, which is refered to by 'script'.
* The 'clNextOuter' refers to the current
|
| ︙ | ︙ | |||
2139 2140 2141 2142 2143 2144 2145 |
* for the places generating arguments for
* which this is true. */
{
Tcl_Obj *result;
int code = TCL_OK;
#define NUM_STATIC_POS 20
int isLiteral;
| | | | | | 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 |
* for the places generating arguments for
* which this is true. */
{
Tcl_Obj *result;
int code = TCL_OK;
#define NUM_STATIC_POS 20
int isLiteral;
Tcl_Size i, maxNumCL, numCL, adjust;
int *clPosition = NULL;
Interp *iPtr = (Interp *) interp;
int inFile = iPtr->evalFlags & TCL_EVAL_FILE;
/*
* Each pass through this loop will substitute one token, and its
* components, if any. The only thing tricky here is that we go to some
* effort to pass Tcl_Obj's through untouched, to avoid string copying and
* Tcl_Obj creation if possible, to aid performance and limit shimmering.
*
* Further optimization opportunities might be to check for the equivalent
* of Tcl_SetObjResult(interp, Tcl_GetObjResult(interp)) and omit them.
*/
/*
* For the handling of continuation lines in literals, first check if
* this is actually a literal. If not then forego the additional
* processing. Otherwise preallocate a small table to store the
* locations of all continuation lines we find in this literal, if any.
* The table is extended if needed.
*/
numCL = 0;
maxNumCL = 0;
isLiteral = 1;
|
| ︙ | ︙ | |||
2215 2216 2217 2218 2219 2220 2221 |
* everything, just the number of lines we have to add as
* correction.
*/
if ((appendByteLength == 1) && (utfCharBytes[0] == ' ')
&& (tokenPtr->start[1] == '\n')) {
if (isLiteral) {
| | | 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 |
* everything, just the number of lines we have to add as
* correction.
*/
if ((appendByteLength == 1) && (utfCharBytes[0] == ' ')
&& (tokenPtr->start[1] == '\n')) {
if (isLiteral) {
Tcl_Size clPos;
if (result == 0) {
clPos = 0;
} else {
(void)Tcl_GetStringFromObj(result, &clPos);
}
|
| ︙ | ︙ | |||
2244 2245 2246 2247 2248 2249 2250 |
iPtr->numLevels++;
code = TclInterpReady(interp);
if (code == TCL_OK) {
/*
* Test cases: info-30.{6,8,9}
*/
| | | 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 |
iPtr->numLevels++;
code = TclInterpReady(interp);
if (code == TCL_OK) {
/*
* Test cases: info-30.{6,8,9}
*/
Tcl_Size theline;
TclAdvanceContinuations(&line, &clNextOuter,
tokenPtr->start - outerScript);
theline = line + adjust;
code = TclEvalEx(interp, tokenPtr->start+1, tokenPtr->size-2,
0, theline, clNextOuter, outerScript);
|
| ︙ | ︙ | |||
2421 2422 2423 2424 2425 2426 2427 |
*
*----------------------------------------------------------------------
*/
static int
CommandComplete(
const char *script, /* Script to check. */
| | | 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 |
*
*----------------------------------------------------------------------
*/
static int
CommandComplete(
const char *script, /* Script to check. */
Tcl_Size numBytes) /* Number of bytes in script. */
{
Tcl_Parse parse;
const char *p, *end;
int result;
p = script;
end = p + numBytes;
|
| ︙ | ︙ | |||
2495 2496 2497 2498 2499 2500 2501 |
*/
int
TclObjCommandComplete(
Tcl_Obj *objPtr) /* Points to object holding script to
* check. */
{
| | | 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 |
*/
int
TclObjCommandComplete(
Tcl_Obj *objPtr) /* Points to object holding script to
* check. */
{
Tcl_Size length;
const char *script = Tcl_GetStringFromObj(objPtr, &length);
return CommandComplete(script, length);
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
|
Changes to generic/tclPathObj.c.
| ︙ | ︙ | |||
21 22 23 24 25 26 27 | static Tcl_Obj * AppendPath(Tcl_Obj *head, Tcl_Obj *tail); static void DupFsPathInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void FreeFsPathInternalRep(Tcl_Obj *pathPtr); static void UpdateStringOfFsPath(Tcl_Obj *pathPtr); static int SetFsPathFromAny(Tcl_Interp *interp, Tcl_Obj *pathPtr); | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | static Tcl_Obj * AppendPath(Tcl_Obj *head, Tcl_Obj *tail); static void DupFsPathInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void FreeFsPathInternalRep(Tcl_Obj *pathPtr); static void UpdateStringOfFsPath(Tcl_Obj *pathPtr); static int SetFsPathFromAny(Tcl_Interp *interp, Tcl_Obj *pathPtr); static Tcl_Size FindSplitPos(const char *path, int separator); static int IsSeparatorOrNull(int ch); static Tcl_Obj * GetExtension(Tcl_Obj *pathPtr); static int MakePathFromNormalized(Tcl_Interp *interp, Tcl_Obj *pathPtr); /* * Define the 'path' object type, which Tcl uses to represent file paths |
| ︙ | ︙ | |||
202 203 204 205 206 207 208 |
oldDirSep = dirSep;
}
again:
if (IsSeparatorOrNull(dirSep[2])) {
/*
* Need to skip '.' in the path.
*/
| | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
oldDirSep = dirSep;
}
again:
if (IsSeparatorOrNull(dirSep[2])) {
/*
* Need to skip '.' in the path.
*/
Tcl_Size curLen;
if (retVal == NULL) {
const char *path = TclGetString(pathPtr);
retVal = Tcl_NewStringObj(path, dirSep - path);
Tcl_IncrRefCount(retVal);
}
(void)Tcl_GetStringFromObj(retVal, &curLen);
if (curLen == 0) {
Tcl_AppendToObj(retVal, dirSep, 1);
}
dirSep += 2;
oldDirSep = dirSep;
if (dirSep[0] != 0 && dirSep[1] == '.') {
goto again;
}
continue;
}
if (dirSep[2] == '.' && IsSeparatorOrNull(dirSep[3])) {
Tcl_Obj *linkObj;
Tcl_Size curLen;
char *linkStr;
/*
* Have '..' so need to skip previous directory.
*/
if (retVal == NULL) {
|
| ︙ | ︙ | |||
301 302 303 304 305 306 307 |
linkStr = Tcl_GetStringFromObj(retVal, &curLen);
/*
* Convert to forward-slashes on windows.
*/
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
| | | 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
linkStr = Tcl_GetStringFromObj(retVal, &curLen);
/*
* Convert to forward-slashes on windows.
*/
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
Tcl_Size i;
for (i = 0; i < curLen; i++) {
if (linkStr[i] == '\\') {
linkStr[i] = '/';
}
}
}
|
| ︙ | ︙ | |||
381 382 383 384 385 386 387 |
}
/*
* Ensure a windows drive like C:/ has a trailing separator.
*/
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
| | | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
}
/*
* Ensure a windows drive like C:/ has a trailing separator.
*/
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
Tcl_Size len;
const char *path = Tcl_GetStringFromObj(retVal, &len);
if (len == 2 && path[0] != 0 && path[1] == ':') {
if (Tcl_IsShared(retVal)) {
TclDecrRefCount(retVal);
retVal = Tcl_DuplicateObj(retVal);
Tcl_IncrRefCount(retVal);
|
| ︙ | ︙ | |||
473 474 475 476 477 478 479 |
*----------------------------------------------------------------------
*/
Tcl_PathType
TclFSGetPathType(
Tcl_Obj *pathPtr,
const Tcl_Filesystem **filesystemPtrPtr,
| | | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
*----------------------------------------------------------------------
*/
Tcl_PathType
TclFSGetPathType(
Tcl_Obj *pathPtr,
const Tcl_Filesystem **filesystemPtrPtr,
Tcl_Size *driveNameLengthPtr)
{
FsPath *fsPathPtr;
if (Tcl_FSConvertToPathType(NULL, pathPtr) != TCL_OK) {
return TclGetPathType(pathPtr, filesystemPtrPtr, driveNameLengthPtr,
NULL);
}
|
| ︙ | ︙ | |||
555 556 557 558 559 560 561 | * Check if the joined-on bit has any directory delimiters in * it. If so, the 'dirname' would be a joining of the main * part with the dirname of the joined-on bit. We could handle * that special case here, but we don't, and instead just use * the standardPath code. */ | | | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
* Check if the joined-on bit has any directory delimiters in
* it. If so, the 'dirname' would be a joining of the main
* part with the dirname of the joined-on bit. We could handle
* that special case here, but we don't, and instead just use
* the standardPath code.
*/
Tcl_Size numBytes;
const char *rest = Tcl_GetStringFromObj(fsPathPtr->normPathPtr, &numBytes);
if (strchr(rest, '/') != NULL) {
goto standardPath;
}
/*
* If the joined-on bit is empty, then [file dirname] is
|
| ︙ | ︙ | |||
592 593 594 595 596 597 598 | /* * Check if the joined-on bit has any directory delimiters in * it. If so, the 'tail' would be only the part following the * last delimiter. We could handle that special case here, but * we don't, and instead just use the standardPath code. */ | | | 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
/*
* Check if the joined-on bit has any directory delimiters in
* it. If so, the 'tail' would be only the part following the
* last delimiter. We could handle that special case here, but
* we don't, and instead just use the standardPath code.
*/
Tcl_Size numBytes;
const char *rest = Tcl_GetStringFromObj(fsPathPtr->normPathPtr, &numBytes);
if (strchr(rest, '/') != NULL) {
goto standardPath;
}
/*
* If the joined-on bit is empty, then [file tail] is
|
| ︙ | ︙ | |||
620 621 622 623 624 625 626 |
Tcl_IncrRefCount(fsPathPtr->normPathPtr);
return fsPathPtr->normPathPtr;
}
case TCL_PATH_EXTENSION:
return GetExtension(fsPathPtr->normPathPtr);
case TCL_PATH_ROOT: {
const char *fileName, *extension;
| | | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
Tcl_IncrRefCount(fsPathPtr->normPathPtr);
return fsPathPtr->normPathPtr;
}
case TCL_PATH_EXTENSION:
return GetExtension(fsPathPtr->normPathPtr);
case TCL_PATH_ROOT: {
const char *fileName, *extension;
Tcl_Size length;
fileName = Tcl_GetStringFromObj(fsPathPtr->normPathPtr,
&length);
extension = TclGetExtension(fileName);
if (extension == NULL) {
/*
* There is no extension so the root is the same as the
|
| ︙ | ︙ | |||
663 664 665 666 667 668 669 |
/* Relative path */
goto standardPath;
} else {
/* Absolute path */
goto standardPath;
}
} else {
| | | | 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 |
/* Relative path */
goto standardPath;
} else {
/* Absolute path */
goto standardPath;
}
} else {
Tcl_Size splitElements;
Tcl_Obj *splitPtr, *resultPtr;
standardPath:
resultPtr = NULL;
if (portion == TCL_PATH_EXTENSION) {
return GetExtension(pathPtr);
} else if (portion == TCL_PATH_ROOT) {
Tcl_Size length;
const char *fileName, *extension;
fileName = Tcl_GetStringFromObj(pathPtr, &length);
extension = TclGetExtension(fileName);
if (extension == NULL) {
Tcl_IncrRefCount(pathPtr);
return pathPtr;
|
| ︙ | ︙ | |||
747 748 749 750 751 752 753 |
Tcl_Obj *ret;
tail = TclGetString(pathPtr);
extension = TclGetExtension(tail);
if (extension == NULL) {
TclNewObj(ret);
} else {
| | | 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 |
Tcl_Obj *ret;
tail = TclGetString(pathPtr);
extension = TclGetExtension(tail);
if (extension == NULL) {
TclNewObj(ret);
} else {
ret = Tcl_NewStringObj(extension, -1);
}
Tcl_IncrRefCount(ret);
return ret;
}
/*
*---------------------------------------------------------------------------
|
| ︙ | ︙ | |||
791 792 793 794 795 796 797 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_FSJoinPath(
Tcl_Obj *listObj, /* Path elements to join, may have a zero
* reference count. */
| | | | | | | | 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_FSJoinPath(
Tcl_Obj *listObj, /* Path elements to join, may have a zero
* reference count. */
Tcl_Size elements) /* Number of elements to use (-1 = all) */
{
Tcl_Obj *res;
Tcl_Size objc;
Tcl_Obj **objv;
if (TclListObjLengthM(NULL, listObj, &objc) != TCL_OK) {
return NULL;
}
elements = ((elements >= 0) && (elements <= objc)) ? elements : objc;
TclListObjGetElementsM(NULL, listObj, &objc, &objv);
res = TclJoinPath(elements, objv, 0);
return res;
}
Tcl_Obj *
TclJoinPath(
Tcl_Size elements, /* Number of elements to use */
Tcl_Obj * const objv[], /* Path elements to join */
int forceRelative) /* If non-zero, assume all more paths are
* relative (e.g. simple normalization) */
{
Tcl_Obj *res = NULL;
Tcl_Size i;
const Tcl_Filesystem *fsPtr = NULL;
if (elements == 0) {
TclNewObj(res);
return res;
}
|
| ︙ | ︙ | |||
852 853 854 855 856 857 858 |
Tcl_PathType type;
/* if forceRelative - second path is relative */
type = forceRelative ? TCL_PATH_RELATIVE :
TclGetPathType(tailObj, NULL, NULL, NULL);
if (type == TCL_PATH_RELATIVE) {
const char *str;
| | | | 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
Tcl_PathType type;
/* if forceRelative - second path is relative */
type = forceRelative ? TCL_PATH_RELATIVE :
TclGetPathType(tailObj, NULL, NULL, NULL);
if (type == TCL_PATH_RELATIVE) {
const char *str;
Tcl_Size len;
str = Tcl_GetStringFromObj(tailObj, &len);
if (len == 0) {
/*
* This happens if we try to handle the root volume '/'.
* There's no need to return a special path object, when
* the base itself is just fine!
*/
return elt;
}
/*
* If it doesn't begin with '.' and is a Unix path or it a
* windows path without backslashes, then we can be very
* efficient here. (In fact even a windows path with
* backslashes can be joined efficiently, but the path object
* would not have forward slashes only, and this would
* therefore contradict our 'file join' documentation).
*/
|
| ︙ | ︙ | |||
919 920 921 922 923 924 925 |
}
}
}
assert ( res == NULL );
for (i = 0; i < elements; i++) {
| | | | 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 |
}
}
}
assert ( res == NULL );
for (i = 0; i < elements; i++) {
Tcl_Size driveNameLength;
Tcl_Size strEltLen, length;
Tcl_PathType type;
char *strElt, *ptr;
Tcl_Obj *driveName = NULL;
Tcl_Obj *elt = objv[i];
strElt = Tcl_GetStringFromObj(elt, &strEltLen);
driveNameLength = 0;
|
| ︙ | ︙ | |||
1162 1163 1164 1165 1166 1167 1168 | /* * Helper function for SetFsPathFromAny. Returns position of first directory * delimiter in the path. If no separator is found, then returns the position * of the end of the string. */ | | | 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 |
/*
* Helper function for SetFsPathFromAny. Returns position of first directory
* delimiter in the path. If no separator is found, then returns the position
* of the end of the string.
*/
static Tcl_Size
FindSplitPos(
const char *path,
int separator)
{
int count = 0;
switch (tclPlatform) {
case TCL_PLATFORM_UNIX:
|
| ︙ | ︙ | |||
1216 1217 1218 1219 1220 1221 1222 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclNewFSPathObj(
Tcl_Obj *dirPtr,
const char *addStrRep,
| | | 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclNewFSPathObj(
Tcl_Obj *dirPtr,
const char *addStrRep,
Tcl_Size len)
{
FsPath *fsPathPtr;
Tcl_Obj *pathPtr;
const char *p;
int state = 0, count = 0;
/*
|
| ︙ | ︙ | |||
1269 1270 1271 1272 1273 1274 1275 |
/*
* Look for path components made up of only "."
* This is overly conservative analysis to keep simple. It may mark some
* things as needing more aggressive normalization that don't actually
* need it. No harm done.
*/
| | | 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 |
/*
* Look for path components made up of only "."
* This is overly conservative analysis to keep simple. It may mark some
* things as needing more aggressive normalization that don't actually
* need it. No harm done.
*/
for (p = addStrRep; len > 0; p++, len--) {
switch (state) {
case 0: /* So far only "." since last dirsep or start */
switch (*p) {
case '.':
count = 1;
break;
case '/':
|
| ︙ | ︙ | |||
1313 1314 1315 1316 1317 1318 1319 |
static Tcl_Obj *
AppendPath(
Tcl_Obj *head,
Tcl_Obj *tail)
{
const char *bytes;
Tcl_Obj *copy = Tcl_DuplicateObj(head);
| | | 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 |
static Tcl_Obj *
AppendPath(
Tcl_Obj *head,
Tcl_Obj *tail)
{
const char *bytes;
Tcl_Obj *copy = Tcl_DuplicateObj(head);
Tcl_Size length;
/*
* This is likely buggy when dealing with virtual filesystem drivers
* that use some character other than "/" as a path separator. I know
* of no evidence that such a foolish thing exists. This solution was
* chosen so that "JoinPath" operations that pass through either path
* internalrep produce the same results; that is, bugward compatibility. If
|
| ︙ | ︙ | |||
1360 1361 1362 1363 1364 1365 1366 |
Tcl_Obj *
TclFSMakePathRelative(
TCL_UNUSED(Tcl_Interp *),
Tcl_Obj *pathPtr, /* The path we have. */
Tcl_Obj *cwdPtr) /* Make it relative to this. */
{
| | | 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 |
Tcl_Obj *
TclFSMakePathRelative(
TCL_UNUSED(Tcl_Interp *),
Tcl_Obj *pathPtr, /* The path we have. */
Tcl_Obj *cwdPtr) /* Make it relative to this. */
{
Tcl_Size cwdLen, len;
const char *tempStr;
Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(pathPtr, &fsPathType);
if (irPtr) {
FsPath *fsPathPtr = PATHOBJ(pathPtr);
if (PATHFLAGS(pathPtr) != 0 && fsPathPtr->cwdPtr == cwdPtr) {
|
| ︙ | ︙ | |||
1628 1629 1630 1631 1632 1633 1634 |
Tcl_FSGetTranslatedStringPath(
Tcl_Interp *interp,
Tcl_Obj *pathPtr)
{
Tcl_Obj *transPtr = Tcl_FSGetTranslatedPath(interp, pathPtr);
if (transPtr != NULL) {
| | | 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 |
Tcl_FSGetTranslatedStringPath(
Tcl_Interp *interp,
Tcl_Obj *pathPtr)
{
Tcl_Obj *transPtr = Tcl_FSGetTranslatedPath(interp, pathPtr);
if (transPtr != NULL) {
Tcl_Size len;
const char *orig = Tcl_GetStringFromObj(transPtr, &len);
char *result = (char *)Tcl_Alloc(len+1);
memcpy(result, orig, len+1);
TclDecrRefCount(transPtr);
return result;
}
|
| ︙ | ︙ | |||
1678 1679 1680 1681 1682 1683 1684 |
if (PATHFLAGS(pathPtr) != 0) {
/*
* This is a special path object which is the result of something like
* 'file join'
*/
Tcl_Obj *dir, *copy;
| | | 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 |
if (PATHFLAGS(pathPtr) != 0) {
/*
* This is a special path object which is the result of something like
* 'file join'
*/
Tcl_Obj *dir, *copy;
Tcl_Size tailLen, cwdLen;
int pathType;
pathType = Tcl_FSGetPathType(fsPathPtr->cwdPtr);
dir = Tcl_FSGetNormalizedPath(interp, fsPathPtr->cwdPtr);
if (dir == NULL) {
return NULL;
}
|
| ︙ | ︙ | |||
1780 1781 1782 1783 1784 1785 1786 |
TclGetString(pathPtr);
Tcl_StoreInternalRep(pathPtr, &fsPathType, NULL);
if (SetFsPathFromAny(interp, pathPtr) != TCL_OK) {
return NULL;
}
fsPathPtr = PATHOBJ(pathPtr);
} else if (fsPathPtr->normPathPtr == NULL) {
| | | 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 |
TclGetString(pathPtr);
Tcl_StoreInternalRep(pathPtr, &fsPathType, NULL);
if (SetFsPathFromAny(interp, pathPtr) != TCL_OK) {
return NULL;
}
fsPathPtr = PATHOBJ(pathPtr);
} else if (fsPathPtr->normPathPtr == NULL) {
Tcl_Size cwdLen;
Tcl_Obj *copy;
copy = AppendPath(fsPathPtr->cwdPtr, pathPtr);
(void) Tcl_GetStringFromObj(fsPathPtr->cwdPtr, &cwdLen);
cwdLen += (TclGetString(copy)[cwdLen] == '/');
|
| ︙ | ︙ | |||
2113 2114 2115 2116 2117 2118 2119 |
int
Tcl_FSEqualPaths(
Tcl_Obj *firstPtr,
Tcl_Obj *secondPtr)
{
const char *firstStr, *secondStr;
| | | 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 |
int
Tcl_FSEqualPaths(
Tcl_Obj *firstPtr,
Tcl_Obj *secondPtr)
{
const char *firstStr, *secondStr;
Tcl_Size firstLen, secondLen;
int tempErrno;
if (firstPtr == secondPtr) {
return 1;
}
if (firstPtr == NULL || secondPtr == NULL) {
|
| ︙ | ︙ | |||
2170 2171 2172 2173 2174 2175 2176 |
*/
static int
SetFsPathFromAny(
TCL_UNUSED(Tcl_Interp *), /* Used for error reporting if not NULL. */
Tcl_Obj *pathPtr) /* The object to convert. */
{
| | | 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 |
*/
static int
SetFsPathFromAny(
TCL_UNUSED(Tcl_Interp *), /* Used for error reporting if not NULL. */
Tcl_Obj *pathPtr) /* The object to convert. */
{
Tcl_Size len;
FsPath *fsPathPtr;
Tcl_Obj *transPtr;
if (TclHasInternalRep(pathPtr, &fsPathType)) {
return TCL_OK;
}
|
| ︙ | ︙ | |||
2203 2204 2205 2206 2207 2208 2209 |
* Now we have a translated filename in 'transPtr'. This will have forward
* slashes on Windows, and will not contain any ~user sequences.
*/
fsPathPtr = (FsPath *)Tcl_Alloc(sizeof(FsPath));
if (transPtr == pathPtr) {
| > > | | | | 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 |
* Now we have a translated filename in 'transPtr'. This will have forward
* slashes on Windows, and will not contain any ~user sequences.
*/
fsPathPtr = (FsPath *)Tcl_Alloc(sizeof(FsPath));
if (transPtr == pathPtr) {
(void) Tcl_GetString(pathPtr);
TclFreeInternalRep(pathPtr);
transPtr = Tcl_DuplicateObj(pathPtr);
fsPathPtr->filesystemEpoch = 0;
} else {
fsPathPtr->filesystemEpoch = TclFSEpoch();
}
Tcl_IncrRefCount(transPtr);
fsPathPtr->translatedPathPtr = transPtr;
fsPathPtr->normPathPtr = NULL;
fsPathPtr->cwdPtr = NULL;
fsPathPtr->nativePathPtr = NULL;
fsPathPtr->fsPtr = NULL;
|
| ︙ | ︙ | |||
2320 2321 2322 2323 2324 2325 2326 |
*/
static void
UpdateStringOfFsPath(
Tcl_Obj *pathPtr) /* path obj with string rep to update. */
{
FsPath *fsPathPtr = PATHOBJ(pathPtr);
| | | 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 |
*/
static void
UpdateStringOfFsPath(
Tcl_Obj *pathPtr) /* path obj with string rep to update. */
{
FsPath *fsPathPtr = PATHOBJ(pathPtr);
Tcl_Size cwdLen;
Tcl_Obj *copy;
if (PATHFLAGS(pathPtr) == 0 || fsPathPtr->cwdPtr == NULL) {
Tcl_Panic("Called UpdateStringOfFsPath with invalid object");
}
copy = AppendPath(fsPathPtr->cwdPtr, fsPathPtr->normPathPtr);
|
| ︙ | ︙ | |||
2392 2393 2394 2395 2396 2397 2398 |
} else {
/*
* It is somewhat unusual to reach this code path without the object
* being of fsPathType. However, we do our best to deal with the
* situation.
*/
| | | 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 |
} else {
/*
* It is somewhat unusual to reach this code path without the object
* being of fsPathType. However, we do our best to deal with the
* situation.
*/
Tcl_Size len;
(void) Tcl_GetStringFromObj(pathPtr, &len);
if (len == 0) {
/*
* We reject the empty path "".
*/
|
| ︙ | ︙ | |||
2538 2539 2540 2541 2542 2543 2544 |
*/
Tcl_Obj *
TclResolveTildePath(
Tcl_Interp *interp, /* May be NULL. Only used for error messages */
Tcl_Obj *pathObj)
{
const char *path;
| | | | 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 |
*/
Tcl_Obj *
TclResolveTildePath(
Tcl_Interp *interp, /* May be NULL. Only used for error messages */
Tcl_Obj *pathObj)
{
const char *path;
Tcl_Size len;
Tcl_Size split;
Tcl_DString resolvedPath;
path = Tcl_GetStringFromObj(pathObj, &len);
if (path[0] != '~') {
return pathObj;
}
|
| ︙ | ︙ | |||
2615 2616 2617 2618 2619 2620 2621 |
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclResolveTildePathList(
Tcl_Obj *pathsObj)
{
Tcl_Obj **objv;
| | | | 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 |
*----------------------------------------------------------------------
*/
Tcl_Obj *
TclResolveTildePathList(
Tcl_Obj *pathsObj)
{
Tcl_Obj **objv;
Tcl_Size objc;
Tcl_Size i;
Tcl_Obj *resolvedPaths;
const char *path;
if (pathsObj == NULL) {
return NULL;
}
if (Tcl_ListObjGetElements(NULL, pathsObj, &objc, &objv) != TCL_OK) {
|
| ︙ | ︙ |
Changes to generic/tclPipe.c.
| ︙ | ︙ | |||
175 176 177 178 179 180 181 | * None. * *---------------------------------------------------------------------- */ void Tcl_DetachPids( | | | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
* None.
*
*----------------------------------------------------------------------
*/
void
Tcl_DetachPids(
Tcl_Size numPids, /* Number of pids to detach: gives size of
* array pointed to by pidPtr. */
Tcl_Pid *pidPtr) /* Array of pids to detach. */
{
Detached *detPtr;
Tcl_Size i;
Tcl_MutexLock(&pipeMutex);
for (i = 0; i < numPids; i++) {
detPtr = (Detached *)Tcl_Alloc(sizeof(Detached));
detPtr->pid = pidPtr[i];
detPtr->nextPtr = detList;
detList = detPtr;
|
| ︙ | ︙ | |||
265 266 267 268 269 270 271 |
*
*----------------------------------------------------------------------
*/
int
TclCleanupChildren(
Tcl_Interp *interp, /* Used for error messages. */
| | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
*
*----------------------------------------------------------------------
*/
int
TclCleanupChildren(
Tcl_Interp *interp, /* Used for error messages. */
Tcl_Size numPids, /* Number of entries in pidPtr array. */
Tcl_Pid *pidPtr, /* Array of process ids of children. */
Tcl_Channel errorChan) /* Channel for file containing stderr output
* from pipeline. NULL means there isn't any
* stderr output. */
{
int result = TCL_OK;
int code, abnormalExit, anyErrorInfo;
TclProcessWaitStatus waitStatus;
Tcl_Size i;
Tcl_Obj *msg, *error;
abnormalExit = 0;
for (i = 0; i < numPids; i++) {
waitStatus = TclProcessWait(pidPtr[i], 0, &code, &msg, &error);
if (waitStatus == TCL_PROCESS_ERROR) {
result = TCL_ERROR;
|
| ︙ | ︙ | |||
357 358 359 360 361 362 363 |
/*
* If a child exited abnormally but didn't output any error information at
* all, generate an error message here.
*/
if ((abnormalExit != 0) && (anyErrorInfo == 0) && (interp != NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
/*
* If a child exited abnormally but didn't output any error information at
* all, generate an error message here.
*/
if ((abnormalExit != 0) && (anyErrorInfo == 0) && (interp != NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"child process exited abnormally", -1));
}
return result;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
391 392 393 394 395 396 397 | * * Side effects: * Processes and pipes are created. * *---------------------------------------------------------------------- */ | | | | | | | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
*
* Side effects:
* Processes and pipes are created.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclCreatePipeline(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
Tcl_Size argc, /* Number of entries in argv. */
const char **argv, /* Array of strings describing commands in
* pipeline plus I/O redirection with <, <<,
* >, etc. Argv[argc] must be NULL. */
Tcl_Pid **pidArrayPtr, /* Word at *pidArrayPtr gets filled in with
* address of array of pids for processes in
* pipeline (first pid is first process in
* pipeline). */
TclFile *inPipePtr, /* If non-NULL, input to the pipeline comes
* from a pipe (unless overridden by
* redirection in the command). The file id
* with which to write to this pipe is stored
* at *inPipePtr. NULL means command specified
* its own input source. */
TclFile *outPipePtr, /* If non-NULL, output to the pipeline goes to
* a pipe, unless overridden by redirection in
* the command. The file id with which to read
* from this pipe is stored at *outPipePtr.
* NULL means command specified its own output
* sink. */
TclFile *errFilePtr) /* If non-NULL, all stderr output from the
* pipeline will go to a temporary file
* created here, and a descriptor to read the
* file will be left at *errFilePtr. The file
* will be removed already, so closing this
* descriptor will be the end of the file. If
* this is NULL, then all stderr output goes
* to our stderr. If the pipeline specifies
* redirection then the file will still be
* created but it will never get any data. */
{
Tcl_Pid *pidPtr = NULL; /* Points to malloc-ed array holding all the
* pids of child processes. */
Tcl_Size numPids; /* Actual number of processes that exist at
* *pidPtr right now. */
Tcl_Size cmdCount; /* Count of number of distinct commands found
* in argc/argv. */
const char *inputLiteral = NULL;
/* If non-null, then this points to a string
* containing input data (specified via <<) to
* be piped to the first process in the
* pipeline. */
TclFile inputFile = NULL; /* If != NULL, gives file to use as input for
|
| ︙ | ︙ | |||
457 458 459 460 461 462 463 |
* stderr. */
int errorClose = 0; /* If non-zero, then errorFile should be
* closed when cleaning up. */
int errorRelease = 0;
const char *p;
const char *nextArg;
int skip, atOK, flags, needCmd, errorToOutput = 0;
| | | 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
* stderr. */
int errorClose = 0; /* If non-zero, then errorFile should be
* closed when cleaning up. */
int errorRelease = 0;
const char *p;
const char *nextArg;
int skip, atOK, flags, needCmd, errorToOutput = 0;
Tcl_Size i, j, lastArg, lastBar;
Tcl_DString execBuffer;
TclFile pipeIn;
TclFile curInFile, curOutFile, curErrFile;
Tcl_Channel channel;
if (inPipePtr != NULL) {
*inPipePtr = NULL;
|
| ︙ | ︙ | |||
486 487 488 489 490 491 492 |
/*
* First, scan through all the arguments to figure out the structure of
* the pipeline. Process all of the input and output redirection arguments
* and remove them from the argument list in the pipeline. Count the
* number of distinct processes (it's the number of "|" arguments plus
* one) but don't remove the "|" arguments because they'll be used in the
| | | | | 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
/*
* First, scan through all the arguments to figure out the structure of
* the pipeline. Process all of the input and output redirection arguments
* and remove them from the argument list in the pipeline. Count the
* number of distinct processes (it's the number of "|" arguments plus
* one) but don't remove the "|" arguments because they'll be used in the
* second pass to separate the individual child processes. Cannot start
* the child processes in this pass because the redirection symbols may
* appear anywhere in the command line - e.g., the '<' that specifies the
* input to the entire pipe may appear at the very end of the argument
* list.
*/
lastBar = -1;
cmdCount = 1;
needCmd = 1;
for (i = 0; i < argc; i++) {
errorToOutput = 0;
skip = 0;
p = argv[i];
switch (*p++) {
case '|':
if (*p == '&') {
p++;
}
if (*p == '\0') {
if ((i == (lastBar + 1)) || (i == (argc - 1))) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal use of | or |& in command", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
"PIPESYNTAX", NULL);
goto error;
}
}
lastBar = i;
cmdCount++;
|
| ︙ | ︙ | |||
696 697 698 699 700 701 702 |
if (needCmd) {
/*
* We had a bar followed only by redirections.
*/
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
if (needCmd) {
/*
* We had a bar followed only by redirections.
*/
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal use of | or |& in command", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC", "PIPESYNTAX",
NULL);
goto error;
}
if (inputFile == NULL) {
if (inputLiteral != NULL) {
|
| ︙ | ︙ | |||
1017 1018 1019 1020 1021 1022 1023 |
*----------------------------------------------------------------------
*/
Tcl_Channel
Tcl_OpenCommandChannel(
Tcl_Interp *interp, /* Interpreter for error reporting. Can NOT be
* NULL. */
| | | | | | | | 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 |
*----------------------------------------------------------------------
*/
Tcl_Channel
Tcl_OpenCommandChannel(
Tcl_Interp *interp, /* Interpreter for error reporting. Can NOT be
* NULL. */
Tcl_Size argc, /* How many arguments. */
const char **argv, /* Array of arguments for command pipe. */
int flags) /* Or'ed combination of TCL_STDIN, TCL_STDOUT,
* TCL_STDERR, and TCL_ENFORCE_MODE. */
{
TclFile *inPipePtr, *outPipePtr, *errFilePtr;
TclFile inPipe, outPipe, errFile;
Tcl_Size numPids;
Tcl_Pid *pidPtr = NULL;
Tcl_Channel channel;
inPipe = outPipe = errFile = NULL;
inPipePtr = (flags & TCL_STDIN) ? &inPipe : NULL;
outPipePtr = (flags & TCL_STDOUT) ? &outPipe : NULL;
errFilePtr = (flags & TCL_STDERR) ? &errFile : NULL;
numPids = TclCreatePipeline(interp, argc, argv, &pidPtr, inPipePtr,
outPipePtr, errFilePtr);
if (numPids < 0) {
goto error;
}
/*
* Verify that the pipes that were created satisfy the readable/writable
* constraints.
*/
if (flags & TCL_ENFORCE_MODE) {
if ((flags & TCL_STDOUT) && (outPipe == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't read output from command:"
" standard output was redirected", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
"BADREDIRECT", NULL);
goto error;
}
if ((flags & TCL_STDIN) && (inPipe == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't write input to command:"
" standard input was redirected", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
"BADREDIRECT", NULL);
goto error;
}
}
channel = TclpCreateCommandChannel(outPipe, inPipe, errFile,
numPids, pidPtr);
if (channel == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"pipe for command could not be created", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC", "NOPIPE", NULL);
goto error;
}
return channel;
error:
if (pidPtr) {
|
| ︙ | ︙ |
Changes to generic/tclPkg.c.
| ︙ | ︙ | |||
161 162 163 164 165 166 167 |
{
Package *pkgPtr;
char *pvi, *vi;
int res;
pkgPtr = FindPackage(interp, name);
if (pkgPtr->version == NULL) {
| | | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
{
Package *pkgPtr;
char *pvi, *vi;
int res;
pkgPtr = FindPackage(interp, name);
if (pkgPtr->version == NULL) {
pkgPtr->version = Tcl_NewStringObj(version, -1);
Tcl_IncrRefCount(pkgPtr->version);
pkgPtr->clientData = clientData;
return TCL_OK;
}
if (CheckVersionAndConvert(interp, Tcl_GetString(pkgPtr->version), &pvi,
NULL) != TCL_OK) {
|
| ︙ | ︙ | |||
287 288 289 290 291 292 293 |
if (isNew) {
TclNewObj(list);
Tcl_SetHashValue(entry, list);
Tcl_IncrRefCount(list);
} else {
list = (Tcl_Obj *)Tcl_GetHashValue(entry);
}
| | | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
if (isNew) {
TclNewObj(list);
Tcl_SetHashValue(entry, list);
Tcl_IncrRefCount(list);
} else {
list = (Tcl_Obj *)Tcl_GetHashValue(entry);
}
Tcl_ListObjAppendElement(interp, list, Tcl_NewStringObj(fileName, -1));
}
}
#undef Tcl_PkgRequire
const char *
Tcl_PkgRequire(
Tcl_Interp *interp, /* Interpreter in which package is now
|
| ︙ | ︙ | |||
403 404 405 406 407 408 409 |
Tcl_ResetResult(interp);
}
} else {
if (exact && TCL_OK
!= CheckVersionAndConvert(interp, version, NULL, NULL)) {
return NULL;
}
| | | | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
Tcl_ResetResult(interp);
}
} else {
if (exact && TCL_OK
!= CheckVersionAndConvert(interp, version, NULL, NULL)) {
return NULL;
}
ov = Tcl_NewStringObj(version, -1);
if (exact) {
Tcl_AppendStringsToObj(ov, "-", version, NULL);
}
Tcl_IncrRefCount(ov);
if (Tcl_PkgRequireProc(interp, name, 1, &ov, clientDataPtr) == TCL_OK) {
result = Tcl_GetStringResult(interp);
Tcl_ResetResult(interp);
}
TclDecrRefCount(ov);
}
return result;
}
int
Tcl_PkgRequireProc(
Tcl_Interp *interp, /* Interpreter in which package is now
* available. */
const char *name, /* Name of desired package. */
Tcl_Size reqc, /* Requirements constraining the desired
* version. */
Tcl_Obj *const reqv[], /* 0 means to use the latest version
* available. */
void *clientDataPtr)
{
RequireProcArgs args;
|
| ︙ | ︙ | |||
527 528 529 530 531 532 533 |
}
/*
* Invoke the "package unknown" script synchronously.
*/
Tcl_DStringInit(&command);
| | | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
}
/*
* Invoke the "package unknown" script synchronously.
*/
Tcl_DStringInit(&command);
Tcl_DStringAppend(&command, script, -1);
Tcl_DStringAppendElement(&command, name);
AddRequirementsToDString(&command, reqc, reqv);
Tcl_NRAddCallback(interp,
PkgRequireCoreStep2, reqPtr, INT2PTR(reqc), (void *) reqv, NULL);
Tcl_NREvalObj(interp,
Tcl_NewStringObj(Tcl_DStringValue(&command),
|
| ︙ | ︙ | |||
835 836 837 838 839 840 841 |
if (bestPtr->pkgIndex) {
TclPkgFileSeen(interp, bestPtr->pkgIndex);
}
reqPtr->versionToProvide = versionToProvide;
Tcl_NRAddCallback(interp,
SelectPackageFinal, reqPtr, INT2PTR(reqc), (void *)reqv,
data[3]);
| | | 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 |
if (bestPtr->pkgIndex) {
TclPkgFileSeen(interp, bestPtr->pkgIndex);
}
reqPtr->versionToProvide = versionToProvide;
Tcl_NRAddCallback(interp,
SelectPackageFinal, reqPtr, INT2PTR(reqc), (void *)reqv,
data[3]);
Tcl_NREvalObj(interp, Tcl_NewStringObj(bestPtr->script, -1),
TCL_EVAL_GLOBAL);
}
return TCL_OK;
}
static int
SelectPackageFinal(
|
| ︙ | ︙ | |||
1076 1077 1078 1079 1080 1081 1082 |
enum pkgOptionsEnum {
PKG_FILES, PKG_FORGET, PKG_IFNEEDED, PKG_NAMES, PKG_PREFER,
PKG_PRESENT, PKG_PROVIDE, PKG_REQUIRE, PKG_UNKNOWN, PKG_VCOMPARE,
PKG_VERSIONS, PKG_VSATISFIES
} optionIndex;
Interp *iPtr = (Interp *) interp;
int exact, satisfies;
| | | 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 |
enum pkgOptionsEnum {
PKG_FILES, PKG_FORGET, PKG_IFNEEDED, PKG_NAMES, PKG_PREFER,
PKG_PRESENT, PKG_PROVIDE, PKG_REQUIRE, PKG_UNKNOWN, PKG_VCOMPARE,
PKG_VERSIONS, PKG_VSATISFIES
} optionIndex;
Interp *iPtr = (Interp *) interp;
int exact, satisfies;
Tcl_Size i, newobjc;
PkgAvail *availPtr, *prevPtr;
Package *pkgPtr;
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
Tcl_HashTable *tablePtr;
const char *version;
const char *argv2, *argv3, *argv4;
|
| ︙ | ︙ | |||
1120 1121 1122 1123 1124 1125 1126 |
break;
}
case PKG_FORGET: {
const char *keyString;
PkgFiles *pkgFiles = (PkgFiles *)
Tcl_GetAssocData(interp, "tclPkgFiles", NULL);
| | | 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 |
break;
}
case PKG_FORGET: {
const char *keyString;
PkgFiles *pkgFiles = (PkgFiles *)
Tcl_GetAssocData(interp, "tclPkgFiles", NULL);
for (i = 2; i < objc; i++) {
keyString = TclGetString(objv[i]);
if (pkgFiles) {
hPtr = Tcl_FindHashEntry(&pkgFiles->table, keyString);
if (hPtr) {
Tcl_Obj *obj = (Tcl_Obj *)Tcl_GetHashValue(hPtr);
Tcl_DeleteHashEntry(hPtr);
Tcl_DecrRefCount(obj);
|
| ︙ | ︙ | |||
1156 1157 1158 1159 1160 1161 1162 |
Tcl_Free(availPtr);
}
Tcl_Free(pkgPtr);
}
break;
}
case PKG_IFNEEDED: {
| | | 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 |
Tcl_Free(availPtr);
}
Tcl_Free(pkgPtr);
}
break;
}
case PKG_IFNEEDED: {
Tcl_Size length;
int res;
char *argv3i, *avi;
if ((objc != 4) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "package version ?script?");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1196 1197 1198 1199 1200 1201 1202 |
res = CompareVersions(avi, argv3i, NULL);
Tcl_Free(avi);
if (res == 0) {
if (objc == 4) {
Tcl_Free(argv3i);
Tcl_SetObjResult(interp,
| | | 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 |
res = CompareVersions(avi, argv3i, NULL);
Tcl_Free(avi);
if (res == 0) {
if (objc == 4) {
Tcl_Free(argv3i);
Tcl_SetObjResult(interp,
Tcl_NewStringObj(availPtr->script, -1));
return TCL_OK;
}
Tcl_EventuallyFree(availPtr->script, TCL_DYNAMIC);
if (availPtr->pkgIndex) {
Tcl_EventuallyFree(availPtr->pkgIndex, TCL_DYNAMIC);
availPtr->pkgIndex = NULL;
}
|
| ︙ | ︙ | |||
1247 1248 1249 1250 1251 1252 1253 |
TclNewObj(resultObj);
tablePtr = &iPtr->packageTable;
for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != NULL;
hPtr = Tcl_NextHashEntry(&search)) {
pkgPtr = (Package *)Tcl_GetHashValue(hPtr);
if ((pkgPtr->version != NULL) || (pkgPtr->availPtr != NULL)) {
Tcl_ListObjAppendElement(NULL,resultObj, Tcl_NewStringObj(
| | | 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 |
TclNewObj(resultObj);
tablePtr = &iPtr->packageTable;
for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != NULL;
hPtr = Tcl_NextHashEntry(&search)) {
pkgPtr = (Package *)Tcl_GetHashValue(hPtr);
if ((pkgPtr->version != NULL) || (pkgPtr->availPtr != NULL)) {
Tcl_ListObjAppendElement(NULL,resultObj, Tcl_NewStringObj(
(char *)Tcl_GetHashKey(tablePtr, hPtr), -1));
}
}
Tcl_SetObjResult(interp, resultObj);
}
break;
case PKG_PRESENT: {
const char *name;
|
| ︙ | ︙ | |||
1349 1350 1351 1352 1353 1354 1355 | return TCL_ERROR; } /* * Create a new-style requirement for the exact version. */ | | | 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 | return TCL_ERROR; } /* * Create a new-style requirement for the exact version. */ ov = Tcl_NewStringObj(version, -1); Tcl_AppendStringsToObj(ov, "-", version, NULL); version = NULL; argv3 = TclGetString(objv[3]); Tcl_IncrRefCount(objv[3]); objvListPtr = Tcl_NewListObj(0, NULL); Tcl_IncrRefCount(objvListPtr); |
| ︙ | ︙ | |||
1395 1396 1397 1398 1399 1400 1401 |
Tcl_NRAddCallback(interp,
PkgRequireCore, (void *) argv2, INT2PTR(newobjc),
newObjvPtr, NULL);
return TCL_OK;
}
break;
case PKG_UNKNOWN: {
| | | | 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 |
Tcl_NRAddCallback(interp,
PkgRequireCore, (void *) argv2, INT2PTR(newobjc),
newObjvPtr, NULL);
return TCL_OK;
}
break;
case PKG_UNKNOWN: {
Tcl_Size length;
if (objc == 2) {
if (iPtr->packageUnknown != NULL) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj(iPtr->packageUnknown, -1));
}
} else if (objc == 3) {
if (iPtr->packageUnknown != NULL) {
Tcl_Free(iPtr->packageUnknown);
}
argv2 = Tcl_GetStringFromObj(objv[2], &length);
if (argv2[0] == 0) {
|
| ︙ | ︙ | |||
1452 1453 1454 1455 1456 1457 1458 | } /* * Always return current value. */ Tcl_SetObjResult(interp, | | | 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 |
}
/*
* Always return current value.
*/
Tcl_SetObjResult(interp,
Tcl_NewStringObj(pkgPreferOptions[iPtr->packagePrefer], -1));
break;
}
case PKG_VCOMPARE:
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "version1 version2");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1499 1500 1501 1502 1503 1504 1505 |
argv2 = TclGetString(objv[2]);
hPtr = Tcl_FindHashEntry(&iPtr->packageTable, argv2);
if (hPtr != NULL) {
pkgPtr = (Package *)Tcl_GetHashValue(hPtr);
for (availPtr = pkgPtr->availPtr; availPtr != NULL;
availPtr = availPtr->nextPtr) {
Tcl_ListObjAppendElement(NULL, resultObj,
| | | 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 |
argv2 = TclGetString(objv[2]);
hPtr = Tcl_FindHashEntry(&iPtr->packageTable, argv2);
if (hPtr != NULL) {
pkgPtr = (Package *)Tcl_GetHashValue(hPtr);
for (availPtr = pkgPtr->availPtr; availPtr != NULL;
availPtr = availPtr->nextPtr) {
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(availPtr->version, -1));
}
}
Tcl_SetObjResult(interp, resultObj);
}
break;
case PKG_VSATISFIES: {
char *argv2i = NULL;
|
| ︙ | ︙ | |||
1781 1782 1783 1784 1785 1786 1787 |
static int
CompareVersions(
char *v1, char *v2, /* Versions strings, of form 2.1.3 (any number
* of version numbers). */
int *isMajorPtr) /* If non-null, the word pointed to is filled
* in with a 0/1 value. 1 means that the
| | | 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 |
static int
CompareVersions(
char *v1, char *v2, /* Versions strings, of form 2.1.3 (any number
* of version numbers). */
int *isMajorPtr) /* If non-null, the word pointed to is filled
* in with a 0/1 value. 1 means that the
* difference occurred in the first element. */
{
int thisIsMajor, res, flip;
char *s1, *e1, *s2, *e2, o1, o2;
/*
* Each iteration of the following loop processes one number from each
* string, terminated by a " " (space). If those numbers don't match then
|
| ︙ | ︙ | |||
2068 2069 2070 2071 2072 2073 2074 |
int reqc, /* Requirements constraining the desired
* version. */
Tcl_Obj *const reqv[]) /* 0 means to use the latest version
* available. */
{
Tcl_Obj *result = Tcl_GetObjResult(interp);
int i;
| | | 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 |
int reqc, /* Requirements constraining the desired
* version. */
Tcl_Obj *const reqv[]) /* 0 means to use the latest version
* available. */
{
Tcl_Obj *result = Tcl_GetObjResult(interp);
int i;
Tcl_Size length;
for (i = 0; i < reqc; i++) {
const char *v = Tcl_GetStringFromObj(reqv[i], &length);
if ((length & 0x1) && (v[length/2] == '-')
&& (strncmp(v, v+((length+1)/2), length/2) == 0)) {
Tcl_AppendPrintfToObj(result, " exactly %s", v+((length+1)/2));
|
| ︙ | ︙ | |||
2235 2236 2237 2238 2239 2240 2241 |
Tcl_Free(min);
Tcl_Free(buf);
return satisfied;
}
/*
* We have both min and max, and generate their internal reps. When
| | | 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 |
Tcl_Free(min);
Tcl_Free(buf);
return satisfied;
}
/*
* We have both min and max, and generate their internal reps. When
* identical we compare as is, otherwise we pad with 'a0' to over the range
* a bit.
*/
CheckVersionAndConvert(NULL, buf, &min, NULL);
CheckVersionAndConvert(NULL, dash, &max, NULL);
if (CompareVersions(min, max, NULL) == 0) {
|
| ︙ | ︙ |
Changes to generic/tclPosixStr.c.
| ︙ | ︙ | |||
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#endif
#ifdef EALIGN
case EALIGN: return "EALIGN";
#endif
#if defined(EALREADY) && (!defined(EBUSY) || (EALREADY != EBUSY))
case EALREADY: return "EALREADY";
#endif
#ifdef EBADE
case EBADE: return "EBADE";
#endif
#ifdef EBADF
case EBADF: return "EBADF";
#endif
#ifdef EBADFD
case EBADFD: return "EBADFD";
#endif
#ifdef EBADMSG
case EBADMSG: return "EBADMSG";
#endif
| > > > < < < > > > > > > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
#endif
#ifdef EALIGN
case EALIGN: return "EALIGN";
#endif
#if defined(EALREADY) && (!defined(EBUSY) || (EALREADY != EBUSY))
case EALREADY: return "EALREADY";
#endif
#ifdef EBADCAT
case EBADCAT: return "EBADCAT";
#endif
#ifdef EBADE
case EBADE: return "EBADE";
#endif
#ifdef EBADF
case EBADF: return "EBADF";
#endif
#ifdef EBADFD
case EBADFD: return "EBADFD";
#endif
#ifdef EBADMSG
case EBADMSG: return "EBADMSG";
#endif
#ifdef EBADR
case EBADR: return "EBADR";
#endif
#ifdef EBADRPC
case EBADRPC: return "EBADRPC";
#endif
#ifdef EBADRQC
case EBADRQC: return "EBADRQC";
#endif
#ifdef EBADSLT
case EBADSLT: return "EBADSLT";
#endif
#ifdef EBFONT
case EBFONT: return "EBFONT";
#endif
#ifdef EBUSY
case EBUSY: return "EBUSY";
#endif
#ifdef ECANCELED
case ECANCELED: return "ECANCELED";
#endif
#ifdef ECASECLASH
case ECASECLASH: return "ECASECLASH";
#endif
#ifdef ECHILD
case ECHILD: return "ECHILD";
#endif
#ifdef ECHRNG
case ECHRNG: return "ECHRNG";
#endif
#ifdef ECOMM
|
| ︙ | ︙ | |||
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
#endif
#ifdef EDUPPKG
case EDUPPKG: return "EDUPPKG";
#endif
#ifdef EEXIST
case EEXIST: return "EEXIST";
#endif
#ifdef EFAULT
case EFAULT: return "EFAULT";
#endif
#ifdef EFBIG
case EFBIG: return "EFBIG";
#endif
#ifdef EHOSTDOWN
case EHOSTDOWN: return "EHOSTDOWN";
#endif
#ifdef EHOSTUNREACH
case EHOSTUNREACH: return "EHOSTUNREACH";
#endif
#if defined(EIDRM) && (!defined(EINPROGRESS) || (EIDRM != EINPROGRESS))
case EIDRM: return "EIDRM";
#endif
#ifdef EINIT
case EINIT: return "EINIT";
#endif
#ifdef EILSEQ
case EILSEQ: return "EILSEQ";
#endif
#ifdef EINPROGRESS
case EINPROGRESS: return "EINPROGRESS";
#endif
#ifdef EINTR
case EINTR: return "EINTR";
#endif
#ifdef EINVAL
case EINVAL: return "EINVAL";
#endif
#ifdef EIO
case EIO: return "EIO";
#endif
#ifdef EISCONN
case EISCONN: return "EISCONN";
#endif
#ifdef EISDIR
case EISDIR: return "EISDIR";
#endif
| > > > > > > > > > | < < < > > > | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
#endif
#ifdef EDUPPKG
case EDUPPKG: return "EDUPPKG";
#endif
#ifdef EEXIST
case EEXIST: return "EEXIST";
#endif
#ifdef EFAIL
case EFAIL: return "EFAIL";
#endif
#ifdef EFAULT
case EFAULT: return "EFAULT";
#endif
#ifdef EFBIG
case EFBIG: return "EFBIG";
#endif
#ifdef EFTYPE
case EFTYPE: return "EFTYPE";
#endif
#ifdef EHOSTDOWN
case EHOSTDOWN: return "EHOSTDOWN";
#endif
#ifdef EHOSTUNREACH
case EHOSTUNREACH: return "EHOSTUNREACH";
#endif
#if defined(EIDRM) && (!defined(EINPROGRESS) || (EIDRM != EINPROGRESS))
case EIDRM: return "EIDRM";
#endif
#ifdef EINIT
case EINIT: return "EINIT";
#endif
#ifdef EILSEQ
case EILSEQ: return "EILSEQ";
#endif
#ifdef EINPROG
case EINPROG: return "EINPROG";
#endif
#ifdef EINPROGRESS
case EINPROGRESS: return "EINPROGRESS";
#endif
#ifdef EINTR
case EINTR: return "EINTR";
#endif
#ifdef EINVAL
case EINVAL: return "EINVAL";
#endif
#ifdef EIO
case EIO: return "EIO";
#endif
#ifdef EISCONN
case EISCONN: return "EISCONN";
#endif
#ifdef EISDIR
case EISDIR: return "EISDIR";
#endif
#ifdef EISNAM
case EISNAM: return "EISNAM";
#endif
#ifdef EL2HLT
case EL2HLT: return "EL2HLT";
#endif
#ifdef EL2NSYNC
case EL2NSYNC: return "EL2NSYNC";
#endif
#ifdef EL3HLT
case EL3HLT: return "EL3HLT";
#endif
#ifdef EL3RST
case EL3RST: return "EL3RST";
#endif
#ifdef ELBIN
case ELBIN: return "ELBIN";
#endif
#ifdef ELIBACC
case ELIBACC: return "ELIBACC";
#endif
#ifdef ELIBBAD
case ELIBBAD: return "ELIBBAD";
#endif
#ifdef ELIBEXEC
|
| ︙ | ︙ | |||
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
#endif
#ifdef ELNRNG
case ELNRNG: return "ELNRNG";
#endif
#if defined(ELOOP) && (!defined(ENOENT) || (ELOOP != ENOENT))
case ELOOP: return "ELOOP";
#endif
#ifdef EMFILE
case EMFILE: return "EMFILE";
#endif
#ifdef EMLINK
case EMLINK: return "EMLINK";
#endif
#ifdef EMSGSIZE
case EMSGSIZE: return "EMSGSIZE";
#endif
#ifdef EMULTIHOP
case EMULTIHOP: return "EMULTIHOP";
#endif
#ifdef ENAMETOOLONG
case ENAMETOOLONG: return "ENAMETOOLONG";
#endif
#ifdef ENAVAIL
case ENAVAIL: return "ENAVAIL";
#endif
| > > > < < < > > > | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
#endif
#ifdef ELNRNG
case ELNRNG: return "ELNRNG";
#endif
#if defined(ELOOP) && (!defined(ENOENT) || (ELOOP != ENOENT))
case ELOOP: return "ELOOP";
#endif
#ifdef EMEDIUMTYPE
case EMEDIUMTYPE: return "EMEDIUMTYPE";
#endif
#ifdef EMFILE
case EMFILE: return "EMFILE";
#endif
#ifdef EMLINK
case EMLINK: return "EMLINK";
#endif
#ifdef EMSGSIZE
case EMSGSIZE: return "EMSGSIZE";
#endif
#ifdef EMULTIHOP
case EMULTIHOP: return "EMULTIHOP";
#endif
#ifdef ENAMETOOLONG
case ENAMETOOLONG: return "ENAMETOOLONG";
#endif
#ifdef ENAVAIL
case ENAVAIL: return "ENAVAIL";
#endif
#ifdef ENETDOWN
case ENETDOWN: return "ENETDOWN";
#endif
#ifdef ENETRESET
case ENETRESET: return "ENETRESET";
#endif
#ifdef ENETUNREACH
case ENETUNREACH: return "ENETUNREACH";
#endif
#ifdef ENFILE
case ENFILE: return "ENFILE";
#endif
#ifdef ENMFILE
case ENMFILE: return "ENMFILE";
#endif
#ifdef ENOANO
case ENOANO: return "ENOANO";
#endif
#if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
case ENOBUFS: return "ENOBUFS";
#endif
#ifdef ENOCSI
|
| ︙ | ︙ | |||
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
#endif
#ifdef ENOLINK
case ENOLINK: return "ENOLINK";
#endif
#ifdef ENOMEM
case ENOMEM: return "ENOMEM";
#endif
#ifdef ENOMSG
case ENOMSG: return "ENOMSG";
#endif
#ifdef ENONET
case ENONET: return "ENONET";
#endif
#ifdef ENOPKG
case ENOPKG: return "ENOPKG";
#endif
#ifdef ENOPROTOOPT
case ENOPROTOOPT: return "ENOPROTOOPT";
#endif
#ifdef ENOSPC
case ENOSPC: return "ENOSPC";
#endif
#if defined(ENOSR) && (!defined(ENAMETOOLONG) || (ENAMETOOLONG != ENOSR))
case ENOSR: return "ENOSR";
#endif
#if defined(ENOSTR) && (!defined(ENOTTY) || (ENOTTY != ENOSTR))
| > > > > > > | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
#endif
#ifdef ENOLINK
case ENOLINK: return "ENOLINK";
#endif
#ifdef ENOMEM
case ENOMEM: return "ENOMEM";
#endif
#ifdef ENOMEDIUM
case ENOMEDIUM: return "ENOMEDIUM";
#endif
#ifdef ENOMSG
case ENOMSG: return "ENOMSG";
#endif
#ifdef ENONET
case ENONET: return "ENONET";
#endif
#ifdef ENOPKG
case ENOPKG: return "ENOPKG";
#endif
#ifdef ENOPROTOOPT
case ENOPROTOOPT: return "ENOPROTOOPT";
#endif
#ifdef ENOSHARE
case ENOSHARE: return "ENOSHARE";
#endif
#ifdef ENOSPC
case ENOSPC: return "ENOSPC";
#endif
#if defined(ENOSR) && (!defined(ENAMETOOLONG) || (ENAMETOOLONG != ENOSR))
case ENOSR: return "ENOSR";
#endif
#if defined(ENOSTR) && (!defined(ENOTTY) || (ENOTTY != ENOSTR))
|
| ︙ | ︙ | |||
334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
#endif
#ifdef ENOTTY
case ENOTTY: return "ENOTTY";
#endif
#ifdef ENOTUNIQ
case ENOTUNIQ: return "ENOTUNIQ";
#endif
#ifdef ENXIO
case ENXIO: return "ENXIO";
#endif
#if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || (ENOTSUP != EOPNOTSUPP))
case EOPNOTSUPP: return "EOPNOTSUPP";
#endif
#ifdef EOTHER
| > > > | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
#endif
#ifdef ENOTTY
case ENOTTY: return "ENOTTY";
#endif
#ifdef ENOTUNIQ
case ENOTUNIQ: return "ENOTUNIQ";
#endif
#ifdef ENWAIT
case ENWAIT: return "ENWAIT";
#endif
#ifdef ENXIO
case ENXIO: return "ENXIO";
#endif
#if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || (ENOTSUP != EOPNOTSUPP))
case EOPNOTSUPP: return "EOPNOTSUPP";
#endif
#ifdef EOTHER
|
| ︙ | ︙ | |||
400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
#endif
#ifdef EREMOTEIO
case EREMOTEIO: return "EREMOTEIO";
#endif
#ifdef EREMOTERELEASE
case EREMOTERELEASE: return "EREMOTERELEASE";
#endif
#ifdef EROFS
case EROFS: return "EROFS";
#endif
#ifdef ERPCMISMATCH
case ERPCMISMATCH: return "ERPCMISMATCH";
#endif
#ifdef ERREMOTE
| > > > | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
#endif
#ifdef EREMOTEIO
case EREMOTEIO: return "EREMOTEIO";
#endif
#ifdef EREMOTERELEASE
case EREMOTERELEASE: return "EREMOTERELEASE";
#endif
#ifdef ERESTART
case ERESTART: return "ERESTART";
#endif
#ifdef EROFS
case EROFS: return "EROFS";
#endif
#ifdef ERPCMISMATCH
case ERPCMISMATCH: return "ERPCMISMATCH";
#endif
#ifdef ERREMOTE
|
| ︙ | ︙ | |||
515 516 517 518 519 520 521 |
#ifdef EAFNOSUPPORT
case EAFNOSUPPORT: return "address family not supported by protocol";
#endif
#ifdef EAGAIN
case EAGAIN: return "resource temporarily unavailable";
#endif
#ifdef EALIGN
| | > > > | | | < < < | | | > > > > > > | | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 |
#ifdef EAFNOSUPPORT
case EAFNOSUPPORT: return "address family not supported by protocol";
#endif
#ifdef EAGAIN
case EAGAIN: return "resource temporarily unavailable";
#endif
#ifdef EALIGN
case EALIGN: return "alignment error";
#endif
#if defined(EALREADY) && (!defined(EBUSY) || (EALREADY != EBUSY))
case EALREADY: return "operation already in progress";
#endif
#ifdef EBADCAT
case EBADCAT: return "bad message catalogue format";
#endif
#ifdef EBADE
case EBADE: return "invalid exchange";
#endif
#ifdef EBADF
case EBADF: return "bad file descriptor";
#endif
#ifdef EBADFD
case EBADFD: return "file descriptor in bad state";
#endif
#ifdef EBADMSG
case EBADMSG: return "bad message";
#endif
#ifdef EBADR
case EBADR: return "invalid request descriptor";
#endif
#ifdef EBADRPC
case EBADRPC: return "RPC structure is bad";
#endif
#ifdef EBADRQC
case EBADRQC: return "invalid request code";
#endif
#ifdef EBADSLT
case EBADSLT: return "invalid slot";
#endif
#ifdef EBFONT
case EBFONT: return "bad font file format";
#endif
#ifdef EBUSY
case EBUSY: return "device or resource busy";
#endif
#ifdef ECANCELED
case ECANCELED: return "operation canceled";
#endif
#ifdef ECASECLASH
case ECASECLASH: return "filename exists with different case";
#endif
#ifdef ECHILD
case ECHILD: return "no child processes";
#endif
#ifdef ECHRNG
case ECHRNG: return "channel number out of range";
#endif
#ifdef ECOMM
case ECOMM: return "communication error on send";
#endif
|
| ︙ | ︙ | |||
584 585 586 587 588 589 590 |
#ifdef EDESTADDRREQ
case EDESTADDRREQ: return "destination address required";
#endif
#ifdef EDIRTY
case EDIRTY: return "mounting a dirty fs w/o force";
#endif
#ifdef EDOM
| | | > > > | > > > | | > > > | | | | | < < < > > > | | > > > < < < | > > > | | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 |
#ifdef EDESTADDRREQ
case EDESTADDRREQ: return "destination address required";
#endif
#ifdef EDIRTY
case EDIRTY: return "mounting a dirty fs w/o force";
#endif
#ifdef EDOM
case EDOM: return "numerical argument out of domain";
#endif
#ifdef EDOTDOT
case EDOTDOT: return "cross mount point";
#endif
#ifdef EDQUOT
case EDQUOT: return "disk quota exceeded";
#endif
#ifdef EDUPPKG
case EDUPPKG: return "duplicate package name";
#endif
#ifdef EEXIST
case EEXIST: return "file exists";
#endif
#ifdef EFAIL
case EFAIL: return "cannot start operation";
#endif
#ifdef EFAULT
case EFAULT: return "bad address";
#endif
#ifdef EFBIG
case EFBIG: return "file too large";
#endif
#ifdef EFTYPE
case EFTYPE: return "inappropriate file type or format";
#endif
#ifdef EHOSTDOWN
case EHOSTDOWN: return "host is down";
#endif
#ifdef EHOSTUNREACH
case EHOSTUNREACH: return "no route to host";
#endif
#if defined(EIDRM) && (!defined(EINPROGRESS) || (EIDRM != EINPROGRESS))
case EIDRM: return "identifier removed";
#endif
#ifdef EINIT
case EINIT: return "initialization error";
#endif
#ifdef EILSEQ
case EILSEQ: return "invalid or incomplete multibyte or wide character";
#endif
#ifdef EINPROG
case EINPROG: return "asynchronous operation in progress";
#endif
#ifdef EINPROGRESS
case EINPROGRESS: return "operation now in progress";
#endif
#ifdef EINTR
case EINTR: return "interrupted system call";
#endif
#ifdef EINVAL
case EINVAL: return "invalid argument";
#endif
#ifdef EIO
case EIO: return "input/output error";
#endif
#ifdef EISCONN
case EISCONN: return "transport endpoint is already connected";
#endif
#ifdef EISDIR
case EISDIR: return "is a directory";
#endif
#ifdef EISNAM
case EISNAM: return "is a named type file";
#endif
#ifdef EL2HLT
case EL2HLT: return "level 2 halted";
#endif
#ifdef EL2NSYNC
case EL2NSYNC: return "level 2 not synchronized";
#endif
#ifdef EL3HLT
case EL3HLT: return "level 3 halted";
#endif
#ifdef EL3RST
case EL3RST: return "level 3 reset";
#endif
#ifdef ELBIN
case ELBIN: return "inode is remote";
#endif
#ifdef ELIBACC
case ELIBACC: return "can not access a needed shared library";
#endif
#ifdef ELIBBAD
case ELIBBAD: return "accessing a corrupted shared library";
#endif
#ifdef ELIBEXEC
case ELIBEXEC: return "cannot exec a shared library directly";
#endif
#if defined(ELIBMAX) && (!defined(ECANCELED) || (ELIBMAX != ECANCELED))
case ELIBMAX: return
"attempting to link in too many shared libraries";
#endif
#ifdef ELIBSCN
case ELIBSCN: return ".lib section in a.out corrupted";
#endif
#ifdef ELNRNG
case ELNRNG: return "link number out of range";
#endif
#if defined(ELOOP) && (!defined(ENOENT) || (ELOOP != ENOENT))
case ELOOP: return "too many levels of symbolic links";
#endif
#ifdef EMEDIUMTYPE
case EMEDIUMTYPE: return "wrong medium type";
#endif
#ifdef EMFILE
case EMFILE: return "too many open files";
#endif
#ifdef EMLINK
case EMLINK: return "too many links";
#endif
#ifdef EMSGSIZE
case EMSGSIZE: return "message too long";
#endif
#ifdef EMULTIHOP
case EMULTIHOP: return "multihop attempted";
#endif
#ifdef ENAMETOOLONG
case ENAMETOOLONG: return "file name too long";
#endif
#ifdef ENAVAIL
case ENAVAIL: return "not available";
#endif
#ifdef ENETDOWN
case ENETDOWN: return "network is down";
#endif
#ifdef ENETRESET
case ENETRESET: return "network dropped connection on reset";
#endif
#ifdef ENETUNREACH
case ENETUNREACH: return "network is unreachable";
#endif
#ifdef ENFILE
case ENFILE: return "too many open files in system";
#endif
#ifdef ENMFILE
case ENMFILE: return "no more files";
#endif
#ifdef ENOANO
case ENOANO: return "no anode";
#endif
#if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
case ENOBUFS: return "no buffer space available";
#endif
#ifdef ENOCSI
case ENOCSI: return "no CSI structure available";
#endif
|
| ︙ | ︙ | |||
738 739 740 741 742 743 744 |
#ifdef ENOLCK
case ENOLCK: return "no locks available";
#endif
#ifdef ENOLINK
case ENOLINK: return "link has been severed";
#endif
#ifdef ENOMEM
| | > > > | > > > | | | < < < > > > | > > > | | | 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
#ifdef ENOLCK
case ENOLCK: return "no locks available";
#endif
#ifdef ENOLINK
case ENOLINK: return "link has been severed";
#endif
#ifdef ENOMEM
case ENOMEM: return "cannot allocate memory";
#endif
#ifdef ENOMEDIUM
case ENOMEDIUM: return "no medium found";
#endif
#ifdef ENOMSG
case ENOMSG: return "no message of desired type";
#endif
#ifdef ENONET
case ENONET: return "machine is not on the network";
#endif
#ifdef ENOPKG
case ENOPKG: return "package not installed";
#endif
#ifdef ENOPROTOOPT
case ENOPROTOOPT: return "protocol not available";
#endif
#ifdef ENOSHARE
case ENOSHARE: return "no such host or network path";
#endif
#ifdef ENOSPC
case ENOSPC: return "no space left on device";
#endif
#if defined(ENOSR) && (!defined(ENAMETOOLONG) || (ENAMETOOLONG != ENOSR))
case ENOSR: return "out of streams resources";
#endif
#if defined(ENOSTR) && (!defined(ENOTTY) || (ENOTTY != ENOSTR))
case ENOSTR: return "device not a stream";
#endif
#ifdef ENOSYM
case ENOSYM: return "unresolved symbol name";
#endif
#ifdef ENOSYS
case ENOSYS: return "function not implemented";
#endif
#ifdef ENOTBLK
case ENOTBLK: return "block device required";
#endif
#ifdef ENOTCONN
case ENOTCONN: return "transport endpoint is not connected";
#endif
#ifdef ENOTDIR
case ENOTDIR: return "not a directory";
#endif
#if defined(ENOTEMPTY) && (!defined(EEXIST) || (ENOTEMPTY != EEXIST))
case ENOTEMPTY: return "directory not empty";
#endif
#ifdef ENOTNAM
case ENOTNAM: return "not a name file";
#endif
#ifdef ENOTRECOVERABLE
case ENOTRECOVERABLE: return "state not recoverable";
#endif
#ifdef ENOTSOCK
case ENOTSOCK: return "socket operation on non-socket";
#endif
#ifdef ENOTSUP
case ENOTSUP: return "operation not supported";
#endif
#ifdef ENOTTY
case ENOTTY: return "inappropriate ioctl for device";
#endif
#ifdef ENOTUNIQ
case ENOTUNIQ: return "name not unique on network";
#endif
#ifdef ENWAIT
case ENWAIT: return "No waiting processes";
#endif
#ifdef ENXIO
case ENXIO: return "no such device or address";
#endif
#if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || (ENOTSUP != EOPNOTSUPP))
case EOPNOTSUPP: return "operation not supported on socket";
#endif
#ifdef EOTHER
case EOTHER: return "other error";
#endif
#if defined(EOVERFLOW) && (!defined(EFBIG) || (EOVERFLOW != EFBIG)) && (!defined(EINVAL) || (EOVERFLOW != EINVAL))
case EOVERFLOW: return "value too large for defined data type";
#endif
#ifdef EOWNERDEAD
case EOWNERDEAD: return "owner died";
#endif
#ifdef EPERM
case EPERM: return "operation not permitted";
#endif
#if defined(EPFNOSUPPORT) && (!defined(ENOLCK) || (ENOLCK != EPFNOSUPPORT))
case EPFNOSUPPORT: return "protocol family not supported";
#endif
#ifdef EPIPE
case EPIPE: return "broken pipe";
#endif
|
| ︙ | ︙ | |||
843 844 845 846 847 848 849 |
#ifdef EPROTONOSUPPORT
case EPROTONOSUPPORT: return "protocol not supported";
#endif
#ifdef EPROTOTYPE
case EPROTOTYPE: return "protocol wrong type for socket";
#endif
#ifdef ERANGE
| | | | | | > > > | | | > > > | | | | | 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 |
#ifdef EPROTONOSUPPORT
case EPROTONOSUPPORT: return "protocol not supported";
#endif
#ifdef EPROTOTYPE
case EPROTOTYPE: return "protocol wrong type for socket";
#endif
#ifdef ERANGE
case ERANGE: return "numerical result out of range";
#endif
#if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED))
case EREFUSED: return "connection refused";
#endif
#ifdef EREMCHG
case EREMCHG: return "remote address changed";
#endif
#ifdef EREMDEV
case EREMDEV: return "remote device";
#endif
#ifdef EREMOTE
case EREMOTE: return "object is remote";
#endif
#ifdef EREMOTEIO
case EREMOTEIO: return "remote I/O error";
#endif
#ifdef EREMOTERELEASE
case EREMOTERELEASE: return "remote peer released connection";
#endif
#ifdef ERESTART
case ERESTART: return "interrupted system call should be restarted";
#endif
#ifdef EROFS
case EROFS: return "read-only file system";
#endif
#ifdef ERPCMISMATCH
case ERPCMISMATCH: return "RPC version is wrong";
#endif
#ifdef ERREMOTE
case ERREMOTE: return "object is remote";
#endif
#ifdef ESHUTDOWN
case ESHUTDOWN: return "cannot send after transport endpoint shutdown";
#endif
#ifdef ESOCKTNOSUPPORT
case ESOCKTNOSUPPORT: return "socket type not supported";
#endif
#ifdef ESPIPE
case ESPIPE: return "illegal seek";
#endif
#ifdef ESRCH
case ESRCH: return "no such process";
#endif
#ifdef ESRMNT
case ESRMNT: return "srmount error";
#endif
#ifdef ESTALE
case ESTALE: return "stale file handle";
#endif
#ifdef ESTRPIPE
case ESTRPIPE: return "streams pipe error";
#endif
#ifdef ESUCCESS
case ESUCCESS: return "success";
#endif
#if defined(ETIME) && (!defined(ELOOP) || (ETIME != ELOOP))
case ETIME: return "timer expired";
#endif
#if defined(ETIMEDOUT) && (!defined(ENOSTR) || (ETIMEDOUT != ENOSTR))
case ETIMEDOUT: return "connection timed out";
#endif
#ifdef ETOOMANYREFS
case ETOOMANYREFS: return "too many references: cannot splice";
#endif
#ifdef ETXTBSY
case ETXTBSY: return "text file busy";
#endif
#ifdef EUCLEAN
case EUCLEAN: return "structure needs cleaning";
#endif
#ifdef EUNATCH
case EUNATCH: return "protocol driver not attached";
#endif
#ifdef EUSERS
case EUSERS: return "too many users";
#endif
#ifdef EVERSION
case EVERSION: return "version mismatch";
#endif
#if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
case EWOULDBLOCK: return "operation would block";
#endif
#ifdef EXDEV
case EXDEV: return "invalid cross-device link";
#endif
#ifdef EXFULL
case EXFULL: return "exchange full";
#endif
default:
#ifdef NO_STRERROR
return "unknown POSIX error";
#else
return strerror(err);
#endif
|
| ︙ | ︙ |
Changes to generic/tclProc.c.
| ︙ | ︙ | |||
520 521 522 523 524 525 526 |
result = TclListObjGetElementsM(interp, argArray[i], &fieldCount,
&fieldValues);
if (result != TCL_OK) {
goto procError;
}
if (fieldCount > 2) {
Tcl_Obj *errorObj = Tcl_NewStringObj(
| | | | | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
result = TclListObjGetElementsM(interp, argArray[i], &fieldCount,
&fieldValues);
if (result != TCL_OK) {
goto procError;
}
if (fieldCount > 2) {
Tcl_Obj *errorObj = Tcl_NewStringObj(
"too many fields in argument specifier \"", -1);
Tcl_AppendObjToObj(errorObj, argArray[i]);
Tcl_AppendToObj(errorObj, "\"", -1);
Tcl_SetObjResult(interp, errorObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"FORMALARGUMENTFORMAT", NULL);
goto procError;
}
if ((fieldCount == 0) || (Tcl_GetCharLength(fieldValues[0]) == 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"argument with no name", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"FORMALARGUMENTFORMAT", NULL);
goto procError;
}
argname = Tcl_GetStringFromObj(fieldValues[0], &nameLength);
|
| ︙ | ︙ | |||
556 557 558 559 560 561 562 |
TclGetString(fieldValues[0])));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"FORMALARGUMENTFORMAT", NULL);
goto procError;
}
} else if (*argnamei == ':' && *(argnamei+1) == ':') {
Tcl_Obj *errorObj = Tcl_NewStringObj(
| | | | 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
TclGetString(fieldValues[0])));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"FORMALARGUMENTFORMAT", NULL);
goto procError;
}
} else if (*argnamei == ':' && *(argnamei+1) == ':') {
Tcl_Obj *errorObj = Tcl_NewStringObj(
"formal parameter \"", -1);
Tcl_AppendObjToObj(errorObj, fieldValues[0]);
Tcl_AppendToObj(errorObj, "\" is not a simple name", -1);
Tcl_SetObjResult(interp, errorObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"FORMALARGUMENTFORMAT", NULL);
goto procError;
}
argnamei++;
}
|
| ︙ | ︙ | |||
609 610 611 612 613 614 615 |
if ((valueLength != tmpLength)
|| memcmp(value, tmpPtr, tmpLength) != 0
) {
Tcl_Obj *errorObj = Tcl_ObjPrintf(
"procedure \"%s\": formal parameter \"", procName);
Tcl_AppendObjToObj(errorObj, fieldValues[0]);
Tcl_AppendToObj(errorObj, "\" has "
| | | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
if ((valueLength != tmpLength)
|| memcmp(value, tmpPtr, tmpLength) != 0
) {
Tcl_Obj *errorObj = Tcl_ObjPrintf(
"procedure \"%s\": formal parameter \"", procName);
Tcl_AppendObjToObj(errorObj, fieldValues[0]);
Tcl_AppendToObj(errorObj, "\" has "
"default value inconsistent with precompiled body", -1);
Tcl_SetObjResult(interp, errorObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"BYTECODELIES", NULL);
goto procError;
}
}
if ((i == numArgs - 1)
|
| ︙ | ︙ | |||
1076 1077 1078 1079 1080 1081 1082 |
*/
numArgs = framePtr->procPtr->numArgs;
desiredObjs = (Tcl_Obj **)TclStackAlloc(interp,
sizeof(Tcl_Obj *) * (numArgs+1));
if (framePtr->isProcCallFrame & FRAME_IS_LAMBDA) {
| | | 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 |
*/
numArgs = framePtr->procPtr->numArgs;
desiredObjs = (Tcl_Obj **)TclStackAlloc(interp,
sizeof(Tcl_Obj *) * (numArgs+1));
if (framePtr->isProcCallFrame & FRAME_IS_LAMBDA) {
desiredObjs[0] = Tcl_NewStringObj("lambdaExpr", -1);
} else {
desiredObjs[0] = framePtr->objv[skip-1];
}
Tcl_IncrRefCount(desiredObjs[0]);
if (localCt > 0) {
Var *defPtr = (Var *)(&framePtr->localCachePtr->varName0 + localCt);
|
| ︙ | ︙ | |||
1503 1504 1505 1506 1507 1508 1509 |
int
TclPushProcCallFrame(
void *clientData, /* Record describing procedure to be
* interpreted. */
Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
| | | 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 |
int
TclPushProcCallFrame(
void *clientData, /* Record describing procedure to be
* interpreted. */
Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
Tcl_Size objc, /* Count of number of arguments to this
* procedure. */
Tcl_Obj *const objv[], /* Argument value objects. */
int isLambda) /* 1 if this is a call by ApplyObjCmd: it
* needs special rules for error msg */
{
Proc *procPtr = (Proc *)clientData;
Namespace *nsPtr = procPtr->cmdPtr->nsPtr;
|
| ︙ | ︙ | |||
1630 1631 1632 1633 1634 1635 1636 |
return TCL_ERROR;
}
return TclNRInterpProcCore(interp, objv[0], 1, &MakeProcError);
}
static int
NRInterpProc2(
| | | | | | | | 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 |
return TCL_ERROR;
}
return TclNRInterpProcCore(interp, objv[0], 1, &MakeProcError);
}
static int
NRInterpProc2(
void *clientData, /* Record describing procedure to be
* interpreted. */
Tcl_Interp *interp, /* Interpreter in which procedure was
* invoked. */
Tcl_Size objc, /* Count of number of arguments to this
* procedure. */
Tcl_Obj *const objv[]) /* Argument value objects. */
{
int result = TclPushProcCallFrame(clientData, interp, objc, objv,
/*isLambda*/ 0);
if (result != TCL_OK) {
return TCL_ERROR;
}
return TclNRInterpProcCore(interp, objv[0], 1, &MakeProcError);
}
static int
ObjInterpProc2(
void *clientData, /* Record describing procedure to be
* interpreted. */
Tcl_Interp *interp, /* Interpreter in which procedure was
* invoked. */
Tcl_Size objc, /* Count of number of arguments to this
* procedure. */
Tcl_Obj *const objv[]) /* Argument value objects. */
{
/*
* Not used much in the core; external interface for iTcl
*/
|
| ︙ | ︙ | |||
1937 1938 1939 1940 1941 1942 1943 |
) {
return TCL_OK;
}
if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
if ((Interp *) *codePtr->interpHandle != iPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 |
) {
return TCL_OK;
}
if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
if ((Interp *) *codePtr->interpHandle != iPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"a precompiled script jumped interps", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"CROSSINTERPBYTECODE", NULL);
return TCL_ERROR;
}
codePtr->compileEpoch = iPtr->compileEpoch;
codePtr->nsPtr = nsPtr;
} else {
|
| ︙ | ︙ |
Changes to generic/tclProcess.c.
| ︙ | ︙ | |||
229 230 231 232 233 234 235 |
msg = "child process lost (is SIGCHLD ignored or trapped?)";
}
if (codePtr) *codePtr = errno;
if (msgObjPtr) *msgObjPtr = Tcl_ObjPrintf(
"error waiting for process to exit: %s", msg);
if (errorObjPtr) {
| | | | | | | | | | | | | | | | | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
msg = "child process lost (is SIGCHLD ignored or trapped?)";
}
if (codePtr) *codePtr = errno;
if (msgObjPtr) *msgObjPtr = Tcl_ObjPrintf(
"error waiting for process to exit: %s", msg);
if (errorObjPtr) {
errorStrings[0] = Tcl_NewStringObj("POSIX", -1);
errorStrings[1] = Tcl_NewStringObj(Tcl_ErrnoId(), -1);
errorStrings[2] = Tcl_NewStringObj(msg, -1);
*errorObjPtr = Tcl_NewListObj(3, errorStrings);
}
return TCL_PROCESS_ERROR;
} else if (WIFEXITED(waitStatus)) {
if (codePtr) *codePtr = WEXITSTATUS(waitStatus);
if (!WEXITSTATUS(waitStatus)) {
/*
* Normal exit.
*/
if (msgObjPtr) *msgObjPtr = NULL;
if (errorObjPtr) *errorObjPtr = NULL;
} else {
/*
* CHILDSTATUS pid code
*
* Child exited with a non-zero exit status.
*/
if (msgObjPtr) *msgObjPtr = Tcl_NewStringObj(
"child process exited abnormally", -1);
if (errorObjPtr) {
errorStrings[0] = Tcl_NewStringObj("CHILDSTATUS", -1);
TclNewIntObj(errorStrings[1], resolvedPid);
TclNewIntObj(errorStrings[2], WEXITSTATUS(waitStatus));
*errorObjPtr = Tcl_NewListObj(3, errorStrings);
}
}
return TCL_PROCESS_EXITED;
} else if (WIFSIGNALED(waitStatus)) {
/*
* CHILDKILLED pid sigName msg
*
* Child killed because of a signal.
*/
msg = Tcl_SignalMsg(WTERMSIG(waitStatus));
if (codePtr) *codePtr = WTERMSIG(waitStatus);
if (msgObjPtr) *msgObjPtr = Tcl_ObjPrintf(
"child killed: %s", msg);
if (errorObjPtr) {
errorStrings[0] = Tcl_NewStringObj("CHILDKILLED", -1);
TclNewIntObj(errorStrings[1], resolvedPid);
errorStrings[2] = Tcl_NewStringObj(Tcl_SignalId(WTERMSIG(waitStatus)), -1);
errorStrings[3] = Tcl_NewStringObj(msg, -1);
*errorObjPtr = Tcl_NewListObj(4, errorStrings);
}
return TCL_PROCESS_SIGNALED;
} else if (WIFSTOPPED(waitStatus)) {
/*
* CHILDSUSP pid sigName msg
*
* Child suspended because of a signal.
*/
msg = Tcl_SignalMsg(WSTOPSIG(waitStatus));
if (codePtr) *codePtr = WSTOPSIG(waitStatus);
if (msgObjPtr) *msgObjPtr = Tcl_ObjPrintf(
"child suspended: %s", msg);
if (errorObjPtr) {
errorStrings[0] = Tcl_NewStringObj("CHILDSUSP", -1);
TclNewIntObj(errorStrings[1], resolvedPid);
errorStrings[2] = Tcl_NewStringObj(Tcl_SignalId(WSTOPSIG(waitStatus)), -1);
errorStrings[3] = Tcl_NewStringObj(msg, -1);
*errorObjPtr = Tcl_NewListObj(4, errorStrings);
}
return TCL_PROCESS_STOPPED;
} else {
/*
* TCL OPERATION EXEC ODDWAITRESULT
*
* Child wait status didn't make sense.
*/
if (codePtr) *codePtr = waitStatus;
if (msgObjPtr) *msgObjPtr = Tcl_NewStringObj(
"child wait status didn't make sense\n", -1);
if (errorObjPtr) {
errorStrings[0] = Tcl_NewStringObj("TCL", -1);
errorStrings[1] = Tcl_NewStringObj("OPERATION", -1);
errorStrings[2] = Tcl_NewStringObj("EXEC", -1);
errorStrings[3] = Tcl_NewStringObj("ODDWAITRESULT", -1);
TclNewIntObj(errorStrings[4], resolvedPid);
*errorObjPtr = Tcl_NewListObj(5, errorStrings);
}
return TCL_PROCESS_UNKNOWN_STATUS;
}
}
|
| ︙ | ︙ | |||
451 452 453 454 455 456 457 |
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *dict;
int options = WNOHANG;
Tcl_HashEntry *entry;
Tcl_HashSearch search;
ProcessInfo *info;
| | | 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *dict;
int options = WNOHANG;
Tcl_HashEntry *entry;
Tcl_HashSearch search;
ProcessInfo *info;
Tcl_Size i, numPids;
Tcl_Obj **pidObjs;
int result;
int pid;
Tcl_Obj *const *savedobjv = objv;
static const char *const switches[] = {
"-wait", "--", NULL
};
|
| ︙ | ︙ | |||
596 597 598 599 600 601 602 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_HashEntry *entry;
Tcl_HashSearch search;
ProcessInfo *info;
| | | 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_HashEntry *entry;
Tcl_HashSearch search;
ProcessInfo *info;
Tcl_Size i, numPids;
Tcl_Obj **pidObjs;
int result, pid;
if (objc != 1 && objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?pids?");
return TCL_ERROR;
}
|
| ︙ | ︙ |
Changes to generic/tclRegexp.c.
| ︙ | ︙ | |||
249 250 251 252 253 254 255 |
*---------------------------------------------------------------------------
*/
void
Tcl_RegExpRange(
Tcl_RegExp re, /* Compiled regular expression that has been
* passed to Tcl_RegExpExec. */
| | | | | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
*---------------------------------------------------------------------------
*/
void
Tcl_RegExpRange(
Tcl_RegExp re, /* Compiled regular expression that has been
* passed to Tcl_RegExpExec. */
Tcl_Size index, /* 0 means give the range of the entire match,
* > 0 means give the range of a matching
* subrange. */
const char **startPtr, /* Store address of first character in
* (sub-)range here. */
const char **endPtr) /* Store address of character just after last
* in (sub-)range here. */
{
TclRegexp *regexpPtr = (TclRegexp *) re;
const char *string;
if (index < 0 || (size_t) index > regexpPtr->re.re_nsub) {
*startPtr = *endPtr = NULL;
} else if (regexpPtr->matches[index].rm_so == (size_t) -1) {
*startPtr = *endPtr = NULL;
} else {
if (regexpPtr->objPtr) {
string = TclGetString(regexpPtr->objPtr);
} else {
string = regexpPtr->string;
}
|
| ︙ | ︙ | |||
359 360 361 362 363 364 365 |
*---------------------------------------------------------------------------
*/
void
TclRegExpRangeUniChar(
Tcl_RegExp re, /* Compiled regular expression that has been
* passed to Tcl_RegExpExec. */
| | | | | | | | | | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
*---------------------------------------------------------------------------
*/
void
TclRegExpRangeUniChar(
Tcl_RegExp re, /* Compiled regular expression that has been
* passed to Tcl_RegExpExec. */
Tcl_Size index, /* 0 means give the range of the entire match,
* > 0 means give the range of a matching
* subrange, -1 means the range of the
* rm_extend field. */
Tcl_Size *startPtr, /* Store address of first character in
* (sub-)range here. */
Tcl_Size *endPtr) /* Store address of character just after last
* in (sub-)range here. */
{
TclRegexp *regexpPtr = (TclRegexp *) re;
if ((regexpPtr->flags®_EXPECT) && (index == -1)) {
*startPtr = regexpPtr->details.rm_extend.rm_so;
*endPtr = regexpPtr->details.rm_extend.rm_eo;
} else if (index < 0 || (size_t) index > regexpPtr->re.re_nsub + 1) {
*startPtr = -1;
*endPtr = -1;
} else {
*startPtr = regexpPtr->matches[index].rm_so;
*endPtr = regexpPtr->matches[index].rm_eo;
}
}
/*
|
| ︙ | ︙ | |||
439 440 441 442 443 444 445 |
int
Tcl_RegExpExecObj(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
Tcl_RegExp re, /* Compiled regular expression; must have been
* returned by previous call to
* Tcl_GetRegExpFromObj. */
Tcl_Obj *textObj, /* Text against which to match re. */
| | | | | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
int
Tcl_RegExpExecObj(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
Tcl_RegExp re, /* Compiled regular expression; must have been
* returned by previous call to
* Tcl_GetRegExpFromObj. */
Tcl_Obj *textObj, /* Text against which to match re. */
Tcl_Size offset, /* Character index that marks where matching
* should begin. */
Tcl_Size nmatches, /* How many subexpression matches (counting
* the whole match as subexpression 0) are of
* interest. -1 means all of them. */
int flags) /* Regular expression execution flags. */
{
TclRegexp *regexpPtr = (TclRegexp *) re;
Tcl_UniChar *udata;
Tcl_Size length;
int reflags = regexpPtr->flags;
#define TCL_REG_GLOBOK_FLAGS \
(TCL_REG_ADVANCED | TCL_REG_NOSUB | TCL_REG_NOCASE)
/*
* Take advantage of the equivalent glob pattern, if one exists.
* This is possible based only on the right mix of incoming flags (0)
|
| ︙ | ︙ | |||
591 592 593 594 595 596 597 |
* the interp regexp cache. */
Tcl_Obj *objPtr, /* Object whose string rep contains regular
* expression pattern. Internal rep will be
* changed to compiled form of this regular
* expression. */
int flags) /* Regular expression compilation flags. */
{
| | | 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
* the interp regexp cache. */
Tcl_Obj *objPtr, /* Object whose string rep contains regular
* expression pattern. Internal rep will be
* changed to compiled form of this regular
* expression. */
int flags) /* Regular expression compilation flags. */
{
Tcl_Size length;
TclRegexp *regexpPtr;
const char *pattern;
RegexpGetInternalRep(objPtr, regexpPtr);
if ((regexpPtr == NULL) || (regexpPtr->flags != flags)) {
pattern = Tcl_GetStringFromObj(objPtr, &length);
|
| ︙ | ︙ | |||
685 686 687 688 689 690 691 |
* Now append a list of all the bit-flags set for the RE.
*/
TclNewObj(infoObj);
for (inf=infonames ; inf->bit != 0 ; inf++) {
if (regexpPtr->re.re_info & inf->bit) {
Tcl_ListObjAppendElement(NULL, infoObj,
| | | 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 |
* Now append a list of all the bit-flags set for the RE.
*/
TclNewObj(infoObj);
for (inf=infonames ; inf->bit != 0 ; inf++) {
if (regexpPtr->re.re_info & inf->bit) {
Tcl_ListObjAppendElement(NULL, infoObj,
Tcl_NewStringObj(inf->text, -1));
}
}
Tcl_ListObjAppendElement(NULL, resultObj, infoObj);
Tcl_SetObjResult(interp, resultObj);
return 0;
}
|
| ︙ | ︙ | |||
726 727 728 729 730 731 732 |
const char *p;
Tcl_ResetResult(interp);
n = TclReError(status, buf, sizeof(buf));
p = (n > sizeof(buf)) ? "..." : "";
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s%s%s", msg, buf, p));
| | | 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 |
const char *p;
Tcl_ResetResult(interp);
n = TclReError(status, buf, sizeof(buf));
p = (n > sizeof(buf)) ? "..." : "";
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s%s%s", msg, buf, p));
snprintf(cbuf, sizeof(cbuf), "%d", status);
(void) TclReError(REG_ITOA, cbuf, sizeof(cbuf));
Tcl_SetErrorCode(interp, "REGEXP", cbuf, buf, NULL);
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ |
Changes to generic/tclResult.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/*
* tclResult.c --
*
* This file contains code to manage the interpreter result.
*
* Copyright © 1997 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 "tclInt.h"
/*
* Indices of the standard return options dictionary keys.
*/
enum returnKeys {
KEY_CODE, KEY_ERRORCODE, KEY_ERRORINFO, KEY_ERRORLINE,
| > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
/*
* tclResult.c --
*
* This file contains code to manage the interpreter result.
*
* Copyright © 1997 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 "tclInt.h"
#include <assert.h>
/*
* Indices of the standard return options dictionary keys.
*/
enum returnKeys {
KEY_CODE, KEY_ERRORCODE, KEY_ERRORINFO, KEY_ERRORLINE,
|
| ︙ | ︙ | |||
207 208 209 210 211 212 213 |
Tcl_Free(statePtr);
}
/*
*----------------------------------------------------------------------
*
* Tcl_SetObjResult --
| < | | < | > | | < | < | > > > > | | | < < < < | < | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
Tcl_Free(statePtr);
}
/*
*----------------------------------------------------------------------
*
* Tcl_SetObjResult --
* Makes objPtr the interpreter's result value.
*
* Results:
* None.
*
* Side effects:
* Stores objPtr interp->objResultPtr, increments its reference count, and
* decrements the reference count of any existing interp->objResultPtr.
*
* The string result is reset.
*
*----------------------------------------------------------------------
*/
void
Tcl_SetObjResult(
Tcl_Interp *interp, /* Interpreter to set the result for. */
Tcl_Obj *objPtr) /* The value to set as the result. */
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *oldObjResult = iPtr->objResultPtr;
if (objPtr == oldObjResult) {
/* This should be impossible */
assert(objPtr->refCount != 0);
return;
} else {
iPtr->objResultPtr = objPtr;
Tcl_IncrRefCount(objPtr);
TclDecrRefCount(oldObjResult);
}
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetObjResult --
*
|
| ︙ | ︙ | |||
313 314 315 316 317 318 319 |
}
while (1) {
const char *bytes = va_arg(argList, char *);
if (bytes == NULL) {
break;
}
| | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
}
while (1) {
const char *bytes = va_arg(argList, char *);
if (bytes == NULL) {
break;
}
Tcl_AppendToObj(objPtr, bytes, -1);
}
Tcl_SetObjResult(interp, objPtr);
va_end(argList);
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
350 351 352 353 354 355 356 |
Tcl_AppendElement(
Tcl_Interp *interp, /* Interpreter whose result is to be
* extended. */
const char *element) /* String to convert to list element and add
* to result. */
{
Interp *iPtr = (Interp *) interp;
| | | | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
Tcl_AppendElement(
Tcl_Interp *interp, /* Interpreter whose result is to be
* extended. */
const char *element) /* String to convert to list element and add
* to result. */
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *elementPtr = Tcl_NewStringObj(element, -1);
Tcl_Obj *listPtr = Tcl_NewListObj(1, &elementPtr);
const char *bytes;
Tcl_Size length;
if (Tcl_IsShared(iPtr->objResultPtr)) {
Tcl_SetObjResult(interp, Tcl_DuplicateObj(iPtr->objResultPtr));
}
bytes = Tcl_GetStringFromObj(iPtr->objResultPtr, &length);
if (TclNeedSpace(bytes, bytes + length)) {
Tcl_AppendToObj(iPtr->objResultPtr, " ", 1);
|
| ︙ | ︙ | |||
507 508 509 510 511 512 513 |
while (1) {
char *elem = va_arg(argList, char *);
if (elem == NULL) {
break;
}
| | | 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
while (1) {
char *elem = va_arg(argList, char *);
if (elem == NULL) {
break;
}
Tcl_ListObjAppendElement(NULL, errorObj, Tcl_NewStringObj(elem, -1));
}
Tcl_SetObjErrorCode(interp, errorObj);
va_end(argList);
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
717 718 719 720 721 722 723 |
if (iPtr->errorInfo) {
Tcl_DecrRefCount(iPtr->errorInfo);
iPtr->errorInfo = NULL;
}
Tcl_DictObjGet(NULL, iPtr->returnOpts, keys[KEY_ERRORINFO],
&valuePtr);
if (valuePtr != NULL) {
| | | | 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 |
if (iPtr->errorInfo) {
Tcl_DecrRefCount(iPtr->errorInfo);
iPtr->errorInfo = NULL;
}
Tcl_DictObjGet(NULL, iPtr->returnOpts, keys[KEY_ERRORINFO],
&valuePtr);
if (valuePtr != NULL) {
Tcl_Size length;
(void) Tcl_GetStringFromObj(valuePtr, &length);
if (length) {
iPtr->errorInfo = valuePtr;
Tcl_IncrRefCount(iPtr->errorInfo);
iPtr->flags |= ERR_ALREADY_LOGGED;
}
}
Tcl_DictObjGet(NULL, iPtr->returnOpts, keys[KEY_ERRORSTACK],
&valuePtr);
if (valuePtr != NULL) {
Tcl_Size len, valueObjc;
Tcl_Obj **valueObjv;
if (Tcl_IsShared(iPtr->errorStack)) {
Tcl_Obj *newObj;
newObj = Tcl_DuplicateObj(iPtr->errorStack);
Tcl_DecrRefCount(iPtr->errorStack);
|
| ︙ | ︙ | |||
906 907 908 909 910 911 912 |
/*
* Check for bogus -errorcode value.
*/
Tcl_DictObjGet(NULL, returnOpts, keys[KEY_ERRORCODE], &valuePtr);
if (valuePtr != NULL) {
| | | 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 |
/*
* Check for bogus -errorcode value.
*/
Tcl_DictObjGet(NULL, returnOpts, keys[KEY_ERRORCODE], &valuePtr);
if (valuePtr != NULL) {
Tcl_Size length;
if (TCL_ERROR == TclListObjLengthM(NULL, valuePtr, &length )) {
/*
* Value is not a list, which is illegal for -errorcode.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
| ︙ | ︙ | |||
928 929 930 931 932 933 934 |
/*
* Check for bogus -errorstack value.
*/
Tcl_DictObjGet(NULL, returnOpts, keys[KEY_ERRORSTACK], &valuePtr);
if (valuePtr != NULL) {
| | | 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 |
/*
* Check for bogus -errorstack value.
*/
Tcl_DictObjGet(NULL, returnOpts, keys[KEY_ERRORSTACK], &valuePtr);
if (valuePtr != NULL) {
Tcl_Size length;
if (TCL_ERROR == TclListObjLengthM(NULL, valuePtr, &length)) {
/*
* Value is not a list, which is illegal for -errorstack.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
| ︙ | ︙ | |||
1096 1097 1098 1099 1100 1101 1102 |
*/
int
Tcl_SetReturnOptions(
Tcl_Interp *interp,
Tcl_Obj *options)
{
| | | 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 |
*/
int
Tcl_SetReturnOptions(
Tcl_Interp *interp,
Tcl_Obj *options)
{
Tcl_Size objc;
int level, code;
Tcl_Obj **objv, *mergedOpts;
Tcl_IncrRefCount(options);
if (TCL_ERROR == TclListObjGetElementsM(interp, options, &objc, &objv)
|| (objc % 2)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
| ︙ | ︙ |
Changes to generic/tclScan.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * tclScan.c -- * * This file contains the implementation of the "scan" command. * * Copyright © 1998 Scriptics Corporation. * * 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 "tclTomMath.h" /* * Flag values used by Tcl_ScanObjCmd. */ #define SCAN_NOSKIP 0x1 /* Don't skip blanks. */ #define SCAN_SUPPRESS 0x2 /* Suppress assignment. */ | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* * tclScan.c -- * * This file contains the implementation of the "scan" command. * * Copyright © 1998 Scriptics Corporation. * * 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 "tclTomMath.h" #include <assert.h> /* * Flag values used by Tcl_ScanObjCmd. */ #define SCAN_NOSKIP 0x1 /* Don't skip blanks. */ #define SCAN_SUPPRESS 0x2 /* Suppress assignment. */ |
| ︙ | ︙ | |||
254 255 256 257 258 259 260 |
Tcl_Interp *interp, /* Current interpreter. */
const char *format, /* The format string. */
int numVars, /* The number of variables passed to the scan
* command. */
int *totalSubs) /* The number of variables that will be
* required. */
{
| | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
Tcl_Interp *interp, /* Current interpreter. */
const char *format, /* The format string. */
int numVars, /* The number of variables passed to the scan
* command. */
int *totalSubs) /* The number of variables that will be
* required. */
{
int gotXpg, gotSequential, i, flags;
char *end;
Tcl_UniChar ch = 0;
int objIndex, xpgSize, nspace = numVars;
int *nassign = (int *)TclStackAlloc(interp, nspace * sizeof(int));
Tcl_Obj *errorMsg; /* Place to build an error messages. Note that
* these are messy operations because we do
* not want to use the formatting engine;
|
| ︙ | ︙ | |||
302 303 304 305 306 307 308 |
if ((ch < 0x80) && isdigit(UCHAR(ch))) { /* INTL: "C" locale. */
/*
* Check for an XPG3-style %n$ specification. Note: there must
* not be a mixture of XPG3 specs and non-XPG3 specs in the same
* format string.
*/
| | > | > > | > | | | | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
if ((ch < 0x80) && isdigit(UCHAR(ch))) { /* INTL: "C" locale. */
/*
* Check for an XPG3-style %n$ specification. Note: there must
* not be a mixture of XPG3 specs and non-XPG3 specs in the same
* format string.
*/
long longVal = strtoul(format-1, &end, 10); /* INTL: "C" locale. */
if (*end != '$') {
goto notXpg;
}
/* assert(longVal >= 0) because of the isdigit() check above */
format = end+1;
format += TclUtfToUniChar(format, &ch);
gotXpg = 1;
if (gotSequential) {
goto mixedXPG;
}
objIndex = longVal - 1;
/* INT_MAX because 9.0 does not support more than INT_MAX-1 args */
if ((objIndex < 0) || objIndex >= INT_MAX ||
(numVars && (objIndex >= numVars))) {
goto badIndex;
}
else if (numVars == 0) {
/*
* In the case where no vars are specified, the user can
* specify %9999$ legally, so we have to consider special
* rules for growing the assign array. 'longVal' is guaranteed
* to be > 0.
*/
xpgSize = (xpgSize > longVal) ? xpgSize : longVal;
}
goto xpgCheckDone;
}
notXpg:
gotSequential = 1;
if (gotXpg) {
|
| ︙ | ︙ | |||
344 345 346 347 348 349 350 |
xpgCheckDone:
/*
* Parse any width specifier.
*/
if ((ch < 0x80) && isdigit(UCHAR(ch))) { /* INTL: "C" locale. */
| > > > | > > > > > > > > > > > > | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
xpgCheckDone:
/*
* Parse any width specifier.
*/
if ((ch < 0x80) && isdigit(UCHAR(ch))) { /* INTL: "C" locale. */
/* Note ull >= 0 because of isdigit check above */
unsigned long long ull;
ull = strtoull(
format - 1, (char **)&format, 10); /* INTL: "C" locale. */
/* Note >=, not >, to leave room for a nul */
if (ull >= TCL_SIZE_MAX) {
Tcl_SetObjResult(
interp,
Tcl_ObjPrintf("specified field width %" TCL_LL_MODIFIER
"u exceeds limit %" TCL_SIZE_MODIFIER "d.",
ull,
(Tcl_Size)TCL_SIZE_MAX-1));
Tcl_SetErrorCode(
interp, "TCL", "FORMAT", "WIDTHLIMIT", NULL);
goto error;
}
flags |= SCAN_WIDTH;
format += TclUtfToUniChar(format, &ch);
}
/*
* Handle any size specifier.
*/
|
| ︙ | ︙ | |||
393 394 395 396 397 398 399 |
/* FALLTHRU */
case 'n':
case 's':
if (flags & (SCAN_LONGER|SCAN_BIG)) {
invalidFieldSize:
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
errorMsg = Tcl_NewStringObj(
| | | | | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
/* FALLTHRU */
case 'n':
case 's':
if (flags & (SCAN_LONGER|SCAN_BIG)) {
invalidFieldSize:
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
errorMsg = Tcl_NewStringObj(
"field size modifier may not be specified in %", -1);
Tcl_AppendToObj(errorMsg, buf, -1);
Tcl_AppendToObj(errorMsg, " conversion", -1);
Tcl_SetObjResult(interp, errorMsg);
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BADSIZE", NULL);
goto error;
}
/*
* Fall through!
*/
|
| ︙ | ︙ | |||
448 449 450 451 452 453 454 | goto badSet; } format += TclUtfToUniChar(format, &ch); } break; badSet: Tcl_SetObjResult(interp, Tcl_NewStringObj( | | | | | | | | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
goto badSet;
}
format += TclUtfToUniChar(format, &ch);
}
break;
badSet:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unmatched [ in format string", -1));
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BRACKET", NULL);
goto error;
default:
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
errorMsg = Tcl_NewStringObj(
"bad scan conversion character \"", -1);
Tcl_AppendToObj(errorMsg, buf, -1);
Tcl_AppendToObj(errorMsg, "\"", -1);
Tcl_SetObjResult(interp, errorMsg);
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BADTYPE", NULL);
goto error;
}
if (!(flags & SCAN_SUPPRESS)) {
if (objIndex >= nspace) {
/*
* Expand the nassign buffer. If we are using XPG specifiers,
* make sure that we grow to a large enough size. xpgSize is
* guaranteed to be at least one larger than objIndex.
*/
int nspaceOrig = nspace;
if (xpgSize) {
nspace = xpgSize;
} else {
nspace += 16; /* formerly STATIC_LIST_SIZE */
}
nassign = (int *)TclStackRealloc(interp, nassign,
nspace * sizeof(int));
for (i = nspaceOrig; i < nspace; i++) {
nassign[i] = 0;
}
}
nassign[objIndex]++;
objIndex++;
}
}
|
| ︙ | ︙ | |||
527 528 529 530 531 532 533 |
TclStackFree(interp, nassign);
return TCL_OK;
badIndex:
if (gotXpg) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
TclStackFree(interp, nassign);
return TCL_OK;
badIndex:
if (gotXpg) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"%n$\" argument index out of range", -1));
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "INDEXRANGE", NULL);
} else {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"different numbers of variable names and field specifiers",
-1));
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "FIELDVARMISMATCH", NULL);
}
|
| ︙ | ︙ | |||
571 572 573 574 575 576 577 |
{
const char *format;
int numVars, nconversions, totalVars = -1;
int objIndex, offset, i, result, code;
long value;
const char *string, *end, *baseString;
char op = 0;
| | > | 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
{
const char *format;
int numVars, nconversions, totalVars = -1;
int objIndex, offset, i, result, code;
long value;
const char *string, *end, *baseString;
char op = 0;
int underflow = 0;
Tcl_Size width;
Tcl_WideInt wideValue;
Tcl_UniChar ch = 0, sch = 0;
Tcl_Obj **objs = NULL, *objPtr = NULL;
int flags;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv,
|
| ︙ | ︙ | |||
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 |
*/
if (ch == '*') {
flags |= SCAN_SUPPRESS;
format += TclUtfToUniChar(format, &ch);
} else if ((ch < 0x80) && isdigit(UCHAR(ch))) { /* INTL: "C" locale. */
char *formatEnd;
value = strtoul(format-1, &formatEnd, 10);/* INTL: "C" locale. */
if (*formatEnd == '$') {
format = formatEnd+1;
format += TclUtfToUniChar(format, &ch);
objIndex = (int) value - 1;
}
}
/*
* Parse any width specifier.
*/
if ((ch < 0x80) && isdigit(UCHAR(ch))) { /* INTL: "C" locale. */
| > > | > > | 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 |
*/
if (ch == '*') {
flags |= SCAN_SUPPRESS;
format += TclUtfToUniChar(format, &ch);
} else if ((ch < 0x80) && isdigit(UCHAR(ch))) { /* INTL: "C" locale. */
char *formatEnd;
/* Note currently XPG3 range limited to INT_MAX to match type of objc */
value = strtoul(format-1, &formatEnd, 10);/* INTL: "C" locale. */
if (*formatEnd == '$') {
format = formatEnd+1;
format += TclUtfToUniChar(format, &ch);
objIndex = (int) value - 1;
}
}
/*
* Parse any width specifier.
*/
if ((ch < 0x80) && isdigit(UCHAR(ch))) { /* INTL: "C" locale. */
unsigned long long ull;
ull = strtoull(format-1, (char **) &format, 10); /* INTL: "C" locale. */
assert(ull <= TCL_SIZE_MAX); /* Else ValidateFormat should've error'ed */
width = (Tcl_Size)ull;
format += TclUtfToUniChar(format, &ch);
} else {
width = 0;
}
/*
* Handle any size specifier.
|
| ︙ | ︙ | |||
922 923 924 925 926 927 928 |
wideValue = WIDE_MAX;
}
}
if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) {
mp_int big;
if (mp_init_u64(&big, (Tcl_WideUInt)wideValue) != MP_OKAY) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 |
wideValue = WIDE_MAX;
}
}
if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) {
mp_int big;
if (mp_init_u64(&big, (Tcl_WideUInt)wideValue) != MP_OKAY) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"insufficient memory to create bignum", -1));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
return TCL_ERROR;
} else {
Tcl_SetBignumObj(objPtr, &big);
}
} else {
TclSetIntObj(objPtr, wideValue);
|
| ︙ | ︙ | |||
949 950 951 952 953 954 955 |
if (res == TCL_ERROR) {
if (objs != NULL) {
Tcl_Free(objs);
}
Tcl_DecrRefCount(objPtr);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 |
if (res == TCL_ERROR) {
if (objs != NULL) {
Tcl_Free(objs);
}
Tcl_DecrRefCount(objPtr);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unsigned bignum scans are invalid", -1));
Tcl_SetErrorCode(interp, "TCL", "FORMAT",
"BADUNSIGNED",NULL);
return TCL_ERROR;
}
}
} else {
if (TclGetLongFromObj(NULL, objPtr, &value) != TCL_OK) {
if (TclGetString(objPtr)[0] == '-') {
value = LONG_MIN;
} else {
value = LONG_MAX;
}
}
if ((flags & SCAN_UNSIGNED) && (value < 0)) {
#ifdef TCL_WIDE_INT_IS_LONG
mp_int big;
if (mp_init_u64(&big, (unsigned long)value) != MP_OKAY) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"insufficient memory to create bignum", -1));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
return TCL_ERROR;
} else {
Tcl_SetBignumObj(objPtr, &big);
}
#else
Tcl_SetWideIntObj(objPtr, (unsigned long)value);
|
| ︙ | ︙ | |||
1063 1064 1065 1066 1067 1068 1069 1070 |
code = TCL_ERROR;
}
Tcl_DecrRefCount(objs[i]);
}
} else {
/*
* Here no vars were specified, we want a list returned (inline scan)
*/
| > > | > | | | > > > > > > > > > > > | 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 |
code = TCL_ERROR;
}
Tcl_DecrRefCount(objs[i]);
}
} else {
/*
* Here no vars were specified, we want a list returned (inline scan)
* We create an empty Tcl_Obj to fill missing values rather than
* allocating a new Tcl_Obj every time. See test scan-bigdata-XX.
*/
Tcl_Obj *emptyObj = Tcl_NewObj();
Tcl_IncrRefCount(emptyObj);
TclNewObj(objPtr);
for (i = 0; code == TCL_OK && i < totalVars; i++) {
if (objs[i] != NULL) {
code = Tcl_ListObjAppendElement(interp, objPtr, objs[i]);
Tcl_DecrRefCount(objs[i]);
} else {
/*
* More %-specifiers than matching chars, so we just spit out
* empty strings for these.
*/
code = Tcl_ListObjAppendElement(interp, objPtr, emptyObj);
}
}
Tcl_DecrRefCount(emptyObj);
if (code != TCL_OK) {
/* If error'ed out, free up remaining. i contains last index freed */
while (++i < totalVars) {
if (objs[i] != NULL) {
Tcl_DecrRefCount(objs[i]);
}
}
Tcl_DecrRefCount(objPtr);
objPtr = NULL;
}
}
if (objs != NULL) {
Tcl_Free(objs);
}
if (code == TCL_OK) {
if (underflow && (nconversions == 0)) {
|
| ︙ | ︙ |
Changes to generic/tclStrToD.c.
| ︙ | ︙ | |||
480 481 482 483 484 485 486 |
Tcl_Interp *interp, /* Used for error reporting. May be NULL. */
Tcl_Obj *objPtr, /* Object to receive the internal rep. */
const char *expected, /* Description of the type of number the
* caller expects to be able to parse
* ("integer", "boolean value", etc.). */
const char *bytes, /* Pointer to the start of the string to
* scan. */
| | | 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
Tcl_Interp *interp, /* Used for error reporting. May be NULL. */
Tcl_Obj *objPtr, /* Object to receive the internal rep. */
const char *expected, /* Description of the type of number the
* caller expects to be able to parse
* ("integer", "boolean value", etc.). */
const char *bytes, /* Pointer to the start of the string to
* scan. */
Tcl_Size numBytes, /* Maximum number of bytes to scan, see
* above. */
const char **endPtrPtr, /* Place to store pointer to the character
* that terminated the scan. */
int flags) /* Flags governing the parse. */
{
enum State {
INITIAL, SIGNUM, ZERO, ZERO_X,
|
| ︙ | ︙ | |||
525 526 527 528 529 530 531 |
* point in the parse. */
int numDigitsAfterDp = 0; /* Number of digits scanned after the decimal
* point. */
int exponentSignum = 0; /* Signum of the exponent of a floating point
* number. */
long exponent = 0; /* Exponent of a floating point number. */
const char *p; /* Pointer to next character to scan. */
| | | | 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
* point in the parse. */
int numDigitsAfterDp = 0; /* Number of digits scanned after the decimal
* point. */
int exponentSignum = 0; /* Signum of the exponent of a floating point
* number. */
long exponent = 0; /* Exponent of a floating point number. */
const char *p; /* Pointer to next character to scan. */
Tcl_Size len; /* Number of characters remaining after p. */
const char *acceptPoint; /* Pointer to position after last character in
* an acceptable number. */
Tcl_Size acceptLen; /* Number of characters following that
* point. */
int status = TCL_OK; /* Status to return to caller. */
char d = 0; /* Last hexadecimal digit scanned; initialized
* to avoid a compiler warning. */
int shift = 0; /* Amount to shift when accumulating binary */
mp_err err = MP_OKAY;
int under = 0; /* Flag trailing '_' as error if true once
|
| ︙ | ︙ | |||
552 553 554 555 556 557 558 |
if (bytes == NULL) {
if (interp == NULL && endPtrPtr == NULL) {
if (TclHasInternalRep(objPtr, &tclDictType)) {
/* A dict can never be a (single) number */
return TCL_ERROR;
}
if (TclHasInternalRep(objPtr, &tclListType)) {
| | | 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
if (bytes == NULL) {
if (interp == NULL && endPtrPtr == NULL) {
if (TclHasInternalRep(objPtr, &tclDictType)) {
/* A dict can never be a (single) number */
return TCL_ERROR;
}
if (TclHasInternalRep(objPtr, &tclListType)) {
Tcl_Size length;
/* A list can only be a (single) number if its length == 1 */
TclListObjLengthM(NULL, objPtr, &length);
if (length != 1) {
return TCL_ERROR;
}
}
}
|
| ︙ | ︙ | |||
1519 1520 1521 1522 1523 1524 1525 |
if (status != TCL_OK) {
if (interp != NULL) {
Tcl_Obj *msg = Tcl_ObjPrintf("expected %s but got \"",
expected);
Tcl_AppendLimitedToObj(msg, bytes, numBytes, 50, "");
| | | 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 |
if (status != TCL_OK) {
if (interp != NULL) {
Tcl_Obj *msg = Tcl_ObjPrintf("expected %s but got \"",
expected);
Tcl_AppendLimitedToObj(msg, bytes, numBytes, 50, "");
Tcl_AppendToObj(msg, "\"", -1);
Tcl_SetObjResult(interp, msg);
Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL);
}
}
/*
* Free memory.
|
| ︙ | ︙ | |||
1747 1748 1749 1750 1751 1752 1753 |
((Tcl_WideInt)significand / pow10vals[-exponent]);
goto returnValue;
}
}
}
/*
| | | 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 |
((Tcl_WideInt)significand / pow10vals[-exponent]);
goto returnValue;
}
}
}
/*
* All the easy cases have failed. Promote the significand to bignum and
* call MakeHighPrecisionDouble to do it the hard way.
*/
if (mp_init_u64(&significandBig, significand) != MP_OKAY) {
return 0.0;
}
retval = MakeHighPrecisionDouble(0, &significandBig, numSigDigs,
|
| ︙ | ︙ | |||
2049 2050 2051 2052 2053 2054 2055 |
return approxResult;
}
}
/*
* Compute twoMd as 2*M*d, where d is the exact value.
* This is done by multiplying by 5**(M5+exponent) and then multiplying
| | | 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 |
return approxResult;
}
}
/*
* Compute twoMd as 2*M*d, where d is the exact value.
* This is done by multiplying by 5**(M5+exponent) and then multiplying
* by 2**(M5+exponent+1), which is, of course, a left shift.
*/
if (mp_init_copy(&twoMd, exactSignificand) != MP_OKAY) {
mp_clear(&twoMv);
return approxResult;
}
for (i = 0; (i <= 8); ++i) {
|
| ︙ | ︙ | |||
2278 2279 2280 2281 2282 2283 2284 | } /* *---------------------------------------------------------------------- * * RequiredPrecision -- * | | | 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 | } /* *---------------------------------------------------------------------- * * RequiredPrecision -- * * Determines the number of bits needed to hold an integer. * * Results: * Returns the position of the most significant bit (0 - 63). Returns 0 * if the number is zero. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ | |||
4783 4784 4785 4786 4787 4788 4789 |
* Infinite values can't convert to bignum.
*/
if (isinf(d)) {
if (interp != NULL) {
const char *s = "integer value too large to represent";
| | | 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 |
* Infinite values can't convert to bignum.
*/
if (isinf(d)) {
if (interp != NULL) {
const char *s = "integer value too large to represent";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, NULL);
}
return TCL_ERROR;
}
fract = frexp(d, &expt);
if (expt <= 0) {
|
| ︙ | ︙ | |||
5269 5270 5271 5272 5273 5274 5275 |
*buffer++ = '-';
}
*buffer++ = 'N';
*buffer++ = 'a';
*buffer++ = 'N';
bitwhack.iv &= ((UINT64_C(1)) << 51) - 1;
if (bitwhack.iv != 0) {
| | | 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 |
*buffer++ = '-';
}
*buffer++ = 'N';
*buffer++ = 'a';
*buffer++ = 'N';
bitwhack.iv &= ((UINT64_C(1)) << 51) - 1;
if (bitwhack.iv != 0) {
snprintf(buffer, TCL_DOUBLE_SPACE, "(%" PRIx64 ")", bitwhack.iv);
} else {
*buffer = '\0';
}
#endif /* IEEE_FLOATING_POINT */
}
/*
|
| ︙ | ︙ |
Changes to generic/tclStringObj.c.
| ︙ | ︙ | |||
41 42 43 44 45 46 47 | /* * Prototypes for functions defined later in this file: */ static void AppendPrintfToObjVA(Tcl_Obj *objPtr, const char *format, va_list argList); static void AppendUnicodeToUnicodeRep(Tcl_Obj *objPtr, | | | | | | | | | | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /* * Prototypes for functions defined later in this file: */ static void AppendPrintfToObjVA(Tcl_Obj *objPtr, const char *format, va_list argList); static void AppendUnicodeToUnicodeRep(Tcl_Obj *objPtr, const Tcl_UniChar *unicode, Tcl_Size appendNumChars); static void AppendUnicodeToUtfRep(Tcl_Obj *objPtr, const Tcl_UniChar *unicode, Tcl_Size numChars); static void AppendUtfToUnicodeRep(Tcl_Obj *objPtr, const char *bytes, Tcl_Size numBytes); static void AppendUtfToUtfRep(Tcl_Obj *objPtr, const char *bytes, Tcl_Size numBytes); static void DupStringInternalRep(Tcl_Obj *objPtr, Tcl_Obj *copyPtr); static Tcl_Size ExtendStringRepWithUnicode(Tcl_Obj *objPtr, const Tcl_UniChar *unicode, Tcl_Size numChars); static void ExtendUnicodeRepWithString(Tcl_Obj *objPtr, const char *bytes, Tcl_Size numBytes, Tcl_Size numAppendChars); static void FillUnicodeRep(Tcl_Obj *objPtr); static void FreeStringInternalRep(Tcl_Obj *objPtr); static void GrowStringBuffer(Tcl_Obj *objPtr, size_t needed, int flag); static void GrowUnicodeBuffer(Tcl_Obj *objPtr, size_t needed); static int SetStringFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static void SetUnicodeObj(Tcl_Obj *objPtr, const Tcl_UniChar *unicode, Tcl_Size numChars); static Tcl_Size UnicodeLength(const Tcl_UniChar *unicode); static void UpdateStringOfString(Tcl_Obj *objPtr); #if TCL_UTF_MAX > 3 #define ISCONTINUATION(bytes) (\ ((bytes)[0] & 0xC0) == 0x80) #else #define ISCONTINUATION(bytes) (\ |
| ︙ | ︙ | |||
133 134 135 136 137 138 139 |
static void
GrowStringBuffer(
Tcl_Obj *objPtr,
size_t needed,
int flag)
{
/*
| | | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
static void
GrowStringBuffer(
Tcl_Obj *objPtr,
size_t needed,
int flag)
{
/*
* Preconditions:
* objPtr->typePtr == &tclStringType
* needed > stringPtr->allocated
* flag || objPtr->bytes != NULL
*/
String *stringPtr = GET_STRING(objPtr);
char *ptr = NULL;
|
| ︙ | ︙ | |||
181 182 183 184 185 186 187 |
static void
GrowUnicodeBuffer(
Tcl_Obj *objPtr,
size_t needed)
{
/*
| | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
static void
GrowUnicodeBuffer(
Tcl_Obj *objPtr,
size_t needed)
{
/*
* Preconditions:
* objPtr->typePtr == &tclStringType
* needed > stringPtr->maxChars
*/
String *ptr = NULL, *stringPtr = GET_STRING(objPtr);
size_t attempt;
|
| ︙ | ︙ | |||
253 254 255 256 257 258 259 |
#ifdef TCL_MEM_DEBUG
#undef Tcl_NewStringObj
Tcl_Obj *
Tcl_NewStringObj(
const char *bytes, /* Points to the first of the length bytes
* used to initialize the new object. */
| | | | | 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
#ifdef TCL_MEM_DEBUG
#undef Tcl_NewStringObj
Tcl_Obj *
Tcl_NewStringObj(
const char *bytes, /* Points to the first of the length bytes
* used to initialize the new object. */
Tcl_Size length) /* The number of bytes to copy from "bytes"
* when initializing the new object. If
* TCL_INDEX_NONE, use bytes up to the first NUL
* byte. */
{
return Tcl_DbNewStringObj(bytes, length, "unknown", 0);
}
#else /* if not TCL_MEM_DEBUG */
Tcl_Obj *
Tcl_NewStringObj(
const char *bytes, /* Points to the first of the length bytes
* used to initialize the new object. */
Tcl_Size length) /* The number of bytes to copy from "bytes"
* when initializing the new object. If -1,
* use bytes up to the first NUL byte. */
{
Tcl_Obj *objPtr;
if (length < 0) {
length = (bytes? strlen(bytes) : 0);
}
TclNewStringObj(objPtr, bytes, length);
return objPtr;
}
#endif /* TCL_MEM_DEBUG */
|
| ︙ | ︙ | |||
313 314 315 316 317 318 319 |
*/
#ifdef TCL_MEM_DEBUG
Tcl_Obj *
Tcl_DbNewStringObj(
const char *bytes, /* Points to the first of the length bytes
* used to initialize the new object. */
| | | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
*/
#ifdef TCL_MEM_DEBUG
Tcl_Obj *
Tcl_DbNewStringObj(
const char *bytes, /* Points to the first of the length bytes
* used to initialize the new object. */
Tcl_Size length, /* The number of bytes to copy from "bytes"
* when initializing the new object. If -1,
* use bytes up to the first NUL byte. */
const char *file, /* The name of the source file calling this
* function; used for debugging. */
int line) /* Line number in the source file; used for
* debugging. */
{
|
| ︙ | ︙ | |||
335 336 337 338 339 340 341 |
return objPtr;
}
#else /* if not TCL_MEM_DEBUG */
Tcl_Obj *
Tcl_DbNewStringObj(
const char *bytes, /* Points to the first of the length bytes
* used to initialize the new object. */
| | | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
return objPtr;
}
#else /* if not TCL_MEM_DEBUG */
Tcl_Obj *
Tcl_DbNewStringObj(
const char *bytes, /* Points to the first of the length bytes
* used to initialize the new object. */
Tcl_Size length, /* The number of bytes to copy from "bytes"
* when initializing the new object. If -1,
* use bytes up to the first NUL byte. */
TCL_UNUSED(const char *) /*file*/,
TCL_UNUSED(int) /*line*/)
{
return Tcl_NewStringObj(bytes, length);
}
|
| ︙ | ︙ | |||
368 369 370 371 372 373 374 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_NewUnicodeObj(
const Tcl_UniChar *unicode, /* The unicode string used to initialize the
* new object. */
| | | | | | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_NewUnicodeObj(
const Tcl_UniChar *unicode, /* The unicode string used to initialize the
* new object. */
Tcl_Size numChars) /* Number of characters in the unicode
* string. */
{
Tcl_Obj *objPtr;
TclNewObj(objPtr);
SetUnicodeObj(objPtr, unicode, numChars);
return objPtr;
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetCharLength --
*
* Get the length of the Unicode string from the Tcl object.
*
* Results:
* Pointer to Unicode string representing the Unicode object.
*
* Side effects:
* Frees old internal rep. Allocates memory for new "String" internal
* rep.
*
*----------------------------------------------------------------------
*/
Tcl_Size
Tcl_GetCharLength(
Tcl_Obj *objPtr) /* The String object to get the num chars
* of. */
{
String *stringPtr;
Tcl_Size numChars = 0;
/*
* Quick, no-shimmer return for short string reps.
*/
if ((objPtr->bytes) && (objPtr->length < 2)) {
/* 0 bytes -> 0 chars; 1 byte -> 1 char */
|
| ︙ | ︙ | |||
440 441 442 443 444 445 446 |
stringPtr = GET_STRING(objPtr);
numChars = stringPtr->numChars;
/*
* If numChars is unknown, compute it.
*/
| | | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
stringPtr = GET_STRING(objPtr);
numChars = stringPtr->numChars;
/*
* If numChars is unknown, compute it.
*/
if (numChars < 0) {
TclNumUtfCharsM(numChars, objPtr->bytes, objPtr->length);
stringPtr->numChars = numChars;
}
return numChars;
}
Tcl_Size
TclGetCharLength(
Tcl_Obj *objPtr) /* The String object to get the num chars
* of. */
{
Tcl_Size numChars = 0;
/*
* Quick, no-shimmer return for short string reps.
*/
if ((objPtr->bytes) && (objPtr->length < 2)) {
/* 0 bytes -> 0 chars; 1 byte -> 1 char */
|
| ︙ | ︙ | |||
505 506 507 508 509 510 511 |
*
*----------------------------------------------------------------------
*/
int
TclCheckEmptyString(
Tcl_Obj *objPtr)
{
| | | 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
*
*----------------------------------------------------------------------
*/
int
TclCheckEmptyString(
Tcl_Obj *objPtr)
{
Tcl_Size length = TCL_INDEX_NONE;
if (objPtr->bytes == &tclEmptyString) {
return TCL_EMPTYSTRING_YES;
}
if (TclListObjIsCanonical(objPtr)) {
TclListObjLengthM(NULL, objPtr, &length);
|
| ︙ | ︙ | |||
549 550 551 552 553 554 555 |
*----------------------------------------------------------------------
*/
int
Tcl_GetUniChar(
Tcl_Obj *objPtr, /* The object to get the Unicode charater
* from. */
| | > > > > | | | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
*----------------------------------------------------------------------
*/
int
Tcl_GetUniChar(
Tcl_Obj *objPtr, /* The object to get the Unicode charater
* from. */
Tcl_Size index) /* Get the index'th Unicode character. */
{
String *stringPtr;
int ch;
if (index < 0) {
return -1;
}
/*
* Optimize the case where we're really dealing with a ByteArray object
* we don't need to convert to a string to perform the indexing operation.
*/
if (TclIsPureByteArray(objPtr)) {
Tcl_Size length = 0;
unsigned char *bytes = Tcl_GetByteArrayFromObj(objPtr, &length);
if (index >= length) {
return -1;
}
return bytes[index];
}
|
| ︙ | ︙ | |||
618 619 620 621 622 623 624 |
return ch;
}
int
TclGetUniChar(
Tcl_Obj *objPtr, /* The object to get the Unicode charater
* from. */
| | > > > > | | | | | 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
return ch;
}
int
TclGetUniChar(
Tcl_Obj *objPtr, /* The object to get the Unicode charater
* from. */
Tcl_Size index) /* Get the index'th Unicode character. */
{
int ch = 0;
if (index < 0) {
return -1;
}
/*
* Optimize the ByteArray case: N need need to convert to a string to
* perform the indexing operation.
*/
if (TclIsPureByteArray(objPtr)) {
Tcl_Size length = 0;
unsigned char *bytes = Tcl_GetByteArrayFromObj(objPtr, &length);
if (index >= length) {
return -1;
}
return bytes[index];
}
Tcl_Size numChars = TclNumUtfChars(objPtr->bytes, objPtr->length);
if (index >= numChars) {
return -1;
}
const char *begin = TclUtfAtIndex(objPtr->bytes, index);
#undef Tcl_UtfToUniChar
Tcl_UtfToUniChar(begin, &ch);
|
| ︙ | ︙ | |||
668 669 670 671 672 673 674 675 676 | * Side effects: * Converts the object to have the String internal rep. * *---------------------------------------------------------------------- */ #undef Tcl_GetUnicodeFromObj Tcl_UniChar * TclGetUnicodeFromObj( | > | | | > | | 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 |
* Side effects:
* Converts the object to have the String internal rep.
*
*----------------------------------------------------------------------
*/
#undef Tcl_GetUnicodeFromObj
#if !defined(TCL_NO_DEPRECATED)
Tcl_UniChar *
TclGetUnicodeFromObj(
Tcl_Obj *objPtr, /* The object to find the Unicode string
* for. */
int *lengthPtr) /* If non-NULL, the location where the string
* rep's Tcl_UniChar length should be stored. If
* NULL, no length is stored. */
{
String *stringPtr;
SetStringFromAny(NULL, objPtr);
stringPtr = GET_STRING(objPtr);
if (stringPtr->hasUnicode == 0) {
FillUnicodeRep(objPtr);
stringPtr = GET_STRING(objPtr);
}
if (lengthPtr != NULL) {
if (stringPtr->numChars > INT_MAX) {
Tcl_Panic("Tcl_GetUnicodeFromObj with 'int' lengthPtr"
" cannot handle such long strings. Please use 'Tcl_Size'");
}
*lengthPtr = (int)stringPtr->numChars;
}
return stringPtr->unicode;
}
#endif /* !defined(TCL_NO_DEPRECATED) */
Tcl_UniChar *
Tcl_GetUnicodeFromObj(
Tcl_Obj *objPtr, /* The object to find the unicode string
* for. */
Tcl_Size *lengthPtr) /* If non-NULL, the location where the string
* rep's unichar length should be stored. If
* NULL, no length is stored. */
{
String *stringPtr;
SetStringFromAny(NULL, objPtr);
stringPtr = GET_STRING(objPtr);
|
| ︙ | ︙ | |||
743 744 745 746 747 748 749 |
*
*----------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_GetRange(
Tcl_Obj *objPtr, /* The Tcl object to find the range of. */
| | | | | | | | 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 |
*
*----------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_GetRange(
Tcl_Obj *objPtr, /* The Tcl object to find the range of. */
Tcl_Size first, /* First index of the range. */
Tcl_Size last) /* Last index of the range. */
{
Tcl_Obj *newObjPtr; /* The Tcl object to find the range of. */
String *stringPtr;
Tcl_Size length = 0;
if (first < 0) {
first = TCL_INDEX_START;
}
/*
* Optimize the case where we're really dealing with a bytearray object
* we don't need to convert to a string to perform the substring operation.
*/
if (TclIsPureByteArray(objPtr)) {
unsigned char *bytes = Tcl_GetByteArrayFromObj(objPtr, &length);
if (last < 0 || last >= length) {
last = length - 1;
}
if (last < first) {
TclNewObj(newObjPtr);
return newObjPtr;
}
return Tcl_NewByteArrayObj(bytes + first, last - first + 1);
}
/*
|
| ︙ | ︙ | |||
788 789 790 791 792 793 794 |
* If numChars is unknown, compute it.
*/
if (stringPtr->numChars == TCL_INDEX_NONE) {
TclNumUtfCharsM(stringPtr->numChars, objPtr->bytes, objPtr->length);
}
if (stringPtr->numChars == objPtr->length) {
| | | | | | | | | | | | | | | | | 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 |
* If numChars is unknown, compute it.
*/
if (stringPtr->numChars == TCL_INDEX_NONE) {
TclNumUtfCharsM(stringPtr->numChars, objPtr->bytes, objPtr->length);
}
if (stringPtr->numChars == objPtr->length) {
if (last < 0 || last >= stringPtr->numChars) {
last = stringPtr->numChars - 1;
}
if (last < first) {
TclNewObj(newObjPtr);
return newObjPtr;
}
newObjPtr = Tcl_NewStringObj(objPtr->bytes + first, last - first + 1);
/*
* Since we know the char length of the result, store it.
*/
SetStringFromAny(NULL, newObjPtr);
stringPtr = GET_STRING(newObjPtr);
stringPtr->numChars = newObjPtr->length;
return newObjPtr;
}
FillUnicodeRep(objPtr);
stringPtr = GET_STRING(objPtr);
}
if (last < 0 || last >= stringPtr->numChars) {
last = stringPtr->numChars - 1;
}
if (last < first) {
TclNewObj(newObjPtr);
return newObjPtr;
}
#if TCL_UTF_MAX < 4
/* See: bug [11ae2be95dac9417] */
if ((first > 0) && ((stringPtr->unicode[first] & 0xFC00) == 0xDC00)
&& ((stringPtr->unicode[first-1] & 0xFC00) == 0xD800)) {
++first;
}
if ((last + 1 < stringPtr->numChars)
&& ((stringPtr->unicode[last+1] & 0xFC00) == 0xDC00)
&& ((stringPtr->unicode[last] & 0xFC00) == 0xD800)) {
++last;
}
#endif
return Tcl_NewUnicodeObj(stringPtr->unicode + first, last - first + 1);
}
Tcl_Obj *
TclGetRange(
Tcl_Obj *objPtr, /* The Tcl object to find the range of. */
Tcl_Size first, /* First index of the range. */
Tcl_Size last) /* Last index of the range. */
{
Tcl_Obj *newObjPtr; /* The Tcl object to find the range of. */
Tcl_Size length = 0;
if (first < 0) {
first = TCL_INDEX_START;
}
/*
* Optimize the case where we're really dealing with a bytearray object
* we don't need to convert to a string to perform the substring operation.
*/
if (TclIsPureByteArray(objPtr)) {
unsigned char *bytes = Tcl_GetByteArrayFromObj(objPtr, &length);
if (last < 0 || last >= length) {
last = length - 1;
}
if (last < first) {
TclNewObj(newObjPtr);
return newObjPtr;
}
return Tcl_NewByteArrayObj(bytes + first, last - first + 1);
}
Tcl_Size numChars = TclNumUtfChars(objPtr->bytes, objPtr->length);
if (last < 0 || last >= numChars) {
last = numChars - 1;
}
if (last < first) {
TclNewObj(newObjPtr);
return newObjPtr;
}
const char *begin = TclUtfAtIndex(objPtr->bytes, first);
const char *end = TclUtfAtIndex(objPtr->bytes, last + 1);
return Tcl_NewStringObj(begin, end - begin);
}
|
| ︙ | ︙ | |||
902 903 904 905 906 907 908 |
*/
void
Tcl_SetStringObj(
Tcl_Obj *objPtr, /* Object whose internal rep to init. */
const char *bytes, /* Points to the first of the length bytes
* used to initialize the object. */
| | | 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 |
*/
void
Tcl_SetStringObj(
Tcl_Obj *objPtr, /* Object whose internal rep to init. */
const char *bytes, /* Points to the first of the length bytes
* used to initialize the object. */
Tcl_Size length) /* The number of bytes to copy from "bytes"
* when initializing the object. If -1,
* use bytes up to the first NUL byte.*/
{
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_SetStringObj");
}
|
| ︙ | ︙ | |||
933 934 935 936 937 938 939 | } /* *---------------------------------------------------------------------- * * Tcl_SetObjLength -- * | | < | | | | | < > | | > > > > | 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 |
}
/*
*----------------------------------------------------------------------
*
* Tcl_SetObjLength --
*
* Changes the length of the string representation of objPtr.
*
* Results:
* None.
*
* Side effects:
* If the size of objPtr's string representation is greater than length, a
* new terminating null byte is stored in objPtr->bytes at length, and
* bytes at positions past length have no meaning. If the length of the
* string representation is greater than length, the storage space is
* reallocated to length+1.
*
* The object's internal representation is changed to &tclStringType.
*
*----------------------------------------------------------------------
*/
void
Tcl_SetObjLength(
Tcl_Obj *objPtr, /* Pointer to object. This object must not
* currently be shared. */
Tcl_Size length) /* Number of bytes desired for string
* representation of object, not including
* terminating null byte. */
{
String *stringPtr;
if (length < 0) {
Tcl_Panic("Tcl_SetObjLength: length requested is negative: "
"%" TCL_SIZE_MODIFIER "d (integer overflow?)", length);
}
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_SetObjLength");
}
if (objPtr->bytes && objPtr->length == length) {
return;
}
|
| ︙ | ︙ | |||
992 993 994 995 996 997 998 | stringPtr->allocated = length; } objPtr->length = length; objPtr->bytes[length] = 0; /* | | | | 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 |
stringPtr->allocated = length;
}
objPtr->length = length;
objPtr->bytes[length] = 0;
/*
* Invalidate the Unicode data.
*/
stringPtr->numChars = TCL_INDEX_NONE;
stringPtr->hasUnicode = 0;
} else {
if (length > stringPtr->maxChars) {
stringPtr = stringRealloc(stringPtr, length);
SET_STRING(objPtr, stringPtr);
stringPtr->maxChars = length;
}
/*
* Mark the new end of the Unicode string
*/
stringPtr->numChars = length;
stringPtr->unicode[length] = 0;
stringPtr->hasUnicode = 1;
/*
|
| ︙ | ︙ | |||
1046 1047 1048 1049 1050 1051 1052 |
*----------------------------------------------------------------------
*/
int
Tcl_AttemptSetObjLength(
Tcl_Obj *objPtr, /* Pointer to object. This object must not
* currently be shared. */
| | > > > > > | 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
*----------------------------------------------------------------------
*/
int
Tcl_AttemptSetObjLength(
Tcl_Obj *objPtr, /* Pointer to object. This object must not
* currently be shared. */
Tcl_Size length) /* Number of bytes desired for string
* representation of object, not including
* terminating null byte. */
{
String *stringPtr;
if (length < 0) {
/* Negative lengths => most likely integer overflow */
return 0;
}
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_AttemptSetObjLength");
}
if (objPtr->bytes && objPtr->length == length) {
return 1;
}
|
| ︙ | ︙ | |||
1089 1090 1091 1092 1093 1094 1095 | stringPtr->allocated = length; } objPtr->length = length; objPtr->bytes[length] = 0; /* | | | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 |
stringPtr->allocated = length;
}
objPtr->length = length;
objPtr->bytes[length] = 0;
/*
* Invalidate the Unicode data.
*/
stringPtr->numChars = TCL_INDEX_NONE;
stringPtr->hasUnicode = 0;
} else {
/*
* Changing length of pure Unicode string.
*/
if (length > stringPtr->maxChars) {
stringPtr = stringAttemptRealloc(stringPtr, length);
if (stringPtr == NULL) {
return 0;
}
SET_STRING(objPtr, stringPtr);
stringPtr->maxChars = length;
}
/*
* Mark the new end of the Unicode string.
*/
stringPtr->unicode[length] = 0;
stringPtr->numChars = length;
stringPtr->hasUnicode = 1;
/*
|
| ︙ | ︙ | |||
1143 1144 1145 1146 1147 1148 1149 |
*
*---------------------------------------------------------------------------
*/
void
Tcl_SetUnicodeObj(
Tcl_Obj *objPtr, /* The object to set the string of. */
| | | | | > | | | | | 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
*
*---------------------------------------------------------------------------
*/
void
Tcl_SetUnicodeObj(
Tcl_Obj *objPtr, /* The object to set the string of. */
const Tcl_UniChar *unicode, /* The Unicode string used to initialize the
* object. */
Tcl_Size numChars) /* Number of characters in the Unicode
* string. */
{
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_SetUnicodeObj");
}
TclFreeInternalRep(objPtr);
SetUnicodeObj(objPtr, unicode, numChars);
}
static Tcl_Size
UnicodeLength(
const Tcl_UniChar *unicode)
{
Tcl_Size numChars = 0;
if (unicode) {
/* TODO - is this overflow check really necessary? */
while ((numChars >= 0) && (unicode[numChars] != 0)) {
numChars++;
}
}
return numChars;
}
static void
SetUnicodeObj(
Tcl_Obj *objPtr, /* The object to set the string of. */
const Tcl_UniChar *unicode, /* The Unicode string used to initialize the
* object. */
Tcl_Size numChars) /* Number of characters in the Unicode
* string. */
{
String *stringPtr;
if (numChars < 0) {
numChars = UnicodeLength(unicode);
}
/*
* Allocate enough space for the String structure + Unicode string.
*/
|
| ︙ | ︙ | |||
1224 1225 1226 1227 1228 1229 1230 |
*/
void
Tcl_AppendLimitedToObj(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* Points to the bytes to append to the
* object. */
| | | | | | | 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 |
*/
void
Tcl_AppendLimitedToObj(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* Points to the bytes to append to the
* object. */
Tcl_Size length, /* The number of bytes available to be
* appended from "bytes". If -1, then
* all bytes up to a NUL byte are available. */
Tcl_Size limit, /* The maximum number of bytes to append to
* the object. */
const char *ellipsis) /* Ellipsis marker string, appended to the
* object to indicate not all available bytes
* at "bytes" were appended. */
{
String *stringPtr;
Tcl_Size toCopy = 0;
Tcl_Size eLen = 0;
if (length < 0) {
length = (bytes ? strlen(bytes) : 0);
}
if (length == 0) {
return;
}
if (limit <= 0) {
return;
|
| ︙ | ︙ | |||
1320 1321 1322 1323 1324 1325 1326 |
*/
void
Tcl_AppendToObj(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* Points to the bytes to append to the
* object. */
| | | | | | > | 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 |
*/
void
Tcl_AppendToObj(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* Points to the bytes to append to the
* object. */
Tcl_Size length) /* The number of bytes to append from "bytes".
* If TCL_INDEX_NONE, then append all bytes up to NUL
* byte. */
{
Tcl_AppendLimitedToObj(objPtr, bytes, length, TCL_SIZE_MAX, NULL);
}
/*
*----------------------------------------------------------------------
*
* Tcl_AppendUnicodeToObj --
*
* This function appends a Unicode string to an object in the most
* efficient manner possible.
*
* Results:
* None.
*
* Side effects:
* Invalidates the string rep and creates a new Unicode string.
*
*----------------------------------------------------------------------
*/
void
Tcl_AppendUnicodeToObj(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const Tcl_UniChar *unicode, /* The Unicode string to append to the
* object. */
Tcl_Size length) /* Number of chars in Unicode. Negative
* lengths means nul terminated */
{
String *stringPtr;
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_AppendUnicodeToObj");
}
|
| ︙ | ︙ | |||
1403 1404 1405 1406 1407 1408 1409 |
void
Tcl_AppendObjToObj(
Tcl_Obj *objPtr, /* Points to the object to append to. */
Tcl_Obj *appendObjPtr) /* Object to append. */
{
String *stringPtr;
| | | | | 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 |
void
Tcl_AppendObjToObj(
Tcl_Obj *objPtr, /* Points to the object to append to. */
Tcl_Obj *appendObjPtr) /* Object to append. */
{
String *stringPtr;
Tcl_Size length = 0, numChars;
Tcl_Size appendNumChars = TCL_INDEX_NONE;
const char *bytes;
/*
* Special case: second object is standard-empty is fast case. We know
* that appending nothing to anything leaves that starting anything...
*/
if (appendObjPtr->bytes == &tclEmptyString) {
return;
}
/*
* Handle append of one ByteArray object to another as a special case.
* Note that we only do this when the objects are pure so that the
* bytearray faithfully represent the true value; Otherwise appending the
* byte arrays together could lose information;
*/
if ((TclIsPureByteArray(objPtr) || objPtr->bytes == &tclEmptyString)
&& TclIsPureByteArray(appendObjPtr)) {
|
| ︙ | ︙ | |||
1444 1445 1446 1447 1448 1449 1450 | * Write!). For the sake of extensions that go off into that realm, * though, here's a more complex approach that can handle all the * cases. * * First, get the lengths. */ | | | 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 | * Write!). For the sake of extensions that go off into that realm, * though, here's a more complex approach that can handle all the * cases. * * First, get the lengths. */ Tcl_Size lengthSrc = 0; (void) Tcl_GetByteArrayFromObj(objPtr, &length); (void) Tcl_GetByteArrayFromObj(appendObjPtr, &lengthSrc); /* * Grow buffer enough for the append. */ |
| ︙ | ︙ | |||
1467 1468 1469 1470 1471 1472 1473 | /* * Now do the append knowing that buffer growth cannot cause any * trouble. */ TclAppendBytesToByteArray(objPtr, | | | 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 |
/*
* Now do the append knowing that buffer growth cannot cause any
* trouble.
*/
TclAppendBytesToByteArray(objPtr,
Tcl_GetByteArrayFromObj(appendObjPtr, (Tcl_Size *) NULL), lengthSrc);
return;
}
/*
* Must append as strings.
*/
|
| ︙ | ︙ | |||
1516 1517 1518 1519 1520 1521 1522 |
* in both objects before appending, then set the combined number of
* characters in the final (appended-to) object.
*/
bytes = Tcl_GetStringFromObj(appendObjPtr, &length);
numChars = stringPtr->numChars;
| | | | | | | | | | | | | | | | 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 |
* in both objects before appending, then set the combined number of
* characters in the final (appended-to) object.
*/
bytes = Tcl_GetStringFromObj(appendObjPtr, &length);
numChars = stringPtr->numChars;
if ((numChars >= 0) && TclHasInternalRep(appendObjPtr, &tclStringType)) {
String *appendStringPtr = GET_STRING(appendObjPtr);
appendNumChars = appendStringPtr->numChars;
}
AppendUtfToUtfRep(objPtr, bytes, length);
if ((numChars >= 0) && (appendNumChars >= 0)) {
stringPtr->numChars = numChars + appendNumChars;
}
}
/*
*----------------------------------------------------------------------
*
* AppendUnicodeToUnicodeRep --
*
* Appends the contents of unicode to the Unicode rep of
* objPtr, which must already have a valid Unicode rep.
*
* Results:
* None.
*
* Side effects:
* objPtr's internal rep is reallocated.
*
*----------------------------------------------------------------------
*/
static void
AppendUnicodeToUnicodeRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const Tcl_UniChar *unicode, /* String to append. */
Tcl_Size appendNumChars) /* Number of chars of "unicode" to append. */
{
String *stringPtr;
Tcl_Size numChars;
if (appendNumChars < 0) {
appendNumChars = UnicodeLength(unicode);
}
if (appendNumChars == 0) {
return;
}
SetStringFromAny(NULL, objPtr);
stringPtr = GET_STRING(objPtr);
/*
* If not enough space has been allocated for the Unicode rep, reallocate
* the internal rep object with additional space. First try to double the
* required allocation; if that fails, try a more modest increase. See the
* "TCL STRING GROWTH ALGORITHM" comment at the top of this file for an
* explanation of this growth algorithm.
*/
numChars = stringPtr->numChars + appendNumChars;
if (numChars > stringPtr->maxChars) {
Tcl_Size offset = -1;
/*
* Protect against case where Unicode points into the existing
* stringPtr->unicode array. Force it to follow any relocations due to
* the reallocs below.
*/
if (unicode && unicode >= stringPtr->unicode
&& unicode <= stringPtr->unicode + stringPtr->maxChars) {
offset = unicode - stringPtr->unicode;
}
GrowUnicodeBuffer(objPtr, numChars);
stringPtr = GET_STRING(objPtr);
/*
* Relocate Unicode if needed; see above.
*/
if (offset >= 0) {
unicode = stringPtr->unicode + offset;
}
}
/*
* Copy the new string onto the end of the old string, then add the
* trailing null.
*/
|
| ︙ | ︙ | |||
1638 1639 1640 1641 1642 1643 1644 |
*----------------------------------------------------------------------
*/
static void
AppendUnicodeToUtfRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const Tcl_UniChar *unicode, /* String to convert to UTF. */
| | | 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 |
*----------------------------------------------------------------------
*/
static void
AppendUnicodeToUtfRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const Tcl_UniChar *unicode, /* String to convert to UTF. */
Tcl_Size numChars) /* Number of chars of Unicode to convert. */
{
String *stringPtr = GET_STRING(objPtr);
numChars = ExtendStringRepWithUnicode(objPtr, unicode, numChars);
if (stringPtr->numChars != TCL_INDEX_NONE) {
stringPtr->numChars += numChars;
|
| ︙ | ︙ | |||
1671 1672 1673 1674 1675 1676 1677 |
*----------------------------------------------------------------------
*/
static void
AppendUtfToUnicodeRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* String to convert to Unicode. */
| | | | 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 |
*----------------------------------------------------------------------
*/
static void
AppendUtfToUnicodeRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* String to convert to Unicode. */
Tcl_Size numBytes) /* Number of bytes of "bytes" to convert. */
{
String *stringPtr;
if (numBytes == 0) {
return;
}
ExtendUnicodeRepWithString(objPtr, bytes, numBytes, -1);
TclInvalidateStringRep(objPtr);
stringPtr = GET_STRING(objPtr);
stringPtr->allocated = 0;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
1707 1708 1709 1710 1711 1712 1713 |
*----------------------------------------------------------------------
*/
static void
AppendUtfToUtfRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* String to append. */
| | | > > > | | 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 |
*----------------------------------------------------------------------
*/
static void
AppendUtfToUtfRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* String to append. */
Tcl_Size numBytes) /* Number of bytes of "bytes" to append. */
{
String *stringPtr;
Tcl_Size newLength, oldLength;
if (numBytes == 0) {
return;
}
/*
* Copy the new string onto the end of the old string, then add the
* trailing null.
*/
if (objPtr->bytes == NULL) {
objPtr->length = 0;
}
oldLength = objPtr->length;
if (numBytes > TCL_SIZE_MAX - oldLength) {
Tcl_Panic("max size for a Tcl value (%" TCL_SIZE_MODIFIER "d bytes) exceeded", TCL_SIZE_MAX);
}
newLength = numBytes + oldLength;
stringPtr = GET_STRING(objPtr);
if (newLength > stringPtr->allocated) {
Tcl_Size offset = -1;
/*
* Protect against case where unicode points into the existing
* stringPtr->unicode array. Force it to follow any relocations due to
* the reallocs below.
*/
|
| ︙ | ︙ | |||
1753 1754 1755 1756 1757 1758 1759 | GrowStringBuffer(objPtr, newLength, 0); /* * Relocate bytes if needed; see above. */ | | | | 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 |
GrowStringBuffer(objPtr, newLength, 0);
/*
* Relocate bytes if needed; see above.
*/
if (offset >= 0) {
bytes = objPtr->bytes + offset;
}
}
/*
* Invalidate the unicode data.
*/
stringPtr->numChars = -1;
stringPtr->hasUnicode = 0;
if (bytes) {
memmove(objPtr->bytes + oldLength, bytes, numBytes);
}
objPtr->bytes[newLength] = 0;
objPtr->length = newLength;
|
| ︙ | ︙ | |||
1808 1809 1810 1811 1812 1813 1814 |
while (1) {
const char *bytes = va_arg(argList, char *);
if (bytes == NULL) {
break;
}
| | | 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 |
while (1) {
const char *bytes = va_arg(argList, char *);
if (bytes == NULL) {
break;
}
Tcl_AppendToObj(objPtr, bytes, -1);
}
va_end(argList);
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
1838 1839 1840 1841 1842 1843 1844 |
*/
int
Tcl_AppendFormatToObj(
Tcl_Interp *interp,
Tcl_Obj *appendObj,
const char *format,
| | | | | > | | | 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 |
*/
int
Tcl_AppendFormatToObj(
Tcl_Interp *interp,
Tcl_Obj *appendObj,
const char *format,
Tcl_Size objc,
Tcl_Obj *const objv[])
{
const char *span = format, *msg, *errCode;
int gotXpg = 0, gotSequential = 0;
Tcl_Size objIndex = 0, originalLength, limit, numBytes = 0;
Tcl_UniChar ch = 0;
static const char *mixedXPG =
"cannot mix \"%\" and \"%n$\" conversion specifiers";
static const char *const badIndex[2] = {
"not enough arguments for all format specifiers",
"\"%n$\" argument index out of range"
};
static const char *overflow = "max size for a Tcl value exceeded";
if (Tcl_IsShared(appendObj)) {
Tcl_Panic("%s called with shared object", "Tcl_AppendFormatToObj");
}
(void)Tcl_GetStringFromObj(appendObj, &originalLength);
limit = TCL_SIZE_MAX - originalLength;
/*
* Format string is NUL-terminated.
*/
while (*format != '\0') {
char *end;
int gotMinus = 0, gotHash = 0, gotZero = 0, gotSpace = 0, gotPlus = 0;
int gotPrecision, sawFlag, useShort = 0, useBig = 0;
Tcl_Size width, precision;
#ifndef TCL_WIDE_INT_IS_LONG
int useWide = 0;
#endif
int newXpg, allocSegment = 0;
Tcl_Size numChars, segmentLimit, segmentNumBytes;
Tcl_Obj *segment;
int step = TclUtfToUniChar(format, &ch);
format += step;
if (ch != '%') {
numBytes += step;
continue;
|
| ︙ | ︙ | |||
1935 1936 1937 1938 1939 1940 1941 |
if (gotXpg) {
msg = mixedXPG;
errCode = "MIXEDSPECTYPES";
goto errorMsg;
}
gotSequential = 1;
}
| | | 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 |
if (gotXpg) {
msg = mixedXPG;
errCode = "MIXEDSPECTYPES";
goto errorMsg;
}
gotSequential = 1;
}
if (objIndex < 0 || objIndex >= objc) {
msg = badIndex[gotXpg];
errCode = gotXpg ? "INDEXRANGE" : "FIELDVARMISMATCH";
goto errorMsg;
}
/*
* Step 2. Set of flags.
|
| ︙ | ︙ | |||
1978 1979 1980 1981 1982 1983 1984 |
/*
* Step 3. Minimum field width.
*/
width = 0;
if (isdigit(UCHAR(ch))) {
| > > | > | > | | > > | > > > > > > > | | 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 |
/*
* Step 3. Minimum field width.
*/
width = 0;
if (isdigit(UCHAR(ch))) {
/* Note ull will be >= 0 because of isdigit check above */
unsigned long long ull;
ull = strtoull(format, &end, 10);
/* Comparison is >=, not >, to leave room for nul */
if (ull >= TCL_SIZE_MAX) {
msg = overflow;
errCode = "OVERFLOW";
goto errorMsg;
}
width = (Tcl_Size)ull;
format = end;
step = TclUtfToUniChar(format, &ch);
} else if (ch == '*') {
if (objIndex >= objc - 1) {
msg = badIndex[gotXpg];
errCode = gotXpg ? "INDEXRANGE" : "FIELDVARMISMATCH";
goto errorMsg;
}
if (TclGetSizeIntFromObj(interp, objv[objIndex], &width) != TCL_OK) {
goto error;
}
if (width < 0) {
width = -width;
gotMinus = 1;
}
objIndex++;
format += step;
step = TclUtfToUniChar(format, &ch);
}
if (width > limit) {
msg = overflow;
errCode = "OVERFLOW";
goto errorMsg;
}
/*
* Step 4. Precision.
*/
gotPrecision = precision = 0;
if (ch == '.') {
gotPrecision = 1;
format += step;
step = TclUtfToUniChar(format, &ch);
}
if (isdigit(UCHAR(ch))) {
/* Note ull will be >= 0 because of isdigit check above */
unsigned long long ull;
ull = strtoull(format, &end, 10);
/* Comparison is >=, not >, to leave room for nul */
if (ull >= TCL_SIZE_MAX) {
msg = overflow;
errCode = "OVERFLOW";
goto errorMsg;
}
precision = (Tcl_Size)ull;
format = end;
step = TclUtfToUniChar(format, &ch);
} else if (ch == '*') {
if (objIndex >= objc - 1) {
msg = badIndex[gotXpg];
errCode = gotXpg ? "INDEXRANGE" : "FIELDVARMISMATCH";
goto errorMsg;
}
if (TclGetSizeIntFromObj(interp, objv[objIndex], &precision)
!= TCL_OK) {
goto error;
}
/*
* TODO: Check this truncation logic.
*/
|
| ︙ | ︙ | |||
2155 2156 2157 2158 2159 2160 2161 |
case 'X':
case 'b': {
short s = 0; /* Silence compiler warning; only defined and
* used when useShort is true. */
long l;
Tcl_WideInt w;
mp_int big;
| | > | 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 |
case 'X':
case 'b': {
short s = 0; /* Silence compiler warning; only defined and
* used when useShort is true. */
long l;
Tcl_WideInt w;
mp_int big;
int isNegative = 0;
Tcl_Size toAppend;
#ifndef TCL_WIDE_INT_IS_LONG
if (ch == 'p') {
useWide = 1;
}
#endif
if (useBig) {
|
| ︙ | ︙ | |||
2213 2214 2215 2216 2217 2218 2219 |
} else {
isNegative = (l < (long) 0);
if (l == (long) 0) gotHash = 0;
}
TclNewObj(segment);
allocSegment = 1;
| | | 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 |
} else {
isNegative = (l < (long) 0);
if (l == (long) 0) gotHash = 0;
}
TclNewObj(segment);
allocSegment = 1;
segmentLimit = TCL_SIZE_MAX;
Tcl_IncrRefCount(segment);
if ((isNegative || gotPlus || gotSpace) && (useBig || ch=='d')) {
Tcl_AppendToObj(segment,
(isNegative ? "-" : gotPlus ? "+" : " "), 1);
segmentLimit -= 1;
}
|
| ︙ | ︙ | |||
2243 2244 2245 2246 2247 2248 2249 |
segmentLimit -= 2;
break;
}
}
switch (ch) {
case 'd': {
| | | 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 |
segmentLimit -= 2;
break;
}
}
switch (ch) {
case 'd': {
Tcl_Size length;
Tcl_Obj *pure;
const char *bytes;
if (useShort) {
TclNewIntObj(pure, s);
#ifndef TCL_WIDE_INT_IS_LONG
} else if (useWide) {
|
| ︙ | ︙ | |||
2278 2279 2280 2281 2282 2283 2284 |
/*
* Canonical decimal string reps for integers are composed
* entirely of one-byte encoded characters, so "length" is the
* number of chars.
*/
if (gotPrecision) {
| | | | | | 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 |
/*
* Canonical decimal string reps for integers are composed
* entirely of one-byte encoded characters, so "length" is the
* number of chars.
*/
if (gotPrecision) {
if (length < precision) {
segmentLimit -= precision - length;
}
while (length < precision) {
Tcl_AppendToObj(segment, "0", 1);
length++;
}
gotZero = 0;
}
if (gotZero) {
length += Tcl_GetCharLength(segment);
if (length < width) {
segmentLimit -= width - length;
}
while (length < width) {
Tcl_AppendToObj(segment, "0", 1);
length++;
}
}
if (toAppend > segmentLimit) {
msg = overflow;
errCode = "OVERFLOW";
|
| ︙ | ︙ | |||
2316 2317 2318 2319 2320 2321 2322 |
case 'p':
case 'x':
case 'X':
case 'b': {
Tcl_WideUInt bits = 0;
Tcl_WideInt numDigits = 0;
int numBits = 4, base = 16, index = 0, shift = 0;
| | | 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 |
case 'p':
case 'x':
case 'X':
case 'b': {
Tcl_WideUInt bits = 0;
Tcl_WideInt numDigits = 0;
int numBits = 4, base = 16, index = 0, shift = 0;
Tcl_Size length;
Tcl_Obj *pure;
char *bytes;
if (ch == 'u') {
base = 10;
} else if (ch == 'o') {
base = 8;
|
| ︙ | ︙ | |||
2410 2411 2412 2413 2414 2415 2416 |
}
bits /= base;
}
if (useBig) {
mp_clear(&big);
}
if (gotPrecision) {
| | | | | | 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 |
}
bits /= base;
}
if (useBig) {
mp_clear(&big);
}
if (gotPrecision) {
if (length < precision) {
segmentLimit -= precision - length;
}
while (length < precision) {
Tcl_AppendToObj(segment, "0", 1);
length++;
}
gotZero = 0;
}
if (gotZero) {
length += Tcl_GetCharLength(segment);
if (length < width) {
segmentLimit -= width - length;
}
while (length < width) {
Tcl_AppendToObj(segment, "0", 1);
length++;
}
}
if (toAppend > segmentLimit) {
msg = overflow;
errCode = "OVERFLOW";
|
| ︙ | ︙ | |||
2477 2478 2479 2480 2481 2482 2483 |
if (gotSpace) {
*p++ = ' ';
}
if (gotPlus) {
*p++ = '+';
}
if (width) {
| | > > | | | 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 |
if (gotSpace) {
*p++ = ' ';
}
if (gotPlus) {
*p++ = '+';
}
if (width) {
p += snprintf(
p, TCL_INTEGER_SPACE, "%" TCL_SIZE_MODIFIER "d", width);
if (width > length) {
length = width;
}
}
if (gotPrecision) {
*p++ = '.';
p += snprintf(
p, TCL_INTEGER_SPACE, "%" TCL_SIZE_MODIFIER "d", precision);
if (precision > TCL_SIZE_MAX - length) {
msg = overflow;
errCode = "OVERFLOW";
goto errorMsg;
}
length += precision;
}
|
| ︙ | ︙ | |||
2584 2585 2586 2587 2588 2589 2590 |
numBytes = 0;
}
return TCL_OK;
errorMsg:
if (interp != NULL) {
| | | 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 |
numBytes = 0;
}
return TCL_OK;
errorMsg:
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(msg, -1));
Tcl_SetErrorCode(interp, "TCL", "FORMAT", errCode, NULL);
}
error:
Tcl_SetObjLength(appendObj, originalLength);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2610 2611 2612 2613 2614 2615 2616 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_Format(
Tcl_Interp *interp,
const char *format,
| | | 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_Format(
Tcl_Interp *interp,
const char *format,
Tcl_Size objc,
Tcl_Obj *const objv[])
{
int result;
Tcl_Obj *objPtr;
TclNewObj(objPtr);
result = Tcl_AppendFormatToObj(interp, objPtr, format, objc, objv);
|
| ︙ | ︙ | |||
2644 2645 2646 2647 2648 2649 2650 |
static void
AppendPrintfToObjVA(
Tcl_Obj *objPtr,
const char *format,
va_list argList)
{
int code;
| | | 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 |
static void
AppendPrintfToObjVA(
Tcl_Obj *objPtr,
const char *format,
va_list argList)
{
int code;
Tcl_Size objc;
Tcl_Obj **objv, *list;
const char *p;
TclNewObj(list);
p = format;
Tcl_IncrRefCount(list);
while (*p != '\0') {
|
| ︙ | ︙ | |||
2891 2892 2893 2894 2895 2896 2897 |
*
*---------------------------------------------------------------------------
*/
char *
TclGetStringStorage(
Tcl_Obj *objPtr,
| | | 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 |
*
*---------------------------------------------------------------------------
*/
char *
TclGetStringStorage(
Tcl_Obj *objPtr,
Tcl_Size *sizePtr)
{
String *stringPtr;
if (!TclHasInternalRep(objPtr, &tclStringType) || objPtr->bytes == NULL) {
return Tcl_GetStringFromObj(objPtr, sizePtr);
}
|
| ︙ | ︙ | |||
2925 2926 2927 2928 2929 2930 2931 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclStringRepeat(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
| | > | > | | 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclStringRepeat(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
Tcl_Size count,
int flags)
{
Tcl_Obj *objResultPtr;
int inPlace = flags & TCL_STRING_IN_PLACE;
Tcl_Size length = 0;
int unichar = 0;
Tcl_Size done = 1;
int binary = TclIsPureByteArray(objPtr);
Tcl_Size maxCount;
/* assert (count >= 2) */
/*
* Analyze to determine what representation result should be.
* GOALS: Avoid shimmering & string rep generation.
* Produce pure bytearray when possible.
|
| ︙ | ︙ | |||
2955 2956 2957 2958 2959 2960 2961 |
}
}
}
if (binary) {
/* Result will be pure byte array. Pre-size it */
(void)Tcl_GetByteArrayFromObj(objPtr, &length);
| | | | | | | | > | | 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 |
}
}
}
if (binary) {
/* Result will be pure byte array. Pre-size it */
(void)Tcl_GetByteArrayFromObj(objPtr, &length);
maxCount = TCL_SIZE_MAX;
} else if (unichar) {
/* Result will be pure Tcl_UniChar array. Pre-size it. */
(void)Tcl_GetUnicodeFromObj(objPtr, &length);
maxCount = TCL_SIZE_MAX/sizeof(Tcl_UniChar);
} else {
/* Result will be concat of string reps. Pre-size it. */
(void)Tcl_GetStringFromObj(objPtr, &length);
maxCount = TCL_SIZE_MAX;
}
if (length == 0) {
/* Any repeats of empty is empty. */
return objPtr;
}
/* maxCount includes space for null */
if (count > (maxCount-1)) {
if (interp) {
Tcl_SetObjResult(
interp,
Tcl_ObjPrintf("max size for a Tcl value (%" TCL_SIZE_MODIFIER
"d bytes) exceeded",
TCL_SIZE_MAX));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
return NULL;
}
if (binary) {
/* Efficiently produce a pure byte array result */
objResultPtr = (!inPlace || Tcl_IsShared(objPtr)) ?
Tcl_DuplicateObj(objPtr) : objPtr;
/* Allocate count*length space */
Tcl_SetByteArrayLength(objResultPtr, count*length); /* PANIC? */
Tcl_SetByteArrayLength(objResultPtr, length);
while (count - done > done) {
Tcl_AppendObjToObj(objResultPtr, objResultPtr);
done *= 2;
}
TclAppendBytesToByteArray(objResultPtr,
Tcl_GetByteArrayFromObj(objResultPtr, (Tcl_Size *) NULL),
(count - done) * length);
} else if (unichar) {
/*
* Efficiently produce a pure Tcl_UniChar array result.
*/
if (!inPlace || Tcl_IsShared(objPtr)) {
objResultPtr = Tcl_NewUnicodeObj(Tcl_GetUnicode(objPtr), length);
} else {
TclInvalidateStringRep(objPtr);
objResultPtr = objPtr;
}
/* TODO - overflow check */
if (0 == Tcl_AttemptSetObjLength(objResultPtr, count*length)) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"string size overflow: unable to alloc %"
TCL_SIZE_MODIFIER "d bytes",
STRING_SIZE(count*length)));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
return NULL;
}
Tcl_SetObjLength(objResultPtr, length);
while (count - done > done) {
|
| ︙ | ︙ | |||
3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 |
if (!inPlace || Tcl_IsShared(objPtr)) {
objResultPtr = Tcl_NewStringObj(TclGetString(objPtr), length);
} else {
TclFreeInternalRep(objPtr);
objResultPtr = objPtr;
}
if (0 == Tcl_AttemptSetObjLength(objResultPtr, count*length)) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
| > | | 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 |
if (!inPlace || Tcl_IsShared(objPtr)) {
objResultPtr = Tcl_NewStringObj(TclGetString(objPtr), length);
} else {
TclFreeInternalRep(objPtr);
objResultPtr = objPtr;
}
/* TODO - overflow check */
if (0 == Tcl_AttemptSetObjLength(objResultPtr, count*length)) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"string size overflow: unable to alloc %" TCL_SIZE_MODIFIER "d bytes",
count*length));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
return NULL;
}
Tcl_SetObjLength(objResultPtr, length);
while (count - done > done) {
|
| ︙ | ︙ | |||
3080 3081 3082 3083 3084 3085 3086 |
*
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclStringCat(
Tcl_Interp *interp,
| | | > | | | | | | 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 |
*
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclStringCat(
Tcl_Interp *interp,
Tcl_Size objc,
Tcl_Obj * const objv[],
int flags)
{
Tcl_Obj *objResultPtr, * const *ov;
int binary = 1;
Tcl_Size oc;
Tcl_Size length = 0;
int allowUniChar = 1, requestUniChar = 0, forceUniChar = 0;
Tcl_Size first = objc - 1; /* Index of first value possibly not empty */
Tcl_Size last = 0; /* Index of last value possibly not empty */
int inPlace = flags & TCL_STRING_IN_PLACE;
/* assert ( objc >= 0 ) */
if (objc <= 1) {
/* Negative (shouldn't be), one or no objects; return first or empty */
return objc == 1 ? objv[0] : Tcl_NewObj();
}
/* assert ( objc >= 2 ) */
/*
* Analyze to determine what representation result should be.
* GOALS: Avoid shimmering & string rep generation.
|
| ︙ | ︙ | |||
3148 3149 3150 3151 3152 3153 3154 |
} while (--oc && (binary || allowUniChar));
if (binary) {
/*
* Result will be pure byte array. Pre-size it
*/
| | | | | | 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 |
} while (--oc && (binary || allowUniChar));
if (binary) {
/*
* Result will be pure byte array. Pre-size it
*/
Tcl_Size numBytes = 0;
ov = objv;
oc = objc;
do {
Tcl_Obj *objPtr = *ov++;
/*
* Every argument is either a bytearray with a ("pure")
* value we know we can safely use, or it is an empty string.
* We don't need to count bytes for the empty strings.
*/
if (TclIsPureByteArray(objPtr)) {
(void)Tcl_GetByteArrayFromObj(objPtr, &numBytes); /* PANIC? */
if (numBytes) {
last = objc - oc;
if (length == 0) {
first = last;
}
if (length > (TCL_SIZE_MAX-numBytes)) {
goto overflow;
}
length += numBytes;
}
}
} while (--oc);
} else if ((allowUniChar && requestUniChar) || forceUniChar) {
/*
* Result will be pure Tcl_UniChar array. Pre-size it.
*/
ov = objv;
oc = objc;
do {
Tcl_Obj *objPtr = *ov++;
if ((objPtr->bytes == NULL) || (objPtr->length)) {
Tcl_Size numChars;
(void)Tcl_GetUnicodeFromObj(objPtr, &numChars); /* PANIC? */
if (numChars) {
last = objc - oc;
if (length == 0) {
first = last;
}
if (length > (Tcl_Size) ((TCL_SIZE_MAX/sizeof(Tcl_UniChar))-numChars)) {
goto overflow;
}
length += numChars;
}
}
} while (--oc);
} else {
|
| ︙ | ︙ | |||
3236 3237 3238 3239 3240 3241 3242 |
* or (oc == 0) and all values are known empty,
* so first = last = objc - 1 signals the right quick return.
*/
first = last = objc - oc - 1;
if (oc && (length == 0)) {
| | | 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 |
* or (oc == 0) and all values are known empty,
* so first = last = objc - 1 signals the right quick return.
*/
first = last = objc - oc - 1;
if (oc && (length == 0)) {
Tcl_Size numBytes;
/* assert ( pendingPtr != NULL ) */
/*
* There's a pending value followed by more values. Loop over
* remaining values generating strings until a non-empty value
* is found, or the pending value gets its string generated.
|
| ︙ | ︙ | |||
3261 3262 3263 3264 3265 3266 3267 |
if (oc || numBytes) {
(void)Tcl_GetStringFromObj(pendingPtr, &length);
}
if (length == 0) {
if (numBytes) {
first = last;
}
| | | | | 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 |
if (oc || numBytes) {
(void)Tcl_GetStringFromObj(pendingPtr, &length);
}
if (length == 0) {
if (numBytes) {
first = last;
}
} else if (numBytes > (TCL_SIZE_MAX - length)) {
goto overflow;
}
length += numBytes;
}
} while (oc && (length == 0));
while (oc) {
Tcl_Size numBytes;
Tcl_Obj *objPtr = *ov++;
/* assert ( length > 0 && pendingPtr == NULL ) */
TclGetString(objPtr); /* PANIC? */
numBytes = objPtr->length;
if (numBytes) {
last = objc - oc;
if (numBytes > (TCL_SIZE_MAX - length)) {
goto overflow;
}
length += numBytes;
}
--oc;
}
}
|
| ︙ | ︙ | |||
3305 3306 3307 3308 3309 3310 3311 |
/*
* Broken interface! Byte array value routines offer no way to handle
* failure to allocate enough space. Following stanza may panic.
*/
if (inPlace && !Tcl_IsShared(*objv)) {
| | | | | 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 |
/*
* Broken interface! Byte array value routines offer no way to handle
* failure to allocate enough space. Following stanza may panic.
*/
if (inPlace && !Tcl_IsShared(*objv)) {
Tcl_Size start = 0;
objResultPtr = *objv++; objc--;
(void)Tcl_GetByteArrayFromObj(objResultPtr, &start);
dst = Tcl_SetByteArrayLength(objResultPtr, length) + start;
} else {
objResultPtr = Tcl_NewByteArrayObj(NULL, length);
dst = Tcl_SetByteArrayLength(objResultPtr, length);
}
while (objc--) {
Tcl_Obj *objPtr = *objv++;
/*
* Every argument is either a bytearray with a ("pure")
* value we know we can safely use, or it is an empty string.
* We don't need to copy bytes from the empty strings.
*/
if (TclIsPureByteArray(objPtr)) {
Tcl_Size more = 0;
unsigned char *src = Tcl_GetByteArrayFromObj(objPtr, &more);
memcpy(dst, src, more);
dst += more;
}
}
} else if ((allowUniChar && requestUniChar) || forceUniChar) {
/* Efficiently produce a pure Tcl_UniChar array result */
Tcl_UniChar *dst;
if (inPlace && !Tcl_IsShared(*objv)) {
Tcl_Size start;
objResultPtr = *objv++; objc--;
/* Ugly interface! Force resize of the unicode array. */
(void)Tcl_GetUnicodeFromObj(objResultPtr, &start);
Tcl_InvalidateStringRep(objResultPtr);
if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
|
| ︙ | ︙ | |||
3375 3376 3377 3378 3379 3380 3381 |
}
dst = Tcl_GetUnicode(objResultPtr);
}
while (objc--) {
Tcl_Obj *objPtr = *objv++;
if ((objPtr->bytes == NULL) || (objPtr->length)) {
| | | | 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 |
}
dst = Tcl_GetUnicode(objResultPtr);
}
while (objc--) {
Tcl_Obj *objPtr = *objv++;
if ((objPtr->bytes == NULL) || (objPtr->length)) {
Tcl_Size more;
Tcl_UniChar *src = Tcl_GetUnicodeFromObj(objPtr, &more);
memcpy(dst, src, more * sizeof(Tcl_UniChar));
dst += more;
}
}
} else {
/* Efficiently concatenate string reps */
char *dst;
if (inPlace && !Tcl_IsShared(*objv)) {
Tcl_Size start;
objResultPtr = *objv++; objc--;
(void)Tcl_GetStringFromObj(objResultPtr, &start);
if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
| ︙ | ︙ | |||
3422 3423 3424 3425 3426 3427 3428 |
}
dst = TclGetString(objResultPtr);
}
while (objc--) {
Tcl_Obj *objPtr = *objv++;
if ((objPtr->bytes == NULL) || (objPtr->length)) {
| | | | 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 |
}
dst = TclGetString(objResultPtr);
}
while (objc--) {
Tcl_Obj *objPtr = *objv++;
if ((objPtr->bytes == NULL) || (objPtr->length)) {
Tcl_Size more;
char *src = Tcl_GetStringFromObj(objPtr, &more);
memcpy(dst, src, more);
dst += more;
}
}
/* Must NUL-terminate! */
*dst = '\0';
}
return objResultPtr;
overflow:
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"max size for a Tcl value (%" TCL_SIZE_MODIFIER "d bytes) exceeded", TCL_SIZE_MAX));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
return NULL;
}
/*
*---------------------------------------------------------------------------
|
| ︙ | ︙ | |||
3465 3466 3467 3468 3469 3470 3471 |
int
TclStringCmp(
Tcl_Obj *value1Ptr,
Tcl_Obj *value2Ptr,
int checkEq, /* comparison is only for equality */
int nocase, /* comparison is not case sensitive */
| | | > | 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 |
int
TclStringCmp(
Tcl_Obj *value1Ptr,
Tcl_Obj *value2Ptr,
int checkEq, /* comparison is only for equality */
int nocase, /* comparison is not case sensitive */
Tcl_Size reqlength) /* requested length in characters;
* TCL_INDEX_NONE to compare whole strings */
{
const char *s1, *s2;
int empty, match;
Tcl_Size length, s1len = 0, s2len = 0;
memCmpFn_t memCmpFn;
if ((reqlength == 0) || (value1Ptr == value2Ptr)) {
/*
* Always match at 0 chars of if it is the same obj.
* Note: as documented reqlength negative means it is ignored
*/
match = 0;
} else {
if (!nocase && TclIsPureByteArray(value1Ptr)
&& TclIsPureByteArray(value2Ptr)) {
/*
* Use binary versions of comparisons since that won't cause undue
|
| ︙ | ︙ | |||
3530 3531 3532 3533 3534 3535 3536 |
#else
checkEq
#endif
) {
memCmpFn = memcmp;
s1len *= sizeof(Tcl_UniChar);
s2len *= sizeof(Tcl_UniChar);
| | | 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 |
#else
checkEq
#endif
) {
memCmpFn = memcmp;
s1len *= sizeof(Tcl_UniChar);
s2len *= sizeof(Tcl_UniChar);
if (reqlength > 0) {
reqlength *= sizeof(Tcl_UniChar);
}
} else {
memCmpFn = (memCmpFn_t) TclUniCharNcmp;
}
}
}
|
| ︙ | ︙ | |||
3574 3575 3576 3577 3578 3579 3580 |
match = 0;
goto matchdone;
}
} else {
s1 = Tcl_GetStringFromObj(value1Ptr, &s1len);
s2 = Tcl_GetStringFromObj(value2Ptr, &s2len);
}
| | | | | | 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 |
match = 0;
goto matchdone;
}
} else {
s1 = Tcl_GetStringFromObj(value1Ptr, &s1len);
s2 = Tcl_GetStringFromObj(value2Ptr, &s2len);
}
if (!nocase && checkEq && reqlength < 0) {
/*
* When we have equal-length we can check only for
* (in)equality. We can use memcmp in all (n)eq cases because
* we don't need to worry about lexical LE/BE variance.
*/
memCmpFn = memcmp;
} else {
/*
* As a catch-all we will work with UTF-8. We cannot use
* memcmp() as that is unsafe with any string containing NUL
* (\xC0\x80 in Tcl's utf rep). We can use the more efficient
* TclpUtfNcmp2 if we are case-sensitive and no specific
* length was requested.
*/
if ((reqlength < 0) && !nocase) {
memCmpFn = (memCmpFn_t) TclpUtfNcmp2;
} else {
s1len = Tcl_NumUtfChars(s1, s1len);
s2len = Tcl_NumUtfChars(s2, s2len);
memCmpFn = (memCmpFn_t)
(nocase ? Tcl_UtfNcasecmp : Tcl_UtfNcmp);
}
}
}
/* At this point s1len, s2len, and reqlength should by now have been
* adjusted so that they are all in the units expected by the selected
* comparison function.
*/
length = (s1len < s2len) ? s1len : s2len;
if (reqlength < 0) {
/*
* The requested length is negative, so ignore it by setting it
* to length + 1 to correct the match var.
*/
reqlength = length + 1;
} else if (reqlength > 0 && reqlength < length) {
length = reqlength;
}
if (checkEq && reqlength < 0 && (s1len != s2len)) {
match = 1; /* This will be reversed below. */
} else {
/*
* The comparison function should compare up to the minimum byte
* length only.
*/
|
| ︙ | ︙ | |||
3659 3660 3661 3662 3663 3664 3665 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclStringFirst(
Tcl_Obj *needle,
Tcl_Obj *haystack,
| | | | | | 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclStringFirst(
Tcl_Obj *needle,
Tcl_Obj *haystack,
Tcl_Size start)
{
Tcl_Size lh = 0, ln = Tcl_GetCharLength(needle);
Tcl_Size value = -1;
Tcl_UniChar *checkStr, *endStr, *uh, *un;
Tcl_Obj *obj;
if (start < 0) {
start = 0;
}
if (ln == 0) {
/* We don't find empty substrings. Bizarre!
* Whenever this routine is turned into a proper substring
* finder, change to `return start` after limits imposed. */
goto firstEnd;
|
| ︙ | ︙ | |||
3766 3767 3768 3769 3770 3771 3772 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclStringLast(
Tcl_Obj *needle,
Tcl_Obj *haystack,
| | | | | | 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclStringLast(
Tcl_Obj *needle,
Tcl_Obj *haystack,
Tcl_Size last)
{
Tcl_Size lh = 0, ln = Tcl_GetCharLength(needle);
Tcl_Size value = -1;
Tcl_UniChar *checkStr, *uh, *un;
Tcl_Obj *obj;
if (ln == 0) {
/*
* We don't find empty substrings. Bizarre!
*
* TODO: When we one day make this a true substring
* finder, change this to "return last", after limitation.
*/
goto lastEnd;
}
if (TclIsPureByteArray(needle) && TclIsPureByteArray(haystack)) {
unsigned char *check, *bh = Tcl_GetByteArrayFromObj(haystack, &lh);
unsigned char *bn = Tcl_GetByteArrayFromObj(needle, &ln);
if (last >= lh) {
last = lh - 1;
}
if (last + 1 < ln) {
/* Don't start the loop if there cannot be a valid answer */
goto lastEnd;
}
check = bh + last + 1 - ln;
|
| ︙ | ︙ | |||
3810 3811 3812 3813 3814 3815 3816 |
}
goto lastEnd;
}
uh = Tcl_GetUnicodeFromObj(haystack, &lh);
un = Tcl_GetUnicodeFromObj(needle, &ln);
| | | 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 |
}
goto lastEnd;
}
uh = Tcl_GetUnicodeFromObj(haystack, &lh);
un = Tcl_GetUnicodeFromObj(needle, &ln);
if (last >= lh) {
last = lh - 1;
}
if (last + 1 < ln) {
/* Don't start the loop if there cannot be a valid answer */
goto lastEnd;
}
checkStr = uh + last + 1 - ln;
|
| ︙ | ︙ | |||
3853 3854 3855 3856 3857 3858 3859 |
*---------------------------------------------------------------------------
*/
static void
ReverseBytes(
unsigned char *to, /* Copy bytes into here... */
unsigned char *from, /* ...from here... */
| | | 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 |
*---------------------------------------------------------------------------
*/
static void
ReverseBytes(
unsigned char *to, /* Copy bytes into here... */
unsigned char *from, /* ...from here... */
Tcl_Size count) /* Until this many are copied, */
/* reversing as you go. */
{
unsigned char *src = from + count;
if (to == from) {
/* Reversing in place */
while (--src > to) {
|
| ︙ | ︙ | |||
3886 3887 3888 3889 3890 3891 3892 |
Tcl_UniChar ch = 0;
int inPlace = flags & TCL_STRING_IN_PLACE;
#if TCL_UTF_MAX < 4
int needFlip = 0;
#endif
if (TclIsPureByteArray(objPtr)) {
| | | | | | 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 |
Tcl_UniChar ch = 0;
int inPlace = flags & TCL_STRING_IN_PLACE;
#if TCL_UTF_MAX < 4
int needFlip = 0;
#endif
if (TclIsPureByteArray(objPtr)) {
Tcl_Size numBytes = 0;
unsigned char *from = Tcl_GetByteArrayFromObj(objPtr, &numBytes);
if (!inPlace || Tcl_IsShared(objPtr)) {
objPtr = Tcl_NewByteArrayObj(NULL, numBytes);
}
ReverseBytes(Tcl_GetByteArrayFromObj(objPtr, (Tcl_Size *)NULL), from, numBytes);
return objPtr;
}
SetStringFromAny(NULL, objPtr);
stringPtr = GET_STRING(objPtr);
if (stringPtr->hasUnicode) {
Tcl_UniChar *from = Tcl_GetUnicode(objPtr);
stringPtr = GET_STRING(objPtr);
Tcl_UniChar *src = from + stringPtr->numChars;
Tcl_UniChar *to;
if (!inPlace || Tcl_IsShared(objPtr)) {
/*
* Create a non-empty, pure Unicode value, so we can coax
* Tcl_SetObjLength into growing the Unicode rep buffer.
*/
objPtr = Tcl_NewUnicodeObj(&ch, 1);
Tcl_SetObjLength(objPtr, stringPtr->numChars);
to = Tcl_GetUnicode(objPtr);
stringPtr = GET_STRING(objPtr);
while (--src >= from) {
|
| ︙ | ︙ | |||
3967 3968 3969 3970 3971 3972 3973 |
}
}
}
#endif
}
if (objPtr->bytes) {
| | | | | | | 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 |
}
}
}
#endif
}
if (objPtr->bytes) {
Tcl_Size numChars = stringPtr->numChars;
Tcl_Size numBytes = objPtr->length;
char *to, *from = objPtr->bytes;
if (!inPlace || Tcl_IsShared(objPtr)) {
TclNewObj(objPtr);
Tcl_SetObjLength(objPtr, numBytes);
}
to = objPtr->bytes;
if (numChars < numBytes) {
/*
* Either numChars == -1 and we don't know how many chars are
* represented by objPtr->bytes and we need Pass 1 just in case,
* or numChars >= 0 and we know we have fewer chars than bytes, so
* we know there's a multibyte character needing Pass 1.
*
* Pass 1. Reverse the bytes of each multi-byte character.
*/
Tcl_Size bytesLeft = numBytes;
int chw;
while (bytesLeft) {
/*
* NOTE: We know that the from buffer is NUL-terminated. It's
* part of the contract for objPtr->bytes values. Thus, we can
* skip calling Tcl_UtfCharComplete() here.
*/
int bytesInChar = TclUtfToUCS4(from, &chw);
ReverseBytes((unsigned char *)to, (unsigned char *)from,
bytesInChar);
to += bytesInChar;
from += bytesInChar;
bytesLeft -= bytesInChar;
}
|
| ︙ | ︙ | |||
4045 4046 4047 4048 4049 4050 4051 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclStringReplace(
Tcl_Interp *interp, /* For error reporting, may be NULL */
Tcl_Obj *objPtr, /* String to act upon */
| | | | > > > | | 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 |
*---------------------------------------------------------------------------
*/
Tcl_Obj *
TclStringReplace(
Tcl_Interp *interp, /* For error reporting, may be NULL */
Tcl_Obj *objPtr, /* String to act upon */
Tcl_Size first, /* First index to replace */
Tcl_Size count, /* How many chars to replace */
Tcl_Obj *insertPtr, /* Replacement string, may be NULL */
int flags) /* TCL_STRING_IN_PLACE => attempt in-place */
{
int inPlace = flags & TCL_STRING_IN_PLACE;
Tcl_Obj *result;
/* Replace nothing with nothing */
if ((insertPtr == NULL) && (count <= 0)) {
if (inPlace) {
return objPtr;
} else {
return Tcl_DuplicateObj(objPtr);
}
}
if (first < 0) {
first = 0;
}
/*
* The caller very likely had to call Tcl_GetCharLength() or similar
* to be able to process index values. This means it is likely that
* objPtr is either a proper "bytearray" or a "string" or else it has
* a known and short string rep.
*/
if (TclIsPureByteArray(objPtr)) {
Tcl_Size numBytes = 0;
unsigned char *bytes = Tcl_GetByteArrayFromObj(objPtr, &numBytes);
if (insertPtr == NULL) {
/* Replace something with nothing. */
assert ( first <= numBytes ) ;
assert ( count <= numBytes ) ;
|
| ︙ | ︙ | |||
4093 4094 4095 4096 4097 4098 4099 |
/* Replace everything */
if ((first == 0) && (count == numBytes)) {
return insertPtr;
}
if (TclIsPureByteArray(insertPtr)) {
| | | | | | 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 |
/* Replace everything */
if ((first == 0) && (count == numBytes)) {
return insertPtr;
}
if (TclIsPureByteArray(insertPtr)) {
Tcl_Size newBytes = 0;
unsigned char *iBytes
= Tcl_GetByteArrayFromObj(insertPtr, &newBytes);
if (count == newBytes && inPlace && !Tcl_IsShared(objPtr)) {
/*
* Removal count and replacement count are equal.
* Other conditions permit. Do in-place splice.
*/
memcpy(bytes + first, iBytes, count);
Tcl_InvalidateStringRep(objPtr);
return objPtr;
}
if (newBytes > (TCL_SIZE_MAX - (numBytes - count))) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"max size for a Tcl value (%" TCL_SIZE_MODIFIER "d bytes) exceeded",
TCL_SIZE_MAX));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
return NULL;
}
result = Tcl_NewByteArrayObj(NULL, numBytes - count + newBytes);
/* PANIC? */
Tcl_SetByteArrayLength(result, 0);
|
| ︙ | ︙ | |||
4138 4139 4140 4141 4142 4143 4144 |
* TODO: Figure out how not to generate a Tcl_UniChar array rep
* when it can be determined objPtr->bytes points to a string of
* all single-byte characters so we can index it directly.
*/
/* The traditional implementation... */
{
| | | 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 |
* TODO: Figure out how not to generate a Tcl_UniChar array rep
* when it can be determined objPtr->bytes points to a string of
* all single-byte characters so we can index it directly.
*/
/* The traditional implementation... */
{
Tcl_Size numChars;
Tcl_UniChar *ustring = Tcl_GetUnicodeFromObj(objPtr, &numChars);
/* TODO: Is there an in-place option worth pursuing here? */
result = Tcl_NewUnicodeObj(ustring, first);
if (insertPtr) {
Tcl_AppendObjToObj(result, insertPtr);
|
| ︙ | ︙ | |||
4162 4163 4164 4165 4166 4167 4168 | /* *--------------------------------------------------------------------------- * * FillUnicodeRep -- * * Populate the Unicode internal rep with the Unicode form of its string | | | 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 | /* *--------------------------------------------------------------------------- * * FillUnicodeRep -- * * Populate the Unicode internal rep with the Unicode form of its string * rep. The object must already have a "String" internal rep. * * Results: * None. * * Side effects: * Reallocates the String internal rep. * |
| ︙ | ︙ | |||
4188 4189 4190 4191 4192 4193 4194 |
stringPtr->numChars);
}
static void
ExtendUnicodeRepWithString(
Tcl_Obj *objPtr,
const char *bytes,
| | | | | 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 |
stringPtr->numChars);
}
static void
ExtendUnicodeRepWithString(
Tcl_Obj *objPtr,
const char *bytes,
Tcl_Size numBytes,
Tcl_Size numAppendChars)
{
String *stringPtr = GET_STRING(objPtr);
Tcl_Size needed, numOrigChars = 0;
Tcl_UniChar *dst, unichar = 0;
if (stringPtr->hasUnicode) {
numOrigChars = stringPtr->numChars;
}
if (numAppendChars == TCL_INDEX_NONE) {
TclNumUtfCharsM(numAppendChars, bytes, numBytes);
|
| ︙ | ︙ | |||
4312 4313 4314 4315 4316 4317 4318 | * * Create an internal representation of type "String" for an object. * * Results: * This operation always succeeds and returns TCL_OK. * * Side effects: | | | | 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 |
*
* Create an internal representation of type "String" for an object.
*
* Results:
* This operation always succeeds and returns TCL_OK.
*
* Side effects:
* Any old internal representation for objPtr is freed and the internal
* representation is set to &tclStringType.
*
*----------------------------------------------------------------------
*/
static int
SetStringFromAny(
TCL_UNUSED(Tcl_Interp *),
|
| ︙ | ︙ | |||
4360 4361 4362 4363 4364 4365 4366 | * Update the string representation for an object whose internal * representation is "String". * * Results: * None. * * Side effects: | | | 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 | * Update the string representation for an object whose internal * representation is "String". * * Results: * None. * * Side effects: * The object's string may be set by converting its Unicode representation * to UTF format. * *---------------------------------------------------------------------- */ static void UpdateStringOfString( |
| ︙ | ︙ | |||
4390 4391 4392 4393 4394 4395 4396 |
TclInitStringRep(objPtr, NULL, 0);
} else {
(void) ExtendStringRepWithUnicode(objPtr, stringPtr->unicode,
stringPtr->numChars);
}
}
| | | | | | | | > > > > | 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 |
TclInitStringRep(objPtr, NULL, 0);
} else {
(void) ExtendStringRepWithUnicode(objPtr, stringPtr->unicode,
stringPtr->numChars);
}
}
static Tcl_Size
ExtendStringRepWithUnicode(
Tcl_Obj *objPtr,
const Tcl_UniChar *unicode,
Tcl_Size numChars)
{
/*
* Precondition: this is the "string" Tcl_ObjType.
*/
Tcl_Size i, origLength, size = 0;
char *dst;
String *stringPtr = GET_STRING(objPtr);
if (numChars < 0) {
numChars = UnicodeLength(unicode);
}
if (numChars == 0) {
return 0;
}
if (objPtr->bytes == NULL) {
objPtr->length = 0;
}
size = origLength = objPtr->length;
/*
* Quick cheap check in case we have more than enough room.
*/
if (numChars <= (TCL_SIZE_MAX - size)/TCL_UTF_MAX
&& stringPtr->allocated >= size + numChars * TCL_UTF_MAX) {
goto copyBytes;
}
for (i = 0; i < numChars && size >= 0; i++) {
/* TODO - overflow check! I don't think check below at end suffices */
size += TclUtfCount(unicode[i]);
}
if (size < 0) {
Tcl_Panic("max size for a Tcl value (%" TCL_SIZE_MODIFIER "d bytes) exceeded", TCL_SIZE_MAX);
}
/*
* Grow space if needed.
*/
if (size > stringPtr->allocated) {
GrowStringBuffer(objPtr, size, 1);
|
| ︙ | ︙ |
Changes to generic/tclStringRep.h.
| ︙ | ︙ | |||
56 57 58 59 60 61 62 |
* calculated. Any other means that there is a valid
* Unicode rep, or that the number of UTF bytes ==
* the number of chars. */
Tcl_Size allocated; /* The amount of space actually allocated for
* the UTF string (minus 1 byte for the
* termination char). */
Tcl_Size maxChars; /* Max number of chars that can fit in the
| | > > > > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
* calculated. Any other means that there is a valid
* Unicode rep, or that the number of UTF bytes ==
* the number of chars. */
Tcl_Size allocated; /* The amount of space actually allocated for
* the UTF string (minus 1 byte for the
* termination char). */
Tcl_Size maxChars; /* Max number of chars that can fit in the
* space allocated for the Unicode array. */
int hasUnicode; /* Boolean determining whether the string has
* a Unicode representation. */
Tcl_UniChar unicode[TCLFLEXARRAY]; /* The array of Unicode chars. The actual size
* of this field depends on the 'maxChars'
* field above. */
} String;
/* Limit on string lengths. The -1 because limit does not include the nul */
#define STRING_MAXCHARS \
((Tcl_Size)((TCL_SIZE_MAX - offsetof(String, unicode))/sizeof(Tcl_UniChar) - 1))
/* Memory needed to hold a string of length numChars - including NUL */
#define STRING_SIZE(numChars) \
(offsetof(String, unicode) + sizeof(Tcl_UniChar) + ((numChars) * sizeof(Tcl_UniChar)))
#define stringAttemptAlloc(numChars) \
(String *) Tcl_AttemptAlloc(STRING_SIZE(numChars))
#define stringAlloc(numChars) \
(String *) Tcl_Alloc(STRING_SIZE(numChars))
#define stringRealloc(ptr, numChars) \
|
| ︙ | ︙ |
Changes to generic/tclStubInit.c.
| ︙ | ︙ | |||
72 73 74 75 76 77 78 | #define TclStaticLibrary Tcl_StaticLibrary #undef Tcl_UniCharToUtfDString #undef Tcl_UtfToUniCharDString #undef Tcl_UtfToUniChar #undef Tcl_UniCharLen #undef TclObjInterpProc #if !defined(_WIN32) && !defined(__CYGWIN__) | | | > > > > > > > > > > | | | | > > > > > > > > > | | | | | | | > | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
#define TclStaticLibrary Tcl_StaticLibrary
#undef Tcl_UniCharToUtfDString
#undef Tcl_UtfToUniCharDString
#undef Tcl_UtfToUniChar
#undef Tcl_UniCharLen
#undef TclObjInterpProc
#if !defined(_WIN32) && !defined(__CYGWIN__)
# undef Tcl_WinConvertError
# define Tcl_WinConvertError 0
#endif
#if defined(TCL_NO_DEPRECATED)
# undef TclGetStringFromObj
# undef TclGetBytesFromObj
# undef TclGetUnicodeFromObj
# define TclGetStringFromObj 0
# define TclGetBytesFromObj 0
# if TCL_UTF_MAX > 3
# define TclGetUnicodeFromObj 0
# endif
#endif
#undef Tcl_Close
#define Tcl_Close 0
#undef TclGetByteArrayFromObj
#define TclGetByteArrayFromObj 0
#undef Tcl_GetByteArrayFromObj
#define Tcl_GetByteArrayFromObj 0
#define TclUnusedStubEntry 0
#if TCL_UTF_MAX < 4
static void uniCodePanic() {
Tcl_Panic("This extension uses a deprecated function, not available now: Tcl is compiled with -DTCL_UTF_MAX==%d", TCL_UTF_MAX);
}
# define Tcl_GetUnicodeFromObj (Tcl_UniChar *(*)(Tcl_Obj *, Tcl_Size *))(void *)uniCodePanic
# define TclGetUnicodeFromObj (Tcl_UniChar *(*)(Tcl_Obj *, int *))(void *)uniCodePanic
# define Tcl_NewUnicodeObj (Tcl_Obj *(*)(const Tcl_UniChar *, Tcl_Size))(void *)uniCodePanic
# define Tcl_SetUnicodeObj (void(*)(Tcl_Obj *, const Tcl_UniChar *, Tcl_Size))(void *)uniCodePanic
# define Tcl_AppendUnicodeToObj (void(*)(Tcl_Obj *, const Tcl_UniChar *, Tcl_Size))(void *)uniCodePanic
#endif
#define TclUtfCharComplete Tcl_UtfCharComplete
#define TclUtfNext Tcl_UtfNext
#define TclUtfPrev Tcl_UtfPrev
#if defined(TCL_NO_DEPRECATED)
# define TclListObjGetElements 0
# define TclListObjLength 0
# define TclDictObjSize 0
# define TclSplitList 0
# define TclSplitPath 0
# define TclFSSplitPath 0
# define TclParseArgsObjv 0
#else /* !defined(TCL_NO_DEPRECATED) */
int TclListObjGetElements(Tcl_Interp *interp, Tcl_Obj *listPtr,
int *objcPtr, Tcl_Obj ***objvPtr) {
Tcl_Size n = TCL_INDEX_NONE;
int result = Tcl_ListObjGetElements(interp, listPtr, &n, objvPtr);
if (objcPtr) {
if ((sizeof(int) != sizeof(size_t)) && (result == TCL_OK) && (n > INT_MAX)) {
if (interp) {
Tcl_AppendResult(interp, "List too large to be processed", NULL);
}
return TCL_ERROR;
}
*objcPtr = n;
}
return result;
}
int TclListObjLength(Tcl_Interp *interp, Tcl_Obj *listPtr,
int *lengthPtr) {
Tcl_Size n = TCL_INDEX_NONE;
int result = Tcl_ListObjLength(interp, listPtr, &n);
if (lengthPtr) {
if ((sizeof(int) != sizeof(size_t)) && (result == TCL_OK) && (n > INT_MAX)) {
if (interp) {
Tcl_AppendResult(interp, "List too large to be processed", NULL);
}
return TCL_ERROR;
}
*lengthPtr = n;
}
return result;
}
int TclDictObjSize(Tcl_Interp *interp, Tcl_Obj *dictPtr,
int *sizePtr) {
Tcl_Size n = TCL_INDEX_NONE;
int result = Tcl_DictObjSize(interp, dictPtr, &n);
if (sizePtr) {
if ((sizeof(int) != sizeof(size_t)) && (result == TCL_OK) && (n > INT_MAX)) {
if (interp) {
Tcl_AppendResult(interp, "Dict too large to be processed", NULL);
}
return TCL_ERROR;
}
*sizePtr = n;
}
return result;
}
int TclSplitList(Tcl_Interp *interp, const char *listStr, int *argcPtr,
const char ***argvPtr) {
Tcl_Size n = TCL_INDEX_NONE;
int result = Tcl_SplitList(interp, listStr, &n, argvPtr);
if (argcPtr) {
if ((sizeof(int) != sizeof(size_t)) && (result == TCL_OK) && (n > INT_MAX)) {
if (interp) {
Tcl_AppendResult(interp, "List too large to be processed", NULL);
}
Tcl_Free((void *)*argvPtr);
return TCL_ERROR;
}
*argcPtr = n;
}
return result;
}
void TclSplitPath(const char *path, int *argcPtr, const char ***argvPtr) {
Tcl_Size n = TCL_INDEX_NONE;
Tcl_SplitPath(path, &n, argvPtr);
if (argcPtr) {
if ((sizeof(int) != sizeof(size_t)) && (n > INT_MAX)) {
n = TCL_INDEX_NONE; /* No other way to return an error-situation */
Tcl_Free((void *)*argvPtr);
*argvPtr = NULL;
}
*argcPtr = n;
}
}
Tcl_Obj *TclFSSplitPath(Tcl_Obj *pathPtr, int *lenPtr) {
Tcl_Size n = TCL_INDEX_NONE;
Tcl_Obj *result = Tcl_FSSplitPath(pathPtr, &n);
if (lenPtr) {
if ((sizeof(int) != sizeof(size_t)) && result && (n > INT_MAX)) {
Tcl_DecrRefCount(result);
return NULL;
}
*lenPtr = n;
}
return result;
}
int TclParseArgsObjv(Tcl_Interp *interp,
const Tcl_ArgvInfo *argTable, int *objcPtr, Tcl_Obj *const *objv,
Tcl_Obj ***remObjv) {
Tcl_Size n = (*objcPtr < 0) ? TCL_INDEX_NONE: *objcPtr ;
int result = Tcl_ParseArgsObjv(interp, argTable, &n, objv, remObjv);
*objcPtr = (int)n;
return result;
}
#endif /* !defined(TCL_NO_DEPRECATED) */
#define TclBN_mp_add mp_add
#define TclBN_mp_add_d mp_add_d
#define TclBN_mp_and mp_and
#define TclBN_mp_clamp mp_clamp
#define TclBN_mp_clear mp_clear
#define TclBN_mp_clear_multi mp_clear_multi
|
| ︙ | ︙ | |||
333 334 335 336 337 338 339 |
int result = Tcl_ExprLong(interp, expr, &longValue);
if (result == TCL_OK) {
if ((longValue >= (long)(INT_MIN))
&& (longValue <= (long)(UINT_MAX))) {
*ptr = (int)longValue;
} else {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
int result = Tcl_ExprLong(interp, expr, &longValue);
if (result == TCL_OK) {
if ((longValue >= (long)(INT_MIN))
&& (longValue <= (long)(UINT_MAX))) {
*ptr = (int)longValue;
} else {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"integer value too large to represent", -1));
result = TCL_ERROR;
}
}
return result;
}
#define Tcl_ExprLong (int(*)(Tcl_Interp*,const char*,long*))exprInt
static int exprIntObj(Tcl_Interp *interp, Tcl_Obj*expr, int *ptr){
long longValue;
int result = Tcl_ExprLongObj(interp, expr, &longValue);
if (result == TCL_OK) {
if ((longValue >= (long)(INT_MIN))
&& (longValue <= (long)(UINT_MAX))) {
*ptr = (int)longValue;
} else {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"integer value too large to represent", -1));
result = TCL_ERROR;
}
}
return result;
}
#define Tcl_ExprLongObj (int(*)(Tcl_Interp*,Tcl_Obj*,long*))exprIntObj
static int utfNcmp(const char *s1, const char *s2, unsigned int n){
|
| ︙ | ︙ | |||
1488 1489 1490 1491 1492 1493 1494 |
Tcl_NRCallObjProc2, /* 679 */
Tcl_GetNumberFromObj, /* 680 */
Tcl_GetNumber, /* 681 */
Tcl_RemoveChannelMode, /* 682 */
Tcl_GetEncodingNulLength, /* 683 */
Tcl_GetWideUIntFromObj, /* 684 */
Tcl_DStringToObj, /* 685 */
| > | | | 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 |
Tcl_NRCallObjProc2, /* 679 */
Tcl_GetNumberFromObj, /* 680 */
Tcl_GetNumber, /* 681 */
Tcl_RemoveChannelMode, /* 682 */
Tcl_GetEncodingNulLength, /* 683 */
Tcl_GetWideUIntFromObj, /* 684 */
Tcl_DStringToObj, /* 685 */
Tcl_GetSizeIntFromObj, /* 686 */
0, /* 687 */
TclUnusedStubEntry, /* 688 */
};
/* !END!: Do not edit above this line. */
|
Changes to generic/tclTest.c.
| ︙ | ︙ | |||
330 331 332 333 334 335 336 337 338 339 340 341 342 343 | static Tcl_ObjCmdProc TestUtfNextCmd; static Tcl_ObjCmdProc TestUtfPrevCmd; static Tcl_ObjCmdProc TestNumUtfCharsCmd; static Tcl_ObjCmdProc TestFindFirstCmd; static Tcl_ObjCmdProc TestFindLastCmd; static Tcl_ObjCmdProc TestHashSystemHashCmd; static Tcl_ObjCmdProc TestGetIntForIndexCmd; static Tcl_NRPostProc NREUnwind_callback; static Tcl_ObjCmdProc TestNREUnwind; static Tcl_ObjCmdProc TestNRELevels; static Tcl_ObjCmdProc TestInterpResolverCmd; #if defined(HAVE_CPUID) && !defined(MAC_OSX_TCL) static Tcl_ObjCmdProc TestcpuidCmd; | > | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | static Tcl_ObjCmdProc TestUtfNextCmd; static Tcl_ObjCmdProc TestUtfPrevCmd; static Tcl_ObjCmdProc TestNumUtfCharsCmd; static Tcl_ObjCmdProc TestFindFirstCmd; static Tcl_ObjCmdProc TestFindLastCmd; static Tcl_ObjCmdProc TestHashSystemHashCmd; static Tcl_ObjCmdProc TestGetIntForIndexCmd; static Tcl_ObjCmdProc TestLutilCmd; static Tcl_NRPostProc NREUnwind_callback; static Tcl_ObjCmdProc TestNREUnwind; static Tcl_ObjCmdProc TestNRELevels; static Tcl_ObjCmdProc TestInterpResolverCmd; #if defined(HAVE_CPUID) && !defined(MAC_OSX_TCL) static Tcl_ObjCmdProc TestcpuidCmd; |
| ︙ | ︙ | |||
718 719 720 721 722 723 724 725 726 727 728 729 730 731 |
NULL, NULL);
Tcl_CreateObjCommand(interp, "testgetencpath", TestgetencpathObjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testsetencpath", TestsetencpathObjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testapplylambda", TestApplyLambdaObjCmd,
NULL, NULL);
if (TclObjTest_Init(interp) != TCL_OK) {
return TCL_ERROR;
}
if (Procbodytest_Init(interp) != TCL_OK) {
return TCL_ERROR;
}
| > > | 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 |
NULL, NULL);
Tcl_CreateObjCommand(interp, "testgetencpath", TestgetencpathObjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testsetencpath", TestsetencpathObjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testapplylambda", TestApplyLambdaObjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testlutil", TestLutilCmd,
NULL, NULL);
if (TclObjTest_Init(interp) != TCL_OK) {
return TCL_ERROR;
}
if (Procbodytest_Init(interp) != TCL_OK) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
920 921 922 923 924 925 926 |
for (asyncPtr = firstHandler; asyncPtr != NULL;
asyncPtr = asyncPtr->nextPtr) {
if (asyncPtr->id == id) {
Tcl_AsyncMark(asyncPtr->handler);
break;
}
}
| | | 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
for (asyncPtr = firstHandler; asyncPtr != NULL;
asyncPtr = asyncPtr->nextPtr) {
if (asyncPtr->id == id) {
Tcl_AsyncMark(asyncPtr->handler);
break;
}
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(argv[3], -1));
Tcl_MutexUnlock(&asyncTestMutex);
return code;
} else if (strcmp(argv[1], "marklater") == 0) {
if (argc != 3) {
goto wrongNumArgs;
}
if (Tcl_GetInt(interp, argv[2], &id) != TCL_OK) {
|
| ︙ | ︙ | |||
1204 1205 1206 1207 1208 1209 1210 |
}
static void
CmdDelProc1(
void *clientData) /* String to save. */
{
Tcl_DStringInit(&delString);
| | | | | | 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 |
}
static void
CmdDelProc1(
void *clientData) /* String to save. */
{
Tcl_DStringInit(&delString);
Tcl_DStringAppend(&delString, "CmdDelProc1 ", -1);
Tcl_DStringAppend(&delString, (char *) clientData, -1);
}
static void
CmdDelProc2(
void *clientData) /* String to save. */
{
Tcl_DStringInit(&delString);
Tcl_DStringAppend(&delString, "CmdDelProc2 ", -1);
Tcl_DStringAppend(&delString, (char *) clientData, -1);
}
/*
*----------------------------------------------------------------------
*
* TestcmdtokenCmd --
*
|
| ︙ | ︙ | |||
1259 1260 1261 1262 1263 1264 1265 | refPtr->token = Tcl_CreateCommand(interp, argv[2], CmdProc0, refPtr, CmdDelProc0); refPtr->id = nextCommandTokenRefId; refPtr->value = "original"; nextCommandTokenRefId++; refPtr->nextPtr = firstCommandTokenRef; firstCommandTokenRef = refPtr; | | | 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 |
refPtr->token = Tcl_CreateCommand(interp, argv[2], CmdProc0,
refPtr, CmdDelProc0);
refPtr->id = nextCommandTokenRefId;
refPtr->value = "original";
nextCommandTokenRefId++;
refPtr->nextPtr = firstCommandTokenRef;
firstCommandTokenRef = refPtr;
snprintf(buf, sizeof(buf), "%d", refPtr->id);
Tcl_AppendResult(interp, buf, NULL);
} else {
if (sscanf(argv[2], "%d", &id) != 1) {
Tcl_AppendResult(interp, "bad command token \"", argv[2],
"\"", NULL);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1467 1468 1469 1470 1471 1472 1473 |
TCL_UNUSED(Tcl_Command),
TCL_UNUSED(int) /*objc*/,
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *word = Tcl_GetString(objv[0]);
if (!strcmp(word, "Error")) {
| | | 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 |
TCL_UNUSED(Tcl_Command),
TCL_UNUSED(int) /*objc*/,
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *word = Tcl_GetString(objv[0]);
if (!strcmp(word, "Error")) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(command, -1));
return TCL_ERROR;
} else if (!strcmp(word, "Break")) {
return TCL_BREAK;
} else if (!strcmp(word, "Continue")) {
return TCL_CONTINUE;
} else if (!strcmp(word, "Return")) {
return TCL_RETURN;
|
| ︙ | ︙ | |||
1831 1832 1833 1834 1835 1836 1837 |
TCL_EXACT, &type) != TCL_OK) {
fprintf(stderr, "bad value? %g\n", d);
return TCL_ERROR;
}
type = types[type];
if (objc > 4) {
if (strcmp(Tcl_GetString(objv[4]), "shorten")) {
| | | 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 |
TCL_EXACT, &type) != TCL_OK) {
fprintf(stderr, "bad value? %g\n", d);
return TCL_ERROR;
}
type = types[type];
if (objc > 4) {
if (strcmp(Tcl_GetString(objv[4]), "shorten")) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("bad flag", -1));
return TCL_ERROR;
}
type |= TCL_DD_SHORTEST;
}
str = TclDoubleDigits(d, ndigits, type, &decpt, &signum, &endPtr);
strObj = Tcl_NewStringObj(str, endPtr-str);
Tcl_Free(str);
|
| ︙ | ︙ | |||
2028 2029 2030 2031 2032 2033 2034 |
const unsigned char *bytes;
unsigned char *bufPtr;
int srcRead, dstLen, dstWrote, dstChars;
Tcl_Obj *srcReadVar, *dstWroteVar, *dstCharsVar;
int result;
int flags;
Tcl_Obj **flagObjs;
| | > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < | 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 |
const unsigned char *bytes;
unsigned char *bufPtr;
int srcRead, dstLen, dstWrote, dstChars;
Tcl_Obj *srcReadVar, *dstWroteVar, *dstCharsVar;
int result;
int flags;
Tcl_Obj **flagObjs;
Tcl_Size nflags;
static const struct {
const char *flagKey;
int flag;
} flagMap[] = {
{"start", TCL_ENCODING_START},
{"end", TCL_ENCODING_END},
{"stoponerror", TCL_ENCODING_STOPONERROR},
{"noterminate", TCL_ENCODING_NO_TERMINATE},
{"charlimit", TCL_ENCODING_CHAR_LIMIT},
{"profiletcl8", TCL_ENCODING_PROFILE_TCL8},
{"profilestrict", TCL_ENCODING_PROFILE_STRICT},
{"profilereplace", TCL_ENCODING_PROFILE_REPLACE},
{NULL, 0}
};
Tcl_Size i;
Tcl_WideInt wide;
if (objc < 7 || objc > 10) {
Tcl_WrongNumArgs(interp,
2,
objv,
"encoding srcbytes flags state dstlen ?srcreadvar? ?dstwrotevar? ?dstcharsvar?");
return TCL_ERROR;
}
if (Tcl_GetEncodingFromObj(interp, objv[2], &encoding) != TCL_OK) {
return TCL_ERROR;
}
/* Flags may be specified as list of integers and keywords */
flags = 0;
if (Tcl_ListObjGetElements(interp, objv[4], &nflags, &flagObjs) != TCL_OK) {
return TCL_ERROR;
}
for (i = 0; i < nflags; ++i) {
int flag;
if (Tcl_GetIntFromObj(NULL, flagObjs[i], &flag) == TCL_OK) {
flags |= flag;
} else {
int idx;
if (Tcl_GetIndexFromObjStruct(interp,
flagObjs[i],
flagMap,
sizeof(flagMap[0]),
"flag",
0,
&idx) != TCL_OK) {
return TCL_ERROR;
}
flags |= flagMap[idx].flag;
}
}
/* Assumes state is integer if not "" */
if (Tcl_GetWideIntFromObj(interp, objv[5], &wide) == TCL_OK) {
encState = (Tcl_EncodingState)(size_t)wide;
encStatePtr = &encState;
} else if (Tcl_GetCharLength(objv[5]) == 0) {
encStatePtr = NULL;
} else {
return TCL_ERROR;
|
| ︙ | ︙ | |||
2234 2235 2236 2237 2238 2239 2240 |
TestencodingObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Encoding encoding;
| | | 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 |
TestencodingObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Encoding encoding;
Tcl_Size length;
const char *string;
TclEncoding *encodingPtr;
static const char *const optionStrings[] = {
"create", "delete", "nullength", "Tcl_ExternalToUtf", "Tcl_UtfToExternal", NULL
};
enum options {
ENC_CREATE, ENC_DELETE, ENC_NULLENGTH, ENC_EXTTOUTF, ENC_UTFTOEXT
|
| ︙ | ︙ | |||
2262 2263 2264 2265 2266 2267 2268 |
case ENC_CREATE: {
Tcl_EncodingType type;
if (objc != 5) {
Tcl_WrongNumArgs(interp, 2, objv, "name toutfcmd fromutfcmd");
return TCL_ERROR;
}
| | | 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 |
case ENC_CREATE: {
Tcl_EncodingType type;
if (objc != 5) {
Tcl_WrongNumArgs(interp, 2, objv, "name toutfcmd fromutfcmd");
return TCL_ERROR;
}
encodingPtr = (TclEncoding *)Tcl_Alloc(sizeof(TclEncoding));
encodingPtr->interp = interp;
string = Tcl_GetStringFromObj(objv[3], &length);
encodingPtr->toUtfCmd = (char *)Tcl_Alloc(length + 1);
memcpy(encodingPtr->toUtfCmd, string, length + 1);
string = Tcl_GetStringFromObj(objv[4], &length);
|
| ︙ | ︙ | |||
2418 2419 2420 2421 2422 2423 2424 |
static int
TestevalexObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | > | 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 |
static int
TestevalexObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int flags;
Tcl_Size length;
const char *script;
flags = 0;
if (objc == 3) {
const char *global = Tcl_GetString(objv[2]);
if (strcmp(global, "global") != 0) {
Tcl_AppendResult(interp, "bad value \"", global,
|
| ︙ | ︙ | |||
2722 2723 2724 2725 2726 2727 2728 |
static void
ExitProcOdd(
void *clientData) /* Integer value to print. */
{
char buf[16 + TCL_INTEGER_SPACE];
int len;
| | | | 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 |
static void
ExitProcOdd(
void *clientData) /* Integer value to print. */
{
char buf[16 + TCL_INTEGER_SPACE];
int len;
snprintf(buf, sizeof(buf), "odd %d\n", (int)PTR2INT(clientData));
len = strlen(buf);
if (len != (int) write(1, buf, len)) {
Tcl_Panic("ExitProcOdd: unable to write to stdout");
}
}
static void
ExitProcEven(
void *clientData) /* Integer value to print. */
{
char buf[16 + TCL_INTEGER_SPACE];
int len;
snprintf(buf, sizeof(buf), "even %d\n", (int)PTR2INT(clientData));
len = strlen(buf);
if (len != (int) write(1, buf, len)) {
Tcl_Panic("ExitProcEven: unable to write to stdout");
}
}
/*
|
| ︙ | ︙ | |||
2781 2782 2783 2784 2785 2786 2787 |
return TCL_ERROR;
}
Tcl_AppendResult(interp, "This is a result", NULL);
result = Tcl_ExprLong(interp, argv[1], &exprResult);
if (result != TCL_OK) {
return result;
}
| | | 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 |
return TCL_ERROR;
}
Tcl_AppendResult(interp, "This is a result", NULL);
result = Tcl_ExprLong(interp, argv[1], &exprResult);
if (result != TCL_OK) {
return result;
}
snprintf(buf, sizeof(buf), ": %ld", exprResult);
Tcl_AppendResult(interp, buf, NULL);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
2823 2824 2825 2826 2827 2828 2829 |
return TCL_ERROR;
}
Tcl_AppendResult(interp, "This is a result", NULL);
result = Tcl_ExprLongObj(interp, objv[1], &exprResult);
if (result != TCL_OK) {
return result;
}
| | | 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 |
return TCL_ERROR;
}
Tcl_AppendResult(interp, "This is a result", NULL);
result = Tcl_ExprLongObj(interp, objv[1], &exprResult);
if (result != TCL_OK) {
return result;
}
snprintf(buf, sizeof(buf), ": %ld", exprResult);
Tcl_AppendResult(interp, buf, NULL);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
3057 3058 3059 3060 3061 3062 3063 | /* *---------------------------------------------------------------------- * * TestgetplatformCmd -- * * This procedure implements the "testgetplatform" command. It is | | | 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 | /* *---------------------------------------------------------------------- * * TestgetplatformCmd -- * * This procedure implements the "testgetplatform" command. It is * used to retrieve the value of the tclPlatform global variable. * * Results: * A standard Tcl result. * * Side effects: * None. * |
| ︙ | ︙ | |||
3424 3425 3426 3427 3428 3429 3430 |
stringVar = NULL;
} else {
stringVar = (char *)Tcl_Alloc(strlen(argv[5]) + 1);
strcpy(stringVar, argv[5]);
}
}
if (argv[6][0] != 0) {
| | | 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 |
stringVar = NULL;
} else {
stringVar = (char *)Tcl_Alloc(strlen(argv[5]) + 1);
strcpy(stringVar, argv[5]);
}
}
if (argv[6][0] != 0) {
tmp = Tcl_NewStringObj(argv[6], -1);
if (Tcl_GetWideIntFromObj(interp, tmp, &wideVar) != TCL_OK) {
Tcl_DecrRefCount(tmp);
return TCL_ERROR;
}
Tcl_DecrRefCount(tmp);
}
if (argv[7][0]) {
|
| ︙ | ︙ | |||
3482 3483 3484 3485 3486 3487 3488 |
if (Tcl_GetDouble(interp, argv[14], &d) != TCL_OK) {
return TCL_ERROR;
}
floatVar = (float) d;
}
if (argv[15][0]) {
Tcl_WideInt w;
| | | 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 |
if (Tcl_GetDouble(interp, argv[14], &d) != TCL_OK) {
return TCL_ERROR;
}
floatVar = (float) d;
}
if (argv[15][0]) {
Tcl_WideInt w;
tmp = Tcl_NewStringObj(argv[15], -1);
if (Tcl_GetWideIntFromObj(interp, tmp, &w) != TCL_OK) {
Tcl_DecrRefCount(tmp);
return TCL_ERROR;
}
Tcl_DecrRefCount(tmp);
uwideVar = (Tcl_WideUInt) w;
}
|
| ︙ | ︙ | |||
3532 3533 3534 3535 3536 3537 3538 |
} else {
stringVar = (char *)Tcl_Alloc(strlen(argv[5]) + 1);
strcpy(stringVar, argv[5]);
}
Tcl_UpdateLinkedVar(interp, "string");
}
if (argv[6][0] != 0) {
| | | 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 |
} else {
stringVar = (char *)Tcl_Alloc(strlen(argv[5]) + 1);
strcpy(stringVar, argv[5]);
}
Tcl_UpdateLinkedVar(interp, "string");
}
if (argv[6][0] != 0) {
tmp = Tcl_NewStringObj(argv[6], -1);
if (Tcl_GetWideIntFromObj(interp, tmp, &wideVar) != TCL_OK) {
Tcl_DecrRefCount(tmp);
return TCL_ERROR;
}
Tcl_DecrRefCount(tmp);
Tcl_UpdateLinkedVar(interp, "wide");
}
|
| ︙ | ︙ | |||
3599 3600 3601 3602 3603 3604 3605 |
return TCL_ERROR;
}
floatVar = (float) d;
Tcl_UpdateLinkedVar(interp, "float");
}
if (argv[15][0]) {
Tcl_WideInt w;
| | | 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 |
return TCL_ERROR;
}
floatVar = (float) d;
Tcl_UpdateLinkedVar(interp, "float");
}
if (argv[15][0]) {
Tcl_WideInt w;
tmp = Tcl_NewStringObj(argv[15], -1);
if (Tcl_GetWideIntFromObj(interp, tmp, &w) != TCL_OK) {
Tcl_DecrRefCount(tmp);
return TCL_ERROR;
}
Tcl_DecrRefCount(tmp);
uwideVar = (Tcl_WideUInt) w;
Tcl_UpdateLinkedVar(interp, "uwide");
|
| ︙ | ︙ | |||
3656 3657 3658 3659 3660 3661 3662 |
static int LinkTypes[] = {
TCL_LINK_CHAR, TCL_LINK_UCHAR,
TCL_LINK_SHORT, TCL_LINK_USHORT, TCL_LINK_INT, TCL_LINK_UINT,
TCL_LINK_LONG, TCL_LINK_ULONG, TCL_LINK_WIDE_INT, TCL_LINK_WIDE_UINT,
TCL_LINK_FLOAT, TCL_LINK_DOUBLE, TCL_LINK_STRING, TCL_LINK_CHARS,
TCL_LINK_BINARY
};
| | > | 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 |
static int LinkTypes[] = {
TCL_LINK_CHAR, TCL_LINK_UCHAR,
TCL_LINK_SHORT, TCL_LINK_USHORT, TCL_LINK_INT, TCL_LINK_UINT,
TCL_LINK_LONG, TCL_LINK_ULONG, TCL_LINK_WIDE_INT, TCL_LINK_WIDE_UINT,
TCL_LINK_FLOAT, TCL_LINK_DOUBLE, TCL_LINK_STRING, TCL_LINK_CHARS,
TCL_LINK_BINARY
};
int typeIndex, readonly, i, size;
Tcl_Size length;
char *name, *arg;
Tcl_WideInt addr;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "option args");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
3706 3707 3708 3709 3710 3711 3712 |
i++;
}
if (Tcl_GetIndexFromObj(interp, objv[i++], LinkType, "type", 0,
&typeIndex) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[i++], &size) == TCL_ERROR) {
| | | | 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 |
i++;
}
if (Tcl_GetIndexFromObj(interp, objv[i++], LinkType, "type", 0,
&typeIndex) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[i++], &size) == TCL_ERROR) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong size value", -1));
return TCL_ERROR;
}
name = Tcl_GetString(objv[i++]);
/*
* If no address is given request one in the underlying function
*/
if (i < objc) {
if (Tcl_GetWideIntFromObj(interp, objv[i], &addr) == TCL_ERROR) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"wrong address value", -1));
return TCL_ERROR;
}
} else {
addr = 0;
}
return Tcl_LinkArray(interp, name, INT2PTR(addr),
LinkTypes[typeIndex] | readonly, size);
|
| ︙ | ︙ | |||
3818 3819 3820 3821 3822 3823 3824 |
}
break;
case LISTREP_DESCRIBE:
#define APPEND_FIELD(targetObj_, structPtr_, fld_) \
do { \
Tcl_ListObjAppendElement( \
| | | | | | | | 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 |
}
break;
case LISTREP_DESCRIBE:
#define APPEND_FIELD(targetObj_, structPtr_, fld_) \
do { \
Tcl_ListObjAppendElement( \
interp, (targetObj_), Tcl_NewStringObj(#fld_, -1)); \
Tcl_ListObjAppendElement( \
interp, (targetObj_), Tcl_NewWideIntObj((structPtr_)->fld_)); \
} while (0)
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "object");
return TCL_ERROR;
} else {
Tcl_Obj **objs;
Tcl_Size nobjs;
ListRep listRep;
Tcl_Obj *listRepObjs[4];
/* Force list representation */
if (Tcl_ListObjGetElements(interp, objv[2], &nobjs, &objs) != TCL_OK) {
return TCL_ERROR;
}
ListObjGetRep(objv[2], &listRep);
listRepObjs[0] = Tcl_NewStringObj("store", -1);
listRepObjs[1] = Tcl_NewListObj(12, NULL);
Tcl_ListObjAppendElement(
interp, listRepObjs[1], Tcl_NewStringObj("memoryAddress", -1));
Tcl_ListObjAppendElement(
interp, listRepObjs[1], Tcl_ObjPrintf("%p", listRep.storePtr));
APPEND_FIELD(listRepObjs[1], listRep.storePtr, firstUsed);
APPEND_FIELD(listRepObjs[1], listRep.storePtr, numUsed);
APPEND_FIELD(listRepObjs[1], listRep.storePtr, numAllocated);
APPEND_FIELD(listRepObjs[1], listRep.storePtr, refCount);
APPEND_FIELD(listRepObjs[1], listRep.storePtr, flags);
if (listRep.spanPtr) {
listRepObjs[2] = Tcl_NewStringObj("span", -1);
listRepObjs[3] = Tcl_NewListObj(8, NULL);
Tcl_ListObjAppendElement(interp,
listRepObjs[3],
Tcl_NewStringObj("memoryAddress", -1));
Tcl_ListObjAppendElement(
interp, listRepObjs[3], Tcl_ObjPrintf("%p", listRep.spanPtr));
APPEND_FIELD(listRepObjs[3], listRep.spanPtr, spanStart);
APPEND_FIELD(
listRepObjs[3], listRep.spanPtr, spanLength);
APPEND_FIELD(listRepObjs[3], listRep.spanPtr, refCount);
}
resultObj = Tcl_NewListObj(listRep.spanPtr ? 4 : 2, listRepObjs);
}
#undef APPEND_FIELD
break;
case LISTREP_CONFIG:
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, "object");
return TCL_ERROR;
}
resultObj = Tcl_NewListObj(2, NULL);
Tcl_ListObjAppendElement(
NULL, resultObj, Tcl_NewStringObj("LIST_SPAN_THRESHOLD", -1));
Tcl_ListObjAppendElement(
NULL, resultObj, Tcl_NewWideIntObj(LIST_SPAN_THRESHOLD));
break;
case LISTREP_VALIDATE:
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "object");
|
| ︙ | ︙ | |||
3946 3947 3948 3949 3950 3951 3952 |
if (objc == 3) {
locale = Tcl_GetString(objv[2]);
} else {
locale = NULL;
}
locale = setlocale(lcTypes[index], locale);
if (locale) {
| | | 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 |
if (objc == 3) {
locale = Tcl_GetString(objv[2]);
} else {
locale = NULL;
}
locale = setlocale(lcTypes[index], locale);
if (locale) {
Tcl_SetStringObj(Tcl_GetObjResult(interp), locale, -1);
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
4001 4002 4003 4004 4005 4006 4007 |
TestparserObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
const char *script;
| > | | 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 |
TestparserObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
const char *script;
Tcl_Size dummy;
int length;
Tcl_Parse parse;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "script length");
return TCL_ERROR;
}
script = Tcl_GetStringFromObj(objv[1], &dummy);
|
| ︙ | ︙ | |||
4057 4058 4059 4060 4061 4062 4063 |
TestexprparserObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
const char *script;
| > | | 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 |
TestexprparserObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
const char *script;
Tcl_Size dummy;
int length;
Tcl_Parse parse;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "expr length");
return TCL_ERROR;
}
script = Tcl_GetStringFromObj(objv[1], &dummy);
|
| ︙ | ︙ | |||
4119 4120 4121 4122 4123 4124 4125 |
Tcl_Interp *interp, /* Interpreter whose result is to be set to
* the contents of a parse structure. */
Tcl_Parse *parsePtr) /* Parse structure to print out. */
{
Tcl_Obj *objPtr;
const char *typeString;
Tcl_Token *tokenPtr;
| | | | 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 |
Tcl_Interp *interp, /* Interpreter whose result is to be set to
* the contents of a parse structure. */
Tcl_Parse *parsePtr) /* Parse structure to print out. */
{
Tcl_Obj *objPtr;
const char *typeString;
Tcl_Token *tokenPtr;
Tcl_Size i;
objPtr = Tcl_GetObjResult(interp);
if (parsePtr->commentSize + 1 > 1) {
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj(parsePtr->commentStart,
parsePtr->commentSize));
} else {
Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewStringObj("-", 1));
}
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj(parsePtr->commandStart, parsePtr->commandSize));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj(parsePtr->numWords));
for (i = 0; i < parsePtr->numTokens; i++) {
tokenPtr = &parsePtr->tokenPtr[i];
switch (tokenPtr->type) {
case TCL_TOKEN_EXPAND_WORD:
typeString = "expand";
break;
case TCL_TOKEN_WORD:
typeString = "word";
|
| ︙ | ︙ | |||
4168 4169 4170 4171 4172 4173 4174 | typeString = "operator"; break; default: typeString = "??"; break; } Tcl_ListObjAppendElement(NULL, objPtr, | | | 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 |
typeString = "operator";
break;
default:
typeString = "??";
break;
}
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj(typeString, -1));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj(tokenPtr->start, tokenPtr->size));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj(tokenPtr->numComponents));
}
Tcl_ListObjAppendElement(NULL, objPtr,
parsePtr->commandStart ?
|
| ︙ | ︙ | |||
4246 4247 4248 4249 4250 4251 4252 |
TestparsevarnameObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
const char *script;
| | > | 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 |
TestparsevarnameObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
const char *script;
int length, append;
Tcl_Size dummy;
Tcl_Parse parse;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv, "script length append");
return TCL_ERROR;
}
script = Tcl_GetStringFromObj(objv[1], &dummy);
|
| ︙ | ︙ | |||
4379 4380 4381 4382 4383 4384 4385 |
static int
TestregexpObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | | 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 |
static int
TestregexpObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int i, indices, match, about;
Tcl_Size stringLength, ii;
int hasxflags, cflags, eflags;
Tcl_RegExp regExpr;
const char *string;
Tcl_Obj *objPtr;
Tcl_RegExpInfo info;
static const char *const options[] = {
"-indices", "-nocase", "-about", "-expanded",
|
| ︙ | ︙ | |||
4497 4498 4499 4500 4501 4502 4503 | const char *varName; const char *value; Tcl_Size start, end; char resinfo[TCL_INTEGER_SPACE * 2]; varName = Tcl_GetString(objv[2]); TclRegExpRangeUniChar(regExpr, TCL_INDEX_NONE, &start, &end); | | | | 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 |
const char *varName;
const char *value;
Tcl_Size start, end;
char resinfo[TCL_INTEGER_SPACE * 2];
varName = Tcl_GetString(objv[2]);
TclRegExpRangeUniChar(regExpr, TCL_INDEX_NONE, &start, &end);
snprintf(resinfo, sizeof(resinfo), "%" TCL_Z_MODIFIER "d %" TCL_Z_MODIFIER "d", start, end-1);
value = Tcl_SetVar2(interp, varName, NULL, resinfo, 0);
if (value == NULL) {
Tcl_AppendResult(interp, "couldn't set variable \"",
varName, "\"", NULL);
return TCL_ERROR;
}
} else if (cflags & TCL_REG_CANMATCH) {
const char *varName;
const char *value;
char resinfo[TCL_INTEGER_SPACE * 2];
Tcl_RegExpGetInfo(regExpr, &info);
varName = Tcl_GetString(objv[2]);
snprintf(resinfo, sizeof(resinfo), "%" TCL_Z_MODIFIER "d", info.extendStart);
value = Tcl_SetVar2(interp, varName, NULL, resinfo, 0);
if (value == NULL) {
Tcl_AppendResult(interp, "couldn't set variable \"",
varName, "\"", NULL);
return TCL_ERROR;
}
}
|
| ︙ | ︙ | |||
4818 4819 4820 4821 4822 4823 4824 | * This procedure implements the "teststaticlibrary" command. * It is used to test the procedure Tcl_StaticLibrary. * * Results: * A standard Tcl result. * * Side effects: | | | 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 | * This procedure implements the "teststaticlibrary" command. * It is used to test the procedure Tcl_StaticLibrary. * * Results: * A standard Tcl result. * * Side effects: * When the package given by argv[1] is loaded into an interpreter, * variable "x" in that interpreter is set to "loaded". * *---------------------------------------------------------------------- */ static int TeststaticlibraryCmd( |
| ︙ | ︙ | |||
5284 5285 5286 5287 5288 5289 5290 | /* *---------------------------------------------------------------------- * * GetTimesObjCmd -- * * This procedure implements the "gettimes" command. It is used for * computing the time needed for various basic operations such as reading | | | 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 | /* *---------------------------------------------------------------------- * * GetTimesObjCmd -- * * This procedure implements the "gettimes" command. It is used for * computing the time needed for various basic operations such as reading * variables, allocating memory, snprintf, converting variables, etc. * * Results: * A standard Tcl result. * * Side effects: * Allocates and frees memory, sets a variable "a" in the interpreter. * |
| ︙ | ︙ | |||
5366 5367 5368 5369 5370 5371 5372 |
Tcl_GetTime(&stop);
timePer = (stop.sec - start.sec)*1000000 + (stop.usec - start.usec);
fprintf(stderr, " %.3f usec per Tcl_DecrRefCount\n", timePer/5000);
Tcl_Free(objv);
/* TclGetString 100000 times */
fprintf(stderr, "Tcl_GetStringFromObj of \"12345\" 100000 times\n");
| | | 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 |
Tcl_GetTime(&stop);
timePer = (stop.sec - start.sec)*1000000 + (stop.usec - start.usec);
fprintf(stderr, " %.3f usec per Tcl_DecrRefCount\n", timePer/5000);
Tcl_Free(objv);
/* TclGetString 100000 times */
fprintf(stderr, "Tcl_GetStringFromObj of \"12345\" 100000 times\n");
objPtr = Tcl_NewStringObj("12345", -1);
Tcl_GetTime(&start);
for (i = 0; i < 100000; i++) {
(void) TclGetString(objPtr);
}
Tcl_GetTime(&stop);
timePer = (stop.sec - start.sec)*1000000 + (stop.usec - start.usec);
fprintf(stderr, " %.3f usec per Tcl_GetStringFromObj of \"12345\"\n",
|
| ︙ | ︙ | |||
5403 5404 5405 5406 5407 5408 5409 |
}
}
Tcl_GetTime(&stop);
timePer = (stop.sec - start.sec)*1000000 + (stop.usec - start.usec);
fprintf(stderr, " %.3f usec per Tcl_GetInt of \"12345\"\n",
timePer/100000);
| | | | | | 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 |
}
}
Tcl_GetTime(&stop);
timePer = (stop.sec - start.sec)*1000000 + (stop.usec - start.usec);
fprintf(stderr, " %.3f usec per Tcl_GetInt of \"12345\"\n",
timePer/100000);
/* snprintf 100000 times */
fprintf(stderr, "snprintf of 12345 100000 times\n");
Tcl_GetTime(&start);
for (i = 0; i < 100000; i++) {
snprintf(newString, sizeof(newString), "%d", 12345);
}
Tcl_GetTime(&stop);
timePer = (stop.sec - start.sec)*1000000 + (stop.usec - start.usec);
fprintf(stderr, " %.3f usec per snprintf of 12345\n",
timePer/100000);
/* hashtable lookup 100000 times */
fprintf(stderr, "hashtable lookup of \"gettimes\" 100000 times\n");
Tcl_GetTime(&start);
for (i = 0; i < 100000; i++) {
(void) Tcl_FindHashEntry(&iPtr->globalNsPtr->cmdTable, "gettimes");
|
| ︙ | ︙ | |||
5533 5534 5535 5536 5537 5538 5539 |
static int
TeststringbytesObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
| | | 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 |
static int
TeststringbytesObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
Tcl_Size n;
const unsigned char *p;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "value");
return TCL_ERROR;
}
p = (const unsigned char *)Tcl_GetStringFromObj(objv[1], &n);
|
| ︙ | ︙ | |||
5669 5670 5671 5672 5673 5674 5675 |
static int
TestbytestringObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
| | | 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 |
static int
TestbytestringObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
Tcl_Size n = 0;
const char *p;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "bytearray");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
5918 5919 5920 5921 5922 5923 5924 |
Tcl_HashSearch hSearch; /* Search variable. */
Tcl_HashEntry *hPtr; /* Search variable. */
Channel *chanPtr; /* The actual channel. */
ChannelState *statePtr; /* state info for channel */
Tcl_Channel chan; /* The opaque type. */
size_t len; /* Length of subcommand string. */
int IOQueued; /* How much IO is queued inside channel? */
| | | 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 |
Tcl_HashSearch hSearch; /* Search variable. */
Tcl_HashEntry *hPtr; /* Search variable. */
Channel *chanPtr; /* The actual channel. */
ChannelState *statePtr; /* state info for channel */
Tcl_Channel chan; /* The opaque type. */
size_t len; /* Length of subcommand string. */
int IOQueued; /* How much IO is queued inside channel? */
char buf[TCL_INTEGER_SPACE];/* For snprintf. */
int mode; /* rw mode of the channel */
if (argc < 2) {
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" subcommand ?additional args..?\"", NULL);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
5969 5970 5971 5972 5973 5974 5975 |
} else {
statePtr = NULL;
chan = NULL;
}
if ((cmdName[0] == 's') && (strncmp(cmdName, "setchannelerror", len) == 0)) {
| | | | 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 |
} else {
statePtr = NULL;
chan = NULL;
}
if ((cmdName[0] == 's') && (strncmp(cmdName, "setchannelerror", len) == 0)) {
Tcl_Obj *msg = Tcl_NewStringObj(argv[3], -1);
Tcl_IncrRefCount(msg);
Tcl_SetChannelError(chan, msg);
Tcl_DecrRefCount(msg);
Tcl_GetChannelError(chan, &msg);
Tcl_SetObjResult(interp, msg);
Tcl_DecrRefCount(msg);
return TCL_OK;
}
if ((cmdName[0] == 's') && (strncmp(cmdName, "setchannelerrorinterp", len) == 0)) {
Tcl_Obj *msg = Tcl_NewStringObj(argv[3], -1);
Tcl_IncrRefCount(msg);
Tcl_SetChannelErrorInterp(interp, msg);
Tcl_DecrRefCount(msg);
Tcl_GetChannelErrorInterp(interp, &msg);
Tcl_SetObjResult(interp, msg);
|
| ︙ | ︙ | |||
6369 6370 6371 6372 6373 6374 6375 |
if (strcmp(argv[3], "-command") != 0) {
Tcl_AppendResult(interp, "bad argument \"", argv[3],
"\": should be \"-command\"", NULL);
return TCL_ERROR;
}
return TclChannelTransform(interp, chan,
| | | 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 |
if (strcmp(argv[3], "-command") != 0) {
Tcl_AppendResult(interp, "bad argument \"", argv[3],
"\": should be \"-command\"", NULL);
return TCL_ERROR;
}
return TclChannelTransform(interp, chan,
Tcl_NewStringObj(argv[4], -1));
}
if ((cmdName[0] == 'u') && (strncmp(cmdName, "unstack", len) == 0)) {
/*
* Syntax: unstack channel
*/
|
| ︙ | ︙ | |||
6460 6461 6462 6463 6464 6465 6466 | esPtr = (EventScriptRecord *)Tcl_Alloc(sizeof(EventScriptRecord)); esPtr->nextPtr = statePtr->scriptRecordPtr; statePtr->scriptRecordPtr = esPtr; esPtr->chanPtr = chanPtr; esPtr->interp = interp; esPtr->mask = mask; | | | 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 |
esPtr = (EventScriptRecord *)Tcl_Alloc(sizeof(EventScriptRecord));
esPtr->nextPtr = statePtr->scriptRecordPtr;
statePtr->scriptRecordPtr = esPtr;
esPtr->chanPtr = chanPtr;
esPtr->interp = interp;
esPtr->mask = mask;
esPtr->scriptPtr = Tcl_NewStringObj(argv[4], -1);
Tcl_IncrRefCount(esPtr->scriptPtr);
Tcl_CreateChannelHandler((Tcl_Channel) chanPtr, mask,
TclChannelEventScriptInvoker, esPtr);
return TCL_OK;
}
|
| ︙ | ︙ | |||
6527 6528 6529 6530 6531 6532 6533 |
}
resultListPtr = Tcl_GetObjResult(interp);
for (esPtr = statePtr->scriptRecordPtr;
esPtr != NULL;
esPtr = esPtr->nextPtr) {
if (esPtr->mask) {
Tcl_ListObjAppendElement(interp, resultListPtr, Tcl_NewStringObj(
| | | | 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 |
}
resultListPtr = Tcl_GetObjResult(interp);
for (esPtr = statePtr->scriptRecordPtr;
esPtr != NULL;
esPtr = esPtr->nextPtr) {
if (esPtr->mask) {
Tcl_ListObjAppendElement(interp, resultListPtr, Tcl_NewStringObj(
(esPtr->mask == TCL_READABLE) ? "readable" : "writable", -1));
} else {
Tcl_ListObjAppendElement(interp, resultListPtr,
Tcl_NewStringObj("none", -1));
}
Tcl_ListObjAppendElement(interp, resultListPtr, esPtr->scriptPtr);
}
Tcl_SetObjResult(interp, resultListPtr);
return TCL_OK;
}
|
| ︙ | ︙ | |||
6832 6833 6834 6835 6836 6837 6838 |
return TCL_ERROR;
}
if (idx[0] != 85 || idx[2] != 85) {
Tcl_AppendResult(interp, "Tcl_GetIndexFromObjStruct overwrites bytes near index variable", NULL);
return TCL_ERROR;
} else if (idx[1] != target) {
char buffer[64];
| | | | 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 |
return TCL_ERROR;
}
if (idx[0] != 85 || idx[2] != 85) {
Tcl_AppendResult(interp, "Tcl_GetIndexFromObjStruct overwrites bytes near index variable", NULL);
return TCL_ERROR;
} else if (idx[1] != target) {
char buffer[64];
snprintf(buffer, sizeof(buffer), "%d", idx[1]);
Tcl_AppendResult(interp, "index value comparison failed: got ",
buffer, NULL);
snprintf(buffer, sizeof(buffer), "%d", target);
Tcl_AppendResult(interp, " when ", buffer, " expected", NULL);
return TCL_ERROR;
}
Tcl_WrongNumArgs(interp, objc, objv, NULL);
return TCL_OK;
}
|
| ︙ | ︙ | |||
6885 6886 6887 6888 6889 6890 6891 |
if (boolVal) {
res = Tcl_FSRegister(interp, &testReportingFilesystem);
msg = (res == TCL_OK) ? "registered" : "failed";
} else {
res = Tcl_FSUnregister(&testReportingFilesystem);
msg = (res == TCL_OK) ? "unregistered" : "failed";
}
| | | 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 |
if (boolVal) {
res = Tcl_FSRegister(interp, &testReportingFilesystem);
msg = (res == TCL_OK) ? "registered" : "failed";
} else {
res = Tcl_FSUnregister(&testReportingFilesystem);
msg = (res == TCL_OK) ? "unregistered" : "failed";
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(msg , -1));
return res;
}
static int
TestReportInFilesystem(
Tcl_Obj *pathPtr,
void **clientDataPtr)
|
| ︙ | ︙ | |||
6967 6968 6969 6970 6971 6972 6973 |
if (interp == NULL) {
/* This is bad, but not much we can do about it */
} else {
Tcl_Obj *savedResult;
Tcl_DString ds;
Tcl_DStringInit(&ds);
| | | 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 |
if (interp == NULL) {
/* This is bad, but not much we can do about it */
} else {
Tcl_Obj *savedResult;
Tcl_DString ds;
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, "lappend filesystemReport ", -1);
Tcl_DStringStartSublist(&ds);
Tcl_DStringAppendElement(&ds, cmd);
if (path != NULL) {
Tcl_DStringAppendElement(&ds, Tcl_GetString(path));
}
if (arg2 != NULL) {
Tcl_DStringAppendElement(&ds, Tcl_GetString(arg2));
|
| ︙ | ︙ | |||
7256 7257 7258 7259 7260 7261 7262 |
if (boolVal) {
res = Tcl_FSRegister(interp, &simpleFilesystem);
msg = (res == TCL_OK) ? "registered" : "failed";
} else {
res = Tcl_FSUnregister(&simpleFilesystem);
msg = (res == TCL_OK) ? "unregistered" : "failed";
}
| | | | | 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 |
if (boolVal) {
res = Tcl_FSRegister(interp, &simpleFilesystem);
msg = (res == TCL_OK) ? "registered" : "failed";
} else {
res = Tcl_FSUnregister(&simpleFilesystem);
msg = (res == TCL_OK) ? "unregistered" : "failed";
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(msg , -1));
return res;
}
/*
* Treats a file name 'simplefs:/foo' by using the file 'foo' in the current
* (native) directory.
*/
static Tcl_Obj *
SimpleRedirect(
Tcl_Obj *pathPtr) /* Name of file to copy. */
{
Tcl_Size len;
const char *str;
Tcl_Obj *origPtr;
/*
* We assume the same name in the current directory is ok.
*/
str = Tcl_GetStringFromObj(pathPtr, &len);
if (len < 10 || strncmp(str, "simplefs:/", 10)) {
/* Probably shouldn't ever reach here */
Tcl_IncrRefCount(pathPtr);
return pathPtr;
}
origPtr = Tcl_NewStringObj(str+10, -1);
Tcl_IncrRefCount(origPtr);
return origPtr;
}
static int
SimpleMatchInDirectory(
Tcl_Interp *interp, /* Interpreter for error
|
| ︙ | ︙ | |||
7315 7316 7317 7318 7319 7320 7321 |
* We assume the same name in the current directory is ok.
*/
resPtr = Tcl_NewObj();
Tcl_IncrRefCount(resPtr);
origPtr = SimpleRedirect(dirPtr);
res = Tcl_FSMatchInDirectory(interp, resPtr, origPtr, pattern, types);
if (res == TCL_OK) {
| | | 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 |
* We assume the same name in the current directory is ok.
*/
resPtr = Tcl_NewObj();
Tcl_IncrRefCount(resPtr);
origPtr = SimpleRedirect(dirPtr);
res = Tcl_FSMatchInDirectory(interp, resPtr, origPtr, pattern, types);
if (res == TCL_OK) {
Tcl_Size gLength, j;
Tcl_ListObjLength(NULL, resPtr, &gLength);
for (j = 0; j < gLength; j++) {
Tcl_Obj *gElt, *nElt;
Tcl_ListObjIndex(NULL, resPtr, j, &gElt);
nElt = Tcl_NewStringObj("simplefs:/",10);
Tcl_AppendObjToObj(nElt, gElt);
Tcl_ListObjAppendElement(NULL, resultPtr, nElt);
|
| ︙ | ︙ | |||
7383 7384 7385 7386 7387 7388 7389 |
static Tcl_Obj *
SimpleListVolumes(void)
{
/* Add one new volume */
Tcl_Obj *retVal;
| | | | | 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 |
static Tcl_Obj *
SimpleListVolumes(void)
{
/* Add one new volume */
Tcl_Obj *retVal;
retVal = Tcl_NewStringObj("simplefs:/", -1);
Tcl_IncrRefCount(retVal);
return retVal;
}
/*
* Used to check operations of Tcl_UtfNext.
*
* Usage: testutfnext -bytestring $bytes
*/
static int
TestUtfNextCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
Tcl_Size numBytes;
char *bytes;
const char *result, *first;
char buffer[32];
static const char tobetested[] = "A\xA0\xC0\xC1\xC2\xD0\xE0\xE8\xF2\xF7\xF8\xFE\xFF";
const char *p = tobetested;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?-bytestring? bytes");
return TCL_ERROR;
}
bytes = Tcl_GetStringFromObj(objv[1], &numBytes);
if (numBytes + 4 > (Tcl_Size) sizeof(buffer)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"\"testutfnext\" can only handle %" TCL_Z_MODIFIER "u bytes",
sizeof(buffer) - 4));
return TCL_ERROR;
}
memcpy(buffer + 1, bytes, numBytes);
|
| ︙ | ︙ | |||
7537 7538 7539 7540 7541 7542 7543 |
{
if (objc > 1) {
int len = -1;
if (objc > 2) {
(void) Tcl_GetIntFromObj(interp, objv[2], &len);
}
| | | 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 |
{
if (objc > 1) {
int len = -1;
if (objc > 2) {
(void) Tcl_GetIntFromObj(interp, objv[2], &len);
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(Tcl_UtfFindFirst(Tcl_GetString(objv[1]), len), -1));
}
return TCL_OK;
}
/*
* Used to check correct operation of Tcl_UtfFindLast
*/
|
| ︙ | ︙ | |||
7559 7560 7561 7562 7563 7564 7565 |
{
if (objc > 1) {
int len = -1;
if (objc > 2) {
(void) Tcl_GetIntFromObj(interp, objv[2], &len);
}
| | | 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 |
{
if (objc > 1) {
int len = -1;
if (objc > 2) {
(void) Tcl_GetIntFromObj(interp, objv[2], &len);
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(Tcl_UtfFindLast(Tcl_GetString(objv[1]), len), -1));
}
return TCL_OK;
}
static int
TestGetIntForIndexCmd(
TCL_UNUSED(void *),
|
| ︙ | ︙ | |||
7637 7638 7639 7640 7641 7642 7643 |
}
if (Tcl_GetIntFromObj(interp, objv[1], &index) != TCL_OK) {
return TCL_ERROR;
}
status = TclWinCPUID(index, regs);
if (status != TCL_OK) {
Tcl_SetObjResult(interp,
| | | 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 |
}
if (Tcl_GetIntFromObj(interp, objv[1], &index) != TCL_OK) {
return TCL_ERROR;
}
status = TclWinCPUID(index, regs);
if (status != TCL_OK) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("operation not available", -1));
return status;
}
for (i=0 ; i<4 ; ++i) {
regsObjs[i] = Tcl_NewWideIntObj(regs[i]);
}
Tcl_SetObjResult(interp, Tcl_NewListObj(4, regsObjs));
return TCL_OK;
|
| ︙ | ︙ | |||
7683 7684 7685 7686 7687 7688 7689 |
return TCL_ERROR;
}
for (i=0 ; i<limit ; i++) {
hPtr = Tcl_CreateHashEntry(&hash, INT2PTR(i), &isNew);
if (!isNew) {
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(i));
| | | | | 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 |
return TCL_ERROR;
}
for (i=0 ; i<limit ; i++) {
hPtr = Tcl_CreateHashEntry(&hash, INT2PTR(i), &isNew);
if (!isNew) {
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(i));
Tcl_AppendToObj(Tcl_GetObjResult(interp)," creation problem", -1);
Tcl_DeleteHashTable(&hash);
return TCL_ERROR;
}
Tcl_SetHashValue(hPtr, INT2PTR(i+42));
}
if (hash.numEntries != (Tcl_Size)limit) {
Tcl_AppendResult(interp, "unexpected maximal size", NULL);
Tcl_DeleteHashTable(&hash);
return TCL_ERROR;
}
for (i=0 ; i<limit ; i++) {
hPtr = Tcl_FindHashEntry(&hash, (char *) INT2PTR(i));
if (hPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(i));
Tcl_AppendToObj(Tcl_GetObjResult(interp)," lookup problem", -1);
Tcl_DeleteHashTable(&hash);
return TCL_ERROR;
}
if (PTR2INT(Tcl_GetHashValue(hPtr)) != i+42) {
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(i));
Tcl_AppendToObj(Tcl_GetObjResult(interp)," value problem", -1);
Tcl_DeleteHashTable(&hash);
return TCL_ERROR;
}
Tcl_DeleteHashEntry(hPtr);
}
if (hash.numEntries != 0) {
|
| ︙ | ︙ | |||
7859 7860 7861 7862 7863 7864 7865 | /* *---------------------------------------------------------------------- * * TestconcatobjCmd -- * * This procedure implements the "testconcatobj" command. It is used * to test that Tcl_ConcatObj does indeed return a fresh Tcl_Obj in all | | | | | | | 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 |
/*
*----------------------------------------------------------------------
*
* TestconcatobjCmd --
*
* This procedure implements the "testconcatobj" command. It is used
* to test that Tcl_ConcatObj does indeed return a fresh Tcl_Obj in all
* cases and that it never corrupts its arguments. In other words, that
* [Bug 1447328] was fixed properly.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static int
TestconcatobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
TCL_UNUSED(int) /*argc*/,
TCL_UNUSED(const char **) /*argv*/)
{
Tcl_Obj *list1Ptr, *list2Ptr, *emptyPtr, *concatPtr, *tmpPtr;
int result = TCL_OK;
Tcl_Size len;
Tcl_Obj *objv[3];
/*
* Set the start of the error message as obj result; it will be cleared at
* the end if no errors were found.
*/
Tcl_SetObjResult(interp,
Tcl_NewStringObj("Tcl_ConcatObj is unsafe:", -1));
emptyPtr = Tcl_NewObj();
list1Ptr = Tcl_NewStringObj("foo bar sum", -1);
Tcl_ListObjLength(NULL, list1Ptr, &len);
Tcl_InvalidateStringRep(list1Ptr);
list2Ptr = Tcl_NewStringObj("eeny meeny", -1);
Tcl_ListObjLength(NULL, list2Ptr, &len);
Tcl_InvalidateStringRep(list2Ptr);
/*
* Verify that concat'ing a list obj with one or more empty strings does
* return a fresh Tcl_Obj (see also [Bug 2055782]).
*/
|
| ︙ | ︙ | |||
8237 8238 8239 8240 8241 8242 8243 |
TestparseargsCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Arguments. */
{
static int foo = 0;
| | | 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 |
TestparseargsCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Arguments. */
{
static int foo = 0;
Tcl_Size count = objc;
Tcl_Obj **remObjv, *result[3];
Tcl_ArgvInfo argTable[] = {
{TCL_ARGV_CONSTANT, "-bool", INT2PTR(1), &foo, "booltest", NULL},
TCL_ARGV_AUTO_REST, TCL_ARGV_AUTO_HELP, TCL_ARGV_TABLE_END
};
foo = 0;
|
| ︙ | ︙ | |||
8265 8266 8267 8268 8269 8270 8271 |
*/
static int
InterpCmdResolver(
Tcl_Interp *interp,
const char *name,
TCL_UNUSED(Tcl_Namespace *),
| | | 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 |
*/
static int
InterpCmdResolver(
Tcl_Interp *interp,
const char *name,
TCL_UNUSED(Tcl_Namespace *),
TCL_UNUSED(int) /* flags */,
Tcl_Command *rPtr)
{
Interp *iPtr = (Interp *) interp;
CallFrame *varFramePtr = iPtr->varFramePtr;
Proc *procPtr = (varFramePtr->isProcCallFrame & FRAME_IS_PROC) ?
varFramePtr->procPtr : NULL;
Namespace *callerNsPtr = varFramePtr->nsPtr;
|
| ︙ | ︙ | |||
8450 8451 8452 8453 8454 8455 8456 |
return var;
}
static int
InterpCompiledVarResolver(
TCL_UNUSED(Tcl_Interp *),
const char *name,
| | | | 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 |
return var;
}
static int
InterpCompiledVarResolver(
TCL_UNUSED(Tcl_Interp *),
const char *name,
TCL_UNUSED(Tcl_Size) /* length */,
TCL_UNUSED(Tcl_Namespace *),
Tcl_ResolvedVarInfo **rPtr)
{
if (*name == 'T') {
MyResolvedVarInfo *resVarInfo = (MyResolvedVarInfo *)Tcl_Alloc(sizeof(MyResolvedVarInfo));
resVarInfo->vInfo.fetchProc = MyCompiledVarFetch;
resVarInfo->vInfo.deleteProc = MyCompiledVarFree;
resVarInfo->var = NULL;
resVarInfo->nameObj = Tcl_NewStringObj(name, -1);
Tcl_IncrRefCount(resVarInfo->nameObj);
*rPtr = &resVarInfo->vInfo;
return TCL_OK;
}
return TCL_CONTINUE;
}
|
| ︙ | ︙ | |||
8544 8545 8546 8547 8548 8549 8550 |
Tcl_Obj *lambdaObjs[2];
Tcl_Obj *evalObjs[2];
Tcl_Obj *lambdaObj;
int result;
/* Create a lambda {{} {set a 42}} */
lambdaObjs[0] = Tcl_NewObj(); /* No parameters */
| | | | 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 |
Tcl_Obj *lambdaObjs[2];
Tcl_Obj *evalObjs[2];
Tcl_Obj *lambdaObj;
int result;
/* Create a lambda {{} {set a 42}} */
lambdaObjs[0] = Tcl_NewObj(); /* No parameters */
lambdaObjs[1] = Tcl_NewStringObj("set a 42", -1); /* Body */
lambdaObj = Tcl_NewListObj(2, lambdaObjs);
Tcl_IncrRefCount(lambdaObj);
/* Create the command "apply {{} {set a 42}" */
evalObjs[0] = Tcl_NewStringObj("apply", -1);
Tcl_IncrRefCount(evalObjs[0]);
/*
* NOTE: IMPORTANT TO EXHIBIT THE BUG. We duplicate the lambda because
* it will get shimmered to a Lambda internal representation but we
* want to hold on to our list representation.
*/
evalObjs[1] = Tcl_DuplicateObj(lambdaObj);
|
| ︙ | ︙ | |||
8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 |
no need for IncrRef */
result = Tcl_EvalObjv(interp, 2, evalObjs, TCL_EVAL_GLOBAL);
Tcl_DecrRefCount(evalObjs[0]);
Tcl_DecrRefCount(lambdaObj);
return result;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 |
no need for IncrRef */
result = Tcl_EvalObjv(interp, 2, evalObjs, TCL_EVAL_GLOBAL);
Tcl_DecrRefCount(evalObjs[0]);
Tcl_DecrRefCount(lambdaObj);
return result;
}
/*
*----------------------------------------------------------------------
*
* TestLutilCmd --
*
* This procedure implements the "testlequal" command. It is used to
* test compare two lists for equality using the string representation
* of each element. Implemented in C because script level loops are
* too slow for comparing large (GB count) lists.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static int
TestLutilCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Arguments. */
{
Tcl_Size nL1, nL2;
Tcl_Obj *l1Obj = NULL;
Tcl_Obj *l2Obj = NULL;
Tcl_Obj **l1Elems;
Tcl_Obj **l2Elems;
static const char *const subcmds[] = {
"equal", "diffindex", NULL
};
enum options {
LUTIL_EQUAL, LUTIL_DIFFINDEX
} idx;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv, "list1 list2");
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[1], subcmds, "option", 0,
&idx) != TCL_OK) {
return TCL_ERROR;
}
/* Protect against shimmering, just to be safe */
l1Obj = Tcl_DuplicateObj(objv[2]);
l2Obj = Tcl_DuplicateObj(objv[3]);
int ret = TCL_ERROR;
if (Tcl_ListObjGetElements(interp, l1Obj, &nL1, &l1Elems) != TCL_OK) {
goto vamoose;
}
if (Tcl_ListObjGetElements(interp, l2Obj, &nL2, &l2Elems) != TCL_OK) {
goto vamoose;
}
Tcl_Size i, nCmp;
ret = TCL_OK;
switch (idx) {
case LUTIL_EQUAL:
/* Avoid the loop below if lengths differ */
if (nL1 != nL2) {
Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
break;
}
/* FALLTHRU */
case LUTIL_DIFFINDEX:
nCmp = nL1 <= nL2 ? nL1 : nL2;
for (i = 0; i < nCmp; ++i) {
if (strcmp(Tcl_GetString(l1Elems[i]), Tcl_GetString(l2Elems[i]))) {
break;
}
}
if (i == nCmp && nCmp == nL1 && nCmp == nL2) {
nCmp = idx == LUTIL_EQUAL ? 1 : -1;
} else {
nCmp = idx == LUTIL_EQUAL ? 0 : i;
}
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nCmp));
break;
}
vamoose:
if (l1Obj) {
Tcl_DecrRefCount(l1Obj);
}
if (l2Obj) {
Tcl_DecrRefCount(l2Obj);
}
return ret;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/
|
Changes to generic/tclTestObj.c.
| ︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 | #ifdef TCL_WITH_EXTERNAL_TOMMATH # include "tommath.h" #else # include "tclTomMath.h" #endif #include "tclStringRep.h" /* * Forward declarations for functions defined later in this file: */ | > | | | > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
#ifdef TCL_WITH_EXTERNAL_TOMMATH
# include "tommath.h"
#else
# include "tclTomMath.h"
#endif
#include "tclStringRep.h"
#include <assert.h>
/*
* Forward declarations for functions defined later in this file:
*/
static int CheckIfVarUnset(Tcl_Interp *interp, Tcl_Obj **varPtr, Tcl_Size varIndex);
static int GetVariableIndex(Tcl_Interp *interp,
Tcl_Obj *obj, Tcl_Size *indexPtr);
static void SetVarToObj(Tcl_Obj **varPtr, Tcl_Size varIndex, Tcl_Obj *objPtr);
static Tcl_ObjCmdProc TestbignumobjCmd;
static Tcl_ObjCmdProc TestbooleanobjCmd;
static Tcl_ObjCmdProc TestdoubleobjCmd;
static Tcl_ObjCmdProc TestindexobjCmd;
static Tcl_ObjCmdProc TestintobjCmd;
static Tcl_ObjCmdProc TestlistobjCmd;
static Tcl_ObjCmdProc TestobjCmd;
static Tcl_ObjCmdProc TeststringobjCmd;
static Tcl_ObjCmdProc TestbigdataCmd;
#define VARPTR_KEY "TCLOBJTEST_VARPTR"
#define NUMBER_OF_OBJECT_VARS 20
static void VarPtrDeleteProc(void *clientData, TCL_UNUSED(Tcl_Interp *))
{
int i;
|
| ︙ | ︙ | |||
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
Tcl_CreateObjCommand(interp, "testindexobj", TestindexobjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testlistobj", TestlistobjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testobj", TestobjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "teststringobj", TeststringobjCmd,
NULL, NULL);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* TestbignumobjCmd --
| > > | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
Tcl_CreateObjCommand(interp, "testindexobj", TestindexobjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testlistobj", TestlistobjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testobj", TestobjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "teststringobj", TeststringobjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testbigdata", TestbigdataCmd,
NULL, NULL);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* TestbignumobjCmd --
|
| ︙ | ︙ | |||
149 150 151 152 153 154 155 |
"set", "get", "mult10", "div10", "iseven", "radixsize", NULL
};
enum options {
BIGNUM_SET, BIGNUM_GET, BIGNUM_MULT10, BIGNUM_DIV10, BIGNUM_ISEVEN,
BIGNUM_RADIXSIZE
} idx;
int index;
| | | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
"set", "get", "mult10", "div10", "iseven", "radixsize", NULL
};
enum options {
BIGNUM_SET, BIGNUM_GET, BIGNUM_MULT10, BIGNUM_DIV10, BIGNUM_ISEVEN,
BIGNUM_RADIXSIZE
} idx;
int index;
Tcl_Size varIndex;
const char *string;
mp_int bignumValue;
Tcl_Obj **varPtr;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
return TCL_ERROR;
|
| ︙ | ︙ | |||
176 177 178 179 180 181 182 |
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "var value");
return TCL_ERROR;
}
string = Tcl_GetString(objv[3]);
if (mp_init(&bignumValue) != MP_OKAY) {
Tcl_SetObjResult(interp,
| | | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "var value");
return TCL_ERROR;
}
string = Tcl_GetString(objv[3]);
if (mp_init(&bignumValue) != MP_OKAY) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("error in mp_init", -1));
return TCL_ERROR;
}
if (mp_read_radix(&bignumValue, string, 10) != MP_OKAY) {
mp_clear(&bignumValue);
Tcl_SetObjResult(interp,
Tcl_NewStringObj("error in mp_read_radix", -1));
return TCL_ERROR;
}
/*
* If the object currently bound to the variable with index varIndex
* has ref count 1 (i.e. the object is unshared) we can modify that
* object directly. Otherwise, if RC>1 (i.e. the object is shared),
|
| ︙ | ︙ | |||
226 227 228 229 230 231 232 |
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_mul_d(&bignumValue, 10, &bignumValue) != MP_OKAY) {
mp_clear(&bignumValue);
Tcl_SetObjResult(interp,
| | | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_mul_d(&bignumValue, 10, &bignumValue) != MP_OKAY) {
mp_clear(&bignumValue);
Tcl_SetObjResult(interp,
Tcl_NewStringObj("error in mp_mul_d", -1));
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
Tcl_SetBignumObj(varPtr[varIndex], &bignumValue);
} else {
SetVarToObj(varPtr, varIndex, Tcl_NewBignumObj(&bignumValue));
}
|
| ︙ | ︙ | |||
251 252 253 254 255 256 257 |
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_div_d(&bignumValue, 10, &bignumValue, NULL) != MP_OKAY) {
mp_clear(&bignumValue);
Tcl_SetObjResult(interp,
| | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_div_d(&bignumValue, 10, &bignumValue, NULL) != MP_OKAY) {
mp_clear(&bignumValue);
Tcl_SetObjResult(interp,
Tcl_NewStringObj("error in mp_div_d", -1));
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
Tcl_SetBignumObj(varPtr[varIndex], &bignumValue);
} else {
SetVarToObj(varPtr, varIndex, Tcl_NewBignumObj(&bignumValue));
}
|
| ︙ | ︙ | |||
276 277 278 279 280 281 282 |
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_mod_2d(&bignumValue, 1, &bignumValue) != MP_OKAY) {
mp_clear(&bignumValue);
Tcl_SetObjResult(interp,
| | | 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_mod_2d(&bignumValue, 1, &bignumValue) != MP_OKAY) {
mp_clear(&bignumValue);
Tcl_SetObjResult(interp,
Tcl_NewStringObj("error in mp_mod_2d", -1));
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
Tcl_SetBooleanObj(varPtr[varIndex], mp_iszero(&bignumValue));
} else {
SetVarToObj(varPtr, varIndex, Tcl_NewBooleanObj(mp_iszero(&bignumValue)));
}
|
| ︙ | ︙ | |||
340 341 342 343 344 345 346 |
static int
TestbooleanobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
static int
TestbooleanobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size varIndex;
int boolValue;
const char *subCmd;
Tcl_Obj **varPtr;
if (objc < 3) {
wrongNumArgs:
Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?");
|
| ︙ | ︙ | |||
440 441 442 443 444 445 446 |
static int
TestdoubleobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
static int
TestdoubleobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size varIndex;
double doubleValue;
const char *subCmd;
Tcl_Obj **varPtr;
if (objc < 3) {
wrongNumArgs:
Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?");
|
| ︙ | ︙ | |||
557 558 559 560 561 562 563 |
TestindexobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int allowAbbrev, index, setError, i, result;
| | | | | | | | 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
TestindexobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int allowAbbrev, index, setError, i, result;
Tcl_Size index2;
const char **argv;
static const char *const tablePtr[] = {"a", "b", "check", NULL};
/*
* Keep this structure declaration in sync with tclIndexObj.c
*/
struct IndexRep {
void *tablePtr; /* Pointer to the table of strings. */
Tcl_Size offset; /* Offset between table entries. */
Tcl_Size index; /* Selected index into table. */
} *indexRep;
if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]),
"check") == 0)) {
/*
* This code checks to be sure that the results of Tcl_GetIndexFromObj
* are properly cached in the object and returned on subsequent
* lookups.
*/
if (Tcl_GetIntForIndex(interp, objv[2], TCL_INDEX_NONE, &index2) != TCL_OK) {
return TCL_ERROR;
}
Tcl_GetIndexFromObj(NULL, objv[1], tablePtr, "token", 0, &index);
indexRep = (struct IndexRep *)objv[1]->internalRep.twoPtrValue.ptr1;
indexRep->index = index2;
result = Tcl_GetIndexFromObj(NULL, objv[1],
tablePtr, "token", 0, &index);
if (result == TCL_OK) {
Tcl_SetWideIntObj(Tcl_GetObjResult(interp), (Tcl_WideInt)((Tcl_WideUInt)(index + 1U)) - 1);
}
return result;
}
if (objc < 5) {
Tcl_AppendToObj(Tcl_GetObjResult(interp), "wrong # args", -1);
return TCL_ERROR;
}
if (Tcl_GetBooleanFromObj(interp, objv[1], &setError) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_GetBooleanFromObj(interp, objv[2], &allowAbbrev) != TCL_OK) {
|
| ︙ | ︙ | |||
616 617 618 619 620 621 622 |
argv[objc-4] = NULL;
result = Tcl_GetIndexFromObj((setError? interp : NULL), objv[3],
argv, "token", TCL_INDEX_TEMP_TABLE|(allowAbbrev? 0 : TCL_EXACT),
&index);
Tcl_Free((void *)argv);
if (result == TCL_OK) {
| | | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
argv[objc-4] = NULL;
result = Tcl_GetIndexFromObj((setError? interp : NULL), objv[3],
argv, "token", TCL_INDEX_TEMP_TABLE|(allowAbbrev? 0 : TCL_EXACT),
&index);
Tcl_Free((void *)argv);
if (result == TCL_OK) {
Tcl_SetWideIntObj(Tcl_GetObjResult(interp), (Tcl_WideInt)((Tcl_WideUInt)(index + 1U)) - 1);
}
return result;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
646 647 648 649 650 651 652 |
static int
TestintobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
static int
TestintobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size varIndex;
#if (INT_MAX != LONG_MAX) /* int is not the same size as long */
int i;
#endif
Tcl_WideInt wideValue;
const char *subCmd;
Tcl_Obj **varPtr;
|
| ︙ | ︙ | |||
734 735 736 737 738 739 740 |
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
if (Tcl_GetWideIntFromObj(interp, varPtr[varIndex], &wideValue) != TCL_OK) {
return TCL_ERROR;
}
Tcl_AppendToObj(Tcl_GetObjResult(interp),
| | | | | | | 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 |
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
if (Tcl_GetWideIntFromObj(interp, varPtr[varIndex], &wideValue) != TCL_OK) {
return TCL_ERROR;
}
Tcl_AppendToObj(Tcl_GetObjResult(interp),
((wideValue == WIDE_MAX)? "1" : "0"), -1);
} else if (strcmp(subCmd, "get") == 0) {
if (objc != 3) {
goto wrongNumArgs;
}
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
Tcl_SetObjResult(interp, varPtr[varIndex]);
} else if (strcmp(subCmd, "get2") == 0) {
if (objc != 3) {
goto wrongNumArgs;
}
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
Tcl_AppendToObj(Tcl_GetObjResult(interp), Tcl_GetString(varPtr[varIndex]), -1);
} else if (strcmp(subCmd, "inttoobigtest") == 0) {
/*
* If long ints have more bits than ints on this platform, verify that
* Tcl_GetIntFromObj returns an error if the long int held in an
* integer object's internal representation is too large to fit in an
* int.
*/
if (objc != 3) {
goto wrongNumArgs;
}
#if (INT_MAX == LONG_MAX) /* int is same size as long int */
Tcl_AppendToObj(Tcl_GetObjResult(interp), "1", -1);
#else
if ((varPtr[varIndex] != NULL) && !Tcl_IsShared(varPtr[varIndex])) {
Tcl_SetWideIntObj(varPtr[varIndex], LONG_MAX);
} else {
SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(LONG_MAX));
}
if (Tcl_GetIntFromObj(interp, varPtr[varIndex], &i) != TCL_OK) {
Tcl_ResetResult(interp);
Tcl_AppendToObj(Tcl_GetObjResult(interp), "1", -1);
return TCL_OK;
}
Tcl_AppendToObj(Tcl_GetObjResult(interp), "0", -1);
#endif
} else if (strcmp(subCmd, "mult10") == 0) {
if (objc != 3) {
goto wrongNumArgs;
}
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
891 892 893 894 895 896 897 |
LISTOBJ_SET,
LISTOBJ_GET,
LISTOBJ_REPLACE,
LISTOBJ_INDEXMEMCHECK,
LISTOBJ_GETELEMENTSMEMCHECK,
} cmdIndex;
| | | | | | | 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 |
LISTOBJ_SET,
LISTOBJ_GET,
LISTOBJ_REPLACE,
LISTOBJ_INDEXMEMCHECK,
LISTOBJ_GETELEMENTSMEMCHECK,
} cmdIndex;
Tcl_Size varIndex; /* Variable number converted to binary */
Tcl_Size first; /* First index in the list */
Tcl_Size count; /* Count of elements in a list */
Tcl_Obj **varPtr;
Tcl_Size i, len;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg...?");
return TCL_ERROR;
}
varPtr = GetVarPtr(interp);
if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[1], subcommands, "command",
0, &cmdIndex) != TCL_OK) {
return TCL_ERROR;
}
switch(cmdIndex) {
case LISTOBJ_SET:
if ((varPtr[varIndex] != NULL) && !Tcl_IsShared(varPtr[varIndex])) {
Tcl_SetListObj(varPtr[varIndex], objc-3, objv+3);
} else {
SetVarToObj(varPtr, varIndex, Tcl_NewListObj(objc-3, objv+3));
}
Tcl_SetObjResult(interp, varPtr[varIndex]);
|
| ︙ | ︙ | |||
936 937 938 939 940 941 942 |
case LISTOBJ_REPLACE:
if (objc < 5) {
Tcl_WrongNumArgs(interp, 2, objv,
"varIndex start count ?element...?");
return TCL_ERROR;
}
| | | | 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 |
case LISTOBJ_REPLACE:
if (objc < 5) {
Tcl_WrongNumArgs(interp, 2, objv,
"varIndex start count ?element...?");
return TCL_ERROR;
}
if (Tcl_GetIntForIndex(interp, objv[3], TCL_INDEX_NONE, &first) != TCL_OK
|| Tcl_GetIntForIndex(interp, objv[4], TCL_INDEX_NONE, &count) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_IsShared(varPtr[varIndex])) {
SetVarToObj(varPtr, varIndex, Tcl_DuplicateObj(varPtr[varIndex]));
}
Tcl_ResetResult(interp);
return Tcl_ListObjReplace(interp, varPtr[varIndex], first, count,
|
| ︙ | ︙ | |||
1024 1025 1026 1027 1028 1029 1030 |
static int
TestobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 |
static int
TestobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size varIndex, destIndex;
int i;
const Tcl_ObjType *targetType;
Tcl_Obj **varPtr;
const char *subcommands[] = {
"freeallvars", "bug3598580", "types",
"objtype", "newobj", "set",
"assign", "convert", "duplicate",
|
| ︙ | ︙ | |||
1100 1101 1102 1103 1104 1105 1106 |
if (objc != 3) {
goto wrongNumArgs;
} else {
const char *typeName;
if (objv[2]->typePtr == NULL) {
| | | | 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 |
if (objc != 3) {
goto wrongNumArgs;
} else {
const char *typeName;
if (objv[2]->typePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
} else {
typeName = objv[2]->typePtr->name;
if (!strcmp(typeName, "utf32string"))
typeName = "string";
#ifndef TCL_WIDE_INT_IS_LONG
else if (!strcmp(typeName, "wideInt")) typeName = "int";
#endif
Tcl_SetObjResult(interp, Tcl_NewStringObj(typeName, -1));
}
}
return TCL_OK;
case TESTOBJ_NEWOBJ:
if (objc != 3) {
goto wrongNumArgs;
}
|
| ︙ | ︙ | |||
1195 1196 1197 1198 1199 1200 1201 |
Tcl_InvalidateStringRep(varPtr[varIndex]);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
case TESTOBJ_REFCOUNT:
if (objc != 3) {
goto wrongNumArgs;
}
| | | | | | 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 |
Tcl_InvalidateStringRep(varPtr[varIndex]);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
case TESTOBJ_REFCOUNT:
if (objc != 3) {
goto wrongNumArgs;
}
Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt)((Tcl_WideUInt)(varPtr[varIndex]->refCount + 1U)) - 1));
break;
case TESTOBJ_TYPE:
if (objc != 3) {
goto wrongNumArgs;
}
if (varPtr[varIndex]->typePtr == NULL) { /* a string! */
Tcl_AppendToObj(Tcl_GetObjResult(interp), "string", -1);
#ifndef TCL_WIDE_INT_IS_LONG
} else if (!strcmp(varPtr[varIndex]->typePtr->name, "wideInt")) {
Tcl_AppendToObj(Tcl_GetObjResult(interp),
"int", -1);
#endif
} else {
Tcl_AppendToObj(Tcl_GetObjResult(interp),
varPtr[varIndex]->typePtr->name, -1);
}
break;
default:
break;
}
return TCL_OK;
|
| ︙ | ︙ | |||
1246 1247 1248 1249 1250 1251 1252 |
TeststringobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_UniChar *unicode;
| | | | 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 |
TeststringobjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_UniChar *unicode;
Tcl_Size size, varIndex;
int option, i;
Tcl_Size length;
#define MAX_STRINGS 11
const char *string, *strings[MAX_STRINGS+1];
String *strPtr;
Tcl_Obj **varPtr;
static const char *const options[] = {
"append", "appendstrings", "get", "get2", "length", "length2",
"set", "set2", "setlength", "maxchars", "range", "appendself",
|
| ︙ | ︙ | |||
1279 1280 1281 1282 1283 1284 1285 |
return TCL_ERROR;
}
switch (option) {
case 0: /* append */
if (objc != 5) {
goto wrongNumArgs;
}
| | | 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 |
return TCL_ERROR;
}
switch (option) {
case 0: /* append */
if (objc != 5) {
goto wrongNumArgs;
}
if (Tcl_GetIntForIndex(interp, objv[4], TCL_INDEX_NONE, &length) != TCL_OK) {
return TCL_ERROR;
}
if (varPtr[varIndex] == NULL) {
SetVarToObj(varPtr, varIndex, Tcl_NewObj());
}
/*
|
| ︙ | ︙ | |||
1341 1342 1343 1344 1345 1346 1347 |
case 3: /* get2 */
if (objc != 3) {
goto wrongNumArgs;
}
if (CheckIfVarUnset(interp, varPtr, varIndex)) {
return TCL_ERROR;
}
| | | | | 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 |
case 3: /* get2 */
if (objc != 3) {
goto wrongNumArgs;
}
if (CheckIfVarUnset(interp, varPtr, varIndex)) {
return TCL_ERROR;
}
Tcl_AppendToObj(Tcl_GetObjResult(interp), Tcl_GetString(varPtr[varIndex]), -1);
break;
case 4: /* length */
if (objc != 3) {
goto wrongNumArgs;
}
Tcl_SetWideIntObj(Tcl_GetObjResult(interp), (varPtr[varIndex] != NULL)
? (Tcl_WideInt)varPtr[varIndex]->length : (Tcl_WideInt)-1);
break;
case 5: /* length2 */
if (objc != 3) {
goto wrongNumArgs;
}
if (varPtr[varIndex] != NULL) {
Tcl_ConvertToType(NULL, varPtr[varIndex],
Tcl_GetObjType("string"));
strPtr = (String *)varPtr[varIndex]->internalRep.twoPtrValue.ptr1;
length = strPtr->allocated;
} else {
length = TCL_INDEX_NONE;
}
Tcl_SetWideIntObj(Tcl_GetObjResult(interp), (Tcl_WideInt)((Tcl_WideUInt)(length + 1U)) - 1);
break;
case 6: /* set */
if (objc != 4) {
goto wrongNumArgs;
}
/*
|
| ︙ | ︙ | |||
1397 1398 1399 1400 1401 1402 1403 |
}
SetVarToObj(varPtr, varIndex, objv[3]);
break;
case 8: /* setlength */
if (objc != 4) {
goto wrongNumArgs;
}
| | | | | | | | 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 |
}
SetVarToObj(varPtr, varIndex, objv[3]);
break;
case 8: /* setlength */
if (objc != 4) {
goto wrongNumArgs;
}
if (Tcl_GetIntForIndex(interp, objv[3], TCL_INDEX_NONE, &length) != TCL_OK) {
return TCL_ERROR;
}
if (varPtr[varIndex] != NULL) {
Tcl_SetObjLength(varPtr[varIndex], length);
}
break;
case 9: /* maxchars */
if (objc != 3) {
goto wrongNumArgs;
}
if (varPtr[varIndex] != NULL) {
Tcl_ConvertToType(NULL, varPtr[varIndex],
Tcl_GetObjType("string"));
strPtr = (String *)varPtr[varIndex]->internalRep.twoPtrValue.ptr1;
length = strPtr->maxChars;
} else {
length = TCL_INDEX_NONE;
}
Tcl_SetWideIntObj(Tcl_GetObjResult(interp), (Tcl_WideInt)((Tcl_WideUInt)(length + 1U)) - 1);
break;
case 10: { /* range */
Tcl_Size first, last;
if (objc != 5) {
goto wrongNumArgs;
}
if ((Tcl_GetIntForIndex(interp, objv[3], TCL_INDEX_NONE, &first) != TCL_OK)
|| (Tcl_GetIntForIndex(interp, objv[4], TCL_INDEX_NONE, &last) != TCL_OK)) {
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_GetRange(varPtr[varIndex], first, last));
break;
}
case 11: /* appendself */
if (objc != 4) {
|
| ︙ | ︙ | |||
1449 1450 1451 1452 1453 1454 1455 |
if (Tcl_IsShared(varPtr[varIndex])) {
SetVarToObj(varPtr, varIndex, Tcl_DuplicateObj(varPtr[varIndex]));
}
string = Tcl_GetStringFromObj(varPtr[varIndex], &size);
| | | | | 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 |
if (Tcl_IsShared(varPtr[varIndex])) {
SetVarToObj(varPtr, varIndex, Tcl_DuplicateObj(varPtr[varIndex]));
}
string = Tcl_GetStringFromObj(varPtr[varIndex], &size);
if (Tcl_GetIntForIndex(interp, objv[3], size-1, &length) != TCL_OK) {
return TCL_ERROR;
}
if (length == TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"index value out of range", -1));
return TCL_ERROR;
}
Tcl_AppendToObj(varPtr[varIndex], string + length, size - length);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
case 12: /* appendself2 */
|
| ︙ | ︙ | |||
1480 1481 1482 1483 1484 1485 1486 |
if (Tcl_IsShared(varPtr[varIndex])) {
SetVarToObj(varPtr, varIndex, Tcl_DuplicateObj(varPtr[varIndex]));
}
unicode = Tcl_GetUnicodeFromObj(varPtr[varIndex], &size);
| | | | | 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 |
if (Tcl_IsShared(varPtr[varIndex])) {
SetVarToObj(varPtr, varIndex, Tcl_DuplicateObj(varPtr[varIndex]));
}
unicode = Tcl_GetUnicodeFromObj(varPtr[varIndex], &size);
if (Tcl_GetIntForIndex(interp, objv[3], size-1, &length) != TCL_OK) {
return TCL_ERROR;
}
if (length == TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"index value out of range", -1));
return TCL_ERROR;
}
Tcl_AppendUnicodeToObj(varPtr[varIndex], unicode + length, size - length);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
case 13: /* newunicode*/
|
| ︙ | ︙ | |||
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 |
Tcl_Free(unicode);
break;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* SetVarToObj --
*
* Utility routine to assign a Tcl_Obj* to a test variable. The
* Tcl_Obj* can be NULL.
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 |
Tcl_Free(unicode);
break;
}
return TCL_OK;
}
/*
*------------------------------------------------------------------------
*
* TestbigdataCmd --
*
* Implements the Tcl command testbigdata
* testbigdata string ?LEN? ?SPLIT? - returns 01234567890123...
* testbigdata bytearray ?LEN? ?SPLIT? - returns {0 1 2 3 4 5 6 7 8 9 0 1 ...}
* testbigdata dict ?SIZE? - returns dict mapping integers to themselves
* If no arguments given, returns the pattern used to generate strings.
* If SPLIT is specified, the character at that position is set to "X".
*
* Results:
* TCL_OK - Success.
* TCL_ERROR - Error.
*
* Side effects:
* Interpreter result holds result or error message.
*
*------------------------------------------------------------------------
*/
static int
TestbigdataCmd (
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const subcmds[] = {
"string", "bytearray", "list", "dict", NULL
};
enum options {
BIGDATA_STRING, BIGDATA_BYTEARRAY, BIGDATA_LIST, BIGDATA_DICT
} idx;
char *s;
unsigned char *p;
Tcl_WideInt i, len, split;
Tcl_DString ds;
Tcl_Obj *objPtr;
#define PATTERN_LEN 10
Tcl_Obj *patternObjs[PATTERN_LEN];
if (objc < 2 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "command ?len? ?split?");
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[1], subcmds, "option", 0,
&idx) != TCL_OK) {
return TCL_ERROR;
}
split = -1;
if (objc == 2) {
len = PATTERN_LEN;
} else {
if (Tcl_GetWideIntFromObj(interp, objv[2], &len) != TCL_OK) {
return TCL_ERROR;
}
if (objc == 4) {
if (Tcl_GetWideIntFromObj(interp, objv[3], &split) != TCL_OK) {
return TCL_ERROR;
}
if (split >= len) {
split = len - 1; /* Last position */
}
}
}
/* Need one byte for nul terminator */
Tcl_WideInt limit =
sizeof(Tcl_Size) == sizeof(Tcl_WideInt) ? WIDE_MAX-1 : INT_MAX-1;
if (len < 0 || len > limit) {
Tcl_SetObjResult(
interp,
Tcl_ObjPrintf(
"%s is greater than max permitted length %" TCL_LL_MODIFIER "d",
Tcl_GetString(objv[2]),
limit));
return TCL_ERROR;
}
switch (idx) {
case BIGDATA_STRING:
Tcl_DStringInit(&ds);
Tcl_DStringSetLength(&ds, len);/* Also stores \0 at index len+1 */
s = Tcl_DStringValue(&ds);
for (i = 0; i < len; ++i) {
s[i] = '0' + (i % PATTERN_LEN);
}
if (split >= 0) {
assert(split < len);
s[split] = 'X';
}
Tcl_DStringResult(interp, &ds);
break;
case BIGDATA_BYTEARRAY:
objPtr = Tcl_NewByteArrayObj(NULL, len);
p = Tcl_GetByteArrayFromObj(objPtr, &len);
for (i = 0; i < len; ++i) {
p[i] = '0' + (i % PATTERN_LEN);
}
if (split >= 0) {
assert(split < len);
p[split] = 'X';
}
Tcl_SetObjResult(interp, objPtr);
break;
case BIGDATA_LIST:
for (i = 0; i < PATTERN_LEN; ++i) {
patternObjs[i] = Tcl_NewIntObj(i);
Tcl_IncrRefCount(patternObjs[i]);
}
objPtr = Tcl_NewListObj(len, NULL);
for (i = 0; i < len; ++i) {
Tcl_ListObjAppendElement(
interp, objPtr, patternObjs[i % PATTERN_LEN]);
}
if (split >= 0) {
assert(split < len);
Tcl_Obj *splitMarker = Tcl_NewStringObj("X", 1);
Tcl_ListObjReplace(interp, objPtr, split, 1, 1, &splitMarker);
}
for (i = 0; i < PATTERN_LEN; ++i) {
patternObjs[i] = Tcl_NewIntObj(i);
Tcl_DecrRefCount(patternObjs[i]);
}
Tcl_SetObjResult(interp, objPtr);
break;
case BIGDATA_DICT:
objPtr = Tcl_NewDictObj();
for (i = 0; i < len; ++i) {
Tcl_Obj *objPtr2 = Tcl_NewWideIntObj(i);
Tcl_DictObjPut(interp, objPtr, objPtr2, objPtr2);
}
Tcl_SetObjResult(interp, objPtr);
break;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* SetVarToObj --
*
* Utility routine to assign a Tcl_Obj* to a test variable. The
* Tcl_Obj* can be NULL.
|
| ︙ | ︙ | |||
1536 1537 1538 1539 1540 1541 1542 |
*
*----------------------------------------------------------------------
*/
static void
SetVarToObj(
Tcl_Obj **varPtr,
| | | 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 |
*
*----------------------------------------------------------------------
*/
static void
SetVarToObj(
Tcl_Obj **varPtr,
Tcl_Size varIndex, /* Designates the assignment variable. */
Tcl_Obj *objPtr) /* Points to object to assign to var. */
{
if (varPtr[varIndex] != NULL) {
Tcl_DecrRefCount(varPtr[varIndex]);
}
varPtr[varIndex] = objPtr;
if (objPtr != NULL) {
|
| ︙ | ︙ | |||
1570 1571 1572 1573 1574 1575 1576 |
static int
GetVariableIndex(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tcl_Obj *obj, /* The variable index
* specified as a nonnegative number less than
* NUMBER_OF_OBJECT_VARS. */
| | | | | | | 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 |
static int
GetVariableIndex(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tcl_Obj *obj, /* The variable index
* specified as a nonnegative number less than
* NUMBER_OF_OBJECT_VARS. */
Tcl_Size *indexPtr) /* Place to store converted result. */
{
Tcl_Size index;
if (Tcl_GetIntForIndex(interp, obj, NUMBER_OF_OBJECT_VARS - 1, &index) != TCL_OK) {
return TCL_ERROR;
}
if (index == TCL_INDEX_NONE) {
Tcl_ResetResult(interp);
Tcl_AppendToObj(Tcl_GetObjResult(interp), "bad variable index", -1);
return TCL_ERROR;
}
*indexPtr = index;
return TCL_OK;
}
|
| ︙ | ︙ | |||
1609 1610 1611 1612 1613 1614 1615 |
*----------------------------------------------------------------------
*/
static int
CheckIfVarUnset(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tcl_Obj ** varPtr,
| | | | | 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 |
*----------------------------------------------------------------------
*/
static int
CheckIfVarUnset(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tcl_Obj ** varPtr,
Tcl_Size varIndex) /* Index of the test variable to check. */
{
if (varPtr[varIndex] == NULL) {
char buf[32 + TCL_INTEGER_SPACE];
snprintf(buf, sizeof(buf), "variable %" TCL_Z_MODIFIER "u is unset (NULL)", varIndex);
Tcl_ResetResult(interp);
Tcl_AppendToObj(Tcl_GetObjResult(interp), buf, -1);
return 1;
}
return 0;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
|
Changes to generic/tclTestProcBodyObj.c.
| ︙ | ︙ | |||
140 141 142 143 144 145 146 |
const char *namesp, /* the namespace in which the command is
* registered */
const CmdTable *cmdTablePtr)/* the command to register */
{
char buf[128];
if (cmdTablePtr->exportIt) {
| | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
const char *namesp, /* the namespace in which the command is
* registered */
const CmdTable *cmdTablePtr)/* the command to register */
{
char buf[128];
if (cmdTablePtr->exportIt) {
snprintf(buf, sizeof(buf), "namespace eval %s { namespace export %s }",
namesp, cmdTablePtr->cmdName);
if (Tcl_EvalEx(interp, buf, TCL_INDEX_NONE, 0) != TCL_OK) {
return TCL_ERROR;
}
}
snprintf(buf, sizeof(buf), "%s::%s", namesp, cmdTablePtr->cmdName);
Tcl_CreateObjCommand(interp, buf, cmdTablePtr->proc, 0, 0);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ |
Changes to generic/tclThread.c.
| ︙ | ︙ | |||
57 58 59 60 61 62 63 |
*
*----------------------------------------------------------------------
*/
void *
Tcl_GetThreadData(
Tcl_ThreadDataKey *keyPtr, /* Identifier for the data chunk */
| | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
*
*----------------------------------------------------------------------
*/
void *
Tcl_GetThreadData(
Tcl_ThreadDataKey *keyPtr, /* Identifier for the data chunk */
Tcl_Size size) /* Size of storage block */
{
void *result;
#if TCL_THREADS
/*
* Initialize the key for this thread.
*/
|
| ︙ | ︙ |
Changes to generic/tclThreadAlloc.c.
| ︙ | ︙ | |||
636 637 638 639 640 641 642 |
Tcl_MutexLock(listLockPtr);
cachePtr = firstCachePtr;
while (cachePtr != NULL) {
Tcl_DStringStartSublist(dsPtr);
if (cachePtr == sharedPtr) {
Tcl_DStringAppendElement(dsPtr, "shared");
} else {
| | | | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 |
Tcl_MutexLock(listLockPtr);
cachePtr = firstCachePtr;
while (cachePtr != NULL) {
Tcl_DStringStartSublist(dsPtr);
if (cachePtr == sharedPtr) {
Tcl_DStringAppendElement(dsPtr, "shared");
} else {
snprintf(buf, sizeof(buf), "thread%p", cachePtr->owner);
Tcl_DStringAppendElement(dsPtr, buf);
}
for (n = 0; n < NBUCKETS; ++n) {
snprintf(buf, sizeof(buf), "%" TCL_Z_MODIFIER "u %" TCL_Z_MODIFIER "u %" TCL_Z_MODIFIER "u %"
TCL_Z_MODIFIER "u %" TCL_Z_MODIFIER "u %" TCL_Z_MODIFIER "u",
bucketInfo[n].blockSize,
cachePtr->buckets[n].numFree,
cachePtr->buckets[n].numRemoves,
cachePtr->buckets[n].numInserts,
cachePtr->buckets[n].totalAssigned,
cachePtr->buckets[n].numLocks);
|
| ︙ | ︙ | |||
933 934 935 936 937 938 939 |
Cache *cachePtr,
int bucket)
{
Block *blockPtr;
size_t n;
/*
| | | 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 |
Cache *cachePtr,
int bucket)
{
Block *blockPtr;
size_t n;
/*
* First, attempt to move blocks from the shared cache. Note the
* potentially dirty read of numFree before acquiring the lock which is a
* slight performance enhancement. The value is verified after the lock is
* actually acquired.
*/
if (cachePtr != sharedPtr && sharedPtr->buckets[bucket].numFree > 0) {
LockBucket(cachePtr, bucket);
|
| ︙ | ︙ |
Changes to generic/tclThreadJoin.c.
| ︙ | ︙ | |||
207 208 209 210 211 212 213 | } /* *---------------------------------------------------------------------- * * TclRememberJoinableThread -- * | | | | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | } /* *---------------------------------------------------------------------- * * TclRememberJoinableThread -- * * This procedure remembers a thread as joinable. Only a call to * TclJoinThread will remove the structure created (and initialized) here. * IOW, not waiting upon a joinable thread will cause memory leaks. * * Results: * None. * * Side effects: * Allocates memory, adds it to the global list of all joinable threads. |
| ︙ | ︙ |
Changes to generic/tclThreadTest.c.
| ︙ | ︙ | |||
268 269 270 271 272 273 274 |
} else {
result = NULL;
}
return ThreadCancel(interp, (Tcl_ThreadId) INT2PTR(id), result, flags);
}
case THREAD_CREATE: {
const char *script;
| | > | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
} else {
result = NULL;
}
return ThreadCancel(interp, (Tcl_ThreadId) INT2PTR(id), result, flags);
}
case THREAD_CREATE: {
const char *script;
int joinable;
Tcl_Size len;
if (objc == 2) {
/*
* Neither joinable nor special script
*/
joinable = 0;
|
| ︙ | ︙ | |||
363 364 365 366 367 368 369 |
result = Tcl_JoinThread((Tcl_ThreadId)INT2PTR(id), &status);
if (result == TCL_OK) {
Tcl_SetIntObj(Tcl_GetObjResult(interp), status);
} else {
char buf[TCL_INTEGER_SPACE];
| | | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
result = Tcl_JoinThread((Tcl_ThreadId)INT2PTR(id), &status);
if (result == TCL_OK) {
Tcl_SetIntObj(Tcl_GetObjResult(interp), status);
} else {
char buf[TCL_INTEGER_SPACE];
snprintf(buf, sizeof(buf), "%" TCL_LL_MODIFIER "d", (long long)id);
Tcl_AppendResult(interp, "cannot join thread ", buf, NULL);
}
return result;
}
case THREAD_NAMES:
if (objc > 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
|
| ︙ | ︙ | |||
645 646 647 648 649 650 651 |
Tcl_Interp *interp) /* Interp that failed */
{
Tcl_Channel errChannel;
const char *errorInfo, *argv[3];
char *script;
char buf[TCL_DOUBLE_SPACE+1];
| | | | | | 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
Tcl_Interp *interp) /* Interp that failed */
{
Tcl_Channel errChannel;
const char *errorInfo, *argv[3];
char *script;
char buf[TCL_DOUBLE_SPACE+1];
snprintf(buf, sizeof(buf), "%p", Tcl_GetCurrentThread());
errorInfo = Tcl_GetVar2(interp, "errorInfo", NULL, TCL_GLOBAL_ONLY);
if (errorProcString == NULL) {
errChannel = Tcl_GetStdChannel(TCL_STDERR);
Tcl_WriteChars(errChannel, "Error from thread ", -1);
Tcl_WriteChars(errChannel, buf, -1);
Tcl_WriteChars(errChannel, "\n", 1);
Tcl_WriteChars(errChannel, errorInfo, -1);
Tcl_WriteChars(errChannel, "\n", 1);
} else {
argv[0] = errorProcString;
argv[1] = buf;
argv[2] = errorInfo;
script = Tcl_Merge(3, argv);
ThreadSend(interp, errorThreadId, script, 0);
|
| ︙ | ︙ | |||
818 819 820 821 822 823 824 |
if (!found) {
Tcl_MutexUnlock(&threadMutex);
Tcl_AppendResult(interp, "invalid thread id", NULL);
return TCL_ERROR;
}
/*
| | | 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
if (!found) {
Tcl_MutexUnlock(&threadMutex);
Tcl_AppendResult(interp, "invalid thread id", NULL);
return TCL_ERROR;
}
/*
* Short circuit sends to ourself. Ought to do something with -async, like
* run in an idle handler.
*/
if (threadId == Tcl_GetCurrentThread()) {
Tcl_MutexUnlock(&threadMutex);
return Tcl_EvalEx(interp, script,-1,TCL_EVAL_GLOBAL);
}
|
| ︙ | ︙ | |||
978 979 980 981 982 983 984 |
* Since Tcl_CancelEval can be safely called from any thread,
* we do it now.
*/
Tcl_MutexUnlock(&threadMutex);
Tcl_ResetResult(interp);
return Tcl_CancelEval(tsdPtr->interp,
| | | 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 |
* Since Tcl_CancelEval can be safely called from any thread,
* we do it now.
*/
Tcl_MutexUnlock(&threadMutex);
Tcl_ResetResult(interp);
return Tcl_CancelEval(tsdPtr->interp,
(result != NULL) ? Tcl_NewStringObj(result, -1) : NULL, 0, flags);
}
/*
*------------------------------------------------------------------------
*
* ThreadEventProc --
*
|
| ︙ | ︙ |
Changes to generic/tclTimer.c.
| ︙ | ︙ | |||
783 784 785 786 787 788 789 |
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_WideInt ms = 0; /* Number of milliseconds to wait */
Tcl_Time wakeup;
AfterInfo *afterPtr;
AfterAssocData *assocPtr;
| | | 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 |
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_WideInt ms = 0; /* Number of milliseconds to wait */
Tcl_Time wakeup;
AfterInfo *afterPtr;
AfterAssocData *assocPtr;
Tcl_Size length;
int index = -1;
static const char *const afterSubCmds[] = {
"cancel", "idle", "info", NULL
};
enum afterSubCmdsEnum {AFTER_CANCEL, AFTER_IDLE, AFTER_INFO};
ThreadSpecificData *tsdPtr = InitTimer();
|
| ︙ | ︙ | |||
878 879 880 881 882 883 884 |
assocPtr->firstAfterPtr = afterPtr;
Tcl_SetObjResult(interp, Tcl_ObjPrintf("after#%d", afterPtr->id));
return TCL_OK;
}
case AFTER_CANCEL: {
Tcl_Obj *commandPtr;
const char *command, *tempCommand;
| | | 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 |
assocPtr->firstAfterPtr = afterPtr;
Tcl_SetObjResult(interp, Tcl_ObjPrintf("after#%d", afterPtr->id));
return TCL_OK;
}
case AFTER_CANCEL: {
Tcl_Obj *commandPtr;
const char *command, *tempCommand;
Tcl_Size tempLength;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "id|command");
return TCL_ERROR;
}
if (objc == 3) {
commandPtr = objv[2];
|
| ︙ | ︙ | |||
970 971 972 973 974 975 976 |
} else {
Tcl_Obj *resultListPtr;
TclNewObj(resultListPtr);
Tcl_ListObjAppendElement(interp, resultListPtr,
afterPtr->commandPtr);
Tcl_ListObjAppendElement(interp, resultListPtr, Tcl_NewStringObj(
| | | 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 |
} else {
Tcl_Obj *resultListPtr;
TclNewObj(resultListPtr);
Tcl_ListObjAppendElement(interp, resultListPtr,
afterPtr->commandPtr);
Tcl_ListObjAppendElement(interp, resultListPtr, Tcl_NewStringObj(
(afterPtr->token == NULL) ? "idle" : "timer", -1));
Tcl_SetObjResult(interp, resultListPtr);
}
break;
default:
Tcl_Panic("Tcl_AfterObjCmd: bad subcommand index to afterSubCmds");
}
return TCL_OK;
|
| ︙ | ︙ |
Changes to generic/tclTomMath.h.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
typedef int mp_err;
# define MP_OKAY 0 /* no error */
# define MP_ERR -1 /* unknown error */
# define MP_MEM -2 /* out of mem */
# define MP_VAL -3 /* invalid input */
# define MP_ITER -4 /* maximum iterations reached */
# define MP_BUF -5 /* buffer overflow, supplied buffer too small */
# define MP_WUR /* nothing */
# define mp_iszero(a) ((a)->used == 0)
# define mp_isneg(a) ((a)->sign != 0)
/* the infamous mp_int structure */
# ifndef MP_INT_DECLARED
# define MP_INT_DECLARED
| > > > > > > > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
typedef int mp_err;
# define MP_OKAY 0 /* no error */
# define MP_ERR -1 /* unknown error */
# define MP_MEM -2 /* out of mem */
# define MP_VAL -3 /* invalid input */
# define MP_ITER -4 /* maximum iterations reached */
# define MP_BUF -5 /* buffer overflow, supplied buffer too small */
typedef int mp_order;
# define MP_LSB_FIRST -1
# define MP_MSB_FIRST 1
typedef int mp_endian;
# define MP_LITTLE_ENDIAN -1
# define MP_NATIVE_ENDIAN 0
# define MP_BIG_ENDIAN 1
# define MP_DEPRECATED_PRAGMA(s) /* nothing */
# define MP_WUR /* nothing */
# define mp_iszero(a) ((a)->used == 0)
# define mp_isneg(a) ((a)->sign != 0)
/* the infamous mp_int structure */
# ifndef MP_INT_DECLARED
# define MP_INT_DECLARED
|
| ︙ | ︙ |
Changes to generic/tclTrace.c.
| ︙ | ︙ | |||
265 266 267 268 269 270 271 |
}
#ifndef TCL_REMOVE_OBSOLETE_TRACES
case TRACE_OLD_VARIABLE:
case TRACE_OLD_VDELETE: {
Tcl_Obj *copyObjv[6];
Tcl_Obj *opsList;
| | > | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
}
#ifndef TCL_REMOVE_OBSOLETE_TRACES
case TRACE_OLD_VARIABLE:
case TRACE_OLD_VDELETE: {
Tcl_Obj *copyObjv[6];
Tcl_Obj *opsList;
int code;
Tcl_Size numFlags;
if (objc != 5) {
Tcl_WrongNumArgs(interp, 2, objv, "name ops command");
return TCL_ERROR;
}
TclNewObj(opsList);
|
| ︙ | ︙ | |||
1100 1101 1102 1103 1104 1105 1106 | * function to be invoked. * * Results: * A standard Tcl return value. * * Side effects: * A trace is set up on the command given by cmdName, such that future | | | 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 | * function to be invoked. * * Results: * A standard Tcl return value. * * Side effects: * A trace is set up on the command given by cmdName, such that future * changes to the command will be mediated by proc. See the manual * entry for complete details on the calling sequence for proc. * *---------------------------------------------------------------------- */ int Tcl_TraceCommand( |
| ︙ | ︙ | |||
2924 2925 2926 2927 2928 2929 2930 |
const char *part2, /* Name of element within array; NULL means
* trace applies to scalar variable or array
* as-a-whole. */
int flags, /* OR-ed collection of bits describing current
* trace, including any of TCL_TRACE_READS,
* TCL_TRACE_WRITES, TCL_TRACE_UNSETS,
* TCL_GLOBAL_ONLY, and TCL_NAMESPACE_ONLY. */
| | | 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 |
const char *part2, /* Name of element within array; NULL means
* trace applies to scalar variable or array
* as-a-whole. */
int flags, /* OR-ed collection of bits describing current
* trace, including any of TCL_TRACE_READS,
* TCL_TRACE_WRITES, TCL_TRACE_UNSETS,
* TCL_GLOBAL_ONLY, and TCL_NAMESPACE_ONLY. */
Tcl_VarTraceProc *proc, /* Function associated with trace. */
void *clientData) /* Arbitrary argument to pass to proc. */
{
VarTrace *tracePtr;
VarTrace *prevPtr, *nextPtr;
Var *varPtr, *arrayPtr;
Interp *iPtr = (Interp *) interp;
ActiveVarTrace *activePtr;
|
| ︙ | ︙ | |||
3052 3053 3054 3055 3056 3057 3058 |
Tcl_Interp *interp, /* Interpreter containing variable. */
const char *part1, /* Name of variable or array. */
const char *part2, /* Name of element within array; NULL means
* trace applies to scalar variable or array
* as-a-whole. */
int flags, /* OR-ed combination of TCL_GLOBAL_ONLY,
* TCL_NAMESPACE_ONLY. */
| | | 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 |
Tcl_Interp *interp, /* Interpreter containing variable. */
const char *part1, /* Name of variable or array. */
const char *part2, /* Name of element within array; NULL means
* trace applies to scalar variable or array
* as-a-whole. */
int flags, /* OR-ed combination of TCL_GLOBAL_ONLY,
* TCL_NAMESPACE_ONLY. */
Tcl_VarTraceProc *proc, /* Function associated with trace. */
void *prevClientData) /* If non-NULL, gives last value returned by
* this function, so this call will return the
* next trace after that one. If NULL, this
* call will return the first trace. */
{
Interp *iPtr = (Interp *) interp;
Var *varPtr, *arrayPtr;
|
| ︙ | ︙ | |||
3110 3111 3112 3113 3114 3115 3116 | * actions. * * Results: * A standard Tcl return value. * * Side effects: * A trace is set up on the variable given by part1 and part2, such that | | | 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 | * actions. * * Results: * A standard Tcl return value. * * Side effects: * A trace is set up on the variable given by part1 and part2, such that * future references to the variable will be mediated by proc. See * the manual entry for complete details on the calling sequence for * proc. The variable's flags are updated. * *---------------------------------------------------------------------- */ int |
| ︙ | ︙ | |||
3163 3164 3165 3166 3167 3168 3169 | * actions. * * Results: * A standard Tcl return value. * * Side effects: * A trace is set up on the variable given by part1 and part2, such that | | | 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 | * actions. * * Results: * A standard Tcl return value. * * Side effects: * A trace is set up on the variable given by part1 and part2, such that * future references to the variable will be mediated by the * traceProc listed in tracePtr. See the manual entry for complete * details on the calling sequence for proc. * *---------------------------------------------------------------------- */ static int |
| ︙ | ︙ |
Changes to generic/tclUtf.c.
| ︙ | ︙ | |||
101 102 103 104 105 106 107 | * * Side effects: * None. * *--------------------------------------------------------------------------- */ | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
*
* Side effects:
* None.
*
*---------------------------------------------------------------------------
*/
int
TclUtfCount(
int ch) /* The Unicode character whose size is returned. */
{
if ((unsigned)(ch - 1) < (UNICODE_SELF - 1)) {
return 1;
}
if (ch <= 0x7FF) {
|
| ︙ | ︙ | |||
201 202 203 204 205 206 207 | * Side effects: * None. * *--------------------------------------------------------------------------- */ #undef Tcl_UniCharToUtf | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
* Side effects:
* None.
*
*---------------------------------------------------------------------------
*/
#undef Tcl_UniCharToUtf
Tcl_Size
Tcl_UniCharToUtf(
int ch, /* The Tcl_UniChar to be stored in the
* buffer. Can be or'ed with flag TCL_COMBINE
*/
char *buf) /* Buffer in which the UTF-8 representation of
* ch is stored. Must be large enough to hold the UTF-8
* character (at most 4 bytes).
|
| ︙ | ︙ | |||
314 315 316 317 318 319 320 |
*---------------------------------------------------------------------------
*/
#undef Tcl_UniCharToUtfDString
char *
Tcl_UniCharToUtfDString(
const int *uniStr, /* Unicode string to convert to UTF-8. */
| | > | | | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
*---------------------------------------------------------------------------
*/
#undef Tcl_UniCharToUtfDString
char *
Tcl_UniCharToUtfDString(
const int *uniStr, /* Unicode string to convert to UTF-8. */
Tcl_Size uniLength, /* Length of Unicode string. Negative for nul
* nul terminated string */
Tcl_DString *dsPtr) /* UTF-8 representation of string is appended
* to this previously initialized DString. */
{
const int *w, *wEnd;
char *p, *string;
Tcl_Size oldLength;
/*
* UTF-8 string length in bytes will be <= Unicode string length * 4.
*/
if (uniStr == NULL) {
return NULL;
}
if (uniLength < 0) {
uniLength = 0;
w = uniStr;
while (*w != '\0') {
uniLength++;
w++;
}
}
|
| ︙ | ︙ | |||
355 356 357 358 359 360 361 |
return string;
}
char *
Tcl_Char16ToUtfDString(
const unsigned short *uniStr,/* Utf-16 string to convert to UTF-8. */
| | | | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
return string;
}
char *
Tcl_Char16ToUtfDString(
const unsigned short *uniStr,/* Utf-16 string to convert to UTF-8. */
Tcl_Size uniLength, /* Length of Utf-16 string. */
Tcl_DString *dsPtr) /* UTF-8 representation of string is appended
* to this previously initialized DString. */
{
const unsigned short *w, *wEnd;
char *p, *string;
size_t oldLength;
int len = 1;
/*
* UTF-8 string length in bytes will be <= Utf16 string length * 3.
*/
if (uniStr == NULL) {
return NULL;
}
if (uniLength < 0) {
uniLength = 0;
w = uniStr;
while (*w != '\0') {
uniLength++;
w++;
}
|
| ︙ | ︙ | |||
449 450 451 452 453 454 455 |
0x20AC, 0x81, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x8D, 0x017D, 0x8F,
0x90, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x2DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x9D, 0x017E, 0x0178
};
#undef Tcl_UtfToUniChar
| | | 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
0x20AC, 0x81, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x8D, 0x017D, 0x8F,
0x90, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x2DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x9D, 0x017E, 0x0178
};
#undef Tcl_UtfToUniChar
Tcl_Size
Tcl_UtfToUniChar(
const char *src, /* The UTF-8 string. */
int *chPtr)/* Filled with the Unicode character represented by
* the UTF-8 string. */
{
int byte;
|
| ︙ | ︙ | |||
532 533 534 535 536 537 538 |
*/
}
*chPtr = byte;
return 1;
}
| | | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
*/
}
*chPtr = byte;
return 1;
}
Tcl_Size
Tcl_UtfToChar16(
const char *src, /* The UTF-8 string. */
unsigned short *chPtr)/* Filled with the Tcl_UniChar represented by
* the UTF-8 string. This could be a surrogate too. */
{
unsigned short byte;
|
| ︙ | ︙ | |||
653 654 655 656 657 658 659 |
*---------------------------------------------------------------------------
*/
#undef Tcl_UtfToUniCharDString
int *
Tcl_UtfToUniCharDString(
const char *src, /* UTF-8 string to convert to Unicode. */
| | | | | 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 |
*---------------------------------------------------------------------------
*/
#undef Tcl_UtfToUniCharDString
int *
Tcl_UtfToUniCharDString(
const char *src, /* UTF-8 string to convert to Unicode. */
Tcl_Size length, /* Length of UTF-8 string in bytes, or -1 for
* strlen(). */
Tcl_DString *dsPtr) /* Unicode representation of string is
* appended to this previously initialized
* DString. */
{
int ch = 0, *w, *wString;
const char *p;
Tcl_Size oldLength;
/* Pointer to the end of string. Never read endPtr[0] */
const char *endPtr = src + length;
/* Pointer to last byte where optimization still can be used */
const char *optPtr = endPtr - TCL_UTF_MAX;
if (src == NULL) {
return NULL;
}
if (length < 0) {
length = strlen(src);
}
/*
* Unicode string length in Tcl_UniChars will be <= UTF-8 string length in
* bytes.
*/
|
| ︙ | ︙ | |||
710 711 712 713 714 715 716 |
return wString;
}
unsigned short *
Tcl_UtfToChar16DString(
const char *src, /* UTF-8 string to convert to Unicode. */
| | | | | 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 |
return wString;
}
unsigned short *
Tcl_UtfToChar16DString(
const char *src, /* UTF-8 string to convert to Unicode. */
Tcl_Size length, /* Length of UTF-8 string in bytes, or -1 for
* strlen(). */
Tcl_DString *dsPtr) /* Unicode representation of string is
* appended to this previously initialized
* DString. */
{
unsigned short ch = 0, *w, *wString;
const char *p;
Tcl_Size oldLength;
/* Pointer to the end of string. Never read endPtr[0] */
const char *endPtr = src + length;
/* Pointer to last byte where optimization still can be used */
const char *optPtr = endPtr - TCL_UTF_MAX;
if (src == NULL) {
return NULL;
}
if (length < 0) {
length = strlen(src);
}
/*
* Unicode string length in WCHARs will be <= UTF-8 string length in
* bytes.
*/
|
| ︙ | ︙ | |||
788 789 790 791 792 793 794 |
*---------------------------------------------------------------------------
*/
int
Tcl_UtfCharComplete(
const char *src, /* String to check if first few bytes contain
* a complete UTF-8 character. */
| | | 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 |
*---------------------------------------------------------------------------
*/
int
Tcl_UtfCharComplete(
const char *src, /* String to check if first few bytes contain
* a complete UTF-8 character. */
Tcl_Size length) /* Length of above string in bytes. */
{
return length >= complete[UCHAR(*src)];
}
/*
*---------------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
811 812 813 814 815 816 817 | * * Side effects: * None. * *--------------------------------------------------------------------------- */ | | | | | | | 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 |
*
* Side effects:
* None.
*
*---------------------------------------------------------------------------
*/
Tcl_Size
Tcl_NumUtfChars(
const char *src, /* The UTF-8 string to measure. */
Tcl_Size length) /* The length of the string in bytes, or
* negative value for strlen(src). */
{
Tcl_UniChar ch = 0;
Tcl_Size i = 0;
if (length < 0) {
/* string is NUL-terminated, so TclUtfToUniChar calls are safe. */
while (*src != '\0') {
src += TclUtfToUniChar(src, &ch);
i++;
}
} else {
/* Will return value between 0 and length. No overflow checks. */
|
| ︙ | ︙ | |||
863 864 865 866 867 868 869 |
}
i++;
}
}
return i;
}
| | | | | | | 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
}
i++;
}
}
return i;
}
Tcl_Size
TclNumUtfChars(
const char *src, /* The UTF-8 string to measure. */
Tcl_Size length) /* The length of the string in bytes, or
* negative for strlen(src). */
{
unsigned short ch = 0;
Tcl_Size i = 0;
if (length < 0) {
/* string is NUL-terminated, so TclUtfToUniChar calls are safe. */
while (*src != '\0') {
src += Tcl_UtfToChar16(src, &ch);
i++;
}
} else {
/* Will return value between 0 and length. No overflow checks. */
|
| ︙ | ︙ | |||
1190 1191 1192 1193 1194 1195 1196 |
*
*---------------------------------------------------------------------------
*/
int
Tcl_UniCharAtIndex(
const char *src, /* The UTF-8 string to dereference. */
| | | | 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 |
*
*---------------------------------------------------------------------------
*/
int
Tcl_UniCharAtIndex(
const char *src, /* The UTF-8 string to dereference. */
Tcl_Size index) /* The position of the desired character. */
{
Tcl_UniChar ch = 0;
int i = 0;
if (index < 0) {
return -1;
}
while (index--) {
i = TclUtfToUniChar(src, &ch);
src += i;
}
#if TCL_UTF_MAX < 4
|
| ︙ | ︙ | |||
1234 1235 1236 1237 1238 1239 1240 |
*
*---------------------------------------------------------------------------
*/
const char *
Tcl_UtfAtIndex(
const char *src, /* The UTF-8 string. */
| | | | | | | 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 |
*
*---------------------------------------------------------------------------
*/
const char *
Tcl_UtfAtIndex(
const char *src, /* The UTF-8 string. */
Tcl_Size index) /* The position of the desired character. */
{
int ch = 0;
if (index > 0) {
while (index--) {
/* Make use of the #undef Tcl_UtfToUniChar above, which already handles UCS4. */
src += Tcl_UtfToUniChar(src, &ch);
}
}
return src;
}
const char *
TclUtfAtIndex(
const char *src, /* The UTF-8 string. */
Tcl_Size index) /* The position of the desired character. */
{
unsigned short ch = 0;
Tcl_Size len = 0;
if (index > 0) {
while (index--) {
src += (len = Tcl_UtfToChar16(src, &ch));
}
if ((ch >= 0xD800) && (len < 3)) {
/* Index points at character following high Surrogate */
src += Tcl_UtfToChar16(src, &ch);
}
|
| ︙ | ︙ | |||
1293 1294 1295 1296 1297 1298 1299 | * that represent the Unicode character is at least as large as the * source buffer from which the backslashed sequence was extracted, no * buffer overruns should occur. * *--------------------------------------------------------------------------- */ | | > | | 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 |
* that represent the Unicode character is at least as large as the
* source buffer from which the backslashed sequence was extracted, no
* buffer overruns should occur.
*
*---------------------------------------------------------------------------
*/
Tcl_Size
Tcl_UtfBackslash(
const char *src, /* Points to the backslash character of a
* backslash sequence. */
int *readPtr, /* Fill in with number of characters read from
* src, unless NULL. */
char *dst) /* Filled with the bytes represented by the
* backslash sequence. */
{
#define LINE_LENGTH 128
Tcl_Size numRead;
int result;
result = TclParseBackslash(src, LINE_LENGTH, &numRead, dst);
if (numRead == LINE_LENGTH) {
/*
* We ate a whole line. Pay the price of a strlen()
*/
|
| ︙ | ︙ | |||
1337 1338 1339 1340 1341 1342 1343 | * * Side effects: * Writes a terminating null after the last converted character. * *---------------------------------------------------------------------- */ | | | | 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 |
*
* Side effects:
* Writes a terminating null after the last converted character.
*
*----------------------------------------------------------------------
*/
Tcl_Size
Tcl_UtfToUpper(
char *str) /* String to convert in place. */
{
int ch, upChar;
char *src, *dst;
Tcl_Size len;
/*
* Iterate over the string until we hit the terminating null.
*/
src = dst = str;
while (*src) {
|
| ︙ | ︙ | |||
1390 1391 1392 1393 1394 1395 1396 | * * Side effects: * Writes a terminating null after the last converted character. * *---------------------------------------------------------------------- */ | | | | 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 |
*
* Side effects:
* Writes a terminating null after the last converted character.
*
*----------------------------------------------------------------------
*/
Tcl_Size
Tcl_UtfToLower(
char *str) /* String to convert in place. */
{
int ch, lowChar;
char *src, *dst;
Tcl_Size len;
/*
* Iterate over the string until we hit the terminating null.
*/
src = dst = str;
while (*src) {
|
| ︙ | ︙ | |||
1444 1445 1446 1447 1448 1449 1450 | * * Side effects: * Writes a terminating null after the last converted character. * *---------------------------------------------------------------------- */ | | | | 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 |
*
* Side effects:
* Writes a terminating null after the last converted character.
*
*----------------------------------------------------------------------
*/
Tcl_Size
Tcl_UtfToTitle(
char *str) /* String to convert in place. */
{
int ch, titleChar, lowChar;
char *src, *dst;
Tcl_Size len;
/*
* Capitalize the first character and then lowercase the rest of the
* characters until we get to a null.
*/
src = dst = str;
|
| ︙ | ︙ | |||
1866 1867 1868 1869 1870 1871 1872 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
Tcl_Char16Len(
const unsigned short *uniStr) /* Unicode string to find length of. */
{
Tcl_Size len = 0;
while (*uniStr != '\0') {
len++;
uniStr++;
}
return len;
}
|
| ︙ | ︙ | |||
1897 1898 1899 1900 1901 1902 1903 | * Side effects: * None. * *---------------------------------------------------------------------- */ #undef Tcl_UniCharLen | | | | 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 |
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
#undef Tcl_UniCharLen
Tcl_Size
Tcl_UniCharLen(
const int *uniStr) /* Unicode string to find length of. */
{
Tcl_Size len = 0;
while (*uniStr != '\0') {
len++;
uniStr++;
}
return len;
}
|
| ︙ | ︙ | |||
1984 1985 1986 1987 1988 1989 1990 |
*----------------------------------------------------------------------
*/
int
TclUniCharNcasecmp(
const Tcl_UniChar *ucs, /* Unicode string to compare to uct. */
const Tcl_UniChar *uct, /* Unicode string ucs is compared to. */
| | | 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 |
*----------------------------------------------------------------------
*/
int
TclUniCharNcasecmp(
const Tcl_UniChar *ucs, /* Unicode string to compare to uct. */
const Tcl_UniChar *uct, /* Unicode string ucs is compared to. */
size_t numChars) /* Number of Unichars to compare. */
{
for ( ; numChars != 0; numChars--, ucs++, uct++) {
if (*ucs != *uct) {
Tcl_UniChar lcs = Tcl_UniCharToLower(*ucs);
Tcl_UniChar lct = Tcl_UniCharToLower(*uct);
if (lcs != lct) {
|
| ︙ | ︙ | |||
2559 2560 2561 2562 2563 2564 2565 |
*
*----------------------------------------------------------------------
*/
int
TclUniCharMatch(
const Tcl_UniChar *string, /* Unicode String. */
| | | | 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 |
*
*----------------------------------------------------------------------
*/
int
TclUniCharMatch(
const Tcl_UniChar *string, /* Unicode String. */
Tcl_Size strLen, /* Length of String */
const Tcl_UniChar *pattern, /* Pattern, which may contain special
* characters. */
Tcl_Size ptnLen, /* Length of Pattern */
int nocase) /* 0 for case sensitive, 1 for insensitive */
{
const Tcl_UniChar *stringEnd, *patternEnd;
Tcl_UniChar p;
stringEnd = string + strLen;
patternEnd = pattern + ptnLen;
|
| ︙ | ︙ |
Changes to generic/tclUtil.c.
| ︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | * Copyright © 1994-1998 Sun Microsystems, Inc. * Copyright © 2001 Kevin B. Kenny. All rights reserved. * * 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 "tclParse.h" #include "tclStringTrim.h" #include "tclTomMath.h" #include <math.h> /* | > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * Copyright © 1994-1998 Sun Microsystems, Inc. * Copyright © 2001 Kevin B. Kenny. All rights reserved. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include <assert.h> #include "tclInt.h" #include "tclParse.h" #include "tclStringTrim.h" #include "tclTomMath.h" #include <math.h> /* |
| ︙ | ︙ | |||
98 99 100 101 102 103 104 | * Prototypes for functions defined later in this file. */ static void ClearHash(Tcl_HashTable *tablePtr); static void FreeProcessGlobalValue(void *clientData); static void FreeThreadHash(void *clientData); static int GetEndOffsetFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, | | | | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | * Prototypes for functions defined later in this file. */ static void ClearHash(Tcl_HashTable *tablePtr); static void FreeProcessGlobalValue(void *clientData); static void FreeThreadHash(void *clientData); static int GetEndOffsetFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_WideInt endValue, Tcl_WideInt *indexPtr); static Tcl_HashTable * GetThreadHash(Tcl_ThreadDataKey *keyPtr); static int GetWideForIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_WideInt endValue, Tcl_WideInt *widePtr); static int FindElement(Tcl_Interp *interp, const char *string, Tcl_Size stringLength, const char *typeStr, const char *typeCode, const char **elementPtr, const char **nextPtr, Tcl_Size *sizePtr, int *literalPtr); /* * The following is the Tcl object type definition for an object that * represents a list index in the form, "end-offset". It is used as a * performance optimization in Tcl_GetIntForIndex. The internal rep is * stored directly in the wideValue, so no memory management is required * for it. This is a caching internalrep, keeping the result of a parse |
| ︙ | ︙ | |||
136 137 138 139 140 141 142 |
NULL,
NULL,
NULL,
NULL,
NULL)
};
| | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
NULL,
NULL,
NULL,
NULL,
NULL)
};
Tcl_Size
TclLengthOne(
TCL_UNUSED(Tcl_Obj *))
{
return 1;
}
/*
|
| ︙ | ︙ | |||
397 398 399 400 401 402 403 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | | 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclMaxListLength(
const char *bytes,
Tcl_Size numBytes,
const char **endPtr)
{
Tcl_Size count = 0;
if ((numBytes == 0) || ((numBytes == TCL_INDEX_NONE) && (*bytes == '\0'))) {
/* Empty string case - quick exit */
goto done;
}
/*
|
| ︙ | ︙ | |||
506 507 508 509 510 511 512 |
TclFindElement(
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, then no error message is left after
* errors. */
const char *list, /* Points to the first byte of a string
* containing a Tcl list with zero or more
* elements (possibly in braces). */
| | | | 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
TclFindElement(
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, then no error message is left after
* errors. */
const char *list, /* Points to the first byte of a string
* containing a Tcl list with zero or more
* elements (possibly in braces). */
Tcl_Size listLength, /* Number of bytes in the list's string. */
const char **elementPtr, /* Where to put address of first significant
* character in first element of list. */
const char **nextPtr, /* Fill in with location of character just
* after all white space following end of
* argument (next arg or end of list). */
Tcl_Size *sizePtr, /* If non-zero, fill in with size of
* element. */
int *literalPtr) /* If non-zero, fill in with non-zero/zero to
* indicate that the substring of *sizePtr
* bytes starting at **elementPtr is/is not
* the literal list element and therefore
* does not/does require a call to
* TclCopyAndCollapse() by the caller. */
|
| ︙ | ︙ | |||
534 535 536 537 538 539 540 |
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, then no error message is left after
* errors. */
const char *dict, /* Points to the first byte of a string
* containing a Tcl dictionary with zero or
* more keys and values (possibly in
* braces). */
| | | | 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, then no error message is left after
* errors. */
const char *dict, /* Points to the first byte of a string
* containing a Tcl dictionary with zero or
* more keys and values (possibly in
* braces). */
Tcl_Size dictLength, /* Number of bytes in the dict's string. */
const char **elementPtr, /* Where to put address of first significant
* character in the first element (i.e., key
* or value) of dict. */
const char **nextPtr, /* Fill in with location of character just
* after all white space following end of
* element (next arg or end of list). */
Tcl_Size *sizePtr, /* If non-zero, fill in with size of
* element. */
int *literalPtr) /* If non-zero, fill in with non-zero/zero to
* indicate that the substring of *sizePtr
* bytes starting at **elementPtr is/is not
* the literal key or value and therefore
* does not/does require a call to
* TclCopyAndCollapse() by the caller. */
|
| ︙ | ︙ | |||
563 564 565 566 567 568 569 |
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, then no error message is left after
* errors. */
const char *string, /* Points to the first byte of a string
* containing a Tcl list or dictionary with
* zero or more elements (possibly in
* braces). */
| | | | | | | 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, then no error message is left after
* errors. */
const char *string, /* Points to the first byte of a string
* containing a Tcl list or dictionary with
* zero or more elements (possibly in
* braces). */
Tcl_Size stringLength, /* Number of bytes in the string. */
const char *typeStr, /* The name of the type of thing we are
* parsing, for error messages. */
const char *typeCode, /* The type code for thing we are parsing, for
* error messages. */
const char **elementPtr, /* Where to put address of first significant
* character in first element. */
const char **nextPtr, /* Fill in with location of character just
* after all white space following end of
* argument (next arg or end of list/dict). */
Tcl_Size *sizePtr, /* If non-zero, fill in with size of
* element. */
int *literalPtr) /* If non-zero, fill in with non-zero/zero to
* indicate that the substring of *sizePtr
* bytes starting at **elementPtr is/is not
* the literal list/dict element and therefore
* does not/does require a call to
* TclCopyAndCollapse() by the caller. */
{
const char *p = string;
const char *elemStart; /* Points to first byte of first element. */
const char *limit; /* Points just after list/dict's last byte. */
Tcl_Size openBraces = 0; /* Brace nesting level during parse. */
int inQuotes = 0;
Tcl_Size size = 0;
Tcl_Size numChars;
int literal = 1;
const char *p2;
/*
* Skim off leading white space and check for an opening brace or quote.
* We treat embedded NULLs in the list/dict as bytes belonging to a list
* element (or dictionary key or value).
|
| ︙ | ︙ | |||
796 797 798 799 800 801 802 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | | | | 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclCopyAndCollapse(
Tcl_Size count, /* Number of byte to copy from src. */
const char *src, /* Copy from here... */
char *dst) /* ... to here. */
{
Tcl_Size newCount = 0;
while (count > 0) {
char c = *src;
if (c == '\\') {
char buf[4] = "";
Tcl_Size numRead;
Tcl_Size backslashCount = TclParseBackslash(src, count, &numRead, buf);
memcpy(dst, buf, backslashCount);
dst += backslashCount;
newCount += backslashCount;
src += numRead;
count -= numRead;
} else {
|
| ︙ | ︙ | |||
863 864 865 866 867 868 869 |
#undef Tcl_SplitList
int
Tcl_SplitList(
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, no error message is left. */
const char *list, /* Pointer to string with list structure. */
| | | | 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 |
#undef Tcl_SplitList
int
Tcl_SplitList(
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, no error message is left. */
const char *list, /* Pointer to string with list structure. */
Tcl_Size *argcPtr, /* Pointer to location to fill in with the
* number of elements in the list. */
const char ***argvPtr) /* Pointer to place to store pointer to array
* of pointers to list elements. */
{
const char **argv, *end, *element;
char *p;
int result;
Tcl_Size length, size, i, elSize;
/*
* Allocate enough space to work in. A (const char *) for each (possible)
* list element plus one more for terminating NULL, plus as many bytes as
* in the original string value, plus one more for a terminating '\0'.
* Space used to hold element separating white space in the original
* string gets re-purposed to hold '\0' characters in the argv array.
|
| ︙ | ︙ | |||
904 905 906 907 908 909 910 |
if (*element == 0) {
break;
}
if (i >= size) {
Tcl_Free((void *)argv);
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 |
if (*element == 0) {
break;
}
if (i >= size) {
Tcl_Free((void *)argv);
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"internal error in Tcl_SplitList", -1));
Tcl_SetErrorCode(interp, "TCL", "INTERNAL", "Tcl_SplitList",
NULL);
}
return TCL_ERROR;
}
argv[i] = p;
if (literal) {
|
| ︙ | ︙ | |||
948 949 950 951 952 953 954 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
Tcl_ScanElement(
const char *src, /* String to convert to list element. */
int *flagPtr) /* Where to store information to guide
* Tcl_ConvertCountedElement. */
{
return Tcl_ScanCountedElement(src, TCL_INDEX_NONE, flagPtr);
}
|
| ︙ | ︙ | |||
980 981 982 983 984 985 986 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | | 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
Tcl_ScanCountedElement(
const char *src, /* String to convert to Tcl list element. */
Tcl_Size length, /* Number of bytes in src, or TCL_INDEX_NONE. */
int *flagPtr) /* Where to store information to guide
* Tcl_ConvertElement. */
{
char flags = CONVERT_ANY;
Tcl_Size numBytes = TclScanElement(src, length, &flags);
*flagPtr = flags;
return numBytes;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
1024 1025 1026 1027 1028 1029 1030 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | | 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclScanElement(
const char *src, /* String to convert to Tcl list element. */
Tcl_Size length, /* Number of bytes in src, or TCL_INDEX_NONE. */
char *flagPtr) /* Where to store information to guide
* Tcl_ConvertElement. */
{
const char *p = src;
Tcl_Size nestingLevel = 0; /* Brace nesting count */
int forbidNone = 0; /* Do not permit CONVERT_NONE mode. Something
* needs protection or escape. */
int requireEscape = 0; /* Force use of CONVERT_ESCAPE mode. For some
* reason bare or brace-quoted form fails. */
int extra = 0; /* Count of number of extra bytes needed for
* formatted element, assuming we use escape
* sequences in formatting. */
|
| ︙ | ︙ | |||
1146 1147 1148 1149 1150 1151 1152 | extra++; /* Escape newline => '\n', one byte longer */ /* * Backslash newline sequence. Brace quoting not permitted. */ requireEscape = 1; | | | | 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 |
extra++; /* Escape newline => '\n', one byte longer */
/*
* Backslash newline sequence. Brace quoting not permitted.
*/
requireEscape = 1;
length -= (length > 0);
p++;
break;
}
if ((p[1] == '{') || (p[1] == '}') || (p[1] == '\\')) {
extra++; /* Escape sequences all one byte longer. */
length -= (length > 0);
p++;
}
forbidNone = 1;
#if COMPAT
preferBrace = 1;
#endif /* COMPAT */
break;
|
| ︙ | ︙ | |||
1177 1178 1179 1180 1181 1182 1183 |
#if COMPAT
preferBrace = 1;
#endif
}
break;
}
}
| | | 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 |
#if COMPAT
preferBrace = 1;
#endif
}
break;
}
}
length -= (length > 0);
p++;
}
endOfString:
if (nestingLevel > 0) {
/*
* Unbalanced braces! Cannot format with brace quoting.
|
| ︙ | ︙ | |||
1241 1242 1243 1244 1245 1246 1247 |
#if COMPAT
if (preferEscape && !preferBrace) {
/*
* If we are quoting solely due to ] or internal " characters use
* the CONVERT_MASK mode where we escape all special characters
* except for braces. "extra" counted space needed to escape
| | | 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 |
#if COMPAT
if (preferEscape && !preferBrace) {
/*
* If we are quoting solely due to ] or internal " characters use
* the CONVERT_MASK mode where we escape all special characters
* except for braces. "extra" counted space needed to escape
* braces too, so subtract "braceCount" to get our actual needs.
*/
bytesNeeded += (extra - braceCount);
/* Make room to escape leading #, if needed. */
if ((*src == '#') && !(*flagPtr & TCL_DONT_QUOTE_HASH)) {
bytesNeeded++;
}
|
| ︙ | ︙ | |||
1325 1326 1327 1328 1329 1330 1331 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
Tcl_ConvertElement(
const char *src, /* Source information for list element. */
char *dst, /* Place to put list-ified element. */
int flags) /* Flags produced by Tcl_ScanElement. */
{
return Tcl_ConvertCountedElement(src, TCL_INDEX_NONE, dst, flags);
}
|
| ︙ | ︙ | |||
1355 1356 1357 1358 1359 1360 1361 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | | 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
Tcl_ConvertCountedElement(
const char *src, /* Source information for list element. */
Tcl_Size length, /* Number of bytes in src, or TCL_INDEX_NONE. */
char *dst, /* Place to put list-ified element. */
int flags) /* Flags produced by Tcl_ScanElement. */
{
Tcl_Size numBytes = TclConvertElement(src, length, dst, flags);
dst[numBytes] = '\0';
return numBytes;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
1388 1389 1390 1391 1392 1393 1394 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclConvertElement(
const char *src, /* Source information for list element. */
Tcl_Size length, /* Number of bytes in src, or TCL_INDEX_NONE. */
char *dst, /* Place to put list-ified element. */
int flags) /* Flags produced by Tcl_ScanElement. */
{
int conversion = flags & CONVERT_MASK;
char *p = dst;
/*
|
| ︙ | ︙ | |||
1426 1427 1428 1429 1430 1431 1432 |
if ((*src == '#') && !(flags & TCL_DONT_QUOTE_HASH)) {
if (conversion == CONVERT_ESCAPE) {
p[0] = '\\';
p[1] = '#';
p += 2;
src++;
| | | 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 |
if ((*src == '#') && !(flags & TCL_DONT_QUOTE_HASH)) {
if (conversion == CONVERT_ESCAPE) {
p[0] = '\\';
p[1] = '#';
p += 2;
src++;
length -= (length > 0);
} else {
conversion = CONVERT_BRACE;
}
}
/*
* No escape or quoting needed. Copy the literal string value.
|
| ︙ | ︙ | |||
1467 1468 1469 1470 1471 1472 1473 |
}
} else {
memcpy(p, src, length);
p += length;
}
*p = '}';
p++;
| | | | 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 |
}
} else {
memcpy(p, src, length);
p += length;
}
*p = '}';
p++;
return (p - dst);
}
/* conversion == CONVERT_ESCAPE or CONVERT_MASK */
/*
* Formatted string is original string converted to escape sequences.
*/
for ( ; length; src++, length -= (length > 0)) {
switch (*src) {
case ']':
case '[':
case '$':
case ';':
case ' ':
case '\\':
|
| ︙ | ︙ | |||
1530 1531 1532 1533 1534 1535 1536 |
*p = '\\';
p++;
*p = 'v';
p++;
continue;
case '\0':
if (length == TCL_INDEX_NONE) {
| | | | 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 |
*p = '\\';
p++;
*p = 'v';
p++;
continue;
case '\0':
if (length == TCL_INDEX_NONE) {
return (p - dst);
}
/*
* If we reach this point, there's an embedded NULL in the string
* range being processed, which should not happen when the
* encoding rules for Tcl strings are properly followed. If the
* day ever comes when we stop tolerating such things, this is
* where to put the Tcl_Panic().
*/
break;
}
*p = *src;
p++;
}
return (p - dst);
}
/*
*----------------------------------------------------------------------
*
* Tcl_Merge --
*
|
| ︙ | ︙ | |||
1571 1572 1573 1574 1575 1576 1577 | * None. * *---------------------------------------------------------------------- */ char * Tcl_Merge( | | | | | 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 |
* None.
*
*----------------------------------------------------------------------
*/
char *
Tcl_Merge(
Tcl_Size argc, /* How many strings to merge. */
const char *const *argv) /* Array of string values. */
{
#define LOCAL_SIZE 64
char localFlags[LOCAL_SIZE], *flagPtr = NULL;
Tcl_Size i, bytesNeeded = 0;
char *result, *dst;
/*
* Handle empty list case first, so logic of the general case can be
* simpler.
*/
if (argc <= 0) {
result = (char *)Tcl_Alloc(1);
result[0] = '\0';
return result;
}
/*
* Pass 1: estimate space, gather flags.
|
| ︙ | ︙ | |||
1642 1643 1644 1645 1646 1647 1648 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | | | 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclTrimRight(
const char *bytes, /* String to be trimmed... */
Tcl_Size numBytes, /* ...and its length in bytes */
/* Calls to TclUtfToUniChar() in this routine
* rely on (bytes[numBytes] == '\0'). */
const char *trim, /* String of trim characters... */
Tcl_Size numTrim) /* ...and its length in bytes */
/* Calls to TclUtfToUniChar() in this routine
* rely on (trim[numTrim] == '\0'). */
{
const char *pp, *p = bytes + numBytes;
int ch1, ch2;
/* Empty strings -> nothing to do */
if ((numBytes == 0) || (numTrim == 0)) {
return 0;
}
/*
* Outer loop: iterate over string to be trimmed.
*/
do {
const char *q = trim;
Tcl_Size pInc = 0, bytesLeft = numTrim;
pp = Tcl_UtfPrev(p, bytes);
do {
pp += pInc;
pInc = TclUtfToUCS4(pp, &ch1);
} while (pp + pInc < p);
|
| ︙ | ︙ | |||
1721 1722 1723 1724 1725 1726 1727 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | | | | | 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclTrimLeft(
const char *bytes, /* String to be trimmed... */
Tcl_Size numBytes, /* ...and its length in bytes */
/* Calls to TclUtfToUniChar() in this routine
* rely on (bytes[numBytes] == '\0'). */
const char *trim, /* String of trim characters... */
Tcl_Size numTrim) /* ...and its length in bytes */
/* Calls to TclUtfToUniChar() in this routine
* rely on (trim[numTrim] == '\0'). */
{
const char *p = bytes;
int ch1, ch2;
/* Empty strings -> nothing to do */
if ((numBytes == 0) || (numTrim == 0)) {
return 0;
}
/*
* Outer loop: iterate over string to be trimmed.
*/
do {
Tcl_Size pInc = TclUtfToUCS4(p, &ch1);
const char *q = trim;
Tcl_Size bytesLeft = numTrim;
/*
* Inner loop: scan trim string for match to current character.
*/
do {
Tcl_Size qInc = TclUtfToUCS4(q, &ch2);
if (ch1 == ch2) {
break;
}
q += qInc;
bytesLeft -= qInc;
|
| ︙ | ︙ | |||
1795 1796 1797 1798 1799 1800 1801 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | | | | 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclTrim(
const char *bytes, /* String to be trimmed... */
Tcl_Size numBytes, /* ...and its length in bytes */
/* Calls in this routine
* rely on (bytes[numBytes] == '\0'). */
const char *trim, /* String of trim characters... */
Tcl_Size numTrim, /* ...and its length in bytes */
/* Calls in this routine
* rely on (trim[numTrim] == '\0'). */
Tcl_Size *trimRightPtr) /* Offset from the end of the string. */
{
Tcl_Size trimLeft = 0, trimRight = 0;
/* Empty strings -> nothing to do */
if ((numBytes > 0) && (numTrim > 0)) {
/* When bytes is NUL-terminated, returns 0 <= trimLeft <= numBytes */
trimLeft = TclTrimLeft(bytes, numBytes, trim, numTrim);
numBytes -= trimLeft;
|
| ︙ | ︙ | |||
1859 1860 1861 1862 1863 1864 1865 | */ /* The whitespace characters trimmed during [concat] operations */ #define CONCAT_WS_SIZE (sizeof(CONCAT_TRIM_SET "") - 1) char * Tcl_Concat( | | | > > > > > > > > > > > | | 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 |
*/
/* The whitespace characters trimmed during [concat] operations */
#define CONCAT_WS_SIZE (sizeof(CONCAT_TRIM_SET "") - 1)
char *
Tcl_Concat(
Tcl_Size argc, /* Number of strings to concatenate. */
const char *const *argv) /* Array of strings to concatenate. */
{
Tcl_Size i, needSpace = 0, bytesNeeded = 0;
char *result, *p;
/*
* Dispose of the empty result corner case first to simplify later code.
*/
if (argc == 0) {
result = (char *) Tcl_Alloc(1);
result[0] = '\0';
return result;
}
/*
* First allocate the result buffer at the size required.
*/
for (i = 0; i < argc; i++) {
bytesNeeded += strlen(argv[i]);
if (bytesNeeded < 0) {
Tcl_Panic("Tcl_Concat: max size of Tcl value exceeded");
}
}
/*
* All element bytes + (argc - 1) spaces + 1 terminating NULL.
*/
if (bytesNeeded + argc - 1 < 0) {
/*
* Panic test could be tighter, but not going to bother for this
* legacy routine.
*/
Tcl_Panic("Tcl_Concat: max size of Tcl value exceeded");
}
result = (char *)Tcl_Alloc(bytesNeeded + argc);
for (p = result, i = 0; i < argc; i++) {
Tcl_Size triml, trimr, elemLength;
const char *element;
element = argv[i];
elemLength = strlen(argv[i]);
/* Trim away the leading/trailing whitespace. */
triml = TclTrim(element, elemLength, CONCAT_TRIM_SET,
|
| ︙ | ︙ | |||
1948 1949 1950 1951 1952 1953 1954 | * A new object is created. * *---------------------------------------------------------------------- */ Tcl_Obj * Tcl_ConcatObj( | | | | | 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 |
* A new object is created.
*
*----------------------------------------------------------------------
*/
Tcl_Obj *
Tcl_ConcatObj(
Tcl_Size objc, /* Number of objects to concatenate. */
Tcl_Obj *const objv[]) /* Array of objects to concatenate. */
{
int needSpace = 0;
Tcl_Size i, bytesNeeded = 0, elemLength;
const char *element;
Tcl_Obj *objPtr, *resPtr;
/*
* Check first to see if all the items are of list type or empty. If so,
* we will concat them together as lists, and return a list object. This
* is only valid when the lists are in canonical form.
*/
for (i = 0; i < objc; i++) {
Tcl_Size length;
objPtr = objv[i];
if (TclListObjIsCanonical(objPtr)) {
continue;
}
(void)Tcl_GetStringFromObj(objPtr, &length);
if (length > 0) {
|
| ︙ | ︙ | |||
2009 2010 2011 2012 2013 2014 2015 |
}
slow:
/*
* Something cannot be determined to be safe, so build the concatenation
* the slow way, using the string representations.
*
| | > > > | | 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 |
}
slow:
/*
* Something cannot be determined to be safe, so build the concatenation
* the slow way, using the string representations.
*
* First try to preallocate the size required.
*/
for (i = 0; i < objc; i++) {
element = Tcl_GetStringFromObj(objv[i], &elemLength);
if (bytesNeeded > (TCL_SIZE_MAX - elemLength)) {
break; /* Overflow. Do not preallocate. See comment below. */
}
bytesNeeded += elemLength;
}
/*
* Does not matter if this fails, will simply try later to build up the
* string with each Append reallocating as needed with the usual string
* append algorithm. When that fails it will report the error.
*/
TclNewObj(resPtr);
(void) Tcl_AttemptSetObjLength(resPtr, bytesNeeded + objc - 1);
Tcl_SetObjLength(resPtr, 0);
for (i = 0; i < objc; i++) {
Tcl_Size triml, trimr;
element = Tcl_GetStringFromObj(objv[i], &elemLength);
/* Trim away the leading/trailing whitespace. */
triml = TclTrim(element, elemLength, CONCAT_TRIM_SET,
CONCAT_WS_SIZE, &trimr);
element += triml;
|
| ︙ | ︙ | |||
2319 2320 2321 2322 2323 2324 2325 |
*
*----------------------------------------------------------------------
*/
int
TclByteArrayMatch(
const unsigned char *string,/* String. */
| | | | 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 |
*
*----------------------------------------------------------------------
*/
int
TclByteArrayMatch(
const unsigned char *string,/* String. */
Tcl_Size strLen, /* Length of String */
const unsigned char *pattern,
/* Pattern, which may contain special
* characters. */
Tcl_Size ptnLen, /* Length of Pattern */
TCL_UNUSED(int) /*flags*/)
{
const unsigned char *stringEnd, *patternEnd;
unsigned char p;
stringEnd = string + strLen;
patternEnd = pattern + ptnLen;
|
| ︙ | ︙ | |||
2501 2502 2503 2504 2505 2506 2507 |
TclStringMatchObj(
Tcl_Obj *strObj, /* string object. */
Tcl_Obj *ptnObj, /* pattern object. */
int flags) /* Only TCL_MATCH_NOCASE should be passed, or
* 0. */
{
int match;
| | | 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 |
TclStringMatchObj(
Tcl_Obj *strObj, /* string object. */
Tcl_Obj *ptnObj, /* pattern object. */
int flags) /* Only TCL_MATCH_NOCASE should be passed, or
* 0. */
{
int match;
Tcl_Size length = 0, plen = 0;
/*
* Promote based on the type of incoming object.
* XXX: Currently doesn't take advantage of exact-ness that
* XXX: TclReToGlob tells us about
trivial = nocase ? 0 : TclMatchIsTrivial(TclGetString(ptnObj));
*/
|
| ︙ | ︙ | |||
2581 2582 2583 2584 2585 2586 2587 |
*/
char *
Tcl_DStringAppend(
Tcl_DString *dsPtr, /* Structure describing dynamic string. */
const char *bytes, /* String to append. If length is
* TCL_INDEX_NONE then this must be null-terminated. */
| | | | | | | 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 |
*/
char *
Tcl_DStringAppend(
Tcl_DString *dsPtr, /* Structure describing dynamic string. */
const char *bytes, /* String to append. If length is
* TCL_INDEX_NONE then this must be null-terminated. */
Tcl_Size length) /* Number of bytes from "bytes" to append. If
* TCL_INDEX_NONE, then append all of bytes, up to null
* at end. */
{
Tcl_Size newSize;
if (length < 0) {
length = strlen(bytes);
}
newSize = length + dsPtr->length;
/*
* Allocate a larger buffer for the string if the current one isn't large
* enough. Allocate extra space in the new buffer so that there will be
* room to grow before we have to allocate again.
*/
if (newSize >= dsPtr->spaceAvl) {
dsPtr->spaceAvl = newSize * 2;
if (dsPtr->string == dsPtr->staticSpace) {
char *newString = (char *)Tcl_Alloc(dsPtr->spaceAvl);
memcpy(newString, dsPtr->string, dsPtr->length);
dsPtr->string = newString;
} else {
Tcl_Size index = TCL_INDEX_NONE;
/* See [16896d49fd] */
if (bytes >= dsPtr->string
&& bytes <= dsPtr->string + dsPtr->length) {
index = bytes - dsPtr->string;
}
dsPtr->string = (char *)Tcl_Realloc(dsPtr->string, dsPtr->spaceAvl);
if (index >= 0) {
bytes = dsPtr->string + index;
}
}
}
/*
* Copy the new string into the buffer at the end of the old one.
|
| ︙ | ︙ | |||
2648 2649 2650 2651 2652 2653 2654 |
*/
char *
TclDStringAppendObj(
Tcl_DString *dsPtr,
Tcl_Obj *objPtr)
{
| | | 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 |
*/
char *
TclDStringAppendObj(
Tcl_DString *dsPtr,
Tcl_Obj *objPtr)
{
Tcl_Size length;
const char *bytes = Tcl_GetStringFromObj(objPtr, &length);
return Tcl_DStringAppend(dsPtr, bytes, length);
}
char *
TclDStringAppendDString(
|
| ︙ | ︙ | |||
2691 2692 2693 2694 2695 2696 2697 |
const char *element) /* String to append. Must be
* null-terminated. */
{
char *dst = dsPtr->string + dsPtr->length;
int needSpace = TclNeedSpace(dsPtr->string, dst);
char flags = 0;
int quoteHash = 1;
| | | 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 |
const char *element) /* String to append. Must be
* null-terminated. */
{
char *dst = dsPtr->string + dsPtr->length;
int needSpace = TclNeedSpace(dsPtr->string, dst);
char flags = 0;
int quoteHash = 1;
Tcl_Size newSize;
if (needSpace) {
/*
* If we need a space to separate the new element from something
* already ending the string, we're not appending the first element
* of any list, so we need not quote any leading hash character.
*/
|
| ︙ | ︙ | |||
2792 2793 2794 2795 2796 2797 2798 |
*
*----------------------------------------------------------------------
*/
void
Tcl_DStringSetLength(
Tcl_DString *dsPtr, /* Structure describing dynamic string. */
| | | | 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 |
*
*----------------------------------------------------------------------
*/
void
Tcl_DStringSetLength(
Tcl_DString *dsPtr, /* Structure describing dynamic string. */
Tcl_Size length) /* New length for dynamic string. */
{
Tcl_Size newsize;
if (length >= dsPtr->spaceAvl) {
/*
* There are two interesting cases here. In the first case, the user
* may be trying to allocate a large buffer of a specific size. It
* would be wasteful to overallocate that buffer, so we just allocate
* enough for the requested size plus the trailing null byte. In the
|
| ︙ | ︙ | |||
3118 3119 3120 3121 3122 3123 3124 |
*dst++ = '.';
while (c != '\0') {
*dst++ = c;
c = *++p;
}
}
| | | 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 |
*dst++ = '.';
while (c != '\0') {
*dst++ = c;
c = *++p;
}
}
snprintf(dst, TCL_DOUBLE_SPACE, "e%+d", exponent);
} else {
/*
* F format for others.
*/
if (exponent < 0) {
*dst++ = '0';
|
| ︙ | ︙ | |||
3271 3272 3273 3274 3275 3276 3277 | * Side effects: * The formatted characters are written into the storage pointer to by * the "buffer" argument. * *---------------------------------------------------------------------- */ | | | | 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 |
* Side effects:
* The formatted characters are written into the storage pointer to by
* the "buffer" argument.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclFormatInt(
char *buffer, /* Points to the storage into which the
* formatted characters are written. */
Tcl_WideInt n) /* The integer to format. */
{
Tcl_WideUInt intVal;
int i = 0, numFormatted, j;
static const char digits[] = "0123456789";
/*
* Generate the characters of the result backwards in the buffer.
*/
intVal = (n < 0 ? -(Tcl_WideUInt)n : (Tcl_WideUInt)n);
|
| ︙ | ︙ | |||
3341 3342 3343 3344 3345 3346 3347 |
static int
GetWideForIndex(
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, then no error message is left after
* errors. */
Tcl_Obj *objPtr, /* Points to the value to be parsed */
| | | 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 |
static int
GetWideForIndex(
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, then no error message is left after
* errors. */
Tcl_Obj *objPtr, /* Points to the value to be parsed */
Tcl_WideInt endValue, /* The value to be stored at *widePtr if
* objPtr holds "end".
* NOTE: this value may be TCL_INDEX_NONE. */
Tcl_WideInt *widePtr) /* Location filled in with a wide integer
* representing an index. */
{
int numType;
void *cd;
|
| ︙ | ︙ | |||
3378 3379 3380 3381 3382 3383 3384 | * * Tcl_GetIntForIndex -- * * Provides an integer corresponding to the list index held in a Tcl * object. The string value 'objPtr' is expected have the format * integer([+-]integer)? or end([+-]integer)?. * | > > > > > > > > | | < | | < | < | > | | | | | > | > | | | 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 |
*
* Tcl_GetIntForIndex --
*
* Provides an integer corresponding to the list index held in a Tcl
* object. The string value 'objPtr' is expected have the format
* integer([+-]integer)? or end([+-]integer)?.
*
* If the computed index lies within the valid range of Tcl indices
* (0..TCL_SIZE_MAX) it is returned. Higher values are returned as
* TCL_SIZE_MAX. Negative values are returned as TCL_INDEX_NONE (-1).
*
* Callers should pass reasonable values for endValue - one in the
* valid index range or TCL_INDEX_NONE (-1), for example for an empty
* list.
*
* Results:
* TCL_OK
*
* The index is stored at the address given by by 'indexPtr'.
*
* TCL_ERROR
*
* The value of 'objPtr' does not have one of the expected formats. If
* 'interp' is non-NULL, an error message is left in the interpreter's
* result object.
*
* Side effects:
*
* The internal representation contained within objPtr may shimmer.
*
*----------------------------------------------------------------------
*/
int
Tcl_GetIntForIndex(
Tcl_Interp *interp, /* Interpreter to use for error reporting. If
* NULL, then no error message is left after
* errors. */
Tcl_Obj *objPtr, /* Points to an object containing either "end"
* or an integer. */
Tcl_Size endValue, /* The value corresponding to the "end" index */
Tcl_Size *indexPtr) /* Location filled in with an integer
* representing an index. May be NULL.*/
{
Tcl_WideInt wide;
if (GetWideForIndex(interp, objPtr, endValue, &wide) == TCL_ERROR) {
return TCL_ERROR;
}
if (indexPtr != NULL) {
/* Note: check against TCL_SIZE_MAX needed for 32-bit builds */
if (wide >= 0 && wide <= TCL_SIZE_MAX) {
*indexPtr = (Tcl_Size)wide;
} else if (wide > TCL_SIZE_MAX) {
*indexPtr = TCL_SIZE_MAX;
} else {
*indexPtr = TCL_INDEX_NONE;
}
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* GetEndOffsetFromObj --
*
* Look for a string of the form "end[+-]offset" or "offset[+-]offset" and
* convert it to an internal representation.
*
* The internal representation (wideValue) uses the following encoding:
*
* WIDE_MIN: Index value TCL_INDEX_NONE (or -1)
* WIDE_MIN+1: Index value n, for any n < -1 (usually same effect as -1)
* -$n: Index "end-[expr {$n-1}]"
* -2: Index "end-1"
* -1: Index "end"
* 0: Index "0"
* WIDE_MAX-1: Index "end+n", for any n > 1. Distinguish from end+1 for
* commands like lset.
* WIDE_MAX: Index "end+1"
*
* Results:
* Tcl return code.
*
* Side effects:
* May store a Tcl_ObjType.
*
*----------------------------------------------------------------------
*/
static int
GetEndOffsetFromObj(
Tcl_Interp *interp,
Tcl_Obj *objPtr, /* Pointer to the object to parse */
Tcl_WideInt endValue, /* The value to be stored at "widePtr" if
* "objPtr" holds "end". */
Tcl_WideInt *widePtr) /* Location filled in with an integer
* representing an index. */
{
Tcl_ObjInternalRep *irPtr;
Tcl_WideInt offset = -1; /* Offset in the "end-offset" expression - 1 */
void *cd;
while ((irPtr = TclFetchInternalRep(objPtr, &endOffsetType)) == NULL) {
Tcl_ObjInternalRep ir;
Tcl_Size length;
const char *bytes = Tcl_GetStringFromObj(objPtr, &length);
if (*bytes != 'e') {
int numType;
const char *opPtr;
int t1 = 0, t2 = 0;
|
| ︙ | ︙ | |||
3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 |
ir.wideValue = offset;
Tcl_StoreInternalRep(objPtr, &endOffsetType, &ir);
}
offset = irPtr->wideValue;
if (offset == WIDE_MAX) {
*widePtr = endValue + 1;
} else if (offset == WIDE_MIN) {
*widePtr = -1;
} else if (offset < 0) {
| > > > > > > > > > | > > | 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 |
ir.wideValue = offset;
Tcl_StoreInternalRep(objPtr, &endOffsetType, &ir);
}
offset = irPtr->wideValue;
if (offset == WIDE_MAX) {
/*
* Encodes end+1. This is distinguished from end+n as noted above
* NOTE: this may wrap around if the caller passes (as lset does)
* listLen-1 as endValue and and listLen is 0. The -1 will be
* interpreted as FF...FF and adding 1 will result in 0 which
* is what we want. 2's complements shenanigans but it is what
* it is ...
*/
*widePtr = endValue + 1;
} else if (offset == WIDE_MIN) {
/* -1 - position before first */
*widePtr = -1;
} else if (offset < 0) {
/* end-(n-1) - Different signs, sum cannot overflow */
*widePtr = endValue + offset + 1;
} else if (offset < WIDE_MAX) {
/* 0:WIDE_MAX-1 - plain old index. */
*widePtr = offset;
} else {
/* Huh, what case remains here? */
*widePtr = WIDE_MAX;
}
return TCL_OK;
/* Report a parse error. */
parseError:
if (interp != NULL) {
|
| ︙ | ︙ | |||
3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 |
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* TclIndexEncode --
*
* Parse objPtr to determine if it is an index value. Two cases
* are possible. The value objPtr might be parsed as an absolute
| > > > > | | < < < > | | | > > > > > | | 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 |
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* TclIndexEncode --
* IMPORTANT: function only encodes indices in the range that fits within
* an "int" type. Do NOT change this as the byte code compiler and engine
* which call this function cannot handle wider index types. Indices
* outside the range will result in the function returning an error.
*
* Parse objPtr to determine if it is an index value. Two cases
* are possible. The value objPtr might be parsed as an absolute
* index value in the Tcl_Size range. Note that this includes
* index values that are integers as presented and it includes index
* arithmetic expressions.
*
* The largest string supported in Tcl 8 has byte length TCL_SIZE_MAX.
* This means the largest supported character length is also TCL_SIZE_MAX,
* and the index of the last character in a string of length TCL_SIZE_MAX
* is TCL_SIZE_MAX-1. Thus the absolute index values that can be
* directly meaningful as an index into either a list or a string are
* integer values in the range 0 to TCL_SIZE_MAX - 1.
*
* This function however can only handle integer indices in the range
* 0 : INT_MAX-1.
*
* Any absolute index value parsed outside that range is encoded
* using the before and after values passed in by the
* caller as the encoding to use for indices that are either
* less than or greater than the usable index range. TCL_INDEX_NONE
* is available as a good choice for most callers to use for
* after. Likewise, the value TCL_INDEX_NONE is good for
|
| ︙ | ︙ | |||
3729 3730 3731 3732 3733 3734 3735 | * index "end" is encoded as -2, down to the index "end-0x7FFFFFFE" * which is encoded as INT_MIN. Since the largest index into a * string possible in Tcl 8 is 0x7FFFFFFE, the interpretation of * "end-0x7FFFFFFE" for that largest string would be 0. Thus, * if the tokens "end-0x7FFFFFFF" or "end+-0x80000000" are parsed, * they can be encoded with the before value. * | < < < < | > | | > > | < < | < | | > > > > > > > > > > > > > > > > > > > > > > > | > | > | | < < | < | | > > > > > > > | | | > > | | < > > > | > > > > > > > > > > > > | | | > | > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 |
* index "end" is encoded as -2, down to the index "end-0x7FFFFFFE"
* which is encoded as INT_MIN. Since the largest index into a
* string possible in Tcl 8 is 0x7FFFFFFE, the interpretation of
* "end-0x7FFFFFFE" for that largest string would be 0. Thus,
* if the tokens "end-0x7FFFFFFF" or "end+-0x80000000" are parsed,
* they can be encoded with the before value.
*
* Returns:
* TCL_OK if parsing succeeded, and TCL_ERROR if it failed or the
* index does not fit in an int type.
*
* Side effects:
* When TCL_OK is returned, the encoded index value is written
* to *indexPtr.
*
*----------------------------------------------------------------------
*/
int
TclIndexEncode(
Tcl_Interp *interp, /* For error reporting, may be NULL */
Tcl_Obj *objPtr, /* Index value to parse */
int before, /* Value to return for index before beginning */
int after, /* Value to return for index after end */
int *indexPtr) /* Where to write the encoded answer, not NULL */
{
Tcl_WideInt wide;
int idx;
const Tcl_WideInt ENDVALUE = 2 * (Tcl_WideInt) INT_MAX;
assert(ENDVALUE < WIDE_MAX);
if (TCL_OK != GetWideForIndex(interp, objPtr, ENDVALUE, &wide)) {
return TCL_ERROR;
}
/*
* We passed 2*INT_MAX as the "end value" to GetWideForIndex. The computed
* index will in one of the following ranges that need to be distinguished
* for encoding purposes in the following code.
* (1) 0:INT_MAX when
* (a) objPtr was a pure non-negative numeric value in that range
* (b) objPtr was a numeric computation M+/-N with a result in that range
* (c) objPtr was of the form end-N where N was in range INT_MAX:2*INT_MAX
* (2) INT_MAX+1:2*INT_MAX when
* (a,b) as above
* (c) objPtr was of the form end-N where N was in range 0:INT_MAX-1
* (3) 2*INT_MAX:WIDE_MAX when
* (a,b) as above
* (c) objPtr was of the form end+N
* (4) (2*INT_MAX)-TCL_SIZE_MAX : -1 when
* (a,b) as above
* (c) objPtr was of the form end-N where N was in the range 0:TCL_SIZE_MAX
* (5) WIDE_MIN:(2*INT_MAX)-TCL_SIZE_MAX
* (a,b) as above
* (c) objPtr was of the form end-N where N was > TCL_SIZE_MAX
*
* For all cases (b) and (c), the internal representation of objPtr
* will be shimmered to endOffsetType. That allows us to distinguish between
* (for example) 1a (encodable) and 1c (not encodable) though the computed
* index value is the same.
*
* Further note, the values TCL_SIZE_MAX < N < WIDE_MAX come into play
* only in the 32-bit builds as TCL_SIZE_MAX == WIDE_MAX for 64-bits.
*/
const Tcl_ObjInternalRep *irPtr =
TclFetchInternalRep(objPtr, &endOffsetType);
if (irPtr && irPtr->wideValue >= 0) {
/*
* "int[+-]int" syntax, works the same here as "int".
* Note same does not hold for negative integers.
* Distinguishes 1b and 1c where wide will be in 0:INT_MAX for
* both but irPtr->wideValue will be negative for 1c.
*/
irPtr = NULL;
}
if (irPtr == NULL) {
/* objPtr can be treated as a purely numeric value. */
/*
* On 64-bit systems, indices in the range INT_MAX:TCL_SIZE_MAX are
* valid indices but are not in the encodable range. Thus an
* error is raised. On 32-bit systems, indices in that range indicate
* the position after the end and so do not raise an error.
*/
if ((sizeof(int) != sizeof(size_t)) &&
(wide > INT_MAX) && (wide < WIDE_MAX-1)) {
/* 2(a,b) on 64-bit systems*/
goto rangeerror;
}
if (wide > INT_MAX) {
/*
* 3(a,b) on 64-bit systems and 2(a,b), 3(a,b) on 32-bit systems
* Because of the check above, this case holds for indices
* greater than INT_MAX on 32-bit systems and > TCL_SIZE_MAX
* on 64-bit systems. Always maps to the element after the end.
*/
idx = after;
} else if (wide < 0) {
/* 4(a,b) (32-bit systems), 5(a,b) - before the beginning */
idx = before;
} else {
/* 1(a,b) Encodable range */
idx = (int)wide;
}
} else {
/* objPtr is not purely numeric (end etc.) */
/*
* On 64-bit systems, indices in the range end-LIST_MAX:end-INT_MAX
* are valid indices (with max size strings/lists) but are not in
* the encodable range. Thus an error is raised. On 32-bit systems,
* indices in that range indicate the position before the beginning
* and so do not raise an error.
*/
if ((sizeof(int) != sizeof(size_t)) &&
(wide > (ENDVALUE - LIST_MAX)) && (wide <= INT_MAX)) {
/* 1(c), 4(a,b) on 64-bit systems */
goto rangeerror;
}
if (wide > ENDVALUE) {
/*
* 2(c) (32-bit systems), 3(c)
* All end+positive or end-negative expressions
* always indicate "after the end".
* Note we will not reach here for a pure numeric value in this
* range because irPtr will be NULL in that case.
*/
idx = after;
} else if (wide <= INT_MAX) {
/* 1(c) (32-bit systems), 4(c) (32-bit systems), 5(c) */
idx = before;
} else {
/* 2(c) Encodable end-positive (or end+negative) */
idx = (int)wide;
}
}
*indexPtr = idx;
return TCL_OK;
rangeerror:
if (interp) {
Tcl_SetObjResult(
interp,
Tcl_ObjPrintf("index \"%s\" out of range", TclGetString(objPtr)));
Tcl_SetErrorCode(interp,
"TCL",
"VALUE",
"INDEX"
"OUTOFRANGE",
NULL);
}
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* TclIndexDecode --
*
* Decodes a value previously encoded by TclIndexEncode. The argument
* endValue indicates what value of "end" should be used in the
* decoding.
*
* Results:
* The decoded index value.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclIndexDecode(
int encoded, /* Value to decode */
Tcl_Size endValue) /* Meaning of "end" to use, > TCL_INDEX_END */
{
if (encoded > TCL_INDEX_END) {
return encoded;
}
endValue += encoded - TCL_INDEX_END;
if (endValue >= 0) {
return endValue;
}
return TCL_INDEX_NONE;
}
/*
*------------------------------------------------------------------------
*
* TclIndexInvalidError --
*
* Generates an error message including the invalid index.
*
* Results:
* Always return TCL_ERROR.
*
* Side effects:
* If interp is not-NULL, an error message is stored in it.
*
*------------------------------------------------------------------------
*/
int
TclIndexInvalidError (
Tcl_Interp *interp, /* May be NULL */
const char *idxType, /* The descriptive string for idx. Defaults to "index" */
Tcl_Size idx) /* Invalid index value */
{
if (interp) {
Tcl_SetObjResult(interp,
Tcl_ObjPrintf("Invalid %s value %" TCL_SIZE_MODIFIER "d.",
idxType ? idxType : "index",
idx));
}
return TCL_ERROR; /* Always */
}
/*
*----------------------------------------------------------------------
*
* ClearHash --
*
* Remove all the entries in the hash table *tablePtr.
|
| ︙ | ︙ | |||
4013 4014 4015 4016 4017 4018 4019 |
Tcl_Obj *
TclGetProcessGlobalValue(
ProcessGlobalValue *pgvPtr)
{
Tcl_Obj *value = NULL;
Tcl_HashTable *cacheMap;
Tcl_HashEntry *hPtr;
| | | 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 |
Tcl_Obj *
TclGetProcessGlobalValue(
ProcessGlobalValue *pgvPtr)
{
Tcl_Obj *value = NULL;
Tcl_HashTable *cacheMap;
Tcl_HashEntry *hPtr;
Tcl_Size epoch = pgvPtr->epoch;
if (pgvPtr->encoding) {
Tcl_Encoding current = Tcl_GetEncoding(NULL, NULL);
if (pgvPtr->encoding != current) {
/*
* The system encoding has changed since the global string value
|
| ︙ | ︙ | |||
4220 4221 4222 4223 4224 4225 4226 |
*----------------------------------------------------------------------
*/
int
TclReToGlob(
Tcl_Interp *interp,
const char *reStr,
| | | 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 |
*----------------------------------------------------------------------
*/
int
TclReToGlob(
Tcl_Interp *interp,
const char *reStr,
Tcl_Size reStrLen,
Tcl_DString *dsPtr,
int *exactPtr,
int *quantifiersFoundPtr)
{
int anchorLeft, anchorRight, lastIsStar, numStars;
char *dsStr, *dsStrStart;
const char *msg, *p, *strEnd, *code;
|
| ︙ | ︙ | |||
4413 4414 4415 4416 4417 4418 4419 |
*exactPtr = (anchorLeft && anchorRight);
}
return TCL_OK;
invalidGlob:
if (interp != NULL) {
| | | 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 |
*exactPtr = (anchorLeft && anchorRight);
}
return TCL_OK;
invalidGlob:
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(msg, -1));
Tcl_SetErrorCode(interp, "TCL", "RE2GLOB", code, NULL);
}
Tcl_DStringFree(dsPtr);
return TCL_ERROR;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
|
Changes to generic/tclVar.c.
| ︙ | ︙ | |||
260 261 262 263 264 265 266 |
} while (0)
#define LocalGetInternalRep(objPtr, index, name) \
do { \
const Tcl_ObjInternalRep *irPtr; \
irPtr = TclFetchInternalRep((objPtr), &localVarNameType); \
(name) = irPtr ? (Tcl_Obj *)irPtr->twoPtrValue.ptr1 : NULL; \
| | | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
} while (0)
#define LocalGetInternalRep(objPtr, index, name) \
do { \
const Tcl_ObjInternalRep *irPtr; \
irPtr = TclFetchInternalRep((objPtr), &localVarNameType); \
(name) = irPtr ? (Tcl_Obj *)irPtr->twoPtrValue.ptr1 : NULL; \
(index) = irPtr ? PTR2INT(irPtr->twoPtrValue.ptr2) : TCL_INDEX_NONE; \
} while (0)
static const Tcl_ObjType parsedVarNameType = {
"parsedVarName",
FreeParsedVarName, DupParsedVarName, NULL, NULL,
TCL_OBJTYPE_V0
};
|
| ︙ | ︙ | |||
299 300 301 302 303 304 305 |
TclVarHashTable *tablePtr,
const char *key,
int *newPtr)
{
Tcl_Obj *keyPtr;
Var *varPtr;
| | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
TclVarHashTable *tablePtr,
const char *key,
int *newPtr)
{
Tcl_Obj *keyPtr;
Var *varPtr;
keyPtr = Tcl_NewStringObj(key, -1);
Tcl_IncrRefCount(keyPtr);
varPtr = VarHashCreateVar(tablePtr, keyPtr, newPtr);
Tcl_DecrRefCount(keyPtr);
return varPtr;
}
|
| ︙ | ︙ | |||
467 468 469 470 471 472 473 |
* return error if it doesn't exist. */
Var **arrayPtrPtr) /* If the name refers to an element of an
* array, *arrayPtrPtr gets filled in with
* address of array variable. Otherwise this
* is set to NULL. */
{
Var *varPtr;
| | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
* return error if it doesn't exist. */
Var **arrayPtrPtr) /* If the name refers to an element of an
* array, *arrayPtrPtr gets filled in with
* address of array variable. Otherwise this
* is set to NULL. */
{
Var *varPtr;
Tcl_Obj *part1Ptr = Tcl_NewStringObj(part1, -1);
if (createPart1) {
Tcl_IncrRefCount(part1Ptr);
}
varPtr = TclObjLookupVar(interp, part1Ptr, part2, flags, msg,
createPart1, createPart2, arrayPtrPtr);
|
| ︙ | ︙ | |||
549 550 551 552 553 554 555 |
* address of array variable. Otherwise this
* is set to NULL. */
{
Tcl_Obj *part2Ptr = NULL;
Var *resPtr;
if (part2) {
| | | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
* address of array variable. Otherwise this
* is set to NULL. */
{
Tcl_Obj *part2Ptr = NULL;
Var *resPtr;
if (part2) {
part2Ptr = Tcl_NewStringObj(part2, -1);
if (createPart2) {
Tcl_IncrRefCount(part2Ptr);
}
}
resPtr = TclObjLookupVarEx(interp, part1Ptr, part2Ptr,
flags, msg, createPart1, createPart2, arrayPtrPtr);
|
| ︙ | ︙ | |||
602 603 604 605 606 607 608 |
Interp *iPtr = (Interp *) interp;
CallFrame *varFramePtr = iPtr->varFramePtr;
Var *varPtr; /* Points to the variable's in-frame Var
* structure. */
const char *errMsg = NULL;
int index, parsed = 0;
| | | | | 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 |
Interp *iPtr = (Interp *) interp;
CallFrame *varFramePtr = iPtr->varFramePtr;
Var *varPtr; /* Points to the variable's in-frame Var
* structure. */
const char *errMsg = NULL;
int index, parsed = 0;
Tcl_Size localIndex;
Tcl_Obj *namePtr, *arrayPtr, *elem;
*arrayPtrPtr = NULL;
restart:
LocalGetInternalRep(part1Ptr, localIndex, namePtr);
if (localIndex >= 0) {
if (HasLocalVars(varFramePtr)
&& !(flags & (TCL_GLOBAL_ONLY | TCL_NAMESPACE_ONLY))
&& (localIndex < varFramePtr->numCompiledLocals)) {
/*
* Use the cached index if the names coincide.
*/
Tcl_Obj *checkNamePtr = localName(varFramePtr, localIndex);
if ((!namePtr && (checkNamePtr == part1Ptr)) ||
(namePtr && (checkNamePtr == namePtr))) {
varPtr = (Var *) &(varFramePtr->compiledLocals[localIndex]);
goto donePart1;
}
}
goto doneParsing;
}
/*
* If part1Ptr is a parsedVarNameType, retrieve the preparsed parts.
*/
ParsedGetInternalRep(part1Ptr, parsed, arrayPtr, elem);
if (parsed && arrayPtr) {
if (part2Ptr != NULL) {
/*
* ERROR: part1Ptr is already an array element, cannot specify
|
| ︙ | ︙ | |||
657 658 659 660 661 662 663 |
}
if (!parsed) {
/*
* part1Ptr is possibly an unparsed array element.
*/
| | | 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
}
if (!parsed) {
/*
* part1Ptr is possibly an unparsed array element.
*/
Tcl_Size len;
const char *part1 = Tcl_GetStringFromObj(part1Ptr, &len);
if ((len > 1) && (part1[len - 1] == ')')) {
const char *part2 = strchr(part1, '(');
if (part2) {
if (part2Ptr != NULL) {
|
| ︙ | ︙ | |||
790 791 792 793 794 795 796 | * * If the current CallFrame corresponds to a proc and the variable found * is one of the compiledLocals, its index is placed in *indexPtr. * Otherwise, *indexPtr will be set to (according to the needs of * TclObjLookupVar): * -1 a global reference * -2 a reference to a namespace variable | | | 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 | * * If the current CallFrame corresponds to a proc and the variable found * is one of the compiledLocals, its index is placed in *indexPtr. * Otherwise, *indexPtr will be set to (according to the needs of * TclObjLookupVar): * -1 a global reference * -2 a reference to a namespace variable * -3 a non-cacheable reference, i.e., one of: * . non-indexed local var * . a reference of unknown origin; * . resolution by a namespace or interp resolver * * If the variable isn't found and creation wasn't specified, or some * other error occurs, NULL is returned and the corresponding error * message is left in *errMsgPtr. |
| ︙ | ︙ | |||
840 841 842 843 844 845 846 |
* to look up the variable. */
Tcl_Var var; /* Used to search for global names. */
Var *varPtr; /* Points to the Var structure returned for
* the variable. */
Namespace *varNsPtr, *cxtNsPtr, *dummy1Ptr, *dummy2Ptr;
ResolverScheme *resPtr;
int isNew, i, result;
| | | 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 |
* to look up the variable. */
Tcl_Var var; /* Used to search for global names. */
Var *varPtr; /* Points to the Var structure returned for
* the variable. */
Namespace *varNsPtr, *cxtNsPtr, *dummy1Ptr, *dummy2Ptr;
ResolverScheme *resPtr;
int isNew, i, result;
Tcl_Size varLen;
const char *varName = Tcl_GetStringFromObj(varNamePtr, &varLen);
varPtr = NULL;
varNsPtr = NULL; /* Set non-NULL if a nonlocal variable. */
*indexPtr = -3;
if (flags & TCL_GLOBAL_ONLY) {
|
| ︙ | ︙ | |||
947 948 949 950 951 952 953 |
*errMsgPtr = BADNAMESPACE;
return NULL;
} else if (tail == NULL) {
*errMsgPtr = MISSINGNAME;
return NULL;
}
if (tail != varName) {
| | | 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 |
*errMsgPtr = BADNAMESPACE;
return NULL;
} else if (tail == NULL) {
*errMsgPtr = MISSINGNAME;
return NULL;
}
if (tail != varName) {
tailPtr = Tcl_NewStringObj(tail, -1);
} else {
tailPtr = varNamePtr;
}
varPtr = VarHashCreateVar(&varNsPtr->varTable, tailPtr, &isNew);
if (lookGlobal) {
/*
* The variable was created starting from the global
|
| ︙ | ︙ | |||
970 971 972 973 974 975 976 |
}
} else { /* Local var: look in frame varFramePtr. */
int localCt = varFramePtr->numCompiledLocals;
if (localCt > 0) {
Tcl_Obj **objPtrPtr = &varFramePtr->localCachePtr->varName0;
const char *localNameStr;
| | | 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 |
}
} else { /* Local var: look in frame varFramePtr. */
int localCt = varFramePtr->numCompiledLocals;
if (localCt > 0) {
Tcl_Obj **objPtrPtr = &varFramePtr->localCachePtr->varName0;
const char *localNameStr;
Tcl_Size localLen;
for (i=0 ; i<localCt ; i++, objPtrPtr++) {
Tcl_Obj *objPtr = *objPtrPtr;
if (objPtr) {
localNameStr = Tcl_GetStringFromObj(objPtr, &localLen);
|
| ︙ | ︙ | |||
1171 1172 1173 1174 1175 1176 1177 |
const char *part2, /* If non-NULL, gives the name of an element
* in the array part1. */
int flags) /* OR-ed combination of TCL_GLOBAL_ONLY,
* TCL_NAMESPACE_ONLY and TCL_LEAVE_ERR_MSG *
* bits. */
{
Tcl_Obj *resultPtr;
| | | | 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 |
const char *part2, /* If non-NULL, gives the name of an element
* in the array part1. */
int flags) /* OR-ed combination of TCL_GLOBAL_ONLY,
* TCL_NAMESPACE_ONLY and TCL_LEAVE_ERR_MSG *
* bits. */
{
Tcl_Obj *resultPtr;
Tcl_Obj *part2Ptr = NULL, *part1Ptr = Tcl_NewStringObj(part1, -1);
if (part2) {
part2Ptr = Tcl_NewStringObj(part2, -1);
Tcl_IncrRefCount(part2Ptr);
}
resultPtr = Tcl_ObjGetVar2(interp, part1Ptr, part2Ptr, flags);
Tcl_DecrRefCount(part1Ptr);
if (part2Ptr) {
|
| ︙ | ︙ | |||
1224 1225 1226 1227 1228 1229 1230 |
const char *part1, /* Name of an array (if part2 is non-NULL) or
* the name of a variable. */
const char *part2, /* If non-NULL, gives the name of an element
* in the array part1. */
int flags) /* OR-ed combination of TCL_GLOBAL_ONLY, and
* TCL_LEAVE_ERR_MSG bits. */
{
| | | | 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 |
const char *part1, /* Name of an array (if part2 is non-NULL) or
* the name of a variable. */
const char *part2, /* If non-NULL, gives the name of an element
* in the array part1. */
int flags) /* OR-ed combination of TCL_GLOBAL_ONLY, and
* TCL_LEAVE_ERR_MSG bits. */
{
Tcl_Obj *resPtr, *part2Ptr = NULL, *part1Ptr = Tcl_NewStringObj(part1, -1);
if (part2) {
part2Ptr = Tcl_NewStringObj(part2, -1);
Tcl_IncrRefCount(part2Ptr);
}
resPtr = Tcl_ObjGetVar2(interp, part1Ptr, part2Ptr, flags);
Tcl_DecrRefCount(part1Ptr);
if (part2Ptr) {
|
| ︙ | ︙ | |||
1545 1546 1547 1548 1549 1550 1551 |
const char *newValue, /* New value for variable. */
int flags) /* Various flags that tell how to set value:
* any of TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY,
* TCL_APPEND_VALUE, TCL_LIST_ELEMENT, or
* TCL_LEAVE_ERR_MSG. */
{
Tcl_Obj *varValuePtr = Tcl_SetVar2Ex(interp, part1, part2,
| | | 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 |
const char *newValue, /* New value for variable. */
int flags) /* Various flags that tell how to set value:
* any of TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY,
* TCL_APPEND_VALUE, TCL_LIST_ELEMENT, or
* TCL_LEAVE_ERR_MSG. */
{
Tcl_Obj *varValuePtr = Tcl_SetVar2Ex(interp, part1, part2,
Tcl_NewStringObj(newValue, -1), flags);
if (varValuePtr == NULL) {
return NULL;
}
return TclGetString(varValuePtr);
}
|
| ︙ | ︙ | |||
1605 1606 1607 1608 1609 1610 1611 |
* in the array part1. */
Tcl_Obj *newValuePtr, /* New value for variable. */
int flags) /* Various flags that tell how to set value:
* any of TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY,
* TCL_APPEND_VALUE, TCL_LIST_ELEMENT or
* TCL_LEAVE_ERR_MSG. */
{
| | | | 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 |
* in the array part1. */
Tcl_Obj *newValuePtr, /* New value for variable. */
int flags) /* Various flags that tell how to set value:
* any of TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY,
* TCL_APPEND_VALUE, TCL_LIST_ELEMENT or
* TCL_LEAVE_ERR_MSG. */
{
Tcl_Obj *resPtr, *part2Ptr = NULL, *part1Ptr = Tcl_NewStringObj(part1, -1);
Tcl_IncrRefCount(part1Ptr);
if (part2) {
part2Ptr = Tcl_NewStringObj(part2, -1);
Tcl_IncrRefCount(part2Ptr);
}
resPtr = Tcl_ObjSetVar2(interp, part1Ptr, part2Ptr, newValuePtr, flags);
Tcl_DecrRefCount(part1Ptr);
if (part2Ptr) {
|
| ︙ | ︙ | |||
2289 2290 2291 2292 2293 2294 2295 |
const char *part1, /* Name of variable or array. */
const char *part2, /* Name of element within array or NULL. */
int flags) /* OR-ed combination of any of
* TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY,
* TCL_LEAVE_ERR_MSG. */
{
int result;
| | | | 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 |
const char *part1, /* Name of variable or array. */
const char *part2, /* Name of element within array or NULL. */
int flags) /* OR-ed combination of any of
* TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY,
* TCL_LEAVE_ERR_MSG. */
{
int result;
Tcl_Obj *part2Ptr = NULL, *part1Ptr = Tcl_NewStringObj(part1, -1);
if (part2) {
part2Ptr = Tcl_NewStringObj(part2, -1);
}
/*
* Filter to pass through only the flags this interface supports.
*/
flags &= (TCL_GLOBAL_ONLY|TCL_NAMESPACE_ONLY|TCL_LEAVE_ERR_MSG);
|
| ︙ | ︙ | |||
2828 2829 2830 2831 2832 2833 2834 |
Tcl_LappendObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *varValuePtr, *newValuePtr;
| | | 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 |
Tcl_LappendObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *varValuePtr, *newValuePtr;
Tcl_Size numElems;
Var *varPtr, *arrayPtr;
int result, createdNewObj;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "varName ?value ...?");
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
3047 3048 3049 3050 3051 3052 3053 |
int objc,
Tcl_Obj *const *objv)
{
Tcl_Obj *varListObj, *arrayNameObj, *scriptObj;
ArraySearch *searchPtr = NULL;
Var *varPtr;
int isArray;
| | | | 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 |
int objc,
Tcl_Obj *const *objv)
{
Tcl_Obj *varListObj, *arrayNameObj, *scriptObj;
ArraySearch *searchPtr = NULL;
Var *varPtr;
int isArray;
Tcl_Size numVars;
/*
* array for {k v} a body
*/
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv, "{key value} arrayName script");
return TCL_ERROR;
}
/*
* Parse arguments.
*/
if (TclListObjLengthM(interp, objv[1], &numVars) != TCL_OK) {
return TCL_ERROR;
}
if (numVars != 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must have two variable names", -1));
Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "array", "for", NULL);
return TCL_ERROR;
}
arrayNameObj = objv[2];
if (TCL_ERROR == LocateArray(interp, arrayNameObj, &varPtr, &isArray)) {
|
| ︙ | ︙ | |||
3124 3125 3126 3127 3128 3129 3130 |
Tcl_Obj *arrayNameObj = (Tcl_Obj *)data[2];
Tcl_Obj *scriptObj = (Tcl_Obj *)data[3];
Tcl_Obj **varv;
Tcl_Obj *keyObj, *valueObj;
Var *varPtr;
Var *arrayPtr;
int done;
| | | 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 |
Tcl_Obj *arrayNameObj = (Tcl_Obj *)data[2];
Tcl_Obj *scriptObj = (Tcl_Obj *)data[3];
Tcl_Obj **varv;
Tcl_Obj *keyObj, *valueObj;
Var *varPtr;
Var *arrayPtr;
int done;
Tcl_Size varc;
/*
* Process the result from the previous execution of the script body.
*/
done = TCL_ERROR;
|
| ︙ | ︙ | |||
3166 3167 3168 3169 3170 3171 3172 |
}
result = TCL_OK;
if (done != TCL_CONTINUE) {
Tcl_ResetResult(interp);
if (done == TCL_ERROR) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 |
}
result = TCL_OK;
if (done != TCL_CONTINUE) {
Tcl_ResetResult(interp);
if (done == TCL_ERROR) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"array changed during iteration", -1));
Tcl_SetErrorCode(interp, "TCL", "READ", "array", "for", NULL);
varPtr->flags |= TCL_LEAVE_ERR_MSG;
result = done;
}
goto arrayfordone;
}
|
| ︙ | ︙ | |||
3632 3633 3634 3635 3636 3637 3638 |
Tcl_Obj *const objv[])
{
Var *varPtr, *varPtr2;
Tcl_Obj *varNameObj, *nameObj, *valueObj, *nameLstObj, *tmpResObj;
Tcl_Obj **nameObjPtr, *patternObj;
Tcl_HashSearch search;
const char *pattern;
| | | 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 |
Tcl_Obj *const objv[])
{
Var *varPtr, *varPtr2;
Tcl_Obj *varNameObj, *nameObj, *valueObj, *nameLstObj, *tmpResObj;
Tcl_Obj **nameObjPtr, *patternObj;
Tcl_HashSearch search;
const char *pattern;
Tcl_Size i, count;
int result, isArray;
switch (objc) {
case 2:
varNameObj = objv[1];
patternObj = NULL;
break;
|
| ︙ | ︙ | |||
3958 3959 3960 3961 3962 3963 3964 |
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *arrayNameObj;
Tcl_Obj *arrayElemObj;
Var *varPtr, *arrayPtr;
int result;
| < | 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 |
int objc,
Tcl_Obj *const objv[])
{
Tcl_Obj *arrayNameObj;
Tcl_Obj *arrayElemObj;
Var *varPtr, *arrayPtr;
int result;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "arrayName list");
return TCL_ERROR;
}
if (TCL_ERROR == LocateArray(interp, objv[1], NULL, NULL)) {
|
| ︙ | ︙ | |||
3993 3994 3995 3996 3997 3998 3999 |
*/
arrayElemObj = objv[2];
if (TclHasInternalRep(arrayElemObj, &tclDictType) && arrayElemObj->bytes == NULL) {
Tcl_Obj *keyPtr, *valuePtr;
Tcl_DictSearch search;
int done;
| | | 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 |
*/
arrayElemObj = objv[2];
if (TclHasInternalRep(arrayElemObj, &tclDictType) && arrayElemObj->bytes == NULL) {
Tcl_Obj *keyPtr, *valuePtr;
Tcl_DictSearch search;
int done;
Tcl_Size size;
if (Tcl_DictObjSize(interp, arrayElemObj, &size) != TCL_OK) {
return TCL_ERROR;
}
if (size == 0) {
/*
* Empty, so we'll just force the array to be properly existing
|
| ︙ | ︙ | |||
4037 4038 4039 4040 4041 4042 4043 |
return TCL_OK;
} else {
/*
* Not a dictionary, so assume (and convert to, for backward-
* -compatibility reasons) a list.
*/
| | > | | 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 |
return TCL_OK;
} else {
/*
* Not a dictionary, so assume (and convert to, for backward-
* -compatibility reasons) a list.
*/
Tcl_Size elemLen;
Tcl_Obj **elemPtrs, *copyListObj;
Tcl_Size i;
result = TclListObjLengthM(interp, arrayElemObj, &elemLen);
if (result != TCL_OK) {
return result;
}
if (elemLen & 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"list must have an even number of elements", -1));
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "FORMAT", NULL);
return TCL_ERROR;
}
if (elemLen == 0) {
goto ensureArray;
}
result = TclListObjGetElementsM(interp, arrayElemObj,
|
| ︙ | ︙ | |||
4216 4217 4218 4219 4220 4221 4222 |
if (!isArray) {
return NotArrayError(interp, varNameObj);
}
stats = Tcl_HashStats((Tcl_HashTable *) varPtr->value.tablePtr);
if (stats == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | | 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 |
if (!isArray) {
return NotArrayError(interp, varNameObj);
}
stats = Tcl_HashStats((Tcl_HashTable *) varPtr->value.tablePtr);
if (stats == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"error reading array statistics", -1));
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(stats, -1));
Tcl_Free(stats);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
4783 4784 4785 4786 4787 4788 4789 |
}
if (TclIsVarInHash(varPtr)) {
if (!TclIsVarDeadHash(varPtr)) {
namePtr = VarHashGetKey(varPtr);
Tcl_AppendObjToObj(objPtr, namePtr);
}
} else if (iPtr->varFramePtr->procPtr) {
| | | 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 |
}
if (TclIsVarInHash(varPtr)) {
if (!TclIsVarDeadHash(varPtr)) {
namePtr = VarHashGetKey(varPtr);
Tcl_AppendObjToObj(objPtr, namePtr);
}
} else if (iPtr->varFramePtr->procPtr) {
Tcl_Size index = varPtr - iPtr->varFramePtr->compiledLocals;
if (index < iPtr->varFramePtr->numCompiledLocals) {
namePtr = localName(iPtr->varFramePtr, index);
Tcl_AppendObjToObj(objPtr, namePtr);
}
}
}
|
| ︙ | ︙ | |||
5607 5608 5609 5610 5611 5612 5613 |
* twoPtrValue.ptr2: index into locals table
*/
static void
FreeLocalVarName(
Tcl_Obj *objPtr)
{
| | | | 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 |
* twoPtrValue.ptr2: index into locals table
*/
static void
FreeLocalVarName(
Tcl_Obj *objPtr)
{
Tcl_Size index;
Tcl_Obj *namePtr;
LocalGetInternalRep(objPtr, index, namePtr);
index++; /* Compiler warning bait. */
if (namePtr) {
Tcl_DecrRefCount(namePtr);
}
}
static void
DupLocalVarName(
Tcl_Obj *srcPtr,
Tcl_Obj *dupPtr)
{
Tcl_Size index;
Tcl_Obj *namePtr;
LocalGetInternalRep(srcPtr, index, namePtr);
if (!namePtr) {
namePtr = srcPtr;
}
LocalSetInternalRep(dupPtr, index, namePtr);
|
| ︙ | ︙ | |||
6207 6208 6209 6210 6211 6212 6213 |
Tcl_Interp *interp, /* Current interpreter. */
Tcl_Obj *listPtr, /* List object to append names to. */
Tcl_Obj *patternPtr, /* Pattern to match against. */
int includeLinks) /* 1 if upvars should be included, else 0. */
{
Interp *iPtr = (Interp *) interp;
Var *varPtr;
| | | 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 |
Tcl_Interp *interp, /* Current interpreter. */
Tcl_Obj *listPtr, /* List object to append names to. */
Tcl_Obj *patternPtr, /* Pattern to match against. */
int includeLinks) /* 1 if upvars should be included, else 0. */
{
Interp *iPtr = (Interp *) interp;
Var *varPtr;
Tcl_Size i, localVarCt;
int added;
Tcl_Obj *objNamePtr;
const char *varName;
TclVarHashTable *localVarTablePtr;
Tcl_HashSearch search;
Tcl_HashTable addedTable;
const char *pattern = patternPtr? TclGetString(patternPtr) : NULL;
|
| ︙ | ︙ |
Changes to generic/tclZipfs.c.
| ︙ | ︙ | |||
38 39 40 41 42 43 44 |
/*
* Macros to report errors only if an interp is present.
*/
#define ZIPFS_ERROR(interp,errstr) \
do { \
if (interp) { \
| | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
/*
* Macros to report errors only if an interp is present.
*/
#define ZIPFS_ERROR(interp,errstr) \
do { \
if (interp) { \
Tcl_SetObjResult(interp, Tcl_NewStringObj(errstr, -1)); \
} \
} while (0)
#define ZIPFS_MEM_ERROR(interp) \
do { \
if (interp) { \
Tcl_SetObjResult(interp, Tcl_NewStringObj( \
"out of memory", -1)); \
Tcl_SetErrorCode(interp, "TCL", "MALLOC", NULL); \
} \
} while (0)
#define ZIPFS_POSIX_ERROR(interp,errstr) \
do { \
if (interp) { \
Tcl_SetObjResult(interp, Tcl_ObjPrintf( \
|
| ︙ | ︙ | |||
1378 1379 1380 1381 1382 1383 1384 |
} else {
/*
* Not an OS file, but rather something in a Tcl VFS. Must copy into
* memory.
*/
zf->length = Tcl_Seek(zf->chan, 0, SEEK_END);
| | | 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 |
} else {
/*
* Not an OS file, but rather something in a Tcl VFS. Must copy into
* memory.
*/
zf->length = Tcl_Seek(zf->chan, 0, SEEK_END);
if (zf->length == (size_t) TCL_INDEX_NONE) {
ZIPFS_POSIX_ERROR(interp, "seek error");
goto error;
}
if ((zf->length - ZIP_CENTRAL_END_LEN)
> (64 * 1024 * 1024 - ZIP_CENTRAL_END_LEN)) {
ZIPFS_ERROR(interp, "illegal file size");
ZIPFS_ERROR_CODE(interp, "FILE_SIZE");
|
| ︙ | ︙ | |||
1477 1478 1479 1480 1481 1482 1483 |
int fd = PTR2INT(handle);
/*
* Determine the file size.
*/
zf->length = lseek(fd, 0, SEEK_END);
| | | 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 |
int fd = PTR2INT(handle);
/*
* Determine the file size.
*/
zf->length = lseek(fd, 0, SEEK_END);
if (zf->length == (size_t) TCL_INDEX_NONE || zf->length < ZIP_CENTRAL_END_LEN) {
ZIPFS_POSIX_ERROR(interp, "invalid file size");
return TCL_ERROR;
}
lseek(fd, 0, SEEK_SET);
zf->data = (unsigned char *)
mmap(0, zf->length, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0);
|
| ︙ | ︙ | |||
1704 1705 1706 1707 1708 1709 1710 | * APK due to the leading dot in the file name component. This * trick should make the files AndroidManifest.xml, * resources.arsc, and classes.dex visible to Tcl. */ Tcl_DString ds2; Tcl_DStringInit(&ds2); | | | | 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 |
* APK due to the leading dot in the file name component. This
* trick should make the files AndroidManifest.xml,
* resources.arsc, and classes.dex visible to Tcl.
*/
Tcl_DString ds2;
Tcl_DStringInit(&ds2);
Tcl_DStringAppend(&ds2, "assets/.root/", -1);
Tcl_DStringAppend(&ds2, path, -1);
if (ZipFSLookup(Tcl_DStringValue(&ds2))) {
/* should not happen but skip it anyway */
Tcl_DStringFree(&ds2);
goto nextent;
}
Tcl_DStringSetLength(&ds, 0);
Tcl_DStringAppend(&ds, Tcl_DStringValue(&ds2),
|
| ︙ | ︙ | |||
1781 1782 1783 1784 1785 1786 1787 |
if (!z->isDirectory && (z->depth > 1)) {
char *dir, *endPtr;
ZipEntry *zd;
Tcl_DStringSetLength(&ds, strlen(z->name) + 8);
Tcl_DStringSetLength(&ds, 0);
| | | 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 |
if (!z->isDirectory && (z->depth > 1)) {
char *dir, *endPtr;
ZipEntry *zd;
Tcl_DStringSetLength(&ds, strlen(z->name) + 8);
Tcl_DStringSetLength(&ds, 0);
Tcl_DStringAppend(&ds, z->name, -1);
dir = Tcl_DStringValue(&ds);
for (endPtr = strrchr(dir, '/'); endPtr && (endPtr != dir);
endPtr = strrchr(dir, '/')) {
Tcl_DStringSetLength(&ds, endPtr - dir);
hPtr = Tcl_CreateHashEntry(&ZipFS.fileHash, dir, &isNew);
if (!isNew) {
/*
|
| ︙ | ︙ | |||
1903 1904 1905 1906 1907 1908 1909 |
}
resultList = Tcl_NewObj();
for (hPtr = Tcl_FirstHashEntry(&ZipFS.zipHash, &search); hPtr;
hPtr = Tcl_NextHashEntry(&search)) {
zf = (ZipFile *) Tcl_GetHashValue(hPtr);
Tcl_ListObjAppendElement(NULL, resultList, Tcl_NewStringObj(
| | | | 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 |
}
resultList = Tcl_NewObj();
for (hPtr = Tcl_FirstHashEntry(&ZipFS.zipHash, &search); hPtr;
hPtr = Tcl_NextHashEntry(&search)) {
zf = (ZipFile *) Tcl_GetHashValue(hPtr);
Tcl_ListObjAppendElement(NULL, resultList, Tcl_NewStringObj(
zf->mountPoint, -1));
Tcl_ListObjAppendElement(NULL, resultList, Tcl_NewStringObj(
zf->name, -1));
}
Tcl_SetObjResult(interp, resultList);
return TCL_OK;
}
/*
*-------------------------------------------------------------------------
|
| ︙ | ︙ | |||
1939 1940 1941 1942 1943 1944 1945 |
Tcl_Interp *interp,
const char *mountPoint)
{
if (interp) {
ZipFile *zf = ZipFSLookupZip(mountPoint);
if (zf) {
| | | 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 |
Tcl_Interp *interp,
const char *mountPoint)
{
if (interp) {
ZipFile *zf = ZipFSLookupZip(mountPoint);
if (zf) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(zf->name, -1));
return TCL_OK;
}
}
return (interp ? TCL_OK : TCL_BREAK);
}
/*
|
| ︙ | ︙ | |||
2233 2234 2235 2236 2237 2238 2239 |
if (objc > 1) {
mountPoint = TclGetString(objv[1]);
}
if (objc > 2) {
zipFileObj = Tcl_FSGetNormalizedPath(interp, objv[2]);
if (!zipFileObj) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 |
if (objc > 1) {
mountPoint = TclGetString(objv[1]);
}
if (objc > 2) {
zipFileObj = Tcl_FSGetNormalizedPath(interp, objv[2]);
if (!zipFileObj) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"could not normalize zip filename", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "NORMALIZE", NULL);
return TCL_ERROR;
}
Tcl_IncrRefCount(zipFileObj);
zipFile = TclGetString(zipFileObj);
}
if (objc > 3) {
|
| ︙ | ︙ | |||
2276 2277 2278 2279 2280 2281 2282 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *mountPoint; /* Mount point path. */
unsigned char *data;
| | | 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 |
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *mountPoint; /* Mount point path. */
unsigned char *data;
Tcl_Size length;
if (objc > 3) {
Tcl_WrongNumArgs(interp, 1, objv, "?mountpoint? ?data?");
return TCL_ERROR;
}
if (objc < 2) {
int ret;
|
| ︙ | ︙ | |||
2329 2330 2331 2332 2333 2334 2335 |
static int
ZipFSRootObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
TCL_UNUSED(int) /*objc*/,
TCL_UNUSED(Tcl_Obj *const *)) /*objv*/
{
| | | 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 |
static int
ZipFSRootObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
TCL_UNUSED(int) /*objc*/,
TCL_UNUSED(Tcl_Obj *const *)) /*objv*/
{
Tcl_SetObjResult(interp, Tcl_NewStringObj(ZIPFS_VOLUME, -1));
return TCL_OK;
}
/*
*-------------------------------------------------------------------------
*
* ZipFSUnmountObjCmd --
|
| ︙ | ︙ | |||
2387 2388 2389 2390 2391 2392 2393 |
static int
ZipFSMkKeyObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
| | | | 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 |
static int
ZipFSMkKeyObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Size len, i = 0;
const char *pw;
Tcl_Obj *passObj;
unsigned char *passBuf;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "password");
return TCL_ERROR;
}
pw = Tcl_GetStringFromObj(objv[1], &len);
if (len == 0) {
return TCL_OK;
}
if (IsPasswordValid(interp, pw, len) != TCL_OK) {
return TCL_ERROR;
}
passObj = Tcl_NewByteArrayObj(NULL, 264);
passBuf = Tcl_GetByteArrayFromObj(passObj, (Tcl_Size *)NULL);
while (len > 0) {
int ch = pw[len - 1];
passBuf[i++] = (ch & 0x0f) | pwrot[(ch >> 4) & 0x0f];
len--;
}
passBuf[i] = i;
|
| ︙ | ︙ | |||
2512 2513 2514 2515 2516 2517 2518 |
ZipEntry *z;
z_stream stream;
Tcl_DString zpathDs; /* Buffer for the encoded filename. */
const char *zpathExt; /* Filename in external encoding (true
* UTF-8). */
const char *zpathTcl; /* Filename in Tcl's internal encoding. */
int crc, flush, zpathlen;
| | > | 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 |
ZipEntry *z;
z_stream stream;
Tcl_DString zpathDs; /* Buffer for the encoded filename. */
const char *zpathExt; /* Filename in external encoding (true
* UTF-8). */
const char *zpathTcl; /* Filename in Tcl's internal encoding. */
int crc, flush, zpathlen;
size_t nbyte, nbytecompr;
Tcl_Size len, olen, align = 0;
long long headerStartOffset, dataStartOffset, dataEndOffset;
int mtime = 0, isNew, compMeth;
unsigned long keys[3], keys0[3];
char obuf[4096];
/*
* Trim leading '/' characters. If this results in an empty string, we've
|
| ︙ | ︙ | |||
2536 2537 2538 2539 2540 2541 2542 |
}
/*
* Convert to encoded form. Note that we use strlen() here; if someone's
* crazy enough to embed NULs in filenames, they deserve what they get!
*/
| | | 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 |
}
/*
* Convert to encoded form. Note that we use strlen() here; if someone's
* crazy enough to embed NULs in filenames, they deserve what they get!
*/
zpathExt = Tcl_UtfToExternalDString(ZipFS.utf8, zpathTcl, -1, &zpathDs);
zpathlen = strlen(zpathExt);
if (zpathlen + ZIP_CENTRAL_HEADER_LEN > bufsize) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"path too long for \"%s\"", TclGetString(pathObj)));
ZIPFS_ERROR_CODE(interp, "PATH_LEN");
Tcl_DStringFree(&zpathDs);
return TCL_ERROR;
|
| ︙ | ︙ | |||
2574 2575 2576 2577 2578 2579 2580 |
* Compute the CRC.
*/
crc = 0;
nbyte = nbytecompr = 0;
while (1) {
len = Tcl_Read(in, buf, bufsize);
| | | 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 |
* Compute the CRC.
*/
crc = 0;
nbyte = nbytecompr = 0;
while (1) {
len = Tcl_Read(in, buf, bufsize);
if (len < 0) {
Tcl_DStringFree(&zpathDs);
if (nbyte == 0 && errno == EISDIR) {
Tcl_Close(interp, in);
return TCL_OK;
}
readErrorWithChannelOpen:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("read error on \"%s\": %s",
|
| ︙ | ︙ | |||
2615 2616 2617 2618 2619 2620 2621 |
* Reserve space for the per-file header. Includes writing the file name
* as we already know that.
*/
memset(buf, '\0', ZIP_LOCAL_HEADER_LEN);
memcpy(buf + ZIP_LOCAL_HEADER_LEN, zpathExt, zpathlen);
len = zpathlen + ZIP_LOCAL_HEADER_LEN;
| | | 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 |
* Reserve space for the per-file header. Includes writing the file name
* as we already know that.
*/
memset(buf, '\0', ZIP_LOCAL_HEADER_LEN);
memcpy(buf + ZIP_LOCAL_HEADER_LEN, zpathExt, zpathlen);
len = zpathlen + ZIP_LOCAL_HEADER_LEN;
if (Tcl_Write(out, buf, len) != len) {
writeErrorWithChannelOpen:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"write error on \"%s\": %s",
TclGetString(pathObj), Tcl_PosixError(interp)));
Tcl_Close(interp, in);
Tcl_DStringFree(&zpathDs);
return TCL_ERROR;
|
| ︙ | ︙ | |||
2639 2640 2641 2642 2643 2644 2645 | const unsigned char *astart = abuf; const unsigned char *aend = abuf + 8; align = 4 + ((len + headerStartOffset) & 3); ZipWriteShort(astart, aend, abuf, 0xffff); ZipWriteShort(astart, aend, abuf + 2, align - 4); ZipWriteInt(astart, aend, abuf + 4, 0x03020100); | | | 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 |
const unsigned char *astart = abuf;
const unsigned char *aend = abuf + 8;
align = 4 + ((len + headerStartOffset) & 3);
ZipWriteShort(astart, aend, abuf, 0xffff);
ZipWriteShort(astart, aend, abuf + 2, align - 4);
ZipWriteInt(astart, aend, abuf + 4, 0x03020100);
if (Tcl_Write(out, (const char *) abuf, align) != align) {
goto writeErrorWithChannelOpen;
}
}
/*
* Set up encryption if we were asked to.
*/
|
| ︙ | ︙ | |||
2704 2705 2706 2707 2708 2709 2710 |
Tcl_Close(interp, in);
Tcl_DStringFree(&zpathDs);
return TCL_ERROR;
}
do {
len = Tcl_Read(in, buf, bufsize);
| | | | | | 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 |
Tcl_Close(interp, in);
Tcl_DStringFree(&zpathDs);
return TCL_ERROR;
}
do {
len = Tcl_Read(in, buf, bufsize);
if (len < 0) {
deflateEnd(&stream);
goto readErrorWithChannelOpen;
}
stream.avail_in = len;
stream.next_in = (unsigned char *) buf;
flush = Tcl_Eof(in) ? Z_FINISH : Z_NO_FLUSH;
do {
stream.avail_out = sizeof(obuf);
stream.next_out = (unsigned char *) obuf;
len = deflate(&stream, flush);
if (len == Z_STREAM_ERROR) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"deflate error on \"%s\"", TclGetString(pathObj)));
ZIPFS_ERROR_CODE(interp, "DEFLATE");
deflateEnd(&stream);
Tcl_Close(interp, in);
Tcl_DStringFree(&zpathDs);
return TCL_ERROR;
}
olen = sizeof(obuf) - stream.avail_out;
if (passwd) {
Tcl_Size i;
int tmp;
for (i = 0; i < olen; i++) {
obuf[i] = (char) zencode(keys, crc32tab, obuf[i], tmp);
}
}
if (olen && (Tcl_Write(out, obuf, olen) != olen)) {
deflateEnd(&stream);
goto writeErrorWithChannelOpen;
}
nbytecompr += olen;
} while (stream.avail_out == 0);
} while (flush != Z_FINISH);
deflateEnd(&stream);
|
| ︙ | ︙ | |||
2768 2769 2770 2771 2772 2773 2774 |
Tcl_Close(interp, in);
Tcl_DStringFree(&zpathDs);
return TCL_ERROR;
}
nbytecompr = (passwd ? 12 : 0);
while (1) {
len = Tcl_Read(in, buf, bufsize);
| | | | | 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 |
Tcl_Close(interp, in);
Tcl_DStringFree(&zpathDs);
return TCL_ERROR;
}
nbytecompr = (passwd ? 12 : 0);
while (1) {
len = Tcl_Read(in, buf, bufsize);
if (len < 0) {
goto readErrorWithChannelOpen;
} else if (len == 0) {
break;
}
if (passwd) {
Tcl_Size i;
int tmp;
for (i = 0; i < len; i++) {
buf[i] = (char) zencode(keys0, crc32tab, buf[i], tmp);
}
}
if (Tcl_Write(out, buf, len) != len) {
goto writeErrorWithChannelOpen;
}
nbytecompr += len;
}
compMeth = ZIP_COMPMETH_STORED;
/*
|
| ︙ | ︙ | |||
2876 2877 2878 2879 2880 2881 2882 |
ZipFSFind(
Tcl_Interp *interp,
Tcl_Obj *dirRoot)
{
Tcl_Obj *cmd[2];
int result;
| | | 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 |
ZipFSFind(
Tcl_Interp *interp,
Tcl_Obj *dirRoot)
{
Tcl_Obj *cmd[2];
int result;
cmd[0] = Tcl_NewStringObj("::tcl::zipfs::find", -1);
cmd[1] = dirRoot;
Tcl_IncrRefCount(cmd[0]);
result = Tcl_EvalObjv(interp, 2, cmd, 0);
Tcl_DecrRefCount(cmd[0]);
if (result != TCL_OK) {
return NULL;
}
|
| ︙ | ︙ | |||
2914 2915 2916 2917 2918 2919 2920 |
static inline const char *
ComputeNameInArchive(
Tcl_Obj *pathObj, /* The path to the origin file */
Tcl_Obj *directNameObj, /* User-specified name for use in the ZIP
* archive */
const char *strip, /* A prefix to strip; may be NULL if no
* stripping need be done. */
| | | | 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 |
static inline const char *
ComputeNameInArchive(
Tcl_Obj *pathObj, /* The path to the origin file */
Tcl_Obj *directNameObj, /* User-specified name for use in the ZIP
* archive */
const char *strip, /* A prefix to strip; may be NULL if no
* stripping need be done. */
Tcl_Size slen) /* The length of the prefix; must be 0 if no
* stripping need be done. */
{
const char *name;
Tcl_Size len;
if (directNameObj) {
name = TclGetString(directNameObj);
} else {
name = Tcl_GetStringFromObj(pathObj, &len);
if (slen > 0) {
if ((len <= slen) || (strncmp(strip, name, slen) != 0)) {
|
| ︙ | ︙ | |||
2987 2988 2989 2990 2991 2992 2993 |
* do not strip anything (except for dirRoot
* itself). */
Tcl_Obj *passwordObj) /* The password for encoding things. NULL if
* there's no password protection. */
{
Tcl_Channel out;
int count, ret = TCL_ERROR;
| | > | | | 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 |
* do not strip anything (except for dirRoot
* itself). */
Tcl_Obj *passwordObj) /* The password for encoding things. NULL if
* there's no password protection. */
{
Tcl_Channel out;
int count, ret = TCL_ERROR;
Tcl_Size pwlen = 0, slen = 0, len, i = 0;
Tcl_Size lobjc;
long long directoryStartOffset;
/* The overall file offset of the start of the
* central directory. */
long long suffixStartOffset;/* The overall file offset of the start of the
* suffix of the central directory (i.e.,
* where this data will be written). */
Tcl_Obj **lobjv, *list = mappingList;
ZipEntry *z;
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
|
| ︙ | ︙ | |||
3173 3174 3175 3176 3177 3178 3179 |
Tcl_InitHashTable(&fileHash, TCL_STRING_KEYS);
if (mappingList == NULL && stripPrefix != NULL) {
strip = Tcl_GetStringFromObj(stripPrefix, &slen);
if (!slen) {
strip = NULL;
}
}
| | | | | 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 |
Tcl_InitHashTable(&fileHash, TCL_STRING_KEYS);
if (mappingList == NULL && stripPrefix != NULL) {
strip = Tcl_GetStringFromObj(stripPrefix, &slen);
if (!slen) {
strip = NULL;
}
}
for (i = 0; i < lobjc; i += (mappingList ? 2 : 1)) {
Tcl_Obj *pathObj = lobjv[i];
const char *name = ComputeNameInArchive(pathObj,
(mappingList ? lobjv[i + 1] : NULL), strip, slen);
if (name[0] == '\0') {
continue;
}
if (ZipAddFile(interp, pathObj, name, out, pw, buf, sizeof(buf),
&fileHash) != TCL_OK) {
goto done;
}
}
/*
* Construct the contents of the ZIP central directory.
*/
directoryStartOffset = Tcl_Tell(out);
count = 0;
for (i = 0; i < lobjc; i += (mappingList ? 2 : 1)) {
const char *name = ComputeNameInArchive(lobjv[i],
(mappingList ? lobjv[i + 1] : NULL), strip, slen);
Tcl_DString ds;
hPtr = Tcl_FindHashEntry(&fileHash, name);
if (!hPtr) {
continue;
}
z = (ZipEntry *) Tcl_GetHashValue(hPtr);
name = Tcl_UtfToExternalDString(ZipFS.utf8, z->name, TCL_INDEX_NONE, &ds);
len = Tcl_DStringLength(&ds);
SerializeCentralDirectoryEntry(start, end, (unsigned char *) buf,
z, len);
if ((Tcl_Write(out, buf, ZIP_CENTRAL_HEADER_LEN)
!= ZIP_CENTRAL_HEADER_LEN)
|| (Tcl_Write(out, name, len) != len)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"write error: %s", Tcl_PosixError(interp)));
Tcl_DStringFree(&ds);
goto done;
}
Tcl_DStringFree(&ds);
count++;
|
| ︙ | ︙ | |||
3277 3278 3279 3280 3281 3282 3283 |
static int
CopyImageFile(
Tcl_Interp *interp, /* For error reporting. */
const char *imgName, /* Where to copy from. */
Tcl_Channel out) /* Where to copy to; already open for writing
* binary data. */
{
| | | | | | | 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 |
static int
CopyImageFile(
Tcl_Interp *interp, /* For error reporting. */
const char *imgName, /* Where to copy from. */
Tcl_Channel out) /* Where to copy to; already open for writing
* binary data. */
{
Tcl_WideInt i, k;
Tcl_Size m, n;
Tcl_Channel in;
char buf[4096];
const char *errMsg;
Tcl_ResetResult(interp);
in = Tcl_OpenFileChannel(interp, imgName, "rb", 0644);
if (!in) {
return TCL_ERROR;
}
/*
* Get the length of the file (and exclude non-files).
*/
i = Tcl_Seek(in, 0, SEEK_END);
if (i == -1) {
errMsg = "seek error";
goto copyError;
}
Tcl_Seek(in, 0, SEEK_SET);
/*
* Copy the whole file, 8 blocks at a time (reasonably efficient). Note
* that this totally ignores things like Windows's Alternate File Streams.
*/
for (k = 0; k < i; k += m) {
m = i - k;
if (m > (Tcl_Size) sizeof(buf)) {
m = sizeof(buf);
}
n = Tcl_Read(in, buf, m);
if (n == -1) {
errMsg = "read error";
goto copyError;
} else if (n == 0) {
break;
|
| ︙ | ︙ | |||
3624 3625 3626 3627 3628 3629 3630 |
if (Tcl_GetBooleanFromObj(interp, objv[3], &zipfs)) {
return TCL_ERROR;
}
mntpoint = TclGetString(objv[1]);
filename = TclGetString(objv[2]);
result = CanonicalPath(mntpoint, filename, &dPath, zipfs);
}
| | | 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 |
if (Tcl_GetBooleanFromObj(interp, objv[3], &zipfs)) {
return TCL_ERROR;
}
mntpoint = TclGetString(objv[1]);
filename = TclGetString(objv[2]);
result = CanonicalPath(mntpoint, filename, &dPath, zipfs);
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(result, -1));
return TCL_OK;
}
/*
*-------------------------------------------------------------------------
*
* ZipFSExistsObjCmd --
|
| ︙ | ︙ | |||
3669 3670 3671 3672 3673 3674 3675 |
/*
* Prepend ZIPFS_VOLUME to filename, eliding the final /
*/
filename = TclGetString(objv[1]);
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, ZIPFS_VOLUME, ZIPFS_VOLUME_LEN - 1);
| | | 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 |
/*
* Prepend ZIPFS_VOLUME to filename, eliding the final /
*/
filename = TclGetString(objv[1]);
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, ZIPFS_VOLUME, ZIPFS_VOLUME_LEN - 1);
Tcl_DStringAppend(&ds, filename, -1);
filename = Tcl_DStringValue(&ds);
ReadLock();
exists = ZipFSLookup(filename) != NULL;
Unlock();
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(exists));
|
| ︙ | ︙ | |||
3720 3721 3722 3723 3724 3725 3726 |
filename = TclGetString(objv[1]);
ReadLock();
z = ZipFSLookup(filename);
if (z) {
Tcl_Obj *result = Tcl_GetObjResult(interp);
Tcl_ListObjAppendElement(interp, result,
| | | 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 |
filename = TclGetString(objv[1]);
ReadLock();
z = ZipFSLookup(filename);
if (z) {
Tcl_Obj *result = Tcl_GetObjResult(interp);
Tcl_ListObjAppendElement(interp, result,
Tcl_NewStringObj(z->zipFilePtr->name, -1));
Tcl_ListObjAppendElement(interp, result,
Tcl_NewWideIntObj(z->numBytes));
Tcl_ListObjAppendElement(interp, result,
Tcl_NewWideIntObj(z->numCompressedBytes));
Tcl_ListObjAppendElement(interp, result, Tcl_NewWideIntObj(z->offset));
}
Unlock();
|
| ︙ | ︙ | |||
3806 3807 3808 3809 3810 3811 3812 |
if (pattern) {
for (hPtr = Tcl_FirstHashEntry(&ZipFS.fileHash, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
ZipEntry *z = (ZipEntry *) Tcl_GetHashValue(hPtr);
if (Tcl_StringMatch(z->name, pattern)) {
Tcl_ListObjAppendElement(interp, result,
| | | | | 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 |
if (pattern) {
for (hPtr = Tcl_FirstHashEntry(&ZipFS.fileHash, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
ZipEntry *z = (ZipEntry *) Tcl_GetHashValue(hPtr);
if (Tcl_StringMatch(z->name, pattern)) {
Tcl_ListObjAppendElement(interp, result,
Tcl_NewStringObj(z->name, -1));
}
}
} else if (regexp) {
for (hPtr = Tcl_FirstHashEntry(&ZipFS.fileHash, &search);
hPtr; hPtr = Tcl_NextHashEntry(&search)) {
ZipEntry *z = (ZipEntry *) Tcl_GetHashValue(hPtr);
if (Tcl_RegExpExec(interp, regexp, z->name, z->name)) {
Tcl_ListObjAppendElement(interp, result,
Tcl_NewStringObj(z->name, -1));
}
}
} else {
for (hPtr = Tcl_FirstHashEntry(&ZipFS.fileHash, &search);
hPtr; hPtr = Tcl_NextHashEntry(&search)) {
ZipEntry *z = (ZipEntry *) Tcl_GetHashValue(hPtr);
Tcl_ListObjAppendElement(interp, result,
Tcl_NewStringObj(z->name, -1));
}
}
Unlock();
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
3869 3870 3871 3872 3873 3874 3875 |
/*
* Use the cached value if that has been set; we don't want to repeat the
* searching and mounting.
*/
if (zipfs_literal_tcl_library) {
| | | | | | | | 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 |
/*
* Use the cached value if that has been set; we don't want to repeat the
* searching and mounting.
*/
if (zipfs_literal_tcl_library) {
return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
}
/*
* Look for the library file system within the executable.
*/
vfsInitScript = Tcl_NewStringObj(ZIPFS_APP_MOUNT "/tcl_library/init.tcl",
-1);
Tcl_IncrRefCount(vfsInitScript);
found = Tcl_FSAccess(vfsInitScript, F_OK);
Tcl_DecrRefCount(vfsInitScript);
if (found == TCL_OK) {
zipfs_literal_tcl_library = ZIPFS_APP_MOUNT "/tcl_library";
return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
}
/*
* Look for the library file system within the DLL/shared library. Note
* that we must mount the zip file and dll before releasing to search.
*/
#if !defined(STATIC_BUILD)
#if defined(_WIN32) || defined(__CYGWIN__)
hModule = (HMODULE)TclWinGetTclInstance();
GetModuleFileNameW(hModule, wName, MAX_PATH);
#ifdef __CYGWIN__
cygwin_conv_path(3, wName, dllName, sizeof(dllName));
#else
WideCharToMultiByte(CP_UTF8, 0, wName, -1, dllName, sizeof(dllName), NULL, NULL);
#endif
if (ZipfsAppHookFindTclInit(dllName) == TCL_OK) {
return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
}
#elif !defined(NO_DLFCN_H)
Dl_info dlinfo;
if (dladdr((const void *)TclZipfs_TclLibrary, &dlinfo) && (dlinfo.dli_fname != NULL)
&& (ZipfsAppHookFindTclInit(dlinfo.dli_fname) == TCL_OK)) {
return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
}
#else
if (ZipfsAppHookFindTclInit(CFG_RUNTIME_LIBDIR "/" CFG_RUNTIME_DLLFILE) == TCL_OK) {
return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
}
#endif /* _WIN32 */
#endif /* !defined(STATIC_BUILD) */
/*
* If anything set the cache (but subsequently failed) go with that
* anyway.
*/
if (zipfs_literal_tcl_library) {
return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
}
return NULL;
}
/*
*-------------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
4391 4392 4393 4394 4395 4396 4397 |
}
}
/*
* Wrap the ZipChannel into a Tcl_Channel.
*/
| | | 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 |
}
}
/*
* Wrap the ZipChannel into a Tcl_Channel.
*/
snprintf(cname, sizeof(cname), "zipfs_%" TCL_Z_MODIFIER "x_%d", z->offset,
ZipFS.idCount++);
z->zipFilePtr->numOpen++;
Unlock();
return Tcl_CreateChannel(&ZipChannelType, cname, info, flags);
error:
Unlock();
|
| ︙ | ︙ | |||
4932 4933 4934 4935 4936 4937 4938 |
*-------------------------------------------------------------------------
*/
static Tcl_Obj *
ZipFSFilesystemSeparatorProc(
TCL_UNUSED(Tcl_Obj *) /*pathPtr*/)
{
| | | 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 |
*-------------------------------------------------------------------------
*/
static Tcl_Obj *
ZipFSFilesystemSeparatorProc(
TCL_UNUSED(Tcl_Obj *) /*pathPtr*/)
{
return Tcl_NewStringObj("/", -1);
}
/*
*-------------------------------------------------------------------------
*
* AppendWithPrefix --
*
|
| ︙ | ︙ | |||
4997 4998 4999 5000 5001 5002 5003 |
Tcl_Obj *pathPtr, /* Where we are looking. */
const char *pattern, /* What names we are looking for. */
Tcl_GlobTypeData *types) /* What types we are looking for. */
{
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
Tcl_Obj *normPathPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr);
| | | | 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 |
Tcl_Obj *pathPtr, /* Where we are looking. */
const char *pattern, /* What names we are looking for. */
Tcl_GlobTypeData *types) /* What types we are looking for. */
{
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
Tcl_Obj *normPathPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr);
int scnt, l, dirOnly = -1, mounts = 0;
Tcl_Size prefixLen, len, strip = 0;
char *pat, *prefix, *path;
Tcl_DString dsPref, *prefixBuf = NULL;
if (!normPathPtr) {
return -1;
}
if (types) {
|
| ︙ | ︙ | |||
5059 5060 5061 5062 5063 5064 5065 |
*/
if (!pattern || (pattern[0] == '\0')) {
ZipEntry *z = ZipFSLookup(path);
if (z && ((dirOnly < 0) || (!dirOnly && !z->isDirectory)
|| (dirOnly && z->isDirectory))) {
| | | 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 |
*/
if (!pattern || (pattern[0] == '\0')) {
ZipEntry *z = ZipFSLookup(path);
if (z && ((dirOnly < 0) || (!dirOnly && !z->isDirectory)
|| (dirOnly && z->isDirectory))) {
AppendWithPrefix(result, prefixBuf, z->name, -1);
}
goto end;
}
/*
* We've got to work for our supper and do the actual globbing. And all
* we've got really is an undifferentiated pile of all the filenames we've
|
| ︙ | ︙ | |||
5092 5093 5094 5095 5096 5097 5098 |
ZipEntry *z = (ZipEntry *) Tcl_GetHashValue(hPtr);
if ((dirOnly >= 0) && ((dirOnly && !z->isDirectory)
|| (!dirOnly && z->isDirectory))) {
continue;
}
if ((z->depth == scnt) && Tcl_StringCaseMatch(z->name, pat, 0)) {
| | | 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 |
ZipEntry *z = (ZipEntry *) Tcl_GetHashValue(hPtr);
if ((dirOnly >= 0) && ((dirOnly && !z->isDirectory)
|| (!dirOnly && z->isDirectory))) {
continue;
}
if ((z->depth == scnt) && Tcl_StringCaseMatch(z->name, pat, 0)) {
AppendWithPrefix(result, prefixBuf, z->name + strip, -1);
}
}
Tcl_Free(pat);
end:
Unlock();
Tcl_DStringFree(&dsPref);
|
| ︙ | ︙ | |||
5134 5135 5136 5137 5138 5139 5140 |
* list. */
Tcl_DString *prefix) /* Workspace filled with a prefix for all the
* filenames, or NULL if no prefix is to be
* used. */
{
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
| | > | 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 |
* list. */
Tcl_DString *prefix) /* Workspace filled with a prefix for all the
* filenames, or NULL if no prefix is to be
* used. */
{
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
size_t l;
Tcl_Size normLength;
const char *path = Tcl_GetStringFromObj(normPathPtr, &normLength);
size_t len = normLength;
if (len < 1) {
/*
* Shouldn't happen. But "shouldn't"...
*/
|
| ︙ | ︙ | |||
5216 5217 5218 5219 5220 5221 5222 |
ZipFSPathInFilesystemProc(
Tcl_Obj *pathPtr,
TCL_UNUSED(void **))
{
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
int ret = -1;
| | | 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 |
ZipFSPathInFilesystemProc(
Tcl_Obj *pathPtr,
TCL_UNUSED(void **))
{
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
int ret = -1;
Tcl_Size len;
char *path;
pathPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr);
if (!pathPtr) {
return -1;
}
path = Tcl_GetStringFromObj(pathPtr, &len);
|
| ︙ | ︙ | |||
5243 5244 5245 5246 5247 5248 5249 |
hPtr = Tcl_NextHashEntry(&search)) {
ZipFile *zf = (ZipFile *) Tcl_GetHashValue(hPtr);
if (zf->mountPointLen == 0) {
ZipEntry *z;
for (z = zf->topEnts; z != NULL; z = z->tnext) {
| | | | 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 |
hPtr = Tcl_NextHashEntry(&search)) {
ZipFile *zf = (ZipFile *) Tcl_GetHashValue(hPtr);
if (zf->mountPointLen == 0) {
ZipEntry *z;
for (z = zf->topEnts; z != NULL; z = z->tnext) {
Tcl_Size lenz = strlen(z->name);
if ((len >= lenz) &&
(strncmp(path, z->name, lenz) == 0)) {
ret = TCL_OK;
goto endloop;
}
}
} else if (((size_t) len >= zf->mountPointLen) &&
(strncmp(path, zf->mountPoint, zf->mountPointLen) == 0)) {
|
| ︙ | ︙ | |||
5282 5283 5284 5285 5286 5287 5288 |
*
*-------------------------------------------------------------------------
*/
static Tcl_Obj *
ZipFSListVolumesProc(void)
{
| | | 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 |
*
*-------------------------------------------------------------------------
*/
static Tcl_Obj *
ZipFSListVolumesProc(void)
{
return Tcl_NewStringObj(ZIPFS_VOLUME, -1);
}
/*
*-------------------------------------------------------------------------
*
* ZipFSFileAttrStringsProc --
*
|
| ︙ | ︙ | |||
5363 5364 5365 5366 5367 5368 5369 |
static int
ZipFSFileAttrsGetProc(
Tcl_Interp *interp, /* Current interpreter. */
int index,
Tcl_Obj *pathPtr,
Tcl_Obj **objPtrRef)
{
| | | 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 |
static int
ZipFSFileAttrsGetProc(
Tcl_Interp *interp, /* Current interpreter. */
int index,
Tcl_Obj *pathPtr,
Tcl_Obj **objPtrRef)
{
Tcl_Size len;
int ret = TCL_OK;
char *path;
ZipEntry *z;
pathPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr);
if (!pathPtr) {
return -1;
|
| ︙ | ︙ | |||
5396 5397 5398 5399 5400 5401 5402 |
TclNewIntObj(*objPtrRef, z->offset);
break;
case ZIP_ATTR_MOUNT:
*objPtrRef = Tcl_NewStringObj(z->zipFilePtr->mountPoint,
z->zipFilePtr->mountPointLen);
break;
case ZIP_ATTR_ARCHIVE:
| | | | 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 |
TclNewIntObj(*objPtrRef, z->offset);
break;
case ZIP_ATTR_MOUNT:
*objPtrRef = Tcl_NewStringObj(z->zipFilePtr->mountPoint,
z->zipFilePtr->mountPointLen);
break;
case ZIP_ATTR_ARCHIVE:
*objPtrRef = Tcl_NewStringObj(z->zipFilePtr->name, -1);
break;
case ZIP_ATTR_PERMISSIONS:
*objPtrRef = Tcl_NewStringObj("0o555", -1);
break;
case ZIP_ATTR_CRC:
TclNewIntObj(*objPtrRef, z->crc32);
break;
default:
ZIPFS_ERROR(interp, "unknown attribute");
ZIPFS_ERROR_CODE(interp, "FILE_ATTR");
|
| ︙ | ︙ | |||
5460 5461 5462 5463 5464 5465 5466 |
*-------------------------------------------------------------------------
*/
static Tcl_Obj *
ZipFSFilesystemPathTypeProc(
TCL_UNUSED(Tcl_Obj *) /*pathPtr*/)
{
| | | 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 |
*-------------------------------------------------------------------------
*/
static Tcl_Obj *
ZipFSFilesystemPathTypeProc(
TCL_UNUSED(Tcl_Obj *) /*pathPtr*/)
{
return Tcl_NewStringObj("zip", -1);
}
/*
*-------------------------------------------------------------------------
*
* ZipFSLoadFile --
*
|
| ︙ | ︙ | |||
5672 5673 5674 5675 5676 5677 5678 | Tcl_IsSafe(interp) ? (initMap + 4) : initMap); /* * Add the [zipfs find] subcommand. */ Tcl_GetEnsembleMappingDict(NULL, ensemble, &mapObj); | | | | 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 |
Tcl_IsSafe(interp) ? (initMap + 4) : initMap);
/*
* Add the [zipfs find] subcommand.
*/
Tcl_GetEnsembleMappingDict(NULL, ensemble, &mapObj);
Tcl_DictObjPut(NULL, mapObj, Tcl_NewStringObj("find", -1),
Tcl_NewStringObj("::tcl::zipfs::find", -1));
Tcl_CreateObjCommand(interp, "::tcl::zipfs::tcl_library_init",
ZipFSTclLibraryObjCmd, NULL, NULL);
Tcl_PkgProvide(interp, "tcl::zipfs", "2.0");
}
return TCL_OK;
#else /* !HAVE_ZLIB */
ZIPFS_ERROR(interp, "no zlib available");
|
| ︙ | ︙ |
Changes to generic/tclZlib.c.
| ︙ | ︙ | |||
60 61 62 63 64 65 66 |
typedef struct {
Tcl_Interp *interp;
z_stream stream; /* The interface to the zlib library. */
int streamEnd; /* If we've got to end-of-stream. */
Tcl_Obj *inData, *outData; /* Input / output buffers (lists) */
Tcl_Obj *currentInput; /* Pointer to what is currently being
* inflated. */
| | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
typedef struct {
Tcl_Interp *interp;
z_stream stream; /* The interface to the zlib library. */
int streamEnd; /* If we've got to end-of-stream. */
Tcl_Obj *inData, *outData; /* Input / output buffers (lists) */
Tcl_Obj *currentInput; /* Pointer to what is currently being
* inflated. */
Tcl_Size outPos;
int mode; /* Either TCL_ZLIB_STREAM_DEFLATE or
* TCL_ZLIB_STREAM_INFLATE. */
int format; /* Flags from the TCL_ZLIB_FORMAT_* */
int level; /* Default 5, 0-9 */
int flush; /* Stores the flush param for deferred the
* decompression. */
int wbits; /* The encoded compression mode, so we can
|
| ︙ | ︙ | |||
285 286 287 288 289 290 291 |
break;
case Z_VERSION_ERROR:
codeStr = "VERSION";
break;
case Z_NEED_DICT:
codeStr = "NEED_DICT";
codeStr2 = codeStrBuf;
| | | | | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
break;
case Z_VERSION_ERROR:
codeStr = "VERSION";
break;
case Z_NEED_DICT:
codeStr = "NEED_DICT";
codeStr2 = codeStrBuf;
snprintf(codeStrBuf, sizeof(codeStrBuf), "%lu", adler);
break;
/*
* These should _not_ happen! This function is for dealing with error
* cases, not non-errors!
*/
case Z_OK:
Tcl_Panic("unexpected zlib result in error handler: Z_OK");
case Z_STREAM_END:
Tcl_Panic("unexpected zlib result in error handler: Z_STREAM_END");
/*
* Anything else is bad news; it's unexpected. Convert to generic
* error.
*/
default:
codeStr = "UNKNOWN";
codeStr2 = codeStrBuf;
snprintf(codeStrBuf, sizeof(codeStrBuf), "%d", code);
break;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(zError(code), -1));
/*
* Tricky point! We might pass NULL twice here (and will when the error
* type is known).
*/
Tcl_SetErrorCode(interp, "TCL", "ZLIB", codeStr, codeStr2, NULL);
|
| ︙ | ︙ | |||
346 347 348 349 350 351 352 |
TclNewLiteralStringObj(objv[2], "BUF");
return Tcl_NewListObj(3, objv);
case Z_VERSION_ERROR:
TclNewLiteralStringObj(objv[2], "VERSION");
return Tcl_NewListObj(3, objv);
case Z_ERRNO:
TclNewLiteralStringObj(objv[2], "POSIX");
| | | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
TclNewLiteralStringObj(objv[2], "BUF");
return Tcl_NewListObj(3, objv);
case Z_VERSION_ERROR:
TclNewLiteralStringObj(objv[2], "VERSION");
return Tcl_NewListObj(3, objv);
case Z_ERRNO:
TclNewLiteralStringObj(objv[2], "POSIX");
objv[3] = Tcl_NewStringObj(Tcl_ErrnoId(), -1);
return Tcl_NewListObj(4, objv);
case Z_NEED_DICT:
TclNewLiteralStringObj(objv[2], "NEED_DICT");
TclNewIntObj(objv[3], (Tcl_WideInt)adler);
return Tcl_NewListObj(4, objv);
/*
|
| ︙ | ︙ | |||
401 402 403 404 405 406 407 |
static inline int
GetValue(
Tcl_Interp *interp,
Tcl_Obj *dictObj,
const char *nameStr,
Tcl_Obj **valuePtrPtr)
{
| | | | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
static inline int
GetValue(
Tcl_Interp *interp,
Tcl_Obj *dictObj,
const char *nameStr,
Tcl_Obj **valuePtrPtr)
{
Tcl_Obj *name = Tcl_NewStringObj(nameStr, -1);
int result = Tcl_DictObjGet(interp, dictObj, name, valuePtrPtr);
TclDecrRefCount(name);
return result;
}
static int
GenerateHeader(
Tcl_Interp *interp, /* Where to put error messages. */
Tcl_Obj *dictObj, /* The dictionary whose contents are to be
* parsed. */
GzipHeader *headerPtr, /* Where to store the parsed-out values. */
int *extraSizePtr) /* Variable to add the length of header
* strings (filename, comment) to. */
{
Tcl_Obj *value;
int len, result = TCL_ERROR;
Tcl_Size length;
Tcl_WideInt wideValue = 0;
const char *valueStr;
Tcl_Encoding latin1enc;
static const char *const types[] = {
"binary", "text"
};
|
| ︙ | ︙ | |||
551 552 553 554 555 556 557 | * Side effects: * Updates the dictionary, which must be writable (i.e. refCount < 2). * *---------------------------------------------------------------------- */ #define SetValue(dictObj, key, value) \ | | | 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
* Side effects:
* Updates the dictionary, which must be writable (i.e. refCount < 2).
*
*----------------------------------------------------------------------
*/
#define SetValue(dictObj, key, value) \
Tcl_DictObjPut(NULL, (dictObj), Tcl_NewStringObj((key), -1), (value))
static void
ExtractHeader(
gz_header *headerPtr, /* The gzip header to extract from. */
Tcl_Obj *dictObj) /* The dictionary to store in. */
{
Tcl_Encoding latin1enc = NULL;
|
| ︙ | ︙ | |||
602 603 604 605 606 607 608 |
SetValue(dictObj, "os", Tcl_NewWideIntObj(headerPtr->os));
}
if (headerPtr->time != 0 /* magic - no time */) {
SetValue(dictObj, "time", Tcl_NewWideIntObj(headerPtr->time));
}
if (headerPtr->text != Z_UNKNOWN) {
SetValue(dictObj, "type",
| | | | | 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
SetValue(dictObj, "os", Tcl_NewWideIntObj(headerPtr->os));
}
if (headerPtr->time != 0 /* magic - no time */) {
SetValue(dictObj, "time", Tcl_NewWideIntObj(headerPtr->time));
}
if (headerPtr->text != Z_UNKNOWN) {
SetValue(dictObj, "type",
Tcl_NewStringObj(headerPtr->text ? "text" : "binary", -1));
}
if (latin1enc != NULL) {
Tcl_FreeEncoding(latin1enc);
}
}
/*
* Disentangle the worst of how the zlib API is used.
*/
static int
SetInflateDictionary(
z_streamp strm,
Tcl_Obj *compDictObj)
{
if (compDictObj != NULL) {
Tcl_Size length = 0;
unsigned char *bytes = Tcl_GetByteArrayFromObj(compDictObj, &length);
if (bytes == NULL) {
return Z_DATA_ERROR;
}
return inflateSetDictionary(strm, bytes, length);
}
return Z_OK;
}
static int
SetDeflateDictionary(
z_streamp strm,
Tcl_Obj *compDictObj)
{
if (compDictObj != NULL) {
Tcl_Size length = 0;
unsigned char *bytes = Tcl_GetByteArrayFromObj(compDictObj, &length);
if (bytes == NULL) {
return Z_DATA_ERROR;
}
return deflateSetDictionary(strm, bytes, length);
}
|
| ︙ | ︙ | |||
845 846 847 848 849 850 851 |
}
Tcl_DStringInit(&cmdname);
TclDStringAppendLiteral(&cmdname, "::tcl::zlib::streamcmd_");
TclDStringAppendObj(&cmdname, Tcl_GetObjResult(interp));
if (Tcl_FindCommand(interp, Tcl_DStringValue(&cmdname),
NULL, 0) != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
}
Tcl_DStringInit(&cmdname);
TclDStringAppendLiteral(&cmdname, "::tcl::zlib::streamcmd_");
TclDStringAppendObj(&cmdname, Tcl_GetObjResult(interp));
if (Tcl_FindCommand(interp, Tcl_DStringValue(&cmdname),
NULL, 0) != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"BUG: Stream command name already exists", -1));
Tcl_SetErrorCode(interp, "TCL", "BUG", "EXISTING_CMD", NULL);
Tcl_DStringFree(&cmdname);
goto error;
}
Tcl_ResetResult(interp);
/*
|
| ︙ | ︙ | |||
1187 1188 1189 1190 1191 1192 1193 |
Tcl_ZlibStreamSetCompressionDictionary(
Tcl_ZlibStream zshandle,
Tcl_Obj *compressionDictionaryObj)
{
ZlibStreamHandle *zshPtr = (ZlibStreamHandle *) zshandle;
if (compressionDictionaryObj && (NULL == Tcl_GetByteArrayFromObj(
| | | 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 |
Tcl_ZlibStreamSetCompressionDictionary(
Tcl_ZlibStream zshandle,
Tcl_Obj *compressionDictionaryObj)
{
ZlibStreamHandle *zshPtr = (ZlibStreamHandle *) zshandle;
if (compressionDictionaryObj && (NULL == Tcl_GetByteArrayFromObj(
compressionDictionaryObj, (Tcl_Size *)NULL))) {
/* Missing or invalid compression dictionary */
compressionDictionaryObj = NULL;
}
if (compressionDictionaryObj != NULL) {
if (Tcl_IsShared(compressionDictionaryObj)) {
compressionDictionaryObj =
Tcl_DuplicateObj(compressionDictionaryObj);
|
| ︙ | ︙ | |||
1230 1231 1232 1233 1234 1235 1236 |
Tcl_Obj *data, /* Data to compress/decompress */
int flush) /* TCL_ZLIB_NO_FLUSH, TCL_ZLIB_FLUSH,
* TCL_ZLIB_FULLFLUSH, or TCL_ZLIB_FINALIZE */
{
ZlibStreamHandle *zshPtr = (ZlibStreamHandle *) zshandle;
char *dataTmp = NULL;
int e;
| > | | | 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 |
Tcl_Obj *data, /* Data to compress/decompress */
int flush) /* TCL_ZLIB_NO_FLUSH, TCL_ZLIB_FLUSH,
* TCL_ZLIB_FULLFLUSH, or TCL_ZLIB_FINALIZE */
{
ZlibStreamHandle *zshPtr = (ZlibStreamHandle *) zshandle;
char *dataTmp = NULL;
int e;
Tcl_Size size = 0;
size_t outSize, toStore;
unsigned char *bytes;
if (zshPtr->streamEnd) {
if (zshPtr->interp) {
Tcl_SetObjResult(zshPtr->interp, Tcl_NewStringObj(
"already past compressed stream end", -1));
Tcl_SetErrorCode(zshPtr->interp, "TCL", "ZIP", "CLOSED", NULL);
}
return TCL_ERROR;
}
bytes = Tcl_GetBytesFromObj(zshPtr->interp, data, &size);
if (bytes == NULL) {
|
| ︙ | ︙ | |||
1355 1356 1357 1358 1359 1360 1361 |
*----------------------------------------------------------------------
*/
int
Tcl_ZlibStreamGet(
Tcl_ZlibStream zshandle, /* As obtained from Tcl_ZlibStreamInit */
Tcl_Obj *data, /* A place to append the data. */
| | | | | | 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 |
*----------------------------------------------------------------------
*/
int
Tcl_ZlibStreamGet(
Tcl_ZlibStream zshandle, /* As obtained from Tcl_ZlibStreamInit */
Tcl_Obj *data, /* A place to append the data. */
Tcl_Size count) /* Number of bytes to grab as a maximum, you
* may get less! */
{
ZlibStreamHandle *zshPtr = (ZlibStreamHandle *) zshandle;
int e;
Tcl_Size listLen, i, itemLen = 0, dataPos = 0;
Tcl_Obj *itemObj;
unsigned char *dataPtr, *itemPtr;
Tcl_Size existing = 0;
/*
* Getting beyond the of stream, just return empty string.
*/
if (zshPtr->streamEnd) {
return TCL_OK;
}
if (NULL == Tcl_GetBytesFromObj(zshPtr->interp, data, &existing)) {
return TCL_ERROR;
}
if (zshPtr->mode == TCL_ZLIB_STREAM_INFLATE) {
if (count < 0) {
/*
* The only safe thing to do is restict to 65k. We might cause a
* panic for out of memory if we just kept growing the buffer.
*/
count = MAX_BUFFER_SIZE;
}
|
| ︙ | ︙ | |||
1467 1468 1469 1470 1471 1472 1473 |
* more to inflate.
*/
if (zshPtr->stream.avail_in > 0) {
if (zshPtr->interp) {
Tcl_SetObjResult(zshPtr->interp, Tcl_NewStringObj(
"unexpected zlib internal state during"
| | | 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 |
* more to inflate.
*/
if (zshPtr->stream.avail_in > 0) {
if (zshPtr->interp) {
Tcl_SetObjResult(zshPtr->interp, Tcl_NewStringObj(
"unexpected zlib internal state during"
" decompression", -1));
Tcl_SetErrorCode(zshPtr->interp, "TCL", "ZIP", "STATE",
NULL);
}
Tcl_SetByteArrayLength(data, existing);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1535 1536 1537 1538 1539 1540 1541 |
Tcl_DecrRefCount(zshPtr->currentInput);
zshPtr->currentInput = 0;
}
inflateEnd(&zshPtr->stream);
}
} else {
TclListObjLengthM(NULL, zshPtr->outData, &listLen);
| | | 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 |
Tcl_DecrRefCount(zshPtr->currentInput);
zshPtr->currentInput = 0;
}
inflateEnd(&zshPtr->stream);
}
} else {
TclListObjLengthM(NULL, zshPtr->outData, &listLen);
if (count < 0) {
count = 0;
for (i=0; i<listLen; i++) {
Tcl_ListObjIndex(NULL, zshPtr->outData, i, &itemObj);
(void) Tcl_GetByteArrayFromObj(itemObj, &itemLen);
if (i == 0) {
count += itemLen - zshPtr->outPos;
} else {
|
| ︙ | ︙ | |||
1565 1566 1567 1568 1569 1570 1571 | /* * Get the next chunk off our list of chunks and grab the data out * of it. */ Tcl_ListObjIndex(NULL, zshPtr->outData, 0, &itemObj); itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen); | | | | | 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 |
/*
* Get the next chunk off our list of chunks and grab the data out
* of it.
*/
Tcl_ListObjIndex(NULL, zshPtr->outData, 0, &itemObj);
itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
if ((itemLen-zshPtr->outPos) >= count-dataPos) {
Tcl_Size len = count - dataPos;
memcpy(dataPtr + dataPos, itemPtr + zshPtr->outPos, len);
zshPtr->outPos += len;
dataPos += len;
if (zshPtr->outPos == itemLen) {
zshPtr->outPos = 0;
}
} else {
Tcl_Size len = itemLen - zshPtr->outPos;
memcpy(dataPtr + dataPos, itemPtr + zshPtr->outPos, len);
dataPos += len;
zshPtr->outPos = 0;
}
if (zshPtr->outPos == 0) {
Tcl_ListObjReplace(NULL, zshPtr->outData, 0, 1, 0, NULL);
|
| ︙ | ︙ | |||
1612 1613 1614 1615 1616 1617 1618 |
Tcl_Interp *interp,
int format,
Tcl_Obj *data,
int level,
Tcl_Obj *gzipHeaderDictObj)
{
int wbits = 0, e = 0, extraSize = 0;
| | | 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 |
Tcl_Interp *interp,
int format,
Tcl_Obj *data,
int level,
Tcl_Obj *gzipHeaderDictObj)
{
int wbits = 0, e = 0, extraSize = 0;
Tcl_Size inLen = 0;
Byte *inData = NULL;
z_stream stream;
GzipHeader header;
gz_header *headerPtr = NULL;
Tcl_Obj *obj;
if (!interp) {
|
| ︙ | ︙ | |||
1734 1735 1736 1737 1738 1739 1740 |
}
if (e != Z_OK) {
goto error;
}
/*
| | | 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 |
}
if (e != Z_OK) {
goto error;
}
/*
* Reduce the ByteArray length to the actual data length produced by
* deflate.
*/
Tcl_SetByteArrayLength(obj, stream.total_out);
Tcl_SetObjResult(interp, obj);
return TCL_OK;
|
| ︙ | ︙ | |||
1763 1764 1765 1766 1767 1768 1769 |
*/
int
Tcl_ZlibInflate(
Tcl_Interp *interp,
int format,
Tcl_Obj *data,
| | | | 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 |
*/
int
Tcl_ZlibInflate(
Tcl_Interp *interp,
int format,
Tcl_Obj *data,
Tcl_Size bufferSize,
Tcl_Obj *gzipHeaderDictObj)
{
int wbits = 0, e = 0;
Tcl_Size inLen = 0, newBufferSize;
Byte *inData = NULL, *outData = NULL, *newOutData = NULL;
z_stream stream;
gz_header header, *headerPtr = NULL;
Tcl_Obj *obj;
char *nameBuf = NULL, *commentBuf = NULL;
if (!interp) {
|
| ︙ | ︙ | |||
1952 1953 1954 1955 1956 1957 1958 |
*----------------------------------------------------------------------
*/
unsigned int
Tcl_ZlibCRC32(
unsigned int crc,
const unsigned char *buf,
| | | | 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 |
*----------------------------------------------------------------------
*/
unsigned int
Tcl_ZlibCRC32(
unsigned int crc,
const unsigned char *buf,
Tcl_Size len)
{
/* Nothing much to do, just wrap the crc32(). */
return crc32(crc, (Bytef *) buf, len);
}
unsigned int
Tcl_ZlibAdler32(
unsigned int adler,
const unsigned char *buf,
Tcl_Size len)
{
return adler32(adler, (Bytef *) buf, len);
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
1985 1986 1987 1988 1989 1990 1991 |
ZlibCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
int i, option, level = -1;
| | > > | 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 |
ZlibCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
int i, option, level = -1;
size_t buffersize = 0;
Tcl_Size dlen = 0;
unsigned int start;
Tcl_WideInt wideLen;
Byte *data;
Tcl_Obj *headerDictObj;
const char *extraInfoStr = NULL;
static const char *const commands[] = {
"adler32", "compress", "crc32", "decompress", "deflate", "gunzip",
"gzip", "inflate", "push", "stream",
|
| ︙ | ︙ | |||
2232 2233 2234 2235 2236 2237 2238 |
* -> channel */
return ZlibPushSubcmd(interp, objc, objv);
};
return TCL_ERROR;
badLevel:
| | | 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 |
* -> channel */
return ZlibPushSubcmd(interp, objc, objv);
};
return TCL_ERROR;
badLevel:
Tcl_SetObjResult(interp, Tcl_NewStringObj("level must be 0 to 9", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMPRESSIONLEVEL", NULL);
if (extraInfoStr) {
Tcl_AddErrorInfo(interp, extraInfoStr);
}
return TCL_ERROR;
badBuffer:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
| ︙ | ︙ | |||
2383 2384 2385 2386 2387 2388 2389 |
Tcl_SetObjResult(interp, Tcl_NewStringObj("level must be 0 to 9",-1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMPRESSIONLEVEL", NULL);
Tcl_AddErrorInfo(interp, "\n (in -level option)");
return TCL_ERROR;
}
if (compDictObj) {
| | | 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 |
Tcl_SetObjResult(interp, Tcl_NewStringObj("level must be 0 to 9",-1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMPRESSIONLEVEL", NULL);
Tcl_AddErrorInfo(interp, "\n (in -level option)");
return TCL_ERROR;
}
if (compDictObj) {
if (NULL == Tcl_GetBytesFromObj(interp, compDictObj, (Tcl_Size *)NULL)) {
return TCL_ERROR;
}
}
/*
* Construct the stream now we know its configuration.
*/
|
| ︙ | ︙ | |||
2442 2443 2444 2445 2446 2447 2448 |
static const char *const pushDecompressOptions[] = {
"-dictionary", "-header", "-level", "-limit", NULL
};
const char *const *pushOptions = pushDecompressOptions;
enum pushOptionsEnum {poDictionary, poHeader, poLevel, poLimit} option;
Tcl_Obj *headerObj = NULL, *compDictObj = NULL;
int limit = DEFAULT_BUFFER_SIZE;
| | | 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 |
static const char *const pushDecompressOptions[] = {
"-dictionary", "-header", "-level", "-limit", NULL
};
const char *const *pushOptions = pushDecompressOptions;
enum pushOptionsEnum {poDictionary, poHeader, poLevel, poLimit} option;
Tcl_Obj *headerObj = NULL, *compDictObj = NULL;
int limit = DEFAULT_BUFFER_SIZE;
Tcl_Size dummy;
if (objc < 4) {
Tcl_WrongNumArgs(interp, 2, objv, "mode channel ?options...?");
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[2], stream_formats, "mode", 0,
|
| ︙ | ︙ | |||
2495 2496 2497 2498 2499 2500 2501 |
/*
* Sanity checks.
*/
if (mode == TCL_ZLIB_STREAM_DEFLATE && !(chanMode & TCL_WRITABLE)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 |
/*
* Sanity checks.
*/
if (mode == TCL_ZLIB_STREAM_DEFLATE && !(chanMode & TCL_WRITABLE)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"compression may only be applied to writable channels", -1));
Tcl_SetErrorCode(interp, "TCL", "ZIP", "UNWRITABLE", NULL);
return TCL_ERROR;
}
if (mode == TCL_ZLIB_STREAM_INFLATE && !(chanMode & TCL_READABLE)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"decompression may only be applied to readable channels",TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "ZIP", "UNREADABLE", NULL);
|
| ︙ | ︙ | |||
2535 2536 2537 2538 2539 2540 2541 |
break;
case poLevel:
if (Tcl_GetIntFromObj(interp, objv[i], (int*) &level) != TCL_OK) {
goto genericOptionError;
}
if (level < 0 || level > 9) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 |
break;
case poLevel:
if (Tcl_GetIntFromObj(interp, objv[i], (int*) &level) != TCL_OK) {
goto genericOptionError;
}
if (level < 0 || level > 9) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"level must be 0 to 9", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMPRESSIONLEVEL",
NULL);
goto genericOptionError;
}
break;
case poLimit:
if (Tcl_GetIntFromObj(interp, objv[i], (int*) &limit) != TCL_OK) {
|
| ︙ | ︙ | |||
2557 2558 2559 2560 2561 2562 2563 |
goto genericOptionError;
}
break;
case poDictionary:
if (format == TCL_ZLIB_FORMAT_GZIP) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"a compression dictionary may not be set in the "
| | | | 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 |
goto genericOptionError;
}
break;
case poDictionary:
if (format == TCL_ZLIB_FORMAT_GZIP) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"a compression dictionary may not be set in the "
"gzip format", -1));
Tcl_SetErrorCode(interp, "TCL", "ZIP", "BADOPT", NULL);
goto genericOptionError;
}
compDictObj = objv[i];
break;
}
}
if (compDictObj && (NULL == Tcl_GetBytesFromObj(interp, compDictObj, (Tcl_Size *)NULL))) {
return TCL_ERROR;
}
if (ZlibStackChannelTransform(interp, mode, format, level, limit, chan,
headerObj, compDictObj) == NULL) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2769 2770 2771 2772 2773 2774 2775 |
flush = Z_FINISH;
}
break;
case ao_buffer: /* -buffer */
if (i == objc-2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-buffer\" option must be followed by integer "
| | | | | | 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 |
flush = Z_FINISH;
}
break;
case ao_buffer: /* -buffer */
if (i == objc-2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-buffer\" option must be followed by integer "
"decompression buffersize", -1));
Tcl_SetErrorCode(interp, "TCL", "ZIP", "NOVAL", NULL);
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[++i], &buffersize) != TCL_OK) {
return TCL_ERROR;
}
if (buffersize < 1 || buffersize > MAX_BUFFER_SIZE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"buffer size must be 1 to %d",
MAX_BUFFER_SIZE));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "BUFFERSIZE", NULL);
return TCL_ERROR;
}
break;
case ao_dictionary:
if (i == objc-2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-dictionary\" option must be followed by"
" compression dictionary bytes", -1));
Tcl_SetErrorCode(interp, "TCL", "ZIP", "NOVAL", NULL);
return TCL_ERROR;
}
compDictObj = objv[++i];
break;
}
if (flush == -2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-flush\", \"-fullflush\" and \"-finalize\" options"
" are mutually exclusive", -1));
Tcl_SetErrorCode(interp, "TCL", "ZIP", "EXCLUSIVE", NULL);
return TCL_ERROR;
}
}
if (flush == -1) {
flush = 0;
}
/*
* Set the compression dictionary if requested.
*/
if (compDictObj != NULL) {
Tcl_Size len = 0;
if (NULL == Tcl_GetBytesFromObj(interp, compDictObj, &len)) {
return TCL_ERROR;
}
if (len == 0) {
compDictObj = NULL;
|
| ︙ | ︙ | |||
2896 2897 2898 2899 2900 2901 2902 |
flush = Z_FINISH;
}
break;
case po_dictionary:
if (i == objc-2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-dictionary\" option must be followed by"
| | | | | 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 |
flush = Z_FINISH;
}
break;
case po_dictionary:
if (i == objc-2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-dictionary\" option must be followed by"
" compression dictionary bytes", -1));
Tcl_SetErrorCode(interp, "TCL", "ZIP", "NOVAL", NULL);
return TCL_ERROR;
}
compDictObj = objv[++i];
break;
}
if (flush == -2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"\"-flush\", \"-fullflush\" and \"-finalize\" options"
" are mutually exclusive", -1));
Tcl_SetErrorCode(interp, "TCL", "ZIP", "EXCLUSIVE", NULL);
return TCL_ERROR;
}
}
if (flush == -1) {
flush = 0;
}
/*
* Set the compression dictionary if requested.
*/
if (compDictObj != NULL) {
Tcl_Size len = 0;
if (NULL == Tcl_GetBytesFromObj(interp, compDictObj, &len)) {
return TCL_ERROR;
}
if (len == 0) {
compDictObj = NULL;
}
|
| ︙ | ︙ | |||
2954 2955 2956 2957 2958 2959 2960 |
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return TCL_ERROR;
} else if (zshPtr->mode != TCL_ZLIB_STREAM_INFLATE
|| zshPtr->format != TCL_ZLIB_FORMAT_GZIP) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 |
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return TCL_ERROR;
} else if (zshPtr->mode != TCL_ZLIB_STREAM_INFLATE
|| zshPtr->format != TCL_ZLIB_FORMAT_GZIP) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"only gunzip streams can produce header information", -1));
Tcl_SetErrorCode(interp, "TCL", "ZIP", "BADOP", NULL);
return TCL_ERROR;
}
TclNewObj(resultObj);
ExtractHeader(&zshPtr->gzHeaderPtr->header, resultObj);
Tcl_SetObjResult(interp, resultObj);
|
| ︙ | ︙ | |||
3268 3269 3270 3271 3272 3273 3274 |
}
errObj = Tcl_NewListObj(0, NULL);
Tcl_ListObjAppendElement(NULL, errObj, Tcl_NewStringObj("-errorcode",-1));
Tcl_ListObjAppendElement(NULL, errObj,
ConvertErrorToList(e, cd->outStream.adler));
Tcl_ListObjAppendElement(NULL, errObj,
| | | 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 |
}
errObj = Tcl_NewListObj(0, NULL);
Tcl_ListObjAppendElement(NULL, errObj, Tcl_NewStringObj("-errorcode",-1));
Tcl_ListObjAppendElement(NULL, errObj,
ConvertErrorToList(e, cd->outStream.adler));
Tcl_ListObjAppendElement(NULL, errObj,
Tcl_NewStringObj(cd->outStream.msg, -1));
Tcl_SetChannelError(cd->parent, errObj);
*errorCodePtr = EINVAL;
return -1;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
3363 3364 3365 3366 3367 3368 3369 |
if (optionName && (strcmp(optionName, "-dictionary") == 0)
&& (cd->format != TCL_ZLIB_FORMAT_GZIP)) {
Tcl_Obj *compDictObj;
int code;
TclNewStringObj(compDictObj, value, strlen(value));
Tcl_IncrRefCount(compDictObj);
| | | 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 |
if (optionName && (strcmp(optionName, "-dictionary") == 0)
&& (cd->format != TCL_ZLIB_FORMAT_GZIP)) {
Tcl_Obj *compDictObj;
int code;
TclNewStringObj(compDictObj, value, strlen(value));
Tcl_IncrRefCount(compDictObj);
if (NULL == Tcl_GetBytesFromObj(interp, compDictObj, (Tcl_Size *)NULL)) {
Tcl_DecrRefCount(compDictObj);
return TCL_ERROR;
}
if (cd->compDictObj) {
TclDecrRefCount(cd->compDictObj);
}
cd->compDictObj = compDictObj;
|
| ︙ | ︙ | |||
3418 3419 3420 3421 3422 3423 3424 |
if (optionName && strcmp(optionName, "-limit") == 0) {
int newLimit;
if (Tcl_GetInt(interp, value, &newLimit) != TCL_OK) {
return TCL_ERROR;
} else if (newLimit < 1 || newLimit > MAX_BUFFER_SIZE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
| | | 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 |
if (optionName && strcmp(optionName, "-limit") == 0) {
int newLimit;
if (Tcl_GetInt(interp, value, &newLimit) != TCL_OK) {
return TCL_ERROR;
} else if (newLimit < 1 || newLimit > MAX_BUFFER_SIZE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"-limit must be between 1 and 65536", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "READLIMIT", NULL);
return TCL_ERROR;
}
}
}
if (setOptionProc == NULL) {
|
| ︙ | ︙ | |||
3487 3488 3489 3490 3491 3492 3493 |
if (cd->mode == TCL_ZLIB_STREAM_DEFLATE) {
crc = cd->outStream.adler;
} else {
crc = cd->inStream.adler;
}
| | | | | 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 |
if (cd->mode == TCL_ZLIB_STREAM_DEFLATE) {
crc = cd->outStream.adler;
} else {
crc = cd->inStream.adler;
}
snprintf(buf, sizeof(buf), "%lu", crc);
if (optionName == NULL) {
Tcl_DStringAppendElement(dsPtr, "-checksum");
Tcl_DStringAppendElement(dsPtr, buf);
} else {
Tcl_DStringAppend(dsPtr, buf, -1);
return TCL_OK;
}
}
if ((cd->format != TCL_ZLIB_FORMAT_GZIP) &&
(optionName == NULL || strcmp(optionName, "-dictionary") == 0)) {
/*
* Embedded NUL bytes are ok; they'll be C080-encoded.
*/
if (optionName == NULL) {
Tcl_DStringAppendElement(dsPtr, "-dictionary");
if (cd->compDictObj) {
Tcl_DStringAppendElement(dsPtr,
TclGetString(cd->compDictObj));
} else {
Tcl_DStringAppendElement(dsPtr, "");
}
} else {
if (cd->compDictObj) {
Tcl_Size length;
const char *str = Tcl_GetStringFromObj(cd->compDictObj, &length);
Tcl_DStringAppend(dsPtr, str, length);
}
return TCL_OK;
}
}
|
| ︙ | ︙ | |||
3818 3819 3820 3821 3822 3823 3824 |
chan = Tcl_StackChannel(interp, &zlibChannelType, cd,
Tcl_GetChannelMode(channel), channel);
if (chan == NULL) {
goto error;
}
cd->chan = chan;
cd->parent = Tcl_GetStackedChannel(chan);
| | | 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 |
chan = Tcl_StackChannel(interp, &zlibChannelType, cd,
Tcl_GetChannelMode(channel), channel);
if (chan == NULL) {
goto error;
}
cd->chan = chan;
cd->parent = Tcl_GetStackedChannel(chan);
Tcl_SetObjResult(interp, Tcl_NewStringObj(Tcl_GetChannelName(chan), -1));
return chan;
error:
if (cd->inBuffer) {
Tcl_Free(cd->inBuffer);
inflateEnd(&cd->inStream);
}
|
| ︙ | ︙ | |||
3948 3949 3950 3951 3952 3953 3954 |
handleError:
errObj = Tcl_NewListObj(0, NULL);
Tcl_ListObjAppendElement(NULL, errObj, Tcl_NewStringObj("-errorcode",-1));
Tcl_ListObjAppendElement(NULL, errObj,
ConvertErrorToList(e, cd->inStream.adler));
Tcl_ListObjAppendElement(NULL, errObj,
| | | 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 |
handleError:
errObj = Tcl_NewListObj(0, NULL);
Tcl_ListObjAppendElement(NULL, errObj, Tcl_NewStringObj("-errorcode",-1));
Tcl_ListObjAppendElement(NULL, errObj,
ConvertErrorToList(e, cd->inStream.adler));
Tcl_ListObjAppendElement(NULL, errObj,
Tcl_NewStringObj(cd->inStream.msg, -1));
Tcl_SetChannelError(cd->parent, errObj);
*errorCodePtr = EINVAL;
return -1;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
4023 4024 4025 4026 4027 4028 4029 |
int mode,
int format,
int level,
Tcl_Obj *dictObj,
Tcl_ZlibStream *zshandle)
{
if (interp) {
| | | 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 |
int mode,
int format,
int level,
Tcl_Obj *dictObj,
Tcl_ZlibStream *zshandle)
{
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("unimplemented", -1));
Tcl_SetErrorCode(interp, "TCL", "UNIMPLEMENTED", NULL);
}
return TCL_ERROR;
}
int
Tcl_ZlibStreamClose(
|
| ︙ | ︙ | |||
4091 4092 4093 4094 4095 4096 4097 |
Tcl_Interp *interp,
int format,
Tcl_Obj *data,
int level,
Tcl_Obj *gzipHeaderDictObj)
{
if (interp) {
| | | | 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 |
Tcl_Interp *interp,
int format,
Tcl_Obj *data,
int level,
Tcl_Obj *gzipHeaderDictObj)
{
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("unimplemented", -1));
Tcl_SetErrorCode(interp, "TCL", "UNIMPLEMENTED", NULL);
}
return TCL_ERROR;
}
int
Tcl_ZlibInflate(
Tcl_Interp *interp,
int format,
Tcl_Obj *data,
size_t bufferSize,
Tcl_Obj *gzipHeaderDictObj)
{
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("unimplemented", -1));
Tcl_SetErrorCode(interp, "TCL", "UNIMPLEMENTED", NULL);
}
return TCL_ERROR;
}
unsigned int
Tcl_ZlibCRC32(
|
| ︙ | ︙ |
Changes to library/auto.tcl.
| ︙ | ︙ | |||
176 177 178 179 180 181 182 |
if {0} {
lappend dirs [file join $grandParentDir library]
lappend dirs [file join $grandParentDir $basename$patch library]
lappend dirs [file join [file dirname $grandParentDir] \
$basename$patch library]
}
}
| | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
if {0} {
lappend dirs [file join $grandParentDir library]
lappend dirs [file join $grandParentDir $basename$patch library]
lappend dirs [file join [file dirname $grandParentDir] \
$basename$patch library]
}
}
# make $dirs unique, preserving order
array set seen {}
foreach i $dirs {
# Make sure $i is unique under normalization. Avoid repeated [source].
if {[interp issafe]} {
# Safe interps have no [file normalize].
set norm $i
} else {
|
| ︙ | ︙ | |||
376 377 378 379 380 381 382 | # interp. Put it back, but move it out of the way. $parser expose namespace $parser invokehidden rename namespace _%@namespace $parser expose eval $parser invokehidden rename eval _%@eval | | | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# interp. Put it back, but move it out of the way.
$parser expose namespace
$parser invokehidden rename namespace _%@namespace
$parser expose eval
$parser invokehidden rename eval _%@eval
# Install all the registered pseudo-command implementations
foreach cmd $initCommands {
eval $cmd
}
}
}
proc cleanup {} {
|
| ︙ | ︙ | |||
629 630 631 632 633 634 635 |
} on ok {} {
if {[namespace which -command tbcload::bcproc] eq ""} {
auto_load tbcload::bcproc
}
load {} tbcload $auto_mkindex_parser::parser
# AUTO MKINDEX: tbcload::bcproc name arglist body
| | | 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 |
} on ok {} {
if {[namespace which -command tbcload::bcproc] eq ""} {
auto_load tbcload::bcproc
}
load {} tbcload $auto_mkindex_parser::parser
# AUTO MKINDEX: tbcload::bcproc name arglist body
# Adds an entry to the auto index list for the given precompiled
# procedure name.
auto_mkindex_parser::commandInit tbcload::bcproc {name args} {
indexEntry $name
}
}
}
|
| ︙ | ︙ | |||
684 685 686 687 688 689 690 |
catch {
set name [dict get [lrange $args 1 end] -command]
if {![string match ::* $name]} {
set name ::[join [lreverse $contextStack] ::]$name
}
regsub -all ::+ $name :: name
}
| | | 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
catch {
set name [dict get [lrange $args 1 end] -command]
if {![string match ::* $name]} {
set name ::[join [lreverse $contextStack] ::]$name
}
regsub -all ::+ $name :: name
}
# create artificial proc to force an entry in the tclIndex
$parser eval [list ::proc $name {} {}]
}
}
}
}
# AUTO MKINDEX: oo::class create name ?definition?
|
| ︙ | ︙ |
Changes to library/clock.tcl.
| ︙ | ︙ | |||
219 220 221 222 223 224 225 |
::msgcat::mcset sv GREGORIAN_CHANGE_DATE 2361390
# Russia
::msgcat::mcset ru GREGORIAN_CHANGE_DATE 2421639
| | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
::msgcat::mcset sv GREGORIAN_CHANGE_DATE 2361390
# Russia
::msgcat::mcset ru GREGORIAN_CHANGE_DATE 2421639
# Romania (Transylvania changed earlier - perhaps de_RO should show the
# earlier date?)
::msgcat::mcset ro GREGORIAN_CHANGE_DATE 2422063
# Greece
::msgcat::mcset el GREGORIAN_CHANGE_DATE 2423480
|
| ︙ | ︙ | |||
2294 2295 2296 2297 2298 2299 2300 | # Parameters: # locale -- Desired locale # # Results: # Returns the locale that was previously current. # # Side effects: | | | 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 |
# Parameters:
# locale -- Desired locale
#
# Results:
# Returns the locale that was previously current.
#
# Side effects:
# Does [mclocale]. If necessary, loads the designated locale's files.
#
#----------------------------------------------------------------------
proc ::tcl::clock::EnterLocale { locale } {
if { $locale eq {system} } {
if { $::tcl_platform(platform) ne {windows} } {
# On a non-windows platform, the 'system' locale is the same as
|
| ︙ | ︙ | |||
2601 2602 2603 2604 2605 2606 2607 | # # ParseStarDate -- # # Parses a StarDate # # Parameters: # year - Year from the Roddenberry epoch | | | 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 | # # ParseStarDate -- # # Parses a StarDate # # Parameters: # year - Year from the Roddenberry epoch # fractYear - Fraction of a year specifying the day of year. # fractDay - Fraction of a day # # Results: # Returns a count of seconds from the Posix epoch. # # Side effects: # None. |
| ︙ | ︙ | |||
2971 2972 2973 2974 2975 2976 2977 | # Parameters: # None. # # Results: # Returns the system time zone. # # Side effects: | | | 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 |
# Parameters:
# None.
#
# Results:
# Returns the system time zone.
#
# Side effects:
# Stores the system time zone in the 'CachedSystemTimeZone'
# variable, since determining it may be an expensive process.
#
#----------------------------------------------------------------------
proc ::tcl::clock::GetSystemTimeZone {} {
variable CachedSystemTimeZone
variable TimeZoneBad
|
| ︙ | ︙ | |||
3397 3398 3399 3400 3401 3402 3403 |
set f [open $fname r]
fconfigure $f -translation binary
set d [read $f]
close $f
# The file begins with a magic number, sixteen reserved bytes, and then
| | | 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 |
set f [open $fname r]
fconfigure $f -translation binary
set d [read $f]
close $f
# The file begins with a magic number, sixteen reserved bytes, and then
# six 4-byte integers giving counts of fields in the file.
binary scan $d a4a1x15IIIIII \
magic version nIsGMT nIsStd nLeap nTime nType nChar
set seek 44
set ilen 4
set iformat I
if { $magic != {TZif} } {
|
| ︙ | ︙ |
Changes to library/history.tcl.
| ︙ | ︙ | |||
264 265 266 267 268 269 270 |
} else {
set i $event
}
if {$i <= $history(oldest)} {
return -code error "event \"$event\" is too far in the past"
}
if {$i > $history(nextid)} {
| | | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
} else {
set i $event
}
if {$i <= $history(oldest)} {
return -code error "event \"$event\" is too far in the past"
}
if {$i > $history(nextid)} {
return -code error "event \"$event\" hasn't occurred yet"
}
return $i
}
# tcl::HistEvent --
#
# Map from an event specifier to the value in the history list.
|
| ︙ | ︙ |
Changes to library/http/http.tcl.
| ︙ | ︙ | |||
3318 3319 3320 3321 3322 3323 3324 | # # Garbage collect the state associated with a transaction # # Arguments # token The token returned from http::geturl # # Side Effects | | | 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 |
#
# Garbage collect the state associated with a transaction
#
# Arguments
# token The token returned from http::geturl
#
# Side Effects
# Unsets the state array.
proc http::cleanup {token} {
variable $token
upvar 0 $token state
if {[info commands ${token}--EventCoroutine] ne {}} {
rename ${token}--EventCoroutine {}
}
|
| ︙ | ︙ | |||
3346 3347 3348 3349 3350 3351 3352 |
unset state
}
return
}
# http::Connect
#
| | | 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 |
unset state
}
return
}
# http::Connect
#
# This callback is made when an asynchronous connection completes.
#
# Arguments
# token The token returned from http::geturl
#
# Side Effects
# Sets the status of the connection, which unblocks
# the waiting geturl call
|
| ︙ | ︙ | |||
3388 3389 3390 3391 3392 3393 3394 | # else: # This is NOT a persistent socket that has been closed since its # last use. # If any other requests are in flight or pipelined/queued, they will # be discarded. } | | | 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 |
# else:
# This is NOT a persistent socket that has been closed since its
# last use.
# If any other requests are in flight or pipelined/queued, they will
# be discarded.
}
Finish $token "connect failed: $err"
return
}
# http::Write
#
# Write POST query data to the socket
#
|
| ︙ | ︙ | |||
4453 4454 4455 4456 4457 4458 4459 | # http::CopyDone # # fcopy completion callback # # Arguments # token The token returned from http::geturl | | | 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 |
# http::CopyDone
#
# fcopy completion callback
#
# Arguments
# token The token returned from http::geturl
# count The amount transferred
#
# Side Effects
# Invokes callbacks
proc http::CopyDone {token count {error {}}} {
variable $token
upvar 0 $token state
|
| ︙ | ︙ |
Changes to library/init.tcl.
| ︙ | ︙ | |||
136 137 138 139 140 141 142 |
# Some machines do not have exec. Also, on all
# platforms, safe interpreters do not have exec.
set auto_noexec 1
}
| | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# Some machines do not have exec. Also, on all
# platforms, safe interpreters do not have exec.
set auto_noexec 1
}
# Define a log command (which can be overwritten to log errors
# differently, specially when stderr is not available)
if {[namespace which -command tclLog] eq ""} {
proc tclLog {string} {
catch {puts stderr $string}
}
}
|
| ︙ | ︙ | |||
730 731 732 733 734 735 736 | # We used to throw an error here, but, looking more closely # at the core copy code in tclFCmd.c, if the destination # exists, then we should only call this function if -force # is true, which means we just want to over-write. So, # the following code is now commented out. # # return -code error "error $action \"$src\" to\ | | | | 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
# We used to throw an error here, but, looking more closely
# at the core copy code in tclFCmd.c, if the destination
# exists, then we should only call this function if -force
# is true, which means we just want to over-write. So,
# the following code is now commented out.
#
# return -code error "error $action \"$src\" to\
# \"$dest\": file exists"
} else {
# Depending on the platform, and on the current
# working directory, the directories '.', '..'
# can be returned in various combinations. Anyway,
# if any other file is returned, we must signal an error.
set existing [glob -nocomplain -directory $dest * .*]
lappend existing {*}[glob -nocomplain -directory $dest \
-type hidden * .*]
foreach s $existing {
if {[file tail $s] ni {. ..}} {
return -code error "error $action \"$src\" to\
\"$dest\": file exists"
}
}
}
} else {
if {[string first $nsrc $ndest] >= 0} {
set srclen [expr {[llength [file split $nsrc]] - 1}]
set ndest [lindex [file split $ndest] $srclen]
|
| ︙ | ︙ |
Changes to library/msgcat/msgcat.tcl.
| ︙ | ︙ | |||
30 31 32 33 34 35 36 |
variable LoadedLocales {}
# Records the locale of the currently sourced message catalogue file
variable FileLocale
# Configuration values per Package (e.g. client namespace).
# The dict key is of the form "<option> <namespace>" and the value is the
| | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
variable LoadedLocales {}
# Records the locale of the currently sourced message catalogue file
variable FileLocale
# Configuration values per Package (e.g. client namespace).
# The dict key is of the form "<option> <namespace>" and the value is the
# configuration option. A non-existing key is an unset option.
variable PackageConfig [dict create mcfolder {} loadcmd {} changecmd {}\
unknowncmd {} loadedlocales {} loclist {}]
# Records the mapping between source strings and translated strings. The
# dict key is of the form "<namespace> <locale> <src>", where locale and
# namespace should be themselves dict values and the value is
# the translated string.
|
| ︙ | ︙ | |||
207 208 209 210 211 212 213 214 215 216 217 218 219 220 | # msgcat::mcn -- # # Find the translation for the given string based on the current # locale setting. Check the passed namespace first, then look in each # parent namespace until the source is found. If additional args are # specified, use the format command to work them into the translated # string. # If no catalog item is found, mcunknown is called in the caller frame # and its result is returned. # # Arguments: # ns Package namespace of the translation # src The string to translate. # args Args to pass to the format command | > | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | # msgcat::mcn -- # # Find the translation for the given string based on the current # locale setting. Check the passed namespace first, then look in each # parent namespace until the source is found. If additional args are # specified, use the format command to work them into the translated # string. # # If no catalog item is found, mcunknown is called in the caller frame # and its result is returned. # # Arguments: # ns Package namespace of the translation # src The string to translate. # args Args to pass to the format command |
| ︙ | ︙ | |||
680 681 682 683 684 685 686 | # unset Clear option. return "". # # Available options are: # # mcfolder # The message catalog folder of the package. # This is automatically set by mcload. | | | 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 | # unset Clear option. return "". # # Available options are: # # mcfolder # The message catalog folder of the package. # This is automatically set by mcload. # If the value is changed using the set subcommand, an eventual # loadcmd is invoked and all message files of the package locale are # loaded. # # loadcmd # The command gets executed before a message file would be # sourced for this module. # The command is invoked with the expanded locale list to load. |
| ︙ | ︙ |
Changes to library/opt/optparse.tcl.
| ︙ | ︙ | |||
71 72 73 74 75 76 77 |
# Array storing the parsed descriptions
variable OptDesc
array set OptDesc {}
# Next potentially free key id (numeric)
variable OptDescN 0
# Inside algorithm/mechanism description:
| | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# Array storing the parsed descriptions
variable OptDesc
array set OptDesc {}
# Next potentially free key id (numeric)
variable OptDescN 0
# Inside algorithm/mechanism description:
# (not for the faint-hearted ;-)
#
# The argument description is parsed into a "program tree"
# It is called a "program" because it is the program used by
# the state machine interpreter that use that program to
# actually parse the arguments at run time.
#
# The general structure of a "program" is
|
| ︙ | ︙ | |||
130 131 132 133 134 135 136 | # Performance/Implementation issues # --------------------------------- # We use tcl lists instead of arrays because with tcl8.0 # they should start to be much faster. # But this code use a lot of helper procs (like Lvarset) # which are quite slow and would be helpfully optimized | | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# Performance/Implementation issues
# ---------------------------------
# We use tcl lists instead of arrays because with tcl8.0
# they should start to be much faster.
# But this code use a lot of helper procs (like Lvarset)
# which are quite slow and would be helpfully optimized
# for instance by being written in C. Also our structure
# is complex and there is maybe some places where the
# string rep might be calculated at great expense. to be checked.
#
# Parse a given description and saves it here under the given key
# generate a unused keyid if not given
#
proc ::tcl::OptKeyRegister {desc {key ""}} {
variable OptDesc
|
| ︙ | ︙ | |||
222 223 224 225 226 227 228 |
variable OptDesc
if {![info exists OptDesc($descKey)]} {
return -code error "Unknown option description key \"$descKey\""
}
set OptDesc($descKey)
}
| | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
variable OptDesc
if {![info exists OptDesc($descKey)]} {
return -code error "Unknown option description key \"$descKey\""
}
set OptDesc($descKey)
}
# Parse entry point for people who don't want to register with a key,
# for instance because the description changes dynamically.
# (otherwise one should really use OptKeyRegister once + OptKeyParse
# as it is way faster or simply OptProc which does it all)
# Assign a temporary key, call OptKeyParse and then free the storage
proc ::tcl::OptParse {desc arglist} {
set tempkey [OptKeyRegister $desc]
set ret [catch {uplevel 1 [list ::tcl::OptKeyParse $tempkey $arglist]} res]
|
| ︙ | ︙ | |||
324 325 326 327 328 329 330 |
set item [lindex $descriptions $adress]
if {[OptIsPrg $item]} {
return [OptCurAddr $item $start]
} else {
return $start
}
}
| | | | | | | | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
set item [lindex $descriptions $adress]
if {[OptIsPrg $item]} {
return [OptCurAddr $item $start]
} else {
return $start
}
}
# Set the value field of the current instruction.
proc OptCurSetValue {descriptionsName value} {
upvar $descriptionsName descriptions
# Get the current item full address.
set adress [OptCurAddr $descriptions]
# Use the 3rd field of the item (see OptValue / OptNewInst).
lappend adress 2
Lvarset descriptions $adress [list 1 $value]
# ^hasBeenSet flag
}
# Empty state means done/paste the end of the program.
proc OptState {item} {
lindex $item 0
}
# current state
proc OptCurState {descriptions} {
OptState [OptCurDesc $descriptions]
}
#######
# Arguments manipulation
# Returns the argument that has to be processed now.
proc OptCurrentArg {lst} {
lindex $lst 0
}
# Advance to next argument.
proc OptNextArg {argsName} {
uplevel 1 [list Lvarpop1 $argsName]
}
#######
|
| ︙ | ︙ | |||
549 550 551 552 553 554 555 |
set vnamesLst [OptTreeVars $item $level $vnamesLst]
} else {
set vname [OptVarName $item]
upvar $level $vname var
if {[OptHasBeenSet $item]} {
# puts "adding $vname"
# lets use the input name for the returned list
| | | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
set vnamesLst [OptTreeVars $item $level $vnamesLst]
} else {
set vname [OptVarName $item]
upvar $level $vname var
if {[OptHasBeenSet $item]} {
# puts "adding $vname"
# lets use the input name for the returned list
# it is more useful, for instance you can check that
# no flags at all was given with expr
# {![string match "*-*" $Args]}
lappend vnamesLst [OptName $item]
set var [OptValue $item]
} else {
set var [OptDefaultValue $item]
}
|
| ︙ | ︙ |
Changes to library/package.tcl.
| ︙ | ︙ | |||
65 66 67 68 69 70 71 | # Arguments: # -direct (optional) If this flag is present, the generated # code in pkgMkIndex.tcl will cause the package to be # loaded when "package require" is executed, rather # than lazily when the first reference to an exported # procedure in the package is made. # -verbose (optional) Verbose output; the name of each file that | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | # Arguments: # -direct (optional) If this flag is present, the generated # code in pkgMkIndex.tcl will cause the package to be # loaded when "package require" is executed, rather # than lazily when the first reference to an exported # procedure in the package is made. # -verbose (optional) Verbose output; the name of each file that # was successfully processed is printed out. Additionally, # if processing of a file failed a message is printed. # -load pat (optional) Preload any packages whose names match # the pattern. Used to handle DLLs that depend on # other packages during their Init procedure. # dir - Name of the directory in which to create the index. # args - Any number of additional arguments, each giving # a glob pattern that matches the names of one or |
| ︙ | ︙ | |||
205 206 207 208 209 210 211 |
}
}
}
proc tclPkgUnknown args {}
package unknown tclPkgUnknown
# Stub out the unknown command so package can call into each other
| | | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
}
}
}
proc tclPkgUnknown args {}
package unknown tclPkgUnknown
# Stub out the unknown command so package can call into each other
# during their initialization.
proc unknown {args} {}
# Stub out the auto_import mechanism
proc auto_import {args} {}
|
| ︙ | ︙ | |||
732 733 734 735 736 737 738 |
error [format $err(valueMissing) "-version"]
}
if {!([llength $opts(-source)] || [llength $opts(-load)])} {
error $err(noLoadOrSource)
}
| | | 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
error [format $err(valueMissing) "-version"]
}
if {!([llength $opts(-source)] || [llength $opts(-load)])} {
error $err(noLoadOrSource)
}
# OK, now everything is good. Generate the package ifneeded statement.
set cmdline "package ifneeded $opts(-name) $opts(-version) "
set cmdList {}
set lazyFileList {}
# Handle -load and -source specs
foreach key {load source} {
|
| ︙ | ︙ |
Changes to library/platform/platform.tcl.
| ︙ | ︙ | |||
261 262 263 264 265 266 267 |
upvar 1 $vv v
set libclist [lsort [glob -nocomplain -directory $base libc*]]
if {![llength $libclist]} { return 0 }
set libc [lindex $libclist 0]
| | | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
upvar 1 $vv v
set libclist [lsort [glob -nocomplain -directory $base libc*]]
if {![llength $libclist]} { return 0 }
set libc [lindex $libclist 0]
# Try executing the library first. This should succeed
# for a glibc library, and return the version
# information.
if {![catch {
set vdata [lindex [split [exec $libc] \n] 0]
}]} {
regexp {version ([0-9]+(\.[0-9]+)*)} $vdata -> v
|
| ︙ | ︙ |
Changes to library/platform/shell.tcl.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 |
proc ::platform::shell::generic {shell} {
# Argument is the path to a tcl shell.
CHECK $shell
LOCATE base out
set code {}
| | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
proc ::platform::shell::generic {shell} {
# Argument is the path to a tcl shell.
CHECK $shell
LOCATE base out
set code {}
# Forget any preexisting platform package, it might be in
# conflict with this one.
lappend code {package forget platform}
# Inject our platform package
lappend code [list source $base]
# Query and print the architecture
lappend code {puts [platform::generic]}
# And done
|
| ︙ | ︙ | |||
48 49 50 51 52 53 54 |
proc ::platform::shell::identify {shell} {
# Argument is the path to a tcl shell.
CHECK $shell
LOCATE base out
set code {}
| | | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
proc ::platform::shell::identify {shell} {
# Argument is the path to a tcl shell.
CHECK $shell
LOCATE base out
set code {}
# Forget any preexisting platform package, it might be in
# conflict with this one.
lappend code {package forget platform}
# Inject our platform package
lappend code [list source $base]
# Query and print the architecture
lappend code {puts [platform::identify]}
# And done
|
| ︙ | ︙ | |||
95 96 97 98 99 100 101 |
return
}
proc ::platform::shell::LOCATE {bv ov} {
upvar 1 $bv base $ov out
# Locate the platform package for injection into the specified
| | | | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
return
}
proc ::platform::shell::LOCATE {bv ov} {
upvar 1 $bv base $ov out
# Locate the platform package for injection into the specified
# shell. We are using package management to find it, wherever it
# is, instead of using hardwired relative paths. This allows us to
# install the two packages as TMs without breaking the code
# here. If the found package is wrapped we copy the code somewhere
# where the spawned shell will be able to read it.
# This code is brittle, it needs has to adapt to whatever changes
# are made to the TM code, i.e. the "provide" statement generated by
# tm.tcl
set pl [package ifneeded platform [package require platform]]
set base [lindex $pl end]
set out 0
if {[lindex [file system $base]] ne "native"} {
|
| ︙ | ︙ |
Changes to library/safe.tcl.
| ︙ | ︙ | |||
190 191 192 193 194 195 196 |
-deleteHook {
return [list -deleteHook $state(cleanupHook)]
}
-noStatics {
# it is most probably a set in fact but we would need
# then to jump to the set part and it is not *sure*
# that it is a set action that the user want, so force
| | | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
-deleteHook {
return [list -deleteHook $state(cleanupHook)]
}
-noStatics {
# it is most probably a set in fact but we would need
# then to jump to the set part and it is not *sure*
# that it is a set action that the user want, so force
# it to use the unambiguous -statics ?value? instead:
return -code error\
"ambigous query (get or set -noStatics ?)\
use -statics instead"
}
-nestedLoadOk {
return -code error\
"ambigous query (get or set -nestedLoadOk ?)\
|
| ︙ | ︙ | |||
245 246 247 248 249 250 251 |
set nested [InterpNested]
} else {
set nested $state(nestedok)
}
if {![::tcl::OptProcArgGiven -deleteHook]} {
set deleteHook $state(cleanupHook)
}
| | | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
set nested [InterpNested]
} else {
set nested $state(nestedok)
}
if {![::tcl::OptProcArgGiven -deleteHook]} {
set deleteHook $state(cleanupHook)
}
# Now reconfigure
set withAutoPath [::tcl::OptProcArgGiven -autoPath]
InterpSetConfig $child $accessPath $statics $nested $deleteHook $autoPath $withAutoPath
# auto_reset the child (to completely sync the new access_path) tests safe-9.8 safe-9.9
if {$doreset} {
if {[catch {::interp eval $child {auto_reset}} msg]} {
Log $child "auto_reset failed: $msg"
} else {
Log $child "successful auto_reset" NOTICE
}
|
| ︙ | ︙ | |||
371 372 373 374 375 376 377 | 0 [info library]] Log $child "tcl_libray was not in first in auto_path,\ moved it to front of child's access_path" NOTICE } set raw_auto_path $access_path | | | 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
0 [info library]]
Log $child "tcl_libray was not in first in auto_path,\
moved it to front of child's access_path" NOTICE
}
set raw_auto_path $access_path
# Add 1st level subdirs (will searched by auto loading from tcl
# code in the child using glob and thus fail, so we add them here
# so by default it works the same).
set access_path [AddSubDirs $access_path]
} else {
set raw_auto_path $autoPath
}
|
| ︙ | ︙ | |||
689 690 691 692 693 694 695 |
foreach sub [interp children $child] {
if {[info exists ::safe::[VarName [list $child $sub]]]} {
::safe::interpDelete [list $child $sub]
}
}
# If the child has a cleanup hook registered, call it. Check the
| | | 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
foreach sub [interp children $child] {
if {[info exists ::safe::[VarName [list $child $sub]]]} {
::safe::interpDelete [list $child $sub]
}
}
# If the child has a cleanup hook registered, call it. Check the
# existence because we might be called to delete an interp which has
# not been registered with us at all
if {[info exists state(cleanupHook)]} {
set hook $state(cleanupHook)
if {[llength $hook]} {
# remove the hook now, otherwise if the hook calls us somehow,
# we'll loop
|
| ︙ | ︙ | |||
723 724 725 726 727 728 729 |
::interp delete $child
Log $child "Deleted" NOTICE
}
return
}
| | | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
::interp delete $child
Log $child "Deleted" NOTICE
}
return
}
# Set (or get) the logging mechanism
proc ::safe::setLogCmd {args} {
variable Log
set la [llength $args]
if {$la == 0} {
return $Log
} elseif {$la == 1} {
|
| ︙ | ︙ |
Changes to library/tcltest/tcltest.tcl.
| ︙ | ︙ | |||
149 150 151 152 153 154 155 |
if {![file isdir $directory]} {
return -code error "\"$directory\" is not a directory"
}
return [AcceptReadable $directory]
}
##### Initialize internal arrays of tcltest, but only if the caller
| | | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
if {![file isdir $directory]} {
return -code error "\"$directory\" is not a directory"
}
return [AcceptReadable $directory]
}
##### Initialize internal arrays of tcltest, but only if the caller
# has not already preinitialized them. This is done to support
# compatibility with older tests that directly access internals
# rather than go through command interfaces.
#
proc ArrayDefault {varName value} {
variable $varName
if {[array exists $varName]} {
return
}
if {[info exists $varName]} {
# Preinitialized value is a scalar: Destroy it!
unset $varName
}
array set $varName $value
}
# save the original environment so that it can be restored later
ArrayDefault originalEnv [array get ::env]
|
| ︙ | ︙ | |||
192 193 194 195 196 197 198 |
# initialize the testConstraints array to keep track of valid
# predefined constraints (see the explanation for the
# InitConstraints proc for more details).
ArrayDefault testConstraints {}
##### Initialize internal variables of tcltest, but only if the caller
| | | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# initialize the testConstraints array to keep track of valid
# predefined constraints (see the explanation for the
# InitConstraints proc for more details).
ArrayDefault testConstraints {}
##### Initialize internal variables of tcltest, but only if the caller
# has not already preinitialized them. This is done to support
# compatibility with older tests that directly access internals
# rather than go through command interfaces.
#
proc Default {varName value {verify AcceptAll}} {
variable $varName
if {![info exists $varName]} {
variable $varName [$verify $value]
|
| ︙ | ︙ | |||
225 226 227 228 229 230 231 |
Default currentFailure false AcceptBoolean
Default failFiles {} AcceptList
# Tests should remove all files they create. The test suite will
# check the current working dir for files created by the tests.
# filesMade keeps track of such files created using the makeFile and
# makeDirectory procedures. filesExisted stores the names of
| | | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
Default currentFailure false AcceptBoolean
Default failFiles {} AcceptList
# Tests should remove all files they create. The test suite will
# check the current working dir for files created by the tests.
# filesMade keeps track of such files created using the makeFile and
# makeDirectory procedures. filesExisted stores the names of
# preexisting files.
#
# Note that $filesExisted lists only those files that exist in
# the original [temporaryDirectory].
Default filesMade {} AcceptList
Default filesExisted {} AcceptList
proc FillFilesExisted {} {
variable filesExisted
|
| ︙ | ︙ | |||
294 295 296 297 298 299 300 |
# stdout and stderr buffers for use when we want to store them
Default outData {}
Default errData {}
# keep track of test level for nested test commands
variable testLevel 0
| | | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# stdout and stderr buffers for use when we want to store them
Default outData {}
Default errData {}
# keep track of test level for nested test commands
variable testLevel 0
# the variables and procedures that existed when saveState was called are
# stored in a variable of the same name
Default saveState {}
# Internationalization support -- used in [SetIso8859_1_Locale] and
# [RestoreLocale]. Those commands are used in cmdIL.test.
if {![info exists [namespace current]::isoLocale]} {
|
| ︙ | ︙ | |||
350 351 352 353 354 355 356 | # (Hopefully this longer comment will be clear when I come # back in a few months, unlike its predecessor :) ) # # The [outputChannel] command (and underlying variable) have to # be kept in sync with the [configure -outfile] configuration # option ( and underlying variable Option(-outfile) ). This is # accomplished with a write trace on Option(-outfile) that will | | | | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | # (Hopefully this longer comment will be clear when I come # back in a few months, unlike its predecessor :) ) # # The [outputChannel] command (and underlying variable) have to # be kept in sync with the [configure -outfile] configuration # option ( and underlying variable Option(-outfile) ). This is # accomplished with a write trace on Option(-outfile) that will # update [outputChannel] whenever a new value is written. That # much is easy. # # The trick is that in order to maintain compatibility with # version 1 of tcltest, we must allow every configuration option # to get its initial value from command line arguments. This is # accomplished by setting initial read traces on all the # configuration options to parse the command line option the first # time they are read. These traces are cancelled whenever the # program itself calls [configure]. # # OK, then so to support tcltest 1 compatibility, it seems we want # to get the return from [outputFile] to trigger the read traces, |
| ︙ | ︙ | |||
478 479 480 481 482 483 484 |
variable Usage; array set Usage {}
# Verification commands for those options
variable Verify; array set Verify {}
# Initialize the default values of the configurable options that are
# historically associated with an exported variable. If that variable
| | | 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
variable Usage; array set Usage {}
# Verification commands for those options
variable Verify; array set Verify {}
# Initialize the default values of the configurable options that are
# historically associated with an exported variable. If that variable
# is already set, support compatibility by accepting its preset value.
# Use [trace] to establish ongoing connection between the deprecated
# exported variable and the modern option kept as a true internal var.
# Also set up usage string and value testing for the option.
proc Option {option value usage {verify AcceptAll} {varName {}}} {
variable Option
variable Verify
variable Usage
|
| ︙ | ︙ | |||
757 758 759 760 761 762 763 |
set directory [AcceptDirectory $directory]
if {![file writable $directory]} {
if {[workingDirectory] eq $directory} {
# Special exception: accept the default value
# even if the directory is not writable
return $directory
}
| | | 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 |
set directory [AcceptDirectory $directory]
if {![file writable $directory]} {
if {[workingDirectory] eq $directory} {
# Special exception: accept the default value
# even if the directory is not writable
return $directory
}
return -code error "\"$directory\" is not writable"
}
return $directory
}
# Directory where files should be created
Option -tmpdir [workingDirectory] {
Save temporary files in the specified directory.
|
| ︙ | ︙ | |||
848 849 850 851 852 853 854 | } ##################################################################### # tcltest::Debug* -- # # Internal helper procedures to write out debug information | | | 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 | } ##################################################################### # tcltest::Debug* -- # # Internal helper procedures to write out debug information # dependent on the chosen level. A test shell may override # them, f.e. to redirect the output into a different # channel, or even into a GUI. # tcltest::DebugPuts -- # # Prints the specified string if the current debug level is # higher than the provided level argument. |
| ︙ | ︙ | |||
1148 1149 1150 1151 1152 1153 1154 |
#
# Side effects:
# None.
proc tcltest::Asciify {s} {
set print ""
foreach c [split $s ""] {
| < | | | | | | | 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 |
#
# Side effects:
# None.
proc tcltest::Asciify {s} {
set print ""
foreach c [split $s ""] {
if {[string is print $c] && (($c <= "\x7E") || ($c == "\n"))} {
append print $c
} elseif {$c <= "\xFF"} {
append print \\x[format %02X [scan $c %c]]
} elseif {$c <= "\xFFFF"} {
append print \\u[format %04X [scan $c %c]]
} else {
append print \\U[format %08X [scan $c %c]]
}
}
return $print
}
# tcltest::ConstraintInitializer --
#
|
| ︙ | ︙ | |||
1786 1787 1788 1789 1790 1791 1792 |
#
proc tcltest::SubstArguments {argList} {
# We need to split the argList up into tokens but cannot use list
# operations as they throw away some significant quoting, and
# [split] ignores braces as it should. Therefore what we do is
| | | 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 |
#
proc tcltest::SubstArguments {argList} {
# We need to split the argList up into tokens but cannot use list
# operations as they throw away some significant quoting, and
# [split] ignores braces as it should. Therefore what we do is
# gradually build up a string out of whitespace-separated strings.
# We cannot use [split] to split the argList into whitespace
# separated strings as it throws away the whitespace which maybe
# important so we have to do it all by hand.
set result {}
set token ""
|
| ︙ | ︙ | |||
1893 1894 1895 1896 1897 1898 1899 |
# setup - Code to run before $script (above). This
# attribute is optional; default is {}.
# cleanup - Code to run after $script (above). This
# attribute is optional; default is {}.
# match - specifies type of matching to do on result,
# output, errorOutput; this must be a string
# previously registered by a call to [customMatch].
| | | 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 |
# setup - Code to run before $script (above). This
# attribute is optional; default is {}.
# cleanup - Code to run after $script (above). This
# attribute is optional; default is {}.
# match - specifies type of matching to do on result,
# output, errorOutput; this must be a string
# previously registered by a call to [customMatch].
# The strings exact, glob, and regexp are preregistered
# by the tcltest package. Default value is exact.
#
# Arguments:
# name - Name of test, in the form foo-1.2.
# description - Short textual description of the test, to
# help humans understand what it does.
#
|
| ︙ | ︙ | |||
1924 1925 1926 1927 1928 1929 1930 |
}
set TestNames($name) [info script]
}
FillFilesExisted
incr testLevel
| | | 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 |
}
set TestNames($name) [info script]
}
FillFilesExisted
incr testLevel
# Predefine everything to null except output and errorOutput. We
# determine whether or not to trap output based on whether or not
# these variables (output & errorOutput) are defined.
lassign {} constraints setup cleanup body result returnCodes errorCode match
# Set the default match mode
set match exact
|
| ︙ | ︙ | |||
2523 2524 2525 2526 2527 2528 2529 |
}
# Call the cleanup hook
cleanupTestsHook
# Remove files and directories created by the makeFile and
# makeDirectory procedures. Record the names of files in
| | | 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 |
}
# Call the cleanup hook
cleanupTestsHook
# Remove files and directories created by the makeFile and
# makeDirectory procedures. Record the names of files in
# workingDirectory that were not preexisting, and associate them
# with the test file that created them.
if {!$calledFromAllFile} {
foreach file $filesMade {
if {[file exists $file]} {
DebugDo 1 {Warn "cleanupTests deleting $file..."}
catch {file delete -force -- $file}
|
| ︙ | ︙ | |||
3481 3482 3483 3484 3485 3486 3487 |
return 1
}
return 0
}
# Initialize the constraints and set up command line arguments
namespace eval tcltest {
| | | | 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 |
return 1
}
return 0
}
# Initialize the constraints and set up command line arguments
namespace eval tcltest {
# Define initializers for all the built-in constraint definitions
DefineConstraintInitializers
# Set up the constraints in the testConstraints array to be lazily
# initialized by a registered initializer, or by "false" if no
# initializer is registered.
trace add variable testConstraints read [namespace code SafeFetch]
# Only initialize constraints at package load time if an
# [initConstraintsHook] has been predefined. This is only
# for compatibility support. The modern way to add a custom
# test constraint is to just call the [testConstraint] command
# straight away, without all this "hook" nonsense.
if {[namespace current] eq
[namespace qualifiers [namespace which initConstraintsHook]]} {
InitConstraints
} else {
|
| ︙ | ︙ |
Changes to library/tm.tcl.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | # [package require] something that wasn't there on the first scan. # # Either # 1) It is there now: If we rescan, you get it; if not you don't. # # This covers the possibility that the application asked for a package # late, and the package was actually added to the installation after the | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | # [package require] something that wasn't there on the first scan. # # Either # 1) It is there now: If we rescan, you get it; if not you don't. # # This covers the possibility that the application asked for a package # late, and the package was actually added to the installation after the # application was started. It should still be able to find it. # # 2) It still is not there: Either way, you don't get it, but the rescan # takes time. This is however an error case and we don't care that much # about it # # 3) It was there the first time; but for some reason a "package forget" has # been run, and "package" doesn't know about it anymore. # # This can be an indication that the application wishes to reload some # functionality. And should work as well. |
| ︙ | ︙ | |||
66 67 68 69 70 71 72 | # args - The paths to add/remove. Must not appear querying the # path with 'list'. # # Results # No result for subcommands 'add' and 'remove'. A list of paths for # 'list'. # | | | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# args - The paths to add/remove. Must not appear querying the
# path with 'list'.
#
# Results
# No result for subcommands 'add' and 'remove'. A list of paths for
# 'list'.
#
# Side effects
# The subcommands 'add' and 'remove' manipulate the list of paths to
# search for Tcl Modules. The subcommand 'list' has no side effects.
proc ::tcl::tm::add {args} {
# PART OF THE ::tcl::tm::path ENSEMBLE
#
# The path is added at the head to the list of module paths.
#
# The command enforces the restriction that no path may be an ancestor
# directory of any other path on the list. If the new path violates this
# restriction an error will be raised.
#
# If the path is already present as is no error will be raised and no
# action will be taken.
variable paths
# We use a copy of the path as source during validation, and extend it as
|
| ︙ | ︙ | |||
162 163 164 165 166 167 168 | # Unknown handler for Tcl Modules, i.e. packages in module form. # # Arguments # original - Original [package unknown] procedure. # name - Name of desired package. # version - Version of desired package. Can be the # empty string. | | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# Unknown handler for Tcl Modules, i.e. packages in module form.
#
# Arguments
# original - Original [package unknown] procedure.
# name - Name of desired package.
# version - Version of desired package. Can be the
# empty string.
# exact - Either -exact or omitted.
#
# Name, version, and exact are used to determine satisfaction. The
# original is called iff no satisfaction was achieved. The name is also
# used to compute the directory to target in the search.
#
# Results
# None.
#
# Side effects
# May populate the package ifneeded database with additional provide
# scripts.
proc ::tcl::tm::UnknownHandler {original name args} {
# Import the list of paths to search for packages in module form.
# Import the pattern used to check package names in detail.
|
| ︙ | ︙ | |||
306 307 308 309 310 311 312 | # # Arguments # None # # Results # None. # | | | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
#
# Arguments
# None
#
# Results
# None.
#
# Side effects
# May add paths to the list of defaults.
proc ::tcl::tm::Defaults {} {
global env tcl_platform
regexp {^(\d+)\.(\d+)} [package provide tcl] - major minor
set exe [file normalize [info nameofexecutable]]
|
| ︙ | ︙ | |||
354 355 356 357 358 359 360 | # # Arguments # paths - List of 'root' paths to derive search paths from. # # Results # No result. # | | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
#
# Arguments
# paths - List of 'root' paths to derive search paths from.
#
# Results
# No result.
#
# Side effects
# Calls 'path add' to paths to the list of module search paths.
proc ::tcl::tm::roots {paths} {
regexp {^(\d+)\.(\d+)} [package provide tcl] - major minor
foreach pa $paths {
set p [file join $pa tcl$major]
for {set n $minor} {$n >= 0} {incr n -1} {
|
| ︙ | ︙ |
Changes to library/tzdata/Africa/Cairo.
| ︙ | ︙ | |||
125 126 127 128 129 130 131 132 |
{1281474000 7200 0 EET}
{1284069600 10800 1 EEST}
{1285880400 7200 0 EET}
{1400191200 10800 1 EEST}
{1403816400 7200 0 EET}
{1406844000 10800 1 EEST}
{1411678800 7200 0 EET}
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
{1281474000 7200 0 EET}
{1284069600 10800 1 EEST}
{1285880400 7200 0 EET}
{1400191200 10800 1 EEST}
{1403816400 7200 0 EET}
{1406844000 10800 1 EEST}
{1411678800 7200 0 EET}
{1682632800 10800 1 EEST}
{1698354000 7200 0 EET}
{1714082400 10800 1 EEST}
{1730408400 7200 0 EET}
{1745532000 10800 1 EEST}
{1761858000 7200 0 EET}
{1776981600 10800 1 EEST}
{1793307600 7200 0 EET}
{1809036000 10800 1 EEST}
{1824757200 7200 0 EET}
{1840485600 10800 1 EEST}
{1856206800 7200 0 EET}
{1871935200 10800 1 EEST}
{1887656400 7200 0 EET}
{1903384800 10800 1 EEST}
{1919710800 7200 0 EET}
{1934834400 10800 1 EEST}
{1951160400 7200 0 EET}
{1966888800 10800 1 EEST}
{1982610000 7200 0 EET}
{1998338400 10800 1 EEST}
{2014059600 7200 0 EET}
{2029788000 10800 1 EEST}
{2045509200 7200 0 EET}
{2061237600 10800 1 EEST}
{2076958800 7200 0 EET}
{2092687200 10800 1 EEST}
{2109013200 7200 0 EET}
{2124136800 10800 1 EEST}
{2140462800 7200 0 EET}
{2156191200 10800 1 EEST}
{2171912400 7200 0 EET}
{2187640800 10800 1 EEST}
{2203362000 7200 0 EET}
{2219090400 10800 1 EEST}
{2234811600 7200 0 EET}
{2250540000 10800 1 EEST}
{2266866000 7200 0 EET}
{2281989600 10800 1 EEST}
{2298315600 7200 0 EET}
{2313439200 10800 1 EEST}
{2329765200 7200 0 EET}
{2345493600 10800 1 EEST}
{2361214800 7200 0 EET}
{2376943200 10800 1 EEST}
{2392664400 7200 0 EET}
{2408392800 10800 1 EEST}
{2424114000 7200 0 EET}
{2439842400 10800 1 EEST}
{2456168400 7200 0 EET}
{2471292000 10800 1 EEST}
{2487618000 7200 0 EET}
{2503346400 10800 1 EEST}
{2519067600 7200 0 EET}
{2534796000 10800 1 EEST}
{2550517200 7200 0 EET}
{2566245600 10800 1 EEST}
{2581966800 7200 0 EET}
{2597695200 10800 1 EEST}
{2614021200 7200 0 EET}
{2629144800 10800 1 EEST}
{2645470800 7200 0 EET}
{2660594400 10800 1 EEST}
{2676920400 7200 0 EET}
{2692648800 10800 1 EEST}
{2708370000 7200 0 EET}
{2724098400 10800 1 EEST}
{2739819600 7200 0 EET}
{2755548000 10800 1 EEST}
{2771269200 7200 0 EET}
{2786997600 10800 1 EEST}
{2803323600 7200 0 EET}
{2818447200 10800 1 EEST}
{2834773200 7200 0 EET}
{2850501600 10800 1 EEST}
{2866222800 7200 0 EET}
{2881951200 10800 1 EEST}
{2897672400 7200 0 EET}
{2913400800 10800 1 EEST}
{2929122000 7200 0 EET}
{2944850400 10800 1 EEST}
{2960571600 7200 0 EET}
{2976300000 10800 1 EEST}
{2992626000 7200 0 EET}
{3007749600 10800 1 EEST}
{3024075600 7200 0 EET}
{3039804000 10800 1 EEST}
{3055525200 7200 0 EET}
{3071253600 10800 1 EEST}
{3086974800 7200 0 EET}
{3102703200 10800 1 EEST}
{3118424400 7200 0 EET}
{3134152800 10800 1 EEST}
{3150478800 7200 0 EET}
{3165602400 10800 1 EEST}
{3181928400 7200 0 EET}
{3197052000 10800 1 EEST}
{3213378000 7200 0 EET}
{3229106400 10800 1 EEST}
{3244827600 7200 0 EET}
{3260556000 10800 1 EEST}
{3276277200 7200 0 EET}
{3292005600 10800 1 EEST}
{3307726800 7200 0 EET}
{3323455200 10800 1 EEST}
{3339781200 7200 0 EET}
{3354904800 10800 1 EEST}
{3371230800 7200 0 EET}
{3386959200 10800 1 EEST}
{3402680400 7200 0 EET}
{3418408800 10800 1 EEST}
{3434130000 7200 0 EET}
{3449858400 10800 1 EEST}
{3465579600 7200 0 EET}
{3481308000 10800 1 EEST}
{3497634000 7200 0 EET}
{3512757600 10800 1 EEST}
{3529083600 7200 0 EET}
{3544207200 10800 1 EEST}
{3560533200 7200 0 EET}
{3576261600 10800 1 EEST}
{3591982800 7200 0 EET}
{3607711200 10800 1 EEST}
{3623432400 7200 0 EET}
{3639160800 10800 1 EEST}
{3654882000 7200 0 EET}
{3670610400 10800 1 EEST}
{3686936400 7200 0 EET}
{3702060000 10800 1 EEST}
{3718386000 7200 0 EET}
{3734114400 10800 1 EEST}
{3749835600 7200 0 EET}
{3765564000 10800 1 EEST}
{3781285200 7200 0 EET}
{3797013600 10800 1 EEST}
{3812734800 7200 0 EET}
{3828463200 10800 1 EEST}
{3844184400 7200 0 EET}
{3859912800 10800 1 EEST}
{3876238800 7200 0 EET}
{3891362400 10800 1 EEST}
{3907688400 7200 0 EET}
{3923416800 10800 1 EEST}
{3939138000 7200 0 EET}
{3954866400 10800 1 EEST}
{3970587600 7200 0 EET}
{3986316000 10800 1 EEST}
{4002037200 7200 0 EET}
{4017765600 10800 1 EEST}
{4034091600 7200 0 EET}
{4049215200 10800 1 EEST}
{4065541200 7200 0 EET}
{4080664800 10800 1 EEST}
{4096990800 7200 0 EET}
}
|
Changes to library/tzdata/Africa/Casablanca.
| ︙ | ︙ | |||
62 63 64 65 66 67 68 |
{1587261600 0 1 +01}
{1590890400 3600 0 +01}
{1618106400 0 1 +01}
{1621130400 3600 0 +01}
{1648346400 0 1 +01}
{1651975200 3600 0 +01}
{1679191200 0 1 +01}
| | | | | | | | | | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
{1587261600 0 1 +01}
{1590890400 3600 0 +01}
{1618106400 0 1 +01}
{1621130400 3600 0 +01}
{1648346400 0 1 +01}
{1651975200 3600 0 +01}
{1679191200 0 1 +01}
{1682215200 3600 0 +01}
{1710036000 0 1 +01}
{1713060000 3600 0 +01}
{1740276000 0 1 +01}
{1743904800 3600 0 +01}
{1771120800 0 1 +01}
{1774144800 3600 0 +01}
{1801965600 0 1 +01}
{1804989600 3600 0 +01}
{1832205600 0 1 +01}
{1835834400 3600 0 +01}
{1863050400 0 1 +01}
{1866074400 3600 0 +01}
{1893290400 0 1 +01}
{1896919200 3600 0 +01}
{1924135200 0 1 +01}
{1927159200 3600 0 +01}
{1954980000 0 1 +01}
{1958004000 3600 0 +01}
{1985220000 0 1 +01}
{1988848800 3600 0 +01}
{2016064800 0 1 +01}
{2019088800 3600 0 +01}
{2046304800 0 1 +01}
{2049933600 3600 0 +01}
{2077149600 0 1 +01}
{2080778400 3600 0 +01}
{2107994400 0 1 +01}
{2111018400 3600 0 +01}
{2138234400 0 1 +01}
{2141863200 3600 0 +01}
{2169079200 0 1 +01}
{2172103200 3600 0 +01}
{2199924000 0 1 +01}
{2202948000 3600 0 +01}
{2230164000 0 1 +01}
{2233792800 3600 0 +01}
{2261008800 0 1 +01}
{2264032800 3600 0 +01}
{2291248800 0 1 +01}
{2294877600 3600 0 +01}
{2322093600 0 1 +01}
{2325722400 3600 0 +01}
{2352938400 0 1 +01}
{2355962400 3600 0 +01}
{2383178400 0 1 +01}
{2386807200 3600 0 +01}
{2414023200 0 1 +01}
{2417047200 3600 0 +01}
{2444868000 0 1 +01}
{2447892000 3600 0 +01}
{2475108000 0 1 +01}
{2478736800 3600 0 +01}
{2505952800 0 1 +01}
{2508976800 3600 0 +01}
{2536192800 0 1 +01}
{2539821600 3600 0 +01}
{2567037600 0 1 +01}
{2570666400 3600 0 +01}
{2597882400 0 1 +01}
{2600906400 3600 0 +01}
{2628122400 0 1 +01}
{2631751200 3600 0 +01}
{2658967200 0 1 +01}
{2661991200 3600 0 +01}
{2689812000 0 1 +01}
{2692836000 3600 0 +01}
{2720052000 0 1 +01}
{2723680800 3600 0 +01}
{2750896800 0 1 +01}
{2753920800 3600 0 +01}
{2781136800 0 1 +01}
{2784765600 3600 0 +01}
{2811981600 0 1 +01}
{2815610400 3600 0 +01}
{2842826400 0 1 +01}
{2845850400 3600 0 +01}
{2873066400 0 1 +01}
{2876695200 3600 0 +01}
{2903911200 0 1 +01}
{2906935200 3600 0 +01}
{2934756000 0 1 +01}
{2937780000 3600 0 +01}
{2964996000 0 1 +01}
{2968624800 3600 0 +01}
{2995840800 0 1 +01}
{2998864800 3600 0 +01}
{3026080800 0 1 +01}
{3029709600 3600 0 +01}
{3056925600 0 1 +01}
{3060554400 3600 0 +01}
{3087770400 0 1 +01}
{3090794400 3600 0 +01}
{3118010400 0 1 +01}
{3121639200 3600 0 +01}
{3148855200 0 1 +01}
{3151879200 3600 0 +01}
{3179700000 0 1 +01}
{3182724000 3600 0 +01}
{3209940000 0 1 +01}
{3213568800 3600 0 +01}
{3240784800 0 1 +01}
{3243808800 3600 0 +01}
{3271024800 0 1 +01}
{3274653600 3600 0 +01}
{3301869600 0 1 +01}
{3305498400 3600 0 +01}
{3332714400 0 1 +01}
{3335738400 3600 0 +01}
{3362954400 0 1 +01}
{3366583200 3600 0 +01}
{3393799200 0 1 +01}
{3396823200 3600 0 +01}
{3424644000 0 1 +01}
{3427668000 3600 0 +01}
{3454884000 0 1 +01}
{3458512800 3600 0 +01}
{3485728800 0 1 +01}
{3488752800 3600 0 +01}
{3515968800 0 1 +01}
{3519597600 3600 0 +01}
{3546813600 0 1 +01}
{3549837600 3600 0 +01}
{3577658400 0 1 +01}
{3580682400 3600 0 +01}
{3607898400 0 1 +01}
{3611527200 3600 0 +01}
{3638743200 0 1 +01}
{3641767200 3600 0 +01}
{3669588000 0 1 +01}
{3672612000 3600 0 +01}
{3699828000 0 1 +01}
{3703456800 3600 0 +01}
}
|
Changes to library/tzdata/Africa/El_Aaiun.
| ︙ | ︙ | |||
51 52 53 54 55 56 57 |
{1587261600 0 1 +01}
{1590890400 3600 0 +01}
{1618106400 0 1 +01}
{1621130400 3600 0 +01}
{1648346400 0 1 +01}
{1651975200 3600 0 +01}
{1679191200 0 1 +01}
| | | | | | | | | | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
{1587261600 0 1 +01}
{1590890400 3600 0 +01}
{1618106400 0 1 +01}
{1621130400 3600 0 +01}
{1648346400 0 1 +01}
{1651975200 3600 0 +01}
{1679191200 0 1 +01}
{1682215200 3600 0 +01}
{1710036000 0 1 +01}
{1713060000 3600 0 +01}
{1740276000 0 1 +01}
{1743904800 3600 0 +01}
{1771120800 0 1 +01}
{1774144800 3600 0 +01}
{1801965600 0 1 +01}
{1804989600 3600 0 +01}
{1832205600 0 1 +01}
{1835834400 3600 0 +01}
{1863050400 0 1 +01}
{1866074400 3600 0 +01}
{1893290400 0 1 +01}
{1896919200 3600 0 +01}
{1924135200 0 1 +01}
{1927159200 3600 0 +01}
{1954980000 0 1 +01}
{1958004000 3600 0 +01}
{1985220000 0 1 +01}
{1988848800 3600 0 +01}
{2016064800 0 1 +01}
{2019088800 3600 0 +01}
{2046304800 0 1 +01}
{2049933600 3600 0 +01}
{2077149600 0 1 +01}
{2080778400 3600 0 +01}
{2107994400 0 1 +01}
{2111018400 3600 0 +01}
{2138234400 0 1 +01}
{2141863200 3600 0 +01}
{2169079200 0 1 +01}
{2172103200 3600 0 +01}
{2199924000 0 1 +01}
{2202948000 3600 0 +01}
{2230164000 0 1 +01}
{2233792800 3600 0 +01}
{2261008800 0 1 +01}
{2264032800 3600 0 +01}
{2291248800 0 1 +01}
{2294877600 3600 0 +01}
{2322093600 0 1 +01}
{2325722400 3600 0 +01}
{2352938400 0 1 +01}
{2355962400 3600 0 +01}
{2383178400 0 1 +01}
{2386807200 3600 0 +01}
{2414023200 0 1 +01}
{2417047200 3600 0 +01}
{2444868000 0 1 +01}
{2447892000 3600 0 +01}
{2475108000 0 1 +01}
{2478736800 3600 0 +01}
{2505952800 0 1 +01}
{2508976800 3600 0 +01}
{2536192800 0 1 +01}
{2539821600 3600 0 +01}
{2567037600 0 1 +01}
{2570666400 3600 0 +01}
{2597882400 0 1 +01}
{2600906400 3600 0 +01}
{2628122400 0 1 +01}
{2631751200 3600 0 +01}
{2658967200 0 1 +01}
{2661991200 3600 0 +01}
{2689812000 0 1 +01}
{2692836000 3600 0 +01}
{2720052000 0 1 +01}
{2723680800 3600 0 +01}
{2750896800 0 1 +01}
{2753920800 3600 0 +01}
{2781136800 0 1 +01}
{2784765600 3600 0 +01}
{2811981600 0 1 +01}
{2815610400 3600 0 +01}
{2842826400 0 1 +01}
{2845850400 3600 0 +01}
{2873066400 0 1 +01}
{2876695200 3600 0 +01}
{2903911200 0 1 +01}
{2906935200 3600 0 +01}
{2934756000 0 1 +01}
{2937780000 3600 0 +01}
{2964996000 0 1 +01}
{2968624800 3600 0 +01}
{2995840800 0 1 +01}
{2998864800 3600 0 +01}
{3026080800 0 1 +01}
{3029709600 3600 0 +01}
{3056925600 0 1 +01}
{3060554400 3600 0 +01}
{3087770400 0 1 +01}
{3090794400 3600 0 +01}
{3118010400 0 1 +01}
{3121639200 3600 0 +01}
{3148855200 0 1 +01}
{3151879200 3600 0 +01}
{3179700000 0 1 +01}
{3182724000 3600 0 +01}
{3209940000 0 1 +01}
{3213568800 3600 0 +01}
{3240784800 0 1 +01}
{3243808800 3600 0 +01}
{3271024800 0 1 +01}
{3274653600 3600 0 +01}
{3301869600 0 1 +01}
{3305498400 3600 0 +01}
{3332714400 0 1 +01}
{3335738400 3600 0 +01}
{3362954400 0 1 +01}
{3366583200 3600 0 +01}
{3393799200 0 1 +01}
{3396823200 3600 0 +01}
{3424644000 0 1 +01}
{3427668000 3600 0 +01}
{3454884000 0 1 +01}
{3458512800 3600 0 +01}
{3485728800 0 1 +01}
{3488752800 3600 0 +01}
{3515968800 0 1 +01}
{3519597600 3600 0 +01}
{3546813600 0 1 +01}
{3549837600 3600 0 +01}
{3577658400 0 1 +01}
{3580682400 3600 0 +01}
{3607898400 0 1 +01}
{3611527200 3600 0 +01}
{3638743200 0 1 +01}
{3641767200 3600 0 +01}
{3669588000 0 1 +01}
{3672612000 3600 0 +01}
{3699828000 0 1 +01}
{3703456800 3600 0 +01}
}
|
Added library/tzdata/America/Ciudad_Juarez.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# created by tools/tclZIC.tcl - do not edit
set TZData(:America/Ciudad_Juarez) {
{-9223372036854775808 -25556 0 LMT}
{-1514739600 -25200 0 MST}
{-1343066400 -21600 0 CST}
{-1234807200 -25200 0 MST}
{-1220292000 -21600 1 MDT}
{-1207159200 -25200 0 MST}
{-1191344400 -21600 0 CST}
{820476000 -21600 0 CST}
{828864000 -18000 1 CDT}
{846399600 -21600 0 CST}
{860313600 -18000 1 CDT}
{877849200 -21600 0 CST}
{883634400 -21600 0 CST}
{891766800 -21600 0 MDT}
{909302400 -25200 0 MST}
{923216400 -21600 1 MDT}
{941356800 -25200 0 MST}
{954666000 -21600 1 MDT}
{972806400 -25200 0 MST}
{989139600 -21600 1 MDT}
{1001836800 -25200 0 MST}
{1018170000 -21600 1 MDT}
{1035705600 -25200 0 MST}
{1049619600 -21600 1 MDT}
{1067155200 -25200 0 MST}
{1081069200 -21600 1 MDT}
{1099209600 -25200 0 MST}
{1112518800 -21600 1 MDT}
{1130659200 -25200 0 MST}
{1143968400 -21600 1 MDT}
{1162108800 -25200 0 MST}
{1175418000 -21600 1 MDT}
{1193558400 -25200 0 MST}
{1207472400 -21600 1 MDT}
{1225008000 -25200 0 MST}
{1238922000 -21600 1 MDT}
{1256457600 -25200 0 MST}
{1262329200 -25200 0 MST}
{1268557200 -21600 1 MDT}
{1289116800 -25200 0 MST}
{1300006800 -21600 1 MDT}
{1320566400 -25200 0 MST}
{1331456400 -21600 1 MDT}
{1352016000 -25200 0 MST}
{1362906000 -21600 1 MDT}
{1383465600 -25200 0 MST}
{1394355600 -21600 1 MDT}
{1414915200 -25200 0 MST}
{1425805200 -21600 1 MDT}
{1446364800 -25200 0 MST}
{1457859600 -21600 1 MDT}
{1478419200 -25200 0 MST}
{1489309200 -21600 1 MDT}
{1509868800 -25200 0 MST}
{1520758800 -21600 1 MDT}
{1541318400 -25200 0 MST}
{1552208400 -21600 1 MDT}
{1572768000 -25200 0 MST}
{1583658000 -21600 1 MDT}
{1604217600 -25200 0 MST}
{1615712400 -21600 1 MDT}
{1636272000 -25200 0 MST}
{1647162000 -21600 1 MDT}
{1667120400 -21600 0 CST}
{1669788000 -25200 0 MST}
{1678611600 -21600 1 MDT}
{1699171200 -25200 0 MST}
{1710061200 -21600 1 MDT}
{1730620800 -25200 0 MST}
{1741510800 -21600 1 MDT}
{1762070400 -25200 0 MST}
{1772960400 -21600 1 MDT}
{1793520000 -25200 0 MST}
{1805014800 -21600 1 MDT}
{1825574400 -25200 0 MST}
{1836464400 -21600 1 MDT}
{1857024000 -25200 0 MST}
{1867914000 -21600 1 MDT}
{1888473600 -25200 0 MST}
{1899363600 -21600 1 MDT}
{1919923200 -25200 0 MST}
{1930813200 -21600 1 MDT}
{1951372800 -25200 0 MST}
{1962867600 -21600 1 MDT}
{1983427200 -25200 0 MST}
{1994317200 -21600 1 MDT}
{2014876800 -25200 0 MST}
{2025766800 -21600 1 MDT}
{2046326400 -25200 0 MST}
{2057216400 -21600 1 MDT}
{2077776000 -25200 0 MST}
{2088666000 -21600 1 MDT}
{2109225600 -25200 0 MST}
{2120115600 -21600 1 MDT}
{2140675200 -25200 0 MST}
{2152170000 -21600 1 MDT}
{2172729600 -25200 0 MST}
{2183619600 -21600 1 MDT}
{2204179200 -25200 0 MST}
{2215069200 -21600 1 MDT}
{2235628800 -25200 0 MST}
{2246518800 -21600 1 MDT}
{2267078400 -25200 0 MST}
{2277968400 -21600 1 MDT}
{2298528000 -25200 0 MST}
{2309418000 -21600 1 MDT}
{2329977600 -25200 0 MST}
{2341472400 -21600 1 MDT}
{2362032000 -25200 0 MST}
{2372922000 -21600 1 MDT}
{2393481600 -25200 0 MST}
{2404371600 -21600 1 MDT}
{2424931200 -25200 0 MST}
{2435821200 -21600 1 MDT}
{2456380800 -25200 0 MST}
{2467270800 -21600 1 MDT}
{2487830400 -25200 0 MST}
{2499325200 -21600 1 MDT}
{2519884800 -25200 0 MST}
{2530774800 -21600 1 MDT}
{2551334400 -25200 0 MST}
{2562224400 -21600 1 MDT}
{2582784000 -25200 0 MST}
{2593674000 -21600 1 MDT}
{2614233600 -25200 0 MST}
{2625123600 -21600 1 MDT}
{2645683200 -25200 0 MST}
{2656573200 -21600 1 MDT}
{2677132800 -25200 0 MST}
{2688627600 -21600 1 MDT}
{2709187200 -25200 0 MST}
{2720077200 -21600 1 MDT}
{2740636800 -25200 0 MST}
{2751526800 -21600 1 MDT}
{2772086400 -25200 0 MST}
{2782976400 -21600 1 MDT}
{2803536000 -25200 0 MST}
{2814426000 -21600 1 MDT}
{2834985600 -25200 0 MST}
{2846480400 -21600 1 MDT}
{2867040000 -25200 0 MST}
{2877930000 -21600 1 MDT}
{2898489600 -25200 0 MST}
{2909379600 -21600 1 MDT}
{2929939200 -25200 0 MST}
{2940829200 -21600 1 MDT}
{2961388800 -25200 0 MST}
{2972278800 -21600 1 MDT}
{2992838400 -25200 0 MST}
{3003728400 -21600 1 MDT}
{3024288000 -25200 0 MST}
{3035782800 -21600 1 MDT}
{3056342400 -25200 0 MST}
{3067232400 -21600 1 MDT}
{3087792000 -25200 0 MST}
{3098682000 -21600 1 MDT}
{3119241600 -25200 0 MST}
{3130131600 -21600 1 MDT}
{3150691200 -25200 0 MST}
{3161581200 -21600 1 MDT}
{3182140800 -25200 0 MST}
{3193030800 -21600 1 MDT}
{3213590400 -25200 0 MST}
{3225085200 -21600 1 MDT}
{3245644800 -25200 0 MST}
{3256534800 -21600 1 MDT}
{3277094400 -25200 0 MST}
{3287984400 -21600 1 MDT}
{3308544000 -25200 0 MST}
{3319434000 -21600 1 MDT}
{3339993600 -25200 0 MST}
{3350883600 -21600 1 MDT}
{3371443200 -25200 0 MST}
{3382938000 -21600 1 MDT}
{3403497600 -25200 0 MST}
{3414387600 -21600 1 MDT}
{3434947200 -25200 0 MST}
{3445837200 -21600 1 MDT}
{3466396800 -25200 0 MST}
{3477286800 -21600 1 MDT}
{3497846400 -25200 0 MST}
{3508736400 -21600 1 MDT}
{3529296000 -25200 0 MST}
{3540186000 -21600 1 MDT}
{3560745600 -25200 0 MST}
{3572240400 -21600 1 MDT}
{3592800000 -25200 0 MST}
{3603690000 -21600 1 MDT}
{3624249600 -25200 0 MST}
{3635139600 -21600 1 MDT}
{3655699200 -25200 0 MST}
{3666589200 -21600 1 MDT}
{3687148800 -25200 0 MST}
{3698038800 -21600 1 MDT}
{3718598400 -25200 0 MST}
{3730093200 -21600 1 MDT}
{3750652800 -25200 0 MST}
{3761542800 -21600 1 MDT}
{3782102400 -25200 0 MST}
{3792992400 -21600 1 MDT}
{3813552000 -25200 0 MST}
{3824442000 -21600 1 MDT}
{3845001600 -25200 0 MST}
{3855891600 -21600 1 MDT}
{3876451200 -25200 0 MST}
{3887341200 -21600 1 MDT}
{3907900800 -25200 0 MST}
{3919395600 -21600 1 MDT}
{3939955200 -25200 0 MST}
{3950845200 -21600 1 MDT}
{3971404800 -25200 0 MST}
{3982294800 -21600 1 MDT}
{4002854400 -25200 0 MST}
{4013744400 -21600 1 MDT}
{4034304000 -25200 0 MST}
{4045194000 -21600 1 MDT}
{4065753600 -25200 0 MST}
{4076643600 -21600 1 MDT}
{4097203200 -25200 0 MST}
}
|
Changes to library/tzdata/America/Nuuk.
| ︙ | ︙ | |||
85 86 87 88 89 90 91 |
{1572138000 -10800 0 -03}
{1585443600 -7200 1 -02}
{1603587600 -10800 0 -03}
{1616893200 -7200 1 -02}
{1635642000 -10800 0 -03}
{1648342800 -7200 1 -02}
{1667091600 -10800 0 -03}
| | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
{1572138000 -10800 0 -03}
{1585443600 -7200 1 -02}
{1603587600 -10800 0 -03}
{1616893200 -7200 1 -02}
{1635642000 -10800 0 -03}
{1648342800 -7200 1 -02}
{1667091600 -10800 0 -03}
{1679792400 -7200 1 -02}
{1698541200 -7200 0 -02}
{1711846800 -3600 1 -01}
{1729990800 -7200 0 -02}
{1743296400 -3600 1 -01}
{1761440400 -7200 0 -02}
{1774746000 -3600 1 -01}
{1792890000 -7200 0 -02}
{1806195600 -3600 1 -01}
{1824944400 -7200 0 -02}
{1837645200 -3600 1 -01}
{1856394000 -7200 0 -02}
{1869094800 -3600 1 -01}
{1887843600 -7200 0 -02}
{1901149200 -3600 1 -01}
{1919293200 -7200 0 -02}
{1932598800 -3600 1 -01}
{1950742800 -7200 0 -02}
{1964048400 -3600 1 -01}
{1982797200 -7200 0 -02}
{1995498000 -3600 1 -01}
{2014246800 -7200 0 -02}
{2026947600 -3600 1 -01}
{2045696400 -7200 0 -02}
{2058397200 -3600 1 -01}
{2077146000 -7200 0 -02}
{2090451600 -3600 1 -01}
{2108595600 -7200 0 -02}
{2121901200 -3600 1 -01}
{2140045200 -7200 0 -02}
{2153350800 -3600 1 -01}
{2172099600 -7200 0 -02}
{2184800400 -3600 1 -01}
{2203549200 -7200 0 -02}
{2216250000 -3600 1 -01}
{2234998800 -7200 0 -02}
{2248304400 -3600 1 -01}
{2266448400 -7200 0 -02}
{2279754000 -3600 1 -01}
{2297898000 -7200 0 -02}
{2311203600 -3600 1 -01}
{2329347600 -7200 0 -02}
{2342653200 -3600 1 -01}
{2361402000 -7200 0 -02}
{2374102800 -3600 1 -01}
{2392851600 -7200 0 -02}
{2405552400 -3600 1 -01}
{2424301200 -7200 0 -02}
{2437606800 -3600 1 -01}
{2455750800 -7200 0 -02}
{2469056400 -3600 1 -01}
{2487200400 -7200 0 -02}
{2500506000 -3600 1 -01}
{2519254800 -7200 0 -02}
{2531955600 -3600 1 -01}
{2550704400 -7200 0 -02}
{2563405200 -3600 1 -01}
{2582154000 -7200 0 -02}
{2595459600 -3600 1 -01}
{2613603600 -7200 0 -02}
{2626909200 -3600 1 -01}
{2645053200 -7200 0 -02}
{2658358800 -3600 1 -01}
{2676502800 -7200 0 -02}
{2689808400 -3600 1 -01}
{2708557200 -7200 0 -02}
{2721258000 -3600 1 -01}
{2740006800 -7200 0 -02}
{2752707600 -3600 1 -01}
{2771456400 -7200 0 -02}
{2784762000 -3600 1 -01}
{2802906000 -7200 0 -02}
{2816211600 -3600 1 -01}
{2834355600 -7200 0 -02}
{2847661200 -3600 1 -01}
{2866410000 -7200 0 -02}
{2879110800 -3600 1 -01}
{2897859600 -7200 0 -02}
{2910560400 -3600 1 -01}
{2929309200 -7200 0 -02}
{2942010000 -3600 1 -01}
{2960758800 -7200 0 -02}
{2974064400 -3600 1 -01}
{2992208400 -7200 0 -02}
{3005514000 -3600 1 -01}
{3023658000 -7200 0 -02}
{3036963600 -3600 1 -01}
{3055712400 -7200 0 -02}
{3068413200 -3600 1 -01}
{3087162000 -7200 0 -02}
{3099862800 -3600 1 -01}
{3118611600 -7200 0 -02}
{3131917200 -3600 1 -01}
{3150061200 -7200 0 -02}
{3163366800 -3600 1 -01}
{3181510800 -7200 0 -02}
{3194816400 -3600 1 -01}
{3212960400 -7200 0 -02}
{3226266000 -3600 1 -01}
{3245014800 -7200 0 -02}
{3257715600 -3600 1 -01}
{3276464400 -7200 0 -02}
{3289165200 -3600 1 -01}
{3307914000 -7200 0 -02}
{3321219600 -3600 1 -01}
{3339363600 -7200 0 -02}
{3352669200 -3600 1 -01}
{3370813200 -7200 0 -02}
{3384118800 -3600 1 -01}
{3402867600 -7200 0 -02}
{3415568400 -3600 1 -01}
{3434317200 -7200 0 -02}
{3447018000 -3600 1 -01}
{3465766800 -7200 0 -02}
{3479072400 -3600 1 -01}
{3497216400 -7200 0 -02}
{3510522000 -3600 1 -01}
{3528666000 -7200 0 -02}
{3541971600 -3600 1 -01}
{3560115600 -7200 0 -02}
{3573421200 -3600 1 -01}
{3592170000 -7200 0 -02}
{3604870800 -3600 1 -01}
{3623619600 -7200 0 -02}
{3636320400 -3600 1 -01}
{3655069200 -7200 0 -02}
{3668374800 -3600 1 -01}
{3686518800 -7200 0 -02}
{3699824400 -3600 1 -01}
{3717968400 -7200 0 -02}
{3731274000 -3600 1 -01}
{3750022800 -7200 0 -02}
{3762723600 -3600 1 -01}
{3781472400 -7200 0 -02}
{3794173200 -3600 1 -01}
{3812922000 -7200 0 -02}
{3825622800 -3600 1 -01}
{3844371600 -7200 0 -02}
{3857677200 -3600 1 -01}
{3875821200 -7200 0 -02}
{3889126800 -3600 1 -01}
{3907270800 -7200 0 -02}
{3920576400 -3600 1 -01}
{3939325200 -7200 0 -02}
{3952026000 -3600 1 -01}
{3970774800 -7200 0 -02}
{3983475600 -3600 1 -01}
{4002224400 -7200 0 -02}
{4015530000 -3600 1 -01}
{4033674000 -7200 0 -02}
{4046979600 -3600 1 -01}
{4065123600 -7200 0 -02}
{4078429200 -3600 1 -01}
{4096573200 -7200 0 -02}
}
|
Changes to library/tzdata/America/Yellowknife.
1 | # created by tools/tclZIC.tcl - do not edit | > > | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 |
# created by tools/tclZIC.tcl - do not edit
if {![info exists TZData(America/Edmonton)]} {
LoadTimeZoneFile America/Edmonton
}
set TZData(:America/Yellowknife) $TZData(:America/Edmonton)
|
Changes to library/tzdata/Asia/Gaza.
| ︙ | ︙ | |||
123 124 125 126 127 128 129 |
{1572037200 7200 0 EET}
{1585346400 10800 1 EEST}
{1603490400 7200 0 EET}
{1616796000 10800 1 EEST}
{1635458400 7200 0 EET}
{1648332000 10800 1 EEST}
{1666998000 7200 0 EET}
| | | | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
{1572037200 7200 0 EET}
{1585346400 10800 1 EEST}
{1603490400 7200 0 EET}
{1616796000 10800 1 EEST}
{1635458400 7200 0 EET}
{1648332000 10800 1 EEST}
{1666998000 7200 0 EET}
{1682726400 10800 1 EEST}
{1698447600 7200 0 EET}
{1712966400 10800 1 EEST}
{1729897200 7200 0 EET}
{1743811200 10800 1 EEST}
{1761346800 7200 0 EET}
{1774656000 10800 1 EEST}
{1792796400 7200 0 EET}
{1806105600 10800 1 EEST}
{1824850800 7200 0 EET}
{1837555200 10800 1 EEST}
{1856300400 7200 0 EET}
|
| ︙ | ︙ | |||
150 151 152 153 154 155 156 |
{1995408000 10800 1 EEST}
{2014153200 7200 0 EET}
{2026857600 10800 1 EEST}
{2045602800 7200 0 EET}
{2058307200 10800 1 EEST}
{2077052400 7200 0 EET}
{2090361600 10800 1 EEST}
| | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
{1995408000 10800 1 EEST}
{2014153200 7200 0 EET}
{2026857600 10800 1 EEST}
{2045602800 7200 0 EET}
{2058307200 10800 1 EEST}
{2077052400 7200 0 EET}
{2090361600 10800 1 EEST}
{2107897200 7200 0 EET}
{2121811200 10800 1 EEST}
{2138742000 7200 0 EET}
{2153260800 10800 1 EEST}
{2168982000 7200 0 EET}
{2184710400 10800 1 EEST}
{2199826800 7200 0 EET}
{2202854400 10800 1 EEST}
{2203455600 7200 0 EET}
{2216160000 10800 1 EEST}
{2230066800 7200 0 EET}
{2233699200 10800 1 EEST}
{2234905200 7200 0 EET}
{2248214400 10800 1 EEST}
{2260911600 7200 0 EET}
{2263939200 10800 1 EEST}
{2266354800 7200 0 EET}
{2279664000 10800 1 EEST}
{2291756400 7200 0 EET}
{2294784000 10800 1 EEST}
{2297804400 7200 0 EET}
{2311113600 10800 1 EEST}
{2321996400 7200 0 EET}
{2325628800 10800 1 EEST}
{2329254000 7200 0 EET}
{2342563200 10800 1 EEST}
{2352841200 7200 0 EET}
{2355868800 10800 1 EEST}
{2361308400 7200 0 EET}
{2374012800 10800 1 EEST}
{2383686000 7200 0 EET}
{2386713600 10800 1 EEST}
{2392758000 7200 0 EET}
{2405462400 10800 1 EEST}
{2413926000 7200 0 EET}
{2417558400 10800 1 EEST}
{2424207600 7200 0 EET}
{2437516800 10800 1 EEST}
{2444770800 7200 0 EET}
{2447798400 10800 1 EEST}
{2455657200 7200 0 EET}
{2468966400 10800 1 EEST}
{2475010800 7200 0 EET}
{2478643200 10800 1 EEST}
{2487106800 7200 0 EET}
{2500416000 10800 1 EEST}
{2505855600 7200 0 EET}
{2508883200 10800 1 EEST}
{2519161200 7200 0 EET}
{2531865600 10800 1 EEST}
{2536700400 7200 0 EET}
{2539728000 10800 1 EEST}
{2550610800 7200 0 EET}
{2563315200 10800 1 EEST}
{2566940400 7200 0 EET}
{2570572800 10800 1 EEST}
{2582060400 7200 0 EET}
{2595369600 10800 1 EEST}
{2597785200 7200 0 EET}
{2600812800 10800 1 EEST}
{2613510000 7200 0 EET}
{2626819200 10800 1 EEST}
{2628025200 7200 0 EET}
{2631657600 10800 1 EEST}
{2644959600 7200 0 EET}
{2658268800 10800 1 EEST}
{2658870000 7200 0 EET}
{2662502400 10800 1 EEST}
{2676409200 7200 0 EET}
{2692742400 10800 1 EEST}
{2708463600 7200 0 EET}
{2723587200 10800 1 EEST}
{2739913200 7200 0 EET}
{2753827200 10800 1 EEST}
{2771362800 7200 0 EET}
{2784672000 10800 1 EEST}
{2802812400 7200 0 EET}
{2816121600 10800 1 EEST}
{2834262000 7200 0 EET}
{2847571200 10800 1 EEST}
{2866316400 7200 0 EET}
|
| ︙ | ︙ | |||
214 215 216 217 218 219 220 |
{3005424000 10800 1 EEST}
{3023564400 7200 0 EET}
{3036873600 10800 1 EEST}
{3055618800 7200 0 EET}
{3068323200 10800 1 EEST}
{3087068400 7200 0 EET}
{3099772800 10800 1 EEST}
| | | | | > > > | > | | > | | | > > > > > > > > > > > > > > > > > > > > > > | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
{3005424000 10800 1 EEST}
{3023564400 7200 0 EET}
{3036873600 10800 1 EEST}
{3055618800 7200 0 EET}
{3068323200 10800 1 EEST}
{3087068400 7200 0 EET}
{3099772800 10800 1 EEST}
{3117913200 7200 0 EET}
{3131827200 10800 1 EEST}
{3148758000 7200 0 EET}
{3163276800 10800 1 EEST}
{3179602800 7200 0 EET}
{3194726400 10800 1 EEST}
{3209842800 7200 0 EET}
{3226176000 10800 1 EEST}
{3240687600 7200 0 EET}
{3243715200 10800 1 EEST}
{3257622000 10800 1 EEST}
{3271532400 7200 0 EET}
{3274560000 10800 1 EEST}
{3289071600 10800 1 EEST}
{3301772400 7200 0 EET}
{3305404800 10800 1 EEST}
{3321126000 10800 1 EEST}
{3332617200 7200 0 EET}
{3335644800 10800 1 EEST}
{3339270000 7200 0 EET}
{3352579200 10800 1 EEST}
{3362857200 7200 0 EET}
{3366489600 10800 1 EEST}
{3370719600 7200 0 EET}
{3384028800 10800 1 EEST}
{3393702000 7200 0 EET}
{3397334400 10800 1 EEST}
{3402774000 7200 0 EET}
{3415478400 10800 1 EEST}
{3424546800 7200 0 EET}
{3427574400 10800 1 EEST}
{3434223600 7200 0 EET}
{3446928000 10800 1 EEST}
{3454786800 7200 0 EET}
{3458419200 10800 1 EEST}
{3465673200 7200 0 EET}
{3478982400 10800 1 EEST}
{3485631600 7200 0 EET}
{3488659200 10800 1 EEST}
{3497122800 7200 0 EET}
{3510432000 10800 1 EEST}
{3516476400 7200 0 EET}
{3519504000 10800 1 EEST}
{3528572400 7200 0 EET}
{3541881600 10800 1 EEST}
{3546716400 7200 0 EET}
{3550348800 10800 1 EEST}
{3560022000 7200 0 EET}
{3573331200 10800 1 EEST}
{3577561200 7200 0 EET}
{3580588800 10800 1 EEST}
{3592076400 7200 0 EET}
{3604780800 10800 1 EEST}
{3607801200 7200 0 EET}
{3611433600 10800 1 EEST}
{3623526000 7200 0 EET}
{3636230400 10800 1 EEST}
{3638646000 7200 0 EET}
{3642278400 10800 1 EEST}
{3654975600 7200 0 EET}
{3668284800 10800 1 EEST}
{3669490800 7200 0 EET}
{3672518400 10800 1 EEST}
{3686425200 7200 0 EET}
{3699734400 10800 1 EEST}
{3717874800 7200 0 EET}
{3731184000 10800 1 EEST}
{3749929200 7200 0 EET}
{3762633600 10800 1 EEST}
{3781378800 7200 0 EET}
|
| ︙ | ︙ |
Changes to library/tzdata/Asia/Hebron.
| ︙ | ︙ | |||
122 123 124 125 126 127 128 |
{1572037200 7200 0 EET}
{1585346400 10800 1 EEST}
{1603490400 7200 0 EET}
{1616796000 10800 1 EEST}
{1635458400 7200 0 EET}
{1648332000 10800 1 EEST}
{1666998000 7200 0 EET}
| | | | | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
{1572037200 7200 0 EET}
{1585346400 10800 1 EEST}
{1603490400 7200 0 EET}
{1616796000 10800 1 EEST}
{1635458400 7200 0 EET}
{1648332000 10800 1 EEST}
{1666998000 7200 0 EET}
{1682726400 10800 1 EEST}
{1698447600 7200 0 EET}
{1712966400 10800 1 EEST}
{1729897200 7200 0 EET}
{1743811200 10800 1 EEST}
{1761346800 7200 0 EET}
{1774656000 10800 1 EEST}
{1792796400 7200 0 EET}
{1806105600 10800 1 EEST}
{1824850800 7200 0 EET}
{1837555200 10800 1 EEST}
{1856300400 7200 0 EET}
|
| ︙ | ︙ | |||
149 150 151 152 153 154 155 |
{1995408000 10800 1 EEST}
{2014153200 7200 0 EET}
{2026857600 10800 1 EEST}
{2045602800 7200 0 EET}
{2058307200 10800 1 EEST}
{2077052400 7200 0 EET}
{2090361600 10800 1 EEST}
| | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
{1995408000 10800 1 EEST}
{2014153200 7200 0 EET}
{2026857600 10800 1 EEST}
{2045602800 7200 0 EET}
{2058307200 10800 1 EEST}
{2077052400 7200 0 EET}
{2090361600 10800 1 EEST}
{2107897200 7200 0 EET}
{2121811200 10800 1 EEST}
{2138742000 7200 0 EET}
{2153260800 10800 1 EEST}
{2168982000 7200 0 EET}
{2184710400 10800 1 EEST}
{2199826800 7200 0 EET}
{2202854400 10800 1 EEST}
{2203455600 7200 0 EET}
{2216160000 10800 1 EEST}
{2230066800 7200 0 EET}
{2233699200 10800 1 EEST}
{2234905200 7200 0 EET}
{2248214400 10800 1 EEST}
{2260911600 7200 0 EET}
{2263939200 10800 1 EEST}
{2266354800 7200 0 EET}
{2279664000 10800 1 EEST}
{2291756400 7200 0 EET}
{2294784000 10800 1 EEST}
{2297804400 7200 0 EET}
{2311113600 10800 1 EEST}
{2321996400 7200 0 EET}
{2325628800 10800 1 EEST}
{2329254000 7200 0 EET}
{2342563200 10800 1 EEST}
{2352841200 7200 0 EET}
{2355868800 10800 1 EEST}
{2361308400 7200 0 EET}
{2374012800 10800 1 EEST}
{2383686000 7200 0 EET}
{2386713600 10800 1 EEST}
{2392758000 7200 0 EET}
{2405462400 10800 1 EEST}
{2413926000 7200 0 EET}
{2417558400 10800 1 EEST}
{2424207600 7200 0 EET}
{2437516800 10800 1 EEST}
{2444770800 7200 0 EET}
{2447798400 10800 1 EEST}
{2455657200 7200 0 EET}
{2468966400 10800 1 EEST}
{2475010800 7200 0 EET}
{2478643200 10800 1 EEST}
{2487106800 7200 0 EET}
{2500416000 10800 1 EEST}
{2505855600 7200 0 EET}
{2508883200 10800 1 EEST}
{2519161200 7200 0 EET}
{2531865600 10800 1 EEST}
{2536700400 7200 0 EET}
{2539728000 10800 1 EEST}
{2550610800 7200 0 EET}
{2563315200 10800 1 EEST}
{2566940400 7200 0 EET}
{2570572800 10800 1 EEST}
{2582060400 7200 0 EET}
{2595369600 10800 1 EEST}
{2597785200 7200 0 EET}
{2600812800 10800 1 EEST}
{2613510000 7200 0 EET}
{2626819200 10800 1 EEST}
{2628025200 7200 0 EET}
{2631657600 10800 1 EEST}
{2644959600 7200 0 EET}
{2658268800 10800 1 EEST}
{2658870000 7200 0 EET}
{2662502400 10800 1 EEST}
{2676409200 7200 0 EET}
{2692742400 10800 1 EEST}
{2708463600 7200 0 EET}
{2723587200 10800 1 EEST}
{2739913200 7200 0 EET}
{2753827200 10800 1 EEST}
{2771362800 7200 0 EET}
{2784672000 10800 1 EEST}
{2802812400 7200 0 EET}
{2816121600 10800 1 EEST}
{2834262000 7200 0 EET}
{2847571200 10800 1 EEST}
{2866316400 7200 0 EET}
|
| ︙ | ︙ | |||
213 214 215 216 217 218 219 |
{3005424000 10800 1 EEST}
{3023564400 7200 0 EET}
{3036873600 10800 1 EEST}
{3055618800 7200 0 EET}
{3068323200 10800 1 EEST}
{3087068400 7200 0 EET}
{3099772800 10800 1 EEST}
| | | | | > > > | > | | > | | | > > > > > > > > > > > > > > > > > > > > > > | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
{3005424000 10800 1 EEST}
{3023564400 7200 0 EET}
{3036873600 10800 1 EEST}
{3055618800 7200 0 EET}
{3068323200 10800 1 EEST}
{3087068400 7200 0 EET}
{3099772800 10800 1 EEST}
{3117913200 7200 0 EET}
{3131827200 10800 1 EEST}
{3148758000 7200 0 EET}
{3163276800 10800 1 EEST}
{3179602800 7200 0 EET}
{3194726400 10800 1 EEST}
{3209842800 7200 0 EET}
{3226176000 10800 1 EEST}
{3240687600 7200 0 EET}
{3243715200 10800 1 EEST}
{3257622000 10800 1 EEST}
{3271532400 7200 0 EET}
{3274560000 10800 1 EEST}
{3289071600 10800 1 EEST}
{3301772400 7200 0 EET}
{3305404800 10800 1 EEST}
{3321126000 10800 1 EEST}
{3332617200 7200 0 EET}
{3335644800 10800 1 EEST}
{3339270000 7200 0 EET}
{3352579200 10800 1 EEST}
{3362857200 7200 0 EET}
{3366489600 10800 1 EEST}
{3370719600 7200 0 EET}
{3384028800 10800 1 EEST}
{3393702000 7200 0 EET}
{3397334400 10800 1 EEST}
{3402774000 7200 0 EET}
{3415478400 10800 1 EEST}
{3424546800 7200 0 EET}
{3427574400 10800 1 EEST}
{3434223600 7200 0 EET}
{3446928000 10800 1 EEST}
{3454786800 7200 0 EET}
{3458419200 10800 1 EEST}
{3465673200 7200 0 EET}
{3478982400 10800 1 EEST}
{3485631600 7200 0 EET}
{3488659200 10800 1 EEST}
{3497122800 7200 0 EET}
{3510432000 10800 1 EEST}
{3516476400 7200 0 EET}
{3519504000 10800 1 EEST}
{3528572400 7200 0 EET}
{3541881600 10800 1 EEST}
{3546716400 7200 0 EET}
{3550348800 10800 1 EEST}
{3560022000 7200 0 EET}
{3573331200 10800 1 EEST}
{3577561200 7200 0 EET}
{3580588800 10800 1 EEST}
{3592076400 7200 0 EET}
{3604780800 10800 1 EEST}
{3607801200 7200 0 EET}
{3611433600 10800 1 EEST}
{3623526000 7200 0 EET}
{3636230400 10800 1 EEST}
{3638646000 7200 0 EET}
{3642278400 10800 1 EEST}
{3654975600 7200 0 EET}
{3668284800 10800 1 EEST}
{3669490800 7200 0 EET}
{3672518400 10800 1 EEST}
{3686425200 7200 0 EET}
{3699734400 10800 1 EEST}
{3717874800 7200 0 EET}
{3731184000 10800 1 EEST}
{3749929200 7200 0 EET}
{3762633600 10800 1 EEST}
{3781378800 7200 0 EET}
|
| ︙ | ︙ |
Changes to library/tzdata/Europe/Kirov.
| ︙ | ︙ | |||
16 17 18 19 20 21 22 |
{496792800 14400 0 +04}
{512517600 18000 1 +05}
{528242400 14400 0 +04}
{543967200 18000 1 +05}
{559692000 14400 0 +04}
{575416800 18000 1 +05}
{591141600 14400 0 +04}
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
{496792800 14400 0 +04}
{512517600 18000 1 +05}
{528242400 14400 0 +04}
{543967200 18000 1 +05}
{559692000 14400 0 +04}
{575416800 18000 1 +05}
{591141600 14400 0 +04}
{606866400 10800 0 MSD}
{606870000 14400 1 MSD}
{622594800 10800 0 MSK}
{638319600 14400 1 MSD}
{654649200 10800 0 MSK}
{670374000 14400 0 +04}
{701820000 10800 0 MSD}
{701823600 14400 1 MSD}
{717548400 10800 0 MSK}
{733273200 14400 1 MSD}
{748998000 10800 0 MSK}
{764722800 14400 1 MSD}
{780447600 10800 0 MSK}
{796172400 14400 1 MSD}
{811897200 10800 0 MSK}
{828226800 14400 1 MSD}
{846370800 10800 0 MSK}
{859676400 14400 1 MSD}
{877820400 10800 0 MSK}
{891126000 14400 1 MSD}
{909270000 10800 0 MSK}
{922575600 14400 1 MSD}
{941324400 10800 0 MSK}
{954025200 14400 1 MSD}
{972774000 10800 0 MSK}
{985474800 14400 1 MSD}
{1004223600 10800 0 MSK}
{1017529200 14400 1 MSD}
{1035673200 10800 0 MSK}
{1048978800 14400 1 MSD}
{1067122800 10800 0 MSK}
{1080428400 14400 1 MSD}
{1099177200 10800 0 MSK}
{1111878000 14400 1 MSD}
{1130626800 10800 0 MSK}
{1143327600 14400 1 MSD}
{1162076400 10800 0 MSK}
{1174777200 14400 1 MSD}
{1193526000 10800 0 MSK}
{1206831600 14400 1 MSD}
{1224975600 10800 0 MSK}
{1238281200 14400 1 MSD}
{1256425200 10800 0 MSK}
{1269730800 14400 1 MSD}
{1288479600 10800 0 MSK}
{1301180400 14400 0 MSK}
{1414274400 10800 0 MSK}
}
|
Changes to library/tzdata/Europe/Volgograd.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 |
{465343200 14400 0 +04}
{481068000 18000 1 +05}
{496792800 14400 0 +04}
{512517600 18000 1 +05}
{528242400 14400 0 +04}
{543967200 18000 1 +05}
{559692000 14400 0 +04}
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
{465343200 14400 0 +04}
{481068000 18000 1 +05}
{496792800 14400 0 +04}
{512517600 18000 1 +05}
{528242400 14400 0 +04}
{543967200 18000 1 +05}
{559692000 14400 0 +04}
{575416800 10800 0 MSD}
{575420400 14400 1 MSD}
{591145200 10800 0 MSK}
{606870000 14400 1 MSD}
{622594800 10800 0 MSK}
{638319600 14400 1 MSD}
{654649200 10800 0 MSK}
{670374000 14400 0 +04}
{701820000 10800 0 MSD}
{701823600 14400 1 MSD}
{717548400 10800 0 MSK}
{733273200 14400 1 MSD}
{748998000 10800 0 MSK}
{764722800 14400 1 MSD}
{780447600 10800 0 MSK}
{796172400 14400 1 MSD}
{811897200 10800 0 MSK}
{828226800 14400 1 MSD}
{846370800 10800 0 MSK}
{859676400 14400 1 MSD}
{877820400 10800 0 MSK}
{891126000 14400 1 MSD}
{909270000 10800 0 MSK}
{922575600 14400 1 MSD}
{941324400 10800 0 MSK}
{954025200 14400 1 MSD}
{972774000 10800 0 MSK}
{985474800 14400 1 MSD}
{1004223600 10800 0 MSK}
{1017529200 14400 1 MSD}
{1035673200 10800 0 MSK}
{1048978800 14400 1 MSD}
{1067122800 10800 0 MSK}
{1080428400 14400 1 MSD}
{1099177200 10800 0 MSK}
{1111878000 14400 1 MSD}
{1130626800 10800 0 MSK}
{1143327600 14400 1 MSD}
{1162076400 10800 0 MSK}
{1174777200 14400 1 MSD}
{1193526000 10800 0 MSK}
{1206831600 14400 1 MSD}
{1224975600 10800 0 MSK}
{1238281200 14400 1 MSD}
{1256425200 10800 0 MSK}
{1269730800 14400 1 MSD}
{1288479600 10800 0 MSK}
{1301180400 14400 0 MSK}
{1414274400 10800 0 MSK}
{1540681200 14400 0 +04}
{1609020000 10800 0 MSK}
}
|
Changes to library/word.tcl.
1 2 3 4 5 6 7 | # word.tcl -- # # This file defines various procedures for computing word boundaries in # strings. This file is primarily needed so Tk text and entry widgets behave # properly for different platforms. # # Copyright © 1996 Sun Microsystems, Inc. | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # word.tcl -- # # This file defines various procedures for computing word boundaries in # strings. This file is primarily needed so Tk text and entry widgets behave # properly for different platforms. # # Copyright © 1996 Sun Microsystems, Inc. # Copyright © 1998 Scriptics Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # The following variables are used to determine which characters are # interpreted as word characters. See bug [f1253530cdd8]. Will # probably be removed in Tcl 9. |
| ︙ | ︙ |
Changes to libtommath/changes.txt.
| ︙ | ︙ | |||
408 409 410 411 412 413 414 |
to other functions like mp_invmod, mp_div, etc...
-- Sped up mp_exptmod_fast by using new code to find R mod m [e.g. B^n mod m]
-- minor fixes
Jan 17th, 2003
v0.12 -- re-wrote the majority of the makefile so its more portable and will
install via "make install" on most *nix platforms
| | | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
to other functions like mp_invmod, mp_div, etc...
-- Sped up mp_exptmod_fast by using new code to find R mod m [e.g. B^n mod m]
-- minor fixes
Jan 17th, 2003
v0.12 -- re-wrote the majority of the makefile so its more portable and will
install via "make install" on most *nix platforms
-- Re-packaged all the source as separate files. Means the library a single
file packagage any more. Instead of just adding "bn.c" you have to add
libtommath.a
-- Renamed "bn.h" to "tommath.h"
-- Changes to the manual to reflect all of this
-- Used GNU Indent to clean up the source
Jan 15th, 2003
|
| ︙ | ︙ |
Changes to macosx/GNUmakefile.
1 2 3 | ######################################################################################################## # # Makefile wrapper to build tcl on Mac OS X in a way compatible with the tk/macosx Xcode buildsystem | | | 1 2 3 4 5 6 7 8 9 10 11 | ######################################################################################################## # # Makefile wrapper to build tcl on Mac OS X in a way compatible with the tk/macosx Xcode buildsystem # uses the standard Unix build system in tcl/unix (which can be used directly instead of this # if you are not using the tk/macosx projects). # # Copyright (c) 2002-2008 Daniel A. Steffen <das@users.sourceforge.net> # # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. ######################################################################################################## |
| ︙ | ︙ | |||
146 147 148 149 150 151 152 |
--prefix="${PREFIX}" --bindir="${BINDIR}" --libdir="${LIBDIR}" \
--mandir="${MANDIR}" --enable-framework --enable-dtrace --disable-zipfs \
${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}; else ./config.status; fi
build-${PROJECT}: ${objdir}/Makefile
${DO_MAKE}
ifeq (${INSTALL_BUILD},)
| | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
--prefix="${PREFIX}" --bindir="${BINDIR}" --libdir="${LIBDIR}" \
--mandir="${MANDIR}" --enable-framework --enable-dtrace --disable-zipfs \
${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}; else ./config.status; fi
build-${PROJECT}: ${objdir}/Makefile
${DO_MAKE}
ifeq (${INSTALL_BUILD},)
# symbolic link hackery to trick
# 'make install INSTALL_ROOT=${OBJ_DIR}'
# into building Tcl.framework and tclsh in ${SYMROOT}
@cd "${OBJ_DIR}" && mkdir -p $(dir $(subst ${space},\ ,.${LIBDIR})) $(dir $(subst ${space},\ ,.${BINDIR})) "${SYMROOT}" && \
rm -f ".${LIBDIR}" ".${BINDIR}" && ln -fs "${SYMROOT}" ".${LIBDIR}" && \
ln -fs "${SYMROOT}" ".${BINDIR}" && ln -fs "${OBJ_DIR}/tcltest" "${SYMROOT}"
endif
|
| ︙ | ︙ |
Changes to macosx/README.
| ︙ | ︙ | |||
125 126 127 128 129 130 131 |
- Unpack the Tcl source release archive.
- The following instructions assume the Tcl source tree is named "tcl${ver}",
(where ${ver} is a shell variable containing the Tcl version number e.g. '9.0').
Setup this shell variable as follows:
ver="9.0"
| < < | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
- Unpack the Tcl source release archive.
- The following instructions assume the Tcl source tree is named "tcl${ver}",
(where ${ver} is a shell variable containing the Tcl version number e.g. '9.0').
Setup this shell variable as follows:
ver="9.0"
- Setup environment variables as desired, e.g. for a universal build on 10.5:
CFLAGS="-arch x86_64 -arch arm64 -mmacosx-version-min=10.5"
export CFLAGS
- Change to the directory containing the Tcl source tree and build:
make -C tcl${ver}/macosx
|
| ︙ | ︙ |
Changes to macosx/tclMacOSXBundle.c.
| ︙ | ︙ | |||
166 167 168 169 170 171 172 |
int
Tcl_MacOSXOpenVersionedBundleResources(
TCL_UNUSED(Tcl_Interp *),
const char *bundleName,
const char *bundleVersion,
int hasResourceFile,
| | | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
int
Tcl_MacOSXOpenVersionedBundleResources(
TCL_UNUSED(Tcl_Interp *),
const char *bundleName,
const char *bundleVersion,
int hasResourceFile,
Tcl_Size maxPathLen,
char *libraryPath)
{
#ifdef HAVE_COREFOUNDATION
CFBundleRef bundleRef, versionedBundleRef = NULL;
CFStringRef bundleNameRef;
CFURLRef libURL;
|
| ︙ | ︙ |
Changes to macosx/tclMacOSXFCmd.c.
| ︙ | ︙ | |||
488 489 490 491 492 493 494 | * TclMacOSXMatchType -- * * This routine is used by the globbing code to check if a file matches a * given mac type and/or creator code. * * Results: * The return value is 1, 0 or -1 indicating whether the file matches the | | | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | * TclMacOSXMatchType -- * * This routine is used by the globbing code to check if a file matches a * given mac type and/or creator code. * * Results: * The return value is 1, 0 or -1 indicating whether the file matches the * given criteria, does not match them, or an error occurred (in which * case an error is left in interp). * * Side effects: * None. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ |
Changes to macosx/tclMacOSXNotify.c.
| ︙ | ︙ | |||
1346 1347 1348 1349 1350 1351 1352 | * TclpWaitForEvent -- * * This function is called by Tcl_DoOneEvent to wait for new events on * the message queue. If the block time is 0, then Tcl_WaitForEvent just * polls without blocking. * * Results: | | | 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 | * TclpWaitForEvent -- * * This function is called by Tcl_DoOneEvent to wait for new events on * the message queue. If the block time is 0, then Tcl_WaitForEvent just * polls without blocking. * * Results: * Returns 0 if a tcl event or timeout occurred and 1 if a non-tcl * CFRunLoop source was processed. * * Side effects: * None. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ |
Changes to tests/appendComp.test.
| ︙ | ︙ | |||
380 381 382 383 384 385 386 | # Note also the tests above now constrained by bug-3057639, these changed # behaviour with the triggering of read traces in bc mode gone. # Going back to the tests below. The direct-eval tests are ok before and after # patch (no read traces run for lappend, append). The compiled tests are # failing for lappend (9.0/1) before the patch, showing how it invokes read # traces in the compiled path. The append tests are good (9.2/3). After the | | | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# Note also the tests above now constrained by bug-3057639, these changed
# behaviour with the triggering of read traces in bc mode gone.
# Going back to the tests below. The direct-eval tests are ok before and after
# patch (no read traces run for lappend, append). The compiled tests are
# failing for lappend (9.0/1) before the patch, showing how it invokes read
# traces in the compiled path. The append tests are good (9.2/3). After the
# patch the failures are gone.
test appendComp-9.0 {bug 3057639, lappend compiled, read trace on non-existing array variable element} -setup {
unset -nocomplain myvar
array set myvar {}
} -body {
proc nonull {var key val} {
upvar 1 $var lvar
|
| ︙ | ︙ |
Added tests/bigdata.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 |
# Test cases for large sized data
#
# Copyright © 2023 Ashok P. Nadkarni
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# These are very rudimentary tests for large size arguments to commands.
# They do not exercise all possible code paths such as shared/unshared Tcl_Objs,
# literal/variable arguments etc.
# They do however test compiled and uncompiled execution.
if {"::tcltest" ni [namespace children]} {
package require tcltest
namespace import -force ::tcltest::*
}
::tcltest::loadTestedCommands
catch [list package require -exact tcl::test [info patchlevel]]
source [file join [file dirname [info script]] tcltests.tcl]
#
# bigtest and bigtestRO (RO->read only) generate compiled and uncompiled
# versions of the given test script. The difference between the two is
# that bigtest generates separate test instances for the two cases while
# bigtestRO generates a single test case covering both. The latter can
# only be used when operands are not modified and when combining tests
# does not consume too much additional memory.
# Wrapper to generate compiled and uncompiled cases for a test. If $args does
# not contain a -body key, $comment is treated as the test body
proc bigtest {id comment result args} {
if {[dict exists $args -body]} {
set body [dict get $args -body]
dict unset args -body
} else {
set body $comment
}
dict lappend args -constraints bigdata
uplevel 1 [list test $id.uncompiled "$comment (uncompiled)" \
-body [list testevalex $body] \
-result $result \
{*}$args]
uplevel 1 [list test $id.compiled-script "$comment (compiled script)" \
-body [list try $body] \
-result $result \
{*}$args]
return
# TODO - is this proc compilation required separately from the compile-script above?
dict append args -setup \n[list proc testxproc {} $body]
dict append args -cleanup "\nrename testxproc {}"
uplevel 1 [list test $id.compiled-proc "$comment (compiled proc)" \
-body {testxproc} \
-result $result \
{*}$args]
}
# Like bigtest except that both compiled and uncompiled are combined into one
# test using the same inout argument. This saves time but for obvious reasons
# should only be used when the input argument is not modified.
proc bigtestRO {id comment result args} {
if {[dict exists $args -body]} {
set body [dict get $args -body]
dict unset args -body
} else {
set body $comment
}
dict lappend args -constraints bigdata
set wrapper ""
set body "{$body}"
append wrapper "set uncompiled_result \[testevalex $body]" \n
append wrapper "set compiled_result \[try $body]" \n
append wrapper {list $uncompiled_result $compiled_result}
uplevel 1 [list test $id.uncompiled,compiled {$comment} \
-body $wrapper \
-result [list $result $result] \
{*}$args]
return
}
interp alias {} bigClean {} unset -nocomplain s s1 s2 bin bin1 bin2 l l1 l2
interp alias {} bigString {} testbigdata string
interp alias {} bigBinary {} testbigdata bytearray
interp alias {} bigList {} testbigdata list
proc bigPatLen {} {
proc bigPatLen {} "return [string length [testbigdata string]]"
bigPatLen
}
# Returns list of expected elements at the indices specified
proc bigStringIndices {indices} {
set pat [testbigdata string]
set patlen [string length $pat]
lmap idx $indices {
string index $pat [expr {$idx%$patlen}]
}
}
# Returns the largest multiple of the pattern length that is less than $limit
proc bigPatlenMultiple {limit} {
set patlen [bigPatLen]
return [expr {($limit/$patlen)*$patlen}]
}
set ::bigLengths(intmax) 0x7fffffff
set ::bigLengths(uintmax) 0xffffffff
# Some tests are more convenient if operands are multiple of pattern length
set ::bigLengths(patlenmultiple) [bigPatlenMultiple $::bigLengths(intmax)]
set ::bigLengths(upatlenmultiple) [bigPatlenMultiple $::bigLengths(uintmax)]
#
# string cat
bigtest string-cat-bigdata-1 "string cat large small result > INT_MAX" 1 -body {
string equal \
[string cat [bigString $::bigLengths(patlenmultiple)] [bigString]] \
[bigString [expr {[bigPatLen]+$::bigLengths(patlenmultiple)}]]
}
bigtest string-cat-bigdata-2 "string cat small large result > INT_MAX" 1 -body {
string equal \
[string cat [bigString] [bigString $::bigLengths(patlenmultiple)]] \
[bigString [expr {[bigPatLen]+$::bigLengths(patlenmultiple)}]]
}
bigtest string-cat-bigdata-3 "string cat result > UINT_MAX" 1 -body {
set s [bigString $::bigLengths(patlenmultiple)]
string equal \
[string cat $s [bigString] $s] \
[bigString [expr {[bigPatLen]+2*$::bigLengths(patlenmultiple)}]]
}
#
# string compare/equal
bigtestRO string-equal/compare-bigdata-1 "string compare/equal equal strings" {0 1} -body {
list [string compare $s1 $s2] [string equal $s1 $s2]
} -setup {
set s1 [bigString 0x100000000]
set s2 [bigString 0x100000000]; # Separate so Tcl_Obj is not the same
} -cleanup {
bigClean
}
bigtestRO string-equal/compare-bigdata-2 "string compare/equal -length unequal strings" {-1 0 0 1} -body {
# Also tests lengths do not wrap
set result {}
lappend result [string compare $s1 $s2]
lappend result [string equal $s1 $s2]
# Check lengths > UINT_MAX
# Also that lengths do not truncate to sizeof(int)
lappend result [string compare -length 0x100000000 $s1 $s2]
lappend result [string equal -length 0x100000000 $s1 $s2]
} -setup {
set s1 [bigString 0x100000001]
set s2 [bigString 0x100000001 0x100000000]; # Differs in last char
} -cleanup {
bigClean
}
# -constraints bug-a814ee5bbd
#
# string first
bigtestRO string-first-bigdata-1 "string first > INT_MAX" {2147483648 -1 2147483650 1} -body {
list \
[string first X $s] \
[string first Y $s] \
[string first 0 $s 0x80000000] \
[string first 1 $s end-0x80000010]
} -setup {
set s [bigString 0x8000000a 0x80000000]
} -cleanup {
bigClean
} -constraints bug-a814ee5bbd
bigtestRO string-first-bigdata-2 "string first > UINT_MAX" {4294967296 -1 4294967300 1} -body {
list \
[string first X $s] \
[string first Y $s] \
[string first 0 $s 0x100000000] \
[string first 1 $s end-0x100000010]
} -setup {
set s [bigString 0x10000000a 0x100000000]
} -cleanup {
bigClean
} -constraints bug-a814ee5bbd
bigtestRO string-first-bigdata-3 "string first - long needle" 10 -body {
string first $needle $s
} -setup {
set s [bigString 0x10000000a 0]
set needle [bigString 0x100000000]
} -cleanup {
bigClean needle
} -constraints bug-a814ee5bbd
#
# string index
bigtestRO string-index-bigdata-1 "string index" {6 7 5 {} 5 4 {} 9 {}} -body {
list \
[string index $s 0x100000000] \
[string index $s 0x100000000+1] \
[string index $s 0x100000000-1] \
[string index $s 0x10000000a] \
[string index $s end] \
[string index $s end-1] \
[string index $s end+1] \
[string index $s end-0x100000000] \
[string index $s end-0x10000000a]
} -setup {
set s [bigString 0x10000000a]
} -cleanup {
bigClean
}
#
# string insert
bigtestRO string-insert-bigdata-1 "string insert" 1 -body {
# Note insert at multiple of 10 to enable comparison against generated string
string equal [string insert [bigString 4294967312] 4294967310 "0123456789"] [bigString 4294967322]
}
bigtestRO string-insert-bigdata-2 "string insert" 1 -body {
string equal [string insert [bigString 4294967312] 10 "0123456789"] [bigString 4294967322]
}
#
# string is
bigtestRO string-is-bigdata-1 "string is" {1 0 0 4294967296} -body {
# TODO - add the other "is" classes
unset -nocomplain failat result
lappend result [string is alnum -failindex failat $s] [info exists failat]
lappend result [string is digit -failindex failat $s] $failat
} -setup {
set s [bigString 0x10000000a 0x100000000]
} -cleanup {
bigClean failat
}
#
# string last
bigtestRO string-last-bigdata-1 "string last > INT_MAX" {2 -1 2147483640 11} -body {
set s [bigString 0x80000010 2]
list \
[string last X $s] \
[string last Y $s] \
[string last 0 $s 0x80000000] \
[string last 1 $s end-0x80000000]
} -setup {
set s [bigString 0x80000010 2]
} -cleanup {
bigClean
} -constraints bug-a814ee5bbd
bigtestRO string-last-bigdata-2 "string last > UINT_MAX" {4294967300 -1 4294967290 1} -body {
list \
[string last 0 $s] \
[string last Y $s] \
[string last 0 $s 0x100000000] \
[string last 1 $s end-0x100000010]
} -setup {
set s [bigString 0x10000000a 2]
} -cleanup {
bigClean
} -constraints bug-a814ee5bbd
bigtestRO string-last-bigdata-3 "string last - long needle" 0 -body {
string last $needle $s
} -setup {
set s [bigString 0x10000000a 0x10000000a]
set needle [bigString 0x100000000]
} -cleanup {
bigClean needle
} -constraints bug-a814ee5bbd
#
# string length
bigtestRO string-length-bigdata-1 {string length $s} 4294967296 -setup {
set s [bigString 0x100000000]
} -cleanup {
bigClean
}
#
# string map
bigtestRO string-map-bigdata-1 {string map} {5 0 0 5} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2
set s2 [string map {0 5 5 0} $s]
list \
[string index $s2 0] \
[string index $s2 5] \
[string index $s2 end] \
[string index $s2 end-5]
} -setup {
set s [bigString 0x100000000]
} -cleanup {
bigClean
} -constraints bug-takesTooLong
#
# string match
bigtestRO string-match-bigdata-1 {string match} {1 0 1} -body {
list \
[string match 0*5 $s] \
[string match 0*4 $s] \
[string match $s $s]
} -setup {
set s [bigString 0x100000000]
} -cleanup {
bigClean
}
#
# string range
bigtestRO string-range-bigdata-1 "string range" {6 7 5 {} 5 4 {} 9 {}} -body {
list \
[string range $s 0x100000000 0x100000000] \
[string range $s 0x100000000+1 0x100000000+1] \
[string range $s 0x100000000-1 0x100000000-1] \
[string range $s 0x10000000a 0x10000000a] \
[string range $s end end] \
[string range $s end-1 end-1] \
[string range $s end+1 end+1] \
[string range $s end-0x100000000 end-0x100000000] \
[string range $s end-0x10000000a end-0x10000000a]
} -setup {
set s [bigString 0x10000000a]
} -cleanup {
bigClean
} -constraints bug-ad9361fd20f0
# TODO - once above bug is fixed, add tests for large result range
#
# string repeat - use bigtest, not bigtestRO !!
bigtest string-repeat-bigdata-1 "string repeat single char length > UINT_MAX" 4294967296 -body {
string length [string repeat x 0x100000000]
}
bigtest string-repeat-bigdata-2 "string repeat multiple char" {4294967296 0123456789abcdef 0123456789abcdef} -body {
set s [string repeat 0123456789abcdef [expr 0x100000000/16]]
list \
[string length $s] \
[string range $s 0 15] \
[string range $s end-15 end]
} -cleanup {
bigClean
}
#
# string replace
bigtestRO string-replace-bigdata-1 "string replace" {789012345 012345678 XYZ789012345 012345678XYZ} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain result
lappend result [string replace $s 0 0x100000000]
lappend result [string replace $s end-0x100000000 end]
lappend result [string replace $s 0 0x100000000 XYZ]
lappend result [string replace $s end-0x100000000 end XYZ]
} -setup {
set s [bigString 0x10000000a]
} -cleanup {
bigClean
}
# TODO -
# - replacements string is large
# - replace in the middle - string length grows, shrinks
# - last < first
#
# string reverse
bigtestRO string-reverse-bigdata-1 "string reverse" {5432109876 9876543210} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2 result
set s2 [string reverse $s]
list [string range $s2 0 9] [string range $s2 end-9 end]
} -setup {
set s [bigString 0x10000000a]
} -cleanup {
bigClean
}
#
# string tolower
bigtestRO string-tolower-bigdata-1 "string tolower" 1 -body {
string equal [string tolower $s] [string repeat abcd $repts]
} -setup {
set repts [expr 0x100000010/4]
set s [string repeat ABCD $repts]
} -cleanup {
bigClean repts
}
bigtestRO string-tolower-bigdata-2 "string tolower first last" {4294967312 ABCDabcdABCD 4294967312 ABCDabcdABCD 4294967312 ABCDabcdABCD} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2 result
set s2 [string tolower $s 4 7]
lappend result [string length $s2] [string range $s2 0 11]
unset s2; #Explicit free to reduce total memory
set s2 [string tolower $s 0x100000008 0x10000000b]
lappend result [string length $s2] [string range $s2 0x100000004 end]
unset s2; #Explicit free to reduce total memory
set s2 [string tolower $s end-7 end-4]
lappend result [string length $s2] [string range $s2 0x100000004 end]
} -setup {
set repts [expr 0x100000010/4]
set s [string repeat ABCD $repts]
} -cleanup {
bigClean repts
}
#
# string totitle
bigtestRO string-totitle-bigdata-1 "string totitle first last" {4294967312 aBcDAbcdaBcD 4294967312 aBcDAbcdaBcD 4294967312 aBcDAbcdaBcD} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2 result
set s2 [string totitle $s 4 7]
lappend result [string length $s2] [string range $s2 0 11]
unset s2; #Explicit free to reduce total memory
set s2 [string totitle $s 0x100000008 0x10000000b]
lappend result [string length $s2] [string range $s2 0x100000004 0x10000000f]
unset s2; #Explicit free to reduce total memory
set s2 [string totitle $s end-7 end-4]
lappend result [string length $s2] [string range $s2 0x100000004 0x10000000f]
} -setup {
set repts [expr 0x100000010/4]
set s [string repeat aBcD $repts]
} -cleanup {
bigClean repts
}
#
# string toupper
bigtestRO string-toupper-bigdata-1 "string toupper" 1 -body {
string equal [string toupper $s] [string repeat ABCD $repts]
} -setup {
set repts [expr 0x100000010/4]
set s [string repeat abcd $repts]
} -cleanup {
bigClean repts
}
bigtestRO string-toupper-bigdata-2 "string toupper first last" {4294967312 abcdABCDabcd 4294967312 abcdABCDabcd 4294967312 abcdABCDabcd} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2 result
set s2 [string toupper $s 4 7]
lappend result [string length $s2] [string range $s2 0 11]
unset s2; #Explicit free to reduce total memory
set s2 [string toupper $s 0x100000008 0x10000000b]
lappend result [string length $s2] [string range $s2 0x100000004 0x10000000f]
unset s2; #Explicit free to reduce total memory
set s2 [string toupper $s end-7 end-4]
lappend result [string length $s2] [string range $s2 0x100000004 0x10000000f]
} -setup {
set repts [expr 0x100000010/4]
set s [string repeat abcd $repts]
} -cleanup {
bigClean repts
}
#
# string trim
bigtestRO string-trim-bigdata-1 "string trim" {abcdyxxy yxxyabcd} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2
set s2 [string trim $s xy]
list [string range $s2 0 7] [string range $s2 end-7 end]
} -setup {
set repts [expr 0x100000010/8]
set s [string repeat xyabcdyx $repts]
} -cleanup {
bigClean
}
#
# string trimleft
bigtestRO string-trimleft-bigdata-1 "string trimleft" {abcdyxxy xyabcdyx} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2
set s2 [string trimleft $s xy]
list [string range $s2 0 7] [string range $s2 end-7 end]
} -setup {
set repts [expr 0x100000010/8]
set s [string repeat xyabcdyx $repts]
} -cleanup {
bigClean
}
#
# string trimright
bigtestRO string-trimright-bigdata-1 "string trimright" {xyabcdyx yxxyabcd} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2
set s2 [string trimright $s xy]
list [string range $s2 0 7] [string range $s2 end-7 end]
} -setup {
set repts [expr 0x100000010/8]
set s [string repeat xyabcdyx $repts]
} -cleanup {
bigClean
}
#
# append
bigtestRO append-bigdata-1 "append large to small" 1 -body {
set s 0123456789
append s [bigString 0x100000000]
string equal $s [bigString 0x10000000a]
} -cleanup {
bigClean
}
bigtest append-bigdata-2 "append small to cross UINT_MAX boundary" 1 -body {
append s 0123456789
string equal $s [bigString 4294967300]
} -setup {
set s [bigString 4294967290]
} -cleanup {
bigClean
}
bigtest append-bigdata-3 "append small to cross UINT_MAX boundary" 1 -body {
set s2 ""
append s2 $s $s $s $s
string equal $s2 [bigString 4294967320]
} -setup {
# Make length multiple of 4 AND 10 since the bigString pattern length is 10
set len [expr 4294967320/4]
set s [bigString $len]
} -cleanup {
bigClean
}
#
# format
bigtestRO format-bigdata-1 "format %s" 1 -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2
set s2 [format %s $s]
string equal $s $s2
} -setup {
set s [bigString 0x100000000]
} -cleanup {
bigClean
}
bigtest format-bigdata-2 "format bigstring%s" 1 -body {
set s [format $s X]
string equal $s [bigString 0x100000001 0x100000000]
} -setup {
set s [bigString 0x100000000]
append s %s
} -cleanup {
bigClean
}
bigtest format-bigdata-3 "format big width" {4294967300 { } { a}} -body {
set s [format %4294967300s a]
list [string length $s] [string range $s 0 3] [string range $s end-3 end]
} -cleanup {
bigClean
}
bigtest format-bigdata-4 "format big negative width" {4294967300 {a } { }} -body {
set s [format %-4294967300s a]
list [string length $s] [string range $s 0 3] [string range $s end-3 end]
} -cleanup {
bigClean
}
bigtest format-bigdata-5 "format big * width" {4294967300 { } { a}} -body {
set s [format %*s 4294967300 a]
list [string length $s] [string range $s 0 3] [string range $s end-3 end]
} -cleanup {
bigClean
}
bigtest format-bigdata-6 "format big negative * width" {4294967300 {a } { }} -body {
set s [format %*s -4294967300 a]
list [string length $s] [string range $s 0 3] [string range $s end-3 end]
} -cleanup {
bigClean
}
bigtestRO format-bigdata-7 "format big precision" {4294967300 0123 6789} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2
set s2 [format %.4294967300s $s]
list [string length $s2] [string range $s2 0 3] [string range $s2 end-3 end]
} -setup {
set s [testbigdata string 4294967310]
} -cleanup {
bigClean
}
bigtestRO format-bigdata-8 "format big * precision" {4294967300 0123 6789} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain s2
set s2 [format %.*s 4294967300 $s]
list [string length $s2] [string range $s2 0 3] [string range $s2 end-3 end]
} -setup {
set s [testbigdata string 4294967310]
} -cleanup {
bigClean
}
#
# scan
bigtestRO scan-bigdata-1 "scan %s" {1 1 2 X 1 2 4294967300 01234X} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain result digits x
lappend result [string equal [scan $s %s] $s]
lappend result [string equal [scan $s {%[0-9X]}] $s]
lappend result [scan $s {%[0-9]%s} digits x] $x
lappend result [string equal $digits [bigString 0x100000009]]
lappend result [scan $s %4294967300s%s x y]
lappend result [string length $x] $y
} -setup {
set s [bigString 0x10000000a 0x100000009]
} -cleanup {
bigClean digits
}
#
# regexp
bigtestRO regexp-bigdata-1 "regexp" 1 -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain result digits
lappend result [regexp {[[:digit:]]*X} $s]
} -setup {
set s [bigString 0x100000000 0x100000000]
} -cleanup {
bigClean digits
}
bigtestRO regexp-bigdata-2 "regexp with capture" 1 -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain result digits match
lappend result [regexp {([[:digit:]])*X} $s match digits] [string equal $match $s]
puts B
unset match; # Free up memory
lappend result [string equal $digits [bigString 0x100000009]]
} -setup {
set s [bigString 0x10000000a 0x100000009]
} -cleanup {
bigClean digits match
} -constraints bug-takesTooLong
#
# regsub
bigtestRO regsub-bigdata-1 "regsub" X -body {
regsub -all \\d $s {}
} -setup {
set s [bigString 0x100000001 0x100000000]
} -cleanup {
bigClean
} -constraints bug-takesTooLong
bigtestRO regsub-bigdata-2 "regsub" 1 -body {
string equal [regsub -all \\d $s x] [string cat [string repeat x 0x100000000] X]
} -setup {
set s [bigString 0x100000001 0x100000000]
} -cleanup {
bigClean
} -constraints bug-takesTooLong
#
# subst
bigtestRO subst-bigdata-1 "subst" {1 1} -body {
unset -nocomplain result
lappend result [string equal [subst $s] $s]
lappend result [string equal [subst {$s}] $s]
} -setup {
set s [bigString 0x10000000a]
} -cleanup {
bigClean
}
#
# binary format
bigtestRO binary-format-bigdata-1 "binary format aN" [list 4294967296 X\0\0\0 \0\0\0\0] -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain bin
set bin [binary format a4294967296 X]
list [string length $bin] [string range $bin 0 3] [string range $bin end-3 end]
} -cleanup {
bigClean
}
# -constraints bug-9369f83649
# TODO - do string compare and add other format specifiers
bigtestRO binary-format-bigdata-2 "binary format a*" 1 -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain bin2
set bin2 [binary format a* $bin]
string equal $bin $bin2
} -setup {
set bin [bigBinary 4294967296]
} -cleanup {
bigClean
}
#
# binary scan
bigtestRO binary-scan-bigdata-1 "binary scan aN" {4294967296 0123 2345} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain bin2
binary scan $bin a4294967296 bin2
list [string length $bin2] [string range $bin2 0 3] [string range $bin2 end-3 end]
} -setup {
set bin [bigBinary 4294967296]
} -cleanup {
bigClean
}
# -constraints bug-9369f83649
# TODO - do string compare and add other format specifiers once above bug is fixed
bigtestRO binary-scan-bigdata-2 "binary scan a*" 1 -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain bin2
binary scan $bin a* bin2
string equal $bin $bin2
} -setup {
set bin [bigBinary 4294967296]
} -cleanup {
bigClean
}
# TODO - do string compare and add other format specifiers once above bug is fixed
#
# binary encode / decode base64
bigtestRO binary-encode/decode-base64-bigdata-1 "binary encode/decode base64" 1 -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
string equal $bin [binary decode base64 [binary encode base64 $bin]]
} -setup {
set bin [bigBinary 4294967296]
} -cleanup {
bigClean
}
#
# binary encode / decode hex
bigtestRO binary-encode/decode-hex-bigdata-1 "binary encode/decode hex" 1 -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
string equal $bin [binary decode hex [binary encode hex $bin]]
} -setup {
set bin [bigBinary 4294967296]
} -cleanup {
bigClean
}
#
# binary encode / decode uuencode
bigtestRO binary-encode/decode-uuencode-bigdata-1 "binary encode/decode uuencode" 1 -body {
string equal $bin [binary decode uuencode [binary encode uuencode $bin]]
} -setup {
set bin [bigBinary 4294967296]
} -cleanup {
bigClean
}
################################################################
# List commands
#
# foreach
bigtestRO foreach-bigdata-1 "foreach" 1 -body {
# Unset explicitly before setting as bigtestRO runs the script twice.
unset -nocomplain l2
foreach x $l {
lappend l2 $x
}
testlutil equal $l $l2
} -setup {
set l [bigList 0x100000000]
} -cleanup {
bigClean
}
#
# lappend
bigtest lappend-bigdata-1 "lappend" {4294967300 4294967300 {1 2 3 4 5 a b c d}} -body {
# Do NOT initialize l in a -setup block. That requires more memory and fails.
# Do not have enough memory for a full compare.
# Just check end
set l [bigList 0x100000000]
list [llength [lappend l a b c d]] [llength $l] [lrange $l end-8 end]
} -cleanup {
bigClean
}
#
# lassign
bigtestRO lassign-bigdata-1 "lassign" {0 1 2 3 4 5 6 7 8 {9 0 1 2 3 4 5 6 7 8} {6 7 8 9 0 1 2 3 4 5}} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain l2
set l2 [lassign $l a b c d e f g h i]
list $a $b $c $d $e $f $g $h $i [lrange $l2 0 9] [lrange $l2 end-9 end]
} -setup {
set l [bigList 0x10000000a]
} -cleanup {
bigClean
}
#
# ledit
bigtest ledit-bigdata-1 "ledit - small result" {{0 X Y Z 8} {0 X Y Z 8}} -body {
list [ledit l 1 0x100000001 X Y Z] $l
} -setup {
set l [bigList 0x100000003]
} -cleanup {
bigClean
}
bigtest ledit-bigdata-2 "ledit - large result" {4294967304 4294967304 {a b c d e f g 7}} -body {
# Do NOT initialize l in a -setup block. That requires more memory and fails.
set l [bigList 0x100000002]
list [llength [ledit l 0x100000000 0x100000000 a b c d e f g]] [llength $l] [lrange $l 0x100000000 end]
} -cleanup {
bigClean
}
bigtest ledit-bigdata-3 "ledit - small -> large result" {2147483651 2147483651} -body {
set l2 {a b c x y z}
list [llength [ledit l2 2 3 {*}$l]] [llength $l2]
} -setup {
set l [bigList 2147483647]
} -cleanup {
bigClean
} -constraints bug-7cddd2845c
#
# lindex
bigtestRO lindex-bigdata-1 "lindex" {6 7 5 {} 5 4 {} 9 {}} -body {
list \
[lindex $l 0x100000000] \
[lindex $l 0x100000000+1] \
[lindex $l 0x100000000-1] \
[lindex $l 0x10000000a] \
[lindex $l end] \
[lindex $l end-1] \
[lindex $l end+1] \
[lindex $l end-0x100000000] \
[lindex $l end-0x10000000a]
} -setup {
set l [bigList 0x10000000a]
} -cleanup {
bigClean
} -constraints bug-dcac54a685
# TODO after bug fix - nested index
#
# linsert
# Cannot use bigtestRO here because 16GB memory not enough to have two 4G sized lists
# Have to throw away source list every time. Also means we cannot compare entire lists
# and instead just compare the affected range
bigtest linsert-bigdata-1 "linsert" {4294967330 1} -body {
# Note insert at multiple of 10 to enable comparison against generated string
set ins [split abcdefghij ""]
set pat [split 0123456789 ""]
set insidx 2000000000
set l [linsert [bigList 4294967320] $insidx {*}$ins]
list \
[llength $l] \
[testlutil equal [lrange $l $insidx-10 $insidx+19] [concat $pat $ins $pat]]
} -cleanup {
bigClean
}
#
# list and {*}
bigtestRO list-bigdata-1 {list {*} } {4294967296 0 4294967295} -body {
unset -nocomplain l2
set l2 [list {*}$l]
list [llength $l2] [lindex $l2 0] [lindex $l2 end]
} -setup {
set l [bigList 0x100000000]
} -cleanup {
bigClean
} -constraints bug-7cddd2845c
#
# llength
bigtestRO llength-bigdata-1 {llength} 4294967296 -body {
llength $l
} -setup {
set l [bigList 0x100000000]
} -cleanup {
bigClean
}
#
# lmap
bigtestRO lmap-bigdata-1 "lmap" 4294967296 -body {
set n 0
if {0} {
# TODO - This is the right test but runs out of memory
testlutil equal $l [lmap e $l {set e}]
} else {
lmap e $l {incr n; continue}
}
set n
} -setup {
set l [bigList 0x100000000]
} -cleanup {
bigClean
puts ""
}
#
# lrange
bigtestRO lrange-bigdata-1 "lrange" {6 7 5 {} 5 4 {} 9 {}} -body {
list \
[lrange $l 0x100000000 0x100000000] \
[lrange $l 0x100000000+1 0x100000000+1] \
[lrange $l 0x100000000-1 0x100000000-1] \
[lrange $l 0x10000000a 0x10000000a] \
[lrange $l end end] \
[lrange $l end-1 end-1] \
[lrange $l end+1 end+1] \
[lrange $l end-0x100000000 end-0x100000000] \
[lrange $l end-0x10000000a end-0x10000000a]
} -setup {
set l [bigList 0x10000000a]
} -cleanup {
bigClean
} -constraints bug-dcac54a685
# TODO - once above bug is fixed, add tests for large result range
#
# lrepeat - use bigtest, not bigtestRO !!
bigtest lrepeat-bigdata-1 "lrepeat single element length > UINT_MAX" 4294967296 -body {
# Just to test long lengths are accepted as arguments
llength [lrepeat 0x100000000 x]
}
bigtest lrepeat-bigdata-2 "string repeat multiple char" {4294967400 {0 1 2 3 4 5 6 7}} -body {
set len [expr 4294967400/8]
set l [lrepeat $len 0 1 2 3 4 5 6 7]
list [llength $l] [lrange $l end-7 end]
} -cleanup {
bigClean
}
#
# lreplace
bigtestRO lreplace-bigdata-1 "lreplace - small result" [list \
[split 789012345 ""] \
[split 012345678 ""] \
[split XYZ789012345 ""] \
[split 012345678XYZ ""] \
] -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain result
lappend result [lreplace $l 0 0x100000000]
lappend result [lreplace $l end-0x100000000 end]
lappend result [lreplace $l 0 0x100000000 X Y Z]
lappend result [lreplace $l end-0x100000000 end X Y Z]
} -setup {
set l [bigList 0x10000000a]
} -cleanup {
bigClean
}
bigtest lreplace-bigdata-2 "lreplace - large result" {4294967301 {a b c d e 0 1 2 3 4 5 6}} -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain l2
set l2 [lreplace [bigList 4294967296] 4294967290 0 a b c d e]
lrange $l2 4294967290 end
} -setup {
#set l [bigList 4294967296]
} -cleanup {
bigClean
} -constraints bug-outofmemorypanic
#
# lsearch
bigtestRO lsearch-bigdata-1 "lsearch" {4294967300 4294967310 -1} -body {
list \
[lsearch -exact $l X] \
[lsearch -exact -start 4294967291 $l 0] \
[lsearch -exact $l Y]
} -setup {
set l [bigList 0x100000010 4294967300]
} -cleanup {
bigClean
}
# TODO - stride, inline, all
#
# lseq
bigtest lseq-bigdata-1 "lseq" {4294967297 4294967296} -body {
list [llength $l] [lindex $l 0x100000000]
} -setup {
set l [lseq 0x100000001]
} -cleanup {
bigClean
}
bigtest lseq-bigdata-2 "lseq" {9223372036854775807 9223372036854775799} -body {
list [llength $l] [lindex $l 9223372036854775800]
} -setup {
set l [lseq 0x7fffffffffffffff]; llength $l
} -cleanup {
bigClean
} -constraints bug-fa00fbbbab
#
# lset
bigtest lset-bigdata-1 "lset" {4294967297 4294967297 {1 2 3 4 5 X}} -body {
# Do NOT initialize l in a -setup block. That requires more memory and fails.
set l [bigList 0x100000001]
list [llength [lset l 0x100000000 X]] [llength $l] [lrange $l end-5 end]
} -cleanup {
bigClean
}
#
# lsort
bigtestRO lsort-bigdata-1 "lsort" [list 4294967296 [lrepeat 10 0] [lrepeat 10 9]] -body {
# Unset explicitly before setting to save memory as bigtestRO runs the
# script below twice.
unset -nocomplain l2
set l2 [lsort $l]
list [llength $l2] [lrange $l2 0 9] [lrange $l2 end-9 end]
} -setup {
set l [bigList 0x100000000]
} -cleanup {
bigClean
} -constraints notenoughmemoryexception
#
# join
bigtestRO join-bigdata-1 "join" [list 0123456789 6789012345] -body {
set s [join $l ""]
list [string range $s 0 9] [string range $s end-9 end]
} -setup {
set l [bigList 0x100000000]
} -cleanup {
bigClean
}
bigtest split-bigdata-1 "split" {4294967296 {0 1 2 3 4} {1 2 3 4 5}} -body {
# Fill list compare needs too much memory
set l [split $s ""]
list [llength $l] [lrange 0 4] [lrange end-4 end]
} -setup {
set s [bigString 0x100000000]
} -cleanup {
bigClean
} -constraints bug-takesTooLong
bigtestRO concat-bigdata-1 "concat" {4294967296 {0 1 2 3 4} {6 7 0 1 2} {3 4 5 6 7}} -body {
unset -nocomplain l2
set l2 [concat $l $l]
list [llength $l2] [lrange $l2 0 4] [lrange $l2 0x80000000-2 0x80000000+2] [lrange $l2 end-4 end]
} -setup {
set l [bigList 0x80000000]
}
#
# TODO
# lremove
# lreverse
# encoding convertfrom
# encoding convertto
# dict *
# cleanup
::tcltest::cleanupTests
return
# Local Variables:
# mode: tcl
# fill-column: 78
# End:
|
Changes to tests/chanio.test.
| ︙ | ︙ | |||
3568 3569 3570 3571 3572 3573 3574 |
chan configure $f -translation binary
chan configure $f -translation
} -cleanup {
chan close $f
} -result lf
#
# Test chan-io-9.14 has been removed because "auto" output translation mode is
| | | 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 |
chan configure $f -translation binary
chan configure $f -translation
} -cleanup {
chan close $f
} -result lf
#
# Test chan-io-9.14 has been removed because "auto" output translation mode is
# not supported.
#
test chan-io-31.14 {Tcl_Write mixed, Tcl_Gets auto} -setup {
file delete $path(test1)
set l ""
} -body {
set f [open $path(test1) w]
chan configure $f -translation lf
|
| ︙ | ︙ | |||
5306 5307 5308 5309 5310 5311 5312 |
lappend l [chan configure $f1 -eofchar]
chan configure $f1 -eofchar D
lappend l [chan configure $f1 -eofchar]
lappend l [list [catch {chan configure $f1 -eofchar {1 2 3}} msg] $msg]
} -cleanup {
chan close $f1
} -result {O D {1 {bad value for -eofchar: must be non-NUL ASCII character}}}
| > | | > | 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 |
lappend l [chan configure $f1 -eofchar]
chan configure $f1 -eofchar D
lappend l [chan configure $f1 -eofchar]
lappend l [list [catch {chan configure $f1 -eofchar {1 2 3}} msg] $msg]
} -cleanup {
chan close $f1
} -result {O D {1 {bad value for -eofchar: must be non-NUL ASCII character}}}
test chan-io-39.23 {
Tcl_GetChannelOption, server socket is not readable or writable, but should
still have valid -eofchar and -translation options.
} -setup {
set l [list]
} -body {
set sock [socket -server [namespace code accept] -myaddr 127.0.0.1 0]
lappend l [chan configure $sock -eofchar] \
[chan configure $sock -translation]
} -cleanup {
chan close $sock
|
| ︙ | ︙ | |||
6864 6865 6866 6867 6868 6869 6870 |
chan puts -nonewline $out [chan read $in]
chan close $in
chan close $out
list [file size $path(kyrillic.txt)] \
[file size $path(utf8-fcopy.txt)] \
[file size $path(utf8-rp.txt)]
} {3 5 5}
| | < | > < < | | > > > | > > | < > | > > | 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 |
chan puts -nonewline $out [chan read $in]
chan close $in
chan close $out
list [file size $path(kyrillic.txt)] \
[file size $path(utf8-fcopy.txt)] \
[file size $path(utf8-rp.txt)]
} {3 5 5}
test chan-io-52.10 {TclCopyChannel & encodings} -constraints {fcopy} -body {
set in [open $path(kyrillic.txt) r]
set out [open $path(utf8-fcopy.txt) w]
chan configure $in -encoding koi8-r -translation lf
# -translation binary is also -encoding binary
chan configure $out -translation binary
chan copy $in $out
chan close $in
chan close $out
file size $path(utf8-fcopy.txt)
} -returnCodes 1 -match glob -result {error writing "*":\
invalid or incomplete multibyte or wide character}
test chan-io-52.11 {TclCopyChannel & encodings} -setup {
set f [open $path(utf8-fcopy.txt) w]
fconfigure $f -encoding utf-8 -translation lf
puts $f АА
close $f
} -constraints {fcopy} -body {
set in [open $path(utf8-fcopy.txt) r]
set out [open $path(kyrillic.txt) w]
# -translation binary is also -encoding binary
chan configure $in -translation binary
chan configure $out -encoding koi8-r -translation lf -profile strict
catch {chan copy $in $out} cres copts
return $cres
} -cleanup {
if {$in in [chan names]} {
close $in
}
if {$out in [chan names]} {
close $out
}
catch {unset cres}
} -match glob -result {error writing "*": invalid or incomplete\
multibyte or wide character}
test chan-io-53.1 {CopyData} -setup {
file delete $path(test1)
} -constraints {fcopy} -body {
set f1 [open $thisScript]
set f2 [open $path(test1) w]
chan configure $f1 -translation lf -blocking 0
|
| ︙ | ︙ | |||
7576 7577 7578 7579 7580 7581 7582 |
chan event $pipe readable [namespace code [list readit $pipe]]
variable x ""
set result ""
vwait [namespace which -variable x]
# cut of the remainder of the error stack, especially the filename
set result [lreplace $result 3 3 [lindex [split [lindex $result 3] \n] 0]]
list $x $result
| | | 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 |
chan event $pipe readable [namespace code [list readit $pipe]]
variable x ""
set result ""
vwait [namespace which -variable x]
# cut of the remainder of the error stack, especially the filename
set result [lreplace $result 3 3 [lindex [split [lindex $result 3] \n] 0]]
list $x $result
} {1 {gets {} catch {error writing "stdout": invalid or incomplete multibyte or wide character}}}
test chan-io-61.1 {Reset eof state after changing the eof char} -setup {
set datafile [makeFile {} eofchar]
set f [open $datafile w]
chan configure $f -translation binary
chan puts -nonewline $f [string repeat "Ho hum\n" 11]
chan puts $f =
|
| ︙ | ︙ | |||
7604 7605 7606 7607 7608 7609 7610 |
#chan seek $f 0 current
#lappend res [chan read $f; chan tell $f]
} -cleanup {
chan close $f
removeFile eofchar
} -result {77 = 23431}
| | | 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 |
#chan seek $f 0 current
#lappend res [chan read $f; chan tell $f]
} -cleanup {
chan close $f
removeFile eofchar
} -result {77 = 23431}
# Test the cutting and splicing of channels, this is incidentally the
# attach/detach facility of package Thread, but __without any safeguards__. It
# can also be used to emulate transfer of channels between threads, and is
# used for that here.
test chan-io-70.0 {Cutting & Splicing channels} -setup {
set f [makeFile {... dummy ...} cutsplice]
set res {}
|
| ︙ | ︙ |
Changes to tests/clock.test.
| ︙ | ︙ | |||
36039 36040 36041 36042 36043 36044 36045 |
unset oldTZ
} else {
unset env(TZ)
}
} \
-result {-0500}
| | | 36039 36040 36041 36042 36043 36044 36045 36046 36047 36048 36049 36050 36051 36052 36053 |
unset oldTZ
} else {
unset env(TZ)
}
} \
-result {-0500}
# 43.1 was a bad test - mktime returning -1 is an error according to Posix.
test clock-44.1 {regression test - time zone name containing hyphen } \
-setup {
if { [info exists env(TZ)] } {
set oldTZ $env(TZ)
}
set env(TZ) US/East-Indiana
|
| ︙ | ︙ |
Changes to tests/cmdAH.test.
| ︙ | ︙ | |||
1720 1721 1722 1723 1724 1725 1726 |
} -result "could not get modification time for file \"con\"" -returnCodes error
test cmdAH-24.14.1 {
Tcl_FileObjCmd: mtime (built-in Windows names with dir path and extension)
} -constraints {win} -body {
file mtime [file join [temporaryDirectory] CON.txt]
} -match regexp -result {could not (?:get modification time|read)} -returnCodes error
| | | 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 |
} -result "could not get modification time for file \"con\"" -returnCodes error
test cmdAH-24.14.1 {
Tcl_FileObjCmd: mtime (built-in Windows names with dir path and extension)
} -constraints {win} -body {
file mtime [file join [temporaryDirectory] CON.txt]
} -match regexp -result {could not (?:get modification time|read)} -returnCodes error
# 3155760000 is 64-bit Unix time, Wed Jan 01 00:00:00 GMT 2070:
test cmdAH-24.20.1 {Tcl_FileObjCmd: atime 64-bit time_t, bug [4718b41c56]} -setup {
set filename [makeFile "" foo.text]
} -body {
list [file atime $filename 3155760000] [file atime $filename]
} -cleanup {
removeFile $filename
} -result {3155760000 3155760000}
|
| ︙ | ︙ | |||
2126 2127 2128 2129 2130 2131 2132 |
test cmdAH-32.5 {file tempfile - templates} -constraints unix -body {
set template [file join $dirfile foo]
close [file tempfile name $template]
expr {[string match $template* $name] ? "ok" : "$template produced $name"}
} -cleanup {
catch {file delete $name}
} -result ok
| | | 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 |
test cmdAH-32.5 {file tempfile - templates} -constraints unix -body {
set template [file join $dirfile foo]
close [file tempfile name $template]
expr {[string match $template* $name] ? "ok" : "$template produced $name"}
} -cleanup {
catch {file delete $name}
} -result ok
# Not portable; not all Unix systems have mkstemps()
test cmdAH-32.6 {file tempfile - templates} -body {
set template [file join $dirfile foo]
close [file tempfile name $template.bar]
expr {[string match $template*.bar $name] ? "ok" :
"$template.bar produced $name"}
} -constraints {unix nonPortable} -cleanup {
catch {file delete $name}
|
| ︙ | ︙ |
Changes to tests/cmdIL.test.
| ︙ | ︙ | |||
164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
} [list \x00 \x7F \x80 \uFFFF \U01FFFF]
test cmdIL-1.41 {lsort -stride and -index} -body {
lsort -stride 2 -index -2 {a 2 b 1}
} -returnCodes error -result {index "-2" out of range}
test cmdIL-1.42 {lsort -stride and-index} -body {
lsort -stride 2 -index -1-1 {a 2 b 1}
} -returnCodes error -result {index "-1-1" out of range}
# Can't think of any good tests for the MergeSort and MergeLists procedures,
# except a bunch of random lists to sort.
test cmdIL-2.1 {MergeSort and MergeLists procedures} -setup {
set result {}
set r 1435753299
| > > > | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
} [list \x00 \x7F \x80 \uFFFF \U01FFFF]
test cmdIL-1.41 {lsort -stride and -index} -body {
lsort -stride 2 -index -2 {a 2 b 1}
} -returnCodes error -result {index "-2" out of range}
test cmdIL-1.42 {lsort -stride and-index} -body {
lsort -stride 2 -index -1-1 {a 2 b 1}
} -returnCodes error -result {index "-1-1" out of range}
test cmdIL-1.43 {lsort -stride errors} -returnCodes error -body {
lsort -stride 4294967296 bar
} -result {list size must be a multiple of the stride length}
# Can't think of any good tests for the MergeSort and MergeLists procedures,
# except a bunch of random lists to sort.
test cmdIL-2.1 {MergeSort and MergeLists procedures} -setup {
set result {}
set r 1435753299
|
| ︙ | ︙ |
Changes to tests/cmdMZ.test.
| ︙ | ︙ | |||
51 52 53 54 55 56 57 |
} -match glob -result {?*}
test cmdMZ-1.4 {Tcl_PwdObjCmd: failure} -setup {
set cwd [pwd]
set foodir [file join [temporaryDirectory] foo]
file delete -force $foodir
file mkdir $foodir
cd $foodir
| | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
} -match glob -result {?*}
test cmdMZ-1.4 {Tcl_PwdObjCmd: failure} -setup {
set cwd [pwd]
set foodir [file join [temporaryDirectory] foo]
file delete -force $foodir
file mkdir $foodir
cd $foodir
} -constraints {Unix nonPortable} -body {
# This test fails on various Unix platforms (eg Linux) where permissions
# caching causes this to fail. The caching is strictly incorrect, but we
# have no control over that.
file attr . -permissions 0
pwd
} -returnCodes error -cleanup {
cd $cwd
file delete -force $foodir
|
| ︙ | ︙ |
Changes to tests/compile.test.
| ︙ | ︙ | |||
516 517 518 519 520 521 522 |
ti eval {foreach cmd {eval "if 1" try catch} {
set c [gencode 500 $cmd]
lappend errors [catch $c e] $e
}}
#puts $errors
# all of nested calls exceed the limit, so must end with "too many nested compilations"
# (or evaluations, depending on compile method/instruction and "mixed" compile within
| | | 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
ti eval {foreach cmd {eval "if 1" try catch} {
set c [gencode 500 $cmd]
lappend errors [catch $c e] $e
}}
#puts $errors
# all of nested calls exceed the limit, so must end with "too many nested compilations"
# (or evaluations, depending on compile method/instruction and "mixed" compile within
# evaluation), so no one succeeds, the result must be empty:
ti eval {set result}
} -result {}
#
# clean up:
if {[interp exists ti]} {
interp delete ti
}
|
| ︙ | ︙ |
Changes to tests/dict.test.
| ︙ | ︙ | |||
1119 1120 1121 1122 1123 1124 1125 |
dict get $successors x
}}
} [dict create c d a b]
test dict-19.2 {dict: testing for leaks} -constraints memory -body {
# This test is made to stress object reference management
memtest {
apply {{} {
| | | 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 |
dict get $successors x
}}
} [dict create c d a b]
test dict-19.2 {dict: testing for leaks} -constraints memory -body {
# This test is made to stress object reference management
memtest {
apply {{} {
# A shared invalid dictionary
set apa {a {}b c d}
set bepa $apa
catch {dict replace $apa e f}
catch {dict remove $apa c d}
catch {dict incr apa a 5}
catch {dict lappend apa a 5}
catch {dict append apa a 5}
|
| ︙ | ︙ |
Changes to tests/encoding.test.
| ︙ | ︙ | |||
461 462 463 464 465 466 467 |
binary scan $y H* z
list [string length $y] $z
} {2 cfbf}
test encoding-15.25 {UtfToUtfProc CESU-8} {
encoding convertfrom cesu-8 \x00
} \x00
test encoding-15.26 {UtfToUtfProc CESU-8} {
| | | 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
binary scan $y H* z
list [string length $y] $z
} {2 cfbf}
test encoding-15.25 {UtfToUtfProc CESU-8} {
encoding convertfrom cesu-8 \x00
} \x00
test encoding-15.26 {UtfToUtfProc CESU-8} {
encoding convertfrom -profile tcl8 cesu-8 \xC0\x80
} \x00
test encoding-15.27 {UtfToUtfProc -profile strict CESU-8} {
encoding convertfrom -profile strict cesu-8 \x00
} \x00
test encoding-15.28 {UtfToUtfProc -profile strict CESU-8} -body {
encoding convertfrom -profile strict cesu-8 \xC0\x80
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC0'}
|
| ︙ | ︙ | |||
488 489 490 491 492 493 494 |
list $val [format %x [scan $val %c]]
} -result "乎 4e4e"
test encoding-16.2 {Utf16ToUtfProc} -body {
set val [encoding convertfrom utf-16 "\xD8\xD8\xDC\xDC"]
list $val [format %x [scan $val %c]]
} -result "\U460DC 460dc"
test encoding-16.3 {Utf16ToUtfProc} -body {
| | | | | | | | | | | | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
list $val [format %x [scan $val %c]]
} -result "乎 4e4e"
test encoding-16.2 {Utf16ToUtfProc} -body {
set val [encoding convertfrom utf-16 "\xD8\xD8\xDC\xDC"]
list $val [format %x [scan $val %c]]
} -result "\U460DC 460dc"
test encoding-16.3 {Utf16ToUtfProc} -body {
set val [encoding convertfrom -profile tcl8 utf-16 "\xDC\xDC"]
list $val [format %x [scan $val %c]]
} -result "\uDCDC dcdc"
test encoding-16.4 {Ucs2ToUtfProc} -body {
set val [encoding convertfrom ucs-2 NN]
list $val [format %x [scan $val %c]]
} -result "乎 4e4e"
test encoding-16.5 {Ucs2ToUtfProc} -body {
set val [encoding convertfrom ucs-2 "\xD8\xD8\xDC\xDC"]
list $val [format %x [scan $val %c]]
} -result "\U460DC 460dc"
test encoding-16.6 {Utf32ToUtfProc} -body {
set val [encoding convertfrom -profile strict utf-32le NN\0\0]
list $val [format %x [scan $val %c]]
} -result "乎 4e4e"
test encoding-16.7 {Utf32ToUtfProc} -body {
set val [encoding convertfrom -profile strict utf-32be \0\0NN]
list $val [format %x [scan $val %c]]
} -result "乎 4e4e"
test encoding-16.8 {Utf32ToUtfProc} -body {
set val [encoding convertfrom -profile tcl8 utf-32 \x41\x00\x00\x41]
list $val [format %x [scan $val %c]]
} -result "\uFFFD fffd"
test encoding-16.9 {Utf32ToUtfProc} -constraints utf32 -body {
encoding convertfrom -profile tcl8 utf-32le \x00\xD8\x00\x00
} -result \uD800
test encoding-16.10 {Utf32ToUtfProc} -body {
encoding convertfrom -profile tcl8 utf-32le \x00\xDC\x00\x00
} -result \uDC00
test encoding-16.11 {Utf32ToUtfProc} -body {
encoding convertfrom -profile tcl8 utf-32le \x00\xD8\x00\x00\x00\xDC\x00\x00
} -result \uD800\uDC00
test encoding-16.12 {Utf32ToUtfProc} -constraints utf32 -body {
encoding convertfrom -profile tcl8 utf-32le \x00\xDC\x00\x00\x00\xD8\x00\x00
} -result \uDC00\uD800
test encoding-16.13 {Utf16ToUtfProc} -body {
encoding convertfrom -profile tcl8 utf-16le \x00\xD8
} -result \uD800
test encoding-16.14 {Utf16ToUtfProc} -body {
encoding convertfrom -profile tcl8 utf-16le \x00\xDC
} -result \uDC00
test encoding-16.15 {Utf16ToUtfProc} -body {
encoding convertfrom utf-16le \x00\xD8\x00\xDC
} -result \U010000
test encoding-16.16 {Utf16ToUtfProc} -body {
encoding convertfrom -profile tcl8 utf-16le \x00\xDC\x00\xD8
} -result \uDC00\uD800
test encoding-16.17 {Utf32ToUtfProc} -body {
list [encoding convertfrom -profile strict -failindex idx utf-32le \x41\x00\x00\x00\x00\xD8\x00\x00\x42\x00\x00\x00] [set idx]
} -result {A 4}
test encoding-16.18 {
Utf16ToUtfProc, Tcl_UniCharToUtf, surrogate pairs in utf-16
|
| ︙ | ︙ | |||
559 560 561 562 563 564 565 |
}
}
}
return done
} [namespace current]]
} -result done
test encoding-16.19 {Utf16ToUtfProc, bug [d19fe0a5b]} -body {
| | | | | | | | | 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
}
}
}
return done
} [namespace current]]
} -result done
test encoding-16.19 {Utf16ToUtfProc, bug [d19fe0a5b]} -body {
encoding convertfrom -profile tcl8 utf-16 "\x41\x41\x41"
} -result \u4141\uFFFD
test encoding-16.20 {Utf16ToUtfProc, bug [d19fe0a5b]} -constraints deprecated -body {
encoding convertfrom utf-16 "\xD8\xD8"
} -result \uD8D8
test encoding-16.21 {Utf32ToUtfProc, bug [d19fe0a5b]} -body {
encoding convertfrom -profile tcl8 utf-32 "\x00\x00\x00\x00\x41\x41"
} -result \x00\uFFFD
test encoding-16.22 {Utf16ToUtfProc, strict, bug [db7a085bd9]} -body {
encoding convertfrom -profile strict utf-16le \x00\xD8
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\x00'}
test encoding-16.23 {Utf16ToUtfProc, strict, bug [db7a085bd9]} -body {
encoding convertfrom -profile strict utf-16le \x00\xDC
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\x00'}
test encoding-16.24 {Utf32ToUtfProc} -body {
encoding convertfrom -profile tcl8 utf-32 "\xFF\xFF\xFF\xFF"
} -result \uFFFD
test encoding-16.25 {Utf32ToUtfProc} -body {
encoding convertfrom -profile tcl8 utf-32 "\x01\x00\x00\x01"
} -result \uFFFD
test encoding-17.1 {UtfToUtf16Proc} -body {
encoding convertto utf-16 "\U460DC"
} -result "\xD8\xD8\xDC\xDC"
test encoding-17.2 {UtfToUcs2Proc} -body {
encoding convertfrom utf-16 \xD8\xD8\xDC\xDC
} -result "\U460DC"
test encoding-17.3 {UtfToUtf16Proc} -body {
encoding convertto -profile tcl8 utf-16be "\uDCDC"
} -result "\xDC\xDC"
test encoding-17.4 {UtfToUtf16Proc} -body {
encoding convertto -profile tcl8 utf-16le "\uD8D8"
} -result "\xD8\xD8"
test encoding-17.5 {UtfToUtf32Proc} -body {
encoding convertto utf-32le "\U460DC"
} -result "\xDC\x60\x04\x00"
test encoding-17.6 {UtfToUtf32Proc} -body {
encoding convertto utf-32be "\U460DC"
} -result "\x00\x04\x60\xDC"
test encoding-17.7 {UtfToUtf16Proc} -body {
encoding convertto -profile strict utf-16be "\uDCDC"
} -returnCodes error -result {unexpected character at index 0: 'U+00DCDC'}
test encoding-17.8 {UtfToUtf16Proc} -body {
encoding convertto -profile strict utf-16le "\uD8D8"
|
| ︙ | ︙ | |||
618 619 620 621 622 623 624 |
encoding convertfrom -profile strict utf-32le "\x00\xD8\x00\x00"
} -returnCodes error -result {unexpected byte sequence starting at index 0: '\x00'}
test encoding-17.12 {Utf32ToUtfProc} -body {
encoding convertfrom -profile strict utf-32le "\x00\xDC\x00\x00"
} -returnCodes error -result {unexpected byte sequence starting at index 0: '\x00'}
test encoding-18.1 {TableToUtfProc on invalid input} -body {
| | | | | | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 |
encoding convertfrom -profile strict utf-32le "\x00\xD8\x00\x00"
} -returnCodes error -result {unexpected byte sequence starting at index 0: '\x00'}
test encoding-17.12 {Utf32ToUtfProc} -body {
encoding convertfrom -profile strict utf-32le "\x00\xDC\x00\x00"
} -returnCodes error -result {unexpected byte sequence starting at index 0: '\x00'}
test encoding-18.1 {TableToUtfProc on invalid input} -body {
list [catch {encoding convertto -profile tcl8 jis0208 \\} res] $res
} -result {0 !)}
test encoding-18.2 {TableToUtfProc on invalid input with -profile strict} -body {
list [catch {encoding convertto -profile strict jis0208 \\} res] $res
} -result {1 {unexpected character at index 0: 'U+00005C'}}
test encoding-18.3 {TableToUtfProc on invalid input with -profile strict -failindex} -body {
list [catch {encoding convertto -profile strict -failindex pos jis0208 \\} res] $res $pos
} -result {0 {} 0}
test encoding-18.4 {TableToUtfProc on invalid input with -failindex -profile strict} -body {
list [catch {encoding convertto -failindex pos -profile strict jis0208 \\} res] $res $pos
} -result {0 {} 0}
test encoding-18.5 {TableToUtfProc on invalid input with -failindex} -body {
list [catch {encoding convertto -profile tcl8 -failindex pos jis0208 \\} res] $res $pos
} -result {0 !) -1}
test encoding-18.6 {TableToUtfProc on invalid input with -profile tcl8} -body {
list [catch {encoding convertto -profile tcl8 jis0208 \\} res] $res
} -result {0 !)}
test encoding-19.1 {TableFromUtfProc} -body {
encoding convertfrom -profile tcl8 ascii AÁ
} -result AÁ
test encoding-19.2 {TableFromUtfProc} -body {
encoding convertfrom -profile tcl8 ascii AÁ
} -result AÁ
test encoding-19.3 {TableFromUtfProc} -body {
encoding convertfrom -profile strict ascii AÁ
} -returnCodes 1 -result {unexpected byte sequence starting at index 1: '\xC1'}
test encoding-19.4 {TableFromUtfProc} -body {
list [encoding convertfrom -profile tcl8 -failindex idx ascii AÁ] [set idx]
} -result [list A\xC1 -1]
test encoding-19.5 {TableFromUtfProc} -body {
list [encoding convertfrom -failindex idx -profile strict ascii A\xC1] [set idx]
} -result {A 1}
test encoding-19.6 {TableFromUtfProc} -body {
list [encoding convertfrom -failindex idx -profile strict ascii AÁB] [set idx]
} -result {A 1}
|
| ︙ | ︙ | |||
795 796 797 798 799 800 801 |
test encoding-24.13 {Parse valid or invalid utf-8} -body {
encoding convertfrom -profile strict utf-8 "\xC1\xBF"
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC1'}
test encoding-24.14 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xC2\x80"]
} 1
test encoding-24.15 {Parse valid or invalid utf-8} -body {
| | | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 |
test encoding-24.13 {Parse valid or invalid utf-8} -body {
encoding convertfrom -profile strict utf-8 "\xC1\xBF"
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC1'}
test encoding-24.14 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xC2\x80"]
} 1
test encoding-24.15 {Parse valid or invalid utf-8} -body {
encoding convertfrom -profile tcl8 utf-8 "Z\xE0\x80"
} -result Z\xE0\u20AC
test encoding-24.16 {Parse valid or invalid utf-8} -constraints testbytestring -body {
encoding convertto utf-8 [testbytestring "Z\u4343\x80"]
} -returnCodes 1 -result {expected byte sequence but character 1 was '䍃' (U+004343)}
test encoding-24.17 {Parse valid or invalid utf-8} -constraints testbytestring -body {
encoding convertto utf-8 [testbytestring "Z\xE0\x80"]
} -result "Z\xC3\xA0\xE2\x82\xAC"
|
| ︙ | ︙ | |||
858 859 860 861 862 863 864 |
test encoding-24.33 {Try to generate noncharacter with -profile strict} -body {
encoding convertto -profile strict utf-8 \uFFFF
} -result \xEF\xBF\xBF
test encoding-24.34 {Try to generate invalid utf-8 with -profile tcl8} -body {
encoding convertto -profile tcl8 utf-8 \uFFFF
} -result \xEF\xBF\xBF
test encoding-24.35 {Parse invalid utf-8} -constraints utf32 -body {
| | | 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 |
test encoding-24.33 {Try to generate noncharacter with -profile strict} -body {
encoding convertto -profile strict utf-8 \uFFFF
} -result \xEF\xBF\xBF
test encoding-24.34 {Try to generate invalid utf-8 with -profile tcl8} -body {
encoding convertto -profile tcl8 utf-8 \uFFFF
} -result \xEF\xBF\xBF
test encoding-24.35 {Parse invalid utf-8} -constraints utf32 -body {
encoding convertfrom -profile tcl8 utf-8 \xED\xA0\x80
} -result \uD800
test encoding-24.36 {Parse invalid utf-8 with -profile strict} -body {
encoding convertfrom -profile strict utf-8 \xED\xA0\x80
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xED'}
test encoding-24.37 {Parse invalid utf-8 with -profile tcl8} -body {
encoding convertfrom -profile tcl8 utf-8 \xED\xA0\x80
} -result \uD800
|
| ︙ | ︙ |
Changes to tests/env.test.
| ︙ | ︙ | |||
217 218 219 220 221 222 223 |
getenv
} -cleanup { cleanup1
} -result {NAME1=test string
NAME2=more
XYZZY=garbage}
test env-2.5 {different encoding (wide chars)} -constraints {win exec} -setup {
| | | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
getenv
} -cleanup { cleanup1
} -result {NAME1=test string
NAME2=more
XYZZY=garbage}
test env-2.5 {different encoding (wide chars)} -constraints {win exec} -setup {
# be sure set of (Unicode) environment occurs if single-byte encoding is used:
encodingswitch cp1252
# German (cp1252) and Russian (cp1251) characters together encoded as utf-8:
set val 2d2dc3a4c3b6c3bcc39f2dd182d0b5d181d1822d2d
set env(XYZZY) [encoding convertfrom utf-8 [binary decode hex $val]]
# now switch to utf-8 (to see correct values from test):
encoding system utf-8
} -body {
exec [interpreter] << [string map [list \$val $val] {
encoding system utf-8; fconfigure stdout -encoding utf-8
|
| ︙ | ︙ | |||
299 300 301 302 303 304 305 |
} -cleanup cleanup1 -result a
test env-5.1 {
corner cases - remove one elem at a time
} -setup setup1 -body {
# When no environment variables exist, the env var will contain no
| | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
} -cleanup cleanup1 -result a
test env-5.1 {
corner cases - remove one elem at a time
} -setup setup1 -body {
# When no environment variables exist, the env var will contain no
# entries. The "array names" call syncs up the C-level environ array with
# the Tcl level env array. Make sure an empty Tcl array is created.
foreach e [array names env] {
unset env($e)
}
array size env
} -cleanup cleanup1 -result 0
|
| ︙ | ︙ | |||
343 344 345 346 347 348 349 |
} -result {a 1}
test env-5.4 {corner cases - unset the env array} -setup {
setup1
interp create i
} -body {
| | | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
} -result {a 1}
test env-5.4 {corner cases - unset the env array} -setup {
setup1
interp create i
} -body {
# The info exists command should be in sync with the env array.
# Know Bug: 1737
i eval {set env(THIS_SHOULD_EXIST) a}
set result [info exists env(THIS_SHOULD_EXIST)]
lappend result [set env(THIS_SHOULD_EXIST)]
lappend result [info exists env(THIS_SHOULD_EXIST)]
} -cleanup {
cleanup1
|
| ︙ | ︙ |
Changes to tests/error.test.
| ︙ | ︙ | |||
920 921 922 923 924 925 926 |
} finally {
throw BAR baz
}
}
list $em [dict get $opts -errorcode]
} {bar FOO}
| | | 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 |
} finally {
throw BAR baz
}
}
list $em [dict get $opts -errorcode]
} {bar FOO}
# try tests - fall-through body cases
test error-19.1 {try with fallthrough body #1} {
set RES {}
try { list a b c } on ok { set RES 0 } - on error {} { set RES 1 }
set RES
} {1}
test error-19.2 {try with fallthrough body #2} {
|
| ︙ | ︙ |
Changes to tests/eval.test.
| ︙ | ︙ | |||
60 61 62 63 64 65 66 |
eval [list list 1 2 3 4 5]
} {1 2 3 4 5}
test eval-3.2 {concatenating eval and pure lists} {
eval [list list 1] [list 2 3 4 5]
} {1 2 3 4 5}
test eval-3.3 {eval and canonical lists} {
set cmd [list list 1 2 3 4 5]
| | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
eval [list list 1 2 3 4 5]
} {1 2 3 4 5}
test eval-3.2 {concatenating eval and pure lists} {
eval [list list 1] [list 2 3 4 5]
} {1 2 3 4 5}
test eval-3.3 {eval and canonical lists} {
set cmd [list list 1 2 3 4 5]
# Force existence of utf-8 rep
set dummy($cmd) $cmd
unset dummy
eval $cmd
} {1 2 3 4 5}
test eval-3.4 {concatenating eval and canonical lists} {
set cmd [list list 1]
set cmd2 [list 2 3 4 5]
# Force existence of utf-8 rep
set dummy($cmd) $cmd
set dummy($cmd2) $cmd2
unset dummy
eval $cmd $cmd2
} {1 2 3 4 5}
# cleanup
|
| ︙ | ︙ |
Changes to tests/event.test.
| ︙ | ︙ | |||
423 424 425 426 427 428 429 |
while executing
"error foo"
("after" script)
}
# someday : add a test checking that when there is no bgerror, an error msg
# goes to stderr ideally one would use sub interp and transfer a fake stderr
| | | 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
while executing
"error foo"
("after" script)
}
# someday : add a test checking that when there is no bgerror, an error msg
# goes to stderr ideally one would use sub interp and transfer a fake stderr
# to it, unfortunately the current interp tcl API does not allow that. The
# other option would be to use fork a test but it then becomes more a
# file/exec test than a bgerror test.
# end of bgerror tests
catch {rename bgerror {}}
test event-8.1 {Tcl_CreateExitHandler procedure} {stdio testexithandler} {
|
| ︙ | ︙ |
Changes to tests/exec.test.
| ︙ | ︙ | |||
21 22 23 24 25 26 27 |
source [file join [file dirname [info script]] tcltests.tcl]
# Some skips when running in a macOS CI environment
testConstraint noosxCI [expr {![info exists ::env(MAC_CI)]}]
unset -nocomplain path
| | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
source [file join [file dirname [info script]] tcltests.tcl]
# Some skips when running in a macOS CI environment
testConstraint noosxCI [expr {![info exists ::env(MAC_CI)]}]
unset -nocomplain path
# Utilities that are like Bourne shell stalwarts, but cross-platform.
set path(echo) [makeFile {
puts -nonewline [lindex $argv 0]
foreach str [lrange $argv 1 end] {
puts -nonewline " $str"
}
puts {}
exit
|
| ︙ | ︙ | |||
433 434 435 436 437 438 439 |
test exec-10.19 {errors in exec invocation} -constraints {exec} -body {
exec cat >@ $f
} -returnCodes error -result "channel \"$f\" wasn't opened for writing"
close $f
test exec-10.20.1 {errors in exec invocation} -constraints {unix exec notValgrind} -body {
exec ~non_existent_user/foo/bar
} -returnCodes error -result {couldn't execute "~non_existent_user/foo/bar": no such file or directory}
| | | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
test exec-10.19 {errors in exec invocation} -constraints {exec} -body {
exec cat >@ $f
} -returnCodes error -result "channel \"$f\" wasn't opened for writing"
close $f
test exec-10.20.1 {errors in exec invocation} -constraints {unix exec notValgrind} -body {
exec ~non_existent_user/foo/bar
} -returnCodes error -result {couldn't execute "~non_existent_user/foo/bar": no such file or directory}
test exec-10.20.2 {errors in exec invocation} -constraints {win exec notValgrind} -body {
exec ~non_existent_user/foo/bar
} -returnCodes error -result {couldn't execute "~non_existent_user\foo\bar": no such file or directory}
test exec-10.21.1 {errors in exec invocation} -constraints {unix exec notValgrind} -body {
exec [interpreter] true | ~xyzzy_bad_user/x | false
} -returnCodes error -result {couldn't execute "~xyzzy_bad_user/x": no such file or directory}
test exec-10.21.2 {errors in exec invocation} -constraints {win exec notValgrind} -body {
exec [interpreter] true | ~xyzzy_bad_user/x | false
|
| ︙ | ︙ |
Changes to tests/fCmd.test.
| ︙ | ︙ | |||
83 84 85 86 87 88 89 |
testConstraint notContinuousIntegration [expr {![info exists ::env(CI)]}]
testConstraint fileSharing 0
testConstraint notFileSharing 1
testConstraint linkFile 1
testConstraint linkDirectory 1
| | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
testConstraint notContinuousIntegration [expr {![info exists ::env(CI)]}]
testConstraint fileSharing 0
testConstraint notFileSharing 1
testConstraint linkFile 1
testConstraint linkDirectory 1
# Several tests require need to match results against the Unix username
set user {}
if {[testConstraint unix]} {
catch {
set user [exec whoami]
}
if {$user eq ""} {
catch {
|
| ︙ | ︙ | |||
406 407 408 409 410 411 412 |
file rename ~_totally_bogus_user td1
} -result {error renaming "~_totally_bogus_user": no such file or directory}
test fCmd-3.15 {FileCopyRename: source[0] == '\x00'} -setup {
cleanup
} -constraints {notRoot unixOrWin} -returnCodes error -body {
file mkdir td1
file rename / td1
| | | | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
file rename ~_totally_bogus_user td1
} -result {error renaming "~_totally_bogus_user": no such file or directory}
test fCmd-3.15 {FileCopyRename: source[0] == '\x00'} -setup {
cleanup
} -constraints {notRoot unixOrWin} -returnCodes error -body {
file mkdir td1
file rename / td1
} -result {error renaming "/" to "td1": file exists}
test fCmd-3.16 {FileCopyRename: break on first error} -setup {
cleanup
} -constraints {notRoot} -returnCodes error -body {
createfile tf1
createfile tf2
createfile tf3
createfile tf4
file mkdir td1
createfile [file join td1 tf3]
file rename tf1 tf2 tf3 tf4 td1
} -result [subst {error renaming "tf3" to "[file join td1 tf3]": file exists}]
test fCmd-4.1 {TclFileMakeDirsCmd: make each dir: 1 dir} -setup {
cleanup
} -constraints {notRoot} -body {
file mkdir td1
glob td*
} -result {td1}
|
| ︙ | ︙ | |||
479 480 481 482 483 484 485 |
list $x [file exists td1]
} -result {1 1}
test fCmd-4.9 {TclFileMakeDirsCmd: exists, not dir} -setup {
cleanup
} -constraints {notRoot} -returnCodes error -body {
createfile tf1
file mkdir tf1
| | | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
list $x [file exists td1]
} -result {1 1}
test fCmd-4.9 {TclFileMakeDirsCmd: exists, not dir} -setup {
cleanup
} -constraints {notRoot} -returnCodes error -body {
createfile tf1
file mkdir tf1
} -result [subst {can't create directory "[file join tf1]": file exists}]
test fCmd-4.10 {TclFileMakeDirsCmd: exists, is dir} -setup {
cleanup
} -constraints {notRoot} -body {
file mkdir td1
set x [file exists td1]
file mkdir td1
list $x [file exists td1]
|
| ︙ | ︙ | |||
655 656 657 658 659 660 661 |
} -result {tf2}
test fCmd-6.10 {CopyRenameOneFile: lstat(target) == 0} -setup {
cleanup
} -constraints {notRoot} -returnCodes error -body {
createfile tf1
createfile tf2
file rename tf1 tf2
| | | | 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
} -result {tf2}
test fCmd-6.10 {CopyRenameOneFile: lstat(target) == 0} -setup {
cleanup
} -constraints {notRoot} -returnCodes error -body {
createfile tf1
createfile tf2
file rename tf1 tf2
} -result {error renaming "tf1" to "tf2": file exists}
test fCmd-6.11 {CopyRenameOneFile: force == 0} -setup {
cleanup
} -constraints {notRoot} -returnCodes error -body {
createfile tf1
createfile tf2
file rename tf1 tf2
} -result {error renaming "tf1" to "tf2": file exists}
test fCmd-6.12 {CopyRenameOneFile: force != 0} -setup {
cleanup
} -constraints {notRoot} -body {
createfile tf1
createfile tf2
file rename -force tf1 tf2
glob tf*
|
| ︙ | ︙ | |||
802 803 804 805 806 807 808 |
test fCmd-6.27 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
cleanup $tmpspace
} -constraints {notRoot xdev} -returnCodes error -body {
file mkdir td1/td2/td3
file mkdir [file join $tmpspace td1]
createfile [file join $tmpspace td1 tf1]
file rename -force td1 $tmpspace
| | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
test fCmd-6.27 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
cleanup $tmpspace
} -constraints {notRoot xdev} -returnCodes error -body {
file mkdir td1/td2/td3
file mkdir [file join $tmpspace td1]
createfile [file join $tmpspace td1 tf1]
file rename -force td1 $tmpspace
} -match glob -result {error renaming "td1" to "/tmp/tcl*/td1": file exists}
test fCmd-6.28 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
cleanup $tmpspace
} -constraints {notRoot xdev notWsl} -body {
file mkdir td1/td2/td3
file attributes td1/td2/td3 -permissions 0
file rename td1 $tmpspace
} -returnCodes error -cleanup {
|
| ︙ | ︙ | |||
879 880 881 882 883 884 885 |
createfile -force
file delete -force -force -- -- -force
glob -- -- -force
} -result {}
test fCmd-8.1 {FileBasename: basename of ~user: argc == 1 && *path == ~} \
-constraints {unix notRoot knownBug tildeexpansion} -body {
| | | 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 |
createfile -force
file delete -force -force -- -- -force
glob -- -- -force
} -result {}
test fCmd-8.1 {FileBasename: basename of ~user: argc == 1 && *path == ~} \
-constraints {unix notRoot knownBug tildeexpansion} -body {
# Labeled knownBug because it is dangerous [Bug: 3881]
file mkdir td1
file attr td1 -perm 0o40000
file rename ~$user td1
} -returnCodes error -cleanup {
file delete -force td1
} -result "error renaming \"~$user\" to \"td1/[file tail ~$user]\": permission denied"
test fCmd-8.2 {FileBasename: basename of ~user: argc == 1 && *path == ~} \
|
| ︙ | ︙ | |||
975 976 977 978 979 980 981 |
testchmod 0o444 tfd4
set msg [list [catch {file rename tf1 tf2} msg] $msg]
file rename -force tfs1 tfd1
file rename -force tfs2 tfd2
file rename -force tfs3 tfd3
file rename -force tfs4 tfd4
list [lsort [glob tf*]] $msg [file writable tfd1] [file writable tfd2] [file writable tfd3] [file writable tfd4]
| | | | 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 |
testchmod 0o444 tfd4
set msg [list [catch {file rename tf1 tf2} msg] $msg]
file rename -force tfs1 tfd1
file rename -force tfs2 tfd2
file rename -force tfs3 tfd3
file rename -force tfs4 tfd4
list [lsort [glob tf*]] $msg [file writable tfd1] [file writable tfd2] [file writable tfd3] [file writable tfd4]
} -result {{tf1 tf2 tfd1 tfd2 tfd3 tfd4} {1 {error renaming "tf1" to "tf2": file exists}} 1 1 0 0}
test fCmd-9.8 {file rename: comprehensive: dir to empty dir} -setup {
cleanup
} -constraints {notRoot testchmod notNetworkFilesystem} -body {
# Under Unix you can rename a read-only directory, but you can't move it
# into another directory.
file mkdir td1
file mkdir [file join td2 td1]
file mkdir tds1
file mkdir tds2
file mkdir tds3
file mkdir tds4
|
| ︙ | ︙ | |||
1011 1012 1013 1014 1015 1016 1017 |
set w4 0
} else {
set w3 [file writable [file join tdd3 tds3]]
set w4 [file writable [file join tdd4 tds4]]
}
list [lsort [glob td*]] $msg [file writable [file join tdd1 tds1]] \
[file writable [file join tdd2 tds2]] $w3 $w4
| | | 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 |
set w4 0
} else {
set w3 [file writable [file join tdd3 tds3]]
set w4 [file writable [file join tdd4 tds4]]
}
list [lsort [glob td*]] $msg [file writable [file join tdd1 tds1]] \
[file writable [file join tdd2 tds2]] $w3 $w4
} -result [subst {{td1 td2 tdd1 tdd2 tdd3 tdd4} {1 {error renaming "td1" to "[file join td2 td1]": file exists}} 1 1 0 0}]
# Test can hit EEXIST or EBUSY, depending on underlying filesystem
test fCmd-9.9 {file rename: comprehensive: dir to non-empty dir} -setup {
cleanup
} -constraints {notRoot testchmod notWine} -body {
file mkdir tds1
file mkdir tds2
file mkdir [file join tdd1 tds1 xxx]
|
| ︙ | ︙ | |||
1061 1062 1063 1064 1065 1066 1067 |
testchmod 0o555 [file join td2 td1]
file mkdir [file join td3 td4] [file join td4 td3]
file rename -force td3 td4
list [file exists td3] [file exists [file join td4 td3 td4]] \
[catch {file rename td1 td2} msg] $msg
} -cleanup {
testchmod 0o755 [file join td2 td1]
| | | 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 |
testchmod 0o555 [file join td2 td1]
file mkdir [file join td3 td4] [file join td4 td3]
file rename -force td3 td4
list [file exists td3] [file exists [file join td4 td3 td4]] \
[catch {file rename td1 td2} msg] $msg
} -cleanup {
testchmod 0o755 [file join td2 td1]
} -result [subst {0 1 1 {error renaming "td1" to "[file join td2 td1]": file exists}}]
# Test can hit EEXIST or EBUSY, depending on underlying filesystem
test fCmd-9.13 {file rename: comprehensive: can't overwrite target} -setup {
cleanup
} -constraints {notRoot notWine} -body {
file mkdir [file join td1 td2] [file join td2 td1 td4]
file rename -force td1 td2
} -returnCodes error -match glob -result \
|
| ︙ | ︙ | |||
1198 1199 1200 1201 1202 1203 1204 |
}
set msg [list [catch {file copy tf1 tf2} msg] $msg]
file copy -force tfs1 tfd1
file copy -force tfs2 tfd2
file copy -force tfs3 tfd3
file copy -force tfs4 tfd4
list [lsort [glob tf*]] $msg [file writable tfd1] [file writable tfd2] [file writable tfd3] [file writable tfd4]
| | | 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
}
set msg [list [catch {file copy tf1 tf2} msg] $msg]
file copy -force tfs1 tfd1
file copy -force tfs2 tfd2
file copy -force tfs3 tfd3
file copy -force tfs4 tfd4
list [lsort [glob tf*]] $msg [file writable tfd1] [file writable tfd2] [file writable tfd3] [file writable tfd4]
} -result {{tf1 tf2 tfd1 tfd2 tfd3 tfd4 tfs1 tfs2 tfs3 tfs4} {1 {error copying "tf1" to "tf2": file exists}} 1 1 0 0}
test fCmd-10.5 {file copy: comprehensive: dir to empty dir} -setup {
cleanup
} -constraints {notRoot testchmod} -body {
file mkdir td1
file mkdir [file join td2 td1]
file mkdir tds1
file mkdir tds2
|
| ︙ | ︙ | |||
1222 1223 1224 1225 1226 1227 1228 |
testchmod 0o555 [file join tdd4 tds4]
set a1 [list [catch {file copy td1 td2} msg] $msg]
set a2 [list [catch {file copy -force tds1 tdd1} msg] $msg]
set a3 [catch {file copy -force tds2 tdd2}]
set a4 [catch {file copy -force tds3 tdd3}]
set a5 [catch {file copy -force tds4 tdd4}]
list [lsort [glob td*]] $a1 $a2 $a3 $a4 $a5
| | | | 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 |
testchmod 0o555 [file join tdd4 tds4]
set a1 [list [catch {file copy td1 td2} msg] $msg]
set a2 [list [catch {file copy -force tds1 tdd1} msg] $msg]
set a3 [catch {file copy -force tds2 tdd2}]
set a4 [catch {file copy -force tds3 tdd3}]
set a5 [catch {file copy -force tds4 tdd4}]
list [lsort [glob td*]] $a1 $a2 $a3 $a4 $a5
} -result [subst {{td1 td2 tdd1 tdd2 tdd3 tdd4 tds1 tds2 tds3 tds4} {1 {error copying "td1" to "[file join td2 td1]": file exists}} {1 {error copying "tds1" to "[file join tdd1 tds1]": file exists}} 1 1 1}]
test fCmd-10.6 {file copy: comprehensive: dir to non-empty dir} -setup {
cleanup
} -constraints {notRoot unixOrWin testchmod notWsl} -body {
file mkdir tds1
file mkdir tds2
file mkdir [file join tdd1 tds1 xxx]
file mkdir [file join tdd2 tds2 xxx]
testchmod 0o555 tds2
set a1 [list [catch {file copy -force tds1 tdd1} msg] $msg]
set a2 [list [catch {file copy -force tds2 tdd2} msg] $msg]
list [lsort [glob td*]] $a1 $a2 [file writable tds1] [file writable tds2]
} -result [subst {{tdd1 tdd2 tds1 tds2} {1 {error copying "tds1" to "[file join tdd1 tds1]": file exists}} {1 {error copying "tds2" to "[file join tdd2 tds2]": file exists}} 1 0}]
test fCmd-10.7 {file rename: comprehensive: file to new name and dir} -setup {
cleanup
} -constraints {notRoot testchmod} -body {
createfile tf1
createfile tf2
file mkdir td1
testchmod 0o444 tf2
|
| ︙ | ︙ | |||
2456 2457 2458 2459 2460 2461 2462 |
} -result {could not create new link "abc.dir": that path already exists}
test fCmd-28.6 {file link: unsupported operation} -setup {
cd [temporaryDirectory]
} -constraints {linkDirectory win} -body {
file link -hard abc.link abc.dir
} -returnCodes error -cleanup {
cd [workingDirectory]
| | | 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 |
} -result {could not create new link "abc.dir": that path already exists}
test fCmd-28.6 {file link: unsupported operation} -setup {
cd [temporaryDirectory]
} -constraints {linkDirectory win} -body {
file link -hard abc.link abc.dir
} -returnCodes error -cleanup {
cd [workingDirectory]
} -result {could not create new link "abc.link" pointing to "abc.dir": is a directory}
test fCmd-28.7 {file link: source already exists} -setup {
cd [temporaryDirectory]
} -constraints {linkFile} -body {
file link abc.file abc2.file
} -returnCodes error -cleanup {
cd [workingDirectory]
} -result {could not create new link "abc.file": that path already exists}
|
| ︙ | ︙ | |||
2533 2534 2535 2536 2537 2538 2539 |
cd abc.link
set dir [pwd]
cd ..
set up [pwd]
cd $orig
# Now '$up' should be either $orig or [file dirname abc.dir], depending on
# whether 'cd' actually moves to the destination of a link, or simply
| | | 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 |
cd abc.link
set dir [pwd]
cd ..
set up [pwd]
cd $orig
# Now '$up' should be either $orig or [file dirname abc.dir], depending on
# whether 'cd' actually moves to the destination of a link, or simply
# treats the link as a directory. (On windows the former, on Unix the
# latter, I believe)
if {
([file normalize $up] ne [file normalize $orig]) &&
([file normalize $up] ne [file normalize [file dirname abc.dir]])
} then {
return "wrong directory with 'cd abc.link ; cd ..': \
\"[file normalize $up]\" should be \"[file normalize $orig]\"\
|
| ︙ | ︙ |
Changes to tests/fileName.test.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
package require tcltest 2.5
namespace import -force ::tcltest::*
}
::tcltest::loadTestedCommands
catch [list package require -exact tcl::test [info patchlevel]]
testConstraint testsetplatform [llength [info commands testsetplatform]]
testConstraint testtranslatefilename [llength [info commands testtranslatefilename]]
testConstraint linkDirectory 1
testConstraint symbolicLinkFile 1
if {[testConstraint win]} {
if {$::tcl_platform(osVersion) < 5.0 \
| > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
package require tcltest 2.5
namespace import -force ::tcltest::*
}
::tcltest::loadTestedCommands
catch [list package require -exact tcl::test [info patchlevel]]
source [file join [file dirname [info script]] tcltests.tcl]
testConstraint testsetplatform [llength [info commands testsetplatform]]
testConstraint testtranslatefilename [llength [info commands testtranslatefilename]]
testConstraint linkDirectory 1
testConstraint symbolicLinkFile 1
if {[testConstraint win]} {
if {$::tcl_platform(osVersion) < 5.0 \
|
| ︙ | ︙ | |||
1342 1343 1344 1345 1346 1347 1348 |
# test fails because if an error occurs, the interp's result is reset...
glob -nocomplain globTest/a2 globTest/a1/* globTest/a3
} {globTest/a2 globTest/a3}
catch {file attributes globTest/a1 -permissions 0o755}
test filename-15.4 {unix specific no complain: no errors, good result} \
{unix nonPortable} {
# test fails because if an error occurs, the interp's result is reset...
| | | 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 |
# test fails because if an error occurs, the interp's result is reset...
glob -nocomplain globTest/a2 globTest/a1/* globTest/a3
} {globTest/a2 globTest/a3}
catch {file attributes globTest/a1 -permissions 0o755}
test filename-15.4 {unix specific no complain: no errors, good result} \
{unix nonPortable} {
# test fails because if an error occurs, the interp's result is reset...
# or you don't run at scriptics where the ouster and welch users exists
glob -nocomplain ~ouster ~foo ~welch
} {/home/ouster /home/welch}
test filename-15.4.1 {no complain: errors, sequencing} {
# ~xxx no longer expanded so errors about unknown users should not occur
list [catch {glob -nocomplain ~wontexist ~blahxyz ~} res1] $res1 \
[catch {glob -nocomplain ~ ~blahxyz ~wontexist} res2] $res2
} {0 {} 0 {}}
|
| ︙ | ︙ | |||
1565 1566 1567 1568 1569 1570 1571 |
cd $dd
} -body {
glob -nocomplain */test
} -cleanup {
cd $savewd
removeDirectory ./~ $dd
removeDirectory isolate
| | | 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 |
cd $dd
} -body {
glob -nocomplain */test
} -cleanup {
cd $savewd
removeDirectory ./~ $dd
removeDirectory isolate
removeFile test [file home]
} -result {}
test fileName-20.7 {Bug 2806250} -setup {
set savewd [pwd]
cd [temporaryDirectory]
set d [makeDirectory isolate]
makeFile {} ./~test $d
} -body {
|
| ︙ | ︙ | |||
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 |
glob -nocomplain -directory [file home] -join * fileName-20.10
} -cleanup {
cd $savewd
removeDirectory isolate
removeFile fileName-20.10 $s
removeDirectory sub [file home]
} -result [file home]/sub/fileName-20.10
# cleanup
catch {file delete -force C:/globTest}
cd [temporaryDirectory]
file delete -force globTest
cd $oldpwd
catch {removeDirectory tcl[pid]}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 |
glob -nocomplain -directory [file home] -join * fileName-20.10
} -cleanup {
cd $savewd
removeDirectory isolate
removeFile fileName-20.10 $s
removeDirectory sub [file home]
} -result [file home]/sub/fileName-20.10
apply [list {} {
test fileName-6d4e9d1af5bf5b7d {
memory leak in SetFsPathFromAny
Runs under both a TCL_DEBUG_MEM build and a -DPURIFY build for
valgrind, which is useful since Valgrind provides information about the
error location, but [memory] doesn't.
} -setup {
if {[namespace which ::memory] eq {}} {
set memcheckcmd [list ::apply [list script {
uplevel 1 $script
return 0
} [namespace current]]]
} else {
set memcheckcmd ::tcltests::scriptmemcheck
}
} -body {
{*}$memcheckcmd {
set interp [interp create]
interp eval $interp {
apply [list {} {
upvar 1 f f
# A unique name so that no internal representation of this
# literal value has been picked up from any other script
# that has alredy been sourced into this interpreter.
set variableUniqueInTheEntireTclCodebase a
set name variableUniqueInTheEntireTclCodebase
# give the Tcl_Obj for "var1" an internal representation of
# type 'localVarNameType'.
set $name
set f [open variableUniqueInTheEntireTclCodebase w]
try {
puts $f {some data}
} finally {
close $f
}
set f [open variableUniqueInTheEntireTclCodebase]
try {
read $f
} finally {
catch {file delete variableUniqueInTheEntireTclCodebase}
close $f
}
} [namespace current]]
}
interp delete $interp
}
} -result 0
} [namespace current]]
# cleanup
catch {file delete -force C:/globTest}
cd [temporaryDirectory]
file delete -force globTest
cd $oldpwd
catch {removeDirectory tcl[pid]}
|
| ︙ | ︙ |
Changes to tests/fileSystem.test.
| ︙ | ︙ | |||
293 294 295 296 297 298 299 |
testsetplatform unix
file normalize /../bar
} {/bar}
test filesystem-1.33 {link normalisation: link near filesystem root} {testsetplatform} {
testsetplatform windows
set res [file normalize C:/../bar]
if {[testConstraint unix]} {
| | | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
testsetplatform unix
file normalize /../bar
} {/bar}
test filesystem-1.33 {link normalisation: link near filesystem root} {testsetplatform} {
testsetplatform windows
set res [file normalize C:/../bar]
if {[testConstraint unix]} {
# Some Unices go further in normalizing this -- not really a problem
# since this is a Windows test.
regexp {C:/bar$} $res res
}
set res
} {C:/bar}
if {[testConstraint testsetplatform]} {
testsetplatform $platform
|
| ︙ | ︙ | |||
690 691 692 693 694 695 696 |
lappend res $err
lappend res [file exists file2]
} -cleanup {
catch {testsimplefilesystem 0}
file delete -force simplefile
file delete -force file2
cd $dir
| | | 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
lappend res $err
lappend res [file exists file2]
} -cleanup {
catch {testsimplefilesystem 0}
file delete -force simplefile
file delete -force file2
cd $dir
} -result {0 {} 1 {error copying "simplefs:/simplefile" to "file2": file exists} 0 {} 1}
test filesystem-7.5 {cross-filesystem file copy with -force} -setup {
set dir [pwd]
cd [tcltest::temporaryDirectory]
set fout [open [file join simplefile] w]
puts -nonewline $fout "1234567890"
close $fout
testsimplefilesystem 1
|
| ︙ | ︙ | |||
715 716 717 718 719 720 721 |
lappend res $err
lappend res [file exists file2]
} -cleanup {
testsimplefilesystem 0
file delete -force simplefile
file delete -force file2
cd $dir
| | | 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 |
lappend res $err
lappend res [file exists file2]
} -cleanup {
testsimplefilesystem 0
file delete -force simplefile
file delete -force file2
cd $dir
} -result {0 {} 1 {error copying "simplefs:/simplefile" to "file2": file exists} 0 {} 1}
test filesystem-7.6 {cross-filesystem dir copy with -force} -setup {
set dir [pwd]
cd [tcltest::temporaryDirectory]
file delete -force simpledir
file mkdir simpledir
file mkdir dir2
set fout [open [file join simpledir simplefile] w]
|
| ︙ | ︙ | |||
743 744 745 746 747 748 749 |
lappend res [file exists [file join dir2 simpledir]] \
[file exists [file join dir2 simpledir simplefile]]
} -cleanup {
testsimplefilesystem 0
file delete -force simpledir
file delete -force dir2
cd $dir
| | | 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
lappend res [file exists [file join dir2 simpledir]] \
[file exists [file join dir2 simpledir simplefile]]
} -cleanup {
testsimplefilesystem 0
file delete -force simpledir
file delete -force dir2
cd $dir
} -result {0 {} 1 {error copying "simplefs:/simpledir" to "dir2/simpledir": file exists} 0 {} 1 1}
test filesystem-7.7 {cross-filesystem dir copy with -force} -setup {
set dir [pwd]
cd [tcltest::temporaryDirectory]
file delete -force simpledir
file mkdir simpledir
file mkdir dir2
set fout [open [file join simpledir simplefile] w]
|
| ︙ | ︙ | |||
773 774 775 776 777 778 779 |
lappend res [file exists [file join dir2 simpledir]] \
[file exists [file join dir2 simpledir simplefile]]
} -cleanup {
testsimplefilesystem 0
file delete -force simpledir
file delete -force dir2
cd $dir
| | | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 |
lappend res [file exists [file join dir2 simpledir]] \
[file exists [file join dir2 simpledir simplefile]]
} -cleanup {
testsimplefilesystem 0
file delete -force simpledir
file delete -force dir2
cd $dir
} -result {0 {} 1 {error copying "simplefs:/simpledir" to "dir2/simpledir": file exists} 0 {} 1 1}
removeFile gorp.file
test filesystem-7.8 {vfs cd} -setup {
set dir [pwd]
cd [tcltest::temporaryDirectory]
file delete -force simpledir
file mkdir simpledir
testsimplefilesystem 1
|
| ︙ | ︙ |
Changes to tests/for.test.
| ︙ | ︙ | |||
333 334 335 336 337 338 339 |
46 {changes in the C APIs for custom channel drivers. Scripts written for earlier releases} \
47 {should work on these new releases as well.} \
48 {} \
49 {Obtaining The Releases} \
50 {} \
51 {Binary Releases} \
52 {} \
| | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
46 {changes in the C APIs for custom channel drivers. Scripts written for earlier releases} \
47 {should work on these new releases as well.} \
48 {} \
49 {Obtaining The Releases} \
50 {} \
51 {Binary Releases} \
52 {} \
53 {Precompiled releases are available for the following platforms: } \
54 {} \
55 { Windows 3.1, Windows 95, and Windows NT: Fetch} \
56 { ftp://ftp.sunlabs.com/pub/tcl/win42b1.exe, then execute it. The file is a} \
57 { self-extracting executable. It will install the Tcl and Tk libraries, the wish and} \
58 { tclsh programs, and documentation.} \
59 { Macintosh (both 68K and PowerPC): Fetch} \
60 { ftp://ftp.sunlabs.com/pub/tcl/mactk4.2b1.sea.hqx. The file is in binhex format,} \
|
| ︙ | ︙ | |||
552 553 554 555 556 557 558 | ts written for earlier releases should work on these new releases as well. Obtaining The Releases Binary Releases | | | 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
ts written for earlier releases
should work on these new releases as well.
Obtaining The Releases
Binary Releases
Precompiled releases are available for the following
platforms:
Windows 3.1, Windows 95, and Windows NT: Fetch
ftp://ftp.sunlabs.com/pub/tcl/win42b1.exe, then
execute it. The file is a
self-extracting executable. It will install the
Tcl and Tk libraries, the wish and
|
| ︙ | ︙ |
Changes to tests/http.test.
| ︙ | ︙ | |||
625 626 627 628 629 630 631 |
if {$token eq ""} {
error "bogus return from http::geturl"
}
http::wait $token
lindex [http::error $token] 0
} -cleanup {
catch {http::cleanup $token}
| | | 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
if {$token eq ""} {
error "bogus return from http::geturl"
}
http::wait $token
lindex [http::error $token] 0
} -cleanup {
catch {http::cleanup $token}
} -result {connect failed: connection refused}
# Bogus host
test http-4.15.$ThreadLevel {http::Event} -body {
# This test may fail if you use a proxy server. That is to be
# expected and is not a problem with Tcl.
# With http::config -threadlevel 1 or 2, the script enters the event loop
# during the DNS lookup, and has the opportunity to time out.
|
| ︙ | ︙ |
Changes to tests/indexObj.test.
|
| | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# This file is a Tcl script to test out the procedures in file
# tkIndexObj.c, which implement indexed table lookups. The tests here are
# organized in the standard fashion for Tcl tests.
#
# Copyright © 1997 Sun Microsystems, Inc.
# Copyright © 1998-1999 Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
if {"::tcltest" ni [namespace children]} {
package require tcltest 2.5
namespace import -force ::tcltest::*
}
::tcltest::loadTestedCommands
catch [list package require -exact tcl::test [info patchlevel]]
testConstraint testindexobj [llength [info commands testindexobj]]
testConstraint testgetintforindex [llength [info commands testgetintforindex]]
testConstraint testparseargs [llength [info commands testparseargs]]
testConstraint has64BitLengths [expr {$tcl_platform(pointerSize) == 8}]
test indexObj-1.1 {exact match} testindexobj {
testindexobj 1 1 xyz abc def xyz alm
} {2}
test indexObj-1.2 {exact match} testindexobj {
testindexobj 1 1 abc abc def xyz alm
} {0}
|
| ︙ | ︙ | |||
180 181 182 183 184 185 186 |
testgetintforindex -2 0
} -1
test indexObj-8.4 {Tcl_GetIntForIndex INT_MAX} testgetintforindex {
testgetintforindex 2147483647 0
} 2147483647
test indexObj-8.5 {Tcl_GetIntForIndex INT_MAX+1} testgetintforindex {
testgetintforindex 2147483648 0
| | | | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
testgetintforindex -2 0
} -1
test indexObj-8.4 {Tcl_GetIntForIndex INT_MAX} testgetintforindex {
testgetintforindex 2147483647 0
} 2147483647
test indexObj-8.5 {Tcl_GetIntForIndex INT_MAX+1} testgetintforindex {
testgetintforindex 2147483648 0
} [expr {[testConstraint has64BitLengths] ? 2147483648 : 2147483647}]
test indexObj-8.6 {Tcl_GetIntForIndex end-1} testgetintforindex {
testgetintforindex end-1 2147483646
} 2147483645
test indexObj-8.7 {Tcl_GetIntForIndex end-1} testgetintforindex {
testgetintforindex end-1 2147483647
} 2147483646
test indexObj-8.8 {Tcl_GetIntForIndex end} testgetintforindex {
testgetintforindex end 2147483646
} 2147483646
test indexObj-8.9 {Tcl_GetIntForIndex end} testgetintforindex {
testgetintforindex end 2147483647
} 2147483647
test indexObj-8.10 {Tcl_GetIntForIndex end-1} testgetintforindex {
testgetintforindex end-1 -1
} -1
test indexObj-8.11 {Tcl_GetIntForIndex end-1} testgetintforindex {
testgetintforindex end-1 -2
} -1
test indexObj-8.12 {Tcl_GetIntForIndex end} testgetintforindex {
testgetintforindex end -1
} -1
test indexObj-8.13 {Tcl_GetIntForIndex end} testgetintforindex {
testgetintforindex end -2
} -1
test indexObj-8.14 {Tcl_GetIntForIndex end+1} testgetintforindex {
testgetintforindex end+1 -1
} 0
test indexObj-8.15 {Tcl_GetIntForIndex end+1} testgetintforindex {
testgetintforindex end+1 -2
} -1
|
| ︙ | ︙ |
Changes to tests/internals.tcl.
| ︙ | ︙ | |||
32 33 34 35 36 37 38 |
set pipe [open |[list [interpreter]] r+]
set ppid [pid $pipe]
# create prlimit args:
set args {}
# with limited address space:
if {[info exists in(-addmem)] || [info exists in(-maxmem)]} {
if {[info exists in(-addmem)]} {
| | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
set pipe [open |[list [interpreter]] r+]
set ppid [pid $pipe]
# create prlimit args:
set args {}
# with limited address space:
if {[info exists in(-addmem)] || [info exists in(-maxmem)]} {
if {[info exists in(-addmem)]} {
# as difference to normal usage, so try to retrieve current memory usage:
if {[catch {
# using ps (vsz is in KB):
incr in(-addmem) [expr {[lindex [exec ps -hq $ppid -o vsz] end] * 1024}]
}]} {
# ps failed, use default size 20MB:
incr in(-addmem) 20000000
# + size of locale-archive (may be up to 100MB):
|
| ︙ | ︙ |
Changes to tests/interp.test.
| ︙ | ︙ | |||
2415 2416 2417 2418 2419 2420 2421 |
list $result $msg
} {1 {expected integer but got "bar"}}
test interp-29.1.5 {interp recursionlimit argument checking} -body {
interp create moo
set result [catch {interp recursionlimit moo 0} msg]
interp delete moo
list $result $msg
| | | | 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 |
list $result $msg
} {1 {expected integer but got "bar"}}
test interp-29.1.5 {interp recursionlimit argument checking} -body {
interp create moo
set result [catch {interp recursionlimit moo 0} msg]
interp delete moo
list $result $msg
} -match glob -result {1 {recursion limit must be > 0}}
test interp-29.1.6 {interp recursionlimit argument checking} -body {
interp create moo
set result [catch {interp recursionlimit moo -1} msg]
interp delete moo
list $result $msg
} -match glob -result {1 {recursion limit must be > 0}}
test interp-29.1.7 {interp recursionlimit argument checking} {
interp create moo
set result [catch {interp recursionlimit moo [expr {wide(1)<<64}]} msg]
interp delete moo
list $result [string range $msg 0 35]
} {1 {integer value too large to represent}}
test interp-29.1.8 {child recursionlimit argument checking} {
|
| ︙ | ︙ | |||
2445 2446 2447 2448 2449 2450 2451 |
list $result $msg
} {1 {expected integer but got "foo"}}
test interp-29.1.10 {child recursionlimit argument checking} -body {
interp create moo
set result [catch {moo recursionlimit 0} msg]
interp delete moo
list $result $msg
| | | | 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 |
list $result $msg
} {1 {expected integer but got "foo"}}
test interp-29.1.10 {child recursionlimit argument checking} -body {
interp create moo
set result [catch {moo recursionlimit 0} msg]
interp delete moo
list $result $msg
} -match glob -result {1 {recursion limit must be > 0}}
test interp-29.1.11 {child recursionlimit argument checking} -body {
interp create moo
set result [catch {moo recursionlimit -1} msg]
interp delete moo
list $result $msg
} -match glob -result {1 {recursion limit must be > 0}}
test interp-29.1.12 {child recursionlimit argument checking} {
interp create moo
set result [catch {moo recursionlimit [expr {wide(1)<<64}]} msg]
interp delete moo
list $result [string range $msg 0 35]
} {1 {integer value too large to represent}}
test interp-29.2.1 {query recursion limit} {
|
| ︙ | ︙ |
Changes to tests/io.test.
| ︙ | ︙ | |||
1616 1617 1618 1619 1620 1621 1622 |
} 160
test io-12.9 {ReadChars: multibyte chars split} -body {
set f [open $path(test1) w]
fconfigure $f -translation binary
puts -nonewline $f [string repeat a 9]\xC2
close $f
set f [open $path(test1)]
| | | 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 |
} 160
test io-12.9 {ReadChars: multibyte chars split} -body {
set f [open $path(test1) w]
fconfigure $f -translation binary
puts -nonewline $f [string repeat a 9]\xC2
close $f
set f [open $path(test1)]
fconfigure $f -encoding utf-8 -profile tcl8 -buffersize 10
set in [read $f]
close $f
scan [string index $in end] %c
} -cleanup {
catch {close $f}
} -result 194
test io-12.10 {ReadChars: multibyte chars split} -body {
|
| ︙ | ︙ | |||
3894 3895 3896 3897 3898 3899 3900 |
fconfigure $f -translation binary
set x [fconfigure $f -translation]
close $f
set x
} lf
#
# Test io-9.14 has been removed because "auto" output translation mode is
| | | 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 |
fconfigure $f -translation binary
set x [fconfigure $f -translation]
close $f
set x
} lf
#
# Test io-9.14 has been removed because "auto" output translation mode is
# not supported.
#
test io-31.14 {Tcl_Write mixed, Tcl_Gets auto} {
file delete $path(test1)
set f [open $path(test1) w]
fconfigure $f -translation lf
puts $f hello\nthere\rand\r\nhere
close $f
|
| ︙ | ︙ | |||
5851 5852 5853 5854 5855 5856 5857 |
fconfigure $f1 -eofchar D
lappend l [fconfigure $f1 -eofchar]
lappend l [list [catch {fconfigure $f1 -eofchar {1 2 3}} msg] $msg]
close $f1
set l
} -result {O D {1 {bad value for -eofchar: must be non-NUL ASCII character}}}
test io-39.23 {Tcl_GetChannelOption, server socket is not readable or
| | | 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 |
fconfigure $f1 -eofchar D
lappend l [fconfigure $f1 -eofchar]
lappend l [list [catch {fconfigure $f1 -eofchar {1 2 3}} msg] $msg]
close $f1
set l
} -result {O D {1 {bad value for -eofchar: must be non-NUL ASCII character}}}
test io-39.23 {Tcl_GetChannelOption, server socket is not readable or
writable, it should still have valid -eofchar and -translation options } {
set l [list]
set sock [socket -server [namespace code accept] -myaddr 127.0.0.1 0]
lappend l [fconfigure $sock -eofchar] [fconfigure $sock -translation]
close $sock
set l
} {{} auto}
test io-39.24 {Tcl_SetChannelOption, server socket is not readable or
|
| ︙ | ︙ | |||
7496 7497 7498 7499 7500 7501 7502 |
close $in
close $out
list [file size $path(kyrillic.txt)] \
[file size $path(utf8-fcopy.txt)] \
[file size $path(utf8-rp.txt)]
} {3 5 5}
| | < < < | > | | < < < < | < | > > > | > > | | < | > > | 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 |
close $in
close $out
list [file size $path(kyrillic.txt)] \
[file size $path(utf8-fcopy.txt)] \
[file size $path(utf8-rp.txt)]
} {3 5 5}
test io-52.10 {TclCopyChannel & encodings} -constraints fcopy -body {
set in [open $path(kyrillic.txt) r]
set out [open $path(utf8-fcopy.txt) w]
fconfigure $in -encoding koi8-r -translation lf
# -translation binary is also -encoding binary
fconfigure $out -translation binary
fcopy $in $out
close $in
close $out
file size $path(utf8-fcopy.txt)
} -returnCodes 1 -match glob -result {error writing "*":\
invalid or incomplete multibyte or wide character}
test io-52.11 {TclCopyChannel & encodings} -setup {
set out [open $path(utf8-fcopy.txt) w]
fconfigure $out -encoding utf-8 -translation lf -profile strict
puts $out АА
close $out
} -constraints {fcopy} -body {
set in [open $path(utf8-fcopy.txt) r]
set out [open $path(kyrillic.txt) w]
# -translation binary is also -encoding binary
fconfigure $in -translation binary
fconfigure $out -encoding koi8-r -translation lf -profile strict
catch {fcopy $in $out} cres copts
return $cres
} -cleanup {
if {$in in [chan names]} {
close $in
}
if {$out in [chan names]} {
close $out
}
catch {unset cres}
} -match glob -result {error writing "*": invalid or incomplete\
multibyte or wide character}
test io-52.12 {coverage of -translation auto} {
file delete $path(test1) $path(test2)
set out [open $path(test1) wb]
chan configure $out -translation lf
puts -nonewline $out abcdefg\rhijklmn\nopqrstu\r\nvwxyz
close $out
|
| ︙ | ︙ | |||
7699 7700 7701 7702 7703 7704 7705 |
fconfigure $in -encoding ascii -profile strict
fconfigure $out -encoding koi8-r -translation lf
fcopy $in $out
} -cleanup {
close $in
close $out
| | | | 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 |
fconfigure $in -encoding ascii -profile strict
fconfigure $out -encoding koi8-r -translation lf
fcopy $in $out
} -cleanup {
close $in
close $out
} -returnCodes 1 -match glob -result {error reading "file*": invalid or incomplete multibyte or wide character}
test io-52.21 {TclCopyChannel & encodings} -setup {
set out [open $path(utf8-fcopy.txt) w]
fconfigure $out -encoding utf-8 -translation lf
puts $out "Á"
close $out
} -constraints {fcopy} -body {
# binary to encoding => the input has to be
# in utf-8 to make sense to the encoder
set in [open $path(utf8-fcopy.txt) r]
set out [open $path(kyrillic.txt) w]
# Using "-encoding ascii" means writing the "Á" gives an error
fconfigure $in -encoding utf-8
fconfigure $out -encoding ascii -translation lf -profile strict
fcopy $in $out
} -cleanup {
close $in
close $out
} -returnCodes 1 -match glob -result {error writing "file*": invalid or incomplete multibyte or wide character}
test io-52.22 {TclCopyChannel & encodings} -setup {
set out [open $path(utf8-fcopy.txt) w]
fconfigure $out -encoding utf-8 -translation lf
puts $out "Á"
close $out
} -constraints {fcopy} -body {
# binary to encoding => the input has to be
|
| ︙ | ︙ | |||
7747 7748 7749 7750 7751 7752 7753 |
fcopy $in $out -command ::xxx
vwait ::s0
set ::s0
} -cleanup {
close $in
close $out
unset ::s0
| | | 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 |
fcopy $in $out -command ::xxx
vwait ::s0
set ::s0
} -cleanup {
close $in
close $out
unset ::s0
} -match glob -result {0 {error reading "file*": invalid or incomplete multibyte or wide character}}
test io-52.23 {TclCopyChannel & encodings} -setup {
set out [open $path(utf8-fcopy.txt) w]
fconfigure $out -encoding utf-8 -translation lf
puts $out "Á"
close $out
} -constraints {fcopy} -body {
# binary to encoding => the input has to be
|
| ︙ | ︙ | |||
7774 7775 7776 7777 7778 7779 7780 |
fcopy $in $out -command ::xxx
vwait ::s0
set ::s0
} -cleanup {
close $in
close $out
unset ::s0
| | > > > > > > > > > > > > > > > > > > > > > > > | 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 |
fcopy $in $out -command ::xxx
vwait ::s0
set ::s0
} -cleanup {
close $in
close $out
unset ::s0
} -match glob -result {0 {error writing "file*": invalid or incomplete multibyte or wide character}}
test io-52.24 {fcopy -size should always be characters} -setup {
set out [open utf8-fcopy-52.24.txt w]
fconfigure $out -encoding utf-8 -translation lf
puts $out "Á"
close $out
} -constraints {fcopy} -body {
set in [open utf8-fcopy-52.24.txt r]
set out [open utf8-fcopy-52.24.out.txt w+]
fconfigure $in -encoding utf-8 -profile tcl8
fconfigure $out -encoding utf-8 -profile tcl8
fcopy $in $out -size 1
seek $out 0
# a result of \xc3 means that only the first byte of the utf-8 encoding of
# Á made it into to the output file.
read $out
} -cleanup {
close $in
close $out
catch {file delete utf8-fcopy-52.24.txt}
catch {file delete utf8-fcopy-52.24.out.txt}
} -result Á
test io-53.1 {CopyData} {fcopy} {
file delete $path(test1)
set f1 [open $thisScript]
set f2 [open $path(test1) w]
fconfigure $f1 -translation lf -blocking 0
|
| ︙ | ︙ | |||
8272 8273 8274 8275 8276 8277 8278 |
set done
} -cleanup {
close $outChan
close $inChan
removeFile out
removeFile in
} -result {40 bytes copied}
| | > > > > > > > > > > > > > > > > > > > > > > > > > > | 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 |
set done
} -cleanup {
close $outChan
close $inChan
removeFile out
removeFile in
} -result {40 bytes copied}
test io-53.12.0 {CopyData: foreground short reads, aka bug 3096275} {stdio unix fcopy} {
file delete $path(pipe)
set f1 [open $path(pipe) w]
puts -nonewline $f1 {
fconfigure stdin -translation binary -blocking 0
fconfigure stdout -buffering none -translation binary
fcopy stdin stdout
}
close $f1
set f1 [open "|[list [interpreter] $path(pipe)]" r+]
fconfigure $f1 -translation binary -buffering none
puts -nonewline $f1 A
after 2000 {set ::done timeout}
fileevent $f1 readable {set ::done ok}
vwait ::done
set ch [read $f1 1]
close $f1
list $::done $ch
} {ok A}
test io-53.12.1 {
Issue 9ca87e6286262a62.
CopyData: foreground short reads via ReadChars().
Related to report 3096275 for ReadBytes().
Prior to the fix this test waited forever for read() to return.
} {stdio unix fcopy} {
file delete $path(output)
set f1 [open $path(output) w]
puts -nonewline $f1 {
chan configure stdin -encoding iso8859-1 -translation lf -buffering none
fcopy stdin stdout
}
close $f1
set f1 [open "|[list [info nameofexecutable] $path(output)]" r+]
try {
chan configure $f1 -encoding utf-8 -buffering none
puts -nonewline $f1 A
set ch [read $f1 1]
} finally {
if {$f1 in [chan names]} {
close $f1
}
}
lindex $ch
} A
test io-53.13 {TclCopyChannel: read error reporting} -setup {
proc driver {cmd args} {
variable buffer
variable index
set chan [lindex $args 0]
switch -- $cmd {
initialize {
|
| ︙ | ︙ | |||
8320 8321 8322 8323 8324 8325 8326 |
set out [open $outFile wb]
chan copy $in $out
} -cleanup {
catch {close $in}
catch {close $out}
removeFile out
rename driver {}
| | | 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 |
set out [open $outFile wb]
chan copy $in $out
} -cleanup {
catch {close $in}
catch {close $out}
removeFile out
rename driver {}
} -result {error reading "rc*": *} -returnCodes error -match glob
test io-53.14 {TclCopyChannel: write error reporting} -setup {
proc driver {cmd args} {
variable buffer
variable index
set chan [lindex $args 0]
switch -- $cmd {
initialize {
|
| ︙ | ︙ | |||
8757 8758 8759 8760 8761 8762 8763 |
variable x ""
set result ""
vwait [namespace which -variable x]
# cut of the remainder of the error stack, especially the filename
set result [lreplace $result 3 3 [lindex [split [lindex $result 3] \n] 0]]
list $x $result
| | | 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 |
variable x ""
set result ""
vwait [namespace which -variable x]
# cut of the remainder of the error stack, especially the filename
set result [lreplace $result 3 3 [lindex [split [lindex $result 3] \n] 0]]
list $x $result
} {1 {gets ABC catch {error writing "stdout": invalid or incomplete multibyte or wide character}}}
test io-61.1 {Reset eof state after changing the eof char} -setup {
set datafile [makeFile {} eofchar]
set f [open $datafile w]
fconfigure $f -translation binary
puts -nonewline $f [string repeat "Ho hum\n" 11]
puts $f =
|
| ︙ | ︙ | |||
8787 8788 8789 8790 8791 8792 8793 |
close $f
set res
} -cleanup {
removeFile eofchar
} -result {77 = 23431}
| | | 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 |
close $f
set res
} -cleanup {
removeFile eofchar
} -result {77 = 23431}
# Test the cutting and splicing of channels, this is incidentally the
# attach/detach facility of package Thread, but __without any
# safeguards__. It can also be used to emulate transfer of channels
# between threads, and is used for that here.
test io-70.0 {Cutting & Splicing channels} {testchannel} {
set f [makeFile {... dummy ...} cutsplice]
set c [open $f r]
|
| ︙ | ︙ | |||
9119 9120 9121 9122 9123 9124 9125 |
read [teststringobj get 2]
} -cleanup {
interp delete child
testobj freeallvars
removeFile io-74.1
} -returnCodes error -match glob -result {can not find channel named "*"}
| | | 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 |
read [teststringobj get 2]
} -cleanup {
interp delete child
testobj freeallvars
removeFile io-74.1
} -returnCodes error -match glob -result {can not find channel named "*"}
test io-75.1 {multibyte encoding error read results in raw bytes (-profile tcl8)} -setup {
set fn [makeFile {} io-75.1]
set f [open $fn w+]
fconfigure $f -encoding binary
# In UTF-8, a byte 0xCx starts a multibyte sequence and must be followed
# by a byte > 0x7F. This is violated to get an invalid sequence.
puts -nonewline $f A\xC0\x40
flush $f
|
| ︙ | ︙ | |||
9210 9211 9212 9213 9214 9215 9216 |
binary scan $d H* hd
set hd
} -cleanup {
close $f
removeFile io-75.5
} -result 4181
| | | | > | > > | > | > | > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | < < | > > > > > > > > | | > > > | > | > | > > > > | > > > > > | | > > | > > > > | | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 |
binary scan $d H* hd
set hd
} -cleanup {
close $f
removeFile io-75.5
} -result 4181
test io-75.6 {invalid utf-8 encoding, gets is not ignored (-profile strict)} -setup {
set fn [makeFile {} io-75.6]
set f [open $fn w+]
fconfigure $f -encoding binary
# \x81 is an incomplete byte sequence in utf-8
puts -nonewline $f A\x81
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar {} \
-translation lf -profile strict
} -body {
gets $f
} -cleanup {
close $f
removeFile io-75.6
} -match glob -returnCodes 1 -result {error reading "file*":\
invalid or incomplete multibyte or wide character}
test io-75.7 {
invalid utf-8 encoding gets is not ignored (-profile strict)
} -setup {
set fn [makeFile {} io-75.7]
set f [open $fn w+]
fconfigure $f -encoding binary
# \x81 is invalid in utf-8
puts -nonewline $f A\x81
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar {} -translation lf \
-profile strict
} -body {
read $f
} -cleanup {
close $f
removeFile io-75.7
} -match glob -returnCodes 1 -result {error reading "file*":\
invalid or incomplete multibyte or wide character}
test io-75.8 {invalid utf-8 encoding eof handling (-profile strict)} -setup {
set fn [makeFile {} io-75.8]
set f [open $fn w+]
fconfigure $f -encoding binary
# \x81 is invalid in utf-8, but since \x1A comes first, -eofchar takes
# precedence.
puts -nonewline $f A\x1A\x81
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A \
-translation lf -profile strict
} -body {
set d [read $f]
binary scan $d H* hd
lappend hd [eof $f]
lappend hd [read $f]
close $f
set hd
} -cleanup {
removeFile io-75.8
} -result {41 1 {}}
test io-75.8.eoflater {invalid utf-8 encoding eof handling (-profile strict)} -setup {
set res {}
set fn [makeFile {} io-75.8]
set f [open $fn w+]
# This also configures the channel encoding profile as strict.
fconfigure $f -encoding binary
# \x81 is invalid in utf-8. -eofchar is not detected, because it comes later.
puts -nonewline $f A\x81\x81\x1A
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A \
-translation lf -profile strict
} -body {
set status [catch {read $f} cres copts]
lappend res $status
lappend res [eof $f]
chan configure $f -encoding iso8859-1
lappend res [read $f 1]
chan configure $f -encoding utf-8
catch {read $f 1} cres
lappend res $cres
close $f
set res
} -cleanup {
removeFile io-75.8
} -match glob -result "1 0 \x81 {error reading \"*\":\
invalid or incomplete multibyte or wide character}"
test io-strict-multibyte-eof {
incomplete utf-8 sequence immediately prior to eof character
See issue 25cdcb7e8fb381fb
} -setup {
set res {}
set chan [file tempfile];
fconfigure $chan -encoding binary
puts -nonewline $chan \x81\x1A
flush $chan
seek $chan 0
chan configure $chan -encoding utf-8 -profile strict
} -body {
set status [catch {read $chan 1} cres]
lappend res $status $cres
} -cleanup {
close $chan
unset res
} -match glob -result {1 {error reading "*":\
invalid or incomplete multibyte or wide character}}
test io-75.9 {unrepresentable character write passes and is replaced by ?} -setup {
set fn [makeFile {} io-75.9]
set f [open $fn w+]
fconfigure $f -encoding iso8859-1 -profile strict
} -body {
catch {puts -nonewline $f "A\u2022"} msg
flush $f
seek $f 0
list [read $f] $msg
} -cleanup {
close $f
removeFile io-75.9
} -match glob -result [list {A} {error writing "*":\
invalid or incomplete multibyte or wide character}]
test io-75.10 {
incomplete multibyte encoding read is not ignored because "binary" sets
profile to strict
} -setup {
set res {}
set fn [makeFile {} io-75.10]
set f [open $fn w+]
fconfigure $f -encoding binary
puts -nonewline $f A\xC0
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none
} -body {
catch {read $f} errmsg
lappend res $errmsg
seek $f 0
chan configure $f -profile tcl8
set d [read $f]
binary scan $d H* hd
lappend res $hd
return $res
} -cleanup {
close $f
removeFile io-75.10
unset result
} -match glob -result {{error reading "file*":\
invalid or incomplete multibyte or wide character} 41c0}
# The current result returns the orphan byte as byte.
# This may be expected due to special utf-8 handling.
# As utf-8 has a special treatment in multi-byte decoding, also test another
# one.
test io-75.11 {shiftjis encoding error read results in raw bytes} -setup {
set fn [makeFile {} io-75.11]
set f [open $fn w+]
fconfigure $f -encoding binary
# In shiftjis, \x81 starts a two-byte sequence.
# But 2nd byte \xFF is not allowed
puts -nonewline $f A\x81\xFFA
flush $f
seek $f 0
fconfigure $f -encoding shiftjis -blocking 0 -eofchar {} -translation lf \
-profile strict
} -body {
set d [read $f]
binary scan $d H* hd
lappend hd [catch {set d [read $f]} msg]
lappend hd $msg
} -cleanup {
close $f
removeFile io-75.11
} -match glob -result {41 1 {error reading "file*":\
invalid or incomplete multibyte or wide character}}
test io-75.12 {
invalid utf-8 encoding read is not ignored because setting the encoding to
"binary" also set the profile to strict
} -setup {
set res {}
set fn [makeFile {} io-75.12]
set f [open $fn w+]
fconfigure $f -encoding binary
puts -nonewline $f A\x81
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar {} -translation lf
} -body {
catch {read $f} errmsg
lappend res $errmsg
chan configure $f -profile tcl8
seek $f 0
set d [read $f]
binary scan $d H* hd
lappend res $hd
return $res
} -cleanup {
close $f
removeFile io-75.12
unset res
} -match glob -result {{error reading "file*":\
invalid or incomplete multibyte or wide character} 4181}
test io-75.13 {
In nonblocking mode when there is an encoding error the data that has been
successfully read so far is returned first and then the error is returned
on the next call to [read].
} -setup {
set fn [makeFile {} io-75.13]
set f [open $fn w+]
fconfigure $f -encoding binary
# \x81 is invalid in utf-8
puts -nonewline $f A\x81
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -blocking 0 -eofchar {} -translation lf \
-profile strict
} -body {
set d [read $f]
binary scan $d H* hd
lappend hd [catch {read $f} msg]
lappend hd $msg
} -cleanup {
close $f
removeFile io-75.13
} -match glob -result {41 1 {error reading "file*":\
invalid or incomplete multibyte or wide character}}
test io-75.14 {
[gets] succesfully returns lines prior to error
invalid utf-8 encoding [gets] continues in non-strict mode after error
} -setup {
set chan [file tempfile]
fconfigure $chan -encoding binary
# \xc0\n is an invalid utf-8 sequence
puts -nonewline $chan a\nb\nc\xc0\nd\n
flush $chan
seek $chan 0
fconfigure $chan -encoding utf-8 -buffering none -eofchar {} \
-translation auto -profile strict
} -body {
lappend res [gets $chan]
lappend res [gets $chan]
set status [catch {gets $chan} cres copts]
lappend res $status $cres
chan configure $chan -profile tcl8
lappend res [gets $chan]
lappend res [gets $chan]
close $chan
return $res
} -match glob -result {a b 1 {error reading "*":\
invalid or incomplete multibyte or wide character} cÀ d}
test io-75.15 {
invalid utf-8 encoding strict
gets does not hang
gets succeeds for the first two lines
} -setup {
set res {}
set chan [file tempfile]
fconfigure $chan -encoding binary
# \xc0\x40 is an invalid utf-8 sequence
puts $chan hello\nAB\nCD\xc0\x40EF\nGHI
seek $chan 0
} -body {
#Now try to read it with [gets]
fconfigure $chan -encoding utf-8 -profile strict
lappend res [gets $chan]
lappend res [gets $chan]
set status [catch {gets $chan} cres copts]
lappend res $status $cres
set status [catch {gets $chan} cres copts]
lappend res $status $cres
chan configure $chan -translation binary
set data [read $chan 4]
foreach char [split $data {}] {
scan $char %c ord
lappend res [format %x $ord]
}
fconfigure $chan -encoding utf-8 -profile strict -translation auto
lappend res [gets $chan]
lappend res [gets $chan]
return $res
} -cleanup {
close $chan
} -match glob -result {hello AB 1 {error reading "*": invalid or incomplete multibyte or wide character}\
1 {error reading "*": invalid or incomplete multibyte or wide character} 43 44 c0 40 EF GHI}
# ### ### ### ######### ######### #########
test io-76.0 {channel modes} -setup {
set datafile [makeFile {some characters} dummy]
|
| ︙ | ︙ | |||
9408 9409 9410 9411 9412 9413 9414 |
set datafile [makeFile {some characters} dummy]
set f [open $datafile r]
} -constraints testchannel -body {
testchannel mremove-rd $f
} -returnCodes error -cleanup {
close $f
removeFile dummy
| | > | > | 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 |
set datafile [makeFile {some characters} dummy]
set f [open $datafile r]
} -constraints testchannel -body {
testchannel mremove-rd $f
} -returnCodes error -cleanup {
close $f
removeFile dummy
} -match glob -result {Tcl_RemoveChannelMode error:\
Bad mode, would make channel inacessible. Channel: "*"}
test io-76.5 {channel mode dropping} -setup {
set datafile [makeFile {some characters} dummy]
set f [open $datafile w]
} -constraints testchannel -body {
testchannel mremove-rd $f
list [testchannel mode $f] [testchannel maxmode $f]
} -cleanup {
close $f
removeFile dummy
} -result {{{} write} {{} write}}
test io-76.6 {channel mode dropping} -setup {
set datafile [makeFile {some characters} dummy]
set f [open $datafile w]
} -constraints testchannel -body {
testchannel mremove-wr $f
} -returnCodes error -cleanup {
close $f
removeFile dummy
} -match glob -result {Tcl_RemoveChannelMode error:\
Bad mode, would make channel inacessible. Channel: "*"}
test io-76.7 {channel mode dropping} -setup {
set datafile [makeFile {some characters} dummy]
set f [open $datafile r+]
} -constraints testchannel -body {
testchannel mremove-rd $f
list [testchannel mode $f] [testchannel maxmode $f]
|
| ︙ | ︙ | |||
9462 9463 9464 9465 9466 9467 9468 |
set f [open $datafile r+]
} -constraints testchannel -body {
testchannel mremove-wr $f
testchannel mremove-rd $f
} -returnCodes error -cleanup {
close $f
removeFile dummy
| | > | > | 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 |
set f [open $datafile r+]
} -constraints testchannel -body {
testchannel mremove-wr $f
testchannel mremove-rd $f
} -returnCodes error -cleanup {
close $f
removeFile dummy
} -match glob -result {Tcl_RemoveChannelMode error:\
Bad mode, would make channel inacessible. Channel: "*"}
test io-76.10 {channel mode dropping} -setup {
set datafile [makeFile {some characters} dummy]
set f [open $datafile r+]
} -constraints testchannel -body {
testchannel mremove-rd $f
testchannel mremove-wr $f
} -returnCodes error -cleanup {
close $f
removeFile dummy
} -match glob -result {Tcl_RemoveChannelMode error:\
Bad mode, would make channel inacessible. Channel: "*"}
# cleanup
foreach file [list fooBar longfile script script2 output test1 pipe my_script \
test2 test3 cat stdout kyrillic.txt utf8-fcopy.txt utf8-rp.txt] {
removeFile $file
}
cleanupTests
}
namespace delete ::tcl::test::io
return
|
Changes to tests/ioCmd.test.
| ︙ | ︙ | |||
262 263 264 265 266 267 268 |
} -body {
set f1 [open $path(test1) w]
fconfigure $f1 -translation binary -buffering none -buffersize 4040 \
-eofchar {} -encoding binary -profile tcl8
fconfigure $f1
} -cleanup {
catch {close $f1}
| | | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
} -body {
set f1 [open $path(test1) w]
fconfigure $f1 -translation binary -buffering none -buffersize 4040 \
-eofchar {} -encoding binary -profile tcl8
fconfigure $f1
} -cleanup {
catch {close $f1}
} -result {-blocking 1 -buffering none -buffersize 4040 -encoding iso8859-1 -eofchar {} -profile tcl8 -translation lf}
test iocmd-8.10 {fconfigure command} -returnCodes error -body {
fconfigure a b
} -result {can not find channel named "a"}
set path(fconfigure.dummy) [makeFile {} fconfigure.dummy]
test iocmd-8.11 {fconfigure command} -body {
set chan [open $path(fconfigure.dummy) r]
fconfigure $chan -froboz blarfo
|
| ︙ | ︙ | |||
492 493 494 495 496 497 498 499 500 501 502 |
set f [open $path(test1) r]
fconfigure $f -translation binary
set result [string length [read $f]]
close $f
set result
} 5
test iocmd-12.11 {POSIX open access modes: BINARY} -body {
set f [open $path(test1) {WRONLY BINARY TRUNC}]
puts $f Ɉ ;# throws an exception
} -cleanup {
close $f
| > | | 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
set f [open $path(test1) r]
fconfigure $f -translation binary
set result [string length [read $f]]
close $f
set result
} 5
test iocmd-12.11 {POSIX open access modes: BINARY} -body {
after 100
set f [open $path(test1) {WRONLY BINARY TRUNC}]
puts $f Ɉ ;# throws an exception
} -cleanup {
close $f
} -returnCodes 1 -match glob -result {error writing "*": invalid or incomplete multibyte or wide character}
test iocmd-12.12 {POSIX open access modes: BINARY} {
set f [open $path(test1) {WRONLY BINARY TRUNC}]
puts $f H
close $f
set f [open $path(test1) r]
fconfigure $f -translation binary
set result [read -nonewline $f]
|
| ︙ | ︙ | |||
684 685 686 687 688 689 690 |
set msg
} {wrong # args: should be "chan subcommand ?arg ...?"}
test iocmd-20.1 {chan, unknown method} -body {
chan foo
} -returnCodes error -match glob -result {unknown or ambiguous subcommand "foo": must be *}
# --- --- --- --------- --------- ---------
| | | | | > | < | 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
set msg
} {wrong # args: should be "chan subcommand ?arg ...?"}
test iocmd-20.1 {chan, unknown method} -body {
chan foo
} -returnCodes error -match glob -result {unknown or ambiguous subcommand "foo": must be *}
# --- --- --- --------- --------- ---------
# chan create, and method "initialize"
test iocmd-21.0 {chan create, wrong#args, not enough} {
catch {chan create} msg
set msg
} {wrong # args: should be "chan create mode cmdprefix"}
test iocmd-21.1 {chan create, wrong#args, too many} {
catch {chan create a b c} msg
set msg
} {wrong # args: should be "chan create mode cmdprefix"}
test iocmd-21.2 {chan create, r/w mode empty} {
proc foo {cmd args} { return {initialize finalize watch} }
set chan [chan create {} foo]
close $chan
rename foo {}
} {}
test iocmd-21.3 {chan create, invalid r/w mode, bad string} {
proc foo {} {}
catch {chan create {c} foo} msg
rename foo {}
set msg
} {bad mode "c": must be read or write}
test iocmd-21.4 {chan create, bad handler, not a list} {
|
| ︙ | ︙ | |||
1053 1054 1055 1056 1057 1058 1059 |
}
set c [chan create {r w} foo]
note [read $c 10]
close $c
rename foo {}
set res
} -result {{read rc* 4096} {read rc* 4096} snarfsnarf}
| | | 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 |
}
set c [chan create {r w} foo]
note [read $c 10]
close $c
rename foo {}
set res
} -result {{read rc* 4096} {read rc* 4096} snarfsnarf}
test iocmd-23.2 {chan read, bad data return, too much} -match glob -body {
set res {}
proc foo {args} {
oninit; onfinal; track
return [string repeat snarf 1000]
}
set c [chan create {r w} foo]
note [catch {read $c 2} msg]; note $msg
|
| ︙ | ︙ | |||
2364 2365 2366 2367 2368 2369 2370 |
note [read $c 10]
close $c
notes
} c]
rename foo {}
set res
} -constraints {testchannel thread} -result {{read rc* 4096} {read rc* 4096} snarfsnarf}
| | | 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 |
note [read $c 10]
close $c
notes
} c]
rename foo {}
set res
} -constraints {testchannel thread} -result {{read rc* 4096} {read rc* 4096} snarfsnarf}
test iocmd.tf-23.2 {chan read, bad data return, too much} -match glob -body {
set res {}
proc foo {args} {
oninit; onfinal; track
return [string repeat snarf 1000]
}
set c [chan create {r w} foo]
notes [inthread $c {
|
| ︙ | ︙ |
Changes to tests/ioTrans.test.
| ︙ | ︙ | |||
110 111 112 113 114 115 116 |
chan
} -result {wrong # args: should be "chan subcommand ?arg ...?"}
test iortrans-1.1 {chan, unknown method} -returnCodes error -body {
chan foo
} -match glob -result {unknown or ambiguous subcommand "foo": must be*}
# --- --- --- --------- --------- ---------
| | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
chan
} -result {wrong # args: should be "chan subcommand ?arg ...?"}
test iortrans-1.1 {chan, unknown method} -returnCodes error -body {
chan foo
} -match glob -result {unknown or ambiguous subcommand "foo": must be*}
# --- --- --- --------- --------- ---------
# chan push, and method "initialize"
test iortrans-2.0 {chan push, wrong#args, not enough} -returnCodes error -body {
chan push
} -result {wrong # args: should be "chan push channel cmdprefix"}
test iortrans-2.1 {chan push, wrong#args, too many} -returnCodes error -body {
chan push a b c
} -result {wrong # args: should be "chan push channel cmdprefix"}
|
| ︙ | ︙ | |||
1330 1331 1332 1333 1334 1335 1336 | # ## The id numbers refer to the original test without thread forwarding, and ## gaps due to tests not applicable to forwarding are left to keep this ## association. # ### ### ### ######### ######### ######### ## Helper command. Runs a script in a separate thread and returns the result. | | | 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 |
#
## The id numbers refer to the original test without thread forwarding, and
## gaps due to tests not applicable to forwarding are left to keep this
## association.
# ### ### ### ######### ######### #########
## Helper command. Runs a script in a separate thread and returns the result.
## A channel is transferred into the thread as well, and a list of configuration
## variables
proc inthread {chan script args} {
# Test thread.
set tid [thread::create -preserved]
thread::send $tid {load {} Tcltest}
|
| ︙ | ︙ | |||
2009 2010 2011 2012 2013 2014 2015 |
set c [chan push [tempchan] foo]
lappend res {*}[inthread $c {
# Flush, no writing
seek $c 2
# The close flushes again, this modifies the file!
lappend notes | [close $c] |
# NOTE: The flush generated by the close is recorded immediately, the
| | | 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 |
set c [chan push [tempchan] foo]
lappend res {*}[inthread $c {
# Flush, no writing
seek $c 2
# The close flushes again, this modifies the file!
lappend notes | [close $c] |
# NOTE: The flush generated by the close is recorded immediately, the
# other note's here are deferred until after the thread is done. This
# changes the order of the result a bit from the non-threaded case
# (The first | moves one to the right). This is an artifact of the
# 'inthread' framework, not of the transformation itself.
notes
} c]
lappend res [tempview]
} -cleanup {
|
| ︙ | ︙ |
Changes to tests/iogt.test.
| ︙ | ︙ | |||
571 572 573 574 575 576 577 |
write {\}\{`~!@#$} {\}\{`~!@#$}
query/maxRead {} -1
read {%^&*()_+-=
} {%^&*()_+-=
}
query/maxRead {} -1
flush/read {} {}
| < > | 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
write {\}\{`~!@#$} {\}\{`~!@#$}
query/maxRead {} -1
read {%^&*()_+-=
} {%^&*()_+-=
}
query/maxRead {} -1
flush/read {} {}
write %^&*()_+-= %^&*()_+-=
write {
} {
}
query/maxRead {} -1
delete/read {} *ignored*
flush/write {} {}
delete/write {} *ignored*}
test iogt-2.4 {basic I/O, mixed trail} {testchannel} {
set fh [open $path(dummy) r]
torture -attach $fh
|
| ︙ | ︙ | |||
839 840 841 842 843 844 845 |
set f [open $path(dummy) r]
# contents of dummy = "abcdefghi..."
read $f 3; # skip behind "abc"
constx -attach $f
# expect to get "xxx" from the transform because of unread "def" input to
# transform which returns "xxx".
#
| | | 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 |
set f [open $path(dummy) r]
# contents of dummy = "abcdefghi..."
read $f 3; # skip behind "abc"
constx -attach $f
# expect to get "xxx" from the transform because of unread "def" input to
# transform which returns "xxx".
#
# Actually the IO layer preread the whole file and will read "def"
# directly from the buffer without bothering to consult the newly stacked
# transformation. This is wrong.
read $f 3
} -cleanup {
close $f
} -result {xxx}
test iogt-6.1 {Push back and up} -constraints {testchannel knownBug} -body {
|
| ︙ | ︙ |
Changes to tests/listObj.test.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
::tcltest::loadTestedCommands
catch [list package require -exact tcl::test [info patchlevel]]
testConstraint testobj [llength [info commands testobj]]
testConstraint memory [llength [info commands memory]]
catch {unset x}
test listobj-1.1 {Tcl_GetListObjType} emptyTest {
# Test removed; tested an internal detail
# that's no longer correct, and duplicated test obj-1.1
} {}
test listobj-2.1 {Tcl_SetListObj, use in lappend} {
| > > > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
::tcltest::loadTestedCommands
catch [list package require -exact tcl::test [info patchlevel]]
testConstraint testobj [llength [info commands testobj]]
testConstraint memory [llength [info commands memory]]
set INT_MAX 0x7fffffff; # Assumes sizeof(int) == 4
set SIZE_MAX [expr {(1 << (8*$::tcl_platform(pointerSize) - 1)) - 1}]
catch {unset x}
test listobj-1.1 {Tcl_GetListObjType} emptyTest {
# Test removed; tested an internal detail
# that's no longer correct, and duplicated test obj-1.1
} {}
test listobj-2.1 {Tcl_SetListObj, use in lappend} {
|
| ︙ | ︙ | |||
202 203 204 205 206 207 208 |
testlistobj get 1
} {f c d e}
test listobj-10.3 {Tcl_ListObjReplace with negative count value} testobj {
testlistobj set 1 a b c d e
testlistobj replace 1 1 -1 f
testlistobj get 1
} {a f b c d e}
| | | | | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
testlistobj get 1
} {f c d e}
test listobj-10.3 {Tcl_ListObjReplace with negative count value} testobj {
testlistobj set 1 a b c d e
testlistobj replace 1 1 -1 f
testlistobj get 1
} {a f b c d e}
test listobj-10.4 {Tcl_ListObjReplace with $SIZE_MAX count value} testobj {
testlistobj set 1 a b c d e
testlistobj replace 1 1 $SIZE_MAX f
testlistobj get 1
} {a f}
test listobj-10.5 {Tcl_ListObjReplace with SIZE_MAX-1 count value} testobj {
testlistobj set 1 a b c d e
testlistobj replace 1 1 [expr {$SIZE_MAX -1}] f
testlistobj get 1
} {a f}
test listobj-11.1 {Bug 3598580: Tcl_ListObjReplace refcount management} testobj {
testobj bug3598580
} 123
|
| ︙ | ︙ |
Changes to tests/lsearch.test.
| ︙ | ︙ | |||
684 685 686 687 688 689 690 691 692 693 694 695 696 697 |
} -result 4
test lsearch-28.8 {lsearch -sorted with -stride} -body {
lsearch -sorted -stride 2 -index 1 -subindices {3 5 8 7 2 9} 9
} -result 5
test lsearch-28.9 {lsearch -sorted with -stride} -body {
lsearch -sorted -stride 2 -index 1 -subindices -inline {3 5 8 7 2 9} 9
} -result 9
# cleanup
catch {unset res}
catch {unset increasingIntegers}
catch {unset decreasingIntegers}
catch {unset increasingDoubles}
| > > > | 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 |
} -result 4
test lsearch-28.8 {lsearch -sorted with -stride} -body {
lsearch -sorted -stride 2 -index 1 -subindices {3 5 8 7 2 9} 9
} -result 5
test lsearch-28.9 {lsearch -sorted with -stride} -body {
lsearch -sorted -stride 2 -index 1 -subindices -inline {3 5 8 7 2 9} 9
} -result 9
test lsearch-28.10 {lsearch -sorted with -stride} -body {
lsearch -sorted -stride 4294967296 -index 1 -subindices -inline {3 5 8 7 2 9} 9
} -returnCodes 1 -result {list size must be a multiple of the stride length}
# cleanup
catch {unset res}
catch {unset increasingIntegers}
catch {unset decreasingIntegers}
catch {unset increasingDoubles}
|
| ︙ | ︙ |
Changes to tests/lseq.test.
| ︙ | ︙ | |||
16 17 18 19 20 21 22 |
testConstraint arithSeriesDouble 1
testConstraint arithSeriesShimmer 1
testConstraint arithSeriesShimmerOk 1
testConstraint knownBug 0
testConstraint has64BitLengths [expr {$tcl_platform(pointerSize) == 8}]
| | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
testConstraint arithSeriesDouble 1
testConstraint arithSeriesShimmer 1
testConstraint arithSeriesShimmerOk 1
testConstraint knownBug 0
testConstraint has64BitLengths [expr {$tcl_platform(pointerSize) == 8}]
# Arg errors
test lseq-1.1 {error cases} -body {
lseq
} \
-returnCodes 1 \
-result {wrong # args: should be "lseq n ??op? n ??by? n??"}
|
| ︙ | ︙ | |||
413 414 415 416 417 418 419 |
[lindex [tcl::unsupported::representation $a] 3] \
$a] \n
} {arithseries
3.5 5.0 6.5 8.0 9.5 11.0 12.5 14.0 15.5 17.0 18.5
arithseries
18.5 17.0 15.5 14.0 12.5 11.0 9.5 8.0 6.5 5.0 3.5}
| | | | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
[lindex [tcl::unsupported::representation $a] 3] \
$a] \n
} {arithseries
3.5 5.0 6.5 8.0 9.5 11.0 12.5 14.0 15.5 17.0 18.5
arithseries
18.5 17.0 15.5 14.0 12.5 11.0 9.5 8.0 6.5 5.0 3.5}
test lseq-3.31 {lreverse inplace with doubles} {arithSeriesDouble has64BitLengths} {
lreverse [lseq 1.1 29.9 0.3]
} {29.9 29.6 29.3 29.0 28.7 28.4 28.1 27.8 27.5 27.2 26.9 26.6 26.3 26.0 25.7 25.4 25.1 24.8 24.5 24.2 23.9 23.6 23.3 23.0 22.7 22.4 22.1 21.8 21.5 21.2 20.9 20.6 20.3 20.0 19.7 19.4 19.1 18.8 18.5 18.2 17.9 17.6 17.3 17.0 16.7 16.4 16.1 15.8 15.5 15.2 14.9 14.6 14.3 14.0 13.7 13.4 13.1 12.8 12.5 12.2 11.9 11.6 11.3 11.0 10.7 10.4 10.1 9.8 9.5 9.2 8.9 8.6 8.3 8.0 7.7 7.4 7.1 6.8 6.5 6.2 5.9 5.6 5.3 5.0 4.7 4.4 4.1 3.8 3.5 3.2 2.9 2.6 2.3 2.0 1.7 1.4 1.1}
test lseq-4.1 {end expressions} {
set start 7
lseq $start $start+11
} {7 8 9 10 11 12 13 14 15 16 17 18}
test lseq-4.2 {start expressions} {
|
| ︙ | ︙ | |||
534 535 536 537 538 539 540 |
} {{} {} 0}
test lseq-4.8 {error case lrange} -body {
lrange [lseq 1 5] fred ginger
} -returnCodes 1 \
-result {bad index "fred": must be integer?[+-]integer? or end?[+-]integer?}
| | < | | < | < < < | < < | | > > | > > > | > > > | | | > | | < < > > > > | > > > > | > > | < > > > | 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
} {{} {} 0}
test lseq-4.8 {error case lrange} -body {
lrange [lseq 1 5] fred ginger
} -returnCodes 1 \
-result {bad index "fred": must be integer?[+-]integer? or end?[+-]integer?}
test lseq-4.9 {lrange empty/partial sets} -body {
foreach {fred ginger} {7 8 4 9 0 15 9 9 4 2} {
lappend res [lrange [lseq 1 5] $fred $ginger]
}
set res
} -result {{} 5 {1 2 3 4 5} {} {}}
# Panic when using variable value?
test lseq-4.10 {panic using variable index} {
set i 0
lindex [lseq 10] $i
} {0}
test lseq-4.11 {bug lseq / lindex discrepancies} -constraints has64BitLengths -body {
lindex [lseq 0x7fffffff] 0x80000000
} -result {}
test lseq-4.12 {bug lseq} -constraints has64BitLengths -body {
llength [lseq 0x100000000]
} -result {4294967296}
test lseq-4.13 {bug lseq} -constraints has64BitLengths -body {
set l [lseq 0x7fffffffffffffff]
list \
[llength $l] \
[lindex $l end] \
[lindex $l 9223372036854775800]
} -result {9223372036854775807 9223372036854775806 9223372036854775800}
test lseq-4.14 {bug lseq - inconsistent rounding} has64BitLengths {
# using a non-integer increment, [lseq] rounding seems to be not consistent:
lseq 4 40 0.1
} {4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12.0 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 13.0 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 14.0 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 15.0 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16.0 16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 16.9 17.0 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 17.9 18.0 18.1 18.2 18.3 18.4 18.5 18.6 18.7 18.8 18.9 19.0 19.1 19.2 19.3 19.4 19.5 19.6 19.7 19.8 19.9 20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.2 27.3 27.4 27.5 27.6 27.7 27.8 27.9 28.0 28.1 28.2 28.3 28.4 28.5 28.6 28.7 28.8 28.9 29.0 29.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30.0 30.1 30.2 30.3 30.4 30.5 30.6 30.7 30.8 30.9 31.0 31.1 31.2 31.3 31.4 31.5 31.6 31.7 31.8 31.9 32.0 32.1 32.2 32.3 32.4 32.5 32.6 32.7 32.8 32.9 33.0 33.1 33.2 33.3 33.4 33.5 33.6 33.7 33.8 33.9 34.0 34.1 34.2 34.3 34.4 34.5 34.6 34.7 34.8 34.9 35.0 35.1 35.2 35.3 35.4 35.5 35.6 35.7 35.8 35.9 36.0 36.1 36.2 36.3 36.4 36.5 36.6 36.7 36.8 36.9 37.0 37.1 37.2 37.3 37.4 37.5 37.6 37.7 37.8 37.9 38.0 38.1 38.2 38.3 38.4 38.5 38.6 38.7 38.8 38.9 39.0 39.1 39.2 39.3 39.4 39.5 39.6 39.7 39.8 39.9 40.0}
test lseq-4.15 {bug lseq - inconsistent rounding} has64BitLengths {
# using a non-integer increment, [lseq] rounding seems to be not consistent:
lseq 6 40 0.1
} {6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12.0 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 13.0 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 14.0 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 15.0 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16.0 16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 16.9 17.0 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 17.9 18.0 18.1 18.2 18.3 18.4 18.5 18.6 18.7 18.8 18.9 19.0 19.1 19.2 19.3 19.4 19.5 19.6 19.7 19.8 19.9 20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.2 27.3 27.4 27.5 27.6 27.7 27.8 27.9 28.0 28.1 28.2 28.3 28.4 28.5 28.6 28.7 28.8 28.9 29.0 29.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30.0 30.1 30.2 30.3 30.4 30.5 30.6 30.7 30.8 30.9 31.0 31.1 31.2 31.3 31.4 31.5 31.6 31.7 31.8 31.9 32.0 32.1 32.2 32.3 32.4 32.5 32.6 32.7 32.8 32.9 33.0 33.1 33.2 33.3 33.4 33.5 33.6 33.7 33.8 33.9 34.0 34.1 34.2 34.3 34.4 34.5 34.6 34.7 34.8 34.9 35.0 35.1 35.2 35.3 35.4 35.5 35.6 35.7 35.8 35.9 36.0 36.1 36.2 36.3 36.4 36.5 36.6 36.7 36.8 36.9 37.0 37.1 37.2 37.3 37.4 37.5 37.6 37.7 37.8 37.9 38.0 38.1 38.2 38.3 38.4 38.5 38.6 38.7 38.8 38.9 39.0 39.1 39.2 39.3 39.4 39.5 39.6 39.7 39.8 39.9 40.0}
test lseq-4.16 {bug lseq - inconsistent rounding} {
# using a non-integer increment, [lseq] rounding seems to be not consistent:
set res {}
lappend res [lseq 4.07 6 0.1]
lappend res [lseq 4.03 4.208 0.013]
} {{4.07 4.17 4.27 4.37 4.47 4.57 4.67 4.77 4.87 4.97 5.07 5.17 5.27 5.37 5.47 5.57 5.67 5.77 5.87 5.97} {4.03 4.043 4.056 4.069 4.082 4.095 4.108 4.121 4.134 4.147 4.16 4.173 4.186 4.199}}
# cleanup
::tcltest::cleanupTests
return
# Local Variables:
# mode: tcl
# End:
|
Changes to tests/mathop.test.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 |
# A namespace to test that operators are exported and that they
# work when imported
namespace eval ::testmathop2 {
namespace import ::tcl::mathop::*
}
# Helper to test math ops.
| | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# A namespace to test that operators are exported and that they
# work when imported
namespace eval ::testmathop2 {
namespace import ::tcl::mathop::*
}
# Helper to test math ops.
# Test different invocation variants and see that they do the same thing.
# Byte compiled / non byte compiled version
# Shared / unshared arguments
# Original / imported
proc TestOp {op args} {
set results {}
# Non byte compiled version, shared args
|
| ︙ | ︙ |
Changes to tests/msgcat.test.
| ︙ | ︙ | |||
1051 1052 1053 1054 1055 1056 1057 |
}
set bgerrorsaved [interp bgerror {}]
interp bgerror {} [namespace code callbackproc]
variable locale
if {![info exist locale]} { set locale [mclocale] }
| | | | | | 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 |
}
set bgerrorsaved [interp bgerror {}]
interp bgerror {} [namespace code callbackproc]
variable locale
if {![info exist locale]} { set locale [mclocale] }
test msgcat-14.1 {invocation loadcmd} -setup {
mcforgetpackage
mclocale $locale
mclocale ""
mcloadedlocales clear
set resultvariable ""
} -cleanup {
mcforgetpackage
} -body {
mcpackageconfig set loadcmd [namespace code callbackproc]
mclocale foo_bar
lsort $resultvariable
} -result {foo foo_bar}
test msgcat-14.2 {invocation failed in loadcmd} -setup {
mcforgetpackage
mclocale $locale
mclocale ""
mcloadedlocales clear
} -cleanup {
mcforgetpackage
after cancel set [namespace current]::resultvariable timeout
} -body {
mcpackageconfig set loadcmd [namespace code callbackfailproc]
mclocale foo_bar
# let the bgerror run
after 100 set [namespace current]::resultvariable timeout
vwait [namespace current]::resultvariable
lassign $resultvariable err errdict
list $err [dict get $errdict -code]
} -result {fail 1}
test msgcat-14.3 {invocation changecmd} -setup {
mcforgetpackage
mclocale $locale
mclocale ""
set resultvariable ""
} -cleanup {
mcforgetpackage
} -body {
mcpackageconfig set changecmd [namespace code callbackproc]
mclocale foo_bar
set resultvariable
} -result {foo_bar foo {}}
test msgcat-14.4 {invocation unknowncmd} -setup {
mcforgetpackage
mclocale $locale
mclocale ""
mcloadedlocales clear
set resultvariable ""
} -cleanup {
mcforgetpackage
|
| ︙ | ︙ |
Changes to tests/ooNext2.test.
| ︙ | ︙ | |||
122 123 124 125 126 127 128 |
}
}
oo::class create C {
superclass A B
variable result
constructor {p q r} {
lappend result ==C== p=$p,q=$q,r=$r
| | | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
}
}
oo::class create C {
superclass A B
variable result
constructor {p q r} {
lappend result ==C== p=$p,q=$q,r=$r
# Route arguments to superclasses, in non-trivial pattern
nextto B $q
nextto A $p $r
}
method result {} {return $result}
}
[C new x y z] result
} -cleanup {
|
| ︙ | ︙ |
Changes to tests/pkgMkIndex.test.
| ︙ | ︙ | |||
486 487 488 489 490 491 492 |
removeFile [file join pkg pkg5.tcl]
removeFile [file join pkg pkg2_a.tcl]
removeFile [file join pkg pkg2_b.tcl]
makeFile {
# This package requires circ2, and circ2 requires circ3, which in turn
| | | 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
removeFile [file join pkg pkg5.tcl]
removeFile [file join pkg pkg2_a.tcl]
removeFile [file join pkg pkg2_b.tcl]
makeFile {
# This package requires circ2, and circ2 requires circ3, which in turn
# requires circ1. In case of circularities, pkg_mkIndex should give up when
# it gets stuck.
package require circ2 1.0
package provide circ1 1.0
namespace eval circ1 {
namespace export c1-1 c1-2 c1-3 c1-4
}
proc circ1::c1-1 { num } {
|
| ︙ | ︙ | |||
650 651 652 653 654 655 656 |
test pkgMkIndex-12.1 {same name procs in different namespace} {
pkgtest::runIndex -lazy $fullPkgPath samename.tcl
} {0 {{football:1.0 {tclPkgSetup {samename.tcl source {::college::team ::pro::team}}}}}}
removeFile [file join pkg samename.tcl]
| | | 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
test pkgMkIndex-12.1 {same name procs in different namespace} {
pkgtest::runIndex -lazy $fullPkgPath samename.tcl
} {0 {{football:1.0 {tclPkgSetup {samename.tcl source {::college::team ::pro::team}}}}}}
removeFile [file join pkg samename.tcl]
# Proc names with embedded spaces are properly listed (i.e. correct number of
# braces) in result
makeFile {
package provide spacename 1.0
proc {a b} {} {}
proc {c d} {} {}
} [file join pkg spacename.tcl]
|
| ︙ | ︙ |
Changes to tests/remote.tcl.
1 2 3 4 5 6 7 8 9 10 11 | # This file contains Tcl code to implement a remote server that can be # used during testing of Tcl socket code. This server is used by some # of the tests in socket.test. # # Source this file in the remote server you are using to test Tcl against. # # Copyright © 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. | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# This file contains Tcl code to implement a remote server that can be
# used during testing of Tcl socket code. This server is used by some
# of the tests in socket.test.
#
# Source this file in the remote server you are using to test Tcl against.
#
# Copyright © 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.
# Initialize message delimiter
# Initialize command array
catch {unset command}
set command(0) ""
set callerSocket ""
# Detect whether we should print out connection messages etc.
|
| ︙ | ︙ |
Changes to tests/resolver.test.
| ︙ | ︙ | |||
199 200 201 202 203 204 205 | # The test resolver-3.1* test bad interactions of resolvers on the "global" # (per interp) literal pools. A resolver might resolve a cmd literal depending # on a context differently, whereas the cmd literal sharing assumed that the # namespace containing the literal solely determines the resolved cmd (and is # resolver-agnostic). # # In order to make the test cases for the per-interpreter cmd literal pool | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# The test resolver-3.1* test bad interactions of resolvers on the "global"
# (per interp) literal pools. A resolver might resolve a cmd literal depending
# on a context differently, whereas the cmd literal sharing assumed that the
# namespace containing the literal solely determines the resolved cmd (and is
# resolver-agnostic).
#
# In order to make the test cases for the per-interpreter cmd literal pool
# reproducible and to minimize interactions between test cases, we use a child
# interpreter per test-case.
#
#
# Testing resolver in namespace-based context "ctx1"
#
test resolver-3.1a {
interp command resolver,
|
| ︙ | ︙ |
Changes to tests/safe-stock.test.
| ︙ | ︙ | |||
93 94 95 96 97 98 99 |
set listOut {}
foreach element $listIn {
lappend listOut [string map $map $element]
}
lsort $listOut
}
| | | | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
set listOut {}
foreach element $listIn {
lappend listOut [string map $map $element]
}
lsort $listOut
}
# Force actual loading of the safe package because we use unexported (and
# thus unautoindexed) APIs in this test result arguments:
catch {safe::interpConfigure}
testConstraint AutoSyncDefined 1
# high level general test
test safe-stock-7.1 {tests that everything works at high level with conventional AutoPathSync, use pkg opt} -setup {
set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
|
| ︙ | ︙ |
Changes to tests/safe.test.
| ︙ | ︙ | |||
52 53 54 55 56 57 58 |
set listOut {}
foreach element $listIn {
lappend listOut [string map $map $element]
}
lsort $listOut
}
| | | | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
set listOut {}
foreach element $listIn {
lappend listOut [string map $map $element]
}
lsort $listOut
}
# Force actual loading of the safe package because we use unexported (and
# thus unautoindexed) APIs in this test result arguments:
catch {safe::interpConfigure}
# testing that nested and statics do what is advertised (we use a static
# package - tcl::test - but it might be absent if we're in standard tclsh)
testConstraint tcl::test [expr {![catch {package require tcl::test}]}]
testConstraint AutoSyncDefined 1
|
| ︙ | ︙ |
Changes to tests/scan.test.
| ︙ | ︙ | |||
504 505 506 507 508 509 510 |
} -result {4 12 34 56 78}
test scan-5.10 {integer scanning} -setup {
set a {}; set b {}; set c {}; set d {}
} -body {
list [scan "1 2 " "%hd %d %d %d" a b c d] $a $b $c $d
} -result {2 1 2 {} {}}
#
| | | 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
} -result {4 12 34 56 78}
test scan-5.10 {integer scanning} -setup {
set a {}; set b {}; set c {}; set d {}
} -body {
list [scan "1 2 " "%hd %d %d %d" a b c d] $a $b $c $d
} -result {2 1 2 {} {}}
#
# The behavior for scanning integers larger than MAX_INT is not defined by the
# ANSI spec. Some implementations wrap the input (-16) some return MAX_INT.
#
test scan-5.11 {integer scanning} -constraints {nonPortable} -setup {
set a {}; set b {}
} -body {
list [scan "4294967280 4294967280" "%u %d" a b] $a \
[expr {$b == -16 || $b == 0x7fffffff}]
|
| ︙ | ︙ | |||
854 855 856 857 858 859 860 861 862 863 864 865 866 867 |
test scan-13.7 {Tcl_ScanObjCmd, inline XPG case lots of arguments} {
scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200" {%20$d %18$d %17$d %16$d %15$d %14$d %13$d %12$d %11$d %10$d %9$d %8$d %7$d %6$d %5$d %4$d %3$d %2$d %1$d}
} {190 180 170 160 150 140 130 120 110 100 90 80 70 60 50 40 30 20 {} 10}
test scan-13.8 {Tcl_ScanObjCmd, inline XPG case lots of arguments} {
set msg [scan "10 20 30" {%100$d %5$d %200$d}]
list [llength $msg] [lindex $msg 99] [lindex $msg 4] [lindex $msg 199]
} {200 10 20 30}
# scan infinities - not working
test scan-14.1 {positive infinity} {
scan Inf %g d
return $d
} Inf
| > > > > > > | 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 |
test scan-13.7 {Tcl_ScanObjCmd, inline XPG case lots of arguments} {
scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200" {%20$d %18$d %17$d %16$d %15$d %14$d %13$d %12$d %11$d %10$d %9$d %8$d %7$d %6$d %5$d %4$d %3$d %2$d %1$d}
} {190 180 170 160 150 140 130 120 110 100 90 80 70 60 50 40 30 20 {} 10}
test scan-13.8 {Tcl_ScanObjCmd, inline XPG case lots of arguments} {
set msg [scan "10 20 30" {%100$d %5$d %200$d}]
list [llength $msg] [lindex $msg 99] [lindex $msg 4] [lindex $msg 199]
} {200 10 20 30}
test scan-13.9 {Tcl_ScanObjCmd, inline XPG case limit error} -body {
# Note this applies to 64-bit builds as well so long as max number of
# command line arguments allowed for scan command is INT_MAX
scan abc {%2147483648$s}
} -result {"%n$" argument index out of range} -returnCodes error
# scan infinities - not working
test scan-14.1 {positive infinity} {
scan Inf %g d
return $d
} Inf
|
| ︙ | ︙ |
Changes to tests/socket.test.
| ︙ | ︙ | |||
123 124 125 126 127 128 129 |
puts $s2 test1; gets $s1
puts $s2 test2; gets $s1
close $s1; close $s2
set t2 [clock milliseconds]
set lat1 [expr {($t2-$t1)*2}]; # doubled as a safety margin
# Test the latency of failed connection attempts over the loopback
| | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
puts $s2 test1; gets $s1
puts $s2 test2; gets $s1
close $s1; close $s2
set t2 [clock milliseconds]
set lat1 [expr {($t2-$t1)*2}]; # doubled as a safety margin
# Test the latency of failed connection attempts over the loopback
# interface. They can take more than a second under Windows and requires
# additional [after]s in some tests that are not needed on systems that fail
# immediately.
set t1 [clock milliseconds]
catch {socket 127.0.0.1 [randport]}
set t2 [clock milliseconds]
set lat2 [expr {($t2-$t1)*3}]
|
| ︙ | ︙ | |||
1860 1861 1862 1863 1864 1865 1866 |
try {
set ::count 0
set ::testmode $testmode
set port 0
set srvsock {}
# if binding on port 0 is not possible (system related, blocked on ISPs etc):
if {[catch {close [socket -async $::localhost $port]}]} {
| | | 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 |
try {
set ::count 0
set ::testmode $testmode
set port 0
set srvsock {}
# if binding on port 0 is not possible (system related, blocked on ISPs etc):
if {[catch {close [socket -async $::localhost $port]}]} {
# simplest server on random port (immediately closing a connect):
set port [randport]
set srvsock [socket -server {apply {{ch args} {close $ch}}} -myaddr $::localhost $port]
# socket on windows has some issues yet (e. g. bug [b6d0d8cc2c]), so we simply decrease iteration count (to 1/4):
if {$::tcl_platform(platform) eq "windows" && $maxIter > 50} {
set ::count [expr {$maxIter / 4 * 3 - 1}]; # bypass 3/4 iterations
}
}
|
| ︙ | ︙ | |||
1894 1895 1896 1897 1898 1899 1900 |
}} $fd]
};#
thread::detach $fd
thread::send -async $::parent [list transf_parent $fd {*}$args]
}
iteration first
}
| | | 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 |
}} $fd]
};#
thread::detach $fd
thread::send -async $::parent [list transf_parent $fd {*}$args]
}
iteration first
}
# parent proc committing transfer attempt (attach) and checking acquire was successful:
proc transf_parent {fd args} {
tcltest::DebugPuts 2 "** trma / $::count ** $args **"
thread::attach $fd
if {"parent-close" in $::testmode} {;# to test close during connect
set ::count $::count
close $fd
return
|
| ︙ | ︙ | |||
2222 2223 2224 2225 2226 2227 2228 |
-constraints {socket} \
-body {
set sock [socket -async localhost [randport]]
catch {gets $sock} x
list $x [fconfigure $sock -error] [fconfigure $sock -error]
} -cleanup {
close $sock
| | | 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 |
-constraints {socket} \
-body {
set sock [socket -async localhost [randport]]
catch {gets $sock} x
list $x [fconfigure $sock -error] [fconfigure $sock -error]
} -cleanup {
close $sock
} -match glob -result {{error reading "sock*": transport endpoint is not connected} {connection refused} {}}
test socket-14.8.0 {pending [socket -async] and nonblocking [gets], server is IPv4} \
-constraints {socket supported_inet localhost_v4} \
-setup {
makeFile {
fileevent stdin readable exit
set server [socket -server accept -myaddr 127.0.0.1 0]
proc accept {s h p} {puts $s ok; close $s; set ::x 1}
|
| ︙ | ︙ | |||
2287 2288 2289 2290 2291 2292 2293 |
for {set i 0} {$i < 50} {incr i } {
if {[catch {gets $sock} x] || $x ne "" || ![fblocked $sock]} break
after 200
}
list $x [fconfigure $sock -error] [fconfigure $sock -error]
} -cleanup {
close $sock
| | | 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 |
for {set i 0} {$i < 50} {incr i } {
if {[catch {gets $sock} x] || $x ne "" || ![fblocked $sock]} break
after 200
}
list $x [fconfigure $sock -error] [fconfigure $sock -error]
} -cleanup {
close $sock
} -match glob -result {{error reading "sock*": transport endpoint is not connected} {connection refused} {}}
test socket-14.9.0 {pending [socket -async] and blocking [puts], server is IPv4} \
-constraints {socket supported_inet localhost_v4} \
-setup {
makeFile {
fileevent stdin readable exit
set server [socket -server accept -myaddr 127.0.0.1 0]
proc accept {s h p} {set ::x $s}
|
| ︙ | ︙ | |||
2402 2403 2404 2405 2406 2407 2408 |
puts $sock ok
fileevent $sock writable {set x 1}
vwait x
close $sock
} -cleanup {
catch {close $sock}
unset x
| | | | 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 |
puts $sock ok
fileevent $sock writable {set x 1}
vwait x
close $sock
} -cleanup {
catch {close $sock}
unset x
} -result {transport endpoint is not connected} -returnCodes 1
test socket-14.11.1 {pending [socket -async] and nonblocking [puts], no listener, flush} \
-constraints {socket testsocket_testflags} \
-body {
set sock [socket -async localhost [randport]]
# Set the socket in async test mode.
# The async connect will not be continued on the following fconfigure
# and puts/flush. Thus, the connect will fail after them.
testsocket testflags $sock 1
fconfigure $sock -blocking 0
puts $sock ok
flush $sock
testsocket testflags $sock 0
fileevent $sock writable {set x 1}
vwait x
close $sock
} -cleanup {
catch {close $sock}
catch {unset x}
} -result {transport endpoint is not connected} -returnCodes 1
test socket-14.12 {[socket -async] background progress triggered by [fconfigure -error]} \
-constraints {socket} \
-body {
set s [socket -async localhost [randport]]
for {set i 0} {$i < 50} {incr i} {
set x [fconfigure $s -error]
if {$x != ""} break
|
| ︙ | ︙ | |||
2443 2444 2445 2446 2447 2448 2449 |
test socket-14.13 {testing writable event when quick failure} \
-constraints {socket win supported_inet notWine} \
-body {
# Test for bug 336441ed59 where a quick background fail was ignored
# Test only for windows as socket -async 255.255.255.255 fails
| | | 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 |
test socket-14.13 {testing writable event when quick failure} \
-constraints {socket win supported_inet notWine} \
-body {
# Test for bug 336441ed59 where a quick background fail was ignored
# Test only for windows as socket -async 255.255.255.255 fails
# directly on Unix
# The following connect should fail very quickly
set a1 [after 2000 {set x timeout}]
set s [socket -async 255.255.255.255 43434]
fileevent $s writable {set x writable}
vwait x
set x
|
| ︙ | ︙ |
Changes to tests/stringObj.test.
| ︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
test stringObj-1.1 {string type registration} testobj {
set t [testobj types]
set first [string first "string" $t]
set result [expr {$first >= 0}]
} 1
test stringObj-2.1 {Tcl_NewStringObj} testobj {
set result ""
lappend result [testobj freeallvars]
lappend result [teststringobj set 1 abcd]
lappend result [testobj type 1]
lappend result [testobj refcount 1]
} {{} abcd string 2}
| > > > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
test stringObj-1.1 {string type registration} testobj {
set t [testobj types]
set first [string first "string" $t]
set result [expr {$first >= 0}]
} 1
set INT_MAX 0x7fffffff; # Assumes sizeof(int) == 4
set SIZE_MAX [expr {(1 << (8*$::tcl_platform(pointerSize) - 1)) - 1}]
test stringObj-2.1 {Tcl_NewStringObj} testobj {
set result ""
lappend result [testobj freeallvars]
lappend result [teststringobj set 1 abcd]
lappend result [testobj type 1]
lappend result [testobj refcount 1]
} {{} abcd string 2}
|
| ︙ | ︙ | |||
311 312 313 314 315 316 317 |
string length $x
list [testobj objtype $x] [testobj objtype $y] [append x $y] \
[set y] [testobj objtype $x] [testobj objtype $y]
} "string int abc\xEF\xBF\xAEghi9 9 string int"
test stringObj-9.11 {TclAppendObjToObj, mixed src & 1-byte dest index check} testobj {
# bug 2678, in <=8.2.0, the second obj (the one to append) in
# Tcl_AppendObjToObj was not correctly checked to see if it was all one
| | | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
string length $x
list [testobj objtype $x] [testobj objtype $y] [append x $y] \
[set y] [testobj objtype $x] [testobj objtype $y]
} "string int abc\xEF\xBF\xAEghi9 9 string int"
test stringObj-9.11 {TclAppendObjToObj, mixed src & 1-byte dest index check} testobj {
# bug 2678, in <=8.2.0, the second obj (the one to append) in
# Tcl_AppendObjToObj was not correctly checked to see if it was all one
# byte chars, so a Unicode string would be added as one byte chars.
set x abcdef
set len [string length $x]
set y a\xFCb\xE5c\xEF
set len [string length $y]
append x $y
string length $x
set q {}
|
| ︙ | ︙ | |||
404 405 406 407 408 409 410 |
list [string length $a] [string length $a]
} {6 6}
test stringObj-13.4 {Tcl_GetCharLength with mixed width chars} testobj {
string length "\xAE"
} 1
test stringObj-13.5 {Tcl_GetCharLength with mixed width chars} testobj {
# string length "○○"
| | | | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
list [string length $a] [string length $a]
} {6 6}
test stringObj-13.4 {Tcl_GetCharLength with mixed width chars} testobj {
string length "\xAE"
} 1
test stringObj-13.5 {Tcl_GetCharLength with mixed width chars} testobj {
# string length "○○"
# Use \uXXXX notation below instead of hard-coding the values, otherwise
# the test will fail in multibyte locales.
string length "\xEF\xBF\xAE\xEF\xBF\xAE"
} 6
test stringObj-13.6 {Tcl_GetCharLength with mixed width chars} testobj {
# set a "ïa¿b®cï¿d®"
# Use \uXXXX notation below instead of hard-coding the values, otherwise
# the test will fail in multibyte locales.
set a "\xEFa\xBFb\xAEc\xEF\xBFd\xAE"
list [string length $a] [string length $a]
} {10 10}
test stringObj-13.7 {Tcl_GetCharLength with identity nulls} {testobj testbytestring} {
# SF bug #684699
string length [testbytestring \x00]
|
| ︙ | ︙ | |||
496 497 498 499 500 501 502 |
teststringobj range 1 -1 -1
} abcde
test stringObj-16.6 {Tcl_GetRange: old anomaly} testobj {
# Older implementations could return "cde"
teststringobj set 1 abcde
teststringobj range 1 2 0
} {}
| | | | | | | | | > | | 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
teststringobj range 1 -1 -1
} abcde
test stringObj-16.6 {Tcl_GetRange: old anomaly} testobj {
# Older implementations could return "cde"
teststringobj set 1 abcde
teststringobj range 1 2 0
} {}
test stringObj-16.7 {Tcl_GetRange: first = INT_MAX-1} testobj {
teststringobj set 1 abcde
teststringobj range 1 [expr {$INT_MAX-1}] 3
} {}
test stringObj-16.8 {Tcl_GetRange: first = SIZE_MAX-1} testobj {
teststringobj set 1 abcde
teststringobj range 1 [expr {$SIZE_MAX - 1}] 3
} {}
test stringObj-16.9 {Tcl_GetRange: last = INT_MAX-1} testobj {
teststringobj set 1 abcde
teststringobj range 1 1 [expr {$INT_MAX-1}]
} bcde
test stringObj-16.10 {Tcl_GetRange: last = SIZE_MAX-1} testobj {
teststringobj set 1 abcde
teststringobj range 1 1 [expr {$SIZE_MAX - 1}]
} bcde
test stringObj-16.11 {Tcl_GetRange: first = last = INT_MAX-1} testobj {
teststringobj set 1 abcde
teststringobj range 1 [expr {$INT_MAX-1}] [expr {$INT_MAX-1}]
} {}
test stringObj-16.12 {Tcl_GetRange: first = last = SIZE_MAX-1} testobj {
teststringobj set 1 abcde
set i [expr {$SIZE_MAX - 1}]
teststringobj range 1 $i $i
} {}
if {[testConstraint testobj]} {
testobj freeallvars
}
# cleanup
::tcltest::cleanupTests
return
# Local Variables:
# mode: tcl
# End:
|
Changes to tests/tcltest.test.
| ︙ | ︙ | |||
538 539 540 541 542 543 544 |
-body {
child msg $a -tmpdir $tdiaf
return $msg
}
-result {*not a directory*}
-match glob
}
| | | | | | | | | | | | 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
-body {
child msg $a -tmpdir $tdiaf
return $msg
}
-result {*not a directory*}
-match glob
}
# Test non-writable directories, non-readable directories with directory flags
set notReadableDir [file join [temporaryDirectory] notreadable]
set notWritableDir [file join [temporaryDirectory] notwritable]
makeDirectory notreadable
makeDirectory notwritable
switch -- $::tcl_platform(platform) {
unix {
file attributes $notReadableDir -permissions 0o333
file attributes $notWritableDir -permissions 0o555
}
default {
# note in FAT/NTFS we won't be able to protect directory with read-only attribute...
catch {file attributes $notWritableDir -readonly 1}
catch {testchmod 0o444 $notWritableDir}
}
}
test tcltest-8.3 {tcltest a.tcl -tmpdir notReadableDir} {
-constraints {unix notRoot notWsl}
-body {
child msg $a -tmpdir $notReadableDir
return $msg
}
-result {*not readable*}
-match glob
}
# This constraint doesn't go at the top of the file so that it doesn't
# interfere with tcltest-5.5
testConstraint notFAT [expr {
![regexp {^(FAT\d*|NTFS)$} [lindex [file system $notWritableDir] 1]]
|| $::tcl_platform(platform) eq "unix" || [llength [info commands testchmod]]
}]
# FAT/NTFS permissions are fairly hopeless; ignore this test if that FS is used
test tcltest-8.4 {tcltest a.tcl -tmpdir notWritableDir} {
-constraints {unixOrWin notRoot notFAT notWsl}
-body {
child msg $a -tmpdir $notWritableDir
return $msg
}
-result {*not writable*}
-match glob
}
test tcltest-8.5 {tcltest a.tcl -tmpdir normaldirectory} {
-constraints unixOrWin
-body {
child msg $a -tmpdir $normaldirectory
# The join is necessary because the message can be split on multiple
|
| ︙ | ︙ | |||
717 718 719 720 721 722 723 |
}
# clean up from directory testing
switch -- $::tcl_platform(platform) {
unix {
file attributes $notReadableDir -permissions 0o777
| | | | | | 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
}
# clean up from directory testing
switch -- $::tcl_platform(platform) {
unix {
file attributes $notReadableDir -permissions 0o777
file attributes $notWritableDir -permissions 0o777
}
default {
catch {testchmod 0o777 $notWritableDir}
catch {file attributes $notWritableDir -readonly 0}
}
}
file delete -force -- $notReadableDir $notWritableDir
removeFile a.tcl
removeFile thisdirectoryisafile
removeDirectory normaldirectory
# -file, -notfile, [matchFiles], [skipFiles]
test tcltest-9.1 {-file d*.tcl} -constraints {unixOrWin} -setup {
set old [testsDirectory]
|
| ︙ | ︙ |
Changes to tests/tcltests.tcl.
| ︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
interp alias {} [namespace current]::tempdir {} [
namespace current]::tempdir_alternate
} else {
interp alias {} [namespace current]::tempdir {} ::tcl::file::tempdir
}
}
proc tempdir_alternate {} {
close [file tempfile tempfile]
set tmpdir [file dirname $tempfile]
set execname [info nameofexecutable]
regsub -all {[^[:alpha:][:digit:]]} $execname _ execname
for {set i 0} {$i < 10000} {incr i} {
| > > > > > > > > > > > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
interp alias {} [namespace current]::tempdir {} [
namespace current]::tempdir_alternate
} else {
interp alias {} [namespace current]::tempdir {} ::tcl::file::tempdir
}
}
# Stolen from dict.test
proc scriptmemcheck script {
set end [lindex [split [memory info] \n] 3 3]
for {set i 0} {$i < 5} {incr i} {
uplevel 1 $script
set tmp $end
set end [lindex [split [memory info] \n] 3 3]
}
expr {$end - $tmp}
}
proc tempdir_alternate {} {
close [file tempfile tempfile]
set tmpdir [file dirname $tempfile]
set execname [info nameofexecutable]
regsub -all {[^[:alpha:][:digit:]]} $execname _ execname
for {set i 0} {$i < 10000} {incr i} {
|
| ︙ | ︙ |
Changes to tests/unixFCmd.test.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 |
testConstraint notWsl [expr {[llength [array names ::env *WSL*]] == 0}]
# These tests really need to be run from a writable directory, which
# it is assumed [temporaryDirectory] is.
set oldcwd [pwd]
cd [temporaryDirectory]
| | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
testConstraint notWsl [expr {[llength [array names ::env *WSL*]] == 0}]
# These tests really need to be run from a writable directory, which
# it is assumed [temporaryDirectory] is.
set oldcwd [pwd]
cd [temporaryDirectory]
# Several tests require need to match results against the Unix username
set user {}
if {[testConstraint unix]} {
catch {set user [exec whoami]}
if {$user == ""} {
catch {regexp {^[^(]*\(([^)]*)\)} [exec id] dummy user}
}
if {$user == ""} {
|
| ︙ | ︙ | |||
108 109 110 111 112 113 114 |
cleanup
} -constraints {unix notRoot} -body {
file mkdir td1/td2
file mkdir td2
file rename td2 td1
} -returnCodes error -cleanup {
cleanup
| | | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
cleanup
} -constraints {unix notRoot} -body {
file mkdir td1/td2
file mkdir td2
file rename td2 td1
} -returnCodes error -cleanup {
cleanup
} -result {error renaming "td2" to "td1/td2": file exists}
test unixFCmd-1.3 {TclpRenameFile: EINVAL} -setup {
cleanup
} -constraints {unix notRoot} -body {
file mkdir td1
file rename td1 td1
} -returnCodes error -cleanup {
cleanup
|
| ︙ | ︙ | |||
383 384 385 386 387 388 389 |
permcheck unixFCmd-17.11 --x--x--x 0o111
permcheck unixFCmd-17.12 {0 a+rwx} {00000 0o777}
file delete -force -- foo.test
test unixFCmd-18.1 {Unix pwd} -constraints {unix notRoot nonPortable} -setup {
set cd [pwd]
} -body {
| | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
permcheck unixFCmd-17.11 --x--x--x 0o111
permcheck unixFCmd-17.12 {0 a+rwx} {00000 0o777}
file delete -force -- foo.test
test unixFCmd-18.1 {Unix pwd} -constraints {unix notRoot nonPortable} -setup {
set cd [pwd]
} -body {
# This test is non-portable because SunOS generates a weird error
# message when the current directory isn't readable.
set nd $cd/tstdir
file mkdir $nd
cd $nd
file attributes $nd -permissions 0
pwd
} -returnCodes error -cleanup {
|
| ︙ | ︙ |
Changes to tests/unixForkEvent.test.
| ︙ | ︙ | |||
13 14 15 16 17 18 19 |
namespace import -force ::tcltest::*
}
testConstraint testfork [llength [info commands testfork]]
# Test if the notifier thread is well initialized in a forked interpreter
# by Tcl_InitNotifier
| | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
namespace import -force ::tcltest::*
}
testConstraint testfork [llength [info commands testfork]]
# Test if the notifier thread is well initialized in a forked interpreter
# by Tcl_InitNotifier
test unixforkevent-1.1 {fork and test writable event} \
-constraints {testfork nonPortable} \
-body {
set myFolder [makeDirectory unixtestfork]
set pid [testfork]
if {$pid == 0} {
# we are the forked process
set result initialized
|
| ︙ | ︙ |
Changes to tests/winConsole.test.
| ︙ | ︙ | |||
340 341 342 343 344 345 346 |
fconfigure stdout -winsize {10 30}
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -profile, or -translation} -returnCodes error
test console-fconfigure-set-3.0 {
fconfigure stderr -winsize
} -constraints {win interactive} -body {
fconfigure stderr -winsize {10 30}
| | | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
fconfigure stdout -winsize {10 30}
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -profile, or -translation} -returnCodes error
test console-fconfigure-set-3.0 {
fconfigure stderr -winsize
} -constraints {win interactive} -body {
fconfigure stderr -winsize {10 30}
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -profile, or -translation} -returnCodes error
# Multiple threads
test console-thread-input-1.0 {Get input in thread} -constraints {
win interactive haveThread
} -setup {
set tid [thread::create]
|
| ︙ | ︙ |
Changes to tests/winDde.test.
| ︙ | ︙ | |||
150 151 152 153 154 155 156 |
dde eval self set \xe1 foo
} -result foo
test winDde-3.5 {DDE request locally} -constraints dde -body {
set \xe1 ""
dde execute TclEval self [list set \xe1 foo]
dde request -binary TclEval self \xe1
} -result "foo\x00"
| | | | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
dde eval self set \xe1 foo
} -result foo
test winDde-3.5 {DDE request locally} -constraints dde -body {
set \xe1 ""
dde execute TclEval self [list set \xe1 foo]
dde request -binary TclEval self \xe1
} -result "foo\x00"
# Set variable a to A with diaeresis (Unicode C4) by relying on the fact
# that utf-8 is sent (e.g. "c3 84" on the wire)
test winDde-3.6 {DDE request utf-8} -constraints dde -body {
set \xe1 "not set"
dde execute TclEval self "set \xe1 \xc4"
scan [set \xe1] %c
} -result 196
# Set variable a to A with diaeresis (Unicode C4) using binary execute
# and compose utf-8 (e.g. "c3 84" ) manually
test winDde-3.7 {DDE request binary} -constraints {dde notWine} -body {
set \xe1 "not set"
dde execute -binary TclEval self [list set \xc3\xa1 \xc3\x84\x00]
scan [set \xe1] %c
} -result 196
test winDde-3.8 {DDE poke locally} -constraints {dde debug} -body {
set \xe1 ""
|
| ︙ | ︙ |
Changes to tests/winFCmd.test.
| ︙ | ︙ | |||
119 120 121 122 123 124 125 | append longname $longname append longname $longname append longname $longname # Uses the "testfile" command instead of the "file" command. The "file" # command provides several layers of sanity checks on the arguments and # it can be difficult to actually forward "insane" arguments to the | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
append longname $longname
append longname $longname
append longname $longname
# Uses the "testfile" command instead of the "file" command. The "file"
# command provides several layers of sanity checks on the arguments and
# it can be difficult to actually forward "insane" arguments to the
# low-level Posix emulation layer.
test winFCmd-1.1 {TclpRenameFile: errno: EACCES} -body {
testfile mv $cdfile $cdrom/dummy~~.fil
} -constraints {win cdrom testfile} -returnCodes error -result EACCES
test winFCmd-1.2 {TclpRenameFile: errno: EEXIST} -setup {
cleanup
} -constraints {win testfile notInCIenv} -body {
|
| ︙ | ︙ |
Changes to tests/zlib.test.
| ︙ | ︙ | |||
288 289 290 291 292 293 294 |
set fd [open $file wb]
} -constraints zlib -body {
list [fconfigure $fd] [zlib push compress $fd; fconfigure $fd] \
[chan pop $fd; fconfigure $fd]
} -cleanup {
catch {close $fd}
removeFile $file
| | | | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
set fd [open $file wb]
} -constraints zlib -body {
list [fconfigure $fd] [zlib push compress $fd; fconfigure $fd] \
[chan pop $fd; fconfigure $fd]
} -cleanup {
catch {close $fd}
removeFile $file
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding iso8859-1 -eofchar {} -profile strict -translation lf} {-blocking 1 -buffering full -buffersize 4096 -encoding iso8859-1 -eofchar {} -profile strict -translation lf -checksum 1 -dictionary {}} {-blocking 1 -buffering full -buffersize 4096 -encoding iso8859-1 -eofchar {} -profile strict -translation lf}}
test zlib-8.7 {transformation and fconfigure} -setup {
set file [makeFile {} test.gz]
set fd [open $file wb]
} -constraints zlib -body {
list [fconfigure $fd] [zlib push gzip $fd; fconfigure $fd] \
[chan pop $fd; fconfigure $fd]
} -cleanup {
catch {close $fd}
removeFile $file
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding iso8859-1 -eofchar {} -profile strict -translation lf} {-blocking 1 -buffering full -buffersize 4096 -encoding iso8859-1 -eofchar {} -profile strict -translation lf -checksum 0} {-blocking 1 -buffering full -buffersize 4096 -encoding iso8859-1 -eofchar {} -profile strict -translation lf}}
# Input is headers from fetching SPDY draft
# Dictionary is that which is proposed _in_ SPDY draft
set spdyHeaders "HTTP/1.0 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nX-Robots-Tag: noarchive\r\nLast-Modified: Tue, 05 Jun 2012 02:43:25 GMT\r\nETag: \"1338864205129|#public|0|en|||0\"\r\nExpires: Tue, 05 Jun 2012 16:17:11 GMT\r\nDate: Tue, 05 Jun 2012 16:17:06 GMT\r\nCache-Control: public, max-age=5\r\nX-Content-Type-Options: nosniff\r\nX-XSS-Protection: 1; mode=block\r\nServer: GSE\r\n"
set spdyDict "optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchif-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser-agent100101200201202203204205206300301302303304305306307400401402403404405406407408409410411412413414415416417500501502503504505accept-rangesageetaglocationproxy-authenticatepublicretry-afterservervarywarningwww-authenticateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertransfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locationcontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMondayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSepOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplication/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1.1statusversionurl"
test zlib-8.8 {transformation and fconfigure} -setup {
lassign [chan pipe] inSide outSide
} -constraints zlib -body {
|
| ︙ | ︙ |
Changes to tools/mkdepend.tcl.
| ︙ | ︙ | |||
248 249 250 251 252 253 254 | } # addSearchPath -- # # Adds a new set of path and replacement string to the global list. # # Arguments: | | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
}
# addSearchPath --
#
# Adds a new set of path and replacement string to the global list.
#
# Arguments:
# newPathInfo comma separated path and replacement string
#
# Results:
# None.
proc addSearchPath {newPathInfo} {
global srcPathList srcPathReplaceList
|
| ︙ | ︙ | |||
292 293 294 295 296 297 298 |
proc readInputListFile {objectListFile} {
global srcFileList srcPathList source_extensions
set f [open $objectListFile r]
set fl [read $f]
close $f
| | | 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
proc readInputListFile {objectListFile} {
global srcFileList srcPathList source_extensions
set f [open $objectListFile r]
set fl [read $f]
close $f
# fix native path separator so it isn't treated as an escape.
regsub -all {\\} $fl {/} fl
# Treat the string as a list so filenames between double quotes are
# treated as list elements.
foreach fname $fl {
# Compiled .res resource files should be ignored.
if {[file extension $fname] ne ".obj"} {continue}
|
| ︙ | ︙ |
Changes to tools/regexpTestLib.tcl.
| ︙ | ︙ | |||
38 39 40 41 42 43 44 |
close $fileId
return $i
}
#
# strings with embedded @'s are truncated
| | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
close $fileId
return $i
}
#
# strings with embedded @'s are truncated
# unpreceded @'s are replaced by {}
#
proc removeAts {ls} {
set len [llength $ls]
set newLs {}
foreach item $ls {
regsub @.* $item "" newItem
lappend newLs $newItem
|
| ︙ | ︙ |
Changes to unix/configure.
| ︙ | ︙ | |||
7637 7638 7639 7640 7641 7642 7643 |
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${tcl_flags}" >&5
printf "%s\n" "${tcl_flags}" >&6; }
fi
| | | | 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 |
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${tcl_flags}" >&5
printf "%s\n" "${tcl_flags}" >&6; }
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if 'long' and 'long long' have the same size (64-bit)?" >&5
printf %s "checking if 'long' and 'long long' have the same size (64-bit)?... " >&6; }
if test ${tcl_cv_type_64bit+y}
then :
printf %s "(cached) " >&6
else $as_nop
tcl_cv_type_64bit=none
# See if we could use long anyway Note that we substitute in the
|
| ︙ | ︙ | |||
7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 |
if test "${tcl_cv_type_64bit}" = none ; then
printf "%s\n" "#define TCL_WIDE_INT_IS_LONG 1" >>confdefs.h
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
else
# Now check for auxiliary declarations
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct dirent64" >&5
printf %s "checking for struct dirent64... " >&6; }
if test ${tcl_cv_struct_dirent64+y}
then :
printf %s "(cached) " >&6
else $as_nop
| > > | 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 |
if test "${tcl_cv_type_64bit}" = none ; then
printf "%s\n" "#define TCL_WIDE_INT_IS_LONG 1" >>confdefs.h
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
# Now check for auxiliary declarations
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct dirent64" >&5
printf %s "checking for struct dirent64... " >&6; }
if test ${tcl_cv_struct_dirent64+y}
then :
printf %s "(cached) " >&6
else $as_nop
|
| ︙ | ︙ | |||
9615 9616 9617 9618 9619 9620 9621 | printf "%s\n" "#define NO_STRING_H 1" >>confdefs.h fi #-------------------------------------------------------------------- | | | 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 |
printf "%s\n" "#define NO_STRING_H 1" >>confdefs.h
fi
#--------------------------------------------------------------------
# On some systems strstr is broken: it returns a pointer even if
# the original string is empty.
#--------------------------------------------------------------------
ac_fn_c_check_func "$LINENO" "strstr" "ac_cv_func_strstr"
if test "x$ac_cv_func_strstr" = xyes
then :
|
| ︙ | ︙ |
Changes to unix/configure.ac.
| ︙ | ︙ | |||
390 391 392 393 394 395 396 |
#--------------------------------------------------------------------
AC_CHECK_FUNC(memmove, , [
AC_DEFINE(NO_MEMMOVE, 1, [Do we have memmove()?])
AC_DEFINE(NO_STRING_H, 1, [Do we have <string.h>?]) ])
#--------------------------------------------------------------------
| | | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
#--------------------------------------------------------------------
AC_CHECK_FUNC(memmove, , [
AC_DEFINE(NO_MEMMOVE, 1, [Do we have memmove()?])
AC_DEFINE(NO_STRING_H, 1, [Do we have <string.h>?]) ])
#--------------------------------------------------------------------
# On some systems strstr is broken: it returns a pointer even if
# the original string is empty.
#--------------------------------------------------------------------
SC_TCL_CHECK_BROKEN_FUNC(strstr, [
exit(strstr("\0test", "test") ? 1 : 0);
])
|
| ︙ | ︙ |
Changes to unix/dltest/Makefile.in.
| ︙ | ︙ | |||
13 14 15 16 17 18 19 | DLTEST_SUFFIX = @DLTEST_SUFFIX@ SRC_DIR = @TCL_SRC_DIR@/unix/dltest BUILD_DIR = @builddir@ TCL_VERSION= @TCL_VERSION@ CFLAGS_DEBUG = @CFLAGS_DEBUG@ CFLAGS_OPTIMIZE = @CFLAGS_OPTIMIZE@ | | | | | | > > > > > > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
DLTEST_SUFFIX = @DLTEST_SUFFIX@
SRC_DIR = @TCL_SRC_DIR@/unix/dltest
BUILD_DIR = @builddir@
TCL_VERSION= @TCL_VERSION@
CFLAGS_DEBUG = @CFLAGS_DEBUG@
CFLAGS_OPTIMIZE = @CFLAGS_OPTIMIZE@
CFLAGS = @CFLAGS_DEFAULT@ @CFLAGS@ -DTCL_NO_DEPRECATED=1 -Wall -Wextra -Wc++-compat -Wconversion -Werror
LDFLAGS_DEBUG = @LDFLAGS_DEBUG@
LDFLAGS_OPTIMIZE = @LDFLAGS_OPTIMIZE@
LDFLAGS = @LDFLAGS_DEFAULT@ @LDFLAGS@
CC_SWITCHES = $(CFLAGS) -I${SRC_DIR}/../../generic -DTCL_MEM_DEBUG \
${SHLIB_CFLAGS} -DUSE_TCL_STUBS ${AC_FLAGS}
all: embtest tcl9pkga${SHLIB_SUFFIX} tcl9pkgb${SHLIB_SUFFIX} tcl9pkgc${SHLIB_SUFFIX} \
tcl9pkgd${SHLIB_SUFFIX} tcl9pkge${SHLIB_SUFFIX} tcl9pkgt${SHLIB_SUFFIX} tcl9pkgua${SHLIB_SUFFIX} \
tcl9pkgooa${SHLIB_SUFFIX} pkga${SHLIB_SUFFIX} pkgb${SHLIB_SUFFIX} pkgc${SHLIB_SUFFIX} pkgt${SHLIB_SUFFIX}
@if test -n "$(DLTEST_SUFFIX)"; then $(MAKE) dltest_suffix; fi
@touch ../dltest.marker
dltest_suffix: tcl9pkga${DLTEST_SUFFIX} tcl9pkgb${DLTEST_SUFFIX} tcl9pkgc${DLTEST_SUFFIX} \
tcl9pkgd${DLTEST_SUFFIX} tcl9pkge${DLTEST_SUFFIX} tcl9pkgt${DLTEST_SUFFIX} tcl9pkgua${DLTEST_SUFFIX} \
tcl9pkgooa${DLTEST_SUFFIX} pkga${DLTEST_SUFFIX} pkgb${DLTEST_SUFFIX} pkgc${DLTEST_SUFFIX} pkgt${DLTEST_SUFFIX}
@touch ../dltest.marker
embtest.o: $(SRC_DIR)/embtest.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/embtest.c
pkgπ.o: $(SRC_DIR)/pkgπ.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgπ.c
pkga.o: $(SRC_DIR)/pkga.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkga.c
pkgb.o: $(SRC_DIR)/pkgb.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgb.c
pkgc.o: $(SRC_DIR)/pkgc.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgc.c
pkgt.o: $(SRC_DIR)/pkgt.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgt.c
tcl8pkga.o: $(SRC_DIR)/pkga.c
$(CC) -o $@ -c $(CC_SWITCHES) -DTCL_MAJOR_VERSION=8 $(SRC_DIR)/pkga.c
tcl8pkgb.o: $(SRC_DIR)/pkgb.c
$(CC) -o $@ -c $(CC_SWITCHES) -DTCL_MAJOR_VERSION=8 $(SRC_DIR)/pkgb.c
tcl8pkgc.o: $(SRC_DIR)/pkgc.c
$(CC) -o $@ -c $(CC_SWITCHES) -DTCL_MAJOR_VERSION=8 $(SRC_DIR)/pkgc.c
tcl8pkgt.o: $(SRC_DIR)/pkgt.c
$(CC) -o $@ -c $(CC_SWITCHES) -DTCL_MAJOR_VERSION=8 $(SRC_DIR)/pkgt.c
pkgd.o: $(SRC_DIR)/pkgd.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgd.c
pkge.o: $(SRC_DIR)/pkge.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkge.c
pkgua.o: $(SRC_DIR)/pkgua.c
|
| ︙ | ︙ | |||
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
tcl9pkgb${SHLIB_SUFFIX}: pkgb.o
${SHLIB_LD} -o $@ pkgb.o ${SHLIB_LD_LIBS}
tcl9pkgc${SHLIB_SUFFIX}: pkgc.o
${SHLIB_LD} -o $@ pkgc.o ${SHLIB_LD_LIBS}
pkga${SHLIB_SUFFIX}: tcl8pkga.o
${SHLIB_LD} -o $@ tcl8pkga.o ${SHLIB_LD_LIBS}
pkgb${SHLIB_SUFFIX}: tcl8pkgb.o
${SHLIB_LD} -o $@ tcl8pkgb.o ${SHLIB_LD_LIBS}
pkgc${SHLIB_SUFFIX}: tcl8pkgc.o
${SHLIB_LD} -o $@ tcl8pkgc.o ${SHLIB_LD_LIBS}
tcl9pkgd${SHLIB_SUFFIX}: pkgd.o
${SHLIB_LD} -o $@ pkgd.o ${SHLIB_LD_LIBS}
tcl9pkge${SHLIB_SUFFIX}: pkge.o
${SHLIB_LD} -o $@ pkge.o ${SHLIB_LD_LIBS}
tcl9pkgua${SHLIB_SUFFIX}: pkgua.o
| > > > > > > | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
tcl9pkgb${SHLIB_SUFFIX}: pkgb.o
${SHLIB_LD} -o $@ pkgb.o ${SHLIB_LD_LIBS}
tcl9pkgc${SHLIB_SUFFIX}: pkgc.o
${SHLIB_LD} -o $@ pkgc.o ${SHLIB_LD_LIBS}
tcl9pkgt${SHLIB_SUFFIX}: pkgt.o
${SHLIB_LD} -o $@ pkgt.o ${SHLIB_LD_LIBS}
pkga${SHLIB_SUFFIX}: tcl8pkga.o
${SHLIB_LD} -o $@ tcl8pkga.o ${SHLIB_LD_LIBS}
pkgb${SHLIB_SUFFIX}: tcl8pkgb.o
${SHLIB_LD} -o $@ tcl8pkgb.o ${SHLIB_LD_LIBS}
pkgc${SHLIB_SUFFIX}: tcl8pkgc.o
${SHLIB_LD} -o $@ tcl8pkgc.o ${SHLIB_LD_LIBS}
pkgt${SHLIB_SUFFIX}: tcl8pkgt.o
${SHLIB_LD} -o $@ tcl8pkgt.o ${SHLIB_LD_LIBS}
tcl9pkgd${SHLIB_SUFFIX}: pkgd.o
${SHLIB_LD} -o $@ pkgd.o ${SHLIB_LD_LIBS}
tcl9pkge${SHLIB_SUFFIX}: pkge.o
${SHLIB_LD} -o $@ pkge.o ${SHLIB_LD_LIBS}
tcl9pkgua${SHLIB_SUFFIX}: pkgua.o
|
| ︙ | ︙ | |||
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
tcl9pkgb${DLTEST_SUFFIX}: pkgb.o
${DLTEST_LD} -o $@ pkgb.o ${SHLIB_LD_LIBS}
tcl9pkgc${DLTEST_SUFFIX}: pkgc.o
${DLTEST_LD} -o $@ pkgc.o ${SHLIB_LD_LIBS}
pkga${DLTEST_SUFFIX}: tcl8pkga.o
${DLTEST_LD} -o $@ tcl8pkga.o ${SHLIB_LD_LIBS}
pkgb${DLTEST_SUFFIX}: tcl8pkgb.o
${DLTEST_LD} -o $@ tcl8pkgb.o ${SHLIB_LD_LIBS}
pkgc${DLTEST_SUFFIX}: tcl8pkgc.o
${DLTEST_LD} -o $@ tcl8pkgc.o ${SHLIB_LD_LIBS}
tcl9pkgd${DLTEST_SUFFIX}: pkgd.o
${DLTEST_LD} -o $@ pkgd.o ${SHLIB_LD_LIBS}
tcl9pkge${DLTEST_SUFFIX}: pkge.o
${DLTEST_LD} -o $@ pkge.o ${SHLIB_LD_LIBS}
tcl9pkgua${DLTEST_SUFFIX}: pkgua.o
| > > > > > > | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
tcl9pkgb${DLTEST_SUFFIX}: pkgb.o
${DLTEST_LD} -o $@ pkgb.o ${SHLIB_LD_LIBS}
tcl9pkgc${DLTEST_SUFFIX}: pkgc.o
${DLTEST_LD} -o $@ pkgc.o ${SHLIB_LD_LIBS}
tcl9pkgt${DLTEST_SUFFIX}: pkgt.o
${DLTEST_LD} -o $@ pkgt.o ${SHLIB_LD_LIBS}
pkga${DLTEST_SUFFIX}: tcl8pkga.o
${DLTEST_LD} -o $@ tcl8pkga.o ${SHLIB_LD_LIBS}
pkgb${DLTEST_SUFFIX}: tcl8pkgb.o
${DLTEST_LD} -o $@ tcl8pkgb.o ${SHLIB_LD_LIBS}
pkgc${DLTEST_SUFFIX}: tcl8pkgc.o
${DLTEST_LD} -o $@ tcl8pkgc.o ${SHLIB_LD_LIBS}
pkgt${DLTEST_SUFFIX}: tcl8pkgt.o
${DLTEST_LD} -o $@ tcl8pkgt.o ${SHLIB_LD_LIBS}
tcl9pkgd${DLTEST_SUFFIX}: pkgd.o
${DLTEST_LD} -o $@ pkgd.o ${SHLIB_LD_LIBS}
tcl9pkge${DLTEST_SUFFIX}: pkge.o
${DLTEST_LD} -o $@ pkge.o ${SHLIB_LD_LIBS}
tcl9pkgua${DLTEST_SUFFIX}: pkgua.o
|
| ︙ | ︙ |
Changes to unix/dltest/embtest.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#include "tcl.h"
#include <stdio.h>
MODULE_SCOPE const TclStubs *tclStubsPtr;
int main(int argc, char **argv) {
const char *version;
int exitcode = 0;
if (tclStubsPtr != NULL) {
printf("ERROR: stub table is already initialized");
exitcode = 1;
}
tclStubsPtr = NULL;
version = Tcl_SetPanicProc(Tcl_ConsolePanic);
if (tclStubsPtr == NULL) {
printf("ERROR: Tcl_SetPanicProc does not initialize the stub table\n");
exitcode = 1;
}
tclStubsPtr = NULL;
version = Tcl_InitSubsystems();
if (tclStubsPtr == NULL) {
printf("ERROR: Tcl_InitSubsystems does not initialize the stub table\n");
exitcode = 1;
}
tclStubsPtr = NULL;
version = Tcl_FindExecutable(argv[0]);
if (tclStubsPtr == NULL) {
printf("ERROR: Tcl_FindExecutable does not initialize the stub table\n");
exitcode = 1;
}
if (!exitcode) {
printf("All OK!\n");
}
return exitcode;
}
| > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#include "tcl.h"
#include <stdio.h>
MODULE_SCOPE const TclStubs *tclStubsPtr;
int main(int argc, char **argv) {
const char *version;
int exitcode = 0;
(void)argc;
if (tclStubsPtr != NULL) {
printf("ERROR: stub table is already initialized");
exitcode = 1;
}
tclStubsPtr = NULL;
version = Tcl_SetPanicProc(Tcl_ConsolePanic);
if (tclStubsPtr == NULL) {
printf("ERROR: Tcl_SetPanicProc does not initialize the stub table\n");
exitcode = 1;
}
tclStubsPtr = NULL;
version = Tcl_InitSubsystems();
if (tclStubsPtr == NULL) {
printf("ERROR: Tcl_InitSubsystems does not initialize the stub table\n");
exitcode = 1;
}
tclStubsPtr = NULL;
version = Tcl_FindExecutable(argv[0]);
if (version != NULL) {
printf("Tcl_FindExecutable gives version %s\n", version);
}
if (tclStubsPtr == NULL) {
printf("ERROR: Tcl_FindExecutable does not initialize the stub table\n");
exitcode = 1;
}
if (!exitcode) {
printf("All OK!\n");
}
return exitcode;
}
|
Changes to unix/dltest/pkga.c.
| ︙ | ︙ | |||
47 48 49 50 51 52 53 |
Tcl_WrongNumArgs(interp, 1, objv, "string1 string2");
return TCL_ERROR;
}
str1 = Tcl_GetStringFromObj(objv[1], &len1);
str2 = Tcl_GetStringFromObj(objv[2], &len2);
if (len1 == len2) {
| | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
Tcl_WrongNumArgs(interp, 1, objv, "string1 string2");
return TCL_ERROR;
}
str1 = Tcl_GetStringFromObj(objv[1], &len1);
str2 = Tcl_GetStringFromObj(objv[2], &len2);
if (len1 == len2) {
result = (Tcl_UtfNcmp(str1, str2, (size_t)len1) == 0);
} else {
result = 0;
}
Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
return TCL_OK;
}
|
| ︙ | ︙ |
Changes to unix/dltest/pkgb.c.
| ︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #undef STATIC_BUILD #include "tcl.h" /* *---------------------------------------------------------------------- * * Pkgb_SubObjCmd -- * * This procedure is invoked to process the "pkgb_sub" Tcl command. It | > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #undef STATIC_BUILD #include "tcl.h" #if defined(_WIN32) && defined(_MSC_VER) # define snprintf _snprintf #endif /* *---------------------------------------------------------------------- * * Pkgb_SubObjCmd -- * * This procedure is invoked to process the "pkgb_sub" Tcl command. It |
| ︙ | ︙ | |||
44 45 46 47 48 49 50 |
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "num num");
return TCL_ERROR;
}
if ((Tcl_GetIntFromObj(interp, objv[1], &first) != TCL_OK)
|| (Tcl_GetIntFromObj(interp, objv[2], &second) != TCL_OK)) {
char buf[TCL_INTEGER_SPACE];
| | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "num num");
return TCL_ERROR;
}
if ((Tcl_GetIntFromObj(interp, objv[1], &first) != TCL_OK)
|| (Tcl_GetIntFromObj(interp, objv[2], &second) != TCL_OK)) {
char buf[TCL_INTEGER_SPACE];
snprintf(buf, sizeof(buf), "%d", Tcl_GetErrorLine(interp));
Tcl_AppendResult(interp, " in line: ", buf, NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewIntObj(first - second));
return TCL_OK;
}
|
| ︙ | ︙ | |||
101 102 103 104 105 106 107 |
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv, "arg1 arg2 num");
return TCL_ERROR;
}
if (Tcl_GetWideIntFromObj(interp, objv[3], &numChars) != TCL_OK) {
return TCL_ERROR;
}
| | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv, "arg1 arg2 num");
return TCL_ERROR;
}
if (Tcl_GetWideIntFromObj(interp, objv[3], &numChars) != TCL_OK) {
return TCL_ERROR;
}
result = Tcl_UtfNcmp(Tcl_GetString(objv[1]), Tcl_GetString(objv[2]), (size_t)numChars);
Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ |
Changes to unix/dltest/pkgooa.c.
| ︙ | ︙ | |||
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
,NULL
#endif
#ifdef Tcl_GetClassOfObject
,NULL
#endif
#ifdef Tcl_GetObjectClassName
,NULL
#endif
};
DLLEXPORT int
Pkgooa_Init(
Tcl_Interp *interp) /* Interpreter in which the package is to be
* made available. */
| > > > > > > > > > | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
,NULL
#endif
#ifdef Tcl_GetClassOfObject
,NULL
#endif
#ifdef Tcl_GetObjectClassName
,NULL
#endif
#ifdef Tcl_MethodIsType2
,NULL
#endif
#ifdef Tcl_NewInstanceMethod2
,NULL
#endif
#ifdef Tcl_NewMethod2
,NULL
#endif
};
DLLEXPORT int
Pkgooa_Init(
Tcl_Interp *interp) /* Interpreter in which the package is to be
* made available. */
|
| ︙ | ︙ |
Added unix/dltest/pkgt.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
/*
* pkgt.c --
*
* This file contains a simple Tcl package "pkgt" that is intended for
* testing the Tcl dynamic loading facilities.
*
* Copyright © 1995 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#undef STATIC_BUILD
#include "tcl.h"
static int TraceProc2 (
void *clientData,
Tcl_Interp *interp,
ptrdiff_t level,
const char *command,
Tcl_Command commandInfo,
ptrdiff_t objc,
struct Tcl_Obj *const *objv)
{
(void)clientData;
(void)interp;
(void)level;
(void)command;
(void)commandInfo;
(void)objc;
(void)objv;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Pkgt_EqObjCmd2 --
*
* This procedure is invoked to process the "pkgt_eq" Tcl command. It
* expects two arguments and returns 1 if they are the same, 0 if they
* are different.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
static int
Pkgt_EqObjCmd2(
void *dummy, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
ptrdiff_t objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_WideInt result;
const char *str1, *str2;
ptrdiff_t len1, len2;
(void)dummy;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "string1 string2");
return TCL_ERROR;
}
str1 = Tcl_GetStringFromObj(objv[1], &len1);
str2 = Tcl_GetStringFromObj(objv[2], &len2);
if (len1 == len2) {
result = (Tcl_UtfNcmp(str1, str2, (size_t) len1) == 0);
} else {
result = 0;
}
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(result));
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Pkgt_Init --
*
* This is a package initialization procedure, which is called by Tcl
* when this package is to be added to an interpreter.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
DLLEXPORT int
Pkgt_Init(
Tcl_Interp *interp) /* Interpreter in which the package is to be
* made available. */
{
int code;
if (Tcl_InitStubs(interp, "8.7-", 0) == NULL) {
return TCL_ERROR;
}
code = Tcl_PkgProvide(interp, "pkgt", "1.0");
if (code != TCL_OK) {
return code;
}
Tcl_CreateObjCommand2(interp, "pkgt_eq", Pkgt_EqObjCmd2, NULL, NULL);
Tcl_CreateObjTrace2(interp, 0, 0, TraceProc2, NULL, NULL);
return TCL_OK;
}
|
Changes to unix/dltest/pkgua.c.
| ︙ | ︙ | |||
134 135 136 137 138 139 140 |
Tcl_WrongNumArgs(interp, 1, objv, "string1 string2");
return TCL_ERROR;
}
str1 = Tcl_GetStringFromObj(objv[1], &len1);
str2 = Tcl_GetStringFromObj(objv[2], &len2);
if (len1 == len2) {
| | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
Tcl_WrongNumArgs(interp, 1, objv, "string1 string2");
return TCL_ERROR;
}
str1 = Tcl_GetStringFromObj(objv[1], &len1);
str2 = Tcl_GetStringFromObj(objv[2], &len2);
if (len1 == len2) {
result = (Tcl_UtfNcmp(str1, str2, (size_t) len1) == 0);
} else {
result = 0;
}
Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
return TCL_OK;
}
|
| ︙ | ︙ |
Changes to unix/install-sh.
| ︙ | ︙ | |||
325 326 327 328 329 330 331 | trap ' ret=$? rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null exit $ret ' 0 # Because "mkdir -p" follows existing symlinks and we likely work | | | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
trap '
ret=$?
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
exit $ret
' 0
# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p'.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
|
| ︙ | ︙ |
Changes to unix/tcl.m4.
| ︙ | ︙ | |||
2374 2375 2376 2377 2378 2379 2380 | # HAVE_STRUCT_DIRENT64, HAVE_DIR64 # HAVE_STRUCT_STAT64 # HAVE_TYPE_OFF64_T # #-------------------------------------------------------------------- AC_DEFUN([SC_TCL_64BIT_FLAGS], [ | | | > | 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 |
# HAVE_STRUCT_DIRENT64, HAVE_DIR64
# HAVE_STRUCT_STAT64
# HAVE_TYPE_OFF64_T
#
#--------------------------------------------------------------------
AC_DEFUN([SC_TCL_64BIT_FLAGS], [
AC_MSG_CHECKING([if 'long' and 'long long' have the same size (64-bit)?])
AC_CACHE_VAL(tcl_cv_type_64bit,[
tcl_cv_type_64bit=none
# See if we could use long anyway Note that we substitute in the
# type that is our current guess for a 64-bit type inside this check
# program, so it should be modified only carefully...
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[switch (0) {
case 1: case (sizeof(long long)==sizeof(long)): ;
}]])],[tcl_cv_type_64bit="long long"],[])])
if test "${tcl_cv_type_64bit}" = none ; then
AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, ['long' and 'long long' have the same size])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
# Now check for auxiliary declarations
AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <dirent.h>]], [[struct dirent64 p;]])],
[tcl_cv_struct_dirent64=yes],[tcl_cv_struct_dirent64=no])])
if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
AC_DEFINE(HAVE_STRUCT_DIRENT64, 1, [Is 'struct dirent64' in <sys/types.h>?])
|
| ︙ | ︙ |
Changes to unix/tclAppInit.c.
| ︙ | ︙ | |||
87 88 89 90 91 92 93 |
#ifdef TCL_LOCAL_MAIN_HOOK
TCL_LOCAL_MAIN_HOOK(&argc, &argv);
#elif (TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6) && (!defined(_WIN32) || defined(UNICODE))
/* New in Tcl 8.7. This doesn't work on Windows without UNICODE */
TclZipfs_AppHook(&argc, &argv);
#endif
| | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
#ifdef TCL_LOCAL_MAIN_HOOK
TCL_LOCAL_MAIN_HOOK(&argc, &argv);
#elif (TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6) && (!defined(_WIN32) || defined(UNICODE))
/* New in Tcl 8.7. This doesn't work on Windows without UNICODE */
TclZipfs_AppHook(&argc, &argv);
#endif
Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
return 0; /* Needed only to prevent compiler warning. */
}
/*
*----------------------------------------------------------------------
*
* Tcl_AppInit --
|
| ︙ | ︙ |
Changes to unix/tclConfig.h.in.
| ︙ | ︙ | |||
440 441 442 443 444 445 446 | /* Do we allow unloading of shared libraries? */ #undef TCL_UNLOAD_DLLS /* Does this platform have wide high-resolution clicks? */ #undef TCL_WIDE_CLICKS | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | /* Do we allow unloading of shared libraries? */ #undef TCL_UNLOAD_DLLS /* Does this platform have wide high-resolution clicks? */ #undef TCL_WIDE_CLICKS /* 'long' and 'long long' have the same size */ #undef TCL_WIDE_INT_IS_LONG /* Tcl with external libtommath */ #undef TCL_WITH_EXTERNAL_TOMMATH /* Is getcwd Posix-compliant? */ #undef USEGETWD |
| ︙ | ︙ |
Changes to unix/tclLoadDl.c.
| ︙ | ︙ | |||
187 188 189 190 191 192 193 |
native = Tcl_DStringAppend(&newName, native, TCL_INDEX_NONE);
proc = dlsym(handle, native); /* INTL: Native. */
Tcl_DStringFree(&newName);
}
#ifdef __cplusplus
if (proc == NULL) {
char buf[32];
| | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
native = Tcl_DStringAppend(&newName, native, TCL_INDEX_NONE);
proc = dlsym(handle, native); /* INTL: Native. */
Tcl_DStringFree(&newName);
}
#ifdef __cplusplus
if (proc == NULL) {
char buf[32];
snprintf(buf, sizeof(buf), "%d", (int)Tcl_DStringLength(&ds));
Tcl_DStringInit(&newName);
TclDStringAppendLiteral(&newName, "__Z");
Tcl_DStringAppend(&newName, buf, TCL_INDEX_NONE);
Tcl_DStringAppend(&newName, Tcl_DStringValue(&ds), TCL_INDEX_NONE);
TclDStringAppendLiteral(&newName, "P10Tcl_Interp");
native = Tcl_DStringValue(&newName);
proc = dlsym(handle, native + 1); /* INTL: Native. */
|
| ︙ | ︙ |
Changes to unix/tclUnixChan.c.
| ︙ | ︙ | |||
592 593 594 595 596 597 598 |
Tcl_Interp *interp, /* For error reporting - can be NULL. */
const char *optionName, /* Which option to set? */
const char *value) /* New value for option. */
{
TtyState *fsPtr = (TtyState *)instanceData;
size_t len, vlen;
TtyAttrs tty;
| | | 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
Tcl_Interp *interp, /* For error reporting - can be NULL. */
const char *optionName, /* Which option to set? */
const char *value) /* New value for option. */
{
TtyState *fsPtr = (TtyState *)instanceData;
size_t len, vlen;
TtyAttrs tty;
Tcl_Size argc;
const char **argv;
struct termios iostate;
len = strlen(optionName);
vlen = strlen(value);
/*
|
| ︙ | ︙ | |||
728 729 730 731 732 733 734 |
/*
* Option -ttycontrol {DTR 1 RTS 0 BREAK 0}
*/
if ((len > 4) && (strncmp(optionName, "-ttycontrol", len) == 0)) {
#if defined(TIOCMGET) && defined(TIOCMSET)
int control, flag;
| | | 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 |
/*
* Option -ttycontrol {DTR 1 RTS 0 BREAK 0}
*/
if ((len > 4) && (strncmp(optionName, "-ttycontrol", len) == 0)) {
#if defined(TIOCMGET) && defined(TIOCMSET)
int control, flag;
Tcl_Size i;
if (Tcl_SplitList(interp, value, &argc, &argv) == TCL_ERROR) {
return TCL_ERROR;
}
if ((argc % 2) == 1) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
| ︙ | ︙ | |||
1005 1006 1007 1008 1009 1010 1011 |
Tcl_DStringAppendElement(dsPtr, "-mode");
}
if (len==0 || (len>2 && strncmp(optionName, "-mode", len)==0)) {
TtyAttrs tty;
valid = 1;
TtyGetAttributes(fsPtr->fileState.fd, &tty);
| | | 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 |
Tcl_DStringAppendElement(dsPtr, "-mode");
}
if (len==0 || (len>2 && strncmp(optionName, "-mode", len)==0)) {
TtyAttrs tty;
valid = 1;
TtyGetAttributes(fsPtr->fileState.fd, &tty);
snprintf(buf, sizeof(buf), "%d,%c,%d,%d", tty.baud, tty.parity, tty.data, tty.stop);
Tcl_DStringAppendElement(dsPtr, buf);
}
/*
* Get option -xchar
*/
|
| ︙ | ︙ | |||
1051 1052 1053 1054 1055 1056 1057 | valid = 1; GETREADQUEUE(fsPtr->fileState.fd, inQueue); GETWRITEQUEUE(fsPtr->fileState.fd, outQueue); inBuffered = Tcl_InputBuffered(fsPtr->fileState.channel); outBuffered = Tcl_OutputBuffered(fsPtr->fileState.channel); | | | | 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 |
valid = 1;
GETREADQUEUE(fsPtr->fileState.fd, inQueue);
GETWRITEQUEUE(fsPtr->fileState.fd, outQueue);
inBuffered = Tcl_InputBuffered(fsPtr->fileState.channel);
outBuffered = Tcl_OutputBuffered(fsPtr->fileState.channel);
snprintf(buf, sizeof(buf), "%d", inBuffered+inQueue);
Tcl_DStringAppendElement(dsPtr, buf);
snprintf(buf, sizeof(buf), "%d", outBuffered+outQueue);
Tcl_DStringAppendElement(dsPtr, buf);
}
#if defined(TIOCMGET)
/*
* Get option -ttystatus
* Option is readonly and returned by [fconfigure chan -ttystatus] but not
|
| ︙ | ︙ | |||
1092 1093 1094 1095 1096 1097 1098 |
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't read terminal size: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
| | | | 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 |
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't read terminal size: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
snprintf(buf, sizeof(buf), "%d", ws.ws_col);
Tcl_DStringAppendElement(dsPtr, buf);
snprintf(buf, sizeof(buf), "%d", ws.ws_row);
Tcl_DStringAppendElement(dsPtr, buf);
}
#endif /* TIOCGWINSZ */
if (valid) {
return TCL_OK;
}
|
| ︙ | ︙ | |||
1460 1461 1462 1463 1464 1465 1466 |
/*
* Only allow setting mark/space parity on platforms that support it Make
* sure to allow for the case where strchr is a macro. [Bug: 5089]
*
* We cannot if/else/endif the strchr arguments, it has to be the whole
* function. On AIX this function is apparently a macro, and macros do
| | | 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 |
/*
* Only allow setting mark/space parity on platforms that support it Make
* sure to allow for the case where strchr is a macro. [Bug: 5089]
*
* We cannot if/else/endif the strchr arguments, it has to be the whole
* function. On AIX this function is apparently a macro, and macros do
* not allow preprocessor directives in their arguments.
*/
if (
#if defined(PAREXT)
strchr("noems", parity)
#else
strchr("noe", parity)
|
| ︙ | ︙ | |||
1649 1650 1651 1652 1653 1654 1655 | * being set up is a device and has the same major/minor as the * initial std FDs (beware reopening!) but that's nearly as messy. */ translation = "auto crlf"; channelTypePtr = &ttyChannelType; TtyInit(fd); | | | | 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 |
* being set up is a device and has the same major/minor as the
* initial std FDs (beware reopening!) but that's nearly as messy.
*/
translation = "auto crlf";
channelTypePtr = &ttyChannelType;
TtyInit(fd);
snprintf(channelName, sizeof(channelName), "serial%d", fd);
} else
#endif /* SUPPORTS_TTY */
{
translation = NULL;
channelTypePtr = &fileChannelType;
snprintf(channelName, sizeof(channelName), "file%d", fd);
}
fsPtr = (TtyState *)Tcl_Alloc(sizeof(TtyState));
fsPtr->fileState.validMask = channelPermissions | TCL_EXCEPTION;
fsPtr->fileState.fd = fd;
#ifdef SUPPORTS_TTY
if (channelTypePtr == &ttyChannelType) {
|
| ︙ | ︙ | |||
1710 1711 1712 1713 1714 1715 1716 |
*
*----------------------------------------------------------------------
*/
Tcl_Channel
Tcl_MakeFileChannel(
void *handle, /* OS level handle. */
| | | | | 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 |
*
*----------------------------------------------------------------------
*/
Tcl_Channel
Tcl_MakeFileChannel(
void *handle, /* OS level handle. */
int mode) /* OR'ed combination of TCL_READABLE and
* TCL_WRITABLE to indicate file mode. */
{
TtyState *fsPtr;
char channelName[16 + TCL_INTEGER_SPACE];
int fd = PTR2INT(handle);
const Tcl_ChannelType *channelTypePtr;
struct stat buf;
if (mode == 0) {
return NULL;
}
#ifdef SUPPORTS_TTY
if (isatty(fd)) {
channelTypePtr = &ttyChannelType;
snprintf(channelName, sizeof(channelName), "serial%d", fd);
} else
#endif /* SUPPORTS_TTY */
if (fstat(fd, &buf) == 0 && S_ISSOCK(buf.st_mode)) {
struct sockaddr sockaddr;
socklen_t sockaddrLen = sizeof(sockaddr);
sockaddr.sa_family = AF_UNSPEC;
if ((getsockname(fd, (struct sockaddr *)&sockaddr, &sockaddrLen) == 0)
&& (sockaddrLen > 0)
&& (sockaddr.sa_family == AF_INET
|| sockaddr.sa_family == AF_INET6)) {
return (Tcl_Channel)TclpMakeTcpClientChannelMode(INT2PTR(fd), mode);
}
goto normalChannelAfterAll;
} else {
normalChannelAfterAll:
channelTypePtr = &fileChannelType;
snprintf(channelName, sizeof(channelName), "file%d", fd);
}
fsPtr = (TtyState *)Tcl_Alloc(sizeof(TtyState));
fsPtr->fileState.fd = fd;
fsPtr->fileState.validMask = mode | TCL_EXCEPTION;
fsPtr->fileState.channel = Tcl_CreateChannel(channelTypePtr, channelName,
fsPtr, mode);
|
| ︙ | ︙ |
Changes to unix/tclUnixCompat.c.
| ︙ | ︙ | |||
730 731 732 733 734 735 736 | #endif /* NEED_COPYGRP */ /* *--------------------------------------------------------------------------- * * CopyHostent -- * | | | 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 | #endif /* NEED_COPYGRP */ /* *--------------------------------------------------------------------------- * * CopyHostent -- * * Copies string fields of the hostent structure to the private buffer, * honouring the size of the buffer. * * Results: * Number of bytes copied on success or -1 on error (errno = ERANGE) * * Side effects: * None |
| ︙ | ︙ |
Changes to unix/tclUnixFCmd.c.
1 2 3 | /* * tclUnixFCmd.c * | | | 1 2 3 4 5 6 7 8 9 10 11 | /* * tclUnixFCmd.c * * This file implements the Unix specific portion of file manipulation * subcommands of the "file" command. All filename arguments should * already be translated to native format. * * Copyright © 1996-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. |
| ︙ | ︙ | |||
339 340 341 342 343 344 345 |
return TCL_OK;
}
if (errno == ENOTEMPTY) {
errno = EEXIST;
}
/*
| | | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
return TCL_OK;
}
if (errno == ENOTEMPTY) {
errno = EEXIST;
}
/*
* IRIX returns EIO when you attempt to move a directory into itself. We
* just map EIO to EINVAL get the right message on SGI. Most platforms
* don't return EIO except in really strange cases.
*/
if (errno == EIO) {
errno = EINVAL;
}
|
| ︙ | ︙ | |||
545 546 547 548 549 550 551 |
const Tcl_StatBuf *statBufPtr,
/* Used to determine mode and blocksize. */
int dontCopyAtts) /* If flag set, don't copy attributes. */
{
int srcFd, dstFd;
size_t blockSize; /* Optimal I/O blocksize for filesystem */
char *buffer; /* Data buffer for copy */
| | | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
const Tcl_StatBuf *statBufPtr,
/* Used to determine mode and blocksize. */
int dontCopyAtts) /* If flag set, don't copy attributes. */
{
int srcFd, dstFd;
size_t blockSize; /* Optimal I/O blocksize for filesystem */
char *buffer; /* Data buffer for copy */
ssize_t nread;
#ifdef DJGPP
#define BINMODE |O_BINARY
#else
#define BINMODE
#endif /* DJGPP */
|
| ︙ | ︙ | |||
602 603 604 605 606 607 608 |
if (blockSize <= 0) {
blockSize = DEFAULT_COPY_BLOCK_SIZE;
}
buffer = (char *)Tcl_Alloc(blockSize);
while (1) {
nread = read(srcFd, buffer, blockSize);
| | | | | | 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
if (blockSize <= 0) {
blockSize = DEFAULT_COPY_BLOCK_SIZE;
}
buffer = (char *)Tcl_Alloc(blockSize);
while (1) {
nread = read(srcFd, buffer, blockSize);
if ((nread == -1) || (nread == 0)) {
break;
}
if (write(dstFd, buffer, nread) != nread) {
nread = -1;
break;
}
}
Tcl_Free(buffer);
close(srcFd);
if ((close(dstFd) != 0) || (nread == -1)) {
unlink(dst); /* INTL: Native. */
return TCL_ERROR;
}
if (!dontCopyAtts && CopyFileAtts(src, dst, statBufPtr) == TCL_ERROR) {
/*
* The copy succeeded, but setting the permissions failed, so be in a
* consistent state, we remove the file that was created by the copy.
|
| ︙ | ︙ | |||
729 730 731 732 733 734 735 | /* *--------------------------------------------------------------------------- * * TclpObjCopyDirectory -- * * Recursively copies a directory. The target directory dst must not * already exist. Note that this function does not merge two directory | | | 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 | /* *--------------------------------------------------------------------------- * * TclpObjCopyDirectory -- * * Recursively copies a directory. The target directory dst must not * already exist. Note that this function does not merge two directory * hierarchies, even if the target directory is an empty directory. * * Results: * If the directory was successfully copied, returns TCL_OK. Otherwise * the return value is TCL_ERROR, errno is set to indicate the error, and * the pathname of the file that caused the error is stored in errorPtr. * See TclpObjCreateDirectory and TclpObjCopyFile for a description of * possible values for errno. |
| ︙ | ︙ | |||
1500 1501 1502 1503 1504 1505 1506 |
int result;
const char *native;
if (Tcl_GetWideIntFromObj(NULL, attributePtr, &gid) != TCL_OK) {
Tcl_DString ds;
struct group *groupPtr = NULL;
const char *string;
| | | 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 |
int result;
const char *native;
if (Tcl_GetWideIntFromObj(NULL, attributePtr, &gid) != TCL_OK) {
Tcl_DString ds;
struct group *groupPtr = NULL;
const char *string;
Tcl_Size length;
string = Tcl_GetStringFromObj(attributePtr, &length);
native = Tcl_UtfToExternalDString(NULL, string, length, &ds);
groupPtr = TclpGetGrNam(native); /* INTL: Native. */
Tcl_DStringFree(&ds);
|
| ︙ | ︙ | |||
1567 1568 1569 1570 1571 1572 1573 |
int result;
const char *native;
if (Tcl_GetWideIntFromObj(NULL, attributePtr, &uid) != TCL_OK) {
Tcl_DString ds;
struct passwd *pwPtr = NULL;
const char *string;
| | | 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 |
int result;
const char *native;
if (Tcl_GetWideIntFromObj(NULL, attributePtr, &uid) != TCL_OK) {
Tcl_DString ds;
struct passwd *pwPtr = NULL;
const char *string;
Tcl_Size length;
string = Tcl_GetStringFromObj(attributePtr, &length);
native = Tcl_UtfToExternalDString(NULL, string, length, &ds);
pwPtr = TclpGetPwNam(native); /* INTL: Native. */
Tcl_DStringFree(&ds);
|
| ︙ | ︙ | |||
1943 1944 1945 1946 1947 1948 1949 |
* at the end of a path part that is already
* normalized. I.e. this is not the index of
* the byte just after the separator. */
{
const char *currentPathEndPosition;
char cur;
| | | 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 |
* at the end of a path part that is already
* normalized. I.e. this is not the index of
* the byte just after the separator. */
{
const char *currentPathEndPosition;
char cur;
Tcl_Size pathLen;
const char *path = Tcl_GetStringFromObj(pathPtr, &pathLen);
Tcl_DString ds;
const char *nativePath;
#ifndef NO_REALPATH
char normPath[MAXPATHLEN];
#endif
|
| ︙ | ︙ | |||
2048 2049 2050 2051 2052 2053 2054 |
*/
return 0;
}
nativePath = Tcl_UtfToExternalDString(NULL, path,nextCheckpoint, &ds);
if (Realpath(nativePath, normPath) != NULL) {
| | | 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 |
*/
return 0;
}
nativePath = Tcl_UtfToExternalDString(NULL, path,nextCheckpoint, &ds);
if (Realpath(nativePath, normPath) != NULL) {
Tcl_Size newNormLen;
wholeStringOk:
newNormLen = strlen(normPath);
if ((newNormLen == Tcl_DStringLength(&ds))
&& (strcmp(normPath, nativePath) == 0)) {
/*
* The original path is unchanged.
|
| ︙ | ︙ | |||
2167 2168 2169 2170 2171 2172 2173 |
Tcl_Obj *basenameObj,
Tcl_Obj *extensionObj,
Tcl_Obj *resultingNameObj)
{
Tcl_DString templ, tmp;
const char *string;
int fd;
| | | 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 |
Tcl_Obj *basenameObj,
Tcl_Obj *extensionObj,
Tcl_Obj *resultingNameObj)
{
Tcl_DString templ, tmp;
const char *string;
int fd;
Tcl_Size length;
/*
* We should also check against making more then TMP_MAX of these.
*/
if (dirObj) {
string = Tcl_GetStringFromObj(dirObj, &length);
|
| ︙ | ︙ |
Changes to unix/tclUnixFile.c.
| ︙ | ︙ | |||
696 697 698 699 700 701 702 | * This function replaces the library version of getcwd(). * * Results: * The input and output are filesystem paths in native form. The result * is either the given clientData, if the working directory hasn't * changed, or a new clientData (owned by our caller), giving the new * native path, or NULL if the current directory could not be determined. | | | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | * This function replaces the library version of getcwd(). * * Results: * The input and output are filesystem paths in native form. The result * is either the given clientData, if the working directory hasn't * changed, or a new clientData (owned by our caller), giving the new * native path, or NULL if the current directory could not be determined. * If NULL is returned, the caller can examine the standard Posix error * codes to determine the cause of the problem. * * Side effects: * None. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ | |||
942 943 944 945 946 947 948 |
/*
* Check symbolic link flag first, since we prefer to create these.
*/
if (linkAction & TCL_CREATE_SYMBOLIC_LINK) {
Tcl_DString ds;
Tcl_Obj *transPtr;
| | | 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 |
/*
* Check symbolic link flag first, since we prefer to create these.
*/
if (linkAction & TCL_CREATE_SYMBOLIC_LINK) {
Tcl_DString ds;
Tcl_Obj *transPtr;
Tcl_Size length;
/*
* Now we don't want to link to the absolute, normalized path.
* Relative links are quite acceptable (but links to ~user are not
* -- these must be expanded first).
*/
|
| ︙ | ︙ | |||
1083 1084 1085 1086 1087 1088 1089 |
TclNativeCreateNativeRep(
Tcl_Obj *pathPtr)
{
char *nativePathPtr;
const char *str;
Tcl_DString ds;
Tcl_Obj *validPathPtr;
| | | 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 |
TclNativeCreateNativeRep(
Tcl_Obj *pathPtr)
{
char *nativePathPtr;
const char *str;
Tcl_DString ds;
Tcl_Obj *validPathPtr;
Tcl_Size len;
if (TclFSCwdIsNative()) {
/*
* The cwd is native, which means we can use the translated path
* without worrying about normalization (this will also usually be
* shorter so the utf-to-external conversion will be somewhat faster).
*/
|
| ︙ | ︙ |
Changes to unix/tclUnixInit.c.
| ︙ | ︙ | |||
451 452 453 454 455 456 457 |
*
*-------------------------------------------------------------------------
*/
void
TclpInitLibraryPath(
char **valuePtr,
| | | | | | 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
*
*-------------------------------------------------------------------------
*/
void
TclpInitLibraryPath(
char **valuePtr,
TCL_HASH_TYPE *lengthPtr,
Tcl_Encoding *encodingPtr)
{
#define LIBRARY_SIZE 32
Tcl_Obj *pathPtr, *objPtr;
const char *str;
Tcl_DString buffer;
TclNewObj(pathPtr);
/*
* Look for the library relative to the TCL_LIBRARY env variable. If the
* last dirname in the TCL_LIBRARY path does not match the last dirname in
* the installLib variable, use the last dir name of installLib in
* addition to the original TCL_LIBRARY path.
*/
str = getenv("TCL_LIBRARY"); /* INTL: Native. */
Tcl_ExternalToUtfDStringEx(NULL, NULL, str, TCL_INDEX_NONE, TCL_ENCODING_PROFILE_TCL8, &buffer, NULL);
str = Tcl_DStringValue(&buffer);
if ((str != NULL) && (str[0] != '\0')) {
Tcl_DString ds;
Tcl_Size pathc;
const char **pathv;
char installLib[LIBRARY_SIZE];
Tcl_DStringInit(&ds);
/*
* Initialize the substrings used when locating an executable. The
* installLib variable computes the path as though the executable is
* installed.
*/
snprintf(installLib, sizeof(installLib), "lib/tcl%s", TCL_VERSION);
/*
* If TCL_LIBRARY is set, search there.
*/
Tcl_ListObjAppendElement(NULL, pathPtr, Tcl_NewStringObj(str, TCL_INDEX_NONE));
|
| ︙ | ︙ | |||
540 541 542 543 544 545 546 |
objPtr = Tcl_NewStringObj(str, TCL_INDEX_NONE);
Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);
}
}
Tcl_DStringFree(&buffer);
*encodingPtr = Tcl_GetEncoding(NULL, NULL);
| > > > > > > > | > | | | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
objPtr = Tcl_NewStringObj(str, TCL_INDEX_NONE);
Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);
}
}
Tcl_DStringFree(&buffer);
*encodingPtr = Tcl_GetEncoding(NULL, NULL);
/*
* Note lengthPtr is (TCL_HASH_TYPE *) which is unsigned so cannot
* pass directly to Tcl_GetStringFromObj.
* TODO - why is the type TCL_HASH_TYPE anyways?
*/
Tcl_Size length;
str = Tcl_GetStringFromObj(pathPtr, &length);
*lengthPtr = length;
*valuePtr = (char *)Tcl_Alloc(length + 1);
memcpy(*valuePtr, str, length + 1);
Tcl_DecrRefCount(pathPtr);
}
/*
*---------------------------------------------------------------------------
*
* TclpSetInitialEncodings --
|
| ︙ | ︙ | |||
897 898 899 900 901 902 903 |
GetSystemInfo(&sysInfo);
if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 22000) {
osInfo.dwMajorVersion = 11;
}
Tcl_SetVar2(interp, "tcl_platform", "os", "Windows NT", TCL_GLOBAL_ONLY);
| | | 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 |
GetSystemInfo(&sysInfo);
if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 22000) {
osInfo.dwMajorVersion = 11;
}
Tcl_SetVar2(interp, "tcl_platform", "os", "Windows NT", TCL_GLOBAL_ONLY);
snprintf(buffer, sizeof(buffer), "%d.%d", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY);
if (sysInfo.wProcessorArchitecture < NUMPROCESSORS) {
Tcl_SetVar2(interp, "tcl_platform", "machine",
processors[sysInfo.wProcessorArchitecture],
TCL_GLOBAL_ONLY);
}
|
| ︙ | ︙ | |||
994 995 996 997 998 999 1000 | /* *---------------------------------------------------------------------- * * TclpFindVariable -- * * Locate the entry in environ for a given name. On Unix this routine is | | | | | | | 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 |
/*
*----------------------------------------------------------------------
*
* TclpFindVariable --
*
* Locate the entry in environ for a given name. On Unix this routine is
* case sensitive, on Windows this matches mixed case.
*
* Results:
* The return value is the index in environ of an entry with the name
* "name", or -1 if there is no such entry. The integer at *lengthPtr is
* filled in with the length of name (if a matching entry is found) or
* the length of the environ array (if no matching entry is found).
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclpFindVariable(
const char *name, /* Name of desired environment variable
* (native). */
Tcl_Size *lengthPtr) /* Used to return length of name (for
* successful searches) or number of non-NULL
* entries in environ (for unsuccessful
* searches). */
{
Tcl_Size i, result = -1;
const char *env, *p1, *p2;
Tcl_DString envString;
Tcl_DStringInit(&envString);
for (i = 0, env = environ[i]; env != NULL; i++, env = environ[i]) {
p1 = Tcl_ExternalToUtfDString(NULL, env, TCL_INDEX_NONE, &envString);
p2 = name;
|
| ︙ | ︙ |
Changes to unix/tclUnixNotfy.c.
| ︙ | ︙ | |||
435 436 437 438 439 440 441 | * threads, which are invalid here, so setting it to NULL is not * unreasonable. */ waitingListPtr = NULL; /* * The tsdPtr from before the fork is copied as well. But since we | | | 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | * threads, which are invalid here, so setting it to NULL is not * unreasonable. */ waitingListPtr = NULL; /* * The tsdPtr from before the fork is copied as well. But since we * are paranoiac, we don't trust its condvar and reset it. */ #ifdef __CYGWIN__ DestroyWindow(tsdPtr->hwnd); tsdPtr->hwnd = CreateWindowExW(NULL, className, className, 0, 0, 0, 0, 0, NULL, NULL, TclWinGetTclInstance(), NULL); ResetEvent(tsdPtr->event); |
| ︙ | ︙ |
Changes to unix/tclUnixPipe.c.
| ︙ | ︙ | |||
389 390 391 392 393 394 395 |
* converted. */
TclFile inputFile, /* If non-NULL, gives the file to use as input
* for the child process. If inputFile file is
* not readable or is NULL, the child will
* receive no standard input. */
TclFile outputFile, /* If non-NULL, gives the file that receives
* output from the child process. If
| | | | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
* converted. */
TclFile inputFile, /* If non-NULL, gives the file to use as input
* for the child process. If inputFile file is
* not readable or is NULL, the child will
* receive no standard input. */
TclFile outputFile, /* If non-NULL, gives the file that receives
* output from the child process. If
* outputFile file is not writable or is
* NULL, output from the child will be
* discarded. */
TclFile errorFile, /* If non-NULL, gives the file that receives
* errors from the child process. If errorFile
* file is not writable or is NULL, errors
* from the child will be discarded. errorFile
* may be the same as outputFile. */
Tcl_Pid *pidPtr) /* If this function is successful, pidPtr is
* filled with the process id of the child
* process. */
{
TclFile errPipeIn, errPipeOut;
|
| ︙ | ︙ | |||
472 473 474 475 476 477 478 |
*/
if (!SetupStdFile(inputFile, TCL_STDIN)
|| !SetupStdFile(outputFile, TCL_STDOUT)
|| (!joinThisError && !SetupStdFile(errorFile, TCL_STDERR))
|| (joinThisError &&
((dup2(1,2) == -1) || (fcntl(2, F_SETFD, 0) != 0)))) {
| | | | 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
*/
if (!SetupStdFile(inputFile, TCL_STDIN)
|| !SetupStdFile(outputFile, TCL_STDOUT)
|| (!joinThisError && !SetupStdFile(errorFile, TCL_STDERR))
|| (joinThisError &&
((dup2(1,2) == -1) || (fcntl(2, F_SETFD, 0) != 0)))) {
snprintf(errSpace, sizeof(errSpace),
"%dforked process couldn't set up input/output", errno);
len = strlen(errSpace);
if (len != (size_t) write(fd, errSpace, len)) {
Tcl_Panic("TclpCreateProcess: unable to write to errPipeOut");
}
_exit(1);
}
/*
* Close the input side of the error pipe.
*/
RestoreSignals();
execvp(newArgv[0], newArgv); /* INTL: Native. */
snprintf(errSpace, sizeof(errSpace), "%dcouldn't execute \"%.150s\"", errno, argv[0]);
len = strlen(errSpace);
if (len != (size_t) write(fd, errSpace, len)) {
Tcl_Panic("TclpCreateProcess: unable to write to errPipeOut");
}
_exit(1);
}
|
| ︙ | ︙ | |||
779 780 781 782 783 784 785 |
/*
* For backward compatibility with previous versions of Tcl, we use
* "file%d" as the base name for pipes even though it would be more
* natural to use "pipe%d".
*/
| | | 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 |
/*
* For backward compatibility with previous versions of Tcl, we use
* "file%d" as the base name for pipes even though it would be more
* natural to use "pipe%d".
*/
snprintf(channelName, sizeof(channelName), "file%d", channelId);
statePtr->channel = Tcl_CreateChannel(&pipeChannelType, channelName,
statePtr, mode);
return statePtr->channel;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ |
Changes to unix/tclUnixPort.h.
| ︙ | ︙ | |||
497 498 499 500 501 502 503 | # define NFDBITS NBBY*sizeof(fd_mask) #endif /* NFDBITS */ #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS) /* *--------------------------------------------------------------------------- | | | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | # define NFDBITS NBBY*sizeof(fd_mask) #endif /* NFDBITS */ #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS) /* *--------------------------------------------------------------------------- * Not all systems declare the errno variable in errno.h, so this file does it * explicitly. The list of system error messages also isn't generally declared * in a header file anywhere. *--------------------------------------------------------------------------- */ #ifdef NO_ERRNO extern int errno; |
| ︙ | ︙ |
Changes to unix/tclUnixSock.c.
| ︙ | ︙ | |||
37 38 39 40 41 42 43 |
struct sockaddr sa;
struct sockaddr_in sa4;
struct sockaddr_in6 sa6;
struct sockaddr_storage sas;
} address;
/*
| | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
struct sockaddr sa;
struct sockaddr_in sa4;
struct sockaddr_in6 sa6;
struct sockaddr_storage sas;
} address;
/*
* This structure describes per-instance state of a tcp-based channel.
*/
typedef struct TcpState TcpState;
typedef struct TcpFdList {
TcpState *statePtr;
int fd;
struct TcpFdList *next;
} TcpFdList;
struct TcpState {
Tcl_Channel channel; /* Channel associated with this file. */
int flags; /* OR'ed combination of the bitfields defined
* below. */
TcpFdList fds; /* The file descriptors of the sockets. */
int interest; /* Event types of interest */
/*
* Only needed for server sockets
*/
|
| ︙ | ︙ | |||
78 79 80 81 82 83 84 |
int filehandlers; /* Caches FileHandlers that get set up while
* an async socket is not yet connected. */
int connectError; /* Cache SO_ERROR of async socket. */
int cachedBlocking; /* Cache blocking mode of async socket. */
};
/*
| | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
int filehandlers; /* Caches FileHandlers that get set up while
* an async socket is not yet connected. */
int connectError; /* Cache SO_ERROR of async socket. */
int cachedBlocking; /* Cache blocking mode of async socket. */
};
/*
* These bits may be OR'ed together into the "flags" field of a TcpState
* structure.
*/
#define TCP_NONBLOCKING (1<<0) /* Socket with non-blocking I/O */
#define TCP_ASYNC_CONNECT (1<<1) /* Async connect in progress. */
#define TCP_ASYNC_PENDING (1<<4) /* TcpConnect was called to
* process an async connect. This
|
| ︙ | ︙ | |||
382 383 384 385 386 387 388 | /* * ---------------------------------------------------------------------- * * WaitForConnect -- * * Check the state of an async connect process. If a connection attempt * terminated, process it, which may finalize it or may start the next | | | | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | /* * ---------------------------------------------------------------------- * * WaitForConnect -- * * Check the state of an async connect process. If a connection attempt * terminated, process it, which may finalize it or may start the next * attempt. If a connect error occurs, it is saved in * statePtr->connectError to be reported by 'fconfigure -error'. * * There are two modes of operation, defined by errorCodePtr: * * non-NULL: Called by explicit read/write command. Blocks if the * socket is blocking. * May return two error codes: * * EWOULDBLOCK: if connect is still in progress * * ENOTCONN: if connect failed. This would be the error message * of a recv or sendto syscall so this is emulated here. * * NULL: Called by a background operation. Do not block and do not * return any error code. * * Results: * 0 if the connection has completed, -1 if still in progress or there is * an error. * * Side effects: |
| ︙ | ︙ | |||
424 425 426 427 428 429 430 |
if (errorCodePtr != NULL && GOT_BITS(statePtr->flags, TCP_ASYNC_FAILED)) {
*errorCodePtr = ENOTCONN;
return -1;
}
/*
| | | 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
if (errorCodePtr != NULL && GOT_BITS(statePtr->flags, TCP_ASYNC_FAILED)) {
*errorCodePtr = ENOTCONN;
return -1;
}
/*
* Check if an async connect is running. If not return ok.
*/
if (!GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
return 0;
}
/*
|
| ︙ | ︙ | |||
1197 1198 1199 1200 1201 1202 1203 | /* * Whether it is a bug or feature or otherwise, it is a fact of life * that on at least some Linux kernels select() fails to report that a * socket file descriptor is writable when the other end of the socket * is closed. This is in contrast to the guarantees Tcl makes that * its channels become writable and fire writable events on an error | | | 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 | /* * Whether it is a bug or feature or otherwise, it is a fact of life * that on at least some Linux kernels select() fails to report that a * socket file descriptor is writable when the other end of the socket * is closed. This is in contrast to the guarantees Tcl makes that * its channels become writable and fire writable events on an error * condition. This has caused a leak of file descriptors in a state of * background flushing. See Tcl ticket 1758a0b603. * * As a workaround, when our caller indicates an interest in writable * notifications, we must tell the notifier built around select() that * we are interested in the readable state of the file descriptor as * well, as that is the only reliable means to get notified of error * conditions. Then it is the task of WrapNotify() above to untangle |
| ︙ | ︙ | |||
1541 1542 1543 1544 1545 1546 1547 |
*/
if (TcpConnect(interp, statePtr) != TCL_OK) {
TcpCloseProc(statePtr, NULL);
return NULL;
}
| | | 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 |
*/
if (TcpConnect(interp, statePtr) != TCL_OK) {
TcpCloseProc(statePtr, NULL);
return NULL;
}
snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, PTR2INT(statePtr));
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, TCL_READABLE | TCL_WRITABLE);
if (Tcl_SetChannelOption(interp, statePtr->channel, "-translation",
"auto crlf") == TCL_ERROR) {
Tcl_CloseEx(NULL, statePtr->channel, 0);
return NULL;
|
| ︙ | ︙ | |||
1597 1598 1599 1600 1601 1602 1603 |
*
*----------------------------------------------------------------------
*/
void *
TclpMakeTcpClientChannelMode(
void *sock, /* The socket to wrap up into a channel. */
| | | | 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 |
*
*----------------------------------------------------------------------
*/
void *
TclpMakeTcpClientChannelMode(
void *sock, /* The socket to wrap up into a channel. */
int mode) /* OR'ed combination of TCL_READABLE and
* TCL_WRITABLE to indicate file mode. */
{
TcpState *statePtr;
char channelName[SOCK_CHAN_LENGTH];
statePtr = (TcpState *)Tcl_Alloc(sizeof(TcpState));
memset(statePtr, 0, sizeof(TcpState));
statePtr->fds.fd = PTR2INT(sock);
statePtr->flags = 0;
snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, PTR2INT(statePtr));
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, mode);
if (Tcl_SetChannelOption(NULL, statePtr->channel, "-translation",
"auto crlf") == TCL_ERROR) {
Tcl_CloseEx(NULL, statePtr->channel, 0);
return NULL;
|
| ︙ | ︙ | |||
1834 1835 1836 1837 1838 1839 1840 |
* Allocate a new TcpState for this socket.
*/
statePtr = (TcpState *)Tcl_Alloc(sizeof(TcpState));
memset(statePtr, 0, sizeof(TcpState));
statePtr->acceptProc = acceptProc;
statePtr->acceptProcData = acceptProcData;
| | | 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 |
* Allocate a new TcpState for this socket.
*/
statePtr = (TcpState *)Tcl_Alloc(sizeof(TcpState));
memset(statePtr, 0, sizeof(TcpState));
statePtr->acceptProc = acceptProc;
statePtr->acceptProcData = acceptProcData;
snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, PTR2INT(statePtr));
newfds = &statePtr->fds;
} else {
newfds = (TcpFdList *)Tcl_Alloc(sizeof(TcpFdList));
memset(newfds, (int) 0, sizeof(TcpFdList));
fds->next = newfds;
}
newfds->fd = sock;
|
| ︙ | ︙ | |||
1926 1927 1928 1929 1930 1931 1932 |
(void) fcntl(newsock, F_SETFD, FD_CLOEXEC);
newSockState = (TcpState *)Tcl_Alloc(sizeof(TcpState));
memset(newSockState, 0, sizeof(TcpState));
newSockState->flags = 0;
newSockState->fds.fd = newsock;
| | | 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 |
(void) fcntl(newsock, F_SETFD, FD_CLOEXEC);
newSockState = (TcpState *)Tcl_Alloc(sizeof(TcpState));
memset(newSockState, 0, sizeof(TcpState));
newSockState->flags = 0;
newSockState->fds.fd = newsock;
snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, PTR2INT(newSockState));
newSockState->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
newSockState, TCL_READABLE | TCL_WRITABLE);
Tcl_SetChannelOption(NULL, newSockState->channel, "-translation",
"auto crlf");
if (fds->statePtr->acceptProc != NULL) {
|
| ︙ | ︙ |
Changes to unix/tclUnixTest.c.
| ︙ | ︙ | |||
186 187 188 189 190 191 192 |
} else if (strcmp(Tcl_GetString(objv[1]), "counts") == 0) {
char buf[TCL_INTEGER_SPACE * 2];
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
return TCL_ERROR;
}
| | | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
} else if (strcmp(Tcl_GetString(objv[1]), "counts") == 0) {
char buf[TCL_INTEGER_SPACE * 2];
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
return TCL_ERROR;
}
snprintf(buf, sizeof(buf), "%d %d", pipePtr->readCount, pipePtr->writeCount);
Tcl_AppendResult(interp, buf, NULL);
} else if (strcmp(Tcl_GetString(objv[1]), "create") == 0) {
if (objc != 5) {
Tcl_WrongNumArgs(interp, 2, objv, "index readMode writeMode");
return TCL_ERROR;
}
if (pipePtr->readFile == NULL) {
|
| ︙ | ︙ | |||
590 591 592 593 594 595 596 | /* *--------------------------------------------------------------------------- * * TestchmodCmd -- * * Implements the "testchmod" cmd. Used when testing "file" command. * The only attribute used by the Windows platform is the user write | | | 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | /* *--------------------------------------------------------------------------- * * TestchmodCmd -- * * Implements the "testchmod" cmd. Used when testing "file" command. * The only attribute used by the Windows platform is the user write * flag; if this is not set, the file is made read-only. Otherwise, the * file is made read-write. * * Results: * A standard Tcl result. * * Side effects: * Changes permissions of specified files. |
| ︙ | ︙ |
Changes to unix/tclUnixTime.c.
| ︙ | ︙ | |||
100 101 102 103 104 105 106 | /* *---------------------------------------------------------------------- * * TclpGetClicks -- * * This procedure returns a value that represents the highest resolution | | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | /* *---------------------------------------------------------------------- * * TclpGetClicks -- * * This procedure returns a value that represents the highest resolution * clock available on the system. There are no guarantees on what the * resolution will be. In Tcl we will call this value a "click". The * start time is also system dependent. * * Results: * Number of clicks from some start time. * * Side effects: |
| ︙ | ︙ |
Changes to unix/tclXtNotify.c.
| ︙ | ︙ | |||
13 14 15 16 17 18 19 | #ifndef USE_TCL_STUBS # define USE_TCL_STUBS #endif #include <X11/Intrinsic.h> #include "tclInt.h" /* | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#ifndef USE_TCL_STUBS
# define USE_TCL_STUBS
#endif
#include <X11/Intrinsic.h>
#include "tclInt.h"
/*
* This structure is used to keep track of the notifier info for a
* registered file.
*/
typedef struct FileHandler {
int fd;
int mask; /* Mask of desired events: TCL_READABLE,
* etc. */
|
| ︙ | ︙ |
Changes to win/Makefile.in.
| ︙ | ︙ | |||
609 610 611 612 613 614 615 |
${TEST_EXE_FILE}: ${TCL_STUB_LIB_FILE} ${TCLTEST_OBJS} tclTestMain.${OBJEXT}
@$(RM) ${TEST_EXE_FILE}
$(CC) $(CFLAGS) $(TCLTEST_OBJS) tclTestMain.$(OBJEXT) $(TCL_LIB_FILE) $(TCL_STUB_LIB_FILE) $(LIBS) \
tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE)
$(COPY) tclsh.exe.manifest ${TEST_EXE_FILE}.manifest
| | | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
${TEST_EXE_FILE}: ${TCL_STUB_LIB_FILE} ${TCLTEST_OBJS} tclTestMain.${OBJEXT}
@$(RM) ${TEST_EXE_FILE}
$(CC) $(CFLAGS) $(TCLTEST_OBJS) tclTestMain.$(OBJEXT) $(TCL_LIB_FILE) $(TCL_STUB_LIB_FILE) $(LIBS) \
tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE)
$(COPY) tclsh.exe.manifest ${TEST_EXE_FILE}.manifest
# use prebuilt zlib1.dll
${ZLIB_DLL_FILE}: ${TCL_STUB_LIB_FILE}
@if test "@ZLIB_LIBS@set" = "${ZLIB_DIR_NATIVE}/win64-arm/zdll.libset" ; then \
$(COPY) $(ZLIB_DIR)/win64-arm/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}; \
elif test "@ZLIB_LIBS@set" = "${ZLIB_DIR_NATIVE}/win64-arm/libz.dll.aset" ; then \
$(COPY) $(ZLIB_DIR)/win64-arm/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}; \
elif test "@ZLIB_LIBS@set" = "${ZLIB_DIR_NATIVE}/win32/zdll.libset" ; then \
$(COPY) $(ZLIB_DIR)/win32/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}; \
|
| ︙ | ︙ | |||
697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
-DCFG_RUNTIME_INCDIR="\"$(includedir_native)\"" \
-DCFG_RUNTIME_DOCDIR="\"$(mandir_native)\"" \
-DCFG_RUNTIME_DLLFILE="\"$(TCL_DLL_FILE)\"" \
-DBUILD_tcl \
@DEPARG@ $(CC_OBJNAME)
tclEvent.${OBJEXT}: tclEvent.c tclUuid.h
$(TOP_DIR)/manifest.uuid:
printf "git-" >$(TOP_DIR)/manifest.uuid
(cd $(TOP_DIR); git rev-parse HEAD >>$(TOP_DIR)/manifest.uuid || \
(printf "svn-r" >$(TOP_DIR)/manifest.uuid ; \
svn info --show-item last-changed-revision >>$(TOP_DIR)/manifest.uuid) || \
printf "unknown" >$(TOP_DIR)/manifest.uuid)
| > > | 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 |
-DCFG_RUNTIME_INCDIR="\"$(includedir_native)\"" \
-DCFG_RUNTIME_DOCDIR="\"$(mandir_native)\"" \
-DCFG_RUNTIME_DLLFILE="\"$(TCL_DLL_FILE)\"" \
-DBUILD_tcl \
@DEPARG@ $(CC_OBJNAME)
tclEvent.${OBJEXT}: tclEvent.c tclUuid.h
tclTest.${OBJEXT}: tclTest.c tclUuid.h
$(TOP_DIR)/manifest.uuid:
printf "git-" >$(TOP_DIR)/manifest.uuid
(cd $(TOP_DIR); git rev-parse HEAD >>$(TOP_DIR)/manifest.uuid || \
(printf "svn-r" >$(TOP_DIR)/manifest.uuid ; \
svn info --show-item last-changed-revision >>$(TOP_DIR)/manifest.uuid) || \
printf "unknown" >$(TOP_DIR)/manifest.uuid)
|
| ︙ | ︙ |
Changes to win/makefile.vc.
| ︙ | ︙ | |||
106 107 108 109 110 111 112 | # set (ie: recent Platform SDK) then MACHINE is set from CPU. # # TMP_DIR=<path> # OUT_DIR=<path> # Hooks to allow the intermediate and output directories to be # changed. $(OUT_DIR) is assumed to be # $(BINROOT)\(Release|Debug) based on if symbols are requested. | | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | # set (ie: recent Platform SDK) then MACHINE is set from CPU. # # TMP_DIR=<path> # OUT_DIR=<path> # Hooks to allow the intermediate and output directories to be # changed. $(OUT_DIR) is assumed to be # $(BINROOT)\(Release|Debug) based on if symbols are requested. # $(TMP_DIR) will be $(OUT_DIR)\<buildtype> by default. # # TESTPAT=<file> # Reads the tests requested to be run from this file. # # Examples: # c:\tcl_src\win\>nmake -f makefile.vc release # c:\tcl_src\win\>nmake -f makefile.vc test |
| ︙ | ︙ |
Changes to win/nmakehlp.c.
| ︙ | ︙ | |||
206 207 208 209 210 211 212 |
ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = FALSE;
/*
| | | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = FALSE;
/*
* Create a non-inheritable pipe.
*/
CreatePipe(&Out.pipe, &h, &sa, 0);
/*
* Dupe the write side, make it inheritable, and close the original.
*/
DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE,
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
/*
* Same as above, but for the error side.
|
| ︙ | ︙ | |||
348 349 350 351 352 353 354 |
/*
* Create a non-inheritible pipe.
*/
CreatePipe(&Out.pipe, &h, &sa, 0);
/*
| | | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
/*
* Create a non-inheritible pipe.
*/
CreatePipe(&Out.pipe, &h, &sa, 0);
/*
* Dupe the write side, make it inheritable, and close the original.
*/
DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE,
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
/*
* Same as above, but for the error side.
|
| ︙ | ︙ | |||
580 581 582 583 584 585 586 |
}
}
/*
* SubstituteFile --
* As windows doesn't provide anything useful like sed and it's unreliable
* to use the tclsh you are building against (consider x-platform builds -
| | | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
}
}
/*
* SubstituteFile --
* As windows doesn't provide anything useful like sed and it's unreliable
* to use the tclsh you are building against (consider x-platform builds -
* e.g. compiling AMD64 target from IX86) we provide a simple substitution
* option here to handle autoconf style substitutions.
* The substitution file is whitespace and line delimited. The file should
* consist of lines matching the regular expression:
* \s*\S+\s+\S*$
*
* Usage is something like:
* nmakehlp -S << $** > $@
|
| ︙ | ︙ | |||
606 607 608 609 610 611 612 |
list_item_t *substPtr = NULL;
FILE *fp, *sp;
fp = fopen(filename, "rt");
if (fp != NULL) {
/*
| | | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
list_item_t *substPtr = NULL;
FILE *fp, *sp;
fp = fopen(filename, "rt");
if (fp != NULL) {
/*
* Build a list of substitutions from the first filename
*/
sp = fopen(substitutions, "rt");
if (sp != NULL) {
while (fgets(szBuffer, sizeof(szBuffer), sp) != NULL) {
unsigned char *ks, *ke, *vs, *ve;
ks = (unsigned char*)szBuffer;
|
| ︙ | ︙ |
Changes to win/rules.vc.
| ︙ | ︙ | |||
1365 1366 1367 1368 1369 1370 1371 | # 12. Set up actual options to be passed to the compiler and linker # Now we have all the information we need, set up the actual flags and # options that we will pass to the compiler and linker. The main # makefile should use these in combination with whatever other flags # and switches are specific to it. # The following macros are defined, names are for historical compatibility: # OPTDEFINES - /Dxxx C macro flags based on user-specified OPTS | | | 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 | # 12. Set up actual options to be passed to the compiler and linker # Now we have all the information we need, set up the actual flags and # options that we will pass to the compiler and linker. The main # makefile should use these in combination with whatever other flags # and switches are specific to it. # The following macros are defined, names are for historical compatibility: # OPTDEFINES - /Dxxx C macro flags based on user-specified OPTS # COMPILERFLAGS - /Dxxx C macro flags independent of any configuration options # crt - Compiler switch that selects the appropriate C runtime # cdebug - Compiler switches related to debug AND optimizations # cwarn - Compiler switches that set warning levels # cflags - complete compiler switches (subsumes cdebug and cwarn) # ldebug - Linker switches controlling debug information and optimization # lflags - complete linker switches (subsumes ldebug) except subsystem type # dlllflags - complete linker switches to build DLLs (subsumes lflags) |
| ︙ | ︙ |
Changes to win/tcl.m4.
| ︙ | ︙ | |||
1040 1041 1042 1043 1044 1045 1046 | # extension can't assume that an executable Tcl shell exists at # build time. # # Arguments # none # # Results | | | 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 |
# extension can't assume that an executable Tcl shell exists at
# build time.
#
# Arguments
# none
#
# Results
# Substitutes the following values:
# TCLSH_PROG
#------------------------------------------------------------------------
AC_DEFUN([SC_PROG_TCLSH], [
AC_MSG_CHECKING([for tclsh])
AC_CACHE_VAL(ac_cv_path_tclsh, [
|
| ︙ | ︙ | |||
1086 1087 1088 1089 1090 1091 1092 | # when running tests from an extension build directory. It is not # correct to use the TCLSH_PROG in cases like this. # # Arguments # none # # Results | | | 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 |
# when running tests from an extension build directory. It is not
# correct to use the TCLSH_PROG in cases like this.
#
# Arguments
# none
#
# Results
# Substitutes the following values:
# BUILD_TCLSH
#------------------------------------------------------------------------
AC_DEFUN([SC_BUILD_TCLSH], [
AC_MSG_CHECKING([for tclsh in Tcl build directory])
BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}\${EXESUFFIX}
AC_MSG_RESULT($BUILD_TCLSH)
|
| ︙ | ︙ |
Changes to win/tclAppInit.c.
| ︙ | ︙ | |||
137 138 139 140 141 142 143 |
#ifdef TCL_LOCAL_MAIN_HOOK
TCL_LOCAL_MAIN_HOOK(&argc, &argv);
#elif (TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6) && (!defined(_WIN32) || defined(UNICODE))
/* New in Tcl 8.7. This doesn't work on Windows without UNICODE */
TclZipfs_AppHook(&argc, &argv);
#endif
| | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
#ifdef TCL_LOCAL_MAIN_HOOK
TCL_LOCAL_MAIN_HOOK(&argc, &argv);
#elif (TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6) && (!defined(_WIN32) || defined(UNICODE))
/* New in Tcl 8.7. This doesn't work on Windows without UNICODE */
TclZipfs_AppHook(&argc, &argv);
#endif
Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
return 0; /* Needed only to prevent compiler warning. */
}
/*
*----------------------------------------------------------------------
*
* Tcl_AppInit --
|
| ︙ | ︙ |
Changes to win/tclWinChan.c.
| ︙ | ︙ | |||
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
static void FileWatchProc(void *instanceData, int mask);
static void FileThreadActionProc(void *instanceData,
int action);
static int FileTruncateProc(void *instanceData,
long long length);
static DWORD FileGetType(HANDLE handle);
static int NativeIsComPort(const WCHAR *nativeName);
/*
* This structure describes the channel type structure for file based IO.
*/
static const Tcl_ChannelType fileChannelType = {
"file", /* Type name. */
| > > | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
static void FileWatchProc(void *instanceData, int mask);
static void FileThreadActionProc(void *instanceData,
int action);
static int FileTruncateProc(void *instanceData,
long long length);
static DWORD FileGetType(HANDLE handle);
static int NativeIsComPort(const WCHAR *nativeName);
static Tcl_Channel OpenFileChannel(HANDLE handle, char *channelName,
int permissions, int appendMode);
/*
* This structure describes the channel type structure for file based IO.
*/
static const Tcl_ChannelType fileChannelType = {
"file", /* Type name. */
|
| ︙ | ︙ | |||
846 847 848 849 850 851 852 | "couldn't open serial \"%s\": %s", TclGetString(pathPtr), Tcl_PosixError(interp))); } return NULL; } /* | | | 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 |
"couldn't open serial \"%s\": %s",
TclGetString(pathPtr), Tcl_PosixError(interp)));
}
return NULL;
}
/*
* For natively-named Windows serial ports we are done.
*/
channel = TclWinOpenSerialChannel(handle, channelName,
channelPermissions);
return channel;
}
|
| ︙ | ︙ | |||
944 945 946 947 948 949 950 |
writeFile = TclWinMakeFile(handle);
}
channel = TclpCreateCommandChannel(readFile, writeFile, NULL, 0, NULL);
break;
case FILE_TYPE_CHAR:
case FILE_TYPE_DISK:
case FILE_TYPE_UNKNOWN:
| | | 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 |
writeFile = TclWinMakeFile(handle);
}
channel = TclpCreateCommandChannel(readFile, writeFile, NULL, 0, NULL);
break;
case FILE_TYPE_CHAR:
case FILE_TYPE_DISK:
case FILE_TYPE_UNKNOWN:
channel = OpenFileChannel(handle, channelName,
channelPermissions,
TEST_FLAG(mode, O_APPEND) ? FILE_APPEND : 0);
break;
default:
/*
* The handle is of an unknown type, probably /dev/nul equivalent or
|
| ︙ | ︙ | |||
986 987 988 989 990 991 992 |
*
*----------------------------------------------------------------------
*/
Tcl_Channel
Tcl_MakeFileChannel(
void *rawHandle, /* OS level handle */
| | | | 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 |
*
*----------------------------------------------------------------------
*/
Tcl_Channel
Tcl_MakeFileChannel(
void *rawHandle, /* OS level handle */
int mode) /* OR'ed combination of TCL_READABLE and
* TCL_WRITABLE to indicate file mode. */
{
#if defined(HAVE_NO_SEH) && !defined(_WIN64) && !defined(__clang__)
TCLEXCEPTION_REGISTRATION registration;
#endif
char channelName[16 + TCL_INTEGER_SPACE];
Tcl_Channel channel = NULL;
HANDLE handle = (HANDLE) rawHandle;
HANDLE dupedHandle;
TclFile readFile = NULL, writeFile = NULL;
BOOL result;
if ((mode & (TCL_READABLE|TCL_WRITABLE)) == 0) {
return NULL;
}
switch (FileGetType(handle)) {
case FILE_TYPE_SERIAL:
channel = TclWinOpenSerialChannel(handle, channelName, mode);
break;
|
| ︙ | ︙ | |||
1022 1023 1024 1025 1026 1027 1028 |
writeFile = TclWinMakeFile(handle);
}
channel = TclpCreateCommandChannel(readFile, writeFile, NULL, 0, NULL);
break;
case FILE_TYPE_DISK:
case FILE_TYPE_CHAR:
| | | 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 |
writeFile = TclWinMakeFile(handle);
}
channel = TclpCreateCommandChannel(readFile, writeFile, NULL, 0, NULL);
break;
case FILE_TYPE_DISK:
case FILE_TYPE_CHAR:
channel = OpenFileChannel(handle, channelName, mode, 0);
break;
case FILE_TYPE_UNKNOWN:
default:
/*
* The handle is of an unknown type. Test the validity of this OS
* handle by duplicating it, then closing the dupe. The Win32 API
|
| ︙ | ︙ | |||
1156 1157 1158 1159 1160 1161 1162 | /* * Fall through, the handle is valid. * * Create the undefined channel, anyways, because we know the handle * is valid to something. */ | | | 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 |
/*
* Fall through, the handle is valid.
*
* Create the undefined channel, anyways, because we know the handle
* is valid to something.
*/
channel = OpenFileChannel(handle, channelName, mode, 0);
}
return channel;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
1244 1245 1246 1247 1248 1249 1250 |
}
return channel;
}
/*
*----------------------------------------------------------------------
*
| | | | | | | 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 |
}
return channel;
}
/*
*----------------------------------------------------------------------
*
* OpenFileChannel --
*
* Constructs a File channel for the specified standard OS handle. This
* is a helper function to break up the construction of channels into
* File, Console, or Serial.
*
* Results:
* Returns the new channel, or NULL.
*
* Side effects:
* May open the channel and may cause creation of a file on the file
* system.
*
*----------------------------------------------------------------------
*/
Tcl_Channel
OpenFileChannel(
HANDLE handle, /* Win32 HANDLE to swallow */
char *channelName, /* Buffer to receive channel name */
int permissions, /* OR'ed combination of TCL_READABLE,
* TCL_WRITABLE, or TCL_EXCEPTION, indicating
* which operations are valid on the file. */
int appendMode) /* OR'ed combination of bits indicating what
* additional configuration of the channel is
* present. */
{
FileInfo *infoPtr;
ThreadSpecificData *tsdPtr = FileInit();
/*
* See if a channel with this handle already exists.
*/
for (infoPtr = tsdPtr->firstFilePtr; infoPtr != NULL;
infoPtr = infoPtr->nextPtr) {
if (infoPtr->handle == (HANDLE) handle) {
return ((permissions & (TCL_READABLE|TCL_WRITABLE|TCL_EXCEPTION))==infoPtr->validMask) ? infoPtr->channel : NULL;
}
}
infoPtr = (FileInfo *)Tcl_Alloc(sizeof(FileInfo));
/*
* TIP #218. Removed the code inserting the new structure into the global
* list. This is now handled in the thread action callbacks, and only
* there.
*/
infoPtr->nextPtr = NULL;
infoPtr->validMask = permissions & (TCL_READABLE|TCL_WRITABLE|TCL_EXCEPTION);
infoPtr->watchMask = 0;
infoPtr->flags = appendMode;
infoPtr->handle = handle;
infoPtr->dirty = 0;
snprintf(channelName, 16 + TCL_INTEGER_SPACE, "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
infoPtr->channel = Tcl_CreateChannel(&fileChannelType, channelName,
infoPtr, permissions);
/*
* Files have default translation of AUTO and ^Z eof char, which means
* that a ^Z will be accepted as EOF when reading.
|
| ︙ | ︙ |
Changes to win/tclWinConsole.c.
| ︙ | ︙ | |||
2119 2120 2121 2122 2123 2124 2125 |
/*
* Use the pointer for the name of the result channel. This keeps the
* channel names unique, since some may share handles (stdin/stdout/stderr
* for instance).
*/
| | | 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 |
/*
* Use the pointer for the name of the result channel. This keeps the
* channel names unique, since some may share handles (stdin/stdout/stderr
* for instance).
*/
snprintf(channelName, 16 + TCL_INTEGER_SPACE, "file%" TCL_Z_MODIFIER "x", (size_t) chanInfoPtr);
if (permissions & TCL_READABLE) {
/*
* Make sure the console input buffer is ready for only character
* input notifications and the buffer is set for line buffering. IOW,
* we only want to catch when complete lines are ready for reading.
*/
|
| ︙ | ︙ | |||
2415 2416 2417 2418 2419 2420 2421 |
interp,
Tcl_ObjPrintf("couldn't read console size: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
Tcl_DStringStartSublist(dsPtr);
| | | | 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 |
interp,
Tcl_ObjPrintf("couldn't read console size: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
Tcl_DStringStartSublist(dsPtr);
snprintf(buf, sizeof(buf),
"%d",
consoleInfo.srWindow.Right - consoleInfo.srWindow.Left + 1);
Tcl_DStringAppendElement(dsPtr, buf);
snprintf(buf, sizeof(buf),
"%d",
consoleInfo.srWindow.Bottom - consoleInfo.srWindow.Top + 1);
Tcl_DStringAppendElement(dsPtr, buf);
Tcl_DStringEndSublist(dsPtr);
}
}
|
| ︙ | ︙ |
Changes to win/tclWinDde.c.
| ︙ | ︙ | |||
314 315 316 317 318 319 320 |
* incoming Dde eval's */
{
int suffix, offset;
RegisteredInterp *riPtr, *prevPtr;
Tcl_DString dString;
const WCHAR *actualName;
Tcl_Obj *srvListPtr = NULL, **srvPtrPtr = NULL;
| > | | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
* incoming Dde eval's */
{
int suffix, offset;
RegisteredInterp *riPtr, *prevPtr;
Tcl_DString dString;
const WCHAR *actualName;
Tcl_Obj *srvListPtr = NULL, **srvPtrPtr = NULL;
Tcl_Size n, srvCount = 0;
int lastSuffix, r = TCL_OK;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
/*
* See if the application is already registered; if so, remove its current
* name from the registry. The deletion of the command will take care of
* disposing of this entry.
*/
|
| ︙ | ︙ | |||
866 867 868 869 870 871 872 |
}
return ddeReturn;
#endif
case XTYP_EXECUTE: {
/*
* Execute this script. The results will be saved into a list object
| | | 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
}
return ddeReturn;
#endif
case XTYP_EXECUTE: {
/*
* Execute this script. The results will be saved into a list object
* which will be retrieved later. See ExecuteRemoteObject.
*/
Tcl_Obj *returnPackagePtr;
char *string;
for (convPtr = tsdPtr->currentConversations; (convPtr != NULL)
&& (convPtr->hConv != hConv); convPtr = convPtr->nextPtr) {
|
| ︙ | ︙ | |||
889 890 891 892 893 894 895 |
utilString = (WCHAR *) DdeAccessData(hData, &dlen);
string = (char *) utilString;
if (!dlen) {
/* Empty binary array. */
ddeObjectPtr = Tcl_NewObj();
} else if ((dlen & 1) || utilString[(dlen>>1)-1]) {
| | | | 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 |
utilString = (WCHAR *) DdeAccessData(hData, &dlen);
string = (char *) utilString;
if (!dlen) {
/* Empty binary array. */
ddeObjectPtr = Tcl_NewObj();
} else if ((dlen & 1) || utilString[(dlen>>1)-1]) {
/* Cannot be Unicode, so assume utf-8 */
if (!string[dlen-1]) {
dlen--;
}
ddeObjectPtr = Tcl_NewStringObj(string, dlen);
} else {
/* Unicode */
Tcl_DString dsBuf;
Tcl_DStringInit(&dsBuf);
Tcl_WCharToUtfDString(utilString, (dlen>>1) - 1, &dsBuf);
ddeObjectPtr = Tcl_NewStringObj(Tcl_DStringValue(&dsBuf),
Tcl_DStringLength(&dsBuf));
Tcl_DStringFree(&dsBuf);
|
| ︙ | ︙ |
Changes to win/tclWinFCmd.c.
| ︙ | ︙ | |||
305 306 307 308 309 310 311 |
return TCL_ERROR;
}
if (errno == EACCES) {
decode:
if (srcAttr & FILE_ATTRIBUTE_DIRECTORY) {
WCHAR *nativeSrcRest, *nativeDstRest;
const char **srcArgv, **dstArgv;
| | > | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
return TCL_ERROR;
}
if (errno == EACCES) {
decode:
if (srcAttr & FILE_ATTRIBUTE_DIRECTORY) {
WCHAR *nativeSrcRest, *nativeDstRest;
const char **srcArgv, **dstArgv;
size_t size;
Tcl_Size srcArgc, dstArgc;
WCHAR nativeSrcPath[MAX_PATH];
WCHAR nativeDstPath[MAX_PATH];
Tcl_DString srcString, dstString;
const char *src, *dst;
size = GetFullPathNameW(nativeSrc, MAX_PATH,
nativeSrcPath, &nativeSrcRest);
|
| ︙ | ︙ | |||
875 876 877 878 879 880 881 | /* *--------------------------------------------------------------------------- * * TclpObjCopyDirectory -- * * Recursively copies a directory. The target directory dst must not * already exist. Note that this function does not merge two directory | | | 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 | /* *--------------------------------------------------------------------------- * * TclpObjCopyDirectory -- * * Recursively copies a directory. The target directory dst must not * already exist. Note that this function does not merge two directory * hierarchies, even if the target directory is an empty directory. * * Results: * If the directory was successfully copied, returns TCL_OK. Otherwise * the return value is TCL_ERROR, errno is set to indicate the error, and * the pathname of the file that caused the error is stored in errorPtr. * See TclpCreateDirectory and TclpCopyFile for a description of possible * values for errno. |
| ︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 |
ConvertFileNameFormat(
Tcl_Interp *interp, /* The interp we are using for errors. */
TCL_UNUSED(int) /*objIndex*/,
Tcl_Obj *fileName, /* The name of the file. */
int longShort, /* 0 to short name, 1 to long name. */
Tcl_Obj **attributePtrPtr) /* A pointer to return the object with. */
{
| | < | 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 |
ConvertFileNameFormat(
Tcl_Interp *interp, /* The interp we are using for errors. */
TCL_UNUSED(int) /*objIndex*/,
Tcl_Obj *fileName, /* The name of the file. */
int longShort, /* 0 to short name, 1 to long name. */
Tcl_Obj **attributePtrPtr) /* A pointer to return the object with. */
{
Tcl_Size pathc, i, length;
Tcl_Obj *splitPath;
splitPath = Tcl_FSSplitPath(fileName, &pathc);
if (splitPath == NULL || pathc == 0) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"could not read \"%s\": no such file or directory",
|
| ︙ | ︙ |
Changes to win/tclWinFile.c.
| ︙ | ︙ | |||
1656 1657 1658 1659 1660 1661 1662 |
if (GetLastError() == ERROR_ACCESS_DENIED) {
Tcl_SetErrno(EACCES);
return -1;
}
}
/*
| | | 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 |
if (GetLastError() == ERROR_ACCESS_DENIED) {
Tcl_SetErrno(EACCES);
return -1;
}
}
/*
* We cannot verify the access fast, check it below using security
* info.
*/
}
/*
* It looks as if the permissions are ok, but if we are on NT, 2000 or XP,
* we have a more complex permissions structure so we try to check that.
|
| ︙ | ︙ | |||
1776 1777 1778 1779 1780 1781 1782 | goto accessError; } RevertToSelf(); /* | | | 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 |
goto accessError;
}
RevertToSelf();
/*
* Setup desiredAccess according to the access privileges we are
* checking.
*/
if (mode & R_OK) {
desiredAccess |= FILE_GENERIC_READ;
}
if (mode & W_OK) {
|
| ︙ | ︙ | |||
2033 2034 2035 2036 2037 2038 2039 |
/*
* If we can use 'createFile' on this, then we can use the resulting
* fileHandle to read more information (nlink, ino) than we can get from
* other attributes reading APIs. If not, then we try to fall back on the
* 'getFileAttributesExProc', and if that isn't available, then on even
* simpler routines.
*
| | | 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 |
/*
* If we can use 'createFile' on this, then we can use the resulting
* fileHandle to read more information (nlink, ino) than we can get from
* other attributes reading APIs. If not, then we try to fall back on the
* 'getFileAttributesExProc', and if that isn't available, then on even
* simpler routines.
*
* Special consideration must be given to Windows hard-coded names like
* CON, NULL, COM1, LPT1 etc. For these, we still need to do the
* CreateFile as some may not exist (e.g. there is no CON in wish by
* default). However the subsequent GetFileInformationByHandle will
* fail. We do a WinIsReserved to see if it is one of the special names,
* and if successful, mock up a BY_HANDLE_FILE_INFORMATION structure.
*/
|
| ︙ | ︙ | |||
2324 2325 2326 2327 2328 2329 2330 | * This function replaces the library version of getcwd(). * * Results: * The input and output are filesystem paths in native form. The result * is either the given clientData, if the working directory hasn't * changed, or a new clientData (owned by our caller), giving the new * native path, or NULL if the current directory could not be determined. | | | 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 | * This function replaces the library version of getcwd(). * * Results: * The input and output are filesystem paths in native form. The result * is either the given clientData, if the working directory hasn't * changed, or a new clientData (owned by our caller), giving the new * native path, or NULL if the current directory could not be determined. * If NULL is returned, the caller can examine the standard Posix error * codes to determine the cause of the problem. * * Side effects: * None. * *---------------------------------------------------------------------- */ |
| ︙ | ︙ |
Changes to win/tclWinInit.c.
| ︙ | ︙ | |||
120 121 122 123 124 125 126 |
*
*-------------------------------------------------------------------------
*/
void
TclpInitLibraryPath(
char **valuePtr,
| | | | | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
*
*-------------------------------------------------------------------------
*/
void
TclpInitLibraryPath(
char **valuePtr,
TCL_HASH_TYPE *lengthPtr,
Tcl_Encoding *encodingPtr)
{
#define LIBRARY_SIZE 64
Tcl_Obj *pathPtr;
char installLib[LIBRARY_SIZE];
const char *bytes;
size_t length;
TclNewObj(pathPtr);
/*
* Initialize the substring used when locating the script library. The
* installLib variable computes the script library path relative to the
* installed DLL.
*/
snprintf(installLib, sizeof(installLib), "lib/tcl%s", TCL_VERSION);
/*
* Look for the library relative to the TCL_LIBRARY env variable. If the
* last dirname in the TCL_LIBRARY path does not match the last dirname in
* the installLib variable, use the last dir name of installLib in
* addition to the original TCL_LIBRARY path.
*/
AppendEnvironment(pathPtr, installLib);
/*
* Look for the library in its default location.
*/
|
| ︙ | ︙ | |||
194 195 196 197 198 199 200 |
*/
static void
AppendEnvironment(
Tcl_Obj *pathPtr,
const char *lib)
{
| | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
*/
static void
AppendEnvironment(
Tcl_Obj *pathPtr,
const char *lib)
{
Tcl_Size pathc;
WCHAR wBuf[MAX_PATH];
char buf[MAX_PATH * 3];
Tcl_Obj *objPtr;
Tcl_DString ds;
const char **pathv;
char *shortlib;
|
| ︙ | ︙ | |||
221 222 223 224 225 226 227 |
}
}
if (shortlib == lib) {
Tcl_Panic("no '/' character found in lib");
}
/*
| | | | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
}
}
if (shortlib == lib) {
Tcl_Panic("no '/' character found in lib");
}
/*
* The "L" preceding the TCL_LIBRARY string is used to tell VC++ that
* this is a Unicode string.
*/
GetEnvironmentVariableW(L"TCL_LIBRARY", wBuf, MAX_PATH);
WideCharToMultiByte(CP_UTF8, 0, wBuf, -1, buf, MAX_PATH * 3, NULL, NULL);
if (buf[0] != '\0') {
objPtr = Tcl_NewStringObj(buf, TCL_INDEX_NONE);
|
| ︙ | ︙ | |||
300 301 302 303 304 305 306 |
p = strrchr(name, '\\');
if (p != NULL) {
end = p;
}
*end = '\\';
TclWinNoBackslash(name);
| | | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
p = strrchr(name, '\\');
if (p != NULL) {
end = p;
}
*end = '\\';
TclWinNoBackslash(name);
snprintf(end + 1, LIBRARY_SIZE, "lib/tcl%s", TCL_VERSION);
*lengthPtr = strlen(name);
*valuePtr = (char *)Tcl_Alloc(*lengthPtr + 1);
*encodingPtr = NULL;
memcpy(*valuePtr, name, *lengthPtr + 1);
}
/*
|
| ︙ | ︙ | |||
348 349 350 351 352 353 354 |
p = strrchr(name, '\\');
if (p != NULL) {
end = p;
}
*end = '\\';
TclWinNoBackslash(name);
| | | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
p = strrchr(name, '\\');
if (p != NULL) {
end = p;
}
*end = '\\';
TclWinNoBackslash(name);
snprintf(end + 1, LIBRARY_SIZE, "../library");
*lengthPtr = strlen(name);
*valuePtr = (char *)Tcl_Alloc(*lengthPtr + 1);
*encodingPtr = NULL;
memcpy(*valuePtr, name, *lengthPtr + 1);
}
/*
|
| ︙ | ︙ | |||
400 401 402 403 404 405 406 |
UINT acp = GetACP();
Tcl_DStringInit(bufPtr);
if (acp == CP_UTF8) {
Tcl_DStringAppend(bufPtr, "utf-8", 5);
} else {
Tcl_DStringSetLength(bufPtr, 2+TCL_INTEGER_SPACE);
| | | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
UINT acp = GetACP();
Tcl_DStringInit(bufPtr);
if (acp == CP_UTF8) {
Tcl_DStringAppend(bufPtr, "utf-8", 5);
} else {
Tcl_DStringSetLength(bufPtr, 2+TCL_INTEGER_SPACE);
snprintf(Tcl_DStringValue(bufPtr), 2+TCL_INTEGER_SPACE, "cp%d", GetACP());
Tcl_DStringSetLength(bufPtr, strlen(Tcl_DStringValue(bufPtr)));
}
return Tcl_DStringValue(bufPtr);
}
const char *
TclpGetUserName(
|
| ︙ | ︙ | |||
484 485 486 487 488 489 490 |
Tcl_SetVar2(interp, "tcl_platform", "platform", "windows",
TCL_GLOBAL_ONLY);
Tcl_SetVar2(interp, "tcl_platform", "os",
"Windows NT", TCL_GLOBAL_ONLY);
if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 22000) {
osInfo.dwMajorVersion = 11;
}
| | | 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
Tcl_SetVar2(interp, "tcl_platform", "platform", "windows",
TCL_GLOBAL_ONLY);
Tcl_SetVar2(interp, "tcl_platform", "os",
"Windows NT", TCL_GLOBAL_ONLY);
if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 22000) {
osInfo.dwMajorVersion = 11;
}
snprintf(buffer, sizeof(buffer), "%ld.%ld", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY);
if (sys.oemId.wProcessorArchitecture < NUMPROCESSORS) {
Tcl_SetVar2(interp, "tcl_platform", "machine",
processors[sys.oemId.wProcessorArchitecture],
TCL_GLOBAL_ONLY);
}
|
| ︙ | ︙ | |||
551 552 553 554 555 556 557 | * TclpFindVariable -- * * Locate the entry in environ for a given name. On Unix this routine is * case sensitive, on Windows this matches mixed case. * * Results: * The return value is the index in environ of an entry with the name | | | | | | 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
* TclpFindVariable --
*
* Locate the entry in environ for a given name. On Unix this routine is
* case sensitive, on Windows this matches mixed case.
*
* Results:
* The return value is the index in environ of an entry with the name
* "name", or -1 if there is no such entry. The integer
* at *lengthPtr is filled in with the length of name (if a matching
* entry is found) or the length of the environ array (if no
* matching entry is found).
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
# define tenviron2utfdstr(string, len, dsPtr) \
(char *)Tcl_Char16ToUtfDString((const unsigned short *)(string), ((((len) + 2) >> 1) - 1), (dsPtr))
Tcl_Size
TclpFindVariable(
const char *name, /* Name of desired environment variable
* (UTF-8). */
Tcl_Size *lengthPtr) /* Used to return length of name (for
* successful searches) or number of non-NULL
* entries in environ (for unsuccessful
* searches). */
{
Tcl_Size i, length, result = -1;
const WCHAR *env;
const char *p1, *p2;
char *envUpper, *nameUpper;
Tcl_DString envString;
/*
* Convert the name to all upper case for the case insensitive comparison.
|
| ︙ | ︙ | |||
600 601 602 603 604 605 606 | /* * Chop the env string off after the equal sign, then Convert the name * to all upper case, so we do not have to convert all the characters * after the equal sign. */ Tcl_DStringInit(&envString); | | | 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
/*
* Chop the env string off after the equal sign, then Convert the name
* to all upper case, so we do not have to convert all the characters
* after the equal sign.
*/
Tcl_DStringInit(&envString);
envUpper = Tcl_WCharToUtfDString(env, -1, &envString);
p1 = strchr(envUpper, '=');
if (p1 == NULL) {
continue;
}
length = p1 - envUpper;
Tcl_DStringSetLength(&envString, length+1);
Tcl_UtfToUpper(envUpper);
|
| ︙ | ︙ |
Changes to win/tclWinInt.h.
| ︙ | ︙ | |||
39 40 41 42 43 44 45 | MODULE_SCOPE char TclWinDriveLetterForVolMountPoint( const WCHAR *mountPoint); MODULE_SCOPE void TclWinEncodingsCleanup(void); MODULE_SCOPE void TclWinInit(HINSTANCE hInst); MODULE_SCOPE TclFile TclWinMakeFile(HANDLE handle); MODULE_SCOPE Tcl_Channel TclWinOpenConsoleChannel(HANDLE handle, char *channelName, int permissions); | < < | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | MODULE_SCOPE char TclWinDriveLetterForVolMountPoint( const WCHAR *mountPoint); MODULE_SCOPE void TclWinEncodingsCleanup(void); MODULE_SCOPE void TclWinInit(HINSTANCE hInst); MODULE_SCOPE TclFile TclWinMakeFile(HANDLE handle); MODULE_SCOPE Tcl_Channel TclWinOpenConsoleChannel(HANDLE handle, char *channelName, int permissions); MODULE_SCOPE Tcl_Channel TclWinOpenSerialChannel(HANDLE handle, char *channelName, int permissions); MODULE_SCOPE HANDLE TclWinSerialOpen(HANDLE handle, const WCHAR *name, DWORD access); MODULE_SCOPE int TclWinSymLinkCopyDirectory(const WCHAR *LinkOriginal, const WCHAR *LinkCopy); MODULE_SCOPE int TclWinSymLinkDelete(const WCHAR *LinkOriginal, |
| ︙ | ︙ |
Changes to win/tclWinNotify.c.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tclInt.h" /* | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tclInt.h" /* * The following static indicates whether this module has been initialized. */ #define INTERVAL_TIMER 1 /* Handle of interval timer. */ #define WM_WAKEUP WM_USER /* Message that is send by * Tcl_AlertNotifier. */ /* |
| ︙ | ︙ |
Changes to win/tclWinPipe.c.
| ︙ | ︙ | |||
919 920 921 922 923 924 925 |
* arguments have not been converted. */
TclFile inputFile, /* If non-NULL, gives the file to use as input
* for the child process. If inputFile file is
* not readable or is NULL, the child will
* receive no standard input. */
TclFile outputFile, /* If non-NULL, gives the file that receives
* output from the child process. If
| | | | 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
* arguments have not been converted. */
TclFile inputFile, /* If non-NULL, gives the file to use as input
* for the child process. If inputFile file is
* not readable or is NULL, the child will
* receive no standard input. */
TclFile outputFile, /* If non-NULL, gives the file that receives
* output from the child process. If
* outputFile file is not writable or is
* NULL, output from the child will be
* discarded. */
TclFile errorFile, /* If non-NULL, gives the file that receives
* errors from the child process. If errorFile
* file is not writable or is NULL, errors
* from the child will be discarded. errorFile
* may be the same as outputFile. */
Tcl_Pid *pidPtr) /* If this function is successful, pidPtr is
* filled with the process id of the child
* process. */
{
int result, applType, createFlags;
|
| ︙ | ︙ | |||
1819 1820 1821 1822 1823 1824 1825 |
/*
* For backward compatibility with previous versions of Tcl, we use
* "file%d" as the base name for pipes even though it would be more
* natural to use "pipe%d". Use the pointer to keep the channel names
* unique, in case channels share handles (stdin/stdout).
*/
| | | 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 |
/*
* For backward compatibility with previous versions of Tcl, we use
* "file%d" as the base name for pipes even though it would be more
* natural to use "pipe%d". Use the pointer to keep the channel names
* unique, in case channels share handles (stdin/stdout).
*/
snprintf(channelName, sizeof(channelName), "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
infoPtr->channel = Tcl_CreateChannel(&pipeChannelType, channelName,
infoPtr, infoPtr->validMask);
Tcl_SetChannelOption(NULL, infoPtr->channel, "-translation", "auto");
return infoPtr->channel;
}
|
| ︙ | ︙ | |||
2701 2702 2703 2704 2705 2706 2707 |
*/
void
TclWinAddProcess(
void *hProcess, /* Handle to process */
size_t id) /* Global process identifier */
{
| | | 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 |
*/
void
TclWinAddProcess(
void *hProcess, /* Handle to process */
size_t id) /* Global process identifier */
{
ProcInfo *procPtr = (ProcInfo *)Tcl_Alloc(sizeof(ProcInfo));
PipeInit();
procPtr->hProcess = hProcess;
procPtr->dwProcessId = id;
Tcl_MutexLock(&pipeMutex);
procPtr->nextPtr = procList;
|
| ︙ | ︙ | |||
2801 2802 2803 2804 2805 2806 2807 |
static int
WaitForRead(
PipeInfo *infoPtr, /* Pipe state. */
int blocking) /* Indicates whether call should be blocking
* or not. */
{
DWORD timeout, count;
| | | 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 |
static int
WaitForRead(
PipeInfo *infoPtr, /* Pipe state. */
int blocking) /* Indicates whether call should be blocking
* or not. */
{
DWORD timeout, count;
HANDLE handle = ((WinFile *) infoPtr->readFile)->handle;
while (1) {
/*
* Synchronize with the reader thread.
*/
/* avoid blocking if pipe-thread exited */
|
| ︙ | ︙ | |||
3134 3135 3136 3137 3138 3139 3140 |
int action)
{
PipeInfo *infoPtr = (PipeInfo *) instanceData;
/*
* We do not access firstPipePtr in the thread structures. This is not for
* all pipes managed by the thread, but only those we are watching.
| | | 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 |
int action)
{
PipeInfo *infoPtr = (PipeInfo *) instanceData;
/*
* We do not access firstPipePtr in the thread structures. This is not for
* all pipes managed by the thread, but only those we are watching.
* Removal of the fileevent handlers before transfer thus takes care of
* this structure.
*/
Tcl_MutexLock(&pipeMutex);
if (action == TCL_CHANNEL_THREAD_INSERT) {
/*
* We can't copy the thread information from the channel when the
|
| ︙ | ︙ | |||
3223 3224 3225 3226 3227 3228 3229 |
counter = TclpGetClicks() % 65533;
counter2 = 1024; /* Only try this many times! Prevents
* an infinite loop. */
do {
char number[TCL_INTEGER_SPACE + 4];
| | | 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 |
counter = TclpGetClicks() % 65533;
counter2 = 1024; /* Only try this many times! Prevents
* an infinite loop. */
do {
char number[TCL_INTEGER_SPACE + 4];
snprintf(number, sizeof(number), "%d.TMP", counter);
counter = (unsigned short) (counter + 1);
Tcl_DStringInit(&buf);
Tcl_UtfToWCharDString(number, strlen(number), &buf);
Tcl_DStringSetLength(&buf, Tcl_DStringLength(&buf) + 1);
memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf) + 1);
Tcl_DStringFree(&buf);
|
| ︙ | ︙ |
Changes to win/tclWinReg.c.
| ︙ | ︙ | |||
778 779 780 781 782 783 784 |
/*
* Initialize a Dstring to maximum statically allocated size we could get
* one more byte by avoiding Tcl_DStringSetLength() and just setting
* length to TCL_DSTRING_STATIC_SIZE, but this should be safer if the
* implementation of Dstrings changes.
*
| | | 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 |
/*
* Initialize a Dstring to maximum statically allocated size we could get
* one more byte by avoiding Tcl_DStringSetLength() and just setting
* length to TCL_DSTRING_STATIC_SIZE, but this should be safer if the
* implementation of Dstrings changes.
*
* This allows short values to be read from the registry in one call.
* Longer values need a second call with an expanded DString.
*/
Tcl_DStringInit(&data);
Tcl_DStringSetLength(&data, TCL_DSTRING_STATIC_SIZE - 1);
length = TCL_DSTRING_STATIC_SIZE/sizeof(WCHAR) - 1;
|
| ︙ | ︙ | |||
872 873 874 875 876 877 878 | } /* *---------------------------------------------------------------------- * * GetValueNames -- * | | | 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 | } /* *---------------------------------------------------------------------- * * GetValueNames -- * * This function enumerates the values of the given key. If the * optional pattern is supplied, then only value names that match the * pattern will be returned. * * Results: * Returns the list of value names in the result object of the * interpreter, or an error message on failure. * |
| ︙ | ︙ | |||
1008 1009 1010 1011 1012 1013 1014 | } /* *---------------------------------------------------------------------- * * OpenSubKey -- * | | | 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | } /* *---------------------------------------------------------------------- * * OpenSubKey -- * * Opens a given subkey of the given root key on the specified * host. * * Results: * Returns the opened key in the keyPtr and a Windows error code as the * return value. * * Side effects: |
| ︙ | ︙ | |||
1093 1094 1095 1096 1097 1098 1099 | } /* *---------------------------------------------------------------------- * * ParseKeyName -- * | | | 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 | } /* *---------------------------------------------------------------------- * * ParseKeyName -- * * Parses a key name into the host, root, and subkey parts. * * Results: * The pointers to the start of the host and subkey names are returned in * the hostNamePtr and keyNamePtr variables. The specified root HKEY is * returned in rootKeyPtr. Returns a standard Tcl result. * * Side effects: |
| ︙ | ︙ | |||
1325 1326 1327 1328 1329 1330 1331 |
}
value = ConvertDWORD((DWORD) type, (DWORD) value);
result = RegSetValueExW(key, (WCHAR *) valueName, 0,
(DWORD) type, (BYTE *) &value, sizeof(DWORD));
} else if (type == REG_MULTI_SZ) {
Tcl_DString data, buf;
| | | 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 |
}
value = ConvertDWORD((DWORD) type, (DWORD) value);
result = RegSetValueExW(key, (WCHAR *) valueName, 0,
(DWORD) type, (BYTE *) &value, sizeof(DWORD));
} else if (type == REG_MULTI_SZ) {
Tcl_DString data, buf;
Tcl_Size objc, i;
Tcl_Obj **objv;
if (Tcl_ListObjGetElements(interp, dataObj, &objc, &objv) != TCL_OK) {
RegCloseKey(key);
Tcl_DStringFree(&nameBuf);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1472 1473 1474 1475 1476 1477 1478 | } /* *---------------------------------------------------------------------- * * AppendSystemError -- * | | | 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 | } /* *---------------------------------------------------------------------- * * AppendSystemError -- * * Formats a Windows system error message and places it into * the interpreter result. * * Results: * None. * * Side effects: * None. |
| ︙ | ︙ | |||
1504 1505 1506 1507 1508 1509 1510 |
resultPtr = Tcl_DuplicateObj(resultPtr);
}
length = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *) tMsgPtrPtr,
0, NULL);
if (length == 0) {
| | | 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 |
resultPtr = Tcl_DuplicateObj(resultPtr);
}
length = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *) tMsgPtrPtr,
0, NULL);
if (length == 0) {
snprintf(msgBuf, sizeof(msgBuf), "unknown error: %ld", error);
msg = msgBuf;
} else {
char *msgPtr;
Tcl_DStringInit(&ds);
Tcl_WCharToUtfDString(tMsgPtr, wcslen(tMsgPtr), &ds);
LocalFree(tMsgPtr);
|
| ︙ | ︙ | |||
1530 1531 1532 1533 1534 1535 1536 |
if (msgPtr[length-1] == '\r') {
--length;
}
msgPtr[length] = 0;
msg = msgPtr;
}
| | | | 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 |
if (msgPtr[length-1] == '\r') {
--length;
}
msgPtr[length] = 0;
msg = msgPtr;
}
snprintf(id, sizeof(id), "%ld", error);
Tcl_SetErrorCode(interp, "WINDOWS", id, msg, NULL);
Tcl_AppendToObj(resultPtr, msg, length);
Tcl_SetObjResult(interp, resultPtr);
if (length != 0) {
Tcl_DStringFree(&ds);
}
}
/*
*----------------------------------------------------------------------
*
* ConvertDWORD --
*
* Determines whether a DWORD needs to be byte swapped, and
* returns the appropriately swapped value.
*
* Results:
* Returns a converted DWORD.
*
* Side effects:
* None.
|
| ︙ | ︙ |
Changes to win/tclWinSerial.c.
| ︙ | ︙ | |||
331 332 333 334 335 336 337 | } /* *---------------------------------------------------------------------- * * SerialBlockTime -- * | | | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | } /* *---------------------------------------------------------------------- * * SerialBlockTime -- * * Wrapper to set Tcl's block time in msec. * * Results: * None. * * Side effects: * Updates the maximum blocking time. * |
| ︙ | ︙ | |||
900 901 902 903 904 905 906 |
}
} else {
errno = *errorCode = EWOULDBLOCK;
return -1;
}
} else {
/*
| | | 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 |
}
} else {
errno = *errorCode = EWOULDBLOCK;
return -1;
}
} else {
/*
* BLOCKING mode: Tcl tries to read a full buffer of 4 kBytes here.
*/
if (cStat.cbInQue > 0) {
if ((DWORD) bufSize > cStat.cbInQue) {
bufSize = cStat.cbInQue;
}
} else {
|
| ︙ | ︙ | |||
969 970 971 972 973 974 975 |
{
SerialInfo *infoPtr = (SerialInfo *) instanceData;
DWORD bytesWritten, timeout;
*errorCode = 0;
/*
| | | | 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 |
{
SerialInfo *infoPtr = (SerialInfo *) instanceData;
DWORD bytesWritten, timeout;
*errorCode = 0;
/*
* At EXIT Tcl tries to flush all open channels in blocking mode. We avoid
* blocking output after ExitProc or CloseHandler(chan) has been called by
* checking the corresponding variables.
*/
if (!initialized || TclInExit()) {
return toWrite;
}
/*
|
| ︙ | ︙ | |||
1454 1455 1456 1457 1458 1459 1460 |
SerialInfo *infoPtr;
SerialInit();
infoPtr = (SerialInfo *)Tcl_Alloc(sizeof(SerialInfo));
memset(infoPtr, 0, sizeof(SerialInfo));
| | | | 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 |
SerialInfo *infoPtr;
SerialInit();
infoPtr = (SerialInfo *)Tcl_Alloc(sizeof(SerialInfo));
memset(infoPtr, 0, sizeof(SerialInfo));
infoPtr->validMask = permissions & (TCL_READABLE|TCL_WRITABLE);
infoPtr->handle = handle;
infoPtr->channel = (Tcl_Channel) NULL;
infoPtr->readable = 0;
infoPtr->writable = 1;
infoPtr->toWrite = infoPtr->writeQueue = 0;
infoPtr->blockTime = SERIAL_DEFAULT_BLOCKTIME;
infoPtr->lastEventTime = 0;
infoPtr->lastError = infoPtr->error = 0;
infoPtr->threadId = Tcl_GetCurrentThread();
infoPtr->sysBufRead = 4096;
infoPtr->sysBufWrite = 4096;
/*
* Use the pointer to keep the channel names unique, in case the handles
* are shared between multiple channels (stdin/stdout).
*/
snprintf(channelName, 16 + TCL_INTEGER_SPACE, "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
infoPtr->channel = Tcl_CreateChannel(&serialChannelType, channelName,
infoPtr, permissions);
SetupComm(handle, infoPtr->sysBufRead, infoPtr->sysBufWrite);
PurgeComm(handle,
|
| ︙ | ︙ | |||
1554 1555 1556 1557 1558 1559 1560 |
}
if (error & CE_PTO) { /* PTO used to signal WRITE-TIMEOUT */
Tcl_DStringAppendElement(dsPtr, "TIMEOUT");
}
if (error & ~((DWORD) (SERIAL_READ_ERRORS | SERIAL_WRITE_ERRORS))) {
char buf[TCL_INTEGER_SPACE + 1];
| | | 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 |
}
if (error & CE_PTO) { /* PTO used to signal WRITE-TIMEOUT */
Tcl_DStringAppendElement(dsPtr, "TIMEOUT");
}
if (error & ~((DWORD) (SERIAL_READ_ERRORS | SERIAL_WRITE_ERRORS))) {
char buf[TCL_INTEGER_SPACE + 1];
snprintf(buf, sizeof(buf), "%ld", error);
Tcl_DStringAppendElement(dsPtr, buf);
}
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
1620 1621 1622 1623 1624 1625 1626 |
{
SerialInfo *infoPtr;
DCB dcb;
BOOL result, flag;
size_t len, vlen;
Tcl_DString ds;
const WCHAR *native;
| | | 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 |
{
SerialInfo *infoPtr;
DCB dcb;
BOOL result, flag;
size_t len, vlen;
Tcl_DString ds;
const WCHAR *native;
Tcl_Size argc;
const char **argv;
infoPtr = (SerialInfo *) instanceData;
/*
* Parse options. This would be far easier if we had Tcl_Objs to work with
* as that would let us use Tcl_GetIndexFromObj()...
|
| ︙ | ︙ | |||
1816 1817 1818 1819 1820 1821 1822 |
}
/*
* Option -ttycontrol {DTR 1 RTS 0 BREAK 0}
*/
if ((len > 4) && (strncmp(optionName, "-ttycontrol", len) == 0)) {
| | | 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 |
}
/*
* Option -ttycontrol {DTR 1 RTS 0 BREAK 0}
*/
if ((len > 4) && (strncmp(optionName, "-ttycontrol", len) == 0)) {
Tcl_Size i;
int res = TCL_OK;
if (Tcl_SplitList(interp, value, &argc, &argv) == TCL_ERROR) {
return TCL_ERROR;
}
if ((argc % 2) == 1) {
if (interp != NULL) {
|
| ︙ | ︙ | |||
2101 2102 2103 2104 2105 2106 2107 |
parity = 'n';
if (dcb.Parity <= 4) {
parity = "noems"[dcb.Parity];
}
stop = (dcb.StopBits == ONESTOPBIT) ? "1" :
(dcb.StopBits == ONE5STOPBITS) ? "1.5" : "2";
| | | | | | 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 |
parity = 'n';
if (dcb.Parity <= 4) {
parity = "noems"[dcb.Parity];
}
stop = (dcb.StopBits == ONESTOPBIT) ? "1" :
(dcb.StopBits == ONE5STOPBITS) ? "1.5" : "2";
snprintf(buf, sizeof(buf), "%ld,%c,%d,%s", dcb.BaudRate, parity,
dcb.ByteSize, stop);
Tcl_DStringAppendElement(dsPtr, buf);
}
/*
* Get option -pollinterval
*/
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-pollinterval");
}
if (len==0 || (len>1 && strncmp(optionName, "-pollinterval", len)==0)) {
char buf[TCL_INTEGER_SPACE + 1];
valid = 1;
snprintf(buf, sizeof(buf), "%d", infoPtr->blockTime);
Tcl_DStringAppendElement(dsPtr, buf);
}
/*
* Get option -sysbuffer
*/
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-sysbuffer");
Tcl_DStringStartSublist(dsPtr);
}
if (len==0 || (len>1 && strncmp(optionName, "-sysbuffer", len) == 0)) {
char buf[TCL_INTEGER_SPACE + 1];
valid = 1;
snprintf(buf, sizeof(buf), "%ld", infoPtr->sysBufRead);
Tcl_DStringAppendElement(dsPtr, buf);
snprintf(buf, sizeof(buf), "%ld", infoPtr->sysBufWrite);
Tcl_DStringAppendElement(dsPtr, buf);
}
if (len == 0) {
Tcl_DStringEndSublist(dsPtr);
}
/*
|
| ︙ | ︙ | |||
2216 2217 2218 2219 2220 2221 2222 | */ EnterCriticalSection(&infoPtr->csWrite); ClearCommError(infoPtr->handle, &error, &cStat); count = (int) cStat.cbOutQue + infoPtr->writeQueue; LeaveCriticalSection(&infoPtr->csWrite); | | | | 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 |
*/
EnterCriticalSection(&infoPtr->csWrite);
ClearCommError(infoPtr->handle, &error, &cStat);
count = (int) cStat.cbOutQue + infoPtr->writeQueue;
LeaveCriticalSection(&infoPtr->csWrite);
snprintf(buf, sizeof(buf), "%ld", inBuffered + cStat.cbInQue);
Tcl_DStringAppendElement(dsPtr, buf);
snprintf(buf, sizeof(buf), "%d", outBuffered + count);
Tcl_DStringAppendElement(dsPtr, buf);
}
/*
* get option -ttystatus
*
* Option is readonly and returned by [fconfigure chan -ttystatus] but not
|
| ︙ | ︙ | |||
2278 2279 2280 2281 2282 2283 2284 |
int action)
{
SerialInfo *infoPtr = (SerialInfo *) instanceData;
/*
* We do not access firstSerialPtr in the thread structures. This is not
* for all serials managed by the thread, but only those we are watching.
| | | 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 |
int action)
{
SerialInfo *infoPtr = (SerialInfo *) instanceData;
/*
* We do not access firstSerialPtr in the thread structures. This is not
* for all serials managed by the thread, but only those we are watching.
* Removal of the fileevent handlers before transfer thus takes care of
* this structure.
*/
Tcl_MutexLock(&serialMutex);
if (action == TCL_CHANNEL_THREAD_INSERT) {
/*
* We can't copy the thread information from the channel when the
|
| ︙ | ︙ |
Changes to win/tclWinSock.c.
| ︙ | ︙ | |||
101 102 103 104 105 106 107 | } address; #ifndef IN6_ARE_ADDR_EQUAL #define IN6_ARE_ADDR_EQUAL IN6_ADDR_EQUAL #endif /* | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
} address;
#ifndef IN6_ARE_ADDR_EQUAL
#define IN6_ARE_ADDR_EQUAL IN6_ADDR_EQUAL
#endif
/*
* This structure describes per-instance state of a tcp-based channel.
*/
typedef struct TcpState TcpState;
typedef struct TcpFdList {
TcpState *statePtr;
SOCKET fd;
|
| ︙ | ︙ | |||
157 158 159 160 161 162 163 |
* This error is still a windows error code.
* Access must be protected by semaphore */
struct TcpState *nextPtr; /* The next socket on the per-thread socket
* list. */
};
/*
| | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
* This error is still a windows error code.
* Access must be protected by semaphore */
struct TcpState *nextPtr; /* The next socket on the per-thread socket
* list. */
};
/*
* These bits may be OR'ed together into the "flags" field of a TcpState
* structure.
*/
#define TCP_NONBLOCKING (1<<0) /* Socket with non-blocking I/O */
#define TCP_ASYNC_CONNECT (1<<1) /* Async connect in progress. */
#define SOCKET_EOF (1<<2) /* A zero read happened on the
* socket. */
|
| ︙ | ︙ | |||
545 546 547 548 549 550 551 | * * There are two modes of operation, defined by errorCodePtr: * * non-NULL: Called by explicite read/write command. Block if socket * is blocking. * May return two error codes: * * EWOULDBLOCK: if connect is still in progress * * ENOTCONN: if connect failed. This would be the error message | | | | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | * * There are two modes of operation, defined by errorCodePtr: * * non-NULL: Called by explicite read/write command. Block if socket * is blocking. * May return two error codes: * * EWOULDBLOCK: if connect is still in progress * * ENOTCONN: if connect failed. This would be the error message * of a recv or sendto syscall so this is emulated here. * * Null: Called by a background operation. Do not block and don't * return any error code. * * Results: * 0 if the connection has completed, -1 if still in progress or there is * an error. * * Side effects: |
| ︙ | ︙ | |||
634 635 636 637 638 639 640 | * Consume the connect event. */ CLEAR_BITS(statePtr->readyEvents, FD_CONNECT); /* * For blocking sockets and foreground processing, disable async | | | | | 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
* Consume the connect event.
*/
CLEAR_BITS(statePtr->readyEvents, FD_CONNECT);
/*
* For blocking sockets and foreground processing, disable async
* connect as we continue now synchronously.
*/
if (errorCodePtr != NULL &&
!GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
}
/*
* Free list lock.
*/
SetEvent(tsdPtr->socketListLock);
/*
* Continue connect. If switched to synchronous connect, the
* connect is terminated.
*/
result = TcpConnect(NULL, statePtr);
/*
* Restore event service mode.
*/
(void) Tcl_SetServiceMode(oldMode);
/*
* Check for Successful connect or async connect restart
*/
if (result == TCL_OK) {
/*
* Check for async connect restart (not possible for
* foreground blocking operation)
*/
|
| ︙ | ︙ | |||
822 823 824 825 826 827 828 | break; } error = WSAGetLastError(); /* * If an RST comes, then ignore the error and report an EOF just like | | | 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 |
break;
}
error = WSAGetLastError();
/*
* If an RST comes, then ignore the error and report an EOF just like
* on Unix.
*/
if (error == WSAECONNRESET) {
SET_BITS(statePtr->flags, SOCKET_EOF);
bytesRead = 0;
break;
}
|
| ︙ | ︙ | |||
1219 1220 1221 1222 1223 1224 1225 |
size_t len = 0;
int reverseDNS = 0;
#define SUPPRESS_RDNS_VAR "::tcl::unsupported::noReverseDNS"
/*
* Go one step in async connect
*
| | | 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 |
size_t len = 0;
int reverseDNS = 0;
#define SUPPRESS_RDNS_VAR "::tcl::unsupported::noReverseDNS"
/*
* Go one step in async connect
*
* If any error is thrown save it as background error to report eventually
* below.
*/
if (!GOT_BITS(statePtr->flags, TCP_ASYNC_TEST_MODE)) {
WaitForConnect(statePtr, NULL);
}
|
| ︙ | ︙ | |||
1766 1767 1768 1769 1770 1771 1772 |
statePtr->addr->ai_addrlen);
error = WSAGetLastError();
Tcl_WinConvertError(error);
if (async_connect && error == WSAEWOULDBLOCK) {
/*
| | | 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 |
statePtr->addr->ai_addrlen);
error = WSAGetLastError();
Tcl_WinConvertError(error);
if (async_connect && error == WSAEWOULDBLOCK) {
/*
* Asynchronous connect
*
* Remember that we jump back behind this next round
*/
SET_BITS(statePtr->flags, TCP_ASYNC_PENDING);
return TCL_OK;
|
| ︙ | ︙ | |||
1835 1836 1837 1838 1839 1840 1841 |
* Async connect terminated
*/
CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
if (Tcl_GetErrno() == 0) {
/*
| | | 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 |
* Async connect terminated
*/
CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
if (Tcl_GetErrno() == 0) {
/*
* Successfully connected
*
* Set up the select mask for read/write events.
*/
statePtr->selectEvents = FD_READ | FD_WRITE | FD_CLOSE;
/*
|
| ︙ | ︙ | |||
1894 1895 1896 1897 1898 1899 1900 | * Free list lock. */ SetEvent(tsdPtr->socketListLock); } /* | | | 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 |
* Free list lock.
*/
SetEvent(tsdPtr->socketListLock);
}
/*
* Error message on synchronous connect
*/
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't open socket: %s", Tcl_PosixError(interp)));
}
return TCL_ERROR;
|
| ︙ | ︙ | |||
1973 1974 1975 1976 1977 1978 1979 |
* Create a new client socket and wrap it in a channel.
*/
if (TcpConnect(interp, statePtr) != TCL_OK) {
TcpCloseProc(statePtr, NULL);
return NULL;
}
| | | 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 |
* Create a new client socket and wrap it in a channel.
*/
if (TcpConnect(interp, statePtr) != TCL_OK) {
TcpCloseProc(statePtr, NULL);
return NULL;
}
snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, (TCL_READABLE | TCL_WRITABLE));
if (TCL_ERROR == Tcl_SetChannelOption(NULL, statePtr->channel,
"-translation", "auto crlf")) {
Tcl_CloseEx(NULL, statePtr->channel, 0);
return NULL;
|
| ︙ | ︙ | |||
2032 2033 2034 2035 2036 2037 2038 |
/*
* Start watching for read/write events on the socket.
*/
statePtr->selectEvents = FD_READ | FD_CLOSE | FD_WRITE;
SendSelectMessage(tsdPtr, SELECT, statePtr);
| | | 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 |
/*
* Start watching for read/write events on the socket.
*/
statePtr->selectEvents = FD_READ | FD_CLOSE | FD_WRITE;
SendSelectMessage(tsdPtr, SELECT, statePtr);
snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, (TCL_READABLE | TCL_WRITABLE));
Tcl_SetChannelOption(NULL, statePtr->channel, "-translation", "auto crlf");
return statePtr->channel;
}
/*
|
| ︙ | ︙ | |||
2204 2205 2206 2207 2208 2209 2210 |
}
if (statePtr != NULL) {
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)TclThreadDataKeyGet(&dataKey);
statePtr->acceptProc = acceptProc;
statePtr->acceptProcData = acceptProcData;
| | | 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 |
}
if (statePtr != NULL) {
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)TclThreadDataKeyGet(&dataKey);
statePtr->acceptProc = acceptProc;
statePtr->acceptProcData = acceptProcData;
snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, 0);
/*
* Set up the select mask for connection request events.
*/
statePtr->selectEvents = FD_ACCEPT;
|
| ︙ | ︙ | |||
2289 2290 2291 2292 2293 2294 2295 |
/*
* Select on read/write events and create the channel.
*/
newInfoPtr->selectEvents = (FD_READ | FD_WRITE | FD_CLOSE);
SendSelectMessage(tsdPtr, SELECT, newInfoPtr);
| | | 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 |
/*
* Select on read/write events and create the channel.
*/
newInfoPtr->selectEvents = (FD_READ | FD_WRITE | FD_CLOSE);
SendSelectMessage(tsdPtr, SELECT, newInfoPtr);
snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, newInfoPtr);
newInfoPtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
newInfoPtr, (TCL_READABLE | TCL_WRITABLE));
if (Tcl_SetChannelOption(NULL, newInfoPtr->channel, "-translation",
"auto crlf") == TCL_ERROR) {
Tcl_CloseEx(NULL, newInfoPtr->channel, 0);
return;
}
|
| ︙ | ︙ | |||
2929 2930 2931 2932 2933 2934 2935 | /* * Get statePtr lock. */ WaitForSingleObject(tsdPtr->socketListLock, INFINITE); /* | | | | 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 |
/*
* Get statePtr lock.
*/
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
/*
* Check if event occurred.
*/
event_found = GOT_BITS(statePtr->readyEvents, events);
/*
* Free list lock.
*/
SetEvent(tsdPtr->socketListLock);
/*
* Exit loop if event occurred.
*/
if (event_found) {
break;
}
/*
|
| ︙ | ︙ | |||
3046 3047 3048 3049 3050 3051 3052 | * interest in a socket event, and the event has occurred. * * Results: * 0 on success. * * Side effects: * The flags for the given socket are updated to reflect the event that | | | 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 |
* interest in a socket event, and the event has occurred.
*
* Results:
* 0 on success.
*
* Side effects:
* The flags for the given socket are updated to reflect the event that
* occurred.
*
*----------------------------------------------------------------------
*/
static LRESULT CALLBACK
SocketProc(
HWND hwnd,
|
| ︙ | ︙ | |||
3196 3197 3198 3199 3200 3201 3202 | } /* *---------------------------------------------------------------------- * * FindFDInList -- * | | | 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 | } /* *---------------------------------------------------------------------- * * FindFDInList -- * * Return true, if the given file descriptor is contained in the * file descriptor list. * * Results: * true if found. * * Side effects: * |
| ︙ | ︙ |
Changes to win/tclWinThrd.c.
| ︙ | ︙ | |||
773 774 775 776 777 778 779 |
*/
if (timeout) {
if (tsdPtr->flags & WIN_THREAD_RUNNING) {
timeout = 0;
} else {
/*
| | | | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 |
*/
if (timeout) {
if (tsdPtr->flags & WIN_THREAD_RUNNING) {
timeout = 0;
} else {
/*
* When dequeueing, we can leave the tsdPtr->nextPtr and
* tsdPtr->prevPtr with dangling pointers because they are
* reinitialized w/out reading them when the thread is enqueued
* later.
*/
if (winCondPtr->firstPtr == tsdPtr) {
winCondPtr->firstPtr = tsdPtr->nextPtr;
} else {
tsdPtr->prevPtr->nextPtr = tsdPtr->nextPtr;
|
| ︙ | ︙ |
Changes to win/tclWinTime.c.
| ︙ | ︙ | |||
618 619 620 621 622 623 624 |
/*
* If calibration cycle occurred after we get curCounter
*/
if (curCounter.QuadPart <= perfCounterLastCall) {
/*
| | | | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
/*
* If calibration cycle occurred after we get curCounter
*/
if (curCounter.QuadPart <= perfCounterLastCall) {
/*
* Calibrated file-time is saved from Posix in 100-ns ticks
*/
return fileTimeLastCall / 10;
}
/*
* If it appears to be more than 1.1 seconds since the last trip
* through the calibration loop, the performance counter may have
* jumped forward. (See MSDN Knowledge Base article Q274323 for a
* description of the hardware problem that makes this test
* necessary.) If the counter jumps, we don't want to use it directly.
* Instead, we must return system time. Eventually, the calibration
* loop should recover.
*/
if (curCounter.QuadPart - perfCounterLastCall <
11 * curCounterFreq * timeInfo.calibrationInterv / 10) {
/*
* Calibrated file-time is saved from Posix in 100-ns ticks.
*/
return NativeCalc100NsTicks(fileTimeLastCall,
perfCounterLastCall, curCounterFreq,
curCounter.QuadPart) / 10;
}
}
|
| ︙ | ︙ | |||
778 779 780 781 782 783 784 |
GetSystemTimeAsFileTime(&curFileTime);
QueryPerformanceCounter(&timeInfo.perfCounterLastCall);
QueryPerformanceFrequency(&timeInfo.curCounterFreq);
timeInfo.fileTimeLastCall.LowPart = curFileTime.dwLowDateTime;
timeInfo.fileTimeLastCall.HighPart = curFileTime.dwHighDateTime;
/*
| | | 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 |
GetSystemTimeAsFileTime(&curFileTime);
QueryPerformanceCounter(&timeInfo.perfCounterLastCall);
QueryPerformanceFrequency(&timeInfo.curCounterFreq);
timeInfo.fileTimeLastCall.LowPart = curFileTime.dwLowDateTime;
timeInfo.fileTimeLastCall.HighPart = curFileTime.dwHighDateTime;
/*
* Calibrated file-time will be saved from Posix in 100-ns ticks.
*/
timeInfo.fileTimeLastCall.QuadPart -= timeInfo.posixEpoch.QuadPart;
ResetCounterSamples(timeInfo.fileTimeLastCall.QuadPart,
timeInfo.perfCounterLastCall.QuadPart,
timeInfo.curCounterFreq.QuadPart);
|
| ︙ | ︙ | |||
853 854 855 856 857 858 859 |
long long vt1; /* Tcl time one second from now. */
long long tdiff; /* Difference between system clock and Tcl
* time. */
long long driftFreq; /* Frequency needed to drift virtual time into
* step over 1 second. */
/*
| | | 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 |
long long vt1; /* Tcl time one second from now. */
long long tdiff; /* Difference between system clock and Tcl
* time. */
long long driftFreq; /* Frequency needed to drift virtual time into
* step over 1 second. */
/*
* Sample performance counter and system time (from Posix epoch).
*/
GetSystemTimeAsFileTime(&curSysTime);
curFileTime.LowPart = curSysTime.dwLowDateTime;
curFileTime.HighPart = curSysTime.dwHighDateTime;
curFileTime.QuadPart -= timeInfo.posixEpoch.QuadPart;
|
| ︙ | ︙ | |||
878 879 880 881 882 883 884 |
return;
}
QueryPerformanceCounter(&curPerfCounter);
lastFileTime.QuadPart = curFileTime.QuadPart;
/*
| | | 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 |
return;
}
QueryPerformanceCounter(&curPerfCounter);
lastFileTime.QuadPart = curFileTime.QuadPart;
/*
* We divide by timeInfo.curCounterFreq.QuadPart in several places. That
* value should always be positive on a correctly functioning system. But
* it is good to be defensive about such matters. So if something goes
* wrong and the value does goes to zero, we clear the
* timeInfo.perfCounterAvailable in order to cause the calibration thread
* to shut itself down, then return without additional processing.
*/
|
| ︙ | ︙ |