Ansify function definitions.

This commit is contained in:
David Given 2016-12-12 21:15:25 +01:00
parent bf2e0be69a
commit a53b51001b
23 changed files with 86 additions and 154 deletions

View file

@ -5,11 +5,11 @@
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
long _abl(i) long i; long _abl(long i)
{ {
return( i>=0?i:-i); return( i>=0?i:-i);
} }
double _abr(f) double f; double _abr(double f)
{ {
return( f>=0.0?f: -f); return( f>=0.0?f: -f);
} }

View file

@ -2,8 +2,7 @@
/* $Id$ */ /* $Id$ */
int _asc(str) int _asc(String* str)
String *str;
{ {
if(str==0 || str->strval==0) if(str==0 || str->strval==0)
error(3); error(3);

View file

@ -1,6 +1,7 @@
/* $Id$ */ #include <stdio.h>
#include <stdlib.h>
asrt(b) void asrt(int b)
{ {
if(!b){ if(!b){
printf("ASSERTION ERROR\n"); printf("ASSERTION ERROR\n");

View file

@ -2,8 +2,7 @@
/* $Id$ */ /* $Id$ */
String *_chr(i) String *_chr(int i)
int i;
{ {
String *s; String *s;
char buf[2]; char buf[2];

View file

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
int _cint(f) double f; int _cint(double f)
{ {
int r; int r;
if( f<-32768 || f>32767) error(4); if( f<-32768 || f>32767) error(4);
@ -10,8 +10,7 @@ int _cint(f) double f;
return(r); return(r);
} }
double _trunc(f) double _trunc(double f)
double f;
{ {
long d; long d;
d=f; d=f;
@ -19,7 +18,7 @@ double f;
return( f ); return( f );
} }
double _fcint(f) double f; double _fcint(double f)
{ {
long r; long r;
if(f<0){ if(f<0){
@ -29,8 +28,7 @@ double _fcint(f) double f;
f=r; f=r;
return(f); return(f);
} }
int _fix(f) int _fix(double f)
double f;
{ {
int r; int r;

View file

@ -52,8 +52,7 @@ char *errortable[255]={
0 0
}; };
error(index) void error(int index)
int index;
{ {
_setline(); _setline();
if( index<0 || index >40 ) if( index<0 || index >40 )

View file

@ -18,8 +18,7 @@ int _chann = -1;
FILE *_chanrd = stdin; FILE *_chanrd = stdin;
FILE *_chanwr = stdout; FILE *_chanwr = stdout;
_setchan(index) void _setchan(int index)
int index;
{ {
#ifdef DEBUG #ifdef DEBUG
printf("setchannel %d\n",index); printf("setchannel %d\n",index);
@ -38,7 +37,7 @@ int index;
_chanrd= _chanwr= _fdtable[index].fd; _chanrd= _chanwr= _fdtable[index].fd;
} }
_asschn() void _asschn(void)
{ {
#ifdef DEBUG #ifdef DEBUG
printf("_asschn %d\n",_chann); printf("_asschn %d\n",_chann);
@ -55,17 +54,14 @@ _asschn()
error(2); error(2);
} }
_clochn(nr) void _clochn(int nr)
int nr;
{ {
if( nr<1 || nr >15 || _fdtable[nr].fd==0) error(3); if( nr<1 || nr >15 || _fdtable[nr].fd==0) error(3);
fclose(_fdtable[nr].fd); fclose(_fdtable[nr].fd);
_fdtable[nr].fd=0; _fdtable[nr].fname=0; _fdtable[nr].fd=0; _fdtable[nr].fname=0;
} }
_opnchn(reclen,fname,mode) void _opnchn(int reclen, String* fname, String* mode)
String *mode,*fname;
int reclen;
{ {
/* channel has been set */ /* channel has been set */
FILE *f; FILE *f;
@ -110,8 +106,7 @@ int reclen;
#endif #endif
} }
_ioeof(channel) int _ioeof(int channel)
int channel;
{ {
FILE *fd; FILE *fd;
char c; char c;
@ -125,7 +120,7 @@ int channel;
return(0); return(0);
} }
_close() void _close(void)
{ {
/* close all open files */ /* close all open files */
int i; int i;

View file

@ -1,12 +1,11 @@
#include <stdlib.h> #include <stdlib.h>
_hlt(nr) void _hlt(int nr)
int nr;
{ {
exit(nr); exit(nr);
} }
_goto_err() void _goto_err(void)
{ {
error(3); error(3);
} }

View file

@ -10,8 +10,7 @@
int _width = 75, _pos=0, _zonewidth=15; int _width = 75, _pos=0, _zonewidth=15;
_out(str) void _out(char* str)
char *str;
{ {
int pos; int pos;
@ -27,7 +26,7 @@ char *str;
else _fdtable[_chann].pos= pos; else _fdtable[_chann].pos= pos;
} }
_outnl() void _outnl(void)
{ {
fputc('\n',_chanwr); fputc('\n',_chanwr);
if( _chann == -1) if( _chann == -1)
@ -35,7 +34,7 @@ _outnl()
else else
_fdtable[_chann].pos=0; _fdtable[_chann].pos=0;
} }
_zone() void _zone(void)
{ {
/* go to next zone */ /* go to next zone */
int pos; int pos;
@ -55,8 +54,7 @@ _zone()
if( _chann== -1) _pos=pos; if( _chann== -1) _pos=pos;
else _fdtable[_chann].pos= pos; else _fdtable[_chann].pos= pos;
} }
_in(buf) void _in(char* buf)
char *buf;
{ {
register int holder ; register int holder ;
char *c; char *c;
@ -77,15 +75,13 @@ char *buf;
_pos=pos; _pos=pos;
} else _fdtable[_chann].pos= pos; } else _fdtable[_chann].pos= pos;
} }
_tab(x) void _tab(int x)
int x;
{ {
if( x> _width) error(3); if( x> _width) error(3);
if( x< _pos) _outnl(); if( x< _pos) _outnl();
_spc(x-_pos); _spc(x-_pos);
} }
_spc(x) void _spc(int x)
int x;
{ {
while(x-->0) _out(" "); while(x-->0) _out(" ");
} }

View file

@ -2,8 +2,7 @@
/* $Id$ */ /* $Id$ */
String *_mki(i) String *_mki(long i)
long i;
{ {
char *buffer =" "; char *buffer =" ";
String *s; String *s;
@ -12,8 +11,7 @@ long i;
* ( (long *)s->strval ) = i ; * ( (long *)s->strval ) = i ;
return(s); return(s);
} }
String *_mkd(d) String *_mkd(double d)
double d;
{ {
char *buffer =" "; char *buffer =" ";
String *s; String *s;
@ -22,13 +20,11 @@ double d;
* ( (double *)s->strval ) = d ; * ( (double *)s->strval ) = d ;
return(s); return(s);
} }
long _cvi(s) long _cvi(String* s)
String *s;
{ {
return *( (long *) s->strval) ; return *( (long *) s->strval) ;
} }
double _cvd(s) double _cvd(String* s)
String *s;
{ {
return *( (double *) s->strval) ; return *( (double *) s->strval) ;
} }

View file

@ -4,16 +4,14 @@
/* $Id$ */ /* $Id$ */
String *_oct(i) String *_oct(int i)
int i;
{ {
char buffer[30]; char buffer[30];
sprintf(buffer,"%o",i); sprintf(buffer,"%o",i);
return( (String *)_newstr(buffer)); return( (String *)_newstr(buffer));
} }
String *_hex(i) String *_hex(int i)
int i;
{ {
char buffer[30]; char buffer[30];
@ -21,8 +19,7 @@ int i;
return( (String *)_newstr(buffer)); return( (String *)_newstr(buffer));
} }
String *_nstr(f) String *_nstr(double f)
double f;
{ {
char buffer[80]; char buffer[80];

View file

@ -1,7 +1,6 @@
/* $Id$ */ /* $Id$ */
int peek(addr) int peek(int addr)
int addr;
{ {
/* this can not work properly for machines in which the /* this can not work properly for machines in which the
POINTERSIZE differs from the integer size POINTERSIZE differs from the integer size
@ -17,8 +16,7 @@ int addr;
return(i); return(i);
} }
_poke(i,j) void _poke(int i, int j)
int i,j;
{ {
char *p; char *p;
p= (char *) i; p= (char *) i;

View file

@ -7,19 +7,18 @@
/* Here all routine to generate terminal oriented output is located */ /* Here all routine to generate terminal oriented output is located */
_qstmark() void _qstmark(void)
{ {
/* prompt for terminal input */ /* prompt for terminal input */
putchar('?'); putchar('?');
} }
_nl() void _nl(void)
{ {
_asschn(); _asschn();
_outnl(); _outnl();
} }
_prinum(i) void _prinum(int i)
int i;
{ {
char buffer[40]; char buffer[40];
@ -29,9 +28,7 @@ int i;
else sprintf(buffer,"-%d ",-i); else sprintf(buffer,"-%d ",-i);
_out(buffer); _out(buffer);
} }
_str(f,buffer) void _str(double f, char* buffer)
double f;
char *buffer;
{ {
register char *c = buffer; register char *c = buffer;
int eformat = 0; int eformat = 0;
@ -59,8 +56,7 @@ char *buffer;
if( *c=='.') *c=0; if( *c=='.') *c=0;
} }
} }
_prfnum(f) void _prfnum(double f)
double f;
{ {
/* BASIC strings trailing zeroes */ /* BASIC strings trailing zeroes */
char buffer[100]; char buffer[100];
@ -72,8 +68,7 @@ double f;
strcat(buffer," "); strcat(buffer," ");
_out(buffer); _out(buffer);
} }
_prstr(str) void _prstr(String* str)
String *str;
{ {
_asschn(); _asschn();
if( str==0) _out("<null>"); if( str==0) _out("<null>");

View file

@ -5,7 +5,7 @@
#define EM_WSIZE _EM_WSIZE #define EM_WSIZE _EM_WSIZE
#endif #endif
_randomi() void _randomi(void)
{ {
int i; int i;
_setchan(-1); _setchan(-1);
@ -14,12 +14,11 @@ _randomi()
_setrand(i); _setrand(i);
} }
_setrand(i) void _setrand(int i)
int i;
{ {
srand(i); srand(i);
} }
double _rnd(d) double d; double _rnd(double d)
{ {
double f; f= (int) rand(); double f; f= (int) rand();
return(f/ return(f/

View file

@ -4,14 +4,14 @@
/* $Id$ */ /* $Id$ */
_readln() void _readln(void)
{ {
register int c; register int c;
while( (c=fgetc(_chanrd)) != EOF && c!= '\n') while( (c=fgetc(_chanrd)) != EOF && c!= '\n')
; ;
} }
readskip() void readskip(void)
{ {
register int c; register int c;
#ifdef DEBUG #ifdef DEBUG
@ -20,8 +20,7 @@ readskip()
while( (c=fgetc(_chanrd)) != EOF && c!= ',' && c!= '\n') while( (c=fgetc(_chanrd)) != EOF && c!= ',' && c!= '\n')
; ;
} }
_readint(addr) void _readint(int* addr)
int *addr;
{ {
int i; int i;
char buf[1024]; char buf[1024];
@ -45,8 +44,7 @@ int *addr;
error(40); error(40);
}else { readskip(); *addr=i;} }else { readskip(); *addr=i;}
} }
_readflt(addr) void _readflt(double* addr)
double *addr;
{ {
double f; double f;
char buf[1024]; char buf[1024];
@ -69,8 +67,7 @@ double *addr;
error(40); error(40);
}else { readskip(); *addr=f;} }else { readskip(); *addr=f;}
} }
_readstr(s) void _readstr(String** s)
String **s;
{ {
char buffer[1024]; char buffer[1024];
register int kar ; register int kar ;
@ -130,8 +127,7 @@ String **s;
extern int _seektab[]; extern int _seektab[];
_restore(line) void _restore(int line)
int line;
{ {
int nr; int nr;
char buffer[1024]; char buffer[1024];
@ -155,8 +151,7 @@ int line;
while(nr-- >0 ) fgets(buffer,1024,_chanrd); while(nr-- >0 ) fgets(buffer,1024,_chanrd);
} }
} }
_rdline(s) void _rdline(String** s)
String **s;
{ {
char buffer[1024]; char buffer[1024];
if( fgets(buffer,1024,_chanrd) == 0) if( fgets(buffer,1024,_chanrd) == 0)

View file

@ -5,8 +5,7 @@
int _gotable[MAXNESTING]; int _gotable[MAXNESTING];
int topstk=0; int topstk=0;
_gosub(x) void _gosub(int x)
int x;
{ {
/* administer gosub */ /* administer gosub */
#ifdef DEBUG #ifdef DEBUG
@ -16,7 +15,7 @@ int x;
_gotable[topstk]= x; _gotable[topstk]= x;
topstk++; topstk++;
} }
_retstmt() int _retstmt(void)
{ {
/* make sure that a return label index is on top /* make sure that a return label index is on top
of the stack */ of the stack */

View file

@ -1,7 +1,6 @@
#include <stdlib.h> #include <stdlib.h>
char * salloc(length) char * salloc(unsigned length)
unsigned length;
{ {
char *c, *s; char *c, *s;
c= malloc(length); c= malloc(length);
@ -10,8 +9,7 @@ unsigned length;
return(c); return(c);
} }
sfree(c) void sfree(char* c)
char *c;
{ {
if( !c ) return; if( !c ) return;
free(c); free(c);

View file

@ -1,15 +1,13 @@
/* $Id$ */ /* $Id$ */
_sgn(v) int _sgn(double v)
double v;
{ {
if( v>0) return(1); if( v>0) return(1);
if( v<0) return(-1); if( v<0) return(-1);
return(0); return(0);
} }
_forsgn(v) int _forsgn(double v)
double v;
{ {
if (v >= 0) return 1; if (v >= 0) return 1;
return -1; return -1;

View file

@ -9,14 +9,12 @@
extern char *salloc() ; extern char *salloc() ;
_length(str) int _length(String* str)
String *str;
{ {
okr(str); okr(str);
return(str->strlength); return(str->strlength);
} }
String *_newstr(str) String *_newstr(char* str)
char *str;
{ {
String *s; String *s;
okr(str); okr(str);
@ -27,15 +25,13 @@ char *str;
strcpy(s->strval,str); strcpy(s->strval,str);
return(s); return(s);
} }
_incstr(src) void _incstr(String* src)
String *src;
{ {
/* one more variable uses the string */ /* one more variable uses the string */
ok(src); ok(src);
src->strcount++; src->strcount++;
} }
_decstr(str) void _decstr(String* str)
String *str;
{ {
ok(str); ok(str);
/* Strings in ROM are initialized with this count */ /* Strings in ROM are initialized with this count */
@ -43,8 +39,7 @@ String *str;
str->strcount--; str->strcount--;
if(str->strcount<=0) _delstr(str); if(str->strcount<=0) _delstr(str);
} }
_strcpy(dst,src) void _strcpy(String* dst, String* src)
String *src,*dst;
{ {
ok(src); ok(src);
ok(dst); ok(dst);
@ -52,15 +47,13 @@ String *src,*dst;
*dst = *src; *dst = *src;
_incstr(src); _incstr(src);
} }
_delstr(src) void _delstr(String* src)
String *src;
{ {
ok(src); ok(src);
sfree(src->strval); sfree(src->strval);
sfree((char *)src); sfree((char *)src);
} }
String *_concat(s1,s2) String *_concat(String* s1,String* s2)
String *s1,*s2;
{ {
String *s; String *s;
int length; int length;
@ -73,16 +66,13 @@ String *s1,*s2;
strcat(s->strval,s1->strval); strcat(s->strval,s1->strval);
return(s); return(s);
} }
_strcomp(s1,s2) int _strcomp(String* s1,String* s2)
String *s1,*s2;
{ {
okr(s1);okr(s2); okr(s1);okr(s2);
return(strcmp(s2->strval,s1->strval)); return(strcmp(s2->strval,s1->strval));
} }
String *_left(size,s) String *_left(int size, String* s)
String *s;
int size;
{ {
String *ns; String *ns;
int i; int i;
@ -99,8 +89,7 @@ int size;
return(ns); return(ns);
} }
String *_space(d) String *_space(int d)
int d;
{ {
String *s; String *s;
int i,len; int i,len;
@ -116,11 +105,10 @@ int d;
return(s); return(s);
} }
String *_strascii() String *_strascii(void)
{ {
} }
String *_string(f, d) String *_string(double f, double d)
double d,f;
{ {
int i,j; int i,j;
String *s; String *s;
@ -136,9 +124,7 @@ double d,f;
s->strval[i]= j; s->strval[i]= j;
return(s); return(s);
} }
_midstmt(s2,i1,i2,s) void _midstmt(String* s2, int i1, int i2, String* s)
int i1,i2;
String *s, *s2;
{ {
int l; int l;
@ -150,9 +136,7 @@ String *s, *s2;
if( i1>l ) i1=l; if( i1>l ) i1=l;
strncpy(s->strval+i2-1,s2->strval,i1); strncpy(s->strval+i2-1,s2->strval,i1);
} }
String *_mid(i1,i2,s) String *_mid(int i1, int i2, String* s)
int i1,i2;
String *s;
{ {
int l; int l;
String *s2; String *s2;
@ -170,9 +154,7 @@ String *s;
return(s2); return(s2);
} }
String *_right(length,str) String *_right(int length, String* str)
String *str;
int length;
{ {
String *s; String *s;
int i; int i;

View file

@ -2,8 +2,7 @@
/* $Id$ */ /* $Id$ */
_intswap(i1,i2) void _intswap(int* i1, int* i2)
int *i1,*i2;
{ {
int i3; int i3;
i3= *i1; i3= *i1;
@ -11,8 +10,7 @@ int *i1,*i2;
*i2=i3; *i2=i3;
} }
_fltswap(i1,i2) void _fltswap(double* i1, double* i2)
double *i1,*i2;
{ {
double i3; double i3;
i3= *i1; i3= *i1;
@ -20,8 +18,7 @@ double *i1,*i2;
*i2=i3; *i2=i3;
} }
_strswap(s1,s2) void _strswap(String** s1, String** s2)
String **s1,**s2;
{ {
String *s; String *s;
s= *s1; s= *s1;

View file

@ -1,7 +1,6 @@
/* $Id$ */ /* $Id$ */
_trace(i) void _trace(int i)
int i;
{ {
printf("[%d]",i); printf("[%d]",i);
} }

View file

@ -13,15 +13,12 @@
int _trpline; /* BASIC return label */ int _trpline; /* BASIC return label */
jmp_buf trpbuf; jmp_buf trpbuf;
_trpset(nr) void _trpset(int nr)
int nr;
{ {
/*debug printf("trap set to %d\n",nr);*/ /*debug printf("trap set to %d\n",nr);*/
_trpline=nr; _trpline=nr;
} }
void void _trpfatal(int i)
_trpfatal(i)
int i;
{ {
extern int _errsym,_erlsym; extern int _errsym,_erlsym;
@ -35,7 +32,7 @@ int i;
_trap(); _trap();
} }
_ini_trp() void _ini_trp(void)
{ {
/* initialize trap routines */ /* initialize trap routines */
int i; int i;
@ -45,12 +42,11 @@ _ini_trp()
} }
_settrap(nr) void _settrap(int nr)
int nr;
{ {
_trpline=nr; _trpline=nr;
} }
_trap() void _trap(void)
{ {
int line; int line;

View file

@ -5,30 +5,27 @@
/* assume that the channel has been set */ /* assume that the channel has been set */
_wrnl() void _wrnl(void)
{ {
if( fputc('\n',_chanwr) == EOF) error(29); if( fputc('\n',_chanwr) == EOF) error(29);
} }
_wrcomma() void _wrcomma(void)
{ {
if( fputc(',',_chanwr) == EOF) error(29); if( fputc(',',_chanwr) == EOF) error(29);
} }
_wrint(i) void _wrint(int i)
int i;
{ {
if(i>0) if(i>0)
if( fputc(' ',_chanwr)==EOF) error(29); if( fputc(' ',_chanwr)==EOF) error(29);
fprintf(_chanwr,"%d",i); fprintf(_chanwr,"%d",i);
if( ferror(_chanwr) ) error(29); if( ferror(_chanwr) ) error(29);
} }
_wrflt(f) void _wrflt(double f)
double f;
{ {
fprintf(_chanwr,"%f",f); fprintf(_chanwr,"%f",f);
if( ferror(_chanwr) ) error(29); if( ferror(_chanwr) ) error(29);
} }
_wrstr(s) void _wrstr(String* s)
String *s;
{ {
fprintf(_chanwr,"\"%s\"",s->strval); fprintf(_chanwr,"\"%s\"",s->strval);
if( ferror(_chanwr) ) error(29); if( ferror(_chanwr) ) error(29);