summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/arith_yacc.c2
-rw-r--r--src/options.c5
-rw-r--r--src/var.c4
-rw-r--r--src/var.h2
4 files changed, 6 insertions, 7 deletions
diff --git a/src/arith_yacc.c b/src/arith_yacc.c
index ad653ed..e473594 100644
--- a/src/arith_yacc.c
+++ b/src/arith_yacc.c
@@ -280,7 +280,7 @@ static intmax_t assignment(int var, int noeval)
 
 	return setvarint(val.name,
 			 op == ARITH_ASS ? result :
-			 do_binop(op - 11, lookupvarint(val.name), result));
+			 do_binop(op - 11, lookupvarint(val.name), result), 0);
 }
 
 intmax_t arith(const char *s)
diff --git a/src/options.c b/src/options.c
index 568148a..f669117 100644
--- a/src/options.c
+++ b/src/options.c
@@ -419,7 +419,7 @@ getopts(char *optstr, char *optvar, char **optfirst)
 	char *p, *q;
 	char c = '?';
 	int done = 0;
-	char s[12];
+	char s[2];
 	char **optnext;
 	int ind = shellparam.optind;
 	int off = shellparam.optoff;
@@ -487,8 +487,7 @@ atend:
 
 out:
 	ind = optnext - optfirst + 1;
-	fmtstr(s, sizeof(s), "%d", ind);
-	setvar("OPTIND", s, VNOFUNC);
+	setvarint("OPTIND", ind, VNOFUNC);
 	s[0] = c;
 	s[1] = '\0';
 	setvar(optvar, s, 0);
diff --git a/src/var.c b/src/var.c
index 17d3637..7f9af9c 100644
--- a/src/var.c
+++ b/src/var.c
@@ -207,13 +207,13 @@ setvar(const char *name, const char *val, int flags)
  * ored with the flags of the variable.
  */
 
-intmax_t setvarint(const char *name, intmax_t val)
+intmax_t setvarint(const char *name, intmax_t val, int flags)
 {
 	int len = max_int_length(sizeof(val));
 	char buf[len];
 
 	fmtstr(buf, len, "%jd", val);
-	setvar(name, buf, 0);
+	setvar(name, buf, flags);
 	return val;
 }
 
diff --git a/src/var.h b/src/var.h
index 66443df..e4e2cff 100644
--- a/src/var.h
+++ b/src/var.h
@@ -127,7 +127,7 @@ extern const char defpathvar[];
 
 void initvar(void);
 void setvar(const char *, const char *, int);
-intmax_t setvarint(const char *, intmax_t);
+intmax_t setvarint(const char *, intmax_t, int);
 void setvareq(char *, int);
 struct strlist;
 void listsetvar(struct strlist *, int);