ack/lang/basic/src/util.c

94 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 "system.h"
#include "util.h"
1988-07-04 11:45:41 +00:00
#include "bem.h"
#ifndef NORCSID
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;
static void Xerror(char *type, char *str)
{
extern int listing;
extern int basicline;
if( !listing) fprint(STDERR, "LINE %d:",basicline);
fprint(STDERR, "%s:%s\n",type, str);
}
void warning(char* str)
1988-07-04 11:45:41 +00:00
{
if (wflag) return;
Xerror("WARNING", str);
}
void error(char* str)
1988-07-04 11:45:41 +00:00
{
Xerror("ERROR", str);
errorcnt++;
}
void fatal(char* str)
1988-07-04 11:45:41 +00:00
{
Xerror("FATAL",str);
C_close();
sys_stop(S_EXIT);
}
void notyetimpl(void)
1988-07-04 11:45:41 +00:00
{
warning("not yet implemented");
}
void illegalcmd(void)
1988-07-04 11:45:41 +00:00
{
warning("illegal command");
}
char *myitoa(int i)
1988-07-04 11:45:41 +00:00
{
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(unsigned int length)
1988-07-04 11:45:41 +00:00
{
char *s,*c;
s=c=malloc(length);
if ( !s ) fatal("Out of memory") ;
while(length--)*c++ =0;
return(s);
}