gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-818


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-818-g662eb8e
Date: Thu, 18 Feb 2016 19:50:16 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, gawk-4.1-stable has been updated
       via  662eb8ea3cdbafed16f2d3abb06c3a03e1c92526 (commit)
      from  771ead66d55eee963444a4cd946d23886e11bd03 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=662eb8ea3cdbafed16f2d3abb06c3a03e1c92526

commit 662eb8ea3cdbafed16f2d3abb06c3a03e1c92526
Author: Arnold D. Robbins <address@hidden>
Date:   Thu Feb 18 21:49:33 2016 +0200

    Fixes to sample programs in the doc.

diff --git a/awklib/eg/prog/cut.awk b/awklib/eg/prog/cut.awk
index 080279b..fd77910 100644
--- a/awklib/eg/prog/cut.awk
+++ b/awklib/eg/prog/cut.awk
@@ -35,7 +35,7 @@ BEGIN {
                        " for delimiter\n", Optarg) > "/dev/stderr"
                 Optarg = substr(Optarg, 1, 1)
             }
-            FS = Optarg
+            fs = FS = Optarg
             OFS = FS
             if (FS == " ")    # defeat awk semantics
                 FS = "[ ]"
@@ -123,7 +123,7 @@ function set_charlist(    field, i, j, f, g, n, m, t,
     nfields = j - 1
 }
 {
-    if (by_fields && suppress && index($0, FS) == 0)
+    if (by_fields && suppress && index($0, fs) == 0)
         next
 
     for (i = 1; i <= nfields; i++) {
diff --git a/awklib/eg/prog/wc.awk b/awklib/eg/prog/wc.awk
index 95940ae..c46d098 100644
--- a/awklib/eg/prog/wc.awk
+++ b/awklib/eg/prog/wc.awk
@@ -30,7 +30,7 @@ BEGIN {
     if (! do_lines && ! do_words && ! do_chars)
         do_lines = do_words = do_chars = 1
 
-    print_total = (ARGC - i > 2)
+    print_total = (ARGC - i > 1)
 }
 function beginfile(file)
 {
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 7ecd1b9..d3afeed 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,9 @@
+2016-02-18         Arnold D. Robbins     <address@hidden>
+
+       * gawktexi.in: Fixes in wc.awk and in cut.awk. Thanks to David Ward,
+       address@hidden  Added an example of use of rewind(), also
+       per suggestion from David Ward.
+
 2016-02-14         Arnold D. Robbins     <address@hidden>
 
        * gawktexi.in: Revise for use with Texinfo 6.1.
diff --git a/doc/gawk.info b/doc/gawk.info
index f66dacb..08c774c 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -15256,6 +15256,33 @@ should not call it from an 'ENDFILE' rule.  (This 
isn't necessary
 anyway, because 'gawk' goes to the next file as soon as an 'ENDFILE'
 rule finishes!)
 
+   You need to be careful calling 'rewind()'.  You can end up causing
+infinite recursion if you don't pay attenion.  Here is an example use:
+
+     $ cat data
+     -| a
+     -| b
+     -| c
+     -| d
+     -| e
+
+     $ cat test.awk
+     -| FNR == 3 && ! rewound {
+     -|        rewound = 1
+     -|        rewind()
+     -| }
+     -|
+     -| { print FILENAME, FNR, $0 }
+
+     $ gawk -f rewind.awk -f test.awk data 
+     -| data 1 a
+     -| data 2 b
+     -| data 1 a
+     -| data 2 b
+     -| data 3 c
+     -| data 4 d
+     -| data 5 e
+
 
 File: gawk.info,  Node: File Checking,  Next: Empty Files,  Prev: Rewind 
Function,  Up: Data File Management
 
@@ -16479,7 +16506,7 @@ by characters, the output field separator is set to the 
null string:
                             " for delimiter\n", Optarg) > "/dev/stderr"
                      Optarg = substr(Optarg, 1, 1)
                  }
-                 FS = Optarg
+                 fs = FS = Optarg
                  OFS = FS
                  if (FS == " ")    # defeat awk semantics
                      FS = "[ ]"
@@ -16496,11 +16523,15 @@ by characters, the output field separator is set to 
the null string:
    The code must take special care when the field delimiter is a space.
 Using a single space ('" "') for the value of 'FS' is incorrect--'awk'
 would separate fields with runs of spaces, TABs, and/or newlines, and we
-want them to be separated with individual spaces.  Also remember that
-after 'getopt()' is through (as described in *note Getopt Function::),
-we have to clear out all the elements of 'ARGV' from 1 to 'Optind', so
-that 'awk' does not try to process the command-line options as file
-names.
+want them to be separated with individual spaces.  To this end, we save
+the original space character in the variable 'fs' for later use; after
+setting 'FS' to '"[ ]"' we can't use it directly to see if the field
+delimiter character is in the string.
+
+   Also remember that after 'getopt()' is through (as described in *note
+Getopt Function::), we have to clear out all the elements of 'ARGV' from
+1 to 'Optind', so that 'awk' does not try to process the command-line
+options as file names.
 
    After dealing with the command-line options, the program verifies
 that the options make sense.  Only one or the other of '-c' and '-f'
@@ -16623,8 +16654,8 @@ printed.  The corresponding field is printed if it 
contains data.  If
 the next field also has data, then the separator character is written
 out between the fields:
 
-     {
-         if (by_fields && suppress && index($0, FS) == 0)
+
+         if (by_fields && suppress && index($0, fs) == 0)
              next
 
          for (i = 1; i <= nfields; i++) {
@@ -17454,7 +17485,7 @@ line:
          if (! do_lines && ! do_words && ! do_chars)
              do_lines = do_words = do_chars = 1
 
-         print_total = (ARGC - i > 2)
+         print_total = (ARGC - i > 1)
      }
 
    The 'beginfile()' function is simple; it just resets the counts of
@@ -34884,268 +34915,268 @@ Node: Shell Quoting629481
 Node: Data File Management630882
 Node: Filetrans Function631514
 Node: Rewind Function635610
-Node: File Checking636996
-Ref: File Checking-Footnote-1638330
-Node: Empty Files638531
-Node: Ignoring Assigns640510
-Node: Getopt Function642060
-Ref: Getopt Function-Footnote-1653529
-Node: Passwd Functions653729
-Ref: Passwd Functions-Footnote-1662568
-Node: Group Functions662656
-Ref: Group Functions-Footnote-1670553
-Node: Walking Arrays670760
-Node: Library Functions Summary673768
-Node: Library Exercises675174
-Node: Sample Programs675639
-Node: Running Examples676409
-Node: Clones677137
-Node: Cut Program678361
-Node: Egrep Program688082
-Ref: Egrep Program-Footnote-1695594
-Node: Id Program695704
-Node: Split Program699384
-Ref: Split Program-Footnote-1702843
-Node: Tee Program702972
-Node: Uniq Program705762
-Node: Wc Program713188
-Ref: Wc Program-Footnote-1717443
-Node: Miscellaneous Programs717537
-Node: Dupword Program718750
-Node: Alarm Program720780
-Node: Translate Program725635
-Ref: Translate Program-Footnote-1730200
-Node: Labels Program730470
-Ref: Labels Program-Footnote-1733821
-Node: Word Sorting733905
-Node: History Sorting737977
-Node: Extract Program739812
-Node: Simple Sed747341
-Node: Igawk Program750415
-Ref: Igawk Program-Footnote-1764746
-Ref: Igawk Program-Footnote-2764948
-Ref: Igawk Program-Footnote-3765070
-Node: Anagram Program765185
-Node: Signature Program768247
-Node: Programs Summary769494
-Node: Programs Exercises770708
-Ref: Programs Exercises-Footnote-1774837
-Node: Advanced Features774928
-Node: Nondecimal Data776918
-Node: Array Sorting778509
-Node: Controlling Array Traversal779209
-Ref: Controlling Array Traversal-Footnote-1787576
-Node: Array Sorting Functions787694
-Ref: Array Sorting Functions-Footnote-1792785
-Node: Two-way I/O792981
-Ref: Two-way I/O-Footnote-1798801
-Ref: Two-way I/O-Footnote-2798988
-Node: TCP/IP Networking799070
-Node: Profiling802188
-Node: Advanced Features Summary809727
-Node: Internationalization811663
-Node: I18N and L10N813143
-Node: Explaining gettext813830
-Ref: Explaining gettext-Footnote-1818853
-Ref: Explaining gettext-Footnote-2819038
-Node: Programmer i18n819203
-Ref: Programmer i18n-Footnote-1824058
-Node: Translator i18n824107
-Node: String Extraction824901
-Ref: String Extraction-Footnote-1826033
-Node: Printf Ordering826119
-Ref: Printf Ordering-Footnote-1828905
-Node: I18N Portability828969
-Ref: I18N Portability-Footnote-1831425
-Node: I18N Example831488
-Ref: I18N Example-Footnote-1834294
-Node: Gawk I18N834367
-Node: I18N Summary835012
-Node: Debugger836353
-Node: Debugging837375
-Node: Debugging Concepts837816
-Node: Debugging Terms839625
-Node: Awk Debugging842200
-Node: Sample Debugging Session843106
-Node: Debugger Invocation843640
-Node: Finding The Bug845026
-Node: List of Debugger Commands851504
-Node: Breakpoint Control852837
-Node: Debugger Execution Control856531
-Node: Viewing And Changing Data859893
-Node: Execution Stack863267
-Node: Debugger Info864904
-Node: Miscellaneous Debugger Commands868975
-Node: Readline Support874063
-Node: Limitations874959
-Node: Debugging Summary877068
-Node: Arbitrary Precision Arithmetic878241
-Node: Computer Arithmetic879657
-Ref: table-numeric-ranges883248
-Ref: Computer Arithmetic-Footnote-1883970
-Node: Math Definitions884027
-Ref: table-ieee-formats887341
-Ref: Math Definitions-Footnote-1887944
-Node: MPFR features888049
-Node: FP Math Caution889766
-Ref: FP Math Caution-Footnote-1890838
-Node: Inexactness of computations891207
-Node: Inexact representation892167
-Node: Comparing FP Values893527
-Node: Errors accumulate894609
-Node: Getting Accuracy896042
-Node: Try To Round898752
-Node: Setting precision899651
-Ref: table-predefined-precision-strings900348
-Node: Setting the rounding mode902178
-Ref: table-gawk-rounding-modes902552
-Ref: Setting the rounding mode-Footnote-1905960
-Node: Arbitrary Precision Integers906139
-Ref: Arbitrary Precision Integers-Footnote-1909123
-Node: POSIX Floating Point Problems909272
-Ref: POSIX Floating Point Problems-Footnote-1913154
-Node: Floating point summary913192
-Node: Dynamic Extensions915382
-Node: Extension Intro916935
-Node: Plugin License918201
-Node: Extension Mechanism Outline918998
-Ref: figure-load-extension919437
-Ref: figure-register-new-function921002
-Ref: figure-call-new-function922094
-Node: Extension API Description924156
-Node: Extension API Functions Introduction925604
-Node: General Data Types930416
-Ref: General Data Types-Footnote-1936371
-Node: Memory Allocation Functions936670
-Ref: Memory Allocation Functions-Footnote-1939515
-Node: Constructor Functions939614
-Node: Registration Functions941359
-Node: Extension Functions942044
-Node: Exit Callback Functions944343
-Node: Extension Version String945593
-Node: Input Parsers946256
-Node: Output Wrappers956141
-Node: Two-way processors960653
-Node: Printing Messages962917
-Ref: Printing Messages-Footnote-1963991
-Node: Updating ERRNO964144
-Node: Requesting Values964883
-Ref: table-value-types-returned965620
-Node: Accessing Parameters966503
-Node: Symbol Table Access967738
-Node: Symbol table by name968250
-Node: Symbol table by cookie970271
-Ref: Symbol table by cookie-Footnote-1974420
-Node: Cached values974484
-Ref: Cached values-Footnote-1977985
-Node: Array Manipulation978076
-Ref: Array Manipulation-Footnote-1979175
-Node: Array Data Types979212
-Ref: Array Data Types-Footnote-1981870
-Node: Array Functions981962
-Node: Flattening Arrays985820
-Node: Creating Arrays992728
-Node: Extension API Variables997499
-Node: Extension Versioning998135
-Node: Extension API Informational Variables1000026
-Node: Extension API Boilerplate1001090
-Node: Finding Extensions1004904
-Node: Extension Example1005463
-Node: Internal File Description1006261
-Node: Internal File Ops1010341
-Ref: Internal File Ops-Footnote-11022103
-Node: Using Internal File Ops1022243
-Ref: Using Internal File Ops-Footnote-11024626
-Node: Extension Samples1024900
-Node: Extension Sample File Functions1026429
-Node: Extension Sample Fnmatch1034078
-Node: Extension Sample Fork1035565
-Node: Extension Sample Inplace1036783
-Node: Extension Sample Ord1039993
-Node: Extension Sample Readdir1040829
-Ref: table-readdir-file-types1041718
-Node: Extension Sample Revout1042523
-Node: Extension Sample Rev2way1043112
-Node: Extension Sample Read write array1043852
-Node: Extension Sample Readfile1045794
-Node: Extension Sample Time1046889
-Node: Extension Sample API Tests1048237
-Node: gawkextlib1048729
-Node: Extension summary1051153
-Node: Extension Exercises1054845
-Node: Language History1056342
-Node: V7/SVR3.11057998
-Node: SVR41060150
-Node: POSIX1061584
-Node: BTL1062963
-Node: POSIX/GNU1063692
-Node: Feature History1069213
-Node: Common Extensions1082542
-Node: Ranges and Locales1083825
-Ref: Ranges and Locales-Footnote-11088441
-Ref: Ranges and Locales-Footnote-21088468
-Ref: Ranges and Locales-Footnote-31088703
-Node: Contributors1088924
-Node: History summary1094493
-Node: Installation1095873
-Node: Gawk Distribution1096817
-Node: Getting1097301
-Node: Extracting1098262
-Node: Distribution contents1099900
-Node: Unix Installation1105651
-Node: Quick Installation1106267
-Node: Additional Configuration Options1108694
-Node: Configuration Philosophy1110498
-Node: Non-Unix Installation1112867
-Node: PC Installation1113325
-Node: PC Binary Installation1114645
-Node: PC Compiling1116497
-Ref: PC Compiling-Footnote-11119521
-Node: PC Testing1119630
-Node: PC Using1120810
-Node: Cygwin1124924
-Node: MSYS1125694
-Node: VMS Installation1126195
-Node: VMS Compilation1126986
-Ref: VMS Compilation-Footnote-11128215
-Node: VMS Dynamic Extensions1128273
-Node: VMS Installation Details1129958
-Node: VMS Running1132211
-Node: VMS GNV1136490
-Node: VMS Old Gawk1137225
-Node: Bugs1137696
-Node: Other Versions1141893
-Node: Installation summary1148477
-Node: Notes1149535
-Node: Compatibility Mode1150400
-Node: Additions1151182
-Node: Accessing The Source1152107
-Node: Adding Code1153542
-Node: New Ports1159761
-Node: Derived Files1164249
-Ref: Derived Files-Footnote-11169734
-Ref: Derived Files-Footnote-21169769
-Ref: Derived Files-Footnote-31170367
-Node: Future Extensions1170481
-Node: Implementation Limitations1171139
-Node: Extension Design1172322
-Node: Old Extension Problems1173476
-Ref: Old Extension Problems-Footnote-11174994
-Node: Extension New Mechanism Goals1175051
-Ref: Extension New Mechanism Goals-Footnote-11178415
-Node: Extension Other Design Decisions1178604
-Node: Extension Future Growth1180717
-Node: Old Extension Mechanism1181553
-Node: Notes summary1183316
-Node: Basic Concepts1184498
-Node: Basic High Level1185179
-Ref: figure-general-flow1185461
-Ref: figure-process-flow1186146
-Ref: Basic High Level-Footnote-11189447
-Node: Basic Data Typing1189632
-Node: Glossary1192960
-Node: Copying1224906
-Node: GNU Free Documentation License1262445
-Node: Index1287563
+Node: File Checking637515
+Ref: File Checking-Footnote-1638849
+Node: Empty Files639050
+Node: Ignoring Assigns641029
+Node: Getopt Function642579
+Ref: Getopt Function-Footnote-1654048
+Node: Passwd Functions654248
+Ref: Passwd Functions-Footnote-1663087
+Node: Group Functions663175
+Ref: Group Functions-Footnote-1671072
+Node: Walking Arrays671279
+Node: Library Functions Summary674287
+Node: Library Exercises675693
+Node: Sample Programs676158
+Node: Running Examples676928
+Node: Clones677656
+Node: Cut Program678880
+Node: Egrep Program688803
+Ref: Egrep Program-Footnote-1696315
+Node: Id Program696425
+Node: Split Program700105
+Ref: Split Program-Footnote-1703564
+Node: Tee Program703693
+Node: Uniq Program706483
+Node: Wc Program713909
+Ref: Wc Program-Footnote-1718164
+Node: Miscellaneous Programs718258
+Node: Dupword Program719471
+Node: Alarm Program721501
+Node: Translate Program726356
+Ref: Translate Program-Footnote-1730921
+Node: Labels Program731191
+Ref: Labels Program-Footnote-1734542
+Node: Word Sorting734626
+Node: History Sorting738698
+Node: Extract Program740533
+Node: Simple Sed748062
+Node: Igawk Program751136
+Ref: Igawk Program-Footnote-1765467
+Ref: Igawk Program-Footnote-2765669
+Ref: Igawk Program-Footnote-3765791
+Node: Anagram Program765906
+Node: Signature Program768968
+Node: Programs Summary770215
+Node: Programs Exercises771429
+Ref: Programs Exercises-Footnote-1775558
+Node: Advanced Features775649
+Node: Nondecimal Data777639
+Node: Array Sorting779230
+Node: Controlling Array Traversal779930
+Ref: Controlling Array Traversal-Footnote-1788297
+Node: Array Sorting Functions788415
+Ref: Array Sorting Functions-Footnote-1793506
+Node: Two-way I/O793702
+Ref: Two-way I/O-Footnote-1799522
+Ref: Two-way I/O-Footnote-2799709
+Node: TCP/IP Networking799791
+Node: Profiling802909
+Node: Advanced Features Summary810448
+Node: Internationalization812384
+Node: I18N and L10N813864
+Node: Explaining gettext814551
+Ref: Explaining gettext-Footnote-1819574
+Ref: Explaining gettext-Footnote-2819759
+Node: Programmer i18n819924
+Ref: Programmer i18n-Footnote-1824779
+Node: Translator i18n824828
+Node: String Extraction825622
+Ref: String Extraction-Footnote-1826754
+Node: Printf Ordering826840
+Ref: Printf Ordering-Footnote-1829626
+Node: I18N Portability829690
+Ref: I18N Portability-Footnote-1832146
+Node: I18N Example832209
+Ref: I18N Example-Footnote-1835015
+Node: Gawk I18N835088
+Node: I18N Summary835733
+Node: Debugger837074
+Node: Debugging838096
+Node: Debugging Concepts838537
+Node: Debugging Terms840346
+Node: Awk Debugging842921
+Node: Sample Debugging Session843827
+Node: Debugger Invocation844361
+Node: Finding The Bug845747
+Node: List of Debugger Commands852225
+Node: Breakpoint Control853558
+Node: Debugger Execution Control857252
+Node: Viewing And Changing Data860614
+Node: Execution Stack863988
+Node: Debugger Info865625
+Node: Miscellaneous Debugger Commands869696
+Node: Readline Support874784
+Node: Limitations875680
+Node: Debugging Summary877789
+Node: Arbitrary Precision Arithmetic878962
+Node: Computer Arithmetic880378
+Ref: table-numeric-ranges883969
+Ref: Computer Arithmetic-Footnote-1884691
+Node: Math Definitions884748
+Ref: table-ieee-formats888062
+Ref: Math Definitions-Footnote-1888665
+Node: MPFR features888770
+Node: FP Math Caution890487
+Ref: FP Math Caution-Footnote-1891559
+Node: Inexactness of computations891928
+Node: Inexact representation892888
+Node: Comparing FP Values894248
+Node: Errors accumulate895330
+Node: Getting Accuracy896763
+Node: Try To Round899473
+Node: Setting precision900372
+Ref: table-predefined-precision-strings901069
+Node: Setting the rounding mode902899
+Ref: table-gawk-rounding-modes903273
+Ref: Setting the rounding mode-Footnote-1906681
+Node: Arbitrary Precision Integers906860
+Ref: Arbitrary Precision Integers-Footnote-1909844
+Node: POSIX Floating Point Problems909993
+Ref: POSIX Floating Point Problems-Footnote-1913875
+Node: Floating point summary913913
+Node: Dynamic Extensions916103
+Node: Extension Intro917656
+Node: Plugin License918922
+Node: Extension Mechanism Outline919719
+Ref: figure-load-extension920158
+Ref: figure-register-new-function921723
+Ref: figure-call-new-function922815
+Node: Extension API Description924877
+Node: Extension API Functions Introduction926325
+Node: General Data Types931137
+Ref: General Data Types-Footnote-1937092
+Node: Memory Allocation Functions937391
+Ref: Memory Allocation Functions-Footnote-1940236
+Node: Constructor Functions940335
+Node: Registration Functions942080
+Node: Extension Functions942765
+Node: Exit Callback Functions945064
+Node: Extension Version String946314
+Node: Input Parsers946977
+Node: Output Wrappers956862
+Node: Two-way processors961374
+Node: Printing Messages963638
+Ref: Printing Messages-Footnote-1964712
+Node: Updating ERRNO964865
+Node: Requesting Values965604
+Ref: table-value-types-returned966341
+Node: Accessing Parameters967224
+Node: Symbol Table Access968459
+Node: Symbol table by name968971
+Node: Symbol table by cookie970992
+Ref: Symbol table by cookie-Footnote-1975141
+Node: Cached values975205
+Ref: Cached values-Footnote-1978706
+Node: Array Manipulation978797
+Ref: Array Manipulation-Footnote-1979896
+Node: Array Data Types979933
+Ref: Array Data Types-Footnote-1982591
+Node: Array Functions982683
+Node: Flattening Arrays986541
+Node: Creating Arrays993449
+Node: Extension API Variables998220
+Node: Extension Versioning998856
+Node: Extension API Informational Variables1000747
+Node: Extension API Boilerplate1001811
+Node: Finding Extensions1005625
+Node: Extension Example1006184
+Node: Internal File Description1006982
+Node: Internal File Ops1011062
+Ref: Internal File Ops-Footnote-11022824
+Node: Using Internal File Ops1022964
+Ref: Using Internal File Ops-Footnote-11025347
+Node: Extension Samples1025621
+Node: Extension Sample File Functions1027150
+Node: Extension Sample Fnmatch1034799
+Node: Extension Sample Fork1036286
+Node: Extension Sample Inplace1037504
+Node: Extension Sample Ord1040714
+Node: Extension Sample Readdir1041550
+Ref: table-readdir-file-types1042439
+Node: Extension Sample Revout1043244
+Node: Extension Sample Rev2way1043833
+Node: Extension Sample Read write array1044573
+Node: Extension Sample Readfile1046515
+Node: Extension Sample Time1047610
+Node: Extension Sample API Tests1048958
+Node: gawkextlib1049450
+Node: Extension summary1051874
+Node: Extension Exercises1055566
+Node: Language History1057063
+Node: V7/SVR3.11058719
+Node: SVR41060871
+Node: POSIX1062305
+Node: BTL1063684
+Node: POSIX/GNU1064413
+Node: Feature History1069934
+Node: Common Extensions1083263
+Node: Ranges and Locales1084546
+Ref: Ranges and Locales-Footnote-11089162
+Ref: Ranges and Locales-Footnote-21089189
+Ref: Ranges and Locales-Footnote-31089424
+Node: Contributors1089645
+Node: History summary1095214
+Node: Installation1096594
+Node: Gawk Distribution1097538
+Node: Getting1098022
+Node: Extracting1098983
+Node: Distribution contents1100621
+Node: Unix Installation1106372
+Node: Quick Installation1106988
+Node: Additional Configuration Options1109415
+Node: Configuration Philosophy1111219
+Node: Non-Unix Installation1113588
+Node: PC Installation1114046
+Node: PC Binary Installation1115366
+Node: PC Compiling1117218
+Ref: PC Compiling-Footnote-11120242
+Node: PC Testing1120351
+Node: PC Using1121531
+Node: Cygwin1125645
+Node: MSYS1126415
+Node: VMS Installation1126916
+Node: VMS Compilation1127707
+Ref: VMS Compilation-Footnote-11128936
+Node: VMS Dynamic Extensions1128994
+Node: VMS Installation Details1130679
+Node: VMS Running1132932
+Node: VMS GNV1137211
+Node: VMS Old Gawk1137946
+Node: Bugs1138417
+Node: Other Versions1142614
+Node: Installation summary1149198
+Node: Notes1150256
+Node: Compatibility Mode1151121
+Node: Additions1151903
+Node: Accessing The Source1152828
+Node: Adding Code1154263
+Node: New Ports1160482
+Node: Derived Files1164970
+Ref: Derived Files-Footnote-11170455
+Ref: Derived Files-Footnote-21170490
+Ref: Derived Files-Footnote-31171088
+Node: Future Extensions1171202
+Node: Implementation Limitations1171860
+Node: Extension Design1173043
+Node: Old Extension Problems1174197
+Ref: Old Extension Problems-Footnote-11175715
+Node: Extension New Mechanism Goals1175772
+Ref: Extension New Mechanism Goals-Footnote-11179136
+Node: Extension Other Design Decisions1179325
+Node: Extension Future Growth1181438
+Node: Old Extension Mechanism1182274
+Node: Notes summary1184037
+Node: Basic Concepts1185219
+Node: Basic High Level1185900
+Ref: figure-general-flow1186182
+Ref: figure-process-flow1186867
+Ref: Basic High Level-Footnote-11190168
+Node: Basic Data Typing1190353
+Node: Glossary1193681
+Node: Copying1225627
+Node: GNU Free Documentation License1263166
+Node: Index1288284
 
 End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index ec816c3..3d90cd9 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -21653,6 +21653,36 @@ Because of this, you should not call it from an 
@code{ENDFILE} rule.
 (This isn't necessary anyway, because @command{gawk} goes to the next
 file as soon as an @code{ENDFILE} rule finishes!)
 
+You need to be careful calling @code{rewind()}.  You can end up
+causing infinite recursion if you don't pay attenion. Here is an
+example use:
+
address@hidden
+$ @kbd{cat data}
address@hidden a
address@hidden b
address@hidden c
address@hidden d
address@hidden e
+
+$ cat @kbd{test.awk}
address@hidden FNR == 3 && ! rewound @{
address@hidden  rewound = 1
address@hidden  rewind()
address@hidden @}
address@hidden 
address@hidden @{ print FILENAME, FNR, $0 @}
+
+$ @kbd{gawk -f rewind.awk -f test.awk data }
address@hidden data 1 a
address@hidden data 2 b
address@hidden data 1 a
address@hidden data 2 b
address@hidden data 3 c
address@hidden data 4 d
address@hidden data 5 e
address@hidden example
+
 @node File Checking
 @subsection Checking for Readable @value{DDF}s
 
@@ -23349,7 +23379,7 @@ BEGIN @{
                        " for delimiter\n", Optarg) > "/dev/stderr"
                 Optarg = substr(Optarg, 1, 1)
             @}
-            FS = Optarg
+            fs = FS = Optarg
             OFS = FS
             if (FS == " ")    # defeat awk semantics
                 FS = "[ ]"
@@ -23371,7 +23401,12 @@ special care when the field delimiter is a space.  
Using
 a single space (@address@hidden" "}}) for the value of @code{FS} is
 address@hidden would separate fields with runs of spaces,
 TABs, and/or newlines, and we want them to be separated with individual
