8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdlib.h> |
11 |
– |
#include <stdio.h> |
12 |
– |
#include <string.h> |
11 |
|
#include <setjmp.h> |
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]; |
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; |
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 |
> |
char *path = getpath(argv[i], getrlibpath(), 0); |
47 |
> |
if (path == NULL) { |
48 |
> |
eputs(argv[0]); |
49 |
> |
eputs(": cannot find file '"); |
50 |
> |
eputs(argv[i]); |
51 |
> |
eputs("'\n"); |
52 |
> |
quit(1); |
53 |
> |
} |
54 |
> |
fcompile(path); |
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; |
131 |
|
|
132 |
|
recover = 0; |
133 |
|
quit(0); |
134 |
+ |
return 0; /* pro forma exit */ |
135 |
|
} |
136 |
|
|
137 |
|
|