diff options
author | vincentdarley <vincentdarley> | 2006-03-28 19:26:51 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley> | 2006-03-28 19:26:51 (GMT) |
commit | 33a8b76b5b3843e63e62ed11c06b89ea6ef42ede (patch) | |
tree | 8527c6fef01b1cdb3276e40ccf7e5ec88cee1280 /generic | |
parent | a8ce4b96284ab3e2477e17c015337d4828703be7 (diff) | |
download | tk-33a8b76b5b3843e63e62ed11c06b89ea6ef42ede.zip tk-33a8b76b5b3843e63e62ed11c06b89ea6ef42ede.tar.gz tk-33a8b76b5b3843e63e62ed11c06b89ea6ef42ede.tar.bz2 |
further fixes to $text dump -command
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkText.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/generic/tkText.c b/generic/tkText.c index 2172e01..fb45e66 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.c,v 1.66 2006/03/26 17:52:39 vincentdarley Exp $ + * RCS: @(#) $Id: tkText.c,v 1.67 2006/03/28 19:26:52 vincentdarley Exp $ */ #include "default.h" @@ -4526,6 +4526,7 @@ TextDumpCmd(textPtr, interp, objc, objv) textChanged = DumpLine(interp, textPtr, what, index1.linePtr, index1.byteIndex, 32000000, lineno, command); if (textChanged) { + if (textPtr->flags & DESTROYED) return TCL_OK; linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr, lineno); textChanged = 0; @@ -4540,6 +4541,7 @@ TextDumpCmd(textPtr, interp, objc, objv) textChanged = DumpLine(interp, textPtr, what, linePtr, 0, 32000000, lineno, command); if (textChanged) { + if (textPtr->flags & DESTROYED) return TCL_OK; linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr, lineno); textChanged = 0; @@ -4548,6 +4550,7 @@ TextDumpCmd(textPtr, interp, objc, objv) if (linePtr != NULL) { DumpLine(interp, textPtr, what, linePtr, 0, endByteIndex, lineno, command); + if (textPtr->flags & DESTROYED) return TCL_OK; } } @@ -4556,6 +4559,7 @@ TextDumpCmd(textPtr, interp, objc, objv) */ if (atEnd) { + if (textPtr->flags & DESTROYED) return TCL_OK; /* Re-get the end index, in case it has changed */ if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) { return TCL_ERROR; @@ -4706,13 +4710,40 @@ DumpLine(interp, textPtr, what, linePtr, startByte, endByte, lineno, command) } offset += currentSize; if (lineChanged) { + TkTextSegment * newSegPtr; int newOffset = 0; textChanged = 1; /* Our indices are no longer valid */ - linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr, lineno); - segPtr = linePtr->segPtr; - while ((newOffset < endByte) && (newOffset < offset) && (segPtr != NULL)) { - segPtr = segPtr->nextPtr; + if (textPtr->flags & DESTROYED) { + return textChanged; + } + linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, + textPtr, lineno); + newSegPtr = linePtr->segPtr; + if (segPtr == newSegPtr) { + segPtr = segPtr->nextPtr; + } else { + while ((newOffset < endByte) && (newOffset < offset) + && (newSegPtr != NULL)) { + newOffset += segPtr->size; + newSegPtr = newSegPtr->nextPtr; + if (segPtr == newSegPtr) break; + } + if (segPtr != newSegPtr && newOffset == offset + && currentSize == 0) { + TkTextSegment *searchPtr = newSegPtr; + while (searchPtr != NULL && searchPtr->size == 0) { + if (searchPtr == segPtr) { + newSegPtr = searchPtr; + break; + } + searchPtr = searchPtr->nextPtr; + } + } + segPtr = newSegPtr; + if (segPtr != NULL) { + segPtr = segPtr->nextPtr; + } } } else { segPtr = segPtr->nextPtr; |