Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macmain.c @ 3236:463b26fa4d7b legacy-trunk
Added options for keeping window open on normal/error termination
Moved whole exit-handling of console window here (from pythonrun.c)
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Fri, 27 Oct 1995 13:32:30 +0000 |
| parents | f4a59ffe1a5f |
| children | 20d74fa3b50b |
| rev | line source |
|---|---|
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /*********************************************************** |
| 2091 | 2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 3 The Netherlands. | |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 All Rights Reserved |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 ******************************************************************/ |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
25 /* Python interpreter main program */ |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
27 #include "Python.h" |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
28 #include "pythonresources.h" |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
29 #include "import.h" |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
30 #include "marshal.h" |
|
2144
0e60cd207adb
must include rename2.h
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
31 |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
32 #include <Memory.h> |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
33 #include <Resources.h> |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 #include <stdio.h> |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
35 #include <Events.h> |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
36 #include <Windows.h> |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
37 #include <Desk.h> |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 |
|
2277
df7e26b5c918
Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents:
2226
diff
changeset
|
39 #ifdef __MWERKS__ |
|
df7e26b5c918
Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents:
2226
diff
changeset
|
40 #include <SIOUX.h> |
|
df7e26b5c918
Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents:
2226
diff
changeset
|
41 #endif |
|
df7e26b5c918
Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents:
2226
diff
changeset
|
42 |
|
3236
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
43 #ifdef THINK_C |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
44 #include <console.h> |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
45 #endif |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
46 |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
47 #define STARTUP "PythonStartup" |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
48 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
49 extern int Py_DebugFlag; /* For parser.c, declared in pythonrun.c */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
50 extern int Py_VerboseFlag; /* For import.c, declared in pythonrun.c */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
51 extern int Py_SuppressPrintingFlag; /* For ceval.c, declared in pythonrun.c */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
52 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
53 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
54 /* Subroutines that live in their own file */ |
| 3228 | 55 extern char *getversion Py_PROTO((void)); |
| 56 extern char *getcopyright Py_PROTO((void)); | |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
57 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
58 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
59 /* For getprogramname(); set by main() */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
60 static char *argv0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
61 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
62 /* For getargcargv(); set by main() */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
63 static char **orig_argv; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
64 static int orig_argc; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
65 |
|
3236
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
66 /* Flags indicating whether stdio window should stay open on termination */ |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
67 static int keep_normal; |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
68 static int keep_error = 1; |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
69 |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
70 #ifdef USE_MAC_APPLET_SUPPORT |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
71 /* Applet support */ |
|
2031
1739f00ffc86
Enlarged version buffer (nobody expects the spanish inquisition:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
1821
diff
changeset
|
72 |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
73 /* Run a compiled Python Python script from 'PYC ' resource __main__ */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
74 static int |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
75 run_main_resource() |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
76 { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
77 Handle h; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
78 long size; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
79 PyObject *code; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
80 PyObject *result; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
81 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
82 h = GetNamedResource('PYC ', "\p__main__"); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
83 if (h == NULL) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
84 Alert(NOPYC_ALERT, NULL); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
85 return 1; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
86 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
87 size = GetResourceSizeOnDisk(h); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
88 HLock(h); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
89 code = PyMarshal_ReadObjectFromString(*h + 8, (int)(size - 8)); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
90 HUnlock(h); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
91 ReleaseResource(h); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
92 if (code == NULL) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
93 PyErr_Print(); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
94 return 1; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
95 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
96 result = PyImport_ExecCodeModule("__main__", code); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
97 Py_DECREF(code); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
98 if (result == NULL) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
99 PyErr_Print(); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
100 return 1; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
101 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
102 Py_DECREF(result); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
103 return 0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
104 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
105 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
106 /* Initialization sequence for applets */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
107 void |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
108 PyMac_InitApplet() |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
109 { |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 int argc; |
|
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 char **argv; |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
112 int err; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
113 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
114 #ifdef USE_MAC_SHARED_LIBRARY |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
115 PyMac_AddLibResources(); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
116 #endif |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
117 #ifdef __MWERKS__ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
118 SIOUXSettings.asktosaveonclose = 0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
119 SIOUXSettings.showstatusline = 0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
120 SIOUXSettings.tabspaces = 4; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
121 #endif |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
122 argc = PyMac_GetArgv(&argv); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
123 Py_Initialize(); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
124 PySys_SetArgv(argc, argv); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
125 err = run_main_resource(); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
126 fflush(stderr); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
127 fflush(stdout); |
|
3236
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
128 PyMac_Exit(err); |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
129 /* XXX Should we bother to Py_Exit(sts)? */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
130 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
131 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
132 #endif /* USE_MAC_APPLET_SUPPORT */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
133 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
134 /* For normal application */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
135 void |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
136 PyMac_InitApplication() |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 { |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
138 int argc; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
139 char **argv; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
140 |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
141 #ifdef USE_MAC_SHARED_LIBRARY |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
142 PyMac_AddLibResources(); |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
143 #endif |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
144 #ifdef __MWERKS__ |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
145 SIOUXSettings.asktosaveonclose = 0; |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
146 SIOUXSettings.showstatusline = 0; |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
147 SIOUXSettings.tabspaces = 4; |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
148 #endif |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
149 argc = PyMac_GetArgv(&argv); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
150 if ( argc > 1 ) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
151 /* We're running a script. Attempt to change current directory */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
152 char curwd[256], *endp; |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
153 |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
154 strcpy(curwd, argv[1]); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
155 endp = strrchr(curwd, ':'); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
156 if ( endp && endp > curwd ) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
157 *endp = '\0'; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
158 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
159 chdir(curwd); |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
160 } |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
161 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
162 Py_Main(argc, argv); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
163 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
164 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
165 /* |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
166 ** PyMac_InteractiveOptions - Allow user to set options if option key is pressed |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
167 */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
168 void |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
169 PyMac_InteractiveOptions(int *inspect, int *verbose, int *suppress_print, |
|
3236
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
170 int *unbuffered, int *debugging, int *keep_normal, |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
171 int *keep_error) |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
172 { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
173 KeyMap rmap; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
174 unsigned char *map; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
175 short item, type; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
176 ControlHandle handle; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
177 DialogPtr dialog; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
178 Rect rect; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
179 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
180 GetKeys(rmap); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
181 map = (unsigned char *)rmap; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
182 if ( ( map[0x3a>>3] & (1<<(0x3a&7)) ) == 0 ) /* option key is 3a */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
183 return; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
184 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
185 dialog = GetNewDialog(OPT_DIALOG, NULL, (WindowPtr)-1); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
186 if ( dialog == NULL ) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
187 printf("Option dialog not found - cannot set options\n"); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
188 return; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
189 } |
|
3236
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
190 |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
191 /* Set keep-open-on-error */ |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
192 GetDialogItem(dialog, OPT_KEEPERROR, &type, (Handle *)&handle, &rect); |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
193 SetCtlValue(handle, *keep_error); |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
194 |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
195 while (1) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
196 handle = NULL; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
197 ModalDialog(NULL, &item); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
198 if ( item == OPT_OK ) |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
199 break; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
200 if ( item == OPT_CANCEL ) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
201 DisposDialog(dialog); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
202 exit(0); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
203 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
204 #define OPT_ITEM(num, var) \ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
205 if ( item == (num) ) { \ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
206 *(var) = !*(var); \ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
207 GetDialogItem(dialog, (num), &type, (Handle *)&handle, &rect); \ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
208 SetCtlValue(handle, (short)*(var)); \ |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
209 } |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
210 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
211 OPT_ITEM(OPT_INSPECT, inspect); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
212 OPT_ITEM(OPT_VERBOSE, verbose); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
213 OPT_ITEM(OPT_SUPPRESS, suppress_print); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
214 OPT_ITEM(OPT_UNBUFFERED, unbuffered); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
215 OPT_ITEM(OPT_DEBUGGING, debugging); |
|
3236
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
216 OPT_ITEM(OPT_KEEPNORMAL, keep_normal); |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
217 OPT_ITEM(OPT_KEEPERROR, keep_error); |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
218 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
219 #undef OPT_ITEM |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
220 } |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
221 DisposDialog(dialog); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
222 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
223 /* Main program */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
224 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
225 int |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
226 Py_Main(argc, argv) |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
227 int argc; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
228 char **argv; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
229 { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
230 int sts; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
231 char *command = NULL; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
232 char *filename = NULL; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
233 FILE *fp = stdin; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
234 int inspect = 0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
235 int unbuffered = 0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
236 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
237 orig_argc = argc; /* For getargcargv() */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
238 orig_argv = argv; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
239 argv0 = argv[0]; /* For getprogramname() */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
240 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
241 PyMac_InteractiveOptions(&inspect, &Py_VerboseFlag, &Py_SuppressPrintingFlag, |
|
3236
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
242 &unbuffered, &Py_DebugFlag, &keep_normal, &keep_error); |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
243 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
244 if (unbuffered) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
245 #ifndef MPW |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
246 setbuf(stdout, (char *)NULL); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
247 setbuf(stderr, (char *)NULL); |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
248 #else |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
249 /* On MPW (3.2) unbuffered seems to hang */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
250 setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
251 setvbuf(stderr, (char *)NULL, _IOLBF, BUFSIZ); |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
252 #endif |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
253 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
254 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
255 filename = argv[1]; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
256 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
257 if (Py_VerboseFlag || |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
258 command == NULL && filename == NULL && isatty((int)fileno(fp))) |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
259 fprintf(stderr, "Python %s\n%s\n", |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
260 getversion(), getcopyright()); |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
261 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
262 if (filename != NULL) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
263 if ((fp = fopen(filename, "r")) == NULL) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
264 fprintf(stderr, "%s: can't open file '%s'\n", |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
265 argv[0], filename); |
|
3236
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
266 PyMac_Exit(2); |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
267 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
268 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
269 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
270 Py_Initialize(); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
271 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
272 PySys_SetArgv(argc-1, argv+1); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
273 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
274 if (filename == NULL && isatty((int)fileno(fp))) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
275 FILE *fp = fopen(STARTUP, "r"); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
276 if (fp != NULL) { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
277 (void) PyRun_SimpleFile(fp, STARTUP); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
278 PyErr_Clear(); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
279 fclose(fp); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
280 } |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
281 } |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
282 sts = PyRun_AnyFile( |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
283 fp, filename == NULL ? "<stdin>" : filename) != 0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
284 if (filename != NULL) |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
285 fclose(fp); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
286 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
287 if (inspect && isatty((int)fileno(stdin)) && |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
288 (filename != NULL || command != NULL)) |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
289 sts = PyRun_AnyFile(stdin, "<stdin>") != 0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
290 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
291 Py_Exit(sts); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
292 /*NOTREACHED*/ |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
293 } |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
294 |
|
3236
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
295 /* |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
296 ** Terminate application |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
297 */ |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
298 PyMac_Exit(status) |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
299 int status; |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
300 { |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
301 int keep; |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
302 |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
303 if ( status ) |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
304 keep = keep_error; |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
305 else |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
306 keep = keep_normal; |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
307 |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
308 #ifdef __MWERKS__ |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
309 if (keep) |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
310 printf("\n[Terminated]\n"); |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
311 else |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
312 SIOUXSettings.autocloseonquit = 1; |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
313 #endif |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
314 #ifdef THINK_C |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
315 console_options.pause_atexit = keep; |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
316 #endif |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
317 |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
318 exit(status); |
|
463b26fa4d7b
Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents:
3228
diff
changeset
|
319 } |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
320 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
321 /* Return the program name -- some code out there needs this. */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
322 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
323 char * |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
324 getprogramname() |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
325 { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
326 return argv0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
327 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
328 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
329 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
330 /* Make the *original* argc/argv available to other modules. |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
331 This is rare, but it is needed by the secureware extension. */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
332 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
333 void |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
334 getargcargv(argc,argv) |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
335 int *argc; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
336 char ***argv; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
337 { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
338 *argc = orig_argc; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
339 *argv = orig_argv; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
340 } |
