summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-02-01 20:53:05 +0200
committerArnold D. Robbins <arnold@skeeve.com>2015-02-01 20:53:05 +0200
commitbcb51623b8e156b03c2ae588906e4ed25fa3eba2 (patch)
treef693983ab1daea9761135dae96be0f515b29f681
parent1bd1b885c7dd16b5e4ab78c040312f6f7d742784 (diff)
downloadgawk-bcb51623b8e156b03c2ae588906e4ed25fa3eba2.tar.gz
Move param checking against function names into --posix.
-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.info627
-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, 403 insertions, 363 deletions
diff --git a/ChangeLog b/ChangeLog
index e5c7c091..6f626cd7 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 21568ea3..ba86e965 100644
--- a/NEWS
+++ b/NEWS
@@ -49,7 +49,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 9a9ca13b..20d3506a 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -4661,7 +4661,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 55615c13..ef7c139a 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2322,7 +2322,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 61caac69..904cd326 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 4e975b14..ca168110 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -13464,8 +13464,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
@@ -14067,13 +14070,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
@@ -32159,7 +32162,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)
@@ -32680,7 +32683,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)
@@ -32897,7 +32900,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)
@@ -33618,7 +33621,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)
@@ -33663,7 +33666,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)
@@ -33756,7 +33759,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.
@@ -33825,7 +33828,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)
@@ -33994,7 +33997,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.
@@ -34368,7 +34371,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)
@@ -34725,302 +34728,302 @@ Node: Type Functions562811
Node: I18N Functions563962
Node: User-defined565607
Node: Definition Syntax566412
-Ref: Definition Syntax-Footnote-1571911
-Node: Function Example571982
-Ref: Function Example-Footnote-1574901
-Node: Function Caveats574923
-Node: Calling A Function575441
-Node: Variable Scope576399
-Node: Pass By Value/Reference579387
-Node: Return Statement582882
-Node: Dynamic Typing585863
-Node: Indirect Calls586792
-Ref: Indirect Calls-Footnote-1598110
-Node: Functions Summary598238
-Node: Library Functions600940
-Ref: Library Functions-Footnote-1604549
-Ref: Library Functions-Footnote-2604692
-Node: Library Names604863
-Ref: Library Names-Footnote-1608317
-Ref: Library Names-Footnote-2608540
-Node: General Functions608626
-Node: Strtonum Function609729
-Node: Assert Function612751
-Node: Round Function616075
-Node: Cliff Random Function617616
-Node: Ordinal Functions618632
-Ref: Ordinal Functions-Footnote-1621695
-Ref: Ordinal Functions-Footnote-2621947
-Node: Join Function622158
-Ref: Join Function-Footnote-1623927
-Node: Getlocaltime Function624127
-Node: Readfile Function627871
-Node: Shell Quoting629841
-Node: Data File Management631242
-Node: Filetrans Function631874
-Node: Rewind Function635930
-Node: File Checking637317
-Ref: File Checking-Footnote-1638649
-Node: Empty Files638850
-Node: Ignoring Assigns640829
-Node: Getopt Function642380
-Ref: Getopt Function-Footnote-1653842
-Node: Passwd Functions654042
-Ref: Passwd Functions-Footnote-1662879
-Node: Group Functions662967
-Ref: Group Functions-Footnote-1670861
-Node: Walking Arrays671074
-Node: Library Functions Summary672677
-Node: Library Exercises674078
-Node: Sample Programs675358
-Node: Running Examples676128
-Node: Clones676856
-Node: Cut Program678080
-Node: Egrep Program687799
-Ref: Egrep Program-Footnote-1695297
-Node: Id Program695407
-Node: Split Program699052
-Ref: Split Program-Footnote-1702500
-Node: Tee Program702628
-Node: Uniq Program705417
-Node: Wc Program712836
-Ref: Wc Program-Footnote-1717086
-Node: Miscellaneous Programs717180
-Node: Dupword Program718393
-Node: Alarm Program720424
-Node: Translate Program725228
-Ref: Translate Program-Footnote-1729793
-Node: Labels Program730063
-Ref: Labels Program-Footnote-1733414
-Node: Word Sorting733498
-Node: History Sorting737569
-Node: Extract Program739405
-Node: Simple Sed746930
-Node: Igawk Program749998
-Ref: Igawk Program-Footnote-1764322
-Ref: Igawk Program-Footnote-2764523
-Ref: Igawk Program-Footnote-3764645
-Node: Anagram Program764760
-Node: Signature Program767817
-Node: Programs Summary769064
-Node: Programs Exercises770257
-Ref: Programs Exercises-Footnote-1774388
-Node: Advanced Features774479
-Node: Nondecimal Data776427
-Node: Array Sorting778017
-Node: Controlling Array Traversal778714
-Ref: Controlling Array Traversal-Footnote-1787047
-Node: Array Sorting Functions787165
-Ref: Array Sorting Functions-Footnote-1791054
-Node: Two-way I/O791250
-Ref: Two-way I/O-Footnote-1796195
-Ref: Two-way I/O-Footnote-2796381
-Node: TCP/IP Networking796463
-Node: Profiling799336
-Node: Advanced Features Summary806883
-Node: Internationalization808816
-Node: I18N and L10N810296
-Node: Explaining gettext810982
-Ref: Explaining gettext-Footnote-1816007
-Ref: Explaining gettext-Footnote-2816191
-Node: Programmer i18n816356
-Ref: Programmer i18n-Footnote-1821222
-Node: Translator i18n821271
-Node: String Extraction822065
-Ref: String Extraction-Footnote-1823196
-Node: Printf Ordering823282
-Ref: Printf Ordering-Footnote-1826068
-Node: I18N Portability826132
-Ref: I18N Portability-Footnote-1828587
-Node: I18N Example828650
-Ref: I18N Example-Footnote-1831453
-Node: Gawk I18N831525
-Node: I18N Summary832163
-Node: Debugger833502
-Node: Debugging834524
-Node: Debugging Concepts834965
-Node: Debugging Terms836818
-Node: Awk Debugging839390
-Node: Sample Debugging Session840284
-Node: Debugger Invocation840804
-Node: Finding The Bug842188
-Node: List of Debugger Commands848663
-Node: Breakpoint Control849996
-Node: Debugger Execution Control853692
-Node: Viewing And Changing Data857056
-Node: Execution Stack860434
-Node: Debugger Info862071
-Node: Miscellaneous Debugger Commands866088
-Node: Readline Support871117
-Node: Limitations872009
-Node: Debugging Summary874123
-Node: Arbitrary Precision Arithmetic875291
-Node: Computer Arithmetic876707
-Ref: table-numeric-ranges880305
-Ref: Computer Arithmetic-Footnote-1881164
-Node: Math Definitions881221
-Ref: table-ieee-formats884509
-Ref: Math Definitions-Footnote-1885113
-Node: MPFR features885218
-Node: FP Math Caution886889
-Ref: FP Math Caution-Footnote-1887939
-Node: Inexactness of computations888308
-Node: Inexact representation889267
-Node: Comparing FP Values890624
-Node: Errors accumulate891706
-Node: Getting Accuracy893139
-Node: Try To Round895801
-Node: Setting precision896700
-Ref: table-predefined-precision-strings897384
-Node: Setting the rounding mode899173
-Ref: table-gawk-rounding-modes899537
-Ref: Setting the rounding mode-Footnote-1902992
-Node: Arbitrary Precision Integers903171
-Ref: Arbitrary Precision Integers-Footnote-1906157
-Node: POSIX Floating Point Problems906306
-Ref: POSIX Floating Point Problems-Footnote-1910179
-Node: Floating point summary910217
-Node: Dynamic Extensions912411
-Node: Extension Intro913963
-Node: Plugin License915229
-Node: Extension Mechanism Outline916026
-Ref: figure-load-extension916454
-Ref: figure-register-new-function917934
-Ref: figure-call-new-function918938
-Node: Extension API Description920924
-Node: Extension API Functions Introduction922374
-Node: General Data Types927198
-Ref: General Data Types-Footnote-1932937
-Node: Memory Allocation Functions933236
-Ref: Memory Allocation Functions-Footnote-1936075
-Node: Constructor Functions936171
-Node: Registration Functions937905
-Node: Extension Functions938590
-Node: Exit Callback Functions940887
-Node: Extension Version String942135
-Node: Input Parsers942800
-Node: Output Wrappers952679
-Node: Two-way processors957194
-Node: Printing Messages959398
-Ref: Printing Messages-Footnote-1960474
-Node: Updating `ERRNO'960626
-Node: Requesting Values961366
-Ref: table-value-types-returned962094
-Node: Accessing Parameters963051
-Node: Symbol Table Access964282
-Node: Symbol table by name964796
-Node: Symbol table by cookie966777
-Ref: Symbol table by cookie-Footnote-1970921
-Node: Cached values970984
-Ref: Cached values-Footnote-1974483
-Node: Array Manipulation974574
-Ref: Array Manipulation-Footnote-1975672
-Node: Array Data Types975709
-Ref: Array Data Types-Footnote-1978364
-Node: Array Functions978456
-Node: Flattening Arrays982310
-Node: Creating Arrays989202
-Node: Extension API Variables993973
-Node: Extension Versioning994609
-Node: Extension API Informational Variables996510
-Node: Extension API Boilerplate997575
-Node: Finding Extensions1001384
-Node: Extension Example1001944
-Node: Internal File Description1002716
-Node: Internal File Ops1006783
-Ref: Internal File Ops-Footnote-11018453
-Node: Using Internal File Ops1018593
-Ref: Using Internal File Ops-Footnote-11020976
-Node: Extension Samples1021249
-Node: Extension Sample File Functions1022775
-Node: Extension Sample Fnmatch1030413
-Node: Extension Sample Fork1031904
-Node: Extension Sample Inplace1033119
-Node: Extension Sample Ord1034794
-Node: Extension Sample Readdir1035630
-Ref: table-readdir-file-types1036506
-Node: Extension Sample Revout1037317
-Node: Extension Sample Rev2way1037907
-Node: Extension Sample Read write array1038647
-Node: Extension Sample Readfile1040587
-Node: Extension Sample Time1041682
-Node: Extension Sample API Tests1043031
-Node: gawkextlib1043522
-Node: Extension summary1046180
-Node: Extension Exercises1049869
-Node: Language History1050591
-Node: V7/SVR3.11052247
-Node: SVR41054428
-Node: POSIX1055873
-Node: BTL1057262
-Node: POSIX/GNU1057996
-Node: Feature History1063560
-Node: Common Extensions1076658
-Node: Ranges and Locales1077982
-Ref: Ranges and Locales-Footnote-11082600
-Ref: Ranges and Locales-Footnote-21082627
-Ref: Ranges and Locales-Footnote-31082861
-Node: Contributors1083082
-Node: History summary1088623
-Node: Installation1089993
-Node: Gawk Distribution1090939
-Node: Getting1091423
-Node: Extracting1092246
-Node: Distribution contents1093881
-Node: Unix Installation1099598
-Node: Quick Installation1100215
-Node: Additional Configuration Options1102639
-Node: Configuration Philosophy1104377
-Node: Non-Unix Installation1106746
-Node: PC Installation1107204
-Node: PC Binary Installation1108523
-Node: PC Compiling1110371
-Ref: PC Compiling-Footnote-11113392
-Node: PC Testing1113501
-Node: PC Using1114677
-Node: Cygwin1118792
-Node: MSYS1119615
-Node: VMS Installation1120115
-Node: VMS Compilation1120907
-Ref: VMS Compilation-Footnote-11122129
-Node: VMS Dynamic Extensions1122187
-Node: VMS Installation Details1123871
-Node: VMS Running1126123
-Node: VMS GNV1128959
-Node: VMS Old Gawk1129693
-Node: Bugs1130163
-Node: Other Versions1134046
-Node: Installation summary1140470
-Node: Notes1141526
-Node: Compatibility Mode1142391
-Node: Additions1143173
-Node: Accessing The Source1144098
-Node: Adding Code1145533
-Node: New Ports1151690
-Node: Derived Files1156172
-Ref: Derived Files-Footnote-11161647
-Ref: Derived Files-Footnote-21161681
-Ref: Derived Files-Footnote-31162277
-Node: Future Extensions1162391
-Node: Implementation Limitations1162997
-Node: Extension Design1164245
-Node: Old Extension Problems1165399
-Ref: Old Extension Problems-Footnote-11166916
-Node: Extension New Mechanism Goals1166973
-Ref: Extension New Mechanism Goals-Footnote-11170333
-Node: Extension Other Design Decisions1170522
-Node: Extension Future Growth1172630
-Node: Old Extension Mechanism1173466
-Node: Notes summary1175228
-Node: Basic Concepts1176414
-Node: Basic High Level1177095
-Ref: figure-general-flow1177367
-Ref: figure-process-flow1177966
-Ref: Basic High Level-Footnote-11181195
-Node: Basic Data Typing1181380
-Node: Glossary1184708
-Node: Copying1216637
-Node: GNU Free Documentation License1254193
-Node: Index1279329
+Ref: Definition Syntax-Footnote-1572044
+Node: Function Example572115
+Ref: Function Example-Footnote-1575034
+Node: Function Caveats575056
+Node: Calling A Function575574
+Node: Variable Scope576532
+Node: Pass By Value/Reference579520
+Node: Return Statement583015
+Node: Dynamic Typing585996
+Node: Indirect Calls586925
+Ref: Indirect Calls-Footnote-1598227
+Node: Functions Summary598355
+Node: Library Functions601057
+Ref: Library Functions-Footnote-1604666
+Ref: Library Functions-Footnote-2604809
+Node: Library Names604980
+Ref: Library Names-Footnote-1608434
+Ref: Library Names-Footnote-2608657
+Node: General Functions608743
+Node: Strtonum Function609846
+Node: Assert Function612868
+Node: Round Function616192
+Node: Cliff Random Function617733
+Node: Ordinal Functions618749
+Ref: Ordinal Functions-Footnote-1621812
+Ref: Ordinal Functions-Footnote-2622064
+Node: Join Function622275
+Ref: Join Function-Footnote-1624044
+Node: Getlocaltime Function624244
+Node: Readfile Function627988
+Node: Shell Quoting629958
+Node: Data File Management631359
+Node: Filetrans Function631991
+Node: Rewind Function636047
+Node: File Checking637434
+Ref: File Checking-Footnote-1638766
+Node: Empty Files638967
+Node: Ignoring Assigns640946
+Node: Getopt Function642497
+Ref: Getopt Function-Footnote-1653959
+Node: Passwd Functions654159
+Ref: Passwd Functions-Footnote-1662996
+Node: Group Functions663084
+Ref: Group Functions-Footnote-1670978
+Node: Walking Arrays671191
+Node: Library Functions Summary672794
+Node: Library Exercises674195
+Node: Sample Programs675475
+Node: Running Examples676245
+Node: Clones676973
+Node: Cut Program678197
+Node: Egrep Program687916
+Ref: Egrep Program-Footnote-1695414
+Node: Id Program695524
+Node: Split Program699169
+Ref: Split Program-Footnote-1702617
+Node: Tee Program702745
+Node: Uniq Program705534
+Node: Wc Program712953
+Ref: Wc Program-Footnote-1717203
+Node: Miscellaneous Programs717297
+Node: Dupword Program718510
+Node: Alarm Program720541
+Node: Translate Program725345
+Ref: Translate Program-Footnote-1729910
+Node: Labels Program730180
+Ref: Labels Program-Footnote-1733531
+Node: Word Sorting733615
+Node: History Sorting737686
+Node: Extract Program739522
+Node: Simple Sed747047
+Node: Igawk Program750115
+Ref: Igawk Program-Footnote-1764439
+Ref: Igawk Program-Footnote-2764640
+Ref: Igawk Program-Footnote-3764762
+Node: Anagram Program764877
+Node: Signature Program767934
+Node: Programs Summary769181
+Node: Programs Exercises770374
+Ref: Programs Exercises-Footnote-1774505
+Node: Advanced Features774596
+Node: Nondecimal Data776544
+Node: Array Sorting778134
+Node: Controlling Array Traversal778831
+Ref: Controlling Array Traversal-Footnote-1787164
+Node: Array Sorting Functions787282
+Ref: Array Sorting Functions-Footnote-1791171
+Node: Two-way I/O791367
+Ref: Two-way I/O-Footnote-1796312
+Ref: Two-way I/O-Footnote-2796498
+Node: TCP/IP Networking796580
+Node: Profiling799453
+Node: Advanced Features Summary807000
+Node: Internationalization808933
+Node: I18N and L10N810413
+Node: Explaining gettext811099
+Ref: Explaining gettext-Footnote-1816124
+Ref: Explaining gettext-Footnote-2816308
+Node: Programmer i18n816473
+Ref: Programmer i18n-Footnote-1821339
+Node: Translator i18n821388
+Node: String Extraction822182
+Ref: String Extraction-Footnote-1823313
+Node: Printf Ordering823399
+Ref: Printf Ordering-Footnote-1826185
+Node: I18N Portability826249
+Ref: I18N Portability-Footnote-1828704
+Node: I18N Example828767
+Ref: I18N Example-Footnote-1831570
+Node: Gawk I18N831642
+Node: I18N Summary832280
+Node: Debugger833619
+Node: Debugging834641
+Node: Debugging Concepts835082
+Node: Debugging Terms836935
+Node: Awk Debugging839507
+Node: Sample Debugging Session840401
+Node: Debugger Invocation840921
+Node: Finding The Bug842305
+Node: List of Debugger Commands848780
+Node: Breakpoint Control850113
+Node: Debugger Execution Control853809
+Node: Viewing And Changing Data857173
+Node: Execution Stack860551
+Node: Debugger Info862188
+Node: Miscellaneous Debugger Commands866205
+Node: Readline Support871234
+Node: Limitations872126
+Node: Debugging Summary874240
+Node: Arbitrary Precision Arithmetic875408
+Node: Computer Arithmetic876824
+Ref: table-numeric-ranges880422
+Ref: Computer Arithmetic-Footnote-1881281
+Node: Math Definitions881338
+Ref: table-ieee-formats884626
+Ref: Math Definitions-Footnote-1885230
+Node: MPFR features885335
+Node: FP Math Caution887006
+Ref: FP Math Caution-Footnote-1888056
+Node: Inexactness of computations888425
+Node: Inexact representation889384
+Node: Comparing FP Values890741
+Node: Errors accumulate891823
+Node: Getting Accuracy893256
+Node: Try To Round895918
+Node: Setting precision896817
+Ref: table-predefined-precision-strings897501
+Node: Setting the rounding mode899290
+Ref: table-gawk-rounding-modes899654
+Ref: Setting the rounding mode-Footnote-1903109
+Node: Arbitrary Precision Integers903288
+Ref: Arbitrary Precision Integers-Footnote-1906274
+Node: POSIX Floating Point Problems906423
+Ref: POSIX Floating Point Problems-Footnote-1910296
+Node: Floating point summary910334
+Node: Dynamic Extensions912528
+Node: Extension Intro914080
+Node: Plugin License915346
+Node: Extension Mechanism Outline916143
+Ref: figure-load-extension916571
+Ref: figure-register-new-function918051
+Ref: figure-call-new-function919055
+Node: Extension API Description921041
+Node: Extension API Functions Introduction922491
+Node: General Data Types927315
+Ref: General Data Types-Footnote-1933054
+Node: Memory Allocation Functions933353
+Ref: Memory Allocation Functions-Footnote-1936192
+Node: Constructor Functions936288
+Node: Registration Functions938022
+Node: Extension Functions938707
+Node: Exit Callback Functions941004
+Node: Extension Version String942252
+Node: Input Parsers942917
+Node: Output Wrappers952796
+Node: Two-way processors957311
+Node: Printing Messages959515
+Ref: Printing Messages-Footnote-1960591
+Node: Updating `ERRNO'960743
+Node: Requesting Values961483
+Ref: table-value-types-returned962211
+Node: Accessing Parameters963168
+Node: Symbol Table Access964399
+Node: Symbol table by name964913
+Node: Symbol table by cookie966894
+Ref: Symbol table by cookie-Footnote-1971038
+Node: Cached values971101
+Ref: Cached values-Footnote-1974600
+Node: Array Manipulation974691
+Ref: Array Manipulation-Footnote-1975789
+Node: Array Data Types975826
+Ref: Array Data Types-Footnote-1978481
+Node: Array Functions978573
+Node: Flattening Arrays982427
+Node: Creating Arrays989319
+Node: Extension API Variables994090
+Node: Extension Versioning994726
+Node: Extension API Informational Variables996627
+Node: Extension API Boilerplate997692
+Node: Finding Extensions1001501
+Node: Extension Example1002061
+Node: Internal File Description1002833
+Node: Internal File Ops1006900
+Ref: Internal File Ops-Footnote-11018570
+Node: Using Internal File Ops1018710
+Ref: Using Internal File Ops-Footnote-11021093
+Node: Extension Samples1021366
+Node: Extension Sample File Functions1022892
+Node: Extension Sample Fnmatch1030530
+Node: Extension Sample Fork1032021
+Node: Extension Sample Inplace1033236
+Node: Extension Sample Ord1034911
+Node: Extension Sample Readdir1035747
+Ref: table-readdir-file-types1036623
+Node: Extension Sample Revout1037434
+Node: Extension Sample Rev2way1038024
+Node: Extension Sample Read write array1038764
+Node: Extension Sample Readfile1040704
+Node: Extension Sample Time1041799
+Node: Extension Sample API Tests1043148
+Node: gawkextlib1043639
+Node: Extension summary1046297
+Node: Extension Exercises1049986
+Node: Language History1050708
+Node: V7/SVR3.11052364
+Node: SVR41054545
+Node: POSIX1055990
+Node: BTL1057379
+Node: POSIX/GNU1058113
+Node: Feature History1063677
+Node: Common Extensions1076775
+Node: Ranges and Locales1078099
+Ref: Ranges and Locales-Footnote-11082717
+Ref: Ranges and Locales-Footnote-21082744
+Ref: Ranges and Locales-Footnote-31082978
+Node: Contributors1083199
+Node: History summary1088740
+Node: Installation1090110
+Node: Gawk Distribution1091056
+Node: Getting1091540
+Node: Extracting1092363
+Node: Distribution contents1093998
+Node: Unix Installation1099715
+Node: Quick Installation1100332
+Node: Additional Configuration Options1102756
+Node: Configuration Philosophy1104494
+Node: Non-Unix Installation1106863
+Node: PC Installation1107321
+Node: PC Binary Installation1108640
+Node: PC Compiling1110488
+Ref: PC Compiling-Footnote-11113509
+Node: PC Testing1113618
+Node: PC Using1114794
+Node: Cygwin1118909
+Node: MSYS1119732
+Node: VMS Installation1120232
+Node: VMS Compilation1121024
+Ref: VMS Compilation-Footnote-11122246
+Node: VMS Dynamic Extensions1122304
+Node: VMS Installation Details1123988
+Node: VMS Running1126240
+Node: VMS GNV1129076
+Node: VMS Old Gawk1129810
+Node: Bugs1130280
+Node: Other Versions1134163
+Node: Installation summary1140587
+Node: Notes1141643
+Node: Compatibility Mode1142508
+Node: Additions1143290
+Node: Accessing The Source1144215
+Node: Adding Code1145650
+Node: New Ports1151807
+Node: Derived Files1156289
+Ref: Derived Files-Footnote-11161764
+Ref: Derived Files-Footnote-21161798
+Ref: Derived Files-Footnote-31162394
+Node: Future Extensions1162508
+Node: Implementation Limitations1163114
+Node: Extension Design1164362
+Node: Old Extension Problems1165516
+Ref: Old Extension Problems-Footnote-11167033
+Node: Extension New Mechanism Goals1167090
+Ref: Extension New Mechanism Goals-Footnote-11170450
+Node: Extension Other Design Decisions1170639
+Node: Extension Future Growth1172747
+Node: Old Extension Mechanism1173583
+Node: Notes summary1175345
+Node: Basic Concepts1176531
+Node: Basic High Level1177212
+Ref: figure-general-flow1177484
+Ref: figure-process-flow1178083
+Ref: Basic High Level-Footnote-11181312
+Node: Basic Data Typing1181497
+Node: Glossary1184825
+Node: Copying1216754
+Node: GNU Free Documentation License1254310
+Node: Index1279446

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index df5afc63..7e8d93de 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -19342,8 +19342,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
@@ -20061,13 +20065,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 0723a4c2..125e8401 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -18463,8 +18463,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
@@ -19182,13 +19186,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 97b3d40b..8672cb00 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 4a90beb4..3160494e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -2011,6 +2011,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 97171726..d1bbf4f8 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -2447,6 +2447,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:
@@ -3054,16 +3064,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 41c85c01..f3639b0f 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