Subject: Remove all the long dead mac entries in tcl*.decls files <p>backport genStubs::forAllStubs function, to generate dummy entries for some MAC_TCL entries <p>re-generate all tcl*Decls.h files.

From: "[email-masked]" <jan.nijtmans>
Date: Thu, 15 Nov 2012 08:23:35 +0000

---
 generic/tcl.decls         |  49 ---------
 generic/tclDecls.h        |  69 +++++++++----
 generic/tclInt.decls      | 111 --------------------
 generic/tclIntPlatDecls.h | 215 +-------------------------------------
 generic/tclPlatDecls.h    |  80 --------------
 generic/tclStubInit.c     |  66 +++---------
 tools/genStubs.tcl        | 258 +++++++++++++++++++++++++++++++++-------------
 7 files changed, 253 insertions(+), 595 deletions(-)

diff --git a/generic/tcl.decls b/generic/tcl.decls
index d4651c6..19bacc3 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -1818,55 +1818,6 @@ declare 1 win {
     char *Tcl_WinTCharToUtf(const TCHAR *str, int len, Tcl_DString *dsPtr)
 }
 
-##################
-# Mac declarations
-
-# This is needed by the shells to handle Macintosh events.
-
-declare 0 mac {
-    void Tcl_MacSetEventProc(Tcl_MacConvertEventPtr procPtr)
-}
-
-# These routines are useful for handling using scripts from resources
-# in the application shell
-
-declare 1 mac {
-    char *Tcl_MacConvertTextResource(Handle resource)
-}
-declare 2 mac {
-    int Tcl_MacEvalResource(Tcl_Interp *interp, const char *resourceName,
-	    int resourceNumber, const char *fileName)
-}
-declare 3 mac {
-    Handle Tcl_MacFindResource(Tcl_Interp *interp, long resourceType,
-	    const char *resourceName, int resourceNumber,
-	    const char *resFileRef, int *releaseIt)
-}
-
-# These routines support the new OSType object type (i.e. the packed 4
-# character type and creator codes).
-
-declare 4 mac {
-    int Tcl_GetOSTypeFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
-	    OSType *osTypePtr)
-}
-declare 5 mac {
-    void Tcl_SetOSTypeObj(Tcl_Obj *objPtr, OSType osType)
-}
-declare 6 mac {
-    Tcl_Obj *Tcl_NewOSTypeObj(OSType osType)
-}
-
-# These are not in MSL 2.1.2, so we need to export them from the
-# Tcl shared library.  They are found in the compat directory.
-
-declare 7 mac {
-    int strncasecmp(const char *s1, const char *s2, size_t n)
-}
-declare 8 mac {
-    int strcasecmp(const char *s1, const char *s2)
-}
-
 ################################
 # Mac OS X specific functions
 
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index b5d376e..29b0eb0 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -52,15 +52,24 @@ EXTERN void		Tcl_DbCkfree _ANSI_ARGS_((char *ptr,
 EXTERN char *		Tcl_DbCkrealloc _ANSI_ARGS_((char *ptr,
 				unsigned int size, CONST char *file,
 				int line));
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
 /* 9 */
 EXTERN void		Tcl_CreateFileHandler _ANSI_ARGS_((int fd, int mask,
 				Tcl_FileProc *proc, ClientData clientData));
 #endif /* UNIX */
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#ifdef MAC_OSX_TCL /* MACOSX */
+/* 9 */
+EXTERN void		Tcl_CreateFileHandler _ANSI_ARGS_((int fd, int mask,
+				Tcl_FileProc *proc, ClientData clientData));
+#endif /* MACOSX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
 /* 10 */
 EXTERN void		Tcl_DeleteFileHandler _ANSI_ARGS_((int fd));
 #endif /* UNIX */
+#ifdef MAC_OSX_TCL /* MACOSX */
+/* 10 */
+EXTERN void		Tcl_DeleteFileHandler _ANSI_ARGS_((int fd));
+#endif /* MACOSX */
 /* 11 */
 EXTERN void		Tcl_SetTimer _ANSI_ARGS_((Tcl_Time *timePtr));
 /* 12 */
@@ -534,12 +543,18 @@ EXTERN Tcl_Interp *	Tcl_GetMaster _ANSI_ARGS_((Tcl_Interp *interp));
 EXTERN CONST char *	Tcl_GetNameOfExecutable _ANSI_ARGS_((void));
 /* 166 */
 EXTERN Tcl_Obj *	Tcl_GetObjResult _ANSI_ARGS_((Tcl_Interp *interp));
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
 /* 167 */
 EXTERN int		Tcl_GetOpenFile _ANSI_ARGS_((Tcl_Interp *interp,
 				CONST char *chanID, int forWriting,
 				int checkUsage, ClientData *filePtr));
 #endif /* UNIX */
+#ifdef MAC_OSX_TCL /* MACOSX */
+/* 167 */
+EXTERN int		Tcl_GetOpenFile _ANSI_ARGS_((Tcl_Interp *interp,
+				CONST char *chanID, int forWriting,
+				int checkUsage, ClientData *filePtr));
+#endif /* MACOSX */
 /* 168 */
 EXTERN Tcl_PathType	Tcl_GetPathType _ANSI_ARGS_((CONST char *path));
 /* 169 */
@@ -1634,24 +1649,24 @@ typedef struct TclStubs {
     char * (*tcl_DbCkalloc) _ANSI_ARGS_((unsigned int size, CONST char *file, int line)); /* 6 */
     void (*tcl_DbCkfree) _ANSI_ARGS_((char *ptr, CONST char *file, int line)); /* 7 */
     char * (*tcl_DbCkrealloc) _ANSI_ARGS_((char *ptr, unsigned int size, CONST char *file, int line)); /* 8 */
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
     void (*tcl_CreateFileHandler) _ANSI_ARGS_((int fd, int mask, Tcl_FileProc *proc, ClientData clientData)); /* 9 */
 #endif /* UNIX */
 #if defined(__WIN32__) /* WIN */
     VOID *reserved9;
 #endif /* WIN */
-#ifdef MAC_TCL
-    VOID *reserved9;
-#endif /* MAC_TCL */
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#ifdef MAC_OSX_TCL /* MACOSX */
+    void (*tcl_CreateFileHandler) _ANSI_ARGS_((int fd, int mask, Tcl_FileProc *proc, ClientData clientData)); /* 9 */
+#endif /* MACOSX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
     void (*tcl_DeleteFileHandler) _ANSI_ARGS_((int fd)); /* 10 */
 #endif /* UNIX */
 #if defined(__WIN32__) /* WIN */
     VOID *reserved10;
 #endif /* WIN */
-#ifdef MAC_TCL
-    VOID *reserved10;
-#endif /* MAC_TCL */
+#ifdef MAC_OSX_TCL /* MACOSX */
+    void (*tcl_DeleteFileHandler) _ANSI_ARGS_((int fd)); /* 10 */
+#endif /* MACOSX */
     void (*tcl_SetTimer) _ANSI_ARGS_((Tcl_Time *timePtr)); /* 11 */
     void (*tcl_Sleep) _ANSI_ARGS_((int ms)); /* 12 */
     int (*tcl_WaitForEvent) _ANSI_ARGS_((Tcl_Time *timePtr)); /* 13 */
@@ -1808,15 +1823,15 @@ typedef struct TclStubs {
     Tcl_Interp * (*tcl_GetMaster) _ANSI_ARGS_((Tcl_Interp *interp)); /* 164 */
     CONST char * (*tcl_GetNameOfExecutable) _ANSI_ARGS_((void)); /* 165 */
     Tcl_Obj * (*tcl_GetObjResult) _ANSI_ARGS_((Tcl_Interp *interp)); /* 166 */
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
     int (*tcl_GetOpenFile) _ANSI_ARGS_((Tcl_Interp *interp, CONST char *chanID, int forWriting, int checkUsage, ClientData *filePtr)); /* 167 */
 #endif /* UNIX */
 #if defined(__WIN32__) /* WIN */
     VOID *reserved167;
 #endif /* WIN */
-#ifdef MAC_TCL
-    VOID *reserved167;
-#endif /* MAC_TCL */
+#ifdef MAC_OSX_TCL /* MACOSX */
+    int (*tcl_GetOpenFile) _ANSI_ARGS_((Tcl_Interp *interp, CONST char *chanID, int forWriting, int checkUsage, ClientData *filePtr)); /* 167 */
+#endif /* MACOSX */
     Tcl_PathType (*tcl_GetPathType) _ANSI_ARGS_((CONST char *path)); /* 168 */
     int (*tcl_Gets) _ANSI_ARGS_((Tcl_Channel chan, Tcl_DString *dsPtr)); /* 169 */
     int (*tcl_GetsObj) _ANSI_ARGS_((Tcl_Channel chan, Tcl_Obj *objPtr)); /* 170 */
@@ -2275,18 +2290,30 @@ extern TclStubs *tclStubsPtr;
 #define Tcl_DbCkrealloc \
 	(tclStubsPtr->tcl_DbCkrealloc) /* 8 */
 #endif
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
 #ifndef Tcl_CreateFileHandler
 #define Tcl_CreateFileHandler \
 	(tclStubsPtr->tcl_CreateFileHandler) /* 9 */
 #endif
 #endif /* UNIX */
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#ifdef MAC_OSX_TCL /* MACOSX */
+#ifndef Tcl_CreateFileHandler
+#define Tcl_CreateFileHandler \
+	(tclStubsPtr->tcl_CreateFileHandler) /* 9 */
+#endif
+#endif /* MACOSX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
 #ifndef Tcl_DeleteFileHandler
 #define Tcl_DeleteFileHandler \
 	(tclStubsPtr->tcl_DeleteFileHandler) /* 10 */
 #endif
 #endif /* UNIX */
+#ifdef MAC_OSX_TCL /* MACOSX */
+#ifndef Tcl_DeleteFileHandler
+#define Tcl_DeleteFileHandler \
+	(tclStubsPtr->tcl_DeleteFileHandler) /* 10 */
+#endif
+#endif /* MACOSX */
 #ifndef Tcl_SetTimer
 #define Tcl_SetTimer \
 	(tclStubsPtr->tcl_SetTimer) /* 11 */
@@ -2911,12 +2938,18 @@ extern TclStubs *tclStubsPtr;
 #define Tcl_GetObjResult \
 	(tclStubsPtr->tcl_GetObjResult) /* 166 */
 #endif
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
 #ifndef Tcl_GetOpenFile
 #define Tcl_GetOpenFile \
 	(tclStubsPtr->tcl_GetOpenFile) /* 167 */
 #endif
 #endif /* UNIX */
+#ifdef MAC_OSX_TCL /* MACOSX */
+#ifndef Tcl_GetOpenFile
+#define Tcl_GetOpenFile \
+	(tclStubsPtr->tcl_GetOpenFile) /* 167 */
+#endif
+#endif /* MACOSX */
 #ifndef Tcl_GetPathType
 #define Tcl_GetPathType \
 	(tclStubsPtr->tcl_GetPathType) /* 168 */
diff --git a/generic/tclInt.decls b/generic/tclInt.decls
index 1366fc3..bdae099 100644
--- a/generic/tclInt.decls
+++ b/generic/tclInt.decls
@@ -713,117 +713,6 @@ declare 199 {
 
 interface tclIntPlat
 
-########################
-# Mac specific internals
-
-declare 0 mac {
-    void *TclpSysAlloc(long size, int isBin)
-}
-declare 1 mac {
-    void TclpSysFree(void *ptr)
-}
-declare 2 mac {
-    void *TclpSysRealloc(void *cp, unsigned int size)
-}
-declare 3 mac {
-    void TclpExit(int status)
-}
-
-# Prototypes for functions found in the tclMacUtil.c compatability library.
-
-declare 4 mac {
-    int FSpGetDefaultDir(FSSpecPtr theSpec)
-}
-declare 5 mac {
-    int FSpSetDefaultDir(FSSpecPtr theSpec)
-}
-declare 6 mac {
-    OSErr FSpFindFolder(short vRefNum, OSType folderType,
-	    Boolean createFolder, FSSpec *spec)
-}
-declare 7 mac {
-    void GetGlobalMouseTcl(Point *mouse)
-}
-
-# The following routines are utility functions in Tcl.  They are exported
-# here because they are needed in Tk.  They are not officially supported,
-# however.  The first set are from the MoreFiles package.
-
-declare 8 mac {
-    pascal OSErr FSpGetDirectoryIDTcl(const FSSpec *spec, long *theDirID,
-	    Boolean *isDirectory)
-}
-declare 9 mac {
-    pascal short FSpOpenResFileCompatTcl(const FSSpec *spec,
-	    SignedByte permission)
-}
-declare 10 mac {
-    pascal void FSpCreateResFileCompatTcl(const FSSpec *spec, OSType creator,
-	    OSType fileType, ScriptCode scriptTag)
-}
-
-# Like the MoreFiles routines these fix problems in the standard
-# Mac calls.  These routines are from tclMacUtils.h.
-
-declare 11 mac {
-    int FSpLocationFromPath(int length, const char *path, FSSpecPtr theSpec)
-}
-declare 12 mac {
-    OSErr FSpPathFromLocation(FSSpecPtr theSpec, int *length,
-	    Handle *fullPath)
-}
-
-# Prototypes of Mac only internal functions.
-
-declare 13 mac {
-    void TclMacExitHandler(void)
-}
-declare 14 mac {
-    void TclMacInitExitToShell(int usePatch)
-}
-declare 15 mac {
-    OSErr TclMacInstallExitToShellPatch(ExitToShellProcPtr newProc)
-}
-declare 16 mac {
-    int TclMacOSErrorToPosixError(int error)
-}
-declare 17 mac {
-    void TclMacRemoveTimer(void *timerToken)
-}
-declare 18 mac {
-    void *TclMacStartTimer(long ms)
-}
-declare 19 mac {
-    int TclMacTimerExpired(void *timerToken)
-}
-declare 20 mac {
-    int TclMacRegisterResourceFork(short fileRef, Tcl_Obj *tokenPtr,
-	    int insert)
-}
-declare 21 mac {
-    short TclMacUnRegisterResourceFork(char *tokenPtr, Tcl_Obj *resultPtr)
-}
-declare 22 mac {
-    int TclMacCreateEnv(void)
-}
-declare 23 mac {
-    FILE *TclMacFOpenHack(const char *path, const char *mode)
-}
-# Replaced in 8.1 by TclpReadLink:
-#  declare 24 mac {
-#      int TclMacReadlink(char *path, char *buf, int size)
-#  }
-declare 24 mac {
-    char *TclpGetTZName(int isdst)
-}
-declare 25 mac {
-    int TclMacChmod(const char *path, int mode)
-}
-# version of FSpLocationFromPath that doesn't resolve the last path component
-declare 26 mac {
-    int FSpLLocationFromPath(int length, const char *path, FSSpecPtr theSpec)
-}
-
 ################################
 # Windows specific functions
 
diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h
index 350df03..f258e26 100644
--- a/generic/tclIntPlatDecls.h
+++ b/generic/tclIntPlatDecls.h
@@ -30,7 +30,7 @@
  * Exported function declarations:
  */
 
-#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */
 /* 0 */
 EXTERN void		TclGetAndDetachPids _ANSI_ARGS_((Tcl_Interp *interp,
 				Tcl_Channel chan));
@@ -166,82 +166,12 @@ EXTERN void		TclWinResetInterfaces _ANSI_ARGS_((void));
 EXTERN int		TclWinCPUID _ANSI_ARGS_((unsigned int index,
 				unsigned int *regs));
 #endif /* WIN */
-#ifdef MAC_TCL
-/* 0 */
-EXTERN VOID *		TclpSysAlloc _ANSI_ARGS_((long size, int isBin));
-/* 1 */
-EXTERN void		TclpSysFree _ANSI_ARGS_((VOID *ptr));
-/* 2 */
-EXTERN VOID *		TclpSysRealloc _ANSI_ARGS_((VOID *cp,
-				unsigned int size));
-/* 3 */
-EXTERN void		TclpExit _ANSI_ARGS_((int status));
-/* 4 */
-EXTERN int		FSpGetDefaultDir _ANSI_ARGS_((FSSpecPtr theSpec));
-/* 5 */
-EXTERN int		FSpSetDefaultDir _ANSI_ARGS_((FSSpecPtr theSpec));
-/* 6 */
-EXTERN OSErr		FSpFindFolder _ANSI_ARGS_((short vRefNum,
-				OSType folderType, Boolean createFolder,
-				FSSpec *spec));
-/* 7 */
-EXTERN void		GetGlobalMouseTcl _ANSI_ARGS_((Point *mouse));
-/* 8 */
-EXTERN pascal OSErr	FSpGetDirectoryIDTcl _ANSI_ARGS_((CONST FSSpec *spec,
-				long *theDirID, Boolean *isDirectory));
-/* 9 */
-EXTERN pascal short	FSpOpenResFileCompatTcl _ANSI_ARGS_((
-				CONST FSSpec *spec, SignedByte permission));
-/* 10 */
-EXTERN pascal void	FSpCreateResFileCompatTcl _ANSI_ARGS_((
-				CONST FSSpec *spec, OSType creator,
-				OSType fileType, ScriptCode scriptTag));
-/* 11 */
-EXTERN int		FSpLocationFromPath _ANSI_ARGS_((int length,
-				CONST char *path, FSSpecPtr theSpec));
-/* 12 */
-EXTERN OSErr		FSpPathFromLocation _ANSI_ARGS_((FSSpecPtr theSpec,
-				int *length, Handle *fullPath));
-/* 13 */
-EXTERN void		TclMacExitHandler _ANSI_ARGS_((void));
-/* 14 */
-EXTERN void		TclMacInitExitToShell _ANSI_ARGS_((int usePatch));
-/* 15 */
-EXTERN OSErr		TclMacInstallExitToShellPatch _ANSI_ARGS_((
-				ExitToShellProcPtr newProc));
-/* 16 */
-EXTERN int		TclMacOSErrorToPosixError _ANSI_ARGS_((int error));
-/* 17 */
-EXTERN void		TclMacRemoveTimer _ANSI_ARGS_((VOID *timerToken));
-/* 18 */
-EXTERN VOID *		TclMacStartTimer _ANSI_ARGS_((long ms));
-/* 19 */
-EXTERN int		TclMacTimerExpired _ANSI_ARGS_((VOID *timerToken));
-/* 20 */
-EXTERN int		TclMacRegisterResourceFork _ANSI_ARGS_((
-				short fileRef, Tcl_Obj *tokenPtr, int insert));
-/* 21 */
-EXTERN short		TclMacUnRegisterResourceFork _ANSI_ARGS_((
-				char *tokenPtr, Tcl_Obj *resultPtr));
-/* 22 */
-EXTERN int		TclMacCreateEnv _ANSI_ARGS_((void));
-/* 23 */
-EXTERN FILE *		TclMacFOpenHack _ANSI_ARGS_((CONST char *path,
-				CONST char *mode));
-/* 24 */
-EXTERN char *		TclpGetTZName _ANSI_ARGS_((int isdst));
-/* 25 */
-EXTERN int		TclMacChmod _ANSI_ARGS_((CONST char *path, int mode));
-/* 26 */
-EXTERN int		FSpLLocationFromPath _ANSI_ARGS_((int length,
-				CONST char *path, FSSpecPtr theSpec));
-#endif /* MAC_TCL */
 
 typedef struct TclIntPlatStubs {
     int magic;
     struct TclIntPlatStubHooks *hooks;
 
-#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */
     void (*tclGetAndDetachPids) _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Channel chan)); /* 0 */
     int (*tclpCloseFile) _ANSI_ARGS_((TclFile file)); /* 1 */
     Tcl_Channel (*tclpCreateCommandChannel) _ANSI_ARGS_((TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr)); /* 2 */
@@ -305,35 +235,6 @@ typedef struct TclIntPlatStubs {
     void (*tclWinResetInterfaces) _ANSI_ARGS_((void)); /* 28 */
     int (*tclWinCPUID) _ANSI_ARGS_((unsigned int index, unsigned int *regs)); /* 29 */
 #endif /* WIN */
-#ifdef MAC_TCL
-    VOID * (*tclpSysAlloc) _ANSI_ARGS_((long size, int isBin)); /* 0 */
-    void (*tclpSysFree) _ANSI_ARGS_((VOID *ptr)); /* 1 */
-    VOID * (*tclpSysRealloc) _ANSI_ARGS_((VOID *cp, unsigned int size)); /* 2 */
-    void (*tclpExit) _ANSI_ARGS_((int status)); /* 3 */
-    int (*fSpGetDefaultDir) _ANSI_ARGS_((FSSpecPtr theSpec)); /* 4 */
-    int (*fSpSetDefaultDir) _ANSI_ARGS_((FSSpecPtr theSpec)); /* 5 */
-    OSErr (*fSpFindFolder) _ANSI_ARGS_((short vRefNum, OSType folderType, Boolean createFolder, FSSpec *spec)); /* 6 */
-    void (*getGlobalMouseTcl) _ANSI_ARGS_((Point *mouse)); /* 7 */
-    pascal OSErr (*fSpGetDirectoryIDTcl) _ANSI_ARGS_((CONST FSSpec *spec, long *theDirID, Boolean *isDirectory)); /* 8 */
-    pascal short (*fSpOpenResFileCompatTcl) _ANSI_ARGS_((CONST FSSpec *spec, SignedByte permission)); /* 9 */
-    pascal void (*fSpCreateResFileCompatTcl) _ANSI_ARGS_((CONST FSSpec *spec, OSType creator, OSType fileType, ScriptCode scriptTag)); /* 10 */
-    int (*fSpLocationFromPath) _ANSI_ARGS_((int length, CONST char *path, FSSpecPtr theSpec)); /* 11 */
-    OSErr (*fSpPathFromLocation) _ANSI_ARGS_((FSSpecPtr theSpec, int *length, Handle *fullPath)); /* 12 */
-    void (*tclMacExitHandler) _ANSI_ARGS_((void)); /* 13 */
-    void (*tclMacInitExitToShell) _ANSI_ARGS_((int usePatch)); /* 14 */
-    OSErr (*tclMacInstallExitToShellPatch) _ANSI_ARGS_((ExitToShellProcPtr newProc)); /* 15 */
-    int (*tclMacOSErrorToPosixError) _ANSI_ARGS_((int error)); /* 16 */
-    void (*tclMacRemoveTimer) _ANSI_ARGS_((VOID *timerToken)); /* 17 */
-    VOID * (*tclMacStartTimer) _ANSI_ARGS_((long ms)); /* 18 */
-    int (*tclMacTimerExpired) _ANSI_ARGS_((VOID *timerToken)); /* 19 */
-    int (*tclMacRegisterResourceFork) _ANSI_ARGS_((short fileRef, Tcl_Obj *tokenPtr, int insert)); /* 20 */
-    short (*tclMacUnRegisterResourceFork) _ANSI_ARGS_((char *tokenPtr, Tcl_Obj *resultPtr)); /* 21 */
-    int (*tclMacCreateEnv) _ANSI_ARGS_((void)); /* 22 */
-    FILE * (*tclMacFOpenHack) _ANSI_ARGS_((CONST char *path, CONST char *mode)); /* 23 */
-    char * (*tclpGetTZName) _ANSI_ARGS_((int isdst)); /* 24 */
-    int (*tclMacChmod) _ANSI_ARGS_((CONST char *path, int mode)); /* 25 */
-    int (*fSpLLocationFromPath) _ANSI_ARGS_((int length, CONST char *path, FSSpecPtr theSpec)); /* 26 */
-#endif /* MAC_TCL */
 } TclIntPlatStubs;
 
 #ifdef __cplusplus
@@ -350,7 +251,7 @@ extern TclIntPlatStubs *tclIntPlatStubsPtr;
  * Inline function declarations:
  */
 
-#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */
 #ifndef TclGetAndDetachPids
 #define TclGetAndDetachPids \
 	(tclIntPlatStubsPtr->tclGetAndDetachPids) /* 0 */
@@ -543,116 +444,6 @@ extern TclIntPlatStubs *tclIntPlatStubsPtr;
 	(tclIntPlatStubsPtr->tclWinCPUID) /* 29 */
 #endif
 #endif /* WIN */
-#ifdef MAC_TCL
-#ifndef TclpSysAlloc
-#define TclpSysAlloc \
-	(tclIntPlatStubsPtr->tclpSysAlloc) /* 0 */
-#endif
-#ifndef TclpSysFree
-#define TclpSysFree \
-	(tclIntPlatStubsPtr->tclpSysFree) /* 1 */
-#endif
-#ifndef TclpSysRealloc
-#define TclpSysRealloc \
-	(tclIntPlatStubsPtr->tclpSysRealloc) /* 2 */
-#endif
-#ifndef TclpExit
-#define TclpExit \
-	(tclIntPlatStubsPtr->tclpExit) /* 3 */
-#endif
-#ifndef FSpGetDefaultDir
-#define FSpGetDefaultDir \
-	(tclIntPlatStubsPtr->fSpGetDefaultDir) /* 4 */
-#endif
-#ifndef FSpSetDefaultDir
-#define FSpSetDefaultDir \
-	(tclIntPlatStubsPtr->fSpSetDefaultDir) /* 5 */
-#endif
-#ifndef FSpFindFolder
-#define FSpFindFolder \
-	(tclIntPlatStubsPtr->fSpFindFolder) /* 6 */
-#endif
-#ifndef GetGlobalMouseTcl
-#define GetGlobalMouseTcl \
-	(tclIntPlatStubsPtr->getGlobalMouseTcl) /* 7 */
-#endif
-#ifndef FSpGetDirectoryIDTcl
-#define FSpGetDirectoryIDTcl \
-	(tclIntPlatStubsPtr->fSpGetDirectoryIDTcl) /* 8 */
-#endif
-#ifndef FSpOpenResFileCompatTcl
-#define FSpOpenResFileCompatTcl \
-	(tclIntPlatStubsPtr->fSpOpenResFileCompatTcl) /* 9 */
-#endif
-#ifndef FSpCreateResFileCompatTcl
-#define FSpCreateResFileCompatTcl \
-	(tclIntPlatStubsPtr->fSpCreateResFileCompatTcl) /* 10 */
-#endif
-#ifndef FSpLocationFromPath
-#define FSpLocationFromPath \
-	(tclIntPlatStubsPtr->fSpLocationFromPath) /* 11 */
-#endif
-#ifndef FSpPathFromLocation
-#define FSpPathFromLocation \
-	(tclIntPlatStubsPtr->fSpPathFromLocation) /* 12 */
-#endif
-#ifndef TclMacExitHandler
-#define TclMacExitHandler \
-	(tclIntPlatStubsPtr->tclMacExitHandler) /* 13 */
-#endif
-#ifndef TclMacInitExitToShell
-#define TclMacInitExitToShell \
-	(tclIntPlatStubsPtr->tclMacInitExitToShell) /* 14 */
-#endif
-#ifndef TclMacInstallExitToShellPatch
-#define TclMacInstallExitToShellPatch \
-	(tclIntPlatStubsPtr->tclMacInstallExitToShellPatch) /* 15 */
-#endif
-#ifndef TclMacOSErrorToPosixError
-#define TclMacOSErrorToPosixError \
-	(tclIntPlatStubsPtr->tclMacOSErrorToPosixError) /* 16 */
-#endif
-#ifndef TclMacRemoveTimer
-#define TclMacRemoveTimer \
-	(tclIntPlatStubsPtr->tclMacRemoveTimer) /* 17 */
-#endif
-#ifndef TclMacStartTimer
-#define TclMacStartTimer \
-	(tclIntPlatStubsPtr->tclMacStartTimer) /* 18 */
-#endif
-#ifndef TclMacTimerExpired
-#define TclMacTimerExpired \
-	(tclIntPlatStubsPtr->tclMacTimerExpired) /* 19 */
-#endif
-#ifndef TclMacRegisterResourceFork
-#define TclMacRegisterResourceFork \
-	(tclIntPlatStubsPtr->tclMacRegisterResourceFork) /* 20 */
-#endif
-#ifndef TclMacUnRegisterResourceFork
-#define TclMacUnRegisterResourceFork \
-	(tclIntPlatStubsPtr->tclMacUnRegisterResourceFork) /* 21 */
-#endif
-#ifndef TclMacCreateEnv
-#define TclMacCreateEnv \
-	(tclIntPlatStubsPtr->tclMacCreateEnv) /* 22 */
-#endif
-#ifndef TclMacFOpenHack
-#define TclMacFOpenHack \
-	(tclIntPlatStubsPtr->tclMacFOpenHack) /* 23 */
-#endif
-#ifndef TclpGetTZName
-#define TclpGetTZName \
-	(tclIntPlatStubsPtr->tclpGetTZName) /* 24 */
-#endif
-#ifndef TclMacChmod
-#define TclMacChmod \
-	(tclIntPlatStubsPtr->tclMacChmod) /* 25 */
-#endif
-#ifndef FSpLLocationFromPath
-#define FSpLLocationFromPath \
-	(tclIntPlatStubsPtr->fSpLLocationFromPath) /* 26 */
-#endif
-#endif /* MAC_TCL */
 
 #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */
 
diff --git a/generic/tclPlatDecls.h b/generic/tclPlatDecls.h
index f63b9c0..b339795 100644
--- a/generic/tclPlatDecls.h
+++ b/generic/tclPlatDecls.h
@@ -37,37 +37,6 @@ EXTERN TCHAR *		Tcl_WinUtfToTChar _ANSI_ARGS_((CONST char *str,
 EXTERN char *		Tcl_WinTCharToUtf _ANSI_ARGS_((CONST TCHAR *str,
 				int len, Tcl_DString *dsPtr));
 #endif /* WIN */
-#ifdef MAC_TCL
-/* 0 */
-EXTERN void		Tcl_MacSetEventProc _ANSI_ARGS_((
-				Tcl_MacConvertEventPtr procPtr));
-/* 1 */
-EXTERN char *		Tcl_MacConvertTextResource _ANSI_ARGS_((
-				Handle resource));
-/* 2 */
-EXTERN int		Tcl_MacEvalResource _ANSI_ARGS_((Tcl_Interp *interp,
-				CONST char *resourceName, int resourceNumber,
-				CONST char *fileName));
-/* 3 */
-EXTERN Handle		Tcl_MacFindResource _ANSI_ARGS_((Tcl_Interp *interp,
-				long resourceType, CONST char *resourceName,
-				int resourceNumber, CONST char *resFileRef,
-				int *releaseIt));
-/* 4 */
-EXTERN int		Tcl_GetOSTypeFromObj _ANSI_ARGS_((Tcl_Interp *interp,
-				Tcl_Obj *objPtr, OSType *osTypePtr));
-/* 5 */
-EXTERN void		Tcl_SetOSTypeObj _ANSI_ARGS_((Tcl_Obj *objPtr,
-				OSType osType));
-/* 6 */
-EXTERN Tcl_Obj *	Tcl_NewOSTypeObj _ANSI_ARGS_((OSType osType));
-/* 7 */
-EXTERN int		strncasecmp _ANSI_ARGS_((CONST char *s1,
-				CONST char *s2, size_t n));
-/* 8 */
-EXTERN int		strcasecmp _ANSI_ARGS_((CONST char *s1,
-				CONST char *s2));
-#endif /* MAC_TCL */
 #ifdef MAC_OSX_TCL /* MACOSX */
 /* 0 */
 EXTERN int		Tcl_MacOSXOpenBundleResources _ANSI_ARGS_((
@@ -90,17 +59,6 @@ typedef struct TclPlatStubs {
     TCHAR * (*tcl_WinUtfToTChar) _ANSI_ARGS_((CONST char *str, int len, Tcl_DString *dsPtr)); /* 0 */
     char * (*tcl_WinTCharToUtf) _ANSI_ARGS_((CONST TCHAR *str, int len, Tcl_DString *dsPtr)); /* 1 */
 #endif /* WIN */
-#ifdef MAC_TCL
-    void (*tcl_MacSetEventProc) _ANSI_ARGS_((Tcl_MacConvertEventPtr procPtr)); /* 0 */
-    char * (*tcl_MacConvertTextResource) _ANSI_ARGS_((Handle resource)); /* 1 */
-    int (*tcl_MacEvalResource) _ANSI_ARGS_((Tcl_Interp *interp, CONST char *resourceName, int resourceNumber, CONST char *fileName)); /* 2 */
-    Handle (*tcl_MacFindResource) _ANSI_ARGS_((Tcl_Interp *interp, long resourceType, CONST char *resourceName, int resourceNumber, CONST char *resFileRef, int *releaseIt)); /* 3 */
-    int (*tcl_GetOSTypeFromObj) _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *objPtr, OSType *osTypePtr)); /* 4 */
-    void (*tcl_SetOSTypeObj) _ANSI_ARGS_((Tcl_Obj *objPtr, OSType osType)); /* 5 */
-    Tcl_Obj * (*tcl_NewOSTypeObj) _ANSI_ARGS_((OSType osType)); /* 6 */
-    int (*strncasecmp) _ANSI_ARGS_((CONST char *s1, CONST char *s2, size_t n)); /* 7 */
-    int (*strcasecmp) _ANSI_ARGS_((CONST char *s1, CONST char *s2)); /* 8 */
-#endif /* MAC_TCL */
 #ifdef MAC_OSX_TCL /* MACOSX */
     int (*tcl_MacOSXOpenBundleResources) _ANSI_ARGS_((Tcl_Interp *interp, CONST char *bundleName, int hasResourceFile, int maxPathLen, char *libraryPath)); /* 0 */
     int (*tcl_MacOSXOpenVersionedBundleResources) _ANSI_ARGS_((Tcl_Interp *interp, CONST char *bundleName, CONST char *bundleVersion, int hasResourceFile, int maxPathLen, char *libraryPath)); /* 1 */
@@ -131,44 +89,6 @@ extern TclPlatStubs *tclPlatStubsPtr;
 	(tclPlatStubsPtr->tcl_WinTCharToUtf) /* 1 */
 #endif
 #endif /* WIN */
-#ifdef MAC_TCL
-#ifndef Tcl_MacSetEventProc
-#define Tcl_MacSetEventProc \
-	(tclPlatStubsPtr->tcl_MacSetEventProc) /* 0 */
-#endif
-#ifndef Tcl_MacConvertTextResource
-#define Tcl_MacConvertTextResource \
-	(tclPlatStubsPtr->tcl_MacConvertTextResource) /* 1 */
-#endif
-#ifndef Tcl_MacEvalResource
-#define Tcl_MacEvalResource \
-	(tclPlatStubsPtr->tcl_MacEvalResource) /* 2 */
-#endif
-#ifndef Tcl_MacFindResource
-#define Tcl_MacFindResource \
-	(tclPlatStubsPtr->tcl_MacFindResource) /* 3 */
-#endif
-#ifndef Tcl_GetOSTypeFromObj
-#define Tcl_GetOSTypeFromObj \
-	(tclPlatStubsPtr->tcl_GetOSTypeFromObj) /* 4 */
-#endif
-#ifndef Tcl_SetOSTypeObj
-#define Tcl_SetOSTypeObj \
-	(tclPlatStubsPtr->tcl_SetOSTypeObj) /* 5 */
-#endif
-#ifndef Tcl_NewOSTypeObj
-#define Tcl_NewOSTypeObj \
-	(tclPlatStubsPtr->tcl_NewOSTypeObj) /* 6 */
-#endif
-#ifndef strncasecmp
-#define strncasecmp \
-	(tclPlatStubsPtr->strncasecmp) /* 7 */
-#endif
-#ifndef strcasecmp
-#define strcasecmp \
-	(tclPlatStubsPtr->strcasecmp) /* 8 */
-#endif
-#endif /* MAC_TCL */
 #ifdef MAC_OSX_TCL /* MACOSX */
 #ifndef Tcl_MacOSXOpenBundleResources
 #define Tcl_MacOSXOpenBundleResources \
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index b548b1d..5efc8c9 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -420,7 +420,7 @@ TclIntStubs tclIntStubs = {
 TclIntPlatStubs tclIntPlatStubs = {
     TCL_STUB_MAGIC,
     NULL,
-#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */
     TclGetAndDetachPids, /* 0 */
     TclpCloseFile, /* 1 */
     TclpCreateCommandChannel, /* 2 */
@@ -484,35 +484,6 @@ TclIntPlatStubs tclIntPlatStubs = {
     TclWinResetInterfaces, /* 28 */
     TclWinCPUID, /* 29 */
 #endif /* WIN */
-#ifdef MAC_TCL
-    TclpSysAlloc, /* 0 */
-    TclpSysFree, /* 1 */
-    TclpSysRealloc, /* 2 */
-    TclpExit, /* 3 */
-    FSpGetDefaultDir, /* 4 */
-    FSpSetDefaultDir, /* 5 */
-    FSpFindFolder, /* 6 */
-    GetGlobalMouseTcl, /* 7 */
-    FSpGetDirectoryIDTcl, /* 8 */
-    FSpOpenResFileCompatTcl, /* 9 */
-    FSpCreateResFileCompatTcl, /* 10 */
-    FSpLocationFromPath, /* 11 */
-    FSpPathFromLocation, /* 12 */
-    TclMacExitHandler, /* 13 */
-    TclMacInitExitToShell, /* 14 */
-    TclMacInstallExitToShellPatch, /* 15 */
-    TclMacOSErrorToPosixError, /* 16 */
-    TclMacRemoveTimer, /* 17 */
-    TclMacStartTimer, /* 18 */
-    TclMacTimerExpired, /* 19 */
-    TclMacRegisterResourceFork, /* 20 */
-    TclMacUnRegisterResourceFork, /* 21 */
-    TclMacCreateEnv, /* 22 */
-    TclMacFOpenHack, /* 23 */
-    TclpGetTZName, /* 24 */
-    TclMacChmod, /* 25 */
-    FSpLLocationFromPath, /* 26 */
-#endif /* MAC_TCL */
 };
 
 TclPlatStubs tclPlatStubs = {
@@ -522,17 +493,6 @@ TclPlatStubs tclPlatStubs = {
     Tcl_WinUtfToTChar, /* 0 */
     Tcl_WinTCharToUtf, /* 1 */
 #endif /* WIN */
-#ifdef MAC_TCL
-    Tcl_MacSetEventProc, /* 0 */
-    Tcl_MacConvertTextResource, /* 1 */
-    Tcl_MacEvalResource, /* 2 */
-    Tcl_MacFindResource, /* 3 */
-    Tcl_GetOSTypeFromObj, /* 4 */
-    Tcl_SetOSTypeObj, /* 5 */
-    Tcl_NewOSTypeObj, /* 6 */
-    strncasecmp, /* 7 */
-    strcasecmp, /* 8 */
-#endif /* MAC_TCL */
 #ifdef MAC_OSX_TCL /* MACOSX */
     Tcl_MacOSXOpenBundleResources, /* 0 */
     Tcl_MacOSXOpenVersionedBundleResources, /* 1 */
@@ -557,24 +517,24 @@ TclStubs tclStubs = {
     Tcl_DbCkalloc, /* 6 */
     Tcl_DbCkfree, /* 7 */
     Tcl_DbCkrealloc, /* 8 */
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
     Tcl_CreateFileHandler, /* 9 */
 #endif /* UNIX */
 #if defined(__WIN32__) /* WIN */
     NULL, /* 9 */
 #endif /* WIN */
-#ifdef MAC_TCL
-    NULL, /* 9 */
-#endif /* MAC_TCL */
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#ifdef MAC_OSX_TCL /* MACOSX */
+    Tcl_CreateFileHandler, /* 9 */
+#endif /* MACOSX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
     Tcl_DeleteFileHandler, /* 10 */
 #endif /* UNIX */
 #if defined(__WIN32__) /* WIN */
     NULL, /* 10 */
 #endif /* WIN */
-#ifdef MAC_TCL
-    NULL, /* 10 */
-#endif /* MAC_TCL */
+#ifdef MAC_OSX_TCL /* MACOSX */
+    Tcl_DeleteFileHandler, /* 10 */
+#endif /* MACOSX */
     Tcl_SetTimer, /* 11 */
     Tcl_Sleep, /* 12 */
     Tcl_WaitForEvent, /* 13 */
@@ -731,15 +691,15 @@ TclStubs tclStubs = {
     Tcl_GetMaster, /* 164 */
     Tcl_GetNameOfExecutable, /* 165 */
     Tcl_GetObjResult, /* 166 */
-#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
+#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
     Tcl_GetOpenFile, /* 167 */
 #endif /* UNIX */
 #if defined(__WIN32__) /* WIN */
     NULL, /* 167 */
 #endif /* WIN */
-#ifdef MAC_TCL
-    NULL, /* 167 */
-#endif /* MAC_TCL */
+#ifdef MAC_OSX_TCL /* MACOSX */
+    Tcl_GetOpenFile, /* 167 */
+#endif /* MACOSX */
     Tcl_GetPathType, /* 168 */
     Tcl_Gets, /* 169 */
     Tcl_GetsObj, /* 170 */
diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl
index 96354f0..c29f6c9 100644
--- a/tools/genStubs.tcl
+++ b/tools/genStubs.tcl
@@ -157,7 +157,7 @@ proc genStubs::hooks {names} {
 # Arguments:
 #	index		The index number of the interface.
 #	platform	The platform the interface belongs to.  Should be one
-#			of generic, win, unix, or mac, or macosx or aqua or x11.
+#			of generic, win, unix, or macosx or aqua or x11.
 #	decl		The C function declaration, or {} for an undefined
 #			entry.
 #
@@ -298,19 +298,12 @@ proc genStubs::addPlatformGuard {plat iftxt {eltxt {}} {withCygwin 0}} {
 	    if {$withCygwin} {
 		append text " && !defined(__CYGWIN__)"
 	    }
-	    append text " && !defined(MAC_TCL)\
+	    append text " && !defined(MAC_OSX_TCL)\
 		    /* UNIX */\n${iftxt}"
 	    if {$eltxt != ""} {
 		append text "#else /* UNIX */\n${eltxt}"
 	    }
 	    append text "#endif /* UNIX */\n"
-	}		    
-	mac {
-	    append text "#ifdef MAC_TCL\n${iftxt}"
-	    if {$eltxt != ""} {
-		append text "#else /* MAC_TCL */\n${eltxt}"
-	    }
-	    append text "#endif /* MAC_TCL */\n"
 	}
 	macosx {
 	    append text "#ifdef MAC_OSX_TCL /* MACOSX */\n${iftxt}"
@@ -331,7 +324,7 @@ proc genStubs::addPlatformGuard {plat iftxt {eltxt {}} {withCygwin 0}} {
 	    if {$withCygwin} {
 		append text " || defined(__CYGWIN__)"
 	    }
-	    append text " || defined(MAC_TCL) || defined(MAC_OSX_TK))\
+	    append text " || defined(MAC_OSX_TK))\
 		    /* X11 */\n${iftxt}"
 	    if {$eltxt != ""} {
 		append text "#else /* X11 */\n${eltxt}"
@@ -696,100 +689,221 @@ proc genStubs::forAllStubs {name slotProc onAll textVar
 		append text [$slotProc $name $stubs($name,generic,$i) $i]
 		set emit 1
 	    } elseif {[llength $slots] > 0} {
-		foreach plat {unix win mac} {
-		    if {[info exists stubs($name,$plat,$i)]} {
-			append text [addPlatformGuard $plat \
-				[$slotProc $name $stubs($name,$plat,$i) $i]]
-			set emit 1
+		array set slot {unix 0 x11 0 win 0 macosx 0 aqua 0}
+		foreach s $slots {
+		    set slot([lindex [split $s ,] 1]) 1
+		}
+		# "aqua", "macosx" and "x11" are special cases:
+		# "macosx" implies "unix", "aqua" implies "macosx" and "x11"
+		# implies "unix", so we need to be careful not to emit
+		# duplicate stubs entries:
+		if {($slot(unix) && $slot(macosx)) || (
+			($slot(unix) || $slot(macosx)) &&
+			($slot(x11)  || $slot(aqua)))} {
+		    puts stderr "conflicting platform entries: $name $i"
+		}
+		## unix ##
+		set temp {}
+		set plat unix
+		if {!$slot(aqua) && !$slot(x11)} {
+		    if {$slot($plat)} {
+			append temp [$slotProc $name $stubs($name,$plat,$i) $i]
 		    } elseif {$onAll} {
-			append text [eval {addPlatformGuard $plat} $skipString]
-			set emit 1
+			eval {append temp} $skipString
 		    }
 		}
-                #
-                # "aqua" and "macosx" and "x11" are special cases, 
-                # since "macosx" always implies "unix" and "aqua", 
-                # "macosx", so we need to be careful not to 
-                # emit duplicate stubs entries for the two.
-                #
-		if {[info exists stubs($name,aqua,$i)]
-                        && ![info exists stubs($name,macosx,$i)]} {
-		    append text [addPlatformGuard aqua \
-			    [$slotProc $name $stubs($name,aqua,$i) $i]]
+		if {$temp ne ""} {
+		    append text [addPlatformGuard $plat $temp]
 		    set emit 1
 		}
-		if {[info exists stubs($name,macosx,$i)]
-                        && ![info exists stubs($name,unix,$i)]} {
-		    append text [addPlatformGuard macosx \
-			    [$slotProc $name $stubs($name,macosx,$i) $i]]
+		## x11 ##
+		set temp {}
+		set plat x11
+		if {!$slot(unix) && !$slot(macosx)} {
+		    if {$slot($plat)} {
+			append temp [$slotProc $name $stubs($name,$plat,$i) $i]
+		    } elseif {$onAll} {
+			eval {append temp} $skipString
+		    }
+		}
+		if {$temp ne ""} {
+		    append text [addPlatformGuard $plat $temp]
 		    set emit 1
 		}
-		if {[info exists stubs($name,x11,$i)]
-                        && ![info exists stubs($name,unix,$i)]} {
-		    append text [addPlatformGuard x11 \
-			    [$slotProc $name $stubs($name,x11,$i) $i]]
+		## win ##
+		set temp {}
+		set plat win
+		if {$slot($plat)} {
+		    append temp [$slotProc $name $stubs($name,$plat,$i) $i]
+		} elseif {$onAll} {
+		    eval {append temp} $skipString
+		}
+		if {$temp ne ""} {
+		    append text [addPlatformGuard $plat $temp]
+		    set emit 1
+		}
+		## macosx ##
+		set temp {}
+		set plat macosx
+		if {!$slot(aqua) && !$slot(x11)} {
+		    if {$slot($plat)} {
+			append temp [$slotProc $name $stubs($name,$plat,$i) $i]
+		    } elseif {$slot(unix)} {
+			append temp [$slotProc $name $stubs($name,unix,$i) $i]
+		    } elseif {$onAll} {
+			eval {append temp} $skipString
+		    }
+		}
+		if {$temp ne ""} {
+		    append text [addPlatformGuard $plat $temp]
+		    set emit 1
+		}
+		## aqua ##
+		set temp {}
+		set plat aqua
+		if {!$slot(unix) && !$slot(macosx)} {
+		    if {[string range $skipString 1 2] ne "/*"} {
+			# genStubs.tcl previously had a bug here causing it to
+			# erroneously generate both a unix entry and an aqua
+			# entry for a given stubs table slot. To preserve
+			# backwards compatibility, generate a dummy stubs entry
+			# before every aqua entry (note that this breaks the
+			# correspondence between emitted entry number and
+			# actual position of the entry in the stubs table, e.g.
+			# TkIntStubs entry 113 for aqua is in fact at position
+			# 114 in the table, entry 114 at position 116 etc).
+			eval {append temp} $skipString
+			set temp "[string range $temp 0 end-1] /*\
+				Dummy entry for stubs table backwards\
+				compatibility */\n"
+		    }
+		    if {$slot($plat)} {
+			append temp [$slotProc $name $stubs($name,$plat,$i) $i]
+		    } elseif {$onAll} {
+			eval {append temp} $skipString
+		    }
+		}
+		if {$temp ne ""} {
+		    append text [addPlatformGuard $plat $temp]
 		    set emit 1
 		}
 	    }
-	    if {$emit == 0} {
+	    if {!$emit} {
 		eval {append text} $skipString
 	    }
 	}
-	
     } else {
 	# Emit separate stubs blocks per platform
-	foreach plat {unix win mac} {
-	    if {[info exists stubs($name,$plat,lastNum)]} {
-		set lastNum $stubs($name,$plat,lastNum)
-		set temp {}
-		for {set i 0} {$i <= $lastNum} {incr i} {
-		    if {![info exists stubs($name,$plat,$i)]} {
-			eval {append temp} $skipString
-		    } else {
-			append temp [$slotProc $name $stubs($name,$plat,$i) $i]
-		    }
+	array set block {unix 0 x11 0 win 0 macosx 0 aqua 0}
+	foreach s [array names stubs $name,*,lastNum] {
+	    set block([lindex [split $s ,] 1]) 1
+	}
+	## unix ##
+	if {$block(unix) && !$block(x11)} {
+	    set temp {}
+	    set plat unix
+	    set lastNum $stubs($name,$plat,lastNum)
+	    for {set i 0} {$i <= $lastNum} {incr i} {
+		if {[info exists stubs($name,$plat,$i)]} {
+		    append temp [$slotProc $name $stubs($name,$plat,$i) $i]
+		} else {
+		    eval {append temp} $skipString
 		}
-		append text [addPlatformGuard $plat $temp {} true]
 	    }
+	    append text [addPlatformGuard $plat $temp {} true]
 	}
-        # Again, make sure you don't duplicate entries for macosx & aqua.
-	if {[info exists stubs($name,aqua,lastNum)]
-                && ![info exists stubs($name,macosx,lastNum)]} {
-	    set lastNum $stubs($name,aqua,lastNum)
+	## win ##
+	if {$block(win)} {
 	    set temp {}
+	    set plat win
+	    set lastNum $stubs($name,$plat,lastNum)
 	    for {set i 0} {$i <= $lastNum} {incr i} {
-		if {![info exists stubs($name,aqua,$i)]} {
-		    eval {append temp} $skipString
+		if {[info exists stubs($name,$plat,$i)]} {
+		    append temp [$slotProc $name $stubs($name,$plat,$i) $i]
 		} else {
-			append temp [$slotProc $name $stubs($name,aqua,$i) $i]
-		    }
+		    eval {append temp} $skipString
 		}
-		append text [addPlatformGuard aqua $temp]
 	    }
-        # Again, make sure you don't duplicate entries for macosx & unix.
-	if {[info exists stubs($name,macosx,lastNum)]
-                && ![info exists stubs($name,unix,lastNum)]} {
-	    set lastNum $stubs($name,macosx,lastNum)
+	    append text [addPlatformGuard $plat $temp {} true]
+	}
+	## macosx ##
+	if {$block(macosx) && !$block(aqua) && !$block(x11)} {
 	    set temp {}
+	    set lastNum -1
+	    foreach plat {unix macosx} {
+		if {$block($plat)} {
+		    set lastNum [expr {$lastNum > $stubs($name,$plat,lastNum)
+			    ? $lastNum : $stubs($name,$plat,lastNum)}]
+		}
+	    }
 	    for {set i 0} {$i <= $lastNum} {incr i} {
-		if {![info exists stubs($name,macosx,$i)]} {
+		set emit 0
+		foreach plat {unix macosx} {
+		    if {[info exists stubs($name,$plat,$i)]} {
+			append temp [$slotProc $name $stubs($name,$plat,$i) $i]
+			set emit 1
+			break
+		    }
+		}
+		if {!$emit} {
 		    eval {append temp} $skipString
-		} else {
-			append temp [$slotProc $name $stubs($name,macosx,$i) $i]
+		}
+	    }
+	    append text [addPlatformGuard macosx $temp]
+	}
+	## aqua ##
+	if {$block(aqua)} {
+	    set temp {}
+	    set lastNum -1
+	    foreach plat {unix macosx aqua} {
+		if {$block($plat)} {
+		    set lastNum [expr {$lastNum > $stubs($name,$plat,lastNum)
+			    ? $lastNum : $stubs($name,$plat,lastNum)}]
+		}
+	    }
+	    for {set i 0} {$i <= $lastNum} {incr i} {
+		set emit 0
+		foreach plat {unix macosx aqua} {
+		    if {[info exists stubs($name,$plat,$i)]} {
+			append temp [$slotProc $name $stubs($name,$plat,$i) $i]
+			set emit 1
+			break
 		    }
 		}
-		append text [addPlatformGuard macosx $temp]
+		if {!$emit} {
+		    eval {append temp} $skipString
+		}
 	    }
-        # Again, make sure you don't duplicate entries for x11 & unix.
-	if {[info exists stubs($name,x11,lastNum)]
-                && ![info exists stubs($name,unix,lastNum)]} {
-	    set lastNum $stubs($name,x11,lastNum)
+	    append text [addPlatformGuard aqua $temp]
+	}
+	## x11 ##
+	if {$block(x11)} {
 	    set temp {}
+	    set lastNum -1
+	    foreach plat {unix macosx x11} {
+		if {$block($plat)} {
+		    set lastNum [expr {$lastNum > $stubs($name,$plat,lastNum)
+			    ? $lastNum : $stubs($name,$plat,lastNum)}]
+		}
+	    }
 	    for {set i 0} {$i <= $lastNum} {incr i} {
-		if {![info exists stubs($name,x11,$i)]} {
+		set emit 0
+		foreach plat {unix macosx x11} {
+		    if {[info exists stubs($name,$plat,$i)]} {
+			if {$plat ne "macosx"} {
+			    append temp [$slotProc $name \
+				    $stubs($name,$plat,$i) $i]
+			} else {
+			    eval {set etxt} $skipString
+			    append temp [addPlatformGuard $plat [$slotProc \
+				    $name $stubs($name,$plat,$i) $i] $etxt true]
+			}
+			set emit 1
+			break
+		    }
+		}
+		if {!$emit} {
 		    eval {append temp} $skipString
-		} else {
-			append temp [$slotProc $name $stubs($name,x11,$i) $i]
 		}
 	    }
 	    append text [addPlatformGuard x11 $temp {} true]
-- 
cgit v0.12