mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
- Reorganized init code
- Fixed serious bug in code to get options from a resource
This commit is contained in:
parent
dc1c64a148
commit
01fbc68896
5 changed files with 63 additions and 45 deletions
|
@ -76,3 +76,9 @@
|
||||||
#define POPT_KEEPNORM 5
|
#define POPT_KEEPNORM 5
|
||||||
#define POPT_KEEPERR 6
|
#define POPT_KEEPERR 6
|
||||||
|
|
||||||
|
/* From macgetpath.c: */
|
||||||
|
void PyMac_PreferenceOptions Py_PROTO((int *inspect, int *verbose, int *suppress_print,
|
||||||
|
int *unbuffered, int *debugging, int *keep_normal,
|
||||||
|
int *keep_error));
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
extern void PyMac_InitApplication();
|
extern void PyMac_InitApplication();
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
#if defined(USE_GUSI)
|
|
||||||
GUSIDefaultSetup();
|
|
||||||
#endif
|
|
||||||
#if defined(__MWERKS__) && defined(__CFM68K__)
|
#if defined(__MWERKS__) && defined(__CFM68K__)
|
||||||
printf("Hello, world!\n");
|
printf("Hello, world!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -295,31 +295,12 @@ event_loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the Mac toolbox world */
|
|
||||||
|
|
||||||
static void
|
|
||||||
init_mac_world()
|
|
||||||
{
|
|
||||||
#ifdef THINK_C
|
|
||||||
printf("\n");
|
|
||||||
#else
|
|
||||||
MaxApplZone();
|
|
||||||
InitGraf(&qd.thePort);
|
|
||||||
InitFonts();
|
|
||||||
InitWindows();
|
|
||||||
TEInit();
|
|
||||||
InitDialogs((long)0);
|
|
||||||
InitMenus();
|
|
||||||
InitCursor();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/* Get the argv vector, return argc */
|
/* Get the argv vector, return argc */
|
||||||
|
|
||||||
int
|
int
|
||||||
PyMac_GetArgv(pargv)
|
PyMac_GetArgv(pargv)
|
||||||
char ***pargv;
|
char ***pargv;
|
||||||
{
|
{
|
||||||
init_mac_world();
|
|
||||||
|
|
||||||
arg_count = 0;
|
arg_count = 0;
|
||||||
arg_vector[arg_count++] = strdup(get_application_name());
|
arg_vector[arg_count++] = strdup(get_application_name());
|
||||||
|
|
|
@ -43,9 +43,9 @@ getpythonpath()
|
||||||
char *curwd;
|
char *curwd;
|
||||||
char *p, *endp;
|
char *p, *endp;
|
||||||
int newlen;
|
int newlen;
|
||||||
extern char *PyMac_GetPythonDir();
|
staticforward char *PyMac_GetPythonDir();
|
||||||
#ifndef USE_BUILTIN_PATH
|
#ifndef USE_BUILTIN_PATH
|
||||||
extern char *PyMac_GetPythonPath();
|
staticforward char *PyMac_GetPythonPath();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( pythonpath ) return pythonpath;
|
if ( pythonpath ) return pythonpath;
|
||||||
|
@ -89,7 +89,7 @@ getpythonpath()
|
||||||
/*
|
/*
|
||||||
** Open/create the Python Preferences file, return the handle
|
** Open/create the Python Preferences file, return the handle
|
||||||
*/
|
*/
|
||||||
short
|
static short
|
||||||
PyMac_OpenPrefFile()
|
PyMac_OpenPrefFile()
|
||||||
{
|
{
|
||||||
AliasHandle handle;
|
AliasHandle handle;
|
||||||
|
@ -142,7 +142,7 @@ PyMac_OpenPrefFile()
|
||||||
/*
|
/*
|
||||||
** Return the name of the Python directory
|
** Return the name of the Python directory
|
||||||
*/
|
*/
|
||||||
char *
|
static char *
|
||||||
PyMac_GetPythonDir()
|
PyMac_GetPythonDir()
|
||||||
{
|
{
|
||||||
static char name[256];
|
static char name[256];
|
||||||
|
@ -187,7 +187,7 @@ PyMac_GetPythonDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_BUILTIN_PATH
|
#ifndef USE_BUILTIN_PATH
|
||||||
char *
|
static char *
|
||||||
PyMac_GetPythonPath(dir)
|
PyMac_GetPythonPath(dir)
|
||||||
char *dir;
|
char *dir;
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,6 +68,54 @@ static int orig_argc;
|
||||||
static int keep_normal;
|
static int keep_normal;
|
||||||
static int keep_error = 1;
|
static int keep_error = 1;
|
||||||
|
|
||||||
|
/* Initialize the Mac toolbox world */
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_mac_world()
|
||||||
|
{
|
||||||
|
#ifdef THINK_C
|
||||||
|
printf("\n");
|
||||||
|
#else
|
||||||
|
MaxApplZone();
|
||||||
|
InitGraf(&qd.thePort);
|
||||||
|
InitFonts();
|
||||||
|
InitWindows();
|
||||||
|
TEInit();
|
||||||
|
InitDialogs((long)0);
|
||||||
|
InitMenus();
|
||||||
|
InitCursor();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialization code shared by interpreter and applets */
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_common()
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Initialize toolboxes */
|
||||||
|
init_mac_world();
|
||||||
|
|
||||||
|
#ifdef USE_MAC_SHARED_LIBRARY
|
||||||
|
/* Add the shared library to the stack of resource files */
|
||||||
|
PyMac_AddLibResources();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_GUSI)
|
||||||
|
/* Setup GUSI */
|
||||||
|
GUSIDefaultSetup();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_SIOUX
|
||||||
|
/* Set various SIOUX flags. Some are changed later based on options */
|
||||||
|
SIOUXSettings.asktosaveonclose = 0;
|
||||||
|
SIOUXSettings.showstatusline = 0;
|
||||||
|
SIOUXSettings.tabspaces = 4;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_MAC_APPLET_SUPPORT
|
#ifdef USE_MAC_APPLET_SUPPORT
|
||||||
/* Applet support */
|
/* Applet support */
|
||||||
|
|
||||||
|
@ -112,14 +160,7 @@ PyMac_InitApplet()
|
||||||
char **argv;
|
char **argv;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
#ifdef USE_MAC_SHARED_LIBRARY
|
init_common();
|
||||||
PyMac_AddLibResources();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_SIOUX
|
|
||||||
SIOUXSettings.asktosaveonclose = 0;
|
|
||||||
SIOUXSettings.showstatusline = 0;
|
|
||||||
SIOUXSettings.tabspaces = 4;
|
|
||||||
#endif
|
|
||||||
argc = PyMac_GetArgv(&argv);
|
argc = PyMac_GetArgv(&argv);
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
PySys_SetArgv(argc, argv);
|
PySys_SetArgv(argc, argv);
|
||||||
|
@ -139,14 +180,7 @@ PyMac_InitApplication()
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
|
|
||||||
#ifdef USE_MAC_SHARED_LIBRARY
|
init_common();
|
||||||
PyMac_AddLibResources();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_SIOUX
|
|
||||||
SIOUXSettings.asktosaveonclose = 0;
|
|
||||||
SIOUXSettings.showstatusline = 0;
|
|
||||||
SIOUXSettings.tabspaces = 4;
|
|
||||||
#endif
|
|
||||||
argc = PyMac_GetArgv(&argv);
|
argc = PyMac_GetArgv(&argv);
|
||||||
if ( argc > 1 ) {
|
if ( argc > 1 ) {
|
||||||
/* We're running a script. Attempt to change current directory */
|
/* We're running a script. Attempt to change current directory */
|
||||||
|
@ -181,8 +215,8 @@ PyMac_InteractiveOptions(int *inspect, int *verbose, int *suppress_print,
|
||||||
/* Default-defaults: */
|
/* Default-defaults: */
|
||||||
*keep_error = 1;
|
*keep_error = 1;
|
||||||
/* Get default settings from our preference file */
|
/* Get default settings from our preference file */
|
||||||
PyMac_PreferenceOptions(&inspect, &Py_VerboseFlag, &Py_SuppressPrintingFlag,
|
PyMac_PreferenceOptions(inspect, verbose, suppress_print,
|
||||||
&unbuffered, &Py_DebugFlag, &keep_normal, &keep_error);
|
unbuffered, debugging, keep_normal, keep_error);
|
||||||
/* If option is pressed override these */
|
/* If option is pressed override these */
|
||||||
GetKeys(rmap);
|
GetKeys(rmap);
|
||||||
map = (unsigned char *)rmap;
|
map = (unsigned char *)rmap;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue