diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-02-01 20:54:20 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-02-01 20:54:20 +0200 |
commit | 545cc9691e3d6479053684815d23e6553a7d0a95 (patch) | |
tree | ed2d4bb149410bcb382aa05545a5e3d56289c927 | |
parent | 86cd3e2cb5117c5800997d3bb363b6d5470be3ce (diff) | |
parent | bcb51623b8e156b03c2ae588906e4ed25fa3eba2 (diff) | |
download | egawk-545cc9691e3d6479053684815d23e6553a7d0a95.tar.gz egawk-545cc9691e3d6479053684815d23e6553a7d0a95.tar.bz2 egawk-545cc9691e3d6479053684815d23e6553a7d0a95.zip |
Merge branch 'gawk-4.1-stable'
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | awkgram.c | 2 | ||||
-rw-r--r-- | awkgram.y | 2 | ||||
-rw-r--r-- | doc/ChangeLog | 6 | ||||
-rw-r--r-- | doc/gawk.info | 629 | ||||
-rw-r--r-- | doc/gawk.texi | 12 | ||||
-rw-r--r-- | doc/gawktexi.in | 12 | ||||
-rw-r--r-- | symbol.c | 36 | ||||
-rw-r--r-- | test/ChangeLog | 7 | ||||
-rw-r--r-- | test/Makefile.am | 9 | ||||
-rw-r--r-- | test/Makefile.in | 20 | ||||
-rw-r--r-- | test/Maketests | 10 | ||||
-rw-r--r-- | test/indirectcall.awk | 8 |
14 files changed, 404 insertions, 364 deletions
@@ -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 @@ -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. @@ -4754,7 +4754,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) @@ -2416,7 +2416,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 27dca3dc..22636fe7 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 1c74fc99..0329a038 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -13494,8 +13494,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 @@ -14097,13 +14100,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 @@ -32305,7 +32308,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) @@ -32827,7 +32830,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) @@ -33044,7 +33047,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) @@ -33771,7 +33774,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) @@ -33816,7 +33819,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) @@ -33909,7 +33912,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. @@ -33978,7 +33981,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) @@ -34147,7 +34150,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. @@ -34521,7 +34524,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) @@ -34878,303 +34881,303 @@ Node: Type Functions564425 Node: I18N Functions565576 Node: User-defined567221 Node: Definition Syntax568026 -Ref: Definition Syntax-Footnote-1573525 -Node: Function Example573596 -Ref: Function Example-Footnote-1576515 -Node: Function Caveats576537 -Node: Calling A Function577055 -Node: Variable Scope578013 -Node: Pass By Value/Reference581001 -Node: Return Statement584496 -Node: Dynamic Typing587477 -Node: Indirect Calls588406 -Ref: Indirect Calls-Footnote-1599724 -Node: Functions Summary599852 -Node: Library Functions602554 -Ref: Library Functions-Footnote-1606163 -Ref: Library Functions-Footnote-2606306 -Node: Library Names606477 -Ref: Library Names-Footnote-1609931 -Ref: Library Names-Footnote-2610154 -Node: General Functions610240 -Node: Strtonum Function611343 -Node: Assert Function614365 -Node: Round Function617689 -Node: Cliff Random Function619230 -Node: Ordinal Functions620246 -Ref: Ordinal Functions-Footnote-1623309 -Ref: Ordinal Functions-Footnote-2623561 -Node: Join Function623772 -Ref: Join Function-Footnote-1625541 -Node: Getlocaltime Function625741 -Node: Readfile Function629485 -Node: Shell Quoting631455 -Node: Data File Management632856 -Node: Filetrans Function633488 -Node: Rewind Function637544 -Node: File Checking638931 -Ref: File Checking-Footnote-1640263 -Node: Empty Files640464 -Node: Ignoring Assigns642443 -Node: Getopt Function643994 -Ref: Getopt Function-Footnote-1655456 -Node: Passwd Functions655656 -Ref: Passwd Functions-Footnote-1664493 -Node: Group Functions664581 -Ref: Group Functions-Footnote-1672475 -Node: Walking Arrays672688 -Node: Library Functions Summary674291 -Node: Library Exercises675692 -Node: Sample Programs676972 -Node: Running Examples677742 -Node: Clones678470 -Node: Cut Program679694 -Node: Egrep Program689413 -Ref: Egrep Program-Footnote-1696911 -Node: Id Program697021 -Node: Split Program700666 -Ref: Split Program-Footnote-1704114 -Node: Tee Program704242 -Node: Uniq Program707031 -Node: Wc Program714450 -Ref: Wc Program-Footnote-1718700 -Node: Miscellaneous Programs718794 -Node: Dupword Program720007 -Node: Alarm Program722038 -Node: Translate Program726842 -Ref: Translate Program-Footnote-1731407 -Node: Labels Program731677 -Ref: Labels Program-Footnote-1735028 -Node: Word Sorting735112 -Node: History Sorting739183 -Node: Extract Program741019 -Node: Simple Sed748544 -Node: Igawk Program751612 -Ref: Igawk Program-Footnote-1765936 -Ref: Igawk Program-Footnote-2766137 -Ref: Igawk Program-Footnote-3766259 -Node: Anagram Program766374 -Node: Signature Program769431 -Node: Programs Summary770678 -Node: Programs Exercises771871 -Ref: Programs Exercises-Footnote-1776002 -Node: Advanced Features776093 -Node: Nondecimal Data778041 -Node: Array Sorting779631 -Node: Controlling Array Traversal780328 -Ref: Controlling Array Traversal-Footnote-1788661 -Node: Array Sorting Functions788779 -Ref: Array Sorting Functions-Footnote-1792668 -Node: Two-way I/O792864 -Ref: Two-way I/O-Footnote-1797809 -Ref: Two-way I/O-Footnote-2797995 -Node: TCP/IP Networking798077 -Node: Profiling800950 -Node: Advanced Features Summary809227 -Node: Internationalization811160 -Node: I18N and L10N812640 -Node: Explaining gettext813326 -Ref: Explaining gettext-Footnote-1818351 -Ref: Explaining gettext-Footnote-2818535 -Node: Programmer i18n818700 -Ref: Programmer i18n-Footnote-1823566 -Node: Translator i18n823615 -Node: String Extraction824409 -Ref: String Extraction-Footnote-1825540 -Node: Printf Ordering825626 -Ref: Printf Ordering-Footnote-1828412 -Node: I18N Portability828476 -Ref: I18N Portability-Footnote-1830931 -Node: I18N Example830994 -Ref: I18N Example-Footnote-1833797 -Node: Gawk I18N833869 -Node: I18N Summary834507 -Node: Debugger835846 -Node: Debugging836868 -Node: Debugging Concepts837309 -Node: Debugging Terms839162 -Node: Awk Debugging841734 -Node: Sample Debugging Session842628 -Node: Debugger Invocation843148 -Node: Finding The Bug844532 -Node: List of Debugger Commands851007 -Node: Breakpoint Control852340 -Node: Debugger Execution Control856036 -Node: Viewing And Changing Data859400 -Node: Execution Stack862778 -Node: Debugger Info864415 -Node: Miscellaneous Debugger Commands868432 -Node: Readline Support873461 -Node: Limitations874353 -Node: Debugging Summary876467 -Node: Arbitrary Precision Arithmetic877635 -Node: Computer Arithmetic879051 -Ref: table-numeric-ranges882649 -Ref: Computer Arithmetic-Footnote-1883508 -Node: Math Definitions883565 -Ref: table-ieee-formats886853 -Ref: Math Definitions-Footnote-1887457 -Node: MPFR features887562 -Node: FP Math Caution889233 -Ref: FP Math Caution-Footnote-1890283 -Node: Inexactness of computations890652 -Node: Inexact representation891611 -Node: Comparing FP Values892968 -Node: Errors accumulate894050 -Node: Getting Accuracy895483 -Node: Try To Round898145 -Node: Setting precision899044 -Ref: table-predefined-precision-strings899728 -Node: Setting the rounding mode901517 -Ref: table-gawk-rounding-modes901881 -Ref: Setting the rounding mode-Footnote-1905336 -Node: Arbitrary Precision Integers905515 -Ref: Arbitrary Precision Integers-Footnote-1910415 -Node: POSIX Floating Point Problems910564 -Ref: POSIX Floating Point Problems-Footnote-1914437 -Node: Floating point summary914475 -Node: Dynamic Extensions916669 -Node: Extension Intro918221 -Node: Plugin License919487 -Node: Extension Mechanism Outline920284 -Ref: figure-load-extension920712 -Ref: figure-register-new-function922192 -Ref: figure-call-new-function923196 -Node: Extension API Description925182 -Node: Extension API Functions Introduction926632 -Node: General Data Types931456 -Ref: General Data Types-Footnote-1937195 -Node: Memory Allocation Functions937494 -Ref: Memory Allocation Functions-Footnote-1940333 -Node: Constructor Functions940429 -Node: Registration Functions942163 -Node: Extension Functions942848 -Node: Exit Callback Functions945145 -Node: Extension Version String946393 -Node: Input Parsers947058 -Node: Output Wrappers956937 -Node: Two-way processors961452 -Node: Printing Messages963656 -Ref: Printing Messages-Footnote-1964732 -Node: Updating `ERRNO'964884 -Node: Requesting Values965624 -Ref: table-value-types-returned966352 -Node: Accessing Parameters967309 -Node: Symbol Table Access968540 -Node: Symbol table by name969054 -Node: Symbol table by cookie971035 -Ref: Symbol table by cookie-Footnote-1975179 -Node: Cached values975242 -Ref: Cached values-Footnote-1978741 -Node: Array Manipulation978832 -Ref: Array Manipulation-Footnote-1979930 -Node: Array Data Types979967 -Ref: Array Data Types-Footnote-1982622 -Node: Array Functions982714 -Node: Flattening Arrays986568 -Node: Creating Arrays993460 -Node: Extension API Variables998231 -Node: Extension Versioning998867 -Node: Extension API Informational Variables1000768 -Node: Extension API Boilerplate1001833 -Node: Finding Extensions1005642 -Node: Extension Example1006202 -Node: Internal File Description1006974 -Node: Internal File Ops1011041 -Ref: Internal File Ops-Footnote-11022711 -Node: Using Internal File Ops1022851 -Ref: Using Internal File Ops-Footnote-11025234 -Node: Extension Samples1025507 -Node: Extension Sample File Functions1027033 -Node: Extension Sample Fnmatch1034671 -Node: Extension Sample Fork1036162 -Node: Extension Sample Inplace1037377 -Node: Extension Sample Ord1039052 -Node: Extension Sample Readdir1039888 -Ref: table-readdir-file-types1040764 -Node: Extension Sample Revout1041575 -Node: Extension Sample Rev2way1042165 -Node: Extension Sample Read write array1042905 -Node: Extension Sample Readfile1044845 -Node: Extension Sample Time1045940 -Node: Extension Sample API Tests1047289 -Node: gawkextlib1047780 -Node: Extension summary1050438 -Node: Extension Exercises1054127 -Node: Language History1054849 -Node: V7/SVR3.11056505 -Node: SVR41058686 -Node: POSIX1060131 -Node: BTL1061520 -Node: POSIX/GNU1062254 -Node: Feature History1067878 -Node: Common Extensions1080976 -Node: Ranges and Locales1082300 -Ref: Ranges and Locales-Footnote-11086918 -Ref: Ranges and Locales-Footnote-21086945 -Ref: Ranges and Locales-Footnote-31087179 -Node: Contributors1087400 -Node: History summary1092941 -Node: Installation1094311 -Node: Gawk Distribution1095257 -Node: Getting1095741 -Node: Extracting1096564 -Node: Distribution contents1098199 -Node: Unix Installation1104264 -Node: Quick Installation1104947 -Node: Shell Startup Files1107358 -Node: Additional Configuration Options1108437 -Node: Configuration Philosophy1110176 -Node: Non-Unix Installation1112545 -Node: PC Installation1113003 -Node: PC Binary Installation1114322 -Node: PC Compiling1116170 -Ref: PC Compiling-Footnote-11119191 -Node: PC Testing1119300 -Node: PC Using1120476 -Node: Cygwin1124591 -Node: MSYS1125414 -Node: VMS Installation1125914 -Node: VMS Compilation1126706 -Ref: VMS Compilation-Footnote-11127928 -Node: VMS Dynamic Extensions1127986 -Node: VMS Installation Details1129670 -Node: VMS Running1131922 -Node: VMS GNV1134758 -Node: VMS Old Gawk1135492 -Node: Bugs1135962 -Node: Other Versions1139845 -Node: Installation summary1146269 -Node: Notes1147325 -Node: Compatibility Mode1148190 -Node: Additions1148972 -Node: Accessing The Source1149897 -Node: Adding Code1151332 -Node: New Ports1157489 -Node: Derived Files1161971 -Ref: Derived Files-Footnote-11167446 -Ref: Derived Files-Footnote-21167480 -Ref: Derived Files-Footnote-31168076 -Node: Future Extensions1168190 -Node: Implementation Limitations1168796 -Node: Extension Design1170044 -Node: Old Extension Problems1171198 -Ref: Old Extension Problems-Footnote-11172715 -Node: Extension New Mechanism Goals1172772 -Ref: Extension New Mechanism Goals-Footnote-11176132 -Node: Extension Other Design Decisions1176321 -Node: Extension Future Growth1178429 -Node: Old Extension Mechanism1179265 -Node: Notes summary1181027 -Node: Basic Concepts1182213 -Node: Basic High Level1182894 -Ref: figure-general-flow1183166 -Ref: figure-process-flow1183765 -Ref: Basic High Level-Footnote-11186994 -Node: Basic Data Typing1187179 -Node: Glossary1190507 -Node: Copying1222436 -Node: GNU Free Documentation License1259992 -Node: Index1285128 +Ref: Definition Syntax-Footnote-1573658 +Node: Function Example573729 +Ref: Function Example-Footnote-1576648 +Node: Function Caveats576670 +Node: Calling A Function577188 +Node: Variable Scope578146 +Node: Pass By Value/Reference581134 +Node: Return Statement584629 +Node: Dynamic Typing587610 +Node: Indirect Calls588539 +Ref: Indirect Calls-Footnote-1599841 +Node: Functions Summary599969 +Node: Library Functions602671 +Ref: Library Functions-Footnote-1606280 +Ref: Library Functions-Footnote-2606423 +Node: Library Names606594 +Ref: Library Names-Footnote-1610048 +Ref: Library Names-Footnote-2610271 +Node: General Functions610357 +Node: Strtonum Function611460 +Node: Assert Function614482 +Node: Round Function617806 +Node: Cliff Random Function619347 +Node: Ordinal Functions620363 +Ref: Ordinal Functions-Footnote-1623426 +Ref: Ordinal Functions-Footnote-2623678 +Node: Join Function623889 +Ref: Join Function-Footnote-1625658 +Node: Getlocaltime Function625858 +Node: Readfile Function629602 +Node: Shell Quoting631572 +Node: Data File Management632973 +Node: Filetrans Function633605 +Node: Rewind Function637661 +Node: File Checking639048 +Ref: File Checking-Footnote-1640380 +Node: Empty Files640581 +Node: Ignoring Assigns642560 +Node: Getopt Function644111 +Ref: Getopt Function-Footnote-1655573 +Node: Passwd Functions655773 +Ref: Passwd Functions-Footnote-1664610 +Node: Group Functions664698 +Ref: Group Functions-Footnote-1672592 +Node: Walking Arrays672805 +Node: Library Functions Summary674408 +Node: Library Exercises675809 +Node: Sample Programs677089 +Node: Running Examples677859 +Node: Clones678587 +Node: Cut Program679811 +Node: Egrep Program689530 +Ref: Egrep Program-Footnote-1697028 +Node: Id Program697138 +Node: Split Program700783 +Ref: Split Program-Footnote-1704231 +Node: Tee Program704359 +Node: Uniq Program707148 +Node: Wc Program714567 +Ref: Wc Program-Footnote-1718817 +Node: Miscellaneous Programs718911 +Node: Dupword Program720124 +Node: Alarm Program722155 +Node: Translate Program726959 +Ref: Translate Program-Footnote-1731524 +Node: Labels Program731794 +Ref: Labels Program-Footnote-1735145 +Node: Word Sorting735229 +Node: History Sorting739300 +Node: Extract Program741136 +Node: Simple Sed748661 +Node: Igawk Program751729 +Ref: Igawk Program-Footnote-1766053 +Ref: Igawk Program-Footnote-2766254 +Ref: Igawk Program-Footnote-3766376 +Node: Anagram Program766491 +Node: Signature Program769548 +Node: Programs Summary770795 +Node: Programs Exercises771988 +Ref: Programs Exercises-Footnote-1776119 +Node: Advanced Features776210 +Node: Nondecimal Data778158 +Node: Array Sorting779748 +Node: Controlling Array Traversal780445 +Ref: Controlling Array Traversal-Footnote-1788778 +Node: Array Sorting Functions788896 +Ref: Array Sorting Functions-Footnote-1792785 +Node: Two-way I/O792981 +Ref: Two-way I/O-Footnote-1797926 +Ref: Two-way I/O-Footnote-2798112 +Node: TCP/IP Networking798194 +Node: Profiling801067 +Node: Advanced Features Summary809344 +Node: Internationalization811277 +Node: I18N and L10N812757 +Node: Explaining gettext813443 +Ref: Explaining gettext-Footnote-1818468 +Ref: Explaining gettext-Footnote-2818652 +Node: Programmer i18n818817 +Ref: Programmer i18n-Footnote-1823683 +Node: Translator i18n823732 +Node: String Extraction824526 +Ref: String Extraction-Footnote-1825657 +Node: Printf Ordering825743 +Ref: Printf Ordering-Footnote-1828529 +Node: I18N Portability828593 +Ref: I18N Portability-Footnote-1831048 +Node: I18N Example831111 +Ref: I18N Example-Footnote-1833914 +Node: Gawk I18N833986 +Node: I18N Summary834624 +Node: Debugger835963 +Node: Debugging836985 +Node: Debugging Concepts837426 +Node: Debugging Terms839279 +Node: Awk Debugging841851 +Node: Sample Debugging Session842745 +Node: Debugger Invocation843265 +Node: Finding The Bug844649 +Node: List of Debugger Commands851124 +Node: Breakpoint Control852457 +Node: Debugger Execution Control856153 +Node: Viewing And Changing Data859517 +Node: Execution Stack862895 +Node: Debugger Info864532 +Node: Miscellaneous Debugger Commands868549 +Node: Readline Support873578 +Node: Limitations874470 +Node: Debugging Summary876584 +Node: Arbitrary Precision Arithmetic877752 +Node: Computer Arithmetic879168 +Ref: table-numeric-ranges882766 +Ref: Computer Arithmetic-Footnote-1883625 +Node: Math Definitions883682 +Ref: table-ieee-formats886970 +Ref: Math Definitions-Footnote-1887574 +Node: MPFR features887679 +Node: FP Math Caution889350 +Ref: FP Math Caution-Footnote-1890400 +Node: Inexactness of computations890769 +Node: Inexact representation891728 +Node: Comparing FP Values893085 +Node: Errors accumulate894167 +Node: Getting Accuracy895600 +Node: Try To Round898262 +Node: Setting precision899161 +Ref: table-predefined-precision-strings899845 +Node: Setting the rounding mode901634 +Ref: table-gawk-rounding-modes901998 +Ref: Setting the rounding mode-Footnote-1905453 +Node: Arbitrary Precision Integers905632 +Ref: Arbitrary Precision Integers-Footnote-1910532 +Node: POSIX Floating Point Problems910681 +Ref: POSIX Floating Point Problems-Footnote-1914554 +Node: Floating point summary914592 +Node: Dynamic Extensions916786 +Node: Extension Intro918338 +Node: Plugin License919604 +Node: Extension Mechanism Outline920401 +Ref: figure-load-extension920829 +Ref: figure-register-new-function922309 +Ref: figure-call-new-function923313 +Node: Extension API Description925299 +Node: Extension API Functions Introduction926749 +Node: General Data Types931573 +Ref: General Data Types-Footnote-1937312 +Node: Memory Allocation Functions937611 +Ref: Memory Allocation Functions-Footnote-1940450 +Node: Constructor Functions940546 +Node: Registration Functions942280 +Node: Extension Functions942965 +Node: Exit Callback Functions945262 +Node: Extension Version String946510 +Node: Input Parsers947175 +Node: Output Wrappers957054 +Node: Two-way processors961569 +Node: Printing Messages963773 +Ref: Printing Messages-Footnote-1964849 +Node: Updating `ERRNO'965001 +Node: Requesting Values965741 +Ref: table-value-types-returned966469 +Node: Accessing Parameters967426 +Node: Symbol Table Access968657 +Node: Symbol table by name969171 +Node: Symbol table by cookie971152 +Ref: Symbol table by cookie-Footnote-1975296 +Node: Cached values975359 +Ref: Cached values-Footnote-1978858 +Node: Array Manipulation978949 +Ref: Array Manipulation-Footnote-1980047 +Node: Array Data Types980084 +Ref: Array Data Types-Footnote-1982739 +Node: Array Functions982831 +Node: Flattening Arrays986685 +Node: Creating Arrays993577 +Node: Extension API Variables998348 +Node: Extension Versioning998984 +Node: Extension API Informational Variables1000885 +Node: Extension API Boilerplate1001950 +Node: Finding Extensions1005759 +Node: Extension Example1006319 +Node: Internal File Description1007091 +Node: Internal File Ops1011158 +Ref: Internal File Ops-Footnote-11022828 +Node: Using Internal File Ops1022968 +Ref: Using Internal File Ops-Footnote-11025351 +Node: Extension Samples1025624 +Node: Extension Sample File Functions1027150 +Node: Extension Sample Fnmatch1034788 +Node: Extension Sample Fork1036279 +Node: Extension Sample Inplace1037494 +Node: Extension Sample Ord1039169 +Node: Extension Sample Readdir1040005 +Ref: table-readdir-file-types1040881 +Node: Extension Sample Revout1041692 +Node: Extension Sample Rev2way1042282 +Node: Extension Sample Read write array1043022 +Node: Extension Sample Readfile1044962 +Node: Extension Sample Time1046057 +Node: Extension Sample API Tests1047406 +Node: gawkextlib1047897 +Node: Extension summary1050555 +Node: Extension Exercises1054244 +Node: Language History1054966 +Node: V7/SVR3.11056622 +Node: SVR41058803 +Node: POSIX1060248 +Node: BTL1061637 +Node: POSIX/GNU1062371 +Node: Feature History1067995 +Node: Common Extensions1081093 +Node: Ranges and Locales1082417 +Ref: Ranges and Locales-Footnote-11087035 +Ref: Ranges and Locales-Footnote-21087062 +Ref: Ranges and Locales-Footnote-31087296 +Node: Contributors1087517 +Node: History summary1093058 +Node: Installation1094428 +Node: Gawk Distribution1095374 +Node: Getting1095858 +Node: Extracting1096681 +Node: Distribution contents1098316 +Node: Unix Installation1104381 +Node: Quick Installation1105064 +Node: Shell Startup Files1107475 +Node: Additional Configuration Options1108554 +Node: Configuration Philosophy1110293 +Node: Non-Unix Installation1112662 +Node: PC Installation1113120 +Node: PC Binary Installation1114439 +Node: PC Compiling1116287 +Ref: PC Compiling-Footnote-11119308 +Node: PC Testing1119417 +Node: PC Using1120593 +Node: Cygwin1124708 +Node: MSYS1125531 +Node: VMS Installation1126031 +Node: VMS Compilation1126823 +Ref: VMS Compilation-Footnote-11128045 +Node: VMS Dynamic Extensions1128103 +Node: VMS Installation Details1129787 +Node: VMS Running1132039 +Node: VMS GNV1134875 +Node: VMS Old Gawk1135609 +Node: Bugs1136079 +Node: Other Versions1139962 +Node: Installation summary1146386 +Node: Notes1147442 +Node: Compatibility Mode1148307 +Node: Additions1149089 +Node: Accessing The Source1150014 +Node: Adding Code1151449 +Node: New Ports1157606 +Node: Derived Files1162088 +Ref: Derived Files-Footnote-11167563 +Ref: Derived Files-Footnote-21167597 +Ref: Derived Files-Footnote-31168193 +Node: Future Extensions1168307 +Node: Implementation Limitations1168913 +Node: Extension Design1170161 +Node: Old Extension Problems1171315 +Ref: Old Extension Problems-Footnote-11172832 +Node: Extension New Mechanism Goals1172889 +Ref: Extension New Mechanism Goals-Footnote-11176249 +Node: Extension Other Design Decisions1176438 +Node: Extension Future Growth1178546 +Node: Old Extension Mechanism1179382 +Node: Notes summary1181144 +Node: Basic Concepts1182330 +Node: Basic High Level1183011 +Ref: figure-general-flow1183283 +Ref: figure-process-flow1183882 +Ref: Basic High Level-Footnote-11187111 +Node: Basic Data Typing1187296 +Node: Glossary1190624 +Node: Copying1222553 +Node: GNU Free Documentation License1260109 +Node: Index1285245 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 68512c2d..457a20f2 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -19375,8 +19375,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 @@ -20094,13 +20098,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 f3805887..64a4ef28 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -18496,8 +18496,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 @@ -19215,13 +19219,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 @@ -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 ac031426..e9d5620a 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 a3fe1beb..c4c0b8b3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2026,6 +2026,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 57d28cac..212cb779 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -2461,6 +2461,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: @@ -3068,16 +3078,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 |