Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b19444f

Browse files
committed
Got rid of ifdefs for long-obsolete GUSI versions and other stuff that is now standard (appearance, interned strings)
1 parent 8ab04b4 commit b19444f

4 files changed

Lines changed: 0 additions & 197 deletions

File tree

Mac/Python/macgetpath.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ PERFORMANCE OF THIS SOFTWARE.
6363
#include <TextUtils.h>
6464
#include <Dialogs.h>
6565

66-
#ifdef USE_GUSI1
67-
#include <GUSI.h>
68-
#endif
69-
7066
#ifndef USE_BUILTIN_PATH
7167
staticforward char *PyMac_GetPythonPath();
7268
#endif
@@ -211,11 +207,6 @@ PyMac_OpenPrefFile()
211207
return -1;
212208
prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm);
213209
if ( prefrh < 0 ) {
214-
#if 0
215-
action = CautionAlert(NOPREFFILE_ID, NULL);
216-
if ( action == NOPREFFILE_NO )
217-
exit(1);
218-
#endif
219210
FSpCreateResFile(&dirspec, 'Pyth', 'pref', 0);
220211
prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm);
221212
if ( prefrh == -1 ) {
@@ -453,28 +444,3 @@ PyMac_PreferenceOptions(PyMac_PrefRecord *pr)
453444
if ( prefrh != -1) CloseResFile(prefrh);
454445
UseResFile(oldrh);
455446
}
456-
457-
#ifdef USE_GUSI1
458-
void
459-
PyMac_SetGUSIOptions()
460-
{
461-
Handle h;
462-
short oldrh, prefrh = -1;
463-
464-
oldrh = CurResFile();
465-
466-
/* Try override from the application resource fork */
467-
UseResFile(PyMac_AppRefNum);
468-
h = Get1Resource('GU\267I', GUSIOPTIONSOVERRIDE_ID);
469-
UseResFile(oldrh);
470-
471-
/* If that didn't work try nonoverride from anywhere */
472-
if ( h == NULL ) {
473-
prefrh = PyMac_OpenPrefFile();
474-
h = GetResource('GU\267I', GUSIOPTIONS_ID);
475-
}
476-
if ( h ) GUSILoadConfiguration(h);
477-
if ( prefrh != -1) CloseResFile(prefrh);
478-
UseResFile(oldrh);
479-
}
480-
#endif /* USE_GUSI1 */

Mac/Python/macglue.c

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ extern pascal unsigned char *PLstrrchr(unsigned char *, unsigned char);
7171

7272
#endif
7373

74-
#ifdef USE_GUSI1
75-
#include <TFileSpec.h> /* For Path2FSSpec */
76-
#include <GUSI.h>
77-
#endif
78-
7974
/* The ID of the Sioux apple menu */
8075
#define SIOUX_APPLEID 32000
8176

@@ -174,11 +169,6 @@ static int upp_inited = 0;
174169
*/
175170
static PyObject *python_event_handler;
176171

177-
/*
178-
** Set to true if we're appearance-compliant
179-
*/
180-
int PyMac_AppearanceCompliant;
181-
182172
/* Given an FSSpec, return the FSSpec of the parent folder */
183173

184174
static OSErr
@@ -250,29 +240,6 @@ PyMac_GetFullPathname (FSSpec *fss, char *buf, int length)
250240
return 0;
251241
}
252242

253-
#ifdef USE_GUSI1
254-
/*
255-
** GUSI (1.6.0 and earlier, at the least) do not set the MacOS idea of
256-
** the working directory. Hence, we call this routine after each call
257-
** to chdir() to rectify things.
258-
*/
259-
void
260-
PyMac_FixGUSIcd()
261-
{
262-
WDPBRec pb;
263-
FSSpec curdirfss;
264-
265-
if ( Path2FSSpec(":x", &curdirfss) != noErr )
266-
return;
267-
268-
/* Set MacOS "working directory" */
269-
pb.ioNamePtr= "\p";
270-
pb.ioVRefNum= curdirfss.vRefNum;
271-
pb.ioWDDirID= curdirfss.parID;
272-
if (PBHSetVolSync(&pb) != noErr)
273-
return;
274-
}
275-
#endif
276243

