From 3c5b4af0d42e9175d48a6e114ec5f3ec05e1b915 Mon Sep 17 00:00:00 2001 From: max Date: Mon, 26 Nov 2012 17:40:29 +0000 Subject: Factor out creation of the -sockname and -peername lists from TcpGetOptionProc() to TcpHostPortList(). Make it robust against implementations of getnameinfo() that error out if reverse mapping fails instead of falling back to the numeric representation. --- ChangeLog | 8 ++++ unix/tclUnixSock.c | 118 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 78 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b4772c..c9d3cb3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-11-26 Reinhard Max + + * unix/tclUnixSock.c: Factor out creation of the -sockname and + -peername lists from TcpGetOptionProc() to TcpHostPortList(). + Make it robust against implementations of getnameinfo() that error + out if reverse mapping fails instead of falling back to the + numeric representation. + 2012-11-20 Donal K. Fellows * generic/tclBinary.c (BinaryDecode64): [Bug 3033307]: Corrected diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index 102c620..31daa62 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -627,6 +627,74 @@ TcpClose2Proc( /* *---------------------------------------------------------------------- * + * TcpHostPortList -- + * + * This function is called by the -gethostname and -getpeername + * switches of TcpGetOptionProc() to add three list elements + * with the textual representation of the given address to the + * given DString. + * + * Results: + * None. + * + * Side effects: + * Adds three elements do dsPtr + * + *---------------------------------------------------------------------- + */ +static void +TcpHostPortList( + Tcl_Interp *interp, + Tcl_DString *dsPtr, + address addr, + socklen_t salen) +{ +#define SUPPRESS_RDNS_VAR "::tcl::unsupported::noReverseDNS" + char host[NI_MAXHOST], nhost[NI_MAXHOST], nport[NI_MAXSERV]; + int flags = 0; + + getnameinfo(&addr.sa, salen, + nhost, sizeof(nhost), nport, sizeof(nport), + NI_NUMERICHOST | NI_NUMERICSERV); + Tcl_DStringAppendElement(dsPtr, nhost); + /* + * We don't want to resolve INADDR_ANY and sin6addr_any; they + * can sometimes cause problems (and never have a name). + */ + if (addr.sa.sa_family == AF_INET) { + if (addr.sa4.sin_addr.s_addr == INADDR_ANY) { + flags |= NI_NUMERICHOST; + } +#ifndef NEED_FAKE_RFC2553 + } else if (addr.sa.sa_family == AF_INET6) { + if ((IN6_ARE_ADDR_EQUAL(&addr.sa6.sin6_addr, + &in6addr_any)) + || (IN6_IS_ADDR_V4MAPPED(&addr.sa6.sin6_addr) && + addr.sa6.sin6_addr.s6_addr[12] == 0 && + addr.sa6.sin6_addr.s6_addr[13] == 0 && + addr.sa6.sin6_addr.s6_addr[14] == 0 && + addr.sa6.sin6_addr.s6_addr[15] == 0)) { + flags |= NI_NUMERICHOST; + } +#endif /* NEED_FAKE_RFC2553 */ + } + /* Check if reverse DNS has been switched off globally */ + if (interp != NULL && Tcl_GetVar(interp, SUPPRESS_RDNS_VAR, 0) != NULL) { + flags |= NI_NUMERICHOST; + } + if (getnameinfo(&addr.sa, salen, host, sizeof(host), NULL, 0, flags) == 0) { + /* Reverse mapping worked */ + Tcl_DStringAppendElement(dsPtr, host); + } else { + /* Reverse mappong failed - use the numeric rep once more */ + Tcl_DStringAppendElement(dsPtr, nhost); + } + Tcl_DStringAppendElement(dsPtr, nport); +} + +/* + *---------------------------------------------------------------------- + * * TcpGetOptionProc -- * * Computes an option value for a TCP socket based channel, or a list of @@ -656,10 +724,7 @@ TcpGetOptionProc( * initialized by caller. */ { TcpState *statePtr = instanceData; - char host[NI_MAXHOST], port[NI_MAXSERV]; size_t len = 0; - int reverseDNS = 0; -#define SUPPRESS_RDNS_VAR "::tcl::unsupported::noReverseDNS" if (optionName != NULL) { len = strlen(optionName); @@ -686,10 +751,6 @@ TcpGetOptionProc( return TCL_OK; } - if (interp != NULL && Tcl_GetVar(interp, SUPPRESS_RDNS_VAR, 0) != NULL) { - reverseDNS = NI_NUMERICHOST; - } - if ((len == 0) || ((len > 1) && (optionName[1] == 'p') && (strncmp(optionName, "-peername", len) == 0))) { address peername; @@ -700,14 +761,7 @@ TcpGetOptionProc( Tcl_DStringAppendElement(dsPtr, "-peername"); Tcl_DStringStartSublist(dsPtr); } - - getnameinfo(&peername.sa, size, host, sizeof(host), NULL, 0, - NI_NUMERICHOST); - Tcl_DStringAppendElement(dsPtr, host); - getnameinfo(&peername.sa, size, host, sizeof(host), port, - sizeof(port), reverseDNS | NI_NUMERICSERV); - Tcl_DStringAppendElement(dsPtr, host); - Tcl_DStringAppendElement(dsPtr, port); + TcpHostPortList(interp, dsPtr, peername, size); if (len) { return TCL_OK; } @@ -745,40 +799,8 @@ TcpGetOptionProc( for (fds = &statePtr->fds; fds != NULL; fds = fds->next) { size = sizeof(sockname); if (getsockname(fds->fd, &(sockname.sa), &size) >= 0) { - int flags = reverseDNS; - found = 1; - getnameinfo(&sockname.sa, size, host, sizeof(host), NULL, 0, - NI_NUMERICHOST); - Tcl_DStringAppendElement(dsPtr, host); - - /* - * We don't want to resolve INADDR_ANY and sin6addr_any; they - * can sometimes cause problems (and never have a name). - */ - - flags |= NI_NUMERICSERV; - if (sockname.sa.sa_family == AF_INET) { - if (sockname.sa4.sin_addr.s_addr == INADDR_ANY) { - flags |= NI_NUMERICHOST; - } -#ifndef NEED_FAKE_RFC2553 - } else if (sockname.sa.sa_family == AF_INET6) { - if ((IN6_ARE_ADDR_EQUAL(&sockname.sa6.sin6_addr, - &in6addr_any)) - || (IN6_IS_ADDR_V4MAPPED(&sockname.sa6.sin6_addr) && - sockname.sa6.sin6_addr.s6_addr[12] == 0 && - sockname.sa6.sin6_addr.s6_addr[13] == 0 && - sockname.sa6.sin6_addr.s6_addr[14] == 0 && - sockname.sa6.sin6_addr.s6_addr[15] == 0)) { - flags |= NI_NUMERICHOST; - } -#endif /* NEED_FAKE_RFC2553 */ - } - getnameinfo(&sockname.sa, size, host, sizeof(host), port, - sizeof(port), flags); - Tcl_DStringAppendElement(dsPtr, host); - Tcl_DStringAppendElement(dsPtr, port); + TcpHostPortList(interp, dsPtr, sockname, size); } } if (found) { -- cgit v0.12 From 9652ccdb2f5dbc810445ea5431b278cf4417a9c1 Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 28 Nov 2012 00:04:31 +0000 Subject: [3590483]: Some compilers cannot initialize with complex non-constants. --- ChangeLog | 8 +++++++- generic/tclZlib.c | 51 +++++++++++++++++++++++++++------------------------ 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9d3cb3..6f8c8ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-11-28 Donal K. Fellows + + * generic/tclZlib.c (ZlibStreamSubcmd): [Bug 3590483]: Use a mechanism + for complex option resolution that has fewer problems with more + finicky compilers. + 2012-11-26 Reinhard Max * unix/tclUnixSock.c: Factor out creation of the -sockname and @@ -5,7 +11,7 @@ Make it robust against implementations of getnameinfo() that error out if reverse mapping fails instead of falling back to the numeric representation. - + 2012-11-20 Donal K. Fellows * generic/tclBinary.c (BinaryDecode64): [Bug 3033307]: Corrected diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 11490f1..c63c306 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -2177,29 +2177,35 @@ ZlibStreamSubcmd( FMT_INFLATE }; int i, format, mode = 0, option, level; + enum objIndices { + OPT_COMPRESSION_DICTIONARY = 0, + OPT_GZIP_HEADER = 1, + OPT_COMPRESSION_LEVEL = 2 + }; + Tcl_Obj *obj[3] = { NULL, NULL, NULL }; +#define compDictObj obj[OPT_COMPRESSION_DICTIONARY] +#define gzipHeaderObj obj[OPT_GZIP_HEADER] +#define levelObj obj[OPT_COMPRESSION_LEVEL] typedef struct { const char *name; - Tcl_Obj **valueVar; + enum objIndices offset; } OptDescriptor; - Tcl_Obj *compDictObj = NULL; - Tcl_Obj *gzipHeaderObj = NULL; - Tcl_Obj *levelObj = NULL; - const OptDescriptor compressionOpts[] = { - { "-dictionary", &compDictObj }, - { "-level", &levelObj }, - { NULL, NULL } + static const OptDescriptor compressionOpts[] = { + { "-dictionary", OPT_COMPRESSION_DICTIONARY }, + { "-level", OPT_COMPRESSION_LEVEL }, + { NULL, 0 } }; - const OptDescriptor gzipOpts[] = { - { "-header", &gzipHeaderObj }, - { "-level", &levelObj }, - { NULL, NULL } + static const OptDescriptor gzipOpts[] = { + { "-header", OPT_GZIP_HEADER }, + { "-level", OPT_COMPRESSION_LEVEL }, + { NULL, 0 } }; - const OptDescriptor expansionOpts[] = { - { "-dictionary", &compDictObj }, - { NULL, NULL } + static const OptDescriptor expansionOpts[] = { + { "-dictionary", OPT_COMPRESSION_DICTIONARY }, + { NULL, 0 } }; - const OptDescriptor gunzipOpts[] = { - { NULL, NULL } + static const OptDescriptor gunzipOpts[] = { + { NULL, 0 } }; const OptDescriptor *desc = NULL; Tcl_ZlibStream zh; @@ -2262,13 +2268,7 @@ ZlibStreamSubcmd( sizeof(OptDescriptor), "option", 0, &option) != TCL_OK) { return TCL_ERROR; } - *desc[option].valueVar = objv[i+1]; - - /* - * Drop the cache on the option name; table address not constant. - */ - - TclFreeIntRep(objv[i]); + obj[desc[option].offset] = objv[i+1]; } /* @@ -2300,6 +2300,9 @@ ZlibStreamSubcmd( } Tcl_SetObjResult(interp, Tcl_ZlibStreamGetCommandName(zh)); return TCL_OK; +#undef compDictObj +#undef gzipHeaderObj +#undef levelObj } /* -- cgit v0.12 From da12d58e11aba7b3a5f30364766ee0d5f30ce00b Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 28 Nov 2012 08:52:00 +0000 Subject: Silence some (unimportant) warnings from the MIPSpro compiler. --- generic/tclZlib.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/generic/tclZlib.c b/generic/tclZlib.c index c63c306..8fbe049 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -2180,7 +2180,8 @@ ZlibStreamSubcmd( enum objIndices { OPT_COMPRESSION_DICTIONARY = 0, OPT_GZIP_HEADER = 1, - OPT_COMPRESSION_LEVEL = 2 + OPT_COMPRESSION_LEVEL = 2, + OPT_END = -1 }; Tcl_Obj *obj[3] = { NULL, NULL, NULL }; #define compDictObj obj[OPT_COMPRESSION_DICTIONARY] @@ -2193,19 +2194,19 @@ ZlibStreamSubcmd( static const OptDescriptor compressionOpts[] = { { "-dictionary", OPT_COMPRESSION_DICTIONARY }, { "-level", OPT_COMPRESSION_LEVEL }, - { NULL, 0 } + { NULL, OPT_END } }; static const OptDescriptor gzipOpts[] = { { "-header", OPT_GZIP_HEADER }, { "-level", OPT_COMPRESSION_LEVEL }, - { NULL, 0 } + { NULL, OPT_END } }; static const OptDescriptor expansionOpts[] = { { "-dictionary", OPT_COMPRESSION_DICTIONARY }, - { NULL, 0 } + { NULL, OPT_END } }; static const OptDescriptor gunzipOpts[] = { - { NULL, 0 } + { NULL, OPT_END } }; const OptDescriptor *desc = NULL; Tcl_ZlibStream zh; -- cgit v0.12 From 665a380e86877529932a05da6d253011e8065642 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 29 Nov 2012 13:15:36 +0000 Subject: silence compiler warning --- generic/tclCompCmdsSZ.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index be63e0e..9c93fb2 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -1224,12 +1224,7 @@ TclCompileSwitchCmd( if (TCL_OK != TclFindElement(NULL, bytes, numBytes, &(bodyTokenArray[numWords].start), &bytes, &(bodyTokenArray[numWords].size), &literal) || !literal) { - abort: - ckfree((char *) bodyToken); - ckfree((char *) bodyTokenArray); - ckfree((char *) bodyLines); - ckfree((char *) bodyContLines); - return TCL_ERROR; + goto abort; } bodyTokenArray[numWords].type = TCL_TOKEN_TEXT; @@ -1254,7 +1249,12 @@ TclCompileSwitchCmd( numWords++; } if (numWords % 2) { - goto abort; + abort: + ckfree((char *) bodyToken); + ckfree((char *) bodyTokenArray); + ckfree((char *) bodyLines); + ckfree((char *) bodyContLines); + return TCL_ERROR; } } else if (numWords % 2 || numWords == 0) { /* -- cgit v0.12 From 8bdf6a3cdd5c1ace4435d972fd5f183ce4f3e18c Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 29 Nov 2012 14:47:12 +0000 Subject: 3588687 When detecting incompatibility during stubs initialization, the error message has always assumed a stubs-disabled 8.0 interp to be the cause. That's no longer a good assumption. More suitable error message committed. --- generic/tclStubLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c index 1ab7ff3..7bf04a0 100644 --- a/generic/tclStubLib.c +++ b/generic/tclStubLib.c @@ -47,7 +47,7 @@ HasStubSupport (interp) if (iPtr->stubTable && (iPtr->stubTable->magic == TCL_STUB_MAGIC)) { return iPtr->stubTable; } - interp->result = "This interpreter does not support stubs-enabled extensions."; + interp->result = "interpreter uses an incompatible stubs mechanism"; interp->freeProc = TCL_STATIC; return NULL; -- cgit v0.12 From c85fd541529c09d23c1091969ad8f96012bb68ec Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 30 Nov 2012 09:16:16 +0000 Subject: Inform the HTML builder about the TDBC drivers. --- pkgs/package.list.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/package.list.txt b/pkgs/package.list.txt index 5020506..f12111d 100644 --- a/pkgs/package.list.txt +++ b/pkgs/package.list.txt @@ -19,3 +19,8 @@ thread Thread tdbc TDBC Tdbc TDBC TDBC TDBC +# Drivers for TDBC +tdbcmysql tdbc::mysql +tdbcodbc tdbc::odbc +tdbcpostgres tdbc::postgres +tdbcsqlite3- tdbc::sqlite3 -- cgit v0.12 From 8ef61c13e0df3175cac5b314840f726f7407b6f8 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 3 Dec 2012 14:33:17 +0000 Subject: Post-header reform (long long ago now) Tcl headers take care of their own protection from EXTERN definitions. --- unix/tclLoadShl.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/unix/tclLoadShl.c b/unix/tclLoadShl.c index c9e4e27..8aaefda 100644 --- a/unix/tclLoadShl.c +++ b/unix/tclLoadShl.c @@ -12,15 +12,6 @@ */ #include - -/* - * On some HP machines, dl.h defines EXTERN; remove that definition. - */ - -#ifdef EXTERN -# undef EXTERN -#endif - #include "tclInt.h" /* -- cgit v0.12 From b222d2f2b2dbf7666e44385dc825b59b5045b3f2 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 3 Dec 2012 19:14:32 +0000 Subject: Disable the legacy configuration setting from $::argv only when a setting call to [configure] is made. Queries should not disturb that support. Bump to tcltest 2.2.11. --- library/tcltest/pkgIndex.tcl | 2 +- library/tcltest/tcltest.tcl | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library/tcltest/pkgIndex.tcl b/library/tcltest/pkgIndex.tcl index e569fa5..eb5859e 100644 --- a/library/tcltest/pkgIndex.tcl +++ b/library/tcltest/pkgIndex.tcl @@ -9,4 +9,4 @@ # full path name of this file's directory. if {![package vsatisfies [package provide Tcl] 8.3]} {return} -package ifneeded tcltest 2.2.10 [list source [file join $dir tcltest.tcl]] +package ifneeded tcltest 2.2.11 [list source [file join $dir tcltest.tcl]] diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 4ae1480c..5d89748 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -22,7 +22,7 @@ namespace eval tcltest { # When the version number changes, be sure to update the pkgIndex.tcl file, # and the install directory in the Makefiles. When the minor version # changes (new feature) be sure to update the man page as well. - variable Version 2.2.10 + variable Version 2.2.11 # Compatibility support for dumb variables defined in tcltest 1 # Do not use these. Call [package provide Tcl] and [info patchlevel] @@ -601,7 +601,9 @@ namespace eval tcltest { } } proc configure args { - RemoveAutoConfigureTraces + if {[llength $args] > 1} { + RemoveAutoConfigureTraces + } set code [catch {eval Configure $args} msg] return -code $code $msg } -- cgit v0.12 From ae09e66da466ea68e269fc388798ca6ce2cd1c4c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 4 Dec 2012 13:39:07 +0000 Subject: MODULE_SCOPE symbol names are suppoted to start with 'tcl' (data) or 'Tcl' (code) --- generic/tclParse.c | 2 +- generic/tclParse.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tclParse.c b/generic/tclParse.c index 309e232..08615a7 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -42,7 +42,7 @@ * TYPE_BRACE - Character is a curly brace (either left or right). */ -const char charTypeTable[] = { +const char tclCharTypeTable[] = { /* * Negative character values, from -128 to -1: */ diff --git a/generic/tclParse.h b/generic/tclParse.h index be1ab15..20c609c 100644 --- a/generic/tclParse.h +++ b/generic/tclParse.h @@ -12,6 +12,6 @@ #define TYPE_CLOSE_BRACK 0x20 #define TYPE_BRACE 0x40 -#define CHAR_TYPE(c) (charTypeTable+128)[(int)(c)] +#define CHAR_TYPE(c) (tclCharTypeTable+128)[(int)(c)] -MODULE_SCOPE const char charTypeTable[]; +MODULE_SCOPE const char tclCharTypeTable[]; -- cgit v0.12