summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--generic/tkText.c16
2 files changed, 15 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 0de2a7e..7fa787d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-11-20 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * generic/tkText.c (TextGetText): reworked to use DString for
+ improved speed. (callewaert, darley)
+ (DestroyText): plugged mem leak when not clearing stack (callewaert)
+ (TextGetText): more efficient string size calculation (darley)
+
2001-11-19 Donal K. Fellows <fellowsd@cs.man.ac.uk>
* library/demos/entry3.tcl: New demo showing off validation and
diff --git a/generic/tkText.c b/generic/tkText.c
index fd0e21a..e0ef3d8 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -14,7 +14,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.20 2001/11/20 09:58:33 hobbs Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.21 2001/11/21 01:36:33 hobbs Exp $
*/
#include "default.h"
@@ -811,6 +811,8 @@ DestroyText(memPtr)
if (textPtr->bindingTable != NULL) {
Tk_DeleteBindingTable(textPtr->bindingTable);
}
+ clearStack(&(textPtr->undoStack));
+ clearStack(&(textPtr->redoStack));
/*
* NOTE: do NOT free up selBorder, selBdString, or selFgColorPtr:
@@ -1414,7 +1416,8 @@ DeleteChars(textPtr, index1String, index2String)
strcpy(deletion->index, indexBuffer);
TextGetText(&index1, &index2, &ds);
- deletion->string = (char *) ckalloc(Tcl_DStringLength(&ds) + 1);
+ deletion->string =
+ (char *) ckalloc((unsigned int) Tcl_DStringLength(&ds) + 1);
strcpy(deletion->string, Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
@@ -2877,7 +2880,7 @@ TextGetText(indexPtr1,indexPtr2, dsPtr)
if (TkTextIndexCmp(indexPtr1, indexPtr2) < 0) {
while (1) {
- int offset, last, savedChar;
+ int offset, last;
TkTextSegment *segPtr;
segPtr = TkTextIndexToSeg(&tmpIndex, &offset);
@@ -2894,11 +2897,8 @@ TextGetText(indexPtr1,indexPtr2, dsPtr)
}
}
if (segPtr->typePtr == &tkTextCharType) {
- savedChar = segPtr->body.chars[last];
- segPtr->body.chars[last] = 0;
- Tcl_DStringAppend(dsPtr,segPtr->body.chars + offset,
- (int)strlen(segPtr->body.chars + offset));
- segPtr->body.chars[last] = savedChar;
+ Tcl_DStringAppend(dsPtr, segPtr->body.chars + offset,
+ last - offset);
}
TkTextIndexForwBytes(&tmpIndex, last-offset, &tmpIndex);
}