[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, master, updated. 4fe569fb78dd1b25822c16c
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, master, updated. 4fe569fb78dd1b25822c16c9cac515a0fc6702a4 |
Date: |
Fri, 25 Mar 2011 11:31:42 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, master has been updated
via 4fe569fb78dd1b25822c16c9cac515a0fc6702a4 (commit)
via a3e92aab353cabae2743b78de1f12fe94e66a339 (commit)
from 09a48263ff3db65b3e24f1b5fc50800c20cce162 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=4fe569fb78dd1b25822c16c9cac515a0fc6702a4
commit 4fe569fb78dd1b25822c16c9cac515a0fc6702a4
Author: Arnold D. Robbins <address@hidden>
Date: Fri Mar 25 13:31:01 2011 +0200
Apply first set of edits to gawk.texi.
diff --git a/awklib/eg/lib/getopt.awk b/awklib/eg/lib/getopt.awk
index d3dd9c1..0b81aa0 100644
--- a/awklib/eg/lib/getopt.awk
+++ b/awklib/eg/lib/getopt.awk
@@ -27,7 +27,7 @@ function getopt(argc, argv, options, thisopt, i)
Optind++
_opti = 0
return -1
- } else if (argv[Optind] !~ /^-[^: \t\n\f\r\v\b]/) {
+ } else if (argv[Optind] !~ /^-[^:[:space:]]/) {
_opti = 0
return -1
}
diff --git a/awklib/eg/lib/groupawk.in b/awklib/eg/lib/groupawk.in
index 1331a46..0917b92 100644
--- a/awklib/eg/lib/groupawk.in
+++ b/awklib/eg/lib/groupawk.in
@@ -49,12 +49,11 @@ function _gr_init( oldfs, oldrs, olddol0, grcat,
close(grcat)
_gr_count = 0
_gr_inited++
+ FS = oldfs
if (using_fw)
FIELDWIDTHS = FIELDWIDTHS
else if (using_fpat)
FPAT = FPAT
- else
- FS = oldfs
RS = oldrs
$0 = olddol0
}
diff --git a/awklib/eg/lib/passwdawk.in b/awklib/eg/lib/passwdawk.in
index 4cbbaaf..d2442ad 100644
--- a/awklib/eg/lib/passwdawk.in
+++ b/awklib/eg/lib/passwdawk.in
@@ -32,12 +32,11 @@ function _pw_init( oldfs, oldrs, olddol0, pwcat,
using_fw, using_fpat)
close(pwcat)
_pw_count = 0
_pw_inited = 1
+ FS = oldfs
if (using_fw)
FIELDWIDTHS = FIELDWIDTHS
else if (using_fpat)
FPAT = FPAT
- else
- FS = oldfs
RS = oldrs
$0 = olddol0
}
diff --git a/awklib/eg/lib/strtonum.awk b/awklib/eg/lib/strtonum.awk
index 6b8498a..a56ab50 100644
--- a/awklib/eg/lib/strtonum.awk
+++ b/awklib/eg/lib/strtonum.awk
@@ -1,4 +1,4 @@
-# strtonum --- convert string to number
+# mystrtonum --- convert string to number
#
# Arnold Robbins, address@hidden, Public Domain
diff --git a/awklib/eg/prog/alarm.awk b/awklib/eg/prog/alarm.awk
index af7e8af..2510c78 100644
--- a/awklib/eg/prog/alarm.awk
+++ b/awklib/eg/prog/alarm.awk
@@ -22,20 +22,20 @@ BEGIN \
switch (ARGC) {
case 5:
delay = ARGV[4] + 0
- # fall through
+ # fall through
case 4:
count = ARGV[3] + 0
- # fall through
+ # fall through
case 3:
message = ARGV[2]
- break
+ break
default:
if (ARGV[1] !~ /[[:digit:]]?[[:digit:]]:[[:digit:]][[:digit:]]/) {
print usage1 > "/dev/stderr"
print usage2 > "/dev/stderr"
exit 1
- }
- break
+ }
+ break
}
# set defaults for once we reach the desired time
diff --git a/doc/gawk.info b/doc/gawk.info
index bfac450..714df82 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -10,7 +10,7 @@ START-INFO-DIR-ENTRY
END-INFO-DIR-ENTRY
Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2007, 2009, 2010 Free Software
+2001, 2002, 2003, 2004, 2005, 2007, 2009, 2010, 2011 Free Software
Foundation, Inc.
@@ -42,7 +42,7 @@ This file documents `awk', a program that you can use to
select
particular records in a file and perform operations upon them.
Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2007, 2009, 2010 Free Software
+2001, 2002, 2003, 2004, 2005, 2007, 2009, 2010, 2011 Free Software
Foundation, Inc.
@@ -162,7 +162,7 @@ texts being (a) (see below), and with the Back-Cover Texts
being (b)
* Regexp Usage:: How to Use Regular Expressions.
* Escape Sequences:: How to write nonprinting characters.
* Regexp Operators:: Regular Expression Operators.
-* Character Lists:: What can go between `[...]'.
+* Bracket Expressions:: What can go between `[...]'.
* GNU Regexp Operators:: Operators specific to GNU software.
* Case-sensitivity:: How to do case-insensitive matching.
* Leftmost Longest:: How much text matches.
@@ -592,6 +592,7 @@ want to learn how, then read this book.
Michael Brennan
Author of `mawk'
+ March, 2001
File: gawk.info, Node: Preface, Next: Getting Started, Prev: Foreword, Up:
Top
@@ -648,9 +649,9 @@ of `awk' called `gawk' (which stands for "GNU awk").
`gawk' runs on a
broad range of Unix systems, ranging from Intel(R)-architecture
PC-based computers up through large-scale systems, such as Crays.
`gawk' has also been ported to Mac OS X, Microsoft Windows (all
-versions) and OS/2 PCs, and VMS. (Other systems to which `gawk' was
-once ported are no longer supported and the code for those systems has
-been removed.)
+versions) and OS/2 PCs, and VMS. (Some other, obsolete systems to
+which `gawk' was once ported are no longer supported and the code for
+those systems has been removed.)
* Menu:
@@ -720,6 +721,10 @@ Internetworking with `gawk'' (a separate document,
available as part of
the `gawk' distribution). His code finally became part of the main
`gawk' distribution with `gawk' version 3.1.
+ John Haque rewrote the `gawk' internals, in the process providing an
+`awk'-level debugger. This version became available as `gawk' version
+4.0, in 2011.
+
*Note Contributors::, for a complete list of those who made
important contributions to `gawk'.
@@ -766,9 +771,9 @@ Using This Book
The term `awk' refers to a particular program as well as to the
language you use to tell this program what to do. When we need to be
careful, we call the language "the `awk' language," and the program
-"the `awk' utility." This Info file explains both how to write program
-in the `awk' language and how to run the `awk' utility. The term
-"`awk' program" refers to a program written by you in the `awk'
+"the `awk' utility." This Info file explains both how to write
+programs in the `awk' language and how to run the `awk' utility. The
+term "`awk' program" refers to a program written by you in the `awk'
programming language.
Primarily, this Info file explains the features of `awk' as defined
@@ -784,9 +789,9 @@ points that are relevant, but not likely to be of interest
on first
reading. All appear in the index, under the heading "advanced
features."
- Most of the time, the examples use complete `awk' programs. In some
-of the more advanced sections, only the part of the `awk' program that
-illustrates the concept currently being described is shown.
+ Most of the time, the examples use complete `awk' programs. Some of
+the more advanced sections show only the part of the `awk' program that
+illustrates the concept currently being described.
While this Info file is aimed principally at people who have not been
exposed to `awk', there is a lot of information here that even the `awk'
@@ -797,6 +802,9 @@ expert should find useful. In particular, the description
of POSIX
*note Getting Started::, provides the essentials you need to know to
begin using `awk'.
+ *note Invoking Gawk::, describes how to run `gawk', the meaning of
+its command-line options, and how it finds `awk' program source files.
+
*note Regexp::, introduces regular expressions in general, and in
particular the flavors supported by POSIX `awk' and `gawk'.
@@ -817,7 +825,8 @@ and the built-in variables `awk' and `gawk' use.
*note Arrays::, covers `awk''s one-and-only data structure:
associative arrays. Deleting array elements and whole arrays is also
-described, as well as sorting arrays in `gawk'.
+described, as well as sorting arrays in `gawk'. It also describes how
+`gawk' provides arrays of arrays.
*note Functions::, describes the built-in functions `awk' and `gawk'
provide, as well as how to define your own functions.
@@ -830,9 +839,6 @@ advanced features. Of particular note are the abilities to
have
two-way communications with another process, perform TCP/IP networking,
and profile your `awk' programs.
- *note Invoking Gawk::, describes how to run `gawk', the meaning of
-its command-line options, and how it finds `awk' program source files.
-
*note Library Functions::, and *note Sample Programs::, provide many
sample `awk' programs. Reading them allows you to see `awk' solving
real problems.
@@ -876,10 +882,11 @@ File: gawk.info, Node: Conventions, Next: Manual
History, Prev: This Manual,
Typographical Conventions
=========================
-This Info file is written using Texinfo, the GNU documentation
-formatting language. A single Texinfo source file is used to produce
-both the printed and online versions of the documentation. This minor
-node briefly documents the typographical conventions used in Texinfo.
+This Info file is written in Texinfo (http://texinfo.org), the GNU
+documentation formatting language. A single Texinfo source file is
+used to produce both the printed and online versions of the
+documentation. This minor node briefly documents the typographical
+conventions used in Texinfo.
Examples you would type at the command-line are preceded by the
common shell primary and secondary prompts, `$' and `>'. Input that
@@ -955,9 +962,11 @@ systems.(2) Many GNU/Linux distributions are available for
download
from the Internet.
(There are numerous other freely available, Unix-like operating
-systems based on the Berkeley Software Distribution, and they use
-recent versions of `gawk' for their versions of `awk'. NetBSD, FreeBSD
-and OpenBSD are three of the most popular ones, but there are others.)
+systems based on the Berkeley Software Distribution, and some of them
+use recent versions of `gawk' for their versions of `awk'. NetBSD
+(http://www.netbsd.org), FreeBSD (http://www.freebsd.org), and OpenBSD
+(http://www.openbsd.org) are three of the most popular ones, but there
+are others.)
The Info file itself has gone through a number of previous editions.
Paul Rubin wrote the very first draft of `The GAWK Manual'; it was
@@ -971,10 +980,10 @@ it progressed, the FSF published several preliminary
versions (numbered
published the first two editions under the title `The GNU Awk User's
Guide'.
- This edition maintains the basic structure of Edition 1.0. For
-Edition 4.0, the content has been thoroughly reviewed and updated. All
-references to versions prior to 4.0 have been removed. Of significant
-note for this edition is *note Debugger::.
+ This edition maintains the basic structure of the previous editions.
+For Edition 4.0, the content has been thoroughly reviewed and updated.
+All references to versions prior to 4.0 have been removed. Of
+significant note for this edition is *note Debugger::.
`GAWK: Effective AWK Programming' will undoubtedly continue to
evolve. An electronic version comes with the `gawk' distribution from
@@ -1041,8 +1050,8 @@ GNU Project.
acknowledgements:
The following people (in alphabetical order) provided helpful
- comments on various versions of this book, Rick Adams, Nelson H.F.
- Beebe, Karl Berry, Dr. Michael Brennan, Rich Burridge, Claire
+ comments on various versions of this book, Rick Adams, Dr. Nelson
+ H.F. Beebe, Karl Berry, Dr. Michael Brennan, Rich Burridge, Claire
Cloutier, Diane Close, Scott Deifik, Christopher ("Topher") Eliot,
Jeffrey Friedl, Dr. Darrel Hankerson, Michal Jaegermann, Dr.
Richard J. LeBlanc, Michael Lijewski, Pat Rankin, Miriam Robbins,
@@ -1075,7 +1084,7 @@ acknowledgements:
Associates contributed significant editorial help for this Info
file for the 3.1 release of `gawk'.
- Nelson Beebe, Andreas Buening, Antonio Colombo, Stephen Davies,
+ Dr. Nelson Beebe, Andreas Buening, Antonio Colombo, Stephen Davies,
Scott Deifik, John H. DuBois III, Darrel Hankerson, Michal Jaegermann,
Ju"rgen Kahrs, Dave Pitts, Stepan Kasal, Pat Rankin, Andrew Schorr,
Corinna Vinschen, Anders Wallin, and Eli Zaretskii (in alphabetical
@@ -1087,13 +1096,14 @@ 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.
+mainstream code base. Efraim Yawitz contributed the initial text of
+*note Debugger::.
I would like to thank Brian Kernighan for invaluable assistance
-during the testing and debugging of `gawk', and for ongoing help in
-clarifying numerous points about the language. We could not have done
-nearly as good a job on either `gawk' or its documentation without his
-help.
+during the testing and debugging of `gawk', and for ongoing help and
+advice in clarifying numerous points about the language. We could not
+have done nearly as good a job on either `gawk' or its documentation
+without his help.
I must thank my wonderful wife, Miriam, for her patience through the
many versions of this project, for her proofreading, and for sharing me
@@ -1107,7 +1117,7 @@ to take advantage of those opportunities.
Arnold Robbins
Nof Ayalon
ISRAEL
-December, 2010
+March, 2011
File: gawk.info, Node: Getting Started, Next: Invoking Gawk, Prev: Preface,
Up: Top
@@ -1271,8 +1281,8 @@ works is explained shortly).
---------- Footnotes ----------
(1) If you use Bash as your shell, you should execute the command
-`set +H' before running this program interactively, to disable the
-`csh'-style command history, which treats `!' as a special character.
+`set +H' before running this program interactively, to disable the C
+shell-style command history, which treats `!' as a special character.
We recommend putting this command into your personal startup file.
(2) Although we generally recommend the use of single quotes around
@@ -1312,7 +1322,7 @@ special characters. Notice that in `advice', the `awk'
program did not
have single quotes around it. The quotes are only needed for programs
that are provided on the `awk' command line.
- If you want to identify your `awk' program files clearly as such,
+ If you want to clearly identify your `awk' program files as such,
you can add the extension `.awk' to the file name. This doesn't affect
the execution of the `awk' program but it does make "housekeeping"
easier.
@@ -1341,7 +1351,7 @@ if you had typed `awk -f advice':
-| Don't Panic!
(We assume you have the current directory in your shell's search path
-variable (typically `$PATH'). If not, you may need to type `./advice'
+variable [typically `$PATH']. If not, you may need to type `./advice'
at the shell.)
Self-contained `awk' scripts are useful when you want to write a
@@ -1363,7 +1373,7 @@ sort from `awk'.
Finally, the value of `ARGV[0]' (*note Built-in Variables::) varies
depending upon your operating system. Some systems put `awk' there,
some put the full pathname of `awk' (such as `/bin/awk'), and some put
-the name of your script (`advice'). Don't rely on the value of
+the name of your script (`advice'). (d.c.) Don't rely on the value of
`ARGV[0]' to provide your script name.
---------- Footnotes ----------
@@ -1454,7 +1464,7 @@ writing it as part of a larger shell script:
Once you are working with the shell, it is helpful to have a basic
knowledge of shell quoting rules. The following rules apply only to
POSIX-compliant, Bourne-style shells (such as Bash, the GNU Bourne-Again
-Shell). If you use `csh', you're on your own.
+Shell). If you use the C shell, you're on your own.
* Quoted items can be concatenated with nonquoted items as well as
with other quoted items. The shell turns everything into one
@@ -1680,7 +1690,7 @@ is to print all lines that match the pattern.
Thus, we could leave out the action (the `print' statement and the
curly braces) in the previous example and the result would be the same:
-all lines matching the pattern `foo' are printed. By comparison,
+`awk' prints all lines matching the pattern `foo'. By comparison,
omitting the `print' statement but retaining the curly braces makes an
empty action that does nothing (i.e., no lines are printed).
@@ -1738,7 +1748,7 @@ different ways to do the same things shown here:
* Print the total number of kilobytes used by FILES:
ls -l FILES | awk '{ x += $5 }
- END { print "total K-bytes:", x /1024 }'
+ END { print "total K-bytes:", x / 1024 }'
* Print a sorted list of the login names of all users:
@@ -1867,8 +1877,8 @@ reports.
---------- Footnotes ----------
- (1) The `LC_ALL=C' is needed to produce traditional-style output
-from `ls'.
+ (1) The `LC_ALL=C' is needed to produce this traditional-style
+output from `ls'.
File: gawk.info, Node: Statements/Lines, Next: Other Features, Prev: More
Complex, Up: Getting Started
@@ -1995,7 +2005,8 @@ There are other variables your program can set as well to
control how
In addition, `awk' provides a number of built-in functions for doing
common computational and string-related operations. `gawk' provides
built-in functions for working with timestamps, performing bit
-manipulation, for runtime string translation, and array sorting.
+manipulation, for runtime string translation (internationalization),
+determining the type of a variable, and array sorting.
As we develop our presentation of the `awk' language, we introduce
most of the variables and many of the functions. They are described
@@ -2027,8 +2038,8 @@ retargetable assembler for eight-bit microprocessors
(*note Glossary::,
for more information), and a microcode assembler for a special-purpose
Prolog computer. While the original `awk''s capabilities were strained
by tasks of such complexity, modern versions are more capable. Even
-the Bell Labs version of `awk' has fewer predefined limits, and those
-that it has are much larger than they used to be.
+Brian Kernighan's version of `awk' has fewer predefined limits, and
+those that it has are much larger than they used to be.
If you find yourself writing `awk' scripts of more than, say, a few
hundred lines, you might consider using a different programming
@@ -2375,7 +2386,8 @@ input as a source of data.)
source file and command-line `awk' programs, `gawk' provides the
`--source' option. This does not require you to pre-empt the standard
input for your source code; it allows you to easily mix command-line
-and library source code (*note AWKPATH Variable::).
+and library source code (*note AWKPATH Variable::). The `--source'
+option may also be used multiple times on the command line.
If no `-f' or `--source' option is specified, then `gawk' uses the
first non-option command-line argument as the text of the program
@@ -2394,7 +2406,7 @@ you would add these lines to the `.profile' file in your
home directory:
POSIXLY_CORRECT=true
export POSIXLY_CORRECT
- For a `csh'-compatible shell,(1) you would add this line to the
+ For a C shell-compatible shell,(1) you would add this line to the
`.login' file in your home directory:
setenv POSIXLY_CORRECT true
@@ -2416,8 +2428,8 @@ File: gawk.info, Node: Other Arguments, Next: Naming
Standard Input, Prev: Op
Any additional arguments on the command line are normally treated as
input files to be processed in the order specified. However, an
argument that has the form `VAR=VALUE', assigns the value VALUE to the
-variable VAR--it does not specify a file at all. (See also *note
-Assignment Options::.)
+variable VAR--it does not specify a file at all. (See *note Assignment
+Options::.)
All these arguments are made available to your `awk' program in the
`ARGV' array (*note Built-in Variables::). Command-line options and
@@ -2486,7 +2498,9 @@ with `getline' (*note Getline/File::).
In addition, `gawk' allows you to specify the special file name
`/dev/stdin', both on the command line and with `getline'. Some other
-versions of `awk' also support this, but it is not standard.
+versions of `awk' also support this, but it is not standard. (Some
+operating systems provide a `/dev/stdin' file in the file system,
+however, `gawk' always processes this file name itself.)
File: gawk.info, Node: Environment Variables, Next: Exit Status, Prev:
Naming Standard Input, Up: Invoking Gawk
@@ -2519,9 +2533,7 @@ 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
variable. If that variable does not exist, `gawk' uses a default path,
-`.:/usr/local/share/awk'.(1) (Programs written for use by system
-administrators should use an `AWKPATH' variable that does not include
-the current directory, `.'.)
+`.:/usr/local/share/awk'.(1)
The search path feature is particularly useful for building libraries
of useful `awk' functions. The library files can be placed in a
@@ -2541,9 +2553,9 @@ Options::.
colon or by placing two colons next to each other (`::').) This
path search mechanism is similar to the shell's.
- However, `gawk' always looks in the current directory before
- before searching `AWKPATH', so there is no real reason to include
- the current directory in the search path.
+ However, `gawk' always looks in the current directory _before_
+ searching `AWKPATH', so there is no real reason to include the
+ current directory in the search path.
If `AWKPATH' is not defined in the environment, `gawk' places its
default search path into `ENVIRON["AWKPATH"]'. This makes it easy to
@@ -2574,9 +2586,8 @@ they are more specialized. Those in the following list
are meant to be
used by regular users.
`POSIXLY_CORRECT'
- If this variable exists, `gawk' switches to POSIX compatibility
- mode, disabling all traditional and GNU extensions. *Note
- Options::.
+ Causes `gawk' to switch POSIX compatibility mode, disabling all
+ traditional and GNU extensions. *Note Options::.
`GAWK_SOCK_RETRIES'
Controls the number of time `gawk' will attempt to retry a two-way
@@ -2588,8 +2599,8 @@ 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.
- The environment variables in the following table are meant for use
-by the `gawk' developers for testing and tuning. They are subject to
+ 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:
`AVG_CHAIN_MAX'
@@ -2613,7 +2624,7 @@ change. The variables are:
slower. Its purpose is to help isolate differences between the two
regexp matchers that `gawk' uses internally. (There aren't
supposed to be differences, but occasionally theory and practice
- don't match up.)
+ don't coordinate with each other.)
`GAWK_STACKSIZE'
This specifies the amount by which `gawk' should grow its internal
@@ -2729,7 +2740,9 @@ to be included.
Given the ability to specify multiple `-f' options, the address@hidden'
mechanism is not strictly necessary. However, the address@hidden' keyword
can help you in constructing self-contained `gawk' programs, thus
-reducing the need for writing complex and tedious command lines.
+reducing the need for writing complex and tedious command lines. In
+particular, address@hidden' is very useful for writing CGI scripts to be run
+from web pages.
As mentioned in *note AWKPATH Variable::, the current directory is
always searched first for source files, before searching in `AWKPATH',
@@ -2786,7 +2799,7 @@ you specify more complicated classes of strings.
* Regexp Usage:: How to Use Regular Expressions.
* Escape Sequences:: How to write nonprinting characters.
* Regexp Operators:: Regular Expression Operators.
-* Character Lists:: What can go between `[...]'.
+* Bracket Expressions:: What can go between `[...]'.
* GNU Regexp Operators:: Operators specific to GNU software.
* Case-sensitivity:: How to do case-insensitive matching.
* Leftmost Longest:: How much text matches.
@@ -2876,8 +2889,8 @@ included normally; you must write `\\' to put one
backslash in the
string or regexp. Thus, the string whose contents are the two
characters `"' and `\' must be written `"\"\\"'.
- Backslash also represents unprintable characters such as TAB or
-newline. While there is nothing to stop you from entering most
+ Other escape sequences represent unprintable characters such as TAB
+or newline. While there is nothing to stop you from entering most
unprintable characters directly in a string constant or regexp constant,
they may look ugly.
@@ -2972,12 +2985,12 @@ not one of the characters previously listed, POSIX
`awk' purposely
leaves what happens as undefined. There are two choices:
Strip the backslash out
- This is what Unix `awk' and `gawk' both do. For example, `"a\qc"'
- is the same as `"aqc"'. (Because this is such an easy bug both to
- introduce and to miss, `gawk' warns you about it.) Consider `FS =
- "[ \t]+\|[ \t]+"' to use vertical bars surrounded by whitespace as
- the field separator. There should be two backslashes in the
- string: `FS = "[ \t]+\\|[ \t]+"'.)
+ This is what Brian Kernighan's `awk' and `gawk' both do. For
+ example, `"a\qc"' is the same as `"aqc"'. (Because this is such
+ an easy bug both to introduce and to miss, `gawk' warns you about
+ it.) Consider `FS = "[ \t]+\|[ \t]+"' to use vertical bars
+ surrounded by whitespace as the field separator. There should be
+ two backslashes in the string: `FS = "[ \t]+\\|[ \t]+"'.)
Leave the backslash alone
Some other `awk' implementations do this. In such
@@ -2998,7 +3011,7 @@ and hexadecimal escape sequences literally when used in
regexp
constants. Thus, `/a\52b/' is equivalent to `/a\*b/'.
-File: gawk.info, Node: Regexp Operators, Next: Character Lists, Prev:
Escape Sequences, Up: Regexp
+File: gawk.info, Node: Regexp Operators, Next: Bracket Expressions, Prev:
Escape Sequences, Up: Regexp
3.3 Regular Expression Operators
================================
@@ -3057,8 +3070,8 @@ sequences and that are not listed in the table stand for
themselves:
the characters that are enclosed in the square brackets. For
example, `[MVX]' matches any one of the characters `M', `V', or
`X' in a string. A full discussion of what can be inside the
- square brackets of a bracket expression is given in *note
- Character Lists::.
+ square brackets of a bracket expression is given in *note Bracket
+ Expressions::.
`[^ ...]'
This is a "complemented bracket expression". The first character
@@ -3172,10 +3185,10 @@ list".
regexp operator or function.
-File: gawk.info, Node: Character Lists, Next: GNU Regexp Operators, Prev:
Regexp Operators, Up: Regexp
+File: gawk.info, Node: Bracket Expressions, Next: GNU Regexp Operators,
Prev: Regexp Operators, Up: Regexp
-3.4 Using Character Lists
-=========================
+3.4 Using Bracket Expressions
+=============================
Within a bracket expression, a "range expression" consists of two
characters separated by a hyphen. It matches any single character that
@@ -3268,7 +3281,7 @@ Equivalence classes
classes.
-File: gawk.info, Node: GNU Regexp Operators, Next: Case-sensitivity, Prev:
Character Lists, Up: Regexp
+File: gawk.info, Node: GNU Regexp Operators, Next: Case-sensitivity, Prev:
Bracket Expressions, Up: Regexp
3.5 `gawk'-Specific Regexp Operators
====================================
@@ -3370,14 +3383,14 @@ File: gawk.info, Node: Case-sensitivity, Next:
Leftmost Longest, Prev: GNU Re
================================
Case is normally significant in regular expressions, both when matching
-ordinary characters (i.e., not metacharacters) and inside character
-sets. Thus, a `w' in a regular expression matches only a lowercase `w'
-and not an uppercase `W'.
+ordinary characters (i.e., not metacharacters) and inside bracket
+expressions. Thus, a `w' in a regular expression matches only a
+lowercase `w' and not an uppercase `W'.
- The simplest way to do a case-independent match is to use a character
-list--for example, `[Ww]'. However, this can be cumbersome if you need
-to use it often, and it can make the regular expressions harder to
-read. There are two alternatives that you might prefer.
+ The simplest way to do a case-independent match is to use a bracket
+expression--for example, `[Ww]'. However, this can be cumbersome if
+you need to use it often, and it can make the regular expressions harder
+to read. There are two alternatives that you might prefer.
One way to perform a case-insensitive match at a particular point in
the program is to convert the data to a single case, using the
@@ -3478,8 +3491,8 @@ File: gawk.info, Node: Computed Regexps, Next: Locales,
Prev: Leftmost Longes
The righthand side of a `~' or `!~' operator need not be a regexp
constant (i.e., a string of characters between slashes). It may be any
expression. The expression is evaluated and converted to a string if
-necessary; the contents of the string are used as the regexp. A regexp
-that is computed in this way is called a "dynamic regexp":
+necessary; the contents of the string are then used as the regexp. A
+regexp computed in this way is called a "dynamic regexp":
BEGIN { digits_regexp = "[[:digit:]]+" }
$0 ~ digits_regexp { print }
@@ -3525,8 +3538,8 @@ constants," for several reasons:
* Using regexp constants is better form; it shows clearly that you
intend a regexp match.
-Advanced Notes: Using `\n' in Character Lists of Dynamic Regexps
-----------------------------------------------------------------
+Advanced Notes: Using `\n' in Bracket Expressions of Dynamic Regexps
+--------------------------------------------------------------------
Some commercial versions of `awk' do not allow the newline character to
be used inside a bracket expression for a dynamic regexp:
@@ -3564,7 +3577,7 @@ ways.
these locales, `[a-dx-z]' is typically not equivalent to `[abcdxyz]';
instead it might be equivalent to `[aBbCcdXxYyz]', for example.
- This point needs to be emphasized: Much literature teaches that one
+ This point needs to be emphasized: Much literature teaches that you
should use `[a-z]' to match a lowercase character. But on systems with
non-ASCII locales, this also matches all of the uppercase characters
except `Z'! This is a continuous cause of confusion, even well into
@@ -3620,6 +3633,10 @@ better performance when reading records. Otherwise,
`gawk' has to make
several function calls, _per input character_, to find the record
terminator.
+ According to POSIX, string conmparison is also affected by locales
+(similar to regular expressions). The details are presented in *note
+POSIX String Comparison::.
+
Finally, the locale affects the value of the decimal point character
used when `gawk' parses input data. This is discussed in detail in
*note Conversion::.
@@ -3794,8 +3811,8 @@ matches `RS', is not part of either record.
character. However, when `RS' is a regular expression, `RT' contains
the actual input text that matched the regular expression.
- If the input file ended without any text that matches `RS', then
-`gawk' sets `RT' to the null string.
+ If the input file ended without any text that matches `RS', `gawk'
+sets `RT' to the null string.
The following example illustrates both of these features. It sets
`RS' equal to a regular expression that matches either a newline or a
@@ -3878,7 +3895,7 @@ When `awk' reads an input record, the record is
automatically "parsed"
or separated by the `awk' utility into chunks called "fields". By
default, fields are separated by "whitespace", like words in a line.
Whitespace in `awk' means any string of one or more spaces, TABs, or
-newlines;(1) other characters, such as formfeed, vertical tab, etc.
+newlines;(1) other characters, such as formfeed, vertical tab, etc.,
that are considered whitespace by other languages, are _not_ considered
whitespace by `awk'.
@@ -4119,6 +4136,22 @@ fields using the _current_ value of `FS'. This also
applies to any
built-in function that updates `$0', such as `sub()' and `gsub()'
(*note String Functions::).
+Advanced Notes: Understanding `$0'
+----------------------------------
+
+It is important to remember that `$0' is the _full_ record, exactly as
+it was read from the input. This includes any leading or trailing
+whitespace, and the exact whitespace (or other characters) that
+separate the fields.
+
+ It is a not-uncommon error to try to change the field separators in
+a record simply by setting `FS' and `OFS', and then expecting a plain
+`print' or `print $0' to print the modified record.
+
+ But this does not work, since nothing was done to change the record
+itself. Instead, you must force the record to be rebuilt, typically
+with a statement such as `$1 = $1', as described earlier.
+
File: gawk.info, Node: Field Separators, Next: Constant Size, Prev:
Changing Fields, Up: Reading Files
@@ -4273,7 +4306,7 @@ field separator a new string? It turns out that
different `awk'
versions answer this question differently, and you should not rely on
any specific behavior in your programs. (d.c.)
- As a point of information, the Brian Kernighan's `awk' allows `^' to
+ As a point of information, Brian Kernighan's `awk' allows `^' to
match only at the beginning of the record. `gawk' also works this way.
For example:
@@ -4282,8 +4315,7 @@ For example:
> printf "-->%s<--\n", $i }'
-| --><--
-| -->AA<--
- -| --><--
- -| -->Bxx<--
+ -| -->xxBxx<--
-| -->C<--
@@ -4351,8 +4383,8 @@ type `-F\t' at the shell, without any quotes, the `\'
gets deleted, so
TABs and not `t's. Use `-v FS="t"' or `-F"[t]"' on the command line if
you really do want to separate your fields with `t's.
- For example, let's use an `awk' program file called `baud.awk' that
-contains the pattern `/300/' and the action `print $1':
+ As an example, let's use an `awk' program file called `baud.awk'
+that contains the pattern `/300/' and the action `print $1':
/300/ { print $1 }
@@ -4446,7 +4478,7 @@ this means that if you change the value of `FS' after a
record is read,
the value of the fields (i.e., how they were split) should reflect the
old value of `FS', not the new one.
- However, many implementations of `awk' do not work this way.
+ However, many older implementations of `awk' do not work this way.
Instead, they defer splitting the fields until a field is actually
referenced. The fields are split using the _current_ value of `FS'!
(d.c.) This behavior can be difficult to diagnose. The following
@@ -4586,7 +4618,7 @@ value is `"FS"' if regular field splitting is being used,
or it is
else if (PROCINFO["FS"] == "FIELDWIDTHS")
FIXED-WIDTH FIELD SPLITTING ...
else
- CONTENT-BASED FIELD SPLITTING ...
+ CONTENT-BASED FIELD SPLITTING ... (see next minor node)
This information is useful when writing a function that needs to
temporarily change `FS' or `FIELDWIDTHS', read some records, and then
@@ -5111,10 +5143,10 @@ all `awk' implementations.
NOTE: Unfortunately, `gawk' has not been consistent in its
treatment of a construct like `"echo " "date" | getline'. Most
versions, including the current version, treat it at as `("echo "
- "date") | getline'. (This how Unix `awk' behaves.) Some versions
- changed and treated it as `"echo " ("date" | getline)'. (This is
- how `mawk' behaves.) In short, _always_ use explicit parentheses,
- and then you won't have to worry.
+ "date") | getline'. (This how Brian Kernighan's `awk' behaves.)
+ Some versions changed and treated it as `"echo " ("date" |
+ getline)'. (This is how `mawk' behaves.) In short, _always_ use
+ explicit parentheses, and then you won't have to worry.
File: gawk.info, Node: Getline/Variable/Pipe, Next: Getline/Coprocess,
Prev: Getline/Pipe, Up: Getline
@@ -5238,21 +5270,22 @@ 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.
-
-Variant Effect Standard /
- Extension
---------------------------------------------------------------------------
-`getline' Sets `$0', `NF', `FNR', and Standard
- `NR'
-`getline' VAR Sets VAR, `FNR', and `NR' Standard
-`getline <' FILE Sets `$0' and `NF' Standard
-`getline VAR < FILE' Sets VAR Standard
-COMMAND `| getline' Sets `$0' and `NF' Standard
-COMMAND `| getline' VAR Sets VAR Standard
-COMMAND `|& getline' Sets `$0' and `NF' Extension
-COMMAND `|& getline' Sets VAR Extension
-VAR
+`getline', listing which built-in variables are set by each one, and
+whether the variant is standard or a `gawk' extension.
+
+Variant Effect Standard /
+ Extension
+-------------------------------------------------------------------------
+`getline' Sets `$0', `NF', `FNR', Standard
+ and `NR'
+`getline' VAR Sets VAR, `FNR', and `NR' Standard
+`getline <' FILE Sets `$0' and `NF' Standard
+`getline VAR < FILE' Sets VAR Standard
+COMMAND `| getline' Sets `$0' and `NF' Standard
+COMMAND `| getline' VAR Sets VAR Standard
+COMMAND `|& getline' Sets `$0' and `NF' Extension
+COMMAND `|& getline' Sets VAR Extension
+VAR
Table 4.1: getline Variants and What They Set
@@ -5426,10 +5459,10 @@ File: gawk.info, Node: Output Separators, Next: OFMT,
Prev: Print Examples,
As mentioned previously, a `print' statement contains a list of items
separated by commas. In the output, the items are normally separated
by single spaces. However, this doesn't need to be the case; a single
-space is only the default. Any string of characters may be used as the
-"output field separator" by setting the built-in variable `OFS'. The
-initial value of this variable is the string `" "'--that is, a single
-space.
+space is simply the default. Any string of characters may be used as
+the "output field separator" by setting the built-in variable `OFS'.
+The initial value of this variable is the string `" "'--that is, a
+single space.
The output from an entire `print' statement is called an "output
record". Each `print' statement outputs one output record, and then
@@ -5531,7 +5564,7 @@ how to output each of the other arguments. It is called
the "format
string".
The format string is very similar to that in the ISO C library
-function `printf'. Most of FORMAT is text to output verbatim.
+function `printf()'. Most of FORMAT is text to output verbatim.
Scattered among this text are "format specifiers"--one per item. Each
format specifier says to output the next item in the argument list at
that place in the format.
@@ -5682,9 +5715,9 @@ which they may appear:
`-'
The minus sign, used before the width modifier (see later on in
- this table), says to left-justify the argument within its
- specified width. Normally, the argument is printed
- right-justified in the specified width. Thus:
+ this list), says to left-justify the argument within its specified
+ width. Normally, the argument is printed right-justified in the
+ specified width. Thus:
printf "%-4s", "foo"
@@ -5696,7 +5729,7 @@ which they may appear:
`+'
The plus sign, used before the width modifier (see later on in
- this table), says to always supply a sign for numeric conversions,
+ this list), says to always supply a sign for numeric conversions,
even if the data to format is positive. The `+' overrides the
space modifier.
@@ -6019,9 +6052,9 @@ produced in the expected order. However, mixing the
operators for the
same file is definitely poor style, and is confusing to readers of your
program.)
- Many `awk' implementations limit the number of pipelines that an
-`awk' program may have open to just one! In `gawk', there is no such
-limit. `gawk' allows a program to open as many pipelines as the
+ Many older `awk' implementations limit the number of pipelines that
+an `awk' program may have open to just one! In `gawk', there is no
+such limit. `gawk' allows a program to open as many pipelines as the
underlying operating system permits.
Advanced Notes: Piping into `sh'
@@ -6067,11 +6100,12 @@ File: gawk.info, Node: Special FD, Next: Special
Network, Up: Special Files
Running programs conventionally have three input and output streams
already available to them for reading and writing. These are known as
the "standard input", "standard output", and "standard error output".
-These streams are, by default, connected to your screen, but they are
-often redirected with the shell, via the `<', `<<', `>', `>>', `>&',
-and `|' operators. Standard error is typically used for writing error
-messages; the reason there are two separate streams, standard output
-and standard error, is so that they can be redirected separately.
+These streams are, by default, connected to your keyboard and screen,
+but they are often redirected with the shell, via the `<', `<<', `>',
+`>>', `>&', and `|' operators. Standard error is typically used for
+writing error messages; the reason there are two separate streams,
+standard output and standard error, is so that they can be redirected
+separately.
In other implementations of `awk', the only way to write an error
message to standard error in an `awk' program is as follows:
@@ -6146,13 +6180,14 @@ File: gawk.info, Node: Special Network, Next: Special
Caveats, Prev: Special
5.7.2 Special Files for Network Communications
----------------------------------------------
-`awk' programs can open a two-way TCP/IP connection, acting as either a
-client or a server. This is done using a special file name of the form:
+`gawk' programs can open a two-way TCP/IP connection, acting as either
+a client or a server. This is done using a special file name of the
+form:
`/NET-TYPE/PROTOCOL/LOCAL-PORT/REMOTE-HOST/REMOTE-PORT'
- The NET-TYPE is one of `inet', `inet4' or `inet6' The PROTOCOL is
-one of `tcp', `udp', or `raw', and the other fields represent the other
+ The NET-TYPE is one of `inet', `inet4' or `inet6'. The PROTOCOL is
+one of `tcp' or `udp', and the other fields represent the other
essential pieces of information for making a networking connection.
These file names are used with the `|&' operator for communicating with
a coprocess (*note Two-way I/O::). This is an advanced feature,
@@ -6173,7 +6208,7 @@ names that `gawk' provides:
* `gawk' _always_ interprets these special file names. For example,
using `/dev/fd/4' for output actually writes on file descriptor 4,
- and not on a new file descriptor that is `dup''ed from file
+ and not on a new file descriptor that is `dup()''ed from file
descriptor 4. Most of the time this does not matter; however, it
is important to _not_ close any of the files related to file
descriptors 0, 1, and 2. Doing so results in unpredictable
@@ -6558,14 +6593,14 @@ the user probably intended:
if (/foo/ ~ $1) print "found foo"
This code is "obviously" testing `$1' for a match against the regexp
-`/foo/'. But in fact, the expression `/foo/ ~ $1' actually means `($0
-~ /foo/) ~ $1'. In other words, first match the input record against
-the regexp `/foo/'. The result is either zero or one, depending upon
-the success or failure of the match. That result is then matched
-against the first field in the record. Because it is unlikely that you
-would ever really want to make this kind of test, `gawk' issues a
-warning when it sees this construct in a program. Another consequence
-of this rule is that the assignment statement:
+`/foo/'. But in fact, the expression `/foo/ ~ $1' really means `($0 ~
+/foo/) ~ $1'. In other words, first match the input record against the
+regexp `/foo/'. The result is either zero or one, depending upon the
+success or failure of the match. That result is then matched against
+the first field in the record. Because it is unlikely that you would
+ever really want to make this kind of test, `gawk' issues a warning
+when it sees this construct in a program. Another consequence of this
+rule is that the assignment statement:
matches = /foo/
@@ -6573,8 +6608,9 @@ assigns either zero or one to the variable `matches',
depending upon
the contents of the current input record.
Constant regular expressions are also used as the first argument for
-the `gensub()', `sub()', and `gsub()' functions, and as the second
-argument of the `match()' function (*note String Functions::). Modern
+the `gensub()', `sub()', and `gsub()' functions, as the second argument
+of the `match()' function, and as the third argument of the
+`patsplit()' function (*note String Functions::). Modern
implementations of `awk', including `gawk', allow the third argument of
`split()' to be a regexp constant, but some older implementations do
not. (d.c.) This can lead to confusion when attempting to use regexp
@@ -6654,9 +6690,9 @@ uppercase.
Variables in `awk' can be assigned either numeric or string values.
The kind of value a variable holds can change over the life of a
program. By default, variables are initialized to the empty string,
-which is zero if converted to a number. There is no need to
-"initialize" each variable explicitly in `awk', which is what you would
-do in C and in most other traditional languages.
+which is zero if converted to a number. There is no need to explicitly
+"initialize" a variable in `awk', which is what you would do in C and
+in most other traditional languages.
File: gawk.info, Node: Assignment Options, Prev: Using Variables, Up:
Variables
@@ -6677,7 +6713,7 @@ option, as in the following:
-v VARIABLE=TEXT
the variable is set at the very beginning, even before the `BEGIN'
-rules are run. The `-v' option and its assignment must precede all the
+rules execute. The `-v' option and its assignment must precede all the
file name arguments, as well as the program text. (*Note Options::,
for more information about the `-v' option.) Otherwise, the variable
assignment is performed at a time determined by its position among the
@@ -6688,10 +6724,10 @@ argument. For example:
prints the value of field number `n' for all input records. Before the
first file is read, the command line sets the variable `n' equal to
-four. This causes the fourth field to be printed in lines from the
-file `inventory-shipped'. After the first file has finished, but
-before the second file is started, `n' is set to two, so that the
-second field is printed in lines from `BBS-list':
+four. This causes the fourth field to be printed in lines from
+`inventory-shipped'. After the first file has finished, but before the
+second file is started, `n' is set to two, so that the second field is
+printed in lines from `BBS-list':
$ awk '{ print $n }' n=4 inventory-shipped n=2 BBS-list
-| 15
@@ -6749,10 +6785,11 @@ exactly.(1)
Strange results can occur if you set `CONVFMT' to a string that
doesn't tell `sprintf()' how to format floating-point numbers in a
useful way. For example, if you forget the `%' in the format, `awk'
-converts all numbers to the same constant string. As a special case,
-if a number is an integer, then the result of converting it to a string
-is _always_ an integer, no matter what the value of `CONVFMT' may be.
-Given the following code fragment:
+converts all numbers to the same constant string.
+
+ As a special case, if a number is an integer, then the result of
+converting it to a string is _always_ an integer, no matter what the
+value of `CONVFMT' may be. Given the following code fragment:
CONVFMT = "%2.2f"
a = 12
@@ -6802,7 +6839,7 @@ GNU/Linux system:
The `en_DK' locale is for English in Denmark, where the comma acts as
the decimal point separator. In the normal `"C"' locale, `gawk' treats
`4,321' as `4', while in the Danish locale, it's treated as the full
-number, `4.321'.
+number, 4.321.
Some earlier versions of `gawk' fully complied with this aspect of
the standard. However, many users in non-English locales complained
@@ -6872,7 +6909,7 @@ small class):
Sandy 84 72 93
Chris 72 92 89
-This programs takes the file `grades' and prints the average of the
+This program takes the file `grades' and prints the average of the
scores:
$ awk '{ sum = $2 + $3 + $4 ; avg = sum / 3
@@ -7024,7 +7061,7 @@ Otherwise, you're never quite sure what you'll get.
---------- Footnotes ----------
- (1) It happens that the current Unix `awk', `gawk' and `mawk' all
+ (1) It happens that Brian Kernighan's `awk', `gawk' and `mawk' all
"get it right," but you should not rely on this.
@@ -7233,22 +7270,22 @@ the lvalue to pre-decrement or after it to
post-decrement. Following
is a summary of increment and decrement expressions:
`++LVALUE'
- This expression increments LVALUE, and the new value becomes the
- value of the expression.
+ Increment LVALUE, returning the new value as the value of the
+ expression.
`LVALUE++'
- This expression increments LVALUE, but the value of the expression
- is the _old_ value of LVALUE.
+ Increment LVALUE, returning the _old_ value of LVALUE as the value
+ of the expression.
`--LVALUE'
- This expression is like `++LVALUE', but instead of adding, it
- subtracts. It decrements LVALUE and delivers the value that is
- the result.
+ Decrement LVALUE, returning the new value as the value of the
+ expression. (This expression is like `++LVALUE', but instead of
+ adding, it subtracts.)
`LVALUE--'
- This expression is like `LVALUE++', but instead of adding, it
- subtracts. It decrements LVALUE. The value of the expression is
- the _old_ value of LVALUE.
+ Decrement LVALUE, returning the _old_ value of LVALUE as the value
+ of the expression. (This expression is like `LVALUE++', but
+ instead of adding, it subtracts.)
Advanced Notes: Operator Evaluation Order
-----------------------------------------
@@ -7314,7 +7351,7 @@ constants `true' and `false', or perhaps their uppercase
equivalents.
However, `awk' is different. It borrows a very simple concept of true
and false from C. In `awk', any nonzero numeric value _or_ any
nonempty string value is true. Any other value (zero or the null
-string `""') is false. The following program prints `A strange truth
+string, `""') is false. The following program prints `A strange truth
value' three times:
BEGIN {
@@ -7563,8 +7600,8 @@ Constant Regexps::, where this is discussed in more
detail.
File: gawk.info, Node: POSIX String Comparison, Prev: Comparison Operators,
Up: Typing and Comparison
-6.3.2.3 String comparison with POSIX rules.
-...........................................
+6.3.2.3 String Comparison With POSIX Rules
+..........................................
The POSIX standard says that string comparison is performed based on
the locale's collating order. This is usually very different from the
@@ -7573,7 +7610,7 @@ comparison.(1)
Because this behavior differs considerably from existing practice,
`gawk' only implements it when in POSIX mode (*note Options::). Here
-is an example to illustrate the difference, in a `en_US.UTF-8' locale:
+is an example to illustrate the difference, in an `en_US.UTF-8' locale:
$ gawk 'BEGIN { printf("ABC < abc = %s\n",
> ("ABC" < "abc" ? "TRUE" : "FALSE")) }'
@@ -7775,7 +7812,7 @@ User-defined::).
As an advanced feature, `gawk' provides indirect function calls,
which is a way to choose the function to call at runtime, instead of
when you write the source code to your program. We defer discussion of
-this feature until later; *Note Indirect Calls::.
+this feature until later; see *note Indirect Calls::.
Like every other expression, the function call has a value, which is
computed by the function based on the arguments you give it. In this
@@ -7952,8 +7989,8 @@ File: gawk.info, Node: Pattern Overview, Next: Using
Shell Variables, Up: Pat
* Expression Patterns:: Any expression can be used as a pattern.
* Ranges:: Pairs of patterns specify record ranges.
* BEGIN/END:: Specifying initialization and cleanup rules.
-* Empty:: The empty pattern, which matches every record.
* BEGINFILE/ENDFILE:: Two special patterns for advanced control.
+* Empty:: The empty pattern, which matches every record.
Patterns in `awk' control the execution of rules--a rule is executed
when its pattern matches the current input record. The following is a
@@ -7977,14 +8014,14 @@ summary of the types of `awk' patterns:
Special patterns for you to supply startup or cleanup actions for
your `awk' program. (*Note BEGIN/END::.)
-`EMPTY'
- The empty pattern matches every input record. (*Note Empty::.)
-
`BEGINFILE'
`ENDFILE'
Special patterns for you to supply startup or cleanup actions to
done on a per file basis. (*Note BEGINFILE/ENDFILE::.)
+`EMPTY'
+ The empty pattern matches every input record. (*Note Empty::.)
+
File: gawk.info, Node: Regexp Patterns, Next: Expression Patterns, Up:
Pattern Overview
@@ -8145,7 +8182,7 @@ worked around; range patterns do not combine with other
patterns:
error--> gawk: cmd. line:1: ^ syntax error
-File: gawk.info, Node: BEGIN/END, Next: Empty, Prev: Ranges, Up: Pattern
Overview
+File: gawk.info, Node: BEGIN/END, Next: BEGINFILE/ENDFILE, Prev: Ranges,
Up: Pattern Overview
7.1.4 The `BEGIN' and `END' Special Patterns
--------------------------------------------
@@ -8219,8 +8256,8 @@ the `FNR' and `NR' variables.
---------- Footnotes ----------
- (1) The original version of `awk' used to keep reading and ignoring
-input until the end of the file was seen.
+ (1) The original version of `awk' kept reading and ignoring input
+until the end of the file was seen.
File: gawk.info, Node: I/O And BEGIN/END, Prev: Using BEGIN/END, Up:
BEGIN/END
@@ -8246,7 +8283,8 @@ number of fields from the last input record. Most
probably due to an
oversight, the standard does not say that `$0' is also preserved,
although logically one would think that it should be. In fact, `gawk'
does preserve the value of `$0' for use in `END' rules. Be aware,
-however, that Unix `awk', and possibly other implementations, do not.
+however, that Brian Kernighan's `awk', and possibly other
+implementations, do not.
The third point follows from the first two. The meaning of `print'
inside a `BEGIN' or `END' rule is the same as always: `print $0'. If
@@ -8266,25 +8304,12 @@ the input has been read. (*Note Next Statement::, and
see *note
Nextfile Statement::.)
-File: gawk.info, Node: Empty, Next: BEGINFILE/ENDFILE, Prev: BEGIN/END,
Up: Pattern Overview
-
-7.1.5 The Empty Pattern
------------------------
+File: gawk.info, Node: BEGINFILE/ENDFILE, Next: Empty, Prev: BEGIN/END,
Up: Pattern Overview
-An empty (i.e., nonexistent) pattern is considered to match _every_
-input record. For example, the program:
-
- awk '{ print $1 }' BBS-list
-
-prints the first field of every record.
-
-
-File: gawk.info, Node: BEGINFILE/ENDFILE, Prev: Empty, Up: Pattern Overview
-
-7.1.6 The `BEGINFILE' and `ENDFILE' Special Patterns
+7.1.5 The `BEGINFILE' and `ENDFILE' Special Patterns
----------------------------------------------------
- NOTE: This minor node describes a `gawk'-specific feature.
+This minor node describes a `gawk'-specific feature.
Two special kinds of rule, `BEGINFILE' and `ENDFILE', give you
"hooks" into `gawk''s command-line file processing loop. As with the
@@ -8299,7 +8324,7 @@ the current file, and `FNR' is set to zero.
The `BEGINFILE' rule provides you the opportunity for two tasks that
would otherwise be difficult or impossible to perform:
- 1. You can test if the file is readable. Normally, it is a fatal
+ * You can test if the file is readable. Normally, it is a fatal
error if a file named on the command line cannot be opened for
reading. However, you can bypass the fatal error and move on to
the next file on the command line.
@@ -8310,7 +8335,7 @@ would otherwise be difficult or impossible to perform:
Nextfile Statement::). This causes `gawk' to skip the file
entirely. Otherwise, `gawk' exits with the usual fatal error.
- 2. If you have written extensions that modify the record handling (by
+ * If you have written extensions that modify the record handling (by
inserting an "open hook"), 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
@@ -8340,6 +8365,19 @@ allowed.
Options::), they are not special.
+File: gawk.info, Node: Empty, Prev: BEGINFILE/ENDFILE, Up: Pattern Overview
+
+7.1.6 The Empty Pattern
+-----------------------
+
+An empty (i.e., nonexistent) pattern is considered to match _every_
+input record. For example, the program:
+
+ awk '{ print $1 }' BBS-list
+
+prints the first field of every record.
+
+
File: gawk.info, Node: Using Shell Variables, Next: Action Overview, Prev:
Pattern Overview, Up: Patterns and Actions
7.2 Using Shell Variables in Programs
@@ -8362,8 +8400,8 @@ the following program:
the `awk' program consists of two pieces of quoted text that are
concatenated together to form the program. The first part is
-double-quoted, which allows substitution of the `pattern' variable
-inside the quotes. The second part is single-quoted.
+double-quoted, which allows substitution of the `pattern' shell
+variable inside the quotes. The second part is single-quoted.
Variable substitution via quoting works, but can be potentially
messy. It requires a good understanding of the shell's quoting rules
@@ -8456,8 +8494,8 @@ File: gawk.info, Node: Statements, Next: Built-in
Variables, Prev: Action Ove
=================================
"Control statements", such as `if', `while', and so on, control the
-flow of execution in `awk' programs. Most of the control statements in
-`awk' are patterned after similar statements in C.
+flow of execution in `awk' programs. Most of `awk''s control
+statements are patterned after similar statements in C.
All the control statements start with special keywords, such as `if'
and `while', to distinguish them from simple expressions. Many control
@@ -8781,7 +8819,7 @@ continues processing. (This is very different from the
`exit'
statement, which stops the entire `awk' program. *Note Exit
Statement::.)
- Th following program illustrates how the CONDITION of a `for' or
+ The following program illustrates how the CONDITION of a `for' or
`while' statement could be replaced with a `break' inside an `if':
# find smallest divisor of num
@@ -8806,8 +8844,8 @@ statement. This is discussed in *note Switch Statement::.
loop or `switch'. However, although it was never documented,
historical implementations of `awk' treated the `break' statement
outside of a loop as if it were a `next' statement (*note Next
-Statement::). Recent versions of Unix `awk' no longer allow this usage,
-nor does `gawk'. (d.c.)
+Statement::). (d.c.) Recent versions of Brian Kernighan's `awk' no
+longer allow this usage, nor does `gawk'.
File: gawk.info, Node: Continue Statement, Next: Next Statement, Prev:
Break Statement, Up: Statements
@@ -8852,12 +8890,13 @@ the previous example with the following `while' loop:
This program loops forever once `x' reaches 5.
- The `continue' statement has no meaning when used outside the body of
-a loop. Historical versions of `awk' treated a `continue' statement
+ The `continue' statement has no special meaning with respect to the
+`switch' statement, nor does it any meaning when used outside the body
+of a loop. Historical versions of `awk' treated a `continue' statement
outside a loop the same way they treated a `break' statement outside a
loop: as if it were a `next' statement (*note Next Statement::).
-Recent versions of Unix `awk' no longer work this way, nor does `gawk'.
-(d.c.)
+(d.c.) Recent versions of Brian Kernighan's `awk' no longer work this
+way, nor does `gawk'.
File: gawk.info, Node: Next Statement, Next: Nextfile Statement, Prev:
Continue Statement, Up: Statements
@@ -8901,8 +8940,8 @@ error output stream, as error messages should be. For
more detail see
If the `next' statement causes the end of the input to be reached,
then the code in any `END' rules is executed. *Note BEGIN/END::.
- The `next' statement is not inside `BEGINFILE' and `ENDFILE' rules.
-*Note BEGINFILE/ENDFILE::.
+ The `next' statement is not allowed inside `BEGINFILE' and `ENDFILE'
+rules. *Note BEGINFILE/ENDFILE::.
According to the POSIX standard, the behavior is undefined if the
`next' statement is used in a `BEGIN' or `END' rule. `gawk' treats it
@@ -8927,13 +8966,14 @@ processing the current data file.
implementations, or if `gawk' is in compatibility mode (*note
Options::), `nextfile' is not special.
- Upon execution of the `nextfile' statement, `FILENAME' is updated to
-the name of the next data file listed on the command line, `FNR' is
-reset to one, `ARGIND' is incremented, and processing starts over with
-the first rule in the program. (`ARGIND' hasn't been introduced yet.
-*Note Built-in Variables::.) If the `nextfile' statement causes the
-end of the input to be reached, then the code in any `END' rules is
-executed. *Note BEGIN/END::.
+ Upon execution of the `nextfile' statement, any `ENDFILE' rules are
+executed, `FILENAME' is updated to the name of the next data file
+listed on the command line, `FNR' is reset to one, `ARGIND' is
+incremented, any `BEGINFILE' rules are executed, and processing starts
+over with the first rule in the program. (`ARGIND' hasn't been
+introduced yet. *Note Built-in Variables::.) If the `nextfile'
+statement causes the end of the input to be reached, then the code in
+any `END' rules is executed. *Note BEGIN/END::.
The `nextfile' statement is useful when there are many data files to
process but it isn't necessary to process every record in every file.
@@ -8962,9 +9002,6 @@ Versions::) also supports `nextfile'. However, it
doesn't allow the
and starts processing it with the first rule in the program, just as
any other `nextfile' statement.
- The `nextfile' statement has a special purpose when used inside a
-`BEGINFILE' rule; see *note BEGINFILE/ENDFILE::.
-
File: gawk.info, Node: Exit Statement, Prev: Nextfile Statement, Up:
Statements
@@ -8987,7 +9024,8 @@ stop immediately.
An `exit' statement that is not part of a `BEGIN' or `END' rule
stops the execution of any further automatic rules for the current
record, skips reading any remaining input records, and executes the
-`END' rule if there is one.
+`END' rule if there is one. Any `ENDFILE' rules are also skipped; they
+are not executed.
In such a case, if you don't want the `END' rule to do its job, set
a variable to nonzero before the `exit' statement and check that
@@ -9016,9 +9054,10 @@ statement with a nonzero argument, as shown in the
following example:
close("date")
}
- For full portability, exit values should be between zero and 126,
-inclusive. Negative values, and values of 127 or greater, may not
-produce consistent results across different operating systems.
+ NOTE: For full portability, exit values should be between zero and
+ 126, inclusive. Negative values, and values of 127 or greater,
+ may not produce consistent results across different operating
+ systems.
File: gawk.info, Node: Built-in Variables, Prev: Statements, Up: Patterns
and Actions
@@ -9065,9 +9104,9 @@ specific to `gawk' are marked with a pound sign (`#').
Alternatively, string values of `"r"' or `"w"' specify that input
files and output files, respectively, should use binary I/O. A
string value of `"rw"' or `"wr"' indicates that all files should
- use binary I/O. Any other string value is equivalent to `"rw"',
- but `gawk' generates a warning message. `BINMODE' is described in
- more detail in *note PC Using::.
+ use binary I/O. Any other string value is treated the same as
+ `"rw"', but causes `gawk' to generate a warning message.
+ `BINMODE' is described in more detail in *note PC Using::.
This variable is a `gawk' extension. In other `awk'
implementations (except `mawk', *note Other Versions::), or if
@@ -9134,10 +9173,10 @@ specific to `gawk' are marked with a pound sign (`#').
regexp matching with `~' and `!~', as well as the `gensub()',
`gsub()', `index()', `match()', `patsplit()', `split()', and
`sub()' functions, record termination with `RS', and field
- splitting with `FS', all ignore case when doing their particular
- regexp operations. However, the value of `IGNORECASE' does _not_
- affect array subscripting and it does not affect field splitting
- when using a single-character field separator. *Note
+ splitting with `FS' and `FPAT', all ignore case when doing their
+ particular regexp operations. However, the value of `IGNORECASE'
+ does _not_ affect array subscripting and it does not affect field
+ splitting when using a single-character field separator. *Note
Case-sensitivity::.
If `gawk' is in compatibility mode (*note Options::), then
@@ -9241,10 +9280,10 @@ with a pound sign (`#').
-| inventory-shipped
-| BBS-list
- `ARGV[0]' contains `"awk"', `ARGV[1]' contains
- `"inventory-shipped"', and `ARGV[2]' contains `"BBS-list"'. The
- value of `ARGC' is three, one more than the index of the last
- element in `ARGV', because the elements are numbered from zero.
+ `ARGV[0]' contains `awk', `ARGV[1]' contains `inventory-shipped',
+ and `ARGV[2]' contains `BBS-list'. The value of `ARGC' is three,
+ one more than the index of the last element in `ARGV', because the
+ elements are numbered from zero.
The names `ARGC' and `ARGV', as well as the convention of indexing
the array from 0 to `ARGC' - 1, are derived from the C language's
@@ -9292,8 +9331,8 @@ with a pound sign (`#').
during a read for `getline', or during a `close()' operation, then
`ERRNO' contains a string describing the error.
- Starting with version 4.0, `gawk' clears `ERRNO' before opening
- each command-line input file. This enables checking if the file is
+ In addition, `gawk' clears `ERRNO' before opening each
+ command-line input file. This enables checking if the file is
readable inside a `BEGINFILE' pattern (*note BEGINFILE/ENDFILE::).
Otherwise, `ERRNO' works similarly to the C variable `errno'.
@@ -9330,7 +9369,7 @@ with a pound sign (`#').
Unlike most of the variables described in this node, assigning a
value to `NF' has the potential to affect `awk''s internal
workings. In particular, assignments to `NF' can be used to
- create or remove fields from the current record: *Note Changing
+ create or remove fields from the current record. *Note Changing
Fields::.
`NR'
@@ -9352,7 +9391,7 @@ with a pound sign (`#').
`PROCINFO["FS"]'
This is `"FS"' if field splitting with `FS' is in effect,
`"FIELDWIDTHS"' if field splitting with `FIELDWIDTHS' is in
- effect, or it is `"FPAT"' if field matching with `FPAT' is in
+ effect, or `"FPAT"' if field matching with `FPAT' is in
effect.
`PROCINFO["gid"]'
@@ -9367,9 +9406,6 @@ with a pound sign (`#').
`PROCINFO["ppid"]'
The parent process ID of the current process.
- `PROCINFO["uid"]'
- The value of the `getuid()' system call.
-
`PROCINFO["sorted_in"]'
If this element exists in `PROCINFO', its value controls the
order in which array indices will be processed by `for(i in
@@ -9390,6 +9426,9 @@ with a pound sign (`#').
new value to this element changes the default. *Note Time
Functions::.
+ `PROCINFO["uid"]'
+ The value of the `getuid()' system call.
+
`PROCINFO["version"]'
The version of `gawk'.
@@ -9553,7 +9592,8 @@ recognize. The previous example with `gawk' would be:
gawk -f myprog -d -v file1 file2 ...
Because `-d' is not a valid `gawk' option, it and the following `-v'
-are passed on to the `awk' program.
+are passed on to the `awk' program. (*Note Getopt Function::, for an
+`awk' library function that parses command-line options.)
File: gawk.info, Node: Arrays, Next: Functions, Prev: Patterns and Actions,
Up: Top
@@ -9890,11 +9930,11 @@ built-in function `length()'.
The order in which elements of the array are accessed by this
statement is determined by the internal arrangement of the array
-elements within `awk' and cannot be controlled or changed. This can
-lead to problems if new elements are added to ARRAY by statements in
-the loop body; it is not predictable whether the `for' loop will reach
-them. Similarly, changing VAR inside the loop may produce strange
-results. It is best to avoid such things.
+elements within `awk' and normally cannot be controlled or changed.
+This can lead to problems if new elements are added to ARRAY by
+statements in the loop body; it is not predictable whether the `for'
+loop will reach them. Similarly, changing VAR inside the loop may
+produce strange results. It is best to avoid such things.
As an extension, `gawk' makes it possible for you to loop over the
elements of an array in order, based on the value of
@@ -9943,7 +9983,7 @@ To remove an individual element of an array, use the
`delete' statement:
Once an array element has been deleted, any value the element once
had is no longer available. It is as if the element had never been
-referred to or had been given a value. The following is an example of
+referred to or been given a value. The following is an example of
deleting elements in an array:
for (i in frequencies)
@@ -9965,10 +10005,10 @@ as assigning it a null value (the empty string, `""').
For example:
if (4 in foo)
print "This is printed, even though foo[4] is empty"
- It is not an error to delete an element that does not exist. If
-`--lint' is provided on the command line (*note Options::), `gawk'
-issues a warning message when an element that is not in the array is
-deleted.
+ It is not an error to delete an element that does not exist.
+However, if `--lint' is provided on the command line (*note Options::),
+`gawk' issues a warning message when an element that is not in the
+array is deleted.
All the elements of an array may be deleted with a single statement
(c.e.) by leaving off the subscript in the `delete' statement, as
@@ -10282,7 +10322,7 @@ result array:
Work with sorted indices directly:
DO SOMETHING WITH dest[i]
...
- Access original array via sorted indices:
+ Access original array via sorted indices:
DO SOMETHING WITH source[dest[i]]
}
}
@@ -10296,8 +10336,7 @@ indices.
memory. Internally, `gawk' maintains "reference counts" to data. For
example, when `asort()' copies the first array to the second one, there
is only one copy of the original array elements' data, even though both
-arrays use the values. Similarly, when copying the indices from `data'
-to `ind', there is only one copy of the actual index strings.
+arrays use the values.
We said previously that comparisons are done using `gawk''s "usual
comparison rules." Because `IGNORECASE' affects string comparisons,
@@ -10366,8 +10405,8 @@ as a scalar.
The built-in functions which take array arguments can also be used
with subarrays. For example, the following code fragment uses `length()'
-to determine the number of elements in the main array `a' and its
-subarrays:
+(*note String Functions::) to determine the number of elements in the
+main array `a' and its subarrays:
print length(a), length(a[1]), length(a[1][3])
@@ -10398,7 +10437,7 @@ an array element is itself an array:
if (isarray(array[i]) {
for (j in array[i]) {
print array[i][j]
- }
+ }
}
}
@@ -10490,10 +10529,10 @@ function followed by arguments in parentheses. For
example, `atan2(y +
z, 1)' is a call to the function `atan2()' and has two arguments.
Whitespace is ignored between the built-in function name and the
-open parenthesis, and it is good practice to avoid using whitespace
-there. User-defined functions do not permit whitespace in this way, and
-it is easier to avoid mistakes by following a simple convention that
-always works--no whitespace after a function name.
+open parenthesis, but nonetheless it is good practice to avoid using
+whitespace there. User-defined functions do not permit whitespace in
+this way, and it is easier to avoid mistakes by following a simple
+convention that always works--no whitespace after a function name.
Each built-in function accepts a certain number of arguments. In
some cases, arguments can be omitted. The defaults for omitted
@@ -10600,8 +10639,8 @@ brackets ([ ]):
Return the sine of X, with X in radians.
`sqrt(X)'
- Return the positive square root of X. `gawk' reports an error if
- X is negative. Thus, `sqrt(4)' is 2.
+ Return the positive square root of X. `gawk' prints a warning
+ message if X is negative. Thus, `sqrt(4)' is 2.
`srand([X])'
Set the starting point, or seed, for generating random numbers to
@@ -10626,11 +10665,12 @@ brackets ([ ]):
---------- Footnotes ----------
- (1) The C version of `rand()' is known to produce fairly poor
-sequences of random numbers. However, nothing requires that an `awk'
-implementation use the C `rand()' to implement the `awk' version of
-`rand()'. In fact, `gawk' uses the BSD `random()' function, which is
-considerably better than `rand()', to produce random numbers.
+ (1) The C version of `rand()' on many Unix systems is known to
+produce fairly poor sequences of random numbers. However, nothing
+requires that an `awk' implementation use the C `rand()' to implement
+the `awk' version of `rand()'. In fact, `gawk' uses the BSD `random()'
+function, which is considerably better than `rand()', to produce random
+numbers.
(2) `mawk' uses a different seed each time.
@@ -10646,9 +10686,20 @@ File: gawk.info, Node: String Functions, Next: I/O
Functions, Prev: Numeric F
-----------------------------------
The functions in this minor node look at or change the text of one or
-more strings. Optional parameters are enclosed in square
-brackets ([ ]). Those functions that are specific to `gawk' are marked
-with a pound sign (`#'):
+more strings. `gawk' understands locales (*note Locales::), and does
+all string processing in terms of _characters_, not _bytes_. This
+distinction is particularly important to understand for locales where
+one character may be represented by multiple bytes. Thus, for example,
+`length()' returns the number of characters in a string, and not the
+number of bytes used to represent those characters, Similarly,
+`index()' works with character indices, and not byte indices.
+
+ In the following list, optional parameters are enclosed in square
+brackets ([ ]). Several functions perform string substitution; the
+full discussion is provided in the description of the `sub()' function,
+which comes towards the end since the list is presented in alphabetic
+order. Those functions that are specific to `gawk' are marked with a
+pound sign (`#'):
* Menu:
@@ -10697,12 +10748,12 @@ with a pound sign (`#'):
`gensub(REGEXP, REPLACEMENT, HOW [, TARGET]) #'
Search the target string TARGET for matches of the regular
- expression REGEXP. If HOW is a string beginning with `g' or `G',
- then replace all matches of REGEXP with REPLACEMENT. Otherwise,
- HOW is treated as a number indicating which match of REGEXP to
- replace. If no TARGET is supplied, use `$0'. It returns the
- modified string is returned as the result of the function and the
- original target string is _not_ changed.
+ expression REGEXP. If HOW is a string beginning with `g' or `G'
+ (short for "global"), then replace all matches of REGEXP with
+ REPLACEMENT. Otherwise, HOW is treated as a number indicating
+ which match of REGEXP to replace. If no TARGET is supplied, use
+ `$0'. It returns the modified string as the result of the
+ function and the original target string is _not_ changed.
`gensub()' is a general substitution function. It's purpose is to
provide more features than the standard `sub()' and `gsub()'
@@ -10733,9 +10784,9 @@ with a pound sign (`#'):
> gawk '{ print gensub(/a/, "AA", 2) }'
-| a b c AA b c
- In this case, `$0' is used as the default target string.
- `gensub()' returns the new string as its result, which is passed
- directly to `print' for printing.
+ In this case, `$0' is the default target string. `gensub()'
+ returns the new string as its result, which is passed directly to
+ `print' for printing.
If the HOW argument is a string that does not begin with `g' or
`G', or if it is a number that is less than or equal to zero, only
@@ -10778,10 +10829,10 @@ with a pound sign (`#'):
`length([STRING])'
Return the number of characters in STRING. If STRING is a number,
the length of the digit string representing that number is
- returned. For example, `length("abcde")' is 5. By contrast,
- `length(15 * 35)' works out to 3. In this example, 15 * 35 = 525,
- and 525 is then converted to the string `"525"', which has three
- characters.
+ returned. For example, `length("abcde")' is five. By contrast,
+ `length(15 * 35)' works out to three. In this example, 15 * 35 =
+ 525, and 525 is then converted to the string `"525"', which has
+ three characters.
If no argument is supplied, `length()' returns the length of `$0'.
@@ -10806,8 +10857,8 @@ with a pound sign (`#'):
If `--lint' has been specified on the command line, `gawk' issues a
warning about this.
- With `gawk' and several other `awk' implementations, when supplied
- an array argument, the `length()' function returns the number of
+ With `gawk' and several other `awk' implementations, when given an
+ array argument, the `length()' function returns the number of
elements in the array. (c.e.) This is less useful than it might
seem at first, as the array is not guaranteed to be indexed from
one to the number of elements in it. If `--lint' is provided on
@@ -10869,7 +10920,7 @@ with a pound sign (`#'):
Match of ru+n found at 12 in My program runs
Match of Melvin found at 1 in Melvin was here.
- If ARRAY is present, it is cleared, and then the 0th element of
+ If ARRAY is present, it is cleared, and then the zeroth element of
ARRAY is set to the entire portion of STRING matched by REGEXP.
If REGEXP contains parentheses, the integer-indexed elements of
ARRAY are set to contain the portion of STRING matching the
@@ -10894,7 +10945,7 @@ with a pound sign (`#'):
-| 9 7
There may not be subscripts for the start and index for every
- parenthesized subexpressions, since they may not all have matched
+ parenthesized subexpression, since they may not all have matched
text; thus they should be tested for with the `in' operator (*note
Reference to Elements::).
@@ -10915,7 +10966,8 @@ with a pound sign (`#'):
leading separator will be in `SEPS[0]'.
The `patsplit()' function splits strings into pieces in a manner
- similar to the way input lines are split into fields using `FPAT'.
+ similar to the way input lines are split into fields using `FPAT'
+ (*note Splitting By Content::.
Before splitting the string, `patsplit()' deletes any previously
existing elements in the arrays ARRAY and SEPS.
@@ -10929,14 +10981,15 @@ with a pound sign (`#'):
first piece is stored in `ARRAY[1]', the second piece in
`ARRAY[2]', and so forth. The string value of the third argument,
FIELDSEP, is a regexp describing where to split STRING (much as
- `FS' can be a regexp describing where to split input records). If
- FIELDSEP is omitted, the value of `FS' is used. `split()' returns
- the number of elements created. SEPS is a `gawk' extension with
- `SEPS[I]' being the separator string between `ARRAY[I]' and
- `ARRAY[I+1]'. If FIELDSEP is a single space then any leading
- whitespace goes into `SEPS[0]' and any trailing whitespace goes
- into `SEPS[N]' where N is the return value of `split()' (that is,
- the number of elements in ARRAY).
+ `FS' can be a regexp describing where to split input records;
+ *note Regexp Field Splitting::). If FIELDSEP is omitted, the
+ value of `FS' is used. `split()' returns the number of elements
+ created. SEPS is a `gawk' extension with `SEPS[I]' being the
+ separator string between `ARRAY[I]' and `ARRAY[I+1]'. If FIELDSEP
+ is a single space then any leading whitespace goes into `SEPS[0]'
+ and any trailing whitespace goes into `SEPS[N]' where N is the
+ return value of `split()' (that is, the number of elements in
+ ARRAY).
The `split()' function splits strings into pieces in a manner
similar to the way input lines are split into fields. For example:
@@ -10963,7 +11016,7 @@ with a pound sign (`#'):
are separated by runs of whitespace. Also as with input
field-splitting, if FIELDSEP is the null string, each individual
character in the string is split into its own array element.
- (This latter is a `gawk'-specific extension.)
+ (c.e.)
Note, however, that `RS' has no effect on the way `split()' works.
Even though `RS = ""' causes newline to also be an input field
@@ -10993,7 +11046,7 @@ with a pound sign (`#'):
pival = sprintf("pi = %.2f (approx.)", 22/7)
- assigns the string `"pi = 3.14 (approx.)"' to the variable `pival'.
+ assigns the string `pi = 3.14 (approx.)' to the variable `pival'.
`strtonum(STR) #'
Examine STR and return its numeric value. If STR begins with a
@@ -11010,17 +11063,17 @@ with a pound sign (`#'):
works only for decimal data, not for octal or hexadecimal.(1)
Note also that `strtonum()' uses the current locale's decimal point
- for recognizing numbers.
+ for recognizing numbers (*note Locales::).
`strtonum()' is a `gawk' extension; it is not available in
compatibility mode (*note Options::).
`sub(REGEXP, REPLACEMENT [, TARGET])'
- It searches TARGET, which is treated as a string, for the
- leftmost, longest substring matched by the regular expression
- REGEXP. Modify the entire string by replacing the matched text
- with REPLACEMENT. The modified string becomes the new value of
- TARGET.
+ Search TARGET, which is treated as a string, for the leftmost,
+ longest substring matched by the regular expression REGEXP.
+ Modify the entire string by replacing the matched text with
+ REPLACEMENT. The modified string becomes the new value of TARGET.
+ Return the number of substitutions made (zero or one).
The REGEXP argument may be either a regexp constant (`/.../') or a
string constant (`"..."'). In the latter case, the string is
@@ -11037,12 +11090,9 @@ with a pound sign (`#'):
str = "water, water, everywhere"
sub(/at/, "ith", str)
- sets `str' to `"wither, water, everywhere"', by replacing the
+ sets `str' to `wither, water, everywhere', by replacing the
leftmost longest occurrence of `at' with `ith'.
- The `sub()' function returns the number of substitutions made
- (either one or zero).
-
If the special character `&' appears in REPLACEMENT, it stands for
the precise substring that was matched by REGEXP. (If the regexp
can match more than one string, then this precise substring may
@@ -11104,11 +11154,11 @@ with a pound sign (`#'):
remaining in the string, counting from character START.
If START is less than one, `substr()' treats it as if it was one.
- (POSIX doesn't specify what to do in this case: Unix `awk' acts
- this way, and therefore `gawk' does too.) If START is greater
- than the number of characters in the string, `substr()' returns
- the null string. Similarly, if LENGTH is present but less than or
- equal to zero, the null string is returned.
+ (POSIX doesn't specify what to do in this case: Brian Kernighan's
+ `awk' acts this way, and therefore `gawk' does too.) If START is
+ greater than the number of characters in the string, `substr()'
+ returns the null string. Similarly, if LENGTH is present but less
+ than or equal to zero, the null string is returned.
The string returned by `substr()' _cannot_ be assigned. Thus, it
is a mistake to attempt to change a portion of a string, as shown
@@ -11123,8 +11173,8 @@ with a pound sign (`#'):
gsub(/xyz/, "pdq", substr($0, 5, 20)) # WRONG
- (Some commercial versions of `awk' do in fact let you use
- `substr()' this way, but doing so is not portable.)
+ (Some commercial versions of `awk' treat `substr()' as assignable,
+ but doing so is not portable.)
If you need to replace bits and pieces of a string, combine
`substr()' with string concatenation, in the following manner:
@@ -11176,11 +11226,11 @@ replacement string to determine what to generate.
At both levels, `awk' looks for a defined set of characters that can
come after a backslash. At the lexical level, it looks for the escape
sequences listed in *note Escape Sequences::. Thus, for every `\' that
-`awk' processes at the runtime level, type two backslashes at the
-lexical level. When a character that is not valid for an escape
-sequence follows the `\', Unix `awk' and `gawk' both simply remove the
-initial `\' and put the next character into the string. Thus, for
-example, `"a\qb"' is treated as `"aqb"'.
+`awk' processes at the runtime level, you must type two backslashes at
+the lexical level. When a character that is not valid for an escape
+sequence follows the `\', Brian Kernighan's `awk' and `gawk' both
+simply remove the initial `\' and put the next character into the
+string. Thus, for example, `"a\qb"' is treated as `"aqb"'.
At the runtime level, the various functions handle sequences of `\'
and `&' differently. The situation is (sadly) somewhat complex.
@@ -11225,7 +11275,7 @@ rules are presented in *note table-posix-sub::.
`\\q' `\q' a literal `\q'
`\\\\' `\\' `\'
-Table 9.2: POSIX rules for `sub()'
+Table 9.2: POSIX rules for `sub()' and `gsub()'
`gawk' follows the POSIX rules.
@@ -11311,8 +11361,8 @@ parameters are enclosed in square brackets ([ ]):
to allow no argument at all. In this case, the buffer for the
standard output is flushed. The second is to allow the null string
(`""') as the argument. In this case, the buffers for _all_ open
- output files and pipes are flushed. Current versions of the Brian
- Kernighan's `awk' also support these extensions.
+ output files and pipes are flushed. Brian Kernighan's `awk' also
+ supports these extensions.
`fflush()' returns zero if the buffer is successfully flushed;
otherwise, it returns -1. In the case where all buffers are
@@ -11327,7 +11377,7 @@ parameters are enclosed in square brackets ([ ]):
`system(COMMAND)'
Execute the operating-system command COMMAND and then return to
- the `awk' program. It returns COMMAND's exit status as its value.
+ the `awk' program. Return COMMAND's exit status.
For example, if the following fragment of code is put in your `awk'
program:
@@ -11496,11 +11546,11 @@ Optional parameters are enclosed in square brackets
([ ]):
`systime()' function. If no TIMESTAMP argument is supplied,
`gawk' uses the current time of day as the timestamp. If no
FORMAT argument is supplied, `strftime()' uses the value of
- `PROCINFO["strftime"]' as the format string. The default string
- value is `"%a %b %e %H:%M:%S %Z %Y"'. This format string produces
- output that is equivalent to that of the `date' utility. You can
- assign a new value to `PROCINFO["strftime"]' to change the default
- format.
+ `PROCINFO["strftime"]' as the format string (*note Built-in
+ Variables::). The default string value is
+ `"%a %b %e %H:%M:%S %Z %Y"'. This format string produces output
+ that is equivalent to that of the `date' utility. You can assign
+ a new value to `PROCINFO["strftime"]' to change the default format.
`systime()'
Return the current time as the number of seconds since the system
@@ -11672,10 +11722,10 @@ undefined.(6)
Informally, a "locale" is the geographic place in which a program is
meant to run. For example, a common way to abbreviate the date
-September 4, 1991 in the United States is "9/4/91." In many countries
-in Europe, however, it is abbreviated "4.9.91." Thus, the `%x'
-specification in a `"US"' locale might produce `9/4/91', while in a
-`"EUROPE"' locale, it might produce `4.9.91'. The ISO C standard
+September 4, 2012 in the United States is "9/4/12." In many countries
+in Europe, however, it is abbreviated "4.9.12." Thus, the `%x'
+specification in a `"US"' locale might produce `9/4/12', while in a
+`"EUROPE"' locale, it might produce `4.9.12'. The ISO C standard
defines a default `"C"' locale, which is an environment that is typical
of what many C programmers are used to.
@@ -11901,7 +11951,8 @@ File: gawk.info, Node: Type Functions, Next: I18N
Functions, Prev: Bitwise Fu
`gawk' provides a single function that lets you distinguish an array
from a scalar variable. This is necessary for writing code that
-traverses every element of a multidimensional array.
+traverses every element of a true multidimensional array (*note Arrays
+of Arrays::).
`isarray(X)'
Return a true value if X is an array. Otherwise return false.
@@ -11982,8 +12033,8 @@ starting to execute any of it.
BODY-OF-FUNCTION
}
-NAME is the name of the function to define. A valid function name is
-like a valid variable name: a sequence of letters, digits, and
+Here, NAME is the name of the function to define. A valid function
+name is like a valid variable name: a sequence of letters, digits, and
underscores that doesn't start with a digit. Within a single `awk'
program, any particular name can only be used as a variable, array, or
function.
@@ -12040,6 +12091,11 @@ can even call this function, either directly or by way
of another
function. When this happens, we say the function is "recursive". The
act of a function calling itself is called "recursion".
+ All the built-in functions return a value to their caller.
+User-defined functions can do also, using the `return' statement, which
+is described in detail in *note Return Statement::. Many of the
+subsequent examples in this minor node use the `return' statement.
+
In many `awk' implementations, including `gawk', the keyword
`function' may be abbreviated `func'. (c.e.) However, POSIX only
specifies the use of the keyword `function'. This actually has some
@@ -12207,6 +12263,7 @@ global variable used by both functions `foo()' and
`bar()':
for (i = 0; i < 3; i++)
print "bar's i=" i
}
+
function foo(j)
{
i = j + 1
@@ -12232,7 +12289,6 @@ variable instance:
bar's i=1
bar's i=2
foo's i=3
- foo's i=3
top's i=3
If you want `i' to be local to both `foo()' and `bar()' do as
@@ -12244,6 +12300,7 @@ that `i' is a local variable, not an argument):
for (i = 0; i < 3; i++)
print "bar's i=" i
}
+
function foo(j, i)
{
i = j + 1
@@ -12254,17 +12311,19 @@ that `i' is a local variable, not an argument):
BEGIN {
i = 10
+ print "top's i=" i
foo(0)
+ print "top's i=" i
}
Running the corrected script produces the following:
top's i=10
- bar's i=1
- foo's i=0
foo's i=1
- foo's i=2
+ bar's i=0
bar's i=1
+ bar's i=2
+ foo's i=1
top's i=10
@@ -12368,10 +12427,11 @@ File: gawk.info, Node: Return Statement, Next:
Dynamic Typing, Prev: Function
9.2.4 The `return' Statement
----------------------------
-The body of a user-defined function can contain a `return' statement.
-This statement returns control to the calling part of the `awk'
-program. It can also be used to return a value for use in the rest of
-the `awk' program. It looks like this:
+As seen in several earlier examples, the body of a user-defined
+function can contain a `return' statement. This statement returns
+control to the calling part of the `awk' program. It can also be used
+to return a value for use in the rest of the `awk' program. It looks
+like this:
return [EXPRESSION]
@@ -12389,10 +12449,10 @@ value. In practice, it returns the empty string.
`awk' does _not_
warn you if you use the return value of such a function.
Sometimes, you want to write a function for what it does, not for
-what it returns. Such a function corresponds to a `void' function in C
-or to a `procedure' in Ada. Thus, it may be appropriate to not return
-any value; simply bear in mind that you should not be using the return
-value of such a function.
+what it returns. Such a function corresponds to a `void' function in
+C, C++ or Java, or to a `procedure' in Ada. Thus, it may be
+appropriate to not return any value; simply bear in mind that you
+should not be using the return value of such a function.
The following is an example of a user-defined function that returns
a value for the largest number among the elements of an array:
@@ -12410,9 +12470,8 @@ You call `maxelt()' with one argument, which is an
array name. The
local variables `i' and `ret' are not intended to be arguments; while
there is nothing to stop you from passing more than one argument to
`maxelt()', the results would be strange. The extra space before `i'
-in the function parameter list indicates that `i' and `ret' are not
-supposed to be arguments. You should follow this convention when
-defining functions.
+in the function parameter list indicates that `i' and `ret' are local
+variables. You should follow this convention when defining functions.
The following program uses the `maxelt()' function. It loads an
array, calls `maxelt()', and then reports the maximum number in that
@@ -12455,8 +12514,8 @@ File: gawk.info, Node: Dynamic Typing, Prev: Return
Statement, Up: User-defin
----------------------------------------------------
`awk' is a very fluid language. It is possible that `awk' can't tell
-if an identifier represents a regular variable or an array until
-runtime. Here is an annotated sample program:
+if an identifier represents a scalar variable or an array until runtime.
+Here is an annotated sample program:
function foo(a)
{
@@ -12545,7 +12604,7 @@ using indirect function calls.
return sum / (last - first + 1)
}
- # sum --- return the average of the values in fields $first - $last
+ # sum --- return the sum of the values in fields $first - $last
function sum(first, last, ret, i)
{
@@ -12557,8 +12616,8 @@ using indirect function calls.
}
These two functions expect to work on fields; thus the parameters
-`first' and `last' indicate where in the fields to start. Otherwise
-they perform the expected computations and are not unusual.
+`first' and `last' indicate where in the fields to start and end.
+Otherwise they perform the expected computations and are not unusual.
# For each record, print the class name and the requested statistics
@@ -12775,13 +12834,13 @@ countries, they were able to sell more systems. As a
result,
internationalization and localization of programs and software systems
became a common practice.
- Until recently, the ability to provide internationalization was
+ For many years, the ability to provide internationalization was
largely restricted to programs written in C and C++. This major node
describes the underlying library `gawk' uses for internationalization,
as well as how `gawk' makes internationalization features available at
the `awk' program level. Having internationalization available at the
`awk' level gives software developers additional flexibility--they are
-no longer required to write in C or C++ when internationalization is a
+no longer forced to write in C or C++ when internationalization is a
requirement.
* Menu:
@@ -12925,7 +12984,7 @@ are:
`LC_TIME'
Time- and date-related information, such as 12- or 24-hour clock,
- month printed before or after day in a date, local month
+ month printed before or after the day in a date, local month
abbreviations, and so on.
`LC_ALL'
@@ -12934,8 +12993,8 @@ are:
---------- Footnotes ----------
(1) For some operating systems, the `gawk' port doesn't support GNU
-`gettext'. As such, these features are not available if you are using
-one of those operating systems. Sorry.
+`gettext'. Therefore, these features are not available if you are
+using one of those operating systems. Sorry.
(2) Americans use a comma every three decimal places and a period
for the decimal point, while many Europeans do exactly the opposite:
@@ -12961,10 +13020,10 @@ internationalization:
underscore are not translated.
`dcgettext(STRING [, DOMAIN [, CATEGORY]])'
- This built-in function returns the translation of STRING in text
- domain DOMAIN for locale category CATEGORY. The default value for
- DOMAIN is the current value of `TEXTDOMAIN'. The default value
- for CATEGORY is `"LC_MESSAGES"'.
+ Return the translation of STRING in text domain DOMAIN for locale
+ category CATEGORY. The default value for DOMAIN is the current
+ value of `TEXTDOMAIN'. The default value for CATEGORY is
+ `"LC_MESSAGES"'.
If you supply a value for CATEGORY, it must be a string equal to
one of the known locale categories described in *note Explaining
@@ -12978,21 +13037,21 @@ internationalization:
arguments.
`dcngettext(STRING1, STRING2, NUMBER [, DOMAIN [, CATEGORY]])'
- This built-in function returns the plural form used for NUMBER of
- the translation of STRING1 and STRING2 in text domain DOMAIN for
- locale category CATEGORY. STRING1 is the English singular variant
- of a message, and STRING2 the English plural variant of the same
- message. The default value for DOMAIN is the current value of
- `TEXTDOMAIN'. The default value for CATEGORY is `"LC_MESSAGES"'.
+ Return the plural form used for NUMBER of the translation of
+ STRING1 and STRING2 in text domain DOMAIN for locale category
+ CATEGORY. STRING1 is the English singular variant of a message,
+ and STRING2 the English plural variant of the same message. The
+ default value for DOMAIN is the current value of `TEXTDOMAIN'.
+ The default value for CATEGORY is `"LC_MESSAGES"'.
The same remarks about argument order as for the `dcgettext()'
function apply.
`bindtextdomain(DIRECTORY [, DOMAIN])'
- This built-in function allows you to specify the directory in which
- `gettext' looks for `.mo' files, in case they will not or cannot
- be placed in the standard locations (e.g., during testing). It
- returns the directory in which DOMAIN is "bound."
+ Change the directory in which `gettext' looks for `.mo' files, in
+ case they will not or cannot be placed in the standard locations
+ (e.g., during testing). Return the directory in which DOMAIN is
+ "bound."
The default DOMAIN is the value of `TEXTDOMAIN'. If DIRECTORY is
the null string (`""'), then `bindtextdomain()' returns the
@@ -13458,10 +13517,10 @@ the program be run in a directory that cannot be
shared among users;
for example, `/tmp' will not do, as another user might happen to be
using a temporary file with the same name.
- It is possible to open a _two-way_ pipe to another process. The
-second process is termed a "coprocess", since it runs in parallel with
-`gawk'. The two-way connection is created using the new `|&' operator
-(borrowed from the Korn shell, `ksh'):(1)
+ However, with `gawk', it is possible to open a _two-way_ pipe to
+another process. The second process is termed a "coprocess", since it
+runs in parallel with `gawk'. The two-way connection is created using
+the `|&' operator (borrowed from the Korn shell, `ksh'):(1)
do {
print DATA |& "subprogram"
@@ -13495,7 +13554,7 @@ or pipeline of programs, that can be started by the
shell.
coprocess, by supplying a second argument to the `close()' function of
either `"to"' or `"from"' (*note Close Files And Pipes::). These
strings tell `gawk' to close the end of the pipe that sends data to the
-process or the end that reads from it, respectively.
+coprocess or the end that reads from it, respectively.
This is particularly necessary in order to use the system `sort'
utility as part of a coprocess; `sort' must read _all_ of its input
@@ -13547,8 +13606,7 @@ regular pipes.
---------- Footnotes ----------
- (1) This is very different from the same operator in the C shell,
-`csh'.
+ (1) This is very different from the same operator in the C shell.
File: gawk.info, Node: TCP/IP Networking, Next: Profiling, Prev: Two-way
I/O, Up: Advanced Features
@@ -13556,7 +13614,8 @@ File: gawk.info, Node: TCP/IP Networking, Next:
Profiling, Prev: Two-way I/O,
11.3 Using `gawk' for Network Programming
=========================================
- `EMISTERED': A host is a host from coast to coast,
+ `EMISTERED':
+ A host is a host from coast to coast,
and no-one can talk to host that's close,
unless the host that isn't close
is busy hung or dead.
@@ -13737,7 +13796,7 @@ output. They are as follows:
* The program is printed in the order `BEGIN' rule, `BEGINFILE' rule,
pattern/action rules, `ENDFILE' rule, `END' rule and functions,
listed alphabetically. Multiple `BEGIN' and `END' rules are
- merged together.
+ merged together, as are multiple `BEGINFILE' and `ENDFILE' rules.
* Pattern-action rules have two counts. The first count, to the
left of the rule, shows how many times the rule's pattern was
@@ -13787,8 +13846,8 @@ you typed when you wrote it. This is because `pgawk'
creates the
profiled version by "pretty printing" its internal representation of
the program. The advantage to this is that `pgawk' can produce a
standard representation. The disadvantage is that all source-code
-comments are lost, as are the distinctions among multiple `BEGIN' and
-`END' rules. Also, things such as:
+comments are lost, as are the distinctions among multiple `BEGIN',
+`END', `BEGINFILE', and `ENDFILE' rules. Also, things such as:
/foo/
@@ -13880,24 +13939,25 @@ community, see *note How To Contribute::, for more
information.
freely use features that are `gawk'-specific. Rewriting these programs
for different implementations of `awk' is pretty straightforward.
- Diagnostic error messages are sent to `/dev/stderr'. Use `| "cat
-1>&2"' instead of `> "/dev/stderr"' if your system does not have a
-`/dev/stderr', or if you cannot use `gawk'.
+ * Diagnostic error messages are sent to `/dev/stderr'. Use `| "cat
+ 1>&2"' instead of `> "/dev/stderr"' if your system does not have a
+ `/dev/stderr', or if you cannot use `gawk'.
- A number of programs use `nextfile' (*note Nextfile Statement::) to
-skip any remaining input in the input file. *note Nextfile Function::,
-shows you how to write a function that does the same thing.
+ * A number of programs use `nextfile' (*note Nextfile Statement::)
+ to skip any remaining input in the input file. *note Nextfile
+ Function::, shows you how to write a function that does the same
+ thing.
- Finally, some of the programs choose to ignore upper- and lowercase
-distinctions in their input. They do so by assigning one to
-`IGNORECASE'. You can achieve almost the same effect(1) by adding the
-following rule to the beginning of the program:
+ * Finally, some of the programs choose to ignore upper- and lowercase
+ distinctions in their input. They do so by assigning one to
+ `IGNORECASE'. You can achieve almost the same effect(1) by adding
+ the following rule to the beginning of the program:
- # ignore case
- { $0 = tolower($0) }
+ # ignore case
+ { $0 = tolower($0) }
-Also, verify that all regexp and string constants used in comparisons
-use only lowercase letters.
+ Also, verify that all regexp and string constants used in
+ comparisons use only lowercase letters.
* Menu:
@@ -14122,7 +14182,8 @@ The `strtonum()' function (*note String Functions::) is
a `gawk'
extension. The following function provides an implementation for other
versions of `awk':
- # strtonum --- convert string to number
+ # mystrtonum --- convert string to number
+
function mystrtonum(str, ret, chars, n, i, k, c)
{
if (str ~ /^0[0-7]*$/) {
@@ -14177,17 +14238,17 @@ versions of `awk':
The function first looks for C-style octal numbers (base 8). If the
input string matches a regular expression describing octal numbers,
-then `mystrtonum' loops through each character in the string. It sets
-`k' to the index in `"01234567"' of the current octal digit. Since the
-return value is one-based, the `k--' adjusts `k' so it can be used in
-computing the return value.
+then `mystrtonum()' loops through each character in the string. It
+sets `k' to the index in `"01234567"' of the current octal digit.
+Since the return value is one-based, the `k--' adjusts `k' so it can be
+used in computing the return value.
Similar logic applies to the code that checks for and converts a
hexadecimal value, which starts with `0x' or `0X'. The use of
`tolower()' simplifies the computation for finding the correct numeric
value for each hexadecimal digit.
- Finally, if the string matches the (rather complicated) regex for a
+ Finally, if the string matches the (rather complicated) regexp for a
regular decimal integer or floating-point number, the computation `ret
= str + 0' lets `awk' convert the value to a number.
@@ -14295,7 +14356,7 @@ unbiased rounding, `.5' rounds to even, rather than
always up, so 1.5
rounds to 2 but 4.5 rounds to 4. This means that if you are using a
format that does rounding (e.g., `"%.0f"'), you should check what your
system does. The following function does traditional rounding; it
-might be useful if your awk's `printf' does unbiased rounding:
+might be useful if your `awk''s `printf' does unbiased rounding:
# round.awk --- do normal rounding
@@ -14452,7 +14513,7 @@ tests such as used here prohibitively expensive.
(2) ASCII has been extended in many countries to use the values from
128 to 255 for country-specific characters. If your system uses these
-extensions, you can simplify `_ord_init' to simply loop from 0 to 255.
+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
@@ -14966,8 +15027,9 @@ command-line arguments for `awk':
...
}
- As a side point, `gawk' actually uses the GNU `getopt_long' function
-to process both normal and GNU-style long options (*note Options::).
+ As a side point, `gawk' actually uses the GNU `getopt_long()'
+function to process both normal and GNU-style long options (*note
+Options::).
The abstraction provided by `getopt()' is very useful and is quite
handy in `awk' programs as well. Following is an `awk' version of
@@ -14994,10 +15056,11 @@ characters (*note String Functions::).(1)
# Private Data:
# _opti -- index in multi-flag option, e.g., -abc
- The function starts out with a list of the global variables it uses,
-what the return values are, what they mean, and any global variables
-that are "private" to this library function. Such documentation is
-essential for any program, and particularly for library functions.
+ The function starts out with comments presenting a list of the
+global variables it uses, what the return values are, what they mean,
+and any global variables that are "private" to this library function.
+Such documentation is essential for any program, and particularly for
+library functions.
The `getopt()' function first checks that it was indeed called with
a string of options (the `options' parameter). If `options' has a zero
@@ -15012,7 +15075,7 @@ length, `getopt()' immediately returns -1:
Optind++
_opti = 0
return -1
- } else if (argv[Optind] !~ /^-[^: \t\n\f\r\v\b]/) {
+ } else if (argv[Optind] !~ /^-[^:[:space:]]/) {
_opti = 0
return -1
}
@@ -15023,11 +15086,10 @@ not begin with a `-'. `Optind' is used to step
through the array of
command-line arguments; it retains its value across calls to
`getopt()', because it is a global variable.
- The regular expression that is used, `/^-[^: \t\n\f\r\v\b]/', is
-perhaps a bit of overkill; it checks for a `-' followed by anything
-that is not whitespace and not a colon. If the current command-line
-argument does not match this pattern, it is not an option, and it ends
-option processing. Continuing on:
+ The regular expression that is used, `/^-[^:[:space:]/', checks for
+a `-' followed by anything that is not whitespace and not a colon. If
+the current command-line argument does not match this pattern, it is
+not an option, and it ends option processing. Continuing on:
if (_opti == 0)
_opti = 2
@@ -15297,12 +15359,11 @@ corresponding to the C functions of the same names:
close(pwcat)
_pw_count = 0
_pw_inited = 1
+ FS = oldfs
if (using_fw)
FIELDWIDTHS = FIELDWIDTHS
else if (using_fpat)
FPAT = FPAT
- else
- FS = oldfs
RS = oldrs
$0 = olddol0
}
@@ -15316,7 +15377,7 @@ you might want it to be in a different directory on
your system.
in three associative arrays. The arrays are indexed by username
(`_pw_byname'), by user ID number (`_pw_byuid'), and by order of
occurrence (`_pw_bycount'). The variable `_pw_inited' is used for
-efficiency; `_pw_init()' needs only to be called once.
+efficiency, since `_pw_init()' needs to be called only once.
Because this function uses `getline' to read information from
`pwcat', it first saves the values of `FS', `RS', and `$0'. It notes
@@ -15535,12 +15596,11 @@ the same names:
close(grcat)
_gr_count = 0
_gr_inited++
+ FS = oldfs
if (using_fw)
FIELDWIDTHS = FIELDWIDTHS
else if (using_fpat)
FPAT = FPAT
- else
- FS = oldfs
RS = oldrs
$0 = olddol0
}
@@ -15652,7 +15712,7 @@ File: gawk.info, Node: Walking Arrays, Prev: Group
Functions, Up: Library Fun
arrays. In particular, any element of an array may be either a scalar,
or another array. The `isarray()' function (*note Type Functions::)
lets you distinguish an array from a scalar. The following function,
-`walk_array', recursively traverses an array, printing each element's
+`walk_array()', recursively traverses an array, printing each element's
indices and value. You call it with the array and a string
representing the name of the array:
@@ -15670,7 +15730,7 @@ It works by looping over each element of the array. If
any given
element is itself an array, the function calls itself recursively,
passing the subarray and a new string representing the current index.
Otherwise, the function simply prints the element's name, index, and
-value. Here is a main program to demonstrate
+value. Here is a main program to demonstrate:
BEGIN {
a[1] = 1
@@ -15749,9 +15809,10 @@ very concise and simple. This is true because `awk'
does so much for
you.
It should be noted that these programs are not necessarily intended
-to replace the installed versions on your system. Instead, their
-purpose is to illustrate `awk' language programming for "real world"
-tasks.
+to replace the installed versions on your system. Nor may all of these
+programs be fully compliant with the most recent POSIX standard. This
+is not a problem; their purpose is to illustrate `awk' language
+programming for "real world" tasks.
The programs are presented in alphabetical order.
@@ -17043,20 +17104,20 @@ Statement::), but the processing could be done with a
series of
switch (ARGC) {
case 5:
delay = ARGV[4] + 0
- # fall through
+ # fall through
case 4:
count = ARGV[3] + 0
- # fall through
+ # fall through
case 3:
message = ARGV[2]
- break
+ break
default:
if (ARGV[1] !~ /[[:digit:]]?[[:digit:]]:[[:digit:]][[:digit:]]/) {
print usage1 > "/dev/stderr"
print usage2 > "/dev/stderr"
exit 1
- }
- break
+ }
+ break
}
# set defaults for once we reach the desired time
@@ -18837,10 +18898,10 @@ execution of the program than we saw in our earlier
example:
...
`end'
Set a list of commands to be executed upon stopping at a
- breakpoint or watchpoint. N is the breakpoint or watchpoint
- number. Without a number, the last one set is used. The actual
- commands follow, starting on the next line, and terminated by the
- `end' command. If the command `silent' is in the list, the usual
+ breakpoint or watchpoint. N is the breakpoint or watchpoint number.
+ Without a number, the last one set is used. The actual commands
+ follow, starting on the next line, and terminated by the `end'
+ command. If the command `silent' is in the list, the usual
messages about stopping at a breakpoint and the source line are
not printed. Any command in the list that resumes execution (e.g.,
`continue') terminates the list (an implicit `end'), and
@@ -18931,7 +18992,7 @@ The commands for viewing and changing variables inside
of `gawk' are:
displays the assigned item number, the variable name and its
current value. If the display variable refers to a function
parameter, it is silently deleted from the list as soon as the
- execution reaches a context where no such variable of the given
+ execution reaches a context where no such variable of the given
name exists. Without argument, `display' displays the current
values of items on the list.
@@ -19164,7 +19225,7 @@ categories, as follows:
Program::) demonstrates:
dgawk> dump
- -| # BEGIN
+ -| # BEGIN
-|
-| [ 2:0x89faef4] Op_rule : [in_rule = BEGIN]
[source_file = brini.awk]
-| [ 3:0x89fa428] Op_push_i : "~" [PERM|STRING|STRCUR]
@@ -19905,9 +19966,9 @@ level is 0, but when retrieving distributions, you
should get the
version with the highest version, release, and patch level. (Note,
however, that patch levels greater than or equal to 70 denote "beta" or
nonproduction software; you might not want to retrieve such a version
-unless you don't mind experimenting.) If you are not on a Unix system,
-you need to make other arrangements for getting and extracting the
-`gawk' distribution. You should consult a local expert.
+unless you don't mind experimenting.) If you are not on a Unix or
+GNU/Linux system, you need to make other arrangements for getting and
+extracting the `gawk' distribution. You should consult a local expert.
File: gawk.info, Node: Distribution contents, Prev: Extracting, Up: Gawk
Distribution
@@ -20636,9 +20697,10 @@ to the original shell-style interface (see the help
entry for details).
One side effect of dual command-line parsing is that if there is only a
single parameter (as in the quoted string program above), the command
becomes ambiguous. To work around this, the normally optional `--'
-flag is required to force Unix style rather than `DCL' parsing. If any
-other dash-type options (or multiple parameters such as data files to
-process) are present, there is no ambiguity and `--' can be omitted.
+flag is required to force Unix-style parsing rather than `DCL' parsing.
+If any other dash-type options (or multiple parameters such as data
+files to process) are present, there is no ambiguity and `--' can be
+omitted.
The default search path, when looking for `awk' program files
specified by the `-f' option, is `"SYS$DISK:[],AWK_LIBRARY:"'. The
@@ -24168,7 +24230,7 @@ Index
* - (hyphen), -= operator <1>: Precedence. (line 95)
* - (hyphen), -= operator: Assignment Ops. (line 129)
* - (hyphen), filenames beginning with: Options. (line 59)
-* - (hyphen), in bracket expressions: Character Lists. (line 16)
+* - (hyphen), in bracket expressions: Bracket Expressions. (line 16)
* --assign option: Options. (line 32)
* --c option: Options. (line 78)
* --characters-as-bytes option: Options. (line 68)
@@ -24257,8 +24319,8 @@ Index
(line 148)
* / (forward slash), patterns and: Expression Patterns. (line 24)
* /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148)
-* /dev/... special files (gawk): Special FD. (line 45)
-* /dev/fd/N special files: Special FD. (line 45)
+* /dev/... special files (gawk): Special FD. (line 46)
+* /dev/fd/N special files: Special FD. (line 46)
* /inet/... special files (gawk): TCP/IP Networking. (line 6)
* /inet4/... special files (gawk): TCP/IP Networking. (line 6)
* /inet6/... special files (gawk): TCP/IP Networking. (line 6)
@@ -24338,7 +24400,7 @@ Index
(line 44)
* \ (backslash), gsub()/gensub()/sub() functions and: Gory Details.
(line 6)
-* \ (backslash), in bracket expressions: Character Lists. (line 16)
+* \ (backslash), in bracket expressions: Bracket Expressions. (line 16)
* \ (backslash), in escape sequences: Escape Sequences. (line 6)
* \ (backslash), in escape sequences, POSIX and: Escape Sequences.
(line 113)
@@ -24349,7 +24411,7 @@ Index
* ^ (caret), ^ operator: Precedence. (line 49)
* ^ (caret), ^= operator <1>: Precedence. (line 95)
* ^ (caret), ^= operator: Assignment Ops. (line 129)
-* ^ (caret), in bracket expressions: Character Lists. (line 16)
+* ^ (caret), in bracket expressions: Bracket Expressions. (line 16)
* ^, in FS: Regexp Field Splitting.
(line 59)
* _ (underscore), _ C macro: Explaining gettext. (line 70)
@@ -24439,7 +24501,7 @@ Index
* arrays, elements, order of: Scanning an Array. (line 48)
* arrays, elements, referencing: Reference to Elements.
(line 6)
-* arrays, elements, retrieving number of: String Functions. (line 18)
+* arrays, elements, retrieving number of: String Functions. (line 29)
* arrays, for statement and: Scanning an Array. (line 20)
* arrays, IGNORECASE variable and: Array Intro. (line 92)
* arrays, indexing: Array Intro. (line 50)
@@ -24449,7 +24511,7 @@ Index
* arrays, names of: Arrays. (line 18)
* arrays, scanning: Scanning an Array. (line 6)
* arrays, sorting: Array Sorting. (line 6)
-* arrays, sorting, IGNORECASE variable and: Array Sorting. (line 69)
+* arrays, sorting, IGNORECASE variable and: Array Sorting. (line 68)
* arrays, sparse: Array Intro. (line 71)
* arrays, subscripts: Numeric Array Subscripts.
(line 6)
@@ -24459,10 +24521,10 @@ Index
(line 47)
* ASCII <1>: Glossary. (line 137)
* ASCII: Ordinal Functions. (line 45)
-* asort() function (gawk) <1>: String Functions. (line 18)
+* asort() function (gawk) <1>: String Functions. (line 29)
* asort() function (gawk): Array Sorting. (line 6)
* asort() function (gawk), arrays, sorting: Array Sorting. (line 6)
-* asorti() function (gawk): String Functions. (line 46)
+* asorti() function (gawk): String Functions. (line 57)
* assert() function (C library): Assert Function. (line 6)
* assert() user-defined function: Assert Function. (line 28)
* assertions: Assert Function. (line 6)
@@ -24519,7 +24581,7 @@ Index
* awk, implementations, limits: Getline Notes. (line 14)
* awk, invoking: Command Line. (line 6)
* awk, new vs. old: Names. (line 6)
-* awk, new vs. old, OFMT variable: Conversion. (line 54)
+* awk, new vs. old, OFMT variable: Conversion. (line 55)
* awk, POSIX and: Preface. (line 22)
* awk, POSIX and, See Also POSIX awk: Preface. (line 22)
* awk, regexp constants and: Comparison Operators.
@@ -24592,7 +24654,7 @@ Index
(line 44)
* backslash (\), gsub()/gensub()/sub() functions and: Gory Details.
(line 6)
-* backslash (\), in bracket expressions: Character Lists. (line 16)
+* backslash (\), in bracket expressions: Bracket Expressions. (line 16)
* backslash (\), in escape sequences: Escape Sequences. (line 6)
* backslash (\), in escape sequences, POSIX and: Escape Sequences.
(line 113)
@@ -24613,13 +24675,13 @@ Index
* BEGIN pattern, next/nextfile statements and <1>: Next Statement.
(line 45)
* BEGIN pattern, next/nextfile statements and: I/O And BEGIN/END.
- (line 36)
+ (line 37)
* 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 144)
+* BEGIN pattern, pwcat program: Passwd Functions. (line 143)
* BEGIN pattern, running awk programs and: Cut Program. (line 68)
* BEGIN pattern, TEXTDOMAIN variable and: Programmer i18n. (line 60)
* BEGINFILE pattern: BEGINFILE/ENDFILE. (line 6)
@@ -24649,15 +24711,20 @@ Index
* braces ({}), actions and: Action Overview. (line 19)
* braces ({}), pgawk program: Profiling. (line 137)
* braces ({}), statements, grouping: Statements. (line 10)
-* bracket expressions <1>: Character Lists. (line 6)
+* bracket expressions <1>: Bracket Expressions. (line 6)
* bracket expressions: Regexp Operators. (line 55)
-* bracket expressions, character classes: Character Lists. (line 29)
-* bracket expressions, collating elements: Character Lists. (line 70)
-* bracket expressions, collating symbols: Character Lists. (line 77)
+* bracket expressions, character classes: Bracket Expressions.
+ (line 29)
+* bracket expressions, collating elements: Bracket Expressions.
+ (line 70)
+* bracket expressions, collating symbols: Bracket Expressions.
+ (line 77)
* bracket expressions, complemented: Regexp Operators. (line 63)
-* bracket expressions, equivalence classes: Character Lists. (line 83)
-* bracket expressions, non-ASCII: Character Lists. (line 70)
-* bracket expressions, range expressions: Character Lists. (line 6)
+* bracket expressions, equivalence classes: Bracket Expressions.
+ (line 83)
+* bracket expressions, non-ASCII: Bracket Expressions. (line 70)
+* bracket expressions, range expressions: Bracket Expressions.
+ (line 6)
* break debugger command: Breakpoint Control. (line 11)
* break statement: Break Statement. (line 6)
* Brennan, Michael <1>: Other Versions. (line 6)
@@ -24698,11 +24765,11 @@ Index
* caret (^), ^ operator: Precedence. (line 49)
* caret (^), ^= operator <1>: Precedence. (line 95)
* caret (^), ^= operator: Assignment Ops. (line 129)
-* caret (^), in bracket expressions: Character Lists. (line 16)
+* caret (^), in bracket expressions: Bracket Expressions. (line 16)
* case keyword: Switch Statement. (line 6)
* case sensitivity, array indices and: Array Intro. (line 92)
-* case sensitivity, converting case: String Functions. (line 494)
-* case sensitivity, example programs: Library Functions. (line 43)
+* case sensitivity, converting case: String Functions. (line 504)
+* case sensitivity, example programs: Library Functions. (line 44)
* case sensitivity, gawk: Case-sensitivity. (line 26)
* case sensitivity, regexps and <1>: User-modified. (line 82)
* case sensitivity, regexps and: Case-sensitivity. (line 6)
@@ -24736,10 +24803,10 @@ Index
(line 131)
* close() function, two-way pipes and: Two-way I/O. (line 77)
* Close, Diane <1>: Contributors. (line 21)
-* Close, Diane: Manual History. (line 39)
+* Close, Diane: Manual History. (line 41)
* close_func() input method: Internals. (line 161)
-* collating elements: Character Lists. (line 70)
-* collating symbols: Character Lists. (line 77)
+* collating elements: Bracket Expressions. (line 70)
+* collating symbols: Bracket Expressions. (line 77)
* Colombo, Antonio: Acknowledgments. (line 60)
* columns, aligning: Print Examples. (line 70)
* columns, cutting: Cut Program. (line 6)
@@ -24767,16 +24834,16 @@ Index
* commenting, backslash continuation and: Statements/Lines. (line 76)
* common extensions, ** operator: Arithmetic Ops. (line 36)
* common extensions, **= operator: Assignment Ops. (line 136)
-* common extensions, /dev/stderr special file: Special FD. (line 45)
-* common extensions, /dev/stdin special file: Special FD. (line 45)
-* common extensions, /dev/stdout special file: Special FD. (line 45)
+* common extensions, /dev/stderr special file: Special FD. (line 46)
+* common extensions, /dev/stdin special file: Special FD. (line 46)
+* common extensions, /dev/stdout special file: Special FD. (line 46)
* common extensions, \x escape sequence: Escape Sequences. (line 61)
* common extensions, BINMODE variable: PC Using. (line 34)
* common extensions, delete to delete entire arrays: Delete. (line 39)
* common extensions, fflush() function: I/O Functions. (line 25)
-* common extensions, func keyword: Definition Syntax. (line 78)
+* common extensions, func keyword: Definition Syntax. (line 83)
* common extensions, length() applied to an array: String Functions.
- (line 167)
+ (line 178)
* common extensions, nextfile statement: Nextfile Statement. (line 6)
* common extensions, RS as a regexp: Records. (line 115)
* common extensions, single character fields: Single Character Fields.
@@ -24818,7 +24885,7 @@ Index
* constants, types of: Constants. (line 6)
* continue statement: Continue Statement. (line 6)
* control statements: Statements. (line 6)
-* converting, case: String Functions. (line 494)
+* converting, case: String Functions. (line 504)
* converting, dates to timestamps: Time Functions. (line 74)
* converting, during subscripting: Numeric Array Subscripts.
(line 31)
@@ -24838,7 +24905,7 @@ Index
* cos() function: Numeric Functions. (line 14)
* counting: Wc Program. (line 6)
* csh utility: Statements/Lines. (line 44)
-* csh utility, POSIXLY_CORRECT environment variable: Options. (line 299)
+* csh utility, POSIXLY_CORRECT environment variable: Options. (line 300)
* 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)
@@ -24847,11 +24914,11 @@ Index
* cut utility: Cut Program. (line 6)
* cut.awk program: Cut Program. (line 45)
* d debugger command (alias for delete): Breakpoint Control. (line 60)
-* d.c., See dark corner: Conventions. (line 37)
+* d.c., See dark corner: Conventions. (line 38)
* dark corner <1>: Glossary. (line 189)
* dark corner <2>: Truth Values. (line 24)
* dark corner <3>: Assignment Ops. (line 148)
-* dark corner: Conventions. (line 37)
+* dark corner: Conventions. (line 38)
* dark corner, ^, in FS: Regexp Field Splitting.
(line 59)
* dark corner, array subscripts: Uninitialized Subscripts.
@@ -24865,7 +24932,7 @@ Index
* dark corner, escape sequences: Other Arguments. (line 31)
* dark corner, escape sequences, for metacharacters: Escape Sequences.
(line 136)
-* dark corner, exit statement: Exit Statement. (line 29)
+* 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)
@@ -24876,7 +24943,7 @@ Index
(line 20)
* dark corner, input files: Records. (line 98)
* dark corner, invoking awk: Command Line. (line 16)
-* dark corner, length() function: String Functions. (line 153)
+* dark corner, length() function: String Functions. (line 164)
* dark corner, multiline records: Multiple Line. (line 35)
* dark corner, NF variable, decrementing: Changing Fields. (line 107)
* dark corner, OFMT variable: OFMT. (line 27)
@@ -24886,7 +24953,7 @@ Index
(line 148)
* dark corner, regexp constants, as arguments to user-defined functions: Using
Constant Regexps.
(line 43)
-* dark corner, split() function: String Functions. (line 330)
+* dark corner, split() function: String Functions. (line 343)
* dark corner, strings, storing: Records. (line 191)
* dark corner, value of ARGV[0]: Auto-set. (line 35)
* data, fixed-width: Constant Size. (line 9)
@@ -25017,7 +25084,7 @@ Index
* 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 167)
+* differences between gawk and awk: String Functions. (line 178)
* differences in awk and gawk, ARGC/ARGV variables: ARGC and ARGV.
(line 88)
* differences in awk and gawk, ARGIND variable: Auto-set. (line 40)
@@ -25034,7 +25101,7 @@ Index
* 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, error messages: Special FD. (line 15)
+* 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)
@@ -25057,7 +25124,7 @@ Index
(line 34)
* differences in awk and gawk, LINT variable: User-modified. (line 98)
* differences in awk and gawk, match() function: String Functions.
- (line 230)
+ (line 241)
* differences in awk and gawk, next/nextfile statements: Nextfile Statement.
(line 6)
* differences in awk and gawk, print/printf statements: Format Modifiers.
@@ -25073,11 +25140,11 @@ Index
* differences in awk and gawk, single-character fields: Single Character
Fields.
(line 6)
* differences in awk and gawk, split() function: String Functions.
- (line 318)
+ (line 331)
* differences in awk and gawk, strings: Scalar Constants. (line 20)
* differences in awk and gawk, strings, storing: Records. (line 187)
* differences in awk and gawk, strtonum() function (gawk): String Functions.
- (line 373)
+ (line 386)
* differences in awk and gawk, TEXTDOMAIN variable: User-modified.
(line 153)
* differences in awk and gawk, trunc-mod operation: Arithmetic Ops.
@@ -25115,7 +25182,7 @@ Index
* e debugger command (alias for enable): Breakpoint Control. (line 69)
* EBCDIC: Ordinal Functions. (line 45)
* egrep utility <1>: Egrep Program. (line 6)
-* egrep utility: Character Lists. (line 23)
+* egrep utility: Bracket Expressions. (line 23)
* egrep.awk program: Egrep Program. (line 54)
* elements in arrays: Reference to Elements.
(line 6)
@@ -25140,17 +25207,17 @@ Index
* END pattern, next/nextfile statements and <1>: Next Statement.
(line 45)
* END pattern, next/nextfile statements and: I/O And BEGIN/END.
- (line 36)
+ (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)
* endfile() user-defined function: Filetrans Function. (line 62)
-* endgrent() function (C library): Group Functions. (line 216)
-* endgrent() user-defined function: Group Functions. (line 219)
-* endpwent() function (C library): Passwd Functions. (line 211)
-* endpwent() user-defined function: Passwd Functions. (line 214)
+* endgrent() function (C library): Group Functions. (line 215)
+* 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 150)
* ENVIRON array: Auto-set. (line 60)
* environment variables: Auto-set. (line 60)
@@ -25159,15 +25226,15 @@ Index
* equals sign (=), == operator <1>: Precedence. (line 65)
* equals sign (=), == operator: Comparison Operators.
(line 11)
-* EREs (Extended Regular Expressions): Character Lists. (line 23)
+* EREs (Extended Regular Expressions): Bracket Expressions. (line 23)
* ERRNO variable <1>: Internals. (line 139)
-* ERRNO variable <2>: TCP/IP Networking. (line 53)
+* 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.
(line 139)
* ERRNO variable: Getline. (line 19)
-* error handling: Special FD. (line 15)
+* error handling: Special FD. (line 16)
* error handling, ERRNO variable and: Auto-set. (line 72)
* error output: Special FD. (line 6)
* escape processing, gsub()/gensub()/sub() functions: Gory Details.
@@ -25208,7 +25275,7 @@ Index
* expressions, matching, See comparison expressions: Typing and Comparison.
(line 9)
* expressions, selecting: Conditional Exp. (line 6)
-* Extended Regular Expressions (EREs): Character Lists. (line 23)
+* Extended Regular Expressions (EREs): Bracket Expressions. (line 23)
* eXtensible Markup Language (XML): Internals. (line 161)
* extension() function (gawk): Using Internal File Ops.
(line 15)
@@ -25216,16 +25283,16 @@ Index
* extensions, Brian Kernighan's awk: BTL. (line 6)
* extensions, common, ** operator: Arithmetic Ops. (line 36)
* extensions, common, **= operator: Assignment Ops. (line 136)
-* extensions, common, /dev/stderr special file: Special FD. (line 45)
-* extensions, common, /dev/stdin special file: Special FD. (line 45)
-* extensions, common, /dev/stdout special file: Special FD. (line 45)
+* extensions, common, /dev/stderr special file: Special FD. (line 46)
+* extensions, common, /dev/stdin special file: Special FD. (line 46)
+* extensions, common, /dev/stdout special file: Special FD. (line 46)
* extensions, common, \x escape sequence: Escape Sequences. (line 61)
* extensions, common, BINMODE variable: PC Using. (line 34)
* extensions, common, delete to delete entire arrays: Delete. (line 39)
* extensions, common, fflush() function: I/O Functions. (line 25)
-* extensions, common, func keyword: Definition Syntax. (line 78)
+* extensions, common, func keyword: Definition Syntax. (line 83)
* extensions, common, length() applied to an array: String Functions.
- (line 167)
+ (line 178)
* extensions, common, nextfile statement: Nextfile Statement. (line 6)
* extensions, common, RS as a regexp: Records. (line 115)
* extensions, common, single character fields: Single Character Fields.
@@ -25282,7 +25349,7 @@ Index
* file descriptors: Special FD. (line 6)
* 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 45)
+* file names, standard streams in gawk: Special FD. (line 46)
* FILENAME variable <1>: Auto-set. (line 92)
* FILENAME variable: Reading Files. (line 6)
* FILENAME variable, getline, setting with: Getline Notes. (line 19)
@@ -25295,7 +25362,7 @@ Index
* files, .po: Explaining gettext. (line 36)
* files, .po, converting to .mo: I18N Example. (line 62)
* files, .pot: Explaining gettext. (line 30)
-* files, /dev/... special files: Special FD. (line 45)
+* files, /dev/... special files: Special FD. (line 46)
* files, /inet/... (gawk): TCP/IP Networking. (line 6)
* files, /inet4/... (gawk): TCP/IP Networking. (line 6)
* files, /inet6/... (gawk): TCP/IP Networking. (line 6)
@@ -25441,10 +25508,10 @@ Index
* functions, user-defined, counts: Profiling. (line 132)
* functions, user-defined, library of: Library Functions. (line 6)
* functions, user-defined, next/nextfile statements and <1>: Nextfile
Statement.
- (line 43)
+ (line 44)
* functions, user-defined, next/nextfile statements and: Next Statement.
(line 45)
-* G-d: Acknowledgments. (line 80)
+* G-d: Acknowledgments. (line 81)
* Garfinkle, Scott: Contributors. (line 35)
* gawk, ARGIND variable in: Other Arguments. (line 12)
* gawk, awk and <1>: This Manual. (line 14)
@@ -25452,7 +25519,7 @@ Index
* gawk, bitwise operations in: Bitwise Functions. (line 39)
* gawk, break statement in: Break Statement. (line 51)
* gawk, built-in variables and: Built-in Variables. (line 14)
-* gawk, character classes and: Character Lists. (line 91)
+* gawk, character classes and: Bracket Expressions. (line 91)
* gawk, coding style in: Adding Code. (line 30)
* gawk, command-line options: GNU Regexp Operators.
(line 70)
@@ -25465,7 +25532,7 @@ Index
* gawk, continue statement in: Continue Statement. (line 43)
* gawk, distribution: Distribution contents.
(line 6)
-* gawk, ERRNO variable in <1>: TCP/IP Networking. (line 53)
+* gawk, ERRNO variable in <1>: TCP/IP Networking. (line 54)
* gawk, ERRNO variable in <2>: Auto-set. (line 72)
* gawk, ERRNO variable in <3>: BEGINFILE/ENDFILE. (line 26)
* gawk, ERRNO variable in <4>: Close Files And Pipes.
@@ -25487,8 +25554,8 @@ Index
* gawk, function arguments and: Calling Built-in. (line 16)
* gawk, functions, adding: Dynamic Extensions. (line 10)
* gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42)
-* gawk, IGNORECASE variable in <1>: String Functions. (line 18)
-* gawk, IGNORECASE variable in <2>: Array Sorting. (line 69)
+* gawk, IGNORECASE variable in <1>: String Functions. (line 29)
+* gawk, IGNORECASE variable in <2>: Array Sorting. (line 68)
* gawk, IGNORECASE variable in <3>: Array Intro. (line 92)
* gawk, IGNORECASE variable in <4>: User-modified. (line 82)
* gawk, IGNORECASE variable in: Case-sensitivity. (line 26)
@@ -25542,7 +25609,7 @@ Index
(line 63)
* General Public License (GPL): Glossary. (line 306)
* General Public License, See GPL: Manual History. (line 11)
-* gensub() function (gawk) <1>: String Functions. (line 57)
+* gensub() function (gawk) <1>: String Functions. (line 68)
* gensub() function (gawk): Using Constant Regexps.
(line 43)
* gensub() function (gawk), escape processing: Gory Details. (line 6)
@@ -25552,19 +25619,19 @@ Index
* get_curfunc_arg_count() internal function: Internals. (line 42)
* get_record() input method: Internals. (line 161)
* get_scalar_argument() internal macro: Internals. (line 133)
-* getaddrinfo() function (C library): TCP/IP Networking. (line 37)
+* 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)
-* getgrgid() function (C library): Group Functions. (line 187)
-* getgrgid() user-defined function: Group Functions. (line 190)
-* getgrnam() function (C library): Group Functions. (line 176)
-* getgrnam() user-defined function: Group Functions. (line 181)
-* getgruser() function (C library): Group Functions. (line 196)
-* getgruser() function, user-defined: Group Functions. (line 199)
+* getgrgid() function (C library): Group Functions. (line 186)
+* getgrgid() user-defined function: Group Functions. (line 189)
+* getgrnam() function (C library): Group Functions. (line 175)
+* getgrnam() user-defined function: Group Functions. (line 180)
+* getgruser() function (C library): Group Functions. (line 195)
+* getgruser() function, user-defined: Group Functions. (line 198)
* getline command: Reading Files. (line 20)
* getline command, _gr_init() user-defined function: Group Functions.
(line 82)
-* getline command, _pw_init() function: Passwd Functions. (line 155)
+* getline command, _pw_init() function: Passwd Functions. (line 154)
* getline command, coprocesses, using from <1>: Close Files And Pipes.
(line 6)
* getline command, coprocesses, using from: Getline/Coprocess.
@@ -25577,13 +25644,13 @@ Index
* getline statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE.
(line 53)
* getopt() function (C library): Getopt Function. (line 15)
-* getopt() user-defined function: Getopt Function. (line 107)
+* getopt() user-defined function: Getopt Function. (line 108)
* getpwent() function (C library): Passwd Functions. (line 16)
* getpwent() user-defined function: Passwd Functions. (line 16)
-* getpwnam() function (C library): Passwd Functions. (line 178)
-* getpwnam() user-defined function: Passwd Functions. (line 183)
-* getpwuid() function (C library): Passwd Functions. (line 189)
-* getpwuid() user-defined function: Passwd Functions. (line 193)
+* getpwnam() function (C library): Passwd Functions. (line 177)
+* getpwnam() user-defined function: Passwd Functions. (line 182)
+* getpwuid() function (C library): Passwd Functions. (line 188)
+* getpwuid() user-defined function: Passwd Functions. (line 192)
* gettext library: Explaining gettext. (line 6)
* gettext library, locale categories: Explaining gettext. (line 80)
* gettext() function (C library): Explaining gettext. (line 62)
@@ -25611,10 +25678,10 @@ Index
* group database, reading: Group Functions. (line 6)
* group file: Group Functions. (line 6)
* groups, information about: Group Functions. (line 6)
-* gsub() function <1>: String Functions. (line 110)
+* gsub() function <1>: String Functions. (line 121)
* gsub() function: Using Constant Regexps.
(line 43)
-* gsub() function, arguments of: String Functions. (line 434)
+* gsub() function, arguments of: String Functions. (line 444)
* gsub() function, escape processing: Gory Details. (line 6)
* h debugger command (alias for help): Miscellaneous Dgawk Commands.
(line 68)
@@ -25638,7 +25705,7 @@ Index
* hyphen (-), -= operator <1>: Precedence. (line 95)
* hyphen (-), -= operator: Assignment Ops. (line 129)
* hyphen (-), filenames beginning with: Options. (line 59)
-* hyphen (-), in bracket expressions: Character Lists. (line 16)
+* hyphen (-), in bracket expressions: Bracket Expressions. (line 16)
* i debugger command (alias for info): Dgawk Info. (line 12)
* id utility: Id Program. (line 6)
* id.awk program: Id Program. (line 30)
@@ -25647,15 +25714,15 @@ Index
* if statement, actions, changing: Ranges. (line 25)
* igawk.sh program: Igawk Program. (line 124)
* ignore debugger command: Breakpoint Control. (line 83)
-* IGNORECASE variable <1>: String Functions. (line 18)
-* IGNORECASE variable <2>: Array Sorting. (line 69)
+* IGNORECASE variable <1>: String Functions. (line 29)
+* IGNORECASE variable <2>: Array Sorting. (line 68)
* IGNORECASE variable <3>: Array Intro. (line 92)
* IGNORECASE variable <4>: User-modified. (line 82)
* IGNORECASE variable: Case-sensitivity. (line 26)
-* IGNORECASE variable, array sorting and: Array Sorting. (line 69)
+* IGNORECASE variable, array sorting and: Array Sorting. (line 68)
* IGNORECASE variable, array subscripts and: Array Intro. (line 92)
* IGNORECASE variable, in example programs: Library Functions.
- (line 43)
+ (line 44)
* implementation issues, gawk: Notes. (line 6)
* implementation issues, gawk, debugging: Compatibility Mode. (line 6)
* implementation issues, gawk, limits <1>: Redirection. (line 135)
@@ -25669,7 +25736,7 @@ Index
* in operator, arrays and: Reference to Elements.
(line 37)
* increment operators: Increment Ops. (line 6)
-* index() function: String Functions. (line 126)
+* index() function: String Functions. (line 137)
* indexing arrays: Array Intro. (line 50)
* indirect function calls: Indirect Calls. (line 6)
* info debugger command: Dgawk Info. (line 12)
@@ -25739,7 +25806,7 @@ Index
* internationalization, localization <1>: Internationalization.
(line 13)
* internationalization, localization: User-modified. (line 153)
-* internationalization, localization, character classes: Character Lists.
+* internationalization, localization, character classes: Bracket Expressions.
(line 91)
* internationalization, localization, gawk and: Internationalization.
(line 13)
@@ -25757,7 +25824,7 @@ Index
* inventory-shipped file: Sample Data Files. (line 32)
* IOBUF internal structure: Internals. (line 161)
* iop_alloc() internal function: Internals. (line 161)
-* isarray() function (gawk): Type Functions. (line 10)
+* isarray() function (gawk): Type Functions. (line 11)
* ISO: Glossary. (line 367)
* ISO 8859-1: Glossary. (line 137)
* ISO Latin-1: Glossary. (line 137)
@@ -25777,8 +25844,8 @@ Index
* Kernighan, Brian <3>: Contributors. (line 12)
* Kernighan, Brian <4>: BTL. (line 6)
* Kernighan, Brian <5>: Concatenation. (line 6)
-* Kernighan, Brian <6>: Acknowledgments. (line 74)
-* Kernighan, Brian <7>: Conventions. (line 33)
+* Kernighan, Brian <6>: Acknowledgments. (line 75)
+* Kernighan, Brian <7>: Conventions. (line 34)
* Kernighan, Brian: History. (line 17)
* kill command, dynamic profiling: Profiling. (line 182)
* Knights, jedi: Undocumented. (line 6)
@@ -25806,7 +25873,7 @@ Index
(line 11)
* left shift, bitwise: Bitwise Functions. (line 32)
* leftmost longest match: Multiple Line. (line 26)
-* length() function: String Functions. (line 137)
+* length() function: String Functions. (line 148)
* Lesser General Public License (LGPL): Glossary. (line 385)
* LGPL (Lesser General Public License): Glossary. (line 385)
* libmawk: Other Versions. (line 104)
@@ -25851,7 +25918,7 @@ Index
* lint checking, empty programs: Command Line. (line 16)
* lint checking, issuing warnings: Options. (line 146)
* lint checking, POSIXLY_CORRECT environment variable: Options.
- (line 286)
+ (line 287)
* lint checking, undefined functions: Pass By Value/Reference.
(line 88)
* LINT variable: User-modified. (line 98)
@@ -25892,9 +25959,9 @@ Index
(line 6)
* marked strings, extracting: String Extraction. (line 6)
* Marx, Groucho: Increment Ops. (line 61)
-* match() function: String Functions. (line 177)
+* match() function: String Functions. (line 188)
* match() function, RSTART/RLENGTH variables: String Functions.
- (line 194)
+ (line 205)
* matching, expressions, See comparison expressions: Typing and Comparison.
(line 9)
* matching, leftmost longest: Multiple Line. (line 26)
@@ -25945,18 +26012,18 @@ Index
(line 43)
* next statement <1>: Next Statement. (line 6)
* next statement: Boolean Ops. (line 85)
-* next statement, BEGIN/END patterns and: I/O And BEGIN/END. (line 36)
+* next statement, BEGIN/END patterns and: I/O And BEGIN/END. (line 37)
* next statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE.
(line 48)
* next statement, user-defined functions and: Next Statement. (line 45)
* nextfile statement: Nextfile Statement. (line 6)
* nextfile statement, BEGIN/END patterns and: I/O And BEGIN/END.
- (line 36)
+ (line 37)
* nextfile statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE.
(line 26)
* nextfile statement, implementing: Nextfile Function. (line 6)
* nextfile statement, user-defined functions and: Nextfile Statement.
- (line 43)
+ (line 44)
* nextfile() user-defined function: Nextfile Function. (line 38)
* nexti debugger command: Dgawk Execution Control.
(line 49)
@@ -26014,7 +26081,7 @@ Index
* octal numbers: Nondecimal-numbers. (line 6)
* octal values, enabling interpretation of: Options. (line 165)
* OFMT variable <1>: User-modified. (line 115)
-* OFMT variable <2>: Conversion. (line 54)
+* OFMT variable <2>: Conversion. (line 55)
* OFMT variable: OFMT. (line 15)
* OFMT variable, POSIX awk and: OFMT. (line 27)
* OFS variable <1>: User-modified. (line 124)
@@ -26095,7 +26162,7 @@ Index
* parentheses (): Regexp Operators. (line 79)
* parentheses (), pgawk program: Profiling. (line 141)
* password file: Passwd Functions. (line 16)
-* patsplit() function: String Functions. (line 264)
+* patsplit() function: String Functions. (line 275)
* patterns: Patterns and Actions.
(line 6)
* patterns, comparison expressions as: Expression Patterns. (line 14)
@@ -26149,19 +26216,19 @@ Index
* portability, deleting array elements: Delete. (line 52)
* portability, example programs: Library Functions. (line 31)
* portability, fflush() function and: I/O Functions. (line 29)
-* portability, functions, defining: Definition Syntax. (line 94)
+* portability, functions, defining: Definition Syntax. (line 99)
* portability, gawk: New Ports. (line 6)
* portability, gettext library and: Explaining gettext. (line 10)
* portability, internationalization and: I18N Portability. (line 6)
-* portability, length() function: String Functions. (line 146)
-* portability, new awk vs. old awk: Conversion. (line 54)
+* portability, length() function: String Functions. (line 157)
+* portability, new awk vs. old awk: Conversion. (line 55)
* portability, next statement in user-defined functions: Pass By
Value/Reference.
(line 91)
* 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 304)
-* portability, substr() function: String Functions. (line 484)
+* portability, POSIXLY_CORRECT environment variable: Options. (line 305)
+* portability, substr() function: String Functions. (line 494)
* 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.
@@ -26184,8 +26251,8 @@ Index
* POSIX awk, backslashes in string constants: Escape Sequences.
(line 113)
* POSIX awk, BEGIN/END patterns: I/O And BEGIN/END. (line 16)
-* POSIX awk, bracket expressions and: Character Lists. (line 23)
-* POSIX awk, bracket expressions and, character classes: Character Lists.
+* POSIX awk, bracket expressions and: Bracket Expressions. (line 23)
+* POSIX awk, bracket expressions and, character classes: Bracket Expressions.
(line 29)
* POSIX awk, break statement and: Break Statement. (line 51)
* POSIX awk, changes in awk versions: POSIX. (line 6)
@@ -26196,13 +26263,13 @@ Index
(line 41)
* POSIX awk, field separators and: Fields. (line 6)
* POSIX awk, FS variable and: User-modified. (line 66)
-* POSIX awk, function keyword in: Definition Syntax. (line 78)
-* POSIX awk, functions and, length(): String Functions. (line 146)
+* POSIX awk, function keyword in: Definition Syntax. (line 83)
+* POSIX awk, functions and, length(): String Functions. (line 157)
* POSIX awk, GNU long options and: Options. (line 15)
* POSIX awk, interval expressions in: Regexp Operators. (line 135)
* POSIX awk, next/nextfile statements and: Next Statement. (line 45)
* POSIX awk, numeric strings and: Variable Typing. (line 6)
-* POSIX awk, OFMT variable and <1>: Conversion. (line 54)
+* POSIX awk, OFMT variable and <1>: Conversion. (line 55)
* POSIX awk, OFMT variable and: OFMT. (line 27)
* POSIX awk, period (.), using: Regexp Operators. (line 50)
* POSIX awk, printf format strings and: Format Modifiers. (line 159)
@@ -26213,7 +26280,7 @@ Index
* POSIX, awk and: Preface. (line 22)
* POSIX, gawk extensions not included in: POSIX/GNU. (line 6)
* POSIX, programs, implementing in awk: Clones. (line 6)
-* POSIXLY_CORRECT environment variable: Options. (line 286)
+* POSIXLY_CORRECT environment variable: Options. (line 287)
* precedence <1>: Precedence. (line 6)
* precedence: Increment Ops. (line 61)
* precedence, regexp operators: Regexp Operators. (line 152)
@@ -26270,9 +26337,9 @@ Index
* programming conventions, --non-decimal-data option: Nondecimal Data.
(line 36)
* programming conventions, ARGC/ARGV variables: Auto-set. (line 31)
-* programming conventions, exit statement: Exit Statement. (line 37)
+* programming conventions, exit statement: Exit Statement. (line 38)
* programming conventions, function parameters: Return Statement.
- (line 44)
+ (line 45)
* programming conventions, functions, calling: Calling Built-in.
(line 10)
* programming conventions, functions, writing: Definition Syntax.
@@ -26313,7 +26380,7 @@ Index
* random numbers, rand()/srand() functions: Numeric Functions.
(line 33)
* random numbers, seed of: Numeric Functions. (line 63)
-* range expressions (regexps): Character Lists. (line 6)
+* range expressions (regexps): Bracket Expressions. (line 6)
* range patterns: Ranges. (line 6)
* Rankin, Pat <1>: Bugs. (line 72)
* Rankin, Pat <2>: Contributors. (line 38)
@@ -26404,7 +26471,7 @@ Index
* right shift, bitwise: Bitwise Functions. (line 32)
* Ritchie, Dennis: Basic Data Typing. (line 74)
* RLENGTH variable: Auto-set. (line 191)
-* RLENGTH variable, match() function and: String Functions. (line 194)
+* RLENGTH variable, match() function and: String Functions. (line 205)
* Robbins, Arnold <1>: Future Extensions. (line 6)
* Robbins, Arnold <2>: Bugs. (line 32)
* Robbins, Arnold <3>: Contributors. (line 103)
@@ -26414,11 +26481,11 @@ Index
* Robbins, Arnold: Command Line Field Separator.
(line 80)
* Robbins, Bill: Getline/Pipe. (line 36)
-* Robbins, Harry: Acknowledgments. (line 80)
-* Robbins, Jean: Acknowledgments. (line 80)
+* Robbins, Harry: Acknowledgments. (line 81)
+* Robbins, Jean: Acknowledgments. (line 81)
* Robbins, Miriam <1>: Passwd Functions. (line 90)
* Robbins, Miriam <2>: Getline/Pipe. (line 36)
-* Robbins, Miriam: Acknowledgments. (line 80)
+* Robbins, Miriam: Acknowledgments. (line 81)
* Robinson, Will: Dynamic Extensions. (line 6)
* robot, the: Dynamic Extensions. (line 6)
* Rommel, Kai Uwe: Contributors. (line 42)
@@ -26429,7 +26496,7 @@ Index
* RS variable, multiline records and: Multiple Line. (line 17)
* rshift() function (gawk): Bitwise Functions. (line 51)
* RSTART variable: Auto-set. (line 197)
-* RSTART variable, match() function and: String Functions. (line 194)
+* RSTART variable, match() function and: String Functions. (line 205)
* RT variable <1>: Auto-set. (line 204)
* RT variable <2>: Getline/Variable/File.
(line 10)
@@ -26448,15 +26515,15 @@ Index
* Schorr, Andrew: Acknowledgments. (line 60)
* Schreiber, Bert: Acknowledgments. (line 38)
* Schreiber, Rita: Acknowledgments. (line 38)
-* search paths <1>: VMS Running. (line 28)
+* search paths <1>: VMS Running. (line 29)
* search paths <2>: PC Using. (line 11)
* search paths <3>: Igawk Program. (line 364)
* search paths: AWKPATH Variable. (line 6)
-* search paths, for source files <1>: VMS Running. (line 28)
+* 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 364)
* search paths, for source files: AWKPATH Variable. (line 6)
-* searching: String Functions. (line 126)
+* searching: String Functions. (line 137)
* searching, files for regular expressions: Egrep Program. (line 6)
* searching, for words: Dupword Program. (line 6)
* sed utility <1>: Glossary. (line 12)
@@ -26547,10 +26614,10 @@ Index
* sparse arrays: Array Intro. (line 71)
* Spencer, Henry: Glossary. (line 12)
* split utility: Split Program. (line 6)
-* split() function: String Functions. (line 285)
+* split() function: String Functions. (line 297)
* split() function, array elements, deleting: Delete. (line 57)
* split.awk program: Split Program. (line 30)
-* sprintf() function <1>: String Functions. (line 349)
+* sprintf() function <1>: String Functions. (line 362)
* sprintf() function: OFMT. (line 15)
* sprintf() function, OFMT variable and: User-modified. (line 124)
* sprintf() function, print/printf statements and: Round Function.
@@ -26599,14 +26666,14 @@ Index
* strings, null: Regexp Field Splitting.
(line 43)
* strings, numeric: Variable Typing. (line 6)
-* strings, splitting: String Functions. (line 304)
-* strtonum() function (gawk): String Functions. (line 356)
+* strings, splitting: String Functions. (line 317)
+* strtonum() function (gawk): String Functions. (line 369)
* strtonum() function (gawk), --non-decimal-data option and: Nondecimal Data.
(line 36)
-* sub() function <1>: String Functions. (line 377)
+* sub() function <1>: String Functions. (line 390)
* sub() function: Using Constant Regexps.
(line 43)
-* sub() function, arguments of: String Functions. (line 434)
+* sub() function, arguments of: String Functions. (line 444)
* sub() function, escape processing: Gory Details. (line 6)
* subscript separators: User-modified. (line 147)
* subscripts in arrays, multidimensional: Multi-dimensional. (line 10)
@@ -26619,7 +26686,7 @@ Index
* SUBSEP variable: User-modified. (line 147)
* SUBSEP variable, multidimensional arrays: Multi-dimensional.
(line 16)
-* substr() function: String Functions. (line 453)
+* substr() function: String Functions. (line 463)
* Sumner, Andrew: Other Versions. (line 55)
* switch statement: Switch Statement. (line 6)
* syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops.
@@ -26670,8 +26737,8 @@ Index
* timestamps, converting dates to: Time Functions. (line 74)
* timestamps, formatted: Gettimeofday Function.
(line 6)
-* tolower() function: String Functions. (line 495)
-* toupper() function: String Functions. (line 501)
+* tolower() function: String Functions. (line 505)
+* toupper() function: String Functions. (line 511)
* tr utility: Translate Program. (line 6)
* trace debugger command: Miscellaneous Dgawk Commands.
(line 110)
@@ -26694,18 +26761,18 @@ Index
* troubleshooting, gawk, fatal errors, function arguments: Calling Built-in.
(line 16)
* troubleshooting, getline function: File Checking. (line 25)
-* troubleshooting, gsub()/sub() functions: String Functions. (line 444)
-* troubleshooting, match() function: String Functions. (line 259)
-* troubleshooting, patsplit() function: String Functions. (line 281)
+* troubleshooting, gsub()/sub() functions: String Functions. (line 454)
+* troubleshooting, match() function: String Functions. (line 270)
+* troubleshooting, patsplit() function: String Functions. (line 293)
* troubleshooting, print statement, omitting commas: Print Examples.
(line 31)
* troubleshooting, printing: Redirection. (line 118)
-* troubleshooting, quotes with file names: Special FD. (line 67)
+* troubleshooting, quotes with file names: Special FD. (line 68)
* troubleshooting, readable data files: File Checking. (line 6)
* troubleshooting, regexp constants vs. string constants: Computed Regexps.
(line 38)
* troubleshooting, string concatenation: Concatenation. (line 27)
-* troubleshooting, substr() function: String Functions. (line 471)
+* troubleshooting, substr() function: String Functions. (line 481)
* troubleshooting, system() function: I/O Functions. (line 85)
* troubleshooting, typographical errors, global variables: Options.
(line 94)
@@ -26874,406 +26941,406 @@ Index
Tag Table:
-Node: Top1340
-Node: Foreword29909
-Node: Preface34237
-Ref: Preface-Footnote-137189
-Ref: Preface-Footnote-237295
-Node: History37527
-Node: Names39761
-Ref: Names-Footnote-141238
-Node: This Manual41310
-Ref: This Manual-Footnote-146208
-Node: Conventions46308
-Node: Manual History48424
-Ref: Manual History-Footnote-151602
-Ref: Manual History-Footnote-251643
-Node: How To Contribute51717
-Node: Acknowledgments52861
-Node: Getting Started57110
-Node: Running gawk59489
-Node: One-shot60675
-Node: Read Terminal61900
-Ref: Read Terminal-Footnote-163550
-Ref: Read Terminal-Footnote-263824
-Node: Long63995
-Node: Executable Scripts65371
-Ref: Executable Scripts-Footnote-167232
-Ref: Executable Scripts-Footnote-267334
-Node: Comments67785
-Node: Quoting70252
-Node: DOS Quoting74869
-Node: Sample Data Files75544
-Node: Very Simple78576
-Node: Two Rules83173
-Node: More Complex85320
-Ref: More Complex-Footnote-188250
-Node: Statements/Lines88330
-Ref: Statements/Lines-Footnote-192792
-Node: Other Features93057
-Node: When93926
-Node: Invoking Gawk96069
-Node: Command Line97454
-Node: Options98237
-Ref: Options-Footnote-1111291
-Node: Other Arguments111316
-Node: Naming Standard Input113979
-Node: Environment Variables114943
-Node: AWKPATH Variable115387
-Ref: AWKPATH Variable-Footnote-1118124
-Node: Other Environment Variables118384
-Node: Exit Status120732
-Node: Include Files121407
-Node: Obsolete124800
-Node: Undocumented125486
-Node: Regexp125727
-Node: Regexp Usage127179
-Node: Escape Sequences129205
-Node: Regexp Operators134948
-Ref: Regexp Operators-Footnote-1142137
-Ref: Regexp Operators-Footnote-2142284
-Node: Character Lists142382
-Ref: table-char-classes144173
-Node: GNU Regexp Operators146817
-Node: Case-sensitivity150536
-Ref: Case-sensitivity-Footnote-1153495
-Ref: Case-sensitivity-Footnote-2153730
-Node: Leftmost Longest153838
-Node: Computed Regexps155039
-Node: Locales158460
-Node: Reading Files162000
-Node: Records163941
-Ref: Records-Footnote-1172620
-Node: Fields172657
-Ref: Fields-Footnote-1175689
-Node: Nonconstant Fields175775
-Node: Changing Fields177977
-Node: Field Separators183267
-Node: Default Field Splitting185896
-Node: Regexp Field Splitting187013
-Node: Single Character Fields190372
-Node: Command Line Field Separator191431
-Node: Field Splitting Summary194870
-Ref: Field Splitting Summary-Footnote-1198056
-Node: Constant Size198157
-Node: Splitting By Content202719
-Ref: Splitting By Content-Footnote-1206445
-Node: Multiple Line206485
-Ref: Multiple Line-Footnote-1212332
-Node: Getline212511
-Node: Plain Getline214739
-Node: Getline/Variable216828
-Node: Getline/File217969
-Node: Getline/Variable/File219291
-Ref: Getline/Variable/File-Footnote-1220890
-Node: Getline/Pipe220977
-Node: Getline/Variable/Pipe223525
-Node: Getline/Coprocess224632
-Node: Getline/Variable/Coprocess225875
-Node: Getline Notes226589
-Node: Getline Summary228531
-Ref: table-getline-variants228815
-Node: Command line directories229720
-Node: Printing230345
-Node: Print231976
-Node: Print Examples233313
-Node: Output Separators236097
-Node: OFMT237856
-Node: Printf239214
-Node: Basic Printf240120
-Node: Control Letters241657
-Node: Format Modifiers245469
-Node: Printf Examples251480
-Node: Redirection254195
-Node: Special Files261173
-Node: Special FD261706
-Ref: Special FD-Footnote-1265317
-Node: Special Network265391
-Node: Special Caveats266246
-Node: Close Files And Pipes267040
-Ref: Close Files And Pipes-Footnote-1274063
-Ref: Close Files And Pipes-Footnote-2274211
-Node: Expressions274361
-Node: Values275430
-Node: Constants276106
-Node: Scalar Constants276786
-Ref: Scalar Constants-Footnote-1277645
-Node: Nondecimal-numbers277827
-Node: Regexp Constants280886
-Node: Using Constant Regexps281361
-Node: Variables284366
-Node: Using Variables285021
-Node: Assignment Options286748
-Node: Conversion288629
-Ref: table-locale-affects294003
-Ref: Conversion-Footnote-1294627
-Node: All Operators294736
-Node: Arithmetic Ops295366
-Node: Concatenation297872
-Ref: Concatenation-Footnote-1300665
-Node: Assignment Ops300784
-Ref: table-assign-ops305772
-Node: Increment Ops307180
-Node: Truth Values and Conditions310658
-Node: Truth Values311741
-Node: Typing and Comparison312789
-Node: Variable Typing313578
-Ref: Variable Typing-Footnote-1317475
-Node: Comparison Operators317597
-Ref: table-relational-ops318007
-Node: POSIX String Comparison321556
-Ref: POSIX String Comparison-Footnote-1322513
-Node: Boolean Ops322651
-Ref: Boolean Ops-Footnote-1326729
-Node: Conditional Exp326820
-Node: Function Calls328552
-Node: Precedence332142
-Node: Patterns and Actions335795
-Node: Pattern Overview336849
-Node: Regexp Patterns338515
-Node: Expression Patterns339058
-Node: Ranges342632
-Node: BEGIN/END345598
-Node: Using BEGIN/END346348
-Ref: Using BEGIN/END-Footnote-1349079
-Node: I/O And BEGIN/END349193
-Node: Empty351462
-Node: BEGINFILE/ENDFILE351796
-Node: Using Shell Variables354620
-Node: Action Overview356899
-Node: Statements359256
-Node: If Statement361115
-Node: While Statement362614
-Node: Do Statement364658
-Node: For Statement365814
-Node: Switch Statement368966
-Node: Break Statement371063
-Node: Continue Statement373039
-Node: Next Statement374740
-Node: Nextfile Statement377122
-Node: Exit Statement379647
-Node: Built-in Variables381978
-Node: User-modified383073
-Ref: User-modified-Footnote-1391074
-Node: Auto-set391136
-Ref: Auto-set-Footnote-1401037
-Node: ARGC and ARGV401242
-Node: Arrays405001
-Node: Array Basics406572
-Node: Array Intro407283
-Node: Reference to Elements411601
-Node: Assigning Elements413871
-Node: Array Example414362
-Node: Scanning an Array416094
-Node: Delete419618
-Ref: Delete-Footnote-1422049
-Node: Numeric Array Subscripts422106
-Node: Uninitialized Subscripts424289
-Node: Multi-dimensional425917
-Node: Multi-scanning429008
-Node: Array Sorting430592
-Ref: Array Sorting-Footnote-1433790
-Node: Arrays of Arrays433984
-Node: Functions438523
-Node: Built-in439345
-Node: Calling Built-in440423
-Node: Numeric Functions442399
-Ref: Numeric Functions-Footnote-1446156
-Ref: Numeric Functions-Footnote-2446492
-Ref: Numeric Functions-Footnote-3446540
-Node: String Functions446809
-Ref: String Functions-Footnote-1468615
-Ref: String Functions-Footnote-2468744
-Ref: String Functions-Footnote-3468992
-Node: Gory Details469079
-Ref: table-sub-escapes470736
-Ref: table-posix-sub472050
-Ref: table-gensub-escapes472950
-Node: I/O Functions474121
-Ref: I/O Functions-Footnote-1480816
-Node: Time Functions480963
-Ref: Time Functions-Footnote-1491829
-Ref: Time Functions-Footnote-2491897
-Ref: Time Functions-Footnote-3492055
-Ref: Time Functions-Footnote-4492166
-Ref: Time Functions-Footnote-5492278
-Ref: Time Functions-Footnote-6492505
-Node: Bitwise Functions492771
-Ref: table-bitwise-ops493329
-Ref: Bitwise Functions-Footnote-1497489
-Node: Type Functions497673
-Node: I18N Functions498111
-Node: User-defined499738
-Node: Definition Syntax500542
-Ref: Definition Syntax-Footnote-1505179
-Node: Function Example505248
-Node: Function Caveats507842
-Node: Calling A Function508263
-Node: Variable Scope509378
-Node: Pass By Value/Reference511306
-Node: Return Statement514746
-Node: Dynamic Typing517688
-Node: Indirect Calls518425
-Node: Internationalization528107
-Node: I18N and L10N529535
-Node: Explaining gettext530221
-Ref: Explaining gettext-Footnote-1535283
-Ref: Explaining gettext-Footnote-2535466
-Node: Programmer i18n535631
-Node: Translator i18n539922
-Node: String Extraction540715
-Ref: String Extraction-Footnote-1541676
-Node: Printf Ordering541762
-Ref: Printf Ordering-Footnote-1544546
-Node: I18N Portability544610
-Ref: I18N Portability-Footnote-1547059
-Node: I18N Example547122
-Ref: I18N Example-Footnote-1549757
-Node: Gawk I18N549829
-Node: Advanced Features550446
-Node: Nondecimal Data551765
-Node: Two-way I/O553346
-Ref: Two-way I/O-Footnote-1558760
-Node: TCP/IP Networking558837
-Node: Profiling561680
-Node: Library Functions569080
-Ref: Library Functions-Footnote-1572119
-Node: Library Names572290
-Ref: Library Names-Footnote-1575761
-Ref: Library Names-Footnote-2575981
-Node: General Functions576067
-Node: Nextfile Function577130
-Node: Strtonum Function581511
-Node: Assert Function584462
-Node: Round Function587788
-Node: Cliff Random Function589329
-Node: Ordinal Functions590345
-Ref: Ordinal Functions-Footnote-1593415
-Ref: Ordinal Functions-Footnote-2593667
-Node: Join Function593883
-Ref: Join Function-Footnote-1595654
-Node: Gettimeofday Function595854
-Node: Data File Management599569
-Node: Filetrans Function600201
-Node: Rewind Function604437
-Node: File Checking605890
-Node: Empty Files606984
-Node: Ignoring Assigns609214
-Node: Getopt Function610767
-Ref: Getopt Function-Footnote-1622092
-Node: Passwd Functions622295
-Ref: Passwd Functions-Footnote-1631282
-Node: Group Functions631370
-Node: Walking Arrays639472
-Node: Sample Programs641038
-Node: Running Examples641703
-Node: Clones642431
-Node: Cut Program643554
-Node: Egrep Program653403
-Ref: Egrep Program-Footnote-1661174
-Node: Id Program661284
-Node: Split Program664900
-Ref: Split Program-Footnote-1668419
-Node: Tee Program668547
-Node: Uniq Program671350
-Node: Wc Program678773
-Ref: Wc Program-Footnote-1683037
-Node: Miscellaneous Programs683237
-Node: Dupword Program684425
-Node: Alarm Program686456
-Node: Translate Program691178
-Ref: Translate Program-Footnote-1695557
-Ref: Translate Program-Footnote-2695785
-Node: Labels Program695919
-Ref: Labels Program-Footnote-1699290
-Node: Word Sorting699374
-Node: History Sorting703257
-Node: Extract Program705095
-Ref: Extract Program-Footnote-1712576
-Node: Simple Sed712704
-Node: Igawk Program715766
-Ref: Igawk Program-Footnote-1730798
-Ref: Igawk Program-Footnote-2730999
-Node: Anagram Program731137
-Node: Signature Program734235
-Node: Debugger735338
-Node: Debugging736249
-Node: Debugging Concepts736563
-Node: Debugging Terms738419
-Node: Awk Debugging740964
-Node: Sample dgawk session741856
-Node: dgawk invocation742348
-Node: Finding The Bug743530
-Node: List of Debugger Commands750015
-Node: Breakpoint Control751326
-Node: Dgawk Execution Control754802
-Node: Viewing And Changing Data758154
-Node: Dgawk Stack761463
-Node: Dgawk Info762923
-Node: Miscellaneous Dgawk Commands766871
-Node: Readline Support772296
-Node: Dgawk Limitations773123
-Node: Language History775262
-Node: V7/SVR3.1776694
-Node: SVR4778989
-Node: POSIX780431
-Node: BTL781429
-Node: POSIX/GNU782163
-Node: Common Extensions787349
-Node: Contributors788450
-Node: Installation792485
-Node: Gawk Distribution793379
-Node: Getting793863
-Node: Extracting794689
-Node: Distribution contents796367
-Node: Unix Installation801385
-Node: Quick Installation802002
-Node: Additional Configuration Options803964
-Node: Configuration Philosophy805441
-Node: Non-Unix Installation807783
-Node: PC Installation808241
-Node: PC Binary Installation809540
-Node: PC Compiling811388
-Node: PC Testing814332
-Node: PC Using815508
-Node: Cygwin819693
-Node: MSYS820690
-Node: VMS Installation821204
-Node: VMS Compilation821810
-Ref: VMS Compilation-Footnote-1822817
-Node: VMS Installation Details822875
-Node: VMS Running824510
-Node: VMS Old Gawk826110
-Node: Bugs826584
-Node: Other Versions830449
-Node: Notes835728
-Node: Compatibility Mode836420
-Node: Additions837203
-Node: Accessing The Source838015
-Node: Adding Code839438
-Node: New Ports844986
-Node: Dynamic Extensions849099
-Node: Internals850475
-Node: Plugin License859591
-Node: Sample Library860225
-Node: Internal File Description860911
-Node: Internal File Ops864618
-Ref: Internal File Ops-Footnote-1869386
-Node: Using Internal File Ops869534
-Node: Future Extensions871911
-Node: Basic Concepts874415
-Node: Basic High Level875172
-Ref: Basic High Level-Footnote-1879207
-Node: Basic Data Typing879392
-Node: Floating Point Issues883917
-Node: String Conversion Precision885000
-Ref: String Conversion Precision-Footnote-1886694
-Node: Unexpected Results886803
-Node: POSIX Floating Point Problems888629
-Ref: POSIX Floating Point Problems-Footnote-1892331
-Node: Glossary892369
-Node: Copying916512
-Node: GNU Free Documentation License954069
-Node: Index979206
+Node: Top1346
+Node: Foreword29921
+Node: Preface34266
+Ref: Preface-Footnote-137233
+Ref: Preface-Footnote-237339
+Node: History37571
+Node: Names39962
+Ref: Names-Footnote-141439
+Node: This Manual41511
+Ref: This Manual-Footnote-146459
+Node: Conventions46559
+Node: Manual History48693
+Ref: Manual History-Footnote-151963
+Ref: Manual History-Footnote-252004
+Node: How To Contribute52078
+Node: Acknowledgments53222
+Node: Getting Started57553
+Node: Running gawk59932
+Node: One-shot61118
+Node: Read Terminal62343
+Ref: Read Terminal-Footnote-163993
+Ref: Read Terminal-Footnote-264269
+Node: Long64440
+Node: Executable Scripts65816
+Ref: Executable Scripts-Footnote-167685
+Ref: Executable Scripts-Footnote-267787
+Node: Comments68238
+Node: Quoting70705
+Node: DOS Quoting75328
+Node: Sample Data Files76003
+Node: Very Simple79035
+Node: Two Rules83634
+Node: More Complex85781
+Ref: More Complex-Footnote-188711
+Node: Statements/Lines88796
+Ref: Statements/Lines-Footnote-193258
+Node: Other Features93523
+Node: When94451
+Node: Invoking Gawk96598
+Node: Command Line97983
+Node: Options98766
+Ref: Options-Footnote-1111898
+Node: Other Arguments111923
+Node: Naming Standard Input114581
+Node: Environment Variables115675
+Node: AWKPATH Variable116119
+Ref: AWKPATH Variable-Footnote-1118716
+Node: Other Environment Variables118976
+Node: Exit Status121316
+Node: Include Files121991
+Node: Obsolete125476
+Node: Undocumented126162
+Node: Regexp126403
+Node: Regexp Usage127855
+Node: Escape Sequences129881
+Node: Regexp Operators135644
+Ref: Regexp Operators-Footnote-1142841
+Ref: Regexp Operators-Footnote-2142988
+Node: Bracket Expressions143086
+Ref: table-char-classes144889
+Node: GNU Regexp Operators147533
+Node: Case-sensitivity151256
+Ref: Case-sensitivity-Footnote-1154224
+Ref: Case-sensitivity-Footnote-2154459
+Node: Leftmost Longest154567
+Node: Computed Regexps155768
+Node: Locales159194
+Node: Reading Files162902
+Node: Records164843
+Ref: Records-Footnote-1173517
+Node: Fields173554
+Ref: Fields-Footnote-1176587
+Node: Nonconstant Fields176673
+Node: Changing Fields178875
+Node: Field Separators184853
+Node: Default Field Splitting187482
+Node: Regexp Field Splitting188599
+Node: Single Character Fields191941
+Node: Command Line Field Separator193000
+Node: Field Splitting Summary196441
+Ref: Field Splitting Summary-Footnote-1199633
+Node: Constant Size199734
+Node: Splitting By Content204318
+Ref: Splitting By Content-Footnote-1208044
+Node: Multiple Line208084
+Ref: Multiple Line-Footnote-1213931
+Node: Getline214110
+Node: Plain Getline216338
+Node: Getline/Variable218427
+Node: Getline/File219568
+Node: Getline/Variable/File220890
+Ref: Getline/Variable/File-Footnote-1222489
+Node: Getline/Pipe222576
+Node: Getline/Variable/Pipe225136
+Node: Getline/Coprocess226243
+Node: Getline/Variable/Coprocess227486
+Node: Getline Notes228200
+Node: Getline Summary230142
+Ref: table-getline-variants230485
+Node: Command line directories231341
+Node: Printing231966
+Node: Print233597
+Node: Print Examples234934
+Node: Output Separators237718
+Node: OFMT239478
+Node: Printf240836
+Node: Basic Printf241742
+Node: Control Letters243281
+Node: Format Modifiers247093
+Node: Printf Examples253102
+Node: Redirection255817
+Node: Special Files262801
+Node: Special FD263334
+Ref: Special FD-Footnote-1266958
+Node: Special Network267032
+Node: Special Caveats267882
+Node: Close Files And Pipes268678
+Ref: Close Files And Pipes-Footnote-1275701
+Ref: Close Files And Pipes-Footnote-2275849
+Node: Expressions275999
+Node: Values277068
+Node: Constants277744
+Node: Scalar Constants278424
+Ref: Scalar Constants-Footnote-1279283
+Node: Nondecimal-numbers279465
+Node: Regexp Constants282524
+Node: Using Constant Regexps282999
+Node: Variables286054
+Node: Using Variables286709
+Node: Assignment Options288433
+Node: Conversion290305
+Ref: table-locale-affects295681
+Ref: Conversion-Footnote-1296305
+Node: All Operators296414
+Node: Arithmetic Ops297044
+Node: Concatenation299549
+Ref: Concatenation-Footnote-1302342
+Node: Assignment Ops302462
+Ref: table-assign-ops307450
+Node: Increment Ops308858
+Node: Truth Values and Conditions312328
+Node: Truth Values313411
+Node: Typing and Comparison314460
+Node: Variable Typing315249
+Ref: Variable Typing-Footnote-1319146
+Node: Comparison Operators319268
+Ref: table-relational-ops319678
+Node: POSIX String Comparison323227
+Ref: POSIX String Comparison-Footnote-1324183
+Node: Boolean Ops324321
+Ref: Boolean Ops-Footnote-1328399
+Node: Conditional Exp328490
+Node: Function Calls330222
+Node: Precedence333816
+Node: Patterns and Actions337469
+Node: Pattern Overview338523
+Node: Regexp Patterns340189
+Node: Expression Patterns340732
+Node: Ranges344306
+Node: BEGIN/END347272
+Node: Using BEGIN/END348034
+Ref: Using BEGIN/END-Footnote-1350765
+Node: I/O And BEGIN/END350871
+Node: BEGINFILE/ENDFILE353153
+Node: Empty355984
+Node: Using Shell Variables356300
+Node: Action Overview358585
+Node: Statements360942
+Node: If Statement362796
+Node: While Statement364295
+Node: Do Statement366339
+Node: For Statement367495
+Node: Switch Statement370647
+Node: Break Statement372744
+Node: Continue Statement374734
+Node: Next Statement376521
+Node: Nextfile Statement378911
+Node: Exit Statement381387
+Node: Built-in Variables383803
+Node: User-modified384898
+Ref: User-modified-Footnote-1392924
+Node: Auto-set392986
+Ref: Auto-set-Footnote-1402861
+Node: ARGC and ARGV403066
+Node: Arrays406917
+Node: Array Basics408488
+Node: Array Intro409199
+Node: Reference to Elements413517
+Node: Assigning Elements415787
+Node: Array Example416278
+Node: Scanning an Array418010
+Node: Delete421542
+Ref: Delete-Footnote-1423977
+Node: Numeric Array Subscripts424034
+Node: Uninitialized Subscripts426217
+Node: Multi-dimensional427845
+Node: Multi-scanning430936
+Node: Array Sorting432520
+Ref: Array Sorting-Footnote-1435614
+Node: Arrays of Arrays435808
+Node: Functions440381
+Node: Built-in441203
+Node: Calling Built-in442281
+Node: Numeric Functions444269
+Ref: Numeric Functions-Footnote-1448034
+Ref: Numeric Functions-Footnote-2448391
+Ref: Numeric Functions-Footnote-3448439
+Node: String Functions448708
+Ref: String Functions-Footnote-1471210
+Ref: String Functions-Footnote-2471339
+Ref: String Functions-Footnote-3471587
+Node: Gory Details471674
+Ref: table-sub-escapes473353
+Ref: table-posix-sub474667
+Ref: table-gensub-escapes475580
+Node: I/O Functions476751
+Ref: I/O Functions-Footnote-1483406
+Node: Time Functions483553
+Ref: Time Functions-Footnote-1494448
+Ref: Time Functions-Footnote-2494516
+Ref: Time Functions-Footnote-3494674
+Ref: Time Functions-Footnote-4494785
+Ref: Time Functions-Footnote-5494897
+Ref: Time Functions-Footnote-6495124
+Node: Bitwise Functions495390
+Ref: table-bitwise-ops495948
+Ref: Bitwise Functions-Footnote-1500108
+Node: Type Functions500292
+Node: I18N Functions500762
+Node: User-defined502389
+Node: Definition Syntax503193
+Ref: Definition Syntax-Footnote-1508103
+Node: Function Example508172
+Node: Function Caveats510766
+Node: Calling A Function511187
+Node: Variable Scope512302
+Node: Pass By Value/Reference514277
+Node: Return Statement517717
+Node: Dynamic Typing520698
+Node: Indirect Calls521433
+Node: Internationalization531118
+Node: I18N and L10N532544
+Node: Explaining gettext533230
+Ref: Explaining gettext-Footnote-1538296
+Ref: Explaining gettext-Footnote-2538480
+Node: Programmer i18n538645
+Node: Translator i18n542845
+Node: String Extraction543638
+Ref: String Extraction-Footnote-1544599
+Node: Printf Ordering544685
+Ref: Printf Ordering-Footnote-1547469
+Node: I18N Portability547533
+Ref: I18N Portability-Footnote-1549982
+Node: I18N Example550045
+Ref: I18N Example-Footnote-1552680
+Node: Gawk I18N552752
+Node: Advanced Features553369
+Node: Nondecimal Data554688
+Node: Two-way I/O556269
+Ref: Two-way I/O-Footnote-1561703
+Node: TCP/IP Networking561773
+Node: Profiling564617
+Node: Library Functions572091
+Ref: Library Functions-Footnote-1575196
+Node: Library Names575367
+Ref: Library Names-Footnote-1578838
+Ref: Library Names-Footnote-2579058
+Node: General Functions579144
+Node: Nextfile Function580207
+Node: Strtonum Function584588
+Node: Assert Function587544
+Node: Round Function590870
+Node: Cliff Random Function592413
+Node: Ordinal Functions593429
+Ref: Ordinal Functions-Footnote-1596499
+Ref: Ordinal Functions-Footnote-2596751
+Node: Join Function596960
+Ref: Join Function-Footnote-1598731
+Node: Gettimeofday Function598931
+Node: Data File Management602646
+Node: Filetrans Function603278
+Node: Rewind Function607514
+Node: File Checking608967
+Node: Empty Files610061
+Node: Ignoring Assigns612291
+Node: Getopt Function613844
+Ref: Getopt Function-Footnote-1625148
+Node: Passwd Functions625351
+Ref: Passwd Functions-Footnote-1634326
+Node: Group Functions634414
+Node: Walking Arrays642498
+Node: Sample Programs644067
+Node: Running Examples644732
+Node: Clones645460
+Node: Cut Program646684
+Node: Egrep Program656533
+Ref: Egrep Program-Footnote-1664304
+Node: Id Program664414
+Node: Split Program668030
+Ref: Split Program-Footnote-1671549
+Node: Tee Program671677
+Node: Uniq Program674480
+Node: Wc Program681903
+Ref: Wc Program-Footnote-1686167
+Node: Miscellaneous Programs686367
+Node: Dupword Program687555
+Node: Alarm Program689586
+Node: Translate Program694343
+Ref: Translate Program-Footnote-1698722
+Ref: Translate Program-Footnote-2698950
+Node: Labels Program699084
+Ref: Labels Program-Footnote-1702455
+Node: Word Sorting702539
+Node: History Sorting706422
+Node: Extract Program708260
+Ref: Extract Program-Footnote-1715741
+Node: Simple Sed715869
+Node: Igawk Program718931
+Ref: Igawk Program-Footnote-1733963
+Ref: Igawk Program-Footnote-2734164
+Node: Anagram Program734302
+Node: Signature Program737400
+Node: Debugger738503
+Node: Debugging739414
+Node: Debugging Concepts739728
+Node: Debugging Terms741584
+Node: Awk Debugging744129
+Node: Sample dgawk session745021
+Node: dgawk invocation745513
+Node: Finding The Bug746695
+Node: List of Debugger Commands753180
+Node: Breakpoint Control754491
+Node: Dgawk Execution Control757967
+Node: Viewing And Changing Data761318
+Node: Dgawk Stack764627
+Node: Dgawk Info766087
+Node: Miscellaneous Dgawk Commands770035
+Node: Readline Support775466
+Node: Dgawk Limitations776293
+Node: Language History778432
+Node: V7/SVR3.1779864
+Node: SVR4782159
+Node: POSIX783601
+Node: BTL784599
+Node: POSIX/GNU785333
+Node: Common Extensions790519
+Node: Contributors791620
+Node: Installation795655
+Node: Gawk Distribution796549
+Node: Getting797033
+Node: Extracting797859
+Node: Distribution contents799550
+Node: Unix Installation804568
+Node: Quick Installation805185
+Node: Additional Configuration Options807147
+Node: Configuration Philosophy808624
+Node: Non-Unix Installation810966
+Node: PC Installation811424
+Node: PC Binary Installation812723
+Node: PC Compiling814571
+Node: PC Testing817515
+Node: PC Using818691
+Node: Cygwin822876
+Node: MSYS823873
+Node: VMS Installation824387
+Node: VMS Compilation824993
+Ref: VMS Compilation-Footnote-1826000
+Node: VMS Installation Details826058
+Node: VMS Running827693
+Node: VMS Old Gawk829300
+Node: Bugs829774
+Node: Other Versions833639
+Node: Notes838918
+Node: Compatibility Mode839610
+Node: Additions840393
+Node: Accessing The Source841205
+Node: Adding Code842628
+Node: New Ports848176
+Node: Dynamic Extensions852289
+Node: Internals853665
+Node: Plugin License862781
+Node: Sample Library863415
+Node: Internal File Description864101
+Node: Internal File Ops867808
+Ref: Internal File Ops-Footnote-1872576
+Node: Using Internal File Ops872724
+Node: Future Extensions875101
+Node: Basic Concepts877605
+Node: Basic High Level878362
+Ref: Basic High Level-Footnote-1882397
+Node: Basic Data Typing882582
+Node: Floating Point Issues887107
+Node: String Conversion Precision888190
+Ref: String Conversion Precision-Footnote-1889884
+Node: Unexpected Results889993
+Node: POSIX Floating Point Problems891819
+Ref: POSIX Floating Point Problems-Footnote-1895521
+Node: Glossary895559
+Node: Copying919702
+Node: GNU Free Documentation License957259
+Node: Index982396
End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 94e7abb..7c63476 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -20,7 +20,7 @@
@c applies to and all the info about who's publishing this edition
@c These apply across the board.
address@hidden UPDATE-MONTH January, 2011
address@hidden UPDATE-MONTH March, 2011
@set VERSION 4.0
@set PATCHLEVEL 0
@@ -143,7 +143,7 @@ Some comments on the layout for TeX.
@copying
Copyright @copyright{} 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999,
-2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009, 2010
+2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009, 2010, 2011
Free Software Foundation, Inc.
@sp 2
@@ -359,7 +359,7 @@ particular records in a file and perform operations upon
them.
* Regexp Usage:: How to Use Regular Expressions.
* Escape Sequences:: How to write nonprinting characters.
* Regexp Operators:: Regular Expression Operators.
-* Character Lists:: What can go between @samp{[...]}.
+* Bracket Expressions:: What can go between @samp{[...]}.
* GNU Regexp Operators:: Operators specific to GNU software.
* Case-sensitivity:: How to do case-insensitive matching.
* Leftmost Longest:: How much text matches.
@@ -729,7 +729,7 @@ I was @code{root} and the one-and-only user.
That day, I began the transition from statistician to Unix programmer.
On one of many trips to the library or bookstore in search of
-books on Unix, I found the gray AWK book, a.k.a. Aho, Kernighan and
+books on Unix, I found the gray AWK book, a.k.a.@: Aho, Kernighan and
Weinberger, @cite{The AWK Programming Language}, Addison-Wesley,
1988. AWK's simple programming paradigm---find a pattern in the
input and then perform an action---often reduced complex or tedious
@@ -827,6 +827,7 @@ AWK or want to learn how, then read this book.
@display
Michael Brennan
Author of @command{mawk}
+March, 2001
@end display
@node Preface
@@ -922,7 +923,7 @@ up through large-scale systems,
such as Crays. @command{gawk} has also been ported to Mac OS X,
Microsoft Windows (all versions) and OS/2 PCs,
and VMS.
-(Other systems to which @command{gawk} was once ported
+(Some other, obsolete systems to which @command{gawk} was once ported
are no longer supported and the code for those systems
has been removed.)
@@ -998,6 +999,10 @@ wrote the bulk of
His code finally became part of the main @command{gawk} distribution
with @command{gawk} @value{PVERSION} 3.1.
+John Haque rewrote the @command{gawk} internals, in the process providing
+an @command{awk}-level debugger. This version became available as
address@hidden @value{PVERSION} 4.0, in 2011.
+
@xref{Contributors},
for a complete list of those who made important contributions to
@command{gawk}.
@@ -1046,7 +1051,8 @@ use to tell this program what to do. When we need to be
careful, we call
the language ``the @command{awk} language,''
and the program ``the @command{awk} utility.''
This @value{DOCUMENT} explains
-both how to write program in the @command{awk} language and how to run the
@command{awk} utility.
+both how to write programs in the @command{awk} language and how to
+run the @command{awk} utility.
The term @address@hidden program} refers to a program written by you in
the @command{awk} programming language.
@@ -1071,7 +1077,7 @@ expert user and for the online Info and HTML versions of
the document.
@end ifnotinfo
There are
-subsections labelled
+subsections labelled @c FIXME: labeled?
as @strong{Advanced Notes}
scattered throughout the @value{DOCUMENT}.
They add a more complete explanation of points that are relevant, but not
likely
@@ -1079,8 +1085,8 @@ to be of interest on first reading.
All appear in the index, under the heading ``advanced features.''
Most of the time, the examples use complete @command{awk} programs.
-In some of the more advanced sections, only the part of the @command{awk}
-program that illustrates the concept currently being described is shown.
+Some of the more advanced sections show only the part of the @command{awk}
+program that illustrates the concept currently being described.
While this @value{DOCUMENT} is aimed principally at people who have not been
exposed
@@ -1094,6 +1100,11 @@ should be of interest.
@ref{Getting Started},
provides the essentials you need to know to begin using @command{awk}.
address@hidden Gawk},
+describes how to run @command{gawk}, the meaning of its
+command-line options, and how it finds @command{awk}
+program source files.
+
@ref{Regexp},
introduces regular expressions in general, and in particular the flavors
supported by POSIX @command{awk} and @command{gawk}.
@@ -1121,7 +1132,8 @@ doing something when a record is matched, and the
built-in variables
@ref{Arrays},
covers @command{awk}'s one-and-only data structure: associative arrays.
Deleting array elements and whole arrays is also described, as well as
-sorting arrays in @command{gawk}.
+sorting arrays in @command{gawk}. It also describes how @command{gawk}
+provides arrays of arrays.
@ref{Functions},
describes the built-in functions @command{awk} and
@@ -1139,11 +1151,6 @@ are the abilities to have two-way communications with
another process,
perform TCP/IP networking, and
profile your @command{awk} programs.
address@hidden Gawk},
-describes how to run @command{gawk}, the meaning of its
-command-line options, and how it finds @command{awk}
-program source files.
-
@ref{Library Functions}, and
@ref{Sample Programs},
provide many sample @command{awk} programs.
@@ -1193,8 +1200,8 @@ and this @value{DOCUMENT}, respectively.
@section Typographical Conventions
@cindex Texinfo
-This @value{DOCUMENT} is written using Texinfo, the GNU documentation
-formatting language.
+This @value{DOCUMENT} is written in @uref{http://texinfo.org, Texinfo},
+the GNU documentation formatting language.
A single Texinfo source file is used to produce both the printed and online
versions of the documentation.
@ifnotinfo
@@ -1329,9 +1336,13 @@ available for download from the Internet.
(There are numerous other freely available, Unix-like operating systems
based on the
-Berkeley Software Distribution, and they use recent versions
+Berkeley Software Distribution, and some of them use recent versions
of @command{gawk} for their versions of @command{awk}.
-NetBSD, FreeBSD and OpenBSD are three of the most popular ones, but there
address@hidden://www.netbsd.org, NetBSD},
address@hidden://www.freebsd.org, FreeBSD},
+and
address@hidden://www.openbsd.org, OpenBSD}
+are three of the most popular ones, but there
are others.)
@ifnotinfo
@@ -1402,7 +1413,7 @@ In 1996, Edition 1.0 was released with @command{gawk}
3.0.0.
The FSF published the first two editions under
the title @cite{The GNU Awk User's Guide}.
-This edition maintains the basic structure of Edition 1.0.
+This edition maintains the basic structure of the previous editions.
For Edition 4.0, the content has been thoroughly reviewed
and updated. All references to versions prior to 4.0 have been
removed.
@@ -1473,7 +1484,7 @@ The following people (in alphabetical order)
provided helpful comments on various
versions of this book,
Rick Adams,
-Nelson H.F. Beebe,
+Dr.@: Nelson H.F. Beebe,
Karl Berry,
Dr.@: Michael Brennan,
Rich Burridge,
@@ -1552,7 +1563,7 @@ significant editorial help for this @value{DOCUMENT} for
the
@cindex Vinschen, Corinna
@cindex Wallin, Anders
@cindex Zaretskii, Eli
-Nelson Beebe,
+Dr.@: Nelson Beebe,
Andreas Buening,
Antonio Colombo,
Stephen Davies,
@@ -1579,14 +1590,14 @@ John Haque contributed the modifications to convert
@command{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 @ref{Debugger}.
@cindex Kernighan, Brian
-I would like to thank Brian Kernighan for
-invaluable assistance during the testing and debugging of @command{gawk}, and
for
-ongoing
-help in clarifying numerous points about the language. We could not have
-done nearly as good a job on either @command{gawk} or its documentation without
-his help.
+I would like to thank Brian Kernighan for invaluable assistance during the
+testing and debugging of @command{gawk}, and for ongoing
+help and advice in clarifying numerous points about the language.
+ We could not have done nearly as good a job on either @command{gawk}
+or its documentation without his help.
@cindex Robbins, Miriam
@cindex Robbins, Jean
@@ -1605,7 +1616,7 @@ take advantage of those opportunities.
Arnold Robbins @*
Nof Ayalon @*
ISRAEL @*
-December, 2010
+March, 2011
@ignore
@c Try this
@@ -1825,7 +1836,7 @@ As an example, the following program prints a friendly
piece of advice
to keep you from worrying about the complexities of computer
address@hidden you use Bash as your shell, you should execute
the command @samp{set +H} before running this program interactively,
-to disable the @command{csh}-style command history, which treats
+to disable the C shell-style command history, which treats
@samp{!} as a special character. We recommend putting this command into
your personal startup file.}
(@code{BEGIN} is a feature we haven't discussed yet):
@@ -1917,7 +1928,7 @@ for programs that are provided on the @command{awk}
command line.
@cindex single quote (@code{'})
@c STARTOFRANGE qs2x
@cindex @code{'} (single quote)
-If you want to identify your @command{awk} program files clearly as such,
+If you want to clearly identify your @command{awk} program files as such,
you can add the extension @file{.awk} to the @value{FN}. This doesn't
affect the execution of the @command{awk} program but it does make
``housekeeping'' easier.
@@ -1964,7 +1975,7 @@ $ @kbd{advice}
@noindent
(We assume you have the current directory in your shell's search
-path variable (typically @code{$PATH}). If not, you may need
+path variable [typically @code{$PATH}]. If not, you may need
to type @samp{./advice} at the shell.)
Self-contained @command{awk} scripts are useful when you want to write a
@@ -1992,7 +2003,8 @@ the value of @code{ARGV[0]}
varies depending upon your operating system.
Some systems put @samp{awk} there, some put the full pathname
of @command{awk} (such as @file{/bin/awk}), and some put the name
-of your script (@samp{advice}). Don't rely on the value of @code{ARGV[0]}
+of your script (@samp{advice}). @value{DARKCORNER}
+Don't rely on the value of @code{ARGV[0]}
to provide your script name.
@node Comments
@@ -2087,7 +2099,7 @@ awk '@var{program text}' @var{input-file1}
@var{input-file2} @dots{}
Once you are working with the shell, it is helpful to have a basic
knowledge of shell quoting rules. The following rules apply only to
POSIX-compliant, Bourne-style shells (such as Bash, the GNU Bourne-Again
-Shell). If you use @command{csh}, you're on your own.
+Shell). If you use the C shell, you're on your own.
@itemize @bullet
@item
@@ -2133,7 +2145,7 @@ in @ref{Read Terminal},
is applicable:
@example
-$ awk "BEGIN @{ print \"Don't Panic!\" @}"
+$ @kbd{awk "BEGIN @{ print \"Don't Panic!\" @}"}
@print{} Don't Panic!
@end example
@@ -2398,7 +2410,7 @@ interpret any of it as special shell characters.
Here is what this program prints:
@example
-$ awk '/foo/ @{ print $0 @}' BBS-list
+$ @kbd{awk '/foo/ @{ print $0 @}' BBS-list}
@print{} fooey 555-1234 2400/1200/300 B
@print{} foot 555-6699 1200/300 B
@print{} macfoo 555-6480 1200/300 A
@@ -2414,8 +2426,8 @@ action is to print all lines that match the pattern.
@cindex actions, empty
Thus, we could leave out the action (the @code{print} statement and the curly
-braces) in the previous example and the result would be the same: all
-lines matching the pattern @samp{foo} are printed. By comparison,
+braces) in the previous example and the result would be the same:
address@hidden prints all lines matching the pattern @samp{foo}. By comparison,
omitting the @code{print} statement but retaining the curly braces makes an
empty action that does nothing (i.e., no lines are printed).
@@ -2499,7 +2511,7 @@ Print the total number of kilobytes used by @var{files}:
@c no need for (x+1023) / 1024
@example
ls -l @var{files} | awk '@{ x += $5 @}
- END @{ print "total K-bytes:", x /1024 @}'
+ END @{ print "total K-bytes:", x / 1024 @}'
@end example
@item
@@ -2563,8 +2575,8 @@ This is what happens if we run this program on our two
sample @value{DF}s,
@file{BBS-list} and @file{inventory-shipped}:
@example
-$ awk '/12/ @{ print $0 @}
-> /21/ @{ print $0 @}' BBS-list inventory-shipped
+$ @kbd{awk '/12/ @{ print $0 @}}
+> @kbd{/21/ @{ print $0 @}' BBS-list inventory-shipped}
@print{} aardvark 555-5553 1200/300 B
@print{} alpo-net 555-3412 2400/1200/300 A
@print{} barfly 555-7685 1200/300 A
@@ -2626,7 +2638,7 @@ The fifth field contains the size of the file in bytes.
The
sixth, seventh, and eighth fields contain the month, day, and time,
respectively, that the file was last modified. Finally, the ninth field
contains the @address@hidden @samp{LC_ALL=C} is
-needed to produce traditional-style output from @command{ls}.}
+needed to produce this traditional-style output from @command{ls}.}
@c @cindex automatic initialization
@cindex initialization, automatic
@@ -2740,10 +2752,10 @@ prompts, analogous to the standard shell's @samp{$} and
@samp{>}.
Compare the previous example to how it is done with a POSIX-compliant shell:
@example
-$ awk 'BEGIN @{
-> print \
-> "hello, world"
-> @}'
+$ @kbd{awk 'BEGIN @{}
+> @kbd{print \}
+> @kbd{"hello, world"}
+> @address@hidden'}
@print{} hello, world
@end example
@end quotation
@@ -2808,7 +2820,8 @@ as well to control how @command{awk} processes your data.
In addition, @command{awk} provides a number of built-in functions for doing
common computational and string-related operations.
@command{gawk} provides built-in functions for working with timestamps,
-performing bit manipulation, for runtime string translation,
+performing bit manipulation, for runtime string translation
(internationalization),
+determining the type of a variable,
and array sorting.
As we develop our presentation of the @command{awk} language, we introduce
@@ -2841,8 +2854,8 @@ retargetable assembler for eight-bit microprocessors
(@pxref{Glossary}, for
more information), and a microcode assembler for a special-purpose Prolog
computer.
While the original @command{awk}'s capabilities were strained by tasks
-of such complexity, modern versions are more capable. Even the Bell
-Labs version of @command{awk} has fewer predefined limits, and those
+of such complexity, modern versions are more capable. Even Brian Kernighan's
+version of @command{awk} has fewer predefined limits, and those
that it has are much larger than they used to be.
@cindex @command{awk} programs, complex
@@ -3354,6 +3367,7 @@ file and command-line @command{awk} programs,
@command{gawk} provides the
input for your source code; it allows you to easily mix command-line
and library source code
(@pxref{AWKPATH Variable}).
+The @option{--source} option may also be used multiple times on the command
line.
@cindex @code{--source} option
If no @option{-f} or @option{--source} option is specified, then @command{gawk}
@@ -3381,7 +3395,7 @@ export POSIXLY_CORRECT
@end example
@cindex @command{csh} utility, @env{POSIXLY_CORRECT} environment variable
-For a @command{csh}-compatible
+For a C shell-compatible
shell,@footnote{Not recommended.}
you would add this line to the @file{.login} file in your home directory:
@@ -3406,7 +3420,7 @@ input files to be processed in the order specified.
However, an
argument that has the form @address@hidden@var{value}}, assigns
the value @var{value} to the variable @var{var}---it does not specify a
file at all.
-(See also
+(See
@ref{Assignment Options}.)
@cindex @command{gawk}, @code{ARGIND} variable in
@@ -3492,6 +3506,9 @@ In addition, @command{gawk} allows you to specify the
special
with @code{getline}.
Some other versions of @command{awk} also support this, but it
is not standard.
+(Some operating systems provide a @file{/dev/stdin} file
+in the file system, however, @command{gawk} always processes
+this @value{FN} itself.)
@node Environment Variables
@section The Environment Variables @command{gawk} Uses
@@ -3533,9 +3550,7 @@ may use a different directory; it
will depend upon how @command{gawk} was built and installed. The actual
directory is the value of @samp{$(datadir)} generated when
@command{gawk} was configured. You probably don't need to worry about this,
-though.} (Programs written for use by
-system administrators should use an @env{AWKPATH} variable that
-does not include the current directory, @file{.}.)
+though.}
The search path feature is particularly useful for building libraries
of useful @command{awk} functions. The library files can be placed in a
@@ -3560,8 +3575,8 @@ This path search mechanism is similar
to the shell's.
@c someday, @cite{The Bourne Again Shell}....
-However, @command{gawk} always looks in the current directory before
-before searching @env{AWKPATH}, so there is no real reason to include
+However, @command{gawk} always looks in the current directory @emph{before}
+searching @env{AWKPATH}, so there is no real reason to include
the current directory in the search path.
@c Prior to 4.0, gawk searched the current directory after the
@c path search, but it's not worth documenting it.
@@ -3588,7 +3603,7 @@ list are meant to be used by regular users.
@table @env
@item POSIXLY_CORRECT
-If this variable exists, @command{gawk} switches to POSIX compatibility
+Causes @command{gawk} to switch POSIX compatibility
mode, disabling all traditional and GNU extensions.
@xref{Options}.
@@ -3604,7 +3619,7 @@ the @code{usleep()} system call,
the value is rounded up to an integral number of seconds.
@end table
-The environment variables in the following table are meant
+The environment variables in the following list are meant
for use by the @command{gawk} developers for testing and tuning.
They are subject to change. The variables are:
@@ -3630,7 +3645,8 @@ If this variable exists, @command{gawk} does not use the
DFA regexp matcher
for ``does it match'' kinds of tests. This can cause @command{gawk}
to be slower. Its purpose is to help isolate differences between the
two regexp matchers that @command{gawk} uses internally. (There aren't
-supposed to be differences, but occasionally theory and practice don't match
up.)
+supposed to be differences, but occasionally theory and practice don't
+coordinate with each other.)
@item GAWK_STACKSIZE
This specifies the amount by which @command{gawk} should grow its
@@ -3774,6 +3790,8 @@ Given the ability to specify multiple @option{-f}
options, the
However, the @samp{@@include} keyword
can help you in constructing self-contained @command{gawk} programs,
thus reducing the need for writing complex and tedious command lines.
+In particular, @samp{@@include} is very useful for writing CGI scripts
+to be run from web pages.
As mentioned in @ref{AWKPATH Variable}, the current directory is always
searched first for source files, before searching in @env{AWKPATH},
@@ -3933,7 +3951,7 @@ regular expressions work, we present more complicated
instances.
* Regexp Usage:: How to Use Regular Expressions.
* Escape Sequences:: How to write nonprinting characters.
* Regexp Operators:: Regular Expression Operators.
-* Character Lists:: What can go between @samp{[...]}.
+* Bracket Expressions:: What can go between @samp{[...]}.
* GNU Regexp Operators:: Operators specific to GNU software.
* Case-sensitivity:: How to do case-insensitive matching.
* Leftmost Longest:: How much text matches.
@@ -4021,7 +4039,7 @@ or selects, all input records whose first field
@emph{does not} contain
the uppercase letter @samp{J}:
@example
-$ awk '$1 !~ /J/' inventory-shipped
+$ @kbd{awk '$1 !~ /J/' inventory-shipped}
@print{} Feb 15 32 24 226
@print{} Mar 15 24 34 228
@print{} Apr 31 52 63 420
@@ -4060,7 +4078,7 @@ included normally; you must write @samp{\\} to put one
backslash in the
string or regexp. Thus, the string whose contents are the two characters
@samp{"} and @samp{\} must be written @code{"\"\\"}.
-Backslash also represents unprintable characters
+Other escape sequences represent unprintable characters
such as TAB or newline. While there is nothing to stop you from entering most
unprintable characters directly in a string constant or regexp constant,
they may look ugly.
@@ -4206,7 +4224,7 @@ leaves what happens as undefined. There are two choices:
@c @cindex warnings, automatic
@table @asis
@item Strip the backslash out
-This is what Unix @command{awk} and @command{gawk} both do.
+This is what Brian Kernighan's @command{awk} and @command{gawk} both do.
For example, @code{"a\qc"} is the same as @code{"aqc"}.
(Because this is such an easy bug both to introduce and to miss,
@command{gawk} warns you about it.)
@@ -4306,7 +4324,7 @@ if ("line1\nLINE 2" ~ /1$/) @dots{}
@cindex @code{.} (period)
@cindex period (@code{.})
address@hidden . @asis{(period)}
address@hidden . @r{(period)}
This matches any single character,
@emph{including} the newline character. For example, @samp{.P}
matches any single character followed by a @samp{P} in a string. Using
@@ -4335,7 +4353,7 @@ the square brackets. For example, @samp{[MVX]} matches
any one of
the characters @samp{M}, @samp{V}, or @samp{X} in a string. A full
discussion of what can be inside the square brackets of a bracket expression
is given in
address@hidden Lists}.
address@hidden Expressions}.
@cindex bracket expressions, complemented
@item [^ @dots{}]
@@ -4476,8 +4494,8 @@ interval expressions are not available in
regular expressions.
@c ENDOFRANGE regexpo
address@hidden Character Lists
address@hidden Using Character Lists
address@hidden Bracket Expressions
address@hidden Using Bracket Expressions
@c STARTOFRANGE charlist
@cindex bracket expressions
@cindex bracket expressions, range expressions
@@ -4792,12 +4810,12 @@ Otherwise, interval expressions are available by
default.
@c STARTOFRANGE csregexp
@cindex case sensitivity, regexps and
Case is normally significant in regular expressions, both when matching
-ordinary characters (i.e., not metacharacters) and inside character
-sets. Thus, a @samp{w} in a regular expression matches only a lowercase
+ordinary characters (i.e., not metacharacters) and inside bracket
+expressions. Thus, a @samp{w} in a regular expression matches only a lowercase
@samp{w} and not an uppercase @samp{W}.
-The simplest way to do a case-independent match is to use a character
-list---for example, @samp{[Ww]}. However, this can be cumbersome if
+The simplest way to do a case-independent match is to use a bracket
+expression---for example, @samp{[Ww]}. However, this can be cumbersome if
you need to use it often, and it can make the regular expressions harder
to read. There are two alternatives that you might prefer.
@@ -4940,8 +4958,8 @@ and also @pxref{Field Separators}).
The righthand side of a @samp{~} or @samp{!~} operator need not be a
regexp constant (i.e., a string of characters between slashes). It may
be any expression. The expression is evaluated and converted to a string
-if necessary; the contents of the string are used as the
-regexp. A regexp that is computed in this way is called a @dfn{dynamic
+if necessary; the contents of the string are then used as the
+regexp. A regexp computed in this way is called a @dfn{dynamic
regexp}:
@example
@@ -5008,7 +5026,7 @@ intend a regexp match.
@end itemize
@c fakenode --- for prepinfo
address@hidden Advanced Notes: Using @code{\n} in Character Lists of Dynamic
Regexps
address@hidden Advanced Notes: Using @code{\n} in Bracket Expressions of
Dynamic Regexps
@cindex regular expressions, dynamic, with embedded newlines
@cindex newlines, in dynamic regexps
@@ -5055,7 +5073,7 @@ and in these locales, @samp{[a-dx-z]} is typically not
equivalent to
@samp{[abcdxyz]}; instead it might be equivalent to @samp{[aBbCcdXxYyz]},
for example.
-This point needs to be emphasized: Much literature teaches that one should
+This point needs to be emphasized: Much literature teaches that you should
use @samp{[a-z]} to match a lowercase character. But on systems with
non-ASCII locales, this also matches all of the uppercase characters
except @samp{Z}! This is a continuous cause of confusion, even well
@@ -5120,6 +5138,10 @@ will give you much better performance when reading
records. Otherwise,
@command{gawk} has to make several function calls, @emph{per input
character}, to find the record terminator.
+According to POSIX, string conmparison is also affected by locales
+(similar to regular expressions). The details are presented in
address@hidden String Comparison}.
+
Finally, the locale affects the value of the decimal point character
used when @command{gawk} parses input data. This is discussed in
detail in @ref{Conversion}.
@@ -5354,7 +5376,7 @@ regular expression, @code{RT} contains
the actual input text that matched the regular expression.
If the input file ended without any text that matches @code{RS},
-then @command{gawk} sets @code{RT} to the null string.
address@hidden sets @code{RT} to the null string.
The following example illustrates both of these features.
It sets @code{RS} equal to a regular expression that
@@ -5362,9 +5384,9 @@ matches either a newline or a series of one or more
uppercase letters
with optional leading and/or trailing whitespace:
@example
-$ echo record 1 AAAA record 2 BBBB record 3 |
-> gawk 'BEGIN @{ RS = "\n|( *[[:upper:]]+ *)" @}
-> @{ print "Record =", $0, "and RT =", RT @}'
+$ @kbd{echo record 1 AAAA record 2 BBBB record 3 |}
+> @kbd{gawk 'BEGIN @{ RS = "\n|( *[[:upper:]]+ *)" @}}
+> @address@hidden print "Record =", $0, "and RT =", RT @}'}
@print{} Record = record 1 and RT = AAAA
@print{} Record = record 2 and RT = BBBB
@print{} Record = record 3 and RT =
@@ -5463,7 +5485,7 @@ like words in a line.
Whitespace in @command{awk} means any string of one or more spaces,
TABs, or newlines;@footnote{In POSIX @command{awk}, newlines are not
considered whitespace for separating fields.} other characters, such as
-formfeed, vertical tab, etc.@: that are
+formfeed, vertical tab, etc., that are
considered whitespace by other languages, are @emph{not} considered
whitespace by @command{awk}.
@@ -5769,6 +5791,24 @@ reparsed into fields using the @emph{current} value of
@code{FS}.
This also applies to any built-in function that updates @code{$0},
such as @code{sub()} and @code{gsub()}
(@pxref{String Functions}).
+
address@hidden fakenode --- for prepinfo
address@hidden Advanced Notes: Understanding @code{$0}
+
+It is important to remember that @code{$0} is the @emph{full}
+record, exactly as it was read from the input. This includes
+any leading or trailing whitespace, and the exact whitespace (or other
+characters) that separate the fields.
+
+It is a not-uncommon error to try to change the field separators
+in a record simply by setting @code{FS} and @code{OFS}, and then
+expecting a plain @samp{print} or @samp{print $0} to print the
+modified record.
+
+But this does not work, since nothing was done to change the record
+itself. Instead, you must force the record to be rebuilt, typically
+with a statement such as @samp{$1 = $1}, as described earlier.
+
@c ENDOFRANGE ficon
@node Field Separators
@@ -5977,7 +6017,7 @@ different @command{awk} versions answer this question
differently, and you
should not rely on any specific behavior in your programs.
@value{DARKCORNER}
-As a point of information, the Brian Kernighan's @command{awk} allows @samp{^}
+As a point of information, Brian Kernighan's @command{awk} allows @samp{^}
to match only at the beginning of the record. @command{gawk}
also works this way. For example:
@@ -5987,8 +6027,7 @@ $ @kbd{echo 'xxAA xxBxx C' |}
> @kbd{printf "-->%s<--\n", $i @}'}
@print{} --><--
@print{} -->AA<--
address@hidden --><--
address@hidden -->Bxx<--
address@hidden -->xxBxx<--
@print{} -->C<--
@end example
@c ENDOFRANGE regexpfs
@@ -6086,7 +6125,7 @@ figures that you really want your fields to be separated
with TABs and
not @samp{t}s. Use @samp{-v FS="t"} or @samp{-F"[t]"} on the command line
if you really do want to separate your fields with @samp{t}s.
-For example, let's use an @command{awk} program file called @file{baud.awk}
+As an example, let's use an @command{awk} program file called @file{baud.awk}
that contains the pattern @code{/300/} and the action @samp{print $1}:
@example
@@ -6199,7 +6238,7 @@ should reflect the old value of @code{FS}, not the new
one.
@cindex dark corner, field separators
@cindex @command{sed} utility
@cindex stream editors
-However, many implementations of @command{awk} do not work this way. Instead,
+However, many older implementations of @command{awk} do not work this way.
Instead,
they defer splitting the fields until a field is actually
referenced. The fields are split
using the @emph{current} value of @code{FS}!
@@ -6388,7 +6427,7 @@ if (PROCINFO["FS"] == "FS")
else if (PROCINFO["FS"] == "FIELDWIDTHS")
@var{fixed-width field splitting} @dots{}
else
- @var{content-based field splitting} @dots{}
+ @var{content-based field splitting} @dots{} (see next @value{SECTION})
@end example
This information is useful when writing a function
@@ -7045,7 +7084,7 @@ Unfortunately, @command{gawk} has not been consistent in
its treatment
of a construct like @address@hidden"echo "} "date" | getline}.
Most versions, including the current version, treat it at as
@address@hidden("echo "} "date") | getline}.
-(This how Unix @command{awk} behaves.)
+(This how Brian Kernighan's @command{awk} behaves.)
Some versions changed and treated it as
@address@hidden"echo "} ("date" | getline)}.
(This is how @command{mawk} behaves.)
@@ -7207,11 +7246,12 @@ can cause @code{FILENAME} to be updated if they cause
@ref{table-getline-variants}
summarizes the eight variants of @code{getline},
-listing which built-in variables are set by each one.
+listing which built-in variables are set by each one,
+and whether the variant is standard or a @command{gawk} extension.
@float Table,table-getline-variants
@caption{getline Variants and What They Set}
address@hidden @columnfractions .33 .43 .22
address@hidden @columnfractions .33 .38 .27
@headitem Variant @tab Effect @tab Standard / Extension
@item @code{getline} @tab Sets @code{$0}, @code{NF}, @code{FNR}, and @code{NR}
@tab Standard
@item @code{getline} @var{var} @tab Sets @var{var}, @code{FNR}, and @code{NR}
@tab Standard
@@ -7431,7 +7471,7 @@ You can continue either a @code{print} or
As mentioned previously, a @code{print} statement contains a list
of items separated by commas. In the output, the items are normally
separated by single spaces. However, this doesn't need to be the case;
-a single space is only the default. Any string of
+a single space is simply the default. Any string of
characters may be used as the @dfn{output field separator} by setting the
built-in variable @code{OFS}. The initial value of this variable
is the string @address@hidden" "}}---that is, a single space.
@@ -7573,7 +7613,7 @@ specifies how to output each of the other arguments. It
is called the
@dfn{format string}.
The format string is very similar to that in the ISO C library function
address@hidden Most of @var{format} is text to output verbatim.
address@hidden()}. Most of @var{format} is text to output verbatim.
Scattered among this text are @dfn{format specifiers}---one per item.
Each format specifier says to output the next item in the argument list
at that place in the format.
@@ -7685,11 +7725,11 @@ and positive infinity as
The special ``not a number'' value formats as @samp{-nan} or @samp{nan}.
@item %F
-Like @code{%f} but the infinity and ``not a number'' values are spelled
+Like @samp{%f} but the infinity and ``not a number'' values are spelled
using uppercase letters.
-The @code{%F} format is a POSIX extension to ISO C; not all systems
-support it. On those that don't, @command{gawk} uses @code{%f} instead.
+The @samp{%F} format is a POSIX extension to ISO C; not all systems
+support it. On those that don't, @command{gawk} uses @samp{%f} instead.
@item address@hidden,} %G
Print a number in either scientific notation or in floating-point
@@ -7776,7 +7816,7 @@ For now, we will not use them.
@item -
The minus sign, used before the width modifier (see later on in
-this table),
+this list),
says to left-justify
the argument within its specified width. Normally, the argument
is printed right-justified in the specified width. Thus:
@@ -7794,7 +7834,7 @@ negative values with a minus sign.
@item +
The plus sign, used before the width modifier (see later on in
-this table),
+this list),
says to always supply a sign for numeric conversions, even if the data
to format is positive. The @samp{+} overrides the space modifier.
@@ -7822,12 +7862,12 @@ character in it. This only works in locales that
support such characters.
For example:
@example
-$ @kbd{cat thousands.awk} @i{Show source program}
+$ @kbd{cat thousands.awk} @ii{Show source program}
@print{} BEGIN @{ printf "%'d\n", 1234567 @}
$ @kbd{LC_ALL=C gawk -f thousands.awk}
address@hidden 1234567 @i{Results in "C" locale}
address@hidden 1234567 @ii{Results in "C" locale}
$ @kbd{LC_ALL=en_US.UTF-8 gawk -f thousands.awk}
address@hidden 1,234,567 @i{Results in US English UTF locale}
address@hidden 1,234,567 @ii{Results in US English UTF locale}
@end example
@noindent
@@ -8224,6 +8264,7 @@ many
@ifnottex
Many
@end ifnottex
+older
@command{awk} implementations limit the number of pipelines that an
@command{awk}
program may have open to just one! In @command{gawk}, there is no such limit.
@command{gawk} allows a program to
@@ -8285,7 +8326,7 @@ and TCP/IP networking.
Running programs conventionally have three input and output streams
already available to them for reading and writing. These are known as
the @dfn{standard input}, @dfn{standard output}, and @dfn{standard error
-output}. These streams are, by default, connected to your screen, but
+output}. These streams are, by default, connected to your keyboard and
screen, but
they are often redirected with the shell, via the @samp{<}, @samp{<<},
@samp{>}, @samp{>>}, @samp{>&}, and @samp{|} operators. Standard error
is typically used for writing error messages; the reason there are two separate
@@ -8391,7 +8432,7 @@ versions of @command{awk}.
@cindex networks, support for
@cindex TCP/IP, support for
address@hidden programs
address@hidden programs
can open a two-way
TCP/IP connection, acting as either a client or a server.
This is done using a special @value{FN} of the form:
@@ -8400,8 +8441,8 @@ This is done using a special @value{FN} of the form:
@file{/@var{net-type}/@var{protocol}/@var{local-port}/@var{remote-host}/@var{remote-port}}
@end example
-The @var{net-type} is one of @samp{inet}, @samp{inet4} or @samp{inet6}
-The @var{protocol} is one of @samp{tcp}, @samp{udp}, or @samp{raw},
+The @var{net-type} is one of @samp{inet}, @samp{inet4} or @samp{inet6}.
+The @var{protocol} is one of @samp{tcp} or @samp{udp},
and the other fields represent the other essential pieces of information
for making a networking connection.
These @value{FN}s are used with the @samp{|&} operator for communicating
@@ -8429,7 +8470,7 @@ compatibility mode (@pxref{Options}).
interprets these special @value{FN}s.
For example, using @samp{/dev/fd/4}
for output actually writes on file descriptor 4, and not on a new
-file descriptor that is @code{dup}'ed from file descriptor 4. Most of
+file descriptor that is @code{dup()}'ed from file descriptor 4. Most of
the time this does not matter; however, it is important to @emph{not}
close any of the files related to file descriptors 0, 1, and 2.
Doing so results in unpredictable behavior.
@@ -8917,7 +8958,7 @@ if (/foo/ ~ $1) print "found foo"
@cindex regexp constants, in @command{gawk}
@noindent
This code is ``obviously'' testing @code{$1} for a match against the regexp
address@hidden/foo/}. But in fact, the expression @samp{/foo/ ~ $1} actually
means
address@hidden/foo/}. But in fact, the expression @samp{/foo/ ~ $1} really
means
@samp{($0 ~ /foo/) ~ $1}. In other words, first match the input record
against the regexp @code{/foo/}. The result is either zero or one,
depending upon the success or failure of the match. That result
@@ -8941,8 +8982,9 @@ upon the contents of the current input record.
@cindex @code{sub()} function
@cindex @code{gsub()} function
Constant regular expressions are also used as the first argument for
-the @code{gensub()}, @code{sub()}, and @code{gsub()} functions, and as the
-second argument of the @code{match()} function
+the @code{gensub()}, @code{sub()}, and @code{gsub()} functions, as the
+second argument of the @code{match()} function,
+and as the third argument of the @code{patsplit()} function
(@pxref{String Functions}).
Modern implementations of @command{awk}, including @command{gawk}, allow
the third argument of @code{split()} to be a regexp constant, but some
@@ -9031,8 +9073,8 @@ variables, but their values are also used or changed
automatically by
Variables in @command{awk} can be assigned either numeric or string values.
The kind of value a variable holds can change over the life of a program.
By default, variables are initialized to the empty string, which
-is zero if converted to a number. There is no need to
-``initialize'' each variable explicitly in @command{awk},
+is zero if converted to a number. There is no need to explicitly
+``initialize'' a variable in @command{awk},
which is what you would do in C and in most other traditional languages.
@node Assignment Options
@@ -9062,7 +9104,7 @@ as in the following:
@noindent
the variable is set at the very beginning, even before the
address@hidden rules are run. The @option{-v} option and its assignment
address@hidden rules execute. The @option{-v} option and its assignment
must precede all the @value{FN} arguments, as well as the program text.
(@xref{Options}, for more information about
the @option{-v} option.)
@@ -9078,7 +9120,7 @@ awk '@{ print $n @}' n=4 inventory-shipped n=2 BBS-list
prints the value of field number @code{n} for all input records. Before
the first file is read, the command line sets the variable @code{n}
equal to four. This causes the fourth field to be printed in lines from
-the file @file{inventory-shipped}. After the first file has finished,
address@hidden After the first file has finished,
but before the second file is started, @code{n} is set to two, so that the
second field is printed in lines from @file{BBS-list}:
@@ -9158,6 +9200,7 @@ Strange results can occur if you set @code{CONVFMT} to a
string that doesn't
tell @code{sprintf()} how to format floating-point numbers in a useful way.
For example, if you forget the @samp{%} in the format, @command{awk} converts
all numbers to the same constant string.
+
As a special case, if a number is an integer, then the result of converting
it to a string is @emph{always} an integer, no matter what the value of
@code{CONVFMT} may be. Given the following code fragment:
@@ -9223,7 +9266,7 @@ $ @kbd{echo 4,321 | LC_ALL=en_DK gawk '@{ print $1 + 1
@}'}
The @samp{en_DK} locale is for English in Denmark, where the comma acts as
the decimal point separator. In the normal @code{"C"} locale, @command{gawk}
treats @samp{4,321} as @samp{4}, while in the Danish locale, it's treated
-as the full number, @samp{4.321}.
+as the full number, 4.321.
Some earlier versions of @command{gawk} fully complied with this aspect
of the standard. However, many users in non-English locales complained
@@ -9296,7 +9339,7 @@ Chris 72 92 89
@end example
@noindent
-This programs takes the file @file{grades} and prints the average
+This program takes the file @file{grades} and prints the average
of the scores:
@example
@@ -9356,7 +9399,7 @@ addition and subtraction have the same precedence.
@cindex differences in @command{awk} and @command{gawk}, trunc-mod operation
@cindex trunc-mod operation
-When computing the remainder of @address@hidden % @var{y}},
+When computing the remainder of @address@hidden % @var{y}},
the quotient is rounded toward zero to an integer and
multiplied by @var{y}. This result is subtracted from @var{x};
this operation is sometimes known as ``trunc-mod.'' The following
@@ -9433,8 +9476,8 @@ print "something meaningful" > file name
@noindent
This produces a syntax error with some versions of Unix
address@hidden@footnote{It happens that the current
-Unix @command{awk}, @command{gawk} and @command{mawk} all ``get it right,''
address@hidden@footnote{It happens that Brian Kernighan's
address@hidden, @command{gawk} and @command{mawk} all ``get it right,''
but you should not rely on this.}
It is necessary to use the following:
@@ -9833,25 +9876,26 @@ Following is a summary of increment and decrement
expressions:
@cindex @code{+} (plus sign), @code{++} operator
@cindex plus sign (@code{+}), @code{++} operator
@item address@hidden
-This expression increments @var{lvalue}, and the new value becomes the
+Increment @var{lvalue}, returning the new value as the
value of the expression.
@item @var{lvalue}++
-This expression increments @var{lvalue}, but
-the value of the expression is the @emph{old} value of @var{lvalue}.
+Increment @var{lvalue}, returning the @emph{old} value of @var{lvalue}
+as the value of the expression.
@cindex @code{-} (hyphen), @code{--} operator
@cindex hyphen (@code{-}), @code{--} operator
@item address@hidden
-This expression is
-like @address@hidden, but instead of adding, it subtracts. It
-decrements @var{lvalue} and delivers the value that is the result.
+Decrement @var{lvalue}, returning the new value as the
+value of the expression.
+(This expression is
+like @address@hidden, but instead of adding, it subtracts.)
@item @var{lvalue}--
-This expression is
-like @address@hidden, but instead of adding, it subtracts. It
-decrements @var{lvalue}. The value of the expression is the @emph{old}
-value of @var{lvalue}.
+Decrement @var{lvalue}, returning the @emph{old} value of @var{lvalue}
+as the value of the expression.
+(This expression is
+like @address@hidden, but instead of adding, it subtracts.)
@end table
@c fakenode --- for prepinfo
@@ -9939,7 +9983,7 @@ However, @command{awk} is different.
It borrows a very simple concept of true and
false from C. In @command{awk}, any nonzero numeric value @emph{or} any
nonempty string value is true. Any other value (zero or the null
-string @code{""}) is false. The following program prints @samp{A strange
+string, @code{""}) is false. The following program prints @samp{A strange
truth value} three times:
@example
@@ -10309,7 +10353,7 @@ One special place where @code{/foo/} is @emph{not} an
abbreviation for
where this is discussed in more detail.
@node POSIX String Comparison
address@hidden String comparison with POSIX rules.
address@hidden String Comparison With POSIX Rules
The POSIX standard says that string comparison is performed based
on the locale's collating order. This is usually very different
@@ -10320,7 +10364,7 @@ to behave the same way as if the strings are compared
with the C
Because this behavior differs considerably from existing practice,
@command{gawk} only implements it when in POSIX mode (@pxref{Options}).
-Here is an example to illustrate the difference, in a @code{en_US.UTF-8}
+Here is an example to illustrate the difference, in an @samp{en_US.UTF-8}
locale:
@example
@@ -10602,7 +10646,7 @@ treated as local variables and initialized to the empty
string
As an advanced feature, @command{gawk} provides indirect function calls,
which is a way to choose the function to call at runtime, instead of
when you write the source code to your program. We defer discussion of
-this feature until later; @xref{Indirect Calls}.
+this feature until later; see @ref{Indirect Calls}.
@cindex side effects, function calls
Like every other expression, the function call has a value, which is
@@ -10878,8 +10922,8 @@ building something useful.
* Expression Patterns:: Any expression can be used as a pattern.
* Ranges:: Pairs of patterns specify record ranges.
* BEGIN/END:: Specifying initialization and cleanup rules.
-* Empty:: The empty pattern, which matches every record.
* BEGINFILE/ENDFILE:: Two special patterns for advanced control.
+* Empty:: The empty pattern, which matches every record.
@end menu
@cindex patterns, types of
@@ -10910,15 +10954,15 @@ Special patterns for you to supply startup or cleanup
actions for your
@command{awk} program.
(@xref{BEGIN/END}.)
address@hidden @var{empty}
-The empty pattern matches every input record.
-(@xref{Empty}.)
-
@item BEGINFILE
@itemx ENDFILE
Special patterns for you to supply startup or cleanup actions to
done on a per file basis.
(@xref{BEGINFILE/ENDFILE}.)
+
address@hidden @var{empty}
+The empty pattern matches every input record.
+(@xref{Empty}.)
@end table
@node Regexp Patterns
@@ -11211,7 +11255,7 @@ for a number of useful library functions.
If an @command{awk} program has only @code{BEGIN} rules and no
other rules, then the program exits after the @code{BEGIN} rule is
address@hidden original version of @command{awk} used to keep
address@hidden original version of @command{awk} kept
reading and ignoring input until the end of the file was seen.} However, if an
@code{END} rule exists, then the input is read, even if there are
no other rules in the program. This is necessary in case the @code{END}
@@ -11245,7 +11289,7 @@ rule. It contains the number of fields from the last
input record.
Most probably due to an oversight, the standard does not say that @code{$0}
is also preserved, although logically one would think that it should be.
In fact, @command{gawk} does preserve the value of @code{$0} for use in
address@hidden rules. Be aware, however, that Unix @command{awk}, and possibly
address@hidden rules. Be aware, however, that Brian Kernighan's @command{awk},
and possibly
other implementations, do not.
The third point follows from the first two. The meaning of @samp{print}
@@ -11271,29 +11315,12 @@ are not valid in an @code{END} rule, since all the
input has been read.
@c ENDOFRANGE beg
@c ENDOFRANGE end
address@hidden Empty
address@hidden The Empty Pattern
-
address@hidden empty pattern
address@hidden patterns, empty
-An empty (i.e., nonexistent) pattern is considered to match @emph{every}
-input record. For example, the program:
-
address@hidden
-awk '@{ print $1 @}' BBS-list
address@hidden example
-
address@hidden
-prints the first field of every record.
-
@node BEGINFILE/ENDFILE
@subsection The @code{BEGINFILE} and @code{ENDFILE} Special Patterns
@cindex @code{BEGINFILE} pattern
@cindex @code{ENDFILE} pattern
address@hidden NOTE
This @value{SECTION} describes a @command{gawk}-specific feature.
address@hidden quotation
Two special kinds of rule, @code{BEGINFILE} and @code{ENDFILE}, give
you ``hooks'' into @command{gawk}'s command-line file processing loop.
@@ -11308,7 +11335,7 @@ is set to the name of the current file, and @code{FNR}
is set to zero.
The @code{BEGINFILE} rule provides you the opportunity for two tasks
that would otherwise be difficult or impossible to perform:
address@hidden 1
address@hidden @bullet
@item
You can test if the file is readable. Normally, it is a fatal error if a
file named on the command line cannot be opened for reading. However,
@@ -11330,7 +11357,7 @@ 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}
has started processing the file. (This is a @emph{very} advanced feature,
currently used only by the @uref{http://xgawk.sourceforge.net, XMLgawk
project}.)
address@hidden enumerate
address@hidden itemize
The @code{ENDFILE} rule is called when @command{gawk} has finished processing
the last record in an input file. For the last input file,
@@ -11356,6 +11383,21 @@ both @code{BEGINFILE} and @code{ENDFILE}. Only the
@samp{getline
@code{BEGINFILE} and @code{ENDFILE} are @command{gawk} extensions.
In most other @command{awk} implementations, or if @command{gawk} is in
compatibility mode (@pxref{Options}), they are not special.
+
address@hidden Empty
address@hidden The Empty Pattern
+
address@hidden empty pattern
address@hidden patterns, empty
+An empty (i.e., nonexistent) pattern is considered to match @emph{every}
+input record. For example, the program:
+
address@hidden
+awk '@{ print $1 @}' BBS-list
address@hidden example
+
address@hidden
+prints the first field of every record.
@c ENDOFRANGE pat
@node Using Shell Variables
@@ -11387,7 +11429,7 @@ awk "/$pattern/ "'@{ nmatches++ @}
the @command{awk} program consists of two pieces of quoted text
that are concatenated together to form the program.
The first part is double-quoted, which allows substitution of
-the @code{pattern} variable inside the quotes.
+the @code{pattern} shell variable inside the quotes.
The second part is single-quoted.
Variable substitution via quoting works, but can be potentially
@@ -11460,8 +11502,8 @@ all. However, if you omit the action entirely, omit
the curly braces as
well. An omitted action is equivalent to @address@hidden print $0 @}}:
@example
-/foo/ @{ @} @i{match @code{foo}, do nothing --- empty action}
-/foo/ @i{match @code{foo}, print the record --- omitted action}
+/foo/ @{ @} @ii{match @code{foo}, do nothing --- empty action}
+/foo/ @ii{match @code{foo}, print the record --- omitted action}
@end example
The following types of statements are supported in @command{awk}:
@@ -11514,8 +11556,8 @@ For deleting array elements.
@cindex actions, control statements in
@dfn{Control statements}, such as @code{if}, @code{while}, and so on,
-control the flow of execution in @command{awk} programs. Most of the
-control statements in @command{awk} are patterned after similar statements in
C.
+control the flow of execution in @command{awk} programs. Most of
@command{awk}'s
+control statements are patterned after similar statements in C.
@cindex compound address@hidden control statements and
@cindex statements, address@hidden control statements and
@@ -11907,7 +11949,7 @@ and continues processing. (This is very different from
the @code{exit}
statement, which stops the entire @command{awk} program.
@xref{Exit Statement}.)
-Th following program illustrates how the @var{condition} of a @code{for}
+The following program illustrates how the @var{condition} of a @code{for}
or @code{while} statement could be replaced with a @code{break} inside
an @code{if}:
@@ -11944,9 +11986,9 @@ However, although it was never documented,
historical implementations of @command{awk} treated the @code{break}
statement outside of a loop as if it were a @code{next} statement
(@pxref{Next Statement}).
-Recent versions of Unix @command{awk} no longer allow this usage,
-nor does @command{gawk}.
@value{DARKCORNER}
+Recent versions of Brian Kernighan's @command{awk} no longer allow this usage,
+nor does @command{gawk}.
@node Continue Statement
@subsection The @code{continue} Statement
@@ -12002,15 +12044,16 @@ This program loops forever once @code{x} reaches 5.
@cindex POSIX @command{awk}, @code{continue} statement and
@cindex dark corner, @code{continue} statement
@cindex @command{gawk}, @code{continue} statement in
-The @code{continue} statement has no meaning when used outside the body of
+The @code{continue} statement has no special meaning with respect to the
address@hidden statement, nor does it any meaning when used outside the body of
a loop. Historical versions of @command{awk} treated a @code{continue}
statement outside a loop the same way they treated a @code{break}
statement outside a loop: as if it were a @code{next}
statement
(@pxref{Next Statement}).
-Recent versions of Unix @command{awk} no longer work this way, nor
-does @command{gawk}.
@value{DARKCORNER}
+Recent versions of Brian Kernighan's @command{awk} no longer work this way, nor
+does @command{gawk}.
@node Next Statement
@subsection The @code{next} Statement
@@ -12060,7 +12103,7 @@ If the @code{next} statement causes the end of the
input to be reached,
then the code in any @code{END} rules is executed.
@xref{BEGIN/END}.
-The @code{next} statement is not inside @code{BEGINFILE} and
+The @code{next} statement is not allowed inside @code{BEGINFILE} and
@code{ENDFILE} rules. @xref{BEGINFILE/ENDFILE}.
@c @cindex @command{awk} language, POSIX version
@@ -12100,9 +12143,12 @@ or if @command{gawk} is in compatibility mode
(@pxref{Options}),
@code{nextfile} is not special.
-Upon execution of the @code{nextfile} statement, @code{FILENAME} is
+Upon execution of the @code{nextfile} statement,
+any @code{ENDFILE} rules are executed,
address@hidden is
updated to the name of the next @value{DF} listed on the command line,
address@hidden is reset to one, @code{ARGIND} is incremented, and processing
address@hidden is reset to one, @code{ARGIND} is incremented,
+any @code{BEGINFILE} rules are executed, and processing
starts over with the first rule in the program.
(@code{ARGIND} hasn't been introduced yet. @xref{Built-in Variables}.)
If the @code{nextfile} statement causes the end of the input to be reached,
@@ -12140,9 +12186,6 @@ Versions}) also supports @code{nextfile}. However, it
doesn't allow the
next record and starts processing it with the first rule in the program,
just as any other @code{nextfile} statement.
-The @code{nextfile} statement has a special purpose when used inside a
address@hidden rule; see @ref{BEGINFILE/ENDFILE}.
-
@node Exit Statement
@subsection The @code{exit} Statement
@@ -12170,6 +12213,7 @@ An @code{exit} statement that is not part of a
@code{BEGIN} or @code{END}
rule stops the execution of any further automatic rules for the current
record, skips reading any remaining input records, and executes the
@code{END} rule if there is one.
+Any @code{ENDFILE} rules are also skipped; they are not executed.
In such a case,
if you don't want the @code{END} rule to do its job, set a variable
@@ -12207,9 +12251,11 @@ BEGIN @{
@}
@end example
address@hidden NOTE
For full portability, exit values should be between zero and 126, inclusive.
Negative values, and values of 127 or greater, may not produce consistent
results across different operating systems.
address@hidden quotation
@c ENDOFRANGE csta
@c ENDOFRANGE acs
@@ -12270,8 +12316,9 @@ string values of @code{"r"} or @code{"w"} specify that
input files and
output files, respectively, should use binary I/O.
A string value of @code{"rw"} or @code{"wr"} indicates that all
files should use binary I/O.
-Any other string value is equivalent to @code{"rw"}, but @command{gawk}
-generates a warning message.
+Any other string value is treated the same as @code{"rw"},
+but causes @command{gawk}
+to generate a warning message.
@code{BINMODE} is described in more detail in
@ref{PC Using}.
@@ -12380,7 +12427,7 @@ matching with @samp{~} and @samp{!~}, as well as the
@code{gensub()},
@code{gsub()}, @code{index()}, @code{match()}, @code{patsplit()},
@code{split()}, and @code{sub()}
functions, record termination with @code{RS}, and field splitting with
address@hidden, all ignore case when doing their particular regexp operations.
address@hidden and @code{FPAT}, all ignore case when doing their particular
regexp operations.
However, the value of @code{IGNORECASE} does @emph{not} affect array
subscripting
and it does not affect field splitting when using a single-character
field separator.
@@ -12531,9 +12578,9 @@ $ @kbd{awk 'BEGIN @{}
@end example
@noindent
address@hidden contains @code{"awk"}, @code{ARGV[1]}
-contains @code{"inventory-shipped"}, and @code{ARGV[2]} contains
address@hidden"BBS-list"}. The value of @code{ARGC} is three, one more than the
address@hidden contains @samp{awk}, @code{ARGV[1]}
+contains @samp{inventory-shipped}, and @code{ARGV[2]} contains
address@hidden The value of @code{ARGC} is three, one more than the
index of the last element in @code{ARGV}, because the elements are numbered
from zero.
@@ -12600,7 +12647,7 @@ If a system error occurs during a redirection for
@code{getline},
during a read for @code{getline}, or during a @code{close()} operation,
then @code{ERRNO} contains a string describing the error.
-Starting with @value{PVERSION} 4.0, @command{gawk} clears @code{ERRNO}
+In addition, @command{gawk} clears @code{ERRNO}
before opening each command-line input file. This enables checking if
the file is readable inside a @code{BEGINFILE} pattern
(@pxref{BEGINFILE/ENDFILE}).
@@ -12663,7 +12710,7 @@ node,
assigning a value to @code{NF} has the potential to affect
@command{awk}'s internal workings. In particular, assignments
to @code{NF} can be used to create or remove fields from the
-current record: @xref{Changing Fields}.
+current record. @xref{Changing Fields}.
@cindex @code{NR} variable
@item NR
@@ -12692,7 +12739,7 @@ The value of the @code{geteuid()} system call.
This is
@code{"FS"} if field splitting with @code{FS} is in effect,
@code{"FIELDWIDTHS"} if field splitting with @code{FIELDWIDTHS} is in effect,
-or it is @code{"FPAT"} if field matching with @code{FPAT} is in effect.
+or @code{"FPAT"} if field matching with @code{FPAT} is in effect.
@item PROCINFO["gid"]
The value of the @code{getgid()} system call.
@@ -12706,9 +12753,6 @@ The process ID of the current process.
@item PROCINFO["ppid"]
The parent process ID of the current process.
address@hidden PROCINFO["uid"]
-The value of the @code{getuid()} system call.
-
@item PROCINFO["sorted_in"]
If this element exists in @code{PROCINFO}, its value controls the
order in which array indices will be processed by
@@ -12730,6 +12774,9 @@ The default time format string for @code{strftime()}.
Assigning a new value to this element changes the default.
@xref{Time Functions}.
address@hidden PROCINFO["uid"]
+The value of the @code{getuid()} system call.
+
@item PROCINFO["version"]
The version of @command{gawk}.
@end table
@@ -12942,6 +12989,8 @@ gawk -f myprog -d -v file1 file2 @dots{}
Because @option{-d} is not a valid @command{gawk} option,
it and the following @option{-v}
are passed on to the @command{awk} program.
+(@xref{Getopt Function}, for an @command{awk} library function
+that parses command-line options.)
@node Arrays
@chapter Arrays in @command{awk}
@@ -13381,7 +13430,7 @@ for a more detailed example of this type.
@cindex elements in arrays, order of
The order in which elements of the array are accessed by this statement
is determined by the internal arrangement of the array elements within
address@hidden and cannot be controlled or changed. This can lead to
address@hidden and normally cannot be controlled or changed. This can lead to
problems if new elements are added to @var{array} by statements in
the loop body; it is not predictable whether the @code{for} loop will
reach them. Similarly, changing @var{var} inside the loop may produce
@@ -13443,7 +13492,7 @@ delete @address@hidden
Once an array element has been deleted, any value the element once
had is no longer available. It is as if the element had never
-been referred to or had been given a value.
+been referred to or been given a value.
The following is an example of deleting elements in an array:
@example
@@ -13476,7 +13525,7 @@ if (4 in foo)
@cindex lint checking, array elements
It is not an error to delete an element that does not exist.
-If @option{--lint} is provided on the command line
+However, if @option{--lint} is provided on the command line
(@pxref{Options}),
@command{gawk} issues a warning message when an element that
is not in the array is deleted.
@@ -13575,7 +13624,7 @@ the following works:
@example
for (i = 1; i <= maxsub; i++)
- @i{do something with} array[i]
+ @ii{do something with} array[i]
@end example
The ``integer values always convert to strings as integers'' rule
@@ -13872,7 +13921,7 @@ END @{
@ii{Work with sorted indices directly:}
@var{do something with} dest[i]
@dots{}
- @ii{Access original array via sorted indices:}
+ @ii{Access original array via sorted indices:}
@var{do something with} source[dest[i]]
@}
@}
@@ -13887,9 +13936,7 @@ Copying array indices and elements isn't expensive in
terms of memory.
Internally, @command{gawk} maintains @dfn{reference counts} to data.
For example, when @code{asort()} copies the first array to the second one,
there is only one copy of the original array elements' data, even though
-both arrays use the values. Similarly, when copying the indices from
address@hidden to @code{ind}, there is only one copy of the actual index
-strings.
+both arrays use the values.
@c Document It And Call It A Feature. Sigh.
@cindex @command{gawk}, @code{IGNORECASE} variable in
@@ -13972,6 +14019,7 @@ as a scalar.
The built-in functions which take array arguments can also be used
with subarrays. For example, the following code fragment uses @code{length()}
+(@pxref{String Functions})
to determine the number of elements in the main array @code{a} and
its subarrays:
@@ -14016,7 +14064,7 @@ for (i in array) @{
if (isarray(array[i]) @{
for (j in array[i]) @{
print array[i][j]
- @}
+ @}
@}
@}
@end example
@@ -14118,7 +14166,7 @@ is a call to the function @code{atan2()} and has two
arguments.
@cindex programming conventions, functions, calling
@cindex whitespace, address@hidden calling
Whitespace is ignored between the built-in function name and the
-open parenthesis, and it is good practice to avoid using whitespace
+open parenthesis, but nonetheless it is good practice to avoid using whitespace
there. User-defined functions do not permit whitespace in this way, and
it is easier to avoid mistakes by following a simple
convention that always works---no whitespace after a function name.
@@ -14205,6 +14253,7 @@ otherwise, report an error.
Return a random number. The values of @code{rand()} are
uniformly distributed between zero and one.
The value could be zero but is never address@hidden C version of @code{rand()}
+on many Unix systems
is known to produce fairly poor sequences of random numbers.
However, nothing requires that an @command{awk} implementation use the C
@code{rand()} to implement the @command{awk} version of @code{rand()}.
@@ -14263,7 +14312,7 @@ Return the sine of @var{x}, with @var{x} in radians.
@item sqrt(@var{x})
@cindex @code{sqrt()} function
Return the positive square root of @var{x}.
address@hidden reports an error
address@hidden prints a warning message
if @var{x} is negative. Thus, @code{sqrt(4)} is 2.
@item srand(@address@hidden@r{]})
@@ -14299,7 +14348,19 @@ sequences of random numbers.
@subsection String-Manipulation Functions
The functions in this @value{SECTION} look at or change the text of one or more
-strings. Optional parameters are enclosed in square address@hidden ([ ]).}
+strings.
address@hidden understands locales (@pxref{Locales}), and does all string
processing in terms of
address@hidden, not @emph{bytes}. This distinction is particularly important
+to understand for locales where one character
+may be represented by multiple bytes. Thus, for example, @code{length()}
+returns the number of characters in a string, and not the number of bytes
+used to represent those characters, Similarly, @code{index()} works with
+character indices, and not byte indices.
+
+In the following list, optional parameters are enclosed in square
address@hidden ([ ]).}
+Several functions perform string substitution; the full discussion is
+provided in the description of the @code{sub()} function, which comes
+towards the end since the list is presented in alphabetic order.
Those functions that are specific to @command{gawk} are marked with a
pound address@hidden (@samp{#}):}
@@ -14370,10 +14431,10 @@ in compatibility mode (@pxref{Options}).
@cindex @code{gensub()} function (@command{gawk})
Search the target string @var{target} for matches of the regular
expression @var{regexp}. If @var{how} is a string beginning with
address@hidden or @samp{G}, then replace all matches of @var{regexp} with
address@hidden or @samp{G} (short for ``global''), then replace all matches of
@var{regexp} with
@var{replacement}. Otherwise, @var{how} is treated as a number indicating
which match of @var{regexp} to replace. If no @var{target} is supplied,
-use @code{$0}. It returns the modified string is returned as the result
+use @code{$0}. It returns the modified string as the result
of the function and the original target string is @emph{not} changed.
@code{gensub()} is a general substitution function. It's purpose is
@@ -14412,7 +14473,7 @@ $ @kbd{echo a b c a b c |}
@print{} a b c AA b c
@end example
-In this case, @code{$0} is used as the default target string.
+In this case, @code{$0} is the default target string.
@code{gensub()} returns the new string as its result, which is
passed directly to @code{print} for printing.
@@ -14471,8 +14532,8 @@ If @var{find} is not found, @code{index()} returns zero.
@cindex @code{length()} function
Return the number of characters in @var{string}. If
@var{string} is a number, the length of the digit string representing
-that number is returned. For example, @code{length("abcde")} is 5. By
-contrast, @code{length(15 * 35)} works out to 3. In this example, 15 * 35 =
+that number is returned. For example, @code{length("abcde")} is five. By
+contrast, @code{length(15 * 35)} works out to three. In this example, 15 * 35 =
525, and 525 is then converted to the string @code{"525"}, which has
three characters.
@@ -14514,7 +14575,7 @@ warning about this.
@cindex common extensions, @code{length()} applied to an array
@cindex extensions, address@hidden @code{length()} applied to an array
@cindex differences between @command{gawk} and @command{awk}
-With @command{gawk} and several other @command{awk} implementations, when
supplied an
+With @command{gawk} and several other @command{awk} implementations, when
given an
array argument, the @code{length()} function returns the number of elements
in the array. @value{COMMONEXT}
This is less useful than it might seem at first, as the
@@ -14599,7 +14660,7 @@ Match of Melvin found at 1 in Melvin was here.
@end example
@cindex differences in @command{awk} and @command{gawk}, @code{match()}
function
-If @var{array} is present, it is cleared, and then the 0th element
+If @var{array} is present, it is cleared, and then the zeroth element
of @var{array} is set to the entire portion of @var{string}
matched by @var{regexp}. If @var{regexp} contains parentheses,
the integer-indexed elements of @var{array} are set to contain the
@@ -14631,7 +14692,7 @@ $ @kbd{echo foooobazbarrrrr |}
@end example
There may not be subscripts for the start and index for every parenthesized
-subexpressions, since they may not all have matched text; thus they
+subexpression, since they may not all have matched text; thus they
should be tested for with the @code{in} operator
(@pxref{Reference to Elements}).
@@ -14660,7 +14721,8 @@ between @address@hidden@var{i}]} and
@address@hidden@var{i}+1]}.
Any leading separator will be in @address@hidden
The @code{patsplit()} function splits strings into pieces in a
-manner similar to the way input lines are split into fields using @code{FPAT}.
+manner similar to the way input lines are split into fields using @code{FPAT}
+(@pxref{Splitting By Content}.
Before splitting the string, @code{patsplit()} deletes any previously existing
elements in the arrays @var{array} and @var{seps}.
@@ -14679,8 +14741,9 @@ and store the pieces in @var{array} and the separator
strings in the
@address@hidden, the second piece in @address@hidden, and so
forth. The string value of the third argument, @var{fieldsep}, is
a regexp describing where to split @var{string} (much as @code{FS} can
-be a regexp describing where to split input records). If
address@hidden is omitted, the value of @code{FS} is used.
+be a regexp describing where to split input records;
address@hidden Field Splitting}).
+If @var{fieldsep} is omitted, the value of @code{FS} is used.
@code{split()} returns the number of elements created.
@var{seps} is a @command{gawk} extension with @address@hidden@var{i}]}
being the separator string
@@ -14728,7 +14791,7 @@ the elements of
are separated by runs of whitespace.
Also as with input field-splitting, if @var{fieldsep} is the null string, each
individual character in the string is split into its own array element.
-(This latter is a @command{gawk}-specific extension.)
address@hidden
Note, however, that @code{RS} has no effect on the way @code{split()}
works. Even though @samp{RS = ""} causes newline to also be an input
@@ -14767,7 +14830,7 @@ pival = sprintf("pi = %.2f (approx.)", 22/7)
@end example
@noindent
-assigns the string @address@hidden"pi = 3.14 (approx.)"}} to the variable
@code{pival}.
+assigns the string @address@hidden = 3.14 (approx.)}} to the variable
@code{pival}.
@cindex @code{strtonum()} function (@command{gawk})
@item strtonum(@var{str}) #
@@ -14790,7 +14853,7 @@ you use the @option{--non-decimal-data} option, which
isn't recommended.
@xref{Nondecimal Data}, for more information.}
Note also that @code{strtonum()} uses the current locale's decimal point
-for recognizing numbers.
+for recognizing numbers (@pxref{Locales}).
@cindex differences in @command{awk} and @command{gawk}, @code{strtonum()}
function (@command{gawk})
@code{strtonum()} is a @command{gawk} extension; it is not available
@@ -14798,11 +14861,12 @@ in compatibility mode (@pxref{Options}).
@item sub(@var{regexp}, @var{replacement} @r{[}, @address@hidden)
@cindex @code{sub()} function
-It searches @var{target}, which is treated as a string, for the
+Search @var{target}, which is treated as a string, for the
leftmost, longest substring matched by the regular expression @var{regexp}.
Modify the entire string
by replacing the matched text with @var{replacement}.
The modified string becomes the new value of @var{target}.
+Return the number of substitutions made (zero or one).
The @var{regexp} argument may be either a regexp constant
(@code{/@dots{}/}) or a string constant (@code{"@dots{}"}).
@@ -14828,12 +14892,9 @@ sub(/at/, "ith", str)
@end example
@noindent
-sets @code{str} to @address@hidden"wither, water, everywhere"}}, by replacing
the
+sets @code{str} to @address@hidden, water, everywhere}}, by replacing the
leftmost longest occurrence of @samp{at} with @samp{ith}.
-The @code{sub()} function returns the number of substitutions made (either
-one or zero).
-
If the special character @samp{&} appears in @var{replacement}, it
stands for the precise substring that was matched by @var{regexp}. (If
the regexp can match more than one string, then this precise substring
@@ -14915,7 +14976,7 @@ in the string, counting from character @var{start}.
If @var{start} is less than one, @code{substr()} treats it as
if it was one. (POSIX doesn't specify what to do in this case:
-Unix @command{awk} acts this way, and therefore @command{gawk}
+Brian Kernighan's @command{awk} acts this way, and therefore @command{gawk}
does too.)
If @var{start} is greater than the number of characters
in the string, @code{substr()} returns the null string.
@@ -14942,8 +15003,8 @@ gsub(/xyz/, "pdq", substr($0, 5, 20)) # WRONG
@end example
@cindex portability, @code{substr()} function
-(Some commercial versions of @command{awk} do in fact let you use
address@hidden()} this way, but doing so is not portable.)
+(Some commercial versions of @command{awk} treat
address@hidden()} as assignable, but doing so is not portable.)
If you need to replace bits and pieces of a string, combine @code{substr()}
with string concatenation, in the following manner:
@@ -14996,9 +15057,9 @@ At both levels, @command{awk} looks for a defined set
of characters that
can come after a backslash. At the lexical level, it looks for the
escape sequences listed in @ref{Escape Sequences}.
Thus, for every @samp{\} that @command{awk} processes at the runtime
-level, type two backslashes at the lexical level.
+level, you must type two backslashes at the lexical level.
When a character that is not valid for an escape sequence follows the
address@hidden, Unix @command{awk} and @command{gawk} both simply remove the
initial
address@hidden, Brian Kernighan's @command{awk} and @command{gawk} both simply
remove the initial
@samp{\} and put the next character into the string. Thus, for
example, @code{"a\qb"} is treated as @code{"aqb"}.
@@ -15214,7 +15275,7 @@ by anything else is not special; the @samp{\} is placed
straight into the output
These rules are presented in @ref{table-posix-sub}.
@float Table,table-posix-sub
address@hidden rules for @code{sub()}}
address@hidden rules for @code{sub()} and @code{gsub()}}
@tex
\vbox{\bigskip
% This table has lots of &'s and \'s, so unspecialize them.
@@ -15407,8 +15468,7 @@ is to allow no argument at all. In this case, the
buffer for the
standard output is flushed. The second is to allow the null string
(@address@hidden""}}) as the argument. In this case, the buffers for
@emph{all} open output files and pipes are flushed.
-Current versions of the Brian Kernighan's @command{awk} also
-support these extensions.
+Brian Kernighan's @command{awk} also supports these extensions.
@c @cindex automatic warnings
@c @cindex warnings, automatic
@@ -15429,7 +15489,7 @@ In such a case, @code{fflush()} returns @minus{}1, as
well.
@cindex interacting with other programs
Execute the operating-system
command @var{command} and then return to the @command{awk} program.
-It returns @var{command}'s exit status as its value.
+Return @var{command}'s exit status.
For example, if the following fragment of code is put in your @command{awk}
program:
@@ -15652,7 +15712,8 @@ The @var{timestamp} is in the same format as the value
returned by the
@code{systime()} function. If no @var{timestamp} argument is supplied,
@command{gawk} uses the current time of day as the timestamp.
If no @var{format} argument is supplied, @code{strftime()} uses
-the value of @code{PROCINFO["strftime"]} as the format string.
+the value of @code{PROCINFO["strftime"]} as the format string
+(@pxref{Built-in Variables}).
The default string value is
@address@hidden"%a %b %e %H:%M:%S %Z %Y"}}. This format string produces
output that is equivalent to that of the @command{date} utility.
@@ -15854,11 +15915,11 @@ returned string or appears literally.}
@c @cindex locale, definition of
Informally, a @dfn{locale} is the geographic place in which a program
is meant to run. For example, a common way to abbreviate the date
-September 4, 1991 in the United States is ``9/4/91.''
-In many countries in Europe, however, it is abbreviated ``4.9.91.''
+September 4, 2012 in the United States is ``9/4/12.''
+In many countries in Europe, however, it is abbreviated ``4.9.12.''
Thus, the @samp{%x} specification in a @code{"US"} locale might produce
address@hidden/4/91}, while in a @code{"EUROPE"} locale, it might produce
address@hidden The ISO C standard defines a default @code{"C"}
address@hidden/4/12}, while in a @code{"EUROPE"} locale, it might produce
address@hidden The ISO C standard defines a default @code{"C"}
locale, which is an environment that is typical of what many C programmers
are used to.
@@ -16260,7 +16321,8 @@ results of the @code{compl()}, @code{lshift()}, and
@code{rshift()} functions.
@command{gawk} provides a single function that lets you distinguish
an array from a scalar variable. This is necessary for writing code
-that traverses every element of a multidimensional array.
+that traverses every element of a true multidimensional array
+(@pxref{Arrays of Arrays}).
@table @code
@cindex @code{isarray()} function (@command{gawk})
@@ -16363,7 +16425,7 @@ function @var{name}(@address@hidden@r{]})
@cindex functions, names of
@cindex namespace issues, functions
@noindent
address@hidden is the name of the function to define. A valid function
+Here, @var{name} is the name of the function to define. A valid function
name is like a valid variable name: a sequence of letters, digits, and
underscores that doesn't start with a digit.
Within a single @command{awk} program, any particular name can only be
@@ -16425,6 +16487,12 @@ can even call this function, either directly or by way
of another
function. When this happens, we say the function is @dfn{recursive}.
The act of a function calling itself is called @dfn{recursion}.
+All the built-in functions return a value to their caller.
+User-defined functions can do also, using the @code{return} statement,
+which is described in detail in @ref{Return Statement}.
+Many of the subsequent examples in this @value{SECTION} use
+the @code{return} statement.
+
@cindex common extensions, @code{func} keyword
@cindex extensions, address@hidden @code{func} keyword
@c @cindex @command{awk} language, POSIX version
@@ -16627,6 +16695,7 @@ function bar()
for (i = 0; i < 3; i++)
print "bar's i=" i
@}
+
function foo(j)
@{
i = j + 1
@@ -16654,7 +16723,6 @@ bar's i=0
bar's i=1
bar's i=2
foo's i=3
-foo's i=3
top's i=3
@end example
@@ -16668,6 +16736,7 @@ function bar( i)
for (i = 0; i < 3; i++)
print "bar's i=" i
@}
+
function foo(j, i)
@{
i = j + 1
@@ -16678,7 +16747,9 @@ function foo(j, i)
BEGIN @{
i = 10
+ print "top's i=" i
foo(0)
+ print "top's i=" i
@}
@end example
@@ -16686,11 +16757,11 @@ Running the corrected script produces the following:
@example
top's i=10
-bar's i=1
-foo's i=0
foo's i=1
-foo's i=2
+bar's i=0
bar's i=1
+bar's i=2
+foo's i=1
top's i=10
@end example
@@ -16820,7 +16891,8 @@ inside a user-defined function.
@subsection The @code{return} Statement
@cindex @code{return} address@hidden user-defined functions
-The body of a user-defined function can contain a @code{return} statement.
+As seen in several earlier examples,
+the body of a user-defined function can contain a @code{return} statement.
This statement returns control to the calling part of the @command{awk}
program. It
can also be used to return a value for use in the rest of the @command{awk}
program. It looks like this:
@@ -16844,7 +16916,7 @@ does @emph{not} warn you if you use the return value of
such a function.
Sometimes, you want to write a function for what it does, not for
what it returns. Such a function corresponds to a @code{void} function
-in C or to a @code{procedure} in Ada. Thus, it may be appropriate to not
+in C, C++ or Java, or to a @code{procedure} in Ada. Thus, it may be
appropriate to not
return any value; simply bear in mind that you should not be using the
return value of such a function.
@@ -16869,7 +16941,7 @@ variables @code{i} and @code{ret} are not intended to
be arguments;
while there is nothing to stop you from passing more than one argument
to @code{maxelt()}, the results would be strange. The extra space before
@code{i} in the function parameter list indicates that @code{i} and
address@hidden are not supposed to be arguments.
address@hidden are local variables.
You should follow this convention when defining functions.
The following program uses the @code{maxelt()} function. It loads an
@@ -16916,7 +16988,7 @@ in the array.
@command{awk} is a very fluid language.
It is possible that @command{awk} can't tell if an identifier
-represents a regular variable or an array until runtime.
+represents a scalar variable or an array until runtime.
Here is an annotated sample program:
@example
@@ -17032,7 +17104,7 @@ function average(first, last, sum, i)
return sum / (last - first + 1)
@}
-# sum --- return the average of the values in fields $first - $last
+# sum --- return the sum of the values in fields $first - $last
function sum(first, last, ret, i)
@{
@@ -17046,7 +17118,7 @@ function sum(first, last, ret, i)
@end example
These two functions expect to work on fields; thus the parameters
address@hidden and @code{last} indicate where in the fields to start.
address@hidden and @code{last} indicate where in the fields to start and end.
Otherwise they perform the expected computations and are not unusual.
@example
@@ -17312,7 +17384,7 @@ of programs and software systems became a common
practice.
@cindex internationalization, localization
@cindex @command{gawk}, internationalization and, See internationalization
@cindex internationalization, localization, @command{gawk} and
-Until recently, the ability to provide internationalization
+For many years, the ability to provide internationalization
was largely restricted to programs written in C and C++.
This @value{CHAPTER} describes the underlying library @command{gawk}
uses for internationalization, as well as how
@@ -17320,7 +17392,7 @@ uses for internationalization, as well as how
features available at the @command{awk} program level.
Having internationalization available at the @command{awk} level
gives software developers additional flexibility---they are no
-longer required to write in C or C++ when internationalization is
+longer forced to write in C or C++ when internationalization is
a requirement.
@menu
@@ -17358,8 +17430,8 @@ The facilities in GNU @code{gettext} focus on messages;
strings printed
by a program, either directly or via formatting with @code{printf} or
@code{sprintf()address@hidden some operating systems, the @command{gawk}
port doesn't support GNU @code{gettext}.
-As such, these features are not available
-if you are using one of those operating systems. Sorry.}
+Therefore, these features are not available
+if you are using one of those operating systems. Sorry.}
@cindex portability, @code{gettext} library and
When using GNU @code{gettext}, each application has its own
@@ -17531,7 +17603,7 @@ local language, and possibly other information as well.
@cindex @code{LC_TIME} locale category
@item LC_TIME
Time- and date-related information, such as 12- or 24-hour clock, month printed
-before or after day in a date, local month abbreviations, and so on.
+before or after the day in a date, local month abbreviations, and so on.
@cindex @code{LC_ALL} locale category
@item LC_ALL
@@ -17563,7 +17635,7 @@ String constants without a leading underscore are not
translated.
@cindex @code{dcgettext()} function (@command{gawk})
@item dcgettext(@var{string} @r{[}, @var{domain} @r{[}, @address@hidden)
-This built-in function returns the translation of @var{string} in
+Return the translation of @var{string} in
text domain @var{domain} for locale category @var{category}.
The default value for @var{domain} is the current value of @code{TEXTDOMAIN}.
The default value for @var{category} is @code{"LC_MESSAGES"}.
@@ -17589,7 +17661,7 @@ default arguments.
@cindex @code{dcngettext()} function (@command{gawk})
@item dcngettext(@var{string1}, @var{string2}, @var{number} @r{[},
@var{domain} @r{[}, @address@hidden)
-This built-in function returns the plural form used for @var{number} of the
+Return the plural form used for @var{number} of the
translation of @var{string1} and @var{string2} in text domain
@var{domain} for locale category @var{category}. @var{string1} is the
English singular variant of a message, and @var{string2} the English plural
@@ -17605,11 +17677,11 @@ The same remarks about argument order as for the
@code{dcgettext()} function app
@cindex files, message object, specifying directory of
@cindex @code{bindtextdomain()} function (@command{gawk})
@item bindtextdomain(@var{directory} @r{[}, @address@hidden)
-This built-in function allows you to specify the directory in which
+Change the directory in which
@code{gettext} looks for @file{.mo} files, in case they
will not or cannot be placed in the standard locations
(e.g., during testing).
-It returns the directory in which @var{domain} is ``bound.''
+Return the directory in which @var{domain} is ``bound.''
The default @var{domain} is the value of @code{TEXTDOMAIN}.
If @var{directory} is the null string (@code{""}), then
@@ -17739,7 +17811,7 @@ First, use the @option{--gen-pot} command-line option
to create
the initial @file{.pot} file:
@example
-$ gawk --gen-pot -f guide.awk > guide.pot
+$ @kbd{gawk --gen-pot -f guide.awk > guide.pot}
@end example
@cindex @code{xgettext} utility
@@ -18251,12 +18323,12 @@ to be using a temporary file with the same name.
@cindex @code{|} (vertical bar), @code{|&} operator (I/O)
@cindex vertical bar (@code{|}), @code{|&} operator (I/O)
@cindex @command{csh} utility, @code{|&} operator, comparison with
-It is possible to
+However, with @command{gawk}, it is possible to
open a @emph{two-way} pipe to another process. The second process is
termed a @dfn{coprocess}, since it runs in parallel with @command{gawk}.
-The two-way connection is created using the new @samp{|&} operator
+The two-way connection is created using the @samp{|&} operator
(borrowed from the Korn shell, @command{ksh}):@footnote{This is very
-different from the same operator in the C shell, @command{csh}.}
+different from the same operator in the C shell.}
@example
do @{
@@ -18304,7 +18376,7 @@ a coprocess, by supplying a second argument to the
@code{close()}
function of either @code{"to"} or @code{"from"}
(@pxref{Close Files And Pipes}).
These strings tell @command{gawk} to close the end of the pipe
-that sends data to the process or the end that reads from it,
+that sends data to the coprocess or the end that reads from it,
respectively.
@cindex @command{sort} utility, coprocesses and
@@ -18381,7 +18453,7 @@ using regular pipes.
@cindex files, @code{/inet6/@dots{}} (@command{gawk})
@cindex @code{EMISTERED}
@quotation
address@hidden:
address@hidden:@*
@ @ @ @ @i{A host is a host from coast to coast,@*
@ @ @ @ and no-one can talk to host that's close,@*
@ @ @ @ unless the host that isn't address@hidden
@@ -18611,7 +18683,8 @@ The program is printed in the order @code{BEGIN} rule,
pattern/action rules,
@code{ENDFILE} rule, @code{END} rule and functions, listed
alphabetically.
-Multiple @code{BEGIN} and @code{END} rules are merged together.
+Multiple @code{BEGIN} and @code{END} rules are merged together,
+as are multiple @code{BEGINFILE} and @code{ENDFILE} rules.
@cindex patterns, counts
@item
@@ -18691,8 +18764,8 @@ typed when you wrote it. This is because
@command{pgawk} creates the
profiled version by ``pretty printing'' its internal representation of
the program. The advantage to this is that @command{pgawk} can produce
a standard representation. The disadvantage is that all source-code
-comments are lost, as are the distinctions among multiple @code{BEGIN}
-and @code{END} rules. Also, things such as:
+comments are lost, as are the distinctions among multiple @code{BEGIN},
address@hidden, @code{BEGINFILE}, and @code{ENDFILE} rules. Also, things such
as:
@example
/foo/
@@ -18832,16 +18905,20 @@ freely use features that are @command{gawk}-specific.
Rewriting these programs for different implementations of @command{awk}
is pretty straightforward.
address@hidden @bullet
address@hidden
Diagnostic error messages are sent to @file{/dev/stderr}.
Use @samp{| "cat 1>&2"} instead of @samp{> "/dev/stderr"} if your system
does not have a @file{/dev/stderr}, or if you cannot use @command{gawk}.
address@hidden
A number of programs use @code{nextfile}
(@pxref{Nextfile Statement})
to skip any remaining input in the input file.
@ref{Nextfile Function},
shows you how to write a function that does the same thing.
address@hidden
@c 12/2000: Thanks to Nelson Beebe for pointing out the output issue.
@cindex case sensitivity, example programs
@cindex @code{IGNORECASE} variable, in example programs
@@ -18861,6 +18938,7 @@ beginning of the program:
@noindent
Also, verify that all regexp and string constants used in
comparisons use only lowercase letters.
address@hidden itemize
@menu
* Library Names:: How to best name private global variables in
@@ -19132,11 +19210,11 @@ provides an implementation for other versions of
@command{awk}:
@example
@c file eg/lib/strtonum.awk
-# strtonum --- convert string to number
+# mystrtonum --- convert string to number
+
@c endfile
@ignore
@c file eg/lib/strtonum.awk
-
#
# Arnold Robbins, arnold@@skeeve.com, Public Domain
# February, 2004
@@ -19200,7 +19278,7 @@ function mystrtonum(str, ret, chars, n, i, k, c)
The function first looks for C-style octal numbers (base 8).
If the input string matches a regular expression describing octal
-numbers, then @code{mystrtonum} loops through each character in the
+numbers, then @code{mystrtonum()} loops through each character in the
string. It sets @code{k} to the index in @code{"01234567"} of the current
octal digit. Since the return value is one-based, the @samp{k--}
adjusts @code{k} so it can be used in computing the return value.
@@ -19210,7 +19288,7 @@ hexadecimal value, which starts with @samp{0x} or
@samp{0X}.
The use of @code{tolower()} simplifies the computation for finding
the correct numeric value for each hexadecimal digit.
-Finally, if the string matches the (rather complicated) regex for a
+Finally, if the string matches the (rather complicated) regexp for a
regular decimal integer or floating-point number, the computation
@samp{ret = str + 0} lets @command{awk} convert the value to a
number.
@@ -19368,7 +19446,7 @@ to naive expectations. In unbiased rounding, @samp{.5}
rounds to even,
rather than always up, so 1.5 rounds to 2 but 4.5 rounds to 4. This means
that if you are using a format that does rounding (e.g., @code{"%.0f"}),
you should check what your system does. The following function does
-traditional rounding; it might be useful if your awk's @code{printf}
+traditional rounding; it might be useful if your @command{awk}'s @code{printf}
does unbiased rounding:
@cindex @code{round()} user-defined function
@@ -19538,7 +19616,7 @@ Although an
defines characters that use the values from 0 to address@hidden
has been extended in many countries to use the values from 128 to 255
for country-specific characters. If your system uses these extensions,
-you can simplify @code{_ord_init} to simply loop from 0 to 255.}
+you can simplify @code{_ord_init} to loop from 0 to 255.}
In the now distant past,
at least one minicomputer manufacturer
@c Pr1me, blech
@@ -20278,7 +20356,7 @@ main(int argc, char *argv[])
@}
@end example
-As a side point, @command{gawk} actually uses the GNU @code{getopt_long}
+As a side point, @command{gawk} actually uses the GNU @code{getopt_long()}
function to process both normal and GNU-style long options
(@pxref{Options}).
@@ -20327,7 +20405,7 @@ The discussion that follows walks through the code a
bit at a time:
@c endfile
@end example
-The function starts out with
+The function starts out with comments presenting
a list of the global variables it uses,
what the return values are, what they mean, and any global variables that
are ``private'' to this library function. Such documentation is essential
@@ -20351,7 +20429,7 @@ function getopt(argc, argv, options, thisopt, i)
_opti = 0
return -1
@end group
- @} else if (argv[Optind] !~ /^-[^: \t\n\f\r\v\b]/) @{
+ @} else if (argv[Optind] !~ /^-[^:[:space:]]/) @{
_opti = 0
return -1
@}
@@ -20364,8 +20442,8 @@ does not begin with a @samp{-}. @code{Optind} is used
to step through
the array of command-line arguments; it retains its value across calls
to @code{getopt()}, because it is a global variable.
-The regular expression that is used, @address@hidden/^-[^: \t\n\f\r\v\b]/}}, is
-perhaps a bit of overkill; it checks for a @samp{-} followed by anything
+The regular expression that is used, @address@hidden/^-[^:[:space:]/}},
+checks for a @samp{-} followed by anything
that is not whitespace and not a colon.
If the current command-line argument does not match this pattern,
it is not an option, and it ends option processing. Continuing on:
@@ -20747,12 +20825,11 @@ function _pw_init( oldfs, oldrs, olddol0, pwcat,
using_fw, using_fpat)
close(pwcat)
_pw_count = 0
_pw_inited = 1
+ FS = oldfs
if (using_fw)
FIELDWIDTHS = FIELDWIDTHS
else if (using_fpat)
FPAT = FPAT
- else
- FS = oldfs
RS = oldrs
$0 = olddol0
@}
@@ -20769,8 +20846,8 @@ The function @code{_pw_init()} keeps three copies of
the user information
in three associative arrays. The arrays are indexed by username
(@code{_pw_byname}), by user ID number (@code{_pw_byuid}), and by order of
occurrence (@code{_pw_bycount}).
-The variable @code{_pw_inited} is used for efficiency; @code{_pw_init()}
-needs only to be called once.
+The variable @code{_pw_inited} is used for efficiency, since @code{_pw_init()}
+needs to be called only once.
@cindex @code{getline} command, @code{_pw_init()} function
Because this function uses @code{getline} to read information from
@@ -21111,12 +21188,11 @@ function _gr_init( oldfs, oldrs, olddol0, grcat,
close(grcat)
_gr_count = 0
_gr_inited++
+ FS = oldfs
if (using_fw)
FIELDWIDTHS = FIELDWIDTHS
else if (using_fpat)
FPAT = FPAT
- else
- FS = oldfs
RS = oldrs
$0 = olddol0
@}
@@ -21267,7 +21343,7 @@ an array may be either a scalar, or another array. The
@code{isarray()} function (@pxref{Type Functions})
lets you distinguish an array
from a scalar.
-The following function, @code{walk_array}, recursively traverses
+The following function, @code{walk_array()}, recursively traverses
an array, printing each element's indices and value.
You call it with the array and a string representing the name
of the array:
@@ -21292,7 +21368,7 @@ It works by looping over each element of the array. If
any given
element is itself an array, the function calls itself recursively,
passing the subarray and a new string representing the current index.
Otherwise, the function simply prints the element's name, index, and value.
-Here is a main program to demonstrate
+Here is a main program to demonstrate:
@example
BEGIN @{
@@ -21404,7 +21480,9 @@ because the algorithms can be very clearly expressed,
and the code is usually
very concise and simple. This is true because @command{awk} does so much for
you.
It should be noted that these programs are not necessarily intended to
-replace the installed versions on your system. Instead, their
+replace the installed versions on your system.
+Nor may all of these programs be fully compliant with the most recent
+POSIX standard. This is not a problem; their
purpose is to illustrate @command{awk} language programming for ``real world''
tasks.
@@ -23078,20 +23156,20 @@ BEGIN \
switch (ARGC) @{
case 5:
delay = ARGV[4] + 0
- # fall through
+ # fall through
case 4:
count = ARGV[3] + 0
- # fall through
+ # fall through
case 3:
message = ARGV[2]
- break
+ break
default:
if (ARGV[1] !~ /[[:digit:]]?[[:digit:]]:[[:digit:]][[:digit:]]/) @{
print usage1 > "/dev/stderr"
print usage2 > "/dev/stderr"
exit 1
- @}
- break
+ @}
+ break
@}
# set defaults for once we reach the desired time
@@ -25329,7 +25407,7 @@ execution of the program than we saw in our earlier
example:
@itemx @dots{}
@itemx @code{end}
Set a list of commands to be executed upon stopping at
-a breakpoint or watchpoint. @var{n} is the breakpoint or watchpoint
number.
+a breakpoint or watchpoint. @var{n} is the breakpoint or watchpoint number.
Without a number, the last one set is used. The actual commands follow,
starting on the next line, and terminated by the @code{end} command.
If the command @code{silent} is in the list, the usual messages about
@@ -25455,7 +25533,7 @@ dgawk> @kbd{display x}
displays the assigned item number, the variable name and its current value.
If the display variable refers to a function parameter, it is silently
deleted from the list as soon as the execution reaches a context where
-no such variable of the given name exists.
+no such variable of the given name exists.
Without argument, @code{display} displays the current values of
items on the list.
@@ -25742,7 +25820,7 @@ partial dump of Davide Brini's obfuscated code
@smallexample
dgawk> @kbd{dump}
address@hidden # BEGIN
address@hidden # BEGIN
@print{}
@print{} [ 2:0x89faef4] Op_rule : [in_rule = BEGIN]
[source_file = brini.awk]
@print{} [ 3:0x89fa428] Op_push_i : "~" [PERM|STRING|STRCUR]
@@ -26857,7 +26935,7 @@ but when retrieving distributions, you should get the
version with the highest
version, release, and patch level. (Note, however, that patch levels greater
than
or equal to 70 denote ``beta'' or nonproduction software; you might not want
to retrieve such a version unless you don't mind experimenting.)
-If you are not on a Unix system, you need to make other arrangements
+If you are not on a Unix or GNU/Linux system, you need to make other
arrangements
for getting and extracting the @command{gawk} distribution. You should consult
a local expert.
@@ -27715,7 +27793,7 @@ to the original shell-style interface (see the help
entry for details).
One side effect of dual command-line parsing is that if there is only a
single parameter (as in the quoted string program above), the command
becomes ambiguous. To work around this, the normally optional @option{--}
-flag is required to force Unix style rather than @code{DCL} parsing. If any
+flag is required to force Unix-style parsing rather than @code{DCL} parsing.
If any
other dash-type options (or multiple parameters such as @value{DF}s to
process) are present, there is no ambiguity and @option{--} can be omitted.
@@ -31840,7 +31918,7 @@ Consistency issues:
Use @code{do}, and not @address@hidden, except where
actually discussing the do-while.
Use "versus" in text and "vs." in index entries
- Use @code{"C"} for the C locale, not ``C''.
+ Use @code{"C"} for the C locale, not ``C'' or @samp{C}.
The words "a", "and", "as", "between", "for", "from", "in", "of",
"on", "that", "the", "to", "with", and "without",
should not be capitalized in @chapter, @section etc.
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=a3e92aab353cabae2743b78de1f12fe94e66a339
commit a3e92aab353cabae2743b78de1f12fe94e66a339
Author: Arnold D. Robbins <address@hidden>
Date: Fri Mar 25 13:23:14 2011 +0200
Some cleanups after code review of main.c.
diff --git a/ChangeLog b/ChangeLog
index 5d9d9c2..75010a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Fri Mar 25 13:15:36 2011 Arnold D. Robbins <address@hidden>
+
+ * awk.h: Move libsigsegv portability checks to here from main.c.
+ * eval.c (fcall_list, fcall_count): Move definitions to here
+ from main.c.
+ * io.c (do_find_source): Check against NULL in for loop.
+ * main.c: Lots of cleanup. Move some things out to other files,
+ add comments to some variable definitions.
+ (enum asgntype): To assign_type
+ (main): Remove decls of getopt variables, clean up comments.
+ Use emalloc and efree for libsigsegv stack. Remove check for SCCS
+ leading magic characters.
+ (add_preassign): Change allocassigns to alloc_assigns.
+ (init_locale): Change strdup calls to estrdup.
+ (save_argv): Make the routine static.
+ * version.in (version_string): Remove leading 4 SCCS magic characters.
+
Wed Mar 2 08:15:02 2011 John Haque <address@hidden>
* array.c (asort_actual): Handle the case when the same array
@@ -12,15 +29,15 @@ Sun Feb 27 08:01:04 2011 Arnold D. Robbins
<address@hidden>
Sat Feb 26 21:54:07 2011 Arnold D. Robbins <address@hidden>
- * eval (sorted_in): Revise text of lint warning.
+ * eval.c (sorted_in): Revise text of lint warning.
Fri Feb 25 17:34:14 2011 Pat Rankin <address@hidden>
- * eval (sorted_in): Remove incorrect unref() call.
+ * eval.c (sorted_in): Remove incorrect unref() call.
Wed Feb 23 21:48:20 2011 Arnold D. Robbins <address@hidden>
- * main (main): Free extra_stack, to make valgrind happier.
+ * main.c (main): Free extra_stack, to make valgrind happier.
Tue Feb 22 12:04:09 2011 Arnold D. Robbins <address@hidden>
diff --git a/TODO b/TODO
index d40a50b..ebf7912 100644
--- a/TODO
+++ b/TODO
@@ -24,7 +24,6 @@ floatcomp.c
floatmagic.h
gawkmisc.c
io.c
-main.c
profile.c
protos.h
@@ -40,6 +39,7 @@ replace.c
msg.c
hard-locale.h
custom.h
+main.c
------
diff --git a/awk.h b/awk.h
index 18e348c..a56b2b2 100644
--- a/awk.h
+++ b/awk.h
@@ -185,6 +185,15 @@ extern void *memset_ulong(void *dest, int val, unsigned
long l);
#define memset memset_ulong
#endif
+#ifdef HAVE_LIBSIGSEGV
+#include <sigsegv.h>
+#else
+typedef void *stackoverflow_context_t;
+#define sigsegv_install_handler(catchsegv) signal(SIGSEGV, catchsig)
+/* define as 0 rather than empty so that (void) cast on it works */
+#define stackoverflow_install_handler(catchstackoverflow, extra_stack,
STACK_SIZE) 0
+#endif
+
/* use this as lintwarn("...")
this is a hack but it gives us the right semantics */
#define lintwarn (*(set_loc(__FILE__, __LINE__),lintfunc))
diff --git a/eval.c b/eval.c
index 1eb6d0b..5b3b2f4 100644
--- a/eval.c
+++ b/eval.c
@@ -29,8 +29,8 @@ extern void after_beginfile(IOBUF **curfile);
extern double pow(double x, double y);
extern double modf(double x, double *yp);
extern double fmod(double x, double y);
-extern NODE **fcall_list;
-extern long fcall_count;
+NODE **fcall_list;
+long fcall_count;
IOBUF *curfile = NULL; /* current data file */
int exiting = FALSE;
diff --git a/io.c b/io.c
index fc02bef..c9d421b 100644
--- a/io.c
+++ b/io.c
@@ -2421,7 +2421,7 @@ do_find_source(const char *src, struct stat *stb, int
*errcode)
init_awkpath(getenv("AWKPATH"));
emalloc(path, char *, max_pathlen + strlen(src) + 1, "do_find_source");
- for (i = 0; awkpath[i]; i++) {
+ for (i = 0; awkpath[i] != NULL; i++) {
if (STREQ(awkpath[i], "./") || STREQ(awkpath[i], ".")) {
*path = '\0';
} else
diff --git a/main.c b/main.c
index 64d9725..b1773d2 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
/*
- * main.c -- Expression tree constructors and main program for gawk.
+ * main.c -- Code generator and main program for gawk.
*/
/*
@@ -32,14 +32,6 @@
#ifdef HAVE_MCHECK_H
#include <mcheck.h>
#endif
-#ifdef HAVE_LIBSIGSEGV
-#include <sigsegv.h>
-#else
-typedef void *stackoverflow_context_t;
-#define sigsegv_install_handler(catchsegv) signal(SIGSEGV, catchsig)
-/* define as 0 rather than empty so that (void) cast on it works */
-#define stackoverflow_install_handler(catchstackoverflow, extra_stack,
STACK_SIZE) 0
-#endif
#define DEFAULT_PROFILE "awkprof.out" /* where to put profile
*/
#define DEFAULT_VARFILE "awkvars.out" /* where to put vars */
@@ -68,10 +60,11 @@ static void save_argv(int, char **);
/* These nodes store all the special variables AWK uses */
NODE *ARGC_node, *ARGIND_node, *ARGV_node, *BINMODE_node, *CONVFMT_node;
-NODE *ENVIRON_node, *ERRNO_node, *FIELDWIDTHS_node, *FILENAME_node, *FNR_node;
-NODE *FS_node, *IGNORECASE_node, *NF_node, *NR_node, *OFMT_node, *OFS_node;
-NODE *ORS_node, *PROCINFO_node, *RLENGTH_node, *RSTART_node, *RS_node;
-NODE *RT_node, *SUBSEP_node, *LINT_node, *TEXTDOMAIN_node, *FPAT_node;
+NODE *ENVIRON_node, *ERRNO_node, *FIELDWIDTHS_node, *FILENAME_node;
+NODE *FNR_node, *FPAT_node, *FS_node, *IGNORECASE_node, *LINT_node;
+NODE *NF_node, *NR_node, *OFMT_node, *OFS_node, *ORS_node, *PROCINFO_node;
+NODE *RLENGTH_node, *RSTART_node, *RS_node, *RT_node, *SUBSEP_node;
+NODE *TEXTDOMAIN_node;
NODE *_r; /* used as temporary in stack macros */
@@ -106,15 +99,12 @@ const char *myname;
/* A block of AWK code to be run */
INSTRUCTION *code_block = NULL;
-char **d_argv;
-extern NODE **args_array;
-INSTRUCTION *rule_list; /* list of rules and functions with
first
- * and last instruction (source_line) information;
- * used for profiling and debugging.
- */
-
-NODE **fcall_list = NULL;
-long fcall_count = 0;
+char **d_argv; /* saved argv for debugger restarting */
+/*
+ * List of rules and functions with first and last instruction (source_line)
+ * information; used for profiling and debugging.
+ */
+INSTRUCTION *rule_list;
int exit_val = EXIT_SUCCESS; /* exit value */
@@ -128,16 +118,16 @@ SRCFILE *srcfiles; /* source files */
* structure to remember variable pre-assignments
*/
struct pre_assign {
- enum asgntype { PRE_ASSIGN = 1, PRE_ASSIGN_FS } type;
+ enum assign_type { PRE_ASSIGN = 1, PRE_ASSIGN_FS } type;
char *val;
};
static struct pre_assign *preassigns = NULL; /* requested via -v or -F */
-static long numassigns = -1; /* how many of them */
+static long numassigns = -1; /* how many of them */
static int disallow_var_assigns = FALSE; /* true for --exec */
-static void add_preassign(enum asgntype type, char *val);
+static void add_preassign(enum assign_type type, char *val);
#undef do_lint
#undef do_lint_old
@@ -156,17 +146,18 @@ int do_tidy_mem = FALSE; /* release vars when done */
int do_optimize = TRUE; /* apply default optimizations */
int do_binary = FALSE; /* hands off my data! */
int do_sandbox = FALSE; /* sandbox mode - disable 'system' function &
redirections */
-
int use_lc_numeric = FALSE; /* obey locale for decimal point */
+
#ifdef MBS_SUPPORT
int gawk_mb_cur_max; /* MB_CUR_MAX value, see comment in main() */
#else
const int gawk_mb_cur_max = 1;
#endif
-FILE *output_fp;
+FILE *output_fp; /* default output for debugger */
int output_is_tty = FALSE; /* control flushing of output */
+/* default format for strftime(), available via PROCINFO */
const char def_strftime_format[] = "%a %b %e %H:%M:%S %Z %Y";
extern const char *version_string;
@@ -180,6 +171,7 @@ void (*lintfunc)(const char *mesg, ...) = warning;
/*
* Note: reserve -D for future use, to merge dgawk into gawk.
+ * Note: reserve -l for future use, for xgawk's -l option.
*/
static const struct option optab[] = {
{ "traditional", no_argument, & do_traditional,
1 },
@@ -221,8 +213,6 @@ static const struct option optab[] = {
int
main(int argc, char **argv)
{
- int c;
- char *scan, *src;
/*
* The + on the front tells GNU getopt not to rearrange argv.
* Note: reserve -D for future use, to merge dgawk into gawk.
@@ -231,15 +221,13 @@ main(int argc, char **argv)
const char *optlist = "+F:f:v:W;m:bcCd::e:E:gh:L:nNOp::PrR:StVY";
int stopped_early = FALSE;
int old_optind;
- extern int optind;
- extern int opterr;
- extern char *optarg;
int i;
+ int c;
+ char *scan, *src;
char *extra_stack;
/* do these checks early */
- if (getenv("TIDYMEM") != NULL)
- do_tidy_mem = TRUE;
+ do_tidy_mem = (getenv("TIDYMEM") != NULL);
#ifdef HAVE_MCHECK_H
#ifdef HAVE_MTRACE
@@ -302,19 +290,13 @@ main(int argc, char **argv)
(void) sigsegv_install_handler(catchsegv);
#define STACK_SIZE (16*1024)
- extra_stack = malloc(STACK_SIZE);
- if (extra_stack == NULL)
- fatal(_("out of memory"));
+ emalloc(extra_stack, char *, STACK_SIZE, "main");
(void) stackoverflow_install_handler(catchstackoverflow, extra_stack,
STACK_SIZE);
#undef STACK_SIZE
myname = gawk_name(argv[0]);
os_arg_fixup(&argc, &argv); /* emulate redirection, expand wildcards */
- /* remove sccs gunk */
- if (strncmp(version_string, "@(#)", 4) == 0)
- version_string += 4;
-
if (argc < 2)
usage(EXIT_FAILURE, stderr);
@@ -327,7 +309,7 @@ main(int argc, char **argv)
/* we do error messages ourselves on invalid options */
opterr = FALSE;
- /* copy argv before getopt gets to it; used to restart debugger */
+ /* copy argv before getopt gets to it; used to restart the debugger */
save_argv(argc, argv);
/* initialize global (main) execution context */
@@ -350,9 +332,9 @@ main(int argc, char **argv)
/* fall through */
case 'f':
/*
- * a la MKS awk, allow multiple -f options.
- * this makes function libraries real easy.
- * most of the magic is in the scanner.
+ * Allow multiple -f options.
+ * This makes function libraries real easy.
+ * Most of the magic is in the scanner.
*
* The following is to allow for whitespace at the end
* of a #! /bin/gawk line in an executable file
@@ -374,11 +356,11 @@ main(int argc, char **argv)
case 'm':
/*
- * Research awk extension.
+ * BWK awk extension.
* -mf nnn set # fields, gawk ignores
* -mr nnn set record length, ditto
*
- * As of at least 10/2007, Research awk also ignores it.
+ * As of at least 10/2007, BWK awk also ignores it.
*/
if (do_lint)
lintwarn(_("`-m[fr]' option irrelevant in
gawk"));
@@ -416,11 +398,12 @@ main(int argc, char **argv)
break;
case 'h':
- usage(EXIT_SUCCESS, stdout); /* per coding stds */
+ /* write usage to stdout, per GNU coding stds */
+ usage(EXIT_SUCCESS, stdout);
break;
- case 'L':
#ifndef NO_LINT
+ case 'L':
do_lint = LINT_ALL;
if (optarg != NULL) {
if (strcmp(optarg, "fatal") == 0)
@@ -428,12 +411,16 @@ main(int argc, char **argv)
else if (strcmp(optarg, "invalid") == 0)
do_lint = LINT_INVALID;
}
-#endif
break;
case 't':
do_lint_old = TRUE;
break;
+#else
+ case 'L':
+ case 't':
+ break;
+#endif
case 'n':
do_non_decimal_data = TRUE;
@@ -502,10 +489,10 @@ main(int argc, char **argv)
case '?':
default:
/*
- * New behavior. If not posix, an unrecognized
- * option stops argument processing so that it can
- * go into ARGV for the awk program to see. This
- * makes use of ``#! /bin/gawk -f'' easier.
+ * If not posix, an unrecognized option stops argument
+ * processing so that it can go into ARGV for the awk
+ * program to see. This makes use of ``#! /bin/gawk -f''
+ * easier.
*
* However, it's never simple. If optopt is set,
* an option that requires an argument didn't get the
@@ -523,7 +510,7 @@ main(int argc, char **argv)
stopped_early = TRUE;
goto out;
} else if (optopt != '\0') {
- /* Use 1003.2 required message format */
+ /* Use POSIX required message format */
fprintf(stderr,
_("%s: option requires an argument --
%c\n"),
myname, optopt);
@@ -707,7 +694,7 @@ out:
/* keep valgrind happier */
if (extra_stack)
- free(extra_stack);
+ efree(extra_stack);
exit(exit_val); /* more portable */
return exit_val; /* to suppress warnings */
@@ -716,9 +703,9 @@ out:
/* add_preassign --- add one element to preassigns */
static void
-add_preassign(enum asgntype type, char *val)
+add_preassign(enum assign_type type, char *val)
{
- static long allocassigns; /* for how many is allocated */
+ static long alloc_assigns; /* for how many are allocated */
#define INIT_SRC 4
@@ -727,11 +714,11 @@ add_preassign(enum asgntype type, char *val)
if (preassigns == NULL) {
emalloc(preassigns, struct pre_assign *,
INIT_SRC * sizeof(struct pre_assign), "add_preassign");
- allocassigns = INIT_SRC;
- } else if (numassigns >= allocassigns) {
- allocassigns *= 2;
+ alloc_assigns = INIT_SRC;
+ } else if (numassigns >= alloc_assigns) {
+ alloc_assigns *= 2;
erealloc(preassigns, struct pre_assign *,
- allocassigns * sizeof(struct pre_assign),
"add_preassigns");
+ alloc_assigns * sizeof(struct pre_assign),
"add_preassigns");
}
preassigns[numassigns].type = type;
preassigns[numassigns].val = estrdup(val, strlen(val));
@@ -744,7 +731,6 @@ add_preassign(enum asgntype type, char *val)
static void
usage(int exitval, FILE *fp)
{
-
/* Not factoring out common stuff makes it easier to translate. */
fprintf(fp, _("Usage: %s [POSIX or GNU style options] -f progfile [--]
file ...\n"),
myname);
@@ -833,11 +819,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the\n\
GNU General Public License for more details.\n\
\n");
static const char blurb_part3[] =
-/*
- N_("You should have received a copy of the GNU General Public
License\n\
-along with this program; if not, write to the Free Software\n\
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.\n");
-*/
N_("You should have received a copy of the GNU General Public
License\n\
along with this program. If not, see http://www.gnu.org/licenses/.\n");
@@ -897,14 +878,13 @@ init_args(int argc0, int argc, const char *argv0, char
**argv)
unref(*aptr);
*aptr = make_string(argv0, strlen(argv0));
(*aptr)->flags |= MAYBE_NUM;
- for (i = argc0, j = 1; i < argc; i++) {
+ for (i = argc0, j = 1; i < argc; i++, j++) {
tmp = make_number((AWKNUM) j);
aptr = assoc_lookup(ARGV_node, tmp, FALSE);
unref(tmp);
unref(*aptr);
*aptr = make_string(argv[i], strlen(argv[i]));
(*aptr)->flags |= MAYBE_NUM;
- j++;
}
ARGC_node = install_symbol(estrdup("ARGC", 4),
@@ -970,11 +950,12 @@ init_vars()
const struct varinit *vp;
NODE *n;
- for (vp = varinit; vp->name; vp++) {
+ for (vp = varinit; vp->name != NULL; vp++) {
if ((vp->flags & NO_INSTALL) != 0)
continue;
- n = mk_symbol(Node_var, vp->strval == NULL ?
make_number(vp->numval)
- :
make_string(vp->strval, strlen(vp->strval)));
+ n = mk_symbol(Node_var, vp->strval == NULL
+ ? make_number(vp->numval)
+ : make_string(vp->strval, strlen(vp->strval)));
n->var_assign = (Func_ptr) vp->assign;
n->var_update = (Func_ptr) vp->update;
@@ -1003,7 +984,7 @@ load_environ()
NODE *tmp;
ENVIRON_node = install_symbol(estrdup("ENVIRON", 7),
- mk_symbol(Node_var_array, (NODE
*) NULL));
+ mk_symbol(Node_var_array, (NODE *) NULL));
for (i = 0; environ[i] != NULL; i++) {
static char nullstr[] = "";
@@ -1058,7 +1039,7 @@ load_procinfo()
AWKNUM value;
PROCINFO_node = install_symbol(estrdup("PROCINFO", 8),
- mk_symbol(Node_var_array, (NODE
*) NULL));
+ mk_symbol(Node_var_array, (NODE *) NULL));
update_PROCINFO_str("version", VERSION);
update_PROCINFO_str("strftime", def_strftime_format);
@@ -1134,7 +1115,7 @@ is_std_var(const char *var)
{
const struct varinit *vp;
- for (vp = varinit; vp->name; vp++) {
+ for (vp = varinit; vp->name != NULL; vp++) {
if (strcmp(vp->name, var) == 0) {
if ((do_traditional || do_posix) && (vp->flags &
NON_STANDARD) != 0)
return FALSE;
@@ -1194,7 +1175,7 @@ arg_assign(char *arg, int initing)
arg, arg, cp);
} else {
/*
- * Recent versions of nawk expand escapes inside assignments.
+ * BWK awk expands escapes inside assignments.
* This makes sense, so we do it too.
*/
it = make_str_node(cp, strlen(cp), SCAN);
@@ -1401,32 +1382,36 @@ init_locale(struct lconv *l)
t = localeconv();
*l = *t;
- l->thousands_sep = strdup(t->thousands_sep);
- l->decimal_point = strdup(t->decimal_point);
- l->grouping = strdup(t->grouping);
- l->int_curr_symbol = strdup(t->int_curr_symbol);
- l->currency_symbol = strdup(t->currency_symbol);
- l->mon_decimal_point = strdup(t->mon_decimal_point);
- l->mon_thousands_sep = strdup(t->mon_thousands_sep);
- l->mon_grouping = strdup(t->mon_grouping);
- l->positive_sign = strdup(t->positive_sign);
- l->negative_sign = strdup(t->negative_sign);
+ l->thousands_sep = estrdup(t->thousands_sep, strlen(t->thousands_sep));
+ l->decimal_point = estrdup(t->decimal_point, strlen(t->decimal_point));
+ l->grouping = estrdup(t->grouping, strlen(t->grouping));
+ l->int_curr_symbol = estrdup(t->int_curr_symbol,
strlen(t->int_curr_symbol));
+ l->currency_symbol = estrdup(t->currency_symbol,
strlen(t->currency_symbol));
+ l->mon_decimal_point = estrdup(t->mon_decimal_point,
strlen(t->mon_decimal_point));
+ l->mon_thousands_sep = estrdup(t->mon_thousands_sep,
strlen(t->mon_thousands_sep));
+ l->mon_grouping = estrdup(t->mon_grouping, strlen(t->mon_grouping));
+ l->positive_sign = estrdup(t->positive_sign, strlen(t->positive_sign));
+ l->negative_sign = estrdup(t->negative_sign, strlen(t->negative_sign));
}
#endif /* LOCALE_H */
/* save_argv --- save argv array */
-void
+static void
save_argv(int argc, char **argv)
{
int i;
+
emalloc(d_argv, char **, (argc + 1) * sizeof(char *), "save_argv");
for (i = 0; i < argc; i++)
d_argv[i] = estrdup(argv[i], strlen(argv[i]));
d_argv[argc] = NULL;
}
-/* update_global_values --- make sure the symbol table has correct values */
+/*
+ * update_global_values --- make sure the symbol table has correct values.
+ * Called from the grammar before dumping values.
+ */
void
update_global_values()
diff --git a/po/ChangeLog b/po/ChangeLog
index 7335180..c8020b7 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,7 @@
+Mon Mar 21 20:40:28 2011 Arnold D. Robbins <address@hidden>
+
+ * LINGUAS: Sorted.
+
Fri Mar 18 12:01:21 2011 Arnold D. Robbins <address@hidden>
* fi.po, fi.gmo: New files.
diff --git a/po/LINGUAS b/po/LINGUAS
index f0115e1..f275198 100644
--- a/po/LINGUAS
+++ b/po/LINGUAS
@@ -1,21 +1,21 @@
+ast
+ca
+da
+de
es
fi
fr
+ga
he
id
it
-sv
-tr
-de
-da
-pt_BR
-ca
-pl
ja
-ro
nl
+pl
+pt_BR
+ro
rw
-ga
+sv
+tr
vi
zh_CN
-ast
diff --git a/po/it.po b/po/it.po
index 8998017..84ef41d 100644
--- a/po/it.po
+++ b/po/it.po
@@ -4,10 +4,10 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: gawk 3.1.80\n"
+"Project-Id-Version: gawk 3.1.81\n"
"Report-Msgid-Bugs-To: address@hidden"
"POT-Creation-Date: 2011-03-18 12:00+0200\n"
-"PO-Revision-Date: 2011-02-11 14:52+0100\n"
+"PO-Revision-Date: 2011-03-19 16:52+0100\n"
"Last-Translator: Antonio Colombo <address@hidden>\n"
"Language-Team: Italian <address@hidden>\n"
"Language: it\n"
@@ -479,9 +479,8 @@ msgid "function `%s' called but never defined"
msgstr "funzione `%s' chiamata ma mai definita"
#: awkgram.y:4373
-#, fuzzy, c-format
msgid "function `%s' defined but never called directly"
-msgstr "funzione `%s' definita ma mai chiamata"
+msgstr "funzione `%s' definita ma mai chiamata direttamente"
#: awkgram.y:4405
#, c-format
@@ -887,13 +886,12 @@ msgid "turning off `--lint' due to assignment to `LINT'"
msgstr "disabilito `--lint' a causa di assegnamento a `LINT'"
#: eval.c:1247
-#, fuzzy
msgid "sorted array traversal is a gawk extension"
-msgstr "`delete array' è un'estensione gawk"
+msgstr "`sorted array traversal' è un'estensione gawk"
#: eval.c:1291
msgid "`PROCINFO[\"sorted_in\"]' value is not recognized"
-msgstr ""
+msgstr "`PROCINFO[\"sorted_in\"]' valore non riconosciuto"
#: eval.c:1373 eval.c:1923
#, c-format
@@ -1096,7 +1094,7 @@ msgstr "split: il secondo argomento non
#: field.c:962
msgid "split: can not use the same array for second and fourth args"
-msgstr ""
+msgstr "split: non si può usare lo stesso vettore come secondo e quarto
argomento"
#: field.c:990
msgid "split: null string for third arg is a gawk extension"
@@ -1116,7 +1114,7 @@ msgstr "patsplit: il terzo argomento non pu
#: field.c:1059
msgid "patsplit: can not use the same array for second and fourth args"
-msgstr ""
+msgstr "patsplit: non si può usare lo stesso vettore come secondo e quarto
argomento"
#: field.c:1089
msgid "`FIELDWIDTHS' is a gawk extension"
@@ -1944,11 +1942,11 @@ msgstr "Riferimento indietro non valido"
#: regcomp.c:153
msgid "Unmatched [ or [^"
-msgstr "[ or [^ non chiusa"
+msgstr "[ o [^ non chiusa"
#: regcomp.c:156
msgid "Unmatched ( or \\("
-msgstr "( or \\( non chiusa"
+msgstr "( o \\( non chiusa"
#: regcomp.c:159
msgid "Unmatched \\{"
@@ -1980,11 +1978,8 @@ msgstr "Espressione regolare troppo complessa"
#: regcomp.c:180
msgid "Unmatched ) or \\)"
-msgstr ") or \\) non aperta"
+msgstr ") o \\) non aperta"
#: regcomp.c:701
msgid "No previous regular expression"
msgstr "Nessuna espressione regolare precedente"
-
-#~ msgid "statement may have no effect"
-#~ msgstr "istruzione che può non aver alcun effetto"
diff --git a/version.c b/version.c
index 65a8d2f..914445a 100644
--- a/version.c
+++ b/version.c
@@ -1,3 +1,3 @@
#include "config.h"
-const char *version_string = "@(#)GNU Awk 3.1.81";
+const char *version_string = "GNU Awk 3.1.81";
diff --git a/version.in b/version.in
index e7a054d..a489761 100644
--- a/version.in
+++ b/version.in
@@ -1,3 +1,3 @@
#include "config.h"
-const char *version_string = "@(#)@PACKAGE_STRING@";
+const char *version_string = "@PACKAGE_STRING@";
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 23 +-
TODO | 2 +-
awk.h | 9 +
awklib/eg/lib/getopt.awk | 2 +-
awklib/eg/lib/groupawk.in | 3 +-
awklib/eg/lib/passwdawk.in | 3 +-
awklib/eg/lib/strtonum.awk | 2 +-
awklib/eg/prog/alarm.awk | 10 +-
doc/gawk.info | 2073 +++++++++++++++++++++++---------------------
doc/gawk.texi | 660 ++++++++-------
eval.c | 4 +-
io.c | 2 +-
main.c | 163 ++--
po/ChangeLog | 4 +
po/LINGUAS | 20 +-
po/it.po | 25 +-
version.c | 2 +-
version.in | 2 +-
18 files changed, 1581 insertions(+), 1428 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, master, updated. 4fe569fb78dd1b25822c16c9cac515a0fc6702a4,
Arnold Robbins <=