-spaces.  Also remember that after @code{getopt()} is through
+spaces.
+To this end, we save the original space character in the variable
address@hidden for later use; after setting @code{FS} to @code{"[ ]"} we can't
+use it directly to see if the field delimiter character is in the string.
+
+Also remember that after @code{getopt()} is through
 (as described in @ref{Getopt Function}),
 we have to
 clear out all the elements of @code{ARGV} from 1 to @code{Optind},
@@ -23522,8 +23557,8 @@ written out between the fields:
 
 @example
 @c file eg/prog/cut.awk
address@hidden
-    if (by_fields && suppress && index($0, FS) == 0)
+{
+    if (by_fields && suppress && index($0, fs) == 0)
         next
 
     for (i = 1; i <= nfields; i++) @{
@@ -24588,7 +24623,7 @@ BEGIN @{
     if (! do_lines && ! do_words && ! do_chars)
         do_lines = do_words = do_chars = 1
 
-    print_total = (ARGC - i > 2)
+    print_total = (ARGC - i > 1)
 @}
 @c endfile
 @end example
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 678fac3..5f60af3 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -20744,6 +20744,36 @@ Because of this, you should not call it from an 
@code{ENDFILE} rule.
 (This isn't necessary anyway, because @command{gawk} goes to the next
 file as soon as an @code{ENDFILE} rule finishes!)
 
+You need to be careful calling @code{rewind()}.  You can end up
+causing infinite recursion if you don't pay attenion. Here is an
+example use:
+
address@hidden
+$ @kbd{cat data}
address@hidden a
address@hidden b
address@hidden c
address@hidden d
address@hidden e
+
+$ cat @kbd{test.awk}
address@hidden FNR == 3 && ! rewound @{
address@hidden  rewound = 1
address@hidden  rewind()
address@hidden @}
address@hidden 
address@hidden @{ print FILENAME, FNR, $0 @}
+
+$ @kbd{gawk -f rewind.awk -f test.awk data }
address@hidden data 1 a
address@hidden data 2 b
address@hidden data 1 a
address@hidden data 2 b
address@hidden data 3 c
address@hidden data 4 d
address@hidden data 5 e
address@hidden example
+
 @node File Checking
 @subsection Checking for Readable @value{DDF}s
 
@@ -22440,7 +22470,7 @@ BEGIN @{
                        " for delimiter\n", Optarg) > "/dev/stderr"
                 Optarg = substr(Optarg, 1, 1)
             @}
-            FS = Optarg
+            fs = FS = Optarg
             OFS = FS
             if (FS == " ")    # defeat awk semantics
                 FS = "[ ]"
@@ -22462,7 +22492,12 @@ special care when the field delimiter is a space.  
Using
 a single space (@address@hidden" "}}) for the value of @code{FS} is
 address@hidden would separate fields with runs of spaces,
 TABs, and/or newlines, and we want them to be separated with individual
