aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/ChangeLog144
-rw-r--r--doc/Makefile.am17
-rw-r--r--doc/Makefile.in67
-rw-r--r--doc/api.texi1013
-rw-r--r--doc/awkcard.in131
-rw-r--r--doc/gawk.1349
-rw-r--r--doc/gawk.info4950
-rw-r--r--doc/gawk.texi3772
-rw-r--r--doc/gawkinet.info72
-rw-r--r--doc/texinfo.tex36
10 files changed, 7016 insertions, 3535 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 00185def..e0f8c2f9 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,7 +1,12 @@
+2012-10-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (LN, install-data-hook, uninstall-hook): Removed. No
+ longer needed since dgawk and pgawk are gone.
+
2012-10-13 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am: Add dgawk.1 to man page links created / removed
- on install / uninstall.
+ on install / uninstall. (On stable branch.)
2012-10-02 Arnold D. Robbins <arnold@skeeve.com>
@@ -9,6 +14,10 @@
bug report from William Bresler <wbresler@acm.org>. Add a link
to the ISO website.
+ * gawk.texi, gawk.1, awkcard.in: Document FUNCTAB, SYMTAB, and
+ PROCINFO["identifiers"]. Including that delete does not work
+ on FUNCTAB and SYMTAB.
+
2012-09-23 Arnold D. Robbins <arnold@skeeve.com>
* gawk.texi (Nextfile Statement): Document that it's now part of POSIX
@@ -16,6 +25,95 @@
(Delete): Document that `delete array' is now part of POSIX.
* awkcard.in: Adjust coloring for nextfile and delete array.
+2012-09-07 Arnold D. Robbins <arnold@skeeve.com>
+
+ * texinfo.tex: Updated to version 2012-09-05.06.
+
+2012-08-27 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.texi: Minor edits, fix some spelling mistakes.
+
+2012-08-26 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.texi: More edits to chapter on arithmetic.
+ Primarily English changes.
+
+2012-08-24 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.texi: Emphasize more that floating point behavior is
+ not a language issue. Add a pointer to POSIX bc.
+ Move arithmetic chapter to later in the book, before chapter
+ on dynamic extensions.
+
+2012-08-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * texinfo.tex: Update infrastructure to Automake 1.12.3.
+
+2012-08-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.texi: Fixed a math bug in the chapter on multiple
+ precision floating point. Thanks to John Haque.
+
+2012-08-12 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.texi: Merged discussion of numbers from Appendix C into
+ the chapter on arbitrary precision arithmetic. Did some surgery
+ on that chapter to organize it a little better.
+
+2012-08-10 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkcard.in, gawk.1, gawk.texi: Updated. Mostly for new API stuff
+ but also some other things.
+ * gawk.texi (Derived Files): New node.
+
+2012-08-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (install-data-hook): Install a dgawk.1 link to the
+ man page also. Remove it on uninstall.
+
+2012-07-29 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * gawk.texi: Document that RT is set by getline.
+
+2012-07-04 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.texi, gawk.1, awkcard.in: Document that and(), or(), and
+ xor() can all take any number of arguments, with a minimum of two.
+
+2012-06-10 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * gawk.texi: Rename gettimeofday function to getlocaltime, since
+ the new time extension will provide gettimeofday.
+
+2012-05-24 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * gawk.texi, gawk.1: Replace references to dlload with dl_load.
+ But much more work needs to be done on the docs.
+
+2012-05-19 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * gawk.texi, gawk.1: Document new -i option, and describe new default
+ .awk suffix behavior.
+
+2012-04-01 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * gawk.texi: Replace documentation of removed functions update_ERRNO and
+ update_ERRNO_saved with descriptions new functions update_ERRNO_int,
+ update_ERRNO_string and unset_ERRNO. And fix a couple of examples
+ to use update_ERRNO_int instead of update_ERRNO.
+
+2012-03-26 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.texi: Minor style edits.
+
+2012-03-21 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * gawk.texi, gawk.1: Document new @load keyword.
+
+2012-03-20 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * gawk.texi, gawk.1: Add AWKLIBPATH.
+
2012-08-12 Arnold D. Robbins <arnold@skeeve.com>
* gawk.texi (Ranges and Locales): Clarified ranges and
@@ -54,6 +152,46 @@
* texinfo.tex: Update to latest from automake 1.11.4.
+2012-04-11 John Haque <j.eh@mchsi.com>
+
+ * gawk.texi: Change RNDMODE to ROUNDMODE.
+ * gawk.1, awkcard.in: Ditto.
+
+2012-04-11 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.texi: Change --arbitrary-precision to --bignum.
+ * gawk.1: Ditto.
+ * awkcard.in: Add --bignum, RNDMODE, PREC.
+
+2012-04-08 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.texi: Editing on new chapter on arbitrary precision numbers.
+
+2012-03-31 John Haque <j.eh@mchsi.com>
+
+ * gawk.texi, gawk.1: Add text on support for arbitrary precision
+ numbers.
+
+2012-02-06 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.texi, gawk.1: And some minor edits thereunto.
+
+2012-02-03 John Haque <j.eh@mchsi.com>
+
+ * gawk.texi, gawk.1: Add text on read timeout.
+
+2011-12-28 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkcard.in, gawk.1: Minor edits after merge of executables.
+
+2011-12-21 John Haque <j.eh@mchsi.com>
+
+ * gawk.texi: Updated sections on profiling and debugging
+ after merging the exes. Document new options --debug and
+ --load, and add a sub-section on loading extension library.
+ * gawk.1: Same.
+ * awkcard.in: Same.
+
2012-03-28 Arnold D. Robbins <arnold@skeeve.com>
* 4.0.1: Release tar ball made.
@@ -87,6 +225,10 @@
Jeroen Schot <schot@A-Eskwadraat.nl>.
* gawk.texi: Some minor fixes.
+2011-08-31 John Haque <j.eh@mchsi.com>
+
+ * gawk.texi: Updated gawk dynamic extension doc.
+
2011-07-28 Arnold D. Robbins <arnold@skeeve.com>
* gawk.texi (Gory Details): Restore text on historical behavior
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 7d683f2b..0e4c85af 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -61,23 +61,6 @@ AWKCARD = awkcard.ps
# to ensure that awkcard.tr is processed by tbl.
#AWKCARD = awkcard.nc
-# The following is patterned after the main Makefile.am. The point is to
-# make pgawk.1 a link to gawk.1 in the installed man directory.
-
-# We want hard links for install-data-hook, below
-LN= ln -f
-
-# Link gawk.1 to pgawk.1 and to dgawk.1
-install-data-hook:
- (cd $(DESTDIR)$(man1dir); \
- $(LN) gawk.1 pgawk.1 2>/dev/null ; \
- $(LN) gawk.1 dgawk.1 2>/dev/null ; \
- exit 0)
-
-# Undo the above when uninstalling
-uninstall-hook:
- cd $(DESTDIR)$(man1dir); rm -f pgawk.1 dgawk.1 ; exit 0
-
postscript: gawk.ps gawkinet.ps gawk.1.ps igawk.1.ps $(AWKCARD)
pdf: postscript gawk.pdf gawkinet.pdf awkcard.pdf gawk.1.pdf igawk.1.pdf
diff --git a/doc/Makefile.in b/doc/Makefile.in
index d84cb7d9..6ec65cc9 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -83,11 +83,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/arch.m4 \
$(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lcmessage.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libsigsegv.m4 \
- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/nls.m4 \
- $(top_srcdir)/m4/noreturn.m4 $(top_srcdir)/m4/po.m4 \
- $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/readline.m4 \
- $(top_srcdir)/m4/socket.m4 $(top_srcdir)/m4/ulonglong.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/mpfr.m4 \
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/noreturn.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/m4/readline.m4 $(top_srcdir)/m4/socket.m4 \
+ $(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -164,6 +164,7 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
+GAWKLIBEXT = @GAWKLIBEXT@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
@@ -179,6 +180,7 @@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LDFLAGS = @LDFLAGS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
+LIBMPFR = @LIBMPFR@
LIBOBJS = @LIBOBJS@
LIBREADLINE = @LIBREADLINE@
LIBS = @LIBS@
@@ -220,6 +222,7 @@ abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
+acl_shlibext = @acl_shlibext@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -254,12 +257,14 @@ mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
+pkgextensiondir = @pkgextensiondir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
+subdirs = @subdirs@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
@@ -291,18 +296,6 @@ CARDFILES = $(CARDSRC) ad.block awkcard.in setter.outline
# Use this if your troff can correctly handle macros from 'colors' file
AWKCARD = awkcard.ps
-
-# Uncomment the following definition of AWKCARD if your troff can produce
-# Postscript but still has troubles with macros from 'colors'. As this
-# is not groff you will have to change TROFF macro as well. Do not forget
-# to ensure that awkcard.tr is processed by tbl.
-#AWKCARD = awkcard.nc
-
-# The following is patterned after the main Makefile.am. The point is to
-# make pgawk.1 a link to gawk.1 in the installed man directory.
-
-# We want hard links for install-data-hook, below
-LN = ln -f
all: all-am
.SUFFIXES:
@@ -648,8 +641,7 @@ info: info-am
info-am: $(INFO_DEPS)
install-data-am: install-info-am install-man
- @$(NORMAL_INSTALL)
- $(MAKE) $(AM_MAKEFLAGS) install-data-hook
+
install-dvi: install-dvi-am
install-dvi-am: $(DVIS)
@@ -784,38 +776,31 @@ ps-am: $(PSS)
uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \
uninstall-man uninstall-pdf-am uninstall-ps-am
- @$(NORMAL_INSTALL)
- $(MAKE) $(AM_MAKEFLAGS) uninstall-hook
+
uninstall-man: uninstall-man1
-.MAKE: install-am install-data-am install-strip uninstall-am
+.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-aminfo clean-generic \
dist-info distclean distclean-generic distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
- install-data-am install-data-hook install-dvi install-dvi-am \
- install-exec install-exec-am install-html install-html-am \
- install-info install-info-am install-man install-man1 \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-aminfo \
- maintainer-clean-generic mostlyclean mostlyclean-aminfo \
- mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \
- uninstall-dvi-am uninstall-hook uninstall-html-am \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-man1 install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-aminfo maintainer-clean-generic mostlyclean \
+ mostlyclean-aminfo mostlyclean-generic pdf pdf-am ps ps-am \
+ uninstall uninstall-am uninstall-dvi-am uninstall-html-am \
uninstall-info-am uninstall-man uninstall-man1 \
uninstall-pdf-am uninstall-ps-am
-# Link gawk.1 to pgawk.1 and to dgawk.1
-install-data-hook:
- (cd $(DESTDIR)$(man1dir); \
- $(LN) gawk.1 pgawk.1 2>/dev/null ; \
- $(LN) gawk.1 dgawk.1 2>/dev/null ; \
- exit 0)
-
-# Undo the above when uninstalling
-uninstall-hook:
- cd $(DESTDIR)$(man1dir); rm -f pgawk.1 dgawk.1 ; exit 0
+# Uncomment the following definition of AWKCARD if your troff can produce
+# Postscript but still has troubles with macros from 'colors'. As this
+# is not groff you will have to change TROFF macro as well. Do not forget
+# to ensure that awkcard.tr is processed by tbl.
+#AWKCARD = awkcard.nc
postscript: gawk.ps gawkinet.ps gawk.1.ps igawk.1.ps $(AWKCARD)
diff --git a/doc/api.texi b/doc/api.texi
new file mode 100644
index 00000000..2b8f186a
--- /dev/null
+++ b/doc/api.texi
@@ -0,0 +1,1013 @@
+\input texinfo @c -*-texinfo-*-
+@c %**start of header (This is for running Texinfo on a region.)
+@setfilename api.info
+@settitle Writing Extensions For Gawk
+@c %**end of header (This is for running Texinfo on a region.)
+
+@dircategory Text creation and manipulation
+@direntry
+* Gawk: (gawk). A text scanning and processing language.
+@end direntry
+@dircategory Individual utilities
+@direntry
+* awk: (gawk)Invoking gawk. Text scanning and processing.
+@end direntry
+
+@set xref-automatic-section-title
+
+@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 all the info about who's publishing this edition
+
+@c These apply across the board.
+@set UPDATE-MONTH August, 2012
+@set VERSION 4.1
+@set PATCHLEVEL 0
+
+@set FSF
+
+@set TITLE Writing Extensions for Gawk
+@set SUBTITLE A Temporary Manual
+@set EDITION 1
+
+@iftex
+@set DOCUMENT book
+@set CHAPTER chapter
+@set APPENDIX appendix
+@set SECTION section
+@set SUBSECTION subsection
+@set DARKCORNER @inmargin{@image{lflashlight,1cm}, @image{rflashlight,1cm}}
+@set COMMONEXT (c.e.)
+@end iftex
+@ifinfo
+@set DOCUMENT Info file
+@set CHAPTER major node
+@set APPENDIX major node
+@set SECTION minor node
+@set SUBSECTION node
+@set DARKCORNER (d.c.)
+@set COMMONEXT (c.e.)
+@end ifinfo
+@ifhtml
+@set DOCUMENT Web page
+@set CHAPTER chapter
+@set APPENDIX appendix
+@set SECTION section
+@set SUBSECTION subsection
+@set DARKCORNER (d.c.)
+@set COMMONEXT (c.e.)
+@end ifhtml
+@ifdocbook
+@set DOCUMENT book
+@set CHAPTER chapter
+@set APPENDIX appendix
+@set SECTION section
+@set SUBSECTION subsection
+@set DARKCORNER (d.c.)
+@set COMMONEXT (c.e.)
+@end ifdocbook
+@ifplaintext
+@set DOCUMENT book
+@set CHAPTER chapter
+@set APPENDIX appendix
+@set SECTION section
+@set SUBSECTION subsection
+@set DARKCORNER (d.c.)
+@set COMMONEXT (c.e.)
+@end ifplaintext
+
+@c some special symbols
+@iftex
+@set LEQ @math{@leq}
+@set PI @math{@pi}
+@end iftex
+@ifnottex
+@set LEQ <=
+@set PI @i{pi}
+@end ifnottex
+
+@ifnottex
+@macro ii{text}
+@i{\text\}
+@end macro
+@end ifnottex
+
+@c For HTML, spell out email addresses, to avoid problems with
+@c address harvesters for spammers.
+@ifhtml
+@macro EMAIL{real,spelled}
+``\spelled\''
+@end macro
+@end ifhtml
+@ifnothtml
+@macro EMAIL{real,spelled}
+@email{\real\}
+@end macro
+@end ifnothtml
+
+@set FN file name
+@set FFN File Name
+@set DF data file
+@set DDF Data File
+@set PVERSION version
+@set CTL Ctrl
+
+@ignore
+Some comments on the layout for TeX.
+1. Use at least texinfo.tex 2000-09-06.09
+2. I have done A LOT of work to make this look good. There are `@page' commands
+ and use of `@group ... @end group' in a number of places. If you muck
+ with anything, it's your responsibility not to break the layout.
+@end ignore
+
+@c merge the function and variable indexes into the concept index
+@ifinfo
+@synindex fn cp
+@synindex vr cp
+@end ifinfo
+@iftex
+@syncodeindex fn cp
+@syncodeindex vr cp
+@end iftex
+@ifxml
+@syncodeindex fn cp
+@syncodeindex vr cp
+@end ifxml
+
+@c If "finalout" is commented out, the printed output will show
+@c black boxes that mark lines that are too long. Thus, it is
+@c unwise to comment it out when running a master in case there are
+@c overfulls which are deemed okay.
+
+@iftex
+@finalout
+@end iftex
+
+@copying
+Copyright @copyright{} 2012
+Free Software Foundation, Inc.
+@sp 2
+
+This is Edition @value{EDITION} of @cite{@value{TITLE}: @value{SUBTITLE}},
+for the @value{VERSION}.@value{PATCHLEVEL} (or later) version of the GNU
+implementation of AWK.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.3 or
+any later version published by the Free Software Foundation; with the
+Invariant Sections being ``GNU General Public License'', the Front-Cover
+texts being (a) (see below), and with the Back-Cover Texts being (b)
+(see below). A copy of the license is included in the section entitled
+``GNU Free Documentation License''.
+
+@enumerate a
+@item
+``A GNU Manual''
+
+@item
+``You have the freedom to
+copy and modify this GNU manual. Buying copies from the FSF
+supports it in developing GNU and promoting software freedom.''
+@end enumerate
+@end copying
+
+@c Comment out the "smallbook" for technical review. Saves
+@c considerable paper. Remember to turn it back on *before*
+@c starting the page-breaking work.
+
+@c 4/2002: Karl Berry recommends commenting out this and the
+@c `@setchapternewpage odd', and letting users use `texi2dvi -t'
+@c if they want to waste paper.
+@c @smallbook
+
+
+@c Uncomment this for the release. Leaving it off saves paper
+@c during editing and review.
+@setchapternewpage odd
+
+@titlepage
+@title @value{TITLE}
+@subtitle @value{SUBTITLE}
+@subtitle Edition @value{EDITION}
+@subtitle @value{UPDATE-MONTH}
+@author Arnold D. Robbins
+@author Efraim Yawitz
+
+@c Include the Distribution inside the titlepage environment so
+@c that headings are turned off. Headings on and off do not work.
+
+@page
+@vskip 0pt plus 1filll
+``To boldly go where no man has gone before'' is a
+Registered Trademark of Paramount Pictures Corporation. @*
+@c sorry, i couldn't resist
+@sp 3
+Published by:
+@sp 1
+
+Free Software Foundation @*
+51 Franklin Street, Fifth Floor @*
+Boston, MA 02110-1301 USA @*
+Phone: +1-617-542-5942 @*
+Fax: +1-617-542-2652 @*
+Email: @email{gnu@@gnu.org} @*
+URL: @uref{http://www.gnu.org/} @*
+
+@c This one is correct for gawk 3.1.0 from the FSF
+ISBN 1-882114-28-0 @*
+@sp 2
+@insertcopying
+@end titlepage
+
+@node Extension API
+@chapter Writing Extensions for @command{gawk}
+
+This @value{CHAPTER} describes how to extend @command{gawk} using
+code written in C or C++. If you don't know anything about C
+programming, you can safely skip this @value{CHAPTER}, although you
+may wish to review the documentation on the extensions that come
+with @command{gawk} (@pxref{Extension Samples}).
+
+@node Extension Intro
+@section Introduction
+
+An @dfn{extension} (sometimes called a @dfn{plug-in}) is a piece of external code
+that @command{gawk} can load at run-time to provide additional
+functionality, over and above the built-in capabilities described in
+the rest of this @value{DOCUMENT}.
+
+Extensions are useful because they allow you (of course) to extend
+@command{gawk}'s functionality. For example, they can provide access to
+system calls (such as @code{chdir()} to change directory) and to other
+C library routines that could be of use. As with most software,
+``the sky is the limit;'' if you can imagine something that you might
+want to do and can write in C or C++, you can write an extension to do it!
+
+Extensions are written in C or C++, using the @dfn{Application Programming
+Interface} (API) defined for this purpose by the @command{gawk}
+developers. The rest of this @value{CHAPTER} explains the design
+decisions behind the API, the facilities it provides and how to use
+them, and presents a small sample extension. In addition, it documents
+the sample extensions included in the @command{gawk} distribution.
+
+@node Extension Design
+@section Extension API Design
+
+The first version of extensions for @command{gawk}
+was developed in the mid-1990s and released with @command{gawk} 3.1 in
+the late 1990s. The basic mechanisms and design remained unchanged for
+close to 15 years, until 2012.
+
+The old extension mechanism used data types and functions from
+@command{gawk} itself, with a ``clever hack'' to install extension
+functions.
+
+@command{gawk} included some sample extensions, of which a few were
+really useful. However, it was clear from the outset that the extension
+mechanism was bolted onto the side and was not really thought out.
+
+@node Old Extension Problems
+@subsection Problems With The Old Mechanism
+
+The old extension mechanism had several problems:
+
+@itemize @bullet
+@item
+It depended heavily upon @command{gawk} internals.
+Any time the @code{NODE} structure changed,
+an extension would have to be recompiled. Furthermore, to really
+write extensions required understanding something about @command{gawk}'s
+internal functions. There was some documentation in this @value{DOCUMENT},
+but it was quite minimal.
+
+@item
+Being able to call into @command{gawk} from an extension required linker
+facilities that are common on Unix-derived systems but that did
+not work on Windows systems; users wanting extensions on Windows
+had to statically link them into @command{gawk}, even though Windows supports
+dynamic loading of shared objects.
+
+@item
+The API would change occasionally as @command{gawk} changed; no compatibility
+between versions was ever offered or planned for.
+@end itemize
+
+Despite the drawbacks, the @command{xgawk} project developers forked
+@command{gawk} and developed several significant extensions. They also
+enhanced @command{gawk}'s facilities relating to file inclusion and
+shared object access.
+
+A new API was desired for a long time, but only in 2012 did the
+@command{gawk} maintainer and the @command{xgawk} developers finally
+start working on it together.
+More information about the @command{xgawk} project is provided
+in @ref{gawkextlib}.
+
+@node Extension New Mechansim Goals
+@subsection Goals For A New Mechansim
+
+Some goals for the new API were:
+
+@itemize @bullet
+@item
+The API should be independent of @command{gawk} internals. Changes in
+@command{gawk} internals should not be visible to the writer of an
+extension function.
+
+@item
+The API should provide @emph{binary} compatibility across @command{gawk}
+releases as long as the API itself does not change.
+
+@item
+The API should enable extensions written in C to have roughly the
+same ``appearance'' as @command{awk} functions, meaning:
+
+@itemize @minus
+@item
+The ability to access function parameters.
+
+@item
+The ability to turn an undefined parameter into an array (call by reference).
+
+@item
+The ability to create, access and update global variables.
+
+@item
+It should provide
+easy access to all the elements of an array at once (``array flattening'')
+in order to loop over all the element in an easy fashion for C code.
+@end itemize
+
+@item
+The ability to create arrays (including @command{gawk}'s true
+multi-dimensional arrays).
+
+@item
+The API should use only features in ISO C 90, so that extensions
+can be written using the widest range of C and C++ compilers. The header
+should include the appropriate @samp{#ifdef __cplusplus} and @samp{extern "C"}
+magic so that a C++ compiler could be used. (If using the C++, the runtime
+system has to be smart enough to call any constructors and destructors,
+as @command{gawk} is a C program.)
+
+@item
+The API mechanism should not require access to @command{gawk}'s
+symbols@footnote{The @dfn{symbols} are the variables and functions
+defined inside @command{gawk}. Access to these symbols by code
+external to @command{gawk} loaded dynamically at run-time is
+problematic on Windows.} by the compile-time or dynamic linker,
+in order to enable creation of extensions that will also work on Windows.
+@end itemize
+
+During development, it became clear that there were other features
+that should be available to extensions, which were also subsequently
+provided:
+
+@itemize @bullet
+@item
+Extensions should have the ability to hook into @command{gawk}'s
+I/O redirection mechanism. In particular, the @command{xgawk}
+developers provided a so-called ``open hook'' to take over reading
+records. During the development, this was generalized to allow
+extensions to hook into input processing, output processing, and
+two-way I/O.
+
+@item
+An extension should be able to provide a ``call back'' function
+to perform clean up actions when @command{gawk} exits.
+@end itemize
+
+strong{FIXME:} Review the header for other things to list here.
+
+@node Extension Other Design Decisions
+@subsection Other Design Decisions
+
+As an ``arbitrary'' design decision, extensions read the values of
+built-in variables and arrays (such as @code{ARGV}, @code{FS}), but cannot
+change them, with the exception of @code{PROCINFO}.
+
+The reason for this is to prevent an extension function from affecting
+the flow of an @command{awk} program outside its control. While a real
+@command{awk} function can do what it likes, that is at the discretion
+of the programmer. An extension function should provide a service or
+make a C API available for use within @command{awk}, and not mess with
+@code{FS} or @code{ARGC} and @code{ARGV}.
+
+In addition, it becomes easy to start down a slippery slope. How
+much access to @command{gawk} facilities do extensions need?
+Do they need @code{getline}? What about calling @code{gsub()} or
+compiling regular expressions? What about calling into @command{awk}
+functions? (@emph{That} would be messy.)
+
+In order to avoid these issues, the @command{gawk} developers chose
+to start with the simplest,
+most basic features that are still truly useful.
+
+Another decision is that
+although @command{gawk} provides nice things like MPFR, and arrays indexed
+internally by integers, we are not bringing these features
+out to the API in order to keep things simple and close to traditional
+@command{awk} semantics. (In fact, arrays indexed internally by integers
+are so transparent that they aren't even documented!)
+
+@node Extension Mechanism Outline
+@subsection At A High Level How It Works
+
+The requirement to avoid access to @command{gawk}'s symbols is, at
+first glance, a difficult one to meet.
+
+One design, apparently used by Perl
+and Ruby and maybe others, would be to make the mainline @command{gawk} code
+into a library, with the @command{gawk} program a small C @code{main()}
+function linked against the library.
+
+This seemed like the tail wagging the dog, complicating build and
+installation and making a simple copy of the @command{gawk} executable
+from one system to another (or one place to another on the same
+system!) into a chancy operation.
+
+Pat Rankin suggested the solution that was adopted. Communication between
+@command{gawk} and an extension is two way. First, when an extension
+is loaded, it is passed a pointer to a @code{struct} whose fields are
+function pointers.
+
+The extension can call functions inside @command{gawk} through these
+function pointers, at runtime, without needing (link time) access
+to @command{gawk}'s symbols. One of these function pointers is to a
+function for ``registering'' new built-in functions.
+
+In the other direction, the extension registers its new functions
+with @command{gawk} by passing function pointers to the functions that
+provide the new feature (@code{do_chdir()}, for example). @command{gawk}
+associates the function pointer with a name and can then call it, using
+a defined calling convention. The
+@code{do_@var{xxx}()} function, in turn, then uses the function pointers in
+the API @code{struct} to do its work.
+
+Convenience macros in the @file{gawkapi.h} header file make calling through
+the function pointers look like regular function calls so that extension
+code is quite readable and understandable.
+
+Although all of this sounds medium complicated, the result is that
+extension code is quite clean and straightforward. This can be seen in
+the sample extensions @file{filefuncs.c} and also the @file{testext.c}
+code for testing the APIs.
+
+Some other bits and pieces:
+
+@itemize @bullet
+@item
+The API provides access to @command{gawk}'s @code{do_@var{xxx}} values,
+reflecting command line options, like @code{do_lint}, @code{do_profiling}
+and so on (@pxref{Extension API Variables}).
+These are informational: an extension cannot affect these
+inside @command{gawk}. In addtion, attempting to assign to them
+produces a compile-time error.
+
+@item
+The API also provides major and minor version numbers, so that an
+extension can check if the @command{gawk} it is loaded with supports the
+facilties it was compiled with. (Version mismatches ``shouldn't''
+happen, but we all know how @emph{that} goes.)
+
+@item
+An extension may register a version string with @command{gawk}; this
+allows @command{gawk} to dump extension version information when
+invoked with the @option{--version} option.
+@end itemize
+
+@node Extension Future Grouth
+@subsection Room For Future Growth
+
+The API also provides room for future growth, in two ways.
+
+An ``extension id'' is passed into the extension when its loaded. This
+extension id is then passed back to @command{gawk} with each function
+call. This allows @command{gawk} to identify the extension calling it,
+should it need to know.
+
+A ``name space'' is passed into @command{gawk} when an extension
+is registered. This allows for some future mechanism for grouping
+extension functions and possibly avoiding name conflicts.
+
+Of course, as of this writing, no decisions have been made with respect
+to any of the above.
+
+@node Extension Versioning
+@subsection API Versioning
+
+The API provides both a ``major'' and a ``minor'' version number.
+The API versions are available at compile time as constants:
+
+@table @code
+@item GAWK_API_MAJOR_VERSION
+The major version of the API.
+
+@item GAWK_API_MINOR_VERSION
+The minor version of the API.
+@end table
+
+The minor version increases when new functions are added to the API. Such
+new functions are always added to the end of the API @code{struct}.
+
+The major version increases (and the minor version is reset to zero) if any
+of the data types change size or member order, or if any of the existing
+functions change signature.
+
+It could happen that
+an extension may be compiled against one version of the API but loaded
+by a version of @command{gawk} using a different version. For this
+reason, the major and minor API versions of the running @command{gawk}
+are included in the API @code{struct} as read-only constant integers:
+
+@table @code
+@item api->major_version
+The major version of the running @command{gawk}.
+
+@item api->minor_version
+The minor version of the running @command{gawk}.
+@end table
+
+It is up to the extension to decide if there are API incompatibilities.
+Typically a check like this is enough:
+
+@example
+if (api->major_version != GAWK_API_MAJOR_VERSION
+ || api->minor_version < GAWK_API_MINOR_VERSION) @{
+ fprintf(stderr, "foo_extension: version mismatch with gawk!\n");
+ fprintf(stderr, "\tmy version (%d, %d), gawk version (%d, %d)\n",
+ GAWK_API_MAJOR_VERSION, GAWK_API_MINOR_VERSION,
+ api->major_version, api->minor_version);
+ exit(1);
+@}
+@end example
+
+Such code is included in the boilerplate @code{dl_load_func} macro
+provided in @file{gawkapi.h}.
+
+@node Extension API Description
+@section API Description
+
+@c Efraim: Here is where you get to start working! :-)
+
+@c this is just a point that should be included in the discussion
+As the API has evolved, it has settled into a pattern where
+query routines return an @code{awk_bool_t}, with ``true'' meaning success and
+``false'' not, but a false return still fills in the actual type.
+
+@node Extension API Data Types
+@subsection Data Types
+
+@node Extension API Functions
+@subsection Functions
+
+Access to facilities within @command{gawk} are made available
+by calling through function pointers passed into your extension.
+
+API function pointers are provided for the following kinds of operations:
+
+@itemize @bullet
+@item
+Accessing parameters, including converting an undefined paramater into
+array
+
+@item
+Printing fatal, warning, and lint warning messages
+
+@item
+Registering input parsers, output wrappers, and two-way processors
+
+@item
+Updating @code{ERRNO}, or unsetting it
+
+@item
+Registering an extension function
+
+@item
+Registering exit handler functions to be called when @command{gawk} exits
+
+@item
+Accessing and creating global variables
+
+@item
+Symbol table access: retreiving a global variable, creating one, or changing one.
+This also includes the ability to create a scalar variable that will be @emph{constant}
+within @command{awk} code.
+
+@item
+Manipulating arrays
+@itemize @minus
+@item
+Retrieving, adding, deleting, and modifying elements
+@item
+Getting the count of elements in an array
+@item
+Creating a new array
+@item
+Clearing an array
+@item
+Flattening an array for easy C style looping over an array
+@end itemize
+
+@item
+Creating and releasing cached values; this provides an
+efficient way to use values for multiple variables and
+can be a big performance win.
+
+@item
+Registering an informational version string.
+@end itemize
+
+While you may call through these function pointers directly,
+the interface is not so pretty. To make extension code look
+more like regular code, the @file{gawkapi.h} header
+file defines a number of macros which you should use in your code.
+This section presents the macros as if they were functions.
+
+Points about using the API:
+
+@c @item
+
+All pointers filled in by @command{gawk} are to memory
+managed by @command{gawk} and should be treated by the extension as
+read-only. Memory for @emph{all} strings passed into @command{gawk}
+from the extension @emph{must} come from @code{malloc()} and is managed
+by @command{gawk} from then on.
+
+@c @item
+
+The API defines several simple structs that map values as seen
+from @command{awk}. A value can be a @code{double}, a string, or an
+array (as in multidimensional arrays, or when creating a new array).
+Strings maintain both pointer and length since embedded @code{NUL}
+characters are allowed.
+
+By intent, strings are maintained using the current multibyte encoding (as
+defined by @env{LC_@var{xxx}} environment variables) and not using wide
+characters. This matches how @command{gawk} stores strings internally
+and also how characters are likely to be input and output from files.
+
+
+@c @item
+
+When retrieving a value (such as a parameter or that of a global variable
+or array element), the extension requests a specific type (number, string,
+@c FIXME: expand to include scalars, value cookies
+array, or ``undefined''). When the request is undefined, the returned value
+will have the real underlying type.
+
+However, if the request and actual type don't match, the access function
+returns ``false'' and fills in the type of the actual value that is there,
+so that the extension can, e.g., print an error message
+(``scalar passed where array expected'').
+
+@c This is documented in the header file and needs some expanding upon.
+@c The table there should be presented here
+
+@node Input Parsers
+@subsubsection Customized Input Parsers
+
+By default, @command{gawk} reads text files as its input. It uses the value
+of @code{RS} to find the end of the record, and then uses @code{FS}
+(or @code{FIELDWIDTHS}) to split it into fields. Additionally, it sets
+the value of @code{RT}. (FIXME: pxrefs as needed.)
+
+If you want, you can provide your own, custom, input parser. An input
+parser's job is to return a record to the @command{gawk} record processing
+code, along with indicators for the value and length of the data to be
+used for @code{RT}, if any.
+
+To provide an input parser, you must provide two functions
+(where @var{XXX} is a prefix name for your extension):
+
+@table @code
+@item int @var{XXX}_can_take_file(const IOBUF_PUBLIC *iobuf)
+This function examines the information available in @code{iobuf}
+(which we discuss shortly). Based on the information there, it
+decides if the input parser should be used for this file.
+If so, it should return true (non-zero). Otherwise, it should
+return false (zero).
+
+@item int @var{XXX}_take_control_of(IOBUF_PUBLIC *iobuf)
+When @command{gawk} decides to hand control of the file over to the
+input parser, it calls this function. This function in turn must fill
+in certain fields in the @code{IOBUF_PUBLIC} structure, and ensure
+that certain conditions are true. It should then return true. If an
+error of some kind occurs, it should not fill in any fields, and should
+return false; then @command{gawk} will not use the input parser.
+The details are presented shortly.
+@end table
+
+Your extension should package these functions inside an
+@code{awk_input_parser_t}, which looks like this (from @file{gawkapi.h}):
+
+@example
+typedef struct input_parser @{
+ const char *name; /* name of parser */
+ int (*can_take_file)(const IOBUF_PUBLIC *iobuf);
+ int (*take_control_of)(IOBUF_PUBLIC *iobuf);
+ struct input_parser *awk_const next; /* for use by gawk */
+@} awk_input_parser_t;
+@end example
+
+The steps are as follows:
+
+@enumerate
+@item
+Create a @code{static awk_input_parser_t} variable and initialize it
+appropriately.
+
+@item
+When your extension is loaded, register your input parser with
+@command{gawk} using the @code{register_input_parser()} API.
+@end enumerate
+
+An @code{IOBUF_PUBLIC} looks like this:
+
+@example
+typedef struct iobuf_public @{
+ const char *name; /* filename */
+ int fd; /* file descriptor */
+#define INVALID_HANDLE (-1)
+ void *opaque; /* private data for input parsers */
+ /*
+ * The get_record function is called to read the next record of data.
+ * It should return the length of the input record (or EOF), and
+ * it should set *out to point to the contents of $0. Note that
+ * gawk will make a copy of the record in *out, so the parser is
+ * responsible for managing its own memory buffer. If an error
+ * occurs, the function should return EOF and set *errcode
+ * to a non-zero value. In that case, if *errcode does not equal
+ * -1, gawk will automatically update the ERRNO variable based on
+ * the value of *errcode (e.g. setting *errcode = errno should do
+ * the right thing). It is guaranteed that errcode is a valid
+ * pointer, so there is no need to test for a NULL value. The
+ * caller sets *errcode to 0, so there is no need to set it unless
+ * an error occurs. The rt_start and rt_len arguments should be
+ * used to return RT to gawk. Gawk will make its own copy of RT,
+ * so the parser is responsible for managing this memory. If EOF is
+ * not returned, the parser must set *rt_len (and *rt_start if *rt_len
+ * is non-zero).
+ */
+ int (*get_record)(char **out, struct iobuf_public *, int *errcode,
+ char **rt_start, size_t *rt_len);
+ /*
+ * The close_func is called to allow the parser to free private data.
+ * Gawk itself will close the fd unless close_func sets it to -1.
+ */
+ void (*close_func)(struct iobuf_public *);
+
+ /* put last, for alignment. bleah */
+ struct stat sbuf; /* stat buf */
+@} IOBUF_PUBLIC;
+@end example
+
+The fields can be divided into two categories: those for use (initially,
+at least) by @code{@var{XXX}_can_take_file()}, and those for use by
+@code{@var{XXX}_take_control_of()}. The first group of fields and their uses
+are as follows:
+
+@table @code
+@item const char *name;
+The name of the file.
+
+@item int fd;
+A file descriptor for the file. If @command{gawk} was able to
+open the file, then it will @emph{not} be equal to
+@code{INVALID_HANDLE}. Otherwise, it will.
+
+@item struct stat sbuf;
+If file descriptor is valid, then @command{gawk} will have filled
+in this structure with a call to the @code{fstat()} system call.
+@end table
+
+The @code{@var{XXX}_can_take_file()} function should examine these
+fields and decide if the input parser should be used for the file.
+The decision can be made based upon @command{gawk} state (the value
+of a variable defined previously by the extension and set by
+@command{awk} code), the name of the
+file, whether or not the file descriptor is valid, the information
+in the @code{struct stat}, or any combination of the above.
+
+Once @code{@var{XXX}_can_take_file()} has returned true, and
+@command{gawk} has decided to use your input parser, it will call
+@code{@var{XXX}_take_control_of()}. That function then fills in at
+least the @code{get_record} field of the @code{IOBUF_PUBLIC}. It must
+also ensure that @code{fd} is not set to @code{INVALID_HANDLE}. All of
+the fields that may be filled by @code{@var{XXX}_take_control_of()}
+are as follows:
+
+@table @code
+@item void *opaque;
+This is used to hold any state information needed by the input parser
+for this file. It is ``opaque'' to @command{gawk}. The input parser
+is not required to use this pointer.
+
+@item int (*get_record)(char **out, struct iobuf_public *, int *errcode,
+@itemx char **rt_start, size_t *rt_len);
+This is a function pointer that should be set to point to the
+function that creates the input records.
+Said function is the core of the input parser. Its behavior is
+described below.
+
+@item void (*close_func)(struct iobuf_public *);
+This is a function pointer that should be set to point to the
+function that does the ``tear down.'' It should release any resources
+allocated by @code{@var{XXX}_take_control_of()}. It may also close
+the file. If it does so, it shold set the @code{fd} field to
+@code{INVALID_HANDLE}.
+
+Having a ``tear down'' function is optional. If your input parser does
+not need it, do not set this field. In that case, @command{gawk}
+will close the regular @code{close()} system call on the
+file descriptor, so it should be valid.
+@end table
+
+The @code{@var{XXX}_get_record()} function does the work of creating
+input records. The parameters are as follows:
+
+@table @code
+@item char **out
+This is a pointer to a @code{char *} variable which is set to point
+to the record. @command{gawk} will make its own copy of the data, so
+the extension must manage this storage.
+
+@item struct iobuf_public *iobuf
+This is the @code{IOBUF_PUBLIC} for the file. The fields should be
+used for reading data (@code{fd}) and for managing private state
+(@code{opaque}), if any.
+
+@item int *errcode
+If an error occurs, @code{*errcode} should be set to an appropriate
+code from @code{<errno.h>}.
+
+@item char **rt_start
+@itemx size_t *rt_len
+If the concept of a ``record terminator'' makes sense, then
+@code{*rt_start} should be set to point to the data to be used for
+@code{RT}, and @code{*rt_len} should be set to the length of the
+data. Otherwise, @code{*rt_len} should be set to zero.
+@end table
+
+The return value is the length of the buffer pointed to by
+@code{*out}, or @code{EOF} if end-of-file was reached or an
+error occurred.
+
+@command{gawk} ships with a sample extension (@pxref{Extension Sample
+Readdir}) that reads directories, returning records for each entry in
+the directory. You may wish to use that code as a guide for writing
+your own input parser.
+
+When writing an input parser, you should think about (and document)
+how it is expected to interact with @command{awk} code. You may want
+it to always be called, and take effect as appropriate (as the
+@code{readdir} extension does). Or you may want it to take effect
+based upon the value of an @code{awk} variable, as the XML extension
+from the @code{gawkextlib} project does (@pxref{gawkextlib}).
+In the latter case, code in a @code{BEGINFILE} section (FIXME: pxref)
+can look at @code{FILENAME} and @code{ERRNO} to decide whether or
+not to activate an input parser.
+
+@node Output Wrappers
+@subsubsection Customized Output Wrappers
+
+@node Two-way processors
+@subsubsection Customized Two-way Processors
+
+@node Extension API Variables
+@subsection External Variables
+
+The API provides access to several variables that describe
+whether the corresponding command-line options were enabled when
+@command{gawk} was invoked. The variables are:
+
+@table @code
+@item do_lint
+This variable will be true if the @option{--lint} option was passed
+(FIXME: pxref).
+
+@item do_traditional
+This variable will be true if the @option{--traditional} option was passed.
+
+@item do_profile
+This variable will be true if the @option{--profile} option was passed.
+
+@item do_sandbox
+This variable will be true if the @option{--sandbox} option was passed.
+
+@item do_debug
+This variable will be true if the @option{--debug} option was passed.
+
+@item do_mpfr
+This variable will be true if the @option{--bignum} option was passed.
+@end table
+
+The value of @code{do_lint} can change if @command{awk} code
+modifies the @code{LINT} built-in variable (FIXME: pxref).
+The others should not change during execution.
+
+@node Extension API Boilerplate
+@subsection Boilerplate Code
+
+@node Extension Example
+@section Example: Some File Functions
+
+@c It's enough to show chdir and stat, no need for fts
+
+@node Extension Samples
+@section Sample Extensions
+
+@node Extension Sample File Functions
+@subsection File Related Functions
+
+@c can pull doc from man pages in extension directory
+
+@node Extension Sample Fnmatch
+@subsection Interface To @code{fnmatch()}
+
+@node Extension Sample Fork
+@subsection Interface to @code{fork()}, @code{wait()} and @code{waitpid()}
+
+@node Extension Sample Ord
+@subsection Character and Numeric values: @code{ord()} and @code{chr()}
+
+@node Extension Sample Readdir
+@subsection Reading Directories
+
+@node Extension Sample Readfile
+@subsection Reading An Entire File
+
+@node Extension Sample Read write array
+@subsection Dumping and Restoring An Array
+
+@node Extension Sample API Tests
+@subsection API Tests
+
+@node Extension Sample Time
+@subsection Time Functions
+
+@cindex time
+@cindex sleep
+
+These functions can be used by either invoking @command{gawk}
+with a command-line argument of @option{-l time} or by
+inserting @code{@@load "time"} in your script.
+
+@table @code
+
+@cindex @code{gettimeofday} time extension function
+@item gettimeofday()
+This function returns the time that has elapsed since 1970-01-01 UTC
+as a floating point value. It should have sub-second precision, but
+the actual precision will vary based on the platform. If the time
+is unavailable on this platform, it returns @minus{}1 and sets @code{ERRNO}.
+If the standard C @code{gettimeofday()} system call is available on this platform,
+then it simply returns the value. Otherwise, if on Windows,
+it tries to use @code{GetSystemTimeAsFileTime()}.
+
+@cindex @code{sleep} time extension function
+@item sleep(@var{seconds})
+This function attempts to sleep for @var{seconds} seconds.
+Note that @var{seconds} may be a floating-point (non-integral) value.
+If @var{seconds} is negative, or the attempt to sleep fails,
+then it returns @minus{}1 and sets @code{ERRNO}.
+Otherwise, the function should return 0 after sleeping
+for the indicated amount of time. Implementation details: depending
+on platform availability, it tries to use @code{nanosleep()} or @code{select()}
+to implement the delay.
+
+@end table
+
+@node gawkextlib
+@section The @code{gawkextlib} Project
+
+The @uref{http://sourceforge.net/projects/gawkextlib/, @code{gawkextlib}} project
+provides a number of @command{gawk} extensions, including one for
+processing XML files. This is the evolution of the original @command{xgawk}
+(XML @command{gawk}) project.
+
+As of this writing, there are four extensions:
+
+@itemize @bullet
+@item
+XML parser extension, using the @uref{http://expat.sourceforge.net, Expat}
+XML parsing library
+
+@item
+Postgres SQL extension
+
+@item
+GD graphics library extension
+
+@item
+MPFR library extension.
+This provides access to a number of MPFR functions which @command{gawk}'s
+native MPFR support does not.
+@end itemize
+
+The @code{time} extension described earlier
+(@pxref{Extension Sample Time})
+was originally from this project but has been moved in to the
+main @command{gawk} distribution.
+
+@bye
diff --git a/doc/awkcard.in b/doc/awkcard.in
index 65f36b4e..9fae7cce 100644
--- a/doc/awkcard.in
+++ b/doc/awkcard.in
@@ -26,7 +26,6 @@
.\" Strings to save typing
.ds AK \*(FCawk\*(FR
.ds GK \*(FCgawk\*(FR
-.ds PK \*(FCpgawk\*(FR
.ds NK Bell Labs \*(FCawk\*(FR
.ds MK \*(FCmawk\*(FR
.\"
@@ -77,7 +76,7 @@ Pattern Elements 8
Printf Formats 14
Records 10
Regular Expressions 11
-Signals (\*(PK) 4
+Signals (\*(GK \*(FC\-\^\-profile\*(FR) 4
Special Filenames 12
String Functions 16
Time Functions (\*(GK) 17
@@ -254,6 +253,9 @@ their types and final values to
If no \*(FIfile\*(FR
is provided, \*(FCgawk\*(FR
uses \*(FCawkvars.out\*(FR.
+.TI "\*(FC\-D\*(FR[\*(FC\*(FIfile\*(FR], \*(FC\-\^\-debug\*(FR[\*(FC=\*(FIfile\*(FR]
+Enable debugging of program. Optionally read stored commands
+from \*(FIfile\*(FR.
.TI "\*(FC-e '\*(FItext\*(FC'\*(FR, \*(FC\-\^\-source '\*(FItext\*(FC'\*(FR
Use \*(FItext\*(FR as AWK program source code.
.TI "\*(FC\-E \*(FIfile\*(FR, \*(FC\-\^\-exec \*(FIfile\*(FR
@@ -269,6 +271,10 @@ for localization.
.TI "\*(FC\-h\*(FR, \*(FC\-\^\-help\*(FR
Print a short summary of the available
options on \*(FCstdout\*(FR, then exit zero.
+.TI "\*(FC\-i \*(FIfile\*(FR, \*(FC\-\^\-include \*(FIfile\*(FR
+Include library AWK code in \*(FIfile\*(FR.
+.TI "\*(FC\-l \*(FIlib\*(FR, \*(FC\-\^\-load \*(FIlib\*(FR
+Load dynamic extension \*(FIlib\fP.
.TI "\*(FC\-L \*(FR[\*(FC\*(FIvalue\*(FR], \*(FC\-\^\-lint\*(FR[\*(FC=\*(FIvalue\*(FR]
Warn about dubious or non-portable constructs.
If \*(FIvalue\*(FR is
@@ -278,36 +284,25 @@ If \*(FIvalue\*(FR is
\*(FCinvalid\*(FR,
only issue warnings about things that are
actually invalid (not fully implemented yet).
+.TI "\*(FC\-M\*(FR, \*(FC\-\^\-bignum\*(FR
+Enable arbitrary-precision arithmetic.
.TI "\*(FC\-n\*(FR, \*(FC\-\^\-non\-decimal\-data\*(FR
Recognize octal and hexadecimal values in input data.
\*(FIUse this option with great caution!\*(FR
.TI "\*(FC\-N\*(FR, \*(FC\-\^\-use\-lc\-numeric\*(FR
Force use of the locale's decimal point character when parsing input data.
+.TI "\*(FC\-o\*(FR[\*(FC\*(FIfile\*(FR], \*(FC\-\^\-pretty-print\*(FR[\*(FC=\*(FIfile\*(FR]
+Output a pretty printed version of the program to \*(FIfile\*(FR
+(default: \*(FCawkprof.out\*(FR).
.TI "\*(FC\-O\*(FR, \*(FC\-\^\-optimize\*(FR
Enable some internal optimizations.
.TI "\*(FC\-p\*(FR[\*(FC\*(FIfile\*(FR], \*(FC\-\^\-profile\*(FR[\*(FC=\*(FIfile\*(FR]
Send profiling data to \*(FIfile\*(FR
(default: \*(FCawkprof.out\*(FR).
-With \*(GK,
-the profile is just a ``pretty printed'' version of the program.
-With \*(PK,
-the profile contains execution counts in the left margin
+The profile contains execution counts in the left margin
of each statement in the program.
.TI "\*(FC\-P\*(FR, \*(FC\-\^\-posix\*(FR
-Disable common and GNU extensions.
-.TI "\*(FC\-R \*(FIfile\*(FR, \*(FC\-\^\-command \*(FIfile\*(FR"
-\*(FCdgawk\*(FR only.
-Read stored debugger commands from \*(FIfile\*(FR.
-.TI "\*(FC\-r\*(FR, \*(FC\-\^\-re\-interval\*(FR
-Enable \*(FIinterval expressions\*(FR in regular
-expression matching (see \fHRegular
-Expressions\fP below). Useful if
-\*(FC\-\^\-traditional\*(FR is specified.
-.TI "\*(FC\-S\*(FR, \*(FC\-\^\-sandbox\*(FR
-Disable the \*(FCsystem()\*(FR function,
-input redirection with \*(FCgetline\*(FR,
-output redirection with \*(FCprint\*(FR and \*(FCprintf\*(FR,
-and dynamic extensions loading.\*(CB
+Disable common and GNU extensions.\*(CB
.in -4n
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(GK\f(HB)\*(FR\s0"
@@ -319,6 +314,17 @@ and dynamic extensions loading.\*(CB
.ES
.fi
.in +4n
+.TI "\*(FC\-r\*(FR, \*(FC\-\^\-re\-interval\*(FR
+Enable \*(FIinterval expressions\*(FR.
+... in regular
+... expression matching (see \fHRegular
+... Expressions\fP below). Useful if
+... \*(FC\-\^\-traditional\*(FR is specified
+.TI "\*(FC\-S\*(FR, \*(FC\-\^\-sandbox\*(FR
+Disable the \*(FCsystem()\*(FR function,
+input redirection with \*(FCgetline\*(FR,
+output redirection with \*(FCprint\*(FR and \*(FCprintf\*(FR,
+and dynamic extensions loading.
.TI "\*(FC-t\*(FR, \*(FC\-\^\-lint\-old\*(FR
Warn about constructs that are not
portable to the original version of
@@ -338,7 +344,7 @@ options are passed on to the AWK program in
\*(FCARGV\*(FR
for processing.\*(CB
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(GK\f(HB)\*(FR\s0"
-
+.sp .4
.\"
.\"
.\" --- Command Line Arguments (mawk)
@@ -383,14 +389,14 @@ The options may be abbreviated using just the first letter, e.g.,
and so on.\*(CB
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(MK\f(HB)\*(FR\s0"
.sp .7
-.\" --- Signals (pgawk)
+.\" --- Signals (gawk --profile)
.ES
.fi
-\*(CD\*(PK accepts two signals.
+\*(CD\*(GK accepts two signals while profiling.
\*(FCSIGUSR1\fP dumps a profile and function call stack to the
profile file. It then continues to run.
\*(FCSIGHUP\fP is similar, but exits.\*(CB
-.EB "\s+2\f(HBSIGNALS (\*(PK\f(HB)\*(FR\s0"
+.EB "\s+2\f(HBSIGNALS (\*(GK \f(HB\-\^\-profile)\*(FR\s0"
.\" --- Lines And Statements
.ES
@@ -450,7 +456,7 @@ The program text is read as if all the \*(FIprog-file\*(FR(s)
\*(CBand command line
source texts\*(CD had been concatenated.
.sp
-\*(GK includes files named on \*(FC@include\*(FR lines.
+\*(CB\*(GK includes files named on \*(FC@include\*(FR lines.
Nested includes are allowed.\*(CD
.sp .5
AWK programs execute in the following order.
@@ -545,7 +551,8 @@ variables, each element being the value of
that variable.
T}
\*(CB\*(FCERRNO\fP T{
-String describing the error if a
+... String describing the error if a
+String error value if a
\*(FCgetline\*(FR
redirection or read
fails, or if
@@ -574,6 +581,10 @@ T}
Input field separator, a space by default
(see \fHFields\fP above).
T}
+\*(CB\*(FCFUNCTAB\fP T{
+An array indexed by the names of all user-defined
+and extension functions.\*(CD
+T}
\*(CB\*(FCIGNORECASE\fP T{
If non-zero, all regular expression and string
operations ignore case.
@@ -588,13 +599,13 @@ T}
\*(CB\*(FCLINT\fP T{
Provides dynamic control of the \*(FC\-\^\-lint\fP
option from within an AWK program.
-When true, \*(GK
-prints lint warnings.
-When assigned the string value \*(FC"fatal"\*(FR,
-lint warnings become fatal errors.
-Any other true value just prints warnings.\*(CD
+... When true, \*(GK
+... prints lint warnings.
+... When assigned the string value \*(FC"fatal"\*(FR,
+... lint warnings become fatal errors.
+... Any other true value just prints warnings.
T}
-\*(FCNF\fP T{
+\*(CD\*(FCNF\fP T{
Number of fields in the current input record.
T}
\*(FCNR\fP T{
@@ -609,7 +620,11 @@ T}
\*(FCORS\fP T{
Output record separator, a newline by default.
T}
-\*(CB\*(FCPROCINFO\fP T{
+\*(CB\*(FCPREC\fP T{
+The working precision of arbitrary precision floating-point
+numbers, 53 by default.
+T}
+\*(FCPROCINFO\fP T{
Elements of this array provide access to information
about the running AWK program. See
\*(AM for details.\*(CD
@@ -618,6 +633,10 @@ T}
Length of the string matched by \*(FCmatch()\*(FR;
\-1 if no match.
T}
+\*(CB\*(FCROUNDMODE\fP T{
+The rounding mode to use for arbitrary precision arithmetic,
+by default \*(FC"N"\fP.\*(CD
+T}
\*(FCRS\fP T{
Input record separator, a newline by default
(see \fHRecords\fP above).
@@ -636,6 +655,11 @@ Character(s) used to separate multiple subscripts
in array elements, by default \*(FC"\e034"\*(FR. (See
\fHArrays\fP below).
T}
+\*(CB\*(FCSYMTAB\fP T{
+An array indexed by the names of all global
+variables and arrays. May be used to indirectly
+set variable and array values.\*(CD
+T}
\*(CB\*(FCTEXTDOMAIN\fP T{
The internationalization text domain,
for finding the localized
@@ -1129,7 +1153,10 @@ The default path is
If a file name given to the \*(FC\-f\fP option contains a ``/'' character,
no path search is performed.
.sp .5
-.PP
+The variable \*(FCAWKLIBPATH\fP
+specifies the search path for dynamic extensions to use
+with \*(FC@load\fP and the \*(FC\-l\fP option.
+.sp .5
For socket communication,
\*(FCGAWK_SOCK_RETRIES\fP
controls the number of retries, and
@@ -1139,6 +1166,10 @@ The interval is in milliseconds. On systems that do not support
\*(FIusleep\fP(3),
the value is rounded up to an integral number of seconds.
.sp .5
+The value of \*(FCGAWK_READ_TIMEOUT\fP specifies the time, in milliseconds,
+for \*(GK to
+wait for input before returning with an error.
+.sp .5
If \*(FCPOSIXLY_CORRECT\fP exists
.\" in the environment,
then \*(GK
@@ -1799,10 +1830,9 @@ provides the following functions for doing bitwise operations.
.fi
.in +.2i
.ti -.2i
-\*(FCand(\*(FIv1\*(FC, \*(FIv2\*(FC)\*(FR
+\*(FCand(\*(FIv1\*(FC, \*(FIv2\*(FR [\*(FC,\*(FR ... ]\*(FC)\*(FR
.br
-Return the bitwise AND of the values provided by
-\*(FIv1\*(FR and \*(FIv2\*(FR.
+Return the bitwise AND of the arguments.
.ti -.2i
\*(FCcompl(\*(FIval\*(FC)\*(FR
.br
@@ -1814,20 +1844,18 @@ Return the bitwise complement of
Return the value of \*(FIval\*(FR,
shifted left by \*(FIcount\*(FR bits.
.ti -.2i
-\*(FCor(\*(FIv1\*(FC, \*(FIv2\*(FC)\*(FR
+\*(FCor(\*(FIv1\*(FC, \*(FIv2\*(FR [\*(FC,\*(FR ... ]\*(FC)\*(FR
.br
-Return the bitwise OR of the values provided by
-\*(FIv1\*(FR and \*(FIv2\*(FR.
+Return the bitwise OR of the arguments.
.ti -.2i
\*(FCrshift(\*(FIval\*(FC, \*(FIcount\*(FC)\*(FR
.br
Return the value of \*(FIval\*(FR,
shifted right by \*(FIcount\*(FR bits.
.ti -.2i
-\*(FCxor(\*(FIv1\*(FC, \*(FIv2\*(FC)\*(FR
+\*(FCxor(\*(FIv1\*(FC, \*(FIv2\*(FR [\*(FC,\*(FR ... ]\*(FC)\*(FR
.br
-Return the bitwise XOR of the values provided by
-\*(FIv1\*(FR and \*(FIv2\*(FR.\*(CB
+Return the bitwise XOR of the arguments.\*(CB
.in -.2i
.EB "\s+2\f(HBBIT MANIPULATION FUNCTIONS (\*(GK\f(HB)\*(FR\s0"
.sp .6
@@ -1836,16 +1864,15 @@ Return the bitwise XOR of the values provided by
.fi
.in +.2i
.ti -.2i
-\*(CD\*(FCextension(\*(FIlib\*(FC, \*(FIfunc\*(FC)\*(FR
+\*(CD\*(FC@load "\*(FIextension\*(FC"\*(FR
.br
-Dynamically load the shared library
-\*(FIlib\*(FR
-and call
-\*(FIfunc\*(FR
-in it to initialize the library.
+Dynamically load the named \*(FIextension\*(FR.
This adds new built-in functions to \*(GK.
-It returns the value returned by
-\*(FIfunc\*(FR.\*(CB
+.\" The extension should use the API defined by the
+.\" \*(FCgawkapi.h\*(FR header file, as documented in
+.\" the full manual.
+The extension is loaded during the parsing of the program.
+See the manual for details.\*(CB
.in -.2i
.EB "\s+2\f(HBDYNAMIC EXTENSIONS (\*(GK\f(HB)\*(FR\s0"
.BT
@@ -1946,7 +1973,7 @@ maintains it.\*(CX
.ES
.fi
\*(CDCopyright \(co 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+2007, 2009, 2010, 2011, 2012 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/gawk.1 b/doc/gawk.1
index e26f9a2e..31fcef1f 100644
--- a/doc/gawk.1
+++ b/doc/gawk.1
@@ -14,7 +14,7 @@
. if \w'\(rq' .ds rq "\(rq
. \}
.\}
-.TH GAWK 1 "Nov 10 2011" "Free Software Foundation" "Utility Commands"
+.TH GAWK 1 "Oct 02 2012" "Free Software Foundation" "Utility Commands"
.SH NAME
gawk \- pattern scanning and processing language
.SH SYNOPSIS
@@ -33,30 +33,6 @@ gawk \- pattern scanning and processing language
]
.I program-text
file .\|.\|.
-.sp
-.B pgawk
-[ \*(PX or \*(GN style options ]
-.B \-f
-.I program-file
-[
-.B \-\^\-
-] file .\|.\|.
-.br
-.B pgawk
-[ \*(PX or \*(GN style options ]
-[
-.B \-\^\-
-]
-.I program-text
-file .\|.\|.
-.sp
-.B dgawk
-[ \*(PX or \*(GN style options ]
-.B \-f
-.I program-file
-[
-.B \-\^\-
-] file .\|.\|.
.SH DESCRIPTION
.I Gawk
is the \*(GN Project's implementation of the \*(AK programming language.
@@ -84,27 +60,31 @@ and
.B ARGV
pre-defined \*(AK variables.
.PP
-.I Pgawk
-is the profiling version of
-.IR gawk .
-It is identical in every way to
-.IR gawk ,
-except that programs run more slowly,
-and it automatically produces an execution profile in the file
+When
+.I gawk
+is invoked with the
+.B \-\^\-profile
+option, it starts gathering profiling statistics
+from the execution of the program.
+.I Gawk
+runs more slowly in this mode, and automatically produces an execution
+profile in the file
.B awkprof.out
when done.
See the
.B \-\^\-profile
option, below.
.PP
-.I Dgawk
-is an
-.I awk
-debugger. Instead of running the program directly, it loads the
+.I Gawk
+also has an integrated debugger. An interactive debugging session can
+be started by supplying the
+.B \-\^\-debug
+option to the command line. In this mode of execution,
+.I gawk
+loads the
AWK source code and then prompts for debugging commands.
-Unlike
-.IR gawk " and " pgawk ", " dgawk
-only processes AWK program source provided with the
+.I Gawk
+can only debug AWK program source provided with the
.B \-f
option.
The debugger is documented in \*(EP.
@@ -117,8 +97,8 @@ while long options start with \*(lq\-\^\-\*(rq.
Long options are provided for both \*(GN-specific features and
for \*(PX-mandated features.
.PP
-.IR Gawk -
-specific options are typically used in long-option form.
+.IR Gawk -specific
+options are typically used in long-option form.
Arguments to long options are either joined with the option
by an
.B =
@@ -273,6 +253,18 @@ names like
and so on.)
.TP
.PD 0
+\fB\-D\fR[\fIfile\fR]
+.TP
+.PD
+\fB\-\^\-debug\fR[\fB=\fIfile\fR]
+Enable debugging of \*(AK programs.
+By default, the debugger reads commands interactively from the terminal.
+The optional
+.IR file
+argument can be used to specify a file with a list
+of commands for the debugger to execute non-interactively.
+.TP
+.PD 0
.BI "\-e " program-text
.TP
.PD
@@ -331,6 +323,33 @@ the standard output.
these options cause an immediate, successful exit.)
.TP
.PD 0
+.BI "\-i " include-file
+.TP
+.PD
+.BI \-\^\-include " include-file"
+Load an awk source library.
+This searches for the library using the
+.B AWKPATH
+environment variable. If the initial search fails, another attempt will
+be made after appending the ".awk" suffix. The file will be loaded only
+once (i.e. duplicates are eliminated), and the code does not constitute
+the main program source.
+.TP
+.PD 0
+.BI "\-l " lib
+.TP
+.PD
+.BI \-\^\-load " lib"
+Load a shared library
+.IR lib .
+This searches for the library using the
+.B AWKLIBPATH
+environment variable. If the initial search fails, another attempt will
+be made after appending the default shared library suffix for the platform.
+The library initialization routine is expected to be named
+.BR dl_load() .
+.TP
+.PD 0
.BR "\-L " [ \fIvalue\fR ]
.TP
.PD
@@ -348,6 +367,16 @@ only warnings about things that are
actually invalid are issued. (This is not fully implemented yet.)
.TP
.PD 0
+.B \-M
+.TP
+.PD
+.B \-\^\-bignum
+Force arbitrary precision arithmetic on numbers. This option has
+no effect if
+.I gawk
+is not compiled to use the GNU MPFR and MP libraries.
+.TP
+.PD 0
.B \-n
.TP
.PD
@@ -387,12 +416,28 @@ users.
..
.TP
.PD 0
+\fB\-o\fR[\fIfile\fR]
+.TP
+.PD
+\fB\-\^\-pretty-print\fR[\fB=\fIfile\fR]
+Output a pretty printed version of the program to
+.IR file .
+If no
+.I file
+is provided,
+.I gawk
+uses a file named
+.B awkprof.out
+in the current directory.
+.TP
+.PD 0
.B \-O
.TP
.PD
.B \-\^\-optimize
Enable optimizations upon the internal representation of the program.
-Currently, this includes just simple constant-folding. The
+Currently, this includes simple constant-folding, and tail call
+elimination for recursive functions. The
.I gawk
maintainer hopes to add additional optimizations over time.
.TP
@@ -401,16 +446,11 @@ maintainer hopes to add additional optimizations over time.
.TP
.PD
\fB\-\^\-profile\fR[\fB=\fIprof_file\fR]
-Send profiling data to
+Start a profiling session, and send the profiling data to
.IR prof_file .
The default is
.BR awkprof.out .
-When run with
-.IR gawk ,
-the profile is just a \*(lqpretty printed\*(rq version of the program.
-When run with
-.IR pgawk ,
-the profile contains execution counts of each statement in the program
+The profile contains execution counts of each statement in the program
in the left margin and function call counts for each user-defined function.
.TP
.PD 0
@@ -482,15 +522,6 @@ They are enabled by default, but this option remains for use with
.BR \-\^-traditional .
.TP
.PD 0
-.B \-R
-.TP
-.PD
-.BI \-\^\-command " file"
-.I Dgawk
-only. Read stored debugger commands from
-.IR file .
-.TP
-.PD 0
.BI \-S
.TP
.PD
@@ -555,6 +586,9 @@ and optional function definitions.
.RS
.PP
\fB@include "\fIfilename\fB"
+.br
+\fB@load "\fIfilename\fB"
+.br
\fIpattern\fB { \fIaction statements\fB }\fR
.br
\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements\fB }\fR
@@ -586,12 +620,21 @@ In addition, lines beginning with
may be used to include other source files into your program,
making library use even easier.
.PP
+Lines beginning with
+.B @load
+may be used to load shared libraries into your program. This is equivalent
+to using the
+.B \-l
+option.
+.PP
The environment variable
.B AWKPATH
specifies a search path to use when finding source files named with
the
.B \-f
-option. If this variable does not exist, the default path is
+and
+.B \-i
+options. If this variable does not exist, the default path is
\fB".:/usr/local/share/awk"\fR.
(The actual directory may vary, depending upon how
.I gawk
@@ -946,6 +989,17 @@ The input field separator, a space by default. See
.BR Fields ,
above.
.TP
+.B FUNCTAB
+An array whose indices are the names of all the user-defined
+or extension functions in the program.
+.BR NOTE :
+The array values cannot currently be used.
+Also, you may not use the
+.B delete
+statment with the
+.B FUNCTAB
+array.
+.TP
.B IGNORECASE
Controls the case-sensitivity of all regular expression
and string operations. If
@@ -1022,6 +1076,10 @@ The output field separator, a space by default.
.B ORS
The output record separator, by default a newline.
.TP
+.B PREC
+The working precision of arbitrary precision floating-point
+numbers, 53 by default.
+.TP
.B PROCINFO
The elements of this array provide access to information about the
running \*(AK program.
@@ -1061,6 +1119,35 @@ or \fB"FIELDWIDTHS"\fP if field splitting with
.B FIELDWIDTHS
is in effect.
.TP
+\fBPROCINFO["identifiers"]\fP
+A subarray, indexed by the names of all identifiers used in the
+text of the AWK program. For each identifier, the value of the element is one of the following:
+.RS
+.TP
+\fB"array"\fR
+The identifier is an array.
+.TP
+\fB"extension"\fR
+The identifier is an extension function loaded via
+.BR @load .
+.TP
+\fB"scalar"\fR
+The identifier is a scalar.
+.TP
+\fB"untyped"\fR
+The identifier is untyped (could be used as a scalar or array,
+.I gawk
+doesn't know yet).
+.TP
+\fB"user"\fR
+The identifier is a user-defined function.
+.RE
+The values indicate what
+.I gawk
+knows about the identifiers after it has finished parsing the program; they are
+.I not
+updated while the program runs.
+.TP
\fBPROCINFO["gid"]\fP
the value of the
.IR getgid (2)
@@ -1120,11 +1207,48 @@ corresponding values of the two elements being compared.
It should return a number less than, equal to, or greater than 0,
depending on how the elements of the array are to be ordered.
.TP
+\fBPROCINFO["input", "READ_TIMEOUT"]\fP
+specifies the timeout in milliseconds for reading data from
+.IR input ,
+where
+.I input
+is a redirection string or a filename. A value of zero or
+less than zero means no timeout.
+.TP
+\fBPROCINFO["mpfr_version"]\fP
+the version of the GNU MPFR library used for arbitrary precision
+number support in
+.IR gawk .
+.TP
+\fBPROCINFO["gmp_version"]\fP
+the version of the GNU MP library used for arbitrary precision
+number support in
+.IR gawk .
+.TP
+\fBPROCINFO["prec_max"]\fP
+the maximum precision supported by the GNU MPFR library for
+arbitrary precision floating-point numbers.
+.TP
+\fBPROCINFO["prec_min"]\fP
+the minimum precision allowed by the GNU MPFR library for
+arbitrary precision floating-point numbers.
+.TP
\fBPROCINFO["version"]\fP
the version of
.IR gawk .
.RE
.TP
+.B ROUNDMODE
+The rounding mode to use for arbitrary precision arithmetic on
+numbers, by default \fB"N"\fR (IEEE-754 roundTiesToEven mode).
+The accepted values are
+\fB"N"\fR or \fB"n"\fR for roundTiesToEven,
+\fB"U"\fR or \fB"u"\fR for roundTowardPositive,
+\fB"D"\fR or \fB"d"\fR for roundTowardNegative,
+\fB"Z"\fR or \fB"z"\fR for roundTowardZero,
+and if your version of GNU MPFR library supports it,
+\fB"A"\fR or \fB"a"\fR for roundTiesToAway.
+.TP
.B RS
The input record separator, by default a newline.
.TP
@@ -1152,6 +1276,30 @@ The length of the string matched by
The character used to separate multiple subscripts in array
elements, by default \fB"\e034"\fR.
.TP
+.B SYMTAB
+An array whose indices are the names of all currently defined
+global variables and arrays in the program. The array may be used
+for indirect access to read or write the value of a variable:
+.PP
+.RS
+.ft B
+foo = 5
+SYMTAB["foo"] = 4
+print foo # prints 4
+.ft R
+.RE
+.PP
+The
+.B isarray()
+function may be used to test if an element in
+.B SYMTAB
+is an array.
+You may not use the
+.B delete
+statment with the
+.B SYMTAB
+array.
+.TP
.B TEXTDOMAIN
The text domain of the \*(AK program; used to find the localized
translations for the program's strings.
@@ -2893,11 +3041,9 @@ integers, doing the operation, and then converting the
result back to floating point.
The functions are:
.TP "\w'\fBrshift(\fIval\fB, \fIcount\fB)\fR'u+2n"
-\fBand(\fIv1\fB, \fIv2\fB)\fR
-Return the bitwise AND of the values provided by
-.I v1
-and
-.IR v2 .
+\fBand(\fIv1\fB, \fIv2 \fR[, ...]\fB)\fR
+Return the bitwise AND of the values provided in the argument list.
+There must be at least two.
.TP
\fBcompl(\fIval\fB)\fR
Return the bitwise complement of
@@ -2910,11 +3056,9 @@ shifted left by
.I count
bits.
.TP
-\fBor(\fIv1\fB, \fIv2\fB)\fR
-Return the bitwise OR of the values provided by
-.I v1
-and
-.IR v2 .
+\fBor(\fIv1\fB, \fIv2 \fR[, ...]\fB)\fR
+Return the bitwise OR of the values provided in the argument list.
+There must be at least two.
.TP
\fBrshift(\fIval\fB, \fIcount\fB)\fR
Return the value of
@@ -2923,11 +3067,9 @@ shifted right by
.I count
bits.
.TP
-\fBxor(\fIv1\fB, \fIv2\fB)\fR
-Return the bitwise XOR of the values provided by
-.I v1
-and
-.IR v2 .
+\fBxor(\fIv1\fB, \fIv2 \fR[, ...]\fB)\fR
+Return the bitwise XOR of the values provided in the argument list.
+There must be at least two.
.PP
.SS Type Function
The following function is for use with multidimensional arrays.
@@ -3103,27 +3245,15 @@ may be used in place of
.SH DYNAMICALLY LOADING NEW FUNCTIONS
You can dynamically add new built-in functions to the running
.I gawk
-interpreter.
+interpreter with the
+.B @load
+statement.
The full details are beyond the scope of this manual page;
-see \*(EP for the details.
-.PP
-.TP 8
-\fBextension(\fIobject\fB, \fIfunction\fB)\fR
-Dynamically link the shared object file named by
-.IR object ,
-and invoke
-.I function
-in that object, to perform initialization.
-These should both be provided as strings.
-Return the value returned by
-.IR function .
-.PP
-Using this feature at the C level is not pretty, but
-it is unlikely to go away. Additional mechanisms may
-be added at some point.
+see \*(EP.
.SH SIGNALS
-.I pgawk
-accepts two signals.
+The
+.I gawk
+profiler accepts two signals.
.B SIGUSR1
causes it to dump a profile and function call stack to the
profile file, which is either
@@ -3133,7 +3263,7 @@ or whatever file was named with the
option. It then continues to run.
.B SIGHUP
causes
-.I pgawk
+.I gawk
to dump the profile and function call stack and then exit.
.SH INTERNATIONALIZATION
.PP
@@ -3573,10 +3703,31 @@ environment variable can be used to provide a list of directories that
.I gawk
searches when looking for files named via the
.B \-f
-and
+,
.B \-\^\-file
+,
+.B \-i
+and
+.B \-\^\-include
+options. If the initial search fails, the path is searched again after
+appending ".awk" to the filename.
+.PP
+The
+.B AWKLIBPATH
+environment variable can be used to provide a list of directories that
+.I gawk
+searches when looking for files named via the
+.B \-l
+and
+.B \-\^\-load
options.
.PP
+The
+.B GAWK_READ_TIMEOUT
+environment variable can be used to specify a timeout
+in milliseconds for reading input from a terminal, pipe
+or two-way communication including sockets.
+.PP
For socket communication, two special environment variables can be used to control the number of retries
.RB ( GAWK_SOCK_RETRIES ),
and the interval between retries
@@ -3627,7 +3778,7 @@ status is 2. On non-POSIX systems, this value may be mapped to
.SH VERSION INFORMATION
This man page documents
.IR gawk ,
-version 4.0.
+version 4.1.
.SH AUTHORS
The original version of \*(UX
.I awk
@@ -3705,6 +3856,7 @@ While the
developers occasionally read this newsgroup, posting bug reports there
is an unreliable way to report bugs. Instead, please use the electronic mail
addresses given above.
+Really.
.PP
If you're using a GNU/Linux or BSD-based system,
you may wish to submit a bug report to the vendor of your distribution.
@@ -3724,6 +3876,7 @@ are surprisingly difficult to diagnose in the completely general case,
and the effort to do so really is not worth it.
.SH SEE ALSO
.IR egrep (1),
+.IR sed (1),
.IR getpid (2),
.IR getppid (2),
.IR getpgrp (2),
@@ -3739,7 +3892,7 @@ Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger,
Addison-Wesley, 1988. ISBN 0-201-07981-X.
.PP
\*(EP,
-Edition 4.0, shipped with the
+Edition 4.1, shipped with the
.I gawk
source.
The current version of this document is available online at
@@ -3786,7 +3939,7 @@ We thank him.
.SH COPYING PERMISSIONS
Copyright \(co 1989, 1991, 1992, 1993, 1994, 1995, 1996,
1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2007, 2009,
-2010, 2011
+2010, 2011, 2012
Free Software Foundation, Inc.
.PP
Permission is granted to make and distribute verbatim copies of
diff --git a/doc/gawk.info b/doc/gawk.info
index 878a03fc..08fbc297 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -94,13 +94,17 @@ texts being (a) (see below), and with the Back-Cover Texts being (b)
* Library Functions:: A Library of `awk' Functions.
* Sample Programs:: Many `awk' programs with complete
explanations.
-* Debugger:: The `dgawk' debugger.
+* Debugger:: The `gawk' debugger.
+* Arbitrary Precision Arithmetic:: Arbitrary precision arithmetic with
+ `gawk'.
+* Dynamic Extensions:: Adding new built-in functions to
+ `gawk'.
* Language History:: The evolution of the `awk'
language.
* Installation:: Installing `gawk' under various
operating systems.
-* Notes:: Notes about `gawk' extensions and
- possible future work.
+* Notes:: Notes about adding things to `gawk'
+ and possible future work.
* Basic Concepts:: A very quick introduction to programming
concepts.
* Glossary:: An explanation of some unfamiliar terms.
@@ -154,9 +158,12 @@ texts being (a) (see below), and with the Back-Cover Texts being (b)
uses.
* AWKPATH Variable:: Searching directories for `awk'
programs.
+* AWKLIBPATH Variable:: Searching directories for `awk'
+ shared libraries.
* Other Environment Variables:: The environment variables.
* Exit Status:: `gawk''s exit status.
* Include Files:: Including other files into your program.
+* Loading Shared Libraries:: Loading shared libraries into your program.
* Obsolete:: Obsolete Options and/or features.
* Undocumented:: Undocumented Options and Features.
* Regexp Usage:: How to Use Regular Expressions.
@@ -196,6 +203,7 @@ texts being (a) (see below), and with the Back-Cover Texts being (b)
* Getline Notes:: Important things to know about
`getline'.
* Getline Summary:: Summary of `getline' Variants.
+* Read Timeout:: Reading input with a timeout.
* Command line directories:: What happens if you put a directory on the
command line.
* Print:: The `print' statement.
@@ -377,7 +385,7 @@ texts being (a) (see below), and with the Back-Cover Texts being (b)
* Ordinal Functions:: Functions for using characters as numbers
and vice versa.
* Join Function:: A function to join an array into a string.
-* Gettimeofday Function:: A function to get formatted times.
+* Getlocaltime Function:: A function to get formatted times.
* Data File Management:: Functions for managing command-line data
files.
* Filetrans Function:: A function for handling data file
@@ -417,23 +425,51 @@ texts being (a) (see below), and with the Back-Cover Texts being (b)
* Anagram Program:: Finding anagrams from a dictionary.
* Signature Program:: People do amazing things with too much time
on their hands.
-* Debugging:: Introduction to `dgawk'.
-* Debugging Concepts:: Debugging In General.
+* Debugging:: Introduction to `gawk' debugger.
+* Debugging Concepts:: Debugging in General.
* Debugging Terms:: Additional Debugging Concepts.
* Awk Debugging:: Awk Debugging.
-* Sample dgawk session:: Sample `dgawk' session.
-* dgawk invocation:: `dgawk' Invocation.
-* Finding The Bug:: Finding The Bug.
-* List of Debugger Commands:: Main `dgawk' Commands.
-* Breakpoint Control:: Control of breakpoints.
-* Dgawk Execution Control:: Control of execution.
-* Viewing And Changing Data:: Viewing and changing data.
-* Dgawk Stack:: Dealing with the stack.
-* Dgawk Info:: Obtaining information about the program and
- the debugger state.
-* Miscellaneous Dgawk Commands:: Miscellaneous Commands.
-* Readline Support:: Readline Support.
-* Dgawk Limitations:: Limitations and future plans.
+* Sample Debugging Session:: Sample debugging session.
+* Debugger Invocation:: How to Start the Debugger.
+* Finding The Bug:: Finding the Bug.
+* List of Debugger Commands:: Main debugger commands.
+* Breakpoint Control:: Control of Breakpoints.
+* Debugger Execution Control:: Control of Execution.
+* Viewing And Changing Data:: Viewing and Changing Data.
+* Execution Stack:: Dealing with the Stack.
+* Debugger Info:: Obtaining Information about the Program and
+ the Debugger State.
+* Miscellaneous Debugger Commands:: Miscellaneous Commands.
+* Readline Support:: Readline support.
+* Limitations:: Limitations and future plans.
+* General Arithmetic:: An introduction to computer arithmetic.
+* Floating Point Issues:: Stuff to know about floating-point numbers.
+* String Conversion Precision:: The String Value Can Lie.
+* Unexpected Results:: Floating Point Numbers Are Not Abstract
+ Numbers.
+* POSIX Floating Point Problems:: Standards Versus Existing Practice.
+* Integer Programming:: Effective integer programming.
+* Floating-point Programming:: Effective Floating-point Programming.
+* Floating-point Representation:: Binary floating-point representation.
+* Floating-point Context:: Floating-point context.
+* Rounding Mode:: Floating-point rounding mode.
+* Gawk and MPFR:: How `gawk' provides
+ arbitrary-precision arithmetic.
+* Arbitrary Precision Floats:: Arbitrary Precision Floating-point
+ Arithmetic with `gawk'.
+* Setting Precision:: Setting the working precision.
+* Setting Rounding Mode:: Setting the rounding mode.
+* Floating-point Constants:: Representing floating-point constants.
+* Changing Precision:: Changing the precision of a number.
+* Exact Arithmetic:: Exact arithmetic with floating-point
+ numbers.
+* Arbitrary Precision Integers:: Arbitrary Precision Integer Arithmetic with
+ `gawk'.
+* Plugin License:: A note about licensing.
+* Sample Library:: A example of new functions.
+* Internal File Description:: What the new functions will do.
+* Internal File Ops:: The code for internal file operations.
+* Using Internal File Ops:: How to use an external extension.
* V7/SVR3.1:: The major changes between V7 and System V
Release 3.1.
* SVR4:: Minor changes between System V Releases 3.1
@@ -484,24 +520,12 @@ texts being (a) (see below), and with the Back-Cover Texts being (b)
`gawk'.
* New Ports:: Porting `gawk' to a new operating
system.
-* Dynamic Extensions:: Adding new built-in functions to
- `gawk'.
-* Internals:: A brief look at some `gawk'
- internals.
-* Plugin License:: A note about licensing.
-* Sample Library:: A example of new functions.
-* Internal File Description:: What the new functions will do.
-* Internal File Ops:: The code for internal file operations.
-* Using Internal File Ops:: How to use an external extension.
+* Derived Files:: Why derived files are kept in the
+ `git' repository.
* Future Extensions:: New features that may be implemented one
day.
* Basic High Level:: The high level view.
* Basic Data Typing:: A very quick intro to data types.
-* Floating Point Issues:: Stuff to know about floating-point numbers.
-* String Conversion Precision:: The String Value Can Lie.
-* Unexpected Results:: Floating Point Numbers Are Not Abstract
- Numbers.
-* POSIX Floating Point Problems:: Standards Versus Existing Practice.
To Miriam, for making me complete.
@@ -849,7 +873,13 @@ and profile your `awk' programs.
sample `awk' programs. Reading them allows you to see `awk' solving
real problems.
- *note Debugger::, describes the `awk' debugger, `dgawk'.
+ *note Debugger::, describes the `awk' debugger.
+
+ *note Arbitrary Precision Arithmetic::, describes advanced
+arithmetic facilities provided by `gawk'.
+
+ *note Dynamic Extensions::, describes how to add new variables and
+functions to `gawk' by writing extensions in C.
*note Language History::, describes how the `awk' language has
evolved since its first release to present. It also describes how
@@ -861,8 +891,8 @@ non-POSIX systems. It also describes how to report bugs in `gawk' and
where to get other freely available `awk' implementations.
*note Notes::, describes how to disable `gawk''s extensions, as well
-as how to contribute new code to `gawk', how to write extension
-libraries, and some possible future directions for `gawk' development.
+as how to contribute new code to `gawk', and some possible future
+directions for `gawk' development.
*note Basic Concepts::, provides some very cursory background
material for those who are completely unfamiliar with computer
@@ -1100,10 +1130,12 @@ it is today. It has been and continues to be a pleasure working with
this team of fine people.
John Haque contributed the modifications to convert `gawk' into a
-byte-code interpreter, including the debugger. Stephen Davies
-contributed to the effort to bring the byte-code changes into the
-mainstream code base. Efraim Yawitz contributed the initial text of
-*note Debugger::.
+byte-code interpreter, including the debugger, and the additional
+modifications for support of arbitrary precision arithmetic. Stephen
+Davies contributed to the effort to bring the byte-code changes into
+the mainstream code base. Efraim Yawitz contributed the initial text
+of *note Debugger::. John Haque contributed the initial text of *note
+Arbitrary Precision Arithmetic::.
I would like to thank Brian Kernighan for invaluable assistance
during the testing and debugging of `gawk', and for ongoing help and
@@ -2086,6 +2118,7 @@ this major node that don't interest you right now.
* Environment Variables:: The environment variables `gawk' uses.
* Exit Status:: `gawk''s exit status.
* Include Files:: Including other files into your program.
+* Loading Shared Libraries:: Loading shared libraries into your program.
* Obsolete:: Obsolete Options and/or features.
* Undocumented:: Undocumented Options and Features.
@@ -2143,6 +2176,20 @@ The following list describes options mandated by the POSIX standard:
`awk' program consists of the concatenation the contents of each
specified SOURCE-FILE.
+`-i SOURCE-FILE'
+`--include SOURCE-FILE'
+ Read `awk' source library from SOURCE-FILE. This option is
+ completely equivalent to using the `@include' directive inside
+ your program. This option is very similar to the `-f' option, but
+ there are two important differences. First, when `-i' is used,
+ the program source will not be loaded if it has been previously
+ loaded, whereas the `-f' will always load the file. Second,
+ because this option is intended to be used with code libraries, the
+ `awk' command does not recognize such files as constituting main
+ program input. Thus, after processing an `-i' argument, we still
+ expect to find the main source code via the `-f' option or on the
+ command-line.
+
`-v VAR=VAL'
`--assign VAR=VAL'
Set the variable VAR to the value VAL _before_ execution of the
@@ -2219,6 +2266,15 @@ The following list describes options mandated by the POSIX standard:
particularly easy mistake to make with simple variable names like
`i', `j', etc.)
+`-D[FILE]'
+`--debug=[FILE]'
+ Enable debugging of `awk' programs (*note Debugging::). By
+ default, the debugger reads commands interactively from the
+ terminal. The optional FILE argument allows you to specify a file
+ with a list of commands for the debugger to execute
+ non-interactively. No space is allowed between the `-D' and FILE,
+ if FILE is supplied.
+
`-e PROGRAM-TEXT'
`--source PROGRAM-TEXT'
Provide program source code in the PROGRAM-TEXT. This option
@@ -2261,6 +2317,15 @@ The following list describes options mandated by the POSIX standard:
Print a "usage" message summarizing the short and long style
options that `gawk' accepts and then exit.
+`-l LIB'
+`--load LIB'
+ Load a shared library LIB. This searches for the library using the
+ `AWKLIBPATH' environment variable. The correct library suffix for
+ your platform will be supplied by default, so it need not be
+ specified in the library name. The library initialization routine
+ should be named `dl_load()'. An alternative is to use the `@load'
+ keyword inside the program to load a shared library.
+
`-L [value]'
`--lint[=value]'
Warn about constructs that are dubious or nonportable to other
@@ -2280,6 +2345,12 @@ The following list describes options mandated by the POSIX standard:
inappropriate construct. As `awk' programs are usually short,
doing so is not burdensome.
+`-M'
+`--bignum'
+ Force arbitrary precision arithmetic on numbers. This option has
+ no effect if `gawk' is not compiled to use the GNU MPFR and MP
+ libraries (*note Arbitrary Precision Arithmetic::).
+
`-n'
`--non-decimal-data'
Enable automatic interpretation of octal and hexadecimal values in
@@ -2293,6 +2364,14 @@ The following list describes options mandated by the POSIX standard:
Force the use of the locale's decimal point character when parsing
numeric input data (*note Locales::).
+`-o[FILE]'
+`--pretty-print[=FILE]'
+ Enable pretty-printing of `awk' programs. By default, output
+ program is created in a file named `awkprof.out'. The optional
+ FILE argument allows you to specify a different file name for the
+ output. No space is allowed between the `-o' and FILE, if FILE is
+ supplied.
+
`-O'
`--optimize'
Enable some optimizations on the internal representation of the
@@ -2308,10 +2387,9 @@ The following list describes options mandated by the POSIX standard:
for the profile file. No space is allowed between the `-p' and
FILE, if FILE is supplied.
- When run with `gawk', the profile is just a "pretty printed"
- version of the program. When run with `pgawk', the profile
- contains execution counts for each statement in the program in the
- left margin, and function call counts for each function.
+ The profile contains execution counts for each statement in the
+ program in the left margin, and function call counts for each
+ function.
`-P'
`--posix'
@@ -2345,11 +2423,6 @@ The following list describes options mandated by the POSIX standard:
remains both for backward compatibility, and for use in
combination with the `--traditional' option.
-`-R FILE'
-`--command=FILE'
- `dgawk' only. Read `dgawk' debugger options and commands from
- FILE. *Note Dgawk Info::, for more information.
-
`-S'
`--sandbox'
Disable the `system()' function, input redirections with `getline',
@@ -2529,10 +2602,12 @@ A number of environment variables influence how `gawk' behaves.
* AWKPATH Variable:: Searching directories for `awk'
programs.
+* AWKLIBPATH Variable:: Searching directories for `awk' shared
+ libraries.
* Other Environment Variables:: The environment variables.

-File: gawk.info, Node: AWKPATH Variable, Next: Other Environment Variables, Up: Environment Variables
+File: gawk.info, Node: AWKPATH Variable, Next: AWKLIBPATH Variable, Up: Environment Variables
2.5.1 The `AWKPATH' Environment Variable
----------------------------------------
@@ -2541,9 +2616,9 @@ The previous minor node described how `awk' program files can be named
on the command-line with the `-f' option. In most `awk'
implementations, you must supply a precise path name for each program
file, unless the file is in the current directory. But in `gawk', if
-the file name supplied to the `-f' option does not contain a `/', then
-`gawk' searches a list of directories (called the "search path"), one
-by one, looking for a file with the specified name.
+the file name supplied to the `-f' or `-i' options does not contain a
+`/', then `gawk' searches a list of directories (called the "search
+path"), one by one, looking for a file with the specified name.
The search path is a string consisting of directory names separated by
colons. `gawk' gets its search path from the `AWKPATH' environment
@@ -2556,11 +2631,15 @@ standard directory in the default path and then specified on the
command line with a short file name. Otherwise, the full file name
would have to be typed for each file.
- By using both the `--source' and `-f' options, your command-line
-`awk' programs can use facilities in `awk' library files (*note Library
-Functions::). Path searching is not done if `gawk' is in compatibility
-mode. This is true for both `--traditional' and `--posix'. *Note
-Options::.
+ By using the `-i' option, or the `--source' and `-f' options, your
+command-line `awk' programs can use facilities in `awk' library files
+(*note Library Functions::). Path searching is not done if `gawk' is
+in compatibility mode. This is true for both `--traditional' and
+`--posix'. *Note Options::.
+
+ If the source code is not found after the initial search, the path
+is searched again after adding the default `.awk' suffix to the
+filename.
NOTE: To include the current directory in the path, either place
`.' explicitly in the path or write a null entry in the path. (A
@@ -2591,9 +2670,22 @@ the value of `$(datadir)' generated when `gawk' was configured. You
probably don't need to worry about this, though.

-File: gawk.info, Node: Other Environment Variables, Prev: AWKPATH Variable, Up: Environment Variables
+File: gawk.info, Node: AWKLIBPATH Variable, Next: Other Environment Variables, Prev: AWKPATH Variable, Up: Environment Variables
-2.5.2 Other Environment Variables
+2.5.2 The `AWKLIBPATH' Environment Variable
+-------------------------------------------
+
+The `AWKLIBPATH' environment variable is similar to the `AWKPATH'
+variable, but it is used to search for shared libraries specified with
+the `-l' option rather than for source files. If the library is not
+found, the path is searched again after adding the appropriate shared
+library suffix for the platform. For example, on GNU/Linux systems,
+the suffix `.so' is used.
+
+
+File: gawk.info, Node: Other Environment Variables, Prev: AWKLIBPATH Variable, Up: Environment Variables
+
+2.5.3 Other Environment Variables
---------------------------------
A number of other environment variables affect `gawk''s behavior, but
@@ -2614,6 +2706,10 @@ used by regular users.
milliseconds. On systems that do not support the `usleep()' system
call, the value is rounded up to an integral number of seconds.
+`GAWK_READ_TIMEOUT'
+ Specifies the time, in milliseconds, for `gawk' to wait for input
+ before returning with an error. *Note Read Timeout::.
+
The environment variables in the following list are meant for use by
the `gawk' developers for testing and tuning. They are subject to
change. The variables are:
@@ -2668,7 +2764,7 @@ with the value of the C constant `EXIT_SUCCESS'. This is usually zero.
non-POSIX systems, this value may be mapped to `EXIT_FAILURE'.

-File: gawk.info, Node: Include Files, Next: Obsolete, Prev: Exit Status, Up: Invoking Gawk
+File: gawk.info, Node: Include Files, Next: Loading Shared Libraries, Prev: Exit Status, Up: Invoking Gawk
2.7 Including Other Files Into Your Program
===========================================
@@ -2682,7 +2778,8 @@ into smaller, more manageable pieces, and also lets you reuse common
together `awk' functions, used to carry out specific tasks, into
external files. These files can be used just like function libraries,
using the `@include' keyword in conjunction with the `AWKPATH'
-environment variable.
+environment variable. Note that source files may also be included
+using the `-i' option.
Let's see an example. We'll start with two (trivial) `awk' scripts,
namely `test1' and `test2'. Here is the `test1' script:
@@ -2764,9 +2861,41 @@ always searched first for source files, before searching in `AWKPATH',
and this also applies to files named with `@include'.

-File: gawk.info, Node: Obsolete, Next: Undocumented, Prev: Include Files, Up: Invoking Gawk
+File: gawk.info, Node: Loading Shared Libraries, Next: Obsolete, Prev: Include Files, Up: Invoking Gawk
+
+2.8 Loading Shared Libraries Into Your Program
+==============================================
+
+This minor node describes a feature that is specific to `gawk'.
+
+ The `@load' keyword can be used to read external `awk' shared
+libraries. This allows you to link in compiled code that may offer
+superior performance and/or give you access to extended capabilities
+not supported by the `awk' language. The `AWKLIBPATH' variable is used
+to search for the shared library. Using `@load' is completely
+equivalent to using the `-l' command-line option.
+
+ If the shared library is not initially found in `AWKLIBPATH', another
+search is conducted after appending the platform's default shared
+library suffix to the filename. For example, on GNU/Linux systems, the
+suffix `.so' is used.
-2.8 Obsolete Options and/or Features
+ $ gawk '@load "ordchr"; BEGIN {print chr(65)}'
+ -| A
+
+This is equivalent to the following example:
+
+ $ gawk -lordchr 'BEGIN {print chr(65)}'
+ -| A
+
+For command-line usage, the `-l' option is more convenient, but `@load'
+is useful for embedding inside an `awk' source file that requires
+access to a shared library.
+
+
+File: gawk.info, Node: Obsolete, Next: Undocumented, Prev: Loading Shared Libraries, Up: Invoking Gawk
+
+2.9 Obsolete Options and/or Features
====================================
This minor node describes features and/or command-line options from
@@ -2782,8 +2911,8 @@ worked. As of version 4.0, they are no longer interpreted specially by

File: gawk.info, Node: Undocumented, Prev: Obsolete, Up: Invoking Gawk
-2.9 Undocumented Options and Features
-=====================================
+2.10 Undocumented Options and Features
+======================================
Use the Source, Luke!
Obi-Wan
@@ -3615,6 +3744,7 @@ have to be named on the `awk' command line (*note Getline::).
* Multiple Line:: Reading multi-line records.
* Getline:: Reading files under explicit program control
using the `getline' function.
+* Read Timeout:: Reading input with a timeout.
* Command line directories:: What happens if you put a directory on the
command line.
@@ -4807,7 +4937,7 @@ feature of `RS' does not apply. It does apply to the default field
separator of a single space: `FS = " "'.

-File: gawk.info, Node: Getline, Next: Command line directories, Prev: Multiple Line, Up: Reading Files
+File: gawk.info, Node: Getline, Next: Read Timeout, Prev: Multiple Line, Up: Reading Files
4.9 Explicit Input with `getline'
=================================
@@ -5233,7 +5363,8 @@ File: gawk.info, Node: Getline Summary, Prev: Getline Notes, Up: Getline
*note table-getline-variants:: summarizes the eight variants of
`getline', listing which built-in variables are set by each one, and
-whether the variant is standard or a `gawk' extension.
+whether the variant is standard or a `gawk' extension. Note: for each
+variant, `gawk' sets the `RT' built-in variable.
Variant Effect Standard /
Extension
@@ -5252,9 +5383,101 @@ VAR
Table 4.1: getline Variants and What They Set

-File: gawk.info, Node: Command line directories, Prev: Getline, Up: Reading Files
+File: gawk.info, Node: Read Timeout, Next: Command line directories, Prev: Getline, Up: Reading Files
+
+4.10 Reading Input With A Timeout
+=================================
+
+You may specify a timeout in milliseconds for reading input from a
+terminal, pipe or two-way communication including, TCP/IP sockets. This
+can be done on a per input, command or connection basis, by setting a
+special element in the `PROCINFO' array:
+
+ PROCINFO["input_name", "READ_TIMEOUT"] = TIMEOUT IN MILLISECONDS
+
+ When set, this will cause `gawk' to time out and return failure if
+no data is available to read within the specified timeout period. For
+example, a TCP client can decide to give up on receiving any response
+from the server after a certain amount of time:
+
+ Service = "/inet/tcp/0/localhost/daytime"
+ PROCINFO[Service, "READ_TIMEOUT"] = 100
+ if ((Service |& getline) > 0)
+ print $0
+ else if (ERRNO != "")
+ print ERRNO
+
+ Here is how to read interactively from the terminal(1) without
+waiting for more than five seconds:
+
+ PROCINFO["/dev/stdin", "READ_TIMEOUT"] = 5000
+ while ((getline < "/dev/stdin") > 0)
+ print $0
+
+ `gawk' will terminate the read operation if input does not arrive
+after waiting for the timeout period, return failure and set the
+`ERRNO' variable to an appropriate string value. A negative or zero
+value for the timeout is the same as specifying no timeout at all.
+
+ A timeout can also be set for reading from the terminal in the
+implicit loop that reads input records and matches them against
+patterns, like so:
+
+ $ gawk 'BEGIN { PROCINFO["-", "READ_TIMEOUT"] = 5000 }
+ > { print "You entered: " $0 }'
+ gawk
+ -| You entered: gawk
+
+ In this case, failure to respond within five seconds results in the
+following error message:
+
+ error--> gawk: cmd. line:2: (FILENAME=- FNR=1) fatal: error reading input file `-': Connection timed out
+
+ The timeout can be set or changed at any time, and will take effect
+on the next attempt to read from the input device. In the following
+example, we start with a timeout value of one second, and progressively
+reduce it by one-tenth of a second until we wait indefinitely for the
+input to arrive:
+
+ PROCINFO[Service, "READ_TIMEOUT"] = 1000
+ while ((Service |& getline) > 0) {
+ print $0
+ PROCINFO[S, "READ_TIMEOUT"] -= 100
+ }
+
+ NOTE: You should not assume that the read operation will block
+ exactly after the tenth record has been printed. It is possible
+ that `gawk' will read and buffer more than one record's worth of
+ data the first time. Because of this, changing the value of
+ timeout like in the above example is not very useful.
+
+ If the `PROCINFO' element is not present and the environment
+variable `GAWK_READ_TIMEOUT' exists, `gawk' uses its value to
+initialize the timeout value. The exclusive use of the environment
+variable to specify timeout has the disadvantage of not being able to
+control it on a per command or connection basis.
+
+ `gawk' considers a timeout event to be an error even though the
+attempt to read from the underlying device may succeed in a later
+attempt. This is a limitation, and it also means that you cannot use
+this to multiplex input from two or more sources.
+
+ Assigning a timeout value prevents read operations from blocking
+indefinitely. But bear in mind that there are other ways `gawk' can
+stall waiting for an input device to be ready. A network client can
+sometimes take a long time to establish a connection before it can
+start reading any data, or the attempt to open a FIFO special file for
+reading can block indefinitely until some other process opens it for
+writing.
+
+ ---------- Footnotes ----------
+
+ (1) This assumes that standard input is the keyboard
+
+
+File: gawk.info, Node: Command line directories, Prev: Read Timeout, Up: Reading Files
-4.10 Directories On The Command Line
+4.11 Directories On The Command Line
====================================
According to the POSIX standard, files named on the `awk' command line
@@ -8329,10 +8552,10 @@ would otherwise be difficult or impossible to perform:
entirely. Otherwise, `gawk' exits with the usual fatal error.
* If you have written extensions that modify the record handling (by
- inserting an "open hook"), you can invoke them at this point,
+ inserting an "input parser"), you can invoke them at this point,
before `gawk' has started processing the file. (This is a _very_
- advanced feature, currently used only by the XMLgawk project
- (http://xmlgawk.sourceforge.net).)
+ advanced feature, currently used only by the `gawkextlib' project
+ (http://gawkextlib.sourceforge.net).)
The `ENDFILE' rule is called when `gawk' has finished processing the
last record in an input file. For the last input file, it will be
@@ -9216,6 +9439,15 @@ specific to `gawk' are marked with a pound sign (`#').
every `print' statement. Its default value is `"\n"', the newline
character. (*Note Output Separators::.)
+`PREC #'
+ The working precision of arbitrary precision floating-point
+ numbers, 53 by default (*note Setting Precision::).
+
+`ROUNDMODE #'
+ The rounding mode to use for arbitrary precision arithmetic on
+ numbers, by default `"N"' (`roundTiesToEven' in the IEEE-754
+ standard) (*note Setting Rounding Mode::).
+
`RS'
This is `awk''s input record separator. Its default value is a
string containing a single newline character, which means that an
@@ -9321,7 +9553,8 @@ with a pound sign (`#').
Some operating systems may not have environment variables. On
such systems, the `ENVIRON' array is empty (except for
- `ENVIRON["AWKPATH"]', *note AWKPATH Variable::).
+ `ENVIRON["AWKPATH"]', *note AWKPATH Variable:: and
+ `ENVIRON["AWKLIBPATH"]', *note AWKLIBPATH Variable::).
`ERRNO #'
If a system error occurs during a redirection for `getline',
@@ -9369,6 +9602,12 @@ with a pound sign (`#').
create or remove fields from the current record. *Note Changing
Fields::.
+`FUNCTAB #'
+ An array whose indices are the names of all the user-defined or
+ extension functions in the program. *NOTE*: The array values
+ cannot currently be used. Also, you may not use the `delete'
+ statement with the `FUNCTAB' array.
+
`NR'
The number of input records `awk' has processed since the
beginning of the program's execution (*note Records::). `NR' is
@@ -9391,6 +9630,32 @@ with a pound sign (`#').
effect, or `"FPAT"' if field matching with `FPAT' is in
effect.
+ `PROCINFO["identifiers"]'
+ A subarray, indexed by the names of all identifiers used in
+ the text of the AWK program. For each identifier, the value
+ of the element is one of the following:
+
+ `"array"'
+ The identifier is an array.
+
+ `"extension"'
+ The identifier is an extension function loaded via
+ `@load'.
+
+ `"scalar"'
+ The identifier is a scalar.
+
+ `"untyped"'
+ The identifier is untyped (could be used as a scalar or
+ array, `gawk' doesn't know yet).
+
+ `"user"'
+ The identifier is a user-defined function.
+
+ The values indicate what `gawk' knows about the identifiers
+ after it has finished parsing the program; they are _not_
+ updated while the program runs.
+
`PROCINFO["gid"]'
The value of the `getgid()' system call.
@@ -9421,6 +9686,23 @@ with a pound sign (`#').
`PROCINFO["version"]'
The version of `gawk'.
+ The following additional elements in the array are available to
+ provide information about the MPFR and GMP libraries if your
+ version of `gawk' supports arbitrary precision numbers (*note
+ Arbitrary Precision Arithmetic::):
+
+ `PROCINFO["mpfr_version"]'
+ The version of the GNU MPFR library.
+
+ `PROCINFO["gmp_version"]'
+ The version of the GNU MP library.
+
+ `PROCINFO["prec_max"]'
+ The maximum precision supported by MPFR.
+
+ `PROCINFO["prec_min"]'
+ The minimum precision required by MPFR.
+
On some systems, there may be elements in the array, `"group1"'
through `"groupN"' for some N. N is the number of supplementary
groups that the process has. Use the `in' operator to test for
@@ -9455,6 +9737,23 @@ with a pound sign (`#').
implementations, or if `gawk' is in compatibility mode (*note
Options::), it is not special.
+`SYMTAB #'
+ An array whose indices are the names of all currently defined
+ global variables and arrays in the program. The array may be used
+ for indirect access to read or write the value of a variable:
+
+ foo = 5
+ SYMTAB["foo"] = 4
+ print foo # prints 4
+
+ The `isarray()' function (*note Type Functions::) may be used to
+ test if an element in `SYMTAB' is an array. Also, you may not use
+ the `delete' statement with the `SYMTAB' array.
+
+ NOTE: In order to avoid severe time-travel paradoxes(2),
+ neither `FUNCTAB' nor `SYMTAB' are available as elements
+ within the `SYMTAB' array.
+
Advanced Notes: Changing `NR' and `FNR'
---------------------------------------
@@ -9484,6 +9783,8 @@ file by resetting `NR' to zero when `FILENAME' changed.
to `"-"', even if there were data files to be processed. This behavior
was incorrect and should not be relied upon in your programs.
+ (2) Not to mention difficult implementation issues.
+

File: gawk.info, Node: ARGC and ARGV, Prev: Auto-set, Up: Built-in Variables
@@ -11968,8 +12269,9 @@ again with `10111001' and shift it left by three bits, you end up with
`11001000'. `gawk' provides built-in functions that implement the
bitwise operations just described. They are:
-`and(V1, V2)'
- Return the bitwise AND of the values provided by V1 and V2.
+`and(V1, V2 [, ...])'
+ Return the bitwise AND of the arguments. There must be at least
+ two.
`compl(VAL)'
Return the bitwise complement of VAL.
@@ -11977,14 +12279,15 @@ bitwise operations just described. They are:
`lshift(VAL, COUNT)'
Return the value of VAL, shifted left by COUNT bits.
-`or(V1, V2)'
- Return the bitwise OR of the values provided by V1 and V2.
+`or(V1, V2 [, ...])'
+ Return the bitwise OR of the arguments. There must be at least two.
`rshift(VAL, COUNT)'
Return the value of VAL, shifted right by COUNT bits.
-`xor(V1, V2)'
- Return the bitwise XOR of the values provided by V1 and V2.
+`xor(V1, V2 [, ...])'
+ Return the bitwise XOR of the arguments. There must be at least
+ two.
For all of these functions, first the double precision
floating-point value is converted to the widest C unsigned integer
@@ -13775,7 +14078,7 @@ login name, and the fields are separated by colons. Each record
defines a subarray, with each field as an element in the subarray.
Running the program produces the following output:
- $ gawk -vPOS=1 -F: -f sort.awk /etc/passwd
+ $ gawk -v POS=1 -F: -f sort.awk /etc/passwd
-| adm:x:3:4:adm:/var/adm:/sbin/nologin
-| apache:x:48:48:Apache:/var/www:/sbin/nologin
-| avahi:x:70:70:Avahi daemon:/:/sbin/nologin
@@ -14156,25 +14459,22 @@ File: gawk.info, Node: Profiling, Prev: TCP/IP Networking, Up: Advanced Featu
==================================
You may produce execution traces of your `awk' programs. This is done
-with a specially compiled version of `gawk', called `pgawk' ("profiling
-`gawk'").
-
- `pgawk' is identical in every way to `gawk', except that when it has
-finished running, it creates a profile of your program in a file named
-`awkprof.out'. Because it is profiling, it also executes up to 45%
+by passing the option `--profile' to `gawk'. When `gawk' has finished
+running, it creates a profile of your program in a file named
+`awkprof.out'. Because it is profiling, it also executes up to 45%
slower than `gawk' normally does.
As shown in the following example, the `--profile' option can be
-used to change the name of the file where `pgawk' will write the
-profile:
+used to change the name of the file where `gawk' will write the profile:
- pgawk --profile=myprog.prof -f myprog.awk data1 data2
+ gawk --profile=myprog.prof -f myprog.awk data1 data2
-In the above example, `pgawk' places the profile in `myprog.prof'
+In the above example, `gawk' places the profile in `myprog.prof'
instead of in `awkprof.out'.
Here is a sample session showing a simple `awk' program, its input
-data, and the results from running `pgawk'. First, the `awk' program:
+data, and the results from running `gawk' with the `--profile' option.
+First, the `awk' program:
BEGIN { print "First BEGIN rule" }
@@ -14210,9 +14510,9 @@ data, and the results from running `pgawk'. First, the `awk' program:
foo
junk
- Here is the `awkprof.out' that results from running `pgawk' on this
-program and data (this example also illustrates that `awk' programmers
-sometimes have to work late):
+ Here is the `awkprof.out' that results from running the `gawk'
+profiler on this program and data (this example also illustrates that
+`awk' programmers sometimes have to work late):
# gawk profile, created Sun Aug 13 00:00:15 2000
@@ -14301,14 +14601,14 @@ output. They are as follows:
redirection. Similarly, if the target of a redirection isn't a
scalar, it gets parenthesized.
- * `pgawk' supplies leading comments in front of the `BEGIN' and
- `END' rules, the pattern/action rules, and the functions.
+ * `gawk' supplies leading comments in front of the `BEGIN' and `END'
+ rules, the pattern/action rules, and the functions.
The profiled version of your program may not look exactly like what
-you typed when you wrote it. This is because `pgawk' creates the
+you typed when you wrote it. This is because `gawk' creates the
profiled version by "pretty printing" its internal representation of
-the program. The advantage to this is that `pgawk' can produce a
+the program. The advantage to this is that `gawk' can produce a
standard representation. The disadvantage is that all source-code
comments are lost, as are the distinctions among multiple `BEGIN',
`END', `BEGINFILE', and `ENDFILE' rules. Also, things such as:
@@ -14323,21 +14623,23 @@ come out as:
which is correct, but possibly surprising.
- Besides creating profiles when a program has completed, `pgawk' can
+ Besides creating profiles when a program has completed, `gawk' can
produce a profile while it is running. This is useful if your `awk'
program goes into an infinite loop and you want to see what has been
-executed. To use this feature, run `pgawk' in the background:
+executed. To use this feature, run `gawk' with the `--profile' option
+in the background:
- $ pgawk -f myprog &
+ $ gawk --profile -f myprog &
[1] 13992
The shell prints a job number and process ID number; in this case,
-13992. Use the `kill' command to send the `USR1' signal to `pgawk':
+13992. Use the `kill' command to send the `USR1' signal to `gawk':
$ kill -USR1 13992
As usual, the profiled version of the program is written to
-`awkprof.out', or to a different file if you use the `--profile' option.
+`awkprof.out', or to a different file if one specified with the
+`--profile' option.
Along with the regular profile, as shown earlier, the profile
includes a trace of any active functions:
@@ -14349,22 +14651,22 @@ includes a trace of any active functions:
# 1. foo
# -- main --
- You may send `pgawk' the `USR1' signal as many times as you like.
+ You may send `gawk' the `USR1' signal as many times as you like.
Each time, the profile and function call trace are appended to the
output profile file.
- If you use the `HUP' signal instead of the `USR1' signal, `pgawk'
+ If you use the `HUP' signal instead of the `USR1' signal, `gawk'
produces the profile and the function call trace and then exits.
- When `pgawk' runs on MS-Windows systems, it uses the `INT' and
-`QUIT' signals for producing the profile and, in the case of the `INT'
-signal, `pgawk' exits. This is because these systems don't support the
-`kill' command, so the only signals you can deliver to a program are
-those generated by the keyboard. The `INT' signal is generated by the
+ When `gawk' runs on MS-Windows systems, it uses the `INT' and `QUIT'
+signals for producing the profile and, in the case of the `INT' signal,
+`gawk' exits. This is because these systems don't support the `kill'
+command, so the only signals you can deliver to a program are those
+generated by the keyboard. The `INT' signal is generated by the
`Ctrl-<C>' or `Ctrl-<BREAK>' key, while the `QUIT' signal is generated
by the `Ctrl-<\>' key.
- Finally, regular `gawk' also accepts the `--profile' option. When
+ Finally, `gawk' also accepts another option `--pretty-print'. When
called this way, `gawk' "pretty prints" the program into `awkprof.out',
without any execution counts.
@@ -14541,7 +14843,7 @@ programming use.
* Ordinal Functions:: Functions for using characters as numbers and
vice versa.
* Join Function:: A function to join an array into a string.
-* Gettimeofday Function:: A function to get formatted times.
+* Getlocaltime Function:: A function to get formatted times.

File: gawk.info, Node: Strtonum Function, Next: Assert Function, Up: General Functions
@@ -14887,7 +15189,7 @@ tests such as used here prohibitively expensive.
extensions, you can simplify `_ord_init' to loop from 0 to 255.

-File: gawk.info, Node: Join Function, Next: Gettimeofday Function, Prev: Ordinal Functions, Up: General Functions
+File: gawk.info, Node: Join Function, Next: Getlocaltime Function, Prev: Ordinal Functions, Up: General Functions
12.2.6 Merging an Array into a String
-------------------------------------
@@ -14934,7 +15236,7 @@ concatenation. The lack of an explicit operator for concatenation
makes string operations more difficult than they really need to be.

-File: gawk.info, Node: Gettimeofday Function, Prev: Join Function, Up: General Functions
+File: gawk.info, Node: Getlocaltime Function, Prev: Join Function, Up: General Functions
12.2.7 Managing the Time of Day
-------------------------------
@@ -14945,11 +15247,11 @@ with the time of day in human readable form. While `strftime()' is
extensive, the control formats are not necessarily easy to remember or
intuitively obvious when reading a program.
- The following function, `gettimeofday()', populates a user-supplied
+ The following function, `getlocaltime()', populates a user-supplied
array with preformatted time information. It returns a string with the
current time formatted in the same way as the `date' utility:
- # gettimeofday.awk --- get the time of day in a usable format
+ # getlocaltime.awk --- get the time of day in a usable format
# Returns a string in the format of output of date(1)
# Populates the array argument time with individual values:
@@ -14973,7 +15275,7 @@ current time formatted in the same way as the `date' utility:
# time["weeknum"] -- week number, Sunday first day
# time["altweeknum"] -- week number, Monday first day
- function gettimeofday(time, ret, now, i)
+ function getlocaltime(time, ret, now, i)
{
# get time once, avoids unnecessary system calls
now = systime()
@@ -15012,7 +15314,7 @@ current time formatted in the same way as the `date' utility:
The string indices are easier to use and read than the various
formats required by `strftime()'. The `alarm' program presented in
*note Alarm Program::, uses this function. A more general design for
-the `gettimeofday()' function would have allowed the user to supply an
+the `getlocaltime()' function would have allowed the user to supply an
optional timestamp value to use instead of the current time.

@@ -17443,8 +17745,8 @@ prints the message on the standard output. In addition, you can give it
the number of times to repeat the message as well as a delay between
repetitions.
- This program uses the `gettimeofday()' function from *note
-Gettimeofday Function::.
+ This program uses the `getlocaltime()' function from *note
+Getlocaltime Function::.
All the work is done in the `BEGIN' rule. The first part is argument
checking and setting of defaults: the delay, the count, and the message
@@ -17459,7 +17761,7 @@ Statement::), but the processing could be done with a series of
# alarm.awk --- set an alarm
#
- # Requires gettimeofday() library function
+ # Requires getlocaltime() library function
# usage: alarm time [ "message" [ count [ delay ] ] ]
BEGIN \
@@ -17515,7 +17817,7 @@ alarm:
minute = atime[2] + 0 # force numeric
# get current broken down time
- gettimeofday(now)
+ getlocaltime(now)
# if time given is 12-hour hours and it's after that
# hour, e.g., `alarm 5:30' at 9 a.m. means 5:30 p.m.,
@@ -18741,47 +19043,48 @@ supplies the following copyright terms:
We leave it to you to determine what the program does.

-File: gawk.info, Node: Debugger, Next: Language History, Prev: Sample Programs, Up: Top
+File: gawk.info, Node: Debugger, Next: Arbitrary Precision Arithmetic, Prev: Sample Programs, Up: Top
-14 `dgawk': The `awk' Debugger
-******************************
+14 Debugging `awk' Programs
+***************************
It would be nice if computer programs worked perfectly the first time
they were run, but in real life, this rarely happens for programs of
any complexity. Thus, most programming languages have facilities
available for "debugging" programs, and now `awk' is no exception.
- The `dgawk' debugger is purposely modeled after the GNU Debugger
+ The `gawk' debugger is purposely modeled after the GNU Debugger
(GDB) (http://www.gnu.org/software/gdb/) command-line debugger. If you
-are familiar with GDB, learning `dgawk' is easy.
+are familiar with GDB, learning how to use `gawk' for debugging your
+program is easy.
* Menu:
-* Debugging:: Introduction to `dgawk'.
-* Sample dgawk session:: Sample `dgawk' session.
-* List of Debugger Commands:: Main `dgawk' Commands.
-* Readline Support:: Readline Support.
-* Dgawk Limitations:: Limitations and future plans.
+* Debugging:: Introduction to `gawk' debugger.
+* Sample Debugging Session:: Sample debugging session.
+* List of Debugger Commands:: Main debugger commands.
+* Readline Support:: Readline support.
+* Limitations:: Limitations and future plans.

-File: gawk.info, Node: Debugging, Next: Sample dgawk session, Up: Debugger
+File: gawk.info, Node: Debugging, Next: Sample Debugging Session, Up: Debugger
-14.1 Introduction to `dgawk'
-============================
+14.1 Introduction to `gawk' Debugger
+====================================
This minor node introduces debugging in general and begins the
discussion of debugging in `gawk'.
* Menu:
-* Debugging Concepts:: Debugging In General.
+* Debugging Concepts:: Debugging in General.
* Debugging Terms:: Additional Debugging Concepts.
* Awk Debugging:: Awk Debugging.

File: gawk.info, Node: Debugging Concepts, Next: Debugging Terms, Up: Debugging
-14.1.1 Debugging In General
+14.1.1 Debugging in General
---------------------------
(If you have used debuggers in other languages, you may want to skip
@@ -18825,9 +19128,8 @@ File: gawk.info, Node: Debugging Terms, Next: Awk Debugging, Prev: Debugging
------------------------------------
Before diving in to the details, we need to introduce several important
-concepts that apply to just about all debuggers, including `dgawk'.
-The following list defines terms used throughout the rest of this
-major node.
+concepts that apply to just about all debuggers. The following list
+defines terms used throughout the rest of this major node.
"Stack Frame"
Programs generally call functions during the course of their
@@ -18845,11 +19147,11 @@ major node.
needed to manage the call stack. This data area is termed a
"stack frame".
- `gawk' also follows this model, and `dgawk' gives you access to
- the call stack and to each stack frame. You can see the call
- stack, as well as from where each function on the stack was
- invoked. Commands that print the call stack print information about
- each stack frame (as detailed later on).
+ `gawk' also follows this model, and gives you access to the call
+ stack and to each stack frame. You can see the call stack, as well
+ as from where each function on the stack was invoked. Commands
+ that print the call stack print information about each stack frame
+ (as detailed later on).
"Breakpoint"
During debugging, you often wish to let the program run until it
@@ -18894,54 +19196,57 @@ individual primitive instructions carried out by the higher-level `awk'
commands.

-File: gawk.info, Node: Sample dgawk session, Next: List of Debugger Commands, Prev: Debugging, Up: Debugger
+File: gawk.info, Node: Sample Debugging Session, Next: List of Debugger Commands, Prev: Debugging, Up: Debugger
-14.2 Sample `dgawk' session
-===========================
+14.2 Sample Debugging Session
+=============================
-In order to illustrate the use of `dgawk', let's look at a sample
-debugging session. We will use the `awk' implementation of the POSIX
-`uniq' command described earlier (*note Uniq Program::) as our example.
+In order to illustrate the use of `gawk' as a debugger, let's look at a
+sample debugging session. We will use the `awk' implementation of the
+POSIX `uniq' command described earlier (*note Uniq Program::) as our
+example.
* Menu:
-* dgawk invocation:: `dgawk' Invocation.
-* Finding The Bug:: Finding The Bug.
+* Debugger Invocation:: How to Start the Debugger.
+* Finding The Bug:: Finding the Bug.

-File: gawk.info, Node: dgawk invocation, Next: Finding The Bug, Up: Sample dgawk session
+File: gawk.info, Node: Debugger Invocation, Next: Finding The Bug, Up: Sample Debugging Session
-14.2.1 `dgawk' Invocation
--------------------------
+14.2.1 How to Start the Debugger
+--------------------------------
-Starting `dgawk' is exactly like running `awk'. The file(s) containing
-the program and any supporting code are given on the command line as
-arguments to one or more `-f' options. (`dgawk' is not designed to
-debug command-line programs, only programs contained in files.) In our
-case, we call `dgawk' like this:
+Starting the debugger is almost exactly like running `awk', except you
+have to pass an additional option `--debug' or the corresponding short
+option `-D'. The file(s) containing the program and any supporting
+code are given on the command line as arguments to one or more `-f'
+options. (`gawk' is not designed to debug command-line programs, only
+programs contained in files.) In our case, we invoke the debugger like
+this:
- $ dgawk -f getopt.awk -f join.awk -f uniq.awk inputfile
+ $ gawk -D -f getopt.awk -f join.awk -f uniq.awk inputfile
where both `getopt.awk' and `uniq.awk' are in `$AWKPATH'. (Experienced
users of GDB or similar debuggers should note that this syntax is
-slightly different from what they are used to. With `dgawk', the
-arguments for running the program are given in the command line to the
-debugger rather than as part of the `run' command at the debugger
+slightly different from what they are used to. With `gawk' debugger,
+the arguments for running the program are given in the command line to
+the debugger rather than as part of the `run' command at the debugger
prompt.)
Instead of immediately running the program on `inputfile', as `gawk'
-would ordinarily do, `dgawk' merely loads all the program source files,
-compiles them internally, and then gives us a prompt:
+would ordinarily do, the debugger merely loads all the program source
+files, compiles them internally, and then gives us a prompt:
- dgawk>
+ gawk>
from which we can issue commands to the debugger. At this point, no
code has been executed.

-File: gawk.info, Node: Finding The Bug, Prev: dgawk invocation, Up: Sample dgawk session
+File: gawk.info, Node: Finding The Bug, Prev: Debugger Invocation, Up: Sample Debugging Session
-14.2.2 Finding The Bug
+14.2.2 Finding the Bug
----------------------
Let's say that we are having a problem using (a faulty version of)
@@ -18971,27 +19276,27 @@ for a breakpoint in `uniq.awk' is at the beginning of the function
`are_equal()', which compares the current line with the previous one.
To set the breakpoint, use the `b' (breakpoint) command:
- dgawk> b are_equal
+ gawk> b are_equal
-| Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 64
The debugger tells us the file and line number where the breakpoint
is. Now type `r' or `run' and the program runs until it hits the
breakpoint for the first time:
- dgawk> r
+ gawk> r
-| Starting program:
-| Stopping in Rule ...
-| Breakpoint 1, are_equal(n, m, clast, cline, alast, aline)
at `awklib/eg/prog/uniq.awk':64
-| 64 if (fcount == 0 && charcount == 0)
- dgawk>
+ gawk>
Now we can look at what's going on inside our program. First of all,
let's see how we got to where we are. At the prompt, we type `bt'
-(short for "backtrace"), and `dgawk' responds with a listing of the
-current stack frames:
+(short for "backtrace"), and the debugger responds with a listing of
+the current stack frames:
- dgawk> bt
+ gawk> bt
-| #0 are_equal(n, m, clast, cline, alast, aline)
at `awklib/eg/prog/uniq.awk':69
-| #1 in main() at `awklib/eg/prog/uniq.awk':89
@@ -19005,9 +19310,9 @@ the key to finding the source of the problem.)
Now that we're in `are_equal()', we can start looking at the values
of some variables. Let's say we type `p n' (`p' is short for "print").
We would expect to see the value of `n', a parameter to `are_equal()'.
-Actually, `dgawk' gives us:
+Actually, the debugger gives us:
- dgawk> p n
+ gawk> p n
-| n = untyped variable
In this case, `n' is an uninitialized local variable, since the
@@ -19015,13 +19320,13 @@ function was called without arguments (*note Function Calls::).
A more useful variable to display might be the current record:
- dgawk> p $0
+ gawk> p $0
-| $0 = string ("gawk is a wonderful program!")
This might be a bit puzzling at first since this is the second line of
our test input above. Let's look at `NR':
- dgawk> p NR
+ gawk> p NR
-| NR = number (2)
So we can see that `are_equal()' was only called for the second record
@@ -19035,7 +19340,7 @@ for `NR == 1':
OK, let's just check that that rule worked correctly:
- dgawk> p last
+ gawk> p last
-| last = string ("awk is a wonderful program!")
Everything we have done so far has verified that the program has
@@ -19044,7 +19349,7 @@ the problem must be inside this function. To investigate further, we
must begin "stepping through" the lines of `are_equal()'. We start by
typing `n' (for "next"):
- dgawk> n
+ gawk> n
-| 67 if (fcount > 0) {
This tells us that `gawk' is now ready to execute line 67, which
@@ -19060,15 +19365,15 @@ was false.)
Continuing to step, we now get to the splitting of the current and
last records:
- dgawk> n
+ gawk> n
-| 68 n = split(last, alast)
- dgawk> n
+ gawk> n
-| 69 m = split($0, aline)
At this point, we should be curious to see what our records were
split into, so we try to look:
- dgawk> p n m alast aline
+ gawk> p n m alast aline
-| n = number (5)
-| m = number (5)
-| alast = array, 5 elements
@@ -19084,19 +19389,19 @@ want to see inside the array?
The first choice would be to use subscripts:
- dgawk> p alast[0]
+ gawk> p alast[0]
-| "0" not in array `alast'
Oops!
- dgawk> p alast[1]
+ gawk> p alast[1]
-| alast["1"] = string ("awk")
- This would be kind of slow for a 100-member array, though, so
-`dgawk' provides a shortcut (reminiscent of another language not to be
+ This would be kind of slow for a 100-member array, though, so `gawk'
+provides a shortcut (reminiscent of another language not to be
mentioned):
- dgawk> p @alast
+ gawk> p @alast
-| alast["1"] = string ("awk")
-| alast["2"] = string ("is")
-| alast["3"] = string ("a")
@@ -19105,9 +19410,9 @@ mentioned):
It looks like we got this far OK. Let's take another step or two:
- dgawk> n
+ gawk> n
-| 70 clast = join(alast, fcount, n)
- dgawk> n
+ gawk> n
-| 71 cline = join(aline, fcount, m)
Well, here we are at our error (sorry to spoil the suspense). What
@@ -19115,7 +19420,7 @@ we had in mind was to join the fields starting from the second one to
make the virtual record to compare, and if the first field was numbered
zero, this would work. Let's look at what we've got:
- dgawk> p cline clast
+ gawk> p cline clast
-| cline = string ("gawk is a wonderful program!")
-| clast = string ("awk is a wonderful program!")
@@ -19123,9 +19428,9 @@ zero, this would work. Let's look at what we've got:
unaltered, input records. A little thinking (the human brain is still
the best debugging tool), and we realize that we were off by one!
- We get out of `dgawk':
+ We get out of the debugger:
- dgawk> q
+ gawk> q
-| The program is running. Exit anyway (y/n)? y
Then we get into an editor:
@@ -19136,12 +19441,13 @@ Then we get into an editor:
and problem solved!

-File: gawk.info, Node: List of Debugger Commands, Next: Readline Support, Prev: Sample dgawk session, Up: Debugger
+File: gawk.info, Node: List of Debugger Commands, Next: Readline Support, Prev: Sample Debugging Session, Up: Debugger
-14.3 Main `dgawk' Commands
-==========================
+14.3 Main Debugger Commands
+===========================
-The `dgawk' command set can be divided into the following categories:
+The `gawk' debugger command set can be divided into the following
+categories:
* Breakpoint control
@@ -19157,26 +19463,26 @@ The `dgawk' command set can be divided into the following categories:
Each of these are discussed in the following subsections. In the
following descriptions, commands which may be abbreviated show the
-abbreviation on a second description line. A `dgawk' command name may
-also be truncated if that partial name is unambiguous. `dgawk' has the
-built-in capability to automatically repeat the previous command when
-just hitting <Enter>. This works for the commands `list', `next',
+abbreviation on a second description line. A debugger command name may
+also be truncated if that partial name is unambiguous. The debugger has
+the built-in capability to automatically repeat the previous command
+when just hitting <Enter>. This works for the commands `list', `next',
`nexti', `step', `stepi' and `continue' executed without any argument.
* Menu:
-* Breakpoint Control:: Control of breakpoints.
-* Dgawk Execution Control:: Control of execution.
-* Viewing And Changing Data:: Viewing and changing data.
-* Dgawk Stack:: Dealing with the stack.
-* Dgawk Info:: Obtaining information about the program and
- the debugger state.
-* Miscellaneous Dgawk Commands:: Miscellaneous Commands.
+* Breakpoint Control:: Control of Breakpoints.
+* Debugger Execution Control:: Control of Execution.
+* Viewing And Changing Data:: Viewing and Changing Data.
+* Execution Stack:: Dealing with the Stack.
+* Debugger Info:: Obtaining Information about the Program and
+ the Debugger State.
+* Miscellaneous Debugger Commands:: Miscellaneous Commands.

-File: gawk.info, Node: Breakpoint Control, Next: Dgawk Execution Control, Up: List of Debugger Commands
+File: gawk.info, Node: Breakpoint Control, Next: Debugger Execution Control, Up: List of Debugger Commands
-14.3.1 Control Of Breakpoints
+14.3.1 Control of Breakpoints
-----------------------------
As we saw above, the first thing you probably want to do in a debugging
@@ -19204,10 +19510,10 @@ controlling breakpoints are:
it from the breakpoint list using the `delete' command.
With a breakpoint, you may also supply a condition. This is an
- `awk' expression (enclosed in double quotes) that `dgawk'
+ `awk' expression (enclosed in double quotes) that the debugger
evaluates whenever the breakpoint is reached. If the condition is
- true, then `dgawk' stops execution and prompts for a command.
- Otherwise, `dgawk' continues executing the program.
+ true, then the debugger stops execution and prompts for a command.
+ Otherwise, it continues executing the program.
`clear' [[FILENAME`:']N | FUNCTION]
Without any argument, delete any breakpoint at the next instruction
@@ -19229,12 +19535,13 @@ controlling breakpoints are:
`condition' N `"EXPRESSION"'
Add a condition to existing breakpoint or watchpoint N. The
- condition is an `awk' expression that `dgawk' evaluates whenever
- the breakpoint or watchpoint is reached. If the condition is true,
- then `dgawk' stops execution and prompts for a command. Otherwise,
- `dgawk' continues executing the program. If the condition
- expression is not specified, any existing condition is removed;
- i.e., the breakpoint or watchpoint is made unconditional.
+ condition is an `awk' expression that the debugger evaluates
+ whenever the breakpoint or watchpoint is reached. If the condition
+ is true, then the debugger stops execution and prompts for a
+ command. Otherwise, the debugger continues executing the program.
+ If the condition expression is not specified, any existing
+ condition is removed; i.e., the breakpoint or watchpoint is made
+ unconditional.
`delete' [N1 N2 ...] [N-M]
`d' [N1 N2 ...] [N-M]
@@ -19268,7 +19575,7 @@ controlling breakpoints are:
arguments are the same as for `break'.

-File: gawk.info, Node: Dgawk Execution Control, Next: Viewing And Changing Data, Prev: Breakpoint Control, Up: List of Debugger Commands
+File: gawk.info, Node: Debugger Execution Control, Next: Viewing And Changing Data, Prev: Breakpoint Control, Up: List of Debugger Commands
14.3.2 Control of Execution
---------------------------
@@ -19291,14 +19598,14 @@ execution of the program than we saw in our earlier example:
`continue') terminates the list (an implicit `end'), and
subsequent commands are ignored. For example:
- dgawk> commands
+ gawk> commands
> silent
> printf "A silent breakpoint; i = %d\n", i
> info locals
> set i = 10
> continue
> end
- dgawk>
+ gawk>
`continue' [COUNT]
`c' [COUNT]
@@ -19331,9 +19638,9 @@ execution of the program than we saw in our earlier example:
`run'
`r'
- Start/restart execution of the program. When restarting, `dgawk'
- retains the current breakpoints, watchpoints, command history,
- automatic display variables, and debugger options.
+ Start/restart execution of the program. When restarting, the
+ debugger retains the current breakpoints, watchpoints, command
+ history, automatic display variables, and debugger options.
`step' [COUNT]
`s' [COUNT]
@@ -19348,7 +19655,7 @@ execution of the program than we saw in our earlier example:
Execute one (or COUNT) instruction(s), stepping inside function
calls. (For illustration of what is meant by an "instruction" in
`gawk', see the output shown under `dump' in *note Miscellaneous
- Dgawk Commands::.)
+ Debugger Commands::.)
`until' [[FILENAME`:']N | FUNCTION]
`u' [[FILENAME`:']N | FUNCTION]
@@ -19358,7 +19665,7 @@ execution of the program than we saw in our earlier example:
current stack frame returns.

-File: gawk.info, Node: Viewing And Changing Data, Next: Dgawk Stack, Prev: Dgawk Execution Control, Up: List of Debugger Commands
+File: gawk.info, Node: Viewing And Changing Data, Next: Execution Stack, Prev: Debugger Execution Control, Up: List of Debugger Commands
14.3.3 Viewing and Changing Data
--------------------------------
@@ -19370,7 +19677,7 @@ The commands for viewing and changing variables inside of `gawk' are:
of the variable or field is displayed each time the program stops.
Each variable added to the list is identified by a unique number:
- dgawk> display x
+ gawk> display x
-| 10: x = 1
displays the assigned item number, the variable name and its
@@ -19398,7 +19705,7 @@ AWK STATEMENTS
Print the value of a `gawk' variable or field. Fields must be
referenced by constants:
- dgawk> print $3
+ gawk> print $3
This prints the third field in the input record (if the specified
field does not exist, it prints `Null field'). A variable can be
@@ -19426,16 +19733,16 @@ AWK STATEMENTS
`watch' VAR | `$'N [`"EXPRESSION"']
`w' VAR | `$'N [`"EXPRESSION"']
- Add variable VAR (or field `$N') to the watch list. `dgawk' then
- stops whenever the value of the variable or field changes. Each
- watched item is assigned a number which can be used to delete it
- from the watch list using the `unwatch' command.
+ Add variable VAR (or field `$N') to the watch list. The debugger
+ then stops whenever the value of the variable or field changes.
+ Each watched item is assigned a number which can be used to delete
+ it from the watch list using the `unwatch' command.
With a watchpoint, you may also supply a condition. This is an
- `awk' expression (enclosed in double quotes) that `dgawk'
+ `awk' expression (enclosed in double quotes) that the debugger
evaluates whenever the watchpoint is reached. If the condition is
- true, then `dgawk' stops execution and prompts for a command.
- Otherwise, `dgawk' continues executing the program.
+ true, then the debugger stops execution and prompts for a command.
+ Otherwise, `gawk' continues executing the program.
`undisplay' [N]
Remove item number N (or all items, if no argument) from the
@@ -19447,9 +19754,9 @@ AWK STATEMENTS

-File: gawk.info, Node: Dgawk Stack, Next: Dgawk Info, Prev: Viewing And Changing Data, Up: List of Debugger Commands
+File: gawk.info, Node: Execution Stack, Next: Debugger Info, Prev: Viewing And Changing Data, Up: List of Debugger Commands
-14.3.4 Dealing With The Stack
+14.3.4 Dealing with the Stack
-----------------------------
Whenever you run a program which contains any function calls, `gawk'
@@ -19484,16 +19791,17 @@ are:
frame. Then select and print the frame.

-File: gawk.info, Node: Dgawk Info, Next: Miscellaneous Dgawk Commands, Prev: Dgawk Stack, Up: List of Debugger Commands
+File: gawk.info, Node: Debugger Info, Next: Miscellaneous Debugger Commands, Prev: Execution Stack, Up: List of Debugger Commands
-14.3.5 Obtaining Information About The Program and The Debugger State
+14.3.5 Obtaining Information about the Program and the Debugger State
---------------------------------------------------------------------
Besides looking at the values of variables, there is often a need to get
other sorts of information about the state of your program and of the
-debugging environment itself. `dgawk' has one command which provides
-this information, appropriately called `info'. `info' is used with one
-of a number of arguments that tell it exactly what you want to know:
+debugging environment itself. The `gawk' debugger has one command which
+provides this information, appropriately called `info'. `info' is used
+with one of a number of arguments that tell it exactly what you want to
+know:
`info' WHAT
`i' WHAT
@@ -19521,10 +19829,10 @@ of a number of arguments that tell it exactly what you want to know:
`source'
The name of the current source file. Each time the program
stops, the current source file is the file containing the
- current instruction. When `dgawk' first starts, the current
- source file is the first file included via the `-f' option.
- The `list FILENAME:LINENO' command can be used at any time to
- change the current source.
+ current instruction. When the debugger first starts, the
+ current source file is the first file included via the `-f'
+ option. The `list FILENAME:LINENO' command can be used at any
+ time to change the current source.
`sources'
List all program sources.
@@ -19548,7 +19856,7 @@ from a file. The commands are:
`history_size'
The maximum number of lines to keep in the history file
- `./.dgawk_history'. The default is 100.
+ `./.gawk_history'. The default is 100.
`listsize'
The number of lines that `list' prints. The default is 15.
@@ -19559,14 +19867,14 @@ from a file. The commands are:
standard output.
`prompt'
- The debugger prompt. The default is `dgawk> '.
+ The debugger prompt. The default is `gawk> '.
`save_history [on | off]'
- Save command history to file `./.dgawk_history'. The default
+ Save command history to file `./.gawk_history'. The default
is `on'.
`save_options [on | off]'
- Save current options to file `./.dgawkrc' upon exit. The
+ Save current options to file `./.gawkrc' upon exit. The
default is `on'. Options are read back in to the next
session upon startup.
@@ -19584,15 +19892,15 @@ from a file. The commands are:
ignored; they do _not_ repeat the last command. You can't restart
the program by having more than one `run' command in the file.
Also, the list of commands may include additional `source'
- commands; however, `dgawk' will not source the same file more than
- once in order to avoid infinite recursion.
+ commands; however, the `gawk' debugger will not source the same
+ file more than once in order to avoid infinite recursion.
In addition to, or instead of the `source' command, you can use
- the `-R FILE' or `--command=FILE' command-line options to execute
+ the `-D FILE' or `--debug=FILE' command-line options to execute
commands from a file non-interactively (*note Options::.

-File: gawk.info, Node: Miscellaneous Dgawk Commands, Prev: Dgawk Info, Up: List of Debugger Commands
+File: gawk.info, Node: Miscellaneous Debugger Commands, Prev: Debugger Info, Up: List of Debugger Commands
14.3.6 Miscellaneous Commands
-----------------------------
@@ -19608,7 +19916,7 @@ categories, as follows:
partial dump of Davide Brini's obfuscated code (*note Signature
Program::) demonstrates:
- dgawk> dump
+ gawk> dump
-| # BEGIN
-|
-| [ 2:0x89faef4] Op_rule : [in_rule = BEGIN] [source_file = brini.awk]
@@ -19657,13 +19965,13 @@ categories, as follows:
-| [ :0x89fa3b0] Op_after_beginfile :
-| [ :0x89fa388] Op_no_op :
-| [ :0x89fa3c4] Op_after_endfile :
- dgawk>
+ gawk>
`help'
`h'
- Print a list of all of the `dgawk' commands with a short summary
- of their usage. `help COMMAND' prints the information about the
- command COMMAND.
+ Print a list of all of the `gawk' debugger commands with a short
+ summary of their usage. `help COMMAND' prints the information
+ about the command COMMAND.
`list' [`-' | `+' | N | FILENAME`:'N | N-M | FUNCTION]
`l' [`-' | `+' | N | FILENAME`:'N | N-M | FUNCTION]
@@ -19697,7 +20005,7 @@ categories, as follows:
Exit the debugger. Debugging is great fun, but sometimes we all
have to tend to other obligations in life, and sometimes we find
the bug, and are free to go on to the next one! As we saw above,
- if you are running a program, `dgawk' warns you if you
+ if you are running a program, the debugger warns you if you
accidentally type `q' or `quit', to make sure you really want to
quit.
@@ -19712,12 +20020,12 @@ categories, as follows:

-File: gawk.info, Node: Readline Support, Next: Dgawk Limitations, Prev: List of Debugger Commands, Up: Debugger
+File: gawk.info, Node: Readline Support, Next: Limitations, Prev: List of Debugger Commands, Up: Debugger
14.4 Readline Support
=====================
-If `dgawk' is compiled with the `readline' library, you can take
+If `gawk' is compiled with the `readline' library, you can take
advantage of that library's command completion and history expansion
features. The following types of completion are available:
@@ -19739,27 +20047,27 @@ Variable name completion

-File: gawk.info, Node: Dgawk Limitations, Prev: Readline Support, Up: Debugger
+File: gawk.info, Node: Limitations, Prev: Readline Support, Up: Debugger
14.5 Limitations and Future Plans
=================================
-We hope you find `dgawk' useful and enjoyable to work with, but as with
-any program, especially in its early releases, it still has some
-limitations. A few which are worth being aware of are:
+We hope you find the `gawk' debugger useful and enjoyable to work with,
+but as with any program, especially in its early releases, it still has
+some limitations. A few which are worth being aware of are:
- * At this point, `dgawk' does not give a detailed explanation of
+ * At this point, the debugger does not give a detailed explanation of
what you did wrong when you type in something it doesn't like.
Rather, it just responds `syntax error'. When you do figure out
what your mistake was, though, you'll feel like a real guru.
- * If you perused the dump of opcodes in *note Miscellaneous Dgawk
+ * If you perused the dump of opcodes in *note Miscellaneous Debugger
Commands::, (or if you are already familiar with `gawk' internals),
you will realize that much of the internal manipulation of data in
`gawk', as in many interpreters, is done on a stack. `Op_push',
`Op_pop', etc., are the "bread and butter" of most `gawk' code.
- Unfortunately, as of now, `dgawk' does not allow you to examine
- the stack's contents.
+ Unfortunately, as of now, the `gawk' debugger does not allow you
+ to examine the stack's contents.
That is, the intermediate results of expression evaluation are on
the stack, but cannot be printed. Rather, only variables which
@@ -19772,20 +20080,1474 @@ limitations. A few which are worth being aware of are:
expressions to see if you got it right. As an `awk' programmer,
you are expected to know what `/[^[:alnum:][:blank:]]/' means.
- * `dgawk' is designed to be used by running a program (with all its
- parameters) on the command line, as described in *note dgawk
- invocation::. There is no way (as of now) to attach or "break in"
- to a running program. This seems reasonable for a language which
- is used mainly for quickly executing, short programs.
+ * The `gawk' debugger is designed to be used by running a program
+ (with all its parameters) on the command line, as described in
+ *note Debugger Invocation::. There is no way (as of now) to
+ attach or "break in" to a running program. This seems reasonable
+ for a language which is used mainly for quickly executing, short
+ programs.
- * `dgawk' only accepts source supplied with the `-f' option.
+ * The `gawk' debugger only accepts source supplied with the `-f'
+ option.
Look forward to a future release when these and other missing
features may be added, and of course feel free to try to add them
yourself!

-File: gawk.info, Node: Language History, Next: Installation, Prev: Debugger, Up: Top
+File: gawk.info, Node: Arbitrary Precision Arithmetic, Next: Dynamic Extensions, Prev: Debugger, Up: Top
+
+15 Arithmetic and Arbitrary Precision Arithmetic with `gawk'
+************************************************************
+
+ There's a credibility gap: We don't know how much of the
+ computer's answers to believe. Novice computer users solve this
+ problem by implicitly trusting in the computer as an infallible
+ authority; they tend to believe that all digits of a printed
+ answer are significant. Disillusioned computer users have just the
+ opposite approach; they are constantly afraid that their answers
+ are almost meaningless.
+ Donald Knuth(1)
+
+ This major node discusses issues that you may encounter when
+performing arithmetic. It begins by discussing some of the general
+attributes of computer arithmetic, along with how this can influence
+what you see when running `awk' programs. This discussion applies to
+all versions of `awk'.
+
+ Then the major node moves on to "arbitrary precision arithmetic", a
+feature which is specific to `gawk'.
+
+* Menu:
+
+* General Arithmetic:: An introduction to computer arithmetic.
+* Floating-point Programming:: Effective Floating-point Programming.
+* Gawk and MPFR:: How `gawk' provides
+ arbitrary-precision arithmetic.
+* Arbitrary Precision Floats:: Arbitrary Precision Floating-point Arithmetic
+ with `gawk'.
+* Arbitrary Precision Integers:: Arbitrary Precision Integer Arithmetic with
+ `gawk'.
+
+ ---------- Footnotes ----------
+
+ (1) Donald E. Knuth. `The Art of Computer Programming'. Volume 2,
+`Seminumerical Algorithms', third edition, 1998, ISBN 0-201-89683-4, p.
+229.
+
+
+File: gawk.info, Node: General Arithmetic, Next: Floating-point Programming, Up: Arbitrary Precision Arithmetic
+
+15.1 A General Description of Computer Arithmetic
+=================================================
+
+Within computers, there are two kinds of numeric values: "integers" and
+"floating-point". In school, integer values were referred to as
+"whole" numbers--that is, numbers without any fractional part, such as
+1, 42, or -17. The advantage to integer numbers is that they represent
+values exactly. The disadvantage is that their range is limited. On
+most systems, this range is -2,147,483,648 to 2,147,483,647. However,
+many systems now support a range from -9,223,372,036,854,775,808 to
+9,223,372,036,854,775,807.
+
+ Integer values come in two flavors: "signed" and "unsigned". Signed
+values may be negative or positive, with the range of values just
+described. Unsigned values are always positive. On most systems, the
+range is from 0 to 4,294,967,295. However, many systems now support a
+range from 0 to 18,446,744,073,709,551,615.
+
+ Floating-point numbers represent what are called "real" numbers;
+i.e., those that do have a fractional part, such as 3.1415927. The
+advantage to floating-point numbers is that they can represent a much
+larger range of values. The disadvantage is that there are numbers
+that they cannot represent exactly. `awk' uses "double precision"
+floating-point numbers, which can hold more digits than "single
+precision" floating-point numbers.
+
+ There a several important issues to be aware of, described next.
+
+* Menu:
+
+* Floating Point Issues:: Stuff to know about floating-point numbers.
+* Integer Programming:: Effective integer programming.
+
+
+File: gawk.info, Node: Floating Point Issues, Next: Integer Programming, Up: General Arithmetic
+
+15.1.1 Floating-Point Number Caveats
+------------------------------------
+
+This minor node describes some of the issues involved in using
+floating-point numbers.
+
+ There is a very nice paper on floating-point arithmetic
+(http://www.validlab.com/goldberg/paper.pdf) by David Goldberg, "What
+Every Computer Scientist Should Know About Floating-point Arithmetic,"
+`ACM Computing Surveys' *23*, 1 (1991-03), 5-48. This is worth reading
+if you are interested in the details, but it does require a background
+in computer science.
+
+* Menu:
+
+* String Conversion Precision:: The String Value Can Lie.
+* Unexpected Results:: Floating Point Numbers Are Not Abstract
+ Numbers.
+* POSIX Floating Point Problems:: Standards Versus Existing Practice.
+
+
+File: gawk.info, Node: String Conversion Precision, Next: Unexpected Results, Up: Floating Point Issues
+
+15.1.1.1 The String Value Can Lie
+.................................
+
+Internally, `awk' keeps both the numeric value (double precision
+floating-point) and the string value for a variable. Separately, `awk'
+keeps track of what type the variable has (*note Typing and
+Comparison::), which plays a role in how variables are used in
+comparisons.
+
+ It is important to note that the string value for a number may not
+reflect the full value (all the digits) that the numeric value actually
+contains. The following program (`values.awk') illustrates this:
+
+ {
+ sum = $1 + $2
+ # see it for what it is
+ printf("sum = %.12g\n", sum)
+ # use CONVFMT
+ a = "<" sum ">"
+ print "a =", a
+ # use OFMT
+ print "sum =", sum
+ }
+
+This program shows the full value of the sum of `$1' and `$2' using
+`printf', and then prints the string values obtained from both
+automatic conversion (via `CONVFMT') and from printing (via `OFMT').
+
+ Here is what happens when the program is run:
+
+ $ echo 3.654321 1.2345678 | awk -f values.awk
+ -| sum = 4.8888888
+ -| a = <4.88889>
+ -| sum = 4.88889
+
+ This makes it clear that the full numeric value is different from
+what the default string representations show.
+
+ `CONVFMT''s default value is `"%.6g"', which yields a value with at
+least six significant digits. For some applications, you might want to
+change it to specify more precision. On most modern machines, most of
+the time, 17 digits is enough to capture a floating-point number's
+value exactly.(1)
+
+ ---------- Footnotes ----------
+
+ (1) Pathological cases can require up to 752 digits (!), but we
+doubt that you need to worry about this.
+
+
+File: gawk.info, Node: Unexpected Results, Next: POSIX Floating Point Problems, Prev: String Conversion Precision, Up: Floating Point Issues
+
+15.1.1.2 Floating Point Numbers Are Not Abstract Numbers
+........................................................
+
+Unlike numbers in the abstract sense (such as what you studied in high
+school or college arithmetic), numbers stored in computers are limited
+in certain ways. They cannot represent an infinite number of digits,
+nor can they always represent things exactly. In particular,
+floating-point numbers cannot always represent values exactly. Here is
+an example:
+
+ $ awk '{ printf("%010d\n", $1 * 100) }'
+ 515.79
+ -| 0000051579
+ 515.80
+ -| 0000051579
+ 515.81
+ -| 0000051580
+ 515.82
+ -| 0000051582
+ Ctrl-d
+
+This shows that some values can be represented exactly, whereas others
+are only approximated. This is not a "bug" in `awk', but simply an
+artifact of how computers represent numbers.
+
+ NOTE: It cannot be emphasized enough that the behavior just
+ described is fundamental to modern computers. You will see this
+ kind of thing happen in _any_ programming language using hardware
+ floating-point numbers. It is _not_ a bug in `gawk', nor is it
+ something that can be "just fixed."
+
+ Another peculiarity of floating-point numbers on modern systems is
+that they often have more than one representation for the number zero!
+In particular, it is possible to represent "minus zero" as well as
+regular, or "positive" zero.
+
+ This example shows that negative and positive zero are distinct
+values when stored internally, but that they are in fact equal to each
+other, as well as to "regular" zero:
+
+ $ gawk 'BEGIN { mz = -0 ; pz = 0
+ > printf "-0 = %g, +0 = %g, (-0 == +0) -> %d\n", mz, pz, mz == pz
+ > printf "mz == 0 -> %d, pz == 0 -> %d\n", mz == 0, pz == 0
+ > }'
+ -| -0 = -0, +0 = 0, (-0 == +0) -> 1
+ -| mz == 0 -> 1, pz == 0 -> 1
+
+ It helps to keep this in mind should you process numeric data that
+contains negative zero values; the fact that the zero is negative is
+noted and can affect comparisons.
+
+
+File: gawk.info, Node: POSIX Floating Point Problems, Prev: Unexpected Results, Up: Floating Point Issues
+
+15.1.1.3 Standards Versus Existing Practice
+...........................................
+
+Historically, `awk' has converted any non-numeric looking string to the
+numeric value zero, when required. Furthermore, the original
+definition of the language and the original POSIX standards specified
+that `awk' only understands decimal numbers (base 10), and not octal
+(base 8) or hexadecimal numbers (base 16).
+
+ Changes in the language of the 2001 and 2004 POSIX standards can be
+interpreted to imply that `awk' should support additional features.
+These features are:
+
+ * Interpretation of floating point data values specified in
+ hexadecimal notation (`0xDEADBEEF'). (Note: data values, _not_
+ source code constants.)
+
+ * Support for the special IEEE 754 floating point values "Not A
+ Number" (NaN), positive Infinity ("inf") and negative Infinity
+ ("-inf"). In particular, the format for these values is as
+ specified by the ISO 1999 C standard, which ignores case and can
+ allow machine-dependent additional characters after the `nan' and
+ allow either `inf' or `infinity'.
+
+ The first problem is that both of these are clear changes to
+historical practice:
+
+ * The `gawk' maintainer feels that supporting hexadecimal floating
+ point values, in particular, is ugly, and was never intended by the
+ original designers to be part of the language.
+
+ * Allowing completely alphabetic strings to have valid numeric
+ values is also a very severe departure from historical practice.
+
+ The second problem is that the `gawk' maintainer feels that this
+interpretation of the standard, which requires a certain amount of
+"language lawyering" to arrive at in the first place, was not even
+intended by the standard developers. In other words, "we see how you
+got where you are, but we don't think that that's where you want to be."
+
+ Recognizing the above issues, but attempting to provide compatibility
+with the earlier versions of the standard, the 2008 POSIX standard
+added explicit wording to allow, but not require, that `awk' support
+hexadecimal floating point values and special values for "Not A Number"
+and infinity.
+
+ Although the `gawk' maintainer continues to feel that providing
+those features is inadvisable, nevertheless, on systems that support
+IEEE floating point, it seems reasonable to provide _some_ way to
+support NaN and Infinity values. The solution implemented in `gawk' is
+as follows:
+
+ * With the `--posix' command-line option, `gawk' becomes "hands
+ off." String values are passed directly to the system library's
+ `strtod()' function, and if it successfully returns a numeric
+ value, that is what's used.(1) By definition, the results are not
+ portable across different systems. They are also a little
+ surprising:
+
+ $ echo nanny | gawk --posix '{ print $1 + 0 }'
+ -| nan
+ $ echo 0xDeadBeef | gawk --posix '{ print $1 + 0 }'
+ -| 3735928559
+
+ * Without `--posix', `gawk' interprets the four strings `+inf',
+ `-inf', `+nan', and `-nan' specially, producing the corresponding
+ special numeric values. The leading sign acts a signal to `gawk'
+ (and the user) that the value is really numeric. Hexadecimal
+ floating point is not supported (unless you also use
+ `--non-decimal-data', which is _not_ recommended). For example:
+
+ $ echo nanny | gawk '{ print $1 + 0 }'
+ -| 0
+ $ echo +nan | gawk '{ print $1 + 0 }'
+ -| nan
+ $ echo 0xDeadBeef | gawk '{ print $1 + 0 }'
+ -| 0
+
+ `gawk' does ignore case in the four special values. Thus `+nan'
+ and `+NaN' are the same.
+
+ ---------- Footnotes ----------
+
+ (1) You asked for it, you got it.
+
+
+File: gawk.info, Node: Integer Programming, Prev: Floating Point Issues, Up: General Arithmetic
+
+15.1.2 Mixing Integers And Floating-point
+-----------------------------------------
+
+As has been mentioned already, `gawk' ordinarily uses hardware double
+precision with 64-bit IEEE binary floating-point representation for
+numbers on most systems. A large integer like 9,007,199,254,740,997 has
+a binary representation that, although finite, is more than 53 bits
+long; it must also be rounded to 53 bits. The biggest integer that can
+be stored in a C `double' is usually the same as the largest possible
+value of a `double'. If your system `double' is an IEEE 64-bit
+`double', this largest possible value is an integer and can be
+represented precisely. What more should one know about integers?
+
+ If you want to know what is the largest integer, such that it and
+all smaller integers can be stored in 64-bit doubles without losing
+precision, then the answer is 2^53. The next representable number is
+the even number 2^53 + 2, meaning it is unlikely that you will be able
+to make `gawk' print 2^53 + 1 in integer format. The range of integers
+exactly representable by a 64-bit double is [-2^53, 2^53]. If you ever
+see an integer outside this range in `gawk' using 64-bit doubles, you
+have reason to be very suspicious about the accuracy of the output.
+Here is a simple program with erroneous output:
+
+ $ gawk 'BEGIN { i = 2^53 - 1; for (j = 0; j < 4; j++) print i + j }'
+ -| 9007199254740991
+ -| 9007199254740992
+ -| 9007199254740992
+ -| 9007199254740994
+
+ The lesson is to not assume that any large integer printed by `gawk'
+represents an exact result from your computation, especially if it wraps
+around on your screen.
+
+
+File: gawk.info, Node: Floating-point Programming, Next: Gawk and MPFR, Prev: General Arithmetic, Up: Arbitrary Precision Arithmetic
+
+15.2 Understanding Floating-point Programming
+=============================================
+
+Numerical programming is an extensive area; if you need to develop
+sophisticated numerical algorithms then `gawk' may not be the ideal
+tool, and this documentation may not be sufficient. It might require
+digesting a book or two to really internalize how to compute with ideal
+accuracy and precision, and the result often depends on the particular
+application.
+
+ NOTE: A floating-point calculation's "accuracy" is how close it
+ comes to the real value. This is as opposed to the "precision",
+ which usually refers to the number of bits used to represent the
+ number (see the Wikipedia article
+ (http://en.wikipedia.org/wiki/Accuracy_and_precision) for more
+ information).
+
+ There are two options for doing floating-point calculations:
+hardware floating-point (as used by standard `awk' and the default for
+`gawk'), and "arbitrary-precision" floating-point, which is software
+based. From this point forward, this major node aims to provide enough
+information to understand both, and then will focus on `gawk''s
+facilities for the latter.(1)
+
+ Binary floating-point representations and arithmetic are inexact.
+Simple values like 0.1 cannot be precisely represented using binary
+floating-point numbers, and the limited precision of floating-point
+numbers means that slight changes in the order of operations or the
+precision of intermediate storage can change the result. To make
+matters worse, with arbitrary precision floating-point, you can set the
+precision before starting a computation, but then you cannot be sure of
+the number of significant decimal places in the final result.
+
+ Sometimes, before you start to write any code, you should think more
+about what you really want and what's really happening. Consider the
+two numbers in the following example:
+
+ x = 0.875 # 1/2 + 1/4 + 1/8
+ y = 0.425
+
+ Unlike the number in `y', the number stored in `x' is exactly
+representable in binary since it can be written as a finite sum of one
+or more fractions whose denominators are all powers of two. When
+`gawk' reads a floating-point number from program source, it
+automatically rounds that number to whatever precision your machine
+supports. If you try to print the numeric content of a variable using
+an output format string of `"%.17g"', it may not produce the same
+number as you assigned to it:
+
+ $ gawk 'BEGIN { x = 0.875; y = 0.425
+ > printf("%0.17g, %0.17g\n", x, y) }'
+ -| 0.875, 0.42499999999999999
+
+ Often the error is so small you do not even notice it, and if you do,
+you can always specify how much precision you would like in your output.
+Usually this is a format string like `"%.15g"', which when used in the
+previous example, produces an output identical to the input.
+
+ Because the underlying representation can be a little bit off from
+the exact value, comparing floating-point values to see if they are
+equal is generally not a good idea. Here is an example where it does
+not work like you expect:
+
+ $ gawk 'BEGIN { print (0.1 + 12.2 == 12.3) }'
+ -| 0
+
+ The loss of accuracy during a single computation with floating-point
+numbers usually isn't enough to worry about. However, if you compute a
+value which is the result of a sequence of floating point operations,
+the error can accumulate and greatly affect the computation itself.
+Here is an attempt to compute the value of the constant pi using one of
+its many series representations:
+
+ BEGIN {
+ x = 1.0 / sqrt(3.0)
+ n = 6
+ for (i = 1; i < 30; i++) {
+ n = n * 2.0
+ x = (sqrt(x * x + 1) - 1) / x
+ printf("%.15f\n", n * x)
+ }
+ }
+
+ When run, the early errors propagating through later computations
+cause the loop to terminate prematurely after an attempt to divide by
+zero.
+
+ $ gawk -f pi.awk
+ -| 3.215390309173475
+ -| 3.159659942097510
+ -| 3.146086215131467
+ -| 3.142714599645573
+ ...
+ -| 3.224515243534819
+ -| 2.791117213058638
+ -| 0.000000000000000
+ error--> gawk: pi.awk:6: fatal: division by zero attempted
+
+ Here is an additional example where the inaccuracies in internal
+representations yield an unexpected result:
+
+ $ gawk 'BEGIN {
+ > for (d = 1.1; d <= 1.5; d += 0.1)
+ > i++
+ > print i
+ > }'
+ -| 4
+
+ Can computation using arbitrary precision help with the previous
+examples? If you are impatient to know, see *note Exact Arithmetic::.
+
+ Instead of arbitrary precision floating-point arithmetic, often all
+you need is an adjustment of your logic or a different order for the
+operations in your calculation. The stability and the accuracy of the
+computation of the constant pi in the previous example can be enhanced
+by using the following simple algebraic transformation:
+
+ (sqrt(x * x + 1) - 1) / x = x / (sqrt(x * x + 1) + 1)
+
+After making this, change the program does converge to pi in under 30
+iterations:
+
+ $ gawk -f /tmp/pi2.awk
+ -| 3.215390309173473
+ -| 3.159659942097501
+ -| 3.146086215131436
+ -| 3.142714599645370
+ -| 3.141873049979825
+ ...
+ -| 3.141592653589797
+ -| 3.141592653589797
+
+ There is no need to be unduly suspicious about the results from
+floating-point arithmetic. The lesson to remember is that
+floating-point arithmetic is always more complex than arithmetic using
+pencil and paper. In order to take advantage of the power of computer
+floating-point, you need to know its limitations and work within them.
+For most casual use of floating-point arithmetic, you will often get
+the expected result in the end if you simply round the display of your
+final results to the correct number of significant decimal digits.
+
+ As general advice, avoid presenting numerical data in a manner that
+implies better precision than is actually the case.
+
+* Menu:
+
+* Floating-point Representation:: Binary floating-point representation.
+* Floating-point Context:: Floating-point context.
+* Rounding Mode:: Floating-point rounding mode.
+
+ ---------- Footnotes ----------
+
+ (1) If you are interested in other tools that perform arbitrary
+precision arithmetic, you may want to investigate the POSIX `bc' tool.
+See the POSIX specification for it
+(http://pubs.opengroup.org/onlinepubs/009695399/utilities/bc.html), for
+more information.
+
+
+File: gawk.info, Node: Floating-point Representation, Next: Floating-point Context, Up: Floating-point Programming
+
+15.2.1 Binary Floating-point Representation
+-------------------------------------------
+
+Although floating-point representations vary from machine to machine,
+the most commonly encountered representation is that defined by the
+IEEE 754 Standard. An IEEE-754 format value has three components:
+
+ * A sign bit telling whether the number is positive or negative.
+
+ * An "exponent", E, giving its order of magnitude.
+
+ * A "significand", S, specifying the actual digits of the number.
+
+ The value of the number is then S * 2^E. The first bit of a
+non-zero binary significand is always one, so the significand in an
+IEEE-754 format only includes the fractional part, leaving the leading
+one implicit. The significand is stored in "normalized" format, which
+means that the first bit is always a one.
+
+ Three of the standard IEEE-754 types are 32-bit single precision,
+64-bit double precision and 128-bit quadruple precision. The standard
+also specifies extended precision formats to allow greater precisions
+and larger exponent ranges.
+
+
+File: gawk.info, Node: Floating-point Context, Next: Rounding Mode, Prev: Floating-point Representation, Up: Floating-point Programming
+
+15.2.2 Floating-point Context
+-----------------------------
+
+A floating-point "context" defines the environment for arithmetic
+operations. It governs precision, sets rules for rounding, and limits
+the range for exponents. The context has the following primary
+components:
+
+"Precision"
+ Precision of the floating-point format in bits.
+
+"emax"
+ Maximum exponent allowed for this format.
+
+"emin"
+ Minimum exponent allowed for this format.
+
+"Underflow behavior"
+ The format may or may not support gradual underflow.
+
+"Rounding"
+ The rounding mode of this context.
+
+ *note table-ieee-formats:: lists the precision and exponent field
+values for the basic IEEE-754 binary formats:
+
+Name Total bits Precision emin emax
+---------------------------------------------------------------------------
+Single 32 24 -126 +127
+Double 64 53 -1022 +1023
+Quadruple 128 113 -16382 +16383
+
+Table 15.1: Basic IEEE Format Context Values
+
+ NOTE: The precision numbers include the implied leading one that
+ gives them one extra bit of significand.
+
+ A floating-point context can also determine which signals are treated
+as exceptions, and can set rules for arithmetic with special values.
+Please consult the IEEE-754 standard or other resources for details.
+
+ `gawk' ordinarily uses the hardware double precision representation
+for numbers. On most systems, this is IEEE-754 floating-point format,
+corresponding to 64-bit binary with 53 bits of precision.
+
+ NOTE: In case an underflow occurs, the standard allows, but does
+ not require, the result from an arithmetic operation to be a
+ number smaller than the smallest nonzero normalized number. Such
+ numbers do not have as many significant digits as normal numbers,
+ and are called "denormals" or "subnormals". The alternative,
+ simply returning a zero, is called "flush to zero". The basic
+ IEEE-754 binary formats support subnormal numbers.
+
+
+File: gawk.info, Node: Rounding Mode, Prev: Floating-point Context, Up: Floating-point Programming
+
+15.2.3 Floating-point Rounding Mode
+-----------------------------------
+
+The "rounding mode" specifies the behavior for the results of numerical
+operations when discarding extra precision. Each rounding mode indicates
+how the least significant returned digit of a rounded result is to be
+calculated. *note table-rounding-modes:: lists the IEEE-754 defined
+rounding modes:
+
+Rounding Mode IEEE Name
+--------------------------------------------------------------------------
+Round to nearest, ties to even `roundTiesToEven'
+Round toward plus Infinity `roundTowardPositive'
+Round toward negative Infinity `roundTowardNegative'
+Round toward zero `roundTowardZero'
+Round to nearest, ties away `roundTiesToAway'
+from zero
+
+Table 15.2: IEEE 754 Rounding Modes
+
+ The default mode `roundTiesToEven' is the most preferred, but the
+least intuitive. This method does the obvious thing for most values, by
+rounding them up or down to the nearest digit. For example, rounding
+1.132 to two digits yields 1.13, and rounding 1.157 yields 1.16.
+
+ However, when it comes to rounding a value that is exactly halfway
+between, things do not work the way you probably learned in school. In
+this case, the number is rounded to the nearest even digit. So
+rounding 0.125 to two digits rounds down to 0.12, but rounding 0.6875
+to three digits rounds up to 0.688. You probably have already
+encountered this rounding mode when using the `printf' routine to
+format floating-point numbers. For example:
+
+ BEGIN {
+ x = -4.5
+ for (i = 1; i < 10; i++) {
+ x += 1.0
+ printf("%4.1f => %2.0f\n", x, x)
+ }
+ }
+
+produces the following output when run:(1)
+
+ -3.5 => -4
+ -2.5 => -2
+ -1.5 => -2
+ -0.5 => 0
+ 0.5 => 0
+ 1.5 => 2
+ 2.5 => 2
+ 3.5 => 4
+ 4.5 => 4
+
+ The theory behind the rounding mode `roundTiesToEven' is that it
+more or less evenly distributes upward and downward rounds of exact
+halves, which might cause the round-off error to cancel itself out.
+This is the default rounding mode used in IEEE-754 computing functions
+and operators.
+
+ The other rounding modes are rarely used. Round toward positive
+infinity (`roundTowardPositive') and round toward negative infinity
+(`roundTowardNegative') are often used to implement interval arithmetic,
+where you adjust the rounding mode to calculate upper and lower bounds
+for the range of output. The `roundTowardZero' mode can be used for
+converting floating-point numbers to integers. The rounding mode
+`roundTiesToAway' rounds the result to the nearest number and selects
+the number with the larger magnitude if a tie occurs.
+
+ Some numerical analysts will tell you that your choice of rounding
+style has tremendous impact on the final outcome, and advise you to
+wait until final output for any rounding. Instead, you can often avoid
+round-off error problems by setting the precision initially to some
+value sufficiently larger than the final desired precision, so that the
+accumulation of round-off error does not influence the outcome. If you
+suspect that results from your computation are sensitive to
+accumulation of round-off error, one way to be sure is to look for a
+significant difference in output when you change the rounding mode.
+
+ ---------- Footnotes ----------
+
+ (1) It is possible for the output to be completely different if the
+C library in your system does not use the IEEE-754 even-rounding rule
+to round halfway cases for `printf()'.
+
+
+File: gawk.info, Node: Gawk and MPFR, Next: Arbitrary Precision Floats, Prev: Floating-point Programming, Up: Arbitrary Precision Arithmetic
+
+15.3 `gawk' + MPFR = Powerful Arithmetic
+========================================
+
+The rest of this major node describes how to use the arbitrary precision
+(also known as "multiple precision" or "infinite precision") numeric
+capabilities in `gawk' to produce maximally accurate results when you
+need it.
+
+ But first you should check if your version of `gawk' supports
+arbitrary precision arithmetic. The easiest way to find out is to look
+at the output of the following command:
+
+ $ gawk --version
+ -| GNU Awk 4.1.0 (GNU MPFR 3.1.0, GNU MP 5.0.3)
+ -| Copyright (C) 1989, 1991-2012 Free Software Foundation.
+ ...
+
+ `gawk' uses the GNU MPFR (http://www.mpfr.org) and GNU MP
+(http://gmplib.org) (GMP) libraries for arbitrary precision arithmetic
+on numbers. So if you do not see the names of these libraries in the
+output, then your version of `gawk' does not support arbitrary
+precision arithmetic.
+
+ Additionally, there are a few elements available in the `PROCINFO'
+array to provide information about the MPFR and GMP libraries. *Note
+Auto-set::, for more information.
+
+
+File: gawk.info, Node: Arbitrary Precision Floats, Next: Arbitrary Precision Integers, Prev: Gawk and MPFR, Up: Arbitrary Precision Arithmetic
+
+15.4 Arbitrary Precision Floating-point Arithmetic with `gawk'
+==============================================================
+
+`gawk' uses the GNU MPFR library for arbitrary precision floating-point
+arithmetic. The MPFR library provides precise control over precisions
+and rounding modes, and gives correctly rounded, reproducible,
+platform-independent results. With the command-line option `--bignum'
+or `-M', all floating-point arithmetic operators and numeric functions
+can yield results to any desired precision level supported by MPFR.
+Two built-in variables, `PREC' and `ROUNDMODE', provide control over
+the working precision and the rounding mode (*note Setting Precision::,
+and *note Setting Rounding Mode::). The precision and the rounding
+mode are set globally for every operation to follow.
+
+ The default working precision for arbitrary precision floating-point
+values is 53, and the default value for `ROUNDMODE' is `"N"', which
+selects the IEEE-754 `roundTiesToEven' rounding mode (*note Rounding
+Mode::).(1) `gawk' uses the default exponent range in MPFR (EMAX = 2^30
+- 1, EMIN = -EMAX) for all floating-point contexts. There is no
+explicit mechanism to adjust the exponent range. MPFR does not
+implement subnormal numbers by default, and this behavior cannot be
+changed in `gawk'.
+
+ NOTE: When emulating an IEEE-754 format (*note Setting
+ Precision::), `gawk' internally adjusts the exponent range to the
+ value defined for the format and also performs computations needed
+ for gradual underflow (subnormal numbers).
+
+ NOTE: MPFR numbers are variable-size entities, consuming only as
+ much space as needed to store the significant digits. Since the
+ performance using MPFR numbers pales in comparison to doing
+ arithmetic using the underlying machine types, you should consider
+ using only as much precision as needed by your program.
+
+* Menu:
+
+* Setting Precision:: Setting the working precision.
+* Setting Rounding Mode:: Setting the rounding mode.
+* Floating-point Constants:: Representing floating-point constants.
+* Changing Precision:: Changing the precision of a number.
+* Exact Arithmetic:: Exact arithmetic with floating-point numbers.
+
+ ---------- Footnotes ----------
+
+ (1) The default precision is 53, since according to the MPFR
+documentation, the library should be able to exactly reproduce all
+computations with double-precision machine floating-point numbers
+(`double' type in C), except the default exponent range is much wider
+and subnormal numbers are not implemented.
+
+
+File: gawk.info, Node: Setting Precision, Next: Setting Rounding Mode, Up: Arbitrary Precision Floats
+
+15.4.1 Setting the Working Precision
+------------------------------------
+
+`gawk' uses a global working precision; it does not keep track of the
+precision or accuracy of individual numbers. Performing an arithmetic
+operation or calling a built-in function rounds the result to the
+current working precision. The default working precision is 53, which
+can be modified using the built-in variable `PREC'. You can also set the
+value to one of the following pre-defined case-insensitive strings to
+emulate an IEEE-754 binary format:
+
+`PREC' IEEE-754 Binary Format
+---------------------------------------------------
+`"half"' 16-bit half-precision.
+`"single"' Basic 32-bit single precision.
+`"double"' Basic 64-bit double precision.
+`"quad"' Basic 128-bit quadruple precision.
+`"oct"' 256-bit octuple precision.
+
+ The following example illustrates the effects of changing precision
+on arithmetic operations:
+
+ $ gawk -M -v PREC=100 'BEGIN { x = 1.0e-400; print x + 0; \
+ > PREC = "double"; print x + 0 }'
+ -| 1e-400
+ -| 0
+
+ Binary and decimal precisions are related approximately, according
+to the formula:
+
+ PREC = 3.322 * DPS
+
+Here, PREC denotes the binary precision (measured in bits) and DPS
+(short for decimal places) is the decimal digits. We can easily
+calculate how many decimal digits the 53-bit significand of an IEEE
+double is equivalent to: 53 / 3.332 which is equal to about 15.95. But
+what does 15.95 digits actually mean? It depends whether you are
+concerned about how many digits you can rely on, or how many digits you
+need.
+
+ It is important to know how many bits it takes to uniquely identify
+a double-precision value (the C type `double'). If you want to convert
+from `double' to decimal and back to `double' (e.g., saving a `double'
+representing an intermediate result to a file, and later reading it
+back to restart the computation), then a few more decimal digits are
+required. 17 digits is generally enough for a `double'.
+
+ It can also be important to know what decimal numbers can be uniquely
+represented with a `double'. If you want to convert from decimal to
+`double' and back again, 15 digits is the most that you can get. Stated
+differently, you should not present the numbers from your
+floating-point computations with more than 15 significant digits in
+them.
+
+ Conversely, it takes a precision of 332 bits to hold an approximation
+of the constant pi that is accurate to 100 decimal places.
+
+ You should always add some extra bits in order to avoid the
+confusing round-off issues that occur because numbers are stored
+internally in binary.
+
+
+File: gawk.info, Node: Setting Rounding Mode, Next: Floating-point Constants, Prev: Setting Precision, Up: Arbitrary Precision Floats
+
+15.4.2 Setting the Rounding Mode
+--------------------------------
+
+The `ROUNDMODE' variable provides program level control over the
+rounding mode. The correspondence between `ROUNDMODE' and the IEEE
+rounding modes is shown in *note table-gawk-rounding-modes::.
+
+Rounding Mode IEEE Name `ROUNDMODE'
+---------------------------------------------------------------------------
+Round to nearest, ties to even `roundTiesToEven' `"N"' or `"n"'
+Round toward plus Infinity `roundTowardPositive' `"U"' or `"u"'
+Round toward negative Infinity `roundTowardNegative' `"D"' or `"d"'
+Round toward zero `roundTowardZero' `"Z"' or `"z"'
+Round to nearest, ties away `roundTiesToAway' `"A"' or `"a"'
+from zero
+
+Table 15.3: `gawk' Rounding Modes
+
+ `ROUNDMODE' has the default value `"N"', which selects the IEEE-754
+rounding mode `roundTiesToEven'. *note Table 15.3:
+table-gawk-rounding-modes, lists `"A"' to select the IEEE-754 mode
+`roundTiesToAway'. This is only available if your version of the MPFR
+library supports it; otherwise setting `ROUNDMODE' to this value has no
+effect. *Note Rounding Mode::, for the meanings of the various rounding
+modes.
+
+ Here is an example of how to change the default rounding behavior of
+`printf''s output:
+
+ $ gawk -M -v ROUNDMODE="Z" 'BEGIN { printf("%.2f\n", 1.378) }'
+ -| 1.37
+
+
+File: gawk.info, Node: Floating-point Constants, Next: Changing Precision, Prev: Setting Rounding Mode, Up: Arbitrary Precision Floats
+
+15.4.3 Representing Floating-point Constants
+--------------------------------------------
+
+Be wary of floating-point constants! When reading a floating-point
+constant from program source code, `gawk' uses the default precision,
+unless overridden by an assignment to the special variable `PREC' on
+the command line, to store it internally as a MPFR number. Changing
+the precision using `PREC' in the program text does _not_ change the
+precision of a constant. If you need to represent a floating-point
+constant at a higher precision than the default and cannot use a
+command line assignment to `PREC', you should either specify the
+constant as a string, or as a rational number, whenever possible. The
+following example illustrates the differences among various ways to
+print a floating-point constant:
+
+ $ gawk -M 'BEGIN { PREC = 113; printf("%0.25f\n", 0.1) }'
+ -| 0.1000000000000000055511151
+ $ gawk -M -v PREC=113 'BEGIN { printf("%0.25f\n", 0.1) }'
+ -| 0.1000000000000000000000000
+ $ gawk -M 'BEGIN { PREC = 113; printf("%0.25f\n", "0.1") }'
+ -| 0.1000000000000000000000000
+ $ gawk -M 'BEGIN { PREC = 113; printf("%0.25f\n", 1/10) }'
+ -| 0.1000000000000000000000000
+
+ In the first case, the number is stored with the default precision
+of 53.
+
+
+File: gawk.info, Node: Changing Precision, Next: Exact Arithmetic, Prev: Floating-point Constants, Up: Arbitrary Precision Floats
+
+15.4.4 Changing the Precision of a Number
+-----------------------------------------
+
+ The point is that in any variable-precision package, a decision is
+ made on how to treat numbers given as data, or arising in
+ intermediate results, which are represented in floating-point
+ format to a precision lower than working precision. Do we promote
+ them to full membership of the high-precision club, or do we treat
+ them and all their associates as second-class citizens? Sometimes
+ the first course is proper, sometimes the second, and it takes
+ careful analysis to tell which.
+
+ Dirk Laurie(1)
+
+ `gawk' does not implicitly modify the precision of any previously
+computed results when the working precision is changed with an
+assignment to `PREC'. The precision of a number is always the one that
+was used at the time of its creation, and there is no way for the user
+to explicitly change it afterwards. However, since the result of a
+floating-point arithmetic operation is always an arbitrary precision
+floating-point value--with a precision set by the value of `PREC'--one
+of the following workarounds effectively accomplishes the desired
+behavior:
+
+ x = x + 0.0
+
+or:
+
+ x += 0.0
+
+ ---------- Footnotes ----------
+
+ (1) Dirk Laurie. `Variable-precision Arithmetic Considered Perilous
+-- A Detective Story'. Electronic Transactions on Numerical Analysis.
+Volume 28, pp. 168-173, 2008.
+
+
+File: gawk.info, Node: Exact Arithmetic, Prev: Changing Precision, Up: Arbitrary Precision Floats
+
+15.4.5 Exact Arithmetic with Floating-point Numbers
+---------------------------------------------------
+
+ CAUTION: Never depend on the exactness of floating-point
+ arithmetic, even for apparently simple expressions!
+
+ Can arbitrary precision arithmetic give exact results? There are no
+easy answers. The standard rules of algebra often do not apply when
+using floating-point arithmetic. Among other things, the distributive
+and associative laws do not hold completely, and order of operation may
+be important for your computation. Rounding error, cumulative precision
+loss and underflow are often troublesome.
+
+ When `gawk' tests the expressions `0.1 + 12.2' and `12.3' for
+equality using the machine double precision arithmetic, it decides that
+they are not equal! (*Note Floating-point Programming::.) You can get
+the result you want by increasing the precision; 56 in this case will
+get the job done:
+
+ $ gawk -M -v PREC=56 'BEGIN { print (0.1 + 12.2 == 12.3) }'
+ -| 1
+
+ If adding more bits is good, perhaps adding even more bits of
+precision is better? Here is what happens if we use an even larger
+value of `PREC':
+
+ $ gawk -M -v PREC=201 'BEGIN { print (0.1 + 12.2 == 12.3) }'
+ -| 0
+
+ This is not a bug in `gawk' or in the MPFR library. It is easy to
+forget that the finite number of bits used to store the value is often
+just an approximation after proper rounding. The test for equality
+succeeds if and only if _all_ bits in the two operands are exactly the
+same. Since this is not necessarily true after floating-point
+computations with a particular precision and effective rounding rule, a
+straight test for equality may not work.
+
+ So, don't assume that floating-point values can be compared for
+equality. You should also exercise caution when using other forms of
+comparisons. The standard way to compare between floating-point
+numbers is to determine how much error (or "tolerance") you will allow
+in a comparison and check to see if one value is within this error
+range of the other.
+
+ In applications where 15 or fewer decimal places suffice, hardware
+double precision arithmetic can be adequate, and is usually much faster.
+But you do need to keep in mind that every floating-point operation can
+suffer a new rounding error with catastrophic consequences as
+illustrated by our earlier attempt to compute the value of the constant
+pi (*note Floating-point Programming::). Extra precision can greatly
+enhance the stability and the accuracy of your computation in such
+cases.
+
+ Repeated addition is not necessarily equivalent to multiplication in
+floating-point arithmetic. In the example in *note Floating-point
+Programming:::
+
+ $ gawk 'BEGIN {
+ > for (d = 1.1; d <= 1.5; d += 0.1)
+ > i++
+ > print i
+ > }'
+ -| 4
+
+you may or may not succeed in getting the correct result by choosing an
+arbitrarily large value for `PREC'. Reformulation of the problem at
+hand is often the correct approach in such situations.
+
+
+File: gawk.info, Node: Arbitrary Precision Integers, Prev: Arbitrary Precision Floats, Up: Arbitrary Precision Arithmetic
+
+15.5 Arbitrary Precision Integer Arithmetic with `gawk'
+=======================================================
+
+If the option `--bignum' or `-M' is specified, `gawk' performs all
+integer arithmetic using GMP arbitrary precision integers. Any number
+that looks like an integer in a program source or data file is stored
+as an arbitrary precision integer. The size of the integer is limited
+only by your computer's memory. The current floating-point context has
+no effect on operations involving integers. For example, the following
+computes 5^4^3^2, the result of which is beyond the limits of ordinary
+`gawk' numbers:
+
+ $ gawk -M 'BEGIN {
+ > x = 5^4^3^2
+ > print "# of digits =", length(x)
+ > print substr(x, 1, 20), "...", substr(x, length(x) - 19, 20)
+ > }'
+ -| # of digits = 183231
+ -| 62060698786608744707 ... 92256259918212890625
+
+ If you were to compute the same value using arbitrary precision
+floating-point values instead, the precision needed for correct output
+(using the formula `prec = 3.322 * dps'), would be 3.322 x 183231, or
+608693.
+
+ The result from an arithmetic operation with an integer and a
+floating-point value is a floating-point value with a precision equal
+to the working precision. The following program calculates the eighth
+term in Sylvester's sequence(1) using a recurrence:
+
+ $ gawk -M 'BEGIN {
+ > s = 2.0
+ > for (i = 1; i <= 7; i++)
+ > s = s * (s - 1) + 1
+ > print s
+ > }'
+ -| 113423713055421845118910464
+
+ The output differs from the actual number,
+113,423,713,055,421,844,361,000,443, because the default precision of
+53 is not enough to represent the floating-point results exactly. You
+can either increase the precision (100 is enough in this case), or
+replace the floating-point constant `2.0' with an integer, to perform
+all computations using integer arithmetic to get the correct output.
+
+ It will sometimes be necessary for `gawk' to implicitly convert an
+arbitrary precision integer into an arbitrary precision floating-point
+value. This is primarily because the MPFR library does not always
+provide the relevant interface to process arbitrary precision integers
+or mixed-mode numbers as needed by an operation or function. In such a
+case, the precision is set to the minimum value necessary for exact
+conversion, and the working precision is not used for this purpose. If
+this is not what you need or want, you can employ a subterfuge like
+this:
+
+ gawk -M 'BEGIN { n = 13; print (n + 0.0) % 2.0 }'
+
+ You can avoid this issue altogether by specifying the number as a
+floating-point value to begin with:
+
+ gawk -M 'BEGIN { n = 13.0; print n % 2.0 }'
+
+ Note that for the particular example above, there is likely best to
+just use the following:
+
+ gawk -M 'BEGIN { n = 13; print n % 2 }'
+
+ ---------- Footnotes ----------
+
+ (1) Weisstein, Eric W. `Sylvester's Sequence'. From MathWorld--A
+Wolfram Web Resource.
+`http://mathworld.wolfram.com/SylvestersSequence.html'
+
+
+File: gawk.info, Node: Dynamic Extensions, Next: Language History, Prev: Arbitrary Precision Arithmetic, Up: Top
+
+16 Writing Extensions for `gawk'
+********************************
+
+This chapter is a placeholder, pending a rewrite for the new API. Some
+of the old bits remain, since they can be partially reused.
+
+ It is possible to add new built-in functions to `gawk' using
+dynamically loaded libraries. This facility is available on systems
+(such as GNU/Linux) that support the C `dlopen()' and `dlsym()'
+functions. This major node describes how to write and use dynamically
+loaded extensions for `gawk'. Experience with programming in C or C++
+is necessary when reading this minor node.
+
+ NOTE: When `--sandbox' is specified, extensions are disabled
+ (*note Options::.
+
+* Menu:
+
+* Plugin License:: A note about licensing.
+* Sample Library:: A example of new functions.
+
+
+File: gawk.info, Node: Plugin License, Next: Sample Library, Up: Dynamic Extensions
+
+16.1 Extension Licensing
+========================
+
+Every dynamic extension should define the global symbol
+`plugin_is_GPL_compatible' to assert that it has been licensed under a
+GPL-compatible license. If this symbol does not exist, `gawk' will
+emit a fatal error and exit.
+
+ The declared type of the symbol should be `int'. It does not need
+to be in any allocated section, though. The code merely asserts that
+the symbol exists in the global scope. Something like this is enough:
+
+ int plugin_is_GPL_compatible;
+
+
+File: gawk.info, Node: Sample Library, Prev: Plugin License, Up: Dynamic Extensions
+
+16.2 Example: Directory and File Operation Built-ins
+====================================================
+
+Two useful functions that are not in `awk' are `chdir()' (so that an
+`awk' program can change its directory) and `stat()' (so that an `awk'
+program can gather information about a file). This minor node
+implements these functions for `gawk' in an external extension library.
+
+* Menu:
+
+* Internal File Description:: What the new functions will do.
+* Internal File Ops:: The code for internal file operations.
+* Using Internal File Ops:: How to use an external extension.
+
+
+File: gawk.info, Node: Internal File Description, Next: Internal File Ops, Up: Sample Library
+
+16.2.1 Using `chdir()' and `stat()'
+-----------------------------------
+
+This minor node shows how to use the new functions at the `awk' level
+once they've been integrated into the running `gawk' interpreter.
+Using `chdir()' is very straightforward. It takes one argument, the new
+directory to change to:
+
+ ...
+ newdir = "/home/arnold/funstuff"
+ ret = chdir(newdir)
+ if (ret < 0) {
+ printf("could not change to %s: %s\n",
+ newdir, ERRNO) > "/dev/stderr"
+ exit 1
+ }
+ ...
+
+ The return value is negative if the `chdir' failed, and `ERRNO'
+(*note Built-in Variables::) is set to a string indicating the error.
+
+ Using `stat()' is a bit more complicated. The C `stat()' function
+fills in a structure that has a fair amount of information. The right
+way to model this in `awk' is to fill in an associative array with the
+appropriate information:
+
+ file = "/home/arnold/.profile"
+ fdata[1] = "x" # force `fdata' to be an array
+ ret = stat(file, fdata)
+ if (ret < 0) {
+ printf("could not stat %s: %s\n",
+ file, ERRNO) > "/dev/stderr"
+ exit 1
+ }
+ printf("size of %s is %d bytes\n", file, fdata["size"])
+
+ The `stat()' function always clears the data array, even if the
+`stat()' fails. It fills in the following elements:
+
+`"name"'
+ The name of the file that was `stat()''ed.
+
+`"dev"'
+`"ino"'
+ The file's device and inode numbers, respectively.
+
+`"mode"'
+ The file's mode, as a numeric value. This includes both the file's
+ type and its permissions.
+
+`"nlink"'
+ The number of hard links (directory entries) the file has.
+
+`"uid"'
+`"gid"'
+ The numeric user and group ID numbers of the file's owner.
+
+`"size"'
+ The size in bytes of the file.
+
+`"blocks"'
+ The number of disk blocks the file actually occupies. This may not
+ be a function of the file's size if the file has holes.
+
+`"atime"'
+`"mtime"'
+`"ctime"'
+ The file's last access, modification, and inode update times,
+ respectively. These are numeric timestamps, suitable for
+ formatting with `strftime()' (*note Built-in::).
+
+`"pmode"'
+ The file's "printable mode." This is a string representation of
+ the file's type and permissions, such as what is produced by `ls
+ -l'--for example, `"drwxr-xr-x"'.
+
+`"type"'
+ A printable string representation of the file's type. The value
+ is one of the following:
+
+ `"blockdev"'
+ `"chardev"'
+ The file is a block or character device ("special file").
+
+ `"directory"'
+ The file is a directory.
+
+ `"fifo"'
+ The file is a named-pipe (also known as a FIFO).
+
+ `"file"'
+ The file is just a regular file.
+
+ `"socket"'
+ The file is an `AF_UNIX' ("Unix domain") socket in the
+ filesystem.
+
+ `"symlink"'
+ The file is a symbolic link.
+
+ Several additional elements may be present depending upon the
+operating system and the type of the file. You can test for them in
+your `awk' program by using the `in' operator (*note Reference to
+Elements::):
+
+`"blksize"'
+ The preferred block size for I/O to the file. This field is not
+ present on all POSIX-like systems in the C `stat' structure.
+
+`"linkval"'
+ If the file is a symbolic link, this element is the name of the
+ file the link points to (i.e., the value of the link).
+
+`"rdev"'
+`"major"'
+`"minor"'
+ If the file is a block or character device file, then these values
+ represent the numeric device number and the major and minor
+ components of that number, respectively.
+
+
+File: gawk.info, Node: Internal File Ops, Next: Using Internal File Ops, Prev: Internal File Description, Up: Sample Library
+
+16.2.2 C Code for `chdir()' and `stat()'
+----------------------------------------
+
+Here is the C code for these extensions. They were written for
+GNU/Linux. The code needs some more work for complete portability to
+other POSIX-compliant systems:(1)
+
+ #include "awk.h"
+
+ #include <sys/sysmacros.h>
+
+ int plugin_is_GPL_compatible;
+
+ /* do_chdir --- provide dynamically loaded chdir() builtin for gawk */
+
+ static NODE *
+ do_chdir(int nargs)
+ {
+ NODE *newdir;
+ int ret = -1;
+
+ if (do_lint && nargs != 1)
+ lintwarn("chdir: called with incorrect number of arguments");
+
+ newdir = get_scalar_argument(0, FALSE);
+
+ The file includes the `"awk.h"' header file for definitions for the
+`gawk' internals. It includes `<sys/sysmacros.h>' for access to the
+`major()' and `minor'() macros.
+
+ By convention, for an `awk' function `foo', the function that
+implements it is called `do_foo'. The function should take a `int'
+argument, usually called `nargs', that represents the number of defined
+arguments for the function. The `newdir' variable represents the new
+directory to change to, retrieved with `get_scalar_argument()'. Note
+that the first argument is numbered zero.
+
+ This code actually accomplishes the `chdir()'. It first forces the
+argument to be a string and passes the string value to the `chdir()'
+system call. If the `chdir()' fails, `ERRNO' is updated.
+
+ (void) force_string(newdir);
+ ret = chdir(newdir->stptr);
+ if (ret < 0)
+ update_ERRNO_int(errno);
+
+ Finally, the function returns the return value to the `awk' level:
+
+ return make_number((AWKNUM) ret);
+ }
+
+ The `stat()' built-in is more involved. First comes a function that
+turns a numeric mode into a printable representation (e.g., 644 becomes
+`-rw-r--r--'). This is omitted here for brevity:
+
+ /* format_mode --- turn a stat mode field into something readable */
+
+ static char *
+ format_mode(unsigned long fmode)
+ {
+ ...
+ }
+
+ Next comes the `do_stat()' function. It starts with variable
+declarations and argument checking:
+
+ /* do_stat --- provide a stat() function for gawk */
+
+ static NODE *
+ do_stat(int nargs)
+ {
+ NODE *file, *array, *tmp;
+ struct stat sbuf;
+ int ret;
+ NODE **aptr;
+ char *pmode; /* printable mode */
+ char *type = "unknown";
+
+ if (do_lint && nargs > 2)
+ lintwarn("stat: called with too many arguments");
+
+ Then comes the actual work. First, the function gets the arguments.
+Then, it always clears the array. The code use `lstat()' (instead of
+`stat()') to get the file information, in case the file is a symbolic
+link. If there's an error, it sets `ERRNO' and returns:
+
+ /* file is first arg, array to hold results is second */
+ file = get_scalar_argument(0, FALSE);
+ array = get_array_argument(1, FALSE);
+
+ /* empty out the array */
+ assoc_clear(array);
+
+ /* lstat the file, if error, set ERRNO and return */
+ (void) force_string(file);
+ ret = lstat(file->stptr, & sbuf);
+ if (ret < 0) {
+ update_ERRNO_int(errno);
+ return make_number((AWKNUM) ret);
+ }
+
+ Now comes the tedious part: filling in the array. Only a few of the
+calls are shown here, since they all follow the same pattern:
+
+ /* fill in the array */
+ aptr = assoc_lookup(array, tmp = make_string("name", 4));
+ *aptr = dupnode(file);
+ unref(tmp);
+
+ aptr = assoc_lookup(array, tmp = make_string("mode", 4));
+ *aptr = make_number((AWKNUM) sbuf.st_mode);
+ unref(tmp);
+
+ aptr = assoc_lookup(array, tmp = make_string("pmode", 5));
+ pmode = format_mode(sbuf.st_mode);
+ *aptr = make_string(pmode, strlen(pmode));
+ unref(tmp);
+
+ When done, return the `lstat()' return value:
+
+
+ return make_number((AWKNUM) ret);
+ }
+
+ Finally, it's necessary to provide the "glue" that loads the new
+function(s) into `gawk'. By convention, each library has a routine
+named `dl_load()' that does the job. The simplest way is to use the
+`dl_load_func' macro in `gawkapi.h'.
+
+ And that's it! As an exercise, consider adding functions to
+implement system calls such as `chown()', `chmod()', and `umask()'.
+
+ ---------- Footnotes ----------
+
+ (1) This version is edited slightly for presentation. See
+`extension/filefuncs.c' in the `gawk' distribution for the complete
+version.
+
+
+File: gawk.info, Node: Using Internal File Ops, Prev: Internal File Ops, Up: Sample Library
+
+16.2.3 Integrating the Extensions
+---------------------------------
+
+Now that the code is written, it must be possible to add it at runtime
+to the running `gawk' interpreter. First, the code must be compiled.
+Assuming that the functions are in a file named `filefuncs.c', and IDIR
+is the location of the `gawk' include files, the following steps create
+a GNU/Linux shared library:
+
+ $ gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -IIDIR filefuncs.c
+ $ ld -o filefuncs.so -shared filefuncs.o
+
+ Once the library exists, it is loaded by calling the `extension()'
+built-in function. This function takes two arguments: the name of the
+library to load and the name of a function to call when the library is
+first loaded. This function adds the new functions to `gawk'. It
+returns the value returned by the initialization function within the
+shared library:
+
+ # file testff.awk
+ BEGIN {
+ extension("./filefuncs.so", "dl_load")
+
+ chdir(".") # no-op
+
+ data[1] = 1 # force `data' to be an array
+ print "Info for testff.awk"
+ ret = stat("testff.awk", data)
+ print "ret =", ret
+ for (i in data)
+ printf "data[\"%s\"] = %s\n", i, data[i]
+ print "testff.awk modified:",
+ strftime("%m %d %y %H:%M:%S", data["mtime"])
+
+ print "\nInfo for JUNK"
+ ret = stat("JUNK", data)
+ print "ret =", ret
+ for (i in data)
+ printf "data[\"%s\"] = %s\n", i, data[i]
+ print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"])
+ }
+
+ Here are the results of running the program:
+
+ $ gawk -f testff.awk
+ -| Info for testff.awk
+ -| ret = 0
+ -| data["size"] = 607
+ -| data["ino"] = 14945891
+ -| data["name"] = testff.awk
+ -| data["pmode"] = -rw-rw-r--
+ -| data["nlink"] = 1
+ -| data["atime"] = 1293993369
+ -| data["mtime"] = 1288520752
+ -| data["mode"] = 33204
+ -| data["blksize"] = 4096
+ -| data["dev"] = 2054
+ -| data["type"] = file
+ -| data["gid"] = 500
+ -| data["uid"] = 500
+ -| data["blocks"] = 8
+ -| data["ctime"] = 1290113572
+ -| testff.awk modified: 10 31 10 12:25:52
+ -|
+ -| Info for JUNK
+ -| ret = -1
+ -| JUNK modified: 01 01 70 02:00:00
+
+
+File: gawk.info, Node: Language History, Next: Installation, Prev: Dynamic Extensions, Up: Top
Appendix A The Evolution of the `awk' Language
**********************************************
@@ -20074,9 +21836,6 @@ the current version of `gawk'.
- The `bindtextdomain()', `dcgettext()' and `dcngettext()'
functions for internationalization (*note Programmer i18n::).
- - The `extension()' built-in function and the ability to add
- new functions dynamically (*note Dynamic Extensions::).
-
- The `fflush()' function from Brian Kernighan's version of
`awk' (*note I/O Functions::).
@@ -20091,12 +21850,21 @@ the current version of `gawk'.
- The `AWKPATH' environment variable for specifying a path
search for the `-f' command-line option (*note Options::).
- - The ability to use GNU-style long-named options that start
- with `--' and the `--characters-as-bytes', `--compat',
- `--dump-variables', `--exec', `--gen-pot', `--lint',
- `--lint-old', `--non-decimal-data', `--posix', `--profile',
- `--re-interval', `--sandbox', `--source', `--traditional', and
- `--use-lc-numeric' options (*note Options::).
+ - The `AWKLIBPATH' environment variable for specifying a path
+ search for the `-l' command-line option (*note Options::).
+
+ - The `-b', `-c', `-C', `-d', `-D', `-e', `-E', `-g', `-h',
+ `-i', `-l', `-L', `-M', `-n', `-N', `-o', `-O', `-p', `-P',
+ `-r', `-S', `-t', and `-V' short options. Also, the ability
+ to use GNU-style long-named options that start with `--' and
+ the `--assign', `--bignum', `--characters-as-bytes',
+ `--copyright', `--debug', `--dump-variables', `--execle',
+ `--field-separator', `--file', `--gen-pot', `--help',
+ `--include', `--lint', `--lint-old', `--load',
+ `--non-decimal-data', `--optimize', `--posix',
+ `--pretty-print', `--profile', `--re-interval', `--sandbox',
+ `--source', `--traditional', `--use-lc-numeric', and
+ `--version' long options (*note Options::).
* Support for the following obsolete systems was removed from the
code and the documentation for `gawk' version 4.0:
@@ -20140,7 +21908,7 @@ Feature BWK Awk Mawk GNU Awk
`\x' Escape sequence X X X
`RS' as regexp X X
`FS' as null string X X X
-`/dev/stdin' special file X X X
+`/dev/stdin' special file X X
`/dev/stdout' special file X X X
`/dev/stderr' special file X X X
`**' and `**=' operators X X
@@ -20325,7 +22093,7 @@ Info file, in approximate chronological order:
various PC platforms.
* Christos Zoulas provided the `extension()' built-in function for
- dynamically adding new modules.
+ dynamically adding new modules. (This was removed at `gawk' 4.1.)
* Ju"rgen Kahrs contributed the initial version of the TCP/IP
networking code and documentation, and motivated the inclusion of
@@ -20361,7 +22129,7 @@ Info file, in approximate chronological order:
Windows32 environments. (This is no longer supported)
* John Haque reworked the `gawk' internals to use a byte-code engine,
- providing the `dgawk' debugger for `awk' programs.
+ providing the `gawk' debugger for `awk' programs.
* Efraim Yawitz contributed the original text for *note Debugger::.
@@ -20856,10 +22624,6 @@ not overwrite it!_ Instead enter the following commands at your prompt
The binary distribution may contain a separate file containing
additional or more detailed installation instructions.
- As of April, 2012, up to date `gawk' binaries for MS Windows are
-available from Eli Zaretskii's ports project
-(http://sourceforge.net/projects/ezwinports/files/).
-

File: gawk.info, Node: PC Compiling, Next: PC Testing, Prev: PC Binary Installation, Up: PC Installation
@@ -21382,9 +23146,10 @@ Unix `awk'
`pawk'
Nelson H.F. Beebe at the University of Utah has modified Brian
Kernighan's `awk' to provide timing and profiling information. It
- is different from `pgawk' (*note Profiling::), in that it uses
- CPU-based profiling, not line-count profiling. You may find it at
- either `ftp://ftp.math.utah.edu/pub/pawk/pawk-20030606.tar.gz' or
+ is different from `gawk' with the `--profile' option. (*note
+ Profiling::), in that it uses CPU-based profiling, not line-count
+ profiling. You may find it at either
+ `ftp://ftp.math.utah.edu/pub/pawk/pawk-20030606.tar.gz' or
`http://www.math.utah.edu/pub/pawk/pawk-20030606.tar.gz'.
Busybox Awk
@@ -21451,8 +23216,6 @@ and maintainers of `gawk'. Everything in it applies specifically to
* Compatibility Mode:: How to disable certain `gawk'
extensions.
* Additions:: Making Additions To `gawk'.
-* Dynamic Extensions:: Adding new built-in functions to
- `gawk'.
* Future Extensions:: New features that may be implemented one day.

@@ -21479,7 +23242,7 @@ for the casual user. It probably has not even been compiled into your
version of `gawk', since it slows down execution.

-File: gawk.info, Node: Additions, Next: Dynamic Extensions, Prev: Compatibility Mode, Up: Notes
+File: gawk.info, Node: Additions, Next: Future Extensions, Prev: Compatibility Mode, Up: Notes
C.2 Making Additions to `gawk'
==============================
@@ -21499,6 +23262,8 @@ as well as any considerations you should bear in mind.
`gawk'.
* New Ports:: Porting `gawk' to a new operating
system.
+* Derived Files:: Why derived files are kept in the
+ `git' repository.

File: gawk.info, Node: Accessing The Source, Next: Adding Code, Up: Additions
@@ -21526,8 +23291,8 @@ access the repository using:
git clone http://git.savannah.gnu.org/r/gawk.git
Once you have made changes, you can use `git diff' to produce a
-patch, and send that to the `gawk' maintainer; see *note Bugs:: for how
-to do that.
+patch, and send that to the `gawk' maintainer; see *note Bugs::, for
+how to do that.
Finally, if you cannot install Git (e.g., if it hasn't been ported
yet to your operating system), you can use the Git-CVS gateway to check
@@ -21610,9 +23375,9 @@ possible to include your changes:
of `switch' statements, instead of just the plain pointer or
character value.
- * Use the `TRUE', `FALSE' and `NULL' symbolic constants and the
- character constant `'\0'' where appropriate, instead of `1'
- and `0'.
+ * Use `true', `false' for `bool' values, the `NULL' symbolic
+ constant for pointer values, and the character constant
+ `'\0'' where appropriate, instead of `1' and `0'.
* Provide one-line descriptive comments for each function.
@@ -21648,9 +23413,10 @@ possible to include your changes:
7. Submit changes as unified diffs. Use `diff -u -r -N' to compare
the original `gawk' source tree with your version. 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
- Bugs::, for the electronic mail information.)
+ using the GNU version of `diff', or best of all, `git diff' or
+ `git format-patch'. Send the output produced by `diff' to me when
+ you submit your changes. (*Note 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
@@ -21667,7 +23433,7 @@ isn't possible for me to do that with a minimum of extra work, then I
probably will not.

-File: gawk.info, Node: New Ports, Prev: Adding Code, Up: Additions
+File: gawk.info, Node: New Ports, Next: Derived Files, Prev: Adding Code, Up: Additions
C.2.3 Porting `gawk' to a New Operating System
----------------------------------------------
@@ -21749,627 +23515,152 @@ code that is already there.
style and brace layout that suits your taste.

-File: gawk.info, Node: Dynamic Extensions, Next: Future Extensions, Prev: Additions, Up: Notes
-
-C.3 Adding New Built-in Functions to `gawk'
-===========================================
-
- Danger Will Robinson! Danger!!
- Warning! Warning!
- The Robot
-
- It is possible to add new built-in functions to `gawk' using
-dynamically loaded libraries. This facility is available on systems
-(such as GNU/Linux) that support the C `dlopen()' and `dlsym()'
-functions. This minor node describes how to write and use dynamically
-loaded extensions for `gawk'. Experience with programming in C or C++
-is necessary when reading this minor node.
-
- CAUTION: The facilities described in this minor node are very much
- subject to change in a future `gawk' release. Be aware that you
- may have to re-do everything, at some future time.
-
- If you have written your own dynamic extensions, be sure to
- recompile them for each new `gawk' release. There is no guarantee
- of binary compatibility between different releases, nor will there
- ever be such a guarantee.
-
- NOTE: When `--sandbox' is specified, extensions are disabled
- (*note Options::.
-
-* Menu:
-
-* Internals:: A brief look at some `gawk' internals.
-* Plugin License:: A note about licensing.
-* Sample Library:: A example of new functions.
-
-
-File: gawk.info, Node: Internals, Next: Plugin License, Up: Dynamic Extensions
-
-C.3.1 A Minimal Introduction to `gawk' Internals
-------------------------------------------------
-
-The truth is that `gawk' was not designed for simple extensibility.
-The facilities for adding functions using shared libraries work, but
-are something of a "bag on the side." Thus, this tour is brief and
-simplistic; would-be `gawk' hackers are encouraged to spend some time
-reading the source code before trying to write extensions based on the
-material presented here. Of particular note are the files `awk.h',
-`builtin.c', and `eval.c'. Reading `awkgram.y' in order to see how the
-parse tree is built would also be of use.
-
- With the disclaimers out of the way, the following types, structure
-members, functions, and macros are declared in `awk.h' and are of use
-when writing extensions. The next minor node shows how they are used:
-
-`AWKNUM'
- An `AWKNUM' is the internal type of `awk' floating-point numbers.
- Typically, it is a C `double'.
-
-`NODE'
- Just about everything is done using objects of type `NODE'. These
- contain both strings and numbers, as well as variables and arrays.
-
-`AWKNUM force_number(NODE *n)'
- This macro forces a value to be numeric. It returns the actual
- numeric value contained in the node. It may end up calling an
- internal `gawk' function.
-
-`void force_string(NODE *n)'
- This macro guarantees that a `NODE''s string value is current. It
- may end up calling an internal `gawk' function. It also
- guarantees that the string is zero-terminated.
-
-`void force_wstring(NODE *n)'
- Similarly, this macro guarantees that a `NODE''s wide-string value
- is current. It may end up calling an internal `gawk' function.
- It also guarantees that the wide string is zero-terminated.
-
-`size_t get_curfunc_arg_count(void)'
- This function returns the actual number of parameters passed to
- the current function. Inside the code of an extension this can be
- used to determine the maximum index which is safe to use with
- `get_actual_argument'. If this value is greater than `nargs', the
- function was called incorrectly from the `awk' program.
-
-`nargs'
- Inside an extension function, this is the maximum number of
- expected parameters, as set by the `make_builtin()' function.
-
-`n->stptr'
-`n->stlen'
- The data and length of a `NODE''s string value, respectively. The
- string is _not_ guaranteed to be zero-terminated. If you need to
- pass the string value to a C library function, save the value in
- `n->stptr[n->stlen]', assign `'\0'' to it, call the routine, and
- then restore the value.
-
-`n->wstptr'
-`n->wstlen'
- The data and length of a `NODE''s wide-string value, respectively.
- Use `force_wstring()' to make sure these values are current.
-
-`n->type'
- The type of the `NODE'. This is a C `enum'. Values should be one
- of `Node_var', `Node_var_new', or `Node_var_array' for function
- parameters.
-
-`n->vname'
- The "variable name" of a node. This is not of much use inside
- externally written extensions.
-
-`void assoc_clear(NODE *n)'
- Clears the associative array pointed to by `n'. Make sure that
- `n->type == Node_var_array' first.
-
-`NODE **assoc_lookup(NODE *symbol, NODE *subs, int reference)'
- Finds, and installs if necessary, array elements. `symbol' is the
- array, `subs' is the subscript. This is usually a value created
- with `make_string()' (see below). `reference' should be `TRUE' if
- it is an error to use the value before it is created. Typically,
- `FALSE' is the correct value to use from extension functions.
-
-`NODE *make_string(char *s, size_t len)'
- Take a C string and turn it into a pointer to a `NODE' that can be
- stored appropriately. This is permanent storage; understanding of
- `gawk' memory management is helpful.
-
-`NODE *make_number(AWKNUM val)'
- Take an `AWKNUM' and turn it into a pointer to a `NODE' that can
- be stored appropriately. This is permanent storage; understanding
- of `gawk' memory management is helpful.
-
-`NODE *dupnode(NODE *n)'
- Duplicate a node. In most cases, this increments an internal
- reference count instead of actually duplicating the entire `NODE';
- understanding of `gawk' memory management is helpful.
-
-`void unref(NODE *n)'
- This macro releases the memory associated with a `NODE' allocated
- with `make_string()' or `make_number()'. Understanding of `gawk'
- memory management is helpful.
-
-`void make_builtin(const char *name, NODE *(*func)(NODE *), int count)'
- Register a C function pointed to by `func' as new built-in
- function `name'. `name' is a regular C string. `count' is the
- maximum number of arguments that the function takes. The function
- should be written in the following manner:
-
- /* do_xxx --- do xxx function for gawk */
-
- NODE *
- do_xxx(int nargs)
- {
- ...
- }
+File: gawk.info, Node: Derived Files, Prev: New Ports, Up: Additions
-`NODE *get_argument(int i)'
- This function is called from within a C extension function to get
- the `i'-th argument from the function call. The first argument is
- argument zero.
-
-`NODE *get_actual_argument(int i,'
-` int optional, int wantarray);'
- This function retrieves a particular argument `i'. `wantarray' is
- `TRUE' if the argument should be an array, `FALSE' otherwise. If
- `optional' is `TRUE', the argument need not have been supplied.
- If it wasn't, the return value is `NULL'. It is a fatal error if
- `optional' is `TRUE' but the argument was not provided.
-
-`get_scalar_argument(i, opt)'
- This is a convenience macro that calls `get_actual_argument()'.
-
-`get_array_argument(i, opt)'
- This is a convenience macro that calls `get_actual_argument()'.
-
-`void update_ERRNO(void)'
- This function is called from within a C extension function to set
- the value of `gawk''s `ERRNO' variable, based on the current value
- of the C `errno' global variable. It is provided as a convenience.
-
-`void update_ERRNO_saved(int errno_saved)'
- This function is called from within a C extension function to set
- the value of `gawk''s `ERRNO' variable, based on the error value
- provided as the argument. It is provided as a convenience.
-
-`void register_deferred_variable(const char *name, NODE *(*load_func)(void))'
- This function is called to register a function to be called when a
- reference to an undefined variable with the given name is
- encountered. The callback function will never be called if the
- variable exists already, so, unless the calling code is running at
- program startup, it should first check whether a variable of the
- given name already exists. The argument function must return a
- pointer to a `NODE' containing the newly created variable. This
- function is used to implement the builtin `ENVIRON' and `PROCINFO'
- arrays, so you can refer to them for examples.
-
-`void register_open_hook(void *(*open_func)(IOBUF *))'
- This function is called to register a function to be called
- whenever a new data file is opened, leading to the creation of an
- `IOBUF' structure in `iop_alloc()'. After creating the new
- `IOBUF', `iop_alloc()' will call (in reverse order of
- registration, so the last function registered is called first)
- each open hook until one returns non-`NULL'. If any hook returns
- a non-`NULL' value, that value is assigned to the `IOBUF''s
- `opaque' field (which will presumably point to a structure
- containing additional state associated with the input processing),
- and no further open hooks are called.
-
- The function called will most likely want to set the `IOBUF''s
- `get_record' method to indicate that future input records should
- be retrieved by calling that method instead of using the standard
- `gawk' input processing.
-
- And the function will also probably want to set the `IOBUF''s
- `close_func' method to be called when the file is closed to clean
- up any state associated with the input.
-
- Finally, hook functions should be prepared to receive an `IOBUF'
- structure where the `fd' field is set to `INVALID_HANDLE', meaning
- that `gawk' was not able to open the file itself. In this case,
- the hook function must be able to successfully open the file and
- place a valid file descriptor there.
-
- Currently, for example, the hook function facility is used to
- implement the XML parser shared library extension. For more info,
- please look in `awk.h' and in `io.c'.
-
- An argument that is supposed to be an array needs to be handled with
-some extra code, in case the array being passed in is actually from a
-function parameter.
-
- The following boilerplate code shows how to do this:
-
- NODE *the_arg;
-
- /* assume need 3rd arg, 0-based */
- the_arg = get_array_argument(2, FALSE);
-
- Again, you should spend time studying the `gawk' internals; don't
-just blindly copy this code.
-
-
-File: gawk.info, Node: Plugin License, Next: Sample Library, Prev: Internals, Up: Dynamic Extensions
-
-C.3.2 Extension Licensing
--------------------------
-
-Every dynamic extension should define the global symbol
-`plugin_is_GPL_compatible' to assert that it has been licensed under a
-GPL-compatible license. If this symbol does not exist, `gawk' will
-emit a fatal error and exit.
-
- The declared type of the symbol should be `int'. It does not need
-to be in any allocated section, though. The code merely asserts that
-the symbol exists in the global scope. Something like this is enough:
-
- int plugin_is_GPL_compatible;
-
-
-File: gawk.info, Node: Sample Library, Prev: Plugin License, Up: Dynamic Extensions
-
-C.3.3 Example: Directory and File Operation Built-ins
------------------------------------------------------
-
-Two useful functions that are not in `awk' are `chdir()' (so that an
-`awk' program can change its directory) and `stat()' (so that an `awk'
-program can gather information about a file). This minor node
-implements these functions for `gawk' in an external extension library.
-
-* Menu:
-
-* Internal File Description:: What the new functions will do.
-* Internal File Ops:: The code for internal file operations.
-* Using Internal File Ops:: How to use an external extension.
-
-
-File: gawk.info, Node: Internal File Description, Next: Internal File Ops, Up: Sample Library
-
-C.3.3.1 Using `chdir()' and `stat()'
-....................................
-
-This minor node shows how to use the new functions at the `awk' level
-once they've been integrated into the running `gawk' interpreter.
-Using `chdir()' is very straightforward. It takes one argument, the new
-directory to change to:
-
- ...
- newdir = "/home/arnold/funstuff"
- ret = chdir(newdir)
- if (ret < 0) {
- printf("could not change to %s: %s\n",
- newdir, ERRNO) > "/dev/stderr"
- exit 1
- }
- ...
-
- The return value is negative if the `chdir' failed, and `ERRNO'
-(*note Built-in Variables::) is set to a string indicating the error.
-
- Using `stat()' is a bit more complicated. The C `stat()' function
-fills in a structure that has a fair amount of information. The right
-way to model this in `awk' is to fill in an associative array with the
-appropriate information:
-
- file = "/home/arnold/.profile"
- fdata[1] = "x" # force `fdata' to be an array
- ret = stat(file, fdata)
- if (ret < 0) {
- printf("could not stat %s: %s\n",
- file, ERRNO) > "/dev/stderr"
- exit 1
- }
- printf("size of %s is %d bytes\n", file, fdata["size"])
-
- The `stat()' function always clears the data array, even if the
-`stat()' fails. It fills in the following elements:
-
-`"name"'
- The name of the file that was `stat()''ed.
-
-`"dev"'
-`"ino"'
- The file's device and inode numbers, respectively.
-
-`"mode"'
- The file's mode, as a numeric value. This includes both the file's
- type and its permissions.
-
-`"nlink"'
- The number of hard links (directory entries) the file has.
-
-`"uid"'
-`"gid"'
- The numeric user and group ID numbers of the file's owner.
-
-`"size"'
- The size in bytes of the file.
-
-`"blocks"'
- The number of disk blocks the file actually occupies. This may not
- be a function of the file's size if the file has holes.
-
-`"atime"'
-`"mtime"'
-`"ctime"'
- The file's last access, modification, and inode update times,
- respectively. These are numeric timestamps, suitable for
- formatting with `strftime()' (*note Built-in::).
-
-`"pmode"'
- The file's "printable mode." This is a string representation of
- the file's type and permissions, such as what is produced by `ls
- -l'--for example, `"drwxr-xr-x"'.
-
-`"type"'
- A printable string representation of the file's type. The value
- is one of the following:
+C.2.4 Why Generated Files Are Kept In `git'
+-------------------------------------------
- `"blockdev"'
- `"chardev"'
- The file is a block or character device ("special file").
+If you look at the `gawk' source in the `git' repository, you will
+notice that it includes files that are automatically generated by GNU
+infrastructure tools, such as `Makefile.in' from `automake' and even
+`configure' from `autoconf'.
- `"directory"'
- The file is a directory.
+ This is different from many Free Software projects that do not store
+the derived files, because that keeps the repository less cluttered,
+and it is easier to see the substantive changes when comparing versions
+and trying to understand what changed between commits.
- `"fifo"'
- The file is a named-pipe (also known as a FIFO).
+ However, there are two reasons why the `gawk' maintainer likes to
+have everything in the repository.
- `"file"'
- The file is just a regular file.
+ First, because it is then easy to reproduce any given version
+completely, without relying upon the availability of (older, likely
+obsolete, and maybe even impossible to find) other tools.
- `"socket"'
- The file is an `AF_UNIX' ("Unix domain") socket in the
- filesystem.
+ As an extreme example, if you ever even think about trying to
+compile, oh, say, the V7 `awk', you will discover that not only do you
+have to bootstrap the V7 `yacc' to do so, but you also need the V7
+`lex'. And the latter is pretty much impossible to bring up on a
+modern GNU/Linux system.(1)
- `"symlink"'
- The file is a symbolic link.
-
- Several additional elements may be present depending upon the
-operating system and the type of the file. You can test for them in
-your `awk' program by using the `in' operator (*note Reference to
-Elements::):
+ (Or, let's say `gawk' 1.2 required `bison' whatever-it-was in 1989
+and that there was no `awkgram.c' file in the repository. Is there a
+guarantee that we could find that `bison' version? Or that _it_ would
+build?)
-`"blksize"'
- The preferred block size for I/O to the file. This field is not
- present on all POSIX-like systems in the C `stat' structure.
+ If the repository has all the generated files, then it's easy to
+just check them out and build. (Or _easier_, depending upon how far
+back we go. `:-)')
-`"linkval"'
- If the file is a symbolic link, this element is the name of the
- file the link points to (i.e., the value of the link).
+ And that brings us to the second (and stronger) reason why all the
+files really need to be in `git'. It boils down to who do you cater
+to--the `gawk' developer(s), or the user who just wants to check out a
+version and try it out?
-`"rdev"'
-`"major"'
-`"minor"'
- If the file is a block or character device file, then these values
- represent the numeric device number and the major and minor
- components of that number, respectively.
+ The `gawk' maintainer wants it to be possible for any interested
+`awk' user in the world to just clone the repository, check out the
+branch of interest and build it. Without their having to have the
+correct version(s) of the autotools.(2) That is the point of the
+`bootstrap.sh' file. It touches the various other files in the right
+order such that
-
-File: gawk.info, Node: Internal File Ops, Next: Using Internal File Ops, Prev: Internal File Description, Up: Sample Library
+ # The canonical incantation for building GNU software:
+ ./bootstrap.sh && ./configure && make
-C.3.3.2 C Code for `chdir()' and `stat()'
-.........................................
+will _just work_.
-Here is the C code for these extensions. They were written for
-GNU/Linux. The code needs some more work for complete portability to
-other POSIX-compliant systems:(1)
+ This is extremely important for the `master' and `gawk-X.Y-stable'
+branches.
- #include "awk.h"
+ Further, the `gawk' maintainer would argue that it's also important
+for the `gawk' developers. When he tried to check out the `xgawk'
+branch(3) to build it, he couldn't. (No `ltmain.sh' file, and he had no
+idea how to create it, and that was not the only problem.)
- #include <sys/sysmacros.h>
+ He felt _extremely_ frustrated. With respect to that branch, the
+maintainer is no different than Jane User who wants to try to build
+`gawk-4.0-stable' or `master' from the repository.
- int plugin_is_GPL_compatible;
+ Thus, the maintainer thinks that it's not just important, but
+critical, that for any given branch, the above incantation _just works_.
- /* do_chdir --- provide dynamically loaded chdir() builtin for gawk */
+ What are some of the consequences and/or actions to take?
- static NODE *
- do_chdir(int nargs)
- {
- NODE *newdir;
- int ret = -1;
+ 1. We don't mind that there are differing files in the different
+ branches as a result of different versions of the autotools.
- if (do_lint && get_curfunc_arg_count() != 1)
- lintwarn("chdir: called with incorrect number of arguments");
+ A. It's the maintainer's job to merge them and he will deal with
+ it.
- newdir = get_scalar_argument(0, FALSE);
+ B. He is really good at `git diff x y > /tmp/diff1 ; gvim
+ /tmp/diff1' to remove the diffs that aren't of interest in
+ order to review code. `:-)'
- The file includes the `"awk.h"' header file for definitions for the
-`gawk' internals. It includes `<sys/sysmacros.h>' for access to the
-`major()' and `minor'() macros.
+ 2. It would certainly help if everyone used the same versions of the
+ GNU tools as he does, which in general are the latest released
+ versions of `automake', `autoconf', `bison', and `gettext'.
- By convention, for an `awk' function `foo', the function that
-implements it is called `do_foo'. The function should take a `int'
-argument, usually called `nargs', that represents the number of defined
-arguments for the function. The `newdir' variable represents the new
-directory to change to, retrieved with `get_scalar_argument()'. Note
-that the first argument is numbered zero.
+ A. Installing from source is quite easy. It's how the maintainer
+ worked for years under Fedora. He had `/usr/local/bin' at
+ the front of hs `PATH' and just did:
- This code actually accomplishes the `chdir()'. It first forces the
-argument to be a string and passes the string value to the `chdir()'
-system call. If the `chdir()' fails, `ERRNO' is updated.
+ wget http://ftp.gnu.org/gnu/PACKAGE/PACKAGE-X.Y.Z.tar.gz
+ tar -xpzvf PACKAGE-X.Y.Z.tar.gz
+ cd PACKAGE-X.Y.Z
+ ./configure && make && make check
+ make install # as root
- (void) force_string(newdir);
- ret = chdir(newdir->stptr);
- if (ret < 0)
- update_ERRNO();
+ B. These days the maintainer uses Ubuntu 10.11 which is medium
+ current, but he is already doing the above for `autoconf' and
+ `bison'.
- Finally, the function returns the return value to the `awk' level:
- return make_number((AWKNUM) ret);
- }
- The `stat()' built-in is more involved. First comes a function that
-turns a numeric mode into a printable representation (e.g., 644 becomes
-`-rw-r--r--'). This is omitted here for brevity:
+ Most of the above was originally written by the maintainer to other
+`gawk' developers. It raised the objection from one of the developers
+"... that anybody pulling down the source from `git' is not an end
+user."
- /* format_mode --- turn a stat mode field into something readable */
+ However, this is not true. There are "power `awk' users" who can
+build `gawk' (using the magic incantation shown previously) but who
+can't program in C. Thus, the major branches should be kept buildable
+all the time.
- static char *
- format_mode(unsigned long fmode)
- {
- ...
- }
+ It was then suggested that there be a `cron' job to create nightly
+tarballs of "the source." Here, the problem is that there are source
+trees, corresponding to the various branches! So, nightly tar balls
+aren't the answer, especially as the repository can go for weeks
+without significant change being introduced.
- Next comes the `do_stat()' function. It starts with variable
-declarations and argument checking:
+ Fortunately, the `git' server can meet this need. For any given
+branch named BRANCHNAME, use:
- /* do_stat --- provide a stat() function for gawk */
+ wget http://git.savannah.gnu.org/cgit/gawk.git/snapshot/gawk-BRANCHNAME.tar.gz
- static NODE *
- do_stat(int nargs)
- {
- NODE *file, *array, *tmp;
- struct stat sbuf;
- int ret;
- NODE **aptr;
- char *pmode; /* printable mode */
- char *type = "unknown";
-
- if (do_lint && get_curfunc_arg_count() > 2)
- lintwarn("stat: called with too many arguments");
-
- Then comes the actual work. First, the function gets the arguments.
-Then, it always clears the array. The code use `lstat()' (instead of
-`stat()') to get the file information, in case the file is a symbolic
-link. If there's an error, it sets `ERRNO' and returns:
-
- /* file is first arg, array to hold results is second */
- file = get_scalar_argument(0, FALSE);
- array = get_array_argument(1, FALSE);
-
- /* empty out the array */
- assoc_clear(array);
-
- /* lstat the file, if error, set ERRNO and return */
- (void) force_string(file);
- ret = lstat(file->stptr, & sbuf);
- if (ret < 0) {
- update_ERRNO();
- return make_number((AWKNUM) ret);
- }
-
- Now comes the tedious part: filling in the array. Only a few of the
-calls are shown here, since they all follow the same pattern:
-
- /* fill in the array */
- aptr = assoc_lookup(array, tmp = make_string("name", 4), FALSE);
- *aptr = dupnode(file);
- unref(tmp);
-
- aptr = assoc_lookup(array, tmp = make_string("mode", 4), FALSE);
- *aptr = make_number((AWKNUM) sbuf.st_mode);
- unref(tmp);
-
- aptr = assoc_lookup(array, tmp = make_string("pmode", 5), FALSE);
- pmode = format_mode(sbuf.st_mode);
- *aptr = make_string(pmode, strlen(pmode));
- unref(tmp);
-
- When done, return the `lstat()' return value:
-
-
- return make_number((AWKNUM) ret);
- }
-
- Finally, it's necessary to provide the "glue" that loads the new
-function(s) into `gawk'. By convention, each library has a routine
-named `dlload()' that does the job:
-
- /* dlload --- load new builtins in this library */
-
- NODE *
- dlload(NODE *tree, void *dl)
- {
- make_builtin("chdir", do_chdir, 1);
- make_builtin("stat", do_stat, 2);
- return make_number((AWKNUM) 0);
- }
-
- And that's it! As an exercise, consider adding functions to
-implement system calls such as `chown()', `chmod()', and `umask()'.
+to retrieve a snapshot of the given branch.
---------- Footnotes ----------
- (1) This version is edited slightly for presentation. See
-`extension/filefuncs.c' in the `gawk' distribution for the complete
-version.
-
-
-File: gawk.info, Node: Using Internal File Ops, Prev: Internal File Ops, Up: Sample Library
-
-C.3.3.3 Integrating the Extensions
-..................................
-
-Now that the code is written, it must be possible to add it at runtime
-to the running `gawk' interpreter. First, the code must be compiled.
-Assuming that the functions are in a file named `filefuncs.c', and IDIR
-is the location of the `gawk' include files, the following steps create
-a GNU/Linux shared library:
-
- $ gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -IIDIR filefuncs.c
- $ ld -o filefuncs.so -shared filefuncs.o
-
- Once the library exists, it is loaded by calling the `extension()'
-built-in function. This function takes two arguments: the name of the
-library to load and the name of a function to call when the library is
-first loaded. This function adds the new functions to `gawk'. It
-returns the value returned by the initialization function within the
-shared library:
-
- # file testff.awk
- BEGIN {
- extension("./filefuncs.so", "dlload")
-
- chdir(".") # no-op
+ (1) We tried. It was painful.
- data[1] = 1 # force `data' to be an array
- print "Info for testff.awk"
- ret = stat("testff.awk", data)
- print "ret =", ret
- for (i in data)
- printf "data[\"%s\"] = %s\n", i, data[i]
- print "testff.awk modified:",
- strftime("%m %d %y %H:%M:%S", data["mtime"])
-
- print "\nInfo for JUNK"
- ret = stat("JUNK", data)
- print "ret =", ret
- for (i in data)
- printf "data[\"%s\"] = %s\n", i, data[i]
- print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"])
- }
+ (2) There is one GNU program that is (in our opinion) severely
+difficult to bootstrap from the `git' repository. For example, on the
+author's old (but still working) PowerPC macintosh with Mac OS X 10.5,
+it was necessary to bootstrap a ton of software, starting with `git'
+itself, in order to try to work with the latest code. It's not
+pleasant, and especially on older systems, it's a big waste of time.
- Here are the results of running the program:
+ Starting with the latest tarball was no picnic either. The
+maintainers had dropped `.gz' and `.bz2' files and only distribute
+`.tar.xz' files. It was necessary to bootstrap `xz' first!
- $ gawk -f testff.awk
- -| Info for testff.awk
- -| ret = 0
- -| data["size"] = 607
- -| data["ino"] = 14945891
- -| data["name"] = testff.awk
- -| data["pmode"] = -rw-rw-r--
- -| data["nlink"] = 1
- -| data["atime"] = 1293993369
- -| data["mtime"] = 1288520752
- -| data["mode"] = 33204
- -| data["blksize"] = 4096
- -| data["dev"] = 2054
- -| data["type"] = file
- -| data["gid"] = 500
- -| data["uid"] = 500
- -| data["blocks"] = 8
- -| data["ctime"] = 1290113572
- -| testff.awk modified: 10 31 10 12:25:52
- -|
- -| Info for JUNK
- -| ret = -1
- -| JUNK modified: 01 01 70 02:00:00
+ (3) A branch created by one of the other developers that did not
+include the generated files.

-File: gawk.info, Node: Future Extensions, Prev: Dynamic Extensions, Up: Notes
+File: gawk.info, Node: Future Extensions, Prev: Additions, Up: Notes
-C.4 Probable Future Extensions
+C.3 Probable Future Extensions
==============================
AWK is a language similar to PERL, only considerably more elegant.
@@ -22386,12 +23677,9 @@ well.
Following is a list of probable future changes visible at the `awk'
language level:
-Loadable module interface
- It is not clear that the `awk'-level interface to the modules
- facility is as good as it should be. The interface needs to be
- redesigned, particularly taking namespace issues into account, as
- well as possibly including issues such as library search path order
- and versioning.
+Databases
+ It may be possible to map a GDBM/NDBM/SDBM file into an `awk'
+ array.
`RECLEN' variable for fixed-length records
Along with `FIELDWIDTHS', this would speed up the processing of
@@ -22399,30 +23687,12 @@ Loadable module interface
`"RECLEN"', depending upon which kind of record processing is in
effect.
-Databases
- It may be possible to map a GDBM/NDBM/SDBM file into an `awk'
- array.
-
More `lint' warnings
There are more things that could be checked for portability.
Following is a list of probable improvements that will make `gawk''s
source code easier to work with:
-Loadable module mechanics
- The current extension mechanism works (*note Dynamic Extensions::),
- but is rather primitive. It requires a fair amount of manual work
- to create and integrate a loadable module. Nor is the current
- mechanism as portable as might be desired. The GNU `libtool'
- package provides a number of features that would make using
- loadable modules much easier. `gawk' should be changed to use
- `libtool'.
-
-Loadable module internals
- The API to its internals that `gawk' "exports" should be revised.
- Too many things are needlessly exposed. A new API should be
- designed and implemented to make module writing easier.
-
Better array subscript management
`gawk''s management of array subscript storage could use revamping,
so that using the same value to index multiple arrays only stores
@@ -22451,7 +23721,6 @@ introductory texts that you should refer to instead.)
* Basic High Level:: The high level view.
* Basic Data Typing:: A very quick intro to data types.
-* Floating Point Issues:: Stuff to know about floating-point numbers.

File: gawk.info, Node: Basic High Level, Next: Basic Data Typing, Up: Basic Concepts
@@ -22550,7 +23819,7 @@ such as C, C++, or Ada, and then translated, or "compiled", into a form
that the computer can execute directly.

-File: gawk.info, Node: Basic Data Typing, Next: Floating Point Issues, Prev: Basic High Level, Up: Basic Concepts
+File: gawk.info, Node: Basic Data Typing, Prev: Basic High Level, Up: Basic Concepts
D.2 Data Values in a Computer
=============================
@@ -22570,34 +23839,10 @@ characters that comprise them. Individual variables, as well as
numeric and string variables, are referred to as "scalar" values.
Groups of values, such as arrays, are not scalars.
- Within computers, there are two kinds of numeric values: "integers"
-and "floating-point". In school, integer values were referred to as
-"whole" numbers--that is, numbers without any fractional part, such as
-1, 42, or -17. The advantage to integer numbers is that they represent
-values exactly. The disadvantage is that their range is limited. On
-most systems, this range is -2,147,483,648 to 2,147,483,647. However,
-many systems now support a range from -9,223,372,036,854,775,808 to
-9,223,372,036,854,775,807.
-
- Integer values come in two flavors: "signed" and "unsigned". Signed
-values may be negative or positive, with the range of values just
-described. Unsigned values are always positive. On most systems, the
-range is from 0 to 4,294,967,295. However, many systems now support a
-range from 0 to 18,446,744,073,709,551,615.
-
- Floating-point numbers represent what are called "real" numbers;
-i.e., those that do have a fractional part, such as 3.1415927. The
-advantage to floating-point numbers is that they can represent a much
-larger range of values. The disadvantage is that there are numbers
-that they cannot represent exactly. `awk' uses "double precision"
-floating-point numbers, which can hold more digits than "single
-precision" floating-point numbers. Floating-point issues are discussed
-more fully in *note Floating Point Issues::.
-
- At the very lowest level, computers store values as groups of binary
-digits, or "bits". Modern computers group bits into groups of eight,
-called "bytes". Advanced applications sometimes have to manipulate
-bits directly, and `gawk' provides functions for doing so.
+ *note General Arithmetic::, provided a basic introduction to numeric
+types (integer and floating-point) and how they are used in a computer.
+Please review that information, including a number of caveats that were
+presented.
While you are probably used to the idea of a number without a value
(i.e., zero), it takes a bit more getting used to the idea of
@@ -22618,6 +23863,11 @@ represents 1 times 8, plus 0 times 4, plus 1 times 2, plus 0 times 1,
or decimal 10. Octal and hexadecimal are discussed more in *note
Nondecimal-numbers::.
+ At the very lowest level, computers store values as groups of binary
+digits, or "bits". Modern computers group bits into groups of eight,
+called "bytes". Advanced applications sometimes have to manipulate
+bits directly, and `gawk' provides functions for doing so.
+
Programs are written in programming languages. Hundreds, if not
thousands, of programming languages exist. One of the most popular is
the C programming language. The C language had a very strong influence
@@ -22635,218 +23885,6 @@ In 1999, a revised ISO C standard was approved and released. Where it
makes sense, POSIX `awk' is compatible with 1999 ISO C.

-File: gawk.info, Node: Floating Point Issues, Prev: Basic Data Typing, Up: Basic Concepts
-
-D.3 Floating-Point Number Caveats
-=================================
-
-As mentioned earlier, floating-point numbers represent what are called
-"real" numbers, i.e., those that have a fractional part. `awk' uses
-double precision floating-point numbers to represent all numeric
-values. This minor node describes some of the issues involved in using
-floating-point numbers.
-
- There is a very nice paper on floating-point arithmetic
-(http://www.validlab.com/goldberg/paper.pdf) by David Goldberg, "What
-Every Computer Scientist Should Know About Floating-point Arithmetic,"
-`ACM Computing Surveys' *23*, 1 (1991-03), 5-48. This is worth reading
-if you are interested in the details, but it does require a background
-in computer science.
-
-* Menu:
-
-* String Conversion Precision:: The String Value Can Lie.
-* Unexpected Results:: Floating Point Numbers Are Not Abstract
- Numbers.
-* POSIX Floating Point Problems:: Standards Versus Existing Practice.
-
-
-File: gawk.info, Node: String Conversion Precision, Next: Unexpected Results, Up: Floating Point Issues
-
-D.3.1 The String Value Can Lie
-------------------------------
-
-Internally, `awk' keeps both the numeric value (double precision
-floating-point) and the string value for a variable. Separately, `awk'
-keeps track of what type the variable has (*note Typing and
-Comparison::), which plays a role in how variables are used in
-comparisons.
-
- It is important to note that the string value for a number may not
-reflect the full value (all the digits) that the numeric value actually
-contains. The following program (`values.awk') illustrates this:
-
- {
- sum = $1 + $2
- # see it for what it is
- printf("sum = %.12g\n", sum)
- # use CONVFMT
- a = "<" sum ">"
- print "a =", a
- # use OFMT
- print "sum =", sum
- }
-
-This program shows the full value of the sum of `$1' and `$2' using
-`printf', and then prints the string values obtained from both
-automatic conversion (via `CONVFMT') and from printing (via `OFMT').
-
- Here is what happens when the program is run:
-
- $ echo 3.654321 1.2345678 | awk -f values.awk
- -| sum = 4.8888888
- -| a = <4.88889>
- -| sum = 4.88889
-
- This makes it clear that the full numeric value is different from
-what the default string representations show.
-
- `CONVFMT''s default value is `"%.6g"', which yields a value with at
-least six significant digits. For some applications, you might want to
-change it to specify more precision. On most modern machines, most of
-the time, 17 digits is enough to capture a floating-point number's
-value exactly.(1)
-
- ---------- Footnotes ----------
-
- (1) Pathological cases can require up to 752 digits (!), but we
-doubt that you need to worry about this.
-
-
-File: gawk.info, Node: Unexpected Results, Next: POSIX Floating Point Problems, Prev: String Conversion Precision, Up: Floating Point Issues
-
-D.3.2 Floating Point Numbers Are Not Abstract Numbers
------------------------------------------------------
-
-Unlike numbers in the abstract sense (such as what you studied in high
-school or college math), numbers stored in computers are limited in
-certain ways. They cannot represent an infinite number of digits, nor
-can they always represent things exactly. In particular,
-floating-point numbers cannot always represent values exactly. Here is
-an example:
-
- $ awk '{ printf("%010d\n", $1 * 100) }'
- 515.79
- -| 0000051579
- 515.80
- -| 0000051579
- 515.81
- -| 0000051580
- 515.82
- -| 0000051582
- Ctrl-d
-
-This shows that some values can be represented exactly, whereas others
-are only approximated. This is not a "bug" in `awk', but simply an
-artifact of how computers represent numbers.
-
- Another peculiarity of floating-point numbers on modern systems is
-that they often have more than one representation for the number zero!
-In particular, it is possible to represent "minus zero" as well as
-regular, or "positive" zero.
-
- This example shows that negative and positive zero are distinct
-values when stored internally, but that they are in fact equal to each
-other, as well as to "regular" zero:
-
- $ gawk 'BEGIN { mz = -0 ; pz = 0
- > printf "-0 = %g, +0 = %g, (-0 == +0) -> %d\n", mz, pz, mz == pz
- > printf "mz == 0 -> %d, pz == 0 -> %d\n", mz == 0, pz == 0
- > }'
- -| -0 = -0, +0 = 0, (-0 == +0) -> 1
- -| mz == 0 -> 1, pz == 0 -> 1
-
- It helps to keep this in mind should you process numeric data that
-contains negative zero values; the fact that the zero is negative is
-noted and can affect comparisons.
-
-
-File: gawk.info, Node: POSIX Floating Point Problems, Prev: Unexpected Results, Up: Floating Point Issues
-
-D.3.3 Standards Versus Existing Practice
-----------------------------------------
-
-Historically, `awk' has converted any non-numeric looking string to the
-numeric value zero, when required. Furthermore, the original
-definition of the language and the original POSIX standards specified
-that `awk' only understands decimal numbers (base 10), and not octal
-(base 8) or hexadecimal numbers (base 16).
-
- Changes in the language of the 2001 and 2004 POSIX standard can be
-interpreted to imply that `awk' should support additional features.
-These features are:
-
- * Interpretation of floating point data values specified in
- hexadecimal notation (`0xDEADBEEF'). (Note: data values, _not_
- source code constants.)
-
- * Support for the special IEEE 754 floating point values "Not A
- Number" (NaN), positive Infinity ("inf") and negative Infinity
- ("-inf"). In particular, the format for these values is as
- specified by the ISO 1999 C standard, which ignores case and can
- allow machine-dependent additional characters after the `nan' and
- allow either `inf' or `infinity'.
-
- The first problem is that both of these are clear changes to
-historical practice:
-
- * The `gawk' maintainer feels that supporting hexadecimal floating
- point values, in particular, is ugly, and was never intended by the
- original designers to be part of the language.
-
- * Allowing completely alphabetic strings to have valid numeric
- values is also a very severe departure from historical practice.
-
- The second problem is that the `gawk' maintainer feels that this
-interpretation of the standard, which requires a certain amount of
-"language lawyering" to arrive at in the first place, was not even
-intended by the standard developers. In other words, "we see how you
-got where you are, but we don't think that that's where you want to be."
-
- The 2008 POSIX standard added explicit wording to allow, but not
-require, that `awk' support hexadecimal floating point values and
-special values for "Not A Number" and infinity.
-
- Although the `gawk' maintainer continues to feel that providing
-those features is inadvisable, nevertheless, on systems that support
-IEEE floating point, it seems reasonable to provide _some_ way to
-support NaN and Infinity values. The solution implemented in `gawk' is
-as follows:
-
- * With the `--posix' command-line option, `gawk' becomes "hands
- off." String values are passed directly to the system library's
- `strtod()' function, and if it successfully returns a numeric
- value, that is what's used.(1) By definition, the results are not
- portable across different systems. They are also a little
- surprising:
-
- $ echo nanny | gawk --posix '{ print $1 + 0 }'
- -| nan
- $ echo 0xDeadBeef | gawk --posix '{ print $1 + 0 }'
- -| 3735928559
-
- * Without `--posix', `gawk' interprets the four strings `+inf',
- `-inf', `+nan', and `-nan' specially, producing the corresponding
- special numeric values. The leading sign acts a signal to `gawk'
- (and the user) that the value is really numeric. Hexadecimal
- floating point is not supported (unless you also use
- `--non-decimal-data', which is _not_ recommended). For example:
-
- $ echo nanny | gawk '{ print $1 + 0 }'
- -| 0
- $ echo +nan | gawk '{ print $1 + 0 }'
- -| nan
- $ echo 0xDeadBeef | gawk '{ print $1 + 0 }'
- -| 0
-
- `gawk' does ignore case in the four special values. Thus `+nan'
- and `+NaN' are the same.
-
- ---------- Footnotes ----------
-
- (1) You asked for it, you got it.
-
-
File: gawk.info, Node: Glossary, Next: Copying, Prev: Basic Concepts, Up: Top
Glossary
@@ -24740,8 +25778,8 @@ Index
* ' (single quote): One-shot. (line 15)
* ' (single quote), vs. apostrophe: Comments. (line 27)
* ' (single quote), with double quotes: Quoting. (line 53)
+* () (parentheses) <1>: Profiling. (line 138)
* () (parentheses): Regexp Operators. (line 79)
-* () (parentheses), pgawk program: Profiling. (line 141)
* * (asterisk), * operator, as multiplication operator: Precedence.
(line 55)
* * (asterisk), * operator, as regexp operator: Regexp Operators.
@@ -24768,79 +25806,86 @@ Index
* - (hyphen), -- operator: Increment Ops. (line 48)
* - (hyphen), -= operator <1>: Precedence. (line 95)
* - (hyphen), -= operator: Assignment Ops. (line 129)
-* - (hyphen), filenames beginning with: Options. (line 59)
+* - (hyphen), filenames beginning with: Options. (line 73)
* - (hyphen), in bracket expressions: Bracket Expressions. (line 17)
-* --assign option: Options. (line 32)
-* --c option: Options. (line 81)
-* --characters-as-bytes option: Options. (line 68)
-* --command option: Options. (line 234)
-* --copyright option: Options. (line 88)
+* --assign option: Options. (line 46)
+* --bignum option: Options. (line 201)
+* --c option: Options. (line 95)
+* --characters-as-bytes option: Options. (line 82)
+* --copyright option: Options. (line 102)
+* --debug option: Options. (line 122)
* --disable-lint configuration option: Additional Configuration Options.
(line 9)
* --disable-nls configuration option: Additional Configuration Options.
(line 24)
* --dump-variables option <1>: Library Names. (line 45)
-* --dump-variables option: Options. (line 93)
-* --exec option: Options. (line 116)
+* --dump-variables option: Options. (line 107)
+* --exec option: Options. (line 139)
* --field-separator option: Options. (line 21)
* --file option: Options. (line 25)
* --gen-pot option <1>: String Extraction. (line 6)
-* --gen-pot option: Options. (line 138)
-* --help option: Options. (line 145)
-* --L option: Options. (line 248)
-* --lint option <1>: Options. (line 150)
+* --gen-pot option: Options. (line 161)
+* --help option: Options. (line 168)
+* --include option: Options. (line 32)
+* --L option: Options. (line 288)
+* --lint option <1>: Options. (line 182)
* --lint option: Command Line. (line 20)
-* --lint-old option: Options. (line 248)
+* --lint-old option: Options. (line 288)
+* --load option: Options. (line 173)
* --non-decimal-data option <1>: Nondecimal Data. (line 6)
-* --non-decimal-data option: Options. (line 169)
+* --non-decimal-data option: Options. (line 207)
* --non-decimal-data option, strtonum() function and: Nondecimal Data.
(line 36)
-* --optimize option: Options. (line 182)
-* --posix option: Options. (line 202)
-* --posix option, --traditional option and: Options. (line 221)
-* --profile option <1>: Profiling. (line 15)
-* --profile option: Options. (line 189)
-* --re-interval option: Options. (line 227)
-* --sandbox option: Options. (line 239)
+* --optimize option: Options. (line 228)
+* --posix option: Options. (line 247)
+* --posix option, --traditional option and: Options. (line 266)
+* --pretty-print option: Options. (line 220)
+* --profile option <1>: Profiling. (line 12)
+* --profile option: Options. (line 235)
+* --re-interval option: Options. (line 272)
+* --sandbox option: Options. (line 279)
* --sandbox option, disabling system() function: I/O Functions.
(line 85)
* --sandbox option, input redirection with getline: Getline. (line 19)
* --sandbox option, output redirection with print, printf: Redirection.
(line 6)
-* --source option: Options. (line 108)
-* --traditional option: Options. (line 81)
-* --traditional option, --posix option and: Options. (line 221)
-* --use-lc-numeric option: Options. (line 177)
-* --version option: Options. (line 253)
+* --source option: Options. (line 131)
+* --traditional option: Options. (line 95)
+* --traditional option, --posix option and: Options. (line 266)
+* --use-lc-numeric option: Options. (line 215)
+* --version option: Options. (line 293)
* --with-whiny-user-strftime configuration option: Additional Configuration Options.
(line 29)
-* -b option: Options. (line 68)
-* -C option: Options. (line 88)
-* -d option: Options. (line 93)
-* -E option: Options. (line 116)
-* -e option: Options. (line 108)
+* -b option: Options. (line 82)
+* -C option: Options. (line 102)
+* -D option: Options. (line 122)
+* -d option: Options. (line 107)
+* -E option: Options. (line 139)
+* -e option: Options. (line 131)
* -F option: Command Line Field Separator.
(line 6)
* -f option: Options. (line 25)
* -F option: Options. (line 21)
* -f option: Long. (line 12)
-* -F option, -Ft sets FS to TAB: Options. (line 261)
-* -f option, on command line: Options. (line 266)
-* -g option: Options. (line 138)
-* -h option: Options. (line 145)
-* -l option: Options. (line 150)
-* -N option: Options. (line 177)
-* -n option: Options. (line 169)
-* -O option: Options. (line 182)
-* -P option: Options. (line 202)
-* -p option: Options. (line 189)
-* -R option: Options. (line 234)
-* -r option: Options. (line 227)
-* -S option: Options. (line 239)
-* -V option: Options. (line 253)
-* -v option: Options. (line 32)
+* -F option, -Ft sets FS to TAB: Options. (line 301)
+* -f option, on command line: Options. (line 306)
+* -g option: Options. (line 161)
+* -h option: Options. (line 168)
+* -i option: Options. (line 32)
+* -l option: Options. (line 173)
+* -M option: Options. (line 201)
+* -N option: Options. (line 215)
+* -n option: Options. (line 207)
+* -O option: Options. (line 228)
+* -o option: Options. (line 220)
+* -P option: Options. (line 247)
+* -p option: Options. (line 235)
+* -r option: Options. (line 272)
+* -S option: Options. (line 279)
+* -V option: Options. (line 293)
+* -v option: Options. (line 46)
* -v option, variables, assigning: Assignment Options. (line 12)
-* -W option: Options. (line 46)
+* -W option: Options. (line 60)
* . (period): Regexp Operators. (line 43)
* .mo files: Explaining gettext. (line 41)
* .mo files, converting from .po: I18N Example. (line 62)
@@ -24969,7 +26014,7 @@ Index
* Ada programming language: Glossary. (line 20)
* adding, features to gawk: Adding Code. (line 6)
* adding, fields: Changing Fields. (line 53)
-* adding, functions to gawk: Dynamic Extensions. (line 10)
+* adding, functions to gawk: Dynamic Extensions. (line 9)
* advanced features, buffering: I/O Functions. (line 98)
* advanced features, close() function: Close Files And Pipes.
(line 131)
@@ -24977,7 +26022,7 @@ Index
(line 67)
* advanced features, data files as single record: Records. (line 180)
* advanced features, fixed-width data: Constant Size. (line 9)
-* advanced features, FNR/NR variables: Auto-set. (line 207)
+* advanced features, FNR/NR variables: Auto-set. (line 274)
* advanced features, gawk: Advanced Features. (line 6)
* advanced features, gawk, network programming: TCP/IP Networking.
(line 6)
@@ -25012,6 +26057,8 @@ Index
* and Boolean-logic operator: Boolean Ops. (line 6)
* and() function (gawk): Bitwise Functions. (line 39)
* ANSI: Glossary. (line 35)
+* arbitrary precision: Arbitrary Precision Arithmetic.
+ (line 6)
* archeologists: Bugs. (line 6)
* ARGC/ARGV variables <1>: ARGC and ARGV. (line 6)
* ARGC/ARGV variables: Auto-set. (line 11)
@@ -25026,18 +26073,15 @@ Index
* arguments, command-line, invoking awk: Command Line. (line 6)
* arguments, in function calls: Function Calls. (line 16)
* arguments, processing: Getopt Function. (line 6)
-* arguments, retrieving: Internals. (line 120)
* arithmetic operators: Arithmetic Ops. (line 6)
* arrays: Arrays. (line 6)
* arrays, as parameters to functions: Pass By Value/Reference.
(line 47)
* arrays, associative: Array Intro. (line 50)
-* arrays, associative, clearing: Internals. (line 75)
* arrays, associative, library functions and: Library Names. (line 57)
* arrays, deleting entire contents: Delete. (line 39)
* arrays, elements, assigning: Assigning Elements. (line 6)
* arrays, elements, deleting: Delete. (line 6)
-* arrays, elements, installing: Internals. (line 79)
* arrays, elements, order of: Scanning an Array. (line 48)
* arrays, elements, referencing: Reference to Elements.
(line 6)
@@ -25076,8 +26120,6 @@ Index
* assignment operators, evaluation order: Assignment Ops. (line 111)
* assignment operators, lvalues/rvalues: Assignment Ops. (line 32)
* assignments as filenames: Ignoring Assigns. (line 6)
-* assoc_clear() internal function: Internals. (line 75)
-* assoc_lookup() internal function: Internals. (line 79)
* associative arrays: Array Intro. (line 50)
* asterisk (*), * operator, as multiplication operator: Precedence.
(line 55)
@@ -25093,7 +26135,10 @@ Index
* asterisk (*), *= operator: Assignment Ops. (line 129)
* atan2() function: Numeric Functions. (line 11)
* awf (amazingly workable formatter) program: Glossary. (line 25)
+* awk debugging, enabling: Options. (line 122)
+* awk enabling: Options. (line 220)
* awk language, POSIX version: Assignment Ops. (line 136)
+* awk profiling, enabling: Options. (line 235)
* awk programs <1>: Two Rules. (line 6)
* awk programs <2>: Executable Scripts. (line 6)
* awk programs: Getting Started. (line 12)
@@ -25109,7 +26154,6 @@ Index
* awk programs, location of: Options. (line 25)
* awk programs, one-line examples: Very Simple. (line 45)
* awk programs, profiling: Profiling. (line 6)
-* awk programs, profiling, enabling: Options. (line 189)
* awk programs, running <1>: Long. (line 6)
* awk programs, running: Running gawk. (line 6)
* awk programs, running, from shell scripts: One-shot. (line 22)
@@ -25144,14 +26188,13 @@ Index
* awk, versions of, See Also Brian Kernighan's awk <1>: Other Versions.
(line 13)
* awk, versions of, See Also Brian Kernighan's awk: BTL. (line 6)
-* awk.h file (internal): Internals. (line 15)
* awka compiler for awk: Other Versions. (line 55)
-* AWKNUM internal type: Internals. (line 19)
+* AWKLIBPATH environment variable: AWKLIBPATH Variable. (line 6)
* AWKPATH environment variable <1>: PC Using. (line 11)
* AWKPATH environment variable: AWKPATH Variable. (line 6)
-* awkprof.out file: Profiling. (line 10)
+* awkprof.out file: Profiling. (line 6)
* awksed.awk program: Simple Sed. (line 25)
-* awkvars.out file: Options. (line 93)
+* awkvars.out file: Options. (line 107)
* b debugger command (alias for break): Breakpoint Control. (line 11)
* backslash (\) <1>: Regexp Operators. (line 18)
* backslash (\) <2>: Quoting. (line 31)
@@ -25203,12 +26246,13 @@ Index
* backslash (\), in escape sequences, POSIX and: Escape Sequences.
(line 113)
* backslash (\), regexp constants: Computed Regexps. (line 28)
-* backtrace debugger command: Dgawk Stack. (line 13)
+* backtrace debugger command: Execution Stack. (line 13)
* BBS-list file: Sample Data Files. (line 6)
* Beebe, Nelson <1>: Other Versions. (line 69)
* Beebe, Nelson: Acknowledgments. (line 60)
-* BEGIN pattern <1>: BEGIN/END. (line 6)
-* BEGIN pattern <2>: Field Separators. (line 44)
+* BEGIN pattern <1>: Profiling. (line 62)
+* BEGIN pattern <2>: BEGIN/END. (line 6)
+* BEGIN pattern <3>: Field Separators. (line 44)
* BEGIN pattern: Records. (line 29)
* BEGIN pattern, assert() user-defined function and: Assert Function.
(line 83)
@@ -25223,7 +26267,6 @@ Index
* BEGIN pattern, OFS/ORS variables, assigning values to: Output Separators.
(line 20)
* BEGIN pattern, operators and: Using BEGIN/END. (line 17)
-* BEGIN pattern, pgawk program: Profiling. (line 65)
* BEGIN pattern, print statement and: I/O And BEGIN/END. (line 16)
* BEGIN pattern, pwcat program: Passwd Functions. (line 143)
* BEGIN pattern, running awk programs and: Cut Program. (line 68)
@@ -25242,7 +26285,7 @@ Index
(line 33)
* BINMODE variable <1>: PC Using. (line 34)
* BINMODE variable: User-modified. (line 10)
-* bits2str() user-defined function: Bitwise Functions. (line 68)
+* bits2str() user-defined function: Bitwise Functions. (line 70)
* bitwise, complement: Bitwise Functions. (line 25)
* bitwise, operations: Bitwise Functions. (line 6)
* bitwise, shift: Bitwise Functions. (line 32)
@@ -25252,8 +26295,8 @@ Index
* Boolean expressions, as patterns: Expression Patterns. (line 41)
* Boolean operators, See Boolean expressions: Boolean Ops. (line 6)
* Bourne shell, quoting rules for: Quoting. (line 18)
+* braces ({}): Profiling. (line 134)
* braces ({}), actions and: Action Overview. (line 19)
-* braces ({}), pgawk program: Profiling. (line 137)
* braces ({}), statements, grouping: Statements. (line 10)
* bracket expressions <1>: Bracket Expressions. (line 6)
* bracket expressions: Regexp Operators. (line 55)
@@ -25280,7 +26323,7 @@ Index
* Broder, Alan J.: Contributors. (line 88)
* Brown, Martin: Contributors. (line 82)
* BSD-based operating systems: Glossary. (line 615)
-* bt debugger command (alias for backtrace): Dgawk Stack. (line 13)
+* bt debugger command (alias for backtrace): Execution Stack. (line 13)
* Buening, Andreas <1>: Bugs. (line 71)
* Buening, Andreas <2>: Contributors. (line 92)
* Buening, Andreas: Acknowledgments. (line 60)
@@ -25295,10 +26338,10 @@ Index
* built-in functions: Functions. (line 6)
* built-in functions, evaluation order: Calling Built-in. (line 30)
* built-in variables: Built-in Variables. (line 6)
-* built-in variables, -v option, setting with: Options. (line 40)
+* built-in variables, -v option, setting with: Options. (line 54)
* built-in variables, conveying information: Auto-set. (line 6)
* built-in variables, user-modifiable: User-modified. (line 6)
-* Busybox Awk: Other Versions. (line 78)
+* Busybox Awk: Other Versions. (line 79)
* call by reference: Pass By Value/Reference.
(line 47)
* call by value: Pass By Value/Reference.
@@ -25318,7 +26361,7 @@ Index
* case sensitivity, regexps and <1>: User-modified. (line 82)
* case sensitivity, regexps and: Case-sensitivity. (line 6)
* case sensitivity, string comparisons and: User-modified. (line 82)
-* CGI, awk scripts for: Options. (line 116)
+* CGI, awk scripts for: Options. (line 139)
* character lists, See bracket expressions: Regexp Operators. (line 55)
* character sets (machine character encodings) <1>: Glossary. (line 141)
* character sets (machine character encodings): Ordinal Functions.
@@ -25348,7 +26391,6 @@ Index
* close() function, two-way pipes and: Two-way I/O. (line 77)
* Close, Diane <1>: Contributors. (line 21)
* Close, Diane: Manual History. (line 41)
-* close_func() input method: Internals. (line 160)
* collating elements: Bracket Expressions. (line 69)
* collating symbols: Bracket Expressions. (line 76)
* Colombo, Antonio: Acknowledgments. (line 60)
@@ -25368,11 +26410,11 @@ Index
(line 6)
* command line, options <2>: Options. (line 6)
* command line, options: Long. (line 12)
-* command line, options, end of: Options. (line 54)
+* command line, options, end of: Options. (line 68)
* command line, variables, assigning on: Assignment Options. (line 6)
* command-line options, processing: Getopt Function. (line 6)
* command-line options, string extraction: String Extraction. (line 6)
-* commands debugger command: Dgawk Execution Control.
+* commands debugger command: Debugger Execution Control.
(line 10)
* commenting: Comments. (line 6)
* commenting, backslash continuation and: Statements/Lines. (line 76)
@@ -25404,14 +26446,14 @@ Index
(line 60)
* compatibility mode (gawk), octal numbers: Nondecimal-numbers.
(line 60)
-* compatibility mode (gawk), specifying: Options. (line 81)
+* compatibility mode (gawk), specifying: Options. (line 95)
* compiled programs <1>: Glossary. (line 161)
* compiled programs: Basic High Level. (line 14)
* compiling gawk for Cygwin: Cygwin. (line 6)
* compiling gawk for MS-DOS and MS-Windows: PC Compiling. (line 13)
* compiling gawk for VMS: VMS Compilation. (line 6)
* compiling gawk with EMX for OS/2: PC Compiling. (line 28)
-* compl() function (gawk): Bitwise Functions. (line 42)
+* compl() function (gawk): Bitwise Functions. (line 43)
* complement, bitwise: Bitwise Functions. (line 25)
* compound statements, control statements and: Statements. (line 10)
* concatenating: Concatenation. (line 9)
@@ -25425,17 +26467,21 @@ Index
(line 29)
* configuration options, gawk: Additional Configuration Options.
(line 6)
+* constants, floating-point: Floating-point Constants.
+ (line 6)
* constants, nondecimal: Nondecimal Data. (line 6)
* constants, types of: Constants. (line 6)
+* context, floating-point: Floating-point Context.
+ (line 6)
* continue statement: Continue Statement. (line 6)
* control statements: Statements. (line 6)
* converting, case: String Functions. (line 522)
* converting, dates to timestamps: Time Functions. (line 74)
* converting, during subscripting: Numeric Array Subscripts.
(line 31)
-* converting, numbers to strings <1>: Bitwise Functions. (line 107)
+* converting, numbers to strings <1>: Bitwise Functions. (line 109)
* converting, numbers to strings: Conversion. (line 6)
-* converting, strings to numbers <1>: Bitwise Functions. (line 107)
+* converting, strings to numbers <1>: Bitwise Functions. (line 109)
* converting, strings to numbers: Conversion. (line 6)
* CONVFMT variable <1>: User-modified. (line 28)
* CONVFMT variable: Conversion. (line 29)
@@ -25449,7 +26495,7 @@ Index
* cos() function: Numeric Functions. (line 15)
* counting: Wc Program. (line 6)
* csh utility: Statements/Lines. (line 44)
-* csh utility, POSIXLY_CORRECT environment variable: Options. (line 308)
+* csh utility, POSIXLY_CORRECT environment variable: Options. (line 348)
* csh utility, |& operator, comparison with: Two-way I/O. (line 44)
* ctime() user-defined function: Function Example. (line 72)
* currency symbols, localization: Explaining gettext. (line 103)
@@ -25457,7 +26503,7 @@ Index
(line 30)
* cut utility: Cut Program. (line 6)
* cut.awk program: Cut Program. (line 45)
-* d debugger command (alias for delete): Breakpoint Control. (line 63)
+* d debugger command (alias for delete): Breakpoint Control. (line 64)
* d.c., See dark corner: Conventions. (line 38)
* dark corner <1>: Glossary. (line 193)
* dark corner <2>: Truth Values. (line 24)
@@ -25479,9 +26525,9 @@ Index
* dark corner, exit statement: Exit Statement. (line 30)
* dark corner, field separators: Field Splitting Summary.
(line 47)
-* dark corner, FILENAME variable <1>: Auto-set. (line 92)
+* dark corner, FILENAME variable <1>: Auto-set. (line 93)
* dark corner, FILENAME variable: Getline Notes. (line 19)
-* dark corner, FNR/NR variables: Auto-set. (line 207)
+* dark corner, FNR/NR variables: Auto-set. (line 274)
* dark corner, format-control characters: Control Letters. (line 18)
* dark corner, FS as null string: Single Character Fields.
(line 20)
@@ -25521,119 +26567,121 @@ Index
(line 33)
* deadlocks: Two-way I/O. (line 70)
* debugger commands, b (break): Breakpoint Control. (line 11)
-* debugger commands, backtrace: Dgawk Stack. (line 13)
+* debugger commands, backtrace: Execution Stack. (line 13)
* debugger commands, break: Breakpoint Control. (line 11)
-* debugger commands, bt (backtrace): Dgawk Stack. (line 13)
-* debugger commands, c (continue): Dgawk Execution Control.
+* debugger commands, bt (backtrace): Execution Stack. (line 13)
+* debugger commands, c (continue): Debugger Execution Control.
(line 33)
* debugger commands, clear: Breakpoint Control. (line 36)
-* debugger commands, commands: Dgawk Execution Control.
+* debugger commands, commands: Debugger Execution Control.
(line 10)
* debugger commands, condition: Breakpoint Control. (line 54)
-* debugger commands, continue: Dgawk Execution Control.
+* debugger commands, continue: Debugger Execution Control.
(line 33)
-* debugger commands, d (delete): Breakpoint Control. (line 63)
-* debugger commands, delete: Breakpoint Control. (line 63)
-* debugger commands, disable: Breakpoint Control. (line 68)
+* debugger commands, d (delete): Breakpoint Control. (line 64)
+* debugger commands, delete: Breakpoint Control. (line 64)
+* debugger commands, disable: Breakpoint Control. (line 69)
* debugger commands, display: Viewing And Changing Data.
(line 8)
-* debugger commands, down: Dgawk Stack. (line 21)
-* debugger commands, dump: Miscellaneous Dgawk Commands.
+* debugger commands, down: Execution Stack. (line 21)
+* debugger commands, dump: Miscellaneous Debugger Commands.
(line 9)
-* debugger commands, e (enable): Breakpoint Control. (line 72)
-* debugger commands, enable: Breakpoint Control. (line 72)
-* debugger commands, end: Dgawk Execution Control.
+* debugger commands, e (enable): Breakpoint Control. (line 73)
+* debugger commands, enable: Breakpoint Control. (line 73)
+* debugger commands, end: Debugger Execution Control.
(line 10)
* debugger commands, eval: Viewing And Changing Data.
(line 23)
-* debugger commands, f (frame): Dgawk Stack. (line 25)
-* debugger commands, finish: Dgawk Execution Control.
+* debugger commands, f (frame): Execution Stack. (line 25)
+* debugger commands, finish: Debugger Execution Control.
(line 39)
-* debugger commands, frame: Dgawk Stack. (line 25)
-* debugger commands, h (help): Miscellaneous Dgawk Commands.
+* debugger commands, frame: Execution Stack. (line 25)
+* debugger commands, h (help): Miscellaneous Debugger Commands.
(line 68)
-* debugger commands, help: Miscellaneous Dgawk Commands.
+* debugger commands, help: Miscellaneous Debugger Commands.
(line 68)
-* debugger commands, i (info): Dgawk Info. (line 12)
-* debugger commands, ignore: Breakpoint Control. (line 86)
-* debugger commands, info: Dgawk Info. (line 12)
-* debugger commands, l (list): Miscellaneous Dgawk Commands.
+* debugger commands, i (info): Debugger Info. (line 13)
+* debugger commands, ignore: Breakpoint Control. (line 87)
+* debugger commands, info: Debugger Info. (line 13)
+* debugger commands, l (list): Miscellaneous Debugger Commands.
(line 74)
-* debugger commands, list: Miscellaneous Dgawk Commands.
+* debugger commands, list: Miscellaneous Debugger Commands.
(line 74)
-* debugger commands, n (next): Dgawk Execution Control.
+* debugger commands, n (next): Debugger Execution Control.
(line 43)
-* debugger commands, next: Dgawk Execution Control.
+* debugger commands, next: Debugger Execution Control.
(line 43)
-* debugger commands, nexti: Dgawk Execution Control.
+* debugger commands, nexti: Debugger Execution Control.
(line 49)
-* debugger commands, ni (nexti): Dgawk Execution Control.
+* debugger commands, ni (nexti): Debugger Execution Control.
(line 49)
-* debugger commands, o (option): Dgawk Info. (line 56)
-* debugger commands, option: Dgawk Info. (line 56)
+* debugger commands, o (option): Debugger Info. (line 57)
+* debugger commands, option: Debugger Info. (line 57)
* debugger commands, p (print): Viewing And Changing Data.
(line 36)
* debugger commands, print: Viewing And Changing Data.
(line 36)
* debugger commands, printf: Viewing And Changing Data.
(line 54)
-* debugger commands, q (quit): Miscellaneous Dgawk Commands.
+* debugger commands, q (quit): Miscellaneous Debugger Commands.
(line 101)
-* debugger commands, quit: Miscellaneous Dgawk Commands.
+* debugger commands, quit: Miscellaneous Debugger Commands.
(line 101)
-* debugger commands, r (run): Dgawk Execution Control.
+* debugger commands, r (run): Debugger Execution Control.
(line 62)
-* debugger commands, return: Dgawk Execution Control.
+* debugger commands, return: Debugger Execution Control.
(line 54)
-* debugger commands, run: Dgawk Execution Control.
+* debugger commands, run: Debugger Execution Control.
(line 62)
-* debugger commands, s (step): Dgawk Execution Control.
+* debugger commands, s (step): Debugger Execution Control.
(line 68)
* debugger commands, set: Viewing And Changing Data.
(line 59)
-* debugger commands, si (stepi): Dgawk Execution Control.
+* debugger commands, si (stepi): Debugger Execution Control.
(line 76)
-* debugger commands, silent: Dgawk Execution Control.
+* debugger commands, silent: Debugger Execution Control.
(line 10)
-* debugger commands, step: Dgawk Execution Control.
+* debugger commands, step: Debugger Execution Control.
(line 68)
-* debugger commands, stepi: Dgawk Execution Control.
+* debugger commands, stepi: Debugger Execution Control.
(line 76)
-* debugger commands, t (tbreak): Breakpoint Control. (line 89)
-* debugger commands, tbreak: Breakpoint Control. (line 89)
-* debugger commands, trace: Miscellaneous Dgawk Commands.
+* debugger commands, t (tbreak): Breakpoint Control. (line 90)
+* debugger commands, tbreak: Breakpoint Control. (line 90)
+* debugger commands, trace: Miscellaneous Debugger Commands.
(line 110)
-* debugger commands, u (until): Dgawk Execution Control.
+* debugger commands, u (until): Debugger Execution Control.
(line 83)
* debugger commands, undisplay: Viewing And Changing Data.
(line 80)
-* debugger commands, until: Dgawk Execution Control.
+* debugger commands, until: Debugger Execution Control.
(line 83)
* debugger commands, unwatch: Viewing And Changing Data.
(line 84)
-* debugger commands, up: Dgawk Stack. (line 33)
+* debugger commands, up: Execution Stack. (line 33)
* debugger commands, w (watch): Viewing And Changing Data.
(line 67)
* debugger commands, watch: Viewing And Changing Data.
(line 67)
+* debugging awk programs: Debugger. (line 6)
* debugging gawk, bug reports: Bugs. (line 9)
-* decimal point character, locale specific: Options. (line 218)
+* decimal point character, locale specific: Options. (line 263)
* decrement operators: Increment Ops. (line 35)
* default keyword: Switch Statement. (line 6)
* Deifik, Scott <1>: Bugs. (line 70)
* Deifik, Scott <2>: Contributors. (line 54)
* Deifik, Scott: Acknowledgments. (line 60)
-* delete debugger command: Breakpoint Control. (line 63)
+* delete debugger command: Breakpoint Control. (line 64)
* delete statement: Delete. (line 6)
* deleting elements in arrays: Delete. (line 6)
* deleting entire arrays: Delete. (line 39)
-* dgawk: Debugger. (line 6)
* differences between gawk and awk: String Functions. (line 196)
* differences in awk and gawk, ARGC/ARGV variables: ARGC and ARGV.
(line 88)
* differences in awk and gawk, ARGIND variable: Auto-set. (line 40)
* differences in awk and gawk, array elements, deleting: Delete.
(line 39)
+* differences in awk and gawk, AWKLIBPATH environment variable: AWKLIBPATH Variable.
+ (line 6)
* differences in awk and gawk, AWKPATH environment variable: AWKPATH Variable.
(line 6)
* differences in awk and gawk, BEGIN/END patterns: I/O And BEGIN/END.
@@ -25644,11 +26692,12 @@ Index
(line 23)
* differences in awk and gawk, close() function: Close Files And Pipes.
(line 81)
-* differences in awk and gawk, ERRNO variable: Auto-set. (line 72)
+* differences in awk and gawk, ERRNO variable: Auto-set. (line 73)
* differences in awk and gawk, error messages: Special FD. (line 16)
* differences in awk and gawk, FIELDWIDTHS variable: User-modified.
(line 35)
* differences in awk and gawk, FPAT variable: User-modified. (line 45)
+* differences in awk and gawk, FUNCTAB variable: Auto-set. (line 119)
* differences in awk and gawk, function arguments (gawk): Calling Built-in.
(line 16)
* differences in awk and gawk, getline command: Getline. (line 19)
@@ -25673,14 +26722,14 @@ Index
(line 6)
* differences in awk and gawk, print/printf statements: Format Modifiers.
(line 13)
-* differences in awk and gawk, PROCINFO array: Auto-set. (line 123)
+* differences in awk and gawk, PROCINFO array: Auto-set. (line 130)
* differences in awk and gawk, record separators: Records. (line 117)
* differences in awk and gawk, regexp constants: Using Constant Regexps.
(line 43)
* differences in awk and gawk, regular expressions: Case-sensitivity.
(line 26)
* differences in awk and gawk, RS/RT variables: Records. (line 172)
-* differences in awk and gawk, RT variable: Auto-set. (line 196)
+* differences in awk and gawk, RT variable: Auto-set. (line 246)
* differences in awk and gawk, single-character fields: Single Character Fields.
(line 6)
* differences in awk and gawk, split() function: String Functions.
@@ -25689,16 +26738,18 @@ Index
* differences in awk and gawk, strings, storing: Records. (line 192)
* differences in awk and gawk, strtonum() function (gawk): String Functions.
(line 404)
+* differences in awk and gawk, SYMTAB variable: Auto-set. (line 254)
* differences in awk and gawk, TEXTDOMAIN variable: User-modified.
- (line 153)
+ (line 162)
* differences in awk and gawk, trunc-mod operation: Arithmetic Ops.
(line 66)
* directories, changing: Sample Library. (line 6)
* directories, command line: Command line directories.
(line 6)
* directories, searching <1>: Igawk Program. (line 368)
+* directories, searching <2>: AWKLIBPATH Variable. (line 6)
* directories, searching: AWKPATH Variable. (line 6)
-* disable debugger command: Breakpoint Control. (line 68)
+* disable debugger command: Breakpoint Control. (line 69)
* display debugger command: Viewing And Changing Data.
(line 8)
* division: Arithmetic Ops. (line 44)
@@ -25712,18 +26763,17 @@ Index
* dollar sign ($), $ field operator: Fields. (line 19)
* dollar sign ($), incrementing fields and arrays: Increment Ops.
(line 30)
-* double precision floating-point: Basic Data Typing. (line 36)
+* double precision floating-point: General Arithmetic. (line 21)
* double quote (") <1>: Quoting. (line 37)
* double quote ("): Read Terminal. (line 25)
* double quote ("), regexp constants: Computed Regexps. (line 28)
-* down debugger command: Dgawk Stack. (line 21)
+* down debugger command: Execution Stack. (line 21)
* Drepper, Ulrich: Acknowledgments. (line 52)
* DuBois, John: Acknowledgments. (line 60)
-* dump debugger command: Miscellaneous Dgawk Commands.
+* dump debugger command: Miscellaneous Debugger Commands.
(line 9)
-* dupnode() internal function: Internals. (line 96)
* dupword.awk program: Dupword Program. (line 31)
-* e debugger command (alias for enable): Breakpoint Control. (line 72)
+* e debugger command (alias for enable): Breakpoint Control. (line 73)
* EBCDIC: Ordinal Functions. (line 45)
* egrep utility <1>: Egrep Program. (line 6)
* egrep utility: Bracket Expressions. (line 24)
@@ -25739,9 +26789,10 @@ Index
* empty pattern: Empty. (line 6)
* empty strings, See null strings: Regexp Field Splitting.
(line 43)
-* enable debugger command: Breakpoint Control. (line 72)
-* end debugger command: Dgawk Execution Control.
+* enable debugger command: Breakpoint Control. (line 73)
+* end debugger command: Debugger Execution Control.
(line 10)
+* END pattern <1>: Profiling. (line 62)
* END pattern: BEGIN/END. (line 6)
* END pattern, assert() user-defined function and: Assert Function.
(line 75)
@@ -25753,7 +26804,6 @@ Index
* END pattern, next/nextfile statements and: I/O And BEGIN/END.
(line 37)
* END pattern, operators and: Using BEGIN/END. (line 17)
-* END pattern, pgawk program: Profiling. (line 65)
* END pattern, print statement and: I/O And BEGIN/END. (line 16)
* ENDFILE pattern: BEGINFILE/ENDFILE. (line 6)
* ENDFILE pattern, Boolean patterns and: Expression Patterns. (line 73)
@@ -25762,7 +26812,6 @@ Index
* endgrent() user-defined function: Group Functions. (line 218)
* endpwent() function (C library): Passwd Functions. (line 210)
* endpwent() user-defined function: Passwd Functions. (line 213)
-* ENVIRON array <1>: Internals. (line 149)
* ENVIRON array: Auto-set. (line 60)
* environment variables: Auto-set. (line 60)
* epoch, definition of: Glossary. (line 239)
@@ -25771,15 +26820,14 @@ Index
* equals sign (=), == operator: Comparison Operators.
(line 11)
* EREs (Extended Regular Expressions): Bracket Expressions. (line 24)
-* ERRNO variable <1>: Internals. (line 139)
-* ERRNO variable <2>: TCP/IP Networking. (line 54)
-* ERRNO variable <3>: Auto-set. (line 72)
-* ERRNO variable <4>: BEGINFILE/ENDFILE. (line 26)
-* ERRNO variable <5>: Close Files And Pipes.
+* ERRNO variable <1>: TCP/IP Networking. (line 54)
+* ERRNO variable <2>: Auto-set. (line 73)
+* ERRNO variable <3>: BEGINFILE/ENDFILE. (line 26)
+* ERRNO variable <4>: Close Files And Pipes.
(line 139)
* ERRNO variable: Getline. (line 19)
* error handling: Special FD. (line 16)
-* error handling, ERRNO variable and: Auto-set. (line 72)
+* error handling, ERRNO variable and: Auto-set. (line 73)
* error output: Special FD. (line 6)
* escape processing, gsub()/gensub()/sub() functions: Gory Details.
(line 6)
@@ -25820,7 +26868,6 @@ Index
(line 9)
* expressions, selecting: Conditional Exp. (line 6)
* Extended Regular Expressions (EREs): Bracket Expressions. (line 24)
-* eXtensible Markup Language (XML): Internals. (line 160)
* extension() function (gawk): Using Internal File Ops.
(line 15)
* extensions, Brian Kernighan's awk <1>: Other Versions. (line 13)
@@ -25845,7 +26892,7 @@ Index
* extract.awk program: Extract Program. (line 78)
* extraction, of marked strings (internationalization): String Extraction.
(line 6)
-* f debugger command (alias for frame): Dgawk Stack. (line 25)
+* f debugger command (alias for frame): Execution Stack. (line 25)
* false, logical: Truth Values. (line 6)
* FDL (Free Documentation License): GNU Free Documentation License.
(line 6)
@@ -25894,7 +26941,7 @@ Index
* file names, distinguishing: Auto-set. (line 52)
* file names, in compatibility mode: Special Caveats. (line 9)
* file names, standard streams in gawk: Special FD. (line 46)
-* FILENAME variable <1>: Auto-set. (line 92)
+* FILENAME variable <1>: Auto-set. (line 93)
* FILENAME variable: Reading Files. (line 6)
* FILENAME variable, getline, setting with: Getline Notes. (line 19)
* filenames, assignments as: Ignoring Assigns. (line 6)
@@ -25912,8 +26959,8 @@ Index
* files, /inet6/... (gawk): TCP/IP Networking. (line 6)
* files, as single records: Records. (line 201)
* files, awk programs in: Long. (line 6)
-* files, awkprof.out: Profiling. (line 10)
-* files, awkvars.out: Options. (line 93)
+* files, awkprof.out: Profiling. (line 6)
+* files, awkvars.out: Options. (line 107)
* files, closing: I/O Functions. (line 10)
* files, descriptors, See file descriptors: Special FD. (line 6)
* files, group: Group Functions. (line 6)
@@ -25941,7 +26988,7 @@ Index
* files, portable object template: Explaining gettext. (line 30)
* files, portable object, converting to message object files: I18N Example.
(line 62)
-* files, portable object, generating: Options. (line 138)
+* files, portable object, generating: Options. (line 161)
* files, processing, ARGIND variable and: Auto-set. (line 47)
* files, reading: Rewind Function. (line 6)
* files, reading, multiline records: Multiple Line. (line 6)
@@ -25950,23 +26997,21 @@ Index
* files, source, search path for: Igawk Program. (line 368)
* files, splitting: Split Program. (line 6)
* files, Texinfo, extracting programs from: Extract Program. (line 6)
-* finish debugger command: Dgawk Execution Control.
+* finish debugger command: Debugger Execution Control.
(line 39)
* Fish, Fred: Contributors. (line 51)
* fixed-width data: Constant Size. (line 9)
* flag variables <1>: Tee Program. (line 20)
* flag variables: Boolean Ops. (line 67)
+* floating-point numbers, arbitrary precision: Arbitrary Precision Arithmetic.
+ (line 6)
* floating-point, numbers <1>: Unexpected Results. (line 6)
-* floating-point, numbers: Basic Data Typing. (line 21)
-* floating-point, numbers, AWKNUM internal type: Internals. (line 19)
-* FNR variable <1>: Auto-set. (line 102)
+* floating-point, numbers: General Arithmetic. (line 6)
+* FNR variable <1>: Auto-set. (line 103)
* FNR variable: Records. (line 6)
-* FNR variable, changing: Auto-set. (line 207)
+* FNR variable, changing: Auto-set. (line 274)
* for statement: For Statement. (line 6)
* for statement, in arrays: Scanning an Array. (line 20)
-* force_number() internal function: Internals. (line 27)
-* force_string() internal function: Internals. (line 32)
-* force_wstring() internal function: Internals. (line 37)
* format specifiers, mixing regular with positional specifiers: Printf Ordering.
(line 57)
* format specifiers, printf statement: Control Letters. (line 6)
@@ -25985,7 +27030,7 @@ Index
* FPAT variable <1>: User-modified. (line 45)
* FPAT variable: Splitting By Content.
(line 26)
-* frame debugger command: Dgawk Stack. (line 25)
+* frame debugger command: Execution Stack. (line 25)
* Free Documentation License (FDL): GNU Free Documentation License.
(line 6)
* Free Software Foundation (FSF) <1>: Glossary. (line 301)
@@ -25997,7 +27042,7 @@ Index
* FS variable, --field-separator option and: Options. (line 21)
* FS variable, as null string: Single Character Fields.
(line 20)
-* FS variable, as TAB character: Options. (line 214)
+* FS variable, as TAB character: Options. (line 259)
* FS variable, changing value of: Field Separators. (line 34)
* FS variable, running awk programs and: Cut Program. (line 68)
* FS variable, setting from command line: Command Line Field Separator.
@@ -26007,6 +27052,7 @@ Index
* FSF (Free Software Foundation) <1>: Glossary. (line 301)
* FSF (Free Software Foundation) <2>: Getting. (line 10)
* FSF (Free Software Foundation): Manual History. (line 6)
+* FUNCTAB array: Auto-set. (line 119)
* function calls: Function Calls. (line 6)
* function calls, indirect: Indirect Calls. (line 6)
* function pointers: Indirect Calls. (line 6)
@@ -26014,7 +27060,7 @@ Index
(line 47)
* functions, built-in <1>: Functions. (line 6)
* functions, built-in: Function Calls. (line 10)
-* functions, built-in, adding to gawk: Dynamic Extensions. (line 10)
+* functions, built-in, adding to gawk: Dynamic Extensions. (line 9)
* functions, built-in, evaluation order: Calling Built-in. (line 30)
* functions, defining: Definition Syntax. (line 6)
* functions, library: Library Functions. (line 6)
@@ -26032,7 +27078,7 @@ Index
(line 6)
* functions, library, managing data files: Data File Management.
(line 6)
-* functions, library, managing time: Gettimeofday Function.
+* functions, library, managing time: Getlocaltime Function.
(line 6)
* functions, library, merging arrays into strings: Join Function.
(line 6)
@@ -26042,20 +27088,20 @@ Index
* functions, names of <1>: Definition Syntax. (line 20)
* functions, names of: Arrays. (line 18)
* functions, recursive: Definition Syntax. (line 73)
-* functions, return values, setting: Internals. (line 139)
* functions, string-translation: I18N Functions. (line 6)
* functions, undefined: Pass By Value/Reference.
(line 71)
* functions, user-defined: User-defined. (line 6)
* functions, user-defined, calling: Calling A Function. (line 6)
-* functions, user-defined, counts: Profiling. (line 132)
+* functions, user-defined, counts: Profiling. (line 129)
* functions, user-defined, library of: Library Functions. (line 6)
* functions, user-defined, next/nextfile statements and <1>: Nextfile Statement.
(line 47)
* functions, user-defined, next/nextfile statements and: Next Statement.
(line 45)
-* G-d: Acknowledgments. (line 81)
+* G-d: Acknowledgments. (line 83)
* Garfinkle, Scott: Contributors. (line 35)
+* gawk program, dynamic profiling: Profiling. (line 171)
* gawk, ARGIND variable in: Other Arguments. (line 12)
* gawk, awk and <1>: This Manual. (line 14)
* gawk, awk and: Preface. (line 23)
@@ -26076,13 +27122,13 @@ Index
* gawk, distribution: Distribution contents.
(line 6)
* gawk, ERRNO variable in <1>: TCP/IP Networking. (line 54)
-* gawk, ERRNO variable in <2>: Auto-set. (line 72)
+* gawk, ERRNO variable in <2>: Auto-set. (line 73)
* gawk, ERRNO variable in <3>: BEGINFILE/ENDFILE. (line 26)
* gawk, ERRNO variable in <4>: Close Files And Pipes.
(line 139)
* gawk, ERRNO variable in: Getline. (line 19)
* gawk, escape sequences: Escape Sequences. (line 125)
-* gawk, extensions, disabling: Options. (line 202)
+* gawk, extensions, disabling: Options. (line 247)
* gawk, features, adding: Adding Code. (line 6)
* gawk, features, advanced: Advanced Features. (line 6)
* gawk, fflush() function in: I/O Functions. (line 44)
@@ -26094,8 +27140,9 @@ Index
* gawk, FPAT variable in <1>: User-modified. (line 45)
* gawk, FPAT variable in: Splitting By Content.
(line 26)
+* gawk, FUNCTAB array in: Auto-set. (line 119)
* gawk, function arguments and: Calling Built-in. (line 16)
-* gawk, functions, adding: Dynamic Extensions. (line 10)
+* gawk, functions, adding: Dynamic Extensions. (line 9)
* gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42)
* gawk, IGNORECASE variable in <1>: Array Sorting Functions.
(line 81)
@@ -26110,7 +27157,6 @@ Index
* gawk, implementation issues, limits: Getline Notes. (line 14)
* gawk, implementation issues, pipes: Redirection. (line 135)
* gawk, installing: Installation. (line 6)
-* gawk, internals: Internals. (line 6)
* gawk, internationalization and, See internationalization: Internationalization.
(line 13)
* gawk, interpreter, adding code to: Using Internal File Ops.
@@ -26126,7 +27172,7 @@ Index
* gawk, OS/2 version of: PC Using. (line 11)
* gawk, PROCINFO array in <1>: Two-way I/O. (line 116)
* gawk, PROCINFO array in <2>: Time Functions. (line 46)
-* gawk, PROCINFO array in: Auto-set. (line 123)
+* gawk, PROCINFO array in: Auto-set. (line 130)
* gawk, regexp constants and: Using Constant Regexps.
(line 28)
* gawk, regular expressions, case sensitivity: Case-sensitivity.
@@ -26134,7 +27180,7 @@ Index
* gawk, regular expressions, operators: GNU Regexp Operators.
(line 6)
* gawk, regular expressions, precedence: Regexp Operators. (line 161)
-* gawk, RT variable in <1>: Auto-set. (line 196)
+* gawk, RT variable in <1>: Auto-set. (line 246)
* gawk, RT variable in <2>: Getline/Variable/File.
(line 10)
* gawk, RT variable in <3>: Multiple Line. (line 129)
@@ -26143,10 +27189,11 @@ Index
* gawk, source code, obtaining: Getting. (line 6)
* gawk, splitting fields and: Constant Size. (line 87)
* gawk, string-translation functions: I18N Functions. (line 6)
-* gawk, TEXTDOMAIN variable in: User-modified. (line 153)
+* gawk, SYMTAB array in: Auto-set. (line 254)
+* gawk, TEXTDOMAIN variable in: User-modified. (line 162)
* gawk, timestamps: Time Functions. (line 6)
* gawk, uses for: Preface. (line 36)
-* gawk, versions of, information about, printing: Options. (line 253)
+* gawk, versions of, information about, printing: Options. (line 293)
* gawk, VMS version of: VMS Installation. (line 6)
* gawk, word-boundary operator: GNU Regexp Operators.
(line 63)
@@ -26156,12 +27203,6 @@ Index
* gensub() function (gawk): Using Constant Regexps.
(line 43)
* gensub() function (gawk), escape processing: Gory Details. (line 6)
-* get_actual_argument() internal function: Internals. (line 125)
-* get_argument() internal function: Internals. (line 120)
-* get_array_argument() internal macro: Internals. (line 136)
-* get_curfunc_arg_count() internal function: Internals. (line 42)
-* get_record() input method: Internals. (line 160)
-* get_scalar_argument() internal macro: Internals. (line 133)
* getaddrinfo() function (C library): TCP/IP Networking. (line 38)
* getgrent() function (C library): Group Functions. (line 6)
* getgrent() user-defined function: Group Functions. (line 6)
@@ -26186,6 +27227,8 @@ Index
* getline command, variants: Getline Summary. (line 6)
* getline statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE.
(line 54)
+* getlocaltime() user-defined function: Getlocaltime Function.
+ (line 16)
* getopt() function (C library): Getopt Function. (line 15)
* getopt() user-defined function: Getopt Function. (line 108)
* getpwent() function (C library): Passwd Functions. (line 16)
@@ -26197,8 +27240,8 @@ Index
* gettext library: Explaining gettext. (line 6)
* gettext library, locale categories: Explaining gettext. (line 80)
* gettext() function (C library): Explaining gettext. (line 62)
-* gettimeofday() user-defined function: Gettimeofday Function.
- (line 16)
+* GMP: Arbitrary Precision Arithmetic.
+ (line 6)
* GNITS mailing list: Acknowledgments. (line 52)
* GNU awk, See gawk: Preface. (line 49)
* GNU Free Documentation License: GNU Free Documentation License.
@@ -26207,7 +27250,7 @@ Index
* GNU Lesser General Public License: Glossary. (line 401)
* GNU long options <1>: Options. (line 6)
* GNU long options: Command Line. (line 13)
-* GNU long options, printing list of: Options. (line 145)
+* GNU long options, printing list of: Options. (line 168)
* GNU Project <1>: Glossary. (line 319)
* GNU Project: Manual History. (line 11)
* GNU/Linux <1>: Glossary. (line 615)
@@ -26215,7 +27258,7 @@ Index
* GNU/Linux: Manual History. (line 28)
* GPL (General Public License) <1>: Glossary. (line 310)
* GPL (General Public License): Manual History. (line 11)
-* GPL (General Public License), printing: Options. (line 88)
+* GPL (General Public License), printing: Options. (line 102)
* grcat program: Group Functions. (line 16)
* Grigera, Juan: Contributors. (line 58)
* group database, reading: Group Functions. (line 6)
@@ -26226,7 +27269,7 @@ Index
(line 43)
* gsub() function, arguments of: String Functions. (line 462)
* gsub() function, escape processing: Gory Details. (line 6)
-* h debugger command (alias for help): Miscellaneous Dgawk Commands.
+* h debugger command (alias for help): Miscellaneous Debugger Commands.
(line 68)
* Hankerson, Darrel <1>: Contributors. (line 61)
* Hankerson, Darrel: Acknowledgments. (line 60)
@@ -26235,28 +27278,30 @@ Index
* Hartholz, Elaine: Acknowledgments. (line 38)
* Hartholz, Marshall: Acknowledgments. (line 38)
* Hasegawa, Isamu: Contributors. (line 94)
-* help debugger command: Miscellaneous Dgawk Commands.
+* help debugger command: Miscellaneous Debugger Commands.
(line 68)
* hexadecimal numbers: Nondecimal-numbers. (line 6)
-* hexadecimal values, enabling interpretation of: Options. (line 169)
+* hexadecimal values, enabling interpretation of: Options. (line 207)
* histsort.awk program: History Sorting. (line 25)
* Hughes, Phil: Acknowledgments. (line 43)
-* HUP signal: Profiling. (line 204)
+* HUP signal: Profiling. (line 203)
* hyphen (-), - operator: Precedence. (line 52)
* hyphen (-), -- (decrement/increment) operators: Precedence. (line 46)
* hyphen (-), -- operator: Increment Ops. (line 48)
* hyphen (-), -= operator <1>: Precedence. (line 95)
* hyphen (-), -= operator: Assignment Ops. (line 129)
-* hyphen (-), filenames beginning with: Options. (line 59)
+* hyphen (-), filenames beginning with: Options. (line 73)
* hyphen (-), in bracket expressions: Bracket Expressions. (line 17)
-* i debugger command (alias for info): Dgawk Info. (line 12)
+* i debugger command (alias for info): Debugger Info. (line 13)
* id utility: Id Program. (line 6)
* id.awk program: Id Program. (line 30)
+* IEEE-754 format: Floating-point Representation.
+ (line 6)
* if statement <1>: If Statement. (line 6)
* if statement: Regexp Usage. (line 19)
* if statement, actions, changing: Ranges. (line 25)
* igawk.sh program: Igawk Program. (line 124)
-* ignore debugger command: Breakpoint Control. (line 86)
+* ignore debugger command: Breakpoint Control. (line 87)
* IGNORECASE variable <1>: Array Sorting Functions.
(line 81)
* IGNORECASE variable <2>: String Functions. (line 29)
@@ -26284,7 +27329,9 @@ Index
* index() function: String Functions. (line 155)
* indexing arrays: Array Intro. (line 50)
* indirect function calls: Indirect Calls. (line 6)
-* info debugger command: Dgawk Info. (line 12)
+* infinite precision: Arbitrary Precision Arithmetic.
+ (line 6)
+* info debugger command: Debugger Info. (line 13)
* initialization, automatic: More Complex. (line 38)
* input files: Reading Files. (line 6)
* input files, closing: Close Files And Pipes.
@@ -26309,47 +27356,18 @@ Index
* insomnia, cure for: Alarm Program. (line 6)
* installation, VMS: VMS Installation. (line 6)
* installing gawk: Installation. (line 6)
-* INT signal (MS-Windows): Profiling. (line 207)
+* INT signal (MS-Windows): Profiling. (line 206)
* int() function: Numeric Functions. (line 23)
-* integers: Basic Data Typing. (line 21)
-* integers, unsigned: Basic Data Typing. (line 30)
+* integer, arbitrary precision: Arbitrary Precision Integers.
+ (line 6)
+* integers: General Arithmetic. (line 6)
+* integers, unsigned: General Arithmetic. (line 15)
* interacting with other programs: I/O Functions. (line 63)
-* internal constant, INVALID_HANDLE: Internals. (line 160)
-* internal function, assoc_clear(): Internals. (line 75)
-* internal function, assoc_lookup(): Internals. (line 79)
-* internal function, dupnode(): Internals. (line 96)
-* internal function, force_number(): Internals. (line 27)
-* internal function, force_string(): Internals. (line 32)
-* internal function, force_wstring(): Internals. (line 37)
-* internal function, get_actual_argument(): Internals. (line 125)
-* internal function, get_argument(): Internals. (line 120)
-* internal function, get_curfunc_arg_count(): Internals. (line 42)
-* internal function, iop_alloc(): Internals. (line 160)
-* internal function, make_builtin(): Internals. (line 106)
-* internal function, make_number(): Internals. (line 91)
-* internal function, make_string(): Internals. (line 86)
-* internal function, register_deferred_variable(): Internals. (line 149)
-* internal function, register_open_hook(): Internals. (line 160)
-* internal function, unref(): Internals. (line 101)
-* internal function, update_ERRNO(): Internals. (line 139)
-* internal function, update_ERRNO_saved(): Internals. (line 144)
-* internal macro, get_array_argument(): Internals. (line 136)
-* internal macro, get_scalar_argument(): Internals. (line 133)
-* internal structure, IOBUF: Internals. (line 160)
-* internal type, AWKNUM: Internals. (line 19)
-* internal type, NODE: Internals. (line 23)
-* internal variable, nargs: Internals. (line 49)
-* internal variable, stlen: Internals. (line 53)
-* internal variable, stptr: Internals. (line 53)
-* internal variable, type: Internals. (line 66)
-* internal variable, vname: Internals. (line 71)
-* internal variable, wstlen: Internals. (line 61)
-* internal variable, wstptr: Internals. (line 61)
* internationalization <1>: I18N and L10N. (line 6)
* internationalization: I18N Functions. (line 6)
* internationalization, localization <1>: Internationalization.
(line 13)
-* internationalization, localization: User-modified. (line 153)
+* internationalization, localization: User-modified. (line 162)
* internationalization, localization, character classes: Bracket Expressions.
(line 90)
* internationalization, localization, gawk and: Internationalization.
@@ -26364,10 +27382,7 @@ Index
* interpreted programs <1>: Glossary. (line 361)
* interpreted programs: Basic High Level. (line 14)
* interval expressions: Regexp Operators. (line 116)
-* INVALID_HANDLE internal constant: Internals. (line 160)
* inventory-shipped file: Sample Data Files. (line 32)
-* IOBUF internal structure: Internals. (line 160)
-* iop_alloc() internal function: Internals. (line 160)
* isarray() function (gawk): Type Functions. (line 11)
* ISO: Glossary. (line 372)
* ISO 8859-1: Glossary. (line 141)
@@ -26375,30 +27390,33 @@ Index
* Jacobs, Andrew: Passwd Functions. (line 90)
* Jaegermann, Michal <1>: Contributors. (line 46)
* Jaegermann, Michal: Acknowledgments. (line 60)
-* Java implementation of awk: Other Versions. (line 96)
+* Java implementation of awk: Other Versions. (line 97)
* Java programming language: Glossary. (line 384)
-* jawk: Other Versions. (line 96)
+* jawk: Other Versions. (line 97)
* Jedi knights: Undocumented. (line 6)
* join() user-defined function: Join Function. (line 18)
* Kahrs, Ju"rgen <1>: Contributors. (line 70)
* Kahrs, Ju"rgen: Acknowledgments. (line 60)
* Kasal, Stepan: Acknowledgments. (line 60)
* Kenobi, Obi-Wan: Undocumented. (line 6)
-* Kernighan, Brian <1>: Basic Data Typing. (line 74)
+* Kernighan, Brian <1>: Basic Data Typing. (line 55)
* Kernighan, Brian <2>: Other Versions. (line 13)
* Kernighan, Brian <3>: Contributors. (line 12)
* Kernighan, Brian <4>: BTL. (line 6)
* Kernighan, Brian <5>: Concatenation. (line 6)
-* Kernighan, Brian <6>: Acknowledgments. (line 75)
+* Kernighan, Brian <6>: Acknowledgments. (line 77)
* Kernighan, Brian <7>: Conventions. (line 34)
* Kernighan, Brian: History. (line 17)
-* kill command, dynamic profiling: Profiling. (line 182)
+* kill command, dynamic profiling: Profiling. (line 180)
* Knights, jedi: Undocumented. (line 6)
+* Knuth, Donald: Arbitrary Precision Arithmetic.
+ (line 6)
* Kwok, Conrad: Contributors. (line 35)
-* l debugger command (alias for list): Miscellaneous Dgawk Commands.
+* l debugger command (alias for list): Miscellaneous Debugger Commands.
(line 74)
* labels.awk program: Labels Program. (line 51)
* languages, data-driven: Basic High Level. (line 83)
+* Laurie, Dirk: Changing Precision. (line 6)
* LC_ALL locale category: Explaining gettext. (line 120)
* LC_COLLATE locale category: Explaining gettext. (line 93)
* LC_CTYPE locale category: Explaining gettext. (line 97)
@@ -26421,7 +27439,7 @@ Index
* length() function: String Functions. (line 166)
* Lesser General Public License (LGPL): Glossary. (line 401)
* LGPL (Lesser General Public License): Glossary. (line 401)
-* libmawk: Other Versions. (line 104)
+* libmawk: Other Versions. (line 105)
* libraries of awk functions: Library Functions. (line 6)
* libraries of awk functions, assertions: Assert Function. (line 6)
* libraries of awk functions, associative arrays and: Library Names.
@@ -26436,7 +27454,7 @@ Index
(line 6)
* libraries of awk functions, managing, data files: Data File Management.
(line 6)
-* libraries of awk functions, managing, time: Gettimeofday Function.
+* libraries of awk functions, managing, time: Getlocaltime Function.
(line 6)
* libraries of awk functions, merging arrays into strings: Join Function.
(line 6)
@@ -26459,20 +27477,21 @@ Index
* lint checking, array subscripts: Uninitialized Subscripts.
(line 43)
* lint checking, empty programs: Command Line. (line 16)
-* lint checking, issuing warnings: Options. (line 150)
+* lint checking, issuing warnings: Options. (line 182)
* lint checking, POSIXLY_CORRECT environment variable: Options.
- (line 292)
+ (line 332)
* lint checking, undefined functions: Pass By Value/Reference.
(line 88)
* LINT variable: User-modified. (line 98)
* Linux <1>: Glossary. (line 615)
* Linux <2>: I18N Example. (line 55)
* Linux: Manual History. (line 28)
-* list debugger command: Miscellaneous Dgawk Commands.
+* list debugger command: Miscellaneous Debugger Commands.
(line 74)
+* loading, library: Options. (line 173)
* local variables: Variable Scope. (line 6)
* locale categories: Explaining gettext. (line 80)
-* locale decimal point character: Options. (line 218)
+* locale decimal point character: Options. (line 263)
* locale, definition of: Locales. (line 6)
* localization: I18N and L10N. (line 6)
* localization, See internationalization, localization: I18N and L10N.
@@ -26485,18 +27504,14 @@ Index
* long options: Command Line. (line 13)
* loops: While Statement. (line 6)
* loops, continue statements and: For Statement. (line 64)
-* loops, count for header: Profiling. (line 126)
+* loops, count for header: Profiling. (line 123)
* loops, exiting: Break Statement. (line 6)
* loops, See Also while statement: While Statement. (line 6)
-* Lost In Space: Dynamic Extensions. (line 6)
* ls utility: More Complex. (line 15)
-* lshift() function (gawk): Bitwise Functions. (line 45)
+* lshift() function (gawk): Bitwise Functions. (line 46)
* lvalues/rvalues: Assignment Ops. (line 32)
* mailing labels, printing: Labels Program. (line 6)
* mailing list, GNITS: Acknowledgments. (line 52)
-* make_builtin() internal function: Internals. (line 106)
-* make_number() internal function: Internals. (line 91)
-* make_string() internal function: Internals. (line 86)
* mark parity: Ordinal Functions. (line 45)
* marked string extraction (internationalization): String Extraction.
(line 6)
@@ -26511,7 +27526,6 @@ Index
* matching, null strings: Gory Details. (line 164)
* mawk program: Other Versions. (line 35)
* McPhee, Patrick: Contributors. (line 100)
-* memory, releasing: Internals. (line 101)
* message object files: Explaining gettext. (line 41)
* message object files, converting from portable object files: I18N Example.
(line 62)
@@ -26523,8 +27537,12 @@ Index
* mktime() function (gawk): Time Functions. (line 24)
* modifiers, in format specifiers: Format Modifiers. (line 6)
* monetary information, localization: Explaining gettext. (line 103)
+* MPFR: Arbitrary Precision Arithmetic.
+ (line 6)
* msgfmt utility: I18N Example. (line 62)
-* n debugger command (alias for next): Dgawk Execution Control.
+* multiple precision: Arbitrary Precision Arithmetic.
+ (line 6)
+* n debugger command (alias for next): Debugger Execution Control.
(line 43)
* names, arrays/variables <1>: Library Names. (line 6)
* names, arrays/variables: Arrays. (line 18)
@@ -26533,14 +27551,13 @@ Index
* namespace issues <1>: Library Names. (line 6)
* namespace issues: Arrays. (line 18)
* namespace issues, functions: Definition Syntax. (line 20)
-* nargs internal variable: Internals. (line 49)
* nawk utility: Names. (line 17)
-* negative zero: Unexpected Results. (line 28)
+* negative zero: Unexpected Results. (line 34)
* NetBSD: Glossary. (line 615)
* networks, programming: TCP/IP Networking. (line 6)
* networks, support for: Special Network. (line 6)
* newlines <1>: Boolean Ops. (line 67)
-* newlines <2>: Options. (line 208)
+* newlines <2>: Options. (line 253)
* newlines: Statements/Lines. (line 6)
* newlines, as field separators: Default Field Splitting.
(line 6)
@@ -26551,7 +27568,7 @@ Index
* newlines, separating statements in actions <1>: Statements. (line 10)
* newlines, separating statements in actions: Action Overview.
(line 19)
-* next debugger command: Dgawk Execution Control.
+* next debugger command: Debugger Execution Control.
(line 43)
* next statement <1>: Next Statement. (line 6)
* next statement: Boolean Ops. (line 85)
@@ -26566,21 +27583,19 @@ Index
(line 26)
* nextfile statement, user-defined functions and: Nextfile Statement.
(line 47)
-* nexti debugger command: Dgawk Execution Control.
+* nexti debugger command: Debugger Execution Control.
(line 49)
-* NF variable <1>: Auto-set. (line 107)
+* NF variable <1>: Auto-set. (line 108)
* NF variable: Fields. (line 33)
* NF variable, decrementing: Changing Fields. (line 107)
-* ni debugger command (alias for nexti): Dgawk Execution Control.
+* ni debugger command (alias for nexti): Debugger Execution Control.
(line 49)
* noassign.awk program: Ignoring Assigns. (line 15)
-* NODE internal type: Internals. (line 23)
-* nodes, duplicating: Internals. (line 96)
* not Boolean-logic operator: Boolean Ops. (line 6)
-* NR variable <1>: Auto-set. (line 118)
+* NR variable <1>: Auto-set. (line 125)
* NR variable: Records. (line 6)
-* NR variable, changing: Auto-set. (line 207)
-* null strings <1>: Basic Data Typing. (line 50)
+* NR variable, changing: Auto-set. (line 274)
+* null strings <1>: Basic Data Typing. (line 26)
* null strings <2>: Truth Values. (line 6)
* null strings <3>: Regexp Field Splitting.
(line 43)
@@ -26596,31 +27611,27 @@ Index
* number sign (#), #! (executable scripts), portability issues with: Executable Scripts.
(line 6)
* number sign (#), commenting: Comments. (line 6)
-* numbers: Internals. (line 91)
* numbers, as array subscripts: Numeric Array Subscripts.
(line 6)
* numbers, as values of characters: Ordinal Functions. (line 6)
* numbers, Cliff random: Cliff Random Function.
(line 6)
-* numbers, converting <1>: Bitwise Functions. (line 107)
+* numbers, converting <1>: Bitwise Functions. (line 109)
* numbers, converting: Conversion. (line 6)
* numbers, converting, to strings: User-modified. (line 28)
-* numbers, floating-point: Basic Data Typing. (line 21)
-* numbers, floating-point, AWKNUM internal type: Internals. (line 19)
+* numbers, floating-point: General Arithmetic. (line 6)
* numbers, hexadecimal: Nondecimal-numbers. (line 6)
-* numbers, NODE internal type: Internals. (line 23)
* numbers, octal: Nondecimal-numbers. (line 6)
* numbers, random: Numeric Functions. (line 64)
* numbers, rounding: Round Function. (line 6)
* numeric, constants: Scalar Constants. (line 6)
* numeric, output format: OFMT. (line 6)
* numeric, strings: Variable Typing. (line 6)
-* numeric, values: Internals. (line 27)
-* o debugger command (alias for option): Dgawk Info. (line 56)
+* o debugger command (alias for option): Debugger Info. (line 57)
* oawk utility: Names. (line 17)
* obsolete features: Obsolete. (line 6)
* octal numbers: Nondecimal-numbers. (line 6)
-* octal values, enabling interpretation of: Options. (line 169)
+* octal values, enabling interpretation of: Options. (line 207)
* OFMT variable <1>: User-modified. (line 115)
* OFMT variable <2>: Conversion. (line 55)
* OFMT variable: OFMT. (line 15)
@@ -26629,7 +27640,7 @@ Index
* OFS variable <2>: Output Separators. (line 6)
* OFS variable: Changing Fields. (line 64)
* OpenBSD: Glossary. (line 615)
-* OpenSolaris: Other Versions. (line 86)
+* OpenSolaris: Other Versions. (line 87)
* operating systems, BSD-based: Manual History. (line 28)
* operating systems, PC, gawk on: PC Using. (line 6)
* operating systems, PC, gawk on, installing: PC Installation.
@@ -26662,21 +27673,21 @@ Index
(line 48)
* operators, word-boundary (gawk): GNU Regexp Operators.
(line 63)
-* option debugger command: Dgawk Info. (line 56)
+* option debugger command: Debugger Info. (line 57)
* options, command-line <1>: Command Line Field Separator.
(line 6)
* options, command-line <2>: Options. (line 6)
* options, command-line: Long. (line 12)
-* options, command-line, end of: Options. (line 54)
+* options, command-line, end of: Options. (line 68)
* options, command-line, invoking awk: Command Line. (line 6)
* options, command-line, processing: Getopt Function. (line 6)
* options, deprecated: Obsolete. (line 6)
* options, long <1>: Options. (line 6)
* options, long: Command Line. (line 13)
-* options, printing list of: Options. (line 145)
+* options, printing list of: Options. (line 168)
* OR bitwise operation: Bitwise Functions. (line 6)
* or Boolean-logic operator: Boolean Ops. (line 6)
-* or() function (gawk): Bitwise Functions. (line 48)
+* or() function (gawk): Bitwise Functions. (line 49)
* ord() user-defined function: Ordinal Functions. (line 16)
* order of evaluation, concatenation: Concatenation. (line 42)
* ORS variable <1>: User-modified. (line 129)
@@ -26699,15 +27710,14 @@ Index
(line 36)
* P1003.1 POSIX standard: Glossary. (line 458)
* P1003.2 POSIX standard: Glossary. (line 458)
-* parameters, number of: Internals. (line 49)
+* parentheses () <1>: Profiling. (line 138)
* parentheses (): Regexp Operators. (line 79)
-* parentheses (), pgawk program: Profiling. (line 141)
* password file: Passwd Functions. (line 16)
* patsplit() function: String Functions. (line 293)
* patterns: Patterns and Actions.
(line 6)
* patterns, comparison expressions as: Expression Patterns. (line 14)
-* patterns, counts: Profiling. (line 113)
+* patterns, counts: Profiling. (line 110)
* patterns, default: Very Simple. (line 34)
* patterns, empty: Empty. (line 6)
* patterns, expressions as: Regexp Patterns. (line 6)
@@ -26725,9 +27735,6 @@ Index
* Perl: Future Extensions. (line 6)
* Peters, Arno: Contributors. (line 85)
* Peterson, Hal: Contributors. (line 40)
-* pgawk program: Profiling. (line 6)
-* pgawk program, awkprof.out file: Profiling. (line 10)
-* pgawk program, dynamic profiling: Profiling. (line 174)
* pipes, closing: Close Files And Pipes.
(line 6)
* pipes, input: Getline/Pipe. (line 6)
@@ -26768,13 +27775,13 @@ Index
* portability, NF variable, decrementing: Changing Fields. (line 115)
* portability, operators: Increment Ops. (line 61)
* portability, operators, not in POSIX awk: Precedence. (line 98)
-* portability, POSIXLY_CORRECT environment variable: Options. (line 313)
+* portability, POSIXLY_CORRECT environment variable: Options. (line 353)
* portability, substr() function: String Functions. (line 512)
* portable object files <1>: Translator i18n. (line 6)
* portable object files: Explaining gettext. (line 36)
* portable object files, converting to message object files: I18N Example.
(line 62)
-* portable object files, generating: Options. (line 138)
+* portable object files, generating: Options. (line 161)
* portable object template files: Explaining gettext. (line 30)
* porting gawk: New Ports. (line 6)
* positional specifiers, printf statement <1>: Printf Ordering.
@@ -26782,7 +27789,7 @@ Index
* positional specifiers, printf statement: Format Modifiers. (line 13)
* positional specifiers, printf statement, mixing with regular formats: Printf Ordering.
(line 57)
-* positive zero: Unexpected Results. (line 28)
+* positive zero: Unexpected Results. (line 34)
* POSIX awk <1>: Assignment Ops. (line 136)
* POSIX awk: This Manual. (line 14)
* POSIX awk, ** operator and: Precedence. (line 98)
@@ -26818,11 +27825,13 @@ Index
* POSIX awk, regular expressions and: Regexp Operators. (line 161)
* POSIX awk, timestamps and: Time Functions. (line 6)
* POSIX awk, | I/O operator and: Getline/Pipe. (line 52)
-* POSIX mode: Options. (line 202)
+* POSIX mode: Options. (line 247)
* POSIX, awk and: Preface. (line 23)
* POSIX, gawk extensions not included in: POSIX/GNU. (line 6)
* POSIX, programs, implementing in awk: Clones. (line 6)
-* POSIXLY_CORRECT environment variable: Options. (line 292)
+* POSIXLY_CORRECT environment variable: Options. (line 332)
+* PREC variable <1>: Setting Precision. (line 6)
+* PREC variable: User-modified. (line 134)
* precedence <1>: Precedence. (line 6)
* precedence: Increment Ops. (line 61)
* precedence, regexp operators: Regexp Operators. (line 156)
@@ -26856,24 +27865,23 @@ Index
* printf statement, sprintf() function and: Round Function. (line 6)
* printf statement, syntax of: Basic Printf. (line 6)
* printing: Printing. (line 6)
-* printing, list of options: Options. (line 145)
+* printing, list of options: Options. (line 168)
* printing, mailing labels: Labels Program. (line 6)
* printing, unduplicated lines of text: Uniq Program. (line 6)
* printing, user information: Id Program. (line 6)
* private variables: Library Names. (line 11)
* processes, two-way communications with: Two-way I/O. (line 23)
* processing data: Basic High Level. (line 6)
-* PROCINFO array <1>: Internals. (line 149)
-* PROCINFO array <2>: Id Program. (line 15)
-* PROCINFO array <3>: Group Functions. (line 6)
-* PROCINFO array <4>: Passwd Functions. (line 6)
-* PROCINFO array <5>: Two-way I/O. (line 116)
-* PROCINFO array <6>: Time Functions. (line 46)
-* PROCINFO array <7>: Auto-set. (line 123)
+* PROCINFO array <1>: Id Program. (line 15)
+* PROCINFO array <2>: Group Functions. (line 6)
+* PROCINFO array <3>: Passwd Functions. (line 6)
+* PROCINFO array <4>: Two-way I/O. (line 116)
+* PROCINFO array <5>: Time Functions. (line 46)
+* PROCINFO array <6>: Auto-set. (line 130)
* PROCINFO array: Obsolete. (line 11)
* profiling awk programs: Profiling. (line 6)
-* profiling awk programs, dynamically: Profiling. (line 174)
-* profiling gawk, See pgawk program: Profiling. (line 6)
+* profiling awk programs, dynamically: Profiling. (line 171)
+* profiling gawk: Profiling. (line 6)
* program, definition of: Getting Started. (line 21)
* programmers, attractiveness of: Two-way I/O. (line 6)
* programming conventions, --non-decimal-data option: Nondecimal Data.
@@ -26897,23 +27905,23 @@ Index
* programming, basic steps: Basic High Level. (line 19)
* programming, concepts: Basic Concepts. (line 6)
* pwcat program: Passwd Functions. (line 23)
-* q debugger command (alias for quit): Miscellaneous Dgawk Commands.
+* q debugger command (alias for quit): Miscellaneous Debugger Commands.
(line 101)
-* QSE Awk: Other Versions. (line 108)
+* QSE Awk: Other Versions. (line 109)
* question mark (?) regexp operator <1>: GNU Regexp Operators.
(line 59)
* question mark (?) regexp operator: Regexp Operators. (line 111)
* question mark (?), ?: operator: Precedence. (line 92)
-* QuikTrim Awk: Other Versions. (line 112)
-* quit debugger command: Miscellaneous Dgawk Commands.
+* QuikTrim Awk: Other Versions. (line 113)
+* quit debugger command: Miscellaneous Debugger Commands.
(line 101)
-* QUIT signal (MS-Windows): Profiling. (line 207)
+* QUIT signal (MS-Windows): Profiling. (line 206)
* quoting <1>: Comments. (line 27)
* quoting <2>: Long. (line 26)
* quoting: Read Terminal. (line 25)
* quoting, rules for: Quoting. (line 6)
* quoting, tricks for: Quoting. (line 71)
-* r debugger command (alias for run): Dgawk Execution Control.
+* r debugger command (alias for run): Debugger Execution Control.
(line 62)
* Rakitzis, Byron: History Sorting. (line 25)
* rand() function: Numeric Functions. (line 34)
@@ -26931,7 +27939,7 @@ Index
* readable data files, checking: File Checking. (line 6)
* readable.awk program: File Checking. (line 11)
* recipe for a programming language: History. (line 6)
-* record separators <1>: User-modified. (line 134)
+* record separators <1>: User-modified. (line 143)
* record separators: Records. (line 14)
* record separators, changing: Records. (line 81)
* record separators, regular expressions as: Records. (line 117)
@@ -26959,8 +27967,6 @@ Index
* regexp constants, slashes vs. quotes: Computed Regexps. (line 28)
* regexp constants, vs. string constants: Computed Regexps. (line 38)
* regexp, See regular expressions: Regexp. (line 6)
-* register_deferred_variable() internal function: Internals. (line 149)
-* register_open_hook() internal function: Internals. (line 160)
* regular expressions: Regexp. (line 6)
* regular expressions as field separators: Field Separators. (line 50)
* regular expressions, anchors in: Regexp Operators. (line 22)
@@ -26979,7 +27985,7 @@ Index
(line 59)
* regular expressions, gawk, command-line options: GNU Regexp Operators.
(line 70)
-* regular expressions, interval expressions and: Options. (line 227)
+* regular expressions, interval expressions and: Options. (line 272)
* regular expressions, leftmost longest match: Leftmost Longest.
(line 6)
* regular expressions, operators <1>: Regexp Operators. (line 6)
@@ -26995,7 +28001,7 @@ Index
* regular expressions, searching for: Egrep Program. (line 6)
* relational operators, See comparison operators: Typing and Comparison.
(line 9)
-* return debugger command: Dgawk Execution Control.
+* return debugger command: Debugger Execution Control.
(line 54)
* return statement, user-defined functions: Return Statement. (line 6)
* return values, close() function: Close Files And Pipes.
@@ -27012,8 +28018,8 @@ Index
* right angle bracket (>), >> operator (I/O) <1>: Precedence. (line 65)
* right angle bracket (>), >> operator (I/O): Redirection. (line 50)
* right shift, bitwise: Bitwise Functions. (line 32)
-* Ritchie, Dennis: Basic Data Typing. (line 74)
-* RLENGTH variable: Auto-set. (line 183)
+* Ritchie, Dennis: Basic Data Typing. (line 55)
+* RLENGTH variable: Auto-set. (line 233)
* RLENGTH variable, match() function and: String Functions. (line 223)
* Robbins, Arnold <1>: Future Extensions. (line 6)
* Robbins, Arnold <2>: Bugs. (line 32)
@@ -27024,23 +28030,25 @@ Index
* Robbins, Arnold: Command Line Field Separator.
(line 80)
* Robbins, Bill: Getline/Pipe. (line 36)
-* Robbins, Harry: Acknowledgments. (line 81)
-* Robbins, Jean: Acknowledgments. (line 81)
+* Robbins, Harry: Acknowledgments. (line 83)
+* Robbins, Jean: Acknowledgments. (line 83)
* Robbins, Miriam <1>: Passwd Functions. (line 90)
* Robbins, Miriam <2>: Getline/Pipe. (line 36)
-* Robbins, Miriam: Acknowledgments. (line 81)
-* Robinson, Will: Dynamic Extensions. (line 6)
-* robot, the: Dynamic Extensions. (line 6)
+* Robbins, Miriam: Acknowledgments. (line 83)
* Rommel, Kai Uwe: Contributors. (line 43)
* round() user-defined function: Round Function. (line 16)
+* rounding mode, floating-point: Rounding Mode. (line 6)
* rounding numbers: Round Function. (line 6)
-* RS variable <1>: User-modified. (line 134)
+* ROUNDMODE variable <1>: Setting Rounding Mode.
+ (line 6)
+* ROUNDMODE variable: User-modified. (line 138)
+* RS variable <1>: User-modified. (line 143)
* RS variable: Records. (line 20)
* RS variable, multiline records and: Multiple Line. (line 17)
-* rshift() function (gawk): Bitwise Functions. (line 51)
-* RSTART variable: Auto-set. (line 189)
+* rshift() function (gawk): Bitwise Functions. (line 52)
+* RSTART variable: Auto-set. (line 239)
* RSTART variable, match() function and: String Functions. (line 223)
-* RT variable <1>: Auto-set. (line 196)
+* RT variable <1>: Auto-set. (line 246)
* RT variable <2>: Getline/Variable/File.
(line 10)
* RT variable <3>: Multiple Line. (line 129)
@@ -27048,12 +28056,12 @@ Index
* Rubin, Paul <1>: Contributors. (line 16)
* Rubin, Paul: History. (line 30)
* rule, definition of: Getting Started. (line 21)
-* run debugger command: Dgawk Execution Control.
+* run debugger command: Debugger Execution Control.
(line 62)
* rvalues/lvalues: Assignment Ops. (line 32)
-* s debugger command (alias for step): Dgawk Execution Control.
+* s debugger command (alias for step): Debugger Execution Control.
(line 68)
-* sandbox mode: Options. (line 239)
+* sandbox mode: Options. (line 279)
* scalar values: Basic Data Typing. (line 13)
* Schorr, Andrew: Acknowledgments. (line 60)
* Schreiber, Bert: Acknowledgments. (line 38)
@@ -27061,7 +28069,9 @@ Index
* search paths <1>: VMS Running. (line 29)
* search paths <2>: PC Using. (line 11)
* search paths <3>: Igawk Program. (line 368)
+* search paths <4>: AWKLIBPATH Variable. (line 6)
* search paths: AWKPATH Variable. (line 6)
+* search paths, for shared libraries: AWKLIBPATH Variable. (line 6)
* search paths, for source files <1>: VMS Running. (line 29)
* search paths, for source files <2>: PC Using. (line 11)
* search paths, for source files <3>: Igawk Program. (line 368)
@@ -27083,11 +28093,11 @@ Index
* separators, field, FIELDWIDTHS variable and: User-modified. (line 35)
* separators, field, FPAT variable and: User-modified. (line 45)
* separators, field, POSIX and: Fields. (line 6)
-* separators, for records <1>: User-modified. (line 134)
+* separators, for records <1>: User-modified. (line 143)
* separators, for records: Records. (line 14)
* separators, for records, regular expressions as: Records. (line 117)
* separators, for statements in actions: Action Overview. (line 19)
-* separators, subscript: User-modified. (line 147)
+* separators, subscript: User-modified. (line 156)
* set debugger command: Viewing And Changing Data.
(line 59)
* shells, piping commands into: Redirection. (line 143)
@@ -27099,7 +28109,7 @@ Index
(line 6)
* shift, bitwise: Bitwise Functions. (line 32)
* short-circuit operators: Boolean Ops. (line 57)
-* si debugger command (alias for stepi): Dgawk Execution Control.
+* si debugger command (alias for stepi): Debugger Execution Control.
(line 76)
* side effects <1>: Increment Ops. (line 11)
* side effects: Concatenation. (line 42)
@@ -27114,18 +28124,18 @@ Index
* side effects, FILENAME variable: Getline Notes. (line 19)
* side effects, function calls: Function Calls. (line 54)
* side effects, statements: Action Overview. (line 32)
-* SIGHUP signal: Profiling. (line 204)
-* SIGINT signal (MS-Windows): Profiling. (line 207)
-* signals, HUP/SIGHUP: Profiling. (line 204)
-* signals, INT/SIGINT (MS-Windows): Profiling. (line 207)
-* signals, QUIT/SIGQUIT (MS-Windows): Profiling. (line 207)
-* signals, USR1/SIGUSR1: Profiling. (line 182)
-* SIGQUIT signal (MS-Windows): Profiling. (line 207)
-* SIGUSR1 signal: Profiling. (line 182)
-* silent debugger command: Dgawk Execution Control.
+* SIGHUP signal: Profiling. (line 203)
+* SIGINT signal (MS-Windows): Profiling. (line 206)
+* signals, HUP/SIGHUP: Profiling. (line 203)
+* signals, INT/SIGINT (MS-Windows): Profiling. (line 206)
+* signals, QUIT/SIGQUIT (MS-Windows): Profiling. (line 206)
+* signals, USR1/SIGUSR1: Profiling. (line 180)
+* SIGQUIT signal (MS-Windows): Profiling. (line 206)
+* SIGUSR1 signal: Profiling. (line 180)
+* silent debugger command: Debugger Execution Control.
(line 10)
* sin() function: Numeric Functions. (line 75)
-* single precision floating-point: Basic Data Typing. (line 36)
+* single precision floating-point: General Arithmetic. (line 21)
* single quote (') <1>: Quoting. (line 31)
* single quote (') <2>: Long. (line 33)
* single quote ('): One-shot. (line 15)
@@ -27135,7 +28145,7 @@ Index
(line 6)
* Skywalker, Luke: Undocumented. (line 6)
* sleep utility: Alarm Program. (line 109)
-* Solaris, POSIX-compliant awk: Other Versions. (line 86)
+* Solaris, POSIX-compliant awk: Other Versions. (line 87)
* sort function, arrays, sorting: Array Sorting Functions.
(line 6)
* sort utility: Word Sorting. (line 50)
@@ -27144,17 +28154,17 @@ Index
(line 93)
* source code, awka: Other Versions. (line 55)
* source code, Brian Kernighan's awk: Other Versions. (line 13)
-* source code, Busybox Awk: Other Versions. (line 78)
+* source code, Busybox Awk: Other Versions. (line 79)
* source code, gawk: Gawk Distribution. (line 6)
-* source code, jawk: Other Versions. (line 96)
-* source code, libmawk: Other Versions. (line 104)
+* source code, jawk: Other Versions. (line 97)
+* source code, libmawk: Other Versions. (line 105)
* source code, mawk: Other Versions. (line 35)
-* source code, mixing: Options. (line 108)
+* source code, mixing: Options. (line 131)
* source code, pawk: Other Versions. (line 69)
-* source code, QSE Awk: Other Versions. (line 108)
-* source code, QuikTrim Awk: Other Versions. (line 112)
-* source code, Solaris awk: Other Versions. (line 86)
-* source code, xgawk: Other Versions. (line 119)
+* source code, QSE Awk: Other Versions. (line 109)
+* source code, QuikTrim Awk: Other Versions. (line 113)
+* source code, Solaris awk: Other Versions. (line 87)
+* source code, xgawk: Other Versions. (line 120)
* source files, search path for: Igawk Program. (line 368)
* sparse arrays: Array Intro. (line 71)
* Spencer, Henry: Glossary. (line 12)
@@ -27182,12 +28192,10 @@ Index
* statements, compound, control statements and: Statements. (line 10)
* statements, control, in actions: Statements. (line 6)
* statements, multiple: Statements/Lines. (line 91)
-* step debugger command: Dgawk Execution Control.
+* step debugger command: Debugger Execution Control.
(line 68)
-* stepi debugger command: Dgawk Execution Control.
+* stepi debugger command: Debugger Execution Control.
(line 76)
-* stlen internal variable: Internals. (line 53)
-* stptr internal variable: Internals. (line 53)
* stream editors <1>: Simple Sed. (line 6)
* stream editors: Field Splitting Summary.
(line 47)
@@ -27198,8 +28206,7 @@ Index
(line 6)
* string operators: Concatenation. (line 9)
* string-matching operators: Regexp Usage. (line 19)
-* strings: Internals. (line 86)
-* strings, converting <1>: Bitwise Functions. (line 107)
+* strings, converting <1>: Bitwise Functions. (line 109)
* strings, converting: Conversion. (line 6)
* strings, converting, numbers to: User-modified. (line 28)
* strings, empty, See null strings: Records. (line 107)
@@ -27207,7 +28214,6 @@ Index
* strings, for localization: Programmer i18n. (line 14)
* strings, length of: Scalar Constants. (line 20)
* strings, merging arrays into: Join Function. (line 6)
-* strings, NODE internal type: Internals. (line 23)
* strings, null: Regexp Field Splitting.
(line 43)
* strings, numeric: Variable Typing. (line 6)
@@ -27220,7 +28226,7 @@ Index
(line 43)
* sub() function, arguments of: String Functions. (line 462)
* sub() function, escape processing: Gory Details. (line 6)
-* subscript separators: User-modified. (line 147)
+* subscript separators: User-modified. (line 156)
* subscripts in arrays, multidimensional: Multi-dimensional. (line 10)
* subscripts in arrays, multidimensional, scanning: Multi-scanning.
(line 11)
@@ -27228,25 +28234,26 @@ Index
(line 6)
* subscripts in arrays, uninitialized variables as: Uninitialized Subscripts.
(line 6)
-* SUBSEP variable: User-modified. (line 147)
+* SUBSEP variable: User-modified. (line 156)
* SUBSEP variable, multidimensional arrays: Multi-dimensional.
(line 16)
* substr() function: String Functions. (line 481)
* Sumner, Andrew: Other Versions. (line 55)
* switch statement: Switch Statement. (line 6)
+* SYMTAB array: Auto-set. (line 254)
* syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops.
(line 148)
* system() function: I/O Functions. (line 63)
* systime() function (gawk): Time Functions. (line 64)
-* t debugger command (alias for tbreak): Breakpoint Control. (line 89)
-* tbreak debugger command: Breakpoint Control. (line 89)
+* t debugger command (alias for tbreak): Breakpoint Control. (line 90)
+* tbreak debugger command: Breakpoint Control. (line 90)
* Tcl: Library Names. (line 57)
* TCP/IP: TCP/IP Networking. (line 6)
* TCP/IP, support for: Special Network. (line 6)
* tee utility: Tee Program. (line 6)
* tee.awk program: Tee Program. (line 26)
* terminating records: Records. (line 117)
-* testbits.awk program: Bitwise Functions. (line 68)
+* testbits.awk program: Bitwise Functions. (line 70)
* Texinfo <1>: Adding Code. (line 99)
* Texinfo <2>: Distribution contents.
(line 79)
@@ -27261,7 +28268,7 @@ Index
* text, printing: Print. (line 22)
* text, printing, unduplicated lines of: Uniq Program. (line 6)
* TEXTDOMAIN variable <1>: Programmer i18n. (line 9)
-* TEXTDOMAIN variable: User-modified. (line 153)
+* TEXTDOMAIN variable: User-modified. (line 162)
* TEXTDOMAIN variable, BEGIN pattern and: Programmer i18n. (line 60)
* TEXTDOMAIN variable, portability and: I18N Portability. (line 20)
* textdomain() function (C library): Explaining gettext. (line 27)
@@ -27275,20 +28282,21 @@ Index
* tilde (~), ~ operator: Regexp Usage. (line 19)
* time, alarm clock example program: Alarm Program. (line 9)
* time, localization and: Explaining gettext. (line 115)
-* time, managing: Gettimeofday Function.
+* time, managing: Getlocaltime Function.
(line 6)
* time, retrieving: Time Functions. (line 17)
+* timeout, reading input: Read Timeout. (line 6)
* timestamps: Time Functions. (line 6)
* timestamps, converting dates to: Time Functions. (line 74)
-* timestamps, formatted: Gettimeofday Function.
+* timestamps, formatted: Getlocaltime Function.
(line 6)
* tolower() function: String Functions. (line 523)
* toupper() function: String Functions. (line 529)
* tr utility: Translate Program. (line 6)
-* trace debugger command: Miscellaneous Dgawk Commands.
+* trace debugger command: Miscellaneous Debugger Commands.
(line 110)
* translate.awk program: Translate Program. (line 55)
-* troubleshooting, --non-decimal-data option: Options. (line 169)
+* troubleshooting, --non-decimal-data option: Options. (line 207)
* troubleshooting, == operator: Comparison Operators.
(line 37)
* troubleshooting, awk uses FS not IFS: Field Separators. (line 29)
@@ -27320,7 +28328,7 @@ Index
* troubleshooting, substr() function: String Functions. (line 499)
* troubleshooting, system() function: I/O Functions. (line 85)
* troubleshooting, typographical errors, global variables: Options.
- (line 98)
+ (line 112)
* true, logical: Truth Values. (line 6)
* Trueman, David <1>: Contributors. (line 31)
* Trueman, David <2>: Acknowledgments. (line 47)
@@ -27328,8 +28336,7 @@ Index
* trunc-mod operation: Arithmetic Ops. (line 66)
* truth values: Truth Values. (line 6)
* type conversion: Conversion. (line 21)
-* type internal variable: Internals. (line 66)
-* u debugger command (alias for until): Dgawk Execution Control.
+* u debugger command (alias for until): Debugger Execution Control.
(line 83)
* undefined functions: Pass By Value/Reference.
(line 71)
@@ -27354,23 +28361,20 @@ Index
(line 72)
* Unix, awk scripts and: Executable Scripts. (line 6)
* UNIXROOT variable, on OS/2 systems: PC Using. (line 17)
-* unref() internal function: Internals. (line 101)
-* unsigned integers: Basic Data Typing. (line 30)
-* until debugger command: Dgawk Execution Control.
+* unsigned integers: General Arithmetic. (line 15)
+* until debugger command: Debugger Execution Control.
(line 83)
* unwatch debugger command: Viewing And Changing Data.
(line 84)
-* up debugger command: Dgawk Stack. (line 33)
-* update_ERRNO() internal function: Internals. (line 139)
-* update_ERRNO_saved() internal function: Internals. (line 144)
+* up debugger command: Execution Stack. (line 33)
* user database, reading: Passwd Functions. (line 6)
* user-defined, functions: User-defined. (line 6)
-* user-defined, functions, counts: Profiling. (line 132)
+* user-defined, functions, counts: Profiling. (line 129)
* user-defined, variables: Variables. (line 6)
* user-modifiable variables: User-modified. (line 6)
* users, information about, printing: Id Program. (line 6)
* users, information about, retrieving: Passwd Functions. (line 16)
-* USR1 signal: Profiling. (line 182)
+* USR1 signal: Profiling. (line 180)
* values, numeric: Basic Data Typing. (line 13)
* values, string: Basic Data Typing. (line 13)
* variable typing: Typing and Comparison.
@@ -27380,7 +28384,7 @@ Index
* variables, assigning on command line: Assignment Options. (line 6)
* variables, built-in <1>: Built-in Variables. (line 6)
* variables, built-in: Using Variables. (line 20)
-* variables, built-in, -v option, setting with: Options. (line 40)
+* variables, built-in, -v option, setting with: Options. (line 54)
* variables, built-in, conveying information: Auto-set. (line 6)
* variables, flag: Boolean Ops. (line 67)
* variables, getline command into, using <1>: Getline/Variable/Coprocess.
@@ -27391,12 +28395,12 @@ Index
(line 6)
* variables, getline command into, using: Getline/Variable. (line 6)
* variables, global, for library functions: Library Names. (line 11)
-* variables, global, printing list of: Options. (line 93)
+* variables, global, printing list of: Options. (line 107)
* variables, initializing: Using Variables. (line 20)
* variables, local: Variable Scope. (line 6)
* variables, names of: Arrays. (line 18)
* variables, private: Library Names. (line 11)
-* variables, setting: Options. (line 32)
+* variables, setting: Options. (line 46)
* variables, shadowing: Definition Syntax. (line 61)
* variables, types of: Assignment Ops. (line 40)
* variables, types of, comparison expressions and: Typing and Comparison.
@@ -27413,7 +28417,6 @@ Index
* vertical bar (|), || operator <1>: Precedence. (line 89)
* vertical bar (|), || operator: Boolean Ops. (line 57)
* Vinschen, Corinna: Acknowledgments. (line 60)
-* vname internal variable: Internals. (line 71)
* w debugger command (alias for watch): Viewing And Changing Data.
(line 67)
* w utility: Constant Size. (line 22)
@@ -27421,7 +28424,7 @@ Index
* Wall, Larry <1>: Future Extensions. (line 6)
* Wall, Larry: Array Intro. (line 6)
* Wallin, Anders: Acknowledgments. (line 60)
-* warnings, issuing: Options. (line 150)
+* warnings, issuing: Options. (line 182)
* watch debugger command: Viewing And Changing Data.
(line 67)
* wc utility: Wc Program. (line 6)
@@ -27433,7 +28436,7 @@ Index
* whitespace, as field separators: Default Field Splitting.
(line 6)
* whitespace, functions, calling: Calling Built-in. (line 10)
-* whitespace, newlines as: Options. (line 208)
+* whitespace, newlines as: Options. (line 253)
* Williams, Kent: Contributors. (line 35)
* Woehlke, Matthew: Contributors. (line 79)
* Woods, John: Contributors. (line 28)
@@ -27447,22 +28450,19 @@ Index
* words, counting: Wc Program. (line 6)
* words, duplicate, searching for: Dupword Program. (line 6)
* words, usage counts, generating: Word Sorting. (line 6)
-* wstlen internal variable: Internals. (line 61)
-* wstptr internal variable: Internals. (line 61)
-* xgawk: Other Versions. (line 119)
+* xgawk: Other Versions. (line 120)
* xgettext utility: String Extraction. (line 13)
-* XML (eXtensible Markup Language): Internals. (line 160)
* XOR bitwise operation: Bitwise Functions. (line 6)
-* xor() function (gawk): Bitwise Functions. (line 54)
+* xor() function (gawk): Bitwise Functions. (line 55)
* Yawitz, Efraim: Contributors. (line 106)
* Zaretskii, Eli <1>: Bugs. (line 70)
* Zaretskii, Eli <2>: Contributors. (line 56)
* Zaretskii, Eli: Acknowledgments. (line 60)
-* zero, negative vs. positive: Unexpected Results. (line 28)
+* zero, negative vs. positive: Unexpected Results. (line 34)
* zerofile.awk program: Empty Files. (line 21)
* Zoulas, Christos: Contributors. (line 67)
+* {} (braces): Profiling. (line 134)
* {} (braces), actions and: Action Overview. (line 19)
-* {} (braces), pgawk program: Profiling. (line 137)
* {} (braces), statements, grouping: Statements. (line 10)
* | (vertical bar): Regexp Operators. (line 69)
* | (vertical bar), | operator (I/O) <1>: Precedence. (line 65)
@@ -27489,418 +28489,450 @@ Index

Tag Table:
Node: Top1352
-Node: Foreword30282
-Node: Preface34627
-Ref: Preface-Footnote-137680
-Ref: Preface-Footnote-237786
-Node: History38018
-Node: Names40409
-Ref: Names-Footnote-141886
-Node: This Manual41958
-Ref: This Manual-Footnote-146905
-Node: Conventions47005
-Node: Manual History49139
-Ref: Manual History-Footnote-152409
-Ref: Manual History-Footnote-252450
-Node: How To Contribute52524
-Node: Acknowledgments53668
-Node: Getting Started57999
-Node: Running gawk60378
-Node: One-shot61564
-Node: Read Terminal62789
-Ref: Read Terminal-Footnote-164439
-Ref: Read Terminal-Footnote-264715
-Node: Long64886
-Node: Executable Scripts66262
-Ref: Executable Scripts-Footnote-168131
-Ref: Executable Scripts-Footnote-268233
-Node: Comments68780
-Node: Quoting71247
-Node: DOS Quoting75870
-Node: Sample Data Files76545
-Node: Very Simple79577
-Node: Two Rules84176
-Node: More Complex86323
-Ref: More Complex-Footnote-189253
-Node: Statements/Lines89338
-Ref: Statements/Lines-Footnote-193800
-Node: Other Features94065
-Node: When94993
-Node: Invoking Gawk97140
-Node: Command Line98525
-Node: Options99308
-Ref: Options-Footnote-1112852
-Node: Other Arguments112877
-Node: Naming Standard Input115535
-Node: Environment Variables116629
-Node: AWKPATH Variable117073
-Ref: AWKPATH Variable-Footnote-1119670
-Node: Other Environment Variables119930
-Node: Exit Status122270
-Node: Include Files122945
-Node: Obsolete126430
-Node: Undocumented127116
-Node: Regexp127357
-Node: Regexp Usage128746
-Node: Escape Sequences130772
-Node: Regexp Operators136535
-Ref: Regexp Operators-Footnote-1143915
-Ref: Regexp Operators-Footnote-2144062
-Node: Bracket Expressions144160
-Ref: table-char-classes146050
-Node: GNU Regexp Operators148573
-Node: Case-sensitivity152296
-Ref: Case-sensitivity-Footnote-1155264
-Ref: Case-sensitivity-Footnote-2155499
-Node: Leftmost Longest155607
-Node: Computed Regexps156808
-Node: Reading Files160218
-Node: Records162159
-Ref: Records-Footnote-1171083
-Node: Fields171120
-Ref: Fields-Footnote-1174153
-Node: Nonconstant Fields174239
-Node: Changing Fields176441
-Node: Field Separators182422
-Node: Default Field Splitting185051
-Node: Regexp Field Splitting186168
-Node: Single Character Fields189510
-Node: Command Line Field Separator190569
-Node: Field Splitting Summary194010
-Ref: Field Splitting Summary-Footnote-1197202
-Node: Constant Size197303
-Node: Splitting By Content201887
-Ref: Splitting By Content-Footnote-1205613
-Node: Multiple Line205653
-Ref: Multiple Line-Footnote-1211500
-Node: Getline211679
-Node: Plain Getline213907
-Node: Getline/Variable215996
-Node: Getline/File217137
-Node: Getline/Variable/File218459
-Ref: Getline/Variable/File-Footnote-1220058
-Node: Getline/Pipe220145
-Node: Getline/Variable/Pipe222705
-Node: Getline/Coprocess223812
-Node: Getline/Variable/Coprocess225055
-Node: Getline Notes225769
-Node: Getline Summary228556
-Ref: table-getline-variants228899
-Node: Command line directories229755
-Node: Printing230380
-Node: Print232011
-Node: Print Examples233348
-Node: Output Separators236132
-Node: OFMT237892
-Node: Printf239250
-Node: Basic Printf240156
-Node: Control Letters241695
-Node: Format Modifiers245507
-Node: Printf Examples251516
-Node: Redirection254231
-Node: Special Files261215
-Node: Special FD261748
-Ref: Special FD-Footnote-1265373
-Node: Special Network265447
-Node: Special Caveats266297
-Node: Close Files And Pipes267093
-Ref: Close Files And Pipes-Footnote-1274116
-Ref: Close Files And Pipes-Footnote-2274264
-Node: Expressions274414
-Node: Values275546
-Node: Constants276222
-Node: Scalar Constants276902
-Ref: Scalar Constants-Footnote-1277761
-Node: Nondecimal-numbers277943
-Node: Regexp Constants281002
-Node: Using Constant Regexps281477
-Node: Variables284532
-Node: Using Variables285187
-Node: Assignment Options286911
-Node: Conversion288783
-Ref: table-locale-affects294159
-Ref: Conversion-Footnote-1294783
-Node: All Operators294892
-Node: Arithmetic Ops295522
-Node: Concatenation298027
-Ref: Concatenation-Footnote-1300820
-Node: Assignment Ops300940
-Ref: table-assign-ops305928
-Node: Increment Ops307336
-Node: Truth Values and Conditions310806
-Node: Truth Values311889
-Node: Typing and Comparison312938
-Node: Variable Typing313727
-Ref: Variable Typing-Footnote-1317624
-Node: Comparison Operators317746
-Ref: table-relational-ops318156
-Node: POSIX String Comparison321705
-Ref: POSIX String Comparison-Footnote-1322661
-Node: Boolean Ops322799
-Ref: Boolean Ops-Footnote-1326877
-Node: Conditional Exp326968
-Node: Function Calls328700
-Node: Precedence332294
-Node: Locales335963
-Node: Patterns and Actions337052
-Node: Pattern Overview338106
-Node: Regexp Patterns339775
-Node: Expression Patterns340318
-Node: Ranges344003
-Node: BEGIN/END346969
-Node: Using BEGIN/END347731
-Ref: Using BEGIN/END-Footnote-1350462
-Node: I/O And BEGIN/END350568
-Node: BEGINFILE/ENDFILE352850
-Node: Empty355743
-Node: Using Shell Variables356059
-Node: Action Overview358344
-Node: Statements360701
-Node: If Statement362555
-Node: While Statement364054
-Node: Do Statement366098
-Node: For Statement367254
-Node: Switch Statement370406
-Node: Break Statement372503
-Node: Continue Statement374493
-Node: Next Statement376286
-Node: Nextfile Statement378676
-Node: Exit Statement381317
-Node: Built-in Variables383733
-Node: User-modified384828
-Ref: User-modified-Footnote-1392854
-Node: Auto-set392916
-Ref: Auto-set-Footnote-1402207
-Node: ARGC and ARGV402412
-Node: Arrays406263
-Node: Array Basics407768
-Node: Array Intro408594
-Node: Reference to Elements412912
-Node: Assigning Elements415182
-Node: Array Example415673
-Node: Scanning an Array417405
-Node: Controlling Scanning419719
-Ref: Controlling Scanning-Footnote-1424652
-Node: Delete424968
-Ref: Delete-Footnote-1427733
-Node: Numeric Array Subscripts427790
-Node: Uninitialized Subscripts429973
-Node: Multi-dimensional431601
-Node: Multi-scanning434695
-Node: Arrays of Arrays436286
-Node: Functions440931
-Node: Built-in441753
-Node: Calling Built-in442831
-Node: Numeric Functions444819
-Ref: Numeric Functions-Footnote-1448651
-Ref: Numeric Functions-Footnote-2449008
-Ref: Numeric Functions-Footnote-3449056
-Node: String Functions449325
-Ref: String Functions-Footnote-1472822
-Ref: String Functions-Footnote-2472951
-Ref: String Functions-Footnote-3473199
-Node: Gory Details473286
-Ref: table-sub-escapes474965
-Ref: table-sub-posix-92476319
-Ref: table-sub-proposed477662
-Ref: table-posix-sub479012
-Ref: table-gensub-escapes480558
-Ref: Gory Details-Footnote-1481765
-Ref: Gory Details-Footnote-2481816
-Node: I/O Functions481967
-Ref: I/O Functions-Footnote-1488622
-Node: Time Functions488769
-Ref: Time Functions-Footnote-1499661
-Ref: Time Functions-Footnote-2499729
-Ref: Time Functions-Footnote-3499887
-Ref: Time Functions-Footnote-4499998
-Ref: Time Functions-Footnote-5500110
-Ref: Time Functions-Footnote-6500337
-Node: Bitwise Functions500603
-Ref: table-bitwise-ops501161
-Ref: Bitwise Functions-Footnote-1505321
-Node: Type Functions505505
-Node: I18N Functions505975
-Node: User-defined507602
-Node: Definition Syntax508406
-Ref: Definition Syntax-Footnote-1513316
-Node: Function Example513385
-Node: Function Caveats515979
-Node: Calling A Function516400
-Node: Variable Scope517515
-Node: Pass By Value/Reference519490
-Node: Return Statement522930
-Node: Dynamic Typing525911
-Node: Indirect Calls526646
-Node: Internationalization536331
-Node: I18N and L10N537757
-Node: Explaining gettext538443
-Ref: Explaining gettext-Footnote-1543509
-Ref: Explaining gettext-Footnote-2543693
-Node: Programmer i18n543858
-Node: Translator i18n548058
-Node: String Extraction548851
-Ref: String Extraction-Footnote-1549812
-Node: Printf Ordering549898
-Ref: Printf Ordering-Footnote-1552682
-Node: I18N Portability552746
-Ref: I18N Portability-Footnote-1555195
-Node: I18N Example555258
-Ref: I18N Example-Footnote-1557893
-Node: Gawk I18N557965
-Node: Advanced Features558582
-Node: Nondecimal Data560095
-Node: Array Sorting561678
-Node: Controlling Array Traversal562375
-Node: Array Sorting Functions570612
-Ref: Array Sorting Functions-Footnote-1574286
-Ref: Array Sorting Functions-Footnote-2574379
-Node: Two-way I/O574573
-Ref: Two-way I/O-Footnote-1580005
-Node: TCP/IP Networking580075
-Node: Profiling582919
-Node: Library Functions590393
-Ref: Library Functions-Footnote-1593400
-Node: Library Names593571
-Ref: Library Names-Footnote-1597042
-Ref: Library Names-Footnote-2597262
-Node: General Functions597348
-Node: Strtonum Function598301
-Node: Assert Function601231
-Node: Round Function604557
-Node: Cliff Random Function606100
-Node: Ordinal Functions607116
-Ref: Ordinal Functions-Footnote-1610186
-Ref: Ordinal Functions-Footnote-2610438
-Node: Join Function610647
-Ref: Join Function-Footnote-1612418
-Node: Gettimeofday Function612618
-Node: Data File Management616333
-Node: Filetrans Function616965
-Node: Rewind Function621104
-Node: File Checking622491
-Node: Empty Files623585
-Node: Ignoring Assigns625815
-Node: Getopt Function627368
-Ref: Getopt Function-Footnote-1638672
-Node: Passwd Functions638875
-Ref: Passwd Functions-Footnote-1647850
-Node: Group Functions647938
-Node: Walking Arrays656022
-Node: Sample Programs657591
-Node: Running Examples658256
-Node: Clones658984
-Node: Cut Program660208
-Node: Egrep Program670053
-Ref: Egrep Program-Footnote-1677826
-Node: Id Program677936
-Node: Split Program681552
-Ref: Split Program-Footnote-1685071
-Node: Tee Program685199
-Node: Uniq Program688002
-Node: Wc Program695431
-Ref: Wc Program-Footnote-1699697
-Ref: Wc Program-Footnote-2699897
-Node: Miscellaneous Programs699989
-Node: Dupword Program701177
-Node: Alarm Program703208
-Node: Translate Program707957
-Ref: Translate Program-Footnote-1712344
-Ref: Translate Program-Footnote-2712572
-Node: Labels Program712706
-Ref: Labels Program-Footnote-1716077
-Node: Word Sorting716161
-Node: History Sorting720045
-Node: Extract Program721884
-Ref: Extract Program-Footnote-1729367
-Node: Simple Sed729495
-Node: Igawk Program732557
-Ref: Igawk Program-Footnote-1747714
-Ref: Igawk Program-Footnote-2747915
-Node: Anagram Program748053
-Node: Signature Program751121
-Node: Debugger752221
-Node: Debugging753132
-Node: Debugging Concepts753545
-Node: Debugging Terms755401
-Node: Awk Debugging758024
-Node: Sample dgawk session758916
-Node: dgawk invocation759408
-Node: Finding The Bug760590
-Node: List of Debugger Commands767076
-Node: Breakpoint Control768387
-Node: Dgawk Execution Control772023
-Node: Viewing And Changing Data775374
-Node: Dgawk Stack778711
-Node: Dgawk Info780171
-Node: Miscellaneous Dgawk Commands784119
-Node: Readline Support789547
-Node: Dgawk Limitations790385
-Node: Language History792574
-Node: V7/SVR3.1794086
-Node: SVR4796407
-Node: POSIX797849
-Node: BTL798857
-Node: POSIX/GNU799591
-Node: Common Extensions804742
-Node: Ranges and Locales805849
-Ref: Ranges and Locales-Footnote-1810467
-Ref: Ranges and Locales-Footnote-2810494
-Ref: Ranges and Locales-Footnote-3810754
-Node: Contributors810975
-Node: Installation815237
-Node: Gawk Distribution816131
-Node: Getting816615
-Node: Extracting817441
-Node: Distribution contents819133
-Node: Unix Installation824355
-Node: Quick Installation824972
-Node: Additional Configuration Options826934
-Node: Configuration Philosophy828411
-Node: Non-Unix Installation830753
-Node: PC Installation831211
-Node: PC Binary Installation832510
-Node: PC Compiling834525
-Node: PC Testing837469
-Node: PC Using838645
-Node: Cygwin842830
-Node: MSYS843830
-Node: VMS Installation844344
-Node: VMS Compilation844947
-Ref: VMS Compilation-Footnote-1845954
-Node: VMS Installation Details846012
-Node: VMS Running847647
-Node: VMS Old Gawk849254
-Node: Bugs849728
-Node: Other Versions853580
-Node: Notes858861
-Node: Compatibility Mode859553
-Node: Additions860336
-Node: Accessing The Source861148
-Node: Adding Code862573
-Node: New Ports868540
-Node: Dynamic Extensions872653
-Node: Internals874029
-Node: Plugin License883132
-Node: Sample Library883766
-Node: Internal File Description884452
-Node: Internal File Ops888167
-Ref: Internal File Ops-Footnote-1892948
-Node: Using Internal File Ops893088
-Node: Future Extensions895465
-Node: Basic Concepts897969
-Node: Basic High Level898726
-Ref: Basic High Level-Footnote-1902761
-Node: Basic Data Typing902946
-Node: Floating Point Issues907471
-Node: String Conversion Precision908554
-Ref: String Conversion Precision-Footnote-1910254
-Node: Unexpected Results910363
-Node: POSIX Floating Point Problems912189
-Ref: POSIX Floating Point Problems-Footnote-1915894
-Node: Glossary915932
-Node: Copying941107
-Node: GNU Free Documentation License978664
-Node: Index1003801
+Node: Foreword31870
+Node: Preface36215
+Ref: Preface-Footnote-139268
+Ref: Preface-Footnote-239374
+Node: History39606
+Node: Names41997
+Ref: Names-Footnote-143474
+Node: This Manual43546
+Ref: This Manual-Footnote-148674
+Node: Conventions48774
+Node: Manual History50908
+Ref: Manual History-Footnote-154178
+Ref: Manual History-Footnote-254219
+Node: How To Contribute54293
+Node: Acknowledgments55437
+Node: Getting Started59933
+Node: Running gawk62312
+Node: One-shot63498
+Node: Read Terminal64723
+Ref: Read Terminal-Footnote-166373
+Ref: Read Terminal-Footnote-266649
+Node: Long66820
+Node: Executable Scripts68196
+Ref: Executable Scripts-Footnote-170065
+Ref: Executable Scripts-Footnote-270167
+Node: Comments70714
+Node: Quoting73181
+Node: DOS Quoting77804
+Node: Sample Data Files78479
+Node: Very Simple81511
+Node: Two Rules86110
+Node: More Complex88257
+Ref: More Complex-Footnote-191187
+Node: Statements/Lines91272
+Ref: Statements/Lines-Footnote-195734
+Node: Other Features95999
+Node: When96927
+Node: Invoking Gawk99074
+Node: Command Line100535
+Node: Options101318
+Ref: Options-Footnote-1116716
+Node: Other Arguments116741
+Node: Naming Standard Input119399
+Node: Environment Variables120493
+Node: AWKPATH Variable121051
+Ref: AWKPATH Variable-Footnote-1123809
+Node: AWKLIBPATH Variable124069
+Node: Other Environment Variables124666
+Node: Exit Status127161
+Node: Include Files127836
+Node: Loading Shared Libraries131405
+Node: Obsolete132630
+Node: Undocumented133327
+Node: Regexp133570
+Node: Regexp Usage134959
+Node: Escape Sequences136985
+Node: Regexp Operators142748
+Ref: Regexp Operators-Footnote-1150128
+Ref: Regexp Operators-Footnote-2150275
+Node: Bracket Expressions150373
+Ref: table-char-classes152263
+Node: GNU Regexp Operators154786
+Node: Case-sensitivity158509
+Ref: Case-sensitivity-Footnote-1161477
+Ref: Case-sensitivity-Footnote-2161712
+Node: Leftmost Longest161820
+Node: Computed Regexps163021
+Node: Reading Files166431
+Node: Records168434
+Ref: Records-Footnote-1177358
+Node: Fields177395
+Ref: Fields-Footnote-1180428
+Node: Nonconstant Fields180514
+Node: Changing Fields182716
+Node: Field Separators188697
+Node: Default Field Splitting191326
+Node: Regexp Field Splitting192443
+Node: Single Character Fields195785
+Node: Command Line Field Separator196844
+Node: Field Splitting Summary200285
+Ref: Field Splitting Summary-Footnote-1203477
+Node: Constant Size203578
+Node: Splitting By Content208162
+Ref: Splitting By Content-Footnote-1211888
+Node: Multiple Line211928
+Ref: Multiple Line-Footnote-1217775
+Node: Getline217954
+Node: Plain Getline220170
+Node: Getline/Variable222259
+Node: Getline/File223400
+Node: Getline/Variable/File224722
+Ref: Getline/Variable/File-Footnote-1226321
+Node: Getline/Pipe226408
+Node: Getline/Variable/Pipe228968
+Node: Getline/Coprocess230075
+Node: Getline/Variable/Coprocess231318
+Node: Getline Notes232032
+Node: Getline Summary234819
+Ref: table-getline-variants235227
+Node: Read Timeout236083
+Ref: Read Timeout-Footnote-1239828
+Node: Command line directories239885
+Node: Printing240515
+Node: Print242146
+Node: Print Examples243483
+Node: Output Separators246267
+Node: OFMT248027
+Node: Printf249385
+Node: Basic Printf250291
+Node: Control Letters251830
+Node: Format Modifiers255642
+Node: Printf Examples261651
+Node: Redirection264366
+Node: Special Files271350
+Node: Special FD271883
+Ref: Special FD-Footnote-1275508
+Node: Special Network275582
+Node: Special Caveats276432
+Node: Close Files And Pipes277228
+Ref: Close Files And Pipes-Footnote-1284251
+Ref: Close Files And Pipes-Footnote-2284399
+Node: Expressions284549
+Node: Values285681
+Node: Constants286357
+Node: Scalar Constants287037
+Ref: Scalar Constants-Footnote-1287896
+Node: Nondecimal-numbers288078
+Node: Regexp Constants291137
+Node: Using Constant Regexps291612
+Node: Variables294667
+Node: Using Variables295322
+Node: Assignment Options297046
+Node: Conversion298918
+Ref: table-locale-affects304294
+Ref: Conversion-Footnote-1304918
+Node: All Operators305027
+Node: Arithmetic Ops305657
+Node: Concatenation308162
+Ref: Concatenation-Footnote-1310955
+Node: Assignment Ops311075
+Ref: table-assign-ops316063
+Node: Increment Ops317471
+Node: Truth Values and Conditions320941
+Node: Truth Values322024
+Node: Typing and Comparison323073
+Node: Variable Typing323862
+Ref: Variable Typing-Footnote-1327759
+Node: Comparison Operators327881
+Ref: table-relational-ops328291
+Node: POSIX String Comparison331840
+Ref: POSIX String Comparison-Footnote-1332796
+Node: Boolean Ops332934
+Ref: Boolean Ops-Footnote-1337012
+Node: Conditional Exp337103
+Node: Function Calls338835
+Node: Precedence342429
+Node: Locales346098
+Node: Patterns and Actions347187
+Node: Pattern Overview348241
+Node: Regexp Patterns349910
+Node: Expression Patterns350453
+Node: Ranges354138
+Node: BEGIN/END357104
+Node: Using BEGIN/END357866
+Ref: Using BEGIN/END-Footnote-1360597
+Node: I/O And BEGIN/END360703
+Node: BEGINFILE/ENDFILE362985
+Node: Empty365889
+Node: Using Shell Variables366205
+Node: Action Overview368490
+Node: Statements370847
+Node: If Statement372701
+Node: While Statement374200
+Node: Do Statement376244
+Node: For Statement377400
+Node: Switch Statement380552
+Node: Break Statement382649
+Node: Continue Statement384639
+Node: Next Statement386432
+Node: Nextfile Statement388822
+Node: Exit Statement391463
+Node: Built-in Variables393879
+Node: User-modified394974
+Ref: User-modified-Footnote-1403329
+Node: Auto-set403391
+Ref: Auto-set-Footnote-1415085
+Ref: Auto-set-Footnote-2415290
+Node: ARGC and ARGV415346
+Node: Arrays419197
+Node: Array Basics420702
+Node: Array Intro421528
+Node: Reference to Elements425846
+Node: Assigning Elements428116
+Node: Array Example428607
+Node: Scanning an Array430339
+Node: Controlling Scanning432653
+Ref: Controlling Scanning-Footnote-1437586
+Node: Delete437902
+Ref: Delete-Footnote-1440667
+Node: Numeric Array Subscripts440724
+Node: Uninitialized Subscripts442907
+Node: Multi-dimensional444535
+Node: Multi-scanning447629
+Node: Arrays of Arrays449220
+Node: Functions453865
+Node: Built-in454687
+Node: Calling Built-in455765
+Node: Numeric Functions457753
+Ref: Numeric Functions-Footnote-1461585
+Ref: Numeric Functions-Footnote-2461942
+Ref: Numeric Functions-Footnote-3461990
+Node: String Functions462259
+Ref: String Functions-Footnote-1485756
+Ref: String Functions-Footnote-2485885
+Ref: String Functions-Footnote-3486133
+Node: Gory Details486220
+Ref: table-sub-escapes487899
+Ref: table-sub-posix-92489253
+Ref: table-sub-proposed490596
+Ref: table-posix-sub491946
+Ref: table-gensub-escapes493492
+Ref: Gory Details-Footnote-1494699
+Ref: Gory Details-Footnote-2494750
+Node: I/O Functions494901
+Ref: I/O Functions-Footnote-1501556
+Node: Time Functions501703
+Ref: Time Functions-Footnote-1512595
+Ref: Time Functions-Footnote-2512663
+Ref: Time Functions-Footnote-3512821
+Ref: Time Functions-Footnote-4512932
+Ref: Time Functions-Footnote-5513044
+Ref: Time Functions-Footnote-6513271
+Node: Bitwise Functions513537
+Ref: table-bitwise-ops514095
+Ref: Bitwise Functions-Footnote-1518316
+Node: Type Functions518500
+Node: I18N Functions518970
+Node: User-defined520597
+Node: Definition Syntax521401
+Ref: Definition Syntax-Footnote-1526311
+Node: Function Example526380
+Node: Function Caveats528974
+Node: Calling A Function529395
+Node: Variable Scope530510
+Node: Pass By Value/Reference532485
+Node: Return Statement535925
+Node: Dynamic Typing538906
+Node: Indirect Calls539641
+Node: Internationalization549326
+Node: I18N and L10N550752
+Node: Explaining gettext551438
+Ref: Explaining gettext-Footnote-1556504
+Ref: Explaining gettext-Footnote-2556688
+Node: Programmer i18n556853
+Node: Translator i18n561053
+Node: String Extraction561846
+Ref: String Extraction-Footnote-1562807
+Node: Printf Ordering562893
+Ref: Printf Ordering-Footnote-1565677
+Node: I18N Portability565741
+Ref: I18N Portability-Footnote-1568190
+Node: I18N Example568253
+Ref: I18N Example-Footnote-1570888
+Node: Gawk I18N570960
+Node: Advanced Features571577
+Node: Nondecimal Data573090
+Node: Array Sorting574673
+Node: Controlling Array Traversal575370
+Node: Array Sorting Functions583608
+Ref: Array Sorting Functions-Footnote-1587282
+Ref: Array Sorting Functions-Footnote-2587375
+Node: Two-way I/O587569
+Ref: Two-way I/O-Footnote-1593001
+Node: TCP/IP Networking593071
+Node: Profiling595915
+Node: Library Functions603369
+Ref: Library Functions-Footnote-1606376
+Node: Library Names606547
+Ref: Library Names-Footnote-1610018
+Ref: Library Names-Footnote-2610238
+Node: General Functions610324
+Node: Strtonum Function611277
+Node: Assert Function614207
+Node: Round Function617533
+Node: Cliff Random Function619076
+Node: Ordinal Functions620092
+Ref: Ordinal Functions-Footnote-1623162
+Ref: Ordinal Functions-Footnote-2623414
+Node: Join Function623623
+Ref: Join Function-Footnote-1625394
+Node: Getlocaltime Function625594
+Node: Data File Management629309
+Node: Filetrans Function629941
+Node: Rewind Function634080
+Node: File Checking635467
+Node: Empty Files636561
+Node: Ignoring Assigns638791
+Node: Getopt Function640344
+Ref: Getopt Function-Footnote-1651648
+Node: Passwd Functions651851
+Ref: Passwd Functions-Footnote-1660826
+Node: Group Functions660914
+Node: Walking Arrays668998
+Node: Sample Programs670567
+Node: Running Examples671232
+Node: Clones671960
+Node: Cut Program673184
+Node: Egrep Program683029
+Ref: Egrep Program-Footnote-1690802
+Node: Id Program690912
+Node: Split Program694528
+Ref: Split Program-Footnote-1698047
+Node: Tee Program698175
+Node: Uniq Program700978
+Node: Wc Program708407
+Ref: Wc Program-Footnote-1712673
+Ref: Wc Program-Footnote-2712873
+Node: Miscellaneous Programs712965
+Node: Dupword Program714153
+Node: Alarm Program716184
+Node: Translate Program720933
+Ref: Translate Program-Footnote-1725320
+Ref: Translate Program-Footnote-2725548
+Node: Labels Program725682
+Ref: Labels Program-Footnote-1729053
+Node: Word Sorting729137
+Node: History Sorting733021
+Node: Extract Program734860
+Ref: Extract Program-Footnote-1742343
+Node: Simple Sed742471
+Node: Igawk Program745533
+Ref: Igawk Program-Footnote-1760690
+Ref: Igawk Program-Footnote-2760891
+Node: Anagram Program761029
+Node: Signature Program764097
+Node: Debugger765197
+Node: Debugging766163
+Node: Debugging Concepts766596
+Node: Debugging Terms768452
+Node: Awk Debugging771049
+Node: Sample Debugging Session771941
+Node: Debugger Invocation772461
+Node: Finding The Bug773790
+Node: List of Debugger Commands780278
+Node: Breakpoint Control781612
+Node: Debugger Execution Control785276
+Node: Viewing And Changing Data788636
+Node: Execution Stack791992
+Node: Debugger Info793459
+Node: Miscellaneous Debugger Commands797440
+Node: Readline Support802885
+Node: Limitations803716
+Node: Arbitrary Precision Arithmetic805968
+Ref: Arbitrary Precision Arithmetic-Footnote-1807610
+Node: General Arithmetic807758
+Node: Floating Point Issues809478
+Node: String Conversion Precision810359
+Ref: String Conversion Precision-Footnote-1812065
+Node: Unexpected Results812174
+Node: POSIX Floating Point Problems814327
+Ref: POSIX Floating Point Problems-Footnote-1818152
+Node: Integer Programming818190
+Node: Floating-point Programming819943
+Ref: Floating-point Programming-Footnote-1826252
+Node: Floating-point Representation826516
+Node: Floating-point Context827681
+Ref: table-ieee-formats828523
+Node: Rounding Mode829907
+Ref: table-rounding-modes830386
+Ref: Rounding Mode-Footnote-1833390
+Node: Gawk and MPFR833571
+Node: Arbitrary Precision Floats834813
+Ref: Arbitrary Precision Floats-Footnote-1837242
+Node: Setting Precision837553
+Node: Setting Rounding Mode840286
+Ref: table-gawk-rounding-modes840690
+Node: Floating-point Constants841870
+Node: Changing Precision843294
+Ref: Changing Precision-Footnote-1844694
+Node: Exact Arithmetic844868
+Node: Arbitrary Precision Integers847976
+Ref: Arbitrary Precision Integers-Footnote-1850976
+Node: Dynamic Extensions851123
+Node: Plugin License852041
+Node: Sample Library852655
+Node: Internal File Description853339
+Node: Internal File Ops857052
+Ref: Internal File Ops-Footnote-1861615
+Node: Using Internal File Ops861755
+Node: Language History864131
+Node: V7/SVR3.1865653
+Node: SVR4867974
+Node: POSIX869416
+Node: BTL870424
+Node: POSIX/GNU871158
+Node: Common Extensions876693
+Node: Ranges and Locales877800
+Ref: Ranges and Locales-Footnote-1882418
+Ref: Ranges and Locales-Footnote-2882445
+Ref: Ranges and Locales-Footnote-3882705
+Node: Contributors882926
+Node: Installation887222
+Node: Gawk Distribution888116
+Node: Getting888600
+Node: Extracting889426
+Node: Distribution contents891118
+Node: Unix Installation896340
+Node: Quick Installation896957
+Node: Additional Configuration Options898919
+Node: Configuration Philosophy900396
+Node: Non-Unix Installation902738
+Node: PC Installation903196
+Node: PC Binary Installation904495
+Node: PC Compiling906343
+Node: PC Testing909287
+Node: PC Using910463
+Node: Cygwin914648
+Node: MSYS915648
+Node: VMS Installation916162
+Node: VMS Compilation916765
+Ref: VMS Compilation-Footnote-1917772
+Node: VMS Installation Details917830
+Node: VMS Running919465
+Node: VMS Old Gawk921072
+Node: Bugs921546
+Node: Other Versions925398
+Node: Notes930713
+Node: Compatibility Mode931300
+Node: Additions932083
+Node: Accessing The Source933010
+Node: Adding Code934436
+Node: New Ports940478
+Node: Derived Files944613
+Ref: Derived Files-Footnote-1949918
+Ref: Derived Files-Footnote-2949952
+Ref: Derived Files-Footnote-3950552
+Node: Future Extensions950650
+Node: Basic Concepts952137
+Node: Basic High Level952818
+Ref: Basic High Level-Footnote-1956853
+Node: Basic Data Typing957038
+Node: Glossary960393
+Node: Copying985568
+Node: GNU Free Documentation License1023125
+Node: Index1048262

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index f0f74fef..f0378b30 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -88,9 +88,11 @@
@c some special symbols
@iftex
@set LEQ @math{@leq}
+@set PI @math{@pi}
@end iftex
@ifnottex
@set LEQ <=
+@set PI @i{pi}
@end ifnottex
@ifnottex
@@ -299,13 +301,17 @@ particular records in a file and perform operations upon them.
* Library Functions:: A Library of @command{awk} Functions.
* Sample Programs:: Many @command{awk} programs with complete
explanations.
-* Debugger:: The @code{dgawk} debugger.
+* Debugger:: The @code{gawk} debugger.
+* Arbitrary Precision Arithmetic:: Arbitrary precision arithmetic with
+ @command{gawk}.
+* Dynamic Extensions:: Adding new built-in functions to
+ @command{gawk}.
* Language History:: The evolution of the @command{awk}
language.
* Installation:: Installing @command{gawk} under various
operating systems.
-* Notes:: Notes about @command{gawk} extensions and
- possible future work.
+* Notes:: Notes about adding things to @command{gawk}
+ and possible future work.
* Basic Concepts:: A very quick introduction to programming
concepts.
* Glossary:: An explanation of some unfamiliar terms.
@@ -360,9 +366,12 @@ particular records in a file and perform operations upon them.
uses.
* AWKPATH Variable:: Searching directories for @command{awk}
programs.
+* AWKLIBPATH Variable:: Searching directories for @command{awk}
+ shared libraries.
* Other Environment Variables:: The environment variables.
* Exit Status:: @command{gawk}'s exit status.
* Include Files:: Including other files into your program.
+* Loading Shared Libraries:: Loading shared libraries into your program.
* Obsolete:: Obsolete Options and/or features.
* Undocumented:: Undocumented Options and Features.
* Regexp Usage:: How to Use Regular Expressions.
@@ -402,6 +411,7 @@ particular records in a file and perform operations upon them.
* Getline Notes:: Important things to know about
@code{getline}.
* Getline Summary:: Summary of @code{getline} Variants.
+* Read Timeout:: Reading input with a timeout.
* Command line directories:: What happens if you put a directory on the
command line.
* Print:: The @code{print} statement.
@@ -583,7 +593,7 @@ particular records in a file and perform operations upon them.
* Ordinal Functions:: Functions for using characters as numbers
and vice versa.
* Join Function:: A function to join an array into a string.
-* Gettimeofday Function:: A function to get formatted times.
+* Getlocaltime Function:: A function to get formatted times.
* Data File Management:: Functions for managing command-line data
files.
* Filetrans Function:: A function for handling data file
@@ -623,23 +633,51 @@ particular records in a file and perform operations upon them.
* Anagram Program:: Finding anagrams from a dictionary.
* Signature Program:: People do amazing things with too much time
on their hands.
-* Debugging:: Introduction to @command{dgawk}.
-* Debugging Concepts:: Debugging In General.
+* Debugging:: Introduction to @command{gawk} debugger.
+* Debugging Concepts:: Debugging in General.
* Debugging Terms:: Additional Debugging Concepts.
* Awk Debugging:: Awk Debugging.
-* Sample dgawk session:: Sample @command{dgawk} session.
-* dgawk invocation:: @command{dgawk} Invocation.
-* Finding The Bug:: Finding The Bug.
-* List of Debugger Commands:: Main @command{dgawk} Commands.
-* Breakpoint Control:: Control of breakpoints.
-* Dgawk Execution Control:: Control of execution.
-* Viewing And Changing Data:: Viewing and changing data.
-* Dgawk Stack:: Dealing with the stack.
-* Dgawk Info:: Obtaining information about the program and
- the debugger state.
-* Miscellaneous Dgawk Commands:: Miscellaneous Commands.
-* Readline Support:: Readline Support.
-* Dgawk Limitations:: Limitations and future plans.
+* Sample Debugging Session:: Sample debugging session.
+* Debugger Invocation:: How to Start the Debugger.
+* Finding The Bug:: Finding the Bug.
+* List of Debugger Commands:: Main debugger commands.
+* Breakpoint Control:: Control of Breakpoints.
+* Debugger Execution Control:: Control of Execution.
+* Viewing And Changing Data:: Viewing and Changing Data.
+* Execution Stack:: Dealing with the Stack.
+* Debugger Info:: Obtaining Information about the Program and
+ the Debugger State.
+* Miscellaneous Debugger Commands:: Miscellaneous Commands.
+* Readline Support:: Readline support.
+* Limitations:: Limitations and future plans.
+* General Arithmetic:: An introduction to computer arithmetic.
+* Floating Point Issues:: Stuff to know about floating-point numbers.
+* String Conversion Precision:: The String Value Can Lie.
+* Unexpected Results:: Floating Point Numbers Are Not Abstract
+ Numbers.
+* POSIX Floating Point Problems:: Standards Versus Existing Practice.
+* Integer Programming:: Effective integer programming.
+* Floating-point Programming:: Effective Floating-point Programming.
+* Floating-point Representation:: Binary floating-point representation.
+* Floating-point Context:: Floating-point context.
+* Rounding Mode:: Floating-point rounding mode.
+* Gawk and MPFR:: How @command{gawk} provides
+ arbitrary-precision arithmetic.
+* Arbitrary Precision Floats:: Arbitrary Precision Floating-point
+ Arithmetic with @command{gawk}.
+* Setting Precision:: Setting the working precision.
+* Setting Rounding Mode:: Setting the rounding mode.
+* Floating-point Constants:: Representing floating-point constants.
+* Changing Precision:: Changing the precision of a number.
+* Exact Arithmetic:: Exact arithmetic with floating-point
+ numbers.
+* Arbitrary Precision Integers:: Arbitrary Precision Integer Arithmetic with
+ @command{gawk}.
+* Plugin License:: A note about licensing.
+* Sample Library:: A example of new functions.
+* Internal File Description:: What the new functions will do.
+* Internal File Ops:: The code for internal file operations.
+* Using Internal File Ops:: How to use an external extension.
* V7/SVR3.1:: The major changes between V7 and System V
Release 3.1.
* SVR4:: Minor changes between System V Releases 3.1
@@ -690,24 +728,12 @@ particular records in a file and perform operations upon them.
@command{gawk}.
* New Ports:: Porting @command{gawk} to a new operating
system.
-* Dynamic Extensions:: Adding new built-in functions to
- @command{gawk}.
-* Internals:: A brief look at some @command{gawk}
- internals.
-* Plugin License:: A note about licensing.
-* Sample Library:: A example of new functions.
-* Internal File Description:: What the new functions will do.
-* Internal File Ops:: The code for internal file operations.
-* Using Internal File Ops:: How to use an external extension.
+* Derived Files:: Why derived files are kept in the
+ @command{git} repository.
* Future Extensions:: New features that may be implemented one
day.
* Basic High Level:: The high level view.
* Basic Data Typing:: A very quick intro to data types.
-* Floating Point Issues:: Stuff to know about floating-point numbers.
-* String Conversion Precision:: The String Value Can Lie.
-* Unexpected Results:: Floating Point Numbers Are Not Abstract
- Numbers.
-* POSIX Floating Point Problems:: Standards Versus Existing Practice.
@end detailmenu
@end menu
@@ -1173,8 +1199,14 @@ provide many sample @command{awk} programs.
Reading them allows you to see @command{awk}
solving real problems.
-@ref{Debugger}, describes the @command{awk} debugger,
-@command{dgawk}.
+@ref{Debugger}, describes the @command{awk} debugger.
+
+@ref{Arbitrary Precision Arithmetic},
+describes advanced arithmetic facilities provided by
+@command{gawk}.
+
+@ref{Dynamic Extensions}, describes how to add new variables and
+functions to @command{gawk} by writing extensions in C.
@ref{Language History},
describes how the @command{awk} language has evolved since
@@ -1192,8 +1224,7 @@ available @command{awk} implementations.
@ref{Notes},
describes how to disable @command{gawk}'s extensions, as
well as how to contribute new code to @command{gawk},
-how to write extension libraries, and some possible
-future directions for @command{gawk} development.
+and some possible future directions for @command{gawk} development.
@ref{Basic Concepts},
provides some very cursory background material for those who
@@ -1603,10 +1634,13 @@ has been and continues to be a pleasure working with this team of fine
people.
John Haque contributed the modifications to convert @command{gawk}
-into a byte-code interpreter, including the debugger. Stephen Davies
+into a byte-code interpreter, including the debugger, and the
+additional modifications for support of arbitrary precision arithmetic.
+Stephen Davies
contributed to the effort to bring the byte-code changes into the mainstream
code base.
Efraim Yawitz contributed the initial text of @ref{Debugger}.
+John Haque contributed the initial text of @ref{Arbitrary Precision Arithmetic}.
@cindex Kernighan, Brian
I would like to thank Brian Kernighan for invaluable assistance during the
@@ -2913,6 +2947,7 @@ things in this @value{CHAPTER} that don't interest you right now.
* Environment Variables:: The environment variables @command{gawk} uses.
* Exit Status:: @command{gawk}'s exit status.
* Include Files:: Including other files into your program.
+* Loading Shared Libraries:: Loading shared libraries into your program.
* Obsolete:: Obsolete Options and/or features.
* Undocumented:: Undocumented Options and Features.
@end menu
@@ -3004,6 +3039,22 @@ This option may be given multiple times; the @command{awk}
program consists of the concatenation the contents of
each specified @var{source-file}.
+@item -i @var{source-file}
+@itemx --include @var{source-file}
+@cindex @code{-i} option
+@cindex @code{--include} option
+@cindex @command{awk} programs, location of
+Read @command{awk} source library from @var{source-file}. This option is
+completely equivalent to using the @samp{@@include} directive inside
+your program. This option is very
+similar to the @option{-f} option, but there are two important differences.
+First, when @option{-i} is used, the program source will not be loaded if it has
+been previously loaded, whereas the @option{-f} will always load the file.
+Second, because this option is intended to be used with code libraries, the
+@command{awk} command does not recognize such files as constituting main program
+input. Thus, after processing an @option{-i} argument, we still expect to
+find the main source code via the @option{-f} option or on the command-line.
+
@item -v @var{var}=@var{val}
@itemx --assign @var{var}=@var{val}
@cindex @code{-v} option
@@ -3115,6 +3166,19 @@ inadvertently use global variables that you meant to be local.
(This is a particularly easy mistake to make with simple variable
names like @code{i}, @code{j}, etc.)
+@item -D@r{[}@var{file}@r{]}
+@itemx --debug=@r{[}@var{file}@r{]}
+@cindex @code{-D} option
+@cindex @code{--debug} option
+@cindex @command{awk} debugging, enabling
+Enable debugging of @command{awk} programs
+(@pxref{Debugging}).
+By default, the debugger reads commands interactively from the terminal.
+The optional @var{file} argument allows you to specify a file with a list
+of commands for the debugger to execute non-interactively.
+No space is allowed between the @option{-D} and @var{file}, if
+@var{file} is supplied.
+
@item -e @var{program-text}
@itemx --source @var{program-text}
@cindex @code{-e} option
@@ -3180,6 +3244,18 @@ for information about this option.
Print a ``usage'' message summarizing the short and long style options
that @command{gawk} accepts and then exit.
+@item -l @var{lib}
+@itemx --load @var{lib}
+@cindex @code{-l} option
+@cindex @code{--load} option
+@cindex loading, library
+Load a shared library @var{lib}. This searches for the library using the @env{AWKLIBPATH}
+environment variable. The correct library suffix for your platform will be
+supplied by default, so it need not be specified in the library name.
+The library initialization routine should be named @code{dl_load()}.
+An alternative is to use the @samp{@@load} keyword inside the program to load
+a shared library.
+
@item -L @r{[}value@r{]}
@itemx --lint@r{[}=value@r{]}
@cindex @code{-l} option
@@ -3203,6 +3279,14 @@ when eliminating problems pointed out by @option{--lint}, you should take
care to search for all occurrences of each inappropriate construct. As
@command{awk} programs are usually short, doing so is not burdensome.
+@item -M
+@itemx --bignum
+@cindex @code{-M} option
+@cindex @code{--bignum} option
+Force arbitrary precision arithmetic on numbers. This option has no effect
+if @command{gawk} is not compiled to use the GNU MPFR and MP libraries
+(@pxref{Arbitrary Precision Arithmetic}).
+
@item -n
@itemx --non-decimal-data
@cindex @code{-n} option
@@ -3226,6 +3310,18 @@ Use with care.
Force the use of the locale's decimal point character
when parsing numeric input data (@pxref{Locales}).
+@item -o@r{[}@var{file}@r{]}
+@itemx --pretty-print@r{[}=@var{file}@r{]}
+@cindex @code{-o} option
+@cindex @code{--pretty-print} option
+@cindex @command{awk} enabling
+Enable pretty-printing of @command{awk} programs.
+By default, output program is created in a file named @file{awkprof.out}.
+The optional @var{file} argument allows you to specify a different
+@value{FN} for the output.
+No space is allowed between the @option{-o} and @var{file}, if
+@var{file} is supplied.
+
@item -O
@itemx --optimize
@cindex @code{--optimize} option
@@ -3238,7 +3334,7 @@ maintainer hopes to add more optimizations over time.
@itemx --profile@r{[}=@var{file}@r{]}
@cindex @code{-p} option
@cindex @code{--profile} option
-@cindex @command{awk} programs, profiling, enabling
+@cindex @command{awk} profiling, enabling
Enable profiling of @command{awk} programs
(@pxref{Profiling}).
By default, profiles are created in a file named @file{awkprof.out}.
@@ -3247,10 +3343,8 @@ The optional @var{file} argument allows you to specify a different
No space is allowed between the @option{-p} and @var{file}, if
@var{file} is supplied.
-When run with @command{gawk}, the profile is just a ``pretty printed'' version
-of the program. When run with @command{pgawk}, the profile contains execution
-counts for each statement in the program in the left margin, and function
-call counts for each function.
+The profile contains execution counts for each statement in the program
+in the left margin, and function call counts for each function.
@item -P
@itemx --posix
@@ -3314,14 +3408,6 @@ This is now @command{gawk}'s default behavior.
Nevertheless, this option remains both for backward compatibility,
and for use in combination with the @option{--traditional} option.
-@item -R @var{file}
-@itemx --command=@var{file}
-@cindex @code{-R} option
-@cindex @code{--command} option
-@command{dgawk} only.
-Read @command{dgawk} debugger options and commands from @var{file}.
-@xref{Dgawk Info}, for more information.
-
@item -S
@itemx --sandbox
@cindex @code{-S} option
@@ -3547,6 +3633,8 @@ behaves.
@menu
* AWKPATH Variable:: Searching directories for @command{awk}
programs.
+* AWKLIBPATH Variable:: Searching directories for @command{awk} shared
+ libraries.
* Other Environment Variables:: The environment variables.
@end menu
@@ -3564,7 +3652,8 @@ on the command-line with the @option{-f} option.
In most @command{awk}
implementations, you must supply a precise path name for each program
file, unless the file is in the current directory.
-But in @command{gawk}, if the @value{FN} supplied to the @option{-f} option
+But in @command{gawk}, if the @value{FN} supplied to the @option{-f}
+or @option{-i} options
does not contain a @samp{/}, then @command{gawk} searches a list of
directories (called the @dfn{search path}), one by one, looking for a
file with the specified name.
@@ -3586,13 +3675,16 @@ standard directory in the default path and then specified on
the command line with a short @value{FN}. Otherwise, the full @value{FN}
would have to be typed for each file.
-By using both the @option{--source} and @option{-f} options, your command-line
+By using the @option{-i} option, or the @option{--source} and @option{-f} options, your command-line
@command{awk} programs can use facilities in @command{awk} library files
(@pxref{Library Functions}).
Path searching is not done if @command{gawk} is in compatibility mode.
This is true for both @option{--traditional} and @option{--posix}.
@xref{Options}.
+If the source code is not found after the initial search, the path is searched
+again after adding the default @samp{.awk} suffix to the filename.
+
@quotation NOTE
To include
the current directory in the path, either place
@@ -3622,6 +3714,21 @@ sense: the @env{AWKPATH} environment variable is used to find the program
source files. Once your program is running, all the files have been
found, and @command{gawk} no longer needs to use @env{AWKPATH}.
+@node AWKLIBPATH Variable
+@subsection The @env{AWKLIBPATH} Environment Variable
+@cindex @env{AWKLIBPATH} environment variable
+@cindex directories, searching
+@cindex search paths
+@cindex search paths, for shared libraries
+@cindex differences in @command{awk} and @command{gawk}, @code{AWKLIBPATH} environment variable
+
+The @env{AWKLIBPATH} environment variable is similar to the @env{AWKPATH}
+variable, but it is used to search for shared libraries specified
+with the @option{-l} option rather than for source files. If the library
+is not found, the path is searched again after adding the appropriate
+shared library suffix for the platform. For example, on GNU/Linux systems,
+the suffix @samp{.so} is used.
+
@node Other Environment Variables
@subsection Other Environment Variables
@@ -3645,6 +3752,11 @@ Specifies the interval between connection retries,
in milliseconds. On systems that do not support
the @code{usleep()} system call,
the value is rounded up to an integral number of seconds.
+
+@item GAWK_READ_TIMEOUT
+Specifies the time, in milliseconds, for @command{gawk} to
+wait for input before returning with an error.
+@xref{Read Timeout}.
@end table
The environment variables in the following list are meant
@@ -3718,8 +3830,9 @@ into smaller, more manageable pieces, and also lets you reuse common @command{aw
code from various @command{awk} scripts. In other words, you can group
together @command{awk} functions, used to carry out specific tasks,
into external files. These files can be used just like function libraries,
-using the @samp{@@include} keyword in conjunction with the @code{AWKPATH}
-environment variable.
+using the @samp{@@include} keyword in conjunction with the @env{AWKPATH}
+environment variable. Note that source files may also be included
+using the @option{-i} option.
Let's see an example.
We'll start with two (trivial) @command{awk} scripts, namely
@@ -3825,6 +3938,41 @@ As mentioned in @ref{AWKPATH Variable}, the current directory is always
searched first for source files, before searching in @env{AWKPATH},
and this also applies to files named with @samp{@@include}.
+@node Loading Shared Libraries
+@section Loading Shared Libraries Into Your Program
+
+This @value{SECTION} describes a feature that is specific to @command{gawk}.
+
+The @samp{@@load} keyword can be used to read external @command{awk} shared
+libraries. This allows you to link in compiled code that may offer superior
+performance and/or give you access to extended capabilities not supported
+by the @command{awk} language. The @env{AWKLIBPATH} variable is used to
+search for the shared library. Using @samp{@@load} is completely equivalent
+to using the @option{-l} command-line option.
+
+If the shared library is not initially found in @env{AWKLIBPATH}, another
+search is conducted after appending the platform's default shared library
+suffix to the filename. For example, on GNU/Linux systems, the suffix
+@samp{.so} is used.
+
+@example
+$ @kbd{gawk '@@load "ordchr"; BEGIN @{print chr(65)@}'}
+@print{} A
+@end example
+
+@noindent
+This is equivalent to the following example:
+
+@example
+$ @kbd{gawk -lordchr 'BEGIN @{print chr(65)@}'}
+@print{} A
+@end example
+
+@noindent
+For command-line usage, the @option{-l} option is more convenient,
+but @samp{@@load} is useful for embedding inside an @command{awk} source file
+that requires access to a shared library.
+
@node Obsolete
@section Obsolete Options and/or Features
@@ -5131,6 +5279,7 @@ used with it do not have to be named on the @command{awk} command line
* Multiple Line:: Reading multi-line records.
* Getline:: Reading files under explicit program control
using the @code{getline} function.
+* Read Timeout:: Reading input with a timeout.
* Command line directories:: What happens if you put a directory on the
command line.
@end menu
@@ -7224,6 +7373,7 @@ know that there is a string value to be assigned. Caveat Emptor.
summarizes the eight variants of @code{getline},
listing which built-in variables are set by each one,
and whether the variant is standard or a @command{gawk} extension.
+Note: for each variant, @command{gawk} sets the @code{RT} built-in variable.
@float Table,table-getline-variants
@caption{getline Variants and What They Set}
@@ -7243,6 +7393,110 @@ and whether the variant is standard or a @command{gawk} extension.
@c ENDOFRANGE inex
@c ENDOFRANGE infir
+@node Read Timeout
+@section Reading Input With A Timeout
+@cindex timeout, reading input
+
+You may specify a timeout in milliseconds for reading input from a terminal,
+pipe or two-way communication including, TCP/IP sockets. This can be done
+on a per input, command or connection basis, by setting a special element
+in the @code{PROCINFO} array:
+
+@example
+PROCINFO["input_name", "READ_TIMEOUT"] = @var{timeout in milliseconds}
+@end example
+
+When set, this will cause @command{gawk} to time out and return failure
+if no data is available to read within the specified timeout period.
+For example, a TCP client can decide to give up on receiving
+any response from the server after a certain amount of time:
+
+@example
+Service = "/inet/tcp/0/localhost/daytime"
+PROCINFO[Service, "READ_TIMEOUT"] = 100
+if ((Service |& getline) > 0)
+ print $0
+else if (ERRNO != "")
+ print ERRNO
+@end example
+
+Here is how to read interactively from the terminal@footnote{This assumes
+that standard input is the keyboard} without waiting
+for more than five seconds:
+
+@example
+PROCINFO["/dev/stdin", "READ_TIMEOUT"] = 5000
+while ((getline < "/dev/stdin") > 0)
+ print $0
+@end example
+
+@command{gawk} will terminate the read operation if input does not
+arrive after waiting for the timeout period, return failure
+and set the @code{ERRNO} variable to an appropriate string value.
+A negative or zero value for the timeout is the same as specifying
+no timeout at all.
+
+A timeout can also be set for reading from the terminal in the implicit
+loop that reads input records and matches them against patterns,
+like so:
+
+@example
+$ @kbd{ gawk 'BEGIN @{ PROCINFO["-", "READ_TIMEOUT"] = 5000 @}}
+> @kbd{@{ print "You entered: " $0 @}'}
+@kbd{gawk}
+@print{} You entered: gawk
+@end example
+
+In this case, failure to respond within five seconds results in the following
+error message:
+
+@example
+@error{} gawk: cmd. line:2: (FILENAME=- FNR=1) fatal: error reading input file `-': Connection timed out
+@end example
+
+The timeout can be set or changed at any time, and will take effect on the
+next attempt to read from the input device. In the following example,
+we start with a timeout value of one second, and progressively
+reduce it by one-tenth of a second until we wait indefinitely
+for the input to arrive:
+
+@example
+PROCINFO[Service, "READ_TIMEOUT"] = 1000
+while ((Service |& getline) > 0) @{
+ print $0
+ PROCINFO[S, "READ_TIMEOUT"] -= 100
+@}
+@end example
+
+@quotation NOTE
+You should not assume that the read operation will block
+exactly after the tenth record has been printed. It is possible that
+@command{gawk} will read and buffer more than one record's
+worth of data the first time. Because of this, changing the value
+of timeout like in the above example is not very useful.
+@end quotation
+
+If the @code{PROCINFO} element is not present and the environment
+variable @env{GAWK_READ_TIMEOUT} exists,
+@command{gawk} uses its value to initialize the timeout value.
+The exclusive use of the environment variable to specify timeout
+has the disadvantage of not being able to control it
+on a per command or connection basis.
+
+@command{gawk} considers a timeout event to be an error even though
+the attempt to read from the underlying device may
+succeed in a later attempt. This is a limitation, and it also
+means that you cannot use this to multiplex input from
+two or more sources.
+
+Assigning a timeout value prevents read operations from
+blocking indefinitely. But bear in mind that there are other ways
+@command{gawk} can stall waiting for an input device to be ready.
+A network client can sometimes take a long time to establish
+a connection before it can start reading any data,
+or the attempt to open a FIFO special file for reading can block
+indefinitely until some other process opens it for writing.
+
@node Command line directories
@section Directories On The Command Line
@cindex directories, command line
@@ -11361,9 +11615,9 @@ fatal error.
@item
If you have written extensions that modify the record handling (by inserting
-an ``open hook''), you can invoke them at this point, before @command{gawk}
+an ``input parser''), you can invoke them at this point, before @command{gawk}
has started processing the file. (This is a @emph{very} advanced feature,
-currently used only by the @uref{http://xmlgawk.sourceforge.net, XMLgawk project}.)
+currently used only by the @uref{http://gawkextlib.sourceforge.net, @code{gawkextlib} project}.)
@end itemize
The @code{ENDFILE} rule is called when @command{gawk} has finished processing
@@ -12525,6 +12779,18 @@ This is the output record separator. It is output at the end of every
@code{print} statement. Its default value is @code{"\n"}, the newline
character. (@xref{Output Separators}.)
+@cindex @code{PREC} variable
+@item PREC #
+The working precision of arbitrary precision floating-point numbers,
+53 by default (@pxref{Setting Precision}).
+
+@cindex @code{ROUNDMODE} variable
+@item ROUNDMODE #
+The rounding mode to use for arbitrary precision arithmetic on
+numbers, by default @code{"N"} (@samp{roundTiesToEven} in
+the IEEE-754 standard)
+(@pxref{Setting Rounding Mode}).
+
@cindex @code{RS} variable
@cindex separators, for records
@cindex record separators
@@ -12671,7 +12937,9 @@ does not affect the environment passed on to any programs that
Some operating systems may not have environment variables.
On such systems, the @code{ENVIRON} array is empty (except for
@w{@code{ENVIRON["AWKPATH"]}},
-@pxref{AWKPATH Variable}).
+@pxref{AWKPATH Variable} and
+@w{@code{ENVIRON["AWKLIBPATH"]}},
+@pxref{AWKLIBPATH Variable}).
@cindex @command{gawk}, @code{ERRNO} variable in
@cindex @code{ERRNO} variable
@@ -12747,6 +13015,16 @@ assigning a value to @code{NF} has the potential to affect
to @code{NF} can be used to create or remove fields from the
current record. @xref{Changing Fields}.
+@cindex @code{FUNCTAB} array
+@cindex @command{gawk}, @code{FUNCTAB} array in
+@cindex differences in @command{awk} and @command{gawk}, @code{FUNCTAB} variable
+@item FUNCTAB #
+An array whose indices are the names of all the user-defined
+or extension functions in the program.
+@strong{NOTE}: The array values cannot currently be used.
+Also, you may not use the @code{delete} statement with the
+@code{FUNCTAB} array.
+
@cindex @code{NR} variable
@item NR
The number of input records @command{awk} has processed since
@@ -12776,6 +13054,34 @@ This is
@code{"FIELDWIDTHS"} if field splitting with @code{FIELDWIDTHS} is in effect,
or @code{"FPAT"} if field matching with @code{FPAT} is in effect.
+@item PROCINFO["identifiers"]
+A subarray, indexed by the names of all identifiers used in the
+text of the AWK program. For each identifier, the value of the element is one of the following:
+
+@table @code
+@item "array"
+The identifier is an array.
+
+@item "extension"
+The identifier is an extension function loaded via
+@code{@@load}.
+
+@item "scalar"
+The identifier is a scalar.
+
+@item "untyped"
+The identifier is untyped (could be used as a scalar or array,
+@command{gawk} doesn't know yet).
+
+@item "user"
+The identifier is a user-defined function.
+@end table
+
+@noindent
+The values indicate what @command{gawk} knows about the identifiers
+after it has finished parsing the program; they are @emph{not} updated
+while the program runs.
+
@item PROCINFO["gid"]
The value of the @code{getgid()} system call.
@@ -12808,6 +13114,25 @@ The value of the @code{getuid()} system call.
The version of @command{gawk}.
@end table
+The following additional elements in the array
+are available to provide information about the MPFR and GMP libraries
+if your version of @command{gawk} supports arbitrary precision numbers
+(@pxref{Arbitrary Precision Arithmetic}):
+
+@table @code
+@item PROCINFO["mpfr_version"]
+The version of the GNU MPFR library.
+
+@item PROCINFO["gmp_version"]
+The version of the GNU MP library.
+
+@item PROCINFO["prec_max"]
+The maximum precision supported by MPFR.
+
+@item PROCINFO["prec_min"]
+The minimum precision required by MPFR.
+@end table
+
On some systems, there may be elements in the array, @code{"group1"}
through @code{"group@var{N}"} for some @var{N}. @var{N} is the number of
supplementary groups that the process has. Use the @code{in} operator
@@ -12855,6 +13180,32 @@ In other @command{awk} implementations,
or if @command{gawk} is in compatibility mode
(@pxref{Options}),
it is not special.
+
+@cindex @command{gawk}, @code{SYMTAB} array in
+@cindex @code{SYMTAB} array
+@cindex differences in @command{awk} and @command{gawk}, @code{SYMTAB} variable
+@item SYMTAB #
+An array whose indices are the names of all currently defined
+global variables and arrays in the program. The array may be used
+for indirect access to read or write the value of a variable:
+
+@example
+foo = 5
+SYMTAB["foo"] = 4
+print foo # prints 4
+@end example
+
+@noindent
+The @code{isarray()} function (@pxref{Type Functions}) may be used to test
+if an element in @code{SYMTAB} is an array.
+Also, you may not use the @code{delete} statement with the
+@code{SYMTAB} array.
+
+@quotation NOTE
+In order to avoid severe time-travel paradoxes@footnote{Not to mention difficult
+implementation issues.}, neither @code{FUNCTAB} nor @code{SYMTAB}
+are available as elements within the @code{SYMTAB} array.
+@end quotation
@end table
@c ENDOFRANGE bvconi
@c ENDOFRANGE vbconi
@@ -16253,8 +16604,8 @@ bitwise operations just described. They are:
@cindex @command{gawk}, bitwise operations in
@table @code
@cindex @code{and()} function (@command{gawk})
-@item and(@var{v1}, @var{v2})
-Return the bitwise AND of the values provided by @var{v1} and @var{v2}.
+@item and(@var{v1}, @var{v2} @r{[}, @r{@dots{}]})
+Return the bitwise AND of the arguments. There must be at least two.
@cindex @code{compl()} function (@command{gawk})
@item compl(@var{val})
@@ -16265,16 +16616,16 @@ Return the bitwise complement of @var{val}.
Return the value of @var{val}, shifted left by @var{count} bits.
@cindex @code{or()} function (@command{gawk})
-@item or(@var{v1}, @var{v2})
-Return the bitwise OR of the values provided by @var{v1} and @var{v2}.
+@item or(@var{v1}, @var{v2} @r{[}, @r{@dots{}]})
+Return the bitwise OR of the arguments. There must be at least two.
@cindex @code{rshift()} function (@command{gawk})
@item rshift(@var{val}, @var{count})
Return the value of @var{val}, shifted right by @var{count} bits.
@cindex @code{xor()} function (@command{gawk})
-@item xor(@var{v1}, @var{v2})
-Return the bitwise XOR of the values provided by @var{v1} and @var{v2}.
+@item xor(@var{v1}, @var{v2} @r{[}, @r{@dots{}]})
+Return the bitwise XOR of the arguments. There must be at least two.
@end table
For all of these functions, first the double precision floating-point value is
@@ -18537,7 +18888,7 @@ Running the program produces the
following output:
@example
-$ @kbd{gawk -vPOS=1 -F: -f sort.awk /etc/passwd}
+$ @kbd{gawk -v POS=1 -F: -f sort.awk /etc/passwd}
@print{} adm:x:3:4:adm:/var/adm:/sbin/nologin
@print{} apache:x:48:48:Apache:/var/www:/sbin/nologin
@print{} avahi:x:70:70:Avahi daemon:/:/sbin/nologin
@@ -19029,40 +19380,32 @@ extensive examples.
@cindex @command{awk} programs, profiling
@c STARTOFRANGE proawk
@cindex profiling @command{awk} programs
-@c STARTOFRANGE pgawk
-@cindex @command{pgawk} program
-@cindex profiling @command{gawk}, See @command{pgawk} program
-
-You may produce execution
-traces of your @command{awk} programs.
-This is done with a specially compiled version of @command{gawk},
-called @command{pgawk} (``profiling @command{gawk}'').
-
+@cindex profiling @command{gawk}
@cindex @code{awkprof.out} file
@cindex files, @code{awkprof.out}
-@cindex @command{pgawk} program, @code{awkprof.out} file
-@command{pgawk} is identical in every way to @command{gawk}, except that when
-it has finished running, it creates a profile of your program in a file
-named @file{awkprof.out}.
-Because it is profiling, it also executes up to 45% slower than
+
+You may produce execution traces of your @command{awk} programs.
+This is done by passing the option @option{--profile} to @command{gawk}.
+When @command{gawk} has finished running, it creates a profile of your program in a file
+named @file{awkprof.out}. Because it is profiling, it also executes up to 45% slower than
@command{gawk} normally does.
@cindex @code{--profile} option
As shown in the following example,
the @option{--profile} option can be used to change the name of the file
-where @command{pgawk} will write the profile:
+where @command{gawk} will write the profile:
@example
-pgawk --profile=myprog.prof -f myprog.awk data1 data2
+gawk --profile=myprog.prof -f myprog.awk data1 data2
@end example
@noindent
-In the above example, @command{pgawk} places the profile in
+In the above example, @command{gawk} places the profile in
@file{myprog.prof} instead of in @file{awkprof.out}.
-Here is a sample
-session showing a simple @command{awk} program, its input data, and the
-results from running @command{pgawk}. First, the @command{awk} program:
+Here is a sample session showing a simple @command{awk} program, its input data, and the
+results from running @command{gawk} with the @option{--profile} option.
+First, the @command{awk} program:
@example
BEGIN @{ print "First BEGIN rule" @}
@@ -19102,12 +19445,12 @@ foo
junk
@end example
-Here is the @file{awkprof.out} that results from running @command{pgawk}
-on this program and data (this example also illustrates that @command{awk}
+Here is the @file{awkprof.out} that results from running the @command{gawk}
+profiler on this program and data (this example also illustrates that @command{awk}
programmers sometimes have to work late):
-@cindex @code{BEGIN} pattern, @command{pgawk} program
-@cindex @code{END} pattern, @command{pgawk} program
+@cindex @code{BEGIN} pattern
+@cindex @code{END} pattern
@example
# gawk profile, created Sun Aug 13 00:00:15 2000
@@ -19199,15 +19542,15 @@ keyword indicates how many times the function was called.
The counts next to the statements in the body show how many times
those statements were executed.
-@cindex @code{@{@}} (braces), @command{pgawk} program
-@cindex braces (@code{@{@}}), @command{pgawk} program
+@cindex @code{@{@}} (braces)
+@cindex braces (@code{@{@}})
@item
The layout uses ``K&R'' style with TABs.
Braces are used everywhere, even when
the body of an @code{if}, @code{else}, or loop is only a single statement.
-@cindex @code{()} (parentheses), @command{pgawk} program
-@cindex parentheses @code{()}, @command{pgawk} program
+@cindex @code{()} (parentheses)
+@cindex parentheses @code{()}
@item
Parentheses are used only where needed, as indicated by the structure
of the program and the precedence rules.
@@ -19230,16 +19573,16 @@ Similarly, if
the target of a redirection isn't a scalar, it gets parenthesized.
@item
-@command{pgawk} supplies leading comments in
+@command{gawk} supplies leading comments in
front of the @code{BEGIN} and @code{END} rules,
the pattern/action rules, and the functions.
@end itemize
The profiled version of your program may not look exactly like what you
-typed when you wrote it. This is because @command{pgawk} creates the
+typed when you wrote it. This is because @command{gawk} creates the
profiled version by ``pretty printing'' its internal representation of
-the program. The advantage to this is that @command{pgawk} can produce
+the program. The advantage to this is that @command{gawk} can produce
a standard representation. The disadvantage is that all source-code
comments are lost, as are the distinctions among multiple @code{BEGIN},
@code{END}, @code{BEGINFILE}, and @code{ENDFILE} rules. Also, things such as:
@@ -19261,15 +19604,16 @@ come out as:
which is correct, but possibly surprising.
@cindex profiling @command{awk} programs, dynamically
-@cindex @command{pgawk} program, dynamic profiling
+@cindex @command{gawk} program, dynamic profiling
Besides creating profiles when a program has completed,
-@command{pgawk} can produce a profile while it is running.
+@command{gawk} can produce a profile while it is running.
This is useful if your @command{awk} program goes into an
infinite loop and you want to see what has been executed.
-To use this feature, run @command{pgawk} in the background:
+To use this feature, run @command{gawk} with the @option{--profile}
+option in the background:
@example
-$ @kbd{pgawk -f myprog &}
+$ @kbd{gawk --profile -f myprog &}
[1] 13992
@end example
@@ -19280,7 +19624,7 @@ $ @kbd{pgawk -f myprog &}
@noindent
The shell prints a job number and process ID number; in this case, 13992.
Use the @command{kill} command to send the @code{USR1} signal
-to @command{pgawk}:
+to @command{gawk}:
@example
$ @kbd{kill -USR1 13992}
@@ -19288,8 +19632,8 @@ $ @kbd{kill -USR1 13992}
@noindent
As usual, the profiled version of the program is written to
-@file{awkprof.out}, or to a different file if you use the @option{--profile}
-option.
+@file{awkprof.out}, or to a different file if one specified with
+the @option{--profile} option.
Along with the regular profile, as shown earlier, the profile
includes a trace of any active functions:
@@ -19303,7 +19647,7 @@ includes a trace of any active functions:
# -- main --
@end example
-You may send @command{pgawk} the @code{USR1} signal as many times as you like.
+You may send @command{gawk} the @code{USR1} signal as many times as you like.
Each time, the profile and function call trace are appended to the output
profile file.
@@ -19311,7 +19655,7 @@ profile file.
@cindex @code{SIGHUP} signal
@cindex signals, @code{HUP}/@code{SIGHUP}
If you use the @code{HUP} signal instead of the @code{USR1} signal,
-@command{pgawk} produces the profile and the function call trace and then exits.
+@command{gawk} produces the profile and the function call trace and then exits.
@cindex @code{INT} signal (MS-Windows)
@cindex @code{SIGINT} signal (MS-Windows)
@@ -19319,21 +19663,20 @@ If you use the @code{HUP} signal instead of the @code{USR1} signal,
@cindex @code{QUIT} signal (MS-Windows)
@cindex @code{SIGQUIT} signal (MS-Windows)
@cindex signals, @code{QUIT}/@code{SIGQUIT} (MS-Windows)
-When @command{pgawk} runs on MS-Windows systems, it uses the
+When @command{gawk} runs on MS-Windows systems, it uses the
@code{INT} and @code{QUIT} signals for producing the profile and, in
-the case of the @code{INT} signal, @command{pgawk} exits. This is
+the case of the @code{INT} signal, @command{gawk} exits. This is
because these systems don't support the @command{kill} command, so the
only signals you can deliver to a program are those generated by the
keyboard. The @code{INT} signal is generated by the
@kbd{@value{CTL}-@key{C}} or @kbd{@value{CTL}-@key{BREAK}} key, while the
@code{QUIT} signal is generated by the @kbd{@value{CTL}-@key{\}} key.
-Finally, regular @command{gawk} also accepts the @option{--profile} option.
+Finally, @command{gawk} also accepts another option @option{--pretty-print}.
When called this way, @command{gawk} ``pretty prints'' the program into
@file{awkprof.out}, without any execution counts.
@c ENDOFRANGE advgaw
@c ENDOFRANGE gawadv
-@c ENDOFRANGE pgawk
@c ENDOFRANGE awkp
@c ENDOFRANGE proawk
@@ -19539,7 +19882,7 @@ programming use.
* Ordinal Functions:: Functions for using characters as numbers and
vice versa.
* Join Function:: A function to join an array into a string.
-* Gettimeofday Function:: A function to get formatted times.
+* Getlocaltime Function:: A function to get formatted times.
@end menu
@node Strtonum Function
@@ -20064,7 +20407,7 @@ be nice if @command{awk} had an assignment operator for concatenation.
The lack of an explicit operator for concatenation makes string operations
more difficult than they really need to be.}
-@node Gettimeofday Function
+@node Getlocaltime Function
@subsection Managing the Time of Day
@cindex libraries of @command{awk} functions, managing, time
@@ -20078,14 +20421,14 @@ in human readable form. While @code{strftime()} is extensive, the control
formats are not necessarily easy to remember or intuitively obvious when
reading a program.
-The following function, @code{gettimeofday()}, populates a user-supplied array
+The following function, @code{getlocaltime()}, populates a user-supplied array
with preformatted time information. It returns a string with the current
time formatted in the same way as the @command{date} utility:
-@cindex @code{gettimeofday()} user-defined function
+@cindex @code{getlocaltime()} user-defined function
@example
@c file eg/lib/gettime.awk
-# gettimeofday.awk --- get the time of day in a usable format
+# getlocaltime.awk --- get the time of day in a usable format
@c endfile
@ignore
@c file eg/lib/gettime.awk
@@ -20118,7 +20461,7 @@ time formatted in the same way as the @command{date} utility:
# time["weeknum"] -- week number, Sunday first day
# time["altweeknum"] -- week number, Monday first day
-function gettimeofday(time, ret, now, i)
+function getlocaltime(time, ret, now, i)
@{
# get time once, avoids unnecessary system calls
now = systime()
@@ -20160,7 +20503,7 @@ The string indices are easier to use and read than the various formats
required by @code{strftime()}. The @code{alarm} program presented in
@ref{Alarm Program},
uses this function.
-A more general design for the @code{gettimeofday()} function would have
+A more general design for the @code{getlocaltime()} function would have
allowed the user to supply an optional timestamp value to use instead
of the current time.
@@ -23452,8 +23795,8 @@ it prints the message on the standard output. In addition, you can give it
the number of times to repeat the message as well as a delay between
repetitions.
-This program uses the @code{gettimeofday()} function from
-@ref{Gettimeofday Function}.
+This program uses the @code{getlocaltime()} function from
+@ref{Getlocaltime Function}.
All the work is done in the @code{BEGIN} rule. The first part is argument
checking and setting of defaults: the delay, the count, and the message to
@@ -23472,7 +23815,7 @@ Here is the program:
@c file eg/prog/alarm.awk
# alarm.awk --- set an alarm
#
-# Requires gettimeofday() library function
+# Requires getlocaltime() library function
@c endfile
@ignore
@c file eg/prog/alarm.awk
@@ -23544,7 +23887,7 @@ is how long to wait before setting off the alarm:
minute = atime[2] + 0 # force numeric
# get current broken down time
- gettimeofday(now)
+ getlocaltime(now)
# if time given is 12-hour hours and it's after that
# hour, e.g., `alarm 5:30' at 9 a.m. means 5:30 p.m.,
@@ -25215,41 +25558,41 @@ BEGIN {
@c FIXME: Add more indexing.
@node Debugger
-@chapter @command{dgawk}: The @command{awk} Debugger
-@cindex @command{dgawk}
+@chapter Debugging @command{awk} Programs
+@cindex debugging @command{awk} programs
It would be nice if computer programs worked perfectly the first time they
were run, but in real life, this rarely happens for programs of
any complexity. Thus, most programming languages have facilities available
for ``debugging'' programs, and now @command{awk} is no exception.
-The @command{dgawk} debugger is purposely modeled after
+The @command{gawk} debugger is purposely modeled after
@uref{http://www.gnu.org/software/gdb/, the GNU Debugger (GDB)}
command-line debugger. If you are familiar with GDB, learning
-@command{dgawk} is easy.
+how to use @command{gawk} for debugging your program is easy.
@menu
-* Debugging:: Introduction to @command{dgawk}.
-* Sample dgawk session:: Sample @command{dgawk} session.
-* List of Debugger Commands:: Main @command{dgawk} Commands.
-* Readline Support:: Readline Support.
-* Dgawk Limitations:: Limitations and future plans.
+* Debugging:: Introduction to @command{gawk} debugger.
+* Sample Debugging Session:: Sample debugging session.
+* List of Debugger Commands:: Main debugger commands.
+* Readline Support:: Readline support.
+* Limitations:: Limitations and future plans.
@end menu
@node Debugging
-@section Introduction to @command{dgawk}
+@section Introduction to @command{gawk} Debugger
This @value{SECTION} introduces debugging in general and begins
the discussion of debugging in @command{gawk}.
@menu
-* Debugging Concepts:: Debugging In General.
+* Debugging Concepts:: Debugging in General.
* Debugging Terms:: Additional Debugging Concepts.
* Awk Debugging:: Awk Debugging.
@end menu
@node Debugging Concepts
-@subsection Debugging In General
+@subsection Debugging in General
(If you have used debuggers in other languages, you may want to skip
ahead to the next section on the specific features of the @command{awk}
@@ -25295,8 +25638,7 @@ functional program that you or someone else wrote).
@subsection Additional Debugging Concepts
Before diving in to the details, we need to introduce several
-important concepts that apply to just about all debuggers, including
-@command{dgawk}.
+important concepts that apply to just about all debuggers.
The following list defines terms used throughout the rest of
this @value{CHAPTER}.
@@ -25315,7 +25657,7 @@ that contains the function's parameters, local variables, and return value,
as well as any other ``bookkeeping'' information needed to manage the
call stack. This data area is termed a @dfn{stack frame}.
-@command{gawk} also follows this model, and @command{dgawk} gives you
+@command{gawk} also follows this model, and gives you
access to the call stack and to each stack frame. You can see the
call stack, as well as from where each function on the stack was
invoked. Commands that print the call stack print information about
@@ -25360,48 +25702,48 @@ each line of @command{awk} code. The debugger provides the opportunity
to look at the individual primitive instructions carried out
by the higher-level @command{awk} commands.
-@node Sample dgawk session
-@section Sample @command{dgawk} session
+@node Sample Debugging Session
+@section Sample Debugging Session
-In order to illustrate the use of @command{dgawk}, let's look at a sample
+In order to illustrate the use of @command{gawk} as a debugger, let's look at a sample
debugging session. We will use the @command{awk} implementation of the
POSIX @command{uniq} command described earlier (@pxref{Uniq Program})
as our example.
@menu
-* dgawk invocation:: @command{dgawk} Invocation.
-* Finding The Bug:: Finding The Bug.
+* Debugger Invocation:: How to Start the Debugger.
+* Finding The Bug:: Finding the Bug.
@end menu
-@node dgawk invocation
-@subsection @command{dgawk} Invocation
+@node Debugger Invocation
+@subsection How to Start the Debugger
-Starting @command{dgawk} is exactly like running @command{awk}. The
-file(s) containing the program and any supporting code are given on the
-command line as arguments to one or more @option{-f} options.
-(@command{dgawk} is not designed to debug command-line
-programs, only programs contained in files.) In our case,
-we call @command{dgawk} like this:
+Starting the debugger is almost exactly like running @command{awk}, except you have to
+pass an additional option @option{--debug} or the corresponding short option @option{-D}.
+The file(s) containing the program and any supporting code are given on the command
+line as arguments to one or more @option{-f} options. (@command{gawk} is not designed
+to debug command-line programs, only programs contained in files.) In our case,
+we invoke the debugger like this:
@example
-$ @kbd{dgawk -f getopt.awk -f join.awk -f uniq.awk inputfile}
+$ @kbd{gawk -D -f getopt.awk -f join.awk -f uniq.awk inputfile}
@end example
@noindent
where both @file{getopt.awk} and @file{uniq.awk} are in @env{$AWKPATH}.
(Experienced users of GDB or similar debuggers should note that
this syntax is slightly different from what they are used to.
-With @command{dgawk}, the arguments for running the program are given
+With @command{gawk} debugger, the arguments for running the program are given
in the command line to the debugger rather than as part of the @code{run}
command at the debugger prompt.)
Instead of immediately running the program on @file{inputfile}, as
-@command{gawk} would ordinarily do, @command{dgawk} merely loads all
+@command{gawk} would ordinarily do, the debugger merely loads all
the program source files, compiles them internally, and then gives
us a prompt:
@example
-dgawk>
+gawk>
@end example
@noindent
@@ -25409,7 +25751,7 @@ from which we can issue commands to the debugger. At this point, no
code has been executed.
@node Finding The Bug
-@subsection Finding The Bug
+@subsection Finding the Bug
Let's say that we are having a problem using (a faulty version of)
@file{uniq.awk} in the ``field-skipping'' mode, and it doesn't seem to be
@@ -25445,7 +25787,7 @@ a breakpoint in @file{uniq.awk} is at the beginning of the function
the breakpoint, use the @code{b} (breakpoint) command:
@example
-dgawk> @kbd{b are_equal}
+gawk> @kbd{b are_equal}
@print{} Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 64
@end example
@@ -25454,22 +25796,22 @@ Now type @samp{r} or @samp{run} and the program runs until it hits
the breakpoint for the first time:
@example
-dgawk> @kbd{r}
+gawk> @kbd{r}
@print{} Starting program:
@print{} Stopping in Rule ...
@print{} Breakpoint 1, are_equal(n, m, clast, cline, alast, aline)
at `awklib/eg/prog/uniq.awk':64
@print{} 64 if (fcount == 0 && charcount == 0)
-dgawk>
+gawk>
@end example
Now we can look at what's going on inside our program. First of all,
let's see how we got to where we are. At the prompt, we type @samp{bt}
-(short for ``backtrace''), and @command{dgawk} responds with a
+(short for ``backtrace''), and the debugger responds with a
listing of the current stack frames:
@example
-dgawk> @kbd{bt}
+gawk> @kbd{bt}
@print{} #0 are_equal(n, m, clast, cline, alast, aline)
at `awklib/eg/prog/uniq.awk':69
@print{} #1 in main() at `awklib/eg/prog/uniq.awk':89
@@ -25484,11 +25826,11 @@ the key to finding the source of the problem.)
Now that we're in @code{are_equal()}, we can start looking at the values
of some variables. Let's say we type @samp{p n}
(@code{p} is short for ``print''). We would expect to see the value of
-@code{n}, a parameter to @code{are_equal()}. Actually, @command{dgawk}
+@code{n}, a parameter to @code{are_equal()}. Actually, the debugger
gives us:
@example
-dgawk> @kbd{p n}
+gawk> @kbd{p n}
@print{} n = untyped variable
@end example
@@ -25499,7 +25841,7 @@ function was called without arguments (@pxref{Function Calls}).
A more useful variable to display might be the current record:
@example
-dgawk> @kbd{p $0}
+gawk> @kbd{p $0}
@print{} $0 = string ("gawk is a wonderful program!")
@end example
@@ -25508,7 +25850,7 @@ This might be a bit puzzling at first since this is the second line of
our test input above. Let's look at @code{NR}:
@example
-dgawk> @kbd{p NR}
+gawk> @kbd{p NR}
@print{} NR = number (2)
@end example
@@ -25527,7 +25869,7 @@ NR == 1 @{
OK, let's just check that that rule worked correctly:
@example
-dgawk> @kbd{p last}
+gawk> @kbd{p last}
@print{} last = string ("awk is a wonderful program!")
@end example
@@ -25538,7 +25880,7 @@ be inside this function. To investigate further, we must begin
@samp{n} (for ``next''):
@example
-dgawk> @kbd{n}
+gawk> @kbd{n}
@print{} 67 if (fcount > 0) @{
@end example
@@ -25558,9 +25900,9 @@ Continuing to step, we now get to the splitting of the current and
last records:
@example
-dgawk> @kbd{n}
+gawk> @kbd{n}
@print{} 68 n = split(last, alast)
-dgawk> @kbd{n}
+gawk> @kbd{n}
@print{} 69 m = split($0, aline)
@end example
@@ -25568,7 +25910,7 @@ At this point, we should be curious to see what our records were split
into, so we try to look:
@example
-dgawk> @kbd{p n m alast aline}
+gawk> @kbd{p n m alast aline}
@print{} n = number (5)
@print{} m = number (5)
@print{} alast = array, 5 elements
@@ -25587,7 +25929,7 @@ inside the array?
The first choice would be to use subscripts:
@example
-dgawk> @kbd{p alast[0]}
+gawk> @kbd{p alast[0]}
@print{} "0" not in array `alast'
@end example
@@ -25595,16 +25937,16 @@ dgawk> @kbd{p alast[0]}
Oops!
@example
-dgawk> @kbd{p alast[1]}
+gawk> @kbd{p alast[1]}
@print{} alast["1"] = string ("awk")
@end example
This would be kind of slow for a 100-member array, though, so
-@command{dgawk} provides a shortcut (reminiscent of another language
+@command{gawk} provides a shortcut (reminiscent of another language
not to be mentioned):
@example
-dgawk> @kbd{p @@alast}
+gawk> @kbd{p @@alast}
@print{} alast["1"] = string ("awk")
@print{} alast["2"] = string ("is")
@print{} alast["3"] = string ("a")
@@ -25616,9 +25958,9 @@ It looks like we got this far OK. Let's take another step
or two:
@example
-dgawk> @kbd{n}
+gawk> @kbd{n}
@print{} 70 clast = join(alast, fcount, n)
-dgawk> @kbd{n}
+gawk> @kbd{n}
@print{} 71 cline = join(aline, fcount, m)
@end example
@@ -25628,7 +25970,7 @@ the virtual record to compare, and if the first field was numbered zero,
this would work. Let's look at what we've got:
@example
-dgawk> @kbd{p cline clast}
+gawk> @kbd{p cline clast}
@print{} cline = string ("gawk is a wonderful program!")
@print{} clast = string ("awk is a wonderful program!")
@end example
@@ -25637,10 +25979,10 @@ Hey, those look pretty familiar! They're just our original, unaltered,
input records. A little thinking (the human brain is still the best
debugging tool), and we realize that we were off by one!
-We get out of @command{dgawk}:
+We get out of the debugger:
@example
-dgawk> @kbd{q}
+gawk> @kbd{q}
@print{} The program is running. Exit anyway (y/n)? @kbd{y}
@end example
@@ -25656,9 +25998,9 @@ cline = join(aline, fcount+1, m)
and problem solved!
@node List of Debugger Commands
-@section Main @command{dgawk} Commands
+@section Main Debugger Commands
-The @command{dgawk} command set can be divided into the
+The @command{gawk} debugger command set can be divided into the
following categories:
@itemize @bullet{}
@@ -25685,24 +26027,24 @@ Miscellaneous
Each of these are discussed in the following subsections.
In the following descriptions, commands which may be abbreviated
show the abbreviation on a second description line.
-A @command{dgawk} command name may also be truncated if that partial
-name is unambiguous. @command{dgawk} has the built-in capability to
+A debugger command name may also be truncated if that partial
+name is unambiguous. The debugger has the built-in capability to
automatically repeat the previous command when just hitting @key{Enter}.
This works for the commands @code{list}, @code{next}, @code{nexti}, @code{step}, @code{stepi}
and @code{continue} executed without any argument.
@menu
-* Breakpoint Control:: Control of breakpoints.
-* Dgawk Execution Control:: Control of execution.
-* Viewing And Changing Data:: Viewing and changing data.
-* Dgawk Stack:: Dealing with the stack.
-* Dgawk Info:: Obtaining information about the program and
- the debugger state.
-* Miscellaneous Dgawk Commands:: Miscellaneous Commands.
+* Breakpoint Control:: Control of Breakpoints.
+* Debugger Execution Control:: Control of Execution.
+* Viewing And Changing Data:: Viewing and Changing Data.
+* Execution Stack:: Dealing with the Stack.
+* Debugger Info:: Obtaining Information about the Program and
+ the Debugger State.
+* Miscellaneous Debugger Commands:: Miscellaneous Commands.
@end menu
@node Breakpoint Control
-@subsection Control Of Breakpoints
+@subsection Control of Breakpoints
As we saw above, the first thing you probably want to do in a debugging
session is to get your breakpoints set up, since otherwise your program
@@ -25737,10 +26079,10 @@ Each breakpoint is assigned a number which can be used to delete it from
the breakpoint list using the @code{delete} command.
With a breakpoint, you may also supply a condition. This is an
-@command{awk} expression (enclosed in double quotes) that @command{dgawk}
+@command{awk} expression (enclosed in double quotes) that the debugger
evaluates whenever the breakpoint is reached. If the condition is true,
-then @command{dgawk} stops execution and prompts for a command. Otherwise,
-@command{dgawk} continues executing the program.
+then the debugger stops execution and prompts for a command. Otherwise,
+it continues executing the program.
@cindex debugger commands, @code{clear}
@cindex @code{clear} debugger command
@@ -25766,10 +26108,10 @@ Delete breakpoint(s) set at entry to function @var{function}.
@cindex @code{condition} debugger command
@item @code{condition} @var{n} @code{"@var{expression}"}
Add a condition to existing breakpoint or watchpoint @var{n}. The
-condition is an @command{awk} expression that @command{dgawk} evaluates
+condition is an @command{awk} expression that the debugger evaluates
whenever the breakpoint or watchpoint is reached. If the condition is true, then
-@command{dgawk} stops execution and prompts for a command. Otherwise,
-@command{dgawk} continues executing the program. If the condition expression is
+the debugger stops execution and prompts for a command. Otherwise,
+the debugger continues executing the program. If the condition expression is
not specified, any existing condition is removed; i.e., the breakpoint or
watchpoint is made unconditional.
@@ -25825,7 +26167,7 @@ Set a temporary breakpoint (enabled for only one stop).
The arguments are the same as for @code{break}.
@end table
-@node Dgawk Execution Control
+@node Debugger Execution Control
@subsection Control of Execution
Now that your breakpoints are ready, you can start running the program
@@ -25854,14 +26196,14 @@ in the list that resumes execution (e.g., @code{continue}) terminates the list
For example:
@example
-dgawk> @kbd{commands}
+gawk> @kbd{commands}
> @kbd{silent}
> @kbd{printf "A silent breakpoint; i = %d\n", i}
> @kbd{info locals}
> @kbd{set i = 10}
> @kbd{continue}
> @kbd{end}
-dgawk>
+gawk>
@end example
@cindex debugger commands, @code{c} (@code{continue})
@@ -25911,7 +26253,7 @@ and the caller of that frame becomes the innermost frame.
@cindex @code{r} debugger command (alias for @code{run})
@item @code{run}
@itemx @code{r}
-Start/restart execution of the program. When restarting, @command{dgawk}
+Start/restart execution of the program. When restarting, the debugger
retains the current breakpoints, watchpoints, command history,
automatic display variables, and debugger options.
@@ -25934,7 +26276,7 @@ stopping, unless it encounters a breakpoint or watchpoint.
@itemx @code{si} [@var{count}]
Execute one (or @var{count}) instruction(s), stepping inside function calls.
(For illustration of what is meant by an ``instruction'' in @command{gawk},
-see the output shown under @code{dump} in @ref{Miscellaneous Dgawk Commands}.)
+see the output shown under @code{dump} in @ref{Miscellaneous Debugger Commands}.)
@cindex debugger commands, @code{u} (@code{until})
@cindex debugger commands, @code{until}
@@ -25962,7 +26304,7 @@ The value of the variable or field is displayed each time the program stops.
Each variable added to the list is identified by a unique number:
@example
-dgawk> @kbd{display x}
+gawk> @kbd{display x}
@print{} 10: x = 1
@end example
@@ -25999,7 +26341,7 @@ Print the value of a @command{gawk} variable or field.
Fields must be referenced by constants:
@example
-dgawk> @kbd{print $3}
+gawk> @kbd{print $3}
@end example
@noindent
@@ -26041,16 +26383,16 @@ You can also set special @command{awk} variables, such as @code{FS},
@item @code{watch} @var{var} | @code{$}@var{n} [@code{"@var{expression}"}]
@itemx @code{w} @var{var} | @code{$}@var{n} [@code{"@var{expression}"}]
Add variable @var{var} (or field @code{$@var{n}}) to the watch list.
-@command{dgawk} then stops whenever
+The debugger then stops whenever
the value of the variable or field changes. Each watched item is assigned a
number which can be used to delete it from the watch list using the
@code{unwatch} command.
With a watchpoint, you may also supply a condition. This is an
-@command{awk} expression (enclosed in double quotes) that @command{dgawk}
+@command{awk} expression (enclosed in double quotes) that the debugger
evaluates whenever the watchpoint is reached. If the condition is true,
-then @command{dgawk} stops execution and prompts for a command. Otherwise,
-@command{dgawk} continues executing the program.
+then the debugger stops execution and prompts for a command. Otherwise,
+@command{gawk} continues executing the program.
@cindex debugger commands, @code{undisplay}
@cindex @code{undisplay} debugger command
@@ -26066,8 +26408,8 @@ watch list.
@end table
-@node Dgawk Stack
-@subsection Dealing With The Stack
+@node Execution Stack
+@subsection Dealing with the Stack
Whenever you run a program which contains any function calls,
@command{gawk} maintains a stack of all of the function calls leading up
@@ -26111,12 +26453,12 @@ Move @var{count} (default 1) frames up the stack toward the outermost frame.
Then select and print the frame.
@end table
-@node Dgawk Info
-@subsection Obtaining Information About The Program and The Debugger State
+@node Debugger Info
+@subsection Obtaining Information about the Program and the Debugger State
Besides looking at the values of variables, there is often a need to get
other sorts of information about the state of your program and of the
-debugging environment itself. @command{dgawk} has one command which
+debugging environment itself. The @command{gawk} debugger has one command which
provides this information, appropriately called @code{info}. @code{info}
is used with one of a number of arguments that tell it exactly what
you want to know:
@@ -26154,7 +26496,7 @@ Local variables of the selected frame.
@item source
The name of the current source file. Each time the program stops, the
current source file is the file containing the current instruction.
-When @command{dgawk} first starts, the current source file is the first file
+When the debugger first starts, the current source file is the first file
included via the @option{-f} option. The
@samp{list @var{filename}:@var{lineno}} command can
be used at any time to change the current source.
@@ -26190,7 +26532,7 @@ The available options are:
@c nested table
@table @code
@item history_size
-The maximum number of lines to keep in the history file @file{./.dgawk_history}.
+The maximum number of lines to keep in the history file @file{./.gawk_history}.
The default is 100.
@item listsize
@@ -26202,14 +26544,14 @@ to standard output. An empty string (@code{""}) resets output to
standard output.
@item prompt
-The debugger prompt. The default is @samp{@w{dgawk> }}.
+The debugger prompt. The default is @samp{@w{gawk> }}.
@item save_history @r{[}on @r{|} off@r{]}
-Save command history to file @file{./.dgawk_history}.
+Save command history to file @file{./.gawk_history}.
The default is @code{on}.
@item save_options @r{[}on @r{|} off@r{]}
-Save current options to file @file{./.dgawkrc} upon exit.
+Save current options to file @file{./.gawkrc} upon exit.
The default is @code{on}.
Options are read back in to the next session upon startup.
@@ -26229,16 +26571,16 @@ Empty lines are ignored; they do @emph{not}
repeat the last command.
You can't restart the program by having more than one @code{run}
command in the file. Also, the list of commands may include additional
-@code{source} commands; however, @command{dgawk} will not source the
+@code{source} commands; however, the @command{gawk} debugger will not source the
same file more than once in order to avoid infinite recursion.
In addition to, or instead of the @code{source} command, you can use
-the @option{-R @var{file}} or @option{--command=@var{file}} command-line
+the @option{-D @var{file}} or @option{--debug=@var{file}} command-line
options to execute commands from a file non-interactively
(@pxref{Options}.
@end table
-@node Miscellaneous Dgawk Commands
+@node Miscellaneous Debugger Commands
@subsection Miscellaneous Commands
There are a few more commands which do not fit into the
@@ -26256,7 +26598,7 @@ partial dump of Davide Brini's obfuscated code
(@pxref{Signature Program}) demonstrates:
@smallexample
-dgawk> @kbd{dump}
+gawk> @kbd{dump}
@print{} # BEGIN
@print{}
@print{} [ 2:0x89faef4] Op_rule : [in_rule = BEGIN] [source_file = brini.awk]
@@ -26305,7 +26647,7 @@ dgawk> @kbd{dump}
@print{} [ :0x89fa3b0] Op_after_beginfile :
@print{} [ :0x89fa388] Op_no_op :
@print{} [ :0x89fa3c4] Op_after_endfile :
-dgawk>
+gawk>
@end smallexample
@cindex debugger commands, @code{h} (@code{help})
@@ -26314,7 +26656,7 @@ dgawk>
@cindex @code{h} debugger command (alias for @code{help})
@item @code{help}
@itemx @code{h}
-Print a list of all of the @command{dgawk} commands with a short
+Print a list of all of the @command{gawk} debugger commands with a short
summary of their usage. @samp{help @var{command}} prints the information
about the command @var{command}.
@@ -26361,7 +26703,7 @@ function @var{function}. This command may change the current source file.
Exit the debugger. Debugging is great fun, but sometimes we all have
to tend to other obligations in life, and sometimes we find the bug,
and are free to go on to the next one! As we saw above, if you are
-running a program, @command{dgawk} warns you if you accidentally type
+running a program, the debugger warns you if you accidentally type
@samp{q} or @samp{quit}, to make sure you really want to quit.
@cindex debugger commands, @code{trace}
@@ -26380,7 +26722,7 @@ fairly self-explanatory, and using @code{stepi} and @code{nexti} while
@node Readline Support
@section Readline Support
-If @command{dgawk} is compiled with the @code{readline} library, you
+If @command{gawk} is compiled with the @code{readline} library, you
can take advantage of that library's command completion and history expansion
features. The following types of completion are available:
@@ -26412,28 +26754,28 @@ and
@end table
-@node Dgawk Limitations
+@node Limitations
@section Limitations and Future Plans
-We hope you find @command{dgawk} useful and enjoyable to work with,
+We hope you find the @command{gawk} debugger useful and enjoyable to work with,
but as with any program, especially in its early releases, it still has
some limitations. A few which are worth being aware of are:
@itemize @bullet{}
@item
-At this point, @command{dgawk} does not give a detailed explanation of
+At this point, the debugger does not give a detailed explanation of
what you did wrong when you type in something it doesn't like. Rather, it just
responds @samp{syntax error}. When you do figure out what your mistake was,
though, you'll feel like a real guru.
@item
-If you perused the dump of opcodes in @ref{Miscellaneous Dgawk Commands},
+If you perused the dump of opcodes in @ref{Miscellaneous Debugger Commands},
(or if you are already familiar with @command{gawk} internals),
you will realize that much of the internal manipulation of data
in @command{gawk}, as in many interpreters, is done on a stack.
@code{Op_push}, @code{Op_pop}, etc., are the ``bread and butter'' of
-most @command{gawk} code. Unfortunately, as of now, @command{dgawk}
-does not allow you to examine the stack's contents.
+most @command{gawk} code. Unfortunately, as of now, the @command{gawk}
+debugger does not allow you to examine the stack's contents.
That is, the intermediate results of expression evaluation are on the
stack, but cannot be printed. Rather, only variables which are defined
@@ -26448,19 +26790,1702 @@ programmer, you are expected to know what @code{/[^[:alnum:][:blank:]]/}
means.
@item
-@command{dgawk} is designed to be used by running a program (with all its
-parameters) on the command line, as described in @ref{dgawk invocation}.
+The @command{gawk} debugger is designed to be used by running a program (with all its
+parameters) on the command line, as described in @ref{Debugger Invocation}.
There is no way (as of now) to attach or ``break in'' to a running program.
This seems reasonable for a language which is used mainly for quickly
executing, short programs.
@item
-@command{dgawk} only accepts source supplied with the @option{-f} option.
+The @command{gawk} debugger only accepts source supplied with the @option{-f} option.
@end itemize
Look forward to a future release when these and other missing features may
be added, and of course feel free to try to add them yourself!
+@node Arbitrary Precision Arithmetic
+@chapter Arithmetic and Arbitrary Precision Arithmetic with @command{gawk}
+@cindex arbitrary precision
+@cindex multiple precision
+@cindex infinite precision
+@cindex floating-point numbers, arbitrary precision
+@cindex MPFR
+@cindex GMP
+
+@cindex Knuth, Donald
+@quotation
+@i{There's a credibility gap: We don't know how much of the computer's answers
+to believe. Novice computer users solve this problem by implicitly trusting
+in the computer as an infallible authority; they tend to believe that all
+digits of a printed answer are significant. Disillusioned computer users have
+just the opposite approach; they are constantly afraid that their answers
+are almost meaningless.}@*
+Donald Knuth@footnote{Donald E.@: Knuth.
+@cite{The Art of Computer Programming}. Volume 2,
+@cite{Seminumerical Algorithms}, third edition,
+1998, ISBN 0-201-89683-4, p.@: 229.}
+@end quotation
+
+This @value{CHAPTER} discusses issues that you may encounter
+when performing arithmetic. It begins by discussing some of
+the general attributes of computer arithmetic, along with how
+this can influence what you see when running @command{awk} programs.
+This discussion applies to all versions of @command{awk}.
+
+Then the @value{CHAPTER} moves on to @dfn{arbitrary precision
+arithmetic}, a feature which is specific to @command{gawk}.
+
+@menu
+* General Arithmetic:: An introduction to computer arithmetic.
+* Floating-point Programming:: Effective Floating-point Programming.
+* Gawk and MPFR:: How @command{gawk} provides
+ arbitrary-precision arithmetic.
+* Arbitrary Precision Floats:: Arbitrary Precision Floating-point Arithmetic
+ with @command{gawk}.
+* Arbitrary Precision Integers:: Arbitrary Precision Integer Arithmetic with
+ @command{gawk}.
+@end menu
+
+@node General Arithmetic
+@section A General Description of Computer Arithmetic
+
+@cindex integers
+@cindex floating-point, numbers
+@cindex numbers, floating-point
+Within computers, there are two kinds of numeric values: @dfn{integers}
+and @dfn{floating-point}.
+In school, integer values were referred to as ``whole'' numbers---that is,
+numbers without any fractional part, such as 1, 42, or @minus{}17.
+The advantage to integer numbers is that they represent values exactly.
+The disadvantage is that their range is limited. On most systems,
+this range is @minus{}2,147,483,648 to 2,147,483,647.
+However, many systems now support a range from
+@minus{}9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
+
+@cindex unsigned integers
+@cindex integers, unsigned
+Integer values come in two flavors: @dfn{signed} and @dfn{unsigned}.
+Signed values may be negative or positive, with the range of values just
+described.
+Unsigned values are always positive. On most systems,
+the range is from 0 to 4,294,967,295.
+However, many systems now support a range from
+0 to 18,446,744,073,709,551,615.
+
+@cindex double precision floating-point
+@cindex single precision floating-point
+Floating-point numbers represent what are called ``real'' numbers; i.e.,
+those that do have a fractional part, such as 3.1415927.
+The advantage to floating-point numbers is that they
+can represent a much larger range of values.
+The disadvantage is that there are numbers that they cannot represent
+exactly.
+@command{awk} uses @dfn{double precision} floating-point numbers, which
+can hold more digits than @dfn{single precision}
+floating-point numbers.
+@c Floating-point issues are discussed more fully in
+@c @ref{Floating Point Issues}.
+
+There a several important issues to be aware of, described next.
+
+@menu
+* Floating Point Issues:: Stuff to know about floating-point numbers.
+* Integer Programming:: Effective integer programming.
+@end menu
+
+@node Floating Point Issues
+@subsection Floating-Point Number Caveats
+
+This @value{SECTION} describes some of the issues
+involved in using floating-point numbers.
+
+There is a very nice
+@uref{http://www.validlab.com/goldberg/paper.pdf, paper on floating-point arithmetic}
+by David Goldberg,
+``What Every Computer Scientist Should Know About Floating-point Arithmetic,''
+@cite{ACM Computing Surveys} @strong{23}, 1 (1991-03), 5-48.
+This is worth reading if you are interested in the details,
+but it does require a background in computer science.
+
+@menu
+* String Conversion Precision:: The String Value Can Lie.
+* Unexpected Results:: Floating Point Numbers Are Not Abstract
+ Numbers.
+* POSIX Floating Point Problems:: Standards Versus Existing Practice.
+@end menu
+
+@node String Conversion Precision
+@subsubsection The String Value Can Lie
+
+Internally, @command{awk} keeps both the numeric value
+(double precision floating-point) and the string value for a variable.
+Separately, @command{awk} keeps
+track of what type the variable has
+(@pxref{Typing and Comparison}),
+which plays a role in how variables are used in comparisons.
+
+It is important to note that the string value for a number may not
+reflect the full value (all the digits) that the numeric value
+actually contains.
+The following program (@file{values.awk}) illustrates this:
+
+@example
+@{
+ sum = $1 + $2
+ # see it for what it is
+ printf("sum = %.12g\n", sum)
+ # use CONVFMT
+ a = "<" sum ">"
+ print "a =", a
+ # use OFMT
+ print "sum =", sum
+@}
+@end example
+
+@noindent
+This program shows the full value of the sum of @code{$1} and @code{$2}
+using @code{printf}, and then prints the string values obtained
+from both automatic conversion (via @code{CONVFMT}) and
+from printing (via @code{OFMT}).
+
+Here is what happens when the program is run:
+
+@example
+$ @kbd{echo 3.654321 1.2345678 | awk -f values.awk}
+@print{} sum = 4.8888888
+@print{} a = <4.88889>
+@print{} sum = 4.88889
+@end example
+
+This makes it clear that the full numeric value is different from
+what the default string representations show.
+
+@code{CONVFMT}'s default value is @code{"%.6g"}, which yields a value with
+at least six significant digits. For some applications, you might want to
+change it to specify more precision.
+On most modern machines, most of the time,
+17 digits is enough to capture a floating-point number's
+value exactly.@footnote{Pathological cases can require up to
+752 digits (!), but we doubt that you need to worry about this.}
+
+@node Unexpected Results
+@subsubsection Floating Point Numbers Are Not Abstract Numbers
+
+@cindex floating-point, numbers
+Unlike numbers in the abstract sense (such as what you studied in high school
+or college arithmetic), numbers stored in computers are limited in certain ways.
+They cannot represent an infinite number of digits, nor can they always
+represent things exactly.
+In particular,
+floating-point numbers cannot
+always represent values exactly. Here is an example:
+
+@example
+$ @kbd{awk '@{ printf("%010d\n", $1 * 100) @}'}
+515.79
+@print{} 0000051579
+515.80
+@print{} 0000051579
+515.81
+@print{} 0000051580
+515.82
+@print{} 0000051582
+@kbd{@value{CTL}-d}
+@end example
+
+@noindent
+This shows that some values can be represented exactly,
+whereas others are only approximated. This is not a ``bug''
+in @command{awk}, but simply an artifact of how computers
+represent numbers.
+
+@quotation NOTE
+It cannot be emphasized enough that the behavior just
+described is fundamental to modern computers. You will
+see this kind of thing happen in @emph{any} programming
+language using hardware floating-point numbers. It is @emph{not}
+a bug in @command{gawk}, nor is it something that can be ``just
+fixed.''
+@end quotation
+
+@cindex negative zero
+@cindex positive zero
+@cindex zero@comma{} negative vs.@: positive
+Another peculiarity of floating-point numbers on modern systems
+is that they often have more than one representation for the number zero!
+In particular, it is possible to represent ``minus zero'' as well as
+regular, or ``positive'' zero.
+
+This example shows that negative and positive zero are distinct values
+when stored internally, but that they are in fact equal to each other,
+as well as to ``regular'' zero:
+
+@example
+$ @kbd{gawk 'BEGIN @{ mz = -0 ; pz = 0}
+> @kbd{printf "-0 = %g, +0 = %g, (-0 == +0) -> %d\n", mz, pz, mz == pz}
+> @kbd{printf "mz == 0 -> %d, pz == 0 -> %d\n", mz == 0, pz == 0}
+> @kbd{@}'}
+@print{} -0 = -0, +0 = 0, (-0 == +0) -> 1
+@print{} mz == 0 -> 1, pz == 0 -> 1
+@end example
+
+It helps to keep this in mind should you process numeric data
+that contains negative zero values; the fact that the zero is negative
+is noted and can affect comparisons.
+
+@node POSIX Floating Point Problems
+@subsubsection Standards Versus Existing Practice
+
+Historically, @command{awk} has converted any non-numeric looking string
+to the numeric value zero, when required. Furthermore, the original
+definition of the language and the original POSIX standards specified that
+@command{awk} only understands decimal numbers (base 10), and not octal
+(base 8) or hexadecimal numbers (base 16).
+
+Changes in the language of the
+2001 and 2004 POSIX standards can be interpreted to imply that @command{awk}
+should support additional features. These features are:
+
+@itemize @bullet
+@item
+Interpretation of floating point data values specified in hexadecimal
+notation (@samp{0xDEADBEEF}). (Note: data values, @emph{not}
+source code constants.)
+
+@item
+Support for the special IEEE 754 floating point values ``Not A Number''
+(NaN), positive Infinity (``inf'') and negative Infinity (``@minus{}inf'').
+In particular, the format for these values is as specified by the ISO 1999
+C standard, which ignores case and can allow machine-dependent additional
+characters after the @samp{nan} and allow either @samp{inf} or @samp{infinity}.
+@end itemize
+
+The first problem is that both of these are clear changes to historical
+practice:
+
+@itemize @bullet
+@item
+The @command{gawk} maintainer feels that supporting hexadecimal floating
+point values, in particular, is ugly, and was never intended by the
+original designers to be part of the language.
+
+@item
+Allowing completely alphabetic strings to have valid numeric
+values is also a very severe departure from historical practice.
+@end itemize
+
+The second problem is that the @code{gawk} maintainer feels that this
+interpretation of the standard, which requires a certain amount of
+``language lawyering'' to arrive at in the first place, was not even
+intended by the standard developers. In other words, ``we see how you
+got where you are, but we don't think that that's where you want to be.''
+
+Recognizing the above issues, but attempting to provide compatibility
+with the earlier versions of the standard,
+the 2008 POSIX standard added explicit wording to allow, but not require,
+that @command{awk} support hexadecimal floating point values and
+special values for ``Not A Number'' and infinity.
+
+Although the @command{gawk} maintainer continues to feel that
+providing those features is inadvisable,
+nevertheless, on systems that support IEEE floating point, it seems
+reasonable to provide @emph{some} way to support NaN and Infinity values.
+The solution implemented in @command{gawk} is as follows:
+
+@itemize @bullet
+@item
+With the @option{--posix} command-line option, @command{gawk} becomes
+``hands off.'' String values are passed directly to the system library's
+@code{strtod()} function, and if it successfully returns a numeric value,
+that is what's used.@footnote{You asked for it, you got it.}
+By definition, the results are not portable across
+different systems. They are also a little surprising:
+
+@example
+$ @kbd{echo nanny | gawk --posix '@{ print $1 + 0 @}'}
+@print{} nan
+$ @kbd{echo 0xDeadBeef | gawk --posix '@{ print $1 + 0 @}'}
+@print{} 3735928559
+@end example
+
+@item
+Without @option{--posix}, @command{gawk} interprets the four strings
+@samp{+inf},
+@samp{-inf},
+@samp{+nan},
+and
+@samp{-nan}
+specially, producing the corresponding special numeric values.
+The leading sign acts a signal to @command{gawk} (and the user)
+that the value is really numeric. Hexadecimal floating point is
+not supported (unless you also use @option{--non-decimal-data},
+which is @emph{not} recommended). For example:
+
+@example
+$ @kbd{echo nanny | gawk '@{ print $1 + 0 @}'}
+@print{} 0
+$ @kbd{echo +nan | gawk '@{ print $1 + 0 @}'}
+@print{} nan
+$ @kbd{echo 0xDeadBeef | gawk '@{ print $1 + 0 @}'}
+@print{} 0
+@end example
+
+@command{gawk} does ignore case in the four special values.
+Thus @samp{+nan} and @samp{+NaN} are the same.
+@end itemize
+
+@node Integer Programming
+@subsection Mixing Integers And Floating-point
+
+As has been mentioned already, @command{gawk} ordinarily uses hardware double
+precision with 64-bit IEEE binary floating-point representation
+for numbers on most systems. A large integer like 9,007,199,254,740,997
+has a binary representation that, although finite, is more than 53 bits long;
+it must also be rounded to 53 bits.
+The biggest integer that can be stored in a C @code{double} is usually the same
+as the largest possible value of a @code{double}. If your system @code{double}
+is an IEEE 64-bit @code{double}, this largest possible value is an integer and
+can be represented precisely. What more should one know about integers?
+
+If you want to know what is the largest integer, such that it and
+all smaller integers can be stored in 64-bit doubles without losing precision,
+then the answer is
+@iftex
+@math{2^{53}}.
+@end iftex
+@ifnottex
+2^53.
+@end ifnottex
+The next representable number is the even number
+@iftex
+@math{2^{53} + 2},
+@end iftex
+@ifnottex
+2^53 + 2,
+@end ifnottex
+meaning it is unlikely that you will be able to make
+@command{gawk} print
+@iftex
+@math{2^{53} + 1}
+@end iftex
+@ifnottex
+2^53 + 1
+@end ifnottex
+in integer format.
+The range of integers exactly representable by a 64-bit double
+is
+@iftex
+@math{[-2^{53}, 2^{53}]}.
+@end iftex
+@ifnottex
+[@minus{}2^53, 2^53].
+@end ifnottex
+If you ever see an integer outside this range in @command{gawk}
+using 64-bit doubles, you have reason to be very suspicious about
+the accuracy of the output. Here is a simple program with erroneous output:
+
+@example
+$ @kbd{gawk 'BEGIN @{ i = 2^53 - 1; for (j = 0; j < 4; j++) print i + j @}'}
+@print{} 9007199254740991
+@print{} 9007199254740992
+@print{} 9007199254740992
+@print{} 9007199254740994
+@end example
+
+The lesson is to not assume that any large integer printed by @command{gawk}
+represents an exact result from your computation, especially if it wraps
+around on your screen.
+
+@node Floating-point Programming
+@section Understanding Floating-point Programming
+
+Numerical programming is an extensive area; if you need to develop
+sophisticated numerical algorithms then @command{gawk} may not be
+the ideal tool, and this documentation may not be sufficient.
+@c FIXME: JOHN: Do you want to cite some actual books?
+It might require digesting a book or two to really internalize how to compute
+with ideal accuracy and precision,
+and the result often depends on the particular application.
+
+@quotation NOTE
+A floating-point calculation's @dfn{accuracy} is how close it comes
+to the real value. This is as opposed to the @dfn{precision}, which
+usually refers to the number of bits used to represent the number
+(see @uref{http://en.wikipedia.org/wiki/Accuracy_and_precision,
+the Wikipedia article} for more information).
+@end quotation
+
+There are two options for doing floating-point calculations:
+hardware floating-point (as used by standard @command{awk} and
+the default for @command{gawk}), and @dfn{arbitrary-precision}
+floating-point, which is software based.
+From this point forward, this @value{CHAPTER}
+aims to provide enough information to understand both, and then
+will focus on @command{gawk}'s facilities for the latter.@footnote{If you
+are interested in other tools that perform arbitrary precision arithmetic,
+you may want to investigate the POSIX @command{bc} tool. See
+@uref{http://pubs.opengroup.org/onlinepubs/009695399/utilities/bc.html,
+the POSIX specification for it}, for more information.}
+
+Binary floating-point representations and arithmetic are inexact.
+Simple values like 0.1 cannot be precisely represented using
+binary floating-point numbers, and the limited precision of
+floating-point numbers means that slight changes in
+the order of operations or the precision of intermediate storage
+can change the result. To make matters worse, with arbitrary precision
+floating-point, you can set the precision before starting a computation,
+but then you cannot be sure of the number of significant decimal places
+in the final result.
+
+Sometimes, before you start to write any code, you should think more
+about what you really want and what's really happening. Consider the
+two numbers in the following example:
+
+@example
+x = 0.875 # 1/2 + 1/4 + 1/8
+y = 0.425
+@end example
+
+Unlike the number in @code{y}, the number stored in @code{x}
+is exactly representable
+in binary since it can be written as a finite sum of one or
+more fractions whose denominators are all powers of two.
+When @command{gawk} reads a floating-point number from
+program source, it automatically rounds that number to whatever
+precision your machine supports. If you try to print the numeric
+content of a variable using an output format string of @code{"%.17g"},
+it may not produce the same number as you assigned to it:
+
+@example
+$ @kbd{gawk 'BEGIN @{ x = 0.875; y = 0.425}
+> @kbd{ printf("%0.17g, %0.17g\n", x, y) @}'}
+@print{} 0.875, 0.42499999999999999
+@end example
+
+Often the error is so small you do not even notice it, and if you do,
+you can always specify how much precision you would like in your output.
+Usually this is a format string like @code{"%.15g"}, which when
+used in the previous example, produces an output identical to the input.
+
+Because the underlying representation can be a little bit off from the exact value,
+comparing floating-point values to see if they are equal is generally not a good idea.
+Here is an example where it does not work like you expect:
+
+@example
+$ @kbd{gawk 'BEGIN @{ print (0.1 + 12.2 == 12.3) @}'}
+@print{} 0
+@end example
+
+The loss of accuracy during a single computation with floating-point numbers
+usually isn't enough to worry about. However, if you compute a value
+which is the result of a sequence of floating point operations,
+the error can accumulate and greatly affect the computation itself.
+Here is an attempt to compute the value of the constant
+@value{PI} using one of its many series representations:
+
+@example
+BEGIN @{
+ x = 1.0 / sqrt(3.0)
+ n = 6
+ for (i = 1; i < 30; i++) @{
+ n = n * 2.0
+ x = (sqrt(x * x + 1) - 1) / x
+ printf("%.15f\n", n * x)
+ @}
+@}
+@end example
+
+When run, the early errors propagating through later computations
+cause the loop to terminate prematurely after an attempt to divide by zero.
+
+@example
+$ @kbd{gawk -f pi.awk}
+@print{} 3.215390309173475
+@print{} 3.159659942097510
+@print{} 3.146086215131467
+@print{} 3.142714599645573
+@dots{}
+@print{} 3.224515243534819
+@print{} 2.791117213058638
+@print{} 0.000000000000000
+@error{} gawk: pi.awk:6: fatal: division by zero attempted
+@end example
+
+Here is an additional example where the inaccuracies in internal representations
+yield an unexpected result:
+
+@example
+$ @kbd{gawk 'BEGIN @{}
+> @kbd{for (d = 1.1; d <= 1.5; d += 0.1)}
+> @kbd{i++}
+> @kbd{print i}
+> @kbd{@}'}
+@print{} 4
+@end example
+
+Can computation using arbitrary precision help with the previous examples?
+If you are impatient to know, see
+@ref{Exact Arithmetic}.
+
+Instead of arbitrary precision floating-point arithmetic,
+often all you need is an adjustment of your logic
+or a different order for the operations in your calculation.
+The stability and the accuracy of the computation of the constant @value{PI}
+in the previous example can be enhanced by using the following
+simple algebraic transformation:
+
+@example
+(sqrt(x * x + 1) - 1) / x = x / (sqrt(x * x + 1) + 1)
+@end example
+
+@noindent
+After making this, change the program does converge to
+@value{PI} in under 30 iterations:
+
+@example
+$ @kbd{gawk -f /tmp/pi2.awk}
+@print{} 3.215390309173473
+@print{} 3.159659942097501
+@print{} 3.146086215131436
+@print{} 3.142714599645370
+@print{} 3.141873049979825
+@dots{}
+@print{} 3.141592653589797
+@print{} 3.141592653589797
+@end example
+
+There is no need to be unduly suspicious about the results from
+floating-point arithmetic. The lesson to remember is that
+floating-point arithmetic is always more complex than arithmetic using
+pencil and paper. In order to take advantage of the power
+of computer floating-point, you need to know its limitations
+and work within them. For most casual use of floating-point arithmetic,
+you will often get the expected result in the end if you simply round
+the display of your final results to the correct number of significant
+decimal digits.
+
+As general advice, avoid presenting numerical data in a manner that
+implies better precision than is actually the case.
+
+@menu
+* Floating-point Representation:: Binary floating-point representation.
+* Floating-point Context:: Floating-point context.
+* Rounding Mode:: Floating-point rounding mode.
+@end menu
+
+@node Floating-point Representation
+@subsection Binary Floating-point Representation
+@cindex IEEE-754 format
+
+Although floating-point representations vary from machine to machine,
+the most commonly encountered representation is that defined by the
+IEEE 754 Standard. An IEEE-754 format value has three components:
+
+@itemize @bullet
+@item
+A sign bit telling whether the number is positive or negative.
+
+@item
+An @dfn{exponent}, @var{e}, giving its order of magnitude.
+
+@item
+A @dfn{significand}, @var{s},
+specifying the actual digits of the number.
+@end itemize
+
+The value of the
+number is then
+@iftex
+@math{s @cdot 2^e}.
+@end iftex
+@ifnottex
+@var{s * 2^e}.
+@end ifnottex
+The first bit of a non-zero binary significand
+is always one, so the significand in an IEEE-754 format only includes the
+fractional part, leaving the leading one implicit.
+The significand is stored in @dfn{normalized} format,
+which means that the first bit is always a one.
+
+Three of the standard IEEE-754 types are 32-bit single precision,
+64-bit double precision and 128-bit quadruple precision.
+The standard also specifies extended precision formats
+to allow greater precisions and larger exponent ranges.
+
+@node Floating-point Context
+@subsection Floating-point Context
+@cindex context, floating-point
+
+A floating-point @dfn{context} defines the environment for arithmetic operations.
+It governs precision, sets rules for rounding, and limits the range for exponents.
+The context has the following primary components:
+
+@table @dfn
+@item Precision
+Precision of the floating-point format in bits.
+@item emax
+Maximum exponent allowed for this format.
+@item emin
+Minimum exponent allowed for this format.
+@item Underflow behavior
+The format may or may not support gradual underflow.
+@item Rounding
+The rounding mode of this context.
+@end table
+
+@ref{table-ieee-formats} lists the precision and exponent
+field values for the basic IEEE-754 binary formats:
+
+@float Table,table-ieee-formats
+@caption{Basic IEEE Format Context Values}
+@multitable @columnfractions .20 .20 .20 .20 .20
+@headitem Name @tab Total bits @tab Precision @tab emin @tab emax
+@item Single @tab 32 @tab 24 @tab @minus{}126 @tab +127
+@item Double @tab 64 @tab 53 @tab @minus{}1022 @tab +1023
+@item Quadruple @tab 128 @tab 113 @tab @minus{}16382 @tab +16383
+@end multitable
+@end float
+
+@quotation NOTE
+The precision numbers include the implied leading one that gives them
+one extra bit of significand.
+@end quotation
+
+A floating-point context can also determine which signals are treated
+as exceptions, and can set rules for arithmetic with special values.
+Please consult the IEEE-754 standard or other resources for details.
+
+@command{gawk} ordinarily uses the hardware double precision
+representation for numbers. On most systems, this is IEEE-754
+floating-point format, corresponding to 64-bit binary with 53 bits
+of precision.
+
+@quotation NOTE
+In case an underflow occurs, the standard allows, but does not require,
+the result from an arithmetic operation to be a number smaller than
+the smallest nonzero normalized number. Such numbers do
+not have as many significant digits as normal numbers, and are called
+@dfn{denormals} or @dfn{subnormals}. The alternative, simply returning a zero,
+is called @dfn{flush to zero}. The basic IEEE-754 binary formats
+support subnormal numbers.
+@end quotation
+
+@node Rounding Mode
+@subsection Floating-point Rounding Mode
+@cindex rounding mode, floating-point
+
+The @dfn{rounding mode} specifies the behavior for the results of numerical
+operations when discarding extra precision. Each rounding mode indicates
+how the least significant returned digit of a rounded result is to
+be calculated.
+@ref{table-rounding-modes} lists the IEEE-754 defined
+rounding modes:
+
+@float Table,table-rounding-modes
+@caption{IEEE 754 Rounding Modes}
+@multitable @columnfractions .45 .55
+@headitem Rounding Mode @tab IEEE Name
+@item Round to nearest, ties to even @tab @code{roundTiesToEven}
+@item Round toward plus Infinity @tab @code{roundTowardPositive}
+@item Round toward negative Infinity @tab @code{roundTowardNegative}
+@item Round toward zero @tab @code{roundTowardZero}
+@item Round to nearest, ties away from zero @tab @code{roundTiesToAway}
+@end multitable
+@end float
+
+The default mode @code{roundTiesToEven} is the most preferred,
+but the least intuitive. This method does the obvious thing for most values,
+by rounding them up or down to the nearest digit.
+For example, rounding 1.132 to two digits yields 1.13,
+and rounding 1.157 yields 1.16.
+
+However, when it comes to rounding a value that is exactly halfway between,
+things do not work the way you probably learned in school.
+In this case, the number is rounded to the nearest even digit.
+So rounding 0.125 to two digits rounds down to 0.12,
+but rounding 0.6875 to three digits rounds up to 0.688.
+You probably have already encountered this rounding mode when
+using the @code{printf} routine to format floating-point numbers.
+For example:
+
+@example
+BEGIN @{
+ x = -4.5
+ for (i = 1; i < 10; i++) @{
+ x += 1.0
+ printf("%4.1f => %2.0f\n", x, x)
+ @}
+@}
+@end example
+
+@noindent
+produces the following output when run:@footnote{It
+is possible for the output to be completely different if the
+C library in your system does not use the IEEE-754 even-rounding
+rule to round halfway cases for @code{printf()}.}
+
+@example
+-3.5 => -4
+-2.5 => -2
+-1.5 => -2
+-0.5 => 0
+ 0.5 => 0
+ 1.5 => 2
+ 2.5 => 2
+ 3.5 => 4
+ 4.5 => 4
+@end example
+
+The theory behind the rounding mode @code{roundTiesToEven} is that
+it more or less evenly distributes upward and downward rounds
+of exact halves, which might cause the round-off error
+to cancel itself out. This is the default rounding mode used
+in IEEE-754 computing functions and operators.
+
+The other rounding modes are rarely used.
+Round toward positive infinity (@code{roundTowardPositive})
+and round toward negative infinity (@code{roundTowardNegative})
+are often used to implement interval arithmetic,
+where you adjust the rounding mode to calculate upper and lower bounds
+for the range of output. The @code{roundTowardZero}
+mode can be used for converting floating-point numbers to integers.
+The rounding mode @code{roundTiesToAway} rounds the result to the
+nearest number and selects the number with the larger magnitude
+if a tie occurs.
+
+Some numerical analysts will tell you that your choice of rounding style
+has tremendous impact on the final outcome, and advise you to wait until
+final output for any rounding. Instead, you can often avoid round-off error problems by
+setting the precision initially to some value sufficiently larger than
+the final desired precision, so that the accumulation of round-off error
+does not influence the outcome.
+If you suspect that results from your computation are
+sensitive to accumulation of round-off error,
+one way to be sure is to look for a significant difference in output
+when you change the rounding mode.
+
+@node Gawk and MPFR
+@section @command{gawk} + MPFR = Powerful Arithmetic
+
+The rest of this @value{CHAPTER} describes how to use the arbitrary precision
+(also known as @dfn{multiple precision} or @dfn{infinite precision}) numeric
+capabilities in @command{gawk} to produce maximally accurate results
+when you need it.
+
+But first you should check if your version of
+@command{gawk} supports arbitrary precision arithmetic.
+The easiest way to find out is to look at the output of
+the following command:
+
+@example
+$ @kbd{gawk --version}
+@print{} GNU Awk 4.1.0 (GNU MPFR 3.1.0, GNU MP 5.0.3)
+@print{} Copyright (C) 1989, 1991-2012 Free Software Foundation.
+@dots{}
+@end example
+
+@command{gawk} uses the
+@uref{http://www.mpfr.org, GNU MPFR}
+and
+@uref{http://gmplib.org, GNU MP} (GMP)
+libraries for arbitrary precision
+arithmetic on numbers. So if you do not see the names of these libraries
+in the output, then your version of @command{gawk} does not support
+arbitrary precision arithmetic.
+
+Additionally,
+there are a few elements available in the @code{PROCINFO} array
+to provide information about the MPFR and GMP libraries.
+@xref{Auto-set}, for more information.
+
+@ignore
+Even if you aren't interested in arbitrary precision arithmetic, you
+may still benefit from knowing about how @command{gawk} handles numbers
+in general, and the limitations of doing arithmetic with ordinary
+@command{gawk} numbers.
+@end ignore
+
+
+@node Arbitrary Precision Floats
+@section Arbitrary Precision Floating-point Arithmetic with @command{gawk}
+
+@command{gawk} uses the GNU MPFR library
+for arbitrary precision floating-point arithmetic. The MPFR library
+provides precise control over precisions and rounding modes, and gives
+correctly rounded, reproducible, platform-independent results. With the
+command-line option @option{--bignum} or @option{-M},
+all floating-point arithmetic operators and numeric functions can yield
+results to any desired precision level supported by MPFR.
+Two built-in variables, @code{PREC} and @code{ROUNDMODE},
+provide control over the working precision and the rounding mode
+(@pxref{Setting Precision}, and
+@pxref{Setting Rounding Mode}).
+The precision and the rounding mode are set globally for every operation
+to follow.
+
+The default working precision for arbitrary precision floating-point values is 53,
+and the default value for @code{ROUNDMODE} is @code{"N"},
+which selects the IEEE-754 @code{roundTiesToEven} rounding mode
+(@pxref{Rounding Mode}).@footnote{The
+default precision is 53, since according to the MPFR documentation,
+the library should be able to exactly reproduce all computations with
+double-precision machine floating-point numbers (@code{double} type
+in C), except the default exponent range is much wider and subnormal
+numbers are not implemented.}
+@command{gawk} uses the default exponent range in MPFR
+@iftex
+(@math{emax = 2^{30} - 1, emin = -emax})
+@end iftex
+@ifnottex
+(@var{emax} = 2^30 @minus{} 1, @var{emin} = @minus{}@var{emax})
+@end ifnottex
+for all floating-point contexts.
+There is no explicit mechanism to adjust the exponent range.
+MPFR does not implement subnormal numbers by default,
+and this behavior cannot be changed in @command{gawk}.
+
+@quotation NOTE
+When emulating an IEEE-754 format (@pxref{Setting Precision}),
+@command{gawk} internally adjusts the exponent range
+to the value defined for the format and also performs computations needed for
+gradual underflow (subnormal numbers).
+@end quotation
+
+@quotation NOTE
+MPFR numbers are variable-size entities, consuming only as much space as
+needed to store the significant digits. Since the performance using MPFR
+numbers pales in comparison to doing arithmetic using the underlying machine
+types, you should consider using only as much precision as needed by
+your program.
+@end quotation
+
+@menu
+* Setting Precision:: Setting the working precision.
+* Setting Rounding Mode:: Setting the rounding mode.
+* Floating-point Constants:: Representing floating-point constants.
+* Changing Precision:: Changing the precision of a number.
+* Exact Arithmetic:: Exact arithmetic with floating-point numbers.
+@end menu
+
+@node Setting Precision
+@subsection Setting the Working Precision
+@cindex @code{PREC} variable
+
+@command{gawk} uses a global working precision; it does not keep track of
+the precision or accuracy of individual numbers. Performing an arithmetic
+operation or calling a built-in function rounds the result to the current
+working precision. The default working precision is 53, which can be
+modified using the built-in variable @code{PREC}. You can also set the
+value to one of the following pre-defined case-insensitive strings
+to emulate an IEEE-754 binary format:
+
+@multitable {@code{"double"}} {12345678901234567890123456789012345}
+@headitem @code{PREC} @tab IEEE-754 Binary Format
+@item @code{"half"} @tab 16-bit half-precision.
+@item @code{"single"} @tab Basic 32-bit single precision.
+@item @code{"double"} @tab Basic 64-bit double precision.
+@item @code{"quad"} @tab Basic 128-bit quadruple precision.
+@item @code{"oct"} @tab 256-bit octuple precision.
+@end multitable
+
+The following example illustrates the effects of changing precision
+on arithmetic operations:
+
+@example
+$ @kbd{gawk -M -v PREC=100 'BEGIN @{ x = 1.0e-400; print x + 0; \}
+> @kbd{PREC = "double"; print x + 0 @}'}
+@print{} 1e-400
+@print{} 0
+@end example
+
+Binary and decimal precisions are related approximately, according to the
+formula:
+
+@iftex
+@math{prec = 3.322 @cdot dps}
+@end iftex
+@ifnottex
+@var{prec} = 3.322 * @var{dps}
+@end ifnottex
+
+@noindent
+Here, @var{prec} denotes the binary precision
+(measured in bits) and @var{dps} (short for decimal places)
+is the decimal digits. We can easily calculate how many decimal
+digits the 53-bit significand of an IEEE double is equivalent to:
+53 / 3.332 which is equal to about 15.95.
+But what does 15.95 digits actually mean? It depends whether you are
+concerned about how many digits you can rely on, or how many digits
+you need.
+
+It is important to know how many bits it takes to uniquely identify
+a double-precision value (the C type @code{double}). If you want to
+convert from @code{double} to decimal and back to @code{double} (e.g.,
+saving a @code{double} representing an intermediate result to a file, and
+later reading it back to restart the computation), then a few more decimal
+digits are required. 17 digits is generally enough for a @code{double}.
+
+It can also be important to know what decimal numbers can be uniquely
+represented with a @code{double}. If you want to convert
+from decimal to @code{double} and back again, 15 digits is the most that
+you can get. Stated differently, you should not present
+the numbers from your floating-point computations with more than 15
+significant digits in them.
+
+Conversely, it takes a precision of 332 bits to hold an approximation
+of the constant @value{PI} that is accurate to 100 decimal places.
+
+You should always add some extra bits in order to avoid the confusing round-off
+issues that occur because numbers are stored internally in binary.
+
+@node Setting Rounding Mode
+@subsection Setting the Rounding Mode
+@cindex @code{ROUNDMODE} variable
+
+The @code{ROUNDMODE} variable provides
+program level control over the rounding mode.
+The correspondence between @code{ROUNDMODE} and the IEEE
+rounding modes is shown in @ref{table-gawk-rounding-modes}.
+
+@float Table,table-gawk-rounding-modes
+@caption{@command{gawk} Rounding Modes}
+@multitable @columnfractions .45 .30 .25
+@headitem Rounding Mode @tab IEEE Name @tab @code{ROUNDMODE}
+@item Round to nearest, ties to even @tab @code{roundTiesToEven} @tab @code{"N"} or @code{"n"}
+@item Round toward plus Infinity @tab @code{roundTowardPositive} @tab @code{"U"} or @code{"u"}
+@item Round toward negative Infinity @tab @code{roundTowardNegative} @tab @code{"D"} or @code{"d"}
+@item Round toward zero @tab @code{roundTowardZero} @tab @code{"Z"} or @code{"z"}
+@item Round to nearest, ties away from zero @tab @code{roundTiesToAway} @tab @code{"A"} or @code{"a"}
+@end multitable
+@end float
+
+@code{ROUNDMODE} has the default value @code{"N"},
+which selects the IEEE-754 rounding mode @code{roundTiesToEven}.
+@ref{table-gawk-rounding-modes}, lists @code{"A"} to select the IEEE-754 mode
+@code{roundTiesToAway}. This is only available
+if your version of the MPFR library supports it; otherwise setting
+@code{ROUNDMODE} to this value has no effect. @xref{Rounding Mode},
+for the meanings of the various rounding modes.
+
+Here is an example of how to change the default rounding behavior of
+@code{printf}'s output:
+
+@example
+$ @kbd{gawk -M -v ROUNDMODE="Z" 'BEGIN @{ printf("%.2f\n", 1.378) @}'}
+@print{} 1.37
+@end example
+
+@node Floating-point Constants
+@subsection Representing Floating-point Constants
+@cindex constants, floating-point
+
+Be wary of floating-point constants! When reading a floating-point constant
+from program source code, @command{gawk} uses the default precision,
+unless overridden
+by an assignment to the special variable @code{PREC} on the command
+line, to store it internally as a MPFR number.
+Changing the precision using @code{PREC} in the program text does
+@emph{not} change the precision of a constant. If you need to
+represent a floating-point constant at a higher precision than the
+default and cannot use a command line assignment to @code{PREC},
+you should either specify the constant as a string, or
+as a rational number, whenever possible. The following example
+illustrates the differences among various ways to
+print a floating-point constant:
+
+@example
+$ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", 0.1) @}'}
+@print{} 0.1000000000000000055511151
+$ @kbd{gawk -M -v PREC=113 'BEGIN @{ printf("%0.25f\n", 0.1) @}'}
+@print{} 0.1000000000000000000000000
+$ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", "0.1") @}'}
+@print{} 0.1000000000000000000000000
+$ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", 1/10) @}'}
+@print{} 0.1000000000000000000000000
+@end example
+
+In the first case, the number is stored with the default precision of 53.
+
+@node Changing Precision
+@subsection Changing the Precision of a Number
+
+@cindex Laurie, Dirk
+@quotation
+@i{The point is that in any variable-precision package,
+a decision is made on how to treat numbers given as data,
+or arising in intermediate results, which are represented in
+floating-point format to a precision lower than working precision.
+Do we promote them to full membership of the high-precision club,
+or do we treat them and all their associates as second-class citizens?
+Sometimes the first course is proper, sometimes the second, and it takes
+careful analysis to tell which.}
+
+Dirk Laurie@footnote{Dirk Laurie.
+@cite{Variable-precision Arithmetic Considered Perilous --- A Detective Story}.
+Electronic Transactions on Numerical Analysis. Volume 28, pp. 168-173, 2008.}
+@end quotation
+
+@command{gawk} does not implicitly modify the precision of any previously
+computed results when the working precision is changed with an assignment
+to @code{PREC}. The precision of a number is always the one that was
+used at the time of its creation, and there is no way for the user
+to explicitly change it afterwards. However, since the result of a
+floating-point arithmetic operation is always an arbitrary precision
+floating-point value---with a precision set by the value of @code{PREC}---one of the
+following workarounds effectively accomplishes the desired behavior:
+
+@example
+x = x + 0.0
+@end example
+
+@noindent
+or:
+
+@example
+x += 0.0
+@end example
+
+@node Exact Arithmetic
+@subsection Exact Arithmetic with Floating-point Numbers
+
+@quotation CAUTION
+Never depend on the exactness of floating-point arithmetic,
+even for apparently simple expressions!
+@end quotation
+
+Can arbitrary precision arithmetic give exact results? There are
+no easy answers. The standard rules of algebra often do not apply
+when using floating-point arithmetic.
+Among other things, the distributive and associative laws
+do not hold completely, and order of operation may be important
+for your computation. Rounding error, cumulative precision loss
+and underflow are often troublesome.
+
+When @command{gawk} tests the expressions @samp{0.1 + 12.2} and @samp{12.3}
+for equality
+using the machine double precision arithmetic, it decides that they
+are not equal!
+(@xref{Floating-point Programming}.)
+You can get the result you want by increasing the precision;
+56 in this case will get the job done:
+
+@example
+$ @kbd{gawk -M -v PREC=56 'BEGIN @{ print (0.1 + 12.2 == 12.3) @}'}
+@print{} 1
+@end example
+
+If adding more bits is good, perhaps adding even more bits of
+precision is better?
+Here is what happens if we use an even larger value of @code{PREC}:
+
+@example
+$ @kbd{gawk -M -v PREC=201 'BEGIN @{ print (0.1 + 12.2 == 12.3) @}'}
+@print{} 0
+@end example
+
+This is not a bug in @command{gawk} or in the MPFR library.
+It is easy to forget that the finite number of bits used to store the value
+is often just an approximation after proper rounding.
+The test for equality succeeds if and only if @emph{all} bits in the two operands
+are exactly the same. Since this is not necessarily true after floating-point
+computations with a particular precision and effective rounding rule,
+a straight test for equality may not work.
+
+So, don't assume that floating-point values can be compared for equality.
+You should also exercise caution when using other forms of comparisons.
+The standard way to compare between floating-point numbers is to determine
+how much error (or @dfn{tolerance}) you will allow in a comparison and
+check to see if one value is within this error range of the other.
+
+In applications where 15 or fewer decimal places suffice,
+hardware double precision arithmetic can be adequate, and is usually much faster.
+But you do need to keep in mind that every floating-point operation
+can suffer a new rounding error with catastrophic consequences as illustrated
+by our earlier attempt to compute the value of the constant @value{PI}
+(@pxref{Floating-point Programming}).
+Extra precision can greatly enhance the stability and the accuracy
+of your computation in such cases.
+
+Repeated addition is not necessarily equivalent to multiplication
+in floating-point arithmetic. In the example in
+@ref{Floating-point Programming}:
+
+@example
+$ @kbd{gawk 'BEGIN @{}
+> @kbd{for (d = 1.1; d <= 1.5; d += 0.1)}
+> @kbd{i++}
+> @kbd{print i}
+> @kbd{@}'}
+@print{} 4
+@end example
+
+@noindent
+you may or may not succeed in getting the correct result by choosing
+an arbitrarily large value for @code{PREC}. Reformulation of
+the problem at hand is often the correct approach in such situations.
+
+@node Arbitrary Precision Integers
+@section Arbitrary Precision Integer Arithmetic with @command{gawk}
+@cindex integer, arbitrary precision
+
+If the option @option{--bignum} or @option{-M} is specified,
+@command{gawk} performs all
+integer arithmetic using GMP arbitrary precision integers.
+Any number that looks like an integer in a program source or data file
+is stored as an arbitrary precision integer.
+The size of the integer is limited only by your computer's memory.
+The current floating-point context has no effect on operations involving integers.
+For example, the following computes
+@iftex
+@math{5^{4^{3^{2}}}},
+@end iftex
+@ifnottex
+5^4^3^2,
+@end ifnottex
+the result of which is beyond the
+limits of ordinary @command{gawk} numbers:
+
+@example
+$ @kbd{gawk -M 'BEGIN @{}
+> @kbd{x = 5^4^3^2}
+> @kbd{print "# of digits =", length(x)}
+> @kbd{print substr(x, 1, 20), "...", substr(x, length(x) - 19, 20)}
+> @kbd{@}'}
+@print{} # of digits = 183231
+@print{} 62060698786608744707 ... 92256259918212890625
+@end example
+
+If you were to compute the same value using arbitrary precision
+floating-point values instead, the precision needed for correct output
+(using the formula
+@iftex
+@math{prec = 3.322 @cdot dps}),
+would be @math{3.322 @cdot 183231},
+@end iftex
+@ifnottex
+@samp{prec = 3.322 * dps}),
+would be 3.322 x 183231,
+@end ifnottex
+or 608693.
+
+The result from an arithmetic operation with an integer and a floating-point value
+is a floating-point value with a precision equal to the working precision.
+The following program calculates the eighth term in
+Sylvester's sequence@footnote{Weisstein, Eric W.
+@cite{Sylvester's Sequence}. From MathWorld---A Wolfram Web Resource.
+@url{http://mathworld.wolfram.com/SylvestersSequence.html}}
+using a recurrence:
+
+@example
+$ @kbd{gawk -M 'BEGIN @{}
+> @kbd{s = 2.0}
+> @kbd{for (i = 1; i <= 7; i++)}
+> @kbd{s = s * (s - 1) + 1}
+> @kbd{print s}
+> @kbd{@}'}
+@print{} 113423713055421845118910464
+@end example
+
+The output differs from the actual number, 113,423,713,055,421,844,361,000,443,
+because the default precision of 53 is not enough to represent the
+floating-point results exactly. You can either increase the precision
+(100 is enough in this case), or replace the floating-point constant
+@samp{2.0} with an integer, to perform all computations using integer
+arithmetic to get the correct output.
+
+It will sometimes be necessary for @command{gawk} to implicitly convert an
+arbitrary precision integer into an arbitrary precision floating-point value.
+This is primarily because the MPFR library does not always provide the
+relevant interface to process arbitrary precision integers or mixed-mode
+numbers as needed by an operation or function.
+In such a case, the precision is set to the minimum value necessary
+for exact conversion, and the working precision is not used for this purpose.
+If this is not what you need or want, you can employ a subterfuge
+like this:
+
+@example
+gawk -M 'BEGIN @{ n = 13; print (n + 0.0) % 2.0 @}'
+@end example
+
+You can avoid this issue altogether by specifying the number as a floating-point value
+to begin with:
+
+@example
+gawk -M 'BEGIN @{ n = 13.0; print n % 2.0 @}'
+@end example
+
+Note that for the particular example above, there is likely best
+to just use the following:
+
+@example
+gawk -M 'BEGIN @{ n = 13; print n % 2 @}'
+@end example
+
+@node Dynamic Extensions
+@chapter Writing Extensions for @command{gawk}
+
+This chapter is a placeholder, pending a rewrite for the new API.
+Some of the old bits remain, since they can be partially reused.
+
+
+@c STARTOFRANGE gladfgaw
+@cindex @command{gawk}, functions, adding
+@c STARTOFRANGE adfugaw
+@cindex adding, functions to @command{gawk}
+@c STARTOFRANGE fubadgaw
+@cindex functions, built-in, adding to @command{gawk}
+It is possible to add new built-in
+functions to @command{gawk} using dynamically loaded libraries. This
+facility is available on systems (such as GNU/Linux) that support
+the C @code{dlopen()} and @code{dlsym()} functions.
+This @value{CHAPTER} describes how to write and use dynamically
+loaded extensions for @command{gawk}.
+Experience with programming in
+C or C++ is necessary when reading this @value{SECTION}.
+
+@quotation NOTE
+When @option{--sandbox} is specified, extensions are disabled
+(@pxref{Options}.
+@end quotation
+
+@menu
+* Plugin License:: A note about licensing.
+* Sample Library:: A example of new functions.
+@end menu
+
+@node Plugin License
+@section Extension Licensing
+
+Every dynamic extension should define the global symbol
+@code{plugin_is_GPL_compatible} to assert that it has been licensed under
+a GPL-compatible license. If this symbol does not exist, @command{gawk}
+will emit a fatal error and exit.
+
+The declared type of the symbol should be @code{int}. It does not need
+to be in any allocated section, though. The code merely asserts that
+the symbol exists in the global scope. Something like this is enough:
+
+@example
+int plugin_is_GPL_compatible;
+@end example
+
+@node Sample Library
+@section Example: Directory and File Operation Built-ins
+@c STARTOFRANGE chdirg
+@cindex @code{chdir()} function@comma{} implementing in @command{gawk}
+@c STARTOFRANGE statg
+@cindex @code{stat()} function@comma{} implementing in @command{gawk}
+@c STARTOFRANGE filre
+@cindex files, information about@comma{} retrieving
+@c STARTOFRANGE dirch
+@cindex directories, changing
+
+Two useful functions that are not in @command{awk} are @code{chdir()}
+(so that an @command{awk} program can change its directory) and
+@code{stat()} (so that an @command{awk} program can gather information about
+a file).
+This @value{SECTION} implements these functions for @command{gawk} in an
+external extension library.
+
+@menu
+* Internal File Description:: What the new functions will do.
+* Internal File Ops:: The code for internal file operations.
+* Using Internal File Ops:: How to use an external extension.
+@end menu
+
+@node Internal File Description
+@subsection Using @code{chdir()} and @code{stat()}
+
+This @value{SECTION} shows how to use the new functions at the @command{awk}
+level once they've been integrated into the running @command{gawk}
+interpreter.
+Using @code{chdir()} is very straightforward. It takes one argument,
+the new directory to change to:
+
+@example
+@dots{}
+newdir = "/home/arnold/funstuff"
+ret = chdir(newdir)
+if (ret < 0) @{
+ printf("could not change to %s: %s\n",
+ newdir, ERRNO) > "/dev/stderr"
+ exit 1
+@}
+@dots{}
+@end example
+
+The return value is negative if the @code{chdir} failed,
+and @code{ERRNO}
+(@pxref{Built-in Variables})
+is set to a string indicating the error.
+
+Using @code{stat()} is a bit more complicated.
+The C @code{stat()} function fills in a structure that has a fair
+amount of information.
+The right way to model this in @command{awk} is to fill in an associative
+array with the appropriate information:
+
+@c broke printf for page breaking
+@example
+file = "/home/arnold/.profile"
+fdata[1] = "x" # force `fdata' to be an array
+ret = stat(file, fdata)
+if (ret < 0) @{
+ printf("could not stat %s: %s\n",
+ file, ERRNO) > "/dev/stderr"
+ exit 1
+@}
+printf("size of %s is %d bytes\n", file, fdata["size"])
+@end example
+
+The @code{stat()} function always clears the data array, even if
+the @code{stat()} fails. It fills in the following elements:
+
+@table @code
+@item "name"
+The name of the file that was @code{stat()}'ed.
+
+@item "dev"
+@itemx "ino"
+The file's device and inode numbers, respectively.
+
+@item "mode"
+The file's mode, as a numeric value. This includes both the file's
+type and its permissions.
+
+@item "nlink"
+The number of hard links (directory entries) the file has.
+
+@item "uid"
+@itemx "gid"
+The numeric user and group ID numbers of the file's owner.
+
+@item "size"
+The size in bytes of the file.
+
+@item "blocks"
+The number of disk blocks the file actually occupies. This may not
+be a function of the file's size if the file has holes.
+
+@item "atime"
+@itemx "mtime"
+@itemx "ctime"
+The file's last access, modification, and inode update times,
+respectively. These are numeric timestamps, suitable for formatting
+with @code{strftime()}
+(@pxref{Built-in}).
+
+@item "pmode"
+The file's ``printable mode.'' This is a string representation of
+the file's type and permissions, such as what is produced by
+@samp{ls -l}---for example, @code{"drwxr-xr-x"}.
+
+@item "type"
+A printable string representation of the file's type. The value
+is one of the following:
+
+@table @code
+@item "blockdev"
+@itemx "chardev"
+The file is a block or character device (``special file'').
+
+@ignore
+@item "door"
+The file is a Solaris ``door'' (special file used for
+interprocess communications).
+@end ignore
+
+@item "directory"
+The file is a directory.
+
+@item "fifo"
+The file is a named-pipe (also known as a FIFO).
+
+@item "file"
+The file is just a regular file.
+
+@item "socket"
+The file is an @code{AF_UNIX} (``Unix domain'') socket in the
+filesystem.
+
+@item "symlink"
+The file is a symbolic link.
+@end table
+@end table
+
+Several additional elements may be present depending upon the operating
+system and the type of the file. You can test for them in your @command{awk}
+program by using the @code{in} operator
+(@pxref{Reference to Elements}):
+
+@table @code
+@item "blksize"
+The preferred block size for I/O to the file. This field is not
+present on all POSIX-like systems in the C @code{stat} structure.
+
+@item "linkval"
+If the file is a symbolic link, this element is the name of the
+file the link points to (i.e., the value of the link).
+
+@item "rdev"
+@itemx "major"
+@itemx "minor"
+If the file is a block or character device file, then these values
+represent the numeric device number and the major and minor components
+of that number, respectively.
+@end table
+
+@node Internal File Ops
+@subsection C Code for @code{chdir()} and @code{stat()}
+
+Here is the C code for these extensions. They were written for
+GNU/Linux. The code needs some more work for complete portability
+to other POSIX-compliant systems:@footnote{This version is edited
+slightly for presentation. See
+@file{extension/filefuncs.c} in the @command{gawk} distribution
+for the complete version.}
+
+@c break line for page breaking
+@example
+#include "awk.h"
+
+#include <sys/sysmacros.h>
+
+int plugin_is_GPL_compatible;
+
+/* do_chdir --- provide dynamically loaded chdir() builtin for gawk */
+
+static NODE *
+do_chdir(int nargs)
+@{
+ NODE *newdir;
+ int ret = -1;
+
+ if (do_lint && nargs != 1)
+ lintwarn("chdir: called with incorrect number of arguments");
+
+ newdir = get_scalar_argument(0, FALSE);
+@end example
+
+The file includes the @code{"awk.h"} header file for definitions
+for the @command{gawk} internals. It includes @code{<sys/sysmacros.h>}
+for access to the @code{major()} and @code{minor}() macros.
+
+@cindex programming conventions, @command{gawk} internals
+By convention, for an @command{awk} function @code{foo}, the function that
+implements it is called @samp{do_foo}. The function should take
+a @samp{int} argument, usually called @code{nargs}, that
+represents the number of defined arguments for the function. The @code{newdir}
+variable represents the new directory to change to, retrieved
+with @code{get_scalar_argument()}. Note that the first argument is
+numbered zero.
+
+This code actually accomplishes the @code{chdir()}. It first forces
+the argument to be a string and passes the string value to the
+@code{chdir()} system call. If the @code{chdir()} fails, @code{ERRNO}
+is updated.
+
+@example
+ (void) force_string(newdir);
+ ret = chdir(newdir->stptr);
+ if (ret < 0)
+ update_ERRNO_int(errno);
+@end example
+
+Finally, the function returns the return value to the @command{awk} level:
+
+@example
+ return make_number((AWKNUM) ret);
+@}
+@end example
+
+The @code{stat()} built-in is more involved. First comes a function
+that turns a numeric mode into a printable representation
+(e.g., 644 becomes @samp{-rw-r--r--}). This is omitted here for brevity:
+
+@c break line for page breaking
+@example
+/* format_mode --- turn a stat mode field into something readable */
+
+static char *
+format_mode(unsigned long fmode)
+@{
+ @dots{}
+@}
+@end example
+
+Next comes the @code{do_stat()} function. It starts with
+variable declarations and argument checking:
+
+@ignore
+Changed message for page breaking. Used to be:
+ "stat: called with incorrect number of arguments (%d), should be 2",
+@end ignore
+@example
+/* do_stat --- provide a stat() function for gawk */
+
+static NODE *
+do_stat(int nargs)
+@{
+ NODE *file, *array, *tmp;
+ struct stat sbuf;
+ int ret;
+ NODE **aptr;
+ char *pmode; /* printable mode */
+ char *type = "unknown";
+
+ if (do_lint && nargs > 2)
+ lintwarn("stat: called with too many arguments");
+@end example
+
+Then comes the actual work. First, the function gets the arguments.
+Then, it always clears the array.
+The code use @code{lstat()} (instead of @code{stat()})
+to get the file information,
+in case the file is a symbolic link.
+If there's an error, it sets @code{ERRNO} and returns:
+
+@c comment made multiline for page breaking
+@example
+ /* file is first arg, array to hold results is second */
+ file = get_scalar_argument(0, FALSE);
+ array = get_array_argument(1, FALSE);
+
+ /* empty out the array */
+ assoc_clear(array);
+
+ /* lstat the file, if error, set ERRNO and return */
+ (void) force_string(file);
+ ret = lstat(file->stptr, & sbuf);
+ if (ret < 0) @{
+ update_ERRNO_int(errno);
+ return make_number((AWKNUM) ret);
+ @}
+@end example
+
+Now comes the tedious part: filling in the array. Only a few of the
+calls are shown here, since they all follow the same pattern:
+
+@example
+ /* fill in the array */
+ aptr = assoc_lookup(array, tmp = make_string("name", 4));
+ *aptr = dupnode(file);
+ unref(tmp);
+
+ aptr = assoc_lookup(array, tmp = make_string("mode", 4));
+ *aptr = make_number((AWKNUM) sbuf.st_mode);
+ unref(tmp);
+
+ aptr = assoc_lookup(array, tmp = make_string("pmode", 5));
+ pmode = format_mode(sbuf.st_mode);
+ *aptr = make_string(pmode, strlen(pmode));
+ unref(tmp);
+@end example
+
+When done, return the @code{lstat()} return value:
+
+@example
+
+ return make_number((AWKNUM) ret);
+@}
+@end example
+
+@cindex programming conventions, @command{gawk} internals
+Finally, it's necessary to provide the ``glue'' that loads the
+new function(s) into @command{gawk}. By convention, each library has
+a routine named @code{dl_load()} that does the job. The simplest way
+is to use the @code{dl_load_func} macro in @code{gawkapi.h}.
+
+And that's it! As an exercise, consider adding functions to
+implement system calls such as @code{chown()}, @code{chmod()},
+and @code{umask()}.
+
+@node Using Internal File Ops
+@subsection Integrating the Extensions
+
+@cindex @command{gawk}, interpreter@comma{} adding code to
+Now that the code is written, it must be possible to add it at
+runtime to the running @command{gawk} interpreter. First, the
+code must be compiled. Assuming that the functions are in
+a file named @file{filefuncs.c}, and @var{idir} is the location
+of the @command{gawk} include files,
+the following steps create
+a GNU/Linux shared library:
+
+@example
+$ @kbd{gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -I@var{idir} filefuncs.c}
+$ @kbd{ld -o filefuncs.so -shared filefuncs.o}
+@end example
+
+@cindex @code{extension()} function (@command{gawk})
+Once the library exists, it is loaded by calling the @code{extension()}
+built-in function.
+This function takes two arguments: the name of the
+library to load and the name of a function to call when the library
+is first loaded. This function adds the new functions to @command{gawk}.
+It returns the value returned by the initialization function
+within the shared library:
+
+@example
+# file testff.awk
+BEGIN @{
+ extension("./filefuncs.so", "dl_load")
+
+ chdir(".") # no-op
+
+ data[1] = 1 # force `data' to be an array
+ print "Info for testff.awk"
+ ret = stat("testff.awk", data)
+ print "ret =", ret
+ for (i in data)
+ printf "data[\"%s\"] = %s\n", i, data[i]
+ print "testff.awk modified:",
+ strftime("%m %d %y %H:%M:%S", data["mtime"])
+
+ print "\nInfo for JUNK"
+ ret = stat("JUNK", data)
+ print "ret =", ret
+ for (i in data)
+ printf "data[\"%s\"] = %s\n", i, data[i]
+ print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"])
+@}
+@end example
+
+Here are the results of running the program:
+
+@example
+$ @kbd{gawk -f testff.awk}
+@print{} Info for testff.awk
+@print{} ret = 0
+@print{} data["size"] = 607
+@print{} data["ino"] = 14945891
+@print{} data["name"] = testff.awk
+@print{} data["pmode"] = -rw-rw-r--
+@print{} data["nlink"] = 1
+@print{} data["atime"] = 1293993369
+@print{} data["mtime"] = 1288520752
+@print{} data["mode"] = 33204
+@print{} data["blksize"] = 4096
+@print{} data["dev"] = 2054
+@print{} data["type"] = file
+@print{} data["gid"] = 500
+@print{} data["uid"] = 500
+@print{} data["blocks"] = 8
+@print{} data["ctime"] = 1290113572
+@print{} testff.awk modified: 10 31 10 12:25:52
+@print{}
+@print{} Info for JUNK
+@print{} ret = -1
+@print{} JUNK modified: 01 01 70 02:00:00
+@end example
+@c ENDOFRANGE filre
+@c ENDOFRANGE dirch
+@c ENDOFRANGE statg
+@c ENDOFRANGE chdirg
+@c ENDOFRANGE gladfgaw
+@c ENDOFRANGE adfugaw
+@c ENDOFRANGE fubadgaw
+
@ignore
@c Try this
@iftex
@@ -26515,8 +28540,6 @@ This @value{CHAPTER} briefly describes the
evolution of the @command{awk} language, with cross-references to other parts
of the @value{DOCUMENT} where you can find more information.
-@c FIXME: Try to determine whether it was 3.1 or 3.2 that had new awk.
-
@menu
* V7/SVR3.1:: The major changes between V7 and System V
Release 3.1.
@@ -26931,6 +28954,7 @@ and
@code{xor()}
functions for bit manipulation
(@pxref{Bitwise Functions}).
+@c In 4.1, and(), or() and xor() grew the ability to take > 2 arguments
@item
The @code{asort()} and @code{asorti()} functions for sorting arrays
@@ -26942,11 +28966,6 @@ functions for internationalization
(@pxref{Programmer i18n}).
@item
-The @code{extension()} built-in function and the ability to add
-new functions dynamically
-(@pxref{Dynamic Extensions}).
-
-@item
The @code{fflush()} function from Brian Kernighan's
version of @command{awk}
(@pxref{I/O Functions}).
@@ -26973,29 +28992,70 @@ the @option{-f} command-line option
(@pxref{Options}).
@item
-The ability to use GNU-style long-named options that start with @option{--}
+The @env{AWKLIBPATH} environment variable for specifying a path search for
+the @option{-l} command-line option
+(@pxref{Options}).
+
+@item
+The
+@option{-b},
+@option{-c},
+@option{-C},
+@option{-d},
+@option{-D},
+@option{-e},
+@option{-E},
+@option{-g},
+@option{-h},
+@option{-i},
+@option{-l},
+@option{-L},
+@option{-M},
+@option{-n},
+@option{-N},
+@option{-o},
+@option{-O},
+@option{-p},
+@option{-P},
+@option{-r},
+@option{-S},
+@option{-t},
+and
+@option{-V}
+short options. Also, the
+ability to use GNU-style long-named options that start with @option{--}
and the
+@option{--assign},
+@option{--bignum},
@option{--characters-as-bytes},
-@option{--compat},
+@option{--copyright},
+@option{--debug},
@option{--dump-variables},
-@option{--exec},
+@option{--execle},
+@option{--field-separator},
+@option{--file},
@option{--gen-pot},
+@option{--help},
+@option{--include},
@option{--lint},
@option{--lint-old},
+@option{--load},
@option{--non-decimal-data},
+@option{--optimize},
@option{--posix},
+@option{--pretty-print},
@option{--profile},
@option{--re-interval},
@option{--sandbox},
@option{--source},
@option{--traditional},
+@option{--use-lc-numeric},
and
-@option{--use-lc-numeric}
-options
+@option{--version}
+long options
(@pxref{Options}).
@end itemize
-
@c new ports
@item
@@ -27060,7 +29120,7 @@ the three most widely-used freely available versions of @command{awk}
@item @samp{\x} Escape sequence @tab X @tab X @tab X
@item @code{RS} as regexp @tab @tab X @tab X
@item @code{FS} as null string @tab X @tab X @tab X
-@item @file{/dev/stdin} special file @tab X @tab X @tab X
+@item @file{/dev/stdin} special file @tab X @tab @tab X
@item @file{/dev/stdout} special file @tab X @tab X @tab X
@item @file{/dev/stderr} special file @tab X @tab X @tab X
@item @code{**} and @code{**=} operators @tab X @tab @tab X
@@ -27171,7 +29231,6 @@ to implementors to implement ranges in whatever way they choose.
The @command{gawk} maintainer chose to apply the pre-POSIX meaning in all
cases: the default regexp matching; with @option{--traditional}, and with
@option{--posix}; in all cases, @command{gawk} remains POSIX compliant.
-
@node Contributors
@appendixsec Major Contributors to @command{gawk}
@cindex @command{gawk}, list of contributors to
@@ -27304,6 +29363,7 @@ the various PC platforms.
Christos Zoulas
provided the @code{extension()}
built-in function for dynamically adding new modules.
+(This was removed at @command{gawk} 4.1.)
@item
@cindex Kahrs, J@"urgen
@@ -27367,7 +29427,7 @@ environments.
@cindex Haque, John
John Haque
reworked the @command{gawk} internals to use a byte-code engine,
-providing the @command{dgawk} debugger for @command{awk} programs.
+providing the @command{gawk} debugger for @command{awk} programs.
@item
@cindex Yawitz, Efraim
@@ -27933,10 +29993,6 @@ install-info --info-dir=x:/usr/info x:/usr/info/gawkinet.info
The binary distribution may contain a separate file containing additional
or more detailed installation instructions.
-As of April, 2012, up to date @command{gawk} binaries for MS Windows
-are available from @uref{http://sourceforge.net/projects/ezwinports/files/,
-Eli Zaretskii's ports project}.
-
@node PC Compiling
@appendixsubsubsec Compiling @command{gawk} for PC Operating Systems
@@ -28641,7 +30697,7 @@ since approximately 2003.
@item @command{pawk}
Nelson H.F.@: Beebe at the University of Utah has modified
Brian Kernighan's @command{awk} to provide timing and profiling information.
-It is different from @command{pgawk}
+It is different from @command{gawk} with the @option{--profile} option.
(@pxref{Profiling}),
in that it uses CPU-based profiling, not line-count
profiling. You may find it at either
@@ -28736,8 +30792,6 @@ maintainers of @command{gawk}. Everything in it applies specifically to
* Compatibility Mode:: How to disable certain @command{gawk}
extensions.
* Additions:: Making Additions To @command{gawk}.
-* Dynamic Extensions:: Adding new built-in functions to
- @command{gawk}.
* Future Extensions:: New features that may be implemented one day.
@end menu
@@ -28783,6 +30837,8 @@ as well as any considerations you should bear in mind.
@command{gawk}.
* New Ports:: Porting @command{gawk} to a new operating
system.
+* Derived Files:: Why derived files are kept in the
+ @command{git} repository.
@end menu
@node Accessing The Source
@@ -28814,7 +30870,7 @@ git clone http://git.savannah.gnu.org/r/gawk.git
@end example
Once you have made changes, you can use @samp{git diff} to produce a
-patch, and send that to the @command{gawk} maintainer; see @ref{Bugs}
+patch, and send that to the @command{gawk} maintainer; see @ref{Bugs},
for how to do that.
Finally, if you cannot install Git (e.g., if it hasn't been ported
@@ -28926,7 +30982,8 @@ of @code{switch} statements, instead of just the
plain pointer or character value.
@item
-Use the @code{TRUE}, @code{FALSE} and @code{NULL} symbolic constants
+Use @code{true}, @code{false} for @code{bool} values,
+the @code{NULL} symbolic constant for pointer values,
and the character constant @code{'\0'} where appropriate, instead of @code{1}
and @code{0}.
@@ -28973,8 +31030,9 @@ You will also have to sign paperwork for your documentation changes.
Submit changes as unified diffs.
Use @samp{diff -u -r -N} to compare
the original @command{gawk} source tree with your version.
-I recommend using the GNU version of @command{diff}.
-Send the output produced by either run of @command{diff} to me when you
+I recommend using the GNU version of @command{diff}, or best of all,
+@samp{git diff} or @samp{git format-patch}.
+Send the output produced by @command{diff} to me when you
submit your changes.
(@xref{Bugs}, for the electronic mail
information.)
@@ -29100,802 +31158,188 @@ operating systems' code that is already there.
In the code that you supply and maintain, feel free to use a
coding style and brace layout that suits your taste.
-@node Dynamic Extensions
-@appendixsec Adding New Built-in Functions to @command{gawk}
-@cindex Robinson, Will
-@cindex robot, the
-@cindex Lost In Space
-@quotation
-@i{Danger Will Robinson! Danger!!@*
-Warning! Warning!}@*
-The Robot
-@end quotation
-
-@c STARTOFRANGE gladfgaw
-@cindex @command{gawk}, functions, adding
-@c STARTOFRANGE adfugaw
-@cindex adding, functions to @command{gawk}
-@c STARTOFRANGE fubadgaw
-@cindex functions, built-in, adding to @command{gawk}
-It is possible to add new built-in
-functions to @command{gawk} using dynamically loaded libraries. This
-facility is available on systems (such as GNU/Linux) that support
-the C @code{dlopen()} and @code{dlsym()} functions.
-This @value{SECTION} describes how to write and use dynamically
-loaded extensions for @command{gawk}.
-Experience with programming in
-C or C++ is necessary when reading this @value{SECTION}.
-
-@quotation CAUTION
-The facilities described in this @value{SECTION}
-are very much subject to change in a future @command{gawk} release.
-Be aware that you may have to re-do everything,
-at some future time.
-
-If you have written your own dynamic extensions,
-be sure to recompile them for each new @command{gawk} release.
-There is no guarantee of binary compatibility between different
-releases, nor will there ever be such a guarantee.
-@end quotation
-
-@quotation NOTE
-When @option{--sandbox} is specified, extensions are disabled
-(@pxref{Options}.
-@end quotation
-
-@menu
-* Internals:: A brief look at some @command{gawk} internals.
-* Plugin License:: A note about licensing.
-* Sample Library:: A example of new functions.
-@end menu
-
-@node Internals
-@appendixsubsec A Minimal Introduction to @command{gawk} Internals
-@c STARTOFRANGE gawint
-@cindex @command{gawk}, internals
-
-The truth is that @command{gawk} was not designed for simple extensibility.
-The facilities for adding functions using shared libraries work, but
-are something of a ``bag on the side.'' Thus, this tour is
-brief and simplistic; would-be @command{gawk} hackers are encouraged to
-spend some time reading the source code before trying to write
-extensions based on the material presented here. Of particular note
-are the files @file{awk.h}, @file{builtin.c}, and @file{eval.c}.
-Reading @file{awkgram.y} in order to see how the parse tree is built
-would also be of use.
-
-@cindex @code{awk.h} file (internal)
-With the disclaimers out of the way, the following types, structure
-members, functions, and macros are declared in @file{awk.h} and are of
-use when writing extensions. The next @value{SECTION}
-shows how they are used:
-
-@table @code
-@cindex floating-point, numbers, @code{AWKNUM} internal type
-@cindex numbers, floating-point, @code{AWKNUM} internal type
-@cindex @code{AWKNUM} internal type
-@cindex internal type, @code{AWKNUM}
-@item AWKNUM
-An @code{AWKNUM} is the internal type of @command{awk}
-floating-point numbers. Typically, it is a C @code{double}.
-
-@cindex @code{NODE} internal type
-@cindex internal type, @code{NODE}
-@cindex strings, @code{NODE} internal type
-@cindex numbers, @code{NODE} internal type
-@item NODE
-Just about everything is done using objects of type @code{NODE}.
-These contain both strings and numbers, as well as variables and arrays.
-
-@cindex @code{force_number()} internal function
-@cindex internal function, @code{force_number()}
-@cindex numeric, values
-@item AWKNUM force_number(NODE *n)
-This macro forces a value to be numeric. It returns the actual
-numeric value contained in the node.
-It may end up calling an internal @command{gawk} function.
-
-@cindex @code{force_string()} internal function
-@cindex internal function, @code{force_string()}
-@item void force_string(NODE *n)
-This macro guarantees that a @code{NODE}'s string value is current.
-It may end up calling an internal @command{gawk} function.
-It also guarantees that the string is zero-terminated.
-
-@cindex @code{force_wstring()} internal function
-@cindex internal function, @code{force_wstring()}
-@item void force_wstring(NODE *n)
-Similarly, this
-macro guarantees that a @code{NODE}'s wide-string value is current.
-It may end up calling an internal @command{gawk} function.
-It also guarantees that the wide string is zero-terminated.
-
-@cindex @code{get_curfunc_arg_count()} internal function
-@cindex internal function, @code{get_curfunc_arg_count()}
-@item size_t get_curfunc_arg_count(void)
-This function returns the actual number of parameters passed
-to the current function. Inside the code of an extension
-this can be used to determine the maximum index which is
-safe to use with @code{get_actual_argument}. If this value is
-greater than @code{nargs}, the function was
-called incorrectly from the @command{awk} program.
-
-@cindex parameters@comma{} number of
-@cindex @code{nargs} internal variable
-@cindex internal variable, @code{nargs}
-@item nargs
-Inside an extension function, this is the maximum number of
-expected parameters, as set by the @code{make_builtin()} function.
-
-@cindex @code{stptr} internal variable
-@cindex internal variable, @code{stptr}
-@cindex @code{stlen} internal variable
-@cindex internal variable, @code{stlen}
-@item n->stptr
-@itemx n->stlen
-The data and length of a @code{NODE}'s string value, respectively.
-The string is @emph{not} guaranteed to be zero-terminated.
-If you need to pass the string value to a C library function, save
-the value in @code{n->stptr[n->stlen]}, assign @code{'\0'} to it,
-call the routine, and then restore the value.
-
-@cindex @code{wstptr} internal variable
-@cindex internal variable, @code{wstptr}
-@cindex @code{wstlen} internal variable
-@cindex internal variable, @code{wstlen}
-@item n->wstptr
-@itemx n->wstlen
-The data and length of a @code{NODE}'s wide-string value, respectively.
-Use @code{force_wstring()} to make sure these values are current.
-
-@cindex @code{type} internal variable
-@cindex internal variable, @code{type}
-@item n->type
-The type of the @code{NODE}. This is a C @code{enum}. Values should
-be one of @code{Node_var}, @code{Node_var_new}, or @code{Node_var_array}
-for function parameters.
-
-@cindex @code{vname} internal variable
-@cindex internal variable, @code{vname}
-@item n->vname
-The ``variable name'' of a node. This is not of much use inside
-externally written extensions.
-
-@cindex arrays, associative, clearing
-@cindex @code{assoc_clear()} internal function
-@cindex internal function, @code{assoc_clear()}
-@item void assoc_clear(NODE *n)
-Clears the associative array pointed to by @code{n}.
-Make sure that @samp{n->type == Node_var_array} first.
-
-@cindex arrays, elements, installing
-@cindex @code{assoc_lookup()} internal function
-@cindex internal function, @code{assoc_lookup()}
-@item NODE **assoc_lookup(NODE *symbol, NODE *subs, int reference)
-Finds, and installs if necessary, array elements.
-@code{symbol} is the array, @code{subs} is the subscript.
-This is usually a value created with @code{make_string()} (see below).
-@code{reference} should be @code{TRUE} if it is an error to use the
-value before it is created. Typically, @code{FALSE} is the
-correct value to use from extension functions.
-
-@cindex strings
-@cindex @code{make_string()} internal function
-@cindex internal function, @code{make_string()}
-@item NODE *make_string(char *s, size_t len)
-Take a C string and turn it into a pointer to a @code{NODE} that
-can be stored appropriately. This is permanent storage; understanding
-of @command{gawk} memory management is helpful.
-
-@cindex numbers
-@cindex @code{make_number()} internal function
-@cindex internal function, @code{make_number()}
-@item NODE *make_number(AWKNUM val)
-Take an @code{AWKNUM} and turn it into a pointer to a @code{NODE} that
-can be stored appropriately. This is permanent storage; understanding
-of @command{gawk} memory management is helpful.
-
-
-@cindex nodes@comma{} duplicating
-@cindex @code{dupnode()} internal function
-@cindex internal function, @code{dupnode()}
-@item NODE *dupnode(NODE *n)
-Duplicate a node. In most cases, this increments an internal
-reference count instead of actually duplicating the entire @code{NODE};
-understanding of @command{gawk} memory management is helpful.
-
-@cindex memory, releasing
-@cindex @code{unref()} internal function
-@cindex internal function, @code{unref()}
-@item void unref(NODE *n)
-This macro releases the memory associated with a @code{NODE}
-allocated with @code{make_string()} or @code{make_number()}.
-Understanding of @command{gawk} memory management is helpful.
-
-@cindex @code{make_builtin()} internal function
-@cindex internal function, @code{make_builtin()}
-@item void make_builtin(const char *name, NODE *(*func)(NODE *), int count)
-Register a C function pointed to by @code{func} as new built-in
-function @code{name}. @code{name} is a regular C string. @code{count}
-is the maximum number of arguments that the function takes.
-The function should be written in the following manner:
-
-@example
-/* do_xxx --- do xxx function for gawk */
-
-NODE *
-do_xxx(int nargs)
-@{
- @dots{}
-@}
-@end example
-
-@cindex arguments, retrieving
-@cindex @code{get_argument()} internal function
-@cindex internal function, @code{get_argument()}
-@item NODE *get_argument(int i)
-This function is called from within a C extension function to get
-the @code{i}-th argument from the function call.
-The first argument is argument zero.
-
-@cindex @code{get_actual_argument()} internal function
-@cindex internal function, @code{get_actual_argument()}
-@item NODE *get_actual_argument(int i,
-@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ int@ optional,@ int@ wantarray);
-This function retrieves a particular argument @code{i}. @code{wantarray} is @code{TRUE}
-if the argument should be an array, @code{FALSE} otherwise. If @code{optional} is
-@code{TRUE}, the argument need not have been supplied. If it wasn't, the return
-value is @code{NULL}. It is a fatal error if @code{optional} is @code{TRUE} but
-the argument was not provided.
-
-@cindex @code{get_scalar_argument()} internal macro
-@cindex internal macro, @code{get_scalar_argument()}
-@item get_scalar_argument(i, opt)
-This is a convenience macro that calls @code{get_actual_argument()}.
-
-@cindex @code{get_array_argument()} internal macro
-@cindex internal macro, @code{get_array_argument()}
-@item get_array_argument(i, opt)
-This is a convenience macro that calls @code{get_actual_argument()}.
-
-@cindex functions, return values@comma{} setting
-
-@cindex @code{ERRNO} variable
-@cindex @code{update_ERRNO()} internal function
-@cindex internal function, @code{update_ERRNO()}
-@item void update_ERRNO(void)
-This function is called from within a C extension function to set
-the value of @command{gawk}'s @code{ERRNO} variable, based on the current
-value of the C @code{errno} global variable.
-It is provided as a convenience.
-
-@cindex @code{ERRNO} variable
-@cindex @code{update_ERRNO_saved()} internal function
-@cindex internal function, @code{update_ERRNO_saved()}
-@item void update_ERRNO_saved(int errno_saved)
-This function is called from within a C extension function to set
-the value of @command{gawk}'s @code{ERRNO} variable, based on the error
-value provided as the argument.
-It is provided as a convenience.
-
-@cindex @code{ENVIRON} array
-@cindex @code{PROCINFO} array
-@cindex @code{register_deferred_variable()} internal function
-@cindex internal function, @code{register_deferred_variable()}
-@item void register_deferred_variable(const char *name, NODE *(*load_func)(void))
-This function is called to register a function to be called when a
-reference to an undefined variable with the given name is encountered.
-The callback function will never be called if the variable exists already,
-so, unless the calling code is running at program startup, it should first
-check whether a variable of the given name already exists.
-The argument function must return a pointer to a @code{NODE} containing the
-newly created variable. This function is used to implement the builtin
-@code{ENVIRON} and @code{PROCINFO} arrays, so you can refer to them
-for examples.
-
-@cindex @code{IOBUF} internal structure
-@cindex internal structure, @code{IOBUF}
-@cindex @code{iop_alloc()} internal function
-@cindex internal function, @code{iop_alloc()}
-@cindex @code{get_record()} input method
-@cindex @code{close_func}() input method
-@cindex @code{INVALID_HANDLE} internal constant
-@cindex internal constant, @code{INVALID_HANDLE}
-@cindex XML (eXtensible Markup Language)
-@cindex eXtensible Markup Language (XML)
-@cindex @code{register_open_hook()} internal function
-@cindex internal function, @code{register_open_hook()}
-@item void register_open_hook(void *(*open_func)(IOBUF *))
-This function is called to register a function to be called whenever
-a new data file is opened, leading to the creation of an @code{IOBUF}
-structure in @code{iop_alloc()}. After creating the new @code{IOBUF},
-@code{iop_alloc()} will call (in reverse order of registration, so the last
-function registered is called first) each open hook until one returns
-non-@code{NULL}. If any hook returns a non-@code{NULL} value, that value is assigned
-to the @code{IOBUF}'s @code{opaque} field (which will presumably point
-to a structure containing additional state associated with the input
-processing), and no further open hooks are called.
-
-The function called will most likely want to set the @code{IOBUF}'s
-@code{get_record} method to indicate that future input records should
-be retrieved by calling that method instead of using the standard
-@command{gawk} input processing.
-
-And the function will also probably want to set the @code{IOBUF}'s
-@code{close_func} method to be called when the file is closed to clean
-up any state associated with the input.
-
-Finally, hook functions should be prepared to receive an @code{IOBUF}
-structure where the @code{fd} field is set to @code{INVALID_HANDLE},
-meaning that @command{gawk} was not able to open the file itself. In
-this case, the hook function must be able to successfully open the file
-and place a valid file descriptor there.
-
-Currently, for example, the hook function facility is used to implement
-the XML parser shared library extension. For more info, please look in
-@file{awk.h} and in @file{io.c}.
-@end table
+@node Derived Files
+@appendixsubsec Why Generated Files Are Kept In @command{git}
-An argument that is supposed to be an array needs to be handled with
-some extra code, in case the array being passed in is actually
-from a function parameter.
+@c From emails written March 22, 2012, to the gawk developers list.
-The following boilerplate code shows how to do this:
+If you look at the @command{gawk} source in the @command{git}
+repository, you will notice that it includes files that are automatically
+generated by GNU infrastructure tools, such as @file{Makefile.in} from
+@command{automake} and even @file{configure} from @command{autoconf}.
-@example
-NODE *the_arg;
+This is different from many Free Software projects that do not store
+the derived files, because that keeps the repository less cluttered,
+and it is easier to see the substantive changes when comparing versions
+and trying to understand what changed between commits.
-/* assume need 3rd arg, 0-based */
-the_arg = get_array_argument(2, FALSE);
-@end example
+However, there are two reasons why the @command{gawk} maintainer
+likes to have everything in the repository.
-Again, you should spend time studying the @command{gawk} internals;
-don't just blindly copy this code.
-@c ENDOFRANGE gawint
+First, because it is then easy to reproduce any given version completely,
+without relying upon the availability of (older, likely obsolete, and
+maybe even impossible to find) other tools.
-@node Plugin License
-@appendixsubsec Extension Licensing
+As an extreme example, if you ever even think about trying to compile,
+oh, say, the V7 @command{awk}, you will discover that not only do you
+have to bootstrap the V7 @command{yacc} to do so, but you also need the
+V7 @command{lex}. And the latter is pretty much impossible to bring up
+on a modern GNU/Linux system.@footnote{We tried. It was painful.}
-Every dynamic extension should define the global symbol
-@code{plugin_is_GPL_compatible} to assert that it has been licensed under
-a GPL-compatible license. If this symbol does not exist, @command{gawk}
-will emit a fatal error and exit.
+(Or, let's say @command{gawk} 1.2 required @command{bison} whatever-it-was
+in 1989 and that there was no @file{awkgram.c} file in the repository. Is
+there a guarantee that we could find that @command{bison} version? Or that
+@emph{it} would build?)
-The declared type of the symbol should be @code{int}. It does not need
-to be in any allocated section, though. The code merely asserts that
-the symbol exists in the global scope. Something like this is enough:
+If the repository has all the generated files, then it's easy to just check
+them out and build. (Or @emph{easier}, depending upon how far back we go.
+@code{:-)})
-@example
-int plugin_is_GPL_compatible;
-@end example
-
-@node Sample Library
-@appendixsubsec Example: Directory and File Operation Built-ins
-@c STARTOFRANGE chdirg
-@cindex @code{chdir()} function@comma{} implementing in @command{gawk}
-@c STARTOFRANGE statg
-@cindex @code{stat()} function@comma{} implementing in @command{gawk}
-@c STARTOFRANGE filre
-@cindex files, information about@comma{} retrieving
-@c STARTOFRANGE dirch
-@cindex directories, changing
-
-Two useful functions that are not in @command{awk} are @code{chdir()}
-(so that an @command{awk} program can change its directory) and
-@code{stat()} (so that an @command{awk} program can gather information about
-a file).
-This @value{SECTION} implements these functions for @command{gawk} in an
-external extension library.
-
-@menu
-* Internal File Description:: What the new functions will do.
-* Internal File Ops:: The code for internal file operations.
-* Using Internal File Ops:: How to use an external extension.
-@end menu
-
-@node Internal File Description
-@appendixsubsubsec Using @code{chdir()} and @code{stat()}
-
-This @value{SECTION} shows how to use the new functions at the @command{awk}
-level once they've been integrated into the running @command{gawk}
-interpreter.
-Using @code{chdir()} is very straightforward. It takes one argument,
-the new directory to change to:
-
-@example
-@dots{}
-newdir = "/home/arnold/funstuff"
-ret = chdir(newdir)
-if (ret < 0) @{
- printf("could not change to %s: %s\n",
- newdir, ERRNO) > "/dev/stderr"
- exit 1
-@}
-@dots{}
-@end example
+And that brings us to the second (and stronger) reason why all the files
+really need to be in @command{git}. It boils down to who do you cater
+to---the @command{gawk} developer(s), or the user who just wants to check
+out a version and try it out?
-The return value is negative if the @code{chdir} failed,
-and @code{ERRNO}
-(@pxref{Built-in Variables})
-is set to a string indicating the error.
+The @command{gawk} maintainer
+wants it to be possible for any interested @command{awk} user in the
+world to just clone the repository, check out the branch of interest and
+build it. Without their having to have the correct version(s) of the
+autotools.@footnote{There is one GNU program that is (in our opinion)
+severely difficult to bootstrap from the @command{git} repository. For
+example, on the author's old (but still working) PowerPC macintosh with
+Mac OS X 10.5, it was necessary to bootstrap a ton of software, starting
+with @command{git} itself, in order to try to work with the latest code.
+It's not pleasant, and especially on older systems, it's a big waste
+of time.
-Using @code{stat()} is a bit more complicated.
-The C @code{stat()} function fills in a structure that has a fair
-amount of information.
-The right way to model this in @command{awk} is to fill in an associative
-array with the appropriate information:
+Starting with the latest tarball was no picnic either. The maintainers
+had dropped @file{.gz} and @file{.bz2} files and only distribute
+@file{.tar.xz} files. It was necessary to bootstrap @command{xz} first!}
+That is the point of the @file{bootstrap.sh} file. It touches the
+various other files in the right order such that
-@c broke printf for page breaking
@example
-file = "/home/arnold/.profile"
-fdata[1] = "x" # force `fdata' to be an array
-ret = stat(file, fdata)
-if (ret < 0) @{
- printf("could not stat %s: %s\n",
- file, ERRNO) > "/dev/stderr"
- exit 1
-@}
-printf("size of %s is %d bytes\n", file, fdata["size"])
+# The canonical incantation for building GNU software:
+./bootstrap.sh && ./configure && make
@end example
-The @code{stat()} function always clears the data array, even if
-the @code{stat()} fails. It fills in the following elements:
+@noindent
+will @emph{just work}.
-@table @code
-@item "name"
-The name of the file that was @code{stat()}'ed.
+This is extremely important for the @code{master} and
+@code{gawk-@var{X}.@var{Y}-stable} branches.
-@item "dev"
-@itemx "ino"
-The file's device and inode numbers, respectively.
+Further, the @command{gawk} maintainer would argue that it's also
+important for the @command{gawk} developers. When he tried to check out
+the @code{xgawk} branch@footnote{A branch created by one of the other
+developers that did not include the generated files.} to build it, he
+couldn't. (No @file{ltmain.sh} file, and he had no idea how to create it,
+and that was not the only problem.)
-@item "mode"
-The file's mode, as a numeric value. This includes both the file's
-type and its permissions.
-
-@item "nlink"
-The number of hard links (directory entries) the file has.
+He felt @emph{extremely} frustrated. With respect to that branch,
+the maintainer is no different than Jane User who wants to try to build
+@code{gawk-4.0-stable} or @code{master} from the repository.
-@item "uid"
-@itemx "gid"
-The numeric user and group ID numbers of the file's owner.
+Thus, the maintainer thinks that it's not just important, but critical,
+that for any given branch, the above incantation @emph{just works}.
-@item "size"
-The size in bytes of the file.
+@c So - that's my reasoning and philosophy.
-@item "blocks"
-The number of disk blocks the file actually occupies. This may not
-be a function of the file's size if the file has holes.
+What are some of the consequences and/or actions to take?
-@item "atime"
-@itemx "mtime"
-@itemx "ctime"
-The file's last access, modification, and inode update times,
-respectively. These are numeric timestamps, suitable for formatting
-with @code{strftime()}
-(@pxref{Built-in}).
+@enumerate 1
+@item
+We don't mind that there are differing files in the different branches
+as a result of different versions of the autotools.
-@item "pmode"
-The file's ``printable mode.'' This is a string representation of
-the file's type and permissions, such as what is produced by
-@samp{ls -l}---for example, @code{"drwxr-xr-x"}.
+@enumerate A
+@item
+It's the maintainer's job to merge them and he will deal with it.
-@item "type"
-A printable string representation of the file's type. The value
-is one of the following:
+@item
+He is really good at @samp{git diff x y > /tmp/diff1 ; gvim /tmp/diff1} to
+remove the diffs that aren't of interest in order to review code. @code{:-)}
+@end enumerate
-@table @code
-@item "blockdev"
-@itemx "chardev"
-The file is a block or character device (``special file'').
+@item
+It would certainly help if everyone used the same versions of the GNU tools
+as he does, which in general are the latest released versions of
+@command{automake},
+@command{autoconf},
+@command{bison},
+and
+@command{gettext}.
@ignore
-@item "door"
-The file is a Solaris ``door'' (special file used for
-interprocess communications).
+If it would help if I sent out an "I just upgraded to version x.y
+of tool Z" kind of message to this list, I can do that. Up until
+now it hasn't been a real issue since I'm the only one who's been
+dorking with the configuration machinery.
@end ignore
-@item "directory"
-The file is a directory.
-
-@item "fifo"
-The file is a named-pipe (also known as a FIFO).
-
-@item "file"
-The file is just a regular file.
-
-@item "socket"
-The file is an @code{AF_UNIX} (``Unix domain'') socket in the
-filesystem.
-
-@item "symlink"
-The file is a symbolic link.
-@end table
-@end table
-
-Several additional elements may be present depending upon the operating
-system and the type of the file. You can test for them in your @command{awk}
-program by using the @code{in} operator
-(@pxref{Reference to Elements}):
-
-@table @code
-@item "blksize"
-The preferred block size for I/O to the file. This field is not
-present on all POSIX-like systems in the C @code{stat} structure.
-
-@item "linkval"
-If the file is a symbolic link, this element is the name of the
-file the link points to (i.e., the value of the link).
-
-@item "rdev"
-@itemx "major"
-@itemx "minor"
-If the file is a block or character device file, then these values
-represent the numeric device number and the major and minor components
-of that number, respectively.
-@end table
-
-@node Internal File Ops
-@appendixsubsubsec C Code for @code{chdir()} and @code{stat()}
-
-Here is the C code for these extensions. They were written for
-GNU/Linux. The code needs some more work for complete portability
-to other POSIX-compliant systems:@footnote{This version is edited
-slightly for presentation. See
-@file{extension/filefuncs.c} in the @command{gawk} distribution
-for the complete version.}
-
-@c break line for page breaking
-@example
-#include "awk.h"
-
-#include <sys/sysmacros.h>
-
-int plugin_is_GPL_compatible;
-
-/* do_chdir --- provide dynamically loaded chdir() builtin for gawk */
-
-static NODE *
-do_chdir(int nargs)
-@{
- NODE *newdir;
- int ret = -1;
-
- if (do_lint && get_curfunc_arg_count() != 1)
- lintwarn("chdir: called with incorrect number of arguments");
-
- newdir = get_scalar_argument(0, FALSE);
-@end example
-
-The file includes the @code{"awk.h"} header file for definitions
-for the @command{gawk} internals. It includes @code{<sys/sysmacros.h>}
-for access to the @code{major()} and @code{minor}() macros.
-
-@cindex programming conventions, @command{gawk} internals
-By convention, for an @command{awk} function @code{foo}, the function that
-implements it is called @samp{do_foo}. The function should take
-a @samp{int} argument, usually called @code{nargs}, that
-represents the number of defined arguments for the function. The @code{newdir}
-variable represents the new directory to change to, retrieved
-with @code{get_scalar_argument()}. Note that the first argument is
-numbered zero.
-
-This code actually accomplishes the @code{chdir()}. It first forces
-the argument to be a string and passes the string value to the
-@code{chdir()} system call. If the @code{chdir()} fails, @code{ERRNO}
-is updated.
-
-@example
- (void) force_string(newdir);
- ret = chdir(newdir->stptr);
- if (ret < 0)
- update_ERRNO();
-@end example
-
-Finally, the function returns the return value to the @command{awk} level:
-
-@example
- return make_number((AWKNUM) ret);
-@}
-@end example
-
-The @code{stat()} built-in is more involved. First comes a function
-that turns a numeric mode into a printable representation
-(e.g., 644 becomes @samp{-rw-r--r--}). This is omitted here for brevity:
+@enumerate A
+@item
+Installing from source is quite easy. It's how the maintainer worked for years
+under Fedora.
+He had @file{/usr/local/bin} at the front of hs @env{PATH} and just did:
-@c break line for page breaking
@example
-/* format_mode --- turn a stat mode field into something readable */
-
-static char *
-format_mode(unsigned long fmode)
-@{
- @dots{}
-@}
+wget http://ftp.gnu.org/gnu/@var{package}/@var{package}-@var{x}.@var{y}.@var{z}.tar.gz
+tar -xpzvf @var{package}-@var{x}.@var{y}.@var{z}.tar.gz
+cd @var{package}-@var{x}.@var{y}.@var{z}
+./configure && make && make check
+make install # as root
@end example
-Next comes the @code{do_stat()} function. It starts with
-variable declarations and argument checking:
+@item
+These days the maintainer uses Ubuntu 10.11 which is medium current, but
+he is already doing the above for @command{autoconf} and @command{bison}.
@ignore
-Changed message for page breaking. Used to be:
- "stat: called with incorrect number of arguments (%d), should be 2",
+(C. Rant: Recent Linux versions with GNOME 3 really suck. What
+ are all those people thinking? Fedora 15 was such a bust it drove
+ me to Ubuntu, but Ubuntu 11.04 and 11.10 are totally unusable from
+ a UI perspective. Bleah.)
@end ignore
-@example
-/* do_stat --- provide a stat() function for gawk */
-
-static NODE *
-do_stat(int nargs)
-@{
- NODE *file, *array, *tmp;
- struct stat sbuf;
- int ret;
- NODE **aptr;
- char *pmode; /* printable mode */
- char *type = "unknown";
-
- if (do_lint && get_curfunc_arg_count() > 2)
- lintwarn("stat: called with too many arguments");
-@end example
-
-Then comes the actual work. First, the function gets the arguments.
-Then, it always clears the array.
-The code use @code{lstat()} (instead of @code{stat()})
-to get the file information,
-in case the file is a symbolic link.
-If there's an error, it sets @code{ERRNO} and returns:
-
-@c comment made multiline for page breaking
-@example
- /* file is first arg, array to hold results is second */
- file = get_scalar_argument(0, FALSE);
- array = get_array_argument(1, FALSE);
-
- /* empty out the array */
- assoc_clear(array);
-
- /* lstat the file, if error, set ERRNO and return */
- (void) force_string(file);
- ret = lstat(file->stptr, & sbuf);
- if (ret < 0) @{
- update_ERRNO();
- return make_number((AWKNUM) ret);
- @}
-@end example
-
-Now comes the tedious part: filling in the array. Only a few of the
-calls are shown here, since they all follow the same pattern:
-
-@example
- /* fill in the array */
- aptr = assoc_lookup(array, tmp = make_string("name", 4), FALSE);
- *aptr = dupnode(file);
- unref(tmp);
-
- aptr = assoc_lookup(array, tmp = make_string("mode", 4), FALSE);
- *aptr = make_number((AWKNUM) sbuf.st_mode);
- unref(tmp);
-
- aptr = assoc_lookup(array, tmp = make_string("pmode", 5), FALSE);
- pmode = format_mode(sbuf.st_mode);
- *aptr = make_string(pmode, strlen(pmode));
- unref(tmp);
-@end example
-
-When done, return the @code{lstat()} return value:
-
-@example
-
- return make_number((AWKNUM) ret);
-@}
-@end example
-
-@cindex programming conventions, @command{gawk} internals
-Finally, it's necessary to provide the ``glue'' that loads the
-new function(s) into @command{gawk}. By convention, each library has
-a routine named @code{dlload()} that does the job:
+@end enumerate
-@example
-/* dlload --- load new builtins in this library */
+@ignore
+@item
+If someone still feels really strongly about all this, then perhaps they
+can have two branches, one for their development with just the clean
+changes, and one that is buildable (xgawk and xgawk-buildable, maybe).
+Or, as I suggested in another mail, make commits in pairs, the first with
+the "real" changes and the second with "everything else needed for
+ building".
+@end ignore
+@end enumerate
-NODE *
-dlload(NODE *tree, void *dl)
-@{
- make_builtin("chdir", do_chdir, 1);
- make_builtin("stat", do_stat, 2);
- return make_number((AWKNUM) 0);
-@}
-@end example
+Most of the above was originally written by the maintainer to other
+@command{gawk} developers. It raised the objection from one of
+the developers ``@dots{} that anybody pulling down the source from
+@command{git} is not an end user.''
-And that's it! As an exercise, consider adding functions to
-implement system calls such as @code{chown()}, @code{chmod()},
-and @code{umask()}.
+However, this is not true. There are ``power @command{awk} users''
+who can build @command{gawk} (using the magic incantation shown previously)
+but who can't program in C. Thus, the major branches should be
+kept buildable all the time.
-@node Using Internal File Ops
-@appendixsubsubsec Integrating the Extensions
+It was then suggested that there be a @command{cron} job to create
+nightly tarballs of ``the source.'' Here, the problem is that there
+are source trees, corresponding to the various branches! So,
+nightly tar balls aren't the answer, especially as the repository can go
+for weeks without significant change being introduced.
-@cindex @command{gawk}, interpreter@comma{} adding code to
-Now that the code is written, it must be possible to add it at
-runtime to the running @command{gawk} interpreter. First, the
-code must be compiled. Assuming that the functions are in
-a file named @file{filefuncs.c}, and @var{idir} is the location
-of the @command{gawk} include files,
-the following steps create
-a GNU/Linux shared library:
+Fortunately, the @command{git} server can meet this need. For any given
+branch named @var{branchname}, use:
@example
-$ @kbd{gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -I@var{idir} filefuncs.c}
-$ @kbd{ld -o filefuncs.so -shared filefuncs.o}
+wget http://git.savannah.gnu.org/cgit/gawk.git/snapshot/gawk-@var{branchname}.tar.gz
@end example
-@cindex @code{extension()} function (@command{gawk})
-Once the library exists, it is loaded by calling the @code{extension()}
-built-in function.
-This function takes two arguments: the name of the
-library to load and the name of a function to call when the library
-is first loaded. This function adds the new functions to @command{gawk}.
-It returns the value returned by the initialization function
-within the shared library:
-
-@example
-# file testff.awk
-BEGIN @{
- extension("./filefuncs.so", "dlload")
-
- chdir(".") # no-op
-
- data[1] = 1 # force `data' to be an array
- print "Info for testff.awk"
- ret = stat("testff.awk", data)
- print "ret =", ret
- for (i in data)
- printf "data[\"%s\"] = %s\n", i, data[i]
- print "testff.awk modified:",
- strftime("%m %d %y %H:%M:%S", data["mtime"])
-
- print "\nInfo for JUNK"
- ret = stat("JUNK", data)
- print "ret =", ret
- for (i in data)
- printf "data[\"%s\"] = %s\n", i, data[i]
- print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"])
-@}
-@end example
+@noindent
+to retrieve a snapshot of the given branch.
-Here are the results of running the program:
-
-@example
-$ @kbd{gawk -f testff.awk}
-@print{} Info for testff.awk
-@print{} ret = 0
-@print{} data["size"] = 607
-@print{} data["ino"] = 14945891
-@print{} data["name"] = testff.awk
-@print{} data["pmode"] = -rw-rw-r--
-@print{} data["nlink"] = 1
-@print{} data["atime"] = 1293993369
-@print{} data["mtime"] = 1288520752
-@print{} data["mode"] = 33204
-@print{} data["blksize"] = 4096
-@print{} data["dev"] = 2054
-@print{} data["type"] = file
-@print{} data["gid"] = 500
-@print{} data["uid"] = 500
-@print{} data["blocks"] = 8
-@print{} data["ctime"] = 1290113572
-@print{} testff.awk modified: 10 31 10 12:25:52
-@print{}
-@print{} Info for JUNK
-@print{} ret = -1
-@print{} JUNK modified: 01 01 70 02:00:00
-@end example
-@c ENDOFRANGE filre
-@c ENDOFRANGE dirch
-@c ENDOFRANGE statg
-@c ENDOFRANGE chdirg
-@c ENDOFRANGE gladfgaw
-@c ENDOFRANGE adfugaw
-@c ENDOFRANGE fubadgaw
@node Future Extensions
@appendixsec Probable Future Extensions
@@ -29954,12 +31398,8 @@ Following is a list of probable future changes visible at the
@c these are ordered by likelihood
@table @asis
-@item Loadable module interface
-It is not clear that the @command{awk}-level interface to the
-modules facility is as good as it should be. The interface needs to be
-redesigned, particularly taking namespace issues into account, as
-well as possibly including issues such as library search path order
-and versioning.
+@item Databases
+It may be possible to map a GDBM/NDBM/SDBM file into an @command{awk} array.
@item @code{RECLEN} variable for fixed-length records
Along with @code{FIELDWIDTHS}, this would speed up the processing of
@@ -29967,9 +31407,6 @@ fixed-length records.
@code{PROCINFO["RS"]} would be @code{"RS"} or @code{"RECLEN"},
depending upon which kind of record processing is in effect.
-@item Databases
-It may be possible to map a GDBM/NDBM/SDBM file into an @command{awk} array.
-
@item More @code{lint} warnings
There are more things that could be checked for portability.
@end table
@@ -29978,21 +31415,6 @@ Following is a list of probable improvements that will make @command{gawk}'s
source code easier to work with:
@table @asis
-@item Loadable module mechanics
-The current extension mechanism works
-(@pxref{Dynamic Extensions}),
-but is rather primitive. It requires a fair amount of manual work
-to create and integrate a loadable module.
-Nor is the current mechanism as portable as might be desired.
-The GNU @command{libtool} package provides a number of features that
-would make using loadable modules much easier.
-@command{gawk} should be changed to use @command{libtool}.
-
-@item Loadable module internals
-The API to its internals that @command{gawk} ``exports'' should be revised.
-Too many things are needlessly exposed. A new API should be designed
-and implemented to make module writing easier.
-
@item Better array subscript management
@command{gawk}'s management of array subscript storage could use revamping,
so that using the same value to index multiple arrays only
@@ -30024,7 +31446,6 @@ other introductory texts that you should refer to instead.)
@menu
* Basic High Level:: The high level view.
* Basic Data Typing:: A very quick intro to data types.
-* Floating Point Issues:: Stuff to know about floating-point numbers.
@end menu
@node Basic High Level
@@ -30175,47 +31596,10 @@ Individual variables, as well as numeric and string variables, are
referred to as @dfn{scalar} values.
Groups of values, such as arrays, are not scalars.
-@cindex integers
-@cindex floating-point, numbers
-@cindex numbers, floating-point
-Within computers, there are two kinds of numeric values: @dfn{integers}
-and @dfn{floating-point}.
-In school, integer values were referred to as ``whole'' numbers---that is,
-numbers without any fractional part, such as 1, 42, or @minus{}17.
-The advantage to integer numbers is that they represent values exactly.
-The disadvantage is that their range is limited. On most systems,
-this range is @minus{}2,147,483,648 to 2,147,483,647.
-However, many systems now support a range from
-@minus{}9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
-
-@cindex unsigned integers
-@cindex integers, unsigned
-Integer values come in two flavors: @dfn{signed} and @dfn{unsigned}.
-Signed values may be negative or positive, with the range of values just
-described.
-Unsigned values are always positive. On most systems,
-the range is from 0 to 4,294,967,295.
-However, many systems now support a range from
-0 to 18,446,744,073,709,551,615.
-
-@cindex double precision floating-point
-@cindex single precision floating-point
-Floating-point numbers represent what are called ``real'' numbers; i.e.,
-those that do have a fractional part, such as 3.1415927.
-The advantage to floating-point numbers is that they
-can represent a much larger range of values.
-The disadvantage is that there are numbers that they cannot represent
-exactly.
-@command{awk} uses @dfn{double precision} floating-point numbers, which
-can hold more digits than @dfn{single precision}
-floating-point numbers.
-Floating-point issues are discussed more fully in
-@ref{Floating Point Issues}.
-
-At the very lowest level, computers store values as groups of binary digits,
-or @dfn{bits}. Modern computers group bits into groups of eight, called @dfn{bytes}.
-Advanced applications sometimes have to manipulate bits directly,
-and @command{gawk} provides functions for doing so.
+@ref{General Arithmetic}, provided a basic introduction to numeric
+types (integer and floating-point) and how they are used in a computer.
+Please review that information, including a number of caveats that
+were presented.
@cindex null strings
While you are probably used to the idea of a number without a value (i.e., zero),
@@ -30239,6 +31623,11 @@ plus 0 times 1, or decimal 10.
Octal and hexadecimal are discussed more in
@ref{Nondecimal-numbers}.
+At the very lowest level, computers store values as groups of binary digits,
+or @dfn{bits}. Modern computers group bits into groups of eight, called @dfn{bytes}.
+Advanced applications sometimes have to manipulate bits directly,
+and @command{gawk} provides functions for doing so.
+
Programs are written in programming languages.
Hundreds, if not thousands, of programming languages exist.
One of the most popular is the C programming language.
@@ -30258,239 +31647,6 @@ standard for C. This standard became an ISO standard in 1990.
In 1999, a revised ISO C standard was approved and released.
Where it makes sense, POSIX @command{awk} is compatible with 1999 ISO C.
-@node Floating Point Issues
-@appendixsec Floating-Point Number Caveats
-
-As mentioned earlier, floating-point numbers represent what are called
-``real'' numbers, i.e., those that have a fractional part. @command{awk}
-uses double precision floating-point numbers to represent all
-numeric values. This @value{SECTION} describes some of the issues
-involved in using floating-point numbers.
-
-There is a very nice
-@uref{http://www.validlab.com/goldberg/paper.pdf, paper on floating-point arithmetic}
-by David Goldberg,
-``What Every Computer Scientist Should Know About Floating-point Arithmetic,''
-@cite{ACM Computing Surveys} @strong{23}, 1 (1991-03), 5-48.
-This is worth reading if you are interested in the details,
-but it does require a background in computer science.
-
-@menu
-* String Conversion Precision:: The String Value Can Lie.
-* Unexpected Results:: Floating Point Numbers Are Not Abstract
- Numbers.
-* POSIX Floating Point Problems:: Standards Versus Existing Practice.
-@end menu
-
-@node String Conversion Precision
-@appendixsubsec The String Value Can Lie
-
-Internally, @command{awk} keeps both the numeric value
-(double precision floating-point) and the string value for a variable.
-Separately, @command{awk} keeps
-track of what type the variable has
-(@pxref{Typing and Comparison}),
-which plays a role in how variables are used in comparisons.
-
-It is important to note that the string value for a number may not
-reflect the full value (all the digits) that the numeric value
-actually contains.
-The following program (@file{values.awk}) illustrates this:
-
-@example
-@{
- sum = $1 + $2
- # see it for what it is
- printf("sum = %.12g\n", sum)
- # use CONVFMT
- a = "<" sum ">"
- print "a =", a
- # use OFMT
- print "sum =", sum
-@}
-@end example
-
-@noindent
-This program shows the full value of the sum of @code{$1} and @code{$2}
-using @code{printf}, and then prints the string values obtained
-from both automatic conversion (via @code{CONVFMT}) and
-from printing (via @code{OFMT}).
-
-Here is what happens when the program is run:
-
-@example
-$ @kbd{echo 3.654321 1.2345678 | awk -f values.awk}
-@print{} sum = 4.8888888
-@print{} a = <4.88889>
-@print{} sum = 4.88889
-@end example
-
-This makes it clear that the full numeric value is different from
-what the default string representations show.
-
-@code{CONVFMT}'s default value is @code{"%.6g"}, which yields a value with
-at least six significant digits. For some applications, you might want to
-change it to specify more precision.
-On most modern machines, most of the time,
-17 digits is enough to capture a floating-point number's
-value exactly.@footnote{Pathological cases can require up to
-752 digits (!), but we doubt that you need to worry about this.}
-
-@node Unexpected Results
-@appendixsubsec Floating Point Numbers Are Not Abstract Numbers
-
-@cindex floating-point, numbers
-Unlike numbers in the abstract sense (such as what you studied in high school
-or college math), numbers stored in computers are limited in certain ways.
-They cannot represent an infinite number of digits, nor can they always
-represent things exactly.
-In particular,
-floating-point numbers cannot
-always represent values exactly. Here is an example:
-
-@example
-$ @kbd{awk '@{ printf("%010d\n", $1 * 100) @}'}
-515.79
-@print{} 0000051579
-515.80
-@print{} 0000051579
-515.81
-@print{} 0000051580
-515.82
-@print{} 0000051582
-@kbd{@value{CTL}-d}
-@end example
-
-@noindent
-This shows that some values can be represented exactly,
-whereas others are only approximated. This is not a ``bug''
-in @command{awk}, but simply an artifact of how computers
-represent numbers.
-
-@cindex negative zero
-@cindex positive zero
-@cindex zero@comma{} negative vs.@: positive
-Another peculiarity of floating-point numbers on modern systems
-is that they often have more than one representation for the number zero!
-In particular, it is possible to represent ``minus zero'' as well as
-regular, or ``positive'' zero.
-
-This example shows that negative and positive zero are distinct values
-when stored internally, but that they are in fact equal to each other,
-as well as to ``regular'' zero:
-
-@example
-$ @kbd{gawk 'BEGIN @{ mz = -0 ; pz = 0}
-> @kbd{printf "-0 = %g, +0 = %g, (-0 == +0) -> %d\n", mz, pz, mz == pz}
-> @kbd{printf "mz == 0 -> %d, pz == 0 -> %d\n", mz == 0, pz == 0}
-> @kbd{@}'}
-@print{} -0 = -0, +0 = 0, (-0 == +0) -> 1
-@print{} mz == 0 -> 1, pz == 0 -> 1
-@end example
-
-It helps to keep this in mind should you process numeric data
-that contains negative zero values; the fact that the zero is negative
-is noted and can affect comparisons.
-
-@node POSIX Floating Point Problems
-@appendixsubsec Standards Versus Existing Practice
-
-Historically, @command{awk} has converted any non-numeric looking string
-to the numeric value zero, when required. Furthermore, the original
-definition of the language and the original POSIX standards specified that
-@command{awk} only understands decimal numbers (base 10), and not octal
-(base 8) or hexadecimal numbers (base 16).
-
-Changes in the language of the
-2001 and 2004 POSIX standard can be interpreted to imply that @command{awk}
-should support additional features. These features are:
-
-@itemize @bullet
-@item
-Interpretation of floating point data values specified in hexadecimal
-notation (@samp{0xDEADBEEF}). (Note: data values, @emph{not}
-source code constants.)
-
-@item
-Support for the special IEEE 754 floating point values ``Not A Number''
-(NaN), positive Infinity (``inf'') and negative Infinity (``@minus{}inf'').
-In particular, the format for these values is as specified by the ISO 1999
-C standard, which ignores case and can allow machine-dependent additional
-characters after the @samp{nan} and allow either @samp{inf} or @samp{infinity}.
-@end itemize
-
-The first problem is that both of these are clear changes to historical
-practice:
-
-@itemize @bullet
-@item
-The @command{gawk} maintainer feels that supporting hexadecimal floating
-point values, in particular, is ugly, and was never intended by the
-original designers to be part of the language.
-
-@item
-Allowing completely alphabetic strings to have valid numeric
-values is also a very severe departure from historical practice.
-@end itemize
-
-The second problem is that the @code{gawk} maintainer feels that this
-interpretation of the standard, which requires a certain amount of
-``language lawyering'' to arrive at in the first place, was not even
-intended by the standard developers. In other words, ``we see how you
-got where you are, but we don't think that that's where you want to be.''
-
-The 2008 POSIX standard added explicit wording to allow, but not require,
-that @command{awk} support hexadecimal floating point values and
-special values for ``Not A Number'' and infinity.
-
-Although the @command{gawk} maintainer continues to feel that
-providing those features is inadvisable,
-nevertheless, on systems that support IEEE floating point, it seems
-reasonable to provide @emph{some} way to support NaN and Infinity values.
-The solution implemented in @command{gawk} is as follows:
-
-@itemize @bullet
-@item
-With the @option{--posix} command-line option, @command{gawk} becomes
-``hands off.'' String values are passed directly to the system library's
-@code{strtod()} function, and if it successfully returns a numeric value,
-that is what's used.@footnote{You asked for it, you got it.}
-By definition, the results are not portable across
-different systems. They are also a little surprising:
-
-@example
-$ @kbd{echo nanny | gawk --posix '@{ print $1 + 0 @}'}
-@print{} nan
-$ @kbd{echo 0xDeadBeef | gawk --posix '@{ print $1 + 0 @}'}
-@print{} 3735928559
-@end example
-
-@item
-Without @option{--posix}, @command{gawk} interprets the four strings
-@samp{+inf},
-@samp{-inf},
-@samp{+nan},
-and
-@samp{-nan}
-specially, producing the corresponding special numeric values.
-The leading sign acts a signal to @command{gawk} (and the user)
-that the value is really numeric. Hexadecimal floating point is
-not supported (unless you also use @option{--non-decimal-data},
-which is @emph{not} recommended). For example:
-
-@example
-$ @kbd{echo nanny | gawk '@{ print $1 + 0 @}'}
-@print{} 0
-$ @kbd{echo +nan | gawk '@{ print $1 + 0 @}'}
-@print{} nan
-$ @kbd{echo 0xDeadBeef | gawk '@{ print $1 + 0 @}'}
-@print{} 0
-@end example
-
-@command{gawk} does ignore case in the four special values.
-Thus @samp{+nan} and @samp{+NaN} are the same.
-@end itemize
-
@c ENDOFRANGE procon
@node Glossary
diff --git a/doc/gawkinet.info b/doc/gawkinet.info
index 0a0d69d8..c8ce6b8d 100644
--- a/doc/gawkinet.info
+++ b/doc/gawkinet.info
@@ -613,7 +613,7 @@ tcp, udp x 0 x Invalid
tcp, udp 0 0 0 Invalid
tcp, udp 0 x 0 Invalid
-Table 2.1: /inet Special File Components
+Table 2.1: /inet Special File Components
In general, TCP is the preferred mechanism to use. It is the
simplest protocol to understand and to use. Use UDP only if
@@ -4358,40 +4358,40 @@ Node: Using Networking17966
Node: Gawk Special Files20284
Node: Special File Fields22094
Ref: table-inet-components25967
-Node: Comparing Protocols27287
-Node: File /inet/tcp27820
-Node: File /inet/udp28846
-Node: TCP Connecting29944
-Node: Troubleshooting32282
-Ref: Troubleshooting-Footnote-135334
-Node: Interacting35903
-Node: Setting Up38633
-Node: Email42127
-Node: Web page44453
-Ref: Web page-Footnote-147258
-Node: Primitive Service47455
-Node: Interacting Service50189
-Ref: Interacting Service-Footnote-159318
-Node: CGI Lib59350
-Node: Simple Server66311
-Ref: Simple Server-Footnote-174034
-Node: Caveats74135
-Node: Challenges75278
-Node: Some Applications and Techniques83957
-Node: PANIC86414
-Node: GETURL88132
-Node: REMCONF90755
-Node: URLCHK96231
-Node: WEBGRAB100066
-Node: STATIST104516
-Ref: STATIST-Footnote-1116224
-Node: MAZE116669
-Node: MOBAGWHO122853
-Ref: MOBAGWHO-Footnote-1136797
-Node: STOXPRED136852
-Node: PROTBASE151107
-Node: Links164188
-Node: GNU Free Documentation License167622
-Node: Index192761
+Node: Comparing Protocols27290
+Node: File /inet/tcp27823
+Node: File /inet/udp28849
+Node: TCP Connecting29947
+Node: Troubleshooting32285
+Ref: Troubleshooting-Footnote-135337
+Node: Interacting35906
+Node: Setting Up38636
+Node: Email42130
+Node: Web page44456
+Ref: Web page-Footnote-147261
+Node: Primitive Service47458
+Node: Interacting Service50192
+Ref: Interacting Service-Footnote-159321
+Node: CGI Lib59353
+Node: Simple Server66314
+Ref: Simple Server-Footnote-174037
+Node: Caveats74138
+Node: Challenges75281
+Node: Some Applications and Techniques83960
+Node: PANIC86417
+Node: GETURL88135
+Node: REMCONF90758
+Node: URLCHK96234
+Node: WEBGRAB100069
+Node: STATIST104519
+Ref: STATIST-Footnote-1116227
+Node: MAZE116672
+Node: MOBAGWHO122856
+Ref: MOBAGWHO-Footnote-1136800
+Node: STOXPRED136855
+Node: PROTBASE151110
+Node: Links164191
+Node: GNU Free Documentation License167625
+Node: Index192764

End Tag Table
diff --git a/doc/texinfo.tex b/doc/texinfo.tex
index f458ba72..9a2439c8 100644
--- a/doc/texinfo.tex
+++ b/doc/texinfo.tex
@@ -3,7 +3,7 @@
% Load plain if necessary, i.e., if running under initex.
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
%
-\def\texinfoversion{2012-09-04.17}
+\def\texinfoversion{2012-09-05.06}
%
% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -3272,7 +3272,8 @@ end
% Settings used for typesetting titles: no hyphenation, no indentation,
% don't worry much about spacing, ragged right. This should be used
% inside a \vbox, and fonts need to be set appropriately first. Because
-% it is always used for titles, nothing else, we call \rmisbold.
+% it is always used for titles, nothing else, we call \rmisbold. \par
+% should be specified before the end of the \vbox, since a vbox is a group.
%
\def\raggedtitlesettings{%
\rmisbold
@@ -3289,7 +3290,7 @@ end
\parseargdef\title{%
\checkenv\titlepage
- \vbox{\titlefonts \raggedtitlesettings #1}
+ \vbox{\titlefonts \raggedtitlesettings #1\par}%
% print a rule at the page bottom also.
\finishedtitlepagefalse
\vskip4pt \hrule height 4pt width \hsize \vskip4pt
@@ -5592,14 +5593,6 @@ end
% Define @majorheading, @heading and @subheading
-% NOTE on use of \vbox for chapter headings, section headings, and such:
-% 1) We use \vbox rather than the earlier \line to permit
-% overlong headings to fold.
-% 2) \hyphenpenalty is set to 10000 because hyphenation in a
-% heading is obnoxious; this forbids it.
-% 3) Likewise, headings look best if no \parindent is used, and
-% if justification is not attempted. Hence \raggedright.
-
\def\majorheading{%
{\advance\chapheadingskip by 10pt \chapbreak }%
\parsearg\chapheadingzzz
@@ -5607,10 +5600,8 @@ end
\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
\def\chapheadingzzz#1{%
- {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
- \parindent=0pt\ptexraggedright
- \rmisbold #1\hfill}}%
- \bigskip \par\penalty 200\relax
+ \vbox{\chapfonts \raggedtitlesettings #1\par}%
+ \nobreak\bigskip \nobreak
\suppressfirstparagraphindent
}
@@ -5769,8 +5760,7 @@ end
%
% Typeset the actual heading.
\nobreak % Avoid page breaks at the interline glue.
- \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
- \hangindent=\wd0 \centerparametersmaybe
+ \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
\unhbox0 #1\par}%
}%
\nobreak\bigskip % no page break after a chapter title
@@ -5792,18 +5782,18 @@ end
\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
%
\def\unnchfopen #1{%
-\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
- \parindent=0pt\ptexraggedright
- \rmisbold #1\hfill}}\bigskip \par\nobreak
+ \chapoddpage
+ \vbox{\chapfonts \raggedtitlesettings #1\par}%
+ \nobreak\bigskip\nobreak
}
\def\chfopen #1#2{\chapoddpage {\chapfonts
\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
\par\penalty 5000 %
}
\def\centerchfopen #1{%
-\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
- \parindent=0pt
- \hfill {\rmisbold #1}\hfill}}\bigskip \par\nobreak
+ \chapoddpage
+ \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}%
+ \nobreak\bigskip \nobreak
}
\def\CHAPFopen{%
\global\let\chapmacro=\chfopen