| 1 | 
greg | 
1.1 | 
#ifndef lint | 
| 2 | 
greg | 
1.8 | 
static const char       RCSid[] = "$Id: ev.c,v 1.7 2008/09/11 05:34:47 greg Exp $"; | 
| 3 | 
greg | 
1.1 | 
#endif | 
| 4 | 
  | 
  | 
/* | 
| 5 | 
  | 
  | 
 *  ev.c - program to evaluate expression arguments | 
| 6 | 
  | 
  | 
 * | 
| 7 | 
  | 
  | 
 *     1/29/87 | 
| 8 | 
  | 
  | 
 */ | 
| 9 | 
  | 
  | 
 | 
| 10 | 
schorsch | 
1.2 | 
#include  <stdlib.h> | 
| 11 | 
greg | 
1.1 | 
#include  <stdio.h> | 
| 12 | 
schorsch | 
1.4 | 
#include  <errno.h> | 
| 13 | 
greg | 
1.1 | 
 | 
| 14 | 
  | 
  | 
#include  "calcomp.h" | 
| 15 | 
schorsch | 
1.3 | 
#include  "rterror.h" | 
| 16 | 
greg | 
1.1 | 
 | 
| 17 | 
  | 
  | 
 | 
| 18 | 
schorsch | 
1.6 | 
int | 
| 19 | 
greg | 
1.8 | 
main(int argc, char *argv[]) | 
| 20 | 
greg | 
1.1 | 
{ | 
| 21 | 
  | 
  | 
        int  i; | 
| 22 | 
  | 
  | 
 | 
| 23 | 
  | 
  | 
        esupport |= E_FUNCTION; | 
| 24 | 
  | 
  | 
        esupport &= ~(E_VARIABLE|E_INCHAN|E_OUTCHAN|E_RCONST); | 
| 25 | 
  | 
  | 
 | 
| 26 | 
  | 
  | 
#ifdef  BIGGERLIB | 
| 27 | 
  | 
  | 
        biggerlib(); | 
| 28 | 
  | 
  | 
#endif | 
| 29 | 
  | 
  | 
 | 
| 30 | 
  | 
  | 
        errno = 0; | 
| 31 | 
  | 
  | 
        for (i = 1; i < argc; i++) | 
| 32 | 
  | 
  | 
                printf("%.9g\n", eval(argv[i])); | 
| 33 | 
  | 
  | 
 | 
| 34 | 
greg | 
1.7 | 
        if (errno != EDOM && errno != ERANGE) | 
| 35 | 
  | 
  | 
                errno = 0; | 
| 36 | 
  | 
  | 
 | 
| 37 | 
greg | 
1.1 | 
        quit(errno ? 2 : 0); | 
| 38 | 
schorsch | 
1.6 | 
        return (errno ? 2 : 0); /* pro forma return */ | 
| 39 | 
greg | 
1.1 | 
} | 
| 40 | 
  | 
  | 
 | 
| 41 | 
  | 
  | 
 | 
| 42 | 
  | 
  | 
void | 
| 43 | 
greg | 
1.8 | 
eputs(const char *msg) | 
| 44 | 
greg | 
1.1 | 
{ | 
| 45 | 
  | 
  | 
        fputs(msg, stderr); | 
| 46 | 
  | 
  | 
} | 
| 47 | 
  | 
  | 
 | 
| 48 | 
  | 
  | 
 | 
| 49 | 
  | 
  | 
void | 
| 50 | 
greg | 
1.8 | 
wputs(const char *msg) | 
| 51 | 
greg | 
1.1 | 
{ | 
| 52 | 
  | 
  | 
        eputs(msg); | 
| 53 | 
  | 
  | 
} | 
| 54 | 
  | 
  | 
 | 
| 55 | 
  | 
  | 
 | 
| 56 | 
  | 
  | 
void | 
| 57 | 
greg | 
1.8 | 
quit(int code) | 
| 58 | 
greg | 
1.1 | 
{ | 
| 59 | 
  | 
  | 
        exit(code); | 
| 60 | 
  | 
  | 
} |