summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-09-23 10:01:57 (GMT)
committernijtmans <nijtmans>2010-09-23 10:01:57 (GMT)
commit25157d30417b906b70fbc56e8105543d1b94a962 (patch)
treed6594df4ec21f5a4ac54918403bdfa99196ab20c
parent82c5aed7f6fa4e8afaf8f80e7d560dbbb63ce79d (diff)
downloadtk-25157d30417b906b70fbc56e8105543d1b94a962.zip
tk-25157d30417b906b70fbc56e8105543d1b94a962.tar.gz
tk-25157d30417b906b70fbc56e8105543d1b94a962.tar.bz2
Add -Wdeclaration-after-statement
tkWinX.c,winMain.c: Make compilable with -DUNICODE tkAppInit.c,winMain.c: Many clean-ups in comments, so all (tcl|tk)AppInit.c variants use the same style.
-rw-r--r--ChangeLog9
-rw-r--r--unix/tkAppInit.c67
-rwxr-xr-xwin/configure2
-rw-r--r--win/tcl.m42
-rw-r--r--win/tkWinX.c33
-rw-r--r--win/winMain.c153
6 files changed, 144 insertions, 122 deletions
diff --git a/ChangeLog b/ChangeLog
index b4c4f47..3f16853 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-23 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * win/tcl.m4: Add -Wdeclaration-after-statement
+ * win/configure: (regenerated)
+ * win/tkWinX.c: Make compilable with -DUNICODE.
+ * win/winMain.c:
+ * unix/tkAppInit.c: Many clean-ups in comments, so all
+ (tcl|tk)AppInit.c variants use the same style.
+
2010-09-20 Jan Nijtmans <nijtmans@users.sf.net>
* generic/ttk/ttkGenStubs.tcl: clean-up, port all genStubs.tcl changes
diff --git a/unix/tkAppInit.c b/unix/tkAppInit.c
index 8822340..caab966 100644
--- a/unix/tkAppInit.c
+++ b/unix/tkAppInit.c
@@ -1,27 +1,45 @@
/*
* tkAppInit.c --
*
- * Provides a default version of the Tcl_AppInit procedure for use in
- * wish and similar Tk-based applications.
+ * Provides a default version of the main program and Tcl_AppInit
+ * procedure for wish and other Tk-based applications.
*
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright (c) 1998-1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkAppInit.c,v 1.10 2009/10/21 20:28:54 nijtmans Exp $
+ * RCS: @(#) $Id: tkAppInit.c,v 1.11 2010/09/23 10:01:57 nijtmans Exp $
*/
-/* Make sure this file is never compiled with Stubs! */
-#undef USE_TCL_STUBS
-#undef USE_TK_STUBS
#include "tk.h"
-#include "locale.h"
#ifdef TK_TEST
-extern int Tktest_Init(Tcl_Interp *interp);
+extern Tcl_PackageInitProc Tktest_Init;
#endif /* TK_TEST */
+
+/*
+ * The following #if block allows you to change the AppInit function by using
+ * a #define of TCL_LOCAL_APPINIT instead of rewriting this entire file. The
+ * #if checks for that #define and uses Tcl_AppInit if it doesn't exist.
+ */
+
+#ifndef TK_LOCAL_APPINIT
+#define TK_LOCAL_APPINIT Tcl_AppInit
+#endif
+extern int TK_LOCAL_APPINIT(Tcl_Interp *interp);
+
+/*
+ * The following #if block allows you to change how Tcl finds the startup
+ * script, prime the library or encoding paths, fiddle with the argv, etc.,
+ * without needing to rewrite Tk_Main()
+ */
+
+#ifdef TK_LOCAL_MAIN_HOOK
+extern int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv);
+#endif
/*
*----------------------------------------------------------------------
@@ -35,7 +53,7 @@ extern int Tktest_Init(Tcl_Interp *interp);
* either.
*
* Side effects:
- * Whatever the application does.
+ * Just about anything, since from here we call arbitrary Tcl code.
*
*----------------------------------------------------------------------
*/
@@ -45,26 +63,7 @@ main(
int argc, /* Number of command-line arguments. */
char **argv) /* Values of command-line arguments. */
{
- /*
- * The following #if block allows you to change the AppInit function by
- * using a #define of TCL_LOCAL_APPINIT instead of rewriting this entire
- * file. The #if checks for that #define and uses Tcl_AppInit if it
- * doesn't exist.
- */
-
-#ifndef TK_LOCAL_APPINIT
-#define TK_LOCAL_APPINIT Tcl_AppInit
-#endif
- extern int TK_LOCAL_APPINIT(Tcl_Interp *interp);
-
- /*
- * The following #if block allows you to change how Tcl finds the startup
- * script, prime the library or encoding paths, fiddle with the argv,
- * etc., without needing to rewrite Tk_Main()
- */
-
#ifdef TK_LOCAL_MAIN_HOOK
- extern int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv);
TK_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
@@ -98,16 +97,17 @@ Tcl_AppInit(
if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
+
if (Tk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
+
#ifdef TK_TEST
if (Tktest_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
- Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
- (Tcl_PackageInitProc *) NULL);
+ Tcl_StaticPackage(interp, "Tktest", Tktest_Init, 0);
#endif /* TK_TEST */
/*
@@ -118,7 +118,8 @@ Tcl_AppInit(
* return TCL_ERROR;
* }
*
- * where "Mod" is the name of the module.
+ * where "Mod" is the name of the module. (Dynamically-loadable packages
+ * should have the same entry-point name.)
*/
/*
@@ -130,10 +131,10 @@ Tcl_AppInit(
* Specify a user-specific startup file to invoke if the application is
* run interactively. Typically the startup file is "~/.apprc" where "app"
* is the name of the application. If this line is deleted then no user-
- * -specific startup file will be run under any conditions.
+ * specific startup file will be run under any conditions.
*/
- Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
+ (Tcl_SetVar)(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
return TCL_OK;
}
diff --git a/win/configure b/win/configure
index 6b2e109..af10732 100755
--- a/win/configure
+++ b/win/configure
@@ -3364,7 +3364,7 @@ echo "$as_me: error: ${CC} does not support the -shared option.
CFLAGS_DEBUG=-g
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
- CFLAGS_WARNING="-Wall"
+ CFLAGS_WARNING="-Wall -Wdeclaration-after-statement"
LDFLAGS_DEBUG=
LDFLAGS_OPTIMIZE=
diff --git a/win/tcl.m4 b/win/tcl.m4
index 9faef88..20845c0 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -535,7 +535,7 @@ file for information about building with Mingw.])
CFLAGS_DEBUG=-g
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
- CFLAGS_WARNING="-Wall"
+ CFLAGS_WARNING="-Wall -Wdeclaration-after-statement"
LDFLAGS_DEBUG=
LDFLAGS_OPTIMIZE=
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 10a764e..da7b848 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -10,15 +10,9 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinX.c,v 1.69 2010/09/16 21:05:12 hobbs Exp $
+ * RCS: @(#) $Id: tkWinX.c,v 1.70 2010/09/23 10:01:57 nijtmans Exp $
*/
-/* TODO: This file does not compile in UNICODE mode.
- * See [Freq 2965056]: Windows build with -DUNICODE
- */
-#undef UNICODE
-#undef _UNICODE
-
#include "tkWinInt.h"
/*
@@ -63,16 +57,16 @@
static const TkWinProcs unicodeProcs = {
1,
- (LRESULT (WINAPI *)(WNDPROC, HWND, UINT, WPARAM, LPARAM)) CallWindowProcW,
- (LRESULT (WINAPI *)(HWND, UINT, WPARAM, LPARAM)) DefWindowProcW,
- (ATOM (WINAPI *)(const WNDCLASS *)) RegisterClassW,
- (BOOL (WINAPI *)(HWND, LPCTSTR)) SetWindowTextW,
+ (LRESULT (WINAPI *)(WNDPROC, HWND, UINT, WPARAM, LPARAM)) CallWindowProc,
+ (LRESULT (WINAPI *)(HWND, UINT, WPARAM, LPARAM)) DefWindowProc,
+ (ATOM (WINAPI *)(const WNDCLASS *)) RegisterClass,
+ (BOOL (WINAPI *)(HWND, LPCTSTR)) SetWindowText,
(HWND (WINAPI *)(DWORD, LPCTSTR, LPCTSTR, DWORD, int, int,
- int, int, HWND, HMENU, HINSTANCE, LPVOID)) CreateWindowExW,
- (BOOL (WINAPI *)(HMENU, UINT, UINT, UINT, LPCTSTR)) InsertMenuW,
- (int (WINAPI *)(HWND, LPCTSTR, int)) GetWindowTextW,
- (HWND (WINAPI *)(LPCTSTR, LPCTSTR)) FindWindowW,
- (int (WINAPI *)(HWND, LPTSTR, int)) GetClassNameW,
+ int, int, HWND, HMENU, HINSTANCE, LPVOID)) CreateWindowEx,
+ (BOOL (WINAPI *)(HMENU, UINT, UINT, UINT, LPCTSTR)) InsertMenu,
+ (int (WINAPI *)(HWND, LPCTSTR, int)) GetWindowText,
+ (HWND (WINAPI *)(LPCTSTR, LPCTSTR)) FindWindow,
+ (int (WINAPI *)(HWND, LPTSTR, int)) GetClassName,
};
const TkWinProcs *const tkWinProcs = &unicodeProcs;
@@ -336,9 +330,10 @@ TkWinXCleanup(
*
* Results:
* The return value is one of:
- * VER_PLATFORM_WIN32s Win32s on Windows 3.1.
- * VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95.
- * VER_PLATFORM_WIN32_NT Win32 on Windows NT
+ * VER_PLATFORM_WIN32s Win32s on Windows 3.1 (not supported)
+ * VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95, 98, ME (not supported)
+ * VER_PLATFORM_WIN32_NT Win32 on Windows NT, 2000, XP
+ * VER_PLATFORM_WIN32_CE Win32 on Windows CE
*
* Side effects:
* None.
diff --git a/win/winMain.c b/win/winMain.c
index ab7fdc5..b3d9f95 100644
--- a/win/winMain.c
+++ b/win/winMain.c
@@ -1,15 +1,17 @@
/*
* winMain.c --
*
- * Main entry point for wish and other Tk-based applications.
+ * Provides a default version of the main program and Tcl_AppInit
+ * procedure for wish and other Tk-based applications.
*
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright (c) 1993 The Regents of the University of California.
+ * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright (c) 1998-1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: winMain.c,v 1.30 2010/09/10 08:59:24 nijtmans Exp $
+ * RCS: @(#) $Id: winMain.c,v 1.31 2010/09/23 10:01:57 nijtmans Exp $
*/
/* TODO: This file does not compile in UNICODE mode.
@@ -18,33 +20,27 @@
#undef UNICODE
#undef _UNICODE
-/* Make sure this file is never compiled with Stubs! */
-#undef USE_TCL_STUBS
-#undef USE_TK_STUBS
-#include "tkInt.h"
+#include "tk.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <locale.h>
+#include <stdlib.h>
+#include <tchar.h>
+#ifdef TK_TEST
+extern Tcl_PackageInitProc Tktest_Init;
+#endif /* TK_TEST */
-/*
- * The following declarations refer to internal Tk routines. These interfaces
- * are available for use, but are not supported.
- */
+#if defined(__CYGWIN__)
+static void setargv(int *argcPtr, TCHAR ***argvPtr);
+#endif /* __CYGWIN__ */
/*
* Forward declarations for procedures defined later in this file:
*/
-static void WishPanic(const char *format, ...);
-#ifdef TK_TEST
-extern int Tktest_Init(Tcl_Interp *interp);
-#endif /* TK_TEST */
-
-#if defined(__CYGWIN__)
-static void setargv(int *argcPtr, char ***argvPtr);
-#endif /* __CYGWIN__ */
+static void WishPanic(const char *format, ...);
static BOOL consoleRequired = TRUE;
@@ -66,7 +62,7 @@ extern int TK_LOCAL_APPINIT(Tcl_Interp *interp);
*/
#ifdef TK_LOCAL_MAIN_HOOK
-extern int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv);
+extern int TK_LOCAL_MAIN_HOOK(int *argc, TCHAR ***argv);
#endif
/*
@@ -86,15 +82,15 @@ extern int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv);
*/
int APIENTRY
-WinMain(
+_tWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
- LPSTR lpszCmdLine,
+ LPTSTR lpszCmdLine,
int nCmdShow)
{
- char **argv;
+ TCHAR **argv;
int argc;
- char *p;
+ TCHAR *p;
Tcl_SetPanicProc(WishPanic);
@@ -121,16 +117,16 @@ WinMain(
setargv(&argc, &argv);
#else
argc = __argc;
- argv = __argv;
+ argv = __targv;
#endif
/*
* Forward slashes substituted for backslashes.
*/
- for (p = argv[0]; *p != '\0'; p++) {
- if (*p == '\\') {
- *p = '/';
+ for (p = argv[0]; *p != TEXT('\0'); p++) {
+ if (*p == TEXT('\\')) {
+ *p = TEXT('/');
}
}
@@ -139,7 +135,7 @@ WinMain(
#endif
Tk_Main(argc, argv, TK_LOCAL_APPINIT);
- return 1;
+ return 0; /* Needed only to prevent compiler warning. */
}
/*
@@ -187,16 +183,17 @@ Tcl_AppInit(
{
extern Tcl_PackageInitProc Registry_Init;
extern Tcl_PackageInitProc Dde_Init;
+ extern Tcl_PackageInitProc Dde_SafeInit;
if (Registry_Init(interp) == TCL_ERROR) {
- return TCL_ERROR;
+ goto error;
}
Tcl_StaticPackage(interp, "registry", Registry_Init, NULL);
if (Dde_Init(interp) == TCL_ERROR) {
- return TCL_ERROR;
+ goto error;
}
- Tcl_StaticPackage(interp, "dde", Dde_Init, NULL);
+ Tcl_StaticPackage(interp, "dde", Dde_Init, Dde_SafeInit);
}
#endif
@@ -204,15 +201,39 @@ Tcl_AppInit(
if (Tktest_Init(interp) == TCL_ERROR) {
goto error;
}
- Tcl_StaticPackage(interp, "Tktest", Tktest_Init, NULL);
+ Tcl_StaticPackage(interp, "Tktest", Tktest_Init, 0);
#endif /* TK_TEST */
- Tcl_SetVar(interp, "tcl_rcFileName", "~/wishrc.tcl", TCL_GLOBAL_ONLY);
+ /*
+ * Call the init procedures for included packages. Each call should look
+ * like this:
+ *
+ * if (Mod_Init(interp) == TCL_ERROR) {
+ * return TCL_ERROR;
+ * }
+ *
+ * where "Mod" is the name of the module. (Dynamically-loadable packages
+ * should have the same entry-point name.)
+ */
+
+ /*
+ * Call Tcl_CreateCommand for application-specific commands, if they
+ * weren't already created by the init procedures called above.
+ */
+
+ /*
+ * Specify a user-specific startup file to invoke if the application is
+ * run interactively. Typically the startup file is "~/.apprc" where "app"
+ * is the name of the application. If this line is deleted then no user-
+ * specific startup file will be run under any conditions.
+ */
+
+ (Tcl_SetVar)(interp, "tcl_rcFileName", "~/wishrc.tcl", TCL_GLOBAL_ONLY);
return TCL_OK;
error:
MessageBeep(MB_ICONEXCLAMATION);
- MessageBox(NULL, Tcl_GetStringResult(interp), "Error in Wish",
+ MessageBoxA(NULL, Tcl_GetStringResult(interp), "Error in Wish",
MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
ExitProcess(1);
@@ -250,7 +271,7 @@ WishPanic(
vsprintf(buf, format, argList);
MessageBeep(MB_ICONEXCLAMATION);
- MessageBox(NULL, buf, "Fatal Error in Wish",
+ MessageBoxA(NULL, buf, "Fatal Error in Wish",
MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
#ifdef _MSC_VER
DebugBreak();
@@ -277,9 +298,9 @@ WishPanic(
*/
int
-main(
+_tmain(
int argc,
- char **argv)
+ TCHAR **argv)
{
Tcl_SetPanicProc(WishPanic);
@@ -297,6 +318,10 @@ main(
consoleRequired = FALSE;
+#ifdef TK_LOCAL_MAIN_HOOK
+ TK_LOCAL_MAIN_HOOK(&argc, &argv);
+#endif
+
Tk_Main(argc, argv, Tcl_AppInit);
return 0;
}
@@ -334,13 +359,13 @@ main(
static void
setargv(
int *argcPtr, /* Filled with number of argument strings. */
- char ***argvPtr) /* Filled with argument strings (malloc'd). */
+ TCHAR ***argvPtr) /* Filled with argument strings (malloc'd). */
{
- char *cmdLine, *p, *arg, *argSpace;
- char **argv;
+ TCHAR *cmdLine, *p, *arg, *argSpace;
+ TCHAR **argv;
int argc, size, inquote, copy, slashes;
- cmdLine = GetCommandLine(); /* INTL: BUG */
+ cmdLine = GetCommandLine();
/*
* Precompute an overly pessimistic guess at the number of arguments in
@@ -348,30 +373,30 @@ setargv(
*/
size = 2;
- for (p = cmdLine; *p != '\0'; p++) {
- if ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
+ for (p = cmdLine; *p != TEXT('\0'); p++) {
+ if ((*p == TEXT(' ')) || (*p == TEXT('\t'))) { /* INTL: ISO space. */
size++;
- while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
+ while ((*p == TEXT(' ')) || (*p == TEXT('\t'))) { /* INTL: ISO space. */
p++;
}
- if (*p == '\0') {
+ if (*p == TEXT('\0')) {
break;
}
}
}
- argSpace = (char *) ckalloc(
- (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
- argv = (char **) argSpace;
- argSpace += size * sizeof(char *);
+ argSpace = (TCHAR *) ckalloc(
+ (unsigned) (size * sizeof(TCHAR *) + (_tcslen(cmdLine) * sizeof(TCHAR)) + 1));
+ argv = (TCHAR **) argSpace;
+ argSpace += size * sizeof(TCHAR *);
size--;
p = cmdLine;
for (argc = 0; argc < size; argc++) {
argv[argc] = arg = argSpace;
- while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
+ while ((*p == TEXT(' ')) || (*p == TEXT('\t'))) { /* INTL: ISO space. */
p++;
}
- if (*p == '\0') {
+ if (*p == TEXT('\0')) {
break;
}
@@ -379,14 +404,14 @@ setargv(
slashes = 0;
while (1) {
copy = 1;
- while (*p == '\\') {
+ while (*p == TEXT('\\')) {
slashes++;
p++;
}
- if (*p == '"') {
+ if (*p == TEXT('"')) {
if ((slashes & 1) == 0) {
copy = 0;
- if ((inquote) && (p[1] == '"')) {
+ if ((inquote) && (p[1] == TEXT('"'))) {
p++;
copy = 1;
} else {
@@ -397,13 +422,13 @@ setargv(
}
while (slashes) {
- *arg = '\\';
+ *arg = TEXT('\\');
arg++;
slashes--;
}
- if ((*p == '\0') || (!inquote &&
- ((*p == ' ') || (*p == '\t')))) { /* INTL: ISO space. */
+ if ((*p == TEXT('\0')) || (!inquote &&
+ ((*p == TEXT(' ')) || (*p == TEXT('\t'))))) { /* INTL: ISO space. */
break;
}
if (copy != 0) {
@@ -412,7 +437,7 @@ setargv(
}
p++;
}
- *arg = '\0';
+ *arg = TEXT('\0');
argSpace = arg + 1;
}
argv[argc] = NULL;
@@ -421,14 +446,6 @@ setargv(
*argvPtr = argv;
}
#endif /* __CYGWIN__ */
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
/*
* Local Variables: