aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--NEWS11
-rw-r--r--awk.h9
-rw-r--r--awklib/eg/test-programs/gen-float-table.awk59
-rw-r--r--awklib/eg/test-programs/gen-float-table.c60
-rw-r--r--awklib/eg/test-programs/gen-float-table.py42
-rw-r--r--builtin.c2
-rw-r--r--doc/ChangeLog39
-rw-r--r--doc/gawk.info1288
-rw-r--r--doc/gawk.texi276
-rw-r--r--doc/gawktexi.in276
-rw-r--r--doc/it/ChangeLog25
-rwxr-xr-x[-rw-r--r--]doc/it/gawktexi.in622
-rwxr-xr-x[-rw-r--r--]doc/it/texinfo.tex191
-rw-r--r--doc/wordlist1
-rw-r--r--eval.c96
-rw-r--r--interpret.h12
-rw-r--r--mpfr.c44
-rw-r--r--node.c3
-rw-r--r--str_array.c38
20 files changed, 2186 insertions, 927 deletions
diff --git a/ChangeLog b/ChangeLog
index 17f06325..56deef6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-03-21 Arnold D. Robbins <arnold@skeeve.com>
+
+ * str_array.c (fnv1a_hash_string): New function.
+ (str_array_init): Use fnv1a_hash_string if AWK_HASH env var
+ set to "fnv1a".
+
2021-02-13 Arnold D. Robbins <arnold@skeeve.com>
* io.c (nextfile): Use the value of ARGC directly in the for
@@ -120,6 +126,19 @@
2020-11-02 Arnold D. Robbins <arnold@skeeve.com>
+ Make gawk numeric comparisons act like C doubles.
+ MPFR differs from doubles w.r.t. NaN, not sure why yet.
+
+ * awk.h (scalar_cmp_t): New enum.
+ * builtin.c (format_nan_inf): Use mpfr_signbit, not mpfr_sgn.
+ * eval.c (cmp_doubles): New routine.
+ (cmp_scalars): Change type to bool, rework logic.
+ * interpret.h (r_interpret): Rework scalar comparisons.
+ * mpfr.c (mpg_cmp_as_numbers): New routine.
+ * node.c: Use <math.h>, not "math.h", minor comment edits.
+
+2020-11-02 Arnold D. Robbins <arnold@skeeve.com>
+
* re.c (make_regexp): Cast len parameter to int to avoid
compiler warnings.
diff --git a/NEWS b/NEWS
index e2345c55..85062216 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,17 @@
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
+Changes from 5.1.x to 5.2.0
+---------------------------
+
+1. Numeric scalars now compare in the same way as C for the relational
+operators. Comparison order for sorting has not changed. This only
+makes a difference when comparing Infinity and NaN values with
+regular numbers; it should not be noticeable most of the time.
+
+2. If the AWK_HASH environment variable is set to "fnv1a" gawk will
+use the FNV1-A hash function for associative arrays.
+
Changes from 5.1.0 to 5.1.1
---------------------------
diff --git a/awk.h b/awk.h
index 2ab25bfd..c9eec663 100644
--- a/awk.h
+++ b/awk.h
@@ -1576,6 +1576,15 @@ typedef enum {
extern field_sep_type current_field_sep(void);
extern const char *current_field_sep_str(void);
+typedef enum {
+ SCALAR_EQ,
+ SCALAR_NEQ,
+ SCALAR_LT,
+ SCALAR_LE,
+ SCALAR_GT,
+ SCALAR_GE,
+} scalar_cmp_t;
+
/* gawkapi.c: */
extern gawk_api_t api_impl;
extern void init_ext_api(void);
diff --git a/awklib/eg/test-programs/gen-float-table.awk b/awklib/eg/test-programs/gen-float-table.awk
new file mode 100644
index 00000000..ea6269c3
--- /dev/null
+++ b/awklib/eg/test-programs/gen-float-table.awk
@@ -0,0 +1,59 @@
+function eq(left, right)
+{
+ return left == right
+}
+
+function ne(left, right)
+{
+ return left != right
+}
+
+function lt(left, right)
+{
+ return left < right
+}
+
+function le(left, right)
+{
+ return left <= right
+}
+
+function gt(left, right)
+{
+ return left > right
+}
+
+function ge(left, right)
+{
+ return left >= right
+}
+
+BEGIN {
+ nan = sqrt(-1)
+ inf = -log(0)
+ split("== != < <= > >=", names)
+ names[3] = names[3] " "
+ names[5] = names[5] " "
+ split("eq ne lt le gt ge", funcs)
+
+ compare[1] = 2.0
+ compare[2] = values[1] = -sqrt(-1.0) # nan
+ compare[3] = values[2] = sqrt(-1.0) # -nan
+ compare[4] = values[3] = -log(0.0) # inf
+ compare[5] = values[4] = log(0.0) # -inf
+
+ for (i = 1; i in values; i++) {
+ for (j = 1; j in compare; j++) {
+ for (k = 1; k in names; k++) {
+ the_func = funcs[k]
+ printf("%g %s %g -> %s\n",
+ values[i],
+ names[k],
+ compare[j],
+ @the_func(values[i], compare[j]) ?
+ "True" : "False");
+ }
+ printf("\n");
+ }
+ }
+}
diff --git a/awklib/eg/test-programs/gen-float-table.c b/awklib/eg/test-programs/gen-float-table.c
new file mode 100644
index 00000000..ba3a0d05
--- /dev/null
+++ b/awklib/eg/test-programs/gen-float-table.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <math.h>
+#include <stdbool.h>
+
+#define def_func(name, op) \
+ bool name(double left, double right) { \
+ return left op right; \
+ }
+
+def_func(eq, ==)
+def_func(ne, !=)
+def_func(lt, <)
+def_func(le, <=)
+def_func(gt, >)
+def_func(ge, >=)
+
+struct {
+ const char *name;
+ bool (*func)(double left, double right);
+} functions[] = {
+ { "==", eq },
+ { "!=", ne },
+ { "< ", lt },
+ { "<=", le },
+ { "> ", gt },
+ { ">=", ge },
+ { 0, 0 }
+};
+
+int main()
+{
+ double values[] = {
+ -sqrt(-1), // nan
+ sqrt(-1), // -nan
+ -log(0.0), // inf
+ log(0.0) // -inf
+ };
+ double compare[] = { 2.0,
+ -sqrt(-1), // nan
+ sqrt(-1), // -nan
+ -log(0.0), // inf
+ log(0.0) // -inf
+ };
+
+ int i, j, k;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 5; j++) {
+ for (k = 0; functions[k].name != NULL; k++) {
+ printf("%g %s %g -> %s\n", values[i],
+ functions[k].name,
+ compare[j],
+ functions[k].func(values[i], compare[j]) ? "True" : "False");
+ }
+ printf("\n");
+ }
+ }
+
+ return 0;
+}
diff --git a/awklib/eg/test-programs/gen-float-table.py b/awklib/eg/test-programs/gen-float-table.py
new file mode 100644
index 00000000..8631b817
--- /dev/null
+++ b/awklib/eg/test-programs/gen-float-table.py
@@ -0,0 +1,42 @@
+from math import *
+
+nan = float('NaN')
+inf = float('Inf')
+
+def eq(left, right):
+ return left == right
+
+def ne(left, right):
+ return left != right
+
+def lt(left, right):
+ return left < right
+
+def le(left, right):
+ return left <= right
+
+def gt(left, right):
+ return left > right
+
+def ge(left, right):
+ return left >= right
+
+func_map = {
+ "==": eq,
+ "!=": ne,
+ "< ": lt,
+ "<=": le,
+ "> ": gt,
+ ">=": ge,
+}
+
+compare = [2.0, nan, -nan, inf, -inf]
+values = [nan, -nan, inf, -inf]
+
+for i in range(len(values)):
+ for j in range(len(compare)):
+ for op in func_map:
+ print("%g %s %g -> %s" %
+ (values[i], op, compare[j], func_map[op](values[i], compare[j])))
+
+ print("")
diff --git a/builtin.c b/builtin.c
index e28c35ef..1b612f4a 100644
--- a/builtin.c
+++ b/builtin.c
@@ -4277,7 +4277,7 @@ format_nan_inf(NODE *n, char format)
goto fmt;
} else if (mpfr_inf_p(n->mpg_numbr)) {
- strcpy(buf, mpfr_sgn(n->mpg_numbr) < 0 ? "-inf" : "+inf");
+ strcpy(buf, mpfr_signbit(n->mpg_numbr) ? "-inf" : "+inf");
goto fmt;
} else
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 04fff857..34a0b68c 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -5,10 +5,22 @@
<arkadiusz@drabczyk.org> for pointing out the lack of
documentation.
+2021-03-21 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Other Environment Variables): Document "fnv1a"
+ possible value for AWK_HASH environment variable.
+
2021-03-18 Arnold D. Robbins <arnold@skeeve.com>
* texinfo.tex: Updated from GNULIB.
+2021-02-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Strange values): Fix a typo in the awk test
+ program. Make the C and Awk versions print "True" and
+ "False" to match Python, making comparisons easier. Thanks to
+ Antonio Columbo for the suggestions.
+
2021-01-25 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in: Fix some spelling errors.
@@ -79,12 +91,39 @@
* gawkworkflow.texi: Add an additional web resource.
* gawktexi.in: More edits in sample programs chapter.
+2020-11-20 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Strange values): Correct the description of what
+ happens with infinity. Thanks to Antonio Columbo for pointing
+ out the problem.
+
2020-11-16 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in (Nextfile Statement): Clarify what happens in
a BEGINFILE rule.
* gawktexi.in: Additional small fixes.
+2020-11-15 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Strange values): Add test programs inside
+ @ignore; extracted to example directory.
+
+2020-11-09 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: Samll improvement in strange numbers section.
+
+2020-11-04 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Strange values): New section on NaN and infinity.
+ Update some other bits to point to it.
+ * wordlist: Updated with more words.
+
+2020-11-16 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Nextfile Statement): Clarify what happens in
+ a BEGINFILE rule.
+>>>>>>> master
+
2020-10-31 Arnold D. Robbins <arnold@skeeve.com>
* texinfo.tex: Updated from GNULIB.
diff --git a/doc/gawk.info b/doc/gawk.info
index 4f0eef36..76ecc3c5 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -547,6 +547,7 @@ in (a) below. A copy of the license is included in the section entitled
* Inexact representation:: Numbers are not exactly represented.
* Comparing FP Values:: How to compare floating point values.
* Errors accumulate:: Errors get bigger as they go.
+* Strange values:: A few words about infinities and NaNs.
* Getting Accuracy:: Getting more accuracy takes some work.
* Try To Round:: Add digits and round.
* Setting precision:: How to set the precision.
@@ -3215,7 +3216,9 @@ change. The variables are:
'AWK_HASH'
If this variable exists with a value of 'gst', 'gawk' switches to
using the hash function from GNU Smalltalk for managing arrays.
- This function may be marginally faster than the standard function.
+ With a value of 'fnv1a', 'gawk' uses the FNV1-A hash function
+ (http://www.isthe.com/chongo/tech/comp/fnv/index.html). These
+ functions may be marginally faster than the standard function.
'AWKREADFUNC'
If this variable exists, 'gawk' switches to reading source files
@@ -6966,8 +6969,8 @@ width. Here is a list of the format-control letters:
On systems supporting IEEE 754 floating-point format, values
representing negative infinity are formatted as '-inf' or
'-infinity', and positive infinity as 'inf' or 'infinity'. The
- special "not a number" value formats as '-nan' or 'nan' (*note Math
- Definitions::).
+ special "not a number" value formats as '-nan' or 'nan' (*note
+ Strange values::).
'%F'
Like '%f', but the infinity and "not a number" values are spelled
@@ -12859,7 +12862,7 @@ brackets ([ ]):
'log(X)'
Return the natural logarithm of X, if X is positive; otherwise,
- return 'NaN' ("not a number") on IEEE 754 systems. Additionally,
+ return NaN ("not a number") on IEEE 754 systems. Additionally,
'gawk' prints a warning message when 'x' is negative.
'rand()'
@@ -24242,18 +24245,10 @@ material here:
another number and infinity produce infinity.
"NaN"
- "Not a number."(1) A special value that results from attempting a
- calculation that has no answer as a real number. In such a case,
- programs can either receive a floating-point exception, or get
- 'NaN' back as the result. The IEEE 754 standard recommends that
- systems return 'NaN'. Some examples:
-
- 'sqrt(-1)'
- This makes sense in the range of complex numbers, but not in
- the range of real numbers, so the result is 'NaN'.
-
- 'log(-8)'
- -8 is out of the domain of 'log()', so the result is 'NaN'.
+ "Not a number." A special value that results from attempting a
+ calculation that has no answer as a real number. *Note Strange
+ values::, for more information about infinity and not-a-number
+ values.
"Normalized"
How the significand (see later in this list) is usually stored.
@@ -24312,11 +24307,6 @@ Table 16.3: Basic IEEE format values
NOTE: The precision numbers include the implied leading one that
gives them one extra bit of significand.
- ---------- Footnotes ----------
-
- (1) Thanks to Michael Brennan for this description, which we have
-paraphrased, and for the examples.
-

File: gawk.info, Node: MPFR features, Next: FP Math Caution, Prev: Math Definitions, Up: Arbitrary Precision Arithmetic
@@ -24409,6 +24399,7 @@ be sure of the number of significant decimal places in the final result.
* Inexact representation:: Numbers are not exactly represented.
* Comparing FP Values:: How to compare floating point values.
* Errors accumulate:: Errors get bigger as they go.
+* Strange values:: A few words about infinities and NaNs.

File: gawk.info, Node: Inexact representation, Next: Comparing FP Values, Up: Inexactness of computations
@@ -24473,7 +24464,7 @@ values with a delta, you should be sure to use 'difference < abs(delta)'
in case someone passes in a negative delta value.

-File: gawk.info, Node: Errors accumulate, Prev: Comparing FP Values, Up: Inexactness of computations
+File: gawk.info, Node: Errors accumulate, Next: Strange values, Prev: Comparing FP Values, Up: Inexactness of computations
16.4.1.3 Errors Accumulate
..........................
@@ -24521,6 +24512,64 @@ representations yield an unexpected result:
-| 4

+File: gawk.info, Node: Strange values, Prev: Errors accumulate, Up: Inexactness of computations
+
+16.4.1.4 Floating Point Values They Didn't Talk About In School
+...............................................................
+
+Both IEEE 754 floating-point hardware, and MPFR, support two kinds of
+values that you probably didn't learn about in school. The first is
+"infinity", a special value, that can be either negative or positive,
+and which is either smaller than any other value (negative infinity), or
+larger than any other value (positive infinity). When such values are
+generated, 'gawk' prints them as either '-inf' or '+inf', respectively.
+It accepts those strings as data input and converts them to the proper
+floating-point values internally.
+
+ Infinity values of the same sign compare as equal to each other.
+Otherwise, operations (addition, subtraction, etc.) involving another
+number and infinity produce mathematically reasonable results.
+
+ The second kind of value is "not a number", or NaN for short.(1)
+This is a special value that results from attempting a calculation that
+has no answer as a real number. In such a case, programs can either
+receive a floating-point exception, or get NaN back as the result. The
+IEEE 754 standard recommends that systems return NaN. Some examples:
+
+'sqrt(-1)'
+ This makes sense in the range of complex numbers, but not in the
+ range of real numbers, so the result is NaN.
+
+'log(-8)'
+ -8 is out of the domain of 'log()', so the result is NaN.
+
+ NaN values are strange. In particular, they cannot be compared with
+other floating point values; any such comparison, except for "is not
+equal to", returns false. NaN values are so much unequal to other
+values that even comparing two identical NaN values with '!=' returns
+true!
+
+ NaN values can also be signed, although it depends upon the
+implementation as to which sign you get for any operation that returns a
+NaN. For example, on some systems, 'sqrt(-1)' returns a negative NaN. On
+others, it returns a positive NaN.
+
+ When such values are generated, 'gawk' prints them as either '-nan'
+or '+nan', respectively. Here too, 'gawk' accepts those strings as data
+input and converts them to the proper floating-point values internally.
+
+ If you want to dive more deeply into this topic, you can find test
+programs in C, 'awk' and Python in the directory
+'awklib/eg/test-programs' in the 'gawk' distribution. These programs
+enable comparison among programming languages as to how they handle NaN
+and infinity values.
+
+ ---------- Footnotes ----------
+
+ (1) Thanks to Michael Brennan for this description, which we have
+paraphrased, and for the examples.
+
+
File: gawk.info, Node: Getting Accuracy, Next: Try To Round, Prev: Inexactness of computations, Up: FP Math Caution
16.4.2 Getting the Accuracy You Need
@@ -38063,603 +38112,604 @@ Index

Tag Table:
Node: Top1200
-Node: Foreword344559
-Node: Foreword449001
-Node: Preface50533
-Ref: Preface-Footnote-153392
-Ref: Preface-Footnote-253501
-Ref: Preface-Footnote-353735
-Node: History53877
-Node: Names56229
-Ref: Names-Footnote-157333
-Node: This Manual57480
-Ref: This Manual-Footnote-164119
-Node: Conventions64219
-Node: Manual History66588
-Ref: Manual History-Footnote-169585
-Ref: Manual History-Footnote-269626
-Node: How To Contribute69700
-Node: Acknowledgments70626
-Node: Getting Started75563
-Node: Running gawk78002
-Node: One-shot79192
-Node: Read Terminal80455
-Node: Long82448
-Node: Executable Scripts83961
-Ref: Executable Scripts-Footnote-186594
-Node: Comments86697
-Node: Quoting89181
-Node: DOS Quoting94707
-Node: Sample Data Files96763
-Node: Very Simple99358
-Node: Two Rules105460
-Node: More Complex107345
-Node: Statements/Lines109677
-Ref: Statements/Lines-Footnote-1114161
-Node: Other Features114426
-Node: When115362
-Ref: When-Footnote-1117116
-Node: Intro Summary117181
-Node: Invoking Gawk118065
-Node: Command Line119579
-Node: Options120377
-Ref: Options-Footnote-1138291
-Ref: Options-Footnote-2138522
-Node: Other Arguments138547
-Node: Naming Standard Input142558
-Node: Environment Variables143768
-Node: AWKPATH Variable144326
-Ref: AWKPATH Variable-Footnote-1147738
-Ref: AWKPATH Variable-Footnote-2147772
-Node: AWKLIBPATH Variable148143
-Ref: AWKLIBPATH Variable-Footnote-1149840
-Node: Other Environment Variables150215
-Node: Exit Status154036
-Node: Include Files154713
-Node: Loading Shared Libraries158403
-Node: Obsolete159831
-Node: Undocumented160523
-Node: Invoking Summary160820
-Node: Regexp163661
-Node: Regexp Usage165115
-Node: Escape Sequences167152
-Node: Regexp Operators173393
-Node: Regexp Operator Details173878
-Ref: Regexp Operator Details-Footnote-1181242
-Node: Interval Expressions181389
-Ref: Interval Expressions-Footnote-1182810
-Node: Bracket Expressions182908
-Ref: table-char-classes185384
-Node: Leftmost Longest188710
-Node: Computed Regexps190013
-Node: GNU Regexp Operators193440
-Node: Case-sensitivity197177
-Ref: Case-sensitivity-Footnote-1200043
-Ref: Case-sensitivity-Footnote-2200278
-Node: Regexp Summary200386
-Node: Reading Files201852
-Node: Records204121
-Node: awk split records205196
-Node: gawk split records209896
-Ref: gawk split records-Footnote-1214970
-Node: Fields215007
-Node: Nonconstant Fields217748
-Ref: Nonconstant Fields-Footnote-1219984
-Node: Changing Fields220188
-Node: Field Separators226219
-Node: Default Field Splitting228917
-Node: Regexp Field Splitting230035
-Node: Single Character Fields233712
-Node: Command Line Field Separator234772
-Node: Full Line Fields237990
-Ref: Full Line Fields-Footnote-1239512
-Ref: Full Line Fields-Footnote-2239558
-Node: Field Splitting Summary239659
-Node: Constant Size241733
-Node: Fixed width data242465
-Node: Skipping intervening245932
-Node: Allowing trailing data246730
-Node: Fields with fixed data247767
-Node: Splitting By Content249285
-Ref: Splitting By Content-Footnote-1253068
-Node: More CSV253231
-Node: Testing field creation254823
-Node: Multiple Line256448
-Node: Getline262725
-Node: Plain Getline265194
-Node: Getline/Variable267767
-Node: Getline/File268918
-Node: Getline/Variable/File270306
-Ref: Getline/Variable/File-Footnote-1271911
-Node: Getline/Pipe271999
-Node: Getline/Variable/Pipe274703
-Node: Getline/Coprocess275838
-Node: Getline/Variable/Coprocess277105
-Node: Getline Notes277847
-Node: Getline Summary280644
-Ref: table-getline-variants281068
-Node: Read Timeout281816
-Ref: Read Timeout-Footnote-1285722
-Node: Retrying Input285780
-Node: Command-line directories286979
-Node: Input Summary287885
-Node: Input Exercises291057
-Node: Printing291491
-Node: Print293325
-Node: Print Examples294782
-Node: Output Separators297562
-Node: OFMT299579
-Node: Printf300935
-Node: Basic Printf301720
-Node: Control Letters303294
-Node: Format Modifiers308458
-Node: Printf Examples314473
-Node: Redirection316959
-Node: Special FD323800
-Ref: Special FD-Footnote-1326968
-Node: Special Files327042
-Node: Other Inherited Files327659
-Node: Special Network328660
-Node: Special Caveats329520
-Node: Close Files And Pipes330469
-Ref: table-close-pipe-return-values337376
-Ref: Close Files And Pipes-Footnote-1338189
-Ref: Close Files And Pipes-Footnote-2338337
-Node: Nonfatal338489
-Node: Output Summary340827
-Node: Output Exercises342049
-Node: Expressions342728
-Node: Values343916
-Node: Constants344594
-Node: Scalar Constants345285
-Ref: Scalar Constants-Footnote-1347795
-Node: Nondecimal-numbers348045
-Node: Regexp Constants351046
-Node: Using Constant Regexps351572
-Node: Standard Regexp Constants352194
-Node: Strong Regexp Constants355382
-Node: Variables358394
-Node: Using Variables359051
-Node: Assignment Options360961
-Node: Conversion363432
-Node: Strings And Numbers363956
-Ref: Strings And Numbers-Footnote-1367019
-Node: Locale influences conversions367128
-Ref: table-locale-affects369886
-Node: All Operators370504
-Node: Arithmetic Ops371133
-Node: Concatenation373849
-Ref: Concatenation-Footnote-1376696
-Node: Assignment Ops376803
-Ref: table-assign-ops381794
-Node: Increment Ops383107
-Node: Truth Values and Conditions386567
-Node: Truth Values387641
-Node: Typing and Comparison388689
-Node: Variable Typing389509
-Ref: Variable Typing-Footnote-1395972
-Ref: Variable Typing-Footnote-2396044
-Node: Comparison Operators396121
-Ref: table-relational-ops396540
-Node: POSIX String Comparison400035
-Ref: POSIX String Comparison-Footnote-1401730
-Ref: POSIX String Comparison-Footnote-2401869
-Node: Boolean Ops401953
-Ref: Boolean Ops-Footnote-1406435
-Node: Conditional Exp406527
-Node: Function Calls408263
-Node: Precedence412140
-Node: Locales415799
-Node: Expressions Summary417431
-Node: Patterns and Actions420004
-Node: Pattern Overview421124
-Node: Regexp Patterns422801
-Node: Expression Patterns423343
-Node: Ranges427124
-Node: BEGIN/END430232
-Node: Using BEGIN/END430993
-Ref: Using BEGIN/END-Footnote-1433747
-Node: I/O And BEGIN/END433853
-Node: BEGINFILE/ENDFILE436166
-Node: Empty439397
-Node: Using Shell Variables439714
-Node: Action Overview441988
-Node: Statements444313
-Node: If Statement446161
-Node: While Statement447656
-Node: Do Statement449684
-Node: For Statement450832
-Node: Switch Statement454003
-Node: Break Statement456444
-Node: Continue Statement458536
-Node: Next Statement460363
-Node: Nextfile Statement462746
-Node: Exit Statement465435
-Node: Built-in Variables467838
-Node: User-modified468971
-Node: Auto-set476738
-Ref: Auto-set-Footnote-1493545
-Ref: Auto-set-Footnote-2493751
-Node: ARGC and ARGV493807
-Node: Pattern Action Summary498020
-Node: Arrays500450
-Node: Array Basics501779
-Node: Array Intro502623
-Ref: figure-array-elements504598
-Ref: Array Intro-Footnote-1507302
-Node: Reference to Elements507430
-Node: Assigning Elements509894
-Node: Array Example510385
-Node: Scanning an Array512144
-Node: Controlling Scanning515166
-Ref: Controlling Scanning-Footnote-1521622
-Node: Numeric Array Subscripts521938
-Node: Uninitialized Subscripts524122
-Node: Delete525741
-Ref: Delete-Footnote-1528493
-Node: Multidimensional528550
-Node: Multiscanning531645
-Node: Arrays of Arrays533236
-Node: Arrays Summary538004
-Node: Functions540097
-Node: Built-in541135
-Node: Calling Built-in542216
-Node: Numeric Functions544212
-Ref: Numeric Functions-Footnote-1548240
-Ref: Numeric Functions-Footnote-2548888
-Ref: Numeric Functions-Footnote-3548936
-Node: String Functions549208
-Ref: String Functions-Footnote-1573349
-Ref: String Functions-Footnote-2573477
-Ref: String Functions-Footnote-3573725
-Node: Gory Details573812
-Ref: table-sub-escapes575603
-Ref: table-sub-proposed577122
-Ref: table-posix-sub578485
-Ref: table-gensub-escapes580026
-Ref: Gory Details-Footnote-1580849
-Node: I/O Functions581003
-Ref: table-system-return-values587457
-Ref: I/O Functions-Footnote-1589537
-Ref: I/O Functions-Footnote-2589685
-Node: Time Functions589805
-Ref: Time Functions-Footnote-1600476
-Ref: Time Functions-Footnote-2600544
-Ref: Time Functions-Footnote-3600702
-Ref: Time Functions-Footnote-4600813
-Ref: Time Functions-Footnote-5600925
-Ref: Time Functions-Footnote-6601152
-Node: Bitwise Functions601418
-Ref: table-bitwise-ops602012
-Ref: Bitwise Functions-Footnote-1608075
-Ref: Bitwise Functions-Footnote-2608248
-Node: Type Functions608439
-Node: I18N Functions611302
-Node: User-defined612953
-Node: Definition Syntax613765
-Ref: Definition Syntax-Footnote-1619459
-Node: Function Example619530
-Ref: Function Example-Footnote-1622452
-Node: Function Calling622474
-Node: Calling A Function623062
-Node: Variable Scope624020
-Node: Pass By Value/Reference627014
-Node: Function Caveats629658
-Ref: Function Caveats-Footnote-1631705
-Node: Return Statement631825
-Node: Dynamic Typing634804
-Node: Indirect Calls635734
-Ref: Indirect Calls-Footnote-1645986
-Node: Functions Summary646114
-Node: Library Functions648819
-Ref: Library Functions-Footnote-1652426
-Ref: Library Functions-Footnote-2652569
-Node: Library Names652740
-Ref: Library Names-Footnote-1656407
-Ref: Library Names-Footnote-2656630
-Node: General Functions656716
-Node: Strtonum Function657819
-Node: Assert Function660841
-Node: Round Function664167
-Node: Cliff Random Function665707
-Node: Ordinal Functions666723
-Ref: Ordinal Functions-Footnote-1669786
-Ref: Ordinal Functions-Footnote-2670038
-Node: Join Function670248
-Ref: Join Function-Footnote-1672018
-Node: Getlocaltime Function672218
-Node: Readfile Function675960
-Node: Shell Quoting677937
-Node: Data File Management679338
-Node: Filetrans Function679970
-Node: Rewind Function684066
-Node: File Checking685975
-Ref: File Checking-Footnote-1687309
-Node: Empty Files687510
-Node: Ignoring Assigns689489
-Node: Getopt Function691039
-Ref: Getopt Function-Footnote-1706250
-Node: Passwd Functions706450
-Ref: Passwd Functions-Footnote-1715289
-Node: Group Functions715377
-Ref: Group Functions-Footnote-1723275
-Node: Walking Arrays723482
-Node: Library Functions Summary726490
-Node: Library Exercises727896
-Node: Sample Programs728361
-Node: Running Examples729131
-Node: Clones729859
-Node: Cut Program731083
-Node: Egrep Program741223
-Node: Id Program750224
-Node: Split Program760171
-Ref: Split Program-Footnote-1770061
-Node: Tee Program770234
-Node: Uniq Program773024
-Node: Wc Program780612
-Node: Bytes vs. Characters781009
-Node: Using extensions782557
-Node: wc program783311
-Node: Miscellaneous Programs788176
-Node: Dupword Program789389
-Node: Alarm Program791419
-Node: Translate Program796274
-Ref: Translate Program-Footnote-1800839
-Node: Labels Program801109
-Ref: Labels Program-Footnote-1804460
-Node: Word Sorting804544
-Node: History Sorting808616
-Node: Extract Program810841
-Node: Simple Sed818895
-Node: Igawk Program821969
-Ref: Igawk Program-Footnote-1836300
-Ref: Igawk Program-Footnote-2836502
-Ref: Igawk Program-Footnote-3836624
-Node: Anagram Program836739
-Node: Signature Program839801
-Node: Programs Summary841048
-Node: Programs Exercises842262
-Ref: Programs Exercises-Footnote-1846392
-Node: Advanced Features846478
-Node: Nondecimal Data848545
-Node: Array Sorting850136
-Node: Controlling Array Traversal850836
-Ref: Controlling Array Traversal-Footnote-1859204
-Node: Array Sorting Functions859322
-Ref: Array Sorting Functions-Footnote-1864413
-Node: Two-way I/O864609
-Ref: Two-way I/O-Footnote-1872330
-Ref: Two-way I/O-Footnote-2872517
-Node: TCP/IP Networking872599
-Node: Profiling875717
-Node: Extension Philosophy885026
-Node: Advanced Features Summary886505
-Node: Internationalization888520
-Node: I18N and L10N890000
-Node: Explaining gettext890687
-Ref: Explaining gettext-Footnote-1896579
-Ref: Explaining gettext-Footnote-2896764
-Node: Programmer i18n896929
-Ref: Programmer i18n-Footnote-1901878
-Node: Translator i18n901927
-Node: String Extraction902721
-Ref: String Extraction-Footnote-1903853
-Node: Printf Ordering903939
-Ref: Printf Ordering-Footnote-1906725
-Node: I18N Portability906789
-Ref: I18N Portability-Footnote-1909245
-Node: I18N Example909308
-Ref: I18N Example-Footnote-1912583
-Ref: I18N Example-Footnote-2912656
-Node: Gawk I18N912765
-Node: I18N Summary913414
-Node: Debugger914755
-Node: Debugging915755
-Node: Debugging Concepts916196
-Node: Debugging Terms918005
-Node: Awk Debugging920580
-Ref: Awk Debugging-Footnote-1921525
-Node: Sample Debugging Session921657
-Node: Debugger Invocation922191
-Node: Finding The Bug923577
-Node: List of Debugger Commands930051
-Node: Breakpoint Control931384
-Node: Debugger Execution Control935078
-Node: Viewing And Changing Data938440
-Node: Execution Stack941981
-Node: Debugger Info943618
-Node: Miscellaneous Debugger Commands947689
-Node: Readline Support952751
-Node: Limitations953647
-Node: Debugging Summary956201
-Node: Namespaces957480
-Node: Global Namespace958591
-Node: Qualified Names959989
-Node: Default Namespace960988
-Node: Changing The Namespace961729
-Node: Naming Rules963343
-Node: Internal Name Management965191
-Node: Namespace Example966233
-Node: Namespace And Features968795
-Node: Namespace Summary970230
-Node: Arbitrary Precision Arithmetic971707
-Node: Computer Arithmetic973194
-Ref: table-numeric-ranges976960
-Ref: table-floating-point-ranges977453
-Ref: Computer Arithmetic-Footnote-1978111
-Node: Math Definitions978168
-Ref: table-ieee-formats981484
-Ref: Math Definitions-Footnote-1982087
-Node: MPFR features982192
-Node: FP Math Caution983910
-Ref: FP Math Caution-Footnote-1984982
-Node: Inexactness of computations985351
-Node: Inexact representation986311
-Node: Comparing FP Values987671
-Node: Errors accumulate988912
-Node: Getting Accuracy990345
-Node: Try To Round993055
-Node: Setting precision993954
-Ref: table-predefined-precision-strings994651
-Node: Setting the rounding mode996481
-Ref: table-gawk-rounding-modes996855
-Ref: Setting the rounding mode-Footnote-11000786
-Node: Arbitrary Precision Integers1000965
-Ref: Arbitrary Precision Integers-Footnote-11004140
-Node: Checking for MPFR1004289
-Node: POSIX Floating Point Problems1005763
-Ref: POSIX Floating Point Problems-Footnote-11010048
-Node: Floating point summary1010086
-Node: Dynamic Extensions1012276
-Node: Extension Intro1013829
-Node: Plugin License1015095
-Node: Extension Mechanism Outline1015892
-Ref: figure-load-extension1016331
-Ref: figure-register-new-function1017896
-Ref: figure-call-new-function1018988
-Node: Extension API Description1021050
-Node: Extension API Functions Introduction1022763
-Ref: table-api-std-headers1024599
-Node: General Data Types1028848
-Ref: General Data Types-Footnote-11037478
-Node: Memory Allocation Functions1037777
-Ref: Memory Allocation Functions-Footnote-11042278
-Node: Constructor Functions1042377
-Node: API Ownership of MPFR and GMP Values1045843
-Node: Registration Functions1047156
-Node: Extension Functions1047856
-Node: Exit Callback Functions1053178
-Node: Extension Version String1054428
-Node: Input Parsers1055091
-Node: Output Wrappers1067812
-Node: Two-way processors1072324
-Node: Printing Messages1074589
-Ref: Printing Messages-Footnote-11075760
-Node: Updating ERRNO1075913
-Node: Requesting Values1076652
-Ref: table-value-types-returned1077389
-Node: Accessing Parameters1078325
-Node: Symbol Table Access1079562
-Node: Symbol table by name1080074
-Ref: Symbol table by name-Footnote-11083098
-Node: Symbol table by cookie1083226
-Ref: Symbol table by cookie-Footnote-11087411
-Node: Cached values1087475
-Ref: Cached values-Footnote-11091011
-Node: Array Manipulation1091164
-Ref: Array Manipulation-Footnote-11092255
-Node: Array Data Types1092292
-Ref: Array Data Types-Footnote-11094950
-Node: Array Functions1095042
-Node: Flattening Arrays1099540
-Node: Creating Arrays1106516
-Node: Redirection API1111283
-Node: Extension API Variables1114116
-Node: Extension Versioning1114827
-Ref: gawk-api-version1115256
-Node: Extension GMP/MPFR Versioning1116987
-Node: Extension API Informational Variables1118615
-Node: Extension API Boilerplate1119688
-Node: Changes from API V11123662
-Node: Finding Extensions1125234
-Node: Extension Example1125793
-Node: Internal File Description1126591
-Node: Internal File Ops1130671
-Ref: Internal File Ops-Footnote-11142021
-Node: Using Internal File Ops1142161
-Ref: Using Internal File Ops-Footnote-11144544
-Node: Extension Samples1144818
-Node: Extension Sample File Functions1146347
-Node: Extension Sample Fnmatch1153996
-Node: Extension Sample Fork1155483
-Node: Extension Sample Inplace1156701
-Node: Extension Sample Ord1160327
-Node: Extension Sample Readdir1161163
-Ref: table-readdir-file-types1162052
-Node: Extension Sample Revout1163119
-Node: Extension Sample Rev2way1163708
-Node: Extension Sample Read write array1164448
-Node: Extension Sample Readfile1166390
-Node: Extension Sample Time1167485
-Node: Extension Sample API Tests1169237
-Node: gawkextlib1169729
-Node: Extension summary1172647
-Node: Extension Exercises1176349
-Node: Language History1177591
-Node: V7/SVR3.11179247
-Node: SVR41181399
-Node: POSIX1182833
-Node: BTL1184214
-Node: POSIX/GNU1184943
-Node: Feature History1190721
-Node: Common Extensions1207040
-Node: Ranges and Locales1208323
-Ref: Ranges and Locales-Footnote-11212939
-Ref: Ranges and Locales-Footnote-21212966
-Ref: Ranges and Locales-Footnote-31213201
-Node: Contributors1213424
-Node: History summary1219421
-Node: Installation1220801
-Node: Gawk Distribution1221745
-Node: Getting1222229
-Node: Extracting1223192
-Node: Distribution contents1224830
-Node: Unix Installation1231310
-Node: Quick Installation1231992
-Node: Shell Startup Files1234406
-Node: Additional Configuration Options1235495
-Node: Configuration Philosophy1237810
-Node: Non-Unix Installation1240179
-Node: PC Installation1240639
-Node: PC Binary Installation1241477
-Node: PC Compiling1241912
-Node: PC Using1243029
-Node: Cygwin1246582
-Node: MSYS1247806
-Node: VMS Installation1248408
-Node: VMS Compilation1249199
-Ref: VMS Compilation-Footnote-11250428
-Node: VMS Dynamic Extensions1250486
-Node: VMS Installation Details1252171
-Node: VMS Running1254424
-Node: VMS GNV1258703
-Node: VMS Old Gawk1259438
-Node: Bugs1259909
-Node: Bug address1260572
-Node: Usenet1263554
-Node: Maintainers1264558
-Node: Other Versions1265743
-Node: Installation summary1273608
-Node: Notes1274817
-Node: Compatibility Mode1275611
-Node: Additions1276393
-Node: Accessing The Source1277318
-Node: Adding Code1278755
-Node: New Ports1284974
-Node: Derived Files1289349
-Ref: Derived Files-Footnote-11295009
-Ref: Derived Files-Footnote-21295044
-Ref: Derived Files-Footnote-31295642
-Node: Future Extensions1295756
-Node: Implementation Limitations1296414
-Node: Extension Design1297624
-Node: Old Extension Problems1298768
-Ref: Old Extension Problems-Footnote-11300286
-Node: Extension New Mechanism Goals1300343
-Ref: Extension New Mechanism Goals-Footnote-11303707
-Node: Extension Other Design Decisions1303896
-Node: Extension Future Growth1306009
-Node: Notes summary1306615
-Node: Basic Concepts1307773
-Node: Basic High Level1308454
-Ref: figure-general-flow1308736
-Ref: figure-process-flow1309421
-Ref: Basic High Level-Footnote-11312722
-Node: Basic Data Typing1312907
-Node: Glossary1316235
-Node: Copying1348120
-Node: GNU Free Documentation License1385663
-Node: Index1410783
+Node: Foreword344638
+Node: Foreword449080
+Node: Preface50612
+Ref: Preface-Footnote-153471
+Ref: Preface-Footnote-253580
+Ref: Preface-Footnote-353814
+Node: History53956
+Node: Names56308
+Ref: Names-Footnote-157412
+Node: This Manual57559
+Ref: This Manual-Footnote-164198
+Node: Conventions64298
+Node: Manual History66667
+Ref: Manual History-Footnote-169664
+Ref: Manual History-Footnote-269705
+Node: How To Contribute69779
+Node: Acknowledgments70705
+Node: Getting Started75642
+Node: Running gawk78081
+Node: One-shot79271
+Node: Read Terminal80534
+Node: Long82527
+Node: Executable Scripts84040
+Ref: Executable Scripts-Footnote-186673
+Node: Comments86776
+Node: Quoting89260
+Node: DOS Quoting94786
+Node: Sample Data Files96842
+Node: Very Simple99437
+Node: Two Rules105539
+Node: More Complex107424
+Node: Statements/Lines109756
+Ref: Statements/Lines-Footnote-1114240
+Node: Other Features114505
+Node: When115441
+Ref: When-Footnote-1117195
+Node: Intro Summary117260
+Node: Invoking Gawk118144
+Node: Command Line119658
+Node: Options120456
+Ref: Options-Footnote-1138370
+Ref: Options-Footnote-2138601
+Node: Other Arguments138626
+Node: Naming Standard Input142637
+Node: Environment Variables143847
+Node: AWKPATH Variable144405
+Ref: AWKPATH Variable-Footnote-1147817
+Ref: AWKPATH Variable-Footnote-2147851
+Node: AWKLIBPATH Variable148222
+Ref: AWKLIBPATH Variable-Footnote-1149919
+Node: Other Environment Variables150294
+Node: Exit Status154246
+Node: Include Files154923
+Node: Loading Shared Libraries158613
+Node: Obsolete160041
+Node: Undocumented160733
+Node: Invoking Summary161030
+Node: Regexp163871
+Node: Regexp Usage165325
+Node: Escape Sequences167362
+Node: Regexp Operators173603
+Node: Regexp Operator Details174088
+Ref: Regexp Operator Details-Footnote-1181452
+Node: Interval Expressions181599
+Ref: Interval Expressions-Footnote-1183020
+Node: Bracket Expressions183118
+Ref: table-char-classes185594
+Node: Leftmost Longest188920
+Node: Computed Regexps190223
+Node: GNU Regexp Operators193650
+Node: Case-sensitivity197387
+Ref: Case-sensitivity-Footnote-1200253
+Ref: Case-sensitivity-Footnote-2200488
+Node: Regexp Summary200596
+Node: Reading Files202062
+Node: Records204331
+Node: awk split records205406
+Node: gawk split records210106
+Ref: gawk split records-Footnote-1215180
+Node: Fields215217
+Node: Nonconstant Fields217958
+Ref: Nonconstant Fields-Footnote-1220194
+Node: Changing Fields220398
+Node: Field Separators226429
+Node: Default Field Splitting229127
+Node: Regexp Field Splitting230245
+Node: Single Character Fields233922
+Node: Command Line Field Separator234982
+Node: Full Line Fields238200
+Ref: Full Line Fields-Footnote-1239722
+Ref: Full Line Fields-Footnote-2239768
+Node: Field Splitting Summary239869
+Node: Constant Size241943
+Node: Fixed width data242675
+Node: Skipping intervening246142
+Node: Allowing trailing data246940
+Node: Fields with fixed data247977
+Node: Splitting By Content249495
+Ref: Splitting By Content-Footnote-1253278
+Node: More CSV253441
+Node: Testing field creation255033
+Node: Multiple Line256658
+Node: Getline262935
+Node: Plain Getline265404
+Node: Getline/Variable267977
+Node: Getline/File269128
+Node: Getline/Variable/File270516
+Ref: Getline/Variable/File-Footnote-1272121
+Node: Getline/Pipe272209
+Node: Getline/Variable/Pipe274913
+Node: Getline/Coprocess276048
+Node: Getline/Variable/Coprocess277315
+Node: Getline Notes278057
+Node: Getline Summary280854
+Ref: table-getline-variants281278
+Node: Read Timeout282026
+Ref: Read Timeout-Footnote-1285932
+Node: Retrying Input285990
+Node: Command-line directories287189
+Node: Input Summary288095
+Node: Input Exercises291267
+Node: Printing291701
+Node: Print293535
+Node: Print Examples294992
+Node: Output Separators297772
+Node: OFMT299789
+Node: Printf301145
+Node: Basic Printf301930
+Node: Control Letters303504
+Node: Format Modifiers308666
+Node: Printf Examples314681
+Node: Redirection317167
+Node: Special FD324008
+Ref: Special FD-Footnote-1327176
+Node: Special Files327250
+Node: Other Inherited Files327867
+Node: Special Network328868
+Node: Special Caveats329728
+Node: Close Files And Pipes330677
+Ref: table-close-pipe-return-values337584
+Ref: Close Files And Pipes-Footnote-1338397
+Ref: Close Files And Pipes-Footnote-2338545
+Node: Nonfatal338697
+Node: Output Summary341035
+Node: Output Exercises342257
+Node: Expressions342936
+Node: Values344124
+Node: Constants344802
+Node: Scalar Constants345493
+Ref: Scalar Constants-Footnote-1348003
+Node: Nondecimal-numbers348253
+Node: Regexp Constants351254
+Node: Using Constant Regexps351780
+Node: Standard Regexp Constants352402
+Node: Strong Regexp Constants355590
+Node: Variables358602
+Node: Using Variables359259
+Node: Assignment Options361169
+Node: Conversion363640
+Node: Strings And Numbers364164
+Ref: Strings And Numbers-Footnote-1367227
+Node: Locale influences conversions367336
+Ref: table-locale-affects370094
+Node: All Operators370712
+Node: Arithmetic Ops371341
+Node: Concatenation374057
+Ref: Concatenation-Footnote-1376904
+Node: Assignment Ops377011
+Ref: table-assign-ops382002
+Node: Increment Ops383315
+Node: Truth Values and Conditions386775
+Node: Truth Values387849
+Node: Typing and Comparison388897
+Node: Variable Typing389717
+Ref: Variable Typing-Footnote-1396180
+Ref: Variable Typing-Footnote-2396252
+Node: Comparison Operators396329
+Ref: table-relational-ops396748
+Node: POSIX String Comparison400243
+Ref: POSIX String Comparison-Footnote-1401938
+Ref: POSIX String Comparison-Footnote-2402077
+Node: Boolean Ops402161
+Ref: Boolean Ops-Footnote-1406643
+Node: Conditional Exp406735
+Node: Function Calls408471
+Node: Precedence412348
+Node: Locales416007
+Node: Expressions Summary417639
+Node: Patterns and Actions420212
+Node: Pattern Overview421332
+Node: Regexp Patterns423009
+Node: Expression Patterns423551
+Node: Ranges427332
+Node: BEGIN/END430440
+Node: Using BEGIN/END431201
+Ref: Using BEGIN/END-Footnote-1433955
+Node: I/O And BEGIN/END434061
+Node: BEGINFILE/ENDFILE436374
+Node: Empty439605
+Node: Using Shell Variables439922
+Node: Action Overview442196
+Node: Statements444521
+Node: If Statement446369
+Node: While Statement447864
+Node: Do Statement449892
+Node: For Statement451040
+Node: Switch Statement454211
+Node: Break Statement456652
+Node: Continue Statement458744
+Node: Next Statement460571
+Node: Nextfile Statement462954
+Node: Exit Statement465643
+Node: Built-in Variables468046
+Node: User-modified469179
+Node: Auto-set476946
+Ref: Auto-set-Footnote-1493753
+Ref: Auto-set-Footnote-2493959
+Node: ARGC and ARGV494015
+Node: Pattern Action Summary498228
+Node: Arrays500658
+Node: Array Basics501987
+Node: Array Intro502831
+Ref: figure-array-elements504806
+Ref: Array Intro-Footnote-1507510
+Node: Reference to Elements507638
+Node: Assigning Elements510102
+Node: Array Example510593
+Node: Scanning an Array512352
+Node: Controlling Scanning515374
+Ref: Controlling Scanning-Footnote-1521830
+Node: Numeric Array Subscripts522146
+Node: Uninitialized Subscripts524330
+Node: Delete525949
+Ref: Delete-Footnote-1528701
+Node: Multidimensional528758
+Node: Multiscanning531853
+Node: Arrays of Arrays533444
+Node: Arrays Summary538212
+Node: Functions540305
+Node: Built-in541343
+Node: Calling Built-in542424
+Node: Numeric Functions544420
+Ref: Numeric Functions-Footnote-1548446
+Ref: Numeric Functions-Footnote-2549094
+Ref: Numeric Functions-Footnote-3549142
+Node: String Functions549414
+Ref: String Functions-Footnote-1573555
+Ref: String Functions-Footnote-2573683
+Ref: String Functions-Footnote-3573931
+Node: Gory Details574018
+Ref: table-sub-escapes575809
+Ref: table-sub-proposed577328
+Ref: table-posix-sub578691
+Ref: table-gensub-escapes580232
+Ref: Gory Details-Footnote-1581055
+Node: I/O Functions581209
+Ref: table-system-return-values587663
+Ref: I/O Functions-Footnote-1589743
+Ref: I/O Functions-Footnote-2589891
+Node: Time Functions590011
+Ref: Time Functions-Footnote-1600682
+Ref: Time Functions-Footnote-2600750
+Ref: Time Functions-Footnote-3600908
+Ref: Time Functions-Footnote-4601019
+Ref: Time Functions-Footnote-5601131
+Ref: Time Functions-Footnote-6601358
+Node: Bitwise Functions601624
+Ref: table-bitwise-ops602218
+Ref: Bitwise Functions-Footnote-1608281
+Ref: Bitwise Functions-Footnote-2608454
+Node: Type Functions608645
+Node: I18N Functions611508
+Node: User-defined613159
+Node: Definition Syntax613971
+Ref: Definition Syntax-Footnote-1619665
+Node: Function Example619736
+Ref: Function Example-Footnote-1622658
+Node: Function Calling622680
+Node: Calling A Function623268
+Node: Variable Scope624226
+Node: Pass By Value/Reference627220
+Node: Function Caveats629864
+Ref: Function Caveats-Footnote-1631911
+Node: Return Statement632031
+Node: Dynamic Typing635010
+Node: Indirect Calls635940
+Ref: Indirect Calls-Footnote-1646192
+Node: Functions Summary646320
+Node: Library Functions649025
+Ref: Library Functions-Footnote-1652632
+Ref: Library Functions-Footnote-2652775
+Node: Library Names652946
+Ref: Library Names-Footnote-1656613
+Ref: Library Names-Footnote-2656836
+Node: General Functions656922
+Node: Strtonum Function658025
+Node: Assert Function661047
+Node: Round Function664373
+Node: Cliff Random Function665913
+Node: Ordinal Functions666929
+Ref: Ordinal Functions-Footnote-1669992
+Ref: Ordinal Functions-Footnote-2670244
+Node: Join Function670454
+Ref: Join Function-Footnote-1672224
+Node: Getlocaltime Function672424
+Node: Readfile Function676166
+Node: Shell Quoting678143
+Node: Data File Management679544
+Node: Filetrans Function680176
+Node: Rewind Function684272
+Node: File Checking686181
+Ref: File Checking-Footnote-1687515
+Node: Empty Files687716
+Node: Ignoring Assigns689695
+Node: Getopt Function691245
+Ref: Getopt Function-Footnote-1706456
+Node: Passwd Functions706656
+Ref: Passwd Functions-Footnote-1715495
+Node: Group Functions715583
+Ref: Group Functions-Footnote-1723481
+Node: Walking Arrays723688
+Node: Library Functions Summary726696
+Node: Library Exercises728102
+Node: Sample Programs728567
+Node: Running Examples729337
+Node: Clones730065
+Node: Cut Program731289
+Node: Egrep Program741429
+Node: Id Program750430
+Node: Split Program760377
+Ref: Split Program-Footnote-1770267
+Node: Tee Program770440
+Node: Uniq Program773230
+Node: Wc Program780818
+Node: Bytes vs. Characters781215
+Node: Using extensions782763
+Node: wc program783517
+Node: Miscellaneous Programs788382
+Node: Dupword Program789595
+Node: Alarm Program791625
+Node: Translate Program796480
+Ref: Translate Program-Footnote-1801045
+Node: Labels Program801315
+Ref: Labels Program-Footnote-1804666
+Node: Word Sorting804750
+Node: History Sorting808822
+Node: Extract Program811047
+Node: Simple Sed819101
+Node: Igawk Program822175
+Ref: Igawk Program-Footnote-1836506
+Ref: Igawk Program-Footnote-2836708
+Ref: Igawk Program-Footnote-3836830
+Node: Anagram Program836945
+Node: Signature Program840007
+Node: Programs Summary841254
+Node: Programs Exercises842468
+Ref: Programs Exercises-Footnote-1846598
+Node: Advanced Features846684
+Node: Nondecimal Data848751
+Node: Array Sorting850342
+Node: Controlling Array Traversal851042
+Ref: Controlling Array Traversal-Footnote-1859410
+Node: Array Sorting Functions859528
+Ref: Array Sorting Functions-Footnote-1864619
+Node: Two-way I/O864815
+Ref: Two-way I/O-Footnote-1872536
+Ref: Two-way I/O-Footnote-2872723
+Node: TCP/IP Networking872805
+Node: Profiling875923
+Node: Extension Philosophy885232
+Node: Advanced Features Summary886711
+Node: Internationalization888726
+Node: I18N and L10N890206
+Node: Explaining gettext890893
+Ref: Explaining gettext-Footnote-1896785
+Ref: Explaining gettext-Footnote-2896970
+Node: Programmer i18n897135
+Ref: Programmer i18n-Footnote-1902084
+Node: Translator i18n902133
+Node: String Extraction902927
+Ref: String Extraction-Footnote-1904059
+Node: Printf Ordering904145
+Ref: Printf Ordering-Footnote-1906931
+Node: I18N Portability906995
+Ref: I18N Portability-Footnote-1909451
+Node: I18N Example909514
+Ref: I18N Example-Footnote-1912789
+Ref: I18N Example-Footnote-2912862
+Node: Gawk I18N912971
+Node: I18N Summary913620
+Node: Debugger914961
+Node: Debugging915961
+Node: Debugging Concepts916402
+Node: Debugging Terms918211
+Node: Awk Debugging920786
+Ref: Awk Debugging-Footnote-1921731
+Node: Sample Debugging Session921863
+Node: Debugger Invocation922397
+Node: Finding The Bug923783
+Node: List of Debugger Commands930257
+Node: Breakpoint Control931590
+Node: Debugger Execution Control935284
+Node: Viewing And Changing Data938646
+Node: Execution Stack942187
+Node: Debugger Info943824
+Node: Miscellaneous Debugger Commands947895
+Node: Readline Support952957
+Node: Limitations953853
+Node: Debugging Summary956407
+Node: Namespaces957686
+Node: Global Namespace958797
+Node: Qualified Names960195
+Node: Default Namespace961194
+Node: Changing The Namespace961935
+Node: Naming Rules963549
+Node: Internal Name Management965397
+Node: Namespace Example966439
+Node: Namespace And Features969001
+Node: Namespace Summary970436
+Node: Arbitrary Precision Arithmetic971913
+Node: Computer Arithmetic973400
+Ref: table-numeric-ranges977166
+Ref: table-floating-point-ranges977659
+Ref: Computer Arithmetic-Footnote-1978317
+Node: Math Definitions978374
+Ref: table-ieee-formats981350
+Node: MPFR features981917
+Node: FP Math Caution983635
+Ref: FP Math Caution-Footnote-1984707
+Node: Inexactness of computations985076
+Node: Inexact representation986107
+Node: Comparing FP Values987467
+Node: Errors accumulate988708
+Node: Strange values990164
+Ref: Strange values-Footnote-1992752
+Node: Getting Accuracy992857
+Node: Try To Round995567
+Node: Setting precision996466
+Ref: table-predefined-precision-strings997163
+Node: Setting the rounding mode998993
+Ref: table-gawk-rounding-modes999367
+Ref: Setting the rounding mode-Footnote-11003298
+Node: Arbitrary Precision Integers1003477
+Ref: Arbitrary Precision Integers-Footnote-11006652
+Node: Checking for MPFR1006801
+Node: POSIX Floating Point Problems1008275
+Ref: POSIX Floating Point Problems-Footnote-11012560
+Node: Floating point summary1012598
+Node: Dynamic Extensions1014788
+Node: Extension Intro1016341
+Node: Plugin License1017607
+Node: Extension Mechanism Outline1018404
+Ref: figure-load-extension1018843
+Ref: figure-register-new-function1020408
+Ref: figure-call-new-function1021500
+Node: Extension API Description1023562
+Node: Extension API Functions Introduction1025275
+Ref: table-api-std-headers1027111
+Node: General Data Types1031360
+Ref: General Data Types-Footnote-11039990
+Node: Memory Allocation Functions1040289
+Ref: Memory Allocation Functions-Footnote-11044790
+Node: Constructor Functions1044889
+Node: API Ownership of MPFR and GMP Values1048355
+Node: Registration Functions1049668
+Node: Extension Functions1050368
+Node: Exit Callback Functions1055690
+Node: Extension Version String1056940
+Node: Input Parsers1057603
+Node: Output Wrappers1070324
+Node: Two-way processors1074836
+Node: Printing Messages1077101
+Ref: Printing Messages-Footnote-11078272
+Node: Updating ERRNO1078425
+Node: Requesting Values1079164
+Ref: table-value-types-returned1079901
+Node: Accessing Parameters1080837
+Node: Symbol Table Access1082074
+Node: Symbol table by name1082586
+Ref: Symbol table by name-Footnote-11085610
+Node: Symbol table by cookie1085738
+Ref: Symbol table by cookie-Footnote-11089923
+Node: Cached values1089987
+Ref: Cached values-Footnote-11093523
+Node: Array Manipulation1093676
+Ref: Array Manipulation-Footnote-11094767
+Node: Array Data Types1094804
+Ref: Array Data Types-Footnote-11097462
+Node: Array Functions1097554
+Node: Flattening Arrays1102052
+Node: Creating Arrays1109028
+Node: Redirection API1113795
+Node: Extension API Variables1116628
+Node: Extension Versioning1117339
+Ref: gawk-api-version1117768
+Node: Extension GMP/MPFR Versioning1119499
+Node: Extension API Informational Variables1121127
+Node: Extension API Boilerplate1122200
+Node: Changes from API V11126174
+Node: Finding Extensions1127746
+Node: Extension Example1128305
+Node: Internal File Description1129103
+Node: Internal File Ops1133183
+Ref: Internal File Ops-Footnote-11144533
+Node: Using Internal File Ops1144673
+Ref: Using Internal File Ops-Footnote-11147056
+Node: Extension Samples1147330
+Node: Extension Sample File Functions1148859
+Node: Extension Sample Fnmatch1156508
+Node: Extension Sample Fork1157995
+Node: Extension Sample Inplace1159213
+Node: Extension Sample Ord1162839
+Node: Extension Sample Readdir1163675
+Ref: table-readdir-file-types1164564
+Node: Extension Sample Revout1165631
+Node: Extension Sample Rev2way1166220
+Node: Extension Sample Read write array1166960
+Node: Extension Sample Readfile1168902
+Node: Extension Sample Time1169997
+Node: Extension Sample API Tests1171749
+Node: gawkextlib1172241
+Node: Extension summary1175159
+Node: Extension Exercises1178861
+Node: Language History1180103
+Node: V7/SVR3.11181759
+Node: SVR41183911
+Node: POSIX1185345
+Node: BTL1186726
+Node: POSIX/GNU1187455
+Node: Feature History1193233
+Node: Common Extensions1209552
+Node: Ranges and Locales1210835
+Ref: Ranges and Locales-Footnote-11215451
+Ref: Ranges and Locales-Footnote-21215478
+Ref: Ranges and Locales-Footnote-31215713
+Node: Contributors1215936
+Node: History summary1221933
+Node: Installation1223313
+Node: Gawk Distribution1224257
+Node: Getting1224741
+Node: Extracting1225704
+Node: Distribution contents1227342
+Node: Unix Installation1233822
+Node: Quick Installation1234504
+Node: Shell Startup Files1236918
+Node: Additional Configuration Options1238007
+Node: Configuration Philosophy1240322
+Node: Non-Unix Installation1242691
+Node: PC Installation1243151
+Node: PC Binary Installation1243989
+Node: PC Compiling1244424
+Node: PC Using1245541
+Node: Cygwin1249094
+Node: MSYS1250318
+Node: VMS Installation1250920
+Node: VMS Compilation1251711
+Ref: VMS Compilation-Footnote-11252940
+Node: VMS Dynamic Extensions1252998
+Node: VMS Installation Details1254683
+Node: VMS Running1256936
+Node: VMS GNV1261215
+Node: VMS Old Gawk1261950
+Node: Bugs1262421
+Node: Bug address1263084
+Node: Usenet1266066
+Node: Maintainers1267070
+Node: Other Versions1268255
+Node: Installation summary1276120
+Node: Notes1277329
+Node: Compatibility Mode1278123
+Node: Additions1278905
+Node: Accessing The Source1279830
+Node: Adding Code1281267
+Node: New Ports1287486
+Node: Derived Files1291861
+Ref: Derived Files-Footnote-11297521
+Ref: Derived Files-Footnote-21297556
+Ref: Derived Files-Footnote-31298154
+Node: Future Extensions1298268
+Node: Implementation Limitations1298926
+Node: Extension Design1300136
+Node: Old Extension Problems1301280
+Ref: Old Extension Problems-Footnote-11302798
+Node: Extension New Mechanism Goals1302855
+Ref: Extension New Mechanism Goals-Footnote-11306219
+Node: Extension Other Design Decisions1306408
+Node: Extension Future Growth1308521
+Node: Notes summary1309127
+Node: Basic Concepts1310285
+Node: Basic High Level1310966
+Ref: figure-general-flow1311248
+Ref: figure-process-flow1311933
+Ref: Basic High Level-Footnote-11315234
+Node: Basic Data Typing1315419
+Node: Glossary1318747
+Node: Copying1350632
+Node: GNU Free Documentation License1388175
+Node: Index1413295

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 7a746e1b..591246c0 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -920,6 +920,7 @@ particular records in a file and perform operations upon them.
* Inexact representation:: Numbers are not exactly represented.
* Comparing FP Values:: How to compare floating point values.
* Errors accumulate:: Errors get bigger as they go.
+* Strange values:: A few words about infinities and NaNs.
* Getting Accuracy:: Getting more accuracy takes some work.
* Try To Round:: Add digits and round.
* Setting precision:: How to set the precision.
@@ -3136,11 +3137,12 @@ column means that the person is a friend.
An @samp{R} means that the person is a relative:
@example
-@c system if test ! -d eg ; then mkdir eg ; fi
-@c system if test ! -d eg/lib ; then mkdir eg/lib ; fi
-@c system if test ! -d eg/data ; then mkdir eg/data ; fi
-@c system if test ! -d eg/prog ; then mkdir eg/prog ; fi
-@c system if test ! -d eg/misc ; then mkdir eg/misc ; fi
+@c system if test ! -d eg ; then mkdir eg ; fi
+@c system if test ! -d eg/lib ; then mkdir eg/lib ; fi
+@c system if test ! -d eg/data ; then mkdir eg/data ; fi
+@c system if test ! -d eg/prog ; then mkdir eg/prog ; fi
+@c system if test ! -d eg/misc ; then mkdir eg/misc ; fi
+@c system if test ! -d eg/test-programs ; then mkdir eg/test-programs ; fi
@c file eg/data/mail-list
Amelia 555-5553 amelia.zodiacusque@@gmail.com F
Anthony 555-3412 anthony.asserturo@@hotmail.com A
@@ -4840,7 +4842,10 @@ blocksize, which is usually the filesystem's I/O blocksize.)
If this variable exists with a value of @samp{gst}, @command{gawk}
switches to using the hash function from GNU Smalltalk for
managing arrays.
-This function may be marginally faster than the standard function.
+With a value of @samp{fnv1a}, @command{gawk} uses the
+@uref{http://www.isthe.com/chongo/tech/comp/fnv/index.html,
+FNV1-A hash function}.
+These functions may be marginally faster than the standard function.
@item AWKREADFUNC
If this variable exists, @command{gawk} switches to reading source
@@ -10195,7 +10200,7 @@ infinity are formatted as
and positive infinity as
@samp{inf} or @samp{infinity}.
The special ``not a number'' value formats as @samp{-nan} or @samp{nan}
-(@pxref{Math Definitions}).
+(@pxref{Strange values}).
@item @code{%F}
Like @samp{%f}, but the infinity and ``not a number'' values are spelled
@@ -18431,7 +18436,7 @@ compatibility mode (@pxref{Options}).
@cindexawkfunc{log}
@cindex logarithm
Return the natural logarithm of @var{x}, if @var{x} is positive;
-otherwise, return @code{NaN} (``not a number'') on IEEE 754 systems.
+otherwise, return NaN (``not a number'') on IEEE 754 systems.
Additionally, @command{gawk} prints a warning message when @code{x}
is negative.
@@ -33777,21 +33782,9 @@ A special value representing infinity. Operations involving another
number and infinity produce infinity.
@item NaN
-``Not a number.''@footnote{Thanks to Michael Brennan for this description,
-which we have paraphrased, and for the examples.} A special value that
-results from attempting a calculation that has no answer as a real number.
-In such a case, programs can either receive a floating-point exception,
-or get @code{NaN} back as the result. The IEEE 754 standard recommends
-that systems return @code{NaN}. Some examples:
-
-@table @code
-@item sqrt(-1)
-This makes sense in the range of complex numbers, but not in the
-range of real numbers, so the result is @code{NaN}.
-
-@item log(-8)
-@minus{}8 is out of the domain of @code{log()}, so the result is @code{NaN}.
-@end table
+``Not a number.'' A special value that results from attempting a
+calculation that has no answer as a real number. @xref{Strange values},
+for more information about infinity and not-a-number values.
@item Normalized
How the significand (see later in this list) is usually stored. The
@@ -33960,6 +33953,7 @@ decimal places in the final result.
* Inexact representation:: Numbers are not exactly represented.
* Comparing FP Values:: How to compare floating point values.
* Errors accumulate:: Errors get bigger as they go.
+* Strange values:: A few words about infinities and NaNs.
@end menu
@node Inexact representation
@@ -34081,6 +34075,242 @@ $ @kbd{gawk 'BEGIN @{}
@print{} 4
@end example
+@node Strange values
+@subsubsection Floating Point Values They Didn't Talk About In School
+
+Both IEEE 754 floating-point hardware, and MPFR, support two kinds of
+values that you probably didn't learn about in school. The first is
+@dfn{infinity}, a special value, that can be either negative or positive,
+and which is either smaller than any other value (negative infinity),
+or larger than any other value (positive infinity). When such values
+are generated, @command{gawk} prints them as either @samp{-inf} or
+@samp{+inf}, respectively. It accepts those strings as data input and
+converts them to the proper floating-point values internally.
+
+Infinity values of the same sign compare as equal to each other.
+Otherwise, operations (addition, subtraction, etc.) involving another
+number and infinity produce mathematically reasonable results.
+
+The second kind of value is ``not a number'', or NaN for
+short.@footnote{Thanks to Michael Brennan for this description, which we
+have paraphrased, and for the examples.} This is a special value that results
+from attempting a calculation that has no answer as a real number.
+In such a case, programs can either receive a floating-point exception,
+or get NaN back as the result. The IEEE 754 standard recommends
+that systems return NaN. Some examples:
+
+@table @code
+@item sqrt(-1)
+@iftex
+The @math{\sqrt{-1}}
+@end iftex
+@ifnottex
+This
+@end ifnottex
+makes sense in the range of complex numbers, but not in the
+range of real numbers, so the result is NaN.
+
+@item log(-8)
+@minus{}8 is out of the domain of @code{log()}, so the result is NaN.
+@end table
+
+NaN values are strange. In particular, they cannot be compared with other
+floating point values; any such comparison, except for ``is not equal
+to'', returns false. NaN values are so much unequal to other values that
+even comparing two identical NaN values with @code{!=} returns true!
+
+NaN values can also be signed, although it depends upon the implementation
+as to which sign you get for any operation that returns a NaN. For
+example, on some systems, @code{sqrt(-1)} returns a negative NaN. On
+others, it returns a positive NaN.
+
+When such values are generated, @command{gawk} prints them as either
+@samp{-nan} or @samp{+nan}, respectively. Here too, @command{gawk}
+accepts those strings as data input and converts them to the proper
+floating-point values internally.
+
+If you want to dive more deeply into this topic, you can find
+test programs in C, @command{awk} and Python in the directory
+@file{awklib/eg/test-programs} in the @command{gawk} distribution.
+These programs enable comparison among programming languages as to how
+they handle NaN and infinity values.
+
+@ignore
+@c file eg/test-programs/gen-float-table.awk
+function eq(left, right)
+@{
+ return left == right
+@}
+
+function ne(left, right)
+@{
+ return left != right
+@}
+
+function lt(left, right)
+@{
+ return left < right
+@}
+
+function le(left, right)
+@{
+ return left <= right
+@}
+
+function gt(left, right)
+@{
+ return left > right
+@}
+
+function ge(left, right)
+@{
+ return left >= right
+@}
+
+BEGIN @{
+ nan = sqrt(-1)
+ inf = -log(0)
+ split("== != < <= > >=", names)
+ names[3] = names[3] " "
+ names[5] = names[5] " "
+ split("eq ne lt le gt ge", funcs)
+
+ compare[1] = 2.0
+ compare[2] = values[1] = -sqrt(-1.0) # nan
+ compare[3] = values[2] = sqrt(-1.0) # -nan
+ compare[4] = values[3] = -log(0.0) # inf
+ compare[5] = values[4] = log(0.0) # -inf
+
+ for (i = 1; i in values; i++) @{
+ for (j = 1; j in compare; j++) @{
+ for (k = 1; k in names; k++) @{
+ the_func = funcs[k]
+ printf("%g %s %g -> %s\n",
+ values[i],
+ names[k],
+ compare[j],
+ @@the_func(values[i], compare[j]) ?
+ "True" : "False");
+ @}
+ printf("\n");
+ @}
+ @}
+@}
+@c endfile
+@end ignore
+
+@ignore
+@c file eg/test-programs/gen-float-table.c
+#include <stdio.h>
+#include <math.h>
+#include <stdbool.h>
+
+#define def_func(name, op) \
+ bool name(double left, double right) @{ \
+ return left op right; \
+ @}
+
+def_func(eq, ==)
+def_func(ne, !=)
+def_func(lt, <)
+def_func(le, <=)
+def_func(gt, >)
+def_func(ge, >=)
+
+struct @{
+ const char *name;
+ bool (*func)(double left, double right);
+@} functions[] = @{
+ @{ "==", eq @},
+ @{ "!=", ne @},
+ @{ "< ", lt @},
+ @{ "<=", le @},
+ @{ "> ", gt @},
+ @{ ">=", ge @},
+ @{ 0, 0 @}
+@};
+
+int main()
+@{
+ double values[] = @{
+ -sqrt(-1), // nan
+ sqrt(-1), // -nan
+ -log(0.0), // inf
+ log(0.0) // -inf
+ @};
+ double compare[] = @{ 2.0,
+ -sqrt(-1), // nan
+ sqrt(-1), // -nan
+ -log(0.0), // inf
+ log(0.0) // -inf
+ @};
+
+ int i, j, k;
+
+ for (i = 0; i < 4; i++) @{
+ for (j = 0; j < 5; j++) @{
+ for (k = 0; functions[k].name != NULL; k++) @{
+ printf("%g %s %g -> %s\n", values[i],
+ functions[k].name,
+ compare[j],
+ functions[k].func(values[i], compare[j]) ? "True" : "False");
+ @}
+ printf("\n");
+ @}
+ @}
+
+ return 0;
+@}
+@c endfile
+@end ignore
+
+@ignore
+@c file eg/test-programs/gen-float-table.py
+from math import *
+
+nan = float('NaN')
+inf = float('Inf')
+
+def eq(left, right):
+ return left == right
+
+def ne(left, right):
+ return left != right
+
+def lt(left, right):
+ return left < right
+
+def le(left, right):
+ return left <= right
+
+def gt(left, right):
+ return left > right
+
+def ge(left, right):
+ return left >= right
+
+func_map = {
+ "==": eq,
+ "!=": ne,
+ "< ": lt,
+ "<=": le,
+ "> ": gt,
+ ">=": ge,
+}
+
+compare = [2.0, nan, -nan, inf, -inf]
+values = [nan, -nan, inf, -inf]
+
+for i in range(len(values)):
+ for j in range(len(compare)):
+ for op in func_map:
+ print("%g %s %g -> %s" %
+ (values[i], op, compare[j], func_map[op](values[i], compare[j])))
+
+ print("")
+@c endfile
+@end ignore
+
@node Getting Accuracy
@subsection Getting the Accuracy You Need
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index a8c1cf86..38e9dc0e 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -915,6 +915,7 @@ particular records in a file and perform operations upon them.
* Inexact representation:: Numbers are not exactly represented.
* Comparing FP Values:: How to compare floating point values.
* Errors accumulate:: Errors get bigger as they go.
+* Strange values:: A few words about infinities and NaNs.
* Getting Accuracy:: Getting more accuracy takes some work.
* Try To Round:: Add digits and round.
* Setting precision:: How to set the precision.
@@ -3046,11 +3047,12 @@ column means that the person is a friend.
An @samp{R} means that the person is a relative:
@example
-@c system if test ! -d eg ; then mkdir eg ; fi
-@c system if test ! -d eg/lib ; then mkdir eg/lib ; fi
-@c system if test ! -d eg/data ; then mkdir eg/data ; fi
-@c system if test ! -d eg/prog ; then mkdir eg/prog ; fi
-@c system if test ! -d eg/misc ; then mkdir eg/misc ; fi
+@c system if test ! -d eg ; then mkdir eg ; fi
+@c system if test ! -d eg/lib ; then mkdir eg/lib ; fi
+@c system if test ! -d eg/data ; then mkdir eg/data ; fi
+@c system if test ! -d eg/prog ; then mkdir eg/prog ; fi
+@c system if test ! -d eg/misc ; then mkdir eg/misc ; fi
+@c system if test ! -d eg/test-programs ; then mkdir eg/test-programs ; fi
@c file eg/data/mail-list
Amelia 555-5553 amelia.zodiacusque@@gmail.com F
Anthony 555-3412 anthony.asserturo@@hotmail.com A
@@ -4706,7 +4708,10 @@ blocksize, which is usually the filesystem's I/O blocksize.)
If this variable exists with a value of @samp{gst}, @command{gawk}
switches to using the hash function from GNU Smalltalk for
managing arrays.
-This function may be marginally faster than the standard function.
+With a value of @samp{fnv1a}, @command{gawk} uses the
+@uref{http://www.isthe.com/chongo/tech/comp/fnv/index.html,
+FNV1-A hash function}.
+These functions may be marginally faster than the standard function.
@item AWKREADFUNC
If this variable exists, @command{gawk} switches to reading source
@@ -9664,7 +9669,7 @@ infinity are formatted as
and positive infinity as
@samp{inf} or @samp{infinity}.
The special ``not a number'' value formats as @samp{-nan} or @samp{nan}
-(@pxref{Math Definitions}).
+(@pxref{Strange values}).
@item @code{%F}
Like @samp{%f}, but the infinity and ``not a number'' values are spelled
@@ -17572,7 +17577,7 @@ compatibility mode (@pxref{Options}).
@cindexawkfunc{log}
@cindex logarithm
Return the natural logarithm of @var{x}, if @var{x} is positive;
-otherwise, return @code{NaN} (``not a number'') on IEEE 754 systems.
+otherwise, return NaN (``not a number'') on IEEE 754 systems.
Additionally, @command{gawk} prints a warning message when @code{x}
is negative.
@@ -32659,21 +32664,9 @@ A special value representing infinity. Operations involving another
number and infinity produce infinity.
@item NaN
-``Not a number.''@footnote{Thanks to Michael Brennan for this description,
-which we have paraphrased, and for the examples.} A special value that
-results from attempting a calculation that has no answer as a real number.
-In such a case, programs can either receive a floating-point exception,
-or get @code{NaN} back as the result. The IEEE 754 standard recommends
-that systems return @code{NaN}. Some examples:
-
-@table @code
-@item sqrt(-1)
-This makes sense in the range of complex numbers, but not in the
-range of real numbers, so the result is @code{NaN}.
-
-@item log(-8)
-@minus{}8 is out of the domain of @code{log()}, so the result is @code{NaN}.
-@end table
+``Not a number.'' A special value that results from attempting a
+calculation that has no answer as a real number. @xref{Strange values},
+for more information about infinity and not-a-number values.
@item Normalized
How the significand (see later in this list) is usually stored. The
@@ -32842,6 +32835,7 @@ decimal places in the final result.
* Inexact representation:: Numbers are not exactly represented.
* Comparing FP Values:: How to compare floating point values.
* Errors accumulate:: Errors get bigger as they go.
+* Strange values:: A few words about infinities and NaNs.
@end menu
@node Inexact representation
@@ -32963,6 +32957,242 @@ $ @kbd{gawk 'BEGIN @{}
@print{} 4
@end example
+@node Strange values
+@subsubsection Floating Point Values They Didn't Talk About In School
+
+Both IEEE 754 floating-point hardware, and MPFR, support two kinds of
+values that you probably didn't learn about in school. The first is
+@dfn{infinity}, a special value, that can be either negative or positive,
+and which is either smaller than any other value (negative infinity),
+or larger than any other value (positive infinity). When such values
+are generated, @command{gawk} prints them as either @samp{-inf} or
+@samp{+inf}, respectively. It accepts those strings as data input and
+converts them to the proper floating-point values internally.
+
+Infinity values of the same sign compare as equal to each other.
+Otherwise, operations (addition, subtraction, etc.) involving another
+number and infinity produce mathematically reasonable results.
+
+The second kind of value is ``not a number'', or NaN for
+short.@footnote{Thanks to Michael Brennan for this description, which we
+have paraphrased, and for the examples.} This is a special value that results
+from attempting a calculation that has no answer as a real number.
+In such a case, programs can either receive a floating-point exception,
+or get NaN back as the result. The IEEE 754 standard recommends
+that systems return NaN. Some examples:
+
+@table @code
+@item sqrt(-1)
+@iftex
+The @math{\sqrt{-1}}
+@end iftex
+@ifnottex
+This
+@end ifnottex
+makes sense in the range of complex numbers, but not in the
+range of real numbers, so the result is NaN.
+
+@item log(-8)
+@minus{}8 is out of the domain of @code{log()}, so the result is NaN.
+@end table
+
+NaN values are strange. In particular, they cannot be compared with other
+floating point values; any such comparison, except for ``is not equal
+to'', returns false. NaN values are so much unequal to other values that
+even comparing two identical NaN values with @code{!=} returns true!
+
+NaN values can also be signed, although it depends upon the implementation
+as to which sign you get for any operation that returns a NaN. For
+example, on some systems, @code{sqrt(-1)} returns a negative NaN. On
+others, it returns a positive NaN.
+
+When such values are generated, @command{gawk} prints them as either
+@samp{-nan} or @samp{+nan}, respectively. Here too, @command{gawk}
+accepts those strings as data input and converts them to the proper
+floating-point values internally.
+
+If you want to dive more deeply into this topic, you can find
+test programs in C, @command{awk} and Python in the directory
+@file{awklib/eg/test-programs} in the @command{gawk} distribution.
+These programs enable comparison among programming languages as to how
+they handle NaN and infinity values.
+
+@ignore
+@c file eg/test-programs/gen-float-table.awk
+function eq(left, right)
+@{
+ return left == right
+@}
+
+function ne(left, right)
+@{
+ return left != right
+@}
+
+function lt(left, right)
+@{
+ return left < right
+@}
+
+function le(left, right)
+@{
+ return left <= right
+@}
+
+function gt(left, right)
+@{
+ return left > right
+@}
+
+function ge(left, right)
+@{
+ return left >= right
+@}
+
+BEGIN @{
+ nan = sqrt(-1)
+ inf = -log(0)
+ split("== != < <= > >=", names)
+ names[3] = names[3] " "
+ names[5] = names[5] " "
+ split("eq ne lt le gt ge", funcs)
+
+ compare[1] = 2.0
+ compare[2] = values[1] = -sqrt(-1.0) # nan
+ compare[3] = values[2] = sqrt(-1.0) # -nan
+ compare[4] = values[3] = -log(0.0) # inf
+ compare[5] = values[4] = log(0.0) # -inf
+
+ for (i = 1; i in values; i++) @{
+ for (j = 1; j in compare; j++) @{
+ for (k = 1; k in names; k++) @{
+ the_func = funcs[k]
+ printf("%g %s %g -> %s\n",
+ values[i],
+ names[k],
+ compare[j],
+ @@the_func(values[i], compare[j]) ?
+ "True" : "False");
+ @}
+ printf("\n");
+ @}
+ @}
+@}
+@c endfile
+@end ignore
+
+@ignore
+@c file eg/test-programs/gen-float-table.c
+#include <stdio.h>
+#include <math.h>
+#include <stdbool.h>
+
+#define def_func(name, op) \
+ bool name(double left, double right) @{ \
+ return left op right; \
+ @}
+
+def_func(eq, ==)
+def_func(ne, !=)
+def_func(lt, <)
+def_func(le, <=)
+def_func(gt, >)
+def_func(ge, >=)
+
+struct @{
+ const char *name;
+ bool (*func)(double left, double right);
+@} functions[] = @{
+ @{ "==", eq @},
+ @{ "!=", ne @},
+ @{ "< ", lt @},
+ @{ "<=", le @},
+ @{ "> ", gt @},
+ @{ ">=", ge @},
+ @{ 0, 0 @}
+@};
+
+int main()
+@{
+ double values[] = @{
+ -sqrt(-1), // nan
+ sqrt(-1), // -nan
+ -log(0.0), // inf
+ log(0.0) // -inf
+ @};
+ double compare[] = @{ 2.0,
+ -sqrt(-1), // nan
+ sqrt(-1), // -nan
+ -log(0.0), // inf
+ log(0.0) // -inf
+ @};
+
+ int i, j, k;
+
+ for (i = 0; i < 4; i++) @{
+ for (j = 0; j < 5; j++) @{
+ for (k = 0; functions[k].name != NULL; k++) @{
+ printf("%g %s %g -> %s\n", values[i],
+ functions[k].name,
+ compare[j],
+ functions[k].func(values[i], compare[j]) ? "True" : "False");
+ @}
+ printf("\n");
+ @}
+ @}
+
+ return 0;
+@}
+@c endfile
+@end ignore
+
+@ignore
+@c file eg/test-programs/gen-float-table.py
+from math import *
+
+nan = float('NaN')
+inf = float('Inf')
+
+def eq(left, right):
+ return left == right
+
+def ne(left, right):
+ return left != right
+
+def lt(left, right):
+ return left < right
+
+def le(left, right):
+ return left <= right
+
+def gt(left, right):
+ return left > right
+
+def ge(left, right):
+ return left >= right
+
+func_map = {
+ "==": eq,
+ "!=": ne,
+ "< ": lt,
+ "<=": le,
+ "> ": gt,
+ ">=": ge,
+}
+
+compare = [2.0, nan, -nan, inf, -inf]
+values = [nan, -nan, inf, -inf]
+
+for i in range(len(values)):
+ for j in range(len(compare)):
+ for op in func_map:
+ print("%g %s %g -> %s" %
+ (values[i], op, compare[j], func_map[op](values[i], compare[j])))
+
+ print("")
+@c endfile
+@end ignore
+
@node Getting Accuracy
@subsection Getting the Accuracy You Need
diff --git a/doc/it/ChangeLog b/doc/it/ChangeLog
index 863eef47..142c8108 100644
--- a/doc/it/ChangeLog
+++ b/doc/it/ChangeLog
@@ -1,3 +1,28 @@
+2021-03-21 Antonio Giovanni Colombo <azc100@gmail.com>
+
+ * gawktexi.in: Updated.
+
+2021-03-20 Antonio Giovanni Colombo <azc100@gmail.com>
+
+ * texinfo.tex: Updated.
+
+2021-02-01 Antonio Giovanni Colombo <azc100@gmail.com>
+
+ * gawktexi.in: Updated.
+
+2021-01-25 Antonio Giovanni Colombo <azc100@gmail.com>
+
+ * gawktexi.in: Updated.
+ * texinfo.tex: Updated.
+
+2021-01-22 Antonio Giovanni Colombo <azc100@gmail.com>
+
+ * gawktexi.in: Updated.
+
+2020-11-20 Antonio Giovanni Colombo <azc100@gmail.com>
+
+ * gawktexi.in: Updated.
+
2020-11-01 Antonio Giovanni Colombo <azc100@gmail.com>
* texinfo.tex: Updated.
diff --git a/doc/it/gawktexi.in b/doc/it/gawktexi.in
index fe7c6b29..f047aa46 100644..100755
--- a/doc/it/gawktexi.in
+++ b/doc/it/gawktexi.in
@@ -56,7 +56,7 @@
@c applies to and all the info about who's publishing this edition
@c These apply across the board.
-@set UPDATE-MONTH Settembre 2020
+@set UPDATE-MONTH Gennaio 2021
@set VERSION 5.1
@set PATCHLEVEL 0
@@ -76,6 +76,7 @@
@iftex
@set DOCUMENT libro
@set CHAPTER capitolo
+@set CHAPTERS capitoli
@set APPENDIX appendice
@set SECTION sezione
@set SECTIONS sezioni
@@ -93,6 +94,7 @@
@ifinfo
@set DOCUMENT File Info
@set CHAPTER nodo principale
+@set CHAPTERS nodi principali
@set APPENDIX nodo principale
@set SECTION nodo secondario
@set SECTIONS nodi secondari
@@ -105,6 +107,7 @@
@ifhtml
@set DOCUMENT Documento
@set CHAPTER capitolo
+@set CHAPTERS capitoli
@set APPENDIX appendice
@set SECTION sezione
@set SECTIONS sezioni
@@ -117,6 +120,7 @@
@ifdocbook
@set DOCUMENT libro
@set CHAPTER capitolo
+@set CHAPTERS capitoli
@set APPENDIX appendice
@set SECTION sezione
@set SECTIONS sezioni
@@ -129,6 +133,7 @@
@ifxml
@set DOCUMENT libro
@set CHAPTER capitolo
+@set CHAPTERS capitoli
@set APPENDIX appendice
@set SECTION sezione
@set SECTIONS sezioni
@@ -141,6 +146,7 @@
@ifplaintext
@set DOCUMENT libro
@set CHAPTER capitolo
+@set CHAPTERS capitoli
@set APPENDIX appendice
@set SECTION sezione
@set SECTIONS sezioni
@@ -309,7 +315,7 @@ Some comments on the layout for TeX.
Tel.: +1-617-542-5942 Fax: +1-617-542-2652 Email: <email>gnu@@gnu.org</email>
URL: <ulink url="https://www.gnu.org">https://www.gnu.org/</ulink></literallayout>
-<literallayout class="normal">Copyright &copy; 1989, 1991, 1992, 1993, 1996&ndash;2005, 2007, 2009&ndash;2020
+<literallayout class="normal">Copyright &copy; 1989, 1991, 1992, 1993, 1996&ndash;2005, 2007, 2009&ndash;2021
Free Software Foundation, Inc.
All Rights Reserved.
</literallayout>
@@ -331,7 +337,7 @@ Italian Linux Documentation Project (ILDP)
Email: <emailildp@@pluto.it
URL: <ulink url="http://www.pluto.it/ildp">http://www.pluto.it/ildp/</ulink></literallayout>
-<literallayout class="normal">Copyright &copy; 2016&ndash;2020
+<literallayout class="normal">Copyright &copy; 2016&ndash;2021
Free Software Foundation, Inc.
All Rights Reserved.
</literallayout>
@@ -339,7 +345,7 @@ All Rights Reserved.
@ifnotdocbook
@iftex
-Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2020 @*
+Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2021 @*
Free Software Foundation, Inc.
@end iftex
@end ifnotdocbook
@@ -687,7 +693,7 @@ Copyright dell'edizione italiana @copyright{} 2016 -- Free Software Foundation,
* Separazione in base al contenuto:: Definire campi dal loro contenuto.
* File CSV:: Ancora sui file CSV.
* Controllare la creazione di campi:: Controllare come @command{gawk} sta
- dividendo i record.
+ suddividendo i record.
* Righe multiple:: Record su righe multiple
* Getline:: Richiedere input usando @code{getline}.
* Getline semplice:: Usare @code{getline} senza argomenti.
@@ -1005,6 +1011,7 @@ Copyright dell'edizione italiana @copyright{} 2016 -- Free Software Foundation,
programmazione di rete.
* Profilare:: Profilare i propri programmi
@command{awk}.
+* Filosofia delle estensioni:: Cosa dovrebbe essere incluso e cosa no.
* Sommario funzionalit@`a avanzate:: Sommario funzionalit@`a avanzate.
* I18N e L10N:: Internazionalizzazione e localiz.
* Utilizzare @command{gettext}:: Come funziona GNU @code{gettext}.
@@ -1065,13 +1072,14 @@ Copyright dell'edizione italiana @copyright{} 2016 -- Free Software Foundation,
esattamente.
* Confronti tra valori in VM:: Come confrontare valori in virgola mobile.
* Gli errori si sommano:: Gli errori diventano sempre maggiori.
+* Valori strani:: Un cenno riguardo ai valori infiniti e a NaN [``non @`e un numero''].
* Ottenere la precisione:: Ottenere la precisione voluta.
* Tentare di arrotondare:: Tentare di aggiungere bit di precisione e
arrotondare.
* Impostare la precisione:: Impostare la precisione.
* Impostare modo di arrotondare:: Impostare la modalit@`a di
arrotondamento.
-* Controllare disponibilit@`a MPFR:: Come controllare se MPFR @`e disponibile.
+* Controllare disponibilit@`a MPFR:: Come controllare se MPFR @`e disponibile.
* Interi a precisione arbitraria:: Aritmetica dei numeri interi a precisione
arbitraria con @command{gawk}.
* Problemi virgola mobile POSIX:: Confronto tra standard e uso corrente.
@@ -3259,7 +3267,7 @@ Le ``shell'' nei sistemi Microsoft Windows usano il carattere doppio apice
per protezione, e rendono difficile o impossibile inserire un carattere
doppio apice letterale in uno @dfn{script} scritto su una riga di comando.
L'esempio che segue, per il quale ringraziamo Jeroen Brink, mostra come
-proteggere i doppi apici, con questo script di una sola riga, che stampa
+proteggere i doppi apici, con questo @dfn{script} di una sola riga, che stampa
tutte le righe di un file, racchiudendole tra doppi apici:
@example
@@ -3338,11 +3346,12 @@ persona @`e un amico [Friend]. Una @samp{R} vuol dire che quella persona @`e
un parente [Relative]:
@example
-@c system if test ! -d eg ; then mkdir eg ; fi
-@c system if test ! -d eg/lib ; then mkdir eg/lib ; fi
-@c system if test ! -d eg/data ; then mkdir eg/data ; fi
-@c system if test ! -d eg/prog ; then mkdir eg/prog ; fi
-@c system if test ! -d eg/misc ; then mkdir eg/misc ; fi
+@c system if test ! -d eg ; then mkdir eg ; fi
+@c system if test ! -d eg/lib ; then mkdir eg/lib ; fi
+@c system if test ! -d eg/data ; then mkdir eg/data ; fi
+@c system if test ! -d eg/prog ; then mkdir eg/prog ; fi
+@c system if test ! -d eg/misc ; then mkdir eg/misc ; fi
+@c system if test ! -d eg/test-programs ; then mkdir eg/test-programs ; fi
@c file eg/data/mail-list
Amelia 555-5553 amelia.zodiacusque@@gmail.com F
Anthony 555-3412 anthony.asserturo@@hotmail.com A
@@ -4534,7 +4543,7 @@ Forza l'uso del carattere di separazione decimale della localizzazione
quando analizza i dati in input
(@pxref{Localizzazioni}).
-@cindex stampa elegante
+@cindex stampa-elegante
@item @option{-o}[@var{file}]
@itemx @option{--pretty-print}[@code{=}@var{file}]
@cindex @option{-o} (opzione)
@@ -5018,7 +5027,7 @@ variabile non esiste, o se ha un come valore la stringa nulla,
@command{gawk} usa un percorso di default (descritto tra poco).
La funzionalit@`a del percorso di ricerca @`e particolarmente utile per costruire
-librerie di funzioni di @command{awk}. I file di libreria possono essere messi
+librerie di funzioni di @command{awk}. Le librerie di file possono essere messe
in una directory standard inclusa nel percorso di ricerca
e richiamati sulla riga di comando con un
@value{FN} breve. Altrimenti, si dovrebbe scrivere l'intero @value{FN} per
@@ -5026,7 +5035,7 @@ ciascun file.
Usando l'opzione @option{-i}, o l'opzione @option{-f}, i programmi di
@command{awk} scritti sulla riga di comando possono usare le funzionalit@`a
-contenute nei file di libreria di @command{awk}
+contenute nelle librerie di file di @command{awk}
@iftex
(@pxrefil{Funzioni di libreria}).
@end iftex
@@ -5192,7 +5201,11 @@ del filesystem).
@item AWK_HASH
Se questa variabile @`e impostata con un valore di @samp{gst}, @command{gawk}
usa la funzione hash di GNU Smalltalk per gestire i vettori.
-Questa funzione pu@`o essere leggermente pi@`u veloce della funzione standard.
+Se invece ha per valore @samp{fnv1a}, @command{gawk} usa la funzione hash
+@uref{http://www.isthe.com/chongo/tech/comp/fnv/index.html,
+FNV1-A}.
+Queste funzioni possono essere leggermente pi@`u veloci della funzione standard.
+
@item AWKREADFUNC
Se questa variabile esiste, @command{gawk} legge i file sorgenti una riga per
volta, anzich@'e a blocchi. Questa variabile @`e presente
@@ -5386,7 +5399,7 @@ possono includere queste ``librerie'' usando il percorso completo dei
file, o impostando opportunamente la variabile d'ambiente @env{AWKPATH} e
quindi usando @code{@@include} con la sola parte del percorso completo che
designa il file. Naturalmente,
-si possono tenere i file di libreria in pi@`u di una directory;
+si possono tenere le librerie di file in pi@`u di una directory;
pi@`u @`e complesso l'ambiente di lavoro, pi@`u
directory possono essere necessarie per organizzare i file da includere.
@@ -6384,7 +6397,7 @@ che occupano un unico byte (caratteri il cui valore stia
nell'intervallo 0--256). Per individuare un intervallo di
caratteri in cui i punti di inizio e fine dell'intervello
abbiano valori maggiori di 256, occorre immettere direttamente
-le codifiche multi-byte dei caratteri in questione.
+le codifiche multibyte dei caratteri in questione.
@cindex @code{\} (barra inversa) @subentry in espressioni tra parentesi quadre
@cindex barra inversa (@code{\}) @subentry in espressioni tra parentesi quadre
@@ -6523,7 +6536,7 @@ sono equivalenti). Queste sequenze sono:
@cindex espressioni @subentry tra parentesi quadre @subentry elementi di collazione
@cindex elementi @subentry di collazione
@item elementi di collazione
-Elementi di collazione multi-byte racchiusi fra
+Elementi di collazione multibyte racchiusi fra
@samp{[.} e @samp{.]}. Per esempio, se @samp{ch} @`e un elemento di collazione,
@samp{[[.ch.]]} @`e una @dfn{regexp} che individua questo elemento di
collazione, mentre @samp{[ch]} @`e una @dfn{regexp} che individua le lettere
@@ -7096,7 +7109,7 @@ getline (@pxref{Getline}).
* Dimensione costante:: Leggere campi di larghezza costante.
* Separazione in base al contenuto:: Definire campi dal loro contenuto.
* Controllare la creazione di campi:: Controllare come @command{gawk} sta
- dividendo i record.
+ suddividendo i record.
* Righe multiple:: Leggere record che sono su pi@`u righe.
* Getline:: Leggere file sotto il controllo del
programma, usando la funzione
@@ -7274,23 +7287,6 @@ in questione non viene trattato come tale, ma viene usato letteralmente.
Ci@`o viene fatto per compatibilit@`a all'indietro sia con il comando
Unix @command{awk} che con lo standard POSIX.
-Quando si usano caratteri normali come separatore di record,
-c'@`e un caso insolito che capita quando @command{gawk}
-@`e reso completamente conforme a POSIX (@pxref{Opzioni}).
-In quel caso, la seguente (estrema) @dfn{pipeline} stampa un sorprendente
-@samp{1}:
-
-@example
-$ echo | gawk --posix 'BEGIN @{ RS = "a" @} ; @{ print NF @}'
-@print{} 1
-@end example
-
-C'@`e un solo campo, consistente in un ritorno a capo. Il valore della
-variabile predefinita @code{NF} @`e il numero di campi nel record corrente.
-(Normalmente @command{gawk} tratta il ritorno a capo come uno spazio
-vuoto, stampando @samp{0} come risultato. Anche molte altre versioni di
-@command{awk} agiscono in questo modo.)
-
@cindex angolo buio @subentry file in input
Il raggiungimento della fine di un file in input fa terminare il record di
input corrente, anche se l'ultimo carattere nel file non @`e il carattere in
@@ -7387,7 +7383,7 @@ particolare se il testo di input che potrebbe avere una corrispondenza con la
parte finale @`e piuttosto lungo. @command{gawk} cerca di evitare questo
problema, ma al momento non ci sono garanzie che questo funzioni sempre.
-@quotation NOTA
+@sidebar Avvertenze per quando si usano espressioni regolari come @code{RS}
Si ricordi che in @command{awk}, i metacaratteri di ancoraggio @samp{^} e
@samp{$} trovano l'inizio e la fine di una @emph{stringa}, e non l'inizio e la
fine di una @emph{riga}. Come risultato, qualcosa come
@@ -7395,7 +7391,15 @@ fine di una @emph{riga}. Come risultato, qualcosa come
Questo perch@'e @command{gawk} vede il file in input come un'unica lunga stringa
in cui possono essere presenti dei caratteri di ritorno a capo.
@`E meglio perci@`o evitare metacaratteri di ancoraggio nel valore di @code{RS}.
-@end quotation
+
+La suddivisione in campi usando espressioni regolari funziona in maniera
+differente di quando la si usa con le funzioni @code{sub()}, @code{gsub()}, e
+@code{gensub()} (@pxref{Funzioni per stringhe}). Tali funzioni consentono
+che un'espressione regolare sia soddisfatta da una stringa nulla;
+La suddivisione in campi non lo consente. Quindi, per esempio,
+@samp{RS = "()"} @emph{non} divide un record in campi di un carattere
+ciascuno.
+@end sidebar
@cindex @command{gawk} @subentry variabile @subentry @code{RT} in
@cindex @code{RT} (variabile)
@@ -8034,6 +8038,15 @@ $ @kbd{echo 'xxAA xxBxx C' |}
@print{} -->C<--
@end example
+Inoltre,
+la suddivisione in campi usando espressioni regolari funziona in maniera
+differente di quando la si usa con le funzioni @code{sub()}, @code{gsub()}, e
+@code{gensub()} (@pxref{Funzioni per stringhe}). Tali funzioni consentono
+che un'espressione regolare sia soddisfatta da una stringa nulla;
+La suddivisione in campi non lo consente. Quindi, per esempio,
+@samp{RS = "()"} @emph{non} divide un record in campi di un carattere
+ciascuno.
+
@node Campi di un solo carattere
@subsection Fare di ogni carattere un campo separato
@@ -8592,6 +8605,10 @@ parole, @code{FS} definisce cosa un campo @emph{non @`e}, invece di cosa
Tuttavia, ci sono casi in cui effettivamente si ha bisogno di definire i campi
in base a cosa essi sono, e non in base a cosa non sono.
+@cindex dati CSV (valori separati da virgole) @subentry analizzare con @code{FPAT}
+@cindex CSV (valori separati da virgole) come dati @subentry analizzare con @code{FPAT}
+@cindex Comma Separated Values (CSV) come dati @subentry analizzare con @code{FPAT}
+@cindex valori separati da virgole (CSV) come dati @subentry analizzare con @code{FPAT}
Il caso pi@`u emblematico @`e quello dei dati cosiddetti @dfn{comma-separated
value} (CSV). Molti fogli elettronici, per esempio, possono esportare i dati
in file di testo, dove ogni record termina con un ritorno a capo e i campi
@@ -8710,7 +8727,7 @@ FPAT = "([^,]*)|(\"[^\"]+\")"
@c Per email from Ed Morton <mortoneccc@comcast.net>
@c
@c WONTFIX: 10/2020
-@c This is too much work. FPAT and CSV files are very flakey and
+@c This is too much work. FPAT and CSV files are very flaky and
@c fragile. Doing something like this is merely inviting trouble.
Come per @code{FS}, la variabile @code{IGNORECASE}
@@ -8789,8 +8806,20 @@ $ @kbd{gawk -v fpat=2 -f test-csv.awk sample.csv}
@print{} NF = 3 <p><><s>
@end example
+@cindex Collado, Manuel
+@cindex @code{CSVMODE}, libreria per @command{gawk}
+@cindex libreria @code{CSVMODE} per @command{gawk}
+@cindex dati CSV (valori separati da virgole) @subentry analizzare con libreria @code{CSVMODE}
+@cindex CSV (valori separati da virgole) come dati @subentry analizzare con libreria @code{CSVMODE}
+@cindex valori separati da virgole (CSV) come dati @subentry analizzare con libreria @code{CSVMODE}
+In generale, usare @code{FPAT} per effettuare l'analisi di dati in formato CSV
+@`e come utilizzare un lenzuolo troppo corto. Rimane sempre un angolo che non
+@`e coperto. Si raccomanda, in alternativa, di usare la libreria @code{CSVMODE}
+messa a disposizione da Manuel Collado. Vedere:
+@uref{http://mcollado.z15.es/xgawk/, @code{CSVMODE} libreria per @command{gawk}}.
+
@node Controllare la creazione di campi
-@section Controllare come @command{gawk} sta dividendo i record
+@section Controllare come @command{gawk} sta suddividendo i record
@cindex @command{gawk} @subentry separazione in campi e
Come visto sopra, @command{gawk} fornisce tre metodi indipendenti per
@@ -10473,9 +10502,9 @@ dallo standard IEEE 754, il valore infinito negativo @`e rappresentato come
@samp{-inf} o @samp{-infinity},
e l'infinito positivo come
@samp{inf} o @samp{infinity}.
-Il valore speciale ``not a number'' [non @`e un numero] viene scritto come
+Il valore speciale ``not a number'' ["non @`e un numero"] viene scritto come
@samp{-nan} o @samp{nan}
-(@pxref{Definizioni matematiche}).
+(@pxref{Valori strani}).
@item @code{%F}
Come @samp{%f}, ma i valori di infinito e di ``not a number'' sono scritti
@@ -13160,16 +13189,18 @@ Per avere la massima portabilit@`a, non usare l'operatore @samp{**=}.
@sidebar Ambiguit@`a sintattiche tra @samp{/=} e le espressioni regolari
@cindex angolo buio @subentry costanti @dfn{regexp} @subentry operatore @code{/=} e
-@cindex @code{/} (barra) @subentry operatore @code{/=} @subentry vs. costante @dfn{regexp} @code{/=@dots{}/}
-@cindex barra (@code{/}) @subentry operatore @code{/=} @subentry vs. costante @dfn{regexp} @code{/=@dots{}/}
+@cindex @code{/} (barra) @subentry operatore @code{/=} @subentry vs.@: costante @dfn{regexp} @code{/=@dots{}/}
+@cindex barra (@code{/}) @subentry operatore @code{/=} @subentry vs.@: costante @dfn{regexp} @code{/=@dots{}/}
@cindex @dfn{regexp} @subentry costanti @subentry @code{/=@dots{}/}, operatore @code{/=} e
@c derived from email from "Nelson H. F. Beebe" <beebe@math.utah.edu>
@c Date: Mon, 1 Sep 1997 13:38:35 -0600 (MDT)
-@cindex angolo buio @subentry operatore @code{/=} vs. costante @dfn{regexp} @code{/=@dots{}/}
-@cindex ambiguit@`a sintattica: operatore @code{/=} vs. costante @dfn{regexp} @code{/=@dots{}/}
-@cindex sintattica @subentry ambiguit@`a: operatore @code{/=} vs. costante @dfn{regexp} @code{/=@dots{}/}
+@cindex angolo buio @subentry operatore @code{/=} vs.@: costante @dfn{regexp} @code{/=@dots{}/}
+@cindex ambiguit@`a sintattica: operatore @code{/=} vs.@: costante @dfn{regexp} @code{/=@dots{}/}
+@cindex sintattica @subentry ambiguit@`a: operatore @code{/=} vs.@: costante @dfn{regexp} @code{/=@dots{}/}
+@cindex @code{/=} (uguale) @subentry operatore vs.@: @code{/=@dots{}/} costante @dfn{regexp}
+@cindex uguale (@code{/=}) @subentry operatore vs.@: @code{/=@dots{}/} costante @dfn{regexp}
C'@`e un'ambiguit@`a sintattica tra l'operatore di assegnamento @code{/=}
e le costanti @dfn{regexp} il cui primo carattere sia @samp{=}.
@value{DARKCORNER}
@@ -14996,12 +15027,13 @@ Ci@`o non @`e pi@`u obbligatorio, ma @`e una buona idea continuare a seguire que
modello per migliorare l'organizzazione e la leggibilit@`a del programma.
Regole multiple @code{BEGIN} ed @code{END} sono utili per scrivere funzioni
-di libreria, poich@'e ogni file di libreria pu@`o avere la sua propria regola
-@code{BEGIN} e/o @code{END} per fare la propria inizializzazione e/o pulizia.
+di libreria, poich@'e ogni file di una libreria pu@`o avere la sua propria
+regola @code{BEGIN} e/o @code{END} per fare la propria inizializzazione e/o
+pulizia.
L'ordine in cui le funzioni di libreria sono menzionate nella riga dei comandi
determina l'ordine in cui le rispettive regole @code{BEGIN} ed @code{END} sono
eseguite. Per questo motivi, occorre prestare attenzione nello scrivere tali
-regole nei file di libreria, in modo che non sia importante
+regole nelle librerie di file, in modo che non sia importante
l'ordine in cui tali regole vengono eseguite.
@xref{Opzioni} per maggiori informazioni sull'uso di funzioni di libreria.
@iftex
@@ -16060,16 +16092,17 @@ risultato.
In @command{gawk}, l'esecuzione di @code{nextfile} produce ulteriori effetti:
le eventuali regole @code{ENDFILE}
sono eseguite se @command{gawk} non
-si trova correntemente all'interno di una regola @code{END} o
-@code{BEGINFILE}; @code{ARGIND} @`e
+si trova correntemente all'interno di una regola @code{END},
+@code{ARGIND} @`e
incrementato e le eventuali regole @code{BEGINFILE} sono eseguite.
(@code{ARGIND} non @`e stato ancora trattato.
@xref{Variabili predefinite}.)
-In @command{gawk}, @code{nextfile} @`e utile all'interno di una regola
+C'@`e un ulteriore caso speciale di utilizzo in @command{gawk}.
+@code{nextfile} @`e utile all'interno di una regola
@code{BEGINFILE} per evitare di elaborare un file che altrimenti causerebbe
un errore fatale in @command{gawk}.
-In questo caso, le regole @code{ENDFILE} non vengono eseguite.
+In questo caso speciale, le regole @code{ENDFILE} non vengono eseguite.
@xref{BEGINFILE/ENDFILE}.
Sebbene possa sembrare che @samp{close(FILENAME)} ottenga lo stesso
@@ -19051,8 +19084,8 @@ modalit@`a compatibile (@pxref{Opzioni}).
@cindexawkfunc{log}
@cindex logaritmo
Restituisce il logaritmo naturale di @var{x}, se @var{x} @`e positivo;
-altrimenti, restituisce @code{NaN} (``not a number'') sui sistemi che
-implementano lo standard IEEE 754.
+altrimenti, restituisce NaN (``not a number'',[``non @`e un numero''])
+sui sistemi che implementano lo standard IEEE 754.
Inoltre, @command{gawk} stampa un messaggio di avvertimento qualora @code{x}
sia negativo.
@@ -26199,13 +26232,13 @@ possono essere separati da virgole, e intervalli di caratteri possono essere
separated da trattini. La lista
@samp{1-8,15,22-35} specifica i caratteri da 1 a 8, 15, e da 22 a 35.
-@item -f @var{lista}
-Usare @var{lista} come lista di campi da ritagliare.
-
@item -d @var{delimitatore}
Usare @var{delimitatore} come carattere che separa i campi invece del
carattere TAB.
+@item -f @var{lista}
+Usare @var{lista} come lista di campi da ritagliare.
+
@item -s
Evita la stampa di righe che non contengono il delimitatore di campo.
@end table
@@ -26216,6 +26249,12 @@ di libreria @code{getopt()}
e la funzione di libreria @code{join()}
(@pxref{Funzione join}).
+La versione POSIX corrente del comando @command{cut} prevede opzioni
+per ritagliare dei campi che possono essere sia byte che caratteri
+[possibilmente multibyte]. Questa versione non tenta di implementare
+tali opzioni, poich@'e @command{awk} lavora esclusivamente in termini
+di caratteri.
+
Il programma inizia con un commento che descrive le opzioni, le funzioni
di libreria necessarie, e una funzione @code{sintassi()} che stampa un
messaggio ed esce. @code{sintassi()} @`e chiamato se si specificano degli
@@ -26237,9 +26276,9 @@ argomenti non validi:
@c file eg/prog/cut.awk
# Opzioni:
+# -c lista Ritagliare caratteri
# -f lista Ritagliare campi
# -d c Carattere di delimitazione di campo
-# -c lista Ritagliare caratteri
#
# -s Sopprimere righe che non contengono il delimitatore
#
@@ -26315,7 +26354,7 @@ un semplice spazio (@code{@w{" "}}) come valore per @code{FS} @`e
sbagliato: @command{awk} separerebbe i campi con serie di spazi,
TAB, e/o ritorni a capo, mentre devono essere separati solo da uno spazio.
Per far questo, salviamo il carattere di spazio originale nella variabile
-@code{fs} per un uso futuro; dopo aver impostato @code{FS} a @code{"[ ]"} non
+@code{fs} per un uso futuro; dopo aver impostato @code{FS} a @code{@w"[ ]"} non
@`e possibile usarlo direttamente per vedere se il carattere delimitatore di
campo @`e nella stringa.
@@ -26633,14 +26672,17 @@ BEGIN @{
@noindent
Si noti il commento relativo alla chiamata del programma:
-Poich@'e parecchie opzioni possono essere sepcificate anche per
+Poich@'e parecchie opzioni possono essere specificate anche per
@command{gawk}, occorre immettere @option{--} per far s@`@{dotless{i}} che
@command{gawk} non prosegua nell'analisi delle opzioni.
Nel seguito c'@`e il codice che gestisce il comportamento specifico di
-@command{egrep}. Se non @`e fornito esplicitamente alcun criterio di ricerca
-tramite l'opzione @option{-e}, si usa il primo argomento sulla riga di
-comando che non sia un'opzione.
+@command{egrep}. @command{egrep} utilizza il primo argomento sulla
+riga di comando che non sia un'opzione se non @`e fornito esplicitamente
+alcun criterio di ricerca tramite l'opzione @option{-e}.
+Se il criterio di ricerca @`e la stringa nulla, ci@`o significa che non
+@`e stato fornito alcun criterio, quindi @`e necessario stampare un
+messaggio di errore e terminare il programma.
Gli argomenti della riga di comando di @command{awk} fino ad
@code{ARGV[Optind]} vengono cancellati,
in modo che @command{awk} non tenti di elaborarli come file. Se
@@ -26734,9 +26776,9 @@ verificando i valori delle variabili @code{RSTART} e @code{RLENGTH}.
Se questi indicano che la corrispondenza non coincide con l'intera
riga, la variabile @code{corrisponde} @`e impostata a zero (falsa).
-Se l'utente chiede invece le righe che @emph{non} corrispondono,
-il senso di @code{corrisponde} @`e invertito, usando l'operatore @samp{!}.
-@code{contatore_file} @`e incrementato con il valore di
+Se l'utente chiede invece le righe che non corrispondono, si inverte
+il senso di @code{corrisponde}, usando l'operatore @samp{!}.
+Poi, @code{contatore_file} @`e incrementato con il valore di
@code{corrisponde}, che vale uno o zero, a seconda che la corrispondenza sia
stata trovata oppure no. Se la riga non corrisponde, l'istruzione
@code{next} passa ad esaminare il record successivo.
@@ -27285,7 +27327,9 @@ Ecco un'implementazione di @command{split} in @command{awk}. Viene utilizzata
la funzione @code{getopt()} presentata in @ref{Funzione getopt}.
Il programma inizia con un commento descrittivo e poi con la
-funzione @code{sintassi()} che ne descrive le opzioni:
+funzione @code{sintassi()} che ne descrive le opzioni. La variabile
+@code{comune} permettere di avere delle righe brevi nella funzione,
+in modo che sia stampata in maniera elegante nella pagina:
@cindex @code{split.awk} (programma)
@cindex programma @subentry @code{split.awk}
@@ -27306,10 +27350,11 @@ funzione @code{sintassi()} che ne descrive le opzioni:
@c endfile
@end ignore
@c file eg/prog/split.awk
-function sintassi()
+function sintassi( comune)
@{
- print("Uso: split [-l contatore] [-a lunghezza-suffisso] [file [nome-output-file]]") > "/dev/stderr"
- print(" split [-b N[k|m]] [-a lunghezza-suffisso] [file [nome-output-file]]") > "/dev/stderr"
+ common = "[-a lunghezza-suffisso] [file [nome-output-file]]"
+ printf("Uso: split [-l contatore] %s\n", comune) > "/dev/stderr"
+ printf(" split [-b N[k|m]] %s\n", comune) > "/dev/stderr"
exit 1
@}
@c endfile
@@ -27801,7 +27846,8 @@ spiegazione delle opzioni e del loro significato, sotto forma di commenti:
function sintassi()
@{
- print("Uso: uniq [-udc [-f campi]] [-s caratteri] [ in [ out ]]") > "/dev/stderr"
+ print("Uso: uniq [-udc [-f campi] [-s caratteri]] " \
+ "[ in [ out ]]") > "/dev/stderr"
exit 1
@}
@@ -28063,7 +28109,7 @@ Klingon e il linguaggio degli elfi di J.R.R.@: Tolkien).
Per risparmiare spazio nei file, i @dfn{code points} Unicode sono
@dfn{codificati}, e la rappresentazione di ogni carattere pu@`o richiedere
da uno a quattro byte nel file. UTF-8 @`e verosimilmente la pi@`u diffusa
-fra queste codifiche multi-byte (@dfn{multibyte encodings}).
+fra queste codifiche multibyte (@dfn{multibyte encodings}).
Lo standard POSIX richiede che @command{awk} gestisca dei caratteri,
non dei byte. Per questo motivo, in @command{gawk}, le funzioni
@@ -28091,7 +28137,7 @@ Per quanto riguarda
@file{wc.awk}, @`e sufficiente sapere che l'estensione viene caricata
con la direttiva @code{@@load}, e la funzione ulteriore che dovr@`a essere
usata si chiama @code{mbs_length()}. Questa funzione restiuisce il numero
-di byte in una stringa, e non il numero di caratteri.
+di byte in una stringa, non il numero di caratteri.
L'estensione @code{"mbs"} fa parte del progetto @code{gawkextlib}.
@xref{gawkextlib} for ulteriori informazioni.
@@ -28110,23 +28156,23 @@ standard input. Se ci sono pi@`u file, stampa anche il contatore totale di
tutti i file. Le opzioni e il loro significato sono i seguenti:
@table @code
-@item -l
-Conta solo le righe.
-
-@item -w
-Conta solo le parole.
-Una ``parola'' @`e una sequenza contigua di caratteri non bianchi, separata da
-spazi e/o TAB. Fortunatamente, questo @`e il modo normale in cui @command{awk}
-separa i campi nei suoi record in input.
-
@item -c
Conta solo i byte.
Un tempo, la lettera @samp{c} di questa opzione stava per ``caratteri.''
Ma, come spiegato pi@`u sopra, byte e carattere non sono pi@`u sinonimi
tra loro.
+@item -l
+Conta solo le righe.
+
@item -m
Conta solo caratteri.
+
+@item -w
+Conta solo le parole.
+Una ``parola'' @`e una sequenza contigua di caratteri non bianchi, separata da
+spazi e/o TAB. Fortunatamente, questo @`e il modo normale in cui @command{awk}
+separa i campi nei suoi record in input.
@end table
L'implementazione di @command{wc} in @command{awk} @`e particolarmente
@@ -30618,6 +30664,7 @@ tratta della capacit@`a di aggiungere dinamicamente nuove funzioni predefinite a
processo.
* Reti TCP/IP:: Usare @command{gawk} per programmazione di rete.
* Profilare:: Profilare i propri programmi @command{awk}.
+* Filosofia delle estensioni:: Cosa dovrebbe essere incluso e cosa no.
* Sommario funzionalit@`a avanzate:: Sommario delle funzionalit@`a avanzate.
@end menu
@@ -31828,7 +31875,7 @@ alfabetico.
La versione profilata del proprio programma potrebbe non apparire esattamente
come quella scritta durante la stesura del programma. Questo perch@'e
-@command{gawk} crea la versione profilata facendo una ``stampa elegante'' della
+@command{gawk} crea la versione profilata facendo una ``stampa-elegante'' della
sua rappresentazione interna del programma. Un vantaggio di ci@`o @`e che
@command{gawk} pu@`o produrre una rappresentazione standard.
Inoltre, cose come:
@@ -31923,9 +31970,9 @@ tastiera. Il segnale @code{INT} @`e generato dalle combinazioni di tasti
@kbd{Ctrl-c} o @kbd{Ctrl-BREAK}, mentre il segnale
@code{QUIT} @`e generato dalla combinazione di tasti @kbd{Ctrl-\}.
-@cindex stampa elegante
+@cindex stampa-elegante
Infine, @command{gawk} accetta anche un'altra opzione, @option{--pretty-print}.
-Quando viene chiamato in questo modo, @command{gawk} fa una ``stampa elegante''
+Quando viene chiamato in questo modo, @command{gawk} fa una ``stampa-elegante''
del programma nel file @file{awkprof.out}, senza conteggi sull'esecuzione.
@quotation NOTA
@@ -31933,10 +31980,10 @@ Una volta, l'opzione @option{--pretty-print} eseguiva anche il programma.
Ora non pi@`u.
@end quotation
-@cindex profilazione @subentry differenza rispetto alla stampa elegante
-@cindex stampa elegante @subentry differenza rispetto alla profilazione
+@cindex profilazione @subentry differenza rispetto alla ``stampa-elegante''
+@cindex stampa-elegante @subentry differenza rispetto alla profilazione
C'@`e una differenza significativa tra l'output creato durante la profilazione,
-e quello creato durante la stampa elegante. L'output della stampa elegante
+e quello creato durante la ``stampa-elegante''. L'output della ``stampa-elegante''
preserva i commenti originali che erano nel programma, anche se la loro
posizione pu@`o non corrispondere esattamente alle posizioni originali che
avevano nel codice sorgente. Tuttavia, nessun commento dovrebbe andare
@@ -31948,23 +31995,83 @@ in maniera perfetta.
Comunque, per una precisa scelta progettuale, l'output della profilazione
@emph{omette} i commenti del programma originale. Questo permette di
concentrarsi sui dati del conteggio di esecuzione ed evita la tentazione di
-usare il profilatore per creare una stampa elegante.
+usare il profilatore per creare una ``stampa-elegante''.
Oltre a ci@`o, l'output stampato in modo elegante non ha l'indentazione iniziale
-che ha l'output della profilazione. Questo rende agevole la stampa elegante
+che ha l'output della profilazione. Questo rende agevole la ``stampa-elegante''
del proprio codice una volta completato lo sviluppo, usando poi il risultato
come versione finale del programma.
Poich@'e la rappresentazione interna del programma @`e formattata per
essere aderente al programma @command{awk} in questione, la profilazione
-e la stampa elegante (opzione @option{--pretty-print}) disabilitano
+e la ``stampa-elegante'' (opzione @option{--pretty-print}) disabilitano
automaticamente le optimizzazioni di default di @command{gawk}.
-La profilazione e la stampa elegante mantengono anche il formato originale
+La profilazione e la ``stampa-elegante'' mantengono anche il formato originale
delle costanti numeriche; se sono stati usati dei valori ottali o esadecimali
nel codice sorgente, questi compariranno nell'output nello stesso
formato con cui sono stati inseriti.
+@node Filosofia delle estensioni
+@section Funzionalit@`a incluse @dfn{versus} estensioni
+
+Come descritto in questo e nei successivi @value{CHAPTERS},
+@command{gawk} ha numerose estensioni ulteriori,
+rispetto a quelle presenti nel comando @command{awk} standard.
+Queste sono state sviluppate col passare del tempo.
+Pi@`u recentemente, l'attenzione si @`e spostata sull'utilizzo
+del meccanismo delle estensioni (@pxref{Estensioni dinamiche}),
+per aggiungere ulteriori funzionalit@`a.
+@ifnotinfo
+Questa @value{SECTION}
+@end ifnotinfo
+@ifinfo
+Questo @value{SECTION}
+@end ifinfo
+tratta della ``filosofia ispiratrice'' riguardo a ci@`o che dovrebbe
+essere aggiunto all'interprete come funzionalit@`a interna,
+rispetto a quello che dovrebbe essere reso disponibile tramite
+estensioni.
+
+Ci sono parecchi obiettivi:
+
+@enumerate 1
+@item
+Conservare il comando @command{awk}; non dovrebbe divenire irriconoscibile
+anche se i programmi scritti per esso verranno eseguito solo usando
+@command{gawk}.
+
+@item
+Non aumentare le dimensioni del nucleo del programma, a meno che ci@`o
+sia assolutamente indispensabile.
+
+@item
+Aggiungere nuove funzionalit@`a o tramite @dfn{script}
+(opzione @option{-f}, direttiva @code{@@include})
+o in un'estensione caricabile scritta in C o C++
+(opzione @option{-l}, direttiva @code{@@load}).
+
+@item
+Estendere il nucleo dell'interpretatore solo se qualche funzionalit@`a @`e:
+
+@c sublist
+@enumerate A
+@item
+Veramente desiderabile.
+@item
+Non si pu@`o fare tramite dei file di libreria o estensioni caricabili.
+@item
+Pu@`o essere aggiunta al nucleo senza troppe difficolt@`a.
+@end enumerate
+@end enumerate
+
+Combinare dei moduli con dei file @command{awk} @`e una tecnica efficace.
+Lo si pu@`o vedere in alcuni degli esempi di estensione.
+
+Il caricamento di estensioni e librerie di file non dovrebbe essere
+fatto automaticamente, perch@'e questo richiede un consumo di risorse
+che molti utenti non desiderano, o di cui non hanno bisogno.
+
@node Sommario funzionalit@`a avanzate
@section Sommario
@@ -32012,9 +32119,14 @@ profilazione @command{gawk} scrive il profilo, includendo lo
@dfn{stack} della chiamata alla funzione e prosegue nell'elaborazione.
@item
-Si pu@`o anche fare solo una ``stampa elegante'' del programma.
+Si pu@`o anche fare solo una ``stampa-elegante'' del programma.
+@item
+Nuove funzionalit@`a dovrebbero essere sviluppate usando, se possibile,
+il meccanismo delle estensioni; si dovrebbero aggiungere al nucleo
+dell'interpretatore solo come ultima risorsa.
@end itemize
+
@node Internazionalizzazione
@chapter Internazionalizzazione con @command{gawk}
@@ -35079,10 +35191,10 @@ Questo
interagisce con altre importanti funzionalit@`a di @command{gawk}.
@cindex spazio-dei-nomi @subentry interazione con la profilazione
-@cindex spazio-dei-nomi @subentry interazione con la stampa elegante
+@cindex spazio-dei-nomi @subentry interazione con la ``stampa-elegante''
@cindex profilazione @subentry interazione con spazio-dei-nomi
-@cindex stampa elegante @subentry interazione con spazio-dei-nomi
-La profilazione e la stampa elegante (@pxref{Profilare}) sono state
+@cindex stampa-elegante @subentry interazione con spazio-dei-nomi
+La profilazione e la ``stampa-elegante'' (@pxref{Profilare}) sono state
migliorate per trattare gli spazi-dei-nomi e le regole per assegnare nomi in
uno spazio-dei-nomi @ref{Regole per i nomi}.
In particolare, l'output tiene insieme le funzioni che appartengono
@@ -35143,7 +35255,7 @@ disponibile la potenza e la flessibilit@`a necessarie.
@item
Altre parti di @command{gawk} sono state estese come necessario per
integrare gli spazi-dei-nomi nel loro funzionamento.
-Questo vale soprattutto per la profilazione / stampa elegante
+Questo vale soprattutto per la profilazione / ``stampa-elegante''
(@pxref{Profilare}) e per le funzionalit@`a relative alle
estensioni (@pxref{Estensioni dinamiche}).
@@ -35366,23 +35478,10 @@ Come i numeri vanno arrotondati, per eccesso o per difetto, quando necessario.
Maggiori dettagli verranno forniti in seguito.
@item NaN
-``Not a number'' (Non un Numero).@footnote{Grazie a Michael
-Brennan per questa descrizione, che abbiamo parafrasato, e per gli esempi.} Un
-valore speciale che risulta da un calcolo che non ha risposta come numero
-reale. In tal caso, i programmi possono o ricevere un'eccezione di virgola
-mobile, o restituire @code{NaN} come risultato. Lo standard IEEE 754
-consiglia che i sistemi restituiscano @code{NaN}. Alcuni esempi:
-
-@table @code
-@item sqrt(-1)
-La radice quadrata di @minus{}1 ha senso nell'insieme dei numeri complessi,
-ma non nell'insieme dei numeri reali,
-per cui il risultato @`e @code{NaN}.
-
-@item log(-8)
-Il logaritmo di @minus{}8 @`e fuori dal dominio di @code{log()},
-per cui il risultato @`e @code{NaN}.
-@end table
+``Not a number'' (``non @`e un numero''). Un valore speciale
+che risulta da un calcolo che non ha come risposta un numero
+reale. @xref{Valori strani}, per maggiori informazioni riguardo
+ai valori infiniti e ai valori ``non-un-numero''.
@item Normalizzato (formato)
Come la mantissa (vedi oltre in questa lista) @`e usualmente memorizzata. Il
@@ -35534,8 +35633,7 @@ ottenere ulteriori informazioni, e non basarsi solo su quanto qui detto.
* Ottenere la precisione:: Ottenere pi@`u precisione richiede qualche
sforzo.
* Tentare di arrotondare:: Aggiungere cifre di precisione e arrotondare.
-* Impostare la precisione:: Come impostare la precisione.
-* Impostare modo di arrotondare:: Impostare le modalit@`a di arrotondamento.
+* Valori strani:: Un cenno riguardo ai valori infiniti e a NaN [``non @`e un numero''].
@end menu
@node Inesattezza nei calcoli
@@ -35682,6 +35780,257 @@ $ @kbd{gawk 'BEGIN @{}
@print{} 4
@end example
+@node Valori strani
+@subsubsection Valori in virgola mobile non spiegati a scuola
+
+Sia l'hardware che implementa lo standard per i numeri in virgola
+mobili IEEE 754, che la libreria matematica MPFR, prevedono due
+tipi di valori di cui probabilmente non vi hanno parlato a scuola.
+Il primo @`e il valore @dfn{infinity} (``infinito''), un valore speciale
+che pu@`o avere un segno sia negativo che positivo, e che @`e pi@`u
+piccolo di ogni altro valore (infinito negativo), o maggiore di ogni
+altro valore (infinito positivo). Quando vengono generati tali valori
+@command{gawk} li stampa come @samp{-inf} o @samp{+inf}, rispettivamente.
+@command{gawk} accetta queste stringhe come dati in input, e li converte
+internamente all'appropriato valore in virgola mobile.
+
+Valori di infinito che abbiano lo stesso segno risultano uguali
+quando sono confrontati fra loro.
+Per il resto, altre operazioni (addizione, sottrazione, etc.)
+che hanno come operando un infinito e un altro numero producono
+risultati matematicamente ragionevoli.
+
+Il secondo tipo di valore @`e ``not a number'' [``non @`e un numero'']
+scritto in forma abbreviata come NaN.@footnote{Grazie a Michael Brennan
+per questa descrizione, che abbiamo parafrasato, e per gli esempi.}
+
+Questo @`e un valore speciale che risulta da un calcolo che non ha come
+risposta un numero reale. In tal caso, i programmi possono o ricevere
+un’eccezione di virgola mobile, o restituire NaN come risultato.
+Lo standard IEEE 754 consiglia che i sistemi restituiscano NaN.
+Alcuni esempi:
+
+@table @code
+@item sqrt(-1)
+@iftex
+La funzione @math{\sqrt{-1}}
+@end iftex
+@ifnottex
+Questa funzione
+@end ifnottex
+ha senso nell'insieme dei numeri complessi,
+ma non nell'insieme dei numeri reali,
+per cui il risultato @`e @code{NaN}.
+
+@item log(-8)
+Il logaritmo di @minus{}8 @`e fuori dal dominio di @code{log()},
+per cui il risultato @`e @code{NaN}.
+@end table
+
+I valori Nan sono strani. In particolare, non possono essere confrontati
+con altri numeri in virgola mobile; ogni confronto di questo tipo, eccetto
+quello ``non uguale a'', restituisce il valore ``falso''.
+I valori NaN sono talmente differenti da altri valori che perfino il
+confronto di due valori NaN identici fra loro con @code{!=} restituisce
+il valore ``vero''!
+
+I valori NaN possono anche avere un segno (positivo o negativo),
+anche se dipende dall'implementazione quale segno viene restituito
+da qualsiasi operazione il cui risultato sia un valore NaN.
+Per esempio, su alcuni sistemi la funzione @code{sqrt(-1)}
+restituisce un NaN negativo. Su altri sistemi il NaN restituito
+@`e invece positivo.
+
+Quando tali valori vengono generati, @command{gawk} li stampa
+come @samp{-nan} o @samp{+nan}, rispettivamente. Anche per
+questi valori, @command{gawk} accetta queste stringhe come
+dati in input e le converte internamente ai valori loro
+assegnati come numeri in virgola mobile.
+
+Se si desidera approfondire ulteriormente questo argomento, si possono
+trovare programmi di test scritti in C, @command{awk} e Python
+nella directory @file{awklib/eg/test-programs} disponibile
+nella distribuzione di @command{gawk}.
+Tali programmi permettono un confronto tra i linguaggi di
+programmazione, riguardo al modo con cui vengono trattati
+i valori di infinito e quelli NaN.
+
+@ignore
+@c file eg/test-programs/gen-float-table.awk
+function eq(left, right)
+@{
+ return left == right
+@}
+
+function ne(left, right)
+@{
+ return left != right
+@}
+
+function lt(left, right)
+@{
+ return left < right
+@}
+
+function le(left, right)
+@{
+ return left <= right
+@}
+
+function gt(left, right)
+@{
+ return left > right
+@}
+
+function ge(left, right)
+@{
+ return left >= right
+@}
+
+BEGIN @{
+ nan = sqrt(-1)
+ inf = -log(0)
+ split("== != < <= > >=", names)
+ names[3] = names[3] " "
+ names[5] = names[5] " "
+ split("eq ne lt le gt ge", funcs)
+
+ compare[1] = 2.0
+ compare[2] = values[1] = -sqrt(-1.0) # nan
+ compare[3] = values[2] = sqrt(-1.0) # -nan
+ compare[4] = values[3] = -log(0.0) # inf
+ compare[5] = values[4] = log(0.0) # -inf
+
+ for (i = 1; i in values; i++) @{
+ for (j = 1; j in compare; j++) @{
+ for (k = 1; k in names; k++) @{
+ the_func = funcs[k]
+ printf("%g %s %g -> %s\n",
+ values[i],
+ names[k],
+ compare[j],
+ @@the_func(values[i], compare[j]) ?
+ "True" : "False");
+ @}
+ printf("\n");
+ @}
+ @}
+@}
+@c endfile
+@end ignore
+
+@ignore
+@c file eg/test-programs/gen-float-table.c
+#include <stdio.h>
+#include <math.h>
+#include <stdbool.h>
+
+#define def_func(name, op) \
+ bool name(double left, double right) @{ \
+ return left op right; \
+ @}
+
+def_func(eq, ==)
+def_func(ne, !=)
+def_func(lt, <)
+def_func(le, <=)
+def_func(gt, >)
+def_func(ge, >=)
+
+struct @{
+ const char *name;
+ bool (*func)(double left, double right);
+@} functions[] = @{
+ @{ "==", eq @},
+ @{ "!=", ne @},
+ @{ "< ", lt @},
+ @{ "<=", le @},
+ @{ "> ", gt @},
+ @{ ">=", ge @},
+ @{ 0, 0 @}
+@};
+
+int main()
+@{
+ double values[] = @{
+ -sqrt(-1), // nan
+ sqrt(-1), // -nan
+ -log(0.0), // inf
+ log(0.0) // -inf
+ @};
+ double compare[] = @{ 2.0,
+ -sqrt(-1), // nan
+ sqrt(-1), // -nan
+ -log(0.0), // inf
+ log(0.0) // -inf
+ @};
+
+ int i, j, k;
+
+ for (i = 0; i < 4; i++) @{
+ for (j = 0; j < 5; j++) @{
+ for (k = 0; functions[k].name != NULL; k++) @{
+ printf("%g %s %g -> %s\n", values[i],
+ functions[k].name,
+ compare[j],
+ functions[k].func(values[i], compare[j]) ? "True" : "False");
+ @}
+ printf("\n");
+ @}
+ @}
+
+ return 0;
+@}
+@c endfile
+@end ignore
+
+@ignore
+@c file eg/test-programs/gen-float-table.py
+from math import *
+
+nan = float('NaN')
+inf = float('Inf')
+
+def eq(left, right):
+ return left == right
+
+def ne(left, right):
+ return left != right
+
+def lt(left, right):
+ return left < right
+
+def le(left, right):
+ return left <= right
+
+def gt(left, right):
+ return left > right
+
+def ge(left, right):
+ return left >= right
+
+func_map = {
+ "==": eq,
+ "!=": ne,
+ "< ": lt,
+ "<=": le,
+ "> ": gt,
+ ">=": ge,
+}
+
+compare = [2.0, nan, -nan, inf, -inf]
+values = [nan, -nan, inf, -inf]
+
+for i in range(len(values)):
+ for j in range(len(compare)):
+ for op in func_map:
+ print("%g %s %g -> %s" %
+ (values[i], op, compare[j], func_map[op](values[i], compare[j])))
+
+ print("")
+@c endfile
+@end ignore
+
@node Ottenere la precisione
@subsection Ottenere la precisione voluta
@@ -38023,7 +38372,7 @@ I campi sono:
@table @code
@item awk_bool_t use_chars;
Impostare ad @code{awk_true} se le lunghezze di campo sono specificate in
-unit@`a di caratteri potenzialmente multi-byte, oppure impostarlo a
+unit@`a di caratteri potenzialmente multibyte, oppure impostarlo a
@code{awk_false} se le lunghezze sono espresse in numero di byte.
L'efficienza del programma sar@`a maggiore utilizzando la dimensione in byte.
@@ -42555,7 +42904,7 @@ con @option{--}.
@item
L'opzione @option{--source} per combinare codice sorgente immesso nella riga
-di comando e codice sorgente proveniente da file di libreria.
+di comando e codice sorgente proveniente da librerie di file.
@end itemize
@end itemize
@@ -43057,7 +43406,7 @@ L'opzione @option{-D} attiva il debugger.
@item
Le opzioni @option{-i} e @option{--include}
-caricano dei file di libreria @command{awk}.
+caricano delle librerie di file @command{awk}.
@item
Le opzioni @option{-l} e @option{--load} caricano estensioni dinamiche
@@ -44390,7 +44739,7 @@ Il codice sorgente di @command{gawk}, in generale, cerca di aderire, nei limiti
del possibile, a degli standard formali. Ci@`o significa che @command{gawk} usa
routine di libreria che sono specificate nello standard ISO C e nello standard
POSIX per le interfacce dei sistemi operativi. Il codice sorgente di
-@command{gawk} richiede l'uso di un compilatore ISO C (standard 1990).
+@command{gawk} richiede l'uso di un compilatore ISO C (standard 1999).
Molti sistemi Unix non aderiscono completamente n@'e allo standard ISO n@'e a
quello POSIX. La sottodirectory @file{missing_d} nella distribuzione di
@@ -45411,6 +45760,10 @@ il sito @url{https://sourceforge.net/projects/awka}.
Il progetto sembra essere stato congelato; non ci sono state modifiche nel
codice sorgente dal 2001 circa.
+@item Resuscitare Awka
+Questo progetto, disponibile nel sito @uref{https://github.com/noyesno/awka},
+si propone di fissare bug in @command{awka} e di aggiungere nuove funzionalit@`a.
+
@cindex Beebe, Nelson H.F.@:
@cindex @command{pawk} (versione con profilazione di Brian Kernighan @command{awk})
@cindex codice sorgente @subentry @command{pawk}
@@ -45464,6 +45817,17 @@ il progetto
mette a disposizione questa implementazione. Si possono vedere i singoli file in
@uref{https://github.com/joyent/illumos-joyent/blob/master/usr/src/cmd/awk_xpg4}.
+@cindex @command{frawk}
+@cindex sorgente @subentry codice @subentry @command{frawk}
+@cindex codice sorgente @subentry @command{frawk}
+@item @command{frawk}
+Questo @`e un linguaggio per scrivere programmi corti.
+``In prima approssimazione, @`e un'implementazione del linguaggio AWK;
+molti comuni programmi @command{awk} producono un output equivalente
+quando passati a @command{frawk}.'' Comunque, ha anche numerose e
+importanti funzionalit@`a ulteriori. Il codice sorgente @`e disponibile
+sul sito @uref{https://github.com/ezrosent/frawk}.
+
@cindex @command{goawk}
@cindex Go @subentry implementazione di @command{awk}
@cindex sorgente @subentry @command{goawk}
@@ -45490,7 +45854,13 @@ essere un interprete completo, anche se, poich@'e usa funzionalit@`a di Java
per l'I/O e per la ricerca di @dfn{regexp}, il linguaggio che supporta
@`e differente da @command{awk} POSIX.
Ulteriori informazioni sono disponibili sulla
-@uref{https://jawk.sourceforge.net, pagina principale del progetto}.
+@uref{http://jawk.sourceforge.net, pagina principale del progetto}.
+
+@item Hoijui's @command{jawk}
+Questo progetto, disponibili sul sito
+@uref{https://github.com/hoijui/Jawk},
+@`e un altro interpretatore di @command{awk} scritto in Java.
+Usa i moderni strumenti di sviluppo software di Java.
@item Libmawk
@cindex @command{libmawk} (interpretatore)
@@ -45504,7 +45874,6 @@ Questo @`e un interprete @command{awk} incorporabile, derivato da
@cindex interpretatore @command{awk} incorporabile @subentry codice sorgente
@cindex Neacsu, Mircea
@item @command{awk} incorporabile di Mircea Neacsu
-@item incorporabile, @command{awk}, di Mircea Neacsu
Mircea Neacsu ha creato un interpretatore @command{awk}
incorporabile, basato su BWK @command{awk}. @`E disponibile
nel sito @uref{https://github.com/neacsum/awk}.
@@ -45549,6 +45918,9 @@ Wikipedia} su @command{awk} per informazioni su ulteriori versioni.
@end table
+Un'interessante raccolta di funzioni di libreria @`e disponibile sul sito
+@uref{https://github.com/e36freak/awk-libs}.
+
@node Sommario dell'installazione
@appendixsec Sommario
diff --git a/doc/it/texinfo.tex b/doc/it/texinfo.tex
index 68153132..b59c81cf 100644..100755
--- a/doc/it/texinfo.tex
+++ b/doc/it/texinfo.tex
@@ -3,9 +3,9 @@
% Load plain if necessary, i.e., if running under initex.
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
%
-\def\texinfoversion{2020-10-24.12}
+\def\texinfoversion{2021-02-20.11}
%
-% Copyright 1985, 1986, 1988, 1990-2020 Free Software Foundation, Inc.
+% Copyright 1985, 1986, 1988, 1990-2021 Free Software Foundation, Inc.
%
% This texinfo.tex file is free software: you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
@@ -248,7 +248,7 @@
\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
\removelastskip\penalty-200\bigskip\fi\fi}
-% Output routine
+% Output routine
%
% For a final copy, take out the rectangles
@@ -588,10 +588,9 @@
\fi
}
-% @end foo executes the definition of \Efoo.
-% But first, it executes a specialized version of \checkenv
-%
-\parseargdef\end{%
+
+% @end foo calls \checkenv and executes the definition of \Efoo.
+\parseargdef\end{
\if 1\csname iscond.#1\endcsname
\else
% The general wording of \badenverr may not be ideal.
@@ -2689,8 +2688,6 @@ end
\definetextfontsizexi
-\message{markup,}
-
% Check if we are currently using a typewriter font. Since all the
% Computer Modern typewriter fonts have zero interword stretch (and
% shrink), and it is reasonable to expect all typewriter fonts to have
@@ -2698,68 +2695,14 @@ end
%
\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
-% Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
-% define and register \INITMACRO to be called on markup style changes.
-% \INITMACRO can check \currentmarkupstyle for the innermost
-% style.
-
-\let\currentmarkupstyle\empty
-
-\def\setupmarkupstyle#1{%
- \def\currentmarkupstyle{#1}%
- \markupstylesetup
-}
-
-\let\markupstylesetup\empty
-
-\def\defmarkupstylesetup#1{%
- \expandafter\def\expandafter\markupstylesetup
- \expandafter{\markupstylesetup #1}%
- \def#1%
-}
-
-% Markup style setup for left and right quotes.
-\defmarkupstylesetup\markupsetuplq{%
- \expandafter\let\expandafter \temp
- \csname markupsetuplq\currentmarkupstyle\endcsname
- \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
-}
-
-\defmarkupstylesetup\markupsetuprq{%
- \expandafter\let\expandafter \temp
- \csname markupsetuprq\currentmarkupstyle\endcsname
- \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
-}
-
{
\catcode`\'=\active
\catcode`\`=\active
-\gdef\markupsetuplqdefault{\let`\lq}
-\gdef\markupsetuprqdefault{\let'\rq}
-
-\gdef\markupsetcodequoteleft{\let`\codequoteleft}
-\gdef\markupsetcodequoteright{\let'\codequoteright}
+\gdef\setcodequotes{\let`\codequoteleft \let'\codequoteright}
+\gdef\setregularquotes{\let`\lq \let'\rq}
}
-\let\markupsetuplqcode \markupsetcodequoteleft
-\let\markupsetuprqcode \markupsetcodequoteright
-%
-\let\markupsetuplqexample \markupsetcodequoteleft
-\let\markupsetuprqexample \markupsetcodequoteright
-%
-\let\markupsetuplqkbd \markupsetcodequoteleft
-\let\markupsetuprqkbd \markupsetcodequoteright
-%
-\let\markupsetuplqsamp \markupsetcodequoteleft
-\let\markupsetuprqsamp \markupsetcodequoteright
-%
-\let\markupsetuplqverb \markupsetcodequoteleft
-\let\markupsetuprqverb \markupsetcodequoteright
-%
-\let\markupsetuplqverbatim \markupsetcodequoteleft
-\let\markupsetuprqverbatim \markupsetcodequoteright
-
% Allow an option to not use regular directed right quote/apostrophe
% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
% The undirected quote is ugly, so don't make it the default, but it
@@ -2922,7 +2865,7 @@ end
}
% @samp.
-\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
+\def\samp#1{{\setcodequotes\lq\tclose{#1}\rq\null}}
% @indicateurl is \samp, that is, with quotes.
\let\indicateurl=\samp
@@ -2965,8 +2908,7 @@ end
\global\let'=\rq \global\let`=\lq % default definitions
%
\global\def\code{\begingroup
- \setupmarkupstyle{code}%
- % The following should really be moved into \setupmarkupstyle handlers.
+ \setcodequotes
\catcode\dashChar=\active \catcode\underChar=\active
\ifallowcodebreaks
\let-\codedash
@@ -3120,7 +3062,7 @@ end
\urefcatcodes
%
\global\def\urefcode{\begingroup
- \setupmarkupstyle{code}%
+ \setcodequotes
\urefcatcodes
\let&\urefcodeamp
\let.\urefcodedot
@@ -3241,8 +3183,8 @@ end
\def\kbdsub#1#2#3\par{%
\def\one{#1}\def\three{#3}\def\threex{??}%
\ifx\one\xkey\ifx\threex\three \key{#2}%
- \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
- \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
+ \else{\tclose{\kbdfont\setcodequotes\look}}\fi
+ \else{\tclose{\kbdfont\setcodequotes\look}}\fi
}
% definition of @key that produces a lozenge. Doesn't adjust to text size.
@@ -3259,7 +3201,7 @@ end
% monospace, don't change it; that way, we respect @kbdinputstyle. But
% if it isn't monospace, then use \tt.
%
-\def\key#1{{\setupmarkupstyle{key}%
+\def\key#1{{\setregularquotes
\nohyphenation
\ifmonospace\else\tt\fi
#1}\null}
@@ -3389,16 +3331,20 @@ end
{\obeylines
\globaldefs=1
\envdef\displaymath{%
-\tex
+\tex%
\def\thisenv{\displaymath}%
+\begingroup\let\end\displaymathend%
$$%
}
-\def\Edisplaymath{$$
+\def\displaymathend{$$\endgroup\end}%
+
+\def\Edisplaymath{%
\def\thisenv{\tex}%
\end tex
}}
+
% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
% Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
% except specified as a normal braced arg, so no newlines to worry about.
@@ -7163,7 +7109,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
% But \@ or @@ will get a plain @ character.
\envdef\tex{%
- \setupmarkupstyle{tex}%
+ \setregularquotes
\catcode `\\=0 \catcode `\{=1 \catcode `\}=2
\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
\catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
@@ -7389,7 +7335,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
% If you want all examples etc. small: @set dispenvsize small.
% If you want even small examples the full size: @set dispenvsize nosmall.
% This affects the following displayed environments:
-% @example, @display, @format, @lisp
+% @example, @display, @format, @lisp, @verbatim
%
\def\smallword{small}
\def\nosmallword{nosmall}
@@ -7435,9 +7381,9 @@ might help (with 'rm \jobname.?? \jobname.??s')%
%
\maketwodispenvdef{lisp}{example}{%
\nonfillstart
- \tt\setupmarkupstyle{example}%
+ \tt\setcodequotes
\let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
- \gobble % eat return
+ \parsearg\gobble
}
% @display/@smalldisplay: same as @lisp except keep current font.
%
@@ -7595,7 +7541,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\def\setupverb{%
\tt % easiest (and conventionally used) font for verbatim
\def\par{\leavevmode\endgraf}%
- \setupmarkupstyle{verb}%
+ \setcodequotes
\tabeightspaces
% Respect line breaks,
% print special symbols as themselves, and
@@ -7636,7 +7582,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\tt % easiest (and conventionally used) font for verbatim
\def\par{\egroup\leavevmode\box\verbbox\endgraf\starttabbox}%
\tabexpand
- \setupmarkupstyle{verbatim}%
+ \setcodequotes
% Respect line breaks,
% print special symbols as themselves, and
% make each space count.
@@ -8055,7 +8001,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
% leave the code in, but it's strange for @var to lead to typewriter.
% Nowadays we recommend @code, since the difference between a ttsl hyphen
% and a tt hyphen is pretty tiny. @code also disables ?` !`.
- \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
+ \def\var##1{{\setregularquotes\ttslanted{##1}}}%
#1%
\sl\hyphenchar\font=45
}
@@ -8164,11 +8110,18 @@ might help (with 'rm \jobname.?? \jobname.??s')%
}
\fi
+\let\E=\expandafter
+
% Used at the time of macro expansion.
% Argument is macro body with arguments substituted
\def\scanmacro#1{%
\newlinechar`\^^M
- \def\xeatspaces{\eatspaces}%
+ % expand the expansion of \eatleadingcr twice to maybe remove a leading
+ % newline (and \else and \fi tokens), then call \eatspaces on the result.
+ \def\xeatspaces##1{%
+ \E\E\E\E\E\E\E\eatspaces\E\E\E\E\E\E\E{\eatleadingcr##1%
+ }}%
+ \def\xempty##1{}%
%
% Process the macro body under the current catcode regime.
\scantokens{#1@comment}%
@@ -8221,6 +8174,11 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\unbrace{\gdef\trim@@@ #1 } #2@{#1}
}
+{\catcode`\^^M=\other%
+\gdef\eatleadingcr#1{\if\noexpand#1\noexpand^^M\else\E#1\fi}}%
+% Warning: this won't work for a delimited argument
+% or for an empty argument
+
% Trim a single trailing ^^M off a string.
{\catcode`\^^M=\other \catcode`\Q=3%
\gdef\eatcr #1{\eatcra #1Q^^MQ}%
@@ -8387,6 +8345,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\let\hash\relax
% \hash is redefined to `#' later to get it into definitions
\let\xeatspaces\relax
+ \let\xempty\relax
\parsemargdefxxx#1,;,%
\ifnum\paramno<10\relax\else
\paramno0\relax
@@ -8398,9 +8357,11 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\else \let\next=\parsemargdefxxx
\advance\paramno by 1
\expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
- {\xeatspaces{\hash\the\paramno}}%
+ {\xeatspaces{\hash\the\paramno\noexpand\xempty{}}}%
\edef\paramlist{\paramlist\hash\the\paramno,}%
\fi\next}
+% the \xempty{} is to give \eatleadingcr an argument in the case of an
+% empty macro argument.
% \parsemacbody, \parsermacbody
%
@@ -8989,7 +8950,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\else
\ifhavexrefs
% We (should) know the real title if we have the xref values.
- \def\printedrefname{\refx{#1-title}{}}%
+ \def\printedrefname{\refx{#1-title}}%
\else
% Otherwise just copy the Info node name.
\def\printedrefname{\ignorespaces #1}%
@@ -9083,7 +9044,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
% If the user specified the print name (third arg) to the ref,
% print it instead of our usual "Figure 1.2".
\ifdim\wd\printedrefnamebox = 0pt
- \refx{#1-snt}{}%
+ \refx{#1-snt}%
\else
\printedrefname
\fi
@@ -9118,28 +9079,30 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\else
% Reference within this manual.
%
- % Only output a following space if the -snt ref is nonempty; for
- % @unnumbered and @anchor, it won't be.
- \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
+ % Only output a following space if the -snt ref is nonempty, as the ref
+ % will be empty for @unnumbered and @anchor.
+ \setbox2 = \hbox{\ignorespaces \refx{#1-snt}}%
\ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
%
% output the `[mynode]' via the macro below so it can be overridden.
\xrefprintnodename\printedrefname
%
- % But we always want a comma and a space:
- ,\space
- %
- % output the `page 3'.
- \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
- % Add a , if xref followed by a space
- \if\space\noexpand\tokenafterxref ,%
- \else\ifx\ \tokenafterxref ,% @TAB
- \else\ifx\*\tokenafterxref ,% @*
- \else\ifx\ \tokenafterxref ,% @SPACE
- \else\ifx\
- \tokenafterxref ,% @NL
- \else\ifx\tie\tokenafterxref ,% @tie
- \fi\fi\fi\fi\fi\fi
+ \expandafter\ifx\csname SETtxiomitxrefpg\endcsname\relax
+ % But we always want a comma and a space:
+ ,\space
+ %
+ % output the `page 3'.
+ \turnoffactive \putwordpage\tie\refx{#1-pg}%
+ % Add a , if xref followed by a space
+ \if\space\noexpand\tokenafterxref ,%
+ \else\ifx\ \tokenafterxref ,% @TAB
+ \else\ifx\*\tokenafterxref ,% @*
+ \else\ifx\ \tokenafterxref ,% @SPACE
+ \else\ifx\
+ \tokenafterxref ,% @NL
+ \else\ifx\tie\tokenafterxref ,% @tie
+ \fi\fi\fi\fi\fi\fi
+ \fi
\fi\fi
\fi
\endlink
@@ -9206,9 +9169,8 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\fi\fi\fi
}
-% \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME. SUFFIX
-% is output afterwards if non-empty.
-\def\refx#1#2{%
+% \refx{NAME} - reference a cross-reference string named NAME.
+\def\refx#1{%
\requireauxfile
{%
\indexnofonts
@@ -9235,7 +9197,6 @@ might help (with 'rm \jobname.?? \jobname.??s')%
% It's defined, so just use it.
\thisrefX
\fi
- #2% Output the suffix in any case.
}
% This is the macro invoked by entries in the aux file. Define a control
@@ -9345,10 +9306,10 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\catcode`\[=\other
\catcode`\]=\other
\catcode`\"=\other
- \catcode`\_=\other
- \catcode`\|=\other
- \catcode`\<=\other
- \catcode`\>=\other
+ \catcode`\_=\active
+ \catcode`\|=\active
+ \catcode`\<=\active
+ \catcode`\>=\active
\catcode`\$=\other
\catcode`\#=\other
\catcode`\&=\other
@@ -9569,7 +9530,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
\catcode`\^^M = 5 % in case we're inside an example
\normalturnoffactive % allow _ et al. in names
- \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
+ \makevalueexpandable
% If the image is by itself, center it.
\ifvmode
\imagevmodetrue
@@ -11622,7 +11583,7 @@ directory should work if nowhere else does.}
\let> = \activegtr
\let~ = \activetilde
\let^ = \activehat
- \markupsetuplqdefault \markupsetuprqdefault
+ \setregularquotes
\let\b = \strong
\let\i = \smartitalic
% in principle, all other definitions in \tex have to be undone too.
@@ -11681,8 +11642,7 @@ directory should work if nowhere else does.}
@let|=@normalverticalbar
@let~=@normaltilde
@let\=@ttbackslash
- @markupsetuplqdefault
- @markupsetuprqdefault
+ @setregularquotes
@unsepspaces
}
}
@@ -11775,8 +11735,7 @@ directory should work if nowhere else does.}
@c Do this last of all since we use ` in the previous @catcode assignments.
@catcode`@'=@active
@catcode`@`=@active
-@markupsetuplqdefault
-@markupsetuprqdefault
+@setregularquotes
@c Local variables:
@c eval: (add-hook 'before-save-hook 'time-stamp)
diff --git a/doc/wordlist b/doc/wordlist
index 95ca8a75..be7655ec 100644
--- a/doc/wordlist
+++ b/doc/wordlist
@@ -321,6 +321,7 @@ NR
NT
NUMCUR
NaN
+NaNs
Nachum
Neacsu
Neacsu's
diff --git a/eval.c b/eval.c
index 9e644523..640f939f 100644
--- a/eval.c
+++ b/eval.c
@@ -25,10 +25,8 @@
*/
#include "awk.h"
+#include <math.h>
-extern double pow(double x, double y);
-extern double modf(double x, double *yp);
-extern double fmod(double x, double y);
NODE **fcall_list = NULL;
long fcall_count = 0;
int currule = 0;
@@ -1521,18 +1519,17 @@ eval_condition(NODE *t)
return boolval(t);
}
-typedef enum {
- SCALAR_EQ_NEQ,
- SCALAR_RELATIONAL
-} scalar_cmp_t;
+static bool cmp_doubles(const NODE *t1, const NODE *t2, scalar_cmp_t comparison_type);
+extern bool mpg_cmp_as_numbers(const NODE *t1, const NODE *t2, scalar_cmp_t comparison_type);
/* cmp_scalars -- compare two nodes on the stack */
-static inline int
+static bool
cmp_scalars(scalar_cmp_t comparison_type)
{
NODE *t1, *t2;
int di;
+ bool ret;
t2 = POP_SCALAR();
t1 = TOP();
@@ -1540,12 +1537,91 @@ cmp_scalars(scalar_cmp_t comparison_type)
DEREF(t2);
fatal(_("attempt to use array `%s' in a scalar context"), array_vname(t1));
}
- di = cmp_nodes(t1, t2, comparison_type == SCALAR_EQ_NEQ);
+
+ if ((t1->flags & STRING) != 0 || (t2->flags & STRING) != 0) {
+ bool use_strcmp = (comparison_type == SCALAR_EQ || comparison_type == SCALAR_NEQ);
+ di = cmp_nodes(t1, t2, use_strcmp);
+
+ switch (comparison_type) {
+ case SCALAR_EQ:
+ ret = (di == 0);
+ break;
+ case SCALAR_NEQ:
+ ret = (di != 0);
+ break;
+ case SCALAR_LT:
+ ret = (di < 0);
+ break;
+ case SCALAR_LE:
+ ret = (di <= 0);
+ break;
+ case SCALAR_GT:
+ ret = (di > 0);
+ break;
+ case SCALAR_GE:
+ ret = (di >= 0);
+ break;
+ }
+ } else {
+ fixtype(t1);
+ fixtype(t2);
+
+#ifdef HAVE_MPFR
+ if (do_mpfr)
+ ret = mpg_cmp_as_numbers(t1, t2, comparison_type);
+ else
+#endif
+ ret = cmp_doubles(t1, t2, comparison_type);
+ }
+
DEREF(t1);
DEREF(t2);
- return di;
+ return ret;
}
+
+/* cmp_doubles --- compare two doubles */
+
+static bool
+cmp_doubles(const NODE *t1, const NODE *t2, scalar_cmp_t comparison_type)
+{
+ /*
+ * This routine provides numeric comparisons that should work
+ * the same as in C. It should NOT be used for sorting.
+ */
+
+ bool t1_nan = isnan(t1->numbr);
+ bool t2_nan = isnan(t2->numbr);
+ int ret;
+
+ if ((t1_nan || t2_nan) && comparison_type != SCALAR_NEQ)
+ return false;
+
+ switch (comparison_type) {
+ case SCALAR_EQ:
+ ret = (t1->numbr == t2->numbr);
+ break;
+ case SCALAR_NEQ:
+ ret = (t1->numbr != t2->numbr);
+ break;
+ case SCALAR_LT:
+ ret = (t1->numbr < t2->numbr);
+ break;
+ case SCALAR_LE:
+ ret = (t1->numbr <= t2->numbr);
+ break;
+ case SCALAR_GT:
+ ret = (t1->numbr > t2->numbr);
+ break;
+ case SCALAR_GE:
+ ret = (t1->numbr >= t2->numbr);
+ break;
+ }
+
+ return ret;
+}
+
+
/* op_assign --- assignment operators excluding = */
static void
diff --git a/interpret.h b/interpret.h
index 739f81eb..93a50f24 100644
--- a/interpret.h
+++ b/interpret.h
@@ -486,37 +486,37 @@ uninitialized_scalar:
break;
case Op_equal:
- r = node_Boolean[cmp_scalars(SCALAR_EQ_NEQ) == 0];
+ r = node_Boolean[cmp_scalars(SCALAR_EQ)];
UPREF(r);
REPLACE(r);
break;
case Op_notequal:
- r = node_Boolean[cmp_scalars(SCALAR_EQ_NEQ) != 0];
+ r = node_Boolean[cmp_scalars(SCALAR_NEQ)];
UPREF(r);
REPLACE(r);
break;
case Op_less:
- r = node_Boolean[cmp_scalars(SCALAR_RELATIONAL) < 0];
+ r = node_Boolean[cmp_scalars(SCALAR_LT)];
UPREF(r);
REPLACE(r);
break;
case Op_greater:
- r = node_Boolean[cmp_scalars(SCALAR_RELATIONAL) > 0];
+ r = node_Boolean[cmp_scalars(SCALAR_GT)];
UPREF(r);
REPLACE(r);
break;
case Op_leq:
- r = node_Boolean[cmp_scalars(SCALAR_RELATIONAL) <= 0];
+ r = node_Boolean[cmp_scalars(SCALAR_LE)];
UPREF(r);
REPLACE(r);
break;
case Op_geq:
- r = node_Boolean[cmp_scalars(SCALAR_RELATIONAL) >= 0];
+ r = node_Boolean[cmp_scalars(SCALAR_GE)];
UPREF(r);
REPLACE(r);
break;
diff --git a/mpfr.c b/mpfr.c
index cabc3910..6b8f9c93 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -476,6 +476,50 @@ mpg_cmp(const NODE *t1, const NODE *t2)
return cmp_awknums(t1, t2);
}
+/* mpg_cmp_as_numbers --- compare two numbers, similar to doubles */
+
+bool
+mpg_cmp_as_numbers(const NODE *t1, const NODE *t2, scalar_cmp_t comparison_type)
+{
+ /*
+ * This routine provides numeric comparisons that should work
+ * the same as in C. It should NOT be used for sorting.
+ */
+
+ bool t1_nan = mpfr_nan_p(t1->mpg_numbr);
+ bool t2_nan = mpfr_nan_p(t2->mpg_numbr);
+ int ret;
+
+ // MPFR is different than native doubles...
+ if (t1_nan || t2_nan)
+ return comparison_type == SCALAR_NEQ;
+
+ int di = mpg_cmp(t1, t2);
+
+ switch (comparison_type) {
+ case SCALAR_EQ:
+ ret = (di == 0);
+ break;
+ case SCALAR_NEQ:
+ ret = (di != 0);
+ break;
+ case SCALAR_LT:
+ ret = (di < 0);
+ break;
+ case SCALAR_LE:
+ ret = (di <= 0);
+ break;
+ case SCALAR_GT:
+ ret = (di > 0);
+ break;
+ case SCALAR_GE:
+ ret = (di >= 0);
+ break;
+ }
+
+ return ret;
+}
+
/*
* mpg_update_var --- update NR or FNR.
diff --git a/node.c b/node.c
index 12d7a046..c22c06ab 100644
--- a/node.c
+++ b/node.c
@@ -370,7 +370,7 @@ int
cmp_awknums(const NODE *t1, const NODE *t2)
{
/*
- * This routine is also used to sort numeric array indices or values.
+ * This routine is used to sort numeric array indices or values.
* For the purposes of sorting, NaN is considered greater than
* any other value, and all NaN values are considered equivalent and equal.
* This isn't in compliance with IEEE standard, but compliance w.r.t. NaN
@@ -390,7 +390,6 @@ cmp_awknums(const NODE *t1, const NODE *t2)
return 1;
}
-
/* make_str_node --- make a string node */
NODE *
diff --git a/str_array.c b/str_array.c
index 84bd2f02..215a52fd 100644
--- a/str_array.c
+++ b/str_array.c
@@ -94,6 +94,7 @@ static void grow_table(NODE *symbol);
static unsigned long gst_hash_string(const char *str, size_t len, unsigned long hsize, size_t *code);
static unsigned long scramble(unsigned long x);
+static unsigned long fnv1a_hash_string(const char *str, size_t len, unsigned long hsize, size_t *code);
static unsigned long awk_hash(const char *s, size_t len, unsigned long hsize, size_t *code);
unsigned long (*hash)(const char *s, size_t len, unsigned long hsize, size_t *code) = awk_hash;
@@ -111,8 +112,13 @@ str_array_init(NODE *symbol ATTRIBUTE_UNUSED, NODE *subs ATTRIBUTE_UNUSED)
/* check relevant environment variables */
if ((newval = getenv_long("STR_CHAIN_MAX")) > 0)
STR_CHAIN_MAX = newval;
- if ((val = getenv("AWK_HASH")) != NULL && strcmp(val, "gst") == 0)
- hash = gst_hash_string;
+
+ if ((val = getenv("AWK_HASH")) != NULL) {
+ if (strcmp(val, "gst") == 0)
+ hash = gst_hash_string;
+ else if (strcmp(val, "fnv1a") == 0)
+ hash = fnv1a_hash_string;
+ }
} else
null_array(symbol);
@@ -772,6 +778,34 @@ scramble(unsigned long x)
return x;
}
+/* fnv1a_hash_string --- fnv1a hash function */
+
+/*
+ * FNV-1a hash function
+ * http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ */
+
+static unsigned long
+fnv1a_hash_string(const char *str, size_t len, unsigned long hsize, size_t *code)
+{
+ /* FNV-1a */
+ register unsigned ret = 2166136261U;
+
+ while (len > 0) {
+ ret ^= (unsigned char) (*str++);
+ ret *= 16777619U;
+ len-- ;
+ }
+
+ if (code != NULL)
+ *code = ret;
+
+ if (ret >= hsize)
+ ret %= hsize;
+
+ return ret;
+}
+
/* env_remove --- for ENVIRON, remove value from real environment */
static NODE **