aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2021-01-09 22:24:07 +0200
committerArnold D. Robbins <arnold@skeeve.com>2021-01-09 22:24:07 +0200
commit3aa6709272d6c74300b70d8371b135289a8d8c9d (patch)
treea1c901c1859db9c7933994f0a37b56f33a6d684e /builtin.c
parent5b3ac78d72621697e717765d2d634d7fc271f3c9 (diff)
downloadegawk-3aa6709272d6c74300b70d8371b135289a8d8c9d.tar.gz
egawk-3aa6709272d6c74300b70d8371b135289a8d8c9d.tar.bz2
egawk-3aa6709272d6c74300b70d8371b135289a8d8c9d.zip
Fix conversion of 018 to decimal. Add a test.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin.c b/builtin.c
index fc5dc31e..e28c35ef 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-2020,
+ * Copyright (C) 1986, 1988, 1989, 1991-2021,
* the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
@@ -3684,7 +3684,9 @@ nondec2awknum(char *str, size_t len, char **endptr)
if (endptr)
*endptr = str;
} else if (len >= 1 && *str == '0') {
- for (; len > 0; len--) {
+ int l;
+ // preserve len in case we go to decimal
+ for (l = len; l > 0; l--) {
if (! isdigit((unsigned char) *str)) {
if (endptr)
*endptr = str;