1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#include "rc.h"
#include "exec.h"
#include "io.h"
#include "fns.h"
char*
emalloc(long n)
{
char *p = (char *)Malloc(n);
if(p==0)
panic("Can't malloc %d bytes", n);
/* if(err){ pfmt(err, "malloc %d->%p\n", n, p); flush(err); } /**/
memset(p, 0, n);
return p;
}
void
efree(char *p)
{
/* pfmt(err, "free %p\n", p); flush(err); /**/
if(p)
free(p);
else pfmt(err, "free 0\n");
}
extern int lastword, lastdol;
void
yyerror(char *m)
{
pfmt(err, "rc: ");
if(runq->cmdfile && !runq->iflag)
pfmt(err, "%s:%d: ", runq->cmdfile, runq->lineno);
else if(runq->cmdfile)
pfmt(err, "%s: ", runq->cmdfile);
else if(!runq->iflag)
pfmt(err, "line %d: ", runq->lineno);
if(tok[0] && tok[0]!='\n')
pfmt(err, "token %q: ", tok);
pfmt(err, "%s\n", m);
flush(err);
lastword = 0;
lastdol = 0;
while(lastc!='\n' && lastc!=EOF) advance();
nerror++;
setvar("status", newword(m, (word *)0));
}
char *bp;
static void
iacvt(int n)
{
if(n<0){
*bp++='-';
n=-n; /* doesn't work for n==-inf */
}
if(n/10)
iacvt(n/10);
*bp++=n%10+'0';
}
void
inttoascii(char *s, long n)
{
bp = s;
iacvt(n);
*bp='\0';
}
void
panic(char *s, int n)
{
pfmt(err, "rc: ");
pfmt(err, s, n);
pchr(err, '\n');
flush(err);
Abort();
}
|