277244
#ifdef USE_GUSI
278245
/*
@@ -282,48 +249,6 @@ PyMac_FixGUSIcd()
282249
void SpinCursor(short x) { /* Dummy */ }
283250
void RotateCursor(short x) { /* Dummy */ }
284251

285-
/*
286-
** Replacement GUSI Spin function
287-
*/
288-
#ifdef USE_GUSI1
289-
static int
290-
PyMac_GUSISpin(spin_msg msg, long arg)
291-
{
292-
static Boolean inForeground = true;
293-
int maxsleep = 6; /* 6 ticks is "normal" sleeptime */
294-
295-
if (PyMac_ConsoleIsDead) return 0;
296-
#if 0
297-
if (inForeground)
298-
SpinCursor(msg == SP_AUTO_SPIN ? short(arg) : 1);
299-
#endif
300-
301-
302-
if ( msg == SP_AUTO_SPIN )
303-
maxsleep = 0;
304-
if ( msg==SP_SLEEP||msg==SP_SELECT ) {
305-
maxsleep = arg;
306-
/*
307-
** We force-scan for interrupts. Not pretty, but otherwise
308-
** a program may hang in select or sleep forever.
309-
*/
310-
scan_event_queue(1);
311-
}
312-
if (interrupted) {
313-
interrupted = 0;
314-
return -1;
315-
}
316-
317-
PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */
318-
319-
return 0;
320-
}
321-
322-
void
323-
PyMac_SetGUSISpin() {
324-
GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin);
325-
}
326-
#endif
327252

328253
/* Called at exit() time thru atexit(), to stop event processing */
329254
void
@@ -440,11 +365,6 @@ PyOS_CheckStack()
440365
if ( &here < sentinel ) {
441366
if (thread_for_sentinel == PyThreadState_Get()) {
442367
return -1;
443-
#if 0
444-
} else {
445-
/* Else we are unsure... */
446-
fprintf(stderr, "Stackcheck in other thread (was %x now %x)\n", thread_for_sentinel,PyThreadState_Get());
447-
#endif
448368
}
449369
}
450370
return 0;
@@ -735,15 +655,7 @@ PyMac_InitMenuBar()
735655
static unsigned char about_sioux[] = "\pAbout SIOUX";
736656

