summaryrefslogtreecommitdiffstats
path: root/bin/sh/arith.y
diff options
context:
space:
mode:
Diffstat (limited to 'bin/sh/arith.y')
-rw-r--r--bin/sh/arith.y22
1 files changed, 13 insertions, 9 deletions
diff --git a/bin/sh/arith.y b/bin/sh/arith.y
index 391cc16..542fc44 100644
--- a/bin/sh/arith.y
+++ b/bin/sh/arith.y
@@ -75,7 +75,10 @@ __FBSDID("$FreeBSD$");
exp:
expr
- { return ($1); }
+ {
+ *YYPARSE_PARAM = $1;
+ return (0);
+ }
;
expr:
@@ -259,12 +262,13 @@ expr:
#include "output.h"
#include "memalloc.h"
-#define lstrlen(var) (3 + (2 + CHAR_BIT * sizeof((var))) / 3)
+#define YYPARSE_PARAM_TYPE arith_t *
+#define YYPARSE_PARAM result
char *arith_buf, *arith_startbuf;
int yylex(void);
-int yyparse(void);
+int yyparse(YYPARSE_PARAM_TYPE);
static int
arith_assign(char *name, arith_t value)
@@ -272,22 +276,22 @@ arith_assign(char *name, arith_t value)
char *str;
int ret;
- str = (char *)ckmalloc(lstrlen(value));
+ str = (char *)ckmalloc(DIGITS(value));
sprintf(str, ARITH_FORMAT_STR, value);
ret = setvarsafe(name, str, 0);
free(str);
return ret;
}
-int
+arith_t
arith(char *s)
{
- long result;
+ arith_t result;
arith_buf = arith_startbuf = s;
INTOFF;
- result = yyparse();
+ yyparse(&result);
arith_lex_reset(); /* Reprime lex. */
INTON;
@@ -313,7 +317,7 @@ expcmd(int argc, char **argv)
char *p;
char *concat;
char **ap;
- long i;
+ arith_t i;
if (argc > 1) {
p = argv[1];
@@ -338,7 +342,7 @@ expcmd(int argc, char **argv)
i = arith(p);
- out1fmt("%ld\n", i);
+ out1fmt(ARITH_FORMAT_STR "\n", i);
return !i;
}
OpenPOWER on IntegriCloud