Deleted Added
full compact
expr.c (95095) expr.c (95887)
1/* $OpenBSD: expr.c,v 1.12 2002/02/16 21:27:48 millert Exp $ */
1/* $OpenBSD: expr.c,v 1.14 2002/04/26 16:15:16 espie Exp $ */
2/* $NetBSD: expr.c,v 1.7 1995/09/28 05:37:31 tls Exp $ */
3
4/*
5 * Copyright (c) 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Ozan Yigit at York University.

--- 23 unchanged lines hidden (view full) ---

33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40#include <sys/cdefs.h>
2/* $NetBSD: expr.c,v 1.7 1995/09/28 05:37:31 tls Exp $ */
3
4/*
5 * Copyright (c) 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Ozan Yigit at York University.

--- 23 unchanged lines hidden (view full) ---

33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40#include <sys/cdefs.h>
41__SCCSID("@(#)expr.c 8.2 (Berkeley) 4/29/95");
42__RCSID_SOURCE("$OpenBSD: expr.c,v 1.12 2002/02/16 21:27:48 millert Exp $");
43__FBSDID("$FreeBSD: head/usr.bin/m4/expr.c 95095 2002-04-20 01:49:10Z jmallett $");
41__SCCSID("@(#)expr.c 8.2 (Berkeley) 4/29/95");
42__RCSID_SOURCE("$OpenBSD: expr.c,v 1.14 2002/04/26 16:15:16 espie Exp $");
43__FBSDID("$FreeBSD: head/usr.bin/m4/expr.c 95887 2002-05-01 21:37:29Z jmallett $");
44
45#include <sys/types.h>
46#include <ctype.h>
47#include <err.h>
48#include <stddef.h>
49#include <stdio.h>
50#include "mdef.h"
51#include "extern.h"

--- 82 unchanged lines hidden (view full) ---

134 * macros:
135 * ungetch - Put back the last character examined.
136 * getch - return the next character from expr string.
137 */
138#define ungetch() nxtch--
139#define getch() *nxtch++
140
141int
44
45#include <sys/types.h>
46#include <ctype.h>
47#include <err.h>
48#include <stddef.h>
49#include <stdio.h>
50#include "mdef.h"
51#include "extern.h"

--- 82 unchanged lines hidden (view full) ---

134 * macros:
135 * ungetch - Put back the last character examined.
136 * getch - return the next character from expr string.
137 */
138#define ungetch() nxtch--
139#define getch() *nxtch++
140
141int
142expr(expbuf)
143 const char *expbuf;
142expr(const char *expbuf)
144{
145 int rval;
146
147 nxtch = expbuf;
148 where = expbuf;
149 if (setjmp(expjump) != 0)
150 return FALSE;
151

--- 6 unchanged lines hidden (view full) ---

158}
159
160/*
161 * query : lor | lor '?' query ':' query
162 */
163static int
164query()
165{
143{
144 int rval;
145
146 nxtch = expbuf;
147 where = expbuf;
148 if (setjmp(expjump) != 0)
149 return FALSE;
150

--- 6 unchanged lines hidden (view full) ---

157}
158
159/*
160 * query : lor | lor '?' query ':' query
161 */
162static int
163query()
164{
166 int bool, true_val, false_val;
165 int result, true_val, false_val;
167
166
168 bool = lor();
167 result = lor();
169 if (skipws() != '?') {
170 ungetch();
168 if (skipws() != '?') {
169 ungetch();
171 return bool;
170 return result;
172 }
173
174 true_val = query();
175 if (skipws() != ':')
176 experr("bad query");
177
178 false_val = query();
171 }
172
173 true_val = query();
174 if (skipws() != ':')
175 experr("bad query");
176
177 false_val = query();
179 return bool ? true_val : false_val;
178 return result ? true_val : false_val;
180}
181
182/*
183 * lor : land { '||' land }
184 */
185static int
186lor()
187{

--- 417 unchanged lines hidden (view full) ---

605 return c;
606}
607
608/*
609 * resets environment to eval(), prints an error
610 * and forces eval to return FALSE.
611 */
612static void
179}
180
181/*
182 * lor : land { '||' land }
183 */
184static int
185lor()
186{

--- 417 unchanged lines hidden (view full) ---

604 return c;
605}
606
607/*
608 * resets environment to eval(), prints an error
609 * and forces eval to return FALSE.
610 */
611static void
613experr(msg)
614 const char *msg;
612experr(const char *msg)
615{
616 printf("m4: %s in expr %s.\n", msg, where);
617 longjmp(expjump, -1);
618}
613{
614 printf("m4: %s in expr %s.\n", msg, where);
615 longjmp(expjump, -1);
616}