Next batch.

This commit is contained in:
Manoel Trapier 2013-03-08 19:13:03 +01:00 committed by Manoël Trapier
parent 60330b05cd
commit 3d1d1277b7
34 changed files with 568 additions and 603 deletions

View File

@ -9,25 +9,22 @@
/* $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"
*/
@ -82,9 +79,7 @@ C_out(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".
*/
@ -145,9 +140,7 @@ arg(p, comma)
}
}
static
pseudo(p)
register struct e_instr *p;
static void pseudo(struct e_instr *p)
{
PS(p->em_opcode);

View File

@ -19,8 +19,8 @@
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;
@ -50,8 +50,8 @@ char *C_current_out = obuf;
char *C_opp = obuf;
#endif
void
C_flush() {
void C_flush()
{
#ifdef INCORE
static unsigned int bufsiz;
@ -83,9 +83,7 @@ C_flush() {
#define Xputbyte(c) put(c)
#endif
void
C_putbyte(c)
int c;
void C_putbyte(int c)
{
Xputbyte(c);
}
@ -95,15 +93,11 @@ C_putbyte(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
*/
@ -116,8 +110,7 @@ C_open(nm)
return 1;
}
void
C_close()
void C_close()
{
/* Finish the code-generation.
*/
@ -151,8 +144,7 @@ C_close()
C_ofp = 0;
}
int
C_busy()
int C_busy()
{
return C_ofp != 0; /* true if code is being generated */
}
@ -166,32 +158,25 @@ C_busy()
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];
@ -202,17 +187,14 @@ C_pt_ilb(l)
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];
@ -220,10 +202,7 @@ C_pt_cst(l)
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;
@ -240,17 +219,14 @@ C_pt_scon(x, y)
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];
@ -258,10 +234,7 @@ C_pt_dlb(l)
wrs(buf);
}
void
C_pt_doff(l, v)
label l;
arith v;
void C_pt_doff(label l, arith v)
{
char buf[16];
@ -272,10 +245,7 @@ C_pt_doff(l, v)
}
}
void
C_pt_noff(s, v)
char *s;
arith v;
void C_pt_noff(char *s, arith v)
{
char buf[16];
@ -286,17 +256,13 @@ C_pt_noff(s, v)
}
}
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];
@ -304,11 +270,7 @@ C_pt_dfilb(l)
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';
@ -317,18 +279,18 @@ C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
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('?');
}
@ -346,8 +308,7 @@ C_pt_ccend() {
names.
*/
void
C_magic()
void C_magic()
{
put16(sp_magic);
}
@ -356,9 +317,7 @@ C_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);
@ -370,9 +329,7 @@ C_pt_ilb(l)
}
}
void
C_pt_dlb(l)
register label l;
void C_pt_dlb(label l)
{
if (fit8u(l)) {
put8(sp_dlb1);
@ -384,9 +341,7 @@ C_pt_dlb(l)
}
}
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
@ -405,10 +360,7 @@ C_pt_cst(l)
}
}
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);
@ -420,9 +372,7 @@ C_pt_doff(l, v)
}
}
void
C_pt_str(s)
register char *s;
void C_pt_str(char *s)
{
register int len;
@ -432,18 +382,13 @@ C_pt_str(s)
}
}
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);
@ -455,19 +400,13 @@ C_pt_noff(s, v)
}
}
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);
@ -475,10 +414,7 @@ C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
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);

View File

