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