aboutsummaryrefslogtreecommitdiffstats
path: root/awklib
diff options
context:
space:
mode:
Diffstat (limited to 'awklib')
-rw-r--r--awklib/ChangeLog13
-rw-r--r--awklib/Makefile.in22
-rw-r--r--awklib/eg/lib/mktime.awk2
-rw-r--r--awklib/eg/lib/round.awk32
-rw-r--r--awklib/eg/prog/cut.awk2
-rw-r--r--awklib/eg/prog/wc.awk2
-rw-r--r--awklib/group.awk80
-rwxr-xr-xawklib/igawk.save120
-rw-r--r--awklib/passwd.awk56
9 files changed, 60 insertions, 269 deletions
diff --git a/awklib/ChangeLog b/awklib/ChangeLog
new file mode 100644
index 00000000..2fab5799
--- /dev/null
+++ b/awklib/ChangeLog
@@ -0,0 +1,13 @@
+Sun Oct 20 12:30:41 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Makefile.in (install): minor tweaks for portability.
+
+Fri Mar 15 06:33:38 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Makefile.in (pwcat, grcat): Add $(LDFLAGS).
+ (clean): add `*~' to list of files to be removed.
+
+Wed Jan 24 10:06:16 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Makefile.in (clean): Remove $(AUXAWK).
+ (maintainer-clean): Depend on distclean, not the other way around.
diff --git a/awklib/Makefile.in b/awklib/Makefile.in
index f5d1b95c..87209881 100644
--- a/awklib/Makefile.in
+++ b/awklib/Makefile.in
@@ -1,6 +1,6 @@
# Makefile for GNU Awk support library.
#
-# Copyright (C) 1995 the Free Software Foundation, Inc.
+# Copyright (C) 1995-1996 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
@@ -56,10 +56,10 @@ stamp-eg: $(srcdir)/../doc/gawk.texi
@echo 'against a file, so this file is a place holder. gack.' >> stamp-eg
pwcat: $(srcdir)/eg/lib/pwcat.c
- $(CC) $(CFLAGS) $(srcdir)/eg/lib/pwcat.c -o $@
+ $(CC) $(CFLAGS) $(srcdir)/eg/lib/pwcat.c $(LDFLAGS) -o $@
grcat: $(srcdir)/eg/lib/grcat.c
- $(CC) $(CFLAGS) $(srcdir)/eg/lib/grcat.c -o $@
+ $(CC) $(CFLAGS) $(srcdir)/eg/lib/grcat.c $(LDFLAGS) -o $@
igawk: $(srcdir)/eg/prog/igawk.sh
cp $(srcdir)/eg/prog/igawk.sh $@ ; chmod 755 $@
@@ -73,12 +73,12 @@ group.awk: $(srcdir)/eg/lib/groupawk.in
sed 's;/usr/local/libexec/awk;$(libexecdir);' < groupawk.in) > group.awk
install: igawk $(AUXPROGS) $(AUXAWK)
- $(INSTALL_PROGRAM) igawk $(bindir)
+ $(INSTALL_PROGRAM) igawk $(bindir)/igawk && chmod 755 $(bindir)/igawk
for i in $(AUXPROGS) ; do \
- $(INSTALL_PROGRAM) $$i $(libexecdir) ; \
+ $(INSTALL_PROGRAM) $$i $(libexecdir)/$$i ; \
done
for i in $(AUXAWK) $(srcdir)/eg/lib/*.awk ; do \
- $(INSTALL_DATA) $$i $(datadir) ; \
+ $(INSTALL_DATA) $$i $(datadir)/$$i ; \
done
# libexecdir and bindir are removed in the top level Makefile's uninstall
@@ -87,10 +87,12 @@ uninstall:
rm -f $(bindir)/igawk
clean:
- rm -f $(AUXPROGS) igawk
-
-maintainer-clean: clean
- rm -fr eg stamp-eg
+ rm -f $(AUXPROGS) $(AUXAWK) igawk *~
distclean: clean
rm -f Makefile
+
+maintainer-clean: distclean
+ @echo "This command is intended for maintainers to use; it"
+ @echo "deletes files that may require special tools to rebuild."
+ rm -fr eg stamp-eg
diff --git a/awklib/eg/lib/mktime.awk b/awklib/eg/lib/mktime.awk
index 60c5b60d..f43d6d19 100644
--- a/awklib/eg/lib/mktime.awk
+++ b/awklib/eg/lib/mktime.awk
@@ -73,7 +73,7 @@ function mktime(str, res1, res2, a, b, i, j, t, diff)
a[3] < 1 || a[3] > 31 ||
a[4] < 0 || a[4] > 23 ||
a[5] < 0 || a[5] > 59 ||
- a[6] < 0 || a[6] > 61 )
+ a[6] < 0 || a[6] > 60 )
return -1
res1 = _tm_addup(a)
diff --git a/awklib/eg/lib/round.awk b/awklib/eg/lib/round.awk
new file mode 100644
index 00000000..d484e148
--- /dev/null
+++ b/awklib/eg/lib/round.awk
@@ -0,0 +1,32 @@
+# round --- do normal rounding
+#
+# Arnold Robbins, arnold@gnu.ai.mit.edu, August, 1996
+# Public Domain
+
+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) }
diff --git a/awklib/eg/prog/cut.awk b/awklib/eg/prog/cut.awk
index c69e6492..7c0da75e 100644
--- a/awklib/eg/prog/cut.awk
+++ b/awklib/eg/prog/cut.awk
@@ -92,7 +92,7 @@ function set_charlist( field, i, j, f, g, t,
if (index(f[i], "-") != 0) { # range
m = split(f[i], g, "-")
if (m != 2 || g[1] >= g[2]) {
- printf(bad character list: %s\n",
+ printf("bad character list: %s\n",
f[i]) > "/dev/stderr"
exit 1
}
diff --git a/awklib/eg/prog/wc.awk b/awklib/eg/prog/wc.awk
index e9898159..e5553116 100644
--- a/awklib/eg/prog/wc.awk
+++ b/awklib/eg/prog/wc.awk
@@ -27,7 +27,7 @@ BEGIN {
if (! do_lines && ! do_words && ! do_chars)
do_lines = do_words = do_chars = 1
- print_total = (ARC - i > 2)
+ print_total = (ARGC - i > 2)
}
function beginfile(file)
{
diff --git a/awklib/group.awk b/awklib/group.awk
deleted file mode 100644
index a8103a04..00000000
--- a/awklib/group.awk
+++ /dev/null
@@ -1,80 +0,0 @@
-# group.awk --- functions for dealing with the group file
-# Arnold Robbins, arnold@gnu.ai.mit.edu, Public Domain
-# May 1993
-
-BEGIN \
-{
- # Change to suit your system
- _gr_awklib = "/usr/local/libexec/awk/"
-}
-function _gr_init( oldfs, oldrs, olddol0, grcat, n, a, i)
-{
- if (_gr_inited)
- return
-
- oldfs = FS
- oldrs = RS
- olddol0 = $0
- 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
- 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/awklib/igawk.save b/awklib/igawk.save
deleted file mode 100755
index 87412aa8..00000000
--- a/awklib/igawk.save
+++ /dev/null
@@ -1,120 +0,0 @@
-#! /bin/sh
-
-# igawk --- like gawk but do @include processing
-# Arnold Robbins, arnold@gnu.ai.mit.edu, Public Domain
-# July 1993
-
-if [ "$1" = debug ]
-then
- set -x
- shift
-else
- # cleanup on exit, hangup, interrupt, quit, termination
- trap 'rm -f /tmp/ig.[se].$$' 0 1 2 3 15
-fi
-
-while [ $# -ne 0 ] # loop over arguments
-do
- case $1 in
- --) shift; break;;
-
- -W) shift
- set -- -W"$@"
- continue;;
-
- -[vF]) opts="$opts $1 '$2'"
- shift;;
-
- -[vF]*) opts="$opts '$1'" ;;
-
- -f) echo @include "$2" >> /tmp/ig.s.$$
- shift;;
-
- -f*) f=`echo "$1" | sed 's/-f//'`
- echo @include "$f" >> /tmp/ig.s.$$ ;;
-
- -?file=*) # -Wfile or --file
- f=`echo "$1" | sed 's/-.file=//'`
- echo @include "$f" >> /tmp/ig.s.$$ ;;
-
- -?file) # get arg, $2
- echo @include "$2" >> /tmp/ig.s.$$
- shift;;
-
- -?source=*) # -Wsource or --source
- t=`echo "$1" | sed 's/-.source=//'`
- echo "$t" >> /tmp/ig.s.$$ ;;
-
- -?source) # get arg, $2
- echo "$2" >> /tmp/ig.s.$$
- shift;;
-
- --*) opts="$opts '$1'" ;;
-
- *) break;;
- esac
-
- shift
-done
-
-if [ ! -s /tmp/ig.s.$$ ]
-then
- echo "$1" > /tmp/ig.s.$$
- shift
-fi
-
-# at this point, /tmp/ig.s.$$ has the program
-gawk -- '
-# process @include directives
-
-function pathto(file, i, t, junk)
-{
- if (index(file, "/") != 0)
- return file
-
- for (i = 1; i <= ndirs; i++) {
- t = (pathlist[i] "/" file)
- if ((getline junk < t) > 0) {
- # found it
- close(t)
- return t
- }
- }
- return ""
-}
-BEGIN {
- path = ENVIRON["AWKPATH"]
- ndirs = split(path, pathlist, ":")
- for (i = 1; i <= ndirs; i++) {
- if (pathlist[i] == "")
- pathlist[i] = "."
- }
- stackptr = 0
- input[stackptr] = ARGV[1] # ARGV[1] is first file
-
- for (; stackptr >= 0; stackptr--) {
- while ((getline < input[stackptr]) > 0) {
- if (tolower($1) != "@include") {
- print
- continue
- }
- fpath = pathto($2)
- if (fpath == "") {
- printf("igawk:%s:%d: cannot find %s\n", \
- input[stackptr], FNR, $2) > "/dev/stderr"
- continue
- }
- if (! (fpath in processed)) {
- processed[fpath] = input[stackptr]
- input[++stackptr] = fpath
- } else
- print $2, "included in", input[stackptr], \
- "already included in", \
- processed[fpath] > "/dev/stderr"
- }
- close(input[stackptr])
- }
-}' /tmp/ig.s.$$ > /tmp/ig.e.$$
-eval gawk -f /tmp/ig.e.$$ $opts -- "$@"
-
-exit $?
diff --git a/awklib/passwd.awk b/awklib/passwd.awk
deleted file mode 100644
index 7b64f60d..00000000
--- a/awklib/passwd.awk
+++ /dev/null
@@ -1,56 +0,0 @@
-# passwd.awk --- access password file information
-# Arnold Robbins, arnold@gnu.ai.mit.edu, Public Domain
-# May 1993
-
-BEGIN {
- # tailor this to suit your system
- _pw_awklib = "/usr/local/libexec/awk/"
-}
-
-function _pw_init( oldfs, oldrs, olddol0, pwcat)
-{
- if (_pw_inited)
- return
- oldfs = FS
- oldrs = RS
- olddol0 = $0
- 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
- 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
-}