Attachment "2215022.patch" to
ticket [2215022fff]
added by
patthoyts
2008-11-07 07:09:20.
0000: 64 69 66 66 20 2d 2d 67 69 74 20 61 2f 64 6f 63 diff --git a/doc
0010: 2f 42 79 74 65 41 72 72 4f 62 6a 2e 33 20 62 2f /ByteArrObj.3 b/
0020: 64 6f 63 2f 42 79 74 65 41 72 72 4f 62 6a 2e 33 doc/ByteArrObj.3
0030: 0a 69 6e 64 65 78 20 64 32 32 39 33 65 32 2e 2e .index d2293e2..
0040: 38 65 63 31 65 62 39 20 31 30 30 36 34 34 0a 2d 8ec1eb9 100644.-
0050: 2d 2d 20 61 2f 64 6f 63 2f 42 79 74 65 41 72 72 -- a/doc/ByteArr
0060: 4f 62 6a 2e 33 0a 2b 2b 2b 20 62 2f 64 6f 63 2f Obj.3.+++ b/doc/
0070: 42 79 74 65 41 72 72 4f 62 6a 2e 33 0a 40 40 20 ByteArrObj.3.@@
0080: 2d 32 39 2c 37 20 2b 32 39 2c 38 20 40 40 20 75 -29,7 +29,8 @@ u
0090: 6e 73 69 67 6e 65 64 20 63 68 61 72 20 2a 0a 20 nsigned char *.
00a0: 2e 53 48 20 41 52 47 55 4d 45 4e 54 53 0a 20 2e .SH ARGUMENTS. .
00b0: 41 53 20 22 63 6f 6e 73 74 20 75 6e 73 69 67 6e AS "const unsign
00c0: 65 64 20 63 68 61 72 22 20 2a 6c 65 6e 67 74 68 ed char" *length
00d0: 50 74 72 20 69 6e 2f 6f 75 74 0a 20 2e 41 50 20 Ptr in/out. .AP
00e0: 22 63 6f 6e 73 74 20 75 6e 73 69 67 6e 65 64 20 "const unsigned
00f0: 63 68 61 72 22 20 2a 62 79 74 65 73 20 69 6e 0a char" *bytes in.
0100: 2d 54 68 65 20 61 72 72 61 79 20 6f 66 20 62 79 -The array of by
0110: 74 65 73 20 75 73 65 64 20 74 6f 20 69 6e 69 74 tes used to init
0120: 69 61 6c 69 7a 65 20 6f 72 20 73 65 74 20 61 20 ialize or set a
0130: 62 79 74 65 2d 61 72 72 61 79 20 6f 62 6a 65 63 byte-array objec
0140: 74 2e 0a 2b 54 68 65 20 61 72 72 61 79 20 6f 66 t..+The array of
0150: 20 62 79 74 65 73 20 75 73 65 64 20 74 6f 20 69 bytes used to i
0160: 6e 69 74 69 61 6c 69 7a 65 20 6f 72 20 73 65 74 nitialize or set
0170: 20 61 20 62 79 74 65 2d 61 72 72 61 79 20 6f 62 a byte-array ob
0180: 6a 65 63 74 2e 20 4d 61 79 20 62 65 20 4e 55 4c ject. May be NUL
0190: 4c 0a 2b 65 76 65 6e 20 69 66 20 5c 66 49 6c 65 L.+even if \fIle
01a0: 6e 67 74 68 5c 66 52 20 69 73 20 6e 6f 6e 2d 7a ngth\fR is non-z
01b0: 65 72 6f 2e 0a 20 2e 41 50 20 69 6e 74 20 6c 65 ero.. .AP int le
01c0: 6e 67 74 68 20 69 6e 0a 20 54 68 65 20 6c 65 6e ngth in. The len
01d0: 67 74 68 20 6f 66 20 74 68 65 20 61 72 72 61 79 gth of the array
01e0: 20 6f 66 20 62 79 74 65 73 2e 20 20 49 74 20 6d of bytes. It m
01f0: 75 73 74 20 62 65 20 3e 3d 20 30 2e 0a 20 2e 41 ust be >= 0.. .A
0200: 50 20 54 63 6c 5f 4f 62 6a 20 2a 6f 62 6a 50 74 P Tcl_Obj *objPt
0210: 72 20 69 6e 2f 6f 75 74 0a 40 40 20 2d 35 35 2c r in/out.@@ -55,
0220: 37 20 2b 35 36 2c 37 20 40 40 20 62 79 74 65 2d 7 +56,7 @@ byte-
0230: 61 72 72 61 79 20 6f 72 20 74 6f 20 63 6f 6e 76 array or to conv
0240: 65 72 74 20 61 6e 20 61 72 62 69 74 72 61 72 79 ert an arbitrary
0250: 20 6f 62 6a 65 63 74 20 74 6f 20 61 20 62 79 74 object to a byt
0260: 65 2d 61 72 72 61 79 2e 20 20 4f 62 74 61 69 6e e-array. Obtain
0270: 69 6e 67 20 74 68 65 0a 20 73 74 72 69 6e 67 20 ing the. string
0280: 72 65 70 72 65 73 65 6e 74 61 74 69 6f 6e 20 6f representation o
0290: 66 20 61 20 62 79 74 65 2d 61 72 72 61 79 20 6f f a byte-array o
02a0: 62 6a 65 63 74 20 28 62 79 20 63 61 6c 6c 69 6e bject (by callin
02b0: 67 0a 20 5c 66 42 54 63 6c 5f 47 65 74 53 74 72 g. \fBTcl_GetStr
02c0: 69 6e 67 46 72 6f 6d 4f 62 6a 5c 66 52 29 20 70 ingFromObj\fR) p
02d0: 72 6f 64 75 63 65 73 20 61 20 70 72 6f 70 65 72 roduces a proper
02e0: 6c 79 20 66 6f 72 6d 65 64 20 55 54 46 2d 38 20 ly formed UTF-8
02f0: 73 65 71 75 65 6e 63 65 20 77 69 74 68 20 61 0a sequence with a.
0300: 20 6f 6e 65 2d 74 6f 2d 6f 6e 65 20 6d 61 70 70 one-to-one mapp
0310: 69 6e 67 20 62 65 74 77 65 65 6e 20 74 68 65 20 ing between the
0320: 62 79 74 65 73 20 69 6e 20 74 68 65 20 69 6e 74 bytes in the int
0330: 65 72 6e 61 6c 20 72 65 70 72 65 73 65 6e 74 61 ernal representa
0340: 74 69 6f 6e 20 61 6e 64 20 74 68 65 0a 2d 55 54 tion and the.-UT
0350: 46 2d 38 20 63 68 61 72 61 63 74 65 72 73 20 69 F-8 characters i
0360: 6e 20 74 68 65 20 73 74 72 69 6e 67 20 72 65 70 n the string rep
0370: 72 65 73 65 6e 74 61 74 69 6f 6e 2e 20 20 0a 2b resentation. .+
0380: 55 54 46 2d 38 20 63 68 61 72 61 63 74 65 72 73 UTF-8 characters
0390: 20 69 6e 20 74 68 65 20 73 74 72 69 6e 67 20 72 in the string r
03a0: 65 70 72 65 73 65 6e 74 61 74 69 6f 6e 2e 0a 20 epresentation..
03b0: 2e 50 50 0a 20 5c 66 42 54 63 6c 5f 4e 65 77 42 .PP. \fBTcl_NewB
03c0: 79 74 65 41 72 72 61 79 4f 62 6a 5c 66 52 20 61 yteArrayObj\fR a
03d0: 6e 64 20 5c 66 42 54 63 6c 5f 53 65 74 42 79 74 nd \fBTcl_SetByt
03e0: 65 41 72 72 61 79 4f 62 6a 5c 66 52 20 77 69 6c eArrayObj\fR wil
03f0: 6c 0a 20 63 72 65 61 74 65 20 61 20 6e 65 77 20 l. create a new
0400: 6f 62 6a 65 63 74 20 6f 66 20 62 79 74 65 2d 61 object of byte-a
0410: 72 72 61 79 20 74 79 70 65 20 6f 72 20 6d 6f 64 rray type or mod
0420: 69 66 79 20 61 6e 20 65 78 69 73 74 69 6e 67 20 ify an existing
0430: 6f 62 6a 65 63 74 20 74 6f 20 68 61 76 65 20 61 object to have a
0440: 0a 40 40 20 2d 36 35 2c 37 20 2b 36 36 2c 38 20 .@@ -65,7 +66,8
0450: 40 40 20 61 72 72 61 79 20 6f 66 20 62 79 74 65 @@ array of byte
0460: 73 20 67 69 76 65 6e 20 62 79 20 5c 66 49 62 79 s given by \fIby
0470: 74 65 73 5c 66 52 2e 20 5c 66 42 54 63 6c 5f 4e tes\fR. \fBTcl_N
0480: 65 77 42 79 74 65 41 72 72 61 79 4f 62 6a 5c 66 ewByteArrayObj\f
0490: 52 20 72 65 74 75 72 6e 73 20 61 0a 20 70 6f 69 R returns a. poi
04a0: 6e 74 65 72 20 74 6f 20 61 20 6e 65 77 6c 79 20 nter to a newly
04b0: 61 6c 6c 6f 63 61 74 65 64 20 6f 62 6a 65 63 74 allocated object
04c0: 20 77 69 74 68 20 61 20 72 65 66 65 72 65 6e 63 with a referenc
04d0: 65 20 63 6f 75 6e 74 20 6f 66 20 7a 65 72 6f 2e e count of zero.
04e0: 0a 20 5c 66 42 54 63 6c 5f 53 65 74 42 79 74 65 . \fBTcl_SetByte
04f0: 41 72 72 61 79 4f 62 6a 5c 66 52 20 69 6e 76 61 ArrayObj\fR inva
0500: 6c 69 64 61 74 65 73 20 61 6e 79 20 6f 6c 64 20 lidates any old
0510: 73 74 72 69 6e 67 20 72 65 70 72 65 73 65 6e 74 string represent
0520: 61 74 69 6f 6e 20 61 6e 64 2c 20 69 66 0a 20 74 ation and, if. t
0530: 68 65 20 6f 62 6a 65 63 74 20 69 73 20 6e 6f 74 he object is not
0540: 20 61 6c 72 65 61 64 79 20 61 20 62 79 74 65 2d already a byte-
0550: 61 72 72 61 79 20 6f 62 6a 65 63 74 2c 20 66 72 array object, fr
0560: 65 65 73 20 61 6e 79 20 6f 6c 64 20 69 6e 74 65 ees any old inte
0570: 72 6e 61 6c 0a 2d 72 65 70 72 65 73 65 6e 74 61 rnal.-representa
0580: 74 69 6f 6e 2e 0a 2b 72 65 70 72 65 73 65 6e 74 tion..+represent
0590: 61 74 69 6f 6e 2e 20 49 66 20 5c 66 49 62 79 74 ation. If \fIbyt
05a0: 65 73 5c 66 52 20 69 73 20 4e 55 4c 4c 20 74 68 es\fR is NULL th
05b0: 65 6e 20 74 68 65 20 6e 65 77 20 62 79 74 65 20 en the new byte
05c0: 61 72 72 61 79 20 63 6f 6e 74 61 69 6e 73 0a 2b array contains.+
05d0: 61 72 62 69 74 72 61 72 79 20 76 61 6c 75 65 73 arbitrary values
05e0: 2e 0a 20 2e 50 50 0a 20 5c 66 42 54 63 6c 5f 47 .. .PP. \fBTcl_G
05f0: 65 74 42 79 74 65 41 72 72 61 79 46 72 6f 6d 4f etByteArrayFromO
0600: 62 6a 5c 66 52 20 63 6f 6e 76 65 72 74 73 20 61 bj\fR converts a
0610: 20 54 63 6c 20 6f 62 6a 65 63 74 20 74 6f 20 62 Tcl object to b
0620: 79 74 65 2d 61 72 72 61 79 20 74 79 70 65 20 61 yte-array type a
0630: 6e 64 0a 20 72 65 74 75 72 6e 73 20 61 20 70 6f nd. returns a po
0640: 69 6e 74 65 72 20 74 6f 20 74 68 65 20 6f 62 6a inter to the obj
0650: 65 63 74 27 73 20 6e 65 77 20 69 6e 74 65 72 6e ect's new intern
0660: 61 6c 20 72 65 70 72 65 73 65 6e 74 61 74 69 6f al representatio
0670: 6e 20 61 73 20 61 6e 20 61 72 72 61 79 20 6f 66 n as an array of
0680: 0a 40 40 20 2d 37 33 2c 37 20 2b 37 35 2c 37 20 .@@ -73,7 +75,7
0690: 40 40 20 62 79 74 65 73 2e 20 20 54 68 65 20 6c @@ bytes. The l
06a0: 65 6e 67 74 68 20 6f 66 20 74 68 69 73 20 61 72 ength of this ar
06b0: 72 61 79 20 69 73 20 73 74 6f 72 65 64 20 69 6e ray is stored in
06c0: 20 5c 66 49 6c 65 6e 67 74 68 50 74 72 5c 66 52 \fIlengthPtr\fR
06d0: 20 69 66 0a 20 5c 66 49 6c 65 6e 67 74 68 50 74 if. \fIlengthPt
06e0: 72 5c 66 52 20 69 73 20 6e 6f 6e 2d 4e 55 4c 4c r\fR is non-NULL
06f0: 2e 20 20 54 68 65 20 73 74 6f 72 61 67 65 20 66 . The storage f
0700: 6f 72 20 74 68 65 20 61 72 72 61 79 20 6f 66 20 or the array of
0710: 62 79 74 65 73 20 69 73 20 6f 77 6e 65 64 20 62 bytes is owned b
0720: 79 0a 20 74 68 65 20 6f 62 6a 65 63 74 20 61 6e y. the object an
0730: 64 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 20 d should not be
0740: 66 72 65 65 64 2e 20 20 54 68 65 20 63 6f 6e 74 freed. The cont
0750: 65 6e 74 73 20 6f 66 20 74 68 65 20 61 72 72 61 ents of the arra
0760: 79 20 6d 61 79 20 62 65 0a 20 6d 6f 64 69 66 69 y may be. modifi
0770: 65 64 20 62 79 20 74 68 65 20 63 61 6c 6c 65 72 ed by the caller
0780: 20 6f 6e 6c 79 20 69 66 20 74 68 65 20 6f 62 6a only if the obj
0790: 65 63 74 20 69 73 20 6e 6f 74 20 73 68 61 72 65 ect is not share
07a0: 64 20 61 6e 64 20 74 68 65 20 63 61 6c 6c 65 72 d and the caller
07b0: 0a 2d 69 6e 76 61 6c 69 64 61 74 65 73 20 74 68 .-invalidates th
07c0: 65 20 73 74 72 69 6e 67 20 72 65 70 72 65 73 65 e string represe
07d0: 6e 74 61 74 69 6f 6e 2e 20 20 0a 2b 69 6e 76 61 ntation. .+inva
07e0: 6c 69 64 61 74 65 73 20 74 68 65 20 73 74 72 69 lidates the stri
07f0: 6e 67 20 72 65 70 72 65 73 65 6e 74 61 74 69 6f ng representatio
0800: 6e 2e 0a 20 2e 50 50 0a 20 5c 66 42 54 63 6c 5f n.. .PP. \fBTcl_
0810: 53 65 74 42 79 74 65 41 72 72 61 79 4c 65 6e 67 SetByteArrayLeng
0820: 74 68 5c 66 52 20 63 6f 6e 76 65 72 74 73 20 74 th\fR converts t
0830: 68 65 20 54 63 6c 20 6f 62 6a 65 63 74 20 74 6f he Tcl object to
0840: 20 62 79 74 65 2d 61 72 72 61 79 20 74 79 70 65 byte-array type
0850: 0a 20 61 6e 64 20 63 68 61 6e 67 65 73 20 74 68 . and changes th
0860: 65 20 6c 65 6e 67 74 68 20 6f 66 20 74 68 65 20 e length of the
0870: 6f 62 6a 65 63 74 27 73 20 69 6e 74 65 72 6e 61 object's interna
0880: 6c 20 72 65 70 72 65 73 65 6e 74 61 74 69 6f 6e l representation
0890: 20 61 73 20 61 6e 0a 64 69 66 66 20 2d 2d 67 69 as an.diff --gi
08a0: 74 20 61 2f 67 65 6e 65 72 69 63 2f 74 63 6c 42 t a/generic/tclB
08b0: 69 6e 61 72 79 2e 63 20 62 2f 67 65 6e 65 72 69 inary.c b/generi
08c0: 63 2f 74 63 6c 42 69 6e 61 72 79 2e 63 0a 69 6e c/tclBinary.c.in
08d0: 64 65 78 20 35 31 31 62 63 33 61 2e 2e 61 61 64 dex 511bc3a..aad
08e0: 64 31 65 35 20 31 30 30 36 34 34 0a 2d 2d 2d 20 d1e5 100644.---
08f0: 61 2f 67 65 6e 65 72 69 63 2f 74 63 6c 42 69 6e a/generic/tclBin
0900: 61 72 79 2e 63 0a 2b 2b 2b 20 62 2f 67 65 6e 65 ary.c.+++ b/gene
0910: 72 69 63 2f 74 63 6c 42 69 6e 61 72 79 2e 63 0a ric/tclBinary.c.
0920: 40 40 20 2d 33 31 32 2c 39 20 2b 33 31 32 2c 39 @@ -312,9 +312,9
0930: 20 40 40 20 76 6f 69 64 0a 20 54 63 6c 5f 53 65 @@ void. Tcl_Se
0940: 74 42 79 74 65 41 72 72 61 79 4f 62 6a 28 0a 20 tByteArrayObj(.
0950: 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 6f 62 6a Tcl_Obj *obj
0960: 50 74 72 2c 09 09 2f 2a 20 4f 62 6a 65 63 74 20 Ptr,../* Object
0970: 74 6f 20 69 6e 69 74 69 61 6c 69 7a 65 20 61 73 to initialize as
0980: 20 61 20 42 79 74 65 41 72 72 61 79 2e 20 2a 2f a ByteArray. */
0990: 0a 20 20 20 20 20 63 6f 6e 73 74 20 75 6e 73 69 . const unsi
09a0: 67 6e 65 64 20 63 68 61 72 20 2a 62 79 74 65 73 gned char *bytes
09b0: 2c 09 2f 2a 20 54 68 65 20 61 72 72 61 79 20 6f ,./* The array o
09c0: 66 20 62 79 74 65 73 20 74 6f 20 75 73 65 20 61 f bytes to use a
09d0: 73 20 74 68 65 20 6e 65 77 0a 2d 09 09 09 09 20 s the new.-....
09e0: 2a 20 76 61 6c 75 65 2e 20 2a 2f 0a 2d 20 20 20 * value. */.-
09f0: 20 69 6e 74 20 6c 65 6e 67 74 68 29 09 09 09 2f int length).../
0a00: 2a 20 4c 65 6e 67 74 68 20 6f 66 20 74 68 65 20 * Length of the
0a10: 61 72 72 61 79 20 6f 66 20 62 79 74 65 73 2c 20 array of bytes,
0a20: 77 68 69 63 68 20 6d 75 73 74 20 62 65 0a 2d 09 which must be.-.
0a30: 09 09 09 20 2a 20 3e 3d 20 30 2e 20 2a 2f 0a 2b ... * >= 0. */.+
0a40: 09 09 09 09 20 20 20 76 61 6c 75 65 2e 20 4d 61 .... value. Ma
0a50: 79 20 62 65 20 4e 55 4c 4c 20 65 76 65 6e 20 69 y be NULL even i
0a60: 66 20 6c 65 6e 67 74 68 20 3e 20 30 2e 20 2a 2f f length > 0. */
0a70: 0a 2b 20 20 20 20 69 6e 74 20 6c 65 6e 67 74 68 .+ int length
0a80: 29 09 09 09 2f 2a 20 4c 65 6e 67 74 68 20 6f 66 ).../* Length of
0a90: 20 74 68 65 20 61 72 72 61 79 20 6f 66 20 62 79 the array of by
0aa0: 74 65 73 2c 20 77 68 69 63 68 20 6d 75 73 74 0a tes, which must.
0ab0: 2b 09 09 09 09 20 20 20 62 65 20 3e 3d 20 30 2e +.... be >= 0.
0ac0: 20 2a 2f 0a 20 7b 0a 20 20 20 20 20 42 79 74 65 */. {. Byte
0ad0: 41 72 72 61 79 20 2a 62 79 74 65 41 72 72 61 79 Array *byteArray
0ae0: 50 74 72 3b 0a 20 0a 40 40 20 2d 33 32 34 2c 31 Ptr;. .@@ -324,1
0af0: 30 20 2b 33 32 34 2c 31 33 20 40 40 20 54 63 6c 0 +324,13 @@ Tcl
0b00: 5f 53 65 74 42 79 74 65 41 72 72 61 79 4f 62 6a _SetByteArrayObj
0b10: 28 0a 20 20 20 20 20 54 63 6c 46 72 65 65 49 6e (. TclFreeIn
0b20: 74 52 65 70 28 6f 62 6a 50 74 72 29 3b 0a 20 20 tRep(objPtr);.
0b30: 20 20 20 54 63 6c 5f 49 6e 76 61 6c 69 64 61 74 Tcl_Invalidat
0b40: 65 53 74 72 69 6e 67 52 65 70 28 6f 62 6a 50 74 eStringRep(objPt
0b50: 72 29 3b 0a 20 0a 2b 20 20 20 20 6c 65 6e 67 74 r);. .+ lengt
0b60: 68 20 3d 20 28 6c 65 6e 67 74 68 20 3c 20 30 29 h = (length < 0)
0b70: 20 3f 20 30 20 3a 20 6c 65 6e 67 74 68 3b 0a 20 ? 0 : length;.
0b80: 20 20 20 20 62 79 74 65 41 72 72 61 79 50 74 72 byteArrayPtr
0b90: 20 3d 20 28 42 79 74 65 41 72 72 61 79 20 2a 29 = (ByteArray *)
0ba0: 20 63 6b 61 6c 6c 6f 63 28 42 59 54 45 41 52 52 ckalloc(BYTEARR
0bb0: 41 59 5f 53 49 5a 45 28 6c 65 6e 67 74 68 29 29 AY_SIZE(length))
0bc0: 3b 0a 20 20 20 20 20 62 79 74 65 41 72 72 61 79 ;. byteArray
0bd0: 50 74 72 2d 3e 75 73 65 64 20 3d 20 6c 65 6e 67 Ptr->used = leng
0be0: 74 68 3b 0a 20 20 20 20 20 62 79 74 65 41 72 72 th;. byteArr
0bf0: 61 79 50 74 72 2d 3e 61 6c 6c 6f 63 61 74 65 64 ayPtr->allocated
0c00: 20 3d 20 6c 65 6e 67 74 68 3b 0a 2d 20 20 20 20 = length;.-
0c10: 6d 65 6d 63 70 79 28 62 79 74 65 41 72 72 61 79 memcpy(byteArray
0c20: 50 74 72 2d 3e 62 79 74 65 73 2c 20 62 79 74 65 Ptr->bytes, byte
0c30: 73 2c 20 28 73 69 7a 65 5f 74 29 20 6c 65 6e 67 s, (size_t) leng
0c40: 74 68 29 3b 0a 2b 20 20 20 20 69 66 20 28 62 79 th);.+ if (by
0c50: 74 65 73 20 26 26 20 6c 65 6e 67 74 68 29 20 7b tes && length) {
0c60: 0a 2b 09 6d 65 6d 63 70 79 28 62 79 74 65 41 72 .+.memcpy(byteAr
0c70: 72 61 79 50 74 72 2d 3e 62 79 74 65 73 2c 20 62 rayPtr->bytes, b
0c80: 79 74 65 73 2c 20 28 73 69 7a 65 5f 74 29 20 6c ytes, (size_t) l
0c90: 65 6e 67 74 68 29 3b 0a 2b 20 20 20 20 7d 0a 20 ength);.+ }.
0ca0: 0a 20 20 20 20 20 6f 62 6a 50 74 72 2d 3e 74 79 . objPtr->ty
0cb0: 70 65 50 74 72 20 3d 20 26 74 63 6c 42 79 74 65 pePtr = &tclByte
0cc0: 41 72 72 61 79 54 79 70 65 3b 0a 20 20 20 20 20 ArrayType;.
0cd0: 53 45 54 5f 42 59 54 45 41 52 52 41 59 28 6f 62 SET_BYTEARRAY(ob
0ce0: 6a 50 74 72 2c 20 62 79 74 65 41 72 72 61 79 50 jPtr, byteArrayP
0cf0: 74 72 29 3b 0a 40 40 20 2d 35 39 33 2c 38 20 2b tr);.@@ -593,8 +
0d00: 35 39 36 2c 38 20 40 40 20 55 70 64 61 74 65 53 596,8 @@ UpdateS
0d10: 74 72 69 6e 67 4f 66 42 79 74 65 41 72 72 61 79 tringOfByteArray
0d20: 28 0a 20 20 2a 0a 20 20 2a 20 54 63 6c 49 6e 69 (. *. * TclIni
0d30: 74 42 69 6e 61 72 79 43 6d 64 20 2d 2d 0a 20 20 tBinaryCmd --.
0d40: 2a 0a 2d 20 2a 09 54 68 69 73 20 66 75 6e 63 74 *.- *.This funct
0d50: 69 6f 6e 20 69 73 20 63 61 6c 6c 65 64 20 74 6f ion is called to
0d60: 20 63 72 65 61 74 65 20 74 68 65 20 22 62 69 6e create the "bin
0d70: 61 72 79 22 20 54 63 6c 20 63 6f 6d 6d 61 6e 64 ary" Tcl command
0d80: 2e 20 53 65 65 20 74 68 65 20 75 73 65 72 0a 2d . See the user.-
0d90: 20 2a 09 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e *.documentation
0da0: 20 66 6f 72 20 64 65 74 61 69 6c 73 20 6f 6e 20 for details on
0db0: 77 68 61 74 20 69 74 20 64 6f 65 73 2e 0a 2b 20 what it does..+
0dc0: 2a 09 54 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 *.This function
0dd0: 69 73 20 63 61 6c 6c 65 64 20 74 6f 20 63 72 65 is called to cre
0de0: 61 74 65 20 74 68 65 20 22 62 69 6e 61 72 79 22 ate the "binary"
0df0: 20 54 63 6c 20 63 6f 6d 6d 61 6e 64 2e 20 53 65 Tcl command. Se
0e00: 65 20 74 68 65 0a 2b 20 2a 09 75 73 65 72 20 64 e the.+ *.user d
0e10: 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 66 6f 72 ocumentation for
0e20: 20 64 65 74 61 69 6c 73 20 6f 6e 20 77 68 61 74 details on what
0e30: 20 69 74 20 64 6f 65 73 2e 0a 20 20 2a 0a 20 20 it does.. *.
0e40: 2a 20 52 65 73 75 6c 74 73 3a 0a 20 20 2a 09 41 * Results:. *.A
0e50: 20 63 6f 6d 6d 61 6e 64 20 74 6f 6b 65 6e 20 66 command token f
0e60: 6f 72 20 74 68 65 20 6e 65 77 20 63 6f 6d 6d 61 or the new comma
0e70: 6e 64 2e 0a 40 40 20 2d 36 30 38 2c 38 39 20 2b nd..@@ -608,89 +
0e80: 36 31 31 2c 33 32 20 40 40 20 55 70 64 61 74 65 611,32 @@ Update
0e90: 53 74 72 69 6e 67 4f 66 42 79 74 65 41 72 72 61 StringOfByteArra
0ea0: 79 28 0a 20 54 63 6c 5f 43 6f 6d 6d 61 6e 64 0a y(. Tcl_Command.
0eb0: 20 54 63 6c 49 6e 69 74 42 69 6e 61 72 79 43 6d TclInitBinaryCm
0ec0: 64 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e d(Tcl_Interp *in
0ed0: 74 65 72 70 29 0a 20 7b 0a 2d 20 20 20 20 54 63 terp). {.- Tc
0ee0: 6c 5f 4e 61 6d 65 73 70 61 63 65 20 2a 6e 73 54 l_Namespace *nsT
0ef0: 63 6c 50 74 72 2c 20 2a 6e 73 42 69 6e 50 74 72 clPtr, *nsBinPtr
0f00: 2c 20 2a 6e 73 45 6e 63 50 74 72 2c 20 2a 6e 73 , *nsEncPtr, *ns
0f10: 44 65 63 50 74 72 3b 0a 2d 20 20 20 20 54 63 6c DecPtr;.- Tcl
0f20: 5f 43 6f 6d 6d 61 6e 64 20 62 69 6e 45 6e 73 65 _Command binEnse
0f30: 6d 62 6c 65 2c 20 65 6e 63 45 6e 73 65 6d 62 6c mble, encEnsembl
0f40: 65 2c 20 64 65 63 45 6e 73 65 6d 62 6c 65 3b 0a e, decEnsemble;.
0f50: 2d 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 62 69 - Tcl_Obj *bi
0f60: 6e 44 69 63 74 2c 20 2a 65 6e 63 44 69 63 74 2c nDict, *encDict,
0f70: 20 2a 64 65 63 44 69 63 74 3b 0a 2d 0a 2d 20 20 *decDict;.-.-
0f80: 20 20 2f 2a 0a 2d 20 20 20 20 20 2a 20 46 49 58 /*.- * FIX
0f90: 20 4d 45 3a 20 49 20 73 6f 20 75 67 6c 79 20 2d ME: I so ugly -
0fa0: 20 70 6c 65 61 73 65 20 6d 61 6b 65 20 6d 65 20 please make me
0fb0: 70 72 65 74 74 79 20 2e 2e 2e 0a 2d 20 20 20 20 pretty ....-
0fc0: 20 2a 2f 0a 2d 0a 2d 20 20 20 20 6e 73 54 63 6c */.-.- nsTcl
0fd0: 50 74 72 20 3d 20 54 63 6c 5f 46 69 6e 64 4e 61 Ptr = Tcl_FindNa
0fe0: 6d 65 73 70 61 63 65 28 69 6e 74 65 72 70 2c 20 mespace(interp,
0ff0: 22 3a 3a 74 63 6c 22 2c 0a 2d 09 4e 55 4c 4c 2c "::tcl",.-.NULL,
1000: 20 54 43 4c 5f 43 52 45 41 54 45 5f 4e 53 5f 49 TCL_CREATE_NS_I
1010: 46 5f 55 4e 4b 4e 4f 57 4e 29 3b 0a 2d 20 20 20 F_UNKNOWN);.-
1020: 20 69 66 20 28 6e 73 54 63 6c 50 74 72 20 3d 3d if (nsTclPtr ==
1030: 20 4e 55 4c 4c 29 20 7b 0a 2d 09 54 63 6c 5f 50 NULL) {.-.Tcl_P
1040: 61 6e 69 63 28 22 75 6e 61 62 6c 65 20 74 6f 20 anic("unable to
1050: 66 69 6e 64 20 6f 72 20 63 72 65 61 74 65 20 3a find or create :
1060: 3a 74 63 6c 20 6e 61 6d 65 73 70 61 63 65 21 22 :tcl namespace!"
1070: 29 3b 0a 2d 20 20 20 20 7d 0a 2d 20 20 20 20 6e );.- }.- n
1080: 73 42 69 6e 50 74 72 20 3d 20 54 63 6c 5f 46 69 sBinPtr = Tcl_Fi
1090: 6e 64 4e 61 6d 65 73 70 61 63 65 28 69 6e 74 65 ndNamespace(inte
10a0: 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 rp, "::tcl::bina
10b0: 72 79 22 2c 0a 2d 09 4e 55 4c 4c 2c 20 54 43 4c ry",.-.NULL, TCL
10c0: 5f 43 52 45 41 54 45 5f 4e 53 5f 49 46 5f 55 4e _CREATE_NS_IF_UN
10d0: 4b 4e 4f 57 4e 29 3b 0a 2d 20 20 20 20 69 66 20 KNOWN);.- if
10e0: 28 6e 73 42 69 6e 50 74 72 20 3d 3d 20 4e 55 4c (nsBinPtr == NUL
10f0: 4c 29 20 7b 0a 2d 09 54 63 6c 5f 50 61 6e 69 63 L) {.-.Tcl_Panic
1100: 28 22 75 6e 61 62 6c 65 20 74 6f 20 66 69 6e 64 ("unable to find
1110: 20 6f 72 20 63 72 65 61 74 65 20 3a 3a 74 63 6c or create ::tcl
1120: 3a 3a 62 69 6e 61 72 79 20 6e 61 6d 65 73 70 61 ::binary namespa
1130: 63 65 21 22 29 3b 0a 2d 20 20 20 20 7d 0a 2d 20 ce!");.- }.-
1140: 20 20 20 62 69 6e 45 6e 73 65 6d 62 6c 65 20 3d binEnsemble =
1150: 20 54 63 6c 5f 43 72 65 61 74 65 45 6e 73 65 6d Tcl_CreateEnsem
1160: 62 6c 65 28 69 6e 74 65 72 70 2c 20 22 3a 3a 62 ble(interp, "::b
1170: 69 6e 61 72 79 22 2c 0a 2d 09 6e 73 42 69 6e 50 inary",.-.nsBinP
1180: 74 72 2c 20 54 43 4c 5f 45 4e 53 45 4d 42 4c 45 tr, TCL_ENSEMBLE
1190: 5f 50 52 45 46 49 58 29 3b 0a 2d 0a 2d 20 20 20 _PREFIX);.-.-
11a0: 20 6e 73 45 6e 63 50 74 72 20 3d 20 54 63 6c 5f nsEncPtr = Tcl_
11b0: 46 69 6e 64 4e 61 6d 65 73 70 61 63 65 28 69 6e FindNamespace(in
11c0: 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a 62 69 terp, "::tcl::bi
11d0: 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 22 2c 0a 2d nary::encode",.-
11e0: 09 4e 55 4c 4c 2c 20 54 43 4c 5f 43 52 45 41 54 .NULL, TCL_CREAT
11f0: 45 5f 4e 53 5f 49 46 5f 55 4e 4b 4e 4f 57 4e 29 E_NS_IF_UNKNOWN)
1200: 3b 0a 2d 20 20 20 20 69 66 20 28 6e 73 45 6e 63 ;.- if (nsEnc
1210: 50 74 72 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 2d Ptr == NULL) {.-
1220: 09 54 63 6c 5f 50 61 6e 69 63 28 22 75 6e 61 62 .Tcl_Panic("unab
1230: 6c 65 20 74 6f 20 66 69 6e 64 20 6f 72 20 63 72 le to find or cr
1240: 65 61 74 65 20 3a 3a 74 63 6c 3a 3a 62 69 6e 61 eate ::tcl::bina
1250: 72 79 3a 3a 65 6e 63 6f 64 65 20 6e 61 6d 65 73 ry::encode names
1260: 70 61 63 65 21 22 29 3b 0a 2d 20 20 20 20 7d 0a pace!");.- }.
1270: 2d 20 20 20 20 65 6e 63 45 6e 73 65 6d 62 6c 65 - encEnsemble
1280: 20 3d 20 54 63 6c 5f 43 72 65 61 74 65 45 6e 73 = Tcl_CreateEns
1290: 65 6d 62 6c 65 28 69 6e 74 65 72 70 2c 20 22 65 emble(interp, "e
12a0: 6e 63 6f 64 65 22 2c 0a 2d 09 6e 73 42 69 6e 50 ncode",.-.nsBinP
12b0: 74 72 2c 20 30 29 3b 0a 2d 0a 2d 20 20 20 20 6e tr, 0);.-.- n
12c0: 73 44 65 63 50 74 72 20 3d 20 54 63 6c 5f 46 69 sDecPtr = Tcl_Fi
12d0: 6e 64 4e 61 6d 65 73 70 61 63 65 28 69 6e 74 65 ndNamespace(inte
12e0: 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 rp, "::tcl::bina
12f0: 72 79 3a 3a 64 65 63 6f 64 65 22 2c 0a 2d 09 4e ry::decode",.-.N
1300: 55 4c 4c 2c 20 54 43 4c 5f 43 52 45 41 54 45 5f ULL, TCL_CREATE_
1310: 4e 53 5f 49 46 5f 55 4e 4b 4e 4f 57 4e 29 3b 0a NS_IF_UNKNOWN);.
1320: 2d 20 20 20 20 69 66 20 28 6e 73 44 65 63 50 74 - if (nsDecPt
1330: 72 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 2d 09 54 r == NULL) {.-.T
1340: 63 6c 5f 50 61 6e 69 63 28 22 75 6e 61 62 6c 65 cl_Panic("unable
1350: 20 74 6f 20 66 69 6e 64 20 6f 72 20 63 72 65 61 to find or crea
1360: 74 65 20 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 te ::tcl::binary
1370: 3a 3a 64 65 63 6f 64 65 20 6e 61 6d 65 73 70 61 ::decode namespa
1380: 63 65 21 22 29 3b 0a 2d 20 20 20 20 7d 0a 2d 20 ce!");.- }.-
1390: 20 20 20 64 65 63 45 6e 73 65 6d 62 6c 65 20 3d decEnsemble =
13a0: 20 54 63 6c 5f 43 72 65 61 74 65 45 6e 73 65 6d Tcl_CreateEnsem
13b0: 62 6c 65 28 69 6e 74 65 72 70 2c 20 22 64 65 63 ble(interp, "dec
13c0: 6f 64 65 22 2c 0a 2d 09 6e 73 42 69 6e 50 74 72 ode",.-.nsBinPtr
13d0: 2c 20 30 29 3b 0a 2d 0a 2d 20 20 20 20 54 63 6c , 0);.-.- Tcl
13e0: 4e 65 77 4f 62 6a 28 62 69 6e 44 69 63 74 29 3b NewObj(binDict);
13f0: 0a 2d 20 20 20 20 54 63 6c 5f 44 69 63 74 4f 62 .- Tcl_DictOb
1400: 6a 50 75 74 28 4e 55 4c 4c 2c 20 62 69 6e 44 69 jPut(NULL, binDi
1410: 63 74 2c 20 54 63 6c 5f 4e 65 77 53 74 72 69 6e ct, Tcl_NewStrin
1420: 67 4f 62 6a 28 22 66 6f 72 6d 61 74 22 2c 2d 31 gObj("format",-1
1430: 29 2c 0a 2d 09 54 63 6c 5f 4e 65 77 53 74 72 69 ),.-.Tcl_NewStri
1440: 6e 67 4f 62 6a 28 22 3a 3a 74 63 6c 3a 3a 62 69 ngObj("::tcl::bi
1450: 6e 61 72 79 3a 3a 66 6f 72 6d 61 74 22 2c 2d 31 nary::format",-1
1460: 29 29 3b 0a 2d 20 20 20 20 54 63 6c 5f 44 69 63 ));.- Tcl_Dic
1470: 74 4f 62 6a 50 75 74 28 4e 55 4c 4c 2c 20 62 69 tObjPut(NULL, bi
1480: 6e 44 69 63 74 2c 20 54 63 6c 5f 4e 65 77 53 74 nDict, Tcl_NewSt
1490: 72 69 6e 67 4f 62 6a 28 22 73 63 61 6e 22 2c 2d ringObj("scan",-
14a0: 31 29 2c 0a 2d 09 54 63 6c 5f 4e 65 77 53 74 72 1),.-.Tcl_NewStr
14b0: 69 6e 67 4f 62 6a 28 22 3a 3a 74 63 6c 3a 3a 62 ingObj("::tcl::b
14c0: 69 6e 61 72 79 3a 3a 73 63 61 6e 22 2c 2d 31 29 inary::scan",-1)
14d0: 29 3b 0a 2d 20 20 20 20 54 63 6c 5f 44 69 63 74 );.- Tcl_Dict
14e0: 4f 62 6a 50 75 74 28 4e 55 4c 4c 2c 20 62 69 6e ObjPut(NULL, bin
14f0: 44 69 63 74 2c 20 54 63 6c 5f 4e 65 77 53 74 72 Dict, Tcl_NewStr
1500: 69 6e 67 4f 62 6a 28 22 65 6e 63 6f 64 65 22 2c ingObj("encode",
1510: 2d 31 29 2c 0a 2d 09 54 63 6c 5f 4e 65 77 53 74 -1),.-.Tcl_NewSt
1520: 72 69 6e 67 4f 62 6a 28 22 3a 3a 74 63 6c 3a 3a ringObj("::tcl::
1530: 62 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 22 2c binary::encode",
1540: 2d 31 29 29 3b 0a 2d 20 20 20 20 54 63 6c 5f 44 -1));.- Tcl_D
1550: 69 63 74 4f 62 6a 50 75 74 28 4e 55 4c 4c 2c 20 ictObjPut(NULL,
1560: 62 69 6e 44 69 63 74 2c 20 54 63 6c 5f 4e 65 77 binDict, Tcl_New
1570: 53 74 72 69 6e 67 4f 62 6a 28 22 64 65 63 6f 64 StringObj("decod
1580: 65 22 2c 2d 31 29 2c 0a 2d 09 54 63 6c 5f 4e 65 e",-1),.-.Tcl_Ne
1590: 77 53 74 72 69 6e 67 4f 62 6a 28 22 3a 3a 74 63 wStringObj("::tc
15a0: 6c 3a 3a 62 69 6e 61 72 79 3a 3a 64 65 63 6f 64 l::binary::decod
15b0: 65 22 2c 2d 31 29 29 3b 0a 2d 20 20 20 20 54 63 e",-1));.- Tc
15c0: 6c 5f 43 72 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 l_CreateObjComma
15d0: 6e 64 28 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 nd(interp, "::tc
15e0: 6c 3a 3a 62 69 6e 61 72 79 3a 3a 66 6f 72 6d 61 l::binary::forma
15f0: 74 22 2c 0a 2d 09 42 69 6e 61 72 79 46 6f 72 6d t",.-.BinaryForm
1600: 61 74 43 6d 64 2c 20 4e 55 4c 4c 2c 20 4e 55 4c atCmd, NULL, NUL
1610: 4c 29 3b 0a 2d 20 20 20 20 54 63 6c 5f 43 72 65 L);.- Tcl_Cre
1620: 61 74 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 69 6e ateObjCommand(in
1630: 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a 62 69 terp, "::tcl::bi
1640: 6e 61 72 79 3a 3a 73 63 61 6e 22 2c 0a 2d 09 42 nary::scan",.-.B
1650: 69 6e 61 72 79 53 63 61 6e 43 6d 64 2c 20 4e 55 inaryScanCmd, NU
1660: 4c 4c 2c 20 4e 55 4c 4c 29 3b 0a 2d 20 20 20 20 LL, NULL);.-
1670: 54 63 6c 5f 53 65 74 45 6e 73 65 6d 62 6c 65 4d Tcl_SetEnsembleM
1680: 61 70 70 69 6e 67 44 69 63 74 28 69 6e 74 65 72 appingDict(inter
1690: 70 2c 20 62 69 6e 45 6e 73 65 6d 62 6c 65 2c 20 p, binEnsemble,
16a0: 62 69 6e 44 69 63 74 29 3b 0a 2d 0a 2d 20 20 20 binDict);.-.-
16b0: 20 54 63 6c 4e 65 77 4f 62 6a 28 65 6e 63 44 69 TclNewObj(encDi
16c0: 63 74 29 3b 0a 2d 20 20 20 20 54 63 6c 5f 44 69 ct);.- Tcl_Di
16d0: 63 74 4f 62 6a 50 75 74 28 4e 55 4c 4c 2c 20 65 ctObjPut(NULL, e
16e0: 6e 63 44 69 63 74 2c 20 54 63 6c 5f 4e 65 77 53 ncDict, Tcl_NewS
16f0: 74 72 69 6e 67 4f 62 6a 28 22 68 65 78 22 2c 2d tringObj("hex",-
1700: 31 29 2c 0a 2d 09 54 63 6c 5f 4e 65 77 53 74 72 1),.-.Tcl_NewStr
1710: 69 6e 67 4f 62 6a 28 22 3a 3a 74 63 6c 3a 3a 62 ingObj("::tcl::b
1720: 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 3a 3a 68 inary::encode::h
1730: 65 78 22 2c 2d 31 29 29 3b 0a 2d 20 20 20 20 54 ex",-1));.- T
1740: 63 6c 5f 44 69 63 74 4f 62 6a 50 75 74 28 4e 55 cl_DictObjPut(NU
1750: 4c 4c 2c 20 65 6e 63 44 69 63 74 2c 20 54 63 6c LL, encDict, Tcl
1760: 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 75 _NewStringObj("u
1770: 75 65 6e 63 6f 64 65 22 2c 2d 31 29 2c 0a 2d 09 uencode",-1),.-.
1780: 54 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a Tcl_NewStringObj
1790: 28 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a ("::tcl::binary:
17a0: 3a 65 6e 63 6f 64 65 3a 3a 75 75 65 6e 63 6f 64 :encode::uuencod
17b0: 65 22 2c 2d 31 29 29 3b 0a 2d 20 20 20 20 54 63 e",-1));.- Tc
17c0: 6c 5f 44 69 63 74 4f 62 6a 50 75 74 28 4e 55 4c l_DictObjPut(NUL
17d0: 4c 2c 20 65 6e 63 44 69 63 74 2c 20 54 63 6c 5f L, encDict, Tcl_
17e0: 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 62 61 NewStringObj("ba
17f0: 73 65 36 34 22 2c 2d 31 29 2c 0a 2d 09 54 63 6c se64",-1),.-.Tcl
1800: 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 3a _NewStringObj(":
1810: 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a 65 6e :tcl::binary::en
1820: 63 6f 64 65 3a 3a 62 61 73 65 36 34 22 2c 2d 31 code::base64",-1
1830: 29 29 3b 0a 2d 20 20 20 20 54 63 6c 5f 43 72 65 ));.- Tcl_Cre
1840: 61 74 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 69 6e ateObjCommand(in
1850: 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a 62 69 terp, "::tcl::bi
1860: 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 3a 3a 68 65 nary::encode::he
1870: 78 22 2c 0a 2d 09 42 69 6e 61 72 79 45 6e 63 6f x",.-.BinaryEnco
1880: 64 65 48 65 78 2c 20 28 43 6c 69 65 6e 74 44 61 deHex, (ClientDa
1890: 74 61 29 48 65 78 44 69 67 69 74 73 2c 20 4e 55 ta)HexDigits, NU
18a0: 4c 4c 29 3b 0a 2d 20 20 20 20 54 63 6c 5f 43 72 LL);.- Tcl_Cr
18b0: 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 69 eateObjCommand(i
18c0: 6e 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a 62 nterp, "::tcl::b
18d0: 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 3a 3a 75 inary::encode::u
18e0: 75 65 6e 63 6f 64 65 22 2c 0a 2d 09 42 69 6e 61 uencode",.-.Bina
18f0: 72 79 45 6e 63 6f 64 65 36 34 2c 20 28 43 6c 69 ryEncode64, (Cli
1900: 65 6e 74 44 61 74 61 29 55 75 65 44 69 67 69 74 entData)UueDigit
1910: 73 2c 20 4e 55 4c 4c 29 3b 0a 2d 20 20 20 20 54 s, NULL);.- T
1920: 63 6c 5f 43 72 65 61 74 65 4f 62 6a 43 6f 6d 6d cl_CreateObjComm
1930: 61 6e 64 28 69 6e 74 65 72 70 2c 20 22 3a 3a 74 and(interp, "::t
1940: 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a 65 6e 63 6f cl::binary::enco
1950: 64 65 3a 3a 62 61 73 65 36 34 22 2c 0a 2d 09 42 de::base64",.-.B
1960: 69 6e 61 72 79 45 6e 63 6f 64 65 36 34 2c 20 28 inaryEncode64, (
1970: 43 6c 69 65 6e 74 44 61 74 61 29 42 36 34 44 69 ClientData)B64Di
1980: 67 69 74 73 2c 20 4e 55 4c 4c 29 3b 0a 2d 20 20 gits, NULL);.-
1990: 20 20 54 63 6c 5f 53 65 74 45 6e 73 65 6d 62 6c Tcl_SetEnsembl
19a0: 65 4d 61 70 70 69 6e 67 44 69 63 74 28 69 6e 74 eMappingDict(int
19b0: 65 72 70 2c 20 65 6e 63 45 6e 73 65 6d 62 6c 65 erp, encEnsemble
19c0: 2c 20 65 6e 63 44 69 63 74 29 3b 0a 2d 0a 2d 20 , encDict);.-.-
19d0: 20 20 20 54 63 6c 4e 65 77 4f 62 6a 28 64 65 63 TclNewObj(dec
19e0: 44 69 63 74 29 3b 0a 2d 20 20 20 20 54 63 6c 5f Dict);.- Tcl_
19f0: 44 69 63 74 4f 62 6a 50 75 74 28 4e 55 4c 4c 2c DictObjPut(NULL,
1a00: 20 64 65 63 44 69 63 74 2c 20 54 63 6c 5f 4e 65 decDict, Tcl_Ne
1a10: 77 53 74 72 69 6e 67 4f 62 6a 28 22 68 65 78 22 wStringObj("hex"
1a20: 2c 2d 31 29 2c 0a 2d 09 54 63 6c 5f 4e 65 77 53 ,-1),.-.Tcl_NewS
1a30: 74 72 69 6e 67 4f 62 6a 28 22 3a 3a 74 63 6c 3a tringObj("::tcl:
1a40: 3a 62 69 6e 61 72 79 3a 3a 64 65 63 6f 64 65 3a :binary::decode:
1a50: 3a 68 65 78 22 2c 2d 31 29 29 3b 0a 2d 20 20 20 :hex",-1));.-
1a60: 20 54 63 6c 5f 44 69 63 74 4f 62 6a 50 75 74 28 Tcl_DictObjPut(
1a70: 4e 55 4c 4c 2c 20 64 65 63 44 69 63 74 2c 20 54 NULL, decDict, T
1a80: 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 cl_NewStringObj(
1a90: 22 75 75 65 6e 63 6f 64 65 22 2c 2d 31 29 2c 0a "uuencode",-1),.
1aa0: 2d 09 54 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f -.Tcl_NewStringO
1ab0: 62 6a 28 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 bj("::tcl::binar
1ac0: 79 3a 3a 64 65 63 6f 64 65 3a 3a 75 75 65 6e 63 y::decode::uuenc
1ad0: 6f 64 65 22 2c 2d 31 29 29 3b 0a 2d 20 20 20 20 ode",-1));.-
1ae0: 54 63 6c 5f 44 69 63 74 4f 62 6a 50 75 74 28 4e Tcl_DictObjPut(N
1af0: 55 4c 4c 2c 20 64 65 63 44 69 63 74 2c 20 54 63 ULL, decDict, Tc
1b00: 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 l_NewStringObj("
1b10: 62 61 73 65 36 34 22 2c 2d 31 29 2c 0a 2d 09 54 base64",-1),.-.T
1b20: 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 cl_NewStringObj(
1b30: 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a "::tcl::binary::
1b40: 64 65 63 6f 64 65 3a 3a 62 61 73 65 36 34 22 2c decode::base64",
1b50: 2d 31 29 29 3b 0a 2d 20 20 20 20 54 63 6c 5f 43 -1));.- Tcl_C
1b60: 72 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 reateObjCommand(
1b70: 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a interp, "::tcl::
1b80: 62 69 6e 61 72 79 3a 3a 64 65 63 6f 64 65 3a 3a binary::decode::
1b90: 68 65 78 22 2c 0a 2d 09 42 69 6e 61 72 79 44 65 hex",.-.BinaryDe
1ba0: 63 6f 64 65 48 65 78 2c 20 28 43 6c 69 65 6e 74 codeHex, (Client
1bb0: 44 61 74 61 29 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 Data)NULL, NULL)
1bc0: 3b 0a 2d 20 20 20 20 54 63 6c 5f 43 72 65 61 74 ;.- Tcl_Creat
1bd0: 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 69 6e 74 65 eObjCommand(inte
1be0: 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 rp, "::tcl::bina
1bf0: 72 79 3a 3a 64 65 63 6f 64 65 3a 3a 75 75 65 6e ry::decode::uuen
1c00: 63 6f 64 65 22 2c 0a 2d 09 42 69 6e 61 72 79 44 code",.-.BinaryD
1c10: 65 63 6f 64 65 55 75 2c 20 28 43 6c 69 65 6e 74 ecodeUu, (Client
1c20: 44 61 74 61 29 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 Data)NULL, NULL)
1c30: 3b 0a 2d 20 20 20 20 54 63 6c 5f 43 72 65 61 74 ;.- Tcl_Creat
1c40: 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 69 6e 74 65 eObjCommand(inte
1c50: 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 rp, "::tcl::bina
1c60: 72 79 3a 3a 64 65 63 6f 64 65 3a 3a 62 61 73 65 ry::decode::base
1c70: 36 34 22 2c 0a 2d 09 42 69 6e 61 72 79 44 65 63 64",.-.BinaryDec
1c80: 6f 64 65 36 34 2c 20 28 43 6c 69 65 6e 74 44 61 ode64, (ClientDa
1c90: 74 61 29 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 3b 0a ta)NULL, NULL);.
1ca0: 2d 20 20 20 20 54 63 6c 5f 53 65 74 45 6e 73 65 - Tcl_SetEnse
1cb0: 6d 62 6c 65 4d 61 70 70 69 6e 67 44 69 63 74 28 mbleMappingDict(
1cc0: 69 6e 74 65 72 70 2c 20 64 65 63 45 6e 73 65 6d interp, decEnsem
1cd0: 62 6c 65 2c 20 64 65 63 44 69 63 74 29 3b 0a 2d ble, decDict);.-
1ce0: 0a 2d 20 20 20 20 72 65 74 75 72 6e 20 62 69 6e .- return bin
1cf0: 45 6e 73 65 6d 62 6c 65 3b 0a 2b 20 20 20 20 63 Ensemble;.+ c
1d00: 6f 6e 73 74 20 45 6e 73 65 6d 62 6c 65 49 6d 70 onst EnsembleImp
1d10: 6c 4d 61 70 20 62 69 6e 61 72 79 4d 61 70 5b 5d lMap binaryMap[]
1d20: 20 3d 20 7b 0a 2b 09 7b 20 22 66 6f 72 6d 61 74 = {.+.{ "format
1d30: 22 2c 20 42 69 6e 61 72 79 46 6f 72 6d 61 74 43 ", BinaryFormatC
1d40: 6d 64 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 md, NULL, NULL,
1d50: 4e 55 4c 4c 2c 20 4e 55 4c 4c 20 7d 2c 0a 2b 09 NULL, NULL },.+.
1d60: 7b 20 22 73 63 61 6e 22 2c 20 20 20 42 69 6e 61 { "scan", Bina
1d70: 72 79 53 63 61 6e 43 6d 64 2c 20 20 20 4e 55 4c ryScanCmd, NUL
1d80: 4c 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 4e L, NULL, NULL, N
1d90: 55 4c 4c 20 7d 2c 0a 2b 09 7b 20 22 65 6e 63 6f ULL },.+.{ "enco
1da0: 64 65 22 2c 20 4e 55 4c 4c 2c 20 20 20 20 20 20 de", NULL,
1db0: 20 20 20 20 20 20 4e 55 4c 4c 2c 20 4e 55 4c 4c NULL, NULL
1dc0: 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 20 7d 2c 0a , NULL, NULL },.
1dd0: 2b 09 7b 20 22 64 65 63 6f 64 65 22 2c 20 4e 55 +.{ "decode", NU
1de0: 4c 4c 2c 20 20 20 20 20 20 20 20 20 20 20 20 4e LL, N
1df0: 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c ULL, NULL, NULL,
1e00: 20 4e 55 4c 4c 20 7d 2c 0a 2b 09 7b 20 4e 55 4c NULL },.+.{ NUL
1e10: 4c 2c 20 20 20 20 20 4e 55 4c 4c 2c 20 20 20 20 L, NULL,
1e20: 20 20 20 20 20 20 20 20 4e 55 4c 4c 2c 20 4e 55 NULL, NU
1e30: 4c 4c 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 20 7d LL, NULL, NULL }
1e40: 0a 2b 20 20 20 20 7d 3b 0a 2b 20 20 20 20 63 6f .+ };.+ co
1e50: 6e 73 74 20 45 6e 73 65 6d 62 6c 65 49 6d 70 6c nst EnsembleImpl
1e60: 4d 61 70 20 65 6e 63 6f 64 65 4d 61 70 5b 5d 20 Map encodeMap[]
1e70: 3d 20 7b 0a 2b 09 7b 20 22 68 65 78 22 2c 20 20 = {.+.{ "hex",
1e80: 20 20 20 42 69 6e 61 72 79 45 6e 63 6f 64 65 48 BinaryEncodeH
1e90: 65 78 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 ex, NULL, NULL,
1ea0: 28 43 6c 69 65 6e 74 44 61 74 61 29 48 65 78 44 (ClientData)HexD
1eb0: 69 67 69 74 73 2c 20 4e 55 4c 4c 20 7d 2c 0a 2b igits, NULL },.+
1ec0: 09 7b 20 22 75 75 65 6e 63 6f 64 65 22 2c 42 69 .{ "uuencode",Bi
1ed0: 6e 61 72 79 45 6e 63 6f 64 65 36 34 2c 20 20 4e naryEncode64, N
1ee0: 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 28 43 6c 69 65 ULL, NULL, (Clie
1ef0: 6e 74 44 61 74 61 29 55 75 65 44 69 67 69 74 73 ntData)UueDigits
1f00: 2c 20 4e 55 4c 4c 20 7d 2c 0a 2b 09 7b 20 22 62 , NULL },.+.{ "b
1f10: 61 73 65 36 34 22 2c 20 20 42 69 6e 61 72 79 45 ase64", BinaryE
1f20: 6e 63 6f 64 65 36 34 2c 20 20 4e 55 4c 4c 2c 20 ncode64, NULL,
1f30: 4e 55 4c 4c 2c 20 28 43 6c 69 65 6e 74 44 61 74 NULL, (ClientDat
1f40: 61 29 42 36 34 44 69 67 69 74 73 2c 20 4e 55 4c a)B64Digits, NUL
1f50: 4c 20 7d 2c 0a 2b 09 7b 20 4e 55 4c 4c 2c 20 20 L },.+.{ NULL,
1f60: 20 20 20 20 4e 55 4c 4c 2c 20 20 20 20 20 20 20 NULL,
1f70: 20 20 20 20 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c NULL, NULL,
1f80: 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 20 7d 0a 2b 20 NULL, NULL }.+
1f90: 20 20 20 7d 3b 0a 2b 20 20 20 20 63 6f 6e 73 74 };.+ const
1fa0: 20 45 6e 73 65 6d 62 6c 65 49 6d 70 6c 4d 61 70 EnsembleImplMap
1fb0: 20 64 65 63 6f 64 65 4d 61 70 5b 5d 20 3d 20 7b decodeMap[] = {
1fc0: 0a 2b 09 7b 20 22 68 65 78 22 2c 20 20 20 20 20 .+.{ "hex",
1fd0: 20 42 69 6e 61 72 79 44 65 63 6f 64 65 48 65 78 BinaryDecodeHex
1fe0: 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 4e 55 , NULL, NULL, NU
1ff0: 4c 4c 2c 20 4e 55 4c 4c 20 7d 2c 0a 2b 09 7b 20 LL, NULL },.+.{
2000: 22 75 75 65 6e 63 6f 64 65 22 2c 20 42 69 6e 61 "uuencode", Bina
2010: 72 79 44 65 63 6f 64 65 55 75 2c 20 20 4e 55 4c ryDecodeUu, NUL
2020: 4c 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 4e L, NULL, NULL, N
2030: 55 4c 4c 20 7d 2c 0a 2b 09 7b 20 22 62 61 73 65 ULL },.+.{ "base
2040: 36 34 22 2c 20 20 20 42 69 6e 61 72 79 44 65 63 64", BinaryDec
2050: 6f 64 65 36 34 2c 20 20 4e 55 4c 4c 2c 20 4e 55 ode64, NULL, NU
2060: 4c 4c 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 20 7d LL, NULL, NULL }
2070: 2c 0a 2b 09 7b 20 4e 55 4c 4c 2c 20 20 20 20 20 ,.+.{ NULL,
2080: 20 20 4e 55 4c 4c 2c 20 20 20 20 20 20 20 20 20 NULL,
2090: 20 20 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 4e NULL, NULL, N
20a0: 55 4c 4c 2c 20 4e 55 4c 4c 20 7d 0a 2b 20 20 20 ULL, NULL }.+
20b0: 20 7d 3b 0a 2b 0a 2b 20 20 20 20 54 63 6c 5f 43 };.+.+ Tcl_C
20c0: 6f 6d 6d 61 6e 64 20 62 69 6e 61 72 79 45 6e 73 ommand binaryEns
20d0: 65 6d 62 6c 65 3b 0a 2b 0a 2b 20 20 20 20 62 69 emble;.+.+ bi
20e0: 6e 61 72 79 45 6e 73 65 6d 62 6c 65 20 3d 20 54 naryEnsemble = T
20f0: 63 6c 4d 61 6b 65 45 6e 73 65 6d 62 6c 65 28 69 clMakeEnsemble(i
2100: 6e 74 65 72 70 2c 20 22 62 69 6e 61 72 79 22 2c nterp, "binary",
2110: 20 62 69 6e 61 72 79 4d 61 70 29 3b 0a 2b 20 20 binaryMap);.+
2120: 20 20 54 63 6c 4d 61 6b 65 45 6e 73 65 6d 62 6c TclMakeEnsembl
2130: 65 28 69 6e 74 65 72 70 2c 20 22 62 69 6e 61 72 e(interp, "binar
2140: 79 20 65 6e 63 6f 64 65 22 2c 20 65 6e 63 6f 64 y encode", encod
2150: 65 4d 61 70 29 3b 0a 2b 20 20 20 20 54 63 6c 4d eMap);.+ TclM
2160: 61 6b 65 45 6e 73 65 6d 62 6c 65 28 69 6e 74 65 akeEnsemble(inte
2170: 72 70 2c 20 22 62 69 6e 61 72 79 20 64 65 63 6f rp, "binary deco
2180: 64 65 22 2c 20 64 65 63 6f 64 65 4d 61 70 29 3b de", decodeMap);
2190: 0a 2b 20 20 20 20 72 65 74 75 72 6e 20 62 69 6e .+ return bin
21a0: 61 72 79 45 6e 73 65 6d 62 6c 65 3b 0a 20 7d 0a aryEnsemble;. }.
21b0: 20 0c 0a 20 2f 2a 0a 40 40 20 2d 32 37 31 30 2c .. /*.@@ -2710,
21c0: 33 20 2b 32 36 35 36 2c 34 20 40 40 20 42 69 6e 3 +2656,4 @@ Bin
21d0: 61 72 79 44 65 63 6f 64 65 36 34 28 0a 20 20 2a aryDecode64(. *
21e0: 20 66 69 6c 6c 2d 63 6f 6c 75 6d 6e 3a 20 37 38 fill-column: 78
21f0: 0a 20 20 2a 20 45 6e 64 3a 0a 20 20 2a 2f 0a 2b . * End:. */.+
2200: 0a 64 69 66 66 20 2d 2d 67 69 74 20 61 2f 67 65 .diff --git a/ge
2210: 6e 65 72 69 63 2f 74 63 6c 49 6e 74 2e 68 20 62 neric/tclInt.h b
2220: 2f 67 65 6e 65 72 69 63 2f 74 63 6c 49 6e 74 2e /generic/tclInt.
2230: 68 0a 69 6e 64 65 78 20 64 38 39 37 61 39 30 2e h.index d897a90.
2240: 2e 34 32 39 65 37 31 66 20 31 30 30 36 34 34 0a .429e71f 100644.
2250: 2d 2d 2d 20 61 2f 67 65 6e 65 72 69 63 2f 74 63 --- a/generic/tc
2260: 6c 49 6e 74 2e 68 0a 2b 2b 2b 20 62 2f 67 65 6e lInt.h.+++ b/gen
2270: 65 72 69 63 2f 74 63 6c 49 6e 74 2e 68 0a 40 40 eric/tclInt.h.@@
2280: 20 2d 31 34 35 35 2c 31 30 20 2b 31 34 35 35 2c -1455,10 +1455,
2290: 31 32 20 40 40 20 74 79 70 65 64 65 66 20 73 74 12 @@ typedef st
22a0: 72 75 63 74 20 42 79 74 65 43 6f 64 65 53 74 61 ruct ByteCodeSta
22b0: 74 73 20 7b 0a 20 20 2a 2f 0a 20 0a 20 74 79 70 ts {. */. . typ
22c0: 65 64 65 66 20 73 74 72 75 63 74 20 7b 0a 2d 20 edef struct {.-
22d0: 20 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 6e const char *n
22e0: 61 6d 65 3b 09 09 2f 2a 20 54 68 65 20 6e 61 6d ame;../* The nam
22f0: 65 20 6f 66 20 74 68 65 20 73 75 62 63 6f 6d 6d e of the subcomm
2300: 61 6e 64 2e 20 2a 2f 0a 2d 20 20 20 20 54 63 6c and. */.- Tcl
2310: 5f 4f 62 6a 43 6d 64 50 72 6f 63 20 2a 70 72 6f _ObjCmdProc *pro
2320: 63 3b 09 2f 2a 20 54 68 65 20 69 6d 70 6c 65 6d c;./* The implem
2330: 65 6e 74 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 entation of the
2340: 73 75 62 63 6f 6d 6d 61 6e 64 2e 20 2a 2f 0a 2d subcommand. */.-
2350: 20 20 20 20 43 6f 6d 70 69 6c 65 50 72 6f 63 20 CompileProc
2360: 2a 63 6f 6d 70 69 6c 65 50 72 6f 63 3b 09 2f 2a *compileProc;./*
2370: 20 54 68 65 20 63 6f 6d 70 69 6c 65 72 20 66 6f The compiler fo
2380: 72 20 74 68 65 20 73 75 62 63 6f 6d 6d 61 6e 64 r the subcommand
2390: 2e 20 2a 2f 0a 2d 20 20 20 20 54 63 6c 5f 4f 62 . */.- Tcl_Ob
23a0: 6a 43 6d 64 50 72 6f 63 20 2a 6e 72 65 50 72 6f jCmdProc *nrePro
23b0: 63 3b 09 2f 2a 20 4e 52 45 20 69 6d 70 6c 65 6d c;./* NRE implem
23c0: 65 6e 74 61 74 69 6f 6e 20 6f 66 20 74 68 69 73 entation of this
23d0: 20 63 6f 6d 6d 61 6e 64 20 2a 2f 0a 2b 20 20 20 command */.+
23e0: 20 63 6f 6e 73 74 20 63 68 61 72 20 20 20 20 20 const char
23f0: 20 20 20 2a 6e 61 6d 65 3b 20 20 20 20 20 20 20 *name;
2400: 20 2f 2a 20 54 68 65 20 6e 61 6d 65 20 6f 66 20 /* The name of
2410: 74 68 65 20 73 75 62 63 6f 6d 6d 61 6e 64 20 20 the subcommand
2420: 20 20 20 20 20 20 20 20 20 2a 2f 0a 2b 20 20 20 */.+
2430: 20 54 63 6c 5f 4f 62 6a 43 6d 64 50 72 6f 63 20 Tcl_ObjCmdProc
2440: 20 20 20 2a 70 72 6f 63 3b 20 20 20 20 20 20 20 *proc;
2450: 20 2f 2a 20 54 68 65 20 69 6d 70 6c 65 6d 65 6e /* The implemen
2460: 74 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 73 75 tation of the su
2470: 62 63 6f 6d 6d 61 6e 64 20 2a 2f 0a 2b 20 20 20 bcommand */.+
2480: 20 43 6f 6d 70 69 6c 65 50 72 6f 63 20 20 20 20 CompileProc
2490: 20 20 20 2a 63 6f 6d 70 69 6c 65 50 72 6f 63 3b *compileProc;
24a0: 20 2f 2a 20 54 68 65 20 63 6f 6d 70 69 6c 65 72 /* The compiler
24b0: 20 66 6f 72 20 74 68 65 20 73 75 62 63 6f 6d 6d for the subcomm
24c0: 61 6e 64 20 20 20 20 20 20 2a 2f 0a 2b 20 20 20 and */.+
24d0: 20 54 63 6c 5f 4f 62 6a 43 6d 64 50 72 6f 63 20 Tcl_ObjCmdProc
24e0: 20 20 20 2a 6e 72 65 50 72 6f 63 3b 20 20 20 20 *nreProc;
24f0: 20 2f 2a 20 4e 52 45 20 69 6d 70 6c 65 6d 65 6e /* NRE implemen
2500: 74 61 74 69 6f 6e 20 6f 66 20 74 68 69 73 20 63 tation of this c
2510: 6f 6d 6d 61 6e 64 20 20 20 2a 2f 0a 2b 20 20 20 ommand */.+
2520: 20 43 6c 69 65 6e 74 44 61 74 61 20 20 20 20 20 ClientData
2530: 20 20 20 20 63 6c 69 65 6e 74 44 61 74 61 3b 20 clientData;
2540: 20 2f 2a 20 41 6e 79 20 63 6c 69 65 6e 74 44 61 /* Any clientDa
2550: 74 61 20 74 6f 20 67 69 76 65 20 74 68 65 20 63 ta to give the c
2560: 6f 6d 6d 61 6e 64 20 20 20 2a 2f 0a 2b 20 20 20 ommand */.+
2570: 20 54 63 6c 5f 43 6d 64 44 65 6c 65 74 65 50 72 Tcl_CmdDeletePr
2580: 6f 63 20 2a 64 65 6c 65 74 65 50 72 6f 63 3b 20 oc *deleteProc;
2590: 20 2f 2a 20 54 68 65 20 64 65 6c 65 74 65 20 70 /* The delete p
25a0: 72 6f 63 2c 20 6d 61 79 20 62 65 20 4e 55 4c 4c roc, may be NULL
25b0: 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 7d 20 45 */. } E
25c0: 6e 73 65 6d 62 6c 65 49 6d 70 6c 4d 61 70 3b 0a nsembleImplMap;.
25d0: 20 0a 20 2f 2a 0a 64 69 66 66 20 2d 2d 67 69 74 . /*.diff --git
25e0: 20 61 2f 67 65 6e 65 72 69 63 2f 74 63 6c 4e 61 a/generic/tclNa
25f0: 6d 65 73 70 2e 63 20 62 2f 67 65 6e 65 72 69 63 mesp.c b/generic
2600: 2f 74 63 6c 4e 61 6d 65 73 70 2e 63 0a 69 6e 64 /tclNamesp.c.ind
2610: 65 78 20 62 35 30 62 35 61 39 2e 2e 37 31 38 38 ex b50b5a9..7188
2620: 61 65 36 20 31 30 30 36 34 34 0a 2d 2d 2d 20 61 ae6 100644.--- a
2630: 2f 67 65 6e 65 72 69 63 2f 74 63 6c 4e 61 6d 65 /generic/tclName
2640: 73 70 2e 63 0a 2b 2b 2b 20 62 2f 67 65 6e 65 72 sp.c.+++ b/gener
2650: 69 63 2f 74 63 6c 4e 61 6d 65 73 70 2e 63 0a 40 ic/tclNamesp.c.@
2660: 40 20 2d 36 31 32 37 2c 31 31 20 2b 36 31 32 37 @ -6127,11 +6127
2670: 2c 34 34 20 40 40 20 54 63 6c 5f 49 73 45 6e 73 ,44 @@ Tcl_IsEns
2680: 65 6d 62 6c 65 28 0a 20 20 2a 09 65 6e 73 65 6d emble(. *.ensem
2690: 62 6c 65 20 77 69 6c 6c 20 62 65 20 73 75 62 6a ble will be subj
26a0: 65 63 74 20 74 6f 20 28 6c 69 6d 69 74 65 64 29 ect to (limited)
26b0: 20 63 6f 6d 70 69 6c 61 74 69 6f 6e 20 69 66 20 compilation if
26c0: 61 6e 79 20 6f 66 20 74 68 65 0a 20 20 2a 09 69 any of the. *.i
26d0: 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 63 6f mplementation co
26e0: 6d 6d 61 6e 64 73 20 61 72 65 20 63 6f 6d 70 69 mmands are compi
26f0: 6c 61 62 6c 65 2e 0a 20 20 2a 0a 2b 20 2a 20 20 lable.. *.+ *
2700: 20 20 20 20 54 68 65 20 65 6e 73 65 6d 62 6c 65 The ensemble
2710: 20 6e 61 6d 65 20 6d 61 79 20 62 65 20 61 20 74 name may be a t
2720: 6f 70 2d 6c 65 76 65 6c 20 63 6f 6d 6d 61 6e 64 op-level command
2730: 2c 20 6c 69 6b 65 20 22 62 69 6e 61 72 79 22 2e , like "binary".
2740: 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20 20 20 20 20 .+ *.+ *
2750: 54 6f 70 2d 6c 65 76 65 6c 20 63 6f 6d 6d 61 6e Top-level comman
2760: 64 73 20 61 72 65 20 70 6c 61 63 65 64 20 69 6e ds are placed in
2770: 20 74 68 65 20 67 6c 6f 62 61 6c 20 6e 61 6d 65 the global name
2780: 73 70 61 63 65 20 61 6e 64 20 74 68 65 0a 2b 20 space and the.+
2790: 2a 20 20 20 20 20 20 20 20 65 6e 73 65 6d 62 6c * ensembl
27a0: 65 20 73 75 62 2d 63 6f 6d 6d 61 6e 64 20 70 72 e sub-command pr
27b0: 6f 63 65 64 75 72 65 73 20 61 72 65 20 70 6c 61 ocedures are pla
27c0: 63 65 64 20 69 6e 20 74 68 65 20 3a 3a 74 63 6c ced in the ::tcl
27d0: 3a 3a 24 6e 61 6d 65 0a 2b 20 2a 20 20 20 20 20 ::$name.+ *
27e0: 20 20 20 6e 61 6d 65 73 70 61 63 65 2e 20 46 6f namespace. Fo
27f0: 72 20 74 68 65 20 27 62 69 6e 61 72 79 27 20 63 r the 'binary' c
2800: 6f 6d 6d 61 6e 64 20 61 6e 64 20 69 74 73 20 27 ommand and its '
2810: 66 6f 72 6d 61 74 27 2c 20 27 73 63 61 6e 27 2c format', 'scan',
2820: 20 65 74 63 0a 2b 20 2a 20 20 20 20 20 20 20 20 etc.+ *
2830: 73 75 62 2d 63 6f 6d 6d 61 6e 64 73 2c 20 74 68 sub-commands, th
2840: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 63 6f 6d 6d e following comm
2850: 61 6e 64 73 20 61 72 65 20 63 72 65 61 74 65 64 ands are created
2860: 3a 0a 2b 20 2a 20 20 20 20 20 20 20 20 20 20 3a :.+ * :
2870: 3a 62 69 6e 61 72 79 0a 2b 20 2a 20 20 20 20 20 :binary.+ *
2880: 20 20 20 20 20 3a 3a 74 63 6c 3a 3a 62 69 6e 61 ::tcl::bina
2890: 72 79 3a 3a 66 6f 72 6d 61 74 0a 2b 20 2a 20 20 ry::format.+ *
28a0: 20 20 20 20 20 20 20 20 3a 3a 74 63 6c 3a 3a 62 ::tcl::b
28b0: 69 6e 61 72 79 3a 3a 73 63 61 6e 0a 2b 20 2a 20 inary::scan.+ *
28c0: 20 20 20 20 20 20 20 20 20 3a 3a 74 63 6c 3a 3a ::tcl::
28d0: 62 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 0a 2b binary::encode.+
28e0: 20 2a 20 20 20 20 20 20 20 20 20 20 3a 3a 74 63 * ::tc
28f0: 6c 3a 3a 62 69 6e 61 72 79 3a 3a 64 65 63 6f 64 l::binary::decod
2900: 65 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20 20 20 54 e.+ *.+ * T
2910: 68 65 20 65 6e 73 65 6d 62 6c 65 20 6e 61 6d 65 he ensemble name
2920: 20 6d 61 79 20 62 65 20 61 20 6e 65 73 74 65 64 may be a nested
2930: 20 65 6e 73 65 6d 62 6c 65 20 63 6f 6d 6d 61 6e ensemble comman
2940: 64 2c 20 6c 69 6b 65 0a 2b 20 2a 20 20 20 20 20 d, like.+ *
2950: 20 22 62 69 6e 61 72 79 20 65 6e 63 6f 64 65 22 "binary encode"
2960: 2e 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20 20 20 20 ..+ *.+ *
2970: 20 4e 65 73 74 65 64 20 63 6f 6d 6d 61 6e 64 73 Nested commands
2980: 20 61 72 65 20 70 6c 61 63 65 64 20 69 6e 20 74 are placed in t
2990: 68 65 69 72 20 70 72 6f 70 65 72 20 6e 65 73 74 heir proper nest
29a0: 65 64 2d 6e 61 6d 65 73 70 61 63 65 0a 2b 20 2a ed-namespace.+ *
29b0: 20 20 20 20 20 20 20 20 70 6c 61 63 65 73 20 28 places (
29c0: 77 68 65 72 65 20 74 68 65 79 20 62 65 6c 6f 6e where they belon
29d0: 67 29 2e 20 46 6f 72 20 65 78 61 6d 70 6c 65 2c g). For example,
29e0: 20 74 68 65 20 27 62 69 6e 61 72 79 20 65 6e 63 the 'binary enc
29f0: 6f 64 65 27 0a 2b 20 2a 20 20 20 20 20 20 20 20 ode'.+ *
2a00: 6e 65 73 74 65 64 20 65 6e 73 65 6d 62 6c 65 20 nested ensemble
2a10: 63 6f 6d 6d 61 6e 64 20 61 6e 64 20 69 74 73 20 command and its
2a20: 27 68 65 78 27 2c 20 27 75 75 65 6e 63 6f 64 65 'hex', 'uuencode
2a30: 27 2c 20 61 6e 64 20 27 62 61 73 65 36 34 27 0a ', and 'base64'.
2a40: 2b 20 2a 20 20 20 20 20 20 20 20 73 75 62 2d 63 + * sub-c
2a50: 6f 6d 6d 61 6e 64 73 20 6e 61 6d 65 73 20 61 72 ommands names ar
2a60: 65 3a 0a 2b 20 2a 20 20 20 20 20 20 20 20 20 20 e:.+ *
2a70: 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a 65 ::tcl::binary::e
2a80: 6e 63 6f 64 65 0a 2b 20 2a 20 20 20 20 20 20 20 ncode.+ *
2a90: 20 20 20 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 ::tcl::binary
2aa0: 3a 3a 65 6e 63 6f 64 65 3a 3a 68 65 78 0a 2b 20 ::encode::hex.+
2ab0: 2a 20 20 20 20 20 20 20 20 20 20 3a 3a 74 63 6c * ::tcl
2ac0: 3a 3a 62 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 ::binary::encode
2ad0: 3a 3a 75 75 65 6e 63 6f 64 65 0a 2b 20 2a 20 20 ::uuencode.+ *
2ae0: 20 20 20 20 20 20 20 20 3a 3a 74 63 6c 3a 3a 62 ::tcl::b
2af0: 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 3a 3a 62 inary::encode::b
2b00: 61 73 65 36 34 0a 2b 20 2a 0a 2b 20 2a 20 41 64 ase64.+ *.+ * Ad
2b10: 64 69 74 69 6f 6e 61 6c 20 6e 6f 74 65 73 3a 0a ditional notes:.
2b20: 2b 20 2a 20 20 20 20 20 20 43 75 72 72 65 6e 74 + * Current
2b30: 6c 79 2c 20 74 68 65 20 54 43 4c 5f 45 4e 53 45 ly, the TCL_ENSE
2b40: 4d 42 4c 45 5f 50 52 45 46 49 58 20 65 6e 73 65 MBLE_PREFIX ense
2b50: 6d 62 6c 65 20 66 6c 61 67 20 69 73 20 6f 6e 6c mble flag is onl
2b60: 79 20 75 73 65 64 20 6f 6e 0a 2b 20 2a 20 20 20 y used on.+ *
2b70: 20 20 20 74 6f 70 2d 6c 65 76 65 6c 20 65 6e 73 top-level ens
2b80: 65 6d 62 6c 65 20 63 6f 6d 6d 61 6e 64 73 2e 20 emble commands.
2b90: 54 68 61 74 20 69 73 20 74 68 65 20 77 61 79 20 That is the way
2ba0: 74 68 65 20 27 62 69 6e 61 72 79 27 20 63 6f 6d the 'binary' com
2bb0: 6d 61 6e 64 0a 2b 20 2a 20 20 20 20 20 20 77 61 mand.+ * wa
2bc0: 73 20 6f 72 69 67 69 6e 61 6c 6c 79 20 65 6e 63 s originally enc
2bd0: 6f 64 65 64 2e 2e 2e 0a 2b 20 2a 0a 2b 20 2a 20 oded....+ *.+ *
2be0: 20 20 20 20 20 54 68 65 20 45 6e 73 65 6d 62 6c The Ensembl
2bf0: 65 49 6d 70 6c 4d 61 70 20 63 75 72 72 65 6e 74 eImplMap current
2c00: 6c 79 20 68 61 73 20 74 68 65 20 54 63 6c 5f 43 ly has the Tcl_C
2c10: 6d 64 44 65 6c 65 74 65 50 72 6f 63 20 69 74 65 mdDeleteProc ite
2c20: 6d 0a 2b 20 2a 20 20 20 20 20 20 63 6f 6d 6d 65 m.+ * comme
2c30: 6e 74 65 64 2d 6f 75 74 20 2d 2d 49 20 64 6f 6e nted-out --I don
2c40: 27 74 20 74 68 69 6e 6b 20 69 74 20 69 73 20 65 't think it is e
2c50: 76 65 72 20 75 73 65 64 20 69 6e 20 63 6f 72 65 ver used in core
2c60: 20 63 6f 6d 6d 61 6e 64 73 2e 20 48 65 6e 63 65 commands. Hence
2c70: 2c 0a 2b 20 2a 20 20 20 20 20 20 69 74 20 69 73 ,.+ * it is
2c80: 20 63 6f 6d 6d 65 6e 74 65 64 20 6f 75 74 20 62 commented out b
2c90: 65 6c 6f 77 20 61 73 20 77 65 6c 6c 2e 2e 2e 20 elow as well...
2ca0: 0a 2b 20 2a 0a 20 20 2a 20 52 65 73 75 6c 74 73 .+ *. * Results
2cb0: 3a 0a 2d 20 2a 09 48 61 6e 64 6c 65 20 66 6f 72 :.- *.Handle for
2cc0: 20 74 68 65 20 65 6e 73 65 6d 62 6c 65 2c 20 6f the ensemble, o
2cd0: 72 20 4e 55 4c 4c 20 69 66 20 63 72 65 61 74 69 r NULL if creati
2ce0: 6f 6e 20 6f 66 20 69 74 20 66 61 69 6c 73 2e 0a on of it fails..
2cf0: 2b 20 2a 09 48 61 6e 64 6c 65 20 66 6f 72 20 74 + *.Handle for t
2d00: 68 65 20 6e 65 77 20 65 6e 73 65 6d 62 6c 65 2c he new ensemble,
2d10: 20 6f 72 20 4e 55 4c 4c 20 6f 6e 20 66 61 69 6c or NULL on fail
2d20: 75 72 65 2e 0a 20 20 2a 0a 20 20 2a 20 53 69 64 ure.. *. * Sid
2d30: 65 20 65 66 66 65 63 74 73 3a 0a 2d 20 2a 09 4d e effects:.- *.M
2d40: 61 79 20 61 64 76 61 6e 63 65 20 62 79 74 65 63 ay advance bytec
2d50: 6f 64 65 20 63 6f 6d 70 69 6c 61 74 69 6f 6e 20 ode compilation
2d60: 65 70 6f 63 68 2e 0a 2b 20 2a 09 4d 61 79 20 61 epoch..+ *.May a
2d70: 64 76 61 6e 63 65 20 74 68 65 20 62 79 74 65 63 dvance the bytec
2d80: 6f 64 65 20 63 6f 6d 70 69 6c 61 74 69 6f 6e 20 ode compilation
2d90: 65 70 6f 63 68 2e 0a 20 20 2a 0a 20 20 2a 2d 2d epoch.. *. *--
2da0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
2db0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
2dc0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
2dd0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
2de0: 2d 2d 2d 2d 0a 20 20 2a 2f 0a 40 40 20 2d 36 31 ----. */.@@ -61
2df0: 33 39 2c 35 38 20 2b 36 31 37 32 2c 39 30 20 40 39,58 +6172,90 @
2e00: 40 20 54 63 6c 5f 49 73 45 6e 73 65 6d 62 6c 65 @ Tcl_IsEnsemble
2e10: 28 0a 20 54 63 6c 5f 43 6f 6d 6d 61 6e 64 0a 20 (. Tcl_Command.
2e20: 54 63 6c 4d 61 6b 65 45 6e 73 65 6d 62 6c 65 28 TclMakeEnsemble(
2e30: 0a 20 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 70 . Tcl_Interp
2e40: 20 2a 69 6e 74 65 72 70 2c 0a 2d 20 20 20 20 63 *interp,.- c
2e50: 6f 6e 73 74 20 63 68 61 72 20 2a 6e 61 6d 65 2c onst char *name,
2e60: 0a 2d 20 20 20 20 63 6f 6e 73 74 20 45 6e 73 65 .- const Ense
2e70: 6d 62 6c 65 49 6d 70 6c 4d 61 70 20 6d 61 70 5b mbleImplMap map[
2e80: 5d 29 0a 2b 20 20 20 20 63 6f 6e 73 74 20 63 68 ]).+ const ch
2e90: 61 72 20 2a 6e 61 6d 65 2c 09 09 20 2f 2a 20 54 ar *name,.. /* T
2ea0: 68 65 20 65 6e 73 65 6d 62 6c 65 20 6e 61 6d 65 he ensemble name
2eb0: 20 28 61 73 20 65 78 70 6c 61 69 6e 65 64 20 61 (as explained a
2ec0: 62 6f 76 65 29 20 2a 2f 0a 2b 20 20 20 20 63 6f bove) */.+ co
2ed0: 6e 73 74 20 45 6e 73 65 6d 62 6c 65 49 6d 70 6c nst EnsembleImpl
2ee0: 4d 61 70 20 6d 61 70 5b 5d 29 20 2f 2a 20 54 68 Map map[]) /* Th
2ef0: 65 20 73 75 62 63 6f 6d 6d 61 6e 64 73 20 74 6f e subcommands to
2f00: 20 63 72 65 61 74 65 20 2a 2f 0a 20 7b 0a 2d 20 create */. {.-
2f10: 20 20 20 54 63 6c 5f 43 6f 6d 6d 61 6e 64 20 65 Tcl_Command e
2f20: 6e 73 65 6d 62 6c 65 3b 09 2f 2a 20 54 68 65 20 nsemble;./* The
2f30: 6f 76 65 72 61 6c 6c 20 65 6e 73 65 6d 62 6c 65 overall ensemble
2f40: 2e 20 2a 2f 0a 2d 20 20 20 20 54 63 6c 5f 4e 61 . */.- Tcl_Na
2f50: 6d 65 73 70 61 63 65 20 2a 74 63 6c 4e 73 50 74 mespace *tclNsPt
2f60: 72 3b 09 2f 2a 20 52 65 66 65 72 65 6e 63 65 20 r;./* Reference
2f70: 74 6f 20 74 68 65 20 22 3a 3a 74 63 6c 22 20 6e to the "::tcl" n
2f80: 61 6d 65 73 70 61 63 65 2e 20 2a 2f 0a 2b 20 20 amespace. */.+
2f90: 20 20 54 63 6c 5f 43 6f 6d 6d 61 6e 64 20 65 6e Tcl_Command en
2fa0: 73 65 6d 62 6c 65 3b 0a 2b 20 20 20 20 54 63 6c semble;.+ Tcl
2fb0: 5f 4e 61 6d 65 73 70 61 63 65 20 2a 6e 73 3b 0a _Namespace *ns;.
2fc0: 20 20 20 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 Tcl_DString
2fd0: 20 62 75 66 3b 0a 2b 20 20 20 20 63 6f 6e 73 74 buf;.+ const
2fe0: 20 63 68 61 72 20 2a 63 75 72 72 4e 61 6d 65 3b char *currName;
2ff0: 09 2f 2a 20 75 73 65 64 20 74 6f 20 6d 61 6e 69 ./* used to mani
3000: 70 75 6c 61 74 65 20 74 68 65 20 66 75 6c 6c 20 pulate the full
3010: 6e 73 20 6e 61 6d 65 20 2a 2f 0a 2b 20 20 20 20 ns name */.+
3020: 63 6f 6e 73 74 20 63 68 61 72 20 2a 6e 65 78 74 const char *next
3030: 4e 61 6d 65 3b 09 2f 2a 20 64 69 74 74 6f 20 2a Name;./* ditto *
3040: 2f 0a 2b 20 20 20 20 69 6e 74 20 6c 65 6e 67 74 /.+ int lengt
3050: 68 3b 0a 2b 20 20 20 20 69 6e 74 20 6e 61 6d 65 h;.+ int name
3060: 43 6f 75 6e 74 3b 09 09 2f 2a 20 6e 20 3d 3d 20 Count;../* n ==
3070: 31 3a 20 74 6f 70 2d 6c 65 76 65 6c 3b 20 6e 20 1: top-level; n
3080: 3e 20 31 3a 20 6e 65 73 74 65 64 20 63 6d 64 20 > 1: nested cmd
3090: 2a 2f 0a 2b 20 20 20 20 69 6e 74 20 65 6e 73 65 */.+ int ense
30a0: 6d 62 6c 65 46 6c 61 67 73 20 3d 20 30 3b 0a 2b mbleFlags = 0;.+
30b0: 0a 2b 20 20 20 20 2f 2a 20 43 6f 6c 6c 65 63 74 .+ /* Collect
30c0: 20 74 68 65 20 61 72 67 75 6d 65 6e 74 20 65 6e the argument en
30d0: 73 65 6d 62 6c 65 20 63 6f 6d 6d 61 6e 64 20 69 semble command i
30e0: 6e 74 6f 20 61 20 63 6f 6d 70 6c 65 74 65 20 6e nto a complete n
30f0: 61 6d 65 73 70 61 63 65 20 6e 61 6d 65 2e 20 2a amespace name. *
3100: 2f 0a 20 0a 2d 20 20 20 20 74 63 6c 4e 73 50 74 /. .- tclNsPt
3110: 72 20 3d 20 54 63 6c 5f 46 69 6e 64 4e 61 6d 65 r = Tcl_FindName
3120: 73 70 61 63 65 28 69 6e 74 65 72 70 2c 20 22 3a space(interp, ":
3130: 3a 74 63 6c 22 2c 20 4e 55 4c 4c 2c 0a 2d 09 20 :tcl", NULL,.-.
3140: 20 20 20 54 43 4c 5f 43 52 45 41 54 45 5f 4e 53 TCL_CREATE_NS
3150: 5f 49 46 5f 55 4e 4b 4e 4f 57 4e 29 3b 0a 2d 20 _IF_UNKNOWN);.-
3160: 20 20 20 69 66 20 28 74 63 6c 4e 73 50 74 72 20 if (tclNsPtr
3170: 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 2d 09 54 63 6c == NULL) {.-.Tcl
3180: 5f 50 61 6e 69 63 28 22 75 6e 61 62 6c 65 20 74 _Panic("unable t
3190: 6f 20 66 69 6e 64 20 6f 72 20 63 72 65 61 74 65 o find or create
31a0: 20 3a 3a 74 63 6c 20 6e 61 6d 65 73 70 61 63 65 ::tcl namespace
31b0: 21 22 29 3b 0a 2d 20 20 20 20 7d 0a 20 20 20 20 !");.- }.
31c0: 20 54 63 6c 5f 44 53 74 72 69 6e 67 49 6e 69 74 Tcl_DStringInit
31d0: 28 26 62 75 66 29 3b 0a 2d 20 20 20 20 54 63 6c (&buf);.- Tcl
31e0: 5f 44 53 74 72 69 6e 67 41 70 70 65 6e 64 28 26 _DStringAppend(&
31f0: 62 75 66 2c 20 22 3a 3a 74 63 6c 3a 3a 22 2c 20 buf, "::tcl::",
3200: 2d 31 29 3b 0a 2d 20 20 20 20 54 63 6c 5f 44 53 -1);.- Tcl_DS
3210: 74 72 69 6e 67 41 70 70 65 6e 64 28 26 62 75 66 tringAppend(&buf
3220: 2c 20 6e 61 6d 65 2c 20 2d 31 29 3b 0a 2d 20 20 , name, -1);.-
3230: 20 20 74 63 6c 4e 73 50 74 72 20 3d 20 54 63 6c tclNsPtr = Tcl
3240: 5f 46 69 6e 64 4e 61 6d 65 73 70 61 63 65 28 69 _FindNamespace(i
3250: 6e 74 65 72 70 2c 20 54 63 6c 5f 44 53 74 72 69 nterp, Tcl_DStri
3260: 6e 67 56 61 6c 75 65 28 26 62 75 66 29 2c 20 4e ngValue(&buf), N
3270: 55 4c 4c 2c 0a 2d 09 20 20 20 20 54 43 4c 5f 43 ULL,.-. TCL_C
3280: 52 45 41 54 45 5f 4e 53 5f 49 46 5f 55 4e 4b 4e REATE_NS_IF_UNKN
3290: 4f 57 4e 29 3b 0a 2d 20 20 20 20 69 66 20 28 74 OWN);.- if (t
32a0: 63 6c 4e 73 50 74 72 20 3d 3d 20 4e 55 4c 4c 29 clNsPtr == NULL)
32b0: 20 7b 0a 2b 20 20 20 20 54 63 6c 5f 44 53 74 72 {.+ Tcl_DStr
32c0: 69 6e 67 41 70 70 65 6e 64 28 26 62 75 66 2c 20 ingAppend(&buf,
32d0: 22 3a 3a 74 63 6c 22 2c 20 2d 31 29 3b 0a 2b 20 "::tcl", -1);.+
32e0: 20 20 20 0a 2b 20 20 20 20 6e 65 78 74 4e 61 6d .+ nextNam
32f0: 65 20 3d 20 6e 61 6d 65 3b 0a 2b 20 20 20 20 6e e = name;.+ n
3300: 61 6d 65 43 6f 75 6e 74 20 3d 20 30 3b 0a 2b 20 ameCount = 0;.+
3310: 20 20 20 64 6f 20 7b 0a 2b 09 6e 61 6d 65 43 6f do {.+.nameCo
3320: 75 6e 74 2b 2b 3b 0a 2b 09 63 75 72 72 4e 61 6d unt++;.+.currNam
3330: 65 20 3d 20 6e 65 78 74 4e 61 6d 65 20 2b 20 73 e = nextName + s
3340: 74 72 73 70 6e 28 6e 65 78 74 4e 61 6d 65 2c 20 trspn(nextName,
3350: 22 20 5c 74 22 29 3b 0a 2b 09 6e 65 78 74 4e 61 " \t");.+.nextNa
3360: 6d 65 20 3d 20 73 74 72 70 62 72 6b 28 63 75 72 me = strpbrk(cur
3370: 72 4e 61 6d 65 2c 20 22 20 5c 74 22 29 3b 0a 2b rName, " \t");.+
3380: 09 6c 65 6e 67 74 68 20 3d 20 28 6e 65 78 74 4e .length = (nextN
3390: 61 6d 65 20 3d 3d 20 4e 55 4c 4c 29 20 3f 20 2d ame == NULL) ? -
33a0: 31 20 3a 20 28 6e 65 78 74 4e 61 6d 65 20 2d 20 1 : (nextName -
33b0: 63 75 72 72 4e 61 6d 65 29 3b 0a 2b 0a 2b 09 54 currName);.+.+.T
33c0: 63 6c 5f 44 53 74 72 69 6e 67 41 70 70 65 6e 64 cl_DStringAppend
33d0: 28 26 62 75 66 2c 20 22 3a 3a 22 2c 20 32 29 3b (&buf, "::", 2);
33e0: 0a 2b 09 54 63 6c 5f 44 53 74 72 69 6e 67 41 70 .+.Tcl_DStringAp
33f0: 70 65 6e 64 28 26 62 75 66 2c 20 63 75 72 72 4e pend(&buf, currN
3400: 61 6d 65 2c 20 6c 65 6e 67 74 68 29 3b 0a 2b 20 ame, length);.+
3410: 20 20 20 7d 20 77 68 69 6c 65 20 28 6e 65 78 74 } while (next
3420: 4e 61 6d 65 29 3b 0a 2b 0a 2b 20 20 20 20 2f 2a Name);.+.+ /*
3430: 20 43 72 65 61 74 65 20 74 68 65 20 65 6e 73 65 Create the ense
3440: 6d 62 6c 65 27 73 20 6e 61 6d 65 73 70 61 63 65 mble's namespace
3450: 20 2a 2f 0a 2b 20 20 20 20 6e 73 20 3d 20 54 63 */.+ ns = Tc
3460: 6c 5f 46 69 6e 64 4e 61 6d 65 73 70 61 63 65 28 l_FindNamespace(
3470: 69 6e 74 65 72 70 2c 20 54 63 6c 5f 44 53 74 72 interp, Tcl_DStr
3480: 69 6e 67 56 61 6c 75 65 28 26 62 75 66 29 2c 0a ingValue(&buf),.
3490: 2b 09 4e 55 4c 4c 2c 20 54 43 4c 5f 43 52 45 41 +.NULL, TCL_CREA
34a0: 54 45 5f 4e 53 5f 49 46 5f 55 4e 4b 4e 4f 57 4e TE_NS_IF_UNKNOWN
34b0: 29 3b 0a 2b 20 20 20 20 69 66 20 28 21 6e 73 29 );.+ if (!ns)
34c0: 20 7b 0a 20 09 54 63 6c 5f 50 61 6e 69 63 28 22 {. .Tcl_Panic("
34d0: 75 6e 61 62 6c 65 20 74 6f 20 66 69 6e 64 20 6f unable to find o
34e0: 72 20 63 72 65 61 74 65 20 25 73 20 6e 61 6d 65 r create %s name
34f0: 73 70 61 63 65 21 22 2c 0a 2d 09 09 54 63 6c 5f space!",.-..Tcl_
3500: 44 53 74 72 69 6e 67 56 61 6c 75 65 28 26 62 75 DStringValue(&bu
3510: 66 29 29 3b 0a 2b 09 20 20 20 20 54 63 6c 5f 44 f));.+. Tcl_D
3520: 53 74 72 69 6e 67 56 61 6c 75 65 28 26 62 75 66 StringValue(&buf
3530: 29 29 3b 0a 20 20 20 20 20 7d 0a 2d 20 20 20 20 ));. }.-
3540: 65 6e 73 65 6d 62 6c 65 20 3d 20 54 63 6c 5f 43 ensemble = Tcl_C
3550: 72 65 61 74 65 45 6e 73 65 6d 62 6c 65 28 69 6e reateEnsemble(in
3560: 74 65 72 70 2c 20 54 63 6c 5f 44 53 74 72 69 6e terp, Tcl_DStrin
3570: 67 56 61 6c 75 65 28 26 62 75 66 29 2b 35 2c 20 gValue(&buf)+5,
3580: 74 63 6c 4e 73 50 74 72 2c 0a 2d 09 20 20 20 20 tclNsPtr,.-.
3590: 54 43 4c 5f 45 4e 53 45 4d 42 4c 45 5f 50 52 45 TCL_ENSEMBLE_PRE
35a0: 46 49 58 29 3b 0a 2d 20 20 20 20 54 63 6c 5f 44 FIX);.- Tcl_D
35b0: 53 74 72 69 6e 67 41 70 70 65 6e 64 28 26 62 75 StringAppend(&bu
35c0: 66 2c 20 22 3a 3a 22 2c 20 2d 31 29 3b 0a 2b 0a f, "::", -1);.+.
35d0: 2b 20 20 20 20 2f 2a 20 43 72 65 61 74 65 20 74 + /* Create t
35e0: 68 65 20 65 6e 73 65 6d 62 6c 65 20 69 74 73 65 he ensemble itse
35f0: 6c 66 20 69 6e 20 74 68 65 20 63 6f 72 72 65 63 lf in the correc
3600: 74 20 6e 61 6d 65 73 70 61 63 65 20 2a 2f 0a 2b t namespace */.+
3610: 20 20 20 20 63 75 72 72 4e 61 6d 65 20 3d 20 54 currName = T
3620: 63 6c 5f 44 53 74 72 69 6e 67 56 61 6c 75 65 28 cl_DStringValue(
3630: 26 62 75 66 29 20 0a 2b 09 2b 20 54 63 6c 5f 44 &buf) .+.+ Tcl_D
3640: 53 74 72 69 6e 67 4c 65 6e 67 74 68 28 26 62 75 StringLength(&bu
3650: 66 29 20 2d 20 73 74 72 6c 65 6e 28 20 63 75 72 f) - strlen( cur
3660: 72 4e 61 6d 65 20 29 3b 0a 2b 20 20 20 20 69 66 rName );.+ if
3670: 20 28 6e 61 6d 65 43 6f 75 6e 74 20 3d 3d 20 31 (nameCount == 1
3680: 29 20 7b 0a 2b 09 65 6e 73 65 6d 62 6c 65 46 6c ) {.+.ensembleFl
3690: 61 67 73 20 3d 20 54 43 4c 5f 45 4e 53 45 4d 42 ags = TCL_ENSEMB
36a0: 4c 45 5f 50 52 45 46 49 58 3b 0a 2b 09 63 75 72 LE_PREFIX;.+.cur
36b0: 72 4e 61 6d 65 20 2d 3d 20 32 3b 0a 2b 20 20 20 rName -= 2;.+
36c0: 20 7d 20 65 6c 73 65 20 7b 0a 2b 09 6e 73 20 3d } else {.+.ns =
36d0: 20 6e 73 2d 3e 70 61 72 65 6e 74 50 74 72 3b 0a ns->parentPtr;.
36e0: 2b 20 20 20 20 7d 0a 2b 20 20 20 20 65 6e 73 65 + }.+ ense
36f0: 6d 62 6c 65 20 3d 20 54 63 6c 5f 43 72 65 61 74 mble = Tcl_Creat
3700: 65 45 6e 73 65 6d 62 6c 65 28 69 6e 74 65 72 70 eEnsemble(interp
3710: 2c 20 63 75 72 72 4e 61 6d 65 2c 20 6e 73 2c 20 , currName, ns,
3720: 65 6e 73 65 6d 62 6c 65 46 6c 61 67 73 29 3b 0a ensembleFlags);.
3730: 2b 0a 2b 20 20 20 20 2f 2a 0a 2b 20 20 20 20 20 +.+ /*.+
3740: 2a 20 43 72 65 61 74 65 20 74 68 65 20 65 6e 73 * Create the ens
3750: 65 6d 62 6c 65 20 6d 61 70 70 69 6e 67 20 64 69 emble mapping di
3760: 63 74 69 6f 6e 61 72 79 20 61 6e 64 20 74 68 65 ctionary and the
3770: 20 65 6e 73 65 6d 62 6c 65 20 63 6f 6d 6d 61 6e ensemble comman
3780: 64 20 70 72 6f 63 73 0a 2b 20 20 20 20 20 2a 2f d procs.+ */
3790: 0a 2b 0a 20 20 20 20 20 69 66 20 28 65 6e 73 65 .+. if (ense
37a0: 6d 62 6c 65 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a mble != NULL) {.
37b0: 20 09 54 63 6c 5f 4f 62 6a 20 2a 6d 61 70 44 69 .Tcl_Obj *mapDi
37c0: 63 74 3b 0a 2d 09 69 6e 74 20 69 2c 20 63 6f 6d ct;.-.int i, com
37d0: 70 69 6c 65 20 3d 20 30 3b 0a 2b 09 69 6e 74 20 pile = 0;.+.int
37e0: 69 3b 0a 20 0a 2b 09 54 63 6c 5f 44 53 74 72 69 i;. .+.Tcl_DStri
37f0: 6e 67 41 70 70 65 6e 64 28 26 62 75 66 2c 20 22 ngAppend(&buf, "
3800: 3a 3a 22 2c 20 32 29 3b 0a 20 09 54 63 6c 4e 65 ::", 2);. .TclNe
3810: 77 4f 62 6a 28 6d 61 70 44 69 63 74 29 3b 0a 20 wObj(mapDict);.
3820: 09 66 6f 72 20 28 69 3d 30 20 3b 20 6d 61 70 5b .for (i=0 ; map[
3830: 69 5d 2e 6e 61 6d 65 20 21 3d 20 4e 55 4c 4c 20 i].name != NULL
3840: 3b 20 69 2b 2b 29 20 7b 0a 20 09 20 20 20 20 54 ; i++) {. . T
3850: 63 6c 5f 4f 62 6a 20 2a 66 72 6f 6d 4f 62 6a 2c cl_Obj *fromObj,
3860: 20 2a 74 6f 4f 62 6a 3b 0a 2d 09 20 20 20 20 72 *toObj;.-. r
3870: 65 67 69 73 74 65 72 20 43 6f 6d 6d 61 6e 64 20 egister Command
3880: 2a 63 6d 64 50 74 72 3b 0a 2b 09 20 20 20 20 43 *cmdPtr;.+. C
3890: 6f 6d 6d 61 6e 64 20 2a 63 6d 64 50 74 72 3b 0a ommand *cmdPtr;.
38a0: 20 0a 20 09 20 20 20 20 66 72 6f 6d 4f 62 6a 20 . . fromObj
38b0: 3d 20 54 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f = Tcl_NewStringO
38c0: 62 6a 28 6d 61 70 5b 69 5d 2e 6e 61 6d 65 2c 20 bj(map[i].name,
38d0: 2d 31 29 3b 0a 20 09 20 20 20 20 54 63 6c 4e 65 -1);. . TclNe
38e0: 77 53 74 72 69 6e 67 4f 62 6a 28 74 6f 4f 62 6a wStringObj(toObj
38f0: 2c 20 54 63 6c 5f 44 53 74 72 69 6e 67 56 61 6c , Tcl_DStringVal
3900: 75 65 28 26 62 75 66 29 2c 0a 2d 09 09 20 20 20 ue(&buf),.-..
3910: 20 54 63 6c 5f 44 53 74 72 69 6e 67 4c 65 6e 67 Tcl_DStringLeng
3920: 74 68 28 26 62 75 66 29 29 3b 0a 2b 09 09 54 63 th(&buf));.+..Tc
3930: 6c 5f 44 53 74 72 69 6e 67 4c 65 6e 67 74 68 28 l_DStringLength(
3940: 26 62 75 66 29 29 3b 0a 20 09 20 20 20 20 54 63 &buf));. . Tc
3950: 6c 5f 41 70 70 65 6e 64 54 6f 4f 62 6a 28 74 6f l_AppendToObj(to
3960: 4f 62 6a 2c 20 6d 61 70 5b 69 5d 2e 6e 61 6d 65 Obj, map[i].name
3970: 2c 20 2d 31 29 3b 0a 20 09 20 20 20 20 54 63 6c , -1);. . Tcl
3980: 5f 44 69 63 74 4f 62 6a 50 75 74 28 4e 55 4c 4c _DictObjPut(NULL
3990: 2c 20 6d 61 70 44 69 63 74 2c 20 66 72 6f 6d 4f , mapDict, fromO
39a0: 62 6a 2c 20 74 6f 4f 62 6a 29 3b 0a 2d 09 20 20 bj, toObj);.-.
39b0: 20 20 63 6d 64 50 74 72 20 3d 20 28 43 6f 6d 6d cmdPtr = (Comm
39c0: 61 6e 64 20 2a 29 20 54 63 6c 5f 43 72 65 61 74 and *) Tcl_Creat
39d0: 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 69 6e 74 65 eObjCommand(inte
39e0: 72 70 2c 0a 2d 09 09 20 20 20 20 54 63 6c 47 65 rp,.-.. TclGe
39f0: 74 53 74 72 69 6e 67 28 74 6f 4f 62 6a 29 2c 20 tString(toObj),
3a00: 6d 61 70 5b 69 5d 2e 70 72 6f 63 2c 20 4e 55 4c map[i].proc, NUL
3a10: 4c 2c 20 4e 55 4c 4c 29 3b 0a 2d 09 20 20 20 20 L, NULL);.-.
3a20: 63 6d 64 50 74 72 2d 3e 63 6f 6d 70 69 6c 65 50 cmdPtr->compileP
3a30: 72 6f 63 20 3d 20 6d 61 70 5b 69 5d 2e 63 6f 6d roc = map[i].com
3a40: 70 69 6c 65 50 72 6f 63 3b 0a 2d 09 20 20 20 20 pileProc;.-.
3a50: 63 6d 64 50 74 72 2d 3e 6e 72 65 50 72 6f 63 20 cmdPtr->nreProc
3a60: 3d 20 6d 61 70 5b 69 5d 2e 6e 72 65 50 72 6f 63 = map[i].nreProc
3a70: 3b 0a 2d 09 20 20 20 20 63 6f 6d 70 69 6c 65 20 ;.-. compile
3a80: 7c 3d 20 28 6d 61 70 5b 69 5d 2e 63 6f 6d 70 69 |= (map[i].compi
3a90: 6c 65 50 72 6f 63 20 21 3d 20 4e 55 4c 4c 29 3b leProc != NULL);
3aa0: 0a 2b 09 20 20 20 20 69 66 20 28 6d 61 70 5b 69 .+. if (map[i
3ab0: 5d 2e 70 72 6f 63 29 20 7b 0a 2b 09 09 63 6d 64 ].proc) {.+..cmd
3ac0: 50 74 72 20 3d 20 28 43 6f 6d 6d 61 6e 64 20 2a Ptr = (Command *
3ad0: 29 54 63 6c 5f 43 72 65 61 74 65 4f 62 6a 43 6f )Tcl_CreateObjCo
3ae0: 6d 6d 61 6e 64 28 69 6e 74 65 72 70 2c 0a 2b 09 mmand(interp,.+.
3af0: 09 20 20 20 20 54 63 6c 47 65 74 53 74 72 69 6e . TclGetStrin
3b00: 67 28 74 6f 4f 62 6a 29 2c 20 6d 61 70 5b 69 5d g(toObj), map[i]
3b10: 2e 70 72 6f 63 2c 0a 2b 09 09 20 20 20 20 6d 61 .proc,.+.. ma
3b20: 70 5b 69 5d 2e 63 6c 69 65 6e 74 44 61 74 61 2c p[i].clientData,
3b30: 20 6d 61 70 5b 69 5d 2e 64 65 6c 65 74 65 50 72 map[i].deletePr
3b40: 6f 63 29 3b 0a 2b 09 09 63 6d 64 50 74 72 2d 3e oc);.+..cmdPtr->
3b50: 63 6f 6d 70 69 6c 65 50 72 6f 63 20 3d 20 6d 61 compileProc = ma
3b60: 70 5b 69 5d 2e 63 6f 6d 70 69 6c 65 50 72 6f 63 p[i].compileProc
3b70: 3b 0a 2b 09 09 63 6d 64 50 74 72 2d 3e 6e 72 65 ;.+..cmdPtr->nre
3b80: 50 72 6f 63 20 3d 20 6d 61 70 5b 69 5d 2e 6e 72 Proc = map[i].nr
3b90: 65 50 72 6f 63 3b 0a 2b 09 09 69 66 20 28 6d 61 eProc;.+..if (ma
3ba0: 70 5b 69 5d 2e 63 6f 6d 70 69 6c 65 50 72 6f 63 p[i].compileProc
3bb0: 20 21 3d 20 4e 55 4c 4c 29 0a 2b 09 09 20 20 20 != NULL).+..
3bc0: 20 65 6e 73 65 6d 62 6c 65 46 6c 61 67 73 20 7c ensembleFlags |
3bd0: 3d 20 45 4e 53 45 4d 42 4c 45 5f 43 4f 4d 50 49 = ENSEMBLE_COMPI
3be0: 4c 45 3b 0a 2b 09 20 20 20 20 7d 0a 20 09 7d 0a LE;.+. }. .}.
3bf0: 20 09 54 63 6c 5f 53 65 74 45 6e 73 65 6d 62 6c .Tcl_SetEnsembl
3c00: 65 4d 61 70 70 69 6e 67 44 69 63 74 28 69 6e 74 eMappingDict(int
3c10: 65 72 70 2c 20 65 6e 73 65 6d 62 6c 65 2c 20 6d erp, ensemble, m
3c20: 61 70 44 69 63 74 29 3b 0a 2d 09 69 66 20 28 63 apDict);.-.if (c
3c30: 6f 6d 70 69 6c 65 29 20 7b 0a 2d 09 20 20 20 20 ompile) {.-.
3c40: 54 63 6c 5f 53 65 74 45 6e 73 65 6d 62 6c 65 46 Tcl_SetEnsembleF
3c50: 6c 61 67 73 28 69 6e 74 65 72 70 2c 20 65 6e 73 lags(interp, ens
3c60: 65 6d 62 6c 65 2c 0a 2d 09 09 20 20 20 20 54 43 emble,.-.. TC
3c70: 4c 5f 45 4e 53 45 4d 42 4c 45 5f 50 52 45 46 49 L_ENSEMBLE_PREFI
3c80: 58 20 7c 20 45 4e 53 45 4d 42 4c 45 5f 43 4f 4d X | ENSEMBLE_COM
3c90: 50 49 4c 45 29 3b 0a 2b 09 69 66 20 28 65 6e 73 PILE);.+.if (ens
3ca0: 65 6d 62 6c 65 46 6c 61 67 73 20 26 20 45 4e 53 embleFlags & ENS
3cb0: 45 4d 42 4c 45 5f 43 4f 4d 50 49 4c 45 29 20 7b EMBLE_COMPILE) {
3cc0: 0a 2b 09 20 20 20 20 54 63 6c 5f 53 65 74 45 6e .+. Tcl_SetEn
3cd0: 73 65 6d 62 6c 65 46 6c 61 67 73 28 69 6e 74 65 sembleFlags(inte
3ce0: 72 70 2c 20 65 6e 73 65 6d 62 6c 65 2c 20 65 6e rp, ensemble, en
3cf0: 73 65 6d 62 6c 65 46 6c 61 67 73 29 3b 0a 20 09 sembleFlags);. .
3d00: 7d 0a 20 20 20 20 20 7d 0a 2d 20 20 20 20 54 63 }. }.- Tc
3d10: 6c 5f 44 53 74 72 69 6e 67 46 72 65 65 28 26 62 l_DStringFree(&b
3d20: 75 66 29 3b 0a 20 0a 2b 20 20 20 20 54 63 6c 5f uf);. .+ Tcl_
3d30: 44 53 74 72 69 6e 67 46 72 65 65 28 26 62 75 66 DStringFree(&buf
3d40: 29 3b 0a 20 20 20 20 20 72 65 74 75 72 6e 20 65 );. return e
3d50: 6e 73 65 6d 62 6c 65 3b 0a 20 7d 0a 20 0c 0a nsemble;. }. ..