diff options
Diffstat (limited to 'contrib/awk/awklib/eg/lib')
-rw-r--r-- | contrib/awk/awklib/eg/lib/assert.awk | 20 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/bits2str.awk | 16 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/cliff_rand.awk | 14 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/ctime.awk | 11 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/ftrans.awk | 15 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/getopt.awk | 80 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/gettime.awk | 62 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/grcat.c | 34 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/groupawk.in | 87 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/join.awk | 16 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/libintl.awk | 9 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/mktime.awk | 105 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/nextfile.awk | 16 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/noassign.awk | 17 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/ord.awk | 44 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/passwdawk.in | 63 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/pwcat.c | 28 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/readable.awk | 16 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/rewind.awk | 20 | ||||
-rw-r--r-- | contrib/awk/awklib/eg/lib/round.awk | 32 |
20 files changed, 0 insertions, 705 deletions
diff --git a/contrib/awk/awklib/eg/lib/assert.awk b/contrib/awk/awklib/eg/lib/assert.awk deleted file mode 100644 index bbfc0669bb79f..0000000000000 --- a/contrib/awk/awklib/eg/lib/assert.awk +++ /dev/null @@ -1,20 +0,0 @@ -# assert --- assert that a condition is true. Otherwise exit. - -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# May, 1993 - -function assert(condition, string) -{ - if (! condition) { - printf("%s:%d: assertion failed: %s\n", - FILENAME, FNR, string) > "/dev/stderr" - _assert_exit = 1 - exit 1 - } -} - -END { - if (_assert_exit) - exit 1 -} diff --git a/contrib/awk/awklib/eg/lib/bits2str.awk b/contrib/awk/awklib/eg/lib/bits2str.awk deleted file mode 100644 index 9725ee8fa7d07..0000000000000 --- a/contrib/awk/awklib/eg/lib/bits2str.awk +++ /dev/null @@ -1,16 +0,0 @@ -# bits2str --- turn a byte into readable 1's and 0's - -function bits2str(bits, data, mask) -{ - if (bits == 0) - return "0" - - mask = 1 - for (; bits != 0; bits = rshift(bits, 1)) - data = (and(bits, mask) ? "1" : "0") data - - while ((length(data) % 8) != 0) - data = "0" data - - return data -} diff --git a/contrib/awk/awklib/eg/lib/cliff_rand.awk b/contrib/awk/awklib/eg/lib/cliff_rand.awk deleted file mode 100644 index 345447ec82a97..0000000000000 --- a/contrib/awk/awklib/eg/lib/cliff_rand.awk +++ /dev/null @@ -1,14 +0,0 @@ -# cliff_rand.awk --- generate Cliff random numbers -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# December 2000 - -BEGIN { _cliff_seed = 0.1 } - -function cliff_rand() -{ - _cliff_seed = (100 * log(_cliff_seed)) % 1 - if (_cliff_seed < 0) - _cliff_seed = - _cliff_seed - return _cliff_seed -} diff --git a/contrib/awk/awklib/eg/lib/ctime.awk b/contrib/awk/awklib/eg/lib/ctime.awk deleted file mode 100644 index 0a50d262428d6..0000000000000 --- a/contrib/awk/awklib/eg/lib/ctime.awk +++ /dev/null @@ -1,11 +0,0 @@ -# ctime.awk -# -# awk version of C ctime(3) function - -function ctime(ts, format) -{ - format = "%a %b %d %H:%M:%S %Z %Y" - if (ts == 0) - ts = systime() # use current time as default - return strftime(format, ts) -} diff --git a/contrib/awk/awklib/eg/lib/ftrans.awk b/contrib/awk/awklib/eg/lib/ftrans.awk deleted file mode 100644 index b0743e2889bf5..0000000000000 --- a/contrib/awk/awklib/eg/lib/ftrans.awk +++ /dev/null @@ -1,15 +0,0 @@ -# ftrans.awk --- handle data file transitions -# -# user supplies beginfile() and endfile() functions -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# November 1992 - -FNR == 1 { - if (_filename_ != "") - endfile(_filename_) - _filename_ = FILENAME - beginfile(FILENAME) -} - -END { endfile(_filename_) } diff --git a/contrib/awk/awklib/eg/lib/getopt.awk b/contrib/awk/awklib/eg/lib/getopt.awk deleted file mode 100644 index 93753052eef12..0000000000000 --- a/contrib/awk/awklib/eg/lib/getopt.awk +++ /dev/null @@ -1,80 +0,0 @@ -# getopt.awk --- do C library getopt(3) function in awk -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# -# Initial version: March, 1991 -# Revised: May, 1993 - -# External variables: -# Optind -- index in ARGV of first non-option argument -# Optarg -- string value of argument to current option -# Opterr -- if nonzero, print our own diagnostic -# Optopt -- current option letter - -# Returns: -# -1 at end of options -# ? for unrecognized option -# <c> a character representing the current option - -# Private Data: -# _opti -- index in multi-flag option, e.g., -abc -function getopt(argc, argv, options, thisopt, i) -{ - if (length(options) == 0) # no options given - return -1 - - if (argv[Optind] == "--") { # all done - Optind++ - _opti = 0 - return -1 - } else if (argv[Optind] !~ /^-[^: \t\n\f\r\v\b]/) { - _opti = 0 - return -1 - } - if (_opti == 0) - _opti = 2 - thisopt = substr(argv[Optind], _opti, 1) - Optopt = thisopt - i = index(options, thisopt) - if (i == 0) { - if (Opterr) - printf("%c -- invalid option\n", - thisopt) > "/dev/stderr" - if (_opti >= length(argv[Optind])) { - Optind++ - _opti = 0 - } else - _opti++ - return "?" - } - if (substr(options, i + 1, 1) == ":") { - # get option argument - if (length(substr(argv[Optind], _opti + 1)) > 0) - Optarg = substr(argv[Optind], _opti + 1) - else - Optarg = argv[++Optind] - _opti = 0 - } else - Optarg = "" - if (_opti == 0 || _opti >= length(argv[Optind])) { - Optind++ - _opti = 0 - } else - _opti++ - return thisopt -} -BEGIN { - Opterr = 1 # default is to diagnose - Optind = 1 # skip ARGV[0] - - # test program - if (_getopt_test) { - while ((_go_c = getopt(ARGC, ARGV, "ab:cd")) != -1) - printf("c = <%c>, optarg = <%s>\n", - _go_c, Optarg) - printf("non-option arguments:\n") - for (; Optind < ARGC; Optind++) - printf("\tARGV[%d] = <%s>\n", - Optind, ARGV[Optind]) - } -} diff --git a/contrib/awk/awklib/eg/lib/gettime.awk b/contrib/awk/awklib/eg/lib/gettime.awk deleted file mode 100644 index c425123c62686..0000000000000 --- a/contrib/awk/awklib/eg/lib/gettime.awk +++ /dev/null @@ -1,62 +0,0 @@ -# gettimeofday.awk --- get the time of day in a usable format -# -# Arnold Robbins, arnold@gnu.org, Public Domain, May 1993 -# - -# Returns a string in the format of output of date(1) -# Populates the array argument time with individual values: -# time["second"] -- seconds (0 - 59) -# time["minute"] -- minutes (0 - 59) -# time["hour"] -- hours (0 - 23) -# time["althour"] -- hours (0 - 12) -# time["monthday"] -- day of month (1 - 31) -# time["month"] -- month of year (1 - 12) -# time["monthname"] -- name of the month -# time["shortmonth"] -- short name of the month -# time["year"] -- year modulo 100 (0 - 99) -# time["fullyear"] -- full year -# time["weekday"] -- day of week (Sunday = 0) -# time["altweekday"] -- day of week (Monday = 0) -# time["dayname"] -- name of weekday -# time["shortdayname"] -- short name of weekday -# time["yearday"] -- day of year (0 - 365) -# time["timezone"] -- abbreviation of timezone name -# time["ampm"] -- AM or PM designation -# time["weeknum"] -- week number, Sunday first day -# time["altweeknum"] -- week number, Monday first day - -function gettimeofday(time, ret, now, i) -{ - # get time once, avoids unnecessary system calls - now = systime() - - # return date(1)-style output - ret = strftime("%a %b %d %H:%M:%S %Z %Y", now) - - # clear out target array - delete time - - # fill in values, force numeric values to be - # numeric by adding 0 - time["second"] = strftime("%S", now) + 0 - time["minute"] = strftime("%M", now) + 0 - time["hour"] = strftime("%H", now) + 0 - time["althour"] = strftime("%I", now) + 0 - time["monthday"] = strftime("%d", now) + 0 - time["month"] = strftime("%m", now) + 0 - time["monthname"] = strftime("%B", now) - time["shortmonth"] = strftime("%b", now) - time["year"] = strftime("%y", now) + 0 - time["fullyear"] = strftime("%Y", now) + 0 - time["weekday"] = strftime("%w", now) + 0 - time["altweekday"] = strftime("%u", now) + 0 - time["dayname"] = strftime("%A", now) - time["shortdayname"] = strftime("%a", now) - time["yearday"] = strftime("%j", now) + 0 - time["timezone"] = strftime("%Z", now) - time["ampm"] = strftime("%p", now) - time["weeknum"] = strftime("%U", now) + 0 - time["altweeknum"] = strftime("%W", now) + 0 - - return ret -} diff --git a/contrib/awk/awklib/eg/lib/grcat.c b/contrib/awk/awklib/eg/lib/grcat.c deleted file mode 100644 index d34ddd560b653..0000000000000 --- a/contrib/awk/awklib/eg/lib/grcat.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * grcat.c - * - * Generate a printable version of the group database - */ -/* - * Arnold Robbins, arnold@gnu.org, May 1993 - * Public Domain - */ - -#include <stdio.h> -#include <grp.h> - -int -main(argc, argv) -int argc; -char **argv; -{ - struct group *g; - int i; - - while ((g = getgrent()) != NULL) { - printf("%s:%s:%d:", g->gr_name, g->gr_passwd, - g->gr_gid); - for (i = 0; g->gr_mem[i] != NULL; i++) { - printf("%s", g->gr_mem[i]); - if (g->gr_mem[i+1] != NULL) - putchar(','); - } - putchar('\n'); - } - endgrent(); - exit(0); -} diff --git a/contrib/awk/awklib/eg/lib/groupawk.in b/contrib/awk/awklib/eg/lib/groupawk.in deleted file mode 100644 index 9d8b402197e23..0000000000000 --- a/contrib/awk/awklib/eg/lib/groupawk.in +++ /dev/null @@ -1,87 +0,0 @@ -# group.awk --- functions for dealing with the group file -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# May 1993 -# Revised October 2000 - -BEGIN \ -{ - # Change to suit your system - _gr_awklib = "/usr/local/libexec/awk/" -} - -function _gr_init( oldfs, oldrs, olddol0, grcat, - using_fw, n, a, i) -{ - if (_gr_inited) - return - - oldfs = FS - oldrs = RS - olddol0 = $0 - using_fw = (PROCINFO["FS"] == "FIELDWIDTHS") - FS = ":" - RS = "\n" - - grcat = _gr_awklib "grcat" - while ((grcat | getline) > 0) { - if ($1 in _gr_byname) - _gr_byname[$1] = _gr_byname[$1] "," $4 - else - _gr_byname[$1] = $0 - if ($3 in _gr_bygid) - _gr_bygid[$3] = _gr_bygid[$3] "," $4 - else - _gr_bygid[$3] = $0 - - n = split($4, a, "[ \t]*,[ \t]*") - for (i = 1; i <= n; i++) - if (a[i] in _gr_groupsbyuser) - _gr_groupsbyuser[a[i]] = \ - _gr_groupsbyuser[a[i]] " " $1 - else - _gr_groupsbyuser[a[i]] = $1 - - _gr_bycount[++_gr_count] = $0 - } - close(grcat) - _gr_count = 0 - _gr_inited++ - FS = oldfs - if (using_fw) - FIELDWIDTHS = FIELDWIDTHS - RS = oldrs - $0 = olddol0 -} -function getgrnam(group) -{ - _gr_init() - if (group in _gr_byname) - return _gr_byname[group] - return "" -} -function getgrgid(gid) -{ - _gr_init() - if (gid in _gr_bygid) - return _gr_bygid[gid] - return "" -} -function getgruser(user) -{ - _gr_init() - if (user in _gr_groupsbyuser) - return _gr_groupsbyuser[user] - return "" -} -function getgrent() -{ - _gr_init() - if (++_gr_count in _gr_bycount) - return _gr_bycount[_gr_count] - return "" -} -function endgrent() -{ - _gr_count = 0 -} diff --git a/contrib/awk/awklib/eg/lib/join.awk b/contrib/awk/awklib/eg/lib/join.awk deleted file mode 100644 index e17b4270ca38e..0000000000000 --- a/contrib/awk/awklib/eg/lib/join.awk +++ /dev/null @@ -1,16 +0,0 @@ -# join.awk --- join an array into a string -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# May 1993 - -function join(array, start, end, sep, result, i) -{ - if (sep == "") - sep = " " - else if (sep == SUBSEP) # magic value - sep = "" - result = array[start] - for (i = start + 1; i <= end; i++) - result = result sep array[i] - return result -} diff --git a/contrib/awk/awklib/eg/lib/libintl.awk b/contrib/awk/awklib/eg/lib/libintl.awk deleted file mode 100644 index a9402c2af9fa8..0000000000000 --- a/contrib/awk/awklib/eg/lib/libintl.awk +++ /dev/null @@ -1,9 +0,0 @@ -function bindtextdomain(dir, domain) -{ - return dir -} - -function dcgettext(string, domain, category) -{ - return string -} diff --git a/contrib/awk/awklib/eg/lib/mktime.awk b/contrib/awk/awklib/eg/lib/mktime.awk deleted file mode 100644 index 57ff20e53aedd..0000000000000 --- a/contrib/awk/awklib/eg/lib/mktime.awk +++ /dev/null @@ -1,105 +0,0 @@ -# mktime.awk --- convert a canonical date representation -# into a timestamp -# Arnold Robbins, arnold@gnu.org, Public Domain -# May 1993 - -BEGIN \ -{ - # Initialize table of month lengths - _tm_months[0,1] = _tm_months[1,1] = 31 - _tm_months[0,2] = 28; _tm_months[1,2] = 29 - _tm_months[0,3] = _tm_months[1,3] = 31 - _tm_months[0,4] = _tm_months[1,4] = 30 - _tm_months[0,5] = _tm_months[1,5] = 31 - _tm_months[0,6] = _tm_months[1,6] = 30 - _tm_months[0,7] = _tm_months[1,7] = 31 - _tm_months[0,8] = _tm_months[1,8] = 31 - _tm_months[0,9] = _tm_months[1,9] = 30 - _tm_months[0,10] = _tm_months[1,10] = 31 - _tm_months[0,11] = _tm_months[1,11] = 30 - _tm_months[0,12] = _tm_months[1,12] = 31 -} -# decide if a year is a leap year -function _tm_isleap(year, ret) -{ - ret = (year % 4 == 0 && year % 100 != 0) || - (year % 400 == 0) - - return ret -} -# convert a date into seconds -function _tm_addup(a, total, yearsecs, daysecs, - hoursecs, i, j) -{ - hoursecs = 60 * 60 - daysecs = 24 * hoursecs - yearsecs = 365 * daysecs - - total = (a[1] - 1970) * yearsecs - - # extra day for leap years - for (i = 1970; i < a[1]; i++) - if (_tm_isleap(i)) - total += daysecs - - j = _tm_isleap(a[1]) - for (i = 1; i < a[2]; i++) - total += _tm_months[j, i] * daysecs - - total += (a[3] - 1) * daysecs - total += a[4] * hoursecs - total += a[5] * 60 - total += a[6] - - return total -} -# mktime --- convert a date into seconds, -# compensate for time zone - -function mktime(str, res1, res2, a, b, i, j, t, diff) -{ - i = split(str, a, " ") # don't rely on FS - - if (i != 6) - return -1 - - # force numeric - for (j in a) - a[j] += 0 - - # validate - if (a[1] < 1970 || - a[2] < 1 || a[2] > 12 || - a[3] < 1 || a[3] > 31 || - a[4] < 0 || a[4] > 23 || - a[5] < 0 || a[5] > 59 || - a[6] < 0 || a[6] > 60 ) - return -1 - - res1 = _tm_addup(a) - t = strftime("%Y %m %d %H %M %S", res1) - - if (_tm_debug) - printf("(%s) -> (%s)\n", str, t) > "/dev/stderr" - - split(t, b, " ") - res2 = _tm_addup(b) - - diff = res1 - res2 - - if (_tm_debug) - printf("diff = %d seconds\n", diff) > "/dev/stderr" - - res1 += diff - - return res1 -} -BEGIN { - if (_tm_test) { - printf "Enter date as yyyy mm dd hh mm ss: " - getline _tm_test_date - t = mktime(_tm_test_date) - r = strftime("%Y %m %d %H %M %S", t) - printf "Got back (%s)\n", r - } -} diff --git a/contrib/awk/awklib/eg/lib/nextfile.awk b/contrib/awk/awklib/eg/lib/nextfile.awk deleted file mode 100644 index caedf0e478e30..0000000000000 --- a/contrib/awk/awklib/eg/lib/nextfile.awk +++ /dev/null @@ -1,16 +0,0 @@ -# nextfile --- skip remaining records in current file -# correctly handle successive occurrences of the same file -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# May, 1993 - -# this should be read in before the "main" awk program - -function nextfile() { _abandon_ = FILENAME; next } - -_abandon_ == FILENAME { - if (FNR == 1) - _abandon_ = "" - else - next -} diff --git a/contrib/awk/awklib/eg/lib/noassign.awk b/contrib/awk/awklib/eg/lib/noassign.awk deleted file mode 100644 index d6d176e40e9d3..0000000000000 --- a/contrib/awk/awklib/eg/lib/noassign.awk +++ /dev/null @@ -1,17 +0,0 @@ -# noassign.awk --- library file to avoid the need for a -# special option that disables command-line assignments -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# October 1999 - -function disable_assigns(argc, argv, i) -{ - for (i = 1; i < argc; i++) - if (argv[i] ~ /^[A-Za-z_][A-Za-z_0-9]*=.*/) - argv[i] = ("./" argv[i]) -} - -BEGIN { - if (No_command_assign) - disable_assigns(ARGC, ARGV) -} diff --git a/contrib/awk/awklib/eg/lib/ord.awk b/contrib/awk/awklib/eg/lib/ord.awk deleted file mode 100644 index 3eacbcc576dc3..0000000000000 --- a/contrib/awk/awklib/eg/lib/ord.awk +++ /dev/null @@ -1,44 +0,0 @@ -# ord.awk --- do ord and chr - -# Global identifiers: -# _ord_: numerical values indexed by characters -# _ord_init: function to initialize _ord_ -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# 16 January, 1992 -# 20 July, 1992, revised - -BEGIN { _ord_init() } - -function _ord_init( low, high, i, t) -{ - low = sprintf("%c", 7) # BEL is ascii 7 - if (low == "\a") { # regular ascii - low = 0 - high = 127 - } else if (sprintf("%c", 128 + 7) == "\a") { - # ascii, mark parity - low = 128 - high = 255 - } else { # ebcdic(!) - low = 0 - high = 255 - } - - for (i = low; i <= high; i++) { - t = sprintf("%c", i) - _ord_[t] = i - } -} -function ord(str, c) -{ - # only first character is of interest - c = substr(str, 1, 1) - return _ord_[c] -} - -function chr(c) -{ - # force c to be numeric by adding 0 - return sprintf("%c", c + 0) -} diff --git a/contrib/awk/awklib/eg/lib/passwdawk.in b/contrib/awk/awklib/eg/lib/passwdawk.in deleted file mode 100644 index 5f6f9e2657fb3..0000000000000 --- a/contrib/awk/awklib/eg/lib/passwdawk.in +++ /dev/null @@ -1,63 +0,0 @@ -# passwd.awk --- access password file information -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# May 1993 -# Revised October 2000 - -BEGIN { - # tailor this to suit your system - _pw_awklib = "/usr/local/libexec/awk/" -} - -function _pw_init( oldfs, oldrs, olddol0, pwcat, using_fw) -{ - if (_pw_inited) - return - - oldfs = FS - oldrs = RS - olddol0 = $0 - using_fw = (PROCINFO["FS"] == "FIELDWIDTHS") - FS = ":" - RS = "\n" - - pwcat = _pw_awklib "pwcat" - while ((pwcat | getline) > 0) { - _pw_byname[$1] = $0 - _pw_byuid[$3] = $0 - _pw_bycount[++_pw_total] = $0 - } - close(pwcat) - _pw_count = 0 - _pw_inited = 1 - FS = oldfs - if (using_fw) - FIELDWIDTHS = FIELDWIDTHS - RS = oldrs - $0 = olddol0 -} -function getpwnam(name) -{ - _pw_init() - if (name in _pw_byname) - return _pw_byname[name] - return "" -} -function getpwuid(uid) -{ - _pw_init() - if (uid in _pw_byuid) - return _pw_byuid[uid] - return "" -} -function getpwent() -{ - _pw_init() - if (_pw_count < _pw_total) - return _pw_bycount[++_pw_count] - return "" -} -function endpwent() -{ - _pw_count = 0 -} diff --git a/contrib/awk/awklib/eg/lib/pwcat.c b/contrib/awk/awklib/eg/lib/pwcat.c deleted file mode 100644 index b9a71340a43ed..0000000000000 --- a/contrib/awk/awklib/eg/lib/pwcat.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * pwcat.c - * - * Generate a printable version of the password database - */ -/* - * Arnold Robbins, arnold@gnu.org, May 1993 - * Public Domain - */ - -#include <stdio.h> -#include <pwd.h> - -int -main(argc, argv) -int argc; -char **argv; -{ - struct passwd *p; - - while ((p = getpwent()) != NULL) - printf("%s:%s:%d:%d:%s:%s:%s\n", - p->pw_name, p->pw_passwd, p->pw_uid, - p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell); - - endpwent(); - exit(0); -} diff --git a/contrib/awk/awklib/eg/lib/readable.awk b/contrib/awk/awklib/eg/lib/readable.awk deleted file mode 100644 index 51705aea0a56a..0000000000000 --- a/contrib/awk/awklib/eg/lib/readable.awk +++ /dev/null @@ -1,16 +0,0 @@ -# readable.awk --- library file to skip over unreadable files -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# October 2000 - -BEGIN { - for (i = 1; i < ARGC; i++) { - if (ARGV[i] ~ /^[A-Za-z_][A-Za-z0-9_]*=.*/ \ - || ARGV[i] == "-") - continue # assignment or standard input - else if ((getline junk < ARGV[i]) < 0) # unreadable - delete ARGV[i] - else - close(ARGV[i]) - } -} diff --git a/contrib/awk/awklib/eg/lib/rewind.awk b/contrib/awk/awklib/eg/lib/rewind.awk deleted file mode 100644 index 33286611341cf..0000000000000 --- a/contrib/awk/awklib/eg/lib/rewind.awk +++ /dev/null @@ -1,20 +0,0 @@ -# rewind.awk --- rewind the current file and start over -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# September 2000 - -function rewind( i) -{ - # shift remaining arguments up - for (i = ARGC; i > ARGIND; i--) - ARGV[i] = ARGV[i-1] - - # make sure gawk knows to keep going - ARGC++ - - # make current file next to get done - ARGV[ARGIND+1] = FILENAME - - # do it - nextfile -} diff --git a/contrib/awk/awklib/eg/lib/round.awk b/contrib/awk/awklib/eg/lib/round.awk deleted file mode 100644 index bf16c2b649029..0000000000000 --- a/contrib/awk/awklib/eg/lib/round.awk +++ /dev/null @@ -1,32 +0,0 @@ -# round --- do normal rounding -# -# Arnold Robbins, arnold@gnu.org, Public Domain -# August, 1996 - -function round(x, ival, aval, fraction) -{ - ival = int(x) # integer part, int() truncates - - # see if fractional part - if (ival == x) # no fraction - return x - - if (x < 0) { - aval = -x # absolute value - ival = int(aval) - fraction = aval - ival - if (fraction >= .5) - return int(x) - 1 # -2.5 --> -3 - else - return int(x) # -2.3 --> -2 - } else { - fraction = x - ival - if (fraction >= .5) - return ival + 1 - else - return ival - } -} - -# test harness -{ print $0, round($0) } |