From bdab09a0d9b8ae500789e11038ce4a96802388ec Mon Sep 17 00:00:00 2001 From: pspjuth Date: Tue, 30 Aug 2016 19:46:35 +0000 Subject: Made text widget's default undo false again. --- generic/tkText.c | 2 +- tests/text.test | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 5ad527a..ab77d99 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -547,7 +547,7 @@ CreateWidget( Tcl_InitHashTable(&sharedPtr->windowTable, TCL_STRING_KEYS); Tcl_InitHashTable(&sharedPtr->imageTable, TCL_STRING_KEYS); sharedPtr->undoStack = TkUndoInitStack(interp,0); - sharedPtr->undo = 1; + sharedPtr->undo = 0; sharedPtr->isDirty = 0; sharedPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL; sharedPtr->autoSeparators = 1; diff --git a/tests/text.test b/tests/text.test index 720afbe..f640817 100644 --- a/tests/text.test +++ b/tests/text.test @@ -29,6 +29,15 @@ test text-1.1 {configuration option: "autoseparators"} -setup { } -cleanup { destroy .t } -result {1} +test text-1.1b {configuration option: "autoseparators", default} -setup { + text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} + pack .t + update +} -body { + .t cget -autoseparators +} -cleanup { + destroy .t +} -result {1} test text-1.2 {configuration option: "autoseparators"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -428,6 +437,15 @@ test text-1.43 {configuration option: "maxundo"} -setup { } -cleanup { destroy .t } -result {5} +test text-1.43b {configuration option: "maxundo", default} -setup { + text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} + pack .t + update +} -body { + .t cget -maxundo +} -cleanup { + destroy .t +} -result {0} test text-1.44 {configuration option: "maxundo"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -732,6 +750,15 @@ test text-1.75 {configuration option: "undo"} -setup { } -cleanup { destroy .t } -result {1} +test text-1.75b {configuration option: "undo", default} -setup { + text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} + pack .t + update +} -body { + .t cget -undo +} -cleanup { + destroy .t +} -result {0} test text-1.76 {configuration option: "undo"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -6396,8 +6423,23 @@ test text-27.16a {undo configuration options with peers} -body { lappend res [.t edit canundo] lappend res [.tt edit canundo] } -cleanup { - destroy .t + destroy .t .tt } -result {1 1 0 0 100 100 1 1} +test text-27.16b {undo configuration options with peers, defaults} -body { + text .t + .t peer create .tt + set res [.t cget -undo] + lappend res [.tt cget -undo] + lappend res [.t cget -autoseparators] + lappend res [.tt cget -autoseparators] + lappend res [.t cget -maxundo] + lappend res [.tt cget -maxundo] + .t insert end "The undo stack is common between peers" + lappend res [.t edit canundo] + lappend res [.tt edit canundo] +} -cleanup { + destroy .t .tt +} -result {0 0 1 1 0 0 0 0} test text-27.17 {bug fix 1536735 - undo with empty text} -body { text .t -undo 1 set r [.t edit modified] -- cgit v0.12 From 34d8945d9d1dbbb3f599cabcad75ec0305f7615d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 31 Aug 2016 08:50:23 +0000 Subject: Fix use of XMaxTransChars in stead of TCL_UTF_MAX in some places. This should prevent possible buffer overflow when TCL_UTF_MAX=6 Micro-optimizations in tkEntry and ttkEntry --- generic/tkEntry.c | 3 ++- generic/ttk/ttkEntry.c | 3 ++- win/tkWinFont.c | 2 +- win/tkWinKey.c | 4 ++-- win/tkWinX.c | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index ea8d7f1..c0ce47b 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1943,7 +1943,8 @@ EntryComputeGeometry( entryPtr->displayString = p; for (i = entryPtr->numChars; --i >= 0; ) { - p += Tcl_UniCharToUtf(ch, p); + memcpy(p, buf, size); + p += size; } *p = '\0'; } diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index f395649..533637d 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -290,7 +290,8 @@ static char *EntryDisplayString(const char *showChar, int numChars) p = displayString = ckalloc(numChars * size + 1); while (numChars--) { - p += Tcl_UniCharToUtf(ch, p); + memcpy(p, buf, size); + p += size; } *p = '\0'; diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 9172b00..940bc10 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -2188,7 +2188,7 @@ FontMapLoadPage( { FontFamily *familyPtr; Tcl_Encoding encoding; - char src[TCL_UTF_MAX], buf[16]; + char src[XMaxTransChars], buf[16]; USHORT *startCount, *endCount; int i, j, bitOffset, end, segCount; diff --git a/win/tkWinKey.c b/win/tkWinKey.c index ed546f7..5591133 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -102,7 +102,7 @@ TkpGetString( */ int unichar; - char buf[TCL_UTF_MAX]; + char buf[XMaxTransChars]; int len; unichar = keyEv->trans_chars[1] & 0xff; @@ -129,7 +129,7 @@ TkpGetString( if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256)) || (keysym == XK_Return) || (keysym == XK_Tab)) { - char buf[TCL_UTF_MAX]; + char buf[XMaxTransChars]; int len; len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf); diff --git a/win/tkWinX.c b/win/tkWinX.c index 6c44059..99102cb 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1215,13 +1215,13 @@ GenerateXEvent( break; case WM_UNICHAR: { - char buffer[TCL_UTF_MAX+1]; + char buffer[XMaxTransChars]; int i; event.type = KeyPress; event.xany.send_event = -3; event.xkey.keycode = wParam; event.xkey.nbytes = Tcl_UniCharToUtf((int)wParam, buffer); - for (i=0; i