Deleted Added
sdiff udiff text old ( 95095 ) new ( 95887 )
full compact
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>
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
142expr(const char *expbuf)
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{
165 int result, true_val, false_val;
166
167 result = lor();
168 if (skipws() != '?') {
169 ungetch();
170 return result;
171 }
172
173 true_val = query();
174 if (skipws() != ':')
175 experr("bad query");
176
177 false_val = query();
178 return result ? true_val : false_val;
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
612experr(const char *msg)
613{
614 printf("m4: %s in expr %s.\n", msg, where);
615 longjmp(expjump, -1);
616}