summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-02-09 18:43:52 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-02-09 18:43:52 (GMT)
commit77c0bc32154c03e49b39ad66e676999e29b66a2c (patch)
treeda2ea54eebc27b5b2601fd217019bc0eae04c6c2
parentb2bb8f7366e971a698d64610c5d30fa31f414ca1 (diff)
parent8f151700b10bf8811876305e284738707d4ad237 (diff)
downloadtk-77c0bc32154c03e49b39ad66e676999e29b66a2c.zip
tk-77c0bc32154c03e49b39ad66e676999e29b66a2c.tar.gz
tk-77c0bc32154c03e49b39ad66e676999e29b66a2c.tar.bz2
merge trunk
-rw-r--r--doc/option.n6
-rw-r--r--generic/tkOption.c40
-rw-r--r--generic/tkTextDisp.c59
-rw-r--r--macosx/GNUmakefile2
-rw-r--r--macosx/tkMacOSXButton.c4
-rw-r--r--macosx/tkMacOSXInit.c2
-rw-r--r--macosx/tkMacOSXPrivate.h4
-rw-r--r--macosx/ttkMacOSXTheme.c2
-rw-r--r--tests/entry.test6
-rwxr-xr-xtests/option.file32
-rw-r--r--tests/textDisp.test19
11 files changed, 80 insertions, 66 deletions
diff --git a/doc/option.n b/doc/option.n
index 8699c0d..2763d64 100644
--- a/doc/option.n
+++ b/doc/option.n
@@ -59,6 +59,12 @@ options specified in that file to the option database. If \fIpriority\fR
is specified, it indicates the priority level at which to enter the
options; \fIpriority\fR defaults to \fBinteractive\fR.
.PP
+The file is read through a channel which is in "utf-8" encoding,
+invalid byte sequences are automatically converted to valid ones.
+This means that encodings like ISO 8859-1 or cp1252 with high
+probability will work as well, but this cannot be guaranteed.
+This cannot be changed, setting the [encoding system] has no effect.
+.PP
The \fIpriority\fR arguments to the \fBoption\fR command are
normally specified symbolically using one of the following values:
.TP
diff --git a/generic/tkOption.c b/generic/tkOption.c
index 680c9db..24e7fb3 100644
--- a/generic/tkOption.c
+++ b/generic/tkOption.c
@@ -1080,10 +1080,10 @@ ReadOptionFile(
* TK_MAX_PRIO. */
{
const char *realName;
- char *buffer;
+ Tcl_Obj *buffer;
int result, bufferSize;
Tcl_Channel chan;
- Tcl_DString newName, optString;
+ Tcl_DString newName;
/*
* Prevent file system access in a safe interpreter.
@@ -1108,24 +1108,10 @@ ReadOptionFile(
return TCL_ERROR;
}
- /*
- * Compute size of file by seeking to the end of the file. This will
- * overallocate if we are performing CRLF translation.
- */
-
- bufferSize = (int) Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_END);
- Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_SET);
-
- if (bufferSize < 0) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "error seeking to end of file \"%s\": %s",
- fileName, Tcl_PosixError(interp)));
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
- }
-
- buffer = ckalloc(bufferSize + 1);
- bufferSize = Tcl_Read(chan, buffer, bufferSize);
+ buffer = Tcl_NewObj();
+ Tcl_IncrRefCount(buffer);
+ Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8");
+ bufferSize = Tcl_ReadChars(chan, buffer, -1, 0);
if (bufferSize < 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error reading file \"%s\": %s",
@@ -1134,18 +1120,8 @@ ReadOptionFile(
return TCL_ERROR;
}
Tcl_Close(NULL, chan);
- buffer[bufferSize] = 0;
- if ((bufferSize>2) && !memcmp(buffer, "\357\273\277", 3)) {
- /* File starts with UTF-8 BOM */
- result = AddFromString(interp, tkwin, buffer+3, priority);
- } else {
- Tcl_DStringInit(&optString);
- Tcl_ExternalToUtfDString(NULL, buffer, bufferSize, &optString);
- result = AddFromString(interp, tkwin, Tcl_DStringValue(&optString),
- priority);
- Tcl_DStringFree(&optString);
- }
- ckfree(buffer);
+ result = AddFromString(interp, tkwin, Tcl_GetString(buffer), priority);
+ Tcl_DecrRefCount(buffer);
return result;
}
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 18b373f..7969091 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -4869,16 +4869,9 @@ TextRedrawTag(
/*
* Round up the starting position if it's before the first line visible on
- * the screen (we only care about what's on the screen). Beware that the
- * display info structure might need update, for instance if we arrived
- * here from an 'after idle' script removing tags in a range whose
- * display lines (and dInfo) were partially invalidated by a previous
- * delete operation in the text widget.
+ * the screen (we only care about what's on the screen).
*/
- if (dInfoPtr->flags & DINFO_OUT_OF_DATE) {
- UpdateDisplayInfo(textPtr);
- }
dlPtr = dInfoPtr->dLinePtr;
if (dlPtr == NULL) {
return;
@@ -5240,7 +5233,10 @@ TkTextSetYView(
dInfoPtr->newTopPixelOffset = 0;
goto scheduleUpdate;
- }
+ }
+ /*
+ * The line is already on screen, with no need to scroll.
+ */
return;
}
}
@@ -6703,6 +6699,7 @@ FindDLine(
const TkTextIndex *indexPtr)/* Index of desired character. */
{
DLine *dlPtrPrev;
+ TkTextIndex indexPtr2;
if (dlPtr == NULL) {
return NULL;
@@ -6727,24 +6724,58 @@ FindDLine(
dlPtrPrev = dlPtr;
dlPtr = dlPtr->nextPtr;
if (dlPtr == NULL) {
- TkTextIndex indexPtr2;
/*
* We're past the last display line, either because the desired
* index lies past the visible text, or because the desired index
- * is on the last display line showing the last logical line.
+ * is on the last display line.
*/
indexPtr2 = dlPtrPrev->index;
TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount,
&indexPtr2);
if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) {
+ /*
+ * The desired index is on the last display line.
+ * --> return this display line.
+ */
dlPtr = dlPtrPrev;
- break;
} else {
- return NULL;
+ /*
+ * The desired index is past the visible text. There is no
+ * display line displaying something at the desired index.
+ * --> return NULL.
+ */
}
+ break;
}
if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) {
- dlPtr = dlPtrPrev;
+ /*
+ * If we're here then we would normally expect that:
+ * dlPtrPrev->index <= indexPtr < dlPtr->index
+ * i.e. we have found the searched display line being dlPtr.
+ * However it is possible that some DLines were unlinked
+ * previously, leading to a situation where going through
+ * the list of display lines skips display lines that did
+ * exist just a moment ago.
+ */
+ indexPtr2 = dlPtrPrev->index;
+ TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount,
+ &indexPtr2);
+ if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) {
+ /*
+ * Confirmed:
+ * dlPtrPrev->index <= indexPtr < dlPtr->index
+ * --> return dlPtrPrev.
+ */
+ dlPtr = dlPtrPrev;
+ } else {
+ /*
+ * The last (rightmost) index shown by dlPtrPrev is still
+ * before the desired index. This may be because there was
+ * previously a display line between dlPtrPrev and dlPtr
+ * and this display line has been unlinked.
+ * --> return dlPtr.
+ */
+ }
break;
}
}
diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile
index 02240ed..d0bab1a 100644
--- a/macosx/GNUmakefile
+++ b/macosx/GNUmakefile
@@ -35,7 +35,7 @@ MANDIR ?= ${PREFIX}/man
TCL_BUILD_DIR ?= ${BUILD_DIR}/tcl/${BUILD_STYLE}
# location of installed tcl, only used if tcl in TCL_BUILD_DIR can't be found
TCL_FRAMEWORK_DIR ?= /Library/Frameworks
-TCLSH_DIR ?= ${PREFIX}
+TCLSH_DIR ?= ${PREFIX}/bin
# set to non-empty value to install manpages in addition to html help:
INSTALL_MANPAGES ?=
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index 59d394e..ebbcf09 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.c
@@ -289,10 +289,10 @@ TkpComputeButtonGeometry(
if ( butPtr->indicatorOn ) {
switch (butPtr->type) {
case TYPE_RADIO_BUTTON:
- GetThemeMetric(kThemeMetricRadioButtonWidth, &butPtr->indicatorDiameter);
+ GetThemeMetric(kThemeMetricRadioButtonWidth, (SInt32 *)&butPtr->indicatorDiameter);
break;
case TYPE_CHECK_BUTTON:
- GetThemeMetric(kThemeMetricCheckBoxWidth, &butPtr->indicatorDiameter);
+ GetThemeMetric(kThemeMetricCheckBoxWidth, (SInt32 *)&butPtr->indicatorDiameter);
break;
default:
break;
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index b965a38..33a60f2 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -57,9 +57,7 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
@end
@implementation TKApplication
-#ifndef __clang__
@synthesize poolProtected = _poolProtected;
-#endif
@end
@implementation TKApplication(TKInit)
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index 2a411f6..65d60ce 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -276,6 +276,10 @@ VISIBILITY_HIDDEN
NSArray *_defaultHelpMenuItems;
NSWindow *_windowWithMouse;
NSAutoreleasePool *_mainPool;
+#ifdef __i386__
+ /* The Objective C runtime used on i386 requires this. */
+ BOOL _poolProtected;
+#endif
}
@property BOOL poolProtected;
@end
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 4753a40..f9611c5 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -298,7 +298,7 @@ static void TabElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- *heightPtr = GetThemeMetric(kThemeMetricLargeTabHeight, heightPtr);
+ GetThemeMetric(kThemeMetricLargeTabHeight, (SInt32 *)heightPtr);
*paddingPtr = Ttk_MakePadding(0, 0, 0, 2);
}
diff --git a/tests/entry.test b/tests/entry.test
index 9c30b00..4f09450 100644
--- a/tests/entry.test
+++ b/tests/entry.test
@@ -1074,7 +1074,7 @@ test entry-3.42 {EntryWidgetCmd procedure, "scan" widget command} -setup {
} -body {
.e scan a
} -cleanup {
- destroy .e
+ destroy .efixed
} -returnCodes error -result {wrong # args: should be ".e scan mark|dragto x"}
test entry-3.43 {EntryWidgetCmd procedure, "scan" widget command} -setup {
entry .e
@@ -1896,12 +1896,12 @@ test entry-6.12 {EntryComputeGeometry procedure} -constraints {
fonts
} -setup {
catch {destroy .e}
- entry .e -font $fixed -bd 2 -relief raised -width 20
+ entry .e -font {Courier -12} -bd 2 -relief raised -width 20
pack .e
} -body {
.e insert end "012\t456\t"
update
- list [.e index @81] [.e index @82] [.e index @116] [.e index @117]
+ list [.e index @80] [.e index @81] [.e index @115] [.e index @116]
} -cleanup {
destroy .e
} -result {6 7 7 8}
diff --git a/tests/option.file3 b/tests/option.file3
index 87f41ae..146cfd9 100755
--- a/tests/option.file3
+++ b/tests/option.file3
@@ -1,4 +1,4 @@
-! This file is a sample option (resource) database used to test
+! This file is a sample option (resource) database used to test
! Tk's option-handling capabilities.
! Comment line \
diff --git a/tests/textDisp.test b/tests/textDisp.test
index caba769..353999f 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -1181,16 +1181,15 @@ test textDisp-8.12 {TkTextChanged, moving the insert cursor redraws only past an
.t mark set insert 3.8 ; # within the same line
update
lappend res $tk_textRedraw
- # This last one is tricky: correct result really is {2.0 3.0} when
- # calling .t mark set insert, two calls to TkTextChanged are done:
- # (a) to redraw the line of the past position of the cursor
- # (b) to redraw the line of the new position of the cursor
- # During (a) the display line showing the cursor gets unlinked,
- # which leads TkTextChanged in (b) to schedule a redraw starting
- # one line _before_ the line containing the insert cursor. This is
- # because during (b) findDLine cannot return the display line the
- # cursor is in since this display line was just unlinked in (a).
-} {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {2.0 3.0}}
+} {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {3.0 4.0}}
+test textDisp-8.13 {TkTextChanged, used to crash, see [06c1433906]} {
+ .t delete 1.0 end
+ .t insert 1.0 \nLine2\nLine3\n
+ update
+ .t insert 3.0 ""
+ .t delete 1.0 2.0
+ update idletasks
+} {}
test textDisp-9.1 {TkTextRedrawTag} {
.t configure -wrap char