summaryrefslogtreecommitdiffstats
path: root/generic/tkText.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-08-10 06:42:38 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-08-10 06:42:38 (GMT)
commitd0d60d0394aa80c49b074ed78c5a58eb8394f3b4 (patch)
treeb2e5939c456b158ec1c05150862dd2083a33fb43 /generic/tkText.c
parent20fd74ff24e59cc7716ff4b2b1707a9df253b22c (diff)
parent7d7b549619c459b43235329d1eafcff775e2828e (diff)
downloadtk-d0d60d0394aa80c49b074ed78c5a58eb8394f3b4.zip
tk-d0d60d0394aa80c49b074ed78c5a58eb8394f3b4.tar.gz
tk-d0d60d0394aa80c49b074ed78c5a58eb8394f3b4.tar.bz2
Merge 8.6
Diffstat (limited to 'generic/tkText.c')
-rw-r--r--generic/tkText.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index 903a1a8..b2bffbf 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -864,7 +864,8 @@ TextWidgetObjCmd(
}
for (i = 2; i < objc-2; i++) {
- int value, length;
+ int value;
+ size_t length;
const char *option = Tcl_GetString(objv[i]);
char c;
@@ -873,19 +874,19 @@ TextWidgetObjCmd(
goto badOption;
}
c = option[1];
- if (c == 'c' && !strncmp("-chars", option, (unsigned) length)) {
+ if (c == 'c' && !strncmp("-chars", option, length)) {
value = CountIndices(textPtr, indexFromPtr, indexToPtr,
COUNT_CHARS);
} else if (c == 'd' && (length > 8)
- && !strncmp("-displaychars", option, (unsigned) length)) {
+ && !strncmp("-displaychars", option, length)) {
value = CountIndices(textPtr, indexFromPtr, indexToPtr,
COUNT_DISPLAY_CHARS);
} else if (c == 'd' && (length > 8)
- && !strncmp("-displayindices", option,(unsigned)length)) {
+ && !strncmp("-displayindices", option,length)) {
value = CountIndices(textPtr, indexFromPtr, indexToPtr,
COUNT_DISPLAY_INDICES);
} else if (c == 'd' && (length > 8)
- && !strncmp("-displaylines", option, (unsigned) length)) {
+ && !strncmp("-displaylines", option, length)) {
TkTextLine *fromPtr, *lastPtr;
TkTextIndex index, index2;
@@ -983,19 +984,19 @@ TextWidgetObjCmd(
value = -value;
}
} else if (c == 'i'
- && !strncmp("-indices", option, (unsigned) length)) {
+ && !strncmp("-indices", option, length)) {
value = CountIndices(textPtr, indexFromPtr, indexToPtr,
COUNT_INDICES);
} else if (c == 'l'
- && !strncmp("-lines", option, (unsigned) length)) {
+ && !strncmp("-lines", option, length)) {
value = TkBTreeLinesTo(textPtr, indexToPtr->linePtr)
- TkBTreeLinesTo(textPtr, indexFromPtr->linePtr);
} else if (c == 'u'
- && !strncmp("-update", option, (unsigned) length)) {
+ && !strncmp("-update", option, length)) {
update = 1;
continue;
} else if (c == 'x'
- && !strncmp("-xpixels", option, (unsigned) length)) {
+ && !strncmp("-xpixels", option, length)) {
int x1, x2;
TkTextIndex index;
@@ -1005,7 +1006,7 @@ TextWidgetObjCmd(
TkTextFindDisplayLineEnd(textPtr, &index, 0, &x2);
value = x2 - x1;
} else if (c == 'y'
- && !strncmp("-ypixels", option, (unsigned) length)) {
+ && !strncmp("-ypixels", option, length)) {
if (update) {
TkTextUpdateLineMetrics(textPtr,
TkBTreeLinesTo(textPtr, indexFromPtr->linePtr),
@@ -1155,14 +1156,14 @@ TextWidgetObjCmd(
objc++;
}
useIdx = ckalloc(objc);
- memset(useIdx, 0, (unsigned) objc);
+ memset(useIdx, 0, (size_t) objc);
/*
* Do a decreasing order sort so that we delete the end ranges
* first to maintain index consistency.
*/
- qsort(indices, (unsigned) objc / 2,
+ qsort(indices, (size_t) objc / 2,
2 * sizeof(TkTextIndex), TextIndexSortProc);
lastStart = NULL;
@@ -1260,7 +1261,7 @@ TextWidgetObjCmd(
Tcl_Obj *objPtr = NULL;
int i, found = 0, visible = 0;
const char *name;
- int length;
+ size_t length;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -1279,7 +1280,7 @@ TextWidgetObjCmd(
name = Tcl_GetString(objv[i]);
length = objv[i]->length;
if (length > 1 && name[0] == '-') {
- if (strncmp("-displaychars", name, (unsigned) length) == 0) {
+ if (strncmp("-displaychars", name, length) == 0) {
i++;
visible = 1;
name = Tcl_GetString(objv[i]);
@@ -2633,7 +2634,8 @@ InsertChars(
* information to add to text. */
int viewUpdate) /* Update the view if set. */
{
- int lineIndex, length;
+ int lineIndex;
+ size_t length;
TkText *tPtr;
int *lineAndByteIndex;
int resetViewCount;
@@ -4231,7 +4233,7 @@ TextSearchAddNextLine(
if (lenPtr != NULL) {
if (searchSpecPtr->exact) {
- (void)Tcl_GetString(theLine);
+ Tcl_GetString(theLine);
*lenPtr = theLine->length;
} else {
*lenPtr = Tcl_GetCharLength(theLine);
@@ -4756,7 +4758,7 @@ TextDumpCmd(
if (objc == arg) {
TkTextIndexForwChars(NULL, &index1, 1, &index2, COUNT_INDICES);
} else {
- int length;
+ size_t length;
const char *str;
if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) {
@@ -4764,7 +4766,7 @@ TextDumpCmd(
}
str = Tcl_GetString(objv[arg]);
length = objv[arg]->length;
- if (strncmp(str, "end", (unsigned) length) == 0) {
+ if (strncmp(str, "end", length) == 0) {
atEnd = 1;
}
}
@@ -6006,7 +6008,7 @@ SearchCore(
}
while (p >= startOfLine + firstOffset) {
if (p[0] == c && !strncmp(p, pattern,
- (unsigned) matchLength)) {
+ (size_t) matchLength)) {
goto backwardsMatch;
}
p--;
@@ -6101,7 +6103,7 @@ SearchCore(
* result.
*/
- if (strncmp(p,pattern,(unsigned)matchLength)) {
+ if (strncmp(p,pattern,(size_t)matchLength)) {
p = NULL;
}
break;
@@ -6908,10 +6910,9 @@ ObjectIsEmpty(
if (objPtr == NULL) {
return 1;
}
- if (objPtr->bytes != NULL) {
- return (objPtr->length == 0);
+ if (objPtr->bytes == NULL) {
+ Tcl_GetString(objPtr);
}
- (void)Tcl_GetString(objPtr);
return (objPtr->length == 0);
}