Moved configuration-dependent initializations (etc.) to config_*.c

This commit is contained in:
Guido van Rossum 1990-11-18 17:28:24 +00:00
parent 10dc2e8097
commit da0c6bdfe3
1 changed files with 9 additions and 154 deletions

View File

@ -1,25 +1,10 @@
/* Python interpreter main program */ /* Python interpreter main program */
/* XXX This is still a mess */
#ifdef THINK_C
#define USE_STDWIN
#endif
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include "string.h" #include "string.h"
#ifdef USE_STDWIN extern char *getpythonpath();
#include "stdwin.h"
int use_stdwin;
#endif
#ifdef USE_AUDIO
#include "asa.h"
#endif
extern char *getenv();
#include "PROTO.h" #include "PROTO.h"
#include "grammar.h" #include "grammar.h"
@ -33,54 +18,17 @@ extern char *getenv();
extern grammar gram; /* From graminit.c */ extern grammar gram; /* From graminit.c */
#ifndef PYTHONPATH
#ifdef THINK_C
#define PYTHONPATH ": :mod"
#else /* !THINK_C */
#ifdef AMOEBA
#define PYTHONPATH ".:/profile/module/python"
#else /* !AMOEBA */
#define PYTHONPATH ".:/usr/local/lib/python"
#endif /* !AMOEBA */
#endif /* !THINK_C */
#endif /* !PYTHONPATH */
int debugging; int debugging;
main(argc, argv) main(argc, argv)
int argc; int argc;
char **argv; char **argv;
{ {
char *path;
char *filename = NULL; char *filename = NULL;
FILE *fp = stdin; FILE *fp = stdin;
int ret; int ret;
#ifdef USE_STDWIN initargs(&argc, &argv);
#ifdef THINK_C
wsetstdio(1);
#else THINK_C
/* Must use "python -s" now to get stdwin support */
if (argc > 1 && strcmp(argv[1], "-s") == 0)
argv[1] = argv[0],
argc--, argv++,
#endif /* !THINK_C */
use_stdwin = 1;
if (use_stdwin)
winitargs(&argc, &argv);
#endif /* USE_STDWIN */
#ifdef THINK_C_not_today
printf("argc = %d, argv[0] = '%s'\n", argc, argv[0]);
if (argc <= 1)
askargs(&argc, &argv);
#endif
initintr(); /* For intrcheck() */ initintr(); /* For intrcheck() */
@ -101,43 +49,10 @@ main(argc, argv)
inittime(); inittime();
initmath(); initmath();
#ifndef THINK_C setpythonpath(getpythonpath());
path = getenv("PYTHONPATH");
if (path == NULL)
#endif
path = PYTHONPATH;
setpythonpath(path);
initrun(); initrun();
initcalls();
#ifdef USE_POSIX
initposix();
#endif
#ifdef THINK_C
initmac();
#endif
#ifdef USE_AUDIO
initaudio();
#endif
#ifdef USE_AMOEBA
initamoeba();
#endif
#ifdef USE_STDWIN
if (use_stdwin)
initstdwin();
#endif
#ifdef USE_GL
initgl();
#endif
#ifdef USE_PANEL
initpanel();
#endif
if (!isatty(fileno(fp))) { if (!isatty(fileno(fp))) {
ret = runfile(fp, file_input, (char *)NULL, (char *)NULL); ret = runfile(fp, file_input, (char *)NULL, (char *)NULL);
@ -176,21 +91,12 @@ main(argc, argv)
goaway(sts) goaway(sts)
int sts; int sts;
{ {
closerun();
#ifdef USE_STDWIN
if (use_stdwin)
wdone();
#endif
#ifdef USE_AUDIO
asa_done();
#endif
#ifdef THINK_C #ifdef THINK_C
#ifndef TRACE_REFS
/* Avoid 'click mouse to continue' in Lightspeed C */
if (sts == 0) if (sts == 0)
Click_On(0); Click_On(0);
#endif #endif
#endif closerun();
donecalls();
exit(sts); exit(sts);
/*NOTREACHED*/ /*NOTREACHED*/
} }
@ -211,8 +117,6 @@ runfile(fp, start, ps1, ps2)
return execute(n) == 0 ? E_DONE : E_ERROR; return execute(n) == 0 ? E_DONE : E_ERROR;
} }
#ifdef THINK_C
/* Ask a yes/no question */ /* Ask a yes/no question */
int int
@ -227,6 +131,8 @@ askyesno(prompt)
return buf[0] == 'y' || buf[0] == 'Y'; return buf[0] == 'y' || buf[0] == 'Y';
} }
#ifdef THINK_C
/* Check for file descriptor connected to interactive device. /* Check for file descriptor connected to interactive device.
Pretend that stdin is always interactive, other files never. */ Pretend that stdin is always interactive, other files never. */
@ -237,57 +143,6 @@ isatty(fd)
return fd == fileno(stdin); return fd == fileno(stdin);
} }
/* Kludge to get arguments on the Mac */
#define MAXARGS 20
static char *
nextarg(pnext)
char **pnext;
{
char *ret;
char *p = *pnext;
while (isspace(*p))
p++;
if (*p == '\0')
return NULL;
ret = p;
while (!isspace(*p))
p++;
if (*p != '\0')
*p++ = '\0';
*pnext = p;
return ret;
}
static
askargs(pargc, pargv)
int *pargc;
char ***pargv; /* sic */
{
static char buf[256];
static char *argv[MAXARGS];
int argc;
char *p, *next;
fprintf(stderr, "Args: ");
if (fgets(buf, sizeof buf, stdin) == NULL)
return;
next = buf;
if ((p = nextarg(&next)) == NULL)
return;
if (*pargc > 0)
argv[0] = (*pargv)[0];
else
argv[0] = "PYTHON";
argc = 1;
argv[argc++] = p;
while (argc+1 < MAXARGS && (p = nextarg(&next)) != NULL)
argv[argc++] = p;
argv[argc] = NULL;
*pargc = argc;
*pargv = argv;
}
#endif #endif
/* WISH LIST /* WISH LIST