Compare commits
232
Commits
tip-470
...
tip-389-impl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f62be3a217 | ||
|
|
e7582d10c6 | ||
|
|
5064777d16 | ||
|
|
5b74714749 | ||
|
|
15a7950c9e | ||
|
|
c925a86988 | ||
|
|
75ecb090c6 | ||
|
|
b8e5e2909e | ||
|
|
fd6a064ee7 | ||
|
|
6881a1a274 | ||
|
|
b0fe49c36d | ||
|
|
a52f0db3e4 | ||
|
|
4bf8f43b3a | ||
|
|
d45863129f | ||
|
|
1b28405773 | ||
|
|
65703d1f87 | ||
|
|
f75f76c9d4 | ||
|
|
f5ea63343e | ||
|
|
a708ae2da2 | ||
|
|
d4e73bcab5 | ||
|
|
8f339500a2 | ||
|
|
bf01a303da | ||
|
|
99d940211c | ||
|
|
7b8b406719 | ||
|
|
db3273f346 | ||
|
|
c659b044b1 | ||
|
|
3e55dbb18c | ||
|
|
b2446d8d41 | ||
|
|
e86e8a501d | ||
|
|
d03a4dcc88 | ||
|
|
4ce5b276eb | ||
|
|
877e9d6b11 | ||
|
|
413fe66650 | ||
|
|
ca70072a99 | ||
|
|
d9f2bf1d17 | ||
|
|
c2846c0f5c | ||
|
|
a15279ffd1 | ||
|
|
b74f59a5b4 | ||
|
|
e08c86934d | ||
|
|
a3dfc55957 | ||
|
|
e3f7bc2783 | ||
|
|
564b991088 | ||
|
|
0ff317501d | ||
|
|
f42f0060be | ||
|
|
3ec5b35deb | ||
|
|
7afc6b1c17 | ||
|
|
ce58cdff9f | ||
|
|
999252be01 | ||
|
|
4b9e6d92be | ||
|
|
e28f1eece4 | ||
|
|
6c1107a3e6 | ||
|
|
4ce83fdb43 | ||
|
|
ce32fdecb2 | ||
|
|
105a61c09b | ||
|
|
25b97a7df9 | ||
|
|
432e75210f | ||
|
|
595e613479 | ||
|
|
c0e413055e | ||
|
|
11719ccf59 | ||
|
|
7c7a396fc5 | ||
|
|
7aafa756ac | ||
|
|
6d8b0c705f | ||
|
|
faaf0a0fe6 | ||
|
|
07bcf919d6 | ||
|
|
f70c0ac860 | ||
|
|
97d25d7902 | ||
|
|
c3d5808cdd | ||
|
|
187a67149b | ||
|
|
2d65cb7514 | ||
|
|
92a05930af | ||
|
|
1ef0babc38 | ||
|
|
92265d56a3 | ||
|
|
4264a4f6ab | ||
|
|
a95a7dd265 | ||
|
|
f385fd1b73 | ||
|
|
2e9194366a | ||
|
|
ce72664606 | ||
|
|
5210283d10 | ||
|
|
0eb18d8f91 | ||
|
|
29be40bf89 | ||
|
|
e6336bb806 | ||
|
|
a04094e9a5 | ||
|
|
922d8a71a5 | ||
|
|
13d9910fd6 | ||
|
|
277f101d7f | ||
|
|
a50a381b04 | ||
|
|
e513ec3916 | ||
|
|
89fcfadbbf | ||
|
|
89ce4defb5 | ||
|
|
ad9bc7297d | ||
|
|
0079285837 | ||
|
|
8ccd8d10ef | ||
|
|
aedd652645 | ||
|
|
4056a4dc4b | ||
|
|
ffaeeeddaa | ||
|
|
c2982f8f62 | ||
|
|
587206a660 | ||
|
|
545f5e64be | ||
|
|
385b618c74 | ||
|
|
3a07a6d26f | ||
|
|
df9ea61fbf | ||
|
|
5f7ca471e4 | ||
|
|
ac8ddf5d4a | ||
|
|
664774bec4 | ||
|
|
3cf11a1ce9 | ||
|
|
6da97c627b | ||
|
|
735ca3d3a8 | ||
|
|
72396a1929 | ||
|
|
816674cdb7 | ||
|
|
6bcfd54d3a | ||
|
|
bb331bf1d8 | ||
|
|
b095f046e6 | ||
|
|
cee94b0658 | ||
|
|
f94f5914a8 | ||
|
|
9dd9b629b3 | ||
|
|
440dbbf620 | ||
|
|
b1243f2603 | ||
|
|
f553fe3b01 | ||
|
|
457f43e25b | ||
|
|
578eeb06bc | ||
|
|
515f0f32c0 | ||
|
|
bcb9c34521 | ||
|
|
af0816e0ca | ||
|
|
ac0fdb5bf8 | ||
|
|
2ee7180448 | ||
|
|
5541cc57f7 | ||
|
|
692ea37c40 | ||
|
|
58dd15c51d | ||
|
|
d0996f3402 | ||
|
|
39356c4079 | ||
|
|
a646f081bc | ||
|
|
89f6884455 | ||
|
|
45cf14ed03 | ||
|
|
5314bbe0ef | ||
|
|
5b2c81a0f3 | ||
|
|
f242dd36bd | ||
|
|
fb2aa596ab | ||
|
|
5621809b18 | ||
|
|
7a8a4b15c4 | ||
|
|
f4615ea166 | ||
|
|
2bd7095b87 | ||
|
|
400f9d27f5 | ||
|
|
5d68b7ef56 | ||
|
|
ba387de8cd | ||
|
|
70d12096d5 | ||
|
|
3dedad17ed | ||
|
|
a9c238476a | ||
|
|
cfafc391f2 | ||
|
|
0fbade1cf8 | ||
|
|
dd54301fb6 | ||
|
|
6352a07912 | ||
|
|
440f85800c | ||
|
|
6454bee19b | ||
|
|
9983a05a80 | ||
|
|
952acc3754 | ||
|
|
94754be1d7 | ||
|
|
56ea73145f | ||
|
|
e8d9fe8ebe | ||
|
|
6168d91b0e | ||
|
|
2712a556fb | ||
|
|
8da19c6dbd | ||
|
|
16f3f234e8 | ||
|
|
e80e320d34 | ||
|
|
f8bc248cc3 | ||
|
|
f165025992 | ||
|
|
ee5e6d9bfc | ||
|
|
2da0c8192d | ||
|
|
919fc57599 | ||
|
|
5badb6535f | ||
|
|
b86c884286 | ||
|
|
8a90be9a10 | ||
|
|
2f9e40fef1 | ||
|
|
0d218fca03 | ||
|
|
f9d42ebf8c | ||
|
|
0177abb172 | ||
|
|
77822d9462 | ||
|
|
78a7a5b561 | ||
|
|
7fde7fcf7b | ||
|
|
cdccb19d1c | ||
|
|
a3fdca376e | ||
|
|
d2595ccfea | ||
|
|
5b059dfd6b | ||
|
|
1a3c0d9be9 | ||
|
|
1e22d92c69 | ||
|
|
f3a4ae987d | ||
|
|
5e45fd7662 | ||
|
|
d7802b428a | ||
|
|
b8d35358ad | ||
|
|
daac4e5d34 | ||
|
|
57ceb807ca | ||
|
|
91d32c4556 | ||
|
|
e9e0f57d92 | ||
|
|
f090fee89b | ||
|
|
e62f87c5f4 | ||
|
|
1bbb844926 | ||
|
|
17cb990469 | ||
|
|
cccfc272df | ||
|
|
eb4e5e0bfb | ||
|
|
fbfcab2541 | ||
|
|
85f54ced38 | ||
|
|
b53c45a530 | ||
|
|
fa6991264b | ||
|
|
e1addb8c74 | ||
|
|
3e3a6740d5 | ||
|
|
5caacf5120 | ||
|
|
ebae9d9816 | ||
|
|
4457581ea5 | ||
|
|
fe773c0a46 | ||
|
|
348f13ad57 | ||
|
|
dd60d52814 | ||
|
|
428c3163c5 | ||
|
|
410178bb88 | ||
|
|
18eed1d727 | ||
|
|
ce72e40607 | ||
|
|
f038b7fc3d | ||
|
|
30dbc0a75b | ||
|
|
57d33c5027 | ||
|
|
e1c5526cb2 | ||
|
|
290c2ef84f | ||
|
|
073618d375 | ||
|
|
5ddf03d324 | ||
|
|
ac98be85ce | ||
|
|
048fae9de6 | ||
|
|
81735df1fa | ||
|
|
9c32ab0d8b | ||
|
|
861e75f503 | ||
|
|
e891120584 | ||
|
|
2045bb3c21 | ||
|
|
a498488c59 | ||
|
|
dd43ee3dbf | ||
|
|
39ad9eb8f3 | ||
|
|
b30ba5a92b |
@@ -3,6 +3,9 @@ compat/zlib/contrib/vstudio/readme.txt
|
||||
compat/zlib/contrib/vstudio/*/zlib.rc
|
||||
compat/zlib/win32/*.txt
|
||||
compat/zlib/win64/*.txt
|
||||
libtommath/*.dsp
|
||||
libtommath/*.sln
|
||||
libtommath/*.vcproj
|
||||
tools/tcl.hpj.in
|
||||
tools/tcl.wse.in
|
||||
win/buildall.vc.bat
|
||||
|
||||
@@ -3,6 +3,9 @@ compat/zlib/contrib/vstudio/readme.txt
|
||||
compat/zlib/contrib/vstudio/*/zlib.rc
|
||||
compat/zlib/win32/*.txt
|
||||
compat/zlib/win64/*.txt
|
||||
libtommath/*.dsp
|
||||
libtommath/*.sln
|
||||
libtommath/*.vcproj
|
||||
tools/tcl.hpj.in
|
||||
tools/tcl.wse.in
|
||||
win/buildall.vc.bat
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/tclsh*
|
||||
*/tcltest*
|
||||
*/versions.vc
|
||||
*/version.vc
|
||||
html
|
||||
libtommath/bn.ilg
|
||||
libtommath/bn.ind
|
||||
@@ -40,7 +41,8 @@ unix/dltest.marker
|
||||
unix/tcl.pc
|
||||
unix/tclIndex
|
||||
unix/pkgs/*
|
||||
win/Debug_VC*
|
||||
win/Release_VC*
|
||||
win/Debug*
|
||||
win/Release*
|
||||
win/pkgs/*
|
||||
win/tcl.hpj
|
||||
win/tcl.hpj
|
||||
win/nmhlp-out.txt
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
README: Tcl
|
||||
This is the Tcl 8.7a0 source distribution.
|
||||
This is the Tcl 8.7a2 source distribution.
|
||||
http://sourceforge.net/projects/tcl/files/Tcl/
|
||||
You can get any source release of Tcl from the URL above.
|
||||
|
||||
|
||||
@@ -8234,7 +8234,7 @@ Dropped support for OS X versions less than 10.4 (Tiger) (fellows)
|
||||
|
||||
2013-05-16 (platform support) mingw-4.0 (nijtmans)
|
||||
|
||||
2013-05-19 (platform support) FreeBSD updates (cerutti)
|
||||
2013-05-19 (platform support) FreeBSD updates (gahr)
|
||||
|
||||
2013-05-20 (bug fix)[3613567] access error temp file creation (keene)
|
||||
|
||||
@@ -8624,3 +8624,220 @@ improvements to regexp engine from Postgres (lane,porter,fellows,seltenreich)
|
||||
2016-02-22 (bug)[9b4702] [info exists env(missing)] kills trace (nijtmans)
|
||||
|
||||
--- Released 8.6.5, February 29, 2016 --- http://core.tcl.tk/tcl/ for details
|
||||
|
||||
2016-03-01 (bug)[803042] mem leak due to reference cycle (porter)
|
||||
|
||||
2016-03-08 (bug)[bbc304] reflected watch race condition (porter)
|
||||
|
||||
2016-03-17 (bug)[fadc99] compile-5.3 (rodriguez,porter)
|
||||
|
||||
2016-03-17 (enhancement)[1a25fd] compile [variable ${ns}::v] (porter)
|
||||
|
||||
2016-03-20 (bug)[1af8de] crash in compiled [string replace] (harder,fellows)
|
||||
|
||||
2016-03-21 (bug)[d30718] segv in notifier finalize (hirofumi,nijtmans)
|
||||
|
||||
2016-03-23 (enhancement)[7d0db7] parallel make (yarda,nijtmans)
|
||||
|
||||
2016-03-23 [f12535] enable test bindings customization (vogel,nijtmans)
|
||||
|
||||
2016-04-04 (bug)[47ac84] compiled [lreplace] fixes (aspect,ferrieux,fellows)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2016-04-08 (bug)[866368] RE \w includes 'Punctuation Connector' (nijtmans)
|
||||
|
||||
2016-04-08 (bug)[2538f3] Win crash Tcl_OpenTcpServer() (griffin)
|
||||
|
||||
2016-04-10 [07d13d] Restore TclBlend support lost in 8.6.1 (buratti)
|
||||
|
||||
2016-05-13 (bug)[3154ea] Mem corruption in assembler exceptions (tkob,kenny)
|
||||
|
||||
2016-05-13 (bug) registry package support any Unicode env (nijtmans)
|
||||
=> registry 1.3.2
|
||||
|
||||
2016-05-21 (bug)[f7d4e] [namespace delete] performance (fellows)
|
||||
|
||||
2016-06-02 (TIP 447) execution time verbosity option (gahr)
|
||||
=> tcltest 2.4.0
|
||||
|
||||
2016-06-16 (bug)[16828b] crash due to [vwait] trace undo fail (dah,porter)
|
||||
|
||||
2016-06-16 (enhancement)[4b61af] good [info frame] from more cases (beric)
|
||||
|
||||
2016-06-21 (bug)[c383eb] crash in [glob -path a] (oehlmann,porter)
|
||||
|
||||
2016-06-21 (update) Update Unicode data to 9.0 (nijtmans)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2016-06-22 (bug)[16896d] Tcl_DString tolerate append to self. (dah,porter)
|
||||
|
||||
2016-06-23 (bug)[d55322] crash in [dict update] (yorick,fellows)
|
||||
|
||||
2016-06-27 (bug)[dd260a] crash in [chan configure -dictionary] (madden,aspect)
|
||||
|
||||
2016-07-02 (bug)[f961d7] usage message with parameters with spaces (porter)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2016-07-02 (enhancement)[09fabc] Sort order of -relateddir (lanam)
|
||||
|
||||
2016-07-07 (bug)[5d7ca0] Win: [file executable] for .cmd and .ps1 (nadkarni)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2016-07-08 (bug)[a47641] [file normalize] & Windows junctions (nadkarni)
|
||||
|
||||
2016-07-09 [ae61a6] [file] handling of Win hardcoded names (CON) (nadkarni)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2016-07-09 [3613671] [file owned] (more) useful on Win (nadkarni)
|
||||
|
||||
2016-07-09 (bug)[1493a4] [namespace upvar] use of resolvers (beric,fellows)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2016-07-10 (bug)[da340d] integer division in clock math (nadkarni)
|
||||
|
||||
2016-07-20 tzdata updated to Olson's tzdata2016f (venkat)
|
||||
|
||||
--- Released 8.6.6, July 27, 2016 --- http://core.tcl.tk/tcl/ for details
|
||||
|
||||
2016-09-07 (bug)[c09edf] Bad caching with custom resolver (neumann,nijtmans)
|
||||
|
||||
2016-09-07 (bug)[4dbdd9] Memleak in test var-8.3 (mr_calvin,porter)
|
||||
|
||||
2016-10-03 (bug)[2bf561] Allow empty command as alias target (yorick,nijtmans)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2016-10-04 (bug)[4d5ae7] Crash in async connects host no address (gahr,fellows)
|
||||
|
||||
2016-10-08 (bug)[838e99] treat application/xml as text (gahr,fellows)
|
||||
=> http 2.8.10
|
||||
|
||||
2016-10-11 (bug)[3cc1d9] Thread finalization crash in zippy (neumann)
|
||||
|
||||
2016-10-12 (bug)[be003d] Fix [scan 0x1 %b], [scan 0x1 %o] (porter)
|
||||
|
||||
2016-10-14 (bug)[eb6b68] Fix stringComp-14.5 (porter)
|
||||
|
||||
2016-10-30 (bug)[b26e38] Fix zlib-7.8 (fellows)
|
||||
|
||||
2016-10-30 (bug)[1ae129] Fix memleak in [history] destruction (fellows)
|
||||
|
||||
2016-11-04 (feature) Provisional Tcl 9 support in msgcat and tcltest (nijtmans)
|
||||
=> msgcat 1.6.1
|
||||
=> tcltest 2.4.1
|
||||
|
||||
2016-11-04 (bug)[824752] Crash in Tcl_ListObjReplace() (gahr,porter)
|
||||
|
||||
2016-11-11 (bug)[79614f] invalidate VFS mounts on sytem encoding change (yorick)
|
||||
|
||||
2016-11-14 OSX: End panic() as legacy support macro; system conflicts (nijtmans)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2016-11-15 (bug) TclOO fix stops crash mixing Itcl and snit (fellows)
|
||||
|
||||
2016-11-17 (update) Reconcile libtommath updates; purge unused files (nijtmans)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2017-01-09 (bug)[b87ad7] Repair drifts in timer clock (sebres)
|
||||
|
||||
2017-01-17 (update) => zlib 1.2.11 (nijtmans)
|
||||
|
||||
2017-01-31 (bug)[39f630] Revise Tcl_LinkVar to tolerate some prefixes (nijtmans)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2017-02-01 (bug)[d0f7ba] Improper NAN optimization. expr-22.1[01] (aspect)
|
||||
|
||||
2017-02-26 (bug)[25842c] zlib stream finalization (aspect)
|
||||
|
||||
2017-03-07 (deprecate) Remove unmaintained makefile.bc file (nijtmans)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2017-03-14 (enhancement) [clock] and [encoding] are now ensembles (kenny)
|
||||
|
||||
2017-03-15 (enhancement) several [clock] subcommands bytecoded (kenny)
|
||||
|
||||
2017-03-23 tzdata updated to Olson's tzdata2017b (jima)
|
||||
|
||||
2017-03-29 (bug)[900cb0] Fix OO unexport introspection (napier)
|
||||
|
||||
2017-04-12 (bug)[42202b] Nesting imbalance in coro injection (nadkarni,sebres)
|
||||
|
||||
2017-04-18 (bug)[bc4322] http package support for safe interps (nash,nijtmans)
|
||||
|
||||
2017-04-28 (bug)[f34cf8] [file join a //b] => /b (neumann,porter)
|
||||
|
||||
2017-05-01 (bug)[8bd13f] Windows threads and pipes (sebres,nijtmans)
|
||||
|
||||
2017-05-01 (bug)[f9fe90] [file join //a b] EIAS violation (aspect,porter)
|
||||
|
||||
2017-05-04 (bug) Make test filesystem-1.52 pass on Windows (nijtmans)
|
||||
|
||||
2017-05-05 (bug)[601522] [binary] field spec overflow -> segfault (porter)
|
||||
|
||||
2017-05-08 (bug)[6ca52a] http memleak handling keep-alive (aspect,nijtmans)
|
||||
=> http 2.8.11
|
||||
|
||||
2017-05-29 (bug)[a3fb33] crash in [lsort] on long lists (sebres)
|
||||
|
||||
2017-06-05 (bug)[67aa9a] Tcl_UtfToUniChar() revised handling invalid UTF-8 (nijtmans)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2017-06-08 (bug)[2738427] Tcl_NumUtfChars() corner case utf-4.9 (nijtmans)
|
||||
|
||||
2017-06-22 (update) Update Unicode data to 10.0 (nijtmans)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2017-06-22 (TIP 473) Let [oo::copy] specify target namespace (fellows)
|
||||
|
||||
2017-06-26 (bug)[46f801] Repair autoloader fragility (porter)
|
||||
|
||||
2017-07-06 (bug)[adb198] Plug memleak in TclJoinPath (sebres,porter)
|
||||
|
||||
2017-07-17 (bug)[fb2208] Repeatable tclIndex generation (wiedemann,nijtmans)
|
||||
|
||||
--- Released 8.6.7, August 9, 2017 --- http://core.tcl.tk/tcl/ for details
|
||||
|
||||
2016-03-17 (bug)[0b8c38] socket accept callbacks always in global ns (porter)
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2016-07-01 Hack accommodations for legacy Itcl 3 disabled (porter)
|
||||
|
||||
2016-07-12 Make TCL_HASH_TYPE build-time configurable (nijtmans)
|
||||
|
||||
2016-07-19 (bug)[0363f0] Partial array search ID reform (porter)
|
||||
|
||||
2016-07-19 (feature removed) Tcl_ObjType "array search" unregistered (porter)
|
||||
*** POTENTIAL INCOMPATIBILITY for Tcl_GetObjType("array search") ***
|
||||
|
||||
2016-10-04 Server socket on port 0 chooses port supporting IPv4 * IPv6 (max)
|
||||
|
||||
2016-11-25 [array named -regexp] supports backrefs (goth)
|
||||
|
||||
2017-01-04 (TIP 456) New routine Tcl_OpenTcpServerEx() (limeboy)
|
||||
|
||||
2017-01-04 (TIP 459) New subcommand [package files] (nijtmans)
|
||||
|
||||
2017-01-16 threaded allocator initialization repair (vasiljevic,nijtmans)
|
||||
|
||||
2017-01-30 Add to Win shell builtins: assoc ftype move (ashok)
|
||||
|
||||
2017-03-31 TCL_MEM_DEBUG facilities better support 64-bit memory (nijtmans)
|
||||
|
||||
2017-04-13 \u escaped content in msg files converted to true utf-8 (nijtmans)
|
||||
|
||||
2017-05-18 (TIP 458) New epoll or kqueue notifiers are default (alborboz)
|
||||
|
||||
2017-05-31 Purge build support for SunOS-4.* (stu)
|
||||
|
||||
2017-06-22 (TIP 463) New option [regsub ... -command ...] (fellows)
|
||||
|
||||
2017-06-22 (TIP 470) Tcl_GetDefineContextObject();[oo::define [self]] (fellows)
|
||||
=> TclOO 1.2.0
|
||||
|
||||
2017-06-23 (TIP 472) Support 0d as prefix of decimal numbers (iyer,griffin)
|
||||
|
||||
2017-08-31 (bug)[2a9465] http state 100 continue handling broken (oehlmann)
|
||||
=> http 2.8.12
|
||||
|
||||
2017-09-02 (bug)[0e4d88] replace command, delete trace kills namespace (porter)
|
||||
|
||||
--- Released 8.7a1, September 8, 2017 --- http://core.tcl.tk/tcl/ for details
|
||||
|
||||
Executable → Regular
Executable → Regular
Regular → Executable
+5
-2
@@ -57,6 +57,9 @@ after the optional white space and sign are
|
||||
.QW \fB0x\fR
|
||||
then \fIsrc\fR is expected to be in hexadecimal form; otherwise,
|
||||
if the first such characters are
|
||||
.QW \fB0d\fR
|
||||
then \fIsrc\fR is expected to be in decimal form; otherwise,
|
||||
if the first such characters are
|
||||
.QW \fB0o\fR
|
||||
then \fIsrc\fR is expected to be in octal form; otherwise,
|
||||
if the first such characters are
|
||||
@@ -65,8 +68,8 @@ then \fIsrc\fR is expected to be in binary form; otherwise,
|
||||
if the first such character is
|
||||
.QW \fB0\fR
|
||||
then \fIsrc\fR
|
||||
is expected to be in octal form; otherwise, \fIsrc\fR is
|
||||
expected to be in decimal form.
|
||||
is expected to be in octal form; otherwise, \fIsrc\fR
|
||||
is expected to be in decimal form.
|
||||
.PP
|
||||
\fBTcl_GetDouble\fR expects \fIsrc\fR to consist of a floating-point
|
||||
number, which is: white space; a sign; a sequence of digits; a
|
||||
|
||||
Regular → Executable
+1
-1
@@ -37,7 +37,7 @@ Tcl_UniChar *
|
||||
Tcl_UniChar *
|
||||
\fBTcl_GetUnicode\fR(\fIobjPtr\fR)
|
||||
.sp
|
||||
Tcl_UniChar
|
||||
int
|
||||
\fBTcl_GetUniChar\fR(\fIobjPtr, index\fR)
|
||||
.sp
|
||||
int
|
||||
|
||||
+3
-3
@@ -13,13 +13,13 @@ Tcl_UniCharToUpper, Tcl_UniCharToLower, Tcl_UniCharToTitle, Tcl_UtfToUpper, Tcl_
|
||||
.nf
|
||||
\fB#include <tcl.h>\fR
|
||||
.sp
|
||||
Tcl_UniChar
|
||||
int
|
||||
\fBTcl_UniCharToUpper\fR(\fIch\fR)
|
||||
.sp
|
||||
Tcl_UniChar
|
||||
int
|
||||
\fBTcl_UniCharToLower\fR(\fIch\fR)
|
||||
.sp
|
||||
Tcl_UniChar
|
||||
int
|
||||
\fBTcl_UniCharToTitle\fR(\fIch\fR)
|
||||
.sp
|
||||
int
|
||||
|
||||
@@ -63,7 +63,7 @@ const char *
|
||||
const char *
|
||||
\fBTcl_UtfPrev\fR(\fIsrc, start\fR)
|
||||
.sp
|
||||
Tcl_UniChar
|
||||
int
|
||||
\fBTcl_UniCharAtIndex\fR(\fIsrc, index\fR)
|
||||
.sp
|
||||
const char *
|
||||
@@ -232,7 +232,7 @@ the start of the UTF-8 string. If \fIsrc\fR was already at \fIstart\fR, the
|
||||
return value will be \fIstart\fR.
|
||||
.PP
|
||||
\fBTcl_UniCharAtIndex\fR corresponds to a C string array dereference or the
|
||||
Pascal Ord() function. It returns the Tcl_UniChar represented at the
|
||||
Pascal Ord() function. It returns the Unicode character represented at the
|
||||
specified character (not byte) \fIindex\fR in the UTF-8 string
|
||||
\fIsrc\fR. The source string must contain at least \fIindex\fR
|
||||
characters. Behavior is undefined if a negative \fIindex\fR is given.
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ exception to occur.
|
||||
The exception causes the current script to be aborted
|
||||
out to the innermost containing loop command, which then
|
||||
continues with the next iteration of the loop.
|
||||
Catch exceptions are also handled in a few other situations, such
|
||||
Continue exceptions are also handled in a few other situations, such
|
||||
as the \fBcatch\fR command and the outermost scripts of procedure
|
||||
bodies.
|
||||
.SH EXAMPLE
|
||||
|
||||
+16
-6
@@ -14,7 +14,7 @@ oo::copy \- create copies of objects and classes
|
||||
.nf
|
||||
package require TclOO
|
||||
|
||||
\fBoo::copy\fI sourceObject \fR?\fItargetObject\fR?
|
||||
\fBoo::copy\fI sourceObject \fR?\fItargetObject\fR? ?\fItargetNamespace\fR?
|
||||
.fi
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
@@ -22,11 +22,21 @@ package require TclOO
|
||||
The \fBoo::copy\fR command creates a copy of an object or class. It takes the
|
||||
name of the object or class to be copied, \fIsourceObject\fR, and optionally
|
||||
the name of the object or class to create, \fItargetObject\fR, which will be
|
||||
resolved relative to the current namespace if not an absolute qualified name.
|
||||
If \fItargetObject\fR is omitted, a new name is chosen. The copied object will
|
||||
be of the same class as the source object, and will have all its per-object
|
||||
methods copied. If it is a class, it will also have all the class methods in
|
||||
the class copied, but it will not have any of its instances copied.
|
||||
resolved relative to the current namespace if not an absolute qualified name
|
||||
and
|
||||
.VS TIP473
|
||||
\fItargetNamespace\fR which is the name of the namespace that will hold the
|
||||
internal state of the object (\fBmy\fR command, etc.); it \fImust not\fR
|
||||
refer to an existing namespace.
|
||||
If either \fItargetObject\fR or \fItargetNamespace\fR is omitted or is given
|
||||
as the empty string, a new name is chosen. Names, unless specified, are
|
||||
chosen with the same algorithm used by the \fBnew\fR method of
|
||||
\fBoo::class\fR.
|
||||
.VE TIP473
|
||||
The copied object will be of the same class as the source object, and will have
|
||||
all its per-object methods copied. If it is a class, it will also have all the
|
||||
class methods in the class copied, but it will not have any of its instances
|
||||
copied.
|
||||
.PP
|
||||
.VS
|
||||
After the \fItargetObject\fR has been created and all definitions of its
|
||||
|
||||
+2
-1
@@ -46,7 +46,8 @@ value is the form produced by the \fB%g\fR format specifier of Tcl's
|
||||
An expression consists of a combination of operands, operators, parentheses and
|
||||
commas, possibly with whitespace between any of these elements, which is
|
||||
ignored.
|
||||
An integer operand may be specified in decimal, binary
|
||||
An integer operand may be specified in decimal (the normal case, the optional
|
||||
first two characters are \fB0d\fR), binary
|
||||
(the first two characters are \fB0b\fR), octal
|
||||
(the first two characters are \fB0o\fR), or hexadecimal
|
||||
(the first two characters are \fB0x\fR) form. For
|
||||
|
||||
@@ -89,6 +89,8 @@ For \fBx\fR or \fBX\fR conversions, \fB0x\fR or \fB0X\fR (respectively)
|
||||
will be added to the beginning of the result unless it is zero.
|
||||
For \fBb\fR conversions, \fB0b\fR
|
||||
will be added to the beginning of the result unless it is zero.
|
||||
For \fBd\fR conversions, \fB0d\fR will be added to the beginning
|
||||
of the result unless it is zero.
|
||||
For all floating-point conversions (\fBe\fR, \fBE\fR, \fBf\fR,
|
||||
\fBg\fR, and \fBG\fR) it guarantees that the result always
|
||||
has a decimal point.
|
||||
|
||||
Regular → Executable
+12
-10
@@ -70,18 +70,20 @@ from the corresponding match.
|
||||
.TP
|
||||
\fB\-command\fR
|
||||
.VS 8.7
|
||||
Changes the handling of the substitution string so that it no longer treats
|
||||
Changes the handling of \fIsubSpec\fR so that it is not treated
|
||||
as a template for a substitution string and the substrings
|
||||
.QW &
|
||||
and
|
||||
.QW \e
|
||||
as special characters, but instead uses them as a non-empty list of words.
|
||||
Each time a substitution is processed, another complete Tcl word is appended
|
||||
to that list for each substitution value (the first such argument represents
|
||||
the overall matched substring, the subsequent arguments will be one per
|
||||
capturing sub-RE, much as are returned from \fBregexp\fR \fB\-inline\fR) and
|
||||
the overall list is then evaluated as a Tcl command call. If the command
|
||||
finishes successfully, the result of command call is substituted into the
|
||||
resulting string.
|
||||
.QW \e\fIn\fR
|
||||
no longer have special meaning. Instead \fIsubSpec\fR must be a
|
||||
command prefix, that is, a non-empty list. The substring of \fIstring\fR
|
||||
that matches \fIexp\fR, and then each substring that matches each
|
||||
capturing sub-RE within \fIexp\fR are appended as additional elements
|
||||
to that list. (The items appended to the list are much like what
|
||||
\fBregexp\fR \fB-inline\fR would return). The completed list is then
|
||||
evaluated as a Tcl command, and the result of that command is the
|
||||
substitution string. Any error or exception from command evaluation
|
||||
becomes an error or exception from the \fBregsub\fR command.
|
||||
.RS
|
||||
.PP
|
||||
If \fB\-all\fR is not also given, the command callback will be invoked at most
|
||||
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2005 Sergey Brester aka sebres.
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH timerate n "" Tcl "Tcl Built-In Commands"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
timerate \- Time-related execution resp. performance measurement of a script
|
||||
.SH SYNOPSIS
|
||||
\fBtimerate \fIscript\fR \fI?time?\fR
|
||||
.sp
|
||||
\fBtimerate \fI?-direct?\fR \fI?-overhead double?\fR \fIscript\fR \fI?time?\fR
|
||||
.sp
|
||||
\fBtimerate \fI?-calibrate?\fR \fI?-direct?\fR \fIscript\fR \fI?time?\fR
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
The first and second form will evaluate \fIscript\fR until the interval
|
||||
\fItime\fR given in milliseconds elapses, or for 1000 milliseconds (1 second)
|
||||
if \fItime\fR is not specified.
|
||||
.sp
|
||||
It will then return a canonical tcl-list of the form
|
||||
.PP
|
||||
.CS
|
||||
\f0.095977 µs/# 52095836 # 10419167 #/sec 5000.000 nett-ms\fR
|
||||
.CE
|
||||
.PP
|
||||
which indicates:
|
||||
.IP \(bu
|
||||
the average amount of time required per iteration, in microseconds (lindex $result 0)
|
||||
.IP \(bu
|
||||
the count how many times it was executed (lindex $result 2)
|
||||
.IP \(bu
|
||||
the estimated rate per second (lindex $result 4)
|
||||
.IP \(bu
|
||||
the estimated real execution time without measurement overhead (lindex $result 6)
|
||||
.PP
|
||||
Time is measured in elapsed time using heighest timer resolution as possible, not CPU time.
|
||||
This command may be used to provide information as to how well the script or a tcl-command
|
||||
is performing and can help determine bottlenecks and fine-tune application performance.
|
||||
.PP
|
||||
\fI-calibrate\fR
|
||||
.
|
||||
To measure very fast scripts as exact as posible the calibration process
|
||||
may be required.
|
||||
|
||||
This parameter used to calibrate \fBtimerate\fR calculating the estimated overhead
|
||||
of given \fIscript\fR as default overhead for further execution of \fBtimerate\fR.
|
||||
It can take up to 10 seconds if parameter \fItime\fR is not specified.
|
||||
.PP
|
||||
\fI-overhead double\fR
|
||||
.
|
||||
This parameter used to supply the measurement overhead of single iteration
|
||||
(in microseconds) that should be ignored during whole evaluation process.
|
||||
.PP
|
||||
\fI-direct\fR
|
||||
.
|
||||
Causes direct execution per iteration (not compiled variant of evaluation used).
|
||||
.PP
|
||||
In opposition to \fBtime\fR the execution limited here by fixed time instead of
|
||||
repetition count.
|
||||
Additionally the compiled variant of the script will be used during whole evaluation
|
||||
(as if it were part of a compiled \fBproc\fR), if parameter \fI-direct\fR is not specified.
|
||||
Therefore it provides more precise results and prevents very long execution time
|
||||
by slow scripts resp. scripts with unknown speed.
|
||||
|
||||
.SH EXAMPLE
|
||||
Estimate how fast it takes for a simple Tcl \fBfor\fR loop (including
|
||||
operations on variable \fIi\fR) to count to a ten:
|
||||
.PP
|
||||
.CS
|
||||
# calibrate:
|
||||
timerate -calibrate {}
|
||||
# measure:
|
||||
timerate { for {set i 0} {$i<10} {incr i} {} } 5000
|
||||
.CE
|
||||
.PP
|
||||
Estimate how fast it takes for a simple Tcl \fBfor\fR loop only (ignoring the
|
||||
overhead for operations on variable \fIi\fR) to count to a ten:
|
||||
.PP
|
||||
.CS
|
||||
# calibrate for overhead of variable operations:
|
||||
set i 0; timerate -calibrate {expr {$i<10}; incr i} 1000
|
||||
# measure:
|
||||
timerate { for {set i 0} {$i<10} {incr i} {} } 5000
|
||||
.CE
|
||||
.PP
|
||||
Estimate the rate of calculating the hour using \fBclock format\fR only, ignoring
|
||||
overhead of the rest, without measurement how fast it takes for a whole script:
|
||||
.PP
|
||||
.CS
|
||||
# calibrate:
|
||||
timerate -calibrate {}
|
||||
# estimate overhead:
|
||||
set tm 0
|
||||
set ovh [lindex [timerate { incr tm [expr {24*60*60}] }] 0]
|
||||
# measure using esimated overhead:
|
||||
set tm 0
|
||||
timerate -overhead $ovh {
|
||||
clock format $tm -format %H
|
||||
incr tm [expr {24*60*60}]; # overhead for this is ignored
|
||||
} 5000
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
time(n)
|
||||
.SH KEYWORDS
|
||||
script, timerate, time
|
||||
.\" Local Variables:
|
||||
.\" mode: nroff
|
||||
.\" End:
|
||||
+5
-5
@@ -1148,16 +1148,16 @@ declare 319 {
|
||||
Tcl_QueuePosition position)
|
||||
}
|
||||
declare 320 {
|
||||
Tcl_UniChar Tcl_UniCharAtIndex(const char *src, int index)
|
||||
int Tcl_UniCharAtIndex(const char *src, int index)
|
||||
}
|
||||
declare 321 {
|
||||
Tcl_UniChar Tcl_UniCharToLower(int ch)
|
||||
int Tcl_UniCharToLower(int ch)
|
||||
}
|
||||
declare 322 {
|
||||
Tcl_UniChar Tcl_UniCharToTitle(int ch)
|
||||
int Tcl_UniCharToTitle(int ch)
|
||||
}
|
||||
declare 323 {
|
||||
Tcl_UniChar Tcl_UniCharToUpper(int ch)
|
||||
int Tcl_UniCharToUpper(int ch)
|
||||
}
|
||||
declare 324 {
|
||||
int Tcl_UniCharToUtf(int ch, char *buf)
|
||||
@@ -1351,7 +1351,7 @@ declare 380 {
|
||||
int Tcl_GetCharLength(Tcl_Obj *objPtr)
|
||||
}
|
||||
declare 381 {
|
||||
Tcl_UniChar Tcl_GetUniChar(Tcl_Obj *objPtr, int index)
|
||||
int Tcl_GetUniChar(Tcl_Obj *objPtr, int index)
|
||||
}
|
||||
declare 382 {
|
||||
Tcl_UniChar *Tcl_GetUnicode(Tcl_Obj *objPtr)
|
||||
|
||||
+5
-3
@@ -55,10 +55,10 @@ extern "C" {
|
||||
#define TCL_MAJOR_VERSION 8
|
||||
#define TCL_MINOR_VERSION 7
|
||||
#define TCL_RELEASE_LEVEL TCL_ALPHA_RELEASE
|
||||
#define TCL_RELEASE_SERIAL 0
|
||||
#define TCL_RELEASE_SERIAL 2
|
||||
|
||||
#define TCL_VERSION "8.7"
|
||||
#define TCL_PATCH_LEVEL "8.7a0"
|
||||
#define TCL_PATCH_LEVEL "8.7a2"
|
||||
|
||||
#if !defined(TCL_NO_DEPRECATED) || defined(RC_INVOKED)
|
||||
/*
|
||||
@@ -2201,7 +2201,7 @@ typedef struct Tcl_EncodingType {
|
||||
*/
|
||||
|
||||
#ifndef TCL_UTF_MAX
|
||||
#define TCL_UTF_MAX 3
|
||||
#define TCL_UTF_MAX 4
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -2263,6 +2263,8 @@ typedef struct mp_int mp_int;
|
||||
#define MP_INT_DECLARED
|
||||
typedef unsigned int mp_digit;
|
||||
#define MP_DIGIT_DECLARED
|
||||
typedef unsigned TCL_WIDE_INT_TYPE mp_word;
|
||||
#define MP_WORD_DECLARED
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------------
|
||||
|
||||
+106
-64
@@ -2053,11 +2053,11 @@ Tcl_CreateCommand(
|
||||
{
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
ImportRef *oldRefPtr = NULL;
|
||||
Namespace *nsPtr, *dummy1, *dummy2;
|
||||
Command *cmdPtr, *refCmdPtr;
|
||||
Namespace *nsPtr;
|
||||
Command *cmdPtr;
|
||||
Tcl_HashEntry *hPtr;
|
||||
const char *tail;
|
||||
int isNew;
|
||||
int isNew = 0, deleted = 0;
|
||||
ImportedCmdData *dataPtr;
|
||||
|
||||
if (iPtr->flags & DELETED) {
|
||||
@@ -2070,32 +2070,52 @@ Tcl_CreateCommand(
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine where the command should reside. If its name contains
|
||||
* namespace qualifiers, we put it in the specified namespace; otherwise,
|
||||
* we always put it in the global namespace.
|
||||
* If the command name we seek to create already exists, we need to
|
||||
* delete that first. That can be tricky in the presence of traces.
|
||||
* Loop until we no longer find an existing command in the way, or
|
||||
* until we've deleted one command and that didn't finish the job.
|
||||
*/
|
||||
|
||||
if (strstr(cmdName, "::") != NULL) {
|
||||
TclGetNamespaceForQualName(interp, cmdName, NULL,
|
||||
TCL_CREATE_NS_IF_UNKNOWN, &nsPtr, &dummy1, &dummy2, &tail);
|
||||
if ((nsPtr == NULL) || (tail == NULL)) {
|
||||
return (Tcl_Command) NULL;
|
||||
}
|
||||
} else {
|
||||
nsPtr = iPtr->globalNsPtr;
|
||||
tail = cmdName;
|
||||
}
|
||||
while (1) {
|
||||
/*
|
||||
* Determine where the command should reside. If its name contains
|
||||
* namespace qualifiers, we put it in the specified namespace;
|
||||
* otherwise, we always put it in the global namespace.
|
||||
*/
|
||||
|
||||
if (strstr(cmdName, "::") != NULL) {
|
||||
Namespace *dummy1, *dummy2;
|
||||
|
||||
TclGetNamespaceForQualName(interp, cmdName, NULL,
|
||||
TCL_CREATE_NS_IF_UNKNOWN, &nsPtr, &dummy1, &dummy2, &tail);
|
||||
if ((nsPtr == NULL) || (tail == NULL)) {
|
||||
return (Tcl_Command) NULL;
|
||||
}
|
||||
} else {
|
||||
nsPtr = iPtr->globalNsPtr;
|
||||
tail = cmdName;
|
||||
}
|
||||
|
||||
hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, tail, &isNew);
|
||||
|
||||
if (isNew || deleted) {
|
||||
/*
|
||||
* isNew - No conflict with existing command.
|
||||
* deleted - We've already deleted a conflicting command
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
/* An existing command conflicts. Try to delete it.. */
|
||||
cmdPtr = Tcl_GetHashValue(hPtr);
|
||||
|
||||
hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, tail, &isNew);
|
||||
if (!isNew) {
|
||||
/*
|
||||
* Command already exists. Delete the old one. Be careful to preserve
|
||||
* Be careful to preserve
|
||||
* any existing import links so we can restore them down below. That
|
||||
* way, you can redefine a command and its import status will remain
|
||||
* intact.
|
||||
*/
|
||||
|
||||
cmdPtr = Tcl_GetHashValue(hPtr);
|
||||
cmdPtr->refCount++;
|
||||
if (cmdPtr->importRefPtr) {
|
||||
cmdPtr->flags |= CMD_REDEF_IN_PROGRESS;
|
||||
@@ -2108,18 +2128,21 @@ Tcl_CreateCommand(
|
||||
cmdPtr->importRefPtr = NULL;
|
||||
}
|
||||
TclCleanupCommandMacro(cmdPtr);
|
||||
deleted = 1;
|
||||
}
|
||||
|
||||
hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, tail, &isNew);
|
||||
if (!isNew) {
|
||||
/*
|
||||
* If the deletion callback recreated the command, just throw away
|
||||
* the new command (if we try to delete it again, we could get
|
||||
* stuck in an infinite loop).
|
||||
*/
|
||||
if (!isNew) {
|
||||
/*
|
||||
* If the deletion callback recreated the command, just throw away
|
||||
* the new command (if we try to delete it again, we could get
|
||||
* stuck in an infinite loop).
|
||||
*/
|
||||
|
||||
ckfree(Tcl_GetHashValue(hPtr));
|
||||
}
|
||||
|
||||
if (!deleted) {
|
||||
|
||||
ckfree(Tcl_GetHashValue(hPtr));
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Command resolvers (per-interp, per-namespace) might have resolved
|
||||
* to a command for the given namespace scope with this command not
|
||||
@@ -2167,7 +2190,7 @@ Tcl_CreateCommand(
|
||||
if (oldRefPtr != NULL) {
|
||||
cmdPtr->importRefPtr = oldRefPtr;
|
||||
while (oldRefPtr != NULL) {
|
||||
refCmdPtr = oldRefPtr->importedCmdPtr;
|
||||
Command *refCmdPtr = oldRefPtr->importedCmdPtr;
|
||||
dataPtr = refCmdPtr->objClientData;
|
||||
dataPtr->realCmdPtr = cmdPtr;
|
||||
oldRefPtr = oldRefPtr->nextPtr;
|
||||
@@ -2228,11 +2251,11 @@ Tcl_CreateObjCommand(
|
||||
{
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
ImportRef *oldRefPtr = NULL;
|
||||
Namespace *nsPtr, *dummy1, *dummy2;
|
||||
Command *cmdPtr, *refCmdPtr;
|
||||
Namespace *nsPtr;
|
||||
Command *cmdPtr;
|
||||
Tcl_HashEntry *hPtr;
|
||||
const char *tail;
|
||||
int isNew;
|
||||
int isNew = 0, deleted = 0;
|
||||
ImportedCmdData *dataPtr;
|
||||
|
||||
if (iPtr->flags & DELETED) {
|
||||
@@ -2245,29 +2268,45 @@ Tcl_CreateObjCommand(
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine where the command should reside. If its name contains
|
||||
* namespace qualifiers, we put it in the specified namespace; otherwise,
|
||||
* we always put it in the global namespace.
|
||||
* If the command name we seek to create already exists, we need to
|
||||
* delete that first. That can be tricky in the presence of traces.
|
||||
* Loop until we no longer find an existing command in the way, or
|
||||
* until we've deleted one command and that didn't finish the job.
|
||||
*/
|
||||
|
||||
if (strstr(cmdName, "::") != NULL) {
|
||||
TclGetNamespaceForQualName(interp, cmdName, NULL,
|
||||
while (1) {
|
||||
/*
|
||||
* Determine where the command should reside. If its name contains
|
||||
* namespace qualifiers, we put it in the specified namespace;
|
||||
* otherwise, we always put it in the global namespace.
|
||||
*/
|
||||
|
||||
if (strstr(cmdName, "::") != NULL) {
|
||||
Namespace *dummy1, *dummy2;
|
||||
|
||||
TclGetNamespaceForQualName(interp, cmdName, NULL,
|
||||
TCL_CREATE_NS_IF_UNKNOWN, &nsPtr, &dummy1, &dummy2, &tail);
|
||||
if ((nsPtr == NULL) || (tail == NULL)) {
|
||||
return (Tcl_Command) NULL;
|
||||
}
|
||||
} else {
|
||||
nsPtr = iPtr->globalNsPtr;
|
||||
tail = cmdName;
|
||||
}
|
||||
if ((nsPtr == NULL) || (tail == NULL)) {
|
||||
return (Tcl_Command) NULL;
|
||||
}
|
||||
} else {
|
||||
nsPtr = iPtr->globalNsPtr;
|
||||
tail = cmdName;
|
||||
}
|
||||
|
||||
hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, tail, &isNew);
|
||||
TclInvalidateNsPath(nsPtr);
|
||||
if (!isNew) {
|
||||
hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, tail, &isNew);
|
||||
|
||||
if (isNew || deleted) {
|
||||
/*
|
||||
* isNew - No conflict with existing command.
|
||||
* deleted - We've already deleted a conflicting command
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
/* An existing command conflicts. Try to delete it.. */
|
||||
cmdPtr = Tcl_GetHashValue(hPtr);
|
||||
|
||||
/* Command already exists. */
|
||||
|
||||
/*
|
||||
* [***] This is wrong. See Tcl Bug a16752c252.
|
||||
* However, this buggy behavior is kept under particular
|
||||
@@ -2304,18 +2343,20 @@ Tcl_CreateObjCommand(
|
||||
cmdPtr->importRefPtr = NULL;
|
||||
}
|
||||
TclCleanupCommandMacro(cmdPtr);
|
||||
deleted = 1;
|
||||
}
|
||||
|
||||
hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, tail, &isNew);
|
||||
if (!isNew) {
|
||||
/*
|
||||
* If the deletion callback recreated the command, just throw away
|
||||
* the new command (if we try to delete it again, we could get
|
||||
* stuck in an infinite loop).
|
||||
*/
|
||||
if (!isNew) {
|
||||
/*
|
||||
* If the deletion callback recreated the command, just throw away
|
||||
* the new command (if we try to delete it again, we could get
|
||||
* stuck in an infinite loop).
|
||||
*/
|
||||
|
||||
ckfree(Tcl_GetHashValue(hPtr));
|
||||
}
|
||||
} else {
|
||||
ckfree(Tcl_GetHashValue(hPtr));
|
||||
}
|
||||
|
||||
if (!deleted) {
|
||||
/*
|
||||
* Command resolvers (per-interp, per-namespace) might have resolved
|
||||
* to a command for the given namespace scope with this command not
|
||||
@@ -2335,6 +2376,7 @@ Tcl_CreateObjCommand(
|
||||
*/
|
||||
|
||||
TclInvalidateNsCmdLookup(nsPtr);
|
||||
TclInvalidateNsPath(nsPtr);
|
||||
}
|
||||
cmdPtr = ckalloc(sizeof(Command));
|
||||
Tcl_SetHashValue(hPtr, cmdPtr);
|
||||
@@ -2362,7 +2404,7 @@ Tcl_CreateObjCommand(
|
||||
if (oldRefPtr != NULL) {
|
||||
cmdPtr->importRefPtr = oldRefPtr;
|
||||
while (oldRefPtr != NULL) {
|
||||
refCmdPtr = oldRefPtr->importedCmdPtr;
|
||||
Command *refCmdPtr = oldRefPtr->importedCmdPtr;
|
||||
dataPtr = refCmdPtr->objClientData;
|
||||
dataPtr->realCmdPtr = cmdPtr;
|
||||
oldRefPtr = oldRefPtr->nextPtr;
|
||||
@@ -7418,7 +7460,7 @@ ExprAbsFunc(
|
||||
}
|
||||
goto unChanged;
|
||||
} else if (l == LONG_MIN) {
|
||||
TclBNInitBignumFromLong(&big, l);
|
||||
TclInitBignumFromLong(&big, l);
|
||||
goto tooLarge;
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_NewLongObj(-l));
|
||||
@@ -7453,7 +7495,7 @@ ExprAbsFunc(
|
||||
goto unChanged;
|
||||
}
|
||||
if (w == LLONG_MIN) {
|
||||
TclBNInitBignumFromWideInt(&big, w);
|
||||
TclInitBignumFromWideInt(&big, w);
|
||||
goto tooLarge;
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(-w));
|
||||
|
||||
+4
-4
@@ -536,7 +536,7 @@ SetByteArrayFromAny(
|
||||
const char *src, *srcEnd;
|
||||
unsigned char *dst;
|
||||
ByteArray *byteArrayPtr;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
|
||||
if (objPtr->typePtr == &properByteArrayType) {
|
||||
return TCL_OK;
|
||||
@@ -1300,7 +1300,7 @@ BinaryFormatCmd(
|
||||
|
||||
badField:
|
||||
{
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
char buf[TCL_UTF_MAX + 1];
|
||||
|
||||
TclUtfToUniChar(errorString, &ch);
|
||||
@@ -1670,7 +1670,7 @@ BinaryScanCmd(
|
||||
|
||||
badField:
|
||||
{
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
char buf[TCL_UTF_MAX + 1];
|
||||
|
||||
TclUtfToUniChar(errorString, &ch);
|
||||
@@ -2284,7 +2284,7 @@ ScanNumber(
|
||||
Tcl_Obj *bigObj = NULL;
|
||||
mp_int big;
|
||||
|
||||
TclBNInitBignumFromWideUInt(&big, uwvalue);
|
||||
TclInitBignumFromWideUInt(&big, uwvalue);
|
||||
bigObj = Tcl_NewBignumObj(&big);
|
||||
return bigObj;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -4370,7 +4370,7 @@ static int
|
||||
DictionaryCompare(
|
||||
const char *left, const char *right) /* The strings to compare. */
|
||||
{
|
||||
Tcl_UniChar uniLeft, uniRight, uniLeftLower, uniRightLower;
|
||||
Tcl_UniChar uniLeft = 0, uniRight = 0, uniLeftLower, uniRightLower;
|
||||
int diff, zeros;
|
||||
int secondaryDiff = 0;
|
||||
|
||||
|
||||
+28
-20
@@ -309,7 +309,7 @@ Tcl_RegexpObjCmd(
|
||||
eflags = 0;
|
||||
} else if (offset > stringLength) {
|
||||
eflags = TCL_REG_NOTBOL;
|
||||
} else if (Tcl_GetUniChar(objPtr, offset-1) == (Tcl_UniChar)'\n') {
|
||||
} else if (Tcl_GetUniChar(objPtr, offset-1) == '\n') {
|
||||
eflags = 0;
|
||||
} else {
|
||||
eflags = TCL_REG_NOTBOL;
|
||||
@@ -487,12 +487,11 @@ Tcl_RegsubObjCmd(
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
int idx, result, cflags, all, wlen, wsublen, numMatches, offset;
|
||||
int start, end, subStart, subEnd, match, command, numParts, numArgs;
|
||||
int start, end, subStart, subEnd, match, command, numParts;
|
||||
Tcl_RegExp regExpr;
|
||||
Tcl_RegExpInfo info;
|
||||
Tcl_Obj *resultPtr, *subPtr, *objPtr, *startIndex = NULL;
|
||||
Tcl_Obj **args = NULL, **parts;
|
||||
Tcl_UniChar ch, *wsrc, *wfirstChar, *wstring, *wsubspec, *wend;
|
||||
Tcl_UniChar ch = 0, *wsrc, *wfirstChar, *wstring, *wsubspec, *wend;
|
||||
|
||||
static const char *const options[] = {
|
||||
"-all", "-command", "-expanded", "-line",
|
||||
@@ -773,12 +772,13 @@ Tcl_RegsubObjCmd(
|
||||
*/
|
||||
|
||||
if (command) {
|
||||
if (args == NULL) {
|
||||
Tcl_ListObjGetElements(interp, subPtr, &numParts, &parts);
|
||||
numArgs = numParts + info.nsubs + 1;
|
||||
args = ckalloc(sizeof(Tcl_Obj*) * numArgs);
|
||||
memcpy(args, parts, sizeof(Tcl_Obj*) * numParts);
|
||||
}
|
||||
Tcl_Obj **args = NULL, **parts;
|
||||
int numArgs;
|
||||
|
||||
Tcl_ListObjGetElements(interp, subPtr, &numParts, &parts);
|
||||
numArgs = numParts + info.nsubs + 1;
|
||||
args = ckalloc(sizeof(Tcl_Obj*) * numArgs);
|
||||
memcpy(args, parts, sizeof(Tcl_Obj*) * numParts);
|
||||
|
||||
for (idx = 0 ; idx <= info.nsubs ; idx++) {
|
||||
subStart = info.matches[idx].start;
|
||||
@@ -800,13 +800,14 @@ Tcl_RegsubObjCmd(
|
||||
* because Tcl_EvalObjv is "hairy monster" in terms of refcount
|
||||
* handling, being able to optionally add references to any of its
|
||||
* argument words. We'll drop the local refs immediately
|
||||
* afterwarsds; subPtr is handled in the main exit stanza.
|
||||
* afterwards; subPtr is handled in the main exit stanza.
|
||||
*/
|
||||
|
||||
result = Tcl_EvalObjv(interp, numArgs, args, 0);
|
||||
for (idx = 0 ; idx <= info.nsubs ; idx++) {
|
||||
TclDecrRefCount(args[idx + numParts]);
|
||||
}
|
||||
ckfree(args);
|
||||
if (result != TCL_OK) {
|
||||
if (result == TCL_ERROR) {
|
||||
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
|
||||
@@ -975,9 +976,6 @@ Tcl_RegsubObjCmd(
|
||||
if (subPtr && (objv[2] == objv[0])) {
|
||||
Tcl_DecrRefCount(subPtr);
|
||||
}
|
||||
if (args) {
|
||||
ckfree(args);
|
||||
}
|
||||
if (resultPtr) {
|
||||
Tcl_DecrRefCount(resultPtr);
|
||||
}
|
||||
@@ -1175,7 +1173,7 @@ Tcl_SplitObjCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
int len;
|
||||
const char *splitChars;
|
||||
const char *stringPtr;
|
||||
@@ -1220,6 +1218,10 @@ Tcl_SplitObjCmd(
|
||||
for ( ; stringPtr < end; stringPtr += len) {
|
||||
len = TclUtfToUniChar(stringPtr, &ch);
|
||||
|
||||
if (!len) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Assume Tcl_UniChar is an integral type...
|
||||
*/
|
||||
@@ -1260,7 +1262,7 @@ Tcl_SplitObjCmd(
|
||||
} else {
|
||||
const char *element, *p, *splitEnd;
|
||||
int splitLen;
|
||||
Tcl_UniChar splitChar;
|
||||
Tcl_UniChar splitChar = 0;
|
||||
|
||||
/*
|
||||
* Normal case: split on any of a given set of characters. Discard
|
||||
@@ -1484,7 +1486,7 @@ StringIsCmd(
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
const char *string1, *end, *stop;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
int (*chcomp)(int) = NULL; /* The UniChar comparison function. */
|
||||
int i, failat = 0, result = 1, strict = 0, index, length1, length2;
|
||||
Tcl_Obj *objPtr, *failVarObj = NULL;
|
||||
@@ -1816,8 +1818,14 @@ StringIsCmd(
|
||||
}
|
||||
end = string1 + length1;
|
||||
for (; string1 < end; string1 += length2, failat++) {
|
||||
int fullchar;
|
||||
length2 = TclUtfToUniChar(string1, &ch);
|
||||
if (!chcomp(ch)) {
|
||||
fullchar = ch;
|
||||
if (!length2) {
|
||||
length2 = TclUtfToUniChar(string1, &ch);
|
||||
fullchar = (((fullchar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000;
|
||||
}
|
||||
if (!chcomp(fullchar)) {
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
@@ -2412,7 +2420,7 @@ StringStartCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
const char *p, *string;
|
||||
int cur, index, length, numChars;
|
||||
|
||||
@@ -2473,7 +2481,7 @@ StringEndCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
const char *p, *end, *string;
|
||||
int cur, index, length, numChars;
|
||||
|
||||
|
||||
@@ -1885,7 +1885,7 @@ ParseLexeme(
|
||||
{
|
||||
const char *end;
|
||||
int scanned;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
Tcl_Obj *literal = NULL;
|
||||
unsigned char byte;
|
||||
|
||||
|
||||
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
* tclDate.h --
|
||||
*
|
||||
* This header file handles common usage of clock primitives
|
||||
* between tclDate.c (yacc), tclClock.c and tclClockFmt.c.
|
||||
*
|
||||
* Copyright (c) 2014 Serg G. Brester (aka sebres)
|
||||
*
|
||||
* See the file "license.terms" for information on usage and redistribution
|
||||
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
*/
|
||||
|
||||
#ifndef _TCLCLOCK_H
|
||||
#define _TCLCLOCK_H
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
|
||||
#define JULIAN_DAY_POSIX_EPOCH 2440588
|
||||
#define GREGORIAN_CHANGE_DATE 2361222
|
||||
#define SECONDS_PER_DAY 86400
|
||||
#define JULIAN_SEC_POSIX_EPOCH (((Tcl_WideInt) JULIAN_DAY_POSIX_EPOCH) \
|
||||
* SECONDS_PER_DAY)
|
||||
#define FOUR_CENTURIES 146097 /* days */
|
||||
#define JDAY_1_JAN_1_CE_JULIAN 1721424
|
||||
#define JDAY_1_JAN_1_CE_GREGORIAN 1721426
|
||||
#define ONE_CENTURY_GREGORIAN 36524 /* days */
|
||||
#define FOUR_YEARS 1461 /* days */
|
||||
#define ONE_YEAR 365 /* days */
|
||||
|
||||
#define RODDENBERRY 1946 /* Another epoch (Hi, Jeff!) */
|
||||
|
||||
|
||||
#define CLF_OPTIONAL (1 << 0) /* token is non mandatory */
|
||||
#define CLF_POSIXSEC (1 << 1)
|
||||
#define CLF_LOCALSEC (1 << 2)
|
||||
#define CLF_JULIANDAY (1 << 3)
|
||||
#define CLF_TIME (1 << 4)
|
||||
#define CLF_CENTURY (1 << 6)
|
||||
#define CLF_DAYOFMONTH (1 << 7)
|
||||
#define CLF_DAYOFYEAR (1 << 8)
|
||||
#define CLF_MONTH (1 << 9)
|
||||
#define CLF_YEAR (1 << 10)
|
||||
#define CLF_ISO8601YEAR (1 << 12)
|
||||
#define CLF_ISO8601 (1 << 13)
|
||||
#define CLF_ISO8601CENTURY (1 << 14)
|
||||
#define CLF_SIGNED (1 << 15)
|
||||
/* On demand (lazy) assemble flags */
|
||||
#define CLF_ASSEMBLE_DATE (1 << 28) /* assemble year, month, etc. using julianDay */
|
||||
#define CLF_ASSEMBLE_JULIANDAY (1 << 29) /* assemble julianDay using year, month, etc. */
|
||||
#define CLF_ASSEMBLE_SECONDS (1 << 30) /* assemble localSeconds (and seconds at end) */
|
||||
|
||||
#define CLF_DATE (CLF_JULIANDAY | CLF_DAYOFMONTH | CLF_DAYOFYEAR | \
|
||||
CLF_MONTH | CLF_YEAR | CLF_ISO8601YEAR | CLF_ISO8601)
|
||||
|
||||
/*
|
||||
* Enumeration of the string literals used in [clock]
|
||||
*/
|
||||
|
||||
typedef enum ClockLiteral {
|
||||
LIT__NIL,
|
||||
LIT__DEFAULT_FORMAT,
|
||||
LIT_SYSTEM, LIT_CURRENT, LIT_C,
|
||||
LIT_BCE, LIT_CE,
|
||||
LIT_DAYOFMONTH, LIT_DAYOFWEEK, LIT_DAYOFYEAR,
|
||||
LIT_ERA, LIT_GMT, LIT_GREGORIAN,
|
||||
LIT_INTEGER_VALUE_TOO_LARGE,
|
||||
LIT_ISO8601WEEK, LIT_ISO8601YEAR,
|
||||
LIT_JULIANDAY, LIT_LOCALSECONDS,
|
||||
LIT_MONTH,
|
||||
LIT_SECONDS, LIT_TZNAME, LIT_TZOFFSET,
|
||||
LIT_YEAR,
|
||||
LIT_TZDATA,
|
||||
LIT_GETSYSTEMTIMEZONE,
|
||||
LIT_SETUPTIMEZONE,
|
||||
LIT_MCGET,
|
||||
LIT_GETSYSTEMLOCALE, LIT_GETCURRENTLOCALE,
|
||||
LIT_LOCALIZE_FORMAT,
|
||||
LIT__END
|
||||
} ClockLiteral;
|
||||
|
||||
#define CLOCK_LITERAL_ARRAY(litarr) static const char *const litarr[] = { \
|
||||
"", \
|
||||
"%a %b %d %H:%M:%S %Z %Y", \
|
||||
"system", "current", "C", \
|
||||
"BCE", "CE", \
|
||||
"dayOfMonth", "dayOfWeek", "dayOfYear", \
|
||||
"era", ":GMT", "gregorian", \
|
||||
"integer value too large to represent", \
|
||||
"iso8601Week", "iso8601Year", \
|
||||
"julianDay", "localSeconds", \
|
||||
"month", \
|
||||
"seconds", "tzName", "tzOffset", \
|
||||
"year", \
|
||||
"::tcl::clock::TZData", \
|
||||
"::tcl::clock::GetSystemTimeZone", \
|
||||
"::tcl::clock::SetupTimeZone", \
|
||||
"::tcl::clock::mcget", \
|
||||
"::tcl::clock::GetSystemLocale", "::tcl::clock::mclocale", \
|
||||
"::tcl::clock::LocalizeFormat" \
|
||||
}
|
||||
|
||||
/*
|
||||
* Enumeration of the msgcat literals used in [clock]
|
||||
*/
|
||||
|
||||
typedef enum ClockMsgCtLiteral {
|
||||
MCLIT__NIL, /* placeholder */
|
||||
MCLIT_MONTHS_FULL, MCLIT_MONTHS_ABBREV, MCLIT_MONTHS_COMB,
|
||||
MCLIT_DAYS_OF_WEEK_FULL, MCLIT_DAYS_OF_WEEK_ABBREV, MCLIT_DAYS_OF_WEEK_COMB,
|
||||
MCLIT_AM, MCLIT_PM,
|
||||
MCLIT_LOCALE_ERAS,
|
||||
MCLIT_BCE, MCLIT_CE,
|
||||
MCLIT_BCE2, MCLIT_CE2,
|
||||
MCLIT_BCE3, MCLIT_CE3,
|
||||
MCLIT_LOCALE_NUMERALS,
|
||||
MCLIT__END
|
||||
} ClockMsgCtLiteral;
|
||||
|
||||
#define CLOCK_LOCALE_LITERAL_ARRAY(litarr, pref) static const char *const litarr[] = { \
|
||||
pref "", \
|
||||
pref "MONTHS_FULL", pref "MONTHS_ABBREV", pref "MONTHS_COMB", \
|
||||
pref "DAYS_OF_WEEK_FULL", pref "DAYS_OF_WEEK_ABBREV", pref "DAYS_OF_WEEK_COMB", \
|
||||
pref "AM", pref "PM", \
|
||||
pref "LOCALE_ERAS", \
|
||||
pref "BCE", pref "CE", \
|
||||
pref "b.c.e.", pref "c.e.", \
|
||||
pref "b.c.", pref "a.d.", \
|
||||
pref "LOCALE_NUMERALS", \
|
||||
}
|
||||
|
||||
/*
|
||||
* Structure containing the fields used in [clock format] and [clock scan]
|
||||
*/
|
||||
|
||||
typedef struct TclDateFields {
|
||||
|
||||
/* Cacheable fields: */
|
||||
|
||||
Tcl_WideInt seconds; /* Time expressed in seconds from the Posix
|
||||
* epoch */
|
||||
Tcl_WideInt localSeconds; /* Local time expressed in nominal seconds
|
||||
* from the Posix epoch */
|
||||
int tzOffset; /* Time zone offset in seconds east of
|
||||
* Greenwich */
|
||||
int julianDay; /* Julian Day Number in local time zone */
|
||||
enum {BCE=1, CE=0} era; /* Era */
|
||||
int gregorian; /* Flag == 1 if the date is Gregorian */
|
||||
int year; /* Year of the era */
|
||||
int dayOfYear; /* Day of the year (1 January == 1) */
|
||||
int month; /* Month number */
|
||||
int dayOfMonth; /* Day of the month */
|
||||
int iso8601Year; /* ISO8601 week-based year */
|
||||
int iso8601Week; /* ISO8601 week number */
|
||||
int dayOfWeek; /* Day of the week */
|
||||
int hour; /* Hours of day (in-between time only calculation) */
|
||||
int minutes; /* Minutes of day (in-between time only calculation) */
|
||||
int secondOfDay; /* Seconds of day (in-between time only calculation) */
|
||||
|
||||
/* Non cacheable fields: */
|
||||
|
||||
Tcl_Obj *tzName; /* Name (or corresponding DST-abbreviation) of the
|
||||
* time zone, if set the refCount is incremented */
|
||||
} TclDateFields;
|
||||
|
||||
#define ClockCacheableDateFieldsSize \
|
||||
TclOffset(TclDateFields, tzName)
|
||||
|
||||
/*
|
||||
* Structure contains return parsed fields.
|
||||
*/
|
||||
|
||||
typedef struct DateInfo {
|
||||
const char *dateStart;
|
||||
const char *dateInput;
|
||||
const char *dateEnd;
|
||||
|
||||
TclDateFields date;
|
||||
|
||||
int flags;
|
||||
|
||||
int dateHaveDate;
|
||||
|
||||
int dateMeridian;
|
||||
int dateHaveTime;
|
||||
|
||||
int dateTimezone;
|
||||
int dateDSTmode;
|
||||
int dateHaveZone;
|
||||
|
||||
int dateRelMonth;
|
||||
int dateRelDay;
|
||||
int dateRelSeconds;
|
||||
int dateHaveRel;
|
||||
|
||||
int dateMonthOrdinalIncr;
|
||||
int dateMonthOrdinal;
|
||||
int dateHaveOrdinalMonth;
|
||||
|
||||
int dateDayOrdinal;
|
||||
int dateDayNumber;
|
||||
int dateHaveDay;
|
||||
|
||||
int *dateRelPointer;
|
||||
|
||||
int dateSpaceCount;
|
||||
int dateDigitCount;
|
||||
|
||||
int dateCentury;
|
||||
|
||||
Tcl_Obj* messages; /* Error messages */
|
||||
const char* separatrix; /* String separating messages */
|
||||
} DateInfo;
|
||||
|
||||
#define yydate (info->date) /* Date fields used for converting */
|
||||
|
||||
#define yyDay (info->date.dayOfMonth)
|
||||
#define yyMonth (info->date.month)
|
||||
#define yyYear (info->date.year)
|
||||
|
||||
#define yyHour (info->date.hour)
|
||||
#define yyMinutes (info->date.minutes)
|
||||
#define yySeconds (info->date.secondOfDay)
|
||||
|
||||
#define yyDSTmode (info->dateDSTmode)
|
||||
#define yyDayOrdinal (info->dateDayOrdinal)
|
||||
#define yyDayNumber (info->dateDayNumber)
|
||||
#define yyMonthOrdinalIncr (info->dateMonthOrdinalIncr)
|
||||
#define yyMonthOrdinal (info->dateMonthOrdinal)
|
||||
#define yyHaveDate (info->dateHaveDate)
|
||||
#define yyHaveDay (info->dateHaveDay)
|
||||
#define yyHaveOrdinalMonth (info->dateHaveOrdinalMonth)
|
||||
#define yyHaveRel (info->dateHaveRel)
|
||||
#define yyHaveTime (info->dateHaveTime)
|
||||
#define yyHaveZone (info->dateHaveZone)
|
||||
#define yyTimezone (info->dateTimezone)
|
||||
#define yyMeridian (info->dateMeridian)
|
||||
#define yyRelMonth (info->dateRelMonth)
|
||||
#define yyRelDay (info->dateRelDay)
|
||||
#define yyRelSeconds (info->dateRelSeconds)
|
||||
#define yyRelPointer (info->dateRelPointer)
|
||||
#define yyInput (info->dateInput)
|
||||
#define yyDigitCount (info->dateDigitCount)
|
||||
#define yySpaceCount (info->dateSpaceCount)
|
||||
|
||||
static inline void
|
||||
ClockInitDateInfo(DateInfo *info) {
|
||||
memset(info, 0, sizeof(DateInfo));
|
||||
}
|
||||
|
||||
/*
|
||||
* Structure containing the command arguments supplied to [clock format] and [clock scan]
|
||||
*/
|
||||
|
||||
#define CLF_EXTENDED (1 << 4)
|
||||
#define CLF_STRICT (1 << 8)
|
||||
#define CLF_LOCALE_USED (1 << 15)
|
||||
|
||||
typedef struct ClockFmtScnCmdArgs {
|
||||
ClientData clientData; /* Opaque pointer to literal pool, etc. */
|
||||
Tcl_Interp *interp; /* Tcl interpreter */
|
||||
|
||||
Tcl_Obj *formatObj; /* Format */
|
||||
Tcl_Obj *localeObj; /* Name of the locale where the time will be expressed. */
|
||||
Tcl_Obj *timezoneObj; /* Default time zone in which the time will be expressed */
|
||||
Tcl_Obj *baseObj; /* Base (scan and add) or clockValue (format) */
|
||||
int flags; /* Flags control scanning */
|
||||
|
||||
Tcl_Obj *mcDictObj; /* Current dictionary of tcl::clock package for given localeObj*/
|
||||
} ClockFmtScnCmdArgs;
|
||||
|
||||
/*
|
||||
* Structure containing the client data for [clock]
|
||||
*/
|
||||
|
||||
typedef struct ClockClientData {
|
||||
size_t refCount; /* Number of live references. */
|
||||
Tcl_Obj **literals; /* Pool of object literals (common, locale independent). */
|
||||
Tcl_Obj **mcLiterals; /* Msgcat object literals with mc-keys for search with locale. */
|
||||
Tcl_Obj **mcLitIdxs; /* Msgcat object indices prefixed with _IDX_,
|
||||
* used for quick dictionary search */
|
||||
|
||||
/* Cache for current clock parameters, imparted via "configure" */
|
||||
unsigned long LastTZEpoch;
|
||||
int currentYearCentury;
|
||||
int yearOfCenturySwitch;
|
||||
Tcl_Obj *SystemTimeZone;
|
||||
Tcl_Obj *SystemSetupTZData;
|
||||
Tcl_Obj *GMTSetupTimeZone;
|
||||
Tcl_Obj *GMTSetupTZData;
|
||||
Tcl_Obj *AnySetupTimeZone;
|
||||
Tcl_Obj *AnySetupTZData;
|
||||
Tcl_Obj *LastUnnormSetupTimeZone;
|
||||
Tcl_Obj *LastSetupTimeZone;
|
||||
Tcl_Obj *LastSetupTZData;
|
||||
|
||||
Tcl_Obj *CurrentLocale;
|
||||
Tcl_Obj *CurrentLocaleDict;
|
||||
Tcl_Obj *LastUnnormUsedLocale;
|
||||
Tcl_Obj *LastUsedLocale;
|
||||
Tcl_Obj *LastUsedLocaleDict;
|
||||
|
||||
/* Cache for last base (last-second fast convert if base/tz not changed) */
|
||||
struct {
|
||||
Tcl_Obj *timezoneObj;
|
||||
TclDateFields Date;
|
||||
} lastBase;
|
||||
/* Las-period cache for fast UTC2Local conversion */
|
||||
struct {
|
||||
/* keys */
|
||||
Tcl_Obj *timezoneObj;
|
||||
int changeover;
|
||||
Tcl_WideInt seconds;
|
||||
Tcl_WideInt rangesVal[2]; /* Bounds for cached time zone offset */
|
||||
/* values */
|
||||
int tzOffset;
|
||||
Tcl_Obj *tzName;
|
||||
} UTC2Local;
|
||||
/* Las-period cache for fast Local2UTC conversion */
|
||||
struct {
|
||||
/* keys */
|
||||
Tcl_Obj *timezoneObj;
|
||||
int changeover;
|
||||
Tcl_WideInt localSeconds;
|
||||
Tcl_WideInt rangesVal[2]; /* Bounds for cached time zone offset */
|
||||
/* values */
|
||||
int tzOffset;
|
||||
} Local2UTC;
|
||||
} ClockClientData;
|
||||
|
||||
#define ClockDefaultYearCentury 2000
|
||||
#define ClockDefaultCenturySwitch 38
|
||||
|
||||
/*
|
||||
* Meridian: am, pm, or 24-hour style.
|
||||
*/
|
||||
|
||||
typedef enum _MERIDIAN {
|
||||
MERam, MERpm, MER24
|
||||
} MERIDIAN;
|
||||
|
||||
/*
|
||||
* Clock scan and format facilities.
|
||||
*/
|
||||
|
||||
#define CLOCK_FMT_SCN_STORAGE_GC_SIZE 32
|
||||
|
||||
#define CLOCK_MIN_TOK_CHAIN_BLOCK_SIZE 2
|
||||
|
||||
typedef struct ClockScanToken ClockScanToken;
|
||||
|
||||
|
||||
typedef int ClockScanTokenProc(
|
||||
ClockFmtScnCmdArgs *opts,
|
||||
DateInfo *info,
|
||||
ClockScanToken *tok);
|
||||
|
||||
|
||||
typedef enum _CLCKTOK_TYPE {
|
||||
CTOKT_DIGIT = 1, CTOKT_PARSER, CTOKT_SPACE, CTOKT_WORD, CTOKT_CHAR,
|
||||
CFMTT_INT, CFMTT_WIDE, CFMTT_PROC
|
||||
} CLCKTOK_TYPE;
|
||||
|
||||
typedef struct ClockScanTokenMap {
|
||||
unsigned short int type;
|
||||
unsigned short int flags;
|
||||
unsigned short int clearFlags;
|
||||
unsigned short int minSize;
|
||||
unsigned short int maxSize;
|
||||
unsigned short int offs;
|
||||
ClockScanTokenProc *parser;
|
||||
const void *data;
|
||||
} ClockScanTokenMap;
|
||||
|
||||
typedef struct ClockScanToken {
|
||||
ClockScanTokenMap *map;
|
||||
struct {
|
||||
const char *start;
|
||||
const char *end;
|
||||
} tokWord;
|
||||
unsigned short int endDistance;
|
||||
unsigned short int lookAhMin;
|
||||
unsigned short int lookAhMax;
|
||||
unsigned short int lookAhTok;
|
||||
} ClockScanToken;
|
||||
|
||||
|
||||
#define MIN_FMT_RESULT_BLOCK_ALLOC 200
|
||||
|
||||
typedef struct DateFormat {
|
||||
char *resMem;
|
||||
char *resEnd;
|
||||
char *output;
|
||||
|
||||
TclDateFields date;
|
||||
|
||||
Tcl_Obj *localeEra;
|
||||
} DateFormat;
|
||||
|
||||
#define CLFMT_INCR (1 << 3)
|
||||
#define CLFMT_DECR (1 << 4)
|
||||
#define CLFMT_CALC (1 << 5)
|
||||
#define CLFMT_LOCALE_INDX (1 << 8)
|
||||
|
||||
typedef struct ClockFormatToken ClockFormatToken;
|
||||
|
||||
typedef int ClockFormatTokenProc(
|
||||
ClockFmtScnCmdArgs *opts,
|
||||
DateFormat *dateFmt,
|
||||
ClockFormatToken *tok,
|
||||
int *val);
|
||||
|
||||
typedef struct ClockFormatTokenMap {
|
||||
unsigned short int type;
|
||||
const char *tostr;
|
||||
unsigned short int width;
|
||||
unsigned short int flags;
|
||||
unsigned short int divider;
|
||||
unsigned short int divmod;
|
||||
unsigned short int offs;
|
||||
ClockFormatTokenProc *fmtproc;
|
||||
void *data;
|
||||
} ClockFormatTokenMap;
|
||||
typedef struct ClockFormatToken {
|
||||
ClockFormatTokenMap *map;
|
||||
struct {
|
||||
const char *start;
|
||||
const char *end;
|
||||
} tokWord;
|
||||
} ClockFormatToken;
|
||||
|
||||
|
||||
typedef struct ClockFmtScnStorage ClockFmtScnStorage;
|
||||
|
||||
typedef struct ClockFmtScnStorage {
|
||||
int objRefCount; /* Reference count shared across threads */
|
||||
ClockScanToken *scnTok;
|
||||
unsigned int scnTokC;
|
||||
unsigned int scnSpaceCount; /* Count of mandatory spaces used in format */
|
||||
ClockFormatToken *fmtTok;
|
||||
unsigned int fmtTokC;
|
||||
#if CLOCK_FMT_SCN_STORAGE_GC_SIZE > 0
|
||||
ClockFmtScnStorage *nextPtr;
|
||||
ClockFmtScnStorage *prevPtr;
|
||||
#endif
|
||||
#if 0
|
||||
+Tcl_HashEntry hashEntry /* ClockFmtScnStorage is a derivate of Tcl_HashEntry,
|
||||
* stored by offset +sizeof(self) */
|
||||
#endif
|
||||
} ClockFmtScnStorage;
|
||||
|
||||
/*
|
||||
* Prototypes of module functions.
|
||||
*/
|
||||
|
||||
MODULE_SCOPE int ToSeconds(int Hours, int Minutes,
|
||||
int Seconds, MERIDIAN Meridian);
|
||||
MODULE_SCOPE int IsGregorianLeapYear(TclDateFields *);
|
||||
MODULE_SCOPE void
|
||||
GetJulianDayFromEraYearWeekDay(
|
||||
TclDateFields *fields, int changeover);
|
||||
MODULE_SCOPE void
|
||||
GetJulianDayFromEraYearMonthDay(
|
||||
TclDateFields *fields, int changeover);
|
||||
MODULE_SCOPE void
|
||||
GetJulianDayFromEraYearDay(
|
||||
TclDateFields *fields, int changeover);
|
||||
MODULE_SCOPE int ConvertUTCToLocal(ClientData clientData, Tcl_Interp *,
|
||||
TclDateFields *, Tcl_Obj *timezoneObj, int);
|
||||
MODULE_SCOPE Tcl_Obj *
|
||||
LookupLastTransition(Tcl_Interp *, Tcl_WideInt,
|
||||
int, Tcl_Obj *const *, Tcl_WideInt rangesVal[2]);
|
||||
|
||||
MODULE_SCOPE int TclClockFreeScan(Tcl_Interp *interp, DateInfo *info);
|
||||
|
||||
/* tclClock.c module declarations */
|
||||
|
||||
MODULE_SCOPE Tcl_Obj *
|
||||
ClockSetupTimeZone(ClientData clientData,
|
||||
Tcl_Interp *interp, Tcl_Obj *timezoneObj);
|
||||
|
||||
MODULE_SCOPE Tcl_Obj *
|
||||
ClockMCDict(ClockFmtScnCmdArgs *opts);
|
||||
MODULE_SCOPE Tcl_Obj *
|
||||
ClockMCGet(ClockFmtScnCmdArgs *opts, int mcKey);
|
||||
MODULE_SCOPE Tcl_Obj *
|
||||
ClockMCGetIdx(ClockFmtScnCmdArgs *opts, int mcKey);
|
||||
MODULE_SCOPE int ClockMCSetIdx(ClockFmtScnCmdArgs *opts, int mcKey,
|
||||
Tcl_Obj *valObj);
|
||||
|
||||
/* tclClockFmt.c module declarations */
|
||||
|
||||
MODULE_SCOPE Tcl_Obj*
|
||||
ClockFrmObjGetLocFmtKey(Tcl_Interp *interp,
|
||||
Tcl_Obj *objPtr);
|
||||
|
||||
MODULE_SCOPE ClockFmtScnStorage *
|
||||
Tcl_GetClockFrmScnFromObj(Tcl_Interp *interp,
|
||||
Tcl_Obj *objPtr);
|
||||
MODULE_SCOPE Tcl_Obj *
|
||||
ClockLocalizeFormat(ClockFmtScnCmdArgs *opts);
|
||||
|
||||
MODULE_SCOPE int ClockScan(register DateInfo *info,
|
||||
Tcl_Obj *strObj, ClockFmtScnCmdArgs *opts);
|
||||
|
||||
MODULE_SCOPE int ClockFormat(register DateFormat *dateFmt,
|
||||
ClockFmtScnCmdArgs *opts);
|
||||
|
||||
MODULE_SCOPE void ClockFrmScnClearCaches(void);
|
||||
|
||||
#endif /* _TCLCLOCK_H */
|
||||
+19
-10
@@ -23,6 +23,15 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(BUILD_tcl)
|
||||
# define TCL_DEPRECATED(msg) EXTERN TCL_DEPRECATED_API(msg)
|
||||
#elif defined(TCL_NO_DEPRECATED)
|
||||
# define TCL_DEPRECATED(msg) MODULE_SCOPE
|
||||
#else
|
||||
# define TCL_DEPRECATED(msg) EXTERN
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* WARNING: This file is automatically generated by the tools/genStubs.tcl
|
||||
* script. Any modifications to the function declarations below should be made
|
||||
@@ -950,13 +959,13 @@ EXTERN void Tcl_ThreadAlert(Tcl_ThreadId threadId);
|
||||
EXTERN void Tcl_ThreadQueueEvent(Tcl_ThreadId threadId,
|
||||
Tcl_Event *evPtr, Tcl_QueuePosition position);
|
||||
/* 320 */
|
||||
EXTERN Tcl_UniChar Tcl_UniCharAtIndex(const char *src, int index);
|
||||
EXTERN int Tcl_UniCharAtIndex(const char *src, int index);
|
||||
/* 321 */
|
||||
EXTERN Tcl_UniChar Tcl_UniCharToLower(int ch);
|
||||
EXTERN int Tcl_UniCharToLower(int ch);
|
||||
/* 322 */
|
||||
EXTERN Tcl_UniChar Tcl_UniCharToTitle(int ch);
|
||||
EXTERN int Tcl_UniCharToTitle(int ch);
|
||||
/* 323 */
|
||||
EXTERN Tcl_UniChar Tcl_UniCharToUpper(int ch);
|
||||
EXTERN int Tcl_UniCharToUpper(int ch);
|
||||
/* 324 */
|
||||
EXTERN int Tcl_UniCharToUtf(int ch, char *buf);
|
||||
/* 325 */
|
||||
@@ -1108,7 +1117,7 @@ EXTERN void Tcl_SetUnicodeObj(Tcl_Obj *objPtr,
|
||||
/* 380 */
|
||||
EXTERN int Tcl_GetCharLength(Tcl_Obj *objPtr);
|
||||
/* 381 */
|
||||
EXTERN Tcl_UniChar Tcl_GetUniChar(Tcl_Obj *objPtr, int index);
|
||||
EXTERN int Tcl_GetUniChar(Tcl_Obj *objPtr, int index);
|
||||
/* 382 */
|
||||
EXTERN Tcl_UniChar * Tcl_GetUnicode(Tcl_Obj *objPtr);
|
||||
/* 383 */
|
||||
@@ -2177,10 +2186,10 @@ typedef struct TclStubs {
|
||||
Tcl_Obj * (*tcl_SetVar2Ex) (Tcl_Interp *interp, const char *part1, const char *part2, Tcl_Obj *newValuePtr, int flags); /* 317 */
|
||||
void (*tcl_ThreadAlert) (Tcl_ThreadId threadId); /* 318 */
|
||||
void (*tcl_ThreadQueueEvent) (Tcl_ThreadId threadId, Tcl_Event *evPtr, Tcl_QueuePosition position); /* 319 */
|
||||
Tcl_UniChar (*tcl_UniCharAtIndex) (const char *src, int index); /* 320 */
|
||||
Tcl_UniChar (*tcl_UniCharToLower) (int ch); /* 321 */
|
||||
Tcl_UniChar (*tcl_UniCharToTitle) (int ch); /* 322 */
|
||||
Tcl_UniChar (*tcl_UniCharToUpper) (int ch); /* 323 */
|
||||
int (*tcl_UniCharAtIndex) (const char *src, int index); /* 320 */
|
||||
int (*tcl_UniCharToLower) (int ch); /* 321 */
|
||||
int (*tcl_UniCharToTitle) (int ch); /* 322 */
|
||||
int (*tcl_UniCharToUpper) (int ch); /* 323 */
|
||||
int (*tcl_UniCharToUtf) (int ch, char *buf); /* 324 */
|
||||
CONST84_RETURN char * (*tcl_UtfAtIndex) (const char *src, int index); /* 325 */
|
||||
int (*tcl_UtfCharComplete) (const char *src, int length); /* 326 */
|
||||
@@ -2238,7 +2247,7 @@ typedef struct TclStubs {
|
||||
Tcl_Obj * (*tcl_NewUnicodeObj) (const Tcl_UniChar *unicode, int numChars); /* 378 */
|
||||
void (*tcl_SetUnicodeObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int numChars); /* 379 */
|
||||
int (*tcl_GetCharLength) (Tcl_Obj *objPtr); /* 380 */
|
||||
Tcl_UniChar (*tcl_GetUniChar) (Tcl_Obj *objPtr, int index); /* 381 */
|
||||
int (*tcl_GetUniChar) (Tcl_Obj *objPtr, int index); /* 381 */
|
||||
Tcl_UniChar * (*tcl_GetUnicode) (Tcl_Obj *objPtr); /* 382 */
|
||||
Tcl_Obj * (*tcl_GetRange) (Tcl_Obj *objPtr, int first, int last); /* 383 */
|
||||
void (*tcl_AppendUnicodeToObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int length); /* 384 */
|
||||
|
||||
+46
-33
@@ -2293,8 +2293,11 @@ UtfToUtfProc(
|
||||
const char *srcStart, *srcEnd, *srcClose;
|
||||
const char *dstStart, *dstEnd;
|
||||
int result, numChars, charLimit = INT_MAX;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar *chPtr = (Tcl_UniChar *) statePtr;
|
||||
|
||||
if (flags & TCL_ENCODING_START) {
|
||||
*statePtr = 0;
|
||||
}
|
||||
result = TCL_OK;
|
||||
|
||||
srcStart = src;
|
||||
@@ -2326,7 +2329,7 @@ UtfToUtfProc(
|
||||
}
|
||||
if (UCHAR(*src) < 0x80 && !(UCHAR(*src) == 0 && pureNullMode == 0)) {
|
||||
/*
|
||||
* Copy 7bit chatacters, but skip null-bytes when we are in input
|
||||
* Copy 7bit characters, but skip null-bytes when we are in input
|
||||
* mode, so that they get converted to 0xc080.
|
||||
*/
|
||||
|
||||
@@ -2342,16 +2345,18 @@ UtfToUtfProc(
|
||||
} else if (!Tcl_UtfCharComplete(src, srcEnd - src)) {
|
||||
/*
|
||||
* Always check before using TclUtfToUniChar. Not doing can so
|
||||
* cause it run beyond the endof the buffer! If we happen such an
|
||||
* incomplete char its byts are made to represent themselves.
|
||||
* cause it run beyond the end of the buffer! If we happen such an
|
||||
* incomplete char its bytes are made to represent themselves.
|
||||
*/
|
||||
|
||||
ch = (unsigned char) *src;
|
||||
*chPtr = (unsigned char) *src;
|
||||
src += 1;
|
||||
dst += Tcl_UniCharToUtf(ch, dst);
|
||||
dst += Tcl_UniCharToUtf(*chPtr, dst);
|
||||
} else {
|
||||
src += TclUtfToUniChar(src, &ch);
|
||||
dst += Tcl_UniCharToUtf(ch, dst);
|
||||
int n = TclUtfToUniChar(src, chPtr);
|
||||
src += n;
|
||||
if (!n) numChars--;
|
||||
dst += Tcl_UniCharToUtf(*chPtr, dst);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2407,8 +2412,11 @@ UnicodeToUtfProc(
|
||||
const char *srcStart, *srcEnd;
|
||||
const char *dstEnd, *dstStart;
|
||||
int result, numChars, charLimit = INT_MAX;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar *chPtr = (Tcl_UniChar *) statePtr;
|
||||
|
||||
if (flags & TCL_ENCODING_START) {
|
||||
*statePtr = 0;
|
||||
}
|
||||
if (flags & TCL_ENCODING_CHAR_LIMIT) {
|
||||
charLimit = *dstCharsPtr;
|
||||
}
|
||||
@@ -2436,11 +2444,13 @@ UnicodeToUtfProc(
|
||||
* Tcl_UniChar-size data.
|
||||
*/
|
||||
|
||||
ch = *(Tcl_UniChar *)src;
|
||||
if (ch && ch < 0x80) {
|
||||
*dst++ = (ch & 0xFF);
|
||||
*chPtr = *(Tcl_UniChar *)src;
|
||||
if (*chPtr && *chPtr < 0x80) {
|
||||
*dst++ = (*chPtr & 0xFF);
|
||||
} else {
|
||||
dst += Tcl_UniCharToUtf(ch, dst);
|
||||
int n = Tcl_UniCharToUtf(*chPtr, dst);
|
||||
dst += n;
|
||||
if (!n) --numChars;/* Don't count high surrogates */
|
||||
}
|
||||
src += sizeof(Tcl_UniChar);
|
||||
}
|
||||
@@ -2497,8 +2507,11 @@ UtfToUnicodeProc(
|
||||
{
|
||||
const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd;
|
||||
int result, numChars;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar *chPtr = (Tcl_UniChar *) statePtr;
|
||||
|
||||
if (flags & TCL_ENCODING_START) {
|
||||
*statePtr = 0;
|
||||
}
|
||||
srcStart = src;
|
||||
srcEnd = src + srcLen;
|
||||
srcClose = srcEnd;
|
||||
@@ -2524,7 +2537,7 @@ UtfToUnicodeProc(
|
||||
result = TCL_CONVERT_NOSPACE;
|
||||
break;
|
||||
}
|
||||
src += TclUtfToUniChar(src, &ch);
|
||||
src += TclUtfToUniChar(src, chPtr);
|
||||
|
||||
/*
|
||||
* Need to handle this in a way that won't cause misalignment by
|
||||
@@ -2533,23 +2546,23 @@ UtfToUnicodeProc(
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#if TCL_UTF_MAX > 4
|
||||
*dst++ = (ch >> 24);
|
||||
*dst++ = ((ch >> 16) & 0xFF);
|
||||
*dst++ = ((ch >> 8) & 0xFF);
|
||||
*dst++ = (ch & 0xFF);
|
||||
*dst++ = (*chPtr >> 24);
|
||||
*dst++ = ((*chPtr >> 16) & 0xFF);
|
||||
*dst++ = ((*chPtr >> 8) & 0xFF);
|
||||
*dst++ = (*chPtr & 0xFF);
|
||||
#else
|
||||
*dst++ = (ch >> 8);
|
||||
*dst++ = (ch & 0xFF);
|
||||
*dst++ = (*chPtr >> 8);
|
||||
*dst++ = (*chPtr & 0xFF);
|
||||
#endif
|
||||
#else
|
||||
#if TCL_UTF_MAX > 4
|
||||
*dst++ = (ch & 0xFF);
|
||||
*dst++ = ((ch >> 8) & 0xFF);
|
||||
*dst++ = ((ch >> 16) & 0xFF);
|
||||
*dst++ = (ch >> 24);
|
||||
*dst++ = (*chPtr & 0xFF);
|
||||
*dst++ = ((*chPtr >> 8) & 0xFF);
|
||||
*dst++ = ((*chPtr >> 16) & 0xFF);
|
||||
*dst++ = (*chPtr >> 24);
|
||||
#else
|
||||
*dst++ = (ch & 0xFF);
|
||||
*dst++ = (ch >> 8);
|
||||
*dst++ = (*chPtr & 0xFF);
|
||||
*dst++ = (*chPtr >> 8);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -2607,7 +2620,7 @@ TableToUtfProc(
|
||||
const char *srcStart, *srcEnd;
|
||||
const char *dstEnd, *dstStart, *prefixBytes;
|
||||
int result, byte, numChars, charLimit = INT_MAX;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
const unsigned short *const *toUnicode;
|
||||
const unsigned short *pageZero;
|
||||
TableEncodingData *dataPtr = clientData;
|
||||
@@ -2719,7 +2732,7 @@ TableFromUtfProc(
|
||||
{
|
||||
const char *srcStart, *srcEnd, *srcClose;
|
||||
const char *dstStart, *dstEnd, *prefixBytes;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
int result, len, word, numChars;
|
||||
TableEncodingData *dataPtr = clientData;
|
||||
const unsigned short *const *fromUnicode;
|
||||
@@ -2853,7 +2866,7 @@ Iso88591ToUtfProc(
|
||||
|
||||
result = TCL_OK;
|
||||
for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
|
||||
if (dst > dstEnd) {
|
||||
result = TCL_CONVERT_NOSPACE;
|
||||
@@ -2939,7 +2952,7 @@ Iso88591FromUtfProc(
|
||||
dstEnd = dst + dstLen - 1;
|
||||
|
||||
for (numChars = 0; src < srcEnd; numChars++) {
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
int len;
|
||||
|
||||
if ((src > srcClose) && (!Tcl_UtfCharComplete(src, srcEnd - src))) {
|
||||
@@ -3326,7 +3339,7 @@ EscapeFromUtfProc(
|
||||
for (numChars = 0; src < srcEnd; numChars++) {
|
||||
unsigned len;
|
||||
int word;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
|
||||
if ((src > srcClose) && (!Tcl_UtfCharComplete(src, srcEnd - src))) {
|
||||
/*
|
||||
@@ -3371,7 +3384,7 @@ EscapeFromUtfProc(
|
||||
|
||||
/*
|
||||
* The state variable has the value of oldState when word is 0.
|
||||
* In this case, the escape sequense should not be copied to dst
|
||||
* In this case, the escape sequence should not be copied to dst
|
||||
* because the current character set is not changed.
|
||||
*/
|
||||
|
||||
|
||||
@@ -5447,7 +5447,7 @@ TEBCresume(
|
||||
valuePtr->bytes+index, 1);
|
||||
} else {
|
||||
char buf[TCL_UTF_MAX];
|
||||
Tcl_UniChar ch = Tcl_GetUniChar(valuePtr, index);
|
||||
int ch = Tcl_GetUniChar(valuePtr, index);
|
||||
|
||||
/*
|
||||
* This could be: Tcl_NewUnicodeObj((const Tcl_UniChar *)&ch, 1)
|
||||
@@ -8218,7 +8218,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
* Arguments are opposite sign; remainder is sum.
|
||||
*/
|
||||
|
||||
TclBNInitBignumFromWideInt(&big1, w1);
|
||||
TclInitBignumFromWideInt(&big1, w1);
|
||||
mp_add(&big2, &big1, &big2);
|
||||
mp_clear(&big1);
|
||||
BIG_RESULT(&big2);
|
||||
@@ -9184,7 +9184,7 @@ ExecuteExtendedUnaryMathOp(
|
||||
if (w != LLONG_MIN) {
|
||||
WIDE_RESULT(-w);
|
||||
}
|
||||
TclBNInitBignumFromLong(&big, *(const long *) ptr);
|
||||
TclInitBignumFromLong(&big, *(const long *) ptr);
|
||||
break;
|
||||
#ifndef TCL_WIDE_INT_IS_LONG
|
||||
case TCL_NUMBER_WIDE:
|
||||
@@ -9192,7 +9192,7 @@ ExecuteExtendedUnaryMathOp(
|
||||
if (w != LLONG_MIN) {
|
||||
WIDE_RESULT(-w);
|
||||
}
|
||||
TclBNInitBignumFromWideInt(&big, w);
|
||||
TclInitBignumFromWideInt(&big, w);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
||||
@@ -45,19 +45,6 @@ static Tcl_HashEntry * AllocArrayEntry(Tcl_HashTable *tablePtr, void *keyPtr);
|
||||
static int CompareArrayKeys(void *keyPtr, Tcl_HashEntry *hPtr);
|
||||
static TCL_HASH_TYPE HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr);
|
||||
|
||||
/*
|
||||
* Prototypes for the one word hash key methods. Not actually declared because
|
||||
* this is a critical path that is implemented in the core hash table access
|
||||
* function.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
static Tcl_HashEntry * AllocOneWordEntry(Tcl_HashTable *tablePtr,
|
||||
void *keyPtr);
|
||||
static int CompareOneWordKeys(void *keyPtr, Tcl_HashEntry *hPtr);
|
||||
static unsigned int HashOneWordKey(Tcl_HashTable *tablePtr, void *keyPtr);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Prototypes for the string hash key methods.
|
||||
*/
|
||||
|
||||
@@ -41,6 +41,8 @@ static void ReflectWatch(ClientData clientData, int mask);
|
||||
static int ReflectBlock(ClientData clientData, int mode);
|
||||
#ifdef TCL_THREADS
|
||||
static void ReflectThread(ClientData clientData, int action);
|
||||
static int ReflectEventRun(Tcl_Event *ev, int flags);
|
||||
static int ReflectEventDelete(Tcl_Event *ev, ClientData cd);
|
||||
#endif
|
||||
static Tcl_WideInt ReflectSeekWide(ClientData clientData,
|
||||
Tcl_WideInt offset, int mode, int *errorCodePtr);
|
||||
@@ -748,6 +750,7 @@ TclChanCreateObjCmd(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef TCL_THREADS
|
||||
typedef struct {
|
||||
Tcl_Event header;
|
||||
ReflectedChannel *rcPtr;
|
||||
@@ -791,6 +794,7 @@ ReflectEventDelete(
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
TclChanPostEventObjCmd(
|
||||
|
||||
+2
-2
@@ -1764,7 +1764,7 @@ Tcl_FSEvalFileEx(
|
||||
* this cross-platform to allow for scripted documents. [Bug: 2040]
|
||||
*/
|
||||
|
||||
Tcl_SetChannelOption(interp, chan, "-eofchar", "\32");
|
||||
Tcl_SetChannelOption(interp, chan, "-eofchar", "\32 {}");
|
||||
|
||||
/*
|
||||
* If the encoding is specified, set it for the channel. Else don't touch
|
||||
@@ -1899,7 +1899,7 @@ TclNREvalFile(
|
||||
* this cross-platform to allow for scripted documents. [Bug: 2040]
|
||||
*/
|
||||
|
||||
Tcl_SetChannelOption(interp, chan, "-eofchar", "\32");
|
||||
Tcl_SetChannelOption(interp, chan, "-eofchar", "\32 {}");
|
||||
|
||||
/*
|
||||
* If the encoding is specified, set it for the channel. Else don't touch
|
||||
|
||||
+4
-1
@@ -3007,6 +3007,9 @@ MODULE_SCOPE int TclInfoLocalsCmd(ClientData dummy, Tcl_Interp *interp,
|
||||
MODULE_SCOPE int TclInfoVarsCmd(ClientData dummy, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *const objv[]);
|
||||
MODULE_SCOPE void TclInitAlloc(void);
|
||||
MODULE_SCOPE void TclInitBignumFromLong(mp_int *, long);
|
||||
MODULE_SCOPE void TclInitBignumFromWideInt(mp_int *, Tcl_WideInt);
|
||||
MODULE_SCOPE void TclInitBignumFromWideUInt(mp_int *, Tcl_WideUInt);
|
||||
MODULE_SCOPE void TclInitDbCkalloc(void);
|
||||
MODULE_SCOPE void TclInitDoubleConversion(void);
|
||||
MODULE_SCOPE void TclInitEmbeddedConfigurationInformation(
|
||||
@@ -4408,7 +4411,7 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
|
||||
|
||||
#define TclUtfToUniChar(str, chPtr) \
|
||||
((((unsigned char) *(str)) < 0xC0) ? \
|
||||
((*(chPtr) = (Tcl_UniChar) *(str)), 1) \
|
||||
((*(chPtr) = (unsigned char) *(str)), 1) \
|
||||
: Tcl_UtfToUniChar(str, chPtr))
|
||||
|
||||
/*
|
||||
|
||||
+2
-2
@@ -692,7 +692,7 @@ SetInvalidRealFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr) {
|
||||
/*
|
||||
* This function checks for integer representations, which are valid
|
||||
* when linking with C variables, but which are invalid in other
|
||||
* contexts in Tcl. Handled are "+", "-", "", "0x", "0b" and "0o"
|
||||
* contexts in Tcl. Handled are "+", "-", "", "0x", "0b", "0d" and "0o"
|
||||
* (upperand lowercase). See bug [39f6304c2e].
|
||||
*/
|
||||
int
|
||||
@@ -701,7 +701,7 @@ GetInvalidIntFromObj(Tcl_Obj *objPtr, int *intPtr)
|
||||
const char *str = TclGetString(objPtr);
|
||||
|
||||
if ((objPtr->length == 0) ||
|
||||
((objPtr->length == 2) && (str[0] == '0') && strchr("xXbBoO", str[1]))) {
|
||||
((objPtr->length == 2) && (str[0] == '0') && strchr("xXbBoOdD", str[1]))) {
|
||||
*intPtr = 0;
|
||||
return TCL_OK;
|
||||
} else if ((objPtr->length == 1) && strchr("+-", str[0])) {
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ Tcl_LoadObjCmd(
|
||||
Tcl_PackageInitProc *initProc;
|
||||
const char *p, *fullFileName, *packageName;
|
||||
Tcl_LoadHandle loadHandle;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
unsigned len;
|
||||
int index, flags = 0;
|
||||
Tcl_Obj *const *savedobjv = objv;
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
* win/tclooConfig.sh
|
||||
*/
|
||||
|
||||
#define TCLOO_VERSION "1.0.4"
|
||||
#define TCLOO_VERSION "1.2.0"
|
||||
#define TCLOO_PATCHLEVEL TCLOO_VERSION
|
||||
|
||||
#include "tcl.h"
|
||||
|
||||
+27
-5
@@ -1183,8 +1183,9 @@ TclOOCopyObjectCmd(
|
||||
{
|
||||
Tcl_Object oPtr, o2Ptr;
|
||||
|
||||
if (objc < 2 || objc > 3) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "sourceName ?targetName?");
|
||||
if (objc < 2 || objc > 4) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv,
|
||||
"sourceName ?targetName? ?targetNamespace?");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
@@ -1204,12 +1205,14 @@ TclOOCopyObjectCmd(
|
||||
if (objc == 2) {
|
||||
o2Ptr = Tcl_CopyObjectInstance(interp, oPtr, NULL, NULL);
|
||||
} else {
|
||||
const char *name;
|
||||
const char *name, *namespaceName;
|
||||
Tcl_DString buffer;
|
||||
|
||||
name = TclGetString(objv[2]);
|
||||
Tcl_DStringInit(&buffer);
|
||||
if (name[0]!=':' || name[1]!=':') {
|
||||
if (name[0] == '\0') {
|
||||
name = NULL;
|
||||
} else if (name[0]!=':' || name[1]!=':') {
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
|
||||
if (iPtr->varFramePtr != NULL) {
|
||||
@@ -1220,7 +1223,26 @@ TclOOCopyObjectCmd(
|
||||
Tcl_DStringAppend(&buffer, name, -1);
|
||||
name = Tcl_DStringValue(&buffer);
|
||||
}
|
||||
o2Ptr = Tcl_CopyObjectInstance(interp, oPtr, name, NULL);
|
||||
|
||||
/*
|
||||
* Choose a unique namespace name if the user didn't supply one.
|
||||
*/
|
||||
|
||||
namespaceName = NULL;
|
||||
if (objc == 4) {
|
||||
namespaceName = TclGetString(objv[3]);
|
||||
|
||||
if (namespaceName[0] == '\0') {
|
||||
namespaceName = NULL;
|
||||
} else if (Tcl_FindNamespace(interp, namespaceName, NULL,
|
||||
0) != NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"%s refers to an existing namespace", namespaceName));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
o2Ptr = Tcl_CopyObjectInstance(interp, oPtr, name, namespaceName);
|
||||
Tcl_DStringFree(&buffer);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -3038,7 +3038,7 @@ Tcl_SetWideIntObj(
|
||||
#else
|
||||
mp_int big;
|
||||
|
||||
TclBNInitBignumFromWideInt(&big, wideValue);
|
||||
TclInitBignumFromWideInt(&big, wideValue);
|
||||
Tcl_SetBignumObj(objPtr, &big);
|
||||
#endif
|
||||
}
|
||||
@@ -3402,12 +3402,12 @@ GetBignumFromObj(
|
||||
return TCL_OK;
|
||||
}
|
||||
if (objPtr->typePtr == &tclIntType) {
|
||||
TclBNInitBignumFromLong(bignumValue, objPtr->internalRep.longValue);
|
||||
TclInitBignumFromLong(bignumValue, objPtr->internalRep.longValue);
|
||||
return TCL_OK;
|
||||
}
|
||||
#ifndef TCL_WIDE_INT_IS_LONG
|
||||
if (objPtr->typePtr == &tclWideIntType) {
|
||||
TclBNInitBignumFromWideInt(bignumValue,
|
||||
TclInitBignumFromWideInt(bignumValue,
|
||||
objPtr->internalRep.wideValue);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ Tcl_PanicVA(
|
||||
__builtin_trap();
|
||||
# elif defined(_WIN64)
|
||||
__debugbreak();
|
||||
# elif defined(_MSC_VER)
|
||||
# elif defined(_MSC_VER) && defined (_M_IX86)
|
||||
_asm {int 3}
|
||||
# else
|
||||
DebugBreak();
|
||||
|
||||
+10
-1
@@ -829,7 +829,7 @@ TclParseBackslash(
|
||||
* written there. */
|
||||
{
|
||||
register const char *p = src+1;
|
||||
Tcl_UniChar unichar;
|
||||
Tcl_UniChar unichar = 0;
|
||||
int result;
|
||||
int count;
|
||||
char buf[TCL_UTF_MAX];
|
||||
@@ -979,6 +979,15 @@ TclParseBackslash(
|
||||
if (readPtr != NULL) {
|
||||
*readPtr = count;
|
||||
}
|
||||
if ((result & 0xF800) == 0xD800) {
|
||||
/* If result is a surrogate, Tcl_UniCharToUtf will try to
|
||||
* handle that especially, but we don't want that here.
|
||||
*/
|
||||
dst[2] = (char) ((result | 0x80) & 0xBF);
|
||||
dst[1] = (char) (((result >> 6) | 0x80) & 0xBF);
|
||||
dst[0] = (char) ((result >> 12) | 0xE0);
|
||||
return 3;
|
||||
}
|
||||
return Tcl_UniCharToUtf(result, dst);
|
||||
}
|
||||
|
||||
|
||||
+31
-33
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "tclInt.h"
|
||||
#include "tclFileSystem.h"
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* Prototypes for functions defined later in this file.
|
||||
@@ -849,18 +850,20 @@ TclJoinPath(
|
||||
int elements,
|
||||
Tcl_Obj * const objv[])
|
||||
{
|
||||
Tcl_Obj *res;
|
||||
Tcl_Obj *res = NULL;
|
||||
int i;
|
||||
const Tcl_Filesystem *fsPtr = NULL;
|
||||
|
||||
res = NULL;
|
||||
assert ( elements >= 0 );
|
||||
|
||||
for (i = 0; i < elements; i++) {
|
||||
int driveNameLength, strEltLen, length;
|
||||
Tcl_PathType type;
|
||||
char *strElt, *ptr;
|
||||
Tcl_Obj *driveName = NULL;
|
||||
Tcl_Obj *elt = objv[i];
|
||||
if (elements == 0) {
|
||||
return Tcl_NewObj();
|
||||
}
|
||||
|
||||
assert ( elements > 0 );
|
||||
|
||||
if (elements == 2) {
|
||||
Tcl_Obj *elt = objv[0];
|
||||
|
||||
/*
|
||||
* This is a special case where we can be much more efficient, where
|
||||
@@ -869,18 +872,17 @@ TclJoinPath(
|
||||
* object which can be normalized more efficiently. Currently we only
|
||||
* use the special case when we have exactly two elements, but we
|
||||
* could expand that in the future.
|
||||
*
|
||||
* Bugfix [a47641a0]. TclNewFSPathObj requires first argument
|
||||
* to be an absolute path. Added a check for that elt is absolute.
|
||||
*
|
||||
* Bugfix [a47641a0]. TclNewFSPathObj requires first argument
|
||||
* to be an absolute path. Added a check for that elt is absolute.
|
||||
*/
|
||||
|
||||
if ((i == (elements-2)) && (i == 0)
|
||||
&& (elt->typePtr == &tclFsPathType)
|
||||
if ((elt->typePtr == &tclFsPathType)
|
||||
&& !((elt->bytes != NULL) && (elt->bytes[0] == '\0'))
|
||||
&& TclGetPathType(elt, NULL, NULL, NULL) == TCL_PATH_ABSOLUTE) {
|
||||
Tcl_Obj *tailObj = objv[i+1];
|
||||
Tcl_Obj *tailObj = objv[1];
|
||||
Tcl_PathType type = TclGetPathType(tailObj, NULL, NULL, NULL);
|
||||
|
||||
type = TclGetPathType(tailObj, NULL, NULL, NULL);
|
||||
if (type == TCL_PATH_RELATIVE) {
|
||||
const char *str;
|
||||
int len;
|
||||
@@ -893,9 +895,6 @@ TclJoinPath(
|
||||
* the base itself is just fine!
|
||||
*/
|
||||
|
||||
if (res != NULL) {
|
||||
TclDecrRefCount(res);
|
||||
}
|
||||
return elt;
|
||||
}
|
||||
|
||||
@@ -918,9 +917,6 @@ TclJoinPath(
|
||||
|
||||
if ((tclPlatform != TCL_PLATFORM_WINDOWS)
|
||||
|| (strchr(Tcl_GetString(elt), '\\') == NULL)) {
|
||||
if (res != NULL) {
|
||||
TclDecrRefCount(res);
|
||||
}
|
||||
|
||||
if (PATHFLAGS(elt)) {
|
||||
return TclNewFSPathObj(elt, str, len);
|
||||
@@ -940,23 +936,28 @@ TclJoinPath(
|
||||
* more general code below handle things.
|
||||
*/
|
||||
} else if (tclPlatform == TCL_PLATFORM_UNIX) {
|
||||
if (res != NULL) {
|
||||
TclDecrRefCount(res);
|
||||
}
|
||||
return tailObj;
|
||||
} else {
|
||||
const char *str = TclGetString(tailObj);
|
||||
|
||||
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
|
||||
if (strchr(str, '\\') == NULL) {
|
||||
if (res != NULL) {
|
||||
TclDecrRefCount(res);
|
||||
}
|
||||
return tailObj;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert ( res == NULL );
|
||||
|
||||
for (i = 0; i < elements; i++) {
|
||||
int driveNameLength, strEltLen, length;
|
||||
Tcl_PathType type;
|
||||
char *strElt, *ptr;
|
||||
Tcl_Obj *driveName = NULL;
|
||||
Tcl_Obj *elt = objv[i];
|
||||
|
||||
strElt = TclGetStringFromObj(elt, &strEltLen);
|
||||
driveNameLength = 0;
|
||||
type = TclGetPathType(elt, &fsPtr, &driveNameLength, &driveName);
|
||||
@@ -1051,10 +1052,8 @@ TclJoinPath(
|
||||
noQuickReturn:
|
||||
if (res == NULL) {
|
||||
res = Tcl_NewObj();
|
||||
ptr = TclGetStringFromObj(res, &length);
|
||||
} else {
|
||||
ptr = TclGetStringFromObj(res, &length);
|
||||
}
|
||||
ptr = TclGetStringFromObj(res, &length);
|
||||
|
||||
/*
|
||||
* Strip off any './' before a tilde, unless this is the beginning of
|
||||
@@ -1087,6 +1086,7 @@ TclJoinPath(
|
||||
|
||||
if (sep != NULL) {
|
||||
separator = TclGetString(sep)[0];
|
||||
TclDecrRefCount(sep);
|
||||
}
|
||||
/* Safety check in case the VFS driver caused sharing */
|
||||
if (Tcl_IsShared(res)) {
|
||||
@@ -1122,9 +1122,7 @@ TclJoinPath(
|
||||
Tcl_SetObjLength(res, length);
|
||||
}
|
||||
}
|
||||
if (res == NULL) {
|
||||
res = Tcl_NewObj();
|
||||
}
|
||||
assert ( res != NULL );
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -668,7 +668,13 @@ TclCreatePipeline(
|
||||
if (*p == '>') {
|
||||
p++;
|
||||
atOK = 0;
|
||||
flags = O_WRONLY | O_CREAT;
|
||||
|
||||
/*
|
||||
* Note that the O_APPEND flag only has an effect on POSIX
|
||||
* platforms. On Windows, we just have to carry on regardless.
|
||||
*/
|
||||
|
||||
flags = O_WRONLY | O_CREAT | O_APPEND;
|
||||
}
|
||||
if (errorClose != 0) {
|
||||
errorClose = 0;
|
||||
|
||||
+5
-12
@@ -331,8 +331,8 @@ Tcl_PkgRequireEx(
|
||||
*
|
||||
* Second, how does this work? If we reach this point, then the global
|
||||
* variable tclEmptyStringRep has the value NULL. Compare that with
|
||||
* the definition of tclEmptyStringRep near the top of the file
|
||||
* generic/tclObj.c. It clearly should not have the value NULL; it
|
||||
* the definition of tclEmptyStringRep near the top of this file.
|
||||
* It clearly should not have the value NULL; it
|
||||
* should point to the char tclEmptyString. If we see it having the
|
||||
* value NULL, then somehow we are seeing a Tcl library that isn't
|
||||
* completely initialized, and that's an indicator for the error
|
||||
@@ -348,18 +348,11 @@ Tcl_PkgRequireEx(
|
||||
* After all, two Tcl libraries can't be a good thing!)
|
||||
*
|
||||
* Trouble is that's going to be tricky. We're now using a Tcl library
|
||||
* that's not fully initialized. In particular, it doesn't have a
|
||||
* proper value for tclEmptyStringRep. The Tcl_Obj system heavily
|
||||
* depends on the value of tclEmptyStringRep and all of Tcl depends
|
||||
* (increasingly) on the Tcl_Obj system, we need to correct that flaw
|
||||
* before making the calls to set the interpreter result to the error
|
||||
* message. That's the only flaw corrected; other problems with
|
||||
* initialization of the Tcl library are not remedied, so be very
|
||||
* careful about adding any other calls here without checking how they
|
||||
* behave when initialization is incomplete.
|
||||
* that's not fully initialized. Functions in it may not work
|
||||
* reliably, so be very careful about adding any other calls here
|
||||
* without checking how they behave when initialization is incomplete.
|
||||
*/
|
||||
|
||||
tclEmptyStringRep = &tclEmptyString;
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"Cannot load package \"%s\" in standalone executable:"
|
||||
" This package is not compiled with stub support", name));
|
||||
|
||||
+11
-5
@@ -72,7 +72,7 @@ BuildCharSet(
|
||||
CharSet *cset,
|
||||
const char *format) /* Points to first char of set. */
|
||||
{
|
||||
Tcl_UniChar ch, start;
|
||||
Tcl_UniChar ch = 0, start;
|
||||
int offset, nranges;
|
||||
const char *end;
|
||||
|
||||
@@ -257,7 +257,7 @@ ValidateFormat(
|
||||
{
|
||||
int gotXpg, gotSequential, value, i, flags;
|
||||
char *end;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
int objIndex, xpgSize, nspace = numVars;
|
||||
int *nassign = TclStackAlloc(interp, nspace * sizeof(int));
|
||||
char buf[TCL_UTF_MAX+1];
|
||||
@@ -582,7 +582,7 @@ Tcl_ScanObjCmd(
|
||||
char op = 0;
|
||||
int width, underflow = 0;
|
||||
Tcl_WideInt wideValue;
|
||||
Tcl_UniChar ch, sch;
|
||||
Tcl_UniChar ch = 0, sch = 0;
|
||||
Tcl_Obj **objs = NULL, *objPtr = NULL;
|
||||
int flags;
|
||||
char buf[513]; /* Temporary buffer to hold scanned number
|
||||
@@ -885,9 +885,15 @@ Tcl_ScanObjCmd(
|
||||
* Scan a single Unicode character.
|
||||
*/
|
||||
|
||||
string += TclUtfToUniChar(string, &sch);
|
||||
offset = TclUtfToUniChar(string, &sch);
|
||||
i = (int)sch;
|
||||
if (!offset) {
|
||||
offset = Tcl_UtfToUniChar(string, &sch);
|
||||
i = (((i<<10) & 0x0FFC00) + 0x10000) + (sch & 0x3FF);
|
||||
}
|
||||
string += offset;
|
||||
if (!(flags & SCAN_SUPPRESS)) {
|
||||
objPtr = Tcl_NewIntObj((int)sch);
|
||||
objPtr = Tcl_NewIntObj(i);
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
CLANG_ASSERT(objs);
|
||||
objs[objIndex++] = objPtr;
|
||||
|
||||
@@ -0,0 +1,527 @@
|
||||
/*
|
||||
* tclStrIdxTree.c --
|
||||
*
|
||||
* Contains the routines for managing string index tries in Tcl.
|
||||
*
|
||||
* This code is back-ported from the tclSE engine, by Serg G. Brester.
|
||||
*
|
||||
* Copyright (c) 2016 by Sergey G. Brester aka sebres. All rights reserved.
|
||||
*
|
||||
* See the file "license.terms" for information on usage and redistribution of
|
||||
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
*
|
||||
* -----------------------------------------------------------------------
|
||||
*
|
||||
* String index tries are prepaired structures used for fast greedy search of the string
|
||||
* (index) by unique string prefix as key.
|
||||
*
|
||||
* Index tree build for two lists together can be explained in the following datagram
|
||||
*
|
||||
* Lists:
|
||||
*
|
||||
* {Januar Februar Maerz April Mai Juni Juli August September Oktober November Dezember}
|
||||
* {Jnr Fbr Mrz Apr Mai Jni Jli Agt Spt Okt Nvb Dzb}
|
||||
*
|
||||
* Index-Tree:
|
||||
*
|
||||
* j 0 * ...
|
||||
* anuar 1 *
|
||||
* u 0 * a 0
|
||||
* ni 6 * pril 4
|
||||
* li 7 * ugust 8
|
||||
* n 0 * gt 8
|
||||
* r 1 * s 9
|
||||
* i 6 * eptember 9
|
||||
* li 7 * pt 9
|
||||
* f 2 * oktober 10
|
||||
* ebruar 2 * n 11
|
||||
* br 2 * ovember 11
|
||||
* m 0 * vb 11
|
||||
* a 0 * d 12
|
||||
* erz 3 * ezember 12
|
||||
* i 5 * zb 12
|
||||
* rz 3 *
|
||||
* ...
|
||||
*
|
||||
* Thereby value 0 shows pure group items (corresponding ambigous matches).
|
||||
* But the group may have a value if it contains only same values
|
||||
* (see for example group "f" above).
|
||||
*
|
||||
* StrIdxTree's are very fast, so:
|
||||
* build of above-mentioned tree takes about 10 microseconds.
|
||||
* search of string index in this tree takes fewer as 0.1 microseconds.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tclInt.h"
|
||||
#include "tclStrIdxTree.h"
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TclStrIdxTreeSearch --
|
||||
*
|
||||
* Find largest part of string "start" in indexed tree (case sensitive).
|
||||
*
|
||||
* Also used for building of string index tree.
|
||||
*
|
||||
* Results:
|
||||
* Return position of UTF character in start after last equal character
|
||||
* and found item (with parent).
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
MODULE_SCOPE const char*
|
||||
TclStrIdxTreeSearch(
|
||||
TclStrIdxTree **foundParent, /* Return value of found sub tree (used for tree build) */
|
||||
TclStrIdx **foundItem, /* Return value of found item */
|
||||
TclStrIdxTree *tree, /* Index tree will be browsed */
|
||||
const char *start, /* UTF string to find in tree */
|
||||
const char *end) /* End of string */
|
||||
{
|
||||
TclStrIdxTree *parent = tree, *prevParent = tree;
|
||||
TclStrIdx *item = tree->firstPtr, *prevItem = NULL;
|
||||
const char *s = start, *f, *cin, *cinf, *prevf;
|
||||
int offs = 0;
|
||||
|
||||
if (item == NULL) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* search in tree */
|
||||
do {
|
||||
cinf = cin = TclGetString(item->key) + offs;
|
||||
f = TclUtfFindEqualNCInLwr(s, end, cin, cin + item->length, &cinf);
|
||||
/* if something was found */
|
||||
if (f > s) {
|
||||
/* if whole string was found */
|
||||
if (f >= end) {
|
||||
start = f;
|
||||
goto done;
|
||||
};
|
||||
/* set new offset and shift start string */
|
||||
offs += cinf - cin;
|
||||
s = f;
|
||||
/* if match item, go deeper as long as possible */
|
||||
if (offs >= item->length && item->childTree.firstPtr) {
|
||||
/* save previuosly found item (if not ambigous) for
|
||||
* possible fallback (few greedy match) */
|
||||
if (item->value != NULL) {
|
||||
prevf = f;
|
||||
prevItem = item;
|
||||
prevParent = parent;
|
||||
}
|
||||
parent = &item->childTree;
|
||||
item = item->childTree.firstPtr;
|
||||
continue;
|
||||
}
|
||||
/* no children - return this item and current chars found */
|
||||
start = f;
|
||||
goto done;
|
||||
}
|
||||
|
||||
item = item->nextPtr;
|
||||
|
||||
} while (item != NULL);
|
||||
|
||||
/* fallback (few greedy match) not ambigous (has a value) */
|
||||
if (prevItem != NULL) {
|
||||
item = prevItem;
|
||||
parent = prevParent;
|
||||
start = prevf;
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
if (foundParent)
|
||||
*foundParent = parent;
|
||||
if (foundItem)
|
||||
*foundItem = item;
|
||||
return start;
|
||||
}
|
||||
|
||||
MODULE_SCOPE void
|
||||
TclStrIdxTreeFree(
|
||||
TclStrIdx *tree)
|
||||
{
|
||||
while (tree != NULL) {
|
||||
TclStrIdx *t;
|
||||
Tcl_DecrRefCount(tree->key);
|
||||
if (tree->childTree.firstPtr != NULL) {
|
||||
TclStrIdxTreeFree(tree->childTree.firstPtr);
|
||||
}
|
||||
t = tree, tree = tree->nextPtr;
|
||||
ckfree(t);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Several bidirectional list primitives
|
||||
*/
|
||||
inline void
|
||||
TclStrIdxTreeInsertBranch(
|
||||
TclStrIdxTree *parent,
|
||||
register TclStrIdx *item,
|
||||
register TclStrIdx *child)
|
||||
{
|
||||
if (parent->firstPtr == child)
|
||||
parent->firstPtr = item;
|
||||
if (parent->lastPtr == child)
|
||||
parent->lastPtr = item;
|
||||
if ( (item->nextPtr = child->nextPtr) ) {
|
||||
item->nextPtr->prevPtr = item;
|
||||
child->nextPtr = NULL;
|
||||
}
|
||||
if ( (item->prevPtr = child->prevPtr) ) {
|
||||
item->prevPtr->nextPtr = item;
|
||||
child->prevPtr = NULL;
|
||||
}
|
||||
item->childTree.firstPtr = child;
|
||||
item->childTree.lastPtr = child;
|
||||
}
|
||||
|
||||
inline void
|
||||
TclStrIdxTreeAppend(
|
||||
register TclStrIdxTree *parent,
|
||||
register TclStrIdx *item)
|
||||
{
|
||||
if (parent->lastPtr != NULL) {
|
||||
parent->lastPtr->nextPtr = item;
|
||||
}
|
||||
item->prevPtr = parent->lastPtr;
|
||||
item->nextPtr = NULL;
|
||||
parent->lastPtr = item;
|
||||
if (parent->firstPtr == NULL) {
|
||||
parent->firstPtr = item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TclStrIdxTreeBuildFromList --
|
||||
*
|
||||
* Build or extend string indexed tree from tcl list.
|
||||
* If the values not given the values of built list are indices starts with 1.
|
||||
* Value of 0 is thereby reserved to the ambigous values.
|
||||
*
|
||||
* Important: by multiple lists, optimal tree can be created only if list with
|
||||
* larger strings used firstly.
|
||||
*
|
||||
* Results:
|
||||
* Returns a standard Tcl result.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
MODULE_SCOPE int
|
||||
TclStrIdxTreeBuildFromList(
|
||||
TclStrIdxTree *idxTree,
|
||||
int lstc,
|
||||
Tcl_Obj **lstv,
|
||||
ClientData *values)
|
||||
{
|
||||
Tcl_Obj **lwrv;
|
||||
int i, ret = TCL_ERROR;
|
||||
ClientData val;
|
||||
const char *s, *e, *f;
|
||||
TclStrIdx *item;
|
||||
|
||||
/* create lowercase reflection of the list keys */
|
||||
|
||||
lwrv = ckalloc(sizeof(Tcl_Obj*) * lstc);
|
||||
if (lwrv == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
for (i = 0; i < lstc; i++) {
|
||||
lwrv[i] = Tcl_DuplicateObj(lstv[i]);
|
||||
if (lwrv[i] == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Tcl_IncrRefCount(lwrv[i]);
|
||||
lwrv[i]->length = Tcl_UtfToLower(TclGetString(lwrv[i]));
|
||||
}
|
||||
|
||||
/* build index tree of the list keys */
|
||||
for (i = 0; i < lstc; i++) {
|
||||
TclStrIdxTree *foundParent = idxTree;
|
||||
e = s = TclGetString(lwrv[i]);
|
||||
e += lwrv[i]->length;
|
||||
val = values ? values[i] : INT2PTR(i+1);
|
||||
|
||||
/* ignore empty keys (impossible to index it) */
|
||||
if (lwrv[i]->length == 0) continue;
|
||||
|
||||
item = NULL;
|
||||
if (idxTree->firstPtr != NULL) {
|
||||
TclStrIdx *foundItem;
|
||||
f = TclStrIdxTreeSearch(&foundParent, &foundItem,
|
||||
idxTree, s, e);
|
||||
/* if common prefix was found */
|
||||
if (f > s) {
|
||||
/* ignore element if fulfilled or ambigous */
|
||||
if (f == e) {
|
||||
continue;
|
||||
}
|
||||
/* if shortest key was found with the same value,
|
||||
* just replace its current key with longest key */
|
||||
if ( foundItem->value == val
|
||||
&& foundItem->length < lwrv[i]->length
|
||||
&& foundItem->childTree.firstPtr == NULL
|
||||
) {
|
||||
Tcl_SetObjRef(foundItem->key, lwrv[i]);
|
||||
foundItem->length = lwrv[i]->length;
|
||||
continue;
|
||||
}
|
||||
/* split tree (e. g. j->(jan,jun) + jul == j->(jan,ju->(jun,jul)) )
|
||||
* but don't split by fulfilled child of found item ( ii->iii->iiii ) */
|
||||
if (foundItem->length != (f - s)) {
|
||||
/* first split found item (insert one between parent and found + new one) */
|
||||
item = ckalloc(sizeof(*item));
|
||||
if (item == NULL) {
|
||||
goto done;
|
||||
}
|
||||
Tcl_InitObjRef(item->key, foundItem->key);
|
||||
item->length = f - s;
|
||||
/* set value or mark as ambigous if not the same value of both */
|
||||
item->value = (foundItem->value == val) ? val : NULL;
|
||||
/* insert group item between foundParent and foundItem */
|
||||
TclStrIdxTreeInsertBranch(foundParent, item, foundItem);
|
||||
foundParent = &item->childTree;
|
||||
} else {
|
||||
/* the new item should be added as child of found item */
|
||||
foundParent = &foundItem->childTree;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* append item at end of found parent */
|
||||
item = ckalloc(sizeof(*item));
|
||||
if (item == NULL) {
|
||||
goto done;
|
||||
}
|
||||
item->childTree.lastPtr = item->childTree.firstPtr = NULL;
|
||||
Tcl_InitObjRef(item->key, lwrv[i]);
|
||||
item->length = lwrv[i]->length;
|
||||
item->value = val;
|
||||
TclStrIdxTreeAppend(foundParent, item);
|
||||
};
|
||||
|
||||
ret = TCL_OK;
|
||||
|
||||
done:
|
||||
|
||||
if (lwrv != NULL) {
|
||||
for (i = 0; i < lstc; i++) {
|
||||
Tcl_DecrRefCount(lwrv[i]);
|
||||
}
|
||||
ckfree(lwrv);
|
||||
}
|
||||
|
||||
if (ret != TCL_OK) {
|
||||
if (idxTree->firstPtr != NULL) {
|
||||
TclStrIdxTreeFree(idxTree->firstPtr);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
StrIdxTreeObj_DupIntRepProc(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr);
|
||||
static void
|
||||
StrIdxTreeObj_FreeIntRepProc(Tcl_Obj *objPtr);
|
||||
static void
|
||||
StrIdxTreeObj_UpdateStringProc(Tcl_Obj *objPtr);
|
||||
|
||||
Tcl_ObjType StrIdxTreeObjType = {
|
||||
"str-idx-tree", /* name */
|
||||
StrIdxTreeObj_FreeIntRepProc, /* freeIntRepProc */
|
||||
StrIdxTreeObj_DupIntRepProc, /* dupIntRepProc */
|
||||
StrIdxTreeObj_UpdateStringProc, /* updateStringProc */
|
||||
NULL /* setFromAnyProc */
|
||||
};
|
||||
|
||||
MODULE_SCOPE Tcl_Obj*
|
||||
TclStrIdxTreeNewObj()
|
||||
{
|
||||
Tcl_Obj *objPtr = Tcl_NewObj();
|
||||
objPtr->internalRep.twoPtrValue.ptr1 = NULL;
|
||||
objPtr->internalRep.twoPtrValue.ptr2 = NULL;
|
||||
objPtr->typePtr = &StrIdxTreeObjType;
|
||||
/* return tree root in internal representation */
|
||||
return objPtr;
|
||||
}
|
||||
|
||||
static void
|
||||
StrIdxTreeObj_DupIntRepProc(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr)
|
||||
{
|
||||
/* follow links (smart pointers) */
|
||||
if ( srcPtr->internalRep.twoPtrValue.ptr1 != NULL
|
||||
&& srcPtr->internalRep.twoPtrValue.ptr2 == NULL
|
||||
) {
|
||||
srcPtr = (Tcl_Obj*)srcPtr->internalRep.twoPtrValue.ptr1;
|
||||
}
|
||||
/* create smart pointer to it (ptr1 != NULL, ptr2 = NULL) */
|
||||
Tcl_InitObjRef(*((Tcl_Obj **)©Ptr->internalRep.twoPtrValue.ptr1),
|
||||
srcPtr);
|
||||
copyPtr->internalRep.twoPtrValue.ptr2 = NULL;
|
||||
copyPtr->typePtr = &StrIdxTreeObjType;
|
||||
}
|
||||
|
||||
static void
|
||||
StrIdxTreeObj_FreeIntRepProc(Tcl_Obj *objPtr)
|
||||
{
|
||||
/* follow links (smart pointers) */
|
||||
if ( objPtr->internalRep.twoPtrValue.ptr1 != NULL
|
||||
&& objPtr->internalRep.twoPtrValue.ptr2 == NULL
|
||||
) {
|
||||
/* is a link */
|
||||
Tcl_UnsetObjRef(*((Tcl_Obj **)&objPtr->internalRep.twoPtrValue.ptr1));
|
||||
} else {
|
||||
/* is a tree */
|
||||
TclStrIdxTree *tree = (TclStrIdxTree*)&objPtr->internalRep.twoPtrValue.ptr1;
|
||||
if (tree->firstPtr != NULL) {
|
||||
TclStrIdxTreeFree(tree->firstPtr);
|
||||
}
|
||||
objPtr->internalRep.twoPtrValue.ptr1 = NULL;
|
||||
objPtr->internalRep.twoPtrValue.ptr2 = NULL;
|
||||
}
|
||||
objPtr->typePtr = NULL;
|
||||
};
|
||||
|
||||
static void
|
||||
StrIdxTreeObj_UpdateStringProc(Tcl_Obj *objPtr)
|
||||
{
|
||||
/* currently only dummy empty string possible */
|
||||
objPtr->length = 0;
|
||||
objPtr->bytes = &tclEmptyString;
|
||||
};
|
||||
|
||||
MODULE_SCOPE TclStrIdxTree *
|
||||
TclStrIdxTreeGetFromObj(Tcl_Obj *objPtr) {
|
||||
/* follow links (smart pointers) */
|
||||
if (objPtr->typePtr != &StrIdxTreeObjType) {
|
||||
return NULL;
|
||||
}
|
||||
if ( objPtr->internalRep.twoPtrValue.ptr1 != NULL
|
||||
&& objPtr->internalRep.twoPtrValue.ptr2 == NULL
|
||||
) {
|
||||
objPtr = (Tcl_Obj*)objPtr->internalRep.twoPtrValue.ptr1;
|
||||
}
|
||||
/* return tree root in internal representation */
|
||||
return (TclStrIdxTree*)&objPtr->internalRep.twoPtrValue.ptr1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Several debug primitives
|
||||
*/
|
||||
#if 0
|
||||
/* currently unused, debug resp. test purposes only */
|
||||
|
||||
void
|
||||
TclStrIdxTreePrint(
|
||||
Tcl_Interp *interp,
|
||||
TclStrIdx *tree,
|
||||
int offs)
|
||||
{
|
||||
Tcl_Obj *obj[2];
|
||||
const char *s;
|
||||
Tcl_InitObjRef(obj[0], Tcl_NewStringObj("::puts", -1));
|
||||
while (tree != NULL) {
|
||||
s = TclGetString(tree->key) + offs;
|
||||
Tcl_InitObjRef(obj[1], Tcl_ObjPrintf("%*s%.*s\t:%d",
|
||||
offs, "", tree->length - offs, s, tree->value));
|
||||
Tcl_PutsObjCmd(NULL, interp, 2, obj);
|
||||
Tcl_UnsetObjRef(obj[1]);
|
||||
if (tree->childTree.firstPtr != NULL) {
|
||||
TclStrIdxTreePrint(interp, tree->childTree.firstPtr, tree->length);
|
||||
}
|
||||
tree = tree->nextPtr;
|
||||
}
|
||||
Tcl_UnsetObjRef(obj[0]);
|
||||
}
|
||||
|
||||
|
||||
MODULE_SCOPE int
|
||||
TclStrIdxTreeTestObjCmd(
|
||||
ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
const char *cs, *cin, *ret;
|
||||
|
||||
static const char *const options[] = {
|
||||
"index", "puts-index", "findequal",
|
||||
NULL
|
||||
};
|
||||
enum optionInd {
|
||||
O_INDEX, O_PUTS_INDEX, O_FINDEQUAL
|
||||
};
|
||||
int optionIndex;
|
||||
|
||||
if (objc < 2) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (Tcl_GetIndexFromObj(interp, objv[1], options,
|
||||
"option", 0, &optionIndex) != TCL_OK) {
|
||||
Tcl_SetErrorCode(interp, "CLOCK", "badOption",
|
||||
Tcl_GetString(objv[1]), NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
switch (optionIndex) {
|
||||
case O_FINDEQUAL:
|
||||
if (objc < 4) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
cs = TclGetString(objv[2]);
|
||||
cin = TclGetString(objv[3]);
|
||||
ret = TclUtfFindEqual(
|
||||
cs, cs + objv[1]->length, cin, cin + objv[2]->length);
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(ret - cs));
|
||||
break;
|
||||
case O_INDEX:
|
||||
case O_PUTS_INDEX:
|
||||
|
||||
if (1) {
|
||||
Tcl_Obj **lstv;
|
||||
int i, lstc;
|
||||
TclStrIdxTree idxTree = {NULL, NULL};
|
||||
i = 1;
|
||||
while (++i < objc) {
|
||||
if (TclListObjGetElements(interp, objv[i],
|
||||
&lstc, &lstv) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
};
|
||||
TclStrIdxTreeBuildFromList(&idxTree, lstc, lstv, NULL);
|
||||
}
|
||||
if (optionIndex == O_PUTS_INDEX) {
|
||||
TclStrIdxTreePrint(interp, idxTree.firstPtr, 0);
|
||||
}
|
||||
TclStrIdxTreeFree(idxTree.firstPtr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 4
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* tclStrIdxTree.h --
|
||||
*
|
||||
* Declarations of string index tries and other primitives currently
|
||||
* back-ported from tclSE.
|
||||
*
|
||||
* Copyright (c) 2016 Serg G. Brester (aka sebres)
|
||||
*
|
||||
* See the file "license.terms" for information on usage and redistribution
|
||||
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
*/
|
||||
|
||||
#ifndef _TCLSTRIDXTREE_H
|
||||
#define _TCLSTRIDXTREE_H
|
||||
|
||||
|
||||
/*
|
||||
* Main structures declarations of index tree and entry
|
||||
*/
|
||||
|
||||
typedef struct TclStrIdxTree {
|
||||
struct TclStrIdx *firstPtr;
|
||||
struct TclStrIdx *lastPtr;
|
||||
} TclStrIdxTree;
|
||||
|
||||
typedef struct TclStrIdx {
|
||||
struct TclStrIdxTree childTree;
|
||||
struct TclStrIdx *nextPtr;
|
||||
struct TclStrIdx *prevPtr;
|
||||
Tcl_Obj *key;
|
||||
int length;
|
||||
ClientData value;
|
||||
} TclStrIdx;
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TclUtfFindEqual, TclUtfFindEqualNC --
|
||||
*
|
||||
* Find largest part of string cs in string cin (case sensitive and not).
|
||||
*
|
||||
* Results:
|
||||
* Return position of UTF character in cs after last equal character.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static inline const char *
|
||||
TclUtfFindEqual(
|
||||
register const char *cs, /* UTF string to find in cin. */
|
||||
register const char *cse, /* End of cs */
|
||||
register const char *cin, /* UTF string will be browsed. */
|
||||
register const char *cine) /* End of cin */
|
||||
{
|
||||
register const char *ret = cs;
|
||||
Tcl_UniChar ch1, ch2;
|
||||
do {
|
||||
cs += TclUtfToUniChar(cs, &ch1);
|
||||
cin += TclUtfToUniChar(cin, &ch2);
|
||||
if (ch1 != ch2) break;
|
||||
} while ((ret = cs) < cse && cin < cine);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
TclUtfFindEqualNC(
|
||||
register const char *cs, /* UTF string to find in cin. */
|
||||
register const char *cse, /* End of cs */
|
||||
register const char *cin, /* UTF string will be browsed. */
|
||||
register const char *cine, /* End of cin */
|
||||
const char **cinfnd) /* Return position in cin */
|
||||
{
|
||||
register const char *ret = cs;
|
||||
Tcl_UniChar ch1, ch2;
|
||||
do {
|
||||
cs += TclUtfToUniChar(cs, &ch1);
|
||||
cin += TclUtfToUniChar(cin, &ch2);
|
||||
if (ch1 != ch2) {
|
||||
ch1 = Tcl_UniCharToLower(ch1);
|
||||
ch2 = Tcl_UniCharToLower(ch2);
|
||||
if (ch1 != ch2) break;
|
||||
}
|
||||
*cinfnd = cin;
|
||||
} while ((ret = cs) < cse && cin < cine);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
TclUtfFindEqualNCInLwr(
|
||||
register const char *cs, /* UTF string (in anycase) to find in cin. */
|
||||
register const char *cse, /* End of cs */
|
||||
register const char *cin, /* UTF string (in lowercase) will be browsed. */
|
||||
register const char *cine, /* End of cin */
|
||||
const char **cinfnd) /* Return position in cin */
|
||||
{
|
||||
register const char *ret = cs;
|
||||
Tcl_UniChar ch1, ch2;
|
||||
do {
|
||||
cs += TclUtfToUniChar(cs, &ch1);
|
||||
cin += TclUtfToUniChar(cin, &ch2);
|
||||
if (ch1 != ch2) {
|
||||
ch1 = Tcl_UniCharToLower(ch1);
|
||||
if (ch1 != ch2) break;
|
||||
}
|
||||
*cinfnd = cin;
|
||||
} while ((ret = cs) < cse && cin < cine);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
TclUtfNext(
|
||||
register const char *src) /* The current location in the string. */
|
||||
{
|
||||
if (((unsigned char) *(src)) < 0xC0) {
|
||||
return ++src;
|
||||
} else {
|
||||
Tcl_UniChar ch;
|
||||
return src + TclUtfToUniChar(src, &ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Primitives to safe set, reset and free references.
|
||||
*/
|
||||
|
||||
#define Tcl_UnsetObjRef(obj) \
|
||||
if (obj != NULL) { Tcl_DecrRefCount(obj); obj = NULL; }
|
||||
#define Tcl_InitObjRef(obj, val) \
|
||||
obj = val; if (obj) { Tcl_IncrRefCount(obj); }
|
||||
#define Tcl_SetObjRef(obj, val) \
|
||||
if (1) { \
|
||||
Tcl_Obj *nval = val; \
|
||||
if (obj != nval) { \
|
||||
Tcl_Obj *prev = obj; \
|
||||
Tcl_InitObjRef(obj, nval); \
|
||||
if (prev != NULL) { Tcl_DecrRefCount(prev); }; \
|
||||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
* Prototypes of module functions.
|
||||
*/
|
||||
|
||||
MODULE_SCOPE const char*
|
||||
TclStrIdxTreeSearch(TclStrIdxTree **foundParent,
|
||||
TclStrIdx **foundItem, TclStrIdxTree *tree,
|
||||
const char *start, const char *end);
|
||||
|
||||
MODULE_SCOPE int TclStrIdxTreeBuildFromList(TclStrIdxTree *idxTree,
|
||||
int lstc, Tcl_Obj **lstv, ClientData *values);
|
||||
|
||||
MODULE_SCOPE Tcl_Obj*
|
||||
TclStrIdxTreeNewObj();
|
||||
|
||||
MODULE_SCOPE TclStrIdxTree*
|
||||
TclStrIdxTreeGetFromObj(Tcl_Obj *objPtr);
|
||||
|
||||
#if 1
|
||||
|
||||
MODULE_SCOPE int TclStrIdxTreeTestObjCmd(ClientData, Tcl_Interp *,
|
||||
int, Tcl_Obj *const objv[]);
|
||||
#endif
|
||||
|
||||
#endif /* _TCLSTRIDXTREE_H */
|
||||
Regular → Executable
+58
-43
@@ -482,7 +482,7 @@ TclParseNumber(
|
||||
{
|
||||
enum State {
|
||||
INITIAL, SIGNUM, ZERO, ZERO_X,
|
||||
ZERO_O, ZERO_B, BINARY,
|
||||
ZERO_O, ZERO_B, ZERO_D, BINARY,
|
||||
HEXADECIMAL, OCTAL, BAD_OCTAL, DECIMAL,
|
||||
LEADING_RADIX_POINT, FRACTION,
|
||||
EXPONENT_START, EXPONENT_SIGNUM, EXPONENT,
|
||||
@@ -664,6 +664,10 @@ TclParseNumber(
|
||||
state = ZERO_O;
|
||||
break;
|
||||
}
|
||||
if (c == 'd' || c == 'D') {
|
||||
state = ZERO_D;
|
||||
break;
|
||||
}
|
||||
#ifdef TCL_NO_DEPRECATED
|
||||
goto decimal;
|
||||
#endif
|
||||
@@ -707,7 +711,7 @@ TclParseNumber(
|
||||
|| (octalSignificandWide >
|
||||
(~(Tcl_WideUInt)0 >> shift)))) {
|
||||
octalSignificandOverflow = 1;
|
||||
TclBNInitBignumFromWideUInt(&octalSignificandBig,
|
||||
TclInitBignumFromWideUInt(&octalSignificandBig,
|
||||
octalSignificandWide);
|
||||
}
|
||||
}
|
||||
@@ -824,7 +828,7 @@ TclParseNumber(
|
||||
((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) ||
|
||||
significandWide > (~(Tcl_WideUInt)0 >> shift))) {
|
||||
significandOverflow = 1;
|
||||
TclBNInitBignumFromWideUInt(&significandBig,
|
||||
TclInitBignumFromWideUInt(&significandBig,
|
||||
significandWide);
|
||||
}
|
||||
}
|
||||
@@ -865,7 +869,7 @@ TclParseNumber(
|
||||
((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) ||
|
||||
significandWide > (~(Tcl_WideUInt)0 >> shift))) {
|
||||
significandOverflow = 1;
|
||||
TclBNInitBignumFromWideUInt(&significandBig,
|
||||
TclInitBignumFromWideUInt(&significandBig,
|
||||
significandWide);
|
||||
}
|
||||
}
|
||||
@@ -880,6 +884,16 @@ TclParseNumber(
|
||||
state = BINARY;
|
||||
break;
|
||||
|
||||
case ZERO_D:
|
||||
if (c == '0') {
|
||||
numTrailZeros++;
|
||||
} else if ( ! isdigit(UCHAR(c))) {
|
||||
goto endgame;
|
||||
}
|
||||
state = DECIMAL;
|
||||
flags |= TCL_PARSE_INTEGER_ONLY;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case DECIMAL:
|
||||
/*
|
||||
* Scanned an optional + or - followed by a string of decimal
|
||||
@@ -1176,6 +1190,7 @@ TclParseNumber(
|
||||
case ZERO_X:
|
||||
case ZERO_O:
|
||||
case ZERO_B:
|
||||
case ZERO_D:
|
||||
case LEADING_RADIX_POINT:
|
||||
case EXPONENT_START:
|
||||
case EXPONENT_SIGNUM:
|
||||
@@ -1199,7 +1214,7 @@ TclParseNumber(
|
||||
((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) ||
|
||||
significandWide > (MOST_BITS + signum) >> shift)) {
|
||||
significandOverflow = 1;
|
||||
TclBNInitBignumFromWideUInt(&significandBig, significandWide);
|
||||
TclInitBignumFromWideUInt(&significandBig, significandWide);
|
||||
}
|
||||
if (shift) {
|
||||
if (!significandOverflow) {
|
||||
@@ -1220,7 +1235,7 @@ TclParseNumber(
|
||||
((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) ||
|
||||
significandWide > (MOST_BITS + signum) >> shift)) {
|
||||
significandOverflow = 1;
|
||||
TclBNInitBignumFromWideUInt(&significandBig, significandWide);
|
||||
TclInitBignumFromWideUInt(&significandBig, significandWide);
|
||||
}
|
||||
if (shift) {
|
||||
if (!significandOverflow) {
|
||||
@@ -1241,7 +1256,7 @@ TclParseNumber(
|
||||
((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) ||
|
||||
octalSignificandWide > (MOST_BITS + signum) >> shift)) {
|
||||
octalSignificandOverflow = 1;
|
||||
TclBNInitBignumFromWideUInt(&octalSignificandBig,
|
||||
TclInitBignumFromWideUInt(&octalSignificandBig,
|
||||
octalSignificandWide);
|
||||
}
|
||||
if (shift) {
|
||||
@@ -1268,7 +1283,7 @@ TclParseNumber(
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
TclBNInitBignumFromWideUInt(&octalSignificandBig,
|
||||
TclInitBignumFromWideUInt(&octalSignificandBig,
|
||||
octalSignificandWide);
|
||||
octalSignificandOverflow = 1;
|
||||
} else {
|
||||
@@ -1296,7 +1311,7 @@ TclParseNumber(
|
||||
&significandWide, &significandBig, significandOverflow);
|
||||
if (!significandOverflow && (significandWide > MOST_BITS+signum)){
|
||||
significandOverflow = 1;
|
||||
TclBNInitBignumFromWideUInt(&significandBig, significandWide);
|
||||
TclInitBignumFromWideUInt(&significandBig, significandWide);
|
||||
}
|
||||
returnInteger:
|
||||
if (!significandOverflow) {
|
||||
@@ -1315,7 +1330,7 @@ TclParseNumber(
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
TclBNInitBignumFromWideUInt(&significandBig,
|
||||
TclInitBignumFromWideUInt(&significandBig,
|
||||
significandWide);
|
||||
significandOverflow = 1;
|
||||
} else {
|
||||
@@ -1470,7 +1485,7 @@ AccumulateDecimalDigit(
|
||||
* bignum and fall through into the bignum case.
|
||||
*/
|
||||
|
||||
TclBNInitBignumFromWideUInt(bignumRepPtr, w);
|
||||
TclInitBignumFromWideUInt(bignumRepPtr, w);
|
||||
} else {
|
||||
/*
|
||||
* Wide multiplication.
|
||||
@@ -1613,7 +1628,7 @@ MakeLowPrecisionDouble(
|
||||
* call MakeHighPrecisionDouble to do it the hard way.
|
||||
*/
|
||||
|
||||
TclBNInitBignumFromWideUInt(&significandBig, significand);
|
||||
TclInitBignumFromWideUInt(&significandBig, significand);
|
||||
retval = MakeHighPrecisionDouble(0, &significandBig, numSigDigs,
|
||||
exponent);
|
||||
mp_clear(&significandBig);
|
||||
@@ -1980,7 +1995,7 @@ RefineApproximation(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static void
|
||||
static inline void
|
||||
MulPow5(
|
||||
mp_int *base, /* Number to multiply. */
|
||||
unsigned n, /* Power of 5 to multiply by. */
|
||||
@@ -2025,7 +2040,7 @@ MulPow5(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
static inline int
|
||||
NormalizeRightward(
|
||||
Tcl_WideUInt *wPtr) /* INOUT: Number to shift. */
|
||||
{
|
||||
@@ -2116,7 +2131,7 @@ RequiredPrecision(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static void
|
||||
static inline void
|
||||
DoubleToExpAndSig(
|
||||
double dv, /* Number to convert. */
|
||||
Tcl_WideUInt *significand, /* OUTPUT: Significand of the number. */
|
||||
@@ -2164,7 +2179,7 @@ DoubleToExpAndSig(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static void
|
||||
static inline void
|
||||
TakeAbsoluteValue(
|
||||
Double *d, /* Number to replace with absolute value. */
|
||||
int *sign) /* Place to put the signum. */
|
||||
@@ -2195,7 +2210,7 @@ TakeAbsoluteValue(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
FormatInfAndNaN(
|
||||
Double *d, /* Exceptional number to format. */
|
||||
int *decpt, /* Decimal point to set to a bogus value. */
|
||||
@@ -2237,7 +2252,7 @@ FormatInfAndNaN(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
FormatZero(
|
||||
int *decpt, /* Location of the decimal point. */
|
||||
char **endPtr) /* Pointer to the end of the formatted data */
|
||||
@@ -2267,7 +2282,7 @@ FormatZero(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
static inline int
|
||||
ApproximateLog10(
|
||||
Tcl_WideUInt bw, /* Integer significand of the number. */
|
||||
int be, /* Power of two to scale bw. */
|
||||
@@ -2315,7 +2330,7 @@ ApproximateLog10(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
static inline int
|
||||
BetterLog10(
|
||||
double d, /* Original number to format. */
|
||||
int k, /* Characteristic(Log base 10) of the
|
||||
@@ -2358,7 +2373,7 @@ BetterLog10(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static void
|
||||
static inline void
|
||||
ComputeScale(
|
||||
int be, /* Exponent part of number: d = bw * 2**be. */
|
||||
int k, /* Characteristic of log10(number). */
|
||||
@@ -2421,7 +2436,7 @@ ComputeScale(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static void
|
||||
static inline void
|
||||
SetPrecisionLimits(
|
||||
int convType, /* Type of conversion: TCL_DD_SHORTEST,
|
||||
* TCL_DD_STEELE0, TCL_DD_E_FMT,
|
||||
@@ -2482,7 +2497,7 @@ SetPrecisionLimits(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
BumpUp(
|
||||
char *s, /* Cursor pointing one past the end of the
|
||||
* string. */
|
||||
@@ -2516,7 +2531,7 @@ BumpUp(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
static inline int
|
||||
AdjustRange(
|
||||
double *dPtr, /* INOUT: Number to adjust. */
|
||||
int k) /* IN: floor(log10(d)) */
|
||||
@@ -2589,7 +2604,7 @@ AdjustRange(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
ShorteningQuickFormat(
|
||||
double d, /* Number to convert. */
|
||||
int k, /* floor(log10(d)) */
|
||||
@@ -2664,7 +2679,7 @@ ShorteningQuickFormat(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
StrictQuickFormat(
|
||||
double d, /* Number to convert. */
|
||||
int k, /* floor(log10(d)) */
|
||||
@@ -2738,7 +2753,7 @@ StrictQuickFormat(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
QuickConversion(
|
||||
double e, /* Number to format. */
|
||||
int k, /* floor(log10(d)), approximately. */
|
||||
@@ -2843,7 +2858,7 @@ QuickConversion(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static void
|
||||
static inline void
|
||||
CastOutPowersOf2(
|
||||
int *b2, /* Power of 2 to multiply the significand. */
|
||||
int *m2, /* Power of 2 to multiply 1/2 ulp. */
|
||||
@@ -2887,7 +2902,7 @@ CastOutPowersOf2(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
ShorteningInt64Conversion(
|
||||
Double *dPtr, /* Original number to convert. */
|
||||
int convType, /* Type of conversion (shortest, Steele,
|
||||
@@ -3056,7 +3071,7 @@ ShorteningInt64Conversion(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
StrictInt64Conversion(
|
||||
Double *dPtr, /* Original number to convert. */
|
||||
int convType, /* Type of conversion (shortest, Steele,
|
||||
@@ -3162,7 +3177,7 @@ StrictInt64Conversion(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
static inline int
|
||||
ShouldBankerRoundUpPowD(
|
||||
mp_int *b, /* Numerator of the fraction. */
|
||||
int sd, /* Denominator is 2**(sd*DIGIT_BIT). */
|
||||
@@ -3200,7 +3215,7 @@ ShouldBankerRoundUpPowD(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
static inline int
|
||||
ShouldBankerRoundUpToNextPowD(
|
||||
mp_int *b, /* Numerator of the fraction. */
|
||||
mp_int *m, /* Numerator of the rounding tolerance. */
|
||||
@@ -3263,7 +3278,7 @@ ShouldBankerRoundUpToNextPowD(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
ShorteningBignumConversionPowD(
|
||||
Double *dPtr, /* Original number to convert. */
|
||||
int convType, /* Type of conversion (shortest, Steele,
|
||||
@@ -3300,7 +3315,7 @@ ShorteningBignumConversionPowD(
|
||||
* mminus = 5**m5
|
||||
*/
|
||||
|
||||
TclBNInitBignumFromWideUInt(&b, bw);
|
||||
TclInitBignumFromWideUInt(&b, bw);
|
||||
mp_init_set_int(&mminus, 1);
|
||||
MulPow5(&b, b5, &b);
|
||||
mp_mul_2d(&b, b2, &b);
|
||||
@@ -3456,7 +3471,7 @@ ShorteningBignumConversionPowD(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
StrictBignumConversionPowD(
|
||||
Double *dPtr, /* Original number to convert. */
|
||||
int convType, /* Type of conversion (shortest, Steele,
|
||||
@@ -3487,7 +3502,7 @@ StrictBignumConversionPowD(
|
||||
* b = bw * 2**b2 * 5**b5
|
||||
*/
|
||||
|
||||
TclBNInitBignumFromWideUInt(&b, bw);
|
||||
TclInitBignumFromWideUInt(&b, bw);
|
||||
MulPow5(&b, b5, &b);
|
||||
mp_mul_2d(&b, b2, &b);
|
||||
|
||||
@@ -3572,7 +3587,7 @@ StrictBignumConversionPowD(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
static inline int
|
||||
ShouldBankerRoundUp(
|
||||
mp_int *twor, /* 2x the remainder from thd division that
|
||||
* produced the last digit. */
|
||||
@@ -3607,7 +3622,7 @@ ShouldBankerRoundUp(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
static inline int
|
||||
ShouldBankerRoundUpToNext(
|
||||
mp_int *b, /* Remainder from the division that produced
|
||||
* the last digit. */
|
||||
@@ -3661,7 +3676,7 @@ ShouldBankerRoundUpToNext(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
ShorteningBignumConversion(
|
||||
Double *dPtr, /* Original number being converted. */
|
||||
int convType, /* Conversion type. */
|
||||
@@ -3695,7 +3710,7 @@ ShorteningBignumConversion(
|
||||
* S = 2**s2 * 5*s5
|
||||
*/
|
||||
|
||||
TclBNInitBignumFromWideUInt(&b, bw);
|
||||
TclInitBignumFromWideUInt(&b, bw);
|
||||
mp_mul_2d(&b, b2, &b);
|
||||
mp_init_set_int(&S, 1);
|
||||
MulPow5(&S, s5, &S); mp_mul_2d(&S, s2, &S);
|
||||
@@ -3877,7 +3892,7 @@ ShorteningBignumConversion(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static char *
|
||||
static inline char *
|
||||
StrictBignumConversion(
|
||||
Double *dPtr, /* Original number being converted. */
|
||||
int convType, /* Conversion type. */
|
||||
@@ -3908,7 +3923,7 @@ StrictBignumConversion(
|
||||
*/
|
||||
|
||||
mp_init_multi(&temp, &dig, NULL);
|
||||
TclBNInitBignumFromWideUInt(&b, bw);
|
||||
TclInitBignumFromWideUInt(&b, bw);
|
||||
mp_mul_2d(&b, b2, &b);
|
||||
mp_init_set_int(&S, 1);
|
||||
MulPow5(&S, s5, &S); mp_mul_2d(&S, s2, &S);
|
||||
@@ -4564,7 +4579,7 @@ Tcl_InitBignumFromDouble(
|
||||
Tcl_WideInt w = (Tcl_WideInt) ldexp(fract, mantBits);
|
||||
int shift = expt - mantBits;
|
||||
|
||||
TclBNInitBignumFromWideInt(b, w);
|
||||
TclInitBignumFromWideInt(b, w);
|
||||
if (shift < 0) {
|
||||
mp_div_2d(b, -shift, b, NULL);
|
||||
} else if (shift > 0) {
|
||||
|
||||
+67
-46
@@ -466,7 +466,7 @@ Tcl_GetCharLength(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Tcl_UniChar
|
||||
int
|
||||
Tcl_GetUniChar(
|
||||
Tcl_Obj *objPtr, /* The object to get the Unicode charater
|
||||
* from. */
|
||||
@@ -483,7 +483,7 @@ Tcl_GetUniChar(
|
||||
if (TclIsPureByteArray(objPtr)) {
|
||||
unsigned char *bytes = Tcl_GetByteArrayFromObj(objPtr, NULL);
|
||||
|
||||
return (Tcl_UniChar) bytes[index];
|
||||
return (int) bytes[index];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -493,7 +493,7 @@ Tcl_GetUniChar(
|
||||
SetStringFromAny(NULL, objPtr);
|
||||
stringPtr = GET_STRING(objPtr);
|
||||
|
||||
if (stringPtr->hasUnicode == 0) {
|
||||
if ((stringPtr->flags & TCL_HAS_UNICODE) == 0) {
|
||||
/*
|
||||
* If numChars is unknown, compute it.
|
||||
*/
|
||||
@@ -507,7 +507,7 @@ Tcl_GetUniChar(
|
||||
FillUnicodeRep(objPtr);
|
||||
stringPtr = GET_STRING(objPtr);
|
||||
}
|
||||
return stringPtr->unicode[index];
|
||||
return (int) stringPtr->unicode[index];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -569,7 +569,7 @@ Tcl_GetUnicodeFromObj(
|
||||
SetStringFromAny(NULL, objPtr);
|
||||
stringPtr = GET_STRING(objPtr);
|
||||
|
||||
if (stringPtr->hasUnicode == 0) {
|
||||
if ((stringPtr->flags & TCL_HAS_UNICODE) == 0) {
|
||||
FillUnicodeRep(objPtr);
|
||||
stringPtr = GET_STRING(objPtr);
|
||||
}
|
||||
@@ -607,6 +607,7 @@ Tcl_GetRange(
|
||||
{
|
||||
Tcl_Obj *newObjPtr; /* The Tcl object to find the range of. */
|
||||
String *stringPtr;
|
||||
int i, firstoffset = 0, lastoffset = 0;
|
||||
|
||||
/*
|
||||
* Optimize the case where we're really dealing with a bytearray object
|
||||
@@ -627,7 +628,7 @@ Tcl_GetRange(
|
||||
SetStringFromAny(NULL, objPtr);
|
||||
stringPtr = GET_STRING(objPtr);
|
||||
|
||||
if (stringPtr->hasUnicode == 0) {
|
||||
if ((stringPtr->flags & TCL_HAS_UNICODE) == 0) {
|
||||
/*
|
||||
* If numChars is unknown, compute it.
|
||||
*/
|
||||
@@ -651,7 +652,17 @@ Tcl_GetRange(
|
||||
stringPtr = GET_STRING(objPtr);
|
||||
}
|
||||
|
||||
return Tcl_NewUnicodeObj(stringPtr->unicode + first, last-first+1);
|
||||
for (i = 0; i <= last + lastoffset + firstoffset; i++) {
|
||||
if ((stringPtr->unicode[i] & 0xfc00) == 0xd800) {
|
||||
if (i < first + firstoffset) {
|
||||
firstoffset++;
|
||||
} else {
|
||||
lastoffset++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Tcl_NewUnicodeObj(stringPtr->unicode + first + firstoffset, last-first+1 + lastoffset + firstoffset);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -783,7 +794,7 @@ Tcl_SetObjLength(
|
||||
*/
|
||||
|
||||
stringPtr->numChars = -1;
|
||||
stringPtr->hasUnicode = 0;
|
||||
stringPtr->flags = 0;
|
||||
} else {
|
||||
/*
|
||||
* Changing length of pure unicode string.
|
||||
@@ -802,7 +813,7 @@ Tcl_SetObjLength(
|
||||
|
||||
stringPtr->numChars = length;
|
||||
stringPtr->unicode[length] = 0;
|
||||
stringPtr->hasUnicode = 1;
|
||||
stringPtr->flags |= TCL_HAS_UNICODE;
|
||||
|
||||
/*
|
||||
* Can only get here when objPtr->bytes == NULL. No need to invalidate
|
||||
@@ -893,7 +904,7 @@ Tcl_AttemptSetObjLength(
|
||||
*/
|
||||
|
||||
stringPtr->numChars = -1;
|
||||
stringPtr->hasUnicode = 0;
|
||||
stringPtr->flags = 0;
|
||||
} else {
|
||||
/*
|
||||
* Changing length of pure unicode string.
|
||||
@@ -917,7 +928,7 @@ Tcl_AttemptSetObjLength(
|
||||
|
||||
stringPtr->unicode[length] = 0;
|
||||
stringPtr->numChars = length;
|
||||
stringPtr->hasUnicode = 1;
|
||||
stringPtr->flags |= TCL_HAS_UNICODE;
|
||||
|
||||
/*
|
||||
* Can only get here when objPtr->bytes == NULL. No need to invalidate
|
||||
@@ -1000,7 +1011,7 @@ SetUnicodeObj(
|
||||
memcpy(stringPtr->unicode, unicode, numChars * sizeof(Tcl_UniChar));
|
||||
stringPtr->unicode[numChars] = 0;
|
||||
stringPtr->numChars = numChars;
|
||||
stringPtr->hasUnicode = 1;
|
||||
stringPtr->flags |= TCL_HAS_UNICODE;
|
||||
|
||||
TclInvalidateStringRep(objPtr);
|
||||
stringPtr->allocated = 0;
|
||||
@@ -1071,7 +1082,7 @@ Tcl_AppendLimitedToObj(
|
||||
SetStringFromAny(NULL, objPtr);
|
||||
stringPtr = GET_STRING(objPtr);
|
||||
|
||||
if (stringPtr->hasUnicode && stringPtr->numChars > 0) {
|
||||
if ((stringPtr->flags & TCL_HAS_UNICODE) && stringPtr->numChars > 0) {
|
||||
AppendUtfToUnicodeRep(objPtr, bytes, toCopy);
|
||||
} else {
|
||||
AppendUtfToUtfRep(objPtr, bytes, toCopy);
|
||||
@@ -1082,7 +1093,7 @@ Tcl_AppendLimitedToObj(
|
||||
}
|
||||
|
||||
stringPtr = GET_STRING(objPtr);
|
||||
if (stringPtr->hasUnicode && stringPtr->numChars > 0) {
|
||||
if ((stringPtr->flags & TCL_HAS_UNICODE) && stringPtr->numChars > 0) {
|
||||
AppendUtfToUnicodeRep(objPtr, ellipsis, strlen(ellipsis));
|
||||
} else {
|
||||
AppendUtfToUtfRep(objPtr, ellipsis, strlen(ellipsis));
|
||||
@@ -1161,7 +1172,7 @@ Tcl_AppendUnicodeToObj(
|
||||
* objPtr's string rep.
|
||||
*/
|
||||
|
||||
if (stringPtr->hasUnicode) {
|
||||
if ((stringPtr->flags & TCL_HAS_UNICODE)) {
|
||||
AppendUnicodeToUnicodeRep(objPtr, unicode, length);
|
||||
} else {
|
||||
AppendUnicodeToUtfRep(objPtr, unicode, length);
|
||||
@@ -1267,7 +1278,7 @@ Tcl_AppendObjToObj(
|
||||
* appendObjPtr and append it.
|
||||
*/
|
||||
|
||||
if (stringPtr->hasUnicode) {
|
||||
if ((stringPtr->flags & TCL_HAS_UNICODE)) {
|
||||
/*
|
||||
* If appendObjPtr is not of the "String" type, don't convert it.
|
||||
*/
|
||||
@@ -1543,7 +1554,7 @@ AppendUtfToUtfRep(
|
||||
*/
|
||||
|
||||
stringPtr->numChars = -1;
|
||||
stringPtr->hasUnicode = 0;
|
||||
stringPtr->flags = 0;
|
||||
|
||||
if (bytes) {
|
||||
memmove(objPtr->bytes + oldLength, bytes, numBytes);
|
||||
@@ -1650,6 +1661,7 @@ Tcl_AppendFormatToObj(
|
||||
const char *span = format, *msg, *errCode;
|
||||
int numBytes = 0, objIndex = 0, gotXpg = 0, gotSequential = 0;
|
||||
int originalLength, limit;
|
||||
Tcl_UniChar ch = 0;
|
||||
static const char *mixedXPG =
|
||||
"cannot mix \"%\" and \"%n$\" conversion specifiers";
|
||||
static const char *const badIndex[2] = {
|
||||
@@ -1677,7 +1689,6 @@ Tcl_AppendFormatToObj(
|
||||
#endif
|
||||
int newXpg, numChars, allocSegment = 0, segmentLimit, segmentNumBytes;
|
||||
Tcl_Obj *segment;
|
||||
Tcl_UniChar ch;
|
||||
int step = TclUtfToUniChar(format, &ch);
|
||||
|
||||
format += step;
|
||||
@@ -2029,9 +2040,12 @@ Tcl_AppendFormatToObj(
|
||||
segmentLimit -= 1;
|
||||
precision--;
|
||||
break;
|
||||
case 'X':
|
||||
Tcl_AppendToObj(segment, "0X", 2);
|
||||
segmentLimit -= 2;
|
||||
break;
|
||||
case 'p':
|
||||
case 'x':
|
||||
case 'X':
|
||||
Tcl_AppendToObj(segment, "0x", 2);
|
||||
segmentLimit -= 2;
|
||||
break;
|
||||
@@ -2039,6 +2053,10 @@ Tcl_AppendFormatToObj(
|
||||
Tcl_AppendToObj(segment, "0b", 2);
|
||||
segmentLimit -= 2;
|
||||
break;
|
||||
case 'd':
|
||||
Tcl_AppendToObj(segment, "0d", 2);
|
||||
segmentLimit -= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2196,7 +2214,11 @@ Tcl_AppendFormatToObj(
|
||||
}
|
||||
digitOffset = (int) (bits % base);
|
||||
if (digitOffset > 9) {
|
||||
bytes[numDigits] = 'a' + digitOffset - 10;
|
||||
if (ch == 'X') {
|
||||
bytes[numDigits] = 'A' + digitOffset - 10;
|
||||
} else {
|
||||
bytes[numDigits] = 'a' + digitOffset - 10;
|
||||
}
|
||||
} else {
|
||||
bytes[numDigits] = '0' + digitOffset;
|
||||
}
|
||||
@@ -2318,14 +2340,6 @@ Tcl_AppendFormatToObj(
|
||||
goto error;
|
||||
}
|
||||
|
||||
switch (ch) {
|
||||
case 'E':
|
||||
case 'G':
|
||||
case 'X': {
|
||||
Tcl_SetObjLength(segment, Tcl_UtfToUpper(TclGetString(segment)));
|
||||
}
|
||||
}
|
||||
|
||||
if (width>0 && numChars<0) {
|
||||
numChars = Tcl_GetCharLength(segment);
|
||||
}
|
||||
@@ -2721,7 +2735,7 @@ TclStringRepeat(
|
||||
if (!binary) {
|
||||
if (objPtr->typePtr == &tclStringType) {
|
||||
String *stringPtr = GET_STRING(objPtr);
|
||||
if (stringPtr->hasUnicode) {
|
||||
if (stringPtr->flags & TCL_HAS_UNICODE) {
|
||||
unichar = 1;
|
||||
}
|
||||
}
|
||||
@@ -3425,7 +3439,7 @@ TclStringObjReverse(
|
||||
Tcl_Obj *objPtr)
|
||||
{
|
||||
String *stringPtr;
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
|
||||
if (TclIsPureByteArray(objPtr)) {
|
||||
int numBytes;
|
||||
@@ -3441,7 +3455,7 @@ TclStringObjReverse(
|
||||
SetStringFromAny(NULL, objPtr);
|
||||
stringPtr = GET_STRING(objPtr);
|
||||
|
||||
if (stringPtr->hasUnicode) {
|
||||
if ((stringPtr->flags & TCL_HAS_UNICODE)) {
|
||||
Tcl_UniChar *from = Tcl_GetUnicode(objPtr);
|
||||
Tcl_UniChar *src = from + stringPtr->numChars;
|
||||
|
||||
@@ -3453,7 +3467,6 @@ TclStringObjReverse(
|
||||
* Tcl_SetObjLength into growing the unicode rep buffer.
|
||||
*/
|
||||
|
||||
ch = 0;
|
||||
objPtr = Tcl_NewUnicodeObj(&ch, 1);
|
||||
Tcl_SetObjLength(objPtr, stringPtr->numChars);
|
||||
to = Tcl_GetUnicode(objPtr);
|
||||
@@ -3555,10 +3568,10 @@ ExtendUnicodeRepWithString(
|
||||
int numAppendChars)
|
||||
{
|
||||
String *stringPtr = GET_STRING(objPtr);
|
||||
int needed, numOrigChars = 0;
|
||||
Tcl_UniChar *dst;
|
||||
int incr, needed, numOrigChars = 0;
|
||||
Tcl_UniChar *dst, unichar = 0;
|
||||
|
||||
if (stringPtr->hasUnicode) {
|
||||
if ((stringPtr->flags & TCL_HAS_UNICODE)) {
|
||||
numOrigChars = stringPtr->numChars;
|
||||
}
|
||||
if (numAppendChars == -1) {
|
||||
@@ -3572,14 +3585,19 @@ ExtendUnicodeRepWithString(
|
||||
stringPtr = GET_STRING(objPtr);
|
||||
}
|
||||
|
||||
stringPtr->hasUnicode = 1;
|
||||
stringPtr->flags |= TCL_HAS_UNICODE;
|
||||
if (bytes) {
|
||||
stringPtr->numChars = needed;
|
||||
} else {
|
||||
numAppendChars = 0;
|
||||
}
|
||||
for (dst=stringPtr->unicode + numOrigChars; numAppendChars-- > 0; dst++) {
|
||||
bytes += TclUtfToUniChar(bytes, dst);
|
||||
bytes += (incr = TclUtfToUniChar(bytes, &unichar));
|
||||
*dst = unichar;
|
||||
if (!incr) {
|
||||
bytes += TclUtfToUniChar(bytes, &unichar);
|
||||
*++dst = unichar;
|
||||
}
|
||||
}
|
||||
*dst = 0;
|
||||
}
|
||||
@@ -3622,7 +3640,7 @@ DupStringInternalRep(
|
||||
return;
|
||||
}
|
||||
|
||||
if (srcStringPtr->hasUnicode) {
|
||||
if (srcStringPtr->flags & TCL_HAS_UNICODE) {
|
||||
int copyMaxChars;
|
||||
|
||||
if (srcStringPtr->maxChars / 2 >= srcStringPtr->numChars) {
|
||||
@@ -3644,7 +3662,7 @@ DupStringInternalRep(
|
||||
copyStringPtr->maxChars = 0;
|
||||
copyStringPtr->unicode[0] = 0;
|
||||
}
|
||||
copyStringPtr->hasUnicode = srcStringPtr->hasUnicode;
|
||||
copyStringPtr->flags = srcStringPtr->flags;
|
||||
copyStringPtr->numChars = srcStringPtr->numChars;
|
||||
|
||||
/*
|
||||
@@ -3699,7 +3717,7 @@ SetStringFromAny(
|
||||
stringPtr->numChars = -1;
|
||||
stringPtr->allocated = objPtr->length;
|
||||
stringPtr->maxChars = 0;
|
||||
stringPtr->hasUnicode = 0;
|
||||
stringPtr->flags = 0;
|
||||
SET_STRING(objPtr, stringPtr);
|
||||
objPtr->typePtr = &tclStringType;
|
||||
}
|
||||
@@ -3758,8 +3776,8 @@ ExtendStringRepWithUnicode(
|
||||
* Pre-condition: this is the "string" Tcl_ObjType.
|
||||
*/
|
||||
|
||||
int i, origLength, size = 0;
|
||||
char *dst;
|
||||
int incr, i, origLength, size = 0, offset = 0;
|
||||
char *dst, buf[TCL_UTF_MAX];
|
||||
String *stringPtr = GET_STRING(objPtr);
|
||||
|
||||
if (numChars < 0) {
|
||||
@@ -3784,9 +3802,11 @@ ExtendStringRepWithUnicode(
|
||||
goto copyBytes;
|
||||
}
|
||||
|
||||
for (i = 0; i < numChars && size >= 0; i++) {
|
||||
size += TclUtfCount(unicode[i]);
|
||||
for (i = 0; i < numChars + offset && size >= 0; i++) {
|
||||
size += (incr = Tcl_UniCharToUtf((int) unicode[i], buf));
|
||||
if (!incr) offset++;
|
||||
}
|
||||
offset = 0;
|
||||
if (size < 0) {
|
||||
Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
|
||||
}
|
||||
@@ -3801,8 +3821,9 @@ ExtendStringRepWithUnicode(
|
||||
|
||||
copyBytes:
|
||||
dst = objPtr->bytes + origLength;
|
||||
for (i = 0; i < numChars; i++) {
|
||||
dst += Tcl_UniCharToUtf((int) unicode[i], dst);
|
||||
for (i = 0; i < numChars + offset; i++) {
|
||||
dst += (incr = Tcl_UniCharToUtf((int) unicode[i], dst));
|
||||
if (!incr) offset++;
|
||||
}
|
||||
*dst = '\0';
|
||||
objPtr->length = dst - objPtr->bytes;
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
* can be officially modified by altering the definition of Tcl_UniChar in
|
||||
* tcl.h, but do not do that unless you are sure what you're doing!
|
||||
*/
|
||||
#define TCL_HAS_UNICODE 1 /* This string has Unicode representation */
|
||||
#define TCL_HAS_BIGUNICODE 2 /* This string contains characters > \uffff */
|
||||
|
||||
typedef struct {
|
||||
int numChars; /* The number of chars in the string. -1 means
|
||||
@@ -57,8 +59,7 @@ typedef struct {
|
||||
* termination char). */
|
||||
int maxChars; /* Max number of chars that can fit in the
|
||||
* space allocated for the unicode array. */
|
||||
int hasUnicode; /* Boolean determining whether the string has
|
||||
* a Unicode representation. */
|
||||
int flags; /* Combination of TCL_HAS_UNICODE and TCL_HAS_BIGUNICODE */
|
||||
Tcl_UniChar unicode[1]; /* The array of Unicode chars. The actual size
|
||||
* of this field depends on the 'maxChars'
|
||||
* field above. */
|
||||
|
||||
@@ -69,6 +69,9 @@ static int TclSockMinimumBuffersOld(int sock, int size)
|
||||
# define TclWinGetSockOpt 0
|
||||
# define TclWinSetSockOpt 0
|
||||
# define TclWinNToHS 0
|
||||
# define TclBNInitBignumFromWideUInt 0
|
||||
# define TclBNInitBignumFromWideInt 0
|
||||
# define TclBNInitBignumFromLong 0
|
||||
#else
|
||||
#define TclSetStartupScriptPath setStartupScriptPath
|
||||
static void TclSetStartupScriptPath(Tcl_Obj *path)
|
||||
@@ -103,6 +106,9 @@ static unsigned short TclWinNToHS(unsigned short ns) {
|
||||
return ntohs(ns);
|
||||
}
|
||||
#endif
|
||||
# define TclBNInitBignumFromWideUInt TclInitBignumFromWideUInt
|
||||
# define TclBNInitBignumFromWideInt TclInitBignumFromWideInt
|
||||
# define TclBNInitBignumFromLong TclInitBignumFromLong
|
||||
#endif /* TCL_NO_DEPRECATED */
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -859,6 +865,10 @@ const TclTomMathStubs tclTomMathStubs = {
|
||||
TclBNInitBignumFromWideInt, /* 65 */
|
||||
TclBNInitBignumFromWideUInt, /* 66 */
|
||||
TclBN_mp_expt_d_ex, /* 67 */
|
||||
TclBN_mp_set_long_long, /* 68 */
|
||||
TclBN_mp_get_long_long, /* 69 */
|
||||
TclBN_mp_set_long, /* 70 */
|
||||
TclBN_mp_get_long, /* 71 */
|
||||
};
|
||||
|
||||
static const TclStubHooks tclStubHooks = {
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* tclStubLibTbl.c --
|
||||
*
|
||||
* Stub object that will be statically linked into extensions that want
|
||||
* to access Tcl.
|
||||
*
|
||||
* Copyright (c) 1998-1999 by Scriptics Corporation.
|
||||
* Copyright (c) 1998 Paul Duffin.
|
||||
*
|
||||
* See the file "license.terms" for information on usage and redistribution of
|
||||
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
*/
|
||||
|
||||
#include "tclInt.h"
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TclInitStubTable --
|
||||
*
|
||||
* Initialize the stub table, using the structure pointed at
|
||||
* by the "version" argument.
|
||||
*
|
||||
* Results:
|
||||
* Outputs the value of the "version" argument.
|
||||
*
|
||||
* Side effects:
|
||||
* Sets the stub table pointers.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
MODULE_SCOPE const char *
|
||||
TclInitStubTable(
|
||||
const char *version) /* points to the version field of a
|
||||
TclStubInfoType structure variable. */
|
||||
{
|
||||
tclStubsPtr = ((const TclStubInfoType *) version)->stubs;
|
||||
|
||||
if (tclStubsPtr->hooks) {
|
||||
tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs;
|
||||
tclIntStubsPtr = tclStubsPtr->hooks->tclIntStubs;
|
||||
tclIntPlatStubsPtr = tclStubsPtr->hooks->tclIntPlatStubs;
|
||||
} else {
|
||||
tclPlatStubsPtr = NULL;
|
||||
tclIntStubsPtr = NULL;
|
||||
tclIntPlatStubsPtr = NULL;
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 4
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
+49
-36
@@ -30,13 +30,13 @@ declare 1 {
|
||||
}
|
||||
|
||||
declare 2 {
|
||||
int TclBN_mp_add(mp_int *a, mp_int *b, mp_int *c)
|
||||
int TclBN_mp_add(const mp_int *a, const mp_int *b, mp_int *c)
|
||||
}
|
||||
declare 3 {
|
||||
int TclBN_mp_add_d(mp_int *a, mp_digit b, mp_int *c)
|
||||
int TclBN_mp_add_d(const mp_int *a, mp_digit b, mp_int *c)
|
||||
}
|
||||
declare 4 {
|
||||
int TclBN_mp_and(mp_int *a, mp_int *b, mp_int *c)
|
||||
int TclBN_mp_and(const mp_int *a, const mp_int *b, mp_int *c)
|
||||
}
|
||||
declare 5 {
|
||||
void TclBN_mp_clamp(mp_int *a)
|
||||
@@ -63,25 +63,25 @@ declare 12 {
|
||||
int TclBN_mp_count_bits(const mp_int *a)
|
||||
}
|
||||
declare 13 {
|
||||
int TclBN_mp_div(mp_int *a, mp_int *b, mp_int *q, mp_int *r)
|
||||
int TclBN_mp_div(const mp_int *a, const mp_int *b, mp_int *q, mp_int *r)
|
||||
}
|
||||
declare 14 {
|
||||
int TclBN_mp_div_d(mp_int *a, mp_digit b, mp_int *q, mp_digit *r)
|
||||
int TclBN_mp_div_d(const mp_int *a, mp_digit b, mp_int *q, mp_digit *r)
|
||||
}
|
||||
declare 15 {
|
||||
int TclBN_mp_div_2(mp_int *a, mp_int *q)
|
||||
int TclBN_mp_div_2(const mp_int *a, mp_int *q)
|
||||
}
|
||||
declare 16 {
|
||||
int TclBN_mp_div_2d(const mp_int *a, int b, mp_int *q, mp_int *r)
|
||||
}
|
||||
declare 17 {
|
||||
int TclBN_mp_div_3(mp_int *a, mp_int *q, mp_digit *r)
|
||||
int TclBN_mp_div_3(const mp_int *a, mp_int *q, mp_digit *r)
|
||||
}
|
||||
declare 18 {
|
||||
void TclBN_mp_exch(mp_int *a, mp_int *b)
|
||||
}
|
||||
declare 19 {
|
||||
int TclBN_mp_expt_d(mp_int *a, mp_digit b, mp_int *c)
|
||||
int TclBN_mp_expt_d(const mp_int *a, mp_digit b, mp_int *c)
|
||||
}
|
||||
declare 20 {
|
||||
int TclBN_mp_grow(mp_int *a, int size)
|
||||
@@ -105,19 +105,19 @@ declare 26 {
|
||||
int TclBN_mp_lshd(mp_int *a, int shift)
|
||||
}
|
||||
declare 27 {
|
||||
int TclBN_mp_mod(mp_int *a, mp_int *b, mp_int *r)
|
||||
int TclBN_mp_mod(const mp_int *a, const mp_int *b, mp_int *r)
|
||||
}
|
||||
declare 28 {
|
||||
int TclBN_mp_mod_2d(const mp_int *a, int b, mp_int *r)
|
||||
}
|
||||
declare 29 {
|
||||
int TclBN_mp_mul(mp_int *a, mp_int *b, mp_int *p)
|
||||
int TclBN_mp_mul(const mp_int *a, const mp_int *b, mp_int *p)
|
||||
}
|
||||
declare 30 {
|
||||
int TclBN_mp_mul_d(mp_int *a, mp_digit b, mp_int *p)
|
||||
int TclBN_mp_mul_d(const mp_int *a, mp_digit b, mp_int *p)
|
||||
}
|
||||
declare 31 {
|
||||
int TclBN_mp_mul_2(mp_int *a, mp_int *p)
|
||||
int TclBN_mp_mul_2(const mp_int *a, mp_int *p)
|
||||
}
|
||||
declare 32 {
|
||||
int TclBN_mp_mul_2d(const mp_int *a, int d, mp_int *p)
|
||||
@@ -126,7 +126,7 @@ declare 33 {
|
||||
int TclBN_mp_neg(const mp_int *a, mp_int *b)
|
||||
}
|
||||
declare 34 {
|
||||
int TclBN_mp_or(mp_int *a, mp_int *b, mp_int *c)
|
||||
int TclBN_mp_or(const mp_int *a, const mp_int *b, mp_int *c)
|
||||
}
|
||||
declare 35 {
|
||||
int TclBN_mp_radix_size(const mp_int *a, int radix, int *size)
|
||||
@@ -144,32 +144,32 @@ declare 39 {
|
||||
void TclBN_mp_set(mp_int *a, mp_digit b)
|
||||
}
|
||||
declare 40 {
|
||||
int TclBN_mp_sqr(mp_int *a, mp_int *b)
|
||||
int TclBN_mp_sqr(const mp_int *a, mp_int *b)
|
||||
}
|
||||
declare 41 {
|
||||
int TclBN_mp_sqrt(mp_int *a, mp_int *b)
|
||||
int TclBN_mp_sqrt(const mp_int *a, mp_int *b)
|
||||
}
|
||||
declare 42 {
|
||||
int TclBN_mp_sub(mp_int *a, mp_int *b, mp_int *c)
|
||||
int TclBN_mp_sub(const mp_int *a, const mp_int *b, mp_int *c)
|
||||
}
|
||||
declare 43 {
|
||||
int TclBN_mp_sub_d(mp_int *a, mp_digit b, mp_int *c)
|
||||
int TclBN_mp_sub_d(const mp_int *a, mp_digit b, mp_int *c)
|
||||
}
|
||||
declare 44 {
|
||||
int TclBN_mp_to_unsigned_bin(mp_int *a, unsigned char *b)
|
||||
int TclBN_mp_to_unsigned_bin(const mp_int *a, unsigned char *b)
|
||||
}
|
||||
declare 45 {
|
||||
int TclBN_mp_to_unsigned_bin_n(mp_int *a, unsigned char *b,
|
||||
int TclBN_mp_to_unsigned_bin_n(const mp_int *a, unsigned char *b,
|
||||
unsigned long *outlen)
|
||||
}
|
||||
declare 46 {
|
||||
int TclBN_mp_toradix_n(mp_int *a, char *str, int radix, int maxlen)
|
||||
int TclBN_mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen)
|
||||
}
|
||||
declare 47 {
|
||||
int TclBN_mp_unsigned_bin_size(mp_int *a)
|
||||
int TclBN_mp_unsigned_bin_size(const mp_int *a)
|
||||
}
|
||||
declare 48 {
|
||||
int TclBN_mp_xor(mp_int *a, mp_int *b, mp_int *c)
|
||||
int TclBN_mp_xor(const mp_int *a, const mp_int *b, mp_int *c)
|
||||
}
|
||||
declare 49 {
|
||||
void TclBN_mp_zero(mp_int *a)
|
||||
@@ -182,34 +182,34 @@ declare 50 {
|
||||
void TclBN_reverse(unsigned char *s, int len)
|
||||
}
|
||||
declare 51 {
|
||||
int TclBN_fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs)
|
||||
int TclBN_fast_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
|
||||
}
|
||||
declare 52 {
|
||||
int TclBN_fast_s_mp_sqr(mp_int *a, mp_int *b)
|
||||
int TclBN_fast_s_mp_sqr(const mp_int *a, mp_int *b)
|
||||
}
|
||||
declare 53 {
|
||||
int TclBN_mp_karatsuba_mul(mp_int *a, mp_int *b, mp_int *c)
|
||||
int TclBN_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
|
||||
}
|
||||
declare 54 {
|
||||
int TclBN_mp_karatsuba_sqr(mp_int *a, mp_int *b)
|
||||
int TclBN_mp_karatsuba_sqr(const mp_int *a, mp_int *b)
|
||||
}
|
||||
declare 55 {
|
||||
int TclBN_mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
|
||||
int TclBN_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
|
||||
}
|
||||
declare 56 {
|
||||
int TclBN_mp_toom_sqr(mp_int *a, mp_int *b)
|
||||
int TclBN_mp_toom_sqr(const mp_int *a, mp_int *b)
|
||||
}
|
||||
declare 57 {
|
||||
int TclBN_s_mp_add(mp_int *a, mp_int *b, mp_int *c)
|
||||
int TclBN_s_mp_add(const mp_int *a, const mp_int *b, mp_int *c)
|
||||
}
|
||||
declare 58 {
|
||||
int TclBN_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs)
|
||||
int TclBN_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
|
||||
}
|
||||
declare 59 {
|
||||
int TclBN_s_mp_sqr(mp_int *a, mp_int *b)
|
||||
int TclBN_s_mp_sqr(const mp_int *a, mp_int *b)
|
||||
}
|
||||
declare 60 {
|
||||
int TclBN_s_mp_sub(mp_int *a, mp_int *b, mp_int *c)
|
||||
int TclBN_s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c)
|
||||
}
|
||||
declare 61 {
|
||||
int TclBN_mp_init_set_int(mp_int *a, unsigned long i)
|
||||
@@ -223,19 +223,32 @@ declare 63 {
|
||||
|
||||
# Formerly internal API to allow initialisation of bignums without knowing the
|
||||
# typedefs of how a bignum works internally.
|
||||
declare 64 {
|
||||
declare 64 {deprecated {Use mp_init() + mp_set_long_long()}} {
|
||||
void TclBNInitBignumFromLong(mp_int *bignum, long initVal)
|
||||
}
|
||||
declare 65 {
|
||||
declare 65 {deprecated {Use mp_init() + mp_set_long_long()}} {
|
||||
void TclBNInitBignumFromWideInt(mp_int *bignum, Tcl_WideInt initVal)
|
||||
}
|
||||
declare 66 {
|
||||
declare 66 {deprecated {Use mp_init() + mp_set_long_long()}} {
|
||||
void TclBNInitBignumFromWideUInt(mp_int *bignum, Tcl_WideUInt initVal)
|
||||
}
|
||||
|
||||
# Added in libtommath 1.0
|
||||
declare 67 {
|
||||
int TclBN_mp_expt_d_ex(mp_int *a, mp_digit b, mp_int *c, int fast)
|
||||
int TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
|
||||
}
|
||||
# Added in libtommath 1.0.1
|
||||
declare 68 {
|
||||
int TclBN_mp_set_long_long(mp_int *a, Tcl_WideUInt i)
|
||||
}
|
||||
declare 69 {
|
||||
Tcl_WideUInt TclBN_mp_get_long_long(const mp_int *a)
|
||||
}
|
||||
declare 70 {
|
||||
int TclBN_mp_set_long(mp_int *a, unsigned long i)
|
||||
}
|
||||
declare 71 {
|
||||
unsigned long TclBN_mp_get_long(const mp_int *a)
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
|
||||
+159
-148
@@ -27,10 +27,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* detect 64-bit mode if possible */
|
||||
#if defined(NEVER) /* 128-bit ints fail in too many places */
|
||||
#if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
|
||||
#define MP_64BIT
|
||||
#endif
|
||||
#if defined(NEVER) /* 128-bit ints fail in too many places */
|
||||
# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
|
||||
# define MP_64BIT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* some default configurations.
|
||||
@@ -43,89 +43,94 @@ extern "C" {
|
||||
*/
|
||||
#ifdef MP_8BIT
|
||||
#ifndef MP_DIGIT_DECLARED
|
||||
typedef uint8_t mp_digit;
|
||||
typedef uint8_t mp_digit;
|
||||
#define MP_DIGIT_DECLARED
|
||||
#endif
|
||||
typedef uint16_t mp_word;
|
||||
#define MP_SIZEOF_MP_DIGIT 1
|
||||
#ifdef DIGIT_BIT
|
||||
#error You must not define DIGIT_BIT when using MP_8BIT
|
||||
#ifndef MP_WORD_DECLARED
|
||||
typedef uint16_t mp_word;
|
||||
#define MP_WORD_DECLARED
|
||||
#endif
|
||||
# define MP_SIZEOF_MP_DIGIT 1
|
||||
# ifdef DIGIT_BIT
|
||||
# error You must not define DIGIT_BIT when using MP_8BIT
|
||||
# endif
|
||||
#elif defined(MP_16BIT)
|
||||
#ifndef MP_DIGIT_DECLARED
|
||||
typedef uint16_t mp_digit;
|
||||
typedef uint16_t mp_digit;
|
||||
#define MP_DIGIT_DECLARED
|
||||
#endif
|
||||
typedef uint32_t mp_word;
|
||||
#define MP_SIZEOF_MP_DIGIT 2
|
||||
#ifdef DIGIT_BIT
|
||||
#error You must not define DIGIT_BIT when using MP_16BIT
|
||||
#ifndef MP_WORD_DECLARED
|
||||
typedef uint32_t mp_word;
|
||||
#define MP_WORD_DECLARED
|
||||
#endif
|
||||
# define MP_SIZEOF_MP_DIGIT 2
|
||||
# ifdef DIGIT_BIT
|
||||
# error You must not define DIGIT_BIT when using MP_16BIT
|
||||
# endif
|
||||
#elif defined(MP_64BIT)
|
||||
/* for GCC only on supported platforms */
|
||||
#ifndef CRYPT
|
||||
typedef unsigned long long ulong64;
|
||||
typedef signed long long long64;
|
||||
#endif
|
||||
|
||||
/* for GCC only on supported platforms */
|
||||
#ifndef MP_DIGIT_DECLARED
|
||||
typedef ulong64 mp_digit;
|
||||
typedef uint64_t mp_digit;
|
||||
#define MP_DIGIT_DECLARED
|
||||
#endif
|
||||
#if defined(_WIN32)
|
||||
typedef unsigned __int128 mp_word;
|
||||
#elif defined(__GNUC__)
|
||||
typedef unsigned long mp_word __attribute__ ((mode(TI)));
|
||||
#else
|
||||
/* it seems you have a problem
|
||||
* but we assume you can somewhere define your own uint128_t */
|
||||
typedef uint128_t mp_word;
|
||||
# if defined(_WIN32)
|
||||
#ifndef MP_WORD_DECLARED
|
||||
typedef unsigned __int128 mp_word;
|
||||
#define MP_WORD_DECLARED
|
||||
#endif
|
||||
|
||||
#define DIGIT_BIT 60
|
||||
#else
|
||||
/* this is the default case, 28-bit digits */
|
||||
|
||||
/* this is to make porting into LibTomCrypt easier :-) */
|
||||
#ifndef CRYPT
|
||||
typedef unsigned long long ulong64;
|
||||
typedef signed long long long64;
|
||||
# elif defined(__GNUC__)
|
||||
typedef unsigned long mp_word __attribute__((mode(TI)));
|
||||
# else
|
||||
/* it seems you have a problem
|
||||
* but we assume you can somewhere define your own uint128_t */
|
||||
#ifndef MP_WORD_DECLARED
|
||||
typedef uint128_t mp_word;
|
||||
#define MP_WORD_DECLARED
|
||||
#endif
|
||||
# endif
|
||||
|
||||
# define DIGIT_BIT 60
|
||||
#else
|
||||
/* this is the default case, 28-bit digits */
|
||||
|
||||
/* this is to make porting into LibTomCrypt easier :-) */
|
||||
#ifndef MP_DIGIT_DECLARED
|
||||
typedef uint32_t mp_digit;
|
||||
typedef uint32_t mp_digit;
|
||||
#define MP_DIGIT_DECLARED
|
||||
#endif
|
||||
typedef ulong64 mp_word;
|
||||
|
||||
#ifdef MP_31BIT
|
||||
/* this is an extension that uses 31-bit digits */
|
||||
#define DIGIT_BIT 31
|
||||
#else
|
||||
/* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */
|
||||
#define DIGIT_BIT 28
|
||||
#define MP_28BIT
|
||||
#ifndef MP_WORD_DECLARED
|
||||
typedef uint64_t mp_word;
|
||||
#define MP_WORD_DECLARED
|
||||
#endif
|
||||
|
||||
# ifdef MP_31BIT
|
||||
/* this is an extension that uses 31-bit digits */
|
||||
# define DIGIT_BIT 31
|
||||
# else
|
||||
/* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */
|
||||
# define DIGIT_BIT 28
|
||||
# define MP_28BIT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
|
||||
#ifndef DIGIT_BIT
|
||||
#define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
|
||||
typedef uint_least32_t mp_min_u32;
|
||||
# define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
|
||||
typedef uint_least32_t mp_min_u32;
|
||||
#else
|
||||
typedef mp_digit mp_min_u32;
|
||||
#endif
|
||||
|
||||
/* platforms that can use a better rand function */
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
||||
#define MP_USE_ALT_RAND 1
|
||||
typedef mp_digit mp_min_u32;
|
||||
#endif
|
||||
|
||||
/* use arc4random on platforms that support it */
|
||||
#ifdef MP_USE_ALT_RAND
|
||||
#define MP_GEN_RANDOM() arc4random()
|
||||
#else
|
||||
#define MP_GEN_RANDOM() rand()
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
||||
# define MP_GEN_RANDOM() arc4random()
|
||||
# define MP_GEN_RANDOM_MAX 0xffffffff
|
||||
#endif
|
||||
|
||||
/* use rand() as fall-back if there's no better rand function */
|
||||
#ifndef MP_GEN_RANDOM
|
||||
# define MP_GEN_RANDOM() rand()
|
||||
# define MP_GEN_RANDOM_MAX RAND_MAX
|
||||
#endif
|
||||
|
||||
#define MP_DIGIT_BIT DIGIT_BIT
|
||||
@@ -158,9 +163,9 @@ typedef int mp_err;
|
||||
/* you'll have to tune these... */
|
||||
#if defined(BUILD_tcl) || !defined(_WIN32)
|
||||
MODULE_SCOPE int KARATSUBA_MUL_CUTOFF,
|
||||
KARATSUBA_SQR_CUTOFF,
|
||||
TOOM_MUL_CUTOFF,
|
||||
TOOM_SQR_CUTOFF;
|
||||
KARATSUBA_SQR_CUTOFF,
|
||||
TOOM_MUL_CUTOFF,
|
||||
TOOM_SQR_CUTOFF;
|
||||
#endif
|
||||
|
||||
/* define this to use lower memory usage routines (exptmods mostly) */
|
||||
@@ -168,11 +173,11 @@ MODULE_SCOPE int KARATSUBA_MUL_CUTOFF,
|
||||
|
||||
/* default precision */
|
||||
#ifndef MP_PREC
|
||||
#ifndef MP_LOW_MEM
|
||||
#define MP_PREC 32 /* default digits of precision */
|
||||
#else
|
||||
#define MP_PREC 8 /* default digits of precision */
|
||||
#endif
|
||||
# ifndef MP_LOW_MEM
|
||||
# define MP_PREC 32 /* default digits of precision */
|
||||
# else
|
||||
# define MP_PREC 8 /* default digits of precision */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
|
||||
@@ -184,17 +189,17 @@ MODULE_SCOPE int KARATSUBA_MUL_CUTOFF,
|
||||
typedef struct mp_int mp_int;
|
||||
#endif
|
||||
struct mp_int {
|
||||
int used, alloc, sign;
|
||||
mp_digit *dp;
|
||||
int used, alloc, sign;
|
||||
mp_digit *dp;
|
||||
};
|
||||
|
||||
/* callback for mp_prime_random, should fill dst with random bytes and return how many read [upto len] */
|
||||
typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
|
||||
|
||||
|
||||
#define USED(m) ((m)->used)
|
||||
#define DIGIT(m,k) ((m)->dp[(k)])
|
||||
#define SIGN(m) ((m)->sign)
|
||||
#define USED(m) ((m)->used)
|
||||
#define DIGIT(m, k) ((m)->dp[(k)])
|
||||
#define SIGN(m) ((m)->sign)
|
||||
|
||||
/* error code to char* string */
|
||||
const char *mp_error_to_string(int code);
|
||||
@@ -272,22 +277,28 @@ int mp_set_long_long(mp_int *a, unsigned long long b);
|
||||
*/
|
||||
|
||||
/* get a 32-bit value */
|
||||
unsigned long mp_get_int(mp_int * a);
|
||||
/*
|
||||
unsigned long mp_get_int(const mp_int *a);
|
||||
*/
|
||||
|
||||
/* get a platform dependent unsigned long value */
|
||||
unsigned long mp_get_long(mp_int * a);
|
||||
/*
|
||||
unsigned long mp_get_long(const mp_int *a);
|
||||
*/
|
||||
|
||||
/* get a platform dependent unsigned long long value */
|
||||
unsigned long long mp_get_long_long(mp_int * a);
|
||||
/*
|
||||
unsigned long long mp_get_long_long(const mp_int *a);
|
||||
*/
|
||||
|
||||
/* initialize and set a digit */
|
||||
/*
|
||||
int mp_init_set (mp_int * a, mp_digit b);
|
||||
int mp_init_set(mp_int *a, mp_digit b);
|
||||
*/
|
||||
|
||||
/* initialize and set 32-bit value */
|
||||
/*
|
||||
int mp_init_set_int (mp_int * a, unsigned long b);
|
||||
int mp_init_set_int(mp_int *a, unsigned long b);
|
||||
*/
|
||||
|
||||
/* copy, b = a */
|
||||
@@ -307,12 +318,12 @@ void mp_clamp(mp_int *a);
|
||||
|
||||
/* import binary data */
|
||||
/*
|
||||
int mp_import(mp_int* rop, size_t count, int order, size_t size, int endian, size_t nails, const void* op);
|
||||
int mp_import(mp_int *rop, size_t count, int order, size_t size, int endian, size_t nails, const void *op);
|
||||
*/
|
||||
|
||||
/* export binary data */
|
||||
/*
|
||||
int mp_export(void* rop, size_t* countp, int order, size_t size, int endian, size_t nails, mp_int* op);
|
||||
int mp_export(void *rop, size_t *countp, int order, size_t size, int endian, size_t nails, const mp_int *op);
|
||||
*/
|
||||
|
||||
/* ---> digit manipulation <--- */
|
||||
@@ -334,7 +345,7 @@ int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d);
|
||||
|
||||
/* b = a/2 */
|
||||
/*
|
||||
int mp_div_2(mp_int *a, mp_int *b);
|
||||
int mp_div_2(const mp_int *a, mp_int *b);
|
||||
*/
|
||||
|
||||
/* c = a * 2**b, implemented as c = a << b */
|
||||
@@ -344,7 +355,7 @@ int mp_mul_2d(const mp_int *a, int b, mp_int *c);
|
||||
|
||||
/* b = a*2 */
|
||||
/*
|
||||
int mp_mul_2(mp_int *a, mp_int *b);
|
||||
int mp_mul_2(const mp_int *a, mp_int *b);
|
||||
*/
|
||||
|
||||
/* c = a mod 2**b */
|
||||
@@ -372,17 +383,17 @@ int mp_rand(mp_int *a, int digits);
|
||||
/* ---> binary operations <--- */
|
||||
/* c = a XOR b */
|
||||
/*
|
||||
int mp_xor(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_xor(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* c = a OR b */
|
||||
/*
|
||||
int mp_or(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_or(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* c = a AND b */
|
||||
/*
|
||||
int mp_and(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_and(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* ---> Basic arithmetic <--- */
|
||||
@@ -394,7 +405,7 @@ int mp_neg(const mp_int *a, mp_int *b);
|
||||
|
||||
/* b = |a| */
|
||||
/*
|
||||
int mp_abs(mp_int *a, mp_int *b);
|
||||
int mp_abs(const mp_int *a, mp_int *b);
|
||||
*/
|
||||
|
||||
/* compare a to b */
|
||||
@@ -409,32 +420,32 @@ int mp_cmp_mag(const mp_int *a, const mp_int *b);
|
||||
|
||||
/* c = a + b */
|
||||
/*
|
||||
int mp_add(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_add(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* c = a - b */
|
||||
/*
|
||||
int mp_sub(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_sub(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* c = a * b */
|
||||
/*
|
||||
int mp_mul(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_mul(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* b = a*a */
|
||||
/*
|
||||
int mp_sqr(mp_int *a, mp_int *b);
|
||||
int mp_sqr(const mp_int *a, mp_int *b);
|
||||
*/
|
||||
|
||||
/* a/b => cb + d == a */
|
||||
/*
|
||||
int mp_div(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
||||
int mp_div(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d);
|
||||
*/
|
||||
|
||||
/* c = a mod b, 0 <= c < b */
|
||||
/*
|
||||
int mp_mod(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_mod(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* ---> single digit functions <--- */
|
||||
@@ -446,82 +457,82 @@ int mp_cmp_d(const mp_int *a, mp_digit b);
|
||||
|
||||
/* c = a + b */
|
||||
/*
|
||||
int mp_add_d(mp_int *a, mp_digit b, mp_int *c);
|
||||
int mp_add_d(const mp_int *a, mp_digit b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* c = a - b */
|
||||
/*
|
||||
int mp_sub_d(mp_int *a, mp_digit b, mp_int *c);
|
||||
int mp_sub_d(const mp_int *a, mp_digit b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* c = a * b */
|
||||
/*
|
||||
int mp_mul_d(mp_int *a, mp_digit b, mp_int *c);
|
||||
int mp_mul_d(const mp_int *a, mp_digit b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* a/b => cb + d == a */
|
||||
/*
|
||||
int mp_div_d(mp_int *a, mp_digit b, mp_int *c, mp_digit *d);
|
||||
int mp_div_d(const mp_int *a, mp_digit b, mp_int *c, mp_digit *d);
|
||||
*/
|
||||
|
||||
/* a/3 => 3c + d == a */
|
||||
/*
|
||||
int mp_div_3(mp_int *a, mp_int *c, mp_digit *d);
|
||||
int mp_div_3(const mp_int *a, mp_int *c, mp_digit *d);
|
||||
*/
|
||||
|
||||
/* c = a**b */
|
||||
/*
|
||||
int mp_expt_d(mp_int *a, mp_digit b, mp_int *c);
|
||||
int mp_expt_d(const mp_int *a, mp_digit b, mp_int *c);
|
||||
*/
|
||||
/*
|
||||
int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast);
|
||||
int mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast);
|
||||
*/
|
||||
|
||||
/* c = a mod b, 0 <= c < b */
|
||||
/*
|
||||
int mp_mod_d(mp_int *a, mp_digit b, mp_digit *c);
|
||||
int mp_mod_d(const mp_int *a, mp_digit b, mp_digit *c);
|
||||
*/
|
||||
|
||||
/* ---> number theory <--- */
|
||||
|
||||
/* d = a + b (mod c) */
|
||||
/*
|
||||
int mp_addmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
||||
int mp_addmod(const mp_int *a, const mp_int *b, const mp_int *c, mp_int *d);
|
||||
*/
|
||||
|
||||
/* d = a - b (mod c) */
|
||||
/*
|
||||
int mp_submod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
||||
int mp_submod(const mp_int *a, const mp_int *b, const mp_int *c, mp_int *d);
|
||||
*/
|
||||
|
||||
/* d = a * b (mod c) */
|
||||
/*
|
||||
int mp_mulmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
||||
int mp_mulmod(const mp_int *a, const mp_int *b, const mp_int *c, mp_int *d);
|
||||
*/
|
||||
|
||||
/* c = a * a (mod b) */
|
||||
/*
|
||||
int mp_sqrmod(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_sqrmod(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* c = 1/a (mod b) */
|
||||
/*
|
||||
int mp_invmod(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_invmod(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* c = (a, b) */
|
||||
/*
|
||||
int mp_gcd(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_gcd(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* produces value such that U1*a + U2*b = U3 */
|
||||
/*
|
||||
int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3);
|
||||
int mp_exteuclid(const mp_int *a, const mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3);
|
||||
*/
|
||||
|
||||
/* c = [a, b] or (a*b)/(a, b) */
|
||||
/*
|
||||
int mp_lcm(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_lcm(const mp_int *a, const mp_int *b, mp_int *c);
|
||||
*/
|
||||
|
||||
/* finds one of the b'th root of a, such that |c|**b <= |a|
|
||||
@@ -529,35 +540,35 @@ int mp_lcm(mp_int *a, mp_int *b, mp_int *c);
|
||||
* returns error if a < 0 and b is even
|
||||
*/
|
||||
/*
|
||||
int mp_n_root(mp_int *a, mp_digit b, mp_int *c);
|
||||
int mp_n_root(const mp_int *a, mp_digit b, mp_int *c);
|
||||
*/
|
||||
/*
|
||||
int mp_n_root_ex (mp_int * a, mp_digit b, mp_int * c, int fast);
|
||||
int mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast);
|
||||
*/
|
||||
|
||||
/* special sqrt algo */
|
||||
/*
|
||||
int mp_sqrt(mp_int *arg, mp_int *ret);
|
||||
int mp_sqrt(const mp_int *arg, mp_int *ret);
|
||||
*/
|
||||
|
||||
/* special sqrt (mod prime) */
|
||||
/*
|
||||
int mp_sqrtmod_prime(mp_int *arg, mp_int *prime, mp_int *ret);
|
||||
int mp_sqrtmod_prime(const mp_int *arg, const mp_int *prime, mp_int *ret);
|
||||
*/
|
||||
|
||||
/* is number a square? */
|
||||
/*
|
||||
int mp_is_square(mp_int *arg, int *ret);
|
||||
int mp_is_square(const mp_int *arg, int *ret);
|
||||
*/
|
||||
|
||||
/* computes the jacobi c = (a | n) (or Legendre if b is prime) */
|
||||
/*
|
||||
int mp_jacobi(mp_int *a, mp_int *n, int *c);
|
||||
int mp_jacobi(const mp_int *a, const mp_int *n, int *c);
|
||||
*/
|
||||
|
||||
/* used to setup the Barrett reduction for a given modulus b */
|
||||
/*
|
||||
int mp_reduce_setup(mp_int *a, mp_int *b);
|
||||
int mp_reduce_setup(mp_int *a, const mp_int *b);
|
||||
*/
|
||||
|
||||
/* Barrett Reduction, computes a (mod b) with a precomputed value c
|
||||
@@ -566,83 +577,83 @@ int mp_reduce_setup(mp_int *a, mp_int *b);
|
||||
* compute the reduction as -1 * mp_reduce(mp_abs(a)) [pseudo code].
|
||||
*/
|
||||
/*
|
||||
int mp_reduce(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_reduce(mp_int *a, const mp_int *b, const mp_int *c);
|
||||
*/
|
||||
|
||||
/* setups the montgomery reduction */
|
||||
/*
|
||||
int mp_montgomery_setup(mp_int *a, mp_digit *mp);
|
||||
int mp_montgomery_setup(const mp_int *a, mp_digit *mp);
|
||||
*/
|
||||
|
||||
/* computes a = B**n mod b without division or multiplication useful for
|
||||
* normalizing numbers in a Montgomery system.
|
||||
*/
|
||||
/*
|
||||
int mp_montgomery_calc_normalization(mp_int *a, mp_int *b);
|
||||
int mp_montgomery_calc_normalization(mp_int *a, const mp_int *b);
|
||||
*/
|
||||
|
||||
/* computes x/R == x (mod N) via Montgomery Reduction */
|
||||
/*
|
||||
int mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp);
|
||||
int mp_montgomery_reduce(mp_int *a, const mp_int *m, mp_digit mp);
|
||||
*/
|
||||
|
||||
/* returns 1 if a is a valid DR modulus */
|
||||
/*
|
||||
int mp_dr_is_modulus(mp_int *a);
|
||||
int mp_dr_is_modulus(const mp_int *a);
|
||||
*/
|
||||
|
||||
/* sets the value of "d" required for mp_dr_reduce */
|
||||
/*
|
||||
void mp_dr_setup(mp_int *a, mp_digit *d);
|
||||
void mp_dr_setup(const mp_int *a, mp_digit *d);
|
||||
*/
|
||||
|
||||
/* reduces a modulo b using the Diminished Radix method */
|
||||
/*
|
||||
int mp_dr_reduce(mp_int *a, mp_int *b, mp_digit mp);
|
||||
int mp_dr_reduce(mp_int *a, const mp_int *b, mp_digit mp);
|
||||
*/
|
||||
|
||||
/* returns true if a can be reduced with mp_reduce_2k */
|
||||
/*
|
||||
int mp_reduce_is_2k(mp_int *a);
|
||||
int mp_reduce_is_2k(const mp_int *a);
|
||||
*/
|
||||
|
||||
/* determines k value for 2k reduction */
|
||||
/*
|
||||
int mp_reduce_2k_setup(mp_int *a, mp_digit *d);
|
||||
int mp_reduce_2k_setup(const mp_int *a, mp_digit *d);
|
||||
*/
|
||||
|
||||
/* reduces a modulo b where b is of the form 2**p - k [0 <= a] */
|
||||
/*
|
||||
int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d);
|
||||
int mp_reduce_2k(mp_int *a, const mp_int *n, mp_digit d);
|
||||
*/
|
||||
|
||||
/* returns true if a can be reduced with mp_reduce_2k_l */
|
||||
/*
|
||||
int mp_reduce_is_2k_l(mp_int *a);
|
||||
int mp_reduce_is_2k_l(const mp_int *a);
|
||||
*/
|
||||
|
||||
/* determines k value for 2k reduction */
|
||||
/*
|
||||
int mp_reduce_2k_setup_l(mp_int *a, mp_int *d);
|
||||
int mp_reduce_2k_setup_l(const mp_int *a, mp_int *d);
|
||||
*/
|
||||
|
||||
/* reduces a modulo b where b is of the form 2**p - k [0 <= a] */
|
||||
/*
|
||||
int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d);
|
||||
int mp_reduce_2k_l(mp_int *a, const mp_int *n, const mp_int *d);
|
||||
*/
|
||||
|
||||
/* d = a**b (mod c) */
|
||||
/*
|
||||
int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
||||
int mp_exptmod(const mp_int *a, const mp_int *b, const mp_int *c, mp_int *d);
|
||||
*/
|
||||
|
||||
/* ---> Primes <--- */
|
||||
|
||||
/* number of primes */
|
||||
#ifdef MP_8BIT
|
||||
# define PRIME_SIZE 31
|
||||
# define PRIME_SIZE 31
|
||||
#else
|
||||
# define PRIME_SIZE 256
|
||||
# define PRIME_SIZE 256
|
||||
#endif
|
||||
|
||||
/* table of first PRIME_SIZE primes */
|
||||
@@ -652,21 +663,21 @@ MODULE_SCOPE const mp_digit ltm_prime_tab[PRIME_SIZE];
|
||||
|
||||
/* result=1 if a is divisible by one of the first PRIME_SIZE primes */
|
||||
/*
|
||||
int mp_prime_is_divisible(mp_int *a, int *result);
|
||||
int mp_prime_is_divisible(const mp_int *a, int *result);
|
||||
*/
|
||||
|
||||
/* performs one Fermat test of "a" using base "b".
|
||||
* Sets result to 0 if composite or 1 if probable prime
|
||||
*/
|
||||
/*
|
||||
int mp_prime_fermat(mp_int *a, mp_int *b, int *result);
|
||||
int mp_prime_fermat(const mp_int *a, const mp_int *b, int *result);
|
||||
*/
|
||||
|
||||
/* performs one Miller-Rabin test of "a" using base "b".
|
||||
* Sets result to 0 if composite or 1 if probable prime
|
||||
*/
|
||||
/*
|
||||
int mp_prime_miller_rabin(mp_int *a, mp_int *b, int *result);
|
||||
int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result);
|
||||
*/
|
||||
|
||||
/* This gives [for a given bit size] the number of trials required
|
||||
@@ -684,7 +695,7 @@ int mp_prime_rabin_miller_trials(int size);
|
||||
* Sets result to 1 if probably prime, 0 otherwise
|
||||
*/
|
||||
/*
|
||||
int mp_prime_is_prime(mp_int *a, int t, int *result);
|
||||
int mp_prime_is_prime(const mp_int *a, int t, int *result);
|
||||
*/
|
||||
|
||||
/* finds the next prime after the number "a" using "t" trials
|
||||
@@ -730,39 +741,39 @@ int mp_count_bits(const mp_int *a);
|
||||
*/
|
||||
|
||||
/*
|
||||
int mp_unsigned_bin_size(mp_int *a);
|
||||
int mp_unsigned_bin_size(const mp_int *a);
|
||||
*/
|
||||
/*
|
||||
int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c);
|
||||
*/
|
||||
/*
|
||||
int mp_to_unsigned_bin(mp_int *a, unsigned char *b);
|
||||
int mp_to_unsigned_bin(const mp_int *a, unsigned char *b);
|
||||
*/
|
||||
/*
|
||||
int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen);
|
||||
int mp_to_unsigned_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen);
|
||||
*/
|
||||
|
||||
/*
|
||||
int mp_signed_bin_size(mp_int *a);
|
||||
int mp_signed_bin_size(const mp_int *a);
|
||||
*/
|
||||
/*
|
||||
int mp_read_signed_bin(mp_int *a, const unsigned char *b, int c);
|
||||
*/
|
||||
/*
|
||||
int mp_to_signed_bin(mp_int *a, unsigned char *b);
|
||||
int mp_to_signed_bin(const mp_int *a, unsigned char *b);
|
||||
*/
|
||||
/*
|
||||
int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen);
|
||||
int mp_to_signed_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen);
|
||||
*/
|
||||
|
||||
/*
|
||||
int mp_read_radix(mp_int *a, const char *str, int radix);
|
||||
*/
|
||||
/*
|
||||
int mp_toradix(mp_int *a, char *str, int radix);
|
||||
int mp_toradix(const mp_int *a, char *str, int radix);
|
||||
*/
|
||||
/*
|
||||
int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen);
|
||||
int mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen);
|
||||
*/
|
||||
/*
|
||||
int mp_radix_size(const mp_int *a, int radix, int *size);
|
||||
@@ -773,7 +784,7 @@ int mp_radix_size(const mp_int *a, int radix, int *size);
|
||||
int mp_fread(mp_int *a, int radix, FILE *stream);
|
||||
*/
|
||||
/*
|
||||
int mp_fwrite(mp_int *a, int radix, FILE *stream);
|
||||
int mp_fwrite(const mp_int *a, int radix, FILE *stream);
|
||||
*/
|
||||
#endif
|
||||
|
||||
@@ -790,13 +801,13 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream);
|
||||
#define mp_tohex(M, S) mp_toradix((M), (S), 16)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
/* ref: $Format:%D$ */
|
||||
/* git commit: $Format:%H$ */
|
||||
/* commit time: $Format:%ai$ */
|
||||
|
||||
|
||||
+123
-79
@@ -74,6 +74,9 @@
|
||||
#define mp_exch TclBN_mp_exch
|
||||
#define mp_expt_d TclBN_mp_expt_d
|
||||
#define mp_expt_d_ex TclBN_mp_expt_d_ex
|
||||
#define mp_get_int TclBN_mp_get_int
|
||||
#define mp_get_long TclBN_mp_get_long
|
||||
#define mp_get_long_long TclBN_mp_get_long_long
|
||||
#define mp_grow TclBN_mp_grow
|
||||
#define mp_init TclBN_mp_init
|
||||
#define mp_init_copy TclBN_mp_init_copy
|
||||
@@ -98,6 +101,8 @@
|
||||
#define mp_s_rmap TclBNMpSRmap
|
||||
#define mp_set TclBN_mp_set
|
||||
#define mp_set_int TclBN_mp_set_int
|
||||
#define mp_set_long TclBN_mp_set_long
|
||||
#define mp_set_long_long TclBN_mp_set_long_long
|
||||
#define mp_shrink TclBN_mp_shrink
|
||||
#define mp_sqr TclBN_mp_sqr
|
||||
#define mp_sqrt TclBN_mp_sqrt
|
||||
@@ -148,11 +153,14 @@ EXTERN int TclBN_epoch(void);
|
||||
/* 1 */
|
||||
EXTERN int TclBN_revision(void);
|
||||
/* 2 */
|
||||
EXTERN int TclBN_mp_add(mp_int *a, mp_int *b, mp_int *c);
|
||||
EXTERN int TclBN_mp_add(const mp_int *a, const mp_int *b,
|
||||
mp_int *c);
|
||||
/* 3 */
|
||||
EXTERN int TclBN_mp_add_d(mp_int *a, mp_digit b, mp_int *c);
|
||||
EXTERN int TclBN_mp_add_d(const mp_int *a, mp_digit b,
|
||||
mp_int *c);
|
||||
/* 4 */
|
||||
EXTERN int TclBN_mp_and(mp_int *a, mp_int *b, mp_int *c);
|
||||
EXTERN int TclBN_mp_and(const mp_int *a, const mp_int *b,
|
||||
mp_int *c);
|
||||
/* 5 */
|
||||
EXTERN void TclBN_mp_clamp(mp_int *a);
|
||||
/* 6 */
|
||||
@@ -170,22 +178,24 @@ EXTERN int TclBN_mp_copy(const mp_int *a, mp_int *b);
|
||||
/* 12 */
|
||||
EXTERN int TclBN_mp_count_bits(const mp_int *a);
|
||||
/* 13 */
|
||||
EXTERN int TclBN_mp_div(mp_int *a, mp_int *b, mp_int *q,
|
||||
mp_int *r);
|
||||
EXTERN int TclBN_mp_div(const mp_int *a, const mp_int *b,
|
||||
mp_int *q, mp_int *r);
|
||||
/* 14 */
|
||||
EXTERN int TclBN_mp_div_d(mp_int *a, mp_digit b, mp_int *q,
|
||||
mp_digit *r);
|
||||
EXTERN int TclBN_mp_div_d(const mp_int *a, mp_digit b,
|
||||
mp_int *q, mp_digit *r);
|
||||
/* 15 */
|
||||
EXTERN int TclBN_mp_div_2(mp_int *a, mp_int *q);
|
||||
EXTERN int TclBN_mp_div_2(const mp_int *a, mp_int *q);
|
||||
/* 16 */
|
||||
EXTERN int TclBN_mp_div_2d(const mp_int *a, int b, mp_int *q,
|
||||
mp_int *r);
|
||||
/* 17 */
|
||||
EXTERN int TclBN_mp_div_3(mp_int *a, mp_int *q, mp_digit *r);
|
||||
EXTERN int TclBN_mp_div_3(const mp_int *a, mp_int *q,
|
||||
mp_digit *r);
|
||||
/* 18 */
|
||||
EXTERN void TclBN_mp_exch(mp_int *a, mp_int *b);
|
||||
/* 19 */
|
||||
EXTERN int TclBN_mp_expt_d(mp_int *a, mp_digit b, mp_int *c);
|
||||
EXTERN int TclBN_mp_expt_d(const mp_int *a, mp_digit b,
|
||||
mp_int *c);
|
||||
/* 20 */
|
||||
EXTERN int TclBN_mp_grow(mp_int *a, int size);
|
||||
/* 21 */
|
||||
@@ -201,21 +211,25 @@ EXTERN int TclBN_mp_init_size(mp_int *a, int size);
|
||||
/* 26 */
|
||||
EXTERN int TclBN_mp_lshd(mp_int *a, int shift);
|
||||
/* 27 */
|
||||
EXTERN int TclBN_mp_mod(mp_int *a, mp_int *b, mp_int *r);
|
||||
EXTERN int TclBN_mp_mod(const mp_int *a, const mp_int *b,
|
||||
mp_int *r);
|
||||
/* 28 */
|
||||
EXTERN int TclBN_mp_mod_2d(const mp_int *a, int b, mp_int *r);
|
||||
/* 29 */
|
||||
EXTERN int TclBN_mp_mul(mp_int *a, mp_int *b, mp_int *p);
|
||||
EXTERN int TclBN_mp_mul(const mp_int *a, const mp_int *b,
|
||||
mp_int *p);
|
||||
/* 30 */
|
||||
EXTERN int TclBN_mp_mul_d(mp_int *a, mp_digit b, mp_int *p);
|
||||
EXTERN int TclBN_mp_mul_d(const mp_int *a, mp_digit b,
|
||||
mp_int *p);
|
||||
/* 31 */
|
||||
EXTERN int TclBN_mp_mul_2(mp_int *a, mp_int *p);
|
||||
EXTERN int TclBN_mp_mul_2(const mp_int *a, mp_int *p);
|
||||
/* 32 */
|
||||
EXTERN int TclBN_mp_mul_2d(const mp_int *a, int d, mp_int *p);
|
||||
/* 33 */
|
||||
EXTERN int TclBN_mp_neg(const mp_int *a, mp_int *b);
|
||||
/* 34 */
|
||||
EXTERN int TclBN_mp_or(mp_int *a, mp_int *b, mp_int *c);
|
||||
EXTERN int TclBN_mp_or(const mp_int *a, const mp_int *b,
|
||||
mp_int *c);
|
||||
/* 35 */
|
||||
EXTERN int TclBN_mp_radix_size(const mp_int *a, int radix,
|
||||
int *size);
|
||||
@@ -229,52 +243,59 @@ EXTERN int TclBN_mp_shrink(mp_int *a);
|
||||
/* 39 */
|
||||
EXTERN void TclBN_mp_set(mp_int *a, mp_digit b);
|
||||
/* 40 */
|
||||
EXTERN int TclBN_mp_sqr(mp_int *a, mp_int *b);
|
||||
EXTERN int TclBN_mp_sqr(const mp_int *a, mp_int *b);
|
||||
/* 41 */
|
||||
EXTERN int TclBN_mp_sqrt(mp_int *a, mp_int *b);
|
||||
EXTERN int TclBN_mp_sqrt(const mp_int *a, mp_int *b);
|
||||
/* 42 */
|
||||
EXTERN int TclBN_mp_sub(mp_int *a, mp_int *b, mp_int *c);
|
||||
EXTERN int TclBN_mp_sub(const mp_int *a, const mp_int *b,
|
||||
mp_int *c);
|
||||
/* 43 */
|
||||
EXTERN int TclBN_mp_sub_d(mp_int *a, mp_digit b, mp_int *c);
|
||||
EXTERN int TclBN_mp_sub_d(const mp_int *a, mp_digit b,
|
||||
mp_int *c);
|
||||
/* 44 */
|
||||
EXTERN int TclBN_mp_to_unsigned_bin(mp_int *a, unsigned char *b);
|
||||
EXTERN int TclBN_mp_to_unsigned_bin(const mp_int *a,
|
||||
unsigned char *b);
|
||||
/* 45 */
|
||||
EXTERN int TclBN_mp_to_unsigned_bin_n(mp_int *a,
|
||||
EXTERN int TclBN_mp_to_unsigned_bin_n(const mp_int *a,
|
||||
unsigned char *b, unsigned long *outlen);
|
||||
/* 46 */
|
||||
EXTERN int TclBN_mp_toradix_n(mp_int *a, char *str, int radix,
|
||||
int maxlen);
|
||||
EXTERN int TclBN_mp_toradix_n(const mp_int *a, char *str,
|
||||
int radix, int maxlen);
|
||||
/* 47 */
|
||||
EXTERN int TclBN_mp_unsigned_bin_size(mp_int *a);
|
||||
EXTERN int TclBN_mp_unsigned_bin_size(const mp_int *a);
|
||||
/* 48 */
|
||||
EXTERN int TclBN_mp_xor(mp_int *a, mp_int *b, mp_int *c);
|
||||
EXTERN int TclBN_mp_xor(const mp_int *a, const mp_int *b,
|
||||
mp_int *c);
|
||||
/* 49 */
|
||||
EXTERN void TclBN_mp_zero(mp_int *a);
|
||||
/* 50 */
|
||||
EXTERN void TclBN_reverse(unsigned char *s, int len);
|
||||
/* 51 */
|
||||
EXTERN int TclBN_fast_s_mp_mul_digs(mp_int *a, mp_int *b,
|
||||
mp_int *c, int digs);
|
||||
EXTERN int TclBN_fast_s_mp_mul_digs(const mp_int *a,
|
||||
const mp_int *b, mp_int *c, int digs);
|
||||
/* 52 */
|
||||
EXTERN int TclBN_fast_s_mp_sqr(mp_int *a, mp_int *b);
|
||||
EXTERN int TclBN_fast_s_mp_sqr(const mp_int *a, mp_int *b);
|
||||
/* 53 */
|
||||
EXTERN int TclBN_mp_karatsuba_mul(mp_int *a, mp_int *b,
|
||||
mp_int *c);
|
||||
EXTERN int TclBN_mp_karatsuba_mul(const mp_int *a,
|
||||
const mp_int *b, mp_int *c);
|
||||
/* 54 */
|
||||
EXTERN int TclBN_mp_karatsuba_sqr(mp_int *a, mp_int *b);
|
||||
EXTERN int TclBN_mp_karatsuba_sqr(const mp_int *a, mp_int *b);
|
||||
/* 55 */
|
||||
EXTERN int TclBN_mp_toom_mul(mp_int *a, mp_int *b, mp_int *c);
|
||||
EXTERN int TclBN_mp_toom_mul(const mp_int *a, const mp_int *b,
|
||||
mp_int *c);
|
||||
/* 56 */
|
||||
EXTERN int TclBN_mp_toom_sqr(mp_int *a, mp_int *b);
|
||||
EXTERN int TclBN_mp_toom_sqr(const mp_int *a, mp_int *b);
|
||||
/* 57 */
|
||||
EXTERN int TclBN_s_mp_add(mp_int *a, mp_int *b, mp_int *c);
|
||||
EXTERN int TclBN_s_mp_add(const mp_int *a, const mp_int *b,
|
||||
mp_int *c);
|
||||
/* 58 */
|
||||
EXTERN int TclBN_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c,
|
||||
int digs);
|
||||
EXTERN int TclBN_s_mp_mul_digs(const mp_int *a, const mp_int *b,
|
||||
mp_int *c, int digs);
|
||||
/* 59 */
|
||||
EXTERN int TclBN_s_mp_sqr(mp_int *a, mp_int *b);
|
||||
EXTERN int TclBN_s_mp_sqr(const mp_int *a, mp_int *b);
|
||||
/* 60 */
|
||||
EXTERN int TclBN_s_mp_sub(mp_int *a, mp_int *b, mp_int *c);
|
||||
EXTERN int TclBN_s_mp_sub(const mp_int *a, const mp_int *b,
|
||||
mp_int *c);
|
||||
/* 61 */
|
||||
EXTERN int TclBN_mp_init_set_int(mp_int *a, unsigned long i);
|
||||
/* 62 */
|
||||
@@ -282,16 +303,27 @@ EXTERN int TclBN_mp_set_int(mp_int *a, unsigned long i);
|
||||
/* 63 */
|
||||
EXTERN int TclBN_mp_cnt_lsb(const mp_int *a);
|
||||
/* 64 */
|
||||
EXTERN void TclBNInitBignumFromLong(mp_int *bignum, long initVal);
|
||||
TCL_DEPRECATED("Use mp_init() + mp_set_long_long()")
|
||||
void TclBNInitBignumFromLong(mp_int *bignum, long initVal);
|
||||
/* 65 */
|
||||
EXTERN void TclBNInitBignumFromWideInt(mp_int *bignum,
|
||||
TCL_DEPRECATED("Use mp_init() + mp_set_long_long()")
|
||||
void TclBNInitBignumFromWideInt(mp_int *bignum,
|
||||
Tcl_WideInt initVal);
|
||||
/* 66 */
|
||||
EXTERN void TclBNInitBignumFromWideUInt(mp_int *bignum,
|
||||
TCL_DEPRECATED("Use mp_init() + mp_set_long_long()")
|
||||
void TclBNInitBignumFromWideUInt(mp_int *bignum,
|
||||
Tcl_WideUInt initVal);
|
||||
/* 67 */
|
||||
EXTERN int TclBN_mp_expt_d_ex(mp_int *a, mp_digit b, mp_int *c,
|
||||
int fast);
|
||||
EXTERN int TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b,
|
||||
mp_int *c, int fast);
|
||||
/* 68 */
|
||||
EXTERN int TclBN_mp_set_long_long(mp_int *a, Tcl_WideUInt i);
|
||||
/* 69 */
|
||||
EXTERN Tcl_WideUInt TclBN_mp_get_long_long(const mp_int *a);
|
||||
/* 70 */
|
||||
EXTERN int TclBN_mp_set_long(mp_int *a, unsigned long i);
|
||||
/* 71 */
|
||||
EXTERN unsigned long TclBN_mp_get_long(const mp_int *a);
|
||||
|
||||
typedef struct TclTomMathStubs {
|
||||
int magic;
|
||||
@@ -299,9 +331,9 @@ typedef struct TclTomMathStubs {
|
||||
|
||||
int (*tclBN_epoch) (void); /* 0 */
|
||||
int (*tclBN_revision) (void); /* 1 */
|
||||
int (*tclBN_mp_add) (mp_int *a, mp_int *b, mp_int *c); /* 2 */
|
||||
int (*tclBN_mp_add_d) (mp_int *a, mp_digit b, mp_int *c); /* 3 */
|
||||
int (*tclBN_mp_and) (mp_int *a, mp_int *b, mp_int *c); /* 4 */
|
||||
int (*tclBN_mp_add) (const mp_int *a, const mp_int *b, mp_int *c); /* 2 */
|
||||
int (*tclBN_mp_add_d) (const mp_int *a, mp_digit b, mp_int *c); /* 3 */
|
||||
int (*tclBN_mp_and) (const mp_int *a, const mp_int *b, mp_int *c); /* 4 */
|
||||
void (*tclBN_mp_clamp) (mp_int *a); /* 5 */
|
||||
void (*tclBN_mp_clear) (mp_int *a); /* 6 */
|
||||
void (*tclBN_mp_clear_multi) (mp_int *a, ...); /* 7 */
|
||||
@@ -310,13 +342,13 @@ typedef struct TclTomMathStubs {
|
||||
int (*tclBN_mp_cmp_mag) (const mp_int *a, const mp_int *b); /* 10 */
|
||||
int (*tclBN_mp_copy) (const mp_int *a, mp_int *b); /* 11 */
|
||||
int (*tclBN_mp_count_bits) (const mp_int *a); /* 12 */
|
||||
int (*tclBN_mp_div) (mp_int *a, mp_int *b, mp_int *q, mp_int *r); /* 13 */
|
||||
int (*tclBN_mp_div_d) (mp_int *a, mp_digit b, mp_int *q, mp_digit *r); /* 14 */
|
||||
int (*tclBN_mp_div_2) (mp_int *a, mp_int *q); /* 15 */
|
||||
int (*tclBN_mp_div) (const mp_int *a, const mp_int *b, mp_int *q, mp_int *r); /* 13 */
|
||||
int (*tclBN_mp_div_d) (const mp_int *a, mp_digit b, mp_int *q, mp_digit *r); /* 14 */
|
||||
int (*tclBN_mp_div_2) (const mp_int *a, mp_int *q); /* 15 */
|
||||
int (*tclBN_mp_div_2d) (const mp_int *a, int b, mp_int *q, mp_int *r); /* 16 */
|
||||
int (*tclBN_mp_div_3) (mp_int *a, mp_int *q, mp_digit *r); /* 17 */
|
||||
int (*tclBN_mp_div_3) (const mp_int *a, mp_int *q, mp_digit *r); /* 17 */
|
||||
void (*tclBN_mp_exch) (mp_int *a, mp_int *b); /* 18 */
|
||||
int (*tclBN_mp_expt_d) (mp_int *a, mp_digit b, mp_int *c); /* 19 */
|
||||
int (*tclBN_mp_expt_d) (const mp_int *a, mp_digit b, mp_int *c); /* 19 */
|
||||
int (*tclBN_mp_grow) (mp_int *a, int size); /* 20 */
|
||||
int (*tclBN_mp_init) (mp_int *a); /* 21 */
|
||||
int (*tclBN_mp_init_copy) (mp_int *a, const mp_int *b); /* 22 */
|
||||
@@ -324,47 +356,51 @@ typedef struct TclTomMathStubs {
|
||||
int (*tclBN_mp_init_set) (mp_int *a, mp_digit b); /* 24 */
|
||||
int (*tclBN_mp_init_size) (mp_int *a, int size); /* 25 */
|
||||
int (*tclBN_mp_lshd) (mp_int *a, int shift); /* 26 */
|
||||
int (*tclBN_mp_mod) (mp_int *a, mp_int *b, mp_int *r); /* 27 */
|
||||
int (*tclBN_mp_mod) (const mp_int *a, const mp_int *b, mp_int *r); /* 27 */
|
||||
int (*tclBN_mp_mod_2d) (const mp_int *a, int b, mp_int *r); /* 28 */
|
||||
int (*tclBN_mp_mul) (mp_int *a, mp_int *b, mp_int *p); /* 29 */
|
||||
int (*tclBN_mp_mul_d) (mp_int *a, mp_digit b, mp_int *p); /* 30 */
|
||||
int (*tclBN_mp_mul_2) (mp_int *a, mp_int *p); /* 31 */
|
||||
int (*tclBN_mp_mul) (const mp_int *a, const mp_int *b, mp_int *p); /* 29 */
|
||||
int (*tclBN_mp_mul_d) (const mp_int *a, mp_digit b, mp_int *p); /* 30 */
|
||||
int (*tclBN_mp_mul_2) (const mp_int *a, mp_int *p); /* 31 */
|
||||
int (*tclBN_mp_mul_2d) (const mp_int *a, int d, mp_int *p); /* 32 */
|
||||
int (*tclBN_mp_neg) (const mp_int *a, mp_int *b); /* 33 */
|
||||
int (*tclBN_mp_or) (mp_int *a, mp_int *b, mp_int *c); /* 34 */
|
||||
int (*tclBN_mp_or) (const mp_int *a, const mp_int *b, mp_int *c); /* 34 */
|
||||
int (*tclBN_mp_radix_size) (const mp_int *a, int radix, int *size); /* 35 */
|
||||
int (*tclBN_mp_read_radix) (mp_int *a, const char *str, int radix); /* 36 */
|
||||
void (*tclBN_mp_rshd) (mp_int *a, int shift); /* 37 */
|
||||
int (*tclBN_mp_shrink) (mp_int *a); /* 38 */
|
||||
void (*tclBN_mp_set) (mp_int *a, mp_digit b); /* 39 */
|
||||
int (*tclBN_mp_sqr) (mp_int *a, mp_int *b); /* 40 */
|
||||
int (*tclBN_mp_sqrt) (mp_int *a, mp_int *b); /* 41 */
|
||||
int (*tclBN_mp_sub) (mp_int *a, mp_int *b, mp_int *c); /* 42 */
|
||||
int (*tclBN_mp_sub_d) (mp_int *a, mp_digit b, mp_int *c); /* 43 */
|
||||
int (*tclBN_mp_to_unsigned_bin) (mp_int *a, unsigned char *b); /* 44 */
|
||||
int (*tclBN_mp_to_unsigned_bin_n) (mp_int *a, unsigned char *b, unsigned long *outlen); /* 45 */
|
||||
int (*tclBN_mp_toradix_n) (mp_int *a, char *str, int radix, int maxlen); /* 46 */
|
||||
int (*tclBN_mp_unsigned_bin_size) (mp_int *a); /* 47 */
|
||||
int (*tclBN_mp_xor) (mp_int *a, mp_int *b, mp_int *c); /* 48 */
|
||||
int (*tclBN_mp_sqr) (const mp_int *a, mp_int *b); /* 40 */
|
||||
int (*tclBN_mp_sqrt) (const mp_int *a, mp_int *b); /* 41 */
|
||||
int (*tclBN_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c); /* 42 */
|
||||
int (*tclBN_mp_sub_d) (const mp_int *a, mp_digit b, mp_int *c); /* 43 */
|
||||
int (*tclBN_mp_to_unsigned_bin) (const mp_int *a, unsigned char *b); /* 44 */
|
||||
int (*tclBN_mp_to_unsigned_bin_n) (const mp_int *a, unsigned char *b, unsigned long *outlen); /* 45 */
|
||||
int (*tclBN_mp_toradix_n) (const mp_int *a, char *str, int radix, int maxlen); /* 46 */
|
||||
int (*tclBN_mp_unsigned_bin_size) (const mp_int *a); /* 47 */
|
||||
int (*tclBN_mp_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 48 */
|
||||
void (*tclBN_mp_zero) (mp_int *a); /* 49 */
|
||||
void (*tclBN_reverse) (unsigned char *s, int len); /* 50 */
|
||||
int (*tclBN_fast_s_mp_mul_digs) (mp_int *a, mp_int *b, mp_int *c, int digs); /* 51 */
|
||||
int (*tclBN_fast_s_mp_sqr) (mp_int *a, mp_int *b); /* 52 */
|
||||
int (*tclBN_mp_karatsuba_mul) (mp_int *a, mp_int *b, mp_int *c); /* 53 */
|
||||
int (*tclBN_mp_karatsuba_sqr) (mp_int *a, mp_int *b); /* 54 */
|
||||
int (*tclBN_mp_toom_mul) (mp_int *a, mp_int *b, mp_int *c); /* 55 */
|
||||
int (*tclBN_mp_toom_sqr) (mp_int *a, mp_int *b); /* 56 */
|
||||
int (*tclBN_s_mp_add) (mp_int *a, mp_int *b, mp_int *c); /* 57 */
|
||||
int (*tclBN_s_mp_mul_digs) (mp_int *a, mp_int *b, mp_int *c, int digs); /* 58 */
|
||||
int (*tclBN_s_mp_sqr) (mp_int *a, mp_int *b); /* 59 */
|
||||
int (*tclBN_s_mp_sub) (mp_int *a, mp_int *b, mp_int *c); /* 60 */
|
||||
int (*tclBN_fast_s_mp_mul_digs) (const mp_int *a, const mp_int *b, mp_int *c, int digs); /* 51 */
|
||||
int (*tclBN_fast_s_mp_sqr) (const mp_int *a, mp_int *b); /* 52 */
|
||||
int (*tclBN_mp_karatsuba_mul) (const mp_int *a, const mp_int *b, mp_int *c); /* 53 */
|
||||
int (*tclBN_mp_karatsuba_sqr) (const mp_int *a, mp_int *b); /* 54 */
|
||||
int (*tclBN_mp_toom_mul) (const mp_int *a, const mp_int *b, mp_int *c); /* 55 */
|
||||
int (*tclBN_mp_toom_sqr) (const mp_int *a, mp_int *b); /* 56 */
|
||||
int (*tclBN_s_mp_add) (const mp_int *a, const mp_int *b, mp_int *c); /* 57 */
|
||||
int (*tclBN_s_mp_mul_digs) (const mp_int *a, const mp_int *b, mp_int *c, int digs); /* 58 */
|
||||
int (*tclBN_s_mp_sqr) (const mp_int *a, mp_int *b); /* 59 */
|
||||
int (*tclBN_s_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c); /* 60 */
|
||||
int (*tclBN_mp_init_set_int) (mp_int *a, unsigned long i); /* 61 */
|
||||
int (*tclBN_mp_set_int) (mp_int *a, unsigned long i); /* 62 */
|
||||
int (*tclBN_mp_cnt_lsb) (const mp_int *a); /* 63 */
|
||||
void (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */
|
||||
void (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */
|
||||
void (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */
|
||||
int (*tclBN_mp_expt_d_ex) (mp_int *a, mp_digit b, mp_int *c, int fast); /* 67 */
|
||||
TCL_DEPRECATED_API("Use mp_init() + mp_set_long_long()") void (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */
|
||||
TCL_DEPRECATED_API("Use mp_init() + mp_set_long_long()") void (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */
|
||||
TCL_DEPRECATED_API("Use mp_init() + mp_set_long_long()") void (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */
|
||||
int (*tclBN_mp_expt_d_ex) (const mp_int *a, mp_digit b, mp_int *c, int fast); /* 67 */
|
||||
int (*tclBN_mp_set_long_long) (mp_int *a, Tcl_WideUInt i); /* 68 */
|
||||
Tcl_WideUInt (*tclBN_mp_get_long_long) (const mp_int *a); /* 69 */
|
||||
int (*tclBN_mp_set_long) (mp_int *a, unsigned long i); /* 70 */
|
||||
unsigned long (*tclBN_mp_get_long) (const mp_int *a); /* 71 */
|
||||
} TclTomMathStubs;
|
||||
|
||||
extern const TclTomMathStubs *tclTomMathStubsPtr;
|
||||
@@ -515,6 +551,14 @@ extern const TclTomMathStubs *tclTomMathStubsPtr;
|
||||
(tclTomMathStubsPtr->tclBNInitBignumFromWideUInt) /* 66 */
|
||||
#define TclBN_mp_expt_d_ex \
|
||||
(tclTomMathStubsPtr->tclBN_mp_expt_d_ex) /* 67 */
|
||||
#define TclBN_mp_set_long_long \
|
||||
(tclTomMathStubsPtr->tclBN_mp_set_long_long) /* 68 */
|
||||
#define TclBN_mp_get_long_long \
|
||||
(tclTomMathStubsPtr->tclBN_mp_get_long_long) /* 69 */
|
||||
#define TclBN_mp_set_long \
|
||||
(tclTomMathStubsPtr->tclBN_mp_set_long) /* 70 */
|
||||
#define TclBN_mp_get_long \
|
||||
(tclTomMathStubsPtr->tclBN_mp_get_long) /* 71 */
|
||||
|
||||
#endif /* defined(USE_TCL_STUBS) */
|
||||
|
||||
|
||||
+23
-143
@@ -89,86 +89,11 @@ TclBN_revision(void)
|
||||
{
|
||||
return TCLTOMMATH_REVISION;
|
||||
}
|
||||
#if 0
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TclBNAlloc --
|
||||
*
|
||||
* Allocate memory for libtommath.
|
||||
*
|
||||
* Results:
|
||||
* Returns a pointer to the allocated block.
|
||||
*
|
||||
* This procedure is a wrapper around Tcl_Alloc, needed because of a
|
||||
* mismatched type signature between Tcl_Alloc and malloc.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern void *
|
||||
TclBNAlloc(
|
||||
size_t x)
|
||||
{
|
||||
return (void *) ckalloc((unsigned int) x);
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TclBNRealloc --
|
||||
*
|
||||
* Change the size of an allocated block of memory in libtommath
|
||||
*
|
||||
* Results:
|
||||
* Returns a pointer to the allocated block.
|
||||
*
|
||||
* This procedure is a wrapper around Tcl_Realloc, needed because of a
|
||||
* mismatched type signature between Tcl_Realloc and realloc.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void *
|
||||
TclBNRealloc(
|
||||
void *p,
|
||||
size_t s)
|
||||
{
|
||||
return (void *) ckrealloc((char *) p, (unsigned int) s);
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TclBNFree --
|
||||
*
|
||||
* Free allocated memory in libtommath.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side effects:
|
||||
* Memory is freed.
|
||||
*
|
||||
* This function is simply a wrapper around Tcl_Free, needed in libtommath
|
||||
* because of a type mismatch between free and Tcl_Free.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern void
|
||||
TclBNFree(
|
||||
void *p)
|
||||
{
|
||||
ckree((char *) p);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TclBNInitBignumFromLong --
|
||||
* TclInitBignumFromLong --
|
||||
*
|
||||
* Allocate and initialize a 'bignum' from a native 'long'.
|
||||
*
|
||||
@@ -181,47 +106,20 @@ TclBNFree(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern void
|
||||
TclBNInitBignumFromLong(
|
||||
void
|
||||
TclInitBignumFromLong(
|
||||
mp_int *a,
|
||||
long initVal)
|
||||
long v)
|
||||
{
|
||||
int status;
|
||||
unsigned long v;
|
||||
mp_digit *p;
|
||||
|
||||
/*
|
||||
* Allocate enough memory to hold the largest possible long
|
||||
*/
|
||||
|
||||
status = mp_init_size(a,
|
||||
(CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) / DIGIT_BIT);
|
||||
if (status != MP_OKAY) {
|
||||
Tcl_Panic("initialization failure in TclBNInitBignumFromLong");
|
||||
if (mp_init_size(a, (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) {
|
||||
Tcl_Panic("initialization failure in TclInitBignumFromLong");
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert arg to sign and magnitude.
|
||||
*/
|
||||
|
||||
if (initVal < 0) {
|
||||
a->sign = MP_NEG;
|
||||
v = -initVal;
|
||||
if (v < (long)0) {
|
||||
mp_set_long_long(a, (Tcl_WideUInt)(-(Tcl_WideInt)v));
|
||||
mp_neg(a, a);
|
||||
} else {
|
||||
a->sign = MP_ZPOS;
|
||||
v = initVal;
|
||||
mp_set_long_long(a, (Tcl_WideUInt)v);
|
||||
}
|
||||
|
||||
/*
|
||||
* Store the magnitude in the bignum.
|
||||
*/
|
||||
|
||||
p = a->dp;
|
||||
while (v) {
|
||||
*p++ = (mp_digit) (v & MP_MASK);
|
||||
v >>= MP_DIGIT_BIT;
|
||||
}
|
||||
a->used = p - a->dp;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -240,16 +138,19 @@ TclBNInitBignumFromLong(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern void
|
||||
TclBNInitBignumFromWideInt(
|
||||
void
|
||||
TclInitBignumFromWideInt(
|
||||
mp_int *a, /* Bignum to initialize */
|
||||
Tcl_WideInt v) /* Initial value */
|
||||
{
|
||||
if (mp_init_size(a, (CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) {
|
||||
Tcl_Panic("initialization failure in TclInitBignumFromWideInt");
|
||||
}
|
||||
if (v < (Tcl_WideInt)0) {
|
||||
TclBNInitBignumFromWideUInt(a, (Tcl_WideUInt)(-v));
|
||||
mp_set_long_long(a, (Tcl_WideUInt)(-v));
|
||||
mp_neg(a, a);
|
||||
} else {
|
||||
TclBNInitBignumFromWideUInt(a, (Tcl_WideUInt)v);
|
||||
mp_set_long_long(a, (Tcl_WideUInt)v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,36 +170,15 @@ TclBNInitBignumFromWideInt(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern void
|
||||
TclBNInitBignumFromWideUInt(
|
||||
void
|
||||
TclInitBignumFromWideUInt(
|
||||
mp_int *a, /* Bignum to initialize */
|
||||
Tcl_WideUInt v) /* Initial value */
|
||||
{
|
||||
int status;
|
||||
mp_digit *p;
|
||||
|
||||
/*
|
||||
* Allocate enough memory to hold the largest possible Tcl_WideUInt.
|
||||
*/
|
||||
|
||||
status = mp_init_size(a,
|
||||
(CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT);
|
||||
if (status != MP_OKAY) {
|
||||
Tcl_Panic("initialization failure in TclBNInitBignumFromWideUInt");
|
||||
}
|
||||
|
||||
a->sign = MP_ZPOS;
|
||||
|
||||
/*
|
||||
* Store the magnitude in the bignum.
|
||||
*/
|
||||
|
||||
p = a->dp;
|
||||
while (v) {
|
||||
*p++ = (mp_digit) (v & MP_MASK);
|
||||
v >>= MP_DIGIT_BIT;
|
||||
}
|
||||
a->used = p - a->dp;
|
||||
if (mp_init_size(a, (CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) {
|
||||
Tcl_Panic("initialization failure in TclInitBignumFromWideUInt");
|
||||
}
|
||||
mp_set_long_long(a, v);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+149
-58
@@ -253,6 +253,15 @@ Tcl_UniCharToUtfDString(
|
||||
* Tcl_UtfCharComplete() before calling this routine to ensure that
|
||||
* enough bytes remain in the string.
|
||||
*
|
||||
* If TCL_UTF_MAX == 4, special handling of Surrogate pairs is done:
|
||||
* For any UTF-8 string containing a character outside of the BMP, the
|
||||
* first call to this function will fill *chPtr with the high surrogate
|
||||
* and generate a return value of 0. Calling Tcl_UtfToUniChar again
|
||||
* will produce the low surrogate and a return value of 4. Because *chPtr
|
||||
* is used to remember whether the high surrogate is already produced, it
|
||||
* is recommended to initialize the variable it points to as 0 before
|
||||
* the first call to Tcl_UtfToUniChar is done.
|
||||
*
|
||||
* Results:
|
||||
* *chPtr is filled with the Tcl_UniChar, and the return value is the
|
||||
* number of bytes from the UTF-8 string that were consumed.
|
||||
@@ -272,7 +281,7 @@ Tcl_UtfToUniChar(
|
||||
register int byte;
|
||||
|
||||
/*
|
||||
* Unroll 1 to 3 byte UTF-8 sequences, use loop to handle longer ones.
|
||||
* Unroll 1 to 3 (or 4) byte UTF-8 sequences.
|
||||
*/
|
||||
|
||||
byte = *((unsigned char *) src);
|
||||
@@ -325,12 +334,30 @@ Tcl_UtfToUniChar(
|
||||
/*
|
||||
* Four-byte-character lead byte followed by three trail bytes.
|
||||
*/
|
||||
#if TCL_UTF_MAX == 4
|
||||
Tcl_UniChar surrogate;
|
||||
|
||||
byte = (((byte & 0x07) << 18) | ((src[1] & 0x3F) << 12)
|
||||
| ((src[2] & 0x3F) << 6) | (src[3] & 0x3F)) - 0x10000;
|
||||
surrogate = (Tcl_UniChar) (0xD800 + (byte >> 10));
|
||||
if (byte & 0x100000) {
|
||||
/* out of range, < 0x10000 or > 0x10ffff */
|
||||
} else if (*chPtr != surrogate) {
|
||||
/* produce high surrogate, but don't advance source pointer */
|
||||
*chPtr = surrogate;
|
||||
return 0;
|
||||
} else {
|
||||
/* produce low surrogate, and advance source pointer */
|
||||
*chPtr = (Tcl_UniChar) (0xDC00 | (byte & 0x3FF));
|
||||
return 4;
|
||||
}
|
||||
#else
|
||||
*chPtr = (Tcl_UniChar) (((byte & 0x07) << 18) | ((src[1] & 0x3F) << 12)
|
||||
| ((src[2] & 0x3F) << 6) | (src[3] & 0x3F));
|
||||
if ((unsigned)(*chPtr - 0x10000) <= 0xFFFFF) {
|
||||
return 4;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -371,7 +398,7 @@ Tcl_UtfToUniCharDString(
|
||||
* appended to this previously initialized
|
||||
* DString. */
|
||||
{
|
||||
Tcl_UniChar *w, *wString;
|
||||
Tcl_UniChar ch, *w, *wString;
|
||||
const char *p, *end;
|
||||
int oldLength;
|
||||
|
||||
@@ -393,8 +420,8 @@ Tcl_UtfToUniCharDString(
|
||||
w = wString;
|
||||
end = src + length;
|
||||
for (p = src; p < end; ) {
|
||||
p += TclUtfToUniChar(p, w);
|
||||
w++;
|
||||
p += TclUtfToUniChar(p, &ch);
|
||||
*w++ = ch;
|
||||
}
|
||||
*w = '\0';
|
||||
Tcl_DStringSetLength(dsPtr,
|
||||
@@ -428,10 +455,7 @@ Tcl_UtfCharComplete(
|
||||
* a complete UTF-8 character. */
|
||||
int length) /* Length of above string in bytes. */
|
||||
{
|
||||
int ch;
|
||||
|
||||
ch = *((unsigned char *) src);
|
||||
return length >= totalBytes[ch];
|
||||
return length >= totalBytes[(unsigned char)*src];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -458,8 +482,8 @@ Tcl_NumUtfChars(
|
||||
int length) /* The length of the string in bytes, or -1
|
||||
* for strlen(string). */
|
||||
{
|
||||
Tcl_UniChar ch;
|
||||
register int i;
|
||||
Tcl_UniChar ch = 0;
|
||||
register int i = 0, n;
|
||||
|
||||
/*
|
||||
* The separate implementations are faster.
|
||||
@@ -468,10 +492,13 @@ Tcl_NumUtfChars(
|
||||
* single-byte char case specially.
|
||||
*/
|
||||
|
||||
i = 0;
|
||||
if (length < 0) {
|
||||
while (*src != '\0') {
|
||||
src += TclUtfToUniChar(src, &ch);
|
||||
n = TclUtfToUniChar(src, &ch);
|
||||
if (!n) {
|
||||
n = Tcl_UtfToUniChar(src, &ch);
|
||||
}
|
||||
src += n;
|
||||
i++;
|
||||
}
|
||||
if (i < 0) i = INT_MAX; /* Bug [2738427] */
|
||||
@@ -479,12 +506,20 @@ Tcl_NumUtfChars(
|
||||
register const char *endPtr = src + length - TCL_UTF_MAX;
|
||||
|
||||
while (src < endPtr) {
|
||||
src += TclUtfToUniChar(src, &ch);
|
||||
n = TclUtfToUniChar(src, &ch);
|
||||
if (!n) {
|
||||
n = Tcl_UtfToUniChar(src, &ch);
|
||||
}
|
||||
src += n;
|
||||
i++;
|
||||
}
|
||||
endPtr += TCL_UTF_MAX;
|
||||
while ((src < endPtr) && Tcl_UtfCharComplete(src, endPtr - src)) {
|
||||
src += TclUtfToUniChar(src, &ch);
|
||||
n = TclUtfToUniChar(src, &ch);
|
||||
if (!n) {
|
||||
n = Tcl_UtfToUniChar(src, &ch);
|
||||
}
|
||||
src += n;
|
||||
i++;
|
||||
}
|
||||
if (src < endPtr) {
|
||||
@@ -519,7 +554,7 @@ Tcl_UtfFindFirst(
|
||||
int ch) /* The Tcl_UniChar to search for. */
|
||||
{
|
||||
int len;
|
||||
Tcl_UniChar find;
|
||||
Tcl_UniChar find = 0;
|
||||
|
||||
while (1) {
|
||||
len = TclUtfToUniChar(src, &find);
|
||||
@@ -558,7 +593,7 @@ Tcl_UtfFindLast(
|
||||
int ch) /* The Tcl_UniChar to search for. */
|
||||
{
|
||||
int len;
|
||||
Tcl_UniChar find;
|
||||
Tcl_UniChar find = 0;
|
||||
const char *last;
|
||||
|
||||
last = NULL;
|
||||
@@ -598,9 +633,15 @@ const char *
|
||||
Tcl_UtfNext(
|
||||
const char *src) /* The current location in the string. */
|
||||
{
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
int len = TclUtfToUniChar(src, &ch);
|
||||
|
||||
return src + TclUtfToUniChar(src, &ch);
|
||||
#if TCL_UTF_MAX == 4
|
||||
if (len == 0) {
|
||||
len = TclUtfToUniChar(src, &ch);
|
||||
}
|
||||
#endif
|
||||
return src + len;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -633,8 +674,7 @@ Tcl_UtfPrev(
|
||||
const char *look;
|
||||
int i, byte;
|
||||
|
||||
src--;
|
||||
look = src;
|
||||
look = --src;
|
||||
for (i = 0; i < TCL_UTF_MAX; i++) {
|
||||
if (look < start) {
|
||||
if (src < start) {
|
||||
@@ -671,16 +711,25 @@ Tcl_UtfPrev(
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Tcl_UniChar
|
||||
int
|
||||
Tcl_UniCharAtIndex(
|
||||
register const char *src, /* The UTF-8 string to dereference. */
|
||||
register int index) /* The position of the desired character. */
|
||||
{
|
||||
Tcl_UniChar ch = 0;
|
||||
Tcl_UniChar unichar = 0;
|
||||
int bytes;
|
||||
int ch = 0;
|
||||
|
||||
while (index >= 0) {
|
||||
index--;
|
||||
src += TclUtfToUniChar(src, &ch);
|
||||
while (index-- >= 0) {
|
||||
bytes = TclUtfToUniChar(src, &unichar);
|
||||
ch = unichar;
|
||||
if (!bytes) {
|
||||
/* TclUtfToUniChar only returns 0 for chars > 0xffff ! */
|
||||
bytes = TclUtfToUniChar(src, &unichar);
|
||||
/* Combine surrogates */
|
||||
ch = (((ch & 0x3ff) << 10) | (unichar & 0x3ff)) + 0x10000;
|
||||
}
|
||||
src += bytes;
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
@@ -707,11 +756,16 @@ Tcl_UtfAtIndex(
|
||||
register const char *src, /* The UTF-8 string. */
|
||||
register int index) /* The position of the desired character. */
|
||||
{
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
int len;
|
||||
|
||||
while (index > 0) {
|
||||
index--;
|
||||
src += TclUtfToUniChar(src, &ch);
|
||||
len = TclUtfToUniChar(src, &ch);
|
||||
if (!len) {
|
||||
len = TclUtfToUniChar(src, &ch);
|
||||
}
|
||||
src += len;
|
||||
}
|
||||
return src;
|
||||
}
|
||||
@@ -791,7 +845,8 @@ int
|
||||
Tcl_UtfToUpper(
|
||||
char *str) /* String to convert in place. */
|
||||
{
|
||||
Tcl_UniChar ch, upChar;
|
||||
Tcl_UniChar ch = 0;
|
||||
int upChar;
|
||||
char *src, *dst;
|
||||
int bytes;
|
||||
|
||||
@@ -802,7 +857,14 @@ Tcl_UtfToUpper(
|
||||
src = dst = str;
|
||||
while (*src) {
|
||||
bytes = TclUtfToUniChar(src, &ch);
|
||||
upChar = Tcl_UniCharToUpper(ch);
|
||||
upChar = ch;
|
||||
if (!bytes) {
|
||||
/* TclUtfToUniChar only returns 0 for chars > 0xffff ! */
|
||||
bytes = TclUtfToUniChar(src, &ch);
|
||||
/* Combine surrogates */
|
||||
upChar = (((upChar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000;
|
||||
}
|
||||
upChar = Tcl_UniCharToUpper(upChar);
|
||||
|
||||
/*
|
||||
* To keep badly formed Utf strings from getting inflated by the
|
||||
@@ -844,7 +906,8 @@ int
|
||||
Tcl_UtfToLower(
|
||||
char *str) /* String to convert in place. */
|
||||
{
|
||||
Tcl_UniChar ch, lowChar;
|
||||
Tcl_UniChar ch = 0;
|
||||
int lowChar;
|
||||
char *src, *dst;
|
||||
int bytes;
|
||||
|
||||
@@ -855,7 +918,14 @@ Tcl_UtfToLower(
|
||||
src = dst = str;
|
||||
while (*src) {
|
||||
bytes = TclUtfToUniChar(src, &ch);
|
||||
lowChar = Tcl_UniCharToLower(ch);
|
||||
lowChar = ch;
|
||||
if (!bytes) {
|
||||
/* TclUtfToUniChar only returns 0 for chars > 0xffff ! */
|
||||
bytes = TclUtfToUniChar(src, &ch);
|
||||
/* Combine surrogates */
|
||||
lowChar = (((lowChar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000;
|
||||
}
|
||||
lowChar = Tcl_UniCharToLower(lowChar);
|
||||
|
||||
/*
|
||||
* To keep badly formed Utf strings from getting inflated by the
|
||||
@@ -898,7 +968,8 @@ int
|
||||
Tcl_UtfToTitle(
|
||||
char *str) /* String to convert in place. */
|
||||
{
|
||||
Tcl_UniChar ch, titleChar, lowChar;
|
||||
Tcl_UniChar ch = 0;
|
||||
int titleChar, lowChar;
|
||||
char *src, *dst;
|
||||
int bytes;
|
||||
|
||||
@@ -911,7 +982,14 @@ Tcl_UtfToTitle(
|
||||
|
||||
if (*src) {
|
||||
bytes = TclUtfToUniChar(src, &ch);
|
||||
titleChar = Tcl_UniCharToTitle(ch);
|
||||
titleChar = ch;
|
||||
if (!bytes) {
|
||||
/* TclUtfToUniChar only returns 0 for chars > 0xffff ! */
|
||||
bytes = TclUtfToUniChar(src, &ch);
|
||||
/* Combine surrogates */
|
||||
titleChar = (((titleChar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000;
|
||||
}
|
||||
titleChar = Tcl_UniCharToTitle(titleChar);
|
||||
|
||||
if (bytes < TclUtfCount(titleChar)) {
|
||||
memcpy(dst, src, (size_t) bytes);
|
||||
@@ -923,7 +1001,14 @@ Tcl_UtfToTitle(
|
||||
}
|
||||
while (*src) {
|
||||
bytes = TclUtfToUniChar(src, &ch);
|
||||
lowChar = Tcl_UniCharToLower(ch);
|
||||
lowChar = ch;
|
||||
if (!bytes) {
|
||||
/* TclUtfToUniChar only returns 0 for chars > 0xffff ! */
|
||||
bytes = TclUtfToUniChar(src, &ch);
|
||||
/* Combine surrogates */
|
||||
lowChar = (((lowChar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000;
|
||||
}
|
||||
lowChar = Tcl_UniCharToLower(lowChar);
|
||||
|
||||
if (bytes < TclUtfCount(lowChar)) {
|
||||
memcpy(dst, src, (size_t) bytes);
|
||||
@@ -1007,7 +1092,7 @@ Tcl_UtfNcmp(
|
||||
const char *ct, /* UTF string cs is compared to. */
|
||||
unsigned long numChars) /* Number of UTF chars to compare. */
|
||||
{
|
||||
Tcl_UniChar ch1, ch2;
|
||||
Tcl_UniChar ch1 = 0, ch2 = 0;
|
||||
|
||||
/*
|
||||
* Cannot use 'memcmp(cs, ct, n);' as byte representation of \u0000 (the
|
||||
@@ -1055,7 +1140,7 @@ Tcl_UtfNcasecmp(
|
||||
const char *ct, /* UTF string cs is compared to. */
|
||||
unsigned long numChars) /* Number of UTF chars to compare. */
|
||||
{
|
||||
Tcl_UniChar ch1, ch2;
|
||||
Tcl_UniChar ch1 = 0, ch2 = 0;
|
||||
while (numChars-- > 0) {
|
||||
/*
|
||||
* n must be interpreted as chars, not bytes.
|
||||
@@ -1131,16 +1216,18 @@ TclUtfCasecmp(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Tcl_UniChar
|
||||
int
|
||||
Tcl_UniCharToUpper(
|
||||
int ch) /* Unicode character to convert. */
|
||||
{
|
||||
int info = GetUniCharInfo(ch);
|
||||
if (!UNICODE_OUT_OF_RANGE(ch)) {
|
||||
int info = GetUniCharInfo(ch);
|
||||
|
||||
if (GetCaseType(info) & 0x04) {
|
||||
ch -= GetDelta(info);
|
||||
if (GetCaseType(info) & 0x04) {
|
||||
ch -= GetDelta(info);
|
||||
}
|
||||
}
|
||||
return (Tcl_UniChar) ch;
|
||||
return ch & 0x1FFFFF;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1159,16 +1246,18 @@ Tcl_UniCharToUpper(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Tcl_UniChar
|
||||
int
|
||||
Tcl_UniCharToLower(
|
||||
int ch) /* Unicode character to convert. */
|
||||
{
|
||||
int info = GetUniCharInfo(ch);
|
||||
if (!UNICODE_OUT_OF_RANGE(ch)) {
|
||||
int info = GetUniCharInfo(ch);
|
||||
|
||||
if (GetCaseType(info) & 0x02) {
|
||||
ch += GetDelta(info);
|
||||
if (GetCaseType(info) & 0x02) {
|
||||
ch += GetDelta(info);
|
||||
}
|
||||
}
|
||||
return (Tcl_UniChar) ch;
|
||||
return ch & 0x1FFFFF;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1187,23 +1276,25 @@ Tcl_UniCharToLower(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Tcl_UniChar
|
||||
int
|
||||
Tcl_UniCharToTitle(
|
||||
int ch) /* Unicode character to convert. */
|
||||
{
|
||||
int info = GetUniCharInfo(ch);
|
||||
int mode = GetCaseType(info);
|
||||
if (!UNICODE_OUT_OF_RANGE(ch)) {
|
||||
int info = GetUniCharInfo(ch);
|
||||
int mode = GetCaseType(info);
|
||||
|
||||
if (mode & 0x1) {
|
||||
/*
|
||||
* Subtract or add one depending on the original case.
|
||||
*/
|
||||
if (mode & 0x1) {
|
||||
/*
|
||||
* Subtract or add one depending on the original case.
|
||||
*/
|
||||
|
||||
ch += ((mode & 0x4) ? -1 : 1);
|
||||
} else if (mode == 0x4) {
|
||||
ch -= GetDelta(info);
|
||||
ch += ((mode & 0x4) ? -1 : 1);
|
||||
} else if (mode == 0x4) {
|
||||
ch -= GetDelta(info);
|
||||
}
|
||||
}
|
||||
return (Tcl_UniChar) ch;
|
||||
return ch & 0x1FFFFF;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1684,7 +1775,7 @@ Tcl_UniCharCaseMatch(
|
||||
* characters. */
|
||||
int nocase) /* 0 for case sensitive, 1 for insensitive */
|
||||
{
|
||||
Tcl_UniChar ch1, p;
|
||||
Tcl_UniChar ch1 = 0, p;
|
||||
|
||||
while (1) {
|
||||
p = *uniPattern;
|
||||
|
||||
+1
-1
@@ -1646,7 +1646,7 @@ Tcl_Backslash(
|
||||
* src, unless NULL. */
|
||||
{
|
||||
char buf[TCL_UTF_MAX];
|
||||
Tcl_UniChar ch;
|
||||
Tcl_UniChar ch = 0;
|
||||
|
||||
Tcl_UtfBackslash(src, readPtr, buf);
|
||||
TclUtfToUniChar(buf, &ch);
|
||||
|
||||
+2
-2
@@ -203,7 +203,7 @@ proc auto_mkindex {dir args} {
|
||||
}
|
||||
|
||||
auto_mkindex_parser::init
|
||||
foreach file [glob -- {*}$args] {
|
||||
foreach file [lsort [glob -- {*}$args]] {
|
||||
try {
|
||||
append index [auto_mkindex_parser::mkindex $file]
|
||||
} on error {msg opts} {
|
||||
@@ -236,7 +236,7 @@ proc auto_mkindex_old {dir args} {
|
||||
if {![llength $args]} {
|
||||
set args *.tcl
|
||||
}
|
||||
foreach file [glob -- {*}$args] {
|
||||
foreach file [lsort [glob -- {*}$args]] {
|
||||
set f ""
|
||||
set error [catch {
|
||||
set f [open $file]
|
||||
|
||||
Regular → Executable
@@ -11,7 +11,7 @@
|
||||
package require Tcl 8.6-
|
||||
# Keep this in sync with pkgIndex.tcl and with the install directories in
|
||||
# Makefiles
|
||||
package provide http 2.8.11
|
||||
package provide http 2.8.12
|
||||
|
||||
namespace eval http {
|
||||
# Allow resourcing to not clobber existing data
|
||||
@@ -1027,6 +1027,7 @@ proc http::Event {sock token} {
|
||||
# We have now read all headers
|
||||
# We ignore HTTP/1.1 100 Continue returns. RFC2616 sec 8.2.3
|
||||
if {$state(http) == "" || ([regexp {^\S+\s(\d+)} $state(http) {} x] && $x == 100)} {
|
||||
set state(state) "connecting"
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
if {![package vsatisfies [package provide Tcl] 8.6-]} {return}
|
||||
package ifneeded http 2.8.11 [list tclPkgSetup $dir http 2.8.11 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}]
|
||||
package ifneeded http 2.8.12 [list tclPkgSetup $dir http 2.8.12 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}]
|
||||
|
||||
+30
-24
@@ -16,7 +16,7 @@
|
||||
if {[info commands package] == ""} {
|
||||
error "version mismatch: library\nscripts expect Tcl version 7.5b1 or later but the loaded version is\nonly [info patchlevel]"
|
||||
}
|
||||
package require -exact Tcl 8.7a0
|
||||
package require -exact Tcl 8.7a2
|
||||
|
||||
# Compute the auto path to use in this interpreter.
|
||||
# The values on the path come from several locations:
|
||||
@@ -286,14 +286,9 @@ proc unknown args {
|
||||
}
|
||||
append cinfo ...
|
||||
}
|
||||
append cinfo "\"\n (\"uplevel\" body line 1)"
|
||||
append cinfo "\n invoked from within"
|
||||
append cinfo "\n\"uplevel 1 \$args\""
|
||||
#
|
||||
# Try each possible form of the stack trace
|
||||
# and trim the extra contribution from the matching case
|
||||
#
|
||||
set expect "$msg\n while executing\n\"$cinfo"
|
||||
set tail "\n (\"uplevel\" body line 1)\n invoked\
|
||||
from within\n\"uplevel 1 \$args\""
|
||||
set expect "$msg\n while executing\n\"$cinfo\"$tail"
|
||||
if {$errInfo eq $expect} {
|
||||
#
|
||||
# The stack has only the eval from the expanded command
|
||||
@@ -307,21 +302,32 @@ proc unknown args {
|
||||
# Stack trace is nested, trim off just the contribution
|
||||
# from the extra "eval" of $args due to the "catch" above.
|
||||
#
|
||||
set expect "\n invoked from within\n\"$cinfo"
|
||||
set exlen [string length $expect]
|
||||
set eilen [string length $errInfo]
|
||||
set i [expr {$eilen - $exlen - 1}]
|
||||
set einfo [string range $errInfo 0 $i]
|
||||
#
|
||||
# For now verify that $errInfo consists of what we are about
|
||||
# to return plus what we expected to trim off.
|
||||
#
|
||||
if {$errInfo ne "$einfo$expect"} {
|
||||
error "Tcl bug: unexpected stack trace in \"unknown\"" {} \
|
||||
[list CORE UNKNOWN BADTRACE $einfo $expect $errInfo]
|
||||
set last [string last $tail $errInfo]
|
||||
if {$last + [string length $tail] != [string length $errInfo]} {
|
||||
# Very likely cannot happen
|
||||
return -options $opts $msg
|
||||
}
|
||||
return -code error -errorcode $errCode \
|
||||
-errorinfo $einfo $msg
|
||||
set errInfo [string range $errInfo 0 $last-1]
|
||||
set tail "\"$cinfo\""
|
||||
set last [string last $tail $errInfo]
|
||||
if {$last + [string length $tail] != [string length $errInfo]} {
|
||||
return -code error -errorcode $errCode \
|
||||
-errorinfo $errInfo $msg
|
||||
}
|
||||
set errInfo [string range $errInfo 0 $last-1]
|
||||
set tail "\n invoked from within\n"
|
||||
set last [string last $tail $errInfo]
|
||||
if {$last + [string length $tail] == [string length $errInfo]} {
|
||||
return -code error -errorcode $errCode \
|
||||
-errorinfo [string range $errInfo 0 $last-1] $msg
|
||||
}
|
||||
set tail "\n while executing\n"
|
||||
set last [string last $tail $errInfo]
|
||||
if {$last + [string length $tail] == [string length $errInfo]} {
|
||||
return -code error -errorcode $errCode \
|
||||
-errorinfo [string range $errInfo 0 $last-1] $msg
|
||||
}
|
||||
return -options $opts $msg
|
||||
} else {
|
||||
dict incr opts -level
|
||||
return -options $opts $msg
|
||||
@@ -636,7 +642,7 @@ proc auto_import {pattern} {
|
||||
if {$tcl_platform(platform) eq "windows"} {
|
||||
# Windows version.
|
||||
#
|
||||
# Note that info executable doesn't work under Windows, so we have to
|
||||
# Note that file executable doesn't work under Windows, so we have to
|
||||
# look for files with .exe, .com, or .bat extensions. Also, the path
|
||||
# may be in the Path or PATH environment variables, and path
|
||||
# components are separated with semicolons, not colons as under Unix.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
package require Tcl 8.5-
|
||||
# When the version number changes, be sure to update the pkgIndex.tcl file,
|
||||
# and the installation directory in the Makefiles.
|
||||
package provide msgcat 1.6.0
|
||||
package provide msgcat 1.6.1
|
||||
|
||||
namespace eval msgcat {
|
||||
namespace export mc mcexists mcload mclocale mcmax mcmset mcpreferences mcset\
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
if {![package vsatisfies [package provide Tcl] 8.5]} {return}
|
||||
package ifneeded msgcat 1.6.0 [list source [file join $dir msgcat.tcl]]
|
||||
if {![package vsatisfies [package provide Tcl] 8.5-]} {return}
|
||||
package ifneeded msgcat 1.6.1 [list source [file join $dir msgcat.tcl]]
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user