Kaydet (Commit) f1dc5663 authored tarafından 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.
üst 9e90a672
This diff is collapsed.
...@@ -27,9 +27,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -27,9 +27,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "allobjects.h" #include "allobjects.h"
#include <errno.h> #include <errno.h>
#ifndef errno
extern int errno;
#endif
#include "modsupport.h" #include "modsupport.h"
......
...@@ -469,7 +469,7 @@ floatsleep(secs) ...@@ -469,7 +469,7 @@ floatsleep(secs)
#endif /* unix */ #endif /* unix */
#ifdef TURBO_C /* Maybe also for MS-DOS? */ #ifdef TURBO_C
#ifndef CLOCKS_PER_SEC #ifndef CLOCKS_PER_SEC
#define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */ #define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */
...@@ -492,3 +492,14 @@ millitimer() ...@@ -492,3 +492,14 @@ millitimer()
} }
#endif /* TURBO_C */ #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. ...@@ -30,10 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define BUF(v) GETSTRINGVALUE((stringobject *)v) #define BUF(v) GETSTRINGVALUE((stringobject *)v)
#include "errno.h" #include <errno.h>
#ifndef errno
extern int errno;
#endif
typedef struct { typedef struct {
OB_HEAD OB_HEAD
......
...@@ -31,10 +31,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -31,10 +31,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h" #include "modsupport.h"
#include <errno.h> #include <errno.h>
#ifndef errno
extern int errno;
#endif
#include <ctype.h> #include <ctype.h>
#include <math.h> #include <math.h>
......
...@@ -131,7 +131,20 @@ static SIGTYPE ...@@ -131,7 +131,20 @@ static SIGTYPE
intcatcher(sig) intcatcher(sig)
int sig; /* Not used by required by interface */ 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); signal(SIGINT, intcatcher);
} }
......
...@@ -47,6 +47,13 @@ int main PROTO((int, char **)); ...@@ -47,6 +47,13 @@ int main PROTO((int, char **));
char *askfile PROTO((void)); char *askfile PROTO((void));
#endif #endif
void
goaway(sts)
int sts;
{
exit(sts);
}
int int
main(argc, argv) main(argc, argv)
int argc; int argc;
...@@ -62,7 +69,7 @@ main(argc, argv) ...@@ -62,7 +69,7 @@ main(argc, argv)
#else #else
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "usage: %s grammar\n", argv[0]); fprintf(stderr, "usage: %s grammar\n", argv[0]);
exit(2); goaway(2);
} }
filename = argv[1]; filename = argv[1];
#endif #endif
...@@ -70,7 +77,7 @@ main(argc, argv) ...@@ -70,7 +77,7 @@ main(argc, argv)
fp = fopen("graminit.c", "w"); fp = fopen("graminit.c", "w");
if (fp == NULL) { if (fp == NULL) {
perror("graminit.c"); perror("graminit.c");
exit(1); goaway(1);
} }
printf("Writing graminit.c ...\n"); printf("Writing graminit.c ...\n");
printgrammar(g, fp); printgrammar(g, fp);
...@@ -78,12 +85,12 @@ main(argc, argv) ...@@ -78,12 +85,12 @@ main(argc, argv)
fp = fopen("graminit.h", "w"); fp = fopen("graminit.h", "w");
if (fp == NULL) { if (fp == NULL) {
perror("graminit.h"); perror("graminit.h");
exit(1); goaway(1);
} }
printf("Writing graminit.h ...\n"); printf("Writing graminit.h ...\n");
printnonterminals(g, fp); printnonterminals(g, fp);
fclose(fp); fclose(fp);
exit(0); goaway(0);
} }
grammar * grammar *
...@@ -97,7 +104,7 @@ getgrammar(filename) ...@@ -97,7 +104,7 @@ getgrammar(filename)
fp = fopen(filename, "r"); fp = fopen(filename, "r");
if (fp == NULL) { if (fp == NULL) {
perror(filename); perror(filename);
exit(1); goaway(1);
} }
g0 = meta_grammar(); g0 = meta_grammar();
n = NULL; n = NULL;
...@@ -105,12 +112,12 @@ getgrammar(filename) ...@@ -105,12 +112,12 @@ getgrammar(filename)
fclose(fp); fclose(fp);
if (n == NULL) { if (n == NULL) {
fprintf(stderr, "Parsing error.\n"); fprintf(stderr, "Parsing error.\n");
exit(1); goaway(1);
} }
g = pgen(n); g = pgen(n);
if (g == NULL) { if (g == NULL) {
printf("Bad grammar.\n"); printf("Bad grammar.\n");
exit(1); goaway(1);
} }
return g; return g;
} }
...@@ -124,12 +131,12 @@ askfile() ...@@ -124,12 +131,12 @@ askfile()
printf("Input file name: "); printf("Input file name: ");
if (fgets(buf, sizeof buf, stdin) == NULL) { if (fgets(buf, sizeof buf, stdin) == NULL) {
printf("EOF\n"); printf("EOF\n");
exit(1); goaway(1);
} }
/* XXX The (unsigned char *) case is needed by THINK C 3.0 */ /* XXX The (unsigned char *) case is needed by THINK C 3.0 */
if (sscanf(/*(unsigned char *)*/buf, " %s ", name) != 1) { if (sscanf(/*(unsigned char *)*/buf, " %s ", name) != 1) {
printf("No file\n"); printf("No file\n");
exit(1); goaway(1);
} }
return name; return name;
} }
...@@ -140,7 +147,7 @@ fatal(msg) ...@@ -140,7 +147,7 @@ fatal(msg)
char *msg; char *msg;
{ {
fprintf(stderr, "pgen: FATAL ERROR: %s\n", msg); fprintf(stderr, "pgen: FATAL ERROR: %s\n", msg);
exit(1); goaway(1);
} }
#ifdef macintosh #ifdef macintosh
......
...@@ -1652,7 +1652,7 @@ locals_2_fast(f, clear) ...@@ -1652,7 +1652,7 @@ locals_2_fast(f, clear)
err_setval(error_type, error_value); err_setval(error_type, error_value);
} }
void static void
mergelocals() mergelocals()
{ {
locals_2_fast(current_frame, 1); locals_2_fast(current_frame, 1);
......
...@@ -39,8 +39,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -39,8 +39,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "structmember.h" #include "structmember.h"
#include <ctype.h> #include <ctype.h>
#include <errno.h>
extern int errno;
#define OFF(x) offsetof(codeobject, x) #define OFF(x) offsetof(codeobject, x)
......
...@@ -59,9 +59,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -59,9 +59,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h" #include "modsupport.h"
#include <errno.h> #include <errno.h>
#ifndef errno
extern int errno;
#endif
#include "errcode.h" #include "errcode.h"
......
...@@ -27,8 +27,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -27,8 +27,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <math.h> #include <math.h>
#include <errno.h> #include <errno.h>
extern int errno;
double double
fmod(x, y) fmod(x, y)
double x, y; double x, y;
......
...@@ -38,7 +38,6 @@ main(argc, argv) ...@@ -38,7 +38,6 @@ main(argc, argv)
{ {
char *p; char *p;
int n, inspect, sts; int n, inspect, sts;
int n;
if ((p = getenv("PYTHONDEBUG")) && *p != '\0') if ((p = getenv("PYTHONDEBUG")) && *p != '\0')
debugging = 1; debugging = 1;
...@@ -63,8 +62,7 @@ main(argc, argv) ...@@ -63,8 +62,7 @@ main(argc, argv)
else else
sts = 0; sts = 0;
if (inspect && isatty((int)fileno(stdin)) && if (inspect && isatty((int)fileno(stdin)))
(filename != NULL || command != NULL))
sts = run(stdin, "<stdin>") != 0; sts = run(stdin, "<stdin>") != 0;
goaway(sts); goaway(sts);
......
...@@ -30,8 +30,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -30,8 +30,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
extern int errno;
#ifndef NO_GETWD #ifndef NO_GETWD
/* Default: Version for BSD systems -- use getwd() */ /* Default: Version for BSD systems -- use getwd() */
......
...@@ -34,7 +34,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -34,7 +34,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "marshal.h" #include "marshal.h"
#include <errno.h> #include <errno.h>
extern int errno;
#define TYPE_NULL '0' #define TYPE_NULL '0'
#define TYPE_NONE 'N' #define TYPE_NONE 'N'
......
...@@ -314,6 +314,8 @@ int getargs(va_alist) va_dcl ...@@ -314,6 +314,8 @@ int getargs(va_alist) va_dcl
return ok; return ok;
} }
#ifdef UNUSED
int int
getlongtuplearg(args, a, n) getlongtuplearg(args, a, n)
object *args; object *args;
...@@ -394,6 +396,8 @@ getshortlistarg(args, a, n) ...@@ -394,6 +396,8 @@ getshortlistarg(args, a, n)
return 1; return 1;
} }
#endif /* UNUSED */
/* Generic function to create a value -- the inverse of getargs() */ /* Generic function to create a value -- the inverse of getargs() */
/* After an original idea and first implementation by Steven Miale */ /* After an original idea and first implementation by Steven Miale */
......
...@@ -284,7 +284,7 @@ run_file(fp, filename, start, globals, locals) ...@@ -284,7 +284,7 @@ run_file(fp, filename, start, globals, locals)
return run_err_node(err, n, filename, globals, locals); return run_err_node(err, n, filename, globals, locals);
} }
object * static object *
run_err_node(err, n, filename, globals, locals) run_err_node(err, n, filename, globals, locals)
int err; int err;
node *n; node *n;
...@@ -298,7 +298,7 @@ run_err_node(err, n, filename, globals, locals) ...@@ -298,7 +298,7 @@ run_err_node(err, n, filename, globals, locals)
return run_node(n, filename, globals, locals); return run_node(n, filename, globals, locals);
} }
object * static object *
run_node(n, filename, globals, locals) run_node(n, filename, globals, locals)
node *n; node *n;
char *filename; char *filename;
...@@ -307,7 +307,7 @@ run_node(n, filename, globals, locals) ...@@ -307,7 +307,7 @@ run_node(n, filename, globals, locals)
return eval_node(n, filename, globals, locals); return eval_node(n, filename, globals, locals);
} }
object * static object *
eval_node(n, filename, globals, locals) eval_node(n, filename, globals, locals)
node *n; node *n;
char *filename; char *filename;
...@@ -392,7 +392,7 @@ fatal(msg) ...@@ -392,7 +392,7 @@ fatal(msg)
extern int threads_started; extern int threads_started;
#endif #endif
void static void
cleanup() cleanup()
{ {
object *exitfunc = sysget("exitfunc"); object *exitfunc = sysget("exitfunc");
...@@ -461,7 +461,7 @@ goaway(sts) ...@@ -461,7 +461,7 @@ goaway(sts)
} }
#ifdef HANDLE_SIGNALS #ifdef HANDLE_SIGNALS
SIGTYPE static SIGTYPE
sighandler(sig) sighandler(sig)
int sig; int sig;
{ {
...@@ -472,7 +472,7 @@ sighandler(sig) ...@@ -472,7 +472,7 @@ sighandler(sig)
} }
#endif #endif
void static void
initsigs() initsigs()
{ {
initintr(); 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