Mercurial > cpython-lru_cache-weakref
annotate Python/frozenmain.c @ 7278:59d2761ba1cf legacy-trunk
Remove obsolete pagenumbering / pagestyle cruft.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Fri, 13 Feb 1998 07:08:56 +0000 |
| parents | bccdeca81669 |
| children | 6c6a48bc5817 |
| rev | line source |
|---|---|
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /*********************************************************** |
|
2062
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1848
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1848
diff
changeset
|
3 The Netherlands. |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 All Rights Reserved |
|
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
12 Centrum or CWI or Corporation for National Research Initiatives or |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
13 CNRI not be used in advertising or publicity pertaining to |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
14 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
15 permission. |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
17 While CWI is the initial source for this software, a modified version |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
18 is made available by the Corporation for National Research Initiatives |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
19 (CNRI) at the Internet address ftp://ftp.python.org. |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
20 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4041
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 ******************************************************************/ |
|
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 |
|
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 /* Python interpreter main program for frozen scripts */ |
|
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
| 2624 | 34 #include "Python.h" |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 |
|
7116
41514d1ed664
Add unistd.h for isatty().
Guido van Rossum <guido@python.org>
parents:
6723
diff
changeset
|
36 #ifdef HAVE_UNISTD_H |
|
41514d1ed664
Add unistd.h for isatty().
Guido van Rossum <guido@python.org>
parents:
6723
diff
changeset
|
37 #include <unistd.h> /* For isatty() */ |
|
41514d1ed664
Add unistd.h for isatty().
Guido van Rossum <guido@python.org>
parents:
6723
diff
changeset
|
38 #endif |
|
41514d1ed664
Add unistd.h for isatty().
Guido van Rossum <guido@python.org>
parents:
6723
diff
changeset
|
39 |
|
2892
33b154b6c61b
moved stuff around to resemble main.c
Guido van Rossum <guido@python.org>
parents:
2624
diff
changeset
|
40 /* Main program */ |
|
33b154b6c61b
moved stuff around to resemble main.c
Guido van Rossum <guido@python.org>
parents:
2624
diff
changeset
|
41 |
|
33b154b6c61b
moved stuff around to resemble main.c
Guido van Rossum <guido@python.org>
parents:
2624
diff
changeset
|
42 int |
|
5887
2a172b4950b6
frozenmain.c is now also in the library,
Guido van Rossum <guido@python.org>
parents:
5852
diff
changeset
|
43 Py_FrozenMain(argc, argv) |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 int argc; |
|
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 char **argv; |
|
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 { |
|
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 char *p; |
|
1396
4a286b300b5e
Must initialize 'inspect' flag
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
48 int n, sts; |
|
4a286b300b5e
Must initialize 'inspect' flag
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
49 int inspect = 0; |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1396
diff
changeset
|
50 int unbuffered = 0; |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1396
diff
changeset
|
51 |
|
7210
bccdeca81669
Set Py_FrozenFlag, to suppress error messages from getpath.c.
Guido van Rossum <guido@python.org>
parents:
7116
diff
changeset
|
52 Py_FrozenFlag = 1; /* Suppress errors from getpath.c */ |
|
bccdeca81669
Set Py_FrozenFlag, to suppress error messages from getpath.c.
Guido van Rossum <guido@python.org>
parents:
7116
diff
changeset
|
53 |
|
1318
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1270
diff
changeset
|
54 if ((p = getenv("PYTHONINSPECT")) && *p != '\0') |
|
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1270
diff
changeset
|
55 inspect = 1; |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1396
diff
changeset
|
56 if ((p = getenv("PYTHONUNBUFFERED")) && *p != '\0') |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1396
diff
changeset
|
57 unbuffered = 1; |
|
1318
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1270
diff
changeset
|
58 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1396
diff
changeset
|
59 if (unbuffered) { |
|
6723
c3f85bcb045a
Make stdin unbuffered too, when PYTHONUNBUFFERED is specified.
Guido van Rossum <guido@python.org>
parents:
6055
diff
changeset
|
60 setbuf(stdin, (char *)NULL); |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1396
diff
changeset
|
61 setbuf(stdout, (char *)NULL); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1396
diff
changeset
|
62 setbuf(stderr, (char *)NULL); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1396
diff
changeset
|
63 } |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1396
diff
changeset
|
64 |
|
5852
4a4778e61c14
Tracking changes to Py_Main():
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
65 Py_SetProgramName(argv[0]); |
|
4a4778e61c14
Tracking changes to Py_Main():
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
66 Py_Initialize(); |
|
4a4778e61c14
Tracking changes to Py_Main():
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
67 |
| 2624 | 68 if (Py_VerboseFlag) |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1396
diff
changeset
|
69 fprintf(stderr, "Python %s\n%s\n", |
|
3621
f158edccc72c
grand renaming; added copyright to some files
Guido van Rossum <guido@python.org>
parents:
2892
diff
changeset
|
70 Py_GetVersion(), Py_GetCopyright()); |
|
5852
4a4778e61c14
Tracking changes to Py_Main():
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
71 |
| 2624 | 72 PySys_SetArgv(argc, argv); |
|
1318
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1270
diff
changeset
|
73 |
| 2624 | 74 n = PyImport_ImportFrozenModule("__main__"); |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 if (n == 0) |
| 2624 | 76 Py_FatalError("__main__ not frozen"); |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 if (n < 0) { |
| 2624 | 78 PyErr_Print(); |
|
1318
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1270
diff
changeset
|
79 sts = 1; |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 } |
|
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 else |
|
1318
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1270
diff
changeset
|
82 sts = 0; |
|
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1270
diff
changeset
|
83 |
|
1319
cd397266dc1c
* Makefile: added all: and default: targets.
Guido van Rossum <guido@python.org>
parents:
1318
diff
changeset
|
84 if (inspect && isatty((int)fileno(stdin))) |
| 2624 | 85 sts = PyRun_AnyFile(stdin, "<stdin>") != 0; |
|
1318
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1270
diff
changeset
|
86 |
| 6055 | 87 Py_Finalize(); |
| 88 return sts; | |
|
1270
14369a5e6167
Support for frozen scripts; added -i option.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 } |
