summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYING7
-rw-r--r--ChangeLog280
-rw-r--r--Makefile.in10
-rw-r--r--NEWS43
-rw-r--r--PORTS19
-rw-r--r--README6
-rw-r--r--README_d/README.linux13
-rw-r--r--README_d/README.pc147
-rw-r--r--README_d/README.sgi32
-rw-r--r--README_d/README.solaris37
-rw-r--r--README_d/README.sony11
-rw-r--r--acconfig.h4
-rw-r--r--aclocal.m494
-rw-r--r--alloca.c2
-rw-r--r--amiga/ChangeLog11
-rw-r--r--amiga/gawkmisc.ami124
-rw-r--r--array.c31
-rw-r--r--atari/ChangeLog8
-rw-r--r--awk.h50
-rw-r--r--awk.y91
-rw-r--r--awklib/ChangeLog12
-rw-r--r--awklib/Makefile.in4
-rw-r--r--awktab.c339
-rw-r--r--builtin.c353
-rw-r--r--configh.in4
-rwxr-xr-xconfigure361
-rw-r--r--configure.in18
-rw-r--r--custom.h14
-rw-r--r--dfa.c50
-rw-r--r--doc/ChangeLog23
-rw-r--r--doc/Makefile.in6
-rw-r--r--doc/awkcard.in851
-rw-r--r--doc/colors15
-rw-r--r--doc/gawk.info1495
-rw-r--r--doc/gawk.texi207
-rw-r--r--eval.c336
-rw-r--r--field.c32
-rw-r--r--gawkmisc.c9
-rw-r--r--getopt.c217
-rw-r--r--getopt.h28
-rw-r--r--getopt1.c58
-rw-r--r--io.c126
-rw-r--r--main.c7
-rw-r--r--missing/strerror.c41
-rw-r--r--missing/strftime.c20
-rw-r--r--missing/strtod.c7
-rw-r--r--missing/system.c39
-rw-r--r--msg.c26
-rw-r--r--node.c21
-rw-r--r--patchlevel.h2
-rw-r--r--pc/ChangeLog28
-rw-r--r--pc/Makefile99
-rw-r--r--pc/Makefile.tst116
-rw-r--r--pc/config.h9
-rw-r--r--pc/install.awk2
-rw-r--r--posix/ChangeLog8
-rw-r--r--posix/gawkmisc.c41
-rw-r--r--regex.c296
-rw-r--r--regex.h83
-rw-r--r--stamp-h.in2
-rw-r--r--test/ChangeLog104
-rw-r--r--test/Makefile.in97
-rw-r--r--test/clobber.awk98
-rw-r--r--test/clobber.ok1
-rw-r--r--test/delarprm.awk50
-rw-r--r--test/delarprm.ok0
-rw-r--r--test/fnarydel.awk60
-rw-r--r--test/fnarydel.ok27
-rw-r--r--test/funstack.awk977
-rw-r--r--test/funstack.in206
-rw-r--r--test/funstack.ok0
-rwxr-xr-x[-rw-r--r--]test/gsubtest.awk0
-rw-r--r--test/intest.awk4
-rw-r--r--test/intest.ok1
-rw-r--r--test/nfldstr.ok0
-rw-r--r--test/nlfldsep.awk2
-rw-r--r--test/nlfldsep.in5
-rwxr-xr-xtest/nlfldsep.sh10
-rw-r--r--test/nondec.awk1
-rw-r--r--test/nondec.ok1
-rw-r--r--test/noparms.awk1
-rw-r--r--test/noparms.ok4
-rw-r--r--test/nors.in1
-rw-r--r--test/nors.ok2
-rw-r--r--test/pid.awk44
-rw-r--r--test/pid.ok0
-rwxr-xr-xtest/pid.sh5
-rw-r--r--test/pipeio1.awk31
-rw-r--r--test/pipeio1.ok2
-rw-r--r--test/pipeio2.awk67
-rw-r--r--test/pipeio2.in8
-rw-r--r--test/pipeio2.ok16
-rw-r--r--test/prdupval.awk1
-rw-r--r--test/prdupval.in1
-rw-r--r--test/prdupval.ok1
-rw-r--r--test/reint.awk1
-rw-r--r--test/reint.in1
-rw-r--r--test/reint.ok1
-rw-r--r--test/strftlng.awk11
-rw-r--r--test/strftlng.ok58
-rw-r--r--test/substr.awk15
-rw-r--r--test/substr.ok9
-rw-r--r--vms/ChangeLog67
-rw-r--r--vms/descrip.mms42
-rw-r--r--vms/gawk.hlp125
-rw-r--r--vms/redirect.h7
-rw-r--r--vms/vms_args.c43
-rw-r--r--vms/vms_fwrite.c39
-rw-r--r--vms/vms_gawk.c40
-rw-r--r--vms/vms_misc.c51
-rw-r--r--vms/vms_popen.c41
-rw-r--r--vms/vmsbuild.com2
-rw-r--r--vms/vmstest.com163
113 files changed, 6429 insertions, 2540 deletions
diff --git a/COPYING b/COPYING
index 916d1f0f..60549be5 100644
--- a/COPYING
+++ b/COPYING
@@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -279,7 +279,7 @@ POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
- Appendix: How to Apply These Terms to Your New Programs
+ How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@@ -305,7 +305,8 @@ the "copyright" line and a pointer to where the full notice is found.
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
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
Also add information on how to contact you by electronic and paper mail.
diff --git a/ChangeLog b/ChangeLog
index 53ce6f7d..0fa65154 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,283 @@
+Thu May 15 12:49:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Release 3.0.3: Release tar file made.
+
+Wed May 14 08:06:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * io.c (do_close): add lint warning if closing something that
+ isn't open.
+
+Tue May 13 12:14:12 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * random.c, builtin.c: remove __GLIBC__ tests, since it breaks
+ `make test'. I prefer consistency across platforms.
+ * Makefile.in (gawk): undid April 25 changes and added comment.
+ Putting COMPLAGS in breaks with -g on VMS POSIX.
+
+Sun May 11 14:48:04 1997 Darrell Hankerson <hankedr@mail.auburn.edu>
+
+ * io.c [MSC_VER]: add cases for WIN32.
+ * regex.c [MSC_VER]: add cases for WIN32.
+
+Sun May 11 07:04:01 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * builtin.c (do_print): in the loop that evaluates each expression
+ to be printed, do a dupnode to avoid bizarre output. Thanks to
+ Michal for finding this problem.
+ * awk.y (yylex): fix scanning of hexadecimal constants.
+
+Wed May 7 15:09:25 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * io.c (get_a_record): fix casetable indexing with cast to int.
+ Keeps Michal happy.
+
+Tue May 6 16:40:19 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * eval.c (func_call): removed unneeded variables.
+
+Mon May 5 21:17:37 1997 Pat Rankin <rankin@eql.caltech.edu>
+
+ * missing/strftime.c [case 'v', VMS_EXT]: for VMS date format, two
+ digit day of month should not be zero padded on the 1st through
+ the 9th.
+
+Mon May 5 06:33:47 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * regex.h, regex.c: merge with current GLIBC version.
+
+Mon May 5 06:33:47 1997 Pat Rankin <rankin@eql.caltech.edu>
+
+ * io.c (nextfile): move the check for null return from iop_open
+ in the normal case and add one for the "no args" case.
+
+Fri Apr 25 16:52:33 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * array.c (grow_table): add a bunch more large primes so arrays
+ can get really big. Thanks to christos@deshaw.com.
+ * all files: remove ifdef'ed out code and update copyrights.
+ * Makefile.in (gawk): add $(COMPFLAGS) to command line.
+ * eval.c (flags2str): added case for FIELD.
+
+Thu Apr 24 22:39:23 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * COPYING: changed to current official version from FSF.
+ * regex.c: merge with GLIBC version.
+ * awk.h [_GNU_SOURCE]: bracket definition inside ifdef.
+ (NODE.source_line): move name member out of `x' union and
+ into `nodep'; avoids problems doing diagnostics.
+ (nondec2num): put decl into #if BITOPS || NONDECDATA
+ * posix/gawkmisc.c, missing/system.c, missing/strtod.c,
+ missing/strerror.c: move to generic GPL statement at top.
+ * builtin.c (nondec2num): put into #if BITOPS || NONDECDATA
+
+Wed Apr 23 22:14:14 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * dfa.c: misc changes for really pedantic SGI compilers.
+ * builtin.c: bracket defs of random() etc for GLIBC.
+ * random.c: bracket whole file for GLIBC.
+ * configure.in: extra goop for GETPGRP test for VMS POSIX.
+ * custom.h [VMS]: remove hard definition of GETPGRP_VOID.
+
+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 21:35:45 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ NEW UNDOCUMENTED FEATURE. USE THE SOURCE LUKE!
+ * acconfig.h [NONDECDATA]: new macro.
+ * awk.h: add decl of do_strtonum.
+ * awk.y (tokentab): add entry for strtonum function.
+ * builtin.c (do_strtonum): new function.
+ * configure.in (non-decimal-data): new --enable-* option.
+ * node.c (r_force_number): change to allow non-decimal data inside
+ ifdef NONDECDATA.
+
+Tue Apr 15 06:32:50 1997 Pat Rankin <rankin@eql.caltech.edu>
+
+ * missing/strftime.c (malloc, realloc, getenv, strchr): only
+ declare these when STDC_HEADERS is not defined.
+ <stdlib.h, string.h>: include these when STDC_HEADERS is defined.
+ * awk.h (freenode, tree_eval, m_tree_eval): reorganize definitions.
+ * alloca.c (malloc): if malloc is already defined as a macro,
+ presumeably by config.h, don't define or declare it.
+
+Wed Apr 9 22:45:27 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Makefile.in [COMPFLAGS]: per suggestion from Karl Berry, put
+ $(CFLAGS) last.
+
+Tue Apr 8 23:54:46 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * eval.c (interpret): For Node_K_break and Node_K_continue, if
+ treating them like `next', also check the function call stack
+ and pop it if necessary.
+
+Mon Apr 7 18:22:37 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * awk.h: Add decls of new routines do_compl() and set_loc().
+ * awk.y (tokentab): add entry for "compl" function.
+ * builtin.c (do_compl): new functionto do ones complement.
+ (do_substr): rationalized yet again, now notices negative start
+ and length parameters.
+ * eval.c (push_args): fix if call_list gets realloc'ed in the
+ middle of things. Avoids crash for deeply nested function calls.
+ * main.c (catch_sig): add call to set_loc().
+ * msg.c (set_loc, srcfile, srcline): new function and private
+ variables to help out in tracing down source of error messages.
+
+Fri Mar 28 08:42:27 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * io.c (iop_alloc, iop_close): Undo changes of Feb 11, apparently
+ other cleanups in io.c made mmap stuff start working again.
+ BAH! It's a mess, the test suite still fails. I'm leaving the
+ mmap stuff undefined for now. It'll probably get ripped out in 3.1.
+
+Thu Mar 27 08:48:57 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * custom.h [_SEQUENT_]: undef HAVE_MMAP.
+
+Wed Mar 26 09:08:16 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * io.c (iop_alloc): fix definition to make it static.
+
+Mon Mar 24 23:09:07 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * field.c (init_fields, etc..): more clean up use of Null_field
+ and the various flags.
+ * node.c (unref): if a field, free the node itself. Fixes
+ memory leak problems.
+
+Sun Mar 23 22:51:09 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * awk.h [FIELD]: new flag for node->flags field.
+ * builtin.c (sub_common): if FIELD is set, dup the string.
+ * field.c (init_fields): set up a new Null_field global var.
+ (init_fields, set_field, set_record) use the FIELD flag.
+ (getfield): use Null_field instead of private variable.
+ * io.c (wait_any): comment out calls to pclose and iop_close,
+ caused weird race conditions. See test/pipeio1.awk. Thanks
+ to Darrell Hankerson for tracing this one down.
+
+Tue Mar 18 20:57:18 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * dfa.c (inboth): free templist; plugs memory leak.
+ * field.c (init_fields, grow_fields_arr, set_field, rebuild_record,
+ set_record): remove PERM flag from entries in fields_arr[]. Fixes
+ nasty memory leak.
+
+Tue Mar 18 06:33:00 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * awk.y (dup_parms): robustified against parameter errors.
+
+Sun Mar 16 21:31:40 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ NEW UNDOCUMENTED FEATURE. USE THE SOURCE LUKE!
+ * acconfig.h [BITOPS]: new macro. If set, do octal & hex and bit ops.
+ * awk.h [isnondecimal]: new macro, and decl of new functions.
+ * awk.y (yylex): add recognition of octal and hex constants.
+ * builtin.c (do_and, do_or, do_xor, do_lshift, do_rshift): new
+ functions that do bit operations.
+ (nondec2awknum): new function to convert octal or hex to double.
+ * configure.in: Add AC_ARG_ENABLE for bit operations.
+ * node.c (r_force_number): add octal and hex conversion.
+
+Sun Mar 16 21:28:56 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * awk.h [IOP_NOFREE_OBJ]: new macro.
+ * io.c (iop_open, iop_alloc): add new third parameter, which is
+ either NULL, meaning allocate a new IOP, or the address of one
+ already allocated. Have a static one in the `nextfile'
+ routine, and use the IOP_NOFREE_OBJ flag for it. All of this
+ keeps us from reading freed memory. The `swaplns' test fails
+ otherwise.
+ (iop_close): if IOP_NOFREE_OBJ is set, don't free the IOBUF.
+
+Wed Feb 26 06:21:02 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * eval.c (in_function, pop_fcall_stack, pop_fcall, push_args):
+ new functions. These manage "frames" of awk function call arguments.
+ The problem is that a `next' or a `nextfile' from a function
+ leaks memory. These changes allow us to free up that memory.
+ (interpret): for Node_K_next and Node_K_nextfile, check if in
+ a function call and free all function call frames.
+
+Fri Feb 21 06:23:19 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Misc changes from Katsuyuki Okabe <HGC02147@niftyserve.or.jp>:
+ * builtin.c (do_substr): change a %d to %ld in warning message.
+ * eval.c (op_assign): fix format string for warning about %=.
+
+Wed Feb 19 23:29:02 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * main.c (main): add do_intervals to condition that causes
+ resetup() to be called again. Makes the --re-interval option
+ actually work. What a concept.
+
+Fri Feb 14 09:47:31 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * io.c [#include "awk.h"]: undef HAVE_MMAP to just use thoe old code.
+ Something is causing a file descriptor leak, and this is getting to
+ be just too much hair. I reserve the right to rip out the mmap
+ code entirely at a future date.
+
+Tue Feb 11 06:28:29 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * io.c (iop_alloc): for an mmap'ed file, close the file descriptor,
+ and then touch each page to get a private copy. Fixes nasty case
+ of truncating our input file.
+ (iop_close): don't call close on mmap'ed file.
+
+Wed Feb 5 17:59:04 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * eval.c (interpret): For Node_K_delete, just call do_delete; let
+ it handle the case of `delete array'.
+ * array.c (do_delete): Changed to handle case of `delete array',
+ and made smarter if the array is actually an uninitialized
+ parameter.
+
+Sun Jan 26 22:58:29 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * getopt.h, getopt.c, getopt1.c: replaced with new versions from
+ GLIBC 2.
+
+Sun Jan 19 23:37:03 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * eval.c (nodetype2str): not static, for debugging.
+ (flags2str) new function: for debugging.
+ * field.c (get_field): add new var that is like Nnull_string but
+ does not have numeric attributes, so that new fields are strings.
+ (set_record): turn off PERM flag before unrefing fields and field 0.
+ * array.c (in_array): always evaluate subscript, could have
+ side effects.
+ * builtin.c (do_strftime): way increase size of buffer to make sure
+ we don't have overflow problem. Keeps Paul Eggert happy.
+ * custom.h [__amigaos__]: define fork to vfork. From Fred Fish.
+ * dfa.c: move include of config.h to top, for RSXNT. From Kai
+ Uwe Rommel.
+ (ISALPHA, etc): change from Jacob Engelbrecht (jaen@novo.dk)
+ to better handle non-ascii environments.
+ * gawkmisc.c: remove amigados case, posix should now work fine.
+ * amiga/*: nuked per previous entry.
+ * Makefile.in: removed all references to amiga
+ * io.c [HAVE_SYS_PARAM_H]: Add #undef RE_DUP_MAX to avoid
+ spurious conflict with regex.h.
+ (flush_io): remove amiga ifdefs, not needed anymore.
+ (spec_setup): set getrec field for special files. Fix from
+ Mark Gray (markgray@pdt.net).
+ * node.c (more_nodes): fix to get the last entry in the array.
+
+Wed Jan 8 17:42:37 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * io.c (mmap_get_record): Fix return value if file ends without
+ record separator.
+
+Fri Jan 3 19:57:16 1997 Pat Rankin <rankin@eql.caltech.edu>
+
+ * awk.y (get_src_buf): Test for an empty source file by detecting
+ an initial read of 0 bytes rather than by relying on info from
+ stat().
+
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/Makefile.in b/Makefile.in
index 40ccf8e7..024ec7d3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,6 +1,6 @@
# Makefile for GNU Awk.
#
-# Copyright (C) 1986, 1988-1996 the Free Software Foundation, Inc.
+# Copyright (C) 1986, 1988-1997 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
@@ -58,7 +58,7 @@ DEFPATH = ".:$(datadir)"
SHELL = /bin/sh
CFLAGS = @CFLAGS@
-COMPFLAGS = $(CFLAGS) -DGAWK -I. -I$(srcdir) @DEFS@
+COMPFLAGS = -DGAWK -I. -I$(srcdir) @DEFS@ $(CFLAGS)
# object files
AWKOBJS = array.o builtin.o eval.o field.o gawkmisc.o io.o main.o \
@@ -97,7 +97,7 @@ MISC = NEWS COPYING FUTURES Makefile.in PROBLEMS README PORTS POSIX.STD \
ChangeLog INSTALL LIMITATIONS install-sh mkinstalldirs aclocal.m4 \
stamp-h.in
-OTHERS= amiga doc pc atari vms README_d posix awklib
+OTHERS= doc pc atari vms README_d posix awklib
ALLDOC= doc/gawk.dvi $(TEXFILES) doc/gawk.info*
@@ -136,6 +136,8 @@ Makefile: $(MAKEFILEIN) config.status
config.status: configure
$(SHELL) ./config.status --recheck
+# Note: if you need something at both compile time and link time, like -pg,
+# you will have to edit the Makefile manually to set LDFLAGS.
gawk: $(ALLOBJS) $(LIBOBJS) $(REOBJS)
$(CC) -o gawk $(LDFLAGS) $(ALLOBJS) $(LIBOBJS) $(REOBJS) $(LIBS)
@@ -145,7 +147,7 @@ $(LIBOBJS): config.h custom.h
# SunOS make's (at least) VPATH doesn't do subdirectories...
# Solaris make doesn't allow $< in the actual rule
-gawkmisc.o: $(srcdir)/amiga/gawkmisc.ami $(srcdir)/atari/gawkmisc.atr \
+gawkmisc.o: $(srcdir)/atari/gawkmisc.atr \
$(srcdir)/pc/gawkmisc.pc $(srcdir)/posix/gawkmisc.c \
$(srcdir)/vms/gawkmisc.vms
$(CC) -c $(COMPFLAGS) -DDEFPATH='$(DEFPATH)' $(srcdir)/gawkmisc.c
diff --git a/NEWS b/NEWS
index f0a2819d..2a3e7fec 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,44 @@
+Changes from 3.0.2 to 3.0.3
+---------------------------
+
+The horrendous per-record memory leak introduced in 3.0.1 is gone, finally.
+
+The `amiga' directory is now gone; Amiga support is now entirely handled
+by the POSIX support.
+
+Win32 support has been added in the `pc' directory. See `README_d/README.pc'
+for more info.
+
+The mmap changes are disabled in io.c, and will be removed entirely
+in the next big release. They were an interesting experiment that just
+really didn't work in practice.
+
+A minor memory leak that occurred when using `next' from within a
+function has also been fixed.
+
+Problems with I/O from sub-processes via a pipe are now gone.
+
+Using "/dev/pid" and the other special /dev files no longer causes a core dump.
+
+The files regex.h, regex.c, getopt.h, getopt.c, and getopt1.c have been
+merged with the versions in GNU libc. Thanks to Ulrich Drepper for his help.
+
+Some new undocumented features have been added. Use the source, Luke!
+It is not clear yet whether these will ever be fully supported.
+
+Array performance should be much better for very very large arrays. "Virtual
+memory required, real memory helpful."
+
+builtin.c:do_substr rationalized, again.
+
+The --re-interval option now works as advertised.
+
+The license text on some of the missing/* files is now generic.
+
+Lots more new test cases.
+
+Lots of other small bugs fixed, see the ChangeLog files for details.
+
Changes from 3.0.1 to 3.0.2
---------------------------
@@ -1550,7 +1591,7 @@ Thu Jan 4 14:19:30 1990 Jim Kingdon (kingdon at albert)
Sun Dec 24 16:16:05 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu)
- * * Makefile: Add (commented out) default defines for Sony News.
+ * Makefile: Add (commented out) default defines for Sony News.
* awk.h: Move declaration of vprintf so it will compile when
-DVPRINTF_MISSING is defined.
diff --git a/PORTS b/PORTS
index 596f1fda..c6cbb839 100644
--- a/PORTS
+++ b/PORTS
@@ -5,27 +5,32 @@ Using cc:
Dec Alpha OSF 4.0
HP9000/755 HP-UX 9.01
IBM PowerPC AIX 4.1.4.0
+ SCO Unix (OpenServer 5)
SGI IRIX 4.0.5
SGI IRIX 5.3
+ SGI IRIX 6.1
+ SGI IRIX 6.2
SunOS 4.1.3
SunOS 5.5
+ IBM SP2 AIX 4.1
Other systems:
- DEC Alpha OSF/1 3.2
DEC Alpha Linux/AXP
+ DEC Alpha OSF/1 3.2
DECstation 5000 ULTRIX 4.3
HP 9000/735 HP-UX 10.01
IBM RS/6000 AIX 3.2
IBM SP2 AIX 4.1
+ Intel x86 DOS (compiler: djgpp v2, emx+gcc,
+ and MSC 6.00A, 7, and 8)
+ Intel x86 Linux 2.0.27
+ Intel x86 Linux 2.1.36
+ Intel x86 OS+2 (compiler: emx+gcc)
NeXT Turbostation Mach 3.3
SGI Indigo/2 IRIX 5.3
+ SGI O2 IRIX 6.2
SGI PowerChallenge IRIX 6.1
+ Sun SPARC Linux 2.0.22
Sun SPARC Solaris 2.5
Sun SPARC Solaris 2.5.1
Sun SPARC SunOS 4.1.3
- Sun SPARC Linux 2.0.22
- Intel x86 Linux 2.1.10
- Intel x86 DOS (compiler: djgpp v2, emx+gcc,
- and MSC 6.00A, 7, and 8)
- Intel x86 OS+2 (compiler: emx+gcc)
-
diff --git a/README b/README
index 30c7839f..890b16db 100644
--- a/README
+++ b/README
@@ -1,10 +1,10 @@
README:
-This is GNU Awk 3.0.2. It should be upwardly compatible with the Bell
+This is GNU Awk 3.0.3. It should be upwardly compatible with the Bell
Labs research version of awk. It is almost completely compliant with
-the 1993 POSIX 1003.2 standard for awk.
+the 1993 POSIX 1003.2 standard for awk. (See the note below about POSIX.)
-Patches 1 and 2 just fix bugs -- see NEWS and ChangeLog for details.
+Patches 1 through 3 just fix bugs -- see NEWS and ChangeLog for details.
See the file INSTALL for installation instructions.
diff --git a/README_d/README.linux b/README_d/README.linux
new file mode 100644
index 00000000..85973a2f
--- /dev/null
+++ b/README_d/README.linux
@@ -0,0 +1,13 @@
+Thu Apr 17 14:41:17 EDT 1997
+
+Some Linux systems, notably RedHat systems through RedHat 4.1, have the
+symbolic links for /dev/stdin and /dev/stdout messed up. Specifically,
+/dev/stdin is linked to ../proc/self/fd/1 and /dev/stdout to
+../proc/self/fd/0. This is backwards. This causes strange behavior
+when using those files from within gawk.
+
+Removing and redoing the symlinks fixes the problem. It is fixed in
+post-4.1 RedHat Linux.
+
+Arnold Robbins
+arnold@gnu.ai.mit.edu
diff --git a/README_d/README.pc b/README_d/README.pc
index 07ea334f..ddf2eb4b 100644
--- a/README_d/README.pc
+++ b/README_d/README.pc
@@ -1,8 +1,10 @@
This is the README for GNU awk 3.0 under OS/2 and DOS.
- Gawk has been compiled and tested under OS/2 and DOS using the GNU
-development tools from DJ Delorie (DJGPP, DOS-only) and Eberhard Mattes
-(EMX, DOS and OS/2). Microsoft C can be used to build 16-bit versions
+ Gawk has been compiled and tested under OS/2, DOS, and Win32 using
+the GNU development tools from DJ Delorie (DJGPP; DOS with special support
+for long filenames under Win95) and Eberhard Mattes (EMX; OS/2, DOS, and
+Win32 with rsxnt). Microsoft Visual C/C++ can be used to build a Win32
+version for Windows 95/NT, and MSC can be used to build 16-bit versions
for DOS and OS/2.
@@ -74,7 +76,7 @@ Kai Uwe Rommel <rommel@leo.org> maintains a (mostly OS/2) collection at
http://www.leo.org/archiv/os2 or ftp://ftp.leo.org
-It contains emx-compiled (32bit) versions of gawk for OS/2 and DOS,
+It contains emx-compiled (32bit) versions of gawk for OS/2, DOS, and Win32,
along with many OS/2 utilities.
The djgpp collection at
@@ -86,13 +88,73 @@ contains a djgpp-compiled (32bit) version of gawk, along with many
djgpp-compiled utilities.
-2. An sh-like shell may be useful for awk programming (and is essential
+2. The following table illustrates some of the differences among the various
+compiled versions of gawk. For example, the djgpp version runs on all the
+systems, but with differing capabilities: it supports long filenames under
+Win-95 but not under NT, and it runs as a DPMI application under OS/2 (which
+translates into "works in the DOS-box under OS/2, but not as a true OS/2
+application").
+
+ DOS Win/WfW Win95 NT OS/2
+ -------------------------------------------------------
+ djgpp | DPMI DPMI DPMI DPMI,NoLFN DPMI
+ emx(1) | N N N N OS2
+ emxbnd(2) | VCPI,DPMI DPMI DPMI,NoLFN DPMI,NoLFN DPMI,OS2
+ emxnt(3) | N N Win32 Win32 N
+ msc | 16 16 16,NoLFN 16,NoLFN 16,DOS
+ msc6bnd | 16 16 16,NoLFN 16,NoLFN 16,DOS,OS2
+ msc6os2 | N N N N 16,OS2
+ vcWin32 | N N Win32 Win32 N
+
+ (1) Requires emxrt.
+
+ (2) May run as a DPMI app in plain DOS and in a DOS-shell under OS/2
+ or Windows, and as a true OS/2 application under OS/2. DPMI
+ requires rsxnt, and VCPI or use as an OS/2 app requires emxrt.
+
+ (3) Requires rsxnt.
+
+ 16 16bit; limited capacity, especially under DOS.
+
+ DOS Runs as a DOS application.
+
+ DPMI Dos Protected Mode Interface; program runs as a DOS application.
+ Under plain DOS, a DPMI server (such as csdpmi from the djgpp
+ archives) is required. See also VCPI.
+
+ emxrt The emx runtime, available from LEO.
+
+ N Not supported.
+
+ NoLFN No long filename support.
+
+ OS2 Runs as an OS/2 application.
+
+ rsxnt Runtimes for use with DPMI or Win32.
+
+ VCPI Virtual Control Program Interface; program runs as a DOS app.
+ Memory managers (such as emm386) may need adjustment. VCPI cannot
+ be used under OS/2, Win/WfW, Win-95, or NT. See also DPMI.
+
+ Win32 Uses/supports Win32 features (such as long filenames).
+
+Reportedly, NTEmacs (another Win32 program) can run programs such as
+Win32-gawk asynchronously. Currently, NTEmacs supports async subprocesses
+only if the child is a Win32 app. Similarly, like native OS/2 versions are
+a plus under OS/2 even for command-line programs, native Win32 versions are
+nice to have under NT and Win95.
+
+Users interested in Win32 applications may also wish to examine the Cygnus
+GNU-Win32 Project at http://www.cygnus.com.
+
+
+3. An sh-like shell may be useful for awk programming (and is essential
for running "make test"). Stewartson's sh (OS/2 and DOS) is a good
choice, and may be found in GNUish.
Stewartson's shell uses a configuration file (see "Command Line Building"
in the sh manual page), and it may be necessary to edit the entry for
-gawk. The following entries are suggested:
+gawk. The following entries are suggested:
-- $(EXTENDED_LINE) -- -- Comment only, not part of file --
gawk = unix ignoretype # emxbnd
@@ -106,10 +168,9 @@ in the above, due to the way djgpp handles @-include files. Entries
for other other utilities (such as sed and wc) may need to be edited
in order to match your specific collection of programs.
-As of Fall 1996, Daisuke Aoyama <jack@st.rim.or.jp> has a test version
-of bash (compiled with djgpp). This version worked flawlessly in
-tests with djgpp gawk and make. It was added to the djgpp collection
-in Nov-96, and may also be obtained via
+Daisuke Aoyama <jack@st.rim.or.jp> has ported Bash 1.14.7 to djgpp.
+This version worked flawlessly in tests with djgpp gawk and make. It
+is now part of the djgpp collection and also from
http://www.st.rim.or.jp/~jack/alpha/
http://www.neongenesis.com/~jack/djgpp-work/alpha/
@@ -132,7 +193,7 @@ for emx-compiled programs (although djgpp-bash almost works with
emx on DOS). GNU make is recommended if using djgpp-bash.
-3. GNU make is available at LEO for OS/2 and in the djgpp collection
+4. GNU make is available at LEO for OS/2 and in the djgpp collection
for DOS.
dmake is by Dennis Vadura (dvadura@watdragon.uwaterloo.ca), CS
@@ -147,7 +208,7 @@ available at
ftp://ftp.simtel.net/simtelnet/msdos/c/ndmake45.zip
-4. Stewartson's shell contains sources for a setargv-replacement
+5. Stewartson's shell contains sources for a setargv-replacement
for MSC, which can add enhanced command-line processing capabilities
to gawk. See the makefile. Note that there is a fatal bug in
stdargv.c, triggered in the case of no closing quote. The following
@@ -168,17 +229,14 @@ character on the command-line.
Known bugs
----------
-1. DJGPP version 1 does not properly support signals. At the time of
-this writing, Version 2 of djgpp was in beta, and promises better
-signal support. However, as of 2.00.beta2, known bugs remain.
-
-2. DJGPP version 1 fails the fsbs test due to its broken handling of
-the line in test/Makefile. Fixed in the version 2 betas.
-
-3. DJGPP 2.00.beta2 popen() fails on commands with pipes; edit the
-makefile and use the popen in the pc directory. Fixed in beta3.
+1. DJGPP version 1 has known problems with signals, and in the way it
+handles command-lines. Older versions of this file contain notes on
+other bugs, and on a few bugs uncovered in the v2 betas. Testing of
+gawk with DJGPP v1 ended with gawk-3.0. djgpp-2.01 and djgpp ports of
+GNU make 3.75 or later are strongly preferred, in part due to enhanced
+support for sh-like shells.
-4. emx does not support DST. On 2-Jan-96, Mattes writes:
+2. emx does not support DST. On 2-Jan-96, Mattes writes:
Quotation from ISO 9899-1990:
@@ -205,31 +263,42 @@ information in a database (of sorts). In Solaris, for instance, it can be
found in /usr/share/zoneinfo/*. The setting of the TZ environment variable
(eg. TZ=US/Pacific) is then used to lookup the specifics for that locale.
-5. The 16-bit DOS version can exhaust memory on scripts such as Henry
-Spencer's "awf". Use GNU C versions if possible.
+3. The 16-bit DOS version can exhaust memory on scripts such as Henry
+Spencer's "awf". Use GNU C versions if possible.
-6. builtin.c of gawk-3.0.1 triggers a bug in MSC 6.00A. The makefile
+4. builtin.c of gawk-3.0.[1-3] triggers a bug in MSC 6.00A. The makefile
works around the bug by compiling builtin.c without optimizations (-Od).
In limited testing, it appears that inserting some dummy code in
builtin.c can provide a better solution than disabling optimizations.
-7. The support in djgpp for sh-like shells (as is needed in
-test/getlnhd.awk) was in development as of Oct-96. Pre-release
-versions of the library worked in our tests. Similarly, the makefiles
-depend on features of djgpp-make which were available only in
-pre-release versions.
+5. There are problems with system() when using the rsx package with emx
+programs (rsx is used in DPMI environments such as MS-Win). The djgpp
+versions are preferred in this case.
+
+6. In contrast to getpid() on UNIX, the getpid() in Microsoft C/C++ 1.52
+(AKA 8.0) sometimes returns negative numbers. The DOS Gawk developers felt
+that it was best to use Microsoft's built-in function; but at the same time,
+we are placing this warning here, because this behavior will undoubtably be
+surprising to many.
+
+7. MSC 6 fails the strftlng test. The funstack test exhausts memory
+on the 16bit DOS versions.
+
+
+Gawk-3.0.3 thanks
+-----------------
The DOS maintainers wish to express their thanks to Eli Zaretskii
<eliz@is.elta.co.il> for his work and for the many conversations
-concerning gawk-3.0.1, make, and djgpp.
+concerning gawk-3.0, make, and djgpp. His FAQ for djgpp is essential
+reading, and he was always willing to answer our questions (even when
+we didn't read the relevant portions of the FAQ :).
-8. There are problems with system() when using the rsx package with emx
-programs (rsx is used in DPMI environments such as MS-Win). The djgpp
-versions are preferred in this case.
+We are indebted to Juan Grigera <j-grigera@usa.net> for the
+Visual C++ target, and for additional help on changes for Win32.
----
-
If you have any problems with the DOS or OS/2 versions of Gawk,
please send bug reports (along with the version and compiler used) to
@@ -237,3 +306,11 @@ please send bug reports (along with the version and compiler used) to
or
Kai Uwe Rommel, rommel@ars.de (OS/2 or bound versions)
Darrel Hankerson, hankedr@mail.auburn.edu
+
+Support for Win32 started in gawk-3.0.3. Reports concerning the emx
+version using rsxnt (emxnt) should go to Kai Uwe Rommel. Reports on
+the Visual C++ version (vcWin32) may be sent to
+
+ Juan Grigera, j-grigera@usa.net (Visual C++ version)
+
+with a copy to Scott Deifik.
diff --git a/README_d/README.sgi b/README_d/README.sgi
index 49a5679c..69b11cd5 100644
--- a/README_d/README.sgi
+++ b/README_d/README.sgi
@@ -1,18 +1,20 @@
-Tue Sep 10 08:53:46 EDT 1996
+From emory!hawkwind.utcs.toronto.edu!cks Mon Dec 30 20:12:35 1996
+Return-Path: <emory!hawkwind.utcs.toronto.edu!cks>
+To: arnold@skeeve.atl.ga.us (Arnold D. Robbins)
+Subject: Re: gawk regex bug
+In-Reply-To: Your message of Tue, 30 Jul 1996 21:45:00 -0400.
+ <m0ulQME-000GWyC@skeeve.atl.ga.us>
+Date: Mon, 30 Dec 1996 19:37:30 -0500
+From: Chris Siebenmann <emory!hawkwind.utcs.toronto.edu!cks>
+Message-Id: <96Dec30.193738est.24603@hawkwind.utcs.utoronto.ca>
+Status: OR
+Content-Length: 196
+X-Lines: 5
+X-Display-Position: 2
-Gawk 3.0.x is known to be broken on 64-bit SGI machines running IRIX 6.2.
+ The latest in my 'gawk on SGIs' stuff: with the newest SGI compilers
+(MIPSPro 7.1, just released) gawk 3.0 compiles and passes the selftests
+even at the highest (-O3) optimization level.
-1) It needs to be compiled with the native cc, not gcc.
+ - cks
-2) Even if compiled with the native cc, the -32 option must be used.
- If not, the gensub and gnu regex tests fail.
-
-I don't have access to an IRIX 6.x machine, so I am not able to track
-down the problem. If any kind soul is able to run gawk from a debugger
-and figure out what the problem(s) are, and would let me know (and supply
-patches!), I'd greatly appreciate it.
-
-Thanks!
-
-Arnold Robbins
-arnold@gnu.ai.mit.edu
diff --git a/README_d/README.solaris b/README_d/README.solaris
new file mode 100644
index 00000000..e83d57e5
--- /dev/null
+++ b/README_d/README.solaris
@@ -0,0 +1,37 @@
+From dragon!lehman.com!carson Fri Feb 7 01:12:09 1997
+Return-Path: <dragon!lehman.com!carson>
+From: carson@lehman.com
+Date: Fri, 7 Feb 1997 01:05:58 -0500
+Message-ID: <199702070605.BAA09185@dragon.lehman.com>
+To: arnold@gnu.ai.mit.edu
+Subject: Solaris 2.5.1 x86 bug in gawk-3.0.2
+Reply-To: carson@lehman.com
+Status: R
+Content-Length: 630
+X-Lines: 23
+X-Display-Position: 0
+
+
+awktab.c has the following bogus logic:
+
+#ifndef alloca
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#else /* not GNU C. */
+#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
+#include <alloca.h>
+#else /* not sparc */
+
+Solaris x86 obviously dosn't define sparc or __sparc.
+
+What you _meant_ to say was:
+
+if (defined(__sun) && defined(__SVR4))
+
+(which identifies Solaris 2.x under both Sun's cc and gcc)
+
+--
+Carson Gaspar -- carson@cs.columbia.edu carson@lehman.com
+http://www.cs.columbia.edu/~carson/home.html
+<This is the boring business .sig - no outre sayings here>
+
diff --git a/README_d/README.sony b/README_d/README.sony
new file mode 100644
index 00000000..32af9aa5
--- /dev/null
+++ b/README_d/README.sony
@@ -0,0 +1,11 @@
+Sun Jan 19 23:13:50 EST 1997
+
+> Machine: SONY NWS-5000 (MIPS r4000)
+> OS : NEWS-OS 4.2.1 (4.3BSD compatible)
+> This OS doesn't have `uname'
+> Tools : gcc-2.7.2.1, bison-1.25, cmp-2.7, bash-2.0
+
+This system has the same problem with the test/tweakfld case that Ultrix MIPS
+has. See the README.ultrix file for details.
+
+Arnold Robbins
diff --git a/acconfig.h b/acconfig.h
index 40b484ce..05f3c613 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1995, 96 the Free Software Foundation, Inc.
+ * Copyright (C) 1995-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -28,6 +28,8 @@
#undef HAVE_STRINGIZE /* can use ANSI # operator in cpp */
#undef REGEX_MALLOC /* use malloc instead of alloca in regex.c */
#undef SPRINTF_RET /* return type of sprintf */
+#undef BITOPS /* bitwise ops (undocumented feature) */
+#undef NONDECDATA /* non-decimal input data (undocumented feature) */
@BOTTOM@
diff --git a/aclocal.m4 b/aclocal.m4
index 0184e83f..ae92a0c1 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -31,53 +31,6 @@ AC_EGREP_CPP([#teststring],[
#define x(y) #y
char *s = x(teststring);
-
-
-dnl To: Keith Bostic <bostic@bsdi.com>
-dnl Cc: bug-gnu-utils@prep.ai.mit.edu
-dnl Subject: Re: autoconf-2.7
-dnl From: Jim Meyering <meyering@asic.sc.ti.com>
-dnl Date: 15 Oct 1996 11:57:12 -0500
-dnl
-dnl | The assumption that, if a simple program can't be compiled and
-dnl | run, that the user is doing cross-compilation, is causing me
-dnl | serious grief. The problem is that Solaris ships a cc command
-dnl | that just fails, if you haven't bought their compiler.
-dnl |
-dnl | What the user is eventually told is that it's not possible to
-dnl | run test programs when cross-compiling, which doesn't point them
-dnl | at the right problem.
-dnl |
-dnl | Maybe it's just me, but I don't know too many normal users that
-dnl | do cross-compilation. I'd like to see a more stringent test to
-dnl | decide if we're doing cross-compilation. (Maybe with a message
-dnl | to use gcc!?!? ;-})
-dnl
-dnl Now I put this line in configure.in files:
-dnl
-dnl AM_SANITY_CHECK_CC
-dnl
-dnl Here's the macro that goes in aclocal.m4 -- it should be in the
-dnl next official release of automake.
-
-AC_DEFUN(AM_SANITY_CHECK_CC,
-[dnl Derived from macros from Bruno Haible and from Cygnus.
-AC_MSG_CHECKING([whether the compiler ($CC $CFLAGS $LDFLAGS) actually works])
-AC_LANG_SAVE
- AC_LANG_C
- AC_TRY_RUN([main() { exit(0); }],
- am_cv_prog_cc_works=yes, am_cv_prog_cc_works=no,
- dnl When crosscompiling, just try linking.
- AC_TRY_LINK([], [], am_cv_prog_cc_works=yes,
- am_cv_prog_cc_works=no))
-AC_LANG_RESTORE
-case "$am_cv_prog_cc_works" in
- *no) AC_MSG_ERROR([Installation or configuration problem: C compiler cannot cr
-eate executables.]) ;;
- *yes) ;;
-esac
-AC_MSG_RESULT(yes)
-])dnl
], gawk_cv_c_stringize=no, gawk_cv_c_stringize=yes))
if test "${gawk_cv_c_stringize}" = yes
then
@@ -85,50 +38,3 @@ then
fi
AC_MSG_RESULT([${gawk_cv_c_stringize}])
])dnl
-
-
-dnl To: Keith Bostic <bostic@bsdi.com>
-dnl Cc: bug-gnu-utils@prep.ai.mit.edu
-dnl Subject: Re: autoconf-2.7
-dnl From: Jim Meyering <meyering@asic.sc.ti.com>
-dnl Date: 15 Oct 1996 11:57:12 -0500
-dnl
-dnl | The assumption that, if a simple program can't be compiled and
-dnl | run, that the user is doing cross-compilation, is causing me
-dnl | serious grief. The problem is that Solaris ships a cc command
-dnl | that just fails, if you haven't bought their compiler.
-dnl |
-dnl | What the user is eventually told is that it's not possible to
-dnl | run test programs when cross-compiling, which doesn't point them
-dnl | at the right problem.
-dnl |
-dnl | Maybe it's just me, but I don't know too many normal users that
-dnl | do cross-compilation. I'd like to see a more stringent test to
-dnl | decide if we're doing cross-compilation. (Maybe with a message
-dnl | to use gcc!?!? ;-})
-dnl
-dnl Now I put this line in configure.in files:
-dnl
-dnl AM_SANITY_CHECK_CC
-dnl
-dnl Here's the macro that goes in aclocal.m4 -- it should be in the
-dnl next official release of automake.
-
-AC_DEFUN(AM_SANITY_CHECK_CC,
-[dnl Derived from macros from Bruno Haible and from Cygnus.
-AC_MSG_CHECKING([whether the compiler ($CC $CFLAGS $LDFLAGS) actually works])
-AC_LANG_SAVE
- AC_LANG_C
- AC_TRY_RUN([main() { exit(0); }],
- am_cv_prog_cc_works=yes, am_cv_prog_cc_works=no,
- dnl When crosscompiling, just try linking.
- AC_TRY_LINK([], [], am_cv_prog_cc_works=yes,
- am_cv_prog_cc_works=no))
-AC_LANG_RESTORE
-case "$am_cv_prog_cc_works" in
- *no) AC_MSG_ERROR([Installation or configuration problem: C compiler cannot cr
-eate executables.]) ;;
- *yes) ;;
-esac
-AC_MSG_RESULT(yes)
-])dnl
diff --git a/alloca.c b/alloca.c
index a14eb079..6bbd9839 100644
--- a/alloca.c
+++ b/alloca.c
@@ -70,6 +70,7 @@ typedef char *pointer;
#define NULL 0
#endif
+#ifndef malloc
/* Different portions of Emacs need to call different versions of
malloc. The Emacs executable needs alloca to call xmalloc, because
ordinary malloc isn't protected from input signals. On the other
@@ -84,6 +85,7 @@ typedef char *pointer;
#define malloc xmalloc
#endif
extern pointer malloc ();
+#endif /* malloc */
/* Define STACK_DIRECTION if you know the direction of stack
growth for your system; otherwise it will be automatically
diff --git a/amiga/ChangeLog b/amiga/ChangeLog
deleted file mode 100644
index e025b89d..00000000
--- a/amiga/ChangeLog
+++ /dev/null
@@ -1,11 +0,0 @@
-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.
-
-Wed Jan 10 22:58:55 1996 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
-
- * ChangeLog created.
diff --git a/amiga/gawkmisc.ami b/amiga/gawkmisc.ami
deleted file mode 100644
index 1107d8d6..00000000
--- a/amiga/gawkmisc.ami
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * gawkmisc.ami --- miscellanious gawk routines that are OS specific.
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991 - 96 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming 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
- */
-
-char quote = '\'';
-char *defpath = ".,/gnu/lib";
-char envsep = ',';
-
-/* gawk_name --- pull out the "gawk" part from how the OS called us */
-
-char *
-gawk_name(filespec)
-const char *filespec;
-{
- char *p;
-
- /* "path/name" -> "name" */
- p = strrchr(filespec, '/');
- return (p == NULL ? (char *) filespec : p + 1);
-}
-
-/* os_arg_fixup --- fixup the command line */
-
-void
-os_arg_fixup(argcp, argvp)
-int *argcp;
-char ***argvp;
-{
- /* no-op */
- return;
-}
-
-/* os_devopen --- open special per-OS devices */
-
-int
-os_devopen(name, flag)
-const char *name;
-int flag;
-{
- /* no-op */
- return INVALID_HANDLE;
-}
-
-/* optimal_bufsize --- determine optimal buffer size */
-
-int
-optimal_bufsize(fd, stb)
-int fd;
-struct stat *stb;
-{
- /* force all members to zero in case OS doesn't use all of them. */
- memset(stb, '\0', sizeof(struct stat));
-
- /*
- * System V.n, n < 4, doesn't have the file system block size in the
- * stat structure. So we have to make some sort of reasonable
- * guess. We use stdio's BUFSIZ, since that is what it was
- * meant for in the first place.
- */
-#ifdef HAVE_ST_BLKSIZE
-#define DEFBLKSIZE (stb->st_blksize ? stb->st_blksize : BUFSIZ)
-#else
-#define DEFBLKSIZE BUFSIZ
-#endif
-
- if (isatty(fd))
- return BUFSIZ;
- if (fstat(fd, stb) == -1)
- fatal("can't stat fd %d (%s)", fd, strerror(errno));
- if (lseek(fd, (off_t)0, 0) == -1) /* not a regular file */
- return DEFBLKSIZE;
- if (stb->st_size > 0 && stb->st_size < DEFBLKSIZE) /* small file */
- return stb->st_size;
- return DEFBLKSIZE;
-}
-
-/* ispath --- return true if path has directory components */
-
-int
-ispath(file)
-const char *file;
-{
- return (strchr(file, '/') != NULL);
-}
-
-/* isdirpunct --- return true if char is a directory separator */
-
-int
-isdirpunct(c)
-int c;
-{
- return (c == '/');
-}
-
-/* fork --- fake fork(2) using vfork */
-
-int
-fork()
-{
- extern int vfork();
-
- return vfork();
-}
diff --git a/array.c b/array.c
index cbc1a236..b178cd2a 100644
--- a/array.c
+++ b/array.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991 - 96 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991 - 97 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -236,9 +236,14 @@ NODE *symbol, *subs;
symbol = stack_ptr[symbol->param_cnt];
if ((symbol->flags & SCALAR) != 0)
fatal("attempt to use scalar as array");
- if (symbol->var_array == NULL)
- return 0;
+ /*
+ * evaluate subscript first, it could have side effects
+ */
subs = concat_exp(subs); /* concat_exp returns a string node */
+ if (symbol->var_array == NULL) {
+ free_temp(subs);
+ return 0;
+ }
hash1 = hash(subs->stptr, subs->stlen, (unsigned long) symbol->array_size);
ret = (assoc_find(symbol, subs, hash1) != NULL);
free_temp(subs);
@@ -330,14 +335,23 @@ NODE *symbol, *tree;
register NODE *bucket, *last;
NODE *subs;
- if (symbol->type == Node_param_list)
+ if (symbol->type == Node_param_list) {
symbol = stack_ptr[symbol->param_cnt];
+ if (symbol->type == Node_var)
+ return;
+ }
if (symbol->type == Node_var_array) {
if (symbol->var_array == NULL)
return;
} else
fatal("delete: illegal use of variable `%s' as array",
symbol->vname);
+
+ if (tree == NULL) { /* delete array */
+ assoc_clear(symbol);
+ return;
+ }
+
subs = concat_exp(tree); /* concat_exp returns string node */
hash1 = hash(subs->stptr, subs->stlen, (unsigned long) symbol->array_size);
@@ -450,7 +464,14 @@ NODE *symbol;
* very large (> 8K), we just double more or less, instead of
* just jumping from 8K to 64K.
*/
- static long sizes[] = { 13, 127, 1021, 8191, 16381, 32749, 65497 };
+ static long sizes[] = { 13, 127, 1021, 8191, 16381, 32749, 65497,
+#if ! defined(MSDOS) && ! defined(OS2) && ! defined(atarist)
+ 131101, 262147, 524309, 1048583, 2097169,
+ 4194319, 8388617, 16777259, 33554467,
+ 67108879, 134217757, 268435459, 536870923,
+ 1073741827
+#endif
+ };
/* find next biggest hash size */
newsize = oldsize = symbol->array_size;
diff --git a/atari/ChangeLog b/atari/ChangeLog
index df405455..ed4bb487 100644
--- a/atari/ChangeLog
+++ b/atari/ChangeLog
@@ -1,3 +1,11 @@
+Thu May 15 12:49:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Release 3.0.3: Release tar file made.
+
+Fri Apr 18 07:55:47 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * BETA Release 3.0.34: Release tar file made.
+
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/awk.h b/awk.h
index 7ab23285..630144d5 100644
--- a/awk.h
+++ b/awk.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-1996 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -29,7 +29,9 @@
#include <config.h>
#endif
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1 /* enable GNU extensions */
+#endif /* _GNU_SOURCE */
#include <stdio.h>
#ifdef HAVE_LIMITS_H
@@ -356,10 +358,10 @@ typedef struct exp_node {
int r_ent; /* range entered */
} r;
union {
- char *name;
struct exp_node *extra;
long xl;
} x;
+ char *name;
short number;
unsigned char reflags;
# define CASE 1
@@ -409,6 +411,7 @@ typedef struct exp_node {
# define SCALAR 512 /* used as scalar, can't be array */
# define FUNC 1024 /* this parameter is really a
* function name; see awk.y */
+# define FIELD 2048 /* this is a field */
char *vname; /* variable's name */
} NODE;
@@ -416,7 +419,7 @@ typedef struct exp_node {
#define lnode sub.nodep.l.lptr
#define nextp sub.nodep.l.lptr
#define rnode sub.nodep.r.rptr
-#define source_file sub.nodep.x.name
+#define source_file sub.nodep.name
#define source_line sub.nodep.number
#define param_cnt sub.nodep.number
#define param sub.nodep.l.param_name
@@ -478,6 +481,7 @@ typedef struct iobuf {
# define IOP_IS_INTERNAL 2
# define IOP_NO_FREE 4
# define IOP_MMAPPED 8
+# define IOP_NOFREE_OBJ 16
int (*getrec)();
} IOBUF;
@@ -579,30 +583,25 @@ extern char casetable[]; /* for case-independent regexp matching */
/* ------------------------- Pseudo-functions ------------------------- */
-#define is_identchar(c) (isalnum(c) || (c) == '_')
+#define is_identchar(c) (isalnum(c) || (c) == '_')
+#define isnondecimal(str) (((str)[0]) == '0')
#ifdef MPROF
#define getnode(n) emalloc(n, NODE *, sizeof(NODE), "getnode")
-#ifndef DEBUG
#define freenode(n) free(n)
-#endif
#else /* not MPROF */
#define getnode(n) if (nextfree) n = nextfree, nextfree = nextfree->nextp;\
else n = more_nodes()
-#ifndef DEBUG
#define freenode(n) ((n)->flags &= ~SCALAR, (n)->nextp = nextfree, nextfree = (n))
-#endif
#endif /* not MPROF */
#ifdef DEBUG
-#define tree_eval(t) r_tree_eval(t, FALSE)
-#define m_tree_eval(t, iscond) r_tree_eval(t, iscond)
-#define get_lhs(p, a) r_get_lhs((p), (a))
#undef freenode
+#define get_lhs(p, a) r_get_lhs((p), (a))
+#define m_tree_eval(t, iscond) r_tree_eval(t, iscond)
#else
#define get_lhs(p, a) ((p)->type == Node_var ? (&(p)->var_value) : \
r_get_lhs((p), (a)))
-#define tree_eval(t) m_tree_eval(t, FALSE)
#if __GNUC__ >= 2
#define m_tree_eval(t, iscond) \
({NODE * _t = (t); \
@@ -630,6 +629,7 @@ extern char casetable[]; /* for case-independent regexp matching */
r_tree_eval(_t, iscond)))))
#endif /* __GNUC__ */
#endif /* not DEBUG */
+#define tree_eval(t) m_tree_eval(t, FALSE)
#define make_number(x) mk_number((x), (unsigned int)(MALLOC|NUM|NUMBER))
#define tmp_number(x) mk_number((x), (unsigned int)(MALLOC|TEMP|NUM|NUMBER))
@@ -639,7 +639,7 @@ extern char casetable[]; /* for case-independent regexp matching */
#define SCAN 1
#define ALREADY_MALLOCED 2
-#define cant_happen() fatal("internal error line %d, file: %s", \
+#define cant_happen() r_fatal("internal error line %d, file: %s", \
__LINE__, __FILE__);
#ifdef HAVE_STRINGIZE
@@ -694,6 +694,8 @@ extern double _msc51bug;
#define STREQN(a,b,n) ((n) && *(a)== *(b) && \
strncmp((a), (b), (size_t) (n)) == 0)
+#define fatal set_loc(__FILE__, __LINE__), r_fatal
+
/* ------------- Function prototypes or defs (as appropriate) ------------- */
/* array.c */
@@ -741,6 +743,18 @@ extern NODE *do_match P((NODE *tree));
extern NODE *do_gsub P((NODE *tree));
extern NODE *do_sub P((NODE *tree));
extern NODE *do_gensub P((NODE *tree));
+#ifdef BITOPS
+extern NODE *do_lshift P((NODE *tree));
+extern NODE *do_rshift P((NODE *tree));
+extern NODE *do_and P((NODE *tree));
+extern NODE *do_or P((NODE *tree));
+extern NODE *do_xor P((NODE *tree));
+extern NODE *do_compl P((NODE *tree));
+extern NODE *do_strtonum P((NODE *tree));
+#endif /* BITOPS */
+#if defined(BITOPS) || defined(NONDECDATA)
+extern AWKNUM nondec2awknum P((char *str, size_t len));
+#endif /* defined(BITOPS) || defined(NONDECDATA) */
/* eval.c */
extern int interpret P((NODE *volatile tree));
extern NODE *r_tree_eval P((NODE *tree, int iscond));
@@ -782,7 +796,6 @@ extern int devopen P((const char *name, const char *mode));
extern int pathopen P((const char *file));
extern NODE *do_getline P((NODE *tree));
extern void do_nextfile P((void));
-extern IOBUF *iop_alloc P((int fd, const char *name));
extern struct redirect *getredirect P((char *str, int len));
/* main.c */
extern int main P((int argc, char **argv));
@@ -795,18 +808,21 @@ extern void err P((const char *s, const char *emsg, va_list argp));
extern void msg P((va_list va_alist, ...));
extern void error P((va_list va_alist, ...));
extern void warning P((va_list va_alist, ...));
-extern void fatal P((va_list va_alist, ...));
+extern void set_loc P((char *file, int line));
+extern void r_fatal P((va_list va_alist, ...));
#else
#if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
extern void msg (char *mesg, ...);
extern void error (char *mesg, ...);
extern void warning (char *mesg, ...);
-extern void fatal (char *mesg, ...);
+extern void set_loc (char *file, int line);
+extern void r_fatal (char *mesg, ...);
#else
extern void msg ();
extern void error ();
extern void warning ();
-extern void fatal ();
+extern void set_loc ();
+extern void r_fatal ();
#endif
#endif
/* node.c */
diff --git a/awk.y b/awk.y
index ef7f4407..1b9a89bf 100644
--- a/awk.y
+++ b/awk.y
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-1996 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -895,9 +895,15 @@ extern NODE
static struct token tokentab[] = {
{"BEGIN", Node_illegal, LEX_BEGIN, 0, 0},
{"END", Node_illegal, LEX_END, 0, 0},
+#ifdef BITOPS
+{"and", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_and},
+#endif /* BITOPS */
{"atan2", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2},
{"break", Node_K_break, LEX_BREAK, 0, 0},
{"close", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_close},
+#ifdef BITOPS
+{"compl", Node_builtin, LEX_BUILTIN, GAWKX|A(1), do_compl},
+#endif /* BITOPS */
{"continue", Node_K_continue, LEX_CONTINUE, 0, 0},
{"cos", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_cos},
{"delete", Node_K_delete, LEX_DELETE, NOT_OLD, 0},
@@ -918,19 +924,31 @@ static struct token tokentab[] = {
{"int", Node_builtin, LEX_BUILTIN, A(1), do_int},
{"length", Node_builtin, LEX_LENGTH, A(0)|A(1), do_length},
{"log", Node_builtin, LEX_BUILTIN, A(1), do_log},
+#ifdef BITOPS
+{"lshift", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_lshift},
+#endif /* BITOPS */
{"match", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_match},
{"next", Node_K_next, LEX_NEXT, 0, 0},
{"nextfile", Node_K_nextfile, LEX_NEXTFILE, GAWKX, 0},
+#ifdef BITOPS
+{"or", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_or},
+#endif /* BITOPS */
{"print", Node_K_print, LEX_PRINT, 0, 0},
{"printf", Node_K_printf, LEX_PRINTF, 0, 0},
{"rand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0), do_rand},
{"return", Node_K_return, LEX_RETURN, NOT_OLD, 0},
+#ifdef BITOPS
+{"rshift", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_rshift},
+#endif /* BITOPS */
{"sin", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_sin},
{"split", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_split},
{"sprintf", Node_builtin, LEX_BUILTIN, 0, do_sprintf},
{"sqrt", Node_builtin, LEX_BUILTIN, A(1), do_sqrt},
{"srand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand},
{"strftime", Node_builtin, LEX_BUILTIN, GAWKX|A(0)|A(1)|A(2), do_strftime},
+#ifdef BITOPS
+{"strtonum", Node_builtin, LEX_BUILTIN, GAWKX|A(1), do_strtonum},
+#endif /* BITOPS */
{"sub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_sub},
{"substr", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_substr},
{"system", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_system},
@@ -938,6 +956,9 @@ static struct token tokentab[] = {
{"tolower", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower},
{"toupper", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper},
{"while", Node_K_while, LEX_WHILE, 0, 0},
+#ifdef BITOPS
+{"xor", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_xor},
+#endif /* BITOPS */
};
/* yyerror --- print a syntax error message, show where */
@@ -1022,11 +1043,13 @@ get_src_buf()
register char *scan;
static int len = 0;
static int did_newline = FALSE;
+ int newfile;
struct stat sbuf;
# define SLOP 128 /* enough space to hold most source lines */
again:
+ newfile = FALSE;
if (nextfile > numfiles)
return NULL;
@@ -1104,17 +1127,7 @@ again:
in, strerror(errno));
}
len = optimal_bufsize(fd, & sbuf);
- if (sbuf.st_size == 0) {
- static int warned = FALSE;
-
- if (do_lint && ! warned) {
- warned = TRUE;
- warning("source file `%s' is empty", source);
- }
- close(fd);
- ++nextfile;
- goto again;
- }
+ newfile = TRUE;
if (buf != NULL)
free(buf);
emalloc(buf, char *, len + SLOP, "get_src_buf");
@@ -1148,6 +1161,14 @@ again:
fatal("can't read sourcefile \"%s\" (%s)",
source, strerror(errno));
if (n == 0) {
+ if (newfile) {
+ static int warned = FALSE;
+
+ if (do_lint && ! warned) {
+ warned = TRUE;
+ warning("source file `%s' is empty", source);
+ }
+ }
close(fd);
samefile = FALSE;
nextfile++;
@@ -1251,6 +1272,7 @@ yylex()
static int did_newline = FALSE;
char *tokkey;
static int lasttok = 0, eof_warned = FALSE;
+ int inhex = FALSE;
if (nextc() == EOF) {
if (lasttok != NEWLINE) {
@@ -1643,6 +1665,15 @@ retry:
tokadd(c);
switch (c) {
+#ifdef BITOPS
+ case 'x':
+ case 'X':
+ if (do_traditional)
+ goto done;
+ if (tok == tokstart + 2)
+ inhex = TRUE;
+ break;
+#endif /* BITOTS */
case '.':
if (seen_point) {
gotnumber = TRUE;
@@ -1652,6 +1683,8 @@ retry:
break;
case 'e':
case 'E':
+ if (inhex)
+ break;
if (seen_e) {
gotnumber = TRUE;
break;
@@ -1662,6 +1695,21 @@ retry:
else
pushback();
break;
+#ifdef BITOPS
+ case 'a':
+ case 'A':
+ case 'b':
+ case 'B':
+ case 'c':
+ case 'C':
+ case 'D':
+ case 'd':
+ case 'f':
+ case 'F':
+ if (do_traditional || ! inhex)
+ goto done;
+ /* fall through */
+#endif
case '0':
case '1':
case '2':
@@ -1674,6 +1722,7 @@ retry:
case '9':
break;
default:
+ done:
gotnumber = TRUE;
}
if (gotnumber)
@@ -1687,6 +1736,11 @@ retry:
eof_warned = TRUE;
}
tokadd('\0');
+#ifdef BITOPS
+ if (! do_traditional && isnondecimal(tokstart))
+ yylval.nodeval = make_number(nondec2awknum(tokstart, strlen(tokstart)));
+ else
+#endif /* BITOPS */
yylval.nodeval = make_number(atof(tokstart));
yylval.nodeval->flags |= PERM;
return lasttok = YNUMBER;
@@ -1956,6 +2010,9 @@ NODE *func;
int count, i, j, dups;
NODE *params;
+ if (func == NULL) /* error earlier */
+ return TRUE;
+
fname = func->param;
count = func->param_cnt;
params = func->rnode;
@@ -1963,11 +2020,19 @@ NODE *func;
if (count == 0) /* no args, no problem */
return FALSE;
+ if (params == NULL) /* error earlier */
+ return TRUE;
+
emalloc(names, char **, count * sizeof(char *), "dup_parms");
i = 0;
- for (np = params; np != NULL; np = np->rnode)
+ for (np = params; np != NULL; np = np->rnode) {
+ if (np->param == NULL) { /* error earlier, give up, go home */
+ free(names);
+ return TRUE;
+ }
names[i++] = np->param;
+ }
dups = 0;
for (i = 1; i < count; i++) {
diff --git a/awklib/ChangeLog b/awklib/ChangeLog
index 407ac2b5..c27d3b2f 100644
--- a/awklib/ChangeLog
+++ b/awklib/ChangeLog
@@ -1,3 +1,15 @@
+Thu May 15 12:49:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Release 3.0.3: Release tar file made.
+
+Fri Apr 18 07:55:47 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * BETA Release 3.0.34: Release tar file made.
+
+Sun Apr 13 15:40:55 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Makefile.in (install): fix second for loop to use $$i. Sigh.
+
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/awklib/Makefile.in b/awklib/Makefile.in
index 895e8886..c63947b3 100644
--- a/awklib/Makefile.in
+++ b/awklib/Makefile.in
@@ -1,6 +1,6 @@
# Makefile for GNU Awk support library.
#
-# Copyright (C) 1995-1996 the Free Software Foundation, Inc.
+# Copyright (C) 1995-1997 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
@@ -78,7 +78,7 @@ install: igawk $(AUXPROGS) $(AUXAWK)
$(INSTALL_PROGRAM) $$i $(libexecdir)/$$i ; \
done
for i in $(AUXAWK) $(srcdir)/eg/lib/*.awk ; do \
- progname=`echo $i | sed 's;.*/;;'` ; \
+ progname=`echo $$i | sed 's;.*/;;'` ; \
$(INSTALL_DATA) $$i $(datadir)/$$progname ; \
done
diff --git a/awktab.c b/awktab.c
index 40e274c2..42971fa7 100644
--- a/awktab.c
+++ b/awktab.c
@@ -1,47 +1,48 @@
/* A Bison parser, made from ./awk.y
- by GNU Bison version 1.28 */
+ by GNU Bison version 1.25
+ */
#define YYBISON 1 /* Identify Bison output. */
-#define FUNC_CALL 257
-#define NAME 258
-#define REGEXP 259
-#define ERROR 260
-#define YNUMBER 261
-#define YSTRING 262
-#define RELOP 263
-#define APPEND_OP 264
-#define ASSIGNOP 265
-#define MATCHOP 266
-#define NEWLINE 267
-#define CONCAT_OP 268
-#define LEX_BEGIN 269
-#define LEX_END 270
-#define LEX_IF 271
-#define LEX_ELSE 272
-#define LEX_RETURN 273
-#define LEX_DELETE 274
-#define LEX_WHILE 275
-#define LEX_DO 276
-#define LEX_FOR 277
-#define LEX_BREAK 278
-#define LEX_CONTINUE 279
-#define LEX_PRINT 280
-#define LEX_PRINTF 281
-#define LEX_NEXT 282
-#define LEX_EXIT 283
-#define LEX_FUNCTION 284
-#define LEX_GETLINE 285
-#define LEX_NEXTFILE 286
-#define LEX_IN 287
-#define LEX_AND 288
-#define LEX_OR 289
-#define INCREMENT 290
-#define DECREMENT 291
-#define LEX_BUILTIN 292
-#define LEX_LENGTH 293
-#define UNARY 294
+#define FUNC_CALL 258
+#define NAME 259
+#define REGEXP 260
+#define ERROR 261
+#define YNUMBER 262
+#define YSTRING 263
+#define RELOP 264
+#define APPEND_OP 265
+#define ASSIGNOP 266
+#define MATCHOP 267
+#define NEWLINE 268
+#define CONCAT_OP 269
+#define LEX_BEGIN 270
+#define LEX_END 271
+#define LEX_IF 272
+#define LEX_ELSE 273
+#define LEX_RETURN 274
+#define LEX_DELETE 275
+#define LEX_WHILE 276
+#define LEX_DO 277
+#define LEX_FOR 278
+#define LEX_BREAK 279
+#define LEX_CONTINUE 280
+#define LEX_PRINT 281
+#define LEX_PRINTF 282
+#define LEX_NEXT 283
+#define LEX_EXIT 284
+#define LEX_FUNCTION 285
+#define LEX_GETLINE 286
+#define LEX_NEXTFILE 287
+#define LEX_IN 288
+#define LEX_AND 289
+#define LEX_OR 290
+#define INCREMENT 291
+#define DECREMENT 292
+#define LEX_BUILTIN 293
+#define LEX_LENGTH 294
+#define UNARY 295
#line 26 "./awk.y"
@@ -129,7 +130,7 @@ typedef union {
#define YYFLAG -32768
#define YYNTBASE 62
-#define YYTRANSLATE(x) ((unsigned)(x) <= 294 ? yytranslate[x] : 107)
+#define YYTRANSLATE(x) ((unsigned)(x) <= 295 ? yytranslate[x] : 107)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -157,11 +158,11 @@ static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 1, 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, 32, 33, 34, 35, 36,
- 37, 38, 39, 52
+ 2, 2, 2, 2, 2, 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, 32, 33, 34, 35,
+ 36, 37, 38, 39, 52
};
#if YYDEBUG != 0
@@ -780,8 +781,7 @@ static const short yycheck[] = { 3,
46, 47, -1, -1, -1, 51, -1, -1, 54, 55
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/usr/lib/bison.simple"
-/* This file comes from bison-1.28. */
+#line 3 "/usr/local/share/bison.simple"
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
@@ -798,66 +798,46 @@ static const short yycheck[] = { 3,
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. */
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
-/* This is the parser code that is written into each bison parser
- when the %semantic_parser declaration is not specified in the grammar.
- It was written by Richard Stallman by simplifying the hairy parser
- used when %semantic_parser is specified. */
-
-#ifndef YYSTACK_USE_ALLOCA
-#ifdef alloca
-#define YYSTACK_USE_ALLOCA
-#else /* alloca not defined */
+#ifndef alloca
#ifdef __GNUC__
-#define YYSTACK_USE_ALLOCA
#define alloca __builtin_alloca
#else /* not GNU C. */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
-#define YYSTACK_USE_ALLOCA
+#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
-/* We think this test detects Watcom and Microsoft C. */
-/* This used to test MSDOS, but that is a bad idea
- since that symbol is in the user namespace. */
-#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
-#if 0 /* No need for malloc.h, which pollutes the namespace;
- instead, just don't use alloca. */
+#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
-#endif
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
-/* I don't know what this was needed for, but it pollutes the namespace.
- So I turned it off. rms, 2 May 1997. */
-/* #include <malloc.h> */
+#include <malloc.h>
#pragma alloca
-#define YYSTACK_USE_ALLOCA
-#else /* not MSDOS, or __TURBOC__, or _AIX */
-#if 0
-#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
- and on HPUX 10. Eventually we can turn this on. */
-#define YYSTACK_USE_ALLOCA
-#define alloca __builtin_alloca
+#else /* not MSDOS, __TURBOC__, or _AIX */
+#ifdef __hpux
+#ifdef __cplusplus
+extern "C" {
+void *alloca (unsigned int);
+};
+#else /* not __cplusplus */
+void *alloca ();
+#endif /* not __cplusplus */
#endif /* __hpux */
-#endif
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
-#endif /* not sparc */
-#endif /* not GNU C */
-#endif /* alloca not defined */
-#endif /* YYSTACK_USE_ALLOCA not defined */
+#endif /* not sparc. */
+#endif /* not GNU C. */
+#endif /* alloca not defined. */
-#ifdef YYSTACK_USE_ALLOCA
-#define YYSTACK_ALLOC alloca
-#else
-#define YYSTACK_ALLOC malloc
-#endif
+/* This is the parser code that is written into each bison parser
+ when the %semantic_parser declaration is not specified in the grammar.
+ It was written by Richard Stallman by simplifying the hairy parser
+ used when %semantic_parser is specified. */
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
@@ -867,8 +847,8 @@ static const short yycheck[] = { 3,
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
+#define YYACCEPT return(0)
+#define YYABORT return(1)
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
This remains here temporarily to ease the
@@ -949,12 +929,12 @@ int yydebug; /* nonzero means print parse trace */
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif
-
-/* Define __yy_memcpy. Note that the size argument
- should be passed with type unsigned int, because that is what the non-GCC
- definitions require. With GCC, __builtin_memcpy takes an arg
- of type size_t, but it can handle unsigned int. */
+/* Prevent warning if -Wstrict-prototypes. */
+#ifdef __GNUC__
+int yyparse (void);
+#endif
+
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
@@ -966,7 +946,7 @@ static void
__yy_memcpy (to, from, count)
char *to;
char *from;
- unsigned int count;
+ int count;
{
register char *f = from;
register char *t = to;
@@ -981,10 +961,10 @@ __yy_memcpy (to, from, count)
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
-__yy_memcpy (char *to, char *from, unsigned int count)
+__yy_memcpy (char *to, char *from, int count)
{
- register char *t = to;
register char *f = from;
+ register char *t = to;
register int i = count;
while (i-- > 0)
@@ -994,7 +974,7 @@ __yy_memcpy (char *to, char *from, unsigned int count)
#endif
#endif
-#line 217 "/usr/lib/bison.simple"
+#line 196 "/usr/local/share/bison.simple"
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
into yyparse. The argument should have type void *.
@@ -1015,15 +995,6 @@ __yy_memcpy (char *to, char *from, unsigned int count)
#define YYPARSE_PARAM_DECL
#endif /* not YYPARSE_PARAM */
-/* Prevent warning if -Wstrict-prototypes. */
-#ifdef __GNUC__
-#ifdef YYPARSE_PARAM
-int yyparse (void *);
-#else
-int yyparse (void);
-#endif
-#endif
-
int
yyparse(YYPARSE_PARAM_ARG)
YYPARSE_PARAM_DECL
@@ -1052,7 +1023,6 @@ yyparse(YYPARSE_PARAM_ARG)
#endif
int yystacksize = YYINITDEPTH;
- int yyfree_stacks = 0;
#ifdef YYPURE
int yychar;
@@ -1137,32 +1107,18 @@ yynewstate:
if (yystacksize >= YYMAXDEPTH)
{
yyerror("parser stack overflow");
- if (yyfree_stacks)
- {
- free (yyss);
- free (yyvs);
-#ifdef YYLSP_NEEDED
- free (yyls);
-#endif
- }
return 2;
}
yystacksize *= 2;
if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH;
-#ifndef YYSTACK_USE_ALLOCA
- yyfree_stacks = 1;
-#endif
- yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
- __yy_memcpy ((char *)yyss, (char *)yyss1,
- size * (unsigned int) sizeof (*yyssp));
- yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
- __yy_memcpy ((char *)yyvs, (char *)yyvs1,
- size * (unsigned int) sizeof (*yyvsp));
+ yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
+ __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
+ yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
+ __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
- yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
- __yy_memcpy ((char *)yyls, (char *)yyls1,
- size * (unsigned int) sizeof (*yylsp));
+ yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
+ __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
@@ -2211,7 +2167,7 @@ case 161:
break;}
}
/* the action file gets copied in in place of this dollarsign */
-#line 543 "/usr/lib/bison.simple"
+#line 498 "/usr/local/share/bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
@@ -2406,30 +2362,6 @@ yyerrhandle:
yystate = yyn;
goto yynewstate;
-
- yyacceptlab:
- /* YYACCEPT comes here. */
- if (yyfree_stacks)
- {
- free (yyss);
- free (yyvs);
-#ifdef YYLSP_NEEDED
- free (yyls);
-#endif
- }
- return 0;
-
- yyabortlab:
- /* YYABORT comes here. */
- if (yyfree_stacks)
- {
- free (yyss);
- free (yyvs);
-#ifdef YYLSP_NEEDED
- free (yyls);
-#endif
- }
- return 1;
}
#line 867 "./awk.y"
@@ -2463,9 +2395,15 @@ extern NODE
static struct token tokentab[] = {
{"BEGIN", Node_illegal, LEX_BEGIN, 0, 0},
{"END", Node_illegal, LEX_END, 0, 0},
+#ifdef BITOPS
+{"and", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_and},
+#endif /* BITOPS */
{"atan2", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2},
{"break", Node_K_break, LEX_BREAK, 0, 0},
{"close", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_close},
+#ifdef BITOPS
+{"compl", Node_builtin, LEX_BUILTIN, GAWKX|A(1), do_compl},
+#endif /* BITOPS */
{"continue", Node_K_continue, LEX_CONTINUE, 0, 0},
{"cos", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_cos},
{"delete", Node_K_delete, LEX_DELETE, NOT_OLD, 0},
@@ -2486,19 +2424,31 @@ static struct token tokentab[] = {
{"int", Node_builtin, LEX_BUILTIN, A(1), do_int},
{"length", Node_builtin, LEX_LENGTH, A(0)|A(1), do_length},
{"log", Node_builtin, LEX_BUILTIN, A(1), do_log},
+#ifdef BITOPS
+{"lshift", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_lshift},
+#endif /* BITOPS */
{"match", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_match},
{"next", Node_K_next, LEX_NEXT, 0, 0},
{"nextfile", Node_K_nextfile, LEX_NEXTFILE, GAWKX, 0},
+#ifdef BITOPS
+{"or", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_or},
+#endif /* BITOPS */
{"print", Node_K_print, LEX_PRINT, 0, 0},
{"printf", Node_K_printf, LEX_PRINTF, 0, 0},
{"rand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0), do_rand},
{"return", Node_K_return, LEX_RETURN, NOT_OLD, 0},
+#ifdef BITOPS
+{"rshift", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_rshift},
+#endif /* BITOPS */
{"sin", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_sin},
{"split", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_split},
{"sprintf", Node_builtin, LEX_BUILTIN, 0, do_sprintf},
{"sqrt", Node_builtin, LEX_BUILTIN, A(1), do_sqrt},
{"srand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand},
{"strftime", Node_builtin, LEX_BUILTIN, GAWKX|A(0)|A(1)|A(2), do_strftime},
+#ifdef BITOPS
+{"strtonum", Node_builtin, LEX_BUILTIN, GAWKX|A(1), do_strtonum},
+#endif /* BITOPS */
{"sub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_sub},
{"substr", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_substr},
{"system", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_system},
@@ -2506,6 +2456,9 @@ static struct token tokentab[] = {
{"tolower", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower},
{"toupper", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper},
{"while", Node_K_while, LEX_WHILE, 0, 0},
+#ifdef BITOPS
+{"xor", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_xor},
+#endif /* BITOPS */
};
/* yyerror --- print a syntax error message, show where */
@@ -2590,11 +2543,13 @@ get_src_buf()
register char *scan;
static int len = 0;
static int did_newline = FALSE;
+ int newfile;
struct stat sbuf;
# define SLOP 128 /* enough space to hold most source lines */
again:
+ newfile = FALSE;
if (nextfile > numfiles)
return NULL;
@@ -2672,17 +2627,7 @@ again:
in, strerror(errno));
}
len = optimal_bufsize(fd, & sbuf);
- if (sbuf.st_size == 0) {
- static int warned = FALSE;
-
- if (do_lint && ! warned) {
- warned = TRUE;
- warning("source file `%s' is empty", source);
- }
- close(fd);
- ++nextfile;
- goto again;
- }
+ newfile = TRUE;
if (buf != NULL)
free(buf);
emalloc(buf, char *, len + SLOP, "get_src_buf");
@@ -2716,6 +2661,14 @@ again:
fatal("can't read sourcefile \"%s\" (%s)",
source, strerror(errno));
if (n == 0) {
+ if (newfile) {
+ static int warned = FALSE;
+
+ if (do_lint && ! warned) {
+ warned = TRUE;
+ warning("source file `%s' is empty", source);
+ }
+ }
close(fd);
samefile = FALSE;
nextfile++;
@@ -2819,6 +2772,7 @@ yylex()
static int did_newline = FALSE;
char *tokkey;
static int lasttok = 0, eof_warned = FALSE;
+ int inhex = FALSE;
if (nextc() == EOF) {
if (lasttok != NEWLINE) {
@@ -2984,8 +2938,10 @@ retry:
if (nextc() == '\n') {
sourceline++;
goto retry;
- } else
+ } else {
yyerror("backslash not last character on line");
+ exit(1);
+ }
break;
case '$':
@@ -3152,6 +3108,7 @@ retry:
if (c == '\n') {
pushback();
yyerror("unterminated string");
+ exit(1);
}
if (c == '\\') {
c = nextc();
@@ -3165,6 +3122,7 @@ retry:
if (c == EOF) {
pushback();
yyerror("unterminated string");
+ exit(1);
}
tokadd(c);
}
@@ -3207,6 +3165,15 @@ retry:
tokadd(c);
switch (c) {
+#ifdef BITOPS
+ case 'x':
+ case 'X':
+ if (do_traditional)
+ goto done;
+ if (tok == tokstart + 2)
+ inhex = TRUE;
+ break;
+#endif /* BITOTS */
case '.':
if (seen_point) {
gotnumber = TRUE;
@@ -3216,6 +3183,8 @@ retry:
break;
case 'e':
case 'E':
+ if (inhex)
+ break;
if (seen_e) {
gotnumber = TRUE;
break;
@@ -3226,6 +3195,21 @@ retry:
else
pushback();
break;
+#ifdef BITOPS
+ case 'a':
+ case 'A':
+ case 'b':
+ case 'B':
+ case 'c':
+ case 'C':
+ case 'D':
+ case 'd':
+ case 'f':
+ case 'F':
+ if (do_traditional || ! inhex)
+ goto done;
+ /* fall through */
+#endif
case '0':
case '1':
case '2':
@@ -3238,6 +3222,7 @@ retry:
case '9':
break;
default:
+ done:
gotnumber = TRUE;
}
if (gotnumber)
@@ -3251,6 +3236,11 @@ retry:
eof_warned = TRUE;
}
tokadd('\0');
+#ifdef BITOPS
+ if (! do_traditional && isnondecimal(tokstart))
+ yylval.nodeval = make_number(nondec2awknum(tokstart, strlen(tokstart)));
+ else
+#endif /* BITOPS */
yylval.nodeval = make_number(atof(tokstart));
yylval.nodeval->flags |= PERM;
return lasttok = YNUMBER;
@@ -3276,8 +3266,10 @@ retry:
return lasttok = '|';
}
- if (c != '_' && ! isalpha(c))
+ if (c != '_' && ! isalpha(c)) {
yyerror("Invalid char '%c' in expression\n", c);
+ exit(1);
+ }
/* it's some type of name-type-thing. Find its length. */
tok = tokstart;
@@ -3518,6 +3510,9 @@ NODE *func;
int count, i, j, dups;
NODE *params;
+ if (func == NULL) /* error earlier */
+ return TRUE;
+
fname = func->param;
count = func->param_cnt;
params = func->rnode;
@@ -3525,11 +3520,19 @@ NODE *func;
if (count == 0) /* no args, no problem */
return FALSE;
+ if (params == NULL) /* error earlier */
+ return TRUE;
+
emalloc(names, char **, count * sizeof(char *), "dup_parms");
i = 0;
- for (np = params; np != NULL; np = np->rnode)
+ for (np = params; np != NULL; np = np->rnode) {
+ if (np->param == NULL) { /* error earlier, give up, go home */
+ free(names);
+ return TRUE;
+ }
names[i++] = np->param;
+ }
dups = 0;
for (i = 1; i < count; i++) {
diff --git a/builtin.c b/builtin.c
index 35402f1e..0686041c 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-1996 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -25,6 +25,7 @@
#include "awk.h"
+#include <assert.h>
#undef HUGE
#undef CHARBITS
#undef INTBITS
@@ -871,25 +872,52 @@ NODE *tree;
{
NODE *t1, *t2, *t3;
NODE *r;
- register int indx;
+ register size_t indx;
size_t length;
+ double d_index, d_length;
t1 = force_string(tree_eval(tree->lnode));
t2 = tree_eval(tree->rnode->lnode);
- indx = (int) force_number(t2) - 1;
+ d_index = force_number(t2);
free_temp(t2);
- if (indx < 0) {
+
+ if (d_index < 1.0) {
if (do_lint)
- warning("substr: start index %d invalid, using 1",
- indx+1);
- indx = 0; /* awk indices start at 1, C at 0 */
+ warning("substr: start index %g invalid, using 1",
+ d_index);
+ d_index = 1;
}
+ if (do_lint && double_to_int(d_index) != d_index)
+ warning("substr: non-integer start index %g will be truncated",
+ d_index);
+
+ indx = d_index - 1; /* awk indices are from 1, C's are from 0 */
+
if (tree->rnode->rnode == NULL) { /* third arg. missing */
- length = t1->stlen - indx; /* use remainder of string */
+ /* use remainder of string */
+ length = t1->stlen - indx;
} else {
t3 = tree_eval(tree->rnode->rnode->lnode);
- length = (size_t) force_number(t3);
+ d_length = force_number(t3);
free_temp(t3);
+ if (d_length <= 0.0) {
+ if (do_lint)
+ warning("substr: length %g is <= 0", d_length);
+ free_temp(t1);
+ return Nnull_string;
+ }
+ if (do_lint && double_to_int(d_length) != d_length)
+ warning(
+ "substr: non-integer length %g will be truncated",
+ d_length);
+ length = d_length;
+ }
+
+ if (t1->stlen == 0) {
+ if (do_lint)
+ warning("substr: source string is zero length");
+ free_temp(t1);
+ return Nnull_string;
}
if ((indx + length) > t1->stlen) {
if (do_lint)
@@ -898,12 +926,10 @@ NODE *tree;
length, indx+1, t1->stlen);
length = t1->stlen - indx;
}
- if (indx >= t1->stlen || (long) length <= 0) {
- if (do_lint && indx >= t1->stlen)
- warning("substr: position %d is past end of string",
+ if (indx >= t1->stlen) {
+ if (do_lint)
+ warning("substr: start index %d is past end of string",
indx+1);
- if (do_lint && (long) length <= 0)
- warning("substr: length %d is <= 0", (long) length);
free_temp(t1);
return Nnull_string;
}
@@ -959,16 +985,17 @@ NODE *tree;
bufp = buf;
bufsize = sizeof(buf);
for (;;) {
+ *bufp = '\0';
buflen = strftime(bufp, bufsize, format, tm);
/*
* buflen can be zero EITHER because there's not enough
* room in the string, or because the control command
* goes to the empty string. Make a reasonable guess that
- * if the buffer is 4 times bigger than the length of the
+ * if the buffer is 1024 times bigger than the length of the
* format string, it's not failing for lack of room.
* Thanks to Paul Eggert for pointing out this issue.
*/
- if (buflen > 0 || bufsize >= 4 * formatlen)
+ if (buflen > 0 || bufsize >= 1024 * formatlen)
break;
bufsize *= 2;
if (bufp == buf)
@@ -1081,7 +1108,13 @@ register NODE *tree;
tree = save;
for (i = 0; tree != NULL; i++, tree = tree->rnode) {
- t[i] = tree_eval(tree->lnode);
+ NODE *n;
+
+ /* Here lies the wumpus. R.I.P. */
+ n = tree_eval(tree->lnode);
+ t[i] = dupnode(n);
+ free_temp(n);
+
if (t[i]->flags & NUMBER) {
if (OFMTidx == CONVFMTidx)
(void) force_string(t[i]);
@@ -1092,7 +1125,7 @@ register NODE *tree;
for (i = 0; i < numnodes; i++) {
efwrite(t[i]->stptr, sizeof(char), t[i]->stlen, fp, "print", rp, FALSE);
- free_temp(t[i]);
+ unref(t[i]);
if (i != numnodes - 1) {
if (OFSlen > 0)
efwrite(OFS, sizeof(char), (size_t) OFSlen,
@@ -1389,7 +1422,7 @@ int how_many, backdigs;
/*
* create a private copy of the string
*/
- if (t->stref > 1 || (t->flags & PERM)) {
+ if (t->stref > 1 || (t->flags & (PERM|FIELD)) != 0) {
unsigned int saveflags;
saveflags = t->flags;
@@ -1731,3 +1764,285 @@ double g; /* value to format */
}
}
#endif /* GFMT_WORKAROUND */
+
+#ifdef BITOPS
+#define BITS_PER_BYTE 8 /* if not true, you lose. too bad. */
+
+/* do_lshift --- perform a << operation */
+
+NODE *
+do_lshift(tree)
+NODE *tree;
+{
+ NODE *s1, *s2;
+ unsigned long uval, ushift, result;
+ AWKNUM val, shift;
+
+ s1 = tree_eval(tree->lnode);
+ s2 = tree_eval(tree->rnode->lnode);
+ val = force_number(s1);
+ shift = force_number(s2);
+ free_temp(s1);
+ free_temp(s2);
+
+ if (do_lint) {
+ if (val < 0 || shift < 0)
+ warning("lshift(%lf, %lf): negative values will give strange results", val, shift);
+ if (double_to_int(val) != val || double_to_int(shift) != shift)
+ warning("lshift(%lf, %lf): fractional values will be truncated", val, shift);
+ if (shift > (sizeof(unsigned long) * BITS_PER_BYTE))
+ warning("lshift(%lf, %lf): too large shift value will give strange results", val, shift);
+ }
+
+ uval = (unsigned long) val;
+ ushift = (unsigned long) shift;
+
+ result = uval << ushift;
+ return tmp_number((AWKNUM) result);
+}
+
+/* do_rshift --- perform a >> operation */
+
+NODE *
+do_rshift(tree)
+NODE *tree;
+{
+ NODE *s1, *s2;
+ unsigned long uval, ushift, result;
+ AWKNUM val, shift;
+
+ s1 = tree_eval(tree->lnode);
+ s2 = tree_eval(tree->rnode->lnode);
+ val = force_number(s1);
+ shift = force_number(s2);
+ free_temp(s1);
+ free_temp(s2);
+
+ if (do_lint) {
+ if (val < 0 || shift < 0)
+ warning("rshift(%lf, %lf): negative values will give strange results", val, shift);
+ if (double_to_int(val) != val || double_to_int(shift) != shift)
+ warning("rshift(%lf, %lf): fractional values will be truncated", val, shift);
+ if (shift > (sizeof(unsigned long) * BITS_PER_BYTE))
+ warning("rshift(%lf, %lf): too large shift value will give strange results", val, shift);
+ }
+
+ uval = (unsigned long) val;
+ ushift = (unsigned long) shift;
+
+ result = uval >> ushift;
+ return tmp_number((AWKNUM) result);
+}
+
+/* do_and --- perform an & operation */
+
+NODE *
+do_and(tree)
+NODE *tree;
+{
+ NODE *s1, *s2;
+ unsigned long uleft, uright, result;
+ AWKNUM left, right;
+
+ s1 = tree_eval(tree->lnode);
+ s2 = tree_eval(tree->rnode->lnode);
+ left = force_number(s1);
+ right = force_number(s2);
+ free_temp(s1);
+ free_temp(s2);
+
+ if (do_lint) {
+ if (left < 0 || right < 0)
+ warning("and(%lf, %lf): negative values will give strange results", left, right);
+ if (double_to_int(left) != left || double_to_int(right) != right)
+ warning("and(%lf, %lf): fractional values will be truncated", left, right);
+ }
+
+ uleft = (unsigned long) left;
+ uright = (unsigned long) right;
+
+ result = uleft & uright;
+ return tmp_number((AWKNUM) result);
+}
+
+/* do_or --- perform an | operation */
+
+NODE *
+do_or(tree)
+NODE *tree;
+{
+ NODE *s1, *s2;
+ unsigned long uleft, uright, result;
+ AWKNUM left, right;
+
+ s1 = tree_eval(tree->lnode);
+ s2 = tree_eval(tree->rnode->lnode);
+ left = force_number(s1);
+ right = force_number(s2);
+ free_temp(s1);
+ free_temp(s2);
+
+ if (do_lint) {
+ if (left < 0 || right < 0)
+ warning("or(%lf, %lf): negative values will give strange results", left, right);
+ if (double_to_int(left) != left || double_to_int(right) != right)
+ warning("or(%lf, %lf): fractional values will be truncated", left, right);
+ }
+
+ uleft = (unsigned long) left;
+ uright = (unsigned long) right;
+
+ result = uleft | uright;
+ return tmp_number((AWKNUM) result);
+}
+
+/* do_xor --- perform an ^ operation */
+
+NODE *
+do_xor(tree)
+NODE *tree;
+{
+ NODE *s1, *s2;
+ unsigned long uleft, uright, result;
+ AWKNUM left, right;
+
+ s1 = tree_eval(tree->lnode);
+ s2 = tree_eval(tree->rnode->lnode);
+ left = force_number(s1);
+ right = force_number(s2);
+ free_temp(s1);
+ free_temp(s2);
+
+ if (do_lint) {
+ if (left < 0 || right < 0)
+ warning("xor(%lf, %lf): negative values will give strange results", left, right);
+ if (double_to_int(left) != left || double_to_int(right) != right)
+ warning("xor(%lf, %lf): fractional values will be truncated", left, right);
+ }
+
+ uleft = (unsigned long) left;
+ uright = (unsigned long) right;
+
+ result = uleft ^ uright;
+ return tmp_number((AWKNUM) result);
+}
+
+/* do_compl --- perform a ~ operation */
+
+NODE *
+do_compl(tree)
+NODE *tree;
+{
+ NODE *tmp;
+ double d;
+ unsigned long uval;
+
+ tmp = tree_eval(tree->lnode);
+ d = force_number(tmp);
+ free_temp(tmp);
+
+ if (do_lint) {
+ if (uval < 0)
+ warning("compl(%lf): negative value will give strange results", d);
+ if (double_to_int(d) != d)
+ warning("compl(%lf): fractional value will be truncated", d);
+ }
+
+ uval = (unsigned long) d;
+ uval = ~ uval;
+ return tmp_number((AWKNUM) uval);
+}
+
+/* do_strtonum --- the strtonum function */
+
+NODE *
+do_strtonum(tree)
+NODE *tree;
+{
+ NODE *tmp;
+ double d, arg;
+
+ tmp = tree_eval(tree->lnode);
+
+ if ((tmp->flags & (NUM|NUMBER)) != 0)
+ d = (double) force_number(tmp);
+ else if (isnondecimal(tmp->stptr))
+ d = nondec2awknum(tmp->stptr, tmp->stlen);
+ else
+ d = (double) force_number(tmp);
+
+ free_temp(tmp);
+ return tmp_number((AWKNUM) d);
+}
+#endif /* BITOPS */
+
+#if defined(BITOPS) || defined(NONDECDATA)
+/* nondec2awknum --- convert octal or hex value to double */
+
+/*
+ * Because of awk's concatenation rules and the way awk.y:yylex()
+ * collects a number, this routine has to be willing to stop on the
+ * first invalid character.
+ */
+
+AWKNUM
+nondec2awknum(str, len)
+char *str;
+size_t len;
+{
+ AWKNUM retval = 0.0;
+ char save;
+ short val;
+
+ if (*str == '0' && (str[1] == 'x' || str[1] == 'X')) {
+ assert(len > 2);
+
+ for (str += 2, len -= 2; len > 0; len--, str++) {
+ switch (*str) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ val = *str - '0';
+ break;
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ val = *str - 'a' + 10;
+ break;
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ val = *str - 'A' + 10;
+ break;
+ default:
+ goto done;
+ }
+ retval = (retval * 16) + val;
+ }
+ } else if (*str == '0') {
+ for (; len > 0; len--) {
+ if (! isdigit(*str) || *str == '8' || *str == '9')
+ goto done;
+ retval = (retval * 8) + (*str - '0');
+ str++;
+ }
+ } else {
+ save = str[len];
+ retval = atof(str);
+ str[len] = save;
+ }
+done:
+ return retval;
+}
+#endif /* defined(BITOPS) || defined(NONDECDATA) */
diff --git a/configh.in b/configh.in
index 4c197f3b..34e89b57 100644
--- a/configh.in
+++ b/configh.in
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 1995, 96 the Free Software Foundation, Inc.
+ * Copyright (C) 1995-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -128,6 +128,8 @@
#undef HAVE_STRINGIZE /* can use ANSI # operator in cpp */
#undef REGEX_MALLOC /* use malloc instead of alloca in regex.c */
#undef SPRINTF_RET /* return type of sprintf */
+#undef BITOPS /* bitwise ops (undocumented feature) */
+#undef NONDECDATA /* non-decimal input data (undocumented feature) */
/* Define if you have the fmod function. */
#undef HAVE_FMOD
diff --git a/configure b/configure
index 0d0b776c..63a0d99d 100755
--- a/configure
+++ b/configure
@@ -11,6 +11,10 @@
ac_help=
ac_default_prefix=/usr/local
# Any additions from configure.in:
+ac_help="$ac_help
+ --enable-bitops Enable Octal and Hex constants and bit functions"
+ac_help="$ac_help
+ --enable-non-decimal-data Enable Octal and Hex constants as valid input data"
# Initialize some variables set by options.
# The variables have the same names as the options, with
@@ -521,12 +525,31 @@ fi
+# Check whether --enable-bitops or --disable-bitops was given.
+if test "${enable_bitops+set}" = set; then
+ enableval="$enable_bitops"
+ cat >> confdefs.h <<\EOF
+#define BITOPS 1
+EOF
+
+fi
+
+# Check whether --enable-non-decimal-data or --disable-non-decimal-data was given.
+if test "${enable_non_decimal_data+set}" = set; then
+ enableval="$enable_non_decimal_data"
+ cat >> confdefs.h <<\EOF
+#define NONDECDATA 1
+EOF
+
+fi
+
+
for ac_prog in 'bison -y' byacc
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:530: checking for $ac_word" >&5
+echo "configure:553: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -556,7 +579,7 @@ done
test -n "$YACC" || YACC="yacc"
echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:560: checking whether ln -s works" >&5
+echo "configure:583: checking whether ln -s works" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -579,7 +602,7 @@ fi
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:583: checking for $ac_word" >&5
+echo "configure:606: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -608,7 +631,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:612: checking for $ac_word" >&5
+echo "configure:635: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -656,7 +679,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:660: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:683: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -666,11 +689,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS
cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext <<EOF
-#line 670 "configure"
+#line 693 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -690,12 +713,12 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:694: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:717: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:699: checking whether we are using GNU C" >&5
+echo "configure:722: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -704,7 +727,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:708: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:731: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -719,7 +742,7 @@ if test $ac_cv_prog_gcc = yes; then
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:723: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:746: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -747,7 +770,7 @@ else
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:751: checking how to run the C preprocessor" >&5
+echo "configure:774: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -762,13 +785,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 766 "configure"
+#line 789 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:772: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:795: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@@ -779,13 +802,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 783 "configure"
+#line 806 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:789: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:812: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@@ -841,7 +864,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:845: checking for a BSD compatible install" >&5
+echo "configure:868: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -892,7 +915,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:896: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:919: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -931,9 +954,9 @@ fi
echo $ac_n "checking for AIX""... $ac_c" 1>&6
-echo "configure:935: checking for AIX" >&5
+echo "configure:958: checking for AIX" >&5
cat > conftest.$ac_ext <<EOF
-#line 937 "configure"
+#line 960 "configure"
#include "confdefs.h"
#ifdef _AIX
yes
@@ -955,7 +978,7 @@ rm -f conftest*
echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
-echo "configure:959: checking for POSIXized ISC" >&5
+echo "configure:982: checking for POSIXized ISC" >&5
if test -d /etc/conf/kconfig.d &&
grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
then
@@ -977,17 +1000,17 @@ fi
ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6
-echo "configure:981: checking for minix/config.h" >&5
+echo "configure:1004: checking for minix/config.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 986 "configure"
+#line 1009 "configure"
#include "confdefs.h"
#include <minix/config.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:991: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1014: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1026,12 +1049,12 @@ fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1030: checking for ANSI C header files" >&5
+echo "configure:1053: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1035 "configure"
+#line 1058 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -1039,7 +1062,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1043: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1066: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1056,7 +1079,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1060 "configure"
+#line 1083 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -1074,7 +1097,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1078 "configure"
+#line 1101 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -1095,7 +1118,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 1099 "configure"
+#line 1122 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1106,7 +1129,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:1110: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
:
else
@@ -1130,12 +1153,12 @@ EOF
fi
echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:1134: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:1157: checking for sys/wait.h that is POSIX.1 compatible" >&5
if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1139 "configure"
+#line 1162 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/wait.h>
@@ -1151,7 +1174,7 @@ wait (&s);
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
; return 0; }
EOF
-if { (eval echo configure:1155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1178: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_sys_wait_h=yes
else
@@ -1175,17 +1198,17 @@ for ac_hdr in limits.h locale.h stdarg.h unistd.h signum.h sys/param.h string.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1179: checking for $ac_hdr" >&5
+echo "configure:1202: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1184 "configure"
+#line 1207 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1189: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1212: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1217,17 +1240,17 @@ then
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1221: checking for $ac_hdr" >&5
+echo "configure:1244: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1226 "configure"
+#line 1249 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1231: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1254: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1258,17 +1281,17 @@ else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1262: checking for $ac_hdr" >&5
+echo "configure:1285: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1267 "configure"
+#line 1290 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1295: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1297,12 +1320,12 @@ done
fi
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:1301: checking for pid_t" >&5
+echo "configure:1324: checking for pid_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1306 "configure"
+#line 1329 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -1330,12 +1353,12 @@ EOF
fi
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1334: checking return type of signal handlers" >&5
+echo "configure:1357: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1339 "configure"
+#line 1362 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -1352,7 +1375,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:1356: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1379: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -1371,12 +1394,12 @@ EOF
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:1375: checking for size_t" >&5
+echo "configure:1398: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1380 "configure"
+#line 1403 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -1404,12 +1427,12 @@ EOF
fi
echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:1408: checking for uid_t in sys/types.h" >&5
+echo "configure:1431: checking for uid_t in sys/types.h" >&5
if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1413 "configure"
+#line 1436 "configure"
#include "confdefs.h"
#include <sys/types.h>
EOF
@@ -1438,7 +1461,7 @@ EOF
fi
echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6
-echo "configure:1442: checking type of array argument to getgroups" >&5
+echo "configure:1465: checking type of array argument to getgroups" >&5
if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1446,7 +1469,7 @@ else
ac_cv_type_getgroups=cross
else
cat > conftest.$ac_ext <<EOF
-#line 1450 "configure"
+#line 1473 "configure"
#include "confdefs.h"
/* Thanks to Mike Rendell for this test. */
@@ -1471,7 +1494,7 @@ main()
}
EOF
-if { (eval echo configure:1475: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_type_getgroups=gid_t
else
@@ -1485,7 +1508,7 @@ fi
if test $ac_cv_type_getgroups = cross; then
cat > conftest.$ac_ext <<EOF
-#line 1489 "configure"
+#line 1512 "configure"
#include "confdefs.h"
#include <unistd.h>
EOF
@@ -1509,7 +1532,7 @@ EOF
cat > conftest.$ac_ext <<EOF
-#line 1513 "configure"
+#line 1536 "configure"
#include "confdefs.h"
#include <stdio.h>
EOF
@@ -1536,19 +1559,19 @@ then
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:1540: checking for working alloca.h" >&5
+echo "configure:1563: checking for working alloca.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1545 "configure"
+#line 1568 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = alloca(2 * sizeof(int));
; return 0; }
EOF
-if { (eval echo configure:1552: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ac_cv_header_alloca_h=yes
else
@@ -1569,12 +1592,12 @@ EOF
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:1573: checking for alloca" >&5
+echo "configure:1596: checking for alloca" >&5
if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1578 "configure"
+#line 1601 "configure"
#include "confdefs.h"
#ifdef __GNUC__
@@ -1597,7 +1620,7 @@ int main() {
char *p = (char *) alloca(1);
; return 0; }
EOF
-if { (eval echo configure:1601: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1624: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ac_cv_func_alloca_works=yes
else
@@ -1629,12 +1652,12 @@ EOF
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:1633: checking whether alloca needs Cray hooks" >&5
+echo "configure:1656: checking whether alloca needs Cray hooks" >&5
if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1638 "configure"
+#line 1661 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@@ -1659,12 +1682,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1663: checking for $ac_func" >&5
+echo "configure:1686: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1668 "configure"
+#line 1691 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1687,7 +1710,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1691: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1714,7 +1737,7 @@ done
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:1718: checking stack direction for C alloca" >&5
+echo "configure:1741: checking stack direction for C alloca" >&5
if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1722,7 +1745,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
-#line 1726 "configure"
+#line 1749 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@@ -1741,7 +1764,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
-if { (eval echo configure:1745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1768: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@@ -1768,12 +1791,12 @@ cat >> confdefs.h <<\EOF
EOF
echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:1772: checking for vprintf" >&5
+echo "configure:1795: checking for vprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1777 "configure"
+#line 1800 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vprintf(); below. */
@@ -1796,7 +1819,7 @@ vprintf();
; return 0; }
EOF
-if { (eval echo configure:1800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1823: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_vprintf=yes"
else
@@ -1820,12 +1843,12 @@ fi
if test "$ac_cv_func_vprintf" != yes; then
echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:1824: checking for _doprnt" >&5
+echo "configure:1847: checking for _doprnt" >&5
if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1829 "configure"
+#line 1852 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char _doprnt(); below. */
@@ -1848,7 +1871,7 @@ _doprnt();
; return 0; }
EOF
-if { (eval echo configure:1852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func__doprnt=yes"
else
@@ -1874,7 +1897,7 @@ fi
echo $ac_n "checking for fmod in -lm""... $ac_c" 1>&6
-echo "configure:1878: checking for fmod in -lm" >&5
+echo "configure:1901: checking for fmod in -lm" >&5
ac_lib_var=`echo m'_'fmod | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1882,7 +1905,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1886 "configure"
+#line 1909 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1893,7 +1916,7 @@ int main() {
fmod()
; return 0; }
EOF
-if { (eval echo configure:1897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1924,12 +1947,12 @@ for ac_func in madvise memset memcpy memcmp fmod setlocale strchr strerror \
strftime strncasecmp strtod system tzset
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1928: checking for $ac_func" >&5
+echo "configure:1951: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1933 "configure"
+#line 1956 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1952,7 +1975,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1981,17 +2004,17 @@ for ac_hdr in unistd.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1985: checking for $ac_hdr" >&5
+echo "configure:2008: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1990 "configure"
+#line 2013 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1995: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2018: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2020,12 +2043,12 @@ done
for ac_func in getpagesize
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2024: checking for $ac_func" >&5
+echo "configure:2047: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2029 "configure"
+#line 2052 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2048,7 +2071,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2073,7 +2096,7 @@ fi
done
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:2077: checking for working mmap" >&5
+echo "configure:2100: checking for working mmap" >&5
if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2081,7 +2104,7 @@ else
ac_cv_func_mmap_fixed_mapped=no
else
cat > conftest.$ac_ext <<EOF
-#line 2085 "configure"
+#line 2108 "configure"
#include "confdefs.h"
/* Thanks to Mike Haertel and Jim Avera for this test.
@@ -2221,7 +2244,7 @@ main()
}
EOF
-if { (eval echo configure:2225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2248: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_func_mmap_fixed_mapped=yes
else
@@ -2244,8 +2267,15 @@ EOF
fi
-echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:2249: checking whether getpgrp takes no argument" >&5
+if (uname) > /dev/null 2>&1
+then
+ case `uname` in
+ *VMS*) cat >> confdefs.h <<\EOF
+#define GETPGRP_VOID 1
+EOF
+ ;;
+ *) echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
+echo "configure:2279: checking whether getpgrp takes no argument" >&5
if eval "test \"`echo '$''{'ac_cv_func_getpgrp_void'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2253,7 +2283,7 @@ else
{ echo "configure: error: cannot check getpgrp if cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2257 "configure"
+#line 2287 "configure"
#include "confdefs.h"
/*
@@ -2308,7 +2338,7 @@ main()
}
EOF
-if { (eval echo configure:2312: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2342: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_func_getpgrp_void=yes
else
@@ -2331,14 +2361,105 @@ EOF
fi
+ ;;
+ esac
+else
+ echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
+echo "configure:2369: checking whether getpgrp takes no argument" >&5
+if eval "test \"`echo '$''{'ac_cv_func_getpgrp_void'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: cannot check getpgrp if cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2377 "configure"
+#include "confdefs.h"
+
+/*
+ * If this system has a BSD-style getpgrp(),
+ * which takes a pid argument, exit unsuccessfully.
+ *
+ * Snarfed from Chet Ramey's bash pgrp.c test program
+ */
+#include <stdio.h>
+#include <sys/types.h>
+
+int pid;
+int pg1, pg2, pg3, pg4;
+int ng, np, s, child;
+
+main()
+{
+ pid = getpid();
+ pg1 = getpgrp(0);
+ pg2 = getpgrp();
+ pg3 = getpgrp(pid);
+ pg4 = getpgrp(1);
+
+ /*
+ * If all of these values are the same, it's pretty sure that
+ * we're on a system that ignores getpgrp's first argument.
+ */
+ if (pg2 == pg4 && pg1 == pg3 && pg2 == pg3)
+ exit(0);
+
+ child = fork();
+ if (child < 0)
+ exit(1);
+ else if (child == 0) {
+ np = getpid();
+ /*
+ * If this is Sys V, this will not work; pgrp will be
+ * set to np because setpgrp just changes a pgrp to be
+ * the same as the pid.
+ */
+ setpgrp(np, pg1);
+ ng = getpgrp(0); /* Same result for Sys V and BSD */
+ if (ng == pg1) {
+ exit(1);
+ } else {
+ exit(0);
+ }
+ } else {
+ wait(&s);
+ exit(s>>8);
+ }
+}
+
+EOF
+if { (eval echo configure:2432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_getpgrp_void=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_getpgrp_void=no
+fi
+rm -fr conftest*
+fi
+
+
+fi
+
+echo "$ac_t""$ac_cv_func_getpgrp_void" 1>&6
+if test $ac_cv_func_getpgrp_void = yes; then
+ cat >> confdefs.h <<\EOF
+#define GETPGRP_VOID 1
+EOF
+
+fi
+
+fi
echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6
-echo "configure:2337: checking for st_blksize in struct stat" >&5
+echo "configure:2458: checking for st_blksize in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2342 "configure"
+#line 2463 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -2346,7 +2467,7 @@ int main() {
struct stat s; s.st_blksize;
; return 0; }
EOF
-if { (eval echo configure:2350: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2471: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_blksize=yes
else
@@ -2367,12 +2488,12 @@ EOF
fi
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2371: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:2492: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2376 "configure"
+#line 2497 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -2381,7 +2502,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:2385: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@@ -2402,12 +2523,12 @@ EOF
fi
echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:2406: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:2527: checking whether struct tm is in sys/time.h or time.h" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2411 "configure"
+#line 2532 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <time.h>
@@ -2415,7 +2536,7 @@ int main() {
struct tm *tp; tp->tm_sec;
; return 0; }
EOF
-if { (eval echo configure:2419: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2540: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm=time.h
else
@@ -2436,12 +2557,12 @@ EOF
fi
echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:2440: checking for tm_zone in struct tm" >&5
+echo "configure:2561: checking for tm_zone in struct tm" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2445 "configure"
+#line 2566 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_cv_struct_tm>
@@ -2449,7 +2570,7 @@ int main() {
struct tm tm; tm.tm_zone;
; return 0; }
EOF
-if { (eval echo configure:2453: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2574: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm_zone=yes
else
@@ -2469,12 +2590,12 @@ EOF
else
echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:2473: checking for tzname" >&5
+echo "configure:2594: checking for tzname" >&5
if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2478 "configure"
+#line 2599 "configure"
#include "confdefs.h"
#include <time.h>
#ifndef tzname /* For SGI. */
@@ -2484,7 +2605,7 @@ int main() {
atoi(*tzname);
; return 0; }
EOF
-if { (eval echo configure:2488: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ac_cv_var_tzname=yes
else
@@ -2507,14 +2628,14 @@ fi
echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6
-echo "configure:2511: checking whether char is unsigned" >&5
+echo "configure:2632: checking whether char is unsigned" >&5
if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$GCC" = yes; then
# GCC predefines this symbol on systems where it applies.
cat > conftest.$ac_ext <<EOF
-#line 2518 "configure"
+#line 2639 "configure"
#include "confdefs.h"
#ifdef __CHAR_UNSIGNED__
yes
@@ -2536,7 +2657,7 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2540 "configure"
+#line 2661 "configure"
#include "confdefs.h"
/* volatile prevents gcc2 from optimizing the test away on sparcs. */
#if !defined(__STDC__) || __STDC__ != 1
@@ -2546,7 +2667,7 @@ main() {
volatile char c = 255; exit(c < 0);
}
EOF
-if { (eval echo configure:2550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2671: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_c_char_unsigned=yes
else
@@ -2570,12 +2691,12 @@ EOF
fi
echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:2574: checking for working const" >&5
+echo "configure:2695: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2579 "configure"
+#line 2700 "configure"
#include "confdefs.h"
int main() {
@@ -2624,7 +2745,7 @@ ccp = (char const *const *) p;
; return 0; }
EOF
-if { (eval echo configure:2628: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2749: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
@@ -2647,12 +2768,12 @@ fi
echo $ac_n "checking for ANSI stringizing capability""... $ac_c" 1>&6
-echo "configure:2651: checking for ANSI stringizing capability" >&5
+echo "configure:2772: checking for ANSI stringizing capability" >&5
if eval "test \"`echo '$''{'gawk_cv_c_stringize'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2656 "configure"
+#line 2777 "configure"
#include "confdefs.h"
#define x(y) #y
diff --git a/configure.in b/configure.in
index c5a9661c..27d10b85 100644
--- a/configure.in
+++ b/configure.in
@@ -1,7 +1,7 @@
dnl
dnl configure.in --- autoconf input file for gawk
dnl
-dnl Copyright (C) 1995, 96 the Free Software Foundation, Inc.
+dnl Copyright (C) 1995-1997 the Free Software Foundation, Inc.
dnl
dnl This file is part of GAWK, the GNU implementation of the
dnl AWK Programming Language.
@@ -31,6 +31,10 @@ AC_INIT(awk.h)
AC_PREREQ(2.12)
AC_CONFIG_HEADER(config.h:configh.in)
+dnl Additional argument stuff
+AC_ARG_ENABLE(bitops, [ --enable-bitops Enable Octal and Hex constants and bit functions], AC_DEFINE(BITOPS))
+AC_ARG_ENABLE(non-decimal-data, [ --enable-non-decimal-data Enable Octal and Hex constants as valid input data], AC_DEFINE(NONDECDATA))
+
dnl checks for programs
AC_PROG_YACC
AC_PROG_LN_S
@@ -99,7 +103,17 @@ dnl see if we have mmap
AC_FUNC_MMAP
dnl check for how to use getpgrp
-AC_FUNC_GETPGRP
+dnl have to hardwire it for VMS POSIX. Sigh.
+if (uname) > /dev/null 2>&1
+then
+ case `uname` in
+ *VMS*) AC_DEFINE(GETPGRP_VOID) ;;
+ *) AC_FUNC_GETPGRP
+ ;;
+ esac
+else
+ AC_FUNC_GETPGRP
+fi
dnl checks for structure members
AC_STRUCT_ST_BLKSIZE
diff --git a/custom.h b/custom.h
index e26a55b5..833bb623 100644
--- a/custom.h
+++ b/custom.h
@@ -11,7 +11,7 @@
*/
/*
- * Copyright (C) 1995, 96 the Free Software Foundation, Inc.
+ * Copyright (C) 1995-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -40,8 +40,6 @@
/* for VMS POSIX, from Pat Rankin, rankin@eql.caltech.edu */
#ifdef VMS_POSIX
#undef VMS
-#define GETPGRP_VOID /* autoconf's test for this tries to use
- `setpgrp()', which doesn't exist. */
#include "vms/redirect.h"
#endif
@@ -49,3 +47,13 @@
#ifdef __QNX__
#define GETPGRP_VOID 1
#endif
+
+/* For Amigas, from Fred Fish, fnf@ninemoons.com */
+#ifdef __amigaos__
+#define fork vfork
+#endif
+
+/* For sequent, based on email with Aron Griffis <agriffis@calypso.coat.com> */
+#ifdef _SEQUENT_
+#undef HAVE_MMAP
+#endif
diff --git a/dfa.c b/dfa.c
index 799670df..03dd9e7e 100644
--- a/dfa.c
+++ b/dfa.c
@@ -18,14 +18,14 @@
/* Written June, 1988 by Mike Haertel
Modified July, 1988 by Arthur David Olson to assist BMG speedups */
-#include <assert.h>
-#include <ctype.h>
-#include <stdio.h>
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#include <assert.h>
+#include <ctype.h>
+#include <stdio.h>
+
#ifdef STDC_HEADERS
#include <stdlib.h>
#else
@@ -51,19 +51,7 @@ extern void free();
#define isgraph(C) (isprint(C) && !isspace(C))
#endif
-#ifdef isascii
-#define ISALPHA(C) (isascii(C) && isalpha(C))
-#define ISUPPER(C) (isascii(C) && isupper(C))
-#define ISLOWER(C) (isascii(C) && islower(C))
-#define ISDIGIT(C) (isascii(C) && isdigit(C))
-#define ISXDIGIT(C) (isascii(C) && isxdigit(C))
-#define ISSPACE(C) (isascii(C) && isspace(C))
-#define ISPUNCT(C) (isascii(C) && ispunct(C))
-#define ISALNUM(C) (isascii(C) && isalnum(C))
-#define ISPRINT(C) (isascii(C) && isprint(C))
-#define ISGRAPH(C) (isascii(C) && isgraph(C))
-#define ISCNTRL(C) (isascii(C) && iscntrl(C))
-#else
+#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
#define ISALPHA(C) isalpha(C)
#define ISUPPER(C) isupper(C)
#define ISLOWER(C) islower(C)
@@ -75,6 +63,18 @@ extern void free();
#define ISPRINT(C) isprint(C)
#define ISGRAPH(C) isgraph(C)
#define ISCNTRL(C) iscntrl(C)
+#else
+#define ISALPHA(C) (isascii(C) && isalpha(C))
+#define ISUPPER(C) (isascii(C) && isupper(C))
+#define ISLOWER(C) (isascii(C) && islower(C))
+#define ISDIGIT(C) (isascii(C) && isdigit(C))
+#define ISXDIGIT(C) (isascii(C) && isxdigit(C))
+#define ISSPACE(C) (isascii(C) && isspace(C))
+#define ISPUNCT(C) (isascii(C) && ispunct(C))
+#define ISALNUM(C) (isascii(C) && isalnum(C))
+#define ISPRINT(C) (isascii(C) && isprint(C))
+#define ISGRAPH(C) (isascii(C) && isgraph(C))
+#define ISCNTRL(C) (isascii(C) && iscntrl(C))
#endif
#include "regex.h"
@@ -334,7 +334,7 @@ dfasyntax(bits, fold)
static char *lexstart; /* Pointer to beginning of input string. */
static char *lexptr; /* Pointer to next input character. */
-static lexleft; /* Number of characters remaining. */
+static int lexleft; /* Number of characters remaining. */
static token lasttok; /* Previous token returned; initially END. */
static int laststart; /* True if we're separated from beginning or (, |
only by zero-width characters. */
@@ -743,12 +743,13 @@ lex()
/* The above loop should consume at most a backslash
and some other character. */
abort();
+ return END; /* keeps pedantic compilers happy. */
}
/* Recursive descent parser for regular expressions. */
static token tok; /* Lookahead token. */
-static depth; /* Current depth of a hypothetical stack
+static int depth; /* Current depth of a hypothetical stack
holding deferred productions. This is
used to determine the depth that will be
required of the real stack later on in
@@ -1536,7 +1537,7 @@ dfastate(s, d, trans)
int state_newline; /* New state on a newline transition. */
int wants_letter; /* New state wants to know letter context. */
int state_letter; /* New state on a letter transition. */
- static initialized; /* Flag for static initialization. */
+ static int initialized; /* Flag for static initialization. */
int i, j, k;
/* Initialize the set of letters, if necessary. */
@@ -1874,12 +1875,12 @@ dfaexec(d, begin, end, newline, count, backref)
int *count;
int *backref;
{
- register s, s1, tmp; /* Current state. */
+ register int s, s1, tmp; /* Current state. */
register unsigned char *p; /* Current input character. */
- register **trans, *t; /* Copy of d->trans so it can be optimized
+ register int **trans, *t; /* Copy of d->trans so it can be optimized
into a register. */
- static sbit[NOTCHAR]; /* Table for anding with d->success. */
- static sbit_init;
+ static int sbit[NOTCHAR]; /* Table for anding with d->success. */
+ static int sbit_init;
if (! sbit_init)
{
@@ -2338,6 +2339,7 @@ inboth(left, right)
}
both = addlists(both, temp);
freelist(temp);
+ free(temp);
if (both == NULL)
return NULL;
}
diff --git a/doc/ChangeLog b/doc/ChangeLog
index e07d69b1..660436a1 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,26 @@
+Thu May 15 12:49:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Release 3.0.3: Release tar file made.
+
+Fri Apr 18 07:55:47 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * BETA Release 3.0.34: Release tar file made.
+
+Sun Apr 13 15:39:20 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Makefile.in ($(infodir)/gawk.info): exit 0 in case install-info
+ fails.
+
+Thu Jan 2 23:17:53 1997 Fred Fish <fnf@ninemoons.com>
+
+ * Makefile.in (awkcard.tr): Use ':' chars to separate parts of
+ sed command, since $(srcdir) may expand to something with '/'
+ characters in it, which confuses sed terribly.
+ * gawk.texi (Amiga Installation): Note change of configuration
+ from "m68k-cbm-amigados" to "m68k-amigaos". Point ftp users
+ towards current ADE distribution and not obsolete Aminet
+ "gcc" distribution. Change "FreshFish" to "Geek Gadgets".
+
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/doc/Makefile.in b/doc/Makefile.in
index 52ecc76d..293676b5 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -1,6 +1,6 @@
# Makefile for GNU Awk documentation.
#
-# Copyright (C) 1993-1996 the Free Software Foundation, Inc.
+# Copyright (C) 1993-1997 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
@@ -79,7 +79,7 @@ $(infodir)/gawk.info: gawk.info
done; \
if $(SHELL) -c 'install-info --version' > /dev/null 2>&1 ; \
then install-info --info-dir=$(infodir) gawk.info ; \
- else true ; fi
+ else true ; fi; exit 0
$(mandir)/gawk$(manext): gawk.1
$(INSTALL_DATA) $(srcdir)/gawk.1 $(mandir)/gawk$(manext)
@@ -108,7 +108,7 @@ postscript: dvi gawk.1 igawk.1 $(AWKCARD)
dvips -o gawk.ps gawk.dvi
awkcard.tr: awkcard.in
- sed 's/SRCDIR/$(srcdir)/' < $(srcdir)/awkcard.in > awkcard.tr
+ sed 's:SRCDIR:$(srcdir):' < $(srcdir)/awkcard.in > awkcard.tr
awkcard.ps: $(CARDFILES)
$(TROFF) $(CARDSRC) | $(SEDME) | cat $(srcdir)/setter.outline - > awkcard.ps
diff --git a/doc/awkcard.in b/doc/awkcard.in
index b68f01d8..4a02c878 100644
--- a/doc/awkcard.in
+++ b/doc/awkcard.in
@@ -1,6 +1,6 @@
.\" AWK Reference Card --- Arnold Robbins, arnold@gnu.ai.mit.edu
.\"
-.\" Copyright (C) 1996 Free Software Foundation, Inc.
+.\" Copyright (C) 1996, 97 Free Software Foundation, Inc.
.\"
.\" Permission is granted to make and distribute verbatim copies of
.\" this reference card provided the copyright notice and this permission
@@ -28,7 +28,12 @@
.ds MK \*(FCmawk\*(FR
.\"
.\"
-
+.de TD\" tab defaults
+.ta .2i .78i 1i 1.2i 1.4i 1.7i
+..
+.de TE
+.TD
+..
.sp
.ce
@@ -50,12 +55,12 @@ Command Line Arguments (\*(MK) 4
Conversions And Comparisons 10
Copying Permissions 16
Definitions 2
-Environment Variables (\*(GK) 16
+Environment Variables 16
Escape Sequences 7
Expressions 9
Fields 6
FTP Information 16
-Historical Features 16
+Historical Features (\*(GK) 16
Input Control 11
Lines And Statements 5
.ig
@@ -70,17 +75,17 @@ Records 6
Regular Expressions 5
Special Filenames 13
String Functions 14
-Time Functions 15
+Time Functions (\*(GK) 15
User-defined Functions 15
Variables 8\*(CX
.in -.2i
.EB "\s+2\f(HBCONTENTS\*(FR\s0"
.sp
-.ta .2i .78i 1i 1.2i 1.4i 1.7i
+.TD
.fi
\*(CD\*(FRThis reference card was written by Arnold Robbins.
Brian Kernighan and Michael Brennan reviewed it; we thank them
-them for their help.
+for their help.
.sp
.SL
.sp
@@ -90,7 +95,7 @@ them for their help.
\*(CD
.SL
.nf
-\*(FR\(co Copyright, 1996 Free Software Foundation
+\*(FR\(co Copyright, 1996, 1997 Free Software Foundation
59 Temple Place \(em Suite 330
Boston, MA 02111-1307 USA
.nf
@@ -104,7 +109,7 @@ Boston, MA 02111-1307 USA
.ES
\*(CDThis card describes POSIX AWK, as well as the three
freely available \*(AK implementations
-(see \fHFTP Information\fP, below).
+(see \fHFTP Information\fP below).
\*(CLCommon extensions (in two or more versions) are printed in light blue.
\*(CBFeatures specific to just one version\(emusually GNU AWK (\*(GK)\(emare
printed in dark blue.
@@ -113,11 +118,15 @@ printed in dark blue.
.sp .5
Several type faces are used to clarify the meaning:
.br
+.nr IN \w'\(bu '
\(bu \*(FC\*(CN\fP is used for computer input.
.br
+.fi
+.in +\n(INu
+.ti -\n(INu
\(bu\|\^\*(FI\*(IN\fP is used to indicate user input and for syntactic
-.br
-\0\|\^placeholders, such as \*(FIvariable\fP or \*(FIaction\fP.
+placeholders, such as \*(FIvariable\fP or \*(FIaction\fP.
+.in -\n(INu
.br
\(bu \*(RN is used for explanatory text.
.sp .5
@@ -125,13 +134,13 @@ Several type faces are used to clarify the meaning:
\*(FC3\*(FR,
\*(FC2.3\*(FR,
\*(FC.4\*(FR,
-\*(FC1.4e2\*(FR,
+\*(FC1.4e2\*(FR
or
\*(FC4.1E5\*(FR.
.sp .5
\*(FIescape sequences\fP \- a special sequence of characters beginning
with a backslash, used to describe otherwise unprintable characters.
-See \fHEscape Sequences\fP, below.
+(See \fHEscape Sequences\fP below.)
.sp .5
\*(FIstring\fP \- a group of characters enclosed in double quotes.
Strings may contain \*(FIescape sequences\*(FR.
@@ -140,7 +149,7 @@ Strings may contain \*(FIescape sequences\*(FR.
enclosed in forward slashes, or a dynamic regexp computed at run-time.
Regexp constants may contain \*(FIescape sequences\*(FR.
.sp .5
-\*(FIname\fP \- a variable, array, or function name.
+\*(FIname\fP \- a variable, array or function name.
.sp .5
\*(FIentry\fP(\*(FIN\fP) \- entry \*(FIentry\fP in section \*(FIN\fP of the
UNIX reference manual.
@@ -153,7 +162,6 @@ UNIX reference manual.
be missing.\*(CX
.EB \s+2\f(HBDEFINITIONS\*(FR\s0
-
.\" --- Command Line Arguments
.ES
.fi
@@ -161,84 +169,115 @@ be missing.\*(CX
setting variables before the \*(FCBEGIN\fP rule is run, and
the location of AWK program source code.
Implementation-specific command line arguments change
-the behaviour of the running interpreter.
+the behavior of the running interpreter.
.sp .5
-.nf
-\*(FC\-F \*(FIfs\*(FR use \*(FIfs\fP for the input field separator
-\*(FC\-v\*(FI var\*(FC\^=\^\*(FIval\*(FR assign the value \*(FIval\*(FR, to the variable \*(FIvar\*(FR,
- before execution of the program begins. Such
- variable values are available to the \*(FCBEGIN\fP rule
-\*(FC\-f \*(FIprog-file\*(FR read the AWK program source from the file
- \*(FIprog-file\*(FR, instead of from the first command
- line argument. Multiple \*(FC\-f\*(FR options may be used
-\*(FC\-\^\-\*(FR signal the end of options
+.TS
+expand;
+l lw(2.2i).
+\*(FC\-F \*(FIfs\*(FR use \*(FIfs\fP for the input field separator.
+\*(FC\-v\*(FI var\*(FC\^=\^\*(FIval\*(FR T{
+assign the value \*(FIval\*(FR, to the variable \*(FIvar\*(FR,
+before execution of the program begins. Such
+variable values are available to the \*(FCBEGIN\fP rule.
+T}
+\*(FC\-f \*(FIprog-file\*(FR T{
+read the AWK program source from the file
+\*(FIprog-file\*(FR, instead of from the first command
+line argument. Multiple \*(FC\-f\*(FR options may be used.
+T}
+\*(FC\-\^\-\*(FR signal the end of options.
+.TE
.sp .5
.fi
\*(CLThe following options are accepted by both \*(NK and \*(GK
\*(CR(ignored by \*(GK, not in \*(MK).\*(CL
.sp .5
.nf
-\*(FC\-mf \*(FIval\*(FR set the maximum number of fields to \*(FIval\fP
-\*(FC\-mr \*(FIval\*(FR set the maximum record size to \*(FIval\fP\*(CX
+.TS
+expand, tab(%);
+l lw(2.2i).
+\*(FC\-mf \*(FIval\*(FR%set the maximum number of fields to \*(FIval\fP
+\*(FC\-mr \*(FIval\*(FR%set the maximum record size to \*(FIval\fP\*(CX
+.TE
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (standard)\*(FR\s0"
.BT
-
-
.ES
.fi
\*(CDThe following options are specific to \*(GK. The \*(FC\-W\*(FR
forms are for full POSIX compliance.
.sp .5
-.nf
+.ig
+.\" This option is left undocumented, on purpose.
+\*(FC\-\^\-nostalgia\*(FR
+\*(FC\-W nostalgia\*(FR%T{
+provide a moment of nostalgia for
+long time \*(AK users.
+T}
+..
+.TS
+expand, tab(%);
+ls
+l lw(1.8i).
\*(FC\-\^\-field-separator \*(FIfs\*(FR
- just like \*(FC\-F\fP
-\*(FC\-\^\-assign \*(FIvar\*(FC\^=\^\*(FIval\*(FR just like \*(FC\-v\fP
-\*(FC\-\^\-file \*(FIprog-file \*(FRjust like \*(FC\-f\fP
+%just like \*(FC\-F\fP
+\*(FC\-\^\-assign \*(FIvar\*(FC\^=\^\*(FIval\*(FR%just like \*(FC\-v\fP
+\*(FC\-\^\-file \*(FIprog-file%\*(FRjust like \*(FC\-f\fP
\*(FC\-\^\-traditional\*(FR
\*(FC\-\^\-compat\*(FR
\*(FC\-W compat\*(FR
-\*(FC\-W traditional\*(FR turn off \*(GK-specific extensions
- (\*(FC\-\^\-traditional\*(FR preferred)
+\*(FC\-W traditional\*(FR%T{
+turn off \*(GK-specific extensions
+(\*(FC\-\^\-traditional\*(FR preferred).
+T}
\*(FC\-\^\-copyleft\*(FR
\*(FC\-\^\-copyright\*(FR
\*(FC\-W copyleft\*(FR
-\*(FC\-W copyright\*(FR print the short version of the GNU
- copyright information on \*(FCstdout\*(FR
+\*(FC\-W copyright\*(FR%T{
+print the short version of the GNU
+copyright information on \*(FCstdout\*(FR.
+T}
\*(FC\-\^\-help\*(FR
\*(FC\-\^\-usage\*(FR
\*(FC\-W help\*(FR
-\*(FC\-W usage\*(FR Print a short summary of the available
- options on \*(FCstdout\*(FR, then exit zero
+\*(FC\-W usage\*(FR%T{
+print a short summary of the available
+options on \*(FCstdout\*(FR, then exit zero.
+T}
\*(FC\-\^\-lint\*(FR
-\*(FC\-W lint\*(FR warn about constructs that are dubious
- or non-portable to other \*(AKs
+\*(FC\-W lint\*(FR%T{
+warn about constructs that are dubious
+or non-portable to other \*(AKs.
+T}
\*(FC\-\^\-lint\-old\*(FR
-\*(FC\-W lint\-old\*(FR warn about constructs that are not
- portable to the original version of
- Unix \*(AK
-.ig
-.\" This option is left undocumented, on purpose.
-\*(FC\-\^\-nostalgia\*(FR
-\*(FC\-W nostalgia\*(FR provide a moment of nostalgia for
- long time \*(AK users
-..
+\*(FC\-W lint\-old\*(FR%T{
+warn about constructs that are not
+portable to the original version of
+Unix \*(AK.
+T}
\*(FC\-\^\-posix\*(FR
-\*(FC\-W posix\*(FR disable common and GNU extensions.
- Enable \*(FIinterval expressions\*(FR in regular
- expression matching (see \fHRegular
- Expressions\fP, below)
+\*(FC\-W posix\*(FR%T{
+disable common and GNU extensions.
+Enable \*(FIinterval expressions\*(FR in regular
+expression matching (see \fHRegular
+Expressions\fP below).
+T}
\*(FC\-\^\-re\-interval\*(FR
-\*(FC\-W re\-interval\*(FR enable \*(FIinterval expressions\*(FR in regular
- expression matching (see \fHRegular
- Expressions\fP, below). Useful if
- \*(FC\-\^\-posix\*(FR is not specified
+\*(FC\-W re\-interval\*(FR%T{
+enable \*(FIinterval expressions\*(FR in regular
+expression matching (see \fHRegular
+Expressions\fP below). Useful if
+\*(FC\-\^\-posix\*(FR is not specified.
+T}
\*(FC\-\^\-source '\*(FItext\*(FC'\*(FR
-\*(FC\-W source '\*(FItext\*(FC'\*(FR use \*(FItext\*(FR as AWK program source code
+\*(FC\-W source '\*(FItext\*(FC'\*(FR%use \*(FItext\*(FR as AWK program source code.
\*(FC\-\^\-version\*(FR
-\*(FC\-W version\*(FR print version information on \*(FCstdout\fP
- and exit zero
+\*(FC\-W version\*(FR%T{
+print version information on \*(FCstdout\fP
+and exit zero.
+T}
+.TE
.sp .5
.fi
In compatibility mode,
@@ -246,7 +285,7 @@ any other options are flagged as illegal, but are otherwise ignored.
In normal operation, as long as program text has been supplied, unknown
options are passed on to the AWK program in
\*(FCARGV\*(FR
-for processing. This is most useful for running AWK
+for processing. This is most useful for running AWK
programs via the \*(FC#!\*(FR executable interpreter mechanism.\*(CB
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(GK\f(HB)\*(FR\s0"
@@ -256,28 +295,43 @@ programs via the \*(FC#!\*(FR executable interpreter mechanism.\*(CB
.fi
\*(CDThe following options are specific to \*(MK.
.sp .5
-.nf
-\*(FC\-W dump\*(FR print an assembly listing of the program to
- \*(FCstdout\fP and exit zero
-\*(FC\-W exec \*(FIfile\*(FR read program text from \*(FIfile\fP. No other
- options are processed. Useful with \*(FC#!\fP
-\*(FC\-W interactive\*(FR unbuffer \*(FCstdout\fP and line buffer \*(FCstdin\fP.
- Lines are always records, ignoriing \*(FCRS\fP
-\*(FC\-W posix_space\*(FR make \*(FC\en\*(FR separate fields when \*(FCRS = "\^"\fP
-\*(FC\-W sprintf=\*(FInum\*(FR adjust the size of \*(MK's internal
- \*(FCsprintf\*(FR buffer
-\*(FC\-W version\*(FR print version and copyright information on
- \*(FCstdout\fP and limit information on \*(FCstderr\fP
- and exit zero
+.fi
+.TS
+expand;
+l lw(1.8i).
+\*(FC\-W dump\*(FR T{
+print an assembly listing of the program to
+\*(FCstdout\fP and exit zero.
+T}
+\*(FC\-W exec \*(FIfile\*(FR T{
+read program text from \*(FIfile\fP. No other
+options are processed. Useful with \*(FC#!\fP.
+T}
+\*(FC\-W interactive\*(FR T{
+unbuffer \*(FCstdout\fP and line buffer \*(FCstdin\fP.
+Lines are always records, ignoring \*(FCRS\fP
+T}
+\*(FC\-W posix_space\*(FR T{
+\*(FC\en\*(FR separates fields when \*(FCRS = "\^"\fP.
+T}
+\*(FC\-W sprintf=\*(FInum\*(FR T{
+adjust the size of \*(MK's internal
+\*(FCsprintf\*(FR buffer.
+T}
+\*(FC\-W version\*(FR T{
+print version and copyright on
+\*(FCstdout\fP and limit information on \*(FCstderr\fP
+and exit zero.
+T}
+.TE
.sp .5
.fi
The options may be abbreviated using just the first letter, e.g.,
\*(FC\-We\*(FR,
-\*(FC\-Wv\*(FR,
+\*(FC\-Wv\*(FR
and so on.\*(CB
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(MK\f(HB)\*(FR\s0"
-
.\" --- Awk Program Execution
.ES
.fi
@@ -289,18 +343,18 @@ and optional function definitions.
\*(FCfunction \*(FIname\*(FC(\*(FIparameter list\*(FC) { \*(FIstatements\*(FC }\*(FR
.sp .5
\*(AK first reads the program source from the
-\*(FIprog-file\*(FR(s) if specified,
+\*(FIprog-file\*(FR(s), if specified,
\*(CBfrom arguments to \*(FC\-\^\-source\*(FR,\*(CD
or from the first non-option argument on the command line.
The program text is read as if all the \*(FIprog-file\*(FR(s)
\*(CBand command line
-source texts\*(CD had been concatenated together.
+source texts\*(CD had been concatenated.
.sp .5
AWK programs execute in the following order.
First, all variable assignments specified via the \*(FC\-v\fP
option are performed.
Next, \*(AK executes the code in the
-\*(FCBEGIN\fP rules(s) (if any), and then proceeds to read
+\*(FCBEGIN\fP rules(s), if any, and then proceeds to read
the files \*(FC1\fP through \*(FCARGC \- 1\fP in the \*(FCARGV\fP array.
(Adjusting \*(FCARGC\fP and \*(FCARGV\fP thus provides control over
the input files that will be processed.)
@@ -308,7 +362,7 @@ If there are no files named on the command line,
\*(AK reads the standard input.
.sp .5
If a command line argument has the form
-\*(FIvar\*(FC=\*(FIval\*(FR
+\*(FIvar\*(FC=\*(FIval\*(FR,
it is treated as a variable assignment. The variable
\*(FIvar\fP will be assigned the value \*(FIval\*(FR.
(This happens after any \*(FCBEGIN\fP rule(s) have been run.)
@@ -329,7 +383,7 @@ For each pattern that the record matches, the associated
The patterns are tested in the order they occur in the program.
.sp .5
Finally, after all the input is exhausted,
-\*(AK executes the code in the \*(FCEND\fP rule(s) (if any).
+\*(AK executes the code in the \*(FCEND\fP rule(s), if any.
.sp .5
If a program only has a \*(FCBEGIN\fP rule, no input files are processed.
If a program only has an \*(FCEND\fP rule, the input will be read.
@@ -344,7 +398,7 @@ If a program only has an \*(FCEND\fP rule, the input will be read.
.fi
\*(CDAWK is a line oriented language. The pattern comes first, and then the
action. Action statements are enclosed in \*(FC{\fP and \*(FC}\*(FR.
-Either the pattern may be missing, or the action may be missing, but
+Either the pattern or the action may be missing, but
not both. If the pattern is missing, the action will be
executed for every input record.
A missing action is equivalent to
@@ -360,19 +414,19 @@ a ``,'',
\*(FC{\*(FR,
\*(CB\*(FC?\*(FR,
\*(FC:\*(FR,\*(CD
-\*(FC&&\*(FR,
+\*(FC&&\*(FR
or
\*(FC||\*(FR
are automatically continued.
Lines ending in \*(FCdo\fP or \*(FCelse\fP
also have their statements automatically continued on the following line.
In other cases, a line can be continued by ending it with a ``\e'',
-in which case the newline will be ignored. However a ``\e'' after a
+in which case the newline will be ignored. However, a ``\e'' after a
\*(FC#\*(FR is not special.
.sp .5
Multiple statements may be put on one line by separating them with a ``;''.
This applies to both the statements within the action part of a
-pattern-action pair (the usual case),
+pattern-action pair (the usual case)
and to the pattern-action statements themselves.\*(CX
.EB "\s+2\f(HBLINES AND STATEMENTS\*(FR\s0"
@@ -422,12 +476,11 @@ _
.sp .5
.fi
\*(CRThe \*(FIr\*(FC{\*(FIn\*(FC,\*(FIm\*(FC}\*(FR notation is called an
-\*(FIinterval expression\fP. POSIX mandates it for AWK regexps, but
+\*(FIinterval expression\fP. POSIX mandates it for AWK regexps, but
most \*(AKs don't implement it. \*(CBUse \*(FC\-\^\-re\-interval\*(FR
or \*(FC\-\^\-posix\*(FR to enable
this feature in \*(GK.\*(CX
.EB "\s+2\f(HBREGULAR EXPRESSIONS\*(FR\s0"
-.ta .2i .78i 1i 1.2i 1.4i 1.7i
.BT
@@ -451,9 +504,6 @@ lp8 lp8 lp8 lp8.
.TE
.fi
.EB "\s+2\f(HBPOSIX CHARACTER CLASSES (\*(GK\f(HB)\*(FR\s0"
-.ta .2i .78i 1i 1.2i 1.4i 1.7i
-
-
.\" --- Records
.ES
@@ -481,8 +531,6 @@ a field separator, in addition to whatever value
when \*(FCRS = "\^"\fP.\*(CX
.EB \s+2\f(HBRECORDS\*(FR\s0
-
-
.\" --- Fields
.ES
.fi
@@ -513,19 +561,19 @@ overrides the use of \*(FCFIELDWIDTHS\*(FR,
and restores the default behavior.\*(CD
.sp .5
Each field in the input record may be referenced by its position,
-\*(FC$1\*(FR, \*(FC$2\*(FR, and so on.
+\*(FC$1\*(FR, \*(FC$2\*(FR and so on.
\*(FC$0\fP is the whole record.
-The value of a field may be assigned to as well.
+Fields may also be assigned new values.
.sp .5
The variable \*(FCNF\fP
is set to the total number of fields in the input record.
.sp .5
-References to non-existent fields (i.e. fields after \*(FC$NF\*(FR)
+References to non-existent fields (i.e., fields after \*(FC$NF\*(FR)
produce the null-string. However, assigning to a non-existent field
(e.g., \*(FC$(NF+2) = 5\*(FR) will increase the value of
\*(FCNF\*(FR, create any intervening fields with the null string as their value,
and cause the value of \*(FC$0\fP
-to be recomputed, with the fields being separated by the
+to be recomputed with the fields being separated by the
value of \*(FCOFS\*(FR.
References to negative numbered fields cause a fatal error.
Decreasing the value of \*(FCNF\fP causes the trailing fields to be lost
@@ -592,9 +640,16 @@ It does not combine with any other pattern expression.\*(CX
.fi
\*(CDWithin strings constants (\*(FC"..."\fP) and regexp
constants (\*(FC/.../\fP), escape sequences may be used to
-generate otherwise unprintable characters. This table lists
+generate otherwise unprintable characters. This table lists
the available escape sequences.
.sp .5
+.ig
+\*(CB\*(FCPROCINFO\fP T{
+elements of this array provide access to info
+about the running AWK program. See
+\*(AM for details.\*(CD
+T}
+..
.TS
center, tab(~);
lp8 lp8 lp8 lp8.
@@ -606,67 +661,107 @@ lp8 lp8 lp8 lp8.
\*(FC\e"\fP~double quote~\*(FC\e/\fP~forward slash\*(CX
.TE
.EB "\s+2\f(HBESCAPE SEQUENCES\*(FR\s0"
-.ta .2i .78i 1i 1.2i 1.4i 1.7i
.BT
.\" --- Variables
.ES
-.nf
-\*(FCARGC\fP number of command line arguments
-\*(CB\*(FCARGIND\fP index in \*(FCARGV\fP of current data file\*(CD
-\*(FCARGV\fP array of command line arguments. Indexed from
- 0 to \*(FCARGC\fP \- 1. Dynamically changing the
- contents of \*(FCARGV\fP can control the files used
- for data
-\*(FCCONVFMT\fP conversion format for numbers, default value
- is \*(FC"%.6g"\*(FR
-\*(FCENVIRON\fP array containing the the current environment.
- The array is indexed by the environment
- variables, each element being the value of
- that variable
-\*(CB\*(FCERRNO\fP contains a string describing the error when a
- redirection or read for \*(FCgetline\*(FR fails, or if
- \*(FCclose()\*(FR fails
-\*(CB\*(FCFIELDWIDTHS\fP white-space separated list of fieldwidths. Used
- to parse the input into fields of fixed width,
- instead of the value of \*(FCFS\fP\*(CD
-\*(FCFILENAME\fP name of the current input file. If no files given
- on the command line, \*(FCFILENAME\fP is ``\-''.
- \*(FCFILENAME\fP is undefined inside the \*(FCBEGIN\fP rule
- (unless set by \*(FCgetline\fP)
-\*(FCFNR\fP number of the input record in current input file
-\*(FCFS\fP input field separator, a space by default.
- See \fHFields\fP, above
-\*(CB\*(FCIGNORECASE\fP if non-zero, all regular expression and string
- operations ignore case. \*(CRIn versions of \*(GK
- prior to 3.0, \*(FCIGNORECASE\fP only affected
- regular expression operations and \*(FCindex()\*(FR\*(CD
-\*(FCNF\fP number of fields in the current input record
-\*(FCNR\fP total number of input records seen so far
-\*(FCOFMT\fP output format for numbers, \*(FC"%.6g"\*(FR, by default.
- \*(CROld versions of \*(AK also used this for number
- to string conversion instead of \*(FCCONVFMT\fP\*(CD
-\*(FCOFS\fP output field separator, a space by default
-\*(FCORS\fP output record separator, a newline by default
-.ig
-\*(CB\*(FCPROCINFO\fP elements of this array provide access to info
- about the running AWK program. See
- \*(AM for details\*(CD
-..
-\*(FCRS\fP input record separator, a newline by default.
- See \fHRecords\fP, above
-\*(CB\*(FCRT\fP record terminator. \*(GK sets \*(FCRT\fP to the input
- text that matched the character or regular
- expression specified by \*(FCRS\*(FR\*(CD
-\*(FCRSTART\fP index of the first character matched by
- \*(FCmatch()\*(FR; 0 if no match
-\*(FCRLENGTH\fP length of the string matched by \*(FCmatch()\*(FR;
- \-1 if no match
-\*(FCSUBSEP\fP character(s) used to separate multiple subscripts
- in array elements, by default \*(FC"\e034"\*(FR. See
- \fHArrays\fP, below\*(CX
+.fi
+.TS
+expand;
+l lw(2i).
+\*(FCARGC\fP T{
+number of command line arguments.
+T}
+\*(CB\*(FCARGIND\fP T{
+index in \*(FCARGV\fP of current data file.\*(CD
+T}
+\*(FCARGV\fP T{
+array of command line arguments. Indexed from
+0 to \*(FCARGC\fP \- 1. Dynamically changing the
+contents of \*(FCARGV\fP can control the files used
+for data.
+T}
+\*(FCCONVFMT\fP T{
+conversion format for numbers, default value
+is \*(FC"%.6g"\*(FR.
+T}
+\*(FCENVIRON\fP T{
+array containing the the current environment.
+The array is indexed by the environment
+variables, each element being the value of
+that variable.
+T}
+\*(CB\*(FCERRNO\fP T{
+contains a string describing the error when a
+redirection or read for \*(FCgetline\*(FR fails, or if
+\*(FCclose()\*(FR fails.
+T}
+\*(FCFIELDWIDTHS\fP T{
+white-space separated list of fieldwidths. Used
+to parse the input into fields of fixed width,
+instead of the value of \*(FCFS\fP.\*(CD
+T}
+\*(FCFILENAME\fP T{
+name of the current input file. If no files given
+on the command line, \*(FCFILENAME\fP is ``\-''.
+\*(FCFILENAME\fP is undefined inside the \*(FCBEGIN\fP rule
+(unless set by \*(FCgetline\fP).
+T}
+\*(FCFNR\fP T{
+number of the input record in current input file.
+T}
+\*(FCFS\fP T{
+input field separator, a space by default
+(see \fHFields\fP above).
+T}
+\*(CB\*(FCIGNORECASE\fP T{
+if non-zero, all regular expression and string
+operations ignore case. \*(CRIn versions of \*(GK
+prior to 3.0, \*(FCIGNORECASE\fP only affected
+regular expression operations and \*(FCindex()\*(FR.\*(CD
+T}
+\*(FCNF\fP T{
+number of fields in the current input record.
+T}
+\*(FCNR\fP T{
+total number of input records seen so far.
+T}
+\*(FCOFMT\fP T{
+output format for numbers, \*(FC"%.6g"\*(FR, by default.
+\*(CROld versions of \*(AK also used this for number
+to string conversion instead of \*(FCCONVFMT\fP.\*(CD
+T}
+\*(FCOFS\fP T{
+output field separator, a space by default.
+T}
+\*(FCORS\fP T{
+output record separator, a newline by default.
+T}
+\*(FCRS\fP T{
+input record separator, a newline by default
+(see \fHRecords\fP above).
+T}
+\*(CB\*(FCRT\fP T{
+record terminator. \*(GK sets \*(FCRT\fP to the input
+text that matched the character or regular
+expression specified by \*(FCRS\*(FR.\*(CD
+T}
+\*(FCRSTART\fP T{
+index of the first character matched by
+\*(FCmatch()\*(FR; 0 if no match.
+T}
+\*(FCRLENGTH\fP T{
+length of the string matched by \*(FCmatch()\*(FR;
+\-1 if no match.
+T}
+\*(FCSUBSEP\fP T{
+character(s) used to separate multiple subscripts
+in array elements, by default \*(FC"\e034"\*(FR. (see
+\fHArrays\fP below).\*(CX
+T}
+.TE
.EB \s+2\f(HBVARIABLES\*(FR\s0
.BT
@@ -674,14 +769,14 @@ lp8 lp8 lp8 lp8.
.\" --- Arrays
.ES
.fi
-\*(CDArrays are subscripted with an expression between square brackets
+\*(CDAn arrays subscript is an expression between square brackets
(\*(FC[ \*(FRand \*(FC]\*(FR).
-If the expression is an expression list
-\*(FC(\*(FIexpr\*(FC, \*(FIexpr \*(FC...)\*(FR
-then the array subscript is a string consisting of the
+If the expression is a list
+\*(FC(\*(FIexpr\*(FC, \*(FIexpr \*(FC...)\*(FR,
+then the subscript is a string consisting of the
concatenation of the (string) value of each expression,
separated by the value of the \*(FCSUBSEP\fP variable.
-This facility simulates multiply dimensioned
+This simulates multi-dimensional
arrays. For example:
.nf
.sp .5
@@ -689,14 +784,14 @@ arrays. For example:
x[i, j, k] = "hello, world\en"\*(FR
.sp .5
.fi
-assigns the string \*(FC"hello, world\en"\*(FR to the element of the array
+assigns \*(FC"hello, world\en"\*(FR to the element of the array
\*(FCx\fP
-which is indexed by the string \*(FC"A\e034B\e034C"\*(FR. All arrays in AWK
-are associative, i.e. indexed by string values.
+indexed by the string \*(FC"A\e034B\e034C"\*(FR. All arrays in AWK
+are associative, i.e., indexed by string values.
.sp .5
-The special operator \*(FCin\fP may be used in an \*(FCif\fP
-or \*(FCwhile\fP statement to see if an array has an index consisting
-of a particular value.
+Use the special operator \*(FCin\fP in an \*(FCif\fP
+or \*(FCwhile\fP statement to see if a particular value is
+an array index.
.sp .5
.nf
\*(FCif (val in array)
@@ -706,24 +801,23 @@ of a particular value.
If the array has multiple subscripts, use
\*(FC(i, j) in array\*(FR.
.sp .5
-The \*(FCin\fP construct may also be used in a \*(FCfor\fP
+Use the \*(FCin\fP construct in a \*(FCfor\fP
loop to iterate over all the elements of an array.
.sp .5
-An element may be deleted from an array using the
-\*(FCdelete\fP statement.
-\*(CLThe \*(FCdelete\fP
-statement can also delete the entire contents of an array,
-just by specifying the array name without a subscript.\*(CX
+Use the \*(FCdelete\fP statement to delete an
+element from an array.
+\*(CLSpecifying just the array name without a subscript in
+the \*(FCdelete\fP
+statement deletes the entire contents of an array.\*(CX
.EB \s+2\f(HBARRAYS\*(FR\s0
-
.\" --- Expressions
.ES
.fi
-\*(CDExpressions are used as patterns, for controlling conditional
+\*(CDExpressions are used as patterns, for controlling conditional action
statements, and to produce parameter values when calling functions.
Expressions may also be used as simple statements,
-particularly if they have side-effects, such as assignment.
+particularly if they have side-effects such as assignment.
Expressions mix \*(FIoperands\fP and \*(FIoperators\fP. Operands are
constants, fields, variables, array elements, and the return
values from function calls (both built-in and user-defined).
@@ -741,10 +835,16 @@ functions, mean \*(FC$0 ~ /\*(FIpat\*(FC/\*(FR.
.sp .5
The AWK operators, in order of decreasing precedence, are
.sp .5
-.nf
+.fi
+.TS
+expand;
+l lw(1.8i).
\*(FC(\&...)\*(FR grouping
-\*(FC$\fP field reference
-\*(FC++ \-\^\-\fP increment and decrement, both prefix and postfix
+\*(FC$\fP field reference
+\*(FC++ \-\^\-\fP T{
+increment and decrement,
+prefix and postfix
+T}
\*(FC^\fP \*(CL\*(FC**\*(FR\*(CD exponentiation
\*(FC+ \- !\fP unary plus, unary minus, and logical negation
\*(FC* / %\fP multiplication, division, and modulus
@@ -754,12 +854,16 @@ The AWK operators, in order of decreasing precedence, are
\*(FC<= >=\fP less than or equal, greater than or equal
\*(FC!= ==\fP not equal, equal
\*(FC~ !~\fP regular expression match, negated match
-\*(FCin\fP array membership
-\*(FC&&\fP logical AND, short circuit
-\*(FC||\fP logical OR, short circuit
-\*(FC?\^:\fP in-line conditional expression
+\*(FCin\fP array membership
+\*(FC&&\fP logical AND, short circuit
+\*(FC||\fP logical OR, short circuit
+\*(FC?\^:\fP in-line conditional expression
+.T&
+l s
+l lw(1.8i).
\*(FC=\0+=\0\-=\0*=\0/=\0%=\0^=\0\*(CL**=\*(CD\fP
- assignment operators\*(CX
+ assignment operators\*(CX
+.TE
.EB \s+2\f(HBEXPRESSIONS\*(FR\s0
@@ -768,7 +872,7 @@ The AWK operators, in order of decreasing precedence, are
.\" --- Conversions and Comparisons
.ES
.fi
-\*(CDVariables and fields may be (floating point) numbers, or strings, or both.
+\*(CDVariables and fields may be (floating point) numbers, strings or both.
Context determines how the value of a variable is interpreted. If used in
a numeric expression, it will be treated as a number, if used as a string
it will be treated as a string.
@@ -788,15 +892,15 @@ Comparisons are performed as follows:
If two variables are numeric, they are compared numerically.
If one value is numeric and the other has a string value that is a
``numeric string,'' then comparisons are also done numerically.
-Otherwise, the numeric value is converted to a string and a string
+Otherwise, the numeric value is converted to a string, and a string
comparison is performed.
Two strings are compared, of course, as strings.
\*(CRAccording to the POSIX standard, even if two strings are
-numeric strings, a numeric comparison is performed. However, this is
+numeric strings, a numeric comparison is performed. However, this is
clearly incorrect, and none of the three free \*(AK\*(FRs do this.\*(CD
.sp .5
Note that string constants, such as \*(FC"57"\fP, are \*(FInot\fP
-numeric strings, they are string constants. The idea of ``numeric string''
+numeric strings, they are string constants. The idea of ``numeric string''
only applies to fields, \*(FCgetline\fP input,
\*(FCFILENAME\*(FR, \*(FCARGV\fP elements, \*(FCENVIRON\fP
elements and the elements of an array created by
@@ -830,41 +934,64 @@ construction.\*(CB
.EB "\s+2\f(HBLOCALIZATION\*(FR\s0"
..
+.ps +2
+.ce 1
+\*(CD\fHISBN: 0-916151-97-2\*(FR
+.ps -2
+
.BT
.\" --- Input Control
.ES
-.nf
-\*(CD\*(FCclose(\*(FIfile\*(FC)\*(FR close input file or pipe
-\*(FCgetline\fP set \*(FC$0\fP from next input record;
- set \*(FCNF\*(FR, \*(FCNR\*(FR, \*(FCFNR\*(FR
-\*(FCgetline < \*(FIfile\*(FR set \*(FC$0\fP from next record of \*(FIfile\*(FR; set \*(FCNF\*(FR
-\*(FCgetline \*(FIv\*(FR set \*(FIv\fP from next input record;
- set \*(FCNR\*(FR, \*(FCFNR\*(FR
-\*(FCgetline \*(FIv \*(FC< \*(FIfile\*(FR set \*(FIv\fP from next record of \*(FIfile\*(FR
-\*(FIcmd \*(FC| getline\*(FR pipe into \*(FCgetline\*(FR; set \*(FC$0\*(FR, \*(FCNF\*(FR
-\*(FIcmd \*(FC| getline \*(FIv\*(FR pipe into \*(FCgetline\*(FR; set \*(FIv\*(FR
-\*(FCnext\fP stop processing the current input
- record. Read next input record and
- start over with the first pattern in the
- program. Upon end of the input data,
- execute any \*(FCEND\fP rule(s)
-\*(CL\*(FCnextfile\fP stop processing the current input file.
- The next input record comes from the
- next input file. \*(FCFILENAME\fP \*(CBand
- \*(FCARGIND\fP\*(CL are updated, \*(FCFNR\fP is reset to 1,
- and processing starts over with the first
- pattern in the AWK program. Upon end
- of input data, execute any \*(FCEND\fP rule(s).
- \*(CREarlier versions of \*(GK used
- \*(FCnext file\*(FR, as two words. This
- generates a warning message and will
- eventually be removed. \*(CR\*(MK does not
- currently support \*(FCnextfile\*(FR\*(CD
+.fi
+.TS
+expand;
+l lw(1.8i).
+\*(CD\*(FCclose(\*(FIfile\*(FC)\*(FR close input file or pipe.
+\*(FCgetline\fP T{
+set \*(FC$0\fP from next input record;
+set \*(FCNF\*(FR, \*(FCNR\*(FR, \*(FCFNR\*(FR.
+T}
+\*(FCgetline < \*(FIfile\*(FR set \*(FC$0\fP from next record of \*(FIfile\*(FR; set \*(FCNF\*(FR.
+\*(FCgetline \*(FIv\*(FR T{
+set \*(FIv\fP from next input record;
+set \*(FCNR\*(FR, \*(FCFNR\*(FR.
+T}
+\*(FCgetline \*(FIv \*(FC< \*(FIfile\*(FR set \*(FIv\fP from next record of \*(FIfile\*(FR.
+\*(FIcmd \*(FC| getline\*(FR pipe into \*(FCgetline\*(FR; set \*(FC$0\*(FR, \*(FCNF\*(FR.
+\*(FIcmd \*(FC| getline \*(FIv\*(FR pipe into \*(FCgetline\*(FR; set \*(FIv\*(FR.
+.TE
+.fi
+.in +.2i
+.ti -.2i
+\*(FCnext\fP
+.br
+stop processing the current input
+record. Read next input record and
+start over with the first pattern in the
+program. Upon end of the input data,
+execute any \*(FCEND\fP rule(s).
+.br
+.ti -.2i
+\*(CL\*(FCnextfile\fP
+.br
+stop processing the current input file.
+The next input record comes from the
+next input file. \*(FCFILENAME\fP \*(CBand
+\*(FCARGIND\fP\*(CL are updated, \*(FCFNR\fP is reset to 1,
+and processing starts over with the first
+pattern in the AWK program. Upon end
+of input data, execute any \*(FCEND\fP rule(s).
+\*(CREarlier versions of \*(GK used
+\*(FCnext file\*(FR, as two words. This
+generates a warning message and will
+eventually be removed. \*(CR\*(MK does not
+currently support \*(FCnextfile\*(FR.\*(CD
+.in -.2i
.sp .5
.fi
-The \*(FCgetline\*(FR command returns 0 on end of file, and \-1 on an
+\*(FCgetline\*(FR returns 0 on end of file, and \-1 on an
error.\*(CX
.EB "\s+2\f(HBINPUT CONTROL\*(FR\s0"
@@ -875,7 +1002,7 @@ error.\*(CX
.ti -.2i
\*(CD\*(FCclose(\*(FIfile\*(FC)\*(FR
.br
-close output file or pipe
+close output file or pipe.
.ti -.2i
\*(CL\*(FCfflush(\*(FR[\*(FIfile\^\*(FR]\*(FC)\*(FR
.br
@@ -883,28 +1010,28 @@ flush any buffers associated
with the open output file or pipe \*(FIfile\*(FR.\*(CD
\*(CBIf \*(FIfile\fP is missing, then standard output is flushed.
If \*(FIfile\fP is the null string, then all open output files and pipes
-are flushed \*(CR(not \*(NK)\*(CD
+are flushed \*(CR(not \*(NK)\*(CD.
.ti -.2i
\*(FCprint\fP
.br
-print the current record. The output record is terminated
-with the value of \*(FCORS\fP
+print the current record. The output record is terminated
+with the value of \*(FCORS\fP.
.ti -.2i
\*(FCprint \*(FIexpr-list\*(FR
.br
-print expressions. Each expression is separated
-by the value of \*(FCOFS\fP. The output record is
-terminated with the value of \*(FCORS\fP
+print expressions. Each expression is separated
+by the value of \*(FCOFS\fP. The output record is
+terminated with the value of \*(FCORS\fP.
.ti -.2i
\*(FCprintf \*(FIfmt\*(FC, \*(FIexpr-list\*(FR
.br
-format and print (see \fHPrintf Formats\fP, below)
+format and print (see \fHPrintf Formats\fP below).
.ti -.2i
\*(FCsystem(\*(FIcmd\*(FC)\*(FR
.br
execute the command \*(FIcmd\*(FR,
and return the exit status
-\*(CR(may not be available on non-POSIX systems)\*(CD
+\*(CR(may not be available on non-POSIX systems)\*(CD.
.sp .5
.in -.2i
I/O redirections may be used with both \*(FCprint\fP and \*(FCprintf\fP.
@@ -948,49 +1075,75 @@ accept the following conversion specification formats:
\*(FC%g\fP use \*(FC%e\fP or \*(FC%f\fP, whichever is shorter, with
nonsignificant zeros suppressed
\*(FC%G\fP like \*(FC%g\fP, but use \*(FC%E\fP instead of \*(FC%e\*(FR
-\*(FC%o\fP an unsigned octal number (the integer part)
+\*(FC%o\fP an unsigned octal integer
\*(FC%s\fP a character string
-\*(FC%x\fP an unsigned hexadecimal number (integer part)
-\*(FC%X\fP like \*(FC%x\fP, but use \*(FCABCDEF\fP instead of \*(FCabcdef\*(FR
-\*(FC%%\fP A single \*(FC%\fP character; no argument is converted
+\*(FC%x\fP an unsigned hexadecimal integer
+\*(FC%X\fP like \*(FC%x\fP, but use \*(FCABCDEF\fP for 10\(en15
+\*(FC%%\fP A literal \*(FC%\fP; no argument is converted
.sp .5
.fi
Optional, additional parameters may lie between the \*(FC%\fP
and the control letter:
.sp .5
-.nf
-\*(FC\-\fP left-justify the expression within its field
-\*(FIspace\fP for numeric conversions, prefix positive values
- with a space, and negative values with a
- minus sign
-\*(FC+\fP used before the \*(FIwidth\fP modifier means to always
- supply a sign for numeric conversions, even if
- the data to be formatted is positive. The \*(FC+\fP
- overrides the space modifier
-\*(FC#\fP use an ``alternate form'' for some control letters.
- For \*(FC%o\*(FR, supply a leading zero.
- For \*(FC%x\*(FR, and \*(FC%X\*(FR, supply a leading \*(FC0x\*(FR or \*(FC0X\*(FR for a
- nonzero result.
- For \*(FC%e\*(FR, \*(FC%E\*(FR, and \*(FC%f\*(FR, the result will always
- contain a decimal point.
- For \*(FC%g\*(FR, and \*(FC%G\*(FR, trailing zeros are not removed
-\*(FC0\fP a leading zero acts as a flag, indicating output
- should be padded with zeroes instead of spaces.
- This applies even to non-numeric output formats.
- Only has an effect when the field width is wider
- than the value to be printed
-\*(FIwidth\fP pad the field to this width. The field is normally
- padded with spaces. If the \*(FC0\fP flag has been used,
- pad with zeroes
-\*(FC\&.\*(FIprec\*(FR specifies the precision to use when printing.
- For the \*(FC%e\*(FR, \*(FC%E\*(FR, and \*(FC%f\*(FR formats, the number of
- digits to print to the right of the decimal point.
- For the \*(FC%g\*(FR and \*(FC%G\fP formats, the maximum
- number of significant digits.
- For the \*(FC%d\*(FR, \*(FC%o\*(FR, \*(FC%i\*(FR, \*(FC%u\*(FR, \*(FC%x\*(FR, and \*(FC%X\fP formats, the
- minimum number of digits to print.
- For the \*(FC%s\fP format, the maximum number of
- characters to print
+.TS
+expand;
+l lw(2.2i).
+\*(FC\-\fP T{
+left-justify the expression within its field.
+T}
+\*(FIspace\fP T{
+for numeric conversions, prefix positive values
+with a space and negative values with a
+minus sign.
+T}
+\*(FC+\fP T{
+used before the \*(FIwidth\fP modifier means to always
+supply a sign for numeric conversions, even if
+the data to be formatted is positive. The \*(FC+\fP
+overrides the space modifier.
+T}
+\*(FC#\fP T{
+use an ``alternate form'' for some control letters.
+T}
+ \*(FC%o\*(FR T{
+supply a leading zero.
+T}
+ \*(FC%x\*(FR, \*(FC%X\*(FR T{
+supply a leading \*(FC0x\*(FR or \*(FC0X\*(FR for a nonzero result.
+T}
+ \*(FC%e\*(FR, \*(FC%E\*(FR, \*(FC%f\*(FR T{
+the result always has a decimal point.
+T}
+ \*(FC%g\*(FR, \*(FC%G\*(FR T{
+trailing zeros are not removed.
+T}
+\*(FC0\fP T{
+a leading zero acts as a flag, indicating output
+should be padded with zeroes instead of spaces.
+This applies even to non-numeric output formats.
+Only has an effect when the field width is wider
+than the value to be printed.
+T}
+\*(FIwidth\fP T{
+pad the field to this width. The field is normally
+padded with spaces. If the \*(FC0\fP flag has been used,
+pad with zeroes.
+The meaning of the \*(FIwidth\*(FR varies by control letter:
+T}
+ \*(FC%d\*(FR, \*(FC%o\*(FR, \*(FC%i\*(FR,
+ \*(FC%u\*(FR, \*(FC%x\*(FR, \*(FC%X\fP T{
+the minimum number of digits to print.
+T}
+ \*(FC%e\*(FR, \*(FC%E\*(FR, \*(FC%f\*(FR T{
+the number of digits to print to the right of the decimal point.
+T}
+ \*(FC%g\*(FR, \*(FC%G\fP T{
+the maximum number of significant digits.
+T}
+ \*(FC%s\fP T{
+the maximum number of characters to print.
+T}
+.TE
.sp .5
.fi
The dynamic \*(FIwidth\fP and \*(FIprec\fP capabilities of the ANSI C
@@ -1008,44 +1161,60 @@ the argument list to \*(FCprintf\fP or \*(FCsprintf()\*(FR.\*(CX
.ES
.fi
\*(CDWhen doing I/O redirection from either \*(FCprint\fP
-or \*(FCprintf\fP into a file, or via \*(FCgetline\fP
+or \*(FCprintf\fP into a file or via \*(FCgetline\fP
from a file, all three implementations of \*(FCawk\fP
-recognize certain special filenames internally. These filenames
+recognize certain special filenames internally. These filenames
allow access to open file descriptors inherited from the
parent process (usually the shell).
-These file names may also be used on the command line to name data files.
+These filenames may also be used on the command line to name data files.
The filenames are:
.sp .5
-.nf
-\*(FC"-"\fP standard input
+.TS
+expand;
+l lw(2i).
+\*(FC"\-"\fP standard input
\*(FC/dev/stdin\fP standard input \*(CR(not \*(MK)\*(CD
\*(FC/dev/stdout\fP standard output
\*(FC/dev/stderr\fP standard error output
+.TE
.sp .5
.fi
\*(CBThe following names are specific to \*(GK.
.sp .5
-.nf
-\*(FC/dev/fd/\^\*(FIn\*(FR file associated with the open file descriptor \*(FIn\*(FR
+.TS
+expand;
+l lw(2i).
+\*(FC/dev/fd/\^\*(FIn\*(FR T{
+file associated with the open file descriptor \*(FIn\*(FR
+T}
+.TE
.sp .5
.fi
Other special filenames provide access to information about the running
\*(FCgawk\fP process.
-The filenames are:\*(FR
+Reading from these files returns a single record.
+The filenames and what they return are:\*(FR
.sp .5
+.TS
+expand;
+l lw(2i).
+\*(FC/dev/pid\fP process ID of current process
+\*(FC/dev/ppid\fP parent process ID of current process
+\*(FC/dev/pgrpid\fP process group ID of current process
+\*(FC/dev/user\fP T{
.nf
-\*(FC/dev/pid\fP returns process ID of current process
-\*(FC/dev/ppid\fP returns parent process ID of current process
-\*(FC/dev/pgrpid\fP returns process group ID of current process
-\*(FC/dev/user\fP returns a single newline-terminated record.
- The fields are separated with spaces.
- \*(FC$1\fP is the return value of \*(FIgetuid\*(FR(2),
- \*(FC$2\fP is the return value of \*(FIgeteuid\*(FR(2),
- \*(FC$3\fP is the return value of \*(FIgetgid\*(FR(2) , and
- \*(FC$4\fP is the return value of \*(FIgetegid\*(FR(2).
- Any additional fields are the group IDs returned
- by \*(FIgetgroups\*(FR(2). Multiple groups may not be
- supported on all systems
+a single newline-terminated record.
+The fields are separated with spaces.
+\*(FC$1\fP is the return value of \*(FIgetuid\*(FR(2),
+\*(FC$2\fP is the return value of \*(FIgeteuid\*(FR(2),
+\*(FC$3\fP is the return value of \*(FIgetgid\*(FR(2) , and
+\*(FC$4\fP is the return value of \*(FIgetegid\*(FR(2).
+.fi
+Any additional fields are the group IDs returned
+by \*(FIgetgroups\*(FR(2). Multiple groups may not be
+supported on all systems.
+T}
+.TE
.sp .5
.fi
.ig
@@ -1063,19 +1232,25 @@ Be aware that you will have to change your programs.\*(CL
.\" --- Builtin Numeric Functions
.ES
-.nf
-\*(CD\*(FCatan2(\*(FIy\*(FC, \*(FIx\*(FC)\*(FR returns the arctangent of \*(FIy/x\fP in radians
-\*(FCcos(\*(FIexpr\*(FC)\*(FR the cosine of \*(FIexpr\fP, which is in radians
-\*(FCexp(\*(FIexpr\*(FC)\*(FR the exponential function (\*(FIe \*(FC^ \*(FIx\*(FR)
-\*(FCint(\*(FIexpr\*(FC)\*(FR truncates to integer
-\*(FClog(\*(FIexpr\*(FC)\*(FR the natural logarithm function (base \*(FIe\^\*(FR)
-\*(FCrand()\fP returns a random number between 0 and 1
-\*(FCsin(\*(FIexpr\*(FC)\*(FR the sine of \*(FIexpr\fP, which is in radians
-\*(FCsqrt(\*(FIexpr\*(FC)\*(FR the square root function
-\&\*(FCsrand(\*(FR[\*(FIexpr\^\*(FR]\*(FC)\*(FR uses \*(FIexpr\fP as a new seed for the random number
- generator. If no \*(FIexpr\fP, the time of day is used.
- Returns previous seed for the random number
- generator\*(CX
+.fi
+.TS
+expand;
+l lw(2i).
+\*(CD\*(FCatan2(\*(FIy\*(FC, \*(FIx\*(FC)\*(FR the arctangent of \*(FIy/x\fP in radians.
+\*(FCcos(\*(FIexpr\*(FC)\*(FR the cosine of \*(FIexpr\fP, which is in radians.
+\*(FCexp(\*(FIexpr\*(FC)\*(FR the exponential function (\*(FIe \*(FC^ \*(FIx\*(FR).
+\*(FCint(\*(FIexpr\*(FC)\*(FR truncates to integer.
+\*(FClog(\*(FIexpr\*(FC)\*(FR the natural logarithm function (base \*(FIe\^\*(FR).
+\*(FCrand()\fP a random number between 0 and 1.
+\*(FCsin(\*(FIexpr\*(FC)\*(FR the sine of \*(FIexpr\fP, which is in radians.
+\*(FCsqrt(\*(FIexpr\*(FC)\*(FR the square root function.
+\&\*(FCsrand(\*(FR[\*(FIexpr\^\*(FR]\*(FC)\*(FR T{
+uses \*(FIexpr\fP as a new seed for the random number
+generator. If no \*(FIexpr\fP, the time of day is used.
+Returns previous seed for the random number
+generator.\*(CX
+T}
+.TE
.EB "\s+2\f(HBNUMERIC FUNCTIONS\*(FR\s0"
@@ -1090,86 +1265,87 @@ Be aware that you will have to change your programs.\*(CL
\*(CB\*(FCgensub(\*(FIr\*(FC, \*(FIs\*(FC, \*(FIh \*(FR[\*(FC, \*(FIt\*(FR]\*(FC)\*(FR
.br
search the target string
-\*(FIt\fP for matches of the regular expression \*(FIr\*(FR. If
+\*(FIt\fP for matches of the regular expression \*(FIr\*(FR. If
\*(FIh\fP is a string beginning with \*(FCg\fP or \*(FCG\*(FR,
-replace all matches of \*(FIr\fP with \*(FIs\*(FR. Otherwise, \*(FIh\fP
-is a number indicating which match of \*(FIr\fP to replace. If no
-\*(FIt\fP is supplied, \*(FC$0\fP is used instead. Within the
+replace all matches of \*(FIr\fP with \*(FIs\*(FR. Otherwise, \*(FIh\fP
+is a number indicating which match of \*(FIr\fP to replace. If no
+\*(FIt\fP is supplied, \*(FC$0\fP is used instead. Within the
replacement text \*(FIs\*(FR, the sequence \*(FC\e\*(FIn\*(FR,
where \*(FIn\fP is a digit from 1 to 9, may be used to indicate just
-the text that matched the \*(FIn\*(FR'th parenthesized subexpression.
+the text that matched the \*(FIn\*(FRth parenthesized subexpression.
The sequence \*(FC\e0\fP represents the entire matched text, as does
-the character \*(FC&\*(FR. Unlike \*(FCsub()\fP and \*(FCgsub()\*(FR,
+the character \*(FC&\*(FR. Unlike \*(FCsub()\fP and \*(FCgsub()\*(FR,
the modified string is returned as the result of the function,
-and the original target string is \*(FInot\fP changed\*(CD
+and the original target string is \*(FInot\fP changed.\*(CD
.ti -.2i
\*(FCgsub(\*(FIr\*(FC, \*(FIs \*(FR[\*(FC, \*(FIt\*(FR]\*(FC)\*(FR
.br
for each substring matching the
regular expression \*(FIr\fP in the string \*(FIt\*(FR, substitute the
-string \*(FIs\*(FR, and return the number of substitutions. If
-\*(FIt\fP is not supplied, use \*(FC$0\*(FR. An \*(FC&\fP in the
+string \*(FIs\*(FR, and return the number of substitutions. If
+\*(FIt\fP is not supplied, use \*(FC$0\*(FR. An \*(FC&\fP in the
replacement text is replaced with the text that was actually matched.
-Use \*(FC\e&\fP to get a literal \*(FC&\*(FR. See \*(AM
+Use \*(FC\e&\fP to get a literal \*(FC&\*(FR. See \*(AM
for a fuller discussion of the rules for \*(FC&\*(FR's and backslashes
-in the replacement text of \*(CB\*(FCgensub()\*(FR,\*(CD \*(FCsub()\*(FR,
+in the replacement text of \*(CB\*(FCgensub()\*(FR,\*(CD \*(FCsub()\*(FR
and \*(FCgsub()\*(FR
.ti -.2i
\*(FCindex(\*(FIs\*(FC, \*(FIt\*(FC)\*(FR
.br
returns the index of the string
-\*(FIt\fP in the string \*(FIs\*(FR, or 0 if \*(FIt\fP is not present
+\*(FIt\fP in the string \*(FIs\*(FR, or 0 if \*(FIt\fP is not present.
.ti -.2i
\*(FClength(\*(FR[\*(FIs\*(FR]\*(FC)\*(FR
.br
returns the length of the string
-\*(FIs\*(FR, or the length of \*(FC$0\fP if \*(FIs\fP is not supplied
+\*(FIs\*(FR, or the length of \*(FC$0\fP if \*(FIs\fP is not supplied.
.ti -.2i
\*(FCmatch(\*(FIs\*(FC, \*(FIr\*(FC)\*(FR
.br
returns the position in
\*(FIs\fP where the regular expression \*(FIr\fP occurs, or 0 if
-\*(FIr\fP is not present, and sets the values of \*(FCRSTART\fP
-and \*(FCRLENGTH\*(FR
+\*(FIr\fP is not present, and sets the values of variables
+\*(FCRSTART\fP
+and \*(FCRLENGTH\*(FR.
.ti -.2i
\*(FCsplit(\*(FIs\*(FC, \*(FIa \*(FR[\*(FC, \*(FIr\*(FR]\*(FC)\*(FR
.br
splits the string
-\*(FIs\fP into the array \*(FIa\fP on the regular expression \*(FIr\*(FR,
+\*(FIs\fP into the array \*(FIa\fP using the regular expression \*(FIr\*(FR,
and returns the number of fields. If \*(FIr\fP is omitted, \*(FCFS\fP
-is used instead. The array \*(FIa\fP is cleared first.
+is used instead. The array \*(FIa\fP is cleared first.
Splitting behaves identically to field splitting.
-See \fHFields\fP, above
+(See \fHFields\fP, above.)
.ti -.2i
\*(FCsprintf(\*(FIfmt\*(FC, \*(FIexpr-list\*(FC)\*(FR
.br
prints \*(FIexpr-list\fP
-according to \*(FIfmt\*(FR, and returns the resulting string
+according to \*(FIfmt\*(FR, and returns the resulting string.
.ti -.2i
\*(FCsub(\*(FIr\*(FC, \*(FIs \*(FR[\*(FC, \*(FIt\*(FR]\*(FC)\*(FR
.br
just like
-\*(FCgsub()\*(FR, but only the first matching substring is replaced
+\*(FCgsub()\*(FR, but only the first matching substring is replaced.
.ti -.2i
\*(FCsubstr(\*(FIs\*(FC, \*(FIi \*(FR[\*(FC, \*(FIn\*(FR]\*(FC)\*(FR
.br
returns the at most
\*(FIn\*(FR-character substring of \*(FIs\fP starting at \*(FIi\*(FR.
-If \*(FIn\fP is omitted, the rest of \*(FIs\fP is used
+If \*(FIn\fP is omitted, the rest of \*(FIs\fP is used.
.ti -.2i
\*(FCtolower(\*(FIstr\*(FC)\*(FR
.br
returns a copy of the string \*(FIstr\*(FR,
with all the upper-case characters in \*(FIstr\fP translated to their
-corresponding lower-case counterparts. Non-alphabetic characters are
-left unchanged
+corresponding lower-case counterparts. Non-alphabetic characters are
+left unchanged.
.ti -.2i
\*(FCtoupper(\*(FIstr\*(FC)\*(FR
.br
returns a copy of the string \*(FIstr\*(FR,
with all the lower-case characters in \*(FIstr\fP translated to their
-corresponding upper-case counterparts. Non-alphabetic characters are
-left unchanged\*(CX
+corresponding upper-case counterparts. Non-alphabetic characters are
+left unchanged.\*(CX
.in -.2i
.EB "\s+2\f(HBSTRING FUNCTIONS\*(FR\s0"
@@ -1194,25 +1370,25 @@ formatting them.
turns \*(FIdatespec\fP into a time
stamp of the same form as returned by \*(FCsystime()\*(FR.
The \*(FIdatespec\fP is a string of the form
-\*(FC"\*(FIYYYY MM DD HH MM SS\*(FC"\*(FR
+\*(FC"\*(FIYYYY MM DD HH MM SS\*(FC"\*(FR.
..
.ti -.2i
\*(FCstrftime(\*(FR[\*(FIformat \*(FR[\*(FC, \*(FItimestamp\*(FR]]\*(FC)\*(FR
.br
formats \*(FItimestamp\fP
-according to the specification in \*(FIformat\*(FR. The
+according to the specification in \*(FIformat\*(FR. The
\*(FItimestamp\fP should be of the same form as returned by
\*(FCsystime()\*(FR.
-If \*(FItimestamp\fP is missing, the current time of day is used. If
+If \*(FItimestamp\fP is missing, the current time of day is used. If
\*(FIformat\fP is missing, a default format equivalent to the output
-of \*(FIdate\*(FR(1) will be used
+of \*(FIdate\*(FR(1) will be used.
.ti -.2i
\*(FCsystime()\fP
.br
returns the current time of day as the number of
-seconds since the Epoch\*(CB
+seconds since the Epoch.\*(CB
.in -.2i
-.EB "\s+2\f(HBTIME FUNCTIONS\*(FR\s0"
+.EB "\s+2\f(HBTIME FUNCTIONS (\*(GK\f(HB)\*(FR\s0"
@@ -1229,7 +1405,7 @@ seconds since the Epoch\*(CB
.sp .5
.fi
Functions are executed when they are called from within expressions
-in either patterns or actions. Actual parameters supplied in the function
+in either patterns or actions. Actual parameters supplied in the function
call instantiate the formal parameters declared in the function.
Arrays are passed by reference, other variables are passed by value.
.sp .5
@@ -1248,7 +1424,7 @@ real parameters by extra spaces in the parameter list. For example:
.fi
.sp .5
The left parenthesis in a function call is required
-to immediately follow the function name,
+to immediately follow the function name
without any intervening white space.
This is to avoid a syntactic ambiguity with the concatenation operator.
This restriction does not apply to the built-in functions.
@@ -1311,30 +1487,41 @@ Historical AWK implementations have treated such usage as
equivalent to the \*(FCnext\fP statement.
\*(GK will support this usage if \*(FC\-\^\-traditional\fP
has been specified.\*(CB
-.EB "\s+2\f(HBHISTORICAL FEATURES\*(FR\s0"
+.EB "\s+2\f(HBHISTORICAL FEATURES (\*(GK\f(HB)\*(FR\s0"
.\" --- FTP Information
.ES
.nf
\*(CDHost: \*(FCftp.gnu.ai.mit.edu\*(FR
-File: \*(FC/pub/gnu/gawk-3.0.2.tar.gz\fP
- GNU \*(AK (\*(GK). There may be a later version
+File: \*(FC/pub/gnu/gawk-3.0.3.tar.gz\fP
+.in +.2i
+.fi
+GNU \*(AK (\*(GK). There may be a later version.
+.in -.2i
+.nf
.sp .5
Host: \*(FCnetlib.bell-labs.com\*(FR
File: \*(FC/netlib/research/awk.bundle.Z\fP
- \*(NK. This version requires an ANSI C compiler;
- GCC (the GNU C compiler) works well
+.in +.2i
+.fi
+\*(NK. This version requires an ANSI C compiler;
+GCC (the GNU C compiler) works well.
+.in -.2i
+.nf
.sp .5
Host: \*(FCftp.whidbey.net\*(FR
File: \*(FC/pub/brennan/mawk1.3.3.tar.gz\fP
- Michael Brennan's \*(MK. There may be a newer version\*(CX
+.in +.2i
+.fi
+Michael Brennan's \*(MK. There may be a newer version.\*(CX
+.in -.2i
.EB "\s+2\f(HBFTP INFORMATION\*(FR\s0"
.\" --- Copying Permissions
.ES
.fi
-\*(CDCopyright \(co 1996 Free Software Foundation, Inc.
+\*(CDCopyright \(co 1996, 1997 Free Software Foundation, Inc.
.sp .5
Permission is granted to make and distribute verbatim copies of this
reference card provided the copyright notice and this permission notice
diff --git a/doc/colors b/doc/colors
index e600f64c..cae1d0eb 100644
--- a/doc/colors
+++ b/doc/colors
@@ -1,7 +1,7 @@
.\" AWK Reference Card --- Arnold Robbins, arnold@gnu.ai.mit.edu
.\" This file sets the colors to use.
.\"
-.\" Copyright (C) 1996 Free Software Foundation, Inc.
+.\" Copyright (C) 1996,97 Free Software Foundation, Inc.
.\"
.\" Permission is granted to make and distribute verbatim copies of
.\" this reference card provided the copyright notice and this permission
@@ -31,12 +31,9 @@ CB - color blue
CD - color dark, i.e. black
CX - color boX, i.e. for the surrounding boxes (red for now)
..
-.ds CR \X'ps: exec .768 0 .047 setrgbcolor'
-.ds CG \X'ps: exec 0 .819 .259 setrgbcolor'
-.\" this is deepskyblue3, pretty good
-...ds CL \X'ps: exec 0 .604 .804 setrgbcolor'
-.\" this is deepskyblue2, even better, use this for now
-.ds CL \X'ps: exec 0 .698 .933 setrgbcolor'
-.ds CB \X'ps: exec 0 .219 .941 setrgbcolor'
-.ds CD \X'ps: exec 0 0 0 setrgbcolor'
+.ds CR \X'ps: exec 0 .96 .65 0 setcmykcolor'
+.ds CG \X'ps: exec 1.0 0 .51 .43 setcmykcolor'
+.ds CL \X'ps: exec .69 .34 0 0 setcmykcolor'
+.ds CB \X'ps: exec 1 .72 0 .06 setcmykcolor'
+.ds CD \X'ps: exec 1 1 1 1 setcmykcolor'
.ds CX \*(CG
diff --git a/doc/gawk.info b/doc/gawk.info
index 680fbab3..a9242e2b 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -1,4 +1,5 @@
-This is gawk.info, produced by makeinfo version 4.0 from gawk.texi.
+This is Info file gawk.info, produced by Makeinfo version 1.67 from the
+input file ./gawk.texi.
INFO-DIR-SECTION Programming Languages
START-INFO-DIR-ENTRY
@@ -8,10 +9,11 @@ END-INFO-DIR-ENTRY
This file documents `awk', a program that you can use to select
particular records in a file and perform operations upon them.
- This is Edition 1.0.1 of `The GNU Awk User's Guide', for the
-3.0.1 version of the GNU implementation of AWK.
+ This is Edition 1.0.3 of `Effective AWK Programming', for the
+3.0.3 version of the GNU implementation of AWK.
- Copyright (C) 1989, 1991, 92, 93, 96 Free Software Foundation, Inc.
+ Copyright (C) 1989, 1991, 92, 93, 96, 97 Free Software Foundation,
+Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
@@ -36,8 +38,8 @@ General Introduction
This file documents `awk', a program that you can use to select
particular records in a file and perform operations upon them.
- This is Edition 1.0.1 of `The GNU Awk User's Guide',
-for the 3.0.1 version of the GNU implementation
+ This is Edition 1.0.3 of `Effective AWK Programming',
+for the 3.0.3 version of the GNU implementation
of AWK.
* Menu:
@@ -171,13 +173,13 @@ of AWK.
* Concatenation:: Concatenating strings.
* Assignment Ops:: Changing the value of a variable or a field.
* Increment Ops:: Incrementing the numeric value of a variable.
-* Truth Values:: What is ``true'' and what is ``false''.
+* Truth Values:: What is "true" and what is "false".
* Typing and Comparison:: How variables acquire types, and how this
affects comparison of numbers and strings with
`<', etc.
* Boolean Ops:: Combining comparison expressions using boolean
- operators `||' (``or''), `&&'
- (``and'') and `!' (``not'').
+ operators `||' ("or"), `&&'
+ ("and") and `!' ("not").
* Conditional Exp:: Conditional expressions select between two
subexpressions under control of a third
subexpression.
@@ -314,7 +316,7 @@ of AWK.
* Time Functions Summary:: Built-in time functions.
* String Constants Summary:: Escape sequences in strings.
* Functions Summary:: Defining and calling functions.
-* Historical Features:: Some undocumented but supported ``features''.
+* Historical Features:: Some undocumented but supported "features".
* Gawk Distribution:: What is in the `gawk' distribution.
* Getting:: How to get the distribution.
* Extracting:: How to extract the distribution.
@@ -346,13 +348,10 @@ of AWK.
To Miriam, for making me complete.
-
To Chana, for the joy you bring us.
-
To Rivka, for the exponential increase.
-
To Nachum, for the added dimension.

@@ -383,8 +382,8 @@ to MS-DOS and OS/2 PC's, Atari and Amiga micro-computers, and VMS.
---------- Footnotes ----------
- (1) These commands are available on POSIX compliant systems, as well
-as on traditional Unix based systems. If you are using some other
+ (1) These commands are available on POSIX compliant systems, as
+well as on traditional Unix based systems. If you are using some other
operating system, you still need to be familiar with the ideas of I/O
redirection and pipes.
@@ -436,25 +435,23 @@ copy of the GPL is included for your reference (*note GNU GENERAL
PUBLIC LICENSE: Copying.). The GPL applies to the C language source
code for `gawk'.
- As of this writing (1995), the only major component of the GNU
-environment still uncompleted is the operating system kernel, and work
-proceeds apace on that. A shell, an editor (Emacs), highly portable
-optimizing C, C++, and Objective-C compilers, a symbolic debugger, and
-dozens of large and small utilities (such as `gawk'), have all been
-completed and are freely available.
-
- Until the GNU operating system is released, the FSF recommends the
-use of Linux, a freely distributable, Unix-like operating system for
-80386 and other systems. There are many books on Linux. One freely
-available one is `Linux Installation and Getting Started', by Matt
-Welsh. Many Linux distributions are available, often in computer
-stores or bundled on CD-ROM with books about Linux. Also, the FSF
-provides a Linux distribution ("Debian"); contact them for more
-information. *Note Getting the `gawk' Distribution: Getting, for the
-FSF's contact information. (There are two other freely available,
-Unix-like operating systems for 80386 and other systems, NetBSD and
-FreeBSD. Both are based on the 4.4-Lite Berkeley Software Distribution,
-and both use recent versions of `gawk' for their versions of `awk'.)
+ A shell, an editor (Emacs), highly portable optimizing C, C++, and
+Objective-C compilers, a symbolic debugger, and dozens of large and
+small utilities (such as `gawk'), have all been completed and are
+freely available. As of this writing (early 1997), the GNU operating
+system kernel (the HURD), has been released, but is still in an early
+stage of development.
+
+ Until the GNU operating system is more fully developed, you should
+consider using Linux, a freely distributable, Unix-like operating
+system for 80386, DEC Alpha, Sun SPARC and other systems. There are
+many books on Linux. One freely available one is `Linux Installation
+and Getting Started', by Matt Welsh. Many Linux distributions are
+available, often in computer stores or bundled on CD-ROM with books
+about Linux. (There are three other freely available, Unix-like
+operating systems for 80386 and other systems, NetBSD, FreeBSD,and
+OpenBSD. All are based on the 4.4-Lite Berkeley Software Distribution,
+and they use recent versions of `gawk' for their versions of `awk'.)
This Info file itself has gone through several previous, preliminary
editions. I started working on a preliminary draft of `The GAWK
@@ -470,12 +467,12 @@ Since then there have been several minor revisions, notably Edition
0.14 of November 1992 that was published by the FSF in January of 1993,
and Edition 0.16 of August 1993.
- Edition 1.0 of `The GNU Awk User's Guide' represents a significant
+ Edition 1.0 of `Effective AWK Programming' represents a significant
re-working of `The GAWK Manual', with much additional material. The
FSF and I agree that I am now the primary author. I also felt that it
needed a more descriptive title.
- `The GNU Awk User's Guide' will undoubtedly continue to evolve. An
+ `Effective AWK Programming' will undoubtedly continue to evolve. An
electronic version comes with the `gawk' distribution from the FSF. If
you find an error in this Info file, please report it! *Note Reporting
Problems and Bugs: Bugs, for information on submitting problem reports
@@ -509,13 +506,13 @@ Close, Christopher ("Topher") Eliot, Michael Lijewski, Pat Rankin,
Miriam Robbins, and Michal Jaegermann.
The following people provided many helpful comments for Edition 1.0
-of `The GNU Awk User's Guide': Karl Berry, Michael Brennan, Darrel
+of `Effective AWK Programming': Karl Berry, Michael Brennan, Darrel
Hankerson, Michal Jaegermann, Michael Lijewski, and Miriam Robbins.
Pat Rankin, Michal Jaegermann, Darrel Hankerson and Scott Deifik
updated their respective sections for Edition 1.0.
Robert J. Chassell provided much valuable advice on the use of
-Texinfo. He also deserves special thanks for convincing me _not_ to
+Texinfo. He also deserves special thanks for convincing me *not* to
title this Info file `How To Gawk Politely'. Karl Berry helped
significantly with the TeX part of Texinfo.
@@ -555,11 +552,9 @@ I also must acknowledge my gratitude to G-d, for the many opportunities
He has sent my way, as well as for the gifts He has given me with which
to take advantage of those opportunities.
-
-
Arnold Robbins
Atlanta, Georgia
-January, 1996
+February, 1997

File: gawk.info, Node: What Is Awk, Next: Getting Started, Prev: Preface, Up: Top
@@ -644,7 +639,7 @@ Library of `awk' Functions: Library Functions.; also *note Practical
your memory about a particular feature.
If you find terms that you aren't familiar with, try looking them up
-in the glossary (*note Glossary::).
+in the glossary (*note Glossary::.).
Most of the time complete `awk' programs are used as examples, but in
some of the more advanced sections, only the part of the `awk' program
@@ -660,6 +655,9 @@ should be of interest.
Dark Corners
------------
+ Who opened that window shade?!?
+ Count Dracula
+
Until the POSIX standard (and `The Gawk Manual'), many features of
`awk' were either poorly documented, or not documented at all.
Descriptions of such features (often called "dark corners") are noted
@@ -851,7 +849,7 @@ specific to the GNU implementation, we use the term `gawk'.
---------- Footnotes ----------
- (1) Often, these systems use `gawk' for their `awk' implementation!
+ (1) Often, these systems use `gawk' for their `awk' implementation!

File: gawk.info, Node: Running gawk, Next: Very Simple, Prev: Names, Up: Getting Started
@@ -1039,7 +1037,7 @@ like this:
: The colon ensures execution by the standard shell.
awk 'PROGRAM' "$@"
- Using this technique, it is _vital_ to enclose the PROGRAM in single
+ Using this technique, it is *vital* to enclose the PROGRAM in single
quotes to protect it from interpretation by the shell. If you omit the
quotes, only a shell wizard can predict the results.
@@ -1051,11 +1049,11 @@ systems obey this convention, but many do.)
---------- Footnotes ----------
- (1) The `#!' mechanism works on Linux systems, Unix systems derived
+ (1) The `#!' mechanism works on Linux systems, Unix systems derived
from Berkeley Unix, System V Release 4, and some System V Release 3
systems.
- (2) The line beginning with `#!' lists the full file name of an
+ (2) The line beginning with `#!' lists the full file name of an
interpreter to be run, and an optional initial command line argument to
pass to that interpreter. The operating system then runs the
interpreter with the given argument and the full argument list of the
@@ -1126,7 +1124,7 @@ special shell characters.
In an `awk' rule, either the pattern or the action can be omitted,
but not both. If the pattern is omitted, then the action is performed
-for _every_ input line. If the action is omitted, the default action
+for *every* input line. If the action is omitted, the default action
is to print all lines that match the pattern.
Thus, we could leave out the action (the `print' statement and the
@@ -1163,7 +1161,7 @@ the pattern and also has `print $0' as the action. Each rule's action
is enclosed in its own pair of braces.
This `awk' program prints every line that contains the string `12'
-_or_ the string `21'. If a line contains both strings, it is printed
+*or* the string `21'. If a line contains both strings, it is printed
twice, once by each rule.
This is what happens if we run this program on our two sample data
@@ -1299,11 +1297,11 @@ expression or a string.
*Caution: backslash continuation does not work as described above
with the C shell.* Continuation with backslash works for `awk'
-programs in files, and also for one-shot programs _provided_ you are
+programs in files, and also for one-shot programs *provided* you are
using a POSIX-compliant shell, such as the Bourne shell or Bash, the
GNU Bourne-Again shell. But the C shell (`csh') behaves differently!
There, you must use two backslashes in a row, followed by a newline.
-Note also that when using the C shell, _every_ newline in your awk
+Note also that when using the C shell, *every* newline in your awk
program must be escaped with a backslash. To illustrate:
% awk 'BEGIN { \
@@ -1317,11 +1315,11 @@ analogous to the standard shell's `$' and `>'.
`awk' is a line-oriented language. Each rule's action has to begin
on the same line as the pattern. To have the pattern and action on
-separate lines, you _must_ use backslash continuation--there is no
+separate lines, you *must* use backslash continuation--there is no
other way.
Note that backslash continuation and comments do not mix. As soon as
-`awk' sees the `#' that starts a comment, it ignores _everything_ on
+`awk' sees the `#' that starts a comment, it ignores *everything* on
the rest of the line. For example:
$ gawk 'BEGIN { print "dont panic" # a friendly \
@@ -1389,10 +1387,10 @@ can avoid the (usually lengthy) compilation part of the typical
edit-compile-test-debug cycle of software development.
Complex programs have been written in `awk', including a complete
-retargetable assembler for eight-bit microprocessors (*note Glossary::,
-for more information) and a microcode assembler for a special purpose
-Prolog computer. However, `awk''s capabilities are strained by tasks of
-such complexity.
+retargetable assembler for eight-bit microprocessors (*note
+Glossary::., for more information) and a microcode assembler for a
+special purpose Prolog computer. However, `awk''s capabilities are
+strained by tasks of such complexity.
If you find yourself writing `awk' scripts of more than, say, a few
hundred lines, you might consider using a different programming
@@ -1490,7 +1488,7 @@ that matches every input record whose text belongs to that set.
both. Such a regexp matches any string that contains that sequence.
Thus, the regexp `foo' matches any string containing `foo'. Therefore,
the pattern `/foo/' matches any input record containing the three
-characters `foo', _anywhere_ in the record. Other kinds of regexps let
+characters `foo', *anywhere* in the record. Other kinds of regexps let
you specify more complicated classes of strings.
* Menu:
@@ -1546,8 +1544,8 @@ statements. (*Note Control Statements in Actions: Statements.)
`EXP !~ /REGEXP/'
This is true if the expression EXP (taken as a character string)
- is _not_ matched by REGEXP. The following example matches, or
- selects, all input records whose first field _does not_ contain
+ is *not* matched by REGEXP. The following example matches, or
+ selects, all input records whose first field *does not* contain
the upper-case letter `J':
$ awk '$1 !~ /J/' inventory-shipped
@@ -1752,7 +1750,7 @@ themselves.
if ("line1\nLINE 2" ~ /1$/) ...
`.'
- The period, or dot, matches any single character, _including_ the
+ The period, or dot, matches any single character, *including* the
newline character. For example:
.P
@@ -1768,7 +1766,7 @@ themselves.
Other versions of `awk' may not be able to match the NUL character.
`[...]'
- This is called a "character list". It matches any _one_ of the
+ This is called a "character list". It matches any *one* of the
characters that are enclosed in the square brackets. For example:
[MVX]
@@ -1806,7 +1804,7 @@ themselves.
notion of what is an alphabetic character differs in the USA and
in France.
- A character class is only valid in a regexp _inside_ the brackets
+ A character class is only valid in a regexp *inside* the brackets
of a character list. Character classes consist of `[:', a keyword
denoting the class, and `:]'. Here are the character classes
defined by the POSIX standard.
@@ -1855,7 +1853,7 @@ themselves.
characters, you had to write `/[A-Za-z0-9]/'. If your character
set had other alphabetic characters in it, this would not match
them. With the POSIX character classes, you can write
- `/[[:alnum:]]/', and this will match _all_ the alphabetic and
+ `/[[:alnum:]]/', and this will match *all* the alphabetic and
numeric characters in your character set.
Two additional special sequences can appear in character lists.
@@ -1863,7 +1861,7 @@ themselves.
symbols (called "collating elements") that are represented with
more than one character, as well as several characters that are
equivalent for "collating", or sorting, purposes. (E.g., in
- French, a plain "e" and a grave-accented "e`" are equivalent.)
+ French, a plain "e" and a grave-accented "`e" are equivalent.)
Collating Symbols
A "collating symbol" is a multi-character collating element
@@ -1876,8 +1874,8 @@ themselves.
An "equivalence class" is a locale-specific name for a list of
characters that are equivalent. The name is enclosed in `[='
and `=]'. For example, the name `e' might be used to
- represent all of "e," "e`," and "e'." In this case, `[[=e]]'
- is a regexp that matches any of `e', `e'', or `e`'.
+ represent all of "e," "`e," and "'e." In this case, `[[=e]]'
+ is a regexp that matches any of `e', `'e', or ``e'.
These features are very valuable in non-English speaking locales.
@@ -1888,7 +1886,7 @@ themselves.
`[^ ...]'
This is a "complemented character list". The first character after
- the `[' _must_ be a `^'. It matches any characters _except_ those
+ the `[' *must* be a `^'. It matches any characters *except* those
in the square brackets. For example:
[^0-9]
@@ -1926,7 +1924,7 @@ themselves.
of one `p' followed by any number of `h's. This will also match
just `p' if no `h's are present.
- The `*' repeats the _smallest_ possible preceding expression.
+ The `*' repeats the *smallest* possible preceding expression.
(Use parentheses if you wish to repeat a larger expression.) It
finds as many repetitions as possible. For example:
@@ -1980,7 +1978,7 @@ themselves.
`egrep' consistent with each other.
However, since old programs may use `{' and `}' in regexp
- constants, by default `gawk' does _not_ match interval expressions
+ constants, by default `gawk' does *not* match interval expressions
in regexps. If either `--posix' or `--re-interval' are specified
(*note Command Line Options: Options.), then interval expressions
are allowed in regexps.
@@ -2068,7 +2066,7 @@ current method of using `\y' for the GNU `\b' appears to be the lesser
of two evils.
The various command line options (*note Command Line Options:
-Options.) control how `gawk' interprets characters in regexps.
+Options.) control how `gawk' interprets characters in regexps.
No options
In the default case, `gawk' provide all the facilities of POSIX
@@ -2120,8 +2118,8 @@ converts the first field to lower-case before matching against it.
This will work in any POSIX-compliant implementation of `awk'.
Another method, specific to `gawk', is to set the variable
-`IGNORECASE' to a non-zero value (*note Built-in Variables::). When
-`IGNORECASE' is not zero, _all_ regexp and string operations ignore
+`IGNORECASE' to a non-zero value (*note Built-in Variables::.). When
+`IGNORECASE' is not zero, *all* regexp and string operations ignore
case. Changing the value of `IGNORECASE' dynamically controls the case
sensitivity of your program as it runs. Case is significant by default
because `IGNORECASE' (like most variables) is initialized to zero.
@@ -2171,8 +2169,8 @@ How Much Text Matches?
echo aaaabcd | awk '{ sub(/a+/, "<A>"); print }'
This example uses the `sub' function (which we haven't discussed yet,
-*note Built-in Functions for String Manipulation: String Functions.)
-to make a change to the input record. Here, the regexp `/a+/' indicates
+*note Built-in Functions for String Manipulation: String Functions.) to
+make a change to the input record. Here, the regexp `/a+/' indicates
"one or more `a' characters," and the replacement text is `<A>'.
The input contains four `a' characters. What will the output be?
@@ -2180,7 +2178,7 @@ In other words, how many is "one or more"--will `awk' match two, three,
or all four `a' characters?
The answer is, `awk' (and POSIX) regular expressions always match
-the leftmost, _longest_ sequence of input characters that can match.
+the leftmost, *longest* sequence of input characters that can match.
Thus, in this example, all four `a' characters are replaced with `<A>'.
$ echo aaaabcd | awk '{ sub(/a+/, "<A>"); print }'
@@ -2217,7 +2215,7 @@ names, and tests if the input record matches this regexp.
difference between a regexp constant enclosed in slashes, and a string
constant enclosed in double quotes. If you are going to use a string
constant, you have to understand that the string is in essence scanned
-_twice_; the first time when `awk' reads your program, and the second
+*twice*; the first time when `awk' reads your program, and the second
time when it goes to match the string on the left-hand side of the
operator with the pattern on the right. This is true of any string
valued expression (such as `identifier_regexp' above), not just string
@@ -2263,7 +2261,7 @@ command) or from files whose names you specify on the `awk' command
line. If you specify input files, `awk' reads them in order, reading
all the data from one before going on to the next. The name of the
current input file can be found in the built-in variable `FILENAME'
-(*note Built-in Variables::).
+(*note Built-in Variables::.).
The input is read in units called "records", and processed by the
rules of your program one record at a time. By default, each record is
@@ -2453,7 +2451,7 @@ separated or "parsed" by the interpreter into chunks called "fields".
By default, fields are separated by whitespace, like words in a line.
Whitespace in `awk' means any string of one or more spaces, tabs or
newlines;(1) other characters such as formfeed, and so on, that are
-considered whitespace by other languages are _not_ considered
+considered whitespace by other languages are *not* considered
whitespace by `awk'.
The purpose of fields is to make it more convenient for you to refer
@@ -2502,8 +2500,8 @@ field contains the string `foo'. The operator `~' is called a
Usage.); it tests whether a string (here, the field `$1') matches a
given regular expression.
- By contrast, the following example looks for `foo' in _the entire
-record_ and prints the first field and the last field for each input
+ By contrast, the following example looks for `foo' in *the entire
+record* and prints the first field and the last field for each input
record containing a match.
$ awk '/foo/ { print $1, $NF }' BBS-list
@@ -2514,7 +2512,7 @@ record containing a match.
---------- Footnotes ----------
- (1) In POSIX `awk', newlines are not considered whitespace for
+ (1) In POSIX `awk', newlines are not considered whitespace for
separating fields.

@@ -2561,7 +2559,7 @@ behave differently.)
As mentioned in *Note Examining Fields: Fields, the number of fields
in the current record is stored in the built-in variable `NF' (also
-*note Built-in Variables::). The expression `$NF' is not a special
+*note Built-in Variables::.). The expression `$NF' is not a special
feature: it is the direct consequence of evaluating `NF' and using its
value as a field number.
@@ -2573,7 +2571,7 @@ Changing the Contents of a Field
You can change the contents of a field as seen by `awk' within an
`awk' program; this changes what `awk' perceives as the current input
-record. (The actual input is untouched; `awk' _never_ modifies the
+record. (The actual input is untouched; `awk' *never* modifies the
input file.)
Consider this example and its output:
@@ -2586,7 +2584,7 @@ input file.)
The `-' sign represents subtraction, so this program reassigns field
three, `$3', to be the value of field two minus ten, `$2 - 10'. (*Note
-Arithmetic Operators: Arithmetic Ops.) Then field two, and the new
+Arithmetic Operators: Arithmetic Ops.) Then field two, and the new
value for field three, are printed.
In order for this to work, the text in field `$2' must make sense as
@@ -2632,11 +2630,11 @@ existing fields.
This recomputation affects and is affected by `NF' (the number of
fields; *note Examining Fields: Fields.), and by a feature that has not
been discussed yet, the "output field separator", `OFS', which is used
-to separate the fields (*note Output Separators::). For example, the
+to separate the fields (*note Output Separators::.). For example, the
value of `NF' is set to the number of the highest field you create.
- Note, however, that merely _referencing_ an out-of-range field does
-_not_ change the value of either `$0' or `NF'. Referencing an
+ Note, however, that merely *referencing* an out-of-range field does
+*not* change the value of either `$0' or `NF'. Referencing an
out-of-range field only produces an empty string. For example:
if ($(NF+1) != "")
@@ -2722,7 +2720,7 @@ would be split into three fields: `m', `*g' and `*gai*pan'. Note the
leading spaces in the values of the second and third fields.
The field separator is represented by the built-in variable `FS'.
-Shell programmers take note! `awk' does _not_ use the name `IFS' which
+Shell programmers take note! `awk' does *not* use the name `IFS' which
is used by the POSIX compatible shells (such as the Bourne shell, `sh',
or the GNU Bourne-Again Shell, Bash).
@@ -2789,7 +2787,7 @@ example, the assignment:
makes every area of an input line that consists of a comma followed by a
space and a tab, into a field separator. (`\t' is an "escape sequence"
-that stands for a tab; *note Escape Sequences::, for the complete list
+that stands for a tab; *note Escape Sequences::., for the complete list
of similar escape sequences.)
For a less trivial example of a regular expression, suppose you want
@@ -2846,17 +2844,14 @@ record separately. In `gawk', this is easy to do, you simply assign
the null string (`""') to `FS'. In this case, each individual character
in the record will become a separate field. Here is an example:
- echo a b | gawk 'BEGIN { FS = "" }
- {
- for (i = 1; i <= NF; i = i + 1)
- print "Field", i, "is", $i
- }'
-
-The output from this is:
-
- Field 1 is a
- Field 2 is
- Field 3 is b
+ $ echo a b | gawk 'BEGIN { FS = "" }
+ > {
+ > for (i = 1; i <= NF; i = i + 1)
+ > print "Field", i, "is", $i
+ > }'
+ -| Field 1 is a
+ -| Field 2 is
+ -| Field 3 is b
Traditionally, the behavior for `FS' equal to `""' was not defined.
In this case, Unix `awk' would simply treat the entire record as only
@@ -2880,7 +2875,7 @@ capital `F'. Contrast this with `-f', which specifies a file
containing an `awk' program. Case is significant in command line
options: the `-F' and `-f' options have nothing to do with each other.
You can use both options at the same time to set the `FS' variable
-_and_ get an `awk' program from a file.
+*and* get an `awk' program from a file.
The value used for the argument to `-F' is processed in exactly the
same way as assignments to the built-in variable `FS'. This means that
@@ -2893,7 +2888,7 @@ would have to type:
Since `\' is used for quoting in the shell, `awk' will see `-F\\'.
Then `awk' processes the `\\' for escape characters (*note Escape
-Sequences::), finally yielding a single `\' to be used for the field
+Sequences::.), finally yielding a single `\' to be used for the field
separator.
As a special case, in compatibility mode (*note Command Line
@@ -2958,8 +2953,8 @@ should reflect the old value of `FS', not the new one.
However, many implementations of `awk' do not work this way.
Instead, they defer splitting the fields until a field is actually
-referenced. The fields will be split using the _current_ value of
-`FS'! (d.c.) This behavior can be difficult to diagnose. The following
+referenced. The fields will be split using the *current* value of
+`FS'! (d.c.) This behavior can be difficult to diagnose. The following
example illustrates the difference between the two methods. (The
`sed'(1) command prints just the first line of `/etc/passwd'.)
@@ -2997,7 +2992,7 @@ value of `FS'. (`==' means "is equal to.")
---------- Footnotes ----------
- (1) The `sed' utility is a "stream editor." Its behavior is also
+ (1) The `sed' utility is a "stream editor." Its behavior is also
defined by the POSIX standard.

@@ -3016,8 +3011,8 @@ numbers are run together; or in the output of programs that did not
anticipate the use of their output as input for other programs.
An example of the latter is a table where all the columns are lined
-up by the use of a variable number of spaces and _empty fields are just
-spaces_. Clearly, `awk''s normal field splitting based on `FS' will
+up by the use of a variable number of spaces and *empty fields are just
+spaces*. Clearly, `awk''s normal field splitting based on `FS' will
not work well in this case. Although a portable `awk' program can use
a series of `substr' calls on `$0' (*note Built-in Functions for String
Manipulation: String Functions.), this is awkward and inefficient for a
@@ -3026,7 +3021,7 @@ large number of fields.
The splitting of an input record into fixed-width fields is
specified by assigning a string containing space-separated numbers to
the built-in variable `FIELDWIDTHS'. Each number specifies the width
-of the field _including_ columns between fields. If you want to ignore
+of the field *including* columns between fields. If you want to ignore
the columns between fields, you can specify the width as a separate
field that is subsequently ignored.
@@ -3127,8 +3122,8 @@ row, they are considered one record-separator.
`"\n\n+"' to `RS'. This regexp matches the newline at the end of the
record, and one or more blank lines after the record. In addition, a
regular expression always matches the longest possible sequence when
-there is a choice (*note How Much Text Matches?: Leftmost Longest.) So
-the next record doesn't start until the first non-blank line that
+there is a choice (*note How Much Text Matches?: Leftmost Longest.).
+So the next record doesn't start until the first non-blank line that
follows--no matter how many blank lines appear in a row, they are
considered one record-separator.
@@ -3142,7 +3137,7 @@ second case, this special processing is not done (d.c.).
separate the fields in the record. One way to do this is to divide each
of the lines into fields in the normal manner. This happens by default
as the result of a special feature: when `RS' is set to the empty
-string, the newline character _always_ acts as a field separator. This
+string, the newline character *always* acts as a field separator. This
is in addition to whatever field separations result from `FS'.
The original motivation for this special exception was probably to
@@ -3259,11 +3254,11 @@ File: gawk.info, Node: Getline Intro, Next: Plain Getline, Prev: Getline, Up
Introduction to `getline'
-------------------------
- This command is used in several different ways, and should _not_ be
+ This command is used in several different ways, and should *not* be
used by beginners. It is covered here because this is the chapter on
input. The examples that follow the explanation of the `getline'
command include material that has not been covered yet. Therefore,
-come back and study the `getline' command _after_ you have reviewed the
+come back and study the `getline' command *after* you have reviewed the
rest of this Info file and have a good knowledge of how `awk' works.
`getline' returns one if it finds a record, and zero if the end of
@@ -3285,7 +3280,7 @@ Using `getline' with No Arguments
from the current input file. All it does in this case is read the next
input record and split it up into fields. This is useful if you've
finished processing the current record, but you want to do some special
-processing _right now_ on the next record. Here's an example:
+processing *right now* on the next record. Here's an example:
awk '{
if ((t = index($0, "/*")) != 0) {
@@ -3641,11 +3636,11 @@ relational operator; otherwise it could be confused with a redirection
of the current record (such as `$1'), variables, or any `awk'
expressions. Numeric values are converted to strings, and then printed.
- The `print' statement is completely general for computing _what_
-values to print. However, with two exceptions, you cannot specify _how_
+ The `print' statement is completely general for computing *what*
+values to print. However, with two exceptions, you cannot specify *how*
to print them--how many columns, whether to use exponential notation or
-not, and so on. (For the exceptions, *note Output Separators::, and
-*Note Controlling Numeric Output with `print': OFMT.) For that, you
+not, and so on. (For the exceptions, *note Output Separators::., and
+*Note Controlling Numeric Output with `print': OFMT.) For that, you
need the `printf' statement (*note Using `printf' Statements for
Fancier Printing: Printf.).
@@ -3704,7 +3699,7 @@ Here is the same program, without the comma:
example's output makes much sense. A heading line at the beginning
would make it clearer. Let's add some headings to our table of months
(`$1') and green crates shipped (`$2'). We do this using the `BEGIN'
-pattern (*note The `BEGIN' and `END' Special Patterns: BEGIN/END.) to
+pattern (*note The `BEGIN' and `END' Special Patterns: BEGIN/END.) to
force the headings to be printed only once:
awk 'BEGIN { print "Month Crates"
@@ -4109,7 +4104,7 @@ last things on their lines. We don't need to put spaces after them.
We could make our table look even nicer by adding headings to the
tops of the columns. To do this, we use the `BEGIN' pattern (*note The
-`BEGIN' and `END' Special Patterns: BEGIN/END.) to force the header to
+`BEGIN' and `END' Special Patterns: BEGIN/END.) to force the header to
be printed only once, at the beginning of the `awk' program:
awk 'BEGIN { print "Name Number"
@@ -4163,7 +4158,7 @@ for `printf' also.
This type of redirection prints the items into the output file
OUTPUT-FILE. The file name OUTPUT-FILE can be any expression.
Its value is changed to a string and then used as a file name
- (*note Expressions::).
+ (*note Expressions::.).
When this type of redirection is used, the OUTPUT-FILE is erased
before the first output is written to it. Subsequent writes to
@@ -4368,7 +4363,7 @@ these file names is done by `gawk' itself. For example, using
`/dev/fd/4' for output will actually write on file descriptor 4, and
not on a new file descriptor that was `dup''ed from file descriptor 4.
Most of the time this does not matter; however, it is important to
-_not_ close any of the files related to file descriptors 0, 1, and 2.
+*not* close any of the files related to file descriptors 0, 1, and 2.
If you do close one of these files, unpredictable behavior will result.
The special files that provide process-related information may
@@ -4382,7 +4377,7 @@ Closing Input and Output Files and Pipes
========================================
If the same file name or the same shell command is used with
-`getline' (*note Explicit Input with `getline': Getline.) more than
+`getline' (*note Explicit Input with `getline': Getline.) more than
once during the execution of an `awk' program, the file is opened (or
the command is executed) only the first time. At that time, the first
record of input is read from that file or command. The next time the
@@ -4406,7 +4401,7 @@ or
close(COMMAND)
The argument FILENAME or COMMAND can be any expression. Its value
-must _exactly_ match the string that was used to open the file or start
+must *exactly* match the string that was used to open the file or start
the command (spaces and other "irrelevant" characters included). For
example, if you open a pipe with this:
@@ -4501,13 +4496,13 @@ calls, as well as combinations of these with various operators.
* Concatenation:: Concatenating strings.
* Assignment Ops:: Changing the value of a variable or a field.
* Increment Ops:: Incrementing the numeric value of a variable.
-* Truth Values:: What is ``true'' and what is ``false''.
+* Truth Values:: What is "true" and what is "false".
* Typing and Comparison:: How variables acquire types, and how this
affects comparison of numbers and strings with
`<', etc.
* Boolean Ops:: Combining comparison expressions using boolean
- operators `||' (``or''), `&&'
- (``and'') and `!' (``not'').
+ operators `||' ("or"), `&&'
+ ("and") and `!' ("not").
* Conditional Exp:: Conditional expressions select between two
subexpressions under control of a third
subexpression.
@@ -4556,8 +4551,9 @@ implementations may have difficulty with some character codes.
---------- Footnotes ----------
- (1) The internal representation uses double-precision floating point
-numbers. If you don't know what that means, then don't worry about it.
+ (1) The internal representation uses double-precision floating
+point numbers. If you don't know what that means, then don't worry
+about it.

File: gawk.info, Node: Regexp Constants, Prev: Scalar Constants, Up: Constants
@@ -4760,7 +4756,7 @@ the `awk' program in an array named `ARGV' (*note Using `ARGC' and
`ARGV': ARGC and ARGV.).
`awk' processes the values of command line assignments for escape
-sequences (d.c.) (*note Escape Sequences::).
+sequences (d.c.) (*note Escape Sequences::.).

File: gawk.info, Node: Conversion, Next: Arithmetic Ops, Prev: Variables, Up: Expressions
@@ -4794,7 +4790,7 @@ interpreted as valid numbers are converted to zero.
The exact manner in which numbers are converted into strings is
controlled by the `awk' built-in variable `CONVFMT' (*note Built-in
-Variables::). Numbers are converted using the `sprintf' function
+Variables::.). Numbers are converted using the `sprintf' function
(*note Built-in Functions for String Manipulation: String Functions.)
with `CONVFMT' as the format specifier.
@@ -4809,7 +4805,7 @@ way. For example, if you forget the `%' in the format, all numbers
will be converted to the same constant string.
As a special case, if a number is an integer, then the result of
-converting it to a string is _always_ an integer, no matter what the
+converting it to a string is *always* an integer, no matter what the
value of `CONVFMT' may be. Given the following code fragment:
CONVFMT = "%2.2f"
@@ -4912,6 +4908,9 @@ File: gawk.info, Node: Concatenation, Next: Assignment Ops, Prev: Arithmetic
String Concatenation
====================
+ It seemed like a good idea at the time.
+ Brian Kernighan
+
There is only one string operation: concatenation. It does not have
a specific operator to represent it. Instead, concatenation is
performed by writing expressions next to one another, with no operator.
@@ -4982,7 +4981,7 @@ makes itself felt through the alteration of the variable. We call this
a "side effect".
The left-hand operand of an assignment need not be a variable (*note
-Variables::); it can also be a field (*note Changing the Contents of a
+Variables::.); it can also be a field (*note Changing the Contents of a
Field: Changing Fields.) or an array element (*note Arrays in `awk':
Arrays.). These are all called "lvalues", which means they can appear
on the left-hand side of an assignment operator. The right-hand
@@ -4990,7 +4989,7 @@ operand may be any expression; it produces the new value which the
assignment stores in the specified variable, field or array element.
(Such values are called "rvalues").
- It is important to note that variables do _not_ have permanent types.
+ It is important to note that variables do *not* have permanent types.
The type of a variable is simply the type of whatever value it happens
to hold at the moment. In the following program fragment, the variable
`foo' has a numeric value at first, and a string value later on:
@@ -5011,7 +5010,7 @@ zero. After executing this code, the value of `foo' is five:
(Note that using a variable as a number and then later as a string can
be confusing and is poor programming style. The above examples
-illustrate how `awk' works, _not_ how you should write your own
+illustrate how `awk' works, *not* how you should write your own
programs!)
An assignment is an expression, so it has a value: the same value
@@ -5046,7 +5045,7 @@ This is equivalent to the following:
Use whichever one makes the meaning of your program clearer.
There are situations where using `+=' (or any assignment operator)
-is _not_ the same as simply repeating the left-hand operand in the
+is *not* the same as simply repeating the left-hand operand in the
right-hand expression. For example:
# Thanks to Pat Rankin for this example
@@ -5066,7 +5065,7 @@ will return different values each time it is called. (Arrays and the
Arrays, and see *Note Numeric Built-in Functions: Numeric Functions,
for more information). This example illustrates an important fact
about the assignment operators: the left-hand expression is only
-evaluated _once_.
+evaluated *once*.
It is also up to the implementation as to which expression is
evaluated first, the left-hand one or the right-hand one. Consider
@@ -5125,7 +5124,7 @@ The assignment expression `V += 1' is completely equivalent.
Writing the `++' after the variable specifies post-increment. This
increments the variable value just the same; the difference is that the
-value of the increment expression itself is the variable's _old_ value.
+value of the increment expression itself is the variable's *old* value.
Thus, if `foo' has the value four, then the expression `foo++' has the
value four, but it changes the value of `foo' to five.
@@ -5153,7 +5152,7 @@ lvalue to pre-decrement or after it to post-decrement.
`LVALUE++'
This expression increments LVALUE, but the value of the expression
- is the _old_ value of LVALUE.
+ is the *old* value of LVALUE.
`--LVALUE'
Like `++LVALUE', but instead of adding, it subtracts. It
@@ -5161,7 +5160,7 @@ lvalue to pre-decrement or after it to post-decrement.
`LVALUE--'
Like `LVALUE++', but instead of adding, it subtracts. It
- decrements LVALUE. The value of the expression is the _old_ value
+ decrements LVALUE. The value of the expression is the *old* value
of LVALUE.

@@ -5175,7 +5174,7 @@ concepts of "true" and "false." Such languages usually use the special
constants `true' and `false', or perhaps their upper-case equivalents.
`awk' is different. It borrows a very simple concept of true and
-false from C. In `awk', any non-zero numeric value, _or_ any non-empty
+false from C. In `awk', any non-zero numeric value, *or* any non-empty
string value is true. Any other value (zero or the null string, `""')
is false. The following program will print `A strange truth value'
three times:
@@ -5198,6 +5197,9 @@ File: gawk.info, Node: Typing and Comparison, Next: Boolean Ops, Prev: Truth
Variable Typing and Comparison Expressions
==========================================
+ The Guide is definitive. Reality is frequently inaccurate.
+ The Hitchhiker's Guide to the Galaxy
+
Unlike other programming languages, `awk' variables do not have a
fixed type. Instead, they can be either a number or a string, depending
upon the value that is assigned to them.
@@ -5252,7 +5254,7 @@ according to the following, symmetric, matrix:
STRNUM | string numeric numeric
--------+----------------------------------------------
- The basic idea is that user input that looks numeric, and _only_
+ The basic idea is that user input that looks numeric, and *only*
user input, should be treated as numeric, even though it is actually
made of characters, and is therefore also a string.
@@ -5374,7 +5376,7 @@ abbreviation for this comparison expression:
$0 ~ /REGEXP/
- One special place where `/foo/' is _not_ an abbreviation for `$0 ~
+ One special place where `/foo/' is *not* an abbreviation for `$0 ~
/foo/' is when it is the right-hand operand of `~' or `!~'! *Note
Using Regular Expression Constants: Using Constant Regexps, where this
is discussed in more detail.
@@ -5420,7 +5422,7 @@ you can use one as a pattern to control the execution of rules.
`BOOLEAN1 || BOOLEAN2'
True if at least one of BOOLEAN1 or BOOLEAN2 is true. For
example, the following statement prints all records in the input
- that contain _either_ `2400' or `foo', or both.
+ that contain *either* `2400' or `foo', or both.
if ($0 ~ /2400/ || $0 ~ /foo/) print
@@ -5430,7 +5432,7 @@ you can use one as a pattern to control the execution of rules.
`! BOOLEAN'
True if BOOLEAN is false. For example, the following program
- prints all records in the input file `BBS-list' that do _not_
+ prints all records in the input file `BBS-list' that do *not*
contain the string `foo'.
awk '{ if (! ($0 ~ /foo/)) print }' BBS-list
@@ -5787,7 +5789,7 @@ whose first field is precisely `foo'.
$ awk '$1 == "foo" { print $2 }' BBS-list
-(There is no output, since there is no BBS site named "foo".) Contrast
+(There is no output, since there is no BBS site named "foo".) Contrast
this with the following regular expression match, which would accept
any record with a first field that contains `foo':
@@ -5808,7 +5810,7 @@ that contain both `2400' and `foo'.
-| fooey 555-1234 2400/1200/300 B
The following command prints all records in `BBS-list' that contain
-_either_ `2400' or `foo', or both.
+*either* `2400' or `foo', or both.
$ awk '/2400/ || /foo/' BBS-list
-| alpo-net 555-3412 2400/1200/300 A
@@ -5819,7 +5821,7 @@ _either_ `2400' or `foo', or both.
-| sdace 555-3430 2400/1200/300 A
-| sabafoo 555-2127 1200/300 C
- The following command prints all records in `BBS-list' that do _not_
+ The following command prints all records in `BBS-list' that do *not*
contain the string `foo'.
$ awk '! /foo/' BBS-list
@@ -5881,7 +5883,7 @@ range pattern that describes the delimited text with the `next'
statement (not discussed yet, *note The `next' Statement: Next
Statement.), which causes `awk' to skip any further processing of the
current record and start over again with the next input record. Such a
-program would like this:
+program would look like this:
/^%$/,/^%$/ { next }
{ print }
@@ -5940,7 +5942,7 @@ been read. For example:
that contain the string `foo'. The `BEGIN' rule prints a title for the
report. There is no need to use the `BEGIN' rule to initialize the
counter `n' to zero, as `awk' does this automatically (*note
-Variables::).
+Variables::.).
The second rule increments the variable `n' every time a record
containing the pattern `foo' is read. The `END' rule prints the value
@@ -6002,7 +6004,7 @@ it.
The second point is similar to the first, but from the other
direction. Inside an `END' rule, what is the value of `$0' and `NF'?
Traditionally, due largely to implementation issues, `$0' and `NF' were
-_undefined_ inside an `END' rule. The POSIX standard specified that
+*undefined* inside an `END' rule. The POSIX standard specified that
`NF' was available in an `END' rule, containing the number of fields
from the last input record. Due most probably to an oversight, the
standard does not say that `$0' is also preserved, although logically
@@ -6026,7 +6028,7 @@ File: gawk.info, Node: Empty, Prev: BEGIN/END, Up: Pattern Overview
The Empty Pattern
-----------------
- An empty (i.e. non-existent) pattern is considered to match _every_
+ An empty (i.e. non-existent) pattern is considered to match *every*
input record. For example, the program:
awk '{ print $1 }' BBS-list
@@ -6069,7 +6071,7 @@ well. An omitted action is equivalent to `{ print $0 }'.
Here are the kinds of statements supported in `awk':
* Expressions, which can call functions or assign values to variables
- (*note Expressions::). Executing this kind of statement simply
+ (*note Expressions::.). Executing this kind of statement simply
computes the value of the expression. This is useful when the
expression has side effects (*note Assignment Expressions:
Assignment Ops.).
@@ -6197,7 +6199,7 @@ running.
The first thing the `while' statement does is test CONDITION. If
CONDITION is true, it executes the statement BODY. (The CONDITION is
-true when the value is not zero and not a null string.) After BODY has
+true when the value is not zero and not a null string.) After BODY has
been executed, CONDITION is tested again, and if it is still true, BODY
is executed again. This process repeats until CONDITION is no longer
true. If CONDITION is initially false, the body of the loop is never
@@ -6696,6 +6698,7 @@ specific to `gawk' are marked with an asterisk, `*'.
the `gensub', `gsub', `index', `match', `split' and `sub'
functions, record termination with `RS', and field splitting with
`FS' all ignore case when doing their particular regexp operations.
+ The value of `IGNORECASE' does *not* affect array subscripting.
*Note Case-sensitivity in Matching: Case-sensitivity.
If `gawk' is in compatibility mode (*note Command Line Options:
@@ -6713,7 +6716,7 @@ specific to `gawk' are marked with an asterisk, `*'.
general expressions; this is now done by `CONVFMT'.
`OFS'
- This is the output field separator (*note Output Separators::).
+ This is the output field separator (*note Output Separators::.).
It is output between the fields output by a `print' statement. Its
default value is `" "', a string consisting of a single space.
@@ -6740,7 +6743,7 @@ specific to `gawk' are marked with an asterisk, `*'.
---------- Footnotes ----------
- (1) In POSIX `awk', newline does not count as whitespace.
+ (1) In POSIX `awk', newline does not count as whitespace.

File: gawk.info, Node: Auto-set, Next: ARGC and ARGV, Prev: User-modified, Up: Built-in Variables
@@ -6893,7 +6896,7 @@ zero when `FILENAME' changed.
---------- Footnotes ----------
- (1) Some early implementations of Unix `awk' initialized `FILENAME'
+ (1) Some early implementations of Unix `awk' initialized `FILENAME'
to `"-"', even if there were data files to be processed. This behavior
was incorrect, and should not be relied upon in your programs.
@@ -6920,7 +6923,7 @@ In this example, `ARGV[0]' contains `"awk"', `ARGV[1]' contains
Notice that the `awk' program is not entered in `ARGV'. The other
special command line options, with their arguments, are also not
-entered. But variable assignments on the command line _are_ treated as
+entered. But variable assignments on the command line *are* treated as
arguments, and do show up in the `ARGV' array.
Your program can alter `ARGC' and the elements of `ARGV'. Each time
@@ -6967,6 +6970,24 @@ then remove, command line options.
}
}
+ To actually get the options into the `awk' program, you have to end
+the `awk' options with `--', and then supply your options, like so:
+
+ awk -f myprog -- -v -d file1 file2 ...
+
+ This is not necessary in `gawk': Unless `--posix' has been
+specified, `gawk' silently puts any unrecognized options into `ARGV'
+for the `awk' program to deal with.
+
+ As soon as it sees an unknown option, `gawk' stops looking for other
+options it might otherwise recognize. The above example with `gawk'
+would be:
+
+ gawk -f myprog -d -v file1 file2 ...
+
+Since `-d' is not a valid `gawk' option, the following `-v' is passed
+on to the `awk' program.
+

File: gawk.info, Node: Arrays, Next: Built-in, Prev: Built-in Variables, Up: Top
@@ -7084,6 +7105,10 @@ numbers and strings as indices. (In fact, array subscripts are always
strings; this is discussed in more detail in *Note Using Numbers to
Subscript Arrays: Numeric Array Subscripts.)
+ The value of `IGNORECASE' has no effect upon array subscripting.
+You must use the exact same string value to retrieve an array element
+as you used to store it.
+
When `awk' creates an array for you, e.g., with the `split' built-in
function, that array's indices are consecutive integers starting at one.
(*Note Built-in Functions for String Manipulation: String Functions.)
@@ -7130,9 +7155,9 @@ index `2', you could write this statement:
if (2 in frequencies)
print "Subscript 2 is present."
- Note that this is _not_ a test of whether or not the array
-`frequencies' contains an element whose _value_ is two. (There is no
-way to do that except to scan all the elements.) Also, this _does not_
+ Note that this is *not* a test of whether or not the array
+`frequencies' contains an element whose *value* is two. (There is no
+way to do that except to scan all the elements.) Also, this *does not*
create `frequencies[2]', while the following (incorrect) alternative
would do so:
@@ -7302,7 +7327,7 @@ the presence of that element will return zero (i.e. false):
if (4 in foo)
print "This will never be printed"
- It is important to note that deleting an element is _not_ the same
+ It is important to note that deleting an element is *not* the same
as assigning it a null value (the empty string, `""').
foo[4] = ""
@@ -7330,7 +7355,7 @@ clear out an array.
split("", array)
The `split' function (*note Built-in Functions for String
-Manipulation: String Functions.) clears out the target array first.
+Manipulation: String Functions.) clears out the target array first.
This call asks it to split apart the null string. Since there is no
data to split out, the function simply clears the array and then
returns.
@@ -7341,8 +7366,8 @@ File: gawk.info, Node: Numeric Array Subscripts, Next: Uninitialized Subscript
Using Numbers to Subscript Arrays
=================================
- An important aspect of arrays to remember is that _array subscripts
-are always strings_. If you use a numeric value as a subscript, it
+ An important aspect of arrays to remember is that *array subscripts
+are always strings*. If you use a numeric value as a subscript, it
will be converted to a string value before it is used for subscripting
(*note Conversion of Strings and Numbers: Conversion.).
@@ -7421,8 +7446,9 @@ value `""', not zero. Thus, `line 1' ended up stored in `l[""]'.
print l[i]
}
- Here, the `++' forces `l' to be numeric, thus making the "old value"
-numeric zero, which is then converted to `"0"' as the array subscript.
+ Here, the `++' forces `lines' to be numeric, thus making the "old
+value" numeric zero, which is then converted to `"0"' as the array
+subscript.
As we have just seen, even though it is somewhat unusual, the null
string (`""') is a valid array subscript (d.c.). If `--lint' is provided
@@ -7523,7 +7549,7 @@ Scanning Multi-dimensional Arrays
There is no special `for' statement for scanning a
"multi-dimensional" array; there cannot be one, because in truth there
are no multi-dimensional arrays or elements; there is only a
-multi-dimensional _way of accessing_ an array.
+multi-dimensional *way of accessing* an array.
However, if your program has an array that is always accessed as
multi-dimensional, you can get the effect of scanning it by combining
@@ -7722,7 +7748,7 @@ Optional parameters are enclosed in square brackets ("[" and "]").
---------- Footnotes ----------
- (1) Computer generated random numbers really are not truly random.
+ (1) Computer generated random numbers really are not truly random.
They are technically known as "pseudo-random." This means that while
the numbers in a sequence appear to be random, you can in fact generate
the same sequence of random numbers over and over again.
@@ -7930,7 +7956,7 @@ and "]").
`gsub(REGEXP, REPLACEMENT [, TARGET])'
This is similar to the `sub' function, except `gsub' replaces
- _all_ of the longest, leftmost, _non-overlapping_ matching
+ *all* of the longest, leftmost, *non-overlapping* matching
substrings it can find. The `g' in `gsub' stands for "global,"
which means replace everywhere. For example:
@@ -7951,7 +7977,7 @@ and "]").
`gsub', it searches the target string TARGET for matches of the
regular expression REGEXP. Unlike `sub' and `gsub', the modified
string is returned as the result of the function, and the original
- target string is _not_ changed. If HOW is a string beginning with
+ target string is *not* changed. If HOW is a string beginning with
`g' or `G', then it replaces all matches of REGEXP with
REPLACEMENT. Otherwise, HOW is a number indicating which match of
REGEXP to replace. If no TARGET is supplied, `$0' is used instead.
@@ -8007,7 +8033,7 @@ and "]").
also returned if LENGTH is greater than the number of characters
remaining in the string, counting from character number START.
- *Note:* The string returned by `substr' _cannot_ be assigned to.
+ *Note:* The string returned by `substr' *cannot* be assigned to.
Thus, it is a mistake to attempt to change a portion of a string,
like this:
@@ -8103,7 +8129,7 @@ leads to two problems.
1. Backslashes must now be doubled in the REPLACEMENT string, breaking
historical `awk' programs.
- 2. To make sure that an `awk' program is portable, _every_ character
+ 2. To make sure that an `awk' program is portable, *every* character
in the REPLACEMENT string must be preceded with a backslash.(1)
The POSIX standard is under revision.(2) Because of the above
@@ -8153,10 +8179,10 @@ the use of `gawk' and `gensub' for when you have to do substitutions.
---------- Footnotes ----------
- (1) This consequence was certainly unintended.
+ (1) This consequence was certainly unintended.
- (2) As of December 1995, with final approval and publication
-hopefully sometime in 1996.
+ (2) As of February 1997, with final approval and publication
+hopefully sometime in 1997.

File: gawk.info, Node: I/O Functions, Next: Time Functions, Prev: String Functions, Up: Built-in
@@ -8198,7 +8224,7 @@ parameters are enclosed in square brackets ("[" and "]").
`gawk' extends the `fflush' function in two ways. The first is to
allow no argument at all. In this case, the buffer for the
standard output is flushed. The second way is to allow the null
- string (`""') as the argument. In this case, the buffers for _all_
+ string (`""') as the argument. In this case, the buffers for *all*
open output files and pipes are flushed.
`fflush' returns zero if the buffer was successfully flushed, and
@@ -8259,7 +8285,7 @@ this example.
-| 2
-| 5
-Here, no output is printed until after the `Control-D' is typed, since
+Here, no output is printed until after the `Control-d' is typed, since
it is all buffered, and sent down the pipe to `cat' in one shot.
Controlling Output Buffering with `system'
@@ -8308,7 +8334,7 @@ latter (undesirable) output is what you would see.
---------- Footnotes ----------
- (1) A program is interactive if the standard output is connected to
+ (1) A program is interactive if the standard output is connected to
a terminal device.

@@ -8564,16 +8590,17 @@ if the time zone was set to UTC.
---------- Footnotes ----------
- (1) Occasionally there are minutes in a year with a leap second,
+ (1) Occasionally there are minutes in a year with a leap second,
which is why the seconds can go up to 60.
- (2) This is because ANSI C leaves the behavior of the C version of
+ (2) This is because ANSI C leaves the behavior of the C version of
`strftime' undefined, and `gawk' will use the system's version of
`strftime' if it's there. Typically, the conversion specifier will
either not appear in the returned string, or it will appear literally.
- (3) If you don't understand any of this, don't worry about it; these
-facilities are meant to make it easier to "internationalize" programs.
+ (3) If you don't understand any of this, don't worry about it;
+these facilities are meant to make it easier to "internationalize"
+programs.

File: gawk.info, Node: User-defined, Next: Invoking Gawk, Prev: Built-in, Up: Top
@@ -8583,7 +8610,7 @@ User-defined Functions
Complicated `awk' programs can often be simplified by defining your
own functions. User-defined functions can be called just like built-in
-ones (*note Function Calls::), but it is up to you to define them--to
+ones (*note Function Calls::.), but it is up to you to define them--to
tell `awk' what they should do.
* Menu:
@@ -8602,7 +8629,7 @@ Function Definition Syntax
Definitions of functions can appear anywhere between the rules of an
`awk' program. Thus, the general form of an `awk' program is extended
-to include sequences of rules _and_ user-defined function definitions.
+to include sequences of rules *and* user-defined function definitions.
There is no need in `awk' to put the definition of a function before
all uses of the function. This is because `awk' reads the entire
program before starting to execute any of it.
@@ -8627,7 +8654,7 @@ cannot have two parameters with the same name.
The BODY-OF-FUNCTION consists of `awk' statements. It is the most
important part of the definition, because it says what the function
-should actually _do_. The argument names exist to give the body a way
+should actually *do*. The argument names exist to give the body a way
to talk about the arguments; local variables, to give the body places
to keep temporary values.
@@ -8668,7 +8695,7 @@ function. When this happens, we say the function is "recursive".
`function' may be abbreviated `func'. However, POSIX only specifies
the use of the keyword `function'. This actually has some practical
implications. If `gawk' is in POSIX-compatibility mode (*note Command
-Line Options: Options.), then the following statement will _not_ define
+Line Options: Options.), then the following statement will *not* define
a function:
func foo() { a = sqrt($1) ; print a }
@@ -8747,7 +8774,7 @@ way:
Here is an example that uses the built-in function `strftime'.
(*Note Functions for Dealing with Time Stamps: Time Functions, for more
-information on `strftime'.) The C `ctime' function takes a timestamp
+information on `strftime'.) The C `ctime' function takes a timestamp
and returns it in a string, formatted in a well known fashion. Here is
an `awk' version:
@@ -8789,7 +8816,7 @@ concatenate a variable with an expression in parentheses. However, it
notices that you used a function name and not a variable name, and
reports an error.
- When a function is called, it is given a _copy_ of the values of its
+ When a function is called, it is given a *copy* of the values of its
arguments. This is known as "call by value". The caller may use a
variable as the expression for the argument, but the called function
does not know this: it only knows what value the argument had. For
@@ -8812,18 +8839,18 @@ this has no effect on any other variables. Thus, if `myfunc' does this:
print str
}
-to change its first argument variable `str', this _does not_ change the
+to change its first argument variable `str', this *does not* change the
value of `foo' in the caller. The role of `foo' in calling `myfunc'
ended when its value, `"bar"', was computed. If `str' also exists
outside of `myfunc', the function body cannot alter this outer value,
because it is shadowed during the execution of `myfunc' and cannot be
seen or changed from there.
- However, when arrays are the parameters to functions, they are _not_
+ However, when arrays are the parameters to functions, they are *not*
copied. Instead, the array itself is made available for direct
manipulation by the function. This is usually called "call by
reference". Changes made to an array parameter inside the body of a
-function _are_ visible outside that function. This can be *very*
+function *are* visible outside that function. This can be *very*
dangerous if you do not watch what you are doing. For example:
function changeit(array, ind, nvalue)
@@ -8862,8 +8889,8 @@ program calls an undefined function.
Options.), `gawk' will report about calls to undefined functions.
Some `awk' implementations generate a run-time error if you use the
-`next' statement (*note The `next' Statement: Next Statement.) inside
-a user-defined function. `gawk' does not have this problem.
+`next' statement (*note The `next' Statement: Next Statement.) inside a
+user-defined function. `gawk' does not have this problem.

File: gawk.info, Node: Return Statement, Prev: Function Caveats, Up: User-defined
@@ -8884,7 +8911,7 @@ value is undefined and, therefore, unpredictable.
A `return' statement with no value expression is assumed at the end
of every function definition. So if control reaches the end of the
function body, then the function returns an unpredictable value. `awk'
-will _not_ warn you if you use the return value of such a function.
+will *not* warn you if you use the return value of such a function.
Sometimes, you want to write a function for what it does, not for
what it returns. Such a function corresponds to a `void' function in C
@@ -9091,7 +9118,7 @@ The options and their meanings are as follows:
restrictions:
* `\x' escape sequences are not recognized (*note Escape
- Sequences::).
+ Sequences::.).
* Newlines do not act as whitespace to separate fields when
`FS' is equal to a single space.
@@ -9195,7 +9222,7 @@ to the `.profile' file in your home directory.
---------- Footnotes ----------
- (1) Not recommended.
+ (1) Not recommended.

File: gawk.info, Node: Other Arguments, Next: AWKPATH Variable, Prev: Options, Up: Invoking Gawk
@@ -9209,7 +9236,7 @@ argument that has the form `VAR=VALUE', assigns the value VALUE to the
variable VAR--it does not specify a file at all.
All these arguments are made available to your `awk' program in the
-`ARGV' array (*note Built-in Variables::). Command line options and
+`ARGV' array (*note Built-in Variables::.). Command line options and
the program text (if present) are omitted from `ARGV'. All other
arguments, including variable assignments, are included. As each
element of `ARGV' is processed, `gawk' sets the variable `ARGIND' to
@@ -9223,15 +9250,15 @@ reading a file.
Therefore, the variables actually receive the given values after all
previously specified files have been read. In particular, the values of
-variables assigned in this fashion are _not_ available inside a `BEGIN'
+variables assigned in this fashion are *not* available inside a `BEGIN'
rule (*note The `BEGIN' and `END' Special Patterns: BEGIN/END.), since
such rules are run before `awk' begins scanning the argument list.
The variable values given on the command line are processed for
-escape sequences (d.c.) (*note Escape Sequences::).
+escape sequences (d.c.) (*note Escape Sequences::.).
In some earlier implementations of `awk', when a variable assignment
-occurred before any file names, the assignment would happen _before_
+occurred before any file names, the assignment would happen *before*
the `BEGIN' rule was executed. `awk''s behavior was thus inconsistent;
some command line assignments were available inside the `BEGIN' rule,
while others were not. However, some applications came to depend upon
@@ -9304,7 +9331,7 @@ path `gawk' will use.
---------- Footnotes ----------
- (1) Your version of `gawk' may use a directory that is different
+ (1) Your version of `gawk' may use a directory that is different
than `/usr/local/share/awk'; it will depend upon how `gawk' was built
and installed. The actual directory will be the value of `$(datadir)'
generated when `gawk' was configured. You probably don't need to worry
@@ -9319,9 +9346,9 @@ Obsolete Options and/or Features
This section describes features and/or command line options from
previous releases of `gawk' that are either not available in the
current version, or that are still supported but deprecated (meaning
-that they will _not_ be in the next release).
+that they will *not* be in the next release).
- For version 3.0.1 of `gawk', there are no command line options or
+ For version 3.0.3 of `gawk', there are no command line options or
other deprecated features from the previous version of `gawk'. This
node is thus essentially a place holder, in case some option becomes
obsolete in a future version of `gawk'.
@@ -9332,6 +9359,9 @@ File: gawk.info, Node: Undocumented, Next: Known Bugs, Prev: Obsolete, Up: I
Undocumented Options and Features
=================================
+ Use the Source, Luke!
+ Obi-Wan
+
This section intentionally left blank.

@@ -9341,9 +9371,8 @@ Known Bugs in `gawk'
====================
* The `-F' option for changing the value of `FS' (*note Command Line
- Options: Options.) is not necessary given the command line
- variable assignment feature; it remains only for backwards
- compatibility.
+ Options: Options.) is not necessary given the command line variable
+ assignment feature; it remains only for backwards compatibility.
* If your system actually has support for `/dev/fd' and the
associated `/dev/stdin', `/dev/stdout', and `/dev/stderr' files,
@@ -9367,7 +9396,7 @@ A Library of `awk' Functions
This chapter presents a library of useful `awk' functions. The
sample programs presented later (*note Practical `awk' Programs: Sample
-Programs.) use these functions. The functions are presented here in a
+Programs.) use these functions. The functions are presented here in a
progression from simple to complex.
*Note Extracting Programs from Texinfo Source Files: Extract Program,
@@ -9479,7 +9508,7 @@ file is reached, and a new data file is opened, changing the value of
and then executes a `next' statement to start the loop going.(1)
This initial version has a subtle problem. What happens if the same
-data file is listed _twice_ on the command line, one right after the
+data file is listed *twice* on the command line, one right after the
other, or even with just a variable assignment between the two
occurrences of the file name?
@@ -9540,9 +9569,9 @@ computations).
---------- Footnotes ----------
- (1) Some implementations of `awk' do not allow you to execute `next'
-from within a function body. Some other work-around will be necessary
-if you use such a version.
+ (1) Some implementations of `awk' do not allow you to execute
+`next' from within a function body. Some other work-around will be
+necessary if you use such a version.

File: gawk.info, Node: Assert Function, Next: Round Function, Prev: Nextfile Function, Up: Library Functions
@@ -9639,7 +9668,7 @@ Rounding Numbers
================
The way `printf' and `sprintf' (*note Using `printf' Statements for
-Fancier Printing: Printf.) do rounding will often depend upon the
+Fancier Printing: Printf.) do rounding will often depend upon the
system's C `sprintf' subroutine. On many machines, `sprintf' rounding
is "unbiased," which means it doesn't always round a trailing `.5' up,
contrary to naive expectations. In unbiased rounding, `.5' rounds to
@@ -9780,10 +9809,10 @@ function. It is commented out for production use.
---------- Footnotes ----------
- (1) ASCII has been extended in many countries to use the values from
-128 to 255 for country-specific characters. If your system uses these
-extensions, you can simplify `_ord_init' to simply loop from zero to
-255.
+ (1) ASCII has been extended in many countries to use the values
+from 128 to 255 for country-specific characters. If your system uses
+these extensions, you can simplify `_ord_init' to simply loop from zero
+to 255.

File: gawk.info, Node: Join Function, Next: Mktime Function, Prev: Ordinal Functions, Up: Library Functions
@@ -9894,7 +9923,7 @@ multiple assignment.
}
The benefit of merging multiple `BEGIN' rules (*note The `BEGIN' and
-`END' Special Patterns: BEGIN/END.) is particularly clear when writing
+`END' Special Patterns: BEGIN/END.) is particularly clear when writing
library files. Functions in library files can cleanly initialize their
own private data and also provide clean-up actions in private `END'
rules.
@@ -10039,7 +10068,7 @@ set-up and error checking.
Recall that `_tm_addup' generated a value in seconds since Midnight,
January 1, 1970. This value is not directly usable as the result we
-want, _since the calculation does not account for the local timezone_.
+want, *since the calculation does not account for the local timezone*.
In other words, the value represents the count in seconds since the
Epoch, but only for UTC (Universal Coordinated Time). If the local
timezone is east or west of UTC, then some number of hours should be
@@ -10055,8 +10084,8 @@ the result.
How can `mktime' determine how far away it is from UTC? This is
surprisingly easy. The returned timestamp represents the time passed to
-`mktime' _as UTC_. This timestamp can be fed back to `strftime', which
-will format it as a _local_ time; i.e. as if it already had the UTC
+`mktime' *as UTC*. This timestamp can be fed back to `strftime', which
+will format it as a *local* time; i.e. as if it already had the UTC
difference added in to it. This is done by giving
`"%Y %m %d %H %M %S"' to `strftime' as the format argument. It returns
the computed timestamp in the original string format. The result
@@ -10095,7 +10124,7 @@ output is to standard error, and test output is to standard output.)
as UTC--four hours ahead of the local time zone. The second line shows
that the difference is 14400 seconds, which is four hours. (The
difference is only four hours, since daylight savings time is in effect
-during May.) The final line of test output shows that the timezone
+during May.) The final line of test output shows that the timezone
compensation algorithm works; the returned time is the same as the
entered time.
@@ -10108,7 +10137,7 @@ months, and AM/PM times into 24-hour clocks, to generate the
---------- Footnotes ----------
- (1) This is the Epoch on POSIX systems. It may be different on
+ (1) This is the Epoch on POSIX systems. It may be different on
other systems.

@@ -10219,7 +10248,7 @@ even supplied us the code to do so.
library program. It arranges to call two user-supplied functions,
`beginfile' and `endfile', at the beginning and end of each data file.
Besides solving the problem in only nine(!) lines of code, it does so
-_portably_; this will work with any implementation of `awk'.
+*portably*; this will work with any implementation of `awk'.
# transfile.awk
#
@@ -10587,7 +10616,7 @@ Reading the User Database
=========================
The `/dev/user' special file (*note Special File Names in `gawk':
-Special Files.) provides access to the current user's real and
+Special Files.) provides access to the current user's real and
effective user and group id numbers, and if available, the user's
supplementary group set. However, since these are numbers, they do not
provide very useful information to the average user. There needs to be
@@ -10600,7 +10629,7 @@ information from the group database.
The POSIX standard does not define the file where user information is
kept. Instead, it provides the `<pwd.h>' header file and several C
language subroutines for obtaining user information. The primary
-function is `getpwent', for "get password entry." The "password" comes
+function is `getpwent', for "get password entry." The "password" comes
from the original user database file, `/etc/passwd', which kept user
information, along with the encrypted passwords (hence the name).
@@ -11114,7 +11143,7 @@ that it is global, while the fact that the variable name is not all
capital letters indicates that the variable is not one of `awk''s
built-in variables, like `FS'.
- It is also important that _all_ variables in library functions that
+ It is also important that *all* variables in library functions that
do not need to save state are in fact declared local. If this is not
done, the variable could accidentally be used in the user's program,
leading to bugs that are very difficult to track down.
@@ -11477,7 +11506,7 @@ is preceded by the name of the file and a colon.
`-v'
Invert the sense of the test. `egrep' prints the lines that do
- _not_ match the pattern, and exits successfully if the pattern was
+ *not* match the pattern, and exits successfully if the pattern was
not matched.
`-i'
@@ -11499,7 +11528,7 @@ Function.).
The program begins with a descriptive comment, and then a `BEGIN'
rule that processes the command line arguments with `getopt'. The `-i'
(ignore case) option is particularly easy with `gawk'; we just use the
-`IGNORECASE' built in variable (*note Built-in Variables::).
+`IGNORECASE' built in variable (*note Built-in Variables::.).
# egrep.awk --- simulate egrep in awk
# Arnold Robbins, arnold@gnu.ai.mit.edu, Public Domain
@@ -11809,8 +11838,7 @@ output file names.
# usage: split [-num] [file] [outname]
- BEGIN \
- {
+ BEGIN {
outfile = "x" # default
count = 1000
if (ARGC > 4)
@@ -12327,9 +12355,9 @@ line.(1)
---------- Footnotes ----------
- (1) Examine the code in *Note Noting Data File Boundaries: Filetrans
-Function. Why must `wc' use a separate `lines' variable, instead of
-using the value of `FNR' in `endfile'?
+ (1) Examine the code in *Note Noting Data File Boundaries:
+Filetrans Function. Why must `wc' use a separate `lines' variable,
+instead of using the value of `FNR' in `endfile'?

File: gawk.info, Node: Miscellaneous Programs, Prev: Clones, Up: Sample Programs
@@ -12494,7 +12522,7 @@ between the two is how long to wait before setting off the alarm.
}
Finally, the program uses the `system' function (*note Built-in
-Functions for Input/Output: I/O Functions.) to call the `sleep'
+Functions for Input/Output: I/O Functions.) to call the `sleep'
utility. The `sleep' utility simply pauses for the given number of
seconds. If the exit status is not zero, the program assumes that
`sleep' was interrupted, and exits. If `sleep' exited with an OK status
@@ -12640,10 +12668,10 @@ program.
---------- Footnotes ----------
- (1) On older, non-POSIX systems, `tr' often does not require that
+ (1) On older, non-POSIX systems, `tr' often does not require that
the lists be enclosed in square brackets and quoted. This is a feature.
- (2) This program was written before `gawk' acquired the ability to
+ (2) This program was written before `gawk' acquired the ability to
split each character in a string into separate array elements. How
might this ability simplify the program?
@@ -12750,7 +12778,7 @@ not have been an even multiple of 20 labels in the data.
---------- Footnotes ----------
- (1) "Real world" is defined as "a program actually used to get
+ (1) "Real world" is defined as "a program actually used to get
something done."

@@ -12783,7 +12811,7 @@ program listing.
rules. The first rule, because it has an empty pattern, is executed on
every line of the input. It uses `awk''s field-accessing mechanism
(*note Examining Fields: Fields.) to pick out the individual words from
-the line, and the built-in variable `NF' (*note Built-in Variables::)
+the line, and the built-in variable `NF' (*note Built-in Variables::.)
to know how many fields are available.
For each input word, an element of the array `freq' is incremented to
@@ -12871,7 +12899,7 @@ Removing Duplicates from Unsorted Text
--------------------------------------
The `uniq' program (*note Printing Non-duplicated Lines of Text:
-Uniq Program.), removes duplicate lines from _sorted_ data.
+Uniq Program.), removes duplicate lines from *sorted* data.
Suppose, however, you need to remove duplicate lines from a data
file, but that you wish to preserve the order the lines are in? A good
@@ -12960,11 +12988,11 @@ optional. Lines containing `@group' and `@end group' are simply
removed. `extract.awk' uses the `join' library function (*note Merging
an Array Into a String: Join Function.).
- The example programs in the on-line Texinfo source for `The GNU Awk
-User's Guide' (`gawk.texi') have all been bracketed inside `file', and
-`endfile' lines. The `gawk' distribution uses a copy of `extract.awk'
-to extract the sample programs and install many of them in a standard
-directory, where `gawk' can find them.
+ The example programs in the on-line Texinfo source for `Effective
+AWK Programming' (`gawk.texi') have all been bracketed inside `file',
+and `endfile' lines. The `gawk' distribution uses a copy of
+`extract.awk' to extract the sample programs and install many of them
+in a standard directory, where `gawk' can find them.
`extract.awk' begins by setting `IGNORECASE' to one, so that mixed
upper-case and lower-case letters in the directives won't matter.
@@ -13401,7 +13429,7 @@ Variable.). If a file name has a `/' in it, no path search is done.
Otherwise, the file name is concatenated with the name of each
directory in the path, and an attempt is made to open the generated file
name. The only way in `awk' to test if a file can be read is to go
-ahead and try to read it with `getline'; that is what `pathto' does.
+ahead and try to read it with `getline'; that is what `pathto' does.(1)
If the file can be read, it is closed, and the file name is returned.
gawk -- '
@@ -13537,6 +13565,11 @@ these files upon startup. Instead, it would be very simple to modify
directives, `default.awk' could simply contain `@include' statements
for the desired library functions.
+ ---------- Footnotes ----------
+
+ (1) On some very old versions of `awk', the test `getline junk < t'
+can loop forever if the file exists but is empty. Caveat Emptor.
+

File: gawk.info, Node: Language History, Next: Gawk Summary, Prev: Sample Programs, Up: Top
@@ -13596,7 +13629,7 @@ changes, with cross-references to further details.
Functions for Input/Output: I/O Functions.).
* The `ARGC', `ARGV', `FNR', `RLENGTH', `RSTART', and `SUBSEP'
- built-in variables (*note Built-in Variables::).
+ built-in variables (*note Built-in Variables::.).
* The conditional expression using the ternary operator `?:' (*note
Conditional Expressions: Conditional Exp.).
@@ -13618,7 +13651,7 @@ changes, with cross-references to further details.
How to Use Regular Expressions: Regexp Usage.).
* The escape sequences `\b', `\f', and `\r' (*note Escape
- Sequences::). (Some vendors have updated their old versions of
+ Sequences::.). (Some vendors have updated their old versions of
`awk' to recognize `\r', `\b', and `\f', but this is not something
you can rely on.)
@@ -13640,7 +13673,7 @@ Changes between SVR3.1 and SVR4
The System V Release 4 version of Unix `awk' added these features
(some of which originated in `gawk'):
- * The `ENVIRON' variable (*note Built-in Variables::).
+ * The `ENVIRON' variable (*note Built-in Variables::.).
* Multiple `-f' options on the command line (*note Command Line
Options: Options.).
@@ -13651,7 +13684,7 @@ Changes between SVR3.1 and SVR4
* The `--' option for terminating command line options.
* The `\a', `\v', and `\x' escape sequences (*note Escape
- Sequences::).
+ Sequences::.).
* A defined return value for the `srand' built-in function (*note
Numeric Built-in Functions: Numeric Functions.).
@@ -13697,7 +13730,7 @@ introduced the following changes into the language:
standard:
* `\x' escape sequences are not recognized (*note Escape
- Sequences::).
+ Sequences::.).
* Newlines do not act as whitespace to separate fields when `FS' is
equal to a single space.
@@ -13735,7 +13768,6 @@ describes extensions in his version of `awk' that are not in POSIX
* The `fflush' built-in function for flushing buffered output (*note
Built-in Functions for Input/Output: I/O Functions.).
-

File: gawk.info, Node: POSIX/GNU, Prev: BTL, Up: Language History
@@ -13786,11 +13818,11 @@ all be disabled with either the `--traditional' or `--posix' options
Version 2.15 of `gawk' introduced these features:
* The `ARGIND' variable, that tracks the movement of `FILENAME'
- through `ARGV' (*note Built-in Variables::).
+ through `ARGV' (*note Built-in Variables::.).
* The `ERRNO' variable, that contains the system error message when
`getline' returns -1, or when `close' fails (*note Built-in
- Variables::).
+ Variables::.).
* The ability to use GNU-style long named options that start with
`--' (*note Command Line Options: Options.).
@@ -13851,7 +13883,6 @@ all be disabled with either the `--traditional' or `--posix' options
* Amiga support (*note Installing `gawk' on an Amiga: Amiga
Installation.).
-

File: gawk.info, Node: Gawk Summary, Next: Installation, Prev: Language History, Up: Top
@@ -13871,7 +13902,7 @@ It is therefore terse, but complete.
parts.
* Actions Summary:: Quick overview of actions.
* Functions Summary:: Defining and calling functions.
-* Historical Features:: Some undocumented but supported ``features''.
+* Historical Features:: Some undocumented but supported "features".

File: gawk.info, Node: Command Line Summary, Next: Language Summary, Prev: Gawk Summary, Up: Gawk Summary
@@ -14020,7 +14051,7 @@ matches, the associated ACTION is executed.
---------- Footnotes ----------
- (1) The path may use a directory other than `/usr/local/share/awk',
+ (1) The path may use a directory other than `/usr/local/share/awk',
depending upon how `gawk' was built and installed.

@@ -14056,7 +14087,7 @@ special case that `FS' is a single space, fields are separated by runs
of spaces, tabs and/or newlines.(1) If `FS' is the null string (`""'),
then each individual character in the record becomes a separate field.
Note that the value of `IGNORECASE' (*note Case-sensitivity in
-Matching: Case-sensitivity.) also affects how fields are split when
+Matching: Case-sensitivity.) also affects how fields are split when
`FS' is a regular expression.
Each field in the input line may be referenced by its position, `$1',
@@ -14081,7 +14112,7 @@ Files: Reading Files.
---------- Footnotes ----------
- (1) In POSIX `awk', newline does not separate fields.
+ (1) In POSIX `awk', newline does not separate fields.

File: gawk.info, Node: Built-in Summary, Next: Arrays Summary, Prev: Fields Summary, Up: Variables/Fields
@@ -14149,7 +14180,8 @@ Built-in Variables
`!~', and the `gensub', `gsub', `index', `match', `split' and
`sub' built-in functions all ignore case when doing regular
expression operations, and all string comparisons are done
- ignoring case.
+ ignoring case. The value of `IGNORECASE' does *not* affect array
+ subscripting.
`NF'
The number of fields in the current input record.
@@ -14199,7 +14231,7 @@ Arrays
------
Arrays are subscripted with an expression between square brackets
-(`[' and `]'). Array subscripts are _always_ strings; numbers are
+(`[' and `]'). Array subscripts are *always* strings; numbers are
converted to strings as necessary, following the standard conversion
rules (*note Conversion of Strings and Numbers: Conversion.).
@@ -14369,7 +14401,7 @@ Regular Expressions
Regular expressions are based on POSIX EREs (extended regular
expressions). The escape sequences allowed in string constants are
-also valid in regular expressions (*note Escape Sequences::). Regexps
+also valid in regular expressions (*note Escape Sequences::.). Regexps
are composed of characters as follows:
`C'
@@ -14380,7 +14412,7 @@ are composed of characters as follows:
matches the literal character C.
`.'
- matches any character, _including_ newline. In strict POSIX mode,
+ matches any character, *including* newline. In strict POSIX mode,
`.' does not match the NUL character, which is a character with
all bits equal to zero.
@@ -15168,7 +15200,7 @@ Getting the `gawk' Distribution
2. You can order `gawk' directly from the Free Software Foundation.
Software distributions are available for Unix, MS-DOS, and VMS, on
- tape, CD-ROM, or floppies (MS-DOS only). The address is:
+ tape and CD-ROM. The address is:
Free Software Foundation
59 Temple Place--Suite 330
@@ -15189,27 +15221,19 @@ Getting the `gawk' Distribution
should use a site that is geographically close to you.
Asia:
-
`cair-archive.kaist.ac.kr:/pub/gnu'
`ftp.cs.titech.ac.jp'
`ftp.nectec.or.th:/pub/mirrors/gnu'
`utsun.s.u-tokyo.ac.jp:/ftpsync/prep'
-
Australia:
-
`archie.au:/gnu'
(`archie.oz' or `archie.oz.au' for ACSnet)
Africa:
-
`ftp.sun.ac.za:/pub/gnu'
-
Middle East:
-
`ftp.technion.ac.il:/pub/unsupported/gnu'
-
Europe:
-
`archive.eu.net'
`ftp.denet.dk'
`ftp.eunet.ch'
@@ -15228,18 +15252,12 @@ Getting the `gawk' Distribution
`nic.switch.ch:/mirror/gnu'
`src.doc.ic.ac.uk:/gnu'
`unix.hensa.ac.uk:/pub/uunet/systems/gnu'
-
South America:
-
`ftp.inf.utfsm.cl:/pub/gnu'
`ftp.unicamp.br:/pub/gnu'
-
Western Canada:
-
`ftp.cs.ubc.ca:/mirror2/gnu'
-
USA:
-
`col.hp.com:/mirrors/gnu'
`f.ms.uky.edu:/pub3/gnu'
`ftp.cc.gatech.edu:/pub/gnu'
@@ -15247,7 +15265,6 @@ Getting the `gawk' Distribution
`ftp.digex.net:/pub/gnu'
`ftp.hawaii.edu:/mirrors/gnu'
`ftp.kpc.com:/pub/mirror/gnu'
-
USA (continued):
`ftp.uu.net:/systems/gnu'
`gatekeeper.dec.com:/pub/GNU'
@@ -15266,21 +15283,21 @@ Extracting the Distribution
`gawk' is distributed as a `tar' file compressed with the GNU Zip
program, `gzip'.
- Once you have the distribution (for example, `gawk-3.0.1.tar.gz'),
+ Once you have the distribution (for example, `gawk-3.0.3.tar.gz'),
first use `gzip' to expand the file, and then use `tar' to extract it.
You can use the following pipeline to produce the `gawk' distribution:
# Under System V, add 'o' to the tar flags
- gzip -d -c gawk-3.0.1.tar.gz | tar -xvpf -
+ gzip -d -c gawk-3.0.3.tar.gz | tar -xvpf -
-This will create a directory named `gawk-3.0.1' in the current
+This will create a directory named `gawk-3.0.3' in the current
directory.
The distribution file name is of the form `gawk-V.R.N.tar.gz'. The
V represents the major version of `gawk', the R represents the current
release of version V, and the N represents a "patch level", meaning
that minor bugs have been fixed in the release. The current patch
-level is 0, but when retrieving distributions, you should get the
+level is 3, but when retrieving distributions, you should get the
version with the highest version, release, and patch level. (Note that
release levels greater than or equal to 90 denote "beta," or
non-production software; you may not wish to retrieve such a version
@@ -15412,10 +15429,6 @@ various `.c', `.y', and `.h' files
extracted into ready to use files. They are installed as part of
the installation process.
-`amiga/*'
- Files needed for building `gawk' on an Amiga. *Note Installing
- `gawk' on an Amiga: Amiga Installation, for details.
-
`atari/*'
Files needed for building `gawk' on an Atari ST. *Note Installing
`gawk' on the Atari ST: Atari Installation, for details.
@@ -15457,7 +15470,7 @@ Compiling `gawk' for Unix
-------------------------
After you have extracted the `gawk' distribution, `cd' to
-`gawk-3.0.1'. Like most GNU software, `gawk' is configured
+`gawk-3.0.3'. Like most GNU software, `gawk' is configured
automatically for your Unix system by running the `configure' program.
This program is a Bourne shell script that was generated automatically
using GNU `autoconf'. (The `autoconf' software is described fully
@@ -15643,7 +15656,7 @@ Running `gawk' on VMS
Command line parsing and quoting conventions are significantly
different on VMS, so examples in this Info file or from other sources
-often need minor changes. They _are_ minor though, and all `awk'
+often need minor changes. They *are* minor though, and all `awk'
programs should run correctly.
Here are a couple of trivial tests:
@@ -15743,7 +15756,7 @@ MS-DOS and OS/2. The file `README_d/README.pc' in the `gawk'
distribution contains additional notes, and `pc/Makefile' contains
important notes on compilation options.
- To build `gawk', copy the files in the `pc' directory (_except_ for
+ To build `gawk', copy the files in the `pc' directory (*except* for
`ChangeLog') to the directory with the rest of the `gawk' sources. The
`Makefile' contains a configuration section with comments, and may need
to be edited in order to work with your `make' utility.
@@ -15879,7 +15892,7 @@ function, which may not support this convention. Whenever it is
possible that a file created by `gawk' will be used by some other
program, use only backslashes. Also remember that in `awk',
backslashes in strings have to be doubled in order to get literal
-backslashes (*note Escape Sequences::).
+backslashes (*note Escape Sequences::.).

File: gawk.info, Node: Amiga Installation, Next: Bugs, Prev: Atari Installation, Up: Installation
@@ -15888,13 +15901,13 @@ Installing `gawk' on an Amiga
=============================
You can install `gawk' on an Amiga system using a Unix emulation
-environment available via anonymous `ftp' from `wuarchive.wustl.edu' in
-the directory `pub/aminet/dev/gcc'. This includes a shell based on
+environment available via anonymous `ftp' from `ftp.ninemoons.com' in
+the directory `pub/ade/current'. This includes a shell based on
`pdksh'. The primary component of this environment is a Unix emulation
library, `ixemul.lib'.
- A more complete distribution for the Amiga is available on the
-FreshFish CD-ROM from:
+ A more complete distribution for the Amiga is available on the Geek
+Gadgets CD-ROM from:
CRONUS
1840 E. Warner Road #105-265
@@ -15909,7 +15922,7 @@ FreshFish CD-ROM from:
Once you have the distribution, you can configure `gawk' simply by
running `configure':
- configure -v m68k-cbm-amigados
+ configure -v m68k-amigaos
Then run `make', and you should be all set! (If these steps do not
work, please send in a bug report; *note Reporting Problems and Bugs:
@@ -15921,6 +15934,9 @@ File: gawk.info, Node: Bugs, Next: Other Versions, Prev: Amiga Installation,
Reporting Problems and Bugs
===========================
+ There is nothing more dangerous than a bored archeologist.
+ The Hitchhiker's Guide to the Galaxy
+
If you have problems with `gawk' or think that you have found a bug,
please report it to the developers; we cannot promise to do anything
but we might well want to fix it.
@@ -15952,7 +15968,7 @@ get this information with the command `gawk --version'. You should
send a carbon copy of your mail to Arnold Robbins, who can be reached
at `arnold@gnu.ai.mit.edu'.
- *Important!* Do _not_ try to report bugs in `gawk' by posting to the
+ *Important!* Do *not* try to report bugs in `gawk' by posting to the
Usenet/Internet newsgroup `comp.lang.awk'. While the `gawk' developers
do occasionally read this newsgroup, there is no guarantee that we will
see your posting. The steps described above are the official,
@@ -16109,9 +16125,9 @@ make it possible for me to include to your changes.
Distribution: Getting, for information on getting the latest
version of `gawk'.
- 2. See *note (Version)Top:: standards, GNU Coding Standards. This
+ 2. See *note : (Version)Top standards, GNU Coding Standards. This
document describes how GNU software should be written. If you
- haven't read it, please do so, preferably _before_ starting to
+ haven't read it, please do so, preferably *before* starting to
modify `gawk'. (The `GNU Coding Standards' are available as part
of the Autoconf distribution, from the FSF.)
@@ -16176,7 +16192,7 @@ make it possible for me to include to your changes.
FSF to distribute your changes, you must either place those
changes in the public domain, and submit a signed statement to that
effect, or assign the copyright in your changes to the FSF. Both
- of these actions are easy to do, and _many_ people have done so
+ of these actions are easy to do, and *many* people have done so
already. If you have questions, please contact me (*note Reporting
Problems and Bugs: Bugs.), or `gnu@prep.ai.mit.edu'.
@@ -16184,8 +16200,8 @@ make it possible for me to include to your changes.
new sections and or chapters for this Info file. If at all
possible, please use real Texinfo, instead of just supplying
unformatted ASCII text (although even that is better than no
- documentation at all). Conventions to be followed in `The GNU Awk
- User's Guide' are provided after the `@bye' at the end of the
+ documentation at all). Conventions to be followed in `Effective
+ AWK Programming' are provided after the `@bye' at the end of the
Texinfo source file. If possible, please update the man page as
well.
@@ -16195,10 +16211,10 @@ make it possible for me to include to your changes.
6. Submit changes as context diffs or unified diffs. Use `diff -c -r
-N' or `diff -u -r -N' to compare the original `gawk' source tree
with your version. (I find context diffs to be more readable, but
- unified diffs are more compact.) I recommend using the GNU
- version of `diff'. Send the output produced by either run of
- `diff' to me when you submit your changes. *Note Reporting
- Problems and Bugs: Bugs, for the electronic mail information.
+ unified diffs are more compact.) I recommend using the GNU version
+ of `diff'. Send the output produced by either run of `diff' to me
+ when you submit your changes. *Note Reporting Problems and Bugs:
+ Bugs, for the electronic mail information.
Using this format makes it easy for me to apply your changes to the
master version of the `gawk' source code (using `patch'). If I
@@ -16281,7 +16297,7 @@ several steps to follow.
FSF to distribute your code, you must either place your code in
the public domain, and submit a signed statement to that effect,
or assign the copyright in your code to the FSF. Both of these
- actions are easy to do, and _many_ people have done so already. If
+ actions are easy to do, and *many* people have done so already. If
you have questions, please contact me, or `gnu@prep.ai.mit.edu'.
Following these steps will make it much easier to integrate your
@@ -16324,9 +16340,9 @@ Databases
A `PROCINFO' Array
The special files that provide process-related information (*note
- Special File Names in `gawk': Special Files.) may be superseded
- by a `PROCINFO' array that would provide the same information, in
- an easier to access fashion.
+ Special File Names in `gawk': Special Files.) may be superseded by
+ a `PROCINFO' array that would provide the same information, in an
+ easier to access fashion.
More `lint' warnings
There are more things that could be checked for portability.
@@ -17184,11 +17200,11 @@ Index
* ! operator: Boolean Ops.
* != operator: Typing and Comparison.
-* !~ operator <1>: Typing and Comparison.
-* !~ operator <2>: Regexp Constants.
-* !~ operator <3>: Computed Regexps.
+* !~ operator <1>: Regexp Constants.
+* !~ operator <2>: Typing and Comparison.
+* !~ operator <3>: Regexp Usage.
* !~ operator <4>: Case-sensitivity.
-* !~ operator: Regexp Usage.
+* !~ operator: Computed Regexps.
* # (comment): Comments.
* #! (executable scripts): Executable Scripts.
* $ (field operator): Fields.
@@ -17207,10 +17223,10 @@ Index
* --traditional option: Options.
* --usage option: Options.
* --version option: Options.
-* -f option: Options.
-* -F option <1>: Options.
-* -F option: Command Line Field Separator.
* -f option: Long.
+* -F option <1>: Command Line Field Separator.
+* -F option: Options.
+* -f option: Options.
* -v option: Options.
* -W option: Options.
* /dev/fd: Special Files.
@@ -17220,8 +17236,8 @@ Index
* /dev/stderr: Special Files.
* /dev/stdin: Special Files.
* /dev/stdout: Special Files.
-* /dev/user <1>: Passwd Functions.
-* /dev/user: Special Files.
+* /dev/user <1>: Special Files.
+* /dev/user: Passwd Functions.
* < operator: Typing and Comparison.
* <= operator: Typing and Comparison.
* == operator: Typing and Comparison.
@@ -17240,8 +17256,8 @@ Index
* _tm_addup: Mktime Function.
* _tm_isleap: Mktime Function.
* accessing fields: Fields.
-* account information <1>: Group Functions.
-* account information: Passwd Functions.
+* account information <1>: Passwd Functions.
+* account information: Group Functions.
* acronym: History.
* action, curly braces: Action Overview.
* action, default: Very Simple.
@@ -17256,20 +17272,21 @@ Index
* amiga: Amiga Installation.
* anchors in regexps: Regexp Operators.
* and operator: Boolean Ops.
-* anonymous ftp <1>: Other Versions.
-* anonymous ftp: Getting.
+* anonymous ftp <1>: Getting.
+* anonymous ftp: Other Versions.
* applications of awk: When.
* ARGC: Auto-set.
-* ARGIND <1>: Other Arguments.
-* ARGIND: Auto-set.
+* ARGIND <1>: Auto-set.
+* ARGIND: Other Arguments.
* argument processing: Getopt Function.
* arguments in function call: Function Calls.
* arguments, command line: Invoking Gawk.
-* ARGV <1>: Other Arguments.
-* ARGV: Auto-set.
+* ARGV <1>: Auto-set.
+* ARGV: Other Arguments.
* arithmetic operators: Arithmetic Ops.
* array assignment: Assigning Elements.
* array reference: Reference to Elements.
+* Array subscripts and IGNORECASE: Array Intro.
* array subscripts, uninitialized variables: Uninitialized Subscripts.
* arrays: Array Intro.
* arrays, associative: Array Intro.
@@ -17292,30 +17309,33 @@ Index
* atan2: Numeric Functions.
* atari: Atari Installation.
* automatic initialization: More Complex.
-* awk language, POSIX version <1>: Definition Syntax.
-* awk language, POSIX version <2>: String Functions.
-* awk language, POSIX version <3>: User-modified.
-* awk language, POSIX version <4>: Next Statement.
-* awk language, POSIX version <5>: Continue Statement.
-* awk language, POSIX version <6>: Break Statement.
-* awk language, POSIX version <7>: Precedence.
-* awk language, POSIX version <8>: Assignment Ops.
-* awk language, POSIX version <9>: Arithmetic Ops.
-* awk language, POSIX version <10>: Conversion.
-* awk language, POSIX version <11>: Format Modifiers.
-* awk language, POSIX version <12>: OFMT.
-* awk language, POSIX version <13>: Field Splitting Summary.
-* awk language, POSIX version <14>: Regexp Operators.
-* awk language, POSIX version: Escape Sequences.
+* awk language, POSIX version <1>: OFMT.
+* awk language, POSIX version <2>: Next Statement.
+* awk language, POSIX version <3>: Continue Statement.
+* awk language, POSIX version <4>: Format Modifiers.
+* awk language, POSIX version <5>: Field Splitting Summary.
+* awk language, POSIX version <6>: Arithmetic Ops.
+* awk language, POSIX version <7>: User-modified.
+* awk language, POSIX version <8>: Precedence.
+* awk language, POSIX version <9>: Assignment Ops.
+* awk language, POSIX version <10>: String Functions.
+* awk language, POSIX version <11>: Regexp Operators.
+* awk language, POSIX version <12>: Escape Sequences.
+* awk language, POSIX version <13>: Regexp Operators.
+* awk language, POSIX version <14>: String Functions.
+* awk language, POSIX version <15>: Definition Syntax.
+* awk language, POSIX version <16>: Break Statement.
+* awk language, POSIX version <17>: Regexp Operators.
+* awk language, POSIX version: Conversion.
* awk language, V.4 version <1>: SVR4.
* awk language, V.4 version: Escape Sequences.
* AWKPATH environment variable: AWKPATH Variable.
* awksed: Simple Sed.
-* backslash continuation <1>: Egrep Program.
-* backslash continuation: Statements/Lines.
+* backslash continuation <1>: Statements/Lines.
+* backslash continuation: Egrep Program.
* backslash continuation and comments: Statements/Lines.
-* backslash continuation in csh <1>: Statements/Lines.
-* backslash continuation in csh: More Complex.
+* backslash continuation in csh <1>: More Complex.
+* backslash continuation in csh: Statements/Lines.
* basic function of awk: Getting Started.
* BBS-list file: Sample Data Files.
* BEGIN special pattern: BEGIN/END.
@@ -17327,8 +17347,9 @@ Index
* break statement: Break Statement.
* break, outside of loops: Break Statement.
* Brennan, Michael <1>: Other Versions.
-* Brennan, Michael <2>: Simple Sed.
-* Brennan, Michael: Delete.
+* Brennan, Michael <2>: Delete.
+* Brennan, Michael <3>: Other Versions.
+* Brennan, Michael: Simple Sed.
* buffer matching operators: GNU Regexp Operators.
* buffering output: I/O Functions.
* buffering, interactive vs. non-interactive: I/O Functions.
@@ -17372,8 +17393,8 @@ Index
* comp.lang.awk: Bugs.
* comparison expressions: Typing and Comparison.
* comparisons, string vs. regexp: Typing and Comparison.
-* compatibility mode <1>: POSIX/GNU.
-* compatibility mode: Options.
+* compatibility mode <1>: Options.
+* compatibility mode: POSIX/GNU.
* complemented character list: Regexp Operators.
* compound statement: Statements.
* computed regular expressions: Computed Regexps.
@@ -17390,40 +17411,42 @@ Index
* conversions, during subscripting: Numeric Array Subscripts.
* converting dates to timestamps: Mktime Function.
* CONVFMT <1>: Numeric Array Subscripts.
-* CONVFMT <2>: User-modified.
-* CONVFMT: Conversion.
+* CONVFMT <2>: Conversion.
+* CONVFMT: User-modified.
* cos: Numeric Functions.
-* csh, backslash continuation <1>: Statements/Lines.
-* csh, backslash continuation: More Complex.
+* csh, backslash continuation <1>: More Complex.
+* csh, backslash continuation: Statements/Lines.
* curly braces: Action Overview.
* custom.h configuration file: Configuration Philosophy.
* cut utility: Cut Program.
* cut.awk: Cut Program.
* d.c., see "dark corner": This Manual.
-* dark corner <1>: Other Arguments.
-* dark corner <2>: Invoking Gawk.
-* dark corner <3>: String Functions.
-* dark corner <4>: Uninitialized Subscripts.
-* dark corner <5>: Auto-set.
-* dark corner <6>: Exit Statement.
-* dark corner <7>: Continue Statement.
-* dark corner <8>: Break Statement.
-* dark corner <9>: Using BEGIN/END.
-* dark corner <10>: Truth Values.
-* dark corner <11>: Conversion.
-* dark corner <12>: Assignment Options.
-* dark corner <13>: Using Constant Regexps.
-* dark corner <14>: Format Modifiers.
-* dark corner <15>: Control Letters.
-* dark corner <16>: OFMT.
+* dark corner <1>: Control Letters.
+* dark corner <2>: Continue Statement.
+* dark corner <3>: Using Constant Regexps.
+* dark corner <4>: Single Character Fields.
+* dark corner <5>: OFMT.
+* dark corner <6>: Auto-set.
+* dark corner <7>: Truth Values.
+* dark corner <8>: Field Splitting Summary.
+* dark corner <9>: Assignment Options.
+* dark corner <10>: This Manual.
+* dark corner <11>: Escape Sequences.
+* dark corner <12>: Format Modifiers.
+* dark corner <13>: Break Statement.
+* dark corner <14>: Invoking Gawk.
+* dark corner <15>: Plain Getline.
+* dark corner <16>: Using Constant Regexps.
* dark corner <17>: Getline Summary.
-* dark corner <18>: Plain Getline.
-* dark corner <19>: Multiple Line.
-* dark corner <20>: Field Splitting Summary.
-* dark corner <21>: Single Character Fields.
-* dark corner <22>: Records.
-* dark corner <23>: Escape Sequences.
-* dark corner: This Manual.
+* dark corner <18>: Multiple Line.
+* dark corner <19>: String Functions.
+* dark corner <20>: Conversion.
+* dark corner <21>: Uninitialized Subscripts.
+* dark corner <22>: Auto-set.
+* dark corner <23>: Records.
+* dark corner <24>: Exit Statement.
+* dark corner <25>: Other Arguments.
+* dark corner: Using BEGIN/END.
* data-driven languages: Getting Started.
* dates, converting to timestamps: Mktime Function.
* decrement operators: Increment Ops.
@@ -17437,24 +17460,28 @@ Index
* deleting entire arrays: Delete.
* deprecated features: Obsolete.
* deprecated options: Obsolete.
-* differences between gawk and awk <1>: AWKPATH Variable.
-* differences between gawk and awk <2>: String Functions.
-* differences between gawk and awk <3>: Calling Built-in.
-* differences between gawk and awk <4>: Delete.
-* differences between gawk and awk <5>: Nextfile Statement.
-* differences between gawk and awk <6>: I/O And BEGIN/END.
-* differences between gawk and awk <7>: Conditional Exp.
-* differences between gawk and awk <8>: Arithmetic Ops.
-* differences between gawk and awk <9>: Using Constant Regexps.
-* differences between gawk and awk <10>: Scalar Constants.
-* differences between gawk and awk <11>: Close Files And Pipes.
-* differences between gawk and awk <12>: Special Files.
-* differences between gawk and awk <13>: Redirection.
-* differences between gawk and awk <14>: Getline Summary.
-* differences between gawk and awk <15>: Getline Intro.
-* differences between gawk and awk <16>: Single Character Fields.
-* differences between gawk and awk <17>: Records.
-* differences between gawk and awk: Case-sensitivity.
+* differences between gawk and awk <1>: Records.
+* differences between gawk and awk <2>: Scalar Constants.
+* differences between gawk and awk <3>: Getline Summary.
+* differences between gawk and awk <4>: ARGC and ARGV.
+* differences between gawk and awk <5>: Calling Built-in.
+* differences between gawk and awk <6>: Nextfile Statement.
+* differences between gawk and awk <7>: AWKPATH Variable.
+* differences between gawk and awk <8>: Getline Intro.
+* differences between gawk and awk <9>: Special Files.
+* differences between gawk and awk <10>: Conditional Exp.
+* differences between gawk and awk <11>: Arithmetic Ops.
+* differences between gawk and awk <12>: String Functions.
+* differences between gawk and awk <13>: I/O And BEGIN/END.
+* differences between gawk and awk <14>: Redirection.
+* differences between gawk and awk <15>: Case-sensitivity.
+* differences between gawk and awk <16>: Using Constant Regexps.
+* differences between gawk and awk <17>: Close Files And Pipes.
+* differences between gawk and awk <18>: String Functions.
+* differences between gawk and awk <19>: Close Files And Pipes.
+* differences between gawk and awk <20>: Delete.
+* differences between gawk and awk <21>: Single Character Fields.
+* differences between gawk and awk: Records.
* directory search: AWKPATH Variable.
* division: Arithmetic Ops.
* documenting awk programs <1>: Library Names.
@@ -17462,8 +17489,8 @@ Index
* dupword.awk: Dupword Program.
* dynamic regular expressions: Computed Regexps.
* EBCDIC: Ordinal Functions.
-* egrep <1>: Regexp Operators.
-* egrep: One-shot.
+* egrep <1>: One-shot.
+* egrep: Regexp Operators.
* egrep utility: Egrep Program.
* egrep.awk: Egrep Program.
* element assignment: Assigning Elements.
@@ -17483,13 +17510,13 @@ Index
* environment variable, AWKPATH: AWKPATH Variable.
* environment variable, POSIXLY_CORRECT: Options.
* equivalence classes: Regexp Operators.
-* ERRNO <1>: Auto-set.
+* ERRNO <1>: Getline Intro.
* ERRNO <2>: Close Files And Pipes.
-* ERRNO: Getline Intro.
+* ERRNO: Auto-set.
* errors, common <1>: Typing and Comparison.
-* errors, common <2>: Print Examples.
+* errors, common <2>: Computed Regexps.
* errors, common <3>: Basic Field Splitting.
-* errors, common: Computed Regexps.
+* errors, common: Print Examples.
* escape processing, sub et. al.: String Functions.
* escape sequence notation: Escape Sequences.
* evaluation, order of: Calling Built-in.
@@ -17518,9 +17545,9 @@ Index
* FIELDWIDTHS: User-modified.
* file descriptors: Special Files.
* file, awk program: Long.
-* FILENAME <1>: Auto-set.
+* FILENAME <1>: Reading Files.
* FILENAME <2>: Getline Summary.
-* FILENAME: Reading Files.
+* FILENAME: Auto-set.
* FILENAME, being set by getline: Getline Summary.
* Fish, Fred: Bugs.
* flushing buffers: I/O Functions.
@@ -17534,15 +17561,16 @@ Index
* formatted output: Printf.
* formatted timestamps: Gettimeofday Function.
* Free Software Foundation <1>: Getting.
-* Free Software Foundation: Manual History.
+* Free Software Foundation <2>: Manual History.
+* Free Software Foundation: Getting.
* FreeBSD: Manual History.
* Friedl, Jeffrey: Acknowledgements.
-* FS <1>: User-modified.
-* FS: Basic Field Splitting.
-* ftp, anonymous <1>: Other Versions.
-* ftp, anonymous: Getting.
-* function call <1>: Function Caveats.
-* function call: Function Calls.
+* FS <1>: Basic Field Splitting.
+* FS: User-modified.
+* ftp, anonymous <1>: Getting.
+* ftp, anonymous: Other Versions.
+* function call <1>: Function Calls.
+* function call: Function Caveats.
* function definition: Definition Syntax.
* function, recursive: Definition Syntax.
* functions, undefined: Function Caveats.
@@ -17574,11 +17602,11 @@ Index
* gsub, third argument of: String Functions.
* Hankerson, Darrel <1>: Bugs.
* Hankerson, Darrel: Acknowledgements.
-* historical features <1>: Historical Features.
+* historical features <1>: Command Line Field Separator.
* historical features <2>: String Functions.
-* historical features <3>: Continue Statement.
-* historical features <4>: Break Statement.
-* historical features: Command Line Field Separator.
+* historical features <3>: Break Statement.
+* historical features <4>: Continue Statement.
+* historical features: Historical Features.
* history of awk: History.
* histsort.awk: History Sorting.
* how awk works: Two Rules.
@@ -17589,10 +17617,12 @@ Index
* if-else statement: If Statement.
* igawk.sh: Igawk Program.
* IGNORECASE <1>: User-modified.
+* IGNORECASE <2>: Array Intro.
* IGNORECASE: Case-sensitivity.
+* IGNORECASE and array subscripts: Array Intro.
* ignoring case: Case-sensitivity.
-* implementation limits <1>: Redirection.
-* implementation limits: Getline Summary.
+* implementation limits <1>: Getline Summary.
+* implementation limits: Redirection.
* in operator: Typing and Comparison.
* increment operators: Increment Ops.
* index: String Functions.
@@ -17618,16 +17648,17 @@ Index
* inventory-shipped file: Sample Data Files.
* invocation of gawk: Invoking Gawk.
* ISO 8601: Time Functions.
-* ISO 8859-1 <1>: Glossary.
-* ISO 8859-1: Case-sensitivity.
+* ISO 8859-1 <1>: Case-sensitivity.
+* ISO 8859-1: Glossary.
* ISO Latin-1 <1>: Glossary.
* ISO Latin-1: Case-sensitivity.
-* Jaegermann, Michal <1>: Bugs.
-* Jaegermann, Michal: Acknowledgements.
+* Jaegermann, Michal <1>: Acknowledgements.
+* Jaegermann, Michal: Bugs.
* join: Join Function.
-* Kernighan, Brian <1>: Other Versions.
-* Kernighan, Brian <2>: BTL.
-* Kernighan, Brian <3>: Acknowledgements.
+* Kernighan, Brian <1>: Concatenation.
+* Kernighan, Brian <2>: Acknowledgements.
+* Kernighan, Brian <3>: Other Versions.
+* Kernighan, Brian <4>: BTL.
* Kernighan, Brian: History.
* known bugs: Known Bugs.
* labels.awk: Labels Program.
@@ -17640,12 +17671,12 @@ Index
* limitations <1>: Redirection.
* limitations: Getline Summary.
* line break: Statements/Lines.
-* line continuation <1>: Conditional Exp.
-* line continuation <2>: Boolean Ops.
-* line continuation <3>: Print Examples.
-* line continuation: Statements/Lines.
-* Linux <1>: Atari Compiling.
-* Linux: Manual History.
+* line continuation <1>: Boolean Ops.
+* line continuation <2>: Print Examples.
+* line continuation <3>: Statements/Lines.
+* line continuation: Conditional Exp.
+* Linux <1>: Manual History.
+* Linux: Atari Compiling.
* locale, definition of: Time Functions.
* log: Numeric Functions.
* logical false: Truth Values.
@@ -17664,10 +17695,10 @@ Index
* mawk: Other Versions.
* merging strings: Join Function.
* metacharacters: Regexp Operators.
-* mistakes, common <1>: Typing and Comparison.
-* mistakes, common <2>: Print Examples.
-* mistakes, common <3>: Basic Field Splitting.
-* mistakes, common: Computed Regexps.
+* mistakes, common <1>: Basic Field Splitting.
+* mistakes, common <2>: Typing and Comparison.
+* mistakes, common <3>: Computed Regexps.
+* mistakes, common: Print Examples.
* mktime: Mktime Function.
* modifiers (in format specifiers): Format Modifiers.
* multi-dimensional subscripts: Multi-dimensional.
@@ -17687,15 +17718,15 @@ Index
* next, inside a user-defined function: Next Statement.
* nextfile function: Nextfile Function.
* nextfile statement: Nextfile Statement.
-* NF <1>: Auto-set.
-* NF: Fields.
+* NF <1>: Fields.
+* NF: Auto-set.
* non-interactive buffering vs. interactive: I/O Functions.
* not operator: Boolean Ops.
* NR <1>: Auto-set.
* NR: Records.
-* null string <1>: Truth Values.
-* null string <2>: Conversion.
-* null string: Regexp Field Splitting.
+* null string <1>: Conversion.
+* null string <2>: Regexp Field Splitting.
+* null string: Truth Values.
* null string, as array subscript: Uninitialized Subscripts.
* number of fields, NF: Fields.
* number of records, NR, FNR: Records.
@@ -17708,10 +17739,10 @@ Index
* obsolete features: Obsolete.
* obsolete options: Obsolete.
* OFMT <1>: User-modified.
-* OFMT <2>: Conversion.
-* OFMT: OFMT.
-* OFS <1>: User-modified.
-* OFS: Output Separators.
+* OFMT <2>: OFMT.
+* OFMT: Conversion.
+* OFS <1>: Output Separators.
+* OFS: User-modified.
* old awk: History.
* old awk vs. new awk: Names.
* one-liners: One-liners.
@@ -17732,8 +17763,8 @@ Index
* or operator: Boolean Ops.
* ord: Ordinal Functions.
* order of evaluation: Calling Built-in.
-* ORS <1>: User-modified.
-* ORS: Output Separators.
+* ORS <1>: Output Separators.
+* ORS: User-modified.
* output: Printing.
* output field separator, OFS: Output Separators.
* output format specifier, OFMT: OFMT.
@@ -17757,30 +17788,33 @@ Index
* PERL: Future Extensions.
* pipeline, input: Getline/Pipe.
* pipes for output: Redirection.
-* portability issues <1>: Portability Notes.
-* portability issues <2>: Definition Syntax.
-* portability issues <3>: I/O Functions.
-* portability issues <4>: String Functions.
-* portability issues <5>: Delete.
-* portability issues <6>: Close Files And Pipes.
-* portability issues <7>: Escape Sequences.
-* portability issues: Statements/Lines.
+* portability issues <1>: Delete.
+* portability issues <2>: Statements/Lines.
+* portability issues <3>: String Functions.
+* portability issues <4>: Close Files And Pipes.
+* portability issues <5>: Definition Syntax.
+* portability issues <6>: I/O Functions.
+* portability issues <7>: Portability Notes.
+* portability issues: Escape Sequences.
* porting gawk: New Ports.
-* POSIX awk <1>: Definition Syntax.
-* POSIX awk <2>: String Functions.
-* POSIX awk <3>: User-modified.
-* POSIX awk <4>: Next Statement.
-* POSIX awk <5>: Continue Statement.
-* POSIX awk <6>: Break Statement.
-* POSIX awk <7>: Precedence.
-* POSIX awk <8>: Assignment Ops.
-* POSIX awk <9>: Arithmetic Ops.
+* POSIX awk <1>: Assignment Ops.
+* POSIX awk <2>: Field Splitting Summary.
+* POSIX awk <3>: Format Modifiers.
+* POSIX awk <4>: String Functions.
+* POSIX awk <5>: OFMT.
+* POSIX awk <6>: Escape Sequences.
+* POSIX awk <7>: Definition Syntax.
+* POSIX awk <8>: Arithmetic Ops.
+* POSIX awk <9>: Precedence.
* POSIX awk <10>: Conversion.
-* POSIX awk <11>: Format Modifiers.
-* POSIX awk <12>: OFMT.
-* POSIX awk <13>: Field Splitting Summary.
-* POSIX awk <14>: Regexp Operators.
-* POSIX awk: Escape Sequences.
+* POSIX awk <11>: User-modified.
+* POSIX awk <12>: Next Statement.
+* POSIX awk <13>: Continue Statement.
+* POSIX awk <14>: Break Statement.
+* POSIX awk <15>: Regexp Operators.
+* POSIX awk <16>: String Functions.
+* POSIX awk <17>: Precedence.
+* POSIX awk: Regexp Operators.
* POSIX mode: Options.
* POSIXLY_CORRECT environment variable: Options.
* precedence: Precedence.
@@ -17797,8 +17831,8 @@ Index
* program, awk: This Manual.
* program, definition of: Getting Started.
* program, self contained: Executable Scripts.
-* programs, documenting <1>: Library Names.
-* programs, documenting: Comments.
+* programs, documenting <1>: Comments.
+* programs, documenting: Library Names.
* pwcat program: Passwd Functions.
* pwcat.c: Passwd Functions.
* quotient: Arithmetic Ops.
@@ -17808,9 +17842,9 @@ Index
* rand: Numeric Functions.
* random numbers, seed of: Numeric Functions.
* range pattern: Ranges.
-* Rankin, Pat <1>: Bugs.
-* Rankin, Pat <2>: Assignment Ops.
-* Rankin, Pat: Acknowledgements.
+* Rankin, Pat <1>: Acknowledgements.
+* Rankin, Pat <2>: Bugs.
+* Rankin, Pat: Assignment Ops.
* reading files: Reading Files.
* reading files, getline command: Getline.
* reading files, multiple line records: Multiple Line.
@@ -17827,8 +17861,8 @@ Index
* regexp comparison vs. string comparison: Typing and Comparison.
* regexp constant: Regexp Usage.
* regexp constants, difference between slashes and quotes: Computed Regexps.
-* regexp match/non-match operators <1>: Typing and Comparison.
-* regexp match/non-match operators: Regexp Usage.
+* regexp match/non-match operators <1>: Regexp Usage.
+* regexp match/non-match operators: Typing and Comparison.
* regexp matching operators: Regexp Usage.
* regexp operators: Regexp Operators.
* regexp operators, GNU specific: GNU Regexp Operators.
@@ -17859,9 +17893,9 @@ Index
* RS: Records.
* RSTART <1>: String Functions.
* RSTART: Auto-set.
-* RT <1>: Auto-set.
-* RT <2>: Multiple Line.
-* RT: Records.
+* RT <1>: Records.
+* RT <2>: Auto-set.
+* RT: Multiple Line.
* rule, definition of: Getting Started.
* running awk programs: Running gawk.
* running long programs: Long.
@@ -17873,13 +17907,13 @@ Index
* scripts, shell: Executable Scripts.
* search path: AWKPATH Variable.
* search path, for source files: AWKPATH Variable.
-* sed utility <1>: Igawk Program.
-* sed utility <2>: Simple Sed.
+* sed utility <1>: Simple Sed.
+* sed utility <2>: Igawk Program.
* sed utility: Field Splitting Summary.
* seed for random numbers: Numeric Functions.
* self contained programs: Executable Scripts.
-* shell quoting <1>: Long.
-* shell quoting: Read Terminal.
+* shell quoting <1>: Read Terminal.
+* shell quoting: Long.
* shell scripts: Executable Scripts.
* short-circuit operators: Boolean Ops.
* side effect: Assignment Ops.
@@ -17914,8 +17948,8 @@ Index
* sub: String Functions.
* sub, third argument of: String Functions.
* subscripts in arrays: Multi-dimensional.
-* SUBSEP <1>: Multi-dimensional.
-* SUBSEP: User-modified.
+* SUBSEP <1>: User-modified.
+* SUBSEP: Multi-dimensional.
* substr: String Functions.
* subtraction: Arithmetic Ops.
* system: I/O Functions.
@@ -17962,271 +17996,244 @@ Index
* wordfreq.sh: Word Sorting.
* || operator: Boolean Ops.
* ~ operator <1>: Typing and Comparison.
-* ~ operator <2>: Regexp Constants.
-* ~ operator <3>: Computed Regexps.
-* ~ operator <4>: Case-sensitivity.
-* ~ operator: Regexp Usage.
+* ~ operator <2>: Regexp Usage.
+* ~ operator <3>: Case-sensitivity.
+* ~ operator <4>: Computed Regexps.
+* ~ operator: Regexp Constants.

Tag Table:
-Node: Top1197
-Node: Preface20700
-Ref: Preface-Footnote-121817
-Node: History22049
-Node: Manual History23407
-Node: Acknowledgements26997
-Node: What Is Awk30624
-Node: This Manual32278
-Node: Conventions34919
-Node: Sample Data Files36211
-Node: Getting Started39294
-Node: Names41602
-Ref: Names-Footnote-143099
-Node: Running gawk43171
-Node: One-shot44332
-Node: Read Terminal45719
-Node: Long47331
-Node: Executable Scripts48724
-Ref: Executable Scripts-Footnote-150374
-Ref: Executable Scripts-Footnote-250523
-Node: Comments50977
-Node: Very Simple52137
-Node: Two Rules54184
-Node: More Complex56363
-Node: Statements/Lines59479
-Node: Other Features63752
-Node: When64478
-Node: One-liners66412
-Node: Regexp69299
-Node: Regexp Usage70625
-Node: Escape Sequences72775
-Node: Regexp Operators78227
-Node: GNU Regexp Operators89260
-Node: Case-sensitivity92965
-Node: Leftmost Longest96080
-Node: Computed Regexps97615
-Node: Reading Files100272
-Node: Records102039
-Node: Fields108534
-Ref: Fields-Footnote-1111516
-Node: Non-Constant Fields111602
-Node: Changing Fields113888
-Node: Field Separators118295
-Node: Basic Field Splitting118997
-Node: Regexp Field Splitting122226
-Node: Single Character Fields124792
-Node: Command Line Field Separator125869
-Node: Field Splitting Summary129109
-Ref: Field Splitting Summary-Footnote-1131028
-Node: Constant Size131129
-Node: Multiple Line135166
-Node: Getline140574
-Node: Getline Intro141648
-Node: Plain Getline142611
-Node: Getline/Variable144875
-Node: Getline/File146017
-Node: Getline/Variable/File147327
-Node: Getline/Pipe149301
-Node: Getline/Variable/Pipe151391
-Node: Getline Summary152509
-Node: Printing154103
-Node: Print155171
-Node: Print Examples157271
-Node: Output Separators159882
-Node: OFMT161780
-Node: Printf163182
-Node: Basic Printf164086
-Node: Control Letters165620
-Node: Format Modifiers168308
-Node: Printf Examples172457
-Node: Redirection175236
-Node: Special Files179874
-Node: Close Files And Pipes185111
-Node: Expressions189172
-Node: Constants191378
-Node: Scalar Constants191857
-Ref: Scalar Constants-Footnote-1192717
-Node: Regexp Constants192861
-Node: Using Constant Regexps193323
-Node: Variables196524
-Node: Using Variables197178
-Node: Assignment Options198613
-Node: Conversion200557
-Node: Arithmetic Ops203738
-Node: Concatenation205872
-Node: Assignment Ops207227
-Node: Increment Ops212822
-Node: Truth Values215350
-Node: Typing and Comparison216398
-Node: Boolean Ops222298
-Node: Conditional Exp225991
-Node: Function Calls227668
-Node: Precedence230548
-Node: Patterns and Actions233936
-Node: Pattern Overview234362
-Node: Kinds of Patterns235137
-Node: Regexp Patterns236274
-Node: Expression Patterns236828
-Node: Ranges240480
-Node: BEGIN/END243199
-Node: Using BEGIN/END243668
-Node: I/O And BEGIN/END246630
-Node: Empty248646
-Node: Action Overview248945
-Node: Statements251516
-Node: If Statement253222
-Node: While Statement254725
-Node: Do Statement256756
-Node: For Statement257858
-Node: Break Statement261115
-Node: Continue Statement263386
-Node: Next Statement265382
-Node: Nextfile Statement267879
-Node: Exit Statement269793
-Node: Built-in Variables271803
-Node: User-modified272899
-Ref: User-modified-Footnote-1277688
-Node: Auto-set277750
-Ref: Auto-set-Footnote-1284073
-Node: ARGC and ARGV284279
-Node: Arrays286981
-Node: Array Intro288444
-Node: Reference to Elements292320
-Node: Assigning Elements294270
-Node: Array Example294772
-Node: Scanning an Array296491
-Node: Delete298821
-Node: Numeric Array Subscripts300881
-Node: Uninitialized Subscripts302787
-Node: Multi-dimensional304427
-Node: Multi-scanning307522
-Node: Built-in309165
-Node: Calling Built-in310154
-Node: Numeric Functions312125
-Ref: Numeric Functions-Footnote-1315673
-Node: String Functions315943
-Ref: String Functions-Footnote-1334729
-Ref: String Functions-Footnote-2334780
-Node: I/O Functions334873
-Ref: I/O Functions-Footnote-1340366
-Node: Time Functions340457
-Ref: Time Functions-Footnote-1348776
-Ref: Time Functions-Footnote-2348887
-Ref: Time Functions-Footnote-3349163
-Node: User-defined349307
-Node: Definition Syntax350019
-Node: Function Example354268
-Node: Function Caveats356598
-Node: Return Statement360469
-Node: Invoking Gawk363124
-Node: Options364359
-Ref: Options-Footnote-1373162
-Node: Other Arguments373187
-Node: AWKPATH Variable375833
-Ref: AWKPATH Variable-Footnote-1378281
-Node: Obsolete378581
-Node: Undocumented379247
-Node: Known Bugs379455
-Node: Library Functions380593
-Node: Portability Notes383012
-Node: Nextfile Function384296
-Ref: Nextfile Function-Footnote-1389001
-Node: Assert Function389171
-Node: Round Function392510
-Node: Ordinal Functions394155
-Ref: Ordinal Functions-Footnote-1397387
-Node: Join Function397606
-Node: Mktime Function399658
-Ref: Mktime Function-Footnote-1411149
-Node: Gettimeofday Function411232
-Node: Filetrans Function415244
-Node: Getopt Function418921
-Node: Passwd Functions430277
-Node: Group Functions438612
-Node: Library Names446509
-Node: Sample Programs450434
-Node: Clones450925
-Node: Cut Program452019
-Node: Egrep Program462048
-Node: Id Program469710
-Node: Split Program472981
-Node: Tee Program476359
-Node: Uniq Program479155
-Node: Wc Program486700
-Ref: Wc Program-Footnote-1490936
-Node: Miscellaneous Programs491117
-Node: Dupword Program492027
-Node: Alarm Program493698
-Node: Translate Program498243
-Ref: Translate Program-Footnote-1502730
-Ref: Translate Program-Footnote-2502873
-Node: Labels Program503053
-Ref: Labels Program-Footnote-1506512
-Node: Word Sorting506596
-Node: History Sorting510940
-Node: Extract Program512909
-Node: Simple Sed519866
-Node: Igawk Program523210
-Node: Language History536353
-Node: V7/SVR3.1537586
-Node: SVR4540239
-Node: POSIX541759
-Node: BTL543378
-Node: POSIX/GNU544142
-Node: Gawk Summary548573
-Node: Command Line Summary549397
-Node: Language Summary552373
-Ref: Language Summary-Footnote-1554630
-Node: Variables/Fields554753
-Node: Fields Summary555487
-Ref: Fields Summary-Footnote-1557215
-Node: Built-in Summary557273
-Node: Arrays Summary560918
-Node: Data Type Summary562211
-Node: Rules Summary564037
-Node: Pattern Summary565565
-Node: Regexp Summary567750
-Node: Actions Summary571132
-Node: Operator Summary572964
-Node: Control Flow Summary574191
-Node: I/O Summary574748
-Node: Printf Summary577737
-Node: Special File Summary581075
-Node: Built-in Functions Summary582753
-Node: Time Functions Summary586753
-Node: String Constants Summary587644
-Node: Functions Summary588964
-Node: Historical Features590025
-Node: Installation591523
-Node: Gawk Distribution592738
-Node: Getting593241
-Node: Extracting596226
-Node: Distribution contents597613
-Node: Unix Installation602527
-Node: Quick Installation603036
-Node: Configuration Philosophy604554
-Node: VMS Installation606956
-Node: VMS Compilation607495
-Node: VMS Installation Details609099
-Node: VMS Running610741
-Node: VMS POSIX612331
-Node: PC Installation613611
-Node: Atari Installation617014
-Node: Atari Compiling618198
-Node: Atari Using620107
-Node: Amiga Installation622953
-Node: Bugs624071
-Node: Other Versions627040
-Node: Notes628614
-Node: Compatibility Mode629221
-Node: Additions630064
-Node: Adding Code630762
-Node: New Ports636102
-Node: Future Extensions640270
-Node: Improvements642519
-Node: Glossary644387
-Node: Copying661452
-Node: Index680644
+Node: Top1230
+Node: Preface20719
+Node: History22069
+Node: Manual History23427
+Node: Acknowledgements26869
+Node: What Is Awk30496
+Node: This Manual32150
+Node: Conventions34849
+Node: Sample Data Files36141
+Node: Getting Started39224
+Node: Names41532
+Node: Running gawk43102
+Node: One-shot44263
+Node: Read Terminal45650
+Node: Long47262
+Node: Executable Scripts48655
+Node: Comments50910
+Node: Very Simple52070
+Node: Two Rules54117
+Node: More Complex56296
+Node: Statements/Lines59412
+Node: Other Features63685
+Node: When64411
+Node: One-liners66346
+Node: Regexp69233
+Node: Regexp Usage70559
+Node: Escape Sequences72709
+Node: Regexp Operators78161
+Node: GNU Regexp Operators89194
+Node: Case-sensitivity92898
+Node: Leftmost Longest96014
+Node: Computed Regexps97549
+Node: Reading Files100206
+Node: Records101974
+Node: Fields108469
+Node: Non-Constant Fields111538
+Node: Changing Fields113825
+Node: Field Separators118232
+Node: Basic Field Splitting118934
+Node: Regexp Field Splitting122163
+Node: Single Character Fields124730
+Node: Command Line Field Separator125799
+Node: Field Splitting Summary129040
+Node: Constant Size131059
+Node: Multiple Line135096
+Node: Getline140504
+Node: Getline Intro141578
+Node: Plain Getline142541
+Node: Getline/Variable144805
+Node: Getline/File145947
+Node: Getline/Variable/File147257
+Node: Getline/Pipe149231
+Node: Getline/Variable/Pipe151321
+Node: Getline Summary152439
+Node: Printing154033
+Node: Print155101
+Node: Print Examples157201
+Node: Output Separators159811
+Node: OFMT161709
+Node: Printf163111
+Node: Basic Printf164015
+Node: Control Letters165549
+Node: Format Modifiers168237
+Node: Printf Examples172386
+Node: Redirection175164
+Node: Special Files179803
+Node: Close Files And Pipes185040
+Node: Expressions189100
+Node: Constants191296
+Node: Scalar Constants191775
+Node: Regexp Constants192780
+Node: Using Constant Regexps193242
+Node: Variables196443
+Node: Using Variables197097
+Node: Assignment Options198532
+Node: Conversion200477
+Node: Arithmetic Ops203659
+Node: Concatenation205793
+Node: Assignment Ops207215
+Node: Increment Ops212811
+Node: Truth Values215339
+Node: Typing and Comparison216387
+Node: Boolean Ops222394
+Node: Conditional Exp226087
+Node: Function Calls227764
+Node: Precedence230644
+Node: Patterns and Actions234032
+Node: Pattern Overview234458
+Node: Kinds of Patterns235233
+Node: Regexp Patterns236370
+Node: Expression Patterns236924
+Node: Ranges240575
+Node: BEGIN/END243299
+Node: Using BEGIN/END243768
+Node: I/O And BEGIN/END246731
+Node: Empty248747
+Node: Action Overview249046
+Node: Statements251618
+Node: If Statement253324
+Node: While Statement254827
+Node: Do Statement256857
+Node: For Statement257959
+Node: Break Statement261216
+Node: Continue Statement263487
+Node: Next Statement265483
+Node: Nextfile Statement267980
+Node: Exit Statement269894
+Node: Built-in Variables271904
+Node: User-modified273000
+Node: Auto-set277922
+Node: ARGC and ARGV284452
+Node: Arrays287798
+Node: Array Intro289261
+Node: Reference to Elements293301
+Node: Assigning Elements295251
+Node: Array Example295753
+Node: Scanning an Array297472
+Node: Delete299802
+Node: Numeric Array Subscripts301861
+Node: Uninitialized Subscripts303767
+Node: Multi-dimensional305411
+Node: Multi-scanning308506
+Node: Built-in310149
+Node: Calling Built-in311138
+Node: Numeric Functions313109
+Node: String Functions316928
+Node: I/O Functions335860
+Node: Time Functions341445
+Node: User-defined350298
+Node: Definition Syntax351011
+Node: Function Example355260
+Node: Function Caveats357589
+Node: Return Statement361459
+Node: Invoking Gawk364114
+Node: Options365349
+Node: Other Arguments374179
+Node: AWKPATH Variable376827
+Node: Obsolete379576
+Node: Undocumented380242
+Node: Known Bugs380491
+Node: Library Functions381623
+Node: Portability Notes384041
+Node: Nextfile Function385325
+Node: Assert Function390201
+Node: Round Function393540
+Node: Ordinal Functions395184
+Node: Join Function398636
+Node: Mktime Function400688
+Node: Gettimeofday Function412261
+Node: Filetrans Function416273
+Node: Getopt Function419950
+Node: Passwd Functions431306
+Node: Group Functions439639
+Node: Library Names447536
+Node: Sample Programs451461
+Node: Clones451952
+Node: Cut Program453046
+Node: Egrep Program463075
+Node: Id Program470738
+Node: Split Program474009
+Node: Tee Program477377
+Node: Uniq Program480173
+Node: Wc Program487718
+Node: Miscellaneous Programs492136
+Node: Dupword Program493046
+Node: Alarm Program494717
+Node: Translate Program499261
+Node: Labels Program504073
+Node: Word Sorting507617
+Node: History Sorting511962
+Node: Extract Program513931
+Node: Simple Sed520889
+Node: Igawk Program524233
+Node: Language History537554
+Node: V7/SVR3.1538787
+Node: SVR4541442
+Node: POSIX542964
+Node: BTL544584
+Node: POSIX/GNU545347
+Node: Gawk Summary549779
+Node: Command Line Summary550601
+Node: Language Summary553577
+Node: Variables/Fields555958
+Node: Fields Summary556692
+Node: Built-in Summary558478
+Node: Arrays Summary562193
+Node: Data Type Summary563486
+Node: Rules Summary565312
+Node: Pattern Summary566840
+Node: Regexp Summary569025
+Node: Actions Summary572408
+Node: Operator Summary574240
+Node: Control Flow Summary575467
+Node: I/O Summary576024
+Node: Printf Summary579013
+Node: Special File Summary582351
+Node: Built-in Functions Summary584029
+Node: Time Functions Summary588029
+Node: String Constants Summary588920
+Node: Functions Summary590240
+Node: Historical Features591301
+Node: Installation592799
+Node: Gawk Distribution594014
+Node: Getting594517
+Node: Extracting597463
+Node: Distribution contents598850
+Node: Unix Installation603626
+Node: Quick Installation604135
+Node: Configuration Philosophy605653
+Node: VMS Installation608055
+Node: VMS Compilation608594
+Node: VMS Installation Details610198
+Node: VMS Running611840
+Node: VMS POSIX613430
+Node: PC Installation614710
+Node: Atari Installation618113
+Node: Atari Compiling619297
+Node: Atari Using621206
+Node: Amiga Installation624053
+Node: Bugs625164
+Node: Other Versions628240
+Node: Notes629814
+Node: Compatibility Mode630421
+Node: Additions631264
+Node: Adding Code631962
+Node: New Ports637302
+Node: Future Extensions641470
+Node: Improvements643718
+Node: Glossary645586
+Node: Copying662651
+Node: Index681843

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index cf7c4ed5..8c2aad2f 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -19,12 +19,12 @@
@c The following information should be updated here only!
@c This sets the edition of the document, the version of gawk it
@c applies to, and when the document was updated.
-@set TITLE The GNU Awk User's Guide
-@set SUBTITLE Effective AWK Programming
-@set PATCHLEVEL 2
+@set TITLE Effective AWK Programming
+@set SUBTITLE A User's Guide for GNU Awk
+@set PATCHLEVEL 3
@set EDITION 1.0.@value{PATCHLEVEL}
@set VERSION 3.0
-@set UPDATE-MONTH December 1996
+@set UPDATE-MONTH February 1997
@iftex
@set DOCUMENT book
@end iftex
@@ -74,7 +74,7 @@ particular records in a file and perform operations upon them.
This is Edition @value{EDITION} of @cite{@value{TITLE}},
for the @value{VERSION}.@value{PATCHLEVEL} version of the GNU implementation of AWK.
-Copyright (C) 1989, 1991, 92, 93, 96 Free Software Foundation, Inc.
+Copyright (C) 1989, 1991, 92, 93, 96, 97 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -106,9 +106,11 @@ by the Foundation.
@subtitle Edition @value{EDITION}
@subtitle @value{UPDATE-MONTH}
@author Arnold D. Robbins
-@sp
+@ignore
+@sp 1
@author Based on @cite{The GAWK Manual},
@author by Robbins, Close, Rubin, and Stallman
+@end ignore
@c Include the Distribution inside the titlepage environment so
@c that headings are turned off. Headings on and off do not work.
@@ -136,22 +138,31 @@ Corporation. @*
Registered Trademark of Paramount Pictures Corporation. @*
@c sorry, i couldn't resist
@sp 3
-Copyright @copyright{} 1989, 1991, 92, 93, 96 Free Software Foundation, Inc.
+Copyright @copyright{} 1989, 1991, 92, 93, 96, 97 Free Software Foundation, Inc.
@sp 2
This is Edition @value{EDITION} of @cite{@value{TITLE}}, @*
for the @value{VERSION}.@value{PATCHLEVEL} (or later) version of the GNU implementation of AWK.
@sp 2
-Published by the Free Software Foundation @*
-59 Temple Place --- Suite 330 @*
-Boston, MA 02111-1307 USA @*
-Phone: +1-617-542-5942 @*
-Fax (including Japan): +1-617-542-2652 @*
-Printed copies are available for $25 each. @*
-@c this ISBN can change! Check with the FSF office...
-@c This one is correct for gawk 3.0 and edition 1.0
-ISBN 1-882114-26-4 @*
+@center Published jointly by:
+
+@multitable {Specialized Systems Consultants, Inc. (SSC)} {Boston, MA 02111-1307 USA}
+@item Specialized Systems Consultants, Inc. (SSC) @tab Free Software Foundation
+@item PO Box 55549 @tab 59 Temple Place --- Suite 330
+@item Seattle, WA 98155 USA @tab Boston, MA 02111-1307 USA
+@item Phone: +1-206-782-7733 @tab Phone: +1-617-542-5942
+@item Fax: +1-206-782-7191 @tab Fax: +1-617-542-2652
+@item E-mail: @code{sales@@ssc.com} @tab E-mail: @code{gnu@@prep.ai.mit.edu}
+@item URL: @code{http://www.ssc.com/} @tab URL: @code{http://www.fsf.org/}
+@end multitable
+
+@sp 1
+@c this ISBN can change! Check with SSC
+@c This one is correct for gawk 3.0 and edition 1.0 from the FSF
+@c ISBN 1-882114-26-4 @*
+@c This one is correct for gawk 3.0.3 and edition 1.0.3 from SSC
+ISBN 1-57831-000-8 @*
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -167,7 +178,8 @@ into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by the Foundation.
@sp 2
-Cover art by Etienne Suvasa.
+@c Cover art by Etienne Suvasa.
+Cover art by Amy Wells Wood.
@end titlepage
@c Thanks to Bob Chassell for directions on doing dedications.
@@ -177,11 +189,11 @@ Cover art by Etienne Suvasa.
@w{ }
@sp 9
@center @i{To Miriam, for making me complete.}
-@sp
+@sp 1
@center @i{To Chana, for the joy you bring us.}
-@sp
+@sp 1
@center @i{To Rivka, for the exponential increase.}
-@sp
+@sp 1
@center @i{To Nachum, for the added dimension.}
@page
@w{ }
@@ -191,7 +203,7 @@ Cover art by Etienne Suvasa.
@iftex
@headings off
-@evenheading @thispage@ @ @ @strong{@thistitle} @| @|
+@evenheading @thispage@ @ @ @strong{@value{TITLE}} @| @|
@oddheading @| @| @strong{@thischapter}@ @ @ @thispage
@ifset DRAFT
@evenfooting @today{} @| @emph{DRAFT!} @| Please Do Not Redistribute
@@ -610,28 +622,26 @@ copy of the GPL is included for your reference
(@pxref{Copying, ,GNU GENERAL PUBLIC LICENSE}).
The GPL applies to the C language source code for @code{gawk}.
-As of this writing (1995), the only major component of the
-GNU environment still uncompleted is the operating system kernel, and
-work proceeds apace on that. A shell, an editor (Emacs), highly portable
-optimizing C, C++, and Objective-C compilers, a symbolic debugger, and dozens
-of large and small utilities (such as @code{gawk}),
-have all been completed and are freely available.
+A shell, an editor (Emacs), highly portable optimizing C, C++, and
+Objective-C compilers, a symbolic debugger, and dozens of large and
+small utilities (such as @code{gawk}), have all been completed and are
+freely available. As of this writing (early 1997), the GNU operating
+system kernel (the HURD), has been released, but is still in an early
+stage of development.
@cindex Linux
@cindex NetBSD
@cindex FreeBSD
-Until the GNU operating system is released, the FSF recommends the use
-of Linux, a freely distributable, Unix-like operating system for 80386
-and other systems. There are many books on Linux. One freely available one
-is @cite{Linux Installation and Getting Started}, by Matt Welsh.
+Until the GNU operating system is more fully developed, you should
+consider using Linux, a freely distributable, Unix-like operating
+system for 80386, DEC Alpha, Sun SPARC and other systems. There are
+many books on Linux. One freely available one is @cite{Linux
+Installation and Getting Started}, by Matt Welsh.
Many Linux distributions are available, often in computer stores or
-bundled on CD-ROM with books about Linux. Also, the FSF provides a Linux
-distribution (``Debian''); contact them for more information.
-@xref{Getting, ,Getting the @code{gawk} Distribution}, for the FSF's contact
-information.
-(There are two other freely available, Unix-like operating systems for
-80386 and other systems, NetBSD and FreeBSD. Both are based on the
-4.4-Lite Berkeley Software Distribution, and both use recent versions
+bundled on CD-ROM with books about Linux.
+(There are three other freely available, Unix-like operating systems for
+80386 and other systems, NetBSD, FreeBSD,and OpenBSD. All are based on the
+4.4-Lite Berkeley Software Distribution, and they use recent versions
of @code{gawk} for their versions of @code{awk}.)
@iftex
@@ -646,7 +656,7 @@ If you paid money for this @value{DOCUMENT}, what you actually paid for
was the @value{DOCUMENT}'s nice printing and binding, and the
publisher's associated costs to produce it. We have made an effort to
keep these costs reasonable; most people would prefer a bound book to
-over 300 pages of photo-copied text that would then have to be held in
+over 330 pages of photo-copied text that would then have to be held in
a loose-leaf binder (not to mention the time and labor involved in
doing the copying). The same is true of producing this
@value{DOCUMENT} from the machine readable source; the retail price is
@@ -770,7 +780,7 @@ take advantage of those opportunities.
@noindent
Arnold Robbins @*
Atlanta, Georgia @*
-January, 1996
+February, 1997
@ignore
Stuff still not covered anywhere:
@@ -899,6 +909,11 @@ should be of interest.
@c fakenode --- for prepinfo
@unnumberedsubsec Dark Corners
+@display
+@i{Who opened that window shade?!?}
+Count Dracula
+@end display
+@sp 1
@cindex d.c., see ``dark corner''
@cindex dark corner
@@ -931,10 +946,12 @@ Error messages, and other output on the command's standard error, are preceded
by the glyph ``@error{}''. For example:
@example
+@group
$ echo hi on stdout
@print{} hi on stdout
$ echo hello on stderr 1>&2
@error{} hello on stderr
+@end group
@end example
@iftex
@@ -3968,7 +3985,7 @@ string @code{"\n\n+"} to @code{RS}. This regexp matches the newline
at the end of the record, and one or more blank lines after the record.
In addition, a regular expression always matches the longest possible
sequence when there is a choice
-(@pxref{Leftmost Longest, ,How Much Text Matches?})
+(@pxref{Leftmost Longest, ,How Much Text Matches?}).
So the next record doesn't start until
the first non-blank line that follows---no matter how many blank lines
appear in a row, they are considered one record-separator.
@@ -5313,7 +5330,15 @@ it has been closed since it was last written to.
@cindex differences between @code{gawk} and @code{awk}
@cindex limitations
@cindex implementation limits
-Many @code{awk} implementations limit the number of pipelines an @code{awk}
+@iftex
+As mentioned earlier
+(@pxref{Getline Summary, , Summary of @code{getline} Variants}),
+many
+@end iftex
+@ifinfo
+Many
+@end ifinfo
+@code{awk} implementations limit the number of pipelines an @code{awk}
program may have open to just one! In @code{gawk}, there is no such limit.
You can open as many pipelines as the underlying operating system will
permit.
@@ -6108,6 +6133,12 @@ addition and subtraction have the same precedence.
@node Concatenation, Assignment Ops, Arithmetic Ops, Expressions
@section String Concatenation
+@cindex Kernighan, Brian
+@display
+@i{It seemed like a good idea at the time.}
+Brian Kernighan
+@end display
+@sp 1
@cindex string operators
@cindex operators, string
@@ -6145,9 +6176,11 @@ following code fragment does not concatenate @code{file} and @code{name}
as you might expect:
@example
+@group
file = "file"
name = "name"
print "something meaningful" > file name
+@end group
@end example
@noindent
@@ -6220,10 +6253,12 @@ to hold at the moment. In the following program fragment, the variable
@code{foo} has a numeric value at first, and a string value later on:
@example
+@group
foo = 1
print foo
foo = "bar"
print foo
+@end group
@end example
@noindent
@@ -6466,8 +6501,12 @@ The string constant @code{"0"} is actually true, since it is non-null (d.c.).
@cindex regexp match/non-match operators
@cindex variable typing
@cindex types of variables
-
@c 2e: consider splitting this section into subsections
+@display
+@i{The Guide is definitive. Reality is frequently inaccurate.}
+The Hitchhiker's Guide to the Galaxy
+@end display
+@sp 1
Unlike other programming languages, @code{awk} variables do not have a
fixed type. Instead, they can be either a number or a string, depending
@@ -7051,8 +7090,6 @@ while @samp{$} has higher precedence.
Here is a table of @code{awk}'s operators, in order from highest
precedence to lowest:
-@c NEEDED
-@page
@c use @code in the items, looks better in TeX w/o all the quotes
@table @code
@item (@dots{})
@@ -7346,7 +7383,7 @@ combine a range pattern that describes the delimited text with the
(not discussed yet, @pxref{Next Statement, , The @code{next} Statement}),
which causes @code{awk} to skip any further processing of the current
record and start over again with the next input record. Such a program
-would like this:
+would look like this:
@example
/^%$/,/^%$/ @{ next @}
@@ -8331,6 +8368,7 @@ matching with @samp{~} and @samp{!~}, and the @code{gensub},
@code{gsub}, @code{index}, @code{match}, @code{split} and @code{sub}
functions, record termination with @code{RS}, and field splitting with
@code{FS} all ignore case when doing their particular regexp operations.
+The value of @code{IGNORECASE} does @emph{not} affect array subscripting.
@xref{Case-sensitivity, ,Case-sensitivity in Matching}.
If @code{gawk} is in compatibility mode
@@ -8643,6 +8681,31 @@ BEGIN @{
@end group
@end example
+To actually get the options into the @code{awk} program, you have to
+end the @code{awk} options with @samp{--}, and then supply your options,
+like so:
+
+@example
+awk -f myprog -- -v -d file1 file2 @dots{}
+@end example
+
+@cindex differences between @code{gawk} and @code{awk}
+This is not necessary in @code{gawk}: Unless @samp{--posix} has been
+specified, @code{gawk} silently puts any unrecognized options into
+@code{ARGV} for the @code{awk} program to deal with.
+
+As soon as it
+sees an unknown option, @code{gawk} stops looking for other options it might
+otherwise recognize. The above example with @code{gawk} would be:
+
+@example
+gawk -f myprog -d -v file1 file2 @dots{}
+@end example
+
+@noindent
+Since @samp{-d} is not a valid @code{gawk} option, the following @samp{-v}
+is passed on to the @code{awk} program.
+
@node Arrays, Built-in, Built-in Variables, Top
@chapter Arrays in @code{awk}
@@ -8795,6 +8858,13 @@ numbers and strings as indices.
in more detail in
@ref{Numeric Array Subscripts, ,Using Numbers to Subscript Arrays}.)
+@cindex Array subscripts and @code{IGNORECASE}
+@cindex @code{IGNORECASE} and array subscripts
+@vindex IGNORECASE
+The value of @code{IGNORECASE} has no effect upon array subscripting.
+You must use the exact same string value to retrieve an array element
+as you used to store it.
+
When @code{awk} creates an array for you, e.g., with the @code{split}
built-in function,
that array's indices are consecutive integers starting at one.
@@ -9202,7 +9272,7 @@ END @{
@}
@end example
-Here, the @samp{++} forces @code{l} to be numeric, thus making
+Here, the @samp{++} forces @code{lines} to be numeric, thus making
the ``old value'' numeric zero, which is then converted to @code{"0"}
as the array subscript.
@@ -10095,8 +10165,8 @@ backslash.@footnote{This consequence was certainly unintended.}
@c I can say that, 'cause I was involved in making this change
@end enumerate
-The POSIX standard is under revision.@footnote{As of December 1995,
-with final approval and publication hopefully sometime in 1996.}
+The POSIX standard is under revision.@footnote{As of @value{UPDATE-MONTH},
+with final approval and publication hopefully sometime in 1997.}
Because of the above problems, proposed text for the revised standard
reverts to rules that correspond more closely to the original existing
practice. The proposed rules have special cases that make it possible
@@ -11589,6 +11659,11 @@ specifies a @samp{%V} conversion specifier.
@node Undocumented, Known Bugs, Obsolete, Invoking Gawk
@section Undocumented Options and Features
@cindex undocumented features
+@display
+@i{Use the Source, Luke!}
+Obi-Wan
+@end display
+@sp 1
This section intentionally left blank.
@@ -16472,7 +16547,10 @@ is done. Otherwise, the file name is concatenated with the name of each
directory in the path, and an attempt is made to open the generated file
name. The only way in @code{awk} to test if a file can be read is to go
ahead and try to read it with @code{getline}; that is what @code{pathto}
-does. If the file can be read, it is closed, and the file name is
+does.@footnote{On some very old versions of @code{awk}, the test
+@samp{getline junk < t} can loop forever if the file exists but is empty.
+Caveat Emptor.}
+If the file can be read, it is closed, and the file name is
returned.
@ignore
An alternative way to test for the file's existence would be to call
@@ -17364,6 +17442,7 @@ with @code{FS}, regular expression matching with @samp{~} and
@code{match}, @code{split} and @code{sub} built-in functions all
ignore case when doing regular expression operations, and all string
comparisons are done ignoring case.
+The value of @code{IGNORECASE} does @emph{not} affect array subscripting.
@item NF
The number of fields in the current input record.
@@ -18538,7 +18617,8 @@ The distribution file name is of the form
The @var{V} represents the major version of @code{gawk},
the @var{R} represents the current release of version @var{V}, and
the @var{n} represents a @dfn{patch level}, meaning that minor bugs have
-been fixed in the release. The current patch level is 0, but when
+been fixed in the release. The current patch level is @value{PATCHLEVEL},
+but when
retrieving distributions, you should get the version with the highest
version, release, and patch level. (Note that release levels greater than
or equal to 90 denote ``beta,'' or non-production software; you may not wish
@@ -18671,10 +18751,6 @@ and the @code{igawk} program from
are extracted into ready to use files.
They are installed as part of the installation process.
-@item amiga/*
-Files needed for building @code{gawk} on an Amiga.
-@xref{Amiga Installation, ,Installing @code{gawk} on an Amiga}, for details.
-
@item atari/*
Files needed for building @code{gawk} on an Atari ST.
@xref{Atari Installation, ,Installing @code{gawk} on the Atari ST}, for details.
@@ -19181,13 +19257,13 @@ strings have to be doubled in order to get literal backslashes
@cindex installation, amiga
You can install @code{gawk} on an Amiga system using a Unix emulation
environment available via anonymous @code{ftp} from
-@code{wuarchive.wustl.edu} in the directory @file{pub/aminet/dev/gcc}.
+@code{ftp.ninemoons.com} in the directory @file{pub/ade/current}.
This includes a shell based on @code{pdksh}. The primary component of
this environment is a Unix emulation library, @file{ixemul.lib}.
@c could really use more background here, who wrote this, etc.
A more complete distribution for the Amiga is available on
-the FreshFish CD-ROM from:
+the Geek Gadgets CD-ROM from:
@quotation
CRONUS @*
@@ -19205,7 +19281,7 @@ Once you have the distribution, you can configure @code{gawk} simply by
running @code{configure}:
@example
-configure -v m68k-cbm-amigados
+configure -v m68k-amigaos
@end example
Then run @code{make}, and you should be all set!
@@ -19214,6 +19290,12 @@ Then run @code{make}, and you should be all set!
@node Bugs, Other Versions, Amiga Installation, Installation
@appendixsec Reporting Problems and Bugs
+@display
+@i{There is nothing more dangerous than a bored archeologist.}
+The Hitchhiker's Guide to the Galaxy
+@c the radio show, not the book. :-)
+@end display
+@sp 1
If you have problems with @code{gawk} or think that you have found a bug,
please report it to the developers; we cannot promise to do anything
@@ -19267,6 +19349,8 @@ are listed below, and also in the @file{README} file in the @code{gawk}
distribution. Information in the @file{README} file should be considered
authoritative if it conflicts with this @value{DOCUMENT}.
+@c NEEDED for looks
+@page
The people maintaining the non-Unix ports of @code{gawk} are:
@cindex Deifik, Scott
@@ -19299,9 +19383,7 @@ addresses listed above.
@node Other Versions, , Bugs, Installation
@appendixsec Other Freely Available @code{awk} Implementations
-
@cindex Brennan, Michael
-@display
@ignore
From: emory!amc.com!brennan (Michael Brennan)
Subject: C++ comments in awk programs
@@ -19309,10 +19391,12 @@ To: arnold@gnu.ai.mit.edu (Arnold Robbins)
Date: Wed, 4 Sep 1996 08:11:48 -0700 (PDT)
@end ignore
+@display
@i{It's kind of fun to put comments like this in your awk code.}
@code{// Do C++ comments work? answer: yes! of course}
Michael Brennan
@end display
+@sp 1
There are two other freely available @code{awk} implementations.
This section briefly describes where to get them.
@@ -19647,7 +19731,6 @@ coding style and brace layout that suits your taste.
@node Future Extensions, Improvements, Additions, Notes
@appendixsec Probable Future Extensions
-
@ignore
From emory!scalpel.netlabs.com!lwall Tue Oct 31 12:43:17 1995
Return-Path: <emory!scalpel.netlabs.com!lwall>
@@ -19682,7 +19765,6 @@ I think that would be fine.
Larry
@end ignore
-
@cindex PERL
@cindex Wall, Larry
@display
@@ -19692,6 +19774,7 @@ Arnold Robbins
@i{Hey!}
Larry Wall
@end display
+@sp 1
This section briefly lists extensions and possible improvements
that indicate the directions we are
diff --git a/eval.c b/eval.c
index b3b7139d..aa2e8816 100644
--- a/eval.c
+++ b/eval.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-1996 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -25,6 +25,8 @@
#include "awk.h"
+#include <assert.h>
+
extern double pow P((double x, double y));
extern double modf P((double x, double *yp));
extern double fmod P((double x, double y));
@@ -33,7 +35,12 @@ static int eval_condition P((NODE *tree));
static NODE *op_assign P((NODE *tree));
static NODE *func_call P((NODE *name, NODE *arg_list));
static NODE *match_op P((NODE *tree));
-static char *nodetype2str P((NODETYPE type));
+static void push_args P((int count, NODE *arglist, NODE **oldstack, char *func_name));
+static void pop_fcall_stack P((void));
+static void pop_fcall P((void));
+static int in_function P((void));
+char *nodetype2str P((NODETYPE type));
+char *flags2str P((int flagval));
#if __GNUC__ < 2
NODE *_t; /* used as a temporary in macros */
@@ -235,7 +242,7 @@ static char *nodetypes[] = {
NULL
};
-static char *
+char *
nodetype2str(type)
NODETYPE type;
{
@@ -248,6 +255,91 @@ NODETYPE type;
return buf;
}
+/* flags2str --- make a flags value readable */
+
+char *
+flags2str(flagval)
+int flagval;
+{
+ static char buffer[BUFSIZ];
+ char *sp;
+
+ sp = buffer;
+
+ if (flagval & MALLOC) {
+ strcpy(sp, "MALLOC");
+ sp += strlen(sp);
+ }
+ if (flagval & TEMP) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "TEMP");
+ sp += strlen(sp);
+ }
+ if (flagval & PERM) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "PERM");
+ sp += strlen(sp);
+ }
+ if (flagval & STRING) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "STRING");
+ sp += strlen(sp);
+ }
+ if (flagval & STR) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "STR");
+ sp += strlen(sp);
+ }
+ if (flagval & NUM) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "NUM");
+ sp += strlen(sp);
+ }
+ if (flagval & NUMBER) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "NUMBER");
+ sp += strlen(sp);
+ }
+ if (flagval & MAYBE_NUM) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "MAYBE_NUM");
+ sp += strlen(sp);
+ }
+ if (flagval & ARRAYMAXED) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "ARRAYMAXED");
+ sp += strlen(sp);
+ }
+ if (flagval & SCALAR) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "SCALAR");
+ sp += strlen(sp);
+ }
+ if (flagval & FUNC) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "FUNC");
+ sp += strlen(sp);
+ }
+ if (flagval & FIELD) {
+ if (sp != buffer)
+ *sp++ = '|';
+ strcpy(sp, "FIELD");
+ sp += strlen(sp);
+ }
+
+ return buffer;
+}
+
/*
* interpret:
* Tree is a bunch of rules to run. Returns zero if it hit an exit()
@@ -432,6 +524,8 @@ register NODE *volatile tree;
}
if (! do_traditional || do_posix)
fatal("use of `break' outside a loop is not allowed");
+ if (in_function())
+ pop_fcall_stack();
longjmp(rule_tag, TAG_CONTINUE);
} else
longjmp(loop_tag, TAG_BREAK);
@@ -452,6 +546,8 @@ register NODE *volatile tree;
}
if (! do_traditional || do_posix)
fatal("use of `continue' outside a loop is not allowed");
+ if (in_function())
+ pop_fcall_stack();
longjmp(rule_tag, TAG_CONTINUE);
} else
longjmp(loop_tag, TAG_CONTINUE);
@@ -466,17 +562,18 @@ register NODE *volatile tree;
break;
case Node_K_delete:
- if (tree->rnode != NULL) /* delete array */
- do_delete(tree->lnode, tree->rnode);
- else
- assoc_clear(tree->lnode);
+ do_delete(tree->lnode, tree->rnode);
break;
case Node_K_next:
+ if (in_function())
+ pop_fcall_stack();
longjmp(rule_tag, TAG_CONTINUE);
break;
case Node_K_nextfile:
+ if (in_function())
+ pop_fcall_stack();
do_nextfile();
break;
@@ -1034,7 +1131,7 @@ register NODE *tree;
case Node_assign_mod:
if (rval == (AWKNUM) 0)
- fatal("division by zero attempted in %=");
+ fatal("division by zero attempted in %%=");
#ifdef HAVE_FMOD
*lhs = make_number(fmod(lval, rval));
#else /* ! HAVE_FMOD */
@@ -1060,46 +1157,134 @@ register NODE *tree;
return *lhs;
}
-/* func_call --- call a function, call by reference for arrays */
+static struct fcall {
+ char *fname;
+ unsigned long count;
+ NODE *arglist;
+ NODE **prevstack;
+ NODE **stack;
+} *fcall_list = NULL;
-NODE **stack_ptr;
+static long fcall_list_size = 0;
+static long curfcall = -1;
-static NODE *
-func_call(name, arg_list)
-NODE *name; /* name is a Node_val giving function name */
-NODE *arg_list; /* Node_expression_list of calling args. */
+/* in_function --- return true/false if we need to unwind awk functions */
+
+static int
+in_function()
{
- register NODE *arg, *argp, *r;
- NODE *n, *f;
- jmp_buf volatile func_tag_stack;
- jmp_buf volatile loop_tag_stack;
- int volatile save_loop_tag_valid = FALSE;
- NODE **volatile save_stack, *save_ret_node;
- NODE **volatile local_stack = NULL, **sp;
+ return (curfcall >= 0);
+}
+
+/* pop_fcall --- pop off a single function call */
+
+static void
+pop_fcall()
+{
+ NODE *n, **sp, *arg, *argp;
int count;
- extern NODE *ret_node;
+ struct fcall *f;
+
+ assert(curfcall >= 0);
+ f = & fcall_list[curfcall];
+ stack_ptr = f->prevstack;
+
+ /*
+ * here, we pop each parameter and check whether
+ * it was an array. If so, and if the arg. passed in was
+ * a simple variable, then the value should be copied back.
+ * This achieves "call-by-reference" for arrays.
+ */
+ sp = f->stack;
+ count = f->count;
+
+ for (argp = f->arglist; count > 0 && argp != NULL; argp = argp->rnode) {
+ arg = argp->lnode;
+ if (arg->type == Node_param_list)
+ arg = stack_ptr[arg->param_cnt];
+ n = *sp++;
+ if ((arg->type == Node_var || arg->type == Node_var_array)
+ && n->type == Node_var_array) {
+ /* should we free arg->var_value ? */
+ arg->var_array = n->var_array;
+ arg->type = Node_var_array;
+ arg->array_size = n->array_size;
+ arg->table_size = n->table_size;
+ arg->flags = n->flags;
+ }
+ /* n->lnode overlays the array size, don't unref it if array */
+ if (n->type != Node_var_array)
+ unref(n->lnode);
+ freenode(n);
+ count--;
+ }
+ while (count-- > 0) {
+ n = *sp++;
+ /* if n is a local array, all the elements should be freed */
+ if (n->type == Node_var_array)
+ assoc_clear(n);
+ unref(n->lnode);
+ freenode(n);
+ }
+ if (f->stack)
+ free((char *) f->stack);
+ memset(f, '\0', sizeof(struct fcall));
+ curfcall--;
+}
+
+/* pop_fcall_stack --- pop off all function args, don't leak memory */
+
+static void
+pop_fcall_stack()
+{
+ while (curfcall >= 0)
+ pop_fcall();
+}
+
+/* push_args --- push function arguments onto the stack */
+
+static void
+push_args(count, arglist, oldstack, func_name)
+int count;
+NODE *arglist;
+NODE **oldstack;
+char *func_name;
+{
+ struct fcall *f;
+ NODE *arg, *argp, *r, **sp, *n;
+
+ if (fcall_list_size == 0) { /* first time */
+ emalloc(fcall_list, struct fcall *, 10 * sizeof(struct fcall),
+ "push_args");
+ fcall_list_size = 10;
+ }
+
+ if (++curfcall >= fcall_list_size) {
+ fcall_list_size *= 2;
+ erealloc(fcall_list, struct fcall *,
+ fcall_list_size * sizeof(struct fcall), "push_args");
+ }
+ f = & fcall_list[curfcall];
+ memset(f, '\0', sizeof(struct fcall));
- /* retrieve function definition node */
- f = lookup(name->stptr);
- if (f == NULL || f->type != Node_func)
- fatal("function `%s' not defined", name->stptr);
-#ifdef FUNC_TRACE
- fprintf(stderr, "function %s called\n", name->stptr);
-#endif
- count = f->lnode->param_cnt;
if (count > 0)
- emalloc(local_stack, NODE **, count*sizeof(NODE *), "func_call");
- sp = local_stack;
+ emalloc(f->stack, NODE **, count*sizeof(NODE *), "func_call");
+ f->count = count;
+ f->fname = func_name; /* not used, for debugging, just in case */
+ f->arglist = arglist;
+ f->prevstack = oldstack;
+
+ sp = f->stack;
/* for each calling arg. add NODE * on stack */
- for (argp = arg_list; count > 0 && argp != NULL; argp = argp->rnode) {
+ for (argp = arglist; count > 0 && argp != NULL; argp = argp->rnode) {
arg = argp->lnode;
getnode(r);
r->type = Node_var;
/* call by reference for arrays; see below also */
if (arg->type == Node_param_list)
- arg = stack_ptr[arg->param_cnt];
+ arg = f->prevstack[arg->param_cnt];
if (arg->type == Node_var_array)
*r = *arg;
else {
@@ -1116,7 +1301,7 @@ NODE *arg_list; /* Node_expression_list of calling args. */
if (argp != NULL) /* left over calling args. */
warning(
"function `%s' called with more arguments than declared",
- name->stptr);
+ func_name);
/* add remaining params. on stack with null value */
while (count-- > 0) {
@@ -1129,6 +1314,44 @@ NODE *arg_list; /* Node_expression_list of calling args. */
}
/*
+ * We have to reassign f. Why, you may ask? It is possible that
+ * other functions were called during the course of tree_eval()-ing
+ * the arguments to this function. As a result of that, fcall_list
+ * may have been realloc()'ed, with the result that f is now
+ * pointing into free()'d space. This was a nasty one to track down.
+ */
+ f = & fcall_list[curfcall];
+
+ stack_ptr = f->stack;
+}
+
+/* func_call --- call a function, call by reference for arrays */
+
+NODE **stack_ptr;
+
+static NODE *
+func_call(name, arg_list)
+NODE *name; /* name is a Node_val giving function name */
+NODE *arg_list; /* Node_expression_list of calling args. */
+{
+ register NODE *r;
+ NODE *f;
+ jmp_buf volatile func_tag_stack;
+ jmp_buf volatile loop_tag_stack;
+ int volatile save_loop_tag_valid = FALSE;
+ NODE *save_ret_node;
+ extern NODE *ret_node;
+
+ /* retrieve function definition node */
+ f = lookup(name->stptr);
+ if (f == NULL || f->type != Node_func)
+ fatal("function `%s' not defined", name->stptr);
+#ifdef FUNC_TRACE
+ fprintf(stderr, "function %s called\n", name->stptr);
+#endif
+ push_args(f->lnode->param_cnt, arg_list, stack_ptr, name->stptr);
+
+ /*
* Execute function body, saving context, as a return statement
* will longjmp back here.
*
@@ -1146,8 +1369,6 @@ NODE *arg_list; /* Node_expression_list of calling args. */
PUSH_BINDING(loop_tag_stack, loop_tag, junk);
loop_tag_valid = FALSE;
}
- save_stack = stack_ptr;
- stack_ptr = local_stack;
PUSH_BINDING(func_tag_stack, func_tag, func_tag_valid);
save_ret_node = ret_node;
ret_node = Nnull_string; /* default return value */
@@ -1157,46 +1378,7 @@ NODE *arg_list; /* Node_expression_list of calling args. */
r = ret_node;
ret_node = (NODE *) save_ret_node;
RESTORE_BINDING(func_tag_stack, func_tag, func_tag_valid);
- stack_ptr = (NODE **) save_stack;
-
- /*
- * here, we pop each parameter and check whether
- * it was an array. If so, and if the arg. passed in was
- * a simple variable, then the value should be copied back.
- * This achieves "call-by-reference" for arrays.
- */
- sp = local_stack;
- count = f->lnode->param_cnt;
- for (argp = arg_list; count > 0 && argp != NULL; argp = argp->rnode) {
- arg = argp->lnode;
- if (arg->type == Node_param_list)
- arg = stack_ptr[arg->param_cnt];
- n = *sp++;
- if ((arg->type == Node_var || arg->type == Node_var_array)
- && n->type == Node_var_array) {
- /* should we free arg->var_value ? */
- arg->var_array = n->var_array;
- arg->type = Node_var_array;
- arg->array_size = n->array_size;
- arg->table_size = n->table_size;
- arg->flags = n->flags;
- }
- /* n->lnode overlays the array size, don't unref it if array */
- if (n->type != Node_var_array)
- unref(n->lnode);
- freenode(n);
- count--;
- }
- while (count-- > 0) {
- n = *sp++;
- /* if n is a local array, all the elements should be freed */
- if (n->type == Node_var_array)
- assoc_clear(n);
- unref(n->lnode);
- freenode(n);
- }
- if (local_stack)
- free((char *) local_stack);
+ pop_fcall();
/* Restore the loop_tag stuff if necessary. */
if (save_loop_tag_valid) {
diff --git a/field.c b/field.c
index c5b4e10f..31c96287 100644
--- a/field.c
+++ b/field.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-1996 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -61,6 +61,7 @@ NODE **fields_arr; /* array of pointers to the field nodes */
int field0_valid; /* $(>0) has not been changed yet */
int default_FS; /* TRUE when FS == " " */
Regexp *FS_regexp = NULL;
+static NODE *Null_field = NULL;
/* init_fields --- set up the fields array to start with */
@@ -72,10 +73,15 @@ init_fields()
emalloc(fields_arr, NODE **, sizeof(NODE *), "init_fields");
getnode(n);
*n = *Nnull_string;
- n->flags |= (SCALAR|PERM);
+ n->flags |= (SCALAR|FIELD);
+ n->flags &= ~PERM;
fields_arr[0] = n;
parse_extent = fields_arr[0]->stptr;
save_FS = dupnode(FS_node->var_value);
+ getnode(Null_field);
+ *Null_field = *Nnull_string;
+ Null_field->flags |= (SCALAR|FIELD);
+ Null_field->flags &= ~(NUM|NUMBER|MAYBE_NUM|PERM);
field0_valid = TRUE;
}
@@ -91,8 +97,7 @@ long num;
erealloc(fields_arr, NODE **, (num + 1) * sizeof(NODE *), "grow_fields_arr");
for (t = nf_high_water + 1; t <= num; t++) {
getnode(n);
- *n = *Nnull_string;
- n->flags |= SCALAR;
+ *n = *Null_field;
fields_arr[t] = n;
}
nf_high_water = num;
@@ -115,7 +120,7 @@ NODE *dummy; /* not used -- just to make interface same as set_element */
n = fields_arr[num];
n->stptr = str;
n->stlen = len;
- n->flags = (PERM|STR|STRING|MAYBE_NUM|SCALAR);
+ n->flags = (STR|STRING|MAYBE_NUM|SCALAR|FIELD);
}
/* rebuild_record --- Someone assigned a value to $(something).
@@ -191,11 +196,9 @@ rebuild_record()
cops += fields_arr[i]->stlen + ofslen;
}
- fields_arr[0]->flags &= ~PERM;
unref(fields_arr[0]);
fields_arr[0] = tmp;
- fields_arr[0]->flags |= PERM;
field0_valid = TRUE;
}
@@ -217,8 +220,7 @@ int freeold;
for (i = 1; i <= parse_high_water; i++) {
unref(fields_arr[i]);
getnode(n);
- *n = *Nnull_string;
- n->flags |= SCALAR;
+ *n = *Null_field;
fields_arr[i] = n;
}
@@ -240,10 +242,10 @@ int freeold;
n->stref = 1;
n->type = Node_val;
n->stfmt = -1;
- n->flags = (STRING|STR|PERM|MAYBE_NUM|SCALAR);
+ n->flags = (STRING|STR|MAYBE_NUM|SCALAR|FIELD);
fields_arr[0] = n;
}
- fields_arr[0]->flags |= (MAYBE_NUM|PERM);
+ fields_arr[0]->flags |= MAYBE_NUM;
field0_valid = TRUE;
}
@@ -273,16 +275,14 @@ set_NF()
for (i = parse_high_water + 1; i <= NF; i++) {
unref(fields_arr[i]);
getnode(n);
- *n = *Nnull_string;
- n->flags |= SCALAR;
+ *n = *Null_field;
fields_arr[i] = n;
}
} else if (parse_high_water > 0) {
for (i = NF + 1; i <= parse_high_water; i++) {
unref(fields_arr[i]);
getnode(n);
- *n = *Nnull_string;
- n->flags |= SCALAR;
+ *n = *Null_field;
fields_arr[i] = n;
}
parse_high_water = NF;
@@ -691,7 +691,7 @@ Func_ptr *assign; /* this field is on the LHS of an assign */
NF = requested;
parse_high_water = requested;
} else
- return &Nnull_string;
+ return &Null_field;
}
return &fields_arr[requested];
diff --git a/gawkmisc.c b/gawkmisc.c
index f7c0f3ce..07079714 100644
--- a/gawkmisc.c
+++ b/gawkmisc.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991 - 96 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991 - 97 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -27,7 +27,7 @@
/* some old compilers don't grok #elif. sigh */
-#if defined(MSDOS) || defined(OS2)
+#if defined(MSDOS) || defined(OS2) || defined(WIN32)
#include "gawkmisc.pc"
#else
#if defined(VMS)
@@ -36,14 +36,10 @@
#if defined(atarist)
#include "atari/gawkmisc.atr"
#else
-#if defined(__amigados__)
-#include "amiga/gawkmisc.ami"
-#else
#include "posix/gawkmisc.c"
#endif
#endif
#endif
-#endif
/* xmalloc --- provide this so that other GNU library routines work */
@@ -65,4 +61,3 @@ size_t bytes;
return p;
}
-
diff --git a/getopt.c b/getopt.c
index cdd5a965..eac576b8 100644
--- a/getopt.c
+++ b/getopt.c
@@ -3,23 +3,26 @@
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
before changing it!
- Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96
+ Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97
Free Software Foundation, Inc.
- 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, or (at your option) any
- later version.
+ This file is part of the GNU C Library. Its master source is NOT part of
+ the C library, however. The master source lives in /gd/gnu/lib.
- This program is distributed in the hope that it will be useful,
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library 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.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library 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
-*/
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
Ditto for AIX 3.2 and <stdlib.h>. */
@@ -49,10 +52,16 @@
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
-/* Unfortunately, for gawk, this version is New And Improved, and must
- be used. This will be fixed for GNU LIBC 2
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-*/
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
+#include <gnu-versions.h>
+#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+#define ELIDE_CODE
+#endif
+#endif
+
+#ifndef ELIDE_CODE
+
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
@@ -60,14 +69,31 @@
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
#include <stdlib.h>
+#include <unistd.h>
#endif /* GNU C library. */
+#ifdef VMS
+#include <unixlib.h>
+#if HAVE_STRING_H - 0
+#include <string.h>
+#endif
+#endif
+
+#if defined (WIN32) && !defined (__CYGWIN32__)
+/* It's not Unix, really. See? Capital letters. */
+#include <windows.h>
+#define getpid() GetCurrentProcessId()
+#endif
+
+#ifndef _
/* This is for other GNU distributions with internationalized messages.
- The GNU C Library itself does not yet support such messages. */
-#if HAVE_LIBINTL_H
+ When compiling libc, the _ macro is predefined. */
+#ifdef HAVE_LIBINTL_H
# include <libintl.h>
+# define _(msgid) gettext (msgid)
#else
-# define gettext(msgid) (msgid)
+# define _(msgid) (msgid)
+#endif
#endif
/* This version of `getopt' appears to the caller like standard Unix `getopt'
@@ -100,14 +126,20 @@ char *optarg = NULL;
On entry to `getopt', zero means this is the first call; initialize.
- When `getopt' returns EOF, this is the index of the first of the
+ When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
-/* XXX 1003.2 says this must be 1 before any call. */
-int optind = 0;
+/* 1003.2 says this must be 1 before any call. */
+int optind = 1;
+
+/* Formerly, initialization of getopt depended on optind==0, which
+ causes problems with re-calling getopt as programs generally don't
+ know that. */
+
+int __getopt_initialized = 0;
/* The next char to be scanned in the option-element
in which the last option character we returned was found.
@@ -156,7 +188,7 @@ int optopt = '?';
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return EOF with `optind' != ARGC. */
+ `--' can cause `getopt' to return -1 with `optind' != ARGC. */
static enum
{
@@ -217,6 +249,31 @@ extern int strlen (const char *);
static int first_nonopt;
static int last_nonopt;
+#ifdef _LIBC
+/* Bash 2.0 gives us an environment variable containing flags
+ indicating ARGV elements that should not be considered arguments. */
+
+static const char *nonoption_flags;
+static int nonoption_flags_len;
+
+static int original_argc;
+static char *const *original_argv;
+
+/* Make sure the environment variable bash 2.0 puts in the environment
+ is valid for the getopt call we must make sure that the ARGV passed
+ to getopt is that one passed to the process. */
+static void store_args (int argc, char *const *argv) __attribute__ ((unused));
+static void
+store_args (int argc, char *const *argv)
+{
+ /* XXX This is no good solution. We should rather copy the args so
+ that we can compare them later. But we must not use malloc(3). */
+ original_argc = argc;
+ original_argv = argv;
+}
+text_set_element (__libc_subinit, store_args);
+#endif
+
/* Exchange two adjacent subsequences of ARGV.
One subsequence is elements [first_nonopt,last_nonopt)
which contains all the non-options that have been skipped so far.
@@ -226,6 +283,10 @@ static int last_nonopt;
`first_nonopt' and `last_nonopt' are relocated so that they describe
the new indices of the non-options in ARGV after they are moved. */
+#if defined (__STDC__) && __STDC__
+static void exchange (char **);
+#endif
+
static void
exchange (argv)
char **argv;
@@ -284,8 +345,13 @@ exchange (argv)
/* Initialize the internal data when the first call is made. */
+#if defined (__STDC__) && __STDC__
+static const char *_getopt_initialize (int, char *const *, const char *);
+#endif
static const char *
-_getopt_initialize (optstring)
+_getopt_initialize (argc, argv, optstring)
+ int argc;
+ char *const *argv;
const char *optstring;
{
/* Start processing options with ARGV-element 1 (since ARGV-element 0
@@ -315,6 +381,26 @@ _getopt_initialize (optstring)
else
ordering = PERMUTE;
+#ifdef _LIBC
+ if (posixly_correct == NULL
+ && argc == original_argc && argv == original_argv)
+ {
+ /* Bash 2.0 puts a special variable in the environment for each
+ command it runs, specifying which ARGV elements are the results of
+ file name wildcard expansion and therefore should not be
+ considered as options. */
+ char var[100];
+ sprintf (var, "_%d_GNU_nonoption_argv_flags_", getpid ());
+ nonoption_flags = getenv (var);
+ if (nonoption_flags == NULL)
+ nonoption_flags_len = 0;
+ else
+ nonoption_flags_len = strlen (nonoption_flags);
+ }
+ else
+ nonoption_flags_len = 0;
+#endif
+
return optstring;
}
@@ -331,7 +417,7 @@ _getopt_initialize (optstring)
updating `optind' and `nextchar' so that the next call to `getopt' can
resume the scan with the following option character or ARGV-element.
- If there are no more option characters, `getopt' returns `EOF'.
+ If there are no more option characters, `getopt' returns -1.
Then `optind' is the index in ARGV of the first ARGV-element
that is not an option. (The ARGV-elements have been permuted
so that those that are not options now come last.)
@@ -385,16 +471,36 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
optarg = NULL;
- if (optind == 0)
+ if (!__getopt_initialized || optind == 0)
{
- optstring = _getopt_initialize (optstring);
+ optstring = _getopt_initialize (argc, argv, optstring);
optind = 1; /* Don't scan ARGV[0], the program name. */
+ __getopt_initialized = 1;
}
+ /* Test whether ARGV[optind] points to a non-option argument.
+ Either it does not have option syntax, or there is an environment flag
+ from the shell indicating it is not an option. The later information
+ is only used when the used in the GNU libc. */
+#ifdef _LIBC
+#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
+ || (optind < nonoption_flags_len \
+ && nonoption_flags[optind] == '1'))
+#else
+#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
+#endif
+
if (nextchar == NULL || *nextchar == '\0')
{
/* Advance to the next ARGV-element. */
+ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+ moved back by the user (who may also have changed the arguments). */
+ if (last_nonopt > optind)
+ last_nonopt = optind;
+ if (first_nonopt > optind)
+ first_nonopt = optind;
+
if (ordering == PERMUTE)
{
/* If we have just processed some options following some non-options,
@@ -408,8 +514,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
/* Skip any additional non-options
and extend the range of non-options previously skipped. */
- while (optind < argc
- && (argv[optind][0] != '-' || argv[optind][1] == '\0'))
+ while (optind < argc && NONOPTION_P)
optind++;
last_nonopt = optind;
}
@@ -441,16 +546,16 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
that we previously skipped, so the caller will digest them. */
if (first_nonopt != last_nonopt)
optind = first_nonopt;
- return EOF;
+ return -1;
}
/* If we have come to a non-option and did not permute it,
either stop the scan or describe it to the caller and pass it by. */
- if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
+ if (NONOPTION_P)
{
if (ordering == REQUIRE_ORDER)
- return EOF;
+ return -1;
optarg = argv[optind++];
return 1;
}
@@ -486,7 +591,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
const struct option *pfound = NULL;
int exact = 0;
int ambig = 0;
- int indfound = 0;
+ int indfound = -1;
int option_index;
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
@@ -497,7 +602,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, nextchar, nameend - nextchar))
{
- if (nameend - nextchar == strlen (p->name))
+ if ((unsigned int) (nameend - nextchar)
+ == (unsigned int) strlen (p->name))
{
/* Exact match found. */
pfound = p;
@@ -519,10 +625,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (ambig && !exact)
{
if (opterr)
- fprintf (stderr, gettext ("%s: option `%s' is ambiguous\n"),
+ fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
+ optopt = 0;
return '?';
}
@@ -542,15 +649,17 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
- gettext ("%s: option `--%s' doesn't allow an argument\n"),
+ _("%s: option `--%s' doesn't allow an argument\n"),
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
- gettext ("%s: option `%c%s' doesn't allow an argument\n"),
+ _("%s: option `%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);
nextchar += strlen (nextchar);
+
+ optopt = pfound->val;
return '?';
}
}
@@ -562,9 +671,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
if (opterr)
fprintf (stderr,
- gettext ("%s: option `%s' requires an argument\n"),
+ _("%s: option `%s' requires an argument\n"),
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
+ optopt = pfound->val;
return optstring[0] == ':' ? ':' : '?';
}
}
@@ -590,15 +700,16 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
if (argv[optind][1] == '-')
/* --option */
- fprintf (stderr, gettext ("%s: unrecognized option `--%s'\n"),
+ fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
argv[0], nextchar);
else
/* +option or -option */
- fprintf (stderr, gettext ("%s: unrecognized option `%c%s'\n"),
+ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
argv[0], argv[optind][0], nextchar);
}
nextchar = (char *) "";
optind++;
+ optopt = 0;
return '?';
}
}
@@ -619,10 +730,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
if (posixly_correct)
/* 1003.2 specifies the format of this message. */
- fprintf (stderr, gettext ("%s: illegal option -- %c\n"),
+ fprintf (stderr, _("%s: illegal option -- %c\n"),
argv[0], c);
else
- fprintf (stderr, gettext ("%s: invalid option -- %c\n"),
+ fprintf (stderr, _("%s: invalid option -- %c\n"),
argv[0], c);
}
optopt = c;
@@ -652,8 +763,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (opterr)
{
/* 1003.2 specifies the format of this message. */
- fprintf (stderr,
- gettext ("%s: option requires an argument -- %c\n"),
+ fprintf (stderr, _("%s: option requires an argument -- %c\n"),
argv[0], c);
}
optopt = c;
@@ -679,7 +789,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, nextchar, nameend - nextchar))
{
- if (nameend - nextchar == strlen (p->name))
+ if ((unsigned int) (nameend - nextchar) == strlen (p->name))
{
/* Exact match found. */
pfound = p;
@@ -700,7 +810,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (ambig && !exact)
{
if (opterr)
- fprintf (stderr, gettext ("%s: option `-W %s' is ambiguous\n"),
+ fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
@@ -718,9 +828,9 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else
{
if (opterr)
- fprintf (stderr,
- gettext ("%s: option `-W %s' doesn't allow an argument\n"),
- argv[0], pfound->name);
+ fprintf (stderr, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
nextchar += strlen (nextchar);
return '?';
@@ -734,7 +844,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
if (opterr)
fprintf (stderr,
- gettext ("%s: option `%s' requires an argument\n"),
+ _("%s: option `%s' requires an argument\n"),
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
return optstring[0] == ':' ? ':' : '?';
@@ -783,7 +893,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
/* 1003.2 specifies the format of this message. */
fprintf (stderr,
- gettext ("%s: option requires an argument -- %c\n"),
+ _("%s: option requires an argument -- %c\n"),
argv[0], c);
}
optopt = c;
@@ -815,8 +925,7 @@ getopt (argc, argv, optstring)
0);
}
-/* no close on purpose (gawk)
-#endif /* _LIBC or not __GNU_LIBRARY__. */
+#endif /* Not ELIDE_CODE. */
#ifdef TEST
@@ -836,7 +945,7 @@ main (argc, argv)
int this_option_optind = optind ? optind : 1;
c = getopt (argc, argv, "abc:d:0123456789");
- if (c == EOF)
+ if (c == -1)
break;
switch (c)
diff --git a/getopt.h b/getopt.h
index dcfedc65..7dad11b7 100644
--- a/getopt.h
+++ b/getopt.h
@@ -1,19 +1,23 @@
/* Declarations for getopt.
- Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
+ Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
- 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, or (at your option) any
- later version.
+ This file is part of the GNU C Library. Its master source is NOT part of
+ the C library, however. The master source lives in /gd/gnu/lib.
- This program is distributed in the hope that it will be useful,
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library 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.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library 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 */
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
#ifndef _GETOPT_H
#define _GETOPT_H 1
@@ -36,7 +40,7 @@ extern char *optarg;
On entry to `getopt', zero means this is the first call; initialize.
- When `getopt' returns EOF, this is the index of the first of the
+ When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
diff --git a/getopt1.c b/getopt1.c
index 628bfd63..8347bb13 100644
--- a/getopt1.c
+++ b/getopt1.c
@@ -1,35 +1,31 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
- Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
- Free Software Foundation, Inc.
+ Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc.
- 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, or (at your option) any
- later version.
+ This file is part of the GNU C Library. Its master source is NOT part of
+ the C library, however. The master source lives in /gd/gnu/lib.
- This program is distributed in the hope that it will be useful,
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library 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.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library 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 */
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
-#if defined (emacs) || defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
- using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
- (which it would do because it found this file in $srcdir). */
#include <config.h>
-#else
-#include "config.h"
-#endif
#endif
#include "getopt.h"
-#ifndef __STDC__
+#if !defined (__STDC__) || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
@@ -47,18 +43,21 @@
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
-/* Unfortunately, for gawk, this version is New And Improved, and must
- be used. This will be fixed for GNU LIBC 2
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-*/
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
+#include <gnu-versions.h>
+#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+#define ELIDE_CODE
+#endif
+#endif
+
+#ifndef ELIDE_CODE
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
-#if defined(__GNU_LIBRARY__) || defined(OS2) || defined(MSDOS) || defined(atarist)
+#ifdef __GNU_LIBRARY__
#include <stdlib.h>
-#else
-char *getenv ();
#endif
#ifndef NULL
@@ -93,8 +92,7 @@ getopt_long_only (argc, argv, options, long_options, opt_index)
}
-/* no close on purpose (gawk)
-#endif /* _LIBC or not __GNU_LIBRARY__. */
+#endif /* Not ELIDE_CODE. */
#ifdef TEST
@@ -125,7 +123,7 @@ main (argc, argv)
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
- if (c == EOF)
+ if (c == -1)
break;
switch (c)
diff --git a/io.c b/io.c
index 225ae86f..74d9a8d7 100644
--- a/io.c
+++ b/io.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-1996 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -24,8 +24,10 @@
*/
#include "awk.h"
+#undef HAVE_MMAP /* for now, probably forever */
#ifdef HAVE_SYS_PARAM_H
+#undef RE_DUP_MAX /* avoid spurious conflict w/regex.h */
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */
@@ -65,7 +67,7 @@
#include <stddef.h>
#endif
-#if defined(MSDOS) || defined(OS2)
+#if defined(MSDOS) || defined(OS2) || defined(WIN32)
#define PIPES_SIMULATED
#endif
@@ -79,7 +81,8 @@ static int close_redir P((struct redirect *rp, int exitwarn));
static int wait_any P((int interesting));
#endif
static IOBUF *gawk_popen P((char *cmd, struct redirect *rp));
-static IOBUF *iop_open P((const char *file, const char *how));
+static IOBUF *iop_open P((const char *file, const char *how, IOBUF *buf));
+static IOBUF *iop_alloc P((int fd, const char *name, IOBUF *buf));
static int gawk_pclose P((struct redirect *rp));
static int do_pathopen P((const char *file));
static int get_a_record P((char **out, IOBUF *iop, int rs, Regexp *RSre, int *errcode));
@@ -122,7 +125,7 @@ extern NODE **fields_arr;
static jmp_buf filebuf; /* for do_nextfile() */
-/* do_nextfile --- implement gawk "next file" extension */
+/* do_nextfile --- implement gawk "nextfile" extension */
void
do_nextfile()
@@ -141,6 +144,8 @@ int skipping;
static int files = 0;
NODE *arg;
static IOBUF *curfile = NULL;
+ static IOBUF mybuf;
+ const char *fname;
if (skipping) {
if (curfile != NULL)
@@ -166,11 +171,11 @@ int skipping;
}
if (! arg_assign(arg->stptr)) {
files++;
- curfile = iop_open(arg->stptr, "r");
+ fname = arg->stptr;
+ curfile = iop_open(fname, "r", &mybuf);
if (curfile == NULL)
- fatal("cannot open file `%s' for reading (%s)",
- arg->stptr, strerror(errno));
- /* NOTREACHED */
+ goto give_up;
+ curfile->flag |= IOP_NOFREE_OBJ;
/* This is a kludge. */
unref(FILENAME_node->var_value);
FILENAME_node->var_value = dupnode(arg);
@@ -184,9 +189,19 @@ int skipping;
/* no args. -- use stdin */
/* FNR is init'ed to 0 */
FILENAME_node->var_value = make_string("-", 1);
- curfile = iop_alloc(fileno(stdin), "stdin");
+ fname = "-";
+ curfile = iop_open(fname, "r", &mybuf);
+ if (curfile == NULL)
+ goto give_up;
+ curfile->flag |= IOP_NOFREE_OBJ;
}
return curfile;
+
+ give_up:
+ fatal("cannot open file `%s' for reading (%s)",
+ fname, strerror(errno));
+ /* NOTREACHED */
+ return 0;
}
/* set_FNR --- update internal FNR from awk variable */
@@ -260,7 +275,8 @@ IOBUF *iop;
/* Don't close standard files or else crufty code elsewhere will lose */
if (iop->fd == fileno(stdin)
|| iop->fd == fileno(stdout)
- || iop->fd == fileno(stderr))
+ || iop->fd == fileno(stderr)
+ || (iop->flag & IOP_MMAPPED) != 0)
ret = 0;
else
ret = close(iop->fd);
@@ -282,7 +298,7 @@ IOBUF *iop;
t = make_string(fields_arr[0]->stptr,
fields_arr[0]->stlen);
unref(fields_arr[0]);
- fields_arr [0] = t;
+ fields_arr[0] = t;
reset_record();
}
if ((iop->flag & IOP_MMAPPED) == 0)
@@ -292,7 +308,8 @@ IOBUF *iop;
(void) munmap(iop->buf, iop->size);
#endif
}
- free((char *) iop);
+ if ((iop->flag & IOP_NOFREE_OBJ) == 0)
+ free((char *) iop);
}
return ret == -1 ? 1 : 0;
}
@@ -441,12 +458,13 @@ int *errflg;
break;
case Node_redirect_input:
direction = "from";
- rp->iop = iop_open(str, "r");
+ rp->iop = iop_open(str, "r", NULL);
break;
default:
cant_happen();
}
if (mode != NULL) {
+ errno = 0;
fd = devopen(str, mode);
if (fd > INVALID_HANDLE) {
if (fd == fileno(stdin))
@@ -469,6 +487,11 @@ int *errflg;
/* too many files open -- close one and try again */
if (errno == EMFILE || errno == ENFILE)
close_one();
+#ifdef HAVE_MMAP
+ /* this works for solaris 2.5, not sunos */
+ else if (errno == 0) /* HACK! */
+ close_one();
+#endif
else {
/*
* Some other reason for failure.
@@ -564,9 +587,14 @@ NODE *tree;
&& STREQN(rp->value, tmp->stptr, tmp->stlen))
break;
}
- free_temp(tmp);
- if (rp == NULL) /* no match */
+ if (rp == NULL) { /* no match */
+ if (do_lint)
+ warning("close: `%.*s' is not an open file or pipe",
+ tmp->stlen, tmp->stptr);
+ free_temp(tmp);
return tmp_number((AWKNUM) 0.0);
+ }
+ free_temp(tmp);
fflush(stdout); /* synchronize regular output */
tmp = tmp_number((AWKNUM) close_redir(rp, FALSE));
rp = NULL;
@@ -650,10 +678,8 @@ flush_io()
status++;
}
if (fflush(stderr)) {
-#ifndef __amigados__ /* HACK (fnf) */
warning("error writing standard error (%s)", strerror(errno));
status++;
-#endif
}
for (rp = red_head; rp != NULL; rp = rp->next)
/* flush both files and pipes, what the heck */
@@ -698,10 +724,8 @@ close_io()
status++;
}
if (fflush(stderr)) {
-#ifndef __amigados__ /* HACK (fnf) */
warning("error writing standard error (%s)", strerror(errno));
status++;
-#endif
}
return status;
}
@@ -819,6 +843,7 @@ int allocate;
iop->end = iop->buf + len;
iop->fd = -1;
iop->flag = IOP_IS_INTERNAL;
+ iop->getrec = get_a_record;
}
/* specfdopen --- open an fd special file */
@@ -834,7 +859,7 @@ const char *name, *mode;
fd = devopen(name, mode);
if (fd == INVALID_HANDLE)
return INVALID_HANDLE;
- tp = iop_alloc(fd, name);
+ tp = iop_alloc(fd, name, NULL);
if (tp == NULL) {
/* don't leak fd's */
close(fd);
@@ -924,13 +949,13 @@ const char *name, *mode;
/* iop_open --- handle special and regular files for input */
static IOBUF *
-iop_open(name, mode)
+iop_open(name, mode, iop)
const char *name, *mode;
+IOBUF *iop;
{
int openfd = INVALID_HANDLE;
int flag = 0;
struct stat buf;
- IOBUF *iop;
static struct internal {
const char *name;
int compare;
@@ -985,8 +1010,7 @@ strictopen:
if (openfd != INVALID_HANDLE && fstat(openfd, &buf) > 0)
if ((buf.st_mode & S_IFMT) == S_IFDIR)
fatal("file `%s' is a directory", name);
- iop = iop_alloc(openfd, name);
- return iop;
+ return iop_alloc(openfd, name, iop);
}
#ifndef PIPES_SIMULATED /* real pipes */
@@ -1019,14 +1043,6 @@ int interesting; /* pid of interest, if any */
if (pid == redp->pid) {
redp->pid = -1;
redp->status = status;
- if (redp->fp != NULL) {
- pclose(redp->fp);
- redp->fp = NULL;
- }
- if (redp->iop != NULL) {
- (void) iop_close(redp->iop);
- redp->iop = NULL;
- }
break;
}
}
@@ -1074,7 +1090,7 @@ struct redirect *rp;
rp->pid = pid;
if (close(p[1]) == -1)
fatal("close of pipe failed (%s)", strerror(errno));
- rp->iop = iop_alloc(p[0], cmd);
+ rp->iop = iop_alloc(p[0], cmd, NULL);
if (rp->iop == NULL)
(void) close(p[0]);
return (rp->iop);
@@ -1117,7 +1133,7 @@ struct redirect *rp;
if ((current = popen(cmd, "r")) == NULL)
return NULL;
- rp->iop = iop_alloc(fileno(current), cmd);
+ rp->iop = iop_alloc(fileno(current), cmd, NULL);
if (rp->iop == NULL) {
(void) fclose(current);
current = NULL;
@@ -1169,7 +1185,7 @@ struct redirect *rp;
return NULL;
pipes[current].name = name;
pipes[current].command = strdup(cmd);
- rp->iop = iop_alloc(current, name);
+ rp->iop = iop_alloc(current, name, NULL);
if (rp->iop == NULL)
(void) close(current);
return (rp->iop);
@@ -1392,17 +1408,18 @@ char *s;
/* iop_alloc --- allocate an IOBUF structure for an open fd */
-IOBUF *
-iop_alloc(fd, name)
+static IOBUF *
+iop_alloc(fd, name, iop)
int fd;
const char *name;
+IOBUF *iop;
{
- IOBUF *iop;
struct stat sbuf;
if (fd == INVALID_HANDLE)
return NULL;
- emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc");
+ if (iop == NULL)
+ emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc");
iop->flag = 0;
if (isatty(fd))
iop->flag |= IOP_IS_TTY;
@@ -1418,6 +1435,8 @@ const char *name;
iop->getrec = get_a_record;
#ifdef HAVE_MMAP
if (S_ISREG(sbuf.st_mode) && sbuf.st_size > 0) {
+ register char *cp;
+
iop->buf = iop->off = mmap((caddr_t) 0, sbuf.st_size,
PROT_READ|PROT_WRITE, MAP_PRIVATE,
fd, 0L);
@@ -1429,13 +1448,28 @@ const char *name;
iop->flag |= IOP_MMAPPED;
iop->size = sbuf.st_size;
+ iop->secsiz = 0;
iop->end = iop->buf + iop->size;
iop->cnt = sbuf.st_size;
iop->getrec = mmap_get_record;
+ (void) close(fd);
+ iop->fd = INVALID_HANDLE;
#if defined(HAVE_MADVISE) && defined(MADV_SEQUENTIAL)
madvise(iop->buf, iop->size, MADV_SEQUENTIAL);
#endif
+ /*
+ * The following is a really gross hack.
+ * We want to ensure that we have a copy of the input
+ * data that won't go away, on the off chance that someone
+ * will truncate the data file we've just mmap'ed.
+ * So, we go through and touch each page, forcing the
+ * system to give us a private copy. A page size of 512
+ * guarantees this will work, even on the least common
+ * denominator system (like, oh say, a VAX).
+ */
+ for (cp = iop->buf; cp < iop->end; cp += 512)
+ *cp = *cp;
}
out:
#endif /* HAVE_MMAP */
@@ -1669,7 +1703,7 @@ int *errcode; /* pointer to error variable */
}
/* search for RS, #2, RS = <single char> */
if (onecase) {
- while (casetable[*bp++] != rs)
+ while (casetable[(int) *bp++] != rs)
continue;
} else {
while (*bp++ != rs)
@@ -1698,7 +1732,7 @@ int *errcode; /* pointer to error variable */
bstart = iop->off = bp;
bp--;
- if (onecase ? casetable[*bp] != rs : *bp != rs) {
+ if (onecase ? casetable[(int) *bp] != rs : *bp != rs) {
bp++;
bstart = bp;
}
@@ -1733,7 +1767,7 @@ char *argv[];
bufsize = atoi(argv[1]);
if (argc > 2)
rs[0] = *argv[2];
- iop = iop_alloc(0, "stdin");
+ iop = iop_alloc(0, "stdin", NULL);
while ((cnt = get_a_record(&out, iop, rs[0], NULL, NULL)) > 0) {
fwrite(out, 1, cnt, stdout);
fwrite(rs, 1, 1, stdout);
@@ -1760,6 +1794,7 @@ int *errcode; /* pointer to error variable */
Regexp *rsre = NULL;
int onecase;
register char *end = iop->end;
+ int cnt;
/* first time through */
if (RS_null_re == NULL) {
@@ -1862,18 +1897,21 @@ int *errcode; /* pointer to error variable */
while (bp < end && *bp++ != rs)
continue;
}
+ cnt = (bp - start) - 1;
if (bp >= iop->end) {
/* at end, may have actually seen rs, or may not */
if (*(bp-1) == rs)
set_RT(bp - 1, 1); /* real RS seen */
- else
+ else {
+ cnt++;
set_RT_to_null();
+ }
} else
set_RT(bp - 1, 1);
iop->off = bp;
*out = start;
- return bp - 1 - start;
+ return cnt;
}
#endif /* HAVE_MMAP */
diff --git a/main.c b/main.c
index 719e006d..92445de4 100644
--- a/main.c
+++ b/main.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-1996 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -340,7 +340,7 @@ out:
* Do this again, after argument processing, since do_posix
* and do_traditional are now paid attention to by resetup().
*/
- if (do_traditional || do_posix) {
+ if (do_traditional || do_posix || do_intervals) {
resetup();
/* now handle RS and FS. have to be careful with FS */
@@ -450,7 +450,7 @@ static void
copyleft()
{
static char blurb_part1[] =
-"Copyright (C) 1989, 1991-1996 Free Software Foundation.\n\
+"Copyright (C) 1989, 1991-1997 Free Software Foundation.\n\
\n\
This program is free software; you can redistribute it and/or modify\n\
it under the terms of the GNU General Public License as published by\n\
@@ -702,6 +702,7 @@ int sig, code;
|| sig == SIGBUS
#endif
) {
+ set_loc(__FILE__, __LINE__);
msg("fatal error: internal error");
/* fatal won't abort() if not compiled for debugging */
abort();
diff --git a/missing/strerror.c b/missing/strerror.c
index e49fdb65..6a725995 100644
--- a/missing/strerror.c
+++ b/missing/strerror.c
@@ -1,27 +1,20 @@
-/*
- * strerror.c --- ANSI C compatible system error routine
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991 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
- */
+/* strerror.c --- ANSI C compatible system error routine
+
+ Copyright (C) 1986, 1988, 1989, 1991 the Free Software Foundation, Inc.
+
+ 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, 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. */
#if 0
#include <stdio.h>
diff --git a/missing/strftime.c b/missing/strftime.c
index 1e16868c..18a6a7bf 100644
--- a/missing/strftime.c
+++ b/missing/strftime.c
@@ -92,23 +92,25 @@
#ifndef __STDC__
#define const /**/
-extern void *malloc();
-extern void *realloc();
extern void tzset();
-extern char *strchr();
-extern char *getenv();
static int weeknumber();
adddecl(static int iso8601wknum();)
#else
-extern void *malloc(unsigned count);
-extern void *realloc(void *ptr, unsigned count);
extern void tzset(void);
-extern char *strchr(const char *str, int ch);
-extern char *getenv(const char *v);
static int weeknumber(const struct tm *timeptr, int firstweekday);
adddecl(static int iso8601wknum(const struct tm *timeptr);)
#endif
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#include <string.h>
+#else
+extern void *malloc();
+extern void *realloc();
+extern char *getenv();
+extern char *strchr();
+#endif
+
#ifdef __GNUC__
#define inline __inline__
#else
@@ -504,7 +506,7 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
#ifdef VMS_EXT
case 'v': /* date as dd-bbb-YYYY */
- sprintf(tbuf, "%02d-%3.3s-%4d",
+ sprintf(tbuf, "%2d-%3.3s-%4d",
range(1, timeptr->tm_mday, 31),
months_a[range(0, timeptr->tm_mon, 11)],
timeptr->tm_year + 1900);
diff --git a/missing/strtod.c b/missing/strtod.c
index 746a5da9..7e6cc0c4 100644
--- a/missing/strtod.c
+++ b/missing/strtod.c
@@ -28,7 +28,7 @@
extern double atof();
double
-strtod (s, ptr)
+strtod(s, ptr)
register char *s;
register char **ptr;
{
@@ -105,7 +105,8 @@ out:
}
#ifdef TEST
-main (argc, argv)
+int
+main(argc, argv)
int argc;
char **argv;
{
@@ -116,5 +117,7 @@ char **argv;
d = strtod (*argv, & p);
printf ("%lf [%s]\n", d, p);
}
+
+ return 0;
}
#endif
diff --git a/missing/system.c b/missing/system.c
index 8e613a3a..11db9925 100644
--- a/missing/system.c
+++ b/missing/system.c
@@ -1,27 +1,20 @@
-/*
- * system.c --- replacement system() for systems missing one
- */
+/* system.c --- replacement system() for systems missing one
-/*
- * Copyright (C) 1986, 1988, 1989, 1991 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
- */
+ Copyright (C) 1986, 1988, 1989, 1991 the Free Software Foundation, Inc.
+
+ 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, 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. */
extern void fatal();
diff --git a/msg.c b/msg.c
index 5bf3c2bc..82fa422e 100644
--- a/msg.c
+++ b/msg.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-1996 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -28,6 +28,9 @@
int sourceline = 0;
char *source = NULL;
+static char *srcfile = NULL;
+static int srcline;
+
/* prototype needed for ansi / gcc */
void err P((const char *s, const char *emsg, va_list argp));
@@ -44,6 +47,12 @@ va_list argp;
(void) fflush(stdout);
(void) fprintf(stderr, "%s: ", myname);
+#ifdef DEBUG
+ if (srcfile != NULL) {
+ fprintf(stderr, "%s:%d:", srcfile, srcline);
+ srcfile = NULL;
+ }
+#endif /* DEBUG */
if (sourceline != 0) {
if (source != NULL)
(void) fprintf(stderr, "%s:", source);
@@ -138,15 +147,26 @@ va_dcl
va_end(args);
}
+/* set_loc --- set location where a fatal error happened */
+
+void
+set_loc(file, line)
+char *file;
+int line;
+{
+ srcfile = file;
+ srcline = line;
+}
+
/* fatal --- print an error message and die */
#if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
void
-fatal(char *mesg, ...)
+r_fatal(char *mesg, ...)
#else
/*VARARGS0*/
void
-fatal(va_alist)
+r_fatal(va_alist)
va_dcl
#endif
{
diff --git a/node.c b/node.c
index 66c9ecb7..6f10b9f3 100644
--- a/node.c
+++ b/node.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-1996 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -79,6 +79,14 @@ register NODE *n;
return n->numbr;
}
+#ifdef NONDECDATA
+ errno = 0;
+ if (! do_traditional && isnondecimal(cp)) {
+ n->numbr = nondec2awknum(cp, cpend - cp);
+ goto finish;
+ }
+#endif /* NONDECDATA */
+
errno = 0;
save = *cpend;
*cpend = '\0';
@@ -88,6 +96,7 @@ register NODE *n;
while (ISSPACE(*ptr))
ptr++;
*cpend = save;
+finish:
/* the >= should be ==, but for SunOS 3.5 strtod() */
if (errno == 0 && ptr >= cpend)
n->flags |= newflags;
@@ -257,7 +266,7 @@ unsigned int flags;
r->flags = flags | SCALAR;
#ifdef DEBUG
r->stref = 1;
- r->stptr = 0;
+ r->stptr = NULL;
r->stlen = 0;
#endif
return r;
@@ -343,10 +352,11 @@ more_nodes()
/* get more nodes and initialize list */
emalloc(nextfree, NODE *, NODECHUNK * sizeof(NODE), "newnode");
- for (np = nextfree; np < &nextfree[NODECHUNK - 1]; np++) {
+ for (np = nextfree; np <= &nextfree[NODECHUNK - 1]; np++) {
np->flags = 0;
np->nextp = np + 1;
}
+ --np;
np->nextp = NULL;
np = nextfree;
nextfree = nextfree->nextp;
@@ -393,6 +403,11 @@ register NODE *tmp;
free(tmp->stptr);
}
freenode(tmp);
+ return;
+ }
+ if ((tmp->flags & FIELD) != 0) {
+ freenode(tmp);
+ return;
}
}
diff --git a/patchlevel.h b/patchlevel.h
index c6161a1f..f3608240 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -1 +1 @@
-#define PATCHLEVEL 2
+#define PATCHLEVEL 3
diff --git a/pc/ChangeLog b/pc/ChangeLog
index b750e922..f1386886 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,31 @@
+Thu May 15 12:49:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Release 3.0.3: Release tar file made.
+
+Tues May 13 20:06:09 1997 Darrel Hankerson <hankedr@mail.auburn.edu>
+
+ * vcWin32 target added. Some new tests for WIN32 in gawkmisc.c
+ io.c, and regex.c. Makefile changes for nmake, which can't
+ expand $($x).
+
+ * config.h updated for BITOPS and NONDECDATA (also in Makefile).
+
+Fri Apr 18 07:55:47 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * BETA Release 3.0.34: Release tar file made.
+
+Fri Jan 17 19:20:45 1997 Darrel Hankerson <hankedr@mail.auburn.edu>
+
+ * Makefile: add KUR's emxnt target for emx+RSXNT. Create awk.exe
+ "link" to gawk.exe for djgpp target. (Suggested by Eli Zaretskii.
+ Should be done as part of a smarter install, since awk.exe only
+ works with djgpp gawk.exe.) Separate djgpp-v1 into djgppv1
+ target. Install awk.exe if present.
+
+ * install.awk: install awk.exe if present (only for djgpp)
+
+ * config.h: additional include for emx+RSXNT.
+
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/pc/Makefile b/pc/Makefile
index a1329eb6..b7fe1e43 100644
--- a/pc/Makefile
+++ b/pc/Makefile
@@ -1,31 +1,35 @@
-# Makefile for gawk (GNU awk) 7 Oct 1996
+# Makefile for gawk (GNU awk) 2 Jan 1997
#
-# - for GNU C (djgpp) [executable for DOS (32-bit)]
-# - for GNU C (emx) [executable for OS/2 2.x or DOS (32-bit)]
-# - for Microsoft C 7 [ececutable for DOS (16-bit)]
-# - for Microsoft C 6.00A [executable for OS/2 or DOS (16-bit)]
-# - for Microsoft C 5.1 [executable for OS/2 or DOS (16-bit)]
+# - for GNU C (djgpp) [32bit executable for DOS]
+# - for GNU C (emx) [32bit executable for OS/2 or DOS or Win32]
+# - for MS-Visual C/C++ 4.x [Win32 executable for Windows 95 & NT]
+# - for Microsoft C 7 [16bit ececutable for DOS]
+# - for Microsoft C 6.00A [16bit executable for OS/2 or DOS]
-# Tested with GNU make and dmake-3.8 under OS/2 and DOS, and ndmake
-# under DOS. Compiling with dmake under DOS may require the DOS-only
-# version of dmake (so that swapping works).
+# Tested with GNU make and dmake-3.8 under OS/2 and DOS, and ndmake and
+# Microsoft nmake under DOS. Compiling with dmake under DOS may require the
+# DOS-only version of dmake (so that swapping works). nmake requires a
+# few edits in the configuration section below.
default:
@echo "Enter $(MAK) target "
@echo " where 'target' is chosen from "
- @echo " djgpp ... DOS 32-bit exe [GNU C, Delorie, v1 or v2] "
+ @echo " djgpp ... DOS 32-bit exe [GNU C, Delorie, v2] "
+ @echo " djgppv1 . DOS 32-bit exe [GNU C, Delorie, v1] "
@echo " emx ..... OS/2 32-bit exe [emx/gcc; uses emxlibc.dll] "
+ @echo " emxnt ... NT exe [emx/gcc with RSXNT] "
@echo " emxbnd .. OS/2 and DOS 32-bit exe [emx/gcc] "
@echo " msc ..... DOS exe [Microsoft C 7 & 8 (AKA 1.52)] "
@echo " msc6 .... DOS exe [Microsoft C 6.00a] "
@echo " msc6os2 . OS/2 exe [Microsoft C 6.00a] "
@echo " msc6bnd . OS/2 and DOS exe [Microsoft C 6.00a] "
- @echo " msvc32 .. DOS exe [Microsoft Visual C] "
+ @echo " vcWin32 . Win32 exe [Microsoft Visual C] "
@echo " ----------------------------------------------------- "
@echo " test .... Perform tests (see README_d/README.pc) "
@echo " install . Install gawk under $(prefix)/ "
# Support dropped in 3.0
+# - for Microsoft C 5.1 [16bit executable for OS/2 or DOS]
# @echo " msc51 DOS exe [Microsoft C 5.1] "
# @echo " msc51bnd OS/2 and DOS exe [Microsoft C 5.1] "
@@ -68,6 +72,16 @@ prefix = c:/gnu
# Define the install method. Method 1 is Unix-like (and requires cat,
# cp, mkdir, sed, and sh); method 2 uses gawk and batch files.
install = 1
+#------------------------------------------------------------------------
+# To work around command-line length problems, this makefile assumes
+# that $($X) can be expanded. If using a make (such as nmake) which
+# cannot handle such macros, define DO_LNK and DO_BIND for your target
+# as $(L<target>) and $(B<target>), resp.; e.g.,
+#DO_LNK = $(LvcWin32)
+#DO_BIND= $(BvcWin32)
+# and then comment the following:
+DO_LNK = $($(LNK))
+DO_BIND= $($(BIND))
#========================================================================
# End of general configuration. Some platform-specific configuration
# notes appear below.
@@ -77,9 +91,8 @@ install = 1
#========================== DJGPP =======================================
#========================================================================
-LDJG = $(CC) $(LF) -o gawk $(LDRSP) $(LF2)
-#BDJG = coff2exe -s /djgpp/bin/go32.exe gawk
-BDJG = coff2exe gawk
+LDJG = $(CC) $(LF) -o gawk.exe $(LDRSP) $(LF2)
+BDJG = stubify -g awk.exe | stubedit awk.exe runfile=gawk
djgpp:
$(MAK) all \
@@ -93,6 +106,16 @@ djgpp-debug:
LNK=LDJG LF2=-lm \
BIND=BDJG
+LDJGv1 = $(CC) $(LF) -o gawk $(LDRSP) $(LF2)
+#BDJGv1 = coff2exe -s /djgpp/bin/go32.exe gawk
+BDJGv1 = coff2exe gawk
+
+djgppv1:
+ $(MAK) all \
+ CC=gcc O=.o CF=-O \
+ LNK=LDJGv1 LF=-s LF2=-lm \
+ BIND=BDJGv1
+
#========================================================================
#========================== EMX =========================================
#========================================================================
@@ -112,6 +135,11 @@ emx:
"CC=gcc -Zomf" O=.obj "CF=-O -DOS2" \
LNK=LEMX "LF=-s -Zcrtdll -Zstack 512" RSP=
+emxnt:
+ $(MAK) all \
+ "CC=gcc -Zwin32 -Zcrtdll=rsxntcs" O=.o "CF=-O -DOS2" \
+ LNK=LEMX "LF=-s -Zstack 512" RSP=
+
emxbnd:
$(MAK) all \
CC=gcc O=.o "CF=-O -DOS2 -DMSDOS" OBJ=popen.o \
@@ -120,7 +148,7 @@ emxbnd:
emxbnd-debug:
$(MAK) all \
- CC=gcc O=.o CF="-g -DOS2 -DMSDOS" OBJ=popen.o \
+ CC=gcc O=.o "CF=-g -DOS2 -DMSDOS" OBJ=popen.o \
LNK=LEMXBND \
BIND=BEMXD "P=|tr \" \" \"\n\""
@@ -146,13 +174,14 @@ MSCLIB = llibce
MSCCL = -FPi
#MSCCL = -FPc
-LMSC = link $(LF) $(LNKRSP) $(STDARGV)/NOE,$@,,/NOD:llibce $(MSCLIB)$(LF2)/STACK:0x5900,nul
+LMSC = link $(LF) $(LNKRSP) $(STDARGV)/NOE,$@,,/NOD:llibce $(MSCLIB)$(LF2)/STACK:0x5420,nul
# CLMSC-linking works when building under OS/2
CLMSC = $(CC) -o $@ $(LF) $(GAWKOBJS) $(STDARGV) $(LF2) -link /NOE/NOI/STACK:0x6f00
BMSC = bind $@ /n DOSMAKEPIPE DOSCWAIT
+
# Ugly hack: config.h defines __STDC__ if not defined on command-line.
# OS/2 versions can't use -Za in getid.c. MSC7 uses stub headers in pc/
# due to ANSI conflicts. MSC 5.1 defines __STDC__=0 regardless of ANSI flag.
@@ -168,6 +197,8 @@ msc:
"CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -Ze -Ipc/include $(MSCOPT)" \
OBJ=popen.obj \
LNK=LMSC P=+
+Lmsc = $(LMSC) # for broken makes (nmake) which cannot expand $($X)
+Bmsc =
msc-debug:
$(MAK) all \
@@ -182,6 +213,8 @@ msc6:
"CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -Za $(MSCOPT)" \
OBJ=popen.obj \
LNK=LMSC P=+
+Lmsc6 = $(LMSC) # for broken makes (nmake) which cannot expand $($X)
+Bmsc6 =
msc6os2:
$(MAK) builtin.obj \
@@ -198,6 +231,18 @@ msc6bnd:
OBJ=popen.obj \
LNK=LMSC "LF2=p,gawk.def" P=+ \
BIND=BMSC
+Lmsc6bnd = $(LMSC) # for broken makes (nmake) which cannot expand $($X)
+Bmsc6bnd = $(BMSC)
+
+
+# Windows '95 / NT
+LvcWin32 = link -nologo -subsystem:console -release -out:$@ $(LNKRSP)
+
+vcWin32:
+ $(MAK) all \
+ "CC=cl -nologo" O=.obj "CF=-o2 -DWIN32 -D__STDC__=0" \
+ LNK=LvcWin32
+
# Support dropped in 3.0
#msc51:
@@ -212,24 +257,14 @@ msc6bnd:
# OBJ=popen.obj \
# LNK=CLMSC "LF=-Lp -Fb" "LF2=gawk.def"
-
-# The msvc32 target was supplied by a user, and is untested by the
-# OS/2 and DOS maintainers. Bug reports welcomed.
-
-LNKMSVC32="link -out:gawk.exe $(LNKRSP)"
-
-msvc32:
- $(MAK) all \
- "CC=cl -nologo" O=.obj "CF=-DMSDOS -D__STDC__=0" \
- OBJ=popen.obj \
- LNK=LNKMSVC32
-
#========================================================================
# Define BIND for BINDless compiles, otherwise $($(BIND)) may break.
BIND = EMPTY
EMPTY=
+# bitwise operations (-DBITOPS) and non-decimal input data (-DNONDECDATA) are
+# undocumented in 3.0.3. They may be enabled in config.h, or added to CFLAGS.
CFLAGS = $(CF) -DGAWK -I. -DHAVE_CONFIG_H
# object files
@@ -256,9 +291,9 @@ GAWKOBJS = $(ALLOBJS) $(LIBOBJS)
all : gawk.exe
gawk.exe:: $(GAWKOBJS) $(RSP)
- $($(LNK))
- $($(BIND))
-
+ $(DO_LNK)
+ $(DO_BIND)
+
$(RSPFILE) : $(GAWKOBJS)
echo $(AWKOBJS1)$P > $@
echo $(AWKOBJS2)$P >> $@
@@ -293,7 +328,7 @@ install1:
sed "s;igawk;$(prefix)/bin/igawk;" pc/awklib/igawk.bat > igawk.bat
sh mkinstal.sh $(prefix)/bin
sh mkinstal.sh $(prefix)/lib/awk $(prefix)/man/man1 $(prefix)/info
- cp gawk.exe igawk.bat igawk.cmd pc/awklib/igawk $(prefix)/bin
+ cp *awk.exe igawk.bat igawk.cmd pc/awklib/igawk $(prefix)/bin
cp awklib/eg/lib/* pc/awklib/igawk.awk $(prefix)/lib/awk
cp doc/*.1 $(prefix)/man/man1
cp doc/gawk.info $(prefix)/info
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index ebc171f3..f530a300 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -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.
@@ -70,7 +70,7 @@
# Using EMXSHELL=/bin/sh with emx versions can exhaust lower mem.
# Lower mem can also be exhausted on some of the tests even with MSC gawk.
# The .SWAP setting forces (DOS-only) dmake to swap itself out.
-.SWAP: childin fflush getlnhd tweakfld
+.SWAP: childin fflush getlnhd tweakfld pipeio1
# This won't work unless you have "sh" and set SHELL equal to it (Make 3.74
# or later which comes with DJGPP will work with SHELL=/bin/sh if you have
@@ -100,8 +100,8 @@ MKDIR = mkdir
#MKDIR = true && command -c mkdir
# Set your unix-style date function here
-#DATE = date
DATE = gdate
+#DATE = date
# ============================================================================
# You shouldn't need to modify anything below this line.
@@ -119,12 +119,13 @@ 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: poundba fflush getlnhd
+unix-tests: poundba 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: regtes inftest
@@ -207,6 +208,9 @@ manyfiles::
@$(MKDIR) junk
@$(AWK) 'BEGIN { for (i = 1; i <= 300; i++) print i, i}' >_$@
@$(AWK) -f $(srcdir)/manyfiles.awk _$@ _$@
+ @echo 'If manyfiles says "junk/*: No such file or directory",'
+ @echo 'use the line on test/Makefile which invokes wc'
+ @echo 'without quoting the "junk/*" argument.'
# @echo "This number better be 1 ->" | tr -d '\012'
@echo "This number better be 1 ->" | tr -d '\012\015'
# @wc -l junk/* | $(AWK) '$$1 != 2' | wc -l
@@ -318,11 +322,15 @@ 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) ;
- @$(DATE) | $(AWK) '{ $$3 = sprintf("%02d", $$3 + 0) ; \
+# @LC_ALL=C; export LC_ALL; LANC=C; export LANG; \
+# date | $(AWK) '{ $$3 = sprintf("%02d", $$3 + 0) ; \
+# This was changed for DOS to avoid the command-line length limit.
+ @LC_ALL=C; export LC_ALL; LANC=C; export LANG; $(DATE) > strf
+ @cat strf | $(AWK) '{ $$3 = sprintf("%02d", $$3 + 0) ; \
print > "strftime.ok" ; \
print strftime() > "'_$@'" }'
- $(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0
+# $(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0
+ $(CMP) strftime.ok _$@ && rm -f _$@ strf strftime.ok || exit 0
litoct::
@echo ab | $(AWK) --traditional -f $(srcdir)/litoct.awk >_$@
@@ -480,15 +488,101 @@ 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::
+ @echo 'Expect pid to fail in DOS.'
+ @AWKPATH=$(srcdir) AWK=$(AWK) $(SHELL) $(srcdir)/pid.sh $$$$ > _`basename $@` ; :
+ -$(CMP) $(srcdir)/pid.ok _`basename $@` && rm -f _`basename $@` _`basename $@`.in
+
+strftlng::
+ @echo 'Edit test/Makefile if you use MSC6, since strftlng will fail.'
+ @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 > _$@
+ @echo A B C D E | tr -d '\15\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::
+ @echo 'Pipeio1 is set to ignore errors. However, there should not be any.'
+ @echo 'If pipeio1 fails, set sh to swap to disk only (in sh.rc).'
+ @echo 'If it still hangs with EMX gawk type ^C, then try the test when'
+ @echo 'not using DPMI and RSX (in particular, run outside MS-Windows).'
+ @$(AWK) -f $(srcdir)/pipeio1.awk >_$@
+ @rm -f test1 test2
+ -$(CMP) $(srcdir)/pipeio1.ok _$@ && rm -f _$@
+
+pipeio2::
+# This would fail were it not for the "cat" line due to DOS's ECHO command.
+ @echo 'pipeio may fail due to the way that your tr & echo work in DOS'
+ @$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@
+ @cat _$@ | $(AWK) '{ sub("ECHO is.*","",$$0); print $$0 } ' > _$@.2
+# $(CMP) $(srcdir)/pipeio2.ok _$@ && rm -f _$@
+ -diff -w $(srcdir)/pipeio2.ok _$@.2 && rm -f _$@ _$@.2
+
+funstack::
+ @echo 'Expect funstack to fail with MSC DOS versions.'
+ -@$(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::
+# This was changed for DOS to avoid the command-line length limit.
+# @if grep BITOP ../config.h | grep define > /dev/null; \
+# then \
+# $(AWK) -f $(srcdir)/nondec.awk >_$@; \
+# else \
+# cp $(srcdir)/nondec.ok _$@; \
+# fi
+ @echo "Don't worry if nondec fails"
+ $(AWK) -f $(srcdir)/nondec.awk >_$@;
+ -$(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/pc/config.h b/pc/config.h
index ff6ed616..7140ac80 100644
--- a/pc/config.h
+++ b/pc/config.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (C) 1995 the Free Software Foundation, Inc.
+ * Copyright (C) 1995-1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Progamming Language.
@@ -128,6 +128,9 @@
#define REGEX_MALLOC 1 /* use malloc instead of alloca in regex.c */
#define SPRINTF_RET int /* return type of sprintf */
+/* #define BITOPS 1 */ /* bitwise ops (undocumented feature) */
+/* #define NONDECDATA 1 */ /* non-decimal input data (undocumented feature) */
+
/* Define if you have the fmod function. */
#define HAVE_FMOD 1
@@ -211,3 +214,7 @@ void * alloca(unsigned);
#if defined(DJGPP)
# define HAVE_LIMITS_H
#endif
+
+#if defined(__WIN32__) && defined(__CRTRSXNT__)
+#include <crtrsxnt.h>
+#endif
diff --git a/pc/install.awk b/pc/install.awk
index 1b125d47..67113898 100644
--- a/pc/install.awk
+++ b/pc/install.awk
@@ -53,7 +53,7 @@ while (getline < igawk) print $0 > igawk_cmd
printf("@sh %s/bin/igawk %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9", prefix) > igawk_bat
# Do common
-cp(igawk " gawk.exe " prefix "/bin")
+cp(igawk " *awk.exe " prefix "/bin")
mkinstalldirs(prefix "/lib/awk " prefix "/man/man1 " prefix "/info")
cp("awklib/eg/lib/* pc/awklib/igawk.awk " prefix "/lib/awk");
cp("doc/*.1 " prefix "/man/man1");
diff --git a/posix/ChangeLog b/posix/ChangeLog
index e025b89d..575baa17 100644
--- a/posix/ChangeLog
+++ b/posix/ChangeLog
@@ -1,3 +1,11 @@
+Thu May 15 12:49:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Release 3.0.3: Release tar file made.
+
+Fri Apr 18 07:55:47 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * BETA Release 3.0.34: Release tar file made.
+
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/posix/gawkmisc.c b/posix/gawkmisc.c
index 2c5f09d3..68bfb5dd 100644
--- a/posix/gawkmisc.c
+++ b/posix/gawkmisc.c
@@ -1,27 +1,20 @@
-/*
- * gawkmisc.c --- miscellanious gawk routines that are OS specific.
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991 - 96 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
- */
+/* gawkmisc.c --- miscellanious gawk routines that are OS specific.
+
+ Copyright (C) 1986, 1988, 1989, 1991 - 96 the Free Software Foundation, Inc.
+
+ 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, 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. */
char quote = '\'';
char *defpath = DEFPATH;
diff --git a/regex.c b/regex.c
index d378c036..221c9b5d 100644
--- a/regex.c
+++ b/regex.c
@@ -1,9 +1,9 @@
/* Extended regular expression matching and search library,
version 0.12.
- (Implements POSIX draft P10003.2/D11.2, except for
+ (Implements POSIX draft P1003.2/D11.2, except for some of the
internationalization features.)
- Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
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
@@ -16,9 +16,8 @@
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. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* AIX requires this to be the first thing in the file. */
#if defined (_AIX) && !defined (REGEX_MALLOC)
@@ -39,6 +38,13 @@
#include <sys/types.h>
#endif
+/* For platform which support the ISO C amendement 1 functionality we
+ support user defined character classes. */
+#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+# include <wctype.h>
+# include <wchar.h>
+#endif
+
/* This is for other GNU distributions with internationalized messages. */
#if HAVE_LIBINTL_H || defined (_LIBC)
# include <libintl.h>
@@ -501,7 +507,7 @@ typedef enum
} while (0)
#ifdef DEBUG
-static void extract_number _RE_ARGS((int *dest, unsigned char *source));
+static void extract_number _RE_ARGS ((int *dest, unsigned char *source));
static void
extract_number (dest, source)
int *dest;
@@ -529,8 +535,8 @@ extract_number (dest, source)
} while (0)
#ifdef DEBUG
-static void extract_number_and_incr _RE_ARGS((int *destination,
- unsigned char **source));
+static void extract_number_and_incr _RE_ARGS ((int *destination,
+ unsigned char **source));
static void
extract_number_and_incr (destination, source)
int *destination;
@@ -615,6 +621,7 @@ print_partial_compiled_pattern (start, end)
unsigned char *end;
{
int mcnt, mcnt2;
+ unsigned char *p1;
unsigned char *p = start;
unsigned char *pend = end;
@@ -756,20 +763,23 @@ print_partial_compiled_pattern (start, end)
case succeed_n:
extract_number_and_incr (&mcnt, &p);
+ p1 = p + mcnt;
extract_number_and_incr (&mcnt2, &p);
- printf ("/succeed_n to %d, %d times", p + mcnt - start, mcnt2);
+ printf ("/succeed_n to %d, %d times", p1 - start, mcnt2);
break;
case jump_n:
extract_number_and_incr (&mcnt, &p);
+ p1 = p + mcnt;
extract_number_and_incr (&mcnt2, &p);
- printf ("/jump_n to %d, %d times", p + mcnt - start, mcnt2);
+ printf ("/jump_n to %d, %d times", p1 - start, mcnt2);
break;
case set_number_at:
extract_number_and_incr (&mcnt, &p);
+ p1 = p + mcnt;
extract_number_and_incr (&mcnt2, &p);
- printf ("/set_number_at location %d to %d", p + mcnt - start, mcnt2);
+ printf ("/set_number_at location %d to %d", p1 - start, mcnt2);
break;
case wordbound:
@@ -847,7 +857,8 @@ print_compiled_pattern (bufp)
unsigned char *buffer = bufp->buffer;
print_partial_compiled_pattern (buffer, buffer + bufp->used);
- printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated);
+ printf ("%ld bytes used/%ld bytes allocated.\n",
+ bufp->used, bufp->allocated);
if (bufp->fastmap_accurate && bufp->fastmap)
{
@@ -862,7 +873,7 @@ print_compiled_pattern (bufp)
printf ("no_sub: %d\t", bufp->no_sub);
printf ("not_bol: %d\t", bufp->not_bol);
printf ("not_eol: %d\t", bufp->not_eol);
- printf ("syntax: %d\n", bufp->syntax);
+ printf ("syntax: %lx\n", bufp->syntax);
/* Perhaps we should print the translate table? */
}
@@ -875,7 +886,7 @@ print_double_string (where, string1, size1, string2, size2)
int size1;
int size2;
{
- unsigned this_char;
+ int this_char;
if (where == NULL)
printf ("(null)");
@@ -896,9 +907,9 @@ print_double_string (where, string1, size1, string2, size2)
void
printchar (c)
- int c;
+ int c;
{
- putc(c, stderr);
+ putc (c, stderr);
}
#else /* not DEBUG */
@@ -1031,15 +1042,17 @@ static const char *re_error_msgid[] =
#ifdef INT_IS_16BIT
#if defined (MATCH_MAY_ALLOCATE)
-long re_max_failures = 20000;
+/* 4400 was enough to cause a crash on Alpha OSF/1,
+ whose default stack limit is 2mb. */
+long int re_max_failures = 4000;
#else
-long re_max_failures = 2000;
+long int re_max_failures = 2000;
#endif
union fail_stack_elt
{
unsigned char *pointer;
- long integer;
+ long int integer;
};
typedef union fail_stack_elt fail_stack_elt_t;
@@ -1047,8 +1060,8 @@ typedef union fail_stack_elt fail_stack_elt_t;
typedef struct
{
fail_stack_elt_t *stack;
- unsigned long size;
- unsigned long avail; /* Offset of next open position. */
+ unsigned long int size;
+ unsigned long int avail; /* Offset of next open position. */
} fail_stack_type;
#else /* not INT_IS_16BIT */
@@ -1118,7 +1131,7 @@ typedef struct
REGEX_REALLOCATE_STACK requires `destination' be declared. */
#define DOUBLE_FAIL_STACK(fail_stack) \
- ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \
+ ((fail_stack).size > (unsigned) (re_max_failures * MAX_FAILURE_ITEMS) \
? 0 \
: ((fail_stack).stack = (fail_stack_elt_t *) \
REGEX_REALLOCATE_STACK ((fail_stack).stack, \
@@ -1189,8 +1202,8 @@ typedef struct
char *destination; \
/* Must be int, so when we don't save any registers, the arithmetic \
of 0 + -1 isn't done as unsigned. */ \
- /* Can't be int, since there is not a shred of a guarantee that int \
- is wide enough to hold a value of something to which pointer can \
+ /* Can't be int, since there is not a shred of a guarantee that int \
+ is wide enough to hold a value of something to which pointer can \
be assigned */ \
s_reg_t this_reg; \
\
@@ -1248,7 +1261,7 @@ typedef struct
DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\
PUSH_FAILURE_INT (highest_active_reg); \
\
- DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \
+ DEBUG_PRINT2 (" Pushing pattern 0x%x:\n", pattern_place); \
DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \
PUSH_FAILURE_POINTER (pattern_place); \
\
@@ -1332,7 +1345,7 @@ typedef struct
DEBUG_PRINT1 ("'\n"); \
\
pat = (unsigned char *) POP_FAILURE_POINTER (); \
- DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \
+ DEBUG_PRINT2 (" Popping pattern 0x%x:\n", pat); \
DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \
\
/* Restore register info. */ \
@@ -1435,25 +1448,25 @@ static char reg_unset_dummy;
/* Subroutine declarations and macros for regex_compile. */
-static reg_errcode_t regex_compile _RE_ARGS((const char *pattern, size_t size,
- reg_syntax_t syntax,
- struct re_pattern_buffer *bufp));
-static void store_op1 _RE_ARGS((re_opcode_t op, unsigned char *loc, int arg));
-static void store_op2 _RE_ARGS((re_opcode_t op, unsigned char *loc,
- int arg1, int arg2));
-static void insert_op1 _RE_ARGS((re_opcode_t op, unsigned char *loc,
- int arg, unsigned char *end));
-static void insert_op2 _RE_ARGS((re_opcode_t op, unsigned char *loc,
- int arg1, int arg2, unsigned char *end));
-static boolean at_begline_loc_p _RE_ARGS((const char *pattern, const char *p,
- reg_syntax_t syntax));
-static boolean at_endline_loc_p _RE_ARGS((const char *p, const char *pend,
- reg_syntax_t syntax));
-static reg_errcode_t compile_range _RE_ARGS((const char **p_ptr,
- const char *pend,
- char *translate,
- reg_syntax_t syntax,
- unsigned char *b));
+static reg_errcode_t regex_compile _RE_ARGS ((const char *pattern, size_t size,
+ reg_syntax_t syntax,
+ struct re_pattern_buffer *bufp));
+static void store_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg));
+static void store_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc,
+ int arg1, int arg2));
+static void insert_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc,
+ int arg, unsigned char *end));
+static void insert_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc,
+ int arg1, int arg2, unsigned char *end));
+static boolean at_begline_loc_p _RE_ARGS ((const char *pattern, const char *p,
+ reg_syntax_t syntax));
+static boolean at_endline_loc_p _RE_ARGS ((const char *p, const char *pend,
+ reg_syntax_t syntax));
+static reg_errcode_t compile_range _RE_ARGS ((const char **p_ptr,
+ const char *pend,
+ char *translate,
+ reg_syntax_t syntax,
+ unsigned char *b));
/* Fetch the next character in the uncompiled pattern---translating it
if necessary. Also cast from a signed character in the constant
@@ -1495,7 +1508,7 @@ static reg_errcode_t compile_range _RE_ARGS((const char **p_ptr,
/* Make sure we have at least N more bytes of space in buffer. */
#define GET_BUFFER_SPACE(n) \
- while (b - bufp->buffer + (n) > bufp->allocated) \
+ while ((unsigned long) (b - bufp->buffer + (n)) > bufp->allocated) \
EXTEND_BUFFER ()
/* Make sure we have one more byte of buffer space and then add C to it. */
@@ -1528,19 +1541,19 @@ static reg_errcode_t compile_range _RE_ARGS((const char **p_ptr,
/* Store a jump with opcode OP at LOC to location TO. We store a
relative address offset by the three bytes the jump itself occupies. */
#define STORE_JUMP(op, loc, to) \
- store_op1 (op, loc, (int)((to) - (loc) - 3))
+ store_op1 (op, loc, (int) ((to) - (loc) - 3))
/* Likewise, for a two-argument jump. */
#define STORE_JUMP2(op, loc, to, arg) \
- store_op2 (op, loc, (int)((to) - (loc) - 3), arg)
+ store_op2 (op, loc, (int) ((to) - (loc) - 3), arg)
/* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */
#define INSERT_JUMP(op, loc, to) \
- insert_op1 (op, loc, (int)((to) - (loc) - 3), b)
+ insert_op1 (op, loc, (int) ((to) - (loc) - 3), b)
/* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */
#define INSERT_JUMP2(op, loc, to, arg) \
- insert_op2 (op, loc, (int)((to) - (loc) - 3), arg, b)
+ insert_op2 (op, loc, (int) ((to) - (loc) - 3), arg, b)
/* This is not an arbitrary limit: the arguments which represent offsets
@@ -1551,15 +1564,15 @@ static reg_errcode_t compile_range _RE_ARGS((const char **p_ptr,
MSC and drop MAX_BUF_SIZE a bit. Otherwise you may end up
reallocating to 0 bytes. Such thing is not going to work too well.
You have been warned!! */
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(WIN32)
/* Microsoft C 16-bit versions limit malloc to approx 65512 bytes.
The REALLOC define eliminates a flurry of conversion warnings,
but is not required. */
#define MAX_BUF_SIZE 65500L
-#define REALLOC(p,s) realloc((p), (size_t) (s))
+#define REALLOC(p,s) realloc ((p), (size_t) (s))
#else
#define MAX_BUF_SIZE (1L << 16)
-#define REALLOC realloc
+#define REALLOC(p,s) realloc ((p), (s))
#endif
/* Extend the buffer by twice its current size via realloc and
@@ -1574,7 +1587,7 @@ static reg_errcode_t compile_range _RE_ARGS((const char **p_ptr,
bufp->allocated <<= 1; \
if (bufp->allocated > MAX_BUF_SIZE) \
bufp->allocated = MAX_BUF_SIZE; \
- bufp->buffer = (unsigned char *) REALLOC(bufp->buffer, bufp->allocated);\
+ bufp->buffer = (unsigned char *) REALLOC (bufp->buffer, bufp->allocated);\
if (bufp->buffer == NULL) \
return REG_ESPACE; \
/* If the buffer moved, move all the pointers into it. */ \
@@ -1606,7 +1619,7 @@ typedef unsigned regnum_t;
/* Since offsets can go either forwards or backwards, this type needs to
be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */
-/* int may be not enough when sizeof(int) == 2 */
+/* int may be not enough when sizeof(int) == 2. */
typedef long pattern_offset_t;
typedef struct
@@ -1659,15 +1672,29 @@ typedef struct
} \
}
-#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
+#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+/* The GNU C library provides support for user-defined character classes
+ and the functions from ISO C amendement 1. */
+# ifdef CHARCLASS_NAME_MAX
+# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
+# else
+/* This shouldn't happen but some implementation might still have this
+ problem. Use a reasonable default value. */
+# define CHAR_CLASS_MAX_LENGTH 256
+# endif
+
+# define IS_CHAR_CLASS(string) wctype (string)
+#else
+# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
-#define IS_CHAR_CLASS(string) \
+# define IS_CHAR_CLASS(string) \
(STREQ (string, "alpha") || STREQ (string, "upper") \
|| STREQ (string, "lower") || STREQ (string, "digit") \
|| STREQ (string, "alnum") || STREQ (string, "xdigit") \
|| STREQ (string, "space") || STREQ (string, "print") \
|| STREQ (string, "punct") || STREQ (string, "graph") \
|| STREQ (string, "cntrl") || STREQ (string, "blank"))
+#endif
#ifndef MATCH_MAY_ALLOCATE
@@ -1717,9 +1744,9 @@ regex_grow_registers (num_regs)
#endif /* not MATCH_MAY_ALLOCATE */
-static boolean group_in_compile_stack _RE_ARGS((compile_stack_type
- compile_stack,
- regnum_t regnum));
+static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type
+ compile_stack,
+ regnum_t regnum));
/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX.
Returns one of error codes defined in `regex.h', or zero for success.
@@ -2145,6 +2172,34 @@ regex_compile (pattern, size, syntax, bufp)
the leading `:' and `[' (but set bits for them). */
if (c == ':' && *p == ']')
{
+#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+ boolean is_lower = STREQ (str, "lower");
+ boolean is_upper = STREQ (str, "upper");
+ wctype_t wt;
+ int ch;
+
+ wt = wctype (str);
+ if (wt == 0)
+ FREE_STACK_RETURN (REG_ECTYPE);
+
+ /* Throw away the ] at the end of the character
+ class. */
+ PATFETCH (c);
+
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ for (ch = 0; ch < 1 << BYTEWIDTH; ++ch)
+ {
+ if (iswctype (btowc (ch), wt))
+ SET_LIST_BIT (ch);
+
+ if (translate && (is_upper || is_lower)
+ && (ISUPPER (ch) || ISLOWER (ch)))
+ SET_LIST_BIT (ch);
+ }
+
+ had_char_class = true;
+#else
int ch;
boolean is_alnum = STREQ (str, "alnum");
boolean is_alpha = STREQ (str, "alpha");
@@ -2187,11 +2242,12 @@ regex_compile (pattern, size, syntax, bufp)
|| (is_upper && ISUPPER (ch))
|| (is_xdigit && ISXDIGIT (ch)))
SET_LIST_BIT (ch);
- if ( translate && (is_upper || is_lower)
- && (ISUPPER(ch) || ISLOWER(ch)))
+ if ( translate && (is_upper || is_lower)
+ && (ISUPPER (ch) || ISLOWER (ch)))
SET_LIST_BIT (ch);
}
had_char_class = true;
+#endif /* libc || wctype.h */
}
else
{
@@ -2616,7 +2672,7 @@ regex_compile (pattern, size, syntax, bufp)
case 'w':
if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
+ goto normal_char;
laststart = b;
BUF_PUSH (wordchar);
break;
@@ -2624,7 +2680,7 @@ regex_compile (pattern, size, syntax, bufp)
case 'W':
if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
+ goto normal_char;
laststart = b;
BUF_PUSH (notwordchar);
break;
@@ -2632,37 +2688,37 @@ regex_compile (pattern, size, syntax, bufp)
case '<':
if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
+ goto normal_char;
BUF_PUSH (wordbeg);
break;
case '>':
if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
+ goto normal_char;
BUF_PUSH (wordend);
break;
case 'b':
if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
+ goto normal_char;
BUF_PUSH (wordbound);
break;
case 'B':
if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
+ goto normal_char;
BUF_PUSH (notwordbound);
break;
case '`':
if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
+ goto normal_char;
BUF_PUSH (begbuf);
break;
case '\'':
if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
+ goto normal_char;
BUF_PUSH (endbuf);
break;
@@ -2677,7 +2733,7 @@ regex_compile (pattern, size, syntax, bufp)
FREE_STACK_RETURN (REG_ESUBREG);
/* Can't back reference to a subexpression if inside of it. */
- if (group_in_compile_stack (compile_stack, (regnum_t)c1))
+ if (group_in_compile_stack (compile_stack, (regnum_t) c1))
goto normal_char;
laststart = b;
@@ -2961,7 +3017,7 @@ compile_range (p_ptr, pend, translate, syntax, b)
unsigned this_char;
const char *p = *p_ptr;
- int range_start, range_end;
+ unsigned int range_start, range_end;
if (p == pend)
return REG_ERANGE;
@@ -3611,17 +3667,17 @@ re_match (bufp, string, size, pos, regs)
}
#endif /* not emacs */
-static boolean group_match_null_string_p _RE_ARGS((unsigned char **p,
- unsigned char *end,
- register_info_type *reg_info));
-static boolean alt_match_null_string_p _RE_ARGS((unsigned char *p,
- unsigned char *end,
- register_info_type *reg_info));
-static boolean common_op_match_null_string_p _RE_ARGS((unsigned char **p,
- unsigned char *end,
+static boolean group_match_null_string_p _RE_ARGS ((unsigned char **p,
+ unsigned char *end,
+ register_info_type *reg_info));
+static boolean alt_match_null_string_p _RE_ARGS ((unsigned char *p,
+ unsigned char *end,
+ register_info_type *reg_info));
+static boolean common_op_match_null_string_p _RE_ARGS ((unsigned char **p,
+ unsigned char *end,
register_info_type *reg_info));
-static int bcmp_translate _RE_ARGS((const char *s1, const char *s2,
- int len, char *translate));
+static int bcmp_translate _RE_ARGS ((const char *s1, const char *s2,
+ int len, char *translate));
/* re_match_2 matches the compiled pattern in BUFP against the
the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1
@@ -3835,7 +3891,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
/* Initialize subexpression text positions to -1 to mark ones that no
start_memory/stop_memory has been seen for. Also initialize the
register information struct. */
- for (mcnt = 1; mcnt < num_regs; mcnt++)
+ for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
{
regstart[mcnt] = regend[mcnt]
= old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE;
@@ -3887,7 +3943,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
dend = end_match_2;
}
- DEBUG_PRINT1 ("The compiled pattern is: ");
+ DEBUG_PRINT1 ("The compiled pattern is:\n");
DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend);
DEBUG_PRINT1 ("The string to match is: `");
DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2);
@@ -3898,7 +3954,11 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
fails at this starting point in the input data. */
for (;;)
{
+#ifdef _LIBC
+ DEBUG_PRINT2 ("\n%p: ", p);
+#else
DEBUG_PRINT2 ("\n0x%x: ", p);
+#endif
if (p == pend)
{ /* End of pattern means we might have succeeded. */
@@ -3935,7 +3995,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
DEBUG_PRINT1 ("\nSAVING match as best so far.\n");
- for (mcnt = 1; mcnt < num_regs; mcnt++)
+ for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
{
best_regstart[mcnt] = regstart[mcnt];
best_regend[mcnt] = regend[mcnt];
@@ -3961,7 +4021,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
dend = ((d >= string1 && d <= end1)
? end_match_1 : end_match_2);
- for (mcnt = 1; mcnt < num_regs; mcnt++)
+ for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
{
regstart[mcnt] = best_regstart[mcnt];
regend[mcnt] = best_regend[mcnt];
@@ -4026,7 +4086,8 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
/* Go through the first `min (num_regs, regs->num_regs)'
registers, since that is all we initialized. */
- for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++)
+ for (mcnt = 1; (unsigned) mcnt < MIN (num_regs, regs->num_regs);
+ mcnt++)
{
if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
regs->start[mcnt] = regs->end[mcnt] = -1;
@@ -4044,7 +4105,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
we (re)allocated the registers, this is the case,
because we always allocate enough to have at least one
-1 at the end. */
- for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++)
+ for (mcnt = num_regs; (unsigned) mcnt < regs->num_regs; mcnt++)
regs->start[mcnt] = regs->end[mcnt] = -1;
} /* regs && !bufp->no_sub */
@@ -4316,7 +4377,8 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
EVER_MATCHED_SOMETHING (reg_info[*p]) = 0;
/* Restore this and inner groups' (if any) registers. */
- for (r = *p; r < *p + *(p + 1); r++)
+ for (r = *p; r < (unsigned) *p + (unsigned) *(p + 1);
+ r++)
{
regstart[r] = old_regstart[r];
@@ -4475,7 +4537,11 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump");
EXTRACT_NUMBER_AND_INCR (mcnt, p);
+#ifdef _LIBC
+ DEBUG_PRINT3 (" %d (to %p):\n", mcnt, p + mcnt);
+#else
DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt);
+#endif
PUSH_FAILURE_POINT (p + mcnt, NULL, -2);
break;
@@ -4498,7 +4564,11 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
DEBUG_PRINT1 ("EXECUTING on_failure_jump");
EXTRACT_NUMBER_AND_INCR (mcnt, p);
+#ifdef _LIBC
+ DEBUG_PRINT3 (" %d (to %p)", mcnt, p + mcnt);
+#else
DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt);
+#endif
/* If this on_failure_jump comes right before a group (i.e.,
the original * applied to a group), save the information
@@ -4626,10 +4696,17 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
= *p2 == (unsigned char) endline ? '\n' : p2[2];
#endif
+#if 0
if ((re_opcode_t) p1[3] == exactn
&& ! ((int) p2[1] * BYTEWIDTH > (int) p1[5]
&& (p2[2 + p1[5] / BYTEWIDTH]
& (1 << (p1[5] % BYTEWIDTH)))))
+#else
+ if ((re_opcode_t) p1[3] == exactn
+ && ! ((int) p2[1] * BYTEWIDTH > (int) p1[4]
+ && (p2[2 + p1[4] / BYTEWIDTH]
+ & (1 << (p1[4] % BYTEWIDTH)))))
+#endif
{
p[-3] = (unsigned char) pop_failure_jump;
DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n",
@@ -4704,16 +4781,26 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
dummy_low_reg, dummy_high_reg,
reg_dummy, reg_dummy, reg_info_dummy);
}
- /* Note fall through. */
+ /* Note fall through. */
+ unconditional_jump:
+#ifdef _LIBC
+ DEBUG_PRINT2 ("\n%p: ", p);
+#else
+ DEBUG_PRINT2 ("\n0x%x: ", p);
+#endif
+ /* Note fall through. */
/* Unconditionally jump (without popping any failure points). */
case jump:
- unconditional_jump:
EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */
DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt);
p += mcnt; /* Do the jump. */
+#ifdef _LIBC
+ DEBUG_PRINT2 ("(to %p).\n", p);
+#else
DEBUG_PRINT2 ("(to 0x%x).\n", p);
+#endif
break;
@@ -4762,11 +4849,19 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
mcnt--;
p += 2;
STORE_NUMBER_AND_INCR (p, mcnt);
- DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p, mcnt);
+#ifdef _LIBC
+ DEBUG_PRINT3 (" Setting %p to %d.\n", p - 2, mcnt);
+#else
+ DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p - 2, mcnt);
+#endif
}
else if (mcnt == 0)
{
+#ifdef _LIBC
+ DEBUG_PRINT2 (" Setting two bytes from %p to no_op.\n", p+2);
+#else
DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2);
+#endif
p[2] = (unsigned char) no_op;
p[3] = (unsigned char) no_op;
goto on_failure;
@@ -4782,6 +4877,11 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
{
mcnt--;
STORE_NUMBER (p + 2, mcnt);
+#ifdef _LIBC
+ DEBUG_PRINT3 (" Setting %p to %d.\n", p + 2, mcnt);
+#else
+ DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p + 2, mcnt);
+#endif
goto unconditional_jump;
}
/* If don't have to jump any more, skip over the rest of command. */
@@ -4796,7 +4896,11 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
EXTRACT_NUMBER_AND_INCR (mcnt, p);
p1 = p + mcnt;
EXTRACT_NUMBER_AND_INCR (mcnt, p);
+#ifdef _LIBC
+ DEBUG_PRINT3 (" Setting %p to %d.\n", p1, mcnt);
+#else
DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt);
+#endif
STORE_NUMBER (p1, mcnt);
break;
}
@@ -5252,8 +5356,8 @@ bcmp_translate (s1, s2, len, translate)
register int len;
RE_TRANSLATE_TYPE translate;
{
- register const unsigned char *p1 = (const unsigned char *) s1,
- *p2 = (const unsigned char *) s2;
+ register const unsigned char *p1 = (const unsigned char *) s1;
+ register const unsigned char *p2 = (const unsigned char *) s2;
while (len)
{
if (translate[*p1++] != translate[*p2++]) return 1;
@@ -5366,6 +5470,7 @@ re_exec (s)
return
0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0);
}
+
#endif /* _REGEX_RE_COMP */
/* POSIX.2 functions. Don't define these for Emacs. */
@@ -5560,7 +5665,8 @@ regerror (errcode, preg, errbuf, errbuf_size)
size_t msg_size;
if (errcode < 0
- || errcode >= (sizeof (re_error_msgid) / sizeof (re_error_msgid[0])))
+ || errcode >= (int) (sizeof (re_error_msgid)
+ / sizeof (re_error_msgid[0])))
/* Only error codes returned by the rest of the code should be passed
to this routine. If we are given anything else, or if other regex
code generates an invalid error code, then the program has a bug.
diff --git a/regex.h b/regex.h
index 666c7b3a..5140052c 100644
--- a/regex.h
+++ b/regex.h
@@ -1,7 +1,6 @@
/* Definitions for data structures and routines for the regular
expression library, version 0.12.
-
- Copyright (C) 1985, 89, 90, 91, 92, 93, 95, 96 Free Software Foundation, Inc.
+ Copyright (C) 1985,89,90,91,92,93,95,96,97 Free Software Foundation, Inc.
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
@@ -14,13 +13,17 @@
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. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef __REGEXP_LIBRARY_H__
#define __REGEXP_LIBRARY_H__
+/* Allow the use in C++ code. */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* POSIX says that <sys/types.h> must be included (by the caller) before
<regex.h>. */
@@ -30,27 +33,26 @@
#include <stddef.h>
#endif
-
/* The following two types have to be signed and unsigned integer type
wide enough to hold a value of a pointer. For most ANSI compilers
ptrdiff_t and size_t should be likely OK. Still size of these two
types is 2 for Microsoft C. Ugh... */
-typedef long s_reg_t;
-typedef unsigned long active_reg_t;
+typedef long int s_reg_t;
+typedef unsigned long int active_reg_t;
/* The following bits are used to determine the regexp syntax we
recognize. The set/not-set meanings are chosen so that Emacs syntax
remains the value 0. The bits are given in alphabetical order, and
the definitions shifted by one from the previous bit; thus, when we
add or remove a bit, only one other definition need change. */
-typedef unsigned long reg_syntax_t;
+typedef unsigned long int reg_syntax_t;
/* If this bit is not set, then \ inside a bracket expression is literal.
If set, then such a \ quotes the following character. */
-#define RE_BACKSLASH_ESCAPE_IN_LISTS (1L)
+#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
/* If this bit is not set, then + and ? are operators, and \+ and \? are
- literals.
+ literals.
If set, then \+ and \? are operators and + and ? are literals. */
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
@@ -66,7 +68,7 @@ typedef unsigned long reg_syntax_t;
^ is an anchor if it is at the beginning of a regular
expression or after an open-group or an alternation operator;
$ is an anchor if it is at the end of a regular expression, or
- before a close-group or an alternation operator.
+ before a close-group or an alternation operator.
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
POSIX draft 11.2 says that * etc. in leading positions is undefined.
@@ -77,7 +79,7 @@ typedef unsigned long reg_syntax_t;
/* If this bit is set, then special characters are always special
regardless of where they are in the pattern.
If this bit is not set, then special characters are special only in
- some contexts; otherwise they are ordinary. Specifically,
+ some contexts; otherwise they are ordinary. Specifically,
* + ? and intervals are only special when not after the beginning,
open-group, or alternation operator. */
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
@@ -99,7 +101,7 @@ typedef unsigned long reg_syntax_t;
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
/* If this bit is set, either \{...\} or {...} defines an
- interval, depending on RE_NO_BK_BRACES.
+ interval, depending on RE_NO_BK_BRACES.
If not set, \{, \}, {, and } are literals. */
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
@@ -124,7 +126,7 @@ typedef unsigned long reg_syntax_t;
If not set, then \<digit> is a back-reference. */
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
-/* If this bit is set, then | is an alternation operator, and \| is literal.
+/* If this bit is set, then | is an alternation operator, and \| is literal.
If not set, then \| is an alternation operator, and | is literal. */
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
@@ -138,13 +140,13 @@ typedef unsigned long reg_syntax_t;
If not set, then an unmatched ) is invalid. */
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
-/* If this bit is set, do not process the GNU regex operators.
- IF not set, then the GNU regex operators are recognized. */
-#define RE_NO_GNU_OPS (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
-
/* If this bit is set, succeed as soon as we match the whole pattern,
without further backtracking. */
-#define RE_NO_POSIX_BACKTRACKING (RE_NO_GNU_OPS << 1)
+#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
+
+/* If this bit is set, do not process the GNU regex operators.
+ If not set, then the GNU regex operators are recognized. */
+#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
/* If this bit is set, turn on internal regex debugging.
If not set, and debugging was on, turn it off.
@@ -152,7 +154,7 @@ typedef unsigned long reg_syntax_t;
We define this bit always, so that all that's needed to turn on
debugging is to recompile regex.c; the calling code can always have
this bit set, and it won't affect anything in the normal case. */
-#define RE_DEBUG (RE_NO_POSIX_BACKTRACKING << 1)
+#define RE_DEBUG (RE_NO_GNU_OPS << 1)
/* This global variable defines the particular regexp syntax to use (for
some interfaces). When a regexp is compiled, the syntax used is
@@ -162,20 +164,20 @@ extern reg_syntax_t re_syntax_options;
/* Define combinations of the above bits for the standard possibilities.
(The [[[ comments delimit what gets put into the Texinfo file, so
- don't delete them!) */
+ don't delete them!) */
/* [[[begin syntaxes]]] */
#define RE_SYNTAX_EMACS 0
#define RE_SYNTAX_AWK \
- (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
- | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
+ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
+ | RE_NO_BK_PARENS | RE_NO_BK_REFS \
+ | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
+ | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
| RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
-#define RE_SYNTAX_GNU_AWK \
- ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
- & ~(RE_DOT_NOT_NULL|RE_INTERVALS|RE_CONTEXT_INDEP_OPS))
+#define RE_SYNTAX_GNU_AWK \
+ ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
+ & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
#define RE_SYNTAX_POSIX_AWK \
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
@@ -235,8 +237,8 @@ extern reg_syntax_t re_syntax_options;
#ifdef RE_DUP_MAX
#undef RE_DUP_MAX
#endif
-/* if sizeof(int) == 2, then ((1 << 15) - 1) overflows */
-#define RE_DUP_MAX (0x7fff)
+/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
+#define RE_DUP_MAX (0x7fff)
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
@@ -248,7 +250,7 @@ extern reg_syntax_t re_syntax_options;
/* If this bit is set, then ignore case when matching.
If not set, then case is significant. */
#define REG_ICASE (REG_EXTENDED << 1)
-
+
/* If this bit is set, then anchors do not match at newline
characters in the string.
If not set, then anchors do match at newlines. */
@@ -287,7 +289,7 @@ typedef enum
REG_EESCAPE, /* Trailing backslash. */
REG_ESUBREG, /* Invalid back reference. */
REG_EBRACK, /* Unmatched left bracket. */
- REG_EPAREN, /* Parenthesis imbalance. */
+ REG_EPAREN, /* Parenthesis imbalance. */
REG_EBRACE, /* Unmatched \{. */
REG_BADBR, /* Invalid contents of \{\}. */
REG_ERANGE, /* Invalid range end. */
@@ -306,7 +308,7 @@ typedef enum
compiled, the `re_nsub' field is available. All other fields are
private to the regex routines. */
-#ifndef RE_TRANSLATE_TYPE
+#ifndef RE_TRANSLATE_TYPE
#define RE_TRANSLATE_TYPE char *
#endif
@@ -319,10 +321,10 @@ struct re_pattern_buffer
unsigned char *buffer;
/* Number of bytes to which `buffer' points. */
- unsigned long allocated;
+ unsigned long int allocated;
/* Number of bytes actually used in `buffer'. */
- unsigned long used;
+ unsigned long int used;
/* Syntax setting with which the pattern was compiled. */
reg_syntax_t syntax;
@@ -366,7 +368,7 @@ struct re_pattern_buffer
unsigned no_sub : 1;
/* If set, a beginning-of-line anchor doesn't match at the
- beginning of the string. */
+ beginning of the string. */
unsigned not_bol : 1;
/* Similarly for an end-of-line anchor. */
@@ -473,7 +475,7 @@ extern int re_match
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
-extern int re_match_2
+extern int re_match_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
int start, struct re_registers *regs, int stop));
@@ -513,6 +515,11 @@ extern size_t regerror
size_t errbuf_size));
extern void regfree _RE_ARGS ((regex_t *preg));
+
+#ifdef __cplusplus
+}
+#endif /* C++ */
+
#endif /* not __REGEXP_LIBRARY_H__ */
/*
diff --git a/stamp-h.in b/stamp-h.in
index 1fee4d60..518d8dc5 100644
--- a/stamp-h.in
+++ b/stamp-h.in
@@ -1 +1 @@
-Wed Dec 18 10:27:30 EST 1996
+Tue May 13 20:58:45 EDT 1997
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}/, "\\&agrave;", s)
+ gsub(/{\\'a}/, "\\&aacute;", s)
+ gsub(/{\\[\^]a}/,"\\&acirc;", s)
+ gsub(/{\\~a}/, "\\&atilde;", s)
+ gsub(/{\\\"a}/, "\\&auml;", s)
+ gsub(/{\\aa}/, "\\&aring;", s)
+ gsub(/{\\ae}/, "\\&aelig;", s)
+
+ gsub(/{\\c{c}}/,"\\&ccedil;", s)
+
+ gsub(/{\\\e}/, "\\&egrave;", s)
+ gsub(/{\\'e}/, "\\&eacute;", s)
+ gsub(/{\\[\^]e}/,"\\&ecirc;", s)
+ gsub(/{\\\"e}/, "\\&euml;", s)
+
+ gsub(/{\\\i}/, "\\&igrave;", s)
+ gsub(/{\\'i}/, "\\&iacute;", s)
+ gsub(/{\\[\^]i}/,"\\&icirc;", s)
+ gsub(/{\\\"i}/, "\\&iuml;", s)
+
+ # ignore eth and thorn
+
+ gsub(/{\\~n}/, "\\&ntilde;", s)
+
+ gsub(/{\\\o}/, "\\&ograve;", s)
+ gsub(/{\\'o}/, "\\&oacute;", s)
+ gsub(/{\\[\^]o}/, "\\&ocirc;", s)
+ gsub(/{\\~o}/, "\\&otilde;", s)
+ gsub(/{\\\"o}/, "\\&ouml;", s)
+ gsub(/{\\o}/, "\\&oslash;", s)
+
+ gsub(/{\\\u}/, "\\&ugrave;", s)
+ gsub(/{\\'u}/, "\\&uacute;", s)
+ gsub(/{\\[\^]u}/,"\\&ucirc;", s)
+ gsub(/{\\\"u}/, "\\&uuml;", s)
+
+ gsub(/{\\'y}/, "\\&yacute;", s)
+ gsub(/{\\\"y}/, "\\&yuml;", s)
+
+ # Now do the same for upper-case accents
+
+ gsub(/{\\\A}/, "\\&Agrave;", s)
+ gsub(/{\\'A}/, "\\&Aacute;", s)
+ gsub(/{\\[\^]A}/, "\\&Acirc;", s)
+ gsub(/{\\~A}/, "\\&Atilde;", s)
+ gsub(/{\\\"A}/, "\\&Auml;", s)
+ gsub(/{\\AA}/, "\\&Aring;", s)
+ gsub(/{\\AE}/, "\\&AElig;", s)
+
+ gsub(/{\\c{C}}/,"\\&Ccedil;", s)
+
+ gsub(/{\\\e}/, "\\&Egrave;", s)
+ gsub(/{\\'E}/, "\\&Eacute;", s)
+ gsub(/{\\[\^]E}/, "\\&Ecirc;", s)
+ gsub(/{\\\"E}/, "\\&Euml;", s)
+
+ gsub(/{\\\I}/, "\\&Igrave;", s)
+ gsub(/{\\'I}/, "\\&Iacute;", s)
+ gsub(/{\\[\^]I}/, "\\&Icirc;", s)
+ gsub(/{\\\"I}/, "\\&Iuml;", s)
+
+ # ignore eth and thorn
+
+ gsub(/{\\~N}/, "\\&Ntilde;", s)
+
+ gsub(/{\\\O}/, "\\&Ograve;", s)
+ gsub(/{\\'O}/, "\\&Oacute;", s)
+ gsub(/{\\[\^]O}/, "\\&Ocirc;", s)
+ gsub(/{\\~O}/, "\\&Otilde;", s)
+ gsub(/{\\\"O}/, "\\&Ouml;", s)
+ gsub(/{\\O}/, "\\&Oslash;", s)
+
+ gsub(/{\\\U}/, "\\&Ugrave;", s)
+ gsub(/{\\'U}/, "\\&Uacute;", s)
+ gsub(/{\\[\^]U}/, "\\&Ucirc;", s)
+ gsub(/{\\\"U}/, "\\&Uuml;", s)
+
+ gsub(/{\\'Y}/, "\\&Yacute;", s)
+
+ gsub(/{\\ss}/, "\\&szlig;", s)
+
+ # Others not mentioned in Flynn's book
+ gsub(/{\\'\\i}/,"\\&iacute;", 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(/&/,"\\&amp;",s) # NB: this one MUST be first
+ gsub(/</,"\\&lt;",s)
+ gsub(/>/,"\\&gt;",s)
+ gsub(/\"/,"\\&quot;",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(/>/, "\\&gt;", s)
+ gsub(/</, "\\&lt;", s)
+ gsub(/"/, "\\&quot;", 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(/\\&/,"\\&amp;",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(/\\&/,"\\&amp;",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
+
diff --git a/vms/ChangeLog b/vms/ChangeLog
index d8992bb4..2d19a8d3 100644
--- a/vms/ChangeLog
+++ b/vms/ChangeLog
@@ -1,3 +1,70 @@
+Thu May 15 12:49:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * Release 3.0.3: Release tar file made.
+
+Mon May 12 18:39:30 1997 Pat Rankin <rankin@eql.caltech.edu>
+
+ * vmstest.com (delarprm, prdupval): new `basic' tests.
+ (nondec): new `gawk.extensions' test (commented out for now).
+ (reint): move from `basic' to `gawk.extensions'.
+
+Mon May 5 21:40:07 1997 Pat Rankin <rankin@eql.caltech.edu>
+
+ * vmstest.com (clobber): new `basic' test.
+ (pid): new test, replacing `specfile'.
+ (pipeio2): new for `unix-tests'; can't execute this one under VMS.
+
+Mon May 5 21:23:52 1997 Pat Rankin <rankin@eql.caltech.edu>
+
+ * vms_args.c (vms_arg_fixup): for the 2>&1 case, don't set the
+ output filename to "sys$error" because that results in an extra
+ empty file being created.
+
+ * vms_misc.c (vms_open): explicitly specify stream_lf format
+ when creating files rather than letting DECC$SHR make a new file
+ inherit its record format from any earlier version of that file.
+
+ Suggested by Pete Cascio <pete@rmi.net>:
+
+ * vms_misc.c (vms_open): use full record sharing options when
+ reading any record-oriented file, regardless of its organization.
+
+Mon Apr 21 19:22:12 1997 Pat Rankin <rankin@eql.caltech.edu>
+
+ * vmstest.com (funstack): new `basic' test.
+ (reint): add missing entry to `basic'.
+ (pipeio1, specfile, strftlng): move from `basic' to `unix-tests'.
+ (childin): skip due to known failure.
+ (specfile): skip due to potentially confusing feedback.
+
+Thu Apr 24 23:18:04 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * vms_popen.c, vms_misc.c, vms_gawk.c, vms_fwrite.c,
+ vms_args.c: moved to generic GPL statement at top.
+
+Fri Apr 18 07:55:47 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
+
+ * BETA Release 3.0.34: Release tar file made.
+
+Wed Apr 2 18:17:30 1997 Pat Rankin <rankin@eql.caltech.edu>
+
+ * descrip.mms, vmsbuild.com (PATCHLVL): update to 3.
+
+ * vmstest.com (nlfldsep, splitvar, intest, nfldstr, nors,
+ fnarydel, noparms, pipeio1): new tests.
+
+Wed Jan 15 15:21:01 1997 Pat Rankin <rankin@eql.caltech.edu>
+
+ * redirect.h (stat, fstat): do not declare these functions;
+ rely on <stat.h> to do so. There are too many DEC C version
+ variants to handle otherwise.
+
+ From Martin Zinser <zinser@axp602.gsi.de>:
+
+ * descrip.mms (gawk.dvi): update to build in [.doc] directory
+ using texindex.c retained from an earlier gawk 2.x distribution.
+ (texindex.exe): don't assume VAX C.
+
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/vms/descrip.mms b/vms/descrip.mms
index f5de76f3..ec00eb9a 100644
--- a/vms/descrip.mms
+++ b/vms/descrip.mms
@@ -31,6 +31,7 @@
# If you have TeX, you can make the target 'gawk.dvi' to process
# _The_GAWK_Manual_ from gawk.texi. You'll need to use a device
# specific post-processor on gawk.dvi in order to get printable data.
+# The full output is approximately 325 pages.
#
# location of various source files, relative to the 'main' directory
@@ -128,7 +129,7 @@ DOCS= $(DOCDIR)gawk.1,$(DOCDIR)gawk.texi,$(DOCDIR)texinfo.tex
# Release of gawk
REL=3.0
-PATCHLVL=1
+PATCHLVL=3
# generic target
all : gawk
@@ -207,37 +208,46 @@ clean :
- delete *.obj;*,gawk.opt;*
spotless : clean tidy
- - delete gawk.dvi;*,gawk.exe;*,[.support]texindex.exe;*
+ - if f$search("gawk.exe").nes."" then delete gawk.exe;*
+ - if f$search("gawk.dvi").nes."" then delete gawk.dvi;*
+ - if f$search("[.doc]texindex.exe").nes."" then delete [.doc]texindex.exe;*
#
-# note: this is completely out of date
+# Note: this only works if you kept a copy of [.support]texindex.c
+# from a gawk 2.x distribution and put it into [.doc]texindex.c.
+# Also, depending on the fonts available with the version of TeX
+# you have, you might need to edit [.doc]texinfo.tex and change
+# the reference to "lcircle10" to be "circle10".
#
-# build gawk.dvi from within the 'support' subdirectory
+# build gawk.dvi from within the 'doc' subdirectory
#
-gawk.dvi : [.support]texindex.exe gawk.texi
- @ set default [.support]
+gawk.dvi : [.doc]texindex.exe [.doc]gawk.texi
+ @ set default [.doc]
@ write sys$output " Warnings from TeX are expected during the first pass"
- TeX [-]gawk.texi
+ TeX gawk.texi
mcr []texindex gawk.cp gawk.fn gawk.ky gawk.pg gawk.tp gawk.vr
@ write sys$output " Second pass"
- TeX [-]gawk.texi
+ TeX gawk.texi
mcr []texindex gawk.cp gawk.fn gawk.ky gawk.pg gawk.tp gawk.vr
@ write sys$output " Third (final) pass"
- TeX [-]gawk.texi
+ TeX gawk.texi
-@ purge
-@ delete gawk.lis;,.aux;,gawk.%%;,.cps;,.fns;,.kys;,.pgs;,.toc;,.tps;,.vrs;
@ rename/new_vers gawk.dvi [-]*.*
@ set default [-]
+# Note: [.doc]texindex.c is not included with the gawk 3.x distribution.
+# Expect lots of "implicitly declared function" diagnostics from DEC C.
#
-# note: besides being out of date, this assumes VAX C
-#
-
-[.support]texindex.exe : [.support]texindex.c
- @ set default [.support]
+[.doc]texindex.exe : [.doc]texindex.c
+ @ set default [.doc]
$(CC) /noOpt/noList/Define=("lines=tlines") texindex.c
- $(LINK) /noMap texindex.obj,sys$library:vaxcrtl.olb/Lib
- -@ delete texindex.obj;*
+ @ open/Write opt texindex.opt
+ @ write opt "texindex.obj"
+ @ write opt "$(LIBS)"
+ @ close opt
+ $(LINK) /noMap/Exe=texindex.exe texindex.opt/Options
+ -@ delete texindex.obj;*,texindex.opt;*
@ set default [-]
#eof
diff --git a/vms/gawk.hlp b/vms/gawk.hlp
index 97e0525c..9a3f2269 100644
--- a/vms/gawk.hlp
+++ b/vms/gawk.hlp
@@ -3,6 +3,7 @@
! revised, Jun'91
! revised, Jul'92
! revised, Jan'95
+! revised, Apr'97
! Online help for GAWK.
!
1 GAWK
@@ -47,8 +48,13 @@
and get the behavior of UN*X awk.
-W copyright [or -W copyleft] display an abbreviated version of
the GNU copyright information
+ -W help list command line options (same as -W usage)
-W lint warn about suspect or non-portable awk program code
+ -W lint-old warn about constructs not available in original awk
-W posix compatibility mode with additional restrictions
+ -W re-interval evaluate '{' and '}' as intervals in regular expressions
+ -W traditional suppress POSIX and GNU regular expression extensions
+ -W usage list command line options (same as -W help)
-W version display program version number
-- don't check further arguments for leading dash
3 program_text
@@ -111,6 +117,9 @@
are used as wildcards in filenames. '*' and '%' have their usual VMS
meanings of multiple character and single character wildcards,
respectively, and '?' is also treated as a single character wildcard.
+ Wildcard expansion only works for filenames specified in native VMS
+ filename syntax (eg, "[-.sibling]*"), not for ones specified pseudo-
+ Unix syntax (eg, "../sibling/*").
When a command line argument that should be a filename contains any
of the wildcard characters, a directory lookup is attempted for files
@@ -223,7 +232,7 @@
Print a brief version of GAWK's copyright notice.
/USAGE
- /USAGE (no corresponding GNU_syntax option)
+ /USAGE (comparable to -"W usage" or -"W help" option)
Print a compact summary of the command line options.
@@ -440,6 +449,15 @@
and/or a through e) digits; if more than two digits
follow, the result is undefined; not recognized if POSIX
compatibility mode is specified.
+
+ When a regular expression is represented in string form ("regex"
+ as opposed to /regex/), backslashes need to be paired. The first
+ one quotes the second during string processing, and the second one
+ remains to be used to quote whatever follows in regular expression
+ processing. For example, to match variable `xxx' against a period
+ character, use (xxx ~ "\\.") or (xxx ~ /\./); if you tried to use
+ (xxx ~ "\."), after string processing it would operate as (xxx ~ /./)
+ and end up matching any single character rather than just a period.
3 statements
A statement refers to a unit of instruction found in the action
part of an awk rule, and also found in the definition of a function.
@@ -577,8 +595,9 @@
4 other_statements
The delete statement is used to remove an element from an array.
The syntax is 'delete' keyword followed by array name, followed
- by index value enclosed in square brackets ([]). Starting with
- gawk version 2.15.4, 'delete' may also be used on an entire array.
+ by index value enclosed in square brackets ([]). 'delete' may
+ also used on an array name, without any index specified, to delete
+ all its elements in a single operation.
The return statement is used in user-defined functions. The syntax
is the keyword 'return' optionally followed by a string or numeric
@@ -640,9 +659,7 @@
the -F option (or /field_separator); the value can be a
regular expression
RS input record separator; default value is a newline ("\n");
- only a single character is allowed [no regular expressions
- or multi-character strings; expected to be remedied in a
- future release of gawk]
+ the value can be multiple characters or a regular expression
OFS output field separator; value to place between variables in
a 'print' statement; default is one space; can be arbitrary
string
@@ -651,8 +668,10 @@
string
OFMT default output format used for printing numbers; default
value is "%.6g"
- CONVFMT conversion format used for string-to-number conversions;
- default value is also "%.6g", like OFMT
+ CONVFMT conversion format used for number-to-string conversions;
+ default value is also "%.6g", like OFMT; not used when the
+ number has a value which may be represented internally as
+ an exact integer (typically within -2147483648 to 2147483647)
SUBSEP subscript separator for array indices; used when an array
subscript is specified as a comma separated list of values:
the comma is replaced by SUBSEP and the resulting index
@@ -662,7 +681,7 @@
(non-zero) matching ignores differences between upper and
lower case letters; affects the '~' and '!~' operators,
the 'index', 'match', 'split', 'sub', and 'gsub' functions,
- and the field splitting based on FS; default value is false (0);
+ and field splitting based on FS; default value is false (0);
has no effect if GAWK is in strict compatibility mode
FIELDWIDTHS space or tab separated list of width sizes; takes
precedence over FS when set, but is cleared if FS has a
@@ -676,6 +695,8 @@
input file is processed by the same program)
FNR current record number of the current input file; reset to 0
each time an input file is completed
+ RT record terminator, the input text which matched RS; not
+ available when the `-W traditional' option is used
RSTART starting position of substring matched by last invocation
of the 'match' function; set to 0 if a match fails and at
the start of each input record
@@ -687,7 +708,7 @@
implementation of GAWK provides values for ["USER"] (the
username), ["PATH"] (current default directory), ["HOME"]
(the user's login directory), and "[TERM]" (terminal type
- if available) [all info provided by VAXCRTL's environ]
+ if available) [all info provided by C RTL's environ]
ERRNO information about the cause of failure for 'getline' or
'close'; "0" if no such failure has occured.
ARGC number of elements in the ARGV array, counting [0] which is
@@ -723,8 +744,11 @@
or 0 otherwise. To remove an element from an array, use the 'delete'
statement
delete Array[Index]
- Note: there is no way to delete an ordinary variable or an entire
- array; 'delete' only works on a specific array element.
+ To remove all array elements at once, use
+ delete Array
+ Note: the latter is a gawk extension; also, there is no way to
+ delete an ordinary variable or an entire array; 'delete' only works
+ on array elements.
To process all elements of an array (in succession) when their
subscripts might be unknown, use the 'in' variant of the for-loop
@@ -800,6 +824,15 @@
gsub(r,t,s) similar to sub(), but gsub() replaces all nonoverlapping
substrings instead of just the first, and the return
value is the number of substitutions made
+ gensub(r,t,n,s) search string s ($0 if omitted) for regexp r and
+ replace the n'th occurrence with substring t; the
+ result is the new string and s (or $0) remains
+ unchanged; if n begins with letter "g" or "G" then
+ all matches are replaced instead of just the n'th;
+ if r has parenthesized subexpressions in it, t may
+ contain the special sequences \\0, \\1, through \\9
+ which expand into the value of the corresponding
+ subexpression; this function is a gawk extension
substr(s,p,l) extract a substring l characters long starting at
offset p in string s; l is optional, if omitted then
the remainder of the string (p thru end) is returned
@@ -879,6 +912,9 @@
close(s) close a file or pipe specified by the string s; the
string used should have the same value as the one
used in a getline or print/printf redirection
+ fflush(s) flush output stream s; if s is omitted, stdout is
+ flushed; if it is specified but its value is an
+ empty string, all output streams are flushed
system(s) pass string s to executed by the operating system;
the command string is executed in a subprocess
5 redirection
@@ -955,9 +991,15 @@
g 'fractional' number in either 'e' or 'f' format, whichever
produces shorter result
- Three optional modifiers can be placed between the initiating
+ Several optional modifiers can be placed between the initiating
percent sign and the format character (doesn't apply to %%).
- left justify (only matters when width specifier is present)
+ (space) for numeric specifiers, prefix nonnegative values with
+ a space and negative values with a minus sign
+ + for numeric specifiers, prefix nonnegative values with a plus
+ sign and negative values with a minus sign
+ # alternate form applicable to several of the format characters
+ (o, x, X, e, E, f, g, G)
NN width ['NN' represents 1 or more decimal digits]; actually
minimum width to use, longer items will not be truncated; a
leading 0 will cause right-justified numbers to be padded on
@@ -1002,7 +1044,9 @@
first character of the set is '^', then the sense of match
is reversed: [^0-9] matches any non-digit; several
characters need to be quoted with backslash (\) if they
- occur in a set: '\', ']', '-', and '^'
+ occur in a set: '\', ']', '-', and '^'; within sets,
+ various special character class designations are recognized,
+ such as [:digit:] and [:punct:], as per POSIX
| alternation (similar to boolean 'or'); match either of two
patterns [for example "^start|stop$" matches leading 'start'
or trailing 'stop']
@@ -1018,8 +1062,13 @@
? optional matching; indicates that the pattern can match zero or
one times ["[a-z][0-9]?" matches lower case letter alone or
followed by a single digit]
+ { } interval specification; {n} to match n times or {m,n} to match
+ at least m but not more than n times; only functional when
+ either the `-W posix' or `-W re-interval' options are used
\ quote; prevent the character which follows from having special
- meaning
+ meaning; if the regexp is specified as a string, then the
+ backslash itself will need to be quoted by preceding it with
+ another backslash
A regular expression which matches a string or line will match against
the first (left-most) substring which meets the pattern and include
@@ -1030,16 +1079,21 @@
explanation of what an awk program is doing and also who wrote it
and when.
3 further_information
- For complete documentation on GAWK, see "The_GAWK_Manual" from FSF.
- Source text for it is present in the file GAWK.TEXINFO. A postscript
+ For complete documentation on GAWK, see "Effective AWK Programming"
+ by Arnold Robbins. The second edition (ISBN 1-57831-000-8) is jointly
+ published by SSC and the FSF (http://www.ssc.com).
+
+ Source text for it is present in the file GAWK.TEXI. A postscript
version is available via anonymous FTP from host prep.ai.mit.edu in
- directory pub/gnu/.
+ directory pub/gnu/, file gawk-{version}-doc.tar.gz where {version}
+ would be the current version number, such as 3.0.3.
+
+ Another source of documentation is "The AWK Programming Language"
+ by Aho, Weinberger, and Kernighan (1988), published by Addison-Wesley.
+ ISBN code is 0-201-07981-X.
- For additional documentation on awk--above and beyond that provided in
- The_GAWK_Manual--see "The_AWK_Programming_Language" by Aho, Weinberger,
- and Kernighan (2nd edition, 1988), published by Addison-Wesley. It is
- both a reference on the awk language and a tutorial on awk's use, with
- many sample programs.
+ Each of these works contains both a reference on the awk language
+ and a tutorial on awk's use, with many sample programs.
3 authors
The awk programming language was originally created by Alfred V. Aho,
Peter J. Weinberger, and Brian W. Kernighan in 1977. The language
@@ -1049,17 +1103,17 @@
and Jay Fenlason, with advice from Richard Stallman, and with
contributions from John Woods. In 1988 and 1989, David Trueman and
Arnold Robbins revised GAWK for compatibility with the newer awk.
+ Arnold Robbins is the current maintainer.
GAWK version 2.11.1 was ported to VMS by Pat Rankin in November, 1989,
with further revisions in the Spring of 1990. The VMS port was
incorporated into the official GNU distribution of version 2.13 in
Spring 1991. (Version 2.12 was never publically released.)
2 release_notes
- GAWK 2.15.6 tested under VAX/VMS V5.5-2, January, 1995; should be
- compatible with VMS versions V4.6 and later. Current source code
- compatible with DEC's VAX C v3.x and v2.4, or DEC C v4.x; also
- compiles successfully with GNU C (GNU's gcc). VMS POSIX uses c89 and
- requires VAX C V3.x (DEC C might work too, but hasn't been confirmed).
+ GAWK 3.0.3 tested under VAX/VMS V6.2 and Alpha/VMS V6.2, April, 1997;
+ should be compatible with VMS versions V4.6 and later. Current source
+ code is compatible with DEC's DEC C v5.x or VAX C v3.2; also compiles
+ successfully with GNU C (tested with gcc-vms 2.7.1).
3 AWK_LIBRARY
GAWK uses a built in search path when looking for a program file
specified by the -f option (or the /input qualifier) when that file
@@ -1146,6 +1200,19 @@
failure. The final exit status will be 1 (VMS success) if 0 is
used, or even (VMS non-success) if non-zero is used.
3 changes
+ Changes between version 3.0.3 and 2.15.6
+
+ General
+ RS can contain multiple characters or be a regexp
+ Regular expression interval support added
+ gensub() and fflush() functions added
+ memory leak(s) introduced in 3.0.2 or 3.0.1 fixed
+ the user manual has been substantially revised
+
+ VMS-specific
+ Switched to build with DEC C by default
+
+3 prior_changes
Changes between version 2.15.6 and 2.14
General
@@ -1157,7 +1224,7 @@
`>+ file' binary-mode output redirection added
/variable=(foo=42) fixed
Floating point number formatting improved
-3 prior_changes
+
Changes between version 2.14 and 2.13.2:
General
diff --git a/vms/redirect.h b/vms/redirect.h
index 18659b5e..294dba7f 100644
--- a/vms/redirect.h
+++ b/vms/redirect.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 88, 89, 91-93, 1996 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 88, 89, 91-93, 1996, 1997 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -99,11 +99,6 @@ extern int close P((int));
extern int dup P((int));
extern int dup2 P((int, int));
extern int read P((int, void *, int));
-#if defined(__DECC) && !defined(__CAN_USE_EXTERN_PREFIX)
-struct stat;
-extern int fstat P((int, struct stat *));
-extern int stat P((const char *, struct stat *));
-#endif
extern int getpgrp P((void));
#endif /* not VMS_POSIX and not IN_CONFIG_H */
diff --git a/vms/vms_args.c b/vms/vms_args.c
index 5371dfb8..fbe50ff6 100644
--- a/vms/vms_args.c
+++ b/vms/vms_args.c
@@ -1,28 +1,21 @@
-/*
- * vms_args.c -- command line parsing, to emulate shell i/o redirection.
- * [ Escape sequence parsing now suppressed. ]
- */
+/* vms_args.c -- command line parsing, to emulate shell i/o redirection.
+ [ Escape sequence parsing now suppressed. ]
-/*
- * Copyright (C) 1991-1996 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
- */
+ Copyright (C) 1991-1996, 1997 the Free Software Foundation, Inc.
+
+ 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, 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. */
/*
* [.vms]vms_arg_fixup - emulate shell's command line processing: handle
@@ -206,7 +199,7 @@ vms_arg_fixup( int *pargc, char ***pargv )
fatal("conflicting specifications for stdout");
else {
out_to_err_redirect = 1;
- f_out = "SYS$ERROR:";
+ /* f_out = "SYS$ERROR:"; */
} break;
case '|': /* pipe */
/* command pipelines are not supported */
diff --git a/vms/vms_fwrite.c b/vms/vms_fwrite.c
index 8f0ebcab..496ef3dc 100644
--- a/vms/vms_fwrite.c
+++ b/vms/vms_fwrite.c
@@ -1,27 +1,20 @@
-/*
- * vms_fwrite.c - augmentation for the fwrite() function.
- */
+/* vms_fwrite.c - augmentation for the fwrite() function.
-/*
- * Copyright (C) 1991-1996 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
- */
+ Copyright (C) 1991-1996 the Free Software Foundation, Inc.
+
+ 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, 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. */
#include "awk.h" /* really "../awk.h" */
diff --git a/vms/vms_gawk.c b/vms/vms_gawk.c
index d98bb801..e021b375 100644
--- a/vms/vms_gawk.c
+++ b/vms/vms_gawk.c
@@ -1,27 +1,21 @@
-/*
- * vms_gawk.c -- parse GAWK command line using DCL syntax
- */
+/* vms_gawk.c -- parse GAWK command line using DCL syntax
-/*
- * Copyright (C) 1991-1993, 1996 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
- */
+ Copyright (C) 1991-1993, 1996 the Free Software Foundation, Inc.
+
+ 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, 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. */
+
/*
* vms_gawk.c - routines to parse the command line as a native DCL command
diff --git a/vms/vms_misc.c b/vms/vms_misc.c
index 8e12c154..1b1a2239 100644
--- a/vms/vms_misc.c
+++ b/vms/vms_misc.c
@@ -1,27 +1,20 @@
-/*
- * vms_misc.c -- sustitute code for missing/different run-time library routines.
- */
+/* vms_misc.c -- sustitute code for missing/different run-time library routines.
-/*
- * Copyright (C) 1991-1993, 1996 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
- */
+ Copyright (C) 1991-1993, 1996, 1997 the Free Software Foundation, Inc.
+
+ 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, 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. */
#define creat creat_dummy /* one of gcc-vms's headers has bad prototype */
#include "awk.h"
@@ -118,17 +111,19 @@ vms_open( const char *name, int mode, ... )
{
int result;
- if (mode == (O_WRONLY|O_CREAT|O_TRUNC))
- result = creat(name, 0, "shr=nil", "mbc=32");
- else {
+ if (mode == (O_WRONLY|O_CREAT|O_TRUNC)) {
+ /* explicitly force stream_lf record format to override DECC$SHR's
+ defaulting of RFM to earlier file version's when one is present */
+ result = creat(name, 0, "rfm=stmlf", "shr=nil", "mbc=32");
+ } else {
struct stat stb;
- const char *mbc, *shr = "shr=get";
+ const char *mbc, *shr = "shr=get", *ctx = "ctx=stm";
if (stat((char *)name, &stb) < 0) { /* assume DECnet */
mbc = "mbc=8";
} else { /* ordinary file; allow full sharing iff record format */
mbc = "mbc=32";
- if (stb.st_fab_rfm < FAB$C_STM) shr = "shr=get,put,upd";
+ if ((stb.st_fab_rfm & 0x0F) < FAB$C_STM) shr = "shr=get,put,upd";
}
result = open(name, mode, 0, shr, mbc, "mbf=2");
}
diff --git a/vms/vms_popen.c b/vms/vms_popen.c
index e5829442..cfc5ecfc 100644
--- a/vms/vms_popen.c
+++ b/vms/vms_popen.c
@@ -1,27 +1,20 @@
-/*
- * [.vms]vms_popen.c -- substitute routines for missing pipe calls.
- */
-
-/*
- * Copyright (C) 1991-1993, 1996 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
- */
+/* [.vms]vms_popen.c -- substitute routines for missing pipe calls.
+
+ Copyright (C) 1991-1993, 1996 the Free Software Foundation, Inc.
+
+ 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, 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. */
#ifndef NO_VMS_PIPES
diff --git a/vms/vmsbuild.com b/vms/vmsbuild.com
index 04a54792..477bf4d2 100644
--- a/vms/vmsbuild.com
+++ b/vms/vmsbuild.com
@@ -7,7 +7,7 @@ $! gawk 3.0 revised, Dec'95
$! gawk 3.0.1 revised, Nov'96
$!
$ REL = "3.0" !release version number
-$ PATCHLVL = "1"
+$ PATCHLVL = "3"
$!
$!
$ CCFLAGS = "/noList" ! "/noOpt/Debug"
diff --git a/vms/vmstest.com b/vms/vmstest.com
index 59a3cd67..d6e652d4 100644
--- a/vms/vmstest.com
+++ b/vms/vmstest.com
@@ -31,7 +31,7 @@ $ if bigtest_test.nes." " then gosub 'bigtest_test'
$ if bigtest_list.nes."" then goto bigtest_loop
$ return
$
-$basic: basic_list = "msg swaplns messages argarray longwrds" -
+$basic: basic_lst1 = "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" -
@@ -40,14 +40,21 @@ $basic: basic_list = "msg swaplns messages argarray longwrds" -
+ " prmreuse math fldchg fldchgnf reindops sprintfc" -
+ " backgsub tweakfld clsflnam mmap8k fnarray dynlj" -
+ " substr eofsplit prt1eval splitwht back89 tradanch"
+$ basic_lst2 = "nlfldsep splitvar intest nfldstr nors" -
+ + " fnarydel noparms funstack clobber delarprm prdupval"
$ echo "basic"
-$basic_loop: basic_test = f$element(0," ",basic_list)
-$ basic_list = basic_list - basic_test - " "
+$basic_loop1: basic_test = f$element(0," ",basic_lst1)
+$ basic_lst1 = basic_lst1 - basic_test - " "
$ if basic_test.nes." " then gosub 'basic_test'
-$ if basic_list.nes."" then goto basic_loop
+$ if basic_lst1.nes."" then goto basic_loop1
+$basic_loop2: basic_test = f$element(0," ",basic_lst2)
+$ basic_lst2 = basic_lst2 - basic_test - " "
+$ if basic_test.nes." " then gosub 'basic_test'
+$ if basic_lst2.nes."" then goto basic_loop2
$ return
$
-$unix_tests: unix_tst_list = "poundbang fflush getlnhd"
+$unix_tests: unix_tst_list = "poundbang fflush getlnhd pipeio1" -
+ + " pipeio2 strftlng pid"
$ echo "unix_tests"
$unix_tst_loop: unix_tst_test = f$element(0," ",unix_tst_list)
$ unix_tst_list = unix_tst_list - unix_tst_test - " "
@@ -56,7 +63,8 @@ $ if unix_tst_list.nes."" then goto unix_tst_loop
$ return
$
$gawk_ext: gawk_ext_list = "fieldwdth ignrcase posix manyfiles" -
- + " igncfs argtest badargs strftime gensub gnureops"
+ + " igncfs argtest badargs strftime gensub gnureops reint" -
+ + " nondec"
$ echo "gawk_ext (gawk.extensions)"
$gawk_ext_loop: gawk_ext_test = f$element(0," ",gawk_ext_list)
$ gawk_ext_list = gawk_ext_list - gawk_ext_test - " "
@@ -306,8 +314,12 @@ $ if $status then rm tmp.;
$ return
$
$nonl: echo "nonl"
-$ ! this one might fail, depending on how the distribution was unpacked,
-$ ! because the nonl.awk might actually end up with a final newline
+$ ! This one might fail, depending on which C run-time library is used.
+$ ! If VAXCRTL is used by the program that unpacks the distribution,
+$ ! then nonl.awk will actually end with a newline. Even when that's
+$ ! not the case, if gawk itself uses VAXCRTL, an absent newline will
+$ ! be fabricated by the library when gawk reads the file. DECC$SHR
+$ ! doesn't behave this way....
$ AWKPATH_srcdir
$ gawk --lint -f nonl.awk _NL: >tmp. 2>&1
$ cmp nonl.ok tmp.
@@ -401,7 +413,9 @@ $ cmp intprec.ok tmp.
$ if $status then rm tmp.;
$ return
$
-$! note: this `childin' test currently [gawk 3.0.1] fails for vms
+$childin: echo "childin: currently fails for the VMS port, so skipped"
+$ return
+$! note: this `childin' test currently [gawk 3.0.3] fails for vms
$childin: echo "childin"
$ echo "note: type ``hi<return><ctrl/Z>'",-
"' if testing appears to hang in `childin'"
@@ -573,12 +587,143 @@ $ cmp tradanch.ok tmp.
$ if $status then rm tmp.;
$ return
$
+$nlfldsep: echo "nlfldsep"
+$ gawk -f nlfldsep.awk nlfldsep.in >tmp.
+$ cmp nlfldsep.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$splitvar: echo "splitvar"
+$ gawk -f splitvar.awk splitvar.in >tmp.
+$ cmp splitvar.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$intest: echo "intest"
+$ gawk -f intest.awk >tmp.
+$ cmp intest.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$pid: echo "pid"
+$ if f$search("pid.ok").eqs."" then create pid.ok
+$ open/Write ftmp _pid.in
+$ write ftmp f$integer("%x" + f$getjpi("","PID"))
+$ write ftmp f$integer("%x" + f$getjpi("","OWNER"))
+$ close ftmp
+$ gawk -f pid.awk _pid.in >tmp.
+$ rm _pid.in;
+$ cmp pid.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$strftlng: echo "strftlng"
+$ define/User TZ "UTC" !useless
+$ gawk -f strftlng.awk >tmp.
+$ cmp strftlng.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$nfldstr: echo "nfldstr"
+$ if f$search("nfldstr.ok").eqs."" then create nfldstr.ok
+$ gawk "$1 == 0 { print ""bug"" }" >tmp.
+
+$ cmp nfldstr.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$nors: echo "nors"
+$!! there's no straightforward way to supply non-terminated input on the fly
+$!! @echo A B C D E | tr -d '\12' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@
+$!! so just read a line from sys$input instead
+$ gawk "{ print $NF }" - nors.in >tmp.
+A B C D E
+$ cmp nors.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$fnarydel: echo "fnarydel"
+$ gawk -f fnarydel.awk >tmp.
+$ cmp fnarydel.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$reint: echo "reint"
+$ gawk --re-interval -f reint.awk reint.in >tmp.
+$ cmp reint.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$noparms: echo "noparms"
+$ set noOn
+$ AWKPATH_srcdir
+$ gawk -f noparms.awk >tmp. 2>&1
+$ set On
+$ cmp noparms.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$pipeio1: echo "pipeio1"
+$ cat = "TYPE" !close enough, as long as we avoid .LIS default suffix
+$ define/User test1 []test1.
+$ define/User test2 []test2.
+$ gawk -f pipeio1.awk >tmp.
+$ rm test1.;,test2.;
+$ cmp pipeio1.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$pipeio2:
+$ echo "pipeio2: uses Unix-specific command so won't work on VMS"
+$ return
+$!!pipeio2: echo "pipeio2"
+$ cat = "gawk -- {print}"
+$ tr = "??" !unfortunately, no trivial substitution available...
+$ gawk -v "SRCDIR=." -f pipeio2.awk >tmp.
+$ cmp pipeio2.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$funstack: echo "funstack"
+$ gawk -f funstack.awk funstack.in >tmp.
+$ cmp funstack.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$clobber: echo "clobber"
+$ gawk -f clobber.awk >tmp.
+$ cmp clobber.ok seq.
+$ if $status then rm seq.;*
+$ cmp clobber.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$delarprm: echo "delarprm"
+$ gawk -f delarprm.awk >tmp.
+$ cmp delarprm.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$prdupval: echo "prdupval"
+$ gawk -f prdupval.awk prdupval.in >tmp.
+$ cmp prdupval.ok tmp.
+$ if $status then rm tmp.;
+$ return
+$
+$nondec: echo "nondec"
+$ ! gawk -f nondec.awk >tmp.
+$ ! cmp nondec.ok tmp.
+$ ! if $status then rm tmp.;
+$ return
$
$clean:
$ if f$search("tmp.") .nes."" then rm tmp.;*
$ if f$search("tmp.too") .nes."" then rm tmp.too;*
$ if f$search("out%.") .nes."" then rm out%.;*
$ if f$search("strftime.ok").nes."" then rm strftime.ok;*
+$ if f$search("test%.") .nes."" then rm test%.;*
+$ if f$search("seq.") .nes."" then rm seq.;*
+$ if f$search("_pid.in") .nes."" then rm _pid.in;*
$ if f$search("[.junk]*.*").nes."" then rm [.junk]*.*;*
$ if f$parse("[.junk]") .nes."" then rm []junk.dir;1
$ return