7 |
|
* 4/1/86 |
8 |
|
*/ |
9 |
|
|
10 |
< |
#include <stdio.h> |
11 |
< |
|
10 |
> |
#include <stdlib.h> |
11 |
|
#include <setjmp.h> |
13 |
– |
|
12 |
|
#include <ctype.h> |
13 |
|
|
14 |
+ |
#include "rtio.h" |
15 |
+ |
#include "rterror.h" |
16 |
|
#include "calcomp.h" |
17 |
|
|
18 |
– |
|
18 |
|
#define MAXRES 100 |
19 |
|
|
20 |
|
double result[MAXRES]; |
21 |
|
int nres = 0; |
22 |
|
|
24 |
– |
#ifndef BSD |
25 |
– |
#define index strchr |
26 |
– |
#endif |
27 |
– |
extern char *index(), *fgets(); |
28 |
– |
|
29 |
– |
|
23 |
|
jmp_buf env; |
24 |
|
int recover = 0; |
25 |
|
|
26 |
|
|
27 |
+ |
int |
28 |
|
main(argc, argv) |
29 |
|
int argc; |
30 |
|
char *argv[]; |
31 |
|
{ |
32 |
< |
char expr[512]; |
32 |
> |
char expr[2048]; |
33 |
> |
char *epos; |
34 |
|
FILE *fp; |
35 |
|
int i; |
36 |
< |
register char *cp; |
36 |
> |
char *cp; |
37 |
|
|
38 |
|
esupport |= E_VARIABLE|E_INCHAN|E_FUNCTION; |
39 |
|
esupport &= ~(E_REDEFW|E_RCONST|E_OUTCHAN); |
42 |
|
#endif |
43 |
|
varset("PI", ':', 3.14159265358979323846); |
44 |
|
|
45 |
< |
for (i = 1; i < argc; i++) |
46 |
< |
fcompile(argv[i]); |
47 |
< |
|
45 |
> |
for (i = 1; i < argc; i++) { |
46 |
> |
cp = getpath(argv[i], getrlibpath(), 0); |
47 |
> |
if (cp == NULL) { |
48 |
> |
eputs(argv[0]); |
49 |
> |
eputs(": cannot find file '"); |
50 |
> |
eputs(argv[i]); |
51 |
> |
eputs("'\n"); |
52 |
> |
quit(1); |
53 |
> |
} |
54 |
> |
fcompile(cp); |
55 |
> |
} |
56 |
|
setjmp(env); |
57 |
|
recover = 1; |
58 |
|
eclock++; |
59 |
|
|
60 |
< |
while (fgets(expr, sizeof(expr), stdin) != NULL) { |
61 |
< |
for (cp = expr; *cp && *cp != '\n'; cp++) |
62 |
< |
; |
63 |
< |
*cp = '\0'; |
60 |
> |
epos = expr; |
61 |
> |
while (fgets(epos, sizeof(expr)-(epos-expr), stdin) != NULL) { |
62 |
> |
while (*epos && *epos != '\n') |
63 |
> |
epos++; |
64 |
> |
if (*epos && epos > expr && epos[-1] == '\\') { |
65 |
> |
epos[-1] = ' '; |
66 |
> |
continue; /* escaped newline */ |
67 |
> |
} |
68 |
> |
*epos = '\0'; |
69 |
> |
epos = expr; |
70 |
|
switch (expr[0]) { |
71 |
|
case '\0': |
72 |
|
continue; |
100 |
|
eputs("file name required\n"); |
101 |
|
continue; |
102 |
|
} |
103 |
+ |
cp = getpath(cp, getrlibpath(), 0); |
104 |
+ |
if (cp == NULL) { |
105 |
+ |
eputs("cannot find file\n"); |
106 |
+ |
continue; |
107 |
+ |
} |
108 |
|
fcompile(cp); |
109 |
|
eclock++; |
110 |
|
continue; |
111 |
|
} |
112 |
< |
if ((cp = index(expr, '=')) != NULL || |
113 |
< |
(cp = index(expr, ':')) != NULL) { |
112 |
> |
if ((cp = strchr(expr, '=')) != NULL || |
113 |
> |
(cp = strchr(expr, ':')) != NULL) { |
114 |
|
if (cp[1]) |
115 |
|
scompile(expr, NULL, 0); |
116 |
|
else if (*cp == '=') { |
136 |
|
|
137 |
|
recover = 0; |
138 |
|
quit(0); |
139 |
+ |
return 0; /* pro forma exit */ |
140 |
|
} |
141 |
|
|
142 |
|
|