aboutsummaryrefslogtreecommitdiffstats
path: root/doc/gawktexi.in
diff options
context:
space:
mode:
Diffstat (limited to 'doc/gawktexi.in')
-rw-r--r--doc/gawktexi.in33
1 files changed, 19 insertions, 14 deletions
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 81a24079..236ef638 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -22168,7 +22168,7 @@ function shell_quote(s, # parameter
@end example
@node Isnumeric Function
-@subsection Checking whether a value is numeric
+@subsection Checking Whether A Value Is Numeric
A frequent programming question is how to ascertain whether a value is numeric.
This can be solved by using this example function @code{isnumeric()}, which
@@ -22183,16 +22183,21 @@ employs the trick of converting a string value to user input by using the
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
- @}
+ 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.
+
@c endfile
@end example
@@ -23037,8 +23042,8 @@ $ @kbd{awk -f getopt.awk -v _getopt_test=1 -- -a \}
@print{} c = <otherd>, Optarg = <>
@print{} c = <otherc>, Optarg = <>
@print{} non-option arguments:
-@print{} ARGV[8] = <arg1>
-@print{} ARGV[9] = <arg2>
+@print{} ARGV[8] = <arg1>
+@print{} ARGV[9] = <arg2>
@end example
In all the runs, the first @option{--} terminates the arguments to
@@ -25235,7 +25240,7 @@ look nice on the page:
@end ignore
@c file eg/prog/split.awk
-function usage( common)
+function usage( common)
@{
common = "[-a suffix-len] [file [outname]]"
printf("usage: split [-l count] %s\n", common) > "/dev/stderr"
@@ -29068,7 +29073,7 @@ main(void)
printf("%d\n", x + y);
return 0;
@}
-$ @kbd{cc -O add.c -o add} @ii{Compile the program}
+$ @kbd{cc -O add.c -o add} @ii{Compile the program}
@end example
You could then write an exceedingly simple @command{gawk} program