Skip to content

Commit 74fea6e

Browse files
author
guido
committed
* 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. git-svn-id: http://svn.python.org/projects/python/trunk@3485 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 5b04357 commit 74fea6e

16 files changed

Lines changed: 140 additions & 165 deletions

Modules/flmodule.c

Lines changed: 83 additions & 122 deletions
Large diffs are not rendered by default.

Modules/mathmodule.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2727
#include "allobjects.h"
2828

2929
#include <errno.h>
30-
#ifndef errno
31-
extern int errno;
32-
#endif
3330

3431
#include "modsupport.h"
3532

Modules/timemodule.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ floatsleep(secs)
469469
#endif /* unix */
470470

471471

472-
#ifdef TURBO_C /* Maybe also for MS-DOS? */
472+
#ifdef TURBO_C
473473

474474
#ifndef CLOCKS_PER_SEC
475475
#define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */
@@ -492,3 +492,14 @@ millitimer()
492492
}
493493

494494
#endif /* TURBO_C */
495+
496+
#ifdef MSDOS
497+
498+
floatsleep(secs)
499+
double secs;
500+
{
501+
clock_t t= clock( );
502+
while( (clock()-t)/CLOCKS_PER_SEC<secs )
503+
;
504+
}
505+
#endif /* MSDOS */

Objects/fileobject.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3030

3131
#define BUF(v) GETSTRINGVALUE((stringobject *)v)
3232

33-
#include "errno.h"
34-
#ifndef errno
35-
extern int errno;
36-
#endif
33+
#include <errno.h>
3734

3835
typedef struct {
3936
OB_HEAD

Objects/floatobject.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3131
#include "modsupport.h"
3232

3333
#include <errno.h>
34-
#ifndef errno
35-
extern int errno;
36-
#endif
37-
3834
#include <ctype.h>
3935
#include <math.h>
4036

Parser/intrcheck.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,20 @@ static SIGTYPE
131131
intcatcher(sig)
132132
int sig; /* Not used by required by interface */
133133
{
134-
interrupted = 1;
134+
extern void goaway PROTO((int));
135+
static char message[] =
136+
"python: to interrupt a truly hanging Python program, interrupt once more.\n";
137+
switch (interrupted++) {
138+
case 0:
139+
break;
140+
case 1:
141+
write(2, message, strlen(message));
142+
break;
143+
case 2:
144+
interrupted = 0;
145+
goaway(1);
146+
break;
147+
}
135148
signal(SIGINT, intcatcher);
136149
}
137150

Parser/pgenmain.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ int main PROTO((int, char **));
4747
char *askfile PROTO((void));
4848
#endif
4949

50+
void
51+
goaway(sts)
52+
int sts;
53+
{
54+
exit(sts);
55+
}
56+
5057
int
5158
main(argc, argv)
5259
int argc;
@@ -62,28 +69,28 @@ main(argc, argv)
6269
#else
6370
if (argc != 2) {
6471
fprintf(stderr, "usage: %s grammar\n", argv[0]);
65-
exit(2);
72+
goaway(2);
6673
}
6774
filename = argv[1];
6875
#endif
6976
g = getgrammar(filename);
7077
fp = fopen("graminit.c", "w");
7178
if (fp == NULL) {
7279
perror("graminit.c");
73-
exit(1);
80+
goaway(1);
7481
}
7582
printf("Writing graminit.c ...\n");
7683
printgrammar(g, fp);
7784
fclose(fp);
7885
fp = fopen("graminit.h", "w");
7986
if (fp == NULL) {
8087
perror("graminit.h");
81-
exit(1);
88+
goaway(1);
8289
}
8390
printf("Writing graminit.h ...\n");
8491
printnonterminals(g, fp);
8592
fclose(fp);
86-
exit(0);
93+
goaway(0);
8794
}
8895

8996
grammar *
@@ -97,20 +104,20 @@ getgrammar(filename)
97104
fp = fopen(filename, "r");
98105
if (fp == NULL) {
99106
perror(filename);
100-
exit(1);
107+
goaway(1);
101108
}
102109
g0 = meta_grammar();
103110
n = NULL;
104111
parsefile(fp, filename, g0, g0->g_start, (char *)NULL, (char *)NULL, &n);
105112
fclose(fp);
106113
if (n == NULL) {
107114
fprintf(stderr, "Parsing error.\n");
108-
exit(1);
115+
goaway(1);
109116
}
110117
g = pgen(n);
111118
if (g == NULL) {
112119
printf("Bad grammar.\n");
113-
exit(1);
120+
goaway(1);
114121
}
115122
return g;
116123
}
@@ -124,12 +131,12 @@ askfile()
124131
printf("Input file name: ");
125132
if (fgets(buf, sizeof buf, stdin) == NULL) {
126133
printf("EOF\n");
127-
exit(1);
134+
goaway(1);
128135
}
129136
/* XXX The (unsigned char *) case is needed by THINK C 3.0 */
130137
if (sscanf(/*(unsigned char *)*/buf, " %s ", name) != 1) {
131138
printf("No file\n");
132-
exit(1);
139+
goaway(1);
133140
}
134141
return name;
135142
}
@@ -140,7 +147,7 @@ fatal(msg)
140147
char *msg;
141148
{
142149
fprintf(stderr, "pgen: FATAL ERROR: %s\n", msg);
143-
exit(1);
150+
goaway(1);
144151
}
145152

146153
#ifdef macintosh

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,7 @@ locals_2_fast(f, clear)
16521652
err_setval(error_type, error_value);
16531653
}
16541654

1655-
void
1655+
static void
16561656
mergelocals()
16571657
{
16581658
locals_2_fast(current_frame, 1);

Python/compile.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3939
#include "structmember.h"
4040

4141
#include <ctype.h>
42-
43-
extern int errno;
42+
#include <errno.h>
4443

4544
#define OFF(x) offsetof(codeobject, x)
4645

Python/errors.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5959
#include "modsupport.h"
6060

6161
#include <errno.h>
62-
#ifndef errno
63-
extern int errno;
64-
#endif
6562

6663
#include "errcode.h"
6764

0 commit comments

Comments
 (0)