Commit f23fc0fd authored by Guido van Rossum's avatar Guido van Rossum

* Makefile: added all: and default: targets.

* many files: made some functions static; removed "extern int errno;".
* frozenmain.c: fixed bugs introduced on 24 June...
* flmodule.c: remove 1.5 bw compat hacks, add new functions in 2.2a
  (and some old functions that were omitted).
* timemodule.c: added MSDOS floatsleep version .
* pgenmain.c: changed exit() to goaway() and added defn of goaway().
* intrcheck.c: add hack (to UNIX only) so interrupting 3 times
  will exit from a hanging program.  The second interrupt prints
  a message explaining this to the user.
parent 03a26654
This diff is collapsed.
......@@ -27,9 +27,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "allobjects.h"
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#include "modsupport.h"
......
......@@ -469,7 +469,7 @@ floatsleep(secs)
#endif /* unix */
#ifdef TURBO_C /* Maybe also for MS-DOS? */
#ifdef TURBO_C
#ifndef CLOCKS_PER_SEC
#define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */
......@@ -492,3 +492,14 @@ millitimer()
}
#endif /* TURBO_C */
#ifdef MSDOS
floatsleep(secs)
double secs;
{
clock_t t= clock( );
while( (clock()-t)/CLOCKS_PER_SEC<secs )
;
}
#endif /* MSDOS */
......@@ -30,10 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define BUF(v) GETSTRINGVALUE((stringobject *)v)
#include "errno.h"
#ifndef errno
extern int errno;
#endif
#include <errno.h>
typedef struct {
OB_HEAD
......
......@@ -31,10 +31,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h"
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#include <ctype.h>
#include <math.h>
......
......@@ -131,7 +131,20 @@ static SIGTYPE
intcatcher(sig)
int sig; /* Not used by required by interface */
{
interrupted = 1;
extern void goaway PROTO((int));
static char message[] =
"python: to interrupt a truly hanging Python program, interrupt once more.\n";
switch (interrupted++) {
case 0:
break;
case 1:
write(2, message, strlen(message));
break;
case 2:
interrupted = 0;
goaway(1);
break;
}
signal(SIGINT, intcatcher);
}
......
......@@ -47,6 +47,13 @@ int main PROTO((int, char **));
char *askfile PROTO((void));
#endif
void
goaway(sts)
int sts;
{
exit(sts);
}
int
main(argc, argv)
int argc;
......@@ -62,7 +69,7 @@ main(argc, argv)
#else
if (argc != 2) {
fprintf(stderr, "usage: %s grammar\n", argv[0]);
exit(2);
goaway(2);
}
filename = argv[1];
#endif
......@@ -70,7 +77,7 @@ main(argc, argv)
fp = fopen("graminit.c", "w");
if (fp == NULL) {
perror("graminit.c");
exit(1);
goaway(1);
}
printf("Writing graminit.c ...\n");
printgrammar(g, fp);
......@@ -78,12 +85,12 @@ main(argc, argv)
fp = fopen("graminit.h", "w");
if (fp == NULL) {
perror("graminit.h");
exit(1);
goaway(1);
}
printf("Writing graminit.h ...\n");
printnonterminals(g, fp);
fclose(fp);
exit(0);
goaway(0);
}
grammar *
......@@ -97,7 +104,7 @@ getgrammar(filename)
fp = fopen(filename, "r");
if (fp == NULL) {
perror(filename);
exit(1);
goaway(1);
}
g0 = meta_grammar();
n = NULL;
......@@ -105,12 +112,12 @@ getgrammar(filename)
fclose(fp);
if (n == NULL) {
fprintf(stderr, "Parsing error.\n");
exit(1);
goaway(1);
}
g = pgen(n);
if (g == NULL) {
printf("Bad grammar.\n");
exit(1);
goaway(1);
}
return g;
}
......@@ -124,12 +131,12 @@ askfile()
printf("Input file name: ");
if (fgets(buf, sizeof buf, stdin) == NULL) {
printf("EOF\n");
exit(1);
goaway(1);
}
/* XXX The (unsigned char *) case is needed by THINK C 3.0 */
if (sscanf(/*(unsigned char *)*/buf, " %s ", name) != 1) {
printf("No file\n");
exit(1);
goaway(1);
}
return name;
}
......@@ -140,7 +147,7 @@ fatal(msg)
char *msg;
{
fprintf(stderr, "pgen: FATAL ERROR: %s\n", msg);
exit(1);
goaway(1);
}
#ifdef macintosh
......
......@@ -1652,7 +1652,7 @@ locals_2_fast(f, clear)
err_setval(error_type, error_value);
}
void
static void
mergelocals()
{
locals_2_fast(current_frame, 1);
......
......@@ -39,8 +39,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "structmember.h"
#include <ctype.h>
extern int errno;
#include <errno.h>
#define OFF(x) offsetof(codeobject, x)
......
......@@ -59,9 +59,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h"
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#include "errcode.h"
......
......@@ -27,8 +27,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <math.h>
#include <errno.h>
extern int errno;
double
fmod(x, y)
double x, y;
......
......@@ -38,7 +38,6 @@ main(argc, argv)
{
char *p;
int n, inspect, sts;
int n;
if ((p = getenv("PYTHONDEBUG")) && *p != '\0')
debugging = 1;
......@@ -63,8 +62,7 @@ main(argc, argv)
else
sts = 0;
if (inspect && isatty((int)fileno(stdin)) &&
(filename != NULL || command != NULL))
if (inspect && isatty((int)fileno(stdin)))
sts = run(stdin, "<stdin>") != 0;
goaway(sts);
......
......@@ -30,8 +30,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdio.h>
#include <errno.h>
extern int errno;
#ifndef NO_GETWD
/* Default: Version for BSD systems -- use getwd() */
......
......@@ -34,7 +34,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "marshal.h"
#include <errno.h>
extern int errno;
#define TYPE_NULL '0'
#define TYPE_NONE 'N'
......
......@@ -314,6 +314,8 @@ int getargs(va_alist) va_dcl
return ok;
}
#ifdef UNUSED
int
getlongtuplearg(args, a, n)
object *args;
......@@ -394,6 +396,8 @@ getshortlistarg(args, a, n)
return 1;
}
#endif /* UNUSED */
/* Generic function to create a value -- the inverse of getargs() */
/* After an original idea and first implementation by Steven Miale */
......
......@@ -284,7 +284,7 @@ run_file(fp, filename, start, globals, locals)
return run_err_node(err, n, filename, globals, locals);
}
object *
static object *
run_err_node(err, n, filename, globals, locals)
int err;
node *n;
......@@ -298,7 +298,7 @@ run_err_node(err, n, filename, globals, locals)
return run_node(n, filename, globals, locals);
}
object *
static object *
run_node(n, filename, globals, locals)
node *n;
char *filename;
......@@ -307,7 +307,7 @@ run_node(n, filename, globals, locals)
return eval_node(n, filename, globals, locals);
}
object *
static object *
eval_node(n, filename, globals, locals)
node *n;
char *filename;
......@@ -392,7 +392,7 @@ fatal(msg)
extern int threads_started;
#endif
void
static void
cleanup()
{
object *exitfunc = sysget("exitfunc");
......@@ -461,7 +461,7 @@ goaway(sts)
}
#ifdef HANDLE_SIGNALS
SIGTYPE
static SIGTYPE
sighandler(sig)
int sig;
{
......@@ -472,7 +472,7 @@ sighandler(sig)
}
#endif
void
static void
initsigs()
{
initintr();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment