diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2021-06-23 20:31:44 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2021-06-23 20:31:44 +0300 |
commit | b5d29eae198241ca46fc3cf4f2d6b725bb22e6d2 (patch) | |
tree | bf126af12789c7daa996f9ea652ff8f46593285f /awklib | |
parent | 0c673e1a2f6b05cc68087dcd67ee4a0ac21f6ca7 (diff) | |
parent | 98ef29fdcadffc0a05c91883c4ab8809a8b0d441 (diff) | |
download | egawk-b5d29eae198241ca46fc3cf4f2d6b725bb22e6d2.tar.gz egawk-b5d29eae198241ca46fc3cf4f2d6b725bb22e6d2.tar.bz2 egawk-b5d29eae198241ca46fc3cf4f2d6b725bb22e6d2.zip |
Merge branch 'gawk-5.1-stable'
Diffstat (limited to 'awklib')
-rw-r--r-- | awklib/eg/lib/isnumeric.awk | 19 | ||||
-rw-r--r-- | awklib/eg/prog/split.awk | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/awklib/eg/lib/isnumeric.awk b/awklib/eg/lib/isnumeric.awk new file mode 100644 index 00000000..c2699022 --- /dev/null +++ b/awklib/eg/lib/isnumeric.awk @@ -0,0 +1,19 @@ +# isnumeric --- check whether a value is numeric + +function isnumeric(x, f) +{ + switch (typeof(x)) { + case "strnum": + case "number": + return 1 + case "string": + return (split(x, f, " ") == 1) && (typeof(f[1]) == "strnum") + default: + return 0 + } +} + +Please note that leading or trailing white space is disregarded in deciding +whether a value is numeric or not, so if it matters to you, you may want +to add an additional check for that. + diff --git a/awklib/eg/prog/split.awk b/awklib/eg/prog/split.awk index 16780044..4804de5f 100644 --- a/awklib/eg/prog/split.awk +++ b/awklib/eg/prog/split.awk @@ -8,7 +8,7 @@ # Rewritten September 2020 -function usage( common) +function usage( common) { common = "[-a suffix-len] [file [outname]]" printf("usage: split [-l count] %s\n", common) > "/dev/stderr" |