diff options
Diffstat (limited to 'mac')
-rw-r--r-- | mac/MW_TclAppleScriptHeader.pch | 3 | ||||
-rw-r--r-- | mac/MW_TclHeader.pch | 15 | ||||
-rw-r--r-- | mac/tclMac.h | 10 | ||||
-rw-r--r-- | mac/tclMacAppInit.c | 9 | ||||
-rw-r--r-- | mac/tclMacCommonDefines.h | 90 | ||||
-rw-r--r-- | mac/tclMacResource.c | 81 | ||||
-rw-r--r-- | mac/tclMacTest.c | 6 |
7 files changed, 67 insertions, 147 deletions
diff --git a/mac/MW_TclAppleScriptHeader.pch b/mac/MW_TclAppleScriptHeader.pch index f37bc1b..bf86989 100644 --- a/mac/MW_TclAppleScriptHeader.pch +++ b/mac/MW_TclAppleScriptHeader.pch @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: MW_TclAppleScriptHeader.pch,v 1.1.2.1 1998/09/24 23:59:08 stanton Exp $ + * RCS: @(#) $Id: MW_TclAppleScriptHeader.pch,v 1.1.2.2 1998/11/11 04:08:26 stanton Exp $ */ /* @@ -22,6 +22,7 @@ * architecture we are compiling for (see the code below). For * example, for a 68k app the prefix file should be: MW_TclHeader68K. */ + #if __POWERPC__ #pragma precompile_target "MW_TclAppleScriptHeaderPPC" #include "MW_TclHeaderPPC" diff --git a/mac/MW_TclHeader.pch b/mac/MW_TclHeader.pch index 01da559..6a193d3 100644 --- a/mac/MW_TclHeader.pch +++ b/mac/MW_TclHeader.pch @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: MW_TclHeader.pch,v 1.1.2.2 1998/09/24 23:59:08 stanton Exp $ + * RCS: @(#) $Id: MW_TclHeader.pch,v 1.1.2.3 1998/11/11 04:08:26 stanton Exp $ */ /* @@ -30,7 +30,7 @@ #pragma precompile_target "MW_TclHeader68K" #endif -#include "tclMacCommonDefines.h" +#include "tclMacCommonPch.h" /* * Place any includes below that will are needed by the majority of the @@ -43,16 +43,5 @@ #include "tclMac.h" #include "tclInt.h" -/* - * These three symbols are needed by Itcl, so we must export them - * here. They are all from tclCompile.h, but there is no need to - * export that whole file... - */ - -EXTERN void TclPrintSource _ANSI_ARGS_((FILE *outFile, - char *string, int maxChars)); -extern int tclTraceExec; -extern int tclTraceCompile; - #pragma export reset diff --git a/mac/tclMac.h b/mac/tclMac.h index 8be6d7a..24f9574 100644 --- a/mac/tclMac.h +++ b/mac/tclMac.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclMac.h,v 1.1.2.2 1998/09/24 23:59:09 stanton Exp $ + * RCS: @(#) $Id: tclMac.h,v 1.1.2.3 1998/11/11 04:08:26 stanton Exp $ */ #ifndef _TCLMAC @@ -79,10 +79,10 @@ EXTERN pascal void FSpCreateResFileCompat(const FSSpec *spec, * Mac calls. These routines is from tclMacUtils.h. */ -EXTERN int FSpLocationFromPath _ANSI_ARGS_((int length, - CONST char *path, FSSpecPtr theSpec)); -EXTERN OSErr FSpPathFromLocation _ANSI_ARGS_((FSSpecPtr theSpec, - int *length, Handle *fullPath)); +EXTERN int FSpLocationFromPath _ANSI_ARGS_((int length, CONST char *path, + FSSpecPtr theSpec)); +EXTERN OSErr FSpPathFromLocation _ANSI_ARGS_((FSSpecPtr theSpec, + int *length, Handle *fullPath)); /* * These are not in MSL 2.1.2, so we need to export them from the diff --git a/mac/tclMacAppInit.c b/mac/tclMacAppInit.c index d39d392..6a4ffc7 100644 --- a/mac/tclMacAppInit.c +++ b/mac/tclMacAppInit.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclMacAppInit.c,v 1.1.2.2 1998/09/24 23:59:09 stanton Exp $ + * RCS: @(#) $Id: tclMacAppInit.c,v 1.1.2.3 1998/11/11 04:08:26 stanton Exp $ */ #include "tcl.h" @@ -26,6 +26,8 @@ short InstallConsole _ANSI_ARGS_((short fd)); #endif #ifdef TCL_TEST +EXTERN int Procbodytest_Init _ANSI_ARGS_((Tcl_Interp *interp)); +EXTERN int Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp *interp)); EXTERN int TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp)); EXTERN int Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp)); #endif /* TCL_TEST */ @@ -108,6 +110,11 @@ Tcl_AppInit( if (TclObjTest_Init(interp) == TCL_ERROR) { return TCL_ERROR; } + if (Procbodytest_Init(interp) == TCL_ERROR) { + return TCL_ERROR; + } + Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init, + Procbodytest_SafeInit); #endif /* TCL_TEST */ /* diff --git a/mac/tclMacCommonDefines.h b/mac/tclMacCommonDefines.h deleted file mode 100644 index a6b184f..0000000 --- a/mac/tclMacCommonDefines.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * tclMacCommonDefines.h -- - * - * This file contains all the defines that commonly go in the .pch files - * for both Tcl & Tk. - * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclMacCommonDefines.h 1.1 98/02/18 13:01:21 - */ - - -/* - * Macintosh Tcl must be compiled with certain compiler options to - * ensure that it will work correctly. The following pragmas are - * used to ensure that those options are set correctly. An error - * will occur at compile time if they are not set correctly. - */ - -#if !__option(enumsalwaysint) -#error Tcl requires the Metrowerks setting "Enums always ints". -#endif - -#if !defined(__POWERPC__) -#if !__option(far_data) -#error Tcl requires the Metrowerks setting "Far data". -#endif -#endif - -#if !defined(__POWERPC__) -#if !__option(fourbyteints) -#error Tcl requires the Metrowerks setting "4 byte ints". -#endif -#endif - -#if !defined(__POWERPC__) -#if !__option(IEEEdoubles) -#error Tcl requires the Metrowerks setting "8 byte doubles". -#endif -#endif - -/* - * The define is used most everywhere to tell Tcl (or any Tcl - * extensions) that we are compiling for the Macintosh platform. - */ - -#define MAC_TCL - -/* - * The following defines control the behavior of the Macintosh - * Universial Headers. - */ - -#define SystemSevenOrLater 1 -#define STRICT_CONTROLS 1 -#define STRICT_WINDOWS 1 - -/* - * Define the following symbol if you want - * to build the Thread capable version of Tcl. - */ - -/* #define TCL_THREADS */ - -/* - * Define the following symbol if you want - * comprehensive debugging turned on. - */ - -/* #define TCL_DEBUG */ - -#ifdef TCL_DEBUG -# define TCL_MEM_DEBUG -# define TCL_TEST -#endif - - -/* - * For a while, we will continue to use the old routine names, so that - * people with older versions of CodeWarrior will still be able to compile - * the source (albeit they will have to update the project files themselves). - * - * At some point, we will convert over to the new routine names. - */ - -#define OLDROUTINENAMES 1 - diff --git a/mac/tclMacResource.c b/mac/tclMacResource.c index 97c480e..033c8d0 100644 --- a/mac/tclMacResource.c +++ b/mac/tclMacResource.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclMacResource.c,v 1.1.2.2 1998/09/24 23:59:16 stanton Exp $ + * RCS: @(#) $Id: tclMacResource.c,v 1.1.2.3 1998/11/11 04:08:27 stanton Exp $ */ #include <Errors.h> @@ -1827,7 +1827,7 @@ GetRsrcRefFromObj( * managed by the procedures in this file. If the resource file * is already registered with the table, then no new token is made. * - * The bahavior is controlled by the value of tokenPtr, and of the + * The behavior is controlled by the value of tokenPtr, and of the * flags variable. For tokenPtr, the possibilities are: * - NULL: The new token is auto-generated, but not returned. * - The string value of tokenPtr is the empty string: Then @@ -1849,7 +1849,7 @@ GetRsrcRefFromObj( * Standard Tcl Result * * Side effects: - * An entry is added to the resource name table. + * An entry may be added to the resource name table. * *---------------------------------------------------------------------- */ @@ -1875,12 +1875,14 @@ TclMacRegisterResourceFork( /* * If we were asked to, check that this file has not been opened - * already. + * already with a different permission. It it has, then return an error. */ + new = 1; + if (flags & TCL_RESOURCE_CHECK_IF_OPEN) { Tcl_HashSearch search; - short oldFileRef; + short oldFileRef, filePermissionFlag; FCBPBRec newFileRec, oldFileRec; OSErr err; @@ -1894,15 +1896,17 @@ TclMacRegisterResourceFork( newFileRec.ioVRefNum = 0; newFileRec.ioRefNum = fileRef; err = PBGetFCBInfo(&newFileRec, false); + filePermissionFlag = ( newFileRec.ioFCBFlags >> 12 ) & 0x1; resourceHashPtr = Tcl_FirstHashEntry(&resourceTable, &search); while (resourceHashPtr != NULL) { - oldFileRef = (short) Tcl_GetHashKey(&resourceTable, resourceHashPtr); - - + if (oldFileRef == fileRef) { + new = 0; + break; + } oldFileRec.ioVRefNum = 0; oldFileRec.ioRefNum = oldFileRef; err = PBGetFCBInfo(&oldFileRec, false); @@ -1913,43 +1917,52 @@ TclMacRegisterResourceFork( * to fix it here, OR because it is the ROM MAP, which has a * fileRef, but can't be gotten to by PBGetFCBInfo. */ - - if (oldFileRef == fileRef) { - resourceId = (char *) Tcl_GetHashValue(resourceHashPtr); - Tcl_SetStringObj(tokenPtr, resourceId, -1); - return TCL_OK; - } else if ((err == noErr) + if ((err == noErr) && (newFileRec.ioFCBVRefNum == oldFileRec.ioFCBVRefNum) - && (newFileRec.ioFCBFlNm == oldFileRec.ioFCBFlNm) - && (newFileRec.ioFCBFlags == oldFileRec.ioFCBFlags)) { + && (newFileRec.ioFCBFlNm == oldFileRec.ioFCBFlNm)) { /* - * THis is the same file. If the permissions are the same as well, - * then close the second path, and return the token for the - * first path - */ - CloseResFile((short) fileRef); - resourceId = (char *) Tcl_GetHashValue(resourceHashPtr); - Tcl_SetStringObj(tokenPtr, resourceId, -1); - return TCL_OK; + * In MacOS 8.1 it seems like we get different file refs even + * though we pass the same file & permissions. This is not + * what Inside Mac says should happen, but it does, so if it + * does, then close the new res file and return the original + * one... + */ + + if (filePermissionFlag == ((oldFileRec.ioFCBFlags >> 12) & 0x1)) { + CloseResFile(fileRef); + new = 0; + break; + } else { + if (tokenPtr != NULL) { + Tcl_SetStringObj(tokenPtr, "Resource already open with different permissions.", -1); + } + return TCL_ERROR; + } } - resourceHashPtr = Tcl_NextHashEntry(&search); } - - } + - resourceHashPtr = Tcl_CreateHashEntry(&resourceTable, + /* + * If the file has already been opened with these same permissions, then it + * will be in our list and we will have set new to 0 above. + * So we will just return the token (if tokenPtr is non-null) + */ + + if (new) { + resourceHashPtr = Tcl_CreateHashEntry(&resourceTable, (char *) fileRef, &new); + } + if (!new) { - if (tokenPtr != NULL) { + if (tokenPtr != NULL) { resourceId = (char *) Tcl_GetHashValue(resourceHashPtr); - Tcl_SetStringObj(tokenPtr, resourceId, -1); + Tcl_SetStringObj(tokenPtr, resourceId, -1); } - return TCL_OK; - } - - + return TCL_OK; + } + /* * If we were passed in a result pointer which is not an empty * string, attempt to use that as the key. If the key already diff --git a/mac/tclMacTest.c b/mac/tclMacTest.c index 54ea96d..8f1117c 100644 --- a/mac/tclMacTest.c +++ b/mac/tclMacTest.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclMacTest.c,v 1.1.2.1 1998/09/24 23:59:18 stanton Exp $ + * RCS: @(#) $Id: tclMacTest.c,v 1.1.2.2 1998/11/11 04:08:27 stanton Exp $ */ #define TCL_TEST @@ -188,11 +188,11 @@ WriteTextResource( strcpy((char *) resourceName, rsrcName); c2pstr((char *) resourceName); - dataHandle = NewHandle(strlen(data) + 1); + dataHandle = NewHandle(strlen(data)); HLock(dataHandle); strcpy(*dataHandle, data); HUnlock(dataHandle); - + /* * Add the resource to the file and close it. */ |