summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-04-28 08:00:51 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-04-28 08:00:51 (GMT)
commite5766f95f8b74aa6577cf8dff98d48a71ab9d131 (patch)
tree6e85f7dd2b98f0c060086540c153617c8b70ae9d /generic
parent69d1bdb95ef90f112d06b7ece0d6db57c504a030 (diff)
parent2836feb5d8fbaffcd6371c423cd0a0b0eebac840 (diff)
downloadtcl-fix_1997007.zip
tcl-fix_1997007.tar.gz
tcl-fix_1997007.tar.bz2
merge core-8-6-branchfix_1997007
Diffstat (limited to 'generic')
-rw-r--r--generic/tclBasic.c32
-rw-r--r--generic/tclDisassemble.c34
-rw-r--r--generic/tclExecute.c6
-rw-r--r--generic/tclInt.h5
-rw-r--r--generic/tclProc.c35
-rw-r--r--generic/tclScan.c21
-rw-r--r--generic/tclStringObj.c14
-rw-r--r--generic/tclZlib.c34
8 files changed, 116 insertions, 65 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 4bddbce..0486383 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -8748,6 +8748,35 @@ TclNRCoroutineActivateCallback(
/*
*----------------------------------------------------------------------
*
+ * TclNREvalList --
+ *
+ * Callback to invoke command as list, used in order to delayed
+ * processing of canonical list command in sane environment.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TclNREvalList(
+ ClientData data[],
+ Tcl_Interp *interp,
+ int result)
+{
+ int objc;
+ Tcl_Obj **objv;
+ Tcl_Obj *listPtr = data[0];
+
+ Tcl_IncrRefCount(listPtr);
+
+ TclMarkTailcall(interp);
+ TclNRAddCallback(interp, TclNRReleaseValues, listPtr, NULL, NULL,NULL);
+ TclListObjGetElements(NULL, listPtr, &objc, &objv);
+ return TclNREvalObjv(interp, objc, objv, 0, NULL);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* NRCoroInjectObjCmd --
*
* Implementation of [::tcl::unsupported::inject] command.
@@ -8799,7 +8828,8 @@ NRCoroInjectObjCmd(
*/
iPtr->execEnvPtr = corPtr->eePtr;
- TclNREvalObjEx(interp, Tcl_NewListObj(objc-2, objv+2), 0, NULL, INT_MIN);
+ TclNRAddCallback(interp, TclNREvalList, Tcl_NewListObj(objc-2, objv+2),
+ NULL, NULL, NULL);
iPtr->execEnvPtr = savedEEPtr;
return TCL_OK;
diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c
index 1d616fb..f62c260 100644
--- a/generic/tclDisassemble.c
+++ b/generic/tclDisassemble.c
@@ -27,9 +27,8 @@ static Tcl_Obj * DisassembleByteCodeObj(Tcl_Interp *interp,
Tcl_Obj *objPtr);
static int FormatInstruction(ByteCode *codePtr,
const unsigned char *pc, Tcl_Obj *bufferObj);
-static void GetLocationInformation(Tcl_Interp *interp,
- Proc *procPtr, Tcl_Obj **fileObjPtr,
- int *linePtr);
+static void GetLocationInformation(Proc *procPtr,
+ Tcl_Obj **fileObjPtr, int *linePtr);
static void PrintSourceToObj(Tcl_Obj *appendObj,
const char *stringPtr, int maxChars);
static void UpdateStringOfInstName(Tcl_Obj *objPtr);
@@ -73,8 +72,6 @@ static const Tcl_ObjType tclInstNameType = {
static void
GetLocationInformation(
- Tcl_Interp *interp, /* Where to look up the location
- * information. */
Proc *procPtr, /* What to look up the information for. */
Tcl_Obj **fileObjPtr, /* Where to write the information about what
* file the code came from. Will be written
@@ -88,20 +85,21 @@ GetLocationInformation(
* either with the line number or with -1 if
* the information is not available. */
{
- Interp *iPtr = (Interp *) interp;
- Tcl_HashEntry *hePtr;
- CmdFrame *cfPtr;
+ CmdFrame *cfPtr = TclGetCmdFrameForProcedure(procPtr);
*fileObjPtr = NULL;
*linePtr = -1;
- if (iPtr != NULL && procPtr != NULL) {
- hePtr = Tcl_FindHashEntry(iPtr->linePBodyPtr, procPtr);
- if (hePtr != NULL && (cfPtr = Tcl_GetHashValue(hePtr)) != NULL) {
- *linePtr = cfPtr->line[0];
- if (cfPtr->type == TCL_LOCATION_SOURCE) {
- *fileObjPtr = cfPtr->data.eval.path;
- }
- }
+ if (cfPtr == NULL) {
+ return;
+ }
+
+ /*
+ * Get the source location data out of the CmdFrame.
+ */
+
+ *linePtr = cfPtr->line[0];
+ if (cfPtr->type == TCL_LOCATION_SOURCE) {
+ *fileObjPtr = cfPtr->data.eval.path;
}
}
@@ -278,7 +276,7 @@ DisassembleByteCodeObj(
Tcl_AppendToObj(bufferObj, " Source ", -1);
PrintSourceToObj(bufferObj, codePtr->source,
TclMin(codePtr->numSrcBytes, 55));
- GetLocationInformation(interp, codePtr->procPtr, &fileObj, &line);
+ GetLocationInformation(codePtr->procPtr, &fileObj, &line);
if (line > -1 && fileObj != NULL) {
Tcl_AppendPrintfToObj(bufferObj, "\n File \"%s\" Line %d",
Tcl_GetString(fileObj), line);
@@ -1221,7 +1219,7 @@ DisassembleByteCodeAsDicts(
* system if it is available.
*/
- GetLocationInformation(interp, codePtr->procPtr, &file, &line);
+ GetLocationInformation(codePtr->procPtr, &file, &line);
/*
* Build the overall result.
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index cb4e6dc..d30e757 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -510,8 +510,7 @@ VarHashCreateVar(
: (*(tPtr) = TCL_NUMBER_DOUBLE)), \
*(ptrPtr) = (ClientData) \
(&((objPtr)->internalRep.doubleValue)), TCL_OK) : \
- ((((objPtr)->typePtr == NULL) && ((objPtr)->bytes == NULL)) || \
- (((objPtr)->bytes != NULL) && ((objPtr)->length == 0))) \
+ (((objPtr)->bytes != NULL) && ((objPtr)->length == 0)) \
? (*(tPtr) = TCL_NUMBER_LONG),TCL_ERROR : \
TclGetNumberFromObj((interp), (objPtr), (ptrPtr), (tPtr)))
#else /* !TCL_WIDE_INT_IS_LONG */
@@ -530,8 +529,7 @@ VarHashCreateVar(
: (*(tPtr) = TCL_NUMBER_DOUBLE)), \
*(ptrPtr) = (ClientData) \
(&((objPtr)->internalRep.doubleValue)), TCL_OK) : \
- ((((objPtr)->typePtr == NULL) && ((objPtr)->bytes == NULL)) || \
- (((objPtr)->bytes != NULL) && ((objPtr)->length == 0))) \
+ (((objPtr)->bytes != NULL) && ((objPtr)->length == 0)) \
? (*(tPtr) = TCL_NUMBER_LONG),TCL_ERROR : \
TclGetNumberFromObj((interp), (objPtr), (ptrPtr), (tPtr)))
#endif /* TCL_WIDE_INT_IS_LONG */
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 1deda3c..fe4fefd 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2940,7 +2940,8 @@ MODULE_SCOPE Tcl_Obj * TclGetBgErrorHandler(Tcl_Interp *interp);
MODULE_SCOPE int TclGetChannelFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, Tcl_Channel *chanPtr,
int *modePtr, int flags);
-MODULE_SCOPE int TclGetCompletionCodeFromObj(Tcl_Interp *interp,
+MODULE_SCOPE CmdFrame * TclGetCmdFrameForProcedure(Proc *procPtr);
+MODULE_SCOPE int TclGetCompletionCodeFromObj(Tcl_Interp *interp,
Tcl_Obj *value, int *code);
MODULE_SCOPE int TclGetNumberFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, ClientData *clientDataPtr,
@@ -3920,7 +3921,7 @@ MODULE_SCOPE int TclCompileAssembleCmd(Tcl_Interp *interp,
struct CompileEnv *envPtr);
/*
- * Functions defined in generic/tclVar.c and currenttly exported only for use
+ * Functions defined in generic/tclVar.c and currently exported only for use
* by the bytecode compiler and engine. Some of these could later be placed in
* the public interface.
*/
diff --git a/generic/tclProc.c b/generic/tclProc.c
index ae9e7cd..5c68e17 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -2774,6 +2774,41 @@ MakeLambdaError(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TclGetCmdFrameForProcedure --
+ *
+ * How to get the CmdFrame information for a procedure.
+ *
+ * Results:
+ * A pointer to the CmdFrame (only guaranteed to be valid until the next
+ * Tcl command is processed or the interpreter's state is otherwise
+ * modified) or a NULL if the information is not available.
+ *
+ * Side effects:
+ * none.
+ *
+ *----------------------------------------------------------------------
+ */
+
+CmdFrame *
+TclGetCmdFrameForProcedure(
+ Proc *procPtr) /* The procedure whose cmd-frame is to be
+ * looked up. */
+{
+ Tcl_HashEntry *hePtr;
+
+ if (procPtr == NULL || procPtr->iPtr == NULL) {
+ return NULL;
+ }
+ hePtr = Tcl_FindHashEntry(procPtr->iPtr->linePBodyPtr, procPtr);
+ if (hePtr == NULL) {
+ return NULL;
+ }
+ return (CmdFrame *) Tcl_GetHashValue(hePtr);
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tclScan.c b/generic/tclScan.c
index 5ea7e46..3edb8be 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -10,7 +10,6 @@
*/
#include "tclInt.h"
-#include "tommath.h"
/*
* Flag values used by Tcl_ScanObjCmd.
@@ -416,7 +415,14 @@ ValidateFormat(
case 'x':
case 'X':
case 'b':
+ break;
case 'u':
+ if (flags & SCAN_BIG) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "unsigned bignum scans are invalid", -1));
+ Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BADUNSIGNED",NULL);
+ goto error;
+ }
break;
/*
* Bracket terms need special checking
@@ -930,18 +936,7 @@ Tcl_ScanObjCmd(
} else {
Tcl_SetWideIntObj(objPtr, wideValue);
}
- } else if (flags & SCAN_BIG) {
- if (flags & SCAN_UNSIGNED) {
- mp_int big;
- if ((Tcl_GetBignumFromObj(interp, objPtr, &big) != TCL_OK)
- || (mp_cmp_d(&big, 0) == MP_LT)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "unsigned bignum scans are invalid", -1));
- Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BADUNSIGNED",NULL);
- return TCL_ERROR;
- }
- }
- } else {
+ } else if (!(flags & SCAN_BIG)) {
if (TclGetLongFromObj(NULL, objPtr, &value) != TCL_OK) {
if (TclGetString(objPtr)[0] == '-') {
value = LONG_MIN;
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 6cce073..4e19750 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -1943,6 +1943,11 @@ Tcl_AppendFormatToObj(
}
case 'u':
+ if (useBig) {
+ msg = "unsigned bignum format is invalid";
+ errCode = "BADUNSIGNED";
+ goto errorMsg;
+ }
case 'd':
case 'o':
case 'x':
@@ -1960,15 +1965,6 @@ Tcl_AppendFormatToObj(
goto error;
}
isNegative = (mp_cmp_d(&big, 0) == MP_LT);
- if (ch == 'u') {
- if (isNegative) {
- msg = "unsigned bignum format is invalid";
- errCode = "BADUNSIGNED";
- goto errorMsg;
- } else {
- ch = 'd';
- }
- }
#ifndef TCL_WIDE_INT_IS_LONG
} else if (useWide) {
if (Tcl_GetWideIntFromObj(NULL, segment, &w) != TCL_OK) {
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 82486d2..fc20d7e 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -3113,30 +3113,28 @@ ZlibTransformOutput(
errorCodePtr);
}
+ /*
+ * No zero-length writes. Flushes must be explicit.
+ */
+
+ if (toWrite == 0) {
+ return 0;
+ }
+
cd->outStream.next_in = (Bytef *) buf;
cd->outStream.avail_in = toWrite;
- do {
+ while (cd->outStream.avail_in > 0) {
e = Deflate(&cd->outStream, cd->outBuffer, cd->outAllocated,
Z_NO_FLUSH, &produced);
+ if (e != Z_OK || produced == 0) {
+ break;
+ }
- if ((e == Z_OK && produced > 0) || e == Z_BUF_ERROR) {
- /*
- * deflate() indicates that it is out of space by returning
- * Z_BUF_ERROR *or* by simply returning Z_OK with no remaining
- * space; in either case, we must write the whole buffer out and
- * retry to compress what is left.
- */
-
- if (e == Z_BUF_ERROR) {
- produced = cd->outAllocated;
- e = Z_OK;
- }
- if (Tcl_WriteRaw(cd->parent, cd->outBuffer, produced) < 0) {
- *errorCodePtr = Tcl_GetErrno();
- return -1;
- }
+ if (Tcl_WriteRaw(cd->parent, cd->outBuffer, produced) < 0) {
+ *errorCodePtr = Tcl_GetErrno();
+ return -1;
}
- } while (e == Z_OK && produced > 0 && cd->outStream.avail_in > 0);
+ }
if (e == Z_OK) {
return toWrite - cd->outStream.avail_in;