diff options
Diffstat (limited to 'generic/tclIOCmd.c')
-rw-r--r-- | generic/tclIOCmd.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index 78ab3cf..5fb3a15 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIOCmd.c,v 1.8 2001/07/31 19:12:06 vincentdarley Exp $ + * RCS: @(#) $Id: tclIOCmd.c,v 1.9 2001/08/06 22:17:58 andreas_kupries Exp $ */ #include "tclInt.h" @@ -228,8 +228,6 @@ Tcl_GetsObjCmd(dummy, interp, objc, objv) return TCL_ERROR; } - resultPtr = Tcl_GetObjResult(interp); - linePtr = resultPtr; if (objc == 3) { /* * Variable gets line, interp get bytecount. @@ -237,11 +235,14 @@ Tcl_GetsObjCmd(dummy, interp, objc, objv) linePtr = Tcl_NewObj(); } + else { + linePtr = Tcl_GetObjResult(interp); + } lineLen = Tcl_GetsObj(chan, linePtr); if (lineLen < 0) { if (!Tcl_Eof(chan) && !Tcl_InputBlocked(chan)) { - if (linePtr != resultPtr) { + if (objc == 3) { Tcl_DecrRefCount(linePtr); } Tcl_ResetResult(interp); @@ -257,6 +258,7 @@ Tcl_GetsObjCmd(dummy, interp, objc, objv) Tcl_DecrRefCount(linePtr); return TCL_ERROR; } + resultPtr = Tcl_GetObjResult(interp); Tcl_SetIntObj(resultPtr, lineLen); return TCL_OK; } |