/* $Id$ */
-static arg();
-static pseudo();
+static void arg(struct e_instr *p, int comma);
+static void pseudo(struct e_instr *p);
extern char em_flag[];
char *C_error;
#define flags(pp) (em_flag[(pp)->em_opcode - sp_fmnem] & EM_PAR)
-struct e_instr *
-C_alloc()
+struct e_instr * C_alloc()
{
static struct e_instr b;
return &b;
}
-int
-C_out(p)
- register struct e_instr *p;
+int C_out(struct e_instr *p)
{
/* Generate EM-code from the e_instr structure "p"
*/
return 1;
}
-static
-arg(p, comma)
- register struct e_instr *p;
+static void arg(struct e_instr *p, int comma)
{
/* Output the argument of "p".
*/
}
}
-static
-pseudo(p)
- register struct e_instr *p;
+static void pseudo(struct e_instr *p)
{
PS(p->em_opcode);
int C_ontmpfile = 0;
int C_sequential = 1;
-Part *C_curr_part;
-int (*C_outpart)(), (*C_swtout)(), (*C_swttmp)();
+Part *C_curr_part;
+void (*C_outpart)(int), (*C_swtout)(void), (*C_swttmp)(void);
#ifdef INCORE
char *C_BASE;
char *C_opp = obuf;
#endif
-void
-C_flush() {
+void C_flush()
+{
#ifdef INCORE
static unsigned int bufsiz;
#define Xputbyte(c) put(c)
#endif
-void
-C_putbyte(c)
- int c;
+void C_putbyte(int c)
{
Xputbyte(c);
}
#endif
/*ARGSUSED*/
-void
-C_init(w, p)
- arith w, p;
+void C_init(arith w, arith p)
{
}
-int
-C_open(nm)
- char *nm;
+int C_open(char *nm)
{
/* Open file "nm" for output
*/
return 1;
}
-void
-C_close()
+void C_close()
{
/* Finish the code-generation.
*/
C_ofp = 0;
}
-int
-C_busy()
+int C_busy()
{
return C_ofp != 0; /* true if code is being generated */
}
names.
*/
-void
-C_magic()
+void C_magic()
{
}
/*** the readable code generating routines ***/
-static
-wrs(s)
- register char *s;
+static void wrs(char *s)
{
while (*s) {
C_putbyte(*s++);
}
}
-void
-C_pt_dnam(s)
- char *s;
+void C_pt_dnam(char *s)
{
wrs(s);
}
-void
-C_pt_ilb(l)
- label l;
+void C_pt_ilb(label l)
{
char buf[16];
extern char em_mnem[][4];
extern char em_pseu[][4];
-void
-C_pt_op(x)
+void C_pt_op(int x)
{
C_putbyte(' ');
wrs(em_mnem[x - sp_fmnem]);
C_putbyte(' ');
}
-void
-C_pt_cst(l)
- arith l;
+void C_pt_cst(arith l)
{
char buf[16];
wrs(buf);
}
-void
-C_pt_scon(x, y)
- char *x;
- arith y;
+void C_pt_scon(char *x, arith y)
{
char xbuf[1024];
register char *p;
C_putbyte('\'');
}
-void
-C_pt_ps(x)
+void C_pt_ps(int x)
{
C_putbyte(' ');
wrs(em_pseu[x - sp_fpseu]);
C_putbyte(' ');
}
-void
-C_pt_dlb(l)
- label l;
+void C_pt_dlb(label l)
{
char buf[16];
wrs(buf);
}
-void
-C_pt_doff(l, v)
- label l;
- arith v;
+void C_pt_doff(label l, arith v)
{
char buf[16];
}
}
-void
-C_pt_noff(s, v)
- char *s;
- arith v;
+void C_pt_noff(char *s, arith v)
{
char buf[16];
}
}
-void
-C_pt_pnam(s)
- char *s;
+void C_pt_pnam(char *s)
{
C_putbyte('$');
wrs(s);
}
-void
-C_pt_dfilb(l)
- label l;
+void C_pt_dfilb(label l)
{
char buf[16];
wrs(buf);
}
-void
-C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
- int sp;
- char *v;
- arith sz;
+void C_pt_wcon(int sp, char *v, arith sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
{
int ch = sp == sp_icon ? 'I' : sp == sp_ucon ? 'U' : 'F';
C_pt_cst(sz);
}
-void
-C_pt_nl() {
+void C_pt_nl()
+{
C_putbyte('\n');
}
-void
-C_pt_comma() {
+void C_pt_comma()
+{
C_putbyte(',');
}
-void
-C_pt_ccend() {
+void C_pt_ccend()
+{
C_putbyte('?');
}
names.
*/
-void
-C_magic()
+void C_magic()
{
put16(sp_magic);
}
#define fit16i(x) ((x) >= (long)(-0x8000) && (x) <= (long)0x7FFF)
#define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */
-void
-C_pt_ilb(l)
- register label l;
+void C_pt_ilb(label l)
{
if (fit8u(l)) {
put8(sp_ilb1);
}
}
-void
-C_pt_dlb(l)
- register label l;
+void C_pt_dlb(label l)
{
if (fit8u(l)) {
put8(sp_dlb1);
}
}
-void
-C_pt_cst(l)
- register arith l;
+void C_pt_cst(arith l)
{
if (l >= (arith) -sp_zcst0 && l < (arith) (sp_ncst0 - sp_zcst0)) {
/* we can convert 'l' to an int because its value
}
}
-void
-C_pt_doff(l, v)
- label l;
- arith v;
+void C_pt_doff(label l, arith v)
{
if (v == 0) {
C_pt_dlb(l);
}
}
-void
-C_pt_str(s)
- register char *s;
+void C_pt_str(char *s)
{
register int len;
}
}
-void
-C_pt_dnam(s)
- char *s;
+void C_pt_dnam(char *s)
{
put8(sp_dnam);
C_pt_str(s);
}
-void
-C_pt_noff(s, v)
- char *s;
- arith v;
+void C_pt_noff(char *s, arith v)
{
if (v == 0) {
C_pt_dnam(s);
}
}
-void
-C_pt_pnam(s)
- char *s;
+void C_pt_pnam(char *s)
{
put8(sp_pnam);
C_pt_str(s);
}
-void
-C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
- int sp;
- char *v;
- arith sz;
+void C_pt_wcon(int sp, char *v, arith sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
{
/* how 'bout signextension int --> long ??? */
put8(sp);
C_pt_str(v);
}
-void
-C_pt_scon(b, n)
- register char *b;
- register arith n;
+void C_pt_scon(char *b, arith n)
{
put8(sp_scon);
C_pt_cst(n);
#define BIGSZ (sizeof(big_10pow)/sizeof(big_10pow[0]))
#define SMALLSZ (sizeof(s10pow)/sizeof(s10pow[0]))
-static
-add_exponent(e, exp)
- register flt_arith *e;
+static void add_exponent(flt_arith *e, int exp)
{
int neg = exp < 0;
int divsz, modsz;
flt_status = status;
}
-void
-flt_str2flt(s, e)
- register char *s;
- register flt_arith *e;
+void flt_str2flt(char *s, flt_arith *e)
{
register int c;
int dotseen = 0;
#define NDIG 18
-static char *
-flt_ecvt(e, decpt, sign)
- register flt_arith *e;
- int *decpt, *sign;
+static char *flt_ecvt(flt_arith *e, int *decpt, int *sign)
{
/* Like ecvt(), but for extended precision */
return buf;
}
-void
-flt_flt2str(e, buf, bufsize)
- flt_arith *e;
- char *buf;
+void flt_flt2str(flt_arith *e, char *buf, int bufsize)
{
-
int sign, dp;
register int i;
register char *s1;
#include <system.h>
#include "print.h"
-extern char *long2str();
-
-static int
-integral(c)
+static int integral(int c)
{
switch (c) {
case 'b':
%[uxbo] = unsigned int
%d = int
$ */
-int
-_format(buf, fmt, argp)
- char *buf, *fmt;
- register va_list argp;
+int _format(char *buf, char *fmt, va_list argp)
{
register char *pf = fmt;
register char *pb = buf;
else
if (*pf == 'l') {
/* alignment ??? */
- if (base = integral(*++pf)) {
+ if ((base = integral(*++pf))) {
arg = long2str(va_arg(argp,long), base);
}
else {
}
}
else
- if (base = integral(*pf)) {
+ if ((base = integral(*pf))) {
arg = long2str((long)va_arg(argp,int), base);
}
else
while (npad-- > 0)
*pb++ = pad;
- while (*pb++ = *arg++);
+ while (((*pb++) = (*arg++)));
pb--;
pf++;
}
_PROTOTYPE(int _format, (char *buf, char *fmt, va_list ap));
_PROTOTYPE(char *sprint, (char *buf, char *fmt, ...));
+char *long2str(long val, int base);
+
#endif /* __PRINT_INCLUDED__ */
The argument must be of a type allowed by "typset".
Return a pointer to the next argument.
*/
-PRIVATE int
-checkarg(arg, typset)
- register struct e_arg *arg;
+PRIVATE int checkarg(struct e_arg *arg, int typset)
{
if (((!typset) && arg->ema_argtype) ||
return 1;
}
#else /* not CHECKING */
-#define checkarg(arg, x) 1
+PRIVATE int checkarg(struct e_arg *arg, int typset)
+{
+ return 1;
+}
+//#define checkarg(arg, x) (1)
#endif /* CHECKING */
/* EM_doinstr: An EM instruction
*/
-PRIVATE void
-EM_doinstr(p)
- register struct e_instr *p;
+PRIVATE void EM_doinstr(struct e_instr *p)
{
register int parametertype; /* parametertype of the instruction */
#include "C_mnem.h"
}
-PRIVATE void
-EM_dopseudo(p)
- register struct e_instr *p;
+PRIVATE void EM_dopseudo(struct e_instr *p)
{
-
switch(p->em_opcode) {
case ps_exc: {
C_exc(p->em_exc1, p->em_exc2);
}
}
-PRIVATE void
-EM_docon(p)
- register struct e_instr *p;
+PRIVATE void EM_docon(struct e_instr *p)
{
checkarg(&(p->em_arg), val_ptyp);
switch(p->em_argtype) {
}
}
-PRIVATE void
-EM_dostartmes(p)
- register struct e_instr *p;
+PRIVATE void EM_dostartmes(struct e_instr *p)
{
if (listtype) {
listtype = ps_mes;
}
-EXPORT int
-EM_mkcalls(line)
- register struct e_instr *line;
+EXPORT int EM_mkcalls(struct e_instr *line)
{
#ifdef CHECKING
#include <ctype.h>
#include <string.h>
-/* #define XXX_YYY /* only for early debugging */
+/* only for early debugging */
+/* #define XXX_YYY */
#ifdef XXX_YYY
#define out(str) (sys_write(STDOUT, str, strlen(str)))
/* inithash, pre_hash, hash: Simple hashtable mechanism
*/
-PRIVATE int
-hash(s)
- register char *s;
+PRIVATE int hash(char *s)
{
register int h = 0;
return h;
}
-PRIVATE void
-pre_hash(i, s)
- char *s;
+PRIVATE void pre_hash(int i, char *s)
{
register int h;
extern char em_mnem[][4];
extern char em_pseu[][4];
-PRIVATE void
-inithash()
+PRIVATE void inithash()
{
register int i;
/* nospace: skip until we find a non-space character. Also skip
comments.
*/
-PRIVATE int
-nospace()
+PRIVATE int nospace()
{
register int c;
/* syntax: Put an error message in EM_error and skip to the end of the line
*/
-PRIVATE void
-syntax(s)
- char *s;
+PRIVATE void syntax(char *s)
{
register int c;
/* checkeol: check that we have a complete line (except maybe for spaces)
*/
-PRIVATE void
-checkeol()
+PRIVATE void checkeol()
{
if (nospace() != '\n') {
/* getescape: read a '\' escape sequence
*/
-PRIVATE int
-getescape()
+PRIVATE int getescape()
{
register int c, j, r;
/* getname: Read a string of characters representing an identifier
*/
-PRIVATE struct string *
-getname()
+PRIVATE struct string * getname()
{
register char *p;
register struct string *s;
/* getstring: read a string of characters between quotes
*/
-PRIVATE struct string *
-getstring()
+PRIVATE struct string *getstring()
{
register char *p;
struct string *s;
return s;
}
-PRIVATE void gettyp();
+PRIVATE void gettyp(int typset, struct e_arg *ap);
-PRIVATE int
-offsetted(argtyp, ap)
- arith *ap;
+PRIVATE int offsetted(int argtyp, arith *ap)
{
register int c;
return argtyp;
}
-PRIVATE int
-getnumber(c, ap)
- register int c;
- register struct e_arg *ap;
+PRIVATE int getnumber(int c, struct e_arg *ap)
{
char str[256 + 1];
register char *p = str;
return sp_cst4;
}
-PRIVATE int getexpr();
+PRIVATE int getexpr(int c, struct e_arg *ap);
-PRIVATE int
-getfactor(c, ap)
- register int c;
- register struct e_arg *ap;
+PRIVATE int getfactor(int c, struct e_arg *ap)
{
if (c == '(') {
if (getexpr(nospace(), ap) != sp_cst4) {
return getnumber(c, ap);
}
-PRIVATE int
-getterm(c, ap)
- register int c;
- register struct e_arg *ap;
+PRIVATE int getterm(int c, struct e_arg *ap)
{
arith left;
return sp_cst4;
}
-PRIVATE int
-getexpr(c, ap)
- register int c;
- register struct e_arg *ap;
+PRIVATE int getexpr(int c, struct e_arg *ap)
{
arith left;
return sp_cst4;
}
-PRIVATE int
-get15u()
+PRIVATE int get15u()
{
struct e_arg dummy;
return (int) (dummy.ema_cst);
}
-PRIVATE void
-gettyp(typset, ap)
- register struct e_arg *ap;
+PRIVATE void gettyp(int typset, struct e_arg *ap)
{
register int c, t;
register int argtyp;
out("string\n");
ungetbyte(c);
- s = getstring(0);
+ s = getstring();
ap->ema_string = s->str;
ap->ema_szoroff = s->length;
ap->ema_argtype = str_ptyp;
}
}
-PRIVATE void
-getarg(typset, ap)
- struct e_arg *ap;
+PRIVATE void getarg(int typset, struct e_arg *ap)
{
register int c;
/* getmnem: We found the start of either an instruction or a pseudo.
get the rest of it
*/
-PRIVATE void
-getmnem(c, p)
- register struct e_instr *p;
+PRIVATE void getmnem(int c, struct e_instr *p)
{
register int h;
int i;
}
}
-PRIVATE void
-line_line()
+PRIVATE void line_line()
{
static char filebuf[256 + 1];
char *btscpy();
EM_filename = filebuf;
}
-PRIVATE void
-getlabel(c, p)
- register struct e_instr *p;
+PRIVATE void getlabel(int c, struct e_instr *p)
{
-
ungetbyte(c);
gettyp(lab_ptyp|ptyp(sp_cst2), &(p->em_arg));
switch(p->em_argtype) {
checkeol();
}
-PRIVATE void
-gethead(p)
- register struct e_instr *p;
+PRIVATE void gethead(struct e_instr *p)
{
register int c;
#define MAXWIDTH 32
-char *
-long2str(val, base)
- register long val;
- register base;
+char *long2str(long val, int base)
{
static char numbuf[MAXWIDTH];
static char vec[] = "0123456789ABCDEF";
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
+#ifndef UTILS_ACK_ACK_H
+#define UTILS_ACK_ACK_H
+
+#include "trans.h"
+#include "grows.h"
+
#ifndef NORCSID
#define RCS_ACK "$Id$"
#endif
/* Intended for flags, possibly in bit fields */
-#define YES 1
-#define NO 0
-#define MAYBE 2
+#define YES (1)
+#define NO (0)
+#define MAYBE (2)
#define EXTERN extern
enum f_path { F_OK, F_NOMATCH, F_NOPATH } ;
/* Own routines */
-enum f_path getpath();
-enum f_path scan_end();
-extern void noodstop();
-extern char *getvar();
-extern char *keeps();
-extern char *basename();
-extern char *skipblank();
-extern char *firstblank();
-extern char *getcore();
-extern char *changecore();
+enum f_path getpath(trf **first);
+enum f_path scan_end(trf **first);
+void noodstop();
+char *getvar(char *name);
+char *keeps(char *str);
+char *basename(char *string);
+char *skipblank(char *str);
+char *firstblank(char *str);
+char *getcore(unsigned size);
+char *changecore(char *ptr, unsigned int size);
#define freecore(area) free(area)
+growstring scanb(char *line);
+growstring scanvars(char *line);
#define DEBUG 1 /* Allow debugging of Ack */
#else
extern int debug ;
#endif
+
+#endif /* UTILS_ACK_ACK_H */
\ No newline at end of file
*
*/
+#include <string.h>
+
#include "ack.h"
#include "list.h"
#include "trans.h"
static char rcs_id[] = "$Id$" ;
#endif
-char *add_u(part,ptr) char *ptr ; {
+void file_final(path *file);
+void disc_inputs(trf *phase);
+
+char *add_u(int part, char *ptr)
+{
if ( part>=26 ) {
ptr=add_u(part/26-1,ptr) ;
}
return ptr+1 ;
}
-char *unique() {
+char *unique()
+{
/* Get the next unique part of the internal filename */
static int u_next = 0 ;
static char buf[10] ;
return buf ;
}
-setfiles(phase) register trf *phase ; {
+int setfiles(trf *phase)
+{
/* Set the out structure according to the in structure,
the transformation and some global data */
growstring pathname ;
return 1 ;
}
-disc_files(phase) trf *phase ; {
+void disc_files(trf *phase)
+{
path temp ;
if ( !phase->t_combine ) {
temp=in ; in=out ; out=temp ;
}
-file_final(file) path *file ; {
+void file_final(path *file)
+{
if ( file->p_path ) {
if ( !file->p_keep && t_flag<=1 ) {
if ( unlink(file->p_path)!=0 ) {
file->p_keep=NO ;
}
-disc_inputs(phase) trf *phase ; {
+void disc_inputs(trf *phase)
+{
/* Remove all the input files of this phase */
/* Only for combiners */
register path *l_in ;
l_clear(&phase->t_inputs) ;
}
-rmfile(file) path *file ; {
+void rmfile(path *file)
+{
/* Remove a file, do not complain when is does not exist */
if ( file->p_path ) {
if ( t_flag<=1 ) unlink(file->p_path) ;
}
}
-rmtemps() {
+void rmtemps()
+{
/* Called in case of disaster, always remove the current output file!
*/
register list_elem *elem ;
}
}
-add_input(file,phase) path *file ; trf *phase ; {
+void add_input(path *file, trf *phase)
+{
register path *store ;
#ifdef DEBUG
if ( debug ) {
static char rcs_grows[] = RCS_GROWS ;
#endif
-gr_add(id,c) register growstring *id ; char c ; {
+void gr_add(growstring *id, char c)
+{
if ( id->gr_size==id->gr_max) {
if ( id->gr_size==0 ) { /* The first time */
id->gr_max= 2*GR_MORE ;
*(id->gr_string+id->gr_size++)= c ;
}
-gr_cat(id,string) growstring *id ; char *string ; {
+void gr_cat(growstring *id, char *string)
+{
register char *ptr ;
#ifdef DEBUG
}
}
-gr_throw(id) register growstring *id ; {
+void gr_throw(growstring *id)
+{
/* Throw the string away */
if ( id->gr_max==0 ) return ;
freecore(id->gr_string) ;
id->gr_size=0 ;
}
-gr_init(id) growstring *id ; {
+void gr_init(growstring *id)
+{
id->gr_size=0 ; id->gr_max=0 ;
}
-char *gr_final(id) growstring *id ; {
+char *gr_final(growstring *id)
+{
/* Throw away the bookkeeping, adjust the string to its final
length and return a pointer to a string to be get rid of with
throws
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
+#ifndef UTILS_ACK_GROWS_H
+#define UTILS_ACK_GROWS_H
+
#ifndef NORCSID
#define RCS_GROWS "$Id$"
#endif
/* Routines used */
-extern int gr_throw() ; /* To free the core */
-extern int gr_add() ; /* To add one character */
-extern int gr_cat() ; /* concatenate the contents and the string */
-extern int gr_init() ; /* Initialize the bookkeeping */
-extern char *gr_final() ; /* Transform to a stable storage string */
+void gr_throw(growstring *id); /* To free the core */
+void gr_add(growstring *id, char c); /* To add one character */
+void gr_cat(growstring *id, char *string); /* concatenate the contents and the string */
+void gr_init(growstring *id); /* Initialize the bookkeeping */
+char *gr_final(growstring *id); /* Transform to a stable storage string */
+
+#endif /* UTILS_ACK_GROWS_H */
\ No newline at end of file
*/
-l_add(header,string) list_head *header ; char *string ; {
+void l_add(list_head *header, char *string)
+{
register list_elem *new;
/* NOSTRICT */
header->ca_last= new ;
}
-l_clear(header) list_head *header ; {
+void l_clear(list_head *header)
+{
register list_elem *old, *next;
for ( old=header->ca_first ; old ; old= next ) {
next= old->ca_next ;
header->ca_last = (list_elem *) 0 ;
}
-l_throw(header) list_head *header ; {
+void l_throw(list_head *header)
+{
register list_elem *old, *next;
for ( old=header->ca_first ; old ; old= next ) {
throws(l_content(*old)) ;
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
+#ifndef UTILS_ACK_LIST_H
+#define UTILS_ACK_LIST_H
+
#ifndef NORCSID
#define RCS_LIST "$Id$"
#endif
/* To be used for scanning lists, ptr is the running variable */
#define scanlist(elem,ptr) \
for ( ptr= elem ; ptr; ptr= l_next(*ptr) )
+
+
+#endif /* UTILS_ACK_LIST_H */
\ No newline at end of file
static int sigs[] = { SIGINT, SIGHUP, SIGTERM, 0 } ;
static int arg_count;
-extern char *getenv();
-
-main(argc,argv) char **argv ; {
+void varinit();
+void vieuwargs(int argc, char *argv[]);
+void firstarg(char *argp);
+void block(trf *first);
+void keephead(char *suffix);
+void keeptail(char *suffix);
+void scanneeds();
+void setneeds(char *suffix, int tail);
+
+
+int main(int argc, char *argv[])
+{
register list_elem *elem ;
register char *frontend ;
register int *n_sig ;
exit(0) ;
}
-char *srcvar() {
+char *srcvar()
+{
return orig.p_path ;
}
-char *getsuffix() {
+char *getsuffix()
+{
return strrchr(orig.p_path, SUFCHAR) ;
}
-varinit() {
+void varinit()
+{
/* initialize the string variables */
register char *envstr ;
extern char *em_dir;
- if ( envstr=getenv("ACKDIR") ) {
+ if ( (envstr=getenv("ACKDIR")) ) {
em_dir = keeps(envstr);
}
setsvar(keeps(HOME),em_dir) ;
/************************* flag processing ***********************/
-vieuwargs(argc,argv) char **argv ; {
+void vieuwargs(int argc, char *argv[])
+{
register char *argp;
register int nextarg ;
register int eaten ;
return ;
}
-firstarg(argp) register char *argp ; {
+void firstarg(char *argp)
+{
register char *name ;
name=strrchr(argp,'/') ;
/************************* argument processing ***********************/
-process(arg) char *arg ; {
+int process(char *arg)
+{
/* Process files & library arguments */
trf *phase ;
register trf *tmp ;
return startrf(phase) ;
}
-int startrf(first) trf *first ; {
+int startrf(trf *first)
+{
/* Start the transformations at the indicated phase */
register trf *phase ;
return 1 ;
}
-block(first) trf *first ; {
+void block(trf *first)
+{
/* One of the input files of this phase could not be produced,
block all combiners taking their input from this one.
*/
if ( phase->t_combine ) phase->t_blocked=YES ;
}
}
-mayprep() {
+
+int mayprep()
+{
int file ;
char fc ;
file=open(in.p_path,0);
return fc=='#' ;
}
-keephead(suffix) char *suffix ; {
+void keephead(char *suffix)
+{
l_add(&head_list, suffix) ;
}
-keeptail(suffix) char *suffix ; {
+void keeptail(char *suffix)
+{
l_add(&tail_list, suffix) ;
}
-scanneeds() {
+void scanneeds()
+{
register list_elem *elem ;
scanlist(l_first(head_list), elem) { setneeds(l_content(*elem),0) ; }
l_clear(&head_list) ;
l_clear(&tail_list) ;
}
-setneeds(suffix,tail) char *suffix ; {
+void setneeds(char *suffix, int tail)
+{
trf *phase ;
p_suffix= suffix ;
int offset ;
-main(argc,argv) char **argv ; {
- register i ;
+void start(char *dir);
+void stop(int filled);
+void readm();
+
+int main(int argc, char *argv[])
+{
+ int i ;
start(argv[1]) ;
for ( i=2 ; i<argc ; i++ ) {
return 0 ;
}
-start(dir) char *dir ; {
+void start(char *dir)
+{
tail= dname ;
while ( *dir ) {
*tail++ = *dir ++ ;
fprintf(intab,"char intable[] = {\n") ;
}
-stop(filled) {
+void stop(int filled)
+{
fprintf(dmach,"\t{\"\",\t-1\t}\n} ;\n") ;
if ( !filled ) fprintf(intab,"\t0\n") ;
fprintf(intab,"\n} ;\n") ;
fclose(dmach); fclose(intab) ;
}
-FILE *do_open(file) char *file ; {
+FILE *do_open(char *file)
+{
FILE *fd;
strcpy(tail,file) ;
return fopen(dname,"r");
}
-readm() {
+void readm()
+{
register int i ;
register int token ;
register FILE *in ;
fprintf(stderr,"warning: non-ascii in %s\n",fname) ;
fprintf(intab,"%4d,",token) ;
} else {
- fprintf(intab," 0,",token) ;
+ fprintf(intab," 0,");
break ;
}
} else if ( isprint(token) ) {
*
*/
+#include <string.h>
+
#include "ack.h"
#include <em_path.h>
#include "list.h"
#define CALL "callname"
#define END "end"
-extern growstring scanb();
-extern growstring scanvars();
-
-int getln() ;
-int getinchar() ;
static char *ty_name ;
static char *bol ;
-
-
static char *inname ;
-setlist(name) char *name ; {
+void intrf();
+void open_in(char *name);
+void close_in();
+
+void setlist(char *name)
+{
/* Name is sought in the internal tables,
if not present, the a file of that name is sought
in first the current and then the EM Lib directory
#endif
}
-static int inoptlist(nm)
- char *nm ;
+static int inoptlist(char *nm)
{
register char *p=Optlist ;
return 0;
}
-intrf() {
+void intrf()
+{
register trf *new ;
growstring bline ;
int twice ;
} else
if ( strcmp(ty_name,PROG)==0 ) {
if ( new->t_prog ) twice=YES ;
- bline= scanb(bol); /* Scan for \ */
- new->t_prog= gr_final(&bline);
+ bline= scanb(bol); /* Scan for \ */
+ new->t_prog= gr_final(&bline);
} else
if ( strcmp(ty_name,MAPF)==0 ) {
/* First read the mapflags line
static char *inptr ;
char *em_dir = EM_DIR;
-open_in(name) register char *name ; {
+void open_in(char *name)
+{
register dmach *cmac ;
gr_init(&rline) ;
}
}
-close_in() {
+void close_in()
+{
if ( !incore ) fclose(infile) ;
gr_throw(&rline) ;
}
-char *readline() {
+char *readline()
+{
/* Get a line from the input,
return 0 if at end,
The line is stored in a volatile buffer,
}
}
-int getinchar() {
- register int token ;
+int getinchar()
+{
+ int token ;
if ( incore ) {
if ( *inptr==0 ) return EOF ;
return token ;
}
-int getln() {
- register char *c_ptr ;
+int getln()
+{
+ char *c_ptr ;
do {
if ( (c_ptr=readline())==(char *)0 ) return 0 ;
#define ARG_MORE 40 /* The size of args chunks to allocate */
-extern growstring scanvars();
-
static char **arglist ; /* The first argument */
static unsigned argcount ; /* The current number of arguments */
static unsigned argmax; /* The maximum number of arguments so far */
-int runphase(phase) register trf *phase ; {
+void x_arg(char *string);
+
+int runphase(trf *phase)
+{
register list_elem *elem ;
char *prog ; int result ;
growstring bline ;
return result ;
}
-int run_exec(phase,prog) trf *phase ; char *prog ; {
+int run_exec(trf *phase, char *prog)
+{
int status, child, waitchild ;
do_flush();
/*NOTREACHED*/
}
-x_arg(string) char *string ; {
+void x_arg(char *string)
+{
/* Add one execute argument to the argument vector */
if ( argcount==argmax ) {
if ( argmax==0 ) {
#include <string.h>
#include "ack.h"
#include "list.h"
-#include "trans.h"
#include "data.h"
#ifndef NORCSID
static char rcs_id[] = "$Id$" ;
#endif
-enum f_path getpath(first) register trf **first ; {
+void start_scan();
+void scan_found();
+void find_cpp();
+void try(list_elem *f_scan, char *suffix);
+
+enum f_path getpath(trf **first)
+{
/* Try to find a transformation path */
start_scan();
/******************** The hard work ********************/
-start_scan() {
+void start_scan()
+{
register list_elem *scan ;
scanlist(l_first(tr_list),scan) {
last_ocount= 0 ;
}
-try(f_scan,suffix) list_elem *f_scan; char *suffix; {
+void try(list_elem *f_scan, char *suffix)
+{
register list_elem *scan ;
register trf *trafo ;
/* Try to find a transformation path starting at f_scan for a
*/
register trf *sneak ;
sneak= trafo ;
- while( sneak=sneak->t_next ) {
+ while( (sneak=sneak->t_next) ) {
sneak->t_scan=YES ;
}
scan_found() ;
sneak= trafo ;
- while( sneak=sneak->t_next ) {
+ while( (sneak=sneak->t_next) ) {
sneak->t_scan=NO ;
}
return ;
}
}
-scan_found() {
+void scan_found()
+{
register list_elem *scan;
int ncount, ocount, pcount ;
}
}
-int satisfy(trafo,suffix) register trf *trafo; char *suffix ; {
+int satisfy(trf *trafo, char *suffix)
+{
register char *f_char, *l_char ;
/* Check whether this transformation is present for
the current machine and the parameter suffix is among
return 0 ;
}
-enum f_path scan_end(first) trf **first ; { /* Finalization */
+enum f_path scan_end(trf **first)
+{ /* Finalization */
/* Return value indicating whether a transformation was found */
/* Set the flags for the transformation up to, but not including,
the combiner
return F_OK ;
}
-find_cpp() {
+void find_cpp()
+{
register list_elem *elem ;
scanlist( l_first(tr_list), elem ) {
if ( t_cont(*elem)->t_isprep ) {
*
*/
+#include <string.h>
#include "ack.h"
#ifndef NORCSID
*/
-extern char *getcore();
-extern fatal();
-
struct vars {
char *v_name;
enum { routine, string } v_type;
static struct vars *v_first ;
-static struct vars *newvar(name) char *name; {
+static struct vars *newvar(char *name)
+{
register struct vars *new ;
for ( new=v_first ; new ; new= new->v_next ) {
return new ;
}
-setsvar(name,str) char *name, *str ; {
+void setsvar(char *name, char *str)
+{
register struct vars *new ;
new= newvar(name);
new->v_value.v_string= str;
}
-setpvar(name,rout) char *name, *(*rout)() ; {
+void setpvar(char *name,char *(*rout)(void))
+{
register struct vars *new ;
new= newvar(name);
new->v_value.v_routine= rout;
}
-char *getvar(name) char *name ; {
+char *getvar(char *name)
+{
register struct vars *scan ;
for ( scan=v_first ; scan ; scan= scan->v_next ) {
static growstring tail ;
static int touch_tail= NO ;
-char *headvar(),*tailvar() ;
+void set_Rflag(char *argp);
+void condit(growstring *line, list_head *fsuff, list_head *lsuff, char *tailval);
+void doassign(char *line, char *star, int length);
+void getcallargs(trf *phase);
+void discardargs(trf *phase);
-int transform(phase) register trf *phase ; {
+int transform(trf *phase)
+{
int ok ;
if ( !setfiles(phase) ) {
return ok ;
}
-getmapflags(phase) register trf *phase ; {
+void getmapflags(trf *phase)
+{
register path *l_in ;
register list_elem *elem ;
int scanned ;
}
-do_Rflag(argp) char *argp ; {
+void do_Rflag(char *argp)
+{
l_add(&R_list,argp) ;
}
-char *headvar() {
+char *headvar()
+{
if ( !touch_head) return "" ;
return gr_start(head) ;
}
-add_head(str) char *str; {
+void add_head(char *str)
+{
if ( !touch_head) {
gr_init(&head) ;
touch_head=YES ;
gr_cat(&head,str) ;
}
-char *tailvar() {
+char *tailvar()
+{
if ( !touch_tail ) return "" ;
return gr_start(tail) ;
}
-add_tail(str) char *str ; {
+void add_tail(char *str)
+{
if ( !touch_tail ) {
gr_init(&tail) ;
touch_tail=YES ;
}
-transini() {
+void transini()
+{
register list_elem *elem ;
register trf *phase ;
setpvar(keeps(TAIL),tailvar) ;
}
-set_Rflag(argp) register char *argp ; {
+void set_Rflag(char *argp)
+{
register char *eos ;
register list_elem *prog ;
register int length ;
/* */
/**************************************************************************/
-growstring scanb(line) char *line ; {
+growstring scanb(char *line)
+{
/* Scan a line for backslashes, setting the NO_SCAN bit in characters
preceded by a backslash.
*/
return result ;
}
-growstring scanvars(line) char *line ; {
+growstring scanvars(char *line)
+{
/* Scan a line variable replacements started by S_VAR.
Two sequences exist: S_VAR name E_VAR, S_VAR name A_VAR text E_VAR.
neither name nor text may contain further replacements.
switch ( token ) {
case A_VAR :
gr_add(&name,0) ;
- if ( tr=getvar(gr_start(name)) ) {
+ if ( (tr=getvar(gr_start(name))) ) {
while ( *tr ) {
gr_add(&result,*tr++) ;
}
break ;
case C_VAR :
gr_add(&name,0) ;
- if ( tr=getvar(gr_start(name)) ) {
+ if ( (tr=getvar(gr_start(name))) ) {
while ( *tr ) {
gr_add(&result,*tr++);
}
return result ;
}
-growstring scanexpr(line) char *line ; {
+growstring scanexpr(char *line)
+{
/* Scan a line for conditional or flag expressions,
dependent on the type. The format is
S_EXPR suflist M_EXPR suflist T_EXPR tail C_EXPR
return result ;
}
-condit(line,fsuff,lsuff,tailval) growstring *line ;
- list_head *fsuff, *lsuff;
- char *tailval ;
+void condit(growstring *line, list_head *fsuff, list_head *lsuff, char *tailval)
{
register list_elem *first ;
register list_elem *last ;
#endif
}
-int mapflag(maplist,cflag) list_head *maplist ; char *cflag ; {
+int mapflag(list_head *maplist, char *cflag)
+{
/* Expand a flag expression */
/* The flag "cflag" is checked for each of the mapflags.
A mapflag entry has the form
return 0 ;
}
-int mapexpand(mapentry,cflag)
- char *mapentry, *cflag ;
+int mapexpand(char *mapentry, char *cflag)
{
register char *star ;
register char *ptr ;
return 1 ;
}
-doassign(line,star,length) char *line, *star ; {
+void doassign(char *line, char *star, int length)
+{
growstring varval, name, temp ;
register char *ptr ;
#define ISBLANK(c) ( (c)==SPACE || (c)==TAB )
-unravel(line,action) char *line ; int (*action)() ; {
+void unravel(char *line, void (*action)(char *))
+{
/* Unravel the line, get arguments a la shell */
/* each argument is handled to action */
/* The input string is left intact */
}
}
-char *c_rep(string,place,rep) char *string, *place, *rep ; {
+char *c_rep(char *string, char *place, char *rep)
+{
/* Produce a string in stable storage produced from 'string'
with the character at place replaced by rep
*/
static list_head *curargs ;
static list_head *comb_args ;
-addargs(string) char *string ; {
+void addargs(char *string)
+{
register char *temp, *repc ;
register list_elem *elem ;
l_add(curargs,temp) ;
}
-getcallargs(phase) register trf *phase ; {
+void getcallargs(trf *phase)
+{
growstring arg1, arg2 ;
arg1= scanvars(phase->t_argd) ;
gr_throw(&arg2) ;
}
-discardargs(phase) register trf *phase ; {
+void discardargs(trf *phase)
+{
l_throw(&phase->t_args) ;
}
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
+#ifndef UTILS_ACK_TRF_H
+#define UTILS_ACK_TRF_H
+
+#include "list.h"
+
#ifndef NORCSID
#define RCS_TRANS "$Id$"
#endif
char *t_argd ; /* Argument descriptor, uses varrep */
char *t_needed ; /* Suffix indicating the libraries needed */
char *t_rts ; /* Suffix indicating the major language used*/
- int t_stdin:1 ; /* The input is taken on stdin */
- int t_stdout:1 ; /* The output comes on stdout */
- int t_combine:1 ; /* Transform several files to one result */
- int t_visited:1 ; /* NO before setup, YES after */
- int t_prep:2 ; /* Needs preprocessor YES/NO/MAYBE */
- int t_isprep:1 ; /* Is preprocessor */
- int t_keep:1 ; /* Keep the output file */
- int t_scan:1 ; /* Used while finding path's */
- int t_bscan:1 ; /* Best scan so far, while finding path's */
- int t_linker:1 ; /* The linker usurps all unrecognized flags */
- int t_do:1 ; /* Is in a path to execute */
- int t_blocked:1 ; /* An input file could not be produced */
+ unsigned int t_stdin:1 ; /* The input is taken on stdin */
+ unsigned int t_stdout:1 ; /* The output comes on stdout */
+ unsigned int t_combine:1 ; /* Transform several files to one result */
+ unsigned int t_visited:1 ; /* NO before setup, YES after */
+ unsigned int t_prep:2 ; /* Needs preprocessor YES/NO/MAYBE */
+ unsigned int t_isprep:1 ; /* Is preprocessor */
+ unsigned int t_keep:1 ; /* Keep the output file */
+ unsigned int t_scan:1 ; /* Used while finding path's */
+ unsigned int t_bscan:1 ; /* Best scan so far, while finding path's */
+ unsigned int t_linker:1 ; /* The linker usurps all unrecognized flags */
+ unsigned int t_do:1 ; /* Is in a path to execute */
+ unsigned int t_blocked:1 ; /* An input file could not be produced */
short t_optim ; /* Is optimizer, + optimizer level */
short t_priority ; /* Importance of including phase in scan */
list_head t_inputs ; /* The input 'path's of a combiner */
} ;
#define t_cont(elem) ((trf *)l_content(elem))
+
+#endif
\ No newline at end of file
# define STDOUT stderr
#endif
-char *basename(string) char *string ; {
+void fuerror(const char *fmt, ...);
+void werror(const char *fmt, ...);
+void quit(int code);
+
+
+char *basename(char *string)
+{
static char retval[256] ;
char *last_dot, *last_start ;
register char *store;
return retval ;
}
-clr_noscan(str) char *str ; {
+void clr_noscan(char *str)
+{
register char *ptr ;
for ( ptr=str ; *ptr ; ptr++ ) {
*ptr&= ~NO_SCAN ;
}
}
-char *skipblank(str) char *str ; {
+char *skipblank(char *str)
+{
register char *ptr ;
for ( ptr=str ; *ptr==SPACE || *ptr==TAB ; ptr++ ) ;
return ptr ;
}
-char *firstblank(str) char *str ; {
+char *firstblank(char *str)
+{
register char *ptr ;
for ( ptr=str ; *ptr && *ptr!=SPACE && *ptr!=TAB ; ptr++ ) ;
}
#ifdef DEBUG
-prns(s) register char *s ; {
+void prns(char *s)
+{
for ( ; *s ; s++ ) {
putc((*s&0377)&~NO_SCAN,STDOUT) ;
}
#endif
/* VARARGS1 */
-void fuerror(const char *fmt, ...) {
+void fuerror(const char *fmt, ...)
+{
/* Fatal user error */
va_list ap;
va_start(ap, fmt);
}
/* VARARGS1 */
-void werror(const char *fmt, ...) {
+void werror(const char *fmt, ...)
+{
/* Warning user error, w_flag */
va_list ap;
if ( w_flag ) return ;
}
/* VARARGS1 */
-void error(const char *fmt, ...) {
+void error(const char *fmt, ...)
+{
/* User error, it is the callers responsibility to quit */
va_list ap;
va_start(ap, fmt);
va_end(ap);
}
-do_flush() {
+void do_flush()
+{
fflush(stdout) ;
fflush(stderr) ;
}
-void
-noodstop() {
+void noodstop()
+{
quit(-3) ;
}
-quit(code) {
+void quit(int code)
+{
rmtemps();
exit(code);
}
***********/
char *keeps(str) char *str ; {
- register char *result ;
+ char *result ;
result= getcore( (unsigned)(strlen(str)+1) ) ;
if ( !result ) fatal("Out of core") ;
return strcpy(result,str) ;
}
-throws(str) char *str ; {
+void throws(char *str)
+{
freecore(str) ;
}
-char *getcore(size) unsigned size ; {
- register char *retptr ;
+char *getcore(unsigned size)
+{
+ char *retptr ;
retptr= calloc(1,size) ;
if ( !retptr ) fatal("Out of memory") ;
return retptr ;
}
-char *changecore(ptr,size) char *ptr ; unsigned size ; {
- register char *retptr ;
+char *changecore(char *ptr, unsigned int size)
+{
+ char *retptr;
- retptr= realloc(ptr,size) ;
+ retptr = realloc(ptr,size) ;
if ( !retptr ) fatal("Out of memory") ;
return retptr ;
}
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
+#include <time.h>
#include <arch.h>
#include <ranlib.h>
#include <unistd.h>
char temp_buf[32];
char *temp_arch = &temp_buf[0];
-extern char *mktemp();
-extern char *ctime();
-usage()
-{
- error(TRUE, "usage: %s [qdprtxl][vlc] archive [file] ...\n",
- progname
- );
-}
+/* Prototypings...*/
+void error(BOOL quit, char *str1, char *str2, char *str3, char *str4);
+void usage(void);
+char *basename(char *path);
+int open_archive(char *name, int mode);
+int main(int argc, char *argv[]);
+struct ar_hdr *get_member(void);
+void get(int argc, char *argv[]);
+void add(char *name, int fd, char *mess);
+void extract(struct ar_hdr *member);
+void copy_member(MEMBER *member, int from, int to, int extracting);
+char *get_mode(int mode);
+void wr_fatal(void);
+void rd_fatal(void);
+void mwrite(int fd, char *address, int bytes);
+void show(char *s, char *name);
+void write_symdef();
+void do_names(struct outhead *headp);
+void enter_name(struct outname *namep);
+void do_object(int f, long size);
/*VARARGS2*/
-error(quit, str1, str2, str3, str4)
-BOOL quit;
-char *str1, *str2, *str3, *str4;
+void error(BOOL quit, char *str1, char *str2, char *str3, char *str4)
{
char errbuf[256];
}
}
-char *basename(path)
-char *path;
+void usage()
+{
+ error(TRUE, "usage: %s [qdprtxl][vlc] archive [file] ...\n",
+ progname,
+ NULL, NULL);
+}
+
+char *basename(char *path)
{
register char *ptr = path;
register char *last = NIL_PTR;
return last + 1;
}
-extern unsigned int rd_unsigned2();
-
-open_archive(name, mode)
-register char *name;
-register int mode;
+int open_archive(char *name, int mode)
{
unsigned short magic = 0;
int fd;
if (mode == CREATE) {
if ((fd = creat(name, 0666)) < 0)
- error(TRUE, "cannot creat %s\n", name);
+ error(TRUE, "cannot creat %s\n", name, NULL, NULL);
magic = MAGIC_NUMBER;
wr_int2(fd, magic);
return fd;
if ((fd = open(name, mode)) < 0) {
if (mode == APPEND) {
close(open_archive(name, CREATE));
- if (!nocr_fl) error(FALSE, "%s: creating %s\n", progname, name);
+ if (!nocr_fl) error(FALSE, "%s: creating %s\n", progname, name, NULL);
return open_archive(name, APPEND);
}
- error(TRUE, "cannot open %s\n", name);
+ error(TRUE, "cannot open %s\n", name, NULL, NULL);
}
lseek(fd, 0L, 0);
magic = rd_unsigned2(fd);
if (magic != AALMAG && magic != ARMAG)
- error(TRUE, "%s is not in ar format\n", name);
+ error(TRUE, "%s is not in ar format\n", name, NULL, NULL);
return fd;
}
-void
-catch()
+void catch(int sig)
{
unlink(temp_arch);
_exit (2);
}
-main(argc, argv)
-int argc;
-char *argv[];
+int main(int argc, char *argv[])
{
register char *ptr;
int needs_arg = 0;
#ifdef AAL
tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib));
tstrtab = malloc(4096);
- if (!tab || !tstrtab) error(TRUE,"Out of core\n");
+ if (!tab || !tstrtab) error(TRUE,"Out of core\n", NULL, NULL, NULL);
tabsz = 512;
strtabsz = 4096;
#endif
return 0;
}
-MEMBER *
-get_member()
+MEMBER *get_member()
{
static MEMBER member;
if (rd_arhdr(ar_fd, &member) == 0)
return NIL_MEM;
if (member.ar_size < 0) {
- error(TRUE, "archive has member with negative size\n");
+ error(TRUE, "archive has member with negative size\n", NULL, NULL, NULL);
}
if (equal(SYMDEF, member.ar_name)) {
lseek(ar_fd, member.ar_size, 1);
return &member;
}
-char *get_mode();
-
-get(argc, argv)
-int argc;
-register char *argv[];
+void get(int argc, char *argv[])
{
register MEMBER *member;
int i = 0;
close(ar_fd);
}
-add(name, fd, mess)
-char *name;
-int fd;
-char *mess;
+void add(char *name, int fd, char *mess)
{
static MEMBER member;
register int read_chars;
int src_fd;
if (stat(name, &status) < 0) {
- error(FALSE, "cannot find %s\n", name);
+ error(FALSE, "cannot find %s\n", name, NULL, NULL);
return;
}
else if (S_ISDIR(status.st_mode)) {
- error(FALSE, "%s is a directory (ignored)\n", name);
+ error(FALSE, "%s is a directory (ignored)\n", name, NULL, NULL);
return;
}
else if (u_fl && status.st_mtime <= member.ar_date) {
wr_arhdr(fd, member);
- copy_member(member, ar_fd, fd, 0);
+ copy_member(&member, ar_fd, fd, 0);
return;
}
else if ((src_fd = open(name, 0)) < 0) {
- error(FALSE, "cannot open %s\n", name);
+ error(FALSE, "cannot open %s\n", name, NULL, NULL);
return;
}
}
else status.st_size -= x;
if (read(src_fd, io_buffer, read_chars) != read_chars) {
- error(FALSE,"%s seems to shrink\n", name);
+ error(FALSE,"%s seems to shrink\n", name, NULL, NULL);
break;
}
mwrite(fd, io_buffer, x);
close(src_fd);
}
-extract(member)
-register MEMBER *member;
+void extract(MEMBER *member)
{
int fd = 1;
char buf[sizeof(member->ar_name) + 1];
strncpy(buf, member->ar_name, sizeof(member->ar_name));
buf[sizeof(member->ar_name)] = 0;
if (pr_fl == FALSE && (fd = creat(buf, 0666)) < 0) {
- error(FALSE, "cannot create %s\n", buf);
+ error(FALSE, "cannot create %s\n", buf, NULL, NULL);
fd = -1;
}
if (pr_fl == FALSE) chmod(buf, member->ar_mode);
}
-copy_member(member, from, to, extracting)
-register MEMBER *member;
-int from, to;
+void copy_member(MEMBER *member, int from, int to, int extracting)
{
register int rest;
long mem_size = member->ar_size;
strncpy(buf, member->ar_name, sizeof(member->ar_name));
buf[sizeof(member->ar_name)] = 0;
- error(TRUE, "read error on %s\n", buf);
+ error(TRUE, "read error on %s\n", buf, NULL, NULL);
}
if (to >= 0) mwrite(to, io_buffer, rest);
mem_size -= (long) rest;
}
}
-char *
-get_mode(mode)
-register int mode;
+char *get_mode(int mode)
{
static char mode_buf[11];
register int tmp = mode;
return mode_buf;
}
-wr_fatal()
+void wr_fatal()
{
- error(TRUE, "write error\n");
+ error(TRUE, "write error\n", NULL, NULL, NULL);
}
-rd_fatal()
+void rd_fatal()
{
- error(TRUE, "read error\n");
+ error(TRUE, "read error\n", NULL, NULL, NULL);
}
-mwrite(fd, address, bytes)
-int fd;
-register char *address;
-register int bytes;
+void mwrite(int fd, char *address, int bytes)
{
if (write(fd, address, bytes) != bytes)
- error(TRUE, "write error\n");
+ error(TRUE, "write error\n", NULL, NULL, NULL);
}
-show(s, name)
-char *s, *name;
+void show(char *s, char *name)
{
MEMBER x;
char buf[sizeof(x.ar_name)+1];
* then 4 bytes giving the size of the string table, followed by the string
* table itself.
*/
-write_symdef()
+void write_symdef()
{
register struct ranlib *ran;
register int i;
* Return whether the bytes in `buf' form a good object header.
* The header is put in `headp'.
*/
-int
-is_outhead(headp)
- register struct outhead *headp;
+int is_outhead(struct outhead *headp)
{
return !BADMAGIC(*headp) && headp->oh_nname != 0;
}
-do_object(f, size)
- long size;
+void do_object(int f, long size)
{
struct outhead headbuf;
* name table and read and write the names one by one. Update the ranlib table
* accordingly.
*/
-do_names(headp)
- struct outhead *headp;
+void do_names(struct outhead *headp)
{
register char *strings;
register int nnames = headp->oh_nname;
if ( headp->oh_nchar != (unsigned int)headp->oh_nchar ||
(strings = malloc((unsigned int)headp->oh_nchar)) == (char *)0
) {
- error(TRUE, "string table too big\n");
+ error(TRUE, "string table too big\n", NULL, NULL, NULL);
}
rd_string(strings, headp->oh_nchar);
while (nnames) {
free(strings);
}
-enter_name(namep)
- struct outname *namep;
+void enter_name(struct outname *namep)
{
register char *cp;
if (tnum >= tabsz) {
tab = (struct ranlib *)
realloc((char *) tab, (tabsz += 512) * sizeof(struct ranlib));
- if (! tab) error(TRUE, "Out of core\n");
+ if (! tab) error(TRUE, "Out of core\n", NULL, NULL, NULL);
}
tab[tnum].ran_off = tssiz;
tab[tnum].ran_pos = offset;
for (cp = namep->on_mptr;; cp++) {
if (tssiz >= strtabsz) {
tstrtab = realloc(tstrtab, (strtabsz += 4096));
- if (! tstrtab) error(TRUE, "string table overflow\n");
+ if (! tstrtab) error(TRUE, "string table overflow\n", NULL, NULL, NULL);
}
tstrtab[tssiz++] = *cp;
if (!*cp) break;
#include <stdio.h>
#include <string.h>
-#ifndef NORCSID
-static char *RcsId = "$Id$";
-#endif
-
#define MAXBUF 256
#define MAXTAB 10000
#define COMCOM '-'
int TabSize = 128; /* default size of generated table */
char *InitialValue; /* initial value of all table entries */
-main(argc, argv)
- char *argv[];
+/* Some protypes */
+void option(char *str);
+void InitTable(char *ival);
+void PrintTable();
+int process(char *str, int format);
+int c_proc(char *str, char *Name);
+int setval(int ch, char *nm);
+int quoted(char **pstr);
+void DoFile(char *name);
+char *getln(char *s, int n, FILE *fp);
+
+int main(int argc, char *argv[])
{
ProgCall = *argv++;
}
exit(0);
/*NOTREACHED*/
+ return 0;
}
-char *
-Salloc(s)
- char *s;
+char *Salloc(char *s)
{
char *ns = malloc((unsigned)strlen(s) + 1);
return ns;
}
-option(str)
- char *str;
+void option(char *str)
{
/* note that *str indicates the source of the option:
either COMCOM (from command line) or FILECOM (from a file).
}
}
-InitTable(ival)
- char *ival;
+void InitTable(char *ival)
{
int i;
}
}
-PrintTable()
+void PrintTable()
{
int i;
}
}
-int
-process(str, format)
- char *str;
+int process(char *str, int format)
{
char *cstr = str;
char *Name = cstr; /* overwrite original string! */
return 0;
}
-c_proc(str, Name)
- char *str;
- char *Name;
+int c_proc(char *str, char *Name)
{
int ch, ch2;
int quoted();
ch2 = quoted(&str);
}
else {
- if (ch2 = (*str++ & 0377));
- else str--;
+ if (!(ch2 = (*str++ & 0377)))
+ str--;
}
if (ch > ch2) {
fprintf(stderr, "%s: bad range\n", ProgCall);
return 1;
}
-int
-setval(ch, nm)
- char *nm;
+int setval(int ch, char *nm)
{
char **p = &Table[ch];
return 1;
}
-int
-quoted(pstr)
- char **pstr;
+int quoted(char **pstr)
{
int ch;
int i;
return ch & 0377;
}
-char *
-getln(s, n, fp)
- char *s;
- FILE *fp;
+char *getln(char *s, int n, FILE *fp)
{
int c = getc(fp);
char *str = s;
#define BUFSIZE 1024
-DoFile(name)
- char *name;
+void DoFile(char *name)
{
char text[BUFSIZE];
FILE *fp;
/* $Id$ */
/* L E X I C A L A N A L Y Z E R */
+#include <string.h>
+
#include "idfsize.h"
#include "numsize.h"
#include "strsize.h"
int AccDefined = 0; /* accept "defined(...)" */
int UnknownIdIsZero = 0; /* interpret unknown id as integer 0 */
-char *string_token();
-char *strcpy();
+char *string_token(char *nm, int stop_char);
+void skipcomment();
-PushLex()
+void PushLex()
{
DOT = 0;
}
-PopLex()
+void PopLex()
{}
-int
-LLlex()
+int LLlex()
{
return (DOT != EOF) ? GetToken(&dot) : EOF;
}
#define BUFSIZ 1024
-int
-GetToken(ptok)
- register struct token *ptok;
+int GetToken(struct token *ptok)
{
char buf[BUFSIZ];
register int c, nch;
crash("Impossible character class");
}
/*NOTREACHED*/
+ return 0;
}
-skipcomment()
+void skipcomment()
{
register int c;
NoUnstack--;
}
-char *
-string_token(nm, stop_char)
- char *nm;
+char *string_token(char *nm, int stop_char)
{
register int c;
register unsigned int str_size;
return str;
}
-int
-quoted(c)
- register int c;
-{
+int quoted(int c)
+{
/* quoted() replaces an escaped character sequence by the
character meant.
*/
}
/* provisional */
-int
-val_in_base(c, base)
- register int c;
+int val_in_base(int c, int base)
{
return
is_dig(c) ? c - '0' :
#include "LLlex.h"
#include "Lpars.h"
-extern char *symbol2str();
-
-LLmessage(tk) {
+void LLmessage(int tk)
+{
if (tk < 0)
error("garbage at end of line");
else if (tk) {
!File: botch_free.h
-/*#define BOTCH_FREE 1 /* botch freed memory, as a check */
+/*#define BOTCH_FREE 1*/ /* botch freed memory, as a check */
!File: debug.h
-/*#define DEBUG 1 /* perform various self-tests */
+/*#define DEBUG 1*/ /* perform various self-tests */
#define NDEBUG 1 /* disable assertions */
!File: inputtype.h
-/*#define INP_READ_IN_ONE 1 /* read input file in one. */
+/*#define INP_READ_IN_ONE 1*/ /* read input file in one. */
/* If defined, we cannot read from a pipe */
#include "Lpars.h"
#include <em_arith.h>
-ch7bin(pval, oper, val)
- register arith *pval, val;
- int oper;
+void ch7bin(arith *pval, int oper, arith val)
{
switch (oper) {
case '%':
#include "Lpars.h"
#include <em_arith.h>
-ch7mon(oper, pval)
- register arith *pval;
+void ch7mon(int oper, arith *pval)
{
switch (oper) {
case '~':
/* $Id$ */
/* PREPROCESSOR: CONTROLLINE INTERPRETER */
+#include <string.h>
+
#include "interface.h"
#include "LLlex.h"
#include "Lpars.h"
#include "idf.h"
#include "input.h"
-#include "ifdepth.h"
-#include "botch_free.h"
-#include "nparams.h"
-#include "parbufsize.h"
-#include "textsize.h"
-#include "idfsize.h"
+#include "ifdepth.h"
+#include "botch_free.h"
+#include "nparams.h"
+#include "parbufsize.h"
+#include "textsize.h"
+#include "idfsize.h"
#include <assert.h>
#include <alloc.h>
#include "class.h"
#include "macro.h"
#include "bits.h"
-IMPORT char **inctable; /* list of include directories */
-IMPORT char *getwdir();
-PRIVATE char ifstack[IFDEPTH]; /* if-stack: the content of an entry is */
+extern char **inctable; /* list of include directories */
+static char ifstack[IFDEPTH]; /* if-stack: the content of an entry is */
/* 1 if a corresponding ELSE has been */
/* encountered. */
int nestcount;
extern int do_preprocess;
-char *
-GetIdentifier()
+/* Prototypes */
+static int ifexpr();
+static void do_include();
+static void do_define();
+static void push_if();
+static void do_elif();
+static void do_else();
+static void do_if();
+static void do_endif();
+static void do_ifdef(int how);
+static void do_undef();
+static void do_line(unsigned int l);
+static int getparams(char *buf[], char parbuf[]);
+static int macroeq(char *s, char *t);
+void macro_def(struct idf *id, char *text, int nformals, int length, int flags);
+
+/* Externel dependency */
+char * getwdir(char *fn);
+
+char *GetIdentifier()
{
/* returns a pointer to the descriptor of the identifier that is
read from the input stream. A null-pointer is returned if
An error message is produced when the token is not recognized,
i.e. it is not one of "define" .. "undef" , integer or newline.
*/
-EXPORT
-domacro()
+void domacro()
{
struct token tk; /* the token itself */
register struct idf *id;
}
}
-PRIVATE
-skip_block(to_endif)
+static void skip_block(int to_endif)
{
/* skip_block() skips the input from
1) a false #if, #ifdef, #ifndef or #elif until the
}
}
-PRIVATE
-ifexpr()
+static int ifexpr()
{
/* ifexpr() returns whether the restricted constant
expression following #if or #elif evaluates to true. This
constant expressions. The result of this expression will
be given in the extern long variable "ifval".
*/
- IMPORT arith ifval;
+ extern arith ifval;
int errors = err_occurred;
ifval = (arith)0;
return (errors == err_occurred) && (ifval != (arith)0);
}
-PRIVATE
-do_include()
+static void do_include()
{
/* do_include() performs the inclusion of a file.
*/
}
}
-PRIVATE
-do_define()
+static void do_define()
{
/* do_define() interprets a #define control line.
*/
LineNumber++;
}
-PRIVATE
-push_if()
+static void push_if()
{
if (nestlevel >= IFDEPTH)
fatal("too many nested #if/#ifdef/#ifndef");
ifstack[++nestlevel] = 0;
}
-PRIVATE
-do_elif()
+static void do_elif()
{
if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel])) {
error("#elif without corresponding #if");
}
}
-PRIVATE
-do_else()
+static void do_else()
{
skipline();
if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel]))
}
}
-PRIVATE
-do_endif()
+static void do_endif()
{
skipline();
if (nestlevel <= svnestlevel[nestcount])
else nestlevel--;
}
-PRIVATE
-do_if()
+static void do_if()
{
push_if();
if (!ifexpr()) /* a false #if/#elif expression */
skip_block(0);
}
-PRIVATE
-do_ifdef(how)
+static void do_ifdef(int how)
{
register struct idf *id;
char *str;
}
}
-PRIVATE
-do_undef()
+static void do_undef()
{
register struct idf *id;
register char *str = GetIdentifier();
/* Forget a macro definition. */
if (str) {
- if (id = findidf(str)) {
+ if ((id = findidf(str))) {
if (id->id_macro) { /* forget the macro */
free_macro(id->id_macro);
id->id_macro = (struct macro *) 0;
skipline();
}
-PRIVATE
-do_line(l)
- unsigned int l;
+static void do_line(unsigned int l)
{
struct token tk;
int t = GetToken(&tk);
FileName = tk.tk_str;
}
-PRIVATE int
-getparams(buf, parbuf)
- char *buf[];
- char parbuf[];
+static int getparams(char *buf[], char parbuf[])
{
/* getparams() reads the formal parameter list of a macro
definition.
/*NOTREACHED*/
}
-EXPORT
-macro_def(id, text, nformals, length, flags)
- register struct idf *id;
- char *text;
+void macro_def(struct idf *id, char *text, int nformals, int length, int flags)
{
/* macro_def() puts the contents and information of a macro
definition into a structure and stores it into the symbol
newdef->mc_count = 0;
}
-PRIVATE int
-find_name(nm, index)
- char *nm, *index[];
+static int find_name(char *nm, char *index[])
{
/* find_name() returns the index of "nm" in the namelist
"index" if it can be found there. 0 is returned if it is
return 0;
}
-PRIVATE char *
-get_text(formals, length)
- char *formals[];
- int *length;
+static char *get_text(char *formals[], int *length)
{
/* get_text() copies the replacement text of a macro
definition with zero, one or more parameters, thereby
*idp++ = c;
} while (in_idf(c));
*--idp = '\0';
- if (n = find_name(id_buf, formals)) {
+ if ((n = find_name(id_buf, formals))) {
/* construct the formal parameter mark */
text[pos++] = FORMALP | (char) n;
if (pos == text_size)
while (pos + sz >= text_size) text_size <<= 1;
text = Realloc(text, text_size);
- while (text[pos++] = *idp++) ;
+ while ((text[pos++] = *idp++)) ;
pos--;
}
}
as strings, without taking care of the leading and trailing
blanks (spaces and tabs).
*/
-PRIVATE
-macroeq(s, t)
- register char *s, *t;
+static int macroeq(char *s, char *t)
{
/* skip leading spaces */
int err_occurred;
-err_hdr(s)
- char *s;
+void err_hdr(char *s)
{
if (FileName) {
fprint(ERROUT, "\"%s\", line %d: %s", FileName, LineNumber, s);
#if __STDC__
/*VARARGS1*/
-error(char *fmt, ...)
+void error(char *fmt, ...)
{
va_list ap;
}
/*VARARGS1*/
-warning(char *fmt, ...)
+void warning(char *fmt, ...)
{
va_list ap;
}
/*VARARGS1*/
-crash(char *fmt, ...)
+void crash(char *fmt, ...)
{
va_list ap;
}
/*VARARGS1*/
-fatal(char *fmt, ...)
+void fatal(char *fmt, ...)
{
va_list ap;
#include "LLlex.h"
#include <em_arith.h>
+void ch7bin(arith *pval, int oper, arith val);
+void ch7mon(int oper, arith *pval);
+
extern arith ifval;
}
#include <inp_pkg.body>
#include <alloc.h>
-char *
-getwdir(fn)
- char *fn;
+char * getwdir(char *fn)
{
register char *p;
char *strrchr();