737657
if ( sioux_mbar ) return;
738-
#if 0
739-
/* This code does not seem to work anymore: apparently
740-
** we now always have a menubar (since MacOS9?).
741-
** So we simply always setup the Sioux menus here.
742-
*/
743-
if ( (sioux_mbar=GetMenuBar()) == NULL ) {
744-
#else
745658
if ( (sioux_mbar=GetMenuBar()) == NULL || GetMenuHandle(SIOUX_APPLEID) == NULL) {
746-
#endif
747659
/* Sioux menu not installed yet. Do so */
748660
SIOUXSetupMenus();
749661
if ( (sioux_mbar=GetMenuBar()) == NULL )
@@ -762,8 +674,6 @@ PyMac_InitMenuBar()
762674
void
763675
PyMac_RestoreMenuBar()
764676
{
765-
#if 1
766-
/* This doesn't seem to work anymore? Or only for Carbon? */
767677
MenuBarHandle curmenubar;
768678

769679
curmenubar = GetMenuBar();
@@ -774,7 +684,6 @@ PyMac_RestoreMenuBar()
774684
PyMac_InitMenuBar();
775685
DrawMenuBar();
776686
}
777-
#endif
778687
}
779688

780689
void

Mac/Python/macimport.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3535
#include <Types.h>
3636
#include <Files.h>
3737
#include <Resources.h>
38-
#if 0
39-
#include <OSUtils.h> /* for Set(Current)A5 */
40-
#include <StandardFile.h>
41-
#include <Memory.h>
42-
#include <Windows.h>
43-
#include <Traps.h>
44-
#include <Processes.h>
45-
#include <Fonts.h>
46-
#include <Menus.h>
47-
#include <TextUtils.h>
48-
#endif
4938
#include <CodeFragments.h>
5039
#include <StringCompare.h>
5140

52-
#ifdef USE_GUSI1
53-
#include "TFileSpec.h" /* for Path2FSSpec() */
54-
#endif
55-
5641
typedef void (*dl_funcptr)();
5742
#define FUNCNAME_PATTERN "init%.200s"
5843

@@ -82,7 +67,6 @@ findnamedresource(
8267
int ok;
8368
Handle h;
8469

85-
#ifdef INTERN_STRINGS
8670
/*
8771
** If we have interning find_module takes care of interning all
8872
** sys.path components. We then keep a record of all sys.path
@@ -100,16 +84,9 @@ findnamedresource(
10084
if ( obj == not_a_file[i] )
10185
return 0;
10286
}
103-
#endif /* INTERN_STRINGS */
104-
#ifdef USE_GUSI1
105-
if ( Path2FSSpec(filename, &fss) != noErr ) {
106-
#else
10787
if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr ) {
108-
#endif
109-
#ifdef INTERN_STRINGS
11088
if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj->ob_sinterned )
11189
not_a_file[max_not_a_file++] = obj;
112-
#endif /* INTERN_STRINGS */
11390
/* doesn't exist or is folder */
11491
return 0;
11592
}
@@ -123,14 +100,12 @@ findnamedresource(
123100
UseResFile(PyMac_AppRefNum);
124101
filerh = -1;
125102
} else {
126-
#ifdef INTERN_STRINGS
127103
if ( FSpGetFInfo(&fss, &finfo) != noErr ) {
128104
if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj->ob_sinterned )
129105
not_a_file[max_not_a_file++] = obj;
130106
/* doesn't exist or is folder */
131107
return 0;
132108
}
133-
#endif /* INTERN_STRINGS */
134109
oldrh = CurResFile();
135110
filerh = FSpOpenResFile(&fss, fsRdPerm);
136111
if ( filerh == -1 )
@@ -270,14 +245,12 @@ PyMac_LoadCodeResourceModule(name, pathname)
270245
"dynamic module not initialized properly");
271246
return NULL;
272247
}
273-
#if 1
274248
/* Remember the filename as the __file__ attribute */
275249
d = PyModule_GetDict(m);
276250
s = PyString_FromString(pathname);
277251
if (s == NULL || PyDict_SetItemString(d, "__file__", s) != 0)
278252
PyErr_Clear(); /* Not important enough to report */
279253
Py_XDECREF(s);
280-
#endif
281254
if (Py_VerboseFlag)
282255
PySys_WriteStderr("import %s # pyd fragment %#s loaded from %s\n",
283256
name, fragmentname, pathname);
@@ -301,12 +274,7 @@ char *filename;
301274
PyObject *m, *co;
302275
long num, size;
303276

