Kaydet (Commit) 23c9e002 authored tarafından Thomas Wouters's avatar Thomas Wouters

Mass ANSIfication.

Work around intrcheck.c's desire to pass 'PyErr_CheckSignals' to
'Py_AddPendingCall' by providing a (static) wrapper function that has the
right number of arguments.
üst f70ef4f8
...@@ -30,8 +30,7 @@ static void fixdfa(grammar *, dfa *); ...@@ -30,8 +30,7 @@ static void fixdfa(grammar *, dfa *);
static void fixstate(grammar *, state *); static void fixstate(grammar *, state *);
void void
PyGrammar_AddAccelerators(g) PyGrammar_AddAccelerators(grammar *g)
grammar *g;
{ {
dfa *d; dfa *d;
int i; int i;
...@@ -48,8 +47,7 @@ PyGrammar_AddAccelerators(g) ...@@ -48,8 +47,7 @@ PyGrammar_AddAccelerators(g)
} }
void void
PyGrammar_RemoveAccelerators(g) PyGrammar_RemoveAccelerators(grammar *g)
grammar *g;
{ {
dfa *d; dfa *d;
int i; int i;
...@@ -68,9 +66,7 @@ PyGrammar_RemoveAccelerators(g) ...@@ -68,9 +66,7 @@ PyGrammar_RemoveAccelerators(g)
} }
static void static void
fixdfa(g, d) fixdfa(grammar *g, dfa *d)
grammar *g;
dfa *d;
{ {
state *s; state *s;
int j; int j;
...@@ -80,9 +76,7 @@ fixdfa(g, d) ...@@ -80,9 +76,7 @@ fixdfa(g, d)
} }
static void static void
fixstate(g, s) fixstate(grammar *g, state *s)
grammar *g;
state *s;
{ {
arc *a; arc *a;
int k; int k;
......
...@@ -14,8 +14,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ...@@ -14,8 +14,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#include "bitset.h" #include "bitset.h"
bitset bitset
newbitset(nbits) newbitset(int nbits)
int nbits;
{ {
int nbytes = NBYTES(nbits); int nbytes = NBYTES(nbits);
bitset ss = PyMem_NEW(BYTE, nbytes); bitset ss = PyMem_NEW(BYTE, nbytes);
...@@ -30,16 +29,13 @@ newbitset(nbits) ...@@ -30,16 +29,13 @@ newbitset(nbits)
} }
void void
delbitset(ss) delbitset(bitset ss)
bitset ss;
{ {
PyMem_DEL(ss); PyMem_DEL(ss);
} }
int int
addbit(ss, ibit) addbit(bitset ss, int ibit)
bitset ss;
int ibit;
{ {
int ibyte = BIT2BYTE(ibit); int ibyte = BIT2BYTE(ibit);
BYTE mask = BIT2MASK(ibit); BYTE mask = BIT2MASK(ibit);
...@@ -52,18 +48,14 @@ addbit(ss, ibit) ...@@ -52,18 +48,14 @@ addbit(ss, ibit)
#if 0 /* Now a macro */ #if 0 /* Now a macro */
int int
testbit(ss, ibit) testbit(bitset ss, int ibit)
bitset ss;
int ibit;
{ {
return (ss[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0; return (ss[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0;
} }
#endif #endif
int int
samebitset(ss1, ss2, nbits) samebitset(bitset ss1, bitset ss2, int nbits)
bitset ss1, ss2;
int nbits;
{ {
int i; int i;
...@@ -74,9 +66,7 @@ samebitset(ss1, ss2, nbits) ...@@ -74,9 +66,7 @@ samebitset(ss1, ss2, nbits)
} }
void void
mergebitset(ss1, ss2, nbits) mergebitset(bitset ss1, bitset ss2, int nbits)
bitset ss1, ss2;
int nbits;
{ {
int i; int i;
......
...@@ -20,8 +20,7 @@ extern int Py_DebugFlag; ...@@ -20,8 +20,7 @@ extern int Py_DebugFlag;
static void calcfirstset(grammar *, dfa *); static void calcfirstset(grammar *, dfa *);
void void
addfirstsets(g) addfirstsets(grammar *g)
grammar *g;
{ {
int i; int i;
dfa *d; dfa *d;
...@@ -35,9 +34,7 @@ addfirstsets(g) ...@@ -35,9 +34,7 @@ addfirstsets(g)
} }
static void static void
calcfirstset(g, d) calcfirstset(grammar *g, dfa *d)
grammar *g;
dfa *d;
{ {
int i, j; int i, j;
state *s; state *s;
......
...@@ -21,8 +21,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ...@@ -21,8 +21,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
extern int Py_DebugFlag; extern int Py_DebugFlag;
grammar * grammar *
newgrammar(start) newgrammar(int start)
int start;
{ {
grammar *g; grammar *g;
...@@ -39,10 +38,7 @@ newgrammar(start) ...@@ -39,10 +38,7 @@ newgrammar(start)
} }
dfa * dfa *
adddfa(g, type, name) adddfa(grammar *g, int type, char *name)
grammar *g;
int type;
char *name;
{ {
dfa *d; dfa *d;
...@@ -60,8 +56,7 @@ adddfa(g, type, name) ...@@ -60,8 +56,7 @@ adddfa(g, type, name)
} }
int int
addstate(d) addstate(dfa *d)
dfa *d;
{ {
state *s; state *s;
...@@ -79,9 +74,7 @@ addstate(d) ...@@ -79,9 +74,7 @@ addstate(d)
} }
void void
addarc(d, from, to, lbl) addarc(dfa *d, int from, int to, int lbl)
dfa *d;
int lbl;
{ {
state *s; state *s;
arc *a; arc *a;
...@@ -99,10 +92,7 @@ addarc(d, from, to, lbl) ...@@ -99,10 +92,7 @@ addarc(d, from, to, lbl)
} }
int int
addlabel(ll, type, str) addlabel(labellist *ll, int type, char *str)
labellist *ll;
int type;
char *str;
{ {
int i; int i;
label *lb; label *lb;
...@@ -124,10 +114,7 @@ addlabel(ll, type, str) ...@@ -124,10 +114,7 @@ addlabel(ll, type, str)
/* Same, but rather dies than adds */ /* Same, but rather dies than adds */
int int
findlabel(ll, type, str) findlabel(labellist *ll, int type, char *str)
labellist *ll;
int type;
char *str;
{ {
int i; int i;
...@@ -145,8 +132,7 @@ findlabel(ll, type, str) ...@@ -145,8 +132,7 @@ findlabel(ll, type, str)
static void translabel(grammar *, label *); static void translabel(grammar *, label *);
void void
translatelabels(g) translatelabels(grammar *g)
grammar *g;
{ {
int i; int i;
...@@ -159,9 +145,7 @@ translatelabels(g) ...@@ -159,9 +145,7 @@ translatelabels(g)
} }
static void static void
translabel(g, lb) translabel(grammar *g, label *lb)
grammar *g;
label *lb;
{ {
int i; int i;
......
...@@ -18,9 +18,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ...@@ -18,9 +18,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
/* Return the DFA for the given type */ /* Return the DFA for the given type */
dfa * dfa *
PyGrammar_FindDFA(g, type) PyGrammar_FindDFA(grammar *g, register int type)
grammar *g;
register int type;
{ {
register dfa *d; register dfa *d;
#if 1 #if 1
...@@ -42,8 +40,7 @@ PyGrammar_FindDFA(g, type) ...@@ -42,8 +40,7 @@ PyGrammar_FindDFA(g, type)
} }
char * char *
PyGrammar_LabelRepr(lb) PyGrammar_LabelRepr(label *lb)
label *lb;
{ {
static char buf[100]; static char buf[100];
......
...@@ -30,17 +30,17 @@ int Py_AddPendingCall(int (*func)(ANY *), ANY *arg); ...@@ -30,17 +30,17 @@ int Py_AddPendingCall(int (*func)(ANY *), ANY *arg);
#include <io.h> #include <io.h>
void void
PyOS_InitInterrupts() PyOS_InitInterrupts(void)
{ {
} }
void void
PyOS_FiniInterrupts() PyOS_FiniInterrupts(void)
{ {
} }
int int
PyOS_InterruptOccurred() PyOS_InterruptOccurred(void)
{ {
_wyield(); _wyield();
} }
...@@ -66,18 +66,18 @@ PyOS_InterruptOccurred() ...@@ -66,18 +66,18 @@ PyOS_InterruptOccurred()
#include <go32.h> #include <go32.h>
void void
PyOS_InitInterrupts() PyOS_InitInterrupts(void)
{ {
_go32_want_ctrl_break(1 /* TRUE */); _go32_want_ctrl_break(1 /* TRUE */);
} }
void void
PyOS_FiniInterrupts() PyOS_FiniInterrupts(void)
{ {
} }
int int
PyOS_InterruptOccurred() PyOS_InterruptOccurred(void)
{ {
return _go32_was_ctrl_break_hit(); return _go32_was_ctrl_break_hit();
} }
...@@ -87,17 +87,17 @@ PyOS_InterruptOccurred() ...@@ -87,17 +87,17 @@ PyOS_InterruptOccurred()
/* This might work for MS-DOS (untested though): */ /* This might work for MS-DOS (untested though): */
void void
PyOS_InitInterrupts() PyOS_InitInterrupts(void)
{ {
} }
void void
PyOS_FiniInterrupts() PyOS_FiniInterrupts(void)
{ {
} }
int int
PyOS_InterruptOccurred() PyOS_InterruptOccurred(void)
{ {
int interrupted = 0; int interrupted = 0;
while (kbhit()) { while (kbhit()) {
...@@ -136,21 +136,21 @@ PyOS_InterruptOccurred() ...@@ -136,21 +136,21 @@ PyOS_InterruptOccurred()
static int interrupted; static int interrupted;
void void
PyErr_SetInterrupt() PyErr_SetInterrupt(void)
{ {
interrupted = 1; interrupted = 1;
} }
extern int PyErr_CheckSignals(); extern int PyErr_CheckSignals(void);
static int
checksignals_witharg(void * arg)
{
return PyErr_CheckSignals();
}
/* ARGSUSED */
static RETSIGTYPE static RETSIGTYPE
#if defined(_M_IX86) && !defined(__QNX__) intcatcher(int sig)
intcatcher(int sig) /* So the C compiler shuts up */
#else /* _M_IX86 */
intcatcher(sig)
int sig; /* Not used by required by interface */
#endif /* _M_IX86 */
{ {
extern void Py_Exit(int); extern void Py_Exit(int);
static char message[] = static char message[] =
...@@ -167,13 +167,13 @@ intcatcher(sig) ...@@ -167,13 +167,13 @@ intcatcher(sig)
break; break;
} }
signal(SIGINT, intcatcher); signal(SIGINT, intcatcher);
Py_AddPendingCall(PyErr_CheckSignals, NULL); Py_AddPendingCall(checksignals_witharg, NULL);
} }
static RETSIGTYPE (*old_siginthandler)() = SIG_DFL; static RETSIGTYPE (*old_siginthandler)(int) = SIG_DFL;
void void
PyOS_InitInterrupts() PyOS_InitInterrupts(void)
{ {
if ((old_siginthandler = signal(SIGINT, SIG_IGN)) != SIG_IGN) if ((old_siginthandler = signal(SIGINT, SIG_IGN)) != SIG_IGN)
signal(SIGINT, intcatcher); signal(SIGINT, intcatcher);
...@@ -189,13 +189,13 @@ PyOS_InitInterrupts() ...@@ -189,13 +189,13 @@ PyOS_InitInterrupts()
} }
void void
PyOS_FiniInterrupts() PyOS_FiniInterrupts(void)
{ {
signal(SIGINT, old_siginthandler); signal(SIGINT, old_siginthandler);
} }
int int
PyOS_InterruptOccurred() PyOS_InterruptOccurred(void)
{ {
if (!interrupted) if (!interrupted)
return 0; return 0;
...@@ -206,6 +206,6 @@ PyOS_InterruptOccurred() ...@@ -206,6 +206,6 @@ PyOS_InterruptOccurred()
#endif /* !OK */ #endif /* !OK */
void void
PyOS_AfterFork() PyOS_AfterFork(void)
{ {
} }
...@@ -19,8 +19,7 @@ static void list1node(FILE *, node *); ...@@ -19,8 +19,7 @@ static void list1node(FILE *, node *);
static void listnode(FILE *, node *); static void listnode(FILE *, node *);
void void
PyNode_ListTree(n) PyNode_ListTree(node *n)
node *n;
{ {
listnode(stdout, n); listnode(stdout, n);
} }
...@@ -28,9 +27,7 @@ PyNode_ListTree(n) ...@@ -28,9 +27,7 @@ PyNode_ListTree(n)
static int level, atbol; static int level, atbol;
static void static void
listnode(fp, n) listnode(FILE *fp, node *n)
FILE *fp;
node *n;
{ {
level = 0; level = 0;
atbol = 1; atbol = 1;
...@@ -38,9 +35,7 @@ listnode(fp, n) ...@@ -38,9 +35,7 @@ listnode(fp, n)
} }
static void static void
list1node(fp, n) list1node(FILE *fp, node *n)
FILE *fp;
node *n;
{ {
if (n == 0) if (n == 0)
return; return;
......
...@@ -156,7 +156,7 @@ static grammar _PyParser_Grammar = { ...@@ -156,7 +156,7 @@ static grammar _PyParser_Grammar = {
}; };
grammar * grammar *
meta_grammar() meta_grammar(void)
{ {
return &_PyParser_Grammar; return &_PyParser_Grammar;
} }
...@@ -23,16 +23,13 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ...@@ -23,16 +23,13 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#include <limits.h> #include <limits.h>
#endif #endif
int (*PyOS_InputHook)() = NULL; int (*PyOS_InputHook)(void) = NULL;
/* This function restarts a fgets() after an EINTR error occurred /* This function restarts a fgets() after an EINTR error occurred
except if PyOS_InterruptOccurred() returns true. */ except if PyOS_InterruptOccurred() returns true. */
static int static int
my_fgets(buf, len, fp) my_fgets(char *buf, int len, FILE *fp)
char *buf;
int len;
FILE *fp;
{ {
char *p; char *p;
for (;;) { for (;;) {
...@@ -65,8 +62,7 @@ my_fgets(buf, len, fp) ...@@ -65,8 +62,7 @@ my_fgets(buf, len, fp)
/* Readline implementation using fgets() */ /* Readline implementation using fgets() */
char * char *
PyOS_StdioReadline(prompt) PyOS_StdioReadline(char *prompt)
char *prompt;
{ {
size_t n; size_t n;
char *p; char *p;
...@@ -124,8 +120,7 @@ char *(*PyOS_ReadlineFunctionPointer)(char *); ...@@ -124,8 +120,7 @@ char *(*PyOS_ReadlineFunctionPointer)(char *);
/* Interface used by tokenizer.c and bltinmodule.c */ /* Interface used by tokenizer.c and bltinmodule.c */
char * char *
PyOS_Readline(prompt) PyOS_Readline(char *prompt)
char *prompt;
{ {
char *rv; char *rv;
if (PyOS_ReadlineFunctionPointer == NULL) { if (PyOS_ReadlineFunctionPointer == NULL) {
......
...@@ -17,8 +17,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ...@@ -17,8 +17,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#include "errcode.h" #include "errcode.h"
node * node *
PyNode_New(type) PyNode_New(int type)
int type;
{ {
node *n = PyMem_NEW(node, 1); node *n = PyMem_NEW(node, 1);
if (n == NULL) if (n == NULL)
...@@ -35,11 +34,7 @@ PyNode_New(type) ...@@ -35,11 +34,7 @@ PyNode_New(type)
#define XXXROUNDUP(n) ((n) == 1 ? 1 : ((n) + XXX - 1) / XXX * XXX) #define XXXROUNDUP(n) ((n) == 1 ? 1 : ((n) + XXX - 1) / XXX * XXX)
int int
PyNode_AddChild(n1, type, str, lineno) PyNode_AddChild(register node *n1, int type, char *str, int lineno)
register node *n1;
int type;
char *str;
int lineno;
{ {
register int nch = n1->n_nchildren; register int nch = n1->n_nchildren;
register int nch1 = nch+1; register int nch1 = nch+1;
...@@ -68,8 +63,7 @@ static void freechildren(node *); ...@@ -68,8 +63,7 @@ static void freechildren(node *);
void void
PyNode_Free(n) PyNode_Free(node *n)
node *n;
{ {
if (n != NULL) { if (n != NULL) {
freechildren(n); freechildren(n);
...@@ -78,8 +72,7 @@ PyNode_Free(n) ...@@ -78,8 +72,7 @@ PyNode_Free(n)
} }
static void static void
freechildren(n) freechildren(node *n)
node *n;
{ {
int i; int i;
for (i = NCH(n); --i >= 0; ) for (i = NCH(n); --i >= 0; )
......
...@@ -36,21 +36,15 @@ extern int Py_DebugFlag; ...@@ -36,21 +36,15 @@ extern int Py_DebugFlag;
static void s_reset(stack *); static void s_reset(stack *);
static void static void
s_reset(s) s_reset(stack *s)
stack *s;
{ {
s->s_top = &s->s_base[MAXSTACK]; s->s_top = &s->s_base[MAXSTACK];
} }
#define s_empty(s) ((s)->s_top == &(s)->s_base[MAXSTACK]) #define s_empty(s) ((s)->s_top == &(s)->s_base[MAXSTACK])
static int s_push(stack *, dfa *, node *);
static int static int
s_push(s, d, parent) s_push(register stack *s, dfa *d, node *parent)
register stack *s;
dfa *d;
node *parent;
{ {
register stackentry *top; register stackentry *top;
if (s->s_top == s->s_base) { if (s->s_top == s->s_base) {
...@@ -66,11 +60,8 @@ s_push(s, d, parent) ...@@ -66,11 +60,8 @@ s_push(s, d, parent)
#ifdef Py_DEBUG #ifdef Py_DEBUG
static void s_pop(stack *);
static void static void
s_pop(s) s_pop(register stack *s)
register stack *s;
{ {
if (s_empty(s)) if (s_empty(s))
Py_FatalError("s_pop: parser stack underflow -- FATAL"); Py_FatalError("s_pop: parser stack underflow -- FATAL");
...@@ -87,9 +78,7 @@ s_pop(s) ...@@ -87,9 +78,7 @@ s_pop(s)
/* PARSER CREATION */ /* PARSER CREATION */
parser_state * parser_state *
PyParser_New(g, start) PyParser_New(grammar *g, int start)
grammar *g;
int start;
{ {
parser_state *ps; parser_state *ps;
...@@ -110,8 +99,7 @@ PyParser_New(g, start) ...@@ -110,8 +99,7 @@ PyParser_New(g, start)
} }
void void
PyParser_Delete(ps) PyParser_Delete(parser_state *ps)
parser_state *ps;
{ {
/* NB If you want to save the parse tree, /* NB If you want to save the parse tree,
you must set p_tree to NULL before calling delparser! */ you must set p_tree to NULL before calling delparser! */
...@@ -122,15 +110,8 @@ PyParser_Delete(ps) ...@@ -122,15 +110,8 @@ PyParser_Delete(ps)
/* PARSER STACK OPERATIONS */ /* PARSER STACK OPERATIONS */
static int shift(stack *, int, char *, int, int);
static int static int
shift(s, type, str, newstate, lineno) shift(register stack *s, int type, char *str, int newstate, int lineno)
register stack *s;
int type;
char *str;
int newstate;
int lineno;
{ {
int err; int err;
assert(!s_empty(s)); assert(!s_empty(s));
...@@ -141,15 +122,8 @@ shift(s, type, str, newstate, lineno) ...@@ -141,15 +122,8 @@ shift(s, type, str, newstate, lineno)
return 0; return 0;
} }
static int push(stack *, int, dfa *, int, int);
static int static int
push(s, type, d, newstate, lineno) push(register stack *s, int type, dfa *d, int newstate, int lineno)
register stack *s;
int type;
dfa *d;
int newstate;
int lineno;
{ {
int err; int err;
register node *n; register node *n;
...@@ -165,13 +139,8 @@ push(s, type, d, newstate, lineno) ...@@ -165,13 +139,8 @@ push(s, type, d, newstate, lineno)
/* PARSER PROPER */ /* PARSER PROPER */
static int classify(grammar *, int, char *);
static int static int
classify(g, type, str) classify(grammar *g, int type, char *str)
grammar *g;
register int type;
char *str;
{ {
register int n = g->g_ll.ll_nlabels; register int n = g->g_ll.ll_nlabels;
...@@ -205,12 +174,8 @@ classify(g, type, str) ...@@ -205,12 +174,8 @@ classify(g, type, str)
} }
int int
PyParser_AddToken(ps, type, str, lineno, expected_ret) PyParser_AddToken(register parser_state *ps, register int type, char *str,
register parser_state *ps; int lineno, int *expected_ret)
register int type;
char *str;
int lineno;
int *expected_ret;
{ {
register int ilabel; register int ilabel;
int err; int err;
...@@ -305,9 +270,7 @@ PyParser_AddToken(ps, type, str, lineno, expected_ret) ...@@ -305,9 +270,7 @@ PyParser_AddToken(ps, type, str, lineno, expected_ret)
/* DEBUG OUTPUT */ /* DEBUG OUTPUT */
void void
dumptree(g, n) dumptree(grammar *g, node *n)
grammar *g;
node *n;
{ {
int i; int i;
...@@ -331,9 +294,7 @@ dumptree(g, n) ...@@ -331,9 +294,7 @@ dumptree(g, n)
} }
void void
showtree(g, n) showtree(grammar *g, node *n)
grammar *g;
node *n;
{ {
int i; int i;
...@@ -354,8 +315,7 @@ showtree(g, n) ...@@ -354,8 +315,7 @@ showtree(g, n)
} }
void void
printtree(ps) printtree(parser_state *ps)
parser_state *ps;
{ {
if (Py_DebugFlag) { if (Py_DebugFlag) {
printf("Parse tree:\n"); printf("Parse tree:\n");
......
...@@ -27,11 +27,7 @@ static node *parsetok(struct tok_state *, grammar *, int, perrdetail *); ...@@ -27,11 +27,7 @@ static node *parsetok(struct tok_state *, grammar *, int, perrdetail *);
/* Parse input coming from a string. Return error code, print some errors. */ /* Parse input coming from a string. Return error code, print some errors. */
node * node *
PyParser_ParseString(s, g, start, err_ret) PyParser_ParseString(char *s, grammar *g, int start, perrdetail *err_ret)
char *s;
grammar *g;
int start;
perrdetail *err_ret;
{ {
struct tok_state *tok; struct tok_state *tok;
...@@ -60,13 +56,8 @@ PyParser_ParseString(s, g, start, err_ret) ...@@ -60,13 +56,8 @@ PyParser_ParseString(s, g, start, err_ret)
/* Parse input coming from a file. Return error code, print some errors. */ /* Parse input coming from a file. Return error code, print some errors. */
node * node *
PyParser_ParseFile(fp, filename, g, start, ps1, ps2, err_ret) PyParser_ParseFile(FILE *fp, char *filename, grammar *g, int start,
FILE *fp; char *ps1, char *ps2, perrdetail *err_ret)
char *filename;
grammar *g;
int start;
char *ps1, *ps2;
perrdetail *err_ret;
{ {
struct tok_state *tok; struct tok_state *tok;
...@@ -95,11 +86,7 @@ PyParser_ParseFile(fp, filename, g, start, ps1, ps2, err_ret) ...@@ -95,11 +86,7 @@ PyParser_ParseFile(fp, filename, g, start, ps1, ps2, err_ret)
Return error code. */ Return error code. */
static node * static node *
parsetok(tok, g, start, err_ret) parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret)
struct tok_state *tok;
grammar *g;
int start;
perrdetail *err_ret;
{ {
parser_state *ps; parser_state *ps;
node *n; node *n;
......
...@@ -55,8 +55,7 @@ static void compile_atom(labellist *ll, ...@@ -55,8 +55,7 @@ static void compile_atom(labellist *ll,
nfa *nf, node *n, int *pa, int *pb); nfa *nf, node *n, int *pa, int *pb);
static int static int
addnfastate(nf) addnfastate(nfa *nf)
nfa *nf;
{ {
nfastate *st; nfastate *st;
...@@ -70,9 +69,7 @@ addnfastate(nf) ...@@ -70,9 +69,7 @@ addnfastate(nf)
} }
static void static void
addnfaarc(nf, from, to, lbl) addnfaarc(nfa *nf, int from, int to, int lbl)
nfa *nf;
int from, to, lbl;
{ {
nfastate *st; nfastate *st;
nfaarc *ar; nfaarc *ar;
...@@ -87,8 +84,7 @@ addnfaarc(nf, from, to, lbl) ...@@ -87,8 +84,7 @@ addnfaarc(nf, from, to, lbl)
} }
static nfa * static nfa *
newnfa(name) newnfa(char *name)
char *name;
{ {
nfa *nf; nfa *nf;
static int type = NT_OFFSET; /* All types will be disjunct */ static int type = NT_OFFSET; /* All types will be disjunct */
...@@ -114,7 +110,7 @@ typedef struct _nfagrammar { ...@@ -114,7 +110,7 @@ typedef struct _nfagrammar {
static void compile_rule(nfagrammar *gr, node *n); static void compile_rule(nfagrammar *gr, node *n);
static nfagrammar * static nfagrammar *
newnfagrammar() newnfagrammar(void)
{ {
nfagrammar *gr; nfagrammar *gr;
...@@ -130,9 +126,7 @@ newnfagrammar() ...@@ -130,9 +126,7 @@ newnfagrammar()
} }
static nfa * static nfa *
addnfa(gr, name) addnfa(nfagrammar *gr, char *name)
nfagrammar *gr;
char *name;
{ {
nfa *nf; nfa *nf;
...@@ -160,8 +154,7 @@ static char REQNFMT[] = "metacompile: less than %d children\n"; ...@@ -160,8 +154,7 @@ static char REQNFMT[] = "metacompile: less than %d children\n";
#endif #endif
static nfagrammar * static nfagrammar *
metacompile(n) metacompile(node *n)
node *n;
{ {
nfagrammar *gr; nfagrammar *gr;
int i; int i;
...@@ -179,9 +172,7 @@ metacompile(n) ...@@ -179,9 +172,7 @@ metacompile(n)
} }
static void static void
compile_rule(gr, n) compile_rule(nfagrammar *gr, node *n)
nfagrammar *gr;
node *n;
{ {
nfa *nf; nfa *nf;
...@@ -200,11 +191,7 @@ compile_rule(gr, n) ...@@ -200,11 +191,7 @@ compile_rule(gr, n)
} }
static void static void
compile_rhs(ll, nf, n, pa, pb) compile_rhs(labellist *ll, nfa *nf, node *n, int *pa, int *pb)
labellist *ll;
nfa *nf;
node *n;
int *pa, *pb;
{ {
int i; int i;
int a, b; int a, b;
...@@ -237,11 +224,7 @@ compile_rhs(ll, nf, n, pa, pb) ...@@ -237,11 +224,7 @@ compile_rhs(ll, nf, n, pa, pb)
} }
static void static void
compile_alt(ll, nf, n, pa, pb) compile_alt(labellist *ll, nfa *nf, node *n, int *pa, int *pb)
labellist *ll;
nfa *nf;
node *n;
int *pa, *pb;
{ {
int i; int i;
int a, b; int a, b;
...@@ -268,11 +251,7 @@ compile_alt(ll, nf, n, pa, pb) ...@@ -268,11 +251,7 @@ compile_alt(ll, nf, n, pa, pb)
} }
static void static void
compile_item(ll, nf, n, pa, pb) compile_item(labellist *ll, nfa *nf, node *n, int *pa, int *pb)
labellist *ll;
nfa *nf;
node *n;
int *pa, *pb;
{ {
int i; int i;
int a, b; int a, b;
...@@ -309,11 +288,7 @@ compile_item(ll, nf, n, pa, pb) ...@@ -309,11 +288,7 @@ compile_item(ll, nf, n, pa, pb)
} }
static void static void
compile_atom(ll, nf, n, pa, pb) compile_atom(labellist *ll, nfa *nf, node *n, int *pa, int *pb)
labellist *ll;
nfa *nf;
node *n;
int *pa, *pb;
{ {
int i; int i;
...@@ -339,10 +314,7 @@ compile_atom(ll, nf, n, pa, pb) ...@@ -339,10 +314,7 @@ compile_atom(ll, nf, n, pa, pb)
} }
static void static void
dumpstate(ll, nf, istate) dumpstate(labellist *ll, nfa *nf, int istate)
labellist *ll;
nfa *nf;
int istate;
{ {
nfastate *st; nfastate *st;
int i; int i;
...@@ -365,9 +337,7 @@ dumpstate(ll, nf, istate) ...@@ -365,9 +337,7 @@ dumpstate(ll, nf, istate)
} }
static void static void
dumpnfa(ll, nf) dumpnfa(labellist *ll, nfa *nf)
labellist *ll;
nfa *nf;
{ {
int i; int i;
...@@ -381,10 +351,7 @@ dumpnfa(ll, nf) ...@@ -381,10 +351,7 @@ dumpnfa(ll, nf)
/* PART TWO -- CONSTRUCT DFA -- Algorithm 3.1 from [Aho&Ullman 77] */ /* PART TWO -- CONSTRUCT DFA -- Algorithm 3.1 from [Aho&Ullman 77] */
static void static void
addclosure(ss, nf, istate) addclosure(bitset ss, nfa *nf, int istate)
bitset ss;
nfa *nf;
int istate;
{ {
if (addbit(ss, istate)) { if (addbit(ss, istate)) {
nfastate *st = &nf->nf_state[istate]; nfastate *st = &nf->nf_state[istate];
...@@ -426,10 +393,7 @@ static void simplify(int xx_nstates, ss_state *xx_state); ...@@ -426,10 +393,7 @@ static void simplify(int xx_nstates, ss_state *xx_state);
static void convert(dfa *d, int xx_nstates, ss_state *xx_state); static void convert(dfa *d, int xx_nstates, ss_state *xx_state);
static void static void
makedfa(gr, nf, d) makedfa(nfagrammar *gr, nfa *nf, dfa *d)
nfagrammar *gr;
nfa *nf;
dfa *d;
{ {
int nbits = nf->nf_nstates; int nbits = nf->nf_nstates;
bitset ss; bitset ss;
...@@ -533,12 +497,8 @@ makedfa(gr, nf, d) ...@@ -533,12 +497,8 @@ makedfa(gr, nf, d)
} }
static void static void
printssdfa(xx_nstates, xx_state, nbits, ll, msg) printssdfa(int xx_nstates, ss_state *xx_state, int nbits,
int xx_nstates; labellist *ll, char *msg)
ss_state *xx_state;
int nbits;
labellist *ll;
char *msg;
{ {
int i, ibit, iarc; int i, ibit, iarc;
ss_state *yy; ss_state *yy;
...@@ -579,8 +539,7 @@ printssdfa(xx_nstates, xx_state, nbits, ll, msg) ...@@ -579,8 +539,7 @@ printssdfa(xx_nstates, xx_state, nbits, ll, msg)
*/ */
static int static int
samestate(s1, s2) samestate(ss_state *s1, ss_state *s2)
ss_state *s1, *s2;
{ {
int i; int i;
...@@ -595,10 +554,7 @@ samestate(s1, s2) ...@@ -595,10 +554,7 @@ samestate(s1, s2)
} }
static void static void
renamestates(xx_nstates, xx_state, from, to) renamestates(int xx_nstates, ss_state *xx_state, int from, int to)
int xx_nstates;
ss_state *xx_state;
int from, to;
{ {
int i, j; int i, j;
...@@ -615,9 +571,7 @@ renamestates(xx_nstates, xx_state, from, to) ...@@ -615,9 +571,7 @@ renamestates(xx_nstates, xx_state, from, to)
} }
static void static void
simplify(xx_nstates, xx_state) simplify(int xx_nstates, ss_state *xx_state)
int xx_nstates;
ss_state *xx_state;
{ {
int changes; int changes;
int i, j; int i, j;
...@@ -648,10 +602,7 @@ simplify(xx_nstates, xx_state) ...@@ -648,10 +602,7 @@ simplify(xx_nstates, xx_state)
/* Convert the DFA into a grammar that can be used by our parser */ /* Convert the DFA into a grammar that can be used by our parser */
static void static void
convert(d, xx_nstates, xx_state) convert(dfa *d, int xx_nstates, ss_state *xx_state)
dfa *d;
int xx_nstates;
ss_state *xx_state;
{ {
int i, j; int i, j;
ss_state *yy; ss_state *yy;
...@@ -685,8 +636,7 @@ convert(d, xx_nstates, xx_state) ...@@ -685,8 +636,7 @@ convert(d, xx_nstates, xx_state)
/* PART FIVE -- GLUE IT ALL TOGETHER */ /* PART FIVE -- GLUE IT ALL TOGETHER */
static grammar * static grammar *
maketables(gr) maketables(nfagrammar *gr)
nfagrammar *gr;
{ {
int i; int i;
nfa *nf; nfa *nf;
...@@ -714,8 +664,7 @@ maketables(gr) ...@@ -714,8 +664,7 @@ maketables(gr)
} }
grammar * grammar *
pgen(n) pgen(node *n)
node *n;
{ {
nfagrammar *gr; nfagrammar *gr;
grammar *g; grammar *g;
......
...@@ -39,16 +39,13 @@ char *askfile(void); ...@@ -39,16 +39,13 @@ char *askfile(void);
#endif #endif
void void
Py_Exit(sts) Py_Exit(int sts)
int sts;
{ {
exit(sts); exit(sts);
} }
int int
main(argc, argv) main(int argc, char **argv)
int argc;
char **argv;
{ {
grammar *g; grammar *g;
FILE *fp; FILE *fp;
...@@ -85,8 +82,7 @@ main(argc, argv) ...@@ -85,8 +82,7 @@ main(argc, argv)
} }
grammar * grammar *
getgrammar(filename) getgrammar(char *filename)
char *filename;
{ {
FILE *fp; FILE *fp;
node *n; node *n;
...@@ -132,7 +128,7 @@ getgrammar(filename) ...@@ -132,7 +128,7 @@ getgrammar(filename)
#ifdef THINK_C #ifdef THINK_C
char * char *
askfile() askfile(void)
{ {
char buf[256]; char buf[256];
static char name[256]; static char name[256];
...@@ -151,8 +147,7 @@ askfile() ...@@ -151,8 +147,7 @@ askfile()
#endif #endif
void void
Py_FatalError(msg) Py_FatalError(char *msg)
char *msg;
{ {
fprintf(stderr, "pgen: FATAL ERROR: %s\n", msg); fprintf(stderr, "pgen: FATAL ERROR: %s\n", msg);
Py_Exit(1); Py_Exit(1);
...@@ -161,8 +156,7 @@ Py_FatalError(msg) ...@@ -161,8 +156,7 @@ Py_FatalError(msg)
#ifdef macintosh #ifdef macintosh
/* ARGSUSED */ /* ARGSUSED */
int int
guesstabsize(path) guesstabsize(char *path)
char *path;
{ {
return 4; return 4;
} }
...@@ -171,8 +165,7 @@ guesstabsize(path) ...@@ -171,8 +165,7 @@ guesstabsize(path)
/* No-nonsense my_readline() for tokenizer.c */ /* No-nonsense my_readline() for tokenizer.c */
char * char *
PyOS_Readline(prompt) PyOS_Readline(char *prompt)
char *prompt;
{ {
size_t n = 1000; size_t n = 1000;
char *p = PyMem_MALLOC(n); char *p = PyMem_MALLOC(n);
...@@ -191,29 +184,14 @@ PyOS_Readline(prompt) ...@@ -191,29 +184,14 @@ PyOS_Readline(prompt)
return PyMem_REALLOC(p, n+1); return PyMem_REALLOC(p, n+1);
} }
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h> #include <stdarg.h>
#else
#include <varargs.h>
#endif
void void
#ifdef HAVE_STDARG_PROTOTYPES
PySys_WriteStderr(const char *format, ...) PySys_WriteStderr(const char *format, ...)
#else
PySys_WriteStderr(va_alist)
va_dcl
#endif
{ {
va_list va; va_list va;
#ifdef HAVE_STDARG_PROTOTYPES
va_start(va, format); va_start(va, format);
#else
char *format;
va_start(va);
format = va_arg(va, char *);
#endif
vfprintf(stderr, format, va); vfprintf(stderr, format, va);
va_end(va); va_end(va);
} }
...@@ -20,9 +20,7 @@ static void printdfas(grammar *, FILE *); ...@@ -20,9 +20,7 @@ static void printdfas(grammar *, FILE *);
static void printlabels(grammar *, FILE *); static void printlabels(grammar *, FILE *);
void void
printgrammar(g, fp) printgrammar(grammar *g, FILE *fp)
grammar *g;
FILE *fp;
{ {
fprintf(fp, "#include \"pgenheaders.h\"\n"); fprintf(fp, "#include \"pgenheaders.h\"\n");
fprintf(fp, "#include \"grammar.h\"\n"); fprintf(fp, "#include \"grammar.h\"\n");
...@@ -37,9 +35,7 @@ printgrammar(g, fp) ...@@ -37,9 +35,7 @@ printgrammar(g, fp)
} }
void void
printnonterminals(g, fp) printnonterminals(grammar *g, FILE *fp)
grammar *g;
FILE *fp;
{ {
dfa *d; dfa *d;
int i; int i;
...@@ -50,10 +46,7 @@ printnonterminals(g, fp) ...@@ -50,10 +46,7 @@ printnonterminals(g, fp)
} }
static void static void
printarcs(i, d, fp) printarcs(int i, dfa *d, FILE *fp)
int i;
dfa *d;
FILE *fp;
{ {
arc *a; arc *a;
state *s; state *s;
...@@ -71,9 +64,7 @@ printarcs(i, d, fp) ...@@ -71,9 +64,7 @@ printarcs(i, d, fp)
} }
static void static void
printstates(g, fp) printstates(grammar *g, FILE *fp)
grammar *g;
FILE *fp;
{ {
state *s; state *s;
dfa *d; dfa *d;
...@@ -93,9 +84,7 @@ printstates(g, fp) ...@@ -93,9 +84,7 @@ printstates(g, fp)
} }
static void static void
printdfas(g, fp) printdfas(grammar *g, FILE *fp)
grammar *g;
FILE *fp;
{ {
dfa *d; dfa *d;
int i, j; int i, j;
...@@ -115,9 +104,7 @@ printdfas(g, fp) ...@@ -115,9 +104,7 @@ printdfas(g, fp)
} }
static void static void
printlabels(g, fp) printlabels(grammar *g, FILE *fp)
grammar *g;
FILE *fp;
{ {
label *l; label *l;
int i; int i;
......
...@@ -88,7 +88,7 @@ char *_PyParser_TokenNames[] = { ...@@ -88,7 +88,7 @@ char *_PyParser_TokenNames[] = {
/* Create and initialize a new tok_state structure */ /* Create and initialize a new tok_state structure */
static struct tok_state * static struct tok_state *
tok_new() tok_new(void)
{ {
struct tok_state *tok = PyMem_NEW(struct tok_state, 1); struct tok_state *tok = PyMem_NEW(struct tok_state, 1);
if (tok == NULL) if (tok == NULL)
...@@ -116,8 +116,7 @@ tok_new() ...@@ -116,8 +116,7 @@ tok_new()
/* Set up tokenizer for string */ /* Set up tokenizer for string */
struct tok_state * struct tok_state *
PyTokenizer_FromString(str) PyTokenizer_FromString(char *str)
char *str;
{ {
struct tok_state *tok = tok_new(); struct tok_state *tok = tok_new();
if (tok == NULL) if (tok == NULL)
...@@ -130,9 +129,7 @@ PyTokenizer_FromString(str) ...@@ -130,9 +129,7 @@ PyTokenizer_FromString(str)
/* Set up tokenizer for file */ /* Set up tokenizer for file */
struct tok_state * struct tok_state *
PyTokenizer_FromFile(fp, ps1, ps2) PyTokenizer_FromFile(FILE *fp, char *ps1, char *ps2)
FILE *fp;
char *ps1, *ps2;
{ {
struct tok_state *tok = tok_new(); struct tok_state *tok = tok_new();
if (tok == NULL) if (tok == NULL)
...@@ -153,8 +150,7 @@ PyTokenizer_FromFile(fp, ps1, ps2) ...@@ -153,8 +150,7 @@ PyTokenizer_FromFile(fp, ps1, ps2)
/* Free a tok_state structure */ /* Free a tok_state structure */
void void
PyTokenizer_Free(tok) PyTokenizer_Free(struct tok_state *tok)
struct tok_state *tok;
{ {
if (tok->fp != NULL && tok->buf != NULL) if (tok->fp != NULL && tok->buf != NULL)
PyMem_DEL(tok->buf); PyMem_DEL(tok->buf);
...@@ -165,8 +161,7 @@ PyTokenizer_Free(tok) ...@@ -165,8 +161,7 @@ PyTokenizer_Free(tok)
/* Get next char, updating state; error code goes into tok->done */ /* Get next char, updating state; error code goes into tok->done */
static int static int
tok_nextc(tok) tok_nextc(register struct tok_state *tok)
register struct tok_state *tok;
{ {
for (;;) { for (;;) {
if (tok->cur != tok->inp) { if (tok->cur != tok->inp) {
...@@ -321,9 +316,7 @@ tok_nextc(tok) ...@@ -321,9 +316,7 @@ tok_nextc(tok)
/* Back-up one character */ /* Back-up one character */
static void static void
tok_backup(tok, c) tok_backup(register struct tok_state *tok, register int c)
register struct tok_state *tok;
register int c;
{ {
if (c != EOF) { if (c != EOF) {
if (--tok->cur < tok->buf) if (--tok->cur < tok->buf)
...@@ -337,8 +330,7 @@ tok_backup(tok, c) ...@@ -337,8 +330,7 @@ tok_backup(tok, c)
/* Return the token corresponding to a single character */ /* Return the token corresponding to a single character */
int int
PyToken_OneChar(c) PyToken_OneChar(int c)
int c;
{ {
switch (c) { switch (c) {
case '(': return LPAR; case '(': return LPAR;
...@@ -370,8 +362,7 @@ PyToken_OneChar(c) ...@@ -370,8 +362,7 @@ PyToken_OneChar(c)
int int
PyToken_TwoChars(c1, c2) PyToken_TwoChars(int c1, int c2)
int c1, c2;
{ {
switch (c1) { switch (c1) {
case '=': case '=':
...@@ -408,8 +399,7 @@ PyToken_TwoChars(c1, c2) ...@@ -408,8 +399,7 @@ PyToken_TwoChars(c1, c2)
static int static int
indenterror(tok) indenterror(struct tok_state *tok)
struct tok_state *tok;
{ {
if (tok->alterror) { if (tok->alterror) {
tok->done = E_TABSPACE; tok->done = E_TABSPACE;
...@@ -428,9 +418,8 @@ indenterror(tok) ...@@ -428,9 +418,8 @@ indenterror(tok)
/* Get next token, after space stripping etc. */ /* Get next token, after space stripping etc. */
int int
PyTokenizer_Get(tok, p_start, p_end) PyTokenizer_Get(register struct tok_state *tok, char **p_start,
register struct tok_state *tok; /* In/out: tokenizer state */ char **p_end)
char **p_start, **p_end; /* Out: point to start/end of token */
{ {
register int c; register int c;
int blankline; int blankline;
...@@ -812,9 +801,7 @@ PyTokenizer_Get(tok, p_start, p_end) ...@@ -812,9 +801,7 @@ PyTokenizer_Get(tok, p_start, p_end)
#ifdef Py_DEBUG #ifdef Py_DEBUG
void void
tok_dump(type, start, end) tok_dump(int type, char *start, char *end)
int type;
char *start, *end;
{ {
printf("%s", _PyParser_TokenNames[type]); printf("%s", _PyParser_TokenNames[type]);
if (type == NAME || type == NUMBER || type == STRING || type == OP) if (type == NAME || type == NUMBER || type == STRING || type == OP)
......
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