aboutsummaryrefslogtreecommitdiffstats
path: root/awklib/eg/lib
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-08-29 13:11:45 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-08-29 13:11:45 +0300
commit6c541fd0f75cd328dd80afec757ecccc833719af (patch)
tree163707da9efd9c8d0c7a7e9d0ef3887222c88bf3 /awklib/eg/lib
parentff28c07f95ff2400eb0ad1becc0eae1eab9dc93d (diff)
downloadegawk-6c541fd0f75cd328dd80afec757ecccc833719af.tar.gz
egawk-6c541fd0f75cd328dd80afec757ecccc833719af.tar.bz2
egawk-6c541fd0f75cd328dd80afec757ecccc833719af.zip
More doc updates.
Diffstat (limited to 'awklib/eg/lib')
-rw-r--r--awklib/eg/lib/getopt.awk3
-rw-r--r--awklib/eg/lib/strtonum.awk7
2 files changed, 6 insertions, 4 deletions
diff --git a/awklib/eg/lib/getopt.awk b/awklib/eg/lib/getopt.awk
index db957ceb..6b1f4c50 100644
--- a/awklib/eg/lib/getopt.awk
+++ b/awklib/eg/lib/getopt.awk
@@ -38,8 +38,7 @@ function getopt(argc, argv, options, thisopt, i)
i = index(options, thisopt)
if (i == 0) {
if (Opterr)
- printf("%c -- invalid option\n",
- thisopt) > "/dev/stderr"
+ printf("%c -- invalid option\n", thisopt) > "/dev/stderr"
if (_opti >= length(argv[Optind])) {
Optind++
_opti = 0
diff --git a/awklib/eg/lib/strtonum.awk b/awklib/eg/lib/strtonum.awk
index 9342e789..5e20626b 100644
--- a/awklib/eg/lib/strtonum.awk
+++ b/awklib/eg/lib/strtonum.awk
@@ -13,8 +13,9 @@ function mystrtonum(str, ret, n, i, k, c)
ret = 0
for (i = 1; i <= n; i++) {
c = substr(str, i, 1)
- if ((k = index("01234567", c)) > 0)
- k-- # adjust for 1-basing in awk
+ # index() returns 0 if c not in string,
+ # includes c == "0"
+ k = index("1234567", c)
ret = ret * 8 + k
}
@@ -26,6 +27,8 @@ function mystrtonum(str, ret, n, i, k, c)
for (i = 1; i <= n; i++) {
c = substr(str, i, 1)
c = tolower(c)
+ # index() returns 0 if c not in string,
+ # includes c == "0"
k = index("123456789abcdef", c)
ret = ret * 16 + k