From 43cfbcbda332e1e6b93a41f0ac7a2c98be3bb1f6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 3 Apr 2022 11:55:39 +0000 Subject: Fix building against Tcl 8.6 headers --- generic/tkConsole.c | 4 ++-- generic/tkFileFilter.c | 4 ++-- generic/tkInt.h | 9 +++++++-- macosx/tkMacOSXBitmap.c | 4 ++-- macosx/tkMacOSXHLEvents.c | 2 +- unix/tkUnixFont.c | 6 +++--- unix/tkUnixKey.c | 2 +- unix/tkUnixSelect.c | 4 ++-- unix/tkUnixSysNotify.c | 4 ++-- unix/tkUnixWm.c | 18 +++++++++--------- win/tkWinClipboard.c | 2 +- win/tkWinFont.c | 8 ++++---- win/tkWinKey.c | 2 +- win/tkWinTest.c | 4 ++-- 14 files changed, 39 insertions(+), 34 deletions(-) diff --git a/generic/tkConsole.c b/generic/tkConsole.c index 15f4490..4ed4cde 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -517,8 +517,8 @@ ConsoleOutput( * Assumption is utf-8 Tcl_Encoding is reliably present. */ - const char *bytes - = Tcl_ExternalToUtfDString(utf8, buf, toWrite, &ds); + Tcl_ExternalToUtfDStringEx(utf8, buf, toWrite, TCL_ENCODING_NOCOMPLAIN, &ds); + const char *bytes = Tcl_DStringValue(&ds); int numBytes = Tcl_DStringLength(&ds); Tcl_Obj *cmd = Tcl_NewStringObj("tk::ConsoleOutput", -1); diff --git a/generic/tkFileFilter.c b/generic/tkFileFilter.c index 99eb626..47f8802 100644 --- a/generic/tkFileFilter.c +++ b/generic/tkFileFilter.c @@ -286,7 +286,7 @@ AddClause( * be 4 macRoman characters long */ - Tcl_UtfToExternalDStringEx(macRoman, strType, len, TCL_ENCODING_NOCOMPLAIN, &osTypeDS); + (void)Tcl_UtfToExternalDStringEx(macRoman, strType, len, TCL_ENCODING_NOCOMPLAIN, &osTypeDS); len = Tcl_DStringLength(&osTypeDS); Tcl_DStringFree(&osTypeDS); } @@ -385,7 +385,7 @@ AddClause( * macRoman characters long */ - Tcl_UtfToExternalDStringEx(macRoman, strType, len, TCL_ENCODING_NOCOMPLAIN, &osTypeDS); + (void)Tcl_UtfToExternalDStringEx(macRoman, strType, len, TCL_ENCODING_NOCOMPLAIN, &osTypeDS); string = Tcl_DStringValue(&osTypeDS); mfPtr->type = (OSType) string[0] << 24 | (OSType) string[1] << 16 | (OSType) string[2] << 8 | (OSType) string[3]; diff --git a/generic/tkInt.h b/generic/tkInt.h index 38f830a..1d37dbc 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -99,14 +99,19 @@ # undef Tcl_UtfToExternalDStringEx /* just assume 'flags' is TCL_ENCODING_NOCOMPLAIN, and return value not used. */ # define Tcl_ExternalToUtfDStringEx(encoding, data, length, flags, ds) \ - (void)Tcl_ExternalToUtfDString(encoding, data, length, ds) + (Tcl_ExternalToUtfDString(encoding, data, length, ds), TCL_INDEX_NONE) # define Tcl_UtfToExternalDStringEx(encoding, data, length, flags, ds) \ - (void)Tcl_UtfToExternalDString(encoding, data, length, ds) + (Tcl_UtfToExternalDString(encoding, data, length, ds), TCL_INDEX_NONE) # if !defined(Tcl_GetParent) && (TCL_MINOR_VERSION < 7) # define Tcl_GetParent Tcl_GetMaster # endif #endif + +#ifndef TCL_ENCODING_NOCOMPLAIN +# define TCL_ENCODING_NOCOMPLAIN 0 +#endif + /* * Macros used to cast between pointers and integers (e.g. when storing an int * in ClientData), on 64-bit architectures they avoid gcc warning about "cast diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c index 4c6f31a..e26c5bb 100644 --- a/macosx/tkMacOSXBitmap.c +++ b/macosx/tkMacOSXBitmap.c @@ -205,7 +205,7 @@ OSTypeFromString(const char *s, OSType *t) { Tcl_DString ds; Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman"); - Tcl_UtfToExternalDStringEx(encoding, s, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_UtfToExternalDStringEx(encoding, s, -1, TCL_ENCODING_NOCOMPLAIN, &ds); if (Tcl_DStringLength(&ds) <= 4) { char string[4] = {}; memcpy(string, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); @@ -384,7 +384,7 @@ TkMacOSXIconBitmapObjCmd( Tcl_DString ds; Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman"); - Tcl_UtfToExternalDStringEx(encoding, value, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_UtfToExternalDStringEx(encoding, value, -1, TCL_ENCODING_NOCOMPLAIN, &ds); len = Tcl_DStringLength(&ds); Tcl_DStringFree(&ds); Tcl_FreeEncoding(encoding); diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index ef6237e..40f9dba 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -227,7 +227,7 @@ static const char getSdefProc[] = "::tk::mac::GetDynamicSdef"; if (fileURL == nil) { continue; } - Tcl_ExternalToUtfDStringEx(utf8, [[fileURL path] UTF8String], -1, + (void)Tcl_ExternalToUtfDStringEx(utf8, [[fileURL path] UTF8String], -1, TCL_ENCODING_NOCOMPLAIN, &pathName); Tcl_DStringAppendElement(openCommand, Tcl_DStringValue(&pathName)); Tcl_DStringFree(&pathName); diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 6ef43b7..1cf7b9b 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -1064,7 +1064,7 @@ Tk_MeasureChars( thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { familyPtr = lastSubFontPtr->familyPtr; - Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, + (void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, TCL_ENCODING_NOCOMPLAIN, p - source, &runString); if (familyPtr->isTwoByteFont) { curX += XTextWidth16(lastSubFontPtr->fontStructPtr, @@ -1082,7 +1082,7 @@ Tk_MeasureChars( p = next; } familyPtr = lastSubFontPtr->familyPtr; - Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, p - source, + (void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, p - source, TCL_ENCODING_NOCOMPLAIN, &runString); if (familyPtr->isTwoByteFont) { curX += XTextWidth16(lastSubFontPtr->fontStructPtr, @@ -1331,7 +1331,7 @@ Tk_DrawChars( do_width = (needWidth || (p != end)) ? 1 : 0; familyPtr = lastSubFontPtr->familyPtr; - Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, + (void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, p - source, TCL_ENCODING_NOCOMPLAIN, &runString); if (familyPtr->isTwoByteFont) { XDrawString16(display, drawable, gc, x, y, diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 008030a..16adcf3 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -175,7 +175,7 @@ TkpGetString( len = 0; } Tcl_DStringSetLength(&buf, len); - Tcl_ExternalToUtfDStringEx(NULL, Tcl_DStringValue(&buf), len, TCL_ENCODING_NOCOMPLAIN, dsPtr); + (void)Tcl_ExternalToUtfDStringEx(NULL, Tcl_DStringValue(&buf), len, TCL_ENCODING_NOCOMPLAIN, dsPtr); Tcl_DStringFree(&buf); #endif /* X_HAVE_UTF8_STRING */ } else diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c index 29a7b2e..6ef8666 100644 --- a/unix/tkUnixSelect.c +++ b/unix/tkUnixSelect.c @@ -620,7 +620,7 @@ TkSelEventProc( } else { encoding = Tcl_GetEncoding(NULL, "iso8859-1"); } - Tcl_ExternalToUtfDStringEx(encoding, propInfo, numItems, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_ExternalToUtfDStringEx(encoding, propInfo, numItems, TCL_ENCODING_NOCOMPLAIN, &ds); if (encoding) { Tcl_FreeEncoding(encoding); } @@ -995,7 +995,7 @@ ConvertSelection( } else { encoding = Tcl_GetEncoding(NULL, "iso2022"); } - Tcl_UtfToExternalDStringEx(encoding, (char *) buffer, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_UtfToExternalDStringEx(encoding, (char *) buffer, -1, TCL_ENCODING_NOCOMPLAIN, &ds); XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, 8, PropModeReplace, (unsigned char *) Tcl_DStringValue(&ds), diff --git a/unix/tkUnixSysNotify.c b/unix/tkUnixSysNotify.c index cb9606c..8f5a972 100755 --- a/unix/tkUnixSysNotify.c +++ b/unix/tkUnixSysNotify.c @@ -145,8 +145,8 @@ SysNotifyCmd( Tcl_DStringInit(&dst); Tcl_DStringInit(&dsm); enc = Tcl_GetEncoding(NULL, "utf-8"); - Tcl_UtfToExternalDStringEx(enc, title, -1, TCL_ENCODING_NOCOMPLAIN, &dst); - Tcl_UtfToExternalDStringEx(enc, message, -1, TCL_ENCODING_NOCOMPLAIN, &dsm); + (void)Tcl_UtfToExternalDStringEx(enc, title, -1, TCL_ENCODING_NOCOMPLAIN, &dst); + (void)Tcl_UtfToExternalDStringEx(enc, message, -1, TCL_ENCODING_NOCOMPLAIN, &dsm); notify_init(appname); notif = notify_notification_new(Tcl_DStringValue(&dst), Tcl_DStringValue(&dsm), icon, NULL); diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index e57c586..3f69f8a 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -713,7 +713,7 @@ TkWmMapWindow( UpdateCommand(winPtr); } if (wmPtr->clientMachine != NULL) { - Tcl_UtfToExternalDStringEx(NULL, wmPtr->clientMachine, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_UtfToExternalDStringEx(NULL, wmPtr->clientMachine, -1, TCL_ENCODING_NOCOMPLAIN, &ds); if (XStringListToTextProperty(&(Tcl_DStringValue(&ds)), 1, &textProp) != 0) { unsigned long pid = (unsigned long) getpid(); @@ -985,8 +985,8 @@ TkWmSetClass( XClassHint *classPtr; Tcl_DString name, ds; - Tcl_UtfToExternalDStringEx(NULL, winPtr->nameUid, -1, TCL_ENCODING_NOCOMPLAIN, &name); - Tcl_UtfToExternalDStringEx(NULL, winPtr->classUid, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_UtfToExternalDStringEx(NULL, winPtr->nameUid, -1, TCL_ENCODING_NOCOMPLAIN, &name); + (void)Tcl_UtfToExternalDStringEx(NULL, winPtr->classUid, -1, TCL_ENCODING_NOCOMPLAIN, &ds); classPtr = XAllocClassHint(); classPtr->res_name = Tcl_DStringValue(&name); classPtr->res_class = Tcl_DStringValue(&ds); @@ -1494,7 +1494,7 @@ WmClientCmd( XTextProperty textProp; Tcl_DString ds; - Tcl_UtfToExternalDStringEx(NULL, wmPtr->clientMachine, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_UtfToExternalDStringEx(NULL, wmPtr->clientMachine, -1, TCL_ENCODING_NOCOMPLAIN, &ds); if (XStringListToTextProperty(&(Tcl_DStringValue(&ds)), 1, &textProp) != 0) { unsigned long pid = (unsigned long) getpid(); @@ -4979,7 +4979,7 @@ UpdateTitle( */ string = (wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid; - Tcl_UtfToExternalDStringEx(NULL, string, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_UtfToExternalDStringEx(NULL, string, -1, TCL_ENCODING_NOCOMPLAIN, &ds); XStoreName(winPtr->display, wmPtr->wrapperPtr->window, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); @@ -4992,7 +4992,7 @@ UpdateTitle( */ if (wmPtr->iconName != NULL) { - Tcl_UtfToExternalDStringEx(NULL, wmPtr->iconName, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_UtfToExternalDStringEx(NULL, wmPtr->iconName, -1, TCL_ENCODING_NOCOMPLAIN, &ds); XSetIconName(winPtr->display, wmPtr->wrapperPtr->window, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); @@ -5512,7 +5512,7 @@ SetNetWmType( char *name = Tcl_GetStringFromObj(objv[n], &len); Tcl_UtfToUpper(name); - Tcl_UtfToExternalDStringEx(NULL, name, len, TCL_ENCODING_NOCOMPLAIN, &dsName); + (void)Tcl_UtfToExternalDStringEx(NULL, name, len, TCL_ENCODING_NOCOMPLAIN, &dsName); Tcl_DStringInit(&ds); Tcl_DStringAppend(&ds, "_NET_WM_WINDOW_TYPE_", 20); Tcl_DStringAppend(&ds, Tcl_DStringValue(&dsName), @@ -5576,7 +5576,7 @@ GetNetWmType( const char *name = Tk_GetAtomName(tkwin, atoms[n]); if (strncmp("_NET_WM_WINDOW_TYPE_", name, 20) == 0) { - Tcl_ExternalToUtfDStringEx(NULL, name+20, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_ExternalToUtfDStringEx(NULL, name+20, -1, TCL_ENCODING_NOCOMPLAIN, &ds); Tcl_UtfToLower(Tcl_DStringValue(&ds)); Tcl_ListObjAppendElement(interp, typePtr, Tcl_NewStringObj(Tcl_DStringValue(&ds), @@ -7386,7 +7386,7 @@ UpdateCommand( offsets = (int *)ckalloc(sizeof(int) * wmPtr->cmdArgc); Tcl_DStringInit(&cmds); for (i = 0; i < wmPtr->cmdArgc; i++) { - Tcl_UtfToExternalDStringEx(NULL, wmPtr->cmdArgv[i], -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_UtfToExternalDStringEx(NULL, wmPtr->cmdArgv[i], -1, TCL_ENCODING_NOCOMPLAIN, &ds); offsets[i] = Tcl_DStringLength(&cmds); Tcl_DStringAppend(&cmds, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)+1); diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 18c7344..56fece8 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -132,7 +132,7 @@ TkSelGetSelection( goto error; } data = (char *)GlobalLock(handle); - Tcl_ExternalToUtfDStringEx(encoding, data, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_ExternalToUtfDStringEx(encoding, data, -1, TCL_ENCODING_NOCOMPLAIN, &ds); GlobalUnlock(handle); if (encoding) { Tcl_FreeEncoding(encoding); diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 15d042c..ddee969 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -849,7 +849,7 @@ Tk_MeasureChars( thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { familyPtr = lastSubFontPtr->familyPtr; - Tcl_UtfToExternalDStringEx(familyPtr->encoding, start, + (void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, start, p - start, TCL_ENCODING_NOCOMPLAIN, &runString); size.cx = 0; familyPtr->getTextExtentPoint32Proc(hdc, @@ -877,7 +877,7 @@ Tk_MeasureChars( */ familyPtr = lastSubFontPtr->familyPtr; - Tcl_UtfToExternalDStringEx(familyPtr->encoding, start, + (void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, start, p - start, TCL_ENCODING_NOCOMPLAIN, &runString); size.cx = 0; familyPtr->getTextExtentPoint32Proc(hdc, (WCHAR *) Tcl_DStringValue(&runString), @@ -1493,7 +1493,7 @@ MultiFontTextOut( if ((thisSubFontPtr != lastSubFontPtr) || (p-source > 200)) { if (p > source) { familyPtr = lastSubFontPtr->familyPtr; - Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, + (void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, p - source, TCL_ENCODING_NOCOMPLAIN, &runString); familyPtr->textOutProc(hdc, (int)(x-(double)tm.tmOverhang/2.0), y, (WCHAR *)Tcl_DStringValue(&runString), @@ -1515,7 +1515,7 @@ MultiFontTextOut( } if (p > source) { familyPtr = lastSubFontPtr->familyPtr; - Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, + (void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, p - source, TCL_ENCODING_NOCOMPLAIN, &runString); familyPtr->textOutProc(hdc, (int)(x-(double)tm.tmOverhang/2.0), y, (WCHAR *)Tcl_DStringValue(&runString), diff --git a/win/tkWinKey.c b/win/tkWinKey.c index ebd39e0..a8257af 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -104,7 +104,7 @@ TkpGetString( if (keyEv->send_event == -1) { TkKeyEvent *ev = (TkKeyEvent *)keyEv; if (ev->nbytes > 0) { - Tcl_ExternalToUtfDStringEx(TkWinGetKeyInputEncoding(), + (void)Tcl_ExternalToUtfDStringEx(TkWinGetKeyInputEncoding(), ev->trans_chars, ev->nbytes, TCL_ENCODING_NOCOMPLAIN, dsPtr); } } else if (keyEv->send_event == -3) { diff --git a/win/tkWinTest.c b/win/tkWinTest.c index a163c92..057395d 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -381,7 +381,7 @@ TestwineventObjCmd( SendMessageA(control, WM_GETTEXT, (WPARAM)sizeof(buf), (LPARAM) buf); #endif - Tcl_ExternalToUtfDStringEx(NULL, buf, -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_ExternalToUtfDStringEx(NULL, buf, -1, TCL_ENCODING_NOCOMPLAIN, &ds); Tcl_AppendResult(interp, Tcl_DStringValue(&ds), NULL); Tcl_DStringFree(&ds); break; @@ -396,7 +396,7 @@ TestwineventObjCmd( return TCL_ERROR; } Tcl_DStringInit(&ds); - Tcl_UtfToExternalDStringEx(NULL, Tcl_GetString(objv[4]), -1, TCL_ENCODING_NOCOMPLAIN, &ds); + (void)Tcl_UtfToExternalDStringEx(NULL, Tcl_GetString(objv[4]), -1, TCL_ENCODING_NOCOMPLAIN, &ds); result = SendMessageA(control, WM_SETTEXT, 0, (LPARAM) Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); -- cgit v0.12