Compare commits

...
Author SHA1 Message Date
apnadkarni 37289addc2 Fix up tests for modified Tcl_GetIntForIndex semantics 2023-08-13 13:37:23 +00:00
apnadkarni e2d5a2cd60 Merge in fix for end+1 indices. 2023-08-13 11:56:12 +00:00
apnadkarni 5860a89267 Fix for Tk [a9929f112a] 2023-08-13 10:35:29 +00:00
apnadkarni aa0e1c2bd9 Revert [0b05b5c750df] that broke bigdata tests and lseq-1.13 2023-08-13 06:22:28 +00:00
griffin baa91f87ba Rename Tcl_BumpObj() to Tcl_BounceRefCount().
After the presentation on Abstract Lists at the 2023 OpenACS/Tcl
Conference, there was a strong opinion that this function should be
renamed. The results of an informal poll had a tie between
Tcl_DoneWithObj() and Tcl_BounceRefCount(). Having seen a reference to
"Bounce" in a research paper on Ref Counting, I chose to use
Tcl_BounceRefCount().
2023-08-12 23:14:43 +00:00
dgp 946847b4b9 silence compiler warning 2023-08-10 14:09:55 +00:00
griffin 96b27040f7 Fix uninitialized variable. 2023-08-09 22:55:25 +00:00
griffin 7dc2ed805f Corrections and additions for ObjectType Abstract List descriptions. Part of bug [30e4e9102f] 2023-08-08 22:55:50 +00:00
griffin 0d106bd729 Fix bug [30e4e9102f] - Abstract List ListIndex should return NULL when index out of range. 2023-08-08 17:10:20 +00:00
griffin 4eef7b0ff0 Implement in,ni operator for abstract lists 2023-08-08 15:21:47 +00:00
apnadkarni 59462a578f Bug [f5c01e42a7]. Disable DictAsListIndex for the time being. 2023-08-08 06:02:32 +00:00
dgp 67a433cc8e quiet test noise 2023-08-04 14:06:34 +00:00
dgp b87eac8cd9 Add DECACHE/CACHE_STACK_INFO() protections to calls out of the bytecode
execution engine to avoid panics from corrupted execution stack.
2023-08-03 20:00:01 +00:00
jan.nijtmans 89cc07aa34 Merge 8.7 2023-08-03 13:04:33 +00:00
jan.nijtmans aeaba6971a Merge 8.7 2023-08-03 11:26:37 +00:00
jan.nijtmans a53c12b3b5 Implement TCL_LIB_FLAG/TCL_BUILD_LIB_SPEC for Windows (which - aparently - has always been just empty) 2023-08-03 10:59:49 +00:00
jan.nijtmans b29ad5dcf2 DOn't use --out-implib on Cygwin any more, no longer needed 2023-08-03 10:15:41 +00:00
jan.nijtmans a6714c6778 Merge 8.7 2023-08-02 20:51:52 +00:00
jan.nijtmans 0472854629 Merge 8.6 2023-08-02 19:34:00 +00:00
jan.nijtmans cca28f5ef3 deprecate TCL_EXPORT_FILE_SUFFIX: no longer needed. Fix some path handling containing spaces 2023-08-02 19:13:20 +00:00
jan.nijtmans e97b71f139 Merge 8.7 2023-08-01 16:12:15 +00:00
jan.nijtmans 47f462c33c Make sure that zdll.lib and tommath.lib are installed in windows, for possible use by extensions. 2023-08-01 16:09:48 +00:00
jan.nijtmans 66027ff8e6 Merge 8.7 2023-08-01 15:52:03 +00:00
jan.nijtmans 2e364fd375 Merge 8.6 2023-08-01 15:42:36 +00:00
jan.nijtmans cb7eb97a8d Add TCL_ZLIB_LIB_NAME to tclConfig.sh (for Windows) 2023-08-01 15:27:33 +00:00
jan.nijtmans 911d6f8e5e Merge 8.7 2023-08-01 13:57:28 +00:00
jan.nijtmans 09e16559af testcase cleanup 2023-08-01 13:19:26 +00:00
apnadkarni c94d0732e0 Bug [76d45ec836] - mingw - tommath not copied on install 2023-08-01 13:01:25 +00:00
jan.nijtmans 2618ae962a merge-mark 2023-08-01 06:53:46 +00:00
jan.nijtmans 82703fea0a merge-mark 2023-08-01 06:52:30 +00:00
jan.nijtmans 3b99720301 Prevent Tcl 8.6 header-file to be usable for Tcl 9 compiles. (see [6f22c7a1fc]) 2023-08-01 06:46:56 +00:00
jan.nijtmans f70182e63c Some more int -> Tcl_Size (backported from 9.0) 2023-08-01 06:39:33 +00:00
jan.nijtmans 1625f9f678 Fix [e58d7e19e9]: Upwards compatibility of TclObjTypeHasProc() 2023-07-31 15:58:14 +00:00
jan.nijtmans fddaf810d4 Add (hopefully confincing) testcase for bug [e58d7e19e9] 2023-07-31 15:45:13 +00:00
jan.nijtmans fc19cf036c Merge bug-e58d7e19e9-demo branch: Show that everything works fine here. 2023-07-29 20:35:16 +00:00
jan.nijtmans e7cef5d811 Demo bug [e58d7e19e9] 2023-07-29 18:11:26 +00:00
apnadkarni 848c57d596 Merge 8.7 - Tcl_ListObjIndex tests 2023-07-29 06:46:16 +00:00
apnadkarni a0cee2b681 Add tests for out of bounds Tcl_ListObjIndex 2023-07-29 05:56:10 +00:00
apnadkarni ae7471ec7e A bunch of 64 bit fixes (int->Tcl_Size) and the like. 2023-07-28 15:51:02 +00:00
jan.nijtmans 861b69164d Merge 8.7 2023-07-28 08:04:01 +00:00
jan.nijtmans c94fa5b242 "utf-8" is the new "identity": make it available always 2023-07-28 07:50:18 +00:00
apnadkarni dc033db224 Merge 8.7 Encoding doc fix 2023-07-28 05:04:44 +00:00
apnadkarni 5c12e53355 Fix transposing of TCL_OK, TCL_ERROR in Encoding docs 2023-07-28 05:02:37 +00:00
jan.nijtmans d74efff177 Add some implicit "-profile tcl8" to testcases 2023-07-27 16:27:21 +00:00
apnadkarni e253c3eed9 Merge trunk 2023-07-27 16:26:38 +00:00
jan.nijtmans 78c6a505b7 Demonstration how to add TCL_OBJTYPE_V3, while keeping upwards compatibility: all other TCL_OBJTYPE_V? macro's continue to work 2023-07-27 13:19:48 +00:00
jan.nijtmans 503165d9c2 Proposed fix for [e58d7e19e9]: Upwards compatibility of TclObjTypeHasProc() 2023-07-27 13:10:40 +00:00
jan.nijtmans e4971bdffc Proposed fix for [e58d7e19e9]: Upwards compatibility of TclObjTypeHasProc() 2023-07-27 12:57:27 +00:00
jan.nijtmans af64c95042 merge-mark 2023-07-27 07:56:27 +00:00
jan.nijtmans 90034cb557 Merge 8.7 2023-07-27 07:52:44 +00:00
jan.nijtmans d49a7f9c8d int -> Tcl_Size in Tcl_MacOSXOpen*BundleResources 2023-07-27 07:22:56 +00:00
jan.nijtmans 3f7d896efb merge-mark 2023-07-26 15:18:53 +00:00
jan.nijtmans 60c1d787b1 Simplify tenviron2utfdstr(), since 2nd argument is always -1. 2023-07-26 15:15:22 +00:00
jan.nijtmans df1e155f68 Merge 8.7 2023-07-26 08:06:52 +00:00
jan.nijtmans 862ae1266c Merge 8.6 2023-07-26 08:03:45 +00:00
jan.nijtmans b985fb8965 Fix [c54e4a1aeb] (again): High Tcl latencies with fork() in larger systems.
vfork() is now prefered, if available
2023-07-26 07:15:26 +00:00
jan.nijtmans 004d2e654f Close fork. Prefer vfork over posix_spawnp 2023-07-25 15:57:02 +00:00
neumann 323f750af8 Regenerated configure file 2023-07-25 15:07:31 +00:00
jan.nijtmans 8733687efc Add (back) check for vfork() 2023-07-25 10:35:22 +00:00
neumann d880550d56 Prefer vfork() over posix_spawnp()
In essence, older versions of the posix_spawn(p) implementation under
glibc have the problem not returning the correct error number in case
the spawn call fails. This is e.g. a problem with CentOS 7, which uses
GNU libc 2.17, which was released 2012-12-25. This has the consequence
that on such systems, Tcl is not error message compliant to versions
without posix_spawn.

The versions of vfork() do not face this problem and show similar
performance characteristics like with posix_spawnp() (spawn time in
essence independent of memory footprint size).

This change was tested with macOS 13.4, Ubuntu 20.04, CentOS 7.9 and
OpenBSD 7.2.
2023-07-25 09:01:51 +00:00
jan.nijtmans c1e69b2d6b Make use_spawn static 2023-07-25 07:54:42 +00:00
jan.nijtmans ecc60b1256 Re-generate configure and tclConfig.h.in 2023-07-25 07:44:01 +00:00
jan.nijtmans b7f335b27d attempt to fix posix_spawn on linux 2023-07-25 07:36:19 +00:00
jan.nijtmans 50944b9abf merge-mark 2023-07-24 15:18:50 +00:00
jan.nijtmans 4dd445404b Merge 8.7 2023-07-24 15:14:46 +00:00
jan.nijtmans ffe298076d Merge 8.6 2023-07-24 15:13:51 +00:00
jan.nijtmans 4f7e149fb6 For now, disable posix_spawnp, until we have a better solution for [407b70361c148773] 2023-07-24 15:12:04 +00:00
jan.nijtmans 545fe029f6 Merge 8.7 2023-07-24 13:32:43 +00:00
jan.nijtmans 399309020d Merge 8.6 2023-07-24 11:13:58 +00:00
jan.nijtmans 30816932df Keeping open [c54e4a1aeb]: Can the exec-17.1 test-failure on MaxOS be fixed? 2023-07-24 10:34:59 +00:00
jan.nijtmans 03b881a299 Fix [c54e4a1aeb]: High Tcl latencies with fork() in larger systems 2023-07-24 10:19:52 +00:00
apnadkarni a3581baf86 Docs - tilde substitution and unsigned int->size_t in Tcl_Alloc 2023-07-24 05:40:38 +00:00
jan.nijtmans 72fef9d4d0 Merge 8.7 2023-07-21 12:00:42 +00:00
jan.nijtmans 7caf2af1db simplify tenviron2utfdstr/utf2tenvirondstr macro's, since 2nd argument is always -1
Improve error-handling related to environment variables
All 'stolen' from TIP #571 branch
2023-07-21 11:37:21 +00:00
jan.nijtmans a22f4cc167 Check for _LARGEFILE64_SOURCE after _FILE_OFFSET_BITS=64, since the latter is prefered 2023-07-21 07:11:25 +00:00
jan.nijtmans d357339eb6 Merge 8.7 2023-07-20 21:01:03 +00:00
jan.nijtmans 9195d0b1bc Fix handling of pre-built libtommath.dll on win64-arm 2023-07-20 20:52:03 +00:00
jan.nijtmans 041458aca6 Add comment to cmdAH-24.20.[12] 2023-07-20 13:32:47 +00:00
jan.nijtmans 6a7b44b23c .... forgot to re-generate tclConfig.h.in 2023-07-20 13:07:41 +00:00
jan.nijtmans c45f83b3db Fix [d40b9c8503]: Enforcing 64-bit time_t? 2023-07-20 12:45:01 +00:00
jan.nijtmans 72db4a5deb Don't bail out when no 64-bit time is available 2023-07-20 12:41:32 +00:00
jan.nijtmans 73a790977d Rebase to 9.0 2023-07-19 16:00:31 +00:00
jan.nijtmans c510082005 Merge 8.7 2023-07-19 14:49:55 +00:00
jan.nijtmans 515bd7c0e7 Improve error-reporting possibilities for Tcl_ExternalToUtfDStringEx/Tcl_UtfToExternalDStringEx in case no interpreter is available, by setting "errno". 2023-07-19 14:23:31 +00:00
jan.nijtmans 50eeabb101 Bugfix for escape-encoding, 'stolen' from TIP #671 branch 2023-07-19 13:04:51 +00:00
apnadkarni 2e4dede387 Merge 8.7 - install tommath.lib 2023-07-17 16:48:17 +00:00
apnadkarni 0a3cfc7902 Fix: tommath.lib needs to be installed to permit extensions to link when using the tommath C API 2023-07-17 16:36:51 +00:00
apnadkarni 53f75ee8c8 Merge 8.7 - update for missing TIP 548 function docs 2023-07-17 06:31:17 +00:00
apnadkarni fc0c89372c Fix missing TIP 548 function docs. Some copy editing of doc prototypes for clarity (sez he). 2023-07-17 06:19:41 +00:00
apnadkarni 7791d13f5c Merge 8.7 - Bug [a366c6efee] 2023-07-16 07:23:13 +00:00
apnadkarni ccf857a3db Bug [a366c6efee] 2023-07-16 06:15:36 +00:00
griffin 56ca2a64d7 Fix bug [c25d2cd3e6], as well as memory leaks in lsearch and concat.
Add cleanup to some tests.
Fix bug and leak in tclTestABSList.c
Correct comment in tclArithSeries.c
2023-07-16 00:24:54 +00:00
dgp e10b5cb8b9 Same fix in chanio.test 2023-07-14 15:59:12 +00:00
dgp 88dd8c1911 Move channel close commands to -cleanup so that when the (expected) error
occurs in [fcopy] we do not leave open channels lurking to interfere with
later tests.
2023-07-14 15:36:05 +00:00
dgp 20188493af dup test name 2023-07-14 14:18:18 +00:00
jan.nijtmans d08eb4bc7d Merge 8.7 2023-07-14 06:28:38 +00:00
oehhar 3fb975f30d Correct wording in Comment 2023-07-13 17:19:06 +00:00
jan.nijtmans 1e54e0ba13 Merge 8.7 2023-07-13 16:23:10 +00:00
jan.nijtmans 55d08599b5 Backport changes in tclListObj.c from Tcl 9.0 2023-07-13 15:42:07 +00:00
pooryorick 0900f426bd Remove incorrect lines that were added to SetDuplicatePureObj().
SetDuplicatePureObj() is specifically not about preserving immutable string
value semantics from the orginal object to the new object.
2023-07-13 12:06:14 +00:00
jan.nijtmans 7709859190 Eliminate another compiler-warning, with -DTCL_NO_DEPRECATED=1 2023-07-12 20:02:39 +00:00
jan.nijtmans aeb6cd1eb9 One more unresolved reference (see prev commit) 2023-07-12 19:56:27 +00:00
jan.nijtmans ca2928e660 More fixes related to [c1691dc608]: 32-bit Linux regressions, like ".... undefined reference to `TclGetUnicodeFromObj'" 2023-07-12 19:36:00 +00:00
jan.nijtmans 99e286f193 Merge 8.7 2023-07-12 19:13:25 +00:00
jan.nijtmans a123c440eb (partial) fix for [c1691dc608]: 32-bit Linux regressions. Eliminate compiler warning 2023-07-12 19:11:46 +00:00
jan.nijtmans 6b299f271e Merge 8.7 2023-07-12 15:12:20 +00:00
jan.nijtmans 74ba5e4336 Fix special-case in SetDuplicatePureObj(): Since typePtr is always &tclListType (ALL current calls to TclDuplicatePureObj() have &tclListType as last argument), this constructions can never work.
(I'm not sure this code is usefull at all, but that's for another day)
2023-07-12 15:09:52 +00:00
jan.nijtmans 6535d19542 Merge 8.7 2023-07-12 14:43:13 +00:00
jan.nijtmans 56aabaf032 Consider 3 more types as special in TclDuplicatePureObj(). Updated comment for the reason why. 2023-07-12 11:38:08 +00:00
apnadkarni 03e22c83db Merge mark 2023-07-12 06:42:39 +00:00
apnadkarni 38d334f8f2 Fix [54329e39c7] 2023-07-12 06:39:22 +00:00
griffin 62f180300b Fix foreach bug [a34733451b].
Other code cleanup discovered by code review.
2023-07-12 03:06:54 +00:00
apnadkarni 6c4636e94b Fix [54329e39c7] 2023-07-12 02:51:50 +00:00
apnadkarni 4ee94e4f67 Add test 2023-07-12 02:31:54 +00:00
apnadkarni 04328bc720 Tweak last for performance in case of traditional lists. 2023-07-11 16:43:13 +00:00
apnadkarni d852753be2 Wrap DECACHE_STACK_INFO around Tcl_ListObjIndex call from bytecode engine. 2023-07-11 12:59:13 +00:00
apnadkarni f7429e3230 Prevent foreach memory bloat iterating within a proc 2023-07-11 11:35:01 +00:00
jan.nijtmans cd97018033 Merge 8.7 2023-07-11 09:23:33 +00:00
jan.nijtmans 531cd741e0 Fix [5916e48806]: tcl.pc: hardcoded depedencies, missing build flags 2023-07-11 09:20:52 +00:00
jan.nijtmans 7aa511f93b Merge 8.7 2023-07-10 16:07:08 +00:00
jan.nijtmans bc24a1ca5a Code cleanup for arithSeries, all backported from 9.0 2023-07-10 15:57:51 +00:00
apnadkarni 7f10145e49 Permit large scripts > INT_MAX. Not complete because compiler source line tracking still limited. 2023-07-09 14:47:22 +00:00
apnadkarni 3edb9b4175 Create new branch named "apn-fix-scripts64" 2023-07-09 13:51:12 +00:00
jan.nijtmans 0f0bd5de07 Unbreak Windows build (broken by [765c9c37a2] due to TIP #628) 2023-07-08 20:36:56 +00:00
jan.nijtmans 35baa585da Merge-mark 2023-07-08 20:28:06 +00:00
jan.nijtmans 6cc4425966 Fix [c5bcbf3494]: Output of surrogates seems to repeat following character 2023-07-08 20:25:28 +00:00
griffin 14cb83639f Cleanup abstract list ObjType function definitions. 2023-07-07 21:06:45 +00:00
jan.nijtmans 68d6146f53 Make TIP #636 work together with TIP #628: Shared 8.7/9.0 build environment 2023-07-07 14:57:17 +00:00
jan.nijtmans ad7e9fe625 TIP #636 cleanup: Eliminate the use of Tcl_ObjTypeLength() et al, which look public but are internal and not documented anywhere. 2023-07-07 14:23:37 +00:00
neumann 5452282a91 - reduced error of posix_spawnp() cases for macOS to 1 (exec-17.1).
The problem seems related to a different I/O setup for cases,
  when stdout is closed and to be replaced by a different stream
- deactivated posix_spawnp() for macOS for the time being
2023-07-07 13:30:19 +00:00
griffin 1858192725 merge TIP #636 (tip-636-tcl9-644) 2023-07-07 02:56:48 +00:00
griffin e7d7e2db67 merge trunk 2023-07-06 21:37:23 +00:00
griffin 024c0aa13a merge trunk 2023-07-06 19:12:14 +00:00
jan.nijtmans 5e662840fb off-by-one. Minor optimization 2023-07-06 16:13:13 +00:00
jan.nijtmans 6ad38477e3 Proposed fix for [c5bcbf3494]: Output of surrogates seems to repeat following character. Also use more ***_SURROGATE() macro's 2023-07-06 15:07:48 +00:00
jan.nijtmans 7ef194a7d1 Merge 8.7 2023-07-05 15:10:20 +00:00
jan.nijtmans a2e7501d74 Merge 8.6 2023-07-05 15:08:38 +00:00
jan.nijtmans 575f580d51 Backport [66ffafd309]: Truncated encoding for DBCS results in infinite loop and running out of memory 2023-07-05 14:55:51 +00:00
apnadkarni 3106ce90c0 Merge 8.7 - Bug [5be203d6ca] - io-7.3 failure 2023-07-05 05:52:58 +00:00
apnadkarni 0109dc8279 Bug [5be203d6ca] - io-7.3 failure 2023-07-05 05:08:56 +00:00
apnadkarni b49afc700b Bug [5be203d6ca] - better fix and add test 2023-07-05 03:23:43 +00:00
griffin 70ca2e60fd merge trunk 2023-07-04 18:13:54 +00:00
jan.nijtmans 3135d809f5 Merge 8.7 2023-07-04 15:13:50 +00:00
jan.nijtmans 6bf04853ec Use more uppercase hex in documentation and test-cases (for consistancy) 2023-07-04 14:52:30 +00:00
jan.nijtmans a2c7cc0d23 Use "tcltest::Asciify" in stead of "printable" 2023-07-04 11:18:44 +00:00
apnadkarni 3d2de6ed07 Correctly compute consumed bytes in case of truncated byte sequence at end. 2023-07-04 06:47:13 +00:00
griffin 7e59780763 merge trunk 2023-07-03 17:07:04 +00:00
jan.nijtmans a071f9c13b Remove useless section in tclUnixPort.h 2023-07-03 15:29:37 +00:00
jan.nijtmans edd3934b32 Merge 8.6. Put vfork check a little bit earlier in unix/tcl.m4. Re-generate unix/configure with (modified) autoconf-2.59 2023-07-03 15:07:05 +00:00
jan.nijtmans f24bab84df Branch meant for bug-fixing [5be203d6ca]: io-7.3 and chanio-7.3 fail in debug mode 2023-07-03 14:16:37 +00:00
jan.nijtmans 3d98702f45 Merge 8.7 2023-07-03 14:10:34 +00:00
jan.nijtmans 6416a20fd8 Adapt tcltest::Asciify, so it's usable for Tcl 8.5 and 8.6 too 2023-07-03 14:09:23 +00:00
jan.nijtmans 77c8868be4 Fix testcase (broken by previous commit) 2023-07-03 14:08:41 +00:00
jan.nijtmans ee7499c2e3 Fix comment (missing ticket ID) 2023-07-03 13:51:28 +00:00
jan.nijtmans 3bfb46688d Temporary disable tests io-7.3 and chanio-7.3, which fail in debug mode. Ticket [5be203d6ca] created. 2023-07-03 13:46:54 +00:00
jan.nijtmans 78c9978aa1 Fix [a5901fc953]: Version control should ignore unix/dltest/embtest 2023-07-03 08:03:03 +00:00
griffin 7968fff465 Add tests for scalar numeric values. 2023-07-03 00:33:16 +00:00
jan.nijtmans 67dfc6e7e3 Merge 8.7 2023-07-02 12:07:35 +00:00
jan.nijtmans 690c5c2c9e Merge 8.6 2023-07-02 12:02:51 +00:00
jan.nijtmans 0070215933 No need for function prototypes in unix/dltest/*.c 2023-07-02 11:53:38 +00:00
fvogel e668c10036 merge core-8-branch (no change) 2023-07-02 09:26:53 +00:00
fvogel 4773d1dadd merge core-8-6-branch (no change) 2023-07-02 09:26:29 +00:00
fvogel bf2b5846b0 Unbreak the 8.6 build. 2023-07-02 09:25:57 +00:00
fvogel 32bd9fd0d2 We definitely need to build core-8-6-branch of Tcl IMHO. 2023-07-02 08:21:04 +00:00
fvogel 5162de4fec We definitely need to build core-8-6-branch of Tcl IMHO. 2023-07-02 08:20:53 +00:00
fvogel 6b4a453621 We definitely need to build core-8-6-branch of Tcl IMHO. 2023-07-02 08:20:36 +00:00
apnadkarni 6a1f856c63 8.7 merge mark 2023-07-02 04:57:10 +00:00
apnadkarni 5dab0fa5de Backport fix [66ffafd309]. DBCS infinite loop on invalid encoding 2023-07-02 04:55:47 +00:00
apnadkarni f368137ec5 8.7 merge mark (lseq tests) 2023-07-02 04:54:33 +00:00
apnadkarni b863e0d57a Tests for [66ffafd309] 2023-07-02 03:03:30 +00:00
apnadkarni 01785b73fb Fix [66ffafd309]. DBCS infinite loop on invalid encoding 2023-07-02 02:41:59 +00:00
apnadkarni cfc103c6b8 Bug [66ffafd309] 2023-07-01 18:02:07 +00:00
griffin 7de69aeb41 merge trunk 2023-06-30 22:16:55 +00:00
griffin a55934d712 Test update for bug [63530267aa]. 2023-06-30 20:34:09 +00:00
griffin 04249bbcd7 Test update for bug [63530267aa]. Fix 32-bit embtest build issue. 2023-06-30 19:02:34 +00:00
griffin eb1f9c9989 merge trunk 2023-06-30 14:34:09 +00:00
jan.nijtmans da8010ca5c Merge 8.7. Remove unused TclArithSeriesObjLength() 2023-06-30 13:40:48 +00:00
jan.nijtmans 6c5be5280f Merge 8.6 2023-06-30 13:28:56 +00:00
jan.nijtmans 24f3e6199d Use more strict compilation-flags (but not -DTCL_MEM_DEBUG) in unix/dltest/Makefile 2023-06-30 13:10:36 +00:00
jan.nijtmans 81da6c1a9a Since TCL_MAJOR_VERSION is always "8", don't check for it. Add C++-compatible typecasts. 2023-06-30 13:08:30 +00:00
neumann f4a4df7a48 Updated configure script to ease testing with this branch 2023-06-30 09:56:01 +00:00
neumann c59dfa5e83 Removed automated setting of USE_VFORK for macOS
The automatic setting of USE_VFORK in unix/configure.in is useless,
confusing, and deprecated. 

Background: configure.in had a section, where it sets
automatically USE_VFORK for macOS.

if test "`uname -s`" = "Darwin" ; then
...
    AC_DEFINE(USE_VFORK, 1, [Should we use vfork() instead of fork()?])
...

However, Daniel Steffen has added the following section 17 years ago
which effectively deactivated USE_VFORK for the x86_64 platform, when
it is set, due to a bug report in RDAR (Apple's bug tracking
system). 16 years ago a section was added to deactivate USE_VFORK for
all platforms with llvm-gcc-4.2 or newer.

/* 
 *---------------------------------------------------------------------------
 * At present, using vfork() instead of fork() causes execve() to fail
 * intermittently on Darwin x86_64. rdar://4685553
 *---------------------------------------------------------------------------
 */

/* Workaround problems with vfork() when building with llvm-gcc-4.2 */
            (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 2 || \
            (__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ > 0))))

This means, that the last 17 years, USE_VFORK was not doing anything
on macOS. Furthermore, macOS 12 (Monterey, released 2021) deprecated
vfork() officially. 

Therefore, it is safe to remove the setting of USE_VFORK from the
default configuration for macOS.

It is still possible to set USE_VFORK manually for certain platform if
needed.
2023-06-30 09:49:08 +00:00
neumann 3f68e9f64f Added auto-configuration of posix_spawnp()
Removed the manual setting of USE_POSIX_SPAWN and
replaced it by HAVE_POSIX_SPAWNP.
2023-06-30 09:12:02 +00:00
jan.nijtmans 801ae4d914 Revert 'fix' for [ac874937c5], committed as part of a "Merge 8.7" commit. It's wrong, since "embtest" is expected to be an executable, not a shared library 2023-06-30 07:40:19 +00:00
griffin cd82527608 merge 8.7 2023-06-29 18:30:13 +00:00
griffin 6f98b30d5b Fix uninitialized variable. 2023-06-29 15:42:14 +00:00
dkf 4b6859f9dc Add timeouts to github workflows to catch runaway scripts 2023-06-29 15:13:57 +00:00
apnadkarni 13b2522d41 Merge 8.7 - Bug [6a3e2cb0f0] - invalid bytes in escape encodings 2023-06-29 11:30:51 +00:00
apnadkarni 6ae93efff0 Bug [6a3e2cb0f0] - invalid bytes in escape encodings 2023-06-29 11:09:29 +00:00
jan.nijtmans 3a1e74ddc5 Merge-mark 2023-06-29 07:24:20 +00:00
griffin b95bc2b4ce Fix ticket [63530267aa] by implementing ticket [e5f06285de] and making additional corrections. 2023-06-28 19:36:41 +00:00
jan.nijtmans 324c39d51c Merge 8.7 2023-06-28 07:27:17 +00:00
jan.nijtmans 26aa7dd453 Fix [26960060d7]: lseq-3.14 triggers use-after-free 2023-06-28 07:20:18 +00:00
jan.nijtmans bc27046551 Fix [78b9b6860c]: Please sync tclOOScript.h 2023-06-28 07:15:59 +00:00
jan.nijtmans e30e67e0cd Fix [https://core.tcl-lang.org/tk/tktview/a9929f112a|a9929f112a]: Bugs in the implementation of TIP #577 ('Enhanced index values for Tk') 2023-06-28 07:10:49 +00:00
jan.nijtmans e5d7a4afce Merge 9.0 2023-06-27 15:31:05 +00:00
jan.nijtmans d273c052a5 Fix [24a8c16dbd]: bigdata.test: invalid command name "testbigdata" on 32-bit 2023-06-27 12:57:13 +00:00
pooryorick 53cfe378b3 Fix previous errors in encoding.test 2023-06-27 10:07:19 +00:00
jan.nijtmans 7f18f499d0 Merge 8.7 2023-06-27 06:55:41 +00:00
jan.nijtmans 04d66a2571 Remove compat/dirent*.h and some other compat/*.c files: Modern C-compilers all have those now 2023-06-27 06:42:06 +00:00
jan.nijtmans e8d619b292 Merge 8.7 2023-06-26 10:12:17 +00:00
jan.nijtmans 1b53ef3bbd Remove compat/stdint.h and compat/stdlib.h: All C-compilers nowadays have it. 2023-06-26 09:52:00 +00:00
jan.nijtmans 07ea9d3df5 Merge 9.0 2023-06-23 23:18:41 +00:00
griffin bd64729686 merge trunk 2023-06-23 17:48:07 +00:00
griffin 4fdc66665f Fix build issue with no_deprecated. 2023-06-23 17:32:43 +00:00
jan.nijtmans be1a8384ef Merge 8.7 2023-06-22 20:07:18 +00:00
jan.nijtmans e37db31205 Fix [44452e2c55]: indexObj.test failures on i386 2023-06-22 19:00:59 +00:00
jan.nijtmans 823a3f2b2b Merge-mark 2023-06-22 13:40:35 +00:00
jan.nijtmans 9df01df02c Since Tcl 8.6 doesn't know about Tcl_Size, don't use it, not even in test comments 2023-06-22 13:39:14 +00:00
jan.nijtmans f35db8a093 Proposed fix for [44452e2c55]: indexObj.test failures on i386 2023-06-22 11:59:58 +00:00
jan.nijtmans b8c47674a4 WIP for fixing [https://core.tcl-lang.org/tk/tktview/a9929f112a|a9929f112a] 2023-06-22 10:12:42 +00:00
jan.nijtmans 9a18abc855 merge-mark 2023-06-21 22:44:08 +00:00
jan.nijtmans 22c9ba1a27 (partial) fix for [https://core.tcl-lang.org/tk/tktview/a9929f112a|a9929f112a]: Bugs in the implementation of TIP 577 ("Enhanced index values for Tk" ) 2023-06-21 22:38:58 +00:00
jan.nijtmans bc87d9a2bc Fix 3 "lset" testcases 2023-06-21 21:30:53 +00:00
jan.nijtmans 7c2d72933f (partial) fix for [https://core.tcl-lang.org/tk/tktview/a9929f112a|a9929f112a]. Tk needs some changes too 2023-06-21 14:52:44 +00:00
jan.nijtmans eb09d3860d Merge 8.7 2023-06-21 07:18:34 +00:00
jan.nijtmans 09c0f68355 "trace variable" -> "trace add variable" in testcases (and documentation) 2023-06-21 07:13:48 +00:00
griffin 172063cace Fix bug in TEBC foreach with abstractlists 2023-06-20 22:16:54 +00:00
jan.nijtmans e26ccd75b1 Merge 8.7 2023-06-20 07:11:30 +00:00
jan.nijtmans 104527a107 Move VarHashGetKey() to tclInt.h. More int -> Tcl_Size 2023-06-20 06:51:49 +00:00
griffin 2e4b97b87f merge trunk 2023-06-20 01:47:47 +00:00
griffin be39d74ee7 Fix crash in BC execution when str concat and abstract list lindex operations have recursive BC execution.
Add testcase for this bug.
2023-06-20 01:28:25 +00:00
apnadkarni ded49faad5 Merge 8.7 - fix tests - hardcoded port and wsl. 2023-06-19 13:39:31 +00:00
apnadkarni 73a582c685 Merge 8.6 - fix tests - hardcoded port and wsl. 2023-06-19 13:21:46 +00:00
apnadkarni c2f255fe84 Fix hardcoded port numbers causing Windows failures with hyperv. Disable
file perm test for WSL.
2023-06-19 12:49:29 +00:00
jan.nijtmans 2ebe7012db Merge 8.7 2023-06-19 12:42:00 +00:00
jan.nijtmans ec8dfd57db Some more Tcl_Size usage 2023-06-19 11:47:58 +00:00
griffin d8ce1ffde8 merge trunk 2023-06-19 04:29:28 +00:00
jan.nijtmans 7f8e25f907 Fix [c13819225e]: Problem with lsort|lsearch -stride on 32-bit linux 2023-06-18 11:04:22 +00:00
griffin 06465624ac Clarification. 2023-06-18 01:51:10 +00:00
jan.nijtmans cf84dd6daf Proposed fix for [c13819225e]: Problem with lsort|lsearch -stride on 32-bit linux. Also fix some compiler warnings 2023-06-16 12:21:21 +00:00
oehhar 954457baf9 tip-636-tcl9-644: doc/Object.3: remove double "the" 2023-06-16 10:49:41 +00:00
griffin f1b8cb6289 Add Tcl_ObjType changes to the appropriate docs. 2023-06-15 20:45:55 +00:00
neumann 414a984d04 Made variant using USE_POSIX_SPAWN error message compatible
This change makes Tcl compiled with USE_POSIX_SPAWN activated error
message compatible with previous versions (using fork). Now, the Tcl
regression test succeeds without errors.
2023-06-15 16:56:35 +00:00
griffin 2e79331ac0 merge trunk 2023-06-13 16:59:57 +00:00
griffin 7d37ba8e63 Remove getdbl abstraction. 2023-06-13 16:47:25 +00:00
jan.nijtmans 478601a07b Merge 8.7 2023-06-13 09:12:25 +00:00
jan.nijtmans 3c8ac03074 Specify implicit "-profile tcl8" in encoding-24.4 testcase 2023-06-13 06:05:02 +00:00
pooryorick d07e50e54a Revert unwarranted change in Tcl_CreateChannel() from [1776327edd]. 2023-06-12 04:10:52 +00:00
apnadkarni 9cf727affb Tests for invalidly encoded file names and env (TIP 671 motivation) 2023-06-11 02:34:35 +00:00
jan.nijtmans 7ab30f565b Merge 8.6 2023-06-08 12:39:44 +00:00
oehhar 4314e8e438 ticket [c54e4a1aeb] patch: Use vfork instead fork. 2023-06-08 12:01:40 +00:00
jan.nijtmans 96c8069270 (cherry-pick): Added note about how some commands are mainly for Tk 2023-06-08 11:59:30 +00:00
griffin dde4e1b094 merge trunk 2023-06-06 20:26:59 +00:00
griffin ac52dca2ba Clean up logic to detect failures. 2023-06-06 16:04:41 +00:00
dkf a9377a35b7 Added note about how some commands are mainly for Tk 2023-06-05 11:12:08 +00:00
pointsman 5140d2419c Merge 8.7 2023-06-04 22:58:07 +00:00
pointsman d716e3bd57 Merge 8.6 2023-06-04 22:56:45 +00:00
pointsman 02f302c8cf Fixed a new test added by [72f78b60851]. The test as it was repeated just the previous one. Now it shows what was fixed. Removed development comment. 2023-06-04 22:54:59 +00:00
jan.nijtmans 9ef860c58c Merge 8.7 2023-06-03 20:03:28 +00:00
jan.nijtmans 702bb9ab89 Merge 8.6 2023-06-03 19:59:48 +00:00
jan.nijtmans a7e21b7c56 Fix [af3ebc5fafe0097c]: clock scan and clock add bugs in error cases / with abbreviated options 2023-06-03 19:51:21 +00:00
jan.nijtmans 6b77d746e1 Merge 8.7 2023-06-02 22:12:10 +00:00
jan.nijtmans 7e152743be In TclAttemptInitStringRep(): Don't do a memcpy if attemptckalloc() fails 2023-06-02 22:05:03 +00:00
dkf 0513ad381a More library(n) docs 2023-06-02 15:12:26 +00:00
jan.nijtmans b37dff78c1 Merge 8.7 2023-06-02 14:02:19 +00:00
jan.nijtmans 103eb015c0 Merge 8.7 2023-06-02 13:59:26 +00:00
dgp 73519e9804 silence compiler warning 2023-06-02 13:46:50 +00:00
jan.nijtmans 2867ac2637 New (internal) macro TclAttemptInitStringRep() 2023-06-02 12:00:02 +00:00
jan.nijtmans 3d0413417d Merge 8.7 2023-06-01 21:04:48 +00:00
jan.nijtmans 56d50aec7c Fix [9921778646]: something is wrong in core-8-branch 2023-06-01 20:58:00 +00:00
dkf b1ee2de573 Added some examples to library(n) 2023-06-01 14:37:44 +00:00
jan.nijtmans 5d5b5a4242 merge-mark 2023-05-31 14:13:19 +00:00
jan.nijtmans c8ff4cae81 Use TclDuplicatePureObj() in stead of TclListObjCopy() where appropriate. Backported from 9.0 2023-05-31 14:12:12 +00:00
jan.nijtmans 6104a20928 Merge 8.7 2023-05-31 07:49:17 +00:00
jan.nijtmans b87d0095dc Document hoe Tcl_ReadChars() behaves in "-profile strict" mode when an encoding error happens. 2023-05-31 07:45:52 +00:00
jan.nijtmans 4632c037e3 Merge 8.7 2023-05-31 07:20:18 +00:00
jan.nijtmans 28c9edc49b Fix [c243e7a85e]: TIP #603 implementation broken on Windows 2023-05-31 07:16:04 +00:00
jan.nijtmans 614c8b3360 Let's see if this helps 2023-05-30 21:31:11 +00:00
dkf a4f289d5b5 More typo fixes 2023-05-30 13:57:09 +00:00
jan.nijtmans 75bdb75689 Merge 8.7 2023-05-30 12:22:20 +00:00
jan.nijtmans 13f6f72bb7 Backport IO-related changes from Tcl 9.0. Needed for preparation of TIP #653 2023-05-30 11:25:13 +00:00
jan.nijtmans af838a5d52 Merge 8.7 2023-05-29 19:41:08 +00:00
jan.nijtmans 8091425c93 int -> Tcl_Size, for full Tcl 9 support 2023-05-29 16:27:28 +00:00
dkf 4c03aeaadd Fix typo and outdated comment 2023-05-29 10:49:45 +00:00
fvogel 69ae2a0f03 merge 8.7 2023-05-28 10:39:40 +00:00
fvogel 7988b3f1b6 Fix errors when building the html man page for configurable.n (TIP #558) 2023-05-28 10:38:13 +00:00
fvogel 827a1d3802 Fix errors when building the html man page for configurable.n 2023-05-28 10:37:31 +00:00
griffin d4e8db78c9 Function name cleanup. 2023-05-26 17:15:12 +00:00
griffin 22306f855b merge trunk, fix leak. 2023-05-25 20:55:52 +00:00
jan.nijtmans 0657f97bc5 Eliminate some clang warnings. Only use "testbigdata" if sizeof(Tcl_Size) == sizeof(Tcl_WideInt) 2023-05-25 15:10:55 +00:00
griffin 09bc3f7033 Remove old cruft. 2023-05-25 04:38:32 +00:00
griffin ba261e8e87 merge trunk 2023-05-24 23:17:17 +00:00
griffin c3f8318a3f Cleanup abstract list definitions. 2023-05-24 20:13:20 +00:00
dkf 6598d2eeae TIP 603: Get 'stat' Information of Open Files 2023-05-24 16:04:46 +00:00
dkf 29225e440c merge core-8-branch 2023-05-24 16:02:24 +00:00
jan.nijtmans 231fd112f9 Merge 8.7 2023-05-24 15:29:11 +00:00
jan.nijtmans 70a3d08fc4 Fix regular expression in previous commit 2023-05-24 15:22:00 +00:00
jan.nijtmans c7771a763e Enhance html generation, so it can handle the "©" copy-sign as well 2023-05-24 15:18:05 +00:00
jan.nijtmans 6c1bdd15d6 More size protection for winDde 2023-05-24 15:16:14 +00:00
jan.nijtmans 9a6a7030e8 Remove TCL_SIZE_SMAX, not used anywhere. Some more variable which should have been Tcl_Size 2023-05-24 10:31:56 +00:00
griffin e91f967003 Merge trunk 2023-05-23 21:36:46 +00:00
jan.nijtmans 633171eda9 Merge 8.7 2023-05-23 16:15:10 +00:00
jan.nijtmans 2acd355f8d Give Tcl_CreateThread a TCL_HASH_TYPE (unsigned) stackSize parameter 2023-05-23 16:03:29 +00:00
pointsman 73ff912a1f Proposed fix for [af3ebc5fafe0]. 2023-05-22 12:17:44 +00:00
jan.nijtmans b9722ec356 Merge 8.7 2023-05-22 10:13:42 +00:00
dkf f3f254e8ba Small documentation corrections 2023-05-22 07:48:43 +00:00
jan.nijtmans f1e62884ba Merge 8.7 2023-05-21 23:00:20 +00:00
jan.nijtmans e18d096bd7 Unbreak windows symbols build. More int -> Tcl_Size backported from 9.0 2023-05-21 21:19:22 +00:00
griffin 54a1d7e517 Fix test to be stable. 2023-05-21 20:42:14 +00:00
griffin c6cce703b5 Add cleanup to lseq tests. Fix assertion. 2023-05-20 23:24:54 +00:00
apnadkarni f19e2665d3 Fix [c9663296fd]. Also refactor memory reallocation. 2023-05-20 16:39:50 +00:00
apnadkarni 96d441c29a Minor refactor to combine alloc/realloc 2023-05-20 15:40:17 +00:00
jan.nijtmans 72dfeb60e2 merge-mark 2023-05-20 10:34:14 +00:00
jan.nijtmans b27acbe84f More int/Tcl_Size backport 2023-05-20 10:07:19 +00:00
apnadkarni 1b8701ee3d Merge trunk 2023-05-19 23:07:13 +00:00
apnadkarni 83d22bd1f6 Fix int/Tcl_Size pointer errors 2023-05-19 22:18:51 +00:00
apnadkarni 861c6c226a Fix build - ckalloc/ckfree not in Tcl 9 2023-05-19 21:31:18 +00:00
jan.nijtmans b0bd6fc251 Merge 8.7 2023-05-19 19:50:31 +00:00
jan.nijtmans 6643ceb141 int -> Tcl_Size and other (internal) signature improvements. Most of them backported from 9.0 2023-05-19 19:47:18 +00:00
apnadkarni 16a75f3cbf More refactoring into common code 2023-05-19 16:47:58 +00:00
dkf ed8816500e Improve the synopsis of the transchan manpage so it helps users a bit 2023-05-19 14:15:18 +00:00
dkf 5ef48eba53 Improve the synopsis of the refchan manpage so it helps users a bit 2023-05-19 13:35:19 +00:00
dkf ee48919fcc Merge 8.7 2023-05-19 12:56:28 +00:00
dkf d6a3425ec6 TIP 558: Basic Configure Support for TclOO 2023-05-19 12:06:05 +00:00
dkf b0f19e41f2 merge core-8-branch 2023-05-19 12:02:49 +00:00
griffin fa313109d6 Merge trunk 2023-05-17 16:12:25 +00:00
pooryorick 00dd4a5b56 Improve TclDuplicatePureObj(), remove unnecessary increment/decrement pairs, and add more error checking. 2023-05-17 12:44:46 +00:00
pooryorick ac555b905c New functions: TclUndoRefCount() and TclDictGetSize(). 2023-05-17 12:26:11 +00:00
pooryorick 5990382222 Fix for [5ee01098824881b5], lseq list conversion results in attempt to access
freed memory.
2023-05-17 12:09:27 +00:00
jan.nijtmans c7e670b85f Merge 8.7 2023-05-17 07:33:33 +00:00
jan.nijtmans 86e88cf233 Remove dead code 2023-05-17 07:30:54 +00:00
griffin 6781fbdf4b Add Tcl_BumpObj() used to prevent leaks from Abstract List elements.
Add Abstract List (ArithSeries) support in Tcl_ListObjIndex().
Fix obj leaks in lsearch operatations on ArithSeries.
Fix obj leaks in concat operations on ArithSeries.
Add concat and lsearch tests using lseq lists.
2023-05-17 05:09:01 +00:00
jan.nijtmans e47cbdc798 Merge 8.6 2023-05-16 16:31:53 +00:00
jan.nijtmans a5297cf7c3 Some more nmakehlp.c tweaks 2023-05-16 16:30:07 +00:00
jan.nijtmans 32ffe00c48 Merge 8.6 2023-05-16 10:26:48 +00:00
jan.nijtmans 8f8a3bc1c0 Only use _snprintf on older MSVC compilers. ZeroMemory -> memset 2023-05-16 10:19:41 +00:00
pooryorick a038d4aad3 Fix memory leaks and remove unnecessary reference count bounce. 2023-05-16 09:33:12 +00:00
jan.nijtmans 17c92b0a7a Merge 8.7 2023-05-16 06:25:19 +00:00
jan.nijtmans 4eb91b8e5b Remove some more references to removed ChangeLog 2023-05-16 06:07:51 +00:00
jan.nijtmans ebcc04616c More int -> Tcl_Size (in tclInt.h) 2023-05-16 06:05:22 +00:00
pooryorick 50dde26caf New function, TclDuplicatePureObj(), doesn't duplicate the string
representation when duplicating an object, unless necessary.  Remove
TclListObjCopy() in favor of TclDuplicatePureObj(), allowing internal
representation to change after the copy rather than before.
2023-05-16 05:25:31 +00:00
apnadkarni 6fa73194d5 Refactor couple more reallocations 2023-05-15 23:08:17 +00:00
pooryorick 49c4458a25 Add Tcl_DecrRefCount() missing from [4b1a20629e]. 2023-05-15 20:49:43 +00:00
apnadkarni 02563b1911 Refactor allocation in Tcl_DStringAppendElement 2023-05-15 20:23:05 +00:00
dgp 54e89ec231 merge 8.7 2023-05-15 17:37:21 +00:00
dgp 8074bcec5e TIP 663 implementation 2023-05-15 17:17:43 +00:00
jan.nijtmans 4db805463e Backport test improvements from 9.0 2023-05-15 15:45:57 +00:00
jan.nijtmans 45dd8baf76 No need to init string rep, if we throw away the object immediately 2023-05-15 15:44:34 +00:00
jan.nijtmans f6f92fd671 Merge 8.7 2023-05-15 11:52:39 +00:00
jan.nijtmans f2f41b4b85 Merge 8.6 2023-05-15 11:45:42 +00:00
jan.nijtmans db43c8cbed One more ckalloc -> attemptckalloc (in compat/waitpid.c), since we can handle the error. 2023-05-15 11:43:15 +00:00
jan.nijtmans 062f4d0529 ckalloc -> attemptckalloc (since return-value is checked). Fix bug in unix/dltest/pkgooa.c, where last NULL-argument was missing 2023-05-15 11:15:28 +00:00
pooryorick 48d6b3d84c Rename TclRelaxRefCount() to TclUndoRefCount(). 2023-05-14 08:21:50 +00:00
pooryorick aafa141509 Add TclRelaxRefCount, and also try to take the fast path more often in byte-compiled [lindex]. 2023-05-13 10:59:32 +00:00
pooryorick d6ed36f134 In tclExecute.c call DECACHE_STACK_INFO() before calling TclLindexList(). 2023-05-12 23:20:26 +00:00
jan.nijtmans 14d2bc5415 Merge 8.7 2023-05-12 08:57:00 +00:00
jan.nijtmans 36cebb89fe Use 'attempt'-functions for libtommath, when built into Tcl 2023-05-11 22:20:17 +00:00
pooryorick 4fa1fa29ae Fix failing valgrind suppression for load.test 2023-05-11 17:17:18 +00:00
pooryorick 6fbc88e2a0 Silence valgrind "still reachable" report in cmdAH.test 2023-05-11 17:07:39 +00:00
jan.nijtmans 87ff0e4ee2 put back pragma voor MSVC warning, accidently removed in previous commit 2023-05-11 15:39:30 +00:00
jan.nijtmans 847fdd28f7 Restore warning-free compilation with C++ compiler 2023-05-11 15:30:18 +00:00
pooryorick 01e71bb26c Fix Valgind report of still reachable blocks in aaa_exit.test and other test
files.
2023-05-11 13:08:59 +00:00
jan.nijtmans ce00b07d6b disable on-purpose compiler warning (MSVC) for testcase 2023-05-11 06:31:49 +00:00
apnadkarni 363a6cc4cd Refactor allocation strategy in Tcl_DStringAppend 2023-05-10 21:32:16 +00:00
jan.nijtmans 180af1f9a5 Merge 8.7 2023-05-10 20:53:49 +00:00
jan.nijtmans c03808607b Backport various changes from 9.0 branch 2023-05-10 19:39:20 +00:00
dgp 6c604517d7 TIP 663 implementation 2023-05-10 18:28:30 +00:00
apnadkarni 6802927d5c Merge trunk 2023-05-10 17:25:47 +00:00
jan.nijtmans c0c0164a71 Merge 8.6 2023-05-10 12:28:06 +00:00
jan.nijtmans 284a501487 Backport: docs: function does not "return an error", it returns TCL_ERROR, indicating an error occured 2023-05-10 12:09:07 +00:00
bch 909827f9ee docs: function does not "return an error", it returns TCL_ERROR, indicating an error occured 2023-05-09 22:36:38 +00:00
jan.nijtmans 293c1ff559 Left-over TCL_ENCODING_STRICT, not used any more.
Add "-profile tcl8" for testcases which don't work in strict profile
2023-05-09 16:11:58 +00:00
griffin 7b647d920a merge trunk 2023-05-09 15:58:53 +00:00
jan.nijtmans e95d2eea7f Merge 8.7 2023-05-09 13:16:25 +00:00
jan.nijtmans 2e02e1affd Remove useless type-casts. Backport some changes from 9.0 2023-05-09 13:06:02 +00:00
jan.nijtmans 77b454d1b2 size_t -> Tcl_Size (twice) 2023-05-09 09:51:47 +00:00
jan.nijtmans 8f15f09491 Fix [96551aca55]: Avoid pointer arithmetic with NULL in FOREACH_STRUCT(). Some typo's 2023-05-08 14:19:04 +00:00
pooryorick 8d076e6525 Make TclLindexFlat() a litle more straightforward. 2023-05-08 14:08:44 +00:00
jan.nijtmans 133b43a521 Better version, keeping the (undocumented) behavior of 'i' initialization 2023-05-08 13:43:56 +00:00
pooryorick af5bfc68cc Use Tcl_Size instead of size_t in two places in TclIndexEncode. 2023-05-08 11:35:45 +00:00
jan.nijtmans 0d8a08dbf1 Proposed fix for [96551aca55]: Avoid pointer arithmetic with NULL in FOREACH_STRUCT() 2023-05-08 09:35:57 +00:00
jan.nijtmans 1a4e52416f Merge 8.7. Restore Tcl_DStringSetLength() behavior, as suggested in [3837178c25] 2023-05-07 20:34:18 +00:00
jan.nijtmans 4dcdd51adb Merge 8.7 2023-05-07 20:10:58 +00:00
jan.nijtmans 73dbbaaa23 New testcase, contributed by @chrstphrchvz. Many thanks! See [3837178c25] 2023-05-07 20:06:50 +00:00
jan.nijtmans d162c9a16d Merge 8.7 2023-05-05 21:22:29 +00:00
jan.nijtmans ce9f04ddd1 Merge 8.6 2023-05-05 21:16:27 +00:00
jan.nijtmans 8f269fcad1 Update .github files 2023-05-05 21:07:47 +00:00
jan.nijtmans 67b780c161 Remove .github and .travis-related stuff: No need to build this branch any more 2023-05-05 20:55:31 +00:00
pooryorick f4cd60dbb4 A few corrections in comments. 2023-05-05 14:57:38 +00:00
apnadkarni d0ba759e2c Merge trunk 2023-05-05 12:36:45 +00:00
apnadkarni 3f84674ae3 Merge 8.7 - list performance tests 2023-05-05 12:35:21 +00:00
apnadkarni 4e92d998eb Minor fixes for perf tests 2023-05-05 12:34:18 +00:00
pooryorick 3e05a7babe Remove TclArithSeriesObjCopy() and use Tcl_DuplicateObj() instead. 2023-05-05 09:40:38 +00:00
apnadkarni 5940356ced Change reallocation growth to 1.5. 2023-05-05 09:17:17 +00:00
pooryorick cc71607cb8 Make some tests select an encoding profile instead of relying on the default. 2023-05-04 20:26:19 +00:00
dgp 405a099384 merge 8.7 2023-05-04 18:22:37 +00:00
dgp 1ea2b16a8d merge 8.6 2023-05-04 18:21:49 +00:00
dgp f976a32c62 Remove mention of Tcl_GlobalEval() from comment. 2023-05-04 18:21:01 +00:00
apnadkarni 92dd14e77c Refactor reallocation in preparation for experimentation with different growth factors 2023-05-04 17:52:06 +00:00
jan.nijtmans 3f2bb8a029 Merge 8.7 2023-05-04 13:06:15 +00:00
jan.nijtmans e51f7da2ee Backport: Do not build every branch. Too expensive. 2023-05-04 12:58:41 +00:00
jan.nijtmans af320fb41e Fix [9c397da4a9]: AppendPrintfToObjVA(): support 64-bit pointers 2023-05-04 12:53:45 +00:00
dkf e2f55284cf Do not build every branch. Too expensive. 2023-05-04 08:24:01 +00:00
apnadkarni 8a45e47c4c Merge trunk 2023-05-04 05:12:11 +00:00
apnadkarni 4dd7110019 Better fallback on list reallocation failure 2023-05-04 04:48:31 +00:00
jan.nijtmans 881b147ab5 Merge 8.7 2023-05-03 15:59:09 +00:00
jan.nijtmans b583ea7360 Backport "Comments only. Fix blatantly obsolete ones". And a few more improvements from the same files. 2023-05-03 15:51:10 +00:00
pointsman d40bb9d13a Removed the bug specific test constraint from the tests related to [0306a5563c] because the bug is fixed. 2023-05-03 15:18:17 +00:00
apnadkarni 688c125ec3 Fix bug-c9663296fd (in progress) 2023-05-03 13:18:05 +00:00
apnadkarni 06cc962945 Comments only. Fix blatantly obsolete ones 2023-05-03 10:01:50 +00:00
pooryorick 88760a8a81 Use Tcl_Size instead of ptrdiff_t in Tcl_ObjCmdProc2(), Tcl_CmdObjTraceProc2, and Tcl_MethodCallProc2(). 2023-05-03 09:31:08 +00:00
apnadkarni aa4247d47b Merge mark 8.7 2023-05-03 04:06:28 +00:00
apnadkarni 81b4fa2fbd Changed CHANNEL_PROFILE_* to ENCODING_PROFILE_* and moved out of tclIO.h. See below.
For whatever reason, these macros were renamed and moved to tclIO.h post-660. This is
inappropriate as those macros deal with *encoding* flags, not *channel* flags and have
relevance outside of I/O making their renaming inappropriate. Further putting them in tclIO.h
forces inclusion of that header in modules that do not otherwise need that header.
2023-05-03 04:03:36 +00:00
apnadkarni 7b688527d7 Changed CHANNEL_PROFILE_* to ENCODING_PROFILE_* and moved out of tclIO.h. See below.
For whatever reason, these macros were renamed and moved to tclIO.h post-660.
This is inappropriate as those macros deal with *encoding* flags, not *channel*
flags and have relevance outside of I/O making their renaming inappropriate. Further
putting them in tclIO.h forces inclusion of that header in modules that do not
otherwise need that header.
2023-05-03 03:31:49 +00:00
griffin 9aac3677ed merge trunk 2023-05-03 02:01:11 +00:00
pointsman 41aa17e389 Fix for [0306a5563c]. 2023-05-02 22:11:28 +00:00
pointsman 84d939b69a Fix for [0306a5563c]. 2023-05-02 21:50:48 +00:00
apnadkarni 60ba166da0 Merge 8.7 fix [784befb0ba] - tailcall crash 2023-05-02 17:06:38 +00:00
apnadkarni 2dccd2a567 Merge 8.6 - [ab123cfd3d] and [784befb0ba] 2023-05-02 16:48:57 +00:00
apnadkarni df75b91956 Fix [ab123cfd3d] - scan ubsan. Tx chrstphrchvz for patch 2023-05-02 16:33:39 +00:00
apnadkarni 43b5729ddf Fix [784befb0ba] - tailcall crash 2023-05-02 16:08:30 +00:00
apnadkarni 1f5d09b497 Fix LISTREP_ASSERT 2023-05-02 11:50:03 +00:00
apnadkarni eb23b011d0 Merge trunk 2023-05-02 11:28:55 +00:00
apnadkarni 03d0f99e6c Fix [bb69c8d17e] compiled string last 2023-05-02 08:42:21 +00:00
apnadkarni 694c4505cd Change realloc strategy on fail, optimize for empty string 2023-05-02 05:38:04 +00:00
jan.nijtmans 28e5ec7db6 Add missing "deprecated" constraint 2023-05-01 15:50:02 +00:00
dkf fea912c676 Remove IDE guff 2023-05-01 15:08:08 +00:00
dkf 7555420166 Add doc comments, fix a typo in a manpage 2023-05-01 14:07:59 +00:00
dkf 10c71dc8b9 Use modern copyright symbol, in line with rest of code 2023-05-01 13:31:30 +00:00
dkf 530e4b3bb9 Merge 8.7 2023-05-01 13:22:24 +00:00
apnadkarni b6bc736eee Tests for [dcac54a685] 2023-05-01 12:39:43 +00:00
apnadkarni fe84f70800 Tests for [ad9361fd20] 2023-05-01 12:16:44 +00:00
apnadkarni c77055a803 Fix [d07f42998d] - argument list truncation 2023-05-01 11:41:48 +00:00
apnadkarni 3b426fffa1 Fix [ab123cfd3d] - ubsan warning in ValidateFormat 2023-05-01 10:38:12 +00:00
apnadkarni 782009ca67 Fix [ab123cfd3d] - ubsan scan warning. 2023-05-01 06:51:51 +00:00
apnadkarni e1f2905dbc Added missing bigdata constraint 2023-05-01 06:41:25 +00:00
griffin ca58c3ae9a Partial sync-up with trunk. 2023-04-30 23:09:13 +00:00
jan.nijtmans dd6950d635 Merge 8.7 2023-04-30 19:21:50 +00:00
jan.nijtmans c3cb435cf4 Fix OPTS=utf16 build for Tcl 9.0 2023-04-30 19:03:12 +00:00
jan.nijtmans 6c4b78cfa8 Eliminate ListSizeT_MAX, since it's the same as TCL_SIZE_MAX 2023-04-30 17:32:25 +00:00
jan.nijtmans 75eea66ef7 Add testcase for TclGetBytesFromObj() 2023-04-30 12:32:20 +00:00
jan.nijtmans 251211e714 Don't test compatibility macro's when TCL_NO_DEPRECATED is defined: this is expected to fail 2023-04-30 12:02:38 +00:00
apnadkarni e313582726 Fix [27b3ce2997] - check INT_MAX limit on script length 2023-04-30 10:20:19 +00:00
apnadkarni a06189323f Fix one more error message for max arg limit 2023-04-30 09:54:16 +00:00
apnadkarni 93f06f4469 Working on [d07f42998d] 2023-04-30 08:08:24 +00:00
apnadkarni 6c973cf9a2 Add tests. Panic on bytecode length limit 2023-04-29 16:16:58 +00:00
jan.nijtmans e393e2694c Add experimental testcase for TclGetBytesFromObj() 2023-04-29 16:10:56 +00:00
jan.nijtmans 1645895629 Eliminate ListSizeT_MAX, since it's the same as TCL_SIZE_MAX 2023-04-29 15:20:12 +00:00
jan.nijtmans ef51b5aacd Resolve a TODO 2023-04-29 14:56:13 +00:00
jan.nijtmans 905633199c Merge 8.7 2023-04-29 14:50:50 +00:00
pointsman 4d289b8084 Updated from trunk. Simplified bug specific tests. 2023-04-29 14:11:36 +00:00
apnadkarni 85a2a91729 Fix [7cddd2845c] - crash with >= INT_MAX operands 2023-04-29 03:15:11 +00:00
apnadkarni 947e3f8405 Limit scripts to INT_MAX-1 bytes 2023-04-29 02:11:48 +00:00
jan.nijtmans ad7deae634 Remove some (void *) typecasts, which are no longer necessary 2023-04-28 15:02:09 +00:00
pooryorick a6d654980e Limit memset() to "TCL_UTF_MAX=3' builds. 2023-04-28 06:43:49 +00:00
pooryorick 2fae9f1746 Add bytearray checking to TclCheckEmptyString(), and then use
TclCheckEmptyString() in Tcl_AppendObjToObj and TclStringCat() to reduce string
generation.
2023-04-27 20:54:21 +00:00
pooryorick 5eb2064b63 Fix for [f5eadcbf9a6b1b4c], passing pointer to uninitialized memory leads
Tcl_UniCharToUtf() to corrupt data.
2023-04-27 20:42:04 +00:00
pooryorick 7f433932f6 memset(0xff) instead of memset(0) to accomodate tests that fill buffer with
0xff.
2023-04-27 20:34:22 +00:00
jan.nijtmans 2e9301202d More size_t -> Tcl_Size, missed by earlier updates 2023-04-27 14:01:37 +00:00
jan.nijtmans 8bfaaa8337 Simplify Tcl 9 compatibility macro's. No change in functionality. 2023-04-27 13:52:42 +00:00
apnadkarni 175931c905 Merge trunk 2023-04-27 13:34:55 +00:00
apnadkarni 18f61eeeeb More checks for exceeding max words 2023-04-27 12:47:08 +00:00
jan.nijtmans 54b8f46097 RingSizeT -> Tcl_Size 2023-04-26 20:24:01 +00:00
jan.nijtmans 372bf74334 Reduce number of needed type-casts. No change in functionality 2023-04-26 19:29:44 +00:00
griffin f9f1724b36 Fix index descrepencies (bug-fa00fbbbabe).
Fix inconsistent rounding (bug-e5f06285de).
2023-04-26 16:18:04 +00:00
jan.nijtmans cd51753d86 More size_t -> Tcl_Size changes, which were missed before. Also (experimental) make the wrapper macro's produce compiler warnings is Tcl_Size is not used. 2023-04-26 15:53:40 +00:00
apnadkarni f227a5d1ff Test fix for [0f98bce669] 2023-04-26 15:45:12 +00:00
apnadkarni 5ddcd8fea9 Fix for [7cddd2845c] (in progress) 2023-04-26 14:56:21 +00:00
jan.nijtmans fe4e51b427 Merge 8.7 2023-04-26 06:51:52 +00:00
jan.nijtmans bd259695f1 Merge 8.6 2023-04-26 06:49:22 +00:00
jan.nijtmans e5eeaadf3c Don't refer to CVS any more 2023-04-26 06:40:14 +00:00
griffin 3aaf8c0544 merge trunk, address some 32-bit issues. 2023-04-26 03:41:57 +00:00
pooryorick 76130df460 Fix for issue [f5eadcbf9a], passing pointer to uninitialized memory leads
Tcl_UniCharToUtf() to corrupt data.
2023-04-25 20:34:03 +00:00
griffin da6df4adde Add fix inconsistent rounding (bug-e5f06285de).
Compute and use the "precision" for sequences of doubles: determine the number of significant digits in the fractional part of the given arguments, and round the results to that limit.
Fix copy bug in DupArithSeriesInternalRep.
2023-04-25 00:36:30 +00:00
pointsman 1ddccee9d3 Added a test for the initial problem and another for the known remaining problem. 2023-04-24 20:21:42 +00:00
pointsman 48570b93a6 Merge trunk. 2023-04-24 20:09:40 +00:00
apnadkarni 025b74f7c7 Fix [2e3fed53ba] - binary encode uuencode 2023-04-24 17:46:14 +00:00
apnadkarni 51043c29db Fix [c719fa8716] - binary encode base64 assertion failure 2023-04-24 17:16:58 +00:00
apnadkarni 553caf0d2c Fix [9369f83649] - binary format/scan for big data 2023-04-24 16:49:34 +00:00
apnadkarni 87e417c1a1 Fix [a814ee5bbd] - string compare/equal -length for long strings 2023-04-24 16:28:21 +00:00
dgp e95eb57666 Adapt signature of TclCompileScript() to fit better after TIP 660. 2023-04-24 15:51:00 +00:00
apnadkarni 3a9a817f67 Fix [d4ede611a7] - scan bigdata 2023-04-24 14:51:20 +00:00
dgp 277effbc04 TIP 422 eliminated va_list arguments from the API of Tcl 9.
However, some of the documentation lingered on.  No more.
2023-04-24 14:22:07 +00:00
apnadkarni 9f102b5b85 Minor change to length limit checks 2023-04-24 13:54:33 +00:00
apnadkarni 642792b1c2 Fix [a550f9710b] (format bigdata) 2023-04-24 12:55:35 +00:00
apnadkarni ef5af05366 Fix for bug [d4ede611a7] (scan) 2023-04-24 10:02:23 +00:00
pointsman 439a4360b3 Fixes the examples given in [0306a5563c]. Still more to do for a full fix. 2023-04-24 09:41:04 +00:00
pooryorick 321bff2cd5 Add bytearray checking to TclCheckEmptyString(), and then use
TclCheckEmptyString() in Tcl_AppendObjToObj and TclStringCat() to reduce string
generation.
2023-04-23 23:57:17 +00:00
jan.nijtmans d252076f75 Missing !defined(TCL_NO_DEPRECATED) around TIP #616 macro's. Thanks Rolf for noticing! 2023-04-23 21:59:34 +00:00
pooryorick eb3390224b Add bytearray checking to TclCheckEmptyString(), and then use
TclCheckEmptyString() in Tcl_AppendObjToObj and TclStringCat() to reduce string
generation.

jn: See discussion on mailing list "On the changing the sourcing of scripts to using strict profiles by default" for explanation why this commit is wrong, just as [e6fe76ae6b] and [4a7b807856] (which are similar commits, disguised as different ones).
2023-04-23 11:28:19 +00:00
apnadkarni f5125db22b Bug [d4ede611a7] (scan) - in progress 2023-04-23 03:25:33 +00:00
griffin 6ca1315df1 merge trunk 2023-04-21 00:35:20 +00:00
griffin b807564e68 sync with trunk. Fix lseq size bugs. 2023-04-20 18:13:36 +00:00
griffin 2aed8b1bdf Fix bug-fa00fbbbabe - seq / lindex discrepancies
Replace macros with static inline functions.
Limit ArithSeries list size to LIST_MAX. This way, shimmering less likely to fail if it happens.
Speed up UpdateStringOfArithSeries.
Fixed issues around indexing into vary large lseq lists.
2023-04-16 18:36:18 +00:00
jan.nijtmans 84a0e08557 Patch from chrstphrchvz, fixing [d40b9c8503]. Many thanks! 2023-03-26 15:51:21 +00:00
griffin 879e7b7112 Merge trunk 2023-03-25 00:29:59 +00:00
jan.nijtmans ef7bbf24e8 code cleanup (reduce diff with trunk) 2022-12-24 09:11:56 +00:00
jan.nijtmans 4531aa608d Merge 9.0 2022-12-22 16:17:57 +00:00
griffin bc3ff73062 Make as much abstract list implementation as possible internal.
Other code cleanup also.
2022-12-21 06:59:38 +00:00
jan.nijtmans a3f8bc6993 Merge 9.0. Now really make dist tests working (again) on Windows/gcc 2022-12-20 10:58:06 +00:00
jan.nijtmans bc7cadbfec Merge 9.0. Make dist tests working (again) on Windows/gcc 2022-12-20 07:24:42 +00:00
jan.nijtmans ab239a3b1f Merge 9.0 2022-12-18 21:38:14 +00:00
jan.nijtmans 7157c6b878 Reserve a place in abstractlist for an additional function 2022-12-18 10:05:40 +00:00
jan.nijtmans 0cdcbf3481 Merge 9.0 2022-12-18 09:10:25 +00:00
jan.nijtmans 9006753369 Merge 9.0. Fix testcases 2022-12-08 14:24:20 +00:00
griffin 6b52bc1a64 Add 'getdouble' function to ObjType, used for abstractlist types. -- Experimental 2022-12-07 23:56:10 +00:00
jan.nijtmans 3836fc2905 Code cleanup (undo some unnecessary changed compared to trunk) 2022-12-01 15:57:20 +00:00
jan.nijtmans 01f2b842e8 Merge 9.0. Fix Windows build (testcases need tcl::test package). Modify TCL_OBJTYPE_V1() macro, so it checks for the number of arguments 2022-12-01 15:16:37 +00:00
griffin b22a59093e Fix bug with slice (range) operation 2022-12-01 02:10:32 +00:00
jan.nijtmans f101fd4d8b Merge 9.0. Rename TclObjTypeHasProc to ABSTRACTLIST_PROC 2022-11-30 22:05:52 +00:00
jan.nijtmans bacd42baab Merge 9.0 2022-11-30 11:13:47 +00:00
jan.nijtmans 4a8099f371 Merge 9.0 (but without the "llength" optimization) 2022-11-30 10:46:57 +00:00
jan.nijtmans 5f45d1454b Merge 9.0 2022-11-29 10:38:49 +00:00
jan.nijtmans b1ee845c02 Merge 9.0 2022-11-29 09:53:43 +00:00
jan.nijtmans 64383b33bd Simplify TclObjTypeHasProc() (a lot!) 2022-11-28 21:45:49 +00:00
jan.nijtmans 2aa92d31a0 Merge 9.0 2022-11-28 16:13:34 +00:00
jan.nijtmans feee6ec002 Merge 9.0 2022-11-25 10:14:57 +00:00
jan.nijtmans b22f30259b TCL_OBJTYPE_V0_INIT -> TCL_OBJTYPE_V0 (See TIP #644). Remove Tcl_SavedResult (See TIP #640) 2022-11-24 21:48:42 +00:00
griffin 85ff1f33c9 Sync with trunk 2022-11-24 20:31:05 +00:00
griffin a4e76a1c02 Sync with trunk 2022-11-24 03:32:46 +00:00
griffin 7b6d022905 Support multiple indicies in abstract list lindex operation.
Catch up with trunk.
2022-11-24 01:18:36 +00:00
griffin 4335a4f475 Remove unused/incomplete functions. Some cleanup. 2022-11-08 22:02:33 +00:00
griffin 3e26e1b26d Sync with trunk 2022-11-06 05:20:26 +00:00
griffin 93374294e8 Sync with trunk 2022-11-05 23:35:46 +00:00
griffin 44a73b3640 Implement abstractlist with tip-644 2022-11-04 22:47:23 +00:00
griffin 853e484a64 TIP 636 for Tcl 9 2022-11-02 22:33:01 +00:00
griffin e2e526bea8 Swap which ObjTyp ptr is used for concrete Rep to match other types. 2022-11-02 16:45:47 +00:00
griffin c5bb0bc339 Sync with core-8-branch 2022-11-01 03:18:39 +00:00
griffin 028b789aec Add missing GetType call to export decls. Change SetElement to support multiple indicies. Improve abstract list test coverage. 2022-10-31 21:50:46 +00:00
griffin bb6cdd342a Sync with core-8-branch 2022-10-28 18:53:27 +00:00
griffin a89453a9e9 Expand AbstractList regression testing. 2022-10-28 06:13:11 +00:00
griffin 119e80fb28 Sync with core-8-branch 2022-10-25 02:30:28 +00:00
griffin 6d3452eeac Add AbstractList regression test (exercise the C API) 2022-10-25 01:13:45 +00:00
griffin e38c5076fe Sync with core-8-branch 2022-10-22 21:13:54 +00:00
griffin 6f1b4d55a4 Add Replace (lreplace) function to AbstractList type, and corrisponding Tcl_AbstractListObjReplace() API. 2022-10-22 00:07:40 +00:00
griffin 8b7cf2c7eb Sync with core-8-branch 2022-10-19 22:29:46 +00:00
griffin 0bc040dc40 More work on lset support in AbstractLists 2022-10-19 04:35:15 +00:00
griffin fb722eca56 Add SetElement function to abstract lists. Fix a few bugs. 2022-10-18 01:03:19 +00:00
griffin 699ec9db36 Sync with core-8-branch 2022-10-14 22:35:01 +00:00
griffin f72344d643 Update AbstractList man page. 2022-10-14 22:06:42 +00:00
griffin 999de87fbf Sync with core-8-branch 2022-10-12 21:16:12 +00:00
griffin 48ae5e307e Modify AbstractList functions to include interp for error reporting. Other various improvements. 2022-10-11 03:49:20 +00:00
apnadkarni 80303ffb39 Generalize UpdateStringOfAbstractList 2022-10-09 06:21:43 +00:00
griffin 7468d97286 Code cleanup and reorganize 2022-10-08 22:31:32 +00:00
griffin d24ee59fb5 TIP #636 starting imiplementation. 2022-10-08 04:28:55 +00:00
griffin f2fd360d01 Sync with core-8-branch 2022-10-08 02:39:41 +00:00
griffin af613a176f Sync with core-8-branch 2022-10-07 19:14:18 +00:00
griffin 9ed6390f05 Remove redundant file references in makefiles 2022-09-30 18:33:34 +00:00
griffin 259828fa5f Sync with core-8-branch 2022-09-29 13:45:46 +00:00
jan.nijtmans 528b7b7168 Merge 8.7 2022-09-28 14:08:05 +00:00
jan.nijtmans 0fbdd463cb Merge 8.7 2022-09-27 13:39:16 +00:00
jan.nijtmans dd1dc3c6e8 Merge 8.7 2022-09-26 19:26:11 +00:00
jan.nijtmans 4a3c559932 rebase to latest 8.7 2022-09-22 12:50:32 +00:00
jan.nijtmans cc185b1d76 eliminate some compiler warnings 2022-09-19 11:50:31 +00:00
jan.nijtmans 2ef45b0593 rebase to 8.7 2022-09-19 11:14:50 +00:00
jan.nijtmans a60681c2f3 Mrge 8.7. Make it work with C++, adapt win/Makefile.in to make it build on Windows with gcc 2022-09-08 14:53:35 +00:00
jan.nijtmans b9b527183a Merge 8.7 2022-09-07 13:26:09 +00:00
griffin 446587dc91 Missed change for Windows. 2022-08-28 00:45:40 +00:00
griffin 31c68fa4e7 Move all ArithSeries code to it's own file. Sync other changes wil TIP-629. 2022-08-28 00:10:13 +00:00
griffin f9e3b4dd74 Reimplement AbstrctList type structure to simplify. fix various bugs. 2022-08-19 18:08:39 +00:00
griffin 8bf1d3fbf1 Fix memory leak. 2022-08-15 15:23:24 +00:00
griffin 298667e221 Fix UpdateString to handle general case. Fix bug with elements list. 2022-08-11 16:21:39 +00:00
griffin 129d7aee61 Fix memory leak with Tcl_AbstractListObjGetElements. 2022-08-10 17:28:09 +00:00
griffin 92f5f9afc6 Make AbstractListRepPtr part of the public API as Tcl_AbstractListRepPtr.
Fix bug with ArithSeries Reverse function.
2022-08-10 04:21:16 +00:00
apnadkarni f3b81a9854 Fix Windows Visual C++ build 2022-08-09 16:07:24 +00:00
griffin 7561d600a6 Add version number to AbstractList implementation. Make sure lsort and lreplace do not shimer their input argument. 2022-08-08 23:52:43 +00:00
griffin 7030b2b274 Abstract Lists (TIP-225) initial implementation. 2022-08-08 19:38:19 +00:00
jan.nijtmans b6ce0622a6 Merge 8.7 2021-11-01 16:28:15 +00:00
dkf 136b650bda Added a basic portable test of [fconfigure -stat] 2021-07-13 19:53:38 +00:00
dkf 65b685deca Added documentation 2021-07-13 19:38:37 +00:00
jan.nijtmans 0865a0b6b0 Merge 8.7. Fix fstat() call in tclUnixChan.c, in case Tcl_StatBuf == struct stat64. 2021-06-29 15:02:53 +00:00
jan.nijtmans 79260bd695 Make tclWinChan.c compile again, fixing obvious implementation problems. Not tested if it actually works. 2021-06-29 08:54:19 +00:00
jan.nijtmans 1a062775d2 Fix iocmd-8.4 testcase 2021-06-28 12:32:35 +00:00
dkf a855be143c merge core-8-branch 2021-06-27 11:26:36 +00:00
dkf 5e07595538 First attempt at Windows implementation.
I don't develop on that platform, so this is extra dodgy!
2021-06-19 20:19:49 +00:00
dkf 5ed49bbc61 Added in missing field 2021-06-19 15:57:41 +00:00
dkf fa0c0e6134 Start of implementing TIP 603: chan configure -stat 2021-06-19 14:59:05 +00:00
jan.nijtmans f3b329dd28 Merge 8.7 2021-01-06 11:52:16 +00:00
dkf 496cff3ee1 merge core-8-branch 2021-01-05 20:41:27 +00:00
dkf 0f93742804 merge core-8-branch 2020-12-06 18:24:00 +00:00
dkf 7dd7fe1b6c merge core-8-branch 2020-02-26 16:56:53 +00:00
dkf bfcd8d392a merge core-8-branch 2020-02-22 12:35:05 +00:00
dkf 004c1e1c8e Less contorted code 2020-02-22 12:31:11 +00:00
dkf 99145db40b There are subtle cases where an append-if-new operation is really useful for a slot. 2020-02-15 10:28:01 +00:00
jan.nijtmans 2569d6f81c Merge 8.7 2020-02-12 13:24:16 +00:00
dkf dafa1487f9 caching is one of the two hard things in CS (along with naming and off-by-one-errors) 2020-02-07 09:21:08 +00:00
dkf 743e0e4e1a Move the TIP 558 tests into their own file 2020-01-01 16:57:08 +00:00
dkf 8249e877df More error cases 2020-01-01 16:46:55 +00:00
dkf b308bd97e6 Check for another tricky edge case 2020-01-01 16:01:36 +00:00
dkf ae24dd87fa merge core-8-branch 2019-12-31 23:27:01 +00:00
dkf 995eed36fd Better error messages when a property has the wrong kind for the type of access desired 2019-12-31 23:25:58 +00:00
dkf c4f94adb46 Other list-returning [info class] subcommands are plurals, so change property -> properties 2019-12-31 22:58:01 +00:00
dkf d4b3d3a460 Added docs 2019-12-31 14:56:32 +00:00
dkf 6eb109c913 Even more tests, this time of the return-code semantics of property getters and setters. 2019-12-30 15:35:51 +00:00
dkf edb3a561eb merge core-8-branch 2019-12-30 10:13:25 +00:00
dkf c15b6135d5 More tests, more fixes 2019-12-30 10:12:16 +00:00
dkf a7a226fc49 Property definitions now work on instances. 2019-12-29 13:23:47 +00:00
dkf 76c3874ad8 Starting to do the testing. 2019-12-28 21:55:56 +00:00
dkf c0eed541eb Implementation of properties for TclOO 2019-12-28 13:24:59 +00:00
228 changed files with 11618 additions and 49824 deletions
+2
View File
@@ -48,9 +48,11 @@ libtommath/*.tex
macosx/configure
unix/autoMkindex.tcl
unix/dltest.marker
unix/dltest/embtest
unix/dltest/*.bundle
unix/dltest/*.dll
unix/dltest/*.dylib
unix/dltest/*.exe
unix/dltest/*.o
unix/dltest/*.sl
unix/dltest/*.so
+16 -1
View File
@@ -1,5 +1,12 @@
name: Linux
on: [push]
on:
push:
branches:
- "main"
- "core-8-branch"
- "core-8-6-branch"
tags:
- "core-**"
permissions:
contents: read
jobs:
@@ -22,6 +29,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
timeout-minutes: 5
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
@@ -32,23 +40,30 @@ jobs:
./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1)
env:
CFGOPT: ${{ matrix.cfgopt }}
timeout-minutes: 5
- name: Build
run: |
make all
timeout-minutes: 5
- name: Build Test Harness
run: |
make tcltest
timeout-minutes: 5
- name: Run Tests
run: |
make test
env:
ERROR_ON_FAILURES: 1
timeout-minutes: 30
- name: Test-Drive Installation
run: |
make install
timeout-minutes: 5
- name: Create Distribution Package
run: |
make dist
timeout-minutes: 5
- name: Convert Documentation to HTML
run: |
make html-tcl
timeout-minutes: 5
+15 -1
View File
@@ -1,5 +1,12 @@
name: macOS
on: [push]
on:
push:
branches:
- "main"
- "core-8-branch"
- "core-8-6-branch"
tags:
- "core-**"
permissions:
contents: read
jobs:
@@ -12,6 +19,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
timeout-minutes: 5
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
@@ -20,11 +28,13 @@ jobs:
run: make all
env:
CFLAGS: -arch x86_64 -arch arm64
timeout-minutes: 15
- name: Run Tests
run: make test styles=develop
env:
ERROR_ON_FAILURES: 1
MAC_CI: 1
timeout-minutes: 15
clang:
runs-on: macos-11
strategy:
@@ -42,6 +52,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
timeout-minutes: 5
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
@@ -53,14 +64,17 @@ jobs:
env:
CFLAGS: -arch x86_64 -arch arm64
CFGOPT: ${{ matrix.cfgopt }}
timeout-minutes: 5
- name: Build
run: |
make all tcltest
env:
CFLAGS: -arch x86_64 -arch arm64
timeout-minutes: 15
- name: Run Tests
run: |
make test
env:
ERROR_ON_FAILURES: 1
MAC_CI: 1
timeout-minutes: 15
+10 -1
View File
@@ -1,5 +1,11 @@
name: Build Binaries
on: [push]
on:
push:
branches:
- "main"
- "core-8-branch"
tags:
- "core-**"
permissions:
contents: read
jobs:
@@ -9,6 +15,7 @@ jobs:
defaults:
run:
shell: bash
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -44,6 +51,7 @@ jobs:
defaults:
run:
shell: bash
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -106,6 +114,7 @@ jobs:
defaults:
run:
shell: msys2 {0}
timeout-minutes: 10
env:
CC: gcc
CFGOPT: --disable-symbols --disable-shared
+19 -1
View File
@@ -1,5 +1,12 @@
name: Windows
on: [push]
on:
push:
branches:
- "main"
- "core-8-branch"
- "core-8-6-branch"
tags:
- "core-**"
permissions:
contents: read
env:
@@ -24,26 +31,31 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
timeout-minutes: 5
- name: Init MSVC
uses: ilammy/msvc-dev-cmd@v1
timeout-minutes: 5
- name: Build ${{ matrix.cfgopt }}
run: |
&nmake -f makefile.vc ${{ matrix.cfgopt }} all
if ($lastexitcode -ne 0) {
throw "nmake exit code: $lastexitcode"
}
timeout-minutes: 5
- name: Build Test Harness ${{ matrix.cfgopt }}
run: |
&nmake -f makefile.vc ${{ matrix.cfgopt }} tcltest
if ($lastexitcode -ne 0) {
throw "nmake exit code: $lastexitcode"
}
timeout-minutes: 5
- name: Run Tests ${{ matrix.cfgopt }}
run: |
&nmake -f makefile.vc ${{ matrix.cfgopt }} test
if ($lastexitcode -ne 0) {
throw "nmake exit code: $lastexitcode"
}
timeout-minutes: 30
gcc:
runs-on: windows-2022
defaults:
@@ -67,8 +79,10 @@ jobs:
with:
msystem: MINGW64
install: git mingw-w64-x86_64-toolchain make
timeout-minutes: 10
- name: Checkout
uses: actions/checkout@v3
timeout-minutes: 5
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
@@ -79,12 +93,16 @@ jobs:
./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1)
env:
CFGOPT: --enable-64bit ${{ matrix.cfgopt }}
timeout-minutes: 5
- name: Build
run: make all
timeout-minutes: 5
- name: Build Test Harness
run: make tcltest
timeout-minutes: 5
- name: Run Tests
run: make test
timeout-minutes: 30
# If you add builds with Wine, be sure to define the environment variable
# CI_USING_WINE when running them so that broken tests know not to run.
+1
View File
@@ -53,6 +53,7 @@ libtommath/*.tex
macosx/configure
unix/autoMkindex.tcl
unix/dltest.marker
unix/dltest/embtest
unix/tcl.pc
unix/tclIndex
unix/pkgs/*
-8856
View File
File diff suppressed because it is too large Load Diff
-2634
View File
File diff suppressed because it is too large Load Diff
-2539
View File
File diff suppressed because it is too large Load Diff
-3629
View File
File diff suppressed because it is too large Load Diff
-4741
View File
File diff suppressed because it is too large Load Diff
-3349
View File
File diff suppressed because it is too large Load Diff
-4619
View File
File diff suppressed because it is too large Load Diff
-3822
View File
File diff suppressed because it is too large Load Diff
-5921
View File
File diff suppressed because it is too large Load Diff
-3796
View File
File diff suppressed because it is too large Load Diff
+45 -49
View File
@@ -4650,7 +4650,7 @@ threading may still cause problems on AIX. (hobbs)
9/21/99 (bug fix) fixed bug when setting array in non-existent
namespace. [Bug: 2613] (hobbs)
--- Released 8.2.1, October 04, 1999 --- See ChangeLog for details ---
--- Released 8.2.1, October 04, 1999
10/30/99 (feature enhancement) new regexp engine from Henry Spencer
was patched in - should greatly reduce stack space usage. (spencer)
@@ -4680,7 +4680,7 @@ when indexing into one (test case string-5.16) [Bug: 2871] (hobbs)
10/30/99 (bug fix) fixes for mac UTF filename handling (ingham)
--- Released 8.2.2, November 04, 1999 --- See ChangeLog for details ---
--- Released 8.2.2, November 04, 1999
11/19/99 (feature enhancement) bug fixes for http package as well as
patch required by TLS (SSL) extension that adds http::(un)register
@@ -4705,7 +4705,7 @@ atexit handlers.
12/07/99 (bug fix) fixes for 'expr + {[incr]}' and 'expr + {[error]}'
cases (different causes).
--- Released 8.2.3, December 16, 1999 --- See ChangeLog for details ---
--- Released 8.2.3, December 16, 1999
1999-09-14 (feature enhancement) added -start switch to regexp and regsub.
@@ -4762,7 +4762,7 @@ ExitThread to _endthreadex to prevent 4K mem leak (gravereaux)
1999-12-21 (bug fix) changed thread ids to longs (for 64bit systems)
--- Released 8.3b1, December 22, 1999 --- See ChangeLog for details ---
--- Released 8.3b1, December 22, 1999
2000-01-10 (feature enhancement) clock scan now supports the common
ISO 8601 date/time formats. See docs for details. (melski)
@@ -4788,7 +4788,7 @@ symbolicly (like chmod) in [file attributes $file -permissions ...] (schoebel)
2000-01-13 (bug fix) fixed lsort -dictionary problem when sorting
characters between 'Z' and 'a' (flawed upper/lower comparison logic) (melski)
--- Released 8.3b2, January 13, 2000 --- See ChangeLog for details ---
--- Released 8.3b2, January 13, 2000
2000-01-14 (feature enhancement) clock format %Q added, clock scan updated
@@ -4827,7 +4827,7 @@ mac panic from an error when closing an async socket (steffen, ingham)
2000-02-10 (feature enhancement) improved error reporting for failed
loads on Windows (dejong, hobbs)
--- Released 8.3.0, February 10, 2000 --- See ChangeLog for details ---
--- Released 8.3.0, February 10, 2000
2000-03 (bug fixes, feature enhancement) overhaul of http package for
proper handling of async callbacks (new options), version is now at 2.3
@@ -4870,7 +4870,7 @@ tclLoadDyld.c dl type. (sanchez)
2000-04-24 (bug fix) fixed hang in threaded Unix case when backgrounded
exec process was running (dejong)
--- Released 8.3.1, April 26, 2000 --- See ChangeLog for details ---
--- Released 8.3.1, April 26, 2000
2000-04-26 (doc fix) updated/added documentation for many API's and
commands (melski)
@@ -4920,7 +4920,7 @@ pattern matching for [array names] (gazetta)
2000-05-31 (feature enhancement) added -nocomplain and -- flags to
[unset] to allow for silent unset operation (hobbs)
--- Released 8.4a1, June 6, 2000 --- See ChangeLog for details ---
--- Released 8.4a1, June 6, 2000
2000-05-29 (bug fix) corrected resource cleanup in http error cases.
Improved handling of error cases in http. (tamhankar)
@@ -4959,7 +4959,7 @@ sections. (english)
2000-08-07 (bug fix) new man pages memory.n, TCL_MEM_DEBUG.3, Init.3 and
DumpActiveMemory.3. (melski)
--- Released 8.3.2, August 9, 2000 --- See ChangeLog for details ---
--- Released 8.3.2, August 9, 2000
2000-06 thru 2000-11 (build improvements) Added support for mingw (gcc on
Windows), AIX-5 and Win64 builds (dejong, hobbs)
@@ -5018,7 +5018,7 @@ environment (gravereaux)
2000-11-03 (new feature) Tcl_SetMainLoop enables defining an event loop for
tclsh. This enables Tk as a truly loadable package. (hobbs)
--- Released 8.4a2, November 3, 2000 --- See ChangeLog for details ---
--- Released 8.4a2, November 3, 2000
2000-09-27 (bug fix) fixed a bug introduced by a partial fix in 8.3.2 that
didn't set nonBlocking correctly when resetting the flags for the write
@@ -5076,7 +5076,7 @@ Update of READMEs.
Corrected IRIX-5* configure (english). Added support for AIX-5 (hobbs).
Added support for Win64 (hobbs).
--- Released 8.3.3, April 6, 2001 --- See ChangeLog for details ---
--- Released 8.3.3, April 6, 2001
2000-11-23 (new feature)[TIP 7] higher resolution timer on Windows (kenny)
@@ -5150,7 +5150,7 @@ system. This includes the addition of 'file normalize', 'file system',
* corrected several minor errors noted by Purify (hobbs)
--- Released 8.4a3, August 6, 2001 --- See ChangeLog for details ---
--- Released 8.4a3, August 6, 2001
2001-06-27 (bug fix)[217987] corrected backslash substitution of non-ASCII
characters. (hobbs, riefenstahl)
@@ -5256,7 +5256,7 @@ bundles to standard .dylib dynamic libraries like on other unices.
2001-10-18 (bug fix) corrected off-by-one-day error in clock scan with
relative months and years during swing hours. (lavana)
--- Released 8.3.4, October 19, 2001 --- See ChangeLog for details ---
--- Released 8.3.4, October 19, 2001
2001-08-21 (bug fix)[219184] overagressive compilation of [catch] (sofer)
@@ -5282,8 +5282,6 @@ compiles to 0 bytecodes (sofer)
2001-09-13 (new feature)[TIP 56] Tcl_EvalTokensStandard API (sofer)
2001-09-13 (new feature) Old ChangeLog entries => ChangeLog.1999 (hobbs)
2001-09-17 (new feature) compiling with TCL_COMPILE_DEBUG now required to
enable all compile and execution tracing (sofer)
*** POTENTIAL INCOMPATIBILITY ***
@@ -5368,8 +5366,6 @@ of the Host: header value
2002-01-25 (new feature)[496733] socket options -eofchar and -translation
return read-only values (dejong)
2002-01-28 (new feature) Old ChangeLog entries => ChangeLog.20900 (hobbs)
2002-01-28 (performance enhancement) bytecompiled [regexp] for trivial cases
that amount to string matching. Also -nocase and --. (hobbs)
@@ -5394,7 +5390,7 @@ errored out. (kupries, sofer)
2002-02-15 (new feature)[TIP 72] support for 64-bit integer values on
32-bit platforms and ability to work with >2GiB files. Extends many
commands. See ChangeLog and TIP for details.
commands. See TIP for details.
*** POTENTIAL INCOMPATIBILITY ***
2002-02-22 (bug fix)[476537] Fix panic when loading shared library without
@@ -5435,7 +5431,7 @@ of prior Tcl releases. Others will need to be reconciled.
related to the handling of iso2022 text and finalization of escape-based
encodings. (taguchi, takahashi, hobbs)
--- Released 8.4a4, March 5, 2002 --- See ChangeLog for details ---
--- Released 8.4a4, March 5, 2002
2002-03-06 (new feature)[TIP 80] expanded [lsearch] options (wilkason, fellows)
@@ -5545,7 +5541,7 @@ options to configure (max)
2002-07-03 (bug fix)[577015] [catch] catches even compile errors (sofer)
--- Released 8.4b1, July 5, 2002 --- See ChangeLog for details ---
--- Released 8.4b1, July 5, 2002
2002-07-08 (bug fix) restored compatibility of [viewFile] in tcltest (porter)
@@ -5583,7 +5579,7 @@ options to configure (max)
Many internal bugs fixed.
Considerable cleanup of the test suite.
--- Released 8.4b2, August 9, 2002 --- See ChangeLog for details ---
--- Released 8.4b2, August 9, 2002
2002-08-20 (new feature) --enable-memdebug configure option (kupries)
@@ -5598,7 +5594,7 @@ Considerable cleanup of the test suite.
2002-09-02 (platfrom support) 64-bit compile on HP-11 (martin)
--- Released 8.4.0, September 10, 2002 --- See ChangeLog for details ---
--- Released 8.4.0, September 10, 2002
2002-09-18 (platform support) Updated support for compiling with Cygwin and
either mingw or gcc. (khan, howell, dejong)
@@ -5661,7 +5657,7 @@ dirs to tcl_pkgPath: @executable_path/../Frameworks and
@executable_path/../PrivateFrameworks (if they exist), as well as the dirs
in DYLD_FRAMEWORK_PATH (if set). (steffen)
--- Released 8.4.1, October 22, 2002 --- See ChangeLog for details ---
--- Released 8.4.1, October 22, 2002
2002-10-28 (bug fix)[627660] [package unknown] chaining for platform specifics
@@ -5754,7 +5750,7 @@ packages in multiple interps.
2003-02-27 (bug fix)[694232] stop [lsearch -start 0 {} x] segfault
--- Released 8.4.2, March 3, 2003 --- See ChangeLog for details ---
--- Released 8.4.2, March 3, 2003
2003-03-06 (bug fix)[699042] Correct case-insensitive unicode string
comparison in Tcl_UniCharNcasecmp
@@ -5836,7 +5832,7 @@ encoding for the original. Most uses of gb2312 really mean euc-cn.
2003-05-14 (bug fix)[736421] Corrected another putenv() copy behavior
problem when compiling on Windows and using Microsoft's runtime.
--- Released 8.4.3, May 20, 2003 --- See ChangeLog for details ---
--- Released 8.4.3, May 20, 2003
2003-05-23 (bug fix)[726018] reverted internals change to the
'cmdName' Tcl_ObjType that broke several extensions (TclBlend, e4graph...)
@@ -5877,7 +5873,7 @@ Improved documentation, new tests, and some code cleanup.
[655300, 720634, 735364, 748700, 756112, 756744, 756951, 758488, 760768,
763312, 769895, 771539, 771840, 771947, 771949, 772333]
--- Released 8.4.4, July 22, 2003 --- See ChangeLog for details ---
--- Released 8.4.4, July 22, 2003
2003-07-23 (bug fix)[775976] fix registry compilation for VC7.
@@ -5923,7 +5919,7 @@ asked for writable events by the generic layer.
2003-11-17 (bug fix)[230589, 504785, 505048, 703709, 840258] fixes to
various odd regexp "can't happen" bugs.
--- Released 8.4.5, November 20, 2003 --- See ChangeLog for details ---
--- Released 8.4.5, November 20, 2003
2003-12-02 (bug fix)[851747] object sharing fix in [binary scan]
@@ -5960,7 +5956,7 @@ various odd regexp "can't happen" bugs.
2004-03-01 (platform support)[218561] Allow 64-bit configure on IRIX64-6.5*
--- Released 8.4.6, March 1, 2004 --- See ChangeLog for details ---
--- Released 8.4.6, March 1, 2004
Changes to 8.5a1 include all changes to the 8.4 line through 8.4.6,
plus the following, which focuses on the high-level feature changes
@@ -6046,7 +6042,7 @@ in this changeset (new minor version) rather than bug fixes:
* [TIP #157] leading {expand} syntax on words to cause argument expansion.
This is a safer/cleaner alternative to the use of 'eval'.
--- Released 8.5a1, March 3, 2004 --- See ChangeLog for details ---
--- Released 8.5a1, March 3, 2004
2004-03-04 (new feature) registry package is [unload]able (thoyts)
=> registry 1.1.4
@@ -6070,7 +6066,7 @@ each command/interp validity before executing. (sofer)
2004-04-06 (clean up) refactored Tcl header file #include order. Might
create need for changes in extensions that #include private headers.
Changed source code files should work with older Tcl as well. See ChangeLog.
Changed source code files should work with older Tcl as well.
*** POTENTIAL INCOMPATIBILITY ***
2004-04-07 (bug fix)[920667] install into any Unicode path on Win (hobbs)
@@ -6346,7 +6342,7 @@ Doc improvements [759545,926590,935853,1017072,1018486,1022527,1027849,
1032243,1047928,1048005,1058446,1062647,1065732,1073334,etc.]
Test suite expansion [1036649,1001997,etc.]
--- Released 8.5a2, December 7, 2004 --- See ChangeLog for details ---
--- Released 8.5a2, December 7, 2004
2004-12-13 (bug fix)[1083082] encoding memory leaks (ade,porter)
@@ -6490,7 +6486,7 @@ Can support [load] from memory as well (steffen)
Documentation improvements [1075433,1085127,1117017,1124160,1149605,etc.]
--- Released 8.5a3, June 4, 2005 --- See ChangeLog for details ---
--- Released 8.5a3, June 4, 2005
2005-06-06 (bug fix)[1213678] Windows/gcc: crash in stack.test (kenny)
@@ -6741,7 +6737,7 @@ removed (steffen)
Documentation improvements [1211078,1190891,1292427,1277503,1104682,1359183,
1415725,666770]
--- Released 8.5a4, April 27, 2006 --- See ChangeLog for details ---
--- Released 8.5a4, April 27, 2006
2006-05-04 (bug fix)[1480509] srand() accept wide input (porter,afredd)
@@ -6837,7 +6833,7 @@ URL validity checking against RFC 2986 (hobbs)
2006-10-13 (platform support) get stack size on Darwin (steffen)
--- Released 8.5a5, October 20, 2006 --- See ChangeLog for details ---
--- Released 8.5a5, October 20, 2006
2006-10-20 (configure change) Added autodetection for OS-supplied timezone
files (max)
@@ -6919,7 +6915,7 @@ upvar and namespace upvar (sofer)
2007-04-23 (bug fix) fts_open() crash on 64bit Darwin 8 or earlier (steffen)
--- Released 8.5a6, April 25, 2007 --- See ChangeLog for details ---
--- Released 8.5a6, April 25, 2007
2007-04-30 (bug fix)[1705778] many valgrind-detected leaks corrected
@@ -7022,7 +7018,7 @@ project for Xcode 3.0 (steffen)
(bug fix)[1066755] Several stack efficiency efforts increases recursion limit
on Windows to be larger than the default [interp recursionlimit] value
--- Released 8.5b1, September 26, 2007 --- See ChangeLog for details ---
--- Released 8.5b1, September 26, 2007
2007-10-02 (bug fix)[1806422] proper [tcl::tm::path] autoload (porter)
@@ -7034,7 +7030,7 @@ on Windows to be larger than the default [interp recursionlimit] value
2007-10-25 (bug fix)[1726873] intermittent crash in threads (vasiljevic)
--- Released 8.5b2, October 26, 2007 --- See ChangeLog for details ---
--- Released 8.5b2, October 26, 2007
2007-10-27 (bug fix)[1821159] fixed broken compile on x86_64 (sofer)
@@ -7070,7 +7066,7 @@ on Windows to be larger than the default [interp recursionlimit] value
Many significant documentation improvements (fellows, sofer)
--- Released 8.5b3, November 19, 2007 --- See ChangeLog for details ---
--- Released 8.5b3, November 19, 2007
2007-11-20 (enhancement) string rep of dict has stable order (fellows)
@@ -7104,7 +7100,7 @@ over-consumption of resources (drewry,lane,ormandy,fellows)
Several documentation and release notes improvements
--- Released 8.5.0, December 20, 2007 --- See ChangeLog for details ---
--- Released 8.5.0, December 20, 2007
2007-12-23 (bug fix)[1857126] restore backref support to regexps (hobbs)
@@ -7126,7 +7122,7 @@ Several documentation and release notes improvements
Several documentation and release notes improvements
--- Released 8.5.1, February 5, 2008 --- See ChangeLog for details ---
--- Released 8.5.1, February 5, 2008
2008-02-06 (enhancement) [clock format] performance (kenny)
@@ -7187,7 +7183,7 @@ variables without "." added to customization hooks (kupries)
2008-03-27 clock tzdata updated to Olson's tzdata2008b (kenny)
--- Released 8.5.2, March 28, 2008 --- See ChangeLog for details ---
--- Released 8.5.2, March 28, 2008
2008-03-30 (bug fix)[1783544] more robust TclIsNaN() (kenny,teterin)
@@ -7242,7 +7238,7 @@ variables without "." added to customization hooks (kupries)
2008-06-25 (bug fix)[1999119] Support TM packages in Safe Base (kupries)
--- Released 8.6a1, June 25, 2008 --- See ChangeLog for details ---
--- Released 8.6a1, June 25, 2008
2008-06-29 (bug fix)[2004480] plug memory leaks (ade,porter,steffen)
@@ -7295,7 +7291,7 @@ in a deleted interp. (porter)
2008-08-21 (bug fix)[2065115] Restored ***= regexp functioning (hobbs,porter)
--- Released 8.6a2, August 25, 2008 --- See ChangeLog for details ---
--- Released 8.6a2, August 25, 2008
2008-08-29 (bug fix)[2082299] Install TclOO header files (fellows)
@@ -7376,7 +7372,7 @@ Tcl_FSFileAttrStringsProc prototype. (nijtmans)
2008-10-10 (bug fix)[2155658] crash in oo method export (fellows)
--- Released 8.6a3, October 10, 2008 --- See ChangeLog for details ---
--- Released 8.6a3, October 10, 2008
2008-10-13 (bug fix) Fix ability to join threads on 64-bit Windows (thoyts)
@@ -7446,7 +7442,7 @@ evaluation in extensions (sofer,kenny)
2008-12-18 (bug fix)[2444274] panic in long commands from {*} (goth,porter)
--- Released 8.6b1, December 19, 2008 --- See ChangeLog for details ---
--- Released 8.6b1, December 19, 2008
2008-12-27 [TIP 234] Tcl_Zlib* interface revisions (fellows)
*** INCOMPATIBILITY with interface of 8.6b1 ***
@@ -7954,7 +7950,7 @@ memory with buffer backup (ferrieux)
Many more Tcl built-in command errors now set an -errorcode.
--- Released 8.6b2, August 8, 2011 --- See ChangeLog for details ---
--- Released 8.6b2, August 8, 2011
2011-07-02 (bug fix)[3349507] correct double(1[string repeat 0 23]) (kenny)
@@ -8115,7 +8111,7 @@ Many revisions to better support a Cygwin environment (nijtmans)
Dropped support for OS X versions less than 10.4 (Tiger) (fellows)
--- Released 8.6b3, September 18, 2012 --- See ChangeLog for details ---
--- Released 8.6b3, September 18, 2012
2012-09-20 (enhancement) full Unicode support (nijtmans)
=> dde 1.4.0
@@ -8162,7 +8158,7 @@ Dropped support for OS X versions less than 10.4 (Tiger) (fellows)
2012-12-13 (bug fix) crash: [zlib gunzip $data -header noSuchNs::var] (porter)
--- Released 8.6.0, December 20, 2012 --- See ChangeLog for details ---
--- Released 8.6.0, December 20, 2012
2012-12-22 (bug fix)[3598150] DString to Tcl_Obj memleak (afredd)
@@ -8251,7 +8247,7 @@ Dropped support for OS X versions less than 10.4 (Tiger) (fellows)
2013-06-05 (bug fix)[2835313] [while 1 {foo [continue]}] crash (fellows)
2013-06-17 (bug fix)[a876646] [:cntrl:] includes \x00 to \x1f (nijtmans)
2013-06-17 (bug fix)[a876646] [:cntrl:] includes \x00 to \x1F (nijtmans)
2013-06-27 (bug fix)[983509] missing encodings for config values (nijtmans)
-21
View File
@@ -1,21 +0,0 @@
/*
* dirent.h --
*
* This file is a replacement for <dirent.h> in systems that
* support the old BSD-style <sys/dir.h> with a "struct direct".
*
* Copyright (c) 1991 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _DIRENT
#define _DIRENT
#include <sys/dir.h>
#define dirent direct
#endif /* _DIRENT */
-53
View File
@@ -1,53 +0,0 @@
/*
* dirent.h --
*
* Declarations of a library of directory-reading procedures
* in the POSIX style ("struct dirent").
*
* Copyright (c) 1991 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _DIRENT
#define _DIRENT
/*
* Dirent structure, which holds information about a single
* directory entry.
*/
#define MAXNAMLEN 255
#define DIRBLKSIZ 512
struct dirent {
long d_ino; /* Inode number of entry */
short d_reclen; /* Length of this record */
short d_namlen; /* Length of string in d_name */
char d_name[MAXNAMLEN + 1]; /* Name must be no longer than this */
};
/*
* State that keeps track of the reading of a directory (clients
* should never look inside this structure; the fields should
* only be accessed by the library procedures).
*/
typedef struct _dirdesc {
int dd_fd;
long dd_loc;
long dd_size;
char dd_buf[DIRBLKSIZ];
} DIR;
/*
* Procedures defined for reading directories:
*/
extern void closedir (DIR *dirp);
extern DIR * opendir (char *name);
extern struct dirent * readdir (DIR *dirp);
#endif /* _DIRENT */
-64
View File
@@ -1,64 +0,0 @@
/*
* memcmp.c --
*
* Source code for the "memcmp" library routine.
*
* Copyright (c) 1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tclPort.h"
/*
* Here is the prototype just in case it is not included in tclPort.h.
*/
int memcmp(const void *s1, const void *s2, size_t n);
/*
*----------------------------------------------------------------------
*
* memcmp --
*
* Compares two bytes sequences.
*
* Results:
* Compares its arguments, looking at the first n bytes (each interpreted
* as an unsigned char), and returns an integer less than, equal to, or
* greater than 0, according as s1 is less than, equal to, or greater
* than s2 when taken to be unsigned 8 bit numbers.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
memcmp(
const void *s1, /* First string. */
const void *s2, /* Second string. */
size_t n) /* Length to compare. */
{
const unsigned char *ptr1 = (const unsigned char *) s1;
const unsigned char *ptr2 = (const unsigned char *) s2;
for ( ; n-- ; ptr1++, ptr2++) {
unsigned char u1 = *ptr1, u2 = *ptr2;
if (u1 != u2) {
return (u1-u2);
}
}
return 0;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
-110
View File
@@ -1,110 +0,0 @@
/*
* opendir.c --
*
* This file provides dirent-style directory-reading procedures for V7
* Unix systems that don't have such procedures. The origin of this code
* is unclear, but it seems to have come originally from Larry Wall.
*/
#include "tclInt.h"
#undef DIRSIZ
#define DIRSIZ(dp) \
((sizeof(struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
/*
* open a directory.
*/
DIR *
opendir(
char *name)
{
DIR *dirp;
int fd;
const char *myname;
myname = ((*name == '\0') ? "." : name);
if ((fd = open(myname, 0, 0)) == -1) {
return NULL;
}
dirp = (DIR *) Tcl_Alloc(sizeof(DIR));
if (dirp == NULL) {
/* unreachable? */
close(fd);
return NULL;
}
dirp->dd_fd = fd;
dirp->dd_loc = 0;
return dirp;
}
/*
* read an old style directory entry and present it as a new one
*/
#ifndef pyr
#define ODIRSIZ 14
struct olddirect {
ino_t od_ino;
char od_name[ODIRSIZ];
};
#else /* a Pyramid in the ATT universe */
#define ODIRSIZ 248
struct olddirect {
long od_ino;
short od_fill1, od_fill2;
char od_name[ODIRSIZ];
};
#endif
/*
* get next entry in a directory.
*/
struct dirent *
readdir(
DIR *dirp)
{
struct olddirect *dp;
static struct dirent dir;
for (;;) {
if (dirp->dd_loc == 0) {
dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ);
if (dirp->dd_size <= 0) {
return NULL;
}
}
if (dirp->dd_loc >= dirp->dd_size) {
dirp->dd_loc = 0;
continue;
}
dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
dirp->dd_loc += sizeof(struct olddirect);
if (dp->od_ino == 0) {
continue;
}
dir.d_ino = dp->od_ino;
strncpy(dir.d_name, dp->od_name, ODIRSIZ);
dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
dir.d_namlen = strlen(dir.d_name);
dir.d_reclen = DIRSIZ(&dir);
return &dir;
}
}
/*
* close a directory.
*/
void
closedir(
DIR *dirp)
{
close(dirp->dd_fd);
dirp->dd_fd = -1;
dirp->dd_loc = 0;
Tcl_Free(dirp);
}
-919
View File
@@ -1,919 +0,0 @@
/* A portable stdint.h
****************************************************************************
* BSD License:
****************************************************************************
*
* Copyright (c) 2005-2016 Paul Hsieh
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************
*
* Version 0.1.16.0
*
* The ANSI C standard committee, for the C99 standard, specified the
* inclusion of a new standard include file called stdint.h. This is
* a very useful and long desired include file which contains several
* very precise definitions for integer scalar types that is critically
* important for making several classes of applications portable
* including cryptography, hashing, variable length integer libraries
* and so on. But for most developers its likely useful just for
* programming sanity.
*
* The problem is that some compiler vendors chose to ignore the C99
* standard and some older compilers have no opportunity to be updated.
* Because of this situation, simply including stdint.h in your code
* makes it unportable.
*
* So that's what this file is all about. It's an attempt to build a
* single universal include file that works on as many platforms as
* possible to deliver what stdint.h is supposed to. Even compilers
* that already come with stdint.h can use this file instead without
* any loss of functionality. A few things that should be noted about
* this file:
*
* 1) It is not guaranteed to be portable and/or present an identical
* interface on all platforms. The extreme variability of the
* ANSI C standard makes this an impossibility right from the
* very get go. Its really only meant to be useful for the vast
* majority of platforms that possess the capability of
* implementing usefully and precisely defined, standard sized
* integer scalars. Systems which are not intrinsically 2s
* complement may produce invalid constants.
*
* 2) There is an unavoidable use of non-reserved symbols.
*
* 3) Other standard include files are invoked.
*
* 4) This file may come in conflict with future platforms that do
* include stdint.h. The hope is that one or the other can be
* used with no real difference.
*
* 5) In the current version, if your platform can't represent
* int32_t, int16_t and int8_t, it just dumps out with a compiler
* error.
*
* 6) 64 bit integers may or may not be defined. Test for their
* presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
* Note that this is different from the C99 specification which
* requires the existence of 64 bit support in the compiler. If
* this is not defined for your platform, yet it is capable of
* dealing with 64 bits then it is because this file has not yet
* been extended to cover all of your system's capabilities.
*
* 7) (u)intptr_t may or may not be defined. Test for its presence
* with the test: #ifdef PTRDIFF_MAX. If this is not defined
* for your platform, then it is because this file has not yet
* been extended to cover all of your system's capabilities, not
* because its optional.
*
* 8) The following might not been defined even if your platform is
* capable of defining it:
*
* WCHAR_MIN
* WCHAR_MAX
* (u)int64_t
* PTRDIFF_MIN
* PTRDIFF_MAX
* (u)intptr_t
*
* 9) The following have not been defined:
*
* WINT_MIN
* WINT_MAX
*
* 10) The criteria for defining (u)int_least(*)_t isn't clear,
* except for systems which don't have a type that precisely
* defined 8, 16, or 32 bit types (which this include file does
* not support anyways). Default definitions have been given.
*
* 11) The criteria for defining (u)int_fast(*)_t isn't something I
* would trust to any particular compiler vendor or the ANSI C
* committee. It is well known that "compatible systems" are
* commonly created that have very different performance
* characteristics from the systems they are compatible with,
* especially those whose vendors make both the compiler and the
* system. Default definitions have been given, but its strongly
* recommended that users never use these definitions for any
* reason (they do *NOT* deliver any serious guarantee of
* improved performance -- not in this file, nor any vendor's
* stdint.h).
*
* 12) The following macros:
*
* PRINTF_INTMAX_MODIFIER
* PRINTF_INT64_MODIFIER
* PRINTF_INT32_MODIFIER
* PRINTF_INT16_MODIFIER
* PRINTF_LEAST64_MODIFIER
* PRINTF_LEAST32_MODIFIER
* PRINTF_LEAST16_MODIFIER
* PRINTF_INTPTR_MODIFIER
*
* are strings which have been defined as the modifiers required
* for the "d", "u" and "x" printf formats to correctly output
* (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
* (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
* PRINTF_INTPTR_MODIFIER is not defined for some systems which
* provide their own stdint.h. PRINTF_INT64_MODIFIER is not
* defined if INT64_MAX is not defined. These are an extension
* beyond what C99 specifies must be in stdint.h.
*
* In addition, the following macros are defined:
*
* PRINTF_INTMAX_HEX_WIDTH
* PRINTF_INT64_HEX_WIDTH
* PRINTF_INT32_HEX_WIDTH
* PRINTF_INT16_HEX_WIDTH
* PRINTF_INT8_HEX_WIDTH
* PRINTF_INTMAX_DEC_WIDTH
* PRINTF_INT64_DEC_WIDTH
* PRINTF_INT32_DEC_WIDTH
* PRINTF_INT16_DEC_WIDTH
* PRINTF_UINT8_DEC_WIDTH
* PRINTF_UINTMAX_DEC_WIDTH
* PRINTF_UINT64_DEC_WIDTH
* PRINTF_UINT32_DEC_WIDTH
* PRINTF_UINT16_DEC_WIDTH
* PRINTF_UINT8_DEC_WIDTH
*
* Which specifies the maximum number of characters required to
* print the number of that type in either hexadecimal or decimal.
* These are an extension beyond what C99 specifies must be in
* stdint.h.
*
* Compilers tested (all with 0 warnings at their highest respective
* settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
* bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
* .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
*
* This file should be considered a work in progress. Suggestions for
* improvements, especially those which increase coverage are strongly
* encouraged.
*
* Acknowledgements
*
* The following people have made significant contributions to the
* development and testing of this file:
*
* Chris Howie
* John Steele Scott
* Dave Thorup
* John Dill
* Florian Wobbe
* Christopher Sean Morrison
* Mikkel Fahnoe Jorgensen
*
*/
#include <stddef.h>
#include <limits.h>
#include <signal.h>
/*
* For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
* do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
*/
#if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
#include <stdint.h>
#define _PSTDINT_H_INCLUDED
# if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__))
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "l"
# endif
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER ""
# endif
# else
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "ll"
# endif
# ifndef PRINTF_INT32_MODIFIER
# if (UINT_MAX == UINT32_MAX)
# define PRINTF_INT32_MODIFIER ""
# else
# define PRINTF_INT32_MODIFIER "l"
# endif
# endif
# endif
# ifndef PRINTF_INT16_MODIFIER
# define PRINTF_INT16_MODIFIER "h"
# endif
# ifndef PRINTF_INTMAX_MODIFIER
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
# endif
# ifndef PRINTF_INT64_HEX_WIDTH
# define PRINTF_INT64_HEX_WIDTH "16"
# endif
# ifndef PRINTF_UINT64_HEX_WIDTH
# define PRINTF_UINT64_HEX_WIDTH "16"
# endif
# ifndef PRINTF_INT32_HEX_WIDTH
# define PRINTF_INT32_HEX_WIDTH "8"
# endif
# ifndef PRINTF_UINT32_HEX_WIDTH
# define PRINTF_UINT32_HEX_WIDTH "8"
# endif
# ifndef PRINTF_INT16_HEX_WIDTH
# define PRINTF_INT16_HEX_WIDTH "4"
# endif
# ifndef PRINTF_UINT16_HEX_WIDTH
# define PRINTF_UINT16_HEX_WIDTH "4"
# endif
# ifndef PRINTF_INT8_HEX_WIDTH
# define PRINTF_INT8_HEX_WIDTH "2"
# endif
# ifndef PRINTF_UINT8_HEX_WIDTH
# define PRINTF_UINT8_HEX_WIDTH "2"
# endif
# ifndef PRINTF_INT64_DEC_WIDTH
# define PRINTF_INT64_DEC_WIDTH "19"
# endif
# ifndef PRINTF_UINT64_DEC_WIDTH
# define PRINTF_UINT64_DEC_WIDTH "20"
# endif
# ifndef PRINTF_INT32_DEC_WIDTH
# define PRINTF_INT32_DEC_WIDTH "10"
# endif
# ifndef PRINTF_UINT32_DEC_WIDTH
# define PRINTF_UINT32_DEC_WIDTH "10"
# endif
# ifndef PRINTF_INT16_DEC_WIDTH
# define PRINTF_INT16_DEC_WIDTH "5"
# endif
# ifndef PRINTF_UINT16_DEC_WIDTH
# define PRINTF_UINT16_DEC_WIDTH "5"
# endif
# ifndef PRINTF_INT8_DEC_WIDTH
# define PRINTF_INT8_DEC_WIDTH "3"
# endif
# ifndef PRINTF_UINT8_DEC_WIDTH
# define PRINTF_UINT8_DEC_WIDTH "3"
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
# endif
# ifndef PRINTF_UINTMAX_HEX_WIDTH
# define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
# endif
# ifndef PRINTF_UINTMAX_DEC_WIDTH
# define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
# endif
/*
* Something really weird is going on with Open Watcom. Just pull some of
* these duplicated definitions from Open Watcom's stdint.h file for now.
*/
# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
# if !defined (INT64_C)
# define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
# endif
# if !defined (UINT64_C)
# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
# endif
# if !defined (INT32_C)
# define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
# endif
# if !defined (UINT32_C)
# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
# endif
# if !defined (INT16_C)
# define INT16_C(x) (x)
# endif
# if !defined (UINT16_C)
# define UINT16_C(x) (x)
# endif
# if !defined (INT8_C)
# define INT8_C(x) (x)
# endif
# if !defined (UINT8_C)
# define UINT8_C(x) (x)
# endif
# if !defined (UINT64_MAX)
# define UINT64_MAX 18446744073709551615ULL
# endif
# if !defined (INT64_MAX)
# define INT64_MAX 9223372036854775807LL
# endif
# if !defined (UINT32_MAX)
# define UINT32_MAX 4294967295UL
# endif
# if !defined (INT32_MAX)
# define INT32_MAX 2147483647L
# endif
# if !defined (INTMAX_MAX)
# define INTMAX_MAX INT64_MAX
# endif
# if !defined (INTMAX_MIN)
# define INTMAX_MIN INT64_MIN
# endif
# endif
#endif
/*
* I have no idea what is the truly correct thing to do on older Solaris.
* From some online discussions, this seems to be what is being
* recommended. For people who actually are developing on older Solaris,
* what I would like to know is, does this define all of the relevant
* macros of a complete stdint.h? Remember, in pstdint.h 64 bit is
* considered optional.
*/
#if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED)
#include <sys/inttypes.h>
#define _PSTDINT_H_INCLUDED
#endif
#ifndef _PSTDINT_H_INCLUDED
#define _PSTDINT_H_INCLUDED
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t)-1)
#endif
/*
* Deduce the type assignments from limits.h under the assumption that
* integer sizes in bits are powers of 2, and follow the ANSI
* definitions.
*/
#ifndef UINT8_MAX
# define UINT8_MAX 0xff
#endif
#if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks)
# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
typedef unsigned char uint8_t;
# define UINT8_C(v) ((uint8_t) v)
# else
# error "Platform not supported"
# endif
#endif
#ifndef INT8_MAX
# define INT8_MAX 0x7f
#endif
#ifndef INT8_MIN
# define INT8_MIN INT8_C(0x80)
#endif
#if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks)
# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
typedef signed char int8_t;
# define INT8_C(v) ((int8_t) v)
# else
# error "Platform not supported"
# endif
#endif
#ifndef UINT16_MAX
# define UINT16_MAX 0xffff
#endif
#if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks)
#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
typedef unsigned int uint16_t;
# ifndef PRINTF_INT16_MODIFIER
# define PRINTF_INT16_MODIFIER ""
# endif
# define UINT16_C(v) ((uint16_t) (v))
#elif (USHRT_MAX == UINT16_MAX)
typedef unsigned short uint16_t;
# define UINT16_C(v) ((uint16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
# define PRINTF_INT16_MODIFIER "h"
# endif
#else
#error "Platform not supported"
#endif
#endif
#ifndef INT16_MAX
# define INT16_MAX 0x7fff
#endif
#ifndef INT16_MIN
# define INT16_MIN INT16_C(0x8000)
#endif
#if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks)
#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
typedef signed int int16_t;
# define INT16_C(v) ((int16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
# define PRINTF_INT16_MODIFIER ""
# endif
#elif (SHRT_MAX == INT16_MAX)
typedef signed short int16_t;
# define INT16_C(v) ((int16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
# define PRINTF_INT16_MODIFIER "h"
# endif
#else
#error "Platform not supported"
#endif
#endif
#ifndef UINT32_MAX
# define UINT32_MAX (0xffffffffUL)
#endif
#if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks)
#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
typedef unsigned long uint32_t;
# define UINT32_C(v) v ## UL
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER "l"
# endif
#elif (UINT_MAX == UINT32_MAX)
typedef unsigned int uint32_t;
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER ""
# endif
# define UINT32_C(v) v ## U
#elif (USHRT_MAX == UINT32_MAX)
typedef unsigned short uint32_t;
# define UINT32_C(v) ((unsigned short) (v))
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER ""
# endif
#else
#error "Platform not supported"
#endif
#endif
#ifndef INT32_MAX
# define INT32_MAX (0x7fffffffL)
#endif
#ifndef INT32_MIN
# define INT32_MIN INT32_C(0x80000000)
#endif
#if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks)
#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
typedef signed long int32_t;
# define INT32_C(v) v ## L
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER "l"
# endif
#elif (INT_MAX == INT32_MAX)
typedef signed int int32_t;
# define INT32_C(v) v
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER ""
# endif
#elif (SHRT_MAX == INT32_MAX)
typedef signed short int32_t;
# define INT32_C(v) ((short) (v))
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER ""
# endif
#else
#error "Platform not supported"
#endif
#endif
/*
* The macro stdint_int64_defined is temporarily used to record
* whether or not 64 integer support is available. It must be
* defined for any 64 integer extensions for new platforms that are
* added.
*/
#undef stdint_int64_defined
#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
# define stdint_int64_defined
typedef long long int64_t;
typedef unsigned long long uint64_t;
# define UINT64_C(v) v ## ULL
# define INT64_C(v) v ## LL
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "ll"
# endif
# endif
#endif
#if !defined (stdint_int64_defined)
# if defined(__GNUC__) && !defined(vxWorks)
# define stdint_int64_defined
__extension__ typedef long long int64_t;
__extension__ typedef unsigned long long uint64_t;
# define UINT64_C(v) v ## ULL
# define INT64_C(v) v ## LL
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "ll"
# endif
# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
# define stdint_int64_defined
typedef long long int64_t;
typedef unsigned long long uint64_t;
# define UINT64_C(v) v ## ULL
# define INT64_C(v) v ## LL
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "ll"
# endif
# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
# define stdint_int64_defined
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
# define UINT64_C(v) v ## UI64
# define INT64_C(v) v ## I64
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "I64"
# endif
# endif
#endif
#if !defined (LONG_LONG_MAX) && defined (INT64_C)
# define LONG_LONG_MAX INT64_C (9223372036854775807)
#endif
#ifndef ULONG_LONG_MAX
# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
#endif
#if !defined (INT64_MAX) && defined (INT64_C)
# define INT64_MAX INT64_C (9223372036854775807)
#endif
#if !defined (INT64_MIN) && defined (INT64_C)
# define INT64_MIN INT64_C (-9223372036854775808)
#endif
#if !defined (UINT64_MAX) && defined (INT64_C)
# define UINT64_MAX UINT64_C (18446744073709551615)
#endif
/*
* Width of hexadecimal for number field.
*/
#ifndef PRINTF_INT64_HEX_WIDTH
# define PRINTF_INT64_HEX_WIDTH "16"
#endif
#ifndef PRINTF_INT32_HEX_WIDTH
# define PRINTF_INT32_HEX_WIDTH "8"
#endif
#ifndef PRINTF_INT16_HEX_WIDTH
# define PRINTF_INT16_HEX_WIDTH "4"
#endif
#ifndef PRINTF_INT8_HEX_WIDTH
# define PRINTF_INT8_HEX_WIDTH "2"
#endif
#ifndef PRINTF_INT64_DEC_WIDTH
# define PRINTF_INT64_DEC_WIDTH "19"
#endif
#ifndef PRINTF_INT32_DEC_WIDTH
# define PRINTF_INT32_DEC_WIDTH "10"
#endif
#ifndef PRINTF_INT16_DEC_WIDTH
# define PRINTF_INT16_DEC_WIDTH "5"
#endif
#ifndef PRINTF_INT8_DEC_WIDTH
# define PRINTF_INT8_DEC_WIDTH "3"
#endif
#ifndef PRINTF_UINT64_DEC_WIDTH
# define PRINTF_UINT64_DEC_WIDTH "20"
#endif
#ifndef PRINTF_UINT32_DEC_WIDTH
# define PRINTF_UINT32_DEC_WIDTH "10"
#endif
#ifndef PRINTF_UINT16_DEC_WIDTH
# define PRINTF_UINT16_DEC_WIDTH "5"
#endif
#ifndef PRINTF_UINT8_DEC_WIDTH
# define PRINTF_UINT8_DEC_WIDTH "3"
#endif
/*
* Ok, lets not worry about 128 bit integers for now. Moore's law says
* we don't need to worry about that until about 2040 at which point
* we'll have bigger things to worry about.
*/
#ifdef stdint_int64_defined
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
# define INTMAX_MAX INT64_MAX
# define INTMAX_MIN INT64_MIN
# define UINTMAX_MAX UINT64_MAX
# define UINTMAX_C(v) UINT64_C(v)
# define INTMAX_C(v) INT64_C(v)
# ifndef PRINTF_INTMAX_MODIFIER
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
# endif
#else
typedef int32_t intmax_t;
typedef uint32_t uintmax_t;
# define INTMAX_MAX INT32_MAX
# define UINTMAX_MAX UINT32_MAX
# define UINTMAX_C(v) UINT32_C(v)
# define INTMAX_C(v) INT32_C(v)
# ifndef PRINTF_INTMAX_MODIFIER
# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
# endif
#endif
/*
* Because this file currently only supports platforms which have
* precise powers of 2 as bit sizes for the default integers, the
* least definitions are all trivial. Its possible that a future
* version of this file could have different definitions.
*/
#ifndef stdint_least_defined
typedef int8_t int_least8_t;
typedef uint8_t uint_least8_t;
typedef int16_t int_least16_t;
typedef uint16_t uint_least16_t;
typedef int32_t int_least32_t;
typedef uint32_t uint_least32_t;
# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
# define UINT_LEAST8_MAX UINT8_MAX
# define INT_LEAST8_MAX INT8_MAX
# define UINT_LEAST16_MAX UINT16_MAX
# define INT_LEAST16_MAX INT16_MAX
# define UINT_LEAST32_MAX UINT32_MAX
# define INT_LEAST32_MAX INT32_MAX
# define INT_LEAST8_MIN INT8_MIN
# define INT_LEAST16_MIN INT16_MIN
# define INT_LEAST32_MIN INT32_MIN
# ifdef stdint_int64_defined
typedef int64_t int_least64_t;
typedef uint64_t uint_least64_t;
# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
# define UINT_LEAST64_MAX UINT64_MAX
# define INT_LEAST64_MAX INT64_MAX
# define INT_LEAST64_MIN INT64_MIN
# endif
#endif
#undef stdint_least_defined
/*
* The ANSI C committee has defined *int*_fast*_t types as well. This,
* of course, defies rationality -- you can't know what will be fast
* just from the type itself. Even for a given architecture, compatible
* implementations might have different performance characteristics.
* Developers are warned to stay away from these types when using this
* or any other stdint.h.
*/
typedef int_least8_t int_fast8_t;
typedef uint_least8_t uint_fast8_t;
typedef int_least16_t int_fast16_t;
typedef uint_least16_t uint_fast16_t;
typedef int_least32_t int_fast32_t;
typedef uint_least32_t uint_fast32_t;
#define UINT_FAST8_MAX UINT_LEAST8_MAX
#define INT_FAST8_MAX INT_LEAST8_MAX
#define UINT_FAST16_MAX UINT_LEAST16_MAX
#define INT_FAST16_MAX INT_LEAST16_MAX
#define UINT_FAST32_MAX UINT_LEAST32_MAX
#define INT_FAST32_MAX INT_LEAST32_MAX
#define INT_FAST8_MIN INT_LEAST8_MIN
#define INT_FAST16_MIN INT_LEAST16_MIN
#define INT_FAST32_MIN INT_LEAST32_MIN
#ifdef stdint_int64_defined
typedef int_least64_t int_fast64_t;
typedef uint_least64_t uint_fast64_t;
# define UINT_FAST64_MAX UINT_LEAST64_MAX
# define INT_FAST64_MAX INT_LEAST64_MAX
# define INT_FAST64_MIN INT_LEAST64_MIN
#endif
#undef stdint_int64_defined
/*
* Whatever piecemeal, per compiler thing we can do about the wchar_t
* type limits.
*/
#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks)
# include <wchar.h>
# ifndef WCHAR_MIN
# define WCHAR_MIN 0
# endif
# ifndef WCHAR_MAX
# define WCHAR_MAX ((wchar_t)-1)
# endif
#endif
/*
* Whatever piecemeal, per compiler/platform thing we can do about the
* (u)intptr_t types and limits.
*/
#if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T)
# define STDINT_H_UINTPTR_T_DEFINED
#endif
#ifndef STDINT_H_UINTPTR_T_DEFINED
# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__)
# define stdint_intptr_bits 64
# elif defined (__WATCOMC__) || defined (__TURBOC__)
# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
# define stdint_intptr_bits 16
# else
# define stdint_intptr_bits 32
# endif
# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__)
# define stdint_intptr_bits 32
# elif defined (__INTEL_COMPILER)
/* TODO -- what did Intel do about x86-64? */
# else
/* #error "This platform might not be supported yet" */
# endif
# ifdef stdint_intptr_bits
# define stdint_intptr_glue3_i(a,b,c) a##b##c
# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
# ifndef PRINTF_INTPTR_MODIFIER
# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
# endif
# ifndef PTRDIFF_MAX
# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
# endif
# ifndef PTRDIFF_MIN
# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
# endif
# ifndef UINTPTR_MAX
# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
# endif
# ifndef INTPTR_MAX
# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
# endif
# ifndef INTPTR_MIN
# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
# endif
# ifndef INTPTR_C
# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
# endif
# ifndef UINTPTR_C
# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
# endif
typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
# else
/* TODO -- This following is likely wrong for some platforms, and does
nothing for the definition of uintptr_t. */
typedef ptrdiff_t intptr_t;
# endif
# define STDINT_H_UINTPTR_T_DEFINED
#endif
/*
* Assumes sig_atomic_t is signed and we have a 2s complement machine.
*/
#ifndef SIG_ATOMIC_MAX
# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
#endif
#endif
#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
/*
* Please compile with the maximum warning settings to make sure macros are
* not defined more than once.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define glue3_aux(x,y,z) x ## y ## z
#define glue3(x,y,z) glue3_aux(x,y,z)
#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0);
#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0);
#define DECL(us,bits) glue3(DECL,us,) (bits)
#define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits)
#define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; }
#define X_SIZE_MAX ((size_t)-1)
int main () {
int err_n = 0;
int err_first = 0;
DECL(I,8)
DECL(U,8)
DECL(I,16)
DECL(U,16)
DECL(I,32)
DECL(U,32)
#ifdef INT64_MAX
DECL(I,64)
DECL(U,64)
#endif
intmax_t imax = INTMAX_C(0);
uintmax_t umax = UINTMAX_C(0);
char str0[256], str1[256];
sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647));
if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH));
sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295));
if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH));
#ifdef INT64_MAX
sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807));
if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1)));
sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591));
if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1)));
#endif
sprintf (str0, "%d %x\n", 0, ~0);
sprintf (str1, "%d %x\n", i8, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1));
sprintf (str1, "%u %x\n", u8, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1));
sprintf (str1, "%d %x\n", i16, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1));
sprintf (str1, "%u %x\n", u16, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1));
sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1));
sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1));
#ifdef INT64_MAX
sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1));
#endif
sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1));
sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1));
TESTUMAX(8);
TESTUMAX(16);
TESTUMAX(32);
#ifdef INT64_MAX
TESTUMAX(64);
#endif
#define STR(v) #v
#define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v));
if (err_n) {
printf ("pstdint.h is not correct. Please use sizes below to correct it:\n");
}
Q(int)
Q(unsigned)
Q(long int)
Q(short int)
Q(int8_t)
Q(int16_t)
Q(int32_t)
#ifdef INT64_MAX
Q(int64_t)
#endif
#if UINT_MAX < X_SIZE_MAX
printf ("UINT_MAX < X_SIZE_MAX\n");
#else
printf ("UINT_MAX >= X_SIZE_MAX\n");
#endif
printf ("%" PRINTF_INT64_MODIFIER "u vs %" PRINTF_INT64_MODIFIER "u\n", UINT_MAX, X_SIZE_MAX);
return EXIT_SUCCESS;
}
#endif
-39
View File
@@ -1,39 +0,0 @@
/*
* stdlib.h --
*
* Declares facilities exported by the "stdlib" portion of the C library.
* This file isn't complete in the ANSI-C sense; it only declares things
* that are needed by Tcl. This file is needed even on many systems with
* their own stdlib.h (e.g. SunOS) because not all stdlib.h files declare
* all the procedures needed here (such as strtol/strtoul).
*
* Copyright (c) 1991 The Regents of the University of California.
* Copyright (c) 1994-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _STDLIB
#define _STDLIB
extern void abort(void);
extern double atof(const char *string);
extern int atoi(const char *string);
extern long atol(const char *string);
extern void * calloc(unsigned long numElements, unsigned long size);
extern void exit(int status);
extern void free(void *blockPtr);
extern char * getenv(const char *name);
extern void * malloc(unsigned long numBytes);
extern void qsort(void *base, unsigned long n, unsigned long size, int (*compar)(
const void *element1, const void *element2));
extern void * realloc(void *ptr, unsigned long numBytes);
extern char * realpath(const char *path, char *resolved_path);
extern int mkstemps(char *templ, int suffixlen);
extern int mkstemp(char *templ);
extern char * mkdtemp(char *templ);
extern long strtol(const char *string, char **endPtr, int base);
extern unsigned long strtoul(const char *string, char **endPtr, int base);
#endif /* _STDLIB */
-70
View File
@@ -1,70 +0,0 @@
/*
* strstr.c --
*
* Source code for the "strstr" library routine.
*
* Copyright (c) 1988-1993 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tcl.h"
#ifndef NULL
#define NULL 0
#endif
/*
*----------------------------------------------------------------------
*
* strstr --
*
* Locate the first instance of a substring in a string.
*
* Results:
* If string contains substring, the return value is the location of the
* first matching instance of substring in string. If string doesn't
* contain substring, the return value is 0. Matching is done on an exact
* character-for-character basis with no wildcards or special characters.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
char *
strstr(
const char *string, /* String to search. */
const char *substring) /* Substring to try to find in string. */
{
const char *a, *b;
/*
* First scan quickly through the two strings looking for a
* single-character match. When it's found, then compare the rest of the
* substring.
*/
b = substring;
if (*b == 0) {
return (char *)string;
}
for ( ; *string != 0; string += 1) {
if (*string != *b) {
continue;
}
a = string;
while (1) {
if (*b == 0) {
return (char *)string;
}
if (*a++ != *b++) {
break;
}
}
b = substring;
}
return NULL;
}
-77
View File
@@ -1,77 +0,0 @@
/*
* strtol.c --
*
* Source code for the "strtol" library procedure.
*
* Copyright (c) 1988 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tclInt.h"
/*
*----------------------------------------------------------------------
*
* strtol --
*
* Convert an ASCII string into an integer.
*
* Results:
* The return value is the integer equivalent of string. If endPtr is
* non-NULL, then *endPtr is filled in with the character after the last
* one that was part of the integer. If string doesn't contain a valid
* integer value, then zero is returned and *endPtr is set to string.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
long int
strtol(
const char *string, /* String of ASCII digits, possibly preceded
* by white space. For bases greater than 10,
* either lower- or upper-case digits may be
* used. */
char **endPtr, /* Where to store address of terminating
* character, or NULL. */
int base) /* Base for conversion. Must be less than 37.
* If 0, then the base is chosen from the
* leading characters of string: "0x" means
* hex, "0" means octal, anything else means
* decimal. */
{
const char *p;
long result;
/*
* Skip any leading blanks.
*/
p = string;
while (isspace(UCHAR(*p))) {
p += 1;
}
/*
* Check for a sign.
*/
if (*p == '-') {
p += 1;
result = -(strtoul(p, endPtr, base));
} else {
if (*p == '+') {
p += 1;
}
result = strtoul(p, endPtr, base);
}
if ((result == 0) && (endPtr != 0) && (*endPtr == p)) {
*endPtr = (char *) string;
}
return result;
}
-214
View File
@@ -1,214 +0,0 @@
/*
* strtoul.c --
*
* Source code for the "strtoul" library procedure.
*
* Copyright (c) 1988 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tclInt.h"
/*
* The table below is used to convert from ASCII digits to a numerical
* equivalent. It maps from '0' through 'z' to integers (100 for non-digit
* characters).
*/
static const char cvtIn[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* '0' - '9' */
100, 100, 100, 100, 100, 100, 100, /* punctuation */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 'A' - 'Z' */
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35,
100, 100, 100, 100, 100, 100, /* punctuation */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 'a' - 'z' */
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35};
/*
*----------------------------------------------------------------------
*
* strtoul --
*
* Convert an ASCII string into an integer.
*
* Results:
* The return value is the integer equivalent of string. If endPtr is
* non-NULL, then *endPtr is filled in with the character after the last
* one that was part of the integer. If string doesn't contain a valid
* integer value, then zero is returned and *endPtr is set to string.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
unsigned long int
strtoul(
const char *string, /* String of ASCII digits, possibly preceded
* by white space. For bases greater than 10,
* either lower- or upper-case digits may be
* used. */
char **endPtr, /* Where to store address of terminating
* character, or NULL. */
int base) /* Base for conversion. Must be less than 37.
* If 0, then the base is chosen from the
* leading characters of string: "0x" means
* hex, "0" means octal, anything else means
* decimal. */
{
const char *p;
unsigned long int result = 0;
unsigned digit;
int anyDigits = 0;
int negative=0;
int overflow=0;
/*
* Skip any leading blanks.
*/
p = string;
while (isspace(UCHAR(*p))) {
p += 1;
}
if (*p == '-') {
negative = 1;
p += 1;
} else {
if (*p == '+') {
p += 1;
}
}
/*
* If no base was provided, pick one from the leading characters of the
* string.
*/
if (base == 0) {
if (*p == '0') {
p += 1;
if ((*p == 'x') || (*p == 'X')) {
p += 1;
base = 16;
} else {
/*
* Must set anyDigits here, otherwise "0" produces a "no
* digits" error.
*/
anyDigits = 1;
base = 8;
}
} else {
base = 10;
}
} else if (base == 16) {
/*
* Skip a leading "0x" from hex numbers.
*/
if ((p[0] == '0') && ((p[1] == 'x') || (p[1] == 'X'))) {
p += 2;
}
}
/*
* Sorry this code is so messy, but speed seems important. Do different
* things for base 8, 10, 16, and other.
*/
if (base == 8) {
unsigned long maxres = ULONG_MAX >> 3;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > 7) {
break;
}
if (result > maxres) { overflow = 1; }
result = (result << 3);
if (digit > (ULONG_MAX - result)) { overflow = 1; }
result += digit;
anyDigits = 1;
}
} else if (base == 10) {
unsigned long maxres = ULONG_MAX / 10;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > 9) {
break;
}
if (result > maxres) { overflow = 1; }
result *= 10;
if (digit > (ULONG_MAX - result)) { overflow = 1; }
result += digit;
anyDigits = 1;
}
} else if (base == 16) {
unsigned long maxres = ULONG_MAX >> 4;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
break;
}
digit = cvtIn[digit];
if (digit > 15) {
break;
}
if (result > maxres) { overflow = 1; }
result = (result << 4);
if (digit > (ULONG_MAX - result)) { overflow = 1; }
result += digit;
anyDigits = 1;
}
} else if (base >= 2 && base <= 36) {
unsigned long maxres = ULONG_MAX / base;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
break;
}
digit = cvtIn[digit];
if (digit >= ( (unsigned) base )) {
break;
}
if (result > maxres) { overflow = 1; }
result *= base;
if (digit > (ULONG_MAX - result)) { overflow = 1; }
result += digit;
anyDigits = 1;
}
}
/*
* See if there were any digits at all.
*/
if (!anyDigits) {
p = string;
}
if (endPtr != 0) {
/* unsafe, but required by the strtoul prototype */
*endPtr = (char *) p;
}
if (overflow) {
errno = ERANGE;
return ULONG_MAX;
}
if (negative) {
return -result;
}
return result;
}
+5 -1
View File
@@ -156,7 +156,11 @@ waitpid(
goto waitAgain;
}
}
waitPtr = (WaitInfo *) Tcl_Alloc(sizeof(WaitInfo));
waitPtr = (WaitInfo *) Tcl_AttemptAlloc(sizeof(WaitInfo));
if (!waitPtr) {
errno = ENOMEM;
return -1;
}
waitPtr->pid = result;
waitPtr->status = status;
waitPtr->nextPtr = deadList;
-3
View File
@@ -67,9 +67,6 @@ 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 va_list argList in
An argument list which must have been initialized using
\fBva_start\fR, and cleared using \fBva_end\fR.
.AP int lineNum
The line number of a script where an error occurred.
.AP "const char" *script in
+1 -1
View File
@@ -32,7 +32,7 @@ void
\fBTcl_GetMemoryInfo\fR(\fIdsPtr\fR)
.SH ARGUMENTS
.AS char *size
.AP "unsigned int" size in
.AP "size_t" size in
Size in bytes of the memory block to allocate.
.AP char *ptr in
Pointer to memory block to free or realloc.
+1 -1
View File
@@ -187,7 +187,7 @@ except its \fIproc2\fR argument is of type \fBTcl_ObjCmdProc2\fR.
typedef int \fBTcl_ObjCmdProc2\fR(
void *\fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
ptrdiff_t \fIobjc\fR,
Tcl_Size \fIobjc\fR,
Tcl_Obj *const \fIobjv\fR[]);
.CE
.PP
+2 -2
View File
@@ -88,10 +88,10 @@ typedef int \fBTcl_CmdObjTraceProc\fR(
typedef int \fBTcl_CmdObjTraceProc2\fR(
\fBvoid *\fR \fIclientData\fR,
\fBTcl_Interp\fR* \fIinterp\fR,
ptrdiff_t \fIlevel\fR,
Tcl_Size \fIlevel\fR,
const char *\fIcommand\fR,
\fBTcl_Command\fR \fIcommandToken\fR,
ptrdiff_t \fIobjc\fR,
Tcl_Size \fIobjc\fR,
\fBTcl_Obj\fR *const \fIobjv\fR[]);
.CE
.PP
+1 -1
View File
@@ -9,7 +9,7 @@
.so man.macros
.BS
.SH NAME
Tcl_DStringInit, Tcl_DStringAppend, Tcl_DStringAppendElement, Tcl_DStringStartSublist, Tcl_DStringEndSublist, Tcl_DStringLength, Tcl_DStringValue, Tcl_DStringSetLength, Tcl_DStringFree, Tcl_DStringResult, Tcl_DStringGetResult \- manipulate dynamic strings
Tcl_DStringInit, Tcl_DStringAppend, Tcl_DStringAppendElement, Tcl_DStringStartSublist, Tcl_DStringEndSublist, Tcl_DStringLength, Tcl_DStringValue, Tcl_DStringSetLength, Tcl_DStringFree, Tcl_DStringResult, Tcl_DStringGetResult, Tcl_DStringToObj \- manipulate dynamic strings
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
+14 -15
View File
@@ -218,17 +218,16 @@ used. The return value is a pointer to the value stored in the DString.
be used to specify the profile to be used for the transform. The
\fBTCL_ENCODING_START\fR and \fBTCL_ENCODING_END\fR bits in \fBflags\fR are
ignored as the function assumes the entire source string to be decoded is passed
into the function. On success, the function returns \fBTCL_ERROR\fR with the
converted string stored in \fB*dstPtr\fR. For errors other than conversion
errors, such as invalid flags, the function returns \fBTCL_OK\fR with an error
into the function. On success, the function returns \fBTCL_OK\fR with the
converted string stored in \fB*dstPtr\fR. For errors \fIother than conversion
errors\fR, such as invalid flags, the function returns \fBTCL_ERROR\fR with an error
message in \fBinterp\fR if it is not NULL.
.PP
For conversion errors, \fBTcl_ExternalToUtfDStringEx\fR returns one
of the \fBTCL_CONVERT_*\fR errors listed below for \fBTcl_ExternalToUtf\fR.
When one of these conversion errors is returned, an error message is
stored in \fBinterp\fR only if \fBerrorIdxPtr\fR is NULL. Otherwise, no error message
is stored as the function expects the caller is interested whatever is
decoded to that point and not treating this as an immediate error condition.
is stored as the function expects the caller is interested the decoded data
up to that point and not treating this as an immediate error condition.
The index of the error location is stored in \fB*errorIdxPtr\fR.
.PP
The caller must call \fBTcl_DStringFree\fR to free up the \fB*dstPtr\fR resources
@@ -547,13 +546,13 @@ encoding:
E
init {}
final {}
iso8859-1 \ex1b(B
jis0201 \ex1b(J
jis0208 \ex1b$@
jis0208 \ex1b$B
jis0212 \ex1b$(D
gb2312 \ex1b$A
ksc5601 \ex1b$(C
iso8859-1 \ex1B(B
jis0201 \ex1B(J
jis0208 \ex1B$@
jis0208 \ex1B$B
jis0212 \ex1B$(D
gb2312 \ex1B$A
ksc5601 \ex1B$(C
.CE
.PP
In the file, the first column represents an option and the second column
@@ -565,7 +564,7 @@ marks that encoding. Tcl syntax is used for the values; in the above
example, for instance,
.QW \fB{}\fR
represents the empty string and
.QW \fB\ex1b\fR
.QW \fB\ex1B\fR
represents character 27.
.PP
When \fBTcl_GetEncoding\fR encounters an encoding \fIname\fR that has not
@@ -590,7 +589,7 @@ with at most one of \fBTCL_ENCODING_PROFILE_TCL8\fR,
\fBTCL_ENCODING_PROFILE_STRICT\fR or \fBTCL_ENCODING_PROFILE_REPLACE\fR.
These correspond to the \fBtcl8\fR, \fBstrict\fR and \fBreplace\fR profiles
respectively. If none are specified, a version-dependent default profile is used.
For Tcl 8.7, the default profile is \fBtcl8\fR.
For Tcl 9.0, the default profile is \fBtcl8\fR.
.PP
For details about profiles, see the \fBPROFILES\fR section in
the documentation of the \fBencoding\fR command.
+1 -1
View File
@@ -133,7 +133,7 @@ is true.
.PP
\fBTcl_Import\fR imports commands matching a pattern into a
namespace. Note that the pattern must include the name of the
namespace to import from. This function returns an error if
namespace to import from. This function returns TCL_ERROR if
an attempt to import a command over an existing command is made,
unless the \fIallowOverwrite\fR flag has been set.
.PP
+46 -25
View File
@@ -23,6 +23,8 @@ Tcl_Obj *
.sp
\fBTcl_DecrRefCount\fR(\fIobjPtr\fR)
.sp
\fBTcl_BounceRefCount\fR(\fIobjPtr\fR)
.sp
int
\fBTcl_IsShared\fR(\fIobjPtr\fR)
.sp
@@ -278,26 +280,27 @@ The string representation is now \fB124\fR
and both representations are again valid.
.SH "STORAGE MANAGEMENT OF VALUES"
.PP
Tcl values are allocated on the heap and are shared as much as possible
to reduce storage requirements.
Reference counting is used to determine when a value is
no longer needed and can safely be freed.
A value just created by \fBTcl_NewObj\fR or \fBTcl_NewStringObj\fR
has \fIrefCount\fR 0, meaning that the object can often be given to a function
like \fBTcl_SetObjResult\fR, \fBTcl_ListObjAppendElement\fR, or
\fBTcl_DictObjPut\fR (as a value) without explicit reference management, all
of which are common use cases. (The latter two require that the the target
list or dictionary be well-formed, but that is often easy to arrange when the
value is being initially constructed.)
The macro \fBTcl_IncrRefCount\fR increments the reference count
when a new reference to the value is created.
The macro \fBTcl_DecrRefCount\fR decrements the count
when a reference is no longer needed and,
if the value's reference count drops to zero, frees its storage.
Tcl values are allocated on the heap and are shared as much as
possible to reduce storage requirements. Reference counting is used
to determine when a value is no longer needed and can safely be freed.
A value just created by \fBTcl_NewObj\fR, \fBTcl_NewStringObj\fR, or
any Abstract List command or function, has \fIrefCount\fR 0, meaning
that the object can often be given to a function like
\fBTcl_SetObjResult\fR, \fBTcl_ListObjAppendElement\fR, or
\fBTcl_DictObjPut\fR (as a value) without explicit reference
management, all of which are common use cases. (The latter two require
that the target list or dictionary be well-formed, but that is
often easy to arrange when the value is being initially constructed.)
The macro \fBTcl_IncrRefCount\fR increments the reference count when a
new reference to the value is created.
The macro \fBTcl_DecrRefCount\fR decrements the count when a reference is no longer needed.
If the value's reference count drops to zero, frees
its storage.
The macro \fBTcl_BounceRefCount\fR will check if the value has no references (i.e. in a "new" state) and free the value.
A value shared by different code or data structures has
\fIrefCount\fR greater than 1.
Incrementing a value's reference count ensures that
it will not be freed too early or have its value change accidentally.
\fIrefCount\fR greater than 1. Incrementing a value's reference count
ensures that it will not be freed too early or have its value change
accidentally.
.PP
As an example, the bytecode interpreter shares argument values
between calling and called Tcl procedures to avoid having to copy values.
@@ -311,12 +314,25 @@ the interpreter calls \fBTcl_DecrRefCount\fR to decrement
each argument's reference count.
When a value's reference count drops less than or equal to zero,
\fBTcl_DecrRefCount\fR reclaims its storage.
Most command procedures do not have to be concerned about
reference counting since they use a value's value immediately
and do not retain a pointer to the value after they return.
However, if they do retain a pointer to a value in a data structure,
they must be careful to increment its reference count
since the retained pointer is a new reference.
.PP
Most command procedures have not been concerned about reference
counting since they use a value's value immediately and do not retain
a pointer to the value after they return. However, there are some
procedures that may return a new value, with a refCount of 0. In this
situation, it is the caller's responsibility to free the value before
the procedure returns. One way to cover this is to always call
\fBTcl_IncrRefCount\fR before using the value, then call
\fBTcl_DecrRefCount\fR before returning. The other way is to use
\fBTcl_BounceRefCount\fR after the value is no longer needed or
referenced. This macro will free the value if there are no other
references to the value. When retaining a pointer to a value in a data
structure the procedure must be careful to increment its reference
count since the retained pointer is a new reference. Examples of
procedures that return new values are \fBTcl_NewIntObj\fR, and
commands like \fBlseq\fR, which creates an Abstract List, and an
lindex on this list may return a new Obj with a refCount of 0.
.PP
Command procedures that directly modify values
such as those for \fBlappend\fR and \fBlinsert\fR must be careful to
@@ -350,6 +366,11 @@ must check whether the variable's value is shared before
incrementing the integer in its internal representation.
If it is shared, it needs to duplicate the value
in order to avoid accidentally changing values in other data structures.
.PP
In cases where a value is obtained, used, and not retained, the value
can be freed using \fBTcl_BounceRefCount\fR. This
is functionally equivalent to calling \fBTcl_IncrRefCount\fR followed
\fBTcl_DecrRefCount\fR.
.SH "SEE ALSO"
Tcl_ConvertToType(3), Tcl_GetIntFromObj(3), Tcl_ListObjAppendElement(3), Tcl_ListObjIndex(3), Tcl_ListObjReplace(3), Tcl_RegisterObjType(3)
.SH KEYWORDS
+164 -12
View File
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.TH Tcl_ObjType 3 8.0 Tcl "Tcl Library Procedures"
.TH Tcl_ObjType 3 9.0 Tcl "Tcl Library Procedures"
.so man.macros
.BS
.SH NAME
@@ -93,14 +93,13 @@ free to set the internal representation for \fIobjPtr\fR to make
use of another related Tcl_ObjType, if it sees fit.
.SH "THE TCL_OBJTYPE STRUCTURE"
.PP
Extension writers can define new value types by defining four
procedures and
initializing a Tcl_ObjType structure to describe the type.
Extension writers may also pass a pointer to their Tcl_ObjType
structure to \fBTcl_RegisterObjType\fR if they wish to permit
other extensions to look up their Tcl_ObjType by name with
the \fBTcl_GetObjType\fR routine.
The \fBTcl_ObjType\fR structure is defined as follows:
Extension writers can define new value types by defining four to eight
procedures and initializing a Tcl_ObjType structure to describe the
type. Extension writers may also pass a pointer to their Tcl_ObjType
structure to \fBTcl_RegisterObjType\fR if they wish to permit other
extensions to look up their Tcl_ObjType by name with the
\fBTcl_GetObjType\fR routine. The \fBTcl_ObjType\fR structure is
defined as follows:
.PP
.CS
typedef struct Tcl_ObjType {
@@ -110,6 +109,16 @@ typedef struct Tcl_ObjType {
Tcl_UpdateStringProc *\fIupdateStringProc\fR;
Tcl_SetFromAnyProc *\fIsetFromAnyProc\fR;
size_t \fIversion\fR;
/* List emulation functions - ObjType Version 1 & 2 */
Tcl_ObjTypeLengthProc *lengthProc;
/* List emulation functions - ObjType Version 2 */
Tcl_ObjTypeIndexProc *\fIindexProc\fR;
Tcl_ObjTypeSliceProc *\fIsliceProc\fR;
Tcl_ObjTypeReverseProc *\fIreverseProc\fR;
Tcl_ObjTypeGetElements *\fIgetElementsProc\fR;
Tcl_ObjTypeSetElement *\fIsetElementProc\fR;
Tcl_ObjTypeReplaceProc *\fIreplaceProc\fR;
Tcl_ObjTypeInOperatorProc *\fIinOperProc\fR;
} \fBTcl_ObjType\fR;
.CE
.SS "THE NAME FIELD"
@@ -206,6 +215,7 @@ The \fIdupIntRepProc\fR member contains the address of a function
called to copy an internal representation from one value to another.
.PP
.CS
typedef void \fBTcl_DupInternalRepProc\fR(
Tcl_Obj *\fIsrcPtr\fR,
Tcl_Obj *\fIdupPtr\fR);
@@ -229,6 +239,7 @@ The \fIfreeIntRepProc\fR member contains the address of a function
that is called when a value is freed.
.PP
.CS
typedef void \fBTcl_FreeInternalRepProc\fR(
Tcl_Obj *\fIobjPtr\fR);
.CE
@@ -256,8 +267,149 @@ immediately, in order to limit stack usage. However, the value will be freed
before the outermost current \fBTcl_DecrRefCount\fR returns.
.SS "THE VERSION FIELD"
.PP
The \fIversion\fR member provides for future extensibility of the structure
and should be set to \fITCL_OBJTYPE_V0\fR.
The \fIversion\fR member provides for future extensibility of the
structure and should be set to \fBTCL_OBJTYPE_V0\fR for compatability
of ObjType definitions prior to version 9.0. Specifics about versions
will be described further in the sections below.
.SH "ABSTRACT LIST TYPES"
.PP
Additional fields in the Tcl_ObjType descriptor allow for control over
how custom data values can be manipulated using Tcl's List commands
without converting the value to a List type. This requires the custom
type to provide functions that will perform the given operation on the
custom data representation. Not all functions are required. In the
absence of a particular function (set to NULL), the fallback is to
allow the internal List operation to perform the operation, most
likely causing the value type to be converted to a traditional list.
.SS "SCALAR VALUE TYPES"
.PP
For a custom value type that is scalar or atomic in nature, i.e., not
a divisible collection, version \fBTCL_OBJTYPE_V1\fR is
recommended. In this case, List commands will treat the scalar value
as if it where a list of length 1, and not convert the value to a List
type.
.SS "VERSION 2: ABSTRACT LISTS"
.PP
Version 2, \fBTCL_OBJTYPE_V2\fR, allows full List support when the
functions described below are provided. This allows for script level
use of the List commands without causing the type of the Tcl_Obj value
to be converted to a list.
.SS "THE LENGTHPROC FIELD"
.PP
The \fBLengthProc\fR function correlates with the \fBTcl_ListObjLength\fR
C API. The function returns the number of elements in the list. It
is used in every List operation and is required for all Abstract List
implementations.
.CS
typedef Tcl_Size
(Tcl_ObjTypeLengthProc) (Tcl_Obj *listPtr);
.CE
.PP
.SS "THE INDEXPROC FIELD"
.PP
The \fBIndexProc\fR function correlates with with the
\fBTcl_ListObjIndex\fR C API. The function returns a Tcl_Obj value for
the element at the specified index.
.CS
typedef int
(Tcl_ObjTypeIndexProc) (
Tcl_Interp *interp,
Tcl_Obj *listPtr,
Tcl_Size index,
Tcl_Obj** elemObj);
.CE
.SS "THE SLICEPROC FIELD"
.PP
The \fBSliceProc\fR correlates with the \fBlrange\fR command,
returning a new List or Abstract List for the portion of the original
list specifed.
.CS
typedef int
(Tcl_ObjTypeSliceProc) (
Tcl_Interp *interp,
Tcl_Obj *listPtr,
Tcl_Size fromIdx,
Tcl_Size toIdx,
Tcl_Obj **newObjPtr);
.CE
.SS "THE REVERSEPROC FIELD"
.PP
The \fBReverseProc\fR correlates with the \fBlreverse\fR command,
returning a List or Abstract List that has the same elements as the
input Abstract List, with the elements in the reverse order.
.CS
typedef int
(Tcl_ObjTypeReverseProc) (
Tcl_Interp *interp,
Tcl_Obj *listPtr,
Tcl_Obj **newObjPtr);
.CE
.SS "THE GETELEMENTS FIELD"
.PP
The \fBGetElements\fR function returns a count and a pointer to an
array of Tcl_Obj values for the entire Abstract List. This is a
correlary to the \fBTcl_ListObjGetElements\fR C API call.
.CS
typedef int
(Tcl_ObjTypeGetElements) (
Tcl_Interp *interp,
Tcl_Obj *listPtr,
Tcl_Size *objcptr,
Tcl_Obj ***objvptr);
.CE
.SS "THE SETELEMENT FIELD"
.PP
The \fBSetElement\fR function replaces the element within the
specified list at the give index. This function correlates to the
\fBlset\fR command.
.CS
typedef Tcl_Obj*
Tcl_ObjTypeSetElement) (
Tcl_Interp *interp,
Tcl_Obj *listPtr,
Tcl_Size indexCount,
Tcl_Obj *const indexArray[],
Tcl_Obj *valueObj);
.CE
.SS "REPLACEPROC FIELD"
.PP
The \fBReplaceProc\fR returns a new list after modfying the list
replacing the elements to be deleted, and adding the elements to be
inserted. This function correlates to the \fBTcl_ListObjReplace\fR C API.
.CS
typedef int
(Tcl_ObjTypeReplaceProc) (
Tcl_Interp *interp,
Tcl_Obj *listObj,
Tcl_Size first,
Tcl_Size numToDelete,
Tcl_Size numToInsert,
Tcl_Obj *const insertObjs[]);
.CE
.SS "THE INOPERATORPROC FIELD"
.PP
The \fBInOperProc\fR function determines whether the value is present in the
given list, according to equivalent string comparison of elements. The
\fBboolResult\fR is set to 1 (true) if the value is present, and 0
(false) if it is not present. This function implements the "in" and
"ni" math operators for an abstract list.
.CS
typedef int
(Tcl_ObjTypeInOperatorProc) (
Tcl_Interp *interp,
Tcl_Obj *valueObj,
Tcl_Obj *listObj,
int *boolResult);
.CE
.SH "REFERENCE COUNT MANAGEMENT"
.PP
The \fIobjPtr\fR argument to \fBTcl_AppendAllObjTypes\fR should be an unshared
@@ -276,6 +428,6 @@ modify the reference count of their arguments, but if the values contain
subsidiary values (e.g., the elements of a list or the keys of a dictionary)
then those subsidiary values may have their reference counts modified.
.SH "SEE ALSO"
Tcl_NewObj(3), Tcl_DecrRefCount(3), Tcl_IncrRefCount(3)
Tcl_NewObj(3), Tcl_DecrRefCount(3), Tcl_IncrRefCount(3), Tcl_BounceRefCount(3)
.SH KEYWORDS
internal representation, value, value type, string representation, type conversion
+7 -5
View File
@@ -406,8 +406,10 @@ 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.
return value is -1 and \fBTcl_ReadChars\fR records a POSIX error
code that can be retrieved with \fBTcl_GetErrno\fR. If an encoding error happens
while the channel is in blocking mode with -profile strict, the characters
retrieved until the encoding error happened will be stored in \fIreadObjPtr\fR.
.PP
Setting \fIcharsToRead\fR to -1 will cause the command to read
all characters currently available (non-blocking) or everything until
@@ -416,9 +418,9 @@ eof (blocking mode).
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
available: \fBTcl_ReadChars\fR returns a short count rather than waiting
for more data.
a short read can also occur if an encoding error is encountered (with -profile
strict) or if there is not enough input currently available:
\fBTcl_ReadChars\fR returns a short count rather than waiting for more data.
.PP
If the channel is in blocking mode, a return value of zero indicates an
end-of-file condition. If the channel is in nonblocking mode, a return
-4
View File
@@ -27,10 +27,6 @@ void
A printf-style format string.
.AP "" arg in
Arguments matching the format string.
.AP va_list argList in
An argument list of arguments matching the format string.
Must have been initialized using \fBva_start\fR,
and cleared using \fBva_end\fR.
.AP Tcl_PanicProc *panicProc in
Procedure to report fatal error message and abort.
.BE
-3
View File
@@ -45,9 +45,6 @@ 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 va_list argList in
An argument list which must have been initialized using
\fBva_start\fR, and cleared using \fBva_end\fR.
.AP Tcl_Interp *sourceInterp in
The interpreter to transfer the result and return options from.
.AP Tcl_Interp *targetInterp in
+1 -4
View File
@@ -115,7 +115,7 @@ 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.
A pointer to a value to read, or to an unshared value to modify.
.AP Tcl_Obj *appendObjPtr in
The value to append to \fIobjPtr\fR in \fBTcl_AppendObjToObj\fR.
.AP "Tcl_Size \&| int" *lengthPtr out
@@ -123,9 +123,6 @@ 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 va_list argList in
An argument list which must have been initialized using
\fBva_start\fR, and cleared using \fBva_end\fR.
.AP Tcl_Size limit in
Maximum number of bytes to be appended.
.AP "const char" *ellipsis in
+1 -1
View File
@@ -188,7 +188,7 @@ is used to initialize the compression engine rather than leaving it to create
it on the fly from the data being compressed. Setting a compression dictionary
allows for more efficient compression in the case where the start of the data
is highly regular, but it does require both the compressor and the
decompressor to agreee on the value to use. Compression dictionaries are only
decompressor to agree on the value to use. Compression dictionaries are only
fully supported for zlib-format data; on compression, they must be set before
any data is sent in with \fBTcl_ZlibStreamPut\fR, and on decompression they
should be set when \fBTcl_ZlibStreamGet\fR produces an \fBerror\fR with its
+1 -1
View File
@@ -69,7 +69,7 @@ This procedure will act as the \fBmain()\fR of the newly created
thread. The specified \fIclientData\fR will be its sole argument.
.AP void *clientData in
Arbitrary information. Passed as sole argument to the \fIproc\fR.
.AP int stackSize in
.AP size_t stackSize in
The size of the stack given to the new thread.
.AP int flags in
Bitmask containing flags allowing the caller to modify behavior of
+56 -50
View File
@@ -8,7 +8,7 @@
.so man.macros
.BS
.SH NAME
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
Tcl_UniChar, Tcl_UniCharToUtf, Tcl_UtfToUniChar, Tcl_UtfToChar16, Tcl_UtfToWChar, Tcl_UniCharToUtfDString, Tcl_UtfToUniCharDString, Tcl_Char16ToUtfDString, Tcl_UtfToWCharDString, Tcl_UtfToChar16DString, Tcl_WCharToUtfDString, 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
@@ -28,28 +28,28 @@ Tcl_Size
\fBTcl_UtfToWChar\fR(\fIsrc, wPtr\fR)
.sp
char *
\fBTcl_UniCharToUtfDString\fR(\fIuniStr, uniLength, dsPtr\fR)
\fBTcl_UniCharToUtfDString\fR(\fIuniStr, numUniChars, dsPtr\fR)
.sp
char *
\fBTcl_Char16ToUtfDString\fR(\fIuStr, uniLength, dsPtr\fR)
\fBTcl_Char16ToUtfDString\fR(\fIutf16, numUtf16, dsPtr\fR)
.sp
char *
\fBTcl_WCharToUtfDString\fR(\fIwStr, uniLength, dsPtr\fR)
\fBTcl_WCharToUtfDString\fR(\fIwcharStr, numWChars, dsPtr\fR)
.sp
Tcl_UniChar *
\fBTcl_UtfToUniCharDString\fR(\fIsrc, length, dsPtr\fR)
\fBTcl_UtfToUniCharDString\fR(\fIsrc, numBytes, dsPtr\fR)
.sp
unsigned short *
\fBTcl_UtfToChar16DString\fR(\fIsrc, length, dsPtr\fR)
\fBTcl_UtfToChar16DString\fR(\fIsrc, numBytes, dsPtr\fR)
.sp
wchar_t *
\fBTcl_UtfToWCharDString\fR(\fIsrc, length, dsPtr\fR)
\fBTcl_UtfToWCharDString\fR(\fIsrc, numBytes, dsPtr\fR)
.sp
int
\fBTcl_Char16Len\fR(\fIuniStr\fR)
\fBTcl_Char16Len\fR(\fIutf16\fR)
.sp
int
\fBTcl_WCharLen\fR(\fIuniStr\fR)
\fBTcl_WCharLen\fR(\fIwcharStr\fR)
.sp
int
\fBTcl_UniCharLen\fR(\fIuniStr\fR)
@@ -70,10 +70,10 @@ int
\fBTcl_UtfNcasecmp\fR(\fIcs, ct, length\fR)
.sp
int
\fBTcl_UtfCharComplete\fR(\fIsrc, length\fR)
\fBTcl_UtfCharComplete\fR(\fIsrc, numBytes\fR)
.sp
int
\fBTcl_NumUtfChars\fR(\fIsrc, length\fR)
\fBTcl_NumUtfChars\fR(\fIsrc, numBytes\fR)
.sp
const char *
\fBTcl_UtfFindFirst\fR(\fIsrc, ch\fR)
@@ -115,28 +115,32 @@ Pointer to a UTF-8 string.
.AP "const char" *ct in
Pointer to a UTF-8 string.
.AP "const Tcl_UniChar" *uniStr in
A null-terminated Unicode string.
A sequence of \fBTcl_UniChar\fR units with null-termination optional
depending on function.
.AP "const Tcl_UniChar" *ucs in
A null-terminated Unicode string.
A null-terminated sequence of \fBTcl_UniChar\fR.
.AP "const Tcl_UniChar" *uct in
A null-terminated Unicode string.
A null-terminated sequence of \fBTcl_UniChar\fR.
.AP "const Tcl_UniChar" *uniPattern in
A null-terminated Unicode string.
.AP "const unsigned short" *uStr in
A null-terminated UTF-16 string.
.AP "const wchar_t" *wStr in
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.
A null-terminated sequence of \fBTcl_UniChar\fR.
.AP "const unsigned short" *utf16 in
A sequence of UTF-16 units with null-termination optional
depending on function.
.AP "const wchar_t" *wcharStr in
A sequence of \fBwchar_t\fR units with null-termination optional
depending on function.
.AP int numBytes in
The length of the UTF-8 input in bytes. If
negative, the length includes all bytes until the first null byte.
.AP int numUtf16 in
The length of the input in UTF-16 units.
If negative, the length includes all bytes until the first null.
.AP int numUniChars in
The length of the input in Tcl_UniChar units.
If negative, the length includes all bytes until the first null.
.AP int numWChars in
The length of the input in wchar_t units.
If negative, the length includes all bytes until the first null.
.AP "Tcl_DString" *dsPtr in/out
A pointer to a previously initialized \fBTcl_DString\fR.
.AP "const char" *start in
@@ -186,30 +190,32 @@ not in proper UTF-8 format, \fBTcl_UtfToUniChar\fR will store the first
byte of \fIsrc\fR in \fI*chPtr\fR as a Tcl_UniChar between 0x00A0 and
0x00FF and return 1.
.PP
\fBTcl_UniCharToUtfDString\fR converts the given Unicode string
to UTF-8, storing the result in a previously initialized \fBTcl_DString\fR.
The return value is a pointer to the UTF-8 representation of the
Unicode string. Storage for the return value is appended to the
end of the \fBTcl_DString\fR.
\fBTcl_UniCharToUtfDString\fR converts the input in the form of a
sequence of \fBTcl_UniChar\fR code points to UTF-8, appending the result to the
previously initialized output \fBTcl_DString\fR. The return value is a pointer
to the UTF-8 representation of the \fBappended\fR string.
.PP
\fBTcl_UtfToUniCharDString\fR converts the given UTF-8 string to Unicode,
storing the result in the previously initialized \fBTcl_DString\fR.
In the argument \fIlength\fR, you may either specify the length of
the given UTF-8 string in bytes or
.QW \-1 ,
in which case \fBTcl_UtfToUniCharDString\fR uses \fBstrlen\fR to
calculate the length. The return value is a pointer to the Unicode
representation of the UTF-8 string. Storage for the return value
is appended to the end of the \fBTcl_DString\fR. The Unicode string
is terminated with a Unicode null character.
\fBTcl_UtfToUniCharDString\fR converts the input in the form of
a UTF-8 encoded string to a \fBTcl_UniChar\fR sequence
appending the result in the previously initialized \fBTcl_DString\fR.
The return value is a pointer to the appended result which is also
terminated with a \fBTcl_UniChar\fR null character.
.PP
\fBTcl_WCharToUtfDString\fR and \fBTcl_UtfToWCharDString\fR are similar to
\fBTcl_UniCharToUtfDString\fR and \fBTcl_UtfToUniCharDString\fR except they
operate on sequences of \fBwchar_t\fR instead of \fBTcl_UniChar\fR.
.PP
\fBTcl_Char16ToUtfDString\fR and \fBTcl_UtfToChar16DString\fR are similar to
\fBTcl_UniCharToUtfDString\fR and \fBTcl_UtfToUniCharDString\fR except they
operate on sequences of \fBUTF-16\fR units instead of \fBTcl_UniChar\fR.
.PP
\fBTcl_Char16Len\fR corresponds to \fBstrlen\fR for UTF-16
characters. It accepts a null-terminated Unicode string and returns
the number of Unicode characters (not bytes) in that string.
characters. It accepts a null-terminated UTF-16 sequence and returns
the number of UTF-16 units until the null.
.PP
\fBTcl_WCharLen\fR corresponds to \fBstrlen\fR for wchar_t
characters. It accepts a null-terminated Unicode string and returns
the number of Unicode characters (not bytes) in that string.
characters. It accepts a null-terminated \fBwchar_t\fR sequence and returns
the number of \fBwchar_t\fR units until the null.
.PP
\fBTcl_UniCharLen\fR corresponds to \fBstrlen\fR for Unicode
characters. It accepts a null-terminated Unicode string and returns
@@ -245,7 +251,7 @@ differences in case when comparing upper, lower or title case
characters.
.PP
\fBTcl_UtfCharComplete\fR returns 1 if the source UTF-8 string \fIsrc\fR
of \fIlength\fR bytes is long enough to be decoded by
of \fInumBytes\fR bytes is long enough to be decoded by
\fBTcl_UtfToUniChar\fR/\fBTcl_UtfNext\fR, or 0 otherwise. This function
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
+20 -20
View File
@@ -241,7 +241,7 @@ which returns a binary string equivalent to:
\fB\e254\fR
.CE
.PP
(i.e. \fB\exac\fR) by
(i.e. \fB\exAC\fR) by
truncating the high-bits of the character, and which is probably not
what is desired.
.RE
@@ -299,7 +299,7 @@ high-to-low order within each byte. For example,
will return a binary string equivalent to:
.PP
.CS
\fB\exe0\exe1\exa0\fR
\fB\exE0\exE1\exA0\fR
.CE
.RE
.IP \fBH\fR 5
@@ -326,7 +326,7 @@ remaining bits of the last byte will be zeros. For example,
will return a binary string equivalent to:
.PP
.CS
\fB\exab\ex00\exde\exf0\ex98\fR
\fB\exAB\ex00\exDE\exF0\ex98\fR
.CE
.RE
.IP \fBh\fR 5
@@ -341,7 +341,7 @@ low-to-high order within each byte. This is seldom required. For example,
will return a binary string equivalent to:
.PP
.CS
\fB\exba\ex00\exed\ex0f\ex89\fR
\fB\exBA\ex00\exED\ex0F\ex89\fR
.CE
.RE
.IP \fBc\fR 5
@@ -363,7 +363,7 @@ than \fIcount\fR, then the extra elements are ignored. For example,
will return a binary string equivalent to:
.PP
.CS
\fB\ex03\exfd\ex80\ex04\ex02\ex05\fR
\fB\ex03\exFD\ex80\ex04\ex02\ex05\fR
.CE
.PP
whereas:
@@ -389,7 +389,7 @@ example,
will return a binary string equivalent to:
.PP
.CS
\fB\ex03\ex00\exfd\exff\ex02\ex01\fR
\fB\ex03\ex00\exFD\exFF\ex02\ex01\fR
.CE
.RE
.IP \fBS\fR 5
@@ -405,7 +405,7 @@ example,
will return a binary string equivalent to:
.PP
.CS
\fB\ex00\ex03\exff\exfd\ex01\ex02\fR
\fB\ex00\ex03\exFF\exFD\ex01\ex02\fR
.CE
.RE
.IP \fBt\fR 5
@@ -429,7 +429,7 @@ example,
will return a binary string equivalent to:
.PP
.CS
\fB\ex03\ex00\ex00\ex00\exfd\exff\exff\exff\ex00\ex00\ex01\ex00\fR
\fB\ex03\ex00\ex00\ex00\exFD\exFF\exFF\exFF\ex00\ex00\ex01\ex00\fR
.CE
.RE
.IP \fBI\fR 5
@@ -445,7 +445,7 @@ For example,
will return a binary string equivalent to:
.PP
.CS
\fB\ex00\ex00\ex00\ex03\exff\exff\exff\exfd\ex00\ex01\ex00\ex00\fR
\fB\ex00\ex00\ex00\ex03\exFF\exFF\exFF\exFD\ex00\ex01\ex00\ex00\fR
.CE
.RE
.IP \fBn\fR 5
@@ -510,7 +510,7 @@ on a Windows system running on an Intel Pentium processor,
will return a binary string equivalent to:
.PP
.CS
\fB\excd\excc\excc\ex3f\ex9a\ex99\ex59\ex40\fR
\fB\exCD\exCC\exCC\ex3F\ex9A\ex99\ex59\ex40\fR
.CE
.RE
.IP \fBr\fR 5
@@ -536,7 +536,7 @@ Windows system running on an Intel Pentium processor,
will return a binary string equivalent to:
.PP
.CS
\fB\ex9a\ex99\ex99\ex99\ex99\ex99\exf9\ex3f\fR
\fB\ex9A\ex99\ex99\ex99\ex99\ex99\exF9\ex3F\fR
.CE
.RE
.IP \fBq\fR 5
@@ -788,7 +788,7 @@ scanned. For example,
.RS
.PP
.CS
\fBbinary scan\fR \ex07\exC6\ex05\ex1f\ex34 H3H* var1 var2
\fBbinary scan\fR \ex07\exC6\ex05\ex1F\ex34 H3H* var1 var2
.CE
.PP
will return \fB2\fR with \fB07c\fR stored in \fIvar1\fR and
@@ -839,7 +839,7 @@ example,
.RS
.PP
.CS
\fBbinary scan\fR \ex05\ex00\ex07\ex00\exf0\exff s2s* var1 var2
\fBbinary scan\fR \ex05\ex00\ex07\ex00\exF0\exFF s2s* var1 var2
.CE
.PP
will return \fB2\fR with \fB5 7\fR stored in \fIvar1\fR and \fB\-16\fR
@@ -853,7 +853,7 @@ order. For example,
.RS
.PP
.CS
\fBbinary scan\fR \ex00\ex05\ex00\ex07\exff\exf0 S2S* var1 var2
\fBbinary scan\fR \ex00\ex05\ex00\ex07\exFF\exF0 S2S* var1 var2
.CE
.PP
will return \fB2\fR with \fB5 7\fR stored in \fIvar1\fR and \fB\-16\fR
@@ -878,7 +878,7 @@ example,
.RS
.PP
.CS
set str \ex05\ex00\ex00\ex00\ex07\ex00\ex00\ex00\exf0\exff\exff\exff
set str \ex05\ex00\ex00\ex00\ex07\ex00\ex00\ex00\exF0\exFF\exFF\exFF
\fBbinary scan\fR $str i2i* var1 var2
.CE
.PP
@@ -894,7 +894,7 @@ immediately after the \fBI\fR. For example,
.RS
.PP
.CS
set str \ex00\ex00\ex00\ex05\ex00\ex00\ex00\ex07\exff\exff\exff\exf0
set str \ex00\ex00\ex00\ex05\ex00\ex00\ex00\ex07\exFF\exFF\exFF\exF0
\fBbinary scan\fR $str I2I* var1 var2
.CE
.PP
@@ -920,7 +920,7 @@ example,
.RS
.PP
.CS
set str \ex05\ex00\ex00\ex00\ex07\ex00\ex00\ex00\exf0\exff\exff\exff
set str \ex05\ex00\ex00\ex00\ex07\ex00\ex00\ex00\exF0\exFF\exFF\exFF
\fBbinary scan\fR $str wi* var1 var2
.CE
.PP
@@ -935,7 +935,7 @@ immediately after the \fBW\fR. For example,
.RS
.PP
.CS
set str \ex00\ex00\ex00\ex05\ex00\ex00\ex00\ex07\exff\exff\exff\exf0
set str \ex00\ex00\ex00\ex05\ex00\ex00\ex00\ex07\exFF\exFF\exFF\exF0
\fBbinary scan\fR $str WI* var1 var2
.CE
.PP
@@ -966,7 +966,7 @@ Intel Pentium processor,
.RS
.PP
.CS
\fBbinary scan\fR \ex3f\excc\excc\excd f var1
\fBbinary scan\fR \ex3F\exCC\exCC\exCD f var1
.CE
.PP
will return \fB1\fR with \fB1.6000000238418579\fR stored in
@@ -990,7 +990,7 @@ running on an Intel Pentium processor,
.RS
.PP
.CS
\fBbinary scan\fR \ex9a\ex99\ex99\ex99\ex99\ex99\exf9\ex3f d var1
\fBbinary scan\fR \ex9A\ex99\ex99\ex99\ex99\ex99\exF9\ex3F d var1
.CE
.PP
will return \fB1\fR with \fB1.6000000000000001\fR
+19 -6
View File
@@ -55,7 +55,9 @@ channel is flushed in the background before finally being closed.
.PP
\fBchan close\fR may return an error if an error occurs while flushing
output. If a process in a command pipeline created by \fBopen\fR returns an
error, \fBchan close\fR generates an error in the same manner as \fBexec\fR.
error (either by returning a non-zero exit code or writing to its standard
error file descriptor), \fBchan close\fR generates an error in the same
manner as \fBexec\fR.
.PP
Closing one side of a socket or command pipeline may lead to the shutdown() or
close() of the underlying system resource, leading to a reaction from whatever
@@ -70,6 +72,17 @@ description of channel sharing.
.PP
When the last interpreter sharing a channel is destroyed, the channel is
switched to blocking mode and fully flushed and then closed.
.PP
Channels are automatically closed when an interpreter is destroyed and
when the process exits.
From 8.6 on (TIP#398), nonblocking channels are no longer switched to
blocking mode when exiting; this guarantees a timely exit even when the
peer or a communication channel is stalled. To ensure proper flushing of
stalled nonblocking channels on exit, one must now either (a) actively
switch them back to blocking or (b) use the environment variable
\fBTCL_FLUSH_NONBLOCKING_ON_EXIT\fR, which when set and not equal to
.QW \fB0\fR
restores the previous behavior.
.RE
.TP
\fBchan configure \fIchannelName\fR ?\fIoptionName\fR? ?\fIvalue\fR? ?\fIoptionName value\fR?...
@@ -139,7 +152,7 @@ If \fIchar\fR is the empty string, there is no special character that marks
the end of the data.
The default value is the empty string. The acceptable range is \ex01 -
\ex7f. A value outside this range results in an error.
\ex7F. A value outside this range results in an error.
.VS "TCL8.7 TIP656"
.TP
\fB\-profile\fR \fIprofile\fR
@@ -232,10 +245,10 @@ files to slow destinations like network sockets.
.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
If \fB\-command\fR is given, \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
an error occurs 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.
@@ -348,8 +361,8 @@ first words of a command that provides the interface for a \fBrefchan\fR.
\fBImode\fR is a list of one or more of the strings
.QW \fBread\fR
or
.QW \fBwrite\fR
, indicating whether the channel is a read channel, a write channel, or both.
.QW \fBwrite\fR ,
indicating whether the channel is a read channel, a write channel, or both.
It is an error if the handler does not support the chosen mode.
.PP
The handler is called as needed from the global namespace at the top level, and
+15 -6
View File
@@ -12,11 +12,12 @@
.SH NAME
close \- Close an open channel
.SH SYNOPSIS
\fBclose \fIchannelId\fR ?r(ead)|w(rite)?
\fBclose \fIchannelId\fR ?\fBr\fR(\fBead\fR)|\fBw\fR(\fBrite\fR)?
.BE
.SH DESCRIPTION
.PP
Closes or half-closes the channel given by \fIchannelId\fR.
Closes or half-closes the channel given by \fIchannelId\fR. \fBchan close\fR
is another name for this command.
.PP
\fIChannelId\fR must be an identifier for an open channel such as a
Tcl standard channel (\fBstdin\fR, \fBstdout\fR, or \fBstderr\fR),
@@ -49,12 +50,20 @@ When the last interpreter in which the channel is registered invokes
.PP
Channels are automatically closed when an interpreter is destroyed and
when the process exits.
From 8.6 on (TIP#398), nonblocking channels are no longer switched to blocking mode when exiting; this guarantees a timely exit even when the peer or a communication channel is stalled. To ensure proper flushing of stalled nonblocking channels on exit, one must now either (a) actively switch them back to blocking or (b) use the environment variable TCL_FLUSH_NONBLOCKING_ON_EXIT, which when set and not equal to "0" restores the previous behavior.
From 8.6 on (TIP#398), nonblocking channels are no longer switched to
blocking mode when exiting; this guarantees a timely exit even when the
peer or a communication channel is stalled. To ensure proper flushing of
stalled nonblocking channels on exit, one must now either (a) actively
switch them back to blocking or (b) use the environment variable
\fBTCL_FLUSH_NONBLOCKING_ON_EXIT\fR, which when set and not equal to
.QW \fB0\fR
restores the previous behavior.
.PP
The command returns an empty string, and may generate an error if
an error occurs while flushing output. If a command in a command
pipeline created with \fBopen\fR returns an error, \fBclose\fR
generates an error (similar to the \fBexec\fR command.)
pipeline created with \fBopen\fR returns an error (either by returning a
non-zero exit code or writing to its standard error file descriptor),
\fBclose\fR generates an error (similar to the \fBexec\fR command.)
.PP
The two-argument form is a
.QW "half-close" :
@@ -95,7 +104,7 @@ proc withOpenFile {filename channelVar script} {
}
.CE
.SH "SEE ALSO"
file(n), open(n), socket(n), eof(n), Tcl_StandardChannels(3)
chan(n), file(n), open(n), socket(n), eof(n), Tcl_StandardChannels(3)
.SH KEYWORDS
blocking, channel, close, nonblocking, half-close
'\" Local Variables:
+333
View File
@@ -0,0 +1,333 @@
'\"
'\" Copyright © 2019 Donal K. Fellows
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.TH configurable n 0.4 TclOO "TclOO Commands"
.so man.macros
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
oo::configurable, configure, property \- class that makes configurable classes and objects, and supports making configurable properties
.SH SYNOPSIS
.nf
package require TclOO
\fBoo::configurable create \fIclass\fR ?\fIdefinitionScript\fR?
\fBoo::define \fIclass\fB {\fR
\fBproperty \fIpropName\fR ?\fIoptions...\fR? ?\fIpropName\fR ?\fIoptions...\fR?...?
\fB}\fR
\fBoo::objdefine \fIobject\fB {\fR
\fBproperty \fIpropName\fR ?\fIoptions...\fR? ?\fIpropName\fR ?\fIoptions...\fR?...?
\fB}\fR
\fIobjectName \fBconfigure\fR
\fIobjectName \fBconfigure\fR \fI\-prop\fR
\fIobjectName \fBconfigure\fR \fI\-prop value\fR ?\fI\-prop value\fR...
.fi
.SH "CLASS HIERARCHY"
.nf
\fBoo::object\fR
\(-> \fBoo::class\fR
\(-> \fBoo::configurable\fR
\fBoo::object\fR
\(-> \fBoo::class\fR
\(-> \fBoo::configurablesupport::configurable\fR
.fi
.BE
.SH DESCRIPTION
.PP
Configurable objects are objects that support being configured with a
\fBconfigure\fR method. Each of the configurable entities of the object is
known as a property of the object. Properties may be defined on classes or
instances; when configuring an object, any of the properties defined by its
classes (direct or indirect) or by the instance itself may be configured.
.PP
The \fBoo::configurable\fR metaclass installs basic support for making
configurable objects into a class. This consists of making a \fBproperty\fR
definition command available in definition scripts for the class and instances
(e.g., from the class's constructor, within \fBoo::define\fR and within
\fBoo::objdefine\fR) and making a \fBconfigure\fR method available within the
instances.
.SS "CONFIGURE METHOD"
.PP
The behavior of the \fBconfigure\fR method is modelled after the
\fBfconfigure\fR/\fBchan configure\fR command.
.PP
If passed no additional arguments, the \fBconfigure\fR method returns an
alphabetically sorted dictionary of all \fIreadable\fR and \fIread-write\fR
properties and their current values.
.PP
If passed a single additional argument, that argument to the \fBconfigure\fR
method must be the name of a property to read (or an unambiguous prefix
thereof); its value is returned.
.PP
Otherwise, if passed an even number of arguments then each pair of arguments
specifies a property name (or an unambiguous prefix thereof) and the value to
set it to. The properties will be set in the order specified, including
duplicates. If the setting of any property fails, the overall \fBconfigure\fR
method fails, the preceding pairs (if any) will continue to have been applied,
and the succeeding pairs (if any) will be not applied. On success, the result
of the \fBconfigure\fR method in this mode operation will be an empty string.
.SS "PROPERTY DEFINITIONS"
.PP
When a class has been manufactured by the \fBoo::configurable\fR metaclass (or
one of its subclasses), it gains an extra definition, \fBproperty\fR. The
\fBproperty\fR definition defines one or more properties that will be exposed
by the class's instances.
.PP
The \fBproperty\fR command takes the name of a property to define first,
\fIwithout a leading hyphen\fR, followed by a number of option-value pairs
that modify the basic behavior of the property. This can then be followed by
an arbitrary number of other property definitions. The supported options are:
.TP
\fB\-get \fIgetterScript\fR
.
This defines the implementation of how to read from the property; the
\fIgetterScript\fR will become the body of a method (taking no arguments)
defined on the class, if the kind of the property is such that the property
can be read from. The method will be named
\fB<ReadProp-\fIpropertyName\fB>\fR, and will default to being a simple read
of the instance variable with the same name as the property (e.g.,
.QW "\fBproperty\fR xyz"
will result in a method
.QW <ReadProp-xyz>
being created).
.TP
\fB\-kind \fIpropertyKind\fR
.
This defines what sort of property is being created. The \fIpropertyKind\fR
must be exactly one of \fBreadable\fR, \fBwritable\fR, or \fBreadwrite\fR
(which is the default) which will make the property read-only, write-only or
read-write, respectively. Read-only properties can only ever be read from,
write-only properties can only ever be written to, and read-write properties
can be both read and written.
.RS
.PP
Note that write-only properties are not particularly discoverable as they are
never reported by the \fBconfigure\fR method other than by error messages when
attempting to write to a property that does not exist.
.RE
.TP
\fB\-set \fIsetterScript\fR
.
This defines the implementation of how to write to the property; the
\fIsetterScript\fR will become the body of a method taking a single argument,
\fIvalue\fR, defined on the class, if the kind of the property is such that
the property can be written to. The method will be named
\fB<WriteProp-\fIpropertyName\fB>\fR, and will default to being a simple write
of the instance variable with the same name as the property (e.g.,
.QW "\fBproperty\fR xyz"
will result in a method
.QW <WriteProp-xyz>
being created).
.PP
Instances of the class that was created by \fBoo::configurable\fR will also
support \fBproperty\fR definitions; the semantics will be exactly as above
except that the properties will be defined on the instance alone.
.PP
Note that the property implementation methods that \fBproperty\fR defines
should not be private, as this makes them inaccessible from the implementation
of \fBconfigure\fR (by design; the property configuration mechanism is
intended for use mainly from outside a class, whereas a class may access
variables directly). The variables accessed by the default implementations of
the properties \fImay\fR be private, if so declared.
.SH "ADVANCED USAGE"
.PP
The configurable class system is comprised of several pieces. The
\fBoo::configurable\fR metaclass works by mixing in a class and setting
definition namespaces during object creation that provide the other bits and
pieces of machinery. The key pieces of the implementation are enumerated here
so that they can be used by other code:
.TP
\fBoo::configuresupport::configurable\fR
.
This is a class that provides the implementation of the \fBconfigure\fR method
(described above in \fBCONFIGURE METHOD\fR).
.TP
\fBoo::configuresupport::configurableclass\fR
.
This is a namespace that contains the definition dialect that provides the
\fBproperty\fR declaration for use in classes (i.e., via \fBoo::define\fR, and
class constructors under normal circumstances), as described above in
\fBPROPERTY DEFINITIONS\fR. It \fBnamespace export\fRs its \fBproperty\fR
command so that it may be used easily in user definition dialects.
.TP
\fBoo::configuresupport::configurableobject\fR
.
This is a namespace that contains the definition dialect that provides the
\fBproperty\fR declaration for use in instance objects (i.e., via
\fBoo::objdefine\fR, and the \fBself\fR declaration in \fBoo::define\fR), as
described above in \fBPROPERTY DEFINITIONS\fR. It \fBnamespace export\fRs its
\fBproperty\fR command so that it may be used easily in user definition
dialects.
.PP
The underlying property discovery mechanism relies on four slots (see
\fBoo::define\fR for what that implies) that list the properties that can be
configured. These slots do not themselves impose any semantics on what the
slots mean other than that they have unique names, no important order, can be
inherited and discovered on classes and instances.
.PP
These slots, and their intended semantics, are:
.TP
\fBoo::configuresupport::readableproperties\fR
.
The set of properties of a class (not including those from its superclasses)
that may be read from when configuring an instance of the class. This slot can
also be read with the \fBinfo class properties\fR command.
.TP
\fBoo::configuresupport::writableproperties\fR
.
The set of properties of a class (not including those from its superclasses)
that may be written to when configuring an instance of the class. This slot
can also be read with the \fBinfo class properties\fR command.
.TP
\fBoo::configuresupport::objreadableproperties\fR
.
The set of properties of an object instance (not including those from its
classes) that may be read from when configuring the object. This slot can
also be read with the \fBinfo object properties\fR command.
.TP
\fBoo::configuresupport::objwritableproperties\fR
.
The set of properties of an object instance (not including those from its
classes) that may be written to when configuring the object. This slot can
also be read with the \fBinfo object properties\fR command.
.PP
Note that though these are slots, they are \fInot\fR in the standard
\fBoo::define\fR or \fBoo::objdefine\fR namespaces; in order to use them
inside a definition script, they need to be referred to by full name. This is
because they are intended to be building bricks of configurable property
system, and not directly used by normal user code.
.SS "IMPLEMENTATION NOTE"
.PP
The implementation of the \fBconfigure\fR method uses
\fBinfo object properties\fR with the \fB\-all\fR option to discover what
properties it may manipulate.
.SH EXAMPLES
.PP
Here we create a simple configurable class and demonstrate how it can be
configured:
.PP
.CS
\fBoo::configurable\fR create Point {
\fBproperty\fR x y
constructor args {
my \fBconfigure\fR -x 0 -y 0 {*}$args
}
variable x y
method print {} {
puts "x=$x, y=$y"
}
}
set pt [Point new -x 27]
$pt print; \fI# x=27, y=0\fR
$pt \fBconfigure\fR -y 42
$pt print; \fI# x=27, y=42\fR
puts "distance from origin: [expr {
hypot([$pt \fBconfigure\fR -x], [$pt \fBconfigure\fR -y])
}]"; \fI# distance from origin: 49.92995093127971\fR
puts [$pt \fBconfigure\fR]
\fI# -x 27 -y 42\fR
.CE
.PP
Such a configurable class can be extended by subclassing, though the subclass
needs to also be created by \fBoo::configurable\fR if it will use the
\fBproperty\fR definition:
.PP
.CS
\fBoo::configurable\fR create Point3D {
superclass Point
\fBproperty\fR z
constructor args {
next -z 0 {*}$args
}
}
set pt2 [Point3D new -x 2 -y 3 -z 4]
puts [$pt2 \fBconfigure\fR]
\fI# -x 2 -y 3 -z 4\fR
.CE
.PP
Once you have a configurable class, you can also add instance properties to
it. (The backing variables for all properties start unset.) Note below that we
are using an unambiguous prefix of a property name when setting it; this is
supported for all properties though full names are normally recommended
because subclasses will not make an unambiguous prefix become ambiguous in
that case.
.PP
.CS
oo::objdefine $pt {
\fBproperty\fR color
}
$pt \fBconfigure\fR -c bisque
puts [$pt \fBconfigure\fR]
\fI# -color bisque -x 27 -y 42\fR
.CE
.PP
You can also do derived properties by making them read-only and supplying a
script that computes them.
.PP
.CS
\fBoo::configurable\fR create PointMk2 {
\fBproperty\fR x y
\fBproperty\fR distance -kind readable -get {
return [expr {hypot($x, $y)}]
}
variable x y
constructor args {
my \fBconfigure\fR -x 0 -y 0 {*}$args
}
}
set pt3 [PointMk2 new -x 3 -y 4]
puts [$pt3 \fBconfigure\fR -distance]
\fI# 5.0\fR
$pt3 \fBconfigure\fR -distance 10
\fI# ERROR: bad property "-distance": must be -x or -y\fR
.CE
.PP
Setters are used to validate the type of a property:
.PP
.CS
\fBoo::configurable\fR create PointMk3 {
\fBproperty\fR x -set {
if {![string is double -strict $value]} {
error "-x property must be a number"
}
set x $value
}
\fBproperty\fR y -set {
if {![string is double -strict $value]} {
error "-y property must be a number"
}
set y $value
}
variable x y
constructor args {
my \fBconfigure\fR -x 0 -y 0 {*}$args
}
}
set pt4 [PointMk3 new]
puts [$pt4 \fBconfigure\fR]
\fI# -x 0 -y 0\fR
$pt4 \fBconfigure\fR -x 3 -y 4
puts [$pt4 \fBconfigure\fR]
\fI# -x 3 -y 4\fR
$pt4 \fBconfigure\fR -x "obviously not a number"
\fI# ERROR: -x property must be a number\fR
.CE
.SH "SEE ALSO"
info(n), oo::class(n), oo::define(n)
.SH KEYWORDS
class, object, properties, configuration
.\" Local variables:
.\" mode: nroff
.\" fill-column: 78
.\" End:
+6
View File
@@ -493,6 +493,12 @@ the slot:
.
This appends the given \fImember\fR elements to the slot definition.
.TP
\fIslot\fR \fB\-appendifnew\fR ?\fImember ...\fR?
.VS TIP558
This appends the given \fImember\fR elements to the slot definition if they
do not already exist.
.VE TIP558
.TP
\fIslot\fR \fB\-clear\fR
.
This sets the slot definition to the empty list.
+1
View File
@@ -1,5 +1,6 @@
'\"
'\" Copyright (c) 1998 Scriptics Corporation.
'\" Copyright (c) 2023 Nathan Coulter
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+16
View File
@@ -119,6 +119,22 @@ Volume-relative path to a file \fBfoo\fR in the root directory of the current
volume. This is not a valid UNC path, so the assumption is that the
extra backslashes are superfluous.
.RE
.SH "TILDE SUBSTITUTION"
.PP
Unlike earlier versions of Tcl, Tcl 9 does not do implicit tilde substitution
on file paths with the exception noted below. The commands \fBfile home\fR and
\fBfile tildeexpand\fR may be used to explicitly accomplish the same.
.PP
The exception to the above is initialization of the \fBauto_path\fR variable
and the Tcl module search paths as documented in the manpages for
\fBtclvars\fR and \fBtm\fR. When any path in an environment variable used to
initialize these starts with a tilde, it will be interpreted as if the first
element is replaced with the location of the home directory for the given
user. If the tilde is followed immediately by a separator, the
\fB$HOME\fR environment variable is substituted. Otherwise the characters
between the tilde and the next separator are taken as a user name, which is
used to retrieve the user's home directory for substitution. This works on
POSIX, MacOS X and Windows platforms.
.SH "PORTABILITY ISSUES"
.PP
Not all file systems are case sensitive, so scripts should avoid code
+47
View File
@@ -490,6 +490,29 @@ be discovered with \fBinfo class forward\fR.
This subcommand returns a list of all classes that have been mixed into the
class named \fIclass\fR.
.TP
\fBinfo class properties\fI class\fR ?\fIoptions...\fR
.VS "TIP 558"
This subcommand returns a sorted list of properties defined on the class named
\fIclass\fR. The \fIoptions\fR define exactly which properties are returned:
.RS
.TP
\fB\-all\fR
.
With this option, the properties from the superclasses and mixins of the class
are also returned.
.TP
\fB\-readable\fR
.
This option (the default behavior) asks for the readable properties to be
returned. Only readable or writable properties are returned, not both.
.TP
\fB\-writable\fR
.
This option asks for the writable properties to be returned. Only readable or
writable properties are returned, not both.
.RE
.VE "TIP 558"
.TP
\fBinfo class subclasses\fI class\fR ?\fIpattern\fR?
.
This subcommand returns a list of direct subclasses of class \fIclass\fR. If
@@ -679,6 +702,30 @@ object named \fIobject\fR.
This subcommand returns the name of the internal namespace of the object named
\fIobject\fR.
.TP
\fBinfo object properties\fI object\fR ?\fIoptions...\fR
.VS "TIP 558"
This subcommand returns a sorted list of properties defined on the object
named \fIobject\fR. The \fIoptions\fR define exactly which properties are
returned:
.RS
.TP
\fB\-all\fR
.
With this option, the properties from the class, superclasses and mixins of
the object are also returned.
.TP
\fB\-readable\fR
.
This option (the default behavior) asks for the readable properties to be
returned. Only readable or writable properties are returned, not both.
.TP
\fB\-writable\fR
.
This option asks for the writable properties to be returned. Only readable or
writable properties are returned, not both.
.RE
.VE "TIP 558"
.TP
\fBinfo object variables\fI object\fRR ?\fB\-private\fR?
.
This subcommand returns a list of all variables that have been declared for
+13 -13
View File
@@ -24,7 +24,7 @@ Arguments \fIfirst\fR and \fIlast\fR are index values specifying the first and
last elements of the range to replace. They are interpreted
the same as index values for the command \fBstring index\fR,
supporting simple index arithmetic and indices relative to the
end of the list. The index 0 refers to the first element of the
end of the list. The index \fB0\fR refers to the first element of the
list, and \fBend\fR refers to the last element of the list.
.PP
If either \fIfirst\fR or \fIlast\fR is less than zero, it is considered to
@@ -49,33 +49,33 @@ between \fIfirst\fR and \fIlast\fR are simply deleted.
Prepend to a list.
.PP
.CS
% set lst {c d e f g}
c d e f g
% ledit lst -1 -1 a b
a b c d e f g
set lst {c d e f g}
\fI\(-> c d e f g\fR
\fBledit\fR lst -1 -1 a b
\fI\(-> a b c d e f g\fR
.CE
.PP
Append to the list.
.PP
.CS
% ledit lst end+1 end+1 h i
a b c d e f g h i
\fBledit\fR lst end+1 end+1 h i
\fI\(-> a b c d e f g h i\fR
.CE
.PP
Delete third and fourth elements.
.PP
.CS
% ledit lst 2 3
a b e f g h i
\fBledit\fR lst 2 3
\fI\(-> a b e f g h i\fR
.CE
.PP
Replace two elements with three.
.PP
.CS
% ledit lst 2 3 x y z
a b x y z g h i
% set lst
a b x y z g h i
\fBledit\fR lst 2 3 x y z
\fI\(-> a b x y z g h i\fR
set lst
\fI\(-> a b x y z g h i\fR
.CE
.PP
.SH "SEE ALSO"
+114 -3
View File
@@ -58,6 +58,7 @@ the auto-load mechanism defined below.
The following procedures are provided in the Tcl library:
.TP
\fBauto_execok \fIcmd\fR
.
Determines whether there is an executable file or shell builtin
by the name \fIcmd\fR. If so, it returns a list of arguments to be
passed to \fBexec\fR to execute the executable file or shell builtin
@@ -70,8 +71,30 @@ remembers information about previous searches in an array named
\fBauto_execs\fR; this avoids the path search in future calls for the
same \fIcmd\fR. The command \fBauto_reset\fR may be used to force
\fBauto_execok\fR to forget its cached information.
.RS
.PP
For example, to run the \fIumask\fR shell builtin on Linux, you would do:
.PP
.CS
exec {*}[\fBauto_execok\fR umask]
.CE
.PP
To run the \fIDIR\fR shell builtin on Windows, you would do:
.PP
.CS
exec {*}[\fBauto_execok\fR dir]
.CE
.PP
To discover if there is a \fIfrobnicate\fR binary on the user's PATH,
you would do:
.PP
.CS
set mayFrob [expr {[llength [\fBauto_execok\fR frobnicate]] > 0}]
.CE
.RE
.TP
\fBauto_import \fIpattern\fR
.
\fBAuto_import\fR is invoked during \fBnamespace import\fR to see if
the imported commands specified by \fIpattern\fR reside in an
autoloaded library. If so, the commands are loaded so that they will
@@ -79,13 +102,18 @@ be available to the interpreter for creating the import links. If the
commands do not reside in an autoloaded library, \fBauto_import\fR
does nothing. The pattern matching is performed according to the
matching rules of \fBnamespace import\fR.
.RS
.PP
It is not normally necessary to call this command directly.
.RE
.TP
\fBauto_load \fIcmd\fR
.
This command attempts to load the definition for a Tcl command named
\fIcmd\fR. To do this, it searches an \fIauto-load path\fR, which is
a list of one or more directories. The auto-load path is given by the
global variable \fBauto_path\fR if it exists. If there is no
\fBauto_path\fR variable, then the TCLLIBPATH environment variable is
\fBauto_path\fR variable, then the \fBTCLLIBPATH\fR environment variable is
used, if it exists. Otherwise the auto-load path consists of just the
Tcl library directory. Within each directory in the auto-load path
there must be a file \fBtclIndex\fR that describes one or more
@@ -104,6 +132,11 @@ the array \fBauto_index\fR; future calls to \fBauto_load\fR check for
cached index information may be deleted with the command
\fBauto_reset\fR. This will force the next \fBauto_load\fR command to
reload the index database from disk.
.RS
.PP
It is not normally necessary to call this command directly; the
default \fBunknown\fR handler will do so.
.RE
.TP
\fBauto_mkindex \fIdir pattern pattern ...\fR
.
@@ -156,6 +189,7 @@ listed in the auto-load index, so that fresh copies of them will be
loaded the next time that they are used.
.TP
\fBauto_qualify \fIcommand namespace\fR
.
Computes a list of fully qualified names for \fIcommand\fR. This list
mirrors the path a standard Tcl interpreter follows for command
lookups: first it looks for the command in the current namespace, and
@@ -175,6 +209,7 @@ performing the actual auto-loading of functions at runtime.
.RE
.TP
\fBtcl_findLibrary \fIbasename version patch initScript enVarName varName\fR
.
This is a standard search procedure for use by extensions during
their initialization. They call this procedure to look for their
script library in several standard directories.
@@ -197,14 +232,28 @@ relative to the executable file in the current build tree;
relative to the executable file in a parallel build tree.
.TP
\fBparray \fIarrayName\fR ?\fIpattern\fR?
.
Prints on standard output the names and values of all the elements in the
array \fIarrayName\fR, or just the names that match \fIpattern\fR (using the
matching rules of \fBstring match\fR) and their values if \fIpattern\fR is
given.
\fIArrayName\fR must be an array accessible to the caller of \fBparray\fR.
It may be either local or global.
The result of this command is the empty string.
.RS
.PP
For example, to print the contents of the \fBtcl_platform\fR array, do:
.PP
.CS
\fBparray\fR tcl_platform
.CE
.RE
.SS "WORD BOUNDARY HELPERS"
.PP
These procedures are mainly used internally by Tk.
.TP
\fBtcl_endOfWord \fIstr start\fR
.
Returns the index of the first end-of-word location that occurs after
a starting index \fIstart\fR in the string \fIstr\fR. An end-of-word
location is defined to be the first non-word character following the
@@ -215,19 +264,35 @@ for more details on how Tcl determines which characters are word
characters.
.TP
\fBtcl_startOfNextWord \fIstr start\fR
.
Returns the index of the first start-of-word location that occurs
after a starting index \fIstart\fR in the string \fIstr\fR. A
start-of-word location is defined to be the first word character
following a non-word character. Returns \-1 if there are no more
start-of-word locations after the starting point.
.RS
.PP
For example, to print the indices of the starts of each word in a
string according to platform rules:
.PP
.CS
set theString "The quick brown fox"
for {set idx 0} {$idx >= 0} {
set idx [\fBtcl_startOfNextWord\fR $theString $idx]} {
puts "Word start index: $idx"
}
.CE
.RE
.TP
\fBtcl_startOfPreviousWord \fIstr start\fR
.
Returns the index of the first start-of-word location that occurs
before a starting index \fIstart\fR in the string \fIstr\fR. Returns
\-1 if there are no more start-of-word locations before the starting
point.
.TP
\fBtcl_wordBreakAfter \fIstr start\fR
.
Returns the index of the first word boundary after the starting index
\fIstart\fR in the string \fIstr\fR. Returns \-1 if there are no more
boundaries after the starting point in the given string. The index
@@ -235,6 +300,7 @@ returned refers to the second character of the pair that comprises a
boundary.
.TP
\fBtcl_wordBreakBefore \fIstr start\fR
.
Returns the index of the first word boundary before the starting index
\fIstart\fR in the string \fIstr\fR. Returns \-1 if there are no more
boundaries before the starting point in the given string. The index
@@ -248,18 +314,30 @@ commands and packages, and determining what are words.
.SS "AUTOLOADING AND PACKAGE MANAGEMENT VARIABLES"
.TP
\fBauto_execs\fR
.
Used by \fBauto_execok\fR to record information about whether
particular commands exist as executable files.
.RS
.PP
Not normally usefully accessed directly by user code.
.RE
.TP
\fBauto_index\fR
.
Used by \fBauto_load\fR to save the index information read from
disk.
.RS
.PP
Not normally usefully accessed directly by user code.
.RE
.TP
\fBauto_noexec\fR
.
If set to any value, then \fBunknown\fR will not attempt to auto-exec
any commands.
.TP
\fBauto_noload\fR
.
If set to any value, then \fBunknown\fR will not attempt to auto-load
any commands.
.TP
@@ -275,37 +353,70 @@ the parent directory of \fBtcl_library\fR,
the directories listed in the \fBtcl_pkgPath\fR variable.
Additional locations to look for files and package indices should
normally be added to this variable using \fBlappend\fR.
.RS
.PP
For example, to add the \fIlib\fR directory next to the running
script, you would do:
.PP
.CS
lappend \fBauto_path\fR [file dirname [info script]]/lib
.CE
.PP
Note that if the script uses \fBcd\fR, it is advisable to ensure that
entries on the \fBauto_path\fR are \fBfile normalize\fRd.
.RE
.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
a default value is used.
.RS
.PP
Use of this environment variable is not recommended outside of testing.
Tcl installations should already know where to find their own script
files, as the value is baked in during the build or installation.
.RE
.TP
\fBenv(TCLLIBPATH)\fR
.
If set, then it must contain a valid Tcl list giving directories to
search during auto-load operations. Directories must be specified in
Tcl format, using
.QW /
as the path separator, regardless of platform.
This variable is only used when initializing the \fBauto_path\fR variable.
.RS
.PP
A key consequence of this variable is that it gives a way to let the user
of a script specify the list of places where that script may use
\fBpackage require\fR to read packages from. It is not normally usefully
settable within a Tcl script itself \fIexcept\fR to influence where other
interpreters load from (whether made with \fBinterp create\fR or launched
as their own threads or subprocesses).
.RE
.SS "WORD BOUNDARY DETERMINATION VARIABLES"
These variables are only used in the \fBtcl_endOfWord\fR,
\fBtcl_startOfNextWord\fR, \fBtcl_startOfPreviousWord\fR,
\fBtcl_wordBreakAfter\fR, and \fBtcl_wordBreakBefore\fR commands.
.TP
\fBtcl_nonwordchars\fR
.
This variable contains a regular expression that is used by routines
like \fBtcl_endOfWord\fR to identify whether a character is part of a
word or not. If the pattern matches a character, the character is
considered to be a non-word character. The default is "\\W".
considered to be a non-word character. The default value is
.QW "\\W" .
.TP
\fBtcl_wordchars\fR
.
This variable contains a regular expression that is used by routines
like \fBtcl_endOfWord\fR to identify whether a character is part of a
word or not. If the pattern matches a character, the character is
considered to be a word character. The default is "\\w".
considered to be a word character. The default value is
.QW "\\w" .
.SH "SEE ALSO"
env(n), info(n), re_syntax(n)
.SH KEYWORDS
+7 -7
View File
@@ -52,11 +52,11 @@ oo::class create ABC {
constructor {} {
\fBlink\fR Foo
# The method foo is now directly accessible as foo here
# The method Foo is now directly accessible as Foo here
\fBlink\fR {bar Foo}
# The method foo is now directly accessible as bar
# The method Foo is now directly accessible as bar
\fBlink\fR {::ExternalCall Foo}
# The method foo is now directly accessible in the global
# The method Foo is now directly accessible in the global
# namespace as ExternalCall
}
@@ -71,13 +71,13 @@ oo::class create ABC {
ABC create abc
abc grill
\fI\(-> Step 1:\fR
\fI\(-> This is foo in ::abc\fR
\fI\(-> This is Foo in ::abc\fR
\fI\(-> Step 2:\fR
\fI\(-> This is foo in ::abc\fR
\fI\(-> This is Foo in ::abc\fR
# Direct access via the linked command
puts "Step 3:"; ExternalCall
\fI\(-> Step 3:\fR
\fI\(-> This is foo in ::abc\fR
\fI\(-> This is Foo in ::abc\fR
.CE
.PP
This example shows that multiple linked commands can be made in a call to
@@ -88,7 +88,7 @@ oo::class create Ex {
constructor {} {
\fBlink\fR a b c
# The methods a, b, and c (defined below) are all now
# directly acessible within methods under their own names.
# directly accessible within methods under their own names.
}
method a {} {
+1 -1
View File
@@ -16,7 +16,7 @@ lremove \- Remove elements from a list by index
.SH DESCRIPTION
.PP
\fBlremove\fR returns a new list formed by simultaneously removing zero or
more elements of \fIlist\fR at each of the indices given by an arbirary number
more elements of \fIlist\fR at each of the indices given by an arbitrary number
of \fIindex\fR arguments. The indices may be in any order and may be repeated;
the element at index will only be removed once. The index values are
interpreted the same as index values for the command \fBstring index\fR,
+86 -50
View File
@@ -11,78 +11,114 @@
.SH NAME
lseq \- Build a numeric sequence returned as a list
.SH SYNOPSIS
\fBlseq \fIStart \fR?(\fB..\fR|\fBto\fR)? \fIEnd\fR ??\fBby\fR? \fIStep\fR?
\fBlseq \fIstart \fR?(\fB..\fR|\fBto\fR)? \fIend\fR ??\fBby\fR? \fIstep\fR?
\fBlseq \fIStart \fBcount\fR \fICount\fR ??\fBby\fR? \fIStep\fR?
\fBlseq \fIstart \fBcount\fR \fIcount\fR ??\fBby\fR? \fIstep\fR?
\fBlseq \fICount\fR ?\fBby \fIStep\fR?
\fBlseq \fIcount\fR ?\fBby \fIstep\fR?
.BE
.SH DESCRIPTION
.PP
The \fBlseq\fR command creates a sequence of numeric values using the given
parameters \fIStart\fR, \fIEnd\fR, and \fIStep\fR. The \fIoperation\fR
argument ".." or "to" defines an inclusive range. The "count" option is used
to define a count of the number of elements in the list. The short form with a
single count value will create a range from 0 to count-1.
parameters \fIstart\fR, \fIend\fR, and \fIstep\fR. The \fIoperation\fR
argument "\fB..\fR" or "\fBto\fR" defines the range. The "\fBcount\fR" option
is used to define a count of the number of elements in the list. A short form
use of the command, with a single count value, will create a range from 0 to
count-1.
The numeric arguments, \fIStart\fR, \fIEnd\fR, \fIStep\fR, and \fICount\fR,
can also be a valid expression. the lseq command will evaluate the expression
The \fBlseq\fR command can produce both increasing and decreasing
sequences. When both \fIstart\fR and \fIend\fR are provided without a
\fIstep\fR value, then if \fIstart\fR <= \fIend\fR, the sequence will be
increasing and if \fIstart\fR > \fIend\fR it will be decreasing. If a
\fIstep\fR vale is included, it's sign should agree with the direction of the
sequence (descending -> negative and ascending -> positive), otherwise an
empty list is returned. For example:
.CS \"
% \fBlseq\fR 1 to 5 ;# increasing
\fI\(-> 1 2 3 4 5
% \fBlseq\fR 5 to 1 ;# decreasing
\fI\(-> 5 4 3 2 1
% \fBlseq\fR 6 to 1 by 2 ;# decreasing, step wrong sign, empty list
% \fBlseq\fR 1 to 5 by 0 ;# all step sizes of 0 produce an empty list
.\"
.CE
The numeric arguments, \fIstart\fR, \fIend\fR, \fIstep\fR, and \fIcount\fR,
may also be a valid expression. The expression will be evaluated and the
numeric result will be used. An expression that does not evaluate to a number
will produce an invalid argument error.
.PP
\fIStart\fR defines the initial value and \fIend\fR defines the limit, not
necessarily the last value. \fBlseq\fR produces a list with \fIcount\fR
elements, and if \fIcount\fR is not supplied, it is computed as
.CS \"
\fIcount\fR = int( (\fIend\fR - \fIstart\fR + \fIstep\fR) / \fIstep\fR )
.\"
.CE
.PP
The numeric arguments, \fIstart\fR, \fIend\fR, \fIstep\fR, and \fIcount\fR,
can also be a valid expression. the \fBlseq\fR command will evaluate the
expression (as if with \fBexpr\fR)
and use the numeric result, or return an error as with any invalid argument
value. A valid expression is a valid [expr] expression, however, the result
must be numeric; a non-numeric string will result in an error.
value; a non-numeric expression result will result in an error.
.SH EXAMPLES
.CS
.\"
\fBlseq\fR 3
\fI\(-> 0 1 2\fR
lseq 3
\(-> 0 1 2
\fBlseq\fR 3 0
\fI\(-> 3 2 1 0\fR
lseq 3 0
\(-> 3 2 1 0
\fBlseq\fR 10 .. 1 by -2
\fI\(-> 10 8 6 4 2\fR
lseq 10 .. 1 by -2
\(-> 10 8 6 4 2
set l [\fBlseq\fR 0 -5]
\fI\(-> 0 -1 -2 -3 -4 -5\fR
set l [lseq 0 -5]
\(-> 0 -1 -2 -3 -4 -5
foreach i [lseq [llength $l]] {
puts l($i)=[lindex $l $i]
}
\(-> l(0)=0
l(1)=-1
l(2)=-2
l(3)=-3
l(4)=-4
l(5)=-5
foreach i [lseq [llength $l]-1 0] {
foreach i [\fBlseq\fR [llength $l]] {
puts l($i)=[lindex $l $i]
}
\(-> l(5)=-5
l(4)=-4
l(3)=-3
l(2)=-2
l(1)=-1
l(0)=0
}
\fI\(-> l(0)=0\fR
\fI\(-> l(1)=-1\fR
\fI\(-> l(2)=-2\fR
\fI\(-> l(3)=-3\fR
\fI\(-> l(4)=-4\fR
\fI\(-> l(5)=-5\fR
set i 17
\(-> 17
if {$i in [lseq 0 50]} { # equivalent to: (0 <= $i && $i < 50)
puts "Ok"
} else {
puts "outside :("
}
\(-> Ok
foreach i [\fBlseq\fR {[llength $l]-1} 0] {
puts l($i)=[lindex $l $i]
}
\fI\(-> l(5)=-5\fR
\fI\(-> l(4)=-4\fR
\fI\(-> l(3)=-3\fR
\fI\(-> l(2)=-2\fR
\fI\(-> l(1)=-1\fR
\fI\(-> l(0)=0\fR
set sqrs [lmap i [lseq 1 10] {expr $i*$i}]
\(-> 1 4 9 16 25 36 49 64 81 100
set i 17
\fI\(-> 17\fR
if {$i in [\fBlseq\fR 0 50]} { # equivalent to: (0 <= $i && $i <= 50)
puts "Ok"
} else {
puts "outside :("
}
\fI\(-> Ok\fR
set sqrs [lmap i [\fBlseq\fR 1 10] { expr {$i*$i} }]
\fI\(-> 1 4 9 16 25 36 49 64 81 100\fR
.\"
.CE
.SH "SEE ALSO"
foreach(n), list(n), lappend(n), lassign(n), ledit(n), lindex(n), linsert(n),
llength(n), lmap(n), lpop(n), lrange(n), lremove(n), lreplace(n),
foreach(n), list(n), lappend(n), lassign(n), lindex(n), linsert(n), llength(n),
lmap(n), lpop(n), lrange(n), lremove(n), lreplace(n),
lreverse(n), lsearch(n), lset(n), lsort(n)
.SH KEYWORDS
element, index, list
+22
View File
@@ -128,6 +128,28 @@ If a new file is created as part of opening it, \fIpermissions\fR
(an integer) is used to set the permissions for the new file in
conjunction with the process's file mode creation mask.
\fIPermissions\fR defaults to 0666.
.PP
.VS "8.7, TIP 603"
When the file opened is an ordinary disk file, the \fBchan configure\fR and
\fBfconfigure\fR commands can be used to query this additional configuration
option:
.TP
\fB\-stat\fR
.
This option, when read, returns a dictionary of values much as is obtained
from the \fBfile stat\fR command, where that stat information relates to the
real opened file. Keys in the dictionary may include \fBatime\fR, \fBctime\fR,
\fBdev\fR, \fBgid\fR, \fBino\fR, \fBmode\fR, \fBmtime\fR, \fBnlink\fR,
\fBsize\fR, \fBtype\fR, and \fBuid\fR among others; the \fBmtime\fR,
\fBsize\fR and \fBtype\fR fields are guaranteed to be present and meaningful
on all platforms; other keys may be present too.
.RS
.PP
\fIImplementation note:\fR This option maps to a call to \fBfstat()\fR on
POSIX platforms, and to a call to \fBGetFileInformationByHandle()\fR on
Windows; the information reported is what those system calls produce.
.RE
.VE "8.7, TIP 603"
.SH "COMMAND PIPELINES"
.PP
If the first character of \fIfileName\fR is
+14 -1
View File
@@ -11,7 +11,20 @@
.SH NAME
refchan \- command handler API of reflected channels
.SH SYNOPSIS
\fBcmdPrefix \fIoption\fR ?\fIarg arg ...\fR?
.nf
\fBchan create \fImode cmdPrefix\fR
\fIcmdPrefix \fBblocking\fR \fIchannelId mode\fR
\fIcmdPrefix \fBcget\fR \fIchannelId option\fR
\fIcmdPrefix \fBcgetall\fR \fIchannelId\fR
\fIcmdPrefix \fBconfigure\fR \fIchannelId option value\fR
\fIcmdPrefix \fBfinalize\fR \fIchannelId\fR
\fIcmdPrefix \fBinitialize\fR \fIchannelId mode\fR
\fIcmdPrefix \fBread\fR \fIchannelId count\fR
\fIcmdPrefix \fBseek\fR \fIchannelId offset base\fR
\fIcmdPrefix \fBwatch\fR \fIchannelId eventspec\fR
\fIcmdPrefix \fBwrite\fR \fIchannelId data\fR
.fi
.BE
.SH DESCRIPTION
.PP
+4
View File
@@ -30,6 +30,10 @@ the parent directory of \fBtcl_library\fR,
the directories listed in the \fBtcl_pkgPath\fR variable.
Additional locations to look for files and package indices should
normally be added to this variable using \fBlappend\fR.
Initialization of auto_path from the TCLLIBPATH environment
variable undergoes tilde substitution (see \fBfilename\fR) on each
path. Any tilde substitution that fails because the user is unknown
will be omitted from auto_path.
.RS
.PP
Additional variables relating to package management exist. More
+3 -3
View File
@@ -35,10 +35,10 @@ if \fItime\fR is not specified.
.sp
The parameter \fImax-count\fR could additionally impose a further restriction
by the maximal number of iterations to evaluate the script.
If \fImax-count\fR is specified, the evalution will stop either this count of
If \fImax-count\fR is specified, the evaluation will stop either this count of
iterations is reached or the time is exceeded.
.sp
It will then return a canonical tcl-list of the form:
It will then return a canonical Tcl-list of the form:
.PP
.CS
\fB0.095977 \(mcs/# 52095836 # 10419167 #/sec 5000.000 net-ms\fR
@@ -85,7 +85,7 @@ used to measure the cost of \fBTcl_EvalObjEx\fR, of the invocation of canonical
lists, and of the uncompiled versions of bytecoded commands.
.PP
As opposed to the \fBtime\fR commmand, which runs the tested script for a fixed
number of iterations, the timerate command runs it for a fixed time.
number of iterations, the \fBtimerate\fR command runs it for a fixed time.
Additionally, the compiled variant of the script will be used during the entire
measurement, as if the script were part of a compiled procedure, if the \fB\-direct\fR
option is not specified. The fixed time period and possibility of compilation allow
+4
View File
@@ -295,6 +295,10 @@ environment variables:
\fB$::env(TCL8.1_TM_PATH)\fR \fB$::env(TCL8_1_TM_PATH)\fR
\fB$::env(TCL8.0_TM_PATH)\fR \fB$::env(TCL8_0_TM_PATH)\fR
.CE
.PP
Paths initialized from the environment variables undergo tilde
substitution (see \fBfilename\fR). Any path whose tilde substitution
fails because the user is unknown will be omitted from search paths.
.SH "SEE ALSO"
package(n), Tcl Improvement Proposal #189
.QW "\fITcl Modules\fR"
+1 -1
View File
@@ -231,7 +231,7 @@ When the trace triggers, three arguments are appended to
.PP
\fIName1\fR gives the name for the variable being accessed.
This is not necessarily the same as the name used in the
\fBtrace variable\fR command: the \fBupvar\fR command allows a
\fBtrace add variable\fR command: the \fBupvar\fR command allows a
procedure to reference a variable under a different name.
If the trace was originally set on an array or array element,
\fIname2\fR provides which index into the array was affected.
+12 -1
View File
@@ -11,7 +11,18 @@
.SH NAME
transchan \- command handler API of channel transforms
.SH SYNOPSIS
\fBcmdPrefix \fIoption\fR ?\fIarg arg ...\fR?
.nf
\fBchan push \fIchannelName cmdPrefix\fR
\fIcmdPrefix \fBclear \fIhandle\fR
\fIcmdPrefix \fBdrain \fIhandle\fR
\fIcmdPrefix \fBfinalize \fIhandle\fR
\fIcmdPrefix \fBflush \fIhandle\fR
\fIcmdPrefix \fBinitialize \fIhandle mode\fR
\fIcmdPrefix \fBlimit? \fIhandle\fR
\fIcmdPrefix \fBread \fIhandle buffer\fR
\fIcmdPrefix \fBwrite \fIhandle buffer\fR
.fi
.BE
.SH DESCRIPTION
.PP
+1 -1
View File
@@ -94,7 +94,7 @@ proc \fIsetByUpvar\fR { name value } {
set localVar $value
}
set originalVar 1
trace variable originalVar w \fItraceproc\fR
trace add variable originalVar write \fItraceproc\fR
\fIsetByUpvar\fR originalVar 2
.CE
.PP
+12 -12
View File
@@ -146,7 +146,7 @@ declare 32 {
}
# Only available in Tcl 8.x, NULL in Tcl 9.0
declare 33 {
unsigned char *TclGetByteArrayFromObj(Tcl_Obj *objPtr, int *numBytesPtr)
unsigned char *TclGetByteArrayFromObj(Tcl_Obj *objPtr, void *numBytesPtr)
}
declare 34 {
int Tcl_GetDouble(Tcl_Interp *interp, const char *src, double *doublePtr)
@@ -173,7 +173,7 @@ declare 40 {
const Tcl_ObjType *Tcl_GetObjType(const char *typeName)
}
declare 41 {
char *TclGetStringFromObj(Tcl_Obj *objPtr, int *lengthPtr)
char *TclGetStringFromObj(Tcl_Obj *objPtr, void *lengthPtr)
}
declare 42 {
void Tcl_InvalidateStringRep(Tcl_Obj *objPtr)
@@ -188,7 +188,7 @@ declare 44 {
}
declare 45 {
int TclListObjGetElements(Tcl_Interp *interp, Tcl_Obj *listPtr,
int *objcPtr, Tcl_Obj ***objvPtr)
void *objcPtr, Tcl_Obj ***objvPtr)
}
declare 46 {
int Tcl_ListObjIndex(Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size index,
@@ -196,7 +196,7 @@ declare 46 {
}
declare 47 {
int TclListObjLength(Tcl_Interp *interp, Tcl_Obj *listPtr,
int *lengthPtr)
void *lengthPtr)
}
declare 48 {
int Tcl_ListObjReplace(Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size first,
@@ -881,12 +881,12 @@ declare 241 {
void Tcl_SourceRCFile(Tcl_Interp *interp)
}
declare 242 {
int TclSplitList(Tcl_Interp *interp, const char *listStr, int *argcPtr,
int TclSplitList(Tcl_Interp *interp, const char *listStr, void *argcPtr,
const char ***argvPtr)
}
# Obsolete, use Tcl_FSSplitPath
declare 243 {
void TclSplitPath(const char *path, int *argcPtr, const char ***argvPtr)
void TclSplitPath(const char *path, void *argcPtr, const char ***argvPtr)
}
# Removed in 9.0 (stub entry only)
#declare 244 {
@@ -1442,7 +1442,7 @@ declare 392 {
}
declare 393 {
int Tcl_CreateThread(Tcl_ThreadId *idPtr, Tcl_ThreadCreateProc *proc,
void *clientData, Tcl_Size stackSize, int flags)
void *clientData, TCL_HASH_TYPE stackSize, int flags)
}
# Introduced in 8.3.2
@@ -1601,7 +1601,7 @@ declare 433 {
# introduced in 8.4a3
declare 434 {
Tcl_UniChar *TclGetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr)
Tcl_UniChar *TclGetUnicodeFromObj(Tcl_Obj *objPtr, void *lengthPtr)
}
# TIP#15 (math function introspection) dkf
@@ -1702,7 +1702,7 @@ declare 460 {
Tcl_Obj *Tcl_FSJoinPath(Tcl_Obj *listObj, Tcl_Size elements)
}
declare 461 {
Tcl_Obj *TclFSSplitPath(Tcl_Obj *pathPtr, int *lenPtr)
Tcl_Obj *TclFSSplitPath(Tcl_Obj *pathPtr, void *lenPtr)
}
declare 462 {
int Tcl_FSEqualPaths(Tcl_Obj *firstPtr, Tcl_Obj *secondPtr)
@@ -1841,7 +1841,7 @@ declare 496 {
Tcl_Obj *keyPtr)
}
declare 497 {
int TclDictObjSize(Tcl_Interp *interp, Tcl_Obj *dictPtr, int *sizePtr)
int TclDictObjSize(Tcl_Interp *interp, Tcl_Obj *dictPtr, void *sizePtr)
}
declare 498 {
int Tcl_DictObjFirst(Tcl_Interp *interp, Tcl_Obj *dictPtr,
@@ -2270,7 +2270,7 @@ declare 603 {
# TIP#265 (option parser) dkf for Sam Bromley
declare 604 {
int TclParseArgsObjv(Tcl_Interp *interp, const Tcl_ArgvInfo *argTable,
int *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv)
void *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv)
}
# TIP#336 (manipulate the error line) dgp
@@ -2468,7 +2468,7 @@ declare 648 {
# TIP #568
declare 649 {
unsigned char *TclGetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
int *numBytesPtr)
void *numBytesPtr)
}
declare 650 {
unsigned char *Tcl_GetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
+102 -17
View File
@@ -355,8 +355,6 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt;
struct {long tv_sec;} st_mtim;
struct {long tv_sec;} st_ctim;
} Tcl_StatBuf;
#elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__)
typedef struct stat64 Tcl_StatBuf;
#else
typedef struct stat Tcl_StatBuf;
#endif
@@ -561,7 +559,7 @@ 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,
Tcl_Size level, const char *command, Tcl_Command commandInfo, Tcl_Size objc,
struct Tcl_Obj *const *objv);
typedef void (Tcl_CmdObjTraceDeleteProc) (void *clientData);
typedef void (Tcl_DupInternalRepProc) (struct Tcl_Obj *srcPtr,
@@ -586,7 +584,7 @@ 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);
Tcl_Size 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, ...);
@@ -608,6 +606,28 @@ typedef void *(Tcl_InitNotifierProc) (void);
typedef void (Tcl_FinalizeNotifierProc) (void *clientData);
typedef void (Tcl_MainLoopProc) (void);
/* Abstract List functions */
typedef Tcl_Size (Tcl_ObjTypeLengthProc) (struct Tcl_Obj *listPtr);
typedef int (Tcl_ObjTypeIndexProc) (Tcl_Interp *interp, struct Tcl_Obj *listPtr,
Tcl_Size index, struct Tcl_Obj** elemObj);
typedef int (Tcl_ObjTypeSliceProc) (Tcl_Interp *interp, struct Tcl_Obj *listPtr,
Tcl_Size fromIdx, Tcl_Size toIdx,
struct Tcl_Obj **newObjPtr);
typedef int (Tcl_ObjTypeReverseProc) (Tcl_Interp *interp, struct Tcl_Obj *listPtr,
struct Tcl_Obj **newObjPtr);
typedef int (Tcl_ObjTypeGetElements) (Tcl_Interp *interp, struct Tcl_Obj *listPtr,
Tcl_Size *objcptr, struct Tcl_Obj ***objvptr);
typedef struct Tcl_Obj* (Tcl_ObjTypeSetElement) (Tcl_Interp *interp, struct Tcl_Obj *listPtr,
Tcl_Size indexCount,
struct Tcl_Obj *const indexArray[],
struct Tcl_Obj *valueObj);
typedef int (Tcl_ObjTypeReplaceProc) (Tcl_Interp *interp, struct Tcl_Obj *listObj,
Tcl_Size first, Tcl_Size numToDelete,
Tcl_Size numToInsert,
struct Tcl_Obj *const insertObjs[]);
typedef int (Tcl_ObjTypeInOperatorProc) (Tcl_Interp *interp, struct Tcl_Obj *valueObj,
struct Tcl_Obj *listObj, int *boolResult);
#ifndef TCL_NO_DEPRECATED
# define Tcl_PackageInitProc Tcl_LibraryInitProc
# define Tcl_PackageUnloadProc Tcl_LibraryUnloadProc
@@ -636,12 +656,40 @@ typedef struct Tcl_ObjType {
/* Called to convert the object's internal rep
* to this type. Frees the internal rep of the
* old type. Returns TCL_ERROR on failure. */
#if TCL_MAJOR_VERSION > 8
size_t version;
/* List emulation functions - ObjType Version 1 */
Tcl_ObjTypeLengthProc *lengthProc; /* Return the [llength] of the
** AbstractList */
Tcl_ObjTypeIndexProc *indexProc; /* Return a value (Tcl_Obj) for
** [lindex $al $index] */
Tcl_ObjTypeSliceProc *sliceProc; /* Return an AbstractList for
** [lrange $al $start $end] */
Tcl_ObjTypeReverseProc *reverseProc; /* Return an AbstractList for
** [lreverse $al] */
Tcl_ObjTypeGetElements *getElementsProc; /* Return an objv[] of all elements in
** the list */
Tcl_ObjTypeSetElement *setElementProc; /* Replace the element at the indicie
** with the given valueObj. */
Tcl_ObjTypeReplaceProc *replaceProc; /* Replace subset with subset */
Tcl_ObjTypeInOperatorProc *inOperProc; /* "in" and "ni" expr list
** operation Determine if the given
** string value matches an element in
** the list */
#endif
} Tcl_ObjType;
#define TCL_OBJTYPE_V0 0 /* Pre-Tcl 9. Set to 0 so compiler will auto-init
* when existing code that does not init this
* field is compiled with Tcl9 headers */
#define TCL_OBJTYPE_CURRENT TCL_OBJTYPE_V0
#if TCL_MAJOR_VERSION > 8
# define TCL_OBJTYPE_V0 0, \
0,0,0,0,0,0,0,0 /* Pre-Tcl 9 */
# define TCL_OBJTYPE_V1(a) offsetof(Tcl_ObjType, indexProc), \
a,0,0,0,0,0,0,0 /* Tcl 9 Version 1 */
# define TCL_OBJTYPE_V2(a,b,c,d,e,f,g,h) sizeof(Tcl_ObjType), \
a,b,c,d,e,f,g,h /* Tcl 9 - AbstractLists */
#else
# define TCL_OBJTYPE_V0 /* just empty */
#endif
/*
* The following structure stores an internal representation (internalrep) for
@@ -694,7 +742,6 @@ typedef struct Tcl_Obj {
Tcl_ObjInternalRep internalRep; /* The internal representation: */
} Tcl_Obj;
/*
*----------------------------------------------------------------------------
* The following definitions support Tcl's namespace facility. Note: the first
@@ -809,8 +856,8 @@ typedef struct {
typedef struct Tcl_DString {
char *string; /* Points to beginning of string: either
* staticSpace below or a malloced array. */
Tcl_Size length; /* Number of non-NULL characters in the
* string. */
Tcl_Size length; /* Number of bytes in string excluding
* terminating nul */
Tcl_Size spaceAvl; /* Total number of bytes available for the
* string and its terminating NULL char. */
char staticSpace[TCL_DSTRING_STATIC_SIZE];
@@ -1933,8 +1980,6 @@ typedef struct Tcl_EncodingType {
* reset to an initial state. If the source
* buffer contains the entire input stream to be
* converted, this flag should be set.
* TCL_ENCODING_STRICT - Be more strict in accepting what
* is considered a 'invalid byte sequence'.
* TCL_ENCODING_STOPONERROR - Not used any more.
* TCL_ENCODING_NO_TERMINATE - If set, Tcl_ExternalToUtf does not append a
* terminating NUL byte. Since it does not need
@@ -1969,15 +2014,18 @@ typedef struct Tcl_EncodingType {
#define TCL_ENCODING_CHAR_LIMIT 0x10
/* Internal use bits, do not define bits in this space. See above comment */
#define TCL_ENCODING_INTERNAL_USE_MASK 0xFF00
/* Reserve top byte for profile values (disjoint, not a mask) */
/*
* Reserve top byte for profile values (disjoint, not a mask). In case of
* changes, ensure ENCODING_PROFILE_* macros in tclInt.h are modified if
* necessary.
*/
#define TCL_ENCODING_PROFILE_TCL8 0x01000000
#define TCL_ENCODING_PROFILE_STRICT 0x02000000
#define TCL_ENCODING_PROFILE_REPLACE 0x03000000
/* Still being argued - For Tcl9, is the default strict? TODO */
#if TCL_MAJOR_VERSION < 9
#define TCL_ENCODING_PROFILE_DEFAULT TCL_ENCODING_PROFILE_TCL8
#else
#define TCL_ENCODING_PROFILE_DEFAULT TCL_ENCODING_PROFILE_TCL8 /* STRICT? REPLACE? TODO */
#define TCL_ENCODING_PROFILE_DEFAULT TCL_ENCODING_PROFILE_TCL8
#endif
/*
@@ -2343,7 +2391,7 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv);
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 *)) \
(void)((const char *(*)(Tcl_Size, const void *, Tcl_AppInitProc *, Tcl_Interp *)) \
TclStubCall((void *)5))(argc, argv, appInitProc, interp)
#endif
#define Tcl_StaticLibrary(interp, pkgName, initProc, safeInitProc) \
@@ -2426,6 +2474,25 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv);
# undef Tcl_IsShared
# define Tcl_IsShared(objPtr) \
Tcl_DbIsShared(objPtr, __FILE__, __LINE__)
/*
* Free the Obj by effectively doing:
*
* Tcl_IncrRefCount(objPtr);
* Tcl_DecrRefCount(objPtr);
*
* This will free the obj if there are no references to the obj.
*/
# define Tcl_BounceRefCount(objPtr) \
TclBounceRefCount(objPtr, __FILE__, __LINE__)
static inline void TclBounceRefCount(Tcl_Obj* objPtr, const char* fn, int line)
{
if (objPtr) {
if ((objPtr)->refCount == 0) {
Tcl_DbDecrRefCount(objPtr, fn, line);
}
}
}
#else
# undef Tcl_IncrRefCount
# define Tcl_IncrRefCount(objPtr) \
@@ -2445,6 +2512,24 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv);
# undef Tcl_IsShared
# define Tcl_IsShared(objPtr) \
((objPtr)->refCount > 1)
/*
* Declare that obj will no longer be used or referenced.
* This will release the obj if there is no referece count,
* otherwise let it be.
*/
# define Tcl_BounceRefCount(objPtr) \
TclBounceRefCount(objPtr);
static inline void TclBounceRefCount(Tcl_Obj* objPtr)
{
if (objPtr) {
if ((objPtr)->refCount == 0) {
Tcl_DecrRefCount(objPtr);
}
}
}
#endif
/*
+526 -330
View File
File diff suppressed because it is too large Load Diff
-57
View File
@@ -1,57 +0,0 @@
/*
* tclArithSeries.h --
*
* 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.
*/
/*
* The structure used for the ArithSeries internal representation.
* Note that the len can in theory be always computed by start,end,step
* but it's faster to cache it inside the internal representation.
*/
typedef struct {
Tcl_WideInt len;
Tcl_Obj **elements;
int isDouble;
Tcl_WideInt start;
Tcl_WideInt end;
Tcl_WideInt step;
} ArithSeries;
typedef struct {
Tcl_WideInt len;
Tcl_Obj **elements;
int isDouble;
double start;
double end;
double step;
} ArithSeriesDbl;
MODULE_SCOPE Tcl_Obj * TclArithSeriesObjCopy(Tcl_Interp *interp,
Tcl_Obj *arithSeriesPtr);
MODULE_SCOPE Tcl_Obj *TclArithSeriesObjIndex(Tcl_Interp *, Tcl_Obj *,
Tcl_WideInt index);
MODULE_SCOPE Tcl_Obj * TclArithSeriesObjRange(Tcl_Interp *interp,
Tcl_Obj *arithSeriesPtr, Tcl_Size fromIdx, Tcl_Size toIdx);
MODULE_SCOPE Tcl_Obj * TclArithSeriesObjReverse(Tcl_Interp *interp,
Tcl_Obj *arithSeriesPtr);
MODULE_SCOPE int TclArithSeriesGetElements(Tcl_Interp *interp,
Tcl_Obj *objPtr, Tcl_Size *objcPtr, Tcl_Obj ***objvPtr);
MODULE_SCOPE int TclNewArithSeriesObj(Tcl_Interp *interp,
Tcl_Obj **arithSeriesObj, int useDoubles,
Tcl_Obj *startObj, Tcl_Obj *endObj,
Tcl_Obj *stepObj, Tcl_Obj *lenObj);
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
+2 -2
View File
@@ -224,7 +224,7 @@ typedef struct AssemblyEnv {
* offsets of the labels. */
Tcl_Size cmdLine; /* Current line number within the assembly
* code */
int* clNext; /* Invisible continuation line for
Tcl_Size* clNext; /* Invisible continuation line for
* [info frame] */
BasicBlock* head_bb; /* First basic block in the code */
BasicBlock* curr_bb; /* Current basic block */
@@ -2247,7 +2247,7 @@ static int
GetListIndexOperand(
AssemblyEnv* assemEnvPtr, /* Assembly environment */
Tcl_Token** tokenPtrPtr, /* Current token from the parser */
int* result) /* OUTPUT: Integer extracted from the token */
int* result) /* OUTPUT: encoded index derived from the token */
{
CompileEnv* envPtr = assemEnvPtr->envPtr;
/* Compilation environment */
+53 -33
View File
@@ -805,7 +805,7 @@ Tcl_CreateInterp(void)
iPtr->legacyFreeProc = (void (*) (void))-1;
iPtr->errorLine = 0;
iPtr->stubTable = &tclStubs;
iPtr->objResultPtr = Tcl_NewObj();
TclNewObj(iPtr->objResultPtr);
Tcl_IncrRefCount(iPtr->objResultPtr);
iPtr->handle = TclHandleCreate(iPtr);
iPtr->globalNsPtr = NULL;
@@ -890,7 +890,7 @@ Tcl_CreateInterp(void)
iPtr->activeInterpTracePtr = NULL;
iPtr->assocData = NULL;
iPtr->execEnvPtr = NULL; /* Set after namespaces initialized. */
iPtr->emptyObjPtr = Tcl_NewObj();
TclNewObj(iPtr->emptyObjPtr);
/* Another empty object. */
Tcl_IncrRefCount(iPtr->emptyObjPtr);
iPtr->threadId = Tcl_GetCurrentThread();
@@ -954,7 +954,7 @@ Tcl_CreateInterp(void)
* TIP #285, Script cancellation support.
*/
iPtr->asyncCancelMsg = Tcl_NewObj();
TclNewObj(iPtr->asyncCancelMsg);
cancelInfo = (CancelInfo *)Tcl_Alloc(sizeof(CancelInfo));
cancelInfo->interp = interp;
@@ -3298,7 +3298,7 @@ invokeObj2Command(
Command *cmdPtr = (Command *) clientData;
if (objc > INT_MAX) {
objc = TCL_INDEX_NONE; /* TODO - why? Should error, not truncate */
return TclCommandWordLimitError(interp, objc);
}
if (cmdPtr->objProc != NULL) {
result = cmdPtr->objProc(cmdPtr->objClientData, interp, objc, objv);
@@ -3315,6 +3315,9 @@ static int cmdWrapper2Proc(void *clientData,
Tcl_Obj *const objv[])
{
Command *cmdPtr = (Command *)clientData;
if (objc > INT_MAX) {
return TclCommandWordLimitError(interp, objc);
}
return cmdPtr->objProc(cmdPtr->objClientData, interp, objc, objv);
}
@@ -5144,7 +5147,7 @@ TclEvalEx(
* 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 */
Tcl_Size *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'
@@ -5164,17 +5167,18 @@ TclEvalEx(
{
Interp *iPtr = (Interp *) interp;
const char *p, *next;
const unsigned int minObjs = 20;
const int minObjs = 20;
Tcl_Obj **objv, **objvSpace;
int *expand, *lines, *lineSpace;
int *expand;
Tcl_Size *lines, *lineSpace;
Tcl_Token *tokenPtr;
int bytesLeft, expandRequested, code = TCL_OK;
Tcl_Size commandLength;
int expandRequested, code = TCL_OK;
Tcl_Size bytesLeft, 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;
Tcl_Size i, objectsUsed = 0;
/* These variables keep track of how much
* state has been allocated while evaluating
* the script, so that it can be freed
@@ -5184,10 +5188,10 @@ TclEvalEx(
Tcl_Obj **stackObjArray = (Tcl_Obj **)
TclStackAlloc(interp, minObjs * sizeof(Tcl_Obj *));
int *expandStack = (int *)TclStackAlloc(interp, minObjs * sizeof(int));
int *linesStack = (int *)TclStackAlloc(interp, minObjs * sizeof(int));
Tcl_Size *linesStack = (Tcl_Size *)TclStackAlloc(interp, minObjs * sizeof(Tcl_Size));
/* TIP #280 Structures for tracking of command
* locations. */
int *clNext = NULL; /* Pointer for the tracking of invisible
Tcl_Size *clNext = NULL; /* Pointer for the tracking of invisible
* continuation lines. Initialized only if the
* caller gave us a table of locations to
* track, via scriptCLLocPtr. It always refers
@@ -5311,9 +5315,9 @@ TclEvalEx(
Tcl_Size wordLine = line;
const char *wordStart = parsePtr->commandStart;
int *wordCLNext = clNext;
unsigned int objectsNeeded = 0;
unsigned int numWords = parsePtr->numWords;
Tcl_Size *wordCLNext = clNext;
Tcl_Size objectsNeeded = 0;
Tcl_Size numWords = parsePtr->numWords;
/*
* Generate an array of objects for the words of the command.
@@ -5322,7 +5326,7 @@ TclEvalEx(
if (numWords > minObjs) {
expand = (int *)Tcl_Alloc(numWords * sizeof(int));
objvSpace = (Tcl_Obj **)Tcl_Alloc(numWords * sizeof(Tcl_Obj *));
lineSpace = (int *)Tcl_Alloc(numWords * sizeof(int));
lineSpace = (Tcl_Size *)Tcl_Alloc(numWords * sizeof(Tcl_Size));
}
expandRequested = 0;
objv = objvSpace;
@@ -5332,6 +5336,8 @@ TclEvalEx(
for (objectsUsed = 0, tokenPtr = parsePtr->tokenPtr;
objectsUsed < numWords;
objectsUsed++, tokenPtr += tokenPtr->numComponents+1) {
Tcl_Size additionalObjsCount;
/*
* TIP #280. Track lines to current word. Save the information
* on a per-word basis, signaling dynamic words as needed.
@@ -5346,7 +5352,7 @@ TclEvalEx(
wordStart = tokenPtr->start;
lines[objectsUsed] = TclWordKnownAtCompileTime(tokenPtr, NULL)
? (int)wordLine : -1;
? wordLine : -1;
if (eeFramePtr->type == TCL_LOCATION_SOURCE) {
iPtr->evalFlags |= TCL_EVAL_FILE;
@@ -5381,12 +5387,22 @@ TclEvalEx(
expandRequested = 1;
expand[objectsUsed] = 1;
objectsNeeded += (numElements ? numElements : 1);
additionalObjsCount = (numElements ? numElements : 1);
} else {
expand[objectsUsed] = 0;
objectsNeeded++;
additionalObjsCount = 1;
}
/* Currently max command words in INT_MAX */
if (additionalObjsCount > INT_MAX ||
objectsNeeded > (INT_MAX - additionalObjsCount)) {
code = TclCommandWordLimitError(interp, -1);
Tcl_DecrRefCount(objv[objectsUsed]);
break;
}
objectsNeeded += additionalObjsCount;
if (wordCLNext) {
TclContinuationsEnterDerived(objv[objectsUsed],
wordStart - outerScript, wordCLNext);
@@ -5402,14 +5418,14 @@ TclEvalEx(
*/
Tcl_Obj **copy = objvSpace;
int *lcopy = lineSpace;
int wordIdx = numWords;
int objIdx = objectsNeeded - 1;
Tcl_Size *lcopy = lineSpace;
Tcl_Size wordIdx = numWords;
Tcl_Size objIdx = objectsNeeded - 1;
if ((numWords > minObjs) || (objectsNeeded > minObjs)) {
objv = objvSpace =
(Tcl_Obj **)Tcl_Alloc(objectsNeeded * sizeof(Tcl_Obj *));
lines = lineSpace = (int *)Tcl_Alloc(objectsNeeded * sizeof(int));
lines = lineSpace = (Tcl_Size *)Tcl_Alloc(objectsNeeded * sizeof(Tcl_Size));
}
objectsUsed = 0;
@@ -5644,7 +5660,7 @@ TclAdvanceLines(
void
TclAdvanceContinuations(
Tcl_Size *line,
int **clNextPtrPtr,
Tcl_Size **clNextPtrPtr,
int loc)
{
/*
@@ -5822,7 +5838,7 @@ TclArgumentBCEnter(
int objc,
void *codePtr,
CmdFrame *cfPtr,
int cmd,
Tcl_Size cmd,
Tcl_Size pc)
{
ExtCmdLoc *eclPtr;
@@ -6137,7 +6153,11 @@ TclNREvalObjEx(
*/
Tcl_IncrRefCount(objPtr);
listPtr = TclListObjCopy(interp, objPtr);
listPtr = TclDuplicatePureObj(interp, objPtr, &tclListType);
if (!listPtr) {
Tcl_DecrRefCount(objPtr);
return TCL_ERROR;
}
Tcl_IncrRefCount(listPtr);
if (word != INT_MIN) {
@@ -7031,7 +7051,7 @@ ExprCeilFunc(
code = Tcl_GetDoubleFromObj(interp, objv[1], &d);
#ifdef ACCEPT_NAN
if (code != TCL_OK) {
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType.objType);
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType);
if (irPtr) {
Tcl_SetObjResult(interp, objv[1]);
@@ -7071,7 +7091,7 @@ ExprFloorFunc(
code = Tcl_GetDoubleFromObj(interp, objv[1], &d);
#ifdef ACCEPT_NAN
if (code != TCL_OK) {
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType.objType);
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType);
if (irPtr) {
Tcl_SetObjResult(interp, objv[1]);
@@ -7217,7 +7237,7 @@ ExprSqrtFunc(
code = Tcl_GetDoubleFromObj(interp, objv[1], &d);
#ifdef ACCEPT_NAN
if (code != TCL_OK) {
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType.objType);
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType);
if (irPtr) {
Tcl_SetObjResult(interp, objv[1]);
@@ -7271,7 +7291,7 @@ ExprUnaryFunc(
code = Tcl_GetDoubleFromObj(interp, objv[1], &d);
#ifdef ACCEPT_NAN
if (code != TCL_OK) {
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType.objType);
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType);
if (irPtr) {
d = irPtr->doubleValue;
@@ -7335,7 +7355,7 @@ ExprBinaryFunc(
code = Tcl_GetDoubleFromObj(interp, objv[1], &d1);
#ifdef ACCEPT_NAN
if (code != TCL_OK) {
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType.objType);
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType);
if (irPtr) {
d1 = irPtr->doubleValue;
@@ -7350,7 +7370,7 @@ ExprBinaryFunc(
code = Tcl_GetDoubleFromObj(interp, objv[2], &d2);
#ifdef ACCEPT_NAN
if (code != TCL_OK) {
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType.objType);
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objv[1], &tclDoubleType);
if (irPtr) {
d2 = irPtr->doubleValue;
@@ -7511,7 +7531,7 @@ ExprDoubleFunc(
}
if (Tcl_GetDoubleFromObj(interp, objv[1], &dResult) != TCL_OK) {
#ifdef ACCEPT_NAN
if (TclHasInternalRep(objv[1], &tclDoubleType.objType)) {
if (TclHasInternalRep(objv[1], &tclDoubleType)) {
Tcl_SetObjResult(interp, objv[1]);
return TCL_OK;
}
+26 -55
View File
@@ -386,7 +386,7 @@ 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
void *numBytesPtr) /* If non-NULL, write the number of bytes
* in the array here */
{
Tcl_Size numBytes = 0;
@@ -404,7 +404,7 @@ TclGetBytesFromObj(
}
return NULL;
} else {
*numBytesPtr = (int) numBytes;
*(int *)numBytesPtr = (int) numBytes;
}
}
return bytes;
@@ -767,43 +767,14 @@ TclAppendBytesToByteArray(
}
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.
*/
attempt = needed;
ptr = (ByteArray *)Tcl_Realloc(byteArrayPtr, BYTEARRAY_SIZE(attempt));
}
byteArrayPtr = ptr;
byteArrayPtr->allocated = attempt;
Tcl_Size newCapacity;
byteArrayPtr =
(ByteArray *)TclReallocElemsEx(byteArrayPtr,
needed,
1,
offsetof(ByteArray, bytes),
&newCapacity);
byteArrayPtr->allocated = newCapacity;
SET_BYTEARRAY(irPtr, byteArrayPtr);
}
@@ -870,7 +841,7 @@ BinaryFormatCmd(
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
Tcl_Size count; /* Count associated with current format
* character. */
int flags; /* Format field flags */
const char *format; /* Pointer to current position in format
@@ -1383,7 +1354,7 @@ BinaryScanCmd(
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
Tcl_Size count; /* Count associated with current format
* character. */
int flags; /* Format field flags */
const char *format; /* Pointer to current position in format
@@ -1795,14 +1766,14 @@ GetFormatSpec(
(*formatPtr)++;
*countPtr = BINARY_ALL;
} else if (isdigit(UCHAR(**formatPtr))) { /* INTL: digit */
unsigned long count;
unsigned long long count;
errno = 0;
count = strtoul(*formatPtr, (char **) formatPtr, 10);
if (errno || (count > (unsigned long) INT_MAX)) {
*countPtr = INT_MAX;
count = strtoull(*formatPtr, (char **) formatPtr, 10);
if (errno || (count > TCL_SIZE_MAX)) {
*countPtr = TCL_SIZE_MAX;
} else {
*countPtr = (int) count;
*countPtr = count;
}
} else {
*countPtr = BINARY_NOCOUNT;
@@ -2030,7 +2001,7 @@ FormatNumber(
*/
if (Tcl_GetDoubleFromObj(interp, src, &dvalue) != TCL_OK) {
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(src, &tclDoubleType.objType);
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(src, &tclDoubleType);
if (irPtr == NULL) {
return TCL_ERROR;
}
@@ -2050,7 +2021,7 @@ FormatNumber(
*/
if (Tcl_GetDoubleFromObj(interp, src, &dvalue) != TCL_OK) {
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(src, &tclDoubleType.objType);
const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(src, &tclDoubleType);
if (irPtr == NULL) {
return TCL_ERROR;
@@ -2638,11 +2609,11 @@ BinaryEncode64(
{
Tcl_Obj *resultObj;
unsigned char *data, *limit;
int maxlen = 0;
Tcl_Size maxlen = 0;
const char *wrapchar = "\n";
Tcl_Size wrapcharlen = 1;
int i, index, size, outindex = 0, purewrap = 1;
Tcl_Size offset, count = 0;
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 };
@@ -2658,7 +2629,7 @@ BinaryEncode64(
}
switch (index) {
case OPT_MAXLEN:
if (Tcl_GetIntFromObj(interp, objv[i + 1], &maxlen) != TCL_OK) {
if (TclGetSizeIntFromObj(interp, objv[i + 1], &maxlen) != TCL_OK) {
return TCL_ERROR;
}
if (maxlen < 0) {
@@ -2764,12 +2735,12 @@ BinaryEncodeUu(
{
Tcl_Obj *resultObj;
unsigned char *data, *start, *cursor;
int rawLength, i, bits, index;
int i, bits, index;
unsigned int n;
int lineLength = 61;
const unsigned char SingleNewline[] = { UCHAR('\n') };
const unsigned char *wrapchar = SingleNewline;
Tcl_Size j, offset, count = 0, wrapcharlen = sizeof(SingleNewline);
Tcl_Size j, rawLength, offset, count = 0, wrapcharlen = sizeof(SingleNewline);
enum { OPT_MAXLEN, OPT_WRAPCHAR };
static const char *const optStrings[] = { "-maxlen", "-wrapchar", NULL };
@@ -2859,7 +2830,7 @@ BinaryEncodeUu(
*/
while (offset < count) {
int lineLen = count - offset;
Tcl_Size lineLen = count - offset;
if (lineLen > rawLength) {
lineLen = rawLength;
+143
View File
@@ -16,6 +16,7 @@
*/
#include "tclInt.h"
#include <assert.h>
#define FALSE 0
#define TRUE 1
@@ -1233,6 +1234,148 @@ TclDumpMemoryInfo(
#endif /* TCL_MEM_DEBUG */
/*
*------------------------------------------------------------------------
*
* TclAllocElemsEx --
*
* See TclAttemptAllocElemsEx. This function differs in that it panics
* on failure.
*
* Results:
* Non-NULL pointer to allocated memory block.
*
* Side effects:
* Panics if memory of at least the requested size could not be
* allocated.
*
*------------------------------------------------------------------------
*/
void *
TclAllocElemsEx(
Tcl_Size elemCount, /* Allocation will store at least these many... */
Tcl_Size elemSize, /* ...elements of this size */
Tcl_Size leadSize, /* Additional leading space in bytes */
Tcl_Size *capacityPtr) /* OUTPUT: Actual capacity is stored
here if non-NULL. Only modified on success */
{
void *ptr = TclAttemptReallocElemsEx(
NULL, elemCount, elemSize, leadSize, capacityPtr);
if (ptr == NULL) {
Tcl_Panic("Failed to allocate %" TCL_SIZE_MODIFIER
"d elements of size %" TCL_SIZE_MODIFIER "d bytes.",
elemCount,
elemSize);
}
return ptr;
}
/*
*------------------------------------------------------------------------
*
* TclAttemptReallocElemsEx --
*
* Attempts to allocate (oldPtr == NULL) or reallocate memory of the
* requested size plus some more for future growth. The amount of
* reallocation is adjusted depending on on failure.
*
*
* Results:
* Pointer to allocated memory block which is at least as large
* as the requested size or NULL if allocation failed.
*
*------------------------------------------------------------------------
*/
void *
TclAttemptReallocElemsEx(
void *oldPtr, /* Pointer to memory block to reallocate or
* NULL to indicate this is a new allocation */
Tcl_Size elemCount, /* Allocation will store at least these many... */
Tcl_Size elemSize, /* ...elements of this size */
Tcl_Size leadSize, /* Additional leading space in bytes */
Tcl_Size *capacityPtr) /* OUTPUT: Actual capacity is stored
here if non-NULL. Only modified on success */
{
void *ptr;
Tcl_Size limit;
Tcl_Size attempt;
assert(elemCount > 0);
assert(elemSize > 0);
assert(elemSize < TCL_SIZE_MAX);
assert(leadSize >= 0);
assert(leadSize < TCL_SIZE_MAX);
limit = (TCL_SIZE_MAX - leadSize) / elemSize;
if (elemCount > limit) {
return NULL;
}
/* Loop trying for extra space, reducing request each time */
attempt = TclUpsizeAlloc(0, elemCount, limit);
ptr = NULL;
while (attempt > elemCount) {
if (oldPtr) {
ptr = Tcl_AttemptRealloc(oldPtr, leadSize + attempt * elemSize);
} else {
ptr = Tcl_AttemptAlloc(leadSize + attempt * elemSize);
}
if (ptr) {
break;
}
attempt = TclUpsizeRetry(elemCount, attempt);
}
/* Try exact size as a last resort */
if (ptr == NULL) {
attempt = elemCount;
if (oldPtr) {
ptr = Tcl_AttemptRealloc(oldPtr, leadSize + attempt * elemSize);
} else {
ptr = Tcl_AttemptAlloc(leadSize + attempt * elemSize);
}
}
if (ptr && capacityPtr) {
*capacityPtr = attempt;
}
return ptr;
}
/*
*------------------------------------------------------------------------
*
* TclReallocElemsEx --
*
* See TclAttemptReallocElemsEx. This function differs in that it panics
* on failure.
*
* Results:
* Non-NULL pointer to allocated memory block.
*
* Side effects:
* Panics if memory of at least the requested size could not be
* allocated.
*
*------------------------------------------------------------------------
*/
void *
TclReallocElemsEx(
void *oldPtr, /* Pointer to memory block to reallocate */
Tcl_Size elemCount, /* Allocation will store at least these many... */
Tcl_Size elemSize, /* ...elements of this size */
Tcl_Size leadSize, /* Additional leading space in bytes */
Tcl_Size *capacityPtr) /* OUTPUT: Actual capacity is stored
here if non-NULL. Only modified on success */
{
void *ptr = TclAttemptReallocElemsEx(
oldPtr, elemCount, elemSize, leadSize, capacityPtr);
if (ptr == NULL) {
Tcl_Panic("Failed to reallocate %" TCL_SIZE_MODIFIER
"d elements of size %" TCL_SIZE_MODIFIER "d bytes.",
elemCount,
elemSize);
}
return ptr;
}
/*
*---------------------------------------------------------------------------
*
+1 -1
View File
@@ -433,7 +433,7 @@ ClockGetdatefieldsObjCmd(
* that it isn't.
*/
if (TclHasInternalRep(objv[1], &tclBignumType.objType)) {
if (TclHasInternalRep(objv[1], &tclBignumType)) {
Tcl_SetObjResult(interp, lit[LIT_INTEGER_VALUE_TOO_LARGE]);
return TCL_ERROR;
}
+68 -61
View File
@@ -17,7 +17,6 @@
#ifdef _WIN32
# include "tclWinInt.h"
#endif
#include "tclArithSeries.h"
/*
* The state structure used by [foreach]. Note that the actual structure has
@@ -435,11 +434,7 @@ EncodingConvertParseOptions (
Tcl_Encoding encoding;
Tcl_Obj *dataObj;
Tcl_Obj *failVarObj;
#if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED)
int profile = TCL_ENCODING_PROFILE_TCL8; /* TODO - default for Tcl9? */
#else
int profile = TCL_ENCODING_PROFILE_TCL8;
#endif
/*
* Possible combinations:
@@ -556,11 +551,11 @@ EncodingConvertfromObjCmd(
/* NOTE: ds must be freed beyond this point even on error */
switch (result) {
case TCL_OK:
errorLocation = TCL_INDEX_NONE;
break;
errorLocation = TCL_INDEX_NONE;
break;
case TCL_ERROR:
/* Error in parameters. Should not happen. interp will have error */
Tcl_DStringFree(&ds);
Tcl_DStringFree(&ds);
return TCL_ERROR;
default:
/*
@@ -570,10 +565,10 @@ EncodingConvertfromObjCmd(
* what could be decoded and the returned error location.
*/
if (failVarObj == NULL) {
Tcl_DStringFree(&ds);
Tcl_DStringFree(&ds);
return TCL_ERROR;
}
break;
break;
}
/*
@@ -658,7 +653,7 @@ EncodingConverttoObjCmd(
break;
case TCL_ERROR:
/* Error in parameters. Should not happen. interp will have error */
Tcl_DStringFree(&ds);
Tcl_DStringFree(&ds);
return TCL_ERROR;
default:
/*
@@ -668,10 +663,10 @@ EncodingConverttoObjCmd(
* what could be decoded and the returned error location.
*/
if (failVarObj == NULL) {
Tcl_DStringFree(&ds);
Tcl_DStringFree(&ds);
return TCL_ERROR;
}
break;
break;
}
/*
* TCL_OK or a TCL_CONVERT_* error where the caller wants back as much
@@ -1204,10 +1199,10 @@ FileAttrAccessTimeCmd(
#if defined(_WIN32)
/* We use a value of 0 to indicate the access time not available */
if (Tcl_GetAccessTimeFromStat(&buf) == 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"could not get access time for file \"%s\"",
TclGetString(objv[1])));
return TCL_ERROR;
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"could not get access time for file \"%s\"",
TclGetString(objv[1])));
return TCL_ERROR;
}
#endif
@@ -1286,10 +1281,10 @@ FileAttrModifyTimeCmd(
#if defined(_WIN32)
/* We use a value of 0 to indicate the modification time not available */
if (Tcl_GetModificationTimeFromStat(&buf) == 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"could not get modification time for file \"%s\"",
TclGetString(objv[1])));
return TCL_ERROR;
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"could not get modification time for file \"%s\"",
TclGetString(objv[1])));
return TCL_ERROR;
}
#endif
if (objc == 3) {
@@ -2329,39 +2324,37 @@ StoreStatData(
unsigned short mode;
if (varName == NULL) {
result = Tcl_NewObj();
Tcl_IncrRefCount(result);
TclNewObj(result);
Tcl_IncrRefCount(result);
#define DOBJPUT(key, objValue) \
Tcl_DictObjPut(NULL, result, \
Tcl_NewStringObj((key), -1), \
(objValue));
DOBJPUT("dev", Tcl_NewWideIntObj((long)statPtr->st_dev));
DOBJPUT("ino", Tcl_NewWideIntObj((Tcl_WideInt)statPtr->st_ino));
DOBJPUT("nlink", Tcl_NewWideIntObj((long)statPtr->st_nlink));
DOBJPUT("uid", Tcl_NewWideIntObj((long)statPtr->st_uid));
DOBJPUT("gid", Tcl_NewWideIntObj((long)statPtr->st_gid));
DOBJPUT("size", Tcl_NewWideIntObj((Tcl_WideInt)statPtr->st_size));
DOBJPUT("dev", Tcl_NewWideIntObj((long)statPtr->st_dev));
DOBJPUT("ino", Tcl_NewWideIntObj((Tcl_WideInt)statPtr->st_ino));
DOBJPUT("nlink", Tcl_NewWideIntObj((long)statPtr->st_nlink));
DOBJPUT("uid", Tcl_NewWideIntObj((long)statPtr->st_uid));
DOBJPUT("gid", Tcl_NewWideIntObj((long)statPtr->st_gid));
DOBJPUT("size", Tcl_NewWideIntObj((Tcl_WideInt)statPtr->st_size));
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
DOBJPUT("blocks", Tcl_NewWideIntObj((Tcl_WideInt)statPtr->st_blocks));
DOBJPUT("blocks", Tcl_NewWideIntObj((Tcl_WideInt)statPtr->st_blocks));
#endif
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
DOBJPUT("blksize", Tcl_NewWideIntObj((long)statPtr->st_blksize));
DOBJPUT("blksize", Tcl_NewWideIntObj((long)statPtr->st_blksize));
#endif
DOBJPUT("atime", Tcl_NewWideIntObj(Tcl_GetAccessTimeFromStat(statPtr)));
DOBJPUT("mtime", Tcl_NewWideIntObj(Tcl_GetModificationTimeFromStat(statPtr)));
DOBJPUT("ctime", Tcl_NewWideIntObj(Tcl_GetChangeTimeFromStat(statPtr)));
mode = (unsigned short) statPtr->st_mode;
DOBJPUT("mode", Tcl_NewWideIntObj(mode));
DOBJPUT("type", Tcl_NewStringObj(GetTypeFromMode(mode), -1));
DOBJPUT("atime", Tcl_NewWideIntObj(Tcl_GetAccessTimeFromStat(statPtr)));
DOBJPUT("mtime", Tcl_NewWideIntObj(Tcl_GetModificationTimeFromStat(statPtr)));
DOBJPUT("ctime", Tcl_NewWideIntObj(Tcl_GetChangeTimeFromStat(statPtr)));
mode = (unsigned short) statPtr->st_mode;
DOBJPUT("mode", Tcl_NewWideIntObj(mode));
DOBJPUT("type", Tcl_NewStringObj(GetTypeFromMode(mode), -1));
#undef DOBJPUT
Tcl_SetObjResult(interp, result);
Tcl_DecrRefCount(result);
return TCL_OK;
Tcl_SetObjResult(interp, result);
Tcl_DecrRefCount(result);
return TCL_OK;
}
/*
* Assume Tcl_ObjSetVar2() does not keep a copy of the field name!
*
* Might be a better idea to call Tcl_SetVar2Ex() instead, except we want
* to have an object (i.e. possibly cached) array variable name but a
* string element name, so no API exists. Messy.
@@ -2393,9 +2386,15 @@ StoreStatData(
#endif
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
STORE_ARY("blksize", Tcl_NewWideIntObj((long)statPtr->st_blksize));
#endif
#ifdef HAVE_STRUCT_STAT_ST_RDEV
if (S_ISCHR(statPtr->st_mode) || S_ISBLK(statPtr->st_mode)) {
STORE_ARY("rdev", Tcl_NewWideIntObj((long) statPtr->st_rdev));
}
#endif
STORE_ARY("atime", Tcl_NewWideIntObj(Tcl_GetAccessTimeFromStat(statPtr)));
STORE_ARY("mtime", Tcl_NewWideIntObj(Tcl_GetModificationTimeFromStat(statPtr)));
STORE_ARY("mtime", Tcl_NewWideIntObj(
Tcl_GetModificationTimeFromStat(statPtr)));
STORE_ARY("ctime", Tcl_NewWideIntObj(Tcl_GetChangeTimeFromStat(statPtr)));
mode = (unsigned short) statPtr->st_mode;
STORE_ARY("mode", Tcl_NewWideIntObj(mode));
@@ -2788,13 +2787,17 @@ EachloopCmd(
for (i=0 ; i<numLists ; i++) {
/* List */
/* Variables */
statePtr->vCopyList[i] = TclListObjCopy(interp, objv[1+i*2]);
if (statePtr->vCopyList[i] == NULL) {
statePtr->vCopyList[i] = Tcl_DuplicateObj(objv[1+i*2]);
if (!statePtr->vCopyList[i]) {
result = TCL_ERROR;
goto done;
}
TclListObjLengthM(NULL, statePtr->vCopyList[i],
result = TclListObjLengthM(interp, statePtr->vCopyList[i],
&statePtr->varcList[i]);
if (result != TCL_OK) {
result = TCL_ERROR;
goto done;
}
if (statePtr->varcList[i] < 1) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s varlist is empty",
@@ -2809,24 +2812,27 @@ EachloopCmd(
&statePtr->varcList[i], &statePtr->varvList[i]);
/* Values */
if (TclHasInternalRep(objv[2+i*2],&tclArithSeriesType.objType)) {
/* Special case for Arith Series */
statePtr->aCopyList[i] = TclArithSeriesObjCopy(interp, objv[2+i*2]);
if (TclObjTypeHasProc(objv[2+i*2],indexProc)) {
/* Special case for AbstractList */
statePtr->aCopyList[i] = Tcl_DuplicateObj(objv[2+i*2]);
if (statePtr->aCopyList[i] == NULL) {
result = TCL_ERROR;
goto done;
}
/* Don't compute values here, wait until the last moment */
statePtr->argcList[i] = ABSTRACTLIST_PROC(statePtr->aCopyList[i], lengthProc)(statePtr->aCopyList[i]);
statePtr->argcList[i] = TclObjTypeLength(statePtr->aCopyList[i]);
} else {
/* List values */
statePtr->aCopyList[i] = TclListObjCopy(interp, objv[2+i*2]);
if (statePtr->aCopyList[i] == NULL) {
statePtr->aCopyList[i] = TclDuplicatePureObj(
interp, objv[2+i*2], &tclListType);
if (!statePtr->aCopyList[i]) {
result = TCL_ERROR;
goto done;
}
TclListObjGetElementsM(NULL, statePtr->aCopyList[i],
result = TclListObjGetElementsM(interp, statePtr->aCopyList[i],
&statePtr->argcList[i], &statePtr->argvList[i]);
if (result != TCL_OK) {
goto done;
}
}
/* account for variable <> value mismatch */
j = statePtr->argcList[i] / statePtr->varcList[i];
@@ -2955,17 +2961,18 @@ ForeachAssignments(
Tcl_Obj *valuePtr, *varValuePtr;
for (i=0 ; i<statePtr->numLists ; i++) {
int isarithseries = TclHasInternalRep(statePtr->aCopyList[i],&tclArithSeriesType.objType);
int isAbstractList =
TclObjTypeHasProc(statePtr->aCopyList[i],indexProc) != NULL;
for (v=0 ; v<statePtr->varcList[i] ; v++) {
k = statePtr->index[i]++;
if (k < statePtr->argcList[i]) {
if (isarithseries) {
valuePtr = TclArithSeriesObjIndex(interp, statePtr->aCopyList[i], k);
if (valuePtr == NULL) {
if (isAbstractList) {
if (TclObjTypeIndex(interp, statePtr->aCopyList[i], k, &valuePtr) != TCL_OK) {
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (setting %s loop variable \"%s\")",
(statePtr->resultList != NULL ? "lmap" : "foreach"),
TclGetString(statePtr->varvList[i][v])));
"\n (setting %s loop variable \"%s\")",
(statePtr->resultList != NULL ? "lmap" : "foreach"),
TclGetString(statePtr->varvList[i][v])));
return TCL_ERROR;
}
} else {
+275 -227
View File
@@ -19,7 +19,6 @@
#include "tclInt.h"
#include "tclRegexp.h"
#include "tclArithSeries.h"
#include "tclTomMath.h"
#include <math.h>
#include <assert.h>
@@ -712,7 +711,7 @@ InfoCommandsCmd(
if (entryPtr != NULL) {
if (specificNsInPattern) {
cmd = (Tcl_Command)Tcl_GetHashValue(entryPtr);
elemObjPtr = Tcl_NewObj();
TclNewObj(elemObjPtr);
Tcl_GetCommandFullName(interp, cmd, elemObjPtr);
} else {
cmdName = (const char *)Tcl_GetHashKey(&nsPtr->cmdTable, entryPtr);
@@ -763,7 +762,7 @@ InfoCommandsCmd(
|| Tcl_StringMatch(cmdName, simplePattern)) {
if (specificNsInPattern) {
cmd = (Tcl_Command)Tcl_GetHashValue(entryPtr);
elemObjPtr = Tcl_NewObj();
TclNewObj(elemObjPtr);
Tcl_GetCommandFullName(interp, cmd, elemObjPtr);
} else {
elemObjPtr = Tcl_NewStringObj(cmdName, -1);
@@ -990,7 +989,8 @@ InfoDefaultCmd(
}
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(1));
} else {
Tcl_Obj *nullObjPtr = Tcl_NewObj();
Tcl_Obj *nullObjPtr;
TclNewObj(nullObjPtr);
valueObjPtr = Tcl_ObjSetVar2(interp, objv[3], NULL,
nullObjPtr, TCL_LEAVE_ERR_MSG);
@@ -1906,7 +1906,7 @@ InfoProcsCmd(
} else {
simpleProcOK:
if (specificNsInPattern) {
elemObjPtr = Tcl_NewObj();
TclNewObj(elemObjPtr);
Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr,
elemObjPtr);
} else {
@@ -1934,7 +1934,7 @@ InfoProcsCmd(
} else {
procOK:
if (specificNsInPattern) {
elemObjPtr = Tcl_NewObj();
TclNewObj(elemObjPtr);
Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr,
elemObjPtr);
} else {
@@ -2202,7 +2202,7 @@ Tcl_JoinObjCmd(
Tcl_Obj *const objv[]) /* The argument objects. */
{
Tcl_Size length, listLen;
int isArithSeries = 0;
int isAbstractList = 0;
Tcl_Obj *resObjPtr = NULL, *joinObjPtr, **elemPtrs;
if ((objc < 2) || (objc > 3)) {
@@ -2215,14 +2215,17 @@ Tcl_JoinObjCmd(
* pointer to its array of element pointers.
*/
if (TclHasInternalRep(objv[1],&tclArithSeriesType.objType)) {
isArithSeries = 1;
listLen = ABSTRACTLIST_PROC(objv[1], lengthProc)(objv[1]);
} else {
if (TclListObjGetElementsM(interp, objv[1], &listLen,
&elemPtrs) != TCL_OK) {
if (TclObjTypeHasProc(objv[1], getElementsProc)) {
listLen = TclObjTypeLength(objv[1]);
isAbstractList = (listLen ? 1 : 0);
if (listLen > 1 &&
TclObjTypeGetElements(interp, objv[1], &listLen, &elemPtrs)
!= TCL_OK) {
return TCL_ERROR;
}
} else if (TclListObjGetElementsM(interp, objv[1], &listLen,
&elemPtrs) != TCL_OK) {
return TCL_ERROR;
}
if (listLen == 0) {
@@ -2231,14 +2234,15 @@ Tcl_JoinObjCmd(
}
if (listLen == 1) {
/* One element; return it */
if (isArithSeries) {
Tcl_Obj *valueObj = TclArithSeriesObjIndex(interp, objv[1], 0);
if (valueObj == NULL) {
if (!isAbstractList) {
Tcl_SetObjResult(interp, elemPtrs[0]);
} else {
Tcl_Obj *elemObj;
if (TclObjTypeIndex(interp, objv[1], 0, &elemObj)
!= TCL_OK) {
return TCL_ERROR;
}
Tcl_SetObjResult(interp, valueObj);
} else {
Tcl_SetObjResult(interp, elemPtrs[0]);
Tcl_SetObjResult(interp, elemObj);
}
return TCL_OK;
}
@@ -2252,43 +2256,20 @@ Tcl_JoinObjCmd(
} else {
Tcl_Size i;
resObjPtr = Tcl_NewObj();
if (isArithSeries) {
Tcl_Obj *valueObj;
for (i = 0; i < listLen; i++) {
if (i > 0) {
TclNewObj(resObjPtr);
for (i = 0; i < listLen; i++) {
if (i > 0) {
/*
* NOTE: This code is relying on Tcl_AppendObjToObj() **NOT**
* to shimmer joinObjPtr. If it did, then the case where
* objv[1] and objv[2] are the same value would not be safe.
* Accessing elemPtrs would crash.
*/
/*
* NOTE: This code is relying on Tcl_AppendObjToObj() **NOT**
* to shimmer joinObjPtr. If it did, then the case where
* objv[1] and objv[2] are the same value would not be safe.
* Accessing elemPtrs would crash.
*/
Tcl_AppendObjToObj(resObjPtr, joinObjPtr);
}
valueObj = TclArithSeriesObjIndex(interp, objv[1], i);
if (valueObj == NULL) {
return TCL_ERROR;
}
Tcl_AppendObjToObj(resObjPtr, valueObj);
Tcl_DecrRefCount(valueObj);
}
} else {
for (i = 0; i < listLen; i++) {
if (i > 0) {
/*
* NOTE: This code is relying on Tcl_AppendObjToObj() **NOT**
* to shimmer joinObjPtr. If it did, then the case where
* objv[1] and objv[2] are the same value would not be safe.
* Accessing elemPtrs would crash.
*/
Tcl_AppendObjToObj(resObjPtr, joinObjPtr);
}
Tcl_AppendObjToObj(resObjPtr, elemPtrs[i]);
Tcl_AppendObjToObj(resObjPtr, joinObjPtr);
}
Tcl_AppendObjToObj(resObjPtr, elemPtrs[i]);
}
}
Tcl_DecrRefCount(joinObjPtr);
@@ -2327,20 +2308,25 @@ Tcl_LassignObjCmd(
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;
int code;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "list ?varName ...?");
return TCL_ERROR;
}
listCopyPtr = TclListObjCopy(interp, objv[1]);
if (listCopyPtr == NULL) {
listCopyPtr = TclDuplicatePureObj(interp, objv[1], &tclListType);
if (!listCopyPtr) {
return TCL_ERROR;
}
Tcl_IncrRefCount(listCopyPtr); /* Important! fs */
TclListObjGetElementsM(NULL, listCopyPtr, &listObjc, &listObjv);
code = TclListObjGetElementsM(
interp, listCopyPtr, &listObjc, &listObjv);
if (code != TCL_OK) {
Tcl_DecrRefCount(listCopyPtr);
return code;
}
origListObjc = listObjc;
objc -= 2;
@@ -2466,7 +2452,7 @@ Tcl_LinsertObjCmd(
{
Tcl_Obj *listPtr;
Tcl_Size len, index;
int result;
int copied = 0, result;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "list index ?element ...?");
@@ -2499,7 +2485,11 @@ Tcl_LinsertObjCmd(
listPtr = objv[1];
if (Tcl_IsShared(listPtr)) {
listPtr = TclListObjCopy(NULL, listPtr);
listPtr = TclDuplicatePureObj(interp, listPtr, &tclListType);
if (!listPtr) {
return TCL_ERROR;
}
copied = 1;
}
if ((objc == 4) && (index == len)) {
@@ -2507,10 +2497,19 @@ Tcl_LinsertObjCmd(
* Special case: insert one element at the end of the list.
*/
Tcl_ListObjAppendElement(NULL, listPtr, objv[3]);
result = Tcl_ListObjAppendElement(NULL, listPtr, objv[3]);
if (result != TCL_OK) {
if (copied) {
Tcl_DecrRefCount(listPtr);
}
return result;
}
} else {
if (TCL_OK != Tcl_ListObjReplace(interp, listPtr, index, 0,
(objc-3), &(objv[3]))) {
if (copied) {
Tcl_DecrRefCount(listPtr);
}
return TCL_ERROR;
}
}
@@ -2634,9 +2633,9 @@ Tcl_LpopObjCmd(
/* Argument objects. */
{
Tcl_Size listLen;
int result;
int copied = 0, result;
Tcl_Obj *elemPtr, *stored;
Tcl_Obj *listPtr, **elemPtrs;
Tcl_Obj *listPtr;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "listvar ?index?");
@@ -2648,7 +2647,7 @@ Tcl_LpopObjCmd(
return TCL_ERROR;
}
result = TclListObjGetElementsM(interp, listPtr, &listLen, &elemPtrs);
result = TclListObjLengthM(interp, listPtr, &listLen);
if (result != TCL_OK) {
return result;
}
@@ -2667,7 +2666,12 @@ Tcl_LpopObjCmd(
"OUTOFRANGE", NULL);
return TCL_ERROR;
}
elemPtr = elemPtrs[listLen - 1];
result = Tcl_ListObjIndex(interp, listPtr, (listLen-1), &elemPtr);
if (result != TCL_OK) {
return result;
}
Tcl_IncrRefCount(elemPtr);
} else {
elemPtr = TclLindexFlat(interp, listPtr, objc-2, objv+2);
@@ -2686,23 +2690,39 @@ Tcl_LpopObjCmd(
if (objc == 2) {
if (Tcl_IsShared(listPtr)) {
listPtr = TclListObjCopy(NULL, listPtr);
listPtr = TclDuplicatePureObj(interp, listPtr, &tclListType);
if (!listPtr) {
return TCL_ERROR;
}
copied = 1;
}
result = Tcl_ListObjReplace(interp, listPtr, listLen - 1, 1, 0, NULL);
if (result != TCL_OK) {
if (copied) {
Tcl_DecrRefCount(listPtr);
}
return result;
}
Tcl_IncrRefCount(listPtr);
} else {
listPtr = TclLsetFlat(interp, listPtr, objc-2, objv+2, NULL);
if (listPtr == NULL) {
Tcl_Obj *newListPtr;
Tcl_ObjTypeSetElement *proc = TclObjTypeHasProc(listPtr, setElementProc);
if (proc) {
newListPtr = proc(interp, listPtr, objc-2, objv+2, NULL);
} else {
newListPtr = TclLsetFlat(interp, listPtr, objc-2, objv+2, NULL);
}
if (newListPtr == NULL) {
if (copied) {
Tcl_DecrRefCount(listPtr);
}
return TCL_ERROR;
} else {
listPtr = newListPtr;
TclUndoRefCount(listPtr);
}
}
stored = Tcl_ObjSetVar2(interp, objv[1], NULL, listPtr, TCL_LEAVE_ERR_MSG);
Tcl_DecrRefCount(listPtr);
if (stored == NULL) {
return TCL_ERROR;
}
@@ -2759,11 +2779,11 @@ Tcl_LrangeObjCmd(
return result;
}
if (TclHasInternalRep(objv[1],&tclArithSeriesType.objType)) {
Tcl_Obj *rangeObj;
rangeObj = TclArithSeriesObjRange(interp, objv[1], first, last);
if (rangeObj) {
Tcl_SetObjResult(interp, rangeObj);
if (TclObjTypeHasProc(objv[1], sliceProc)) {
Tcl_Obj *resultObj;
int status = TclObjTypeSlice(interp, objv[1], first, last, &resultObj);
if (status == TCL_OK) {
Tcl_SetObjResult(interp, resultObj);
} else {
return TCL_ERROR;
}
@@ -2819,6 +2839,7 @@ Tcl_LremoveObjCmd(
Tcl_Size i, idxc, prevIdx, first, num;
Tcl_Size *idxv, listLen;
Tcl_Obj *listObj;
int copied = 0, status = TCL_OK;
/*
* Parse the arguments.
@@ -2841,10 +2862,10 @@ Tcl_LremoveObjCmd(
}
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;
status = (TclGetIntForIndexM(interp, objv[i], /*endValue*/ listLen - 1,
&idxv[i - 2]) != TCL_OK);
if (status != TCL_OK) {
goto done;
}
}
@@ -2862,7 +2883,12 @@ Tcl_LremoveObjCmd(
*/
if (Tcl_IsShared(listObj)) {
listObj = TclListObjCopy(NULL, listObj);
listObj = TclDuplicatePureObj(interp, listObj, &tclListType);
if (!listObj) {
status = TCL_ERROR;
goto done;
}
copied = 1;
}
num = 0;
first = listLen;
@@ -2897,18 +2923,28 @@ Tcl_LremoveObjCmd(
* and we're only ever contracting that list.
*/
(void) Tcl_ListObjReplace(interp, listObj, first, num, 0, NULL);
status = Tcl_ListObjReplace(interp, listObj, first, num, 0, NULL);
if (status != TCL_OK) {
goto done;
}
listLen -= num;
num = 1;
first = idx;
}
}
if (num != 0) {
(void) Tcl_ListObjReplace(interp, listObj, first, num, 0, NULL);
status = Tcl_ListObjReplace(interp, listObj, first, num, 0, NULL);
if (status != TCL_OK) {
if (copied) {
Tcl_DecrRefCount(listObj);
}
goto done;
}
}
Tcl_Free(idxv);
Tcl_SetObjResult(interp, listObj);
return TCL_OK;
done:
Tcl_Free(idxv);
return status;
}
/*
@@ -2936,7 +2972,8 @@ Tcl_LrepeatObjCmd(
Tcl_Obj *const objv[])
/* The argument objects. */
{
Tcl_Size elementCount, i, totalElems;
Tcl_WideInt elementCount, i;
Tcl_Size totalElems;
Tcl_Obj *listPtr, **dataArray = NULL;
/*
@@ -2948,12 +2985,12 @@ Tcl_LrepeatObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "count ?value ...?");
return TCL_ERROR;
}
if (TCL_OK != TclGetSizeIntFromObj(interp, objv[1], &elementCount)) {
if (TCL_OK != TclGetWideIntFromObj(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));
"bad count \"%" TCL_LL_MODIFIER "d\": must be integer >= 0", elementCount));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LREPEAT", "NEGARG",
NULL);
return TCL_ERROR;
@@ -3102,7 +3139,10 @@ Tcl_LreplaceObjCmd(
listPtr = objv[1];
if (Tcl_IsShared(listPtr)) {
listPtr = TclListObjCopy(NULL, listPtr);
listPtr = TclDuplicatePureObj(interp, listPtr, &tclListType);
if (!listPtr) {
return TCL_ERROR;
}
}
/*
@@ -3115,6 +3155,7 @@ Tcl_LreplaceObjCmd(
if (TCL_OK != Tcl_ListObjReplace(interp, listPtr, first, numToDelete,
objc-4, objv+4)) {
Tcl_DecrRefCount(listPtr);
return TCL_ERROR;
}
@@ -3159,20 +3200,18 @@ Tcl_LreverseObjCmd(
}
/*
* Handle ArithSeries special case - don't shimmer a series into a list
* just to reverse it.
* Handle AbstractList special case - do not shimmer into a list, if it
* supports a private Reverse function, just to reverse it.
*/
if (TclHasInternalRep(objv[1],&tclArithSeriesType.objType)) {
Tcl_Obj *resObj = TclArithSeriesObjReverse(interp, objv[1]);
if (resObj) {
Tcl_SetObjResult(interp, resObj);
if (TclObjTypeHasProc(objv[1], reverseProc)) {
Tcl_Obj *resultObj;
if (TclObjTypeReverse(interp, objv[1], &resultObj) == TCL_OK) {
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
} else {
return TCL_ERROR;
}
} /* end ArithSeries */
} /* end Abstract List */
/* True List */
if (TclListObjLengthM(interp, objv[1], &elemc) != TCL_OK) {
return TCL_ERROR;
}
@@ -3258,14 +3297,14 @@ Tcl_LsearchObjCmd(
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;
Tcl_Size groupOffset, lower, upper;
int allocatedIndexVector = 0;
int isIncreasing;
Tcl_WideInt patWide, objWide, wide;
Tcl_WideInt patWide, objWide, wide, groupSize;
int allMatches, inlineReturn, negatedMatch, returnSubindices, noCase;
double patDouble, objDouble;
SortInfo sortInfo;
Tcl_Obj *patObj, **listv, *listPtr, *startPtr, *itemPtr;
Tcl_Obj *patObj, **listv, *listPtr, *startPtr, *itemPtr = NULL;
SortStrCmpFn_t strCmpFn = TclUtfCmp;
Tcl_RegExp regexp = NULL;
static const char *const options[] = {
@@ -3710,9 +3749,14 @@ Tcl_LsearchObjCmd(
lower = start - groupSize;
upper = listc;
itemPtr = NULL;
while (lower + groupSize != upper && sortInfo.resultCode == TCL_OK) {
i = (lower + upper)/2;
i -= i % groupSize;
Tcl_BounceRefCount(itemPtr);
itemPtr = NULL;
if (sortInfo.indexc != 0) {
itemPtr = SelectObjFromSublist(listv[i+groupOffset], &sortInfo);
if (sortInfo.resultCode != TCL_OK) {
@@ -3811,6 +3855,9 @@ Tcl_LsearchObjCmd(
}
for (i = start; i < listc; i += groupSize) {
match = 0;
Tcl_BounceRefCount(itemPtr);
itemPtr = NULL;
if (sortInfo.indexc != 0) {
itemPtr = SelectObjFromSublist(listv[i+groupOffset], &sortInfo);
if (sortInfo.resultCode != TCL_OK) {
@@ -3910,6 +3957,7 @@ Tcl_LsearchObjCmd(
*/
if (returnSubindices && (sortInfo.indexc != 0)) {
Tcl_BounceRefCount(itemPtr);
itemPtr = SelectObjFromSublist(listv[i+groupOffset],
&sortInfo);
Tcl_ListObjAppendElement(interp, listPtr, itemPtr);
@@ -3917,6 +3965,7 @@ Tcl_LsearchObjCmd(
Tcl_ListObjReplace(interp, listPtr, LIST_MAX, 0,
groupSize, &listv[i]);
} else {
Tcl_BounceRefCount(itemPtr);
itemPtr = listv[i];
Tcl_ListObjAppendElement(interp, listPtr, itemPtr);
}
@@ -3937,6 +3986,9 @@ Tcl_LsearchObjCmd(
}
}
Tcl_BounceRefCount(itemPtr);
itemPtr = NULL;
/*
* Return everything or a single value.
*/
@@ -3984,6 +4036,9 @@ Tcl_LsearchObjCmd(
*/
done:
/* potential lingering abstract list element */
Tcl_BounceRefCount(itemPtr);
if (startPtr != NULL) {
Tcl_DecrRefCount(startPtr);
}
@@ -3993,91 +4048,6 @@ Tcl_LsearchObjCmd(
return result;
}
/*
*----------------------------------------------------------------------
*
* Tcl_LsetObjCmd --
*
* This procedure is invoked to process the "lset" Tcl command. See the
* user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
int
Tcl_LsetObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
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. */
/*
* Check parameter count.
*/
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv,
"listVar ?index? ?index ...? value");
return TCL_ERROR;
}
/*
* Look up the list variable's value.
*/
listPtr = Tcl_ObjGetVar2(interp, objv[1], NULL, TCL_LEAVE_ERR_MSG);
if (listPtr == NULL) {
return TCL_ERROR;
}
/*
* Substitute the value in the value. Return either the value or else an
* unshared copy of it.
*/
if (objc == 4) {
finalValuePtr = TclLsetList(interp, listPtr, objv[2], objv[3]);
} else {
finalValuePtr = TclLsetFlat(interp, listPtr, objc-3, objv+2,
objv[objc-1]);
}
/*
* If substitution has failed, bail out.
*/
if (finalValuePtr == NULL) {
return TCL_ERROR;
}
/*
* Finally, update the variable so that traces fire.
*/
listPtr = Tcl_ObjSetVar2(interp, objv[1], NULL, finalValuePtr,
TCL_LEAVE_ERR_MSG);
Tcl_DecrRefCount(finalValuePtr);
if (listPtr == NULL) {
return TCL_ERROR;
}
/*
* Return the new value of the variable as the interpreter result.
*/
Tcl_SetObjResult(interp, listPtr);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
@@ -4218,7 +4188,7 @@ Tcl_LseqObjCmd(
Tcl_WideInt values[5];
Tcl_Obj *numValues[5];
Tcl_Obj *numberObj;
int status, keyword, useDoubles = 0;
int status = TCL_ERROR, keyword, useDoubles = 0;
Tcl_Obj *arithSeriesPtr;
SequenceOperators opmode;
SequenceDecoded decoded;
@@ -4288,11 +4258,10 @@ Tcl_LseqObjCmd(
case 0:
Tcl_WrongNumArgs(interp, 1, objv,
"n ??op? n ??by? n??");
status = TCL_ERROR;
goto done;
break;
/* range n */
/* lseq n */
case 1:
start = zero;
elementCount = numValues[0];
@@ -4300,22 +4269,22 @@ Tcl_LseqObjCmd(
step = one;
break;
/* range n n */
/* lseq n n */
case 11:
start = numValues[0];
end = numValues[1];
break;
/* range n n n */
/* lseq n n n */
case 111:
start = numValues[0];
end = numValues[1];
step = numValues[2];
break;
/* range n 'to' n */
/* range n 'count' n */
/* range n 'by' n */
/* lseq n 'to' n */
/* lseq n 'count' n */
/* lseq n 'by' n */
case 121:
opmode = (SequenceOperators)values[1];
switch (opmode) {
@@ -4335,13 +4304,12 @@ Tcl_LseqObjCmd(
step = one;
break;
default:
status = TCL_ERROR;
goto done;
}
break;
/* range n 'to' n n */
/* range n 'count' n n */
/* lseq n 'to' n n */
/* lseq n 'count' n n */
case 1211:
opmode = (SequenceOperators)values[1];
switch (opmode) {
@@ -4358,17 +4326,15 @@ Tcl_LseqObjCmd(
break;
case LSEQ_BY:
/* Error case */
status = TCL_ERROR;
goto done;
break;
default:
status = TCL_ERROR;
goto done;
break;
}
break;
/* range n n 'by' n */
/* lseq n n 'by' n */
case 1121:
start = numValues[0];
end = numValues[1];
@@ -4381,14 +4347,13 @@ Tcl_LseqObjCmd(
case LSEQ_TO:
case LSEQ_COUNT:
default:
status = TCL_ERROR;
goto done;
break;
}
break;
/* range n 'to' n 'by' n */
/* range n 'count' n 'by' n */
/* lseq n 'to' n 'by' n */
/* lseq n 'count' n 'by' n */
case 12121:
start = numValues[0];
opmode = (SequenceOperators)values[3];
@@ -4397,7 +4362,6 @@ Tcl_LseqObjCmd(
step = numValues[4];
break;
default:
status = TCL_ERROR;
goto done;
break;
}
@@ -4413,7 +4377,6 @@ Tcl_LseqObjCmd(
elementCount = numValues[2];
break;
default:
status = TCL_ERROR;
goto done;
break;
}
@@ -4427,7 +4390,6 @@ Tcl_LseqObjCmd(
case 1212:
opmode = (SequenceOperators)values[3]; goto KeywordError; break;
KeywordError:
status = TCL_ERROR;
switch (opmode) {
case LSEQ_DOTS:
case LSEQ_TO:
@@ -4443,14 +4405,12 @@ Tcl_LseqObjCmd(
"missing \"by\" value."));
break;
}
status = TCL_ERROR;
goto done;
break;
/* All other argument errors */
default:
Tcl_WrongNumArgs(interp, 1, objv, "n ??op? n ??by? n??");
status = TCL_ERROR;
goto done;
break;
}
@@ -4478,6 +4438,99 @@ Tcl_LseqObjCmd(
return status;
}
/*
*----------------------------------------------------------------------
*
* Tcl_LsetObjCmd --
*
* This procedure is invoked to process the "lset" Tcl command. See the
* user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
int
Tcl_LsetObjCmd(
TCL_UNUSED(ClientData),
Tcl_Interp *interp, /* Current interpreter. */
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. */
/*
* Check parameter count.
*/
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv,
"listVar ?index? ?index ...? value");
return TCL_ERROR;
}
/*
* Look up the list variable's value.
*/
listPtr = Tcl_ObjGetVar2(interp, objv[1], NULL, TCL_LEAVE_ERR_MSG);
if (listPtr == NULL) {
return TCL_ERROR;
}
/*
* Substitute the value in the value. Return either the value or else an
* unshared copy of it.
*/
if (objc == 4) {
finalValuePtr = TclLsetList(interp, listPtr, objv[2], objv[3]);
} else {
if (TclObjTypeHasProc(listPtr, setElementProc)) {
finalValuePtr = TclObjTypeSetElement(interp, listPtr,
objc-3, objv+2, objv[objc-1]);
if (finalValuePtr) {
Tcl_IncrRefCount(finalValuePtr);
}
} else {
finalValuePtr = TclLsetFlat(interp, listPtr, objc-3, objv+2,
objv[objc-1]);
}
}
/*
* If substitution has failed, bail out.
*/
if (finalValuePtr == NULL) {
return TCL_ERROR;
}
/*
* Finally, update the variable so that traces fire.
*/
listPtr = Tcl_ObjSetVar2(interp, objv[1], NULL, finalValuePtr,
TCL_LEAVE_ERR_MSG);
Tcl_DecrRefCount(finalValuePtr);
if (listPtr == NULL) {
return TCL_ERROR;
}
/*
* Return the new value of the variable as the interpreter result.
*/
Tcl_SetObjResult(interp, listPtr);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
@@ -4505,8 +4558,8 @@ Tcl_LsortObjCmd(
int indices, nocase = 0, indexc;
int sortMode = SORTMODE_ASCII;
int group, allocatedIndexVector = 0;
Tcl_Size j, idx, groupSize, groupOffset, length;
Tcl_WideInt wide;
Tcl_Size j, idx, groupOffset, length;
Tcl_WideInt wide, groupSize;
Tcl_Obj *resultPtr, *cmdPtr, **listObjPtrs, *listObj, *indexPtr;
Tcl_Size i, elmArrSize;
SortElement *elementArray = NULL, *elementPtr;
@@ -4722,7 +4775,7 @@ Tcl_LsortObjCmd(
* 1675116]
*/
listObj = TclListObjCopy(interp, listObj);
listObj = TclDuplicatePureObj(interp ,listObj, &tclListType);
if (listObj == NULL) {
sortInfo.resultCode = TCL_ERROR;
goto done;
@@ -4739,8 +4792,6 @@ Tcl_LsortObjCmd(
if (Tcl_ListObjAppendElement(interp, newCommandPtr, newObjPtr)
!= TCL_OK) {
TclDecrRefCount(newCommandPtr);
TclDecrRefCount(listObj);
Tcl_IncrRefCount(newObjPtr);
TclDecrRefCount(newObjPtr);
sortInfo.resultCode = TCL_ERROR;
goto done;
@@ -4749,9 +4800,9 @@ Tcl_LsortObjCmd(
sortInfo.compareCmdPtr = newCommandPtr;
}
if (TclHasInternalRep(listObj,&tclArithSeriesType.objType)) {
sortInfo.resultCode = TclArithSeriesGetElements(interp,
listObj, &length, &listObjPtrs);
if (TclObjTypeHasProc(objv[1], getElementsProc)) {
sortInfo.resultCode =
TclObjTypeGetElements(interp, listObj, &length, &listObjPtrs);
} else {
sortInfo.resultCode = TclListObjGetElementsM(interp, listObj,
&length, &listObjPtrs);
@@ -5080,7 +5131,10 @@ Tcl_LeditObjCmd(
}
if (Tcl_IsShared(listPtr)) {
listPtr = TclListObjCopy(NULL, listPtr);
listPtr = TclDuplicatePureObj(interp, listPtr, &tclListType);
if (!listPtr) {
return TCL_ERROR;
}
createdNewObj = 1;
} else {
createdNewObj = 0;
@@ -5097,18 +5151,10 @@ Tcl_LeditObjCmd(
/*
* Tcl_ObjSetVar2 may return a value different from listPtr in the
* presence of traces etc.. Note that finalValuePtr will always have a
* reference count of at least 1 corresponding to the reference from the
* var. If it is same as listPtr, then ref count will be at least 2
* since we are incr'ing the latter below (safer when calling
* Tcl_ObjSetVar2 which can release it in some cases). Note that we
* leave the incrref of listPtr this late because we want to pass it as
* unshared to Tcl_ListObjReplace above if possible.
* presence of traces etc.
*/
Tcl_IncrRefCount(listPtr);
finalValuePtr =
Tcl_ObjSetVar2(interp, objv[1], NULL, listPtr, TCL_LEAVE_ERR_MSG);
Tcl_DecrRefCount(listPtr); /* safe irrespective of createdNewObj */
if (finalValuePtr == NULL) {
return TCL_ERROR;
}
@@ -5505,7 +5551,7 @@ SelectObjFromSublist(
for (i=0 ; i<infoPtr->indexc ; i++) {
Tcl_Size listLen;
int index;
Tcl_Obj *currentObj;
Tcl_Obj *currentObj, *lastObj=NULL;
if (TclListObjLengthM(infoPtr->interp, objPtr, &listLen) != TCL_OK) {
infoPtr->resultCode = TCL_ERROR;
@@ -5536,6 +5582,8 @@ SelectObjFromSublist(
return NULL;
}
objPtr = currentObj;
Tcl_BounceRefCount(lastObj);
lastObj = currentObj;
}
return objPtr;
}
+23 -22
View File
@@ -357,7 +357,7 @@ Tcl_RegexpObjCmd(
objc = info.nsubs + 1;
if (all <= 1) {
resultPtr = Tcl_NewObj();
TclNewObj(resultPtr);
}
}
for (i = 0; i < objc; i++) {
@@ -399,7 +399,7 @@ Tcl_RegexpObjCmd(
offset + info.matches[i].start,
offset + info.matches[i].end - 1);
} else {
newPtr = Tcl_NewObj();
TclNewObj(newPtr);
}
}
if (doinline) {
@@ -1194,7 +1194,7 @@ Tcl_SplitObjCmd(
stringPtr = Tcl_GetStringFromObj(objv[1], &stringLen);
end = stringPtr + stringLen;
listPtr = Tcl_NewObj();
TclNewObj(listPtr);
if (stringLen == 0) {
/*
@@ -1612,7 +1612,7 @@ StringIsCmd(
case STR_IS_BOOL:
case STR_IS_TRUE:
case STR_IS_FALSE:
if (!TclHasInternalRep(objPtr, &tclBooleanType.objType)
if (!TclHasInternalRep(objPtr, &tclBooleanType)
&& (TCL_OK != TclSetBooleanFromAny(NULL, objPtr))) {
if (strict) {
result = 0;
@@ -1681,9 +1681,9 @@ StringIsCmd(
chcomp = Tcl_UniCharIsDigit;
break;
case STR_IS_DOUBLE: {
if (TclHasInternalRep(objPtr, &tclDoubleType.objType) ||
TclHasInternalRep(objPtr, &tclIntType.objType) ||
TclHasInternalRep(objPtr, &tclBignumType.objType)) {
if (TclHasInternalRep(objPtr, &tclDoubleType) ||
TclHasInternalRep(objPtr, &tclIntType) ||
TclHasInternalRep(objPtr, &tclBignumType)) {
break;
}
string1 = Tcl_GetStringFromObj(objPtr, &length1);
@@ -1712,8 +1712,8 @@ StringIsCmd(
break;
case STR_IS_INT:
case STR_IS_ENTIER:
if (TclHasInternalRep(objPtr, &tclIntType.objType) ||
TclHasInternalRep(objPtr, &tclBignumType.objType)) {
if (TclHasInternalRep(objPtr, &tclIntType) ||
TclHasInternalRep(objPtr, &tclBignumType)) {
break;
}
string1 = Tcl_GetStringFromObj(objPtr, &length1);
@@ -2642,8 +2642,8 @@ StringEqualCmd(
*/
const char *string2;
int i, match, nocase = 0, reqlength = -1;
Tcl_Size length;
int i, match, nocase = 0;
Tcl_Size length, reqlength = -1;
if (objc < 3 || objc > 6) {
str_cmp_args:
@@ -2662,7 +2662,7 @@ StringEqualCmd(
goto str_cmp_args;
}
i++;
if (TclGetIntFromObj(interp, objv[i], &reqlength) != TCL_OK) {
if (TclGetSizeIntFromObj(interp, objv[i], &reqlength) != TCL_OK) {
return TCL_ERROR;
}
} else {
@@ -2717,7 +2717,8 @@ StringCmpCmd(
* the expr string comparison in INST_EQ/INST_NEQ/INST_LT/...).
*/
int match, nocase, reqlength, status;
int match, nocase, status;
Tcl_Size reqlength;
status = TclStringCmpOpts(interp, objc, objv, &nocase, &reqlength);
if (status != TCL_OK) {
@@ -2736,7 +2737,7 @@ TclStringCmpOpts(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects. */
int *nocase,
int *reqlength)
Tcl_Size *reqlength)
{
int i;
Tcl_Size length;
@@ -2761,7 +2762,7 @@ TclStringCmpOpts(
goto str_cmp_args;
}
i++;
if (TclGetIntFromObj(interp, objv[i], reqlength) != TCL_OK) {
if (TclGetSizeIntFromObj(interp, objv[i], reqlength) != TCL_OK) {
return TCL_ERROR;
}
} else {
@@ -3847,7 +3848,7 @@ TclNRSwitchObjCmd(
if (ctxPtr->type == TCL_LOCATION_SOURCE && ctxPtr->line[bidx] >= 0) {
int bline = ctxPtr->line[bidx];
ctxPtr->line = (int *)Tcl_Alloc(objc * sizeof(int));
ctxPtr->line = (Tcl_Size *)Tcl_Alloc(objc * sizeof(Tcl_Size));
ctxPtr->nline = objc;
TclListLines(blist, bline, objc, ctxPtr->line, objv);
} else {
@@ -3861,7 +3862,7 @@ TclNRSwitchObjCmd(
int k;
ctxPtr->line = (int *)Tcl_Alloc(objc * sizeof(int));
ctxPtr->line = (Tcl_Size *)Tcl_Alloc(objc * sizeof(Tcl_Size));
ctxPtr->nline = objc;
for (k=0; k < objc; k++) {
ctxPtr->line[k] = -1;
@@ -4700,7 +4701,7 @@ TclNRTryObjCmd(
return TCL_ERROR;
}
bodyObj = objv[1];
handlersObj = Tcl_NewObj();
TclNewObj(handlersObj);
bodyShared = 0;
haveHandlers = 0;
for (i=2 ; i<objc ; i++) {
@@ -5301,17 +5302,17 @@ TclListLines(
* 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_Size n, /* #elements in lines */
Tcl_Size *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;
int i, length = strlen(listStr);
Tcl_Size i, length = strlen(listStr);
const char *element = NULL, *next = NULL;
ContLineLoc *clLocPtr = TclContinuationsGet(listObj);
int *clNext = (clLocPtr ? &clLocPtr->loc[0] : NULL);
Tcl_Size *clNext = (clLocPtr ? &clLocPtr->loc[0] : NULL);
for (i = 0; i < n; i++) {
TclFindElement(NULL, listStr, length, &element, &next, NULL, NULL);
+17 -17
View File
@@ -41,12 +41,12 @@ static int CompileUnaryOpCmd(Tcl_Interp *interp,
CompileEnv *envPtr);
static void IssueSwitchChainedTests(Tcl_Interp *interp,
CompileEnv *envPtr, int mode, int noCase,
int numWords, Tcl_Token **bodyToken,
int *bodyLines, int **bodyNext);
Tcl_Size numWords, Tcl_Token **bodyToken,
Tcl_Size *bodyLines, Tcl_Size **bodyNext);
static void IssueSwitchJumpTable(Tcl_Interp *interp,
CompileEnv *envPtr, int numWords,
Tcl_Token **bodyToken, int *bodyLines,
int **bodyContLines);
Tcl_Token **bodyToken, Tcl_Size *bodyLines,
Tcl_Size **bodyContLines);
static int IssueTryClausesInstructions(Tcl_Interp *interp,
CompileEnv *envPtr, Tcl_Token *bodyToken,
int numHandlers, int *matchCodes,
@@ -1800,14 +1800,14 @@ TclCompileSwitchCmd(
Tcl_Token *bodyTokenArray; /* Array of real pattern list items. */
Tcl_Token **bodyToken; /* Array of pointers to pattern list items. */
int *bodyLines; /* Array of line numbers for body list
Tcl_Size *bodyLines; /* Array of line numbers for body list
* items. */
int **bodyContLines; /* Array of continuation line info. */
Tcl_Size **bodyContLines; /* Array of continuation line info. */
int noCase; /* Has the -nocase flag been given? */
int foundMode = 0; /* Have we seen a mode flag yet? */
int i, valueIndex;
int result = TCL_ERROR;
int *clNext = envPtr->clNext;
Tcl_Size *clNext = envPtr->clNext;
/*
* Only handle the following versions:
@@ -1964,8 +1964,8 @@ TclCompileSwitchCmd(
}
bodyTokenArray = (Tcl_Token *)Tcl_Alloc(sizeof(Tcl_Token) * maxLen);
bodyToken = (Tcl_Token **)Tcl_Alloc(sizeof(Tcl_Token *) * maxLen);
bodyLines = (int *)Tcl_Alloc(sizeof(int) * maxLen);
bodyContLines = (int **)Tcl_Alloc(sizeof(int*) * maxLen);
bodyLines = (Tcl_Size *)Tcl_Alloc(sizeof(Tcl_Size) * maxLen);
bodyContLines = (Tcl_Size **)Tcl_Alloc(sizeof(Tcl_Size*) * maxLen);
bline = mapPtr->loc[eclIndex].line[valueIndex+1];
numWords = 0;
@@ -2025,8 +2025,8 @@ TclCompileSwitchCmd(
*/
bodyToken = (Tcl_Token **)Tcl_Alloc(sizeof(Tcl_Token *) * numWords);
bodyLines = (int *)Tcl_Alloc(sizeof(int) * numWords);
bodyContLines = (int **)Tcl_Alloc(sizeof(int*) * numWords);
bodyLines = (Tcl_Size *)Tcl_Alloc(sizeof(Tcl_Size) * numWords);
bodyContLines = (Tcl_Size **)Tcl_Alloc(sizeof(Tcl_Size*) * numWords);
bodyTokenArray = NULL;
for (i=0 ; i<numWords ; i++) {
/*
@@ -2116,13 +2116,13 @@ IssueSwitchChainedTests(
CompileEnv *envPtr, /* Holds resulting instructions. */
int mode, /* Exact, Glob or Regexp */
int noCase, /* Case-insensitivity flag. */
int numBodyTokens, /* Number of tokens describing things the
Tcl_Size numBodyTokens, /* Number of tokens describing things the
* switch can match against and bodies to
* execute when the match succeeds. */
Tcl_Token **bodyToken, /* Array of pointers to pattern list items. */
int *bodyLines, /* Array of line numbers for body list
Tcl_Size *bodyLines, /* Array of line numbers for body list
* items. */
int **bodyContLines) /* Array of continuation line info. */
Tcl_Size **bodyContLines) /* Array of continuation line info. */
{
enum {Switch_Exact, Switch_Glob, Switch_Regexp};
int foundDefault; /* Flag to indicate whether a "default" clause
@@ -2368,9 +2368,9 @@ IssueSwitchJumpTable(
* switch can match against and bodies to
* execute when the match succeeds. */
Tcl_Token **bodyToken, /* Array of pointers to pattern list items. */
int *bodyLines, /* Array of line numbers for body list
Tcl_Size *bodyLines, /* Array of line numbers for body list
* items. */
int **bodyContLines) /* Array of continuation line info. */
Tcl_Size **bodyContLines) /* Array of continuation line info. */
{
JumptableInfo *jtPtr;
int infoIndex, isNew, *finalFixups, numRealBodies = 0, jumpLocation;
@@ -2669,7 +2669,7 @@ TclCompileTailcallCmd(
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
int i;
if (parsePtr->numWords < 2 || parsePtr->numWords > 256
if (parsePtr->numWords < 2 || parsePtr->numWords >= 256
|| envPtr->procPtr == NULL) {
return TCL_ERROR;
}
+3 -3
View File
@@ -2093,9 +2093,9 @@ ParseLexeme(
if (end < start + numBytes && !TclIsBareword(*end)) {
number:
TclInitStringRep(literal, start, end-start);
*lexemePtr = NUMBER;
if (literalPtr) {
TclInitStringRep(literal, start, end-start);
*literalPtr = literal;
} else {
Tcl_DecrRefCount(literal);
@@ -2111,7 +2111,7 @@ ParseLexeme(
* Example: Inf + luence + () becomes a valid function call.
* [Bug 3401704]
*/
if (TclHasInternalRep(literal, &tclDoubleType.objType)) {
if (TclHasInternalRep(literal, &tclDoubleType)) {
const char *p = start;
while (p < end) {
@@ -2168,7 +2168,7 @@ ParseLexeme(
}
*lexemePtr = BAREWORD;
if (literalPtr) {
Tcl_SetStringObj(literal, start, (int) (end-start));
Tcl_SetStringObj(literal, start, end-start);
*literalPtr = literal;
} else {
Tcl_DecrRefCount(literal);
+57 -25
View File
@@ -701,7 +701,8 @@ static void StartExpanding(CompileEnv *envPtr);
*/
static void EnterCmdWordData(ExtCmdLoc *eclPtr, Tcl_Size srcOffset,
Tcl_Token *tokenPtr, const char *cmd,
Tcl_Size numWords, Tcl_Size line, int *clNext, int **lines,
Tcl_Size numWords, Tcl_Size line,
Tcl_Size *clNext, Tcl_Size **lines,
CompileEnv *envPtr);
static void ReleaseCmdWordData(ExtCmdLoc *eclPtr);
@@ -720,8 +721,8 @@ const Tcl_ObjType tclByteCodeType = {
};
/*
* subtCodeType provides the standard type managemnt procedures for the
* substcode type, which represents substiution within a Tcl value.
* substCodeType provides the standard type management procedures for the
* substcode type, which represents substitution within a Tcl value.
*/
static const Tcl_ObjType substCodeType = {
@@ -869,6 +870,18 @@ TclSetByteCodeFromAny(
result = hookProc(interp, &compEnv, clientData);
}
/*
* After optimization is all done, check that byte code length limits
* are not exceeded. Bug [27b3ce2997].
*/
if ((compEnv.codeNext - compEnv.codeStart) > INT_MAX) {
/*
* Cannot just return TCL_ERROR as callers ignore return value.
* TODO - May be use TclCompileSyntaxError here?
*/
Tcl_Panic("Maximum byte code length %d exceeded.", INT_MAX);
}
/*
* Change the object into a ByteCode object. Ownership of the literal
* objects and aux data items passes to the ByteCode object.
@@ -1941,7 +1954,8 @@ CompileCmdCompileProc(
CompileEnv *envPtr)
{
DefineLineInformation;
int unwind = 0, incrOffset = -1;
int unwind = 0;
Tcl_Size incrOffset = -1;
int depth = TclGetStackDepth(envPtr);
/*
@@ -2028,11 +2042,11 @@ CompileCommandTokens(
Command *cmdPtr = NULL;
int code = TCL_ERROR;
int cmdKnown, expand = -1;
int *wlines, wlineat;
int cmdLine = envPtr->line;
int *clNext = envPtr->clNext;
int cmdIdx = envPtr->numCommands;
int startCodeOffset = envPtr->codeNext - envPtr->codeStart;
Tcl_Size *wlines, wlineat;
Tcl_Size cmdLine = envPtr->line;
Tcl_Size *clNext = envPtr->clNext;
Tcl_Size cmdIdx = envPtr->numCommands;
Tcl_Size startCodeOffset = envPtr->codeNext - envPtr->codeStart;
int depth = TclGetStackDepth(envPtr);
assert ((int)parsePtr->numWords > 0);
@@ -2136,7 +2150,7 @@ TclCompileScript(
* serves as context for finding and compiling
* commands. May not be NULL. */
const char *script, /* The source script to compile. */
size_t numBytes, /* Number of bytes in script. If -1, the
Tcl_Size numBytes, /* Number of bytes in script. If < 0, the
* script consists of all bytes up to the
* first null character. */
CompileEnv *envPtr) /* Holds resulting instructions. */
@@ -2167,9 +2181,26 @@ TclCompileScript(
return;
}
if (numBytes < 0) {
numBytes = strlen(script);
}
/* Each iteration compiles one command from the script. */
if (numBytes + 1 > 1) {
if (numBytes > 0) {
if (numBytes >= INT_MAX) {
/*
* Note this gets -errorline as 1. Not worth figuring out which line
* crosses the limit to get -errorline for this error case.
*/
Tcl_SetObjResult(interp,
Tcl_ObjPrintf("Script length %" TCL_SIZE_MODIFIER
"d exceeds max permitted length %d.",
numBytes, INT_MAX-1));
Tcl_SetErrorCode(interp, "TCL", "LIMIT", "SCRIPTLENGTH", NULL);
TclCompileSyntaxError(interp, envPtr);
return;
}
/*
* Don't use system stack (size of Tcl_Parse is ca. 400 bytes), so
* many nested compilations (body enclosed in body) can cause abnormal
@@ -2392,19 +2423,20 @@ TclCompileTokens(
Tcl_Interp *interp, /* Used for error and status reporting. */
Tcl_Token *tokenPtr, /* Pointer to first in an array of tokens to
* compile. */
size_t count1, /* Number of tokens to consider at tokenPtr.
size_t count1, /* Number of tokens to consider at tokenPtr.
* Must be at least 1. */
CompileEnv *envPtr) /* Holds the resulting instructions. */
{
Tcl_DString textBuffer; /* Holds concatenated chars from adjacent
* TCL_TOKEN_TEXT, TCL_TOKEN_BS tokens. */
char buffer[4] = "";
int i, numObjsToConcat, adjust;
Tcl_Size i, numObjsToConcat, adjust;
size_t length;
unsigned char *entryCodeNext = envPtr->codeNext;
#define NUM_STATIC_POS 20
int isLiteral, maxNumCL, numCL;
int *clPosition = NULL;
int isLiteral;
Tcl_Size maxNumCL, numCL;
Tcl_Size *clPosition = NULL;
int depth = TclGetStackDepth(envPtr);
int count = count1;
@@ -2434,7 +2466,7 @@ TclCompileTokens(
if (isLiteral) {
maxNumCL = NUM_STATIC_POS;
clPosition = (int *)Tcl_Alloc(maxNumCL * sizeof(int));
clPosition = (Tcl_Size *)Tcl_Alloc(maxNumCL * sizeof(Tcl_Size));
}
adjust = 0;
@@ -2474,8 +2506,8 @@ TclCompileTokens(
if (numCL >= maxNumCL) {
maxNumCL *= 2;
clPosition = (int *)Tcl_Realloc(clPosition,
maxNumCL * sizeof(int));
clPosition = (Tcl_Size *)Tcl_Realloc(clPosition,
maxNumCL * sizeof(Tcl_Size));
}
clPosition[numCL] = clPos;
numCL ++;
@@ -3301,14 +3333,14 @@ EnterCmdWordData(
const char *cmd,
Tcl_Size numWords,
Tcl_Size line,
int *clNext,
int **wlines,
Tcl_Size *clNext,
Tcl_Size **wlines,
CompileEnv *envPtr)
{
ECL *ePtr;
const char *last;
Tcl_Size wordIdx, wordLine;
int *wwlines, *wordNext;
Tcl_Size *wwlines, *wordNext;
if (eclPtr->nuloc >= eclPtr->nloc) {
/*
@@ -3327,10 +3359,10 @@ EnterCmdWordData(
ePtr = &eclPtr->loc[eclPtr->nuloc];
ePtr->srcOffset = srcOffset;
ePtr->line = (int *)Tcl_Alloc(numWords * sizeof(int));
ePtr->next = (int **)Tcl_Alloc(numWords * sizeof(int *));
ePtr->line = (Tcl_Size *)Tcl_Alloc(numWords * sizeof(Tcl_Size));
ePtr->next = (Tcl_Size **)Tcl_Alloc(numWords * sizeof(Tcl_Size *));
ePtr->nline = numWords;
wwlines = (int *)Tcl_Alloc(numWords * sizeof(int));
wwlines = (Tcl_Size *)Tcl_Alloc(numWords * sizeof(Tcl_Size));
last = cmd;
wordLine = line;
@@ -3343,7 +3375,7 @@ EnterCmdWordData(
/* See Ticket 4b61afd660 */
wwlines[wordIdx] =
((wordIdx == 0) || TclWordKnownAtCompileTime(tokenPtr, NULL))
? (int)wordLine : -1;
? wordLine : -1;
ePtr->line[wordIdx] = wordLine;
ePtr->next[wordIdx] = wordNext;
last = tokenPtr->start;
+5 -5
View File
@@ -183,16 +183,16 @@ typedef struct {
typedef struct {
Tcl_Size srcOffset; /* Command location to find the entry. */
Tcl_Size nline; /* Number of words in the command */
int *line; /* Line information for all words in the
Tcl_Size *line; /* Line information for all words in the
* command. */
int **next; /* Transient information used by the compiler
Tcl_Size **next; /* Transient information used by the compiler
* for tracking of hidden continuation
* lines. */
} ECL;
typedef struct {
int type; /* Context type. */
int start; /* Starting line for compiled script. Needed
Tcl_Size start; /* Starting line for compiled script. Needed
* for the extended recompile check in
* tclCompileObj. */
Tcl_Obj *path; /* Path of the sourced file the command is
@@ -392,7 +392,7 @@ typedef struct CompileEnv {
* encountered that have not yet been paired
* with a corresponding
* INST_INVOKE_EXPANDED. */
int *clNext; /* If not NULL, it refers to the next slot in
Tcl_Size *clNext; /* If not NULL, it refers to the next slot in
* clLoc to check for an invisible
* continuation line. */
} CompileEnv;
@@ -1100,7 +1100,7 @@ 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, size_t numBytes,
const char *script, Tcl_Size numBytes,
CompileEnv *envPtr);
MODULE_SCOPE void TclCompileSyntaxError(Tcl_Interp *interp,
CompileEnv *envPtr);
+61 -53
View File
@@ -136,7 +136,7 @@ EXTERN int Tcl_GetBooleanFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, int *intPtr);
/* 33 */
EXTERN unsigned char * TclGetByteArrayFromObj(Tcl_Obj *objPtr,
int *numBytesPtr);
void *numBytesPtr);
/* 34 */
EXTERN int Tcl_GetDouble(Tcl_Interp *interp, const char *src,
double *doublePtr);
@@ -156,7 +156,7 @@ EXTERN int Tcl_GetLongFromObj(Tcl_Interp *interp,
/* 40 */
EXTERN const Tcl_ObjType * Tcl_GetObjType(const char *typeName);
/* 41 */
EXTERN char * TclGetStringFromObj(Tcl_Obj *objPtr, int *lengthPtr);
EXTERN char * TclGetStringFromObj(Tcl_Obj *objPtr, void *lengthPtr);
/* 42 */
EXTERN void Tcl_InvalidateStringRep(Tcl_Obj *objPtr);
/* 43 */
@@ -167,7 +167,7 @@ EXTERN int Tcl_ListObjAppendElement(Tcl_Interp *interp,
Tcl_Obj *listPtr, Tcl_Obj *objPtr);
/* 45 */
EXTERN int TclListObjGetElements(Tcl_Interp *interp,
Tcl_Obj *listPtr, int *objcPtr,
Tcl_Obj *listPtr, void *objcPtr,
Tcl_Obj ***objvPtr);
/* 46 */
EXTERN int Tcl_ListObjIndex(Tcl_Interp *interp,
@@ -175,7 +175,7 @@ EXTERN int Tcl_ListObjIndex(Tcl_Interp *interp,
Tcl_Obj **objPtrPtr);
/* 47 */
EXTERN int TclListObjLength(Tcl_Interp *interp,
Tcl_Obj *listPtr, int *lengthPtr);
Tcl_Obj *listPtr, void *lengthPtr);
/* 48 */
EXTERN int Tcl_ListObjReplace(Tcl_Interp *interp,
Tcl_Obj *listPtr, Tcl_Size first,
@@ -665,9 +665,9 @@ EXTERN const char * Tcl_SignalMsg(int sig);
EXTERN void Tcl_SourceRCFile(Tcl_Interp *interp);
/* 242 */
EXTERN int TclSplitList(Tcl_Interp *interp, const char *listStr,
int *argcPtr, const char ***argvPtr);
void *argcPtr, const char ***argvPtr);
/* 243 */
EXTERN void TclSplitPath(const char *path, int *argcPtr,
EXTERN void TclSplitPath(const char *path, void *argcPtr,
const char ***argvPtr);
/* Slot 244 is reserved */
/* Slot 245 is reserved */
@@ -1036,7 +1036,7 @@ EXTERN void Tcl_MutexFinalize(Tcl_Mutex *mutex);
/* 393 */
EXTERN int Tcl_CreateThread(Tcl_ThreadId *idPtr,
Tcl_ThreadCreateProc *proc, void *clientData,
Tcl_Size stackSize, int flags);
TCL_HASH_TYPE stackSize, int flags);
/* 394 */
EXTERN Tcl_Size Tcl_ReadRaw(Tcl_Channel chan, char *dst,
Tcl_Size bytesToRead);
@@ -1137,7 +1137,8 @@ EXTERN int Tcl_AttemptSetObjLength(Tcl_Obj *objPtr,
/* 433 */
EXTERN Tcl_ThreadId Tcl_GetChannelThread(Tcl_Channel channel);
/* 434 */
EXTERN Tcl_UniChar * TclGetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr);
EXTERN Tcl_UniChar * TclGetUnicodeFromObj(Tcl_Obj *objPtr,
void *lengthPtr);
/* Slot 435 is reserved */
/* Slot 436 is reserved */
/* 437 */
@@ -1209,7 +1210,7 @@ EXTERN int Tcl_FSConvertToPathType(Tcl_Interp *interp,
/* 460 */
EXTERN Tcl_Obj * Tcl_FSJoinPath(Tcl_Obj *listObj, Tcl_Size elements);
/* 461 */
EXTERN Tcl_Obj * TclFSSplitPath(Tcl_Obj *pathPtr, int *lenPtr);
EXTERN Tcl_Obj * TclFSSplitPath(Tcl_Obj *pathPtr, void *lenPtr);
/* 462 */
EXTERN int Tcl_FSEqualPaths(Tcl_Obj *firstPtr,
Tcl_Obj *secondPtr);
@@ -1306,7 +1307,7 @@ EXTERN int Tcl_DictObjRemove(Tcl_Interp *interp,
Tcl_Obj *dictPtr, Tcl_Obj *keyPtr);
/* 497 */
EXTERN int TclDictObjSize(Tcl_Interp *interp, Tcl_Obj *dictPtr,
int *sizePtr);
void *sizePtr);
/* 498 */
EXTERN int Tcl_DictObjFirst(Tcl_Interp *interp,
Tcl_Obj *dictPtr, Tcl_DictSearch *searchPtr,
@@ -1612,7 +1613,7 @@ EXTERN int Tcl_GetEnsembleParameterList(Tcl_Interp *interp,
Tcl_Command token, Tcl_Obj **paramListPtr);
/* 604 */
EXTERN int TclParseArgsObjv(Tcl_Interp *interp,
const Tcl_ArgvInfo *argTable, int *objcPtr,
const Tcl_ArgvInfo *argTable, void *objcPtr,
Tcl_Obj *const *objv, Tcl_Obj ***remObjv);
/* 605 */
EXTERN int Tcl_GetErrorLine(Tcl_Interp *interp);
@@ -1744,7 +1745,7 @@ 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);
Tcl_Obj *objPtr, void *numBytesPtr);
/* 650 */
EXTERN unsigned char * Tcl_GetBytesFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, Tcl_Size *numBytesPtr);
@@ -1911,7 +1912,7 @@ typedef struct TclStubs {
void (*tclFreeObj) (Tcl_Obj *objPtr); /* 30 */
int (*tcl_GetBoolean) (Tcl_Interp *interp, const char *src, int *intPtr); /* 31 */
int (*tcl_GetBooleanFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *intPtr); /* 32 */
unsigned char * (*tclGetByteArrayFromObj) (Tcl_Obj *objPtr, int *numBytesPtr); /* 33 */
unsigned char * (*tclGetByteArrayFromObj) (Tcl_Obj *objPtr, void *numBytesPtr); /* 33 */
int (*tcl_GetDouble) (Tcl_Interp *interp, const char *src, double *doublePtr); /* 34 */
int (*tcl_GetDoubleFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, double *doublePtr); /* 35 */
void (*reserved36)(void);
@@ -1919,13 +1920,13 @@ typedef struct TclStubs {
int (*tcl_GetIntFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *intPtr); /* 38 */
int (*tcl_GetLongFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, long *longPtr); /* 39 */
const Tcl_ObjType * (*tcl_GetObjType) (const char *typeName); /* 40 */
char * (*tclGetStringFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 41 */
char * (*tclGetStringFromObj) (Tcl_Obj *objPtr, void *lengthPtr); /* 41 */
void (*tcl_InvalidateStringRep) (Tcl_Obj *objPtr); /* 42 */
int (*tcl_ListObjAppendList) (Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Obj *elemListPtr); /* 43 */
int (*tcl_ListObjAppendElement) (Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Obj *objPtr); /* 44 */
int (*tclListObjGetElements) (Tcl_Interp *interp, Tcl_Obj *listPtr, int *objcPtr, Tcl_Obj ***objvPtr); /* 45 */
int (*tclListObjGetElements) (Tcl_Interp *interp, Tcl_Obj *listPtr, void *objcPtr, Tcl_Obj ***objvPtr); /* 45 */
int (*tcl_ListObjIndex) (Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size index, Tcl_Obj **objPtrPtr); /* 46 */
int (*tclListObjLength) (Tcl_Interp *interp, Tcl_Obj *listPtr, int *lengthPtr); /* 47 */
int (*tclListObjLength) (Tcl_Interp *interp, Tcl_Obj *listPtr, void *lengthPtr); /* 47 */
int (*tcl_ListObjReplace) (Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size first, Tcl_Size count, Tcl_Size objc, Tcl_Obj *const objv[]); /* 48 */
void (*reserved49)(void);
Tcl_Obj * (*tcl_NewByteArrayObj) (const unsigned char *bytes, Tcl_Size numBytes); /* 50 */
@@ -2120,8 +2121,8 @@ typedef struct TclStubs {
const char * (*tcl_SignalId) (int sig); /* 239 */
const char * (*tcl_SignalMsg) (int sig); /* 240 */
void (*tcl_SourceRCFile) (Tcl_Interp *interp); /* 241 */
int (*tclSplitList) (Tcl_Interp *interp, const char *listStr, int *argcPtr, const char ***argvPtr); /* 242 */
void (*tclSplitPath) (const char *path, int *argcPtr, const char ***argvPtr); /* 243 */
int (*tclSplitList) (Tcl_Interp *interp, const char *listStr, void *argcPtr, const char ***argvPtr); /* 242 */
void (*tclSplitPath) (const char *path, void *argcPtr, const char ***argvPtr); /* 243 */
void (*reserved244)(void);
void (*reserved245)(void);
void (*reserved246)(void);
@@ -2271,7 +2272,7 @@ typedef struct TclStubs {
int (*tcl_ProcObjCmd) (void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[]); /* 390 */
void (*tcl_ConditionFinalize) (Tcl_Condition *condPtr); /* 391 */
void (*tcl_MutexFinalize) (Tcl_Mutex *mutex); /* 392 */
int (*tcl_CreateThread) (Tcl_ThreadId *idPtr, Tcl_ThreadCreateProc *proc, void *clientData, Tcl_Size stackSize, int flags); /* 393 */
int (*tcl_CreateThread) (Tcl_ThreadId *idPtr, Tcl_ThreadCreateProc *proc, void *clientData, TCL_HASH_TYPE stackSize, int flags); /* 393 */
Tcl_Size (*tcl_ReadRaw) (Tcl_Channel chan, char *dst, Tcl_Size bytesToRead); /* 394 */
Tcl_Size (*tcl_WriteRaw) (Tcl_Channel chan, const char *src, Tcl_Size srcLen); /* 395 */
Tcl_Channel (*tcl_GetTopChannel) (Tcl_Channel chan); /* 396 */
@@ -2312,7 +2313,7 @@ typedef struct TclStubs {
void * (*tcl_AttemptDbCkrealloc) (void *ptr, TCL_HASH_TYPE size, const char *file, int line); /* 431 */
int (*tcl_AttemptSetObjLength) (Tcl_Obj *objPtr, Tcl_Size length); /* 432 */
Tcl_ThreadId (*tcl_GetChannelThread) (Tcl_Channel channel); /* 433 */
Tcl_UniChar * (*tclGetUnicodeFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 434 */
Tcl_UniChar * (*tclGetUnicodeFromObj) (Tcl_Obj *objPtr, void *lengthPtr); /* 434 */
void (*reserved435)(void);
void (*reserved436)(void);
Tcl_Obj * (*tcl_SubstObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int flags); /* 437 */
@@ -2339,7 +2340,7 @@ typedef struct TclStubs {
int (*tcl_FSChdir) (Tcl_Obj *pathPtr); /* 458 */
int (*tcl_FSConvertToPathType) (Tcl_Interp *interp, Tcl_Obj *pathPtr); /* 459 */
Tcl_Obj * (*tcl_FSJoinPath) (Tcl_Obj *listObj, Tcl_Size elements); /* 460 */
Tcl_Obj * (*tclFSSplitPath) (Tcl_Obj *pathPtr, int *lenPtr); /* 461 */
Tcl_Obj * (*tclFSSplitPath) (Tcl_Obj *pathPtr, void *lenPtr); /* 461 */
int (*tcl_FSEqualPaths) (Tcl_Obj *firstPtr, Tcl_Obj *secondPtr); /* 462 */
Tcl_Obj * (*tcl_FSGetNormalizedPath) (Tcl_Interp *interp, Tcl_Obj *pathPtr); /* 463 */
Tcl_Obj * (*tcl_FSJoinToPath) (Tcl_Obj *pathPtr, Tcl_Size objc, Tcl_Obj *const objv[]); /* 464 */
@@ -2375,7 +2376,7 @@ typedef struct TclStubs {
int (*tcl_DictObjPut) (Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_Obj *keyPtr, Tcl_Obj *valuePtr); /* 494 */
int (*tcl_DictObjGet) (Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_Obj *keyPtr, Tcl_Obj **valuePtrPtr); /* 495 */
int (*tcl_DictObjRemove) (Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_Obj *keyPtr); /* 496 */
int (*tclDictObjSize) (Tcl_Interp *interp, Tcl_Obj *dictPtr, int *sizePtr); /* 497 */
int (*tclDictObjSize) (Tcl_Interp *interp, Tcl_Obj *dictPtr, void *sizePtr); /* 497 */
int (*tcl_DictObjFirst) (Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_DictSearch *searchPtr, Tcl_Obj **keyPtrPtr, Tcl_Obj **valuePtrPtr, int *donePtr); /* 498 */
void (*tcl_DictObjNext) (Tcl_DictSearch *searchPtr, Tcl_Obj **keyPtrPtr, Tcl_Obj **valuePtrPtr, int *donePtr); /* 499 */
void (*tcl_DictObjDone) (Tcl_DictSearch *searchPtr); /* 500 */
@@ -2482,7 +2483,7 @@ typedef struct TclStubs {
unsigned (*tcl_GetBlockSizeFromStat) (const Tcl_StatBuf *statPtr); /* 601 */
int (*tcl_SetEnsembleParameterList) (Tcl_Interp *interp, Tcl_Command token, Tcl_Obj *paramList); /* 602 */
int (*tcl_GetEnsembleParameterList) (Tcl_Interp *interp, Tcl_Command token, Tcl_Obj **paramListPtr); /* 603 */
int (*tclParseArgsObjv) (Tcl_Interp *interp, const Tcl_ArgvInfo *argTable, int *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv); /* 604 */
int (*tclParseArgsObjv) (Tcl_Interp *interp, const Tcl_ArgvInfo *argTable, void *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv); /* 604 */
int (*tcl_GetErrorLine) (Tcl_Interp *interp); /* 605 */
void (*tcl_SetErrorLine) (Tcl_Interp *interp, int lineNum); /* 606 */
void (*tcl_TransferResult) (Tcl_Interp *sourceInterp, int code, Tcl_Interp *targetInterp); /* 607 */
@@ -2527,7 +2528,7 @@ typedef struct TclStubs {
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 * (*tclGetBytesFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, void *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 */
@@ -4040,15 +4041,15 @@ extern const TclStubs *tclStubsPtr;
# 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->tclGetBytesFromObj(interp, objPtr, (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->tclGetStringFromObj(objPtr, (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->tclGetUnicodeFromObj(objPtr, (sizePtr)) : \
tclStubsPtr->tcl_GetUnicodeFromObj(objPtr, (Tcl_Size *)(void *)(sizePtr)))
# endif
#define Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, indexPtr) \
@@ -4063,19 +4064,15 @@ extern const TclStubs *tclStubsPtr;
#if TCL_MAJOR_VERSION > 8
#define Tcl_GetByteArrayFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetBytesFromObj(NULL, objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tclGetBytesFromObj(NULL, objPtr, (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->tclGetByteArrayFromObj(objPtr, (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)))
@@ -4085,18 +4082,27 @@ extern const TclStubs *tclStubsPtr;
#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)))
#if defined(TCL_NO_DEPRECATED)
#define Tcl_GetByteArrayFromObj(objPtr, sizePtr) \
(Tcl_GetBytesFromObj)(NULL, objPtr, (Tcl_Size *)(void *)(sizePtr))
#else
#define Tcl_GetByteArrayFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetBytesFromObj(NULL, objPtr, (int *)(void *)(sizePtr)) : \
TclGetBytesFromObj(NULL, objPtr, (sizePtr)) : \
(Tcl_GetBytesFromObj)(NULL, objPtr, (Tcl_Size *)(void *)(sizePtr)))
#define Tcl_GetUnicodeFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetUnicodeFromObj(objPtr, (int *)(void *)(sizePtr)) : \
TclGetUnicodeFromObj(objPtr, (sizePtr)) : \
(Tcl_GetUnicodeFromObj)(objPtr, (Tcl_Size *)(void *)(sizePtr)))
#define Tcl_GetStringFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetStringFromObj(objPtr, (sizePtr)) : \
(Tcl_GetStringFromObj)(objPtr, (Tcl_Size *)(void *)(sizePtr)))
#define Tcl_GetBytesFromObj(interp, objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetBytesFromObj(interp, objPtr, (sizePtr)) : \
(Tcl_GetBytesFromObj)(interp, objPtr, (Tcl_Size *)(void *)(sizePtr)))
#endif
#endif
#ifdef TCL_MEM_DEBUG
@@ -4168,34 +4174,36 @@ extern const TclStubs *tclStubsPtr;
# 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->tclListObjGetElements((interp), (listPtr), (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->tclListObjLength((interp), (listPtr), (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->tclDictObjSize((interp), (dictPtr), (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->tclSplitList((interp), (listStr), (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->tclSplitPath((path), (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->tclFSSplitPath((pathPtr), (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->tclParseArgsObjv((interp), (argTable), (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 \
@@ -4211,25 +4219,25 @@ extern const TclStubs *tclStubsPtr;
: (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)) \
? TclListObjGetElements((interp), (listPtr), (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)) \
? TclListObjLength((interp), (listPtr), (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)) \
? TclDictObjSize((interp), (dictPtr), (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)) \
? TclSplitList((interp), (listStr), (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)) \
? TclSplitPath((path), (argcPtr), (argvPtr)) \
: (Tcl_SplitPath)((path), (Tcl_Size *)(void *)(argcPtr), (argvPtr)))
# define Tcl_FSSplitPath(pathPtr, lenPtr) (sizeof(*(lenPtr)) == sizeof(int) \
? TclFSSplitPath((pathPtr), (int *)(void *)(lenPtr)) \
? TclFSSplitPath((pathPtr), (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)) \
? TclParseArgsObjv((interp), (argTable), (objcPtr), (objv), (remObjv)) \
: (Tcl_ParseArgsObjv)((interp), (argTable), (Tcl_Size *)(void *)(objcPtr), (objv), (remObjv)))
#endif /* !defined(BUILD_tcl) */
#endif
+193 -6
View File
@@ -61,6 +61,8 @@ static Tcl_ObjCmdProc DictForNRCmd;
static Tcl_ObjCmdProc DictMapNRCmd;
static Tcl_NRPostProc DictForLoopCallback;
static Tcl_NRPostProc DictMapLoopCallback;
static Tcl_ObjTypeLengthProc DictAsListLength;
/* static Tcl_ObjTypeIndexProc DictAsListIndex; Needs rewrite */
/*
* Table of dict subcommand names and implementations.
@@ -143,11 +145,22 @@ typedef struct Dict {
const Tcl_ObjType tclDictType = {
"dict",
FreeDictInternalRep, /* freeIntRepProc */
DupDictInternalRep, /* dupIntRepProc */
UpdateStringOfDict, /* updateStringProc */
SetDictFromAny, /* setFromAnyProc */
TCL_OBJTYPE_V0
FreeDictInternalRep, /* freeIntRepProc */
DupDictInternalRep, /* dupIntRepProc */
UpdateStringOfDict, /* updateStringProc */
SetDictFromAny, /* setFromAnyProc */
TCL_OBJTYPE_V2( /* Extended type for AbstractLists */
DictAsListLength, /* return "list" length of dict value w/o
* shimmering */
NULL, /* return key or value at "list" index
* location. (keysare at even indicies,
* values at odd indicies) */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL)
};
#define DictSetInternalRep(objPtr, dictRepPtr) \
@@ -603,7 +616,7 @@ SetDictFromAny(
* the conversion from lists to dictionaries.
*/
if (TclHasInternalRep(objPtr, &tclListType.objType)) {
if (TclHasInternalRep(objPtr, &tclListType)) {
Tcl_Size objc, i;
Tcl_Obj **objv;
@@ -1045,6 +1058,26 @@ Tcl_DictObjRemove(
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_DictGetSize
*
* Returns the size of dictPtr. Caller must ensure that dictPtr has type
* 'tclDicttype'.
*
*
*----------------------------------------------------------------------
*/
Tcl_Size
TclDictGetSize(Tcl_Obj *dictPtr)
{
Dict *dict;
DictGetInternalRep(dictPtr, dict);
return dict->table.numEntries;
}
/*
*----------------------------------------------------------------------
*
@@ -3768,6 +3801,160 @@ TclInitDictCmd(
return TclMakeEnsemble(interp, "dict", implementationMap);
}
/*
*----------------------------------------------------------------------
*
* DictAsListLength --
*
* Compute the length of a list as if the dict value were converted to a
* list.
*
* Note: the list length may not match the dict size * 2. This occurs when
* there are duplicate keys in the original string representation.
*
* Side Effects --
*
* The intent is to have no side effects.
*/
static Tcl_Size
DictAsListLength(
Tcl_Obj *objPtr)
{
Tcl_Size estCount, length, llen;
const char *limit, *nextElem = Tcl_GetStringFromObj(objPtr, &length);
Tcl_Obj *elemPtr;
/*
* Allocate enough space to hold a (Tcl_Obj *) for each
* (possible) list element.
*/
estCount = TclMaxListLength(nextElem, length, &limit);
estCount += (estCount == 0); /* Smallest list struct holds 1
* element. */
elemPtr = Tcl_NewObj();
llen = 0;
while (nextElem < limit) {
const char *elemStart;
char *check;
Tcl_Size elemSize;
int literal;
if (TCL_OK != TclFindElement(NULL, nextElem, limit - nextElem,
&elemStart, &nextElem, &elemSize, &literal)) {
Tcl_DecrRefCount(elemPtr);
return 0;
}
if (elemStart == limit) {
break;
}
TclInvalidateStringRep(elemPtr);
check = Tcl_InitStringRep(elemPtr, literal ? elemStart : NULL,
elemSize);
if (elemSize && check == NULL) {
Tcl_DecrRefCount(elemPtr);
return 0;
}
if (!literal) {
Tcl_InitStringRep(elemPtr, NULL,
TclCopyAndCollapse(elemSize, elemStart, check));
}
llen++;
}
Tcl_DecrRefCount(elemPtr);
return llen;
}
/*
*----------------------------------------------------------------------
*
* DictAsListIndex --
*
* Return the key or value at the given "list" index, i.e., as if the string
* value where treated as a list. The intent is to support this list
* operation w/o causing the Obj value to shimmer into a List.
*
* Side Effects --
*
* The intent is to have no side effects.
*
*/
#if 0 /* Needs rewrite */
static int
DictAsListIndex(
Tcl_Interp *interp,
struct Tcl_Obj *objPtr,
Tcl_Size index,
Tcl_Obj** elemObjPtr)
{
Tcl_Size /*estCount,*/ length, llen;
const char *limit, *nextElem = Tcl_GetStringFromObj(objPtr, &length);
Tcl_Obj *elemPtr;
/*
* Compute limit of the list string
*/
TclMaxListLength(nextElem, length, &limit);
elemPtr = Tcl_NewObj();
llen = 0;
/*
* parse out each element until reaching the "index"th element.
* Sure this is slow, but shimmering is slower.
*/
while (nextElem < limit) {
const char *elemStart;
char *check;
Tcl_Size elemSize;
int literal;
if (TCL_OK != TclFindElement(NULL, nextElem, limit - nextElem,
&elemStart, &nextElem, &elemSize, &literal)) {
Tcl_DecrRefCount(elemPtr);
return 0;
}
if (elemStart == limit) {
break;
}
TclInvalidateStringRep(elemPtr);
check = Tcl_InitStringRep(elemPtr, literal ? elemStart : NULL,
elemSize);
if (elemSize && check == NULL) {
Tcl_DecrRefCount(elemPtr);
if (interp) {
// Need error message here
}
return TCL_ERROR;
}
if (!literal) {
Tcl_InitStringRep(elemPtr, NULL,
TclCopyAndCollapse(elemSize, elemStart, check));
}
if (llen == index) {
*elemObjPtr = elemPtr;
return TCL_OK;
}
llen++;
}
/*
* Index is beyond end of list - return empty
*/
Tcl_InitStringRep(elemPtr, NULL, 0);
*elemObjPtr = elemPtr;
return TCL_OK;
}
#endif
/*
* Local Variables:
* mode: c
+23 -22
View File
@@ -256,7 +256,8 @@ DisassembleByteCodeObj(
unsigned char *codeStart, *codeLimit, *pc;
unsigned char *codeDeltaNext, *codeLengthNext;
unsigned char *srcDeltaNext, *srcLengthNext;
int codeOffset, codeLen, srcOffset, srcLen, numCmds, delta, i, line;
int codeOffset, codeLen, srcOffset, srcLen, numCmds, delta, line;
Tcl_Size i;
Interp *iPtr;
Tcl_Obj *bufferObj, *fileObj;
@@ -278,7 +279,7 @@ DisassembleByteCodeObj(
*/
Tcl_AppendPrintfToObj(bufferObj,
"ByteCode %p, refCt %" TCL_Z_MODIFIER "u, epoch %" TCL_Z_MODIFIER "u, interp %p (epoch %" TCL_Z_MODIFIER "u)\n",
"ByteCode %p, refCt %" TCL_SIZE_MODIFIER "u, epoch %" TCL_SIZE_MODIFIER "u, interp %p (epoch %" TCL_SIZE_MODIFIER "u)\n",
codePtr, codePtr->refCount, codePtr->compileEpoch, iPtr, iPtr->compileEpoch);
Tcl_AppendToObj(bufferObj, " Source ", -1);
PrintSourceToObj(bufferObj, codePtr->source,
@@ -289,7 +290,7 @@ DisassembleByteCodeObj(
TclGetString(fileObj), line);
}
Tcl_AppendPrintfToObj(bufferObj,
"\n Cmds %d, src %" TCL_Z_MODIFIER "u, inst %" TCL_Z_MODIFIER "u, litObjs %" TCL_Z_MODIFIER "u, aux %" TCL_Z_MODIFIER "u, stkDepth %" TCL_Z_MODIFIER "u, code/src %.2f\n",
"\n Cmds %d, src %" TCL_SIZE_MODIFIER "u, inst %" TCL_SIZE_MODIFIER "u, litObjs %" TCL_SIZE_MODIFIER "u, aux %" TCL_SIZE_MODIFIER "u, stkDepth %" TCL_SIZE_MODIFIER "u, code/src %.2f\n",
numCmds, codePtr->numSrcBytes, codePtr->numCodeBytes,
codePtr->numLitObjects, codePtr->numAuxDataItems,
codePtr->maxStackDepth,
@@ -301,8 +302,8 @@ DisassembleByteCodeObj(
#ifdef TCL_COMPILE_STATS
Tcl_AppendPrintfToObj(bufferObj,
" Code %" TCL_Z_MODIFIER "u = header %" TCL_Z_MODIFIER "u+inst %" TCL_Z_MODIFIER "u+litObj %"
TCL_Z_MODIFIER "u+exc %" TCL_Z_MODIFIER "u+aux %" TCL_Z_MODIFIER "u+cmdMap %" TCL_Z_MODIFIER "u\n",
" Code %" TCL_Z_MODIFIER "u = header %" TCL_Z_MODIFIER "u+inst %" TCL_SIZE_MODIFIER "u+litObj %"
TCL_Z_MODIFIER "u+exc %" TCL_Z_MODIFIER "u+aux %" TCL_Z_MODIFIER "u+cmdMap %" TCL_SIZE_MODIFIER "u\n",
codePtr->structureSize,
offsetof(ByteCode, localCachePtr),
codePtr->numCodeBytes,
@@ -320,10 +321,10 @@ DisassembleByteCodeObj(
if (codePtr->procPtr != NULL) {
Proc *procPtr = codePtr->procPtr;
int numCompiledLocals = procPtr->numCompiledLocals;
Tcl_Size numCompiledLocals = procPtr->numCompiledLocals;
Tcl_AppendPrintfToObj(bufferObj,
" Proc %p, refCt %" TCL_Z_MODIFIER "u, args %" TCL_Z_MODIFIER "u, compiled locals %d\n",
" Proc %p, refCt %" TCL_SIZE_MODIFIER "u, args %" TCL_SIZE_MODIFIER "u, compiled locals %" TCL_SIZE_MODIFIER "u\n",
procPtr, procPtr->refCount, procPtr->numArgs,
numCompiledLocals);
if (numCompiledLocals > 0) {
@@ -331,7 +332,7 @@ DisassembleByteCodeObj(
for (i = 0; i < numCompiledLocals; i++) {
Tcl_AppendPrintfToObj(bufferObj,
" slot %d%s%s%s%s%s%s", i,
" slot %" TCL_SIZE_MODIFIER "u%s%s%s%s%s%s", i,
(localPtr->flags & (VAR_ARRAY|VAR_LINK)) ? "" : ", scalar",
(localPtr->flags & VAR_ARRAY) ? ", array" : "",
(localPtr->flags & VAR_LINK) ? ", link" : "",
@@ -354,24 +355,24 @@ DisassembleByteCodeObj(
*/
if ((int)codePtr->numExceptRanges > 0) {
Tcl_AppendPrintfToObj(bufferObj, " Exception ranges %" TCL_Z_MODIFIER "u, depth %" TCL_Z_MODIFIER "u:\n",
Tcl_AppendPrintfToObj(bufferObj, " Exception ranges %" TCL_SIZE_MODIFIER "u, depth %" TCL_SIZE_MODIFIER "u:\n",
codePtr->numExceptRanges, codePtr->maxExceptDepth);
for (i = 0; i < (int)codePtr->numExceptRanges; i++) {
ExceptionRange *rangePtr = &codePtr->exceptArrayPtr[i];
Tcl_AppendPrintfToObj(bufferObj,
" %d: level %" TCL_Z_MODIFIER "u, %s, pc %" TCL_Z_MODIFIER "u-%" TCL_Z_MODIFIER "u, ",
" %" TCL_SIZE_MODIFIER "u: level %" TCL_SIZE_MODIFIER "u, %s, pc %" TCL_SIZE_MODIFIER "u-%" TCL_SIZE_MODIFIER "u, ",
i, rangePtr->nestingLevel,
(rangePtr->type==LOOP_EXCEPTION_RANGE ? "loop" : "catch"),
rangePtr->codeOffset,
(rangePtr->codeOffset + rangePtr->numCodeBytes - 1));
switch (rangePtr->type) {
case LOOP_EXCEPTION_RANGE:
Tcl_AppendPrintfToObj(bufferObj, "continue %" TCL_Z_MODIFIER "u, break %" TCL_Z_MODIFIER "u\n",
Tcl_AppendPrintfToObj(bufferObj, "continue %" TCL_SIZE_MODIFIER "u, break %" TCL_SIZE_MODIFIER "u\n",
rangePtr->continueOffset, rangePtr->breakOffset);
break;
case CATCH_EXCEPTION_RANGE:
Tcl_AppendPrintfToObj(bufferObj, "catch %" TCL_Z_MODIFIER "u\n",
Tcl_AppendPrintfToObj(bufferObj, "catch %" TCL_SIZE_MODIFIER "u\n",
rangePtr->catchOffset);
break;
default:
@@ -445,7 +446,7 @@ DisassembleByteCodeObj(
srcLengthNext++;
}
Tcl_AppendPrintfToObj(bufferObj, "%s%4d: pc %d-%d, src %d-%d",
Tcl_AppendPrintfToObj(bufferObj, "%s%4" TCL_SIZE_MODIFIER "u: pc %d-%d, src %d-%d",
((i % 2)? " " : "\n "),
(i+1), codeOffset, (codeOffset + codeLen - 1),
srcOffset, (srcOffset + srcLen - 1));
@@ -504,7 +505,7 @@ DisassembleByteCodeObj(
pc += FormatInstruction(codePtr, pc, bufferObj);
}
Tcl_AppendPrintfToObj(bufferObj, " Command %d: ", i+1);
Tcl_AppendPrintfToObj(bufferObj, " Command %" TCL_SIZE_MODIFIER "u: ", i+1);
PrintSourceToObj(bufferObj, (codePtr->source + srcOffset),
TclMin(srcLen, 55));
Tcl_AppendToObj(bufferObj, "\n", -1);
@@ -544,7 +545,7 @@ FormatInstruction(
unsigned char *codeStart = codePtr->codeStart;
unsigned pcOffset = pc - codeStart;
int opnd = 0, i, j, numBytes = 1;
int localCt = procPtr ? (int)procPtr->numCompiledLocals : 0;
Tcl_Size localCt = procPtr ? procPtr->numCompiledLocals : 0;
CompiledLocal *localPtr = procPtr ? procPtr->firstLocalPtr : NULL;
char suffixBuffer[128]; /* Additional info to print after main opcode
* and immediates. */
@@ -625,7 +626,7 @@ FormatInstruction(
printLVTindex:
if (localPtr != NULL) {
if (opnd >= localCt) {
Tcl_Panic("FormatInstruction: bad local var index %u (%u locals)",
Tcl_Panic("FormatInstruction: bad local var index %u (%" TCL_SIZE_MODIFIER "u locals)",
opnd, localCt);
}
for (j = 0; j < opnd; j++) {
@@ -943,8 +944,8 @@ DisassembleByteCodeAsDicts(
Tcl_Obj *description, *literals, *variables, *instructions, *inst;
Tcl_Obj *aux, *exn, *commands, *file;
unsigned char *pc, *opnd, *codeOffPtr, *codeLenPtr, *srcOffPtr, *srcLenPtr;
int codeOffset, codeLength, sourceOffset, sourceLength;
int i, val, line;
int codeOffset, codeLength, sourceOffset, sourceLength, val, line;
Tcl_Size i;
ByteCodeGetInternalRep(objPtr, &tclByteCodeType, codePtr);
@@ -953,7 +954,7 @@ DisassembleByteCodeAsDicts(
*/
TclNewObj(literals);
for (i=0 ; i<(int)codePtr->numLitObjects ; i++) {
for (i=0 ; i<codePtr->numLitObjects ; i++) {
Tcl_ListObjAppendElement(NULL, literals, codePtr->objArrayPtr[i]);
}
@@ -963,7 +964,7 @@ DisassembleByteCodeAsDicts(
TclNewObj(variables);
if (codePtr->procPtr) {
int localCount = codePtr->procPtr->numCompiledLocals;
Tcl_Size localCount = codePtr->procPtr->numCompiledLocals;
CompiledLocal *localPtr = codePtr->procPtr->firstLocalPtr;
for (i=0 ; i<localCount ; i++,localPtr=localPtr->nextPtr) {
@@ -1146,14 +1147,14 @@ DisassembleByteCodeAsDicts(
switch (rangePtr->type) {
case LOOP_EXCEPTION_RANGE:
Tcl_ListObjAppendElement(NULL, exn, Tcl_ObjPrintf(
"type %s level %" TCL_Z_MODIFIER "u from %" TCL_Z_MODIFIER "u to %" TCL_Z_MODIFIER "u break %" TCL_Z_MODIFIER "u continue %" TCL_Z_MODIFIER "u",
"type %s level %" TCL_SIZE_MODIFIER "u from %" TCL_SIZE_MODIFIER "u to %" TCL_SIZE_MODIFIER "u break %" TCL_SIZE_MODIFIER "u continue %" TCL_SIZE_MODIFIER "u",
"loop", rangePtr->nestingLevel, rangePtr->codeOffset,
rangePtr->codeOffset + rangePtr->numCodeBytes - 1,
rangePtr->breakOffset, rangePtr->continueOffset));
break;
case CATCH_EXCEPTION_RANGE:
Tcl_ListObjAppendElement(NULL, exn, Tcl_ObjPrintf(
"type %s level %" TCL_Z_MODIFIER "u from %" TCL_Z_MODIFIER "u to %" TCL_Z_MODIFIER "u catch %" TCL_Z_MODIFIER "u",
"type %s level %" TCL_SIZE_MODIFIER "u from %" TCL_SIZE_MODIFIER "u to %" TCL_SIZE_MODIFIER "u catch %" TCL_SIZE_MODIFIER "u",
"catch", rangePtr->nestingLevel, rangePtr->codeOffset,
rangePtr->codeOffset + rangePtr->numCodeBytes - 1,
rangePtr->catchOffset));
+101 -38
View File
@@ -10,7 +10,7 @@
*/
#include "tclInt.h"
#include "tclIO.h"
#include <assert.h>
typedef size_t (LengthProc)(const char *src);
@@ -186,6 +186,7 @@ TCL_DECLARE_MUTEX(encodingMutex)
static Tcl_Encoding defaultEncoding = NULL;
static Tcl_Encoding systemEncoding = NULL;
Tcl_Encoding tclIdentityEncoding = NULL;
Tcl_Encoding tclUtf8Encoding = NULL;
/*
* Names of encoding profiles and corresponding integer values.
@@ -200,16 +201,16 @@ static struct TclEncodingProfiles {
{"tcl8", TCL_ENCODING_PROFILE_TCL8},
};
#define PROFILE_TCL8(flags_) \
((CHANNEL_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_TCL8) \
|| (CHANNEL_PROFILE_GET(flags_) == 0 \
((ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_TCL8) \
|| (ENCODING_PROFILE_GET(flags_) == 0 \
&& TCL_ENCODING_PROFILE_DEFAULT == TCL_ENCODING_PROFILE_TCL8))
#define PROFILE_STRICT(flags_) \
((CHANNEL_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_STRICT) \
|| (CHANNEL_PROFILE_GET(flags_) == 0 \
((ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_STRICT) \
|| (ENCODING_PROFILE_GET(flags_) == 0 \
&& TCL_ENCODING_PROFILE_DEFAULT == TCL_ENCODING_PROFILE_STRICT))
#define PROFILE_REPLACE(flags_) \
((CHANNEL_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_REPLACE) \
|| (CHANNEL_PROFILE_GET(flags_) == 0 \
((ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_REPLACE) \
|| (ENCODING_PROFILE_GET(flags_) == 0 \
&& TCL_ENCODING_PROFILE_DEFAULT == TCL_ENCODING_PROFILE_REPLACE))
#define UNICODE_REPLACE_CHAR ((Tcl_UniChar)0xFFFD)
@@ -572,8 +573,8 @@ TclInitEncodingSubsystem(void)
unsigned size;
unsigned short i;
union {
char c;
short s;
char c;
short s;
} isLe;
int leFlags;
@@ -609,7 +610,7 @@ TclInitEncodingSubsystem(void)
type.freeProc = NULL;
type.nullSize = 1;
type.clientData = INT2PTR(ENCODING_UTF);
Tcl_CreateEncoding(&type);
tclUtf8Encoding = Tcl_CreateEncoding(&type);
type.clientData = NULL;
type.encodingName = "cesu-8";
Tcl_CreateEncoding(&type);
@@ -731,6 +732,8 @@ TclFinalizeEncodingSubsystem(void)
defaultEncoding = NULL;
FreeEncoding(tclIdentityEncoding);
tclIdentityEncoding = NULL;
FreeEncoding(tclUtf8Encoding);
tclUtf8Encoding = NULL;
hPtr = Tcl_FirstHashEntry(&encodingTable, &search);
while (hPtr != NULL) {
@@ -1166,7 +1169,7 @@ Tcl_ExternalToUtfDString(
* Tcl_ExternalToUtfDStringEx --
*
* Convert a source buffer from the specified encoding into UTF-8.
* The parameter flags controls the behavior, if any of the bytes in
* "flags" controls the behavior if any of the bytes in
* the source buffer are invalid or cannot be represented in utf-8.
* Possible flags values:
* target encoding. It should be composed by OR-ing the following:
@@ -1235,6 +1238,7 @@ Tcl_ExternalToUtfDStringEx(
"Parameter error: TCL_ENCODING_{START,STOP} bits set in flags.",
TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "ENCODING", "ILLEGALFLAGS", NULL);
errno = EINVAL;
return TCL_ERROR;
}
@@ -1299,17 +1303,20 @@ Tcl_ExternalToUtfDStringEx(
/* 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);
snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "u", nBytesProcessed);
Tcl_SetObjResult(
interp,
Tcl_ObjPrintf("unexpected byte sequence starting at index %"
TCL_Z_MODIFIER "u: '\\x%02X'",
TCL_SIZE_MODIFIER "u: '\\x%02X'",
nBytesProcessed,
UCHAR(srcStart[nBytesProcessed])));
Tcl_SetErrorCode(
interp, "TCL", "ENCODING", "ILLEGALSEQUENCE", buf, NULL);
}
}
if (result != TCL_OK) {
errno = (result == TCL_CONVERT_NOSPACE) ? ENOMEM : EILSEQ;
}
return result;
}
@@ -1500,7 +1507,7 @@ Tcl_UtfToExternalDString(
* The parameter flags controls the behavior, if any of the bytes in
* the source buffer are invalid or cannot be represented in the
* target encoding. It should be composed by OR-ing the following:
* - *At most one* of TCL_ENCODING_PROFILE{DEFAULT,TCL8,STRICT}
* - *At most one* of TCL_ENCODING_PROFILE_*
* - TCL_ENCODING_STOPONERROR: Backward compatibility. Sets the profile
* to TCL_ENCODING_PROFILE_STRICT overriding any specified profile flags
*
@@ -1563,6 +1570,7 @@ Tcl_UtfToExternalDStringEx(
"Parameter error: TCL_ENCODING_{START,STOP} bits set in flags.",
TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "ENCODING", "ILLEGALFLAGS", NULL);
errno = EINVAL;
return TCL_ERROR;
}
@@ -1630,11 +1638,11 @@ Tcl_UtfToExternalDStringEx(
int ucs4;
char buf[TCL_INTEGER_SPACE];
TclUtfToUCS4(&srcStart[nBytesProcessed], &ucs4);
snprintf(buf, sizeof(buf), "%" TCL_Z_MODIFIER "u", nBytesProcessed);
snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "u", nBytesProcessed);
Tcl_SetObjResult(
interp,
Tcl_ObjPrintf(
"unexpected character at index %" TCL_Z_MODIFIER
"unexpected character at index %" TCL_SIZE_MODIFIER
"u: 'U+%06X'",
pos,
ucs4));
@@ -1642,6 +1650,9 @@ Tcl_UtfToExternalDStringEx(
buf, NULL);
}
}
if (result != TCL_OK) {
errno = (result == TCL_CONVERT_NOSPACE) ? ENOMEM : EILSEQ;
}
return result;
}
@@ -2532,7 +2543,17 @@ UtfToUtfProc(
flags |= PTR2INT(clientData);
dstEnd = dst + dstLen - ((flags & ENCODING_UTF) ? TCL_UTF_MAX : 6);
profile = CHANNEL_PROFILE_GET(flags);
#if TCL_UTF_MAX < 4
/* Initialize the buffer so that some random data doesn't trick
* Tcl_UniCharToUtf() into thinking it should combine surrogate pairs.
* Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its
* prior non-stateful nature, this call to memset can also be removed.
*/
memset(dst, 0xff, dstLen);
#endif
profile = ENCODING_PROFILE_GET(flags);
for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
if ((src > srcClose) && (!Tcl_UtfCharComplete(src, srcEnd - src))) {
@@ -2579,10 +2600,10 @@ UtfToUtfProc(
} else if (!Tcl_UtfCharComplete(src, srcEnd - src)) {
/*
* Incomplete byte sequence.
* Always check before using TclUtfToUCS4. Not doing can so
* cause it run beyond the end of the buffer! If we happen such an
* incomplete char its bytes are made to represent themselves
* unless the user has explicitly asked to be told.
* Always check before using TclUtfToUCS4. Not doing so can cause it
* run beyond the end of the buffer! If we happen on such an incomplete
* char its bytes are made to represent themselves unless the user has
* explicitly asked to be told.
*/
if (flags & ENCODING_INPUT) {
@@ -2746,6 +2767,15 @@ Utf32ToUtfProc(
}
result = TCL_OK;
#if TCL_UTF_MAX < 4
/* Initialize the buffer so that some random data doesn't trick
* Tcl_UniCharToUtf() into thinking it should combine surrogate pairs.
* Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its
* prior non-stateful nature, this call to memset can also be removed.
*/
memset(dst, 0xff, dstLen);
#endif
/*
* Check alignment with utf-32 (4 == sizeof(UTF-32))
*/
@@ -3015,6 +3045,15 @@ Utf16ToUtfProc(
}
result = TCL_OK;
#if TCL_UTF_MAX < 4
/* Initialize the buffer so that some random data doesn't trick
* Tcl_UniCharToUtf() into thinking it should combine surrogate pairs.
* Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its
* prior non-stateful nature, this call to memset can also be removed.
*/
memset(dst, 0xff, dstLen);
#endif
/*
* Check alignment with utf-16 (2 == sizeof(UTF-16))
*/
@@ -3428,6 +3467,15 @@ TableToUtfProc(
dstStart = dst;
dstEnd = dst + dstLen - TCL_UTF_MAX;
#if TCL_UTF_MAX < 4
/* Initialize the buffer so that some random data doesn't trick
* Tcl_UniCharToUtf() into thinking it should combine surrogate pairs.
* Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its
* prior non-stateful nature, this call to memset can also be removed.
*/
memset(dst, 0xff, dstLen);
#endif
toUnicode = (const unsigned short *const *) dataPtr->toUnicode;
prefixBytes = dataPtr->prefixBytes;
pageZero = toUnicode[0];
@@ -3440,30 +3488,28 @@ TableToUtfProc(
}
byte = *((unsigned char *) src);
if (prefixBytes[byte]) {
src++;
if (src >= srcEnd) {
if (src >= srcEnd-1) {
/* Prefix byte but nothing after it */
if (!(flags & TCL_ENCODING_END)) {
src--;
/* More data to come */
result = TCL_CONVERT_MULTIBYTE;
break;
} else if (PROFILE_STRICT(flags)) {
src--;
result = TCL_CONVERT_SYNTAX;
break;
} else if (PROFILE_REPLACE(flags)) {
ch = UNICODE_REPLACE_CHAR;
} else {
src--; /* See bug [bdcb5126c0] */
result = TCL_CONVERT_MULTIBYTE;
break;
ch = (Tcl_UniChar)byte;
}
} else {
ch = toUnicode[byte][*((unsigned char *)src)];
ch = toUnicode[byte][*((unsigned char *)++src)];
}
} else {
ch = pageZero[byte];
}
if ((ch == 0) && (byte != 0)) {
/* Prefix+suffix pair is invalid */
if (PROFILE_STRICT(flags)) {
result = TCL_CONVERT_SYNTAX;
break;
@@ -3490,6 +3536,7 @@ TableToUtfProc(
src++;
}
assert(src <= srcEnd);
*srcReadPtr = src - srcStart;
*dstWrotePtr = dst - dstStart;
*dstCharsPtr = numChars;
@@ -3669,6 +3716,15 @@ Iso88591ToUtfProc(
dstStart = dst;
dstEnd = dst + dstLen - TCL_UTF_MAX;
#if TCL_UTF_MAX < 4
/* Initialize the buffer so that some random data doesn't trick
* Tcl_UniCharToUtf() into thinking it should combine surrogate pairs.
* Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its
* prior non-stateful nature, this call to memset can also be removed.
*/
memset(dst, 0xff, dstLen);
#endif
result = TCL_OK;
for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
Tcl_UniChar ch = 0;
@@ -3908,6 +3964,15 @@ EscapeToUtfProc(
dstStart = dst;
dstEnd = dst + dstLen - TCL_UTF_MAX;
#if TCL_UTF_MAX < 4
/* Initialize the buffer so that some random data doesn't trick
* Tcl_UniCharToUtf() into thinking it should combine surrogate pairs.
* Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its
* prior non-stateful nature, this call to memset can also be removed.
*/
memset(dst, 0xff, dstLen);
#endif
state = PTR2INT(*statePtr);
if (flags & TCL_ENCODING_START) {
state = 0;
@@ -4004,12 +4069,10 @@ EscapeToUtfProc(
if ((checked == dataPtr->numSubTables + 2)
|| (flags & TCL_ENCODING_END)) {
if (!PROFILE_STRICT(flags)) {
/*
* Skip the unknown escape sequence. TODO - bug?
* May be replace with UNICODE_REPLACE_CHAR?
*/
src += longest;
unsigned skip = longest > left ? left : longest;
/* Unknown escape sequence */
dst += Tcl_UniCharToUtf(UNICODE_REPLACE_CHAR, dst);
src += skip;
continue;
}
result = TCL_CONVERT_SYNTAX;
@@ -4587,9 +4650,9 @@ TclEncodingProfileIdToName(
int TclEncodingSetProfileFlags(int flags)
{
if (flags & TCL_ENCODING_STOPONERROR) {
CHANNEL_PROFILE_SET(flags, TCL_ENCODING_PROFILE_STRICT);
ENCODING_PROFILE_SET(flags, TCL_ENCODING_PROFILE_STRICT);
} else {
int profile = CHANNEL_PROFILE_GET(flags);
int profile = ENCODING_PROFILE_GET(flags);
switch (profile) {
case TCL_ENCODING_PROFILE_TCL8:
case TCL_ENCODING_PROFILE_STRICT:
@@ -4597,7 +4660,7 @@ int TclEncodingSetProfileFlags(int flags)
break;
case 0: /* Unspecified by caller */
default:
CHANNEL_PROFILE_SET(flags, TCL_ENCODING_PROFILE_DEFAULT);
ENCODING_PROFILE_SET(flags, TCL_ENCODING_PROFILE_DEFAULT);
break;
}
}
+39 -10
View File
@@ -312,7 +312,17 @@ TclNamespaceEnsembleCmd(
Tcl_AppendObjToObj(newCmd, listv[0]);
Tcl_ListObjReplace(NULL, newList, 0, 1, 1, &newCmd);
if (patchedDict == NULL) {
patchedDict = Tcl_DuplicateObj(objv[1]);
patchedDict = TclDuplicatePureObj(
interp, objv[1], &tclDictType);
if (!patchedDict) {
if (allocatedMapFlag) {
Tcl_DecrRefCount(mapObj);
}
Tcl_DecrRefCount(newList);
Tcl_DecrRefCount(newCmd);
Tcl_DecrRefCount(patchedDict);
return TCL_ERROR;
}
}
Tcl_DictObjPut(NULL, patchedDict, subcmdWordsObj,
newList);
@@ -596,7 +606,14 @@ TclNamespaceEnsembleCmd(
}
cmd = TclGetString(listv[0]);
if (!(cmd[0] == ':' && cmd[1] == ':')) {
Tcl_Obj *newList = Tcl_DuplicateObj(listObj);
Tcl_Obj *newList = TclDuplicatePureObj(
interp, listObj, &tclListType);
if (!newList) {
if (patchedDict) {
Tcl_DecrRefCount(patchedDict);
}
goto freeMapAndError;
}
Tcl_Obj *newCmd = NewNsObj((Tcl_Namespace*)nsPtr);
if (nsPtr->parentPtr) {
@@ -606,7 +623,11 @@ TclNamespaceEnsembleCmd(
Tcl_ListObjReplace(NULL, newList, 0, 1, 1,
&newCmd);
if (patchedDict == NULL) {
patchedDict = Tcl_DuplicateObj(objv[1]);
patchedDict = TclDuplicatePureObj(
interp, objv[1], &tclListType);
if (!patchedDict) {
goto freeMapAndError;
}
}
Tcl_DictObjPut(NULL, patchedDict, subcmdWordsObj,
newList);
@@ -1904,7 +1925,11 @@ NsEnsembleImplementationCmdNR(
TclListObjLengthM(NULL, prefixObj, &prefixObjc);
if (objc == 2) {
copyPtr = TclListObjCopy(NULL, prefixObj);
copyPtr = TclDuplicatePureObj(
interp, prefixObj, &tclListType);
if (!copyPtr) {
return TCL_ERROR;
}
} else {
copyPtr = Tcl_NewListObj(objc - 2 + prefixObjc, NULL);
Tcl_ListObjAppendList(NULL, copyPtr, prefixObj);
@@ -2304,7 +2329,11 @@ EnsembleUnknownCallback(
* Create the "unknown" command callback to determine what to do.
*/
unknownCmd = Tcl_DuplicateObj(ensemblePtr->unknownHandler);
unknownCmd = TclDuplicatePureObj(
interp, ensemblePtr->unknownHandler, &tclListType);
if (!unknownCmd) {
return TCL_ERROR;
}
TclNewObj(ensObj);
Tcl_GetCommandFullName(interp, ensemblePtr->token, ensObj);
Tcl_ListObjAppendElement(NULL, unknownCmd, ensObj);
@@ -3264,7 +3293,7 @@ TclAttemptCompileProc(
Tcl_Size i;
Tcl_Token *saveTokenPtr = parsePtr->tokenPtr;
Tcl_Size savedStackDepth = envPtr->currStackDepth;
unsigned savedCodeNext = envPtr->codeNext - envPtr->codeStart;
Tcl_Size savedCodeNext = envPtr->codeNext - envPtr->codeStart;
Tcl_Size savedAuxDataArrayNext = envPtr->auxDataArrayNext;
Tcl_Size savedExceptArrayNext = envPtr->exceptArrayNext;
#ifdef TCL_COMPILE_DEBUG
@@ -3327,13 +3356,13 @@ TclAttemptCompileProc(
ExceptionAux *auxPtr = envPtr->exceptAuxArrayPtr;
for (i = 0; i < savedExceptArrayNext; i++) {
while ((int)auxPtr->numBreakTargets > 0
&& auxPtr->breakTargets[auxPtr->numBreakTargets - 1]
while (auxPtr->numBreakTargets > 0
&& (Tcl_Size) auxPtr->breakTargets[auxPtr->numBreakTargets - 1]
>= savedCodeNext) {
auxPtr->numBreakTargets--;
}
while ((int)auxPtr->numContinueTargets > 0
&& auxPtr->continueTargets[auxPtr->numContinueTargets - 1]
while (auxPtr->numContinueTargets > 0
&& (Tcl_Size) auxPtr->continueTargets[auxPtr->numContinueTargets - 1]
>= savedCodeNext) {
auxPtr->numContinueTargets--;
}
+43 -27
View File
@@ -19,20 +19,20 @@ TCL_DECLARE_MUTEX(envMutex) /* To serialize access to environ. */
#if defined(_WIN32)
# define tenviron _wenviron
# define tenviron2utfdstr(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \
(char *)Tcl_Char16ToUtfDString((const unsigned short *)(string), ((((len) + 2) >> 1) - 1), (dsPtr)))
# define utf2tenvirondstr(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \
(const WCHAR *)Tcl_UtfToChar16DString((string), (len), (dsPtr)))
# define tenviron2utfdstr(str, dsPtr) (Tcl_DStringInit(dsPtr), \
(char *)Tcl_Char16ToUtfDString((const unsigned short *)(str), -1, (dsPtr)))
# define utf2tenvirondstr(str, dsPtr) (Tcl_DStringInit(dsPtr), \
(const WCHAR *)Tcl_UtfToChar16DString((str), -1, (dsPtr)))
# define techar WCHAR
# ifdef USE_PUTENV
# define putenv(env) _wputenv((const wchar_t *)env)
# endif
#else
# define tenviron environ
# define tenviron2utfdstr(tenvstr, len, dstr) \
Tcl_ExternalToUtfDString(NULL, tenvstr, len, dstr)
# define utf2tenvirondstr(str, len, dstr) \
Tcl_UtfToExternalDString(NULL, str, len, dstr)
# define tenviron2utfdstr(str, dsPtr) \
Tcl_ExternalToUtfDString(NULL, str, -1, dsPtr)
# define utf2tenvirondstr(str, dsPtr) \
Tcl_UtfToExternalDString(NULL, str, -1, dsPtr)
# define techar char
#endif
@@ -42,7 +42,7 @@ size_t TclEnvEpoch = 0; /* Epoch of the tcl environment
* (if changed with tcl-env). */
static struct {
size_t cacheSize; /* Number of env strings in cache. */
Tcl_Size cacheSize; /* Number of env strings in cache. */
char **cache; /* Array containing all of the environment
* strings that Tcl has allocated. */
#ifndef USE_PUTENV
@@ -159,7 +159,11 @@ TclSetupEnv(
const char *p1;
char *p2;
p1 = tenviron2utfdstr(tenviron[i], -1, &envString);
p1 = tenviron2utfdstr(tenviron[i], &envString);
if (p1 == NULL) {
/* Ignore what cannot be decoded (should not happen) */
continue;
}
p2 = (char *)strchr(p1, '=');
if (p2 == NULL) {
/*
@@ -301,9 +305,9 @@ TclSetEnv(
* interpreters.
*/
oldEnv = tenviron2utfdstr(tenviron[index], -1, &envString);
if (strcmp(value, oldEnv + (length + 1)) == 0) {
Tcl_DStringFree(&envString);
oldEnv = tenviron2utfdstr(tenviron[index], &envString);
if (oldEnv == NULL || strcmp(value, oldEnv + (length + 1)) == 0) {
Tcl_DStringFree(&envString); /* OK even if oldEnv is NULL */
Tcl_MutexUnlock(&envMutex);
return;
}
@@ -324,7 +328,13 @@ TclSetEnv(
memcpy(p, name, nameLength);
p[nameLength] = '=';
memcpy(p+nameLength+1, value, valueLength+1);
p2 = utf2tenvirondstr(p, -1, &envString);
p2 = utf2tenvirondstr(p, &envString);
if (p2 == NULL) {
/* No way to signal error from here :-( but should not happen */
Tcl_Free(p);
Tcl_MutexUnlock(&envMutex);
return;
}
/*
* Copy the native string to heap memory.
@@ -502,7 +512,11 @@ TclUnsetEnv(
string[length] = '\0';
#endif /* _WIN32 */
utf2tenvirondstr(string, -1, &envString);
if (utf2tenvirondstr(string, &envString) == NULL) {
/* Should not happen except memory alloc fail. */
Tcl_MutexUnlock(&envMutex);
return;
}
string = (char *)Tcl_Realloc(string, Tcl_DStringLength(&envString) + tNTL);
memcpy(string, Tcl_DStringValue(&envString),
Tcl_DStringLength(&envString) + tNTL);
@@ -577,17 +591,19 @@ TclGetEnv(
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;
result = tenviron2utfdstr(tenviron[index], &envStr);
if (result) {
result += length;
if (*result == '=') {
result++;
Tcl_DStringInit(valuePtr);
Tcl_DStringAppend(valuePtr, result, -1);
result = Tcl_DStringValue(valuePtr);
} else {
result = NULL;
}
Tcl_DStringFree(&envStr);
}
Tcl_DStringFree(&envStr);
}
Tcl_MutexUnlock(&envMutex);
return result;
@@ -703,7 +719,7 @@ ReplaceString(
const char *oldStr, /* Old environment string. */
char *newStr) /* New environment string. */
{
size_t i;
Tcl_Size i;
/*
* Check to see if the old value was allocated by Tcl. If so, it needs to
@@ -782,7 +798,7 @@ TclFinalizeEnvironment(void)
if (env.cache) {
#ifdef PURIFY
size_t i;
Tcl_Size i;
for (i = 0; i < env.cacheSize; i++) {
Tcl_Free(env.cache[i]);
}
+6 -2
View File
@@ -232,7 +232,11 @@ HandleBgErrors(
* support one handler setting another handler.
*/
Tcl_Obj *copyObj = TclListObjCopy(NULL, assocPtr->cmdPrefix);
Tcl_Obj *copyObj = TclDuplicatePureObj(
interp, assocPtr->cmdPrefix, &tclListType);
if (!copyObj) {
return;
}
errPtr = assocPtr->firstBgPtr;
@@ -2048,7 +2052,7 @@ 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 */
TCL_HASH_TYPE stackSize, /* Size of stack for the new thread */
int flags) /* Flags controlling behaviour of the new
* thread. */
{
+309 -188
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -2339,8 +2339,8 @@ Tcl_AllocStatBuf(void)
* Access functions for Tcl_StatBuf --
*
* These functions provide portable read-only access to the portable
* fields of the Tcl_StatBuf structure (really a 'struct stat', 'struct
* stat64' or something else related). [TIP #316]
* fields of the Tcl_StatBuf structure (really a 'struct stat'
* or something else related). [TIP #316]
*
* Results:
* The value from the field being retrieved.
+62 -75
View File
@@ -205,7 +205,7 @@ 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;
static void FreeBinaryEncoding(void);
static Tcl_HashTable * GetChannelTable(Tcl_Interp *interp);
static int GetInput(Channel *chanPtr);
static void PeekAhead(Channel *chanPtr, char **dstEndPtr,
@@ -223,8 +223,8 @@ static void StopCopy(CopyState *csPtr);
static void TranslateInputEOL(ChannelState *statePtr, char *dst,
const char *src, int *dstLenPtr, int *srcLenPtr);
static void UpdateInterest(Channel *chanPtr);
static int Write(Channel *chanPtr, const char *src,
int srcLen, Tcl_Encoding encoding);
static Tcl_Size Write(Channel *chanPtr, const char *src,
Tcl_Size srcLen, Tcl_Encoding encoding);
static Tcl_Obj * FixLevelCode(Tcl_Obj *msg);
static void SpliceChannel(Tcl_Channel chan);
static void CutChannel(Tcl_Channel chan);
@@ -659,7 +659,7 @@ TclFinalizeIOSubsystem(void)
statePtr->refCount--;
}
if (statePtr->refCount + 1 <= 1) {
if (statePtr->refCount <= 0) {
/*
* Close it only if the refcount indicates that the channel is
* not referenced from any interpreter. If it is, that
@@ -695,6 +695,7 @@ TclFinalizeIOSubsystem(void)
}
}
FreeBinaryEncoding();
TclpFinalizeSockets();
TclpFinalizePipes();
}
@@ -1077,7 +1078,7 @@ CheckForStdChannelsBeingClosed(
if (tsdPtr->stdinInitialized == 1
&& tsdPtr->stdinChannel != NULL
&& statePtr == ((Channel *)tsdPtr->stdinChannel)->state) {
if (statePtr->refCount + 1 < 3) {
if (statePtr->refCount < 2) {
statePtr->refCount = 0;
tsdPtr->stdinChannel = NULL;
return;
@@ -1085,7 +1086,7 @@ CheckForStdChannelsBeingClosed(
} else if (tsdPtr->stdoutInitialized == 1
&& tsdPtr->stdoutChannel != NULL
&& statePtr == ((Channel *)tsdPtr->stdoutChannel)->state) {
if (statePtr->refCount + 1 < 3) {
if (statePtr->refCount < 2) {
statePtr->refCount = 0;
tsdPtr->stdoutChannel = NULL;
return;
@@ -1093,7 +1094,7 @@ CheckForStdChannelsBeingClosed(
} else if (tsdPtr->stderrInitialized == 1
&& tsdPtr->stderrChannel != NULL
&& statePtr == ((Channel *)tsdPtr->stderrChannel)->state) {
if (statePtr->refCount + 1 < 3) {
if (statePtr->refCount < 2) {
statePtr->refCount = 0;
tsdPtr->stderrChannel = NULL;
return;
@@ -1255,7 +1256,7 @@ Tcl_UnregisterChannel(
* If the refCount reached zero, close the actual channel.
*/
if (statePtr->refCount + 1 <= 1) {
if (statePtr->refCount <= 0) {
Tcl_Preserve(statePtr);
if (!GotFlag(statePtr, BG_FLUSH_SCHEDULED)) {
/*
@@ -1679,11 +1680,11 @@ Tcl_CreateChannel(
statePtr->encoding = Tcl_GetEncoding(NULL, name);
statePtr->inputEncodingState = NULL;
statePtr->inputEncodingFlags = TCL_ENCODING_START;
CHANNEL_PROFILE_SET(statePtr->inputEncodingFlags,
ENCODING_PROFILE_SET(statePtr->inputEncodingFlags,
TCL_ENCODING_PROFILE_DEFAULT);
statePtr->outputEncodingState = NULL;
statePtr->outputEncodingFlags = TCL_ENCODING_START;
CHANNEL_PROFILE_SET(statePtr->outputEncodingFlags,
ENCODING_PROFILE_SET(statePtr->outputEncodingFlags,
TCL_ENCODING_PROFILE_DEFAULT);
/*
@@ -2003,7 +2004,7 @@ static void
ChannelFree(
Channel *chanPtr)
{
if (!chanPtr->refCount) {
if (chanPtr->refCount == 0) {
Tcl_Free(chanPtr);
return;
}
@@ -2178,7 +2179,7 @@ Tcl_UnstackChannel(
* necessary.
*/
if (statePtr->refCount + 1 <= 1) {
if (statePtr->refCount <= 0) {
if (Tcl_CloseEx(interp, chan, 0) != TCL_OK) {
/*
* TIP #219, Tcl Channel Reflection API.
@@ -2546,7 +2547,7 @@ static int
IsShared(
ChannelBuffer *bufPtr)
{
return bufPtr->refCount + 1 > 2;
return bufPtr->refCount > 1;
}
/*
@@ -2995,7 +2996,7 @@ FlushChannel(
* current output buffer.
*/
if (GotFlag(statePtr, CHANNEL_CLOSED) && (statePtr->refCount + 1 <= 1) &&
if (GotFlag(statePtr, CHANNEL_CLOSED) && (statePtr->refCount <= 0) &&
(statePtr->outQueueHead == NULL) &&
((statePtr->curOutPtr == NULL) ||
IsBufferEmpty(statePtr->curOutPtr))) {
@@ -3456,7 +3457,7 @@ TclClose(
statePtr = chanPtr->state;
chanPtr = statePtr->topChanPtr;
if (statePtr->refCount + 1 > 1) {
if (statePtr->refCount > 0) {
Tcl_Panic("called Tcl_Close on channel with refCount > 0");
}
@@ -4191,7 +4192,6 @@ Tcl_WriteChars(
}
objPtr = Tcl_NewStringObj(src, len);
Tcl_IncrRefCount(objPtr);
src = (char *) Tcl_GetByteArrayFromObj(objPtr, &len);
if (src == NULL) {
Tcl_SetErrno(EILSEQ);
@@ -4240,6 +4240,7 @@ Tcl_WriteObj(
Channel *chanPtr;
ChannelState *statePtr; /* State info for channel */
const char *src;
Tcl_Size srcLen = 0;
statePtr = ((Channel *) chan)->state;
chanPtr = statePtr->topChanPtr;
@@ -4247,34 +4248,21 @@ Tcl_WriteObj(
if (CheckChannelErrors(statePtr, TCL_WRITABLE) != 0) {
return TCL_INDEX_NONE;
}
Tcl_Size srcLen;
if (statePtr->encoding == NULL) {
Tcl_Size result;
src = (char *) Tcl_GetByteArrayFromObj(objPtr, &srcLen);
if (src == NULL) {
Tcl_SetErrno(EILSEQ);
return TCL_INDEX_NONE;
result = TCL_INDEX_NONE;
} else {
result = WriteBytes(chanPtr, src, srcLen);
}
return result;
} else {
src = Tcl_GetStringFromObj(objPtr, &srcLen);
return WriteChars(chanPtr, src, srcLen);
}
size_t totalWritten = 0;
/*
* 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;
}
static void
@@ -4345,17 +4333,18 @@ WillRead(
*----------------------------------------------------------------------
*/
static int
static Tcl_Size
Write(
Channel *chanPtr, /* The channel to buffer output for. */
const char *src, /* UTF-8 string to write. */
int srcLen, /* Length of UTF-8 string in bytes. */
Tcl_Size srcLen, /* Length of UTF-8 string in bytes. */
Tcl_Encoding encoding)
{
ChannelState *statePtr = chanPtr->state;
/* State info for channel */
char *nextNewLine = NULL;
int endEncoding, saved = 0, total = 0, flushed = 0, needNlFlush = 0;
int endEncoding, needNlFlush = 0;
Tcl_Size saved = 0, total = 0, flushed = 0;
char safe[BUFFER_PADDING];
int encodingError = 0;
@@ -4368,7 +4357,6 @@ Write(
*/
endEncoding = ((statePtr->outputEncodingFlags & TCL_ENCODING_END) != 0);
if (GotFlag(statePtr, CHANNEL_LINEBUFFERED)
|| (statePtr->outputTranslation != TCL_TRANSLATE_LF)) {
nextNewLine = (char *)memchr(src, '\n', srcLen);
@@ -4377,7 +4365,8 @@ Write(
while (srcLen + saved + endEncoding > 0 && !encodingError) {
ChannelBuffer *bufPtr;
char *dst;
int result, srcRead, dstLen, dstWrote, srcLimit = srcLen;
int result, srcRead, dstLen, dstWrote;
Tcl_Size srcLimit = srcLen;
if (nextNewLine) {
srcLimit = nextNewLine - src;
@@ -4567,7 +4556,7 @@ Tcl_Gets(
TclNewObj(objPtr);
charsStored = Tcl_GetsObj(chan, objPtr);
if (charsStored + 1 > 1) {
if (charsStored > 0) {
TclDStringAppendObj(lineRead, objPtr);
}
TclDecrRefCount(objPtr);
@@ -4649,7 +4638,7 @@ Tcl_GetsObj(
if (statePtr->encoding == GetBinaryEncoding()
&& ((statePtr->inputTranslation == TCL_TRANSLATE_LF)
|| (statePtr->inputTranslation == TCL_TRANSLATE_CR))
&& Tcl_GetByteArrayFromObj(objPtr, (size_t *)NULL) != NULL) {
&& Tcl_GetByteArrayFromObj(objPtr, (Tcl_Size *)NULL) != NULL) {
return TclGetsObjBinary(chan, objPtr);
}
@@ -5301,8 +5290,7 @@ TclGetsObjBinary(
*/
static void
FreeBinaryEncoding(
TCL_UNUSED(void *))
FreeBinaryEncoding(void)
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
@@ -5319,7 +5307,6 @@ GetBinaryEncoding(void)
if (tsdPtr->binaryEncoding == NULL) {
tsdPtr->binaryEncoding = Tcl_GetEncoding(NULL, "iso8859-1");
Tcl_CreateThreadExitHandler(FreeBinaryEncoding, NULL);
}
if (tsdPtr->binaryEncoding == NULL) {
Tcl_Panic("binary encoding is not available");
@@ -5942,7 +5929,7 @@ DoReadChars(
if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR)) {
ResetFlag(statePtr, CHANNEL_EOF|CHANNEL_ENCODING_ERROR);
/* TODO: We don't need this call? */
/* TODO: UpdateInterest not needed here? */
UpdateInterest(chanPtr);
Tcl_SetErrno(EILSEQ);
return -1;
@@ -5959,7 +5946,7 @@ DoReadChars(
assert(statePtr->inputEncodingFlags & TCL_ENCODING_END);
assert(!GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR));
/* TODO: We don't need this call? */
/* TODO: UpdateInterest not needed here? */
UpdateInterest(chanPtr);
return 0;
}
@@ -5973,7 +5960,7 @@ DoReadChars(
}
ResetFlag(statePtr, CHANNEL_BLOCKED|CHANNEL_EOF);
statePtr->inputEncodingFlags &= ~TCL_ENCODING_END;
/* TODO: We don't need this call? */
/* TODO: UpdateInterest not needed here? */
UpdateInterest(chanPtr);
return 0;
}
@@ -5990,7 +5977,7 @@ DoReadChars(
&& (statePtr->inEofChar == '\0');
if (appendFlag) {
if (binaryMode && (NULL == Tcl_GetByteArrayFromObj(objPtr, (size_t *)NULL))) {
if (binaryMode && (NULL == Tcl_GetByteArrayFromObj(objPtr, (Tcl_Size *)NULL))) {
binaryMode = 0;
}
} else {
@@ -6010,7 +5997,7 @@ DoReadChars(
}
ResetFlag(statePtr, CHANNEL_BLOCKED|CHANNEL_EOF);
statePtr->inputEncodingFlags &= ~TCL_ENCODING_END;
for (copied = 0; toRead > 0 || toRead == TCL_INDEX_NONE; ) {
for (copied = 0; toRead != 0 ; ) {
int copiedNow = -1;
if (statePtr->inQueueHead != NULL) {
if (binaryMode) {
@@ -6020,7 +6007,7 @@ DoReadChars(
}
/*
* If the current buffer is empty recycle it.
* Recycle current buffer if empty.
*/
bufPtr = statePtr->inQueueHead;
@@ -7985,7 +7972,7 @@ Tcl_GetChannelOption(
Tcl_DStringAppendElement(dsPtr, "-profile");
}
/* Note currently input and output profiles are same */
profile = CHANNEL_PROFILE_GET(statePtr->inputEncodingFlags);
profile = ENCODING_PROFILE_GET(statePtr->inputEncodingFlags);
profileName = TclEncodingProfileIdToName(interp, profile);
if (profileName == NULL) {
return TCL_ERROR;
@@ -8180,11 +8167,11 @@ Tcl_SetChannelOption(
if ((newValue[0] == '\0') || (strcmp(newValue, "binary") == 0)) {
encoding = Tcl_GetEncoding(NULL, "iso8859-1");
CHANNEL_PROFILE_SET(statePtr->inputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->inputEncodingFlags)
ENCODING_PROFILE_SET(statePtr->inputEncodingFlags
,ENCODING_PROFILE_GET(statePtr->inputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
CHANNEL_PROFILE_SET(statePtr->outputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->outputEncodingFlags)
ENCODING_PROFILE_SET(statePtr->outputEncodingFlags
,ENCODING_PROFILE_GET(statePtr->outputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
} else {
encoding = Tcl_GetEncoding(interp, newValue);
@@ -8207,12 +8194,12 @@ Tcl_SetChannelOption(
Tcl_FreeEncoding(statePtr->encoding);
statePtr->encoding = encoding;
statePtr->inputEncodingState = NULL;
profile = CHANNEL_PROFILE_GET(statePtr->inputEncodingFlags);
profile = ENCODING_PROFILE_GET(statePtr->inputEncodingFlags);
statePtr->inputEncodingFlags = TCL_ENCODING_START;
CHANNEL_PROFILE_SET(statePtr->inputEncodingFlags, profile);
ENCODING_PROFILE_SET(statePtr->inputEncodingFlags, profile);
statePtr->outputEncodingState = NULL;
statePtr->outputEncodingFlags = TCL_ENCODING_START;
CHANNEL_PROFILE_SET(statePtr->outputEncodingFlags, profile); /* Same as input */
ENCODING_PROFILE_SET(statePtr->outputEncodingFlags, profile); /* Same as input */
ResetFlag(statePtr, CHANNEL_NEED_MORE_DATA|CHANNEL_ENCODING_ERROR);
UpdateInterest(chanPtr);
return TCL_OK;
@@ -8229,7 +8216,7 @@ Tcl_SetChannelOption(
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -eofchar: must be non-NUL ASCII"
" character", -1));
" character", TCL_INDEX_NONE));
}
Tcl_Free((void *)argv);
return TCL_ERROR;
@@ -8255,8 +8242,8 @@ Tcl_SetChannelOption(
if (TclEncodingProfileNameToId(interp, newValue, &profile) != TCL_OK) {
return TCL_ERROR;
}
CHANNEL_PROFILE_SET(statePtr->inputEncodingFlags, profile);
CHANNEL_PROFILE_SET(statePtr->outputEncodingFlags, profile);
ENCODING_PROFILE_SET(statePtr->inputEncodingFlags, profile);
ENCODING_PROFILE_SET(statePtr->outputEncodingFlags, profile);
ResetFlag(statePtr, CHANNEL_NEED_MORE_DATA|CHANNEL_ENCODING_ERROR);
return TCL_OK;
} else if (HaveOpt(1, "-translation")) {
@@ -8294,11 +8281,11 @@ Tcl_SetChannelOption(
statePtr->inEofChar = 0;
Tcl_FreeEncoding(statePtr->encoding);
statePtr->encoding = Tcl_GetEncoding(NULL, "iso8859-1");
CHANNEL_PROFILE_SET(statePtr->inputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->inputEncodingFlags)
ENCODING_PROFILE_SET(statePtr->inputEncodingFlags
,ENCODING_PROFILE_GET(statePtr->inputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
CHANNEL_PROFILE_SET(statePtr->outputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->outputEncodingFlags)
ENCODING_PROFILE_SET(statePtr->outputEncodingFlags
,ENCODING_PROFILE_GET(statePtr->outputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
} else if (strcmp(readMode, "lf") == 0) {
translation = TCL_TRANSLATE_LF;
@@ -8349,11 +8336,11 @@ Tcl_SetChannelOption(
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)
ENCODING_PROFILE_SET(statePtr->inputEncodingFlags
,ENCODING_PROFILE_GET(statePtr->inputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
CHANNEL_PROFILE_SET(statePtr->outputEncodingFlags
,CHANNEL_PROFILE_GET(statePtr->outputEncodingFlags)
ENCODING_PROFILE_SET(statePtr->outputEncodingFlags
,ENCODING_PROFILE_GET(statePtr->outputEncodingFlags)
|TCL_ENCODING_PROFILE_STRICT);
} else if (strcmp(writeMode, "lf") == 0) {
statePtr->outputTranslation = TCL_TRANSLATE_LF;
@@ -10217,7 +10204,7 @@ DoRead(
== (CHANNEL_EOF|CHANNEL_BLOCKED)));
UpdateInterest(chanPtr);
TclChannelRelease((Tcl_Channel)chanPtr);
return (int)(p - dst);
return (Tcl_Size)(p - dst);
}
/*
@@ -10280,8 +10267,8 @@ Lossless(
(
toRead == -1
&& inStatePtr->encoding == outStatePtr->encoding
&& CHANNEL_PROFILE_GET(inStatePtr->inputEncodingFlags) == TCL_ENCODING_PROFILE_TCL8
&& CHANNEL_PROFILE_GET(outStatePtr->inputEncodingFlags) == TCL_ENCODING_PROFILE_TCL8
&& ENCODING_PROFILE_GET(inStatePtr->inputEncodingFlags) == TCL_ENCODING_PROFILE_TCL8
&& ENCODING_PROFILE_GET(outStatePtr->inputEncodingFlags) == TCL_ENCODING_PROFILE_TCL8
)
);
}
@@ -10654,7 +10641,7 @@ Tcl_IsChannelShared(
ChannelState *statePtr = ((Channel *) chan)->state;
/* State of real channel structure. */
return ((statePtr->refCount + 1 > 2) ? 1 : 0);
return ((statePtr->refCount > 1) ? 1 : 0);
}
/*
-7
View File
@@ -288,13 +288,6 @@ typedef struct ChannelState {
#define CHANNEL_CLOSEDWRITE (1<<21) /* Channel write side has been closed.
* No further Tcl-level write IO on
* the channel is allowed. */
#define CHANNEL_PROFILE_MASK 0xFF000000
#define CHANNEL_PROFILE_GET(flags_) ((flags_) & CHANNEL_PROFILE_MASK)
#define CHANNEL_PROFILE_SET(flags_, profile_) \
do { \
(flags_) &= ~CHANNEL_PROFILE_MASK; \
(flags_) |= profile_; \
} while (0)
/*
* The length of time to wait between synthetic timer events. Must be zero or
+1 -1
View File
@@ -1788,9 +1788,9 @@ ChanPendingObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Channel chan;
int mode;
static const char *const options[] = {"input", "output", NULL};
enum pendingOptionsEnum {PENDING_INPUT, PENDING_OUTPUT} index;
int mode;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "mode channelId");
+12 -3
View File
@@ -375,11 +375,15 @@ ExecuteCallback(
* interpreters. */
{
Tcl_Obj *resObj; /* See below, switch (transmit). */
size_t resLen = 0;
Tcl_Size resLen = 0;
unsigned char *resBuf;
Tcl_InterpState state = NULL;
int res = TCL_OK;
Tcl_Obj *command = TclListObjCopy(NULL, dataPtr->command);
Tcl_Obj *command = TclDuplicatePureObj(
interp, dataPtr->command, &tclListType);
if (!command) {
return TCL_ERROR;
}
Tcl_Interp *eval = dataPtr->interp;
Tcl_Preserve(eval);
@@ -397,7 +401,12 @@ ExecuteCallback(
}
Tcl_IncrRefCount(command);
Tcl_ListObjAppendElement(NULL, command, Tcl_NewStringObj((char *) op, -1));
res = Tcl_ListObjAppendElement(NULL, command, Tcl_NewStringObj((char *) op, -1));
if (res != TCL_OK) {
Tcl_DecrRefCount(command);
Tcl_Release(eval);
return res;
}
/*
* Use a byte-array to prevent the misinterpretation of binary data coming
+11 -4
View File
@@ -580,6 +580,9 @@ TclChanCreateObjCmd(
rcId = NextHandle();
rcPtr = NewReflectedChannel(interp, cmdObj, mode, rcId);
if (!rcPtr) {
return TCL_ERROR;
}
/*
* Invoke 'initialize' and validate that the handler is present and ok.
@@ -2258,8 +2261,10 @@ NewReflectedChannel(
rcPtr->mode = mode;
rcPtr->interest = 0; /* Initially no interest registered */
/* ASSERT: cmdpfxObj is a Tcl List */
rcPtr->cmd = TclListObjCopy(NULL, cmdpfxObj);
rcPtr->cmd = TclDuplicatePureObj(interp, cmdpfxObj, &tclListType);
if (!rcPtr->cmd) {
return NULL;
}
Tcl_IncrRefCount(rcPtr->cmd);
rcPtr->methods = Tcl_NewListObj(METH_WRITE + 1, NULL);
while (mn <= (int)METH_WRITE) {
@@ -2396,8 +2401,10 @@ InvokeTclMethod(
* before the channel id.
*/
cmd = TclListObjCopy(NULL, rcPtr->cmd);
cmd = TclDuplicatePureObj(NULL, rcPtr->cmd, &tclListType);
if (!cmd) {
return TCL_ERROR;
}
Tcl_ListObjIndex(NULL, rcPtr->methods, method, &methObj);
Tcl_ListObjAppendElement(NULL, cmd, methObj);
Tcl_ListObjAppendElement(NULL, cmd, rcPtr->name);
+9 -9
View File
@@ -264,7 +264,7 @@ struct ForwardParamTransform {
ForwardParamBase base; /* "Supertype". MUST COME FIRST. */
char *buf; /* I: Bytes to transform,
* O: Bytes in transform result */
size_t size; /* I: #bytes to transform,
Tcl_Size size; /* I: #bytes to transform,
* O: #bytes in the transform result */
};
struct ForwardParamLimit {
@@ -2562,7 +2562,7 @@ ForwardProc(
* Sent it back to the request originator.
*/
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev;
/* Array of returned bytes */
@@ -2596,7 +2596,7 @@ ForwardProc(
* Sent it back to the request originator.
*/
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev;
/* Array of returned bytes */
@@ -2626,7 +2626,7 @@ ForwardProc(
* Sent it back to the request originator.
*/
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
@@ -2652,7 +2652,7 @@ ForwardProc(
* Sent it back to the request originator.
*/
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev;
/* Array of returned bytes */
@@ -3045,7 +3045,7 @@ TransformRead(
Tcl_Obj *bufObj)
{
Tcl_Obj *resObj;
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
/*
@@ -3100,7 +3100,7 @@ TransformWrite(
{
Tcl_Obj *bufObj;
Tcl_Obj *resObj;
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
int res;
@@ -3167,7 +3167,7 @@ TransformDrain(
int *errorCodePtr)
{
Tcl_Obj *resObj;
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
/*
@@ -3216,7 +3216,7 @@ TransformFlush(
int op)
{
Tcl_Obj *resObj;
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
int res;
+5 -5
View File
@@ -1687,7 +1687,7 @@ Tcl_FSEvalFileEx(
use the utf-8 encoding. */
{
Tcl_Size length;
int result = TCL_ERROR;
int result = TCL_ERROR;
Tcl_StatBuf statBuf;
Tcl_Obj *oldScriptFile;
Interp *iPtr;
@@ -1802,7 +1802,7 @@ Tcl_FSEvalFileEx(
const char *pathString = Tcl_GetStringFromObj(pathPtr, &length);
unsigned limit = 150;
int overflow = (length > limit);
int overflow = ((unsigned)length > limit);
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (file \"%.*s%s\" line %d)",
@@ -1954,12 +1954,12 @@ EvalFileCallback(
Tcl_Size length;
const char *pathString = Tcl_GetStringFromObj(pathPtr, &length);
const unsigned int limit = 150;
int overflow = (length > limit);
const unsigned limit = 150;
int overflow = ((unsigned)length > limit);
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (file \"%.*s%s\" line %d)",
(overflow ? limit : (unsigned int)length), pathString,
(overflow ? limit : (unsigned)length), pathString,
(overflow ? "..." : ""), Tcl_GetErrorLine(interp)));
}
+11 -11
View File
@@ -37,7 +37,7 @@ static void PrintUsage(Tcl_Interp *interp,
* that can be invoked by generic object code.
*/
static const Tcl_ObjType indexType = {
const Tcl_ObjType tclIndexType = {
"index", /* name */
FreeIndex, /* freeIntRepProc */
DupIndex, /* dupIntRepProc */
@@ -213,7 +213,7 @@ Tcl_GetIndexFromObjStruct(
*/
if (objPtr && !(flags & TCL_INDEX_TEMP_TABLE)) {
irPtr = TclFetchInternalRep(objPtr, &indexType);
irPtr = TclFetchInternalRep(objPtr, &tclIndexType);
if (irPtr) {
indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1;
if ((indexRep->tablePtr == tablePtr)
@@ -282,7 +282,7 @@ Tcl_GetIndexFromObjStruct(
*/
if (objPtr && (index != TCL_INDEX_NONE) && !(flags & TCL_INDEX_TEMP_TABLE)) {
irPtr = TclFetchInternalRep(objPtr, &indexType);
irPtr = TclFetchInternalRep(objPtr, &tclIndexType);
if (irPtr) {
indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1;
} else {
@@ -290,7 +290,7 @@ Tcl_GetIndexFromObjStruct(
indexRep = (IndexRep*)Tcl_Alloc(sizeof(IndexRep));
ir.twoPtrValue.ptr1 = indexRep;
Tcl_StoreInternalRep(objPtr, &indexType, &ir);
Tcl_StoreInternalRep(objPtr, &tclIndexType, &ir);
}
indexRep->tablePtr = (void *) tablePtr;
indexRep->offset = offset;
@@ -385,7 +385,7 @@ static void
UpdateStringOfIndex(
Tcl_Obj *objPtr)
{
IndexRep *indexRep = (IndexRep *)TclFetchInternalRep(objPtr, &indexType)->twoPtrValue.ptr1;
IndexRep *indexRep = (IndexRep *)TclFetchInternalRep(objPtr, &tclIndexType)->twoPtrValue.ptr1;
const char *indexStr = EXPAND_OF(indexRep);
Tcl_InitStringRep(objPtr, indexStr, strlen(indexStr));
@@ -417,11 +417,11 @@ DupIndex(
Tcl_ObjInternalRep ir;
IndexRep *dupIndexRep = (IndexRep *)Tcl_Alloc(sizeof(IndexRep));
memcpy(dupIndexRep, TclFetchInternalRep(srcPtr, &indexType)->twoPtrValue.ptr1,
memcpy(dupIndexRep, TclFetchInternalRep(srcPtr, &tclIndexType)->twoPtrValue.ptr1,
sizeof(IndexRep));
ir.twoPtrValue.ptr1 = dupIndexRep;
Tcl_StoreInternalRep(dupPtr, &indexType, &ir);
Tcl_StoreInternalRep(dupPtr, &tclIndexType, &ir);
}
/*
@@ -445,7 +445,7 @@ static void
FreeIndex(
Tcl_Obj *objPtr)
{
Tcl_Free(TclFetchInternalRep(objPtr, &indexType)->twoPtrValue.ptr1);
Tcl_Free(TclFetchInternalRep(objPtr, &tclIndexType)->twoPtrValue.ptr1);
objPtr->typePtr = NULL;
}
@@ -865,7 +865,7 @@ Tcl_WrongNumArgs(
*/
const Tcl_ObjInternalRep *irPtr;
if ((irPtr = TclFetchInternalRep(origObjv[i], &indexType))) {
if ((irPtr = TclFetchInternalRep(origObjv[i], &tclIndexType))) {
IndexRep *indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1;
elementStr = EXPAND_OF(indexRep);
@@ -912,7 +912,7 @@ Tcl_WrongNumArgs(
*/
const Tcl_ObjInternalRep *irPtr;
if ((irPtr = TclFetchInternalRep(objv[i], &indexType))) {
if ((irPtr = TclFetchInternalRep(objv[i], &tclIndexType))) {
IndexRep *indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1;
Tcl_AppendStringsToObj(objPtr, EXPAND_OF(indexRep), NULL);
@@ -1361,7 +1361,7 @@ TclGetCompletionCodeFromObj(
"ok", "error", "return", "break", "continue", NULL
};
if (!TclHasInternalRep(value, &indexType)
if (!TclHasInternalRep(value, &tclIndexType)
&& TclGetIntFromObj(NULL, value, codePtr) == TCL_OK) {
return TCL_OK;
}
+1 -1
View File
@@ -537,7 +537,7 @@ declare 214 {
void TclSetObjNameOfExecutable(Tcl_Obj *name, Tcl_Encoding encoding)
}
declare 215 {
void *TclStackAlloc(Tcl_Interp *interp, Tcl_Size numBytes)
void *TclStackAlloc(Tcl_Interp *interp, TCL_HASH_TYPE numBytes)
}
declare 216 {
void TclStackFree(Tcl_Interp *interp, void *freePtr)
+262 -85
View File
@@ -66,11 +66,8 @@
#include <ctype.h>
#include <stdarg.h>
#ifdef NO_STDLIB_H
# include "../compat/stdlib.h"
#else
# include <stdlib.h>
#endif
#include <stdlib.h>
#include <stdint.h>
#ifdef NO_STRING_H
#include "../compat/string.h"
#else
@@ -104,12 +101,6 @@
# 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
@@ -1092,20 +1083,102 @@ typedef struct ActiveInterpTrace {
#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 \
&& ((objPtr)->typePtr->version > offsetof(TclObjTypeWithAbstractList, abstractList.proc))) ? \
((const TclObjTypeWithAbstractList *)(objPtr)->typePtr)->abstractList.proc : NULL)
#if TCL_MAJOR_VERSION > 8
#define TclObjTypeHasProc(objPtr, proc) (((objPtr)->typePtr \
&& ((offsetof(Tcl_ObjType, proc) < offsetof(Tcl_ObjType, version)) \
|| (offsetof(Tcl_ObjType, proc) < (objPtr)->typePtr->version))) ? \
((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.
*/
static inline Tcl_Size
TclObjTypeLength(Tcl_Obj *objPtr)
{
Tcl_ObjTypeLengthProc *proc = TclObjTypeHasProc(objPtr, lengthProc);
return proc(objPtr);
}
static inline int
TclObjTypeIndex(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
Tcl_Size index,
Tcl_Obj **elemObjPtr)
{
Tcl_ObjTypeIndexProc *proc = TclObjTypeHasProc(objPtr, indexProc);
return proc(interp, objPtr, index, elemObjPtr);
}
static inline int
TclObjTypeSlice(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
Tcl_Size fromIdx,
Tcl_Size toIdx,
Tcl_Obj **newObjPtr)
{
Tcl_ObjTypeSliceProc *proc = TclObjTypeHasProc(objPtr, sliceProc);
return proc(interp, objPtr, fromIdx, toIdx, newObjPtr);
}
static inline int
TclObjTypeReverse(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
Tcl_Obj **newObjPtr)
{
Tcl_ObjTypeReverseProc *proc = TclObjTypeHasProc(objPtr, reverseProc);
return proc(interp, objPtr, newObjPtr);
}
static inline int
TclObjTypeGetElements(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
Tcl_Size *objCPtr,
Tcl_Obj ***objVPtr)
{
Tcl_ObjTypeGetElements *proc = TclObjTypeHasProc(objPtr, getElementsProc);
return proc(interp, objPtr, objCPtr, objVPtr);
}
static inline Tcl_Obj*
TclObjTypeSetElement(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
Tcl_Size indexCount,
Tcl_Obj *const indexArray[],
Tcl_Obj *valueObj)
{
Tcl_ObjTypeSetElement *proc = TclObjTypeHasProc(objPtr, setElementProc);
return proc(interp, objPtr, indexCount, indexArray, valueObj);
}
static inline int
TclObjTypeReplace(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
Tcl_Size first,
Tcl_Size numToDelete,
Tcl_Size numToInsert,
Tcl_Obj *const insertObjs[])
{
Tcl_ObjTypeReplaceProc *proc = TclObjTypeHasProc(objPtr, replaceProc);
return proc(interp, objPtr, first, numToDelete, numToInsert, insertObjs);
}
static inline int
TclObjTypeInOperator(Tcl_Interp *interp, struct Tcl_Obj *valueObj,
struct Tcl_Obj *listObj, int *boolResult)
{
Tcl_ObjTypeInOperatorProc *proc = TclObjTypeHasProc(listObj, inOperProc);
return proc(interp, valueObj, listObj, boolResult);
}
#endif /* TCL_MAJOR_VERSION > 8 */
/*
* The structure below defines an entry in the assocData hash table which is
* associated with an interpreter. The entry contains a pointer to a function
@@ -1248,7 +1321,7 @@ typedef struct CmdFrame {
int type; /* Values see below. */
int level; /* Number of frames in stack, prevent O(n)
* scan of list. */
int *line; /* Lines the words of the command start on. */
Tcl_Size *line; /* Lines the words of the command start on. */
Tcl_Size nline;
CallFrame *framePtr; /* Procedure activation record, may be
* NULL. */
@@ -1343,7 +1416,7 @@ typedef struct CFWordBC {
typedef struct ContLineLoc {
Tcl_Size num; /* Number of entries in loc, not counting the
* final -1 marker entry. */
int loc[TCLFLEXARRAY];/* Table of locations, as character offsets.
Tcl_Size loc[TCLFLEXARRAY];/* Table of locations, as character offsets.
* The table is allocated as part of the
* structure, extending behind the nominal end
* of the structure. An entry containing the
@@ -2451,16 +2524,6 @@ typedef enum TclEolTranslation {
#define TCL_INVOKE_NO_UNKNOWN (1<<1)
#define TCL_INVOKE_NO_TRACEBACK (1<<2)
#if TCL_MAJOR_VERSION > 8
/*
* SSIZE_MAX, NOT SIZE_MAX as negative differences need to be expressed
* between values of the Tcl_Size type so limit the range to signed
*/
# define ListSizeT_MAX ((Tcl_Size)PTRDIFF_MAX)
#else
# define ListSizeT_MAX INT_MAX
#endif
/*
* ListStore --
*
@@ -2501,7 +2564,8 @@ typedef struct ListStore {
/* Max number of elements that can be contained in a list */
#define LIST_MAX \
((Tcl_Size)((ListSizeT_MAX - offsetof(ListStore, slots)) / sizeof(Tcl_Obj *)))
((Tcl_Size)(((size_t)TCL_SIZE_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 *))))
@@ -2513,7 +2577,7 @@ typedef struct 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 */
size_t refCount; /* Count of references to this span record */
} ListSpan;
#ifndef LIST_SPAN_THRESHOLD /* May be set on build line */
#define LIST_SPAN_THRESHOLD 101
@@ -2593,6 +2657,7 @@ typedef struct ListRep {
(((objv_) = &ListObjStorePtr(listObj_)->slots[ListObjStart(listObj_)]), \
(ListObjLength(listObj_, (objc_))))
/*
* Returns 1/0 whether the internal representation (not the Tcl_Obj itself)
* is shared. Note by intent this only checks for sharing of ListStore,
@@ -2608,8 +2673,8 @@ typedef struct ListRep {
* (1) No string representation exists which means it will obviously have
* to be generated from the list representation when needed
* (2) The ListStore flags is marked canonical. This is done at the time
* the string representation is generated from the list IF the list
* representation does not have a span (see comments in UpdateStringOfList).
* the string representation is generated from the list under certain
* conditions (see comments in UpdateStringOfList).
* (3) The list representation does not have a span component. This is
* because list Tcl_Obj's with spans are always created from existing lists
* and never from strings (see SetListFromAny) and thus their string
@@ -2627,7 +2692,7 @@ typedef struct ListRep {
* converted to a list.
*/
#define TclListObjGetElementsM(interp_, listObj_, objcPtr_, objvPtr_) \
(((listObj_)->typePtr == &tclListType.objType) \
(((listObj_)->typePtr == &tclListType) \
? ((ListObjGetElements((listObj_), *(objcPtr_), *(objvPtr_))), \
TCL_OK) \
: Tcl_ListObjGetElements( \
@@ -2639,12 +2704,12 @@ typedef struct ListRep {
* Tcl_Obj cannot be converted to a list.
*/
#define TclListObjLengthM(interp_, listObj_, lenPtr_) \
(((listObj_)->typePtr == &tclListType.objType) \
(((listObj_)->typePtr == &tclListType) \
? ((ListObjLength((listObj_), *(lenPtr_))), TCL_OK) \
: Tcl_ListObjLength((interp_), (listObj_), (lenPtr_)))
#define TclListObjIsCanonical(listObj_) \
(((listObj_)->typePtr == &tclListType.objType) ? ListObjIsCanonical((listObj_)) : 0)
(((listObj_)->typePtr == &tclListType) ? ListObjIsCanonical((listObj_)) : 0)
/*
* Modes for collecting (or not) in the implementations of TclNRForeachCmd,
@@ -2664,27 +2729,27 @@ typedef struct ListRep {
#if TCL_MAJOR_VERSION > 8
#define TclGetBooleanFromObj(interp, objPtr, intPtr) \
(((objPtr)->typePtr == &tclIntType.objType \
|| (objPtr)->typePtr == &tclBooleanType.objType) \
(((objPtr)->typePtr == &tclIntType \
|| (objPtr)->typePtr == &tclBooleanType) \
? (*(intPtr) = ((objPtr)->internalRep.wideValue!=0), TCL_OK) \
: Tcl_GetBooleanFromObj((interp), (objPtr), (intPtr)))
#else
#define TclGetBooleanFromObj(interp, objPtr, intPtr) \
(((objPtr)->typePtr == &tclIntType.objType) \
(((objPtr)->typePtr == &tclIntType) \
? (*(intPtr) = ((objPtr)->internalRep.wideValue!=0), TCL_OK) \
: ((objPtr)->typePtr == &tclBooleanType.objType) \
: ((objPtr)->typePtr == &tclBooleanType) \
? (*(intPtr) = ((objPtr)->internalRep.longValue!=0), TCL_OK) \
: Tcl_GetBooleanFromObj((interp), (objPtr), (intPtr)))
#endif
#ifdef TCL_WIDE_INT_IS_LONG
#define TclGetLongFromObj(interp, objPtr, longPtr) \
(((objPtr)->typePtr == &tclIntType.objType) \
(((objPtr)->typePtr == &tclIntType) \
? ((*(longPtr) = (objPtr)->internalRep.wideValue), TCL_OK) \
: Tcl_GetLongFromObj((interp), (objPtr), (longPtr)))
#else
#define TclGetLongFromObj(interp, objPtr, longPtr) \
(((objPtr)->typePtr == &tclIntType.objType \
(((objPtr)->typePtr == &tclIntType \
&& (objPtr)->internalRep.wideValue >= (Tcl_WideInt)(LONG_MIN) \
&& (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(LONG_MAX)) \
? ((*(longPtr) = (long)(objPtr)->internalRep.wideValue), TCL_OK) \
@@ -2692,13 +2757,13 @@ typedef struct ListRep {
#endif
#define TclGetIntFromObj(interp, objPtr, intPtr) \
(((objPtr)->typePtr == &tclIntType.objType \
(((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.objType) && ((objPtr)->internalRep.wideValue >= 0) \
((((objPtr)->typePtr == &tclIntType) && ((objPtr)->internalRep.wideValue >= 0) \
&& ((objPtr)->internalRep.wideValue <= endValue)) \
? ((*(idxPtr) = (objPtr)->internalRep.wideValue), TCL_OK) \
: Tcl_GetIntForIndex((interp), (objPtr), (endValue), (idxPtr)))
@@ -2712,7 +2777,7 @@ typedef struct ListRep {
*/
#define TclGetWideIntFromObj(interp, objPtr, wideIntPtr) \
(((objPtr)->typePtr == &tclIntType.objType) \
(((objPtr)->typePtr == &tclIntType) \
? (*(wideIntPtr) = \
((objPtr)->internalRep.wideValue), TCL_OK) : \
Tcl_GetWideIntFromObj((interp), (objPtr), (wideIntPtr)))
@@ -2864,6 +2929,91 @@ typedef struct ProcessGlobalValue {
#define TCL_PARSE_NO_UNDERSCORE 128
/* Reject underscore digit separator */
/*
*----------------------------------------------------------------------
* Internal convenience macros for manipulating encoding flags. See
* TCL_ENCODING_PROFILE_* in tcl.h
*----------------------------------------------------------------------
*/
#define ENCODING_PROFILE_MASK 0xFF000000
#define ENCODING_PROFILE_GET(flags_) ((flags_) & ENCODING_PROFILE_MASK)
#define ENCODING_PROFILE_SET(flags_, profile_) \
do { \
(flags_) &= ~ENCODING_PROFILE_MASK; \
(flags_) |= profile_; \
} while (0)
/*
*----------------------------------------------------------------------
* Common functions for calculating overallocation. Trivial but allows for
* experimenting with growth factors without having to change code in
* multiple places. See TclAttemptAllocElemsEx and similar for usage
* examples. Best to use those functions. Direct use of TclUpsizeAlloc /
* TclResizeAlloc is needed in special cases such as when total size of
* memory block is limited to less than TCL_SIZE_MAX.
*
*----------------------------------------------------------------------
*/
static inline Tcl_Size
TclUpsizeAlloc(TCL_UNUSED(Tcl_Size) /* oldSize. For future experiments with
* some growth algorithms that use this
* information. */,
Tcl_Size needed,
Tcl_Size limit)
{
/* assert (oldCapacity < needed <= limit) */
if (needed < (limit - needed/2)) {
return needed + needed / 2;
}
else {
return limit;
}
}
static inline Tcl_Size TclUpsizeRetry(Tcl_Size needed, Tcl_Size lastAttempt) {
/* assert (needed < lastAttempt) */
if (needed < lastAttempt - 1) {
/* (needed+lastAttempt)/2 but that formula may overflow Tcl_Size */
return needed + (lastAttempt - needed) / 2;
} else {
return needed;
}
}
MODULE_SCOPE void *TclAllocElemsEx(Tcl_Size elemCount, Tcl_Size elemSize,
Tcl_Size leadSize, Tcl_Size *capacityPtr);
MODULE_SCOPE void *TclReallocElemsEx(void *oldPtr, Tcl_Size elemCount,
Tcl_Size elemSize, Tcl_Size leadSize,
Tcl_Size *capacityPtr);
MODULE_SCOPE void *TclAttemptReallocElemsEx(void *oldPtr,
Tcl_Size elemCount, Tcl_Size elemSize,
Tcl_Size leadSize, Tcl_Size *capacityPtr);
/* Alloc elemCount elements of size elemSize with leadSize header
* returning actual capacity (in elements) in *capacityPtr. */
static inline void *TclAttemptAllocElemsEx(Tcl_Size elemCount, Tcl_Size elemSize,
Tcl_Size leadSize, Tcl_Size *capacityPtr) {
return TclAttemptReallocElemsEx(
NULL, elemCount, elemSize, leadSize, capacityPtr);
}
/* Alloc numByte bytes, returning actual capacity in *capacityPtr. */
static inline void *TclAllocEx(Tcl_Size numBytes, Tcl_Size *capacityPtr) {
return TclAllocElemsEx(numBytes, 1, 0, capacityPtr);
}
/* Alloc numByte bytes, returning actual capacity in *capacityPtr. */
static inline void *
TclAttemptAllocEx(Tcl_Size numBytes, Tcl_Size *capacityPtr)
{
return TclAttemptAllocElemsEx(numBytes, 1, 0, capacityPtr);
}
/* Realloc numByte bytes, returning actual capacity in *capacityPtr. */
static inline void *TclReallocEx(void *oldPtr, Tcl_Size numBytes, Tcl_Size *capacityPtr) {
return TclReallocElemsEx(oldPtr, numBytes, 1, 0, capacityPtr);
}
/* Realloc numByte bytes, returning actual capacity in *capacityPtr. */
static inline void *TclAttemptReallocEx(void *oldPtr, Tcl_Size numBytes, Tcl_Size *capacityPtr) {
return TclAttemptReallocElemsEx(oldPtr, numBytes, 1, 0, capacityPtr);
}
/*
*----------------------------------------------------------------
* Variables shared among Tcl modules but not used by the outside world.
@@ -2880,6 +3030,7 @@ MODULE_SCOPE TclPlatformType tclPlatform;
*/
MODULE_SCOPE Tcl_Encoding tclIdentityEncoding;
MODULE_SCOPE Tcl_Encoding tclUtf8Encoding;
MODULE_SCOPE int
TclEncodingProfileNameToId(Tcl_Interp *interp,
const char *profileName,
@@ -2902,13 +3053,13 @@ MODULE_SCOPE void *tclTimeClientData;
* Variables denoting the Tcl object types defined in the core.
*/
MODULE_SCOPE const TclObjTypeWithAbstractList tclBignumType;
MODULE_SCOPE const TclObjTypeWithAbstractList tclBooleanType;
MODULE_SCOPE const Tcl_ObjType tclBignumType;
MODULE_SCOPE const Tcl_ObjType tclBooleanType;
MODULE_SCOPE const Tcl_ObjType tclByteCodeType;
MODULE_SCOPE const TclObjTypeWithAbstractList tclDoubleType;
MODULE_SCOPE const TclObjTypeWithAbstractList tclIntType;
MODULE_SCOPE const TclObjTypeWithAbstractList tclListType;
MODULE_SCOPE const TclObjTypeWithAbstractList tclArithSeriesType;
MODULE_SCOPE const Tcl_ObjType tclDoubleType;
MODULE_SCOPE const Tcl_ObjType tclIntType;
MODULE_SCOPE const Tcl_ObjType tclIndexType;
MODULE_SCOPE const Tcl_ObjType tclListType;
MODULE_SCOPE const Tcl_ObjType tclDictType;
MODULE_SCOPE const Tcl_ObjType tclProcBodyType;
MODULE_SCOPE const Tcl_ObjType tclStringType;
@@ -3056,7 +3207,7 @@ 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,
MODULE_SCOPE void TclAdvanceContinuations(Tcl_Size *line, Tcl_Size **next,
int loc);
MODULE_SCOPE void TclAdvanceLines(Tcl_Size *line, const char *start,
const char *end);
@@ -3066,7 +3217,7 @@ 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);
void *codePtr, CmdFrame *cfPtr, Tcl_Size cmd, Tcl_Size pc);
MODULE_SCOPE void TclArgumentBCRelease(Tcl_Interp *interp,
CmdFrame *cfPtr);
MODULE_SCOPE void TclArgumentGet(Tcl_Interp *interp, Tcl_Obj *obj,
@@ -3091,9 +3242,9 @@ 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);
Tcl_Size *loc);
MODULE_SCOPE void TclContinuationsEnterDerived(Tcl_Obj *objPtr,
int start, int *clNext);
Tcl_Size start, Tcl_Size *clNext);
MODULE_SCOPE ContLineLoc *TclContinuationsGet(Tcl_Obj *objPtr);
MODULE_SCOPE void TclContinuationsCopy(Tcl_Obj *objPtr,
Tcl_Obj *originObjPtr);
@@ -3108,6 +3259,9 @@ MODULE_SCOPE Tcl_Command TclCreateEnsembleInNs(Tcl_Interp *interp,
Tcl_Namespace *ensembleNamespacePtr, int flags);
MODULE_SCOPE void TclDeleteNamespaceVars(Namespace *nsPtr);
MODULE_SCOPE void TclDeleteNamespaceChildren(Namespace *nsPtr);
MODULE_SCOPE Tcl_Size TclDictGetSize(Tcl_Obj *dictPtr);
MODULE_SCOPE Tcl_Obj *TclDuplicatePureObj(Tcl_Interp *interp,
Tcl_Obj * objPtr, const Tcl_ObjType *typPtr);
MODULE_SCOPE int TclFindDictElement(Tcl_Interp *interp,
const char *dict, Tcl_Size dictLength,
const char **elementPtr, const char **nextPtr,
@@ -3115,7 +3269,7 @@ MODULE_SCOPE int TclFindDictElement(Tcl_Interp *interp,
/* 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);
Tcl_Size *clNextOuter, const char *outerScript);
MODULE_SCOPE Tcl_ObjCmdProc TclFileAttrsCmd;
MODULE_SCOPE Tcl_ObjCmdProc TclFileCopyCmd;
MODULE_SCOPE Tcl_ObjCmdProc TclFileDeleteCmd;
@@ -3234,10 +3388,10 @@ 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[]);
MODULE_SCOPE Tcl_Obj * TclListObjGetElement(Tcl_Obj *listObj, Tcl_Size index);
/* 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 void TclListLines(Tcl_Obj *listObj, Tcl_Size line, Tcl_Size n,
Tcl_Size *lines, Tcl_Obj *const *elems);
MODULE_SCOPE int TclListObjAppendElements(Tcl_Interp *interp,
Tcl_Obj *toObj, Tcl_Size elemCount,
Tcl_Obj *const elemObjv[]);
@@ -3280,10 +3434,14 @@ MODULE_SCOPE void TclParseInit(Tcl_Interp *interp, const char *string,
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 void TclUndoRefCount(Tcl_Obj *objPtr);
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);
@@ -3311,7 +3469,7 @@ MODULE_SCOPE int TclCreateSocketAddress(Tcl_Interp *interp,
const char **errorMsgPtr);
MODULE_SCOPE int TclpThreadCreate(Tcl_ThreadId *idPtr,
Tcl_ThreadCreateProc *proc, void *clientData,
size_t stackSize, int flags);
TCL_HASH_TYPE 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);
@@ -3380,13 +3538,13 @@ 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);
TCL_HASH_TYPE 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,
int *reqlength);
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,
@@ -3401,7 +3559,7 @@ MODULE_SCOPE void TclSubstParse(Tcl_Interp *interp, const char *bytes,
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);
Tcl_Size *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,
@@ -4156,6 +4314,7 @@ MODULE_SCOPE TclProcessWaitStatus TclProcessWait(Tcl_Pid pid, int options,
int *codePtr, Tcl_Obj **msgObjPtr,
Tcl_Obj **errorObjPtr);
MODULE_SCOPE int TclClose(Tcl_Interp *, Tcl_Channel chan);
/*
* TIP #508: [array default]
*/
@@ -4173,6 +4332,12 @@ MODULE_SCOPE int TclIndexEncode(Tcl_Interp *interp, Tcl_Obj *objPtr,
MODULE_SCOPE Tcl_Size TclIndexDecode(int encoded, Tcl_Size endValue);
MODULE_SCOPE int TclIndexInvalidError(Tcl_Interp *interp,
const char *idxType, Tcl_Size idx);
/*
* Error message utility functions
*/
MODULE_SCOPE int TclCommandWordLimitError(Tcl_Interp *interp, Tcl_Size count);
#endif /* TCL_MAJOR_VERSION > 8 */
/* Constants used in index value encoding routines. */
@@ -4456,15 +4621,12 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
# define TclDecrRefCount(objPtr) \
Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
# define TclNewListObjDirect(objc, objv) \
TclDbNewListObjDirect(objc, objv, __FILE__, __LINE__)
#undef USE_THREAD_ALLOC
#endif /* TCL_MEM_DEBUG */
/*
*----------------------------------------------------------------
* Macro used by the Tcl core to set a Tcl_Obj's string representation to a
* Macros used by the Tcl core to set a Tcl_Obj's string representation to a
* copy of the "len" bytes starting at "bytePtr". The value of "len" must
* not be negative. When "len" is 0, then it is acceptable to pass
* "bytePtr" = NULL. When "len" > 0, "bytePtr" must not be NULL, and it
@@ -4477,17 +4639,22 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
* Because "len" is referenced multiple times, take care that it is an
* expression with the same value each use.
*
* The ANSI C "prototype" for this macro is:
* The ANSI C "prototypes" for these macros are:
*
* MODULE_SCOPE void TclInitEmptyStringRep(Tcl_Obj *objPtr);
* MODULE_SCOPE void TclInitStringRep(Tcl_Obj *objPtr, char *bytePtr, size_t len);
* MODULE_SCOPE void TclAttemptInitStringRep(Tcl_Obj *objPtr, char *bytePtr, size_t len);
*
*----------------------------------------------------------------
*/
#define TclInitEmptyStringRep(objPtr) \
((objPtr)->length = (((objPtr)->bytes = &tclEmptyString), 0))
#define TclInitStringRep(objPtr, bytePtr, len) \
if ((len) == 0) { \
(objPtr)->bytes = &tclEmptyString; \
(objPtr)->length = 0; \
TclInitEmptyStringRep(objPtr); \
} else { \
(objPtr)->bytes = (char *)Tcl_Alloc((len) + 1U); \
memcpy((objPtr)->bytes, (bytePtr) ? (bytePtr) : &tclEmptyString, (len)); \
@@ -4495,6 +4662,16 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
(objPtr)->length = (len); \
}
#define TclAttemptInitStringRep(objPtr, bytePtr, len) \
((((len) == 0) ? ( \
TclInitEmptyStringRep(objPtr) \
) : ( \
(objPtr)->bytes = (char *)Tcl_AttemptAlloc((len) + 1U), \
(objPtr)->length = ((objPtr)->bytes) ? \
(memcpy((objPtr)->bytes, (bytePtr) ? (bytePtr) : &tclEmptyString, (len)), \
(objPtr)->bytes[len] = '\0', (len)) : (-1) \
)), (objPtr)->bytes)
/*
*----------------------------------------------------------------
* Macro used by the Tcl core to get the string representation's byte array
@@ -4793,7 +4970,7 @@ MODULE_SCOPE Tcl_LibraryInitProc TclObjTest_Init;
MODULE_SCOPE Tcl_LibraryInitProc TclThread_Init;
MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_Init;
MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit;
MODULE_SCOPE Tcl_LibraryInitProc Tcl_ABSListTest_Init;
/*
@@ -4825,7 +5002,7 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit;
Tcl_ObjInternalRep ir; \
ir.wideValue = (Tcl_WideInt) i; \
TclInvalidateStringRep(objPtr); \
Tcl_StoreInternalRep(objPtr, &tclIntType.objType, &ir); \
Tcl_StoreInternalRep(objPtr, &tclIntType, &ir); \
} while (0)
#define TclSetDoubleObj(objPtr, d) \
@@ -4833,7 +5010,7 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit;
Tcl_ObjInternalRep ir; \
ir.doubleValue = (double) d; \
TclInvalidateStringRep(objPtr); \
Tcl_StoreInternalRep(objPtr, &tclDoubleType.objType, &ir); \
Tcl_StoreInternalRep(objPtr, &tclDoubleType, &ir); \
} while (0)
/*
@@ -4844,7 +5021,7 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit;
*
* MODULE_SCOPE void TclNewIntObj(Tcl_Obj *objPtr, Tcl_WideInt w);
* MODULE_SCOPE void TclNewDoubleObj(Tcl_Obj *objPtr, double d);
* MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, const char *s, size_t len);
* MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, const char *s, Tcl_Size len);
* MODULE_SCOPE void TclNewLiteralStringObj(Tcl_Obj*objPtr, const char *sLiteral);
*
*----------------------------------------------------------------
@@ -4858,7 +5035,7 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit;
(objPtr)->refCount = 0; \
(objPtr)->bytes = NULL; \
(objPtr)->internalRep.wideValue = (Tcl_WideInt)(w); \
(objPtr)->typePtr = &tclIntType.objType; \
(objPtr)->typePtr = &tclIntType; \
TCL_DTRACE_OBJ_CREATE(objPtr); \
} while (0)
@@ -4877,13 +5054,13 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit;
TclSetBignumInternalRep((objPtr), &bignumValue_); \
} else { \
(objPtr)->internalRep.wideValue = (Tcl_WideInt)(uw_); \
(objPtr)->typePtr = &tclIntType.objType; \
(objPtr)->typePtr = &tclIntType; \
} \
TCL_DTRACE_OBJ_CREATE(objPtr); \
} while (0)
#define TclNewIndexObj(objPtr, uw) \
TclNewIntObj(objPtr, uw)
#define TclNewIndexObj(objPtr, w) \
TclNewIntObj(objPtr, w)
#define TclNewDoubleObj(objPtr, d) \
do { \
@@ -4892,7 +5069,7 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit;
(objPtr)->refCount = 0; \
(objPtr)->bytes = NULL; \
(objPtr)->internalRep.doubleValue = (double)(d); \
(objPtr)->typePtr = &tclDoubleType.objType; \
(objPtr)->typePtr = &tclDoubleType; \
TCL_DTRACE_OBJ_CREATE(objPtr); \
} while (0)
@@ -5153,7 +5330,7 @@ typedef struct NRE_callback {
#define TCLNR_FREE(interp, ptr) TclSmallFreeEx((interp), (ptr))
#else
#define TCLNR_ALLOC(interp, ptr) \
(ptr = (Tcl_Alloc(sizeof(NRE_callback))))
((ptr) = Tcl_Alloc(sizeof(NRE_callback)))
#define TCLNR_FREE(interp, ptr) Tcl_Free(ptr)
#endif
+3 -2
View File
@@ -451,7 +451,8 @@ EXTERN Tcl_Obj * TclGetObjNameOfExecutable(void);
EXTERN void TclSetObjNameOfExecutable(Tcl_Obj *name,
Tcl_Encoding encoding);
/* 215 */
EXTERN void * TclStackAlloc(Tcl_Interp *interp, Tcl_Size numBytes);
EXTERN void * TclStackAlloc(Tcl_Interp *interp,
TCL_HASH_TYPE numBytes);
/* 216 */
EXTERN void TclStackFree(Tcl_Interp *interp, void *freePtr);
/* 217 */
@@ -803,7 +804,7 @@ typedef struct TclIntStubs {
void (*tclpFindExecutable) (const char *argv0); /* 212 */
Tcl_Obj * (*tclGetObjNameOfExecutable) (void); /* 213 */
void (*tclSetObjNameOfExecutable) (Tcl_Obj *name, Tcl_Encoding encoding); /* 214 */
void * (*tclStackAlloc) (Tcl_Interp *interp, Tcl_Size numBytes); /* 215 */
void * (*tclStackAlloc) (Tcl_Interp *interp, TCL_HASH_TYPE numBytes); /* 215 */
void (*tclStackFree) (Tcl_Interp *interp, void *freePtr); /* 216 */
int (*tclPushStackFrame) (Tcl_Interp *interp, Tcl_CallFrame **framePtrPtr, Tcl_Namespace *namespacePtr, int isProcCallFrame); /* 217 */
void (*tclPopStackFrame) (Tcl_Interp *interp); /* 218 */

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