diff options
author | Guido van Rossum <guido@python.org> | 1993-07-05 10:31:29 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-07-05 10:31:29 (GMT) |
commit | f1dc56632881fe4e5beed047580bf927679f3669 (patch) | |
tree | f669dcac15ec9cb2801b881c3a7b1a579e7c994e /Parser | |
parent | 9e90a672b44e2acfd5c6dabfb9435bb4bb46c845 (diff) | |
download | cpython-f1dc56632881fe4e5beed047580bf927679f3669.zip cpython-f1dc56632881fe4e5beed047580bf927679f3669.tar.gz cpython-f1dc56632881fe4e5beed047580bf927679f3669.tar.bz2 |
* 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.
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/intrcheck.c | 15 | ||||
-rw-r--r-- | Parser/pgenmain.c | 27 |
2 files changed, 31 insertions, 11 deletions
diff --git a/Parser/intrcheck.c b/Parser/intrcheck.c index 4636b3f..f5891ee 100644 --- a/Parser/intrcheck.c +++ b/Parser/intrcheck.c @@ -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); } diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c index 57cdc61..1b759d5 100644 --- a/Parser/pgenmain.c +++ b/Parser/pgenmain.c @@ -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 |