summary refs log tree commit diff
path: root/src/mystring.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-10-11 22:36:28 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2007-10-11 22:36:28 +0800
commitf6e3b2f8a59922405f42c8bc283e0f5546c25d0e (patch)
tree6f8a59c3b8f836292fda23c77b1c95eefeae9cc4 /src/mystring.c
parent[PARSER] Report substition errors at expansion time (diff)
downloaddash-f6e3b2f8a59922405f42c8bc283e0f5546c25d0e.tar.gz
dash-f6e3b2f8a59922405f42c8bc283e0f5546c25d0e.zip
[ARITH] Add assignment and intmax_t support
This patch adds assignment operator support in arithmetic expansions.  It
also changes the type used to intmax_t.
Diffstat (limited to '')
-rw-r--r--src/mystring.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mystring.c b/src/mystring.c
index df1691b..b84b7e2 100644
--- a/src/mystring.c
+++ b/src/mystring.c
@@ -112,13 +112,13 @@ prefix(const char *string, const char *pfx)
 /*
  * Convert a string into an integer of type intmax_t.  Alow trailing spaces.
  */
-intmax_t atomax10(const char *s)
+intmax_t atomax(const char *s, int base)
 {
 	char *p;
 	intmax_t r;
 
 	errno = 0;
-	r = strtoimax(s, &p, 10);
+	r = strtoimax(s, &p, base);
 
 	if (errno != 0)
 		sh_error(illnum, s);
@@ -132,6 +132,11 @@ intmax_t atomax10(const char *s)
 	return r;
 }
 
+intmax_t atomax10(const char *s)
+{
+	return atomax(s, 10);
+}
+
 /*
  * Convert a string of digits to an integer, printing an error message on
  * failure.