Patch #672053: Return a result from Py_Main, instead of exiting.

This commit is contained in:
Martin v. Löwis 2003-03-30 17:09:58 +00:00
parent e98922fb80
commit 852ba7eb2a

View file

@ -88,7 +88,7 @@ PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\
"; ";
static void static int
usage(int exitcode, char* program) usage(int exitcode, char* program)
{ {
FILE *f = exitcode ? stderr : stdout; FILE *f = exitcode ? stderr : stdout;
@ -105,14 +105,14 @@ usage(int exitcode, char* program)
#if defined(__VMS) #if defined(__VMS)
if (exitcode == 0) { if (exitcode == 0) {
/* suppress 'error' message */ /* suppress 'error' message */
exit(1); return 1;
} }
else { else {
/* STS$M_INHIB_MSG + SS$_ABORT */ /* STS$M_INHIB_MSG + SS$_ABORT */
exit(0x1000002c); return 0x1000002c;
} }
#else #else
exit(exitcode); return exitcode;
#endif #endif
/*NOTREACHED*/ /*NOTREACHED*/
} }
@ -194,7 +194,7 @@ Py_Main(int argc, char **argv)
fprintf(stderr, fprintf(stderr,
"-Q option should be `-Qold', " "-Q option should be `-Qold', "
"`-Qwarn', `-Qwarnall', or `-Qnew' only\n"); "`-Qwarn', `-Qwarnall', or `-Qnew' only\n");
usage(2, argv[0]); return usage(2, argv[0]);
/* NOTREACHED */ /* NOTREACHED */
case 'i': case 'i':
@ -255,18 +255,18 @@ Py_Main(int argc, char **argv)
/* This space reserved for other options */ /* This space reserved for other options */
default: default:
usage(2, argv[0]); return usage(2, argv[0]);
/*NOTREACHED*/ /*NOTREACHED*/
} }
} }
if (help) if (help)
usage(0, argv[0]); return usage(0, argv[0]);
if (version) { if (version) {
fprintf(stderr, "Python %s\n", PY_VERSION); fprintf(stderr, "Python %s\n", PY_VERSION);
exit(0); return 0;
} }
if (!saw_inspect_flag && if (!saw_inspect_flag &&
@ -291,7 +291,7 @@ Py_Main(int argc, char **argv)
if ((fp = fopen(filename, "r")) == NULL) { if ((fp = fopen(filename, "r")) == NULL) {
fprintf(stderr, "%s: can't open file '%s'\n", fprintf(stderr, "%s: can't open file '%s'\n",
argv[0], filename); argv[0], filename);
exit(2); return 2;
} }
else if (skipfirstline) { else if (skipfirstline) {
int ch; int ch;