ack/lang/basic/src/util.c

99 lines
1.1 KiB
C
Raw Normal View History

1988-07-04 11:45:41 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include "bem.h"
#ifndef NORSCID
1994-06-24 11:31:16 +00:00
static char rcs_id[] = "$Id$" ;
1988-07-04 11:45:41 +00:00
#endif
#define abs(X) (X>=0?X:-X)
/* Miscelaneous routines can be found here */
int errorcnt;
void
1988-07-04 11:45:41 +00:00
warning(str)
char *str;
{
if (wflag) return;
Xerror("WARNING", str);
}
error(str)
char *str;
{
Xerror("ERROR", str);
errorcnt++;
}
Xerror(type, str)
char *str;
char *type;
{
extern int listing;
extern int basicline;
if( !listing) fprint(STDERR, "LINE %d:",basicline);
fprint(STDERR, "%s:%s\n",type, str);
}
fatal(str)
char *str;
{
Xerror("FATAL",str);
C_close();
sys_stop(S_EXIT);
}
notyetimpl()
{
warning("not yet implemented");
}
illegalcmd()
{
warning("illegal command");
}
char *itoa(i)
int i;
{
static char buf[30];
1993-11-10 12:35:33 +00:00
sprint(buf,"%d",i);
1988-07-04 11:45:41 +00:00
return(buf);
}
char *salloc(length)
unsigned length;
{
char *s,*c;
s=c=malloc(length);
if ( !s ) fatal("Out of memory") ;
while(length--)*c++ =0;
return(s);
}