summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2013-09-16 08:52:12 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2013-09-16 08:52:12 (GMT)
commit826a355cc84e880287a692ccc1c3c48c915f5f4a (patch)
tree683bb526841b0cbb1256673632f87d08d29daffa /generic
parentd005d657b483f1d31c4acf3b7d0aafac8e0b288a (diff)
downloadtcl-826a355cc84e880287a692ccc1c3c48c915f5f4a.zip
tcl-826a355cc84e880287a692ccc1c3c48c915f5f4a.tar.gz
tcl-826a355cc84e880287a692ccc1c3c48c915f5f4a.tar.bz2
Be careful: separator needs to be bytes, not internal-encoded.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclBinary.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 2053319..114984f 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -2586,13 +2586,15 @@ BinaryEncodeUu(
unsigned char *data, *start, *cursor;
int offset, count, rawLength, n, i, j, bits, index;
int lineLength = 61;
- const char *wrapchar = "\n";
- int wrapcharlen = 1;
- enum {OPT_MAXLEN, OPT_WRAPCHAR };
+ const unsigned char SingleNewline[] = { (unsigned char) '\n' };
+ const unsigned char *wrapchar = SingleNewline;
+ int wrapcharlen = sizeof(SingleNewline);
+ enum { OPT_MAXLEN, OPT_WRAPCHAR };
static const char *const optStrings[] = { "-maxlen", "-wrapchar", NULL };
if (objc < 2 || objc%2 != 0) {
- Tcl_WrongNumArgs(interp, 1, objv, "?-maxlen len? ?-wrapchar char? data");
+ Tcl_WrongNumArgs(interp, 1, objv,
+ "?-maxlen len? ?-wrapchar char? data");
return TCL_ERROR;
}
for (i = 1; i < objc-1; i += 2) {
@@ -2613,7 +2615,7 @@ BinaryEncodeUu(
}
break;
case OPT_WRAPCHAR:
- wrapchar = Tcl_GetStringFromObj(objv[i+1], &wrapcharlen);
+ wrapchar = Tcl_GetByteArrayFromObj(objv[i+1], &wrapcharlen);
break;
}
}
@@ -2628,7 +2630,8 @@ BinaryEncodeUu(
data = Tcl_GetByteArrayFromObj(objv[objc-1], &count);
rawLength = (lineLength - 1) * 3 / 4;
start = cursor = Tcl_SetByteArrayLength(resultObj,
- (lineLength + wrapcharlen) * ((count + (rawLength - 1)) / rawLength));
+ (lineLength + wrapcharlen) *
+ ((count + (rawLength - 1)) / rawLength));
n = bits = 0;
/*
@@ -2657,7 +2660,7 @@ BinaryEncodeUu(
*cursor++ = UueDigits[(n >> (bits + 2)) & 0x3f];
bits = 0;
}
- for (j=0; j<wrapcharlen; ++j) {
+ for (j=0 ; j<wrapcharlen ; ++j) {
*cursor++ = wrapchar[j];
}
}