Attachment "tip287-revised.patch" to
ticket [1586860fff]
added by
cleverly
2006-11-06 07:03:34.
0000: 2d 2d 2d 20 64 6f 63 2f 63 68 61 6e 2e 6e 2e 6f --- doc/chan.n.o
0010: 72 69 67 09 32 30 30 36 2d 31 30 2d 32 38 20 32 rig.2006-10-28 2
0020: 32 3a 33 37 3a 34 38 2e 30 30 30 30 30 30 30 30 2:37:48.00000000
0030: 30 20 2d 30 36 30 30 0a 2b 2b 2b 20 64 6f 63 2f 0 -0600.+++ doc/
0040: 63 68 61 6e 2e 6e 09 32 30 30 36 2d 31 31 2d 30 chan.n.2006-11-0
0050: 35 20 31 34 3a 35 39 3a 33 38 2e 30 30 30 30 30 5 14:59:38.00000
0060: 30 30 30 30 20 2d 30 37 30 30 0a 40 40 20 2d 34 0000 -0700.@@ -4
0070: 39 33 2c 36 20 2b 34 39 33 2c 32 31 20 40 40 0a 93,6 +493,21 @@.
0080: 20 6f 6e 6c 79 20 74 68 6f 73 65 20 63 68 61 6e only those chan
0090: 6e 65 6c 20 6e 61 6d 65 73 20 74 68 61 74 20 6d nel names that m
00a0: 61 74 63 68 20 69 74 20 28 61 63 63 6f 72 64 69 atch it (accordi
00b0: 6e 67 20 74 6f 20 74 68 65 20 72 75 6c 65 73 20 ng to the rules
00c0: 6f 66 0a 20 5c 66 42 73 74 72 69 6e 67 20 6d 61 of. \fBstring ma
00d0: 74 63 68 5c 66 52 29 20 77 69 6c 6c 20 62 65 20 tch\fR) will be
00e0: 72 65 74 75 72 6e 65 64 2e 0a 20 2e 54 50 0a 2b returned.. .TP.+
00f0: 5c 66 42 63 68 61 6e 20 70 65 6e 64 69 6e 67 69 \fBchan pendingi
0100: 6e 70 75 74 20 5c 66 49 63 68 61 6e 6e 65 6c 49 nput \fIchannelI
0110: 64 5c 66 52 0a 2b 2e 0a 2b 54 68 69 73 20 72 65 d\fR.+..+This re
0120: 74 75 72 6e 73 20 74 68 65 20 6e 75 6d 62 65 72 turns the number
0130: 20 6f 66 20 62 79 74 65 73 20 6f 66 20 69 6e 70 of bytes of inp
0140: 75 74 20 63 75 72 72 65 6e 74 6c 79 20 62 75 66 ut currently buf
0150: 66 65 72 65 64 20 0a 2b 69 6e 74 65 72 6e 61 6c fered .+internal
0160: 6c 79 20 66 6f 72 20 5c 66 49 63 68 61 6e 6e 65 ly for \fIchanne
0170: 6c 49 64 5c 66 72 20 28 65 73 70 65 63 69 61 6c lId\fr (especial
0180: 6c 79 20 75 73 65 66 75 6c 20 69 6e 20 61 20 72 ly useful in a r
0190: 65 61 64 61 62 6c 65 20 65 76 65 6e 74 20 0a 2b eadable event .+
01a0: 63 61 6c 6c 62 61 63 6b 20 74 6f 20 69 6d 70 6f callback to impo
01b0: 73 65 20 61 70 70 6c 69 63 61 74 69 6f 6e 2d 73 se application-s
01c0: 70 65 63 69 66 69 63 20 6c 69 6d 69 74 73 20 6f pecific limits o
01d0: 6e 20 6c 69 6e 65 20 6c 65 6e 67 74 68 73 20 74 n line lengths t
01e0: 6f 20 61 76 6f 69 64 0a 2b 61 20 70 6f 74 65 6e o avoid.+a poten
01f0: 74 69 61 6c 20 64 65 6e 69 61 6c 2d 6f 66 2d 73 tial denial-of-s
0200: 65 72 76 69 63 65 20 61 74 74 61 63 6b 20 77 68 ervice attack wh
0210: 65 72 65 20 61 20 68 6f 73 74 69 6c 65 20 75 73 ere a hostile us
0220: 65 72 20 63 72 61 66 74 73 0a 2b 61 6e 20 65 78 er crafts.+an ex
0230: 74 72 65 6d 65 6c 79 20 6c 6f 6e 67 20 6c 69 6e tremely long lin
0240: 65 20 74 68 61 74 20 65 78 63 65 65 64 73 20 74 e that exceeds t
0250: 68 65 20 61 76 61 69 6c 61 62 6c 65 20 6d 65 6d he available mem
0260: 6f 72 79 20 74 6f 20 62 75 66 66 65 72 20 69 74 ory to buffer it
0270: 29 2e 0a 2b 52 65 74 75 72 6e 73 20 2d 31 20 69 )..+Returns -1 i
0280: 66 20 74 68 65 20 63 68 61 6e 6e 65 6c 20 77 61 f the channel wa
0290: 73 20 6e 6f 74 20 6f 70 65 6e 65 64 20 66 6f 72 s not opened for
02a0: 20 72 65 61 64 69 6e 67 2e 0a 2b 2e 54 50 0a 2b reading..+.TP.+
02b0: 5c 66 42 63 68 61 6e 20 70 65 6e 64 69 6e 67 6f \fBchan pendingo
02c0: 75 74 70 75 74 20 5c 66 49 63 68 61 6e 6e 65 6c utput \fIchannel
02d0: 49 64 5c 66 52 0a 2b 2e 0a 2b 54 68 69 73 20 72 Id\fR.+..+This r
02e0: 65 74 75 72 6e 73 20 74 68 65 20 6e 75 6d 62 65 eturns the numbe
02f0: 72 20 6f 66 20 62 79 74 65 73 20 6f 66 20 6f 75 r of bytes of ou
0300: 74 70 75 74 20 63 75 72 72 65 6e 74 6c 79 20 62 tput currently b
0310: 75 66 66 65 72 65 64 20 0a 2b 69 6e 74 65 72 6e uffered .+intern
0320: 61 6c 6c 79 20 66 6f 72 20 5c 66 49 63 68 61 6e ally for \fIchan
0330: 6e 65 6c 49 64 5c 66 72 2e 20 52 65 74 75 72 6e nelId\fr. Return
0340: 73 20 2d 31 20 69 66 20 74 68 65 20 63 68 61 6e s -1 if the chan
0350: 6e 65 6c 20 77 61 73 20 6e 6f 74 20 0a 2b 6f 70 nel was not .+op
0360: 65 6e 65 64 20 66 6f 72 20 77 72 69 74 69 6e 67 ened for writing
0370: 2e 0a 2b 2e 54 50 0a 20 5c 66 42 63 68 61 6e 20 ..+.TP. \fBchan
0380: 70 6f 73 74 65 76 65 6e 74 20 5c 66 49 63 68 61 postevent \fIcha
0390: 6e 6e 65 6c 49 64 20 65 76 65 6e 74 53 70 65 63 nnelId eventSpec
03a0: 5c 66 52 0a 20 2e 0a 20 54 68 69 73 20 73 75 62 \fR. .. This sub
03b0: 63 6f 6d 6d 61 6e 64 20 69 73 20 75 73 65 64 20 command is used
03c0: 62 79 20 63 6f 6d 6d 61 6e 64 20 68 61 6e 64 6c by command handl
03d0: 65 72 73 20 73 70 65 63 69 66 69 65 64 20 77 69 ers specified wi
03e0: 74 68 20 5c 66 42 63 68 61 6e 0a 2d 2d 2d 20 67 th \fBchan.--- g
03f0: 65 6e 65 72 69 63 2f 74 63 6c 42 61 73 69 63 2e eneric/tclBasic.
0400: 63 2e 6f 72 69 67 09 32 30 30 36 2d 31 30 2d 32 c.orig.2006-10-2
0410: 38 20 32 31 3a 35 35 3a 35 39 2e 30 30 30 30 30 8 21:55:59.00000
0420: 30 30 30 30 20 2d 30 36 30 30 0a 2b 2b 2b 20 67 0000 -0600.+++ g
0430: 65 6e 65 72 69 63 2f 74 63 6c 42 61 73 69 63 2e eneric/tclBasic.
0440: 63 09 32 30 30 36 2d 31 31 2d 30 35 20 31 34 3a c.2006-11-05 14:
0450: 35 30 3a 33 30 2e 30 30 30 30 30 30 30 30 30 20 50:30.000000000
0460: 2d 30 37 30 30 0a 40 40 20 2d 34 38 35 2c 36 20 -0700.@@ -485,6
0470: 2b 34 38 35 2c 31 33 20 40 40 0a 20 20 20 20 20 +485,13 @@.
0480: 54 63 6c 5f 43 72 65 61 74 65 4f 62 6a 43 6f 6d Tcl_CreateObjCom
0490: 6d 61 6e 64 28 69 6e 74 65 72 70 2c 20 22 3a 3a mand(interp, "::
04a0: 74 63 6c 3a 3a 63 68 61 6e 3a 3a 72 50 6f 73 74 tcl::chan::rPost
04b0: 65 76 65 6e 74 22 2c 0a 20 09 20 20 20 20 54 63 event",. . Tc
04c0: 6c 43 68 61 6e 50 6f 73 74 45 76 65 6e 74 4f 62 lChanPostEventOb
04d0: 6a 43 6d 64 2c 20 28 43 6c 69 65 6e 74 44 61 74 jCmd, (ClientDat
04e0: 61 29 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 3b 0a a) NULL, NULL);.
04f0: 20 0a 2b 20 20 20 20 2f 2a 20 54 49 50 20 23 32 .+ /* TIP #2
0500: 38 37 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 5f 43 87 */.+ Tcl_C
0510: 72 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 reateObjCommand(
0520: 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a interp, "::tcl::
0530: 63 68 61 6e 3a 3a 50 65 6e 64 69 6e 67 49 6e 70 chan::PendingInp
0540: 75 74 22 2c 0a 2b 09 20 20 20 20 54 63 6c 43 68 ut",.+. TclCh
0550: 61 6e 50 65 6e 64 69 6e 67 49 6e 70 75 74 4f 62 anPendingInputOb
0560: 6a 43 6d 64 2c 20 28 43 6c 69 65 6e 74 44 61 74 jCmd, (ClientDat
0570: 61 29 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 3b 0a a) NULL, NULL);.
0580: 2b 0a 2b 20 20 20 20 54 63 6c 5f 43 72 65 61 74 +.+ Tcl_Creat
0590: 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 69 6e 74 65 eObjCommand(inte
05a0: 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a 63 68 61 6e rp, "::tcl::chan
05b0: 3a 3a 50 65 6e 64 69 6e 67 4f 75 74 70 75 74 22 ::PendingOutput"
05c0: 2c 0a 2b 09 20 20 20 20 54 63 6c 43 68 61 6e 50 ,.+. TclChanP
05d0: 65 6e 64 69 6e 67 4f 75 74 70 75 74 4f 62 6a 43 endingOutputObjC
05e0: 6d 64 2c 20 28 43 6c 69 65 6e 74 44 61 74 61 29 md, (ClientData)
05f0: 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 3b 0a 2b 0a NULL, NULL);.+.
0600: 20 20 20 20 20 2f 2a 0a 20 20 20 20 20 20 2a 20 /*. *
0610: 52 65 67 69 73 74 65 72 20 74 68 65 20 62 75 69 Register the bui
0620: 6c 74 2d 69 6e 20 66 75 6e 63 74 69 6f 6e 73 2e lt-in functions.
0630: 20 54 68 69 73 20 69 73 20 65 6d 70 74 79 20 6e This is empty n
0640: 6f 77 20 74 68 61 74 20 74 68 65 79 20 61 72 65 ow that they are
0650: 0a 20 20 20 20 20 20 2a 20 69 6d 70 6c 65 6d 65 . * impleme
0660: 6e 74 65 64 20 61 73 20 63 6f 6d 6d 61 6e 64 73 nted as commands
0670: 20 69 6e 20 74 68 65 20 3a 3a 74 63 6c 3a 3a 6d in the ::tcl::m
0680: 61 74 68 66 75 6e 63 20 6e 61 6d 65 73 70 61 63 athfunc namespac
0690: 65 2e 0a 2d 2d 2d 20 67 65 6e 65 72 69 63 2f 74 e..--- generic/t
06a0: 63 6c 49 6e 74 2e 68 2e 6f 72 69 67 09 32 30 30 clInt.h.orig.200
06b0: 36 2d 31 30 2d 32 38 20 32 32 3a 30 38 3a 33 38 6-10-28 22:08:38
06c0: 2e 30 30 30 30 30 30 30 30 30 20 2d 30 36 30 30 .000000000 -0600
06d0: 0a 2b 2b 2b 20 67 65 6e 65 72 69 63 2f 74 63 6c .+++ generic/tcl
06e0: 49 6e 74 2e 68 09 32 30 30 36 2d 31 31 2d 30 35 Int.h.2006-11-05
06f0: 20 31 34 3a 35 30 3a 35 33 2e 30 30 30 30 30 30 14:50:53.000000
0700: 30 30 30 20 2d 30 37 30 30 0a 40 40 20 2d 32 32 000 -0700.@@ -22
0710: 38 36 2c 36 20 2b 32 32 38 36 2c 31 32 20 40 40 86,6 +2286,12 @@
0720: 0a 20 4d 4f 44 55 4c 45 5f 53 43 4f 50 45 20 69 . MODULE_SCOPE i
0730: 6e 74 09 54 63 6c 5f 43 64 4f 62 6a 43 6d 64 28 nt.Tcl_CdObjCmd(
0740: 43 6c 69 65 6e 74 44 61 74 61 20 63 6c 69 65 6e ClientData clien
0750: 74 44 61 74 61 2c 0a 20 09 09 09 20 20 20 20 54 tData,. ... T
0760: 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 cl_Interp *inter
0770: 70 2c 20 69 6e 74 20 6f 62 6a 63 2c 0a 20 09 09 p, int objc,. ..
0780: 09 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 43 4f . Tcl_Obj *CO
0790: 4e 53 54 20 6f 62 6a 76 5b 5d 29 3b 0a 2b 4d 4f NST objv[]);.+MO
07a0: 44 55 4c 45 5f 53 43 4f 50 45 20 69 6e 74 09 54 DULE_SCOPE int.T
07b0: 63 6c 43 68 61 6e 50 65 6e 64 69 6e 67 49 6e 70 clChanPendingInp
07c0: 75 74 4f 62 6a 43 6d 64 28 0a 2b 09 09 09 20 20 utObjCmd(.+...
07d0: 20 20 43 6c 69 65 6e 74 44 61 74 61 20 63 6c 69 ClientData cli
07e0: 65 6e 74 44 61 74 61 2c 20 54 63 6c 5f 49 6e 74 entData, Tcl_Int
07f0: 65 72 70 20 2a 69 6e 74 65 72 70 2c 0a 2b 09 09 erp *interp,.+..
0800: 09 20 20 20 20 69 6e 74 20 6f 62 6a 63 2c 20 54 . int objc, T
0810: 63 6c 5f 4f 62 6a 20 2a 43 4f 4e 53 54 20 6f 62 cl_Obj *CONST ob
0820: 6a 76 5b 5d 29 3b 20 2f 2a 20 54 49 50 20 32 38 jv[]); /* TIP 28
0830: 37 20 2a 2f 0a 2b 4d 4f 44 55 4c 45 5f 53 43 4f 7 */.+MODULE_SCO
0840: 50 45 20 69 6e 74 09 54 63 6c 43 68 61 6e 50 65 PE int.TclChanPe
0850: 6e 64 69 6e 67 4f 75 74 70 75 74 4f 62 6a 43 6d ndingOutputObjCm
0860: 64 28 0a 2b 09 09 09 20 20 20 20 43 6c 69 65 6e d(.+... Clien
0870: 74 44 61 74 61 20 63 6c 69 65 6e 74 44 61 74 61 tData clientData
0880: 2c 20 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e , Tcl_Interp *in
0890: 74 65 72 70 2c 0a 2b 09 09 09 20 20 20 20 69 6e terp,.+... in
08a0: 74 20 6f 62 6a 63 2c 20 54 63 6c 5f 4f 62 6a 20 t objc, Tcl_Obj
08b0: 2a 43 4f 4e 53 54 20 6f 62 6a 76 5b 5d 29 3b 20 *CONST objv[]);
08c0: 2f 2a 20 54 49 50 20 32 38 37 20 2a 2f 0a 20 4d /* TIP 287 */. M
08d0: 4f 44 55 4c 45 5f 53 43 4f 50 45 20 69 6e 74 09 ODULE_SCOPE int.
08e0: 54 63 6c 43 68 61 6e 54 72 75 6e 63 61 74 65 4f TclChanTruncateO
08f0: 62 6a 43 6d 64 28 0a 20 09 09 09 20 20 20 20 43 bjCmd(. ... C
0900: 6c 69 65 6e 74 44 61 74 61 20 63 6c 69 65 6e 74 lientData client
0910: 44 61 74 61 2c 20 54 63 6c 5f 49 6e 74 65 72 70 Data, Tcl_Interp
0920: 20 2a 69 6e 74 65 72 70 2c 0a 20 09 09 09 20 20 *interp,. ...
0930: 20 20 69 6e 74 20 6f 62 6a 63 2c 20 54 63 6c 5f int objc, Tcl_
0940: 4f 62 6a 20 2a 43 4f 4e 53 54 20 6f 62 6a 76 5b Obj *CONST objv[
0950: 5d 29 3b 0a 2d 2d 2d 20 67 65 6e 65 72 69 63 2f ]);.--- generic/
0960: 74 63 6c 49 4f 43 6d 64 2e 63 2e 6f 72 69 67 09 tclIOCmd.c.orig.
0970: 32 30 30 36 2d 31 30 2d 32 38 20 32 31 3a 35 38 2006-10-28 21:58
0980: 3a 32 37 2e 30 30 30 30 30 30 30 30 30 20 2d 30 :27.000000000 -0
0990: 36 30 30 0a 2b 2b 2b 20 67 65 6e 65 72 69 63 2f 600.+++ generic/
09a0: 74 63 6c 49 4f 43 6d 64 2e 63 09 32 30 30 36 2d tclIOCmd.c.2006-
09b0: 31 31 2d 30 35 20 31 36 3a 33 39 3a 30 37 2e 30 11-05 16:39:07.0
09c0: 30 30 30 30 30 30 30 30 20 2d 30 37 30 30 0a 40 00000000 -0700.@
09d0: 40 20 2d 31 36 31 39 2c 36 20 2b 31 36 31 39 2c @ -1619,6 +1619,
09e0: 31 30 38 20 40 40 0a 20 7d 0a 20 0c 0a 20 2f 2a 108 @@. }. .. /*
09f0: 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d .+ *------------
0a00: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0a10: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0a20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0a30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a ---------------.
0a40: 2b 20 2a 0a 2b 20 2a 20 54 63 6c 43 68 61 6e 50 + *.+ * TclChanP
0a50: 65 6e 64 69 6e 67 49 6e 70 75 74 4f 62 6a 43 6d endingInputObjCm
0a60: 64 20 2d 2d 0a 2b 20 2a 0a 2b 20 2a 09 54 68 69 d --.+ *.+ *.Thi
0a70: 73 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 69 6e s function is in
0a80: 76 6f 6b 65 64 20 74 6f 20 70 72 6f 63 65 73 73 voked to process
0a90: 20 74 68 65 20 54 63 6c 20 22 63 68 61 6e 20 70 the Tcl "chan p
0aa0: 65 6e 64 69 6e 67 69 6e 70 75 74 20 24 63 68 61 endinginput $cha
0ab0: 6e 22 20 0a 2b 20 2a 09 63 6f 6d 6d 61 6e 64 20 n" .+ *.command
0ac0: 28 54 49 50 20 23 32 38 37 29 2e 20 53 65 65 20 (TIP #287). See
0ad0: 74 68 65 20 75 73 65 72 20 64 6f 63 75 6d 65 6e the user documen
0ae0: 74 61 74 69 6f 6e 20 66 6f 72 20 64 65 74 61 69 tation for detai
0af0: 6c 73 20 6f 6e 20 0a 2b 20 2a 09 77 68 61 74 20 ls on .+ *.what
0b00: 69 74 20 64 6f 65 73 2e 0a 2b 20 2a 0a 2b 20 2a it does..+ *.+ *
0b10: 20 52 65 73 75 6c 74 73 3a 0a 2b 20 2a 09 41 20 Results:.+ *.A
0b20: 73 74 61 6e 64 61 72 64 20 54 63 6c 20 72 65 73 standard Tcl res
0b30: 75 6c 74 2e 0a 2b 20 2a 0a 2b 20 2a 20 53 69 64 ult..+ *.+ * Sid
0b40: 65 20 65 66 66 65 63 74 73 3a 0a 2b 20 2a 09 53 e effects:.+ *.S
0b50: 65 74 73 20 69 6e 74 65 72 70 27 73 20 72 65 73 ets interp's res
0b60: 75 6c 74 20 74 6f 20 74 68 65 20 6e 75 6d 62 65 ult to the numbe
0b70: 72 20 6f 66 20 62 79 74 65 73 20 6f 66 20 69 6e r of bytes of in
0b80: 70 75 74 20 69 6e 20 74 68 65 0a 2b 20 2a 09 63 put in the.+ *.c
0b90: 68 61 6e 6e 65 6c 73 20 69 6e 70 75 74 20 62 75 hannels input bu
0ba0: 66 66 65 72 2c 20 6f 72 20 2d 31 20 69 66 20 74 ffer, or -1 if t
0bb0: 68 65 20 63 68 61 6e 6e 65 6c 20 77 61 73 6e 27 he channel wasn'
0bc0: 74 20 6f 70 65 6e 65 64 20 66 6f 72 20 0a 2b 20 t opened for .+
0bd0: 2a 09 72 65 61 64 69 6e 67 2e 0a 2b 20 2a 0a 2b *.reading..+ *.+
0be0: 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d *--------------
0bf0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0c00: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0c10: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0c20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 -------------.+
0c30: 2a 2f 0a 2b 0a 2b 09 2f 2a 20 41 52 47 53 55 53 */.+.+./* ARGSUS
0c40: 45 44 20 2a 2f 0a 2b 69 6e 74 0a 2b 54 63 6c 43 ED */.+int.+TclC
0c50: 68 61 6e 50 65 6e 64 69 6e 67 49 6e 70 75 74 4f hanPendingInputO
0c60: 62 6a 43 6d 64 28 0a 2b 20 20 20 20 43 6c 69 65 bjCmd(.+ Clie
0c70: 6e 74 44 61 74 61 20 75 6e 75 73 65 64 2c 09 09 ntData unused,..
0c80: 2f 2a 20 4e 6f 74 20 75 73 65 64 2e 20 2a 2f 0a /* Not used. */.
0c90: 2b 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 70 20 + Tcl_Interp
0ca0: 2a 69 6e 74 65 72 70 2c 09 09 2f 2a 20 43 75 72 *interp,../* Cur
0cb0: 72 65 6e 74 20 69 6e 74 65 72 70 72 65 74 65 72 rent interpreter
0cc0: 2e 20 2a 2f 0a 2b 20 20 20 20 69 6e 74 20 6f 62 . */.+ int ob
0cd0: 6a 63 2c 09 09 09 2f 2a 20 4e 75 6d 62 65 72 20 jc,.../* Number
0ce0: 6f 66 20 61 72 67 75 6d 65 6e 74 73 2e 20 2a 2f of arguments. */
0cf0: 0a 2b 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 43 .+ Tcl_Obj *C
0d00: 4f 4e 53 54 20 6f 62 6a 76 5b 5d 29 09 2f 2a 20 ONST objv[])./*
0d10: 41 72 67 75 6d 65 6e 74 20 6f 62 6a 65 63 74 73 Argument objects
0d20: 2e 20 2a 2f 0a 2b 7b 0a 2b 20 20 20 20 54 63 6c . */.+{.+ Tcl
0d30: 5f 43 68 61 6e 6e 65 6c 20 63 68 61 6e 3b 0a 2b _Channel chan;.+
0d40: 20 20 20 20 69 6e 74 20 6d 6f 64 65 3b 0a 2b 20 int mode;.+
0d50: 20 20 20 63 68 61 72 20 2a 61 72 67 3b 0a 2b 0a char *arg;.+.
0d60: 2b 20 20 20 20 69 66 20 28 6f 62 6a 63 20 21 3d + if (objc !=
0d70: 20 32 29 20 7b 0a 2b 09 54 63 6c 5f 57 72 6f 6e 2) {.+.Tcl_Wron
0d80: 67 4e 75 6d 41 72 67 73 28 69 6e 74 65 72 70 2c gNumArgs(interp,
0d90: 20 31 2c 20 6f 62 6a 76 2c 20 22 63 68 61 6e 6e 1, objv, "chann
0da0: 65 6c 49 64 22 29 3b 0a 2b 09 72 65 74 75 72 6e elId");.+.return
0db0: 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 2b 20 20 20 TCL_ERROR;.+
0dc0: 20 7d 0a 2b 0a 2b 20 20 20 20 61 72 67 20 3d 20 }.+.+ arg =
0dd0: 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 28 6f 62 Tcl_GetString(ob
0de0: 6a 76 5b 31 5d 29 3b 0a 2b 20 20 20 20 63 68 61 jv[1]);.+ cha
0df0: 6e 20 3d 20 54 63 6c 5f 47 65 74 43 68 61 6e 6e n = Tcl_GetChann
0e00: 65 6c 28 69 6e 74 65 72 70 2c 20 61 72 67 2c 20 el(interp, arg,
0e10: 26 6d 6f 64 65 29 3b 0a 2b 20 20 20 20 69 66 20 &mode);.+ if
0e20: 28 63 68 61 6e 20 3d 3d 20 4e 55 4c 4c 29 20 7b (chan == NULL) {
0e30: 0a 2b 09 72 65 74 75 72 6e 20 54 43 4c 5f 45 52 .+.return TCL_ER
0e40: 52 4f 52 3b 0a 2b 20 20 20 20 7d 0a 2b 0a 2b 20 ROR;.+ }.+.+
0e50: 20 20 20 69 66 20 28 28 6d 6f 64 65 20 26 20 54 if ((mode & T
0e60: 43 4c 5f 52 45 41 44 41 42 4c 45 29 20 3d 3d 20 CL_READABLE) ==
0e70: 30 29 20 7b 0a 2b 09 54 63 6c 5f 53 65 74 4f 62 0) {.+.Tcl_SetOb
0e80: 6a 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 jResult(interp,
0e90: 54 63 6c 5f 4e 65 77 49 6e 74 4f 62 6a 28 2d 31 Tcl_NewIntObj(-1
0ea0: 29 29 3b 0a 2b 20 20 20 20 7d 20 65 6c 73 65 20 ));.+ } else
0eb0: 7b 0a 2b 09 54 63 6c 5f 53 65 74 4f 62 6a 52 65 {.+.Tcl_SetObjRe
0ec0: 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 54 63 6c sult(interp, Tcl
0ed0: 5f 4e 65 77 49 6e 74 4f 62 6a 28 54 63 6c 5f 49 _NewIntObj(Tcl_I
0ee0: 6e 70 75 74 42 75 66 66 65 72 65 64 28 63 68 61 nputBuffered(cha
0ef0: 6e 29 29 29 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 n)));.+ }.+
0f00: 20 20 72 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b return TCL_OK;
0f10: 0a 2b 7d 0a 2b 0c 0a 2b 2f 2a 0a 2b 20 2a 2d 2d .+}.+..+/*.+ *--
0f20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0f30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0f40: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0f50: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0f60: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 0a 2b 20 ---------.+ *.+
0f70: 2a 20 54 63 6c 43 68 61 6e 50 65 6e 64 69 6e 67 * TclChanPending
0f80: 4f 75 74 70 75 74 4f 62 6a 43 6d 64 20 2d 2d 0a OutputObjCmd --.
0f90: 2b 20 2a 0a 2b 20 2a 09 54 68 69 73 20 66 75 6e + *.+ *.This fun
0fa0: 63 74 69 6f 6e 20 69 73 20 69 6e 76 6f 6b 65 64 ction is invoked
0fb0: 20 74 6f 20 70 72 6f 63 65 73 73 20 74 68 65 20 to process the
0fc0: 54 63 6c 20 22 63 68 61 6e 20 70 65 6e 64 69 6e Tcl "chan pendin
0fd0: 67 6f 75 74 70 75 74 20 24 63 68 61 6e 22 0a 2b goutput $chan".+
0fe0: 20 2a 09 63 6f 6d 6d 61 6e 64 20 28 54 49 50 20 *.command (TIP
0ff0: 23 32 38 37 29 2e 20 53 65 65 20 74 68 65 20 75 #287). See the u
1000: 73 65 72 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f ser documentatio
1010: 6e 20 66 6f 72 20 64 65 74 61 69 6c 73 20 6f 6e n for details on
1020: 20 77 68 61 74 20 0a 2b 20 2a 09 69 74 20 64 6f what .+ *.it do
1030: 65 73 2e 0a 2b 20 2a 0a 2b 20 2a 20 52 65 73 75 es..+ *.+ * Resu
1040: 6c 74 73 3a 0a 2b 20 2a 09 41 20 73 74 61 6e 64 lts:.+ *.A stand
1050: 61 72 64 20 54 63 6c 20 72 65 73 75 6c 74 2e 0a ard Tcl result..
1060: 2b 20 2a 0a 2b 20 2a 20 53 69 64 65 20 65 66 66 + *.+ * Side eff
1070: 65 63 74 73 3a 0a 2b 20 2a 09 53 65 74 73 20 69 ects:.+ *.Sets i
1080: 6e 74 65 72 70 27 73 20 72 65 73 75 6c 74 20 74 nterp's result t
1090: 6f 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 o the number of
10a0: 62 79 74 65 73 20 6f 66 20 6f 75 74 70 75 74 20 bytes of output
10b0: 69 6e 20 74 68 65 0a 2b 20 2a 09 63 68 61 6e 6e in the.+ *.chann
10c0: 65 6c 73 20 6f 75 74 70 75 74 20 62 75 66 66 65 els output buffe
10d0: 72 2c 20 6f 72 20 2d 31 20 69 66 20 74 68 65 20 r, or -1 if the
10e0: 63 68 61 6e 6e 65 6c 20 77 61 73 6e 27 74 20 6f channel wasn't o
10f0: 70 65 6e 65 64 20 66 6f 72 20 0a 2b 20 2a 09 77 pened for .+ *.w
1100: 72 69 74 69 6e 67 2e 0a 2b 20 2a 0a 2b 20 2a 2d riting..+ *.+ *-
1110: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1120: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1130: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1140: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1150: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 2f 0a ----------.+ */.
1160: 2b 0a 2b 09 2f 2a 20 41 52 47 53 55 53 45 44 20 +.+./* ARGSUSED
1170: 2a 2f 0a 2b 69 6e 74 0a 2b 54 63 6c 43 68 61 6e */.+int.+TclChan
1180: 50 65 6e 64 69 6e 67 4f 75 74 70 75 74 4f 62 6a PendingOutputObj
1190: 43 6d 64 28 0a 2b 20 20 20 20 43 6c 69 65 6e 74 Cmd(.+ Client
11a0: 44 61 74 61 20 75 6e 75 73 65 64 2c 09 09 2f 2a Data unused,../*
11b0: 20 4e 6f 74 20 75 73 65 64 2e 20 2a 2f 0a 2b 20 Not used. */.+
11c0: 20 20 20 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 Tcl_Interp *i
11d0: 6e 74 65 72 70 2c 09 09 2f 2a 20 43 75 72 72 65 nterp,../* Curre
11e0: 6e 74 20 69 6e 74 65 72 70 72 65 74 65 72 2e 20 nt interpreter.
11f0: 2a 2f 0a 2b 20 20 20 20 69 6e 74 20 6f 62 6a 63 */.+ int objc
1200: 2c 09 09 09 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 ,.../* Number of
1210: 20 61 72 67 75 6d 65 6e 74 73 2e 20 2a 2f 0a 2b arguments. */.+
1220: 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 43 4f 4e Tcl_Obj *CON
1230: 53 54 20 6f 62 6a 76 5b 5d 29 09 2f 2a 20 41 72 ST objv[])./* Ar
1240: 67 75 6d 65 6e 74 20 6f 62 6a 65 63 74 73 2e 20 gument objects.
1250: 2a 2f 0a 2b 7b 0a 2b 20 20 20 20 54 63 6c 5f 43 */.+{.+ Tcl_C
1260: 68 61 6e 6e 65 6c 20 63 68 61 6e 3b 0a 2b 20 20 hannel chan;.+
1270: 20 20 69 6e 74 20 6d 6f 64 65 3b 0a 2b 20 20 20 int mode;.+
1280: 20 63 68 61 72 20 2a 61 72 67 3b 0a 2b 0a 2b 20 char *arg;.+.+
1290: 20 20 20 69 66 20 28 6f 62 6a 63 20 21 3d 20 32 if (objc != 2
12a0: 29 20 7b 0a 2b 09 54 63 6c 5f 57 72 6f 6e 67 4e ) {.+.Tcl_WrongN
12b0: 75 6d 41 72 67 73 28 69 6e 74 65 72 70 2c 20 31 umArgs(interp, 1
12c0: 2c 20 6f 62 6a 76 2c 20 22 63 68 61 6e 6e 65 6c , objv, "channel
12d0: 49 64 22 29 3b 0a 2b 09 72 65 74 75 72 6e 20 54 Id");.+.return T
12e0: 43 4c 5f 45 52 52 4f 52 3b 0a 2b 20 20 20 20 7d CL_ERROR;.+ }
12f0: 0a 2b 0a 2b 20 20 20 20 61 72 67 20 3d 20 54 63 .+.+ arg = Tc
1300: 6c 5f 47 65 74 53 74 72 69 6e 67 28 6f 62 6a 76 l_GetString(objv
1310: 5b 31 5d 29 3b 0a 2b 20 20 20 20 63 68 61 6e 20 [1]);.+ chan
1320: 3d 20 54 63 6c 5f 47 65 74 43 68 61 6e 6e 65 6c = Tcl_GetChannel
1330: 28 69 6e 74 65 72 70 2c 20 61 72 67 2c 20 26 6d (interp, arg, &m
1340: 6f 64 65 29 3b 0a 2b 20 20 20 20 69 66 20 28 63 ode);.+ if (c
1350: 68 61 6e 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 2b han == NULL) {.+
1360: 09 72 65 74 75 72 6e 20 54 43 4c 5f 45 52 52 4f .return TCL_ERRO
1370: 52 3b 0a 2b 20 20 20 20 7d 0a 2b 0a 2b 20 20 20 R;.+ }.+.+
1380: 20 69 66 20 28 28 6d 6f 64 65 20 26 20 54 43 4c if ((mode & TCL
1390: 5f 57 52 49 54 45 41 42 4c 45 29 20 3d 3d 20 30 _WRITEABLE) == 0
13a0: 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 54 63 6c ) {.+ Tcl
13b0: 5f 53 65 74 4f 62 6a 52 65 73 75 6c 74 28 69 6e _SetObjResult(in
13c0: 74 65 72 70 2c 20 54 63 6c 5f 4e 65 77 49 6e 74 terp, Tcl_NewInt
13d0: 4f 62 6a 28 2d 31 29 29 3b 0a 2b 20 20 20 20 7d Obj(-1));.+ }
13e0: 20 65 6c 73 65 20 7b 0a 2b 20 20 20 20 20 20 20 else {.+
13f0: 20 54 63 6c 5f 53 65 74 4f 62 6a 52 65 73 75 6c Tcl_SetObjResul
1400: 74 28 69 6e 74 65 72 70 2c 20 54 63 6c 5f 4e 65 t(interp, Tcl_Ne
1410: 77 49 6e 74 4f 62 6a 28 54 63 6c 5f 4f 75 74 70 wIntObj(Tcl_Outp
1420: 75 74 42 75 66 66 65 72 65 64 28 63 68 61 6e 29 utBuffered(chan)
1430: 29 29 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 20 ));.+ }.+
1440: 72 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 2b return TCL_OK;.+
1450: 7d 0a 2b 0c 0a 2b 2f 2a 0a 20 20 2a 2d 2d 2d 2d }.+..+/*. *----
1460: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1470: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1480: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1490: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
14a0: 2d 2d 0a 20 20 2a 0a 20 20 2a 20 54 63 6c 5f 43 --. *. * Tcl_C
14b0: 68 61 6e 54 72 75 6e 63 61 74 65 4f 62 6a 43 6d hanTruncateObjCm
14c0: 64 20 2d 2d 0a 2d 2d 2d 20 6c 69 62 72 61 72 79 d --.--- library
14d0: 2f 69 6e 69 74 2e 74 63 6c 2e 6f 72 69 67 09 32 /init.tcl.orig.2
14e0: 30 30 36 2d 30 39 2d 32 32 20 31 32 3a 31 33 3a 006-09-22 12:13:
14f0: 32 39 2e 30 30 30 30 30 30 30 30 30 20 2d 30 36 29.000000000 -06
1500: 30 30 0a 2b 2b 2b 20 6c 69 62 72 61 72 79 2f 69 00.+++ library/i
1510: 6e 69 74 2e 74 63 6c 09 32 30 30 36 2d 31 31 2d nit.tcl.2006-11-
1520: 30 35 20 31 34 3a 35 36 3a 35 38 2e 30 30 30 30 05 14:56:58.0000
1530: 30 30 30 30 30 20 2d 30 37 30 30 0a 40 40 20 2d 00000 -0700.@@ -
1540: 37 38 2c 32 33 20 2b 37 38 2c 32 36 20 40 40 0a 78,23 +78,26 @@.
1550: 20 20 20 20 20 23 20 53 65 74 20 75 70 20 74 68 # Set up th
1560: 65 20 27 63 68 61 6e 27 20 65 6e 73 65 6d 62 6c e 'chan' ensembl
1570: 65 20 28 54 49 50 20 23 32 30 38 29 2e 0a 20 20 e (TIP #208)..
1580: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61 namespace eva
1590: 6c 20 63 68 61 6e 20 7b 0a 20 20 20 20 20 20 20 l chan {.
15a0: 20 20 23 20 54 49 50 20 23 32 31 39 2e 20 41 64 # TIP #219. Ad
15b0: 64 65 64 20 6d 65 74 68 6f 64 73 3a 20 63 72 65 ded methods: cre
15c0: 61 74 65 2c 20 70 6f 73 74 65 76 65 6e 74 2e 0a ate, postevent..
15d0: 2b 20 20 20 20 20 20 20 20 23 20 54 49 50 20 23 + # TIP #
15e0: 32 38 37 2e 20 41 64 64 65 64 20 6d 65 74 68 6f 287. Added metho
15f0: 64 73 3a 20 70 65 6e 64 69 6e 67 69 6e 70 75 74 ds: pendinginput
1600: 2c 20 70 65 6e 64 69 6e 67 6f 75 74 70 75 74 2e , pendingoutput.
1610: 0a 20 20 20 20 20 20 20 20 20 6e 61 6d 65 73 70 . namesp
1620: 61 63 65 20 65 6e 73 65 6d 62 6c 65 20 63 72 65 ace ensemble cre
1630: 61 74 65 20 2d 63 6f 6d 6d 61 6e 64 20 3a 3a 63 ate -command ::c
1640: 68 61 6e 20 2d 6d 61 70 20 7b 0a 2d 20 20 20 20 han -map {.-
1650: 20 20 20 20 20 20 20 20 62 6c 6f 63 6b 65 64 20 blocked
1660: 20 20 20 20 3a 3a 66 62 6c 6f 63 6b 65 64 0a 2d ::fblocked.-
1670: 20 20 20 20 20 20 20 20 20 20 20 20 63 6c 6f 73 clos
1680: 65 20 20 20 20 20 20 20 3a 3a 63 6c 6f 73 65 0a e ::close.
1690: 2d 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e - con
16a0: 66 69 67 75 72 65 20 20 20 3a 3a 66 63 6f 6e 66 figure ::fconf
16b0: 69 67 75 72 65 0a 2d 20 20 20 20 20 20 20 20 20 igure.-
16c0: 20 20 20 63 6f 70 79 20 20 20 20 20 20 20 20 3a copy :
16d0: 3a 66 63 6f 70 79 0a 2d 20 20 20 20 20 20 20 20 :fcopy.-
16e0: 20 20 20 20 63 72 65 61 74 65 20 20 20 20 20 20 create
16f0: 3a 3a 74 63 6c 3a 3a 63 68 61 6e 3a 3a 72 43 72 ::tcl::chan::rCr
1700: 65 61 74 65 0a 2d 20 20 20 20 20 20 20 20 20 20 eate.-
1710: 20 20 65 6f 66 20 20 20 20 20 20 20 20 20 3a 3a eof ::
1720: 65 6f 66 0a 2d 20 20 20 20 20 20 20 20 20 20 20 eof.-
1730: 20 65 76 65 6e 74 20 20 20 20 20 20 20 3a 3a 66 event ::f
1740: 69 6c 65 65 76 65 6e 74 0a 2d 20 20 20 20 20 20 ileevent.-
1750: 20 20 20 20 20 20 66 6c 75 73 68 20 20 20 20 20 flush
1760: 20 20 3a 3a 66 6c 75 73 68 0a 2d 20 20 20 20 20 ::flush.-
1770: 20 20 20 20 20 20 20 67 65 74 73 20 20 20 20 20 gets
1780: 20 20 20 3a 3a 67 65 74 73 0a 2d 20 20 20 20 20 ::gets.-
1790: 20 20 20 20 20 20 20 6e 61 6d 65 73 20 20 20 20 names
17a0: 20 20 20 7b 3a 3a 66 69 6c 65 20 63 68 61 6e 6e {::file chann
17b0: 65 6c 73 7d 0a 2d 20 20 20 20 20 20 20 20 20 20 els}.-
17c0: 20 20 70 6f 73 74 65 76 65 6e 74 20 20 20 3a 3a postevent ::
17d0: 74 63 6c 3a 3a 63 68 61 6e 3a 3a 72 50 6f 73 74 tcl::chan::rPost
17e0: 65 76 65 6e 74 0a 2d 20 20 20 20 20 20 20 20 20 event.-
17f0: 20 20 20 70 75 74 73 20 20 20 20 20 20 20 20 3a puts :
1800: 3a 70 75 74 73 0a 2d 20 20 20 20 20 20 20 20 20 :puts.-
1810: 20 20 20 72 65 61 64 20 20 20 20 20 20 20 20 3a read :
1820: 3a 72 65 61 64 0a 2d 20 20 20 20 20 20 20 20 20 :read.-
1830: 20 20 20 73 65 65 6b 20 20 20 20 20 20 20 20 3a seek :
1840: 3a 73 65 65 6b 0a 2d 20 20 20 20 20 20 20 20 20 :seek.-
1850: 20 20 20 74 65 6c 6c 20 20 20 20 20 20 20 20 3a tell :
1860: 3a 74 65 6c 6c 0a 2d 20 20 20 20 20 20 20 20 20 :tell.-
1870: 20 20 20 74 72 75 6e 63 61 74 65 20 20 20 20 3a truncate :
1880: 3a 74 63 6c 3a 3a 63 68 61 6e 3a 3a 54 72 75 6e :tcl::chan::Trun
1890: 63 61 74 65 0a 2b 20 20 20 20 20 20 20 20 20 20 cate.+
18a0: 20 20 70 65 6e 64 69 6e 67 69 6e 70 75 74 20 20 pendinginput
18b0: 3a 3a 74 63 6c 3a 3a 63 68 61 6e 3a 3a 50 65 6e ::tcl::chan::Pen
18c0: 64 69 6e 67 49 6e 70 75 74 0a 2b 20 20 20 20 20 dingInput.+
18d0: 20 20 20 20 20 20 20 70 65 6e 64 69 6e 67 6f 75 pendingou
18e0: 74 70 75 74 20 3a 3a 74 63 6c 3a 3a 63 68 61 6e tput ::tcl::chan
18f0: 3a 3a 50 65 6e 64 69 6e 67 4f 75 74 70 75 74 0a ::PendingOutput.
1900: 2b 20 20 20 20 20 20 20 20 20 20 20 20 62 6c 6f + blo
1910: 63 6b 65 64 20 20 20 20 20 20 20 3a 3a 66 62 6c cked ::fbl
1920: 6f 63 6b 65 64 0a 2b 20 20 20 20 20 20 20 20 20 ocked.+
1930: 20 20 20 63 6c 6f 73 65 20 20 20 20 20 20 20 20 close
1940: 20 3a 3a 63 6c 6f 73 65 0a 2b 20 20 20 20 20 20 ::close.+
1950: 20 20 20 20 20 20 63 6f 6e 66 69 67 75 72 65 20 configure
1960: 20 20 20 20 3a 3a 66 63 6f 6e 66 69 67 75 72 65 ::fconfigure
1970: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 63 6f .+ co
1980: 70 79 20 20 20 20 20 20 20 20 20 20 3a 3a 66 63 py ::fc
1990: 6f 70 79 0a 2b 20 20 20 20 20 20 20 20 20 20 20 opy.+
19a0: 20 63 72 65 61 74 65 20 20 20 20 20 20 20 20 3a create :
19b0: 3a 74 63 6c 3a 3a 63 68 61 6e 3a 3a 72 43 72 65 :tcl::chan::rCre
19c0: 61 74 65 0a 2b 20 20 20 20 20 20 20 20 20 20 20 ate.+
19d0: 20 65 6f 66 20 20 20 20 20 20 20 20 20 20 20 3a eof :
19e0: 3a 65 6f 66 0a 2b 20 20 20 20 20 20 20 20 20 20 :eof.+
19f0: 20 20 65 76 65 6e 74 20 20 20 20 20 20 20 20 20 event
1a00: 3a 3a 66 69 6c 65 65 76 65 6e 74 0a 2b 20 20 20 ::fileevent.+
1a10: 20 20 20 20 20 20 20 20 20 66 6c 75 73 68 20 20 flush
1a20: 20 20 20 20 20 20 20 3a 3a 66 6c 75 73 68 0a 2b ::flush.+
1a30: 20 20 20 20 20 20 20 20 20 20 20 20 67 65 74 73 gets
1a40: 20 20 20 20 20 20 20 20 20 20 3a 3a 67 65 74 73 ::gets
1a50: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 6e 61 .+ na
1a60: 6d 65 73 20 20 20 20 20 20 20 20 20 7b 3a 3a 66 mes {::f
1a70: 69 6c 65 20 63 68 61 6e 6e 65 6c 73 7d 0a 2b 20 ile channels}.+
1a80: 20 20 20 20 20 20 20 20 20 20 20 70 6f 73 74 65 poste
1a90: 76 65 6e 74 20 20 20 20 20 3a 3a 74 63 6c 3a 3a vent ::tcl::
1aa0: 63 68 61 6e 3a 3a 72 50 6f 73 74 65 76 65 6e 74 chan::rPostevent
1ab0: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 70 75 .+ pu
1ac0: 74 73 20 20 20 20 20 20 20 20 20 20 3a 3a 70 75 ts ::pu
1ad0: 74 73 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 ts.+
1ae0: 72 65 61 64 20 20 20 20 20 20 20 20 20 20 3a 3a read ::
1af0: 72 65 61 64 0a 2b 20 20 20 20 20 20 20 20 20 20 read.+
1b00: 20 20 73 65 65 6b 20 20 20 20 20 20 20 20 20 20 seek
1b10: 3a 3a 73 65 65 6b 0a 2b 20 20 20 20 20 20 20 20 ::seek.+
1b20: 20 20 20 20 74 65 6c 6c 20 20 20 20 20 20 20 20 tell
1b30: 20 20 3a 3a 74 65 6c 6c 0a 2b 20 20 20 20 20 20 ::tell.+
1b40: 20 20 20 20 20 20 74 72 75 6e 63 61 74 65 20 20 truncate
1b50: 20 20 20 20 3a 3a 74 63 6c 3a 3a 63 68 61 6e 3a ::tcl::chan:
1b60: 3a 54 72 75 6e 63 61 74 65 0a 20 20 20 20 20 20 :Truncate.
1b70: 20 20 20 7d 0a 20 20 20 20 20 7d 0a 20 0a 2d 2d }. }. .--
1b80: 2d 20 74 65 73 74 73 2f 63 68 61 6e 2e 74 65 73 - tests/chan.tes
1b90: 74 2e 6f 72 69 67 09 32 30 30 36 2d 31 30 2d 32 t.orig.2006-10-2
1ba0: 39 20 31 33 3a 35 39 3a 33 35 2e 30 30 30 30 30 9 13:59:35.00000
1bb0: 30 30 30 30 20 2d 30 37 30 30 0a 2b 2b 2b 20 74 0000 -0700.+++ t
1bc0: 65 73 74 73 2f 63 68 61 6e 2e 74 65 73 74 09 32 ests/chan.test.2
1bd0: 30 30 36 2d 31 31 2d 30 35 20 31 35 3a 30 37 3a 006-11-05 15:07:
1be0: 35 31 2e 30 30 30 30 30 30 30 30 30 20 2d 30 37 51.000000000 -07
1bf0: 30 30 0a 40 40 20 2d 32 34 2c 37 20 2b 32 34 2c 00.@@ -24,7 +24,
1c00: 37 20 40 40 0a 20 7d 20 2d 72 65 74 75 72 6e 43 7 @@. } -returnC
1c10: 6f 64 65 73 20 65 72 72 6f 72 20 2d 72 65 73 75 odes error -resu
1c20: 6c 74 20 22 77 72 6f 6e 67 20 23 20 61 72 67 73 lt "wrong # args
1c30: 3a 20 73 68 6f 75 6c 64 20 62 65 20 5c 22 63 68 : should be \"ch
1c40: 61 6e 20 73 75 62 63 6f 6d 6d 61 6e 64 20 3f 61 an subcommand ?a
1c50: 72 67 75 6d 65 6e 74 20 2e 2e 2e 3f 5c 22 22 0a rgument ...?\"".
1c60: 20 74 65 73 74 20 63 68 61 6e 2d 31 2e 32 20 7b test chan-1.2 {
1c70: 63 68 61 6e 20 63 6f 6d 6d 61 6e 64 20 67 65 6e chan command gen
1c80: 65 72 61 6c 20 73 79 6e 74 61 78 7d 20 2d 62 6f eral syntax} -bo
1c90: 64 79 20 7b 0a 20 20 20 20 20 63 68 61 6e 20 46 dy {. chan F
1ca0: 4f 4f 42 41 52 0a 2d 7d 20 2d 72 65 74 75 72 6e OOBAR.-} -return
1cb0: 43 6f 64 65 73 20 65 72 72 6f 72 20 2d 72 65 73 Codes error -res
1cc0: 75 6c 74 20 22 75 6e 6b 6e 6f 77 6e 20 6f 72 20 ult "unknown or
1cd0: 61 6d 62 69 67 75 6f 75 73 20 73 75 62 63 6f 6d ambiguous subcom
1ce0: 6d 61 6e 64 20 5c 22 46 4f 4f 42 41 52 5c 22 3a mand \"FOOBAR\":
1cf0: 20 6d 75 73 74 20 62 65 20 62 6c 6f 63 6b 65 64 must be blocked
1d00: 2c 20 63 6c 6f 73 65 2c 20 63 6f 6e 66 69 67 75 , close, configu
1d10: 72 65 2c 20 63 6f 70 79 2c 20 63 72 65 61 74 65 re, copy, create
1d20: 2c 20 65 6f 66 2c 20 65 76 65 6e 74 2c 20 66 6c , eof, event, fl
1d30: 75 73 68 2c 20 67 65 74 73 2c 20 6e 61 6d 65 73 ush, gets, names
1d40: 2c 20 70 6f 73 74 65 76 65 6e 74 2c 20 70 75 74 , postevent, put
1d50: 73 2c 20 72 65 61 64 2c 20 73 65 65 6b 2c 20 74 s, read, seek, t
1d60: 65 6c 6c 2c 20 6f 72 20 74 72 75 6e 63 61 74 65 ell, or truncate
1d70: 22 0a 2b 7d 20 2d 72 65 74 75 72 6e 43 6f 64 65 ".+} -returnCode
1d80: 73 20 65 72 72 6f 72 20 2d 72 65 73 75 6c 74 20 s error -result
1d90: 22 75 6e 6b 6e 6f 77 6e 20 6f 72 20 61 6d 62 69 "unknown or ambi
1da0: 67 75 6f 75 73 20 73 75 62 63 6f 6d 6d 61 6e 64 guous subcommand
1db0: 20 5c 22 46 4f 4f 42 41 52 5c 22 3a 20 6d 75 73 \"FOOBAR\": mus
1dc0: 74 20 62 65 20 61 76 61 69 6c 61 62 6c 65 2c 20 t be available,
1dd0: 62 6c 6f 63 6b 65 64 2c 20 63 6c 6f 73 65 2c 20 blocked, close,
1de0: 63 6f 6e 66 69 67 75 72 65 2c 20 63 6f 70 79 2c configure, copy,
1df0: 20 63 72 65 61 74 65 2c 20 65 6f 66 2c 20 65 76 create, eof, ev
1e00: 65 6e 74 2c 20 66 6c 75 73 68 2c 20 67 65 74 73 ent, flush, gets
1e10: 2c 20 6e 61 6d 65 73 2c 20 70 6f 73 74 65 76 65 , names, posteve
1e20: 6e 74 2c 20 70 75 74 73 2c 20 72 65 61 64 2c 20 nt, puts, read,
1e30: 73 65 65 6b 2c 20 74 65 6c 6c 2c 20 6f 72 20 74 seek, tell, or t
1e40: 72 75 6e 63 61 74 65 22 0a 20 0a 20 74 65 73 74 runcate". . test
1e50: 20 63 68 61 6e 2d 32 2e 31 20 7b 63 68 61 6e 20 chan-2.1 {chan
1e60: 63 6f 6d 6d 61 6e 64 3a 20 62 6c 6f 63 6b 65 64 command: blocked
1e70: 20 73 75 62 63 6f 6d 6d 61 6e 64 7d 20 2d 62 6f subcommand} -bo
1e80: 64 79 20 7b 0a 20 20 20 20 20 63 68 61 6e 20 62 dy {. chan b
1e90: 6c 6f 63 6b 65 64 20 66 6f 6f 20 62 61 72 0a 40 locked foo bar.@
1ea0: 40 20 2d 39 36 2c 36 20 2b 39 36 2c 31 31 32 20 @ -96,6 +96,112
1eb0: 40 40 0a 20 20 20 20 20 63 61 74 63 68 20 7b 72 @@. catch {r
1ec0: 65 6d 6f 76 65 46 69 6c 65 20 24 66 69 6c 65 7d emoveFile $file}
1ed0: 0a 20 7d 0a 20 0a 2b 23 20 54 49 50 20 32 38 37 . }. .+# TIP 287
1ee0: 3a 20 63 68 61 6e 20 70 65 6e 64 69 6e 67 69 6e : chan pendingin
1ef0: 70 75 74 0a 2b 74 65 73 74 20 63 68 61 6e 2d 31 put.+test chan-1
1f00: 36 2e 31 20 7b 63 68 61 6e 20 63 6f 6d 6d 61 6e 6.1 {chan comman
1f10: 64 3a 20 70 65 6e 64 69 6e 67 69 6e 70 75 74 20 d: pendinginput
1f20: 73 75 62 63 6f 6d 6d 61 6e 64 7d 20 2d 62 6f 64 subcommand} -bod
1f30: 79 20 7b 0a 2b 20 20 20 20 63 68 61 6e 20 70 65 y {.+ chan pe
1f40: 6e 64 69 6e 67 69 6e 70 75 74 20 66 6f 6f 20 62 ndinginput foo b
1f50: 61 72 0a 2b 7d 20 2d 72 65 74 75 72 6e 43 6f 64 ar.+} -returnCod
1f60: 65 73 20 65 72 72 6f 72 20 2d 72 65 73 75 6c 74 es error -result
1f70: 20 22 77 72 6f 6e 67 20 23 20 61 72 67 73 3a 20 "wrong # args:
1f80: 73 68 6f 75 6c 64 20 62 65 20 5c 22 63 68 61 6e should be \"chan
1f90: 20 70 65 6e 64 69 6e 67 69 6e 70 75 74 20 63 68 pendinginput ch
1fa0: 61 6e 6e 65 6c 49 64 5c 22 22 0a 2b 74 65 73 74 annelId\"".+test
1fb0: 20 63 68 61 6e 2d 31 36 2e 32 20 7b 63 68 61 6e chan-16.2 {chan
1fc0: 20 63 6f 6d 6d 61 6e 64 3a 20 70 65 6e 64 69 6e command: pendin
1fd0: 67 69 6e 70 75 74 20 73 75 62 63 6f 6d 6d 61 6e ginput subcomman
1fe0: 64 7d 20 2d 62 6f 64 79 20 7b 0a 2b 20 20 20 20 d} -body {.+
1ff0: 63 68 61 6e 20 70 65 6e 64 69 6e 67 69 6e 70 75 chan pendinginpu
2000: 74 20 73 74 64 6f 75 74 20 0a 2b 7d 20 2d 72 65 t stdout .+} -re
2010: 73 75 6c 74 20 2d 31 0a 2b 74 65 73 74 20 63 68 sult -1.+test ch
2020: 61 6e 2d 31 36 2e 33 20 7b 63 68 61 6e 20 63 6f an-16.3 {chan co
2030: 6d 6d 61 6e 64 3a 20 70 65 6e 64 69 6e 67 69 6e mmand: pendingin
2040: 70 75 74 20 73 75 62 63 6f 6d 6d 61 6e 64 7d 20 put subcommand}
2050: 2d 62 6f 64 79 20 7b 0a 2b 20 20 20 20 63 68 61 -body {.+ cha
2060: 6e 20 70 65 6e 64 69 6e 67 69 6e 70 75 74 20 73 n pendinginput s
2070: 74 64 69 6e 0a 2b 7d 20 2d 72 65 73 75 6c 74 20 tdin.+} -result
2080: 30 0a 2b 74 65 73 74 20 63 68 61 6e 2d 31 36 2e 0.+test chan-16.
2090: 34 20 7b 63 68 61 6e 20 63 6f 6d 6d 61 6e 64 3a 4 {chan command:
20a0: 20 70 65 6e 64 69 6e 67 69 6e 70 75 74 20 73 75 pendinginput su
20b0: 62 63 6f 6d 6d 61 6e 64 7d 20 2d 62 6f 64 79 20 bcommand} -body
20c0: 7b 0a 2b 20 20 20 20 63 68 61 6e 20 70 65 6e 64 {.+ chan pend
20d0: 69 6e 67 69 6e 70 75 74 20 46 4f 4f 42 41 52 0a inginput FOOBAR.
20e0: 2b 7d 20 2d 72 65 74 75 72 6e 43 6f 64 65 73 20 +} -returnCodes
20f0: 65 72 72 6f 72 20 2d 72 65 73 75 6c 74 20 22 63 error -result "c
2100: 61 6e 20 6e 6f 74 20 66 69 6e 64 20 63 68 61 6e an not find chan
2110: 6e 65 6c 20 6e 61 6d 65 64 20 5c 22 46 4f 4f 42 nel named \"FOOB
2120: 41 52 5c 22 22 0a 2b 74 65 73 74 20 63 68 61 6e AR\"".+test chan
2130: 2d 31 36 2e 35 20 7b 63 68 61 6e 20 63 6f 6d 6d -16.5 {chan comm
2140: 61 6e 64 3a 20 70 65 6e 64 69 6e 67 69 6e 70 75 and: pendinginpu
2150: 74 20 73 75 62 63 6f 6d 6d 61 6e 64 7d 20 2d 73 t subcommand} -s
2160: 65 74 75 70 20 7b 0a 2b 20 20 20 20 73 65 74 20 etup {.+ set
2170: 66 69 6c 65 20 5b 6d 61 6b 65 46 69 6c 65 20 7b file [makeFile {
2180: 7d 20 74 65 73 74 41 76 61 69 6c 61 62 6c 65 5d } testAvailable]
2190: 0a 2b 20 20 20 20 73 65 74 20 66 20 5b 6f 70 65 .+ set f [ope
21a0: 6e 20 24 66 69 6c 65 20 77 2b 5d 0a 2b 20 20 20 n $file w+].+
21b0: 20 63 68 61 6e 20 63 6f 6e 66 69 67 75 72 65 20 chan configure
21c0: 24 66 20 2d 74 72 61 6e 73 6c 61 74 69 6f 6e 20 $f -translation
21d0: 6c 66 20 2d 62 75 66 66 65 72 69 6e 67 20 6c 69 lf -buffering li
21e0: 6e 65 0a 2b 7d 20 2d 62 6f 64 79 20 7b 0a 2b 20 ne.+} -body {.+
21f0: 20 20 20 63 68 61 6e 20 70 75 74 73 20 24 66 20 chan puts $f
2200: 66 6f 6f 0a 2b 20 20 20 20 63 68 61 6e 20 70 75 foo.+ chan pu
2210: 74 73 20 24 66 20 62 61 72 0a 2b 20 20 20 20 63 ts $f bar.+ c
2220: 68 61 6e 20 70 75 74 73 20 24 66 20 62 61 7a 0a han puts $f baz.
2230: 2b 20 20 20 20 63 68 61 6e 20 73 65 65 6b 20 24 + chan seek $
2240: 66 20 30 0a 2b 20 20 20 20 63 68 61 6e 20 67 65 f 0.+ chan ge
2250: 74 73 20 24 66 0a 2b 20 20 20 20 63 68 61 6e 20 ts $f.+ chan
2260: 70 65 6e 64 69 6e 67 69 6e 70 75 74 20 24 66 0a pendinginput $f.
2270: 2b 7d 20 2d 72 65 73 75 6c 74 20 38 20 2d 63 6c +} -result 8 -cl
2280: 65 61 6e 75 70 20 7b 0a 2b 20 20 20 20 63 61 74 eanup {.+ cat
2290: 63 68 20 7b 63 68 61 6e 20 63 6c 6f 73 65 20 24 ch {chan close $
22a0: 66 7d 0a 2b 20 20 20 20 63 61 74 63 68 20 7b 72 f}.+ catch {r
22b0: 65 6d 6f 76 65 46 69 6c 65 20 24 66 69 6c 65 7d emoveFile $file}
22c0: 0a 2b 7d 0a 2b 74 65 73 74 20 63 68 61 6e 2d 31 .+}.+test chan-1
22d0: 36 2e 36 20 7b 63 68 61 6e 20 63 6f 6d 6d 61 6e 6.6 {chan comman
22e0: 64 3a 20 70 65 6e 64 69 6e 67 69 6e 70 75 74 20 d: pendinginput
22f0: 73 75 62 63 6f 6d 6d 61 6e 64 7d 20 2d 73 65 74 subcommand} -set
2300: 75 70 20 7b 0a 2b 20 20 20 20 70 72 6f 63 20 63 up {.+ proc c
2310: 68 61 6e 2d 31 36 2e 36 2d 61 63 63 65 70 74 20 han-16.6-accept
2320: 7b 73 6f 63 6b 20 61 64 64 72 20 70 6f 72 74 7d {sock addr port}
2330: 20 7b 0a 2b 20 20 20 20 20 20 20 20 63 68 61 6e {.+ chan
2340: 20 63 6f 6e 66 69 67 75 72 65 20 24 73 6f 63 6b configure $sock
2350: 20 2d 62 6c 6f 63 6b 69 6e 67 20 30 20 2d 62 75 -blocking 0 -bu
2360: 66 66 65 72 69 6e 67 20 6c 69 6e 65 20 2d 62 75 ffering line -bu
2370: 66 66 65 72 73 69 7a 65 20 33 32 0a 2b 20 20 20 ffersize 32.+
2380: 20 20 20 20 20 63 68 61 6e 20 65 76 65 6e 74 20 chan event
2390: 24 73 6f 63 6b 20 72 65 61 64 61 62 6c 65 20 5b $sock readable [
23a0: 6c 69 73 74 20 63 68 61 6e 2d 31 36 2e 36 2d 72 list chan-16.6-r
23b0: 65 61 64 61 62 6c 65 20 24 73 6f 63 6b 5d 0a 2b eadable $sock].+
23c0: 20 20 20 20 7d 0a 2b 0a 2b 20 20 20 20 70 72 6f }.+.+ pro
23d0: 63 20 63 68 61 6e 2d 31 36 2e 36 2d 72 65 61 64 c chan-16.6-read
23e0: 61 62 6c 65 20 7b 73 6f 63 6b 7d 20 7b 0a 2b 20 able {sock} {.+
23f0: 20 20 20 20 20 20 20 73 65 74 20 72 20 5b 63 68 set r [ch
2400: 61 6e 20 67 65 74 73 20 24 73 6f 63 6b 20 6c 69 an gets $sock li
2410: 6e 65 5d 0a 2b 20 20 20 20 20 20 20 20 73 65 74 ne].+ set
2420: 20 6c 20 5b 73 74 72 69 6e 67 20 6c 65 6e 67 74 l [string lengt
2430: 68 20 24 6c 69 6e 65 5d 0a 2b 20 20 20 20 20 20 h $line].+
2440: 20 20 73 65 74 20 65 20 5b 63 68 61 6e 20 65 6f set e [chan eo
2450: 66 20 24 73 6f 63 6b 5d 0a 2b 20 20 20 20 20 20 f $sock].+
2460: 20 20 73 65 74 20 62 20 5b 63 68 61 6e 20 62 6c set b [chan bl
2470: 6f 63 6b 65 64 20 24 73 6f 63 6b 5d 0a 2b 20 20 ocked $sock].+
2480: 20 20 20 20 20 20 73 65 74 20 69 20 5b 63 68 61 set i [cha
2490: 6e 20 70 65 6e 64 69 6e 67 69 6e 70 75 74 20 24 n pendinginput $
24a0: 73 6f 63 6b 5d 0a 2b 0a 2b 20 20 20 20 20 20 20 sock].+.+
24b0: 20 6c 61 70 70 65 6e 64 20 3a 3a 63 68 61 6e 2d lappend ::chan-
24c0: 31 36 2e 36 2d 64 61 74 61 20 24 72 20 24 6c 20 16.6-data $r $l
24d0: 24 65 20 24 62 20 24 69 0a 2b 0a 2b 20 20 20 20 $e $b $i.+.+
24e0: 20 20 20 20 69 66 20 7b 24 72 20 21 3d 20 2d 31 if {$r != -1
24f0: 20 7c 7c 20 24 65 20 7c 7c 20 24 6c 20 7c 7c 20 || $e || $l ||
2500: 21 24 62 20 7c 7c 20 24 69 20 3e 20 31 32 38 7d !$b || $i > 128}
2510: 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 {.+
2520: 73 65 74 20 64 61 74 61 20 5b 72 65 61 64 20 24 set data [read $
2530: 73 6f 63 6b 20 24 69 5d 0a 2b 20 20 20 20 20 20 sock $i].+
2540: 20 20 20 20 20 20 6c 61 70 70 65 6e 64 20 3a 3a lappend ::
2550: 63 68 61 6e 2d 31 36 2e 36 2d 64 61 74 61 20 5b chan-16.6-data [
2560: 73 74 72 69 6e 67 20 72 61 6e 67 65 20 24 64 61 string range $da
2570: 74 61 20 30 20 32 5d 0a 2b 20 20 20 20 20 20 20 ta 0 2].+
2580: 20 20 20 20 20 6c 61 70 70 65 6e 64 20 3a 3a 63 lappend ::c
2590: 68 61 6e 2d 31 36 2e 36 2d 64 61 74 61 20 5b 73 han-16.6-data [s
25a0: 74 72 69 6e 67 20 72 61 6e 67 65 20 24 64 61 74 tring range $dat
25b0: 61 20 65 6e 64 2d 32 20 65 6e 64 5d 0a 2b 20 20 a end-2 end].+
25c0: 20 20 20 20 20 20 20 20 20 20 73 65 74 20 3a 3a set ::
25d0: 63 68 61 6e 2d 31 36 2e 36 2d 64 6f 6e 65 20 31 chan-16.6-done 1
25e0: 0a 2b 20 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 .+ }.+
25f0: 20 7d 0a 2b 0a 2b 20 20 20 20 70 72 6f 63 20 63 }.+.+ proc c
2600: 68 61 6e 2d 31 36 2e 36 2d 63 6c 69 65 6e 74 20 han-16.6-client
2610: 7b 7d 20 7b 0a 2b 20 20 20 20 20 20 20 20 63 68 {} {.+ ch
2620: 61 6e 20 70 75 74 73 20 2d 6e 6f 6e 65 77 6c 69 an puts -nonewli
2630: 6e 65 20 24 3a 3a 63 6c 69 65 6e 74 20 41 42 43 ne $::client ABC
2640: 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 DEFGHIJKLMNOPQRS
2650: 54 55 56 57 58 59 5a 31 32 33 34 35 36 37 38 39 TUVWXYZ123456789
2660: 30 0a 2b 20 20 20 20 20 20 20 20 63 68 61 6e 20 0.+ chan
2670: 66 6c 75 73 68 20 24 3a 3a 63 6c 69 65 6e 74 0a flush $::client.
2680: 2b 20 20 20 20 20 20 20 20 61 66 74 65 72 20 31 + after 1
2690: 30 30 20 63 68 61 6e 2d 31 36 2e 36 2d 63 6c 69 00 chan-16.6-cli
26a0: 65 6e 74 0a 2b 20 20 20 20 7d 0a 2b 0a 2b 20 20 ent.+ }.+.+
26b0: 20 20 73 65 74 20 3a 3a 73 65 72 76 65 72 20 5b set ::server [
26c0: 73 6f 63 6b 65 74 20 2d 73 65 72 76 65 72 20 63 socket -server c
26d0: 68 61 6e 2d 31 36 2e 36 2d 61 63 63 65 70 74 20 han-16.6-accept
26e0: 2d 6d 79 61 64 64 72 20 31 32 37 2e 30 2e 30 2e -myaddr 127.0.0.
26f0: 31 20 30 5d 0a 2b 20 20 20 20 73 65 74 20 3a 3a 1 0].+ set ::
2700: 63 6c 69 65 6e 74 20 5b 73 6f 63 6b 65 74 20 31 client [socket 1
2710: 32 37 2e 30 2e 30 2e 31 20 5b 6c 69 6e 64 65 78 27.0.0.1 [lindex
2720: 20 5b 66 63 6f 6e 66 69 67 75 72 65 20 24 3a 3a [fconfigure $::
2730: 73 65 72 76 65 72 20 2d 73 6f 63 6b 6e 61 6d 65 server -sockname
2740: 5d 20 32 5d 5d 0a 2b 20 20 20 20 73 65 74 20 3a ] 2]].+ set :
2750: 3a 63 68 61 6e 2d 31 36 2e 36 2d 64 61 74 61 20 :chan-16.6-data
2760: 5b 6c 69 73 74 5d 0a 2b 20 20 20 20 73 65 74 20 [list].+ set
2770: 3a 3a 63 68 61 6e 2d 31 36 2e 36 2d 64 6f 6e 65 ::chan-16.6-done
2780: 20 30 0a 2b 7d 20 2d 62 6f 64 79 20 7b 0a 2b 20 0.+} -body {.+
2790: 20 20 20 61 66 74 65 72 20 69 64 6c 65 20 63 68 after idle ch
27a0: 61 6e 2d 31 36 2e 36 2d 63 6c 69 65 6e 74 20 0a an-16.6-client .
27b0: 2b 20 20 20 20 76 77 61 69 74 20 3a 3a 63 68 61 + vwait ::cha
27c0: 6e 2d 31 36 2e 36 2d 64 6f 6e 65 0a 2b 20 20 20 n-16.6-done.+
27d0: 20 73 65 74 20 3a 3a 63 68 61 6e 2d 31 36 2e 36 set ::chan-16.6
27e0: 2d 64 61 74 61 0a 2b 7d 20 2d 72 65 73 75 6c 74 -data.+} -result
27f0: 20 7b 2d 31 20 30 20 30 20 31 20 33 36 20 2d 31 {-1 0 0 1 36 -1
2800: 20 30 20 30 20 31 20 37 32 20 2d 31 20 30 20 30 0 0 1 72 -1 0 0
2810: 20 31 20 31 30 38 20 2d 31 20 30 20 30 20 31 20 1 108 -1 0 0 1
2820: 31 34 34 20 41 42 43 20 38 39 30 7d 20 2d 63 6c 144 ABC 890} -cl
2830: 65 61 6e 75 70 20 7b 0a 2b 20 20 20 20 63 61 74 eanup {.+ cat
2840: 63 68 20 7b 63 68 61 6e 20 63 6c 6f 73 65 20 24 ch {chan close $
2850: 63 6c 69 65 6e 74 7d 0a 2b 20 20 20 20 63 61 74 client}.+ cat
2860: 63 68 20 7b 63 68 61 6e 20 63 6c 6f 73 65 20 24 ch {chan close $
2870: 73 65 72 76 65 72 7d 0a 2b 20 20 20 20 72 65 6e server}.+ ren
2880: 61 6d 65 20 63 68 61 6e 2d 31 36 2e 36 2d 61 63 ame chan-16.6-ac
2890: 63 65 70 74 20 7b 7d 0a 2b 20 20 20 20 72 65 6e cept {}.+ ren
28a0: 61 6d 65 20 63 68 61 6e 2d 31 36 2e 36 2d 72 65 ame chan-16.6-re
28b0: 61 64 61 62 6c 65 20 7b 7d 0a 2b 20 20 20 20 72 adable {}.+ r
28c0: 65 6e 61 6d 65 20 63 68 61 6e 2d 31 36 2e 36 2d ename chan-16.6-
28d0: 63 6c 69 65 6e 74 20 7b 7d 0a 2b 20 20 20 20 75 client {}.+ u
28e0: 6e 73 65 74 20 2d 6e 6f 63 6f 6d 70 6c 61 69 6e nset -nocomplain
28f0: 20 3a 3a 63 68 61 6e 2d 31 36 2e 36 2d 64 61 74 ::chan-16.6-dat
2900: 61 0a 2b 20 20 20 20 75 6e 73 65 74 20 2d 6e 6f a.+ unset -no
2910: 63 6f 6d 70 6c 61 69 6e 20 3a 3a 63 68 61 6e 2d complain ::chan-
2920: 31 36 2e 36 2d 64 6f 6e 65 0a 2b 20 20 20 20 75 16.6-done.+ u
2930: 6e 73 65 74 20 2d 6e 6f 63 6f 6d 70 6c 61 69 6e nset -nocomplain
2940: 20 3a 3a 73 65 72 76 65 72 0a 2b 20 20 20 20 75 ::server.+ u
2950: 6e 73 65 74 20 2d 6e 6f 63 6f 6d 70 6c 61 69 6e nset -nocomplain
2960: 20 3a 3a 63 6c 69 65 6e 74 0a 2b 7d 0a 2b 0a 2b ::client.+}.+.+
2970: 23 20 54 49 50 20 32 38 37 3a 20 63 68 61 6e 20 # TIP 287: chan
2980: 70 65 6e 64 69 6e 67 6f 75 74 70 75 74 0a 2b 74 pendingoutput.+t
2990: 65 73 74 20 63 68 61 6e 2d 31 37 2e 31 20 7b 63 est chan-17.1 {c
29a0: 68 61 6e 20 63 6f 6d 6d 61 6e 64 3a 20 70 65 6e han command: pen
29b0: 64 69 6e 67 6f 75 74 70 75 74 20 73 75 62 63 6f dingoutput subco
29c0: 6d 6d 61 6e 64 7d 20 2d 62 6f 64 79 20 7b 0a 2b mmand} -body {.+
29d0: 20 20 20 20 63 68 61 6e 20 70 65 6e 64 69 6e 67 chan pending
29e0: 6f 75 74 70 75 74 20 66 6f 6f 20 62 61 72 0a 2b output foo bar.+
29f0: 7d 20 2d 72 65 74 75 72 6e 43 6f 64 65 73 20 65 } -returnCodes e
2a00: 72 72 6f 72 20 2d 72 65 73 75 6c 74 20 22 77 72 rror -result "wr
2a10: 6f 6e 67 20 23 20 61 72 67 73 3a 20 73 68 6f 75 ong # args: shou
2a20: 6c 64 20 62 65 20 5c 22 63 68 61 6e 20 70 65 6e ld be \"chan pen
2a30: 64 69 6e 67 6f 75 74 70 75 74 20 63 68 61 6e 6e dingoutput chann
2a40: 65 6c 49 64 5c 22 22 0a 2b 74 65 73 74 20 63 68 elId\"".+test ch
2a50: 61 6e 2d 31 37 2e 32 20 7b 63 68 61 6e 20 63 6f an-17.2 {chan co
2a60: 6d 6d 61 6e 64 3a 20 70 65 6e 64 69 6e 67 6f 75 mmand: pendingou
2a70: 74 70 75 74 20 73 75 62 63 6f 6d 6d 61 6e 64 7d tput subcommand}
2a80: 20 2d 62 6f 64 79 20 7b 0a 2b 20 20 20 20 63 68 -body {.+ ch
2a90: 61 6e 20 70 65 6e 64 69 6e 67 6f 75 74 70 75 74 an pendingoutput
2aa0: 20 73 74 64 69 6e 0a 2b 7d 20 2d 72 65 73 75 6c stdin.+} -resul
2ab0: 74 20 2d 31 0a 2b 74 65 73 74 20 63 68 61 6e 2d t -1.+test chan-
2ac0: 31 37 2e 33 20 7b 63 68 61 6e 20 63 6f 6d 6d 61 17.3 {chan comma
2ad0: 6e 64 3a 20 70 65 6e 64 69 6e 67 6f 75 74 70 75 nd: pendingoutpu
2ae0: 74 20 73 75 62 63 6f 6d 6d 61 6e 64 7d 20 2d 62 t subcommand} -b
2af0: 6f 64 79 20 7b 0a 2b 20 20 20 20 63 68 61 6e 20 ody {.+ chan
2b00: 70 65 6e 64 69 6e 67 6f 75 74 70 75 74 20 73 74 pendingoutput st
2b10: 64 6f 75 74 0a 2b 7d 20 2d 72 65 73 75 6c 74 20 dout.+} -result
2b20: 30 0a 2b 74 65 73 74 20 63 68 61 6e 2d 31 37 2e 0.+test chan-17.
2b30: 34 20 7b 63 68 61 6e 20 63 6f 6d 6d 61 6e 64 3a 4 {chan command:
2b40: 20 70 65 6e 64 69 6e 67 6f 75 74 70 75 74 20 73 pendingoutput s
2b50: 75 62 63 6f 6d 6d 61 6e 64 7d 20 2d 62 6f 64 79 ubcommand} -body
2b60: 20 7b 0a 2b 20 20 20 20 63 68 61 6e 20 70 65 6e {.+ chan pen
2b70: 64 69 6e 67 6f 75 74 70 75 74 20 46 4f 4f 42 41 dingoutput FOOBA
2b80: 52 0a 2b 7d 20 2d 72 65 74 75 72 6e 43 6f 64 65 R.+} -returnCode
2b90: 73 20 65 72 72 6f 72 20 2d 72 65 73 75 6c 74 20 s error -result
2ba0: 22 63 61 6e 20 6e 6f 74 20 66 69 6e 64 20 63 68 "can not find ch
2bb0: 61 6e 6e 65 6c 20 6e 61 6d 65 64 20 5c 22 46 4f annel named \"FO
2bc0: 4f 42 41 52 5c 22 22 0a 2b 74 65 73 74 20 63 68 OBAR\"".+test ch
2bd0: 61 6e 2d 31 37 2e 35 20 7b 63 68 61 6e 20 63 6f an-17.5 {chan co
2be0: 6d 6d 61 6e 64 3a 20 70 65 6e 64 69 6e 67 6f 75 mmand: pendingou
2bf0: 74 70 75 74 20 73 75 62 63 6f 6d 6d 61 6e 64 7d tput subcommand}
2c00: 20 2d 73 65 74 75 70 20 7b 0a 2b 20 20 20 20 73 -setup {.+ s
2c10: 65 74 20 66 69 6c 65 20 5b 6d 61 6b 65 46 69 6c et file [makeFil
2c20: 65 20 7b 7d 20 74 65 73 74 50 65 6e 64 69 6e 67 e {} testPending
2c30: 4f 75 74 70 75 74 5d 0a 2b 20 20 20 20 73 65 74 Output].+ set
2c40: 20 66 20 5b 6f 70 65 6e 20 24 66 69 6c 65 20 77 f [open $file w
2c50: 2b 5d 0a 2b 20 20 20 20 63 68 61 6e 20 63 6f 6e +].+ chan con
2c60: 66 69 67 75 72 65 20 24 66 20 2d 74 72 61 6e 73 figure $f -trans
2c70: 6c 61 74 69 6f 6e 20 6c 66 20 2d 62 75 66 66 65 lation lf -buffe
2c80: 72 69 6e 67 20 66 75 6c 6c 20 2d 62 75 66 66 65 ring full -buffe
2c90: 72 73 69 7a 65 20 31 30 32 34 0a 2b 7d 20 2d 62 rsize 1024.+} -b
2ca0: 6f 64 79 20 7b 0a 2b 20 20 20 20 73 65 74 20 72 ody {.+ set r
2cb0: 65 73 75 6c 74 20 5b 6c 69 73 74 5d 0a 2b 20 20 esult [list].+
2cc0: 20 20 63 68 61 6e 20 70 75 74 73 20 24 66 20 5b chan puts $f [
2cd0: 73 74 72 69 6e 67 20 72 65 70 65 61 74 20 78 20 string repeat x
2ce0: 35 31 32 5d 0a 2b 20 20 20 20 6c 61 70 70 65 6e 512].+ lappen
2cf0: 64 20 72 65 73 75 6c 74 20 5b 63 68 61 6e 20 70 d result [chan p
2d00: 65 6e 64 69 6e 67 6f 75 74 70 75 74 20 24 66 5d endingoutput $f]
2d10: 0a 2b 20 20 20 20 63 68 61 6e 20 66 6c 75 73 68 .+ chan flush
2d20: 20 24 66 0a 2b 20 20 20 20 6c 61 70 70 65 6e 64 $f.+ lappend
2d30: 20 72 65 73 75 6c 74 20 5b 63 68 61 6e 20 70 65 result [chan pe
2d40: 6e 64 69 6e 67 6f 75 74 70 75 74 20 24 66 5d 0a ndingoutput $f].
2d50: 2b 7d 20 2d 72 65 73 75 6c 74 20 5b 6c 69 73 74 +} -result [list
2d60: 20 35 31 33 20 30 5d 20 2d 63 6c 65 61 6e 75 70 513 0] -cleanup
2d70: 20 7b 0a 2b 20 20 20 20 75 6e 73 65 74 20 2d 6e {.+ unset -n
2d80: 6f 63 6f 6d 70 6c 61 69 6e 20 72 65 73 75 6c 74 ocomplain result
2d90: 0a 2b 20 20 20 20 63 61 74 63 68 20 7b 63 68 61 .+ catch {cha
2da0: 6e 20 63 6c 6f 73 65 20 24 66 7d 0a 2b 20 20 20 n close $f}.+
2db0: 20 63 61 74 63 68 20 7b 72 65 6d 6f 76 65 46 69 catch {removeFi
2dc0: 6c 65 20 24 66 69 6c 65 7d 0a 2b 7d 0a 2b 0a 20 le $file}.+}.+.
2dd0: 63 6c 65 61 6e 75 70 54 65 73 74 73 0a 20 72 65 cleanupTests. re
2de0: 74 75 72 6e 0a 20 0a 2d 2d 2d 20 74 65 73 74 73 turn. .--- tests
2df0: 2f 69 6f 43 6d 64 2e 74 65 73 74 2e 6f 72 69 67 /ioCmd.test.orig
2e00: 09 32 30 30 36 2d 31 30 2d 32 38 20 32 33 3a 30 .2006-10-28 23:0
2e10: 36 3a 34 34 2e 30 30 30 30 30 30 30 30 30 20 2d 6:44.000000000 -
2e20: 30 36 30 30 0a 2b 2b 2b 20 74 65 73 74 73 2f 69 0600.+++ tests/i
2e30: 6f 43 6d 64 2e 74 65 73 74 09 32 30 30 36 2d 31 oCmd.test.2006-1
2e40: 31 2d 30 35 20 31 35 3a 30 30 3a 30 38 2e 30 30 1-05 15:00:08.00
2e50: 30 30 30 30 30 30 30 20 2d 30 37 30 30 0a 40 40 0000000 -0700.@@
2e60: 20 2d 36 32 38 2c 37 20 2b 36 32 38 2c 37 20 40 -628,7 +628,7 @
2e70: 40 0a 20 74 65 73 74 20 69 6f 63 6d 64 2d 32 30 @. test iocmd-20
2e80: 2e 31 20 7b 63 68 61 6e 2c 20 75 6e 6b 6e 6f 77 .1 {chan, unknow
2e90: 6e 20 6d 65 74 68 6f 64 7d 20 7b 0a 20 20 20 20 n method} {.
2ea0: 20 63 61 74 63 68 20 7b 63 68 61 6e 20 66 6f 6f catch {chan foo
2eb0: 7d 20 6d 73 67 0a 20 20 20 20 20 73 65 74 20 6d } msg. set m
2ec0: 73 67 0a 2d 7d 20 7b 75 6e 6b 6e 6f 77 6e 20 6f sg.-} {unknown o
2ed0: 72 20 61 6d 62 69 67 75 6f 75 73 20 73 75 62 63 r ambiguous subc
2ee0: 6f 6d 6d 61 6e 64 20 22 66 6f 6f 22 3a 20 6d 75 ommand "foo": mu
2ef0: 73 74 20 62 65 20 62 6c 6f 63 6b 65 64 2c 20 63 st be blocked, c
2f00: 6c 6f 73 65 2c 20 63 6f 6e 66 69 67 75 72 65 2c lose, configure,
2f10: 20 63 6f 70 79 2c 20 63 72 65 61 74 65 2c 20 65 copy, create, e
2f20: 6f 66 2c 20 65 76 65 6e 74 2c 20 66 6c 75 73 68 of, event, flush
2f30: 2c 20 67 65 74 73 2c 20 6e 61 6d 65 73 2c 20 70 , gets, names, p
2f40: 6f 73 74 65 76 65 6e 74 2c 20 70 75 74 73 2c 20 ostevent, puts,
2f50: 72 65 61 64 2c 20 73 65 65 6b 2c 20 74 65 6c 6c read, seek, tell
2f60: 2c 20 6f 72 20 74 72 75 6e 63 61 74 65 7d 0a 2b , or truncate}.+
2f70: 7d 20 7b 75 6e 6b 6e 6f 77 6e 20 6f 72 20 61 6d } {unknown or am
2f80: 62 69 67 75 6f 75 73 20 73 75 62 63 6f 6d 6d 61 biguous subcomma
2f90: 6e 64 20 22 66 6f 6f 22 3a 20 6d 75 73 74 20 62 nd "foo": must b
2fa0: 65 20 62 6c 6f 63 6b 65 64 2c 20 63 6c 6f 73 65 e blocked, close
2fb0: 2c 20 63 6f 6e 66 69 67 75 72 65 2c 20 63 6f 70 , configure, cop
2fc0: 79 2c 20 63 72 65 61 74 65 2c 20 65 6f 66 2c 20 y, create, eof,
2fd0: 65 76 65 6e 74 2c 20 66 6c 75 73 68 2c 20 67 65 event, flush, ge
2fe0: 74 73 2c 20 6e 61 6d 65 73 2c 20 70 65 6e 64 69 ts, names, pendi
2ff0: 6e 67 69 6e 70 75 74 2c 20 70 65 6e 64 69 6e 67 nginput, pending
3000: 6f 75 74 70 75 74 2c 20 70 6f 73 74 65 76 65 6e output, posteven
3010: 74 2c 20 70 75 74 73 2c 20 72 65 61 64 2c 20 73 t, puts, read, s
3020: 65 65 6b 2c 20 74 65 6c 6c 2c 20 6f 72 20 74 72 eek, tell, or tr
3030: 75 6e 63 61 74 65 7d 0a 20 0a 20 23 20 2d 2d 2d uncate}. . # ---
3040: 20 2d 2d 2d 20 2d 2d 2d 20 2d 2d 2d 2d 2d 2d 2d --- --- -------
3050: 2d 2d 20 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 2d 2d 2d -- --------- ---
3060: 2d 2d 2d 2d 2d 2d 0a 20 23 20 63 68 61 6e 20 63 ------. # chan c
3070: 72 65 61 74 65 2c 20 61 6e 64 20 6d 65 74 68 6f reate, and metho
3080: 64 20 22 69 6e 69 74 61 6c 69 7a 65 22 0a d "initalize".