summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2015-02-01 14:32:51 -0500
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2015-02-01 14:32:51 -0500
commit2473b938036dfdd32ff47833ea032a80a6fa5659 (patch)
treef5a61f6446c8ed4a3c30e51c0cf2c26b48d39cb8
parenta3eb4b0a735b4fbd60ed66154befd31c56b601db (diff)
parent545cc9691e3d6479053684815d23e6553a7d0a95 (diff)
downloadgawk-2473b938036dfdd32ff47833ea032a80a6fa5659.tar.gz
Merge branch 'master' into select
-rw-r--r--ChangeLog13
-rw-r--r--NEWS2
-rw-r--r--awkgram.c2
-rw-r--r--awkgram.y2
-rw-r--r--doc/ChangeLog6
-rw-r--r--doc/gawk.info631
-rw-r--r--doc/gawk.texi12
-rw-r--r--doc/gawktexi.in12
-rw-r--r--symbol.c36
-rw-r--r--test/ChangeLog7
-rw-r--r--test/Makefile.am9
-rw-r--r--test/Makefile.in20
-rw-r--r--test/Maketests10
-rw-r--r--test/indirectcall.awk8
14 files changed, 405 insertions, 365 deletions
diff --git a/ChangeLog b/ChangeLog
index e5897b52..4b280367 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2015-02-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ Move POSIX requirement for disallowing paramater names with the
+ same name as a function into --posix.
+
+ * NEWS: Document it.
+ * awkgram.y (parse_program): Check do_posix before calling
+ check_param_names().
+ * symbol.c (check_param_names): Set up a fake node and call
+ in_array() for function parameter names instead of linear
+ searching the function list a second time. Thanks to Andrew
+ Schorr for the motivation.
+
2015-01-30 Arnold D. Robbins <arnold@skeeve.com>
Don't allow function parameter names to be the same as function
diff --git a/NEWS b/NEWS
index bf1ea842..b1c7803c 100644
--- a/NEWS
+++ b/NEWS
@@ -89,7 +89,7 @@ Changes from 4.1.1 to 4.1.2
11. POSIX requires that the names of function parameters not be the
same as any of the special built-in variables and also not conflict
with the names of any functions. Gawk has checked for the former
- since 3.1.7. It now also checks for the latter.
+ since 3.1.7. With --posix, it now also checks for the latter.
XX. A number of bugs have been fixed. See the ChangeLog.
diff --git a/awkgram.c b/awkgram.c
index 7a184ed5..80ef5b1c 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -4755,7 +4755,7 @@ parse_program(INSTRUCTION **pcode)
if (ret == 0) /* avoid spurious warning if parser aborted with YYABORT */
check_funcs();
- if (! check_param_names())
+ if (do_posix && ! check_param_names())
errcount++;
if (args_array == NULL)
diff --git a/awkgram.y b/awkgram.y
index 03d91b74..a6ae5269 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2417,7 +2417,7 @@ parse_program(INSTRUCTION **pcode)
if (ret == 0) /* avoid spurious warning if parser aborted with YYABORT */
check_funcs();
- if (! check_param_names())
+ if (do_posix && ! check_param_names())
errcount++;
if (args_array == NULL)
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 19948706..9b7d31db 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: POSIX requirement that function parameters cannot
+ have the same name as a function is now --posix.
+ Restore indirectcall example.
+
2015-01-30 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in: Document POSIX requirement that function parameters
diff --git a/doc/gawk.info b/doc/gawk.info
index e399353b..15f5d978 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -13542,8 +13542,11 @@ have a parameter with the same name as the function itself.
CAUTION: According to the POSIX standard, function parameters
cannot have the same name as one of the special predefined
variables (*note Built-in Variables::), nor may a function
- parameter have the same name as another function. Not all
- versions of `awk' enforce these restrictions.
+ parameter have the same name as another function.
+
+ Not all versions of `awk' enforce these restrictions. `gawk'
+ always enforces the first restriction. With `--posix' (*note
+ Options::), it also enforces the second restriction.
Local variables act like the empty string if referenced where a
string value is required, and like zero if referenced where a numeric
@@ -14145,13 +14148,13 @@ using indirect function calls:
# average --- return the average of the values in fields $first - $last
- function average(first, last, the_sum, i)
+ function average(first, last, sum, i)
{
- the_sum = 0;
+ sum = 0;
for (i = first; i <= last; i++)
- the_sum += $i
+ sum += $i
- return the_sum / (last - first + 1)
+ return sum / (last - first + 1)
}
# sum --- return the sum of the values in fields $first - $last
@@ -32420,7 +32423,7 @@ Index
* common extensions, \x escape sequence: Escape Sequences. (line 61)
* common extensions, BINMODE variable: PC Using. (line 33)
* common extensions, delete to delete entire arrays: Delete. (line 39)
-* common extensions, func keyword: Definition Syntax. (line 95)
+* common extensions, func keyword: Definition Syntax. (line 98)
* common extensions, length() applied to an array: String Functions.
(line 201)
* common extensions, RS as a regexp: gawk split records. (line 6)
@@ -32944,7 +32947,7 @@ Index
* extensions, common, BINMODE variable: PC Using. (line 33)
* extensions, common, delete to delete entire arrays: Delete. (line 39)
* extensions, common, fflush() function: I/O Functions. (line 43)
-* extensions, common, func keyword: Definition Syntax. (line 95)
+* extensions, common, func keyword: Definition Syntax. (line 98)
* extensions, common, length() applied to an array: String Functions.
(line 201)
* extensions, common, RS as a regexp: gawk split records. (line 6)
@@ -33161,7 +33164,7 @@ Index
* functions, library, user database, reading: Passwd Functions.
(line 6)
* functions, names of: Definition Syntax. (line 23)
-* functions, recursive: Definition Syntax. (line 85)
+* functions, recursive: Definition Syntax. (line 88)
* functions, string-translation: I18N Functions. (line 6)
* functions, undefined: Pass By Value/Reference.
(line 68)
@@ -33888,7 +33891,7 @@ Index
(line 65)
* portability, deleting array elements: Delete. (line 56)
* portability, example programs: Library Functions. (line 42)
-* portability, functions, defining: Definition Syntax. (line 111)
+* portability, functions, defining: Definition Syntax. (line 114)
* portability, gawk: New Ports. (line 6)
* portability, gettext library and: Explaining gettext. (line 11)
* portability, internationalization and: I18N Portability. (line 6)
@@ -33933,7 +33936,7 @@ Index
* POSIX awk, field separators and <1>: Full Line Fields. (line 16)
* POSIX awk, field separators and: Fields. (line 6)
* POSIX awk, FS variable and: User-modified. (line 60)
-* POSIX awk, function keyword in: Definition Syntax. (line 95)
+* POSIX awk, function keyword in: Definition Syntax. (line 98)
* POSIX awk, functions and, gsub()/sub(): Gory Details. (line 90)
* POSIX awk, functions and, length(): String Functions. (line 180)
* POSIX awk, GNU long options and: Options. (line 15)
@@ -34026,7 +34029,7 @@ Index
* programming conventions, functions, calling: Calling Built-in.
(line 10)
* programming conventions, functions, writing: Definition Syntax.
- (line 67)
+ (line 70)
* programming conventions, gawk extensions: Internal File Ops.
(line 45)
* programming conventions, private variable names: Library Names.
@@ -34095,7 +34098,7 @@ Index
* records, splitting input into: Records. (line 6)
* records, terminating: awk split records. (line 125)
* records, treating files as: gawk split records. (line 93)
-* recursive functions: Definition Syntax. (line 85)
+* recursive functions: Definition Syntax. (line 88)
* redirect gawk output, in debugger: Debugger Info. (line 72)
* redirection of input: Getline/File. (line 6)
* redirection of output: Redirection. (line 6)
@@ -34265,7 +34268,7 @@ Index
* set directory of message catalogs: I18N Functions. (line 12)
* set watchpoint: Viewing And Changing Data.
(line 67)
-* shadowing of variable values: Definition Syntax. (line 73)
+* shadowing of variable values: Definition Syntax. (line 76)
* shell quoting, rules for: Quoting. (line 6)
* shells, piping commands into: Redirection. (line 136)
* shells, quoting: Using Shell Variables.
@@ -34639,7 +34642,7 @@ Index
* variables, predefined conveying information: Auto-set. (line 6)
* variables, private: Library Names. (line 11)
* variables, setting: Options. (line 32)
-* variables, shadowing: Definition Syntax. (line 73)
+* variables, shadowing: Definition Syntax. (line 76)
* variables, types of: Assignment Ops. (line 40)
* variables, types of, comparison expressions and: Typing and Comparison.
(line 9)
@@ -34997,304 +35000,304 @@ Node: Type Functions566713
Node: I18N Functions567864
Node: User-defined569509
Node: Definition Syntax570314
-Ref: Definition Syntax-Footnote-1575813
-Node: Function Example575884
-Ref: Function Example-Footnote-1578803
-Node: Function Caveats578825
-Node: Calling A Function579343
-Node: Variable Scope580301
-Node: Pass By Value/Reference583289
-Node: Return Statement586784
-Node: Dynamic Typing589765
-Node: Indirect Calls590694
-Ref: Indirect Calls-Footnote-1602012
-Node: Functions Summary602140
-Node: Library Functions604842
-Ref: Library Functions-Footnote-1608451
-Ref: Library Functions-Footnote-2608594
-Node: Library Names608765
-Ref: Library Names-Footnote-1612219
-Ref: Library Names-Footnote-2612442
-Node: General Functions612528
-Node: Strtonum Function613631
-Node: Assert Function616653
-Node: Round Function619977
-Node: Cliff Random Function621518
-Node: Ordinal Functions622534
-Ref: Ordinal Functions-Footnote-1625597
-Ref: Ordinal Functions-Footnote-2625849
-Node: Join Function626060
-Ref: Join Function-Footnote-1627829
-Node: Getlocaltime Function628029
-Node: Readfile Function631773
-Node: Shell Quoting633743
-Node: Data File Management635144
-Node: Filetrans Function635776
-Node: Rewind Function639832
-Node: File Checking641219
-Ref: File Checking-Footnote-1642551
-Node: Empty Files642752
-Node: Ignoring Assigns644731
-Node: Getopt Function646282
-Ref: Getopt Function-Footnote-1657744
-Node: Passwd Functions657944
-Ref: Passwd Functions-Footnote-1666781
-Node: Group Functions666869
-Ref: Group Functions-Footnote-1674763
-Node: Walking Arrays674976
-Node: Library Functions Summary676579
-Node: Library Exercises677980
-Node: Sample Programs679260
-Node: Running Examples680030
-Node: Clones680758
-Node: Cut Program681982
-Node: Egrep Program691701
-Ref: Egrep Program-Footnote-1699199
-Node: Id Program699309
-Node: Split Program702954
-Ref: Split Program-Footnote-1706402
-Node: Tee Program706530
-Node: Uniq Program709319
-Node: Wc Program716738
-Ref: Wc Program-Footnote-1720988
-Node: Miscellaneous Programs721082
-Node: Dupword Program722295
-Node: Alarm Program724326
-Node: Translate Program729130
-Ref: Translate Program-Footnote-1733695
-Node: Labels Program733965
-Ref: Labels Program-Footnote-1737316
-Node: Word Sorting737400
-Node: History Sorting741471
-Node: Extract Program743307
-Node: Simple Sed750832
-Node: Igawk Program753900
-Ref: Igawk Program-Footnote-1768224
-Ref: Igawk Program-Footnote-2768425
-Ref: Igawk Program-Footnote-3768547
-Node: Anagram Program768662
-Node: Signature Program771719
-Node: Programs Summary772966
-Node: Programs Exercises774159
-Ref: Programs Exercises-Footnote-1778290
-Node: Advanced Features778381
-Node: Nondecimal Data780329
-Node: Array Sorting781919
-Node: Controlling Array Traversal782616
-Ref: Controlling Array Traversal-Footnote-1790949
-Node: Array Sorting Functions791067
-Ref: Array Sorting Functions-Footnote-1794956
-Node: Two-way I/O795152
-Ref: Two-way I/O-Footnote-1800097
-Ref: Two-way I/O-Footnote-2800283
-Node: TCP/IP Networking800365
-Node: Profiling803238
-Node: Advanced Features Summary811515
-Node: Internationalization813448
-Node: I18N and L10N814928
-Node: Explaining gettext815614
-Ref: Explaining gettext-Footnote-1820639
-Ref: Explaining gettext-Footnote-2820823
-Node: Programmer i18n820988
-Ref: Programmer i18n-Footnote-1825854
-Node: Translator i18n825903
-Node: String Extraction826697
-Ref: String Extraction-Footnote-1827828
-Node: Printf Ordering827914
-Ref: Printf Ordering-Footnote-1830700
-Node: I18N Portability830764
-Ref: I18N Portability-Footnote-1833219
-Node: I18N Example833282
-Ref: I18N Example-Footnote-1836085
-Node: Gawk I18N836157
-Node: I18N Summary836795
-Node: Debugger838134
-Node: Debugging839156
-Node: Debugging Concepts839597
-Node: Debugging Terms841450
-Node: Awk Debugging844022
-Node: Sample Debugging Session844916
-Node: Debugger Invocation845436
-Node: Finding The Bug846820
-Node: List of Debugger Commands853295
-Node: Breakpoint Control854628
-Node: Debugger Execution Control858324
-Node: Viewing And Changing Data861688
-Node: Execution Stack865066
-Node: Debugger Info866703
-Node: Miscellaneous Debugger Commands870720
-Node: Readline Support875749
-Node: Limitations876641
-Node: Debugging Summary878755
-Node: Arbitrary Precision Arithmetic879923
-Node: Computer Arithmetic881339
-Ref: table-numeric-ranges884937
-Ref: Computer Arithmetic-Footnote-1885796
-Node: Math Definitions885853
-Ref: table-ieee-formats889141
-Ref: Math Definitions-Footnote-1889745
-Node: MPFR features889850
-Node: FP Math Caution891521
-Ref: FP Math Caution-Footnote-1892571
-Node: Inexactness of computations892940
-Node: Inexact representation893899
-Node: Comparing FP Values895256
-Node: Errors accumulate896338
-Node: Getting Accuracy897771
-Node: Try To Round900433
-Node: Setting precision901332
-Ref: table-predefined-precision-strings902016
-Node: Setting the rounding mode903805
-Ref: table-gawk-rounding-modes904169
-Ref: Setting the rounding mode-Footnote-1907624
-Node: Arbitrary Precision Integers907803
-Ref: Arbitrary Precision Integers-Footnote-1912703
-Node: POSIX Floating Point Problems912852
-Ref: POSIX Floating Point Problems-Footnote-1916725
-Node: Floating point summary916763
-Node: Dynamic Extensions918957
-Node: Extension Intro920509
-Node: Plugin License921775
-Node: Extension Mechanism Outline922572
-Ref: figure-load-extension923000
-Ref: figure-register-new-function924480
-Ref: figure-call-new-function925484
-Node: Extension API Description927470
-Node: Extension API Functions Introduction929004
-Node: General Data Types933876
-Ref: General Data Types-Footnote-1939615
-Node: Memory Allocation Functions939914
-Ref: Memory Allocation Functions-Footnote-1942753
-Node: Constructor Functions942849
-Node: Registration Functions944583
-Node: Extension Functions945268
-Node: Exit Callback Functions947565
-Node: Extension Version String948813
-Node: Input Parsers949478
-Node: Output Wrappers959357
-Node: Two-way processors963872
-Node: Printing Messages966076
-Ref: Printing Messages-Footnote-1967152
-Node: Updating `ERRNO'967304
-Node: Requesting Values968044
-Ref: table-value-types-returned968772
-Node: Accessing Parameters969729
-Node: Symbol Table Access970960
-Node: Symbol table by name971474
-Node: Symbol table by cookie973455
-Ref: Symbol table by cookie-Footnote-1977599
-Node: Cached values977662
-Ref: Cached values-Footnote-1981161
-Node: Array Manipulation981252
-Ref: Array Manipulation-Footnote-1982342
-Node: Array Data Types982379
-Ref: Array Data Types-Footnote-1985034
-Node: Array Functions985126
-Node: Flattening Arrays988980
-Node: Creating Arrays995872
-Node: Redirection API1000643
-Node: Extension API Variables1003414
-Node: Extension Versioning1004047
-Node: Extension API Informational Variables1005948
-Node: Extension API Boilerplate1007013
-Node: Finding Extensions1010822
-Node: Extension Example1011382
-Node: Internal File Description1012154
-Node: Internal File Ops1016221
-Ref: Internal File Ops-Footnote-11027891
-Node: Using Internal File Ops1028031
-Ref: Using Internal File Ops-Footnote-11030414
-Node: Extension Samples1030687
-Node: Extension Sample File Functions1032213
-Node: Extension Sample Fnmatch1039851
-Node: Extension Sample Fork1041342
-Node: Extension Sample Inplace1042557
-Node: Extension Sample Ord1044232
-Node: Extension Sample Readdir1045068
-Ref: table-readdir-file-types1045944
-Node: Extension Sample Revout1046755
-Node: Extension Sample Rev2way1047345
-Node: Extension Sample Read write array1048085
-Node: Extension Sample Readfile1050025
-Node: Extension Sample Time1051120
-Node: Extension Sample API Tests1052469
-Node: gawkextlib1052960
-Node: Extension summary1055618
-Node: Extension Exercises1059307
-Node: Language History1060029
-Node: V7/SVR3.11061685
-Node: SVR41063866
-Node: POSIX1065311
-Node: BTL1066700
-Node: POSIX/GNU1067434
-Node: Feature History1073058
-Node: Common Extensions1086156
-Node: Ranges and Locales1087480
-Ref: Ranges and Locales-Footnote-11092098
-Ref: Ranges and Locales-Footnote-21092125
-Ref: Ranges and Locales-Footnote-31092359
-Node: Contributors1092580
-Node: History summary1098121
-Node: Installation1099491
-Node: Gawk Distribution1100437
-Node: Getting1100921
-Node: Extracting1101744
-Node: Distribution contents1103379
-Node: Unix Installation1109444
-Node: Quick Installation1110127
-Node: Shell Startup Files1112538
-Node: Additional Configuration Options1113617
-Node: Configuration Philosophy1115356
-Node: Non-Unix Installation1117725
-Node: PC Installation1118183
-Node: PC Binary Installation1119502
-Node: PC Compiling1121350
-Ref: PC Compiling-Footnote-11124371
-Node: PC Testing1124480
-Node: PC Using1125656
-Node: Cygwin1129771
-Node: MSYS1130594
-Node: VMS Installation1131094
-Node: VMS Compilation1131886
-Ref: VMS Compilation-Footnote-11133108
-Node: VMS Dynamic Extensions1133166
-Node: VMS Installation Details1134850
-Node: VMS Running1137102
-Node: VMS GNV1139938
-Node: VMS Old Gawk1140672
-Node: Bugs1141142
-Node: Other Versions1145025
-Node: Installation summary1151449
-Node: Notes1152505
-Node: Compatibility Mode1153370
-Node: Additions1154152
-Node: Accessing The Source1155077
-Node: Adding Code1156512
-Node: New Ports1162669
-Node: Derived Files1167151
-Ref: Derived Files-Footnote-11172626
-Ref: Derived Files-Footnote-21172660
-Ref: Derived Files-Footnote-31173256
-Node: Future Extensions1173370
-Node: Implementation Limitations1173976
-Node: Extension Design1175224
-Node: Old Extension Problems1176378
-Ref: Old Extension Problems-Footnote-11177895
-Node: Extension New Mechanism Goals1177952
-Ref: Extension New Mechanism Goals-Footnote-11181312
-Node: Extension Other Design Decisions1181501
-Node: Extension Future Growth1183609
-Node: Old Extension Mechanism1184445
-Node: Notes summary1186207
-Node: Basic Concepts1187393
-Node: Basic High Level1188074
-Ref: figure-general-flow1188346
-Ref: figure-process-flow1188945
-Ref: Basic High Level-Footnote-11192174
-Node: Basic Data Typing1192359
-Node: Glossary1195687
-Node: Copying1227616
-Node: GNU Free Documentation License1265172
-Node: Index1290308
+Ref: Definition Syntax-Footnote-1575946
+Node: Function Example576017
+Ref: Function Example-Footnote-1578936
+Node: Function Caveats578958
+Node: Calling A Function579476
+Node: Variable Scope580434
+Node: Pass By Value/Reference583422
+Node: Return Statement586917
+Node: Dynamic Typing589898
+Node: Indirect Calls590827
+Ref: Indirect Calls-Footnote-1602129
+Node: Functions Summary602257
+Node: Library Functions604959
+Ref: Library Functions-Footnote-1608568
+Ref: Library Functions-Footnote-2608711
+Node: Library Names608882
+Ref: Library Names-Footnote-1612336
+Ref: Library Names-Footnote-2612559
+Node: General Functions612645
+Node: Strtonum Function613748
+Node: Assert Function616770
+Node: Round Function620094
+Node: Cliff Random Function621635
+Node: Ordinal Functions622651
+Ref: Ordinal Functions-Footnote-1625714
+Ref: Ordinal Functions-Footnote-2625966
+Node: Join Function626177
+Ref: Join Function-Footnote-1627946
+Node: Getlocaltime Function628146
+Node: Readfile Function631890
+Node: Shell Quoting633860
+Node: Data File Management635261
+Node: Filetrans Function635893
+Node: Rewind Function639949
+Node: File Checking641336
+Ref: File Checking-Footnote-1642668
+Node: Empty Files642869
+Node: Ignoring Assigns644848
+Node: Getopt Function646399
+Ref: Getopt Function-Footnote-1657861
+Node: Passwd Functions658061
+Ref: Passwd Functions-Footnote-1666898
+Node: Group Functions666986
+Ref: Group Functions-Footnote-1674880
+Node: Walking Arrays675093
+Node: Library Functions Summary676696
+Node: Library Exercises678097
+Node: Sample Programs679377
+Node: Running Examples680147
+Node: Clones680875
+Node: Cut Program682099
+Node: Egrep Program691818
+Ref: Egrep Program-Footnote-1699316
+Node: Id Program699426
+Node: Split Program703071
+Ref: Split Program-Footnote-1706519
+Node: Tee Program706647
+Node: Uniq Program709436
+Node: Wc Program716855
+Ref: Wc Program-Footnote-1721105
+Node: Miscellaneous Programs721199
+Node: Dupword Program722412
+Node: Alarm Program724443
+Node: Translate Program729247
+Ref: Translate Program-Footnote-1733812
+Node: Labels Program734082
+Ref: Labels Program-Footnote-1737433
+Node: Word Sorting737517
+Node: History Sorting741588
+Node: Extract Program743424
+Node: Simple Sed750949
+Node: Igawk Program754017
+Ref: Igawk Program-Footnote-1768341
+Ref: Igawk Program-Footnote-2768542
+Ref: Igawk Program-Footnote-3768664
+Node: Anagram Program768779
+Node: Signature Program771836
+Node: Programs Summary773083
+Node: Programs Exercises774276
+Ref: Programs Exercises-Footnote-1778407
+Node: Advanced Features778498
+Node: Nondecimal Data780446
+Node: Array Sorting782036
+Node: Controlling Array Traversal782733
+Ref: Controlling Array Traversal-Footnote-1791066
+Node: Array Sorting Functions791184
+Ref: Array Sorting Functions-Footnote-1795073
+Node: Two-way I/O795269
+Ref: Two-way I/O-Footnote-1800214
+Ref: Two-way I/O-Footnote-2800400
+Node: TCP/IP Networking800482
+Node: Profiling803355
+Node: Advanced Features Summary811632
+Node: Internationalization813565
+Node: I18N and L10N815045
+Node: Explaining gettext815731
+Ref: Explaining gettext-Footnote-1820756
+Ref: Explaining gettext-Footnote-2820940
+Node: Programmer i18n821105
+Ref: Programmer i18n-Footnote-1825971
+Node: Translator i18n826020
+Node: String Extraction826814
+Ref: String Extraction-Footnote-1827945
+Node: Printf Ordering828031
+Ref: Printf Ordering-Footnote-1830817
+Node: I18N Portability830881
+Ref: I18N Portability-Footnote-1833336
+Node: I18N Example833399
+Ref: I18N Example-Footnote-1836202
+Node: Gawk I18N836274
+Node: I18N Summary836912
+Node: Debugger838251
+Node: Debugging839273
+Node: Debugging Concepts839714
+Node: Debugging Terms841567
+Node: Awk Debugging844139
+Node: Sample Debugging Session845033
+Node: Debugger Invocation845553
+Node: Finding The Bug846937
+Node: List of Debugger Commands853412
+Node: Breakpoint Control854745
+Node: Debugger Execution Control858441
+Node: Viewing And Changing Data861805
+Node: Execution Stack865183
+Node: Debugger Info866820
+Node: Miscellaneous Debugger Commands870837
+Node: Readline Support875866
+Node: Limitations876758
+Node: Debugging Summary878872
+Node: Arbitrary Precision Arithmetic880040
+Node: Computer Arithmetic881456
+Ref: table-numeric-ranges885054
+Ref: Computer Arithmetic-Footnote-1885913
+Node: Math Definitions885970
+Ref: table-ieee-formats889258
+Ref: Math Definitions-Footnote-1889862
+Node: MPFR features889967
+Node: FP Math Caution891638
+Ref: FP Math Caution-Footnote-1892688
+Node: Inexactness of computations893057
+Node: Inexact representation894016
+Node: Comparing FP Values895373
+Node: Errors accumulate896455
+Node: Getting Accuracy897888
+Node: Try To Round900550
+Node: Setting precision901449
+Ref: table-predefined-precision-strings902133
+Node: Setting the rounding mode903922
+Ref: table-gawk-rounding-modes904286
+Ref: Setting the rounding mode-Footnote-1907741
+Node: Arbitrary Precision Integers907920
+Ref: Arbitrary Precision Integers-Footnote-1912820
+Node: POSIX Floating Point Problems912969
+Ref: POSIX Floating Point Problems-Footnote-1916842
+Node: Floating point summary916880
+Node: Dynamic Extensions919074
+Node: Extension Intro920626
+Node: Plugin License921892
+Node: Extension Mechanism Outline922689
+Ref: figure-load-extension923117
+Ref: figure-register-new-function924597
+Ref: figure-call-new-function925601
+Node: Extension API Description927587
+Node: Extension API Functions Introduction929121
+Node: General Data Types933993
+Ref: General Data Types-Footnote-1939732
+Node: Memory Allocation Functions940031
+Ref: Memory Allocation Functions-Footnote-1942870
+Node: Constructor Functions942966
+Node: Registration Functions944700
+Node: Extension Functions945385
+Node: Exit Callback Functions947682
+Node: Extension Version String948930
+Node: Input Parsers949595
+Node: Output Wrappers959474
+Node: Two-way processors963989
+Node: Printing Messages966193
+Ref: Printing Messages-Footnote-1967269
+Node: Updating `ERRNO'967421
+Node: Requesting Values968161
+Ref: table-value-types-returned968889
+Node: Accessing Parameters969846
+Node: Symbol Table Access971077
+Node: Symbol table by name971591
+Node: Symbol table by cookie973572
+Ref: Symbol table by cookie-Footnote-1977716
+Node: Cached values977779
+Ref: Cached values-Footnote-1981278
+Node: Array Manipulation981369
+Ref: Array Manipulation-Footnote-1982459
+Node: Array Data Types982496
+Ref: Array Data Types-Footnote-1985151
+Node: Array Functions985243
+Node: Flattening Arrays989097
+Node: Creating Arrays995989
+Node: Redirection API1000760
+Node: Extension API Variables1003531
+Node: Extension Versioning1004164
+Node: Extension API Informational Variables1006065
+Node: Extension API Boilerplate1007130
+Node: Finding Extensions1010939
+Node: Extension Example1011499
+Node: Internal File Description1012271
+Node: Internal File Ops1016338
+Ref: Internal File Ops-Footnote-11028008
+Node: Using Internal File Ops1028148
+Ref: Using Internal File Ops-Footnote-11030531
+Node: Extension Samples1030804
+Node: Extension Sample File Functions1032330
+Node: Extension Sample Fnmatch1039968
+Node: Extension Sample Fork1041459
+Node: Extension Sample Inplace1042674
+Node: Extension Sample Ord1044349
+Node: Extension Sample Readdir1045185
+Ref: table-readdir-file-types1046061
+Node: Extension Sample Revout1046872
+Node: Extension Sample Rev2way1047462
+Node: Extension Sample Read write array1048202
+Node: Extension Sample Readfile1050142
+Node: Extension Sample Time1051237
+Node: Extension Sample API Tests1052586
+Node: gawkextlib1053077
+Node: Extension summary1055735
+Node: Extension Exercises1059424
+Node: Language History1060146
+Node: V7/SVR3.11061802
+Node: SVR41063983
+Node: POSIX1065428
+Node: BTL1066817
+Node: POSIX/GNU1067551
+Node: Feature History1073175
+Node: Common Extensions1086273
+Node: Ranges and Locales1087597
+Ref: Ranges and Locales-Footnote-11092215
+Ref: Ranges and Locales-Footnote-21092242
+Ref: Ranges and Locales-Footnote-31092476
+Node: Contributors1092697
+Node: History summary1098238
+Node: Installation1099608
+Node: Gawk Distribution1100554
+Node: Getting1101038
+Node: Extracting1101861
+Node: Distribution contents1103496
+Node: Unix Installation1109561
+Node: Quick Installation1110244
+Node: Shell Startup Files1112655
+Node: Additional Configuration Options1113734
+Node: Configuration Philosophy1115473
+Node: Non-Unix Installation1117842
+Node: PC Installation1118300
+Node: PC Binary Installation1119619
+Node: PC Compiling1121467
+Ref: PC Compiling-Footnote-11124488
+Node: PC Testing1124597
+Node: PC Using1125773
+Node: Cygwin1129888
+Node: MSYS1130711
+Node: VMS Installation1131211
+Node: VMS Compilation1132003
+Ref: VMS Compilation-Footnote-11133225
+Node: VMS Dynamic Extensions1133283
+Node: VMS Installation Details1134967
+Node: VMS Running1137219
+Node: VMS GNV1140055
+Node: VMS Old Gawk1140789
+Node: Bugs1141259
+Node: Other Versions1145142
+Node: Installation summary1151566
+Node: Notes1152622
+Node: Compatibility Mode1153487
+Node: Additions1154269
+Node: Accessing The Source1155194
+Node: Adding Code1156629
+Node: New Ports1162786
+Node: Derived Files1167268
+Ref: Derived Files-Footnote-11172743
+Ref: Derived Files-Footnote-21172777
+Ref: Derived Files-Footnote-31173373
+Node: Future Extensions1173487
+Node: Implementation Limitations1174093
+Node: Extension Design1175341
+Node: Old Extension Problems1176495
+Ref: Old Extension Problems-Footnote-11178012
+Node: Extension New Mechanism Goals1178069
+Ref: Extension New Mechanism Goals-Footnote-11181429
+Node: Extension Other Design Decisions1181618
+Node: Extension Future Growth1183726
+Node: Old Extension Mechanism1184562
+Node: Notes summary1186324
+Node: Basic Concepts1187510
+Node: Basic High Level1188191
+Ref: figure-general-flow1188463
+Ref: figure-process-flow1189062
+Ref: Basic High Level-Footnote-11192291
+Node: Basic Data Typing1192476
+Node: Glossary1195804
+Node: Copying1227733
+Node: GNU Free Documentation License1265289
+Node: Index1290425

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 9ad9e3d4..cc215c6a 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -19427,8 +19427,12 @@ According to the POSIX standard, function parameters
cannot have the same name as one of the special predefined variables
(@pxref{Built-in Variables}), nor may a function parameter have the
same name as another function.
+
Not all versions of @command{awk} enforce
these restrictions.
+@command{gawk} always enforces the first restriction.
+With @option{--posix} (@pxref{Options}),
+it also enforces the second restriction.
@end quotation
Local variables act like the empty string if referenced where a string
@@ -20146,13 +20150,13 @@ using indirect function calls:
@c file eg/prog/indirectcall.awk
# average --- return the average of the values in fields $first - $last
-function average(first, last, the_sum, i)
+function average(first, last, sum, i)
@{
- the_sum = 0;
+ sum = 0;
for (i = first; i <= last; i++)
- the_sum += $i
+ sum += $i
- return the_sum / (last - first + 1)
+ return sum / (last - first + 1)
@}
# sum --- return the sum of the values in fields $first - $last
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index e557efae..b7134716 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -18548,8 +18548,12 @@ According to the POSIX standard, function parameters
cannot have the same name as one of the special predefined variables
(@pxref{Built-in Variables}), nor may a function parameter have the
same name as another function.
+
Not all versions of @command{awk} enforce
these restrictions.
+@command{gawk} always enforces the first restriction.
+With @option{--posix} (@pxref{Options}),
+it also enforces the second restriction.
@end quotation
Local variables act like the empty string if referenced where a string
@@ -19267,13 +19271,13 @@ using indirect function calls:
@c file eg/prog/indirectcall.awk
# average --- return the average of the values in fields $first - $last
-function average(first, last, the_sum, i)
+function average(first, last, sum, i)
@{
- the_sum = 0;
+ sum = 0;
for (i = first; i <= last; i++)
- the_sum += $i
+ sum += $i
- return the_sum / (last - first + 1)
+ return sum / (last - first + 1)
@}
# sum --- return the sum of the values in fields $first - $last
diff --git a/symbol.c b/symbol.c
index 552c111e..cbfb1edf 100644
--- a/symbol.c
+++ b/symbol.c
@@ -630,14 +630,23 @@ load_symbols()
bool
check_param_names(void)
{
- int i, j, k;
+ int i, j;
NODE **list;
NODE *f;
long max;
bool result = true;
+ NODE n;
+
+ if (func_table->table_size == 0)
+ return result;
max = func_table->table_size * 2;
+ memset(& n, sizeof n, 0);
+ n.type = Node_val;
+ n.flags = STRING|STRCUR;
+ n.stfmt = -1;
+
/*
* assoc_list() returns an array with two elements per awk array
* element. Elements i and i+1 in the C array represent the key
@@ -650,10 +659,6 @@ check_param_names(void)
list = assoc_list(func_table, "@unsorted", ASORTI);
- /*
- * You want linear searches?
- * Have we got linear searches!
- */
for (i = 0; i < max; i += 2) {
f = list[i+1];
if (f->type == Node_builtin_func || f->param_cnt == 0)
@@ -662,16 +667,17 @@ check_param_names(void)
/* loop over each param in function i */
for (j = 0; j < f->param_cnt; j++) {
/* compare to function names */
- for (k = 0; k < max; k += 2) {
- if (k == i)
- continue;
- if (strcmp(f->fparms[j].param, list[k]->stptr) == 0) {
- error(
- _("function `%s': can't use function `%s' as a parameter name"),
- list[i]->stptr,
- list[k]->stptr);
- result = false;
- }
+
+ /* use a fake node to avoid malloc/free of make_string */
+ n.stptr = f->fparms[j].param;
+ n.stlen = strlen(f->fparms[j].param);
+
+ if (in_array(func_table, & n)) {
+ error(
+ _("function `%s': can't use function `%s' as a parameter name"),
+ list[i]->stptr,
+ f->fparms[j].param);
+ result = false;
}
}
}
diff --git a/test/ChangeLog b/test/ChangeLog
index 2bcbc6ea..4d332e49 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,6 +1,11 @@
+2015-02-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (paramasfunc1, paramasfunc2): Now need --posix.
+ * indirectcall.awk: Restore after code change.
+
2015-01-30 Arnold D. Robbins <arnold@skeeve.com>
- * Makefile.in (callparam, paramasfunc1, paramasfunc2): New tests.
+ * Makefile.am (callparam, paramasfunc1, paramasfunc2): New tests.
* callparam.awk, callparam.ok: New files.
* paramasfunc1.awk, paramasfunc1.ok: New files.
* paramasfunc2.awk, paramasfunc2.ok: New files.
diff --git a/test/Makefile.am b/test/Makefile.am
index d5f9b002..873b0a7c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -2051,6 +2051,15 @@ genpot:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk --gen-pot >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+paramasfunc1::
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --posix >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+paramasfunc2::
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --posix >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
# Targets generated for other tests:
include Maketests
diff --git a/test/Makefile.in b/test/Makefile.in
index b90c3e73..09de6713 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -2486,6 +2486,16 @@ genpot:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk --gen-pot >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+paramasfunc1::
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --posix >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+paramasfunc2::
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --posix >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
Gt-dummy:
# file Maketests, generated from Makefile.am by the Gentests program
addcomma:
@@ -3093,16 +3103,6 @@ opasnslf:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
-paramasfunc1:
- @echo $@
- @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
- @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
-
-paramasfunc2:
- @echo $@
- @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
- @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
-
paramdup:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 5368195b..b25bba42 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -605,16 +605,6 @@ opasnslf:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
-paramasfunc1:
- @echo $@
- @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
- @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
-
-paramasfunc2:
- @echo $@
- @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
- @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
-
paramdup:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/indirectcall.awk b/test/indirectcall.awk
index 74290973..5cfdd235 100644
--- a/test/indirectcall.awk
+++ b/test/indirectcall.awk
@@ -5,13 +5,13 @@
# average --- return the average of the values in fields $first - $last
-function average(first, last, the_sum, i)
+function average(first, last, sum, i)
{
- the_sum = 0;
+ sum = 0;
for (i = first; i <= last; i++)
- the_sum += $i
+ sum += $i
- return the_sum / (last - first + 1)
+ return sum / (last - first + 1)
}
# sum --- return the average of the values in fields $first - $last