diff options
Diffstat (limited to 'test')
42 files changed, 1901 insertions, 23 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 722d2e6a..8efafaad 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,107 @@ +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. diff --git a/test/Makefile.in b/test/Makefile.in index c8299e51..07d0cbcf 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1,6 +1,6 @@ # Makefile for GNU Awk test suite. # -# Copyright (C) 1988-1996 the Free Software Foundation, Inc. +# Copyright (C) 1988-1997 the Free Software Foundation, Inc. # # This file is part of GAWK, the GNU implementation of the # AWK Programming Language. @@ -36,18 +36,19 @@ basic: msg swaplns messages argarray longwrds \ 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 + back89 tradanch nlfldsep splitvar intest nfldstr nors fnarydel \ + noparms funstack clobber delarprm prdupval -unix-tests: poundbang fflush getlnhd +unix-tests: poundbang fflush getlnhd pipeio1 pipeio2 strftlng pid gawk.extensions: fieldwdth ignrcase posix manyfiles igncfs argtest \ - badargs strftime gensub gnureops + badargs strftime gensub gnureops reint nondec extra: regtest inftest poundbang:: - cp $(AWK) /tmp/gawk && $(srcdir)/poundbang $(srcdir)/poundbang >_`basename $@` - rm -f /tmp/gawk + @cp $(AWK) /tmp/gawk && $(srcdir)/poundbang $(srcdir)/poundbang >_`basename $@` + @rm -f /tmp/gawk $(CMP) $(srcdir)/poundbang.ok _`basename $@` && rm -f _`basename $@` msg:: @@ -62,7 +63,10 @@ swaplns:: 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 && echo IT IS OK THAT THIS TEST FAILED; } + { $(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 \ @@ -207,7 +211,8 @@ nofmtch:: strftime:: : this test could fail on slow machines or on a second boundary, : so if it does, double check the actual results - @date | $(AWK) '{ $$3 = sprintf("%02d", $$3 + 0) ; \ + @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 @@ -358,15 +363,87 @@ tradanch:: $(CMP) $(srcdir)/tradanch.ok _$@ && rm -f _$@ nlfldsep:: - AWK=$(AWK); export AWK; $(srcdir)/nlfldsep.sh > _$@ + @$(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 *~ + rm -fr _* core junk out1 out2 out3 strftime.ok test1 test2 seq *~ distclean: clean rm -f Makefile diff --git a/test/clobber.awk b/test/clobber.awk new file mode 100644 index 00000000..d6635f26 --- /dev/null +++ b/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/test/clobber.ok b/test/clobber.ok new file mode 100644 index 00000000..71057085 --- /dev/null +++ b/test/clobber.ok @@ -0,0 +1 @@ +000801
\ No newline at end of file diff --git a/test/delarprm.awk b/test/delarprm.awk new file mode 100644 index 00000000..d59de31f --- /dev/null +++ b/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/test/delarprm.ok b/test/delarprm.ok new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/delarprm.ok diff --git a/test/fnarydel.awk b/test/fnarydel.awk new file mode 100644 index 00000000..8a1264cb --- /dev/null +++ b/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/test/fnarydel.ok b/test/fnarydel.ok new file mode 100644 index 00000000..7f3e4531 --- /dev/null +++ b/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/test/funstack.awk b/test/funstack.awk new file mode 100644 index 00000000..ab85b45e --- /dev/null +++ b/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/test/funstack.in b/test/funstack.in new file mode 100644 index 00000000..7a29a254 --- /dev/null +++ b/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/test/funstack.ok b/test/funstack.ok new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/funstack.ok diff --git a/test/gsubtest.awk b/test/gsubtest.awk index 31374795..31374795 100644..100755 --- a/test/gsubtest.awk +++ b/test/gsubtest.awk diff --git a/test/intest.awk b/test/intest.awk new file mode 100644 index 00000000..f030d07a --- /dev/null +++ b/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/test/intest.ok b/test/intest.ok new file mode 100644 index 00000000..6e8183b7 --- /dev/null +++ b/test/intest.ok @@ -0,0 +1 @@ +0 1 diff --git a/test/nfldstr.ok b/test/nfldstr.ok new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/nfldstr.ok diff --git a/test/nlfldsep.awk b/test/nlfldsep.awk new file mode 100644 index 00000000..4fac81da --- /dev/null +++ b/test/nlfldsep.awk @@ -0,0 +1,2 @@ +BEGIN { RS = "A" } +{print NF; for (i = 1; i <= NF; i++) print $i ; print ""} diff --git a/test/nlfldsep.in b/test/nlfldsep.in new file mode 100644 index 00000000..7b2317f0 --- /dev/null +++ b/test/nlfldsep.in @@ -0,0 +1,5 @@ +some stuff +more stuffA +junk +stuffA +final diff --git a/test/nlfldsep.sh b/test/nlfldsep.sh deleted file mode 100755 index 0a0a5f53..00000000 --- a/test/nlfldsep.sh +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh -AWK=${AWK-../gawk} - -echo 'some stuff -more stuffA -junk -stuffA -final' | $AWK 'BEGIN { RS = "A" } -{print NF; for (i = 1; i <= NF; i++) print $i ; print ""}' - diff --git a/test/nondec.awk b/test/nondec.awk new file mode 100644 index 00000000..a6801101 --- /dev/null +++ b/test/nondec.awk @@ -0,0 +1 @@ +BEGIN { print 0x81c3e8, 0x744018 } diff --git a/test/nondec.ok b/test/nondec.ok new file mode 100644 index 00000000..560f3d1c --- /dev/null +++ b/test/nondec.ok @@ -0,0 +1 @@ +8504296 7618584 diff --git a/test/noparms.awk b/test/noparms.awk new file mode 100644 index 00000000..2c7ccc76 --- /dev/null +++ b/test/noparms.awk @@ -0,0 +1 @@ +function x(a, b, c , ,) {} diff --git a/test/noparms.ok b/test/noparms.ok new file mode 100644 index 00000000..4c934c38 --- /dev/null +++ b/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/test/nors.in b/test/nors.in new file mode 100644 index 00000000..f90d9eca --- /dev/null +++ b/test/nors.in @@ -0,0 +1 @@ +A B C D E
\ No newline at end of file diff --git a/test/nors.ok b/test/nors.ok new file mode 100644 index 00000000..54d5aab8 --- /dev/null +++ b/test/nors.ok @@ -0,0 +1,2 @@ +E +E diff --git a/test/pid.awk b/test/pid.awk new file mode 100644 index 00000000..9b47d908 --- /dev/null +++ b/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/test/pid.ok b/test/pid.ok new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/pid.ok diff --git a/test/pid.sh b/test/pid.sh new file mode 100755 index 00000000..a19d72ce --- /dev/null +++ b/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/test/pipeio1.awk b/test/pipeio1.awk new file mode 100644 index 00000000..66f50adf --- /dev/null +++ b/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/test/pipeio1.ok b/test/pipeio1.ok new file mode 100644 index 00000000..706b09ef --- /dev/null +++ b/test/pipeio1.ok @@ -0,0 +1,2 @@ +1 2 + 2 diff --git a/test/pipeio2.awk b/test/pipeio2.awk new file mode 100644 index 00000000..6f4f979d --- /dev/null +++ b/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/test/pipeio2.in b/test/pipeio2.in new file mode 100644 index 00000000..2652b0ef --- /dev/null +++ b/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/test/pipeio2.ok b/test/pipeio2.ok new file mode 100644 index 00000000..3f55c05c --- /dev/null +++ b/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/test/prdupval.awk b/test/prdupval.awk new file mode 100644 index 00000000..32c67dce --- /dev/null +++ b/test/prdupval.awk @@ -0,0 +1 @@ +{ print NF, $NF, "abc" $NF } diff --git a/test/prdupval.in b/test/prdupval.in new file mode 100644 index 00000000..5626abf0 --- /dev/null +++ b/test/prdupval.in @@ -0,0 +1 @@ +one diff --git a/test/prdupval.ok b/test/prdupval.ok new file mode 100644 index 00000000..62536160 --- /dev/null +++ b/test/prdupval.ok @@ -0,0 +1 @@ +1 one abcone diff --git a/test/reint.awk b/test/reint.awk new file mode 100644 index 00000000..add0f2ac --- /dev/null +++ b/test/reint.awk @@ -0,0 +1 @@ +{ print match($0, /a{3}/) } diff --git a/test/reint.in b/test/reint.in new file mode 100644 index 00000000..43caa2a7 --- /dev/null +++ b/test/reint.in @@ -0,0 +1 @@ +match this: aaa diff --git a/test/reint.ok b/test/reint.ok new file mode 100644 index 00000000..b1bd38b6 --- /dev/null +++ b/test/reint.ok @@ -0,0 +1 @@ +13 diff --git a/test/strftlng.awk b/test/strftlng.awk new file mode 100644 index 00000000..0ef81950 --- /dev/null +++ b/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/test/strftlng.ok b/test/strftlng.ok new file mode 100644 index 00000000..3008aa2e --- /dev/null +++ b/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/test/substr.awk b/test/substr.awk index f330402c..60163696 100644 --- a/test/substr.awk +++ b/test/substr.awk @@ -1,5 +1,14 @@ BEGIN { - x = "A" - printf("%-39s\n", substr(x,1,39)) - exit (0) + 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/test/substr.ok b/test/substr.ok index 5f9debb1..be6889d1 100644 --- a/test/substr.ok +++ b/test/substr.ok @@ -1 +1,10 @@ A +ab +bc +ab + + +ab + +ef + |