Back to index

tetex-bin  3.0
sexpr.c
Go to the documentation of this file.
00001 /*
00002  * File:    sexpr.c
00003  * Purpose: evaluate algebraic expression from single argument
00004  *          (Derived from expr.c from J.T. Conklin <jtc@netbsd.org>.)
00005  * Version: 1.0 (Nov 1995)
00006  * Author:  Piet Tutelaers
00007  */
00008 
00009 #include <stdio.h>
00010 #include "strexpr.h" /* strexpr() */
00011 #include "basics.h"  /* fatal() */
00012 
00013 int main(int argc, char *argv[]) {
00014    int result;
00015 
00016    if (argc < 2) fatal("Usage: sexpr expression ...\n");
00017 
00018    while (--argc > 0) {
00019       if (strexpr(&result, *++argv))
00020          fatal("expression error\n");
00021 
00022       printf("%s = %d\n", argv[0] , result);
00023    }
00024    exit(0);
00025 }