summaryrefslogtreecommitdiffstats
path: root/bin/expr
diff options
context:
space:
mode:
Diffstat (limited to 'bin/expr')
-rw-r--r--bin/expr/expr.y141
1 files changed, 56 insertions, 85 deletions
diff --git a/bin/expr/expr.y b/bin/expr/expr.y
index 5367b89..d368ce3 100644
--- a/bin/expr/expr.y
+++ b/bin/expr/expr.y
@@ -32,35 +32,34 @@ struct val {
struct val *result;
-int chk_div __P((quad_t, quad_t));
-int chk_minus __P((quad_t, quad_t, quad_t));
-int chk_plus __P((quad_t, quad_t, quad_t));
-int chk_times __P((quad_t, quad_t, quad_t));
-void free_value __P((struct val *));
-int is_zero_or_null __P((struct val *));
-int isstring __P((struct val *));
-int main __P((int, char **));
-struct val *make_integer __P((quad_t));
-struct val *make_str __P((const char *));
-struct val *op_and __P((struct val *, struct val *));
-struct val *op_colon __P((struct val *, struct val *));
-struct val *op_div __P((struct val *, struct val *));
-struct val *op_eq __P((struct val *, struct val *));
-struct val *op_ge __P((struct val *, struct val *));
-struct val *op_gt __P((struct val *, struct val *));
-struct val *op_le __P((struct val *, struct val *));
-struct val *op_lt __P((struct val *, struct val *));
-struct val *op_minus __P((struct val *, struct val *));
-struct val *op_ne __P((struct val *, struct val *));
-struct val *op_or __P((struct val *, struct val *));
-struct val *op_plus __P((struct val *, struct val *));
-struct val *op_rem __P((struct val *, struct val *));
-struct val *op_times __P((struct val *, struct val *));
-quad_t to_integer __P((struct val *));
-void to_string __P((struct val *));
-int yyerror __P((const char *));
-int yylex __P((void));
-int yyparse __P((void));
+int chk_div(quad_t, quad_t);
+int chk_minus(quad_t, quad_t, quad_t);
+int chk_plus(quad_t, quad_t, quad_t);
+int chk_times(quad_t, quad_t, quad_t);
+void free_value(struct val *);
+int is_zero_or_null(struct val *);
+int isstring(struct val *);
+struct val *make_integer(quad_t);
+struct val *make_str(const char *);
+struct val *op_and(struct val *, struct val *);
+struct val *op_colon(struct val *, struct val *);
+struct val *op_div(struct val *, struct val *);
+struct val *op_eq(struct val *, struct val *);
+struct val *op_ge(struct val *, struct val *);
+struct val *op_gt(struct val *, struct val *);
+struct val *op_le(struct val *, struct val *);
+struct val *op_lt(struct val *, struct val *);
+struct val *op_minus(struct val *, struct val *);
+struct val *op_ne(struct val *, struct val *);
+struct val *op_or(struct val *, struct val *);
+struct val *op_plus(struct val *, struct val *);
+struct val *op_rem(struct val *, struct val *);
+struct val *op_times(struct val *, struct val *);
+quad_t to_integer(struct val *);
+void to_string(struct val *);
+int yyerror(const char *);
+int yylex(void);
+int yyparse(void);
char **av;
%}
@@ -106,8 +105,7 @@ expr: TOKEN
%%
struct val *
-make_integer (i)
-quad_t i;
+make_integer(quad_t i)
{
struct val *vp;
@@ -122,8 +120,7 @@ quad_t i;
}
struct val *
-make_str (s)
-const char *s;
+make_str(const char *s)
{
struct val *vp;
size_t i;
@@ -152,8 +149,7 @@ const char *s;
void
-free_value (vp)
-struct val *vp;
+free_value(struct val *vp)
{
if (vp->type == string || vp->type == numeric_string)
free (vp->u.s);
@@ -161,8 +157,7 @@ struct val *vp;
quad_t
-to_integer (vp)
-struct val *vp;
+to_integer(struct val *vp)
{
quad_t i;
@@ -185,8 +180,7 @@ struct val *vp;
}
void
-to_string (vp)
-struct val *vp;
+to_string(struct val *vp)
{
char *tmp;
@@ -205,8 +199,7 @@ struct val *vp;
int
-isstring (vp)
-struct val *vp;
+isstring(struct val *vp)
{
/* only TRUE if this string is not a valid integer */
return (vp->type == string);
@@ -214,7 +207,7 @@ struct val *vp;
int
-yylex ()
+yylex(void)
{
char *p;
@@ -239,8 +232,7 @@ yylex ()
}
int
-is_zero_or_null (vp)
-struct val *vp;
+is_zero_or_null(struct val *vp)
{
if (vp->type == integer) {
return (vp->u.i == 0);
@@ -251,9 +243,7 @@ struct val *vp;
}
int
-main (argc, argv)
-int argc __unused;
-char **argv;
+main(int argc __unused, char *argv[])
{
setlocale (LC_ALL, "");
@@ -270,16 +260,14 @@ char **argv;
}
int
-yyerror (s)
-const char *s __unused;
+yyerror(const char *s __unused)
{
errx (2, "syntax error");
}
struct val *
-op_or (a, b)
-struct val *a, *b;
+op_or(struct val *a, struct val *b)
{
if (is_zero_or_null (a)) {
free_value (a);
@@ -291,8 +279,7 @@ struct val *a, *b;
}
struct val *
-op_and (a, b)
-struct val *a, *b;
+op_and(struct val *a, struct val *b)
{
if (is_zero_or_null (a) || is_zero_or_null (b)) {
free_value (a);
@@ -305,8 +292,7 @@ struct val *a, *b;
}
struct val *
-op_eq (a, b)
-struct val *a, *b;
+op_eq(struct val *a, struct val *b)
{
struct val *r;
@@ -326,8 +312,7 @@ struct val *a, *b;
}
struct val *
-op_gt (a, b)
-struct val *a, *b;
+op_gt(struct val *a, struct val *b)
{
struct val *r;
@@ -347,8 +332,7 @@ struct val *a, *b;
}
struct val *
-op_lt (a, b)
-struct val *a, *b;
+op_lt(struct val *a, struct val *b)
{
struct val *r;
@@ -368,8 +352,7 @@ struct val *a, *b;
}
struct val *
-op_ge (a, b)
-struct val *a, *b;
+op_ge(struct val *a, struct val *b)
{
struct val *r;
@@ -389,8 +372,7 @@ struct val *a, *b;
}
struct val *
-op_le (a, b)
-struct val *a, *b;
+op_le(struct val *a, struct val *b)
{
struct val *r;
@@ -410,8 +392,7 @@ struct val *a, *b;
}
struct val *
-op_ne (a, b)
-struct val *a, *b;
+op_ne(struct val *a, struct val *b)
{
struct val *r;
@@ -431,8 +412,7 @@ struct val *a, *b;
}
int
-chk_plus (a, b, r)
-quad_t a, b, r;
+chk_plus(quad_t a, quad_t b, quad_t r)
{
/* sum of two positive numbers must be positive */
if (a > 0 && b > 0 && r <= 0)
@@ -445,8 +425,7 @@ quad_t a, b, r;
}
struct val *
-op_plus (a, b)
-struct val *a, *b;
+op_plus(struct val *a, struct val *b)
{
struct val *r;
@@ -464,8 +443,7 @@ struct val *a, *b;
}
int
-chk_minus (a, b, r)
-quad_t a, b, r;
+chk_minus(quad_t a, quad_t b, quad_t r)
{
/* special case subtraction of QUAD_MIN */
if (b == QUAD_MIN) {
@@ -479,8 +457,7 @@ quad_t a, b, r;
}
struct val *
-op_minus (a, b)
-struct val *a, *b;
+op_minus(struct val *a, struct val *b)
{
struct val *r;
@@ -498,8 +475,7 @@ struct val *a, *b;
}
int
-chk_times (a, b, r)
-quad_t a, b, r;
+chk_times(quad_t a, quad_t b, quad_t r)
{
/* special case: first operand is 0, no overflow possible */
if (a == 0)
@@ -511,8 +487,7 @@ quad_t a, b, r;
}
struct val *
-op_times (a, b)
-struct val *a, *b;
+op_times(struct val *a, struct val *b)
{
struct val *r;
@@ -530,8 +505,7 @@ struct val *a, *b;
}
int
-chk_div (a, b)
-quad_t a, b;
+chk_div(quad_t a, quad_t b)
{
/* div by zero has been taken care of before */
/* only QUAD_MIN / -1 causes overflow */
@@ -542,8 +516,7 @@ quad_t a, b;
}
struct val *
-op_div (a, b)
-struct val *a, *b;
+op_div(struct val *a, struct val *b)
{
struct val *r;
@@ -565,8 +538,7 @@ struct val *a, *b;
}
struct val *
-op_rem (a, b)
-struct val *a, *b;
+op_rem(struct val *a, struct val *b)
{
struct val *r;
@@ -586,8 +558,7 @@ struct val *a, *b;
}
struct val *
-op_colon (a, b)
-struct val *a, *b;
+op_colon(struct val *a, struct val *b)
{
regex_t rp;
regmatch_t rm[2];
OpenPOWER on IntegriCloud