summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstu <stwo@users.sourceforge.net>2017-06-05 18:33:57 (GMT)
committerstu <stwo@users.sourceforge.net>2017-06-05 18:33:57 (GMT)
commita323b71adcc1795f6d3e38d0a3a51ff10b8d76b9 (patch)
tree16d4f7c60c955d540aaee31eb84bff501bcb5f70
parent51b616c6fb451a91e7ac680f3998eef84c352658 (diff)
downloadtcl-stwo_dev86.zip
tcl-stwo_dev86.tar.gz
tcl-stwo_dev86.tar.bz2
Change the return type of Tcl_RegisterChannel from void to Tcl_Channel and have Tcl_RegisterChannel return the channel. his is a convenience to the programmer.stwo_dev86
-rw-r--r--doc/OpenFileChnl.34
-rw-r--r--generic/tcl.decls2
-rw-r--r--generic/tclDecls.h4
-rw-r--r--generic/tclIO.c8
4 files changed, 11 insertions, 7 deletions
diff --git a/doc/OpenFileChnl.3 b/doc/OpenFileChnl.3
index 582ff4b..5623b80 100644
--- a/doc/OpenFileChnl.3
+++ b/doc/OpenFileChnl.3
@@ -32,7 +32,7 @@ int
int
\fBTcl_GetChannelNamesEx\fR(\fIinterp, pattern\fR)
.sp
-void
+Tcl_Channel
\fBTcl_RegisterChannel\fR(\fIinterp, channel\fR)
.sp
int
@@ -319,6 +319,8 @@ the name given in the call to \fBTcl_CreateChannel\fR. After this call,
the channel becomes the property of the interpreter, and the caller should
not call \fBTcl_Close\fR for the channel; the channel will be closed
automatically when it is unregistered from the interpreter.
+\fBTcl_RegisterChannel\fR returns the channel, as a convenience to the
+programmer,
.PP
Code executing outside of any Tcl interpreter can call
\fBTcl_RegisterChannel\fR with \fIinterp\fR as NULL, to indicate that it
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 4d4bf5f..cca6f08 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -748,7 +748,7 @@ declare 209 {
int Tcl_RecordAndEvalObj(Tcl_Interp *interp, Tcl_Obj *cmdPtr, int flags)
}
declare 210 {
- void Tcl_RegisterChannel(Tcl_Interp *interp, Tcl_Channel chan)
+ Tcl_Channel Tcl_RegisterChannel(Tcl_Interp *interp, Tcl_Channel chan)
}
declare 211 {
void Tcl_RegisterObjType(const Tcl_ObjType *typePtr)
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 185546b..94a4f39 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -633,7 +633,7 @@ EXTERN int Tcl_RecordAndEval(Tcl_Interp *interp,
EXTERN int Tcl_RecordAndEvalObj(Tcl_Interp *interp,
Tcl_Obj *cmdPtr, int flags);
/* 210 */
-EXTERN void Tcl_RegisterChannel(Tcl_Interp *interp,
+EXTERN Tcl_Channel Tcl_RegisterChannel(Tcl_Interp *interp,
Tcl_Channel chan);
/* 211 */
EXTERN void Tcl_RegisterObjType(const Tcl_ObjType *typePtr);
@@ -2067,7 +2067,7 @@ typedef struct TclStubs {
void (*tcl_ReapDetachedProcs) (void); /* 207 */
int (*tcl_RecordAndEval) (Tcl_Interp *interp, const char *cmd, int flags); /* 208 */
int (*tcl_RecordAndEvalObj) (Tcl_Interp *interp, Tcl_Obj *cmdPtr, int flags); /* 209 */
- void (*tcl_RegisterChannel) (Tcl_Interp *interp, Tcl_Channel chan); /* 210 */
+ Tcl_Channel (*tcl_RegisterChannel) (Tcl_Interp *interp, Tcl_Channel chan); /* 210 */
void (*tcl_RegisterObjType) (const Tcl_ObjType *typePtr); /* 211 */
Tcl_RegExp (*tcl_RegExpCompile) (Tcl_Interp *interp, const char *pattern); /* 212 */
int (*tcl_RegExpExec) (Tcl_Interp *interp, Tcl_RegExp regexp, const char *text, const char *start); /* 213 */
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 1460392..a1f9e30 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -1138,7 +1138,7 @@ Tcl_IsStandardChannel(
* channel refCount.
*
* Results:
- * None.
+ * The channel.
*
* Side effects:
* May increment the reference count of a channel.
@@ -1146,7 +1146,7 @@ Tcl_IsStandardChannel(
*----------------------------------------------------------------------
*/
-void
+Tcl_Channel
Tcl_RegisterChannel(
Tcl_Interp *interp, /* Interpreter in which to add the channel. */
Tcl_Channel chan) /* The channel to add to this interpreter
@@ -1175,7 +1175,7 @@ Tcl_RegisterChannel(
hPtr = Tcl_CreateHashEntry(hTblPtr, statePtr->channelName, &isNew);
if (!isNew) {
if (chan == Tcl_GetHashValue(hPtr)) {
- return;
+ return chan;
}
Tcl_Panic("Tcl_RegisterChannel: duplicate channel names");
@@ -1183,6 +1183,8 @@ Tcl_RegisterChannel(
Tcl_SetHashValue(hPtr, chanPtr);
}
statePtr->refCount++;
+
+ return chan;
}
/*