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 */
/* XXX This is still a mess */
#ifdef THINK_C
#define USE_STDWIN
#endif
#include <stdio.h>
#include <ctype.h>
#include "string.h"
#ifdef USE_STDWIN
#include "stdwin.h"
int use_stdwin;
#endif
#ifdef USE_AUDIO
#include "asa.h"
#endif
extern char *getenv();
extern char *getpythonpath();
#include "PROTO.h"
#include "grammar.h"
@ -33,54 +18,17 @@ extern char *getenv();
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;
main(argc, argv)
int argc;
char **argv;
{
char *path;
char *filename = NULL;
FILE *fp = stdin;
int ret;
#ifdef USE_STDWIN
#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
initargs(&argc, &argv);
initintr(); /* For intrcheck() */
@ -101,43 +49,10 @@ main(argc, argv)
inittime();
initmath();
#ifndef THINK_C
path = getenv("PYTHONPATH");
if (path == NULL)
#endif
path = PYTHONPATH;
setpythonpath(path);
setpythonpath(getpythonpath());
initrun();
#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
initcalls();
if (!isatty(fileno(fp))) {
ret = runfile(fp, file_input, (char *)NULL, (char *)NULL);
@ -176,21 +91,12 @@ main(argc, argv)
goaway(sts)
int sts;
{
closerun();
#ifdef USE_STDWIN
if (use_stdwin)
wdone();
#endif
#ifdef USE_AUDIO
asa_done();
#endif
#ifdef THINK_C
#ifndef TRACE_REFS
/* Avoid 'click mouse to continue' in Lightspeed C */
if (sts == 0)
Click_On(0);
#endif
#endif
closerun();
donecalls();
exit(sts);
/*NOTREACHED*/
}
@ -211,8 +117,6 @@ runfile(fp, start, ps1, ps2)
return execute(n) == 0 ? E_DONE : E_ERROR;
}
#ifdef THINK_C
/* Ask a yes/no question */
int
@ -227,6 +131,8 @@ askyesno(prompt)
return buf[0] == 'y' || buf[0] == 'Y';
}
#ifdef THINK_C
/* Check for file descriptor connected to interactive device.
Pretend that stdin is always interactive, other files never. */
@ -237,57 +143,6 @@ isatty(fd)
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
/* WISH LIST