304-
#ifdef USE_GUSI1
305-
if ( (err=Path2FSSpec(filename, &fss)) != noErr ||
306-
FSpGetFInfo(&fss, &finfo) != noErr )
307-
#else
308277
if ( (err=FSMakeFSSpec(0, 0, Pstring(filename), &fss)) != noErr )
309-
#endif
310278
goto error;
311279
if ( fssequal(&fss, &PyMac_ApplicationFSSpec) ) {
312280
/*
@@ -423,9 +391,6 @@ PyMac_FindModuleExtension(char *buf, size_t *lenp, char *module)
423391
unsigned char fnbuf[64];
424392
int modnamelen = strlen(module);
425393
FSSpec fss;
426-
#ifdef USE_GUSI1
427-
FInfo finfo;
428-
#endif
429394
short refnum;
430395
long dirid;
431396

@@ -438,14 +403,8 @@ PyMac_FindModuleExtension(char *buf, size_t *lenp, char *module)
438403
return 0;
439404

440405
strcpy(buf+*lenp, _PyImport_Filetab[0].suffix);
441-
#ifdef USE_GUSI1
442-
if ( Path2FSSpec(buf, &fss) == noErr &&
443-
FSpGetFInfo(&fss, &finfo) == noErr)
444-
return _PyImport_Filetab;
445-
#else
446406
if ( FSMakeFSSpec(0, 0, Pstring(buf), &fss) == noErr )
447407
return _PyImport_Filetab;
448-
#endif
449408
/*
450409
** We cannot check for fnfErr (unfortunately), it can mean either that
451410
** the file doesn't exist (fine, we try others) or the path leading to it.

Mac/Python/macmain.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4545
#include <CFBase.h>
4646
#include <CFArray.h>
4747
#endif /* TARGET_API_MAC_CARBON */
48-
#ifdef USE_APPEARANCE
4948
#include <Gestalt.h>
5049
#include <Appearance.h>
51-
#endif /* USE_APPEARANCE */
5250
#else
5351
#include <Carbon/Carbon.h>
5452
#endif /* WITHOUT_FRAMEWORKS */
@@ -91,21 +89,6 @@ PyMac_PrefRecord PyMac_options;
9189
static void Py_Main(int, char **, char *); /* Forward */
9290
void PyMac_Exit(int); /* Forward */
9391

94-
static void init_appearance(void)
95-
{
96-
#ifdef USE_APPEARANCE
97-
OSErr err;
98-
SInt32 response;
99-
100-
err = Gestalt(gestaltAppearanceAttr,&response);
101-
if ( err ) goto no_appearance;
102-
if ( !(response&(1<<gestaltAppearanceExists)) ) goto no_appearance;
103-
/* XXXX Should we check the version? Compat-mode? */
104-
PyMac_AppearanceCompliant = 1;
105-
no_appearance:
106-
return;
107-
#endif /* USE_APPEARANCE */
108-
}
10992
/* Initialize the Mac toolbox world */
11093

11194
static void
@@ -122,7 +105,6 @@ init_mac_world(void)
122105
InitMenus();
123106
#endif
124107
InitCursor();
125-
init_appearance();
126108
}
127109

128110
/*
@@ -283,21 +265,12 @@ init_common(int *argcp, char ***argvp, int embedded)
283265
PyMac_AddLibResources();
284266
#endif
285267

286-
#if defined(USE_GUSI1)
287-
/* Setup GUSI */
288-
GUSIDefaultSetup();
289-
PyMac_SetGUSISpin();
290-
PyMac_SetGUSIOptions();
291-
#endif
292268
#if defined(USE_GUSI)
293269
atexit(PyMac_StopGUSISpin);
294270
#endif
295271

296272
#ifdef USE_SIOUX
297273
/* Set various SIOUX flags. Some are changed later based on options */
298-
#if 0
299-
SIOUXSettings.standalone = 0; /* XXXX Attempting to keep sioux from eating events */
300-
#endif
301274
SIOUXSettings.asktosaveonclose = 0;
302275
SIOUXSettings.showstatusline = 0;
303276
SIOUXSettings.tabspaces = 4;
@@ -598,10 +571,6 @@ PyMac_InitApplication(void)
598571
*endp = '\0';
599572

600573
chdir(curwd);
601-
#ifdef USE_GUSI1
602-
/* Change MacOS's idea of wd too */
603-
PyMac_FixGUSIcd();
604-
#endif
605574
}
606575
/* Check that the first argument is a text file */
607576
if ( PyMac_getfiletype(argv[1]) != 'TEXT' ) {

0 commit comments

Comments
 (0)