summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-02-13 22:24:07 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-02-13 22:24:07 (GMT)
commit3929a73ee0fd5945e8f186f495229f3dc98877de (patch)
tree9580f689ca4e85163b41575852834d678e84824c
parent55704171415295ccf24dc89ec02755b78f05830a (diff)
parent30c32418f67d6455d36bfeb1b8b4539ca5f23771 (diff)
downloadtcl-3929a73ee0fd5945e8f186f495229f3dc98877de.zip
tcl-3929a73ee0fd5945e8f186f495229f3dc98877de.tar.gz
tcl-3929a73ee0fd5945e8f186f495229f3dc98877de.tar.bz2
Merge trunk
-rw-r--r--.travis.yml77
-rw-r--r--doc/SetResult.312
-rw-r--r--generic/tcl.decls19
-rw-r--r--generic/tcl.h11
-rw-r--r--generic/tclDecls.h32
-rw-r--r--generic/tclIO.c100
-rw-r--r--generic/tclIOCmd.c2
-rw-r--r--generic/tclIORTrans.c38
-rw-r--r--generic/tclInt.h8
-rw-r--r--generic/tclLink.c2
-rw-r--r--generic/tclObj.c22
-rw-r--r--generic/tclResult.c30
-rw-r--r--generic/tclStrToD.c12
-rw-r--r--generic/tclStubInit.c2
-rw-r--r--generic/tclZipfs.c36
-rw-r--r--generic/tclZlib.c2
-rw-r--r--library/tcltest/tcltest.tcl2
-rw-r--r--tests/cmdIL.test47
-rw-r--r--tests/internals.tcl96
-rwxr-xr-xunix/configure3
-rw-r--r--unix/tcl.m425
-rw-r--r--unix/tclUnixSock.c30
-rw-r--r--win/Makefile.in2
-rw-r--r--win/rules.vc5
-rw-r--r--win/tclWinSock.c30
25 files changed, 295 insertions, 350 deletions
diff --git a/.travis.yml b/.travis.yml
index 334ab6c..07aaf2a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,34 +6,34 @@ matrix:
# Testing on Linux with various compilers
- name: "Linux/GCC/Shared"
os: linux
- dist: xenial
+ dist: bionic
compiler: gcc
env:
- BUILD_DIR=unix
- name: "Linux/GCC/Shared: UTF_MAX=3"
os: linux
- dist: xenial
+ dist: bionic
compiler: gcc
env:
- BUILD_DIR=unix
- CFGOPT="CFLAGS=-DTCL_UTF_MAX=3"
- name: "Linux/GCC/Shared: NO_DEPRECATED"
os: linux
- dist: xenial
+ dist: bionic
compiler: gcc
env:
- BUILD_DIR=unix
- CFGOPT="CFLAGS=-DTCL_NO_DEPRECATED=1"
- name: "Linux/GCC/Static"
os: linux
- dist: xenial
+ dist: bionic
compiler: gcc
env:
- CFGOPT="--disable-shared"
- BUILD_DIR=unix
- name: "Linux/GCC/Debug"
os: linux
- dist: xenial
+ dist: bionic
compiler: gcc
env:
- BUILD_DIR=unix
@@ -41,7 +41,7 @@ matrix:
# Older versions of GCC...
- name: "Linux/GCC 7/Shared"
os: linux
- dist: xenial
+ dist: bionic
compiler: gcc-7
addons:
apt:
@@ -53,7 +53,7 @@ matrix:
- BUILD_DIR=unix
- name: "Linux/GCC 6/Shared"
os: linux
- dist: xenial
+ dist: bionic
compiler: gcc-6
addons:
apt:
@@ -65,7 +65,7 @@ matrix:
- BUILD_DIR=unix
- name: "Linux/GCC 5/Shared"
os: linux
- dist: xenial
+ dist: bionic
compiler: gcc-5
addons:
apt:
@@ -75,35 +75,23 @@ matrix:
- g++-5
env:
- BUILD_DIR=unix
- - name: "Linux/GCC 4.9/Shared"
- os: linux
- dist: xenial
- compiler: gcc-4.9
- addons:
- apt:
- sources:
- - ubuntu-toolchain-r-test
- packages:
- - g++-4.9
- env:
- - BUILD_DIR=unix
# Clang
- name: "Linux/Clang/Shared"
os: linux
- dist: xenial
+ dist: bionic
compiler: clang
env:
- BUILD_DIR=unix
- name: "Linux/Clang/Static"
os: linux
- dist: xenial
+ dist: bionic
compiler: clang
env:
- CFGOPT="--disable-shared"
- BUILD_DIR=unix
- name: "Linux/Clang/Debug"
os: linux
- dist: xenial
+ dist: bionic
compiler: clang
env:
- BUILD_DIR=unix
@@ -128,6 +116,13 @@ matrix:
homebrew:
packages:
- libtommath
+ - name: "macOS/Xcode 11/Shared"
+ os: osx
+ osx_image: xcode11
+ env:
+ - BUILD_DIR=macosx
+ install: []
+ script: *mactest
- name: "macOS/Xcode 10/Shared"
os: osx
osx_image: xcode10.3
@@ -165,7 +160,7 @@ matrix:
# Doesn't run tests because wine is only an imperfect Windows emulation
- name: "Linux-cross-Windows/GCC/Shared/no test"
os: linux
- dist: xenial
+ dist: bionic
compiler: x86_64-w64-mingw32-gcc
addons:
apt:
@@ -186,7 +181,7 @@ matrix:
# Doesn't run tests because wine is only an imperfect Windows emulation
- name: "Linux-cross-Windows-32/GCC/Shared/no test"
os: linux
- dist: xenial
+ dist: bionic
compiler: i686-w64-mingw32-gcc
addons:
apt:
@@ -212,8 +207,8 @@ matrix:
- cd ${BUILD_DIR}
install: []
script:
- - cmd.exe /C 'vcvarsall.bat x64 && nmake -f makefile.vc all tcltest'
- - cmd.exe /C 'vcvarsall.bat x64 && nmake -f makefile.vc test'
+ - cmd.exe //C vcvarsall.bat x64 '&&' nmake '-f' makefile.vc all tcltest
+ - cmd.exe //C vcvarsall.bat x64 '&&' nmake '-f' makefile.vc test
- name: "Windows/MSVC/Shared: NO_DEPRECATED"
os: windows
compiler: cl
@@ -221,8 +216,8 @@ matrix:
before_install: *vcpreinst
install: []
script:
- - cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=nodep -f makefile.vc all tcltest'
- - cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=nodep -f makefile.vc test'
+ - cmd.exe //C vcvarsall.bat x64 '&&' nmake 'OPTS=nodep' '-f' makefile.vc all tcltest
+ - cmd.exe //C vcvarsall.bat x64 '&&' nmake 'OPTS=nodep' '-f' makefile.vc test
- name: "Windows/MSVC/Static"
os: windows
compiler: cl
@@ -230,8 +225,8 @@ matrix:
before_install: *vcpreinst
install: []
script:
- - cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=static,msvcrt -f makefile.vc all tcltest'
- - cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=static,msvcrt -f makefile.vc test'
+ - cmd.exe //C vcvarsall.bat x64 '&&' nmake 'OPTS=static,msvcrt' '-f' makefile.vc all tcltest
+ - cmd.exe //C vcvarsall.bat x64 '&&' nmake 'OPTS=static,msvcrt' '-f' makefile.vc test
- name: "Windows/MSVC/Debug"
os: windows
compiler: cl
@@ -239,8 +234,8 @@ matrix:
before_install: *vcpreinst
install: []
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'
+ - 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
# Test on Windows with MSVC native (32-bit)
- name: "Windows/MSVC-x86/Shared"
os: windows
@@ -249,8 +244,8 @@ matrix:
before_install: *vcpreinst
install: []
script:
- - cmd.exe /C 'vcvarsall.bat x86 && nmake -f makefile.vc all tcltest'
- - cmd.exe /C 'vcvarsall.bat x86 && nmake -f makefile.vc test'
+ - cmd.exe //C vcvarsall.bat x86 '&&' nmake '-f' makefile.vc all tcltest
+ - cmd.exe //C vcvarsall.bat x86 '&&' nmake '-f' makefile.vc test
- name: "Windows/MSVC-x86/Shared: NO_DEPRECATED"
os: windows
compiler: cl
@@ -258,8 +253,8 @@ matrix:
before_install: *vcpreinst
install: []
script:
- - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=nodep -f makefile.vc all tcltest'
- - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=nodep -f makefile.vc test'
+ - cmd.exe //C vcvarsall.bat x86 '&&' nmake 'OPTS=nodep' '-f' makefile.vc all tcltest
+ - cmd.exe //C vcvarsall.bat x86 '&&' nmake 'OPTS=nodep' '-f' makefile.vc test
- name: "Windows/MSVC-x86/Static"
os: windows
compiler: cl
@@ -267,8 +262,8 @@ matrix:
before_install: *vcpreinst
install: []
script:
- - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=static,msvcrt -f makefile.vc all tcltest'
- - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=static,msvcrt -f makefile.vc test'
+ - cmd.exe //C vcvarsall.bat x86 '&&' nmake 'OPTS=static,msvcrt' '-f' makefile.vc all tcltest
+ - cmd.exe //C vcvarsall.bat x86 '&&' nmake 'OPTS=static,msvcrt' '-f' makefile.vc test
- name: "Windows/MSVC-x86/Debug"
os: windows
compiler: cl
@@ -276,8 +271,8 @@ matrix:
before_install: *vcpreinst
install: []
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'
+ - 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
# Test on Windows with GCC native
- name: "Windows/GCC/Shared"
os: windows
diff --git a/doc/SetResult.3 b/doc/SetResult.3
index 07e2344..1355d6b 100644
--- a/doc/SetResult.3
+++ b/doc/SetResult.3
@@ -9,7 +9,7 @@
.so man.macros
.BS
.SH NAME
-Tcl_SetObjResult, Tcl_GetObjResult, Tcl_SetResult, Tcl_GetStringResult, Tcl_AppendResult, Tcl_AppendElement, Tcl_ResetResult, Tcl_TransferResult, Tcl_FreeResult \- manipulate Tcl result
+Tcl_SetObjResult, Tcl_GetObjResult, Tcl_SetResult, Tcl_GetStringResult, Tcl_AppendResult, Tcl_AppendElement, Tcl_ResetResult, Tcl_TransferResult \- manipulate Tcl result
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -31,8 +31,6 @@ const char *
\fBTcl_TransferResult\fR(\fIsourceInterp, code, targetInterp\fR)
.sp
\fBTcl_AppendElement\fR(\fIinterp, element\fR)
-.sp
-\fBTcl_FreeResult\fR(\fIinterp\fR)
.SH ARGUMENTS
.AS Tcl_FreeProc sourceInterp out
.AP Tcl_Interp *interp out
@@ -177,14 +175,6 @@ single character
or ends in the characters
.QW " {" )
then no space is added.
-.PP
-\fBTcl_FreeResult\fR performs part of the work
-of \fBTcl_ResetResult\fR.
-It frees up the memory associated with \fIinterp\fR's result.
-It also sets \fIinterp->freeProc\fR to zero, but does not
-change \fIinterp->result\fR or clear error state.
-\fBTcl_FreeResult\fR is most commonly used when a procedure
-is about to replace one result value with another.
.SH "THE TCL_FREEPROC ARGUMENT TO TCL_SETRESULT"
.PP
\fBTcl_SetResult\fR's \fIfreeProc\fR argument specifies how
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 5b3688a..63995be 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -540,9 +540,10 @@ declare 145 {
declare 146 {
int Tcl_Flush(Tcl_Channel chan)
}
-declare 147 {
- void Tcl_FreeResult(Tcl_Interp *interp)
-}
+# Removed in 9.0, TIP 559
+#declare 147 {
+# void Tcl_FreeResult(Tcl_Interp *interp)
+#}
declare 148 {
int Tcl_GetAlias(Tcl_Interp *interp, const char *slaveCmd,
Tcl_Interp **targetInterpPtr, const char **targetCmdPtr,
@@ -2067,19 +2068,19 @@ declare 554 {
# TIP#237 (arbitrary-precision integers) kbk
declare 555 {
- Tcl_Obj *Tcl_NewBignumObj(mp_int *value)
+ Tcl_Obj *Tcl_NewBignumObj(void *value)
}
declare 556 {
- Tcl_Obj *Tcl_DbNewBignumObj(mp_int *value, const char *file, int line)
+ Tcl_Obj *Tcl_DbNewBignumObj(void *value, const char *file, int line)
}
declare 557 {
- void Tcl_SetBignumObj(Tcl_Obj *obj, mp_int *value)
+ void Tcl_SetBignumObj(Tcl_Obj *obj, void *value)
}
declare 558 {
- int Tcl_GetBignumFromObj(Tcl_Interp *interp, Tcl_Obj *obj, mp_int *value)
+ int Tcl_GetBignumFromObj(Tcl_Interp *interp, Tcl_Obj *obj, void *value)
}
declare 559 {
- int Tcl_TakeBignumFromObj(Tcl_Interp *interp, Tcl_Obj *obj, mp_int *value)
+ int Tcl_TakeBignumFromObj(Tcl_Interp *interp, Tcl_Obj *obj, void *value)
}
# TIP #208 ('chan' command) jeffh
@@ -2108,7 +2109,7 @@ declare 565 {
# TIP #237 (additional conversion functions for bignum support) kbk/dgp
declare 566 {
int Tcl_InitBignumFromDouble(Tcl_Interp *interp, double initval,
- mp_int *toInit)
+ void *toInit)
}
# TIP#181 (namespace unknown command) dgp for Neil Madden
diff --git a/generic/tcl.h b/generic/tcl.h
index c853e85..cb565bb 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -1993,9 +1993,16 @@ typedef struct Tcl_Config {
typedef void (Tcl_LimitHandlerProc) (void *clientData, Tcl_Interp *interp);
typedef void (Tcl_LimitHandlerDeleteProc) (void *clientData);
+#if 0
/*
*----------------------------------------------------------------------------
- * Override definitions for libtommath.
+ * We would like to provide an anonymous structure "mp_int" here, which is
+ * compatible with libtommath's "mp_int", but without duplicating anything
+ * from <tommath.h> or including <tommath.h> here. But the libtommath project
+ * didn't honor our request. See: <https://github.com/libtom/libtommath/pull/473>
+ *
+ * That's why this part is commented out, and we are using (void *) in
+ * various API's in stead of the more correct (mp_int *).
*/
#ifndef MP_INT_DECLARED
@@ -2003,6 +2010,8 @@ typedef void (Tcl_LimitHandlerDeleteProc) (void *clientData);
typedef struct mp_int mp_int;
#endif
+#endif
+
/*
*----------------------------------------------------------------------------
* Definitions needed for Tcl_ParseArgvObj routines.
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index bc2db64..bb8176f 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -434,8 +434,7 @@ EXTERN Tcl_HashEntry * Tcl_FirstHashEntry(Tcl_HashTable *tablePtr,
Tcl_HashSearch *searchPtr);
/* 146 */
EXTERN int Tcl_Flush(Tcl_Channel chan);
-/* 147 */
-EXTERN void Tcl_FreeResult(Tcl_Interp *interp);
+/* Slot 147 is reserved */
/* 148 */
EXTERN int Tcl_GetAlias(Tcl_Interp *interp,
const char *slaveCmd,
@@ -1491,18 +1490,18 @@ EXTERN void Tcl_QueryTimeProc(Tcl_GetTimeProc **getProc,
EXTERN Tcl_DriverThreadActionProc * Tcl_ChannelThreadActionProc(
const Tcl_ChannelType *chanTypePtr);
/* 555 */
-EXTERN Tcl_Obj * Tcl_NewBignumObj(mp_int *value);
+EXTERN Tcl_Obj * Tcl_NewBignumObj(void *value);
/* 556 */
-EXTERN Tcl_Obj * Tcl_DbNewBignumObj(mp_int *value, const char *file,
+EXTERN Tcl_Obj * Tcl_DbNewBignumObj(void *value, const char *file,
int line);
/* 557 */
-EXTERN void Tcl_SetBignumObj(Tcl_Obj *obj, mp_int *value);
+EXTERN void Tcl_SetBignumObj(Tcl_Obj *obj, void *value);
/* 558 */
EXTERN int Tcl_GetBignumFromObj(Tcl_Interp *interp,
- Tcl_Obj *obj, mp_int *value);
+ Tcl_Obj *obj, void *value);
/* 559 */
EXTERN int Tcl_TakeBignumFromObj(Tcl_Interp *interp,
- Tcl_Obj *obj, mp_int *value);
+ Tcl_Obj *obj, void *value);
/* 560 */
EXTERN int Tcl_TruncateChannel(Tcl_Channel chan,
Tcl_WideInt length);
@@ -1521,7 +1520,7 @@ EXTERN void Tcl_SetChannelError(Tcl_Channel chan, Tcl_Obj *msg);
EXTERN void Tcl_GetChannelError(Tcl_Channel chan, Tcl_Obj **msg);
/* 566 */
EXTERN int Tcl_InitBignumFromDouble(Tcl_Interp *interp,
- double initval, mp_int *toInit);
+ double initval, void *toInit);
/* 567 */
EXTERN Tcl_Obj * Tcl_GetNamespaceUnknownHandler(Tcl_Interp *interp,
Tcl_Namespace *nsPtr);
@@ -1932,7 +1931,7 @@ typedef struct TclStubs {
void (*reserved144)(void);
Tcl_HashEntry * (*tcl_FirstHashEntry) (Tcl_HashTable *tablePtr, Tcl_HashSearch *searchPtr); /* 145 */
int (*tcl_Flush) (Tcl_Channel chan); /* 146 */
- void (*tcl_FreeResult) (Tcl_Interp *interp); /* 147 */
+ void (*reserved147)(void);
int (*tcl_GetAlias) (Tcl_Interp *interp, const char *slaveCmd, Tcl_Interp **targetInterpPtr, const char **targetCmdPtr, int *argcPtr, const char ***argvPtr); /* 148 */
int (*tcl_GetAliasObj) (Tcl_Interp *interp, const char *slaveCmd, Tcl_Interp **targetInterpPtr, const char **targetCmdPtr, int *objcPtr, Tcl_Obj ***objv); /* 149 */
void * (*tcl_GetAssocData) (Tcl_Interp *interp, const char *name, Tcl_InterpDeleteProc **procPtr); /* 150 */
@@ -2348,18 +2347,18 @@ typedef struct TclStubs {
void (*tcl_SetTimeProc) (Tcl_GetTimeProc *getProc, Tcl_ScaleTimeProc *scaleProc, void *clientData); /* 552 */
void (*tcl_QueryTimeProc) (Tcl_GetTimeProc **getProc, Tcl_ScaleTimeProc **scaleProc, void **clientData); /* 553 */
Tcl_DriverThreadActionProc * (*tcl_ChannelThreadActionProc) (const Tcl_ChannelType *chanTypePtr); /* 554 */
- Tcl_Obj * (*tcl_NewBignumObj) (mp_int *value); /* 555 */
- Tcl_Obj * (*tcl_DbNewBignumObj) (mp_int *value, const char *file, int line); /* 556 */
- void (*tcl_SetBignumObj) (Tcl_Obj *obj, mp_int *value); /* 557 */
- int (*tcl_GetBignumFromObj) (Tcl_Interp *interp, Tcl_Obj *obj, mp_int *value); /* 558 */
- int (*tcl_TakeBignumFromObj) (Tcl_Interp *interp, Tcl_Obj *obj, mp_int *value); /* 559 */
+ Tcl_Obj * (*tcl_NewBignumObj) (void *value); /* 555 */
+ Tcl_Obj * (*tcl_DbNewBignumObj) (void *value, const char *file, int line); /* 556 */
+ void (*tcl_SetBignumObj) (Tcl_Obj *obj, void *value); /* 557 */
+ int (*tcl_GetBignumFromObj) (Tcl_Interp *interp, Tcl_Obj *obj, void *value); /* 558 */
+ int (*tcl_TakeBignumFromObj) (Tcl_Interp *interp, Tcl_Obj *obj, void *value); /* 559 */
int (*tcl_TruncateChannel) (Tcl_Channel chan, Tcl_WideInt length); /* 560 */
Tcl_DriverTruncateProc * (*tcl_ChannelTruncateProc) (const Tcl_ChannelType *chanTypePtr); /* 561 */
void (*tcl_SetChannelErrorInterp) (Tcl_Interp *interp, Tcl_Obj *msg); /* 562 */
void (*tcl_GetChannelErrorInterp) (Tcl_Interp *interp, Tcl_Obj **msg); /* 563 */
void (*tcl_SetChannelError) (Tcl_Channel chan, Tcl_Obj *msg); /* 564 */
void (*tcl_GetChannelError) (Tcl_Channel chan, Tcl_Obj **msg); /* 565 */
- int (*tcl_InitBignumFromDouble) (Tcl_Interp *interp, double initval, mp_int *toInit); /* 566 */
+ int (*tcl_InitBignumFromDouble) (Tcl_Interp *interp, double initval, void *toInit); /* 566 */
Tcl_Obj * (*tcl_GetNamespaceUnknownHandler) (Tcl_Interp *interp, Tcl_Namespace *nsPtr); /* 567 */
int (*tcl_SetNamespaceUnknownHandler) (Tcl_Interp *interp, Tcl_Namespace *nsPtr, Tcl_Obj *handlerPtr); /* 568 */
int (*tcl_GetEncodingFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Encoding *encodingPtr); /* 569 */
@@ -2745,8 +2744,7 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_FirstHashEntry) /* 145 */
#define Tcl_Flush \
(tclStubsPtr->tcl_Flush) /* 146 */
-#define Tcl_FreeResult \
- (tclStubsPtr->tcl_FreeResult) /* 147 */
+/* Slot 147 is reserved */
#define Tcl_GetAlias \
(tclStubsPtr->tcl_GetAlias) /* 148 */
#define Tcl_GetAliasObj \
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 242d182..4d5e328 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -204,8 +204,6 @@ static Tcl_Encoding GetBinaryEncoding();
static void FreeBinaryEncoding(ClientData clientData);
static Tcl_HashTable * GetChannelTable(Tcl_Interp *interp);
static int GetInput(Channel *chanPtr);
-static int HaveVersion(const Tcl_ChannelType *typePtr,
- Tcl_ChannelTypeVersion minimumVersion);
static void PeekAhead(Channel *chanPtr, char **dstEndPtr,
GetsState *gsPtr);
static int ReadBytes(ChannelState *statePtr, Tcl_Obj *objPtr,
@@ -492,9 +490,8 @@ ChanSeek(
* type and non-NULL.
*/
- if (HaveVersion(chanPtr->typePtr, TCL_CHANNEL_VERSION_3) &&
- chanPtr->typePtr->wideSeekProc != NULL) {
- return chanPtr->typePtr->wideSeekProc(chanPtr->instanceData,
+ if (Tcl_ChannelWideSeekProc(chanPtr->typePtr) != NULL) {
+ return Tcl_ChannelWideSeekProc(chanPtr->typePtr)(chanPtr->instanceData,
offset, mode, errnoPtr);
}
@@ -503,7 +500,7 @@ ChanSeek(
return -1;
}
- return chanPtr->typePtr->seekProc(chanPtr->instanceData,
+ return Tcl_ChannelSeekProc(chanPtr->typePtr)(chanPtr->instanceData,
offset, mode, errnoPtr);
}
@@ -4216,7 +4213,7 @@ WillWrite(
{
int inputBuffered;
- if ((chanPtr->typePtr->seekProc != NULL) &&
+ if ((Tcl_ChannelSeekProc(chanPtr->typePtr) != NULL) &&
((inputBuffered = Tcl_InputBuffered((Tcl_Channel) chanPtr)) > 0)){
int ignore;
@@ -4238,7 +4235,7 @@ WillRead(
Tcl_SetErrno(EINVAL);
return -1;
}
- if ((chanPtr->typePtr->seekProc != NULL)
+ if ((Tcl_ChannelSeekProc(chanPtr->typePtr) != NULL)
&& (Tcl_OutputBuffered((Tcl_Channel) chanPtr) > 0)) {
/*
* CAVEAT - The assumption here is that FlushChannel() will push out
@@ -7001,7 +6998,7 @@ Tcl_Seek(
* defined. This means that the channel does not support seeking.
*/
- if (chanPtr->typePtr->seekProc == NULL) {
+ if (Tcl_ChannelSeekProc(chanPtr->typePtr) == NULL) {
Tcl_SetErrno(EINVAL);
return -1;
}
@@ -7165,7 +7162,7 @@ Tcl_Tell(
* defined. This means that the channel does not support seeking.
*/
- if (chanPtr->typePtr->seekProc == NULL) {
+ if (Tcl_ChannelSeekProc(chanPtr->typePtr) == NULL) {
Tcl_SetErrno(EINVAL);
return -1;
}
@@ -10488,49 +10485,15 @@ Tcl_ChannelVersion(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (chanTypePtr->version == TCL_CHANNEL_VERSION_2) {
- return TCL_CHANNEL_VERSION_2;
- } else if (chanTypePtr->version == TCL_CHANNEL_VERSION_3) {
- return TCL_CHANNEL_VERSION_3;
- } else if (chanTypePtr->version == TCL_CHANNEL_VERSION_4) {
- return TCL_CHANNEL_VERSION_4;
- } else if (chanTypePtr->version == TCL_CHANNEL_VERSION_5) {
- return TCL_CHANNEL_VERSION_5;
- } else {
+ if ((chanTypePtr->version < TCL_CHANNEL_VERSION_2)
+ || (chanTypePtr->version > TCL_CHANNEL_VERSION_5)) {
/*
* In <v2 channel versions, the version field is occupied by the
* Tcl_DriverBlockModeProc
*/
-
return TCL_CHANNEL_VERSION_1;
}
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * HaveVersion --
- *
- * Return whether a channel type is (at least) of a given version.
- *
- * Results:
- * True if the minimum version is exceeded by the version actually
- * present.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-HaveVersion(
- const Tcl_ChannelType *chanTypePtr,
- Tcl_ChannelTypeVersion minimumVersion)
-{
- Tcl_ChannelTypeVersion actualVersion = Tcl_ChannelVersion(chanTypePtr);
-
- return (PTR2INT(actualVersion)) >= (PTR2INT(minimumVersion));
+ return chanTypePtr->version;
}
/*
@@ -10553,15 +10516,14 @@ Tcl_ChannelBlockModeProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) {
- return chanTypePtr->blockModeProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_2) {
+ /*
+ * The v1 structure had the blockModeProc in a different place.
+ */
+ return (Tcl_DriverBlockModeProc *) chanTypePtr->version;
}
- /*
- * The v1 structure had the blockModeProc in a different place.
- */
-
- return (Tcl_DriverBlockModeProc *) chanTypePtr->version;
+ return chanTypePtr->blockModeProc;
}
/*
@@ -10801,10 +10763,10 @@ Tcl_ChannelFlushProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) {
- return chanTypePtr->flushProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_2) {
+ return NULL;
}
- return NULL;
+ return chanTypePtr->flushProc;
}
/*
@@ -10828,10 +10790,10 @@ Tcl_ChannelHandlerProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) {
- return chanTypePtr->handlerProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_2) {
+ return NULL;
}
- return NULL;
+ return chanTypePtr->handlerProc;
}
/*
@@ -10855,10 +10817,10 @@ Tcl_ChannelWideSeekProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_3)) {
- return chanTypePtr->wideSeekProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_3) {
+ return NULL;
}
- return NULL;
+ return chanTypePtr->wideSeekProc;
}
/*
@@ -10883,10 +10845,10 @@ Tcl_ChannelThreadActionProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_4)) {
- return chanTypePtr->threadActionProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_4) {
+ return NULL;
}
- return NULL;
+ return chanTypePtr->threadActionProc;
}
/*
@@ -11198,10 +11160,10 @@ Tcl_ChannelTruncateProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_5)) {
- return chanTypePtr->truncateProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_5) {
+ return NULL;
}
- return NULL;
+ return chanTypePtr->truncateProc;
}
/*
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index 522ed3d..342c730 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -684,7 +684,7 @@ Tcl_CloseObjCmd(
/*
* Special handling is needed if and only if the channel mode supports
* more than the direction to close. Because if the close the last
- * direction suppported we can and will go through the regular
+ * direction supported we can and will go through the regular
* process.
*/
diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c
index 5fbd511..ec18767 100644
--- a/generic/tclIORTrans.c
+++ b/generic/tclIORTrans.c
@@ -27,10 +27,6 @@
#define EOK 0
#endif
-/* DUPLICATE of HaveVersion() in tclIO.c // TODO - MODULE_SCOPE */
-static int HaveVersion(const Tcl_ChannelType *typePtr,
- Tcl_ChannelTypeVersion minimumVersion);
-
/*
* Signatures of all functions used in the C layer of the reflection.
*/
@@ -1386,15 +1382,14 @@ ReflectSeekWide(
* non-NULL...
*/
- if (HaveVersion(parent->typePtr, TCL_CHANNEL_VERSION_3) &&
- parent->typePtr->wideSeekProc != NULL) {
- curPos = parent->typePtr->wideSeekProc(parent->instanceData, offset,
+ if (Tcl_ChannelWideSeekProc(parent->typePtr) != NULL) {
+ curPos = Tcl_ChannelWideSeekProc(parent->typePtr)(parent->instanceData, offset,
seekMode, errorCodePtr);
} else if (offset < LONG_MIN || offset > LONG_MAX) {
*errorCodePtr = EOVERFLOW;
curPos = -1;
} else {
- curPos = parent->typePtr->seekProc(
+ curPos = Tcl_ChannelSeekProc(parent->typePtr)(
parent->instanceData, offset, seekMode,
errorCodePtr);
}
@@ -3390,33 +3385,6 @@ TransformLimit(
return 1;
}
-/* DUPLICATE of HaveVersion() in tclIO.c
- *----------------------------------------------------------------------
- *
- * HaveVersion --
- *
- * Return whether a channel type is (at least) of a given version.
- *
- * Results:
- * True if the minimum version is exceeded by the version actually
- * present.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-HaveVersion(
- const Tcl_ChannelType *chanTypePtr,
- Tcl_ChannelTypeVersion minimumVersion)
-{
- Tcl_ChannelTypeVersion actualVersion = Tcl_ChannelVersion(chanTypePtr);
-
- return PTR2INT(actualVersion) >= PTR2INT(minimumVersion);
-}
-
/*
* Local Variables:
* mode: c
diff --git a/generic/tclInt.h b/generic/tclInt.h
index f483e36..72ec2b2 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2845,11 +2845,11 @@ MODULE_SCOPE void TclArgumentBCRelease(Tcl_Interp *interp,
CmdFrame *cfPtr);
MODULE_SCOPE void TclArgumentGet(Tcl_Interp *interp, Tcl_Obj *obj,
CmdFrame **cfPtrPtr, int *wordPtr);
-MODULE_SCOPE double TclBignumToDouble(const mp_int *bignum);
+MODULE_SCOPE double TclBignumToDouble(const void *bignum);
MODULE_SCOPE int TclByteArrayMatch(const unsigned char *string,
size_t strLen, const unsigned char *pattern,
size_t ptnLen, int flags);
-MODULE_SCOPE double TclCeil(const mp_int *a);
+MODULE_SCOPE double TclCeil(const void *a);
MODULE_SCOPE void TclChannelPreserve(Tcl_Channel chan);
MODULE_SCOPE void TclChannelRelease(Tcl_Channel chan);
MODULE_SCOPE int TclCheckArrayTraces(Tcl_Interp *interp, Var *varPtr,
@@ -2930,7 +2930,7 @@ MODULE_SCOPE void TclFinalizeThreadAlloc(void);
MODULE_SCOPE void TclFinalizeThreadAllocThread(void);
MODULE_SCOPE void TclFinalizeThreadData(int quick);
MODULE_SCOPE void TclFinalizeThreadObjects(void);
-MODULE_SCOPE double TclFloor(const mp_int *a);
+MODULE_SCOPE double TclFloor(const void *a);
MODULE_SCOPE void TclFormatNaN(double value, char *buffer);
MODULE_SCOPE int TclFSFileAttrIndex(Tcl_Obj *pathPtr,
const char *attributeName, int *indexPtr);
@@ -3121,7 +3121,7 @@ MODULE_SCOPE size_t TclScanElement(const char *string, size_t length,
MODULE_SCOPE void TclSetBgErrorHandler(Tcl_Interp *interp,
Tcl_Obj *cmdPrefix);
MODULE_SCOPE void TclSetBignumIntRep(Tcl_Obj *objPtr,
- mp_int *bignumValue);
+ void *bignumValue);
MODULE_SCOPE int TclSetBooleanFromAny(Tcl_Interp *interp,
Tcl_Obj *objPtr);
MODULE_SCOPE void TclSetCmdNameObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
diff --git a/generic/tclLink.c b/generic/tclLink.c
index 4476f73..01dc5cb 100644
--- a/generic/tclLink.c
+++ b/generic/tclLink.c
@@ -164,7 +164,7 @@ Tcl_LinkVar(
int code;
linkPtr = (Link *) Tcl_VarTraceInfo2(interp, varName, NULL,
- TCL_GLOBAL_ONLY, LinkTraceProc, (ClientData) NULL);
+ TCL_GLOBAL_ONLY, LinkTraceProc, NULL);
if (linkPtr != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"variable '%s' is already linked", varName));
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 58bc480..487ea26 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -3047,14 +3047,14 @@ UpdateStringOfBignum(
Tcl_Obj *
Tcl_NewBignumObj(
- mp_int *bignumValue)
+ void *bignumValue)
{
return Tcl_DbNewBignumObj(bignumValue, "unknown", 0);
}
#else
Tcl_Obj *
Tcl_NewBignumObj(
- mp_int *bignumValue)
+ void *bignumValue)
{
Tcl_Obj *objPtr;
@@ -3085,7 +3085,7 @@ Tcl_NewBignumObj(
#ifdef TCL_MEM_DEBUG
Tcl_Obj *
Tcl_DbNewBignumObj(
- mp_int *bignumValue,
+ void *bignumValue,
const char *file,
int line)
{
@@ -3098,7 +3098,7 @@ Tcl_DbNewBignumObj(
#else
Tcl_Obj *
Tcl_DbNewBignumObj(
- mp_int *bignumValue,
+ void *bignumValue,
const char *file,
int line)
{
@@ -3210,9 +3210,9 @@ int
Tcl_GetBignumFromObj(
Tcl_Interp *interp, /* Tcl interpreter for error reporting */
Tcl_Obj *objPtr, /* Object to read */
- mp_int *bignumValue) /* Returned bignum value. */
+ void *bignumValue) /* Returned bignum value. */
{
- return GetBignumFromObj(interp, objPtr, 1, bignumValue);
+ return GetBignumFromObj(interp, objPtr, 1, (mp_int *)bignumValue);
}
/*
@@ -3245,9 +3245,9 @@ int
Tcl_TakeBignumFromObj(
Tcl_Interp *interp, /* Tcl interpreter for error reporting */
Tcl_Obj *objPtr, /* Object to read */
- mp_int *bignumValue) /* Returned bignum value. */
+ void *bignumValue) /* Returned bignum value. */
{
- return GetBignumFromObj(interp, objPtr, 0, bignumValue);
+ return GetBignumFromObj(interp, objPtr, 0, (mp_int *)bignumValue);
}
/*
@@ -3270,12 +3270,13 @@ Tcl_TakeBignumFromObj(
void
Tcl_SetBignumObj(
Tcl_Obj *objPtr, /* Object to set */
- mp_int *bignumValue) /* Value to store */
+ void *big) /* Value to store */
{
Tcl_WideUInt value = 0;
size_t numBytes;
Tcl_WideUInt scratch;
unsigned char *bytes = (unsigned char *) &scratch;
+ mp_int *bignumValue = (mp_int *) big;
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_SetBignumObj");
@@ -3323,8 +3324,9 @@ Tcl_SetBignumObj(
void
TclSetBignumIntRep(
Tcl_Obj *objPtr,
- mp_int *bignumValue)
+ void *big)
{
+ mp_int *bignumValue = (mp_int *)big;
objPtr->typePtr = &tclBignumType;
PACK_BIGNUM(*bignumValue, objPtr);
diff --git a/generic/tclResult.c b/generic/tclResult.c
index 3ca3c7b..69edd39 100644
--- a/generic/tclResult.c
+++ b/generic/tclResult.c
@@ -373,36 +373,6 @@ Tcl_AppendElement(
/*
*----------------------------------------------------------------------
*
- * Tcl_FreeResult --
- *
- * This function frees up the memory associated with an interpreter's
- * result, resetting the interpreter's result object. Tcl_FreeResult is
- * most commonly used when a function is about to replace one result
- * value with another.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Frees the memory associated with interp's result but does not change
- * any part of the error dictionary (i.e., the errorinfo and errorcode
- * remain the same).
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tcl_FreeResult(
- Tcl_Interp *interp)/* Interpreter for which to free result. */
-{
- Interp *iPtr = (Interp *) interp;
-
- ResetObjResult(iPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
* Tcl_ResetResult --
*
* This function resets both the interpreter's string and object results.
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index 7ef1c8c..9028ff4 100644
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -4624,11 +4624,12 @@ int
Tcl_InitBignumFromDouble(
Tcl_Interp *interp, /* For error message. */
double d, /* Number to convert. */
- mp_int *b) /* Place to store the result. */
+ void *big) /* Place to store the result. */
{
double fract;
int expt;
mp_err err;
+ mp_int *b = (mp_int *)big;
/*
* Infinite values can't convert to bignum.
@@ -4684,12 +4685,13 @@ Tcl_InitBignumFromDouble(
double
TclBignumToDouble(
- const mp_int *a) /* Integer to convert. */
+ const void *big) /* Integer to convert. */
{
mp_int b;
int bits, shift, i, lsb;
double r;
mp_err err;
+ const mp_int *a = (const mp_int *)big;
/*
@@ -4805,11 +4807,12 @@ TclBignumToDouble(
double
TclCeil(
- const mp_int *a) /* Integer to convert. */
+ const void *big) /* Integer to convert. */
{
double r = 0.0;
mp_int b;
mp_err err;
+ const mp_int *a = (const mp_int *)big;
err = mp_init(&b);
if ((err == MP_OKAY) && mp_isneg(a)) {
@@ -4870,11 +4873,12 @@ TclCeil(
double
TclFloor(
- const mp_int *a) /* Integer to convert. */
+ const void *big) /* Integer to convert. */
{
double r = 0.0;
mp_int b;
mp_err err;
+ const mp_int *a = (const mp_int *)big;
err = mp_init(&b);
if ((err == MP_OKAY) && mp_isneg(a)) {
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index 59dba15..48ff391 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -900,7 +900,7 @@ const TclStubs tclStubs = {
0, /* 144 */
Tcl_FirstHashEntry, /* 145 */
Tcl_Flush, /* 146 */
- Tcl_FreeResult, /* 147 */
+ 0, /* 147 */
Tcl_GetAlias, /* 148 */
Tcl_GetAliasObj, /* 149 */
Tcl_GetAssocData, /* 150 */
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 98f6ba8..815854b 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -392,6 +392,8 @@ static int ZipChannelRead(void *instanceData, char *buf,
int toRead, int *errloc);
static int ZipChannelSeek(void *instanceData, long offset,
int mode, int *errloc);
+static Tcl_WideInt ZipChannelWideSeek(void *instanceData, Tcl_WideInt offset,
+ int mode, int *errloc);
static void ZipChannelWatchChannel(void *instanceData,
int mask);
static int ZipChannelWrite(void *instanceData,
@@ -454,7 +456,7 @@ static Tcl_ChannelType ZipChannelType = {
NULL, /* Set blocking mode for raw channel, NULL'able */
NULL, /* Function to flush channel, NULL'able */
NULL, /* Function to handle event, NULL'able */
- NULL, /* Wide seek function, NULL'able */
+ ZipChannelWideSeek, /* Wide seek function, NULL'able */
NULL, /* Thread action function, NULL'able */
NULL, /* Truncate function, NULL'able */
};
@@ -1280,7 +1282,7 @@ ZipFSCatalogFilesystem(
*zf = *zf0;
zf->mountPoint = Tcl_GetHashKey(&ZipFS.zipHash, hPtr);
- Tcl_CreateExitHandler(ZipfsExitHandler, (ClientData)zf);
+ Tcl_CreateExitHandler(ZipfsExitHandler, zf);
zf->mountPointLen = strlen(zf->mountPoint);
zf->nameLength = strlen(zipname);
zf->name = Tcl_Alloc(zf->nameLength + 1);
@@ -1846,7 +1848,7 @@ TclZipfs_Unmount(
Tcl_Free(z);
}
ZipFSCloseArchive(interp, zf);
- Tcl_DeleteExitHandler(ZipfsExitHandler, (ClientData)zf);
+ Tcl_DeleteExitHandler(ZipfsExitHandler, zf);
Tcl_Free(zf);
unmounted = 1;
done:
@@ -3466,7 +3468,7 @@ ZipChannelWrite(
/*
*-------------------------------------------------------------------------
*
- * ZipChannelSeek --
+ * ZipChannelSeek/ZipChannelWideSeek --
*
* This function is called to position file pointer of channel.
*
@@ -3479,15 +3481,15 @@ ZipChannelWrite(
*-------------------------------------------------------------------------
*/
-static int
-ZipChannelSeek(
+static Tcl_WideInt
+ZipChannelWideSeek(
void *instanceData,
- long offset,
+ Tcl_WideInt offset,
int mode,
int *errloc)
{
ZipChannel *info = (ZipChannel *) instanceData;
- unsigned long end;
+ size_t end;
if (!info->isWriting && (info->isDirectory < 0)) {
/*
@@ -3519,20 +3521,30 @@ ZipChannelSeek(
return -1;
}
if (info->isWriting) {
- if ((unsigned long) offset > info->maxWrite) {
+ if ((size_t) offset > info->maxWrite) {
*errloc = EINVAL;
return -1;
}
- if ((unsigned long) offset > info->numBytes) {
+ if ((size_t) offset > info->numBytes) {
info->numBytes = offset;
}
- } else if ((unsigned long) offset > end) {
+ } else if ((size_t) offset > end) {
*errloc = EINVAL;
return -1;
}
- info->numRead = (unsigned long) offset;
+ info->numRead = (size_t) offset;
return info->numRead;
}
+
+static int
+ZipChannelSeek(
+ void *instanceData,
+ long offset,
+ int mode,
+ int *errloc)
+{
+ return ZipChannelWideSeek(instanceData, offset, mode, errloc);
+}
/*
*-------------------------------------------------------------------------
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index df0372b..b3fe234 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -204,7 +204,7 @@ static void ZlibTransformTimerRun(void *clientData);
static const Tcl_ChannelType zlibChannelType = {
"zlib",
- TCL_CHANNEL_VERSION_3,
+ TCL_CHANNEL_VERSION_5,
ZlibTransformClose,
ZlibTransformInput,
ZlibTransformOutput,
diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl
index c51467b..e5cfc77 100644
--- a/library/tcltest/tcltest.tcl
+++ b/library/tcltest/tcltest.tcl
@@ -970,7 +970,7 @@ proc tcltest::testConstraint {constraint {value ""}} {
return $testConstraints($constraint)
}
# Check for boolean values
- if {[catch {expr {$value && $value}} msg]} {
+ if {[catch {expr {$value && 1}} msg]} {
return -code error $msg
}
if {[limitConstraints] && ($constraint ni $Option(-constraints))} {
diff --git a/tests/cmdIL.test b/tests/cmdIL.test
index be4d2d6..05b5040 100644
--- a/tests/cmdIL.test
+++ b/tests/cmdIL.test
@@ -19,7 +19,8 @@ catch [list package require -exact Tcltest [info patchlevel]]
# Used for constraining memory leak tests
testConstraint memory [llength [info commands memory]]
testConstraint testobj [llength [info commands testobj]]
-testConstraint prlimit [expr {[testConstraint macOrUnix] && ![catch { exec prlimit -n }]}]
+source [file join [file dirname [info script]] internals.tcl]
+namespace import -force ::tcltest::internals::*
test cmdIL-1.1 {Tcl_LsortObjCmd procedure} -returnCodes error -body {
lsort
@@ -520,39 +521,21 @@ test cmdIL-5.5 {lsort with list style index and sharing} -body {
test cmdIL-5.6 {lsort with multiple list-style index options} {
lsort -index {1 2 3} -index 0 {{a b} {c d} {b e}}
} {{a b} {b e} {c d}}
-test cmdIL-5.7 {lsort memory exhaustion} -constraints {prlimit} -body {
- # test it in child process (with limited address space):
- set pipe {}
- if {[catch {
- set pipe [open |[list [interpreter]] r+]
- exec prlimit -p [pid $pipe] --as=80000000
- } msg]} {
- catch {close $pipe}
- tcltest::Skip "prlimit: error - [regsub {^\s*([^\n]*).*$} $msg {\1}]"
+test cmdIL-5.7 {lsort memory exhaustion} -constraints {testWithLimit} -body {
+ # test it in child process (with limited address space) ca. 80MB extra memory
+ # on x64 system it would be not enough to sort 4M items (the half 2M only),
+ # warn and skip if no error (enough memory) or error by list creation:
+ testWithLimit \
+ -warn-on-code 0 -warn-on-alloc-error 1 \
+ -addmem [expr {$tcl_platform(pointerSize)*4000000 + $tcl_platform(pointerSize)*3*2000000}] \
+ {
+ # create list and get length (avoid too long output in interactive shells):
+ llength [set l [lrepeat 4000000 ""]]
+ # test OOM:
+ llength [lsort $l]
}
- # if no error (enough memory), or error by list creation - add it as skipped test:
- if {![catch {
- chan configure $pipe -buffering line
- puts $pipe {
- # create list and get length (avoid too long output in interactive shells):
- llength [set l [lrepeat 4000000 ""]]
- # test OOM:
- puts [llength [lsort $l]]
- exit
- }
- set result [read $pipe]
- close $pipe
- set pipe {}
- set result
- } result] || [regexp {^(?:list creation failed|unable to (?:re)?alloc)} $result]} {
- tcltest::Skip "prlimit: wrong AS-limit, result: $result"
- }
- set result
# expecting error no memory by sort
-} -cleanup {
- if {$pipe ne ""} { catch { close $pipe } }
- unset -nocomplain pipe line result
-} -result {no enough memory to proccess sort of 4000000 items}
+} -returnCodes 1 -result {no enough memory to proccess sort of 4000000 items}
# Compiled version
test cmdIL-6.1 {lassign command syntax} -returnCodes error -body {
diff --git a/tests/internals.tcl b/tests/internals.tcl
new file mode 100644
index 0000000..6b5bb87
--- /dev/null
+++ b/tests/internals.tcl
@@ -0,0 +1,96 @@
+# This file contains internal facilities for Tcl tests.
+#
+# Source this file in the related tests to include from tcl-tests:
+#
+# source [file join [file dirname [info script]] internals.tcl]
+#
+# Copyright (c) 2020 Sergey G. Brester (sebres).
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+
+if {[namespace which -command ::tcltest::internals::scriptpath] eq ""} {namespace eval ::tcltest::internals {
+
+namespace path ::tcltest
+
+::tcltest::ConstraintInitializer testWithLimit { expr {[testConstraint macOrUnix] && ![catch { exec prlimit --version }]} }
+
+# test-with-limit --
+#
+# Usage: test-with-limit ?-addmem bytes? ?-maxmem bytes? command
+# Options:
+# -addmem - set additional memory limit (in bytes) as difference (extra memory needed to run a test)
+# -maxmem - set absolute maximum address space limit (in bytes)
+#
+proc testWithLimit args {
+ set body [lindex $args end]
+ array set in [lrange $args 0 end-1]
+ # test in child process (with limits):
+ set pipe {}
+ if {[catch {
+ # start new process:
+ set pipe [open |[list [interpreter]] r+]
+ set ppid [pid $pipe]
+ # create prlimit args:
+ set args {}
+ # with limited address space:
+ if {[info exists in(-addmem)] || [info exists in(-maxmem)]} {
+ if {[info exists in(-addmem)]} {
+ # as differnce to normal usage, so try to retrieve current memory usage:
+ if {[catch {
+ # using ps (vsz is in KB):
+ incr in(-addmem) [expr {[lindex [exec ps -hq $ppid -o vsz] end] * 1024}]
+ }]} {
+ # ps failed, use default size 20MB:
+ incr in(-addmem) 20000000
+ # + size of locale-archive (may be up to 100MB):
+ incr in(-addmem) [expr {
+ [file exists /usr/lib/locale/locale-archive] ?
+ [file size /usr/lib/locale/locale-archive] : 0
+ }]
+ }
+ if {![info exists in(-maxmem)]} {
+ set in(-maxmem) $in(-addmem)
+ }
+ set in(-maxmem) [expr { max($in(-addmem), $in(-maxmem)) }]
+ }
+ append args --as=$in(-maxmem)
+ }
+ # apply limits:
+ exec prlimit -p $ppid {*}$args
+ } msg opt]} {
+ catch {close $pipe}
+ tcltest::Warn "testWithLimit: error - [regsub {^\s*([^\n]*).*$} $msg {\1}]"
+ tcltest::Skip testWithLimit
+ }
+ # execute body, close process and return:
+ set ret [catch {
+ chan configure $pipe -buffering line
+ puts $pipe "puts \[$body\]"
+ puts $pipe exit
+ set result [read $pipe]
+ close $pipe
+ set pipe {}
+ set result
+ } result opt]
+ if {$pipe ne ""} { catch { close $pipe } }
+ if {$ret && [dict get $opt -errorcode] eq "BYPASS-SKIPPED-TEST"} {
+ return {*}$opt $result
+ }
+ if { ( [info exists in(-warn-on-code)] && $ret in $in(-warn-on-code) )
+ || ( $ret && [info exists in(-warn-on-alloc-error)] && $in(-warn-on-alloc-error)
+ && [regexp {\munable to (?:re)?alloc\M} $result] )
+ } {
+ tcltest::Warn "testWithLimit: wrong limit, result: $result"
+ tcltest::Skip testWithLimit
+ }
+ return {*}$opt $result
+}
+
+# export all routines starting with test
+namespace export test*
+
+# for script path & as mark for loaded
+proc scriptpath {} [list return [info script]]
+
+}}; # end of internals. \ No newline at end of file
diff --git a/unix/configure b/unix/configure
index b01a4bc..f4073cd 100755
--- a/unix/configure
+++ b/unix/configure
@@ -5313,7 +5313,7 @@ fi
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
TCL_NEEDS_EXP_FILE=1
- TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.dll.a'
+ TCL_EXPORT_FILE_SUFFIX='${VERSION}.dll.a'
SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$@.a"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Cygwin version of gcc" >&5
$as_echo_n "checking for Cygwin version of gcc... " >&6; }
@@ -6733,7 +6733,6 @@ else
fi
# FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
- DBGX=""
if test "$tcl_ok" = "no"; then
CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 1c4653e..1bf731e 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -293,10 +293,6 @@ AC_DEFUN([SC_LOAD_TCLCONFIG], [
AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
fi
- # eval is required to do the TCL_DBGX substitution
- eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
- eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
-
# If the TCL_BIN_DIR is the build directory (not the install directory),
# then set the common variable name to the value of the build variables.
# For example, the variable TCL_LIB_SPEC will be set to the value
@@ -330,12 +326,6 @@ AC_DEFUN([SC_LOAD_TCLCONFIG], [
esac
fi
- # eval is required to do the TCL_DBGX substitution
- eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
- eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
- eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
- eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
-
AC_SUBST(TCL_VERSION)
AC_SUBST(TCL_PATCH_LEVEL)
AC_SUBST(TCL_BIN_DIR)
@@ -376,10 +366,6 @@ AC_DEFUN([SC_LOAD_TKCONFIG], [
AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
fi
- # eval is required to do the TK_DBGX substitution
- eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
- eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
-
# If the TK_BIN_DIR is the build directory (not the install directory),
# then set the common variable name to the value of the build variables.
# For example, the variable TK_LIB_SPEC will be set to the value
@@ -413,12 +399,6 @@ AC_DEFUN([SC_LOAD_TKCONFIG], [
esac
fi
- # eval is required to do the TK_DBGX substitution
- eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
- eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
- eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
- eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
-
AC_SUBST(TK_VERSION)
AC_SUBST(TK_BIN_DIR)
AC_SUBST(TK_SRC_DIR)
@@ -624,8 +604,6 @@ AC_DEFUN([SC_ENABLE_FRAMEWORK], [
# Sets to $(CFLAGS_OPTIMIZE) if false
# LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
# Sets to $(LDFLAGS_OPTIMIZE) if false
-# DBGX Formerly used as debug library extension;
-# always blank now.
#------------------------------------------------------------------------
AC_DEFUN([SC_ENABLE_SYMBOLS], [
@@ -635,7 +613,6 @@ AC_DEFUN([SC_ENABLE_SYMBOLS], [
[build with debugging symbols (default: off)]),
[tcl_ok=$enableval], [tcl_ok=no])
# FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
- DBGX=""
if test "$tcl_ok" = "no"; then
CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
@@ -1109,7 +1086,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
TCL_NEEDS_EXP_FILE=1
- TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.dll.a'
+ TCL_EXPORT_FILE_SUFFIX='${VERSION}.dll.a'
SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$[@].a"
AC_CACHE_CHECK(for Cygwin version of gcc,
ac_cv_cygwin,
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 09ed008..29defff 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -687,32 +687,22 @@ TcpClose2Proc(
int flags) /* Flags that indicate which side to close. */
{
TcpState *statePtr = instanceData;
- int errorCode = 0;
- int sd;
+ int readError = 0;
+ int writeError = 0;
/*
* Shutdown the OS socket handle.
*/
-
- switch(flags) {
- case TCL_CLOSE_READ:
- sd = SHUT_RD;
- break;
- case TCL_CLOSE_WRITE:
- sd = SHUT_WR;
- break;
- default:
- if (interp) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "socket close2proc called bidirectionally", -1));
- }
- return TCL_ERROR;
+ if ((flags & (TCL_CLOSE_READ|TCL_CLOSE_WRITE)) == 0) {
+ return TcpCloseProc(instanceData, interp);
}
- if (shutdown(statePtr->fds.fd,sd) < 0) {
- errorCode = errno;
+ if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->fds.fd, SHUT_RD) < 0)) {
+ readError = errno;
}
-
- return errorCode;
+ if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->fds.fd, SHUT_WR) < 0)) {
+ writeError = errno;
+ }
+ return (readError != 0) ? readError : writeError;
}
/*
diff --git a/win/Makefile.in b/win/Makefile.in
index 9dae1b2..bb0c38b 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -834,7 +834,7 @@ install-binaries: binaries
install-libraries-zipfs-shared: libraries
install-libraries-zipfs-static: install-libraries-zipfs-shared
- $(INSTALL_DATA) ${TCL_ZIP_FILE} "$(LIB_INSTALL_DIR)"
+ $(COPY) ${TCL_ZIP_FILE} "$(LIB_INSTALL_DIR)"
install-libraries: libraries install-tzdata install-msgs
@for i in "$$($(CYGPATH) $(prefix)/lib)" "$(INCLUDE_INSTALL_DIR)" \
diff --git a/win/rules.vc b/win/rules.vc
index 8c1a9ce..ac741dc 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -1289,11 +1289,8 @@ OPTDEFINES = $(OPTDEFINES) /DHAVE_STDINT_H=1
!else
OPTDEFINES = $(OPTDEFINES) /DMP_NO_STDINT=1
!endif
-!if $(VCVERSION) >= 1700
-OPTDEFINES = $(OPTDEFINES) /DHAVE_INTTYPES_H=1
-!endif
!if $(VCVERSION) >= 1800
-OPTDEFINES = $(OPTDEFINES) /DHAVE_STDBOOL_H=1
+OPTDEFINES = $(OPTDEFINES) /DHAVE_INTTYPES_H=1 /DHAVE_STDBOOL_H=1
!endif
!if $(TCL_MEM_DEBUG)
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 8e2723d..efda780 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -1136,26 +1136,15 @@ TcpClose2Proc(
int flags) /* Flags that indicate which side to close. */
{
TcpState *statePtr = instanceData;
- int errorCode = 0;
- int sd;
+ int readError = 0;
+ int writeError = 0;
/*
* Shutdown the OS socket handle.
*/
- switch(flags) {
- case TCL_CLOSE_READ:
- sd = SD_RECEIVE;
- break;
- case TCL_CLOSE_WRITE:
- sd = SD_SEND;
- break;
- default:
- if (interp) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "socket close2proc called bidirectionally", -1));
- }
- return TCL_ERROR;
+ if ((flags & (TCL_CLOSE_READ|TCL_CLOSE_WRITE)) == 0) {
+ return TcpCloseProc(instanceData, interp);
}
/*
@@ -1163,12 +1152,15 @@ TcpClose2Proc(
* TCL_WRITABLE so this should never be called for a server socket.
*/
- if (shutdown(statePtr->sockets->fd, sd) == SOCKET_ERROR) {
+ if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->sockets->fd, SD_RECEIVE) == SOCKET_ERROR)) {
TclWinConvertError((DWORD) WSAGetLastError());
- errorCode = Tcl_GetErrno();
+ readError = Tcl_GetErrno();
}
-
- return errorCode;
+ if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->sockets->fd, SD_SEND) == SOCKET_ERROR)) {
+ TclWinConvertError((DWORD) WSAGetLastError());
+ writeError = Tcl_GetErrno();
+ }
+ return (readError != 0) ? readError : writeError;
}
/*