diff options
author | dgp <dgp@users.sourceforge.net> | 2015-09-23 16:37:06 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2015-09-23 16:37:06 (GMT) |
commit | 773fea02280ffb98f9d79bec83e4121e92f1be28 (patch) | |
tree | 96bb15abcaf084d545a65c64ebc9da85434da8ae /generic | |
parent | 4e12c83774ba3d73e4970089e9c04a886bdbae94 (diff) | |
parent | e52bf0ecd422e64401d71475c5995f18c49c8561 (diff) | |
download | tcl-773fea02280ffb98f9d79bec83e4121e92f1be28.zip tcl-773fea02280ffb98f9d79bec83e4121e92f1be28.tar.gz tcl-773fea02280ffb98f9d79bec83e4121e92f1be28.tar.bz2 |
merge 8.5bug_e0a7b3e5f8
Diffstat (limited to 'generic')
-rw-r--r-- | generic/regc_color.c | 2 | ||||
-rw-r--r-- | generic/regc_nfa.c | 1 | ||||
-rw-r--r-- | generic/regcomp.c | 19 | ||||
-rw-r--r-- | generic/tclIO.c | 47 | ||||
-rw-r--r-- | generic/tclIORChan.c | 8 | ||||
-rw-r--r-- | generic/tclMain.c | 3 | ||||
-rw-r--r-- | generic/tclThread.c | 26 |
7 files changed, 74 insertions, 32 deletions
diff --git a/generic/regc_color.c b/generic/regc_color.c index 58de004..35e7904 100644 --- a/generic/regc_color.c +++ b/generic/regc_color.c @@ -259,7 +259,7 @@ newcolor( return COLORLESS; /* too many colors */ } n = cm->ncds * 2; - if (n < MAX_COLOR + 1) { + if (n > MAX_COLOR + 1) { n = MAX_COLOR + 1; } if (cm->cd == cm->cdspace) { diff --git a/generic/regc_nfa.c b/generic/regc_nfa.c index 2de7e14..1d572c3 100644 --- a/generic/regc_nfa.c +++ b/generic/regc_nfa.c @@ -49,6 +49,7 @@ newnfa( nfa = (struct nfa *) MALLOC(sizeof(struct nfa)); if (nfa == NULL) { + ERR(REG_ESPACE); return NULL; } diff --git a/generic/regcomp.c b/generic/regcomp.c index 77f2f20..b1c02d8 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -593,13 +593,15 @@ makesearch( break; } } + + /* + * We want to mark states as being in the list already by having non + * NULL tmp fields, but we can't just store the old slist value in tmp + * because that doesn't work for the first such state. Instead, the + * first list entry gets its own address in tmp. + */ if (b != NULL && s->tmp == NULL) { - /* - * Must be split if not already in the list (fixes bugs 505048, - * 230589, 840258, 504785). - */ - - s->tmp = slist; + s->tmp = (slist != NULL) ? slist : s; slist = s; } } @@ -620,7 +622,7 @@ makesearch( freearc(nfa, a); } } - s2 = s->tmp; + s2 = (s->tmp != s) ? s->tmp : NULL; s->tmp = NULL; /* clean up while we're at it */ } } @@ -982,6 +984,7 @@ parseqatom( NOERR(); assert(v->nextvalue > 0); atom = subre(v, 'b', BACKR, lp, rp); + NOERR(); subno = v->nextvalue; atom->subno = subno; EMPTYARC(lp, rp); /* temporarily, so there's something */ @@ -1129,6 +1132,7 @@ parseqatom( */ t = subre(v, '.', COMBINE(qprefer, atom->flags), lp, rp); + NOERR(); t->left = atom; atomp = &t->left; @@ -1142,6 +1146,7 @@ parseqatom( assert(top->op == '=' && top->left == NULL && top->right == NULL); top->left = subre(v, '=', top->flags, top->begin, lp); + NOERR(); top->op = '.'; top->right = t; diff --git a/generic/tclIO.c b/generic/tclIO.c index 9a4735f..0910cc5 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -113,11 +113,30 @@ typedef struct CopyState { Tcl_WideInt total; /* Total bytes transferred (written). */ Tcl_Interp *interp; /* Interp that started the copy. */ Tcl_Obj *cmdPtr; /* Command to be invoked at completion. */ + int refCount; /* Claim count on the struct */ + int bufInUse; /* Flag to govern access to buffer */ int bufSize; /* Size of appended buffer. */ char buffer[1]; /* Copy buffer, this must be the last * field. */ } CopyState; +static void +PreserveCopyState( + CopyState *csPtr) +{ + csPtr->refCount++; +} + +static void +ReleaseCopyState( + CopyState *csPtr) +{ + if (--csPtr->refCount) { + return; + } + ckfree((char *) csPtr); +} + /* * All static variables used in this file are collected into a single instance * of the following structure. For multi-threaded implementations, there is @@ -8649,9 +8668,13 @@ TclCopyChannel( Tcl_IncrRefCount(cmdPtr); } csPtr->cmdPtr = cmdPtr; + csPtr->refCount = 1; + csPtr->bufInUse = 0; inStatePtr->csPtrR = csPtr; + PreserveCopyState(csPtr); outStatePtr->csPtrW = csPtr; + PreserveCopyState(csPtr); /* * Special handling of -size 0 async transfers, so that the -command is @@ -8703,6 +8726,11 @@ CopyData( /* Encoding control */ int underflow; /* Input underflow */ + if (csPtr->bufInUse) { + return TCL_OK; + } + PreserveCopyState(csPtr); + inChan = (Tcl_Channel) csPtr->readPtr; outChan = (Tcl_Channel) csPtr->writePtr; inStatePtr = csPtr->readPtr->state; @@ -8764,6 +8792,7 @@ CopyData( sizeb = csPtr->toRead; } + csPtr->bufInUse = 1; if (inBinary || sameEncoding) { size = DoRead(inStatePtr->topChanPtr, csPtr->buffer, sizeb); } else { @@ -8814,6 +8843,7 @@ CopyData( TclDecrRefCount(bufObj); bufObj = NULL; } + ReleaseCopyState(csPtr); return TCL_OK; } } @@ -8834,6 +8864,7 @@ CopyData( } else { sizeb = WriteChars(outStatePtr->topChanPtr, buffer, sizeb); } + csPtr->bufInUse = 0; /* * [Bug 2895565]. At this point 'size' still contains the number of @@ -8905,6 +8936,7 @@ CopyData( TclDecrRefCount(bufObj); bufObj = NULL; } + ReleaseCopyState(csPtr); return TCL_OK; } @@ -8927,6 +8959,7 @@ CopyData( TclDecrRefCount(bufObj); bufObj = NULL; } + ReleaseCopyState(csPtr); return TCL_OK; } } /* while */ @@ -8942,15 +8975,14 @@ CopyData( */ total = csPtr->total; - if (cmdPtr && interp) { + if (cmdPtr && interp && csPtr->cmdPtr) { int code; /* * Get a private copy of the command so we can mutate it by adding * arguments. Note that StopCopy frees our saved reference to the * original command obj. */ - - cmdPtr = Tcl_DuplicateObj(cmdPtr); + cmdPtr = Tcl_DuplicateObj(csPtr->cmdPtr); Tcl_IncrRefCount(cmdPtr); StopCopy(csPtr); Tcl_Preserve(interp); @@ -8978,6 +9010,7 @@ CopyData( } } } + ReleaseCopyState(csPtr); return result; } @@ -9291,10 +9324,16 @@ StopCopy( CopyEventProc, csPtr); } TclDecrRefCount(csPtr->cmdPtr); + csPtr->cmdPtr = NULL; + } + if (inStatePtr->csPtrR == NULL) { + return; } + ReleaseCopyState(inStatePtr->csPtrR); inStatePtr->csPtrR = NULL; + ReleaseCopyState(outStatePtr->csPtrW); outStatePtr->csPtrW = NULL; - ckfree((char *) csPtr); + ReleaseCopyState(csPtr); } /* diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index bbb5b88..2e5fa45 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -1508,14 +1508,6 @@ ReflectWatch( mask &= rcPtr->mode; - if (mask == rcPtr->interest) { - /* - * Same old, same old, why should we do something? - */ - - return; - } - rcPtr->interest = mask; /* diff --git a/generic/tclMain.c b/generic/tclMain.c index 5e5109b..b2206f8 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -28,7 +28,10 @@ * source directory to make their own modified versions). */ +#if defined _MSC_VER && _MSC_VER < 1900 +/* isatty is always defined on MSVC 14.0, but not necessarily as CRTIMPORT. */ extern CRTIMPORT int isatty(int fd); +#endif static Tcl_Obj *tclStartupScriptPath = NULL; static Tcl_Obj *tclStartupScriptEncoding = NULL; diff --git a/generic/tclThread.c b/generic/tclThread.c index 087d735..17071e5 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.c @@ -24,7 +24,7 @@ typedef struct { int num; /* Number of objects remembered */ int max; /* Max size of the array */ - char **list; /* List of pointers */ + void **list; /* List of pointers */ } SyncObjRecord; static SyncObjRecord keyRecord = {0, 0, NULL}; @@ -35,8 +35,8 @@ static SyncObjRecord condRecord = {0, 0, NULL}; * Prototypes of functions used only in this file. */ -static void ForgetSyncObject(char *objPtr, SyncObjRecord *recPtr); -static void RememberSyncObject(char *objPtr, +static void ForgetSyncObject(void *objPtr, SyncObjRecord *recPtr); +static void RememberSyncObject(void *objPtr, SyncObjRecord *recPtr); /* @@ -94,7 +94,7 @@ Tcl_GetThreadData( result = ckalloc((size_t) size); memset(result, 0, (size_t) size); *keyPtr = (Tcl_ThreadDataKey)result; - RememberSyncObject((char *) keyPtr, &keyRecord); + RememberSyncObject(keyPtr, &keyRecord); } result = * (void **) keyPtr; #endif /* TCL_THREADS */ @@ -153,10 +153,10 @@ TclThreadDataKeyGet( static void RememberSyncObject( - char *objPtr, /* Pointer to sync object */ + void *objPtr, /* Pointer to sync object */ SyncObjRecord *recPtr) /* Record of sync objects */ { - char **newList; + void **newList; int i, j; @@ -178,7 +178,7 @@ RememberSyncObject( if (recPtr->num >= recPtr->max) { recPtr->max += 8; - newList = (char **) ckalloc(recPtr->max * sizeof(char *)); + newList = (void **) ckalloc(recPtr->max * sizeof(char *)); for (i=0,j=0 ; i<recPtr->num ; i++) { if (recPtr->list[i] != NULL) { newList[j++] = recPtr->list[i]; @@ -214,7 +214,7 @@ RememberSyncObject( static void ForgetSyncObject( - char *objPtr, /* Pointer to sync object */ + void *objPtr, /* Pointer to sync object */ SyncObjRecord *recPtr) /* Record of sync objects */ { int i; @@ -248,7 +248,7 @@ void TclRememberMutex( Tcl_Mutex *mutexPtr) { - RememberSyncObject((char *)mutexPtr, &mutexRecord); + RememberSyncObject(mutexPtr, &mutexRecord); } /* @@ -276,7 +276,7 @@ Tcl_MutexFinalize( TclpFinalizeMutex(mutexPtr); #endif TclpMasterLock(); - ForgetSyncObject((char *) mutexPtr, &mutexRecord); + ForgetSyncObject(mutexPtr, &mutexRecord); TclpMasterUnlock(); } @@ -303,7 +303,9 @@ void TclMutexUnlockAndFinalize( Tcl_Mutex *mutexPtr) { +#ifdef TCL_THREADS Tcl_Mutex mutex; +#endif TclpMasterLock(); TclpMutexLock(); #ifdef TCL_THREADS @@ -338,7 +340,7 @@ void TclRememberCondition( Tcl_Condition *condPtr) { - RememberSyncObject((char *) condPtr, &condRecord); + RememberSyncObject(condPtr, &condRecord); } /* @@ -366,7 +368,7 @@ Tcl_ConditionFinalize( TclpFinalizeCondition(condPtr); #endif TclpMasterLock(); - ForgetSyncObject((char *) condPtr, &condRecord); + ForgetSyncObject(condPtr, &condRecord); TclpMasterUnlock(); } |