* 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.
This commit is contained in:
Guido van Rossum 1993-07-05 10:31:29 +00:00
parent 9e90a672b4
commit f1dc566328
16 changed files with 140 additions and 165 deletions

View File

@ -24,10 +24,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* FL module -- interface to Mark Overmars' FORMS Library. */
/* As distributed, this code works with FORMS 2.0.
If you #define the symbol FL_V15 it will work with FORMS 1.5 (I hope),
and possibly also with previous versions.
(You must also edit FL.py to set _v15 to 1.) */
/* This code works with FORMS version 2.2a.
FORMS can be ftp'ed from ftp.cs.ruu.nl (131.211.80.17), directory
/pub/SGI/FORMS. */
/* A half-hearted attempt has been made to allow programs using this
* module to exploit parallelism (through the threads module). No provisions
@ -269,6 +268,35 @@ generic_unfreeze_object(g, args)
return generic_call(g, args, fl_unfreeze_object);
}
static object *
generic_activate_object(g, args)
genericobject *g;
object *args;
{
return generic_call(g, args, fl_activate_object);
}
static object *
generic_deactivate_object(g, args)
genericobject *g;
object *args;
{
return generic_call(g, args, fl_deactivate_object);
}
static object *
generic_set_object_shortcut(g, args)
genericobject *g;
object *args;
{
char *str;
if (!getargs(args, "s", &str))
return NULL;
fl_set_object_shortcut(g->ob_generic, str);
INCREF(None);
return None;
}
static struct methodlist generic_methods[] = {
{"set_call_back", generic_set_call_back},
{"delete_object", generic_delete_object},
@ -277,10 +305,9 @@ static struct methodlist generic_methods[] = {
{"redraw_object", generic_redraw_object},
{"freeze_object", generic_freeze_object},
{"unfreeze_object", generic_unfreeze_object},
#if 0
{"handle_object", generic_handle_object},
{"handle_object_direct",generic_handle_object_direct},
#endif
{"activate_object", generic_activate_object},
{"deactivate_object", generic_deactivate_object},
{"set_object_shortcut", generic_set_object_shortcut},
{NULL, NULL} /* sentinel */
};
@ -314,7 +341,7 @@ static struct memberlist generic_memberlist[] = {
{"pushed", T_INT, OFF(pushed), RO},
{"focus", T_INT, OFF(focus), RO},
{"belowmouse", T_INT, OFF(belowmouse),RO},
{"frozen", T_INT, OFF(frozen), RO},
/* {"frozen", T_INT, OFF(frozen), RO}, */
{"active", T_INT, OFF(active)},
{"input", T_INT, OFF(input)},
{"visible", T_INT, OFF(visible), RO},
@ -518,7 +545,7 @@ call_forms_INstr (func, obj, args)
}
/* voide func (object, int, string) */
/* void func (object, int, string) */
static object *
call_forms_INiINstr (func, obj, args)
void (*func)(FL_OBJECT *, int, char *);
@ -537,10 +564,10 @@ call_forms_INiINstr (func, obj, args)
}
#ifdef UNUSED
/* void func (object, float) */
/* void func (object, int, int) */
static object *
call_forms_INiINi (func, obj, args)
void (*func)(FL_OBJECT *, float, float);
void (*func)(FL_OBJECT *, int, int);
FL_OBJECT *obj;
object *args;
{
@ -848,6 +875,15 @@ get_button(g, args)
{
return call_forms_Ri (fl_get_button, g-> ob_generic, args);
}
static object *
get_button_numb(g, args)
genericobject *g;
object *args;
{
return call_forms_Ri (fl_get_button_numb, g-> ob_generic, args);
}
static object *
set_button_shortcut(g, args)
genericobject *g;
@ -859,9 +895,8 @@ set_button_shortcut(g, args)
static struct methodlist button_methods[] = {
{"set_button", set_button},
{"get_button", get_button},
#ifndef FL_V15
{"get_button_numb", get_button_numb},
{"set_button_shortcut", set_button_shortcut},
#endif /* !FL_V15 */
{NULL, NULL} /* sentinel */
};
@ -1034,48 +1069,9 @@ static struct methodlist counter_methods[] = {
{NULL, NULL} /* sentinel */
};
#ifdef FL_V15
/* Class : Defaults */
static object *
get_default(g, args)
genericobject *g;
object *args;
{
char c;
if (!getnoarg(args)) return NULL;
c = fl_get_default (g->ob_generic);
return mkvalue("c", c);
}
static struct methodlist default_methods[] = {
{"get_default", get_default},
{NULL, NULL} /* sentinel */
};
#endif /* FL_V15 */
/* Class: Dials */
#ifdef FL_V15
static object *
set_dial (g, args)
genericobject *g;
object *args;
{
float f1, f2, f3;
if (!getargs(args, "(fff)", &f1, &f2, &f3))
return NULL;
fl_set_dial (g->ob_generic, f1, f2, f3);
INCREF(None);
return None;
}
#endif /* FL_V15 */
static object *
get_dial_value(g, args)
genericobject *g;
@ -1108,7 +1104,6 @@ get_dial_bounds (g, args)
return call_forms_OUTfOUTf (fl_get_dial_bounds, g-> ob_generic, args);
}
#ifndef FL_V15
static object *
set_dial_step (g, args)
genericobject *g;
@ -1116,20 +1111,13 @@ set_dial_step (g, args)
{
return call_forms_INf (fl_set_dial_step, g-> ob_generic, args);
}
#endif /* !FL_V15 */
static struct methodlist dial_methods[] = {
#ifdef FL_V15
{"set_dial", set_dial},
{"get_dial", get_dial_value},
#endif /* FL_V15 */
{"set_dial_value", set_dial_value},
{"get_dial_value", get_dial_value},
{"set_dial_bounds", set_dial_bounds},
{"get_dial_bounds", get_dial_bounds},
#ifndef FL_V15
{"set_dial_step", set_dial_step},
#endif /* !FL_V15 */
{NULL, NULL} /* sentinel */
};
@ -1159,7 +1147,6 @@ set_input_color (g, args)
return call_forms_INfINf (fl_set_input_color, g-> ob_generic, args);
}
#ifndef FL_V15
static object *
set_input_return (g, args)
genericobject *g;
@ -1167,15 +1154,12 @@ set_input_return (g, args)
{
return call_forms_INi (fl_set_input_return, g-> ob_generic, args);
}
#endif /* !FL_V15 */
static struct methodlist input_methods[] = {
{"set_input", set_input},
{"get_input", get_input},
{"set_input_color", set_input_color},
#ifndef FL_V15
{"set_input_return", set_input_return},
#endif /* !FL_V15 */
{NULL, NULL} /* sentinel */
};
@ -1227,22 +1211,6 @@ static struct methodlist menu_methods[] = {
/* Class: Sliders */
#ifdef FL_V15
static object *
set_slider (g, args)
genericobject *g;
object *args;
{
float f1, f2, f3;
if (!args(args, "(fff)", &f1, &f2, &f3))
return NULL;
fl_set_slider (g->ob_generic, f1, f2, f3);
INCREF(None);
return None;
}
#endif /* FL_V15 */
static object *
get_slider_value(g, args)
genericobject *g;
@ -1299,7 +1267,6 @@ set_slider_precision (g, args)
return call_forms_INi (fl_set_slider_precision, g-> ob_generic, args);
}
#ifndef FL_V15
static object *
set_slider_step (g, args)
genericobject *g;
@ -1307,14 +1274,9 @@ set_slider_step (g, args)
{
return call_forms_INf (fl_set_slider_step, g-> ob_generic, args);
}
#endif /* !FL_V15 */
static struct methodlist slider_methods[] = {
#ifdef FL_V15
{"set_slider", set_slider},
{"get_slider", get_slider_value},
#endif /* FL_V15 */
{"set_slider_value", set_slider_value},
{"get_slider_value", get_slider_value},
{"set_slider_bounds", set_slider_bounds},
@ -1322,9 +1284,7 @@ static struct methodlist slider_methods[] = {
{"set_slider_return", set_slider_return},
{"set_slider_size", set_slider_size},
{"set_slider_precision",set_slider_precision},
#ifndef FL_V15
{"set_slider_step", set_slider_step},
#endif /* !FL_V15 */
{NULL, NULL} /* sentinel */
};
@ -1487,6 +1447,22 @@ form_call_INiINi(func, f, args)
return None;
}
static object *
form_call_INfINf(func, f, args)
FL_FORM *f;
object *args;
void (*func)(FL_FORM *, float, float);
{
float a, b;
if (!getargs(args, "(ff)", &a, &b)) return NULL;
(*func)(f, a, b);
INCREF(None);
return None;
}
static object *
form_hide_form(f, args)
formobject *f;
@ -1534,6 +1510,22 @@ form_set_form_position(f, args)
return form_call_INiINi(fl_set_form_position, f-> ob_form, args);
}
static object *
form_set_form_size(f, args)
formobject *f;
object *args;
{
return form_call_INiINi(fl_set_form_size, f-> ob_form, args);
}
static object *
form_scale_form(f, args)
formobject *f;
object *args;
{
return form_call_INfINf(fl_scale_form, f-> ob_form, args);
}
static object *
generic_add_object(f, args, func, internal_methods)
formobject *f;
@ -1627,16 +1619,6 @@ form_add_counter(f, args)
return generic_add_object(f, args, fl_add_counter, counter_methods);
}
#ifdef FL_V15
static object *
form_add_default(f, args)
formobject *f;
object *args;
{
return generic_add_object(f, args, fl_add_default, default_methods);
}
#endif /* FL_V15 */
static object *
form_add_clock(f, args)
formobject *f;
@ -1719,16 +1701,6 @@ form_unfreeze_form(f, args)
return form_call(fl_unfreeze_form, f-> ob_form, args);
}
#ifdef FL_V15
static object *
form_remove_form(f, args)
formobject *f;
object *args;
{
return form_call(fl_remove_form, f-> ob_form, args);
}
#endif /* FL_V15 */
static object *
form_activate_form(f, args)
formobject *f;
@ -1845,11 +1817,10 @@ static struct methodlist form_methods[] = {
{"hide_form", form_hide_form},
{"redraw_form", form_redraw_form},
{"set_form_position", form_set_form_position},
{"set_form_size", form_set_form_size},
{"scale_form", form_scale_form},
{"freeze_form", form_freeze_form},
{"unfreeze_form", form_unfreeze_form},
#ifdef FL_V15
{"remove_form", form_remove_form},
#endif /* FL_V15 */
{"activate_form", form_activate_form},
{"deactivate_form", form_deactivate_form},
{"bgn_group", form_bgn_group},
@ -1869,9 +1840,6 @@ static struct methodlist form_methods[] = {
{"add_valslider", form_add_valslider},
{"add_dial", form_add_dial},
{"add_counter", form_add_counter},
#ifdef FL_V15
{"add_default", form_add_default},
#endif /* FL_V15 */
{"add_box", form_add_box},
{"add_clock", form_add_clock},
{"add_choice", form_add_choice},
@ -2136,7 +2104,6 @@ fl_call(func, args)
}
#endif
#ifndef FL_V15
static object *
forms_set_graphics_mode(dummy, args)
object *dummy;
@ -2192,8 +2159,6 @@ forms_set_font_name(dummy, args)
return None;
}
#endif /* !FL_V15 */
static object *
forms_qdevice(self, args)
@ -2552,12 +2517,10 @@ static struct methodlist forms_methods[] = {
{"get_directory", forms_get_directory},
{"get_pattern", forms_get_pattern},
{"get_filename", forms_get_filename},
#ifndef FL_V15
{"set_graphics_mode", forms_set_graphics_mode},
{"get_rgbmode", forms_get_rgbmode},
{"show_errors", forms_show_errors},
{"set_font_name", forms_set_font_name},
#endif /* !FL_V15 */
{NULL, NULL} /* sentinel */
};
@ -2566,7 +2529,5 @@ initfl()
{
initmodule("fl", forms_methods);
foreground();
#ifndef FL_V15
fl_init();
#endif /* !FL_V15 */
}

View File

@ -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"

View File

@ -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 */

View File

@ -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

View File

@ -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>

View File

@ -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);
}

View File

@ -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

View File

@ -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);

View File

@ -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)

View File

@ -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"

View File

@ -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;

View File

@ -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);

View File

@ -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() */

View File

@ -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'

View File

@ -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 */

View File

@ -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();