expr.c revision 1.1.1.3 1 1.1.1.3 christos /* $OpenBSD: expr.c,v 1.17 2006/01/20 23:10:19 espie Exp $ */
2 1.1 cgd /*
3 1.1.1.3 christos * Copyright (c) 2004 Marc Espie <espie (at) cvs.openbsd.org>
4 1.1 cgd *
5 1.1.1.3 christos * Permission to use, copy, modify, and distribute this software for any
6 1.1.1.3 christos * purpose with or without fee is hereby granted, provided that the above
7 1.1.1.3 christos * copyright notice and this permission notice appear in all copies.
8 1.1.1.3 christos *
9 1.1.1.3 christos * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 1.1.1.3 christos * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 1.1.1.3 christos * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 1.1.1.3 christos * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 1.1.1.3 christos * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 1.1.1.3 christos * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 1.1.1.3 christos * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 1.1 cgd */
17 1.1.1.3 christos #include <stdint.h>
18 1.1 cgd #include <stdio.h>
19 1.1.1.3 christos #include <stddef.h>
20 1.1.1.3 christos #include "mdef.h"
21 1.1.1.3 christos #include "extern.h"
22 1.1 cgd
23 1.1.1.3 christos int32_t end_result;
24 1.1.1.3 christos const char *copy_toeval;
25 1.1.1.2 tls
26 1.1.1.3 christos extern void yy_scan_string(const char *);
27 1.1.1.3 christos extern int yyparse(void);
28 1.1.1.2 tls
29 1.1.1.2 tls int
30 1.1.1.3 christos yyerror(const char *msg)
31 1.1 cgd {
32 1.1.1.3 christos fprintf(stderr, "m4: %s in expr %s\n", msg, copy_toeval);
33 1.1.1.3 christos return(0);
34 1.1 cgd }
35 1.1.1.2 tls
36 1.1.1.3 christos int
37 1.1.1.3 christos expr(const char *toeval)
38 1.1 cgd {
39 1.1.1.3 christos copy_toeval = toeval;
40 1.1.1.3 christos yy_scan_string(toeval);
41 1.1.1.3 christos yyparse();
42 1.1.1.3 christos return end_result;
43 1.1 cgd }
44