summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-07-31 14:35:01 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-07-31 14:35:01 (GMT)
commitae22e88dbd7dad273ac8679a6f743fdd401279a8 (patch)
tree7c9f0bc23bc6492c3039e5642daed397ccdb3f11 /unix
parent442f90b526732f9a4d6cc2164cb8f2fe3b5f8dc7 (diff)
downloadtcl-ae22e88dbd7dad273ac8679a6f743fdd401279a8.zip
tcl-ae22e88dbd7dad273ac8679a6f743fdd401279a8.tar.gz
tcl-ae22e88dbd7dad273ac8679a6f743fdd401279a8.tar.bz2
Purge use of Tcl_AppendElement, and corrected conversion of PIDs to integer
objects.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixPipe.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c
index a505bef..377b84b 100644
--- a/unix/tclUnixPipe.c
+++ b/unix/tclUnixPipe.c
@@ -874,8 +874,8 @@ TclGetAndDetachPids(
{
PipeState *pipePtr;
const Tcl_ChannelType *chanTypePtr;
+ Tcl_Obj *pidsObj;
int i;
- char buf[TCL_INTEGER_SPACE];
/*
* Punt if the channel is not a command channel.
@@ -886,12 +886,14 @@ TclGetAndDetachPids(
return;
}
- pipePtr = (PipeState *) Tcl_GetChannelInstanceData(chan);
+ pipePtr = Tcl_GetChannelInstanceData(chan);
+ TclNewObj(pidsObj);
for (i = 0; i < pipePtr->numPids; i++) {
- TclFormatInt(buf, (long) TclpGetPid(pipePtr->pidPtr[i]));
- Tcl_AppendElement(interp, buf);
- Tcl_DetachPids(1, &(pipePtr->pidPtr[i]));
+ Tcl_ListObjAppendElement(NULL, pidsObj, Tcl_NewIntObj(
+ PTR2INT(pipePtr->pidPtr[i])));
+ Tcl_DetachPids(1, &pipePtr->pidPtr[i]);
}
+ Tcl_SetObjResult(interp, pidsObj);
if (pipePtr->numPids > 0) {
ckfree(pipePtr->pidPtr);
pipePtr->numPids = 0;
@@ -1275,7 +1277,7 @@ Tcl_PidObjCmd(
Tcl_Channel chan;
PipeState *pipePtr;
int i;
- Tcl_Obj *resultPtr, *longObjPtr;
+ Tcl_Obj *resultPtr;
if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?channelId?");
@@ -1301,11 +1303,11 @@ Tcl_PidObjCmd(
* Extract the process IDs from the pipe structure.
*/
- pipePtr = (PipeState *) Tcl_GetChannelInstanceData(chan);
+ pipePtr = Tcl_GetChannelInstanceData(chan);
resultPtr = Tcl_NewObj();
for (i = 0; i < pipePtr->numPids; i++) {
- longObjPtr = Tcl_NewLongObj((long) TclpGetPid(pipePtr->pidPtr[i]));
- Tcl_ListObjAppendElement(NULL, resultPtr, longObjPtr);
+ Tcl_ListObjAppendElement(NULL, resultPtr,
+ Tcl_NewIntObj(PTR2INT(TclpGetPid(pipePtr->pidPtr[i]))));
}
Tcl_SetObjResult(interp, resultPtr);
}