diff options
| -rw-r--r-- | .travis.yml | 81 | ||||
| -rw-r--r-- | doc/binary.n | 22 | ||||
| -rw-r--r-- | generic/tclBinary.c | 35 | ||||
| -rw-r--r-- | generic/tclStubInit.c | 2 | ||||
| -rw-r--r-- | tests/binary.test | 12 |
5 files changed, 120 insertions, 32 deletions
diff --git a/.travis.yml b/.travis.yml index b17db27..1f7b2d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,15 @@ sudo: false language: c - +addons: + apt: + packages: + - binutils-mingw-w64-i686 + - binutils-mingw-w64-x86-64 + - gcc-mingw-w64 + - gcc-mingw-w64-base + - gcc-mingw-w64-i686 + - gcc-mingw-w64-x86-64 + - gcc-multilib matrix: include: # Testing on Linux with various compilers @@ -38,6 +47,13 @@ matrix: env: - BUILD_DIR=unix - CFGOPT="--enable-symbols" + - name: "Linux/GCC/Mem-Debug" + os: linux + dist: bionic + compiler: gcc + env: + - BUILD_DIR=unix + - CFGOPT="--enable-symbols=mem" # Older versions of GCC... - name: "Linux/GCC 7/Shared" os: linux @@ -96,6 +112,13 @@ matrix: env: - BUILD_DIR=unix - CFGOPT="--enable-symbols" + - name: "Linux/Clang/Mem-Debug" + os: linux + dist: bionic + compiler: clang + env: + - BUILD_DIR=unix + - CFGOPT="--enable-symbols=mem" # Testing on Mac, various styles - name: "macOS/Xcode 11.3/Shared/Unix-like" os: osx @@ -146,13 +169,6 @@ matrix: os: linux dist: bionic compiler: x86_64-w64-mingw32-gcc - addons: - apt: - packages: - - gcc-mingw-w64-base - - binutils-mingw-w64-x86-64 - - gcc-mingw-w64-x86-64 - - gcc-mingw-w64 env: - BUILD_DIR=win - CFGOPT="--host=x86_64-w64-mingw32 --enable-64bit" @@ -167,14 +183,6 @@ matrix: os: linux dist: bionic compiler: i686-w64-mingw32-gcc - addons: - apt: - packages: - - gcc-mingw-w64-base - - binutils-mingw-w64-i686 - - gcc-mingw-w64-i686 - - gcc-mingw-w64 - - gcc-multilib env: - BUILD_DIR=win - CFGOPT=--host=i686-w64-mingw32 @@ -220,6 +228,15 @@ matrix: script: - cmd.exe //C vcvarsall.bat x64 '&&' nmake 'OPTS=symbols' '-f' makefile.vc all tcltest - cmd.exe //C vcvarsall.bat x64 '&&' nmake 'OPTS=symbols' '-f' makefile.vc test + - name: "Windows/MSVC/Mem-Debug" + os: windows + compiler: cl + env: *vcenv + before_install: *vcpreinst + install: [] + script: + - cmd.exe //C vcvarsall.bat x64 '&&' nmake 'STATS=memdbg' '-f' makefile.vc all tcltest + - cmd.exe //C vcvarsall.bat x64 '&&' nmake 'STATS=memdbg' '-f' makefile.vc test # Test on Windows with MSVC native (32-bit) - name: "Windows/MSVC-x86/Shared" os: windows @@ -257,6 +274,15 @@ matrix: script: - cmd.exe //C vcvarsall.bat x86 '&&' nmake 'OPTS=symbols' '-f' makefile.vc all tcltest - cmd.exe //C vcvarsall.bat x86 '&&' nmake 'OPTS=symbols' '-f' makefile.vc test + - name: "Windows/MSVC-x86/Mem-Debug" + os: windows + compiler: cl + env: *vcenv + before_install: *vcpreinst + install: [] + script: + - cmd.exe //C vcvarsall.bat x86 '&&' nmake 'STATS=memdbg' '-f' makefile.vc all tcltest + - cmd.exe //C vcvarsall.bat x86 '&&' nmake 'STATS=memdbg' '-f' makefile.vc test # Test on Windows with GCC native - name: "Windows/GCC/Shared" os: windows @@ -265,7 +291,7 @@ matrix: - BUILD_DIR=win - CFGOPT="--enable-64bit" before_install: &makepreinst - - choco install make + - choco install -y make - cd ${BUILD_DIR} - name: "Windows/GCC/Shared: UTF_MAX=4" os: windows @@ -288,6 +314,13 @@ matrix: - BUILD_DIR=win - CFGOPT="--enable-64bit --enable-symbols" before_install: *makepreinst + - name: "Windows/GCC/Mem-Debug" + os: windows + compiler: gcc + env: + - BUILD_DIR=win + - CFGOPT="--enable-64bit --enable-symbols=mem" + before_install: *makepreinst # Test on Windows with GCC native (32-bit) - name: "Windows/GCC-x86/Shared" os: windows @@ -316,7 +349,21 @@ matrix: - BUILD_DIR=win - CFGOPT="--enable-symbols" before_install: *makepreinst + - name: "Windows/GCC-x86/Mem-Debug" + os: windows + compiler: gcc + env: + - BUILD_DIR=win + - CFGOPT="--enable-symbols=mem" + before_install: *makepreinst before_install: + - |- + case $TRAVIS_OS_NAME in + osx) + brew update + brew install libtommath + ;; + esac - cd ${BUILD_DIR} install: - ./configure ${CFGOPT} --prefix=$HOME || (cat config.log && exit 1) diff --git a/doc/binary.n b/doc/binary.n index 1f93c03..92a939a 100644 --- a/doc/binary.n +++ b/doc/binary.n @@ -110,23 +110,27 @@ produce files that other implementations of decoders cannot process): .TP \fB\-maxlen \fIlength\fR . -Indicates that the output should be split into lines of no more than -\fIlength\fR characters. By default, lines are split every 61 characters, and -this must be in the range 3 to 85 due to limitations in the encoding. +Indicates the maximum number of characters to produce for each encoded line. +The valid range is 5 to 85. Line lengths outside that range cannot be +accommodated by the encoding format. The default value is 61. .TP \fB\-wrapchar \fIcharacter\fR . -Indicates that, when lines are split because of the \fB\-maxlen\fR option, -\fIcharacter\fR should be used to separate lines. By default, this is a -newline character, -.QW \en . +Indicates the character(s) to use to mark the end of each encoded line. +Acceptable values are a sequence of zero or more characters from the +set { \\x09 (TAB), \\x0B (VT), \\x0C (FF), \\x0D (CR) } followed +by zero or one newline \\x0A (LF). Any other values are rejected because +they would generate encoded text that could not be decoded. The default value +is a single newline. .PP During decoding, the following options are supported: .TP \fB\-strict\fR . -Instructs the decoder to throw an error if it encounters unexpected -whitespace characters. Otherwise it ignores them. +Instructs the decoder to throw an error if it encounters anything +outside of the standard encoding format. Without this option, the +decoder tolerates some deviations, mostly to forgive reflows of lines +between the encoder and decoder. .PP Note that neither the encoder nor the decoder handle the header and footer of the uuencode format. diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 3575bce..6306159 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2639,16 +2639,47 @@ BinaryEncodeUu( &lineLength) != TCL_OK) { return TCL_ERROR; } - if (lineLength < 3 || lineLength > 85) { + if (lineLength < 5 || lineLength > 85) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "line length out of range", -1)); Tcl_SetErrorCode(interp, "TCL", "BINARY", "ENCODE", "LINE_LENGTH", NULL); return TCL_ERROR; } + lineLength = ((lineLength - 1) & -4) + 1; /* 5, 9, 13 ... */ break; case OPT_WRAPCHAR: - wrapchar = Tcl_GetByteArrayFromObj(objv[i + 1], &wrapcharlen); + wrapchar = (const unsigned char *) TclGetStringFromObj( + objv[i + 1], &wrapcharlen); + { + const unsigned char *p = wrapchar; + int numBytes = wrapcharlen; + + while (numBytes) { + switch (*p) { + case '\t': + case '\v': + case '\f': + case '\r': + p++; numBytes--; + continue; + case '\n': + numBytes--; + break; + default: + badwrap: + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "invalid wrapchar; will defeat decoding", + -1)); + Tcl_SetErrorCode(interp, "TCL", "BINARY", + "ENCODE", "WRAPCHAR", NULL); + return TCL_ERROR; + } + } + if (numBytes) { + goto badwrap; + } + } break; } } diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index aae51dd..5c901e7 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -151,7 +151,7 @@ static unsigned short TclWinNToHS(unsigned short ns) { #define TclMacOSXSetFileAttribute (int (*)(Tcl_Interp *, int, Tcl_Obj *, Tcl_Obj *))(void *)isatty #define TclMacOSXCopyFileAttributes (int (*)(const char *, const char *, const Tcl_StatBuf *))(void *)TclUnixCopyFile #define TclMacOSXMatchType (int (*)(Tcl_Interp *, const char *, const char *, Tcl_StatBuf *, Tcl_GlobTypeData *))(void *)TclpMakeFile -#define TclMacOSXNotifierAddRunLoopMode (void (*)(const void *))TclpOpenFile +#define TclMacOSXNotifierAddRunLoopMode (void (*)(const void *))(void *)TclpOpenFile #endif #ifdef _WIN32 diff --git a/tests/binary.test b/tests/binary.test index 399a07c..c2c5eb4 100644 --- a/tests/binary.test +++ b/tests/binary.test @@ -2794,11 +2794,17 @@ test binary-74.10 {binary encode uuencode} -returnCodes error -body { binary encode uuencode -foo 30 abcabcabc } -result {bad option "-foo": must be -maxlen or -wrapchar} test binary-74.11 {binary encode uuencode} -returnCodes error -body { - binary encode uuencode -maxlen 1 abcabcabc + binary encode uuencode -maxlen 4 abcabcabc } -result {line length out of range} test binary-74.12 {binary encode uuencode} -body { - binary encode uuencode -maxlen 3 -wrapchar | abcabcabc -} -result {!80|!8@|!8P|!80|!8@|!8P|!80|!8@|!8P|} + binary encode uuencode -maxlen 5 -wrapchar \t abcabcabc +} -result #86)C\t#86)C\t#86)C\t +test binary-74.13 {binary encode uuencode} -body { + binary encode uuencode -maxlen 85 -wrapchar \t abcabcabc +} -result )86)C86)C86)C\t +test binary-74.14 {binary encode uuencode} -returnCodes error -body { + binary encode uuencode -maxlen 86 abcabcabc +} -result {line length out of range} test binary-75.1 {binary decode uuencode} -body { binary decode uuencode |
