From e76d16d3eba7f034fc003f1061736c298b03c74f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 7 Dec 2012 21:28:49 +0000 Subject: only set tclStubsPtr if all version checks pass. Backported from tcl 8.5. --- generic/tclStubLib.c | 105 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 62 insertions(+), 43 deletions(-) diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c index 7bf04a0..39e94c8 100644 --- a/generic/tclStubLib.c +++ b/generic/tclStubLib.c @@ -1,45 +1,26 @@ -/* +/* * tclStubLib.c -- * - * Stub object that will be statically linked into extensions that wish + * Stub object that will be statically linked into extensions that want * to access Tcl. * * Copyright (c) 1998-1999 by Scriptics Corporation. * Copyright (c) 1998 Paul Duffin. * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -/* - * We need to ensure that we use the stub macros so that this file contains - * no references to any of the stub functions. This will make it possible - * to build an extension that references Tcl_InitStubs but doesn't end up - * including the rest of the stub functions. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#ifndef USE_TCL_STUBS -#define USE_TCL_STUBS -#endif -#undef USE_TCL_STUB_PROCS - #include "tclInt.h" #include "tclPort.h" -/* - * Ensure that Tcl_InitStubs is built as an exported symbol. The other stub - * functions should be built as non-exported symbols. - */ - TclStubs *tclStubsPtr = NULL; TclPlatStubs *tclPlatStubsPtr = NULL; TclIntStubs *tclIntStubsPtr = NULL; TclIntPlatStubs *tclIntPlatStubsPtr = NULL; -static TclStubs * HasStubSupport _ANSI_ARGS_((Tcl_Interp *interp)); - static TclStubs * -HasStubSupport (interp) +HasStubSupport(interp) Tcl_Interp *interp; { Interp *iPtr = (Interp *) interp; @@ -49,57 +30,87 @@ HasStubSupport (interp) } interp->result = "interpreter uses an incompatible stubs mechanism"; interp->freeProc = TCL_STATIC; - return NULL; } /* + * Use our own isdigit to avoid linking to libc on windows + */ + +static int isDigit(const int c) +{ + return (c >= '0' && c <= '9'); +} + +/* *---------------------------------------------------------------------- * * Tcl_InitStubs -- * - * Tries to initialise the stub table pointers and ensures that - * the correct version of Tcl is loaded. + * Tries to initialise the stub table pointers and ensures that the + * correct version of Tcl is loaded. * * Results: - * The actual version of Tcl that satisfies the request, or - * NULL to indicate that an error occurred. + * The actual version of Tcl that satisfies the request, or NULL to + * indicate that an error occurred. * * Side effects: * Sets the stub table pointers. * *---------------------------------------------------------------------- */ - -#ifdef Tcl_InitStubs #undef Tcl_InitStubs -#endif - CONST char * -Tcl_InitStubs (interp, version, exact) +Tcl_InitStubs(interp, version, exact) Tcl_Interp *interp; CONST char *version; int exact; { CONST char *actualVersion = NULL; - ClientData pkgData = NULL; + TclStubs *stubsPtr; /* - * We can't optimize this check by caching tclStubsPtr because - * that prevents apps from being able to load/unload Tcl dynamically - * multiple times. [Bug 615304] + * We can't optimize this check by caching tclStubsPtr because that + * prevents apps from being able to load/unload Tcl dynamically multiple + * times. [Bug 615304] */ - tclStubsPtr = HasStubSupport(interp); - if (!tclStubsPtr) { + stubsPtr = HasStubSupport(interp); + if (!stubsPtr) { return NULL; } - actualVersion = Tcl_PkgRequireEx(interp, "Tcl", version, exact, &pkgData); + actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 0, NULL); if (actualVersion == NULL) { return NULL; } - tclStubsPtr = (TclStubs*)pkgData; + if (exact) { + CONST char *p = version; + int count = 0; + + while (*p) { + count += !isDigit(*p++); + } + if (count == 1) { + CONST char *q = actualVersion; + + p = version; + while (*p && (*p == *q)) { + p++; q++; + } + if (*p || isDigit(*q)) { + /* Construct error message */ + stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL); + return NULL; + } + } else { + actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL); + if (actualVersion == NULL) { + return NULL; + } + } + } + tclStubsPtr = stubsPtr; if (tclStubsPtr->hooks) { tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs; @@ -110,6 +121,14 @@ Tcl_InitStubs (interp, version, exact) tclIntStubsPtr = NULL; tclIntPlatStubsPtr = NULL; } - + return actualVersion; } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ -- cgit v0.12 From 8ea32cad84602b02b1eab7b2ca01bf583bd1c9db Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 7 Dec 2012 22:14:26 +0000 Subject: just lost one MODULE_SCOPE in the merge --- generic/tclStubLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c index 5a122dd..b8979df 100644 --- a/generic/tclStubLib.c +++ b/generic/tclStubLib.c @@ -64,7 +64,7 @@ static int isDigit(const int c) *---------------------------------------------------------------------- */ #undef Tcl_InitStubs -const char * +MODULE_SCOPE const char * Tcl_InitStubs( Tcl_Interp *interp, const char *version, -- cgit v0.12 From 5ab4d052c526754eca52cbec0aea41c6a61d7fb6 Mon Sep 17 00:00:00 2001 From: ferrieux Date: Sat, 8 Dec 2012 17:13:03 +0000 Subject: Fix busyloop at exit under TCL_FINALIZE_ON_EXIT when there are unflushed nonblocking channels. Thanks Miguel for spotting. --- ChangeLog | 5 +++++ generic/tclIO.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 37c3e2e..c1a3ff7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-12-08 Alexandre Ferrieux + * generic/tclIO.c: Fix busyloop at exit under TCL_FINALIZE_ON_EXIT + when there are unflushed nonblocking channels. Thanks Miguel for + spotting. + 2012-12-07 Jan Nijtmans * unix/dltest/pkgb.c: Turn pkgb.so into a Tcl9 interoperability test diff --git a/generic/tclIO.c b/generic/tclIO.c index 0cb9fa9..715c1ef 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -2472,7 +2472,7 @@ FlushChannel( * it's a tty channel (dup'ed underneath) */ - if (!GotFlag(statePtr, BG_FLUSH_SCHEDULED)) { + if (!GotFlag(statePtr, BG_FLUSH_SCHEDULED) && !TclInExit()) { SetFlag(statePtr, BG_FLUSH_SCHEDULED); UpdateInterest(chanPtr); } -- cgit v0.12 From ff12195b2b7d3b9d0f8f4441bd3ec0c991ba742b Mon Sep 17 00:00:00 2001 From: ferrieux Date: Sun, 9 Dec 2012 11:52:04 +0000 Subject: Clean up unwanted eofchar side-effect of chan-4.6 leading to a spurious "'" at end of chan.test under certain conditions (see [Bug 3389289] and [Bug 3389251]). --- ChangeLog | 5 +++++ tests/chan.test | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c1a3ff7..aeb6a62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-12-09 Alexandre Ferrieux + * tests/chan.test: Clean up unwanted eofchar side-effect of + chan-4.6 leading to a spurious "'" at end of chan.test under + certain conditions (see [Bug 3389289] and [Bug 3389251]). + 2012-12-08 Alexandre Ferrieux * generic/tclIO.c: Fix busyloop at exit under TCL_FINALIZE_ON_EXIT when there are unflushed nonblocking channels. Thanks Miguel for diff --git a/tests/chan.test b/tests/chan.test index da44ffd..d8390e2 100644 --- a/tests/chan.test +++ b/tests/chan.test @@ -61,7 +61,7 @@ test chan-4.5 {chan command: check valid inValue, invalid outValue} -body { } -returnCodes error -match glob -result {bad value for -eofchar:*} test chan-4.6 {chan command: check no inValue, valid outValue} -body { chan configure stdout -eofchar [list {} \x27] -} -returnCodes ok -result {} +} -returnCodes ok -result {} -cleanup {chan configure stdout -eofchar [list {} {}]} test chan-5.1 {chan command: copy subcommand} -body { chan copy foo -- cgit v0.12 From a68a31f4bff004ca60d9cf17cb74a9fc8b94d2ed Mon Sep 17 00:00:00 2001 From: ferrieux Date: Sun, 9 Dec 2012 19:44:57 +0000 Subject: [Bug 3594188] Clarifications about commas. --- ChangeLog | 1 + doc/expr.n | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index aeb6a62..9c42929 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * tests/chan.test: Clean up unwanted eofchar side-effect of chan-4.6 leading to a spurious "'" at end of chan.test under certain conditions (see [Bug 3389289] and [Bug 3389251]). + * doc/expr.n: [Bug 3594188] Clarifications about commas. 2012-12-08 Alexandre Ferrieux * generic/tclIO.c: Fix busyloop at exit under TCL_FINALIZE_ON_EXIT diff --git a/doc/expr.n b/doc/expr.n index 6d965fb..8698f5c 100644 --- a/doc/expr.n +++ b/doc/expr.n @@ -39,9 +39,9 @@ additional operators not found in C. .SS OPERANDS .PP A Tcl expression consists of a combination of operands, operators, -and parentheses. +parentheses and commas. White space may be used between the operands and operators and -parentheses; it is ignored by the expression's instructions. +parentheses (or commas); it is ignored by the expression's instructions. Where possible, operands are interpreted as integer values. Integer values may be specified in decimal (the normal case), in binary (if the first two characters of the operand are \fB0b\fR), in octal @@ -283,6 +283,18 @@ rules for resolving functions in namespaces. Either current]::tcl::mathfunc::sin\fR will satisfy the request, and others may as well (depending on the current \fBnamespace path\fR setting). .PP +Some mathematical functions have several arguments, separated by commas like in C. Thus: +.PP +.CS +\fBexpr\fR {hypot($x,$y)} +.CE +.PP +ends up as +.PP +.CS +tcl::mathfunc::hypot $x $y +.CE +.PP See the \fBmathfunc\fR(n) manual page for the math functions that are available by default. .SS "TYPES, OVERFLOW, AND PRECISION" -- cgit v0.12 From e595fefe85b468cabc5e2cbebb030a525b46228f Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 10 Dec 2012 14:08:59 +0000 Subject: Restore the initialization of tclStubsPtr from the "Tcl" package clientData so that we don't close off a potential avenue of future innovations. --- generic/tclStubLib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c index 39e94c8..ceee8f3 100644 --- a/generic/tclStubLib.c +++ b/generic/tclStubLib.c @@ -67,6 +67,7 @@ Tcl_InitStubs(interp, version, exact) int exact; { CONST char *actualVersion = NULL; + ClientData pkgData = NULL; TclStubs *stubsPtr; /* @@ -80,7 +81,7 @@ Tcl_InitStubs(interp, version, exact) return NULL; } - actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 0, NULL); + actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 0, &pkgData); if (actualVersion == NULL) { return NULL; } @@ -110,7 +111,7 @@ Tcl_InitStubs(interp, version, exact) } } } - tclStubsPtr = stubsPtr; + tclStubsPtr = (TclStubs *)pkgData; if (tclStubsPtr->hooks) { tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs; -- cgit v0.12