aboutsummaryrefslogtreecommitdiff
path: root/bin/expr
diff options
context:
space:
mode:
Diffstat (limited to 'bin/expr')
-rw-r--r--bin/expr/Makefile9
-rw-r--r--bin/expr/Makefile.depend21
-rw-r--r--bin/expr/expr.18
-rw-r--r--bin/expr/expr.y20
-rw-r--r--bin/expr/tests/Makefile16
5 files changed, 29 insertions, 45 deletions
diff --git a/bin/expr/Makefile b/bin/expr/Makefile
index 1d741b7e0b6d..b86cf6686ab0 100644
--- a/bin/expr/Makefile
+++ b/bin/expr/Makefile
@@ -1,18 +1,9 @@
# $FreeBSD$
-.include <src.opts.mk>
-
PROG= expr
SRCS= expr.y
YFLAGS=
-# expr relies on signed integer wrapping
-CFLAGS+= -fwrapv
-
NO_WMISSING_VARIABLE_DECLARATIONS=
-.if ${MK_TESTS} != "no"
-SUBDIR+= tests
-.endif
-
.include <bsd.prog.mk>
diff --git a/bin/expr/Makefile.depend b/bin/expr/Makefile.depend
new file mode 100644
index 000000000000..1c402a90a785
--- /dev/null
+++ b/bin/expr/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+expr.o: expr.c
+expr.po: expr.c
+.endif
diff --git a/bin/expr/expr.1 b/bin/expr/expr.1
index d02105561fde..34be0b8fa9de 100644
--- a/bin/expr/expr.1
+++ b/bin/expr/expr.1
@@ -90,17 +90,17 @@ Return the evaluation of
.Ar expr1
if neither expression evaluates to an empty string or zero;
otherwise, returns zero.
-.It Ar expr1 Bro =, >, >=, <, <=, != Brc Ar expr2
+.It Ar expr1 Li "{=, >, >=, <, <=, !=}" Ar expr2
Return the results of integer comparison if both arguments are integers;
otherwise, returns the results of string comparison using the locale-specific
collation sequence.
The result of each comparison is 1 if the specified relation is true,
or 0 if the relation is false.
-.It Ar expr1 Bro +, - Brc Ar expr2
+.It Ar expr1 Li "{+, -}" Ar expr2
Return the results of addition or subtraction of integer-valued arguments.
-.It Ar expr1 Bro *, /, % Brc Ar expr2
+.It Ar expr1 Li "{*, /, %}" Ar expr2
Return the results of multiplication, integer division, or remainder of integer-valued arguments.
-.It Ar expr1 Li \&: Ar expr2
+.It Ar expr1 Li : Ar expr2
The
.Dq Li \&:
operator matches
diff --git a/bin/expr/expr.y b/bin/expr/expr.y
index 0ddf3990d2a8..1856ec84d0f7 100644
--- a/bin/expr/expr.y
+++ b/bin/expr/expr.y
@@ -444,26 +444,14 @@ op_minus(struct val *a, struct val *b)
return (r);
}
-/*
- * We depend on undefined behaviour giving a result (in r).
- * To test this result, pass it as volatile. This prevents
- * optimizing away of the test based on the undefined behaviour.
- */
void
-assert_times(intmax_t a, intmax_t b, volatile intmax_t r)
+assert_times(intmax_t a, intmax_t b, intmax_t r)
{
/*
- * If the first operand is 0, no overflow is possible,
- * else the result of the division test must match the
- * second operand.
- *
- * Be careful to avoid overflow in the overflow test, as
- * in assert_div(). Overflow in division would kill us
- * with a SIGFPE before getting the test wrong. In old
- * buggy versions, optimization used to give a null test
- * instead of a SIGFPE.
+ * if first operand is 0, no overflow is possible,
+ * else result of division test must match second operand
*/
- if ((a == -1 && b == INTMAX_MIN) || (a != 0 && r / a != b))
+ if (a != 0 && r / a != b)
errx(ERR_EXIT, "overflow");
}
diff --git a/bin/expr/tests/Makefile b/bin/expr/tests/Makefile
deleted file mode 100644
index 80c130c3df20..000000000000
--- a/bin/expr/tests/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# $FreeBSD$
-
-OBJTOP= ${.OBJDIR}/../../..
-SRCTOP= ${.CURDIR}/../../..
-TESTSRC= ${SRCTOP}/contrib/netbsd-tests/bin/expr
-
-TESTSDIR= ${TESTSBASE}/bin/expr
-
-NETBSD_ATF_TESTS_SH= expr_test
-
-ATF_TESTS_SH_SED_expr_test+= -e 's/eval expr/eval expr --/g'
-ATF_TESTS_SH_SED_expr_test+= -e 's/"expr: integer overflow or underflow occurred for operation.*"/"expr: overflow"/g'
-
-.include <netbsd-tests.test.mk>
-
-.include <bsd.test.mk>