summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-11-29 16:05:33 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-11-29 16:05:33 (GMT)
commit6d6996d99fb8dc3566f23a3b6fa22dfb0bda0a16 (patch)
tree1213b14637736aa3f29ae39c21314720c8ceaf21
parent11af978f519524d92ce53cc5fbed1d3512ce08cb (diff)
downloadtcl-6d6996d99fb8dc3566f23a3b6fa22dfb0bda0a16.zip
tcl-6d6996d99fb8dc3566f23a3b6fa22dfb0bda0a16.tar.gz
tcl-6d6996d99fb8dc3566f23a3b6fa22dfb0bda0a16.tar.bz2
make Windows dde (-> 1.4.5) and registry (-> 1.3.7) extensions ready for the Tcl 9.0 era.
-rw-r--r--library/dde/pkgIndex.tcl6
-rw-r--r--library/registry/pkgIndex.tcl4
-rw-r--r--tests/registry.test4
-rw-r--r--tests/winDde.test4
-rw-r--r--win/Makefile.in4
-rw-r--r--win/makefile.vc4
-rw-r--r--win/tclWinDde.c93
-rw-r--r--win/tclWinReg.c124
8 files changed, 116 insertions, 127 deletions
diff --git a/library/dde/pkgIndex.tcl b/library/dde/pkgIndex.tcl
index 18ac517..ace1681 100644
--- a/library/dde/pkgIndex.tcl
+++ b/library/dde/pkgIndex.tcl
@@ -1,12 +1,12 @@
if {[info sharedlibextension] != ".dll"} return
if {[package vsatisfies [package provide Tcl] 9.0-]} {
- package ifneeded dde 1.4.4 \
+ package ifneeded dde 1.4.5 \
[list load [file join $dir tcl9dde14.dll] Dde]
} elseif {![package vsatisfies [package provide Tcl] 8.7]
&& [::tcl::pkgconfig get debug]} {
- package ifneeded dde 1.4.4 \
+ package ifneeded dde 1.4.5 \
[list load [file join $dir tcldde14g.dll] Dde]
} else {
- package ifneeded dde 1.4.4 \
+ package ifneeded dde 1.4.5 \
[list load [file join $dir tcldde14.dll] Dde]
}
diff --git a/library/registry/pkgIndex.tcl b/library/registry/pkgIndex.tcl
index 765f02a..edb4729 100644
--- a/library/registry/pkgIndex.tcl
+++ b/library/registry/pkgIndex.tcl
@@ -1,9 +1,9 @@
if {![package vsatisfies [package provide Tcl] 8.5-]} return
if {[info sharedlibextension] != ".dll"} return
if {[package vsatisfies [package provide Tcl] 9.0-]} {
- package ifneeded registry 1.3.6 \
+ package ifneeded registry 1.3.7 \
[list load [file join $dir tcl9registry13.dll] Registry]
} else {
- package ifneeded registry 1.3.6 \
+ package ifneeded registry 1.3.7 \
[list load [file join $dir tclregistry13.dll] Registry]
}
diff --git a/tests/registry.test b/tests/registry.test
index 4fc96bf..2f1fd8c 100644
--- a/tests/registry.test
+++ b/tests/registry.test
@@ -19,7 +19,7 @@ testConstraint reg 0
if {[testConstraint win]} {
if {![catch {
::tcltest::loadTestedCommands
- set ::regver [package require registry 1.3.6]
+ set ::regver [package require registry 1.3.7]
}]} {
testConstraint reg 1
}
@@ -34,7 +34,7 @@ testConstraint english [expr {
test registry-1.0 {check if we are testing the right dll} {win reg} {
set ::regver
-} {1.3.6}
+} {1.3.7}
test registry-1.1 {argument parsing for registry command} {win reg} {
list [catch {registry} msg] $msg
} {1 {wrong # args: should be "registry ?-32bit|-64bit? option ?arg ...?"}}
diff --git a/tests/winDde.test b/tests/winDde.test
index c56d27d..14308c7 100644
--- a/tests/winDde.test
+++ b/tests/winDde.test
@@ -19,7 +19,7 @@ testConstraint dde 0
if {[testConstraint win]} {
if {![catch {
::tcltest::loadTestedCommands
- set ::ddever [package require dde 1.4.4]
+ set ::ddever [package require dde 1.4.5]
set ::ddelib [info loaded {} Dde]}]} {
testConstraint dde 1
}
@@ -105,7 +105,7 @@ proc createChildProcess {ddeServerName args} {
# -------------------------------------------------------------------------
test winDde-1.0 {check if we are testing the right dll} {win dde} {
set ::ddever
-} {1.4.4}
+} {1.4.5}
test winDde-1.1 {Settings the server's topic name} -constraints dde -body {
list [dde servername foobar] [dde servername] [dde servername self]
diff --git a/win/Makefile.in b/win/Makefile.in
index 689f9b8..6d7bb7d 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -157,8 +157,8 @@ TEST_DLL_FILE = tcltest$(VER)${DLLSUFFIX}
TEST_EXE_FILE = tcltest${EXESUFFIX}
TEST_LIB_FILE = @LIBPREFIX@tcltest$(VER)${DLLSUFFIX}${LIBSUFFIX}
TEST_LOAD_PRMS = lappend ::auto_path {$(ROOT_DIR_WIN_NATIVE)/tests};\
- package ifneeded dde 1.4.4 [list load [file normalize ${DDE_DLL_FILE}]];\
- package ifneeded registry 1.3.6 [list load [file normalize ${REG_DLL_FILE}]]
+ package ifneeded dde 1.4.5 [list load [file normalize ${DDE_DLL_FILE}]];\
+ package ifneeded registry 1.3.7 [list load [file normalize ${REG_DLL_FILE}]]
TEST_LOAD_FACILITIES = package ifneeded tcl::test ${VERSION}@TCL_PATCH_LEVEL@ [list load [file normalize ${TEST_DLL_FILE}] Tcltest];\
$(TEST_LOAD_PRMS)
ZLIB_DLL_FILE = zlib1.dll
diff --git a/win/makefile.vc b/win/makefile.vc
index e583ae0..1f0b02e 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -500,8 +500,8 @@ test: test-core test-pkgs
test-core: setup $(TCLTEST) dlls
set TCL_LIBRARY=$(ROOT:\=/)/library
$(DEBUGGER) $(TCLTEST) "$(ROOT:\=/)/tests/all.tcl" $(TESTFLAGS) -loadfile <<
- package ifneeded dde 1.4.4 [list load "$(TCLDDELIB:\=/)"]
- package ifneeded registry 1.3.6 [list load "$(TCLREGLIB:\=/)"]
+ package ifneeded dde 1.4.5 [list load "$(TCLDDELIB:\=/)"]
+ package ifneeded registry 1.3.7 [list load "$(TCLREGLIB:\=/)"]
<<
runtest: setup $(TCLTEST) dlls
diff --git a/win/tclWinDde.c b/win/tclWinDde.c
index 678eed3..e232471 100644
--- a/win/tclWinDde.c
+++ b/win/tclWinDde.c
@@ -79,7 +79,7 @@ static DWORD ddeInstance; /* The application instance handle given to us
* by DdeInitialize. */
static int ddeIsServer = 0;
-#define TCL_DDE_VERSION "1.4.4"
+#define TCL_DDE_VERSION "1.4.5"
#define TCL_DDE_PACKAGE_NAME "dde"
#define TCL_DDE_SERVICE_NAME L"TclEval"
#define TCL_DDE_EXECUTE_RESULT L"$TCLEVAL$EXECUTE$RESULT"
@@ -117,7 +117,7 @@ static int DdeObjCmd(void *clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
-#if (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7)
+#if (TCL_MAJOR_VERSION < 9) && defined(TCL_MINOR_VERSION) && (TCL_MINOR_VERSION < 7)
# if TCL_UTF_MAX > 3
# define Tcl_WCharToUtfDString(a,b,c) Tcl_WinTCharToUtf((TCHAR *)(a),(b)*sizeof(WCHAR),c)
# define Tcl_UtfToWCharDString(a,b,c) (WCHAR *)Tcl_WinUtfToTChar(a,b,c)
@@ -125,32 +125,20 @@ static int DdeObjCmd(void *clientData,
# define Tcl_WCharToUtfDString Tcl_UniCharToUtfDString
# define Tcl_UtfToWCharDString Tcl_UtfToUniCharDString
# endif
+#define Tcl_Size int
+#define TCL_INDEX_NONE -1
#endif
-static unsigned char *
-getByteArrayFromObj(
- Tcl_Obj *objPtr,
- size_t *lengthPtr
-) {
- int length;
-
- unsigned char *result = Tcl_GetByteArrayFromObj(objPtr, &length);
-#if TCL_MAJOR_VERSION > 8
- if (sizeof(TCL_HASH_TYPE) > sizeof(int)) {
- /* 64-bit and TIP #494 situation: */
- *lengthPtr = *(TCL_HASH_TYPE *) objPtr->internalRep.twoPtrValue.ptr1;
- } else
-#endif
- /* 32-bit or without TIP #494 */
- *lengthPtr = (size_t) (unsigned) length;
- return result;
-}
-
#ifdef __cplusplus
extern "C" {
#endif
DLLEXPORT int Dde_Init(Tcl_Interp *interp);
DLLEXPORT int Dde_SafeInit(Tcl_Interp *interp);
+#if TCL_MAJOR_VERSION < 9
+/* With those additional entries, "load dde14.dll" works without 3th argument */
+DLLEXPORT int Tcldde_Init(Tcl_Interp *interp);
+DLLEXPORT int Tcldde_SafeInit(Tcl_Interp *interp);
+#endif
#ifdef __cplusplus
}
#endif
@@ -410,7 +398,7 @@ DdeSetServerName(
Tcl_ListObjIndex(interp, srvPtrPtr[n], 1, &namePtr);
Tcl_DStringInit(&ds);
- Tcl_UtfToWCharDString(Tcl_GetString(namePtr), -1, &ds);
+ Tcl_UtfToWCharDString(Tcl_GetString(namePtr), TCL_INDEX_NONE, &ds);
if (wcscmp(actualName, (WCHAR *)Tcl_DStringValue(&ds)) == 0) {
suffix++;
Tcl_DStringFree(&ds);
@@ -568,7 +556,7 @@ ExecuteRemoteObject(
if ((riPtr->handlerPtr == NULL) && Tcl_IsSafe(riPtr->interp)) {
Tcl_SetObjResult(riPtr->interp, Tcl_NewStringObj("permission denied: "
"a handler procedure must be defined for use in a safe "
- "interp", -1));
+ "interp", TCL_INDEX_NONE));
Tcl_SetErrorCode(riPtr->interp, "TCL", "DDE", "SECURITY_CHECK", NULL);
result = TCL_ERROR;
}
@@ -647,7 +635,7 @@ DdeServerProc(
/* Transaction-dependent data. */
{
Tcl_DString dString;
- size_t len;
+ Tcl_Size len;
DWORD dlen;
WCHAR *utilString;
Tcl_Obj *ddeObjectPtr;
@@ -767,8 +755,7 @@ DdeServerProc(
CP_WINUNICODE);
if (_wcsicmp(utilString, TCL_DDE_EXECUTE_RESULT) == 0) {
returnString =
- Tcl_GetString(convPtr->returnPackagePtr);
- len = convPtr->returnPackagePtr->length;
+ Tcl_GetStringFromObj(convPtr->returnPackagePtr, &len);
if (uFmt != CF_TEXT) {
Tcl_DStringInit(&dsBuf);
Tcl_UtfToWCharDString(returnString, len, &dsBuf);
@@ -790,8 +777,7 @@ DdeServerProc(
convPtr->riPtr->interp, Tcl_DStringValue(&ds), NULL,
TCL_GLOBAL_ONLY);
if (variableObjPtr != NULL) {
- returnString = Tcl_GetString(variableObjPtr);
- len = variableObjPtr->length;
+ returnString = Tcl_GetStringFromObj(variableObjPtr, &len);
if (uFmt != CF_TEXT) {
Tcl_DStringInit(&dsBuf);
Tcl_UtfToWCharDString(returnString, len, &dsBuf);
@@ -852,7 +838,7 @@ DdeServerProc(
Tcl_WCharToUtfDString(utilString, wcslen(utilString), &ds2);
utilString = (WCHAR *) Tcl_DStringValue(&ds2);
}
- variableObjPtr = Tcl_NewStringObj((char *)utilString, -1);
+ variableObjPtr = Tcl_NewStringObj((char *)utilString, TCL_INDEX_NONE);
Tcl_SetVar2Ex(convPtr->riPtr->interp, Tcl_DStringValue(&ds), NULL,
variableObjPtr, TCL_GLOBAL_ONLY);
@@ -1147,12 +1133,12 @@ DdeServicesOnAck(
GlobalGetAtomNameW(service, sz, 255);
Tcl_DStringInit(&dString);
Tcl_WCharToUtfDString(sz, wcslen(sz), &dString);
- Tcl_ListObjAppendElement(NULL, matchPtr, Tcl_NewStringObj(Tcl_DStringValue(&dString), -1));
+ Tcl_ListObjAppendElement(NULL, matchPtr, Tcl_NewStringObj(Tcl_DStringValue(&dString), TCL_INDEX_NONE));
Tcl_DStringFree(&dString);
GlobalGetAtomNameW(topic, sz, 255);
Tcl_DStringInit(&dString);
Tcl_WCharToUtfDString(sz, wcslen(sz), &dString);
- Tcl_ListObjAppendElement(NULL, matchPtr, Tcl_NewStringObj(Tcl_DStringValue(&dString), -1));
+ Tcl_ListObjAppendElement(NULL, matchPtr, Tcl_NewStringObj(Tcl_DStringValue(&dString), TCL_INDEX_NONE));
Tcl_DStringFree(&dString);
/*
@@ -1270,7 +1256,7 @@ SetDdeError(
errorCode = "FAILED";
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(errorMessage, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(errorMessage, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "DDE", errorCode, NULL);
}
@@ -1325,7 +1311,7 @@ DdeObjCmd(
};
int index, i, argIndex;
- size_t length;
+ Tcl_Size length;
int flags = 0, result = TCL_OK, firstArg = 0;
HSZ ddeService = NULL, ddeTopic = NULL, ddeItem = NULL, ddeCookie = NULL;
HDDEDATA ddeData = NULL, ddeItemData = NULL, ddeReturn;
@@ -1488,9 +1474,8 @@ DdeObjCmd(
Initialize();
if (firstArg != 1) {
- const char *src = Tcl_GetString(objv[firstArg]);
+ const char *src = Tcl_GetStringFromObj(objv[firstArg], &length);
- length = objv[firstArg]->length;
Tcl_DStringInit(&serviceBuf);
Tcl_UtfToWCharDString(src, length, &serviceBuf);
serviceName = (WCHAR *) Tcl_DStringValue(&serviceBuf);
@@ -1507,9 +1492,8 @@ DdeObjCmd(
}
if ((index != DDE_SERVERNAME) && (index != DDE_EVAL)) {
- const char *src = Tcl_GetString(objv[firstArg + 1]);
+ const char *src = Tcl_GetStringFromObj(objv[firstArg + 1], &length);
- length = objv[firstArg + 1]->length;
Tcl_DStringInit(&topicBuf);
topicName = Tcl_UtfToWCharDString(src, length, &topicBuf);
length = Tcl_DStringLength(&topicBuf) / sizeof(WCHAR);
@@ -1539,19 +1523,18 @@ DdeObjCmd(
break;
case DDE_EXECUTE: {
- size_t dataLength;
+ Tcl_Size dataLength;
const void *dataString;
Tcl_DString dsBuf;
Tcl_DStringInit(&dsBuf);
if (flags & DDE_FLAG_BINARY) {
dataString =
- getByteArrayFromObj(objv[firstArg + 2], &dataLength);
+ Tcl_GetByteArrayFromObj(objv[firstArg + 2], &dataLength);
} else {
const char *src;
- src = Tcl_GetString(objv[firstArg + 2]);
- dataLength = objv[firstArg + 2]->length;
+ src = Tcl_GetStringFromObj(objv[firstArg + 2], &dataLength);
Tcl_DStringInit(&dsBuf);
dataString =
Tcl_UtfToWCharDString(src, dataLength, &dsBuf);
@@ -1560,7 +1543,7 @@ DdeObjCmd(
if (dataLength + 1 < 2) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("cannot execute null data", -1));
+ Tcl_NewStringObj("cannot execute null data", TCL_INDEX_NONE));
Tcl_DStringFree(&dsBuf);
Tcl_SetErrorCode(interp, "TCL", "DDE", "NULL", NULL);
result = TCL_ERROR;
@@ -1604,15 +1587,14 @@ DdeObjCmd(
const WCHAR *itemString;
const char *src;
- src = Tcl_GetString(objv[firstArg + 2]);
- length = objv[firstArg + 2]->length;
+ src = Tcl_GetStringFromObj(objv[firstArg + 2], &length);
Tcl_DStringInit(&itemBuf);
itemString = Tcl_UtfToWCharDString(src, length, &itemBuf);
length = Tcl_DStringLength(&itemBuf) / sizeof(WCHAR);
if (length == 0) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("cannot request value of null data", -1));
+ Tcl_NewStringObj("cannot request value of null data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "DDE", "NULL", NULL);
result = TCL_ERROR;
goto cleanup;
@@ -1672,14 +1654,13 @@ DdeObjCmd(
BYTE *dataString;
const char *src;
- src = Tcl_GetString(objv[firstArg + 2]);
- length = objv[firstArg + 2]->length;
+ src = Tcl_GetStringFromObj(objv[firstArg + 2], &length);
Tcl_DStringInit(&itemBuf);
itemString = Tcl_UtfToWCharDString(src, length, &itemBuf);
length = Tcl_DStringLength(&itemBuf) / sizeof(WCHAR);
if (length == 0) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("cannot have a null item", -1));
+ Tcl_NewStringObj("cannot have a null item", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "DDE", "NULL", NULL);
result = TCL_ERROR;
goto cleanup;
@@ -1687,11 +1668,10 @@ DdeObjCmd(
Tcl_DStringInit(&dsBuf);
if (flags & DDE_FLAG_BINARY) {
dataString = (BYTE *)
- getByteArrayFromObj(objv[firstArg + 3], &length);
+ Tcl_GetByteArrayFromObj(objv[firstArg + 3], &length);
} else {
const char *data =
- Tcl_GetString(objv[firstArg + 3]);
- length = objv[firstArg + 3]->length;
+ Tcl_GetStringFromObj(objv[firstArg + 3], &length);
Tcl_DStringInit(&dsBuf);
dataString = (BYTE *)
Tcl_UtfToWCharDString(data, length, &dsBuf);
@@ -1734,7 +1714,7 @@ DdeObjCmd(
if (serviceName == NULL) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("invalid service name \"\"", -1));
+ Tcl_NewStringObj("invalid service name \"\"", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "DDE", "NO_SERVER", NULL);
result = TCL_ERROR;
goto cleanup;
@@ -1782,7 +1762,7 @@ DdeObjCmd(
if (Tcl_IsSafe(riPtr->interp) && (riPtr->handlerPtr == NULL)) {
Tcl_SetObjResult(riPtr->interp, Tcl_NewStringObj(
"permission denied: a handler procedure must be"
- " defined for use in a safe interp", -1));
+ " defined for use in a safe interp", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "DDE", "SECURITY_CHECK",
NULL);
result = TCL_ERROR;
@@ -1848,15 +1828,14 @@ DdeObjCmd(
if (MakeDdeConnection(interp, serviceName, &hConv) != TCL_OK) {
invalidServerResponse:
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("invalid data returned from server", -1));
+ Tcl_NewStringObj("invalid data returned from server", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "DDE", "BAD_RESPONSE", NULL);
result = TCL_ERROR;
goto cleanup;
}
objPtr = Tcl_ConcatObj(objc, objv);
- string = Tcl_GetString(objPtr);
- length = objPtr->length;
+ string = Tcl_GetStringFromObj(objPtr, &length);
Tcl_DStringInit(&dsBuf);
Tcl_UtfToWCharDString(string, length, &dsBuf);
string = Tcl_DStringValue(&dsBuf);
@@ -1906,7 +1885,7 @@ DdeObjCmd(
length = DdeGetData(ddeData, NULL, 0, 0);
ddeDataString = (WCHAR *) Tcl_Alloc(length);
DdeGetData(ddeData, (BYTE *) ddeDataString, (DWORD) length, 0);
- if (length > sizeof(WCHAR)) {
+ if (length > (Tcl_Size)sizeof(WCHAR)) {
length -= sizeof(WCHAR);
}
Tcl_DStringInit(&dsBuf);
diff --git a/win/tclWinReg.c b/win/tclWinReg.c
index 2daf43e..6fafead 100644
--- a/win/tclWinReg.c
+++ b/win/tclWinReg.c
@@ -124,7 +124,7 @@ static int SetValue(Tcl_Interp *interp, Tcl_Obj *keyNameObj,
Tcl_Obj *valueNameObj, Tcl_Obj *dataObj,
Tcl_Obj *typeObj, REGSAM mode);
-#if (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7)
+#if (TCL_MAJOR_VERSION < 9) && defined(TCL_MINOR_VERSION) && (TCL_MINOR_VERSION < 7)
# if TCL_UTF_MAX > 3
# define Tcl_WCharToUtfDString(a,b,c) Tcl_WinTCharToUtf((TCHAR *)(a),(b)*sizeof(WCHAR),c)
# define Tcl_UtfToWCharDString(a,b,c) (WCHAR *)Tcl_WinUtfToTChar(a,b,c)
@@ -132,32 +132,20 @@ static int SetValue(Tcl_Interp *interp, Tcl_Obj *keyNameObj,
# define Tcl_WCharToUtfDString Tcl_UniCharToUtfDString
# define Tcl_UtfToWCharDString Tcl_UtfToUniCharDString
# endif
+#define Tcl_Size int
+#define TCL_INDEX_NONE -1
#endif
-static unsigned char *
-getByteArrayFromObj(
- Tcl_Obj *objPtr,
- size_t *lengthPtr
-) {
- int length;
-
- unsigned char *result = Tcl_GetByteArrayFromObj(objPtr, &length);
-#if TCL_MAJOR_VERSION > 8
- if (sizeof(TCL_HASH_TYPE) > sizeof(int)) {
- /* 64-bit and TIP #494 situation: */
- *lengthPtr = *(TCL_HASH_TYPE *) objPtr->internalRep.twoPtrValue.ptr1;
- } else
-#endif
- /* 32-bit or without TIP #494 */
- *lengthPtr = (size_t) (unsigned) length;
- return result;
-}
-
#ifdef __cplusplus
extern "C" {
#endif
DLLEXPORT int Registry_Init(Tcl_Interp *interp);
DLLEXPORT int Registry_Unload(Tcl_Interp *interp, int flags);
+#if TCL_MAJOR_VERSION < 9
+/* With those additional entries, "load registry13.dll" works without 3th argument */
+DLLEXPORT int Tclregistry_Init(Tcl_Interp *interp);
+DLLEXPORT int Tclregistry_SafeInit(Tcl_Interp *interp);
+#endif
#ifdef __cplusplus
}
#endif
@@ -191,8 +179,16 @@ Registry_Init(
cmd = Tcl_CreateObjCommand(interp, "registry", RegistryObjCmd,
interp, DeleteCmd);
Tcl_SetAssocData(interp, REGISTRY_ASSOC_KEY, NULL, cmd);
- return Tcl_PkgProvideEx(interp, "registry", "1.3.6", NULL);
+ return Tcl_PkgProvideEx(interp, "registry", "1.3.7", NULL);
+}
+#if TCL_MAJOR_VERSION < 9
+int
+Tclregistry_Init(
+ Tcl_Interp *interp)
+{
+ return Registry_Init(interp);
}
+#endif
/*
*----------------------------------------------------------------------
@@ -223,9 +219,9 @@ Registry_Unload(
* Unregister the registry package. There is no Tcl_PkgForget()
*/
- objv[0] = Tcl_NewStringObj("package", -1);
- objv[1] = Tcl_NewStringObj("forget", -1);
- objv[2] = Tcl_NewStringObj("registry", -1);
+ objv[0] = Tcl_NewStringObj("package", TCL_INDEX_NONE);
+ objv[1] = Tcl_NewStringObj("forget", TCL_INDEX_NONE);
+ objv[2] = Tcl_NewStringObj("registry", TCL_INDEX_NONE);
Tcl_EvalObjv(interp, 3, objv, TCL_EVAL_GLOBAL);
/*
@@ -239,6 +235,15 @@ Registry_Unload(
return TCL_OK;
}
+#if TCL_MAJOR_VERSION < 9
+int
+Tclregistry_Unload(
+ Tcl_Interp *interp,
+ int flags)
+{
+ return Registry_Unload(interp, flags);
+}
+#endif
/*
*----------------------------------------------------------------------
@@ -438,13 +443,14 @@ DeleteKey(
DWORD result;
Tcl_DString buf;
REGSAM saveMode = mode;
+ Tcl_Size len;
/*
* Find the parent of the key being deleted and open it.
*/
- keyName = Tcl_GetString(keyNameObj);
- buffer = (char *)Tcl_Alloc(keyNameObj->length + 1);
+ keyName = Tcl_GetStringFromObj(keyNameObj, &len);
+ buffer = (char *)Tcl_Alloc(len + 1);
strcpy(buffer, keyName);
if (ParseKeyName(interp, buffer, &hostName, &rootKey,
@@ -455,7 +461,7 @@ DeleteKey(
if (*keyName == '\0') {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("bad key: cannot delete root keys", -1));
+ Tcl_NewStringObj("bad key: cannot delete root keys", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "WIN_REG", "DEL_ROOT_KEY", NULL);
Tcl_Free(buffer);
return TCL_ERROR;
@@ -477,7 +483,7 @@ DeleteKey(
return TCL_OK;
}
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("unable to delete key: ", -1));
+ Tcl_NewStringObj("unable to delete key: ", TCL_INDEX_NONE));
AppendSystemError(interp, result);
return TCL_ERROR;
}
@@ -487,13 +493,13 @@ DeleteKey(
*/
Tcl_DStringInit(&buf);
- nativeTail = Tcl_UtfToWCharDString(tail, -1, &buf);
+ nativeTail = Tcl_UtfToWCharDString(tail, TCL_INDEX_NONE, &buf);
result = RecursiveDeleteKey(subkey, nativeTail, saveMode);
Tcl_DStringFree(&buf);
if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("unable to delete key: ", -1));
+ Tcl_NewStringObj("unable to delete key: ", TCL_INDEX_NONE));
AppendSystemError(interp, result);
result = TCL_ERROR;
} else {
@@ -532,6 +538,7 @@ DeleteValue(
char *valueName;
DWORD result;
Tcl_DString ds;
+ Tcl_Size len;
/*
* Attempt to open the key for deletion.
@@ -542,9 +549,9 @@ DeleteValue(
return TCL_ERROR;
}
- valueName = Tcl_GetString(valueNameObj);
+ valueName = Tcl_GetStringFromObj(valueNameObj, &len);
Tcl_DStringInit(&ds);
- Tcl_UtfToWCharDString(valueName, valueNameObj->length, &ds);
+ Tcl_UtfToWCharDString(valueName, len, &ds);
result = RegDeleteValueW(key, (const WCHAR *)Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
if (result != ERROR_SUCCESS) {
@@ -685,6 +692,7 @@ GetType(
Tcl_DString ds;
const char *valueName;
const WCHAR *nativeValue;
+ Tcl_Size len;
/*
* Attempt to open the key for reading.
@@ -699,9 +707,9 @@ GetType(
* Get the type of the value.
*/
- valueName = Tcl_GetString(valueNameObj);
+ valueName = Tcl_GetStringFromObj(valueNameObj, &len);
Tcl_DStringInit(&ds);
- nativeValue = Tcl_UtfToWCharDString(valueName, valueNameObj->length, &ds);
+ nativeValue = Tcl_UtfToWCharDString(valueName, len, &ds);
result = RegQueryValueExW(key, nativeValue, NULL, &type,
NULL, NULL);
Tcl_DStringFree(&ds);
@@ -723,7 +731,7 @@ GetType(
if (type > lastType) {
Tcl_SetObjResult(interp, Tcl_NewIntObj((int) type));
} else {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(typeNames[type], -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(typeNames[type], TCL_INDEX_NONE));
}
return TCL_OK;
}
@@ -757,6 +765,7 @@ GetValue(
const WCHAR *nativeValue;
DWORD result, length, type;
Tcl_DString data, buf;
+ Tcl_Size len;
/*
* Attempt to open the key for reading.
@@ -781,9 +790,9 @@ GetValue(
Tcl_DStringSetLength(&data, TCL_DSTRING_STATIC_SIZE - 1);
length = TCL_DSTRING_STATIC_SIZE/sizeof(WCHAR) - 1;
- valueName = Tcl_GetString(valueNameObj);
+ valueName = Tcl_GetStringFromObj(valueNameObj, &len);
Tcl_DStringInit(&buf);
- nativeValue = Tcl_UtfToWCharDString(valueName, valueNameObj->length, &buf);
+ nativeValue = Tcl_UtfToWCharDString(valueName, len, &buf);
result = RegQueryValueExW(key, nativeValue, NULL, &type,
(BYTE *) Tcl_DStringValue(&data), &length);
@@ -975,9 +984,10 @@ OpenKey(
char *keyName, *buffer, *hostName;
HKEY rootKey;
DWORD result;
+ Tcl_Size len;
- keyName = Tcl_GetString(keyNameObj);
- buffer = (char *)Tcl_Alloc(keyNameObj->length + 1);
+ keyName = Tcl_GetStringFromObj(keyNameObj, &len);
+ buffer = (char *)Tcl_Alloc(len + 1);
strcpy(buffer, keyName);
result = ParseKeyName(interp, buffer, &hostName, &rootKey, &keyName);
@@ -985,7 +995,7 @@ OpenKey(
result = OpenSubKey(hostName, rootKey, keyName, mode, flags, keyPtr);
if (result != ERROR_SUCCESS) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("unable to open key: ", -1));
+ Tcl_NewStringObj("unable to open key: ", TCL_INDEX_NONE));
AppendSystemError(interp, result);
result = TCL_ERROR;
} else {
@@ -1033,7 +1043,7 @@ OpenSubKey(
if (hostName) {
Tcl_DStringInit(&buf);
- hostName = (char *) Tcl_UtfToWCharDString(hostName, -1, &buf);
+ hostName = (char *) Tcl_UtfToWCharDString(hostName, TCL_INDEX_NONE, &buf);
result = RegConnectRegistryW((WCHAR *)hostName, rootKey,
&rootKey);
Tcl_DStringFree(&buf);
@@ -1049,7 +1059,7 @@ OpenSubKey(
if (keyName) {
Tcl_DStringInit(&buf);
- keyName = (char *) Tcl_UtfToWCharDString(keyName, -1, &buf);
+ keyName = (char *) Tcl_UtfToWCharDString(keyName, TCL_INDEX_NONE, &buf);
}
if (flags & REG_CREATE) {
DWORD create;
@@ -1153,7 +1163,7 @@ ParseKeyName(
* Look for a matching root name.
*/
- rootObj = Tcl_NewStringObj(rootName, -1);
+ rootObj = Tcl_NewStringObj(rootName, TCL_INDEX_NONE);
result = Tcl_GetIndexFromObj(interp, rootObj, rootKeyNames, "root name",
TCL_EXACT, &index);
Tcl_DecrRefCount(rootObj);
@@ -1285,6 +1295,7 @@ SetValue(
HKEY key;
const char *valueName;
Tcl_DString nameBuf;
+ Tcl_Size len;
if (typeObj == NULL) {
type = REG_SZ;
@@ -1300,9 +1311,9 @@ SetValue(
return TCL_ERROR;
}
- valueName = Tcl_GetString(valueNameObj);
+ valueName = Tcl_GetStringFromObj(valueNameObj, &len);
Tcl_DStringInit(&nameBuf);
- valueName = (char *) Tcl_UtfToWCharDString(valueName, valueNameObj->length, &nameBuf);
+ valueName = (char *) Tcl_UtfToWCharDString(valueName, len, &nameBuf);
if (type == REG_DWORD || type == REG_DWORD_BIG_ENDIAN) {
int value;
@@ -1335,9 +1346,9 @@ SetValue(
Tcl_DStringInit(&data);
for (i = 0; i < objc; i++) {
- const char *bytes = Tcl_GetString(objv[i]);
+ const char *bytes = Tcl_GetStringFromObj(objv[i], &len);
- Tcl_DStringAppend(&data, bytes, objv[i]->length);
+ Tcl_DStringAppend(&data, bytes, len);
/*
* Add a null character to separate this value from the next.
@@ -1356,10 +1367,10 @@ SetValue(
Tcl_DStringFree(&buf);
} else if (type == REG_SZ || type == REG_EXPAND_SZ) {
Tcl_DString buf;
- const char *data = Tcl_GetString(dataObj);
+ const char *data = Tcl_GetStringFromObj(dataObj, &len);
Tcl_DStringInit(&buf);
- data = (char *) Tcl_UtfToWCharDString(data, dataObj->length, &buf);
+ data = (char *) Tcl_UtfToWCharDString(data, len, &buf);
/*
* Include the null in the length, padding if needed for WCHAR.
@@ -1372,13 +1383,13 @@ SetValue(
Tcl_DStringFree(&buf);
} else {
BYTE *data;
- size_t bytelength;
+ Tcl_Size bytelength;
/*
* Store binary data in the registry.
*/
- data = (BYTE *) getByteArrayFromObj(dataObj, &bytelength);
+ data = (BYTE *) Tcl_GetByteArrayFromObj(dataObj, &bytelength);
result = RegSetValueExW(key, (WCHAR *) valueName, 0,
(DWORD) type, data, (DWORD) bytelength);
}
@@ -1388,7 +1399,7 @@ SetValue(
if (result != ERROR_SUCCESS) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("unable to set value: ", -1));
+ Tcl_NewStringObj("unable to set value: ", TCL_INDEX_NONE));
AppendSystemError(interp, result);
return TCL_ERROR;
}
@@ -1421,15 +1432,14 @@ BroadcastValue(
LRESULT result;
DWORD_PTR sendResult;
int timeout = 3000;
- size_t len;
+ Tcl_Size len;
const char *str;
Tcl_Obj *objPtr;
WCHAR *wstr;
Tcl_DString ds;
if (objc == 3) {
- str = Tcl_GetString(objv[1]);
- len = objv[1]->length;
+ str = Tcl_GetStringFromObj(objv[1], &len);
if ((len < 2) || (*str != '-') || strncmp(str, "-timeout", len)) {
return TCL_BREAK;
}
@@ -1438,9 +1448,9 @@ BroadcastValue(
}
}
- str = Tcl_GetString(objv[0]);
+ str = Tcl_GetStringFromObj(objv[0], &len);
Tcl_DStringInit(&ds);
- wstr = Tcl_UtfToWCharDString(str, objv[0]->length, &ds);
+ wstr = Tcl_UtfToWCharDString(str, len, &ds);
if (Tcl_DStringLength(&ds) == 0) {
wstr = NULL;
}