logo

utils-std

Collection of commonly available Unix tools
commit: a66eb72146112ded006ceff4f7d05952abb2ead6
parent 8a0dc3cf2748757aa8a232f14adccdc1bf2aaf76
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 29 May 2024 14:09:20 +0200

cmd/expr: Add static on non-main functions

Diffstat:

Mcmd/expr.y120++++++++++++++++++++++++++++++++++++++++----------------------------------------
1 file changed, 60 insertions(+), 60 deletions(-)

diff --git a/cmd/expr.y b/cmd/expr.y @@ -46,37 +46,37 @@ char **av; int nonposix; struct val *result; -void assert_to_integer(struct val *); -void assert_div(intmax_t, intmax_t); -void assert_minus(intmax_t, intmax_t, intmax_t); -void assert_plus(intmax_t, intmax_t, intmax_t); -void assert_times(intmax_t, intmax_t, intmax_t); -int compare_vals(struct val *, struct val *); -void free_value(struct val *); -int is_integer(const char *); -int is_string(struct val *); -int is_zero_or_null(struct val *); -struct val *make_integer(intmax_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 *); -int to_integer(struct val *); -void to_string(struct val *); +static void assert_to_integer(struct val *); +static void assert_div(intmax_t, intmax_t); +static void assert_minus(intmax_t, intmax_t, intmax_t); +static void assert_plus(intmax_t, intmax_t, intmax_t); +static void assert_times(intmax_t, intmax_t, intmax_t); +static int compare_vals(struct val *, struct val *); +static void free_value(struct val *); +static int is_integer(const char *); +static int is_string(struct val *); +static int is_zero_or_null(struct val *); +static struct val *make_integer(intmax_t); +static struct val *make_str(const char *); +static struct val *op_and(struct val *, struct val *); +static struct val *op_colon(struct val *, struct val *); +static struct val *op_div(struct val *, struct val *); +static struct val *op_eq(struct val *, struct val *); +static struct val *op_ge(struct val *, struct val *); +static struct val *op_gt(struct val *, struct val *); +static struct val *op_le(struct val *, struct val *); +static struct val *op_lt(struct val *, struct val *); +static struct val *op_minus(struct val *, struct val *); +static struct val *op_ne(struct val *, struct val *); +static struct val *op_or(struct val *, struct val *); +static struct val *op_plus(struct val *, struct val *); +static struct val *op_rem(struct val *, struct val *); +static struct val *op_times(struct val *, struct val *); +static int to_integer(struct val *); +static void to_string(struct val *); #define YYERROR_IS_DECLARED -int yyerror(const char *); -int yylex(void); +static int yyerror(const char *); +static int yylex(void); %} @@ -119,7 +119,7 @@ expr: TOKEN %% -struct val * +static struct val * make_integer(intmax_t i) { struct val *vp; @@ -133,7 +133,7 @@ make_integer(intmax_t i) return (vp); } -struct val * +static struct val * make_str(const char *s) { struct val *vp; @@ -153,7 +153,7 @@ make_str(const char *s) return (vp); } -void +static void free_value(struct val *vp) { if (vp->type == string || vp->type == numeric_string) @@ -163,7 +163,7 @@ free_value(struct val *vp) free(vp); } -int +static int to_integer(struct val *vp) { intmax_t i; @@ -182,7 +182,7 @@ to_integer(struct val *vp) return (vp->type == integer); } -void +static void assert_to_integer(struct val *vp) { if (vp->type == string) @@ -191,7 +191,7 @@ assert_to_integer(struct val *vp) errx(ERR_EXIT, "operand too large: '%s'", vp->u.s); } -void +static void to_string(struct val *vp) { char *tmp; @@ -214,7 +214,7 @@ to_string(struct val *vp) vp->u.s = tmp; } -int +static int is_integer(const char *s) { if (nonposix) { @@ -232,14 +232,14 @@ is_integer(const char *s) return (*s == '\0'); } -int +static int is_string(struct val *vp) { /* only TRUE if this string is not a valid integer */ return (vp->type == string); } -int +static int yylex(void) { char *p; @@ -264,7 +264,7 @@ yylex(void) return (TOKEN); } -int +static int is_zero_or_null(struct val *vp) { if (vp->type == integer) @@ -311,13 +311,13 @@ main(int argc, char *argv[]) return err; } -int +static int yyerror(const char *s) { errx(ERR_EXIT, "syntax error"); } -struct val * +static struct val * op_or(struct val *a, struct val *b) { if (!is_zero_or_null(a)) { @@ -331,7 +331,7 @@ op_or(struct val *a, struct val *b) return (make_integer((intmax_t)0)); } -struct val * +static struct val * op_and(struct val *a, struct val *b) { if (is_zero_or_null(a) || is_zero_or_null(b)) { @@ -344,7 +344,7 @@ op_and(struct val *a, struct val *b) } } -int +static int compare_vals(struct val *a, struct val *b) { int r; @@ -369,43 +369,43 @@ compare_vals(struct val *a, struct val *b) return (r); } -struct val * +static struct val * op_eq(struct val *a, struct val *b) { return (make_integer((intmax_t)(compare_vals(a, b) == 0))); } -struct val * +static struct val * op_gt(struct val *a, struct val *b) { return (make_integer((intmax_t)(compare_vals(a, b) > 0))); } -struct val * +static struct val * op_lt(struct val *a, struct val *b) { return (make_integer((intmax_t)(compare_vals(a, b) < 0))); } -struct val * +static struct val * op_ge(struct val *a, struct val *b) { return (make_integer((intmax_t)(compare_vals(a, b) >= 0))); } -struct val * +static struct val * op_le(struct val *a, struct val *b) { return (make_integer((intmax_t)(compare_vals(a, b) <= 0))); } -struct val * +static struct val * op_ne(struct val *a, struct val *b) { return (make_integer((intmax_t)(compare_vals(a, b) != 0))); } -void +static void assert_plus(intmax_t a, intmax_t b, intmax_t r) { /* @@ -417,7 +417,7 @@ assert_plus(intmax_t a, intmax_t b, intmax_t r) errx(ERR_EXIT, "overflow"); } -struct val * +static struct val * op_plus(struct val *a, struct val *b) { struct val *r; @@ -432,7 +432,7 @@ op_plus(struct val *a, struct val *b) return (r); } -void +static void assert_minus(intmax_t a, intmax_t b, intmax_t r) { if ((a >= 0 && b < 0 && r <= 0) || @@ -440,7 +440,7 @@ assert_minus(intmax_t a, intmax_t b, intmax_t r) errx(ERR_EXIT, "overflow"); } -struct val * +static struct val * op_minus(struct val *a, struct val *b) { struct val *r; @@ -460,7 +460,7 @@ op_minus(struct val *a, struct val *b) * To test this result, pass it as volatile. This prevents * optimizing away of the test based on the undefined behaviour. */ -void +static void assert_times(intmax_t a, intmax_t b, volatile intmax_t r) { /* @@ -478,7 +478,7 @@ assert_times(intmax_t a, intmax_t b, volatile intmax_t r) errx(ERR_EXIT, "overflow"); } -struct val * +static struct val * op_times(struct val *a, struct val *b) { struct val *r; @@ -493,7 +493,7 @@ op_times(struct val *a, struct val *b) return (r); } -void +static void assert_div(intmax_t a, intmax_t b) { if (b == 0) @@ -503,7 +503,7 @@ assert_div(intmax_t a, intmax_t b) errx(ERR_EXIT, "overflow"); } -struct val * +static struct val * op_div(struct val *a, struct val *b) { struct val *r; @@ -519,7 +519,7 @@ op_div(struct val *a, struct val *b) return (r); } -struct val * +static struct val * op_rem(struct val *a, struct val *b) { struct val *r; @@ -535,7 +535,7 @@ op_rem(struct val *a, struct val *b) return (r); } -struct val * +static struct val * op_colon(struct val *a, struct val *b) { regex_t rp;