diff options
author | dgp <dgp@users.sourceforge.net> | 2013-04-01 17:07:10 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2013-04-01 17:07:10 (GMT) |
commit | d81f8f7c49270ddc93b4d639c0e7f77767c4fd47 (patch) | |
tree | 64da754277b242dc50862f735d5b4ee523971fa6 /generic/tkStubLib.c | |
parent | e19cf65c7641a093a5c7cf8325c5466e431d7c69 (diff) | |
parent | b8f8082aad49088238582658c22248f9469ad055 (diff) | |
download | tk-d81f8f7c49270ddc93b4d639c0e7f77767c4fd47.zip tk-d81f8f7c49270ddc93b4d639c0e7f77767c4fd47.tar.gz tk-d81f8f7c49270ddc93b4d639c0e7f77767c4fd47.tar.bz2 |
Merge 8.5. Bring together the compile time and run time Xkb checks.bug_3607830
Diffstat (limited to 'generic/tkStubLib.c')
-rw-r--r-- | generic/tkStubLib.c | 111 |
1 files changed, 51 insertions, 60 deletions
diff --git a/generic/tkStubLib.c b/generic/tkStubLib.c index 5349a0b..f605b5d 100644 --- a/generic/tkStubLib.c +++ b/generic/tkStubLib.c @@ -1,33 +1,16 @@ /* * tkStubLib.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 Tk. * - * Copyright (c) 1998 Paul Duffin. * 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 Tk_InitStubs but doesn't end up - * including the rest of the stub functions. - */ - -#ifndef USE_TCL_STUBS -#define USE_TCL_STUBS -#endif -#undef USE_TCL_STUB_PROCS - -#ifndef USE_TK_STUBS -#define USE_TK_STUBS -#endif -#undef USE_TK_STUB_PROCS - #include "tkInt.h" #ifdef __WIN32__ @@ -56,7 +39,8 @@ TkIntXlibStubs *tkIntXlibStubsPtr = NULL; * Use our own isdigit to avoid linking to libc on windows */ -static int isDigit(const int c) +static int +isDigit(const int c) { return (c >= '0' && c <= '9'); } @@ -78,66 +62,73 @@ static int isDigit(const int c) * *---------------------------------------------------------------------- */ - -#ifdef Tk_InitStubs #undef Tk_InitStubs -#endif - CONST char * Tk_InitStubs( Tcl_Interp *interp, CONST char *version, int exact) { - CONST char *actualVersion; - TkStubs **stubsPtrPtr = &tkStubsPtr; /* squelch warning */ - - actualVersion = Tcl_PkgRequireEx(interp, "Tk", version, 0, - (ClientData *) stubsPtrPtr); - if (!actualVersion) { + const char *packageName = "Tk"; + const char *errMsg = NULL; + ClientData clientData = NULL; + CONST char *actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp, + packageName, version, 0, &clientData); + TkStubs *stubsPtr = (TkStubs *)clientData; + + if (actualVersion == NULL) { return NULL; } + if (exact) { - CONST char *p = version; - int count = 0; + CONST char *p = version; + int count = 0; - while (*p) { - count += !isDigit(*p++); - } - if (count == 1) { + while (*p) { + count += !isDigit(*p++); + } + if (count == 1) { CONST char *q = actualVersion; p = version; while (*p && (*p == *q)) { p++; q++; } - if (*p) { + if (*p || isDigit(*q)) { /* Construct error message */ - Tcl_PkgRequireEx(interp, "Tk", version, 1, NULL); - return NULL; - - } - } else { - actualVersion = Tcl_PkgRequireEx(interp, "Tk", version, 1, NULL); - if (actualVersion == NULL) { - return NULL; - } - } + tclStubsPtr->tcl_PkgRequireEx(interp, "Tk", version, 1, NULL); + return NULL; + } + } else { + actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp, "Tk", + version, 1, NULL); + if (actualVersion == NULL) { + return NULL; + } + } } - - if (!tkStubsPtr) { - Tcl_SetResult(interp, - "This implementation of Tk does not support stubs", - TCL_STATIC); - return NULL; + if (stubsPtr == NULL) { + errMsg = "missing stub table pointer"; + } else { + tkStubsPtr = stubsPtr; + if (stubsPtr->hooks) { + tkPlatStubsPtr = stubsPtr->hooks->tkPlatStubs; + tkIntStubsPtr = stubsPtr->hooks->tkIntStubs; + tkIntPlatStubsPtr = stubsPtr->hooks->tkIntPlatStubs; + tkIntXlibStubsPtr = stubsPtr->hooks->tkIntXlibStubs; + } else { + tkPlatStubsPtr = NULL; + tkIntStubsPtr = NULL; + tkIntPlatStubsPtr = NULL; + tkIntXlibStubsPtr = NULL; + } + return actualVersion; } - - tkPlatStubsPtr = tkStubsPtr->hooks->tkPlatStubs; - tkIntStubsPtr = tkStubsPtr->hooks->tkIntStubs; - tkIntPlatStubsPtr = tkStubsPtr->hooks->tkIntPlatStubs; - tkIntXlibStubsPtr = tkStubsPtr->hooks->tkIntXlibStubs; - - return actualVersion; + tclStubsPtr->tcl_ResetResult(interp); + tclStubsPtr->tcl_AppendResult(interp, "Error loading ", packageName, + " (requested version ", version, ", actual version ", + actualVersion, "): ", errMsg, NULL); + return NULL; } /* |