]> granicus.if.org Git - python/commitdiff
- Reorganized init code
authorJack Jansen <jack.jansen@cwi.nl>
Wed, 28 Feb 1996 15:42:47 +0000 (15:42 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Wed, 28 Feb 1996 15:42:47 +0000 (15:42 +0000)
- Fixed serious bug in code to get options from a resource

Mac/Include/pythonresources.h
Mac/Python/macapplication.c
Mac/Python/macgetargv.c
Mac/Python/macgetpath.c
Mac/Python/macmain.c

index ca00a2399f907ab1820ea938672785ae8710029e..49e909f5878efa1d5ba6d4dfd936756769752820 100644 (file)
 #define POPT_DEBUGGING 4
 #define POPT_KEEPNORM  5
 #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));
+
  
index 5d7bc830eb78979ad70f2ad8bc41fd72e0efd24e..00287418826eb2173d7fb53e7d50387e8dc36836 100644 (file)
@@ -31,9 +31,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 extern void PyMac_InitApplication();
 
 main() {
-#if defined(USE_GUSI)
-       GUSIDefaultSetup();
-#endif
 #if defined(__MWERKS__) && defined(__CFM68K__)
        printf("Hello, world!\n");
 #endif
index 90cdb5a698df873237ea4585c8dd7c8c7df6d7bd..96a02fdec54f97f29a7c4bfd23b24925ed6fd4e1 100644 (file)
@@ -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 */
 
 int
 PyMac_GetArgv(pargv)
        char ***pargv;
 {
-       init_mac_world();
        
        arg_count = 0;
        arg_vector[arg_count++] = strdup(get_application_name());
index b78273630be126d751b10ce15d28895eec9eb4d2..38feb3e92ebe624b5a6a9260807981994c567475 100644 (file)
@@ -43,9 +43,9 @@ getpythonpath()
        char *curwd;
        char *p, *endp;
        int newlen;
-       extern char *PyMac_GetPythonDir();
+       staticforward char *PyMac_GetPythonDir();
 #ifndef USE_BUILTIN_PATH
-       extern char *PyMac_GetPythonPath();
+       staticforward char *PyMac_GetPythonPath();
 #endif
        
        if ( pythonpath ) return pythonpath;
@@ -89,7 +89,7 @@ getpythonpath()
 /*
 ** Open/create the Python Preferences file, return the handle
 */
-short
+static short
 PyMac_OpenPrefFile()
 {
     AliasHandle handle;
@@ -142,7 +142,7 @@ PyMac_OpenPrefFile()
 /*
 ** Return the name of the Python directory
 */
-char *
+static char *
 PyMac_GetPythonDir()
 {
     static char name[256];
@@ -187,7 +187,7 @@ PyMac_GetPythonDir()
 }
 
 #ifndef USE_BUILTIN_PATH
-char *
+static char *
 PyMac_GetPythonPath(dir)
 char *dir;
 {
index ecaa0187fc9c2d3c5c0e6e8af8e35c09992b5e1d..3d878ed4328bd5f5a67c2751733c6625dc721985 100644 (file)
@@ -68,6 +68,54 @@ static int  orig_argc;
 static int keep_normal;
 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
 /* Applet support */
 
@@ -112,14 +160,7 @@ PyMac_InitApplet()
        char **argv;
        int err;
 
-#ifdef USE_MAC_SHARED_LIBRARY
-       PyMac_AddLibResources();
-#endif
-#ifdef USE_SIOUX
-       SIOUXSettings.asktosaveonclose = 0;
-       SIOUXSettings.showstatusline = 0;
-       SIOUXSettings.tabspaces = 4;
-#endif
+       init_common();
        argc = PyMac_GetArgv(&argv);
        Py_Initialize();
        PySys_SetArgv(argc, argv);
@@ -139,14 +180,7 @@ PyMac_InitApplication()
        int argc;
        char **argv;
        
-#ifdef USE_MAC_SHARED_LIBRARY
-       PyMac_AddLibResources();
-#endif
-#ifdef USE_SIOUX
-       SIOUXSettings.asktosaveonclose = 0;
-       SIOUXSettings.showstatusline = 0;
-       SIOUXSettings.tabspaces = 4;
-#endif
+       init_common();
        argc = PyMac_GetArgv(&argv);
        if ( argc > 1 ) {
                /* 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: */
        *keep_error = 1;
        /* Get default settings from our preference file */
-       PyMac_PreferenceOptions(&inspect, &Py_VerboseFlag, &Py_SuppressPrintingFlag,
-                       &unbuffered, &Py_DebugFlag, &keep_normal, &keep_error);
+       PyMac_PreferenceOptions(inspect, verbose, suppress_print,
+                       unbuffered, debugging, keep_normal, keep_error);
        /* If option is pressed override these */
        GetKeys(rmap);
        map = (unsigned char *)rmap;