summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-09-15 16:30:01 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-09-15 16:30:01 (GMT)
commitd005d657b483f1d31c4acf3b7d0aafac8e0b288a (patch)
tree360685fd1b62a3725597d9104b1a1eabd7d2fa8e /generic
parent0f1f636a50239c2409172a34da5fa1b1f45bf9c4 (diff)
parentdc8a74cb4dd9032147ee2106fb16a738e394bc1f (diff)
downloadtcl-d005d657b483f1d31c4acf3b7d0aafac8e0b288a.zip
tcl-d005d657b483f1d31c4acf3b7d0aafac8e0b288a.tar.gz
tcl-d005d657b483f1d31c4acf3b7d0aafac8e0b288a.tar.bz2
Add back -wrapchar option to "binary encode uuencode"
Diffstat (limited to 'generic')
-rw-r--r--generic/tclBinary.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index c0dd926..2053319 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -2584,13 +2584,15 @@ BinaryEncodeUu(
{
Tcl_Obj *resultObj;
unsigned char *data, *start, *cursor;
- int offset, count, rawLength, n, i, bits, index;
+ int offset, count, rawLength, n, i, j, bits, index;
int lineLength = 61;
- enum {OPT_MAXLEN};
- static const char *const optStrings[] = { "-maxlen", NULL };
+ const char *wrapchar = "\n";
+ int wrapcharlen = 1;
+ 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? data");
+ Tcl_WrongNumArgs(interp, 1, objv, "?-maxlen len? ?-wrapchar char? data");
return TCL_ERROR;
}
for (i = 1; i < objc-1; i += 2) {
@@ -2610,6 +2612,9 @@ BinaryEncodeUu(
return TCL_ERROR;
}
break;
+ case OPT_WRAPCHAR:
+ wrapchar = Tcl_GetStringFromObj(objv[i+1], &wrapcharlen);
+ break;
}
}
@@ -2623,7 +2628,7 @@ BinaryEncodeUu(
data = Tcl_GetByteArrayFromObj(objv[objc-1], &count);
rawLength = (lineLength - 1) * 3 / 4;
start = cursor = Tcl_SetByteArrayLength(resultObj,
- (lineLength + 1) * ((count + (rawLength - 1)) / rawLength));
+ (lineLength + wrapcharlen) * ((count + (rawLength - 1)) / rawLength));
n = bits = 0;
/*
@@ -2652,7 +2657,9 @@ BinaryEncodeUu(
*cursor++ = UueDigits[(n >> (bits + 2)) & 0x3f];
bits = 0;
}
- *cursor++ = '\n';
+ for (j=0; j<wrapcharlen; ++j) {
+ *cursor++ = wrapchar[j];
+ }
}
/*