From: Roland Schwingel <roland@onevision.com>
To: insight@sourceware.org
Subject: [PATCH] libgui: Make it compileable on windows with recent gcc versions and also on win64
Date: Fri, 23 Mar 2012 10:22:00 -0000 [thread overview]
Message-ID: <4F6C4EB9.4000003@onevision.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 3199 bytes --]
Hi...
The attached patch fixes the major problems of libgui on native windows
(mingw) regarding compilation and 64bit. It also adjusts to new tcl/tk
versions. There are still some warnings left I have to adress later but
in the current shape it runs here now successfully for some weeks.
This is just a first rough version. More polishing here is needed. There
are also a bunch dead code in which can be removed.
Changelog:
2012-03-23 Roland Schwingel <roland.schwingel@onevision.com>
* src/subcommand.c,src/subcommand.h
(subcommand_implementation,ide_create_command_with_subcommands):
Make some params const to match tcl/tk changes.
* src/tclcursor.c (get_cursor_size,get_cursor_position): Ditto.
* src/tclmsgbox.c: Include windows.h early.
(msgbox_init,msgbox_exit): Take care about encodings to windows
functions.
(msgbox_thread): Use correct api call here.
(msgbox_internal,msgbox): Make CONST84 where needed.
* src/tclwinmode.c (seterrormode_command): Ditto.
* src/tclshellexe.c (shell_execute_command): Ditto. Plus correct
cast return
value to shut up 64bit gcc.
* src/tclwinfont.c (win_choose_font): Make CONST84 where needed and
use dedicated windows api.
* src/tclwinprint.c (winprint_page_setup_command): Make
const/CONST84 where needed.
(winprint_print_text_options,winprint_print_text_invoke,winprint_print_command):
Ditto.
(winprint_print_text_invoke,): Ditto.
(winprint_start,winprint_print_commandwinprint_abort_command): use
dedicated windows structs/api.
* src/tkTable.c: Obsolete old dprint stuff.
(StringifyObjects,Tk_TableObjCmd,TableWidgetObjCmd,TableConfigure,TableFetchSelection):
adjust const.
(selCmdNames,commandNames,updateOpts): make const.
* src/tkTable.h: Adjust windows includes. include stdint.h. define
CONST86 if missing. Deine
PTR2INT/INT2PTR taken from tcl if missing. Make some functions const.
* src/tkTableCmds.c: Make bdCmdNames and clearnames CONST84.
* src/tkTableEdit.c: Make modCmdNamesand rcCmdNames CONST84.
* src/tkTableTag.c: Make tagCmdNames CONST84.
(TableTagGetEntry): Make param argcv CONST84.
(TableInitTags): Make some internal strings CONST84.
(FindRowColTag): Ditto.
(Table_TagCmd): Ditto.
* src/tkTableUtil.c (TableOptionBdSet):Ditto.
(TableOptionBdGet): Make retval CONST86. Fix ptr/int arithmetics.
(Cmd_OptionSet): Make param value CONST84.
(Cmd_OptionGet): Make retval CONST86.
* src/tkTableWin.c (StickyPrintProc): Ditto. Make some internal
strings CONST84.
(StickyParseProc): Make param value CONST84.
* src/tkWarpPointer.c: Include windows.h ahead of tk.h.
(WarpPointer): Remove unused var.
* src/tkWinPrintCanvas.c (PrintCanvasCmd): use dedicated windows
structs/api.
Fix casting.
* src/tkWinPrintText.c (PrintTextCmd): Add #if case for compiling
against tcl 8.5 and up.
use dedicated windows structs/api.
(ide_delete_print_text_command): Delete unused static function.
(DisplayDLineToDrawable): Add #if case for compiling against tcl
8.5 and up. Fix casting.
Any comments? Is this ok?
Roland
[-- Attachment #2: libgui_src.base.patch --]
[-- Type: text/plain, Size: 31388 bytes --]
diff -ruN libgui_orig/src/subcommand.c libgui/src/subcommand.c
--- libgui_orig/src/subcommand.c 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/subcommand.c 2012-02-24 13:53:50.760585300 +0100
@@ -34,7 +34,7 @@
table. */
static int
subcommand_implementation (ClientData cd, Tcl_Interp *interp,
- int argc, char *argv[])
+ int argc,CONST84 char *argv[])
{
struct subcommand_clientdata *data = (struct subcommand_clientdata *) cd;
const struct ide_subcommand_table *commands = data->commands;
@@ -90,7 +90,7 @@
/* Define a command with subcommands. */
int
-ide_create_command_with_subcommands (Tcl_Interp *interp, char *name,
+ide_create_command_with_subcommands (Tcl_Interp *interp, const char *name,
const struct ide_subcommand_table *table,
ClientData subdata,
Tcl_CmdDeleteProc *delete)
diff -ruN libgui_orig/src/subcommand.h libgui/src/subcommand.h
--- libgui_orig/src/subcommand.h 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/subcommand.h 2012-02-24 13:52:36.539002400 +0100
@@ -21,7 +21,7 @@
/* Define a command with subcommands. */
int ide_create_command_with_subcommands
- (Tcl_Interp *interp, char *name, const struct ide_subcommand_table *table,
+ (Tcl_Interp *interp, const char *name, const struct ide_subcommand_table *table,
ClientData, Tcl_CmdDeleteProc *);
#ifdef __cplusplus
diff -ruN libgui_orig/src/tclcursor.c libgui/src/tclcursor.c
--- libgui_orig/src/tclcursor.c 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/tclcursor.c 2012-02-24 14:02:44.176135300 +0100
@@ -25,7 +25,7 @@
#include "subcommand.h"
static int
-get_cursor_size (ClientData cd, Tcl_Interp *interp, int argc, char *argv[])
+get_cursor_size (ClientData cd, Tcl_Interp *interp, int argc,CONST84 char *argv[])
{
char buf[30];
@@ -38,7 +38,7 @@
}
static int
-get_cursor_position (ClientData cd, Tcl_Interp *interp, int argc, char *argv[])
+get_cursor_position (ClientData cd, Tcl_Interp *interp, int argc,CONST84 char *argv[])
{
POINT where;
char buf[30];
diff -ruN libgui_orig/src/tclmsgbox.c libgui/src/tclmsgbox.c
--- libgui_orig/src/tclmsgbox.c 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/tclmsgbox.c 2012-02-24 13:33:44.464962700 +0100
@@ -4,11 +4,11 @@
#ifdef _WIN32
+#include <windows.h>
+
#include <tcl.h>
#include <tk.h>
-#include <windows.h>
-
/* FIXME: We use some internal Tcl and Tk Windows stuff. */
#include <tkWinInt.h>
@@ -96,7 +96,7 @@
class.hInstance = TclWinGetTclInstance();
class.hbrBackground = NULL;
class.lpszMenuName = NULL;
- class.lpszClassName = "ide_messagebox";
+ class.lpszClassName = TEXT("ide_messagebox");
class.lpfnWndProc = msgbox_wndproc;
class.hIcon = NULL;
class.hCursor = NULL;
@@ -104,7 +104,7 @@
if (! RegisterClass (&class))
return TCL_ERROR;
- hidden_hwnd = CreateWindow ("ide_messagebox", "ide_messagebox", WS_TILED,
+ hidden_hwnd = CreateWindow (TEXT("ide_messagebox"), TEXT("ide_messagebox"), WS_TILED,
0, 0, 0, 0, NULL, NULL, class.hInstance, NULL);
if (hidden_hwnd == NULL)
return TCL_ERROR;
@@ -119,7 +119,7 @@
{
if (hidden_hwnd != NULL)
{
- UnregisterClass ("ide_messagebox", TclWinGetTclInstance ());
+ UnregisterClass (TEXT("ide_messagebox"), TclWinGetTclInstance ());
DestroyWindow (hidden_hwnd);
hidden_hwnd = NULL;
@@ -136,7 +136,7 @@
{
struct msgbox_data *md = (struct msgbox_data *) arg;
- md->result = MessageBox (md->hwnd, md->message, md->title,
+ md->result = MessageBoxA (md->hwnd, md->message, md->title,
md->flags | MB_SETFOREGROUND);
PostMessage (md->hidden_hwnd, MSGBOX_MESSAGE, 0, (LPARAM) arg);
return 0;
@@ -241,18 +241,18 @@
static int
msgbox_internal (ClientData clientData, Tcl_Interp *interp, int argc,
- char **argv, char *code)
+ CONST84 char **argv, CONST84 char *code)
{
int flags;
Tk_Window parent = NULL;
HWND hWnd;
- char *message = "";
- char *title = "";
+ CONST84 char *message = "";
+ CONST84 char *title = "";
int icon = MB_ICONINFORMATION;
int type = MB_OK;
int modal = MB_SYSTEMMODAL;
int i, j;
- char *defaultBtn = NULL;
+ CONST84 char *defaultBtn = NULL;
int defaultBtnIdx = -1;
for (i=1; i<argc; i+=2) {
@@ -430,7 +430,7 @@
/* This is the ide_messageBox function. */
static int
-msgbox (ClientData cd, Tcl_Interp *interp, int argc, char **argv)
+msgbox (ClientData cd, Tcl_Interp *interp, int argc,CONST84 char **argv)
{
if (argc < 2)
{
diff -ruN libgui_orig/src/tclshellexe.c libgui/src/tclshellexe.c
--- libgui_orig/src/tclshellexe.c 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/tclshellexe.c 2012-03-22 15:49:59.547660300 +0100
@@ -16,12 +16,12 @@
static int
shell_execute_command (ClientData clientData, Tcl_Interp *interp,
- int argc, char *argv[])
+ int argc, CONST84 char *argv[])
{
- char *operation;
- char *file;
- char *param;
- char *dir;
+ CONST84 char *operation;
+ CONST84 char *file;
+ CONST84 char *param;
+ CONST84 char *dir;
int ret;
if (argc < 3 || argc > 5)
@@ -55,7 +55,7 @@
else
dir = NULL;
- ret = (int)ShellExecute(NULL, operation, file, param, dir, SW_SHOWNORMAL);
+ ret = (int)(ssize_t)ShellExecuteA(NULL, operation, file, param, dir, SW_SHOWNORMAL);
if (ret <= 32)
{
Tcl_AppendResult(interp, strerror(ret), NULL);
diff -ruN libgui_orig/src/tclwinfont.c libgui/src/tclwinfont.c
--- libgui_orig/src/tclwinfont.c 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/tclwinfont.c 2012-02-24 13:42:41.393703800 +0100
@@ -50,13 +50,13 @@
/* Implement the ide_win_choose_font procedure. */
static int
-win_choose_font (ClientData cd, Tcl_Interp *interp, int argc, char **argv)
+win_choose_font (ClientData cd, Tcl_Interp *interp, int argc,CONST84 char **argv)
{
- char *deffont;
+ CONST84 char *deffont;
Tk_Window parent;
int i, oldMode;
- CHOOSEFONT cf;
- LOGFONT lf;
+ CHOOSEFONTA cf;
+ LOGFONTA lf;
HDC hdc;
HFONT hfont;
char facebuf[LF_FACESIZE];
@@ -154,7 +154,7 @@
}
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- if (! ChooseFont (&cf))
+ if (! ChooseFontA (&cf))
{
DWORD code;
@@ -191,7 +191,7 @@
specification it will wind up with the font that the user expects
to see. Some of this code is taken from AllocFont. */
- hfont = CreateFontIndirect (&lf);
+ hfont = CreateFontIndirectA (&lf);
if (hfont == NULL)
{
/* This should be impossible. */
@@ -208,7 +208,7 @@
hdc = GetDC (cf.hwndOwner);
hfont = SelectObject (hdc, hfont);
- GetTextFace (hdc, sizeof (facebuf), facebuf);
+ GetTextFaceA (hdc, sizeof (facebuf), facebuf);
GetTextMetrics (hdc, &tm);
Tcl_ResetResult (interp);
diff -ruN libgui_orig/src/tclwinmode.c libgui/src/tclwinmode.c
--- libgui_orig/src/tclwinmode.c 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/tclwinmode.c 2012-02-24 14:06:55.963738000 +0100
@@ -28,7 +28,7 @@
static int
seterrormode_command (ClientData cd, Tcl_Interp *interp,
- int argc, char *argv[])
+ int argc, CONST84 char *argv[])
{
#ifdef __CYGWIN32__
int len, i;
diff -ruN libgui_orig/src/tclwinprint.c libgui/src/tclwinprint.c
--- libgui_orig/src/tclwinprint.c 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/tclwinprint.c 2012-02-24 13:57:12.703864500 +0100
@@ -136,7 +136,7 @@
static int
winprint_page_setup_command (ClientData cd, Tcl_Interp *interp, int argc,
- char **argv)
+ CONST84 char **argv)
{
struct winprint_data *wd = (struct winprint_data *) cd;
Tk_Window parent;
@@ -258,13 +258,13 @@
/* Whether to use the print dialog. */
int dialog;
/* The parent window. */
- char *parent;
+ const char *parent;
/* The document name. */
- char *name;
+ const char *name;
/* The page procedure. */
- char *pageproc;
+ const char *pageproc;
/* The init procedure. This is called once before printing. */
- char *initproc;
+ const char *initproc;
/* Print using PostScript? */
int postscript;
};
@@ -273,7 +273,7 @@
static int
winprint_print_text_options (struct winprint_data *wd, Tcl_Interp *interp,
- int argc, char **argv,
+ int argc, const char **argv,
struct print_text_options *pto)
{
int i;
@@ -458,7 +458,7 @@
winprint_start (struct winprint_data *wd, Tcl_Interp *interp, PRINTDLG *pd,
const struct print_text_options *pto, int *cancelled)
{
- DOCINFO di;
+ DOCINFOA di;
*cancelled = 0;
@@ -479,7 +479,7 @@
di.lpszDatatype = NULL;
di.fwType = 0;
- if (StartDoc (pd->hDC, &di) <= 0)
+ if (StartDocA (pd->hDC, &di) <= 0)
{
if (GetLastError () == ERROR_CANCELLED)
*cancelled = 1;
@@ -527,7 +527,7 @@
/* Invoke the query or page procedure for ide_winprint print_text. */
static int
-winprint_print_text_invoke (Tcl_Interp *interp, char *proc, const char *name,
+winprint_print_text_invoke (Tcl_Interp *interp, const char *proc, const char *name,
enum winprint_query *result)
{
char *q;
@@ -557,11 +557,11 @@
/* Implement ide_winprint print_text. */
static int
winprint_print_command (ClientData cd, Tcl_Interp *interp, int argc,
- char **argv)
+ CONST84 char **argv)
{
struct winprint_data *wd = (struct winprint_data *) cd;
- char *queryproc;
- char *textproc;
+ const char *queryproc;
+ const char *textproc;
struct print_text_options pto;
PRINTDLG pd;
int cancelled;
@@ -829,7 +829,7 @@
l = Tcl_GetStringFromObj (Tcl_GetObjResult (interp), &len);
- TextOut (pd.hDC, left, y, l, len);
+ TextOutA (pd.hDC, left, y, l, len);
y += lineheight;
if (y >= bottom)
@@ -890,7 +890,7 @@
static int
winprint_abort_command (ClientData cd, Tcl_Interp *interp, int argc,
- char **argv)
+ CONST84 char **argv)
{
struct winprint_data *wd = (struct winprint_data *) cd;
diff -ruN libgui_orig/src/tkTable.c libgui/src/tkTable.c
--- libgui_orig/src/tkTable.c 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/tkTable.c 2012-02-24 15:25:18.870312200 +0100
@@ -24,20 +24,16 @@
#include "tkTable.h"
-#ifdef DEBUG
-#include "dprint.h"
-#endif
-
static char ** StringifyObjects _ANSI_ARGS_((int objc,
- Tcl_Obj *CONST objv[]));
+ Tcl_Obj *const objv[]));
static int Tk_TableObjCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
+ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]));
static int TableWidgetObjCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
+ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]));
static int TableConfigure _ANSI_ARGS_((Tcl_Interp *interp,
- Table *tablePtr, int objc, Tcl_Obj *CONST objv[],
+ Table *tablePtr, int objc, Tcl_Obj *const objv[],
int flags, int forceUpdate));
static void TableDestroy _ANSI_ARGS_((ClientData clientdata));
static void TableEventProc _ANSI_ARGS_((ClientData clientData,
@@ -65,7 +61,7 @@
* enumerated types used to dispatch the widget command.
*/
-static char *selCmdNames[] = {
+static const char *selCmdNames[] = {
"anchor", "clear", "includes", "present", "set", (char *)NULL
};
enum selCommand {
@@ -73,7 +69,7 @@
CMD_SEL_SET
};
-static char *commandNames[] = {
+static const char *commandNames[] = {
"activate", "bbox", "border", "cget", "clear", "configure",
"curselection", "curvalue", "delete", "get", "height",
"hidden", "icursor", "index", "insert",
@@ -328,7 +324,7 @@
* Keep this in sync with the above values.
*/
-static char *updateOpts[] = {
+static const char *updateOpts[] = {
"-anchor", "-background", "-bg", "-bd",
"-borderwidth", "-cache", "-command", "-colorigin",
"-cols", "-colstretchmode", "-coltagcommand",
@@ -1041,7 +1037,7 @@
/* Do the configuration */
argv = StringifyObjects(objc, objv);
result = Tk_ConfigureWidget(interp, tablePtr->tkwin, tableSpecs,
- objc, argv, (char *) tablePtr, flags);
+ objc, (CONST84 char **)argv, (char *) tablePtr, flags);
ckfree((char *) argv);
if (result != TCL_OK) {
return TCL_ERROR;
@@ -1679,12 +1675,6 @@
invalidY+invalidHeight-1, &rowTo, &colTo);
tablePtr->flags &= ~AVOID_SPANS;
-#ifdef DEBUG
- tcl_dprintf(tablePtr->interp, "%d,%d => %d,%d",
- rowFrom+tablePtr->rowOffset, colFrom+tablePtr->colOffset,
- rowTo+tablePtr->rowOffset, colTo+tablePtr->colOffset);
-#endif
-
/*
* Initialize colTagsCache hash table to cache column tag names.
*/
@@ -3377,7 +3367,7 @@
Tcl_HashSearch search;
int length, count, lastrow=0, needcs=0, r, c, listArgc, rslen=0, cslen=0;
int numcols, numrows;
- char **listArgv;
+ CONST84 char **listArgv;
/* if we are not exporting the selection ||
* we have no data source, return */
diff -ruN libgui_orig/src/tkTable.h libgui/src/tkTable.h
--- libgui_orig/src/tkTable.h 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/tkTable.h 2012-03-22 15:50:05.366470500 +0100
@@ -15,9 +15,26 @@
#ifndef _TKTABLE_H_
#define _TKTABLE_H_
+#ifdef WIN32
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# undef WIN32_LEAN_AND_MEAN
+/* VC++ has an entry point called DllMain instead of DllEntryPoint */
+# if defined(_MSC_VER)
+# define DllEntryPoint DllMain
+# endif
+#endif
+
+
#include <string.h>
#include <stdlib.h>
+#include <stdint.h>
#include <tk.h>
+
+#ifndef CONST86
+# define CONST86 CONST84
+#endif
+
#ifdef MAC_TCL
# include <Xatom.h>
#else
@@ -46,16 +63,6 @@
# define TCL_STORAGE_CLASS DLLIMPORT
#endif
-#ifdef WIN32
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# undef WIN32_LEAN_AND_MEAN
-/* VC++ has an entry point called DllMain instead of DllEntryPoint */
-# if defined(_MSC_VER)
-# define DllEntryPoint DllMain
-# endif
-#endif
-
#if defined(WIN32) || defined(MAC_TCL)
/* XSync call defined in the internals for some reason */
# ifndef XSync
@@ -506,17 +513,17 @@
extern int TableOptionBdSet _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- char *value, char *widgRec, int offset));
-extern char * TableOptionBdGet _ANSI_ARGS_((ClientData clientData,
+ CONST84 char *value, char *widgRec, int offset));
+extern CONST86 char * TableOptionBdGet _ANSI_ARGS_((ClientData clientData,
Tk_Window tkwin, char *widgRec, int offset,
Tcl_FreeProc **freeProcPtr));
extern int TableTagConfigureBd _ANSI_ARGS_((Table *tablePtr,
TableTag *tagPtr, char *oldValue, int nullOK));
extern int Cmd_OptionSet _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp,
- Tk_Window unused, char *value,
+ Tk_Window unused, CONST84 char *value,
char *widgRec, int offset));
-extern char * Cmd_OptionGet _ANSI_ARGS_((ClientData clientData,
+extern CONST86 char * Cmd_OptionGet _ANSI_ARGS_((ClientData clientData,
Tk_Window unused, char *widgRec,
int offset,
Tcl_FreeProc **freeProcPtr));
@@ -631,6 +638,31 @@
(rowPtr), (colPtr))
/*
+ * 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
+ * to/from pointer from/to integer of different size".
+ */
+
+#if !defined(INT2PTR) && !defined(PTR2INT)
+# if defined(HAVE_INTPTR_T) || defined(intptr_t)
+# define INT2PTR(p) ((void *)(intptr_t)(p))
+# define PTR2INT(p) ((int)(intptr_t)(p))
+# else
+# define INT2PTR(p) ((void *)(p))
+# define PTR2INT(p) ((int)(p))
+# endif
+#endif
+#if !defined(UINT2PTR) && !defined(PTR2UINT)
+# if defined(HAVE_UINTPTR_T) || defined(uintptr_t)
+# define UINT2PTR(p) ((void *)(uintptr_t)(p))
+# define PTR2UINT(p) ((unsigned int)(uintptr_t)(p))
+# else
+# define UINT2PTR(p) ((void *)(p))
+# define PTR2UINT(p) ((unsigned int)(p))
+# endif
+#endif
+
+/*
* end of header
* reset TCL_STORAGE_CLASS to DLLIMPORT.
*/
diff -ruN libgui_orig/src/tkTableCmds.c libgui/src/tkTableCmds.c
--- libgui_orig/src/tkTableCmds.c 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/tkTableCmds.c 2012-03-22 15:50:15.428488200 +0100
@@ -306,7 +306,7 @@
return TCL_OK;
}
\f
-static char *bdCmdNames[] = {
+static CONST84 char *bdCmdNames[] = {
"mark", "dragto", (char *)NULL
};
enum bdCmd {
@@ -438,7 +438,7 @@
}
\f
/* clear subcommands */
-static char *clearNames[] = {
+static CONST84 char *clearNames[] = {
"all", "cache", "sizes", "tags", (char *)NULL
};
enum clearCommand {
diff -ruN libgui_orig/src/tkTableEdit.c libgui/src/tkTableEdit.c
--- libgui_orig/src/tkTableEdit.c 2001-09-09 00:34:47.000000000 +0200
+++ libgui/src/tkTableEdit.c 2012-03-22 15:50:23.727702800 +0100
@@ -20,7 +20,7 @@
int outOfBounds));
/* insert/delete subcommands */
-static char *modCmdNames[] = {
+static CONST84 char *modCmdNames[] = {
"active", "cols", "rows", (char *)NULL
};
enum modCmd {
@@ -28,7 +28,7 @@
};
/* insert/delete row/col switches */
-static char *rcCmdNames[] = {
+static CONST84 char *rcCmdNames[] = {
"-keeptitles", "-holddimensions", "-holdselection",
"-holdtags", "-holdwindows", "--",
(char *) NULL
diff -ruN libgui_orig/src/tkTableTag.c libgui/src/tkTableTag.c
--- libgui_orig/src/tkTableTag.c 2002-06-07 10:59:44.000000000 +0200
+++ libgui/src/tkTableTag.c 2012-02-24 15:28:18.042081700 +0100
@@ -14,13 +14,13 @@
#include "tkTable.h"
static TableTag *TableTagGetEntry _ANSI_ARGS_((Table *tablePtr, char *name,
- int objc, char **argv));
+ int objc, CONST84 char **argv));
static unsigned int TableTagGetPriority _ANSI_ARGS_((Table *tablePtr,
TableTag *tagPtr));
static void TableImageProc _ANSI_ARGS_((ClientData clientData, int x,
int y, int width, int height, int imageWidth, int imageHeight));
-static char *tagCmdNames[] = {
+static CONST84 char *tagCmdNames[] = {
"celltag", "cget", "coltag", "configure", "delete", "exists",
"includes", "lower", "names", "raise", "rowtag", (char *) NULL
};
@@ -436,7 +436,7 @@
*----------------------------------------------------------------------
*/
static TableTag *
-TableTagGetEntry(Table *tablePtr, char *name, int objc, char **argv)
+TableTagGetEntry(Table *tablePtr, char *name, int objc, CONST84 char **argv)
{
Tcl_HashEntry *entryPtr;
TableTag *tagPtr = NULL;
@@ -516,12 +516,12 @@
void
TableInitTags(Table *tablePtr)
{
- static char *activeArgs[] = {"-bg", ACTIVE_BG, "-relief", "flat" };
- static char *selArgs[] = {"-bg", SELECT_BG, "-fg", SELECT_FG,
+ static CONST84 char *activeArgs[] = {"-bg", ACTIVE_BG, "-relief", "flat" };
+ static CONST84 char *selArgs[] = {"-bg", SELECT_BG, "-fg", SELECT_FG,
"-relief", "sunken" };
- static char *titleArgs[] = {"-bg", DISABLED, "-fg", "white",
+ static CONST84 char *titleArgs[] = {"-bg", DISABLED, "-fg", "white",
"-relief", "flat", "-state", "disabled" };
- static char *flashArgs[] = {"-bg", "red" };
+ static CONST84 char *flashArgs[] = {"-bg", "red" };
/*
* The order of creation is important to priority.
*/
@@ -568,7 +568,7 @@
sprintf(buf, " %d", cell);
Tcl_Preserve((ClientData) interp);
if (Tcl_VarEval(interp, cmd, buf, (char *)NULL) == TCL_OK) {
- char *name = Tcl_GetStringResult(interp);
+ CONST84_RETURN char *name = Tcl_GetStringResult(interp);
if (name && *name) {
/*
* If a result was returned, check to see if it is
@@ -976,10 +976,10 @@
(char *) tagPtr, (objc == 5) ?
Tcl_GetString(objv[4]) : NULL, 0);
} else {
- char **argv;
+ CONST84 char **argv;
/* Stringify */
- argv = (char **) ckalloc((objc + 1) * sizeof(char *));
+ argv = (CONST84 char **) ckalloc((objc + 1) * sizeof(char *));
for (i = 0; i < objc; i++)
argv[i] = Tcl_GetString(objv[i]);
argv[objc] = NULL;
diff -ruN libgui_orig/src/tkTableUtil.c libgui/src/tkTableUtil.c
--- libgui_orig/src/tkTableUtil.c 2001-09-09 00:34:48.000000000 +0200
+++ libgui/src/tkTableUtil.c 2012-02-24 12:27:11.311731300 +0100
@@ -41,16 +41,16 @@
ClientData clientData; /* Type of struct being set. */
Tcl_Interp *interp; /* Used for reporting errors. */
Tk_Window tkwin; /* Window containing table widget. */
- char *value; /* Value of option. */
+ CONST84 char *value; /* Value of option. */
char *widgRec; /* Pointer to record for item. */
int offset; /* Offset into item. */
{
char **borderStr;
int *bordersPtr, *bdPtr;
- int type = (int) clientData;
+ int type = PTR2INT(clientData);
int result = TCL_OK;
int argc;
- char **argv;
+ CONST84 char **argv;
if ((type == BD_TABLE) && (value[0] == '\0')) {
@@ -137,7 +137,7 @@
*----------------------------------------------------------------------
*/
-char *
+CONST86 char *
TableOptionBdGet(clientData, tkwin, widgRec, offset, freeProcPtr)
ClientData clientData; /* Type of struct being set. */
Tk_Window tkwin; /* Window containing canvas widget. */
@@ -147,7 +147,7 @@
* information about how to reclaim
* storage for return string. */
{
- register int type = (int) clientData;
+ register int type = PTR2INT(clientData);
if (type == BD_TABLE) {
return ((TableTag *) (widgRec + offset))->borderStr;
@@ -183,7 +183,7 @@
char *oldValue, int nullOK)
{
int i, argc, result = TCL_OK;
- char **argv;
+ CONST84 char **argv;
/*
* First check to see if the value really changed.
@@ -270,7 +270,7 @@
int
Cmd_OptionSet(ClientData clientData, Tcl_Interp *interp,
- Tk_Window unused, char *value, char *widgRec, int offset)
+ Tk_Window unused, CONST84 char *value, char *widgRec, int offset)
{
Cmd_Struct *p = (Cmd_Struct *)clientData;
int mode = Cmd_GetValue(p,value);
@@ -297,7 +297,7 @@
*----------------------------------------------------------------------
*/
-char *
+CONST86 char *
Cmd_OptionGet(ClientData clientData, Tk_Window unused,
char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
{
diff -ruN libgui_orig/src/tkTableWin.c libgui/src/tkTableWin.c
--- libgui_orig/src/tkTableWin.c 2001-09-09 00:34:48.000000000 +0200
+++ libgui/src/tkTableWin.c 2012-02-24 15:29:04.600424800 +0100
@@ -15,9 +15,9 @@
#include "tkTable.h"
static int StickyParseProc _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, Tk_Window tkwin, char *value,
+ Tcl_Interp *interp, Tk_Window tkwin, CONST84 char *value,
char *widgRec, int offset));
-static char * StickyPrintProc _ANSI_ARGS_((ClientData clientData,
+static CONST86 char * StickyPrintProc _ANSI_ARGS_((ClientData clientData,
Tk_Window tkwin, char *widgRec, int offset,
Tcl_FreeProc **freeProcPtr));
@@ -43,7 +43,7 @@
};
/* windows subcommands */
-static char *winCmdNames[] = {
+static const char *winCmdNames[] = {
"cget", "configure", "delete", "move", "names", (char *) NULL
};
enum winCommand {
@@ -117,7 +117,7 @@
*
*----------------------------------------------------------------------
*/
-static char *
+static CONST86 char *
StickyPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr)
ClientData clientData; /* Ignored. */
Tk_Window tkwin; /* Window for text widget. */
@@ -163,7 +163,7 @@
ClientData clientData; /* Not used.*/
Tcl_Interp *interp; /* Used for reporting errors. */
Tk_Window tkwin; /* Window for text widget. */
- char *value; /* Value of option. */
+ CONST84 char *value; /* Value of option. */
char *widgRec; /* Pointer to TkTextEmbWindow
* structure. */
int offset; /* Offset into item (ignored). */
@@ -615,19 +615,19 @@
Tcl_Interp *interp = tablePtr->interp;
Tk_Window oldWindow;
int i, result;
- char **argv;
+ const char **argv;
oldWindow = ewPtr->tkwin;
/* Stringify */
- argv = (char **) ckalloc((objc + 1) * sizeof(char *));
+ argv = (const char **) ckalloc((objc + 1) * sizeof(char *));
for (i = 0; i < objc; i++)
argv[i] = Tcl_GetString(objv[i]);
argv[i] = NULL;
result = Tk_ConfigureWidget(interp, tablePtr->tkwin,
winConfigSpecs, objc, argv, (char *) ewPtr,
TK_CONFIG_ARGV_ONLY);
- ckfree((char *) argv);
+ ckfree((const char *) argv);
if (result != TCL_OK) {
return TCL_ERROR;
}
diff -ruN libgui_orig/src/tkWarpPointer.c libgui/src/tkWarpPointer.c
--- libgui_orig/src/tkWarpPointer.c 2001-09-09 00:34:48.000000000 +0200
+++ libgui/src/tkWarpPointer.c 2012-02-24 15:29:15.586078900 +0100
@@ -24,12 +24,13 @@
*
*
* ---------------------------------------------------------------------------*/
-#include "tk.h"
#ifdef _WIN32
#include <windows.h>
#include <winuser.h>
#endif
+#include "tk.h"
+
int
WarpPointer (clientData, interp, objc, objv)
ClientData clientData;
@@ -39,7 +40,6 @@
{
Tk_Window tkwin;
int x, y;
- char *str;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv, "widgetId x y");
diff -ruN libgui_orig/src/tkWinPrintCanvas.c libgui/src/tkWinPrintCanvas.c
--- libgui_orig/src/tkWinPrintCanvas.c 2001-09-09 00:34:48.000000000 +0200
+++ libgui/src/tkWinPrintCanvas.c 2012-02-24 14:01:44.848274800 +0100
@@ -52,7 +52,7 @@
int tiles_wide,tiles_high;
int tile_y, tile_x;
int screenX1, screenX2, screenY1, screenY2, width, height;
- DOCINFO *lpdi = (DOCINFO *) ckalloc(sizeof(DOCINFO));
+ DOCINFOA *lpdi = (DOCINFOA *) ckalloc(sizeof(DOCINFOA));
if (argc < 2) {
Tcl_AppendResult(interp, "wrong # args: should be \"",
@@ -75,7 +75,7 @@
memset(lpdi,0,sizeof(DOCINFO));
lpdi->cbSize=sizeof(DOCINFO);
lpdi->lpszDocName= (LPCSTR) ckalloc(255);
- sprintf((char*)lpdi->lpszDocName,"SN - Printing\0");
+ strcpy((char *)lpdi->lpszDocName,"SN - Printing");
lpdi->lpszOutput=NULL;
canvasPtr = (TkCanvas *)(canvCmd.clientData);
@@ -144,7 +144,7 @@
tiles_high = ( widget_Y_size / page_Y_size ); /* start at zero */
tiles_wide = ( widget_X_size / page_X_size ); /* start at zero */
- StartDoc(pd.hDC,lpdi);
+ StartDocA(pd.hDC,lpdi);
for (tile_x = 0; tile_x <= tiles_wide;tile_x++) {
for (tile_y = 0; tile_y <= tiles_high;tile_y++) {
@@ -154,7 +154,7 @@
for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
itemPtr = itemPtr->nextPtr) {
(*itemPtr->typePtr->displayProc)((Tk_Canvas) canvasPtr, itemPtr,
- canvasPtr->display, (unsigned long) PrinterDrawable/*pixmap*/, screenX1, screenY1, width,
+ canvasPtr->display, (Drawable) PrinterDrawable/*pixmap*/, screenX1, screenY1, width,
height);
}
diff -ruN libgui_orig/src/tkWinPrintText.c libgui/src/tkWinPrintText.c
--- libgui_orig/src/tkWinPrintText.c 2001-09-09 00:34:48.000000000 +0200
+++ libgui/src/tkWinPrintText.c 2012-03-22 13:56:42.037502500 +0100
@@ -243,13 +243,11 @@
DLine *dlPtr;
TkWinDrawable *PrinterDrawable;
Tk_Window tkwin;
- Tk_Item *itemPtr;
int maxHeight;
DLine *prevPtr;
Pixmap pixmap;
- int bottomY = 0; /* Initialization needed only to stop
- * compiler warnings. */
- DOCINFO *lpdi = (DOCINFO *) ckalloc(sizeof(DOCINFO));
+
+ DOCINFOA *lpdi = (DOCINFOA *) ckalloc(sizeof(DOCINFOA));
TkTextIndex first, last;
int numLines;
HDC hDCpixmap;
@@ -292,7 +290,7 @@
memset(lpdi,0,sizeof(DOCINFO));
lpdi->cbSize=sizeof(DOCINFO);
lpdi->lpszDocName = (LPCSTR) ckalloc(255);
- sprintf((char*)lpdi->lpszDocName,"SN - Printing\0");
+ strcpy((char*)lpdi->lpszDocName,"SN - Printing\0");
lpdi->lpszOutput=NULL;
textPtr = (TkText *)(textCmd.clientData);
@@ -358,16 +356,24 @@
/* Make the text widget big enough for all the
text to be seen. */
+#if (TCL_MAJOR_VERSION >= 8) && (TCL_MINOR_VERSION >= 5)
+ numLines = TkBTreeNumLines(textPtr->sharedTextPtr->tree,textPtr);
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, 0, 0, &first);
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, numLines, 100, &last);
+ TkTextChanged(textPtr->sharedTextPtr, textPtr, &first, &last);
+#elif (TCL_MAJOR_VERSION >= 8) && (TCL_MINOR_VERSION >= 1)
numLines = TkBTreeNumLines(textPtr->tree);
-#if (TCL_MAJOR_VERSION >= 8) && (TCL_MINOR_VERSION >= 1)
TkTextMakeByteIndex(textPtr->tree, 0, 0, &first);
TkTextMakeByteIndex(textPtr->tree, numLines, 100, &last);
+ TkTextChanged(textPtr, &first, &last);
#else
+ numLines = TkBTreeNumLines(textPtr->tree);
TkTextMakeIndex(textPtr->tree, 0, 0, &first);
TkTextMakeIndex(textPtr->tree, numLines, 100, &last);
-#endif
TkTextChanged(textPtr, &first, &last);
-
+#endif
/*
* Set the display info flag to out-of-date.
*/
@@ -403,7 +409,7 @@
tiles_high = ( maxHeight / page_Y_size ); /* start at page zero */
- StartDoc(pd.hDC,lpdi);
+ StartDocA(pd.hDC,lpdi);
for (tile_y = 0; tile_y <= tiles_high;tile_y++) {
SetViewportOrgEx(pd.hDC,0,-(tile_y*Ptr_pixY),NULL);
@@ -437,8 +443,13 @@
/*
* Pitch the info again.
*/
+ #if (TCL_MAJOR_VERSION >= 8) && (TCL_MINOR_VERSION >= 5)
+ TkTextChanged(textPtr->sharedTextPtr,textPtr, &first, &last);
+ #else
TkTextChanged(textPtr, &first, &last);
-
+ #endif
/*
* Display info not valid anymore.
*/
@@ -455,14 +466,6 @@
return TCL_ERROR;
}
-
-
-static void
-ide_delete_print_text_command(ClientData clientData)
-{
- /* destructor code here.*/
-}
-
int
ide_create_print_text_command (Tcl_Interp *interp)
{
@@ -498,7 +501,7 @@
register TkTextDispChunk *chunkPtr;
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
Display *display;
- int height, x;
+ int x;
/*
* First, clear the area of the line to the background color for the
@@ -518,21 +521,36 @@
continue;
} else {
x = chunkPtr->x + dInfoPtr->x - dInfoPtr->curPixelOffset;
+ #if (TCL_MAJOR_VERSION >= 8) && (TCL_MINOR_VERSION >= 5)
+ if ((x + chunkPtr->width <= 0) || (x >= dInfoPtr->maxX)) {
+ (*chunkPtr->displayProc)(textPtr, chunkPtr, -chunkPtr->width,
+ dlPtr->y,
+ dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
+ dlPtr->baseline - dlPtr->spaceAbove, display, (Drawable)drawable,
+ dlPtr->y + dlPtr->spaceAbove);
+ } else {
+ (*chunkPtr->displayProc)(textPtr, chunkPtr, x, dlPtr->y,
+ dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
+ dlPtr->baseline - dlPtr->spaceAbove, display, (Drawable)drawable,
+ dlPtr->y + dlPtr->spaceAbove);
+ }
+ #else
if ((x + chunkPtr->width <= 0) || (x >= dInfoPtr->maxX)) {
(*chunkPtr->displayProc)(chunkPtr, -chunkPtr->width,
dlPtr->y,
dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
- dlPtr->baseline - dlPtr->spaceAbove, display, (unsigned long)drawable,
+ dlPtr->baseline - dlPtr->spaceAbove, display, (Drawable)drawable,
dlPtr->y + dlPtr->spaceAbove);
} else {
(*chunkPtr->displayProc)(chunkPtr, x, dlPtr->y,
dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
- dlPtr->baseline - dlPtr->spaceAbove, display, (unsigned long)drawable,
+ dlPtr->baseline - dlPtr->spaceAbove, display, (Drawable)drawable,
dlPtr->y + dlPtr->spaceAbove);
}
+ #endif
}
}
}
-#endif /* _WIN */
+#endif /* _WIN32 */
next reply other threads:[~2012-03-23 10:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-23 10:22 Roland Schwingel [this message]
2012-05-24 21:35 ` Keith Seitz
2012-05-25 12:00 Roland Schwingel
2012-06-04 1:13 ` Keith Seitz
2012-08-08 13:37 Roland Schwingel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F6C4EB9.4000003@onevision.com \
--to=roland@onevision.com \
--cc=insight@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).