diff options
author | jraynard <jraynard@FreeBSD.org> | 1997-10-14 18:17:11 +0000 |
---|---|---|
committer | jraynard <jraynard@FreeBSD.org> | 1997-10-14 18:17:11 +0000 |
commit | a46c41193ff2573a4c910e19b570e9c253e714a1 (patch) | |
tree | d84200da2f7f2d8f1321c265bc6ddd7ce15633f8 /contrib/awk/test | |
download | FreeBSD-src-a46c41193ff2573a4c910e19b570e9c253e714a1.zip FreeBSD-src-a46c41193ff2573a4c910e19b570e9c253e714a1.tar.gz |
Virgin import of GNU awk 3.0.3
Diffstat (limited to 'contrib/awk/test')
216 files changed, 4522 insertions, 0 deletions
diff --git a/contrib/awk/test/ChangeLog b/contrib/awk/test/ChangeLog new file mode 100644 index 0000000..8efafaa --- /dev/null +++ b/contrib/awk/test/ChangeLog @@ -0,0 +1,252 @@ +Thu May 15 12:49:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Release 3.0.3: Release tar file made. + +Tue May 13 12:53:46 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (messages): more testing for OK failure on Linux. + +Sun May 11 14:57:11 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (nondec): new test case. + * nondec.awk, nondec.ok: new files. + +Sun May 11 07:07:05 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (prdupval): new test case. + * prdupval.awk, prdupval.in, prdupval.ok: new files. + +Wed May 7 21:54:34 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (delarprm): new test case. + * delarprm.awk, delarprm.ok: new files. + +Wed May 7 17:54:00 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (pid): several fixes from ghazi@caip.rutgers.edu. + +Tue May 6 20:28:30 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (strftime): Use the right locale stuff. + (clobber): don't need an input file. + +Thu Apr 24 22:24:42 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (pid): new test case, from jco@convex.com. + (specfile): removed test case, pid does it better. + * pid.awk, pid.ok, pid.sh: new files. + * specfile.awk: removed. + +Wed Apr 23 23:37:10 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (pipeio2): new test case. + * pipeio2.awk, pipeio2.ok, pipeio2.in: new files. + +Sun Apr 20 12:22:52 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (clobber): new test case. + * clobber.awk, clobber.ok: new files. + +Fri Apr 18 07:55:47 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * BETA Release 3.0.34: Release tar file made. + +Tue Apr 15 05:57:29 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (strftlng): More wizardry for bizarre Unix systems. + (nlfldsep): use program and input file, not shell script + (basic, unix-tests, gawk.extensions): moved specfile, pipeio1 + and strftlng into unix-tests per Pat Rankin. + * nlfldsep.awk, nlfldsep.in: new files. + * nlfldsep.sh: removed. + +Wed Apr 9 23:32:47 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (funstack): new test case. + * funstack.awk, funstack.in, funstack.ok: new files. + * substr.awk: added many more tests. + * substr.ok: updated + +Wed Mar 19 20:10:21 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (pipeio1): new test case. + * pipeio1.awk, pipeio1.ok: new files. + +Tue Mar 18 06:38:36 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (noparm): new test case. + * noparm.awk, noparm.ok: new files. + +Fri Feb 21 06:30:18 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (reint): new test case. + * reint.awk, reint.in, reint.ok: new files. + +Wed Feb 5 18:17:51 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (fnarydel): new test case. + * fnarydel.awk, fnarydel.ok: new files. + +Sun Jan 19 17:06:18 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (nors): new test case. + * nors.ok: new file. + +Sun Jan 19 17:06:18 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (specfile, strftlng, nfldstr): new test cases. + * specfile.awk, strftlng.awk, strftlng.ok, nfldstr.ok: new files. + +Fri Dec 27 11:27:13 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (intest): new test case. + * intest.awk, intest.ok: new files. + +Wed Dec 25 11:25:22 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Release 3.0.2: Release tar file made. + +Tue Dec 10 23:09:26 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Release 3.0.1: Release tar file made. + +Thu Nov 7 09:12:20 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (splitvar): new test case. + * splitvar.awk, splitvar.in, splitvar.ok: new files. + +Sun Nov 3 10:55:50 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (nlfldsep): new test case. + * nlfldsep.sh, nlfldsep.ok: new files. + +Fri Oct 25 10:29:56 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * rand.awk: call srand with fixed seed. + * rand.ok: new file. + * Makefile.in (rand): changed to compare output with rand.ok. + +Sat Oct 19 21:52:04 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (tradanch): new test case. + * tradanch.awk, tradanch.in, tradanch.ok: new files. + +Thu Oct 17 21:22:05 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * tweakfld.awk: move `rm' out into Makefile.in. + * eofsplit.awk: fixed buggy code so won't loop forever. + * Makefile.in (all): add unix-tests. + (unix-tests): new target, has pound-bang, fflush, getlnhd. + (basic): removed fflush, getlnhd. + (tweakfld): added rm from tweakfld.awk. + +Sun Oct 6 22:00:35 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (back89): new test case. + * back89.in, back89.ok: new files. + +Sun Oct 6 20:45:54 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (splitwht): new test case. + * splitwht.awk, splitwht.ok: new files. + +Sun Sep 29 23:14:20 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (gsubtest): new test case. + * gsubtest.awk, gsubtest.ok: new files. + +Fri Sep 20 11:58:40 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (prtoeval): new test case. + * prtoeval.awk, prtoeval.ok: new files. + +Tue Sep 10 06:26:44 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (gsubasgn): new test case. + * gsubasgn.awk, gsubasgn.ok: new files. + +Wed Aug 28 22:06:33 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * badargs.ok: updated output corresponding to change made to + main.c (see main ChangeLog). + +Thu Aug 1 07:20:28 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (clean): remove out[123] files from `messages' test. + Thanks to Pat Rankin (rankin@eql.caltech.edu). + +Sat Jul 27 23:56:57 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (prt1eval): new test case. + * prt1eval.awk, prt1eval.ok: new files. + +Mon Jul 22 22:06:10 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (eofsplit): new test case. + * eofsplit.awk, eofsplit.ok: new files. + +Sun Jul 14 07:07:45 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (fldchgnf): new test case. + * fldchgnf.awk, fldchgnf.ok: new files. + +Tue May 21 23:23:22 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (substr): new test case. + * substr.awk, substr.ok: new files. + +Tue May 14 15:05:23 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (dynlj): new test case. + * dynlj.awk, dynlj.ok: new files. + +Sun May 12 20:45:34 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (fnarray): new test case. + * fnarray.awk, fnarray.ok: new files. + +Fri Mar 15 06:46:48 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (clean): added `*~' to list of files to be removed. + * tweakfld.awk (END): added to do clean up action. + +Thu Mar 14 16:41:32 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (mmap8k): new test case. + * mmap8k.in, mmap8k.ok: new files. + +Sun Mar 10 22:58:35 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (clsflnam): new test case. + * clsflnam.in, clsflnam.awk, clsflnam.ok: new files. + * tweakfld.awk: changed to have a fixed date. + +Thu Mar 7 09:56:09 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (tweakfld): new test case. + * tweakfld.in, tweakfld.awk, tweakfld.ok: new files. + +Sun Mar 3 06:51:26 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (getlnhd, backgsub) : new test cases. + * getlnhd.awk, getlnhd.ok: new files. + * backgsub.in, backgsub.awk, backgsub.ok: new files. + +Mon Feb 26 22:30:02 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (sprintfc): new test case. + * sprintfc.in, sprintfc.awk, sprintfc.ok: new files. + * gensub.awk: updated for case of no match of regex. + +Wed Jan 24 10:06:16 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * Makefile.in (distclean, maintainer-clean): new targets. + (reindops): added test from Rick Adams (rick@uunet.uu.net). + (arrayparm, paramdup, defref, strftime, prmarscl, sclforin, + sclifin): Fix from Larry Schwimmer (schwim@cyclone.stanford.edu) + so that tests that are supposed to fail use `... || exit 0' to + cause a clean `make clean'. + +Wed Jan 10 22:58:55 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us> + + * ChangeLog created. diff --git a/contrib/awk/test/Makefile b/contrib/awk/test/Makefile new file mode 100644 index 0000000..1a9168e --- /dev/null +++ b/contrib/awk/test/Makefile @@ -0,0 +1,451 @@ +# Generated automatically from Makefile.in by configure. +# Makefile for GNU Awk test suite. +# +# Copyright (C) 1988-1997 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +SHELL = /bin/sh +AWK = ../gawk +CMP = cmp + +srcdir = . + +bigtest: basic unix-tests gawk.extensions + +basic: msg swaplns messages argarray longwrds \ + getline fstabplus compare arrayref rs fsrs rand \ + fsbs negexp asgext anchgsub splitargv awkpath nfset reparse \ + convfmt arrayparm paramdup nonl defref nofmtch litoct resplit \ + rswhite prmarscl sclforin sclifin intprec childin noeffect \ + numsubstr pcntplus prmreuse math fldchg fldchgnf reindops \ + sprintfc backgsub tweakfld clsflnam mmap8k fnarray \ + dynlj substr eofsplit prt1eval gsubasgn prtoeval gsubtest splitwht \ + back89 tradanch nlfldsep splitvar intest nfldstr nors fnarydel \ + noparms funstack clobber delarprm prdupval + +unix-tests: poundbang fflush getlnhd pipeio1 pipeio2 strftlng pid + +gawk.extensions: fieldwdth ignrcase posix manyfiles igncfs argtest \ + badargs strftime gensub gnureops reint nondec + +extra: regtest inftest + +poundbang:: + @cp $(AWK) /tmp/gawk && $(srcdir)/poundbang $(srcdir)/poundbang >_`basename $@` + @rm -f /tmp/gawk + $(CMP) $(srcdir)/poundbang.ok _`basename $@` && rm -f _`basename $@` + +msg:: + @echo 'Any output from "cmp" is bad news, although some differences' + @echo 'in floating point values are probably benign -- in particular,' + @echo 'some systems may omit a leading zero and the floating point' + @echo 'precision may lead to slightly different output in a few cases.' + +swaplns:: + @$(AWK) -f $(srcdir)/swaplns.awk $(srcdir)/swaplns.in >_$@ + $(CMP) $(srcdir)/swaplns.ok _$@ && rm -f _$@ + +messages:: + @$(AWK) -f $(srcdir)/messages.awk >out2 2>out3 + { $(CMP) $(srcdir)/out1.ok out1 && $(CMP) $(srcdir)/out2.ok out2 && \ + $(CMP) $(srcdir)/out3.ok out3 && rm -f out1 out2 out3; } || \ + { { test -d /dev/fd || test -d /proc/self/fd; } && \ + echo IT IS OK THAT THIS TEST FAILED; } + +argarray:: + @case $(srcdir) in \ + .) : ;; \ + *) cp $(srcdir)/argarray.in . ;; \ + esac + @TEST=test echo just a test | $(AWK) -f $(srcdir)/argarray.awk ./argarray.in - >_$@ + $(CMP) $(srcdir)/argarray.ok _$@ && rm -f _$@ + +fstabplus:: + @echo '1 2' | $(AWK) -f $(srcdir)/fstabplus.awk >_$@ + $(CMP) $(srcdir)/fstabplus.ok _$@ && rm -f _$@ + +fsrs:: + @$(AWK) -f $(srcdir)/fsrs.awk $(srcdir)/fsrs.in >_$@ + $(CMP) $(srcdir)/fsrs.ok _$@ && rm -f _$@ + +igncfs:: + @$(AWK) -f $(srcdir)/igncfs.awk $(srcdir)/igncfs.in >_$@ + $(CMP) $(srcdir)/igncfs.ok _$@ && rm -f _$@ + +longwrds:: + @$(AWK) -f $(srcdir)/longwrds.awk $(srcdir)/manpage | sort >_$@ + $(CMP) $(srcdir)/longwrds.ok _$@ && rm -f _$@ + +fieldwdth:: + @echo '123456789' | $(AWK) -v FIELDWIDTHS="2 3 4" '{ print $$2}' >_$@ + $(CMP) $(srcdir)/fieldwdth.ok _$@ && rm -f _$@ + +ignrcase:: + @echo xYz | $(AWK) -v IGNORECASE=1 '{ sub(/y/, ""); print}' >_$@ + $(CMP) $(srcdir)/ignrcase.ok _$@ && rm -f _$@ + +regtest:: + @echo 'Some of the output from regtest is very system specific, do not' + @echo 'be distressed if your output differs from that distributed.' + @echo 'Manual inspection is called for.' + AWK=`pwd`/$(AWK) $(srcdir)/regtest + +posix:: + @echo '1:2,3 4' | $(AWK) -f $(srcdir)/posix.awk >_$@ + $(CMP) $(srcdir)/posix.ok _$@ && rm -f _$@ + +manyfiles:: + @rm -rf junk + @mkdir junk + @$(AWK) 'BEGIN { for (i = 1; i <= 300; i++) print i, i}' >_$@ + @$(AWK) -f $(srcdir)/manyfiles.awk _$@ _$@ + @echo "This number better be 1 ->" | tr -d '\012' + @wc -l junk/* | $(AWK) '$$1 != 2' | wc -l + @rm -rf junk _$@ + +compare:: + @$(AWK) -f $(srcdir)/compare.awk 0 1 $(srcdir)/compare.in >_$@ + $(CMP) $(srcdir)/compare.ok _$@ && rm -f _$@ + +arrayref:: + @$(AWK) -f $(srcdir)/arrayref.awk >_$@ + $(CMP) $(srcdir)/arrayref.ok _$@ && rm -f _$@ + +rs:: + @$(AWK) -v RS="" '{ print $$1, $$2}' $(srcdir)/rs.in >_$@ + $(CMP) $(srcdir)/rs.ok _$@ && rm -f _$@ + +fsbs:: + @$(AWK) -v FS='\' '{ print $$1, $$2 }' $(srcdir)/fsbs.in >_$@ + $(CMP) $(srcdir)/fsbs.ok _$@ && rm -f _$@ + +inftest:: + @echo This test is very machine specific... + @$(AWK) -f $(srcdir)/inftest.awk >_$@ + $(CMP) $(srcdir)/inftest.ok _$@ && rm -f _$@ + +getline:: + @$(AWK) -f $(srcdir)/getline.awk $(srcdir)/getline.awk $(srcdir)/getline.awk >_$@ + $(CMP) $(srcdir)/getline.ok _$@ && rm -f _$@ + +rand:: + @$(AWK) -f $(srcdir)/rand.awk >_$@ + $(CMP) $(srcdir)/rand.ok _$@ && rm -f _$@ + +negexp:: + @$(AWK) 'BEGIN { a = -2; print 10^a }' >_$@ + $(CMP) $(srcdir)/negexp.ok _$@ && rm -f _$@ + +asgext:: + @$(AWK) -f $(srcdir)/asgext.awk $(srcdir)/asgext.in >_$@ + $(CMP) $(srcdir)/asgext.ok _$@ && rm -f _$@ + +anchgsub:: + @$(AWK) -f $(srcdir)/anchgsub.awk $(srcdir)/anchgsub.in >_$@ + $(CMP) $(srcdir)/anchgsub.ok _$@ && rm -f _$@ + +splitargv:: + @$(AWK) -f $(srcdir)/splitargv.awk $(srcdir)/splitargv.in >_$@ + $(CMP) $(srcdir)/splitargv.ok _$@ && rm -f _$@ + +awkpath:: + @AWKPATH="$(srcdir):$(srcdir)/lib" $(AWK) -f awkpath.awk >_$@ + $(CMP) $(srcdir)/awkpath.ok _$@ && rm -f _$@ + +nfset:: + @$(AWK) -f $(srcdir)/nfset.awk $(srcdir)/nfset.in >_$@ + $(CMP) $(srcdir)/nfset.ok _$@ && rm -f _$@ + +reparse:: + @$(AWK) -f $(srcdir)/reparse.awk $(srcdir)/reparse.in >_$@ + $(CMP) $(srcdir)/reparse.ok _$@ && rm -f _$@ + +argtest:: + @$(AWK) -f $(srcdir)/argtest.awk -x -y abc >_$@ + $(CMP) $(srcdir)/argtest.ok _$@ && rm -f _$@ + +badargs:: + @-$(AWK) -f 2>&1 | grep -v patchlevel >_$@ + $(CMP) $(srcdir)/badargs.ok _$@ && rm -f _$@ + +convfmt:: + @$(AWK) -f $(srcdir)/convfmt.awk >_$@ + $(CMP) $(srcdir)/convfmt.ok _$@ && rm -f _$@ + +arrayparm:: + @-AWKPATH=$(srcdir) $(AWK) -f arrayparm.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/arrayparm.ok _$@ && rm -f _$@ + +paramdup:: + @-AWKPATH=$(srcdir) $(AWK) -f paramdup.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/paramdup.ok _$@ && rm -f _$@ + +nonl:: + @-AWKPATH=$(srcdir) $(AWK) --lint -f nonl.awk /dev/null >_$@ 2>&1 + $(CMP) $(srcdir)/nonl.ok _$@ && rm -f _$@ + +defref:: + @-AWKPATH=$(srcdir) $(AWK) --lint -f defref.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/defref.ok _$@ && rm -f _$@ + +nofmtch:: + @-AWKPATH=$(srcdir) $(AWK) --lint -f nofmtch.awk >_$@ 2>&1 + $(CMP) $(srcdir)/nofmtch.ok _$@ && rm -f _$@ + +strftime:: + : this test could fail on slow machines or on a second boundary, + : so if it does, double check the actual results + @LC_ALL=C; export LC_ALL; LANC=C; export LANG; \ + date | $(AWK) '{ $$3 = sprintf("%02d", $$3 + 0) ; \ + print > "strftime.ok" ; \ + print strftime() > "'_$@'" }' + $(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0 + +litoct:: + @echo ab | $(AWK) --traditional -f $(srcdir)/litoct.awk >_$@ + $(CMP) $(srcdir)/litoct.ok _$@ && rm -f _$@ + +gensub:: + @$(AWK) -f $(srcdir)/gensub.awk $(srcdir)/gensub.in >_$@ + $(CMP) $(srcdir)/gensub.ok _$@ && rm -f _$@ + +resplit:: + @echo a:b:c d:e:f | $(AWK) '{ FS = ":"; $$0 = $$0; print $$2 }' > _$@ + $(CMP) $(srcdir)/resplit.ok _$@ && rm -f _$@ + +rswhite:: + @$(AWK) -f $(srcdir)/rswhite.awk $(srcdir)/rswhite.in > _$@ + $(CMP) $(srcdir)/rswhite.ok _$@ && rm -f _$@ + +prmarscl:: + @-AWKPATH=$(srcdir) $(AWK) -f prmarscl.awk > _$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/prmarscl.ok _$@ && rm -f _$@ + +sclforin:: + @-AWKPATH=$(srcdir) $(AWK) -f sclforin.awk > _$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/sclforin.ok _$@ && rm -f _$@ + +sclifin:: + @-AWKPATH=$(srcdir) $(AWK) -f sclifin.awk > _$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/sclifin.ok _$@ && rm -f _$@ + +intprec:: + @-$(AWK) -f $(srcdir)/intprec.awk > _$@ 2>&1 + $(CMP) $(srcdir)/intprec.ok _$@ && rm -f _$@ + +childin:: + @echo hi | $(AWK) 'BEGIN { "cat" | getline; print; close("cat") }' > _$@ + $(CMP) $(srcdir)/childin.ok _$@ && rm -f _$@ + +noeffect:: + @-AWKPATH=$(srcdir) $(AWK) --lint -f noeffect.awk > _$@ 2>&1 + $(CMP) $(srcdir)/noeffect.ok _$@ && rm -f _$@ + +numsubstr:: + @-AWKPATH=$(srcdir) $(AWK) -f numsubstr.awk $(srcdir)/numsubstr.in >_$@ + $(CMP) $(srcdir)/numsubstr.ok _$@ && rm -f _$@ + +gnureops:: + @$(AWK) -f $(srcdir)/gnureops.awk >_$@ + $(CMP) $(srcdir)/gnureops.ok _$@ && rm -f _$@ + +pcntplus:: + @$(AWK) -f $(srcdir)/pcntplus.awk >_$@ + $(CMP) $(srcdir)/pcntplus.ok _$@ && rm -f _$@ + +prmreuse:: + @$(AWK) -f $(srcdir)/prmreuse.awk >_$@ + $(CMP) $(srcdir)/prmreuse.ok _$@ && rm -f _$@ + +math:: + @$(AWK) -f $(srcdir)/math.awk >_$@ + $(CMP) $(srcdir)/math.ok _$@ && rm -f _$@ + +fflush:: + @$(srcdir)/fflush.sh >_$@ + $(CMP) $(srcdir)/fflush.ok _$@ && rm -f _$@ + +fldchg:: + @$(AWK) -f $(srcdir)/fldchg.awk $(srcdir)/fldchg.in >_$@ + $(CMP) $(srcdir)/fldchg.ok _$@ && rm -f _$@ + +fldchgnf:: + @$(AWK) -f $(srcdir)/fldchgnf.awk $(srcdir)/fldchgnf.in >_$@ + $(CMP) $(srcdir)/fldchgnf.ok _$@ && rm -f _$@ + +reindops:: + @$(AWK) -f $(srcdir)/reindops.awk $(srcdir)/reindops.in >_$@ + $(CMP) $(srcdir)/reindops.ok _$@ && rm -f _$@ + +sprintfc:: + @$(AWK) -f $(srcdir)/sprintfc.awk $(srcdir)/sprintfc.in >_$@ + $(CMP) $(srcdir)/sprintfc.ok _$@ && rm -f _$@ + +getlnhd:: + @$(AWK) -f $(srcdir)/getlnhd.awk >_$@ + $(CMP) $(srcdir)/getlnhd.ok _$@ && rm -f _$@ + +backgsub:: + @$(AWK) -f $(srcdir)/backgsub.awk $(srcdir)/backgsub.in >_$@ + $(CMP) $(srcdir)/backgsub.ok _$@ && rm -f _$@ + +tweakfld:: + @$(AWK) -f $(srcdir)/tweakfld.awk $(srcdir)/tweakfld.in >_$@ + @rm -f errors.cleanup + $(CMP) $(srcdir)/tweakfld.ok _$@ && rm -f _$@ + +clsflnam:: + @$(AWK) -f $(srcdir)/clsflnam.awk $(srcdir)/clsflnam.in >_$@ + $(CMP) $(srcdir)/clsflnam.ok _$@ && rm -f _$@ + +mmap8k:: + @$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@ + $(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@ + +fnarray:: + @-AWKPATH=$(srcdir) $(AWK) -f fnarray.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/fnarray.ok _$@ && rm -f _$@ + +dynlj:: + @$(AWK) -f $(srcdir)/dynlj.awk >_$@ + $(CMP) $(srcdir)/dynlj.ok _$@ && rm -f _$@ + +substr:: + @$(AWK) -f $(srcdir)/substr.awk >_$@ + $(CMP) $(srcdir)/substr.ok _$@ && rm -f _$@ + +eofsplit:: + @$(AWK) -f $(srcdir)/eofsplit.awk >_$@ + $(CMP) $(srcdir)/eofsplit.ok _$@ && rm -f _$@ + +prt1eval:: + @$(AWK) -f $(srcdir)/prt1eval.awk >_$@ + $(CMP) $(srcdir)/prt1eval.ok _$@ && rm -f _$@ + +gsubasgn:: + @-AWKPATH=$(srcdir) $(AWK) -f gsubasgn.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/gsubasgn.ok _$@ && rm -f _$@ + +prtoeval:: + @$(AWK) -f $(srcdir)/prtoeval.awk >_$@ + $(CMP) $(srcdir)/prtoeval.ok _$@ && rm -f _$@ + +gsubtest:: + @$(AWK) -f $(srcdir)/gsubtest.awk >_$@ + $(CMP) $(srcdir)/gsubtest.ok _$@ && rm -f _$@ + +splitwht:: + @$(AWK) -f $(srcdir)/splitwht.awk >_$@ + $(CMP) $(srcdir)/splitwht.ok _$@ && rm -f _$@ + +back89:: + @$(AWK) '/a\8b/' $(srcdir)/back89.in >_$@ + $(CMP) $(srcdir)/back89.ok _$@ && rm -f _$@ + +tradanch:: + @$(AWK) --traditional -f $(srcdir)/tradanch.awk $(srcdir)/tradanch.in >_$@ + $(CMP) $(srcdir)/tradanch.ok _$@ && rm -f _$@ + +nlfldsep:: + @$(AWK) -f $(srcdir)/nlfldsep.awk $(srcdir)/nlfldsep.in > _$@ + $(CMP) $(srcdir)/nlfldsep.ok _$@ && rm -f _$@ + +splitvar:: + @$(AWK) -f $(srcdir)/splitvar.awk $(srcdir)/splitvar.in >_$@ + $(CMP) $(srcdir)/splitvar.ok _$@ && rm -f _$@ + +intest:: + @$(AWK) -f $(srcdir)/intest.awk >_$@ + $(CMP) $(srcdir)/intest.ok _$@ && rm -f _$@ + +# AIX /bin/sh exec's the last command in a list, therefore issue a ":" +# command so that pid.sh is fork'ed as a child before being exec'ed. +pid:: + @AWKPATH=$(srcdir) AWK=$(AWK) $(SHELL) $(srcdir)/pid.sh $$$$ > _`basename $@` ; : + $(CMP) $(srcdir)/pid.ok _`basename $@` && rm -f _`basename $@` _`basename $@`.in + +strftlng:: + @TZ=UTC; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ + @if $(CMP) -s $(srcdir)/strftlng.ok _$@ ; then : ; else \ + TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \ + fi + $(CMP) $(srcdir)/strftlng.ok _$@ && rm -f _$@ + +nfldstr:: + @echo | $(AWK) '$$1 == 0 { print "bug" }' > _$@ + $(CMP) $(srcdir)/nfldstr.ok _$@ && rm -f _$@ + +nors:: + @echo A B C D E | tr -d '\12' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@ + $(CMP) $(srcdir)/nors.ok _$@ && rm -f _$@ + +fnarydel:: + @$(AWK) -f $(srcdir)/fnarydel.awk >_$@ + $(CMP) $(srcdir)/fnarydel.ok _$@ && rm -f _$@ + +reint:: + @$(AWK) --re-interval -f $(srcdir)/reint.awk $(srcdir)/reint.in >_$@ + $(CMP) $(srcdir)/reint.ok _$@ && rm -f _$@ + +noparms:: + @-AWKPATH=$(srcdir) $(AWK) -f noparms.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/noparms.ok _$@ && rm -f _$@ + +pipeio1:: + @$(AWK) -f $(srcdir)/pipeio1.awk >_$@ + @rm -f test1 test2 + $(CMP) $(srcdir)/pipeio1.ok _$@ && rm -f _$@ + +pipeio2:: + @$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@ + $(CMP) $(srcdir)/pipeio2.ok _$@ && rm -f _$@ + +funstack:: + @$(AWK) -f $(srcdir)/funstack.awk $(srcdir)/funstack.in >_$@ + $(CMP) $(srcdir)/funstack.ok _$@ && rm -f _$@ + +clobber:: + @$(AWK) -f $(srcdir)/clobber.awk >_$@ + $(CMP) $(srcdir)/clobber.ok seq && $(CMP) $(srcdir)/clobber.ok _$@ && rm -f _$@ + @rm -f seq + +delarprm:: + @$(AWK) -f $(srcdir)/delarprm.awk >_$@ + $(CMP) $(srcdir)/delarprm.ok _$@ && rm -f _$@ + +prdupval:: + @$(AWK) -f $(srcdir)/prdupval.awk $(srcdir)/prdupval.in >_$@ + $(CMP) $(srcdir)/prdupval.ok _$@ && rm -f _$@ + +nondec:: + @if grep BITOP ../config.h | grep define > /dev/null; \ + then \ + $(AWK) -f $(srcdir)/nondec.awk >_$@; \ + else \ + cp $(srcdir)/nondec.ok _$@; \ + fi + $(CMP) $(srcdir)/nondec.ok _$@ && rm -f _$@ + +clean: + rm -fr _* core junk out1 out2 out3 strftime.ok test1 test2 seq *~ + +distclean: clean + rm -f Makefile + +maintainer-clean: distclean diff --git a/contrib/awk/test/Makefile.in b/contrib/awk/test/Makefile.in new file mode 100644 index 0000000..07d0cbc --- /dev/null +++ b/contrib/awk/test/Makefile.in @@ -0,0 +1,451 @@ +# Makefile for GNU Awk test suite. +# +# Copyright (C) 1988-1997 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +SHELL = /bin/sh +AWK = ../gawk +CMP = cmp + +srcdir = @srcdir@ +VPATH = @srcdir@ + +bigtest: basic unix-tests gawk.extensions + +basic: msg swaplns messages argarray longwrds \ + getline fstabplus compare arrayref rs fsrs rand \ + fsbs negexp asgext anchgsub splitargv awkpath nfset reparse \ + convfmt arrayparm paramdup nonl defref nofmtch litoct resplit \ + rswhite prmarscl sclforin sclifin intprec childin noeffect \ + numsubstr pcntplus prmreuse math fldchg fldchgnf reindops \ + sprintfc backgsub tweakfld clsflnam mmap8k fnarray \ + dynlj substr eofsplit prt1eval gsubasgn prtoeval gsubtest splitwht \ + back89 tradanch nlfldsep splitvar intest nfldstr nors fnarydel \ + noparms funstack clobber delarprm prdupval + +unix-tests: poundbang fflush getlnhd pipeio1 pipeio2 strftlng pid + +gawk.extensions: fieldwdth ignrcase posix manyfiles igncfs argtest \ + badargs strftime gensub gnureops reint nondec + +extra: regtest inftest + +poundbang:: + @cp $(AWK) /tmp/gawk && $(srcdir)/poundbang $(srcdir)/poundbang >_`basename $@` + @rm -f /tmp/gawk + $(CMP) $(srcdir)/poundbang.ok _`basename $@` && rm -f _`basename $@` + +msg:: + @echo 'Any output from "cmp" is bad news, although some differences' + @echo 'in floating point values are probably benign -- in particular,' + @echo 'some systems may omit a leading zero and the floating point' + @echo 'precision may lead to slightly different output in a few cases.' + +swaplns:: + @$(AWK) -f $(srcdir)/swaplns.awk $(srcdir)/swaplns.in >_$@ + $(CMP) $(srcdir)/swaplns.ok _$@ && rm -f _$@ + +messages:: + @$(AWK) -f $(srcdir)/messages.awk >out2 2>out3 + { $(CMP) $(srcdir)/out1.ok out1 && $(CMP) $(srcdir)/out2.ok out2 && \ + $(CMP) $(srcdir)/out3.ok out3 && rm -f out1 out2 out3; } || \ + { { test -d /dev/fd || test -d /proc/self/fd; } && \ + echo IT IS OK THAT THIS TEST FAILED; } + +argarray:: + @case $(srcdir) in \ + .) : ;; \ + *) cp $(srcdir)/argarray.in . ;; \ + esac + @TEST=test echo just a test | $(AWK) -f $(srcdir)/argarray.awk ./argarray.in - >_$@ + $(CMP) $(srcdir)/argarray.ok _$@ && rm -f _$@ + +fstabplus:: + @echo '1 2' | $(AWK) -f $(srcdir)/fstabplus.awk >_$@ + $(CMP) $(srcdir)/fstabplus.ok _$@ && rm -f _$@ + +fsrs:: + @$(AWK) -f $(srcdir)/fsrs.awk $(srcdir)/fsrs.in >_$@ + $(CMP) $(srcdir)/fsrs.ok _$@ && rm -f _$@ + +igncfs:: + @$(AWK) -f $(srcdir)/igncfs.awk $(srcdir)/igncfs.in >_$@ + $(CMP) $(srcdir)/igncfs.ok _$@ && rm -f _$@ + +longwrds:: + @$(AWK) -f $(srcdir)/longwrds.awk $(srcdir)/manpage | sort >_$@ + $(CMP) $(srcdir)/longwrds.ok _$@ && rm -f _$@ + +fieldwdth:: + @echo '123456789' | $(AWK) -v FIELDWIDTHS="2 3 4" '{ print $$2}' >_$@ + $(CMP) $(srcdir)/fieldwdth.ok _$@ && rm -f _$@ + +ignrcase:: + @echo xYz | $(AWK) -v IGNORECASE=1 '{ sub(/y/, ""); print}' >_$@ + $(CMP) $(srcdir)/ignrcase.ok _$@ && rm -f _$@ + +regtest:: + @echo 'Some of the output from regtest is very system specific, do not' + @echo 'be distressed if your output differs from that distributed.' + @echo 'Manual inspection is called for.' + AWK=`pwd`/$(AWK) $(srcdir)/regtest + +posix:: + @echo '1:2,3 4' | $(AWK) -f $(srcdir)/posix.awk >_$@ + $(CMP) $(srcdir)/posix.ok _$@ && rm -f _$@ + +manyfiles:: + @rm -rf junk + @mkdir junk + @$(AWK) 'BEGIN { for (i = 1; i <= 300; i++) print i, i}' >_$@ + @$(AWK) -f $(srcdir)/manyfiles.awk _$@ _$@ + @echo "This number better be 1 ->" | tr -d '\012' + @wc -l junk/* | $(AWK) '$$1 != 2' | wc -l + @rm -rf junk _$@ + +compare:: + @$(AWK) -f $(srcdir)/compare.awk 0 1 $(srcdir)/compare.in >_$@ + $(CMP) $(srcdir)/compare.ok _$@ && rm -f _$@ + +arrayref:: + @$(AWK) -f $(srcdir)/arrayref.awk >_$@ + $(CMP) $(srcdir)/arrayref.ok _$@ && rm -f _$@ + +rs:: + @$(AWK) -v RS="" '{ print $$1, $$2}' $(srcdir)/rs.in >_$@ + $(CMP) $(srcdir)/rs.ok _$@ && rm -f _$@ + +fsbs:: + @$(AWK) -v FS='\' '{ print $$1, $$2 }' $(srcdir)/fsbs.in >_$@ + $(CMP) $(srcdir)/fsbs.ok _$@ && rm -f _$@ + +inftest:: + @echo This test is very machine specific... + @$(AWK) -f $(srcdir)/inftest.awk >_$@ + $(CMP) $(srcdir)/inftest.ok _$@ && rm -f _$@ + +getline:: + @$(AWK) -f $(srcdir)/getline.awk $(srcdir)/getline.awk $(srcdir)/getline.awk >_$@ + $(CMP) $(srcdir)/getline.ok _$@ && rm -f _$@ + +rand:: + @$(AWK) -f $(srcdir)/rand.awk >_$@ + $(CMP) $(srcdir)/rand.ok _$@ && rm -f _$@ + +negexp:: + @$(AWK) 'BEGIN { a = -2; print 10^a }' >_$@ + $(CMP) $(srcdir)/negexp.ok _$@ && rm -f _$@ + +asgext:: + @$(AWK) -f $(srcdir)/asgext.awk $(srcdir)/asgext.in >_$@ + $(CMP) $(srcdir)/asgext.ok _$@ && rm -f _$@ + +anchgsub:: + @$(AWK) -f $(srcdir)/anchgsub.awk $(srcdir)/anchgsub.in >_$@ + $(CMP) $(srcdir)/anchgsub.ok _$@ && rm -f _$@ + +splitargv:: + @$(AWK) -f $(srcdir)/splitargv.awk $(srcdir)/splitargv.in >_$@ + $(CMP) $(srcdir)/splitargv.ok _$@ && rm -f _$@ + +awkpath:: + @AWKPATH="$(srcdir):$(srcdir)/lib" $(AWK) -f awkpath.awk >_$@ + $(CMP) $(srcdir)/awkpath.ok _$@ && rm -f _$@ + +nfset:: + @$(AWK) -f $(srcdir)/nfset.awk $(srcdir)/nfset.in >_$@ + $(CMP) $(srcdir)/nfset.ok _$@ && rm -f _$@ + +reparse:: + @$(AWK) -f $(srcdir)/reparse.awk $(srcdir)/reparse.in >_$@ + $(CMP) $(srcdir)/reparse.ok _$@ && rm -f _$@ + +argtest:: + @$(AWK) -f $(srcdir)/argtest.awk -x -y abc >_$@ + $(CMP) $(srcdir)/argtest.ok _$@ && rm -f _$@ + +badargs:: + @-$(AWK) -f 2>&1 | grep -v patchlevel >_$@ + $(CMP) $(srcdir)/badargs.ok _$@ && rm -f _$@ + +convfmt:: + @$(AWK) -f $(srcdir)/convfmt.awk >_$@ + $(CMP) $(srcdir)/convfmt.ok _$@ && rm -f _$@ + +arrayparm:: + @-AWKPATH=$(srcdir) $(AWK) -f arrayparm.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/arrayparm.ok _$@ && rm -f _$@ + +paramdup:: + @-AWKPATH=$(srcdir) $(AWK) -f paramdup.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/paramdup.ok _$@ && rm -f _$@ + +nonl:: + @-AWKPATH=$(srcdir) $(AWK) --lint -f nonl.awk /dev/null >_$@ 2>&1 + $(CMP) $(srcdir)/nonl.ok _$@ && rm -f _$@ + +defref:: + @-AWKPATH=$(srcdir) $(AWK) --lint -f defref.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/defref.ok _$@ && rm -f _$@ + +nofmtch:: + @-AWKPATH=$(srcdir) $(AWK) --lint -f nofmtch.awk >_$@ 2>&1 + $(CMP) $(srcdir)/nofmtch.ok _$@ && rm -f _$@ + +strftime:: + : this test could fail on slow machines or on a second boundary, + : so if it does, double check the actual results + @LC_ALL=C; export LC_ALL; LANC=C; export LANG; \ + date | $(AWK) '{ $$3 = sprintf("%02d", $$3 + 0) ; \ + print > "strftime.ok" ; \ + print strftime() > "'_$@'" }' + $(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0 + +litoct:: + @echo ab | $(AWK) --traditional -f $(srcdir)/litoct.awk >_$@ + $(CMP) $(srcdir)/litoct.ok _$@ && rm -f _$@ + +gensub:: + @$(AWK) -f $(srcdir)/gensub.awk $(srcdir)/gensub.in >_$@ + $(CMP) $(srcdir)/gensub.ok _$@ && rm -f _$@ + +resplit:: + @echo a:b:c d:e:f | $(AWK) '{ FS = ":"; $$0 = $$0; print $$2 }' > _$@ + $(CMP) $(srcdir)/resplit.ok _$@ && rm -f _$@ + +rswhite:: + @$(AWK) -f $(srcdir)/rswhite.awk $(srcdir)/rswhite.in > _$@ + $(CMP) $(srcdir)/rswhite.ok _$@ && rm -f _$@ + +prmarscl:: + @-AWKPATH=$(srcdir) $(AWK) -f prmarscl.awk > _$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/prmarscl.ok _$@ && rm -f _$@ + +sclforin:: + @-AWKPATH=$(srcdir) $(AWK) -f sclforin.awk > _$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/sclforin.ok _$@ && rm -f _$@ + +sclifin:: + @-AWKPATH=$(srcdir) $(AWK) -f sclifin.awk > _$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/sclifin.ok _$@ && rm -f _$@ + +intprec:: + @-$(AWK) -f $(srcdir)/intprec.awk > _$@ 2>&1 + $(CMP) $(srcdir)/intprec.ok _$@ && rm -f _$@ + +childin:: + @echo hi | $(AWK) 'BEGIN { "cat" | getline; print; close("cat") }' > _$@ + $(CMP) $(srcdir)/childin.ok _$@ && rm -f _$@ + +noeffect:: + @-AWKPATH=$(srcdir) $(AWK) --lint -f noeffect.awk > _$@ 2>&1 + $(CMP) $(srcdir)/noeffect.ok _$@ && rm -f _$@ + +numsubstr:: + @-AWKPATH=$(srcdir) $(AWK) -f numsubstr.awk $(srcdir)/numsubstr.in >_$@ + $(CMP) $(srcdir)/numsubstr.ok _$@ && rm -f _$@ + +gnureops:: + @$(AWK) -f $(srcdir)/gnureops.awk >_$@ + $(CMP) $(srcdir)/gnureops.ok _$@ && rm -f _$@ + +pcntplus:: + @$(AWK) -f $(srcdir)/pcntplus.awk >_$@ + $(CMP) $(srcdir)/pcntplus.ok _$@ && rm -f _$@ + +prmreuse:: + @$(AWK) -f $(srcdir)/prmreuse.awk >_$@ + $(CMP) $(srcdir)/prmreuse.ok _$@ && rm -f _$@ + +math:: + @$(AWK) -f $(srcdir)/math.awk >_$@ + $(CMP) $(srcdir)/math.ok _$@ && rm -f _$@ + +fflush:: + @$(srcdir)/fflush.sh >_$@ + $(CMP) $(srcdir)/fflush.ok _$@ && rm -f _$@ + +fldchg:: + @$(AWK) -f $(srcdir)/fldchg.awk $(srcdir)/fldchg.in >_$@ + $(CMP) $(srcdir)/fldchg.ok _$@ && rm -f _$@ + +fldchgnf:: + @$(AWK) -f $(srcdir)/fldchgnf.awk $(srcdir)/fldchgnf.in >_$@ + $(CMP) $(srcdir)/fldchgnf.ok _$@ && rm -f _$@ + +reindops:: + @$(AWK) -f $(srcdir)/reindops.awk $(srcdir)/reindops.in >_$@ + $(CMP) $(srcdir)/reindops.ok _$@ && rm -f _$@ + +sprintfc:: + @$(AWK) -f $(srcdir)/sprintfc.awk $(srcdir)/sprintfc.in >_$@ + $(CMP) $(srcdir)/sprintfc.ok _$@ && rm -f _$@ + +getlnhd:: + @$(AWK) -f $(srcdir)/getlnhd.awk >_$@ + $(CMP) $(srcdir)/getlnhd.ok _$@ && rm -f _$@ + +backgsub:: + @$(AWK) -f $(srcdir)/backgsub.awk $(srcdir)/backgsub.in >_$@ + $(CMP) $(srcdir)/backgsub.ok _$@ && rm -f _$@ + +tweakfld:: + @$(AWK) -f $(srcdir)/tweakfld.awk $(srcdir)/tweakfld.in >_$@ + @rm -f errors.cleanup + $(CMP) $(srcdir)/tweakfld.ok _$@ && rm -f _$@ + +clsflnam:: + @$(AWK) -f $(srcdir)/clsflnam.awk $(srcdir)/clsflnam.in >_$@ + $(CMP) $(srcdir)/clsflnam.ok _$@ && rm -f _$@ + +mmap8k:: + @$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@ + $(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@ + +fnarray:: + @-AWKPATH=$(srcdir) $(AWK) -f fnarray.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/fnarray.ok _$@ && rm -f _$@ + +dynlj:: + @$(AWK) -f $(srcdir)/dynlj.awk >_$@ + $(CMP) $(srcdir)/dynlj.ok _$@ && rm -f _$@ + +substr:: + @$(AWK) -f $(srcdir)/substr.awk >_$@ + $(CMP) $(srcdir)/substr.ok _$@ && rm -f _$@ + +eofsplit:: + @$(AWK) -f $(srcdir)/eofsplit.awk >_$@ + $(CMP) $(srcdir)/eofsplit.ok _$@ && rm -f _$@ + +prt1eval:: + @$(AWK) -f $(srcdir)/prt1eval.awk >_$@ + $(CMP) $(srcdir)/prt1eval.ok _$@ && rm -f _$@ + +gsubasgn:: + @-AWKPATH=$(srcdir) $(AWK) -f gsubasgn.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/gsubasgn.ok _$@ && rm -f _$@ + +prtoeval:: + @$(AWK) -f $(srcdir)/prtoeval.awk >_$@ + $(CMP) $(srcdir)/prtoeval.ok _$@ && rm -f _$@ + +gsubtest:: + @$(AWK) -f $(srcdir)/gsubtest.awk >_$@ + $(CMP) $(srcdir)/gsubtest.ok _$@ && rm -f _$@ + +splitwht:: + @$(AWK) -f $(srcdir)/splitwht.awk >_$@ + $(CMP) $(srcdir)/splitwht.ok _$@ && rm -f _$@ + +back89:: + @$(AWK) '/a\8b/' $(srcdir)/back89.in >_$@ + $(CMP) $(srcdir)/back89.ok _$@ && rm -f _$@ + +tradanch:: + @$(AWK) --traditional -f $(srcdir)/tradanch.awk $(srcdir)/tradanch.in >_$@ + $(CMP) $(srcdir)/tradanch.ok _$@ && rm -f _$@ + +nlfldsep:: + @$(AWK) -f $(srcdir)/nlfldsep.awk $(srcdir)/nlfldsep.in > _$@ + $(CMP) $(srcdir)/nlfldsep.ok _$@ && rm -f _$@ + +splitvar:: + @$(AWK) -f $(srcdir)/splitvar.awk $(srcdir)/splitvar.in >_$@ + $(CMP) $(srcdir)/splitvar.ok _$@ && rm -f _$@ + +intest:: + @$(AWK) -f $(srcdir)/intest.awk >_$@ + $(CMP) $(srcdir)/intest.ok _$@ && rm -f _$@ + +# AIX /bin/sh exec's the last command in a list, therefore issue a ":" +# command so that pid.sh is fork'ed as a child before being exec'ed. +pid:: + @AWKPATH=$(srcdir) AWK=$(AWK) $(SHELL) $(srcdir)/pid.sh $$$$ > _`basename $@` ; : + $(CMP) $(srcdir)/pid.ok _`basename $@` && rm -f _`basename $@` _`basename $@`.in + +strftlng:: + @TZ=UTC; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ + @if $(CMP) -s $(srcdir)/strftlng.ok _$@ ; then : ; else \ + TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \ + fi + $(CMP) $(srcdir)/strftlng.ok _$@ && rm -f _$@ + +nfldstr:: + @echo | $(AWK) '$$1 == 0 { print "bug" }' > _$@ + $(CMP) $(srcdir)/nfldstr.ok _$@ && rm -f _$@ + +nors:: + @echo A B C D E | tr -d '\12' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@ + $(CMP) $(srcdir)/nors.ok _$@ && rm -f _$@ + +fnarydel:: + @$(AWK) -f $(srcdir)/fnarydel.awk >_$@ + $(CMP) $(srcdir)/fnarydel.ok _$@ && rm -f _$@ + +reint:: + @$(AWK) --re-interval -f $(srcdir)/reint.awk $(srcdir)/reint.in >_$@ + $(CMP) $(srcdir)/reint.ok _$@ && rm -f _$@ + +noparms:: + @-AWKPATH=$(srcdir) $(AWK) -f noparms.awk >_$@ 2>&1 || exit 0 + $(CMP) $(srcdir)/noparms.ok _$@ && rm -f _$@ + +pipeio1:: + @$(AWK) -f $(srcdir)/pipeio1.awk >_$@ + @rm -f test1 test2 + $(CMP) $(srcdir)/pipeio1.ok _$@ && rm -f _$@ + +pipeio2:: + @$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@ + $(CMP) $(srcdir)/pipeio2.ok _$@ && rm -f _$@ + +funstack:: + @$(AWK) -f $(srcdir)/funstack.awk $(srcdir)/funstack.in >_$@ + $(CMP) $(srcdir)/funstack.ok _$@ && rm -f _$@ + +clobber:: + @$(AWK) -f $(srcdir)/clobber.awk >_$@ + $(CMP) $(srcdir)/clobber.ok seq && $(CMP) $(srcdir)/clobber.ok _$@ && rm -f _$@ + @rm -f seq + +delarprm:: + @$(AWK) -f $(srcdir)/delarprm.awk >_$@ + $(CMP) $(srcdir)/delarprm.ok _$@ && rm -f _$@ + +prdupval:: + @$(AWK) -f $(srcdir)/prdupval.awk $(srcdir)/prdupval.in >_$@ + $(CMP) $(srcdir)/prdupval.ok _$@ && rm -f _$@ + +nondec:: + @if grep BITOP ../config.h | grep define > /dev/null; \ + then \ + $(AWK) -f $(srcdir)/nondec.awk >_$@; \ + else \ + cp $(srcdir)/nondec.ok _$@; \ + fi + $(CMP) $(srcdir)/nondec.ok _$@ && rm -f _$@ + +clean: + rm -fr _* core junk out1 out2 out3 strftime.ok test1 test2 seq *~ + +distclean: clean + rm -f Makefile + +maintainer-clean: distclean diff --git a/contrib/awk/test/README b/contrib/awk/test/README new file mode 100644 index 0000000..2343be2 --- /dev/null +++ b/contrib/awk/test/README @@ -0,0 +1,18 @@ +Mon Jan 22 13:08:58 EST 1996 + +This directory contains the tests for gawk. The tests use the +following conventions. + +Given some aspect of gawk named `foo', there will be one or more +of the following files: + +foo.awk --- actual code for the test if not inline in the Makefile +foo.in --- the data for the test, if it needs data +foo.ok --- the expected results +_foo --- the actual results; generated at run time + +The _foo file will be left around if a test fails, allowing you to +compare actual and expected results, in case they differ. + +If they do differ (other than strftime.ok and _strftime!), send in a +bug report. See the manual for the bug report procedure. diff --git a/contrib/awk/test/anchgsub.awk b/contrib/awk/test/anchgsub.awk new file mode 100644 index 0000000..52e8aa4 --- /dev/null +++ b/contrib/awk/test/anchgsub.awk @@ -0,0 +1 @@ +{ gsub(/^[ ]*/, "", $0) ; print } diff --git a/contrib/awk/test/anchgsub.in b/contrib/awk/test/anchgsub.in new file mode 100644 index 0000000..b829d84 --- /dev/null +++ b/contrib/awk/test/anchgsub.in @@ -0,0 +1 @@ + This is a test, this is only a test. diff --git a/contrib/awk/test/anchgsub.ok b/contrib/awk/test/anchgsub.ok new file mode 100644 index 0000000..c33dfb9 --- /dev/null +++ b/contrib/awk/test/anchgsub.ok @@ -0,0 +1 @@ +This is a test, this is only a test. diff --git a/contrib/awk/test/argarray.awk b/contrib/awk/test/argarray.awk new file mode 100644 index 0000000..1960f9bd --- /dev/null +++ b/contrib/awk/test/argarray.awk @@ -0,0 +1,14 @@ +BEGIN { + argn = " argument" (ARGC > 1 ? "s" : "") + are = ARGC > 1 ? "are" : "is" + print "here we have " ARGC argn + print "which " are + for (x = 0; x < ARGC; x++) + print "\t", ARGV[x] + print "Environment variable TEST=" ENVIRON["TEST"] + print "and the current input file is called \"" FILENAME "\"" +} + +FNR == 1 { + print "in main loop, this input file is known as \"" FILENAME "\"" +} diff --git a/contrib/awk/test/argarray.in b/contrib/awk/test/argarray.in new file mode 100644 index 0000000..bc93338 --- /dev/null +++ b/contrib/awk/test/argarray.in @@ -0,0 +1 @@ +this is a simple test file diff --git a/contrib/awk/test/argarray.ok b/contrib/awk/test/argarray.ok new file mode 100644 index 0000000..18eb841 --- /dev/null +++ b/contrib/awk/test/argarray.ok @@ -0,0 +1,9 @@ +here we have 3 arguments +which are + gawk + ./argarray.in + - +Environment variable TEST= +and the current input file is called "" +in main loop, this input file is known as "./argarray.in" +in main loop, this input file is known as "-" diff --git a/contrib/awk/test/argtest.awk b/contrib/awk/test/argtest.awk new file mode 100644 index 0000000..e7a1145 --- /dev/null +++ b/contrib/awk/test/argtest.awk @@ -0,0 +1,4 @@ +BEGIN { + for (i = 0; i < ARGC; i++) + printf("ARGV[%d] = %s\n", i, ARGV[i]) +} diff --git a/contrib/awk/test/argtest.ok b/contrib/awk/test/argtest.ok new file mode 100644 index 0000000..591bc64 --- /dev/null +++ b/contrib/awk/test/argtest.ok @@ -0,0 +1,4 @@ +ARGV[0] = gawk +ARGV[1] = -x +ARGV[2] = -y +ARGV[3] = abc diff --git a/contrib/awk/test/arrayparm.awk b/contrib/awk/test/arrayparm.awk new file mode 100644 index 0000000..d6f34d9 --- /dev/null +++ b/contrib/awk/test/arrayparm.awk @@ -0,0 +1,21 @@ +# +# Test program from: +# +# Date: Tue, 21 Feb 95 16:09:29 EST +# From: emory!blackhawk.com!aaron (Aaron Sosnick) +# +BEGIN { + foo[1]=1; + foo[2]=2; + bug1(foo); +} +function bug1(i) { + for (i in foo) { + bug2(i); + delete foo[i]; + print i,1,bot[1]; + } +} +function bug2(arg) { + bot[arg]=arg; +} diff --git a/contrib/awk/test/arrayparm.ok b/contrib/awk/test/arrayparm.ok new file mode 100644 index 0000000..b315f7c --- /dev/null +++ b/contrib/awk/test/arrayparm.ok @@ -0,0 +1 @@ +gawk: arrayparm.awk:18: fatal: attempt to use array `foo' in a scalar context diff --git a/contrib/awk/test/arrayref.awk b/contrib/awk/test/arrayref.awk new file mode 100644 index 0000000..144d41a --- /dev/null +++ b/contrib/awk/test/arrayref.awk @@ -0,0 +1,13 @@ + BEGIN { # foo[10] = 0 # put this line in and it will work + test(foo); print foo[1] + test2(foo2); print foo2[1] + } + + function test(foo) + { + test2(foo) + } + function test2(bar) + { + bar[1] = 1 + } diff --git a/contrib/awk/test/arrayref.ok b/contrib/awk/test/arrayref.ok new file mode 100644 index 0000000..6ed281c --- /dev/null +++ b/contrib/awk/test/arrayref.ok @@ -0,0 +1,2 @@ +1 +1 diff --git a/contrib/awk/test/asgext.awk b/contrib/awk/test/asgext.awk new file mode 100644 index 0000000..c7f1775 --- /dev/null +++ b/contrib/awk/test/asgext.awk @@ -0,0 +1 @@ +{ print $3; $4 = "a"; print } diff --git a/contrib/awk/test/asgext.in b/contrib/awk/test/asgext.in new file mode 100644 index 0000000..3743b5b --- /dev/null +++ b/contrib/awk/test/asgext.in @@ -0,0 +1,3 @@ +1 2 3 +1 +1 2 3 4 diff --git a/contrib/awk/test/asgext.ok b/contrib/awk/test/asgext.ok new file mode 100644 index 0000000..2c0df70 --- /dev/null +++ b/contrib/awk/test/asgext.ok @@ -0,0 +1,6 @@ +3 +1 2 3 a + +1 a +3 +1 2 3 a diff --git a/contrib/awk/test/awkpath.ok b/contrib/awk/test/awkpath.ok new file mode 100644 index 0000000..6cffe1b --- /dev/null +++ b/contrib/awk/test/awkpath.ok @@ -0,0 +1 @@ +Found it. diff --git a/contrib/awk/test/back89.in b/contrib/awk/test/back89.in new file mode 100644 index 0000000..b0a88f2 --- /dev/null +++ b/contrib/awk/test/back89.in @@ -0,0 +1,2 @@ +a8b +a\8b diff --git a/contrib/awk/test/back89.ok b/contrib/awk/test/back89.ok new file mode 100644 index 0000000..e9ea4d5 --- /dev/null +++ b/contrib/awk/test/back89.ok @@ -0,0 +1 @@ +a8b diff --git a/contrib/awk/test/backgsub.awk b/contrib/awk/test/backgsub.awk new file mode 100644 index 0000000..bec7354 --- /dev/null +++ b/contrib/awk/test/backgsub.awk @@ -0,0 +1,4 @@ +{ + gsub( "\\\\", "\\\\") + print +} diff --git a/contrib/awk/test/backgsub.in b/contrib/awk/test/backgsub.in new file mode 100644 index 0000000..2d3f17f --- /dev/null +++ b/contrib/awk/test/backgsub.in @@ -0,0 +1 @@ +\x\y\z diff --git a/contrib/awk/test/backgsub.ok b/contrib/awk/test/backgsub.ok new file mode 100644 index 0000000..e2e265f --- /dev/null +++ b/contrib/awk/test/backgsub.ok @@ -0,0 +1 @@ +\\x\\y\\z diff --git a/contrib/awk/test/badargs.ok b/contrib/awk/test/badargs.ok new file mode 100644 index 0000000..c89e520 --- /dev/null +++ b/contrib/awk/test/badargs.ok @@ -0,0 +1,23 @@ +gawk: option requires an argument -- f +Usage: gawk [POSIX or GNU style options] -f progfile [--] file ... + gawk [POSIX or GNU style options] [--] 'program' file ... +POSIX options: GNU long options: + -f progfile --file=progfile + -F fs --field-separator=fs + -v var=val --assign=var=val + -m[fr] val + -W compat --compat + -W copyleft --copyleft + -W copyright --copyright + -W help --help + -W lint --lint + -W lint-old --lint-old + -W posix --posix + -W re-interval --re-interval + -W source=program-text --source=program-text + -W traditional --traditional + -W usage --usage + -W version --version + +Report bugs to bug-gnu-utils@prep.ai.mit.edu, +with a Cc: to arnold@gnu.ai.mit.edu diff --git a/contrib/awk/test/childin.ok b/contrib/awk/test/childin.ok new file mode 100644 index 0000000..45b983b --- /dev/null +++ b/contrib/awk/test/childin.ok @@ -0,0 +1 @@ +hi diff --git a/contrib/awk/test/clobber.awk b/contrib/awk/test/clobber.awk new file mode 100644 index 0000000..d6635f2 --- /dev/null +++ b/contrib/awk/test/clobber.awk @@ -0,0 +1,98 @@ +BEGIN { + print "000800" > "seq" + close("seq") + ARGV[1] = "seq" + ARGC = 2 +} + +{ printf "%06d", $1 + 1 >"seq"; + printf "%06d", $1 + 1 } +# Date: Mon, 20 Jan 1997 15:14:06 -0600 (CST) +# From: Dave Bodenstab <emory!synet.net!imdave> +# To: bug-gnu-utils@prep.ai.mit.edu +# Subject: GNU awk 3.0.2 core dump +# Cc: arnold@gnu.ai.mit.edu +# +# The following program produces a core file on my FreeBSD system: +# +# bash$ echo 000800 >/tmp/seq +# bash$ gawk '{ printf "%06d", $1 + 1 >"/tmp/seq"; +# printf "%06d", $1 + 1 }' /tmp/seq +# +# This fragment comes from mgetty+sendfax. +# +# Here is the trace: +# +# Script started on Mon Jan 20 15:09:04 1997 +# bash$ gawk --version +# GNU Awk 3.0.2 +# Copyright (C) 1989, 1991-1996 Free Software Foundation. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# bash$ gdb gawk +# GDB is free software and you are welcome to distribute copies of it +# under certain conditions; type "show copying" to see the conditions. +# There is absolutely no warranty for GDB; type "show warranty" for details. +# GDB 4.13 (i386-unknown-freebsd), +# Copyright 1994 Free Software Foundation, Inc... +# (gdb) shell echo 000800 >/tmp/seq +# (gdb) r '{ printf "%06d", $1 + 1 >"/tmp/seq"; printf "%06d", $1 + 1 }(gdb) r '{ printf "%06d", $1 + 1 >"/tmp/seq"; printf "%06d", $1 + 1 }' /tmp/seq +# Starting program: /scratch/archive/src/cmd/gnuawk-3.0.2/gawk '{ printf "%06d", $1 + 1 >"/tmp/seq"; printf "%06d", $1 + 1 }' /tmp/seq +# +# Program received signal SIGBUS, Bus error. +# 0xd86f in def_parse_field (up_to=1, buf=0x37704, len=6, fs=0x3b240, rp=0x0, +# set=0xce6c <set_field>, n=0x0) at field.c:391 +# 391 sav = *end; +# (gdb) bt +# #0 0xd86f in def_parse_field (up_to=1, buf=0x37704, len=6, fs=0x3b240, +# rp=0x0, set=0xce6c <set_field>, n=0x0) at field.c:391 +# #1 0xddb1 in get_field (requested=1, assign=0x0) at field.c:669 +# #2 0xc25d in r_get_lhs (ptr=0x3b9b4, assign=0x0) at eval.c:1339 +# #3 0x9ab0 in r_tree_eval (tree=0x3b9b4, iscond=0) at eval.c:604 +# #4 0xa5f1 in r_tree_eval (tree=0x3b9fc, iscond=0) at eval.c:745 +# #5 0x4661 in format_tree (fmt_string=0x3e040 "%06d", n0=0, carg=0x3ba20) +# at builtin.c:620 +# #6 0x5beb in do_sprintf (tree=0x3b96c) at builtin.c:809 +# #7 0x5cd5 in do_printf (tree=0x3ba8c) at builtin.c:844 +# #8 0x9271 in interpret (tree=0x3ba8c) at eval.c:465 +# #9 0x8ca3 in interpret (tree=0x3bbd0) at eval.c:308 +# #10 0x8c34 in interpret (tree=0x3bc18) at eval.c:292 +# #11 0xf069 in do_input () at io.c:312 +# #12 0x12ba9 in main (argc=3, argv=0xefbfd538) at main.c:393 +# (gdb) l +# 386 *buf += len; +# 387 return nf; +# 388 } +# 389 +# 390 /* before doing anything save the char at *end */ +# 391 sav = *end; +# 392 /* because it will be destroyed now: */ +# 393 +# 394 *end = ' '; /* sentinel character */ +# 395 for (; nf < up_to; scan++) { +# (gdb) print end +# $1 = 0x804d006 <Error reading address 0x804d006: No such file or directory> +# (gdb) print buf +# $2 = (char **) 0x37704 +# (gdb) print *buf +# $3 = 0x804d000 <Error reading address 0x804d000: No such file or directory> +# (gdb) q +# The program is running. Quit anyway (and kill it)? (y or n) y +# bash$ exit +# +# Script done on Mon Jan 20 15:11:07 1997 +# +# Dave Bodenstab +# imdave@synet.net diff --git a/contrib/awk/test/clobber.ok b/contrib/awk/test/clobber.ok new file mode 100644 index 0000000..7105708 --- /dev/null +++ b/contrib/awk/test/clobber.ok @@ -0,0 +1 @@ +000801
\ No newline at end of file diff --git a/contrib/awk/test/clsflnam.awk b/contrib/awk/test/clsflnam.awk new file mode 100644 index 0000000..5392891 --- /dev/null +++ b/contrib/awk/test/clsflnam.awk @@ -0,0 +1,12 @@ +#! /usr/bin/awk -f +BEGIN { + getline +# print ("FILENAME =", FILENAME) > "/dev/stderr" + #Rewind the file + if (close(FILENAME)) { + print "Error " ERRNO " closing input file" > "/dev/stderr"; + exit; + } +} +{ print "Analysing ", $0 } + diff --git a/contrib/awk/test/clsflnam.in b/contrib/awk/test/clsflnam.in new file mode 100644 index 0000000..a92d664 --- /dev/null +++ b/contrib/awk/test/clsflnam.in @@ -0,0 +1,3 @@ +line 1 +line 2 +line 3 diff --git a/contrib/awk/test/clsflnam.ok b/contrib/awk/test/clsflnam.ok new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/clsflnam.ok diff --git a/contrib/awk/test/compare.awk b/contrib/awk/test/compare.awk new file mode 100644 index 0000000..39a88f3 --- /dev/null +++ b/contrib/awk/test/compare.awk @@ -0,0 +1,13 @@ +BEGIN { + if (ARGV[1]) print 1 + ARGV[1] = "" + if (ARGV[2]) print 2 + ARGV[2] = "" + if ("0") print "zero" + if ("") print "null" + if (0) print 0 +} +{ + if ($0) print $0 + if ($1) print $1 +} diff --git a/contrib/awk/test/compare.in b/contrib/awk/test/compare.in new file mode 100644 index 0000000..1ab098b --- /dev/null +++ b/contrib/awk/test/compare.in @@ -0,0 +1,4 @@ +0 +1 +0 1 + diff --git a/contrib/awk/test/compare.ok b/contrib/awk/test/compare.ok new file mode 100644 index 0000000..8241359 --- /dev/null +++ b/contrib/awk/test/compare.ok @@ -0,0 +1,5 @@ +2 +zero +1 +1 +0 1 diff --git a/contrib/awk/test/convfmt.awk b/contrib/awk/test/convfmt.awk new file mode 100644 index 0000000..90fd204 --- /dev/null +++ b/contrib/awk/test/convfmt.awk @@ -0,0 +1,10 @@ +BEGIN { + CONVFMT = "%2.2f" + a = 123.456 + b = a "" # give `a' string value also + printf "a = %s\n", a + CONVFMT = "%.6g" + printf "a = %s\n", a + a += 0 # make `a' numeric only again + printf "a = %s\n", a # use `a' as string +} diff --git a/contrib/awk/test/convfmt.ok b/contrib/awk/test/convfmt.ok new file mode 100644 index 0000000..a7b66f7 --- /dev/null +++ b/contrib/awk/test/convfmt.ok @@ -0,0 +1,3 @@ +a = 123.46 +a = 123.456 +a = 123.456 diff --git a/contrib/awk/test/defref.awk b/contrib/awk/test/defref.awk new file mode 100644 index 0000000..b4e8f10 --- /dev/null +++ b/contrib/awk/test/defref.awk @@ -0,0 +1 @@ +BEGIN { foo() } diff --git a/contrib/awk/test/defref.ok b/contrib/awk/test/defref.ok new file mode 100644 index 0000000..f833c96 --- /dev/null +++ b/contrib/awk/test/defref.ok @@ -0,0 +1,2 @@ +gawk: defref.awk:2: warning: function `foo' called but never defined +gawk: defref.awk:1: fatal: function `foo' not defined diff --git a/contrib/awk/test/delarprm.awk b/contrib/awk/test/delarprm.awk new file mode 100644 index 0000000..d59de31 --- /dev/null +++ b/contrib/awk/test/delarprm.awk @@ -0,0 +1,50 @@ +# From dragon!unagi.cis.upenn.edu!sjanet Tue Mar 25 17:12:20 1997 +# Return-Path: <dragon!unagi.cis.upenn.edu!sjanet> +# Received: by skeeve.atl.ga.us (/\==/\ Smail3.1.22.1 #22.1) +# id <m0w9eS4-000GWyC@skeeve.atl.ga.us>; Tue, 25 Mar 97 17:12 EST +# Received: by vecnet.com (DECUS UUCP /2.0/2.0/2.0/); +# Tue, 25 Mar 97 16:58:36 EDT +# Received: from gnu-life.ai.mit.edu by antaries.vec.net (MX V4.2 VAX) with SMTP; +# Tue, 25 Mar 1997 16:58:26 EST +# Received: from linc.cis.upenn.edu by gnu-life.ai.mit.edu (8.8.5/8.6.12GNU) with +# ESMTP id QAA24350 for <bug-gnu-utils@prep.ai.mit.edu>; Tue, 25 Mar +# 1997 16:56:59 -0500 (EST) +# Received: from unagi.cis.upenn.edu (UNAGI.CIS.UPENN.EDU [158.130.8.153]) by +# linc.cis.upenn.edu (8.8.5/8.8.5) with ESMTP id QAA09424; Tue, 25 Mar +# 1997 16:56:54 -0500 (EST) +# Received: (from sjanet@localhost) by unagi.cis.upenn.edu (8.8.5/8.8.5) id +# QAA03969; Tue, 25 Mar 1997 16:56:50 -0500 (EST) +# Date: Tue, 25 Mar 1997 16:56:50 -0500 (EST) +# From: Stan Janet <sjanet@unagi.cis.upenn.edu> +# Message-ID: <199703252156.QAA03969@unagi.cis.upenn.edu> +# To: bug-gnu-utils@prep.ai.mit.edu +# CC: arnold@gnu.ai.mit.edu +# Subject: GNU awk 3.0.2 bug: fatal error deleting local array inside function +# Status: ORf +# +# Version: GNU Awk 3.0.2 +# Platforms: SunOS 4.1.1 (compiled with Sun cc) +# IRIX 5.3 (compiled with SGI cc) +# Problem: Deleting local array inside function causes fatal internal error (and +# core dump. The error does not occur when the variable "x", unused in +# the example, is removed or when the function is declared foo(x,p). +# When the function is declared foo(p,x), adding a dummy line that uses +# "x", e.g. "x=1" does not prevent the error. If "p" is not deleted, +# there is no error. If "p[1]" is used to delete the lone element, there +# is no error. +# +# ==== The program x.gawk ==== + +function foo(p,x) { + p[1]="bar" + delete p + return 0 +} + +BEGIN { + foo() +} + +# ==== The output for "gawk -f x.gawk" (SunOS) ==== +# +# gawk: x.gawk:4: fatal error: internal error diff --git a/contrib/awk/test/delarprm.ok b/contrib/awk/test/delarprm.ok new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/delarprm.ok diff --git a/contrib/awk/test/dynlj.awk b/contrib/awk/test/dynlj.awk new file mode 100644 index 0000000..ec6851b --- /dev/null +++ b/contrib/awk/test/dynlj.awk @@ -0,0 +1 @@ +BEGIN { printf "%*sworld\n", -20, "hello" } diff --git a/contrib/awk/test/dynlj.ok b/contrib/awk/test/dynlj.ok new file mode 100644 index 0000000..c8f3fe9 --- /dev/null +++ b/contrib/awk/test/dynlj.ok @@ -0,0 +1 @@ +hello world diff --git a/contrib/awk/test/eofsplit.awk b/contrib/awk/test/eofsplit.awk new file mode 100644 index 0000000..22042b4 --- /dev/null +++ b/contrib/awk/test/eofsplit.awk @@ -0,0 +1,68 @@ +# Date: Sat, 30 Mar 1996 12:47:17 -0800 (PST) +# From: Charles Howes <chowes@grid.direct.ca> +# To: bug-gnu-utils@prep.ai.mit.edu, arnold@gnu.ai.mit.edu +# Subject: Bug in Gawk 3.0.0, sample code: +# +#!/usr/local/bin/gawk -f +# +# Hello! This is a bug report from chowes@direct.ca +# +# uname -a +# SunOS hostname 5.5 Generic sun4m +# +# Gnu Awk (gawk) 3.0, patchlevel 0: +BEGIN{ +FS=":" +while ((getline < "/etc/passwd") > 0) { + r=$3 + z=0 + n[0]=1 + } +FS=" " +} +#gawk: fp.new:16: fatal error: internal error +#Abort + +# #!/usr/local/bin/gawk -f +# # Gnu Awk (gawk) 2.15, patchlevel 6 +# +# BEGIN{ +# f="/etc/passwd" +# while (getline < f) n[0]=1 +# FS=" " +# } +# #gawk: /staff/chowes/bin/fp:7: fatal error: internal error +# #Abort + +# These examples are not perfect coding style because I took a real +# piece of code and tried to strip away anything that didn't make the error +# message go away. +# +# The interesting part of the 'truss' is: +# +# fstat(3, 0xEFFFF278) = 0 +# lseek(3, 0, SEEK_SET) = 0 +# read(3, " r o o t : x : 0 : 1 : S".., 2291) = 2291 +# brk(0x00050020) = 0 +# brk(0x00052020) = 0 +# read(3, 0x0004F4B8, 2291) = 0 +# close(3) = 0 +# Incurred fault #6, FLTBOUNDS %pc = 0x0001B810 +# siginfo: SIGSEGV SEGV_MAPERR addr=0x00053000 +# Received signal #11, SIGSEGV [caught] +# siginfo: SIGSEGV SEGV_MAPERR addr=0x00053000 +# write(2, " g a w k", 4) = 4 +# write(2, " : ", 2) = 2 +# +# -- +# Charles Howes -- chowes@direct.ca Voice: (604) 691-1607 +# System Administrator Fax: (604) 691-1605 +# Internet Direct - 1050 - 555 West Hastings St - Vancouver, BC V6B 4N6 +# +# A sysadmin's life is a sorry one. The only advantage he has over Emergency +# Room doctors is that malpractice suits are rare. On the other hand, ER +# doctors never have to deal with patients installing new versions of their +# own innards! -Michael O'Brien +# +# "I think I know what may have gone wrong in the original s/w. +# It's a bug in the way it was written." - Vagueness**n diff --git a/contrib/awk/test/eofsplit.ok b/contrib/awk/test/eofsplit.ok new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/eofsplit.ok diff --git a/contrib/awk/test/fflush.ok b/contrib/awk/test/fflush.ok new file mode 100644 index 0000000..4cf0df6 --- /dev/null +++ b/contrib/awk/test/fflush.ok @@ -0,0 +1,16 @@ +1st +2nd +1st +2nd +1st +2nd +1st +2nd +1st +2nd +1st +2nd +1st +2nd +1st +2nd diff --git a/contrib/awk/test/fflush.sh b/contrib/awk/test/fflush.sh new file mode 100755 index 0000000..42d624c --- /dev/null +++ b/contrib/awk/test/fflush.sh @@ -0,0 +1,16 @@ +#! /bin/sh +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"cat"}' + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"cat"}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");close("/dev/stdout");print "2nd"|"cat"}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"cat";close("cat")}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"cat";close("cat")}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"cat";close("cat")}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"sort"}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"sort";close("sort")}'|cat diff --git a/contrib/awk/test/fieldwdth.ok b/contrib/awk/test/fieldwdth.ok new file mode 100644 index 0000000..51b4008 --- /dev/null +++ b/contrib/awk/test/fieldwdth.ok @@ -0,0 +1 @@ +345 diff --git a/contrib/awk/test/fldchg.awk b/contrib/awk/test/fldchg.awk new file mode 100644 index 0000000..a8018f7 --- /dev/null +++ b/contrib/awk/test/fldchg.awk @@ -0,0 +1,8 @@ +{ +# print "0:", $0 + gsub("aa", "+") + print "1:", $0 + $3 = "<" $3 ">" + print "2:", $0 + print "2a:" "%" $1 "%" $2 "%" $3 "%" $4 "%" $5 +} diff --git a/contrib/awk/test/fldchg.in b/contrib/awk/test/fldchg.in new file mode 100644 index 0000000..f500c36 --- /dev/null +++ b/contrib/awk/test/fldchg.in @@ -0,0 +1 @@ +aa aab c d e f diff --git a/contrib/awk/test/fldchg.ok b/contrib/awk/test/fldchg.ok new file mode 100644 index 0000000..cc5032a --- /dev/null +++ b/contrib/awk/test/fldchg.ok @@ -0,0 +1,3 @@ +1: + +b c d e f +2: + +b <c> d e f +2a:%+%+b%<c>%d%e diff --git a/contrib/awk/test/fldchgnf.awk b/contrib/awk/test/fldchgnf.awk new file mode 100644 index 0000000..fbb8f11 --- /dev/null +++ b/contrib/awk/test/fldchgnf.awk @@ -0,0 +1 @@ +{ OFS = ":"; $2 = ""; print $0; print NF } diff --git a/contrib/awk/test/fldchgnf.in b/contrib/awk/test/fldchgnf.in new file mode 100644 index 0000000..8e13e46 --- /dev/null +++ b/contrib/awk/test/fldchgnf.in @@ -0,0 +1 @@ +a b c d diff --git a/contrib/awk/test/fldchgnf.ok b/contrib/awk/test/fldchgnf.ok new file mode 100644 index 0000000..10b38ed --- /dev/null +++ b/contrib/awk/test/fldchgnf.ok @@ -0,0 +1,2 @@ +a::c:d +4 diff --git a/contrib/awk/test/fnarray.awk b/contrib/awk/test/fnarray.awk new file mode 100644 index 0000000..92a18b9 --- /dev/null +++ b/contrib/awk/test/fnarray.awk @@ -0,0 +1,7 @@ +function foo(N) { + return 0 +} +BEGIN { + Num = foo[c] +} + diff --git a/contrib/awk/test/fnarray.ok b/contrib/awk/test/fnarray.ok new file mode 100644 index 0000000..94beacd --- /dev/null +++ b/contrib/awk/test/fnarray.ok @@ -0,0 +1 @@ +gawk: fnarray.awk:5: fatal: attempt to use function `foo' as array diff --git a/contrib/awk/test/fnarydel.awk b/contrib/awk/test/fnarydel.awk new file mode 100644 index 0000000..8a1264c --- /dev/null +++ b/contrib/awk/test/fnarydel.awk @@ -0,0 +1,60 @@ +#!/usr/local/bin/gawk -f +BEGIN { + process() +} + +function process(aa,a) { + delete aa +} + +BEGIN { + for (i = 1; i < 10; i++) + a[i] = i; + + print "first loop" + for (i in a) + print a[i] + + delete a + + print "second loop" + for (i in a) + print a[i] + + for (i = 1; i < 10; i++) + a[i] = i; + + print "third loop" + for (i in a) + print a[i] + + print "call func" + delit(a) + + print "fourth loop" + for (i in a) + print a[i] + + stressit() +} + +function delit(arr) +{ + delete arr +} + +function stressit( array, i) +{ + delete array + array[4] = 4 + array[5] = 5 + delete array[5] + print "You should just see: 4 4" + for (i in array) + print i, array[i] + delete array + print "You should see nothing between this line" + for (i in array) + print i, array[i] + print "And this one" +} diff --git a/contrib/awk/test/fnarydel.ok b/contrib/awk/test/fnarydel.ok new file mode 100644 index 0000000..7f3e453 --- /dev/null +++ b/contrib/awk/test/fnarydel.ok @@ -0,0 +1,27 @@ +first loop +4 +5 +6 +7 +8 +9 +1 +2 +3 +second loop +third loop +4 +5 +6 +7 +8 +9 +1 +2 +3 +call func +fourth loop +You should just see: 4 4 +4 4 +You should see nothing between this line +And this one diff --git a/contrib/awk/test/fsbs.in b/contrib/awk/test/fsbs.in new file mode 100644 index 0000000..0a102c3 --- /dev/null +++ b/contrib/awk/test/fsbs.in @@ -0,0 +1 @@ +1\2 diff --git a/contrib/awk/test/fsbs.ok b/contrib/awk/test/fsbs.ok new file mode 100644 index 0000000..8d04f96 --- /dev/null +++ b/contrib/awk/test/fsbs.ok @@ -0,0 +1 @@ +1 2 diff --git a/contrib/awk/test/fsrs.awk b/contrib/awk/test/fsrs.awk new file mode 100644 index 0000000..a001489 --- /dev/null +++ b/contrib/awk/test/fsrs.awk @@ -0,0 +1,8 @@ +BEGIN { + RS=""; FS="\n"; + ORS=""; OFS="\n"; + } +{ + split ($2,f," ") + print $0; +} diff --git a/contrib/awk/test/fsrs.in b/contrib/awk/test/fsrs.in new file mode 100644 index 0000000..4b49d81 --- /dev/null +++ b/contrib/awk/test/fsrs.in @@ -0,0 +1,7 @@ +a b +c d +e f + +1 2 +3 4 +5 6 diff --git a/contrib/awk/test/fsrs.ok b/contrib/awk/test/fsrs.ok new file mode 100644 index 0000000..7dafd65 --- /dev/null +++ b/contrib/awk/test/fsrs.ok @@ -0,0 +1,5 @@ +a b +c d +e f1 2 +3 4 +5 6
\ No newline at end of file diff --git a/contrib/awk/test/fstabplus.awk b/contrib/awk/test/fstabplus.awk new file mode 100644 index 0000000..748a44f --- /dev/null +++ b/contrib/awk/test/fstabplus.awk @@ -0,0 +1,2 @@ +BEGIN { FS = "\t+" } + { print $1, $2 } diff --git a/contrib/awk/test/fstabplus.ok b/contrib/awk/test/fstabplus.ok new file mode 100644 index 0000000..8d04f96 --- /dev/null +++ b/contrib/awk/test/fstabplus.ok @@ -0,0 +1 @@ +1 2 diff --git a/contrib/awk/test/funstack.awk b/contrib/awk/test/funstack.awk new file mode 100644 index 0000000..ab85b45 --- /dev/null +++ b/contrib/awk/test/funstack.awk @@ -0,0 +1,977 @@ +### ==================================================================== +### @Awk-file{ +### author = "Nelson H. F. Beebe", +### version = "1.00", +### date = "09 October 1996", +### time = "15:57:06 MDT", +### filename = "journal-toc.awk", +### address = "Center for Scientific Computing +### Department of Mathematics +### University of Utah +### Salt Lake City, UT 84112 +### USA", +### telephone = "+1 801 581 5254", +### FAX = "+1 801 581 4148", +### URL = "http://www.math.utah.edu/~beebe", +### checksum = "25092 977 3357 26493", +### email = "beebe@math.utah.edu (Internet)", +### codetable = "ISO/ASCII", +### keywords = "BibTeX, bibliography, HTML, journal table of +### contents", +### supported = "yes", +### docstring = "Create a journal cover table of contents from +### <at>Article{...} entries in a journal BibTeX +### .bib file for checking the bibliography +### database against the actual journal covers. +### The output can be either plain text, or HTML. +### +### Usage: +### bibclean -max-width 0 BibTeX-file(s) | \ +### bibsort -byvolume | \ +### awk -f journal-toc.awk \ +### [-v HTML=nnn] [-v INDENT=nnn] \ +### [-v BIBFILEURL=url] >foo.toc +### +### or if the bibliography is already sorted +### by volume, +### +### bibclean -max-width 0 BibTeX-file(s) | \ +### awk -f journal-toc.awk \ +### [-v HTML=nnn] [-v INDENT=nnn] \ +### [-v BIBFILEURL=url] >foo.toc +### +### A non-zero value of the command-line option, +### HTML=nnn, results in HTML output instead of +### the default plain ASCII text (corresponding +### to HTML=0). The +### +### The INDENT=nnn command-line option specifies +### the number of blanks to indent each logical +### level of HTML. The default is INDENT=4. +### INDENT=0 suppresses indentation. The INDENT +### option has no effect when the default HTML=0 +### (plain text output) option is in effect. +### +### When HTML output is selected, the +### BIBFILEURL=url command-line option provides a +### way to request hypertext links from table of +### contents page numbers to the complete BibTeX +### entry for the article. These links are +### created by appending a sharp (#) and the +### citation label to the BIBFILEURL value, which +### conforms with the practice of +### bibtex-to-html.awk. +### +### The HTML output form may be useful as a more +### compact representation of journal article +### bibliography data than the original BibTeX +### file provides. Of course, the +### table-of-contents format provides less +### information, and is considerably more +### troublesome for a computer program to parse. +### +### When URL key values are provided, they will +### be used to create hypertext links around +### article titles. This supports journals that +### provide article contents on the World-Wide +### Web. +### +### For parsing simplicity, this program requires +### that BibTeX +### +### key = "value" +### +### and +### +### @String{name = "value"} +### +### specifications be entirely contained on +### single lines, which is readily provided by +### the `bibclean -max-width 0' filter. It also +### requires that bibliography entries begin and +### end at the start of a line, and that +### quotation marks, rather than balanced braces, +### delimit string values. This is a +### conventional format that again can be +### guaranteed by bibclean. +### +### This program requires `new' awk, as described +### in the book +### +### Alfred V. Aho, Brian W. Kernighan, and +### Peter J. Weinberger, +### ``The AWK Programming Language'', +### Addison-Wesley (1988), ISBN +### 0-201-07981-X, +### +### such as provided by programs named (GNU) +### gawk, nawk, and recent AT&T awk. +### +### The checksum field above contains a CRC-16 +### checksum as the first value, followed by the +### equivalent of the standard UNIX wc (word +### count) utility output of lines, words, and +### characters. This is produced by Robert +### Solovay's checksum utility.", +### } +### ==================================================================== + +BEGIN { initialize() } + +/^ *@ *[Ss][Tt][Rr][Ii][Nn][Gg] *{/ { do_String(); next } + +/^ *@ *[Pp][Rr][Ee][Aa][Mm][Bb][Ll][Ee]/ { next } + +/^ *@ *[Aa][Rr][Tt][Ii][Cc][Ll][Ee]/ { do_Article(); next } + +/^ *@/ { do_Other(); next } + +/^ *author *= *\"/ { do_author(); next } + +/^ *journal *= */ { do_journal(); next } + +/^ *volume *= *\"/ { do_volume(); next } + +/^ *number *= *\"/ { do_number(); next } + +/^ *year *= *\"/ { do_year(); next } + +/^ *month *= */ { do_month(); next } + +/^ *title *= *\"/ { do_title(); next } + +/^ *pages *= *\"/ { do_pages(); next } + +/^ *URL *= *\"/ { do_URL(); next } + +/^ *} *$/ { if (In_Article) do_end_entry(); next } + +END { terminate() } + + +######################################################################## +# NB: The programming conventions for variables in this program are: # +# UPPERCASE global constants and user options # +# Initialuppercase global variables # +# lowercase local variables # +# Any deviation is an error! # +######################################################################## + + +function do_Article() +{ + In_Article = 1 + + Citation_label = $0 + sub(/^[^\{]*{/,"",Citation_label) + sub(/ *, *$/,"",Citation_label) + + Author = "" + Title = "" + Journal = "" + Volume = "" + Number = "" + Month = "" + Year = "" + Pages = "" + Url = "" +} + + +function do_author() +{ + Author = TeX_to_HTML(get_value($0)) +} + + +function do_end_entry( k,n,parts) +{ + n = split(Author,parts," and ") + if (Last_number != Number) + do_new_issue() + for (k = 1; k < n; ++k) + print_toc_line(parts[k] " and", "", "") + Title_prefix = html_begin_title() + Title_suffix = html_end_title() + if (html_length(Title) <= (MAX_TITLE_CHARS + MIN_LEADERS)) # complete title fits on line + print_toc_line(parts[n], Title, html_begin_pages() Pages html_end_pages()) + else # need to split long title over multiple lines + do_long_title(parts[n], Title, html_begin_pages() Pages html_end_pages()) +} + + +function do_journal() +{ + if ($0 ~ /[=] *"/) # have journal = "quoted journal name", + Journal = get_value($0) + else # have journal = journal-abbreviation, + { + Journal = get_abbrev($0) + if (Journal in String) # replace abbrev by its expansion + Journal = String[Journal] + } + gsub(/\\-/,"",Journal) # remove discretionary hyphens +} + + +function do_long_title(author,title,pages, last_title,n) +{ + title = trim(title) # discard leading and trailing space + while (length(title) > 0) + { + n = html_breakpoint(title,MAX_TITLE_CHARS+MIN_LEADERS) + last_title = substr(title,1,n) + title = substr(title,n+1) + sub(/^ +/,"",title) # discard any leading space + print_toc_line(author, last_title, (length(title) == 0) ? pages : "") + author = "" + } +} + + +function do_month( k,n,parts) +{ + Month = ($0 ~ /[=] *"/) ? get_value($0) : get_abbrev($0) + gsub(/[\"]/,"",Month) + gsub(/ *# *\\slash *# */," / ",Month) + gsub(/ *# *-+ *# */," / ",Month) + n = split(Month,parts," */ *") + Month = "" + for (k = 1; k <= n; ++k) + Month = Month ((k > 1) ? " / " : "") \ + ((parts[k] in Month_expansion) ? Month_expansion[parts[k]] : parts[k]) +} + + +function do_new_issue() +{ + Last_number = Number + if (HTML) + { + if (Last_volume != Volume) + { + Last_volume = Volume + print_line(prefix(2) "<BR>") + } + html_end_toc() + html_begin_issue() + print_line(prefix(2) Journal "<BR>") + } + else + { + print_line("") + print_line(Journal) + } + + print_line(strip_html(vol_no_month_year())) + + if (HTML) + { + html_end_issue() + html_toc_entry() + html_begin_toc() + } + else + print_line("") +} + + +function do_number() +{ + Number = get_value($0) +} + + +function do_Other() +{ + In_Article = 0 +} + + +function do_pages() +{ + Pages = get_value($0) + sub(/--[?][?]/,"",Pages) +} + + +function do_String() +{ + sub(/^[^\{]*\{/,"",$0) # discard up to and including open brace + sub(/\} *$/,"",$0) # discard from optional whitespace and trailing brace to end of line + String[get_key($0)] = get_value($0) +} + + +function do_title() +{ + Title = TeX_to_HTML(get_value($0)) +} + + +function do_URL( parts) +{ + Url = get_value($0) + split(Url,parts,"[,;]") # in case we have multiple URLs + Url = trim(parts[1]) +} + + +function do_volume() +{ + Volume = get_value($0) +} + + +function do_year() +{ + Year = get_value($0) +} + + +function get_abbrev(s) +{ # return abbrev from ``key = abbrev,'' + sub(/^[^=]*= */,"",s) # discard text up to start of non-blank value + sub(/ *,? *$/,"",s) # discard trailing optional whitspace, quote, + # optional comma, and optional space + return (s) +} + + +function get_key(s) +{ # return kay from ``key = "value",'' + sub(/^ */,"",s) # discard leading space + sub(/ *=.*$/,"",s) # discard everthing after key + + return (s) +} + + +function get_value(s) +{ # return value from ``key = "value",'' + sub(/^[^\"]*\" */,"",s) # discard text up to start of non-blank value + sub(/ *\",? *$/,"",s) # discard trailing optional whitspace, quote, + # optional comma, and optional space + return (s) +} + + +function html_accents(s) +{ + if (index(s,"\\") > 0) # important optimization + { + # Convert common lower-case accented letters according to the + # table on p. 169 of in Peter Flynn's ``The World Wide Web + # Handbook'', International Thomson Computer Press, 1995, ISBN + # 1-85032-205-8. The official table of ISO Latin 1 SGML + # entities used in HTML can be found in the file + # /usr/local/lib/html-check/lib/ISOlat1.sgml (your path + # may differ). + + gsub(/{\\\a}/, "\\à", s) + gsub(/{\\'a}/, "\\á", s) + gsub(/{\\[\^]a}/,"\\â", s) + gsub(/{\\~a}/, "\\ã", s) + gsub(/{\\\"a}/, "\\ä", s) + gsub(/{\\aa}/, "\\å", s) + gsub(/{\\ae}/, "\\æ", s) + + gsub(/{\\c{c}}/,"\\ç", s) + + gsub(/{\\\e}/, "\\è", s) + gsub(/{\\'e}/, "\\é", s) + gsub(/{\\[\^]e}/,"\\ê", s) + gsub(/{\\\"e}/, "\\ë", s) + + gsub(/{\\\i}/, "\\ì", s) + gsub(/{\\'i}/, "\\í", s) + gsub(/{\\[\^]i}/,"\\î", s) + gsub(/{\\\"i}/, "\\ï", s) + + # ignore eth and thorn + + gsub(/{\\~n}/, "\\ñ", s) + + gsub(/{\\\o}/, "\\ò", s) + gsub(/{\\'o}/, "\\ó", s) + gsub(/{\\[\^]o}/, "\\ô", s) + gsub(/{\\~o}/, "\\õ", s) + gsub(/{\\\"o}/, "\\ö", s) + gsub(/{\\o}/, "\\ø", s) + + gsub(/{\\\u}/, "\\ù", s) + gsub(/{\\'u}/, "\\ú", s) + gsub(/{\\[\^]u}/,"\\û", s) + gsub(/{\\\"u}/, "\\ü", s) + + gsub(/{\\'y}/, "\\ý", s) + gsub(/{\\\"y}/, "\\ÿ", s) + + # Now do the same for upper-case accents + + gsub(/{\\\A}/, "\\À", s) + gsub(/{\\'A}/, "\\Á", s) + gsub(/{\\[\^]A}/, "\\Â", s) + gsub(/{\\~A}/, "\\Ã", s) + gsub(/{\\\"A}/, "\\Ä", s) + gsub(/{\\AA}/, "\\Å", s) + gsub(/{\\AE}/, "\\Æ", s) + + gsub(/{\\c{C}}/,"\\Ç", s) + + gsub(/{\\\e}/, "\\È", s) + gsub(/{\\'E}/, "\\É", s) + gsub(/{\\[\^]E}/, "\\Ê", s) + gsub(/{\\\"E}/, "\\Ë", s) + + gsub(/{\\\I}/, "\\Ì", s) + gsub(/{\\'I}/, "\\Í", s) + gsub(/{\\[\^]I}/, "\\Î", s) + gsub(/{\\\"I}/, "\\Ï", s) + + # ignore eth and thorn + + gsub(/{\\~N}/, "\\Ñ", s) + + gsub(/{\\\O}/, "\\Ò", s) + gsub(/{\\'O}/, "\\Ó", s) + gsub(/{\\[\^]O}/, "\\Ô", s) + gsub(/{\\~O}/, "\\Õ", s) + gsub(/{\\\"O}/, "\\Ö", s) + gsub(/{\\O}/, "\\Ø", s) + + gsub(/{\\\U}/, "\\Ù", s) + gsub(/{\\'U}/, "\\Ú", s) + gsub(/{\\[\^]U}/, "\\Û", s) + gsub(/{\\\"U}/, "\\Ü", s) + + gsub(/{\\'Y}/, "\\Ý", s) + + gsub(/{\\ss}/, "\\ß", s) + + # Others not mentioned in Flynn's book + gsub(/{\\'\\i}/,"\\í", s) + gsub(/{\\'\\j}/,"j", s) + } + return (s) +} + + +function html_begin_issue() +{ + print_line("") + print_line(prefix(2) "<HR>") + print_line("") + print_line(prefix(2) "<H1>") + print_line(prefix(3) "<A NAME=\"" html_label() "\">") +} + + +function html_begin_pages() +{ + return ((HTML && (BIBFILEURL != "")) ? ("<A HREF=\"" BIBFILEURL "#" Citation_label "\">") : "") +} + + +function html_begin_pre() +{ + In_PRE = 1 + print_line("<PRE>") +} + + +function html_begin_title() +{ + return ((HTML && (Url != "")) ? ("<A HREF=\"" Url "\">") : "") +} + + +function html_begin_toc() +{ + html_end_toc() + html_begin_pre() +} + + +function html_body( k) +{ + for (k = 1; k <= BodyLines; ++k) + print Body[k] +} + +function html_breakpoint(title,maxlength, break_after,k) +{ + # Return the largest character position in title AFTER which we + # can break the title across lines, without exceeding maxlength + # visible characters. + if (html_length(title) > maxlength) # then need to split title across lines + { + # In the presence of HTML markup, the initialization of + # k here is complicated, because we need to advance it + # until html_length(title) is at least maxlength, + # without invoking the expensive html_length() function + # too frequently. The need to split the title makes the + # alternative of delayed insertion of HTML markup much + # more complicated. + break_after = 0 + for (k = min(maxlength,length(title)); k < length(title); ++k) + { + if (substr(title,k+1,1) == " ") + { # could break after position k + if (html_length(substr(title,1,k)) <= maxlength) + break_after = k + else # advanced too far, retreat back to last break_after + break + } + } + if (break_after == 0) # no breakpoint found by forward scan + { # so switch to backward scan + for (k = min(maxlength,length(title)) - 1; \ + (k > 0) && (substr(title,k+1,1) != " "); --k) + ; # find space at which to break title + if (k < 1) # no break point found + k = length(title) # so must print entire string + } + else + k = break_after + } + else # title fits on one line + k = length(title) + return (k) +} + + + +function html_end_issue() +{ + print_line(prefix(3) "</A>") + print_line(prefix(2) "</H1>") +} + + +function html_end_pages() +{ + return ((HTML && (BIBFILEURL != "")) ? "</A>" : "") +} + + +function html_end_pre() +{ + if (In_PRE) + { + print_line("</PRE>") + In_PRE = 0 + } +} + + +function html_end_title() +{ + return ((HTML && (Url != "")) ? "</A>" : "") +} + + +function html_end_toc() +{ + html_end_pre() +} + + +function html_fonts(s, arg,control_word,k,level,n,open_brace) +{ + open_brace = index(s,"{") + if (open_brace > 0) # important optimization + { + level = 1 + for (k = open_brace + 1; (level != 0) && (k <= length(s)); ++k) + { + if (substr(s,k,1) == "{") + level++ + else if (substr(s,k,1) == "}") + level-- + } + + # {...} is now found at open_brace ... (k-1) + for (control_word in Font_decl_map) # look for {\xxx ...} + { + if (substr(s,open_brace+1,length(control_word)+1) ~ \ + ("\\" control_word "[^A-Za-z]")) + { + n = open_brace + 1 + length(control_word) + arg = trim(substr(s,n,k - n)) + if (Font_decl_map[control_word] == "toupper") # arg -> ARG + arg = toupper(arg) + else if (Font_decl_map[control_word] != "") # arg -> <TAG>arg</TAG> + arg = "<" Font_decl_map[control_word] ">" arg "</" Font_decl_map[control_word] ">" + return (substr(s,1,open_brace-1) arg html_fonts(substr(s,k))) + } + } + for (control_word in Font_cmd_map) # look for \xxx{...} + { + if (substr(s,open_brace - length(control_word),length(control_word)) ~ \ + ("\\" control_word)) + { + n = open_brace + 1 + arg = trim(substr(s,n,k - n)) + if (Font_cmd_map[control_word] == "toupper") # arg -> ARG + arg = toupper(arg) + else if (Font_cmd_map[control_word] != "") # arg -> <TAG>arg</TAG> + arg = "<" Font_cmd_map[control_word] ">" arg "</" Font_cmd_map[control_word] ">" + n = open_brace - length(control_word) - 1 + return (substr(s,1,n) arg html_fonts(substr(s,k))) + } + } + } + return (s) +} + + +function html_header() +{ + USER = ENVIRON["USER"] + if (USER == "") + USER = ENVIRON["LOGNAME"] + if (USER == "") + USER = "????" + "hostname" | getline HOSTNAME + "date" | getline DATE + ("ypcat passwd | grep '^" USER ":' | awk -F: '{print $5}'") | getline PERSONAL_NAME + if (PERSONAL_NAME == "") + ("grep '^" USER ":' /etc/passwd | awk -F: '{print $5}'") | getline PERSONAL_NAME + + + print "<!-- WARNING: Do NOT edit this file. It was converted from -->" + print "<!-- BibTeX format to HTML by journal-toc.awk version " VERSION_NUMBER " " VERSION_DATE " -->" + print "<!-- on " DATE " -->" + print "<!-- for " PERSONAL_NAME " (" USER "@" HOSTNAME ") -->" + print "" + print "" + print "<!DOCTYPE HTML public \"-//IETF//DTD HTML//EN\">" + print "" + print "<HTML>" + print prefix(1) "<HEAD>" + print prefix(2) "<TITLE>" + print prefix(3) Journal + print prefix(2) "</TITLE>" + print prefix(2) "<LINK REV=\"made\" HREF=\"mailto:" USER "@" HOSTNAME "\">" + print prefix(1) "</HEAD>" + print "" + print prefix(1) "<BODY>" +} + + +function html_label( label) +{ + label = Volume "(" Number "):" Month ":" Year + gsub(/[^A-Za-z0-9():,;.\/\-]/,"",label) + return (label) +} + + +function html_length(s) +{ # Return visible length of s, ignoring any HTML markup + if (HTML) + { + gsub(/<\/?[^>]*>/,"",s) # remove SGML tags + gsub(/&[A-Za-z0-9]+;/,"",s) # remove SGML entities + } + return (length(s)) +} + + +function html_toc() +{ + print prefix(2) "<H1>" + print prefix(3) "Table of contents for issues of " Journal + print prefix(2) "</H1>" + print HTML_TOC +} + + +function html_toc_entry() +{ + HTML_TOC = HTML_TOC " <A HREF=\"#" html_label() "\">" + HTML_TOC = HTML_TOC vol_no_month_year() + HTML_TOC = HTML_TOC "</A><BR>" "\n" +} + + +function html_trailer() +{ + html_end_pre() + print prefix(1) "</BODY>" + print "</HTML>" +} + + +function initialize() +{ + # NB: Update these when the program changes + VERSION_DATE = "[09-Oct-1996]" + VERSION_NUMBER = "1.00" + + HTML = (HTML == "") ? 0 : (0 + HTML) + + if (INDENT == "") + INDENT = 4 + + if (HTML == 0) + INDENT = 0 # indentation suppressed in ASCII mode + + LEADERS = " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ." + + MAX_TITLE_CHARS = 36 # 36 produces a 79-char output line when there is + # just an initial page number. If this is + # increased, the LEADERS string may need to be + # lengthened. + + MIN_LEADERS = 4 # Minimum number of characters from LEADERS + # required when leaders are used. The total + # number of characters that can appear in a + # title line is MAX_TITLE_CHARS + MIN_LEADERS. + # Leaders are omitted when the title length is + # between MAX_TITLE_CHARS and this sum. + + MIN_LEADERS_SPACE = " " # must be at least MIN_LEADERS characters long + + Month_expansion["jan"] = "January" + Month_expansion["feb"] = "February" + Month_expansion["mar"] = "March" + Month_expansion["apr"] = "April" + Month_expansion["may"] = "May" + Month_expansion["jun"] = "June" + Month_expansion["jul"] = "July" + Month_expansion["aug"] = "August" + Month_expansion["sep"] = "September" + Month_expansion["oct"] = "October" + Month_expansion["nov"] = "November" + Month_expansion["dec"] = "December" + + Font_cmd_map["\\emph"] = "EM" + Font_cmd_map["\\textbf"] = "B" + Font_cmd_map["\\textit"] = "I" + Font_cmd_map["\\textmd"] = "" + Font_cmd_map["\\textrm"] = "" + Font_cmd_map["\\textsc"] = "toupper" + Font_cmd_map["\\textsl"] = "I" + Font_cmd_map["\\texttt"] = "t" + Font_cmd_map["\\textup"] = "" + + Font_decl_map["\\bf"] = "B" + Font_decl_map["\\em"] = "EM" + Font_decl_map["\\it"] = "I" + Font_decl_map["\\rm"] = "" + Font_decl_map["\\sc"] = "toupper" + Font_decl_map["\\sf"] = "" + Font_decl_map["\\tt"] = "TT" + Font_decl_map["\\itshape"] = "I" + Font_decl_map["\\upshape"] = "" + Font_decl_map["\\slshape"] = "I" + Font_decl_map["\\scshape"] = "toupper" + Font_decl_map["\\mdseries"] = "" + Font_decl_map["\\bfseries"] = "B" + Font_decl_map["\\rmfamily"] = "" + Font_decl_map["\\sffamily"] = "" + Font_decl_map["\\ttfamily"] = "TT" +} + +function min(a,b) +{ + return (a < b) ? a : b +} + + +function prefix(level) +{ + # Return a prefix of up to 60 blanks + + if (In_PRE) + return ("") + else + return (substr(" ", \ + 1, INDENT * level)) +} + + +function print_line(line) +{ + if (HTML) # must buffer in memory so that we can accumulate TOC + Body[++BodyLines] = line + else + print line +} + + +function print_toc_line(author,title,pages, extra,leaders,n,t) +{ + # When we have a multiline title, the hypertext link goes only + # on the first line. A multiline hypertext link looks awful + # because of long underlines under the leading indentation. + + if (pages == "") # then no leaders needed in title lines other than last one + t = sprintf("%31s %s%s%s", author, Title_prefix, title, Title_suffix) + else # last title line, with page number + { + n = html_length(title) # potentially expensive + extra = n % 2 # extra space for aligned leader dots + if (n <= MAX_TITLE_CHARS) # then need leaders + leaders = substr(LEADERS, 1, MAX_TITLE_CHARS + MIN_LEADERS - extra - \ + min(MAX_TITLE_CHARS,n)) + else # title (almost) fills line, so no leaders + leaders = substr(MIN_LEADERS_SPACE,1, \ + (MAX_TITLE_CHARS + MIN_LEADERS - extra - n)) + t = sprintf("%31s %s%s%s%s%s %4s", \ + author, Title_prefix, title, Title_suffix, \ + (extra ? " " : ""), leaders, pages) + } + + Title_prefix = "" # forget any hypertext + Title_suffix = "" # link material + + # Efficency note: an earlier version accumulated the body in a + # single scalar like this: "Body = Body t". Profiling revealed + # this statement as the major hot spot, and the change to array + # storage made the program more than twice as fast. This + # suggests that awk might benefit from an optimization of + # "s = s t" that uses realloc() instead of malloc(). + if (HTML) + Body[++BodyLines] = t + else + print t +} + + +function protect_SGML_characters(s) +{ + gsub(/&/,"\\&",s) # NB: this one MUST be first + gsub(/</,"\\<",s) + gsub(/>/,"\\>",s) + gsub(/\"/,"\\"",s) + return (s) +} + + +function strip_braces(s, k) +{ # strip non-backslashed braces from s and return the result + + return (strip_char(strip_char(s,"{"),"}")) +} + + +function strip_char(s,c, k) +{ # strip non-backslashed instances of c from s, and return the result + k = index(s,c) + if (k > 0) # then found the character + { + if (substr(s,k-1,1) != "\\") # then not backslashed char + s = substr(s,1,k-1) strip_char(substr(s,k+1),c) # so remove it (recursively) + else # preserve backslashed char + s = substr(s,1,k) strip_char(s,k+1,c) + } + return (s) +} + + +function strip_html(s) +{ + gsub(/<\/?[^>]*>/,"",s) + return (s) +} + + +function terminate() +{ + if (HTML) + { + html_end_pre() + + HTML = 0 # NB: stop line buffering + html_header() + html_toc() + html_body() + html_trailer() + } +} + + +function TeX_to_HTML(s, k,n,parts) +{ + # First convert the four SGML reserved characters to SGML entities + if (HTML) + { + gsub(/>/, "\\>", s) + gsub(/</, "\\<", s) + gsub(/"/, "\\"", s) + } + + gsub(/[$][$]/,"$$",s) # change display math to triple dollars for split + n = split(s,parts,/[$]/)# split into non-math (odd) and math (even) parts + + s = "" + for (k = 1; k <= n; ++k) # unbrace non-math part, leaving math mode intact + s = s ((k > 1) ? "$" : "") \ + ((k % 2) ? strip_braces(TeX_to_HTML_nonmath(parts[k])) : \ + TeX_to_HTML_math(parts[k])) + + gsub(/[$][$][$]/,"$$",s) # restore display math + + return (s) +} + + +function TeX_to_HTML_math(s) +{ + # Mostly a dummy for now, but HTML 3 could support some math translation + + gsub(/\\&/,"\\&",s) # reduce TeX ampersands to SGML entities + + return (s) +} + + +function TeX_to_HTML_nonmath(s) +{ + if (index(s,"\\") > 0) # important optimization + { + gsub(/\\slash +/,"/",s) # replace TeX slashes with conventional ones + gsub(/ *\\emdash +/," --- ",s) # replace BibNet emdashes with conventional ones + gsub(/\\%/,"%",s) # reduce TeX percents to conventional ones + gsub(/\\[$]/,"$",s) # reduce TeX dollars to conventional ones + gsub(/\\#/,"#",s) # reduce TeX sharps to conventional ones + + if (HTML) # translate TeX markup to HTML + { + gsub(/\\&/,"\\&",s) # reduce TeX ampersands to SGML entities + s = html_accents(s) + s = html_fonts(s) + } + else # plain ASCII text output: discard all TeX markup + { + gsub(/\\\&/, "\\&", s) # reduce TeX ampersands to conventional ones + + gsub(/\\[a-z][a-z] +/,"",s) # remove TeX font changes + gsub(/\\[^A-Za-z]/,"",s) # remove remaining TeX control symbols + } + } + return (s) +} + + +function trim(s) +{ + gsub(/^[ \t]+/,"",s) + gsub(/[ \t]+$/,"",s) + return (s) +} + + +function vol_no_month_year() +{ + return ("Volume " wrap(Volume) ", Number " wrap(Number) ", " wrap(Month) ", " wrap(Year)) +} + + +function wrap(value) +{ + return (HTML ? ("<STRONG>" value "</STRONG>") : value) +} diff --git a/contrib/awk/test/funstack.in b/contrib/awk/test/funstack.in new file mode 100644 index 0000000..7a29a25 --- /dev/null +++ b/contrib/awk/test/funstack.in @@ -0,0 +1,206 @@ +%%% ==================================================================== +%%% BibTeX-file{ +%%% author = "Nelson H. F. Beebe", +%%% version = "2.09", +%%% date = "26 March 1997", +%%% time = "08:21:19 MST", +%%% filename = "cacm1970.bib", +%%% address = "Center for Scientific Computing +%%% Department of Mathematics +%%% University of Utah +%%% Salt Lake City, UT 84112 +%%% USA", +%%% telephone = "+1 801 581 5254", +%%% FAX = "+1 801 581 4148", +%%% checksum = "50673 40670 196033 1787829", +%%% email = "beebe at math.utah.edu (Internet)", +%%% codetable = "ISO/ASCII", +%%% keywords = "bibliography, CACM, Communications of the +%%% ACM", +%%% supported = "yes", +%%% docstring = "This is a bibliography of the journal +%%% Communications of the ACM, covering +%%% (incompletely) 1970 -- 1979. +%%% +%%% At version 2.09, the year coverage looked +%%% like this: +%%% +%%% 1961 ( 1) 1972 (168) 1983 ( 0) +%%% 1962 ( 1) 1973 (158) 1984 ( 0) +%%% 1963 ( 2) 1974 (127) 1985 ( 2) +%%% 1964 ( 2) 1975 (107) 1986 ( 0) +%%% 1965 ( 1) 1976 ( 97) 1987 ( 0) +%%% 1966 ( 2) 1977 (117) 1988 ( 0) +%%% 1967 ( 1) 1978 (118) 1989 ( 0) +%%% 1968 ( 1) 1979 ( 78) 1990 ( 2) +%%% 1969 ( 3) 1980 ( 1) 1991 ( 4) +%%% 1970 (157) 1981 ( 2) 1992 ( 1) +%%% 1971 (104) 1982 ( 1) +%%% +%%% Article: 1252 +%%% Book: 2 +%%% InProceedings: 1 +%%% Manual: 1 +%%% MastersThesis: 1 +%%% PhdThesis: 1 +%%% +%%% Total entries: 1258 +%%% +%%% The size of the original cacm.bib file +%%% covering 1958--1996 became too large (about +%%% 4000 entries) for BibTeX and TeX to handle, +%%% so at version 1.44, it was split into +%%% cacm1950.bib, cacm1960.bib, cacm1970.bib, +%%% cacm1980.bib, and cacm1990.bib, each covering +%%% the decade starting with the year embedded in +%%% the filename. Version numbers for these +%%% files begin at 2.00. +%%% +%%% Volumes from the 1990s average more than 200 +%%% articles yearly, so a complete bibliography +%%% for this journal could contain more than 6000 +%%% entries from 1958 to 2000. +%%% +%%% These bibliographies also include ACM +%%% Algorithms 1--492. For Algorithms 493--686, +%%% including Algorithm 568, published in ACM +%%% Transactions on Programming Languages and +%%% Systems (TOPLAS), see the companion +%%% bibliographies, toms.bib and toplas.bib. +%%% +%%% All published Remarks and Corrigenda are +%%% cross-referenced in both directions, so +%%% that citing a paper will automatically +%%% generate citations for those Remarks and +%%% Corrigenda. Cross-referenced entries are +%%% duplicated in cacm19*.bib and toms.bib, so +%%% that each is completely self-contained. +%%% +%%% Source code for ACM Algorithms from 380 +%%% onwards, with some omissions, is available +%%% via the Netlib service at +%%% http://netlib.ornl.gov/, and +%%% ftp://netlib.bell-labs.com/netlib/toms. +%%% +%%% There is a World Wide Web search facility +%%% for articles published in this journal from +%%% 1959 to 1979 at +%%% http://ciir.cs.umass.edu/cgi-bin/web_query_form/public/cacm2.1. +%%% +%%% The initial draft of entries for 1981 -- +%%% 1990 was extracted from the ACM Computing +%%% Archive CD ROM for the 1980s, with manual +%%% corrections and additions. Additions were +%%% then made from all of the bibliographies in +%%% the TeX User Group collection, from +%%% bibliographies in the author's personal +%%% files, from the Compendex database +%%% (1970--1979), from the IEEE INSPEC database +%%% (1970--1979), from tables of contents +%%% information at http://www.acm.org/pubs/cacm/, +%%% from Zentralblatt fur Mathematik Mathematics +%%% Abstracts at +%%% http://www.emis.de/cgi-bin/MATH/, from +%%% bibliographies at Internet host +%%% netlib.bell-labs.com, and from the computer +%%% science bibliography collection on +%%% ftp.ira.uka.de in /pub/bibliography to which +%%% many people of have contributed. The +%%% snapshot of this collection was taken on +%%% 5-May-1994, and it consists of 441 BibTeX +%%% files, 2,672,675 lines, 205,289 entries, and +%%% 6,375 <at>String{} abbreviations, occupying +%%% 94.8MB of disk space. +%%% +%%% Numerous errors in the sources noted above +%%% have been corrected. Spelling has been +%%% verified with the UNIX spell and GNU ispell +%%% programs using the exception dictionary +%%% stored in the companion file with extension +%%% .sok. +%%% +%%% BibTeX citation tags are uniformly chosen +%%% as name:year:abbrev, where name is the +%%% family name of the first author or editor, +%%% year is a 4-digit number, and abbrev is a +%%% 3-letter condensation of important title +%%% words. Citation tags were automatically +%%% generated by software developed for the +%%% BibNet Project. +%%% +%%% In this bibliography, entries are sorted in +%%% publication order within each journal, +%%% using bibsort -byvolume. +%%% +%%% The checksum field above contains a CRC-16 +%%% checksum as the first value, followed by the +%%% equivalent of the standard UNIX wc (word +%%% count) utility output of lines, words, and +%%% characters. This is produced by Robert +%%% Solovay's checksum utility.", +%%% } +%%% ==================================================================== + +@Preamble{"\input bibnames.sty " # "\input path.sty " # "\def \TM {${}^{\sc TM}$} " # "\hyphenation{ al-pha-mer-ic Balz-er Blom-quist Bo-ta-fo-go Bran-din Brans-comb Bu-tera Chris-tina Christ-o-fi-des Col-lins Cor-dell data-base econ-omies Fletch-er + flow-chart flow-charts Fry-styk ge-dank-en Gar-fink-el Ge-ha-ni Glush-ko Goud-reau Gua-dan-go Hari-di Haw-thorn Hem-men-ding-er Hor-o-witz Hour-vitz Hirsch-berg Ike-da Ka-chi-tvi-chyan-u-kul Kat-ze-nel-son Kitz-miller Ko-ba-yashi Le-Me-tay-er Ken-ne-dy + Law-rence Mac-kay Mai-net-ti Mar-sa-glia Max-well Mer-ner Mo-ran-di Na-ray-an New-ell Nich-ols para-digm pat-ent-ed Phi-lo-kyp-rou Prep-a-ra-ta pseu-do-chain-ing QUIK-SCRIPT Rad-e-mach-er re-eval-u-a-tion re-wind Ros-witha Scheu-er-mann Schwach-heim + Schob-bens Schon-berg Sho-sha-ni Si-tha-ra-ma Skwa-rec-ki Streck-er Strin-gi-ni Tes-ler Te-zu-ka Teu-ho-la Till-quist Town-send Tsi-chri-tzis Tur-ski Vuille-min Wald-ing-er Za-bo-row-ski Za-mora }"} + +%======================================================================= +% Acknowledgement abbreviations: + +@String{ack-nhfb = "Nelson H. F. Beebe, Center for Scientific Computing, Department of Mathematics, University of Utah, Salt Lake City, UT 84112, USA, Tel: +1 801 581 5254, FAX: +1 801 581 4148, e-mail: \path|beebe@math.utah.edu|"} + +@String{ack-nj = "Norbert Juffa, 2445 Mission College Blvd. Santa Clara, CA 95054 USA email: \path=norbert@iit.com="} + +%======================================================================= +% Journal abbreviations: + +@String{j-CACM = "Communications of the ACM"} + +@String{j-COMP-SURV = "Computing Surveys"} + +@String{j-J-ACM = "Journal of the ACM"} + +@String{j-MANAGEMENT-SCIENCE = "Management Science"} + +@String{j-SIAM-J-COMPUT = "SIAM Journal of Computing"} + +@String{j-SPE = "Software --- Practice and Experience"} + +@String{j-TOMS = "ACM Transactions on Mathematical Software"} + +%======================================================================= +% Publisher abbreviations: + +@String{pub-ANSI = "American National Standards Institute"} + +@String{pub-ANSI:adr = "1430 Broadway, New York, NY 10018, USA"} + +@String{pub-AW = "Ad{\-d}i{\-s}on-Wes{\-l}ey"} + +@String{pub-AW:adr = "Reading, MA, USA"} + +@String{pub-SUCSLI = "Stanford University Center for the Study of Language and Information"} + +@String{pub-SUCSLI:adr = "Stanford, CA, USA"} + +@String{pub-SV = "Spring{\-}er-Ver{\-}lag"} + +@String{pub-SV:adr = "Berlin, Germany~/ Heidelberg, Germany~/ London, UK~/ etc."} +@MastersThesis{Dittmer:1976:IEP, + author = "Ingo Dittmer", + title = "{Implementation eines Einschrittcompilers f{\"u}r die Progammiersprache PASCAL auf der Rechenanlage IBM\slash 360 der Universit{\"a}t M{\"u}nster}. ({English} title: Implementation of a One-Step Compiler for the Programming Language + {PASCAL} on the {IBM}\slash 360 of the {University of Muenster})", + type = "Diplomearbeit", + school = "Universit{\"a}t M{\"u}nster", + address = "M{\"u}nster, Germany", + pages = "??", + month = "??", + year = "1976", + bibdate = "Sat Feb 17 13:24:29 1996", + note = "Diplomearbeit M{\"u}nster 1976 und doert angegebene Literatur (English: Muenster diploma work 1976 and the literature cited therein). The hashing method was rediscovered fourteen years later by Pearson \cite{Pearson:1990:FHV}, and then + commented on by several authors \cite{Dittmer:1991:NFH,Savoy:1991:NFH,Litsios:1991:NFH,Pearson:1991:NFH}.", + acknowledgement = ack-nhfb, + xxnote = "Cannot find in Dissertation Abstracts, European.", +} diff --git a/contrib/awk/test/funstack.ok b/contrib/awk/test/funstack.ok new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/funstack.ok diff --git a/contrib/awk/test/gensub.awk b/contrib/awk/test/gensub.awk new file mode 100644 index 0000000..f91d84d --- /dev/null +++ b/contrib/awk/test/gensub.awk @@ -0,0 +1,7 @@ +BEGIN { a = "this is a test of gawk" + b = gensub(/(this).*(test).*(gawk)/, "3 = <\\3>, 2 = <\\2>, 1 = <\\1>", 1, a) + print b +} +NR == 1 { print gensub(/b/, "BB", 2) } +NR == 2 { print gensub(/c/, "CC", "global") } +END { print gensub(/foo/, "bar", 1, "DON'T PANIC") } diff --git a/contrib/awk/test/gensub.in b/contrib/awk/test/gensub.in new file mode 100644 index 0000000..96c9faf --- /dev/null +++ b/contrib/awk/test/gensub.in @@ -0,0 +1,2 @@ +a b c a b c a b c +a b c a b c a b c diff --git a/contrib/awk/test/gensub.ok b/contrib/awk/test/gensub.ok new file mode 100644 index 0000000..b9ea3de --- /dev/null +++ b/contrib/awk/test/gensub.ok @@ -0,0 +1,4 @@ +3 = <gawk>, 2 = <test>, 1 = <this> +a b c a BB c a b c +a b CC a b CC a b CC +DON'T PANIC diff --git a/contrib/awk/test/getline.awk b/contrib/awk/test/getline.awk new file mode 100644 index 0000000..f4e413f --- /dev/null +++ b/contrib/awk/test/getline.awk @@ -0,0 +1 @@ +BEGIN { while( getline > 0) { print } } diff --git a/contrib/awk/test/getline.ok b/contrib/awk/test/getline.ok new file mode 100644 index 0000000..9b7f2b9 --- /dev/null +++ b/contrib/awk/test/getline.ok @@ -0,0 +1,2 @@ +BEGIN { while( getline > 0) { print } } +BEGIN { while( getline > 0) { print } } diff --git a/contrib/awk/test/getlnhd.awk b/contrib/awk/test/getlnhd.awk new file mode 100644 index 0000000..f0f801b --- /dev/null +++ b/contrib/awk/test/getlnhd.awk @@ -0,0 +1,10 @@ +BEGIN { pipe = "cat <<EOF\n" + pipe = pipe "select * from user\n" + pipe = pipe " where Name = 'O\\'Donell'\n" + pipe = pipe "EOF\n" + + while ((pipe | getline) > 0) + print + + exit 0 +} diff --git a/contrib/awk/test/getlnhd.ok b/contrib/awk/test/getlnhd.ok new file mode 100644 index 0000000..d8cb453 --- /dev/null +++ b/contrib/awk/test/getlnhd.ok @@ -0,0 +1,2 @@ +select * from user + where Name = 'O\'Donell' diff --git a/contrib/awk/test/gnureops.awk b/contrib/awk/test/gnureops.awk new file mode 100644 index 0000000..15b9b84 --- /dev/null +++ b/contrib/awk/test/gnureops.awk @@ -0,0 +1,45 @@ +# test the gnu regexp ops + +BEGIN { + if ("a rat is here" ~ /\yrat/) print "test 1 ok (\\y)" + else print "test 1 failed (\\y)" + if ("a rat is here" ~ /rat\y/) print "test 2 ok (\\y)" + else print "test 2 failed (\\y)" + if ("what a brat" !~ /\yrat/) print "test 3 ok (\\y)" + else print "test 3 failed (\\y)" + + if ("in the crate" ~ /\Brat/) print "test 4 ok (\\B)" + else print "test 4 failed (\\B)" + if ("a rat" !~ /\Brat/) print "test 5 ok (\\B)" + else print "test 5 failed (\\B)" + + if ("a word" ~ /\<word/) print "test 6 ok (\\<)" + else print "test 6 failed (\\<)" + if ("foreword" !~ /\<word/) print "test 7 ok (\\<)" + else print "test 7 failed (\\<)" + + if ("a word" ~ /word\>/) print "test 8 ok (\\>)" + else print "test 8 failed (\\\\>)" + if ("wordy" !~ /word\>/) print "test 9 ok (\\>)" + else print "test 9 failed (\\>)" + + if ("a" ~ /\w/) print "test 10 ok (\\w)" + else print "test 10 failed (\\\\w)" + if ("+" !~ /\w/) print "test 11 ok (\\w)" + else print "test 11 failed (\\w)" + + if ("a" !~ /\W/) print "test 12 ok (\\W)" + else print "test 12 failed (\\W)" + if ("+" ~ /\W/) print "test 13 ok (\\W)" + else print "test 13 failed (\\W)" + + if ("a" ~ /\`a/) print "test 14 ok (\\`)" + else print "test 14 failed (\\`)" + if ("b" !~ /\`a/) print "test 15 ok (\\`)" + else print "test 15 failed (\\`)" + + if ("a" ~ /a\'/) print "test 16 ok (\\')" + else print "test 16 failed (\\')" + if ("b" !~ /a\'/) print "test 17 ok (\\')" + else print "test 17 failed (\\')" +} diff --git a/contrib/awk/test/gnureops.ok b/contrib/awk/test/gnureops.ok new file mode 100644 index 0000000..0fb5f50 --- /dev/null +++ b/contrib/awk/test/gnureops.ok @@ -0,0 +1,17 @@ +test 1 ok (\y) +test 2 ok (\y) +test 3 ok (\y) +test 4 ok (\B) +test 5 ok (\B) +test 6 ok (\<) +test 7 ok (\<) +test 8 ok (\>) +test 9 ok (\>) +test 10 ok (\w) +test 11 ok (\w) +test 12 ok (\W) +test 13 ok (\W) +test 14 ok (\`) +test 15 ok (\`) +test 16 ok (\') +test 17 ok (\') diff --git a/contrib/awk/test/gsubasgn.awk b/contrib/awk/test/gsubasgn.awk new file mode 100644 index 0000000..f0b7701 --- /dev/null +++ b/contrib/awk/test/gsubasgn.awk @@ -0,0 +1,13 @@ +# tests for assigning to a function within that function + +#1 - should be bad +function test1 (r) { gsub(r, "x", test1) } +BEGIN { test1("") } + +#2 - should be bad +function test2 () { gsub(/a/, "x", test2) } +BEGIN { test2() } + +#3 - should be ok +function test3 (r) { gsub(/a/, "x", r) } +BEGIN { test3("") } diff --git a/contrib/awk/test/gsubasgn.ok b/contrib/awk/test/gsubasgn.ok new file mode 100644 index 0000000..dfa6fbc --- /dev/null +++ b/contrib/awk/test/gsubasgn.ok @@ -0,0 +1,4 @@ +gawk: gsubasgn.awk:4: function test1 (r) { gsub(r, "x", test1) } +gawk: gsubasgn.awk:4: ^ gsub third parameter is not a changeable object +gawk: gsubasgn.awk:8: function test2 () { gsub(/a/, "x", test2) } +gawk: gsubasgn.awk:8: ^ gsub third parameter is not a changeable object diff --git a/contrib/awk/test/gsubtest.awk b/contrib/awk/test/gsubtest.awk new file mode 100755 index 0000000..3137479 --- /dev/null +++ b/contrib/awk/test/gsubtest.awk @@ -0,0 +1,8 @@ +BEGIN { + str = "abc"; gsub("b+", "FOO", str); print str + str = "abc"; gsub("x*", "X", str); print str + str = "abc"; gsub("b*", "X", str); print str + str = "abc"; gsub("c", "X", str); print str + str = "abc"; gsub("c+", "X", str); print str + str = "abc"; gsub("x*$", "X", str); print str +} diff --git a/contrib/awk/test/gsubtest.ok b/contrib/awk/test/gsubtest.ok new file mode 100644 index 0000000..191bebd --- /dev/null +++ b/contrib/awk/test/gsubtest.ok @@ -0,0 +1,6 @@ +aFOOc +XaXbXcX +XaXcX +abX +abX +abcX diff --git a/contrib/awk/test/igncfs.awk b/contrib/awk/test/igncfs.awk new file mode 100644 index 0000000..ebb58b2 --- /dev/null +++ b/contrib/awk/test/igncfs.awk @@ -0,0 +1,8 @@ +BEGIN { + IGNORECASE=1 + FS="[^a-z]+" +} +{ + for (i=1; i<NF; i++) printf "%s, ", $i + printf "%s\n", $NF +} diff --git a/contrib/awk/test/igncfs.in b/contrib/awk/test/igncfs.in new file mode 100644 index 0000000..5598017 --- /dev/null +++ b/contrib/awk/test/igncfs.in @@ -0,0 +1,2 @@ +this is handled ok +This is Not hanDLed Well diff --git a/contrib/awk/test/igncfs.ok b/contrib/awk/test/igncfs.ok new file mode 100644 index 0000000..41df9a4 --- /dev/null +++ b/contrib/awk/test/igncfs.ok @@ -0,0 +1,2 @@ +this, is, handled, ok +This, is, Not, hanDLed, Well diff --git a/contrib/awk/test/ignrcase.ok b/contrib/awk/test/ignrcase.ok new file mode 100644 index 0000000..d66e95c --- /dev/null +++ b/contrib/awk/test/ignrcase.ok @@ -0,0 +1 @@ +xz diff --git a/contrib/awk/test/inftest.awk b/contrib/awk/test/inftest.awk new file mode 100644 index 0000000..ec0eda1 --- /dev/null +++ b/contrib/awk/test/inftest.awk @@ -0,0 +1,5 @@ +BEGIN { + x = 100 + do { y = x ; x *= 1000; print x,y } while ( y != x ) + print "loop terminated" +} diff --git a/contrib/awk/test/inftest.ok b/contrib/awk/test/inftest.ok new file mode 100644 index 0000000..83a93d0 --- /dev/null +++ b/contrib/awk/test/inftest.ok @@ -0,0 +1,105 @@ +100000 100 +100000000 100000 +1e+11 100000000 +1e+14 1e+11 +1e+17 1e+14 +1e+20 1e+17 +1e+23 1e+20 +1e+26 1e+23 +1e+29 1e+26 +1e+32 1e+29 +1e+35 1e+32 +1e+38 1e+35 +1e+41 1e+38 +1e+44 1e+41 +1e+47 1e+44 +1e+50 1e+47 +1e+53 1e+50 +1e+56 1e+53 +1e+59 1e+56 +1e+62 1e+59 +1e+65 1e+62 +1e+68 1e+65 +1e+71 1e+68 +1e+74 1e+71 +1e+77 1e+74 +1e+80 1e+77 +1e+83 1e+80 +1e+86 1e+83 +1e+89 1e+86 +1e+92 1e+89 +1e+95 1e+92 +1e+98 1e+95 +1e+101 1e+98 +1e+104 1e+101 +1e+107 1e+104 +1e+110 1e+107 +1e+113 1e+110 +1e+116 1e+113 +1e+119 1e+116 +1e+122 1e+119 +1e+125 1e+122 +1e+128 1e+125 +1e+131 1e+128 +1e+134 1e+131 +1e+137 1e+134 +1e+140 1e+137 +1e+143 1e+140 +1e+146 1e+143 +1e+149 1e+146 +1e+152 1e+149 +1e+155 1e+152 +1e+158 1e+155 +1e+161 1e+158 +1e+164 1e+161 +1e+167 1e+164 +1e+170 1e+167 +1e+173 1e+170 +1e+176 1e+173 +1e+179 1e+176 +1e+182 1e+179 +1e+185 1e+182 +1e+188 1e+185 +1e+191 1e+188 +1e+194 1e+191 +1e+197 1e+194 +1e+200 1e+197 +1e+203 1e+200 +1e+206 1e+203 +1e+209 1e+206 +1e+212 1e+209 +1e+215 1e+212 +1e+218 1e+215 +1e+221 1e+218 +1e+224 1e+221 +1e+227 1e+224 +1e+230 1e+227 +1e+233 1e+230 +1e+236 1e+233 +1e+239 1e+236 +1e+242 1e+239 +1e+245 1e+242 +1e+248 1e+245 +1e+251 1e+248 +1e+254 1e+251 +1e+257 1e+254 +1e+260 1e+257 +1e+263 1e+260 +1e+266 1e+263 +1e+269 1e+266 +1e+272 1e+269 +1e+275 1e+272 +1e+278 1e+275 +1e+281 1e+278 +1e+284 1e+281 +1e+287 1e+284 +1e+290 1e+287 +1e+293 1e+290 +1e+296 1e+293 +1e+299 1e+296 +1e+302 1e+299 +1e+305 1e+302 +1e+308 1e+305 +Inf 1e+308 +Inf Inf +loop terminated diff --git a/contrib/awk/test/intest.awk b/contrib/awk/test/intest.awk new file mode 100644 index 0000000..f030d07 --- /dev/null +++ b/contrib/awk/test/intest.awk @@ -0,0 +1,4 @@ +BEGIN { + bool = ((b = 1) in c); + print bool, b # gawk-3.0.1 prints "0 "; should print "0 1" +} diff --git a/contrib/awk/test/intest.ok b/contrib/awk/test/intest.ok new file mode 100644 index 0000000..6e8183b --- /dev/null +++ b/contrib/awk/test/intest.ok @@ -0,0 +1 @@ +0 1 diff --git a/contrib/awk/test/intprec.awk b/contrib/awk/test/intprec.awk new file mode 100644 index 0000000..978e9ea --- /dev/null +++ b/contrib/awk/test/intprec.awk @@ -0,0 +1 @@ +BEGIN { printf "%.10d:%.10x\n", 5, 14 } diff --git a/contrib/awk/test/intprec.ok b/contrib/awk/test/intprec.ok new file mode 100644 index 0000000..8783fac --- /dev/null +++ b/contrib/awk/test/intprec.ok @@ -0,0 +1 @@ +0000000005:000000000e diff --git a/contrib/awk/test/lib/awkpath.awk b/contrib/awk/test/lib/awkpath.awk new file mode 100644 index 0000000..6663ca4 --- /dev/null +++ b/contrib/awk/test/lib/awkpath.awk @@ -0,0 +1 @@ +BEGIN { print "Found it." } diff --git a/contrib/awk/test/litoct.awk b/contrib/awk/test/litoct.awk new file mode 100644 index 0000000..5cfc128 --- /dev/null +++ b/contrib/awk/test/litoct.awk @@ -0,0 +1 @@ +{ if (/a\52b/) print "match" ; else print "no match" } diff --git a/contrib/awk/test/litoct.ok b/contrib/awk/test/litoct.ok new file mode 100644 index 0000000..4c0be97 --- /dev/null +++ b/contrib/awk/test/litoct.ok @@ -0,0 +1 @@ +no match diff --git a/contrib/awk/test/longwrds.awk b/contrib/awk/test/longwrds.awk new file mode 100644 index 0000000..f6a7816 --- /dev/null +++ b/contrib/awk/test/longwrds.awk @@ -0,0 +1,20 @@ +# From Gawk Manual modified by bug fix and removal of punctuation +# Record every word which is used at least once +{ + for (i = 1; i <= NF; i++) { + tmp = tolower($i) + if (0 != (pos = match(tmp, /([a-z]|-)+/))) + used[substr(tmp, pos, RLENGTH)] = 1 + } +} + +#Find a number of distinct words longer than 10 characters +END { + num_long_words = 0 + for (x in used) + if (length(x) > 10) { + ++num_long_words + print x + } + print num_long_words, "long words" +} diff --git a/contrib/awk/test/longwrds.ok b/contrib/awk/test/longwrds.ok new file mode 100644 index 0000000..01faa84 --- /dev/null +++ b/contrib/awk/test/longwrds.ok @@ -0,0 +1,21 @@ +20 long words +compatibility +concatenated +consistency +definitions +description +distributing +fistatements +gawk-options +gnu-specific +identically +implementation +implementations +information +non-portable +pattern-action +pre-defined +program-file +program-text +programming +restrictions diff --git a/contrib/awk/test/manpage b/contrib/awk/test/manpage new file mode 100644 index 0000000..09c3948 --- /dev/null +++ b/contrib/awk/test/manpage @@ -0,0 +1,200 @@ +.ds PX \s-1POSIX\s+1 +.ds UX \s-1UNIX\s+1 +.ds AN \s-1ANSI\s+1 +.TH GAWK 1 "May 28 1991" "Free Software Foundation" "Utility Commands" +.SH NAME +gawk \- pattern scanning and processing language +.SH SYNOPSIS +.B gawk +[ +.B \-W +.I gawk-options +] [ +.BI \-F\^ fs +] [ +.B \-v +.IR var = val +] +.B \-f +.I program-file +[ +.B \-\^\- +] file .\^.\^. +.br +.B gawk +[ +.B \-W +.I gawk-options +] [ +.BI \-F\^ fs +] [ +.B \-v +.IR var = val +] [ +.B \-\^\- +] +.I program-text +file .\^.\^. +.SH DESCRIPTION +.I Gawk +is the GNU Project's implementation of the AWK programming language. +It conforms to the definition of the language in +the \*(PX 1003.2 Command Language And Utilities Standard +(draft 11). +This version in turn is based on the description in +.IR "The AWK Programming Language" , +by Aho, Kernighan, and Weinberger, +with the additional features defined in the System V Release 4 version +of \*(UX +.IR awk . +.I Gawk +also provides some GNU-specific extensions. +.PP +The command line consists of options to +.I gawk +itself, the AWK program text (if not supplied via the +.B \-f +option), and values to be made +available in the +.B ARGC +and +.B ARGV +pre-defined AWK variables. +.SH OPTIONS +.PP +.I Gawk +accepts the following options, which should be available on any implementation +of the AWK language. +.TP +.BI \-F fs +Use +.I fs +for the input field separator (the value of the +.B FS +predefined +variable). +.TP +\fB\-v\fI var\fR\^=\^\fIval\fR +Assign the value +.IR val , +to the variable +.IR var , +before execution of the program begins. +Such variable values are available to the +.B BEGIN +block of an AWK program. +.TP +.BI \-f " program-file" +Read the AWK program source from the file +.IR program-file , +instead of from the first command line argument. +Multiple +.B \-f +options may be used. +.TP +.B \-\^\- +Signal the end of options. This is useful to allow further arguments to the +AWK program itself to start with a ``\-''. +This is mainly for consistency with the argument parsing convention used +by most other \*(PX programs. +.PP +Following the \*(PX standard, +.IR gawk -specific +options are supplied via arguments to the +.B \-W +option. Multiple +.B \-W +options may be supplied, or multiple arguments may be supplied together +if they are separated by commas, or enclosed in quotes and separated +by white space. +Case is ignored in arguments to the +.B \-W +option. +.PP +The +.B \-W +option accepts the following arguments: +.TP \w'\fBcopyright\fR'u+1n +.B compat +Run in +.I compatibility +mode. In compatibility mode, +.I gawk +behaves identically to \*(UX +.IR awk ; +none of the GNU-specific extensions are recognized. +.TP +.PD 0 +.B copyleft +.TP +.PD +.B copyright +Print the short version of the GNU copyright information message on +the error output. +.TP +.B lint +Provide warnings about constructs that are +dubious or non-portable to other AWK implementations. +.TP +.B posix +This turns on +.I compatibility +mode, with the following additional restrictions: +.RS +.TP \w'\(bu'u+1n +\(bu +.B \ex +escape sequences are not recognized. +.TP +\(bu +The synonym +.B func +for the keyword +.B function +is not recognized. +.TP +\(bu +The operators +.B ** +and +.B **= +cannot be used in place of +.B ^ +and +.BR ^= . +.RE +.TP +.B version +Print version information for this particular copy of +.I gawk +on the error output. +This is useful mainly for knowing if the current copy of +.I gawk +on your system +is up to date with respect to whatever the Free Software Foundation +is distributing. +.PP +Any other options are flagged as illegal, but are otherwise ignored. +.SH AWK PROGRAM EXECUTION +.PP +An AWK program consists of a sequence of pattern-action statements +and optional function definitions. +.RS +.PP +\fIpattern\fB { \fIaction statements\fB }\fR +.br +\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements\fB }\fR +.RE +.PP +.I Gawk +first reads the program source from the +.IR program-file (s) +if specified, or from the first non-option argument on the command line. +The +.B \-f +option may be used multiple times on the command line. +.I Gawk +will read the program text as if all the +.IR program-file s +had been concatenated together. This is useful for building libraries +of AWK functions, without having to include them in each new AWK diff --git a/contrib/awk/test/manyfiles.awk b/contrib/awk/test/manyfiles.awk new file mode 100644 index 0000000..8651a3a --- /dev/null +++ b/contrib/awk/test/manyfiles.awk @@ -0,0 +1 @@ +{ print $2 > ("junk/" $1) } diff --git a/contrib/awk/test/math.awk b/contrib/awk/test/math.awk new file mode 100644 index 0000000..90a01dd --- /dev/null +++ b/contrib/awk/test/math.awk @@ -0,0 +1,10 @@ +BEGIN { + pi = 3.1415927 + printf "cos(%f) = %f\n", pi/4, cos(pi/4) + printf "sin(%f) = %f\n", pi/4, sin(pi/4) + e = exp(1) + printf "e = %f\n", e + printf "log(e) = %f\n", log(e) + printf "sqrt(pi ^ 2) = %f\n", sqrt(pi ^ 2) + printf "atan2(1, 1) = %f\n", atan2(1, 1) +} diff --git a/contrib/awk/test/math.ok b/contrib/awk/test/math.ok new file mode 100644 index 0000000..a396a5b --- /dev/null +++ b/contrib/awk/test/math.ok @@ -0,0 +1,6 @@ +cos(0.785398) = 0.707107 +sin(0.785398) = 0.707107 +e = 2.718282 +log(e) = 1.000000 +sqrt(pi ^ 2) = 3.141593 +atan2(1, 1) = 0.785398 diff --git a/contrib/awk/test/messages.awk b/contrib/awk/test/messages.awk new file mode 100644 index 0000000..555f6e3 --- /dev/null +++ b/contrib/awk/test/messages.awk @@ -0,0 +1,9 @@ +# This is a demo of different ways of printing with gawk. Try it +# with and without -c (compatibility) flag, redirecting output +# from gawk to a file or not. Some results can be quite unexpected. +BEGIN { + print "Goes to a file out1" > "out1" + print "Normal print statement" + print "This printed on stdout" > "/dev/stdout" + print "You blew it!" > "/dev/stderr" +} diff --git a/contrib/awk/test/mmap8k.in b/contrib/awk/test/mmap8k.in new file mode 100644 index 0000000..0500ddf --- /dev/null +++ b/contrib/awk/test/mmap8k.in @@ -0,0 +1,143 @@ +XXXXXXXX.com ALTERNET 9305 930528 1500.00 startup +XXXXXXXX.com ALTERNET 9305 930624 94.38 Line-9305 +XXXXXXXX.com ALTERNET 9306 930624 104.49 Line-9306 +XXXXXXXX.com ALTERNET 9306 930624 649.16 Line-install +XXXXXXXX.com ALTERNET 9306 930624 166.67 TCP-slip +XXXXXXXX.com ALTERNET 9307 930624 104.49 Line-9307 +XXXXXXXX.com ALTERNET 9307 930624 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9308 930701 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9308 930701 104.49 line-9308 +XXXXXXXX.com PAYMENT 9307 930731 1500.00 1870 +XXXXXXXX.com ALTERNET 9309 930801 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9309 930801 104.49 line-9309 +XXXXXXXX.com INTEREST 9307 930801 22.50 +XXXXXXXX.com CREDADJ 9308 930805 22.50 waive interest +XXXXXXXX.com PAYMENT 9308 930820 1723.68 1982 +XXXXXXXX.com ALTERNET 9310 930901 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9310 930901 104.49 line-9310 +XXXXXXXX.com PAYMENT 9310 931001 708.98 2313 +XXXXXXXX.com ALTERNET 9311 931001 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9311 931001 104.49 line-9311 +XXXXXXXX.com INTEREST 9309 931001 5.32 +XXXXXXXX.com CREDADJ 9310 931007 5.32 waive int-9309 +XXXXXXXX.com ALTERNET 9312 931101 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9312 931101 104.49 line-9312 +XXXXXXXX.com PAYMENT 9311 931120 354.49 002701 +XXXXXXXX.com ALTERNET 9401 931201 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9401 931201 104.49 line-9401 +XXXXXXXX.com PAYMENT 9312 931218 354.49 2884 +XXXXXXXX.com ALTERNET 9402 940101 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9402 940101 104.49 line-9402 +XXXXXXXX.com INTEREST 9312 940101 5.32 +XXXXXXXX.com PAYMENT 9401 940122 354.49 3084 +XXXXXXXX.com ALTERNET 9403 940201 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9403 940201 104.49 line-9403 +XXXXXXXX.com INTEREST 9401 940201 5.40 +XXXXXXXX.com PAYMENT 9402 940207 354.49 3140 +XXXXXXXX.com CREDADJ 9402 940211 5.32 interest-9402 +XXXXXXXX.com CREDADJ 9402 940211 5.40 interest-9403 +XXXXXXXX.com ALTERNET 9404 940301 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9404 940301 104.49 line-9404 +XXXXXXXX.com INTEREST 9402 940301 5.32 +XXXXXXXX.com PAYMENT 9403 940310 354.49 003307 +XXXXXXXX.com PAYMENT 9403 940324 354.49 3446 +XXXXXXXX.com ALTERNET 9405 940401 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9405 940401 104.49 line-9405 +XXXXXXXX.com ALTERNET 9406 940501 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9406 940501 104.49 line-9406 +XXXXXXXX.com INTEREST 9404 940501 5.40 +XXXXXXXX.com PAYMENT 9405 940509 359.81 003819 +XXXXXXXX.com ALTERNET 9407 940601 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9407 940601 104.49 line-9407 +XXXXXXXX.com INTEREST 9405 940601 5.40 +XXXXXXXX.com PAYMENT 9406 940603 354.49 004025 +XXXXXXXX.com ALTERNET 9408 940701 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9408 940701 104.49 line-9408 +XXXXXXXX.com INTEREST 9406 940701 5.48 +XXXXXXXX.com PAYMENT 9407 940725 354.49 004350 +XXXXXXXX.com ALTERNET 9409 940801 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9409 940801 104.49 line-9409 +XXXXXXXX.com INTEREST 9407 940801 5.56 +XXXXXXXX.com PAYMENT 9408 940808 354.49 004454 +XXXXXXXX.com ALTERNET 9409 940811 0.00 startup +XXXXXXXX.com EQUIPMENT 9408 940831 399.00 ATL6402-1 +XXXXXXXX.com EQUIPMENT 9408 940831 2295.00 NBClassicPac-1 +XXXXXXXX.com EQUIPMENT 9408 940831 1060.00 Syn35-1+ship +XXXXXXXX.com ALTERNET 9410 940901 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9410 940901 104.49 line-9410 +XXXXXXXX.com INTEREST 9408 940901 5.64 +XXXXXXXX.com PAYMENT 9409 940906 354.49 004677 +XXXXXXXX.com CREDADJ 9409 940921 124.95 TCP-slip-9409 +XXXXXXXX.com CREDADJ 9409 940921 52.20 line-9409 +XXXXXXXX.com CREDADJ 9410 940921 250.00 TCP-slip-9410 +XXXXXXXX.com CREDADJ 9410 940921 104.49 line-9410 +XXXXXXXX.com ALTERNET 9409 940921 397.50 TCP-56k-local recon +XXXXXXXX.com ALTERNET 9409 940921 87.45 line-9409 recon +XXXXXXXX.com ALTERNET 9410 940921 795.00 TCP-56k-local recon +XXXXXXXX.com ALTERNET 9410 940921 174.90 line-9410 recon +XXXXXXXX.com ALTERNET 9411 941001 795.00 TCP-56k-local +XXXXXXXX.com ALTERNET 9411 941001 174.90 line-9411 +XXXXXXXX.com INTEREST 9409 941001 54.06 +XXXXXXXX.com PAYMENT 9410 941017 354.49 5026 +XXXXXXXX.com ALTERNET 9412 941101 795.00 TCP-56k-local +XXXXXXXX.com ALTERNET 9412 941101 174.90 line-9412 +XXXXXXXX.com INTEREST 9410 941101 85.93 +XXXXXXXX.com PAYMENT 9411 941114 969.90 005274 +XXXXXXXX.com ALTERNET 9501 941201 795.00 TCP-56k-local +XXXXXXXX.com ALTERNET 9501 941201 174.90 line-9501 +XXXXXXXX.com INTEREST 9411 941201 87.22 +XXXXXXXX.com PAYMENT 9412 941219 4723.90 5590 +XXXXXXXX.com ALTERNET 9502 950101 795.00 TCP-56k-local +XXXXXXXX.com ALTERNET 9502 950101 174.90 line-9502 +XXXXXXXX.com INTEREST 9412 950101 32.22 +XXXXXXXX.com PAYMENT 9501 950103 1893.11 5766 +XXXXXXXX.com ALTERNET 9503 950201 795.00 TCP-56k-local-old +XXXXXXXX.com ALTERNET 9503 950201 174.90 line-9503 +XXXXXXXX.com INTEREST 9501 950201 18.85 +XXXXXXXX.com PAYMENT 9502 950207 969.90 6044 +XXXXXXXX.com ALTERNET 9504 950301 795.00 TCP-56k-local-old +XXXXXXXX.com ALTERNET 9504 950301 174.90 line-9504 +XXXXXXXX.com INTEREST 9502 950301 19.13 +XXXXXXXX.com PAYMENT 9503 950307 969.90 6408 +XXXXXXXX.com ALTERNET 9504 950316 3000.00 startup TCP-bt1-128k%5 +XXXXXXXX.com PAYMENT 9503 950327 969.90 6594 +XXXXXXXX.com ALTERNET 9505 950401 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9505 950401 556.60 line-9505 +XXXXXXXX.com EQUIPMENT 9504 950410 1595.00 cisco2501-1 +XXXXXXXX.com CREDADJ 9504 950417 503.50 TCP-56k-local +XXXXXXXX.com CREDADJ 9504 950417 116.60 line-9504 +XXXXXXXX.com ALTERNET 9504 950417 448.80 line-install +XXXXXXXX.com ALTERNET 9504 950417 752.02 TCP-bt1-128k%5 recon +XXXXXXXX.com ALTERNET 9504 950417 371.00 line-9504 recon +XXXXXXXX.com PAYMENT 9504 950424 3000.00 6841 +XXXXXXXX.com ALTERNET 9506 950501 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9506 950501 556.60 line-9506 +XXXXXXXX.com PAYMENT 9505 950505 2049.86 6985 +XXXXXXXX.com PAYMENT 9505 950531 3924.22 7179 +XXXXXXXX.com ALTERNET 9507 950601 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9507 950601 556.60 line-9507 +XXXXXXXX.com PAYMENT 9506 950607 1744.10 7232 +XXXXXXXX.com ALTERNET 9508 950701 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9508 950701 556.60 line-9508 +XXXXXXXX.com PAYMENT 9507 950705 1744.10 7641 +XXXXXXXX.com ALTERNET 9509 950801 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9509 950801 556.60 line-9509 +XXXXXXXX.com PAYMENT 9508 950803 1744.10 7914 +XXXXXXXX.com ALTERNET 9510 950901 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9510 950901 556.60 line-9510 +XXXXXXXX.com PAYMENT 9509 950905 1744.10 8203 +XXXXXXXX.com ALTERNET 9511 951001 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9511 951001 556.60 line-9511 +XXXXXXXX.com PAYMENT 9510 951003 1744.10 8508 +XXXXXXXX.com ALTERNET 9512 951101 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9512 951101 556.60 line-9512 +XXXXXXXX.com PAYMENT 9511 951103 2129.83 8837 +XXXXXXXX.com ALTERNET 9601 951201 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9601 951201 556.60 line-9601 +XXXXXXXX.com PAYMENT 9512 951204 2129.83 9131 +XXXXXXXX.com ALTERNET 9602 960101 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9602 960101 556.60 line-9602 +XXXXXXXX.com PAYMENT 9601 960103 1744.10 9456 +XXXXXXXX.com ALTERNET 9603 960201 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9603 960201 556.60 line-9603 +XXXXXXXX.com PAYMENT 9602 960205 1358.37 9834 diff --git a/contrib/awk/test/negexp.ok b/contrib/awk/test/negexp.ok new file mode 100644 index 0000000..6e6566c --- /dev/null +++ b/contrib/awk/test/negexp.ok @@ -0,0 +1 @@ +0.01 diff --git a/contrib/awk/test/nfldstr.ok b/contrib/awk/test/nfldstr.ok new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/nfldstr.ok diff --git a/contrib/awk/test/nfset.awk b/contrib/awk/test/nfset.awk new file mode 100644 index 0000000..09ebd08 --- /dev/null +++ b/contrib/awk/test/nfset.awk @@ -0,0 +1 @@ +{ NF = 5 ; print } diff --git a/contrib/awk/test/nfset.in b/contrib/awk/test/nfset.in new file mode 100644 index 0000000..43329b5 --- /dev/null +++ b/contrib/awk/test/nfset.in @@ -0,0 +1,5 @@ +1 2 +1 2 3 4 +1 2 3 4 5 +1 2 3 4 5 6 7 8 +1 diff --git a/contrib/awk/test/nfset.ok b/contrib/awk/test/nfset.ok new file mode 100644 index 0000000..3ba48ae --- /dev/null +++ b/contrib/awk/test/nfset.ok @@ -0,0 +1,5 @@ +1 2 +1 2 3 4 +1 2 3 4 5 +1 2 3 4 5 +1 diff --git a/contrib/awk/test/nlfldsep.awk b/contrib/awk/test/nlfldsep.awk new file mode 100644 index 0000000..4fac81d --- /dev/null +++ b/contrib/awk/test/nlfldsep.awk @@ -0,0 +1,2 @@ +BEGIN { RS = "A" } +{print NF; for (i = 1; i <= NF; i++) print $i ; print ""} diff --git a/contrib/awk/test/nlfldsep.in b/contrib/awk/test/nlfldsep.in new file mode 100644 index 0000000..7b2317f --- /dev/null +++ b/contrib/awk/test/nlfldsep.in @@ -0,0 +1,5 @@ +some stuff +more stuffA +junk +stuffA +final diff --git a/contrib/awk/test/nlfldsep.ok b/contrib/awk/test/nlfldsep.ok new file mode 100644 index 0000000..6684916 --- /dev/null +++ b/contrib/awk/test/nlfldsep.ok @@ -0,0 +1,13 @@ +4 +some +stuff +more +stuff + +2 +junk +stuff + +1 +final + diff --git a/contrib/awk/test/noeffect.awk b/contrib/awk/test/noeffect.awk new file mode 100644 index 0000000..b375a4c --- /dev/null +++ b/contrib/awk/test/noeffect.awk @@ -0,0 +1,4 @@ +BEGIN { + s == "hello, world"; + print s +} diff --git a/contrib/awk/test/noeffect.ok b/contrib/awk/test/noeffect.ok new file mode 100644 index 0000000..b820ddf --- /dev/null +++ b/contrib/awk/test/noeffect.ok @@ -0,0 +1,2 @@ +gawk: noeffect.awk:3: warning: statement may have no effect + diff --git a/contrib/awk/test/nofmtch.awk b/contrib/awk/test/nofmtch.awk new file mode 100644 index 0000000..2ea2249 --- /dev/null +++ b/contrib/awk/test/nofmtch.awk @@ -0,0 +1 @@ +BEGIN { printf "%3\n" } diff --git a/contrib/awk/test/nofmtch.ok b/contrib/awk/test/nofmtch.ok new file mode 100644 index 0000000..e6f3846 --- /dev/null +++ b/contrib/awk/test/nofmtch.ok @@ -0,0 +1,2 @@ +gawk: nofmtch.awk:1: warning: printf format specifier does not have control letter +%3 diff --git a/contrib/awk/test/nondec.awk b/contrib/awk/test/nondec.awk new file mode 100644 index 0000000..a680110 --- /dev/null +++ b/contrib/awk/test/nondec.awk @@ -0,0 +1 @@ +BEGIN { print 0x81c3e8, 0x744018 } diff --git a/contrib/awk/test/nondec.ok b/contrib/awk/test/nondec.ok new file mode 100644 index 0000000..560f3d1 --- /dev/null +++ b/contrib/awk/test/nondec.ok @@ -0,0 +1 @@ +8504296 7618584 diff --git a/contrib/awk/test/nonl.awk b/contrib/awk/test/nonl.awk new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/contrib/awk/test/nonl.awk @@ -0,0 +1 @@ +0
\ No newline at end of file diff --git a/contrib/awk/test/nonl.ok b/contrib/awk/test/nonl.ok new file mode 100644 index 0000000..24bd9b7 --- /dev/null +++ b/contrib/awk/test/nonl.ok @@ -0,0 +1 @@ +gawk: nonl.awk:1: warning: source file does not end in newline diff --git a/contrib/awk/test/noparms.awk b/contrib/awk/test/noparms.awk new file mode 100644 index 0000000..2c7ccc7 --- /dev/null +++ b/contrib/awk/test/noparms.awk @@ -0,0 +1 @@ +function x(a, b, c , ,) {} diff --git a/contrib/awk/test/noparms.ok b/contrib/awk/test/noparms.ok new file mode 100644 index 0000000..4c934c3 --- /dev/null +++ b/contrib/awk/test/noparms.ok @@ -0,0 +1,4 @@ +gawk: noparms.awk:1: function x(a, b, c , ,) {} +gawk: noparms.awk:1: ^ parse error +gawk: noparms.awk:1: function x(a, b, c , ,) {} +gawk: noparms.awk:1: ^ parse error diff --git a/contrib/awk/test/nors.in b/contrib/awk/test/nors.in new file mode 100644 index 0000000..f90d9ec --- /dev/null +++ b/contrib/awk/test/nors.in @@ -0,0 +1 @@ +A B C D E
\ No newline at end of file diff --git a/contrib/awk/test/nors.ok b/contrib/awk/test/nors.ok new file mode 100644 index 0000000..54d5aab --- /dev/null +++ b/contrib/awk/test/nors.ok @@ -0,0 +1,2 @@ +E +E diff --git a/contrib/awk/test/numsubstr.awk b/contrib/awk/test/numsubstr.awk new file mode 100644 index 0000000..7a30993 --- /dev/null +++ b/contrib/awk/test/numsubstr.awk @@ -0,0 +1 @@ +{ print substr(1000+$1, 2) } diff --git a/contrib/awk/test/numsubstr.in b/contrib/awk/test/numsubstr.in new file mode 100644 index 0000000..ac65c36 --- /dev/null +++ b/contrib/awk/test/numsubstr.in @@ -0,0 +1,3 @@ +5000 +10000 +5000 diff --git a/contrib/awk/test/numsubstr.ok b/contrib/awk/test/numsubstr.ok new file mode 100644 index 0000000..86ec13c --- /dev/null +++ b/contrib/awk/test/numsubstr.ok @@ -0,0 +1,3 @@ +000 +1000 +000 diff --git a/contrib/awk/test/out1.ok b/contrib/awk/test/out1.ok new file mode 100644 index 0000000..f54b2b4 --- /dev/null +++ b/contrib/awk/test/out1.ok @@ -0,0 +1 @@ +Goes to a file out1 diff --git a/contrib/awk/test/out2.ok b/contrib/awk/test/out2.ok new file mode 100644 index 0000000..66b7d2f --- /dev/null +++ b/contrib/awk/test/out2.ok @@ -0,0 +1,2 @@ +Normal print statement +This printed on stdout diff --git a/contrib/awk/test/out3.ok b/contrib/awk/test/out3.ok new file mode 100644 index 0000000..7eb822f --- /dev/null +++ b/contrib/awk/test/out3.ok @@ -0,0 +1 @@ +You blew it! diff --git a/contrib/awk/test/paramdup.awk b/contrib/awk/test/paramdup.awk new file mode 100644 index 0000000..1f1cc7a --- /dev/null +++ b/contrib/awk/test/paramdup.awk @@ -0,0 +1,8 @@ +BEGIN { foo(0, 1, 2) } + +function foo(a, b, c, b, a) +{ + print "a =", a + print "b =", b + print "c =", c +} diff --git a/contrib/awk/test/paramdup.ok b/contrib/awk/test/paramdup.ok new file mode 100644 index 0000000..0308cc8 --- /dev/null +++ b/contrib/awk/test/paramdup.ok @@ -0,0 +1,2 @@ +gawk: paramdup.awk:4: error: function `foo': parameter #4, `b', duplicates parameter #2 +gawk: paramdup.awk:4: error: function `foo': parameter #5, `a', duplicates parameter #1 diff --git a/contrib/awk/test/pcntplus.awk b/contrib/awk/test/pcntplus.awk new file mode 100644 index 0000000..13999ac --- /dev/null +++ b/contrib/awk/test/pcntplus.awk @@ -0,0 +1 @@ +BEGIN { printf "%+d %d\n", 3, 4 } diff --git a/contrib/awk/test/pcntplus.ok b/contrib/awk/test/pcntplus.ok new file mode 100644 index 0000000..b790269 --- /dev/null +++ b/contrib/awk/test/pcntplus.ok @@ -0,0 +1 @@ ++3 4 diff --git a/contrib/awk/test/pid.awk b/contrib/awk/test/pid.awk new file mode 100644 index 0000000..9b47d90 --- /dev/null +++ b/contrib/awk/test/pid.awk @@ -0,0 +1,44 @@ +# From: John C. Oppenheimer <jco@slinky.convex.com> +# Subject: gawk-3.0.2 pid test +# To: arnold@skeeve.atl.ga.us +# Date: Mon, 10 Feb 1997 08:31:55 -0600 (CST) +# +# Thanks for the very quick reply. +# +# This all started when I was looking for how to do the equivalent of +# "nextfile." I was after documentation and found our gawk down a few +# revs. +# +# Looks like the nextfile functionality was added somewhere around +# 2.15.5. There wasn't a way to do it, until now! Thanks for the +# functionality! +# +# Saw the /dev/xxx capability and just tried it. +# +# Anyway, I wrote a pid test. I hope that it is portable. Wanted to +# make a user test, but looks like id(1) is not very portable. But a +# little test is better than none. +# +# John +# +# pid.ok is a zero length file +# +# ================== pid.awk ============ +BEGIN { + getline pid <"/dev/pid" + getline ppid <"/dev/ppid" +} +NR == 1 { + if (pid != $0) { + printf "Bad pid %d, wanted %d\n", $0, pid + } +} +NR == 2 { + if (ppid != $0) { + printf "Bad ppid %d, wanted %d\n", $0, ppid + } +} +END { # ADR --- added + close("/dev/pid") + close("/dev/ppid") +} diff --git a/contrib/awk/test/pid.ok b/contrib/awk/test/pid.ok new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/pid.ok diff --git a/contrib/awk/test/pid.sh b/contrib/awk/test/pid.sh new file mode 100755 index 0000000..a19d72c --- /dev/null +++ b/contrib/awk/test/pid.sh @@ -0,0 +1,5 @@ +#! /bin/sh +AWK=${AWK-../gawk} +echo $$ > _pid.in +echo $1 >> _pid.in +exec $AWK -f pid.awk _pid.in diff --git a/contrib/awk/test/pipeio1.awk b/contrib/awk/test/pipeio1.awk new file mode 100644 index 0000000..66f50ad --- /dev/null +++ b/contrib/awk/test/pipeio1.awk @@ -0,0 +1,31 @@ +# From dragon!gamgee.acad.emich.edu!dhw Tue Mar 18 01:12:15 1997 +# Return-Path: <dragon!gamgee.acad.emich.edu!dhw> +# Message-ID: <m0w6owW-000IDSC@gamgee.acad.emich.edu> +# Date: Mon, 17 Mar 97 20:48 CST +# From: dhw@gamgee.acad.emich.edu (David H. West) +# To: arnold@gnu.ai.mit.edu +# Subject: gawk 3.0.2 bug report (cc of msg to bug-gnu-utils) +# Status: OR +# Content-Length: 869 +# X-Lines: 20 +# X-Display-Position: 2 +# +# Nature of bug: operation on a pipe side-effects a different pipe. +# Observed-With: gawk 3.0.2, Linux kernel 2.0.28 +# Reproduce-By: running the following script, without and with the "close" +# statement uncommented. +# -----------------cut here-------------------------- +BEGIN {FILE1="test1"; FILE2="test2"; + print "1\n" > FILE1; close(FILE1); + print "2\n" > FILE2; close(FILE2); + cmd1="cat " FILE1; cmd2="cat " FILE2; + #end of preparing commands which give easily-predictable output + + while( (cmd1 | getline)==1) { #terminates as file has only 1 line + #and we never close cmd1 + cmd2 | getline L; + #BUG: uncommenting the following line causes an infinite loop + close(cmd2); + print $0,L; + } + } diff --git a/contrib/awk/test/pipeio1.ok b/contrib/awk/test/pipeio1.ok new file mode 100644 index 0000000..706b09e --- /dev/null +++ b/contrib/awk/test/pipeio1.ok @@ -0,0 +1,2 @@ +1 2 + 2 diff --git a/contrib/awk/test/pipeio2.awk b/contrib/awk/test/pipeio2.awk new file mode 100644 index 0000000..6f4f979 --- /dev/null +++ b/contrib/awk/test/pipeio2.awk @@ -0,0 +1,67 @@ +# From: megaadm@rina.quantum.de +# Subject: Bug report - closing down pipes which read from shell com +# To: bug-gnu-utils@prep.ai.mit.edu +# Date: Thu, 27 Feb 1997 23:19:16 +0100 (CET) +# CC: arnold@gnu.ai.mit.edu +# +# Hello people, +# +# i think i found a bug or something mysterious behaviour in +# gawk Version 3.0 patchlevel 0. +# +# I am running on linux 2.0.25 under bash. +# +# Could you please have a look at the following awk program +# an let me please know, if this is what i expect it to, +# namely a bug. +# +# ----------- cut here -------------------------------------------- +BEGIN { + # OS is linux 2.0.25 + # shell is bash + # Gnu Awk (gawk) 3.0, patchlevel 0 + # The command i typed on the shell was "gawk -f <this_prog> -" + + #com = "cal 01 1997" + com = ("cat " SRCDIR "/pipeio2.in") + + while ((com | getline fnam) > 0) { + + com_tr = "echo " fnam " | tr [0-9]. ..........." + print "\'" com_tr "\'" + + com_tr | getline nam + print nam + + # please run that program and take a look at the + # output. I think this is what was expected. + + # Then comment in the following 4 lines and see + # what happens. I expect the first pipe "com | getline" + # not to be close, but i think this is exactly what happens + # So, is this ok ? + + if (close(com_tr) < 0) { + print ERRNO + break + } + } + + close(com) + } +# ----------- cut here -------------------------------------------- +# +# There is another thing i do not understand. +# Why doesn't the awk - command "close" reports an +# error, if i would say close("abc") which i had never +# openend ? +# +# Regards, +# Ulrich Gvbel +# -- +# /********************************************************\ +# * Ulrich Gvbel, goebel@quantum.de * +# * Quantum Gesellschaft f|r Software mbH, Dortmund * +# * phone : +49-231-9749-201 fax: +49-231-9749-3 * +# * private: +49-231-803994 fax: +49-231-803994 * +# \********************************************************/ diff --git a/contrib/awk/test/pipeio2.in b/contrib/awk/test/pipeio2.in new file mode 100644 index 0000000..2652b0e --- /dev/null +++ b/contrib/awk/test/pipeio2.in @@ -0,0 +1,8 @@ + January 1997 + S M Tu W Th F S + 1 2 3 4 + 5 6 7 8 9 10 11 +12 13 14 15 16 17 18 +19 20 21 22 23 24 25 +26 27 28 29 30 31 + diff --git a/contrib/awk/test/pipeio2.ok b/contrib/awk/test/pipeio2.ok new file mode 100644 index 0000000..3f55c05 --- /dev/null +++ b/contrib/awk/test/pipeio2.ok @@ -0,0 +1,16 @@ +'echo January 1997 | tr [0-9]. ...........' +January .... +'echo S M Tu W Th F S | tr [0-9]. ...........' +S M Tu W Th F S +'echo 1 2 3 4 | tr [0-9]. ...........' +. . . . +'echo 5 6 7 8 9 10 11 | tr [0-9]. ...........' +. . . . . .. .. +'echo 12 13 14 15 16 17 18 | tr [0-9]. ...........' +.. .. .. .. .. .. .. +'echo 19 20 21 22 23 24 25 | tr [0-9]. ...........' +.. .. .. .. .. .. .. +'echo 26 27 28 29 30 31 | tr [0-9]. ...........' +.. .. .. .. .. .. +'echo | tr [0-9]. ...........' + diff --git a/contrib/awk/test/posix.awk b/contrib/awk/test/posix.awk new file mode 100644 index 0000000..79474f3 --- /dev/null +++ b/contrib/awk/test/posix.awk @@ -0,0 +1,69 @@ +BEGIN { + a = "+2"; b = 2; c = "+2a"; d = "+2 "; e = " 2" + + printf "Test #1: " + if (b == a) print "\"" a "\"" " compares as a number" + else print "\"" a "\"" " compares as a string" + + printf "Test #2: " + if (b == c) print "\"" c "\"" " compares as a number" + else print "\"" c "\"" " compares as a string" + + printf "Test #3: " + if (b == d) print "\"" d "\"" " compares as a number" + else print "\"" d "\"" " compares as a string" + + printf "Test #4: " + if (b == e) print "\"" e "\"" " compares as a number" + else print "\"" e "\"" " compares as a string" + + f = a + b + c + d + e + print "after addition" + + printf "Test #5: " + if (b == a) print "\"" a "\"" " compares as a number" + else print "\"" a "\"" " compares as a string" + + printf "Test #6: " + if (b == c) print "\"" c "\"" " compares as a number" + else print "\"" c "\"" " compares as a string" + + printf "Test #7: " + if (b == d) print "\"" d "\"" " compares as a number" + else print "\"" d "\"" " compares as a string" + + printf "Test #8: " + if (b == e) print "\"" e "\"" " compares as a number" + else print "\"" e "\"" " compares as a string" + + printf "Test #9: " + if ("3e5" > "5") print "\"3e5\" > \"5\"" + else print "\"3e5\" <= \"5\"" + + printf "Test #10: " + x = 32.14 + y[x] = "test" + OFMT = "%e" + print y[x] + + printf "Test #11: " + x = x + 0 + print y[x] + + printf "Test #12: " + OFMT="%f" + CONVFMT="%e" + print 1.5, 1.5 "" + + printf "Test #13: " + if ( 1000000 "" == 1000001 "") print "match" + else print "nomatch" +} +{ + printf "Test #14: " + FS = ":" + print $1 + FS = "," + printf "Test #15: " + print $2 +} diff --git a/contrib/awk/test/posix.ok b/contrib/awk/test/posix.ok new file mode 100644 index 0000000..100b150 --- /dev/null +++ b/contrib/awk/test/posix.ok @@ -0,0 +1,16 @@ +Test #1: "+2" compares as a string +Test #2: "+2a" compares as a string +Test #3: "+2 " compares as a string +Test #4: " 2" compares as a string +after addition +Test #5: "+2" compares as a string +Test #6: "+2a" compares as a string +Test #7: "+2 " compares as a string +Test #8: " 2" compares as a string +Test #9: "3e5" <= "5" +Test #10: test +Test #11: test +Test #12: 1.500000 1.500000e+00 +Test #13: nomatch +Test #14: 1:2,3 +Test #15: 4 diff --git a/contrib/awk/test/poundbang b/contrib/awk/test/poundbang new file mode 100755 index 0000000..d60652e --- /dev/null +++ b/contrib/awk/test/poundbang @@ -0,0 +1,3 @@ +#! /tmp/gawk -f + { ccount += length($0) } +END { printf "average line length is %2.4f\n", ccount/NR} diff --git a/contrib/awk/test/poundbang.ok b/contrib/awk/test/poundbang.ok new file mode 100644 index 0000000..143e28d --- /dev/null +++ b/contrib/awk/test/poundbang.ok @@ -0,0 +1 @@ +average line length is 32.6667 diff --git a/contrib/awk/test/prdupval.awk b/contrib/awk/test/prdupval.awk new file mode 100644 index 0000000..32c67dc --- /dev/null +++ b/contrib/awk/test/prdupval.awk @@ -0,0 +1 @@ +{ print NF, $NF, "abc" $NF } diff --git a/contrib/awk/test/prdupval.in b/contrib/awk/test/prdupval.in new file mode 100644 index 0000000..5626abf --- /dev/null +++ b/contrib/awk/test/prdupval.in @@ -0,0 +1 @@ +one diff --git a/contrib/awk/test/prdupval.ok b/contrib/awk/test/prdupval.ok new file mode 100644 index 0000000..6253616 --- /dev/null +++ b/contrib/awk/test/prdupval.ok @@ -0,0 +1 @@ +1 one abcone diff --git a/contrib/awk/test/prmarscl.awk b/contrib/awk/test/prmarscl.awk new file mode 100644 index 0000000..3caf3d9 --- /dev/null +++ b/contrib/awk/test/prmarscl.awk @@ -0,0 +1,6 @@ +function test(a) +{ + print a[1] +} + +BEGIN { j = 4; test(j) } diff --git a/contrib/awk/test/prmarscl.ok b/contrib/awk/test/prmarscl.ok new file mode 100644 index 0000000..b42cee6 --- /dev/null +++ b/contrib/awk/test/prmarscl.ok @@ -0,0 +1 @@ +gawk: prmarscl.awk:4: fatal: attempt to use scalar parameter 1 as an array diff --git a/contrib/awk/test/prmreuse.awk b/contrib/awk/test/prmreuse.awk new file mode 100644 index 0000000..37e06f5 --- /dev/null +++ b/contrib/awk/test/prmreuse.awk @@ -0,0 +1,14 @@ +# from Pat Rankin, rankin@eql.caltech.edu + +BEGIN { dummy(1); legit(); exit } + +function dummy(arg) +{ + return arg +} + +function legit( scratch) +{ + split("1 2 3", scratch) + return "" +} diff --git a/contrib/awk/test/prmreuse.ok b/contrib/awk/test/prmreuse.ok new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/prmreuse.ok diff --git a/contrib/awk/test/prt1eval.awk b/contrib/awk/test/prt1eval.awk new file mode 100644 index 0000000..4ecd368 --- /dev/null +++ b/contrib/awk/test/prt1eval.awk @@ -0,0 +1,6 @@ +function tst () { + sum += 1 + return sum +} + +BEGIN { OFMT = "%.0f" ; print tst() } diff --git a/contrib/awk/test/prt1eval.ok b/contrib/awk/test/prt1eval.ok new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/contrib/awk/test/prt1eval.ok @@ -0,0 +1 @@ +1 diff --git a/contrib/awk/test/prtoeval.awk b/contrib/awk/test/prtoeval.awk new file mode 100644 index 0000000..77880d8 --- /dev/null +++ b/contrib/awk/test/prtoeval.awk @@ -0,0 +1,4 @@ +function returns_a_str() { print "<in function>" ; return "'A STRING'" } +BEGIN { + print "partial line:", returns_a_str() +} diff --git a/contrib/awk/test/prtoeval.ok b/contrib/awk/test/prtoeval.ok new file mode 100644 index 0000000..13e122b --- /dev/null +++ b/contrib/awk/test/prtoeval.ok @@ -0,0 +1,2 @@ +<in function> +partial line: 'A STRING' diff --git a/contrib/awk/test/rand.awk b/contrib/awk/test/rand.awk new file mode 100644 index 0000000..6378f3d --- /dev/null +++ b/contrib/awk/test/rand.awk @@ -0,0 +1,6 @@ +BEGIN { + srand(2) + for (i = 0; i < 19; i++) + printf "%3d ", (1 + int(100 * rand())) + print "" +} diff --git a/contrib/awk/test/rand.ok b/contrib/awk/test/rand.ok new file mode 100644 index 0000000..b6d7554 --- /dev/null +++ b/contrib/awk/test/rand.ok @@ -0,0 +1 @@ + 27 17 86 27 22 53 61 11 33 48 51 97 99 35 20 27 62 100 32 diff --git a/contrib/awk/test/reg/exp-eq.awk b/contrib/awk/test/reg/exp-eq.awk new file mode 100644 index 0000000..fed6a69 --- /dev/null +++ b/contrib/awk/test/reg/exp-eq.awk @@ -0,0 +1 @@ +{ $0 ^= 3 ; print $1} diff --git a/contrib/awk/test/reg/exp-eq.good b/contrib/awk/test/reg/exp-eq.good new file mode 100644 index 0000000..d8d59aa --- /dev/null +++ b/contrib/awk/test/reg/exp-eq.good @@ -0,0 +1,3 @@ +1 +8 +27 diff --git a/contrib/awk/test/reg/exp-eq.in b/contrib/awk/test/reg/exp-eq.in new file mode 100644 index 0000000..01e79c3 --- /dev/null +++ b/contrib/awk/test/reg/exp-eq.in @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/contrib/awk/test/reg/exp.awk b/contrib/awk/test/reg/exp.awk new file mode 100644 index 0000000..4e707f8 --- /dev/null +++ b/contrib/awk/test/reg/exp.awk @@ -0,0 +1 @@ +BEGIN { print exp(0), exp(1000000), exp(0.5) } diff --git a/contrib/awk/test/reg/exp.good b/contrib/awk/test/reg/exp.good new file mode 100644 index 0000000..07b8853 --- /dev/null +++ b/contrib/awk/test/reg/exp.good @@ -0,0 +1,2 @@ +1 gawk: reg/exp.awk:1: warning: exp argument 1e+06 is out of range +Inf 1.64872 diff --git a/contrib/awk/test/reg/exp.in b/contrib/awk/test/reg/exp.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/reg/exp.in diff --git a/contrib/awk/test/reg/func.awk b/contrib/awk/test/reg/func.awk new file mode 100644 index 0000000..e32cd4e --- /dev/null +++ b/contrib/awk/test/reg/func.awk @@ -0,0 +1 @@ +BEGIN { print dummy(1) } diff --git a/contrib/awk/test/reg/func.good b/contrib/awk/test/reg/func.good new file mode 100644 index 0000000..d3c7c71 --- /dev/null +++ b/contrib/awk/test/reg/func.good @@ -0,0 +1 @@ +gawk: reg/func.awk:1: fatal: function `dummy' not defined diff --git a/contrib/awk/test/reg/func.in b/contrib/awk/test/reg/func.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/reg/func.in diff --git a/contrib/awk/test/reg/func2.awk b/contrib/awk/test/reg/func2.awk new file mode 100644 index 0000000..2abf2c1 --- /dev/null +++ b/contrib/awk/test/reg/func2.awk @@ -0,0 +1,2 @@ +function dummy() { ; } +BEGIN { print dummy (1) } diff --git a/contrib/awk/test/reg/func2.good b/contrib/awk/test/reg/func2.good new file mode 100644 index 0000000..ae87bc3 --- /dev/null +++ b/contrib/awk/test/reg/func2.good @@ -0,0 +1,2 @@ +gawk: reg/func2.awk:2: fatal: function `dummy' called with space between name and (, +or used in other expression context diff --git a/contrib/awk/test/reg/func2.in b/contrib/awk/test/reg/func2.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/reg/func2.in diff --git a/contrib/awk/test/reg/log.awk b/contrib/awk/test/reg/log.awk new file mode 100644 index 0000000..bcae90b --- /dev/null +++ b/contrib/awk/test/reg/log.awk @@ -0,0 +1 @@ +BEGIN { print log(0), log(-1), log(100) } diff --git a/contrib/awk/test/reg/log.good b/contrib/awk/test/reg/log.good new file mode 100644 index 0000000..857ab77 --- /dev/null +++ b/contrib/awk/test/reg/log.good @@ -0,0 +1,4 @@ +log: SING error +-Inf gawk: reg/log.awk:1: warning: log called with negative argument -1 +log: DOMAIN error +NaN 4.60517 diff --git a/contrib/awk/test/reg/log.in b/contrib/awk/test/reg/log.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/reg/log.in diff --git a/contrib/awk/test/regtest b/contrib/awk/test/regtest new file mode 100755 index 0000000..72b0dbf --- /dev/null +++ b/contrib/awk/test/regtest @@ -0,0 +1,18 @@ +#! /bin/sh + +case "$AWK" in +"") AWK=../gawk ;; +esac +#AWK=${AWK:-../gawk} + +for i in reg/*.awk +do + it=`basename $i .awk` + $AWK -f $i <reg/$it.in >reg/$it.out 2>&1 + if cmp -s reg/$it.out reg/$it.good + then + rm -f reg/$it.out + else + echo "regtest: $it fails" + fi +done diff --git a/contrib/awk/test/reindops.awk b/contrib/awk/test/reindops.awk new file mode 100644 index 0000000..13ae657 --- /dev/null +++ b/contrib/awk/test/reindops.awk @@ -0,0 +1,6 @@ +{ + if ($1 !~ /^+[2-9]/) + print "gawk is broken" + else + print "gawk is ok" +} diff --git a/contrib/awk/test/reindops.in b/contrib/awk/test/reindops.in new file mode 100644 index 0000000..b1e5435 --- /dev/null +++ b/contrib/awk/test/reindops.in @@ -0,0 +1 @@ ++44 123 456 diff --git a/contrib/awk/test/reindops.ok b/contrib/awk/test/reindops.ok new file mode 100644 index 0000000..f9605fd --- /dev/null +++ b/contrib/awk/test/reindops.ok @@ -0,0 +1 @@ +gawk is ok diff --git a/contrib/awk/test/reint.awk b/contrib/awk/test/reint.awk new file mode 100644 index 0000000..add0f2a --- /dev/null +++ b/contrib/awk/test/reint.awk @@ -0,0 +1 @@ +{ print match($0, /a{3}/) } diff --git a/contrib/awk/test/reint.in b/contrib/awk/test/reint.in new file mode 100644 index 0000000..43caa2a --- /dev/null +++ b/contrib/awk/test/reint.in @@ -0,0 +1 @@ +match this: aaa diff --git a/contrib/awk/test/reint.ok b/contrib/awk/test/reint.ok new file mode 100644 index 0000000..b1bd38b --- /dev/null +++ b/contrib/awk/test/reint.ok @@ -0,0 +1 @@ +13 diff --git a/contrib/awk/test/reparse.awk b/contrib/awk/test/reparse.awk new file mode 100644 index 0000000..433ecbb --- /dev/null +++ b/contrib/awk/test/reparse.awk @@ -0,0 +1,7 @@ +{ + gsub(/x/, " ") + $0 = $0 + print $1 + print $0 + print $1, $2, $3 +} diff --git a/contrib/awk/test/reparse.in b/contrib/awk/test/reparse.in new file mode 100644 index 0000000..6f31cde --- /dev/null +++ b/contrib/awk/test/reparse.in @@ -0,0 +1 @@ +1 axbxc 2 diff --git a/contrib/awk/test/reparse.ok b/contrib/awk/test/reparse.ok new file mode 100644 index 0000000..6bdfacf --- /dev/null +++ b/contrib/awk/test/reparse.ok @@ -0,0 +1,3 @@ +1 +1 a b c 2 +1 a b diff --git a/contrib/awk/test/resplit.ok b/contrib/awk/test/resplit.ok new file mode 100644 index 0000000..6178079 --- /dev/null +++ b/contrib/awk/test/resplit.ok @@ -0,0 +1 @@ +b diff --git a/contrib/awk/test/rs.in b/contrib/awk/test/rs.in new file mode 100644 index 0000000..edef835 --- /dev/null +++ b/contrib/awk/test/rs.in @@ -0,0 +1,15 @@ + + +a +b + + +c d + + + +e + + + + diff --git a/contrib/awk/test/rs.ok b/contrib/awk/test/rs.ok new file mode 100644 index 0000000..9dd6bd3 --- /dev/null +++ b/contrib/awk/test/rs.ok @@ -0,0 +1,3 @@ +a b +c d +e diff --git a/contrib/awk/test/rswhite.awk b/contrib/awk/test/rswhite.awk new file mode 100644 index 0000000..0048765 --- /dev/null +++ b/contrib/awk/test/rswhite.awk @@ -0,0 +1,2 @@ +BEGIN { RS = "" } +{ printf("<%s>\n", $0) } diff --git a/contrib/awk/test/rswhite.in b/contrib/awk/test/rswhite.in new file mode 100644 index 0000000..39f7756 --- /dev/null +++ b/contrib/awk/test/rswhite.in @@ -0,0 +1,2 @@ + a b +c d diff --git a/contrib/awk/test/rswhite.ok b/contrib/awk/test/rswhite.ok new file mode 100644 index 0000000..a029e47 --- /dev/null +++ b/contrib/awk/test/rswhite.ok @@ -0,0 +1,2 @@ +< a b +c d> diff --git a/contrib/awk/test/sclforin.awk b/contrib/awk/test/sclforin.awk new file mode 100644 index 0000000..335e854 --- /dev/null +++ b/contrib/awk/test/sclforin.awk @@ -0,0 +1 @@ +BEGIN { j = 4; for (i in j) print j[i] } diff --git a/contrib/awk/test/sclforin.ok b/contrib/awk/test/sclforin.ok new file mode 100644 index 0000000..d87fa61 --- /dev/null +++ b/contrib/awk/test/sclforin.ok @@ -0,0 +1 @@ +gawk: sclforin.awk:1: fatal: attempt to use scalar as array diff --git a/contrib/awk/test/sclifin.awk b/contrib/awk/test/sclifin.awk new file mode 100644 index 0000000..64f5d0d --- /dev/null +++ b/contrib/awk/test/sclifin.awk @@ -0,0 +1,7 @@ +BEGIN { + j = 4 + if ("foo" in j) + print "ouch" + else + print "ok" +} diff --git a/contrib/awk/test/sclifin.ok b/contrib/awk/test/sclifin.ok new file mode 100644 index 0000000..717f836 --- /dev/null +++ b/contrib/awk/test/sclifin.ok @@ -0,0 +1 @@ +gawk: sclifin.awk:7: fatal: attempt to use scalar as array diff --git a/contrib/awk/test/splitargv.awk b/contrib/awk/test/splitargv.awk new file mode 100644 index 0000000..10886ef --- /dev/null +++ b/contrib/awk/test/splitargv.awk @@ -0,0 +1,7 @@ +BEGIN { + for (idx = 1; idx < ARGC; idx++) + split(ARGV[idx], temp, "."); + } + { + print $0; + } diff --git a/contrib/awk/test/splitargv.in b/contrib/awk/test/splitargv.in new file mode 100644 index 0000000..10886ef --- /dev/null +++ b/contrib/awk/test/splitargv.in @@ -0,0 +1,7 @@ +BEGIN { + for (idx = 1; idx < ARGC; idx++) + split(ARGV[idx], temp, "."); + } + { + print $0; + } diff --git a/contrib/awk/test/splitargv.ok b/contrib/awk/test/splitargv.ok new file mode 100644 index 0000000..10886ef --- /dev/null +++ b/contrib/awk/test/splitargv.ok @@ -0,0 +1,7 @@ +BEGIN { + for (idx = 1; idx < ARGC; idx++) + split(ARGV[idx], temp, "."); + } + { + print $0; + } diff --git a/contrib/awk/test/splitvar.awk b/contrib/awk/test/splitvar.awk new file mode 100644 index 0000000..9e1ac79 --- /dev/null +++ b/contrib/awk/test/splitvar.awk @@ -0,0 +1,5 @@ +{ + sep = "=+" + n = split($0, a, sep) + print n +} diff --git a/contrib/awk/test/splitvar.in b/contrib/awk/test/splitvar.in new file mode 100644 index 0000000..85be8ee --- /dev/null +++ b/contrib/awk/test/splitvar.in @@ -0,0 +1 @@ +Here===Is=Some=====Data diff --git a/contrib/awk/test/splitvar.ok b/contrib/awk/test/splitvar.ok new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/contrib/awk/test/splitvar.ok @@ -0,0 +1 @@ +4 diff --git a/contrib/awk/test/splitwht.awk b/contrib/awk/test/splitwht.awk new file mode 100644 index 0000000..6163d72 --- /dev/null +++ b/contrib/awk/test/splitwht.awk @@ -0,0 +1,7 @@ +BEGIN { + str = "a b\t\tc d" + n = split(str, a, " ") + print n + m = split(str, b, / /) + print m +} diff --git a/contrib/awk/test/splitwht.ok b/contrib/awk/test/splitwht.ok new file mode 100644 index 0000000..61c83cb --- /dev/null +++ b/contrib/awk/test/splitwht.ok @@ -0,0 +1,2 @@ +4 +5 diff --git a/contrib/awk/test/sprintfc.awk b/contrib/awk/test/sprintfc.awk new file mode 100644 index 0000000..ee1e5a7 --- /dev/null +++ b/contrib/awk/test/sprintfc.awk @@ -0,0 +1 @@ +{ print sprintf("%c", $1), $1 } diff --git a/contrib/awk/test/sprintfc.in b/contrib/awk/test/sprintfc.in new file mode 100644 index 0000000..4602d28 --- /dev/null +++ b/contrib/awk/test/sprintfc.in @@ -0,0 +1,3 @@ +65 +66 +foo diff --git a/contrib/awk/test/sprintfc.ok b/contrib/awk/test/sprintfc.ok new file mode 100644 index 0000000..33769a8 --- /dev/null +++ b/contrib/awk/test/sprintfc.ok @@ -0,0 +1,3 @@ +A 65 +B 66 +f foo diff --git a/contrib/awk/test/strftlng.awk b/contrib/awk/test/strftlng.awk new file mode 100644 index 0000000..0ef8195 --- /dev/null +++ b/contrib/awk/test/strftlng.awk @@ -0,0 +1,11 @@ +# test file from Paul Eggert, eggert@twinsun.com +# modified for portability (%c doesn't cut it) + +BEGIN { + BUFSIZ = 1024 + simpleformat = format = "%m/%d/%y %H:%M:%S\n" + clen = length(strftime(format, 0)) + for (i = 1; i < BUFSIZ / clen + 1; i++) + format = format simpleformat + printf "%s", strftime(format, 0) +} diff --git a/contrib/awk/test/strftlng.ok b/contrib/awk/test/strftlng.ok new file mode 100644 index 0000000..3008aa2 --- /dev/null +++ b/contrib/awk/test/strftlng.ok @@ -0,0 +1,58 @@ +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 diff --git a/contrib/awk/test/substr.awk b/contrib/awk/test/substr.awk new file mode 100644 index 0000000..6016369 --- /dev/null +++ b/contrib/awk/test/substr.awk @@ -0,0 +1,14 @@ +BEGIN { + x = "A" + printf("%-39s\n", substr(x,1,39)) + print substr("abcdef", 0, 2) + print substr("abcdef", 2.3, 2) + print substr("abcdef", -1, 2) + print substr("abcdef", 1, 0) + print substr("abcdef", 1, -3) + print substr("abcdef", 1, 2.3) + print substr("", 1, 2) + print substr("abcdef", 5, 5) + print substr("abcdef", 7, 2) + exit (0) +} diff --git a/contrib/awk/test/substr.ok b/contrib/awk/test/substr.ok new file mode 100644 index 0000000..be6889d --- /dev/null +++ b/contrib/awk/test/substr.ok @@ -0,0 +1,10 @@ +A +ab +bc +ab + + +ab + +ef + diff --git a/contrib/awk/test/swaplns.awk b/contrib/awk/test/swaplns.awk new file mode 100644 index 0000000..6bf2240 --- /dev/null +++ b/contrib/awk/test/swaplns.awk @@ -0,0 +1,7 @@ +{ + if ((getline tmp) > 0) { + print tmp + print + } else + print +} diff --git a/contrib/awk/test/swaplns.in b/contrib/awk/test/swaplns.in new file mode 100644 index 0000000..71fb162 --- /dev/null +++ b/contrib/awk/test/swaplns.in @@ -0,0 +1,9 @@ +This directory contains some examples/test-cases for different +features of gawk - mostly not present in an old awk. Some are from +"The GAWK Manual", some are original, and some are mixture of the two. +Read header comments before attempting to use. Have fun and remember +that program which consists only of BEGIN block does not need an input +file. + + --mj + diff --git a/contrib/awk/test/swaplns.ok b/contrib/awk/test/swaplns.ok new file mode 100644 index 0000000..d38b7ca --- /dev/null +++ b/contrib/awk/test/swaplns.ok @@ -0,0 +1,9 @@ +features of gawk - mostly not present in an old awk. Some are from +This directory contains some examples/test-cases for different +Read header comments before attempting to use. Have fun and remember +"The GAWK Manual", some are original, and some are mixture of the two. +file. +that program which consists only of BEGIN block does not need an input + --mj + + diff --git a/contrib/awk/test/tradanch.awk b/contrib/awk/test/tradanch.awk new file mode 100644 index 0000000..0cd45d1 --- /dev/null +++ b/contrib/awk/test/tradanch.awk @@ -0,0 +1,2 @@ +/foo^bar/ +/foo$bar/ diff --git a/contrib/awk/test/tradanch.in b/contrib/awk/test/tradanch.in new file mode 100644 index 0000000..e5c8a09 --- /dev/null +++ b/contrib/awk/test/tradanch.in @@ -0,0 +1,2 @@ +foo^bar +foo$bar diff --git a/contrib/awk/test/tradanch.ok b/contrib/awk/test/tradanch.ok new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/awk/test/tradanch.ok diff --git a/contrib/awk/test/tweakfld.awk b/contrib/awk/test/tweakfld.awk new file mode 100644 index 0000000..e7b538f --- /dev/null +++ b/contrib/awk/test/tweakfld.awk @@ -0,0 +1,296 @@ +# To: bug-gnu-utils@prep.ai.mit.edu +# Cc: arnold@gnu.ai.mit.edu +# Date: Mon, 20 Nov 1995 11:39:29 -0500 +# From: "R. Hank Donnelly" <emory!head-cfa.harvard.edu!donnelly> +# +# Operating system: Linux1.2.13 (Slackware distrib) +# GAWK version: 2.15 (?) +# compiler: GCC (?) +# +# The following enclosed script does not want to fully process the input data +# file. It correctly executes the operations on the first record, and then dies +# on the second one. My true data file is much longer but this is +# representative and it does fail on a file even as short as this one. +# The failure appears to occur in the declared function add2output. Between the +# steps of incrementing NF by one and setting $NF to the passed variable +# the passed variable appears to vanish (i.e. NF does go from 68 to 69 +# and before incrementing it "variable" equals what it should but after +# "variable" has no value at all.) +# +# The scripts have been developed using nawk on a Sun (where they run fine) +# I have tried gawk there but get a different crash which I have not yet traced +# down. Ideally I would like to keep the script the same so that it would run +# on either gawk or nawk (that way I can step back and forth between laptop and +# workstation. +# +# Any ideas why the laptop installation is having problems? +# Hank +# +# +# #!/usr/bin/gawk -f + +BEGIN { + # set a few values + FS = "\t" + OFS = "\t" + pi = atan2(0, -1) +# distance from HRMA to focal plane in mm + fullradius = 10260.54 + + # set locations of parameters on input line + nf_nrg = 1 + nf_order = 3 + nf_item = 4 + nf_suite = 5 + nf_grating = 8 + nf_shutter = 9 + nf_type = 13 + nf_src = 14 + nf_target = 15 + nf_voltage = 16 + nf_flux = 17 + nf_filt1 = 20 + nf_filt1_th = 21 + nf_filt2 = 22 + nf_filt2_th = 23 + nf_bnd = 24 + nf_hrma_polar = 27 + nf_hrma_az = 28 + nf_detector = 30 + nf_acis_read = 32 + nf_acis_proc = 33 + nf_acis_frame = 34 + nf_hxda_aplist = 36 + nf_hxda_y_range = 37 + nf_hxda_z_range = 38 + nf_hxda_y_step = 39 + nf_hxda_z_step = 40 + nf_sim_z = 41 + nf_fam_polar = 43 + nf_fam_az = 44 + nf_fam_dither_type = 45 + nf_mono_init = 51 + nf_mono_range = 52 + nf_mono_step = 53 + nf_defocus = 54 + nf_acis_temp = 55 + nf_tight = 59 + nf_offset_y = 64 + nf_offset_z = 65 + + while( getline < "xrcf_mnemonics.dat" > 0 ) { + mnemonic[$1] = $2 + } + +# "date" | getline date_line +# ADR: use a fixed date so that testing will work + date_line = "Sun Mar 10 23:00:27 EST 1996" + split(date_line, in_date, " ") + out_date = in_date[2] " " in_date[3] ", " in_date[6] +} + +function add2output( variable ) { +#print("hi1") >> "debug" + NF++ +#print("hi2") >> "debug" + $NF = variable +#print("hi3") >> "debug" +} + +function error( ekey, message ) { + print "Error at input line " NR ", anode " ekey >> "errors.cleanup" + print " " message "." >> "errors.cleanup" +} + +function hxda_na() { + $nf_hxda_aplist = $nf_hxda_y_range = $nf_hxda_z_range = "N/A" + $nf_hxda_y_step = $nf_hxda_z_step = "N/A" +} + +function acis_na() { + $nf_acis_read = $nf_acis_proc = $nf_acis_frame = $nf_acis_temp = "N/A" +} + +function hrc_na() { +# print ("hi") >> "debug" +} + +function fpsi_na() { + acis_na() + hrc_na() + $nf_sim_z = $nf_fam_polar = $nf_fam_az = $nf_fam_dither_type = "N/A" +} + +function mono_na() { + $nf_mono_init = $nf_mono_range = $nf_mono_step = "N/A" +} + +# this gives the pitch and yaw of the HRMA and FAM +# positive pitch is facing the source "looking down" +# positive yaw is looking left +# 0 az is north 90 is up +# this also adds in the FAM X,Y,Z positions + +function polaz2yawpitch(polar, az) { + theta = az * pi / 180 + phi = polar * pi / 180 / 60 + + + if( polar == 0 ) { + add2output( 0 ) + add2output( 0 ) + } else { + if(az == 0 || az == 180) + add2output( 0 ) + else + add2output( - polar * sin(theta) ) + + +# x = cos (phi) +# y = sin (phi) * cos (theta) +# add2output( atan2(y,x)*180 / pi * 60 ) + + if(az == 90 || az ==270 ) + add2output( 0 ) + else + add2output( - polar * cos(theta) ) + + } +# x = cos (phi) +# z= sin (phi) * sin (theta) +# add2output( atan2(z,x)*180 / pi * 60 ) + + if(config !~ /HXDA/) { +# negative values of defocus move us farther from the source thus +# increasing radius + radius = fullradius - defocus + +# FAM_x; FAM_y; FAM_z + if((offset_y == 0) && (offset_z == 0)){ + add2output( fullradius - radius * cos (phi) ) + + if (az == 90 || az ==270) + add2output( 0 ) + else + add2output( radius * sin (phi) * cos (theta) ) + + if (az == 0 || az == 180) + add2output( 0 ) + else + add2output( - radius * sin (phi) * sin (theta) ) + } else { +# ******* THIS SEGMENT OF CODE IS NOT MATHEMATICALLY CORRECT FOR **** +# OFF AXIS ANGLES AND IS SUPPLIED AS A WORKAROUND SINCE IT WILL +# PROBABLY ONLY BE USED ON AXIS. + add2output( defocus ) + add2output( offset_y ) + add2output( offset_z ) + } + + } else { + add2output( "N/A" ) + add2output( "N/A" ) + add2output( "N/A" ) + } +} + +# set TIGHT/LOOSE to N/A if it is not one of the two allowed values +function tight_na() { + if( $nf_tight !~ /TIGHT|LOOSE/ ) { + $nf_tight == "N/A" + } +} + +# this entry is used to give certain entries names +{ + type = $nf_type + item = $nf_item + suite = $nf_suite + order = $nf_order + detector = $nf_detector + grating = $nf_grating + offset_y= $nf_offset_y + offset_z= $nf_offset_z + bnd = $nf_bnd + defocus = $nf_defocus +} + +{ + # make configuration parameter + # as well as setting configuration-dependent N/A values + + if( $nf_bnd ~ "SCAN" ) { + # BND is scanning beam + config = "BND" + hxda_na() + fpsi_na() + } else { + if( grating == "NONE" ) { + config = "HRMA" + } else { + if( grating == "HETG" ) { + if( order != "Both" ) { + $nf_shutter = order substr($nf_shutter, \ + index($nf_shutter, ",") ) + } + } else { + order = "N/A" + } + config = "HRMA/" grating + } + + if( detector ~ /ACIS|HRC/ ) { + detsys = detector + nsub = sub("-", ",", detsys) + config = config "/" detsys + hxda_na() + } else { + config = config "/HXDA" + fpsi_na() + if( detector == "HSI" ) { + hxda_na() + } + } + } + + add2output( config ) + + if( $nf_src ~ /EIPS|Penning/ ) mono_na() + + if( $nf_src == "Penning" ) $nf_voltage = "N/A" + + itm = sprintf("%03d", item) + + if(config in mnemonic) { + if( type in mnemonic ) { + ID = mnemonic[config] "-" mnemonic[type] "-" suite "." itm + add2output( ID ) + } else { + error(type, "measurement type not in list") + } + } else { + error(config, "measurement configuration not in list") + } + + # add date to output line + add2output( out_date ) + + # Convert HRMA polar and azimuthal angles to yaw and pitch + polaz2yawpitch($nf_hrma_polar, $nf_hrma_az) + + # set TIGHT/LOOSE to N/A if it is not one of the two allowed values + tight_na() + + # compute number of HXDA apertures + if( config ~ /HXDA/ && $nf_hxda_aplist != "N/A") + add2output( split( $nf_hxda_aplist, dummy, "," ) ) + else + add2output( "N/A" ) + + # make sure the BND value is properly set + if($nf_bnd == "FIXED" && detector ~ /ACIS/) + $nf_bnd =bnd"-SYNC" + else + $nf_bnd = bnd"-FREE" + print +} diff --git a/contrib/awk/test/tweakfld.in b/contrib/awk/test/tweakfld.in new file mode 100644 index 0000000..e27a9dde --- /dev/null +++ b/contrib/awk/test/tweakfld.in @@ -0,0 +1,3 @@ +0.277 N/A N/A 1 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS C-Ka 1.108 0.13484 N/A N/A C8H8 10.32 C8H8 20.64 FIXED 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 44.7175 44.7175 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate +1.486 N/A N/A 2 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS Al-Ka 4.458 0.642119 N/A N/A Al 18.38 Al 36.76 FIXED 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 5.55556 5.55556 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate +4.51 N/A N/A 3 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS Ti-Ka 22.55 3.02894 N/A N/A Ti 40.6 N/A N/A FIXED 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 5.55556 5.55556 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate diff --git a/contrib/awk/test/tweakfld.ok b/contrib/awk/test/tweakfld.ok new file mode 100644 index 0000000..3c4d894 --- /dev/null +++ b/contrib/awk/test/tweakfld.ok @@ -0,0 +1,3 @@ +0.277 N/A N/A 1 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS C-Ka 1.108 0.13484 N/A N/A C8H8 10.32 C8H8 20.64 FIXED-FREE 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 44.7175 44.7175 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate HRMA/HRC,I Mar 10, 1996 0 0 0 0 0 N/A +1.486 N/A N/A 2 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS Al-Ka 4.458 0.642119 N/A N/A Al 18.38 Al 36.76 FIXED-FREE 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 5.55556 5.55556 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate HRMA/HRC,I Mar 10, 1996 0 0 0 0 0 N/A +4.51 N/A N/A 3 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS Ti-Ka 22.55 3.02894 N/A N/A Ti 40.6 N/A N/A FIXED-FREE 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 5.55556 5.55556 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate HRMA/HRC,I Mar 10, 1996 0 0 0 0 0 N/A |