-spaces.  Also remember that after @code{getopt()} is through
+spaces.
+To this end, we save the original space character in the variable
address@hidden for later use; after setting @code{FS} to @code{"[ ]"} we can't
+use it directly to see if the field delimiter character is in the string.
+
+Also remember that after @code{getopt()} is through
 (as described in @ref{Getopt Function}),
 we have to
 clear out all the elements of @code{ARGV} from 1 to @code{Optind},
@@ -22613,8 +22648,8 @@ written out between the fields:
 
 @example
 @c file eg/prog/cut.awk
address@hidden
-    if (by_fields && suppress && index($0, FS) == 0)
+{
+    if (by_fields && suppress && index($0, fs) == 0)
         next
 
     for (i = 1; i <= nfields; i++) @{
@@ -23679,7 +23714,7 @@ BEGIN @{
     if (! do_lines && ! do_words && ! do_chars)
         do_lines = do_words = do_chars = 1
 
-    print_total = (ARGC - i > 2)
+    print_total = (ARGC - i > 1)
 @}
 @c endfile
 @end example

-----------------------------------------------------------------------

Summary of changes:
 awklib/eg/prog/cut.awk |    4 +-
 awklib/eg/prog/wc.awk  |    2 +-
 doc/ChangeLog          |    6 +
 doc/gawk.info          |  575 +++++++++++++++++++++++++-----------------------
 doc/gawk.texi          |   45 ++++-
 doc/gawktexi.in        |   45 ++++-
 6 files changed, 392 insertions(+), 285 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]