Commit 62989cb6 authored by Duncan White's avatar Duncan White

k&r -> ansi thoughout

parent bd690078
This diff is collapsed.
#ifdef HASPROTOS
extern void make_declns( char * , char * , char * , declnlist , char * );
#else
extern void make_declns();
#endif
......@@ -53,7 +53,7 @@ static int curint;
/* ----------------- Private procedures ---------------- */
static void white_space()
static void white_space( void )
{
int c;
......@@ -73,7 +73,7 @@ static void white_space()
/* ----------------- Public procedures ---------------- */
void ungettok()
void ungettok( void )
{
if( havepushedtok )
{
......@@ -87,7 +87,7 @@ printf( "lexer: ungot token %s\n", tokenname[ curtok ] );
}
TOKEN nexttok()
TOKEN nexttok( void )
{
int c;
int pos;
......@@ -183,7 +183,7 @@ printf( "returning token %s\n", tokenname[ curtok ] );
}
BOOL readnextline( line ) char *line;
BOOL readnextline( char *line )
{
int c;
char *s = line;
......
......@@ -30,12 +30,6 @@ extern FILE *lexfile;
/* ----------------- Public procedures ---------------- */
#ifdef HASPROTOS
extern TOKEN nexttok( void );
extern void ungettok( void );
extern BOOL readnextline( char * );
#else
extern TOKEN nexttok();
extern void ungettok();
extern BOOL readnextline();
#endif
extern TOKEN nexttok( void );
extern BOOL readnextline( char * line );
......@@ -13,26 +13,14 @@ BOOL opt; /* opt == perform optimizations */
BOOL verbose; /* verbose == be verbose - diagnostics */
/*
/^#ifdef HASPROTOS
!/endif$
stat %
*/
#ifdef HASPROTOS
static void optimize_decln( decln );
static BOOL tail_optimize( decln );
#else
static void optimize_decln();
static BOOL tail_optimize();
#endif
#define implies( a, b ) (!(a) || (b))
void optimize( d ) declnlist d;
void optimize( declnlist d )
{
for( ; d != NULL; d = d->next )
{
......@@ -48,7 +36,7 @@ void optimize( d ) declnlist d;
}
static void optimize_decln( d ) decln d;
static void optimize_decln( decln d )
{
int t, e, ne;
shapelist s;
......@@ -135,7 +123,7 @@ static void optimize_decln( d ) decln d;
Return TRUE if the optimization is possible.
*/
static BOOL tail_optimize( d ) decln d;
static BOOL tail_optimize( decln d )
{
shapelist s;
printlist pl;
......
......@@ -5,8 +5,4 @@ extern BOOL opt; /* perform optimizations */
extern BOOL verbose; /* be verbose */
#ifdef HASPROTOS
extern void optimize( declnlist );
#else
extern void optimize();
#endif
......@@ -36,36 +36,16 @@
#define COPYOF(new,old) {new=malloc(1+strlen(old));if(new)strcpy(new,old);}
/*
/^#ifdef HASPROTOS
!/endif$
stat %
*/
#ifdef HASPROTOS
static BOOL parse_chunk( char * );
static BOOL parse_declns( declnlist * );
static void error( char * );
static BOOL parse_decln( char ** , shapelist * );
static BOOL parse_shapes( shapelist * );
static BOOL parse_shape( char ** , paramlist * , printlist * );
static BOOL parse_params( paramlist * );
static BOOL parse_printlist( printlist * );
static BOOL parse_printitem( printitem * );
static BOOL parse_param( char ** , char ** );
#else
static BOOL parse_chunk();
static BOOL parse_declns();
static void error();
static BOOL parse_decln();
static BOOL parse_shapes();
static BOOL parse_shape();
static BOOL parse_params();
static BOOL parse_printlist();
static BOOL parse_printitem();
static BOOL parse_param();
#endif
static BOOL parse_chunk( char * s );
static BOOL parse_declns( declnlist * dp );
static void error( char * s );
static BOOL parse_decln( char ** name, shapelist * shapes );
static BOOL parse_shapes( shapelist * sp );
static BOOL parse_shape( char ** tagname, paramlist * pl, printlist * print );
static BOOL parse_params( paramlist * pp );
static BOOL parse_printlist( printlist * pp );
static BOOL parse_printitem( printitem * item );
static BOOL parse_param( char ** type, char ** name );
#define MUSTBE(t,mesg) if( nexttok() != (t) ) {error(mesg); return FALSE;}
......@@ -78,7 +58,7 @@ static BOOL parse_param();
* tTYPE tOPENCURLY declns tCLOSECURLY
*/
BOOL parse_data( exports, globals, begin, dp ) char *exports, *globals, *begin; declnlist *dp;
BOOL parse_data( char *exports, char *globals, char *begin, declnlist *dp )
{
if( nexttok() == tEXPORT )
{
......@@ -119,7 +99,7 @@ BOOL parse_data( exports, globals, begin, dp ) char *exports, *globals, *begin;
/* chunk = tOPENCURLY list_of_lines tCLOSECURLY */
static BOOL parse_chunk( s ) char *s;
static BOOL parse_chunk( char *s )
{
char line[256];
int startlineno;
......@@ -149,7 +129,7 @@ static BOOL parse_chunk( s ) char *s;
/* declns = list*( decln ) */
/* NB: a decln starts with a tID */
static BOOL parse_declns( dp ) declnlist *dp;
static BOOL parse_declns( declnlist *dp )
{
char *name;
shapelist shapes;
......@@ -166,7 +146,7 @@ static BOOL parse_declns( dp ) declnlist *dp;
}
static void error( s ) char *s;
static void error( char *s )
{
fprintf( stderr, "%s at line %d\n", s, lineno );
}
......@@ -174,7 +154,7 @@ static void error( s ) char *s;
/* decln = tID tEQ shapes tSEMI */
static BOOL parse_decln( name, shapes ) char **name; shapelist *shapes;
static BOOL parse_decln( char **name, shapelist *shapes )
{
MUSTBE( tID, "declaration expected" );
COPYOF( *name, lexidval );
......@@ -191,7 +171,7 @@ static BOOL parse_decln( name, shapes ) char **name; shapelist *shapes;
/* shapes = sep-list+( shape, tOR ) */
static BOOL parse_shapes( sp ) shapelist *sp;
static BOOL parse_shapes( shapelist *sp )
{
char *tagname;
paramlist paras;
......@@ -211,7 +191,7 @@ static BOOL parse_shapes( sp ) shapelist *sp;
/* shape = tID [ tOPENBR params tCLOSEBR ] printlist */
static BOOL parse_shape( tagname, pl, print ) char **tagname; paramlist *pl; printlist *print;
static BOOL parse_shape( char **tagname, paramlist *pl, printlist *print )
{
*pl = (paramlist) NULL;
*print = (printlist) NULL;
......@@ -235,7 +215,7 @@ static BOOL parse_shape( tagname, pl, print ) char **tagname; paramlist *pl; pri
/* params = sep-list+( param, tCOMMA ) */
static BOOL parse_params( pp ) paramlist *pp;
static BOOL parse_params( paramlist *pp )
{
char *type;
char *name;
......@@ -254,7 +234,7 @@ static BOOL parse_params( pp ) paramlist *pp;
/* printlist = list( printitem ) */
/* NB: Never fails, cos items are one token long */
static BOOL parse_printlist( pp ) printlist *pp;
static BOOL parse_printlist( printlist *pp )
{
printitem item;
......@@ -271,7 +251,7 @@ static BOOL parse_printlist( pp ) printlist *pp;
/* printitem = tSTR | tNUM */
static BOOL parse_printitem( item ) printitem *item;
static BOOL parse_printitem( printitem *item )
{
char *temp;
......@@ -292,7 +272,7 @@ static BOOL parse_printitem( item ) printitem *item;
/* param = tID tID */
static BOOL parse_param( type, name ) char **type, **name;
static BOOL parse_param( char **type, char **name )
{
MUSTBE( tID, "Field type expected" );
COPYOF( *type, lexidval );
......
#ifdef HASPROTOS
extern BOOL parse_data( char * , char * , char * , declnlist * );
#else
extern BOOL parse_data();
#endif
extern BOOL parse_data( char * exports, char * globals, char * begin, declnlist * dp );
......@@ -18,7 +18,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include "struct.h"
......@@ -27,7 +26,7 @@
#define COPYOF(new,old) {new=malloc(1+strlen(old));if(new)strcpy(new,old);}
declnlist build_declnlist(name,s,next) char *name; shapelist s; declnlist next;
declnlist build_declnlist( char *name, shapelist s, declnlist next )
{
declnlist new = NEW(declnlist);
......@@ -38,7 +37,7 @@ declnlist build_declnlist(name,s,next) char *name; shapelist s; declnlist next;
}
void print_declnlist(d) declnlist d;
void print_declnlist( declnlist d )
{
for ( ; d; d = d->next)
{
......@@ -50,7 +49,7 @@ void print_declnlist(d) declnlist d;
}
shapelist build_shapelist(id, p, pl, next) char *id; paramlist p; printlist pl; shapelist next;
shapelist build_shapelist( char *id, paramlist p, printlist pl, shapelist next )
{
shapelist new = NEW(shapelist);
......@@ -62,7 +61,7 @@ shapelist build_shapelist(id, p, pl, next) char *id; paramlist p; printlist pl;
}
void print_shape(s) shapelist s;
void print_shape( shapelist s )
{
Puts(s->name);
if (s->params)
......@@ -76,7 +75,7 @@ void print_shape(s) shapelist s;
}
void print_shapelist(s) shapelist s;
void print_shapelist( shapelist s )
{
if (s != NULL)
{
......@@ -90,7 +89,7 @@ void print_shapelist(s) shapelist s;
}
paramlist build_paramlist(type, id, next) char *type, *id; paramlist next;
paramlist build_paramlist( char *type, char *id, paramlist next )
{
paramlist new = NEW(paramlist);
......@@ -102,7 +101,7 @@ paramlist build_paramlist(type, id, next) char *type, *id; paramlist next;
}
void print_paramlist(p) paramlist p;
void print_paramlist( paramlist p )
{
if (p != NULL)
{
......@@ -115,7 +114,7 @@ void print_paramlist(p) paramlist p;
}
printitem build_printitem_str(s) char *s;
printitem build_printitem_str( char *s )
{
printitem new = NEW( printitem );
......@@ -126,7 +125,7 @@ printitem build_printitem_str(s) char *s;
}
printitem build_printitem_num(n) int n;
printitem build_printitem_num( int n )
{
printitem new = NEW(printitem);
......@@ -137,7 +136,7 @@ printitem build_printitem_num(n) int n;
}
void print_printitem(i) printitem i;
void print_printitem( printitem i )
{
switch(i->tag)
{
......@@ -156,7 +155,7 @@ void print_printitem(i) printitem i;
}
printlist build_printlist(h, t) printitem h; printlist t;
printlist build_printlist( printitem h, printlist t )
{
printlist new = NEW(printlist);
......@@ -166,7 +165,7 @@ printlist build_printlist(h, t) printitem h; printlist t;
}
void print_printlist(p) printlist p;
void print_printlist( printlist p )
{
for (; p; p = p->next)
{
......@@ -175,7 +174,7 @@ void print_printlist(p) printlist p;
}
param findnthparam( n, p, sname, dname ) int n; paramlist p; char *sname, *dname;
param findnthparam( int n, paramlist p, char *sname, char *dname )
{
int m = n;
......@@ -191,6 +190,3 @@ param findnthparam( n, p, sname, dname ) int n; paramlist p; char *sname, *dname
return p;
}
......@@ -81,39 +81,16 @@ typedef shapelist shape; /* JUST THE FIRST */
typedef paramlist param; /* JUST THE FIRST */
/*
/^#ifdef HASPROTOS
!/endif$
prot %
*/
#ifdef HASPROTOS
extern declnlist build_declnlist( char * , shapelist , declnlist );
extern void print_declnlist( declnlist );
extern shapelist build_shapelist( char * , paramlist , printlist , shapelist );
extern void print_shape( shapelist );
extern void print_shapelist( shapelist );
extern paramlist build_paramlist( char * , char * , paramlist );
extern void print_paramlist( paramlist );
extern printitem build_printitem_str( char * );
extern printitem build_printitem_num( int );
extern void print_printitem( printitem );
extern printlist build_printlist( printitem , printlist );
extern void print_printlist( printlist );
extern param findnthparam( int , paramlist , char * , char * );
#else
extern declnlist build_declnlist();
extern void print_declnlist();
extern shapelist build_shapelist();
extern void print_shape();
extern void print_shapelist();
extern paramlist build_paramlist();
extern void print_paramlist();
extern printitem build_printitem_str();
extern printitem build_printitem_num();
extern void print_printitem();
extern printlist build_printlist();
extern void print_printlist();
extern param findnthparam();
#endif
extern declnlist build_declnlist( char * name, shapelist s, declnlist next );
extern void print_declnlist( declnlist d );
extern shapelist build_shapelist( char * id, paramlist p, printlist pl, shapelist next );
extern void print_shape( shapelist s );
extern void print_shapelist( shapelist s );
extern paramlist build_paramlist( char * type, char * id, paramlist next );
extern void print_paramlist( paramlist p );
extern printitem build_printitem_str( char * s );
extern printitem build_printitem_num( int n );
extern void print_printitem( printitem i );
extern printlist build_printlist( printitem h, printlist t );
extern void print_printlist( printlist p );
extern param findnthparam( int n, paramlist p, char * sname, char * dname );
CFLAGS = -g -UDEBUGGING
CFLAGS = -g -UDEBUGGING -Wall
TESTEXECS = ctest
AUTOCRAP = ctest.o cx.[och]
......
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