[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, gawk-4.0-stable, updated. 3f6a81b5812d5f
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, gawk-4.0-stable, updated. 3f6a81b5812d5f527aea23e77754732374a10c55 |
Date: |
Tue, 08 Nov 2011 19:20:43 +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, gawk-4.0-stable has been updated
via 3f6a81b5812d5f527aea23e77754732374a10c55 (commit)
from 2a63ca5d9af44de631e7853c8320357c6f5d6a3a (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=3f6a81b5812d5f527aea23e77754732374a10c55
commit 3f6a81b5812d5f527aea23e77754732374a10c55
Author: Arnold D. Robbins <address@hidden>
Date: Tue Nov 8 21:20:26 2011 +0200
More documentation changes.
diff --git a/NEWS b/NEWS
index 0106f7c..0745c32 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,16 @@
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
+Changes from 4.0.0 to 4.0.1
+---------------------------
+
+1. The default handling of backslash in sub() and gsub() has been reverted to
the
+ behavior of 3.1. It was silly to think I could break compatibility that way,
+ even for standards compliance.
+
+XXX. Lots of minor bugs fixed and portability clean-ups along the way. See the
ChangeLog
+ for details.
+
Changes from 3.1.8 to 4.0.0
---------------------------
diff --git a/doc/ChangeLog b/doc/ChangeLog
index e4855ca..64fe7a3 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-08 Arnold D. Robbins <address@hidden>
+
+ * gawk.texi: Further improvement in the discussion of sorted array
+ traversal. Some sections reordered and text edited to suit.
+
2011-11-06 Arnold D. Robbins <address@hidden>
* gawk.texi: Try to improve discussion of sorted array
diff --git a/doc/gawk.info b/doc/gawk.info
index 53fe12d..06133a6 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -15,7 +15,7 @@ Foundation, Inc.
This is Edition 4 of `GAWK: Effective AWK Programming: A User's
-Guide for GNU Awk', for the 4.0.0 (or later) version of the GNU
+Guide for GNU Awk', for the 4.0.1 (or later) version of the GNU
implementation of AWK.
Permission is granted to copy, distribute and/or modify this document
@@ -47,7 +47,7 @@ Foundation, Inc.
This is Edition 4 of `GAWK: Effective AWK Programming: A User's
-Guide for GNU Awk', for the 4.0.0 (or later) version of the GNU
+Guide for GNU Awk', for the 4.0.1 (or later) version of the GNU
implementation of AWK.
Permission is granted to copy, distribute and/or modify this document
@@ -109,439 +109,399 @@ texts being (a) (see below), and with the Back-Cover
Texts being (b)
* GNU Free Documentation License:: The license for this Info file.
* Index:: Concept and Variable Index.
-* History:: The history of `gawk' and
- `awk'.
-* Names:: What name to use to find `awk'.
-* This Manual:: Using this Info file. Includes
- sample input files that you can use.
-* Conventions:: Typographical Conventions.
-* Manual History:: Brief history of the GNU project and
- this Info file.
-* How To Contribute:: Helping to save the world.
-* Acknowledgments:: Acknowledgments.
-* Running gawk:: How to run `gawk' programs;
- includes command-line syntax.
-* One-shot:: Running a short throwaway `awk'
- program.
-* Read Terminal:: Using no input files (input from
- terminal instead).
-* Long:: Putting permanent `awk'
- programs in files.
-* Executable Scripts:: Making self-contained `awk'
- programs.
-* Comments:: Adding documentation to `gawk'
- programs.
-* Quoting:: More discussion of shell quoting
- issues.
-* DOS Quoting:: Quoting in Windows Batch Files.
-* Sample Data Files:: Sample data files for use in the
- `awk' programs illustrated in
- this Info file.
-* Very Simple:: A very simple example.
-* Two Rules:: A less simple one-line example using
- two rules.
-* More Complex:: A more complex example.
-* Statements/Lines:: Subdividing or combining statements
- into lines.
-* Other Features:: Other Features of `awk'.
-* When:: When to use `gawk' and when to
- use other things.
-* Command Line:: How to run `awk'.
-* Options:: Command-line options and their
- meanings.
-* Other Arguments:: Input file names and variable
- assignments.
-* Naming Standard Input:: How to specify standard input with
- other files.
-* Environment Variables:: The environment variables
- `gawk' uses.
-* AWKPATH Variable:: Searching directories for `awk'
- programs.
-* Other Environment Variables:: The environment variables.
-* Exit Status:: `gawk''s exit status.
-* Include Files:: Including other files into your
- program.
-* Obsolete:: Obsolete Options and/or features.
-* Undocumented:: Undocumented Options and Features.
-* Regexp Usage:: How to Use Regular Expressions.
-* Escape Sequences:: How to write nonprinting characters.
-* Regexp Operators:: Regular Expression Operators.
-* 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.
-* Computed Regexps:: Using Dynamic Regexps.
-* Records:: Controlling how data is split into
- records.
-* Fields:: An introduction to fields.
-* Nonconstant Fields:: Nonconstant Field Numbers.
-* Changing Fields:: Changing the Contents of a Field.
-* Field Separators:: The field separator and how to change
- it.
-* Default Field Splitting:: How fields are normally separated.
-* Regexp Field Splitting:: Using regexps as the field separator.
-* Single Character Fields:: Making each character a separate field.
-* Command Line Field Separator:: Setting `FS' from the
- command-line.
-* Field Splitting Summary:: Some final points and a summary table.
-* Constant Size:: Reading constant width data.
-* Splitting By Content:: Defining Fields By Content
-* Multiple Line:: Reading multi-line records.
-* Getline:: Reading files under explicit program
- control using the `getline'
- function.
-* Plain Getline:: Using `getline' with no arguments.
-* Getline/Variable:: Using `getline' into a variable.
-* Getline/File:: Using `getline' from a file.
-* Getline/Variable/File:: Using `getline' into a variable
- from a file.
-* Getline/Pipe:: Using `getline' from a pipe.
-* Getline/Variable/Pipe:: Using `getline' into a variable
- from a pipe.
-* Getline/Coprocess:: Using `getline' from a coprocess.
-* Getline/Variable/Coprocess:: Using `getline' into a variable
- from a coprocess.
-* Getline Notes:: Important things to know about
- `getline'.
-* Getline Summary:: Summary of `getline' Variants.
-* Command line directories:: What happens if you put a directory on
- the command line.
-* Print:: The `print' statement.
-* Print Examples:: Simple examples of `print'
- statements.
-* Output Separators:: The output separators and how to change
- them.
-* OFMT:: Controlling Numeric Output With
- `print'.
-* Printf:: The `printf' statement.
-* Basic Printf:: Syntax of the `printf' statement.
-* Control Letters:: Format-control letters.
-* Format Modifiers:: Format-specification modifiers.
-* Printf Examples:: Several examples.
-* Redirection:: How to redirect output to multiple
- files and pipes.
-* Special Files:: File name interpretation in
- `gawk'. `gawk' allows
- access to inherited file descriptors.
-* Special FD:: Special files for I/O.
-* Special Network:: Special files for network
- communications.
-* Special Caveats:: Things to watch out for.
-* Close Files And Pipes:: Closing Input and Output Files and
- Pipes.
-* Values:: Constants, Variables, and Regular
- Expressions.
-* Constants:: String, numeric and regexp constants.
-* Scalar Constants:: Numeric and string constants.
-* Nondecimal-numbers:: What are octal and hex numbers.
-* Regexp Constants:: Regular Expression constants.
-* Using Constant Regexps:: When and how to use a regexp constant.
-* Variables:: Variables give names to values for
- later use.
-* Using Variables:: Using variables in your programs.
-* Assignment Options:: Setting variables on the command-line
- and a summary of command-line syntax.
- This is an advanced method of input.
-* Conversion:: The conversion of strings to numbers
- and vice versa.
-* All Operators:: `gawk''s operators.
-* Arithmetic Ops:: Arithmetic operations (`+',
- `-', etc.)
-* Concatenation:: Concatenating strings.
-* Assignment Ops:: Changing the value of a variable or a
- field.
-* Increment Ops:: Incrementing the numeric value of a
- variable.
-* Truth Values and Conditions:: Testing for true and false.
-* Truth Values:: What is ``true'' and what is ``false''.
-* Typing and Comparison:: How variables acquire types and how
- this affects comparison of numbers and
- strings with `<', etc.
-* Variable Typing:: String type versus numeric type.
-* Comparison Operators:: The comparison operators.
-* POSIX String Comparison:: String comparison with POSIX rules.
-* Boolean Ops:: Combining comparison expressions using
- boolean operators `||' (``or''),
- `&&' (``and'') and `!'
- (``not'').
-* Conditional Exp:: Conditional expressions select between
- two subexpressions under control of a
- third subexpression.
-* Function Calls:: A function call is an expression.
-* Precedence:: How various operators nest.
-* Locales:: How the locale affects things.
-* Pattern Overview:: What goes into a pattern.
-* Regexp Patterns:: Using regexps as patterns.
-* Expression Patterns:: Any expression can be used as a
- pattern.
-* Ranges:: Pairs of patterns specify record
- ranges.
-* BEGIN/END:: Specifying initialization and cleanup
- rules.
-* Using BEGIN/END:: How and why to use BEGIN/END rules.
-* I/O And BEGIN/END:: I/O issues in BEGIN/END rules.
-* BEGINFILE/ENDFILE:: Two special patterns for advanced
- control.
-* Empty:: The empty pattern, which matches every
- record.
-* Using Shell Variables:: How to use shell variables with
- `awk'.
-* Action Overview:: What goes into an action.
-* Statements:: Describes the various control
- statements in detail.
-* If Statement:: Conditionally execute some
- `awk' statements.
-* While Statement:: Loop until some condition is satisfied.
-* Do Statement:: Do specified action while looping until
- some condition is satisfied.
-* For Statement:: Another looping statement, that
- provides initialization and increment
- clauses.
-* Switch Statement:: Switch/case evaluation for conditional
- execution of statements based on a
- value.
-* Break Statement:: Immediately exit the innermost
- enclosing loop.
-* Continue Statement:: Skip to the end of the innermost
- enclosing loop.
-* Next Statement:: Stop processing the current input
- record.
-* Nextfile Statement:: Stop processing the current file.
-* Exit Statement:: Stop execution of `awk'.
-* Built-in Variables:: Summarizes the built-in variables.
-* User-modified:: Built-in variables that you change to
- control `awk'.
-* Auto-set:: Built-in variables where `awk'
- gives you information.
-* ARGC and ARGV:: Ways to use `ARGC' and
- `ARGV'.
-* Array Basics:: The basics of arrays.
-* Array Intro:: Introduction to Arrays
-* Reference to Elements:: How to examine one element of an array.
-* Assigning Elements:: How to change an element of an array.
-* Array Example:: Basic Example of an Array
-* Scanning an Array:: A variation of the `for'
- statement. It loops through the indices
- of an array's existing elements.
-* Delete:: The `delete' statement removes an
- element from an array.
-* Numeric Array Subscripts:: How to use numbers as subscripts in
- `awk'.
-* Uninitialized Subscripts:: Using Uninitialized variables as
- subscripts.
-* Multi-dimensional:: Emulating multidimensional arrays in
- `awk'.
-* Multi-scanning:: Scanning multidimensional arrays.
-* Arrays of Arrays:: True multidimensional arrays.
-* Built-in:: Summarizes the built-in functions.
-* Calling Built-in:: How to call built-in functions.
-* Numeric Functions:: Functions that work with numbers,
- including `int()', `sin()'
- and `rand()'.
-* String Functions:: Functions for string manipulation, such
- as `split()', `match()' and
- `sprintf()'.
-* Gory Details:: More than you want to know about
- `\' and `&' with
- `sub()', `gsub()', and
- `gensub()'.
-* I/O Functions:: Functions for files and shell commands.
-* Time Functions:: Functions for dealing with timestamps.
-* Bitwise Functions:: Functions for bitwise operations.
-* Type Functions:: Functions for type information.
-* I18N Functions:: Functions for string translation.
-* User-defined:: Describes User-defined functions in
- detail.
-* Definition Syntax:: How to write definitions and what they
- mean.
-* Function Example:: An example function definition and what
- it does.
-* Function Caveats:: Things to watch out for.
-* Calling A Function:: Don't use spaces.
-* Variable Scope:: Controlling variable scope.
-* Pass By Value/Reference:: Passing parameters.
-* Return Statement:: Specifying the value a function
- returns.
-* Dynamic Typing:: How variable types can change at
- runtime.
-* Indirect Calls:: Choosing the function to call at
- runtime.
-* I18N and L10N:: Internationalization and Localization.
-* Explaining gettext:: How GNU `gettext' works.
-* Programmer i18n:: Features for the programmer.
-* Translator i18n:: Features for the translator.
-* String Extraction:: Extracting marked strings.
-* Printf Ordering:: Rearranging `printf' arguments.
-* I18N Portability:: `awk'-level portability issues.
-* I18N Example:: A simple i18n example.
-* Gawk I18N:: `gawk' is also
- internationalized.
-* Nondecimal Data:: Allowing nondecimal input data.
-* Array Sorting:: Facilities for controlling array
- traversal and sorting arrays.
-* Controlling Array Traversal:: How to use PROCINFO["sorted_in"].
-* Controlling Scanning With A Function:: Using a function to control scanning.
-* Controlling Scanning:: Controlling the order in which arrays
- are scanned.
-* Array Sorting Functions:: How to use `asort()' and
- `asorti()'.
-* Two-way I/O:: Two-way communications with another
- process.
-* TCP/IP Networking:: Using `gawk' for network
- programming.
-* Profiling:: Profiling your `awk' programs.
-* Library Names:: How to best name private global
- variables in library functions.
-* General Functions:: Functions that are of general use.
-* Strtonum Function:: A replacement for the built-in
- `strtonum()' function.
-* Assert Function:: A function for assertions in
- `awk' programs.
-* Round Function:: A function for rounding if
- `sprintf()' does not do it
- correctly.
-* Cliff Random Function:: The Cliff Random Number Generator.
-* Ordinal Functions:: Functions for using characters as
- numbers and vice versa.
-* Join Function:: A function to join an array into a
- string.
-* Gettimeofday Function:: A function to get formatted times.
-* Data File Management:: Functions for managing command-line
- data files.
-* Filetrans Function:: A function for handling data file
- transitions.
-* Rewind Function:: A function for rereading the current
- file.
-* File Checking:: Checking that data files are readable.
-* Empty Files:: Checking for zero-length files.
-* Ignoring Assigns:: Treating assignments as file names.
-* Getopt Function:: A function for processing command-line
- arguments.
-* Passwd Functions:: Functions for getting user information.
-* Group Functions:: Functions for getting group
- information.
-* Walking Arrays:: A function to walk arrays of arrays.
-* Running Examples:: How to run these examples.
-* Clones:: Clones of common utilities.
-* Cut Program:: The `cut' utility.
-* Egrep Program:: The `egrep' utility.
-* Id Program:: The `id' utility.
-* Split Program:: The `split' utility.
-* Tee Program:: The `tee' utility.
-* Uniq Program:: The `uniq' utility.
-* Wc Program:: The `wc' utility.
-* Miscellaneous Programs:: Some interesting `awk'
- programs.
-* Dupword Program:: Finding duplicated words in a document.
-* Alarm Program:: An alarm clock.
-* Translate Program:: A program similar to the `tr'
- utility.
-* Labels Program:: Printing mailing labels.
-* Word Sorting:: A program to produce a word usage
- count.
-* History Sorting:: Eliminating duplicate entries from a
- history file.
-* Extract Program:: Pulling out programs from Texinfo
- source files.
-* Simple Sed:: A Simple Stream Editor.
-* Igawk Program:: A wrapper for `awk' that
- includes files.
-* Anagram Program:: Finding anagrams from a dictionary.
-* Signature Program:: People do amazing things with too much
- time on their hands.
-* Debugging:: Introduction to `dgawk'.
-* Debugging Concepts:: Debugging In General.
-* Debugging Terms:: Additional Debugging Concepts.
-* Awk Debugging:: Awk Debugging.
-* Sample dgawk session:: Sample `dgawk' session.
-* dgawk invocation:: `dgawk' Invocation.
-* Finding The Bug:: Finding The Bug.
-* List of Debugger Commands:: Main `dgawk' Commands.
-* Breakpoint Control:: Control of breakpoints.
-* Dgawk Execution Control:: Control of execution.
-* Viewing And Changing Data:: Viewing and changing data.
-* Dgawk Stack:: Dealing with the stack.
-* Dgawk Info:: Obtaining information about the program
- and the debugger state.
-* Miscellaneous Dgawk Commands:: Miscellaneous Commands.
-* Readline Support:: Readline Support.
-* Dgawk Limitations:: Limitations and future plans.
-* V7/SVR3.1:: The major changes between V7 and System
- V Release 3.1.
-* SVR4:: Minor changes between System V Releases
- 3.1 and 4.
-* POSIX:: New features from the POSIX standard.
-* BTL:: New features from Brian Kernighan's
- version of `awk'.
-* POSIX/GNU:: The extensions in `gawk' not in
- POSIX `awk'.
-* Common Extensions:: Common Extensions Summary.
-* Ranges and Locales:: How locales used to affect regexp
- ranges.
-* Contributors:: The major contributors to
- `gawk'.
-* Gawk Distribution:: What is in the `gawk'
- distribution.
-* Getting:: How to get the distribution.
-* Extracting:: How to extract the distribution.
-* Distribution contents:: What is in the distribution.
-* Unix Installation:: Installing `gawk' under various
- versions of Unix.
-* Quick Installation:: Compiling `gawk' under Unix.
-* Additional Configuration Options:: Other compile-time options.
-* Configuration Philosophy:: How it's all supposed to work.
-* Non-Unix Installation:: Installation on Other Operating
- Systems.
-* PC Installation:: Installing and Compiling `gawk'
- on MS-DOS and OS/2.
-* PC Binary Installation:: Installing a prepared distribution.
-* PC Compiling:: Compiling `gawk' for MS-DOS,
- Windows32, and OS/2.
-* PC Testing:: Testing `gawk' on PC systems.
-* PC Using:: Running `gawk' on MS-DOS,
- Windows32 and OS/2.
-* Cygwin:: Building and running `gawk' for
- Cygwin.
-* MSYS:: Using `gawk' In The MSYS
- Environment.
-* VMS Installation:: Installing `gawk' on VMS.
-* VMS Compilation:: How to compile `gawk' under
- VMS.
-* VMS Installation Details:: How to install `gawk' under
- VMS.
-* VMS Running:: How to run `gawk' under VMS.
-* VMS Old Gawk:: An old version comes with some VMS
- systems.
-* Bugs:: Reporting Problems and Bugs.
-* Other Versions:: Other freely available `awk'
- implementations.
-* Compatibility Mode:: How to disable certain `gawk'
- extensions.
-* Additions:: Making Additions To `gawk'.
-* Accessing The Source:: Accessing the Git repository.
-* Adding Code:: Adding code to the main body of
- `gawk'.
-* New Ports:: Porting `gawk' to a new
- operating system.
-* Dynamic Extensions:: Adding new built-in functions to
- `gawk'.
-* Internals:: A brief look at some `gawk'
- internals.
-* Plugin License:: A note about licensing.
-* Sample Library:: A example of new functions.
-* Internal File Description:: What the new functions will do.
-* Internal File Ops:: The code for internal file operations.
-* Using Internal File Ops:: How to use an external extension.
-* Future Extensions:: New features that may be implemented
- one day.
-* Basic High Level:: The high level view.
-* Basic Data Typing:: A very quick intro to data types.
-* Floating Point Issues:: Stuff to know about floating-point
- numbers.
-* String Conversion Precision:: The String Value Can Lie.
-* Unexpected Results:: Floating Point Numbers Are Not Abstract
- Numbers.
-* POSIX Floating Point Problems:: Standards Versus Existing Practice.
+* History:: The history of `gawk' and
+ `awk'.
+* Names:: What name to use to find `awk'.
+* This Manual:: Using this Info file. Includes
+ sample input files that you can use.
+* Conventions:: Typographical Conventions.
+* Manual History:: Brief history of the GNU project and this
+ Info file.
+* How To Contribute:: Helping to save the world.
+* Acknowledgments:: Acknowledgments.
+* Running gawk:: How to run `gawk' programs;
+ includes command-line syntax.
+* One-shot:: Running a short throwaway `awk'
+ program.
+* Read Terminal:: Using no input files (input from terminal
+ instead).
+* Long:: Putting permanent `awk' programs in
+ files.
+* Executable Scripts:: Making self-contained `awk'
+ programs.
+* Comments:: Adding documentation to `gawk'
+ programs.
+* Quoting:: More discussion of shell quoting issues.
+* DOS Quoting:: Quoting in Windows Batch Files.
+* Sample Data Files:: Sample data files for use in the
+ `awk' programs illustrated in this
+ Info file.
+* Very Simple:: A very simple example.
+* Two Rules:: A less simple one-line example using two
+ rules.
+* More Complex:: A more complex example.
+* Statements/Lines:: Subdividing or combining statements into
+ lines.
+* Other Features:: Other Features of `awk'.
+* When:: When to use `gawk' and when to use
+ other things.
+* Command Line:: How to run `awk'.
+* Options:: Command-line options and their meanings.
+* Other Arguments:: Input file names and variable assignments.
+* Naming Standard Input:: How to specify standard input with other
+ files.
+* Environment Variables:: The environment variables `gawk'
+ uses.
+* AWKPATH Variable:: Searching directories for `awk'
+ programs.
+* Other Environment Variables:: The environment variables.
+* Exit Status:: `gawk''s exit status.
+* Include Files:: Including other files into your program.
+* Obsolete:: Obsolete Options and/or features.
+* Undocumented:: Undocumented Options and Features.
+* Regexp Usage:: How to Use Regular Expressions.
+* Escape Sequences:: How to write nonprinting characters.
+* Regexp Operators:: Regular Expression Operators.
+* 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.
+* Computed Regexps:: Using Dynamic Regexps.
+* Records:: Controlling how data is split into records.
+* Fields:: An introduction to fields.
+* Nonconstant Fields:: Nonconstant Field Numbers.
+* Changing Fields:: Changing the Contents of a Field.
+* Field Separators:: The field separator and how to change it.
+* Default Field Splitting:: How fields are normally separated.
+* Regexp Field Splitting:: Using regexps as the field separator.
+* Single Character Fields:: Making each character a separate field.
+* Command Line Field Separator:: Setting `FS' from the command-line.
+* Field Splitting Summary:: Some final points and a summary table.
+* Constant Size:: Reading constant width data.
+* Splitting By Content:: Defining Fields By Content
+* Multiple Line:: Reading multi-line records.
+* Getline:: Reading files under explicit program
+ control using the `getline' function.
+* Plain Getline:: Using `getline' with no arguments.
+* Getline/Variable:: Using `getline' into a variable.
+* Getline/File:: Using `getline' from a file.
+* Getline/Variable/File:: Using `getline' into a variable from a
+ file.
+* Getline/Pipe:: Using `getline' from a pipe.
+* Getline/Variable/Pipe:: Using `getline' into a variable from a
+ pipe.
+* Getline/Coprocess:: Using `getline' from a coprocess.
+* Getline/Variable/Coprocess:: Using `getline' into a variable from a
+ coprocess.
+* Getline Notes:: Important things to know about
+ `getline'.
+* Getline Summary:: Summary of `getline' Variants.
+* Command line directories:: What happens if you put a directory on the
+ command line.
+* Print:: The `print' statement.
+* Print Examples:: Simple examples of `print' statements.
+* Output Separators:: The output separators and how to change
+ them.
+* OFMT:: Controlling Numeric Output With
+ `print'.
+* Printf:: The `printf' statement.
+* Basic Printf:: Syntax of the `printf' statement.
+* Control Letters:: Format-control letters.
+* Format Modifiers:: Format-specification modifiers.
+* Printf Examples:: Several examples.
+* Redirection:: How to redirect output to multiple files
+ and pipes.
+* Special Files:: File name interpretation in `gawk'.
+ `gawk' allows access to inherited
+ file descriptors.
+* Special FD:: Special files for I/O.
+* Special Network:: Special files for network communications.
+* Special Caveats:: Things to watch out for.
+* Close Files And Pipes:: Closing Input and Output Files and Pipes.
+* Values:: Constants, Variables, and Regular
+ Expressions.
+* Constants:: String, numeric and regexp constants.
+* Scalar Constants:: Numeric and string constants.
+* Nondecimal-numbers:: What are octal and hex numbers.
+* Regexp Constants:: Regular Expression constants.
+* Using Constant Regexps:: When and how to use a regexp constant.
+* Variables:: Variables give names to values for later
+ use.
+* Using Variables:: Using variables in your programs.
+* Assignment Options:: Setting variables on the command-line and a
+ summary of command-line syntax. This is an
+ advanced method of input.
+* Conversion:: The conversion of strings to numbers and
+ vice versa.
+* All Operators:: `gawk''s operators.
+* Arithmetic Ops:: Arithmetic operations (`+', `-',
+ etc.)
+* Concatenation:: Concatenating strings.
+* Assignment Ops:: Changing the value of a variable or a
+ field.
+* Increment Ops:: Incrementing the numeric value of a
+ variable.
+* Truth Values and Conditions:: Testing for true and false.
+* Truth Values:: What is ``true'' and what is ``false''.
+* Typing and Comparison:: How variables acquire types and how this
+ affects comparison of numbers and strings
+ with `<', etc.
+* Variable Typing:: String type versus numeric type.
+* Comparison Operators:: The comparison operators.
+* POSIX String Comparison:: String comparison with POSIX rules.
+* Boolean Ops:: Combining comparison expressions using
+ boolean operators `||' (``or''),
+ `&&' (``and'') and `!' (``not'').
+* Conditional Exp:: Conditional expressions select between two
+ subexpressions under control of a third
+ subexpression.
+* Function Calls:: A function call is an expression.
+* Precedence:: How various operators nest.
+* Locales:: How the locale affects things.
+* Pattern Overview:: What goes into a pattern.
+* Regexp Patterns:: Using regexps as patterns.
+* Expression Patterns:: Any expression can be used as a pattern.
+* Ranges:: Pairs of patterns specify record ranges.
+* BEGIN/END:: Specifying initialization and cleanup
+ rules.
+* Using BEGIN/END:: How and why to use BEGIN/END rules.
+* I/O And BEGIN/END:: I/O issues in BEGIN/END rules.
+* BEGINFILE/ENDFILE:: Two special patterns for advanced control.
+* Empty:: The empty pattern, which matches every
+ record.
+* Using Shell Variables:: How to use shell variables with
+ `awk'.
+* Action Overview:: What goes into an action.
+* Statements:: Describes the various control statements in
+ detail.
+* If Statement:: Conditionally execute some `awk'
+ statements.
+* While Statement:: Loop until some condition is satisfied.
+* Do Statement:: Do specified action while looping until
+ some condition is satisfied.
+* For Statement:: Another looping statement, that provides
+ initialization and increment clauses.
+* Switch Statement:: Switch/case evaluation for conditional
+ execution of statements based on a value.
+* Break Statement:: Immediately exit the innermost enclosing
+ loop.
+* Continue Statement:: Skip to the end of the innermost enclosing
+ loop.
+* Next Statement:: Stop processing the current input record.
+* Nextfile Statement:: Stop processing the current file.
+* Exit Statement:: Stop execution of `awk'.
+* Built-in Variables:: Summarizes the built-in variables.
+* User-modified:: Built-in variables that you change to
+ control `awk'.
+* Auto-set:: Built-in variables where `awk'
+ gives you information.
+* ARGC and ARGV:: Ways to use `ARGC' and `ARGV'.
+* Array Basics:: The basics of arrays.
+* Array Intro:: Introduction to Arrays
+* Reference to Elements:: How to examine one element of an array.
+* Assigning Elements:: How to change an element of an array.
+* Array Example:: Basic Example of an Array
+* Scanning an Array:: A variation of the `for' statement. It
+ loops through the indices of an array's
+ existing elements.
+* Controlling Scanning:: Controlling the order in which arrays are
+ scanned.
+* Delete:: The `delete' statement removes an
+ element from an array.
+* Numeric Array Subscripts:: How to use numbers as subscripts in
+ `awk'.
+* Uninitialized Subscripts:: Using Uninitialized variables as
+ subscripts.
+* Multi-dimensional:: Emulating multidimensional arrays in
+ `awk'.
+* Multi-scanning:: Scanning multidimensional arrays.
+* Arrays of Arrays:: True multidimensional arrays.
+* Built-in:: Summarizes the built-in functions.
+* Calling Built-in:: How to call built-in functions.
+* Numeric Functions:: Functions that work with numbers, including
+ `int()', `sin()' and
+ `rand()'.
+* String Functions:: Functions for string manipulation, such as
+ `split()', `match()' and
+ `sprintf()'.
+* Gory Details:: More than you want to know about `\'
+ and `&' with `sub()',
+ `gsub()', and `gensub()'.
+* I/O Functions:: Functions for files and shell commands.
+* Time Functions:: Functions for dealing with timestamps.
+* Bitwise Functions:: Functions for bitwise operations.
+* Type Functions:: Functions for type information.
+* I18N Functions:: Functions for string translation.
+* User-defined:: Describes User-defined functions in detail.
+* Definition Syntax:: How to write definitions and what they
+ mean.
+* Function Example:: An example function definition and what it
+ does.
+* Function Caveats:: Things to watch out for.
+* Calling A Function:: Don't use spaces.
+* Variable Scope:: Controlling variable scope.
+* Pass By Value/Reference:: Passing parameters.
+* Return Statement:: Specifying the value a function returns.
+* Dynamic Typing:: How variable types can change at runtime.
+* Indirect Calls:: Choosing the function to call at runtime.
+* I18N and L10N:: Internationalization and Localization.
+* Explaining gettext:: How GNU `gettext' works.
+* Programmer i18n:: Features for the programmer.
+* Translator i18n:: Features for the translator.
+* String Extraction:: Extracting marked strings.
+* Printf Ordering:: Rearranging `printf' arguments.
+* I18N Portability:: `awk'-level portability issues.
+* I18N Example:: A simple i18n example.
+* Gawk I18N:: `gawk' is also internationalized.
+* Nondecimal Data:: Allowing nondecimal input data.
+* Array Sorting:: Facilities for controlling array traversal
+ and sorting arrays.
+* Controlling Array Traversal:: How to use PROCINFO["sorted_in"].
+* Array Sorting Functions:: How to use `asort()' and
+ `asorti()'.
+* Two-way I/O:: Two-way communications with another
+ process.
+* TCP/IP Networking:: Using `gawk' for network
+ programming.
+* Profiling:: Profiling your `awk' programs.
+* Library Names:: How to best name private global variables
+ in library functions.
+* General Functions:: Functions that are of general use.
+* Strtonum Function:: A replacement for the built-in
+ `strtonum()' function.
+* Assert Function:: A function for assertions in `awk'
+ programs.
+* Round Function:: A function for rounding if `sprintf()'
+ does not do it correctly.
+* Cliff Random Function:: The Cliff Random Number Generator.
+* Ordinal Functions:: Functions for using characters as numbers
+ and vice versa.
+* Join Function:: A function to join an array into a string.
+* Gettimeofday Function:: A function to get formatted times.
+* Data File Management:: Functions for managing command-line data
+ files.
+* Filetrans Function:: A function for handling data file
+ transitions.
+* Rewind Function:: A function for rereading the current file.
+* File Checking:: Checking that data files are readable.
+* Empty Files:: Checking for zero-length files.
+* Ignoring Assigns:: Treating assignments as file names.
+* Getopt Function:: A function for processing command-line
+ arguments.
+* Passwd Functions:: Functions for getting user information.
+* Group Functions:: Functions for getting group information.
+* Walking Arrays:: A function to walk arrays of arrays.
+* Running Examples:: How to run these examples.
+* Clones:: Clones of common utilities.
+* Cut Program:: The `cut' utility.
+* Egrep Program:: The `egrep' utility.
+* Id Program:: The `id' utility.
+* Split Program:: The `split' utility.
+* Tee Program:: The `tee' utility.
+* Uniq Program:: The `uniq' utility.
+* Wc Program:: The `wc' utility.
+* Miscellaneous Programs:: Some interesting `awk' programs.
+* Dupword Program:: Finding duplicated words in a document.
+* Alarm Program:: An alarm clock.
+* Translate Program:: A program similar to the `tr'
+ utility.
+* Labels Program:: Printing mailing labels.
+* Word Sorting:: A program to produce a word usage count.
+* History Sorting:: Eliminating duplicate entries from a
+ history file.
+* Extract Program:: Pulling out programs from Texinfo source
+ files.
+* Simple Sed:: A Simple Stream Editor.
+* Igawk Program:: A wrapper for `awk' that includes
+ files.
+* Anagram Program:: Finding anagrams from a dictionary.
+* Signature Program:: People do amazing things with too much time
+ on their hands.
+* Debugging:: Introduction to `dgawk'.
+* Debugging Concepts:: Debugging In General.
+* Debugging Terms:: Additional Debugging Concepts.
+* Awk Debugging:: Awk Debugging.
+* Sample dgawk session:: Sample `dgawk' session.
+* dgawk invocation:: `dgawk' Invocation.
+* Finding The Bug:: Finding The Bug.
+* List of Debugger Commands:: Main `dgawk' Commands.
+* Breakpoint Control:: Control of breakpoints.
+* Dgawk Execution Control:: Control of execution.
+* Viewing And Changing Data:: Viewing and changing data.
+* Dgawk Stack:: Dealing with the stack.
+* Dgawk Info:: Obtaining information about the program and
+ the debugger state.
+* Miscellaneous Dgawk Commands:: Miscellaneous Commands.
+* Readline Support:: Readline Support.
+* Dgawk Limitations:: Limitations and future plans.
+* V7/SVR3.1:: The major changes between V7 and System V
+ Release 3.1.
+* SVR4:: Minor changes between System V Releases 3.1
+ and 4.
+* POSIX:: New features from the POSIX standard.
+* BTL:: New features from Brian Kernighan's version
+ of `awk'.
+* POSIX/GNU:: The extensions in `gawk' not in
+ POSIX `awk'.
+* Common Extensions:: Common Extensions Summary.
+* Ranges and Locales:: How locales used to affect regexp ranges.
+* Contributors:: The major contributors to `gawk'.
+* Gawk Distribution:: What is in the `gawk' distribution.
+* Getting:: How to get the distribution.
+* Extracting:: How to extract the distribution.
+* Distribution contents:: What is in the distribution.
+* Unix Installation:: Installing `gawk' under various
+ versions of Unix.
+* Quick Installation:: Compiling `gawk' under Unix.
+* Additional Configuration Options:: Other compile-time options.
+* Configuration Philosophy:: How it's all supposed to work.
+* Non-Unix Installation:: Installation on Other Operating Systems.
+* PC Installation:: Installing and Compiling `gawk' on
+ MS-DOS and OS/2.
+* PC Binary Installation:: Installing a prepared distribution.
+* PC Compiling:: Compiling `gawk' for MS-DOS,
+ Windows32, and OS/2.
+* PC Testing:: Testing `gawk' on PC systems.
+* PC Using:: Running `gawk' on MS-DOS, Windows32
+ and OS/2.
+* Cygwin:: Building and running `gawk' for
+ Cygwin.
+* MSYS:: Using `gawk' In The MSYS
+ Environment.
+* VMS Installation:: Installing `gawk' on VMS.
+* VMS Compilation:: How to compile `gawk' under VMS.
+* VMS Installation Details:: How to install `gawk' under VMS.
+* VMS Running:: How to run `gawk' under VMS.
+* VMS Old Gawk:: An old version comes with some VMS systems.
+* Bugs:: Reporting Problems and Bugs.
+* Other Versions:: Other freely available `awk'
+ implementations.
+* Compatibility Mode:: How to disable certain `gawk'
+ extensions.
+* Additions:: Making Additions To `gawk'.
+* Accessing The Source:: Accessing the Git repository.
+* Adding Code:: Adding code to the main body of
+ `gawk'.
+* New Ports:: Porting `gawk' to a new operating
+ system.
+* Dynamic Extensions:: Adding new built-in functions to
+ `gawk'.
+* Internals:: A brief look at some `gawk'
+ internals.
+* Plugin License:: A note about licensing.
+* Sample Library:: A example of new functions.
+* Internal File Description:: What the new functions will do.
+* Internal File Ops:: The code for internal file operations.
+* Using Internal File Ops:: How to use an external extension.
+* Future Extensions:: New features that may be implemented one
+ day.
+* Basic High Level:: The high level view.
+* Basic Data Typing:: A very quick intro to data types.
+* Floating Point Issues:: Stuff to know about floating-point numbers.
+* String Conversion Precision:: The String Value Can Lie.
+* Unexpected Results:: Floating Point Numbers Are Not Abstract
+ Numbers.
+* POSIX Floating Point Problems:: Standards Versus Existing Practice.
To Miriam, for making me complete.
@@ -9641,6 +9601,8 @@ one at a time, and traversing all of the elements in an
array.
* Scanning an Array:: A variation of the `for' statement. It
loops through the indices of an array's
existing elements.
+* Controlling Scanning:: Controlling the order in which arrays are
+ scanned.
File: gawk.info, Node: Array Intro, Next: Reference to Elements, Up: Array
Basics
@@ -9873,7 +9835,7 @@ easy improvement to the program's `END' rule, as follows:
}
-File: gawk.info, Node: Scanning an Array, Prev: Array Example, Up: Array
Basics
+File: gawk.info, Node: Scanning an Array, Next: Controlling Scanning, Prev:
Array Example, Up: Array Basics
8.1.5 Scanning All Elements of an Array
---------------------------------------
@@ -9928,15 +9890,148 @@ 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
-`PROCINFO["sorted_in"]' (*note Auto-set::). This is an advanced
-feature, so discussion of it is delayed until *note Controlling Array
-Traversal::.
+
+File: gawk.info, Node: Controlling Scanning, Prev: Scanning an Array, Up:
Array Basics
+
+8.1.6 Using Predefined Array Scanning Orders
+--------------------------------------------
+
+By default, when a `for' loop traverses an array, the order is
+undefined, meaning that the `awk' implementation determines the order
+in which the array is traversed. This order is usually based on the
+internal implementation of arrays and will vary from one version of
+`awk' to the next.
+
+ Often, though, you may wish to do something simple, such as
+"traverse the array by comparing the indices in ascending order," or
+"traverse the array by on comparing the values in descending order."
+`gawk' provides two mechanims which give you this control.
+
+ * Set `PROCINFO["sorted_in"]' to one of a set of predefined values.
+ We describe this now.
+
+ * Set `PROCINFO["sorted_in"]' to the name of a user-defined function
+ to be used for comparison of array elements. This advanced feature
+ is described later, in *note Array Sorting::.
+
+ The following special values for `PROCINFO["sorted_in"]' are
+available:
+
+`"@unsorted"'
+ Array elements are processed in arbitrary order, which is the
+ default `awk' behavior.
+
+`"@ind_str_asc"'
+ Order by indices compared as strings; this is the most basic sort.
+ (Internally, array indices are always strings, so with `a[2*5] = 1'
+ the index is `"10"' rather than numeric 10.)
+
+`"@ind_num_asc"'
+ Order by indices but force them to be treated as numbers in the
+ process. Any index with a non-numeric value will end up
+ positioned as if it were zero.
+
+`"@val_type_asc"'
+ Order by element values rather than indices. Ordering is by the
+ type assigned to the element (*note Typing and Comparison::). All
+ numeric values come before all string values, which in turn come
+ before all subarrays. (Subarrays have not been described yet;
+ *note Arrays of Arrays::).
+
+`"@val_str_asc"'
+ Order by element values rather than by indices. Scalar values are
+ compared as strings. Subarrays, if present, come out last.
+
+`"@val_num_asc"'
+ Order by element values rather than by indices. Scalar values are
+ compared as numbers. Subarrays, if present, come out last. When
+ numeric values are equal, the string values are used to provide an
+ ordering: this guarantees consistent results across different
+ versions of the C `qsort()' function,(1) which `gawk' uses
+ internally to perform the sorting.
+
+`"@ind_str_desc"'
+ Reverse order from the most basic sort.
+
+`"@ind_num_desc"'
+ Numeric indices ordered from high to low.
+
+`"@val_type_desc"'
+ Element values, based on type, in descending order.
+
+`"@val_str_desc"'
+ Element values, treated as strings, ordered from high to low.
+ Subarrays, if present, come out first.
+
+`"@val_num_desc"'
+ Element values, treated as numbers, ordered from high to low.
+ Subarrays, if present, come out first.
+
+ The array traversal order is determined before the `for' loop starts
+to run. Changing `PROCINFO["sorted_in"]' in the loop body will not
+affect the loop.
+
+ For example:
+
+ $ gawk 'BEGIN {
+ > a[4] = 4
+ > a[3] = 3
+ > for (i in a)
+ > print i, a[i]
+ > }'
+ -| 4 4
+ -| 3 3
+ $ gawk 'BEGIN {
+ > PROCINFO["sorted_in"] = "@ind_str_asc"
+ > a[4] = 4
+ > a[3] = 3
+ > for (i in a)
+ > print i, a[i]
+ > }'
+ -| 3 3
+ -| 4 4
+
+ When sorting an array by element values, if a value happens to be a
+subarray then it is considered to be greater than any string or numeric
+value, regardless of what the subarray itself contains, and all
+subarrays are treated as being equal to each other. Their order
+relative to each other is determined by their index strings.
+
+ Here are some additional things to bear in mind about sorted array
+traversal.
+
+ * The value of `PROCINFO["sorted_in"]' is global. That is, it affects
+ all array traversal `for' loops. If you need to change it within
+ your own code, you should see if it's defined and save and restore
+ the value:
+
+ ...
+ if ("sorted_in" in PROCINFO) {
+ save_sorted = PROCINFO["sorted_in"]
+ PROCINFO["sorted_in"] = "@val_str_desc" # or whatever
+ }
+ ...
+ if (save_sorted)
+ PROCINFO["sorted_in"] = save_sorted
+
+ * As mentioned, the default array traversal order is represented by
+ `"@unsorted"'. You can also get the default behavior by assigning
+ the null string to `PROCINFO["sorted_in"]' or by just deleting the
+ `"sorted_in"' element from the `PROCINFO' array with the `delete'
+ statement. (The `delete' statement hasn't been described yet;
+ *note Delete::.)
In addition, `gawk' provides built-in functions for sorting arrays;
see *note Array Sorting Functions::.
+ ---------- Footnotes ----------
+
+ (1) When two elements compare as equal, the C `qsort()' function
+does not guarantee that they will maintain their original relative
+order after sorting. Using the string value to provide a unique
+ordering when the numeric values are equal ensures that `gawk' behaves
+consistently across different environments.
+
File: gawk.info, Node: Delete, Next: Numeric Array Subscripts, Prev: Array
Basics, Up: Arrays
@@ -13462,8 +13557,8 @@ File: gawk.info, Node: Array Sorting, Next: Two-way
I/O, Prev: Nondecimal Dat
11.2 Controlling Array Traversal and Array Sorting
==================================================
-`gawk' lets you control the order in which `for (i in array)' loops
-will traverse an array.
+`gawk' lets you control the order in which a `for (i in array)' loop
+traverses an array.
In addition, two built-in functions, `asort()' and `asorti()', let
you sort arrays based on the array values and indices, respectively.
@@ -13487,24 +13582,17 @@ of arrays inside `awk'.
Often, though, it is desirable to be able to loop over the elements
in a particular order that you, the programmer, choose. `gawk' lets
-you do this; this node describes how.
-
-* Menu:
-
-* Controlling Scanning With A Function:: Using a function to control scanning.
-* Controlling Scanning:: Controlling the order in which arrays
- are scanned.
-
-
-File: gawk.info, Node: Controlling Scanning With A Function, Next:
Controlling Scanning, Up: Controlling Array Traversal
+you do this.
-11.2.1.1 Array Scanning Using A User-defined Function
-.....................................................
+ *note Controlling Scanning::, describes how you can assign special,
+pre-defined values to `PROCINFO["sorted_in"]' in order to control the
+order in which `gawk' will traverse an array during a `for' loop.
-The value of `PROCINFO["sorted_in"]' can be a function name. This lets
-you traverse an array based on any custom criterion. The array
-elements are ordered according to the return value of this function.
-The comparison function should be defined with at least four arguments:
+ In addition, the value of `PROCINFO["sorted_in"]' can be a function
+name. This lets you traverse an array based on any custom criterion.
+The array elements are ordered according to the return value of this
+function. The comparison function should be defined with at least four
+arguments:
function comp_func(i1, v1, i2, v2)
{
@@ -13514,8 +13602,9 @@ The comparison function should be defined with at least
four arguments:
Here, I1 and I2 are the indices, and V1 and V2 are the corresponding
values of the two elements being compared. Either V1 or V2, or both,
-can be arrays if the array being traversed contains subarrays as
-values. The three possible return values are interpreted this way:
+can be arrays if the array being traversed contains subarrays as values.
+(*Note Arrays of Arrays::, for more information about subarrays.) The
+three possible return values are interpreted as follows:
`comp_func(i1, v1, i2, v2) < 0'
Index I1 comes before index I2 during loop traversal.
@@ -13642,9 +13731,8 @@ specific field position and can be used for this
purpose:
The first field in each entry of the password file is the user's
login name, and the fields are seperated by colons. Each record
-defines a subarray (*note Arrays of Arrays::), with each field as an
-element in the subarray. Running the program produces the following
-output:
+defines a subarray, with each field as an element in the subarray.
+Running the program produces the following output:
$ gawk -vPOS=1 -F: -f sort.awk /etc/passwd
-| adm:x:3:4:adm:/var/adm:/sbin/nologin
@@ -13714,150 +13802,16 @@ time of `awk' programs. For this reason, sorted
array traversal is not
the default.
-File: gawk.info, Node: Controlling Scanning, Prev: Controlling Scanning With
A Function, Up: Controlling Array Traversal
-
-11.2.1.2 Controlling Array Scanning Order
-.........................................
-
-As described in *note Controlling Scanning With A Function::, you can
-provide the name of a function as the value of `PROCINFO["sorted_in"]'
-to specify custom sorting criteria.
-
- Often, though, you may wish to do something simple, such as "sort
-based on comparing the indices in ascending order," or "sort based on
-comparing the values in descending order." Having to write a simple
-comparison function for this purpose for use in all of your programs
-becomes tedious. For the common simple cases, `gawk' provides the
-option of using special names that do the requested sorting for you.
-You can think of them as "predefined" sorting functions, if you like,
-although the names purposely include characters that are not valid in
-real `awk' function names.
-
- The following special values are available:
-
-`"@unsorted"'
- Array elements are processed in arbitrary order, which is the
- default `awk' behavior.
-
-`"@ind_str_asc"'
- Order by indices compared as strings; this is the most basic sort.
- (Internally, array indices are always strings, so with `a[2*5] = 1'
- the index is `"10"' rather than numeric 10.)
-
-`"@ind_num_asc"'
- Order by indices but force them to be treated as numbers in the
- process. Any index with a non-numeric value will end up
- positioned as if it were zero.
-
-`"@val_type_asc"'
- Order by element values rather than indices. Ordering is by the
- type assigned to the element (*note Typing and Comparison::). All
- numeric values come before all string values, which in turn come
- before all subarrays.
-
-`"@val_str_asc"'
- Order by element values rather than by indices. Scalar values are
- compared as strings. Subarrays, if present, come out last.
-
-`"@val_num_asc"'
- Order by element values rather than by indices. Scalar values are
- compared as numbers. Subarrays, if present, come out last. When
- numeric values are equal, the string values are used to provide an
- ordering: this guarantees consistent results across different
- versions of the C `qsort()' function(1), which `gawk' uses
- internally to perform the sorting.
-
-`"@ind_str_desc"'
- Reverse order from the most basic sort.
-
-`"@ind_num_desc"'
- Numeric indices ordered from high to low.
-
-`"@val_type_desc"'
- Element values, based on type, in descending order.
-
-`"@val_str_desc"'
- Element values, treated as strings, ordered from high to low.
- Subarrays, if present, come out first.
-
-`"@val_num_desc"'
- Element values, treated as numbers, ordered from high to low.
- Subarrays, if present, come out first.
-
- The array traversal order is determined before the `for' loop starts
-to run. Changing `PROCINFO["sorted_in"]' in the loop body will not
-affect the loop.
-
- For example:
-
- $ gawk 'BEGIN {
- > a[4] = 4
- > a[3] = 3
- > for (i in a)
- > print i, a[i]
- > }'
- -| 4 4
- -| 3 3
- $ gawk 'BEGIN {
- > PROCINFO["sorted_in"] = "@ind_str_asc"
- > a[4] = 4
- > a[3] = 3
- > for (i in a)
- > print i, a[i]
- > }'
- -| 3 3
- -| 4 4
-
- When sorting an array by element values, if a value happens to be a
-subarray then it is considered to be greater than any string or numeric
-value, regardless of what the subarray itself contains, and all
-subarrays are treated as being equal to each other. Their order
-relative to each other is determined by their index strings.
-
- Here are some additional things to bear in mind about sorted array
-traversal.
-
- * The value of `PROCINFO["sorted_in"]' is global. That is, it affects
- all array traversal `for' loops. If you need to change it within
- your own function, you should see if it's defined and save and
- restore the value:
-
- function myfunct(p1, p2, save_sorted)
- {
- ...
- if ("sorted_in" in PROCINFO) {
- save_sorted = PROCINFO["sorted_in"]
- PROCINFO["sorted_in"] = "@val_str_desc" # or whatever
- }
- ...
- if (save_sorted)
- PROCINFO["sorted_in"] = save_sorted
- }
-
- * As mentioned, the default array traversal order is represented by
- `"@unsorted"'. You can also get the default behavior by assigning
- the null string to `PROCINFO["sorted_in"]' or by just deleting the
- `"sorted_in"' element from the `PROCINFO' array.
-
- ---------- Footnotes ----------
-
- (1) When two elements compare as equal, the C `qsort()' function
-does not guarantee that they will maintain their original relative
-order after sorting. Using the string value to provide a unique
-ordering when the numeric values are equal ensures that `gawk' behaves
-consistently across different environments.
-
-
File: gawk.info, Node: Array Sorting Functions, Prev: Controlling Array
Traversal, Up: Array Sorting
11.2.2 Sorting Array Values and Indices with `gawk'
---------------------------------------------------
In most `awk' implementations, sorting an array requires writing a
-`sort' function. While this can be educational for exploring different
-sorting algorithms, usually that's not the point of the program.
-`gawk' provides the built-in `asort()' and `asorti()' functions (*note
-String Functions::) for sorting arrays. For example:
+`sort()' function. While this can be educational for exploring
+different sorting algorithms, usually that's not the point of the
+program. `gawk' provides the built-in `asort()' and `asorti()'
+functions (*note String Functions::) for sorting arrays. For example:
POPULATE THE ARRAY data
n = asort(data)
@@ -13886,8 +13840,9 @@ array is not affected.
`asort()' accepts a third string argument to control comparison of
array elements. As with `PROCINFO["sorted_in"]', this argument may be
-the name of a user-defined function, or one of the predefined names
-that `gawk' provides (*note Controlling Scanning With A Function::).
+one of the predefined names that `gawk' provides (*note Controlling
+Scanning::), or the name of a user-defined function (*note Controlling
+Array Traversal::).
NOTE: In all cases, the sorted element values consist of the
original array's element values. The ability to control
@@ -20418,7 +20373,7 @@ There are three ways to get GNU software:
supported. If you have the `wget' program, you can use a command
like the following:
- wget http://ftp.gnu.org/gnu/gawk/gawk-4.0.0.tar.gz
+ wget http://ftp.gnu.org/gnu/gawk/gawk-4.0.1.tar.gz
The GNU software archive is mirrored around the world. The
up-to-date list of mirror sites is available from the main FSF web site
@@ -20437,26 +20392,26 @@ compression programs: `gzip', `bzip2', and `xz'. For
simplicity, the
rest of these instructions assume you are using the one compressed with
the GNU Zip program, `gzip'.
- Once you have the distribution (for example, `gawk-4.0.0.tar.gz'),
+ Once you have the distribution (for example, `gawk-4.0.1.tar.gz'),
use `gzip' to expand the file and then use `tar' to extract it. You
can use the following pipeline to produce the `gawk' distribution:
# Under System V, add 'o' to the tar options
- gzip -d -c gawk-4.0.0.tar.gz | tar -xvpf -
+ gzip -d -c gawk-4.0.1.tar.gz | tar -xvpf -
On a system with GNU `tar', you can let `tar' do the decompression
for you:
- tar -xvpzf gawk-4.0.0.tar.gz
+ tar -xvpzf gawk-4.0.1.tar.gz
-Extracting the archive creates a directory named `gawk-4.0.0' in the
+Extracting the archive creates a directory named `gawk-4.0.1' in the
current directory.
The distribution file name is of the form `gawk-V.R.P.tar.gz'. The
V represents the major version of `gawk', the R represents the current
release of version V, and the P represents a "patch level", meaning
that minor bugs have been fixed in the release. The current patch
-level is 0, but when retrieving distributions, you should get the
+level is 1, 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
@@ -20650,7 +20605,7 @@ Unix-derived systems, GNU/Linux, BSD-based systems, and
the Cygwin
environment for MS-Windows.
After you have extracted the `gawk' distribution, `cd' to
-`gawk-4.0.0'. Like most GNU software, `gawk' is configured
+`gawk-4.0.1'. Like most GNU software, `gawk' is configured
automatically for your system by running the `configure' program. This
program is a Bourne shell script that is generated automatically using
GNU `autoconf'. (The `autoconf' software is described fully starting
@@ -21060,8 +21015,8 @@ tools, such as Bash, the GNU Compiler Collection (GCC),
GNU Make, and
other GNU programs. Compilation and installation for Cygwin is the
same as for a Unix system:
- tar -xvpzf gawk-4.0.0.tar.gz
- cd gawk-4.0.0
+ tar -xvpzf gawk-4.0.1.tar.gz
+ cd gawk-4.0.1
./configure
make
@@ -25042,7 +24997,7 @@ Index
* arrays, sorting: Array Sorting Functions.
(line 6)
* arrays, sorting, IGNORECASE variable and: Array Sorting Functions.
- (line 80)
+ (line 81)
* arrays, sparse: Array Intro. (line 71)
* arrays, subscripts: Numeric Array Subscripts.
(line 6)
@@ -26087,7 +26042,7 @@ Index
* gawk, functions, adding: Dynamic Extensions. (line 10)
* gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42)
* gawk, IGNORECASE variable in <1>: Array Sorting Functions.
- (line 80)
+ (line 81)
* gawk, IGNORECASE variable in <2>: String Functions. (line 29)
* gawk, IGNORECASE variable in <3>: Array Intro. (line 92)
* gawk, IGNORECASE variable in <4>: User-modified. (line 82)
@@ -26247,13 +26202,13 @@ Index
* igawk.sh program: Igawk Program. (line 124)
* ignore debugger command: Breakpoint Control. (line 86)
* IGNORECASE variable <1>: Array Sorting Functions.
- (line 80)
+ (line 81)
* IGNORECASE variable <2>: String Functions. (line 29)
* 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 Functions.
- (line 80)
+ (line 81)
* IGNORECASE variable, array subscripts and: Array Intro. (line 92)
* IGNORECASE variable, in example programs: Library Functions.
(line 42)
@@ -26936,7 +26891,7 @@ Index
* redirection of input: Getline/File. (line 6)
* redirection of output: Redirection. (line 6)
* reference counting, sorting arrays: Array Sorting Functions.
- (line 74)
+ (line 75)
* regexp constants <1>: Comparison Operators.
(line 103)
* regexp constants <2>: Regexp Constants. (line 6)
@@ -27478,417 +27433,416 @@ Index
Tag Table:
Node: Top1346
-Node: Foreword33440
-Node: Preface37785
-Ref: Preface-Footnote-140838
-Ref: Preface-Footnote-240944
-Node: History41176
-Node: Names43567
-Ref: Names-Footnote-145044
-Node: This Manual45116
-Ref: This Manual-Footnote-150063
-Node: Conventions50163
-Node: Manual History52297
-Ref: Manual History-Footnote-155567
-Ref: Manual History-Footnote-255608
-Node: How To Contribute55682
-Node: Acknowledgments56826
-Node: Getting Started61157
-Node: Running gawk63536
-Node: One-shot64722
-Node: Read Terminal65947
-Ref: Read Terminal-Footnote-167597
-Ref: Read Terminal-Footnote-267873
-Node: Long68044
-Node: Executable Scripts69420
-Ref: Executable Scripts-Footnote-171289
-Ref: Executable Scripts-Footnote-271391
-Node: Comments71842
-Node: Quoting74309
-Node: DOS Quoting78932
-Node: Sample Data Files79607
-Node: Very Simple82639
-Node: Two Rules87238
-Node: More Complex89385
-Ref: More Complex-Footnote-192315
-Node: Statements/Lines92400
-Ref: Statements/Lines-Footnote-196862
-Node: Other Features97127
-Node: When98055
-Node: Invoking Gawk100202
-Node: Command Line101587
-Node: Options102370
-Ref: Options-Footnote-1115807
-Node: Other Arguments115832
-Node: Naming Standard Input118490
-Node: Environment Variables119584
-Node: AWKPATH Variable120028
-Ref: AWKPATH Variable-Footnote-1122625
-Node: Other Environment Variables122885
-Node: Exit Status125225
-Node: Include Files125900
-Node: Obsolete129385
-Node: Undocumented130071
-Node: Regexp130312
-Node: Regexp Usage131701
-Node: Escape Sequences133727
-Node: Regexp Operators139490
-Ref: Regexp Operators-Footnote-1146687
-Ref: Regexp Operators-Footnote-2146834
-Node: Bracket Expressions146932
-Ref: table-char-classes148822
-Node: GNU Regexp Operators151345
-Node: Case-sensitivity155068
-Ref: Case-sensitivity-Footnote-1158036
-Ref: Case-sensitivity-Footnote-2158271
-Node: Leftmost Longest158379
-Node: Computed Regexps159580
-Node: Reading Files162990
-Node: Records164931
-Ref: Records-Footnote-1173605
-Node: Fields173642
-Ref: Fields-Footnote-1176675
-Node: Nonconstant Fields176761
-Node: Changing Fields178963
-Node: Field Separators184941
-Node: Default Field Splitting187570
-Node: Regexp Field Splitting188687
-Node: Single Character Fields192029
-Node: Command Line Field Separator193088
-Node: Field Splitting Summary196529
-Ref: Field Splitting Summary-Footnote-1199721
-Node: Constant Size199822
-Node: Splitting By Content204406
-Ref: Splitting By Content-Footnote-1208132
-Node: Multiple Line208172
-Ref: Multiple Line-Footnote-1214019
-Node: Getline214198
-Node: Plain Getline216426
-Node: Getline/Variable218515
-Node: Getline/File219656
-Node: Getline/Variable/File220978
-Ref: Getline/Variable/File-Footnote-1222577
-Node: Getline/Pipe222664
-Node: Getline/Variable/Pipe225224
-Node: Getline/Coprocess226331
-Node: Getline/Variable/Coprocess227574
-Node: Getline Notes228288
-Node: Getline Summary230230
-Ref: table-getline-variants230573
-Node: Command line directories231429
-Node: Printing232054
-Node: Print233685
-Node: Print Examples235022
-Node: Output Separators237806
-Node: OFMT239566
-Node: Printf240924
-Node: Basic Printf241830
-Node: Control Letters243369
-Node: Format Modifiers247181
-Node: Printf Examples253190
-Node: Redirection255905
-Node: Special Files262889
-Node: Special FD263422
-Ref: Special FD-Footnote-1267047
-Node: Special Network267121
-Node: Special Caveats267971
-Node: Close Files And Pipes268767
-Ref: Close Files And Pipes-Footnote-1275790
-Ref: Close Files And Pipes-Footnote-2275938
-Node: Expressions276088
-Node: Values277220
-Node: Constants277896
-Node: Scalar Constants278576
-Ref: Scalar Constants-Footnote-1279435
-Node: Nondecimal-numbers279617
-Node: Regexp Constants282676
-Node: Using Constant Regexps283151
-Node: Variables286206
-Node: Using Variables286861
-Node: Assignment Options288585
-Node: Conversion290457
-Ref: table-locale-affects295833
-Ref: Conversion-Footnote-1296457
-Node: All Operators296566
-Node: Arithmetic Ops297196
-Node: Concatenation299701
-Ref: Concatenation-Footnote-1302494
-Node: Assignment Ops302614
-Ref: table-assign-ops307602
-Node: Increment Ops309010
-Node: Truth Values and Conditions312480
-Node: Truth Values313563
-Node: Typing and Comparison314612
-Node: Variable Typing315401
-Ref: Variable Typing-Footnote-1319298
-Node: Comparison Operators319420
-Ref: table-relational-ops319830
-Node: POSIX String Comparison323379
-Ref: POSIX String Comparison-Footnote-1324335
-Node: Boolean Ops324473
-Ref: Boolean Ops-Footnote-1328551
-Node: Conditional Exp328642
-Node: Function Calls330374
-Node: Precedence333968
-Node: Locales337637
-Node: Patterns and Actions338726
-Node: Pattern Overview339780
-Node: Regexp Patterns341446
-Node: Expression Patterns341989
-Node: Ranges345674
-Node: BEGIN/END348640
-Node: Using BEGIN/END349402
-Ref: Using BEGIN/END-Footnote-1352133
-Node: I/O And BEGIN/END352239
-Node: BEGINFILE/ENDFILE354521
-Node: Empty357414
-Node: Using Shell Variables357730
-Node: Action Overview360015
-Node: Statements362372
-Node: If Statement364226
-Node: While Statement365725
-Node: Do Statement367769
-Node: For Statement368925
-Node: Switch Statement372077
-Node: Break Statement374174
-Node: Continue Statement376164
-Node: Next Statement377951
-Node: Nextfile Statement380341
-Node: Exit Statement382886
-Node: Built-in Variables385302
-Node: User-modified386397
-Ref: User-modified-Footnote-1394423
-Node: Auto-set394485
-Ref: Auto-set-Footnote-1403776
-Node: ARGC and ARGV403981
-Node: Arrays407832
-Node: Array Basics409337
-Node: Array Intro410048
-Node: Reference to Elements414366
-Node: Assigning Elements416636
-Node: Array Example417127
-Node: Scanning an Array418859
-Node: Delete421525
-Ref: Delete-Footnote-1423960
-Node: Numeric Array Subscripts424017
-Node: Uninitialized Subscripts426200
-Node: Multi-dimensional427828
-Node: Multi-scanning430922
-Node: Arrays of Arrays432513
-Node: Functions437158
-Node: Built-in437980
-Node: Calling Built-in439058
-Node: Numeric Functions441046
-Ref: Numeric Functions-Footnote-1444811
-Ref: Numeric Functions-Footnote-2445168
-Ref: Numeric Functions-Footnote-3445216
-Node: String Functions445485
-Ref: String Functions-Footnote-1468982
-Ref: String Functions-Footnote-2469111
-Ref: String Functions-Footnote-3469359
-Node: Gory Details469446
-Ref: table-sub-escapes471125
-Ref: table-sub-posix-92472479
-Ref: table-sub-proposed473822
-Ref: table-posix-sub475172
-Ref: table-gensub-escapes476718
-Ref: Gory Details-Footnote-1477925
-Ref: Gory Details-Footnote-2477976
-Node: I/O Functions478127
-Ref: I/O Functions-Footnote-1484782
-Node: Time Functions484929
-Ref: Time Functions-Footnote-1495821
-Ref: Time Functions-Footnote-2495889
-Ref: Time Functions-Footnote-3496047
-Ref: Time Functions-Footnote-4496158
-Ref: Time Functions-Footnote-5496270
-Ref: Time Functions-Footnote-6496497
-Node: Bitwise Functions496763
-Ref: table-bitwise-ops497321
-Ref: Bitwise Functions-Footnote-1501481
-Node: Type Functions501665
-Node: I18N Functions502135
-Node: User-defined503762
-Node: Definition Syntax504566
-Ref: Definition Syntax-Footnote-1509476
-Node: Function Example509545
-Node: Function Caveats512139
-Node: Calling A Function512560
-Node: Variable Scope513675
-Node: Pass By Value/Reference515650
-Node: Return Statement519090
-Node: Dynamic Typing522071
-Node: Indirect Calls522806
-Node: Internationalization532491
-Node: I18N and L10N533917
-Node: Explaining gettext534603
-Ref: Explaining gettext-Footnote-1539669
-Ref: Explaining gettext-Footnote-2539853
-Node: Programmer i18n540018
-Node: Translator i18n544218
-Node: String Extraction545011
-Ref: String Extraction-Footnote-1545972
-Node: Printf Ordering546058
-Ref: Printf Ordering-Footnote-1548842
-Node: I18N Portability548906
-Ref: I18N Portability-Footnote-1551355
-Node: I18N Example551418
-Ref: I18N Example-Footnote-1554053
-Node: Gawk I18N554125
-Node: Advanced Features554742
-Node: Nondecimal Data556255
-Node: Array Sorting557838
-Node: Controlling Array Traversal558538
-Node: Controlling Scanning With A Function559285
-Node: Controlling Scanning566994
-Ref: Controlling Scanning-Footnote-1571648
-Node: Array Sorting Functions571964
-Ref: Array Sorting Functions-Footnote-1575613
-Ref: Array Sorting Functions-Footnote-2575706
-Node: Two-way I/O575900
-Ref: Two-way I/O-Footnote-1581332
-Node: TCP/IP Networking581402
-Node: Profiling584246
-Node: Library Functions591720
-Ref: Library Functions-Footnote-1594727
-Node: Library Names594898
-Ref: Library Names-Footnote-1598369
-Ref: Library Names-Footnote-2598589
-Node: General Functions598675
-Node: Strtonum Function599628
-Node: Assert Function602558
-Node: Round Function605884
-Node: Cliff Random Function607427
-Node: Ordinal Functions608443
-Ref: Ordinal Functions-Footnote-1611513
-Ref: Ordinal Functions-Footnote-2611765
-Node: Join Function611974
-Ref: Join Function-Footnote-1613745
-Node: Gettimeofday Function613945
-Node: Data File Management617660
-Node: Filetrans Function618292
-Node: Rewind Function622431
-Node: File Checking623818
-Node: Empty Files624912
-Node: Ignoring Assigns627142
-Node: Getopt Function628695
-Ref: Getopt Function-Footnote-1639999
-Node: Passwd Functions640202
-Ref: Passwd Functions-Footnote-1649177
-Node: Group Functions649265
-Node: Walking Arrays657349
-Node: Sample Programs658918
-Node: Running Examples659583
-Node: Clones660311
-Node: Cut Program661535
-Node: Egrep Program671380
-Ref: Egrep Program-Footnote-1679153
-Node: Id Program679263
-Node: Split Program682879
-Ref: Split Program-Footnote-1686398
-Node: Tee Program686526
-Node: Uniq Program689329
-Node: Wc Program696758
-Ref: Wc Program-Footnote-1701024
-Ref: Wc Program-Footnote-2701224
-Node: Miscellaneous Programs701316
-Node: Dupword Program702504
-Node: Alarm Program704535
-Node: Translate Program709284
-Ref: Translate Program-Footnote-1713671
-Ref: Translate Program-Footnote-2713899
-Node: Labels Program714033
-Ref: Labels Program-Footnote-1717404
-Node: Word Sorting717488
-Node: History Sorting721372
-Node: Extract Program723211
-Ref: Extract Program-Footnote-1730694
-Node: Simple Sed730822
-Node: Igawk Program733884
-Ref: Igawk Program-Footnote-1749041
-Ref: Igawk Program-Footnote-2749242
-Node: Anagram Program749380
-Node: Signature Program752448
-Node: Debugger753548
-Node: Debugging754459
-Node: Debugging Concepts754872
-Node: Debugging Terms756728
-Node: Awk Debugging759351
-Node: Sample dgawk session760243
-Node: dgawk invocation760735
-Node: Finding The Bug761917
-Node: List of Debugger Commands768403
-Node: Breakpoint Control769714
-Node: Dgawk Execution Control773350
-Node: Viewing And Changing Data776701
-Node: Dgawk Stack780038
-Node: Dgawk Info781498
-Node: Miscellaneous Dgawk Commands785446
-Node: Readline Support790874
-Node: Dgawk Limitations791712
-Node: Language History793901
-Node: V7/SVR3.1795413
-Node: SVR4797734
-Node: POSIX799176
-Node: BTL800184
-Node: POSIX/GNU800918
-Node: Common Extensions806069
-Node: Ranges and Locales807176
-Ref: Ranges and Locales-Footnote-1811783
-Node: Contributors812004
-Node: Installation816266
-Node: Gawk Distribution817160
-Node: Getting817644
-Node: Extracting818470
-Node: Distribution contents820162
-Node: Unix Installation825384
-Node: Quick Installation826001
-Node: Additional Configuration Options827963
-Node: Configuration Philosophy829440
-Node: Non-Unix Installation831782
-Node: PC Installation832240
-Node: PC Binary Installation833539
-Node: PC Compiling835387
-Node: PC Testing838331
-Node: PC Using839507
-Node: Cygwin843692
-Node: MSYS844692
-Node: VMS Installation845206
-Node: VMS Compilation845809
-Ref: VMS Compilation-Footnote-1846816
-Node: VMS Installation Details846874
-Node: VMS Running848509
-Node: VMS Old Gawk850116
-Node: Bugs850590
-Node: Other Versions854442
-Node: Notes859723
-Node: Compatibility Mode860415
-Node: Additions861198
-Node: Accessing The Source862010
-Node: Adding Code863435
-Node: New Ports869402
-Node: Dynamic Extensions873515
-Node: Internals874891
-Node: Plugin License883994
-Node: Sample Library884628
-Node: Internal File Description885314
-Node: Internal File Ops889029
-Ref: Internal File Ops-Footnote-1893810
-Node: Using Internal File Ops893950
-Node: Future Extensions896327
-Node: Basic Concepts898831
-Node: Basic High Level899588
-Ref: Basic High Level-Footnote-1903623
-Node: Basic Data Typing903808
-Node: Floating Point Issues908333
-Node: String Conversion Precision909416
-Ref: String Conversion Precision-Footnote-1911116
-Node: Unexpected Results911225
-Node: POSIX Floating Point Problems913051
-Ref: POSIX Floating Point Problems-Footnote-1916756
-Node: Glossary916794
-Node: Copying941770
-Node: GNU Free Documentation License979327
-Node: Index1004464
+Node: Foreword30270
+Node: Preface34615
+Ref: Preface-Footnote-137668
+Ref: Preface-Footnote-237774
+Node: History38006
+Node: Names40397
+Ref: Names-Footnote-141874
+Node: This Manual41946
+Ref: This Manual-Footnote-146893
+Node: Conventions46993
+Node: Manual History49127
+Ref: Manual History-Footnote-152397
+Ref: Manual History-Footnote-252438
+Node: How To Contribute52512
+Node: Acknowledgments53656
+Node: Getting Started57987
+Node: Running gawk60366
+Node: One-shot61552
+Node: Read Terminal62777
+Ref: Read Terminal-Footnote-164427
+Ref: Read Terminal-Footnote-264703
+Node: Long64874
+Node: Executable Scripts66250
+Ref: Executable Scripts-Footnote-168119
+Ref: Executable Scripts-Footnote-268221
+Node: Comments68672
+Node: Quoting71139
+Node: DOS Quoting75762
+Node: Sample Data Files76437
+Node: Very Simple79469
+Node: Two Rules84068
+Node: More Complex86215
+Ref: More Complex-Footnote-189145
+Node: Statements/Lines89230
+Ref: Statements/Lines-Footnote-193692
+Node: Other Features93957
+Node: When94885
+Node: Invoking Gawk97032
+Node: Command Line98417
+Node: Options99200
+Ref: Options-Footnote-1112637
+Node: Other Arguments112662
+Node: Naming Standard Input115320
+Node: Environment Variables116414
+Node: AWKPATH Variable116858
+Ref: AWKPATH Variable-Footnote-1119455
+Node: Other Environment Variables119715
+Node: Exit Status122055
+Node: Include Files122730
+Node: Obsolete126215
+Node: Undocumented126901
+Node: Regexp127142
+Node: Regexp Usage128531
+Node: Escape Sequences130557
+Node: Regexp Operators136320
+Ref: Regexp Operators-Footnote-1143517
+Ref: Regexp Operators-Footnote-2143664
+Node: Bracket Expressions143762
+Ref: table-char-classes145652
+Node: GNU Regexp Operators148175
+Node: Case-sensitivity151898
+Ref: Case-sensitivity-Footnote-1154866
+Ref: Case-sensitivity-Footnote-2155101
+Node: Leftmost Longest155209
+Node: Computed Regexps156410
+Node: Reading Files159820
+Node: Records161761
+Ref: Records-Footnote-1170435
+Node: Fields170472
+Ref: Fields-Footnote-1173505
+Node: Nonconstant Fields173591
+Node: Changing Fields175793
+Node: Field Separators181771
+Node: Default Field Splitting184400
+Node: Regexp Field Splitting185517
+Node: Single Character Fields188859
+Node: Command Line Field Separator189918
+Node: Field Splitting Summary193359
+Ref: Field Splitting Summary-Footnote-1196551
+Node: Constant Size196652
+Node: Splitting By Content201236
+Ref: Splitting By Content-Footnote-1204962
+Node: Multiple Line205002
+Ref: Multiple Line-Footnote-1210849
+Node: Getline211028
+Node: Plain Getline213256
+Node: Getline/Variable215345
+Node: Getline/File216486
+Node: Getline/Variable/File217808
+Ref: Getline/Variable/File-Footnote-1219407
+Node: Getline/Pipe219494
+Node: Getline/Variable/Pipe222054
+Node: Getline/Coprocess223161
+Node: Getline/Variable/Coprocess224404
+Node: Getline Notes225118
+Node: Getline Summary227060
+Ref: table-getline-variants227403
+Node: Command line directories228259
+Node: Printing228884
+Node: Print230515
+Node: Print Examples231852
+Node: Output Separators234636
+Node: OFMT236396
+Node: Printf237754
+Node: Basic Printf238660
+Node: Control Letters240199
+Node: Format Modifiers244011
+Node: Printf Examples250020
+Node: Redirection252735
+Node: Special Files259719
+Node: Special FD260252
+Ref: Special FD-Footnote-1263877
+Node: Special Network263951
+Node: Special Caveats264801
+Node: Close Files And Pipes265597
+Ref: Close Files And Pipes-Footnote-1272620
+Ref: Close Files And Pipes-Footnote-2272768
+Node: Expressions272918
+Node: Values274050
+Node: Constants274726
+Node: Scalar Constants275406
+Ref: Scalar Constants-Footnote-1276265
+Node: Nondecimal-numbers276447
+Node: Regexp Constants279506
+Node: Using Constant Regexps279981
+Node: Variables283036
+Node: Using Variables283691
+Node: Assignment Options285415
+Node: Conversion287287
+Ref: table-locale-affects292663
+Ref: Conversion-Footnote-1293287
+Node: All Operators293396
+Node: Arithmetic Ops294026
+Node: Concatenation296531
+Ref: Concatenation-Footnote-1299324
+Node: Assignment Ops299444
+Ref: table-assign-ops304432
+Node: Increment Ops305840
+Node: Truth Values and Conditions309310
+Node: Truth Values310393
+Node: Typing and Comparison311442
+Node: Variable Typing312231
+Ref: Variable Typing-Footnote-1316128
+Node: Comparison Operators316250
+Ref: table-relational-ops316660
+Node: POSIX String Comparison320209
+Ref: POSIX String Comparison-Footnote-1321165
+Node: Boolean Ops321303
+Ref: Boolean Ops-Footnote-1325381
+Node: Conditional Exp325472
+Node: Function Calls327204
+Node: Precedence330798
+Node: Locales334467
+Node: Patterns and Actions335556
+Node: Pattern Overview336610
+Node: Regexp Patterns338276
+Node: Expression Patterns338819
+Node: Ranges342504
+Node: BEGIN/END345470
+Node: Using BEGIN/END346232
+Ref: Using BEGIN/END-Footnote-1348963
+Node: I/O And BEGIN/END349069
+Node: BEGINFILE/ENDFILE351351
+Node: Empty354244
+Node: Using Shell Variables354560
+Node: Action Overview356845
+Node: Statements359202
+Node: If Statement361056
+Node: While Statement362555
+Node: Do Statement364599
+Node: For Statement365755
+Node: Switch Statement368907
+Node: Break Statement371004
+Node: Continue Statement372994
+Node: Next Statement374781
+Node: Nextfile Statement377171
+Node: Exit Statement379716
+Node: Built-in Variables382132
+Node: User-modified383227
+Ref: User-modified-Footnote-1391253
+Node: Auto-set391315
+Ref: Auto-set-Footnote-1400606
+Node: ARGC and ARGV400811
+Node: Arrays404662
+Node: Array Basics406167
+Node: Array Intro406993
+Node: Reference to Elements411311
+Node: Assigning Elements413581
+Node: Array Example414072
+Node: Scanning an Array415804
+Node: Controlling Scanning418118
+Ref: Controlling Scanning-Footnote-1423050
+Node: Delete423366
+Ref: Delete-Footnote-1425801
+Node: Numeric Array Subscripts425858
+Node: Uninitialized Subscripts428041
+Node: Multi-dimensional429669
+Node: Multi-scanning432763
+Node: Arrays of Arrays434354
+Node: Functions438999
+Node: Built-in439821
+Node: Calling Built-in440899
+Node: Numeric Functions442887
+Ref: Numeric Functions-Footnote-1446652
+Ref: Numeric Functions-Footnote-2447009
+Ref: Numeric Functions-Footnote-3447057
+Node: String Functions447326
+Ref: String Functions-Footnote-1470823
+Ref: String Functions-Footnote-2470952
+Ref: String Functions-Footnote-3471200
+Node: Gory Details471287
+Ref: table-sub-escapes472966
+Ref: table-sub-posix-92474320
+Ref: table-sub-proposed475663
+Ref: table-posix-sub477013
+Ref: table-gensub-escapes478559
+Ref: Gory Details-Footnote-1479766
+Ref: Gory Details-Footnote-2479817
+Node: I/O Functions479968
+Ref: I/O Functions-Footnote-1486623
+Node: Time Functions486770
+Ref: Time Functions-Footnote-1497662
+Ref: Time Functions-Footnote-2497730
+Ref: Time Functions-Footnote-3497888
+Ref: Time Functions-Footnote-4497999
+Ref: Time Functions-Footnote-5498111
+Ref: Time Functions-Footnote-6498338
+Node: Bitwise Functions498604
+Ref: table-bitwise-ops499162
+Ref: Bitwise Functions-Footnote-1503322
+Node: Type Functions503506
+Node: I18N Functions503976
+Node: User-defined505603
+Node: Definition Syntax506407
+Ref: Definition Syntax-Footnote-1511317
+Node: Function Example511386
+Node: Function Caveats513980
+Node: Calling A Function514401
+Node: Variable Scope515516
+Node: Pass By Value/Reference517491
+Node: Return Statement520931
+Node: Dynamic Typing523912
+Node: Indirect Calls524647
+Node: Internationalization534332
+Node: I18N and L10N535758
+Node: Explaining gettext536444
+Ref: Explaining gettext-Footnote-1541510
+Ref: Explaining gettext-Footnote-2541694
+Node: Programmer i18n541859
+Node: Translator i18n546059
+Node: String Extraction546852
+Ref: String Extraction-Footnote-1547813
+Node: Printf Ordering547899
+Ref: Printf Ordering-Footnote-1550683
+Node: I18N Portability550747
+Ref: I18N Portability-Footnote-1553196
+Node: I18N Example553259
+Ref: I18N Example-Footnote-1555894
+Node: Gawk I18N555966
+Node: Advanced Features556583
+Node: Nondecimal Data558096
+Node: Array Sorting559679
+Node: Controlling Array Traversal560376
+Node: Array Sorting Functions568613
+Ref: Array Sorting Functions-Footnote-1572287
+Ref: Array Sorting Functions-Footnote-2572380
+Node: Two-way I/O572574
+Ref: Two-way I/O-Footnote-1578006
+Node: TCP/IP Networking578076
+Node: Profiling580920
+Node: Library Functions588394
+Ref: Library Functions-Footnote-1591401
+Node: Library Names591572
+Ref: Library Names-Footnote-1595043
+Ref: Library Names-Footnote-2595263
+Node: General Functions595349
+Node: Strtonum Function596302
+Node: Assert Function599232
+Node: Round Function602558
+Node: Cliff Random Function604101
+Node: Ordinal Functions605117
+Ref: Ordinal Functions-Footnote-1608187
+Ref: Ordinal Functions-Footnote-2608439
+Node: Join Function608648
+Ref: Join Function-Footnote-1610419
+Node: Gettimeofday Function610619
+Node: Data File Management614334
+Node: Filetrans Function614966
+Node: Rewind Function619105
+Node: File Checking620492
+Node: Empty Files621586
+Node: Ignoring Assigns623816
+Node: Getopt Function625369
+Ref: Getopt Function-Footnote-1636673
+Node: Passwd Functions636876
+Ref: Passwd Functions-Footnote-1645851
+Node: Group Functions645939
+Node: Walking Arrays654023
+Node: Sample Programs655592
+Node: Running Examples656257
+Node: Clones656985
+Node: Cut Program658209
+Node: Egrep Program668054
+Ref: Egrep Program-Footnote-1675827
+Node: Id Program675937
+Node: Split Program679553
+Ref: Split Program-Footnote-1683072
+Node: Tee Program683200
+Node: Uniq Program686003
+Node: Wc Program693432
+Ref: Wc Program-Footnote-1697698
+Ref: Wc Program-Footnote-2697898
+Node: Miscellaneous Programs697990
+Node: Dupword Program699178
+Node: Alarm Program701209
+Node: Translate Program705958
+Ref: Translate Program-Footnote-1710345
+Ref: Translate Program-Footnote-2710573
+Node: Labels Program710707
+Ref: Labels Program-Footnote-1714078
+Node: Word Sorting714162
+Node: History Sorting718046
+Node: Extract Program719885
+Ref: Extract Program-Footnote-1727368
+Node: Simple Sed727496
+Node: Igawk Program730558
+Ref: Igawk Program-Footnote-1745715
+Ref: Igawk Program-Footnote-2745916
+Node: Anagram Program746054
+Node: Signature Program749122
+Node: Debugger750222
+Node: Debugging751133
+Node: Debugging Concepts751546
+Node: Debugging Terms753402
+Node: Awk Debugging756025
+Node: Sample dgawk session756917
+Node: dgawk invocation757409
+Node: Finding The Bug758591
+Node: List of Debugger Commands765077
+Node: Breakpoint Control766388
+Node: Dgawk Execution Control770024
+Node: Viewing And Changing Data773375
+Node: Dgawk Stack776712
+Node: Dgawk Info778172
+Node: Miscellaneous Dgawk Commands782120
+Node: Readline Support787548
+Node: Dgawk Limitations788386
+Node: Language History790575
+Node: V7/SVR3.1792087
+Node: SVR4794408
+Node: POSIX795850
+Node: BTL796858
+Node: POSIX/GNU797592
+Node: Common Extensions802743
+Node: Ranges and Locales803850
+Ref: Ranges and Locales-Footnote-1808457
+Node: Contributors808678
+Node: Installation812940
+Node: Gawk Distribution813834
+Node: Getting814318
+Node: Extracting815144
+Node: Distribution contents816836
+Node: Unix Installation822058
+Node: Quick Installation822675
+Node: Additional Configuration Options824637
+Node: Configuration Philosophy826114
+Node: Non-Unix Installation828456
+Node: PC Installation828914
+Node: PC Binary Installation830213
+Node: PC Compiling832061
+Node: PC Testing835005
+Node: PC Using836181
+Node: Cygwin840366
+Node: MSYS841366
+Node: VMS Installation841880
+Node: VMS Compilation842483
+Ref: VMS Compilation-Footnote-1843490
+Node: VMS Installation Details843548
+Node: VMS Running845183
+Node: VMS Old Gawk846790
+Node: Bugs847264
+Node: Other Versions851116
+Node: Notes856397
+Node: Compatibility Mode857089
+Node: Additions857872
+Node: Accessing The Source858684
+Node: Adding Code860109
+Node: New Ports866076
+Node: Dynamic Extensions870189
+Node: Internals871565
+Node: Plugin License880668
+Node: Sample Library881302
+Node: Internal File Description881988
+Node: Internal File Ops885703
+Ref: Internal File Ops-Footnote-1890484
+Node: Using Internal File Ops890624
+Node: Future Extensions893001
+Node: Basic Concepts895505
+Node: Basic High Level896262
+Ref: Basic High Level-Footnote-1900297
+Node: Basic Data Typing900482
+Node: Floating Point Issues905007
+Node: String Conversion Precision906090
+Ref: String Conversion Precision-Footnote-1907790
+Node: Unexpected Results907899
+Node: POSIX Floating Point Problems909725
+Ref: POSIX Floating Point Problems-Footnote-1913430
+Node: Glossary913468
+Node: Copying938444
+Node: GNU Free Documentation License976001
+Node: Index1001138
End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index fa145bb..dfd6dd8 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -20,9 +20,9 @@
@c applies to and all the info about who's publishing this edition
@c These apply across the board.
address@hidden UPDATE-MONTH June, 2011
address@hidden UPDATE-MONTH November, 2011
@set VERSION 4.0
address@hidden PATCHLEVEL 0
address@hidden PATCHLEVEL 1
@set FSF
@@ -306,439 +306,399 @@ particular records in a file and perform operations
upon them.
* Index:: Concept and Variable Index.
@detailmenu
-* History:: The history of @command{gawk} and
- @command{awk}.
-* Names:: What name to use to find @command{awk}.
-* This Manual:: Using this @value{DOCUMENT}. Includes
- sample input files that you can use.
-* Conventions:: Typographical Conventions.
-* Manual History:: Brief history of the GNU project and
- this @value{DOCUMENT}.
-* How To Contribute:: Helping to save the world.
-* Acknowledgments:: Acknowledgments.
-* Running gawk:: How to run @command{gawk} programs;
- includes command-line syntax.
-* One-shot:: Running a short throwaway @command{awk}
- program.
-* Read Terminal:: Using no input files (input from
- terminal instead).
-* Long:: Putting permanent @command{awk}
- programs in files.
-* Executable Scripts:: Making self-contained @command{awk}
- programs.
-* Comments:: Adding documentation to @command{gawk}
- programs.
-* Quoting:: More discussion of shell quoting
- issues.
-* DOS Quoting:: Quoting in Windows Batch Files.
-* Sample Data Files:: Sample data files for use in the
- @command{awk} programs illustrated in
- this @value{DOCUMENT}.
-* Very Simple:: A very simple example.
-* Two Rules:: A less simple one-line example using
- two rules.
-* More Complex:: A more complex example.
-* Statements/Lines:: Subdividing or combining statements
- into lines.
-* Other Features:: Other Features of @command{awk}.
-* When:: When to use @command{gawk} and when to
- use other things.
-* Command Line:: How to run @command{awk}.
-* Options:: Command-line options and their
- meanings.
-* Other Arguments:: Input file names and variable
- assignments.
-* Naming Standard Input:: How to specify standard input with
- other files.
-* Environment Variables:: The environment variables
- @command{gawk} uses.
-* AWKPATH Variable:: Searching directories for @command{awk}
- programs.
-* Other Environment Variables:: The environment variables.
-* Exit Status:: @command{gawk}'s exit status.
-* Include Files:: Including other files into your
- program.
-* Obsolete:: Obsolete Options and/or features.
-* Undocumented:: Undocumented Options and Features.
-* Regexp Usage:: How to Use Regular Expressions.
-* Escape Sequences:: How to write nonprinting characters.
-* Regexp Operators:: Regular Expression Operators.
-* 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.
-* Computed Regexps:: Using Dynamic Regexps.
-* Records:: Controlling how data is split into
- records.
-* Fields:: An introduction to fields.
-* Nonconstant Fields:: Nonconstant Field Numbers.
-* Changing Fields:: Changing the Contents of a Field.
-* Field Separators:: The field separator and how to change
- it.
-* Default Field Splitting:: How fields are normally separated.
-* Regexp Field Splitting:: Using regexps as the field separator.
-* Single Character Fields:: Making each character a separate field.
-* Command Line Field Separator:: Setting @code{FS} from the
- command-line.
-* Field Splitting Summary:: Some final points and a summary table.
-* Constant Size:: Reading constant width data.
-* Splitting By Content:: Defining Fields By Content
-* Multiple Line:: Reading multi-line records.
-* Getline:: Reading files under explicit program
- control using the @code{getline}
- function.
-* Plain Getline:: Using @code{getline} with no arguments.
-* Getline/Variable:: Using @code{getline} into a variable.
-* Getline/File:: Using @code{getline} from a file.
-* Getline/Variable/File:: Using @code{getline} into a variable
- from a file.
-* Getline/Pipe:: Using @code{getline} from a pipe.
-* Getline/Variable/Pipe:: Using @code{getline} into a variable
- from a pipe.
-* Getline/Coprocess:: Using @code{getline} from a coprocess.
-* Getline/Variable/Coprocess:: Using @code{getline} into a variable
- from a coprocess.
-* Getline Notes:: Important things to know about
- @code{getline}.
-* Getline Summary:: Summary of @code{getline} Variants.
-* Command line directories:: What happens if you put a directory on
- the command line.
-* Print:: The @code{print} statement.
-* Print Examples:: Simple examples of @code{print}
- statements.
-* Output Separators:: The output separators and how to change
- them.
-* OFMT:: Controlling Numeric Output With
- @code{print}.
-* Printf:: The @code{printf} statement.
-* Basic Printf:: Syntax of the @code{printf} statement.
-* Control Letters:: Format-control letters.
-* Format Modifiers:: Format-specification modifiers.
-* Printf Examples:: Several examples.
-* Redirection:: How to redirect output to multiple
- files and pipes.
-* Special Files:: File name interpretation in
- @command{gawk}. @command{gawk} allows
- access to inherited file descriptors.
-* Special FD:: Special files for I/O.
-* Special Network:: Special files for network
- communications.
-* Special Caveats:: Things to watch out for.
-* Close Files And Pipes:: Closing Input and Output Files and
- Pipes.
-* Values:: Constants, Variables, and Regular
- Expressions.
-* Constants:: String, numeric and regexp constants.
-* Scalar Constants:: Numeric and string constants.
-* Nondecimal-numbers:: What are octal and hex numbers.
-* Regexp Constants:: Regular Expression constants.
-* Using Constant Regexps:: When and how to use a regexp constant.
-* Variables:: Variables give names to values for
- later use.
-* Using Variables:: Using variables in your programs.
-* Assignment Options:: Setting variables on the command-line
- and a summary of command-line syntax.
- This is an advanced method of input.
-* Conversion:: The conversion of strings to numbers
- and vice versa.
-* All Operators:: @command{gawk}'s operators.
-* Arithmetic Ops:: Arithmetic operations (@samp{+},
- @samp{-}, etc.)
-* Concatenation:: Concatenating strings.
-* Assignment Ops:: Changing the value of a variable or a
- field.
-* Increment Ops:: Incrementing the numeric value of a
- variable.
-* Truth Values and Conditions:: Testing for true and false.
-* Truth Values:: What is ``true'' and what is ``false''.
-* Typing and Comparison:: How variables acquire types and how
- this affects comparison of numbers and
- strings with @samp{<}, etc.
-* Variable Typing:: String type versus numeric type.
-* Comparison Operators:: The comparison operators.
-* POSIX String Comparison:: String comparison with POSIX rules.
-* Boolean Ops:: Combining comparison expressions using
- boolean operators @samp{||} (``or''),
- @samp{&&} (``and'') and @samp{!}
- (``not'').
-* Conditional Exp:: Conditional expressions select between
- two subexpressions under control of a
- third subexpression.
-* Function Calls:: A function call is an expression.
-* Precedence:: How various operators nest.
-* Locales:: How the locale affects things.
-* Pattern Overview:: What goes into a pattern.
-* Regexp Patterns:: Using regexps as patterns.
-* Expression Patterns:: Any expression can be used as a
- pattern.
-* Ranges:: Pairs of patterns specify record
- ranges.
-* BEGIN/END:: Specifying initialization and cleanup
- rules.
-* Using BEGIN/END:: How and why to use BEGIN/END rules.
-* I/O And BEGIN/END:: I/O issues in BEGIN/END rules.
-* BEGINFILE/ENDFILE:: Two special patterns for advanced
- control.
-* Empty:: The empty pattern, which matches every
- record.
-* Using Shell Variables:: How to use shell variables with
- @command{awk}.
-* Action Overview:: What goes into an action.
-* Statements:: Describes the various control
- statements in detail.
-* If Statement:: Conditionally execute some
- @command{awk} statements.
-* While Statement:: Loop until some condition is satisfied.
-* Do Statement:: Do specified action while looping until
- some condition is satisfied.
-* For Statement:: Another looping statement, that
- provides initialization and increment
- clauses.
-* Switch Statement:: Switch/case evaluation for conditional
- execution of statements based on a
- value.
-* Break Statement:: Immediately exit the innermost
- enclosing loop.
-* Continue Statement:: Skip to the end of the innermost
- enclosing loop.
-* Next Statement:: Stop processing the current input
- record.
-* Nextfile Statement:: Stop processing the current file.
-* Exit Statement:: Stop execution of @command{awk}.
-* Built-in Variables:: Summarizes the built-in variables.
-* User-modified:: Built-in variables that you change to
- control @command{awk}.
-* Auto-set:: Built-in variables where @command{awk}
- gives you information.
-* ARGC and ARGV:: Ways to use @code{ARGC} and
- @code{ARGV}.
-* Array Basics:: The basics of arrays.
-* Array Intro:: Introduction to Arrays
-* Reference to Elements:: How to examine one element of an array.
-* Assigning Elements:: How to change an element of an array.
-* Array Example:: Basic Example of an Array
-* Scanning an Array:: A variation of the @code{for}
- statement. It loops through the indices
- of an array's existing elements.
-* Delete:: The @code{delete} statement removes an
- element from an array.
-* Numeric Array Subscripts:: How to use numbers as subscripts in
- @command{awk}.
-* Uninitialized Subscripts:: Using Uninitialized variables as
- subscripts.
-* Multi-dimensional:: Emulating multidimensional arrays in
- @command{awk}.
-* Multi-scanning:: Scanning multidimensional arrays.
-* Arrays of Arrays:: True multidimensional arrays.
-* Built-in:: Summarizes the built-in functions.
-* Calling Built-in:: How to call built-in functions.
-* Numeric Functions:: Functions that work with numbers,
- including @code{int()}, @code{sin()}
- and @code{rand()}.
-* String Functions:: Functions for string manipulation, such
- as @code{split()}, @code{match()} and
- @code{sprintf()}.
-* Gory Details:: More than you want to know about
- @samp{\} and @samp{&} with
- @code{sub()}, @code{gsub()}, and
- @code{gensub()}.
-* I/O Functions:: Functions for files and shell commands.
-* Time Functions:: Functions for dealing with timestamps.
-* Bitwise Functions:: Functions for bitwise operations.
-* Type Functions:: Functions for type information.
-* I18N Functions:: Functions for string translation.
-* User-defined:: Describes User-defined functions in
- detail.
-* Definition Syntax:: How to write definitions and what they
- mean.
-* Function Example:: An example function definition and what
- it does.
-* Function Caveats:: Things to watch out for.
-* Calling A Function:: Don't use spaces.
-* Variable Scope:: Controlling variable scope.
-* Pass By Value/Reference:: Passing parameters.
-* Return Statement:: Specifying the value a function
- returns.
-* Dynamic Typing:: How variable types can change at
- runtime.
-* Indirect Calls:: Choosing the function to call at
- runtime.
-* I18N and L10N:: Internationalization and Localization.
-* Explaining gettext:: How GNU @code{gettext} works.
-* Programmer i18n:: Features for the programmer.
-* Translator i18n:: Features for the translator.
-* String Extraction:: Extracting marked strings.
-* Printf Ordering:: Rearranging @code{printf} arguments.
-* I18N Portability:: @command{awk}-level portability issues.
-* I18N Example:: A simple i18n example.
-* Gawk I18N:: @command{gawk} is also
- internationalized.
-* Nondecimal Data:: Allowing nondecimal input data.
-* Array Sorting:: Facilities for controlling array
- traversal and sorting arrays.
-* Controlling Array Traversal:: How to use PROCINFO["sorted_in"].
-* Controlling Scanning With A Function:: Using a function to control scanning.
-* Controlling Scanning:: Controlling the order in which arrays
- are scanned.
-* Array Sorting Functions:: How to use @code{asort()} and
- @code{asorti()}.
-* Two-way I/O:: Two-way communications with another
- process.
-* TCP/IP Networking:: Using @command{gawk} for network
- programming.
-* Profiling:: Profiling your @command{awk} programs.
-* Library Names:: How to best name private global
- variables in library functions.
-* General Functions:: Functions that are of general use.
-* Strtonum Function:: A replacement for the built-in
- @code{strtonum()} function.
-* Assert Function:: A function for assertions in
- @command{awk} programs.
-* Round Function:: A function for rounding if
- @code{sprintf()} does not do it
- correctly.
-* Cliff Random Function:: The Cliff Random Number Generator.
-* Ordinal Functions:: Functions for using characters as
- numbers and vice versa.
-* Join Function:: A function to join an array into a
- string.
-* Gettimeofday Function:: A function to get formatted times.
-* Data File Management:: Functions for managing command-line
- data files.
-* Filetrans Function:: A function for handling data file
- transitions.
-* Rewind Function:: A function for rereading the current
- file.
-* File Checking:: Checking that data files are readable.
-* Empty Files:: Checking for zero-length files.
-* Ignoring Assigns:: Treating assignments as file names.
-* Getopt Function:: A function for processing command-line
- arguments.
-* Passwd Functions:: Functions for getting user information.
-* Group Functions:: Functions for getting group
- information.
-* Walking Arrays:: A function to walk arrays of arrays.
-* Running Examples:: How to run these examples.
-* Clones:: Clones of common utilities.
-* Cut Program:: The @command{cut} utility.
-* Egrep Program:: The @command{egrep} utility.
-* Id Program:: The @command{id} utility.
-* Split Program:: The @command{split} utility.
-* Tee Program:: The @command{tee} utility.
-* Uniq Program:: The @command{uniq} utility.
-* Wc Program:: The @command{wc} utility.
-* Miscellaneous Programs:: Some interesting @command{awk}
- programs.
-* Dupword Program:: Finding duplicated words in a document.
-* Alarm Program:: An alarm clock.
-* Translate Program:: A program similar to the @command{tr}
- utility.
-* Labels Program:: Printing mailing labels.
-* Word Sorting:: A program to produce a word usage
- count.
-* History Sorting:: Eliminating duplicate entries from a
- history file.
-* Extract Program:: Pulling out programs from Texinfo
- source files.
-* Simple Sed:: A Simple Stream Editor.
-* Igawk Program:: A wrapper for @command{awk} that
- includes files.
-* Anagram Program:: Finding anagrams from a dictionary.
-* Signature Program:: People do amazing things with too much
- time on their hands.
-* Debugging:: Introduction to @command{dgawk}.
-* Debugging Concepts:: Debugging In General.
-* Debugging Terms:: Additional Debugging Concepts.
-* Awk Debugging:: Awk Debugging.
-* Sample dgawk session:: Sample @command{dgawk} session.
-* dgawk invocation:: @command{dgawk} Invocation.
-* Finding The Bug:: Finding The Bug.
-* List of Debugger Commands:: Main @command{dgawk} Commands.
-* Breakpoint Control:: Control of breakpoints.
-* Dgawk Execution Control:: Control of execution.
-* Viewing And Changing Data:: Viewing and changing data.
-* Dgawk Stack:: Dealing with the stack.
-* Dgawk Info:: Obtaining information about the program
- and the debugger state.
-* Miscellaneous Dgawk Commands:: Miscellaneous Commands.
-* Readline Support:: Readline Support.
-* Dgawk Limitations:: Limitations and future plans.
-* V7/SVR3.1:: The major changes between V7 and System
- V Release 3.1.
-* SVR4:: Minor changes between System V Releases
- 3.1 and 4.
-* POSIX:: New features from the POSIX standard.
-* BTL:: New features from Brian Kernighan's
- version of @command{awk}.
-* POSIX/GNU:: The extensions in @command{gawk} not in
- POSIX @command{awk}.
-* Common Extensions:: Common Extensions Summary.
-* Ranges and Locales:: How locales used to affect regexp
- ranges.
-* Contributors:: The major contributors to
- @command{gawk}.
-* Gawk Distribution:: What is in the @command{gawk}
- distribution.
-* Getting:: How to get the distribution.
-* Extracting:: How to extract the distribution.
-* Distribution contents:: What is in the distribution.
-* Unix Installation:: Installing @command{gawk} under various
- versions of Unix.
-* Quick Installation:: Compiling @command{gawk} under Unix.
-* Additional Configuration Options:: Other compile-time options.
-* Configuration Philosophy:: How it's all supposed to work.
-* Non-Unix Installation:: Installation on Other Operating
- Systems.
-* PC Installation:: Installing and Compiling @command{gawk}
- on MS-DOS and OS/2.
-* PC Binary Installation:: Installing a prepared distribution.
-* PC Compiling:: Compiling @command{gawk} for MS-DOS,
- Windows32, and OS/2.
-* PC Testing:: Testing @command{gawk} on PC systems.
-* PC Using:: Running @command{gawk} on MS-DOS,
- Windows32 and OS/2.
-* Cygwin:: Building and running @command{gawk} for
- Cygwin.
-* MSYS:: Using @command{gawk} In The MSYS
- Environment.
-* VMS Installation:: Installing @command{gawk} on VMS.
-* VMS Compilation:: How to compile @command{gawk} under
- VMS.
-* VMS Installation Details:: How to install @command{gawk} under
- VMS.
-* VMS Running:: How to run @command{gawk} under VMS.
-* VMS Old Gawk:: An old version comes with some VMS
- systems.
-* Bugs:: Reporting Problems and Bugs.
-* Other Versions:: Other freely available @command{awk}
- implementations.
-* Compatibility Mode:: How to disable certain @command{gawk}
- extensions.
-* Additions:: Making Additions To @command{gawk}.
-* Accessing The Source:: Accessing the Git repository.
-* Adding Code:: Adding code to the main body of
- @command{gawk}.
-* New Ports:: Porting @command{gawk} to a new
- operating system.
-* Dynamic Extensions:: Adding new built-in functions to
- @command{gawk}.
-* Internals:: A brief look at some @command{gawk}
- internals.
-* Plugin License:: A note about licensing.
-* Sample Library:: A example of new functions.
-* Internal File Description:: What the new functions will do.
-* Internal File Ops:: The code for internal file operations.
-* Using Internal File Ops:: How to use an external extension.
-* Future Extensions:: New features that may be implemented
- one day.
-* Basic High Level:: The high level view.
-* Basic Data Typing:: A very quick intro to data types.
-* Floating Point Issues:: Stuff to know about floating-point
- numbers.
-* String Conversion Precision:: The String Value Can Lie.
-* Unexpected Results:: Floating Point Numbers Are Not Abstract
- Numbers.
-* POSIX Floating Point Problems:: Standards Versus Existing Practice.
+* History:: The history of @command{gawk} and
+ @command{awk}.
+* Names:: What name to use to find @command{awk}.
+* This Manual:: Using this @value{DOCUMENT}. Includes
+ sample input files that you can use.
+* Conventions:: Typographical Conventions.
+* Manual History:: Brief history of the GNU project and this
+ @value{DOCUMENT}.
+* How To Contribute:: Helping to save the world.
+* Acknowledgments:: Acknowledgments.
+* Running gawk:: How to run @command{gawk} programs;
+ includes command-line syntax.
+* One-shot:: Running a short throwaway @command{awk}
+ program.
+* Read Terminal:: Using no input files (input from terminal
+ instead).
+* Long:: Putting permanent @command{awk} programs in
+ files.
+* Executable Scripts:: Making self-contained @command{awk}
+ programs.
+* Comments:: Adding documentation to @command{gawk}
+ programs.
+* Quoting:: More discussion of shell quoting issues.
+* DOS Quoting:: Quoting in Windows Batch Files.
+* Sample Data Files:: Sample data files for use in the
+ @command{awk} programs illustrated in this
+ @value{DOCUMENT}.
+* Very Simple:: A very simple example.
+* Two Rules:: A less simple one-line example using two
+ rules.
+* More Complex:: A more complex example.
+* Statements/Lines:: Subdividing or combining statements into
+ lines.
+* Other Features:: Other Features of @command{awk}.
+* When:: When to use @command{gawk} and when to use
+ other things.
+* Command Line:: How to run @command{awk}.
+* Options:: Command-line options and their meanings.
+* Other Arguments:: Input file names and variable assignments.
+* Naming Standard Input:: How to specify standard input with other
+ files.
+* Environment Variables:: The environment variables @command{gawk}
+ uses.
+* AWKPATH Variable:: Searching directories for @command{awk}
+ programs.
+* Other Environment Variables:: The environment variables.
+* Exit Status:: @command{gawk}'s exit status.
+* Include Files:: Including other files into your program.
+* Obsolete:: Obsolete Options and/or features.
+* Undocumented:: Undocumented Options and Features.
+* Regexp Usage:: How to Use Regular Expressions.
+* Escape Sequences:: How to write nonprinting characters.
+* Regexp Operators:: Regular Expression Operators.
+* 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.
+* Computed Regexps:: Using Dynamic Regexps.
+* Records:: Controlling how data is split into records.
+* Fields:: An introduction to fields.
+* Nonconstant Fields:: Nonconstant Field Numbers.
+* Changing Fields:: Changing the Contents of a Field.
+* Field Separators:: The field separator and how to change it.
+* Default Field Splitting:: How fields are normally separated.
+* Regexp Field Splitting:: Using regexps as the field separator.
+* Single Character Fields:: Making each character a separate field.
+* Command Line Field Separator:: Setting @code{FS} from the command-line.
+* Field Splitting Summary:: Some final points and a summary table.
+* Constant Size:: Reading constant width data.
+* Splitting By Content:: Defining Fields By Content
+* Multiple Line:: Reading multi-line records.
+* Getline:: Reading files under explicit program
+ control using the @code{getline} function.
+* Plain Getline:: Using @code{getline} with no arguments.
+* Getline/Variable:: Using @code{getline} into a variable.
+* Getline/File:: Using @code{getline} from a file.
+* Getline/Variable/File:: Using @code{getline} into a variable from a
+ file.
+* Getline/Pipe:: Using @code{getline} from a pipe.
+* Getline/Variable/Pipe:: Using @code{getline} into a variable from a
+ pipe.
+* Getline/Coprocess:: Using @code{getline} from a coprocess.
+* Getline/Variable/Coprocess:: Using @code{getline} into a variable from a
+ coprocess.
+* Getline Notes:: Important things to know about
+ @code{getline}.
+* Getline Summary:: Summary of @code{getline} Variants.
+* Command line directories:: What happens if you put a directory on the
+ command line.
+* Print:: The @code{print} statement.
+* Print Examples:: Simple examples of @code{print} statements.
+* Output Separators:: The output separators and how to change
+ them.
+* OFMT:: Controlling Numeric Output With
+ @code{print}.
+* Printf:: The @code{printf} statement.
+* Basic Printf:: Syntax of the @code{printf} statement.
+* Control Letters:: Format-control letters.
+* Format Modifiers:: Format-specification modifiers.
+* Printf Examples:: Several examples.
+* Redirection:: How to redirect output to multiple files
+ and pipes.
+* Special Files:: File name interpretation in @command{gawk}.
+ @command{gawk} allows access to inherited
+ file descriptors.
+* Special FD:: Special files for I/O.
+* Special Network:: Special files for network communications.
+* Special Caveats:: Things to watch out for.
+* Close Files And Pipes:: Closing Input and Output Files and Pipes.
+* Values:: Constants, Variables, and Regular
+ Expressions.
+* Constants:: String, numeric and regexp constants.
+* Scalar Constants:: Numeric and string constants.
+* Nondecimal-numbers:: What are octal and hex numbers.
+* Regexp Constants:: Regular Expression constants.
+* Using Constant Regexps:: When and how to use a regexp constant.
+* Variables:: Variables give names to values for later
+ use.
+* Using Variables:: Using variables in your programs.
+* Assignment Options:: Setting variables on the command-line and a
+ summary of command-line syntax. This is an
+ advanced method of input.
+* Conversion:: The conversion of strings to numbers and
+ vice versa.
+* All Operators:: @command{gawk}'s operators.
+* Arithmetic Ops:: Arithmetic operations (@samp{+}, @samp{-},
+ etc.)
+* Concatenation:: Concatenating strings.
+* Assignment Ops:: Changing the value of a variable or a
+ field.
+* Increment Ops:: Incrementing the numeric value of a
+ variable.
+* Truth Values and Conditions:: Testing for true and false.
+* Truth Values:: What is ``true'' and what is ``false''.
+* Typing and Comparison:: How variables acquire types and how this
+ affects comparison of numbers and strings
+ with @samp{<}, etc.
+* Variable Typing:: String type versus numeric type.
+* Comparison Operators:: The comparison operators.
+* POSIX String Comparison:: String comparison with POSIX rules.
+* Boolean Ops:: Combining comparison expressions using
+ boolean operators @samp{||} (``or''),
+ @samp{&&} (``and'') and @samp{!} (``not'').
+* Conditional Exp:: Conditional expressions select between two
+ subexpressions under control of a third
+ subexpression.
+* Function Calls:: A function call is an expression.
+* Precedence:: How various operators nest.
+* Locales:: How the locale affects things.
+* Pattern Overview:: What goes into a pattern.
+* Regexp Patterns:: Using regexps as patterns.
+* Expression Patterns:: Any expression can be used as a pattern.
+* Ranges:: Pairs of patterns specify record ranges.
+* BEGIN/END:: Specifying initialization and cleanup
+ rules.
+* Using BEGIN/END:: How and why to use BEGIN/END rules.
+* I/O And BEGIN/END:: I/O issues in BEGIN/END rules.
+* BEGINFILE/ENDFILE:: Two special patterns for advanced control.
+* Empty:: The empty pattern, which matches every
+ record.
+* Using Shell Variables:: How to use shell variables with
+ @command{awk}.
+* Action Overview:: What goes into an action.
+* Statements:: Describes the various control statements in
+ detail.
+* If Statement:: Conditionally execute some @command{awk}
+ statements.
+* While Statement:: Loop until some condition is satisfied.
+* Do Statement:: Do specified action while looping until
+ some condition is satisfied.
+* For Statement:: Another looping statement, that provides
+ initialization and increment clauses.
+* Switch Statement:: Switch/case evaluation for conditional
+ execution of statements based on a value.
+* Break Statement:: Immediately exit the innermost enclosing
+ loop.
+* Continue Statement:: Skip to the end of the innermost enclosing
+ loop.
+* Next Statement:: Stop processing the current input record.
+* Nextfile Statement:: Stop processing the current file.
+* Exit Statement:: Stop execution of @command{awk}.
+* Built-in Variables:: Summarizes the built-in variables.
+* User-modified:: Built-in variables that you change to
+ control @command{awk}.
+* Auto-set:: Built-in variables where @command{awk}
+ gives you information.
+* ARGC and ARGV:: Ways to use @code{ARGC} and @code{ARGV}.
+* Array Basics:: The basics of arrays.
+* Array Intro:: Introduction to Arrays
+* Reference to Elements:: How to examine one element of an array.
+* Assigning Elements:: How to change an element of an array.
+* Array Example:: Basic Example of an Array
+* Scanning an Array:: A variation of the @code{for} statement. It
+ loops through the indices of an array's
+ existing elements.
+* Controlling Scanning:: Controlling the order in which arrays are
+ scanned.
+* Delete:: The @code{delete} statement removes an
+ element from an array.
+* Numeric Array Subscripts:: How to use numbers as subscripts in
+ @command{awk}.
+* Uninitialized Subscripts:: Using Uninitialized variables as
+ subscripts.
+* Multi-dimensional:: Emulating multidimensional arrays in
+ @command{awk}.
+* Multi-scanning:: Scanning multidimensional arrays.
+* Arrays of Arrays:: True multidimensional arrays.
+* Built-in:: Summarizes the built-in functions.
+* Calling Built-in:: How to call built-in functions.
+* Numeric Functions:: Functions that work with numbers, including
+ @code{int()}, @code{sin()} and
+ @code{rand()}.
+* String Functions:: Functions for string manipulation, such as
+ @code{split()}, @code{match()} and
+ @code{sprintf()}.
+* Gory Details:: More than you want to know about @samp{\}
+ and @samp{&} with @code{sub()},
+ @code{gsub()}, and @code{gensub()}.
+* I/O Functions:: Functions for files and shell commands.
+* Time Functions:: Functions for dealing with timestamps.
+* Bitwise Functions:: Functions for bitwise operations.
+* Type Functions:: Functions for type information.
+* I18N Functions:: Functions for string translation.
+* User-defined:: Describes User-defined functions in detail.
+* Definition Syntax:: How to write definitions and what they
+ mean.
+* Function Example:: An example function definition and what it
+ does.
+* Function Caveats:: Things to watch out for.
+* Calling A Function:: Don't use spaces.
+* Variable Scope:: Controlling variable scope.
+* Pass By Value/Reference:: Passing parameters.
+* Return Statement:: Specifying the value a function returns.
+* Dynamic Typing:: How variable types can change at runtime.
+* Indirect Calls:: Choosing the function to call at runtime.
+* I18N and L10N:: Internationalization and Localization.
+* Explaining gettext:: How GNU @code{gettext} works.
+* Programmer i18n:: Features for the programmer.
+* Translator i18n:: Features for the translator.
+* String Extraction:: Extracting marked strings.
+* Printf Ordering:: Rearranging @code{printf} arguments.
+* I18N Portability:: @command{awk}-level portability issues.
+* I18N Example:: A simple i18n example.
+* Gawk I18N:: @command{gawk} is also internationalized.
+* Nondecimal Data:: Allowing nondecimal input data.
+* Array Sorting:: Facilities for controlling array traversal
+ and sorting arrays.
+* Controlling Array Traversal:: How to use PROCINFO["sorted_in"].
+* Array Sorting Functions:: How to use @code{asort()} and
+ @code{asorti()}.
+* Two-way I/O:: Two-way communications with another
+ process.
+* TCP/IP Networking:: Using @command{gawk} for network
+ programming.
+* Profiling:: Profiling your @command{awk} programs.
+* Library Names:: How to best name private global variables
+ in library functions.
+* General Functions:: Functions that are of general use.
+* Strtonum Function:: A replacement for the built-in
+ @code{strtonum()} function.
+* Assert Function:: A function for assertions in @command{awk}
+ programs.
+* Round Function:: A function for rounding if @code{sprintf()}
+ does not do it correctly.
+* Cliff Random Function:: The Cliff Random Number Generator.
+* Ordinal Functions:: Functions for using characters as numbers
+ and vice versa.
+* Join Function:: A function to join an array into a string.
+* Gettimeofday Function:: A function to get formatted times.
+* Data File Management:: Functions for managing command-line data
+ files.
+* Filetrans Function:: A function for handling data file
+ transitions.
+* Rewind Function:: A function for rereading the current file.
+* File Checking:: Checking that data files are readable.
+* Empty Files:: Checking for zero-length files.
+* Ignoring Assigns:: Treating assignments as file names.
+* Getopt Function:: A function for processing command-line
+ arguments.
+* Passwd Functions:: Functions for getting user information.
+* Group Functions:: Functions for getting group information.
+* Walking Arrays:: A function to walk arrays of arrays.
+* Running Examples:: How to run these examples.
+* Clones:: Clones of common utilities.
+* Cut Program:: The @command{cut} utility.
+* Egrep Program:: The @command{egrep} utility.
+* Id Program:: The @command{id} utility.
+* Split Program:: The @command{split} utility.
+* Tee Program:: The @command{tee} utility.
+* Uniq Program:: The @command{uniq} utility.
+* Wc Program:: The @command{wc} utility.
+* Miscellaneous Programs:: Some interesting @command{awk} programs.
+* Dupword Program:: Finding duplicated words in a document.
+* Alarm Program:: An alarm clock.
+* Translate Program:: A program similar to the @command{tr}
+ utility.
+* Labels Program:: Printing mailing labels.
+* Word Sorting:: A program to produce a word usage count.
+* History Sorting:: Eliminating duplicate entries from a
+ history file.
+* Extract Program:: Pulling out programs from Texinfo source
+ files.
+* Simple Sed:: A Simple Stream Editor.
+* Igawk Program:: A wrapper for @command{awk} that includes
+ files.
+* Anagram Program:: Finding anagrams from a dictionary.
+* Signature Program:: People do amazing things with too much time
+ on their hands.
+* Debugging:: Introduction to @command{dgawk}.
+* Debugging Concepts:: Debugging In General.
+* Debugging Terms:: Additional Debugging Concepts.
+* Awk Debugging:: Awk Debugging.
+* Sample dgawk session:: Sample @command{dgawk} session.
+* dgawk invocation:: @command{dgawk} Invocation.
+* Finding The Bug:: Finding The Bug.
+* List of Debugger Commands:: Main @command{dgawk} Commands.
+* Breakpoint Control:: Control of breakpoints.
+* Dgawk Execution Control:: Control of execution.
+* Viewing And Changing Data:: Viewing and changing data.
+* Dgawk Stack:: Dealing with the stack.
+* Dgawk Info:: Obtaining information about the program and
+ the debugger state.
+* Miscellaneous Dgawk Commands:: Miscellaneous Commands.
+* Readline Support:: Readline Support.
+* Dgawk Limitations:: Limitations and future plans.
+* V7/SVR3.1:: The major changes between V7 and System V
+ Release 3.1.
+* SVR4:: Minor changes between System V Releases 3.1
+ and 4.
+* POSIX:: New features from the POSIX standard.
+* BTL:: New features from Brian Kernighan's version
+ of @command{awk}.
+* POSIX/GNU:: The extensions in @command{gawk} not in
+ POSIX @command{awk}.
+* Common Extensions:: Common Extensions Summary.
+* Ranges and Locales:: How locales used to affect regexp ranges.
+* Contributors:: The major contributors to @command{gawk}.
+* Gawk Distribution:: What is in the @command{gawk} distribution.
+* Getting:: How to get the distribution.
+* Extracting:: How to extract the distribution.
+* Distribution contents:: What is in the distribution.
+* Unix Installation:: Installing @command{gawk} under various
+ versions of Unix.
+* Quick Installation:: Compiling @command{gawk} under Unix.
+* Additional Configuration Options:: Other compile-time options.
+* Configuration Philosophy:: How it's all supposed to work.
+* Non-Unix Installation:: Installation on Other Operating Systems.
+* PC Installation:: Installing and Compiling @command{gawk} on
+ MS-DOS and OS/2.
+* PC Binary Installation:: Installing a prepared distribution.
+* PC Compiling:: Compiling @command{gawk} for MS-DOS,
+ Windows32, and OS/2.
+* PC Testing:: Testing @command{gawk} on PC systems.
+* PC Using:: Running @command{gawk} on MS-DOS, Windows32
+ and OS/2.
+* Cygwin:: Building and running @command{gawk} for
+ Cygwin.
+* MSYS:: Using @command{gawk} In The MSYS
+ Environment.
+* VMS Installation:: Installing @command{gawk} on VMS.
+* VMS Compilation:: How to compile @command{gawk} under VMS.
+* VMS Installation Details:: How to install @command{gawk} under VMS.
+* VMS Running:: How to run @command{gawk} under VMS.
+* VMS Old Gawk:: An old version comes with some VMS systems.
+* Bugs:: Reporting Problems and Bugs.
+* Other Versions:: Other freely available @command{awk}
+ implementations.
+* Compatibility Mode:: How to disable certain @command{gawk}
+ extensions.
+* Additions:: Making Additions To @command{gawk}.
+* Accessing The Source:: Accessing the Git repository.
+* Adding Code:: Adding code to the main body of
+ @command{gawk}.
+* New Ports:: Porting @command{gawk} to a new operating
+ system.
+* Dynamic Extensions:: Adding new built-in functions to
+ @command{gawk}.
+* Internals:: A brief look at some @command{gawk}
+ internals.
+* Plugin License:: A note about licensing.
+* Sample Library:: A example of new functions.
+* Internal File Description:: What the new functions will do.
+* Internal File Ops:: The code for internal file operations.
+* Using Internal File Ops:: How to use an external extension.
+* Future Extensions:: New features that may be implemented one
+ day.
+* Basic High Level:: The high level view.
+* Basic Data Typing:: A very quick intro to data types.
+* Floating Point Issues:: Stuff to know about floating-point numbers.
+* String Conversion Precision:: The String Value Can Lie.
+* Unexpected Results:: Floating Point Numbers Are Not Abstract
+ Numbers.
+* POSIX Floating Point Problems:: Standards Versus Existing Practice.
@end detailmenu
@end menu
@@ -13054,6 +13014,8 @@ an array.
* Scanning an Array:: A variation of the @code{for} statement. It
loops through the indices of an array's
existing elements.
+* Controlling Scanning:: Controlling the order in which arrays are
+ scanned.
@end menu
@node Array Intro
@@ -13441,11 +13403,151 @@ the loop body; it is not predictable whether the
@code{for} loop will
reach them. Similarly, changing @var{var} inside the loop may produce
strange results. It is best to avoid such things.
-As an extension, @command{gawk} makes it possible for you to
-loop over the elements of an array in order, based on the value of
address@hidden"sorted_in"]} (@pxref{Auto-set}).
-This is an advanced feature, so discussion of it is delayed
-until @ref{Controlling Array Traversal}.
address@hidden Controlling Scanning
address@hidden Using Predefined Array Scanning Orders
+
+By default, when a @code{for} loop traverses an array, the order
+is undefined, meaning that the @command{awk} implementation
+determines the order in which the array is traversed.
+This order is usually based on the internal implementation of arrays
+and will vary from one version of @command{awk} to the next.
+
+Often, though, you may wish to do something simple, such as
+``traverse the array by comparing the indices in ascending order,''
+or ``traverse the array by on comparing the values in descending order.''
address@hidden provides two mechanims which give you this control.
+
address@hidden @bullet
address@hidden
+Set @code{PROCINFO["sorted_in"]} to one of a set of predefined values.
+We describe this now.
+
address@hidden
+Set @code{PROCINFO["sorted_in"]} to the name of a user-defined function
+to be used for comparison of array elements. This advanced feature
+is described later, in @ref{Array Sorting}.
address@hidden itemize
+
+The following special values for @code{PROCINFO["sorted_in"]} are available:
+
address@hidden @code
address@hidden "@@unsorted"
+Array elements are processed in arbitrary order, which is the default
address@hidden behavior.
+
address@hidden "@@ind_str_asc"
+Order by indices compared as strings; this is the most basic sort.
+(Internally, array indices are always strings, so with @samp{a[2*5] = 1}
+the index is @code{"10"} rather than numeric 10.)
+
address@hidden "@@ind_num_asc"
+Order by indices but force them to be treated as numbers in the process.
+Any index with a non-numeric value will end up positioned as if it were zero.
+
address@hidden "@@val_type_asc"
+Order by element values rather than indices.
+Ordering is by the type assigned to the element
+(@pxref{Typing and Comparison}).
+All numeric values come before all string values,
+which in turn come before all subarrays.
+(Subarrays have not been described yet;
address@hidden of Arrays}).
+
address@hidden "@@val_str_asc"
+Order by element values rather than by indices. Scalar values are
+compared as strings. Subarrays, if present, come out last.
+
address@hidden "@@val_num_asc"
+Order by element values rather than by indices. Scalar values are
+compared as numbers. Subarrays, if present, come out last.
+When numeric values are equal, the string values are used to provide
+an ordering: this guarantees consistent results across different
+versions of the C @code{qsort()} function,@footnote{When two elements
+compare as equal, the C @code{qsort()} function does not guarantee
+that they will maintain their original relative order after sorting.
+Using the string value to provide a unique ordering when the numeric
+values are equal ensures that @command{gawk} behaves consistently
+across different environments.} which @command{gawk} uses internally
+to perform the sorting.
+
address@hidden "@@ind_str_desc"
+Reverse order from the most basic sort.
+
address@hidden "@@ind_num_desc"
+Numeric indices ordered from high to low.
+
address@hidden "@@val_type_desc"
+Element values, based on type, in descending order.
+
address@hidden "@@val_str_desc"
+Element values, treated as strings, ordered from high to low.
+Subarrays, if present, come out first.
+
address@hidden "@@val_num_desc"
+Element values, treated as numbers, ordered from high to low.
+Subarrays, if present, come out first.
address@hidden table
+
+The array traversal order is determined before the @code{for} loop
+starts to run. Changing @code{PROCINFO["sorted_in"]} in the loop body
+will not affect the loop.
+
+For example:
+
address@hidden
+$ @kbd{gawk 'BEGIN @{}
+> @kbd{ a[4] = 4}
+> @kbd{ a[3] = 3}
+> @kbd{ for (i in a)}
+> @kbd{ print i, a[i]}
+> @address@hidden'}
address@hidden 4 4
address@hidden 3 3
+$ @kbd{gawk 'BEGIN @{}
+> @kbd{ PROCINFO["sorted_in"] = "@@ind_str_asc"}
+> @kbd{ a[4] = 4}
+> @kbd{ a[3] = 3}
+> @kbd{ for (i in a)}
+> @kbd{ print i, a[i]}
+> @address@hidden'}
address@hidden 3 3
address@hidden 4 4
address@hidden example
+
+When sorting an array by element values, if a value happens to be
+a subarray then it is considered to be greater than any string or
+numeric value, regardless of what the subarray itself contains,
+and all subarrays are treated as being equal to each other. Their
+order relative to each other is determined by their index strings.
+
+Here are some additional things to bear in mind about sorted
+array traversal.
+
address@hidden @bullet
address@hidden
+The value of @code{PROCINFO["sorted_in"]} is global. That is, it affects
+all array traversal @code{for} loops. If you need to change it within your
+own code, you should see if it's defined and save and restore the value:
+
address@hidden
address@hidden
+if ("sorted_in" in PROCINFO) @{
+ save_sorted = PROCINFO["sorted_in"]
+ PROCINFO["sorted_in"] = "@@val_str_desc" # or whatever
address@hidden
address@hidden
+if (save_sorted)
+ PROCINFO["sorted_in"] = save_sorted
address@hidden example
+
address@hidden
+As mentioned, the default array traversal order is represented by
address@hidden"@@unsorted"}. You can also get the default behavior by assigning
+the null string to @code{PROCINFO["sorted_in"]} or by just deleting the
address@hidden"sorted_in"} element from the @code{PROCINFO} array with
+the @code{delete} statement.
+(The @code{delete} statement hasn't been described yet; @pxref{Delete}.)
address@hidden itemize
In addition, @command{gawk} provides built-in functions for
sorting arrays; see @ref{Array Sorting Functions}.
@@ -18164,8 +18266,8 @@ leads to less surprising results.
@node Array Sorting
@section Controlling Array Traversal and Array Sorting
address@hidden lets you control the order in which @samp{for (i in array)} loops
-will traverse an array.
address@hidden lets you control the order in which a @samp{for (i in array)}
+loop traverses an array.
In addition, two built-in functions, @code{asort()} and @code{asorti()},
let you sort arrays based on the array values and indices, respectively.
@@ -18186,18 +18288,14 @@ the internal implementation of arrays inside
@command{awk}.
Often, though, it is desirable to be able to loop over the elements
in a particular order that you, the programmer, choose. @command{gawk}
-lets you do this; this @value{SUBSECTION} describes how.
-
address@hidden
-* Controlling Scanning With A Function:: Using a function to control scanning.
-* Controlling Scanning:: Controlling the order in which arrays
- are scanned.
address@hidden menu
+lets you do this.
address@hidden Controlling Scanning With A Function
address@hidden Array Scanning Using A User-defined Function
address@hidden Scanning}, describes how you can assign special,
+pre-defined values to @code{PROCINFO["sorted_in"]} in order to
+control the order in which @command{gawk} will traverse an array
+during a @code{for} loop.
-The value of @code{PROCINFO["sorted_in"]} can be a function name.
+In addition, the value of @code{PROCINFO["sorted_in"]} can be a function name.
This lets you traverse an array based on any custom criterion.
The array elements are ordered according to the return value of this
function. The comparison function should be defined with at least
@@ -18214,8 +18312,9 @@ function comp_func(i1, v1, i2, v2)
Here, @var{i1} and @var{i2} are the indices, and @var{v1} and @var{v2}
are the corresponding values of the two elements being compared.
Either @var{v1} or @var{v2}, or both, can be arrays if the array being
-traversed contains subarrays as values. The three possible return values
-are interpreted this way:
+traversed contains subarrays as values.
+(@xref{Arrays of Arrays}, for more information about subarrays.)
+The three possible return values are interpreted as follows:
@table @code
@item comp_func(i1, v1, i2, v2) < 0
@@ -18357,7 +18456,7 @@ END @{
The first field in each entry of the password file is the user's login name,
and the fields are seperated by colons.
-Each record defines a subarray (@pxref{Arrays of Arrays}),
+Each record defines a subarray,
with each field as an element in the subarray.
Running the program produces the
following output:
@@ -18447,151 +18546,6 @@ sorted array traversal is not the default.
@c maintainers believe that only the people who wish to use a
@c feature should have to pay for it.
address@hidden Controlling Scanning
address@hidden Controlling Array Scanning Order
-
-As described in
address@hidden
-the previous subsubsection,
address@hidden iftex
address@hidden
address@hidden Scanning With A Function},
address@hidden ifnottex
-you can provide the name of a function as the value of
address@hidden"sorted_in"]} to specify custom sorting criteria.
-
-Often, though, you may wish to do something simple, such as
-``sort based on comparing the indices in ascending order,''
-or ``sort based on comparing the values in descending order.''
-Having to write a simple comparison function for this purpose
-for use in all of your programs becomes tedious.
-For the common simple cases, @command{gawk} provides
-the option of using special names that do the requested
-sorting for you.
-You can think of them as ``predefined'' sorting functions,
-if you like, although the names purposely include characters
-that are not valid in real @command{awk} function names.
-
-The following special values are available:
-
address@hidden @code
address@hidden "@@unsorted"
-Array elements are processed in arbitrary order, which is the default
address@hidden behavior.
-
address@hidden "@@ind_str_asc"
-Order by indices compared as strings; this is the most basic sort.
-(Internally, array indices are always strings, so with @samp{a[2*5] = 1}
-the index is @code{"10"} rather than numeric 10.)
-
address@hidden "@@ind_num_asc"
-Order by indices but force them to be treated as numbers in the process.
-Any index with a non-numeric value will end up positioned as if it were zero.
-
address@hidden "@@val_type_asc"
-Order by element values rather than indices.
-Ordering is by the type assigned to the element
-(@pxref{Typing and Comparison}).
-All numeric values come before all string values,
-which in turn come before all subarrays.
-
address@hidden "@@val_str_asc"
-Order by element values rather than by indices. Scalar values are
-compared as strings. Subarrays, if present, come out last.
-
address@hidden "@@val_num_asc"
-Order by element values rather than by indices. Scalar values are
-compared as numbers. Subarrays, if present, come out last.
-When numeric values are equal, the string values are used to provide
-an ordering: this guarantees consistent results across different
-versions of the C @code{qsort()} address@hidden two elements
-compare as equal, the C @code{qsort()} function does not guarantee
-that they will maintain their original relative order after sorting.
-Using the string value to provide a unique ordering when the numeric
-values are equal ensures that @command{gawk} behaves consistently
-across different environments.}, which @command{gawk} uses internally
-to perform the sorting.
-
address@hidden "@@ind_str_desc"
-Reverse order from the most basic sort.
-
address@hidden "@@ind_num_desc"
-Numeric indices ordered from high to low.
-
address@hidden "@@val_type_desc"
-Element values, based on type, in descending order.
-
address@hidden "@@val_str_desc"
-Element values, treated as strings, ordered from high to low.
-Subarrays, if present, come out first.
-
address@hidden "@@val_num_desc"
-Element values, treated as numbers, ordered from high to low.
-Subarrays, if present, come out first.
address@hidden table
-
-The array traversal order is determined before the @code{for} loop
-starts to run. Changing @code{PROCINFO["sorted_in"]} in the loop body
-will not affect the loop.
-
-For example:
-
address@hidden
-$ @kbd{gawk 'BEGIN @{}
-> @kbd{ a[4] = 4}
-> @kbd{ a[3] = 3}
-> @kbd{ for (i in a)}
-> @kbd{ print i, a[i]}
-> @address@hidden'}
address@hidden 4 4
address@hidden 3 3
-$ @kbd{gawk 'BEGIN @{}
-> @kbd{ PROCINFO["sorted_in"] = "@@ind_str_asc"}
-> @kbd{ a[4] = 4}
-> @kbd{ a[3] = 3}
-> @kbd{ for (i in a)}
-> @kbd{ print i, a[i]}
-> @address@hidden'}
address@hidden 3 3
address@hidden 4 4
address@hidden example
-
-When sorting an array by element values, if a value happens to be
-a subarray then it is considered to be greater than any string or
-numeric value, regardless of what the subarray itself contains,
-and all subarrays are treated as being equal to each other. Their
-order relative to each other is determined by their index strings.
-
-Here are some additional things to bear in mind about sorted
-array traversal.
-
address@hidden @bullet
address@hidden
-The value of @code{PROCINFO["sorted_in"]} is global. That is, it affects
-all array traversal @code{for} loops. If you need to change it within your
-own function, you should see if it's defined and save and restore the value:
-
address@hidden
-function myfunct(p1, p2, save_sorted)
address@hidden
- @dots{}
- if ("sorted_in" in PROCINFO) @{
- save_sorted = PROCINFO["sorted_in"]
- PROCINFO["sorted_in"] = "@@val_str_desc" # or whatever
- @}
- @dots{}
- if (save_sorted)
- PROCINFO["sorted_in"] = save_sorted
address@hidden
address@hidden example
-
address@hidden
-As mentioned, the default array traversal order is represented by
address@hidden"@@unsorted"}. You can also get the default behavior by assigning
-the null string to @code{PROCINFO["sorted_in"]} or by just deleting the
address@hidden"sorted_in"} element from the @code{PROCINFO} array.
address@hidden itemize
-
@node Array Sorting Functions
@subsection Sorting Array Values and Indices with @command{gawk}
@@ -18600,7 +18554,7 @@ the null string to @code{PROCINFO["sorted_in"]} or by
just deleting the
@cindex @code{asort()} function (@command{gawk}), address@hidden sorting
@cindex sort function, arrays, sorting
In most @command{awk} implementations, sorting an array requires
-writing a @code{sort} function.
+writing a @code{sort()} function.
While this can be educational for exploring different sorting algorithms,
usually that's not the point of the program.
@command{gawk} provides the built-in @code{asort()}
@@ -18641,12 +18595,11 @@ In this case, @command{gawk} copies the @code{source}
array into the
@code{dest} array and then sorts @code{dest}, destroying its indices.
However, the @code{source} array is not affected.
address@hidden()} accepts a third string argument
-to control comparison of array elements.
-As with @code{PROCINFO["sorted_in"]}, this argument may be the
-name of a user-defined function, or one of the predefined names
-that @command{gawk} provides
-(@pxref{Controlling Scanning With A Function}).
address@hidden()} accepts a third string argument to control comparison of
+array elements. As with @code{PROCINFO["sorted_in"]}, this argument
+may be one of the predefined names that @command{gawk} provides
+(@pxref{Controlling Scanning}), or the name of a user-defined function
+(@pxref{Controlling Array Traversal}).
@quotation NOTE
In all cases, the sorted element values consist of the original
-----------------------------------------------------------------------
Summary of changes:
NEWS | 10 +
doc/ChangeLog | 5 +
doc/gawk.info | 2014 ++++++++++++++++++++++++++++-----------------------------
doc/gawk.texi | 1167 ++++++++++++++++-----------------
4 files changed, 1559 insertions(+), 1637 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, gawk-4.0-stable, updated. 3f6a81b5812d5f527aea23e77754732374a10c55,
Arnold Robbins <=