summaryrefslogtreecommitdiffstats
path: root/generic/tclBinary.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-06-08 10:23:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-06-08 10:23:13 (GMT)
commit8ef685ede6f3371073dfb6f84eff77b62398787c (patch)
treefd4894d3b57bc034901dff8f04b0b9b465057ce1 /generic/tclBinary.c
parentaa312430e34a7bd58cddb79b7dd6840e86ced518 (diff)
parentbdccbf1c921b2158d107e97cc64b72ab81a05ee5 (diff)
downloadtcl-8ef685ede6f3371073dfb6f84eff77b62398787c.zip
tcl-8ef685ede6f3371073dfb6f84eff77b62398787c.tar.gz
tcl-8ef685ede6f3371073dfb6f84eff77b62398787c.tar.bz2
TIP #616: Tcl lists > 2^31 elements
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r--generic/tclBinary.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 36f4482..a45e4b2 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -909,7 +909,7 @@ BinaryFormatCmd(
* cursor has visited.*/
const char *errorString;
const char *errorValue, *str;
- int offset, size;
+ size_t offset, size;
size_t length;
if (objc < 2) {
@@ -1008,7 +1008,7 @@ BinaryFormatCmd(
arg++;
count = 1;
} else {
- int listc;
+ size_t listc;
Tcl_Obj **listv;
/*
@@ -1023,7 +1023,7 @@ BinaryFormatCmd(
if (count == BINARY_ALL) {
count = listc;
- } else if (count > (size_t)listc) {
+ } else if (count > listc) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"number of elements in list does not match count",
-1));
@@ -1047,16 +1047,16 @@ BinaryFormatCmd(
if (count == BINARY_NOCOUNT) {
count = 1;
}
- if ((count > (size_t)offset) || (count == BINARY_ALL)) {
+ if ((count > offset) || (count == BINARY_ALL)) {
count = offset;
}
- if (offset > (int)length) {
+ if (offset > length) {
length = offset;
}
offset -= count;
break;
case '@':
- if (offset > (int)length) {
+ if (offset > length) {
length = offset;
}
if (count == BINARY_ALL) {
@@ -1072,7 +1072,7 @@ BinaryFormatCmd(
goto badField;
}
}
- if (offset > (int)length) {
+ if (offset > length) {
length = offset;
}
if (length == 0) {
@@ -1151,7 +1151,7 @@ BinaryFormatCmd(
value = 0;
errorString = "binary";
if (cmd == 'B') {
- for (offset = 0; (size_t)offset < count; offset++) {
+ for (offset = 0; offset < count; offset++) {
value <<= 1;
if (str[offset] == '1') {
value |= 1;
@@ -1166,7 +1166,7 @@ BinaryFormatCmd(
}
}
} else {
- for (offset = 0; (size_t)offset < count; offset++) {
+ for (offset = 0; offset < count; offset++) {
value >>= 1;
if (str[offset] == '1') {
value |= 128;
@@ -1213,7 +1213,7 @@ BinaryFormatCmd(
value = 0;
errorString = "hexadecimal";
if (cmd == 'H') {
- for (offset = 0; (size_t)offset < count; offset++) {
+ for (offset = 0; offset < count; offset++) {
value <<= 4;
if (!isxdigit(UCHAR(str[offset]))) { /* INTL: digit */
errorValue = str;
@@ -1234,7 +1234,7 @@ BinaryFormatCmd(
}
}
} else {
- for (offset = 0; (size_t)offset < count; offset++) {
+ for (offset = 0; offset < count; offset++) {
value >>= 4;
if (!isxdigit(UCHAR(str[offset]))) { /* INTL: digit */
@@ -1286,7 +1286,7 @@ BinaryFormatCmd(
case 'q':
case 'Q':
case 'f': {
- int listc, i;
+ size_t listc, i;
Tcl_Obj **listv;
if (count == BINARY_NOCOUNT) {
@@ -1305,7 +1305,7 @@ BinaryFormatCmd(
}
}
arg++;
- for (i = 0; (size_t)i < count; i++) {
+ for (i = 0; i < count; i++) {
if (FormatNumber(interp, cmd, listv[i], &cursor) != TCL_OK) {
Tcl_DecrRefCount(resultPtr);
return TCL_ERROR;
@@ -1416,7 +1416,7 @@ BinaryScanCmd(
unsigned char *buffer; /* Start of result buffer. */
const char *errorString;
const char *str;
- int offset, size, i;
+ size_t offset, size, i;
size_t length = 0;
Tcl_Obj *valuePtr, *elementPtr;
@@ -1536,7 +1536,7 @@ BinaryScanCmd(
dest = TclGetString(valuePtr);
if (cmd == 'b') {
- for (i = 0; (size_t)i < count; i++) {
+ for (i = 0; i < count; i++) {
if (i % 8) {
value >>= 1;
} else {
@@ -1545,7 +1545,7 @@ BinaryScanCmd(
*dest++ = (char) ((value & 1) ? '1' : '0');
}
} else {
- for (i = 0; (size_t)i < count; i++) {
+ for (i = 0; i < count; i++) {
if (i % 8) {
value <<= 1;
} else {
@@ -1591,7 +1591,7 @@ BinaryScanCmd(
dest = TclGetString(valuePtr);
if (cmd == 'h') {
- for (i = 0; (size_t)i < count; i++) {
+ for (i = 0; i < count; i++) {
if (i % 2) {
value >>= 4;
} else {
@@ -1600,7 +1600,7 @@ BinaryScanCmd(
*dest++ = hexdigit[value & 0xF];
}
} else {
- for (i = 0; (size_t)i < count; i++) {
+ for (i = 0; i < count; i++) {
if (i % 2) {
value <<= 4;
} else {
@@ -1657,7 +1657,7 @@ BinaryScanCmd(
goto badIndex;
}
if (count == BINARY_NOCOUNT) {
- if ((length - offset) < (size_t)size) {
+ if (length < (size_t)size + offset) {
goto done;
}
valuePtr = ScanNumber(buffer+offset, cmd, flags,
@@ -1672,7 +1672,7 @@ BinaryScanCmd(
}
TclNewObj(valuePtr);
src = buffer + offset;
- for (i = 0; (size_t)i < count; i++) {
+ for (i = 0; i < count; i++) {
elementPtr = ScanNumber(src, cmd, flags, &numberCachePtr);
src += size;
Tcl_ListObjAppendElement(NULL, valuePtr, elementPtr);
@@ -1703,7 +1703,7 @@ BinaryScanCmd(
if (count == BINARY_NOCOUNT) {
count = 1;
}
- if ((count == BINARY_ALL) || (count > (size_t)offset)) {
+ if ((count == BINARY_ALL) || (count > offset)) {
offset = 0;
} else {
offset -= count;