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 |
|
|
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; |
98 |
|
; |
99 |
|
if (!*cp) { |
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); |