diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-12-15 23:33:49 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-12-15 23:33:49 +0200 |
commit | edfb721ac785219e9b881d8ac3a841cef8270a79 (patch) | |
tree | 896975ebdb9331b17157ea6e30f646d3e3c75df6 /awklib/eg | |
parent | 9d3481aa7472d05543df77e0b2da9077e5ab3795 (diff) | |
download | gawk-edfb721ac785219e9b881d8ac3a841cef8270a79.tar.gz |
Doc fixes.
Diffstat (limited to 'awklib/eg')
-rw-r--r-- | awklib/eg/prog/alarm.awk | 28 | ||||
-rw-r--r-- | awklib/eg/prog/cut.awk | 3 | ||||
-rw-r--r-- | awklib/eg/prog/egrep.awk | 3 | ||||
-rw-r--r-- | awklib/eg/prog/split.awk | 4 | ||||
-rw-r--r-- | awklib/eg/prog/tee.awk | 3 | ||||
-rw-r--r-- | awklib/eg/prog/uniq.awk | 5 | ||||
-rw-r--r-- | awklib/eg/prog/wc.awk | 4 |
7 files changed, 31 insertions, 19 deletions
diff --git a/awklib/eg/prog/alarm.awk b/awklib/eg/prog/alarm.awk index 52fae393..af7e8af1 100644 --- a/awklib/eg/prog/alarm.awk +++ b/awklib/eg/prog/alarm.awk @@ -1,9 +1,10 @@ # alarm.awk --- set an alarm # -# Requires gettimeofday library function +# Requires gettimeofday() library function # # Arnold Robbins, arnold@skeeve.com, Public Domain # May 1993 +# Revised December 2010 # usage: alarm time [ "message" [ count [ delay ] ] ] @@ -17,19 +18,24 @@ BEGIN \ print usage1 > "/dev/stderr" print usage2 > "/dev/stderr" exit 1 - } else if (ARGC == 5) { + } + switch (ARGC) { + case 5: delay = ARGV[4] + 0 + # fall through + case 4: count = ARGV[3] + 0 + # fall through + case 3: message = ARGV[2] - } else if (ARGC == 4) { - count = ARGV[3] + 0 - message = ARGV[2] - } else if (ARGC == 3) { - message = ARGV[2] - } else if (ARGV[1] !~ /[0-9]?[0-9]:[0-9][0-9]/) { - print usage1 > "/dev/stderr" - print usage2 > "/dev/stderr" - exit 1 + break + default: + if (ARGV[1] !~ /[[:digit:]]?[[:digit:]]:[[:digit:]][[:digit:]]/) { + print usage1 > "/dev/stderr" + print usage2 > "/dev/stderr" + exit 1 + } + break } # set defaults for once we reach the desired time diff --git a/awklib/eg/prog/cut.awk b/awklib/eg/prog/cut.awk index d9866b82..482ccd6e 100644 --- a/awklib/eg/prog/cut.awk +++ b/awklib/eg/prog/cut.awk @@ -35,7 +35,7 @@ BEGIN \ } else if (c == "d") { if (length(Optarg) > 1) { printf("Using first character of %s" \ - " for delimiter\n", Optarg) > "/dev/stderr" + " for delimiter\n", Optarg) > "/dev/stderr" Optarg = substr(Optarg, 1, 1) } FS = Optarg @@ -48,6 +48,7 @@ BEGIN \ usage() } + # Clear out options for (i = 1; i < Optind; i++) ARGV[i] = "" if (by_fields && by_chars) diff --git a/awklib/eg/prog/egrep.awk b/awklib/eg/prog/egrep.awk index b34241f8..56d199c8 100644 --- a/awklib/eg/prog/egrep.awk +++ b/awklib/eg/prog/egrep.awk @@ -54,11 +54,12 @@ function beginfile(junk) } function endfile(file) { - if (! no_print && count_only) + if (! no_print && count_only) { if (do_filenames) print file ":" fcount else print fcount + } total += fcount } diff --git a/awklib/eg/prog/split.awk b/awklib/eg/prog/split.awk index 723d7a6a..c907530b 100644 --- a/awklib/eg/prog/split.awk +++ b/awklib/eg/prog/split.awk @@ -1,6 +1,6 @@ # split.awk --- do split in awk # -# Requires ord and chr library functions +# Requires ord() and chr() library functions # # Arnold Robbins, arnold@skeeve.com, Public Domain # May 1993 @@ -14,7 +14,7 @@ BEGIN { usage() i = 1 - if (ARGV[i] ~ /^-[0-9]+$/) { + if (ARGV[i] ~ /^-[[:digit:]]+$/) { count = -ARGV[i] ARGV[i] = "" i++ diff --git a/awklib/eg/prog/tee.awk b/awklib/eg/prog/tee.awk index 82e80865..639b9f80 100644 --- a/awklib/eg/prog/tee.awk +++ b/awklib/eg/prog/tee.awk @@ -1,5 +1,8 @@ # tee.awk --- tee in awk # +# Copy standard input to all named output files. +# Append content if -a option is supplied. +# # Arnold Robbins, arnold@skeeve.com, Public Domain # May 1993 # Revised December 1995 diff --git a/awklib/eg/prog/uniq.awk b/awklib/eg/prog/uniq.awk index 0b2afa88..07d9b9e8 100644 --- a/awklib/eg/prog/uniq.awk +++ b/awklib/eg/prog/uniq.awk @@ -1,6 +1,6 @@ # uniq.awk --- do uniq in awk # -# Requires getopt and join library functions +# Requires getopt() and join() library functions # # Arnold Robbins, arnold@skeeve.com, Public Domain # May 1993 @@ -14,7 +14,7 @@ function usage( e) # -c count lines. overrides -d and -u # -d only repeated lines -# -u only non-repeated lines +# -u only nonrepeated lines # -n skip n fields # +n skip n characters, skip fields first @@ -116,4 +116,5 @@ END { else if ((repeated_only && count > 1) || (non_repeated_only && count == 1)) print last > outputfile + close(outputfile) } diff --git a/awklib/eg/prog/wc.awk b/awklib/eg/prog/wc.awk index d51b9ff2..95940ae4 100644 --- a/awklib/eg/prog/wc.awk +++ b/awklib/eg/prog/wc.awk @@ -10,10 +10,10 @@ # # Default is to count lines, words, characters # -# Requires getopt and file transition library functions +# Requires getopt() and file transition library functions BEGIN { - # let getopt print a message about + # let getopt() print a message about # invalid options. we ignore them while ((c = getopt(ARGC, ARGV, "lwc")) != -1) { if (c == "l") |