Pristine Ack-5.5
[Ack-5.5.git] / lang / basic / src / util.c
1 /*
2  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  */
5
6 #include "bem.h"
7
8 #ifndef NORSCID
9 static char rcs_id[] = "$Id: util.c,v 1.4 1994/06/24 11:31:16 ceriel Exp $" ;
10 #endif
11
12 #define abs(X)  (X>=0?X:-X)
13 /* Miscelaneous routines can be found here */
14
15 int     errorcnt;
16
17
18
19 warning(str)
20 char *str;
21 {
22          if (wflag) return;
23          Xerror("WARNING", str);
24 }
25
26
27 error(str)
28 char *str;
29 {
30         Xerror("ERROR", str);
31         errorcnt++;
32 }
33
34 Xerror(type, str)
35 char *str;
36 char *type;
37 {
38         extern int listing;
39         extern int basicline;
40
41         if( !listing) fprint(STDERR, "LINE %d:",basicline);
42         fprint(STDERR, "%s:%s\n",type, str);
43 }
44
45
46
47 fatal(str)
48 char *str;
49 {
50         Xerror("FATAL",str);
51         C_close();
52         sys_stop(S_EXIT);
53 }
54
55
56
57 notyetimpl()
58 {
59         warning("not yet implemented");
60 }
61
62
63
64 illegalcmd()
65 {
66         warning("illegal command");
67 }
68
69
70
71 char *itoa(i)
72 int i;
73 {
74         static char buf[30];
75
76         sprint(buf,"%d",i);
77         return(buf);
78 }
79
80
81
82
83
84
85 char *salloc(length)
86 unsigned length;
87 {               
88         char *s,*c;
89
90         s=c=malloc(length);
91         if ( !s ) fatal("Out of memory") ;
92         while(length--)*c++ =0;
93         return(s);
94 }
95
96
97