9 |
|
|
10 |
|
#include <stdlib.h> |
11 |
|
#include <stdio.h> |
12 |
+ |
#include <errno.h> |
13 |
|
|
14 |
|
#include "calcomp.h" |
15 |
+ |
#include "rterror.h" |
16 |
|
|
17 |
|
|
18 |
< |
main(argc, argv) |
19 |
< |
int argc; |
18 |
< |
char *argv[]; |
18 |
> |
int |
19 |
> |
main(int argc, char *argv[]) |
20 |
|
{ |
20 |
– |
extern int errno; |
21 |
|
int i; |
22 |
|
|
23 |
|
esupport |= E_FUNCTION; |
31 |
|
for (i = 1; i < argc; i++) |
32 |
|
printf("%.9g\n", eval(argv[i])); |
33 |
|
|
34 |
+ |
if (errno != EDOM && errno != ERANGE) |
35 |
+ |
errno = 0; |
36 |
+ |
|
37 |
|
quit(errno ? 2 : 0); |
38 |
+ |
return (errno ? 2 : 0); /* pro forma return */ |
39 |
|
} |
40 |
|
|
41 |
|
|
42 |
|
void |
43 |
< |
eputs(msg) |
40 |
< |
char *msg; |
43 |
> |
eputs(const char *msg) |
44 |
|
{ |
45 |
|
fputs(msg, stderr); |
46 |
|
} |
47 |
|
|
48 |
|
|
49 |
|
void |
50 |
< |
wputs(msg) |
48 |
< |
char *msg; |
50 |
> |
wputs(const char *msg) |
51 |
|
{ |
52 |
|
eputs(msg); |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
void |
57 |
< |
quit(code) |
56 |
< |
int code; |
57 |
> |
quit(int code) |
58 |
|
{ |
59 |
|
exit(code); |
60 |
|
} |