@ -193,9 +193,7 @@ static flt_arith r_big_10pow[] = { /* representation of 10 ** -(28*i) */
#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;
@ -218,10 +216,7 @@ add_exponent(e, exp)
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;
@ -291,10 +286,7 @@ flt_str2flt(s, e)
#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 */
@ -420,12 +412,8 @@ flt_ecvt(e, decpt, sign)
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;

View File

@ -8,10 +8,7 @@
#include <system.h>
#include "print.h"
extern char *long2str();
static int
integral(c)
static int integral(int c)
{
switch (c) {
case 'b':
@ -35,10 +32,7 @@ integral(c)
%[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;
@ -75,7 +69,7 @@ _format(buf, fmt, argp)
else
if (*pf == 'l') {
/* alignment ??? */
if (base = integral(*++pf)) {
if ((base = integral(*++pf))) {
arg = long2str(va_arg(argp,long), base);
}
else {
@ -84,7 +78,7 @@ _format(buf, fmt, argp)
}
}
else
if (base = integral(*pf)) {
if ((base = integral(*pf))) {
arg = long2str((long)va_arg(argp,int), base);
}
else
@ -98,7 +92,7 @@ _format(buf, fmt, argp)
while (npad-- > 0)
*pb++ = pad;
while (*pb++ = *arg++);
while (((*pb++) = (*arg++)));
pb--;
pf++;
}

View File

@ -20,4 +20,6 @@ _PROTOTYPE(void doprnt, (File *f, char *fmt, va_list ap));
_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__ */

View File

@ -31,9 +31,7 @@ static int listtype = 0; /* indicates pseudo when generating code for
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) ||
@ -53,14 +51,16 @@ checkarg(arg, typset)
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 */
@ -94,11 +94,8 @@ EM_doinstr(p)
#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);
@ -326,9 +323,7 @@ EM_dopseudo(p)
}
}
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) {
@ -365,9 +360,7 @@ EM_docon(p)
}
}
PRIVATE void
EM_dostartmes(p)
register struct e_instr *p;
PRIVATE void EM_dostartmes(struct e_instr *p)
{
if (listtype) {
@ -379,9 +372,7 @@ EM_dostartmes(p)
listtype = ps_mes;
}
EXPORT int
EM_mkcalls(line)
register struct e_instr *line;
EXPORT int EM_mkcalls(struct e_instr *line)
{
#ifdef CHECKING

View File

@ -11,7 +11,8 @@
#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)))
@ -31,9 +32,7 @@ static int argnum; /* Number of arguments */
/* inithash, pre_hash, hash: Simple hashtable mechanism
*/
PRIVATE int
hash(s)
register char *s;
PRIVATE int hash(char *s)
{
register int h = 0;
@ -44,9 +43,7 @@ hash(s)
return h;
}
PRIVATE void
pre_hash(i, s)
char *s;
PRIVATE void pre_hash(int i, char *s)
{
register int h;
@ -67,8 +64,7 @@ pre_hash(i, s)
extern char em_mnem[][4];
extern char em_pseu[][4];
PRIVATE void
inithash()
PRIVATE void inithash()
{
register int i;
@ -86,8 +82,7 @@ inithash()
/* nospace: skip until we find a non-space character. Also skip
comments.
*/
PRIVATE int
nospace()
PRIVATE int nospace()
{
register int c;
@ -104,9 +99,7 @@ nospace()
/* 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;
@ -118,8 +111,7 @@ syntax(s)
/* checkeol: check that we have a complete line (except maybe for spaces)
*/
PRIVATE void
checkeol()
PRIVATE void checkeol()
{
if (nospace() != '\n') {
@ -130,8 +122,7 @@ checkeol()
/* getescape: read a '\' escape sequence
*/
PRIVATE int
getescape()
PRIVATE int getescape()
{
register int c, j, r;
@ -163,8 +154,7 @@ getescape()
/* getname: Read a string of characters representing an identifier
*/
PRIVATE struct string *
getname()
PRIVATE struct string * getname()
{
register char *p;
register struct string *s;
@ -202,8 +192,7 @@ getname()
/* getstring: read a string of characters between quotes
*/
PRIVATE struct string *
getstring()
PRIVATE struct string *getstring()
{
register char *p;
struct string *s;
@ -252,11 +241,9 @@ getstring()
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;
@ -274,10 +261,7 @@ offsetted(argtyp, ap)
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;
@ -365,12 +349,9 @@ getnumber(c, ap)
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) {
@ -385,10 +366,7 @@ getfactor(c, ap)
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;
@ -413,10 +391,7 @@ getterm(c, ap)
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;
@ -440,8 +415,7 @@ getexpr(c, ap)
return sp_cst4;
}
PRIVATE int
get15u()
PRIVATE int get15u()
{
struct e_arg dummy;
@ -452,9 +426,7 @@ get15u()
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;
@ -499,7 +471,7 @@ gettyp(typset, ap)
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;
@ -528,9 +500,7 @@ gettyp(typset, ap)
}
}
PRIVATE void
getarg(typset, ap)
struct e_arg *ap;
PRIVATE void getarg(int typset, struct e_arg *ap)
{
register int c;
@ -550,9 +520,7 @@ getarg(typset, ap)
/* 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;
@ -592,8 +560,7 @@ getmnem(c, p)
}
}
PRIVATE void
line_line()
PRIVATE void line_line()
{
static char filebuf[256 + 1];
char *btscpy();
@ -606,11 +573,8 @@ line_line()
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) {
@ -629,9 +593,7 @@ getlabel(c, p)
checkeol();
}
PRIVATE void
gethead(p)
register struct e_instr *p;
PRIVATE void gethead(struct e_instr *p)
{
register int c;

View File

@ -14,10 +14,7 @@
#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";

View File

@ -2,6 +2,12 @@
* (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
@ -29,9 +35,9 @@
/* 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
@ -65,17 +71,19 @@ typedef struct {
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 */
@ -84,3 +92,5 @@ extern char *changecore();
#else
extern int debug ;
#endif
#endif /* UTILS_ACK_ACK_H */

View File

@ -4,6 +4,8 @@
*
*/
#include <string.h>
#include "ack.h"
#include "list.h"
#include "trans.h"
@ -15,7 +17,11 @@
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) ;
}
@ -23,7 +29,8 @@ char *add_u(part,ptr) char *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] ;
@ -35,7 +42,8 @@ char *unique() {
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 ;
@ -93,7 +101,8 @@ setfiles(phase) register trf *phase ; {
return 1 ;
}
disc_files(phase) trf *phase ; {
void disc_files(trf *phase)
{
path temp ;
if ( !phase->t_combine ) {
@ -104,7 +113,8 @@ disc_files(phase) trf *phase ; {
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 ) {
@ -118,7 +128,8 @@ file_final(file) path *file ; {
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 ;
@ -131,7 +142,8 @@ disc_inputs(phase) trf *phase ; {
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) ;
@ -142,7 +154,8 @@ rmfile(file) path *file ; {
}
}
rmtemps() {
void rmtemps()
{
/* Called in case of disaster, always remove the current output file!
*/
register list_elem *elem ;
@ -157,7 +170,8 @@ rmtemps() {
}
}
add_input(file,phase) path *file ; trf *phase ; {
void add_input(path *file, trf *phase)
{
register path *store ;
#ifdef DEBUG
if ( debug ) {

View File

@ -18,7 +18,8 @@ static char rcs_id[] = "$Id$" ;
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 ;
@ -31,7 +32,8 @@ gr_add(id,c) register growstring *id ; char c ; {
*(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
@ -49,7 +51,8 @@ gr_cat(id,string) growstring *id ; char *string ; {
}
}
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) ;
@ -58,11 +61,13 @@ gr_throw(id) register growstring *id ; {
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

View File

@ -2,6 +2,9 @@
* (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
@ -20,8 +23,10 @@ typedef struct {
/* 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 */

View File

@ -32,7 +32,8 @@ Routines:
*/
l_add(header,string) list_head *header ; char *string ; {
void l_add(list_head *header, char *string)
{
register list_elem *new;
/* NOSTRICT */
@ -48,7 +49,8 @@ l_add(header,string) list_head *header ; char *string ; {
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 ;
@ -58,7 +60,8 @@ l_clear(header) list_head *header ; {
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)) ;

View File

@ -2,6 +2,9 @@
* (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
@ -29,3 +32,6 @@ typedef struct ca_elem list_elem ; /* The decl. for elements */
/* 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 */

View File

@ -22,9 +22,18 @@ static char rcs_ack[] = RCS_ACK ;
static int sigs[] = { SIGINT, SIGHUP, SIGTERM, 0 } ;
static int arg_count;
extern char *getenv();
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);
main(argc,argv) char **argv ; {
int main(int argc, char *argv[])
{
register list_elem *elem ;
register char *frontend ;
register int *n_sig ;
@ -113,20 +122,23 @@ main(argc,argv) char **argv ; {
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) ;
@ -136,7 +148,8 @@ varinit() {
/************************* flag processing ***********************/
vieuwargs(argc,argv) char **argv ; {
void vieuwargs(int argc, char *argv[])
{
register char *argp;
register int nextarg ;
register int eaten ;
@ -248,7 +261,8 @@ vieuwargs(argc,argv) char **argv ; {
return ;
}
firstarg(argp) register char *argp ; {
void firstarg(char *argp)
{
register char *name ;
name=strrchr(argp,'/') ;
@ -262,7 +276,8 @@ firstarg(argp) register char *argp ; {
/************************* argument processing ***********************/
process(arg) char *arg ; {
int process(char *arg)
{
/* Process files & library arguments */
trf *phase ;
register trf *tmp ;
@ -322,7 +337,8 @@ process(arg) char *arg ; {
return startrf(phase) ;
}
int startrf(first) trf *first ; {
int startrf(trf *first)
{
/* Start the transformations at the indicated phase */
register trf *phase ;
@ -394,7 +410,8 @@ if ( debug ) vprint("Transformation sequence complete for %s\n",
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.
*/
@ -403,7 +420,9 @@ block(first) trf *first ; {
if ( phase->t_combine ) phase->t_blocked=YES ;
}
}
mayprep() {
int mayprep()
{
int file ;
char fc ;
file=open(in.p_path,0);
@ -413,15 +432,18 @@ mayprep() {
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) ;
@ -429,7 +451,8 @@ scanneeds() {
l_clear(&tail_list) ;
}
setneeds(suffix,tail) char *suffix ; {
void setneeds(char *suffix, int tail)
{
trf *phase ;
p_suffix= suffix ;

View File

@ -22,8 +22,13 @@ FILE *dmach ;
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++ ) {
@ -34,7 +39,8 @@ main(argc,argv) char **argv ; {
return 0 ;
}
start(dir) char *dir ; {
void start(char *dir)
{
tail= dname ;
while ( *dir ) {
*tail++ = *dir ++ ;
@ -51,14 +57,16 @@ start(dir) char *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) ;
@ -70,7 +78,8 @@ FILE *do_open(file) char *file ; {
return fopen(dname,"r");
}
readm() {
void readm()
{
register int i ;
register int token ;
register FILE *in ;
@ -97,7 +106,7 @@ readm() {
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) ) {

View File

@ -4,6 +4,8 @@
*
*/
#include <string.h>
#include "ack.h"
#include <em_path.h>
#include "list.h"
@ -46,18 +48,16 @@ static char rcs_dmach[] = RCS_DMACH ;
#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
@ -90,8 +90,7 @@ setlist(name) char *name ; {
#endif
}
static int inoptlist(nm)
char *nm ;
static int inoptlist(char *nm)
{
register char *p=Optlist ;
@ -105,7 +104,8 @@ static int inoptlist(nm)
return 0;
}
intrf() {
void intrf()
{
register trf *new ;
growstring bline ;
int twice ;
@ -128,8 +128,8 @@ intrf() {
} 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
@ -262,7 +262,8 @@ static FILE *infile ;
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) ;
@ -295,12 +296,14 @@ open_in(name) register char *name ; {
}
}
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,
@ -352,8 +355,9 @@ char *readline() {
}
}
int getinchar() {
register int token ;
int getinchar()
{
int token ;
if ( incore ) {
if ( *inptr==0 ) return EOF ;
@ -366,8 +370,9 @@ int getinchar() {
return token ;
}
int getln() {
register char *c_ptr ;
int getln()
{
char *c_ptr ;
do {
if ( (c_ptr=readline())==(char *)0 ) return 0 ;

View File

@ -19,13 +19,14 @@ static char rcs_id[] = "$Id$" ;
#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 ;
@ -70,7 +71,8 @@ int runphase(phase) register trf *phase ; {
return result ;
}
int run_exec(phase,prog) trf *phase ; char *prog ; {
int run_exec(trf *phase, char *prog)
{
int status, child, waitchild ;
do_flush();
@ -136,7 +138,8 @@ int run_exec(phase,prog) trf *phase ; char *prog ; {
/*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 ) {

View File

@ -8,14 +8,19 @@
#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();
@ -47,7 +52,8 @@ static int suf_found; /* Was the suffix at least recognized ? */
/******************** The hard work ********************/
start_scan() {
void start_scan()
{
register list_elem *scan ;
scanlist(l_first(tr_list),scan) {
@ -61,7 +67,8 @@ start_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
@ -106,12 +113,12 @@ try(f_scan,suffix) list_elem *f_scan; char *suffix; {
*/
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 ;
@ -131,7 +138,8 @@ try(f_scan,suffix) list_elem *f_scan; char *suffix; {
}
}
scan_found() {
void scan_found()
{
register list_elem *scan;
int ncount, ocount, pcount ;
@ -179,7 +187,8 @@ scan_found() {
}
}
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
@ -204,7 +213,8 @@ int satisfy(trafo,suffix) register trf *trafo; char *suffix ; {
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
@ -245,7 +255,8 @@ enum f_path scan_end(first) trf **first ; { /* Finalization */
return F_OK ;
}
find_cpp() {
void find_cpp()
{
register list_elem *elem ;
scanlist( l_first(tr_list), elem ) {
if ( t_cont(*elem)->t_isprep ) {

View File

@ -4,6 +4,7 @@
*
*/
#include <string.h>
#include "ack.h"
#ifndef NORCSID
@ -44,9 +45,6 @@ static char rcs_id[] = "$Id$" ;
*/
extern char *getcore();
extern fatal();
struct vars {
char *v_name;
enum { routine, string } v_type;
@ -60,7 +58,8 @@ struct vars {
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 ) {
@ -79,7 +78,8 @@ static struct vars *newvar(name) char *name; {
return new ;
}
setsvar(name,str) char *name, *str ; {
void setsvar(char *name, char *str)
{
register struct vars *new ;
new= newvar(name);
@ -90,7 +90,8 @@ setsvar(name,str) char *name, *str ; {
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);
@ -101,7 +102,8 @@ setpvar(name,rout) char *name, *(*rout)() ; {
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 ) {

View File

@ -26,9 +26,14 @@ static int touch_head= NO ;
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) ) {
@ -46,7 +51,8 @@ int transform(phase) register trf *phase ; {
return ok ;
}
getmapflags(phase) register trf *phase ; {
void getmapflags(trf *phase)
{
register path *l_in ;
register list_elem *elem ;
int scanned ;
@ -106,16 +112,19 @@ getmapflags(phase) register trf *phase ; {
}
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 ;
@ -123,12 +132,14 @@ add_head(str) char *str; {
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 ;
@ -137,7 +148,8 @@ add_tail(str) char *str ; {
}
transini() {
void transini()
{
register list_elem *elem ;
register trf *phase ;
@ -153,7 +165,8 @@ transini() {
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 ;
@ -201,7 +214,8 @@ set_Rflag(argp) register char *argp ; {
/* */
/**************************************************************************/
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.
*/
@ -232,7 +246,8 @@ growstring scanb(line) char *line ; {
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.
@ -280,7 +295,7 @@ growstring scanvars(line) char *line ; {
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++) ;
}
@ -292,7 +307,7 @@ growstring scanvars(line) char *line ; {
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++);
}
@ -326,7 +341,8 @@ growstring scanvars(line) char *line ; {
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
@ -413,9 +429,7 @@ growstring scanexpr(line) char *line ; {
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 ;
@ -440,7 +454,8 @@ condit(line,fsuff,lsuff,tailval) growstring *line ;
#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
@ -462,8 +477,7 @@ int mapflag(maplist,cflag) list_head *maplist ; char *cflag ; {
return 0 ;
}
int mapexpand(mapentry,cflag)
char *mapentry, *cflag ;
int mapexpand(char *mapentry, char *cflag)
{
register char *star ;
register char *ptr ;
@ -504,7 +518,8 @@ int mapexpand(mapentry,cflag)
return 1 ;
}
doassign(line,star,length) char *line, *star ; {
void doassign(char *line, char *star, int length)
{
growstring varval, name, temp ;
register char *ptr ;
@ -537,7 +552,8 @@ doassign(line,star,length) char *line, *star ; {
#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 */
@ -574,7 +590,8 @@ unravel(line,action) char *line ; int (*action)() ; {
}
}
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
*/
@ -598,7 +615,8 @@ char *c_rep(string,place,rep) char *string, *place, *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 ;
@ -645,7 +663,8 @@ addargs(string) char *string ; {
l_add(curargs,temp) ;
}
getcallargs(phase) register trf *phase ; {
void getcallargs(trf *phase)
{
growstring arg1, arg2 ;
arg1= scanvars(phase->t_argd) ;
@ -663,6 +682,7 @@ getcallargs(phase) register trf *phase ; {
gr_throw(&arg2) ;
}
discardargs(phase) register trf *phase ; {
void discardargs(trf *phase)
{
l_throw(&phase->t_args) ;
}

View File

@ -2,6 +2,11 @@
* (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
@ -21,18 +26,18 @@ struct transform {
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 */
@ -44,3 +49,5 @@ struct transform {
} ;
#define t_cont(elem) ((trf *)l_content(elem))
#endif

View File

@ -32,7 +32,13 @@ extern int n_error;
# 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;
@ -62,21 +68,24 @@ out:
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++ ) ;
@ -107,7 +116,8 @@ void vprint(const char* fmt, ...)
}
#ifdef DEBUG
prns(s) register char *s ; {
void prns(char *s)
{
for ( ; *s ; s++ ) {
putc((*s&0377)&~NO_SCAN,STDOUT) ;
}
@ -116,7 +126,8 @@ prns(s) register char *s ; {
#endif
/* VARARGS1 */
void fuerror(const char *fmt, ...) {
void fuerror(const char *fmt, ...)
{
/* Fatal user error */
va_list ap;
va_start(ap, fmt);
@ -127,7 +138,8 @@ void fuerror(const char *fmt, ...) {
}
/* VARARGS1 */
void werror(const char *fmt, ...) {
void werror(const char *fmt, ...)
{
/* Warning user error, w_flag */
va_list ap;
if ( w_flag ) return ;
@ -139,7 +151,8 @@ void werror(const char *fmt, ...) {
}
/* 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);
@ -150,17 +163,19 @@ void error(const char *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);
}
@ -172,28 +187,31 @@ quit(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 ;
}

View File

@ -31,6 +31,7 @@ static char RcsId[] = "$Id$";
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <time.h>
#include <arch.h>
#include <ranlib.h>
#include <unistd.h>
@ -106,20 +107,30 @@ char *progname;
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];
@ -131,8 +142,14 @@ char *str1, *str2, *str3, *str4;
}
}
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;
@ -151,18 +168,14 @@ char *path;
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;
@ -171,29 +184,26 @@ register int mode;
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;
@ -278,7 +288,7 @@ char *argv[];
#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
@ -289,8 +299,7 @@ char *argv[];
return 0;
}
MEMBER *
get_member()
MEMBER *get_member()
{
static MEMBER member;
@ -298,7 +307,7 @@ again:
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);
@ -307,11 +316,7 @@ again:
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;
@ -437,10 +442,7 @@ register char *argv[];
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;
@ -448,20 +450,20 @@ char *mess;
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;
}
@ -497,7 +499,7 @@ char *mess;
}
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);
@ -508,8 +510,7 @@ char *mess;
close(src_fd);
}
extract(member)
register MEMBER *member;
void extract(MEMBER *member)
{
int fd = 1;
char buf[sizeof(member->ar_name) + 1];
@ -517,7 +518,7 @@ register MEMBER *member;
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;
}
@ -533,9 +534,7 @@ register MEMBER *member;
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;
@ -557,7 +556,7 @@ int from, to;
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;
@ -570,9 +569,7 @@ int from, to;
}
}
char *
get_mode(mode)
register int mode;
char *get_mode(int mode)
{
static char mode_buf[11];
register int tmp = mode;
@ -592,27 +589,23 @@ register int 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];
@ -630,7 +623,7 @@ char *s, *name;
* 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;
@ -675,16 +668,13 @@ write_symdef()
* 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;
@ -710,8 +700,7 @@ do_object(f, size)
* 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;
@ -722,7 +711,7 @@ do_names(headp)
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) {
@ -756,15 +745,14 @@ do_names(headp)
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;
@ -772,7 +760,7 @@ enter_name(namep)
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;

View File

@ -13,10 +13,6 @@
#include <stdio.h>
#include <string.h>
#ifndef NORCSID
static char *RcsId = "$Id$";
#endif
#define MAXBUF 256
#define MAXTAB 10000
#define COMCOM '-'
@ -30,8 +26,18 @@ char *ProgCall; /* callname of this program */
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++;
@ -48,11 +54,10 @@ main(argc, argv)
}
exit(0);
/*NOTREACHED*/
return 0;
}
char *
Salloc(s)
char *s;
char *Salloc(char *s)
{
char *ns = malloc((unsigned)strlen(s) + 1);
@ -66,8 +71,7 @@ Salloc(s)
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).
@ -124,8 +128,7 @@ option(str)
}
}
InitTable(ival)
char *ival;
void InitTable(char *ival)
{
int i;
@ -138,7 +141,7 @@ InitTable(ival)
}
}
PrintTable()
void PrintTable()
{
int i;
@ -155,9 +158,7 @@ PrintTable()
}
}
int
process(str, format)
char *str;
int process(char *str, int format)
{
char *cstr = str;
char *Name = cstr; /* overwrite original string! */
@ -189,9 +190,7 @@ process(str, format)
return 0;
}
c_proc(str, Name)
char *str;
char *Name;
int c_proc(char *str, char *Name)
{
int ch, ch2;
int quoted();
@ -209,8 +208,8 @@ c_proc(str, Name)
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);
@ -228,9 +227,7 @@ c_proc(str, Name)
return 1;
}
int
setval(ch, nm)
char *nm;
int setval(int ch, char *nm)
{
char **p = &Table[ch];
@ -245,9 +242,7 @@ setval(ch, nm)
return 1;
}
int
quoted(pstr)
char **pstr;
int quoted(char **pstr)
{
int ch;
int i;
@ -290,10 +285,7 @@ quoted(pstr)
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;
@ -316,8 +308,7 @@ getln(s, n, fp)
#define BUFSIZE 1024
DoFile(name)
char *name;
void DoFile(char *name)
{
char text[BUFSIZE];
FILE *fp;

View File

@ -5,6 +5,8 @@
/* $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"
@ -25,28 +27,25 @@ int AccFileSpecifier = 0; /* return filespecifier <...> */
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;
@ -258,9 +257,10 @@ again: /* rescan the input after an error or replacement */
crash("Impossible character class");
}
/*NOTREACHED*/
return 0;
}
skipcomment()
void skipcomment()
{
register int c;
@ -283,9 +283,7 @@ skipcomment()
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;
@ -322,10 +320,8 @@ string_token(nm, stop_char)
return str;
}
int
quoted(c)
register int c;
{
int quoted(int c)
{
/* quoted() replaces an escaped character sequence by the
character meant.
*/
@ -363,9 +359,7 @@ quoted(c)
}
/* provisional */
int
val_in_base(c, base)
register int c;
int val_in_base(int c, int base)
{
return
is_dig(c) ? c - '0' :

View File

@ -8,9 +8,8 @@
#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) {

View File

@ -34,11 +34,11 @@
!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 */
@ -51,7 +51,7 @@
!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 */

View File

@ -8,9 +8,7 @@
#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 '%':

View File

@ -8,8 +8,7 @@
#include "Lpars.h"
#include <em_arith.h>
ch7mon(oper, pval)
register arith *pval;
void ch7mon(int oper, arith *pval)
{
switch (oper) {
case '~':

View File

@ -5,6 +5,8 @@
/* $Id$ */
/* PREPROCESSOR: CONTROLLINE INTERPRETER */
#include <string.h>
#include "interface.h"
#include "LLlex.h"
#include "Lpars.h"
@ -12,21 +14,20 @@
#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. */
@ -35,8 +36,26 @@ int svnestlevel[30] = {-1};
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
@ -60,8 +79,7 @@ GetIdentifier()
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;
@ -139,8 +157,7 @@ domacro()
}
}
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
@ -228,8 +245,7 @@ skip_block(to_endif)
}
}
PRIVATE
ifexpr()
static int ifexpr()
{
/* ifexpr() returns whether the restricted constant
expression following #if or #elif evaluates to true. This
@ -237,7 +253,7 @@ ifexpr()
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;
@ -251,8 +267,7 @@ ifexpr()
return (errors == err_occurred) && (ifval != (arith)0);
}
PRIVATE
do_include()
static void do_include()
{
/* do_include() performs the inclusion of a file.
*/
@ -288,8 +303,7 @@ do_include()
}
}
PRIVATE
do_define()
static void do_define()
{
/* do_define() interprets a #define control line.
*/
@ -339,8 +353,7 @@ do_define()
LineNumber++;
}
PRIVATE
push_if()
static void push_if()
{
if (nestlevel >= IFDEPTH)
fatal("too many nested #if/#ifdef/#ifndef");
@ -348,8 +361,7 @@ push_if()
ifstack[++nestlevel] = 0;
}
PRIVATE
do_elif()
static void do_elif()
{
if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel])) {
error("#elif without corresponding #if");
@ -362,8 +374,7 @@ do_elif()
}
}
PRIVATE
do_else()
static void do_else()
{
skipline();
if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel]))
@ -374,8 +385,7 @@ do_else()
}
}
PRIVATE
do_endif()
static void do_endif()
{
skipline();
if (nestlevel <= svnestlevel[nestcount])
@ -383,16 +393,14 @@ do_endif()
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;
@ -421,15 +429,14 @@ do_ifdef(how)
}
}
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;
@ -443,9 +450,7 @@ do_undef()
skipline();
}
PRIVATE
do_line(l)
unsigned int l;
static void do_line(unsigned int l)
{
struct token tk;
int t = GetToken(&tk);
@ -457,10 +462,7 @@ do_line(l)
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.
@ -526,10 +528,7 @@ getparams(buf, parbuf)
/*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
@ -567,9 +566,7 @@ macro_def(id, text, nformals, length, flags)
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
@ -584,10 +581,7 @@ find_name(nm, index)
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
@ -655,7 +649,7 @@ get_text(formals, length)
*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)
@ -669,7 +663,7 @@ get_text(formals, length)
while (pos + sz >= text_size) text_size <<= 1;
text = Realloc(text, text_size);
while (text[pos++] = *idp++) ;
while ((text[pos++] = *idp++)) ;
pos--;
}
}
@ -693,9 +687,7 @@ get_text(formals, length)
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 */

View File

@ -22,8 +22,7 @@
int err_occurred;
err_hdr(s)
char *s;
void err_hdr(char *s)
{
if (FileName) {
fprint(ERROUT, "\"%s\", line %d: %s", FileName, LineNumber, s);
@ -33,7 +32,7 @@ err_hdr(s)
#if __STDC__
/*VARARGS1*/
error(char *fmt, ...)
void error(char *fmt, ...)
{
va_list ap;
@ -46,7 +45,7 @@ error(char *fmt, ...)
}
/*VARARGS1*/
warning(char *fmt, ...)
void warning(char *fmt, ...)
{
va_list ap;
@ -58,7 +57,7 @@ warning(char *fmt, ...)
}
/*VARARGS1*/
crash(char *fmt, ...)
void crash(char *fmt, ...)
{
va_list ap;
@ -71,7 +70,7 @@ crash(char *fmt, ...)
}
/*VARARGS1*/
fatal(char *fmt, ...)
void fatal(char *fmt, ...)
{
va_list ap;

View File

@ -12,6 +12,9 @@
#include "LLlex.h"
#include <em_arith.h>
void ch7bin(arith *pval, int oper, arith val);
void ch7mon(int oper, arith *pval);
extern arith ifval;
}

View File

@ -15,9 +15,7 @@ struct file_info finfo;
#include <inp_pkg.body>
#include <alloc.h>
char *
getwdir(fn)
char *fn;
char * getwdir(char *fn)
{
register char *p;
char *strrchr();