summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorseandeelywoods <seandeelywoods>2014-10-19 11:06:00 (GMT)
committerseandeelywoods <seandeelywoods>2014-10-19 11:06:00 (GMT)
commitbc2e2d80d513f1a9fd0500fbfe21b014e1e4560f (patch)
treec6e652d17433e98dfdd59e930743d15239aefd57 /generic
parent3f4b0e6ce72b06d8872a817bb1ae1680254f5823 (diff)
parentfe445f7962f05b59609189e8ec30cb508705ca37 (diff)
downloadtcl-bc2e2d80d513f1a9fd0500fbfe21b014e1e4560f.zip
tcl-bc2e2d80d513f1a9fd0500fbfe21b014e1e4560f.tar.gz
tcl-bc2e2d80d513f1a9fd0500fbfe21b014e1e4560f.tar.bz2
Bringing in the latest fixes from trunk
Diffstat (limited to 'generic')
-rw-r--r--generic/tclAlloc.c2
-rw-r--r--generic/tclCompCmds.c9
-rw-r--r--generic/tclCompCmdsGR.c2
-rw-r--r--generic/tclCompCmdsSZ.c5
-rw-r--r--generic/tclCompile.h12
-rw-r--r--generic/tclIO.c58
-rw-r--r--generic/tclInt.h2
-rw-r--r--generic/tclTrace.c3
8 files changed, 54 insertions, 39 deletions
diff --git a/generic/tclAlloc.c b/generic/tclAlloc.c
index ae61e85..cda1f38 100644
--- a/generic/tclAlloc.c
+++ b/generic/tclAlloc.c
@@ -31,7 +31,7 @@
* until Tcl uses config.h properly.
*/
-#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__BORLANDC__)
+#if defined(_MSC_VER) || defined(__MSVCRT__) || defined(__BORLANDC__)
typedef unsigned long caddr_t;
#endif
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 431f0af..18f4564 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -301,7 +301,8 @@ TclCompileArraySetCmd(
* a proc, we cannot do a better compile than generic.
*/
- if (envPtr->procPtr == NULL && !(isDataEven && len == 0)) {
+ if ((varTokenPtr->type != TCL_TOKEN_SIMPLE_WORD) ||
+ (envPtr->procPtr == NULL && !(isDataEven && len == 0))) {
code = TclCompileBasic2ArgCmd(interp, parsePtr, cmdPtr, envPtr);
goto done;
}
@@ -342,8 +343,9 @@ TclCompileArraySetCmd(
* a non-local variable: upvar from a local one! This consumes the
* variable name that was left at stacktop.
*/
-
- localIndex = AnonymousLocal(envPtr);
+
+ localIndex = TclFindCompiledLocal(varTokenPtr->start,
+ varTokenPtr->size, 1, envPtr);
PushStringLiteral(envPtr, "0");
TclEmitInstInt4(INST_REVERSE, 2, envPtr);
TclEmitInstInt4(INST_UPVAR, localIndex, envPtr);
@@ -2401,7 +2403,6 @@ TclCompileForCmd(
SetLineInformation(2);
TclCompileExprWords(interp, testTokenPtr, 1, envPtr);
- TclClearNumConversion(envPtr);
jumpDist = CurrentOffset(envPtr) - bodyCodeOffset;
if (jumpDist > 127) {
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c
index 603c51d..9d258fc 100644
--- a/generic/tclCompCmdsGR.c
+++ b/generic/tclCompCmdsGR.c
@@ -281,7 +281,6 @@ TclCompileIfCmd(
SetLineInformation(wordIdx);
Tcl_ResetResult(interp);
TclCompileExprWords(interp, testTokenPtr, 1, envPtr);
- TclClearNumConversion(envPtr);
if (jumpFalseFixupArray.next >= jumpFalseFixupArray.end) {
TclExpandJumpFixupArray(&jumpFalseFixupArray);
}
@@ -531,7 +530,6 @@ TclCompileIncrCmd(
} else {
SetLineInformation(2);
CompileTokens(envPtr, incrTokenPtr, interp);
- TclClearNumConversion(envPtr);
}
} else { /* No incr amount given so use 1. */
haveImmValue = 1;
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index 2b83fd2..382d2d1 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -322,8 +322,8 @@ TclCompileStringCatCmd(
CompileWord(envPtr, wordTokenPtr, interp, i);
numArgs ++;
if (numArgs >= 254) { /* 254 to take care of the possible +1 of "folded" above */
- TclEmitInstInt1(INST_STR_CONCAT1, 254, envPtr);
- numArgs -= 253; /* concat pushes 1 obj, the result */
+ TclEmitInstInt1(INST_STR_CONCAT1, numArgs, envPtr);
+ numArgs = 1; /* concat pushes 1 obj, the result */
}
}
wordTokenPtr = TokenAfter(wordTokenPtr);
@@ -3782,7 +3782,6 @@ TclCompileWhileCmd(
}
SetLineInformation(1);
TclCompileExprWords(interp, testTokenPtr, 1, envPtr);
- TclClearNumConversion(envPtr);
jumpDist = CurrentOffset(envPtr) - bodyCodeOffset;
if (jumpDist > 127) {
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 01b78d9..51f0b34 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -1414,18 +1414,6 @@ MODULE_SCOPE int TclPushProcCallFrame(ClientData clientData,
} while (0)
/*
- * If the expr compiler finished with TRY_CONVERT, macro to remove it when the
- * job is done by the following instruction.
- */
-
-#define TclClearNumConversion(envPtr) \
- do { \
- if (*(envPtr->codeNext - 1) == INST_TRY_CVT_TO_NUMERIC) { \
- envPtr->codeNext--; \
- } \
- } while (0)
-
-/*
* Macros to update a (signed or unsigned) integer starting at a pointer. The
* two variants depend on the number of bytes. The ANSI C "prototypes" for
* these macros are:
diff --git a/generic/tclIO.c b/generic/tclIO.c
index dcde8d1..207ce19 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -3894,7 +3894,10 @@ Tcl_Write(
if (srcLen < 0) {
srcLen = strlen(src);
}
- return WriteBytes(chanPtr, src, srcLen);
+ if (WriteBytes(chanPtr, src, srcLen) < 0) {
+ return -1;
+ }
+ return srcLen;
}
/*
@@ -4450,6 +4453,7 @@ Tcl_GetsObj(
eof = NULL;
inEofChar = statePtr->inEofChar;
+ ResetFlag(statePtr, CHANNEL_BLOCKED);
while (1) {
if (dst >= dstEnd) {
if (FilterInputBytes(chanPtr, &gs) != 0) {
@@ -4798,6 +4802,7 @@ TclGetsObjBinary(
eolChar = (statePtr->inputTranslation == TCL_TRANSLATE_LF) ? '\n' : '\r';
+ ResetFlag(statePtr, CHANNEL_BLOCKED);
while (1) {
/*
* Subtract the number of bytes that were removed from channel
@@ -5086,6 +5091,12 @@ FilterInputBytes(
*/
read:
+ if (GotFlag(statePtr, CHANNEL_NONBLOCKING|CHANNEL_BLOCKED)
+ == (CHANNEL_NONBLOCKING|CHANNEL_BLOCKED)) {
+ gsPtr->charsWrote = 0;
+ gsPtr->rawRead = 0;
+ return -1;
+ }
if (GetInput(chanPtr) != 0) {
gsPtr->charsWrote = 0;
gsPtr->rawRead = 0;
@@ -5176,12 +5187,6 @@ FilterInputBytes(
* some more, but avoid blocking on a non-blocking channel.
*/
- if (GotFlag(statePtr, CHANNEL_NONBLOCKING|CHANNEL_BLOCKED)
- == (CHANNEL_NONBLOCKING|CHANNEL_BLOCKED)) {
- gsPtr->charsWrote = 0;
- gsPtr->rawRead = 0;
- return -1;
- }
goto read;
}
} else {
@@ -6046,12 +6051,11 @@ ReadChars(
/*
* We read more chars than allowed. Reset limits to
* prevent that and try again. Don't forget the extra
- * padding of TCL_UTF_MAX - 1 bytes demanded by the
+ * padding of TCL_UTF_MAX bytes demanded by the
* Tcl_ExternalToUtf() call!
*/
- dstLimit = Tcl_UtfAtIndex(dst, charsToRead + 1)
- + TCL_UTF_MAX - 1 - dst;
+ dstLimit = Tcl_UtfAtIndex(dst, charsToRead) + TCL_UTF_MAX - dst;
statePtr->flags = savedFlags;
statePtr->inputEncodingFlags = savedIEFlags;
statePtr->inputEncodingState = savedState;
@@ -9021,7 +9025,7 @@ MBRead(
}
code = GetInput(inStatePtr->topChanPtr);
- if (code == 0) {
+ if (code == 0 || GotFlag(inStatePtr, CHANNEL_BLOCKED)) {
return TCL_OK;
} else {
MBError(csPtr, TCL_READABLE, code);
@@ -9271,6 +9275,10 @@ CopyData(
csPtr);
}
if (size == 0) {
+ if (!GotFlag(inStatePtr, CHANNEL_NONBLOCKING)) {
+ /* We allowed a short read. Keep trying. */
+ continue;
+ }
if (bufObj != NULL) {
TclDecrRefCount(bufObj);
bufObj = NULL;
@@ -9503,21 +9511,39 @@ DoRead(
}
/*
- * If there is not enough data in the buffers to possibly
- * complete the read, then go get more.
+ * Don't read more data if we have what we need.
*/
- if (bufPtr == NULL || BytesLeft(bufPtr) < bytesToRead) {
+ while (!bufPtr || /* We got no buffer! OR */
+ (!IsBufferFull(bufPtr) && /* Our buffer has room AND */
+ (BytesLeft(bufPtr) < bytesToRead) ) ) {
+ /* Not enough bytes in it
+ * yet to fill the dst */
+ int code;
+
moreData:
- if (GetInput(chanPtr)) {
+ code = GetInput(chanPtr);
+ bufPtr = statePtr->inQueueHead;
+
+ assert (bufPtr != NULL);
+
+ if (GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)) {
+ /* Further reads cannot do any more */
+ break;
+ }
+
+ if (code) {
/* Read error */
UpdateInterest(chanPtr);
TclChannelRelease((Tcl_Channel)chanPtr);
return -1;
}
- bufPtr = statePtr->inQueueHead;
+
+ assert (IsBufferFull(bufPtr));
}
+ assert (bufPtr != NULL);
+
bytesRead = BytesLeft(bufPtr);
bytesWritten = bytesToRead;
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 7287a13..860c2a3 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -1741,7 +1741,7 @@ enum PkgPreferOptions {
* definition there.
* Some macros require knowledge of some fields in the struct in order to
* avoid hitting the TSD unnecessarily. In order to facilitate this, a pointer
- * to the relevant fields is kept in the objCache field in struct Interp.
+ * to the relevant fields is kept in the allocCache field in struct Interp.
*----------------------------------------------------------------
*/
diff --git a/generic/tclTrace.c b/generic/tclTrace.c
index c0cde49..6184a89 100644
--- a/generic/tclTrace.c
+++ b/generic/tclTrace.c
@@ -2511,6 +2511,9 @@ TclObjCallVarTraces(
if (!part1Ptr) {
part1Ptr = localName(iPtr->varFramePtr, index);
}
+ if (!part1Ptr) {
+ Tcl_Panic("Cannot trace a variable with no name");
+ }
part1 = TclGetString(part1Ptr);
part2 = part2Ptr? TclGetString(part2Ptr) : NULL;