Prototypes for string functions. More static.

This commit is contained in:
George Koehler 2017-11-12 11:25:18 -05:00
parent 98b27dd505
commit ba2a45180c
14 changed files with 117 additions and 123 deletions

View file

@ -1114,7 +1114,6 @@ readcodebytes()
#ifdef TABLEDEBUG #ifdef TABLEDEBUG
initlset(f) char* f; initlset(f) char* f;
{ {
extern char* myalloc();
set_flag = f; set_flag = f;
if ((set_fd = open(f + 1, 2)) < 0) if ((set_fd = open(f + 1, 2)) < 0)

View file

@ -87,10 +87,8 @@ char opdesc[] = {
#endif #endif
}; };
string salloc(),strcpy(),strcat(); static string mycat(string s1, string s2) {
string s;
string mycat(s1,s2) register string s1,s2; {
register string s;
if (s1==0 || *s1=='\0') return(s2); if (s1==0 || *s1=='\0') return(s2);
if (s2==0 || *s2=='\0') return(s1); if (s2==0 || *s2=='\0') return(s1);
@ -101,7 +99,7 @@ string mycat(s1,s2) register string s1,s2; {
return(s); return(s);
} }
string mystrcpy(s) register string s; { string mystrcpy(string s) {
register string r; register string r;
r=salloc(strlen(s)); r=salloc(strlen(s));
@ -109,9 +107,9 @@ string mystrcpy(s) register string s; {
return(r); return(r);
} }
char digstr[21][15]; static char digstr[21][15];
string tostring(n) register word n; { string tostring(word n) {
char buf[25]; char buf[25];
if (n>=-20 && n<=20 && (n&1)==0) { if (n>=-20 && n<=20 && (n&1)==0) {

View file

@ -21,15 +21,13 @@ static char rcsid[] = "$Id$";
* Author: Hans van Staveren * Author: Hans van Staveren
*/ */
extern string myalloc(); static int rar[MAXCREG];
static rl_p *lar;
static int maxindex;
static int regclass[NREGS];
static struct perm *perms;
int rar[MAXCREG]; static void permute(int);
rl_p *lar;
int maxindex;
int regclass[NREGS];
struct perm *perms;
void permute();
struct perm * struct perm *
tuples(regls,nregneeded) rl_p *regls; { tuples(regls,nregneeded) rl_p *regls; {
@ -66,11 +64,10 @@ tuples(regls,nregneeded) rl_p *regls; {
return(perms); return(perms);
} }
void static void permute(int index) {
permute(index) { struct perm *pp;
register struct perm *pp; rl_p rlp;
register rl_p rlp; int i,j;
register i,j;
if (index == maxindex) { if (index == maxindex) {
for (pp=perms; pp != 0; pp=pp->p_next) { for (pp=perms; pp != 0; pp=pp->p_next) {

View file

@ -55,50 +55,57 @@ Read the documentation.
#define SEGROM 2 #define SEGROM 2
#define SEGBSS 3 #define SEGBSS 3
long con();
#define get8() getc(emfile) #define get8() getc(emfile)
FILE *emfile; static FILE *emfile;
int nextispseu,savetab1; static int nextispseu,savetab1;
int opcode; static int opcode;
int offtyp; static int offtyp;
long argval; static long argval;
int dlbval; static int dlbval;
char *str,argstr[128],labstr[128]; static char *str,argstr[128],labstr[128];
unsigned int maxstrsiz; static unsigned int maxstrsiz;
int strsiz; static int strsiz;
int holno=0; static int holno=0;
int procno=0; static int procno=0;
int curseg= -1; static int curseg= -1;
int part_size=0; static int part_size=0;
word part_word=0; static word part_word=0;
#ifdef REGVARS #ifdef REGVARS
int regallowed=0; static int regallowed=0;
#endif #endif
extern char em_flag[]; extern char em_flag[];
extern short em_ptyp[]; extern short em_ptyp[];
extern double atof();
/* machine dependent */
void prolog(full nlocals); void prolog(full nlocals);
void mes(); void mes(word);
void bss();
void savelab(); static int getarg(int);
void dumplab(); static int table1(void);
void part_flush(); static int table2(void);
void xdumplab(); static int table3(int);
void switchseg(); static int get16(void);
static long get32(void);
static void getstring(void);
static string strarg(int);
static void bss(full, int, int);
static long con(int);
static void switchseg(int);
static void savelab(void);
static void dumplab(void);
static void xdumplab(void);
static void part_flush(void);
static string holstr(word);
/* Own version of atol that continues computing on overflow. /* Own version of atol that continues computing on overflow.
We don't know that about the ANSI C one. We don't know that about the ANSI C one.
*/ */
long our_atol(s) long our_atol(char *s) {
register char *s; long total = 0;
{ unsigned digit;
register long total = 0;
register unsigned digit;
int minus = 0; int minus = 0;
while (*s == ' ' || *s == '\t') s++; while (*s == ' ' || *s == '\t') s++;
@ -117,14 +124,7 @@ register char *s;
#define sp_cstx sp_cst2 #define sp_cstx sp_cst2
string tostring(); void in_init(char *filename) {
string holstr();
string strarg();
string mystrcpy();
string myalloc();
long get32();
in_init(filename) char *filename; {
emfile = stdin; emfile = stdin;
if (filename && (emfile=freopen(filename,"r",stdin))==NULL) if (filename && (emfile=freopen(filename,"r",stdin))==NULL)
@ -134,19 +134,18 @@ in_init(filename) char *filename; {
str = myalloc(maxstrsiz=256); str = myalloc(maxstrsiz=256);
} }
in_start() { void in_start(void) {
#ifdef modhead #ifdef modhead
fprintf(codefile,"%s",modhead) ; fprintf(codefile,"%s",modhead) ;
#endif #endif
} }
in_finish() { static void in_finish(void) {
} }
void void fillemlines(void) {
fillemlines() { int t,i;
register int t,i; struct emline *lp;
register struct emline *lp;
while ((emlines+nemlines)-emp<MAXEMLINES-5) { while ((emlines+nemlines)-emp<MAXEMLINES-5) {
assert(nemlines<MAXEMLINES); assert(nemlines<MAXEMLINES);
@ -439,8 +438,8 @@ dopseudo() {
/* ----- input ----- */ /* ----- input ----- */
int getarg(typset) { static int getarg(int typset) {
register t,argtyp; int t,argtyp;
argtyp = t = table2(); argtyp = t = table2();
if (t == EOF) if (t == EOF)
@ -452,8 +451,8 @@ int getarg(typset) {
return(argtyp); return(argtyp);
} }
int table1() { static int table1(void) {
register i; int i;
i = get8(); i = get8();
if (i < sp_fmnem+sp_nmnem && i >= sp_fmnem) { if (i < sp_fmnem+sp_nmnem && i >= sp_fmnem) {
@ -471,8 +470,8 @@ int table1() {
return(table3(i)); return(table3(i));
} }
int table2() { static int table2(void) {
register i; int i;
i = get8(); i = get8();
if (i < sp_fcst0+sp_ncst0 && i >= sp_fcst0) { if (i < sp_fcst0+sp_ncst0 && i >= sp_fcst0) {
@ -482,7 +481,7 @@ int table2() {
return(table3(i)); return(table3(i));
} }
int table3(i) { static int table3(int i) {
word consiz; word consiz;
switch(i) { switch(i) {
@ -525,8 +524,8 @@ int table3(i) {
return(i); return(i);
} }
int get16() { static int get16(void) {
register int l_byte, h_byte; int l_byte, h_byte;
l_byte = get8(); l_byte = get8();
h_byte = get8(); h_byte = get8();
@ -534,9 +533,9 @@ int get16() {
return l_byte | (h_byte*256) ; return l_byte | (h_byte*256) ;
} }
long get32() { static long get32(void) {
register long l; long l;
register int h_byte; int h_byte;
l = get8(); l = get8();
l |= ((unsigned) get8())*256 ; l |= ((unsigned) get8())*256 ;
@ -546,9 +545,9 @@ long get32() {
return l | (h_byte*256L*256*256L) ; return l | (h_byte*256L*256*256L) ;
} }
getstring() { static void getstring(void) {
register char *p; char *p;
register n; int n;
getarg(cst_ptyp); getarg(cst_ptyp);
if (argval < 0) if (argval < 0)
@ -565,8 +564,8 @@ getstring() {
*p++ = '\0'; *p++ = '\0';
} }
char *strarg(t) { static string strarg(int t) {
register char *p; char *p;
switch (t) { switch (t) {
case sp_ilb1: case sp_ilb1:
@ -613,9 +612,8 @@ char *strarg(t) {
return(mystrcpy(argstr)); return(mystrcpy(argstr));
} }
void static void bss(full n, int t, int b) {
bss(n,t,b) full n; { long s = 0;
register long s = 0;
if (n % TEM_WSIZE) if (n % TEM_WSIZE)
fatal("bad BSS size"); fatal("bad BSS size");
@ -637,8 +635,8 @@ bss(n,t,b) full n; {
fatal("bad BSS initializer"); fatal("bad BSS initializer");
} }
long con(t) { static long con(int t) {
register i; int i;
strarg(t); strarg(t);
switch (t) { switch (t) {
@ -686,8 +684,7 @@ swtxt() {
switchseg(SEGTXT); switchseg(SEGTXT);
} }
void static void switchseg(int s) {
switchseg(s) {
if (s == curseg) if (s == curseg)
return; return;
@ -696,8 +693,7 @@ switchseg(s) {
fprintf(codefile,"%s\n",segname[s]); fprintf(codefile,"%s\n",segname[s]);
} }
void static void savelab(void) {
savelab() {
register char *p,*q; register char *p,*q;
part_flush(); part_flush();
@ -711,8 +707,7 @@ savelab() {
; ;
} }
void static void dumplab(void) {
dumplab() {
if (labstr[0] == 0) if (labstr[0] == 0)
return; return;
@ -721,8 +716,7 @@ dumplab() {
labstr[0] = 0; labstr[0] = 0;
} }
void static void xdumplab(void) {
xdumplab() {
if (labstr[0] == 0) if (labstr[0] == 0)
return; return;
@ -730,8 +724,7 @@ xdumplab() {
newdlb(labstr); newdlb(labstr);
} }
void static void part_flush(void) {
part_flush() {
/* /*
* Each new data fragment and each data label starts at * Each new data fragment and each data label starts at
@ -744,7 +737,7 @@ part_flush() {
part_word = 0; part_word = 0;
} }
string holstr(n) word n; { static string holstr(word n) {
sprintf(str,hol_off,n,holno); sprintf(str,hol_off,n,holno);
return(mystrcpy(str)); return(mystrcpy(str));

View file

@ -22,10 +22,7 @@ static char rcsid[] = "$Id$";
* Author: Hans van Staveren * Author: Hans van Staveren
*/ */
string mystrcpy();
FILE *codefile; FILE *codefile;
extern FILE *freopen();
out_init(filename) char *filename; { out_init(filename) char *filename; {

View file

@ -16,9 +16,7 @@ static char rcsid[] = "$Id$";
* Author: Hans van Staveren * Author: Hans van Staveren
*/ */
extern string myalloc(); static glosym_p glolist= (glosym_p) 0;
glosym_p glolist= (glosym_p) 0;
enterglo(name,romp) string name; word *romp; { enterglo(name,romp) string name; word *romp; {
register glosym_p gp; register glosym_p gp;

View file

@ -5,7 +5,6 @@
#include "label.h" #include "label.h"
static label_p label_list = (label_p)0; static label_p label_list = (label_p)0;
extern char *myalloc();
void void
add_label(num, height, flth) add_label(num, height, flth)

View file

@ -22,6 +22,10 @@ int Debug=0;
char *strtdebug=""; char *strtdebug="";
#endif #endif
/* fillem.c */
void in_init(char *);
void in_start(void);
main(argc,argv) char **argv; { main(argc,argv) char **argv; {
register unsigned n; register unsigned n;
extern unsigned cc1,cc2,cc3,cc4; extern unsigned cc1,cc2,cc3,cc4;

View file

@ -27,6 +27,9 @@ static char rcsid[] = "$Id$";
extern char em_mnem[][4]; extern char em_mnem[][4];
#endif #endif
/* fillem.c */
void fillemlines(void);
byte *trypat(bp,len) register byte *bp; { byte *trypat(bp,len) register byte *bp; {
register patlen,i; register patlen,i;
result_t result; result_t result;

View file

@ -24,8 +24,7 @@ static char rcsid[] = "$Id$";
* *
* Author: Hans van Staveren * Author: Hans van Staveren
*/ */
extern string myalloc(); static struct regvar *rvlist;
struct regvar *rvlist;
struct regvar * struct regvar *
linkreg(long of, int sz, int tp, int sc) { linkreg(long of, int sz, int tp, int sc) {

View file

@ -18,7 +18,6 @@ struct regassigned {
int ra_score; int ra_score;
}; };
extern struct regvar *rvlist;
extern int nregvar[]; extern int nregvar[];
extern struct regassigned *regassigned[]; extern struct regassigned *regassigned[];

View file

@ -32,7 +32,7 @@ static char rcsid[] = "$Id$";
char *stab[MAXSTAB]; char *stab[MAXSTAB];
int nstab=0; int nstab=0;
void chkstr(); static void chkstr(string, char *);
string myalloc(size) { string myalloc(size) {
register string p; register string p;
@ -43,21 +43,21 @@ string myalloc(size) {
return(p); return(p);
} }
myfree(p) string p; { void myfree(string p) {
free(p); free(p);
} }
popstr(nnstab) { void popstr(int nnstab) {
register i; int i;
for (i=nnstab;i<nstab;i++) for (i=nnstab;i<nstab;i++)
myfree(stab[i]); myfree(stab[i]);
nstab = nnstab; nstab = nnstab;
} }
char *salloc(size) { char *salloc(int size) {
register char *p; char *p;
if (nstab==MAXSTAB) if (nstab==MAXSTAB)
fatal("String table overflow"); fatal("String table overflow");
@ -66,7 +66,7 @@ char *salloc(size) {
return(p); return(p);
} }
compar(p1,p2) char **p1,**p2; { static int compar(char **p1, char **p2) {
assert(*p1 != *p2); assert(*p1 != *p2);
if (*p1 < *p2) if (*p1 < *p2)
@ -74,14 +74,13 @@ compar(p1,p2) char **p1,**p2; {
return(1); return(1);
} }
void void garbage_collect(void) {
garbage_collect() { int i;
register i;
struct emline *emlp; struct emline *emlp;
token_p tp; token_p tp;
tkdef_p tdp; tkdef_p tdp;
struct reginfo *rp; struct reginfo *rp;
register char **fillp,**scanp; char **fillp,**scanp;
char used[MAXSTAB]; /* could be bitarray */ char used[MAXSTAB]; /* could be bitarray */
if (nstab<THRESHOLD) if (nstab<THRESHOLD)
@ -119,9 +118,9 @@ garbage_collect() {
nstab = fillp-stab; nstab = fillp-stab;
} }
void static void
chkstr(str,used) string str; char used[]; { chkstr(string str, char *used) {
register low,middle,high; int low,middle,high;
low=0; high=nstab-1; low=0; high=nstab-1;
while (high>low) { while (high>low) {

View file

@ -24,7 +24,6 @@ static char rcsid[] = "$Id$";
* Author: Hans van Staveren * Author: Hans van Staveren
*/ */
string myalloc();
unsigned codegen(); unsigned codegen();
match(tp,tep,optexp) register token_p tp; register set_p tep; { match(tp,tep,optexp) register token_p tp; register set_p tep; {

View file

@ -28,3 +28,13 @@ typedef char * string;
#ifndef WRD_FMT #ifndef WRD_FMT
#define WRD_FMT "%ld" #define WRD_FMT "%ld"
#endif /* WRD_FMT */ #endif /* WRD_FMT */
/* compute.c */
string mystrcpy(string);
string tostring(word);
/* salloc.c */
string myalloc(int);
void myfree(string);
void popstr(int);
char *salloc(int);
void garbage_collect(void);