summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-03-16 18:11:08 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-03-16 18:11:08 (GMT)
commite7fc2e1e1d845b964cbf8c084865e83d1ced239f (patch)
treecbf743d53c85e2e497a9a02a5afdb5750d86c25b
parent527e79c3a8b0d8df5cce3676a94700785584ef06 (diff)
parent88f9f54d4c4e23a4d20b82b40b385c6d558013f9 (diff)
downloadtcl-e7fc2e1e1d845b964cbf8c084865e83d1ced239f.zip
tcl-e7fc2e1e1d845b964cbf8c084865e83d1ced239f.tar.gz
tcl-e7fc2e1e1d845b964cbf8c084865e83d1ced239f.tar.bz2
Merge 9.0
-rw-r--r--generic/tclIO.c52
-rw-r--r--generic/tclIO.h3
-rw-r--r--generic/tclLiteral.c4
-rw-r--r--generic/tclProc.c2
-rw-r--r--generic/tclTest.c4
-rw-r--r--tests/encoding.test16
-rw-r--r--tools/valgrind_check_success30
-rwxr-xr-xunix/configure50
-rw-r--r--unix/tcl.m43
-rw-r--r--unix/tclConfig.h.in3
10 files changed, 85 insertions, 82 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 63579ee..bc891a2 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -165,6 +165,7 @@ static int CheckForDeadChannel(Tcl_Interp *interp,
static void CheckForStdChannelsBeingClosed(Tcl_Channel chan);
static void CleanupChannelHandlers(Tcl_Interp *interp,
Channel *chanPtr);
+static void CleanupTimerHandler(ChannelState *statePtr);
static int CloseChannel(Tcl_Interp *interp, Channel *chanPtr,
int errorCode);
static int CloseChannelPart(Tcl_Interp *interp, Channel *chanPtr,
@@ -172,6 +173,7 @@ static int CloseChannelPart(Tcl_Interp *interp, Channel *chanPtr,
static int CloseWrite(Tcl_Interp *interp, Channel *chanPtr);
static void CommonGetsCleanup(Channel *chanPtr);
static int CopyData(CopyState *csPtr, int mask);
+static void DeleteTimerHandler(ChannelState *statePtr);
static int MoveBytes(CopyState *csPtr);
static void MBCallback(CopyState *csPtr, Tcl_Obj *errObj);
@@ -1708,6 +1710,7 @@ Tcl_CreateChannel(
statePtr->scriptRecordPtr = NULL;
statePtr->bufSize = CHANNELBUFFER_DEFAULT_SIZE;
statePtr->timer = NULL;
+ statePtr->timerChanPtr = NULL;
statePtr->csPtrR = NULL;
statePtr->csPtrW = NULL;
statePtr->outputStage = NULL;
@@ -3153,8 +3156,8 @@ CloseChannel(
/*
* Cancel any outstanding timer.
*/
+ DeleteTimerHandler(statePtr);
- Tcl_DeleteTimerHandler(statePtr->timer);
/*
* Mark the channel as deleted by clearing the type structure.
@@ -3506,7 +3509,7 @@ TclClose(
/*
* Cancel any outstanding timer.
*/
- Tcl_DeleteTimerHandler(statePtr->timer);
+ DeleteTimerHandler(statePtr);
/*
* Invoke the registered close callbacks and delete their records.
@@ -3959,8 +3962,7 @@ Tcl_ClearChannelHandlers(
/*
* Cancel any outstanding timer.
*/
-
- Tcl_DeleteTimerHandler(statePtr->timer);
+ DeleteTimerHandler(statePtr);
/*
* Remove any references to channel handlers for this channel that may be
@@ -8641,8 +8643,9 @@ UpdateInterest(
if (!statePtr->timer) {
TclChannelPreserve((Tcl_Channel)chanPtr);
+ statePtr->timerChanPtr = chanPtr;
statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME,
- ChannelTimerProc, chanPtr);
+ ChannelTimerProc, chanPtr);
}
}
}
@@ -8652,6 +8655,7 @@ UpdateInterest(
&& GotFlag(statePtr, CHANNEL_NONBLOCKING)) {
TclChannelPreserve((Tcl_Channel)chanPtr);
+ statePtr->timerChanPtr = chanPtr;
statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME,
ChannelTimerProc,chanPtr);
}
@@ -8682,7 +8686,6 @@ ChannelTimerProc(
void *clientData)
{
Channel *chanPtr = (Channel *)clientData;
-
/* State info for channel */
ChannelState *statePtr = chanPtr->state;
@@ -8693,7 +8696,7 @@ ChannelTimerProc(
*/
if (chanPtr->typePtr == NULL) {
- TclChannelRelease((Tcl_Channel)chanPtr);
+ CleanupTimerHandler(statePtr);
} else {
Tcl_Preserve(statePtr);
statePtr->timer = NULL;
@@ -8706,35 +8709,52 @@ ChannelTimerProc(
* before UpdateInterest gets called by Tcl_NotifyChannel.
*/
statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME,
- ChannelTimerProc,chanPtr);
+ ChannelTimerProc,chanPtr);
Tcl_NotifyChannel((Tcl_Channel) chanPtr, TCL_WRITABLE);
} else {
/* The channel may have just been closed from within Tcl_NotifyChannel */
if (!GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (!GotFlag(statePtr, CHANNEL_NEED_MORE_DATA)
- && (statePtr->interestMask & TCL_READABLE)
- && (statePtr->inQueueHead != NULL)
- && IsBufferReady(statePtr->inQueueHead)) {
+ && (statePtr->interestMask & TCL_READABLE)
+ && (statePtr->inQueueHead != NULL)
+ && IsBufferReady(statePtr->inQueueHead)) {
/*
* Restart the timer in case a channel handler reenters the event loop
* before UpdateInterest gets called by Tcl_NotifyChannel.
*/
statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME,
- ChannelTimerProc,chanPtr);
+ ChannelTimerProc,chanPtr);
Tcl_NotifyChannel((Tcl_Channel) chanPtr, TCL_READABLE);
} else {
- TclChannelRelease((Tcl_Channel)chanPtr);
+ CleanupTimerHandler(statePtr);
UpdateInterest(chanPtr);
}
} else {
- TclChannelRelease((Tcl_Channel)chanPtr);
+ CleanupTimerHandler(statePtr);
}
}
-
Tcl_Release(statePtr);
}
-
+}
+
+static void
+DeleteTimerHandler(
+ ChannelState *statePtr
+)
+{
+ if (statePtr->timer != NULL) {
+ Tcl_DeleteTimerHandler(statePtr->timer);
+ CleanupTimerHandler(statePtr);
+ }
+}
+static void
+CleanupTimerHandler(
+ ChannelState *statePtr
+){
+ TclChannelRelease((Tcl_Channel)statePtr->timerChanPtr);
+ statePtr->timer = NULL;
+ statePtr->timerChanPtr = NULL;
}
/*
diff --git a/generic/tclIO.h b/generic/tclIO.h
index 8f0ef8a..c3b5bc3 100644
--- a/generic/tclIO.h
+++ b/generic/tclIO.h
@@ -190,6 +190,9 @@ typedef struct ChannelState {
* handlers ("fileevent") on this channel. */
size_t bufSize; /* What size buffers to allocate? */
Tcl_TimerToken timer; /* Handle to wakeup timer for this channel. */
+ Channel *timerChanPtr; /* Needed in order to decrement the refCount of
+ the right channel when the timer is
+ deleted. */
struct CopyState *csPtrR; /* State of background copy for which channel
* is input, or NULL. */
struct CopyState *csPtrW; /* State of background copy for which channel
diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c
index 24e99fc..c3f0f7d 100644
--- a/generic/tclLiteral.c
+++ b/generic/tclLiteral.c
@@ -179,8 +179,8 @@ TclCreateLiteral(
const char *bytes, /* The start of the string. Note that this is
* not a NUL-terminated string. */
size_t length, /* Number of bytes in the string. */
- size_t hash, /* The string's hash. If -1, it will be
- * computed here. */
+ size_t hash, /* The string's hash. If the value is
+ * TCL_INDEX_NONE, it will be computed here. */
int *newPtr,
Namespace *nsPtr,
int flags,
diff --git a/generic/tclProc.c b/generic/tclProc.c
index c8a304a..a472a2d 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -1298,7 +1298,7 @@ InitLocalCache(
*namePtr = NULL;
} else {
*namePtr = TclCreateLiteral(iPtr, localPtr->name,
- localPtr->nameLength, /* hash */ (size_t) -1,
+ localPtr->nameLength, /* hash */ TCL_INDEX_NONE,
&isNew, /* nsPtr */ NULL, 0, NULL);
Tcl_IncrRefCount(*namePtr);
}
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 459461f..590b0c8 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -2086,7 +2086,7 @@ static int UtfExtWrapper(
/* Assumes state is integer if not "" */
Tcl_WideInt wide;
if (Tcl_GetWideIntFromObj(interp, objv[5], &wide) == TCL_OK) {
- encState = (Tcl_EncodingState) wide;
+ encState = (Tcl_EncodingState)(size_t)wide;
encStatePtr = &encState;
} else if (Tcl_GetCharLength(objv[5]) == 0) {
encStatePtr = NULL;
@@ -2174,7 +2174,7 @@ static int UtfExtWrapper(
}
result = TCL_OK;
resultObjs[1] =
- encStatePtr ? Tcl_NewWideIntObj((Tcl_WideInt)encState) : Tcl_NewObj();
+ encStatePtr ? Tcl_NewWideIntObj((Tcl_WideInt)(size_t)encState) : Tcl_NewObj();
resultObjs[2] = Tcl_NewByteArrayObj(bufPtr, dstLen);
if (srcReadVar) {
if (Tcl_ObjSetVar2(interp,
diff --git a/tests/encoding.test b/tests/encoding.test
index 407bd28..1be6fed 100644
--- a/tests/encoding.test
+++ b/tests/encoding.test
@@ -623,7 +623,7 @@ test encoding-17.12 {Utf32ToUtfProc} -body {
test encoding-18.1 {TableToUtfProc on invalid input} -body {
list [catch {encoding convertto jis0208 \\} res] $res
-} -result {1 {unexpected character at index 0: 'U+00005C'}}
+} -result {0 !)}
test encoding-18.2 {TableToUtfProc on invalid input with -profile strict} -body {
list [catch {encoding convertto -profile strict jis0208 \\} res] $res
} -result {1 {unexpected character at index 0: 'U+00005C'}}
@@ -810,8 +810,11 @@ test encoding-24.17 {Parse valid or invalid utf-8} -constraints testbytestring -
test encoding-24.18 {Parse valid or invalid utf-8} -constraints testbytestring -body {
encoding convertto utf-8 [testbytestring "Z\xE0\x80xxxxxx"]
} -result "Z\xC3\xA0\xE2\x82\xACxxxxxx"
-test encoding-24.19 {Parse valid or invalid utf-8} -body {
- encoding convertto utf-8 "ZX\uD800"
+test encoding-24.19.1 {Parse valid or invalid utf-8} -body {
+ encoding convertto -profile tcl8 utf-8 "ZX\uD800"
+} -result ZX\xED\xA0\x80
+test encoding-24.19.2 {Parse valid or invalid utf-8} -body {
+ encoding convertto -profile strict utf-8 "ZX\uD800"
} -returnCodes 1 -match glob -result "unexpected character at index 2: 'U+00D800'"
test encoding-24.20 {Parse with -profile tcl8 but without providing encoding} -body {
encoding convertfrom -profile tcl8 "\x20"
@@ -867,9 +870,12 @@ test encoding-24.36 {Parse invalid utf-8 with -profile strict} -body {
test encoding-24.37 {Parse invalid utf-8 with -profile tcl8} -body {
encoding convertfrom -profile tcl8 utf-8 \xED\xA0\x80
} -result \uD800
-test encoding-24.38 {Try to generate invalid utf-8} -body {
- encoding convertto utf-8 \uD800
+test encoding-24.38.1 {Try to generate invalid utf-8} -body {
+ encoding convertto -profile tcl8 utf-8 \uD800
} -returnCodes 1 -result {unexpected character at index 0: 'U+00D800'}
+test encoding-24.38.2 {Try to generate invalid utf-8} -body {
+ encoding convertto -profile strict utf-8 \uD800
+} -result \xED\xA0\x80
test encoding-24.39 {Try to generate invalid utf-8 with -profile strict} -body {
encoding convertto -profile strict utf-8 \uD800
} -returnCodes 1 -result {unexpected character at index 0: 'U+00D800'}
diff --git a/tools/valgrind_check_success b/tools/valgrind_check_success
new file mode 100644
index 0000000..24830d5
--- /dev/null
+++ b/tools/valgrind_check_success
@@ -0,0 +1,30 @@
+#! /usr/bin/env tclsh
+
+
+proc main {sourcetype source} {
+ switch $sourcetype {
+ file {
+ set chan [open $source]
+ try {
+ set data [read $chan]
+ } finally {
+ close $chan
+ }
+ }
+ string {
+ set data $source
+ }
+ default {
+ error [list {wrong # args}]
+ }
+ }
+ set found [regexp -inline -all {blocks are\
+ (?:(?:(?:definitely|indirectly|possibly) lost)|still reachable)} $data]
+ if {[llength $found]} {
+ puts 0
+ } else {
+ puts 1
+ }
+ flush stdout
+}
+main {*}$argv
diff --git a/unix/configure b/unix/configure
index 4855fd3..6a80e5c 100755
--- a/unix/configure
+++ b/unix/configure
@@ -7631,56 +7631,6 @@ printf "%s\n" "#define _LARGEFILE64_SOURCE 1" >>confdefs.h
tcl_flags="$tcl_flags _LARGEFILE64_SOURCE"
fi
-
- if test ${tcl_cv_flag__largefile_source64+y}
-then :
- printf %s "(cached) " >&6
-else $as_nop
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/stat.h>
-int
-main (void)
-{
-char *p = (char *)open64;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
- tcl_cv_flag__largefile_source64=no
-else $as_nop
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#define _LARGEFILE_SOURCE64 1
-#include <sys/stat.h>
-int
-main (void)
-{
-char *p = (char *)open64;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
- tcl_cv_flag__largefile_source64=yes
-else $as_nop
- tcl_cv_flag__largefile_source64=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
- if test "x${tcl_cv_flag__largefile_source64}" = "xyes" ; then
-
-printf "%s\n" "#define _LARGEFILE_SOURCE64 1" >>confdefs.h
-
- tcl_flags="$tcl_flags _LARGEFILE_SOURCE64"
- fi
-
if test "x${tcl_flags}" = "x" ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
printf "%s\n" "none" >&6; }
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 84436a3..17d3b06 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -2329,7 +2329,6 @@ AC_DEFUN([SC_TCL_LINK_LIBS], [
# Might define the following vars:
# _ISOC99_SOURCE
# _LARGEFILE64_SOURCE
-# _LARGEFILE_SOURCE64
#
#--------------------------------------------------------------------
@@ -2353,8 +2352,6 @@ AC_DEFUN([SC_TCL_EARLY_FLAGS],[
[char *p = (char *)strtoll; char *q = (char *)strtoull;])
SC_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
[struct stat64 buf; int i = stat64("/", &buf);])
- SC_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include <sys/stat.h>],
- [char *p = (char *)open64;])
if test "x${tcl_flags}" = "x" ; then
AC_MSG_RESULT([none])
else
diff --git a/unix/tclConfig.h.in b/unix/tclConfig.h.in
index 0075804..4d8230a 100644
--- a/unix/tclConfig.h.in
+++ b/unix/tclConfig.h.in
@@ -489,9 +489,6 @@
/* Add the _LARGEFILE64_SOURCE flag when building */
#undef _LARGEFILE64_SOURCE
-/* Add the _LARGEFILE_SOURCE64 flag when building */
-#undef _LARGEFILE_SOURCE64
-
/* # needed in sys/socket.h Should OS/390 do the right thing with sockets? */
#undef _OE_SOCKETS