summaryrefslogtreecommitdiffstats
path: root/win/tclWinReg.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-10-30 20:39:24 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-10-30 20:39:24 (GMT)
commit74707353e824dd0dced5d646f6603f80e9647ae5 (patch)
treef6debcecd71fc39b2a2caad48558a40b6f33b6e4 /win/tclWinReg.c
parent22a5d73ebf204659f328464091641c1b71c865c1 (diff)
downloadtcl-74707353e824dd0dced5d646f6603f80e9647ae5.zip
tcl-74707353e824dd0dced5d646f6603f80e9647ae5.tar.gz
tcl-74707353e824dd0dced5d646f6603f80e9647ae5.tar.bz2
Add support for TIP #494 to registry and dde. Only effective when compiled against Tcl 9.0 headers. This way we can keep the source-code for those extensions 100% equal in all branches.
Work-around for gcc warning in tclWinFile.c. Discovered by Travis CI.
Diffstat (limited to 'win/tclWinReg.c')
-rw-r--r--win/tclWinReg.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/win/tclWinReg.c b/win/tclWinReg.c
index 0d2cd94..f93a553 100644
--- a/win/tclWinReg.c
+++ b/win/tclWinReg.c
@@ -124,6 +124,25 @@ static int SetValue(Tcl_Interp *interp, Tcl_Obj *keyNameObj,
Tcl_Obj *valueNameObj, Tcl_Obj *dataObj,
Tcl_Obj *typeObj, REGSAM mode);
+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;
+}
+
DLLEXPORT int Registry_Init(Tcl_Interp *interp);
DLLEXPORT int Registry_Unload(Tcl_Interp *interp, int flags);
@@ -1324,13 +1343,13 @@ SetValue(
Tcl_DStringFree(&buf);
} else {
BYTE *data;
- int bytelength;
+ size_t bytelength;
/*
* Store binary data in the registry.
*/
- data = (BYTE *) Tcl_GetByteArrayFromObj(dataObj, &bytelength);
+ data = (BYTE *) getByteArrayFromObj(dataObj, &bytelength);
result = RegSetValueEx(key, (TCHAR *) valueName, 0,
(DWORD) type, data, (DWORD) bytelength);
}